brane 0.3.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/AGENTS.md +12 -7
  2. package/CHANGELOG.md +37 -4
  3. package/CONTRIBUTING.md +12 -2
  4. package/DESIGN.md +7 -4
  5. package/README.md +2 -2
  6. package/SECURITY.md +8 -0
  7. package/dist/commands/config.js +17 -0
  8. package/dist/commands/meld.js +38 -10
  9. package/dist/commands/spawn.js +11 -4
  10. package/dist/commands/token.js +2 -1
  11. package/dist/daemon/server.js +88 -84
  12. package/dist/db/schema.js +10 -0
  13. package/dist/db/tokens.js +43 -2
  14. package/dist/shared/app-origin.js +26 -0
  15. package/dist/shared/narrative-menu.js +8 -6
  16. package/dist/shared/view-url.js +39 -20
  17. package/dist/test/app-host-literal.test.js +53 -0
  18. package/dist/test/cors-preflight.test.js +28 -21
  19. package/dist/test/hook-config.test.js +38 -1
  20. package/dist/test/meld.test.js +59 -1
  21. package/dist/test/narrative-menu.test.js +13 -0
  22. package/dist/test/remote-meld.test.js +13 -0
  23. package/dist/test/terminal-size.test.js +36 -0
  24. package/dist/test/token-devices.test.js +59 -0
  25. package/dist/test/view-url.test.js +93 -47
  26. package/dist/test/wrangler-route.test.js +27 -0
  27. package/dist/tmux.js +11 -0
  28. package/docker-entrypoint.sh +15 -2
  29. package/docs/daemon-api.md +4 -4
  30. package/docs/releasing.md +59 -8
  31. package/docs/terminal-mirroring.md +32 -0
  32. package/docs/token-rotation.md +22 -4
  33. package/docs/view-urls.md +26 -6
  34. package/docs/web-app.md +1 -1
  35. package/expo/dist/_expo/static/js/web/{entry-e56efc1291dca7258ea00b8108b033a4.js → entry-e94247f119fdcd3b424a1764233a41d2.js} +47 -45
  36. package/expo/dist/index.html +1 -1
  37. package/expo/dist/sw.js +2 -2
  38. package/package.json +1 -1
  39. package/wiki/shared/index.md +5 -0
@@ -4,11 +4,11 @@ var __BUNDLE_START_TIME__=globalThis.nativePerformanceNow?nativePerformanceNow()
4
4
  'undefined'!=typeof globalThis?globalThis:'undefined'!=typeof global?global:'undefined'!=typeof window&&window;
5
5
  !(function(r){let l=0,n=!0===r.RN$useAlwaysAvailableJSErrorHandling?r.RN$handleException:(r,l)=>{throw r};const t={setGlobalHandler(r){n=r},getGlobalHandler:()=>n,reportError(r){n&&n(r,!1)},reportFatalError(r){n&&n(r,!0)},applyWithGuard(r,n,e,a,o){try{return l++,r.apply(n,e)}catch(r){t.reportError(r)}finally{l--}return null},applyWithGuardIfNeeded:(r,l,n)=>t.inGuard()?r.apply(l,n):(t.applyWithGuard(r,l,n),null),inGuard:()=>!!l,guard(r,l,n){if('function'!=typeof r)return console.warn('A function must be passed to ErrorUtils.guard, got ',r),null;const e=l??r.name??'<generated guard>';return function(...l){return t.applyWithGuard(r,n??this,l,null,e)}}};r.ErrorUtils=t})('undefined'!=typeof globalThis?globalThis:'undefined'!=typeof global?global:'undefined'!=typeof window?window:this);
6
6
  __d(function(g,r,i,a,m,e,d){"use strict";r(d[0])},0,[1]);
7
- __d(function(g,r,i,a,m,e,d){"use strict";r(d[0]);var n=r(d[1]);(0,r(d[2]).renderRootComponent)(n.App)},1,[2,5,991]);
7
+ __d(function(g,r,i,a,m,e,d){"use strict";r(d[0]);var n=r(d[1]);(0,r(d[2]).renderRootComponent)(n.App)},1,[2,5,993]);
8
8
  __d(function(g,r,i,a,m,e,d){"use strict";r(d[0]),r(d[1])},2,[3,4]);
9
9
  __d(function(g,r,i,a,m,e,d){},3,[]);
10
10
  __d(function(g,r,i,a,m,e,d){const _='undefined'==typeof window;globalThis.__webpack_chunk_load__=_=>g[`${__METRO_GLOBAL_PREFIX__}__loadBundleAsync`](_),globalThis.__webpack_require__=o=>{const t=ErrorUtils.reportFatalError;_&&(ErrorUtils.reportFatalError=_=>{throw _});try{return g[`${__METRO_GLOBAL_PREFIX__}__r`](o)}finally{_&&(ErrorUtils.reportFatalError=t)}}},4,[]);
11
- __d(function(g,r,i,a,m,e,d){"use strict";var t=r(d[0]),o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.App=function(){return t.jsx(c.Head.Provider,{children:t.jsx(u.ExpoRoot,{context:n.ctx})})};const n=r(d[1]),u=(o(r(d[2])),r(d[3])),c=r(d[4]);r(d[5])},5,[6,8,11,712,989,990]);
11
+ __d(function(g,r,i,a,m,e,d){"use strict";var t=r(d[0]),o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.App=function(){return t.jsx(c.Head.Provider,{children:t.jsx(u.ExpoRoot,{context:n.ctx})})};const n=r(d[1]),u=(o(r(d[2])),r(d[3])),c=r(d[4]);r(d[5])},5,[6,8,11,712,991,992]);
12
12
  __d(function(g,r,i,a,m,e,d){'use strict';m.exports=r(d[0])},6,[7]);
13
13
  __d(function(g,r,i,a,m,e,d){
14
14
  /**
@@ -22,8 +22,8 @@ __d(function(g,r,i,a,m,e,d){
22
22
  */
23
23
  "use strict";var n=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function o(t,o,f){var l=null;if(void 0!==f&&(l=""+f),void 0!==o.key&&(l=""+o.key),"key"in o)for(var y in f={},o)"key"!==y&&(f[y]=o[y]);else f=o;return o=f.ref,{$$typeof:n,type:t,key:l,ref:void 0!==o?o:null,props:f}}e.Fragment=t,e.jsx=o,e.jsxs=o},7,[]);
24
24
  __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"ctx",{enumerable:!0,get:function(){return t}});const t=r(d[0])},8,[9]);
25
- __d(function(g,r,i,a,m,e,d){const t=Object.defineProperties({},{"./[nid].tsx":{enumerable:!0,get:()=>r(d[0])},"./_layout.tsx":{enumerable:!0,get:()=>r(d[1])},"./index.tsx":{enumerable:!0,get:()=>r(d[2])}});function n(n){return t[n]}n.keys=function(){return Object.keys(t)},n.resolve=function(t){throw new Error('Unimplemented Metro module context functionality')},m.exports=n},9,[10,736,979]);
26
- __d(function(g,r,_i,_a,_m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return ae}});var t=r(_d[0]),n=e(r(_d[1])),o=e(r(_d[2])),a=e(r(_d[3])),l=e(r(_d[4]));r(_d[5]);var s=e(r(_d[6])),i=e(r(_d[7])),c=e(r(_d[8])),u=e(r(_d[9]));r(_d[10]);var d=r(_d[11]),f=r(_d[12]),h=r(_d[13]),b=r(_d[14]),m=e(r(_d[15])),p=e(r(_d[16])),y=e(r(_d[17])),v=r(_d[18]),x=r(_d[19]),w=r(_d[20]),S=r(_d[21]),C=r(_d[22]),T=r(_d[23]),j=r(_d[24]),R=e(r(_d[25])),k=r(_d[26]),P=r(_d[27]),A=r(_d[28]),_=r(_d[29]),I=e(_),E=e(r(_d[30])),L=e(r(_d[31])),M=e(r(_d[32])),N=r(_d[33]),z=r(_d[34]),q=r(_d[35]),$=r(_d[36]),F=r(_d[37]),B=r(_d[38]),H=r(_d[39]);function O(e,t=!1){const n=new Date(e),o=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"][n.getDay()],a=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][n.getMonth()],l=n.getDate(),s=n.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"});if(t)return`${o} ${a} ${l}, ${n.getFullYear()} ${s}`;const i=new Date,c=n.getFullYear()===i.getFullYear();return c&&n.getMonth()===i.getMonth()&&n.getDate()===i.getDate()?`${o} ${s}`:c?`${o} ${a} ${l} ${s}`:`${o} ${a} ${l}, ${n.getFullYear()} ${s}`}function D(e){return"agent_signal"===e}const W=(0,t.memo)(function({uri:e,onPress:n}){const[o,l]=(0,t.useState)(null);(0,t.useEffect)(()=>{a.default.getSize(e,(e,t)=>l({w:e,h:t}),()=>l({w:200,h:150}))},[e]);const i=o?Math.min(200/o.w,150/o.h):1,c=o?Math.round(o.w*i):200,u=o?Math.round(o.h*i):150;return(0,H.jsx)(s.default,{onPress:n,children:(0,H.jsx)(a.default,{source:{uri:e},style:{width:c,height:u,borderRadius:8},resizeMode:"cover"})})}),G=(0,t.memo)(function({item:e,nid:t,agentType:a,foldPath:l,conn:i,selection:c,palette:u=0,onImagePress:d,onForeignPress:f,onFilePress:h,fileHref:m,onTimestampPress:p}){const y=(0,w.useIsSelected)(c,e.seq),v="human_signal"===e.type;const x=D(e.type),C=(0,z.isSystemEvent)(e.type),T=i&&e.payloads?e.payloads.filter(b.isInlinePayload):[],j=i&&e.payloads?e.payloads.filter(e=>!(0,b.isInlinePayload)(e)):[],R=(0,H.jsxs)(H.Fragment,{children:[(e.source||C)&&(0,H.jsxs)(n.default,{style:le.bubbleSourceRow,children:[x&&e.source&&(0,H.jsx)(s.default,{onPress:()=>f?.(e.source,e.time),style:le.bubbleSourcePress,children:(0,H.jsx)(o.default,{style:[le.bubbleSource,le.bubbleSourceLink,{color:(0,S.speakerColor)(e.source,u)}],children:e.source})}),(0,H.jsx)(s.default,{onPress:()=>p?.(e.seq),style:[le.bubbleSourcePress,x&&le.bubbleSourceAfterLink],children:(0,H.jsx)(o.default,{style:[le.bubbleSource,x&&e.source&&{color:(0,S.speakerColor)(e.source,u)},C&&le.bubbleSourceSystem],children:C?`system (${t}:${e.seq})`:v?`you (${t}:${e.seq})`:x?`(${t}:${e.seq})`:`${e.source}:${e.seq}`})}),(0,H.jsx)(L.default,{text:`${t}:${e.seq}`,size:9,padding:3,marginLeft:1,translateY:-1})]}),e.content?(0,H.jsx)(k.MarkdownContent,{content:C?(0,z.systemLine)({type:e.type,content:e.content},{agent:a??(0,z.agentTypeOf)(t),fold:l}):e.content,foreign:x,system:C,onFilePress:h,fileHref:m}):null,T.length>0&&i&&(0,H.jsx)(n.default,{style:le.payloadsContainer,children:T.map(e=>(0,H.jsx)(W,{uri:(0,b.payloadUrl)(i,e),onPress:()=>d?.((0,b.payloadUrl)(i,e))},e))}),j.length>0&&i&&(0,H.jsx)(n.default,{style:le.payloadsContainer,children:j.map(e=>{const t=(0,A.downloadNameFor)(e),n=(0,b.payloadUrl)(i,e);return(0,H.jsx)(s.default,{onPress:()=>{"undefined"!=typeof window&&(0,A.downloadUrl)(n,t).catch(e=>console.error("Payload download failed:",e))},style:le.filePayload,children:(0,H.jsx)(o.default,{style:le.filePayloadText,children:t})},e)})}),(0,H.jsx)(s.default,{onPress:()=>p?.(e.seq),style:le.bubbleTimePress,children:(0,H.jsx)(o.default,{style:le.bubbleTime,children:O(e.time)})})]}),P=[le.bubble,C?le.bubbleSystem:v?le.bubbleOperator:x?[le.bubbleForeign,{backgroundColor:(0,S.speakerBgColor)(e.source||"unknown",u)}]:le.bubbleAgent,y&&le.bubbleSelected];return(0,H.jsx)(n.default,{style:[le.bubbleRow,v?le.bubbleRowRight:x||C?le.bubbleRowCenter:le.bubbleRowLeft],children:(0,H.jsx)(n.default,{dataSet:{bubble:String(e.seq)},style:P,children:R})})}),U=(0,t.memo)(function({conn:e,nid:l,loadEvents:i,chatActive:c,selection:u,onDeselect:d}){const h=(0,w.useSelectedSeqs)(u),[m,p]=(0,t.useState)(!1),[y,v]=(0,t.useState)(!1),[x,S]=(0,t.useState)([]),C=(0,t.useRef)(null),T=(0,t.useRef)(null),j=(0,t.useRef)(!1),R=(0,t.useRef)(!1),k=(0,f.useIsFocused)(),P=c&&k;R.current=P;const A=(0,t.useRef)(""),_=(0,t.useRef)(null),I=`brane:draft:${l}`;(0,t.useEffect)(()=>{try{const e=localStorage.getItem(I);if(e&&(A.current=e,v(e.trim().length>0),T.current)){T.current.value=e}}catch{}return()=>{_.current&&clearTimeout(_.current);try{const e=A.current;e.trim()?localStorage.setItem(I,e):localStorage.removeItem(I)}catch{}}},[I]);const E=(0,t.useCallback)(e=>{A.current=e;const t=0===e.trim().length;v(e=>e===!t?e:!t),_.current&&clearTimeout(_.current),_.current=setTimeout(()=>{try{e.trim()?localStorage.setItem(I,e):localStorage.removeItem(I)}catch{}},300)},[I]);(0,t.useEffect)(()=>{const e=T.current;if(!e)return;if(!P)return void(document.activeElement===e&&e.blur());if(!window.matchMedia?.("(pointer: fine)").matches)return;const t=requestAnimationFrame(()=>{try{e.focus({preventScroll:!0})}catch{e.focus()}});return()=>cancelAnimationFrame(t)},[P]),(0,t.useEffect)(()=>{if(!P)return;const e=e=>{if(!R.current)return;const t=e.target,n=t?.tagName;if("INPUT"===n||"TEXTAREA"===n||t?.isContentEditable)return;if(e.metaKey||e.ctrlKey||e.altKey)return;if(e.isComposing)return;if(1!==e.key.length)return;const o=T.current;if(!o)return;e.preventDefault();const a=(o.value||"")+e.key;o.value=a,o.focus({preventScroll:!0});try{o.setSelectionRange(a.length,a.length)}catch{}E(a)};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[P,E]),(0,t.useEffect)(()=>{if(!k)return;const e=e=>{const t=e.clipboardData?.items;if(t)for(const e of Array.from(t)){if(!e.type.startsWith("image/"))continue;const t=e.getAsFile();if(!t)continue;const n=new FileReader;n.onload=()=>{const e=n.result,o=e.split(",")[1],a=t.type.split("/")[1]||"png";S(t=>[...t,{id:`${Date.now()}_${Math.random().toString(36).slice(2,6)}`,filename:`paste_${Date.now()}.${a}`,data:o,uri:e}])},n.readAsDataURL(t)}};return document.addEventListener("paste",e),()=>document.removeEventListener("paste",e)},[k]);const L=(0,t.useCallback)(()=>{if(!C.current){const e=document.createElement("input");e.type="file",e.accept="*/*",e.multiple=!0,e.style.display="none",e.addEventListener("change",()=>{const t=e.files;if(t){for(const e of Array.from(t)){const t=new FileReader;t.onload=()=>{const n=t.result,o=n.split(",")[1];S(t=>[...t,{id:String(Date.now())+e.name,filename:e.name,data:o,uri:n}])},t.readAsDataURL(e)}e.value=""}}),document.body.appendChild(e),C.current=e}C.current.click()},[]);(0,t.useEffect)(()=>()=>{C.current&&(C.current.remove(),C.current=null)},[]);const M=(0,t.useCallback)(e=>{S(t=>t.filter(t=>t.id!==e))},[]),N=(0,t.useCallback)(async()=>{const t=A.current.trim();if(!e||!l||!t&&0===x.length)return;const n=x.length>0?x.map(e=>({filename:e.filename,data:e.data})):void 0;p(!0),S([]);try{await(0,b.sendSignal)(e,l,t||"(attachment)","web",n,[...h]),h.length>0&&d(),A.current="",v(!1);try{localStorage.removeItem(I)}catch{}if(T.current){const e=T.current;"function"==typeof e.clear?e.clear():e.value=""}j.current=!0,i()}catch{}finally{p(!1)}},[e,l,I,x,h,d,i]);return(0,t.useEffect)(()=>{if(m)return;if(!j.current)return;if(j.current=!1,!R.current)return;const e=T.current;if(e)try{e.focus({preventScroll:!0})}catch{e.focus()}},[m]),(0,H.jsxs)(H.Fragment,{children:[x.length>0&&(0,H.jsx)(n.default,{style:le.pendingPayloadsRow,dataSet:{composer:"1"},children:x.map(e=>(0,H.jsxs)(n.default,{style:le.pendingPayloadThumb,children:[(0,b.isInlinePayload)(e.filename)?(0,H.jsx)(a.default,{source:{uri:e.uri},style:le.pendingPayloadImage,resizeMode:"cover"}):(0,H.jsx)(n.default,{style:[le.pendingPayloadImage,{justifyContent:"center",alignItems:"center",backgroundColor:"rgba(255,255,255,0.1)"}],children:(0,H.jsx)(o.default,{style:{color:"#aaa",fontSize:10},numberOfLines:2,children:e.filename.split(".").pop()})}),(0,H.jsx)(s.default,{style:le.pendingPayloadRemove,onPress:()=>M(e.id),children:(0,H.jsx)(o.default,{style:le.pendingPayloadRemoveText,children:"\xd7"})})]},e.id))}),(0,H.jsxs)(n.default,{style:le.inputRow,dataSet:{composer:"1"},children:[(0,H.jsx)(s.default,{onPress:L,accessibilityLabel:"Attach file",style:({hovered:e,pressed:t})=>[le.attachButton,(e||t)&&le.circleGlowActive],children:(0,H.jsx)(o.default,{style:le.attachText,children:"\ud83e\uddeb"})}),(0,H.jsx)("textarea",{ref:T,style:{flex:1,backgroundColor:"#111",color:"#e0e0e0",borderRadius:20,paddingLeft:16,paddingRight:16,paddingTop:6,paddingBottom:6,fontSize:16,border:"1px solid #555",resize:"none",overflow:"auto",maxHeight:120,fieldSizing:"content",fontFamily:"system-ui, -apple-system, sans-serif",outline:"none",lineHeight:"22px",boxSizing:"border-box"},onChange:e=>E(e.target.value),placeholder:"Compose message...",disabled:m,autoComplete:"off",autoCorrect:"on",spellCheck:!0,inputMode:"text",rows:1}),(0,H.jsx)(s.default,{style:[le.sendButton,!m&&(y||x.length>0)&&le.circleGlowSend],onPress:N,disabled:m||!y&&0===x.length,children:(0,H.jsx)(o.default,{style:[le.sendText,(m||!y&&0===x.length)&&le.sendTextInactive],children:"\ud83e\udd8b"})})]})]})}),X=(0,t.memo)(function({nid:e,narrativeSummary:a,narrativeFoldPath:l,narrativeRole:i,narrativeStatus:c,narrativeMcpConnected:u,narrativeAwaiting:d,palette:f,narrativeCreatedAt:h,narrativeLastActivity:b,cost:m,archived:p,selection:S,openSwitcher:C,onDownload:R,onTerminate:k,onRevive:P,onTwin:A,onArchiveToggle:_,onRecolor:I,onShowQr:E,onIsolateDaemon:L,isIsolated:M}){const[N,z]=(0,t.useState)(!1),q=(0,w.useSelectedSeqs)(S).length,$=!!(i||l||h),F=(0,x.isAwaiting)({mcpConnected:u,awaiting:d})?(0,x.awaitingGlow)((0,T.glowHueFor)(e)):void 0;return(0,H.jsxs)(n.default,{style:[le.header,le.glowTransition,F?{boxShadow:F}:null],children:[(0,H.jsxs)(s.default,{style:le.headerTitleContainer,onPress:C,children:[(0,H.jsx)(j.NarrativeIdentity,{id:e,foldPath:l,align:"center"}),$?(0,H.jsx)(j.NarrativeMetaLine,{role:i,cost:m,createdAt:h??void 0,lastActivity:b,status:c,mcpConnected:u,style:{marginTop:4}}):null,a?(0,H.jsx)("div",{style:{position:"relative",marginRight:8},children:(0,H.jsx)("div",{className:"no-scrollbar",style:{overflowX:"auto",overflowY:"hidden",scrollbarWidth:"none",WebkitOverflowScrolling:"touch",maskImage:"linear-gradient(to right, #000 calc(100% - 60px), transparent)",WebkitMaskImage:"linear-gradient(to right, #000 calc(100% - 60px), transparent)"},children:(0,H.jsx)(o.default,{style:le.headerSummary,children:a})})}):null]}),(0,H.jsxs)("div",{style:{position:"relative"},children:[(0,H.jsx)(s.default,{onPress:()=>z(e=>!e),style:le.reloadButton,hitSlop:8,children:(0,H.jsx)(o.default,{style:[le.reloadText,N&&le.reloadTextActive],children:"\ud83e\udda0"})}),N&&(0,H.jsx)(y.default,{items:(0,v.narrativeMenuItems)({role:i,status:c,mcpConnected:u,archived:p,isIsolated:M,selectedCount:q,onMeld:()=>{z(!1),E()},onIsolate:()=>{z(!1),L()},onExport:e=>{z(!1),R(e)},onRecolor:()=>{z(!1),I()},onTwin:()=>{z(!1),A()},onRevive:()=>{z(!1),P()},onEnd:()=>{z(!1),k()},onArchiveToggle:()=>{z(!1),_()}}),onClose:()=>z(!1)})]})]})}),Y={headerShown:!1},V=new Map;function J(e){return null!=e.cost_amount&&e.cost_unit?{amount:e.cost_amount,unit:e.cost_unit}:null}const K=300,Q={flex:1,minHeight:0,display:"flex",flexDirection:"column-reverse",overflowY:"auto",overflowX:"hidden"},Z={marginBottom:"auto"},ee=.3;function te(e,t){const n=e?.querySelector(`[data-seq="${t}"]`);if(!e||!n)return!1;const o=n.getBoundingClientRect().top-e.getBoundingClientRect().top;return e.scrollTop+=o-e.clientHeight*ee,!0}const ne='button, a[href], [role="button"], [role="link"], [role="menuitem"]';function re(e){return e?V.get(e)??{}:{}}function oe(e,t){const n=V.get(e)??{};V.set(e,Object.assign({},n,t))}function ae(){const e=(0,f.useIsFocused)(),{nid:y,scrollTo:S,scrollToSeq:k,tab:A,pinned:L,path:z,line:O}=(0,d.useLocalSearchParams)(),D=(0,d.useRouter)(),{conn:W,subscribe:V,unsubscribe:ee,onHint:ae,onMeta:se,onStatus:ie,onToolUses:ce,narrativeIds:ue}=(0,h.useBrane)(),[de,fe]=(0,t.useState)([]),[he,ge]=(0,t.useState)(()=>new Map),be=(0,t.useRef)(0),me=(0,t.useRef)(Number.MAX_SAFE_INTEGER),[pe,ye]=(0,t.useState)(()=>z??""),[ve,xe]=(0,t.useState)(()=>(0,F.parseLineSpec)(O).line),[we,Se]=(0,t.useState)(()=>(0,F.parseLineSpec)(O).lineEnd),Ce=y?`brane:files:${y}`:null,Te=y?`brane:tabs:${y}`:null,je=(0,t.useRef)(null),[Re,ke]=(0,t.useState)(()=>(0,F.parseActiveTab)(A)),[Pe,Ae]=(0,t.useState)(()=>(0,F.parsePinnedTabs)(L)),Ie=(0,t.useRef)(y??null);(0,t.useEffect)(()=>{if(!y)return;if(Ie.current===y)return;Ie.current=y;const e=(0,F.parseLineSpec)(O);ye(z??""),xe(e.line),Se(e.lineEnd)},[y]);const Ee=(0,t.useRef)(null);(0,t.useEffect)(()=>{if(!Ce||!y)return;if(Ee.current===y)return;if(Ee.current=y,z)return;let e=null;try{e=sessionStorage.getItem(Ce)}catch{return}if(!e)return;let t=null;try{t=JSON.parse(e)}catch{}if(!t?.path)return;ye(t.path),xe(t.line),Se(t.lineEnd);const n=t.line?t.lineEnd&&t.lineEnd>t.line?`${t.line}-${t.lineEnd}`:String(t.line):void 0;D.setParams({path:t.path,line:n})},[y]),(0,t.useEffect)(()=>{if(Ce)try{if(pe){const e={path:pe};ve&&(e.line=ve),we&&(e.lineEnd=we),sessionStorage.setItem(Ce,JSON.stringify(e))}else sessionStorage.removeItem(Ce)}catch{}},[Ce,pe,ve,we]),(0,t.useEffect)(()=>{if(Te&&je.current===y)try{sessionStorage.setItem(Te,JSON.stringify({tab:Re,pinned:(0,F.serializePinned)(Pe)}))}catch{}},[Te,y,Re,Pe]);const Le=(0,t.useMemo)(()=>(0,B.visiblePanes)(Re,Pe),[Re,Pe]),Me=(0,t.useMemo)(()=>{const e=e=>{const t=Le.indexOf(e),n=Le.length;return t<0||1===n?{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:t<0?0:1,backgroundColor:"#111",pointerEvents:t<0?"none":"auto"}:{position:"absolute",top:0,bottom:0,left:t/n*100+"%",width:100/n+"%",zIndex:1,backgroundColor:"#111",borderLeftWidth:t>0?c.default.hairlineWidth:0,borderLeftColor:"#555"}};return{chat:e("chat"),terminal:e("terminal"),files:e("files")}},[Le]),Ne=1===Le.length,[ze,qe]=(0,t.useState)(null),[$e,Fe]=(0,t.useState)(!1),[Be,He]=(0,t.useState)(!1),[Oe,De]=(0,t.useState)(()=>re(y).summary??null),[We,Ge]=(0,t.useState)(()=>re(y).agent_type??null),[Ue,Xe]=(0,t.useState)(()=>re(y).role??null),[Ye,Ve]=(0,t.useState)(()=>re(y).archived??!1),[Je,Ke]=(0,t.useState)(()=>re(y).fold_path??null),[Qe,Ze]=(0,t.useState)(()=>re(y).status??null),[et,tt]=(0,t.useState)(()=>re(y).mcp_connected??!1),[nt,rt]=(0,t.useState)(!1),[ot,at]=(0,t.useState)(()=>re(y).created_at??null),[lt,st]=(0,t.useState)(()=>re(y).last_activity??null),[it,ct]=(0,t.useState)(()=>J(re(y)));(0,t.useEffect)(()=>{const e=re(y);De(e.summary??null),Ge(e.agent_type??null),Xe(e.role??null),Ve(e.archived??!1),Ke(e.fold_path??null),Ze(e.status??null),tt(e.mcp_connected??!1),rt(!1),at(e.created_at??null),st(e.last_activity??null),ct(J(e))},[y]);const[ut,dt]=(0,t.useState)(!1),[ft,ht]=(0,t.useState)([]),[gt,bt]=(0,t.useState)(!1),[mt,pt]=(0,t.useState)(null),yt=(0,t.useMemo)(()=>(0,q.collectKnownNids)({viewing:y,pushed:[...ue].map(e=>({id:e})),listed:mt}),[y,ue,mt]),vt=(0,w.useMessageSelection)(y),xt=(0,t.useRef)(0),[wt,St]=(0,t.useState)(()=>(0,C.readRecolorSalt)(y));(0,t.useEffect)(()=>St((0,C.readRecolorSalt)(y)),[y]);const Ct=(0,t.useCallback)(()=>{(0,T.recolorGlowHue)(y),St((0,C.bumpRecolorSalt)(y))},[y]),Tt=(0,t.useRef)(null),jt=(0,t.useRef)(null),Rt=(0,t.useRef)(!1),kt=(0,t.useRef)(!0),[Pt,At]=(0,t.useState)(!0),[_t,It]=(0,t.useState)(!0),[Et,Lt]=(0,t.useState)(!0),Mt=(0,t.useRef)(null),Nt=(0,t.useRef)(null),zt=(0,t.useRef)(!0);zt.current=Le.includes("chat");const qt=(0,t.useRef)(0),$t=(0,t.useRef)(S?Number(S):0),Ft=(0,t.useRef)(k?Number(k):0),Bt=(0,t.useRef)(!1),[Ht,Ot]=(0,t.useState)(!1),[Dt,Wt]=(0,t.useState)(!0),Gt=(0,t.useRef)(!1),Ut=(0,t.useRef)(!1),Xt=(0,t.useRef)(null),Yt=(0,t.useRef)(!1),Vt=(0,t.useRef)(!1);(0,t.useEffect)(()=>{if(Le.includes("chat")&&!Yt.current){const e=Ft.current,t=$t.current;if((e||t)&&0===de.length)return;Yt.current=!0,qt.current=Date.now();let n=-1;if(e&&de.length>0)n=de.findIndex(t=>t.seq===e),n>=0&&vt.replace([e]),Ft.current=0;else if(t&&de.length>0){let e=1/0;for(let o=0;o<de.length;o++){const a=Math.abs(de[o].time-t);a<e&&(e=a,n=o)}$t.current=0}if(n>=0){Ut.current=!0;const e=setTimeout(()=>{Ut.current=!1},2e3);return te(Tt.current,de[n].seq),()=>clearTimeout(e)}kt.current=!0,At(!0)}Le.includes("terminal")&&(Vt.current=!0)},[Le,de.length]);const Jt=(0,t.useCallback)(()=>{Tt.current?.scrollTo({top:0})},[]),Kt=(0,t.useCallback)(()=>{const e=Tt.current;e?.scrollTo({top:-e.scrollHeight,behavior:"smooth"})},[]),Qt=(0,t.useRef)(!1),Zt=(0,t.useRef)(!1),en=(0,t.useCallback)(async()=>{if(W&&y)if(Qt.current)Zt.current=!0;else{Qt.current=!0;try{do{Zt.current=!1;const e=await(0,b.fetchEvents)(W,y,xt.current);e.events.length>0&&(fe(t=>{const n=t.length>0?t[t.length-1].seq:0,o=e.events.filter(e=>e.seq>n);return o.length>0?[...t,...o]:t}),xt.current=e.events[e.events.length-1].seq)}while(Zt.current)}finally{Qt.current=!1}}},[W,y]),tn=(0,t.useCallback)(async()=>{if(W&&y&&!Gt.current&&Dt){Gt.current=!0;try{const e=de.length>0?de[0].seq:1/0,t=await(0,b.fetchEventsBefore)(W,y,e,50);t.events.length>0&&fe(e=>{const n=e.length>0?e[0].seq:1/0,o=t.events.filter(e=>e.seq<n);return o.length>0?[...o,...e]:e}),(t.events.length<50||t.events.length>0&&t.events[0].seq<=t.min_seq)&&Wt(!1)}finally{Gt.current=!1}}},[W,y,de,Dt]),nn=(0,t.useCallback)(e=>{0!==e.length&&ge(t=>{let n=null;for(const o of e){const e=(n??t).get(o.dedup_key);e&&e.rev>=o.rev||(n||(n=new Map(t)),n.set(o.dedup_key,o),o.rev>be.current&&(be.current=o.rev))}return n??t})},[]);(0,t.useEffect)(()=>{if(!W||!y||0===de.length)return;const e=Math.max(0,de[0].seq-1),t=me.current;e>=t||(me.current=e,(0,b.fetchAllToolUseWindow)(W,y,{afterSeqGte:e,afterSeqLt:t===Number.MAX_SAFE_INTEGER?void 0:t},nn).catch(()=>{me.current=Number.MAX_SAFE_INTEGER}))},[W,y,de,nn]),(0,t.useEffect)(()=>{if(W&&y)return ce((e,t,n)=>{e===y&&(t?nn(t):(0,b.fetchAllToolUsesSince)(W,y,be.current,nn).catch(()=>{me.current=Number.MAX_SAFE_INTEGER}))})},[W,y,ce,nn]),(0,t.useEffect)(()=>{if(!W||!y)return;const e=`${W.host}|${W.token}|${y}`;if(Xt.current===e)return;Xt.current=e,fe([]),Wt(!0),xt.current=0,ge(new Map),be.current=0,me.current=Number.MAX_SAFE_INTEGER;const t=Ft.current;$t.current;(async()=>{try{if(t){const e=Math.floor(25),n=Math.max(0,t-e-1),o=await(0,b.fetchEvents)(W,y,n,50);o.events.length>0?(fe(o.events),xt.current=o.events[o.events.length-1].seq,Wt(o.events[0].seq>1)):(xt.current=o.seq,Wt(!1))}else{const e=await(0,b.fetchEventsBefore)(W,y,Number.MAX_SAFE_INTEGER,50);e.events.length>0?(fe(e.events),xt.current=e.events[e.events.length-1].seq,(e.events.length<50||e.events[0].seq<=e.min_seq)&&Wt(!1)):(xt.current=0,Wt(!1))}}catch{en()}})()},[W,y]);const rn=(0,t.useCallback)(e=>{if(!y)return;e.summary&&(De(e.summary),oe(y,{summary:e.summary})),e.agent_type&&(Ge(e.agent_type),oe(y,{agent_type:e.agent_type})),e.role&&(Xe(e.role),oe(y,{role:e.role})),Ke(e.fold_path??null),oe(y,{fold_path:e.fold_path??null});const t=!!e.archived;Ve(t),oe(y,{archived:t}),e.status&&(Ze(e.status),oe(y,{status:e.status}));const n=!!e.mcp_connected;tt(n),oe(y,{mcp_connected:n}),rt(!!e.awaiting),at(e.created_at??null),oe(y,{created_at:e.created_at}),st(e.last_activity??null),oe(y,{last_activity:e.last_activity??null}),ct(J({cost_amount:e.cost_amount,cost_unit:e.cost_unit})),oe(y,{cost_amount:e.cost_amount??null,cost_unit:e.cost_unit??null})},[y]);(0,t.useEffect)(()=>{W&&y&&(0,b.fetchNarrative)(W,y).then(rn).catch(()=>{})},[W,y,rn]),(0,t.useEffect)(()=>{W&&y&&(0,b.fetchNarratives)(W,{archived:!0}).then(e=>{pt(e);const t=e.find(e=>e.id===y);t&&rn(t)}).catch(e=>{console.warn("narrative list sweep failed; linkifying from pushed ids only",e)})},[W,y,rn]),(0,t.useEffect)(()=>{if(!y)return;V(y,xt.current);const e=ae((e,t)=>{if(e===y){en();const e=Date.now();st(e),oe(y,{last_activity:e})}});return()=>{ee(y),e()}},[y,V,ee,ae,en]),(0,t.useEffect)(()=>{if(y)return se((e,t,n,o)=>{e===y&&(n&&(De(n),oe(y,{summary:n})),null!=o&&(ct(o),oe(y,{cost_amount:o.amount,cost_unit:o.unit})))})},[y,se]),(0,t.useEffect)(()=>{if(y)return ie((e,t)=>{e===y&&("mcp_connected"===t?(tt(!0),oe(y,{mcp_connected:!0})):"mcp_disconnected"===t?(tt(!1),rt(!1),oe(y,{mcp_connected:!1})):t===x.AWAITING_STATUS||t===x.NOT_AWAITING_STATUS?rt(t===x.AWAITING_STATUS):"active"!==t&&"ended"!==t||(Ze(t),oe(y,{status:t})))})},[y,ie]);const on=(0,t.useCallback)(async e=>{W&&y&&("all"!==e?await(0,v.openNarrativeExport)(W,y,[...vt.getSelected()],"excluded"===e?"except":"only"):await(0,v.openNarrativeExport)(W,y))},[W,y,vt]),an=(0,t.useCallback)(async()=>{if(kt.current)Bt.current=!0,kt.current=!1,At(!1),Kt(),setTimeout(()=>{Bt.current=!1},600);else{const e=setTimeout(()=>Ot(!0),150);try{await en()}finally{clearTimeout(e),Ot(!1)}kt.current=!0,At(!0),Jt()}},[en,Jt,Kt]),ln=(0,t.useCallback)(()=>{_t?Mt.current?.scrollToTop():Mt.current?.scrollToBottom()},[_t]),sn=(0,t.useCallback)(()=>{Et?Nt.current?.scrollToTop():Nt.current?.scrollToBottom()},[Et]),cn=(0,t.useCallback)((e,t,n,o,a)=>{D.setParams((0,F.viewParams)(e,t,n,o,a))},[D]),un=(0,t.useCallback)(e=>{ke(t=>t===e?t:(cn(e,Pe,pe,ve,we),e))},[cn,Pe,pe,ve,we]),dn=(0,t.useCallback)(e=>{if(Re===e)return;const{pinned:t}=(0,B.selectPane)(Re,Pe,e);ke(e),Ae(t),cn(e,t,pe,ve,we)},[cn,Re,Pe,pe,ve,we]),fn=(0,t.useCallback)(()=>{const{pinned:e}=(0,B.selectPane)(Re,Pe,"terminal");ke("terminal"),Ae(e),cn("terminal",e,pe,ve,we),setTimeout(()=>Mt.current?.focus(),60)},[cn,Re,Pe,pe,ve,we]);(0,t.useEffect)(()=>{if(!e)return;if(Le.length<2)return;const t=e=>{const t=e.target;if(t?.closest?.(ne))return;const n=t?.closest?.("[data-pane]"),o=n?.getAttribute("data-pane");"chat"!==o&&"terminal"!==o&&"files"!==o||(dn(o),"terminal"===o&&Mt.current?.focus())};return document.addEventListener("pointerdown",t,!0),()=>document.removeEventListener("pointerdown",t,!0)},[e,Le.length,dn]);const hn=(0,t.useCallback)(e=>{Ae(t=>{const n=new Set(t);return n.has(e)?n.delete(e):n.add(e),cn(Re,n,pe,ve,we),n})},[cn,Re,pe,ve,we]),[gn,bn]=(0,t.useState)(null),mn=(0,t.useCallback)((e,t)=>{(e!==y||t)&&D.push((0,P.narrativeHref)(e,t))},[D,y]),pn=(0,t.useCallback)((e,t)=>{D.push(`/${e}?scrollTo=${t}`)},[D]),yn=(0,t.useCallback)(e=>{const t=vt.toggle(e);D.setParams({scrollToSeq:t?String(e):void 0})},[D,vt]),vn=(0,t.useCallback)(()=>{0!==vt.clear().length&&D.setParams({scrollToSeq:void 0})},[D,vt]);(0,t.useEffect)(()=>{if(!e)return;const t=e=>{const t=e.target;t?.closest&&t.closest('[data-pane="chat"]')&&(t.closest("[data-bubble], [data-chrome]")||t.closest("input, textarea, [data-composer]")||window.getSelection()?.toString()||vn())};return document.addEventListener("click",t),()=>document.removeEventListener("click",t)},[e,vn]);const xn=(0,t.useCallback)((e,t,n)=>{ye(e),xe(t),Se(n);"files"===Re||Pe.has("files")?cn(Re,Pe,e,t,n):(ke("files"),cn("files",Pe,e,t,n))},[cn,Re,Pe]),wn=(0,t.useCallback)(e=>{const{path:t,line:n,lineEnd:o}=(0,_.parseRelLink)(e);xn(t,n,o)},[xn]),Sn=(0,t.useCallback)(e=>{if(!y)return;const{path:t,line:n,lineEnd:o}=(0,_.parseRelLink)(e);return(0,P.fileHref)(y,t,n,o,(0,F.serializePinned)(Pe)||void 0)},[y,Pe]),Cn=(0,t.useRef)(Re);Cn.current=Re;const Tn=(0,t.useRef)(Pe);Tn.current=Pe,(0,t.useEffect)(()=>{const e=(0,F.parseActiveTab)(A);e!==Cn.current&&ke(e);const t=(0,F.parsePinnedTabs)(L),n=Tn.current;(t.size!==n.size||[...t].some(e=>!n.has(e)))&&Ae(t)},[A,L]),(0,t.useEffect)(()=>{if(!Te||!y)return;if(je.current===y)return;if(je.current=y,A||L)return;let e=null;try{e=sessionStorage.getItem(Te)}catch{return}if(!e)return;let t=null;try{t=JSON.parse(e)}catch{}t&&(ke((0,F.parseActiveTab)(t.tab)),Ae((0,F.parsePinnedTabs)(t.pinned)))},[y]);const jn=(0,t.useMemo)(()=>{const e=new Map;if(0===he.size||0===de.length)return e;const t=de[0].seq,n=de[de.length-1].seq;for(const o of he.values()){let a=Math.min(o.after_seq,n);if(0===a){if(1!==t)continue;a=0}else if(a<t)continue;const l=e.get(a);l?l.push(o):e.set(a,[o])}for(const t of e.values())t.sort((e,t)=>e.started_at-t.started_at||e.dedup_key.localeCompare(t.dedup_key));return e},[de,he]),Rn=(0,t.useCallback)(e=>W&&y?(0,b.fetchToolUse)(W,y,e):Promise.reject(new Error("no connection")),[W,y]),kn=(0,t.useCallback)(({item:e})=>{const t=1===e.seq?jn.get(0):void 0,n=jn.get(e.seq),o=(0,H.jsx)(G,{item:e,nid:y,agentType:We,foldPath:Je,conn:W,selection:vt,palette:wt,onImagePress:qe,onForeignPress:pn,onFilePress:wn,fileHref:Sn,onTimestampPress:yn});return t||n?(0,H.jsxs)(H.Fragment,{children:[t&&(0,H.jsx)(m.default,{rows:t,onNarrativePress:mn,onFetchFull:Rn}),o,n&&(0,H.jsx)(m.default,{rows:n,onNarrativePress:mn,onFetchFull:Rn})]}):o},[y,We,Je,W,vt,wt,pn,mn,wn,Sn,yn,jn,Rn]),Pn=(0,t.useMemo)(()=>(0,F.viewParams)(Re,Pe,pe,ve,we),[Re,Pe,pe,ve,we]),An=(0,t.useCallback)(()=>{if(!W||!y)return;if("undefined"==typeof window)return;const e=(0,F.buildIsolateUrl)({hostname:window.location.hostname,protocol:window.location.protocol,search:window.location.search,path:`/${y}`,conn:W,view:Pn});window.open(e,"_blank","noopener,noreferrer")},[W,y,Pn]),_n=(0,t.useCallback)(async()=>{if(!W||!y)return;const e=!Ye;Ve(e),oe(y,{archived:e});try{await(0,b.archiveNarrative)(W,y,e)}catch{Ve(!e),oe(y,{archived:!e})}},[W,y,Ye]),In=(0,t.useCallback)(()=>{W&&(dt(!0),bt(!0),(0,b.fetchNarratives)(W).then(e=>{const t=e.filter(e=>e.mcp_connected||"active"===e.status||e.id===y);ht((0,$.sortNarratives)(t))}).catch(()=>{}).finally(()=>bt(!1)))},[W,y]);return(0,H.jsx)(u.default,{style:le.container,behavior:void 0,keyboardVerticalOffset:90,children:(0,H.jsxs)(N.MarkdownLinksProvider,{knownNarrativeIds:yt,onNarrativePress:mn,onProtocolPress:bn,children:[(0,H.jsx)(d.Stack.Screen,{options:Y}),(0,H.jsx)(X,{nid:y,narrativeSummary:Oe,narrativeFoldPath:Je,narrativeRole:Ue,narrativeStatus:Qe,narrativeMcpConnected:et,narrativeAwaiting:nt,palette:wt,narrativeCreatedAt:ot,narrativeLastActivity:lt,cost:(0,b.formatCost)(it?.amount,it?.unit),archived:Ye,selection:vt,openSwitcher:In,onDownload:on,onTerminate:()=>{fn(),Mt.current?.terminate()},onRevive:()=>{(0,v.revivesAsTwin)(Ue)||fn(),Mt.current?.revive()},onTwin:()=>He(!0),onArchiveToggle:_n,onRecolor:Ct,onShowQr:()=>Fe(!0),onIsolateDaemon:An,isIsolated:"undefined"!=typeof window&&(0,F.isIsolatedHost)(window.location.hostname)}),(0,H.jsx)(n.default,{style:le.tabBar,children:F.CANONICAL_TABS.map((e,t)=>{const a=Re===e,l=Pe.has(e),i=a||l,c="chat"===e?"Chat":"terminal"===e?"Terminal":"Files",u="chat"===e?Pt:"terminal"===e?_t:Et,d="chat"===e?an:"terminal"===e?ln:sn;return(0,H.jsxs)(n.default,{style:[le.tab,t>0&&le.tabDivider,a&&le.tabActive],children:[(0,H.jsx)(s.default,{style:le.tabLabel,onPress:()=>un(e),children:(0,H.jsx)(o.default,{style:[le.tabText,a&&le.tabTextActive],children:c})}),(0,H.jsx)(s.default,{style:le.tabPin,onPress:()=>hn(e),hitSlop:6,children:(0,H.jsx)(o.default,{style:[le.tabPinIcon,l?le.tabPinOn:le.tabPinOff],children:"\ud83d\udccc"})}),(0,H.jsx)(s.default,{style:le.tabArrowPress,onPress:d,disabled:!i,hitSlop:6,children:i?"chat"===e&&Ht?(0,H.jsx)(o.default,{style:le.tabArrowText,children:"\u267b\ufe0f"}):(0,H.jsx)(o.default,{style:le.tabArrowText,children:u?"\u2191":"\u2193"}):(0,H.jsx)(o.default,{style:le.tabArrowText})})]},e)})}),(0,H.jsxs)(n.default,Object.assign({style:{flex:1,overflow:"hidden",position:"relative"}},Ne?{onTouchStart:e=>{const t=e.nativeEvent;jt.current={x:t.pageX,y:t.pageY}},onTouchMove:e=>{if(!jt.current)return;const t=e.nativeEvent,n=Math.abs(t.pageX-jt.current.x),o=Math.abs(t.pageY-jt.current.y);n>15&&n>1.5*o&&!Rt.current&&(Rt.current=!0)},onTouchEnd:e=>{if(!jt.current)return;const t=e.nativeEvent,n=t.pageX-jt.current.x,o=t.pageY-jt.current.y;jt.current=null,Rt.current=!1;if(!("undefined"!=typeof window&&!!window.getSelection()?.toString())&&Math.abs(n)>60&&Math.abs(n)>1.5*Math.abs(o)){const e=Le[0],t=F.CANONICAL_TABS.indexOf(e),o=n<0?t+1:t-1;o>=0&&o<F.CANONICAL_TABS.length&&un(F.CANONICAL_TABS[o])}}}:{},{children:[(0,H.jsxs)(n.default,{style:Me.chat,dataSet:{pane:"chat"},children:[(0,H.jsx)("div",{ref:Tt,style:Q,onScroll:e=>{const t=e.currentTarget,n=t.scrollTop>-50;n===kt.current||Bt.current||(kt.current=n,At(n));const o=t.scrollHeight-t.clientHeight+t.scrollTop,a=Date.now()-qt.current;o<200&&Dt&&!Gt.current&&!Ut.current&&zt.current&&qt.current>0&&a>K&&tn()},children:(0,H.jsx)(n.default,{style:[le.list,Z],children:de.map(e=>(0,H.jsx)("div",{"data-seq":e.seq,children:kn({item:e})},e.seq))})}),(0,H.jsx)(U,{conn:W,nid:y,loadEvents:en,chatActive:"chat"===Re,selection:vt,onDeselect:vn})]}),W&&y&&(0,H.jsx)(n.default,{style:Me.terminal,dataSet:{pane:"terminal"},children:(0,H.jsx)(p.default,{ref:Mt,conn:W,nid:y,active:Le.includes("terminal"),keyboardActive:"terminal"===Re&&!ut&&!Be&&null===ze,agentType:We,role:Ue,onAtBottomChange:It,onTwin:()=>He(!0),onRevived:e=>D.push((0,F.terminalOnlyHref)(e))})}),W&&y&&(0,H.jsx)(n.default,{style:Me.files,dataSet:{pane:"files"},children:(0,H.jsx)(I.default,{ref:Nt,conn:W,nid:y,path:pe,line:ve,lineEnd:we,active:Le.includes("files"),onPathChange:xn,onImagePress:qe,onAtBottomChange:Lt})})]})),(0,H.jsx)(i.default,{visible:ut,transparent:!0,animationType:"fade",onRequestClose:()=>dt(!1),children:(0,H.jsx)(s.default,{style:le.switcherOverlay,onPress:()=>dt(!1),children:(0,H.jsxs)(n.default,{style:le.switcherContent,children:[(0,H.jsxs)(n.default,{style:le.switcherTitleRow,children:[(0,H.jsx)(o.default,{style:le.switcherTitle,children:"Switch narrative"}),(0,H.jsx)(s.default,{hitSlop:8,onPress:()=>{dt(!1),D.push("/")},children:(0,H.jsx)(o.default,{style:le.switcherListLink,children:"All narratives"})})]}),(0,H.jsx)(l.default,{data:ft,keyExtractor:e=>e.id,style:le.switcherList,ListEmptyComponent:(0,H.jsx)(o.default,{style:le.switcherEmpty,children:gt?"Loading\u2026":"No active narratives"}),renderItem:({item:e})=>{const t="ended"===e.status&&!e.mcp_connected,n=(0,x.isAwaiting)({mcpConnected:e.mcp_connected,awaiting:e.awaiting})?(0,x.awaitingGlow)((0,T.glowHueFor)(e.id)):void 0;return(0,H.jsxs)(s.default,{style:[le.switcherItem,e.id===y&&le.switcherItemActive,t&&le.switcherItemEnded,n?{boxShadow:n}:null],onPress:()=>{dt(!1),e.id!==y&&D.push(`/${e.id}`)},children:[(0,H.jsx)(j.NarrativeIdentity,{id:e.id,foldPath:e.fold_path,titleStyle:t?{color:"#666"}:void 0,copyMarginLeft:5,dimmed:t}),(0,H.jsx)(j.NarrativeMetaLine,{role:e.role,cost:(0,b.formatCost)(e.cost_amount,e.cost_unit),createdAt:e.created_at,lastActivity:e.last_activity,status:e.status,mcpConnected:e.mcp_connected,dimmed:t,style:{marginTop:4}}),e.summary&&(0,H.jsx)("div",{style:{position:"relative"},children:(0,H.jsx)("div",{className:"no-scrollbar",style:{overflowX:"auto",overflowY:"hidden",scrollbarWidth:"none",WebkitOverflowScrolling:"touch",maskImage:"linear-gradient(to right, #000 calc(100% - 40px), transparent)",WebkitMaskImage:"linear-gradient(to right, #000 calc(100% - 40px), transparent)"},children:(0,H.jsx)(o.default,{style:[le.switcherItemSummary,t&&{color:"#555"}],children:e.summary})})})]})}}),(0,H.jsx)(s.default,{style:le.switcherCancel,onPress:()=>dt(!1),children:(0,H.jsx)(o.default,{style:le.switcherCancelText,children:"Cancel"})})]})})}),(0,H.jsx)(R.default,{visible:$e,conn:W,path:`/${y}`,view:Pn,onClose:()=>Fe(!1)}),(0,H.jsx)(E.default,{visible:Be,conn:W,re:y,defaultFoldPath:Je,onClose:()=>He(!1),onSpawned:e=>{He(!1),D.push(`/${e.id}`)}}),(0,H.jsx)(i.default,{visible:null!==ze,transparent:!0,animationType:"fade",onRequestClose:()=>qe(null),children:(0,H.jsxs)(s.default,{style:le.lightboxBackdrop,onPress:()=>qe(null),children:[ze&&(0,H.jsx)(a.default,{source:{uri:ze},style:le.lightboxImage,resizeMode:"contain"}),(0,H.jsx)(o.default,{style:le.lightboxHint,children:"Tap anywhere to close"})]})}),gn&&W&&(0,H.jsx)(N.MarkdownLinksProvider,{onNarrativePress:(e,t)=>{bn(null),mn(e,t)},children:(0,H.jsx)(M.default,{conn:W,target:{source:"protocols",slug:gn},onClose:()=>bn(null)})})]})})}const le=c.default.create({container:{flex:1},glowTransition:{transitionProperty:"box-shadow",transitionDuration:"400ms"},header:{flexDirection:"row",alignItems:"center",backgroundColor:"#1a1a1e",paddingHorizontal:4,paddingVertical:6,borderBottomWidth:c.default.hairlineWidth,borderBottomColor:"rgb(216, 216, 216)",position:"relative",zIndex:10},tabBar:{flexDirection:"row",borderBottomWidth:c.default.hairlineWidth,borderBottomColor:"#555",backgroundColor:"#111"},tab:{width:100/F.CANONICAL_TABS.length+"%",position:"relative"},tabDivider:{borderLeftWidth:c.default.hairlineWidth,borderLeftColor:"#555"},tabActive:{borderBottomWidth:2,borderBottomColor:"#4caf50"},tabLabel:{flex:1,paddingVertical:10,paddingHorizontal:36,alignItems:"center",justifyContent:"center"},tabPin:{position:"absolute",left:0,top:0,bottom:0,width:36,alignItems:"center",justifyContent:"center"},tabPinIcon:{fontSize:12},tabPinOn:{opacity:1},tabPinOff:{opacity:.25},tabArrowPress:{position:"absolute",right:0,top:0,bottom:0,width:36,alignItems:"center",justifyContent:"center"},tabText:{color:"#666",fontSize:14,fontWeight:"600"},tabTextActive:{color:"#4caf50"},tabArrowText:{color:"#8fd4b4",fontSize:16,fontWeight:"400"},headerTitleContainer:{flexDirection:"column",alignItems:"stretch",justifyContent:"center",flex:1,minWidth:0,paddingHorizontal:8},headerSubtitle:{color:"#888",fontSize:12,fontFamily:"monospace",marginTop:1},headerSummary:{color:"#9a9aa0",fontSize:12,lineHeight:12,whiteSpace:"nowrap"},list:{paddingHorizontal:12,paddingVertical:8},bubbleRow:{marginBottom:6,flexDirection:"row"},bubbleRowLeft:{justifyContent:"flex-start"},bubbleRowRight:{justifyContent:"flex-end"},bubbleRowCenter:{justifyContent:"center"},bubble:{maxWidth:"85%",borderRadius:16,paddingHorizontal:14,paddingVertical:10,borderWidth:1.5,borderColor:"transparent",borderStyle:"solid"},bubbleAgent:{backgroundColor:"#1c1c1e",borderBottomLeftRadius:4},bubbleOperator:{backgroundColor:"#1a4a7a",borderBottomRightRadius:4},bubbleForeign:{borderRadius:12},bubbleSystem:{backgroundColor:"transparent",borderWidth:1,borderStyle:"dashed",borderColor:"#3a3a3c",borderRadius:12},bubbleSelected:{borderColor:"#5b9bd5"},bubbleSourceRow:{flexDirection:"row",alignItems:"center",alignSelf:"flex-start",marginBottom:3},bubbleSourcePress:{alignSelf:"flex-start"},bubbleSource:{color:"#4caf50",fontSize:11,fontFamily:"monospace"},bubbleSourceLink:{textDecorationLine:"underline"},bubbleSourceAfterLink:{marginLeft:4},bubbleSourceSystem:{color:"#8a8a8e"},bubbleTimePress:{alignSelf:"flex-end",marginTop:4},bubbleTime:{color:"#666",fontSize:11,textAlign:"right"},inputRow:{flexDirection:"row",padding:8,paddingBottom:8,borderTopWidth:1,borderTopColor:"rgb(216, 216, 216)",backgroundColor:"#1a1a1a",alignItems:"flex-end"},input:{flex:1,backgroundColor:"#111",color:"#e0e0e0",borderRadius:20,paddingHorizontal:16,paddingVertical:8,fontSize:15,borderWidth:1,borderColor:"#555",maxHeight:120,minHeight:36},sendButton:Object.assign({marginLeft:8,width:36,height:36,borderRadius:18,backgroundColor:"#1c1c1e",borderWidth:1,borderColor:"#555",justifyContent:"center",alignItems:"center"},{transition:"box-shadow 160ms ease, border-color 160ms ease"}),sendText:{fontSize:20,lineHeight:20,transform:[{translateX:-1},{translateY:1},{rotate:"45deg"}]},sendTextInactive:{opacity:.35},attachButton:Object.assign({width:36,height:36,borderRadius:18,backgroundColor:"#1c1c1e",justifyContent:"center",alignItems:"center",marginRight:8,borderWidth:1,borderColor:"#555"},{transition:"box-shadow 160ms ease, border-color 160ms ease"}),attachText:{fontSize:20,lineHeight:20,marginTop:-3},circleGlowActive:Object.assign({borderColor:"rgba(255, 130, 180, 0.6)"},{boxShadow:["0 0 10px rgba(255, 130, 180, 0.9)","0 0 25px rgba(255, 110, 165, 0.7)","0 0 50px rgba(255, 100, 155, 0.4)"].join(", ")}),circleGlowSend:Object.assign({borderColor:"rgba(90, 230, 200, 0.6)"},{boxShadow:["0 0 10px rgba(90, 230, 200, 0.9)","0 0 25px rgba(70, 215, 190, 0.7)","0 0 50px rgba(60, 200, 180, 0.4)"].join(", ")}),payloadsContainer:{marginTop:6,gap:4},filePayload:{backgroundColor:"rgba(255,255,255,0.1)",borderRadius:6,paddingHorizontal:10,paddingVertical:6},filePayloadText:{color:"#6cf",fontSize:13},pendingPayloadsRow:{flexDirection:"row",paddingHorizontal:12,paddingTop:8,gap:8,backgroundColor:"#111"},pendingPayloadThumb:{position:"relative",width:60,height:60},pendingPayloadImage:{width:60,height:60,borderRadius:8,borderWidth:1,borderColor:"#555"},pendingPayloadRemove:{position:"absolute",top:-6,right:-6,width:20,height:20,borderRadius:10,backgroundColor:"#c00",justifyContent:"center",alignItems:"center"},pendingPayloadRemoveText:{color:"#fff",fontSize:14,fontWeight:"700",lineHeight:16},switcherOverlay:{flex:1,backgroundColor:"rgba(0,0,0,0.6)",justifyContent:"center",alignItems:"center",padding:24},switcherContent:{backgroundColor:"#1e1e1e",borderRadius:12,paddingTop:20,paddingHorizontal:20,paddingBottom:8,width:"100%",maxWidth:400,maxHeight:"70%"},switcherTitleRow:{flexDirection:"row",alignItems:"baseline",justifyContent:"space-between",marginBottom:16},switcherTitle:{color:"#e0e0e0",fontSize:18,fontWeight:"600"},switcherListLink:{color:"#8fd4b4",fontSize:14},switcherList:{flexGrow:0,padding:4,margin:-4},switcherItem:{paddingVertical:12,paddingHorizontal:12,borderRadius:8,backgroundColor:"#2a2a2a",marginBottom:8},switcherItemActive:{outlineWidth:2,outlineStyle:"solid",outlineColor:"#4caf50",outlineOffset:2},switcherItemEnded:{opacity:.5},switcherItemSummary:{color:"#9a9aa0",fontSize:12,lineHeight:12,whiteSpace:"nowrap"},switcherEmpty:{color:"#888",fontSize:14,textAlign:"center",paddingVertical:20},switcherCancel:{paddingVertical:12,alignItems:"center",marginTop:4},switcherCancelText:{color:"#888",fontSize:15},lightboxBackdrop:{flex:1,backgroundColor:"rgba(0, 0, 0, 0.95)",justifyContent:"center",alignItems:"center",padding:8},lightboxImage:{width:"100%",height:"92%"},lightboxHint:{color:"#888",fontSize:14,marginTop:20},reloadButton:{paddingHorizontal:8,paddingVertical:4,marginRight:4},reloadText:Object.assign({fontSize:20},{transition:"text-shadow 160ms ease"}),reloadTextActive:Object.assign({},{textShadow:["0 0 10px rgba(140, 230, 170, 0.9)","0 0 25px rgba(120, 215, 155, 0.7)","0 0 50px rgba(100, 200, 145, 0.4)","0 2px 15px rgba(130, 220, 165, 0.6)"].join(", ")})})},10,[11,13,105,106,113,145,146,153,26,160,116,161,165,736,745,758,761,773,769,753,774,771,770,776,778,780,786,760,958,959,972,779,973,950,749,976,977,747,978,6]);
25
+ __d(function(g,r,i,a,m,e,d){const t=Object.defineProperties({},{"./[nid].tsx":{enumerable:!0,get:()=>r(d[0])},"./_layout.tsx":{enumerable:!0,get:()=>r(d[1])},"./index.tsx":{enumerable:!0,get:()=>r(d[2])}});function n(n){return t[n]}n.keys=function(){return Object.keys(t)},n.resolve=function(t){throw new Error('Unimplemented Metro module context functionality')},m.exports=n},9,[10,736,981]);
26
+ __d(function(g,r,_i,_a,_m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return le}});var t=r(_d[0]),n=e(r(_d[1])),o=e(r(_d[2])),a=e(r(_d[3])),l=e(r(_d[4]));r(_d[5]);var s=e(r(_d[6])),i=e(r(_d[7])),c=e(r(_d[8])),u=e(r(_d[9]));r(_d[10]);var d=r(_d[11]),f=r(_d[12]),h=r(_d[13]),b=r(_d[14]),m=e(r(_d[15])),p=e(r(_d[16])),y=e(r(_d[17])),v=r(_d[18]),x=r(_d[19]),w=r(_d[20]),S=r(_d[21]),C=r(_d[22]),T=r(_d[23]),j=r(_d[24]),R=e(r(_d[25])),k=r(_d[26]),P=r(_d[27]),A=r(_d[28]),I=r(_d[29]),_=e(I),E=e(r(_d[30])),L=e(r(_d[31])),M=e(r(_d[32])),N=r(_d[33]),z=r(_d[34]),q=r(_d[35]),$=r(_d[36]),F=r(_d[37]),B=r(_d[38]),H=r(_d[39]),O=r(_d[40]);function D(e,t=!1){const n=new Date(e),o=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"][n.getDay()],a=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][n.getMonth()],l=n.getDate(),s=n.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"});if(t)return`${o} ${a} ${l}, ${n.getFullYear()} ${s}`;const i=new Date,c=n.getFullYear()===i.getFullYear();return c&&n.getMonth()===i.getMonth()&&n.getDate()===i.getDate()?`${o} ${s}`:c?`${o} ${a} ${l} ${s}`:`${o} ${a} ${l}, ${n.getFullYear()} ${s}`}function W(e){return"agent_signal"===e}const G=(0,t.memo)(function({uri:e,onPress:n}){const[o,l]=(0,t.useState)(null);(0,t.useEffect)(()=>{a.default.getSize(e,(e,t)=>l({w:e,h:t}),()=>l({w:200,h:150}))},[e]);const i=o?Math.min(200/o.w,150/o.h):1,c=o?Math.round(o.w*i):200,u=o?Math.round(o.h*i):150;return(0,O.jsx)(s.default,{onPress:n,children:(0,O.jsx)(a.default,{source:{uri:e},style:{width:c,height:u,borderRadius:8},resizeMode:"cover"})})}),U=(0,t.memo)(function({item:e,nid:t,agentType:a,foldPath:l,conn:i,selection:c,palette:u=0,onImagePress:d,onForeignPress:f,onFilePress:h,fileHref:m,onTimestampPress:p}){const y=(0,w.useIsSelected)(c,e.seq),v="human_signal"===e.type;const x=W(e.type),C=(0,z.isSystemEvent)(e.type),T=i&&e.payloads?e.payloads.filter(b.isInlinePayload):[],j=i&&e.payloads?e.payloads.filter(e=>!(0,b.isInlinePayload)(e)):[],R=(0,O.jsxs)(O.Fragment,{children:[(e.source||C)&&(0,O.jsxs)(n.default,{style:se.bubbleSourceRow,children:[x&&e.source&&(0,O.jsx)(s.default,{onPress:()=>f?.(e.source,e.time),style:se.bubbleSourcePress,children:(0,O.jsx)(o.default,{style:[se.bubbleSource,se.bubbleSourceLink,{color:(0,S.speakerColor)(e.source,u)}],children:e.source})}),(0,O.jsx)(s.default,{onPress:()=>p?.(e.seq),style:[se.bubbleSourcePress,x&&se.bubbleSourceAfterLink],children:(0,O.jsx)(o.default,{style:[se.bubbleSource,x&&e.source&&{color:(0,S.speakerColor)(e.source,u)},C&&se.bubbleSourceSystem],children:C?`system (${t}:${e.seq})`:v?`you (${t}:${e.seq})`:x?`(${t}:${e.seq})`:`${e.source}:${e.seq}`})}),(0,O.jsx)(L.default,{text:`${t}:${e.seq}`,size:9,padding:3,marginLeft:1,translateY:-1})]}),e.content?(0,O.jsx)(k.MarkdownContent,{content:C?(0,z.systemLine)({type:e.type,content:e.content},{agent:a??(0,z.agentTypeOf)(t),fold:l}):e.content,foreign:x,system:C,onFilePress:h,fileHref:m}):null,T.length>0&&i&&(0,O.jsx)(n.default,{style:se.payloadsContainer,children:T.map(e=>(0,O.jsx)(G,{uri:(0,b.payloadUrl)(i,e),onPress:()=>d?.((0,b.payloadUrl)(i,e))},e))}),j.length>0&&i&&(0,O.jsx)(n.default,{style:se.payloadsContainer,children:j.map(e=>{const t=(0,A.downloadNameFor)(e),n=(0,b.payloadUrl)(i,e);return(0,O.jsx)(s.default,{onPress:()=>{"undefined"!=typeof window&&(0,A.downloadUrl)(n,t).catch(e=>console.error("Payload download failed:",e))},style:se.filePayload,children:(0,O.jsx)(o.default,{style:se.filePayloadText,children:t})},e)})}),(0,O.jsx)(s.default,{onPress:()=>p?.(e.seq),style:se.bubbleTimePress,children:(0,O.jsx)(o.default,{style:se.bubbleTime,children:D(e.time)})})]}),P=[se.bubble,C?se.bubbleSystem:v?se.bubbleOperator:x?[se.bubbleForeign,{backgroundColor:(0,S.speakerBgColor)(e.source||"unknown",u)}]:se.bubbleAgent,y&&se.bubbleSelected];return(0,O.jsx)(n.default,{style:[se.bubbleRow,v?se.bubbleRowRight:x||C?se.bubbleRowCenter:se.bubbleRowLeft],children:(0,O.jsx)(n.default,{dataSet:{bubble:String(e.seq)},style:P,children:R})})}),X=(0,t.memo)(function({conn:e,nid:l,loadEvents:i,chatActive:c,selection:u,onDeselect:d}){const h=(0,w.useSelectedSeqs)(u),[m,p]=(0,t.useState)(!1),[y,v]=(0,t.useState)(!1),[x,S]=(0,t.useState)([]),C=(0,t.useRef)(null),T=(0,t.useRef)(null),j=(0,t.useRef)(!1),R=(0,t.useRef)(!1),k=(0,f.useIsFocused)(),P=c&&k;R.current=P;const A=(0,t.useRef)(""),I=(0,t.useRef)(null),_=`brane:draft:${l}`;(0,t.useEffect)(()=>{try{const e=localStorage.getItem(_);if(e&&(A.current=e,v(e.trim().length>0),T.current)){T.current.value=e}}catch{}return()=>{I.current&&clearTimeout(I.current);try{const e=A.current;e.trim()?localStorage.setItem(_,e):localStorage.removeItem(_)}catch{}}},[_]);const E=(0,t.useCallback)(e=>{A.current=e;const t=0===e.trim().length;v(e=>e===!t?e:!t),I.current&&clearTimeout(I.current),I.current=setTimeout(()=>{try{e.trim()?localStorage.setItem(_,e):localStorage.removeItem(_)}catch{}},300)},[_]);(0,t.useEffect)(()=>{const e=T.current;if(!e)return;if(!P)return void(document.activeElement===e&&e.blur());if(!window.matchMedia?.("(pointer: fine)").matches)return;const t=requestAnimationFrame(()=>{try{e.focus({preventScroll:!0})}catch{e.focus()}});return()=>cancelAnimationFrame(t)},[P]),(0,t.useEffect)(()=>{if(!P)return;const e=e=>{if(!R.current)return;const t=e.target,n=t?.tagName;if("INPUT"===n||"TEXTAREA"===n||t?.isContentEditable)return;if(e.metaKey||e.ctrlKey||e.altKey)return;if(e.isComposing)return;if(1!==e.key.length)return;const o=T.current;if(!o)return;e.preventDefault();const a=(o.value||"")+e.key;o.value=a,o.focus({preventScroll:!0});try{o.setSelectionRange(a.length,a.length)}catch{}E(a)};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[P,E]),(0,t.useEffect)(()=>{if(!k)return;const e=e=>{const t=e.clipboardData?.items;if(t)for(const e of Array.from(t)){if(!e.type.startsWith("image/"))continue;const t=e.getAsFile();if(!t)continue;const n=new FileReader;n.onload=()=>{const e=n.result,o=e.split(",")[1],a=t.type.split("/")[1]||"png";S(t=>[...t,{id:`${Date.now()}_${Math.random().toString(36).slice(2,6)}`,filename:`paste_${Date.now()}.${a}`,data:o,uri:e}])},n.readAsDataURL(t)}};return document.addEventListener("paste",e),()=>document.removeEventListener("paste",e)},[k]);const L=(0,t.useCallback)(()=>{if(!C.current){const e=document.createElement("input");e.type="file",e.accept="*/*",e.multiple=!0,e.style.display="none",e.addEventListener("change",()=>{const t=e.files;if(t){for(const e of Array.from(t)){const t=new FileReader;t.onload=()=>{const n=t.result,o=n.split(",")[1];S(t=>[...t,{id:String(Date.now())+e.name,filename:e.name,data:o,uri:n}])},t.readAsDataURL(e)}e.value=""}}),document.body.appendChild(e),C.current=e}C.current.click()},[]);(0,t.useEffect)(()=>()=>{C.current&&(C.current.remove(),C.current=null)},[]);const M=(0,t.useCallback)(e=>{S(t=>t.filter(t=>t.id!==e))},[]),N=(0,t.useCallback)(async()=>{const t=A.current.trim();if(!e||!l||!t&&0===x.length)return;const n=x.length>0?x.map(e=>({filename:e.filename,data:e.data})):void 0;p(!0),S([]);try{await(0,b.sendSignal)(e,l,t||"(attachment)","web",n,[...h]),h.length>0&&d(),A.current="",v(!1);try{localStorage.removeItem(_)}catch{}if(T.current){const e=T.current;"function"==typeof e.clear?e.clear():e.value=""}j.current=!0,i()}catch{}finally{p(!1)}},[e,l,_,x,h,d,i]);return(0,t.useEffect)(()=>{if(m)return;if(!j.current)return;if(j.current=!1,!R.current)return;const e=T.current;if(e)try{e.focus({preventScroll:!0})}catch{e.focus()}},[m]),(0,O.jsxs)(O.Fragment,{children:[x.length>0&&(0,O.jsx)(n.default,{style:se.pendingPayloadsRow,dataSet:{composer:"1"},children:x.map(e=>(0,O.jsxs)(n.default,{style:se.pendingPayloadThumb,children:[(0,b.isInlinePayload)(e.filename)?(0,O.jsx)(a.default,{source:{uri:e.uri},style:se.pendingPayloadImage,resizeMode:"cover"}):(0,O.jsx)(n.default,{style:[se.pendingPayloadImage,{justifyContent:"center",alignItems:"center",backgroundColor:"rgba(255,255,255,0.1)"}],children:(0,O.jsx)(o.default,{style:{color:"#aaa",fontSize:10},numberOfLines:2,children:e.filename.split(".").pop()})}),(0,O.jsx)(s.default,{style:se.pendingPayloadRemove,onPress:()=>M(e.id),children:(0,O.jsx)(o.default,{style:se.pendingPayloadRemoveText,children:"\xd7"})})]},e.id))}),(0,O.jsxs)(n.default,{style:se.inputRow,dataSet:{composer:"1"},children:[(0,O.jsx)(s.default,{onPress:L,accessibilityLabel:"Attach file",style:({hovered:e,pressed:t})=>[se.attachButton,(e||t)&&se.circleGlowActive],children:(0,O.jsx)(o.default,{style:se.attachText,children:"\ud83e\uddeb"})}),(0,O.jsx)("textarea",{ref:T,style:{flex:1,backgroundColor:"#111",color:"#e0e0e0",borderRadius:20,paddingLeft:16,paddingRight:16,paddingTop:6,paddingBottom:6,fontSize:16,border:"1px solid #555",resize:"none",overflow:"auto",maxHeight:120,fieldSizing:"content",fontFamily:"system-ui, -apple-system, sans-serif",outline:"none",lineHeight:"22px",boxSizing:"border-box"},onChange:e=>E(e.target.value),placeholder:"Compose message...",disabled:m,autoComplete:"off",autoCorrect:"on",spellCheck:!0,inputMode:"text",rows:1}),(0,O.jsx)(s.default,{style:[se.sendButton,!m&&(y||x.length>0)&&se.circleGlowSend],onPress:N,disabled:m||!y&&0===x.length,children:(0,O.jsx)(o.default,{style:[se.sendText,(m||!y&&0===x.length)&&se.sendTextInactive],children:"\ud83e\udd8b"})})]})]})}),Y=(0,t.memo)(function({nid:e,narrativeSummary:a,narrativeFoldPath:l,narrativeRole:i,narrativeStatus:c,narrativeMcpConnected:u,narrativeAwaiting:d,palette:f,narrativeCreatedAt:h,narrativeLastActivity:b,cost:m,archived:p,selection:S,openSwitcher:C,onDownload:R,onTerminate:k,onRevive:P,onTwin:A,onArchiveToggle:I,onRecolor:_,onShowQr:E,onIsolateDaemon:L,isIsolated:M,canIsolate:N}){const[z,q]=(0,t.useState)(!1),$=(0,w.useSelectedSeqs)(S).length,F=!!(i||l||h),B=(0,x.isAwaiting)({mcpConnected:u,awaiting:d})?(0,x.awaitingGlow)((0,T.glowHueFor)(e)):void 0;return(0,O.jsxs)(n.default,{style:[se.header,se.glowTransition,B?{boxShadow:B}:null],children:[(0,O.jsxs)(s.default,{style:se.headerTitleContainer,onPress:C,children:[(0,O.jsx)(j.NarrativeIdentity,{id:e,foldPath:l,align:"center"}),F?(0,O.jsx)(j.NarrativeMetaLine,{role:i,cost:m,createdAt:h??void 0,lastActivity:b,status:c,mcpConnected:u,style:{marginTop:4}}):null,a?(0,O.jsx)("div",{style:{position:"relative",marginRight:8},children:(0,O.jsx)("div",{className:"no-scrollbar",style:{overflowX:"auto",overflowY:"hidden",scrollbarWidth:"none",WebkitOverflowScrolling:"touch",maskImage:"linear-gradient(to right, #000 calc(100% - 60px), transparent)",WebkitMaskImage:"linear-gradient(to right, #000 calc(100% - 60px), transparent)"},children:(0,O.jsx)(o.default,{style:se.headerSummary,children:a})})}):null]}),(0,O.jsxs)("div",{style:{position:"relative"},children:[(0,O.jsx)(s.default,{onPress:()=>q(e=>!e),style:se.reloadButton,hitSlop:8,children:(0,O.jsx)(o.default,{style:[se.reloadText,z&&se.reloadTextActive],children:"\ud83e\udda0"})}),z&&(0,O.jsx)(y.default,{items:(0,v.narrativeMenuItems)({role:i,status:c,mcpConnected:u,archived:p,isIsolated:M,canIsolate:N,selectedCount:$,onMeld:()=>{q(!1),E()},onIsolate:()=>{q(!1),L()},onExport:e=>{q(!1),R(e)},onRecolor:()=>{q(!1),_()},onTwin:()=>{q(!1),A()},onRevive:()=>{q(!1),P()},onEnd:()=>{q(!1),k()},onArchiveToggle:()=>{q(!1),I()}}),onClose:()=>q(!1)})]})]})}),V={headerShown:!1},J=new Map;function K(e){return null!=e.cost_amount&&e.cost_unit?{amount:e.cost_amount,unit:e.cost_unit}:null}const Q=300,Z={flex:1,minHeight:0,display:"flex",flexDirection:"column-reverse",overflowY:"auto",overflowX:"hidden"},ee={marginBottom:"auto"},te=.3;function ne(e,t){const n=e?.querySelector(`[data-seq="${t}"]`);if(!e||!n)return!1;const o=n.getBoundingClientRect().top-e.getBoundingClientRect().top;return e.scrollTop+=o-e.clientHeight*te,!0}const re='button, a[href], [role="button"], [role="link"], [role="menuitem"]';function oe(e){return e?J.get(e)??{}:{}}function ae(e,t){const n=J.get(e)??{};J.set(e,Object.assign({},n,t))}function le(){const e=(0,f.useIsFocused)(),{nid:y,scrollTo:S,scrollToSeq:k,tab:A,pinned:L,path:z,line:D}=(0,d.useLocalSearchParams)(),W=(0,d.useRouter)(),{conn:G,subscribe:J,unsubscribe:te,onHint:le,onMeta:ie,onStatus:ce,onToolUses:ue,narrativeIds:de}=(0,h.useBrane)(),[fe,he]=(0,t.useState)([]),[ge,be]=(0,t.useState)(()=>new Map),me=(0,t.useRef)(0),pe=(0,t.useRef)(Number.MAX_SAFE_INTEGER),[ye,ve]=(0,t.useState)(()=>z??""),[xe,we]=(0,t.useState)(()=>(0,F.parseLineSpec)(D).line),[Se,Ce]=(0,t.useState)(()=>(0,F.parseLineSpec)(D).lineEnd),Te=y?`brane:files:${y}`:null,je=y?`brane:tabs:${y}`:null,Re=(0,t.useRef)(null),[ke,Pe]=(0,t.useState)(()=>(0,F.parseActiveTab)(A)),[Ae,Ie]=(0,t.useState)(()=>(0,F.parsePinnedTabs)(L)),Ee=(0,t.useRef)(y??null);(0,t.useEffect)(()=>{if(!y)return;if(Ee.current===y)return;Ee.current=y;const e=(0,F.parseLineSpec)(D);ve(z??""),we(e.line),Ce(e.lineEnd)},[y]);const Le=(0,t.useRef)(null);(0,t.useEffect)(()=>{if(!Te||!y)return;if(Le.current===y)return;if(Le.current=y,z)return;let e=null;try{e=sessionStorage.getItem(Te)}catch{return}if(!e)return;let t=null;try{t=JSON.parse(e)}catch{}if(!t?.path)return;ve(t.path),we(t.line),Ce(t.lineEnd);const n=t.line?t.lineEnd&&t.lineEnd>t.line?`${t.line}-${t.lineEnd}`:String(t.line):void 0;W.setParams({path:t.path,line:n})},[y]),(0,t.useEffect)(()=>{if(Te)try{if(ye){const e={path:ye};xe&&(e.line=xe),Se&&(e.lineEnd=Se),sessionStorage.setItem(Te,JSON.stringify(e))}else sessionStorage.removeItem(Te)}catch{}},[Te,ye,xe,Se]),(0,t.useEffect)(()=>{if(je&&Re.current===y)try{sessionStorage.setItem(je,JSON.stringify({tab:ke,pinned:(0,F.serializePinned)(Ae)}))}catch{}},[je,y,ke,Ae]);const Me=(0,t.useMemo)(()=>(0,H.visiblePanes)(ke,Ae),[ke,Ae]),Ne=(0,t.useMemo)(()=>{const e=e=>{const t=Me.indexOf(e),n=Me.length;return t<0||1===n?{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:t<0?0:1,backgroundColor:"#111",pointerEvents:t<0?"none":"auto"}:{position:"absolute",top:0,bottom:0,left:t/n*100+"%",width:100/n+"%",zIndex:1,backgroundColor:"#111",borderLeftWidth:t>0?c.default.hairlineWidth:0,borderLeftColor:"#555"}};return{chat:e("chat"),terminal:e("terminal"),files:e("files")}},[Me]),ze=1===Me.length,[qe,$e]=(0,t.useState)(null),[Fe,Be]=(0,t.useState)(!1),[He,Oe]=(0,t.useState)(!1),[De,We]=(0,t.useState)(()=>oe(y).summary??null),[Ge,Ue]=(0,t.useState)(()=>oe(y).agent_type??null),[Xe,Ye]=(0,t.useState)(()=>oe(y).role??null),[Ve,Je]=(0,t.useState)(()=>oe(y).archived??!1),[Ke,Qe]=(0,t.useState)(()=>oe(y).fold_path??null),[Ze,et]=(0,t.useState)(()=>oe(y).status??null),[tt,nt]=(0,t.useState)(()=>oe(y).mcp_connected??!1),[rt,ot]=(0,t.useState)(!1),[at,lt]=(0,t.useState)(()=>oe(y).created_at??null),[st,it]=(0,t.useState)(()=>oe(y).last_activity??null),[ct,ut]=(0,t.useState)(()=>K(oe(y)));(0,t.useEffect)(()=>{const e=oe(y);We(e.summary??null),Ue(e.agent_type??null),Ye(e.role??null),Je(e.archived??!1),Qe(e.fold_path??null),et(e.status??null),nt(e.mcp_connected??!1),ot(!1),lt(e.created_at??null),it(e.last_activity??null),ut(K(e))},[y]);const[dt,ft]=(0,t.useState)(!1),[ht,gt]=(0,t.useState)([]),[bt,mt]=(0,t.useState)(!1),[pt,yt]=(0,t.useState)(null),vt=(0,t.useMemo)(()=>(0,q.collectKnownNids)({viewing:y,pushed:[...de].map(e=>({id:e})),listed:pt}),[y,de,pt]),xt=(0,w.useMessageSelection)(y),wt=(0,t.useRef)(0),[St,Ct]=(0,t.useState)(()=>(0,C.readRecolorSalt)(y));(0,t.useEffect)(()=>Ct((0,C.readRecolorSalt)(y)),[y]);const Tt=(0,t.useCallback)(()=>{(0,T.recolorGlowHue)(y),Ct((0,C.bumpRecolorSalt)(y))},[y]),jt=(0,t.useRef)(null),Rt=(0,t.useRef)(null),kt=(0,t.useRef)(!1),Pt=(0,t.useRef)(!0),[At,It]=(0,t.useState)(!0),[_t,Et]=(0,t.useState)(!0),[Lt,Mt]=(0,t.useState)(!0),Nt=(0,t.useRef)(null),zt=(0,t.useRef)(null),qt=(0,t.useRef)(!0);qt.current=Me.includes("chat");const $t=(0,t.useRef)(0),Ft=(0,t.useRef)(S?Number(S):0),Bt=(0,t.useRef)(k?Number(k):0),Ht=(0,t.useRef)(!1),[Ot,Dt]=(0,t.useState)(!1),[Wt,Gt]=(0,t.useState)(!0),Ut=(0,t.useRef)(!1),Xt=(0,t.useRef)(!1),Yt=(0,t.useRef)(null),Vt=(0,t.useRef)(!1),Jt=(0,t.useRef)(!1);(0,t.useEffect)(()=>{if(Me.includes("chat")&&!Vt.current){const e=Bt.current,t=Ft.current;if((e||t)&&0===fe.length)return;Vt.current=!0,$t.current=Date.now();let n=-1;if(e&&fe.length>0)n=fe.findIndex(t=>t.seq===e),n>=0&&xt.replace([e]),Bt.current=0;else if(t&&fe.length>0){let e=1/0;for(let o=0;o<fe.length;o++){const a=Math.abs(fe[o].time-t);a<e&&(e=a,n=o)}Ft.current=0}if(n>=0){Xt.current=!0;const e=setTimeout(()=>{Xt.current=!1},2e3);return ne(jt.current,fe[n].seq),()=>clearTimeout(e)}Pt.current=!0,It(!0)}Me.includes("terminal")&&(Jt.current=!0)},[Me,fe.length]);const Kt=(0,t.useCallback)(()=>{jt.current?.scrollTo({top:0})},[]),Qt=(0,t.useCallback)(()=>{const e=jt.current;e?.scrollTo({top:-e.scrollHeight,behavior:"smooth"})},[]),Zt=(0,t.useRef)(!1),en=(0,t.useRef)(!1),tn=(0,t.useCallback)(async()=>{if(G&&y)if(Zt.current)en.current=!0;else{Zt.current=!0;try{do{en.current=!1;const e=await(0,b.fetchEvents)(G,y,wt.current);e.events.length>0&&(he(t=>{const n=t.length>0?t[t.length-1].seq:0,o=e.events.filter(e=>e.seq>n);return o.length>0?[...t,...o]:t}),wt.current=e.events[e.events.length-1].seq)}while(en.current)}finally{Zt.current=!1}}},[G,y]),nn=(0,t.useCallback)(async()=>{if(G&&y&&!Ut.current&&Wt){Ut.current=!0;try{const e=fe.length>0?fe[0].seq:1/0,t=await(0,b.fetchEventsBefore)(G,y,e,50);t.events.length>0&&he(e=>{const n=e.length>0?e[0].seq:1/0,o=t.events.filter(e=>e.seq<n);return o.length>0?[...o,...e]:e}),(t.events.length<50||t.events.length>0&&t.events[0].seq<=t.min_seq)&&Gt(!1)}finally{Ut.current=!1}}},[G,y,fe,Wt]),rn=(0,t.useCallback)(e=>{0!==e.length&&be(t=>{let n=null;for(const o of e){const e=(n??t).get(o.dedup_key);e&&e.rev>=o.rev||(n||(n=new Map(t)),n.set(o.dedup_key,o),o.rev>me.current&&(me.current=o.rev))}return n??t})},[]);(0,t.useEffect)(()=>{if(!G||!y||0===fe.length)return;const e=Math.max(0,fe[0].seq-1),t=pe.current;e>=t||(pe.current=e,(0,b.fetchAllToolUseWindow)(G,y,{afterSeqGte:e,afterSeqLt:t===Number.MAX_SAFE_INTEGER?void 0:t},rn).catch(()=>{pe.current=Number.MAX_SAFE_INTEGER}))},[G,y,fe,rn]),(0,t.useEffect)(()=>{if(G&&y)return ue((e,t,n)=>{e===y&&(t?rn(t):(0,b.fetchAllToolUsesSince)(G,y,me.current,rn).catch(()=>{pe.current=Number.MAX_SAFE_INTEGER}))})},[G,y,ue,rn]),(0,t.useEffect)(()=>{if(!G||!y)return;const e=`${G.host}|${G.token}|${y}`;if(Yt.current===e)return;Yt.current=e,he([]),Gt(!0),wt.current=0,be(new Map),me.current=0,pe.current=Number.MAX_SAFE_INTEGER;const t=Bt.current;Ft.current;(async()=>{try{if(t){const e=Math.floor(25),n=Math.max(0,t-e-1),o=await(0,b.fetchEvents)(G,y,n,50);o.events.length>0?(he(o.events),wt.current=o.events[o.events.length-1].seq,Gt(o.events[0].seq>1)):(wt.current=o.seq,Gt(!1))}else{const e=await(0,b.fetchEventsBefore)(G,y,Number.MAX_SAFE_INTEGER,50);e.events.length>0?(he(e.events),wt.current=e.events[e.events.length-1].seq,(e.events.length<50||e.events[0].seq<=e.min_seq)&&Gt(!1)):(wt.current=0,Gt(!1))}}catch{tn()}})()},[G,y]);const on=(0,t.useCallback)(e=>{if(!y)return;e.summary&&(We(e.summary),ae(y,{summary:e.summary})),e.agent_type&&(Ue(e.agent_type),ae(y,{agent_type:e.agent_type})),e.role&&(Ye(e.role),ae(y,{role:e.role})),Qe(e.fold_path??null),ae(y,{fold_path:e.fold_path??null});const t=!!e.archived;Je(t),ae(y,{archived:t}),e.status&&(et(e.status),ae(y,{status:e.status}));const n=!!e.mcp_connected;nt(n),ae(y,{mcp_connected:n}),ot(!!e.awaiting),lt(e.created_at??null),ae(y,{created_at:e.created_at}),it(e.last_activity??null),ae(y,{last_activity:e.last_activity??null}),ut(K({cost_amount:e.cost_amount,cost_unit:e.cost_unit})),ae(y,{cost_amount:e.cost_amount??null,cost_unit:e.cost_unit??null})},[y]);(0,t.useEffect)(()=>{G&&y&&(0,b.fetchNarrative)(G,y).then(on).catch(()=>{})},[G,y,on]),(0,t.useEffect)(()=>{G&&y&&(0,b.fetchNarratives)(G,{archived:!0}).then(e=>{yt(e);const t=e.find(e=>e.id===y);t&&on(t)}).catch(e=>{console.warn("narrative list sweep failed; linkifying from pushed ids only",e)})},[G,y,on]),(0,t.useEffect)(()=>{if(!y)return;J(y,wt.current);const e=le((e,t)=>{if(e===y){tn();const e=Date.now();it(e),ae(y,{last_activity:e})}});return()=>{te(y),e()}},[y,J,te,le,tn]),(0,t.useEffect)(()=>{if(y)return ie((e,t,n,o)=>{e===y&&(n&&(We(n),ae(y,{summary:n})),null!=o&&(ut(o),ae(y,{cost_amount:o.amount,cost_unit:o.unit})))})},[y,ie]),(0,t.useEffect)(()=>{if(y)return ce((e,t)=>{e===y&&("mcp_connected"===t?(nt(!0),ae(y,{mcp_connected:!0})):"mcp_disconnected"===t?(nt(!1),ot(!1),ae(y,{mcp_connected:!1})):t===x.AWAITING_STATUS||t===x.NOT_AWAITING_STATUS?ot(t===x.AWAITING_STATUS):"active"!==t&&"ended"!==t||(et(t),ae(y,{status:t})))})},[y,ce]);const an=(0,t.useCallback)(async e=>{G&&y&&("all"!==e?await(0,v.openNarrativeExport)(G,y,[...xt.getSelected()],"excluded"===e?"except":"only"):await(0,v.openNarrativeExport)(G,y))},[G,y,xt]),ln=(0,t.useCallback)(async()=>{if(Pt.current)Ht.current=!0,Pt.current=!1,It(!1),Qt(),setTimeout(()=>{Ht.current=!1},600);else{const e=setTimeout(()=>Dt(!0),150);try{await tn()}finally{clearTimeout(e),Dt(!1)}Pt.current=!0,It(!0),Kt()}},[tn,Kt,Qt]),sn=(0,t.useCallback)(()=>{_t?Nt.current?.scrollToTop():Nt.current?.scrollToBottom()},[_t]),cn=(0,t.useCallback)(()=>{Lt?zt.current?.scrollToTop():zt.current?.scrollToBottom()},[Lt]),un=(0,t.useCallback)((e,t,n,o,a)=>{W.setParams((0,F.viewParams)(e,t,n,o,a))},[W]),dn=(0,t.useCallback)(e=>{Pe(t=>t===e?t:(un(e,Ae,ye,xe,Se),e))},[un,Ae,ye,xe,Se]),fn=(0,t.useCallback)(e=>{if(ke===e)return;const{pinned:t}=(0,H.selectPane)(ke,Ae,e);Pe(e),Ie(t),un(e,t,ye,xe,Se)},[un,ke,Ae,ye,xe,Se]),hn=(0,t.useCallback)(()=>{const{pinned:e}=(0,H.selectPane)(ke,Ae,"terminal");Pe("terminal"),Ie(e),un("terminal",e,ye,xe,Se),setTimeout(()=>Nt.current?.focus(),60)},[un,ke,Ae,ye,xe,Se]);(0,t.useEffect)(()=>{if(!e)return;if(Me.length<2)return;const t=e=>{const t=e.target;if(t?.closest?.(re))return;const n=t?.closest?.("[data-pane]"),o=n?.getAttribute("data-pane");"chat"!==o&&"terminal"!==o&&"files"!==o||(fn(o),"terminal"===o&&Nt.current?.focus())};return document.addEventListener("pointerdown",t,!0),()=>document.removeEventListener("pointerdown",t,!0)},[e,Me.length,fn]);const gn=(0,t.useCallback)(e=>{Ie(t=>{const n=new Set(t);return n.has(e)?n.delete(e):n.add(e),un(ke,n,ye,xe,Se),n})},[un,ke,ye,xe,Se]),[bn,mn]=(0,t.useState)(null),pn=(0,t.useCallback)((e,t)=>{(e!==y||t)&&W.push((0,P.narrativeHref)(e,t))},[W,y]),yn=(0,t.useCallback)((e,t)=>{W.push(`/${e}?scrollTo=${t}`)},[W]),vn=(0,t.useCallback)(e=>{const t=xt.toggle(e);W.setParams({scrollToSeq:t?String(e):void 0})},[W,xt]),xn=(0,t.useCallback)(()=>{0!==xt.clear().length&&W.setParams({scrollToSeq:void 0})},[W,xt]);(0,t.useEffect)(()=>{if(!e)return;const t=e=>{const t=e.target;t?.closest&&t.closest('[data-pane="chat"]')&&(t.closest("[data-bubble], [data-chrome]")||t.closest("input, textarea, [data-composer]")||window.getSelection()?.toString()||xn())};return document.addEventListener("click",t),()=>document.removeEventListener("click",t)},[e,xn]);const wn=(0,t.useCallback)((e,t,n)=>{ve(e),we(t),Ce(n);"files"===ke||Ae.has("files")?un(ke,Ae,e,t,n):(Pe("files"),un("files",Ae,e,t,n))},[un,ke,Ae]),Sn=(0,t.useCallback)(e=>{const{path:t,line:n,lineEnd:o}=(0,I.parseRelLink)(e);wn(t,n,o)},[wn]),Cn=(0,t.useCallback)(e=>{if(!y)return;const{path:t,line:n,lineEnd:o}=(0,I.parseRelLink)(e);return(0,P.fileHref)(y,t,n,o,(0,F.serializePinned)(Ae)||void 0)},[y,Ae]),Tn=(0,t.useRef)(ke);Tn.current=ke;const jn=(0,t.useRef)(Ae);jn.current=Ae,(0,t.useEffect)(()=>{const e=(0,F.parseActiveTab)(A);e!==Tn.current&&Pe(e);const t=(0,F.parsePinnedTabs)(L),n=jn.current;(t.size!==n.size||[...t].some(e=>!n.has(e)))&&Ie(t)},[A,L]),(0,t.useEffect)(()=>{if(!je||!y)return;if(Re.current===y)return;if(Re.current=y,A||L)return;let e=null;try{e=sessionStorage.getItem(je)}catch{return}if(!e)return;let t=null;try{t=JSON.parse(e)}catch{}t&&(Pe((0,F.parseActiveTab)(t.tab)),Ie((0,F.parsePinnedTabs)(t.pinned)))},[y]);const Rn=(0,t.useMemo)(()=>{const e=new Map;if(0===ge.size||0===fe.length)return e;const t=fe[0].seq,n=fe[fe.length-1].seq;for(const o of ge.values()){let a=Math.min(o.after_seq,n);if(0===a){if(1!==t)continue;a=0}else if(a<t)continue;const l=e.get(a);l?l.push(o):e.set(a,[o])}for(const t of e.values())t.sort((e,t)=>e.started_at-t.started_at||e.dedup_key.localeCompare(t.dedup_key));return e},[fe,ge]),kn=(0,t.useCallback)(e=>G&&y?(0,b.fetchToolUse)(G,y,e):Promise.reject(new Error("no connection")),[G,y]),Pn=(0,t.useCallback)(({item:e})=>{const t=1===e.seq?Rn.get(0):void 0,n=Rn.get(e.seq),o=(0,O.jsx)(U,{item:e,nid:y,agentType:Ge,foldPath:Ke,conn:G,selection:xt,palette:St,onImagePress:$e,onForeignPress:yn,onFilePress:Sn,fileHref:Cn,onTimestampPress:vn});return t||n?(0,O.jsxs)(O.Fragment,{children:[t&&(0,O.jsx)(m.default,{rows:t,onNarrativePress:pn,onFetchFull:kn}),o,n&&(0,O.jsx)(m.default,{rows:n,onNarrativePress:pn,onFetchFull:kn})]}):o},[y,Ge,Ke,G,xt,St,yn,pn,Sn,Cn,vn,Rn,kn]),An=(0,t.useMemo)(()=>(0,F.viewParams)(ke,Ae,ye,xe,Se),[ke,Ae,ye,xe,Se]),In="undefined"!=typeof window&&!!G&&(0,F.isIsolated)(window.location.host,G.host),_n=(0,B.useAppHost)(G,In),En=(0,t.useCallback)(()=>{if(!G||!y)return;if("undefined"==typeof window)return;const e=(0,F.buildIsolateUrl)({host:window.location.host,protocol:window.location.protocol,search:window.location.search,path:`/${y}`,conn:G,appHost:_n,view:An});e&&window.open(e,"_blank","noopener,noreferrer")},[G,y,An,_n]),Ln=(0,t.useCallback)(async()=>{if(!G||!y)return;const e=!Ve;Je(e),ae(y,{archived:e});try{await(0,b.archiveNarrative)(G,y,e)}catch{Je(!e),ae(y,{archived:!e})}},[G,y,Ve]),Mn=(0,t.useCallback)(()=>{G&&(ft(!0),mt(!0),(0,b.fetchNarratives)(G).then(e=>{const t=e.filter(e=>e.mcp_connected||"active"===e.status||e.id===y);gt((0,$.sortNarratives)(t))}).catch(()=>{}).finally(()=>mt(!1)))},[G,y]);return(0,O.jsx)(u.default,{style:se.container,behavior:void 0,keyboardVerticalOffset:90,children:(0,O.jsxs)(N.MarkdownLinksProvider,{knownNarrativeIds:vt,onNarrativePress:pn,onProtocolPress:mn,children:[(0,O.jsx)(d.Stack.Screen,{options:V}),(0,O.jsx)(Y,{nid:y,narrativeSummary:De,narrativeFoldPath:Ke,narrativeRole:Xe,narrativeStatus:Ze,narrativeMcpConnected:tt,narrativeAwaiting:rt,palette:St,narrativeCreatedAt:at,narrativeLastActivity:st,cost:(0,b.formatCost)(ct?.amount,ct?.unit),archived:Ve,selection:xt,openSwitcher:Mn,onDownload:an,onTerminate:()=>{hn(),Nt.current?.terminate()},onRevive:()=>{(0,v.revivesAsTwin)(Xe)||hn(),Nt.current?.revive()},onTwin:()=>Oe(!0),onArchiveToggle:Ln,onRecolor:Tt,onShowQr:()=>Be(!0),onIsolateDaemon:En,isIsolated:In,canIsolate:!In||!!_n}),(0,O.jsx)(n.default,{style:se.tabBar,children:F.CANONICAL_TABS.map((e,t)=>{const a=ke===e,l=Ae.has(e),i=a||l,c="chat"===e?"Chat":"terminal"===e?"Terminal":"Files",u="chat"===e?At:"terminal"===e?_t:Lt,d="chat"===e?ln:"terminal"===e?sn:cn;return(0,O.jsxs)(n.default,{style:[se.tab,t>0&&se.tabDivider,a&&se.tabActive],children:[(0,O.jsx)(s.default,{style:se.tabLabel,onPress:()=>dn(e),children:(0,O.jsx)(o.default,{style:[se.tabText,a&&se.tabTextActive],children:c})}),(0,O.jsx)(s.default,{style:se.tabPin,onPress:()=>gn(e),hitSlop:6,children:(0,O.jsx)(o.default,{style:[se.tabPinIcon,l?se.tabPinOn:se.tabPinOff],children:"\ud83d\udccc"})}),(0,O.jsx)(s.default,{style:se.tabArrowPress,onPress:d,disabled:!i,hitSlop:6,children:i?"chat"===e&&Ot?(0,O.jsx)(o.default,{style:se.tabArrowText,children:"\u267b\ufe0f"}):(0,O.jsx)(o.default,{style:se.tabArrowText,children:u?"\u2191":"\u2193"}):(0,O.jsx)(o.default,{style:se.tabArrowText})})]},e)})}),(0,O.jsxs)(n.default,Object.assign({style:{flex:1,overflow:"hidden",position:"relative"}},ze?{onTouchStart:e=>{const t=e.nativeEvent;Rt.current={x:t.pageX,y:t.pageY}},onTouchMove:e=>{if(!Rt.current)return;const t=e.nativeEvent,n=Math.abs(t.pageX-Rt.current.x),o=Math.abs(t.pageY-Rt.current.y);n>15&&n>1.5*o&&!kt.current&&(kt.current=!0)},onTouchEnd:e=>{if(!Rt.current)return;const t=e.nativeEvent,n=t.pageX-Rt.current.x,o=t.pageY-Rt.current.y;Rt.current=null,kt.current=!1;if(!("undefined"!=typeof window&&!!window.getSelection()?.toString())&&Math.abs(n)>60&&Math.abs(n)>1.5*Math.abs(o)){const e=Me[0],t=F.CANONICAL_TABS.indexOf(e),o=n<0?t+1:t-1;o>=0&&o<F.CANONICAL_TABS.length&&dn(F.CANONICAL_TABS[o])}}}:{},{children:[(0,O.jsxs)(n.default,{style:Ne.chat,dataSet:{pane:"chat"},children:[(0,O.jsx)("div",{ref:jt,style:Z,onScroll:e=>{const t=e.currentTarget,n=t.scrollTop>-50;n===Pt.current||Ht.current||(Pt.current=n,It(n));const o=t.scrollHeight-t.clientHeight+t.scrollTop,a=Date.now()-$t.current;o<200&&Wt&&!Ut.current&&!Xt.current&&qt.current&&$t.current>0&&a>Q&&nn()},children:(0,O.jsx)(n.default,{style:[se.list,ee],children:fe.map(e=>(0,O.jsx)("div",{"data-seq":e.seq,children:Pn({item:e})},e.seq))})}),(0,O.jsx)(X,{conn:G,nid:y,loadEvents:tn,chatActive:"chat"===ke,selection:xt,onDeselect:xn})]}),G&&y&&(0,O.jsx)(n.default,{style:Ne.terminal,dataSet:{pane:"terminal"},children:(0,O.jsx)(p.default,{ref:Nt,conn:G,nid:y,active:Me.includes("terminal"),keyboardActive:"terminal"===ke&&!dt&&!He&&null===qe,agentType:Ge,role:Xe,onAtBottomChange:Et,onTwin:()=>Oe(!0),onRevived:e=>W.push((0,F.terminalOnlyHref)(e))})}),G&&y&&(0,O.jsx)(n.default,{style:Ne.files,dataSet:{pane:"files"},children:(0,O.jsx)(_.default,{ref:zt,conn:G,nid:y,path:ye,line:xe,lineEnd:Se,active:Me.includes("files"),onPathChange:wn,onImagePress:$e,onAtBottomChange:Mt})})]})),(0,O.jsx)(i.default,{visible:dt,transparent:!0,animationType:"fade",onRequestClose:()=>ft(!1),children:(0,O.jsx)(s.default,{style:se.switcherOverlay,onPress:()=>ft(!1),children:(0,O.jsxs)(n.default,{style:se.switcherContent,children:[(0,O.jsxs)(n.default,{style:se.switcherTitleRow,children:[(0,O.jsx)(o.default,{style:se.switcherTitle,children:"Switch narrative"}),(0,O.jsx)(s.default,{hitSlop:8,onPress:()=>{ft(!1),W.push("/")},children:(0,O.jsx)(o.default,{style:se.switcherListLink,children:"All narratives"})})]}),(0,O.jsx)(l.default,{data:ht,keyExtractor:e=>e.id,style:se.switcherList,ListEmptyComponent:(0,O.jsx)(o.default,{style:se.switcherEmpty,children:bt?"Loading\u2026":"No active narratives"}),renderItem:({item:e})=>{const t="ended"===e.status&&!e.mcp_connected,n=(0,x.isAwaiting)({mcpConnected:e.mcp_connected,awaiting:e.awaiting})?(0,x.awaitingGlow)((0,T.glowHueFor)(e.id)):void 0;return(0,O.jsxs)(s.default,{style:[se.switcherItem,e.id===y&&se.switcherItemActive,t&&se.switcherItemEnded,n?{boxShadow:n}:null],onPress:()=>{ft(!1),e.id!==y&&W.push(`/${e.id}`)},children:[(0,O.jsx)(j.NarrativeIdentity,{id:e.id,foldPath:e.fold_path,titleStyle:t?{color:"#666"}:void 0,copyMarginLeft:5,dimmed:t}),(0,O.jsx)(j.NarrativeMetaLine,{role:e.role,cost:(0,b.formatCost)(e.cost_amount,e.cost_unit),createdAt:e.created_at,lastActivity:e.last_activity,status:e.status,mcpConnected:e.mcp_connected,dimmed:t,style:{marginTop:4}}),e.summary&&(0,O.jsx)("div",{style:{position:"relative"},children:(0,O.jsx)("div",{className:"no-scrollbar",style:{overflowX:"auto",overflowY:"hidden",scrollbarWidth:"none",WebkitOverflowScrolling:"touch",maskImage:"linear-gradient(to right, #000 calc(100% - 40px), transparent)",WebkitMaskImage:"linear-gradient(to right, #000 calc(100% - 40px), transparent)"},children:(0,O.jsx)(o.default,{style:[se.switcherItemSummary,t&&{color:"#555"}],children:e.summary})})})]})}}),(0,O.jsx)(s.default,{style:se.switcherCancel,onPress:()=>ft(!1),children:(0,O.jsx)(o.default,{style:se.switcherCancelText,children:"Cancel"})})]})})}),(0,O.jsx)(R.default,{visible:Fe,conn:G,path:`/${y}`,view:An,onClose:()=>Be(!1)}),(0,O.jsx)(E.default,{visible:He,conn:G,re:y,defaultFoldPath:Ke,onClose:()=>Oe(!1),onSpawned:e=>{Oe(!1),W.push(`/${e.id}`)}}),(0,O.jsx)(i.default,{visible:null!==qe,transparent:!0,animationType:"fade",onRequestClose:()=>$e(null),children:(0,O.jsxs)(s.default,{style:se.lightboxBackdrop,onPress:()=>$e(null),children:[qe&&(0,O.jsx)(a.default,{source:{uri:qe},style:se.lightboxImage,resizeMode:"contain"}),(0,O.jsx)(o.default,{style:se.lightboxHint,children:"Tap anywhere to close"})]})}),bn&&G&&(0,O.jsx)(N.MarkdownLinksProvider,{onNarrativePress:(e,t)=>{mn(null),pn(e,t)},children:(0,O.jsx)(M.default,{conn:G,target:{source:"protocols",slug:bn},onClose:()=>mn(null)})})]})})}const se=c.default.create({container:{flex:1},glowTransition:{transitionProperty:"box-shadow",transitionDuration:"400ms"},header:{flexDirection:"row",alignItems:"center",backgroundColor:"#1a1a1e",paddingHorizontal:4,paddingVertical:6,borderBottomWidth:c.default.hairlineWidth,borderBottomColor:"rgb(216, 216, 216)",position:"relative",zIndex:10},tabBar:{flexDirection:"row",borderBottomWidth:c.default.hairlineWidth,borderBottomColor:"#555",backgroundColor:"#111"},tab:{width:100/F.CANONICAL_TABS.length+"%",position:"relative"},tabDivider:{borderLeftWidth:c.default.hairlineWidth,borderLeftColor:"#555"},tabActive:{borderBottomWidth:2,borderBottomColor:"#4caf50"},tabLabel:{flex:1,paddingVertical:10,paddingHorizontal:36,alignItems:"center",justifyContent:"center"},tabPin:{position:"absolute",left:0,top:0,bottom:0,width:36,alignItems:"center",justifyContent:"center"},tabPinIcon:{fontSize:12},tabPinOn:{opacity:1},tabPinOff:{opacity:.25},tabArrowPress:{position:"absolute",right:0,top:0,bottom:0,width:36,alignItems:"center",justifyContent:"center"},tabText:{color:"#666",fontSize:14,fontWeight:"600"},tabTextActive:{color:"#4caf50"},tabArrowText:{color:"#8fd4b4",fontSize:16,fontWeight:"400"},headerTitleContainer:{flexDirection:"column",alignItems:"stretch",justifyContent:"center",flex:1,minWidth:0,paddingHorizontal:8},headerSubtitle:{color:"#888",fontSize:12,fontFamily:"monospace",marginTop:1},headerSummary:{color:"#9a9aa0",fontSize:12,lineHeight:12,whiteSpace:"nowrap"},list:{paddingHorizontal:12,paddingVertical:8},bubbleRow:{marginBottom:6,flexDirection:"row"},bubbleRowLeft:{justifyContent:"flex-start"},bubbleRowRight:{justifyContent:"flex-end"},bubbleRowCenter:{justifyContent:"center"},bubble:{maxWidth:"85%",borderRadius:16,paddingHorizontal:14,paddingVertical:10,borderWidth:1.5,borderColor:"transparent",borderStyle:"solid"},bubbleAgent:{backgroundColor:"#1c1c1e",borderBottomLeftRadius:4},bubbleOperator:{backgroundColor:"#1a4a7a",borderBottomRightRadius:4},bubbleForeign:{borderRadius:12},bubbleSystem:{backgroundColor:"transparent",borderWidth:1,borderStyle:"dashed",borderColor:"#3a3a3c",borderRadius:12},bubbleSelected:{borderColor:"#5b9bd5"},bubbleSourceRow:{flexDirection:"row",alignItems:"center",alignSelf:"flex-start",marginBottom:3},bubbleSourcePress:{alignSelf:"flex-start"},bubbleSource:{color:"#4caf50",fontSize:11,fontFamily:"monospace"},bubbleSourceLink:{textDecorationLine:"underline"},bubbleSourceAfterLink:{marginLeft:4},bubbleSourceSystem:{color:"#8a8a8e"},bubbleTimePress:{alignSelf:"flex-end",marginTop:4},bubbleTime:{color:"#666",fontSize:11,textAlign:"right"},inputRow:{flexDirection:"row",padding:8,paddingBottom:8,borderTopWidth:1,borderTopColor:"rgb(216, 216, 216)",backgroundColor:"#1a1a1a",alignItems:"flex-end"},input:{flex:1,backgroundColor:"#111",color:"#e0e0e0",borderRadius:20,paddingHorizontal:16,paddingVertical:8,fontSize:15,borderWidth:1,borderColor:"#555",maxHeight:120,minHeight:36},sendButton:Object.assign({marginLeft:8,width:36,height:36,borderRadius:18,backgroundColor:"#1c1c1e",borderWidth:1,borderColor:"#555",justifyContent:"center",alignItems:"center"},{transition:"box-shadow 160ms ease, border-color 160ms ease"}),sendText:{fontSize:20,lineHeight:20,transform:[{translateX:-1},{translateY:1},{rotate:"45deg"}]},sendTextInactive:{opacity:.35},attachButton:Object.assign({width:36,height:36,borderRadius:18,backgroundColor:"#1c1c1e",justifyContent:"center",alignItems:"center",marginRight:8,borderWidth:1,borderColor:"#555"},{transition:"box-shadow 160ms ease, border-color 160ms ease"}),attachText:{fontSize:20,lineHeight:20,marginTop:-3},circleGlowActive:Object.assign({borderColor:"rgba(255, 130, 180, 0.6)"},{boxShadow:["0 0 10px rgba(255, 130, 180, 0.9)","0 0 25px rgba(255, 110, 165, 0.7)","0 0 50px rgba(255, 100, 155, 0.4)"].join(", ")}),circleGlowSend:Object.assign({borderColor:"rgba(90, 230, 200, 0.6)"},{boxShadow:["0 0 10px rgba(90, 230, 200, 0.9)","0 0 25px rgba(70, 215, 190, 0.7)","0 0 50px rgba(60, 200, 180, 0.4)"].join(", ")}),payloadsContainer:{marginTop:6,gap:4},filePayload:{backgroundColor:"rgba(255,255,255,0.1)",borderRadius:6,paddingHorizontal:10,paddingVertical:6},filePayloadText:{color:"#6cf",fontSize:13},pendingPayloadsRow:{flexDirection:"row",paddingHorizontal:12,paddingTop:8,gap:8,backgroundColor:"#111"},pendingPayloadThumb:{position:"relative",width:60,height:60},pendingPayloadImage:{width:60,height:60,borderRadius:8,borderWidth:1,borderColor:"#555"},pendingPayloadRemove:{position:"absolute",top:-6,right:-6,width:20,height:20,borderRadius:10,backgroundColor:"#c00",justifyContent:"center",alignItems:"center"},pendingPayloadRemoveText:{color:"#fff",fontSize:14,fontWeight:"700",lineHeight:16},switcherOverlay:{flex:1,backgroundColor:"rgba(0,0,0,0.6)",justifyContent:"center",alignItems:"center",padding:24},switcherContent:{backgroundColor:"#1e1e1e",borderRadius:12,paddingTop:20,paddingHorizontal:20,paddingBottom:8,width:"100%",maxWidth:400,maxHeight:"70%"},switcherTitleRow:{flexDirection:"row",alignItems:"baseline",justifyContent:"space-between",marginBottom:16},switcherTitle:{color:"#e0e0e0",fontSize:18,fontWeight:"600"},switcherListLink:{color:"#8fd4b4",fontSize:14},switcherList:{flexGrow:0,padding:4,margin:-4},switcherItem:{paddingVertical:12,paddingHorizontal:12,borderRadius:8,backgroundColor:"#2a2a2a",marginBottom:8},switcherItemActive:{outlineWidth:2,outlineStyle:"solid",outlineColor:"#4caf50",outlineOffset:2},switcherItemEnded:{opacity:.5},switcherItemSummary:{color:"#9a9aa0",fontSize:12,lineHeight:12,whiteSpace:"nowrap"},switcherEmpty:{color:"#888",fontSize:14,textAlign:"center",paddingVertical:20},switcherCancel:{paddingVertical:12,alignItems:"center",marginTop:4},switcherCancelText:{color:"#888",fontSize:15},lightboxBackdrop:{flex:1,backgroundColor:"rgba(0, 0, 0, 0.95)",justifyContent:"center",alignItems:"center",padding:8},lightboxImage:{width:"100%",height:"92%"},lightboxHint:{color:"#888",fontSize:14,marginTop:20},reloadButton:{paddingHorizontal:8,paddingVertical:4,marginRight:4},reloadText:Object.assign({fontSize:20},{transition:"text-shadow 160ms ease"}),reloadTextActive:Object.assign({},{textShadow:["0 0 10px rgba(140, 230, 170, 0.9)","0 0 25px rgba(120, 215, 155, 0.7)","0 0 50px rgba(100, 200, 145, 0.4)","0 2px 15px rgba(130, 220, 165, 0.6)"].join(", ")})})},10,[11,13,105,106,113,145,146,153,26,160,116,161,165,736,745,759,762,773,769,754,774,771,770,776,778,780,786,761,958,959,972,779,973,950,751,976,977,747,978,980,6]);
27
27
  __d(function(g,r,i,a,m,e,d){'use strict';m.exports=r(d[0])},11,[12]);
28
28
  __d(function(g,r,_i,a,m,e,d){
29
29
  /**
@@ -836,7 +836,7 @@ __d(function(g,r,i,a,m,e,d){"use strict";var t=this&&this.__importDefault||funct
836
836
  __d(function(g,r,i,a,m,e,d){"use strict";var t=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.Tabs=void 0;const u=t(r(d[0]));e.Tabs=u.default;const n=r(d[1]);u.default.Screen=n.Screen,e.default=u.default},733,[734,295]);
837
837
  __d(function(g,r,i,a,m,e,d){"use strict";var t=r(d[0]),n=r(d[1]);const o=["href"];var s=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const l=r(d[2]),u=(s(r(d[3])),r(d[4])),c=r(d[5]),f=r(d[6]),b=r(d[7]),h=r(d[8]),p=(0,l.createBottomTabNavigator)().Navigator,B=(0,c.withLayoutContext)(p,s=>s.map(s=>{if('function'!=typeof s.options&&void 0!==s.options?.href){const l=s.options,{href:c}=l,b=n(l,o);if(b.tabBarButton)throw new Error('Cannot use `href` and `tabBarButton` together.');return Object.assign({},s,{options:Object.assign({},b,{tabBarItemStyle:null==c?{display:'none'}:b.tabBarItemStyle,tabBarButton:n=>{if(null==c)return null;const o='web'===u.Platform.OS?n.children:t.jsx(u.Pressable,{children:n.children});return t.jsx(f.Link,Object.assign({},n,{style:[{display:'flex'},n.style],href:c,asChild:'web'!==u.Platform.OS,children:o}))}})})}return s})),j=Object.assign(n=>t.jsx(B,Object.assign({},n,{UNSTABLE_router:b.tabRouterOverride})),{Screen:B.Screen,Protected:h.Protected});e.default=j},734,[6,167,509,11,342,452,623,735,671]);
838
838
  __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.tabRouterOverride=void 0;function t(t){return'REPLACE'===t.type}e.tabRouterOverride=n=>Object.assign({},n,{getStateForAction:(o,s,c)=>{if(s.target&&s.target!==o.key)return null;if(t(s)){let t=n.getStateForAction(o,Object.assign({},s,{type:'JUMP_TO'}),c);if(!t||void 0===t.index||!Array.isArray(t.history))return null;if(0!==t.index){const n=t.index-1;t=Object.assign({},t,{key:`${t.key}-replace`,history:[...t.history.slice(0,n),...t.history.splice(t.index)]})}return t}return n.getStateForAction(o,s,c)}})},735,[]);
839
- __d(function(g,r,i,a,m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return w}}),_e.useBrane=function(){return(0,s.useContext)(v)};var t=r(_d[0]),n=e(r(_d[1])),o=r(_d[2]),s=r(_d[3]),c=r(_d[4]),l=r(_d[5]),u=r(_d[6]),d=r(_d[7]),h=r(_d[8]),f=e(r(_d[9])),k=r(_d[10]),b=r(_d[11]);(0,k.installNoPan)();const v=(0,s.createContext)({conn:null,connected:!1,daemons:[],activeDaemon:null,activeBraneId:null,switchDaemon:()=>{},switchBrane:()=>{},addDaemon:()=>Promise.reject(new Error("no context")),removeDaemon:()=>{},rotateActiveToken:()=>Promise.reject(new Error("no context")),subscribe:()=>{},unsubscribe:()=>{},subscribeActivity:()=>{},unsubscribeActivity:()=>{},onActivity:()=>()=>{},onHint:()=>()=>{},onStatus:()=>()=>{},onMeta:()=>()=>{},onToolUses:()=>()=>{},protocols:new Set,narrativeIds:new Set});function w(){const[e,k]=(0,s.useState)([]),[w,p]=(0,s.useState)(null),[S,y]=(0,s.useState)(null),[D,C]=(0,s.useState)(!1),[A]=(0,s.useState)(()=>new Set),[_]=(0,s.useState)(()=>new Set),[j]=(0,s.useState)(()=>new Set),[x]=(0,s.useState)(()=>new Set),[I]=(0,s.useState)(()=>new Set),[E,T]=(0,s.useState)(()=>new Set),P=(0,s.useRef)(null),M=e.find(e=>e.id===w)??null,O=(0,s.useMemo)(()=>M?{host:M.host,token:M.token}:null,[M?.host,M?.token]),U=(0,s.useRef)(null),B=(0,s.useCallback)(e=>{const t=(0,h.loadDaemons)().find(t=>t.host===e.host&&t.token===e.token);if(!t)return;t.revoked||k((0,h.updateDaemon)(t.id,{revoked:!0}));const n=U.current;P.current&&n?.host===e.host&&n.token===e.token&&(P.current.close(),P.current=null,U.current=null,C(!1))},[]);(0,s.useEffect)(()=>((0,c.setUnauthorizedListener)(B),()=>(0,c.setUnauthorizedListener)(null)),[B]);const N=(0,s.useCallback)(e=>{P.current?.close(),P.current=null,U.current=null,C(!1);const t=(0,h.loadDaemons)().find(t=>t.host===e.host&&t.token===e.token);if(t?.revoked)return;const n=(0,l.createControlChannel)({conn:e,onMessage:e=>{if("state"===e.type)T(new Set(e.narratives.map(e=>e.id)));else if("new_events"===e.type)for(const t of A)t(e.narrative,e.head_seq);else if("activity"===e.type)for(const t of _)t(e.narrative,e.seq,e.time);else if("status"===e.type)for(const t of j)t(e.narrative,e.status);else if("awaiting"===e.type){const t=e.awaiting?d.AWAITING_STATUS:d.NOT_AWAITING_STATUS;for(const n of j)n(e.narrative,t)}else if("meta"===e.type){const t=null!=e.cost_amount&&e.cost_unit?{amount:e.cost_amount,unit:e.cost_unit}:void 0;for(const n of x)n(e.narrative,e.title,e.summary,t)}else if("tool_uses"===e.type)for(const t of I)t(e.narrative,e.rows,e.rev);else if("tool_uses_resync"===e.type)for(const t of I)t(e.narrative,null,e.rev)},onConnect:()=>C(!0),onDisconnect:()=>C(!1),onSignedOut:()=>B(e)});P.current=n,U.current=e},[A,_,j,x,I,B]);(0,s.useEffect)(()=>{"serviceWorker"in navigator&&navigator.serviceWorker.register("/sw.js").catch(()=>{})},[]);const $=(0,s.useRef)(null),[z,L]=(0,s.useState)(null),W=(0,s.useCallback)(()=>{const e=(0,h.loadDaemons)(),t=(0,h.getActiveDaemonId)();if(0===e.length)return;k(e);const n=t&&e.find(e=>e.id===t)?t:e[0].id;p(n),(0,h.setActiveDaemonId)(n);const o=e.find(e=>e.id===n);N({host:o.host,token:o.token})},[N]),H=(0,s.useCallback)(()=>{if(window.history.replaceState){const e=window.location.pathname+(0,u.withoutConnectionParams)(window.location.search)+(0,u.withoutConnectionHash)(window.location.hash);window.history.replaceState({},"",e)}(0,c.clearStoredConnection)()},[]);(0,s.useEffect)(()=>{const e=(0,c.parseConnectionParams)();return e?(W(),void(0,c.probeDaemon)(e.host,e.token).then(t=>{const n=(0,h.loadDaemons)().find(e=>e.brane_id===t.brane_id);if(n&&n.token===e.token){const t=Object.assign({},n,{host:e.host,addedAt:n.addedAt});return t.host!==n.host&&((0,h.addDaemon)(t),k((0,h.loadDaemons)())),p(t.id),(0,h.setActiveDaemonId)(t.id),N({host:t.host,token:t.token}),void H()}$.current={host:e.host,token:e.token},L({status:t,host:e.host,isUpdate:void 0!==n})}).catch(()=>{H()})):(W(),()=>{P.current?.close()})},[W,N,H]);const R=(0,s.useCallback)(()=>{const e=z,t=$.current;if(!e||!t)return;const n={id:`${e.status.username}@${e.status.hostname}`,host:t.host,token:t.token,hostname:e.status.hostname,username:e.status.username,brane_id:e.status.brane_id,addedAt:Date.now()},o=(0,h.addDaemon)(n);k(o),p(n.id),(0,h.setActiveDaemonId)(n.id),(0,h.setDefaultDaemonId)(n.id),y(null),N({host:n.host,token:n.token}),$.current=null,L(null),H()},[z,N,H]),q=(0,s.useCallback)(()=>{$.current=null,L(null),H()},[H]),G=(0,s.useCallback)(t=>{const n=e.find(e=>e.id===t);n&&(p(t),(0,h.setActiveDaemonId)(t),(0,h.setDefaultDaemonId)(t),y(null),N({host:n.host,token:n.token}))},[e,N]),Y=(0,s.useCallback)(e=>{y(e)},[]),K=(0,s.useCallback)(async(e,t)=>{const n=await(0,c.probeDaemon)(e,t),o={id:`${n.username}@${n.hostname}`,host:e,token:t,hostname:n.hostname,username:n.username,brane_id:n.brane_id,addedAt:Date.now()},s=(0,h.addDaemon)(o);return k(s),p(o.id),(0,h.setActiveDaemonId)(o.id),N({host:o.host,token:o.token}),o},[N]),F=(0,s.useCallback)(e=>{const t=(0,h.removeDaemon)(e);if(k(t),w===e){const e=t[0]??null;p(e?.id??null),(0,h.setActiveDaemonId)(e?.id??null),e?N({host:e.host,token:e.token}):(P.current?.close(),P.current=null,C(!1))}},[w,N]),J=(0,s.useCallback)(async()=>{const e=M;if(!e)throw new Error("No active daemon");const t={host:e.host,token:e.token},n=await(0,c.rotateToken)(t);P.current?.close(),P.current=null,U.current=null,C(!1);try{await(0,c.probeDaemon)(e.host,n.token)}catch(e){N(t);const n=e instanceof Error&&/\b401\b/.test(e.message);throw new Error(n?"The daemon did not accept the new token: another rotation replaced it before this one was confirmed. Your access is unchanged \u2014 try again, and if it keeps happening, rotate from the shell with `brane token rotate`.":`Could not confirm the new token; your access is unchanged. ${e instanceof Error?e.message:String(e)}`)}const o=Object.assign({},e,{token:n.token,revoked:!1});k((0,h.addDaemon)(o)),N({host:o.host,token:o.token}),(0,c.clearStoredConnection)()},[M,N]);(0,s.useEffect)(()=>{if("undefined"==typeof window)return;const e=e=>{if(e.key!==h.DAEMONS_KEY&&null!==e.key)return;const t=(0,h.loadDaemons)();k(t);const n=t.find(e=>e.id===w);n&&O&&(n.revoked?(P.current?.close(),P.current=null,C(!1)):n.token===O.token&&n.host===O.host||N({host:n.host,token:n.token}))};return window.addEventListener("storage",e),()=>window.removeEventListener("storage",e)},[w,O,N]);const Q=(0,s.useCallback)((e,t=0)=>{P.current?.subscribe(e,t)},[]),V=(0,s.useCallback)(e=>{P.current?.unsubscribe(e)},[]),X=(0,s.useCallback)(()=>{P.current?.subscribeActivity()},[]),Z=(0,s.useCallback)(()=>{P.current?.unsubscribeActivity()},[]),ee=(0,s.useCallback)(e=>(_.add(e),()=>{_.delete(e)}),[_]),te=(0,s.useCallback)(e=>(A.add(e),()=>{A.delete(e)}),[A]),ne=(0,s.useCallback)(e=>(j.add(e),()=>{j.delete(e)}),[j]),oe=(0,s.useCallback)(e=>(x.add(e),()=>{x.delete(e)}),[x]),se=(0,s.useCallback)(e=>(I.add(e),()=>{I.delete(e)}),[I]),[ae,re]=(0,s.useState)(()=>new Set);(0,s.useEffect)(()=>{if(!O)return void re(new Set);let e=!1;return(0,c.listProtocols)(O).then(t=>{e||re(new Set(t.map(e=>e.name)))}).catch(()=>{}),()=>{e=!0}},[O]);const ie=(0,s.useMemo)(()=>({conn:O,connected:D,daemons:e,activeDaemon:M,activeBraneId:S,switchDaemon:G,switchBrane:Y,addDaemon:K,removeDaemon:F,rotateActiveToken:J,subscribe:Q,unsubscribe:V,subscribeActivity:X,unsubscribeActivity:Z,onActivity:ee,onHint:te,onStatus:ne,onMeta:oe,onToolUses:se,protocols:ae,narrativeIds:E}),[O,D,e,M,S,G,Y,K,F,J,Q,V,X,Z,ee,te,ne,oe,se,ae]);return(0,b.jsxs)(v.Provider,{value:ie,children:[(0,b.jsxs)(n.default,{children:[(0,b.jsx)("meta",{name:"viewport",content:"width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, viewport-fit=cover, shrink-to-fit=no"}),(0,b.jsx)("meta",{name:"apple-mobile-web-app-capable",content:"yes"}),(0,b.jsx)("meta",{name:"apple-mobile-web-app-status-bar-style",content:"black-translucent"}),(0,b.jsx)("link",{rel:"icon",type:"image/svg+xml",href:"/favicon.svg"}),(0,b.jsx)("link",{rel:"apple-touch-icon",href:"/apple-touch-icon.png"}),(0,b.jsx)("link",{rel:"manifest",href:"/manifest.json"}),(0,b.jsx)("style",{children:"html, body { background-color: #111 !important; height: 100%; overflow: hidden; overscroll-behavior: none; } #root { box-sizing: border-box; padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom); height: var(--brane-vvh, 100%); overflow: hidden; } .no-scrollbar::-webkit-scrollbar { display: none; }"})]}),(0,b.jsx)(t.Stack,{screenOptions:{headerStyle:{backgroundColor:"#1a1a1e"},headerTintColor:"#8fd4b4",headerTitleStyle:{fontSize:17},contentStyle:{backgroundColor:"#121214"}}}),(0,b.jsx)(o.StatusBar,{style:"light"}),(0,b.jsx)(f.default,{pending:z,onConfirm:R,onCancel:q})]})}},736,[161,737,742,11,745,751,747,753,754,755,756,6]);
839
+ __d(function(g,r,i,a,m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return w}}),_e.useBrane=function(){return(0,s.useContext)(v)};var t=r(_d[0]),n=e(r(_d[1])),o=r(_d[2]),s=r(_d[3]),c=r(_d[4]),l=r(_d[5]),u=r(_d[6]),d=r(_d[7]),h=r(_d[8]),f=e(r(_d[9])),k=r(_d[10]),b=r(_d[11]);(0,k.installNoPan)();const v=(0,s.createContext)({conn:null,connected:!1,daemons:[],activeDaemon:null,activeBraneId:null,switchDaemon:()=>{},switchBrane:()=>{},addDaemon:()=>Promise.reject(new Error("no context")),removeDaemon:()=>{},rotateActiveToken:()=>Promise.reject(new Error("no context")),subscribe:()=>{},unsubscribe:()=>{},subscribeActivity:()=>{},unsubscribeActivity:()=>{},onActivity:()=>()=>{},onHint:()=>()=>{},onStatus:()=>()=>{},onMeta:()=>()=>{},onToolUses:()=>()=>{},protocols:new Set,narrativeIds:new Set});function w(){const[e,k]=(0,s.useState)([]),[w,p]=(0,s.useState)(null),[S,y]=(0,s.useState)(null),[D,C]=(0,s.useState)(!1),[A]=(0,s.useState)(()=>new Set),[_]=(0,s.useState)(()=>new Set),[j]=(0,s.useState)(()=>new Set),[x]=(0,s.useState)(()=>new Set),[I]=(0,s.useState)(()=>new Set),[E,T]=(0,s.useState)(()=>new Set),P=(0,s.useRef)(null),M=e.find(e=>e.id===w)??null,O=(0,s.useMemo)(()=>M?{host:M.host,token:M.token}:null,[M?.host,M?.token]),U=(0,s.useRef)(null),B=(0,s.useCallback)(e=>{const t=(0,h.loadDaemons)().find(t=>t.host===e.host&&t.token===e.token);if(!t)return;t.revoked||k((0,h.updateDaemon)(t.id,{revoked:!0}));const n=U.current;P.current&&n?.host===e.host&&n.token===e.token&&(P.current.close(),P.current=null,U.current=null,C(!1))},[]);(0,s.useEffect)(()=>((0,c.setUnauthorizedListener)(B),()=>(0,c.setUnauthorizedListener)(null)),[B]);const N=(0,s.useCallback)(e=>{P.current?.close(),P.current=null,U.current=null,C(!1);const t=(0,h.loadDaemons)().find(t=>t.host===e.host&&t.token===e.token);if(t?.revoked)return;const n=(0,l.createControlChannel)({conn:e,onMessage:e=>{if("state"===e.type)T(new Set(e.narratives.map(e=>e.id)));else if("new_events"===e.type)for(const t of A)t(e.narrative,e.head_seq);else if("activity"===e.type)for(const t of _)t(e.narrative,e.seq,e.time);else if("status"===e.type)for(const t of j)t(e.narrative,e.status);else if("awaiting"===e.type){const t=e.awaiting?d.AWAITING_STATUS:d.NOT_AWAITING_STATUS;for(const n of j)n(e.narrative,t)}else if("meta"===e.type){const t=null!=e.cost_amount&&e.cost_unit?{amount:e.cost_amount,unit:e.cost_unit}:void 0;for(const n of x)n(e.narrative,e.title,e.summary,t)}else if("tool_uses"===e.type)for(const t of I)t(e.narrative,e.rows,e.rev);else if("tool_uses_resync"===e.type)for(const t of I)t(e.narrative,null,e.rev)},onConnect:()=>C(!0),onDisconnect:()=>C(!1),onSignedOut:()=>B(e)});P.current=n,U.current=e},[A,_,j,x,I,B]);(0,s.useEffect)(()=>{"serviceWorker"in navigator&&navigator.serviceWorker.register("/sw.js").catch(()=>{})},[]);const $=(0,s.useRef)(null),[z,L]=(0,s.useState)(null),W=(0,s.useCallback)(()=>{const e=(0,h.loadDaemons)(),t=(0,h.getActiveDaemonId)();if(0===e.length)return;k(e);const n=t&&e.find(e=>e.id===t)?t:e[0].id;p(n),(0,h.setActiveDaemonId)(n);const o=e.find(e=>e.id===n);N({host:o.host,token:o.token})},[N]),H=(0,s.useCallback)(()=>{if(window.history.replaceState){const e=window.location.pathname+(0,u.withoutConnectionParams)(window.location.search)+(0,u.withoutConnectionHash)(window.location.hash);window.history.replaceState({},"",e)}(0,c.clearStoredConnection)()},[]);(0,s.useEffect)(()=>{const e=(0,c.parseConnectionParams)();return e?(W(),void(0,c.probeDaemon)(e.host,e.token).then(t=>{const n=(0,h.loadDaemons)().find(e=>e.brane_id===t.brane_id);if(n&&n.token===e.token){const t=Object.assign({},n,{host:e.host,addedAt:n.addedAt});return t.host!==n.host&&((0,h.addDaemon)(t),k((0,h.loadDaemons)())),p(t.id),(0,h.setActiveDaemonId)(t.id),N({host:t.host,token:t.token}),void H()}$.current={host:e.host,token:e.token},L({status:t,host:e.host,isUpdate:void 0!==n})}).catch(()=>{H()})):(W(),()=>{P.current?.close()})},[W,N,H]);const R=(0,s.useCallback)(()=>{const e=z,t=$.current;if(!e||!t)return;const n={id:`${e.status.username}@${e.status.hostname}`,host:t.host,token:t.token,hostname:e.status.hostname,username:e.status.username,brane_id:e.status.brane_id,addedAt:Date.now()},o=(0,h.addDaemon)(n);k(o),p(n.id),(0,h.setActiveDaemonId)(n.id),(0,h.setDefaultDaemonId)(n.id),y(null),N({host:n.host,token:n.token}),$.current=null,L(null),H()},[z,N,H]),q=(0,s.useCallback)(()=>{$.current=null,L(null),H()},[H]),G=(0,s.useCallback)(t=>{const n=e.find(e=>e.id===t);n&&(p(t),(0,h.setActiveDaemonId)(t),(0,h.setDefaultDaemonId)(t),y(null),N({host:n.host,token:n.token}))},[e,N]),Y=(0,s.useCallback)(e=>{y(e)},[]),K=(0,s.useCallback)(async(e,t)=>{const n=await(0,c.probeDaemon)(e,t),o={id:`${n.username}@${n.hostname}`,host:e,token:t,hostname:n.hostname,username:n.username,brane_id:n.brane_id,addedAt:Date.now()},s=(0,h.addDaemon)(o);return k(s),p(o.id),(0,h.setActiveDaemonId)(o.id),N({host:o.host,token:o.token}),o},[N]),F=(0,s.useCallback)(e=>{const t=(0,h.removeDaemon)(e);if(k(t),w===e){const e=t[0]??null;p(e?.id??null),(0,h.setActiveDaemonId)(e?.id??null),e?N({host:e.host,token:e.token}):(P.current?.close(),P.current=null,C(!1))}},[w,N]),J=(0,s.useCallback)(async()=>{const e=M;if(!e)throw new Error("No active daemon");const t={host:e.host,token:e.token},n=await(0,c.rotateToken)(t);P.current?.close(),P.current=null,U.current=null,C(!1);try{await(0,c.probeDaemon)(e.host,n.token)}catch(e){N(t);const n=e instanceof Error&&/\b401\b/.test(e.message);throw new Error(n?"The daemon did not accept the new token: another rotation replaced it before this one was confirmed. Your access is unchanged \u2014 try again, and if it keeps happening, rotate from the shell with `brane token rotate`.":`Could not confirm the new token; your access is unchanged. ${e instanceof Error?e.message:String(e)}`)}const o=Object.assign({},e,{token:n.token,revoked:!1});k((0,h.addDaemon)(o)),N({host:o.host,token:o.token}),(0,c.clearStoredConnection)()},[M,N]);(0,s.useEffect)(()=>{if("undefined"==typeof window)return;const e=e=>{if(e.key!==h.DAEMONS_KEY&&null!==e.key)return;const t=(0,h.loadDaemons)();k(t);const n=t.find(e=>e.id===w);n&&O&&(n.revoked?(P.current?.close(),P.current=null,C(!1)):n.token===O.token&&n.host===O.host||N({host:n.host,token:n.token}))};return window.addEventListener("storage",e),()=>window.removeEventListener("storage",e)},[w,O,N]);const Q=(0,s.useCallback)((e,t=0)=>{P.current?.subscribe(e,t)},[]),V=(0,s.useCallback)(e=>{P.current?.unsubscribe(e)},[]),X=(0,s.useCallback)(()=>{P.current?.subscribeActivity()},[]),Z=(0,s.useCallback)(()=>{P.current?.unsubscribeActivity()},[]),ee=(0,s.useCallback)(e=>(_.add(e),()=>{_.delete(e)}),[_]),te=(0,s.useCallback)(e=>(A.add(e),()=>{A.delete(e)}),[A]),ne=(0,s.useCallback)(e=>(j.add(e),()=>{j.delete(e)}),[j]),oe=(0,s.useCallback)(e=>(x.add(e),()=>{x.delete(e)}),[x]),se=(0,s.useCallback)(e=>(I.add(e),()=>{I.delete(e)}),[I]),[ae,re]=(0,s.useState)(()=>new Set);(0,s.useEffect)(()=>{if(!O)return void re(new Set);let e=!1;return(0,c.listProtocols)(O).then(t=>{e||re(new Set(t.map(e=>e.name)))}).catch(()=>{}),()=>{e=!0}},[O]);const ie=(0,s.useMemo)(()=>({conn:O,connected:D,daemons:e,activeDaemon:M,activeBraneId:S,switchDaemon:G,switchBrane:Y,addDaemon:K,removeDaemon:F,rotateActiveToken:J,subscribe:Q,unsubscribe:V,subscribeActivity:X,unsubscribeActivity:Z,onActivity:ee,onHint:te,onStatus:ne,onMeta:oe,onToolUses:se,protocols:ae,narrativeIds:E}),[O,D,e,M,S,G,Y,K,F,J,Q,V,X,Z,ee,te,ne,oe,se,ae]);return(0,b.jsxs)(v.Provider,{value:ie,children:[(0,b.jsxs)(n.default,{children:[(0,b.jsx)("meta",{name:"viewport",content:"width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, viewport-fit=cover, shrink-to-fit=no"}),(0,b.jsx)("meta",{name:"apple-mobile-web-app-capable",content:"yes"}),(0,b.jsx)("meta",{name:"apple-mobile-web-app-status-bar-style",content:"black-translucent"}),(0,b.jsx)("link",{rel:"icon",type:"image/svg+xml",href:"/favicon.svg"}),(0,b.jsx)("link",{rel:"apple-touch-icon",href:"/apple-touch-icon.png"}),(0,b.jsx)("link",{rel:"manifest",href:"/manifest.json"}),(0,b.jsx)("style",{children:"html, body { background-color: #111 !important; height: 100%; overflow: hidden; overscroll-behavior: none; } #root { box-sizing: border-box; padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom); height: var(--brane-vvh, 100%); overflow: hidden; } .no-scrollbar::-webkit-scrollbar { display: none; }"})]}),(0,b.jsx)(t.Stack,{screenOptions:{headerStyle:{backgroundColor:"#1a1a1e"},headerTintColor:"#8fd4b4",headerTitleStyle:{fontSize:17},contentStyle:{backgroundColor:"#121214"}}}),(0,b.jsx)(o.StatusBar,{style:"light"}),(0,b.jsx)(f.default,{pending:z,onConfirm:R,onCancel:q})]})}},736,[161,737,742,11,745,753,747,754,755,756,757,6]);
840
840
  __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return t.Head}});var t=r(d[0])},737,[738]);
841
841
  __d(function(g,r,i,a,m,e,d){"use strict";var t=r(d[0]),n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.Head=void 0;n(r(d[1]));const u=r(d[2]),l=r(d[3]);function o({children:n}){return t.jsx(u.Helmet,{children:n})}e.Head=({children:n})=>(0,l.useIsFocused)()?t.jsx(o,{children:n}):null,e.Head.Provider=u.HelmetProvider},738,[6,11,739,722]);
842
842
  __d(function(g,r,_i,a,m,e,d){"use strict";var t=r(d[0]);const s=["children"],n=["children"];var i,o=Object.create,c=Object.defineProperty,l=Object.getOwnPropertyDescriptor,p=Object.getOwnPropertyNames,u=Object.getPrototypeOf,h=Object.prototype.hasOwnProperty,y=(t,s,n,i)=>{if(s&&"object"==typeof s||"function"==typeof s)for(let o of p(s))h.call(t,o)||o===n||c(t,o,{get:()=>s[o],enumerable:!(i=l(s,o))||i.enumerable});return t},b=(t,s,n)=>(n=null!=t?o(u(t)):{},y(!s&&t&&t.__esModule?n:c(n,"default",{value:t,enumerable:!0}),t)),f={};((t,s)=>{for(var n in s)c(t,n,{get:s[n],enumerable:!0})})(f,{Helmet:()=>Oe,HelmetData:()=>ce,HelmetProvider:()=>pe}),m.exports=(i=f,y(c({},"__esModule",{value:!0}),i));var T=b(r(d[1])),O=b(r(d[2])),A=b(r(d[3])),j=b(r(d[1])),C=b(r(d[1])),w=(t=>(t.BASE="base",t.BODY="body",t.HEAD="head",t.HTML="html",t.LINK="link",t.META="meta",t.NOSCRIPT="noscript",t.SCRIPT="script",t.STYLE="style",t.TITLE="title",t.FRAGMENT="Symbol(react.fragment)",t))(w||{}),x={rel:["amphtml","canonical","alternate"]},v={type:["application/ld+json"]},$={charset:"",name:["generator","robots","description"],property:["og:type","og:title","og:url","og:image","og:image:alt","og:description","twitter:url","twitter:title","twitter:description","twitter:image","twitter:image:alt","twitter:card","twitter:site"]},k=Object.values(w),S={accesskey:"accessKey",charset:"charSet",class:"className",contenteditable:"contentEditable",contextmenu:"contextMenu","http-equiv":"httpEquiv",itemprop:"itemProp",tabindex:"tabIndex"},M=Object.entries(S).reduce((t,[s,n])=>(t[n]=s,t),{}),E="data-rh",P="defaultTitle",H="defer",D="encodeSpecialCharacters",L="onChangeClientState",I="titleTemplate",U="prioritizeSeoTags",N=(t,s)=>{for(let n=t.length-1;n>=0;n-=1){const i=t[n];if(Object.prototype.hasOwnProperty.call(i,s))return i[s]}return null},q=t=>{let s=N(t,"title");const n=N(t,I);if(Array.isArray(s)&&(s=s.join("")),n&&s)return n.replace(/%s/g,()=>s);const i=N(t,P);return s||i||void 0},_=t=>N(t,L)||(()=>{}),R=(t,s)=>s.filter(s=>void 0!==s[t]).map(s=>s[t]).reduce((t,s)=>Object.assign({},t,s),{}),z=(t,s)=>s.filter(t=>void 0!==t.base).map(t=>t.base).reverse().reduce((s,n)=>{if(!s.length){const i=Object.keys(n);for(let o=0;o<i.length;o+=1){const c=i[o].toLowerCase();if(-1!==t.indexOf(c)&&n[c])return s.concat(n)}}return s},[]),B=(t,s,n)=>{const i={};return n.filter(s=>{return!!Array.isArray(s[t])||(void 0!==s[t]&&(n=`Helmet: ${t} should be of type "Array". Instead found type "${typeof s[t]}"`,console&&"function"==typeof console.warn&&console.warn(n)),!1);var n}).map(s=>s[t]).reverse().reduce((t,n)=>{const o={};n.filter(t=>{let n;const c=Object.keys(t);for(let i=0;i<c.length;i+=1){const o=c[i],l=o.toLowerCase();-1===s.indexOf(l)||"rel"===n&&"canonical"===t[n].toLowerCase()||"rel"===l&&"stylesheet"===t[l].toLowerCase()||(n=l),-1===s.indexOf(o)||"innerHTML"!==o&&"cssText"!==o&&"itemprop"!==o||(n=o)}if(!n||!t[n])return!1;const l=t[n].toLowerCase();return i[n]||(i[n]={}),o[n]||(o[n]={}),!i[n][l]&&(o[n][l]=!0,!0)}).reverse().forEach(s=>t.push(s));const c=Object.keys(o);for(let t=0;t<c.length;t+=1){const s=c[t],n=Object.assign({},i[s],o[s]);i[s]=n}return t},[]).reverse()},F=(t,s)=>{if(Array.isArray(t)&&t.length)for(let n=0;n<t.length;n+=1){if(t[n][s])return!0}return!1},Y=t=>Array.isArray(t)?t.join(""):t,K=(t,s)=>{const n=Object.keys(t);for(let i=0;i<n.length;i+=1)if(s[n[i]]&&s[n[i]].includes(t[n[i]]))return!0;return!1},G=(t,s)=>Array.isArray(t)?t.reduce((t,n)=>(K(n,s)?t.priority.push(n):t.default.push(n),t),{priority:[],default:[]}):{default:t,priority:[]},W=(t,s)=>Object.assign({},t,{[s]:void 0}),J=["noscript","script","style"],Q=(t,s=!0)=>!1===s?String(t):String(t).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#x27;"),V=t=>Object.keys(t).reduce((s,n)=>{const i=void 0!==t[n]?`${n}="${Q(t[n])}"`:`${n}`;return s?`${s} ${i}`:i},""),X=(t,s,n,i)=>{const o=V(n),c=Y(s);return o?`<${t} ${E}="true" ${o}>${Q(c,i)}</${t}>`:`<${t} ${E}="true">${Q(c,i)}</${t}>`},Z=(t,s,n=!0)=>s.reduce((s,i)=>{const o=i,c=Object.keys(o).filter(t=>!("innerHTML"===t||"cssText"===t)).reduce((t,s)=>{const i=void 0===o[s]?s:`${s}="${Q(o[s],n)}"`;return t?`${t} ${i}`:i},""),l=o.innerHTML||o.cssText||"",p=-1===J.indexOf(t);return`${s}<${t} ${E}="true" ${c}${p?"/>":`>${l}</${t}>`}`},""),ee=(t,s={})=>Object.keys(t).reduce((s,n)=>(s[S[n]||n]=t[n],s),s),te=(t,s,n)=>{const i=ee(n,{key:s,[E]:!0});return[C.default.createElement("title",i,s)]},re=(t,s)=>s.map((s,n)=>{const i={key:n,[E]:!0};return Object.keys(s).forEach(t=>{const n=S[t]||t;if("innerHTML"===n||"cssText"===n){const t=s.innerHTML||s.cssText;i.dangerouslySetInnerHTML={__html:t}}else i[n]=s[t]}),C.default.createElement(t,i)}),se=(t,s,n=!0)=>{switch(t){case"title":return{toComponent:()=>te(0,s.title,s.titleAttributes),toString:()=>X(t,s.title,s.titleAttributes,n)};case"bodyAttributes":case"htmlAttributes":return{toComponent:()=>ee(s),toString:()=>V(s)};default:return{toComponent:()=>re(t,s),toString:()=>Z(t,s,n)}}},ne=({metaTags:t,linkTags:s,scriptTags:n,encode:i})=>{const o=G(t,$),c=G(s,x),l=G(n,v);return{priorityMethods:{toComponent:()=>[...re("meta",o.priority),...re("link",c.priority),...re("script",l.priority)],toString:()=>`${se("meta",o.priority,i)} ${se("link",c.priority,i)} ${se("script",l.priority,i)}`},metaTags:o.default,linkTags:c.default,scriptTags:l.default}},ie=t=>{const{baseTag:s,bodyAttributes:n,encode:i=!0,htmlAttributes:o,noscriptTags:c,styleTags:l,title:p="",titleAttributes:u,prioritizeSeoTags:h}=t;let{linkTags:y,metaTags:b,scriptTags:f}=t,T={toComponent:()=>{},toString:()=>""};return h&&({priorityMethods:T,linkTags:y,metaTags:b,scriptTags:f}=ne(t)),{priority:T,base:se("base",s,i),bodyAttributes:se("bodyAttributes",n,i),htmlAttributes:se("htmlAttributes",o,i),link:se("link",y,i),meta:se("meta",b,i),noscript:se("noscript",c,i),script:se("script",f,i),style:se("style",l,i),title:se("title",{title:p,titleAttributes:u},i)}},oe=[],ae=!("undefined"==typeof window||!window.document||!window.document.createElement),ce=class{instances=[];canUseDOM=ae;value={setHelmet:t=>{this.context.helmet=t},helmetInstances:{get:()=>this.canUseDOM?oe:this.instances,add:t=>{(this.canUseDOM?oe:this.instances).push(t)},remove:t=>{const s=(this.canUseDOM?oe:this.instances).indexOf(t);(this.canUseDOM?oe:this.instances).splice(s,1)}}};constructor(t,s){this.context=t,this.canUseDOM=s||!1,s||(t.helmet=ie({baseTag:[],bodyAttributes:{},encodeSpecialCharacters:!0,htmlAttributes:{},linkTags:[],metaTags:[],noscriptTags:[],scriptTags:[],styleTags:[],title:"",titleAttributes:{}}))}},le=j.default.createContext({}),pe=class t extends j.Component{static canUseDOM=ae;constructor(s){super(s),this.helmetData=new ce(this.props.context||{},t.canUseDOM)}render(){return j.default.createElement(le.Provider,{value:this.helmetData.value},this.props.children)}},ue=r(d[1]),de=b(r(d[4])),he=(t,s)=>{const n=document.head||document.querySelector("head"),i=n.querySelectorAll(`${t}[${E}]`),o=[].slice.call(i),c=[];let l;return s&&s.length&&s.forEach(s=>{const n=document.createElement(t);for(const t in s)if(Object.prototype.hasOwnProperty.call(s,t))if("innerHTML"===t)n.innerHTML=s.innerHTML;else if("cssText"===t)n.styleSheet?n.styleSheet.cssText=s.cssText:n.appendChild(document.createTextNode(s.cssText));else{const i=t,o=void 0===s[i]?"":s[i];n.setAttribute(t,o)}n.setAttribute(E,"true"),o.some((t,s)=>(l=s,n.isEqualNode(t)))?o.splice(l,1):c.push(n)}),o.forEach(t=>t.parentNode?.removeChild(t)),c.forEach(t=>n.appendChild(t)),{oldTags:o,newTags:c}},me=(t,s)=>{const n=document.getElementsByTagName(t)[0];if(!n)return;const i=n.getAttribute(E),o=i?i.split(","):[],c=[...o],l=Object.keys(s);for(const t of l){const i=s[t]||"";n.getAttribute(t)!==i&&n.setAttribute(t,i),-1===o.indexOf(t)&&o.push(t);const l=c.indexOf(t);-1!==l&&c.splice(l,1)}for(let t=c.length-1;t>=0;t-=1)n.removeAttribute(c[t]);o.length===c.length?n.removeAttribute(E):n.getAttribute(E)!==l.join(",")&&n.setAttribute(E,l.join(","))},ge=(t,s)=>{void 0!==t&&document.title!==t&&(document.title=Y(t)),me("title",s)},ye=(t,s)=>{const{baseTag:n,bodyAttributes:i,htmlAttributes:o,linkTags:c,metaTags:l,noscriptTags:p,onChangeClientState:u,scriptTags:h,styleTags:y,title:b,titleAttributes:f}=t;me("body",i),me("html",o),ge(b,f);const T={baseTag:he("base",n),linkTags:he("link",c),metaTags:he("meta",l),noscriptTags:he("noscript",p),scriptTags:he("script",h),styleTags:he("style",y)},O={},A={};Object.keys(T).forEach(t=>{const{newTags:s,oldTags:n}=T[t];s.length&&(O[t]=s),n.length&&(A[t]=T[t].oldTags)}),s&&s(),u(t,O,A)},be=null,fe=t=>{be&&cancelAnimationFrame(be),t.defer?be=requestAnimationFrame(()=>{ye(t,()=>{be=null})}):(ye(t),be=null)},Te=class extends ue.Component{rendered=!1;shouldComponentUpdate(t){return!(0,de.default)(t,this.props)}componentDidUpdate(){this.emitChange()}componentWillUnmount(){const{helmetInstances:t}=this.props.context;t.remove(this),this.emitChange()}emitChange(){const{helmetInstances:t,setHelmet:s}=this.props.context;let n=null;const i=(o=t.get().map(t=>{const s=Object.assign({},t.props);return delete s.context,s}),{baseTag:z(["href"],o),bodyAttributes:R("bodyAttributes",o),defer:N(o,H),encode:N(o,D),htmlAttributes:R("htmlAttributes",o),linkTags:B("link",["rel","href"],o),metaTags:B("meta",["name","charset","http-equiv","property","itemprop"],o),noscriptTags:B("noscript",["innerHTML"],o),onChangeClientState:_(o),scriptTags:B("script",["src","innerHTML"],o),styleTags:B("style",["cssText"],o),title:q(o),titleAttributes:R("titleAttributes",o),prioritizeSeoTags:F(o,U)});var o;pe.canUseDOM?fe(i):ie&&(n=ie(i)),s(n)}init(){if(this.rendered)return;this.rendered=!0;const{helmetInstances:t}=this.props.context;t.add(this),this.emitChange()}render(){return this.init(),null}},Oe=class extends T.Component{static defaultProps={defer:!0,encodeSpecialCharacters:!0,prioritizeSeoTags:!1};shouldComponentUpdate(t){return!(0,O.default)(W(this.props,"helmetData"),W(t,"helmetData"))}mapNestedChildrenToProps(t,s){if(!s)return null;switch(t.type){case"script":case"noscript":return{innerHTML:s};case"style":return{cssText:s};default:throw new Error(`<${t.type} /> elements are self-closing and can not contain children. Refer to our API for more information.`)}}flattenArrayTypeChildren(t,s,n,i){return Object.assign({},s,{[t.type]:[...s[t.type]||[],Object.assign({},n,this.mapNestedChildrenToProps(t,i))]})}mapObjectTypeChildren(t,s,n,i){switch(t.type){case"title":return Object.assign({},s,{[t.type]:i,titleAttributes:Object.assign({},n)});case"body":return Object.assign({},s,{bodyAttributes:Object.assign({},n)});case"html":return Object.assign({},s,{htmlAttributes:Object.assign({},n)});default:return Object.assign({},s,{[t.type]:Object.assign({},n)})}}mapArrayTypeChildrenToProps(t,s){let n=Object.assign({},s);return Object.keys(t).forEach(s=>{n=Object.assign({},n,{[s]:t[s]})}),n}warnOnInvalidChildren(t,s){return(0,A.default)(k.some(s=>t.type===s),"function"==typeof t.type?"You may be attempting to nest <Helmet> components within each other, which is not allowed. Refer to our API for more information.":`Only elements types ${k.join(", ")} are allowed. Helmet does not support rendering <${t.type}> elements. Refer to our API for more information.`),(0,A.default)(!s||"string"==typeof s||Array.isArray(s)&&!s.some(t=>"string"!=typeof t),`Helmet expects a string as a child of <${t.type}>. Did you forget to wrap your children in braces? ( <${t.type}>{\`\`}</${t.type}> ) Refer to our API for more information.`),!0}mapChildrenToProps(n,i){let o={};return T.default.Children.forEach(n,n=>{if(!n||!n.props)return;const c=n.props,{children:l}=c,p=t(c,s),u=Object.keys(p).reduce((t,s)=>(t[M[s]||s]=p[s],t),{});let{type:h}=n;switch("symbol"==typeof h?h=h.toString():this.warnOnInvalidChildren(n,l),h){case"Symbol(react.fragment)":i=this.mapChildrenToProps(l,i);break;case"link":case"meta":case"noscript":case"script":case"style":o=this.flattenArrayTypeChildren(n,o,u,l);break;default:i=this.mapObjectTypeChildren(n,i,u,l)}}),this.mapArrayTypeChildrenToProps(o,i)}render(){const s=this.props,{children:i}=s,o=t(s,n);let c=Object.assign({},o),{helmetData:l}=o;if(i&&(c=this.mapChildrenToProps(i,c)),l&&!(l instanceof ce)){l=new ce(l.context,!0),delete c.helmetData}return l?T.default.createElement(Te,Object.assign({},c,{context:l.value})):T.default.createElement(le.Consumer,null,t=>T.default.createElement(Te,Object.assign({},c,{context:t})))}}},739,[167,11,740,333,741]);
@@ -845,48 +845,48 @@ __d(function(g,r,i,a,m,e,d){m.exports=function(t,n,o,f){var c=o?o.call(f,t,n):vo
845
845
  __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"StatusBar",{enumerable:!0,get:function(){return t.StatusBar}}),Object.defineProperty(e,"setStatusBarStyle",{enumerable:!0,get:function(){return t.setStatusBarStyle}}),Object.defineProperty(e,"setStatusBarHidden",{enumerable:!0,get:function(){return t.setStatusBarHidden}}),Object.defineProperty(e,"setStatusBarBackgroundColor",{enumerable:!0,get:function(){return t.setStatusBarBackgroundColor}}),Object.defineProperty(e,"setStatusBarNetworkActivityIndicatorVisible",{enumerable:!0,get:function(){return t.setStatusBarNetworkActivityIndicatorVisible}}),Object.defineProperty(e,"setStatusBarTranslucent",{enumerable:!0,get:function(){return t.setStatusBarTranslucent}}),Object.defineProperty(e,"StatusBarStyle",{enumerable:!0,get:function(){return n.StatusBarStyle}}),Object.defineProperty(e,"StatusBarAnimation",{enumerable:!0,get:function(){return n.StatusBarAnimation}}),Object.defineProperty(e,"StatusBarProps",{enumerable:!0,get:function(){return n.StatusBarProps}});var t=r(d[0]),n=r(d[1])},742,[743,744]);
846
846
  __d(function(g,r,i,a,m,_e,d){"use strict";function t(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.StatusBar=function({style:t,hideTransitionAnimation:n,animated:c,hidden:f}){const h=(0,o.default)(),S=e.default.useMemo(()=>s(t,h),[t,h]);return(0,l.jsx)(u.default,{animated:c,hidden:f,barStyle:S,showHideTransition:'none'===n?void 0:n})},_e.setStatusBarStyle=function(t,e){u.default.setBarStyle(s(t),e)},_e.setStatusBarHidden=function(t,e){u.default.setHidden(t,e)},_e.setStatusBarBackgroundColor=function(t,e){},_e.setStatusBarNetworkActivityIndicatorVisible=function(t){},_e.setStatusBarTranslucent=function(t){};var e=t(r(d[0])),n=t(r(d[1])),u=t(r(d[2])),o=t(r(d[3])),l=r(d[4]);function s(t="auto",e=n.default?.getColorScheme()??'light'){e||(e='light');let u=t;return'auto'===t?u='light'===e?'dark':'light':'inverted'===t&&(u='light'===e?'light':'dark'),'light'===u?'light-content':'dark-content'}},743,[11,400,427,441,6]);
847
847
  __d(function(g,r,i,a,m,e,d){},744,[]);
848
- __d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"formatCost",{enumerable:!0,get:function(){return o.formatCost}}),Object.defineProperty(e,"formatCostTotals",{enumerable:!0,get:function(){return o.formatCostTotals}}),Object.defineProperty(e,"isInlinePayload",{enumerable:!0,get:function(){return s.isInlinePayload}}),e.parseConnectionParams=function(){if("undefined"==typeof window)return null;const t=u();if(t){try{sessionStorage.setItem(c,JSON.stringify(t))}catch{}return t}try{const t=sessionStorage.getItem(c);if(t)return JSON.parse(t)}catch{}return null},e.clearStoredConnection=function(){if("undefined"==typeof window)return;try{sessionStorage.removeItem(c)}catch{}},e.setUnauthorizedListener=function(t){f=t},e.fetchStatus=async function(n){const r=await w(h(n,"/api/status"),{headers:t.NO_HEADERS});if(!r.ok)throw new Error(`Status ${r.status}`);return r.json()},e.fetchNarratives=async function(n,r){const o=new URLSearchParams;r?.archived&&o.set("archived","1");r?.braneIds&&r.braneIds.length>0&&o.set("brane_ids",r.braneIds.join(","));const s=o.toString(),c=h(n,s?`/api/narratives?${s}`:"/api/narratives"),u=await w(c,{headers:t.NO_HEADERS});if(!u.ok)throw new Error(`Narratives ${u.status}`);return(await u.json()).narratives},e.fetchNarrative=async function(n,r){const o=await w(h(n,`/api/narratives/${r}`),{headers:t.NO_HEADERS});if(!o.ok)throw new Error(`Narrative ${o.status}`);return(await o.json()).narrative},e.fetchEvents=async function(n,r,o=0,s){const c=new URLSearchParams({after:String(o)});void 0!==s&&c.set("limit",String(s));const u=await w(h(n,`/api/narratives/${r}/events?${c}`),{headers:t.NO_HEADERS});if(!u.ok)throw new Error(`Events ${u.status}`);return u.json()},e.fetchToolUse=async function(n,r,o){const s=await w(h(n,`/api/narratives/${r}/tool_uses/${encodeURIComponent(o)}`),{headers:t.NO_HEADERS});if(!s.ok)throw new Error(`Tool use ${s.status}`);return(await s.json()).tool_use},e.fetchToolUseWindow=S,e.fetchToolUsesSince=E,e.fetchAllToolUseWindow=async function(t,n,r,o){let s;for(let c=0;c<p;c++){const c=await S(t,n,Object.assign({},r,{after:s}));if(o(c.tool_uses),!c.truncated||!c.next_cursor)return;s=c.next_cursor}console.warn(`[tool_uses] stopped paging window for ${n} after ${p} pages`)},e.fetchAllToolUsesSince=async function(t,n,r,o){let s=r;for(let r=0;r<p;r++){const r=await E(t,n,{sinceRev:s});if(o(r.tool_uses),!r.truncated||null==r.next_since_rev)return;s=r.next_since_rev}console.warn(`[tool_uses] stopped catching up ${n} after ${p} pages`)},e.fetchEventsBefore=async function(n,r,o,s=50){const c=new URLSearchParams({before:String(o),limit:String(s)}),u=await w(h(n,`/api/narratives/${r}/events?${c}`),{headers:t.NO_HEADERS});if(!u.ok)throw new Error(`Events ${u.status}`);return u.json()},e.sendSignal=async function(n,r,o,s="web",c,u){const f={content:o,source:s};c&&c.length>0&&(f.payloads=c);u&&u.length>0&&(f.re=u);const l=await w(h(n,`/api/narratives/${r}/signal`),{method:"POST",headers:t.JSON_HEADERS,body:JSON.stringify(f)});if(!l.ok)throw new Error(`Signal ${l.status}`);return l.json()},e.spawnAgent=async function(n,r,o,s="worker",c,u,f){const l={agent:r,fold_path:o,role:s};c&&(l.model=c);u&&u.length>0&&(l.extra_args=u);f&&(l.re=f);const S=await w(h(n,"/api/spawn"),{method:"POST",headers:t.JSON_HEADERS,body:JSON.stringify(l)});if(!S.ok){const t=await S.json().catch(()=>({}));throw new Error(t.error??`Spawn ${S.status}`)}return(await S.json()).narrative},e.runUtility=async function(n,r,o){const s=await w(h(n,"/api/run"),{method:"POST",headers:t.JSON_HEADERS,body:JSON.stringify({command:r,fold_path:o})});if(!s.ok){const t=await s.json().catch(()=>({}));throw new Error(t.error??`Run ${s.status}`)}return(await s.json()).narrative},e.fetchRunHistory=async function(n){const r=await w(h(n,"/api/run-history"),{headers:t.NO_HEADERS});if(!r.ok)throw new Error(`Run history ${r.status}`);return(await r.json()).history},e.fetchSpawnHistory=async function(n){const r=await w(h(n,"/api/spawn-history"),{headers:t.NO_HEADERS});if(!r.ok)throw new Error(`Spawn history ${r.status}`);return(await r.json()).history},e.fetchFolds=async function(n,r=!1){const o=await w(h(n,r?"/api/folds?archived=1":"/api/folds"),{headers:t.NO_HEADERS});if(!o.ok)throw new Error(`Folds ${o.status}`);return(await o.json()).folds},e.addFold=async function(n,r){const o=await w(h(n,"/api/folds"),{method:"POST",headers:t.JSON_HEADERS,body:JSON.stringify({path:r})});if(!o.ok){const t=await o.json().catch(()=>({}));throw new Error(t.error??`Add fold ${o.status}`)}return(await o.json()).fold},e.archiveFold=async function(n,r,o=!0){const s=await w(h(n,"/api/folds/archive"),{method:"PATCH",headers:t.JSON_HEADERS,body:JSON.stringify({path:r,archived:o})});if(!s.ok){const t=await s.json().catch(()=>({}));throw new Error(t.error??`Archive fold ${s.status}`)}return s.json()},e.fetchBranes=async function(n){const r=await w(h(n,"/api/branes"),{headers:t.NO_HEADERS});if(!r.ok)throw new Error(`Branes ${r.status}`);return(await r.json()).branes},e.reviveNarrative=async function(n,r,o){const s={};o&&(s.agent=o);const c=await w(h(n,`/api/revive/${r}`),{method:"POST",headers:t.JSON_HEADERS,body:JSON.stringify(s)});if(!c.ok){const t=await c.json().catch(()=>({}));throw new Error(t.error??`Revive ${c.status}`)}return c.json()},e.archiveNarrative=async function(n,r,o=!0){const s=await w(h(n,`/api/narratives/${r}/archive`),{method:"PATCH",headers:t.JSON_HEADERS,body:JSON.stringify({archived:o})});if(!s.ok)throw new Error(`Archive ${s.status}`);return s.json()},e.searchNarratives=async function(n,r,o=20,s){const c={query:r,limit:o};s&&s.length>0&&(c.brane_ids=s);const u=await w(h(n,"/api/search"),{method:"POST",headers:t.JSON_HEADERS,body:JSON.stringify(c)});if(!u.ok){const t=await u.json().catch(()=>({}));throw new Error(t.error??`Search ${u.status}`)}return u.json()},e.searchWiki=async function(n,r,o=10,s){const c={query:r,limit:o};s&&s.length>0&&(c.brane_ids=s);const u=await w(h(n,"/api/wiki/search"),{method:"POST",headers:t.JSON_HEADERS,body:JSON.stringify(c)});if(!u.ok){const t=await u.json().catch(()=>({}));throw new Error(t.error??`Wiki search ${u.status}`)}return u.json()},e.readWikiSection=async function(n,r){const o=new URLSearchParams({slug:r.slug});r.source&&o.set("source",r.source);r.anchor&&o.set("anchor",r.anchor);null!=r.window&&o.set("window",String(r.window));r.braneIds&&r.braneIds.length>0&&o.set("brane_ids",r.braneIds.join(","));const s=await w(h(n,`/api/wiki/read?${o.toString()}`),{headers:t.NO_HEADERS});if(!s.ok){const t=await s.json().catch(()=>({}));throw new Error(t.error??`Wiki read ${s.status}`)}return s.json()},e.listProtocols=async function(n){const r=await w(h(n,"/api/protocols"),{headers:t.NO_HEADERS});if(!r.ok){const t=await r.json().catch(()=>({}));throw new Error(t.error??`Protocols ${r.status}`)}return(await r.json()).protocols??[]},e.wikiAssetUrl=function(t,n,r){const o=new URLSearchParams({source:n,path:r});return h(t,`/api/wiki/asset?${o.toString()}`)},e.payloadUrl=function(t,n){return h(t,`/api/payloads/${n}`)},e.fetchFiles=async function(n,r,o,s){const c=new URLSearchParams({nid:r,path:o});void 0!==s&&c.set("offset",String(s));const u=await w(h(n,`/api/files?${c}`),{headers:t.NO_HEADERS});if(!u.ok){const t=await u.json().catch(()=>({}));throw new Error(t.error??`Files ${u.status}`)}return u.json()},e.streamFileFind=async function(n,r,o,s,c,u,f){const l=new URLSearchParams({nid:r,path:o,q:s});c>0&&l.set("from",String(c));const S=await w(h(n,`/api/files/find?${l}`),{headers:t.NO_HEADERS,signal:f});if(!S.ok){const t=await S.json().catch(()=>({}));throw new Error(t.error??`Find ${S.status}`)}if(!S.body)throw new Error("Find: no response body");const E=S.body.getReader(),y=new TextDecoder;let p="";try{for(;;){const{done:t,value:n}=await E.read();if(t)break;let r;for(p+=y.decode(n,{stream:!0});(r=p.indexOf("\n"))>=0;){const t=p.slice(0,r);p=p.slice(r+1),t&&u(JSON.parse(t))}}}finally{E.releaseLock()}},e.filesRawUrl=function(t,n,r){const o=new URLSearchParams({nid:n,path:r,raw:"1"});return h(t,`/api/files?${o}`)},e.fetchNarrativeExportHtml=async function(n,o,s=0,c,u="only"){const f=(0,r.formatSeqParam)(c),l=f?(0,r.formatSeqModeParam)(u):null,S=(s>0?`&palette=${s}`:"")+(f?`&seqs=${f}`:"")+(l?`&seqs_mode=${l}`:""),E=await w(h(n,`/api/narratives/${o}/export?format=html${S}`),{headers:t.NO_HEADERS});if(!E.ok){const t=await E.text().catch(()=>"");throw new Error(t||`Export ${E.status}`)}return E.blob()},e.fetchHighlight=async function(n,r,o){const s=await w(h(n,"/api/highlight"),{method:"POST",headers:t.JSON_HEADERS,body:JSON.stringify({content:r,lang:o})});if(!s.ok)return null;const c=await s.json().catch(()=>null);return c?.highlight??null},e.fetchDiagram=async function(n,r){const o=await w(h(n,"/api/diagram"),{method:"POST",headers:t.JSON_HEADERS,body:JSON.stringify({source:r})});if(!o.ok)return null;const s=await o.json().catch(()=>null);return s?.diagram??null},e.fetchFileList=async function(n,r){const o=new URLSearchParams({nid:r}),s=await w(h(n,`/api/files/list?${o}`),{headers:t.NO_HEADERS});if(!s.ok){const t=await s.json().catch(()=>({}));throw new Error(t.error??`File list ${s.status}`)}return s.json()},e.rotateToken=async function(n){const r=await w(h(n,"/api/token/rotate"),{method:"POST",headers:t.NO_HEADERS});if(!r.ok)throw new Error(`Rotate ${r.status}`);return r.json()},e.mintDeviceToken=async function(n){const r=await w(h(n,"/api/tokens"),{method:"POST",headers:t.NO_HEADERS});if(404===r.status)return null;if(!r.ok){const t=await r.json().catch(()=>({}));throw new Error(t.error??`Mint ${r.status}`)}const o=await r.json();return{token:o.token,validForMs:o.validForMs}},e.listDeviceTokens=async function(n){const r=await w(h(n,"/api/tokens"),{headers:t.NO_HEADERS});if(404===r.status)return null;if(!r.ok)throw new Error(`Devices ${r.status}`);return(await r.json()).tokens},e.revokeDeviceToken=async function(n,r,o=[]){const s=o.length?`?also=${o.map(encodeURIComponent).join(",")}`:"",c=await w(h(n,`/api/tokens/${encodeURIComponent(r)}/revoke${s}`),{method:"POST",headers:t.NO_HEADERS});if(c.ok||404===c.status)return;const u=await c.json().catch(()=>({}));throw new Error(u.error??`Revoke ${c.status}`)},e.probeDaemon=async function(n,r){const o={host:n,token:r},s=await w(h(o,"/api/status"),{headers:t.NO_HEADERS});if(!s.ok)throw new Error(`Status ${s.status}`);return s.json()};var t=_r(d[0]),n=_r(d[1]),r=_r(d[2]),o=_r(d[3]),s=_r(d[4]);const c="brane_conn";function u(){const t=new URLSearchParams(window.location.hash.slice(1)),n=new URLSearchParams(window.location.search),r=t.get("token")??n.get("token");if(!r)return null;return{host:t.get("host")??n.get("host")??window.location.host,token:r}}function h(n,r){return`${"https:"===window.location.protocol?"https":"http"}://${n.host}${(0,t.withToken)(r,n.token)}`}function w(n,r,o=t.DEFAULT_TIMEOUT_MS){const s=(0,t.isRetryableMethod)(r.method??"GET")?t.MAX_ATTEMPTS:1,c=r.signal,u=async h=>{const w=new AbortController,S=setTimeout(()=>w.abort(),o);c&&(c.aborted?w.abort():c.addEventListener("abort",()=>w.abort(),{once:!0}));try{const t=await fetch(n,Object.assign({},r,{signal:w.signal}));if(401===t.status&&f){const t=l(n);t&&f(t)}return t}catch(n){if(h+1<s&&(0,t.isRetryableError)(n)&&!c?.aborted)return await new Promise(n=>setTimeout(n,(0,t.retryDelayMs)(h))),u(h+1);throw n}finally{clearTimeout(S)}};return u(0)}!(function(){if("undefined"==typeof window||!window.history?.replaceState)return;const t=u();if(!t)return;try{sessionStorage.setItem(c,JSON.stringify(t))}catch{return}const r=window.location.pathname+(0,n.withoutConnectionParams)(window.location.search)+(0,n.withoutConnectionHash)(window.location.hash);window.history.replaceState(window.history.state,"",r)})();let f=null;function l(t){try{const n=new URL(t),r=n.searchParams.get("token");return r?{host:n.host,token:r}:null}catch{return null}}async function S(t,n,r={}){const o=new URLSearchParams;return void 0!==r.afterSeqGte&&o.set("after_seq_gte",String(r.afterSeqGte)),void 0!==r.afterSeqLt&&o.set("after_seq_lt",String(r.afterSeqLt)),void 0!==r.limit&&o.set("limit",String(r.limit)),r.after&&(o.set("after_cursor_seq",String(r.after.after_seq)),o.set("after_cursor_started_at",String(r.after.started_at)),o.set("after_cursor_dedup_key",r.after.dedup_key)),y(t,n,o)}async function E(t,n,r){const o=new URLSearchParams;return o.set("since_rev",String(r.sinceRev)),void 0!==r.limit&&o.set("limit",String(r.limit)),y(t,n,o)}async function y(n,r,o){const s=await w(h(n,`/api/narratives/${r}/tool_uses?${o}`),{headers:t.NO_HEADERS});if(!s.ok)throw new Error(`ToolUses ${s.status}`);return s.json()}const p=100},745,[746,747,748,749,750]);
848
+ __d(function(g,_r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"formatCost",{enumerable:!0,get:function(){return s.formatCost}}),Object.defineProperty(e,"formatCostTotals",{enumerable:!0,get:function(){return s.formatCostTotals}}),Object.defineProperty(e,"isInlinePayload",{enumerable:!0,get:function(){return c.isInlinePayload}}),e.parseConnectionParams=function(){if("undefined"==typeof window)return null;const t=h();if(t){try{sessionStorage.setItem(u,JSON.stringify(t))}catch{}return t}try{const t=sessionStorage.getItem(u);if(t)return JSON.parse(t)}catch{}return null},e.clearStoredConnection=function(){if("undefined"==typeof window)return;try{sessionStorage.removeItem(u)}catch{}},e.setUnauthorizedListener=function(t){l=t},e.fetchStatus=async function(n){const r=await f(w(n,"/api/status"),{headers:t.NO_HEADERS});if(!r.ok)throw new Error(`Status ${r.status}`);return r.json()},e.fetchNarratives=async function(n,r){const o=new URLSearchParams;r?.archived&&o.set("archived","1");r?.braneIds&&r.braneIds.length>0&&o.set("brane_ids",r.braneIds.join(","));const s=o.toString(),c=w(n,s?`/api/narratives?${s}`:"/api/narratives"),u=await f(c,{headers:t.NO_HEADERS});if(!u.ok)throw new Error(`Narratives ${u.status}`);return(await u.json()).narratives},e.fetchNarrative=async function(n,r){const o=await f(w(n,`/api/narratives/${r}`),{headers:t.NO_HEADERS});if(!o.ok)throw new Error(`Narrative ${o.status}`);return(await o.json()).narrative},e.fetchEvents=async function(n,r,o=0,s){const c=new URLSearchParams({after:String(o)});void 0!==s&&c.set("limit",String(s));const u=await f(w(n,`/api/narratives/${r}/events?${c}`),{headers:t.NO_HEADERS});if(!u.ok)throw new Error(`Events ${u.status}`);return u.json()},e.fetchToolUse=async function(n,r,o){const s=await f(w(n,`/api/narratives/${r}/tool_uses/${encodeURIComponent(o)}`),{headers:t.NO_HEADERS});if(!s.ok)throw new Error(`Tool use ${s.status}`);return(await s.json()).tool_use},e.fetchToolUseWindow=E,e.fetchToolUsesSince=y,e.fetchAllToolUseWindow=async function(t,n,r,o){let s;for(let c=0;c<_;c++){const c=await E(t,n,Object.assign({},r,{after:s}));if(o(c.tool_uses),!c.truncated||!c.next_cursor)return;s=c.next_cursor}console.warn(`[tool_uses] stopped paging window for ${n} after ${_} pages`)},e.fetchAllToolUsesSince=async function(t,n,r,o){let s=r;for(let r=0;r<_;r++){const r=await y(t,n,{sinceRev:s});if(o(r.tool_uses),!r.truncated||null==r.next_since_rev)return;s=r.next_since_rev}console.warn(`[tool_uses] stopped catching up ${n} after ${_} pages`)},e.fetchEventsBefore=async function(n,r,o,s=50){const c=new URLSearchParams({before:String(o),limit:String(s)}),u=await f(w(n,`/api/narratives/${r}/events?${c}`),{headers:t.NO_HEADERS});if(!u.ok)throw new Error(`Events ${u.status}`);return u.json()},e.sendSignal=async function(n,r,o,s="web",c,u){const h={content:o,source:s};c&&c.length>0&&(h.payloads=c);u&&u.length>0&&(h.re=u);const l=await f(w(n,`/api/narratives/${r}/signal`),{method:"POST",headers:t.JSON_HEADERS,body:JSON.stringify(h)});if(!l.ok)throw new Error(`Signal ${l.status}`);return l.json()},e.spawnAgent=async function(n,r,s,c="worker",u,h,l){const S={agent:r,fold_path:s,role:c};u&&(S.model=u);h&&h.length>0&&(S.extra_args=h);l&&(S.re=l);const E=(0,o.lastTerminalSize)();E&&(S.terminal_size=E);const y=await f(w(n,"/api/spawn"),{method:"POST",headers:t.JSON_HEADERS,body:JSON.stringify(S)});if(!y.ok){const t=await y.json().catch(()=>({}));throw new Error(t.error??`Spawn ${y.status}`)}return(await y.json()).narrative},e.runUtility=async function(n,r,s){const c=await f(w(n,"/api/run"),{method:"POST",headers:t.JSON_HEADERS,body:JSON.stringify({command:r,fold_path:s,terminal_size:(0,o.lastTerminalSize)()??void 0})});if(!c.ok){const t=await c.json().catch(()=>({}));throw new Error(t.error??`Run ${c.status}`)}return(await c.json()).narrative},e.fetchRunHistory=async function(n){const r=await f(w(n,"/api/run-history"),{headers:t.NO_HEADERS});if(!r.ok)throw new Error(`Run history ${r.status}`);return(await r.json()).history},e.fetchSpawnHistory=async function(n){const r=await f(w(n,"/api/spawn-history"),{headers:t.NO_HEADERS});if(!r.ok)throw new Error(`Spawn history ${r.status}`);return(await r.json()).history},e.fetchFolds=async function(n,r=!1){const o=await f(w(n,r?"/api/folds?archived=1":"/api/folds"),{headers:t.NO_HEADERS});if(!o.ok)throw new Error(`Folds ${o.status}`);return(await o.json()).folds},e.addFold=async function(n,r){const o=await f(w(n,"/api/folds"),{method:"POST",headers:t.JSON_HEADERS,body:JSON.stringify({path:r})});if(!o.ok){const t=await o.json().catch(()=>({}));throw new Error(t.error??`Add fold ${o.status}`)}return(await o.json()).fold},e.archiveFold=async function(n,r,o=!0){const s=await f(w(n,"/api/folds/archive"),{method:"PATCH",headers:t.JSON_HEADERS,body:JSON.stringify({path:r,archived:o})});if(!s.ok){const t=await s.json().catch(()=>({}));throw new Error(t.error??`Archive fold ${s.status}`)}return s.json()},e.fetchBranes=async function(n){const r=await f(w(n,"/api/branes"),{headers:t.NO_HEADERS});if(!r.ok)throw new Error(`Branes ${r.status}`);return(await r.json()).branes},e.reviveNarrative=async function(n,r,o){const s={};o&&(s.agent=o);const c=await f(w(n,`/api/revive/${r}`),{method:"POST",headers:t.JSON_HEADERS,body:JSON.stringify(s)});if(!c.ok){const t=await c.json().catch(()=>({}));throw new Error(t.error??`Revive ${c.status}`)}return c.json()},e.archiveNarrative=async function(n,r,o=!0){const s=await f(w(n,`/api/narratives/${r}/archive`),{method:"PATCH",headers:t.JSON_HEADERS,body:JSON.stringify({archived:o})});if(!s.ok)throw new Error(`Archive ${s.status}`);return s.json()},e.searchNarratives=async function(n,r,o=20,s){const c={query:r,limit:o};s&&s.length>0&&(c.brane_ids=s);const u=await f(w(n,"/api/search"),{method:"POST",headers:t.JSON_HEADERS,body:JSON.stringify(c)});if(!u.ok){const t=await u.json().catch(()=>({}));throw new Error(t.error??`Search ${u.status}`)}return u.json()},e.searchWiki=async function(n,r,o=10,s){const c={query:r,limit:o};s&&s.length>0&&(c.brane_ids=s);const u=await f(w(n,"/api/wiki/search"),{method:"POST",headers:t.JSON_HEADERS,body:JSON.stringify(c)});if(!u.ok){const t=await u.json().catch(()=>({}));throw new Error(t.error??`Wiki search ${u.status}`)}return u.json()},e.readWikiSection=async function(n,r){const o=new URLSearchParams({slug:r.slug});r.source&&o.set("source",r.source);r.anchor&&o.set("anchor",r.anchor);null!=r.window&&o.set("window",String(r.window));r.braneIds&&r.braneIds.length>0&&o.set("brane_ids",r.braneIds.join(","));const s=await f(w(n,`/api/wiki/read?${o.toString()}`),{headers:t.NO_HEADERS});if(!s.ok){const t=await s.json().catch(()=>({}));throw new Error(t.error??`Wiki read ${s.status}`)}return s.json()},e.listProtocols=async function(n){const r=await f(w(n,"/api/protocols"),{headers:t.NO_HEADERS});if(!r.ok){const t=await r.json().catch(()=>({}));throw new Error(t.error??`Protocols ${r.status}`)}return(await r.json()).protocols??[]},e.wikiAssetUrl=function(t,n,r){const o=new URLSearchParams({source:n,path:r});return w(t,`/api/wiki/asset?${o.toString()}`)},e.payloadUrl=function(t,n){return w(t,`/api/payloads/${n}`)},e.fetchFiles=async function(n,r,o,s){const c=new URLSearchParams({nid:r,path:o});void 0!==s&&c.set("offset",String(s));const u=await f(w(n,`/api/files?${c}`),{headers:t.NO_HEADERS});if(!u.ok){const t=await u.json().catch(()=>({}));throw new Error(t.error??`Files ${u.status}`)}return u.json()},e.streamFileFind=async function(n,r,o,s,c,u,h){const l=new URLSearchParams({nid:r,path:o,q:s});c>0&&l.set("from",String(c));const S=await f(w(n,`/api/files/find?${l}`),{headers:t.NO_HEADERS,signal:h});if(!S.ok){const t=await S.json().catch(()=>({}));throw new Error(t.error??`Find ${S.status}`)}if(!S.body)throw new Error("Find: no response body");const E=S.body.getReader(),y=new TextDecoder;let p="";try{for(;;){const{done:t,value:n}=await E.read();if(t)break;let r;for(p+=y.decode(n,{stream:!0});(r=p.indexOf("\n"))>=0;){const t=p.slice(0,r);p=p.slice(r+1),t&&u(JSON.parse(t))}}}finally{E.releaseLock()}},e.filesRawUrl=function(t,n,r){const o=new URLSearchParams({nid:n,path:r,raw:"1"});return w(t,`/api/files?${o}`)},e.fetchNarrativeExportHtml=async function(n,o,s=0,c,u="only"){const h=(0,r.formatSeqParam)(c),l=h?(0,r.formatSeqModeParam)(u):null,S=(s>0?`&palette=${s}`:"")+(h?`&seqs=${h}`:"")+(l?`&seqs_mode=${l}`:""),E=await f(w(n,`/api/narratives/${o}/export?format=html${S}`),{headers:t.NO_HEADERS});if(!E.ok){const t=await E.text().catch(()=>"");throw new Error(t||`Export ${E.status}`)}return E.blob()},e.fetchHighlight=async function(n,r,o){const s=await f(w(n,"/api/highlight"),{method:"POST",headers:t.JSON_HEADERS,body:JSON.stringify({content:r,lang:o})});if(!s.ok)return null;const c=await s.json().catch(()=>null);return c?.highlight??null},e.fetchDiagram=async function(n,r){const o=await f(w(n,"/api/diagram"),{method:"POST",headers:t.JSON_HEADERS,body:JSON.stringify({source:r})});if(!o.ok)return null;const s=await o.json().catch(()=>null);return s?.diagram??null},e.fetchFileList=async function(n,r){const o=new URLSearchParams({nid:r}),s=await f(w(n,`/api/files/list?${o}`),{headers:t.NO_HEADERS});if(!s.ok){const t=await s.json().catch(()=>({}));throw new Error(t.error??`File list ${s.status}`)}return s.json()},e.rotateToken=async function(n){const r=await f(w(n,"/api/token/rotate"),{method:"POST",headers:t.NO_HEADERS});if(!r.ok)throw new Error(`Rotate ${r.status}`);return r.json()},e.mintDeviceToken=async function(n){const r=await f(w(n,"/api/tokens"),{method:"POST",headers:t.NO_HEADERS});if(404===r.status)return null;if(!r.ok){const t=await r.json().catch(()=>({}));throw new Error(t.error??`Mint ${r.status}`)}const o=await r.json();return{token:o.token,validForMs:o.validForMs}},e.listDeviceTokens=async function(n){const r=await f(w(n,"/api/tokens"),{headers:t.NO_HEADERS});if(404===r.status)return null;if(!r.ok)throw new Error(`Devices ${r.status}`);return(await r.json()).tokens},e.revokeDeviceToken=async function(n,r,o=[]){const s=o.length?`?also=${o.map(encodeURIComponent).join(",")}`:"",c=await f(w(n,`/api/tokens/${encodeURIComponent(r)}/revoke${s}`),{method:"POST",headers:t.NO_HEADERS});if(c.ok||404===c.status)return;const u=await c.json().catch(()=>({}));throw new Error(u.error??`Revoke ${c.status}`)},e.probeDaemon=async function(n,r){const o={host:n,token:r},s=await f(w(o,"/api/status"),{headers:t.NO_HEADERS});if(!s.ok)throw new Error(`Status ${s.status}`);return s.json()};var t=_r(d[0]),n=_r(d[1]),r=_r(d[2]),o=_r(d[3]),s=_r(d[4]),c=_r(d[5]);const u="brane_conn";function h(){const t=new URLSearchParams(window.location.hash.slice(1)),n=new URLSearchParams(window.location.search),r=t.get("token")??n.get("token");if(!r)return null;return{host:t.get("host")??n.get("host")??window.location.host,token:r}}function w(n,r){return`${"https:"===window.location.protocol?"https":"http"}://${n.host}${(0,t.withToken)(r,n.token)}`}function f(n,r,o=t.DEFAULT_TIMEOUT_MS){const s=(0,t.isRetryableMethod)(r.method??"GET")?t.MAX_ATTEMPTS:1,c=r.signal,u=async h=>{const w=new AbortController,f=setTimeout(()=>w.abort(),o);c&&(c.aborted?w.abort():c.addEventListener("abort",()=>w.abort(),{once:!0}));try{const t=await fetch(n,Object.assign({},r,{signal:w.signal}));if(401===t.status&&l){const t=S(n);t&&l(t)}return t}catch(n){if(h+1<s&&(0,t.isRetryableError)(n)&&!c?.aborted)return await new Promise(n=>setTimeout(n,(0,t.retryDelayMs)(h))),u(h+1);throw n}finally{clearTimeout(f)}};return u(0)}!(function(){if("undefined"==typeof window||!window.history?.replaceState)return;const t=h();if(!t)return;try{sessionStorage.setItem(u,JSON.stringify(t))}catch{return}const r=window.location.pathname+(0,n.withoutConnectionParams)(window.location.search)+(0,n.withoutConnectionHash)(window.location.hash);window.history.replaceState(window.history.state,"",r)})();let l=null;function S(t){try{const n=new URL(t),r=n.searchParams.get("token");return r?{host:n.host,token:r}:null}catch{return null}}async function E(t,n,r={}){const o=new URLSearchParams;return void 0!==r.afterSeqGte&&o.set("after_seq_gte",String(r.afterSeqGte)),void 0!==r.afterSeqLt&&o.set("after_seq_lt",String(r.afterSeqLt)),void 0!==r.limit&&o.set("limit",String(r.limit)),r.after&&(o.set("after_cursor_seq",String(r.after.after_seq)),o.set("after_cursor_started_at",String(r.after.started_at)),o.set("after_cursor_dedup_key",r.after.dedup_key)),p(t,n,o)}async function y(t,n,r){const o=new URLSearchParams;return o.set("since_rev",String(r.sinceRev)),void 0!==r.limit&&o.set("limit",String(r.limit)),p(t,n,o)}async function p(n,r,o){const s=await f(w(n,`/api/narratives/${r}/tool_uses?${o}`),{headers:t.NO_HEADERS});if(!s.ok)throw new Error(`ToolUses ${s.status}`);return s.json()}const _=100},745,[746,747,748,749,751,752]);
849
849
  __d(function(g,r,_i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.requiresPreflight=function(c,i={}){if(!o.has(c.toUpperCase()))return!0;for(const[o,c]of Object.entries(i)){const i=o.toLowerCase();if(!n.has(i))return!0;if("content-type"===i){const n=c.split(";")[0].trim().toLowerCase();if(!t.includes(n))return!0}}return!1},Object.defineProperty(e,"NO_HEADERS",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"JSON_HEADERS",{enumerable:!0,get:function(){return i}}),e.withToken=function(t,n){const[o,c]=u(t),i=o.includes("?")?"&":"?";return`${o}${i}token=${encodeURIComponent(n)}${c}`},Object.defineProperty(e,"DEFAULT_TIMEOUT_MS",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"MAX_ATTEMPTS",{enumerable:!0,get:function(){return s}}),e.isRetryableMethod=function(t){const n=t.toUpperCase();return"GET"===n||"HEAD"===n},e.isRetryableError=function(t){if("undefined"!=typeof DOMException&&t instanceof DOMException)return"AbortError"===t.name;return t instanceof Error&&"AbortError"===t.name||t instanceof TypeError},e.retryDelayMs=function(t){return p*2**t};const t=["application/x-www-form-urlencoded","multipart/form-data","text/plain"],n=new Set(["accept","accept-language","content-language","content-type","range"]),o=new Set(["GET","HEAD","POST"]);const c={},i={"Content-Type":"application/json"};function u(t){const n=t.indexOf("#");return-1===n?[t,""]:[t.slice(0,n),t.slice(n)]}const f=6e4,s=3,p=500},746,[]);
850
- __d(function(g,r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CANONICAL_TABS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"SHARED_SPA_HOST",{enumerable:!0,get:function(){return o}}),e.isIsolatedHost=s,e.parseActiveTab=function(t){return n.has(t)?t:"chat"},e.parsePinnedTabs=function(t){return t?new Set(t.split(",").map(t=>t.trim()).filter(t=>n.has(t))):new Set},e.serializePinned=c,e.viewParams=u,e.terminalOnlyHref=function(t){const n=new URLSearchParams;for(const[t,o]of Object.entries(u("terminal",new Set)))o&&n.set(t,o);return`/${t}?${n.toString()}`},e.parseLineSpec=function(t){if(!t)return{};const n=t.match(/^(\d+)(?:-(\d+))?$/);if(!n)return{};const o=Number(n[1]),s=n[2]?Number(n[2]):void 0;return void 0!==s&&s>=o?{line:o,lineEnd:s}:{line:o}},Object.defineProperty(e,"CONNECTION_PARAMS",{enumerable:!0,get:function(){return f}}),e.withoutConnectionParams=function(t){const n=new URLSearchParams(t);for(const t of f)n.delete(t);const o=n.toString();return o?`?${o}`:""},e.withoutConnectionHash=function(t){const n=t.startsWith("#")?t.slice(1):t;if(!n)return"";const o=new URLSearchParams(n);for(const t of f)o.delete(t);const s=o.toString();return s?`#${s}`:""},e.connectionFragment=l,e.buildViewUrl=h,e.buildIsolateUrl=function(t){return h(s(t.hostname)?"shared":"daemon",t)},e.buildMeldUrl=function(t){return h(s(t.hostname)?"daemon":"shared",t)};const t=["chat","terminal","files"],n=new Set(t),o="brane.organelle.dev";function s(t){return t!==o}function c(n){return t.filter(t=>n.has(t)).join(",")}function u(t,n,o,s,u){return{tab:"chat"!==t?t:void 0,pinned:c(n)||void 0,path:o||void 0,line:s?u&&u>s?`${s}-${u}`:String(s):void 0}}const f=["host","token"];function l(t,n){const o=new URLSearchParams;return n&&o.set("host",t.host),o.set("token",t.token),`#${o.toString()}`}function h(t,n){const{protocol:s,search:c,path:u,conn:h,view:m}=n,S=new URLSearchParams(c);for(const[t,n]of Object.entries(m))n?S.set(t,n):S.delete(t);for(const t of f)S.delete(t);const b=S.toString(),p=(b?`?${b}`:"")+l(h,"shared"===t);if("shared"===t)return`https://${o}${u}${p}`;return`${"https:"===s?"https":"http"}://${h.host}${u}${p}`}},747,[]);
850
+ __d(function(g,r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CANONICAL_TABS",{enumerable:!0,get:function(){return t}}),e.isIsolated=o,e.parseActiveTab=function(t){return n.has(t)?t:"chat"},e.parsePinnedTabs=function(t){return t?new Set(t.split(",").map(t=>t.trim()).filter(t=>n.has(t))):new Set},e.serializePinned=s,e.viewParams=c,e.terminalOnlyHref=function(t){const n=new URLSearchParams;for(const[t,o]of Object.entries(c("terminal",new Set)))o&&n.set(t,o);return`/${t}?${n.toString()}`},e.parseLineSpec=function(t){if(!t)return{};const n=t.match(/^(\d+)(?:-(\d+))?$/);if(!n)return{};const o=Number(n[1]),s=n[2]?Number(n[2]):void 0;return void 0!==s&&s>=o?{line:o,lineEnd:s}:{line:o}},Object.defineProperty(e,"CONNECTION_PARAMS",{enumerable:!0,get:function(){return u}}),e.withoutConnectionParams=function(t){const n=new URLSearchParams(t);for(const t of u)n.delete(t);const o=n.toString();return o?`?${o}`:""},e.withoutConnectionHash=function(t){const n=t.startsWith("#")?t.slice(1):t;if(!n)return"";const o=new URLSearchParams(n);for(const t of u)o.delete(t);const s=o.toString();return s?`#${s}`:""},e.connectionFragment=f,e.buildViewUrl=l,e.buildIsolateUrl=function(t){return l(o(t.host,t.conn.host)?"shared":"daemon",t)},e.buildMeldUrl=function(t){return l(o(t.host,t.conn.host)?"daemon":"shared",t)};const t=["chat","terminal","files"],n=new Set(t);function o(t,n){return t.toLowerCase()===n.toLowerCase()}function s(n){return t.filter(t=>n.has(t)).join(",")}function c(t,n,o,c,u){return{tab:"chat"!==t?t:void 0,pinned:s(n)||void 0,path:o||void 0,line:c?u&&u>c?`${c}-${u}`:String(c):void 0}}const u=["host","token"];function f(t,n){const o=new URLSearchParams;return n&&o.set("host",t.host),o.set("token",t.token),`#${o.toString()}`}function l(t,n){const{protocol:o,search:s,path:c,conn:l,view:m}=n,$=new URLSearchParams(s);for(const[t,n]of Object.entries(m))n?$.set(t,n):$.delete(t);for(const t of u)$.delete(t);const S=$.toString(),w=(S?`?${S}`:"")+f(l,"shared"===t);if("shared"===t){const t=p(n);return null===t?null:`${t}${c}${w}`}return`${h(o)}://${l.host}${c}${w}`}function h(t){return"https:"===t?"https":"http"}function p(t){return o(t.host,t.conn.host)?t.appHost?`https://${t.appHost}`:null:`${h(t.protocol)}://${t.host}`}},747,[]);
851
851
  __d(function(g,r,i,_a,m,e,d){"use strict";function t(t){let n=2166136261;for(const o of[...t].sort((t,n)=>t-n).join(","))n^=o.charCodeAt(0),n=Math.imul(n,16777619)>>>0;return(n>>>8).toString(16).padStart(6,"0")}Object.defineProperty(e,'__esModule',{value:!0}),e.formatSeqParam=function(t){if(!t)return null;const n=[...new Set(t)].filter(t=>Number.isInteger(t)&&t>0).sort((t,n)=>t-n);return n.length>0?n.join(","):null},e.parseSeqParam=function(t){if(!t)return[];const n=new Set;for(const o of t.split(",")){const t=o.trim();if(!t)continue;if(!/^\d+$/.test(t))continue;const u=Number(t);Number.isSafeInteger(u)&&u>0&&n.add(u)}return[...n].sort((t,n)=>t-n)},e.formatSeqModeParam=function(t){return"except"===t?"except":null},e.parseSeqModeParam=function(t){return"except"===t?.trim()?"except":"only"},e.exportFileName=function(n,o){return o?`${n}.${o.seqs.length}-of-${o.total}.${t(o.seqs)}.html`:`${n}.html`},e.seqDigest=t},748,[]);
852
- __d(function(g,r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CONVERSATIONAL_EVENT_TYPES_LIST",{enumerable:!0,get:function(){return t}}),e.isSystemEvent=function(t){return!n.has(t)},e.formatInvocation=u,e.spawnedContent=l,e.revivedContent=function(t,n,o=[],l=!1){const c=`Revived ${u([t,...o])} /${n}`;return l?`${c} (forked \u2014 original still live)`:c},e.runningContent=function(t){return`Running ${u(t)}`},e.restartedContent=function(t){return`Restarted ${u(t)}`},e.agentTypeOf=function(t){return t.replace(/-[a-z0-9]{8}$/,"")},e.formatSystemContent=c,Object.defineProperty(e,"FOLD_LINK_SCHEME",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"FOLD_COLOR",{enumerable:!0,get:function(){return $}}),e.systemLine=function(t,n={}){let o=c(t.content,n.agent);const u=n.fold??null;if(!u)return o;const l=` in ${u}`;o.endsWith(l)&&(o=o.slice(0,-l.length));return"started"===t.type?`${o} in [${u}](${f}${u})`:o},e.relPart=s,e.formatActivitySpan=function(t,n,o=Date.now()){const u=s(t,o),l=t=>t.ago?`${t.val} ago`:t.val;if(!("number"==typeof n&&n-t>6e4))return l(u);const c=s(n,o);return u.val===c.val?l(u):u.ago&&c.ago?`${u.val} to ${c.val} ago`:`${l(u)} to ${l(c)}`},e.formatCost=m,e.formatCostTotals=function(t){if(!t?.length)return null;const n=t.map(t=>m(t.amount,t.unit)).filter(t=>!!t);return n.length?n.join(" \xb7 "):null};const t=["narration","human_signal","agent_signal"],n=new Set(t);function o(t){return""===t||/[\s'"$`\\]/.test(t)?`'${t.replace(/'/g,"'\\''")}'`:t}function u(t){const n=t.map(o).join(" "),u=Math.max(0,...Array.from(n.matchAll(/`+/g),t=>t[0].length)),l="`".repeat(u+1);return u?`${l} ${n} ${l}`:`${l}${n}${l}`}function l(t,n,o={}){const l=`Spawned ${u([t,...o.args??[]])} /${n}`;return o.from?`${l} from ${o.from}`:l}function c(t,n){const o=t.trimEnd();if(o.includes("`"))return o;let u;return(u=/^Spawned (\S+) \(([A-Za-z0-9][\w.-]*)\)$/.exec(o))?l(u[1],u[2]):(u=/^Twinned from (\S+)$/.exec(o))?n?l(n,"twin",{from:u[1]}):`/twin from ${u[1]}`:(u=/^Revived (\S+) session( \(.*\))?$/.exec(o))?`Revived \`${u[1]}\`${u[2]??""}`:(u=/^(Running|Restarted) (.+)$/.exec(o))?`${u[1]} \`${u[2]}\``:o}const f="brane://fold/",$="#5e8a72";function s(t,n=Date.now()){const o=Math.floor((n-t)/1e3);if(o<60)return{val:`${Math.max(1,o)}s`,ago:!0};const u=Math.floor(o/60);if(u<60)return{val:`${u}m`,ago:!0};const l=Math.floor(u/60);if(l<24)return{val:`${l}h`,ago:!0};const c=Math.floor(l/24);if(c<7)return{val:`${c}d`,ago:!0};const f=new Date(t),$=`${["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][f.getMonth()]} ${f.getDate()}`;return{val:f.getFullYear()===new Date(n).getFullYear()?$:`${$}, ${f.getFullYear()}`,ago:!1}}function m(t,n){if(null==t||!n)return null;if("USD"===n)return`$${t.toFixed(2)}`;return`${Number.isInteger(t)?t.toLocaleString():t.toLocaleString(void 0,{maximumFractionDigits:2})} ${n}`}},749,[]);
853
- __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"INLINE_PAYLOAD_MIME",{enumerable:!0,get:function(){return n}}),e.payloadExtname=t,e.isInlinePayload=function(o){return t(o)in n},e.attachmentDisposition=function(n){const t=n.replace(/[\\/]/g,"_").replace(o,"")||"download",p=t.replace(/"/g,'\\"');return/^[\x20-\x7e]*$/.test(t)?`attachment; filename="${p}"`:`attachment; filename="${c(t)}"; filename*=UTF-8''${l=t,encodeURIComponent(l).replace(/['()*]/g,n=>`%${n.charCodeAt(0).toString(16).toUpperCase()}`)}`;var l};const n={".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".bmp":"image/bmp",".avif":"image/avif",".svg":"image/svg+xml"};function t(n){const t=n.lastIndexOf(".");if(t<0)return"";const o=n.slice(t).toLowerCase();return o.includes("/")?"":o}const o=/[\u0000-\u001f\u007f]/g;function c(n){return n.replace(/[^\x20-\x7e]/g,"_").replace(/["\\]/g,"_").replace(/^_+$/,"")||"download"}},750,[]);
854
- __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.createControlChannel=function(n){const{conn:s,onMessage:o,onConnect:c,onDisconnect:u,onSignedOut:f}=n,b=`${"undefined"!=typeof window&&"https:"===window.location.protocol?"wss":"ws"}://${s.host}/ws/control?token=${s.token}`;let y=null,l=null,S=!1;const O=new Map,p=new Map;let v=0;return(function n(){if(S)return;y=new WebSocket(b),y.onopen=()=>{for(const[t,n]of O)y.send(JSON.stringify({type:"subscribe",narrative:t,after:n}));v>0&&y.send(JSON.stringify({type:"subscribe_activity"})),c?.()},y.onmessage=t=>{try{const n=JSON.parse(t.data);o(n)}catch{}},y.onclose=s=>{if(u?.(),!S)return(0,t.isSignedOutClose)(s.code)?(S=!0,void f?.()):void(l=setTimeout(n,2e3))},y.onerror=()=>{y?.close()}})(),{subscribe:function(t,n=0){const s=p.get(t)??0;if(p.set(t,s+1),s>0)return;O.set(t,n),y?.readyState===WebSocket.OPEN&&y.send(JSON.stringify({type:"subscribe",narrative:t,after:n}))},unsubscribe:function(t){const n=p.get(t)??0;if(n>1)return void p.set(t,n-1);p.delete(t),O.delete(t),y?.readyState===WebSocket.OPEN&&y.send(JSON.stringify({type:"unsubscribe",narrative:t}))},subscribeActivity:function(){if(v+=1,v>1)return;y?.readyState===WebSocket.OPEN&&y.send(JSON.stringify({type:"subscribe_activity"}))},unsubscribeActivity:function(){if(v>1)return void(v-=1);v=0,y?.readyState===WebSocket.OPEN&&y.send(JSON.stringify({type:"unsubscribe_activity"}))},send:function(t,n,s="web"){y?.readyState===WebSocket.OPEN&&y.send(JSON.stringify({type:"signal",narrative:t,content:n,source:s}))},close:function(){S=!0,l&&clearTimeout(l);y?.close()}}};var t=r(d[0])},751,[752]);
855
- __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"WS_CLOSE_TOKEN_ROTATED",{enumerable:!0,get:function(){return t}}),e.isSignedOutClose=function(n){return n===t};const t=4401},752,[]);
856
- __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.isAwaiting=function({mcpConnected:n,awaiting:t}){return!!n&&!!t},e.awaitingGlow=function(n){return[`inset 0 0 3px 1px oklch(0.78 0.16 ${n} / 0.95)`,`inset 0 0 18px 2px oklch(0.74 0.15 ${n} / 0.55)`,`inset 0 0 40px 4px oklch(0.7 0.14 ${n} / 0.28)`,`inset 0 4px 3px -3px oklch(0.78 0.16 ${n} / 0.95)`].join(", ")},Object.defineProperty(e,"AWAITING_STATUS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"NOT_AWAITING_STATUS",{enumerable:!0,get:function(){return t}});const n="awaiting",t="not_awaiting"},753,[]);
857
- __d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DAEMONS_KEY",{enumerable:!0,get:function(){return t}}),e.loadDaemons=u,e.saveDaemons=l,e.addDaemon=function(t){const n=u(),o=n.findIndex(n=>n.brane_id===t.brane_id);o>=0?n[o]=Object.assign({},t,{addedAt:n[o].addedAt}):n.push(t);return l(n),n},e.updateDaemon=function(t,n){const o=u().map(o=>o.id===t?Object.assign({},o,n):o);return l(o),o},e.removeDaemon=function(t){const n=u().filter(n=>n.id!==t);l(n),f()===t&&I(n[0]?.id??null);s()===t&&d(n[0]?.id??null);return n},e.getActiveDaemonId=function(){c();try{return sessionStorage.getItem(n)??localStorage.getItem(o)}catch{return null}},e.setActiveDaemonId=d,e.getDefaultDaemonId=f,e.setDefaultDaemonId=I;const t="brane_daemons",n="brane_active_daemon",o="brane_default_daemon";function c(){try{const t=localStorage.getItem(n);t&&!localStorage.getItem(o)&&localStorage.setItem(o,t),t&&localStorage.removeItem(n)}catch{}}function u(){try{const n=localStorage.getItem(t);return n?JSON.parse(n):[]}catch{return[]}}function l(n){localStorage.setItem(t,JSON.stringify(n))}function s(){try{return sessionStorage.getItem(n)}catch{return null}}function d(t){try{t?sessionStorage.setItem(n,t):sessionStorage.removeItem(n)}catch{}}function f(){try{return localStorage.getItem(o)}catch{return null}}function I(t){try{t?localStorage.setItem(o,t):localStorage.removeItem(o)}catch{}}},754,[]);
858
- __d(function(g,r,i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return u}});var t=e(r(d[0])),l=e(r(d[1])),n=e(r(d[2])),o=e(r(d[3])),s=e(r(d[4])),c=r(d[5]);function u({pending:e,onConfirm:s,onCancel:u}){const h=null!==e,x=e?`${e.status.username}@${e.status.hostname}`:"";return(0,c.jsx)(t.default,{visible:h,transparent:!0,animationType:"fade",onRequestClose:u,children:(0,c.jsx)(l.default,{style:b.backdrop,onPress:u,children:(0,c.jsxs)(l.default,{style:b.card,onPress:e=>e.stopPropagation(),children:[(0,c.jsx)(n.default,{style:b.title,children:e?.isUpdate?"Update credentials?":"Meld this device?"}),e?.isUpdate?(0,c.jsx)(n.default,{style:b.body,children:"You're already paired with this brane. The meld URL has a new token \u2014 replace the stored one?"}):(0,c.jsx)(n.default,{style:b.body,children:"You'll add this daemon to this device and switch to it."}),(0,c.jsxs)(o.default,{style:b.detailsBlock,children:[(0,c.jsx)(f,{label:"Daemon",value:x}),(0,c.jsx)(f,{label:"Address",value:e?.host??""}),(0,c.jsx)(f,{label:"Brane",value:e?.status.brane_id??"",mono:!0})]}),(0,c.jsxs)(o.default,{style:b.buttonRow,children:[(0,c.jsx)(l.default,{style:[b.button,b.cancelButton],onPress:u,children:(0,c.jsx)(n.default,{style:b.cancelText,children:"Cancel"})}),(0,c.jsx)(l.default,{style:[b.button,b.confirmButton],onPress:s,children:(0,c.jsx)(n.default,{style:b.confirmText,children:e?.isUpdate?"Update":"Meld"})})]})]})})})}function f({label:e,value:t,mono:l}){return(0,c.jsxs)(o.default,{style:b.detailRow,children:[(0,c.jsx)(n.default,{style:b.detailLabel,children:e}),(0,c.jsx)(n.default,{style:[b.detailValue,l&&b.detailValueMono],numberOfLines:1,selectable:!0,children:t})]})}const b=s.default.create({backdrop:{flex:1,backgroundColor:"rgba(0,0,0,0.7)",justifyContent:"center",alignItems:"center",padding:24},card:{backgroundColor:"#1e1e1e",borderRadius:12,padding:22,width:"100%",maxWidth:360},title:{color:"#e0e0e0",fontSize:17,fontWeight:"600",marginBottom:10,textAlign:"center"},body:{color:"#bbb",fontSize:13,lineHeight:18,marginBottom:14,textAlign:"center"},detailsBlock:{backgroundColor:"#2a2a2a",borderRadius:8,padding:12,marginBottom:18},detailRow:{flexDirection:"row",paddingVertical:3},detailLabel:{color:"#888",fontSize:12,width:70},detailValue:{color:"#e0e0e0",fontSize:12,flex:1},detailValueMono:{fontFamily:"monospace"},buttonRow:{flexDirection:"row",gap:10},button:{flex:1,paddingVertical:10,borderRadius:6,alignItems:"center"},cancelButton:{backgroundColor:"#2a2a2a"},cancelText:{color:"#ccc",fontSize:14},confirmButton:{backgroundColor:"#2e7d32"},confirmText:{color:"#fff",fontSize:14,fontWeight:"600"}})},755,[153,146,105,13,26,6]);
859
- __d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.installNoPan=function(){if(t||"undefined"==typeof window)return;t=!0;const n=window.visualViewport,o=document.documentElement;let s=null;const c=()=>{if(!n)return;const t=(0,e.layoutHeight)(n.height,n.scale,s);null!==t&&t!==s&&(s=t,o.style.setProperty("--brane-vvh",`${t}px`))};n&&(n.addEventListener("resize",c),c());const l=!window.matchMedia?.("(pointer: fine)").matches;let u=0;const h=()=>{const t=document.activeElement;(0,e.mustBlur)({touch:l,textEntryFocused:!!t&&(0,e.isTextEntry)(t),keyboardUp:!!n&&window.innerHeight-n.height>120,msSinceTapFocus:Date.now()-u})&&t?.blur()};n&&n.addEventListener("resize",h);document.addEventListener("focusin",()=>{setTimeout(h,e.TAP_FOCUS_GRACE_MS+50)},!0);let p=0,v=0,f=!1,w=!1;document.addEventListener("touchstart",e=>{const t=e.touches[0];p=t.clientX,v=t.clientY,f=!1,w=e.touches.length>1},{passive:!0,capture:!0}),document.addEventListener("touchmove",t=>{const o=t.touches[0],s=o.clientX-p,c=o.clientY-v;if((Math.abs(s)>e.TAP_SLOP_PX||Math.abs(c)>e.TAP_SLOP_PX)&&(f=!0),w||t.touches.length>1||n&&Math.abs(n.scale-1)>.01)return;const l=[];for(let n=t.target;n&&n!==document.body;n=n.parentElement){const t=getComputedStyle(n);l.push((0,e.scrollBoxOf)({overflowY:t.overflowY,reversed:t.display.includes("flex")&&"column-reverse"===t.flexDirection,scrollTop:n.scrollTop,clientHeight:n.clientHeight,scrollHeight:n.scrollHeight}))}(0,e.dragAllowed)(s,c,l)||t.preventDefault()},{passive:!1,capture:!0}),document.addEventListener("touchend",t=>{if(f||w)return;const n=t.target?.closest?.("input, textarea, [contenteditable]");n&&n!==document.activeElement&&(0,e.isTextEntry)(n)&&(t.preventDefault(),u=Date.now(),n.focus({preventScroll:!0}))},{passive:!1,capture:!0})},r(d[0]);var e=r(d[1]);let t=!1},756,[116,757]);
860
- __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"TAP_SLOP_PX",{enumerable:!0,get:function(){return o}}),e.isTextEntry=function(o){if(o.isContentEditable)return!0;const n=o.tagName.toUpperCase();return("INPUT"===n||"TEXTAREA"===n)&&(!o.disabled&&!o.readOnly&&("TEXTAREA"===n||!t.has((o.type??"text").toLowerCase())))},e.scrollBoxOf=function(o){const t=o.scrollHeight-o.clientHeight;if("auto"!==o.overflowY&&"scroll"!==o.overflowY||!(t>1))return{scrolls:!1,roomAbove:0,roomBelow:0};const[n,s]=o.reversed?[-t,0]:[0,t];return{scrolls:!0,roomAbove:o.scrollTop-n,roomBelow:s-o.scrollTop}},e.dragAllowed=function(o,t,n){if(Math.abs(o)>Math.abs(t))return!0;if(0===t)return!0;for(const o of n)if(o.scrolls){if(t>0&&o.roomAbove>1)return!0;if(t<0&&o.roomBelow>1)return!0}return!1},e.layoutHeight=function(o,t,n){return Math.abs(t-1)>.01?n:Math.round(o)},Object.defineProperty(e,"TAP_FOCUS_GRACE_MS",{enumerable:!0,get:function(){return n}}),e.mustBlur=function(o){return o.touch&&o.textEntryFocused&&!o.keyboardUp&&o.msSinceTapFocus>n};const o=10,t=new Set(["button","checkbox","color","file","hidden","image","radio","range","reset","submit"]);const n=1e3},757,[]);
861
- __d(function(g,r,i,a,_m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return N}});var t=r(d[0]);r(d[1]);var n=e(r(d[2]));r(d[3]);var o=e(r(d[4])),l=e(r(d[5])),s=e(r(d[6])),u=r(d[7]),c=r(d[8]),f=r(d[9]);function p(e){const t=e.match(/^mcp__([^_]+(?:_[^_]+)*?)__(.+)$/);return t?`${t[1]}:${t[2]}`:e}function y(e){if(!e)return null;try{return JSON.parse(e)}catch{return null}}function h(e){return"object"!=typeof e||null===e||Array.isArray(e)?null:e}function m(e){const t=h(y(e.output));if(!t)return null;if(Array.isArray(t.content)){const e=t.content.find(e=>"string"==typeof e?.text)?.text;return h(y("string"==typeof e?e:null))}return t}function x(e){const t=p(e.name);if("brane:listen"===t)return{kind:"listen"};if("brane:narrate"!==t)return{kind:"work"};const n=h(y(e.input))?.nid;if("string"!=typeof n||n===e.narrative_id)return{kind:"self_narrate"};const o=m(e)?.seq;return{kind:"foreign_narrate",nid:n,seq:"number"==typeof o?o:void 0}}const b=240,j=8e3;function _(e){if(!e.input)return"";let t;try{t=JSON.parse(e.input)}catch{return e.input}if("object"!=typeof t||null===t)return String(t);const n=t,o=n.command??n.file_path??n.pattern??n.url??n.query??n.path;if("string"==typeof o)return o;const l=Object.values(n).find(e=>"string"==typeof e);return"string"==typeof l?l:e.input}function w(e){const t=_(e).replace(/\s*\n\s*/g," \u23ce ");return t.length>b?`${t.slice(0,b)}\u2026`:t}function k(e){if(!e)return null;const t=y(e);return null===t?e:JSON.stringify(t,null,2)}function S(e){return e.length<=j?{body:e,note:null}:{body:e.slice(0,j),note:`+${(e.length-j).toLocaleString()} more characters`}}function v(e){const t=h(y(e));return!!t&&0===Object.keys(t).length}function L(e){const t=[],n=p(e.name).startsWith("brane:"),o=(e,o,l)=>{if(!o)return;if(n&&("input"===e||"output"===e)&&v(o))return;const{body:s,note:u}=S(o);t.push({label:e,body:s,note:[l?.note,u].filter(Boolean).join(" \xb7 ")||null,failed:l?.failed})};return o("input",k(e.input),{note:e.input_truncated?"excerpt \u2014 the daemon holds the full value":void 0}),o("output",k(e.output),{note:e.output_truncated?"excerpt \u2014 the daemon holds the full value":void 0}),o("error",e.error,{failed:!0}),(e.decided_by||e.decision_note)&&o("decision",[e.decided_by,e.decision_note].filter(Boolean).join(" \u2014 ")),t}function $(e){return[e.status,e.source,e.agent_type].filter(Boolean).join(" \xb7 ")}function O(e){return null==e?"":e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}function z(e){return"failed"===e.status||"denied"===e.status}function F(e){return z(e)?{glyph:"\u2717",failed:!0}:"unknown"===e.status?{glyph:"\u2013",failed:!1}:"pending"===e.status||"allowed"===e.status?{glyph:"\u2026",failed:!1}:null}function T({children:e}){const t=(0,u.useHorizontalPanGuard)();return(0,f.jsx)("div",Object.assign({style:{overflowX:"auto",overflowY:"hidden"}},t,{children:(0,f.jsx)("div",{style:{display:"flex",flexDirection:"column",width:"max-content",minWidth:"100%"},children:e})}))}function N({rows:e,onNarrativePress:o,onFetchFull:u}){const y=(0,t.useMemo)(()=>e.map(e=>({row:e,kind:x(e)})).filter(({kind:e})=>"self_narrate"!==e.kind),[e]),h=y.some(({row:e})=>z(e)),[m,b]=(0,t.useState)(h),j=(0,t.useRef)(!1);(0,t.useEffect)(()=>{h&&!j.current&&b(!0)},[h]);const[_,k]=(0,t.useState)(P),S=(0,t.useCallback)(e=>{k(t=>{const n=new Set(t);return n.delete(e)||n.add(e),n})},[]),[v,L]=(0,t.useState)(0),$=(0,t.useMemo)(()=>{const e=new Map;let t=0;for(const{row:n,kind:o}of y){const l=p(n.name);e.set(l,(e.get(l)??0)+1),"listen"!==o.kind&&(t+=n.duration_ms??0)}const n=[...e.entries()].map(([e,t])=>t>1?`${e} \xd7${t}`:e).join(", ");return`${1===y.length?"1 tool":`${y.length} tools`}${t>0?` (${O(t)})`:""}: ${n}`},[y]);return 0===y.length?null:(0,f.jsxs)(s.default,{style:R.container,dataSet:{chrome:"tools"},onLayout:e=>L(e.nativeEvent.layout.width),children:[(0,f.jsxs)(n.default,{onPress:()=>{j.current=!0,b(e=>(e&&k(P),!e))},style:R.summaryRow,children:[(0,f.jsx)(l.default,{style:R.gear,children:"\u2699"}),(0,f.jsx)(l.default,{style:[R.summaryText,h&&R.failText],numberOfLines:1,children:$})]}),m&&(0,f.jsx)(T,{children:y.map(({row:e,kind:y})=>{const h=F(e),m=_.has(e.dedup_key);return(0,f.jsxs)(t.Fragment,{children:[(0,f.jsxs)(n.default,{style:R.row,onPress:()=>S(e.dedup_key),accessibilityRole:"button",accessibilityState:{expanded:m},children:[(0,f.jsx)(l.default,{style:R.gear,children:"\u2699"}),(0,f.jsx)(l.default,{style:[R.name,h?.failed&&R.failText],numberOfLines:1,children:p(e.name)}),"foreign_narrate"===y.kind?(0,f.jsx)(l.default,{style:[R.args,C],numberOfLines:q?void 0:1,children:(0,f.jsxs)(l.default,Object.assign({style:R.link},A((0,c.narrativeHref)(y.nid,y.seq),()=>o?.(y.nid,y.seq)),{children:["\u2192\xa0",y.seq?`${y.nid}:${y.seq}`:y.nid]}))}):(0,f.jsx)(l.default,{style:[R.args,C],numberOfLines:q?void 0:1,children:w(e)}),(0,f.jsx)(s.default,{style:R.slack}),(0,f.jsxs)(s.default,{style:[R.trailing,M],children:[(0,f.jsx)(l.default,{style:R.duration,children:O(e.duration_ms)}),(0,f.jsx)(l.default,{style:[R.status,h?.failed&&R.failText],children:h?.glyph??" "})]})]}),m&&(0,f.jsx)(n.default,{style:[R.detail,D,v>0?{width:v-2*H}:null],onPress:()=>{"undefined"!=typeof window&&window.getSelection()?.toString()||S(e.dedup_key)},children:(0,f.jsx)(B,{row:e,onFetchFull:u})})]},e.dedup_key)})}),m&&y.map(({row:e})=>e).filter(z).map(e=>e.error?(0,f.jsx)(l.default,{style:[R.errorLine,R.failText],numberOfLines:2,children:e.error},`${e.dedup_key}-err`):null)]})}function B({row:e,onFetchFull:n}){const[o,u]=(0,t.useState)(null),[c,p]=(0,t.useState)(!1),y=!(!e.input_truncated&&!e.output_truncated);(0,t.useEffect)(()=>{if(!y||!n||o)return;let t=!0;return n(e.dedup_key).then(e=>{t&&u(e)}).catch(()=>{t&&p(!0)}),()=>{t=!1}},[y,n,o,e.dedup_key]);const h=o??e,m=(0,t.useMemo)(()=>L(h),[h]),x=y&&!o&&!c;return(0,f.jsxs)(f.Fragment,{children:[x&&(0,f.jsx)(l.default,{style:R.detailNote,children:"excerpt \u2014 fetching the rest\u2026"}),c&&(0,f.jsx)(l.default,{style:[R.detailNote,R.failText],children:"excerpt \u2014 the full value could not be fetched"}),0===m.length?(0,f.jsx)(l.default,{style:R.detailNote,children:"nothing recorded beyond the row itself"}):m.map(e=>(0,f.jsxs)(s.default,{style:R.detailSection,children:[(0,f.jsx)(l.default,{style:R.detailLabel,children:e.label}),(0,f.jsx)(l.default,{style:[R.detailBody,e.failed&&R.failText],selectable:!0,children:e.body}),e.note&&(0,f.jsx)(l.default,{style:R.detailNote,children:e.note})]},e.label)),(0,f.jsx)(l.default,{style:R.detailNote,children:$(h)})]})}const P=new Set;function A(e,t){const n=(0,c.inAppLinkProps)(e,t),o=n.onClick;return Object.assign({},n,{onClick:e=>{e.stopPropagation?.(),o?.(e)}})}const q=!0,C={whiteSpace:"nowrap",textOverflow:"clip"},M={position:"sticky",right:0},D={position:"sticky",left:0},H=12,R=o.default.create({container:{paddingHorizontal:H,paddingTop:4,paddingBottom:10},summaryRow:{flexDirection:"row",alignItems:"center"},row:{flexDirection:"row",alignItems:"center",paddingVertical:2,paddingLeft:18},gear:{color:"#666",fontSize:11,width:18,textAlign:"center"},summaryText:{color:"#8a8a8e",fontSize:12,flexShrink:1},name:{color:"#9a9aa0",fontSize:12,fontFamily:"monospace",minWidth:64,paddingRight:8},args:{color:"#666",fontSize:12,fontFamily:"monospace"},slack:{flex:1,minWidth:8},link:{color:"#6cb6ff",textDecorationLine:"underline"},trailing:{flexDirection:"row",alignItems:"center",backgroundColor:"#111",paddingLeft:10},duration:{color:"#666",fontSize:11,paddingLeft:8,textAlign:"right"},status:{fontSize:11,width:14,textAlign:"center",color:"#666"},detail:{alignSelf:"flex-start",backgroundColor:"#17171b",borderLeftWidth:2,borderLeftColor:"#333",paddingHorizontal:10,paddingVertical:6,marginBottom:4},detailSection:{paddingBottom:6},detailLabel:{color:"#8a8a8e",fontSize:10,textTransform:"uppercase",letterSpacing:.5,paddingBottom:2},detailBody:{color:"#c8c8cc",fontSize:11,fontFamily:"monospace",lineHeight:15},detailNote:{color:"#666",fontSize:10,fontStyle:"italic"},errorLine:{fontSize:11,fontFamily:"monospace",paddingLeft:36,paddingVertical:1},failText:{color:"#e57373"}})},758,[11,116,146,122,26,105,13,759,760,6]);
862
- __d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.useHorizontalPanGuard=function(){const e=(0,n.useRef)(null),u=(0,n.useRef)(!1);return(0,n.useMemo)(()=>{const n=n=>{u.current&&n.stopPropagation?.(),e.current=null,u.current=!1};return{onTouchStart:n=>{e.current=t(n),u.current=!1},onTouchMove:n=>{const o=e.current;if(o){if(!u.current){const{x:e,y:c}=t(n),s=Math.abs(e-o.x),l=Math.abs(c-o.y);s>6&&s>1.2*l&&(u.current=!0)}u.current&&n.stopPropagation()}},onTouchEnd:n,onTouchCancel:n}},[])};var n=r(d[0]);function t(n){const t=n.nativeEvent?.touches?.[0]??n.nativeEvent??n;return{x:t.pageX??t.clientX??0,y:t.pageY??t.clientY??0}}},759,[11]);
863
- __d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.inAppLinkProps=function(t,n){return t?{href:t,onClick:t=>{e(t)&&(t.preventDefault(),n())}}:{onPress:n}},_e.narrativeHref=function(e,t){return t?`/${e}?scrollToSeq=${t}`:`/${e}`},_e.fileHref=function(e,t,n,o,u){const f=new URLSearchParams({tab:"files",path:t});n&&f.set("line",o&&o>n?`${n}-${o}`:String(n));u&&f.set("pinned",u);return`/${e}?${f.toString()}`},r(d[0]);function e(e){return!(0!==e.button||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey)}},760,[116]);
864
- __d(function(g,r,_i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return H}});var t=r(d[0]);r(d[1]);var n=r(d[2]),o=r(d[3]),c=r(d[4]),s=r(d[5]),l=r(d[6]),i=e(r(d[7])),u=e(r(d[8])),f=e(r(d[9])),p=r(d[10]),y=r(d[11]);const h=1.4,v=16.799999999999997,b=(0,c.blockGlyphStylesheet)(h);function x(e,t){let n="";return e.ctrlKey&&(n+="C-"),e.altKey&&(n+="M-"),t&&e.shiftKey&&(n+="S-"),n}const C={Enter:"Enter",Escape:"Escape",Tab:"Tab",Backspace:"BSpace",Delete:"DC",Insert:"IC",ArrowUp:"Up",ArrowDown:"Down",ArrowLeft:"Left",ArrowRight:"Right",Home:"Home",End:"End",PageUp:"PPage",PageDown:"NPage",F1:"F1",F2:"F2",F3:"F3",F4:"F4",F5:"F5",F6:"F6",F7:"F7",F8:"F8",F9:"F9",F10:"F10",F11:"F11",F12:"F12"};function w(e){const t=C[e.key];if(t)return x(e,!0)+t;if(" "===e.key){const t=x(e,!1);return t?t+"Space":" "}return(e.ctrlKey||e.altKey)&&1===e.key.length?x(e,!1)+e.key.toLowerCase():1!==e.key.length||e.ctrlKey||e.altKey||e.metaKey?null:e.key}const k=[{label:"Esc",keys:"Escape"},{label:"1",keys:"1"},{label:"2",keys:"2"},{label:"3",keys:"3"}],E="undefined"!=typeof navigator&&"undefined"!=typeof document&&(/iP(ad|hone|od)/.test(navigator.userAgent)||/Mac/.test(navigator.userAgent)&&"ontouchend"in document),S="undefined"!=typeof navigator&&/Mac|iP(ad|hone|od)/.test(navigator.platform||navigator.userAgent);function F(e){return"v"===e.key.toLowerCase()&&!e.altKey&&(S?e.metaKey&&!e.ctrlKey:e.ctrlKey&&!e.metaKey)}const R=/[\u23fa\u{1F518}]/gu;const M=/\x1b\][\s\S]*?(?:\x07|\x1b\\)/g;function j(e){return e.replace(M,"")}function K({onPress:e,style:n,children:o}){const[c,s]=(0,t.useState)(!1),l=(0,t.useRef)(null),i=(0,t.useCallback)(()=>{e(),l.current&&clearTimeout(l.current),s(!0),l.current=setTimeout(()=>s(!1),180)},[e]);return(0,y.jsx)("button",{onClick:i,style:Object.assign({},n,c?{backgroundColor:"#4444cc",border:"1px solid #7c7cff",color:"#fff",boxShadow:"0 0 8px rgba(120, 120, 255, 0.8)"}:{boxShadow:"none"},{transition:"background-color 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease, color 0.15s ease"}),children:o})}const L=(0,t.forwardRef)(function({conn:e,nid:x,active:C=!0,keyboardActive:S,agentType:M,role:L,onAtBottomChange:H,onTwin:A,onRevived:T},D){const P=(0,t.useRef)(null),z=(0,t.useRef)(null),_=(0,t.useRef)(null),B=(0,t.useRef)(!0),I=(0,t.useRef)(null),N=(0,t.useRef)(null),X=(0,t.useRef)(null),Y=(0,t.useRef)(0),q=(0,t.useRef)(C);q.current=C;const O=(0,t.useRef)(S??C);O.current=S??C;const W=(0,n.useIsFocused)(),U=(0,t.useRef)(W);U.current=W;const[G,$]=(0,t.useState)(!1),[J,Q]=(0,t.useState)(!1),V=(0,t.useRef)(null),Z=(0,t.useRef)(!1);Z.current=J;const[ee,te]=(0,t.useState)(!1),[ne,re]=(0,t.useState)(!1),oe=(0,t.useRef)(()=>{}),[ce,se]=(0,t.useState)(!1),le=(0,t.useRef)(!1),ie=(0,t.useRef)(null),ue=(0,t.useRef)(null),ae=(0,t.useRef)(null),de=(S??C)&&W,fe=(0,t.useRef)(de);fe.current=de;const pe=(0,t.useRef)(!0),ye=(0,t.useRef)(H);ye.current=H;const he=(0,t.useCallback)(e=>{pe.current=e,le.current&&e!==B.current&&(B.current=e,ye.current?.(e))},[]),me=(0,t.useCallback)(e=>{"C-End"===e?he(!0):"PPage"!==e&&"C-Home"!==e||he(!1)},[he]);(0,t.useImperativeHandle)(D,()=>({focus:()=>{const e=P.current;if(e)try{e.focus({preventScroll:!0})}catch{e.focus()}},scrollToTop:()=>{if(le.current)return _.current?.sendKeys("C-Home"),void he(!1);const e=P.current;e&&(e.scrollTop=0,B.current=!1,H?.(!1))},scrollToBottom:()=>{if(le.current)return _.current?.sendKeys("C-End"),void he(!0);const e=P.current;e&&(e.scrollTop=e.scrollHeight,B.current=!0,H?.(!0))},terminate:()=>{(0,l.sendInterrupt)(e=>_.current?.sendKeys(e))},revive:()=>{oe.current()}}),[H,he]);const ve=(0,t.useRef)(new WeakMap),ge=(0,t.useCallback)((e,t)=>{var n;0===t.length?e.textContent="\xa0":z.current?e.innerHTML=(0,c.paintBlockGlyphs)(z.current.ansi_to_html((n=j(t),E?n.replace(R,"\u25cf"):n))):e.textContent=j(t)},[]),be=(0,t.useCallback)(e=>{const t=document.createElement("div");return t.style.display="block",t.style.minHeight="1.4em",t.style.position="relative",ge(t,e),ve.current.set(t,e),t},[ge]),xe=(0,t.useCallback)((e,t)=>{ge(e,t),ve.current.set(e,t)},[ge]),Ce=(0,t.useCallback)(e=>ve.current.get(e),[]),we=(0,t.useCallback)(()=>{const e=P.current?.querySelector("pre"),t=ae.current,n=ue.current,o=ie.current;if(!e||!n||!o)return void(t?.parentNode&&t.parentNode.removeChild(t));const c=e.children[n.line];if(!c)return void(t?.parentNode&&t.parentNode.removeChild(t));const s=t??document.createElement("span");t||(s.style.position="absolute",s.style.top="0",s.style.pointerEvents="none",s.style.backgroundColor="#fff",s.style.mixBlendMode="difference",ae.current=s),s.style.left=n.col*o.width+"px",s.style.width=`${o.width}px`,s.style.height=`${v}px`,fe.current?(s.style.backgroundColor="#fff",s.style.border="none",s.style.animation="brane-cursor-blink 1.06s steps(1, end) infinite"):(s.style.backgroundColor="transparent",s.style.border="1px solid #fff",s.style.boxSizing="border-box",s.style.animation="none"),"relative"!==c.style.position&&(c.style.position="relative"),s.parentNode!==c&&c.appendChild(s)},[]);(0,t.useEffect)(()=>{we()},[de,we]);const ke=(0,t.useCallback)(()=>{const e=P.current,t=e?.querySelector("pre");if(t){for(;t.firstChild;)t.removeChild(t.firstChild);ve.current=new WeakMap,ae.current=null}_.current?.refresh()},[]),Ee=(0,t.useCallback)((e,t)=>{const n=Array.from(e.children),o=t.length,c=n.length,s=Math.min(o,c);let l=o!==c;for(let e=0;e<s;e++)Ce(n[e])!==t[e]&&(xe(n[e],t[e]),l=!0);if(o>c){const n=document.createDocumentFragment();for(let e=c;e<o;e++)n.appendChild(be(t[e]));e.appendChild(n)}else if(c>o)for(let t=c-1;t>=o;t--)e.removeChild(n[t]);return l},[be,xe,Ce]),Se=(0,t.useCallback)((e,t,n,o)=>{const c=Math.max(0,0|n),s=Math.max(0,0|o),l=Array.from(e.children).length;let i=!1;if(c>l){const t=document.createDocumentFragment();for(let e=l;e<c;e++)t.appendChild(be(""));e.appendChild(t),i=!0}const u=Array.from(e.children);let f=null;for(let e=0;e<t.length;e++){const n=c+e;n<u.length?Ce(u[n])!==t[e]&&(xe(u[n],t[e]),i=!0):(f||(f=document.createDocumentFragment()),f.appendChild(be(t[e])),i=!0)}f&&e.appendChild(f);const p=e.children.length;if(p>s){for(let t=p-1;t>=s;t--){const n=e.children[t];n&&e.removeChild(n)}i=!0}return i},[be,xe,Ce]),Fe=(0,t.useCallback)(e=>{const t=P.current;if(!t||!z.current)return;const n=t.querySelector("pre");if(!n)return;const o=t,c=le.current?pe.current:o.scrollHeight-o.scrollTop-o.clientHeight<40;let s;c!==B.current&&H?.(c),B.current=c,"frame"!==e.type&&"append"!==e.type||(ue.current=e.cursor??null);let l=!1;if("frame"===e.type){const t=e.data.split("\n");l=Ee(n,t),s=e.alternate_on}else if("append"===e.type){const t=e.data.split("\n");l=Se(n,t,e.lineOffset,e.totalLines),s=e.alternate_on}void 0!==s&&s!==le.current&&(le.current=s,se(s)),we(),l&&B.current&&o.scrollHeight>o.clientHeight&&(o.scrollTop=o.scrollHeight)},[Ee,Se,H,we]),Re=(0,t.useCallback)(()=>{X.current=null;const e=N.current;e&&(N.current=null,Fe(e))},[Fe]),Me=(0,t.useCallback)(e=>{if(!q.current)return void(I.current=e);const t=null!==N.current;N.current=e,t||(Y.current=Date.now()),null!==X.current?Date.now()-Y.current>=400&&(cancelAnimationFrame(X.current),X.current=null,Re()):X.current=requestAnimationFrame(Re)},[Re]);(0,t.useEffect)(()=>{if("undefined"==typeof document)return;const e=()=>{"visible"===document.visibilityState&&(null!==X.current&&(cancelAnimationFrame(X.current),X.current=null),N.current&&Re(),q.current&&_.current?.refresh())};return document.addEventListener("visibilitychange",e),()=>document.removeEventListener("visibilitychange",e)},[Re]),(0,t.useEffect)(()=>()=>{null!==X.current&&(cancelAnimationFrame(X.current),X.current=null),N.current=null},[]);const je=(0,t.useRef)(void 0);(0,t.useEffect)(()=>{const e=_.current;if(!e)return;const t=je.current;je.current=C,C?(e.start(),I.current&&(Fe(I.current),I.current=null),!1===t&&ke()):e.stop()},[C,Fe,ke]),(0,t.useEffect)(()=>{if(!z.current){const e=new o.AnsiUp;e.use_classes=!1,z.current=e}const t=(0,l.createTerminalChannel)({conn:e,nid:x,onFrame:Me,onCursor:e=>{ue.current=e,q.current&&we()},onTerminated:()=>te(!0)});return _.current=t,t.start(),()=>{t.close(),_.current=null}},[e,x,Me,we]),(0,t.useEffect)(()=>{const e=e=>{if(!O.current||!U.current)return;if(Z.current)return;if(F(e))return;let t=w(e);t&&le.current&&("Home"===t?t="C-Home":"End"===t&&(t="C-End")),t&&_.current&&(e.preventDefault(),_.current.sendKeys(t),me(t))};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[]),(0,t.useEffect)(()=>{const e=e=>{if(!O.current||!U.current)return;const t=e.clipboardData?.getData("text");t&&(e.preventDefault(),_.current?.sendPaste(t),Z.current&&Q(!1))};return document.addEventListener("paste",e),()=>document.removeEventListener("paste",e)},[]);const Ke=(0,t.useCallback)(async()=>{try{const e=await(navigator.clipboard?.readText());if(e)return void _.current?.sendPaste(e);if(""===e)return}catch{}Q(!0)},[]);(0,t.useEffect)(()=>{const e=P.current;if(!e)return;const t=document.createElement("span");t.style.fontFamily="'Menlo', 'Monaco', 'Courier New', monospace",t.style.fontSize="12px",t.style.lineHeight="1.4",t.style.position="absolute",t.style.visibility="hidden",t.style.whiteSpace="pre",t.textContent="X",document.body.appendChild(t);const n=t.getBoundingClientRect().width;if(document.body.removeChild(t),0===n)return;const o=v;let c=0,s=0;const l=new ResizeObserver(e=>{for(const t of e){const{width:e,height:l}=t.contentRect,i=Math.floor((e-16)/n),u=Math.floor((l-16)/o);i>0&&u>0&&(i!==c||u!==s)&&(c=i,s=u,_.current?.resize(i,u))}});return l.observe(e),()=>l.disconnect()},[]),(0,t.useEffect)(()=>{const e=document.createElement("span");e.style.fontFamily="'Menlo', 'Monaco', 'Courier New', monospace",e.style.fontSize="12px",e.style.lineHeight="1.4",e.style.position="absolute",e.style.visibility="hidden",e.style.whiteSpace="pre",e.textContent="X",document.body.appendChild(e),ie.current={width:e.getBoundingClientRect().width,height:v},document.body.removeChild(e)},[]),(0,t.useEffect)(()=>{const e=P.current;if(!e||ce)return;const t=t=>{if(t.altKey||t.shiftKey||t.metaKey||t.ctrlKey)return;const n=ue.current,o=ie.current,c=_.current;if(!n||!o||!c)return;const s="undefined"!=typeof window?window.getSelection():null;if(s&&!s.isCollapsed)return;const l=e.querySelector("pre");if(!l)return;let i=t.target;for(;i&&i.parentElement!==l;)i=i.parentElement;if(!i)return;if(Array.prototype.indexOf.call(l.children,i)!==n.line)return;const u=Math.max(0,Math.round((t.clientX-i.getBoundingClientRect().left)/o.width))-n.col;0!==u&&c.sendKeys(u>0?"Right":"Left",Math.abs(u))};return e.addEventListener("click",t),()=>e.removeEventListener("click",t)},[ce]),(0,t.useEffect)(()=>{const e=P.current;if(!e||!ce)return;const t=(t,n)=>{if(!ie.current)return null;const o=e.querySelector("pre");if(!o)return null;const c=o.getBoundingClientRect(),s=t-c.left-8,l=n-c.top-8;return{col:Math.max(0,Math.floor(s/ie.current.width)),row:Math.max(0,Math.floor(l/ie.current.height))}};let n=!1,o=0,c=null;const s=e=>e.altKey||e.shiftKey,l=l=>{if(s(l))return;const i=t(l.clientX,l.clientY);if(i&&_.current){try{e.focus({preventScroll:!0})}catch{e.focus()}var u;l.preventDefault(),u=l.button,o=1===u?1:2===u?2:0,n=!0,c=i,_.current.sendMouse(i.col,i.row,o,"down")}},i=e=>{if(!n)return;const s=t(e.clientX,e.clientY);s&&_.current&&(c&&s.col===c.col&&s.row===c.row||(c=s,_.current.sendMouse(s.col,s.row,o,"drag")))},u=e=>{if(!n)return;const s=t(e.clientX,e.clientY)??c;n=!1,s&&_.current?(_.current.sendMouse(s.col,s.row,o,"up"),c=null):c=null},f=e=>{const n=t(e.clientX,e.clientY);if(!n||!_.current)return;e.preventDefault();const o=e.deltaY>0?"scroll_down":"scroll_up";_.current.sendMouse(n.col,n.row,0,o),"scroll_up"===o&&he(!1)},p=e=>{s(e)||e.preventDefault()};return e.addEventListener("mousedown",l),e.addEventListener("wheel",f,{passive:!1}),e.addEventListener("contextmenu",p),window.addEventListener("mousemove",i),window.addEventListener("mouseup",u),()=>{e.removeEventListener("mousedown",l),e.removeEventListener("wheel",f),e.removeEventListener("contextmenu",p),window.removeEventListener("mousemove",i),window.removeEventListener("mouseup",u)}},[ce]),(0,t.useEffect)(()=>{const e=P.current;if(!e||!ce)return;let t=0,n=0,o=0,c=0,s=0;const l=l=>{if(1!==l.touches.length)return;const i=l.touches[0];if(t=i.clientX,n=i.clientY,o=i.clientY,ie.current){const t=(e.querySelector("pre")??e).getBoundingClientRect(),n=i.clientX-t.left-8,o=i.clientY-t.top-8;c=Math.max(0,Math.floor(n/ie.current.width)),s=Math.max(0,Math.floor(o/ie.current.height))}},i=e=>{if(1!==e.touches.length)return;if(!_.current)return;const l=e.touches[0],i=l.clientY-n,u=l.clientX-t;Math.abs(i)>Math.abs(u)&&e.preventDefault();const f=l.clientY-o;if(Math.abs(f)<20)return;const p=Math.trunc(f/20);o+=20*p;const y=p>0?"scroll_up":"scroll_down";for(let e=0;e<Math.abs(p);e++)_.current.sendMouse(c,s,0,y);"scroll_up"===y&&he(!1)};return e.addEventListener("touchstart",l,{passive:!0}),e.addEventListener("touchmove",i,{passive:!1}),()=>{e.removeEventListener("touchstart",l),e.removeEventListener("touchmove",i)}},[ce]),(0,t.useEffect)(()=>{const e=P.current;e&&B.current&&requestAnimationFrame(()=>{e.scrollTop=e.scrollHeight})},[G]);const Le=S??C;(0,t.useEffect)(()=>{if(!Le)return;const e=P.current;if(e)try{e.focus({preventScroll:!0})}catch{e.focus()}},[Le]),(0,t.useEffect)(()=>{const e=P.current;if(!e)return;let t=B.current;const n=()=>{const n=e.scrollHeight-e.scrollTop-e.clientHeight<40;n!==t&&(t=n,B.current=n,H?.(n))};return e.addEventListener("scroll",n,{passive:!0}),()=>e.removeEventListener("scroll",n)},[H]);const He=(0,t.useCallback)(async()=>{if((0,p.revivesAsTwin)(L)&&A)A();else{re(!0);try{const t=await(0,s.reviveNarrative)(e,x);if(t.nid&&t.nid!==x)return void T?.(t.nid);te(!1),_.current?.close();const n=(0,l.createTerminalChannel)({conn:e,nid:x,onFrame:Me,onTerminated:()=>te(!0)});_.current=n,n.start()}catch(e){console.error("Revive failed:",e)}finally{re(!1)}}},[e,x,Me,L,A,T]);oe.current=He;const Ae=(0,t.useCallback)(e=>{if(!_.current)return;if(e.keys)return void _.current.sendKeys(e.keys);if(!e.text)return;const t=e.text.split("\n");for(let e=0;e<t.length;e++)t[e]&&_.current.sendKeys(t[e]),e<t.length-1&&_.current.sendKeys("Enter")},[]),Te=(0,t.useCallback)(e=>{_.current?.sendKeys(e),me(e)},[me]),De=(0,t.useCallback)(e=>{if(_.current)return"transcript"===e.action?(_.current.sendKeys("C-o"),void ke()):void("paste"!==e.action?e.keys&&(_.current.sendKeys(e.keys),me(e.keys)):Ke())},[ke,me,Ke]);return(0,y.jsxs)("div",{style:{display:"flex",flexDirection:"column",flex:1,minHeight:0,overflow:"hidden"},children:[(0,y.jsx)("style",{children:"@keyframes brane-cursor-blink {\n 0%, 45% { opacity: 1; }\n 55%, 100% { opacity: 0; }\n}"}),(0,y.jsx)("style",{children:b}),(0,y.jsxs)("div",{style:{position:"relative",flex:1,minHeight:0,display:"flex",flexDirection:"column"},children:[ee&&(0,y.jsx)("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:10,display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"rgba(0, 0, 0, 0.85)"},children:(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)("div",{style:{position:"absolute",left:0,right:0,top:"50%",transform:"translateY(calc(-100% - 36px))",textAlign:"center",color:"#888",fontSize:15,fontFamily:"system-ui, -apple-system, sans-serif",pointerEvents:"none"},children:"Session ended"}),(0,y.jsx)("button",{onClick:()=>He(),disabled:ne,style:{padding:"10px 24px",borderRadius:8,border:"1px solid #4caf50",backgroundColor:ne?"#1c1c1e":"#2e7d32",color:"#fff",fontSize:15,fontWeight:"600",cursor:ne?"default":"pointer",opacity:ne?.6:1,fontFamily:"system-ui, -apple-system, sans-serif"},children:ne?"utility"===L?"Restarting\u2026":"Reviving\u2026":(0,p.revivesAsTwin)(L)?"/twin":"utility"===L?"Restart":"Revive"})]})}),(0,y.jsx)("div",{ref:P,tabIndex:0,style:Object.assign({flex:1,minHeight:0,overflow:ce?"hidden":"auto",backgroundColor:"#111",outline:"none",WebkitOverflowScrolling:"touch",touchAction:ce?"none":"auto"},ce?{display:"flex",flexDirection:"column",justifyContent:"flex-end",alignItems:"flex-start"}:{}),children:(0,y.jsx)("pre",{style:{margin:ce?"auto":0,padding:8,fontFamily:"'Menlo', 'Monaco', 'Courier New', monospace",fontSize:12,lineHeight:h,color:"#e0e0e0",whiteSpace:"pre",wordWrap:"normal",overflowX:"auto",cursor:ce?"pointer":"default"}})})]}),J&&(0,y.jsxs)("div",{style:{padding:"8px 10px",backgroundColor:"#1a1a1a",borderTop:"1px solid #444",flexShrink:0},children:[(0,y.jsx)("div",{style:{color:"#aaa",fontSize:12,marginBottom:6,fontFamily:"monospace"},children:"Paste here (long-press \u2192 Paste), or type and Send"}),(0,y.jsxs)("div",{style:{display:"flex",gap:8,alignItems:"flex-start"},children:[(0,y.jsx)("textarea",{autoFocus:!0,ref:V,rows:2,style:{flex:1,backgroundColor:"#111",color:"#e0e0e0",border:"1px solid #555",borderRadius:6,padding:6,fontFamily:"'Menlo', 'Monaco', 'Courier New', monospace",fontSize:13,resize:"vertical"}}),(0,y.jsx)("button",{onClick:()=>{const e=V.current?.value??"";e&&_.current?.sendPaste(e),Q(!1)},style:{padding:"6px 10px",borderRadius:6,border:"1px solid #555",backgroundColor:"#252525",color:"#ccc",fontSize:13,fontFamily:"monospace",cursor:"pointer"},children:"Send"}),(0,y.jsx)("button",{onClick:()=>Q(!1),style:{padding:"6px 10px",borderRadius:6,border:"1px solid #555",backgroundColor:"#1e1e1e",color:"#888",fontSize:13,fontFamily:"monospace",cursor:"pointer"},children:"Cancel"})]})]}),G&&(0,y.jsx)(i.default,{sendKeys:Te}),(0,y.jsxs)("div",{style:{display:"flex",flexDirection:"row",justifyContent:"center",gap:8,padding:"6px 8px",paddingBottom:"max(6px, env(safe-area-inset-bottom))",minHeight:53,boxSizing:"border-box",backgroundColor:"#1a1a1a",borderTop:"1px solid rgb(216, 216, 216)",flexShrink:0,alignItems:"center"},children:[(0,y.jsx)("button",{onClick:()=>$(e=>!e),style:{padding:"6px 8px",borderRadius:6,border:"1px solid "+(G?"#4caf50":"#555"),backgroundColor:G?"#2e7d32":"#252525",color:G?"#fff":"#ccc",fontSize:15,lineHeight:"18px",fontFamily:"monospace",cursor:"pointer",whiteSpace:"nowrap"},children:"\ud83c\udfb9"}),(0,y.jsx)("div",{style:{width:1,height:24,backgroundColor:"#333",flexShrink:0}}),(0,y.jsx)(u.default,{onSelect:Ae}),(0,y.jsx)(f.default,{onControl:De}),(0,y.jsx)("div",{style:{width:1,height:24,backgroundColor:"#333",flexShrink:0}}),k.map(e=>(0,y.jsx)(K,{onPress:()=>_.current?.sendKeys(e.keys),style:{padding:"6px 8px",borderRadius:6,border:"1px solid #555",backgroundColor:"#1e1e1e",color:"#aaa",fontSize:14,fontFamily:"monospace",cursor:"pointer",whiteSpace:"nowrap",minWidth:28,textAlign:"center"},children:e.label},e.label)),(0,y.jsx)(K,{onPress:()=>_.current?.sendKeys("Enter"),style:{padding:"6px 8px",borderRadius:6,border:"1px solid #555",backgroundColor:"#1e1e1e",color:"#aaa",fontSize:14,fontFamily:"monospace",cursor:"pointer",whiteSpace:"nowrap",minWidth:34,textAlign:"center"},children:"Ret"})]})]})});var H=(0,t.memo)(L)},761,[11,116,165,762,763,745,764,765,766,768,769,6]);
865
- __d(function(_g,_r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"AnsiUp",{enumerable:!0,get:function(){return r}});var t,n,i,s,l=this&&this.__makeTemplateObject||function(t,n){return Object.defineProperty?Object.defineProperty(t,"raw",{value:n}):t.raw=n,t};!(function(t){t[t.EOS=0]="EOS",t[t.Text=1]="Text",t[t.Incomplete=2]="Incomplete",t[t.ESC=3]="ESC",t[t.Unknown=4]="Unknown",t[t.SGR=5]="SGR",t[t.OSCURL=6]="OSCURL"})(t||(t={}));class r{constructor(){this.VERSION="6.0.6",this.setup_palettes(),this._use_classes=!1,this.bold=!1,this.faint=!1,this.italic=!1,this.underline=!1,this.fg=this.bg=null,this._buffer='',this._url_allowlist={http:1,https:1},this._escape_html=!0,this.boldStyle='font-weight:bold',this.faintStyle='opacity:0.7',this.italicStyle='font-style:italic',this.underlineStyle='text-decoration:underline'}set use_classes(t){this._use_classes=t}get use_classes(){return this._use_classes}set url_allowlist(t){this._url_allowlist=t}get url_allowlist(){return this._url_allowlist}set escape_html(t){this._escape_html=t}get escape_html(){return this._escape_html}set boldStyle(t){this._boldStyle=t}get boldStyle(){return this._boldStyle}set faintStyle(t){this._faintStyle=t}get faintStyle(){return this._faintStyle}set italicStyle(t){this._italicStyle=t}get italicStyle(){return this._italicStyle}set underlineStyle(t){this._underlineStyle=t}get underlineStyle(){return this._underlineStyle}setup_palettes(){this.ansi_colors=[[{rgb:[0,0,0],class_name:"ansi-black"},{rgb:[187,0,0],class_name:"ansi-red"},{rgb:[0,187,0],class_name:"ansi-green"},{rgb:[187,187,0],class_name:"ansi-yellow"},{rgb:[0,0,187],class_name:"ansi-blue"},{rgb:[187,0,187],class_name:"ansi-magenta"},{rgb:[0,187,187],class_name:"ansi-cyan"},{rgb:[255,255,255],class_name:"ansi-white"}],[{rgb:[85,85,85],class_name:"ansi-bright-black"},{rgb:[255,85,85],class_name:"ansi-bright-red"},{rgb:[0,255,0],class_name:"ansi-bright-green"},{rgb:[255,255,85],class_name:"ansi-bright-yellow"},{rgb:[85,85,255],class_name:"ansi-bright-blue"},{rgb:[255,85,255],class_name:"ansi-bright-magenta"},{rgb:[85,255,255],class_name:"ansi-bright-cyan"},{rgb:[255,255,255],class_name:"ansi-bright-white"}]],this.palette_256=[],this.ansi_colors.forEach(t=>{t.forEach(t=>{this.palette_256.push(t)})});let t=[0,95,135,175,215,255];for(let n=0;n<6;++n)for(let i=0;i<6;++i)for(let s=0;s<6;++s){let l={rgb:[t[n],t[i],t[s]],class_name:'truecolor'};this.palette_256.push(l)}let n=8;for(let t=0;t<24;++t,n+=10){let t={rgb:[n,n,n],class_name:'truecolor'};this.palette_256.push(t)}}escape_txt_for_html(t){return this._escape_html?t.replace(/[&<>"']/gm,t=>"&"===t?"&amp;":"<"===t?"&lt;":">"===t?"&gt;":"\""===t?"&quot;":"'"===t?"&#x27;":void 0):t}append_buffer(t){var n=this._buffer+t;this._buffer=n}get_next_packet(){var r={kind:t.EOS,text:'',url:''},_=this._buffer.length;if(0==_)return r;var c=this._buffer.indexOf("\x1b");if(-1==c)return r.kind=t.Text,r.text=this._buffer,this._buffer='',r;if(c>0)return r.kind=t.Text,r.text=this._buffer.slice(0,c),this._buffer=this._buffer.slice(c),r;if(0==c){if(_<3)return r.kind=t.Incomplete,r;var u=this._buffer.charAt(1);if('['!=u&&']'!=u&&'('!=u)return r.kind=t.ESC,r.text=this._buffer.slice(0,1),this._buffer=this._buffer.slice(1),r;if('['==u){this._csi_regex||(this._csi_regex=h(n||(n=l(["\n ^ # beginning of line\n #\n # First attempt\n (?: # legal sequence\n \x1b[ # CSI\n ([<-?]?) # private-mode char\n ([d;]*) # any digits or semicolons\n ([ -/]? # an intermediate modifier\n [@-~]) # the command\n )\n | # alternate (second attempt)\n (?: # illegal sequence\n \x1b[ # CSI\n [ -~]* # anything legal\n ([\0-\x1f:]) # anything illegal\n )\n "],["\n ^ # beginning of line\n #\n # First attempt\n (?: # legal sequence\n \\x1b\\[ # CSI\n ([\\x3c-\\x3f]?) # private-mode char\n ([\\d;]*) # any digits or semicolons\n ([\\x20-\\x2f]? # an intermediate modifier\n [\\x40-\\x7e]) # the command\n )\n | # alternate (second attempt)\n (?: # illegal sequence\n \\x1b\\[ # CSI\n [\\x20-\\x7e]* # anything legal\n ([\\x00-\\x1f:]) # anything illegal\n )\n "]))));let i=this._buffer.match(this._csi_regex);if(null===i)return r.kind=t.Incomplete,r;if(i[4])return r.kind=t.ESC,r.text=this._buffer.slice(0,1),this._buffer=this._buffer.slice(1),r;''!=i[1]||'m'!=i[3]?r.kind=t.Unknown:r.kind=t.SGR,r.text=i[2];var o=i[0].length;return this._buffer=this._buffer.slice(o),r}if(']'==u){if(_<4)return r.kind=t.Incomplete,r;if('8'!=this._buffer.charAt(2)||';'!=this._buffer.charAt(3))return r.kind=t.ESC,r.text=this._buffer.slice(0,1),this._buffer=this._buffer.slice(1),r;this._osc_st||(this._osc_st=f(i||(i=l(["\n (?: # legal sequence\n (\x1b\\) # ESC | # alternate\n (\x07) # BEL (what xterm did)\n )\n | # alternate (second attempt)\n ( # illegal sequence\n [\0-\x06] # anything illegal\n | # alternate\n [\b-\x1a] # anything illegal\n | # alternate\n [\x1c-\x1f] # anything illegal\n )\n "],["\n (?: # legal sequence\n (\\x1b\\\\) # ESC \\\n | # alternate\n (\\x07) # BEL (what xterm did)\n )\n | # alternate (second attempt)\n ( # illegal sequence\n [\\x00-\\x06] # anything illegal\n | # alternate\n [\\x08-\\x1a] # anything illegal\n | # alternate\n [\\x1c-\\x1f] # anything illegal\n )\n "])))),this._osc_st.lastIndex=0;{let n=this._osc_st.exec(this._buffer);if(null===n)return r.kind=t.Incomplete,r;if(n[3])return r.kind=t.ESC,r.text=this._buffer.slice(0,1),this._buffer=this._buffer.slice(1),r}{let n=this._osc_st.exec(this._buffer);if(null===n)return r.kind=t.Incomplete,r;if(n[3])return r.kind=t.ESC,r.text=this._buffer.slice(0,1),this._buffer=this._buffer.slice(1),r}this._osc_regex||(this._osc_regex=h(s||(s=l(["\n ^ # beginning of line\n #\n \x1b]8; # OSC Hyperlink\n [ -:<-~]* # params (excluding ;)\n ; # end of params\n ([!-~]{0,512}) # URL capture\n (?: # ST\n (?:\x1b\\) # ESC | # alternate\n (?:\x07) # BEL (what xterm did)\n )\n ([ -~]+) # TEXT capture\n \x1b]8;; # OSC Hyperlink End\n (?: # ST\n (?:\x1b\\) # ESC | # alternate\n (?:\x07) # BEL (what xterm did)\n )\n "],["\n ^ # beginning of line\n #\n \\x1b\\]8; # OSC Hyperlink\n [\\x20-\\x3a\\x3c-\\x7e]* # params (excluding ;)\n ; # end of params\n ([\\x21-\\x7e]{0,512}) # URL capture\n (?: # ST\n (?:\\x1b\\\\) # ESC \\\n | # alternate\n (?:\\x07) # BEL (what xterm did)\n )\n ([\\x20-\\x7e]+) # TEXT capture\n \\x1b\\]8;; # OSC Hyperlink End\n (?: # ST\n (?:\\x1b\\\\) # ESC \\\n | # alternate\n (?:\\x07) # BEL (what xterm did)\n )\n "]))));let n=this._buffer.match(this._osc_regex);if(null===n)return r.kind=t.ESC,r.text=this._buffer.slice(0,1),this._buffer=this._buffer.slice(1),r;r.kind=t.OSCURL,r.url=n[1],r.text=n[2];o=n[0].length;return this._buffer=this._buffer.slice(o),r}if('('==u)return r.kind=t.Unknown,this._buffer=this._buffer.slice(3),r}}ansi_to_html(n){this.append_buffer(n);for(var i=[];;){var s=this.get_next_packet();if(s.kind==t.EOS||s.kind==t.Incomplete)break;s.kind!=t.ESC&&s.kind!=t.Unknown&&(s.kind==t.Text?i.push(this.transform_to_html(this.with_state(s))):s.kind==t.SGR?this.process_ansi(s):s.kind==t.OSCURL&&i.push(this.process_hyperlink(s)))}return i.join("")}with_state(t){return{bold:this.bold,faint:this.faint,italic:this.italic,underline:this.underline,fg:this.fg,bg:this.bg,text:t.text}}process_ansi(t){let n=t.text.split(';');for(;n.length>0;){let t=n.shift(),i=parseInt(t,10);if(isNaN(i)||0===i)this.fg=null,this.bg=null,this.bold=!1,this.faint=!1,this.italic=!1,this.underline=!1;else if(1===i)this.bold=!0;else if(2===i)this.faint=!0;else if(3===i)this.italic=!0;else if(4===i)this.underline=!0;else if(21===i)this.bold=!1;else if(22===i)this.faint=!1,this.bold=!1;else if(23===i)this.italic=!1;else if(24===i)this.underline=!1;else if(39===i)this.fg=null;else if(49===i)this.bg=null;else if(i>=30&&i<38)this.fg=this.ansi_colors[0][i-30];else if(i>=40&&i<48)this.bg=this.ansi_colors[0][i-40];else if(i>=90&&i<98)this.fg=this.ansi_colors[1][i-90];else if(i>=100&&i<108)this.bg=this.ansi_colors[1][i-100];else if((38===i||48===i)&&n.length>0){let t=38===i,s=n.shift();if('5'===s&&n.length>0){let i=parseInt(n.shift(),10);i>=0&&i<=255&&(t?this.fg=this.palette_256[i]:this.bg=this.palette_256[i])}if('2'===s&&n.length>2){let i=parseInt(n.shift(),10),s=parseInt(n.shift(),10),l=parseInt(n.shift(),10);if(i>=0&&i<=255&&s>=0&&s<=255&&l>=0&&l<=255){let n={rgb:[i,s,l],class_name:'truecolor'};t?this.fg=n:this.bg=n}}}}}transform_to_html(t){let n=t.text;if(0===n.length)return n;if(n=this.escape_txt_for_html(n),!(t.bold||t.italic||t.faint||t.underline||null!==t.fg||null!==t.bg))return n;let i=[],s=[],l=t.fg,r=t.bg;t.bold&&i.push(this._boldStyle),t.faint&&i.push(this._faintStyle),t.italic&&i.push(this._italicStyle),t.underline&&i.push(this._underlineStyle),this._use_classes?(l&&('truecolor'!==l.class_name?s.push(`${l.class_name}-fg`):i.push(`color:rgb(${l.rgb.join(',')})`)),r&&('truecolor'!==r.class_name?s.push(`${r.class_name}-bg`):i.push(`background-color:rgb(${r.rgb.join(',')})`))):(l&&i.push(`color:rgb(${l.rgb.join(',')})`),r&&i.push(`background-color:rgb(${r.rgb})`));let h='',f='';return s.length&&(h=` class="${s.join(' ')}"`),i.length&&(f=` style="${i.join(';')}"`),`<span${f}${h}>${n}</span>`}process_hyperlink(t){let n=t.url.split(':');return n.length<1?'':this._url_allowlist[n[0]]?`<a href="${this.escape_txt_for_html(t.url)}">${this.escape_txt_for_html(t.text)}</a>`:''}}function h(t,...n){let i=t.raw[0].replace(/^\s+|\s+\n|\s*#[\s\S]*?\n|\n/gm,'');return new RegExp(i)}function f(t,...n){let i=t.raw[0].replace(/^\s+|\s+\n|\s*#[\s\S]*?\n|\n/gm,'');return new RegExp(i,'g')}},762,[]);
866
- __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"BLOCK_GLYPH_RE",{enumerable:!0,get:function(){return s}}),e.blockGlyphClass=$,e.paintBlockGlyphs=function(t){return p.test(t)?t.replace(s,t=>`<span class="tb ${$(t.charCodeAt(0))}">${t}</span>`):t},e.blockGlyphStylesheet=function(t){const n=[`.tb{display:inline-block;width:1ch;height:${t}em;overflow:hidden;vertical-align:top;-webkit-text-fill-color:transparent}`];for(const[t,o]of Object.entries(l))n.push(`.${$(+t)}{background:${o}}`);return n.join("\n")};const t="currentColor",n="transparent";function o(o,c){const l=+(100*c).toFixed(4)+"%";return`linear-gradient(to ${o},${t} ${l},${n} ${l})`}function c(o,c,l,s){const p=o=>o?t:n;return`conic-gradient(at 50% 50%,${p(o)} 0 25%,${p(c)} 0 50%,${p(l)} 0 75%,${p(s)} 0)`}const l={9600:o("bottom",.5),9601:o("top",.125),9602:o("top",.25),9603:o("top",.375),9604:o("top",.5),9605:o("top",.625),9606:o("top",.75),9607:o("top",.875),9608:t,9609:o("right",.875),9610:o("right",.75),9611:o("right",.625),9612:o("right",.5),9613:o("right",.375),9614:o("right",.25),9615:o("right",.125),9616:o("left",.5),9617:`color-mix(in srgb,${t} 25%,${n})`,9618:`color-mix(in srgb,${t} 50%,${n})`,9619:`color-mix(in srgb,${t} 75%,${n})`,9620:o("bottom",.125),9621:o("left",.125),9622:c(!1,!1,!0,!1),9623:c(!1,!0,!1,!1),9624:c(!1,!1,!1,!0),9625:c(!1,!0,!0,!0),9626:c(!1,!0,!1,!0),9627:c(!0,!1,!0,!0),9628:c(!0,!0,!1,!0),9629:c(!0,!1,!1,!1),9630:c(!0,!1,!0,!1),9631:c(!0,!0,!0,!1)},s=/[\u2580-\u259f]/g,p=/[\u2580-\u259f]/;function $(t){return`tb-${t.toString(16)}`}},763,[]);
867
- __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.createTerminalChannel=n,e.sendInterrupt=s,e.interruptSession=function(t,u){let y=!1;const f=n({conn:t,nid:u,onFrame:()=>{},onConnect:()=>{y||(y=!0,clearTimeout(l),s(f.sendKeys),setTimeout(()=>f.close(),o[o.length-1]+200))}}),l=setTimeout(()=>{y||f.close()},c)};var t=r(d[0]);function n(n){const{conn:o,nid:s,onFrame:c,onCursor:u,onTerminated:y,onConnect:f,onDisconnect:l}=n,p=`${"undefined"!=typeof window&&"https:"===window.location.protocol?"wss":"ws"}://${o.host}/ws/terminal/${s}?token=${o.token}`;let S=null,O=null,N=!1,k=!1,b=null;return(function n(){N||(S=new WebSocket(p),S.onopen=()=>{f?.(),k&&S.send(JSON.stringify({type:"start"})),b&&S.send(JSON.stringify(Object.assign({type:"resize"},b)))},S.onmessage=t=>{try{const n=JSON.parse(t.data);"terminated"===n.type?y?.():"cursor"===n.type?u?.(n.cursor??null):"frame"!==n.type&&"append"!==n.type||c(n)}catch{}},S.onclose=o=>{l?.(),N||((0,t.isSignedOutClose)(o.code)?N=!0:O=setTimeout(n,2e3))},S.onerror=()=>{S?.close()})})(),{start:function(){k=!0,S?.readyState===WebSocket.OPEN&&S.send(JSON.stringify({type:"start"}))},stop:function(){k=!1,S?.readyState===WebSocket.OPEN&&S.send(JSON.stringify({type:"stop"}))},resize:function(t,n){b={cols:t,rows:n},S?.readyState===WebSocket.OPEN&&S.send(JSON.stringify({type:"resize",cols:t,rows:n}))},sendKeys:function(t,n){S?.readyState===WebSocket.OPEN&&S.send(JSON.stringify(Object.assign({type:"keys",keys:t},n&&n>1?{repeat:n}:{})))},sendPaste:function(t){t&&S?.readyState===WebSocket.OPEN&&S.send(JSON.stringify({type:"paste",text:t}))},sendMouse:function(t,n,o=0,s="click"){S?.readyState===WebSocket.OPEN&&S.send(JSON.stringify({type:"mouse",x:t,y:n,button:o,action:s}))},close:function(){N=!0,k=!1,O&&clearTimeout(O),S?.close()},refresh:function(){S?.readyState===WebSocket.OPEN&&S.send(JSON.stringify({type:"refresh"}))}}}const o=[0,150,300];function s(t){for(const n of o)0===n?t("C-c"):setTimeout(()=>t("C-c"),n)}const c=1e4},764,[752]);
852
+ __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.lastTerminalSize=function(){return n},e.createTerminalChannel=o,e.sendInterrupt=c,e.interruptSession=function(t,n){let u=!1;const l=o({conn:t,nid:n,onFrame:()=>{},onConnect:()=>{u||(u=!0,clearTimeout(f),c(l.sendKeys),setTimeout(()=>l.close(),s[s.length-1]+200))}}),f=setTimeout(()=>{u||l.close()},y)};var t=r(d[0]);let n=null;function o(o){const{conn:s,nid:c,onFrame:y,onCursor:u,onTerminated:l,onConnect:f,onDisconnect:S}=o,p=`${"undefined"!=typeof window&&"https:"===window.location.protocol?"wss":"ws"}://${s.host}/ws/terminal/${c}?token=${s.token}`;let O=null,N=null,k=!1,b=!1,w=null;return(function n(){k||(O=new WebSocket(p),O.onopen=()=>{f?.(),b&&O.send(JSON.stringify({type:"start"})),w&&O.send(JSON.stringify(Object.assign({type:"resize"},w)))},O.onmessage=t=>{try{const n=JSON.parse(t.data);"terminated"===n.type?l?.():"cursor"===n.type?u?.(n.cursor??null):"frame"!==n.type&&"append"!==n.type||y(n)}catch{}},O.onclose=o=>{S?.(),k||((0,t.isSignedOutClose)(o.code)?k=!0:N=setTimeout(n,2e3))},O.onerror=()=>{O?.close()})})(),{start:function(){b=!0,O?.readyState===WebSocket.OPEN&&O.send(JSON.stringify({type:"start"}))},stop:function(){b=!1,O?.readyState===WebSocket.OPEN&&O.send(JSON.stringify({type:"stop"}))},resize:function(t,o){w={cols:t,rows:o},n={cols:t,rows:o},O?.readyState===WebSocket.OPEN&&O.send(JSON.stringify({type:"resize",cols:t,rows:o}))},sendKeys:function(t,n){O?.readyState===WebSocket.OPEN&&O.send(JSON.stringify(Object.assign({type:"keys",keys:t},n&&n>1?{repeat:n}:{})))},sendPaste:function(t){t&&O?.readyState===WebSocket.OPEN&&O.send(JSON.stringify({type:"paste",text:t}))},sendMouse:function(t,n,o=0,s="click"){O?.readyState===WebSocket.OPEN&&O.send(JSON.stringify({type:"mouse",x:t,y:n,button:o,action:s}))},close:function(){k=!0,b=!1,N&&clearTimeout(N),O?.close()},refresh:function(){O?.readyState===WebSocket.OPEN&&O.send(JSON.stringify({type:"refresh"}))},clearHistory:function(){O?.readyState===WebSocket.OPEN&&O.send(JSON.stringify({type:"clear_history"}))}}}const s=[0,150,300];function c(t){for(const n of s)0===n?t("C-c"):setTimeout(()=>t("C-c"),n)}const y=1e4},749,[750]);
853
+ __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"WS_CLOSE_TOKEN_ROTATED",{enumerable:!0,get:function(){return t}}),e.isSignedOutClose=function(n){return n===t};const t=4401},750,[]);
854
+ __d(function(g,r,i,a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CONVERSATIONAL_EVENT_TYPES_LIST",{enumerable:!0,get:function(){return t}}),e.isSystemEvent=function(t){return!n.has(t)},e.formatInvocation=u,e.spawnedContent=l,e.revivedContent=function(t,n,o=[],l=!1){const c=`Revived ${u([t,...o])} /${n}`;return l?`${c} (forked \u2014 original still live)`:c},e.runningContent=function(t){return`Running ${u(t)}`},e.restartedContent=function(t){return`Restarted ${u(t)}`},e.agentTypeOf=function(t){return t.replace(/-[a-z0-9]{8}$/,"")},e.formatSystemContent=c,Object.defineProperty(e,"FOLD_LINK_SCHEME",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"FOLD_COLOR",{enumerable:!0,get:function(){return $}}),e.systemLine=function(t,n={}){let o=c(t.content,n.agent);const u=n.fold??null;if(!u)return o;const l=` in ${u}`;o.endsWith(l)&&(o=o.slice(0,-l.length));return"started"===t.type?`${o} in [${u}](${f}${u})`:o},e.relPart=s,e.formatActivitySpan=function(t,n,o=Date.now()){const u=s(t,o),l=t=>t.ago?`${t.val} ago`:t.val;if(!("number"==typeof n&&n-t>6e4))return l(u);const c=s(n,o);return u.val===c.val?l(u):u.ago&&c.ago?`${u.val} to ${c.val} ago`:`${l(u)} to ${l(c)}`},e.formatCost=m,e.formatCostTotals=function(t){if(!t?.length)return null;const n=t.map(t=>m(t.amount,t.unit)).filter(t=>!!t);return n.length?n.join(" \xb7 "):null};const t=["narration","human_signal","agent_signal"],n=new Set(t);function o(t){return""===t||/[\s'"$`\\]/.test(t)?`'${t.replace(/'/g,"'\\''")}'`:t}function u(t){const n=t.map(o).join(" "),u=Math.max(0,...Array.from(n.matchAll(/`+/g),t=>t[0].length)),l="`".repeat(u+1);return u?`${l} ${n} ${l}`:`${l}${n}${l}`}function l(t,n,o={}){const l=`Spawned ${u([t,...o.args??[]])} /${n}`;return o.from?`${l} from ${o.from}`:l}function c(t,n){const o=t.trimEnd();if(o.includes("`"))return o;let u;return(u=/^Spawned (\S+) \(([A-Za-z0-9][\w.-]*)\)$/.exec(o))?l(u[1],u[2]):(u=/^Twinned from (\S+)$/.exec(o))?n?l(n,"twin",{from:u[1]}):`/twin from ${u[1]}`:(u=/^Revived (\S+) session( \(.*\))?$/.exec(o))?`Revived \`${u[1]}\`${u[2]??""}`:(u=/^(Running|Restarted) (.+)$/.exec(o))?`${u[1]} \`${u[2]}\``:o}const f="brane://fold/",$="#5e8a72";function s(t,n=Date.now()){const o=Math.floor((n-t)/1e3);if(o<60)return{val:`${Math.max(1,o)}s`,ago:!0};const u=Math.floor(o/60);if(u<60)return{val:`${u}m`,ago:!0};const l=Math.floor(u/60);if(l<24)return{val:`${l}h`,ago:!0};const c=Math.floor(l/24);if(c<7)return{val:`${c}d`,ago:!0};const f=new Date(t),$=`${["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][f.getMonth()]} ${f.getDate()}`;return{val:f.getFullYear()===new Date(n).getFullYear()?$:`${$}, ${f.getFullYear()}`,ago:!1}}function m(t,n){if(null==t||!n)return null;if("USD"===n)return`$${t.toFixed(2)}`;return`${Number.isInteger(t)?t.toLocaleString():t.toLocaleString(void 0,{maximumFractionDigits:2})} ${n}`}},751,[]);
855
+ __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"INLINE_PAYLOAD_MIME",{enumerable:!0,get:function(){return n}}),e.payloadExtname=t,e.isInlinePayload=function(o){return t(o)in n},e.attachmentDisposition=function(n){const t=n.replace(/[\\/]/g,"_").replace(o,"")||"download",p=t.replace(/"/g,'\\"');return/^[\x20-\x7e]*$/.test(t)?`attachment; filename="${p}"`:`attachment; filename="${c(t)}"; filename*=UTF-8''${l=t,encodeURIComponent(l).replace(/['()*]/g,n=>`%${n.charCodeAt(0).toString(16).toUpperCase()}`)}`;var l};const n={".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".bmp":"image/bmp",".avif":"image/avif",".svg":"image/svg+xml"};function t(n){const t=n.lastIndexOf(".");if(t<0)return"";const o=n.slice(t).toLowerCase();return o.includes("/")?"":o}const o=/[\u0000-\u001f\u007f]/g;function c(n){return n.replace(/[^\x20-\x7e]/g,"_").replace(/["\\]/g,"_").replace(/^_+$/,"")||"download"}},752,[]);
856
+ __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.createControlChannel=function(n){const{conn:s,onMessage:o,onConnect:c,onDisconnect:u,onSignedOut:f}=n,b=`${"undefined"!=typeof window&&"https:"===window.location.protocol?"wss":"ws"}://${s.host}/ws/control?token=${s.token}`;let y=null,l=null,S=!1;const O=new Map,p=new Map;let v=0;return(function n(){if(S)return;y=new WebSocket(b),y.onopen=()=>{for(const[t,n]of O)y.send(JSON.stringify({type:"subscribe",narrative:t,after:n}));v>0&&y.send(JSON.stringify({type:"subscribe_activity"})),c?.()},y.onmessage=t=>{try{const n=JSON.parse(t.data);o(n)}catch{}},y.onclose=s=>{if(u?.(),!S)return(0,t.isSignedOutClose)(s.code)?(S=!0,void f?.()):void(l=setTimeout(n,2e3))},y.onerror=()=>{y?.close()}})(),{subscribe:function(t,n=0){const s=p.get(t)??0;if(p.set(t,s+1),s>0)return;O.set(t,n),y?.readyState===WebSocket.OPEN&&y.send(JSON.stringify({type:"subscribe",narrative:t,after:n}))},unsubscribe:function(t){const n=p.get(t)??0;if(n>1)return void p.set(t,n-1);p.delete(t),O.delete(t),y?.readyState===WebSocket.OPEN&&y.send(JSON.stringify({type:"unsubscribe",narrative:t}))},subscribeActivity:function(){if(v+=1,v>1)return;y?.readyState===WebSocket.OPEN&&y.send(JSON.stringify({type:"subscribe_activity"}))},unsubscribeActivity:function(){if(v>1)return void(v-=1);v=0,y?.readyState===WebSocket.OPEN&&y.send(JSON.stringify({type:"unsubscribe_activity"}))},send:function(t,n,s="web"){y?.readyState===WebSocket.OPEN&&y.send(JSON.stringify({type:"signal",narrative:t,content:n,source:s}))},close:function(){S=!0,l&&clearTimeout(l);y?.close()}}};var t=r(d[0])},753,[750]);
857
+ __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.isAwaiting=function({mcpConnected:n,awaiting:t}){return!!n&&!!t},e.awaitingGlow=function(n){return[`inset 0 0 3px 1px oklch(0.78 0.16 ${n} / 0.95)`,`inset 0 0 18px 2px oklch(0.74 0.15 ${n} / 0.55)`,`inset 0 0 40px 4px oklch(0.7 0.14 ${n} / 0.28)`,`inset 0 4px 3px -3px oklch(0.78 0.16 ${n} / 0.95)`].join(", ")},Object.defineProperty(e,"AWAITING_STATUS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"NOT_AWAITING_STATUS",{enumerable:!0,get:function(){return t}});const n="awaiting",t="not_awaiting"},754,[]);
858
+ __d(function(g,r,i,a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DAEMONS_KEY",{enumerable:!0,get:function(){return t}}),e.loadDaemons=u,e.saveDaemons=l,e.addDaemon=function(t){const n=u(),o=n.findIndex(n=>n.brane_id===t.brane_id);o>=0?n[o]=Object.assign({},t,{addedAt:n[o].addedAt}):n.push(t);return l(n),n},e.updateDaemon=function(t,n){const o=u().map(o=>o.id===t?Object.assign({},o,n):o);return l(o),o},e.removeDaemon=function(t){const n=u().filter(n=>n.id!==t);l(n),f()===t&&I(n[0]?.id??null);s()===t&&d(n[0]?.id??null);return n},e.getActiveDaemonId=function(){c();try{return sessionStorage.getItem(n)??localStorage.getItem(o)}catch{return null}},e.setActiveDaemonId=d,e.getDefaultDaemonId=f,e.setDefaultDaemonId=I;const t="brane_daemons",n="brane_active_daemon",o="brane_default_daemon";function c(){try{const t=localStorage.getItem(n);t&&!localStorage.getItem(o)&&localStorage.setItem(o,t),t&&localStorage.removeItem(n)}catch{}}function u(){try{const n=localStorage.getItem(t);return n?JSON.parse(n):[]}catch{return[]}}function l(n){localStorage.setItem(t,JSON.stringify(n))}function s(){try{return sessionStorage.getItem(n)}catch{return null}}function d(t){try{t?sessionStorage.setItem(n,t):sessionStorage.removeItem(n)}catch{}}function f(){try{return localStorage.getItem(o)}catch{return null}}function I(t){try{t?localStorage.setItem(o,t):localStorage.removeItem(o)}catch{}}},755,[]);
859
+ __d(function(g,r,i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return u}});var t=e(r(d[0])),l=e(r(d[1])),n=e(r(d[2])),o=e(r(d[3])),s=e(r(d[4])),c=r(d[5]);function u({pending:e,onConfirm:s,onCancel:u}){const h=null!==e,x=e?`${e.status.username}@${e.status.hostname}`:"";return(0,c.jsx)(t.default,{visible:h,transparent:!0,animationType:"fade",onRequestClose:u,children:(0,c.jsx)(l.default,{style:b.backdrop,onPress:u,children:(0,c.jsxs)(l.default,{style:b.card,onPress:e=>e.stopPropagation(),children:[(0,c.jsx)(n.default,{style:b.title,children:e?.isUpdate?"Update credentials?":"Meld this device?"}),e?.isUpdate?(0,c.jsx)(n.default,{style:b.body,children:"You're already paired with this brane. The meld URL has a new token \u2014 replace the stored one?"}):(0,c.jsx)(n.default,{style:b.body,children:"You'll add this daemon to this device and switch to it."}),(0,c.jsxs)(o.default,{style:b.detailsBlock,children:[(0,c.jsx)(f,{label:"Daemon",value:x}),(0,c.jsx)(f,{label:"Address",value:e?.host??""}),(0,c.jsx)(f,{label:"Brane",value:e?.status.brane_id??"",mono:!0})]}),(0,c.jsxs)(o.default,{style:b.buttonRow,children:[(0,c.jsx)(l.default,{style:[b.button,b.cancelButton],onPress:u,children:(0,c.jsx)(n.default,{style:b.cancelText,children:"Cancel"})}),(0,c.jsx)(l.default,{style:[b.button,b.confirmButton],onPress:s,children:(0,c.jsx)(n.default,{style:b.confirmText,children:e?.isUpdate?"Update":"Meld"})})]})]})})})}function f({label:e,value:t,mono:l}){return(0,c.jsxs)(o.default,{style:b.detailRow,children:[(0,c.jsx)(n.default,{style:b.detailLabel,children:e}),(0,c.jsx)(n.default,{style:[b.detailValue,l&&b.detailValueMono],numberOfLines:1,selectable:!0,children:t})]})}const b=s.default.create({backdrop:{flex:1,backgroundColor:"rgba(0,0,0,0.7)",justifyContent:"center",alignItems:"center",padding:24},card:{backgroundColor:"#1e1e1e",borderRadius:12,padding:22,width:"100%",maxWidth:360},title:{color:"#e0e0e0",fontSize:17,fontWeight:"600",marginBottom:10,textAlign:"center"},body:{color:"#bbb",fontSize:13,lineHeight:18,marginBottom:14,textAlign:"center"},detailsBlock:{backgroundColor:"#2a2a2a",borderRadius:8,padding:12,marginBottom:18},detailRow:{flexDirection:"row",paddingVertical:3},detailLabel:{color:"#888",fontSize:12,width:70},detailValue:{color:"#e0e0e0",fontSize:12,flex:1},detailValueMono:{fontFamily:"monospace"},buttonRow:{flexDirection:"row",gap:10},button:{flex:1,paddingVertical:10,borderRadius:6,alignItems:"center"},cancelButton:{backgroundColor:"#2a2a2a"},cancelText:{color:"#ccc",fontSize:14},confirmButton:{backgroundColor:"#2e7d32"},confirmText:{color:"#fff",fontSize:14,fontWeight:"600"}})},756,[153,146,105,13,26,6]);
860
+ __d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.installNoPan=function(){if(t||"undefined"==typeof window)return;t=!0;const n=window.visualViewport,o=document.documentElement;let s=null;const c=()=>{if(!n)return;const t=(0,e.layoutHeight)(n.height,n.scale,s);null!==t&&t!==s&&(s=t,o.style.setProperty("--brane-vvh",`${t}px`))};n&&(n.addEventListener("resize",c),c());const l=!window.matchMedia?.("(pointer: fine)").matches;let u=0;const h=()=>{const t=document.activeElement;(0,e.mustBlur)({touch:l,textEntryFocused:!!t&&(0,e.isTextEntry)(t),keyboardUp:!!n&&window.innerHeight-n.height>120,msSinceTapFocus:Date.now()-u})&&t?.blur()};n&&n.addEventListener("resize",h);document.addEventListener("focusin",()=>{setTimeout(h,e.TAP_FOCUS_GRACE_MS+50)},!0);let p=0,v=0,f=!1,w=!1;document.addEventListener("touchstart",e=>{const t=e.touches[0];p=t.clientX,v=t.clientY,f=!1,w=e.touches.length>1},{passive:!0,capture:!0}),document.addEventListener("touchmove",t=>{const o=t.touches[0],s=o.clientX-p,c=o.clientY-v;if((Math.abs(s)>e.TAP_SLOP_PX||Math.abs(c)>e.TAP_SLOP_PX)&&(f=!0),w||t.touches.length>1||n&&Math.abs(n.scale-1)>.01)return;const l=[];for(let n=t.target;n&&n!==document.body;n=n.parentElement){const t=getComputedStyle(n);l.push((0,e.scrollBoxOf)({overflowY:t.overflowY,reversed:t.display.includes("flex")&&"column-reverse"===t.flexDirection,scrollTop:n.scrollTop,clientHeight:n.clientHeight,scrollHeight:n.scrollHeight}))}(0,e.dragAllowed)(s,c,l)||t.preventDefault()},{passive:!1,capture:!0}),document.addEventListener("touchend",t=>{if(f||w)return;const n=t.target?.closest?.("input, textarea, [contenteditable]");n&&n!==document.activeElement&&(0,e.isTextEntry)(n)&&(t.preventDefault(),u=Date.now(),n.focus({preventScroll:!0}))},{passive:!1,capture:!0})},r(d[0]);var e=r(d[1]);let t=!1},757,[116,758]);
861
+ __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"TAP_SLOP_PX",{enumerable:!0,get:function(){return o}}),e.isTextEntry=function(o){if(o.isContentEditable)return!0;const n=o.tagName.toUpperCase();return("INPUT"===n||"TEXTAREA"===n)&&(!o.disabled&&!o.readOnly&&("TEXTAREA"===n||!t.has((o.type??"text").toLowerCase())))},e.scrollBoxOf=function(o){const t=o.scrollHeight-o.clientHeight;if("auto"!==o.overflowY&&"scroll"!==o.overflowY||!(t>1))return{scrolls:!1,roomAbove:0,roomBelow:0};const[n,s]=o.reversed?[-t,0]:[0,t];return{scrolls:!0,roomAbove:o.scrollTop-n,roomBelow:s-o.scrollTop}},e.dragAllowed=function(o,t,n){if(Math.abs(o)>Math.abs(t))return!0;if(0===t)return!0;for(const o of n)if(o.scrolls){if(t>0&&o.roomAbove>1)return!0;if(t<0&&o.roomBelow>1)return!0}return!1},e.layoutHeight=function(o,t,n){return Math.abs(t-1)>.01?n:Math.round(o)},Object.defineProperty(e,"TAP_FOCUS_GRACE_MS",{enumerable:!0,get:function(){return n}}),e.mustBlur=function(o){return o.touch&&o.textEntryFocused&&!o.keyboardUp&&o.msSinceTapFocus>n};const o=10,t=new Set(["button","checkbox","color","file","hidden","image","radio","range","reset","submit"]);const n=1e3},758,[]);
862
+ __d(function(g,r,i,a,_m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return N}});var t=r(d[0]);r(d[1]);var n=e(r(d[2]));r(d[3]);var o=e(r(d[4])),l=e(r(d[5])),s=e(r(d[6])),u=r(d[7]),c=r(d[8]),f=r(d[9]);function p(e){const t=e.match(/^mcp__([^_]+(?:_[^_]+)*?)__(.+)$/);return t?`${t[1]}:${t[2]}`:e}function y(e){if(!e)return null;try{return JSON.parse(e)}catch{return null}}function h(e){return"object"!=typeof e||null===e||Array.isArray(e)?null:e}function m(e){const t=h(y(e.output));if(!t)return null;if(Array.isArray(t.content)){const e=t.content.find(e=>"string"==typeof e?.text)?.text;return h(y("string"==typeof e?e:null))}return t}function x(e){const t=p(e.name);if("brane:listen"===t)return{kind:"listen"};if("brane:narrate"!==t)return{kind:"work"};const n=h(y(e.input))?.nid;if("string"!=typeof n||n===e.narrative_id)return{kind:"self_narrate"};const o=m(e)?.seq;return{kind:"foreign_narrate",nid:n,seq:"number"==typeof o?o:void 0}}const b=240,j=8e3;function _(e){if(!e.input)return"";let t;try{t=JSON.parse(e.input)}catch{return e.input}if("object"!=typeof t||null===t)return String(t);const n=t,o=n.command??n.file_path??n.pattern??n.url??n.query??n.path;if("string"==typeof o)return o;const l=Object.values(n).find(e=>"string"==typeof e);return"string"==typeof l?l:e.input}function w(e){const t=_(e).replace(/\s*\n\s*/g," \u23ce ");return t.length>b?`${t.slice(0,b)}\u2026`:t}function k(e){if(!e)return null;const t=y(e);return null===t?e:JSON.stringify(t,null,2)}function S(e){return e.length<=j?{body:e,note:null}:{body:e.slice(0,j),note:`+${(e.length-j).toLocaleString()} more characters`}}function v(e){const t=h(y(e));return!!t&&0===Object.keys(t).length}function L(e){const t=[],n=p(e.name).startsWith("brane:"),o=(e,o,l)=>{if(!o)return;if(n&&("input"===e||"output"===e)&&v(o))return;const{body:s,note:u}=S(o);t.push({label:e,body:s,note:[l?.note,u].filter(Boolean).join(" \xb7 ")||null,failed:l?.failed})};return o("input",k(e.input),{note:e.input_truncated?"excerpt \u2014 the daemon holds the full value":void 0}),o("output",k(e.output),{note:e.output_truncated?"excerpt \u2014 the daemon holds the full value":void 0}),o("error",e.error,{failed:!0}),(e.decided_by||e.decision_note)&&o("decision",[e.decided_by,e.decision_note].filter(Boolean).join(" \u2014 ")),t}function $(e){return[e.status,e.source,e.agent_type].filter(Boolean).join(" \xb7 ")}function O(e){return null==e?"":e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}function z(e){return"failed"===e.status||"denied"===e.status}function F(e){return z(e)?{glyph:"\u2717",failed:!0}:"unknown"===e.status?{glyph:"\u2013",failed:!1}:"pending"===e.status||"allowed"===e.status?{glyph:"\u2026",failed:!1}:null}function T({children:e}){const t=(0,u.useHorizontalPanGuard)();return(0,f.jsx)("div",Object.assign({style:{overflowX:"auto",overflowY:"hidden"}},t,{children:(0,f.jsx)("div",{style:{display:"flex",flexDirection:"column",width:"max-content",minWidth:"100%"},children:e})}))}function N({rows:e,onNarrativePress:o,onFetchFull:u}){const y=(0,t.useMemo)(()=>e.map(e=>({row:e,kind:x(e)})).filter(({kind:e})=>"self_narrate"!==e.kind),[e]),h=y.some(({row:e})=>z(e)),[m,b]=(0,t.useState)(h),j=(0,t.useRef)(!1);(0,t.useEffect)(()=>{h&&!j.current&&b(!0)},[h]);const[_,k]=(0,t.useState)(P),S=(0,t.useCallback)(e=>{k(t=>{const n=new Set(t);return n.delete(e)||n.add(e),n})},[]),[v,L]=(0,t.useState)(0),$=(0,t.useMemo)(()=>{const e=new Map;let t=0;for(const{row:n,kind:o}of y){const l=p(n.name);e.set(l,(e.get(l)??0)+1),"listen"!==o.kind&&(t+=n.duration_ms??0)}const n=[...e.entries()].map(([e,t])=>t>1?`${e} \xd7${t}`:e).join(", ");return`${1===y.length?"1 tool":`${y.length} tools`}${t>0?` (${O(t)})`:""}: ${n}`},[y]);return 0===y.length?null:(0,f.jsxs)(s.default,{style:R.container,dataSet:{chrome:"tools"},onLayout:e=>L(e.nativeEvent.layout.width),children:[(0,f.jsxs)(n.default,{onPress:()=>{j.current=!0,b(e=>(e&&k(P),!e))},style:R.summaryRow,children:[(0,f.jsx)(l.default,{style:R.gear,children:"\u2699"}),(0,f.jsx)(l.default,{style:[R.summaryText,h&&R.failText],numberOfLines:1,children:$})]}),m&&(0,f.jsx)(T,{children:y.map(({row:e,kind:y})=>{const h=F(e),m=_.has(e.dedup_key);return(0,f.jsxs)(t.Fragment,{children:[(0,f.jsxs)(n.default,{style:R.row,onPress:()=>S(e.dedup_key),accessibilityRole:"button",accessibilityState:{expanded:m},children:[(0,f.jsx)(l.default,{style:R.gear,children:"\u2699"}),(0,f.jsx)(l.default,{style:[R.name,h?.failed&&R.failText],numberOfLines:1,children:p(e.name)}),"foreign_narrate"===y.kind?(0,f.jsx)(l.default,{style:[R.args,C],numberOfLines:q?void 0:1,children:(0,f.jsxs)(l.default,Object.assign({style:R.link},A((0,c.narrativeHref)(y.nid,y.seq),()=>o?.(y.nid,y.seq)),{children:["\u2192\xa0",y.seq?`${y.nid}:${y.seq}`:y.nid]}))}):(0,f.jsx)(l.default,{style:[R.args,C],numberOfLines:q?void 0:1,children:w(e)}),(0,f.jsx)(s.default,{style:R.slack}),(0,f.jsxs)(s.default,{style:[R.trailing,M],children:[(0,f.jsx)(l.default,{style:R.duration,children:O(e.duration_ms)}),(0,f.jsx)(l.default,{style:[R.status,h?.failed&&R.failText],children:h?.glyph??" "})]})]}),m&&(0,f.jsx)(n.default,{style:[R.detail,D,v>0?{width:v-2*H}:null],onPress:()=>{"undefined"!=typeof window&&window.getSelection()?.toString()||S(e.dedup_key)},children:(0,f.jsx)(B,{row:e,onFetchFull:u})})]},e.dedup_key)})}),m&&y.map(({row:e})=>e).filter(z).map(e=>e.error?(0,f.jsx)(l.default,{style:[R.errorLine,R.failText],numberOfLines:2,children:e.error},`${e.dedup_key}-err`):null)]})}function B({row:e,onFetchFull:n}){const[o,u]=(0,t.useState)(null),[c,p]=(0,t.useState)(!1),y=!(!e.input_truncated&&!e.output_truncated);(0,t.useEffect)(()=>{if(!y||!n||o)return;let t=!0;return n(e.dedup_key).then(e=>{t&&u(e)}).catch(()=>{t&&p(!0)}),()=>{t=!1}},[y,n,o,e.dedup_key]);const h=o??e,m=(0,t.useMemo)(()=>L(h),[h]),x=y&&!o&&!c;return(0,f.jsxs)(f.Fragment,{children:[x&&(0,f.jsx)(l.default,{style:R.detailNote,children:"excerpt \u2014 fetching the rest\u2026"}),c&&(0,f.jsx)(l.default,{style:[R.detailNote,R.failText],children:"excerpt \u2014 the full value could not be fetched"}),0===m.length?(0,f.jsx)(l.default,{style:R.detailNote,children:"nothing recorded beyond the row itself"}):m.map(e=>(0,f.jsxs)(s.default,{style:R.detailSection,children:[(0,f.jsx)(l.default,{style:R.detailLabel,children:e.label}),(0,f.jsx)(l.default,{style:[R.detailBody,e.failed&&R.failText],selectable:!0,children:e.body}),e.note&&(0,f.jsx)(l.default,{style:R.detailNote,children:e.note})]},e.label)),(0,f.jsx)(l.default,{style:R.detailNote,children:$(h)})]})}const P=new Set;function A(e,t){const n=(0,c.inAppLinkProps)(e,t),o=n.onClick;return Object.assign({},n,{onClick:e=>{e.stopPropagation?.(),o?.(e)}})}const q=!0,C={whiteSpace:"nowrap",textOverflow:"clip"},M={position:"sticky",right:0},D={position:"sticky",left:0},H=12,R=o.default.create({container:{paddingHorizontal:H,paddingTop:4,paddingBottom:10},summaryRow:{flexDirection:"row",alignItems:"center"},row:{flexDirection:"row",alignItems:"center",paddingVertical:2,paddingLeft:18},gear:{color:"#666",fontSize:11,width:18,textAlign:"center"},summaryText:{color:"#8a8a8e",fontSize:12,flexShrink:1},name:{color:"#9a9aa0",fontSize:12,fontFamily:"monospace",minWidth:64,paddingRight:8},args:{color:"#666",fontSize:12,fontFamily:"monospace"},slack:{flex:1,minWidth:8},link:{color:"#6cb6ff",textDecorationLine:"underline"},trailing:{flexDirection:"row",alignItems:"center",backgroundColor:"#111",paddingLeft:10},duration:{color:"#666",fontSize:11,paddingLeft:8,textAlign:"right"},status:{fontSize:11,width:14,textAlign:"center",color:"#666"},detail:{alignSelf:"flex-start",backgroundColor:"#17171b",borderLeftWidth:2,borderLeftColor:"#333",paddingHorizontal:10,paddingVertical:6,marginBottom:4},detailSection:{paddingBottom:6},detailLabel:{color:"#8a8a8e",fontSize:10,textTransform:"uppercase",letterSpacing:.5,paddingBottom:2},detailBody:{color:"#c8c8cc",fontSize:11,fontFamily:"monospace",lineHeight:15},detailNote:{color:"#666",fontSize:10,fontStyle:"italic"},errorLine:{fontSize:11,fontFamily:"monospace",paddingLeft:36,paddingVertical:1},failText:{color:"#e57373"}})},759,[11,116,146,122,26,105,13,760,761,6]);
863
+ __d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.useHorizontalPanGuard=function(){const e=(0,n.useRef)(null),u=(0,n.useRef)(!1);return(0,n.useMemo)(()=>{const n=n=>{u.current&&n.stopPropagation?.(),e.current=null,u.current=!1};return{onTouchStart:n=>{e.current=t(n),u.current=!1},onTouchMove:n=>{const o=e.current;if(o){if(!u.current){const{x:e,y:c}=t(n),s=Math.abs(e-o.x),l=Math.abs(c-o.y);s>6&&s>1.2*l&&(u.current=!0)}u.current&&n.stopPropagation()}},onTouchEnd:n,onTouchCancel:n}},[])};var n=r(d[0]);function t(n){const t=n.nativeEvent?.touches?.[0]??n.nativeEvent??n;return{x:t.pageX??t.clientX??0,y:t.pageY??t.clientY??0}}},760,[11]);
864
+ __d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.inAppLinkProps=function(t,n){return t?{href:t,onClick:t=>{e(t)&&(t.preventDefault(),n())}}:{onPress:n}},_e.narrativeHref=function(e,t){return t?`/${e}?scrollToSeq=${t}`:`/${e}`},_e.fileHref=function(e,t,n,o,u){const f=new URLSearchParams({tab:"files",path:t});n&&f.set("line",o&&o>n?`${n}-${o}`:String(n));u&&f.set("pinned",u);return`/${e}?${f.toString()}`},r(d[0]);function e(e){return!(0!==e.button||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey)}},761,[116]);
865
+ __d(function(g,r,_i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return H}});var t=r(d[0]);r(d[1]);var n=r(d[2]),o=r(d[3]),c=r(d[4]),s=r(d[5]),l=r(d[6]),i=e(r(d[7])),u=e(r(d[8])),f=e(r(d[9])),p=r(d[10]),y=r(d[11]);const h=1.4,v=16.799999999999997,b=(0,c.blockGlyphStylesheet)(h);function x(e,t){let n="";return e.ctrlKey&&(n+="C-"),e.altKey&&(n+="M-"),t&&e.shiftKey&&(n+="S-"),n}const C={Enter:"Enter",Escape:"Escape",Tab:"Tab",Backspace:"BSpace",Delete:"DC",Insert:"IC",ArrowUp:"Up",ArrowDown:"Down",ArrowLeft:"Left",ArrowRight:"Right",Home:"Home",End:"End",PageUp:"PPage",PageDown:"NPage",F1:"F1",F2:"F2",F3:"F3",F4:"F4",F5:"F5",F6:"F6",F7:"F7",F8:"F8",F9:"F9",F10:"F10",F11:"F11",F12:"F12"};function w(e){const t=C[e.key];if(t)return x(e,!0)+t;if(" "===e.key){const t=x(e,!1);return t?t+"Space":" "}return(e.ctrlKey||e.altKey)&&1===e.key.length?x(e,!1)+e.key.toLowerCase():1!==e.key.length||e.ctrlKey||e.altKey||e.metaKey?null:e.key}const k=[{label:"Esc",keys:"Escape"},{label:"1",keys:"1"},{label:"2",keys:"2"},{label:"3",keys:"3"}],E="undefined"!=typeof navigator&&"undefined"!=typeof document&&(/iP(ad|hone|od)/.test(navigator.userAgent)||/Mac/.test(navigator.userAgent)&&"ontouchend"in document),S="undefined"!=typeof navigator&&/Mac|iP(ad|hone|od)/.test(navigator.platform||navigator.userAgent);function F(e){return"v"===e.key.toLowerCase()&&!e.altKey&&(S?e.metaKey&&!e.ctrlKey:e.ctrlKey&&!e.metaKey)}const R=/[\u23fa\u{1F518}]/gu;const M=/\x1b\][\s\S]*?(?:\x07|\x1b\\)/g;function j(e){return e.replace(M,"")}function K({onPress:e,style:n,children:o}){const[c,s]=(0,t.useState)(!1),l=(0,t.useRef)(null),i=(0,t.useCallback)(()=>{e(),l.current&&clearTimeout(l.current),s(!0),l.current=setTimeout(()=>s(!1),180)},[e]);return(0,y.jsx)("button",{onClick:i,style:Object.assign({},n,c?{backgroundColor:"#4444cc",border:"1px solid #7c7cff",color:"#fff",boxShadow:"0 0 8px rgba(120, 120, 255, 0.8)"}:{boxShadow:"none"},{transition:"background-color 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease, color 0.15s ease"}),children:o})}const L=(0,t.forwardRef)(function({conn:e,nid:x,active:C=!0,keyboardActive:S,agentType:M,role:L,onAtBottomChange:H,onTwin:A,onRevived:T},D){const P=(0,t.useRef)(null),z=(0,t.useRef)(null),_=(0,t.useRef)(null),B=(0,t.useRef)(!0),I=(0,t.useRef)(null),N=(0,t.useRef)(null),X=(0,t.useRef)(null),Y=(0,t.useRef)(0),q=(0,t.useRef)(C);q.current=C;const O=(0,t.useRef)(S??C);O.current=S??C;const W=(0,n.useIsFocused)(),U=(0,t.useRef)(W);U.current=W;const[G,$]=(0,t.useState)(!1),[J,Q]=(0,t.useState)(!1),V=(0,t.useRef)(null),Z=(0,t.useRef)(!1);Z.current=J;const[ee,te]=(0,t.useState)(!1),[ne,re]=(0,t.useState)(!1),oe=(0,t.useRef)(()=>{}),[ce,se]=(0,t.useState)(!1),le=(0,t.useRef)(!1),ie=(0,t.useRef)(null),ue=(0,t.useRef)(null),ae=(0,t.useRef)(null),de=(S??C)&&W,fe=(0,t.useRef)(de);fe.current=de;const pe=(0,t.useRef)(!0),ye=(0,t.useRef)(H);ye.current=H;const he=(0,t.useCallback)(e=>{pe.current=e,le.current&&e!==B.current&&(B.current=e,ye.current?.(e))},[]),me=(0,t.useCallback)(e=>{"C-End"===e?he(!0):"PPage"!==e&&"C-Home"!==e||he(!1)},[he]);(0,t.useImperativeHandle)(D,()=>({focus:()=>{const e=P.current;if(e)try{e.focus({preventScroll:!0})}catch{e.focus()}},scrollToTop:()=>{if(le.current)return _.current?.sendKeys("C-Home"),void he(!1);const e=P.current;e&&(e.scrollTop=0,B.current=!1,H?.(!1))},scrollToBottom:()=>{if(le.current)return _.current?.sendKeys("C-End"),void he(!0);const e=P.current;e&&(e.scrollTop=e.scrollHeight,B.current=!0,H?.(!0))},terminate:()=>{(0,l.sendInterrupt)(e=>_.current?.sendKeys(e))},revive:()=>{oe.current()}}),[H,he]);const ve=(0,t.useRef)(new WeakMap),ge=(0,t.useCallback)((e,t)=>{var n;0===t.length?e.textContent="\xa0":z.current?e.innerHTML=(0,c.paintBlockGlyphs)(z.current.ansi_to_html((n=j(t),E?n.replace(R,"\u25cf"):n))):e.textContent=j(t)},[]),be=(0,t.useCallback)(e=>{const t=document.createElement("div");return t.style.display="block",t.style.minHeight="1.4em",t.style.position="relative",ge(t,e),ve.current.set(t,e),t},[ge]),xe=(0,t.useCallback)((e,t)=>{ge(e,t),ve.current.set(e,t)},[ge]),Ce=(0,t.useCallback)(e=>ve.current.get(e),[]),we=(0,t.useCallback)(()=>{const e=P.current?.querySelector("pre"),t=ae.current,n=ue.current,o=ie.current;if(!e||!n||!o)return void(t?.parentNode&&t.parentNode.removeChild(t));const c=e.children[n.line];if(!c)return void(t?.parentNode&&t.parentNode.removeChild(t));const s=t??document.createElement("span");t||(s.style.position="absolute",s.style.top="0",s.style.pointerEvents="none",s.style.backgroundColor="#fff",s.style.mixBlendMode="difference",ae.current=s),s.style.left=n.col*o.width+"px",s.style.width=`${o.width}px`,s.style.height=`${v}px`,fe.current?(s.style.backgroundColor="#fff",s.style.border="none",s.style.animation="brane-cursor-blink 1.06s steps(1, end) infinite"):(s.style.backgroundColor="transparent",s.style.border="1px solid #fff",s.style.boxSizing="border-box",s.style.animation="none"),"relative"!==c.style.position&&(c.style.position="relative"),s.parentNode!==c&&c.appendChild(s)},[]);(0,t.useEffect)(()=>{we()},[de,we]);const ke=(0,t.useCallback)(()=>{const e=P.current,t=e?.querySelector("pre");if(t){for(;t.firstChild;)t.removeChild(t.firstChild);ve.current=new WeakMap,ae.current=null}_.current?.refresh()},[]),Ee=(0,t.useCallback)((e,t)=>{const n=Array.from(e.children),o=t.length,c=n.length,s=Math.min(o,c);let l=o!==c;for(let e=0;e<s;e++)Ce(n[e])!==t[e]&&(xe(n[e],t[e]),l=!0);if(o>c){const n=document.createDocumentFragment();for(let e=c;e<o;e++)n.appendChild(be(t[e]));e.appendChild(n)}else if(c>o)for(let t=c-1;t>=o;t--)e.removeChild(n[t]);return l},[be,xe,Ce]),Se=(0,t.useCallback)((e,t,n,o)=>{const c=Math.max(0,0|n),s=Math.max(0,0|o),l=Array.from(e.children).length;let i=!1;if(c>l){const t=document.createDocumentFragment();for(let e=l;e<c;e++)t.appendChild(be(""));e.appendChild(t),i=!0}const u=Array.from(e.children);let f=null;for(let e=0;e<t.length;e++){const n=c+e;n<u.length?Ce(u[n])!==t[e]&&(xe(u[n],t[e]),i=!0):(f||(f=document.createDocumentFragment()),f.appendChild(be(t[e])),i=!0)}f&&e.appendChild(f);const p=e.children.length;if(p>s){for(let t=p-1;t>=s;t--){const n=e.children[t];n&&e.removeChild(n)}i=!0}return i},[be,xe,Ce]),Fe=(0,t.useCallback)(e=>{const t=P.current;if(!t||!z.current)return;const n=t.querySelector("pre");if(!n)return;const o=t,c=le.current?pe.current:o.scrollHeight-o.scrollTop-o.clientHeight<40;let s;c!==B.current&&H?.(c),B.current=c,"frame"!==e.type&&"append"!==e.type||(ue.current=e.cursor??null);let l=!1;if("frame"===e.type){const t=e.data.split("\n");l=Ee(n,t),s=e.alternate_on}else if("append"===e.type){const t=e.data.split("\n");l=Se(n,t,e.lineOffset,e.totalLines),s=e.alternate_on}void 0!==s&&s!==le.current&&(le.current=s,se(s)),we(),l&&B.current&&o.scrollHeight>o.clientHeight&&(o.scrollTop=o.scrollHeight)},[Ee,Se,H,we]),Re=(0,t.useCallback)(()=>{X.current=null;const e=N.current;e&&(N.current=null,Fe(e))},[Fe]),Me=(0,t.useCallback)(e=>{if(!q.current)return void(I.current=e);const t=null!==N.current;N.current=e,t||(Y.current=Date.now()),null!==X.current?Date.now()-Y.current>=400&&(cancelAnimationFrame(X.current),X.current=null,Re()):X.current=requestAnimationFrame(Re)},[Re]);(0,t.useEffect)(()=>{if("undefined"==typeof document)return;const e=()=>{"visible"===document.visibilityState&&(null!==X.current&&(cancelAnimationFrame(X.current),X.current=null),N.current&&Re(),q.current&&_.current?.refresh())};return document.addEventListener("visibilitychange",e),()=>document.removeEventListener("visibilitychange",e)},[Re]),(0,t.useEffect)(()=>()=>{null!==X.current&&(cancelAnimationFrame(X.current),X.current=null),N.current=null},[]);const je=(0,t.useRef)(void 0);(0,t.useEffect)(()=>{const e=_.current;if(!e)return;const t=je.current;je.current=C,C?(e.start(),I.current&&(Fe(I.current),I.current=null),!1===t&&ke()):e.stop()},[C,Fe,ke]),(0,t.useEffect)(()=>{if(!z.current){const e=new o.AnsiUp;e.use_classes=!1,z.current=e}const t=(0,l.createTerminalChannel)({conn:e,nid:x,onFrame:Me,onCursor:e=>{ue.current=e,q.current&&we()},onTerminated:()=>te(!0)});return _.current=t,t.start(),()=>{t.close(),_.current=null}},[e,x,Me,we]),(0,t.useEffect)(()=>{const e=e=>{if(!O.current||!U.current)return;if(Z.current)return;if(F(e))return;let t=w(e);t&&le.current&&("Home"===t?t="C-Home":"End"===t&&(t="C-End")),t&&_.current&&(e.preventDefault(),_.current.sendKeys(t),me(t))};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[]),(0,t.useEffect)(()=>{const e=e=>{if(!O.current||!U.current)return;const t=e.clipboardData?.getData("text");t&&(e.preventDefault(),_.current?.sendPaste(t),Z.current&&Q(!1))};return document.addEventListener("paste",e),()=>document.removeEventListener("paste",e)},[]);const Ke=(0,t.useCallback)(async()=>{try{const e=await(navigator.clipboard?.readText());if(e)return void _.current?.sendPaste(e);if(""===e)return}catch{}Q(!0)},[]);(0,t.useEffect)(()=>{const e=P.current;if(!e)return;const t=document.createElement("span");t.style.fontFamily="'Menlo', 'Monaco', 'Courier New', monospace",t.style.fontSize="12px",t.style.lineHeight="1.4",t.style.position="absolute",t.style.visibility="hidden",t.style.whiteSpace="pre",t.textContent="X",document.body.appendChild(t);const n=t.getBoundingClientRect().width;if(document.body.removeChild(t),0===n)return;const o=v;let c=0,s=0;const l=new ResizeObserver(e=>{for(const t of e){const{width:e,height:l}=t.contentRect,i=Math.floor((e-16)/n),u=Math.floor((l-16)/o);i>0&&u>0&&(i!==c||u!==s)&&(c=i,s=u,_.current?.resize(i,u))}});return l.observe(e),()=>l.disconnect()},[]),(0,t.useEffect)(()=>{const e=document.createElement("span");e.style.fontFamily="'Menlo', 'Monaco', 'Courier New', monospace",e.style.fontSize="12px",e.style.lineHeight="1.4",e.style.position="absolute",e.style.visibility="hidden",e.style.whiteSpace="pre",e.textContent="X",document.body.appendChild(e),ie.current={width:e.getBoundingClientRect().width,height:v},document.body.removeChild(e)},[]),(0,t.useEffect)(()=>{const e=P.current;if(!e||ce)return;const t=t=>{if(t.altKey||t.shiftKey||t.metaKey||t.ctrlKey)return;const n=ue.current,o=ie.current,c=_.current;if(!n||!o||!c)return;const s="undefined"!=typeof window?window.getSelection():null;if(s&&!s.isCollapsed)return;const l=e.querySelector("pre");if(!l)return;let i=t.target;for(;i&&i.parentElement!==l;)i=i.parentElement;if(!i)return;if(Array.prototype.indexOf.call(l.children,i)!==n.line)return;const u=Math.max(0,Math.round((t.clientX-i.getBoundingClientRect().left)/o.width))-n.col;0!==u&&c.sendKeys(u>0?"Right":"Left",Math.abs(u))};return e.addEventListener("click",t),()=>e.removeEventListener("click",t)},[ce]),(0,t.useEffect)(()=>{const e=P.current;if(!e||!ce)return;const t=(t,n)=>{if(!ie.current)return null;const o=e.querySelector("pre");if(!o)return null;const c=o.getBoundingClientRect(),s=t-c.left-8,l=n-c.top-8;return{col:Math.max(0,Math.floor(s/ie.current.width)),row:Math.max(0,Math.floor(l/ie.current.height))}};let n=!1,o=0,c=null;const s=e=>e.altKey||e.shiftKey,l=l=>{if(s(l))return;const i=t(l.clientX,l.clientY);if(i&&_.current){try{e.focus({preventScroll:!0})}catch{e.focus()}var u;l.preventDefault(),u=l.button,o=1===u?1:2===u?2:0,n=!0,c=i,_.current.sendMouse(i.col,i.row,o,"down")}},i=e=>{if(!n)return;const s=t(e.clientX,e.clientY);s&&_.current&&(c&&s.col===c.col&&s.row===c.row||(c=s,_.current.sendMouse(s.col,s.row,o,"drag")))},u=e=>{if(!n)return;const s=t(e.clientX,e.clientY)??c;n=!1,s&&_.current?(_.current.sendMouse(s.col,s.row,o,"up"),c=null):c=null},f=e=>{const n=t(e.clientX,e.clientY);if(!n||!_.current)return;e.preventDefault();const o=e.deltaY>0?"scroll_down":"scroll_up";_.current.sendMouse(n.col,n.row,0,o),"scroll_up"===o&&he(!1)},p=e=>{s(e)||e.preventDefault()};return e.addEventListener("mousedown",l),e.addEventListener("wheel",f,{passive:!1}),e.addEventListener("contextmenu",p),window.addEventListener("mousemove",i),window.addEventListener("mouseup",u),()=>{e.removeEventListener("mousedown",l),e.removeEventListener("wheel",f),e.removeEventListener("contextmenu",p),window.removeEventListener("mousemove",i),window.removeEventListener("mouseup",u)}},[ce]),(0,t.useEffect)(()=>{const e=P.current;if(!e||!ce)return;let t=0,n=0,o=0,c=0,s=0;const l=l=>{if(1!==l.touches.length)return;const i=l.touches[0];if(t=i.clientX,n=i.clientY,o=i.clientY,ie.current){const t=(e.querySelector("pre")??e).getBoundingClientRect(),n=i.clientX-t.left-8,o=i.clientY-t.top-8;c=Math.max(0,Math.floor(n/ie.current.width)),s=Math.max(0,Math.floor(o/ie.current.height))}},i=e=>{if(1!==e.touches.length)return;if(!_.current)return;const l=e.touches[0],i=l.clientY-n,u=l.clientX-t;Math.abs(i)>Math.abs(u)&&e.preventDefault();const f=l.clientY-o;if(Math.abs(f)<20)return;const p=Math.trunc(f/20);o+=20*p;const y=p>0?"scroll_up":"scroll_down";for(let e=0;e<Math.abs(p);e++)_.current.sendMouse(c,s,0,y);"scroll_up"===y&&he(!1)};return e.addEventListener("touchstart",l,{passive:!0}),e.addEventListener("touchmove",i,{passive:!1}),()=>{e.removeEventListener("touchstart",l),e.removeEventListener("touchmove",i)}},[ce]),(0,t.useEffect)(()=>{const e=P.current;e&&B.current&&requestAnimationFrame(()=>{e.scrollTop=e.scrollHeight})},[G]);const Le=S??C;(0,t.useEffect)(()=>{if(!Le)return;const e=P.current;if(e)try{e.focus({preventScroll:!0})}catch{e.focus()}},[Le]),(0,t.useEffect)(()=>{const e=P.current;if(!e)return;let t=B.current;const n=()=>{const n=e.scrollHeight-e.scrollTop-e.clientHeight<40;n!==t&&(t=n,B.current=n,H?.(n))};return e.addEventListener("scroll",n,{passive:!0}),()=>e.removeEventListener("scroll",n)},[H]);const He=(0,t.useCallback)(async()=>{if((0,p.revivesAsTwin)(L)&&A)A();else{re(!0);try{const t=await(0,s.reviveNarrative)(e,x);if(t.nid&&t.nid!==x)return void T?.(t.nid);te(!1),_.current?.close();const n=(0,l.createTerminalChannel)({conn:e,nid:x,onFrame:Me,onTerminated:()=>te(!0)});_.current=n,n.start()}catch(e){console.error("Revive failed:",e)}finally{re(!1)}}},[e,x,Me,L,A,T]);oe.current=He;const Ae=(0,t.useCallback)(e=>{if(!_.current)return;if(e.keys)return void _.current.sendKeys(e.keys);if(!e.text)return;const t=e.text.split("\n");for(let e=0;e<t.length;e++)t[e]&&_.current.sendKeys(t[e]),e<t.length-1&&_.current.sendKeys("Enter")},[]),Te=(0,t.useCallback)(e=>{_.current?.sendKeys(e),me(e)},[me]),De=(0,t.useCallback)(e=>{if(_.current)return"transcript"===e.action?(_.current.sendKeys("C-o"),void ke()):void("paste"!==e.action?"clear-history"!==e.action?e.keys&&(_.current.sendKeys(e.keys),me(e.keys)):_.current.clearHistory():Ke())},[ke,me,Ke]);return(0,y.jsxs)("div",{style:{display:"flex",flexDirection:"column",flex:1,minHeight:0,overflow:"hidden"},children:[(0,y.jsx)("style",{children:"@keyframes brane-cursor-blink {\n 0%, 45% { opacity: 1; }\n 55%, 100% { opacity: 0; }\n}"}),(0,y.jsx)("style",{children:b}),(0,y.jsxs)("div",{style:{position:"relative",flex:1,minHeight:0,display:"flex",flexDirection:"column"},children:[ee&&(0,y.jsx)("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:10,display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"rgba(0, 0, 0, 0.85)"},children:(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)("div",{style:{position:"absolute",left:0,right:0,top:"50%",transform:"translateY(calc(-100% - 36px))",textAlign:"center",color:"#888",fontSize:15,fontFamily:"system-ui, -apple-system, sans-serif",pointerEvents:"none"},children:"Session ended"}),(0,y.jsx)("button",{onClick:()=>He(),disabled:ne,style:{padding:"10px 24px",borderRadius:8,border:"1px solid #4caf50",backgroundColor:ne?"#1c1c1e":"#2e7d32",color:"#fff",fontSize:15,fontWeight:"600",cursor:ne?"default":"pointer",opacity:ne?.6:1,fontFamily:"system-ui, -apple-system, sans-serif"},children:ne?"utility"===L?"Restarting\u2026":"Reviving\u2026":(0,p.revivesAsTwin)(L)?"/twin":"utility"===L?"Restart":"Revive"})]})}),(0,y.jsx)("div",{ref:P,tabIndex:0,style:Object.assign({flex:1,minHeight:0,overflow:ce?"hidden":"auto",backgroundColor:"#111",outline:"none",WebkitOverflowScrolling:"touch",touchAction:ce?"none":"auto"},ce?{display:"flex",flexDirection:"column",justifyContent:"flex-end",alignItems:"flex-start"}:{}),children:(0,y.jsx)("pre",{style:{margin:ce?"auto":0,padding:8,fontFamily:"'Menlo', 'Monaco', 'Courier New', monospace",fontSize:12,lineHeight:h,color:"#e0e0e0",whiteSpace:"pre",wordWrap:"normal",overflowX:"auto",cursor:ce?"pointer":"default"}})})]}),J&&(0,y.jsxs)("div",{style:{padding:"8px 10px",backgroundColor:"#1a1a1a",borderTop:"1px solid #444",flexShrink:0},children:[(0,y.jsx)("div",{style:{color:"#aaa",fontSize:12,marginBottom:6,fontFamily:"monospace"},children:"Paste here (long-press \u2192 Paste), or type and Send"}),(0,y.jsxs)("div",{style:{display:"flex",gap:8,alignItems:"flex-start"},children:[(0,y.jsx)("textarea",{autoFocus:!0,ref:V,rows:2,style:{flex:1,backgroundColor:"#111",color:"#e0e0e0",border:"1px solid #555",borderRadius:6,padding:6,fontFamily:"'Menlo', 'Monaco', 'Courier New', monospace",fontSize:13,resize:"vertical"}}),(0,y.jsx)("button",{onClick:()=>{const e=V.current?.value??"";e&&_.current?.sendPaste(e),Q(!1)},style:{padding:"6px 10px",borderRadius:6,border:"1px solid #555",backgroundColor:"#252525",color:"#ccc",fontSize:13,fontFamily:"monospace",cursor:"pointer"},children:"Send"}),(0,y.jsx)("button",{onClick:()=>Q(!1),style:{padding:"6px 10px",borderRadius:6,border:"1px solid #555",backgroundColor:"#1e1e1e",color:"#888",fontSize:13,fontFamily:"monospace",cursor:"pointer"},children:"Cancel"})]})]}),G&&(0,y.jsx)(i.default,{sendKeys:Te}),(0,y.jsxs)("div",{style:{display:"flex",flexDirection:"row",justifyContent:"center",gap:8,padding:"6px 8px",paddingBottom:"max(6px, env(safe-area-inset-bottom))",minHeight:53,boxSizing:"border-box",backgroundColor:"#1a1a1a",borderTop:"1px solid rgb(216, 216, 216)",flexShrink:0,alignItems:"center"},children:[(0,y.jsx)("button",{onClick:()=>$(e=>!e),style:{padding:"6px 8px",borderRadius:6,border:"1px solid "+(G?"#4caf50":"#555"),backgroundColor:G?"#2e7d32":"#252525",color:G?"#fff":"#ccc",fontSize:15,lineHeight:"18px",fontFamily:"monospace",cursor:"pointer",whiteSpace:"nowrap"},children:"\ud83c\udfb9"}),(0,y.jsx)("div",{style:{width:1,height:24,backgroundColor:"#333",flexShrink:0}}),(0,y.jsx)(u.default,{onSelect:Ae}),(0,y.jsx)(f.default,{onControl:De}),(0,y.jsx)("div",{style:{width:1,height:24,backgroundColor:"#333",flexShrink:0}}),k.map(e=>(0,y.jsx)(K,{onPress:()=>_.current?.sendKeys(e.keys),style:{padding:"6px 8px",borderRadius:6,border:"1px solid #555",backgroundColor:"#1e1e1e",color:"#aaa",fontSize:14,fontFamily:"monospace",cursor:"pointer",whiteSpace:"nowrap",minWidth:28,textAlign:"center"},children:e.label},e.label)),(0,y.jsx)(K,{onPress:()=>_.current?.sendKeys("Enter"),style:{padding:"6px 8px",borderRadius:6,border:"1px solid #555",backgroundColor:"#1e1e1e",color:"#aaa",fontSize:14,fontFamily:"monospace",cursor:"pointer",whiteSpace:"nowrap",minWidth:34,textAlign:"center"},children:"Ret"})]})]})});var H=(0,t.memo)(L)},762,[11,116,165,763,764,745,749,765,766,768,769,6]);
866
+ __d(function(_g,_r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"AnsiUp",{enumerable:!0,get:function(){return r}});var t,n,i,s,l=this&&this.__makeTemplateObject||function(t,n){return Object.defineProperty?Object.defineProperty(t,"raw",{value:n}):t.raw=n,t};!(function(t){t[t.EOS=0]="EOS",t[t.Text=1]="Text",t[t.Incomplete=2]="Incomplete",t[t.ESC=3]="ESC",t[t.Unknown=4]="Unknown",t[t.SGR=5]="SGR",t[t.OSCURL=6]="OSCURL"})(t||(t={}));class r{constructor(){this.VERSION="6.0.6",this.setup_palettes(),this._use_classes=!1,this.bold=!1,this.faint=!1,this.italic=!1,this.underline=!1,this.fg=this.bg=null,this._buffer='',this._url_allowlist={http:1,https:1},this._escape_html=!0,this.boldStyle='font-weight:bold',this.faintStyle='opacity:0.7',this.italicStyle='font-style:italic',this.underlineStyle='text-decoration:underline'}set use_classes(t){this._use_classes=t}get use_classes(){return this._use_classes}set url_allowlist(t){this._url_allowlist=t}get url_allowlist(){return this._url_allowlist}set escape_html(t){this._escape_html=t}get escape_html(){return this._escape_html}set boldStyle(t){this._boldStyle=t}get boldStyle(){return this._boldStyle}set faintStyle(t){this._faintStyle=t}get faintStyle(){return this._faintStyle}set italicStyle(t){this._italicStyle=t}get italicStyle(){return this._italicStyle}set underlineStyle(t){this._underlineStyle=t}get underlineStyle(){return this._underlineStyle}setup_palettes(){this.ansi_colors=[[{rgb:[0,0,0],class_name:"ansi-black"},{rgb:[187,0,0],class_name:"ansi-red"},{rgb:[0,187,0],class_name:"ansi-green"},{rgb:[187,187,0],class_name:"ansi-yellow"},{rgb:[0,0,187],class_name:"ansi-blue"},{rgb:[187,0,187],class_name:"ansi-magenta"},{rgb:[0,187,187],class_name:"ansi-cyan"},{rgb:[255,255,255],class_name:"ansi-white"}],[{rgb:[85,85,85],class_name:"ansi-bright-black"},{rgb:[255,85,85],class_name:"ansi-bright-red"},{rgb:[0,255,0],class_name:"ansi-bright-green"},{rgb:[255,255,85],class_name:"ansi-bright-yellow"},{rgb:[85,85,255],class_name:"ansi-bright-blue"},{rgb:[255,85,255],class_name:"ansi-bright-magenta"},{rgb:[85,255,255],class_name:"ansi-bright-cyan"},{rgb:[255,255,255],class_name:"ansi-bright-white"}]],this.palette_256=[],this.ansi_colors.forEach(t=>{t.forEach(t=>{this.palette_256.push(t)})});let t=[0,95,135,175,215,255];for(let n=0;n<6;++n)for(let i=0;i<6;++i)for(let s=0;s<6;++s){let l={rgb:[t[n],t[i],t[s]],class_name:'truecolor'};this.palette_256.push(l)}let n=8;for(let t=0;t<24;++t,n+=10){let t={rgb:[n,n,n],class_name:'truecolor'};this.palette_256.push(t)}}escape_txt_for_html(t){return this._escape_html?t.replace(/[&<>"']/gm,t=>"&"===t?"&amp;":"<"===t?"&lt;":">"===t?"&gt;":"\""===t?"&quot;":"'"===t?"&#x27;":void 0):t}append_buffer(t){var n=this._buffer+t;this._buffer=n}get_next_packet(){var r={kind:t.EOS,text:'',url:''},_=this._buffer.length;if(0==_)return r;var c=this._buffer.indexOf("\x1b");if(-1==c)return r.kind=t.Text,r.text=this._buffer,this._buffer='',r;if(c>0)return r.kind=t.Text,r.text=this._buffer.slice(0,c),this._buffer=this._buffer.slice(c),r;if(0==c){if(_<3)return r.kind=t.Incomplete,r;var u=this._buffer.charAt(1);if('['!=u&&']'!=u&&'('!=u)return r.kind=t.ESC,r.text=this._buffer.slice(0,1),this._buffer=this._buffer.slice(1),r;if('['==u){this._csi_regex||(this._csi_regex=h(n||(n=l(["\n ^ # beginning of line\n #\n # First attempt\n (?: # legal sequence\n \x1b[ # CSI\n ([<-?]?) # private-mode char\n ([d;]*) # any digits or semicolons\n ([ -/]? # an intermediate modifier\n [@-~]) # the command\n )\n | # alternate (second attempt)\n (?: # illegal sequence\n \x1b[ # CSI\n [ -~]* # anything legal\n ([\0-\x1f:]) # anything illegal\n )\n "],["\n ^ # beginning of line\n #\n # First attempt\n (?: # legal sequence\n \\x1b\\[ # CSI\n ([\\x3c-\\x3f]?) # private-mode char\n ([\\d;]*) # any digits or semicolons\n ([\\x20-\\x2f]? # an intermediate modifier\n [\\x40-\\x7e]) # the command\n )\n | # alternate (second attempt)\n (?: # illegal sequence\n \\x1b\\[ # CSI\n [\\x20-\\x7e]* # anything legal\n ([\\x00-\\x1f:]) # anything illegal\n )\n "]))));let i=this._buffer.match(this._csi_regex);if(null===i)return r.kind=t.Incomplete,r;if(i[4])return r.kind=t.ESC,r.text=this._buffer.slice(0,1),this._buffer=this._buffer.slice(1),r;''!=i[1]||'m'!=i[3]?r.kind=t.Unknown:r.kind=t.SGR,r.text=i[2];var o=i[0].length;return this._buffer=this._buffer.slice(o),r}if(']'==u){if(_<4)return r.kind=t.Incomplete,r;if('8'!=this._buffer.charAt(2)||';'!=this._buffer.charAt(3))return r.kind=t.ESC,r.text=this._buffer.slice(0,1),this._buffer=this._buffer.slice(1),r;this._osc_st||(this._osc_st=f(i||(i=l(["\n (?: # legal sequence\n (\x1b\\) # ESC | # alternate\n (\x07) # BEL (what xterm did)\n )\n | # alternate (second attempt)\n ( # illegal sequence\n [\0-\x06] # anything illegal\n | # alternate\n [\b-\x1a] # anything illegal\n | # alternate\n [\x1c-\x1f] # anything illegal\n )\n "],["\n (?: # legal sequence\n (\\x1b\\\\) # ESC \\\n | # alternate\n (\\x07) # BEL (what xterm did)\n )\n | # alternate (second attempt)\n ( # illegal sequence\n [\\x00-\\x06] # anything illegal\n | # alternate\n [\\x08-\\x1a] # anything illegal\n | # alternate\n [\\x1c-\\x1f] # anything illegal\n )\n "])))),this._osc_st.lastIndex=0;{let n=this._osc_st.exec(this._buffer);if(null===n)return r.kind=t.Incomplete,r;if(n[3])return r.kind=t.ESC,r.text=this._buffer.slice(0,1),this._buffer=this._buffer.slice(1),r}{let n=this._osc_st.exec(this._buffer);if(null===n)return r.kind=t.Incomplete,r;if(n[3])return r.kind=t.ESC,r.text=this._buffer.slice(0,1),this._buffer=this._buffer.slice(1),r}this._osc_regex||(this._osc_regex=h(s||(s=l(["\n ^ # beginning of line\n #\n \x1b]8; # OSC Hyperlink\n [ -:<-~]* # params (excluding ;)\n ; # end of params\n ([!-~]{0,512}) # URL capture\n (?: # ST\n (?:\x1b\\) # ESC | # alternate\n (?:\x07) # BEL (what xterm did)\n )\n ([ -~]+) # TEXT capture\n \x1b]8;; # OSC Hyperlink End\n (?: # ST\n (?:\x1b\\) # ESC | # alternate\n (?:\x07) # BEL (what xterm did)\n )\n "],["\n ^ # beginning of line\n #\n \\x1b\\]8; # OSC Hyperlink\n [\\x20-\\x3a\\x3c-\\x7e]* # params (excluding ;)\n ; # end of params\n ([\\x21-\\x7e]{0,512}) # URL capture\n (?: # ST\n (?:\\x1b\\\\) # ESC \\\n | # alternate\n (?:\\x07) # BEL (what xterm did)\n )\n ([\\x20-\\x7e]+) # TEXT capture\n \\x1b\\]8;; # OSC Hyperlink End\n (?: # ST\n (?:\\x1b\\\\) # ESC \\\n | # alternate\n (?:\\x07) # BEL (what xterm did)\n )\n "]))));let n=this._buffer.match(this._osc_regex);if(null===n)return r.kind=t.ESC,r.text=this._buffer.slice(0,1),this._buffer=this._buffer.slice(1),r;r.kind=t.OSCURL,r.url=n[1],r.text=n[2];o=n[0].length;return this._buffer=this._buffer.slice(o),r}if('('==u)return r.kind=t.Unknown,this._buffer=this._buffer.slice(3),r}}ansi_to_html(n){this.append_buffer(n);for(var i=[];;){var s=this.get_next_packet();if(s.kind==t.EOS||s.kind==t.Incomplete)break;s.kind!=t.ESC&&s.kind!=t.Unknown&&(s.kind==t.Text?i.push(this.transform_to_html(this.with_state(s))):s.kind==t.SGR?this.process_ansi(s):s.kind==t.OSCURL&&i.push(this.process_hyperlink(s)))}return i.join("")}with_state(t){return{bold:this.bold,faint:this.faint,italic:this.italic,underline:this.underline,fg:this.fg,bg:this.bg,text:t.text}}process_ansi(t){let n=t.text.split(';');for(;n.length>0;){let t=n.shift(),i=parseInt(t,10);if(isNaN(i)||0===i)this.fg=null,this.bg=null,this.bold=!1,this.faint=!1,this.italic=!1,this.underline=!1;else if(1===i)this.bold=!0;else if(2===i)this.faint=!0;else if(3===i)this.italic=!0;else if(4===i)this.underline=!0;else if(21===i)this.bold=!1;else if(22===i)this.faint=!1,this.bold=!1;else if(23===i)this.italic=!1;else if(24===i)this.underline=!1;else if(39===i)this.fg=null;else if(49===i)this.bg=null;else if(i>=30&&i<38)this.fg=this.ansi_colors[0][i-30];else if(i>=40&&i<48)this.bg=this.ansi_colors[0][i-40];else if(i>=90&&i<98)this.fg=this.ansi_colors[1][i-90];else if(i>=100&&i<108)this.bg=this.ansi_colors[1][i-100];else if((38===i||48===i)&&n.length>0){let t=38===i,s=n.shift();if('5'===s&&n.length>0){let i=parseInt(n.shift(),10);i>=0&&i<=255&&(t?this.fg=this.palette_256[i]:this.bg=this.palette_256[i])}if('2'===s&&n.length>2){let i=parseInt(n.shift(),10),s=parseInt(n.shift(),10),l=parseInt(n.shift(),10);if(i>=0&&i<=255&&s>=0&&s<=255&&l>=0&&l<=255){let n={rgb:[i,s,l],class_name:'truecolor'};t?this.fg=n:this.bg=n}}}}}transform_to_html(t){let n=t.text;if(0===n.length)return n;if(n=this.escape_txt_for_html(n),!(t.bold||t.italic||t.faint||t.underline||null!==t.fg||null!==t.bg))return n;let i=[],s=[],l=t.fg,r=t.bg;t.bold&&i.push(this._boldStyle),t.faint&&i.push(this._faintStyle),t.italic&&i.push(this._italicStyle),t.underline&&i.push(this._underlineStyle),this._use_classes?(l&&('truecolor'!==l.class_name?s.push(`${l.class_name}-fg`):i.push(`color:rgb(${l.rgb.join(',')})`)),r&&('truecolor'!==r.class_name?s.push(`${r.class_name}-bg`):i.push(`background-color:rgb(${r.rgb.join(',')})`))):(l&&i.push(`color:rgb(${l.rgb.join(',')})`),r&&i.push(`background-color:rgb(${r.rgb})`));let h='',f='';return s.length&&(h=` class="${s.join(' ')}"`),i.length&&(f=` style="${i.join(';')}"`),`<span${f}${h}>${n}</span>`}process_hyperlink(t){let n=t.url.split(':');return n.length<1?'':this._url_allowlist[n[0]]?`<a href="${this.escape_txt_for_html(t.url)}">${this.escape_txt_for_html(t.text)}</a>`:''}}function h(t,...n){let i=t.raw[0].replace(/^\s+|\s+\n|\s*#[\s\S]*?\n|\n/gm,'');return new RegExp(i)}function f(t,...n){let i=t.raw[0].replace(/^\s+|\s+\n|\s*#[\s\S]*?\n|\n/gm,'');return new RegExp(i,'g')}},763,[]);
867
+ __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"BLOCK_GLYPH_RE",{enumerable:!0,get:function(){return s}}),e.blockGlyphClass=$,e.paintBlockGlyphs=function(t){return p.test(t)?t.replace(s,t=>`<span class="tb ${$(t.charCodeAt(0))}">${t}</span>`):t},e.blockGlyphStylesheet=function(t){const n=[`.tb{display:inline-block;width:1ch;height:${t}em;overflow:hidden;vertical-align:top;-webkit-text-fill-color:transparent}`];for(const[t,o]of Object.entries(l))n.push(`.${$(+t)}{background:${o}}`);return n.join("\n")};const t="currentColor",n="transparent";function o(o,c){const l=+(100*c).toFixed(4)+"%";return`linear-gradient(to ${o},${t} ${l},${n} ${l})`}function c(o,c,l,s){const p=o=>o?t:n;return`conic-gradient(at 50% 50%,${p(o)} 0 25%,${p(c)} 0 50%,${p(l)} 0 75%,${p(s)} 0)`}const l={9600:o("bottom",.5),9601:o("top",.125),9602:o("top",.25),9603:o("top",.375),9604:o("top",.5),9605:o("top",.625),9606:o("top",.75),9607:o("top",.875),9608:t,9609:o("right",.875),9610:o("right",.75),9611:o("right",.625),9612:o("right",.5),9613:o("right",.375),9614:o("right",.25),9615:o("right",.125),9616:o("left",.5),9617:`color-mix(in srgb,${t} 25%,${n})`,9618:`color-mix(in srgb,${t} 50%,${n})`,9619:`color-mix(in srgb,${t} 75%,${n})`,9620:o("bottom",.125),9621:o("left",.125),9622:c(!1,!1,!0,!1),9623:c(!1,!0,!1,!1),9624:c(!1,!1,!1,!0),9625:c(!1,!0,!0,!0),9626:c(!1,!0,!1,!0),9627:c(!0,!1,!0,!0),9628:c(!0,!0,!1,!0),9629:c(!0,!1,!1,!1),9630:c(!0,!1,!0,!1),9631:c(!0,!0,!0,!1)},s=/[\u2580-\u259f]/g,p=/[\u2580-\u259f]/;function $(t){return`tb-${t.toString(16)}`}},764,[]);
868
868
  __d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return u}});var t=r(d[0]),e=r(d[1]);const l=[[{label:"`",shiftLabel:"~",tmux:"`",shiftTmux:"~"},{label:"1",shiftLabel:"!",tmux:"1",shiftTmux:"!"},{label:"2",shiftLabel:"@",tmux:"2",shiftTmux:"@"},{label:"3",shiftLabel:"#",tmux:"3",shiftTmux:"#"},{label:"4",shiftLabel:"$",tmux:"4",shiftTmux:"$"},{label:"5",shiftLabel:"%",tmux:"5",shiftTmux:"%"},{label:"6",shiftLabel:"^",tmux:"6",shiftTmux:"^"},{label:"7",shiftLabel:"&",tmux:"7",shiftTmux:"&"},{label:"8",shiftLabel:"*",tmux:"8",shiftTmux:"*"},{label:"9",shiftLabel:"(",tmux:"9",shiftTmux:"("},{label:"0",shiftLabel:")",tmux:"0",shiftTmux:")"},{label:"-",shiftLabel:"_",tmux:"-",shiftTmux:"_"},{label:"=",shiftLabel:"+",tmux:"=",shiftTmux:"+"},{label:"\u232b",tmux:"BSpace"}],[{label:"q",tmux:"q",shiftTmux:"Q"},{label:"w",tmux:"w",shiftTmux:"W"},{label:"e",tmux:"e",shiftTmux:"E"},{label:"r",tmux:"r",shiftTmux:"R"},{label:"t",tmux:"t",shiftTmux:"T"},{label:"y",tmux:"y",shiftTmux:"Y"},{label:"u",tmux:"u",shiftTmux:"U"},{label:"i",tmux:"i",shiftTmux:"I"},{label:"o",tmux:"o",shiftTmux:"O"},{label:"p",tmux:"p",shiftTmux:"P"},{label:"[",shiftLabel:"{",tmux:"[",shiftTmux:"{"},{label:"]",shiftLabel:"}",tmux:"]",shiftTmux:"}"}],[{label:"a",tmux:"a",shiftTmux:"A"},{label:"s",tmux:"s",shiftTmux:"S"},{label:"d",tmux:"d",shiftTmux:"D"},{label:"f",tmux:"f",shiftTmux:"F"},{label:"g",tmux:"g",shiftTmux:"G"},{label:"h",tmux:"h",shiftTmux:"H"},{label:"j",tmux:"j",shiftTmux:"J"},{label:"k",tmux:"k",shiftTmux:"K"},{label:"l",tmux:"l",shiftTmux:"L"},{label:";",shiftLabel:":",tmux:";",shiftTmux:":"},{label:"'",shiftLabel:'"',tmux:"'",shiftTmux:'"'},{label:"\\",shiftLabel:"|",tmux:"\\",shiftTmux:"|"}],[{label:"Shift",tmux:"",type:"shift",width:1.8},{label:"z",tmux:"z",shiftTmux:"Z"},{label:"x",tmux:"x",shiftTmux:"X"},{label:"c",tmux:"c",shiftTmux:"C"},{label:"v",tmux:"v",shiftTmux:"V"},{label:"b",tmux:"b",shiftTmux:"B"},{label:"n",tmux:"n",shiftTmux:"N"},{label:"m",tmux:"m",shiftTmux:"M"},{label:",",shiftLabel:"<",tmux:",",shiftTmux:"<"},{label:".",shiftLabel:">",tmux:".",shiftTmux:">"},{label:"/",shiftLabel:"?",tmux:"/",shiftTmux:"?"}],[{label:"Ctrl",tmux:"",type:"ctrl",width:1.4},{label:"Alt",tmux:"",type:"alt",width:1.2},{label:"Tab",tmux:"Tab",width:1.2},{label:"",tmux:"Space",width:4},{label:"\u2190",tmux:"Left"},{label:"\u2193",tmux:"Down"},{label:"\u2191",tmux:"Up"},{label:"\u2192",tmux:"Right"}]];function u({sendKeys:u}){const s=(0,t.useRef)({shift:!1,ctrl:!1,alt:!1}),[x,f]=(0,t.useState)({shift:!1,ctrl:!1,alt:!1}),[h,b]=(0,t.useState)(null),n=(0,t.useRef)(null),o=(0,t.useRef)(!1),c=(0,t.useCallback)(t=>{s.current[t]=!s.current[t],f(Object.assign({},s.current))},[]),T=(0,t.useCallback)(t=>{const{shift:e,ctrl:l,alt:x}=s.current;let f=e&&t.shiftTmux?t.shiftTmux:t.tmux;l&&1===f.length&&/[a-zA-Z]/.test(f)?u(`C-${f.toLowerCase()}`):x&&1===f.length?u(`M-${f.toLowerCase()}`):u(f)},[u]),p=(t,l,u)=>{const s="shift"===t.type||"ctrl"===t.type||"alt"===t.type,f=s&&x[t.type];let p;p=s?t.label:x.shift?t.shiftLabel||(1===t.label.length?t.label.toUpperCase():t.label):t.label;const L=`${l}-${u}`,y=h===L,w=()=>{s?c(t.type):(T(t),n.current&&clearTimeout(n.current),b(L),n.current=setTimeout(()=>b(null),180))};return(0,e.jsx)("div",{onTouchStart:t=>{t.preventDefault(),o.current=!0,w()},onMouseDown:t=>{t.preventDefault(),o.current?o.current=!1:w()},style:{flex:t.width||1,height:"min(36px, 6vh)",display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:f?"#2e7d32":y?"#4444cc":"#2a2a2a",border:"1px solid "+(f?"#4caf50":y?"#7c7cff":"#3a3a3a"),borderRadius:4,boxShadow:y?"0 0 8px rgba(120, 120, 255, 0.8)":"none",cursor:"pointer",userSelect:"none",WebkitUserSelect:"none",touchAction:"manipulation",transition:"background-color 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease"},children:(0,e.jsx)("span",{style:{color:f||y?"#fff":"#ccc",fontSize:s||t.tmux.length>1?11:14,fontFamily:"monospace",fontWeight:s?"600":"400",pointerEvents:"none"},children:p})},L)};return(0,e.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:"min(3px, 0.5vh)",padding:"min(4px, 0.6vh) 3px",backgroundColor:"#1a1a1a",borderTop:"1px solid rgb(216, 216, 216)",flexShrink:0},children:l.map((t,l)=>(0,e.jsx)("div",{style:{display:"flex",flexDirection:"row",gap:"min(3px, 0.5vh)"},children:t.map((t,e)=>p(t,l,e))},l))})}},765,[11,6]);
869
869
  __d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return u}});var e,o=r(d[0]),t=r(d[1]),n=(e=t)&&e.__esModule?e:{default:e},l=r(d[2]);const c=[{label:"live loop",text:"live loop\n"},{label:"live loop (full)",text:"Use your brane MCP server's read_protocol tool to read the 'LIVE_loop' protocol, then commence LIVE looping. All LIVE loop tools (narrate, listen, whoami, etc.) come from the brane MCP server.\n"},{label:"narrate more",text:"narrate more per LIVE loop protocol\n"},{label:"continue if unblocked",text:"continue if unblocked\n"},{label:"/ramify",text:"/ramify\n"}];function u({onSelect:e}){const[u,s]=(0,o.useState)(!1),p=(0,o.useRef)(null);return(0,o.useEffect)(()=>{if(!u)return;const e=e=>{p.current&&!p.current.contains(e.target)&&s(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[u]),(0,l.jsxs)("div",{ref:p,style:{position:"relative"},children:[(0,l.jsx)("button",{onClick:()=>s(e=>!e),style:{padding:"6px 8px",borderRadius:6,border:"1px solid "+(u?"rgba(255,120,90,0.9)":"#555"),backgroundColor:u?"#6e2f24":"#252525",color:u?"#fff":"#ccc",fontSize:14,lineHeight:"18px",fontFamily:"monospace",cursor:"pointer",whiteSpace:"nowrap"},children:"\ud83e\udd6b\u25be"}),u&&(0,l.jsx)(n.default,{hue:"tomato",style:{bottom:"calc(100% + 4px)",left:0,padding:4,display:"flex",flexDirection:"column",gap:2,minWidth:180},children:c.map(o=>(0,l.jsx)("button",{onClick:()=>{e(o),s(!1)},style:{padding:"10px 14px",borderRadius:6,border:"none",backgroundColor:"transparent",color:"#ccc",fontSize:14,fontFamily:"monospace",cursor:"pointer",textAlign:"left",whiteSpace:"nowrap"},onMouseEnter:e=>{e.target.style.backgroundColor=`rgba(${(0,t.menuHueRgb)("tomato")}, 0.18)`},onMouseLeave:e=>{e.target.style.backgroundColor="transparent"},children:o.label},o.label))})]})}},766,[11,767,6]);
870
870
  __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return u}}),e.menuHueRgb=function(n){return t[n]};var n=r(d[0]),o=r(d[1]);const t={green:"140, 230, 170",tomato:"255, 120, 90",blue:"120, 190, 255",grey:"170, 175, 180"},b={green:"rgba(34,50,42,0.75)",tomato:"rgba(58,30,26,0.75)",blue:"rgba(26,38,60,0.75)",grey:"rgba(40,42,46,0.75)"};var u=(0,n.forwardRef)(function({hue:n,style:u,children:s},c){const l=t[n];return(0,o.jsx)("div",{ref:c,style:Object.assign({position:"absolute",backgroundColor:b[n],border:`1px solid rgba(${l}, 0.4)`,borderRadius:8,zIndex:100,boxShadow:["0 6px 20px rgba(0,0,0,0.45)",`0 4px 14px rgba(${l}, 0.5)`,`0 0 24px rgba(${l}, 0.32)`,`0 0 50px rgba(${l}, 0.18)`].join(", ")},u),children:s})})},767,[11,6]);
871
- __d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return u}});var e,o=r(d[0]),t=r(d[1]),n=(e=t)&&e.__esModule?e:{default:e},l=r(d[2]);const s=[{code:"^C",emoji:"\ud83d\uded1",label:"cancel / interrupt",keys:"C-c"},{code:"^O",emoji:"\ud83e\ude97",label:"verbose transcript",action:"transcript"},{code:"^T",emoji:"\u2705",label:"toggle todos",keys:"C-t"},{code:"^V",emoji:"\ud83d\udccb",label:"paste clipboard",action:"paste"},{code:"\u21e7\u21e5",emoji:"\ud83d\udea6",label:"cycle permission mode",keys:"BTab"},{code:"^B",emoji:"\ud83d\ude36\u200d\ud83c\udf2b\ufe0f",label:"background task",keys:"C-b"},{code:"^D",emoji:"\ud83e\ude82",label:"exit (EOF on empty input)",keys:"C-d"},{code:"^J",emoji:"\u21a9\ufe0f",label:"newline without submitting",keys:"C-j"},{code:"^L",emoji:"\ud83e\uddf9",label:"clear / redraw",keys:"C-l"}],c=[{code:"Home",emoji:"\u23eb",label:"jump to top",keys:"C-Home"},{code:"\xa0End",emoji:"\u23ec",label:"jump to bottom",keys:"C-End"},{code:"Page",emoji:"\u2b06\ufe0f",label:"page up",keys:"PPage"},{code:"Page",emoji:"\u2b07\ufe0f",label:"page down",keys:"NPage"}];function u({onControl:e}){const[u,p]=(0,o.useState)(!1),b=(0,o.useRef)(null);(0,o.useEffect)(()=>{if(!u)return;const e=e=>{b.current&&!b.current.contains(e.target)&&p(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[u]);const y=o=>(0,l.jsxs)("button",{title:o.label,onClick:()=>{"paste"===o.action&&p(!1),e(o)},style:{display:"inline-flex",flexDirection:"row",alignItems:"center",justifyContent:"center",minWidth:0,gap:5,padding:"7px 8px",borderRadius:6,border:"none",backgroundColor:"transparent",color:"#e0e0e0",fontSize:13,lineHeight:"16px",fontFamily:"monospace",cursor:"pointer",whiteSpace:"nowrap"},onMouseEnter:e=>{e.currentTarget.style.backgroundColor=`rgba(${(0,t.menuHueRgb)("blue")}, 0.2)`},onMouseLeave:e=>{e.currentTarget.style.backgroundColor="transparent"},children:[(0,l.jsx)("span",{children:o.code}),(0,l.jsx)("span",{style:{fontSize:14},children:o.emoji})]},o.label);return(0,l.jsxs)("div",{ref:b,style:{position:"relative"},children:[(0,l.jsx)("button",{onClick:()=>p(e=>!e),style:{padding:"6px 8px",borderRadius:6,border:"1px solid "+(u?"rgba(120,190,255,0.9)":"#555"),backgroundColor:u?"#27496f":"#252525",color:u?"#fff":"#ccc",fontSize:14,lineHeight:"18px",fontFamily:"monospace",cursor:"pointer",whiteSpace:"nowrap"},children:"\ud83e\uddbe\u25be"}),u&&(0,l.jsxs)(n.default,{hue:"blue",style:{bottom:"calc(100% + 4px)",left:0,padding:8,display:"flex",flexDirection:"column",gap:8,width:220,maxWidth:"92vw"},children:[(0,l.jsx)("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:6},children:s.map(y)}),(0,l.jsx)("div",{style:{height:1,backgroundColor:`rgba(${(0,t.menuHueRgb)("blue")}, 0.25)`}}),(0,l.jsx)("div",{style:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:6},children:c.map(y)})]})]})}},768,[11,767,6]);
871
+ __d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return p}});var e,o=r(d[0]),t=r(d[1]),n=(e=t)&&e.__esModule?e:{default:e},l=r(d[2]);const s=[{code:"^C",emoji:"\ud83d\uded1",label:"cancel / interrupt",keys:"C-c"},{code:"^O",emoji:"\ud83e\ude97",label:"verbose transcript",action:"transcript"},{code:"^T",emoji:"\u2705",label:"toggle todos",keys:"C-t"},{code:"^V",emoji:"\ud83d\udccb",label:"paste clipboard",action:"paste"},{code:"\u21e7\u21e5",emoji:"\ud83d\udea6",label:"cycle permission mode",keys:"BTab"},{code:"^B",emoji:"\ud83d\ude36\u200d\ud83c\udf2b\ufe0f",label:"background task",keys:"C-b"},{code:"^D",emoji:"\ud83e\ude82",label:"exit (EOF on empty input)",keys:"C-d"},{code:"^J",emoji:"\u21a9\ufe0f",label:"newline without submitting",keys:"C-j"},{code:"^L",emoji:"\ud83e\uddf9",label:"clear / redraw",keys:"C-l"}],c=[{code:"Home",emoji:"\u23eb",label:"jump to top",keys:"C-Home"},{code:"\xa0End",emoji:"\u23ec",label:"jump to bottom",keys:"C-End"},{code:"Page",emoji:"\u2b06\ufe0f",label:"page up",keys:"PPage"},{code:"Page",emoji:"\u2b07\ufe0f",label:"page down",keys:"NPage"}],u={code:"Clear",emoji:"\ud83e\uddfd",label:"clear scrollback (keeps the screen)",action:"clear-history"};function p({onControl:e}){const[p,b]=(0,o.useState)(!1),y=(0,o.useRef)(null);(0,o.useEffect)(()=>{if(!p)return;const e=e=>{y.current&&!y.current.contains(e.target)&&b(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[p]);const j=o=>(0,l.jsxs)("button",{title:o.label,onClick:()=>{"paste"!==o.action&&"clear-history"!==o.action||b(!1),e(o)},style:{display:"inline-flex",flexDirection:"row",alignItems:"center",justifyContent:"center",minWidth:0,gap:5,padding:"7px 8px",borderRadius:6,border:"none",backgroundColor:"transparent",color:"#e0e0e0",fontSize:13,lineHeight:"16px",fontFamily:"monospace",cursor:"pointer",whiteSpace:"nowrap"},onMouseEnter:e=>{e.currentTarget.style.backgroundColor=`rgba(${(0,t.menuHueRgb)("blue")}, 0.2)`},onMouseLeave:e=>{e.currentTarget.style.backgroundColor="transparent"},children:[(0,l.jsx)("span",{children:o.code}),(0,l.jsx)("span",{style:{fontSize:14},children:o.emoji})]},o.label);return(0,l.jsxs)("div",{ref:y,style:{position:"relative"},children:[(0,l.jsx)("button",{onClick:()=>b(e=>!e),style:{padding:"6px 8px",borderRadius:6,border:"1px solid "+(p?"rgba(120,190,255,0.9)":"#555"),backgroundColor:p?"#27496f":"#252525",color:p?"#fff":"#ccc",fontSize:14,lineHeight:"18px",fontFamily:"monospace",cursor:"pointer",whiteSpace:"nowrap"},children:"\ud83e\uddbe\u25be"}),p&&(0,l.jsxs)(n.default,{hue:"blue",style:{bottom:"calc(100% + 4px)",left:0,padding:8,display:"flex",flexDirection:"column",gap:8,width:220,maxWidth:"92vw"},children:[(0,l.jsx)("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:6},children:s.map(j)}),(0,l.jsx)("div",{style:{height:1,backgroundColor:`rgba(${(0,t.menuHueRgb)("blue")}, 0.25)`}}),(0,l.jsx)("div",{style:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:6},children:c.map(j)}),(0,l.jsx)("div",{style:{height:1,backgroundColor:`rgba(${(0,t.menuHueRgb)("blue")}, 0.25)`}}),(0,l.jsx)("div",{style:{display:"grid"},children:j(u)})]})]})}},768,[11,767,6]);
872
872
  __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"revivesAsTwin",{enumerable:!0,get:function(){return o.revivesAsTwin}}),e.narrativeMenuItems=function(t){return(0,o.narrativeMenuItems)(t)},e.openNarrativeExport=async function(o,c,s,u="only"){try{const l=await(0,t.fetchNarrativeExportHtml)(o,c,(0,n.readRecolorSalt)(c),s,u);window.open(URL.createObjectURL(l),"_blank")}catch(t){console.error("Export failed:",t)}};var t=r(d[0]),n=r(d[1]),o=r(d[2])},769,[745,770,772]);
873
873
  __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.readRecolorSalt=o,e.bumpRecolorSalt=function(c){const l=o(c)+1;try{localStorage.setItem((0,t.recolorStorageKey)(c),String(l))}catch{}return l};var t=r(d[0]);function o(o){try{return(0,t.parseRecolorSalt)(localStorage.getItem((0,t.recolorStorageKey)(o)))}catch{return 0}}},770,[771]);
874
874
  __d(function(g,r,_i,a,m,e,d){"use strict";function t(t){let n=0;for(let o=0;o<t.length;o++)n=t.charCodeAt(o)+((n<<5)-n);return n}function n(n,o=0){let u=t(n);var l;return o&&(l=u^Math.imul(o,2654435761),l^=l>>>16,l=Math.imul(l,2246822507),l^=l>>>13,l=Math.imul(l,3266489909),u=0|(l^=l>>>16)),Math.abs(u)%360}Object.defineProperty(e,'__esModule',{value:!0}),e.speakerHue=n,e.speakerColor=function(t,o=0){return`hsl(${n(t,o)}, 60%, 80%)`},e.speakerBgColor=function(t,o=0){return`hsl(${n(t,o)}, 30%, 20%)`},e.recolorStorageKey=function(t){return`brane:recolor:${t}`},e.parseRecolorSalt=function(t){const n=Number(t);return Number.isInteger(n)&&n>0?n:0}},771,[]);
875
- __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.revivesAsTwin=function(n){return"external"===n||"absorbed"===n},e.narrativeMenuItems=function({role:n,status:o,mcpConnected:l,archived:s=!1,isIsolated:c=!1,selectedCount:t=0,onMeld:b,onIsolate:u,onExport:v,onRecolor:P,onTwin:x,onRevive:p,onEnd:E,onArchiveToggle:f}){const h="ended"===o&&!l;return[{icon:"\ud83d\udd96",label:"Meld",onPress:b},{icon:c?"\ud83c\udfd8\ufe0f":"\ud83c\udfe0",label:c?"Unisolate":"Isolate",onPress:u},...t>0?[{icon:"\ud83d\udce8",label:`Export ${t} selected`,onPress:()=>v("selected")},{icon:"\ud83d\udce4",label:`Export ${t} excluded`,onPress:()=>v("excluded")}]:[{icon:"\ud83d\udce8",label:"Export",onPress:()=>v("all")}],{icon:"\ud83c\udfa8",label:"Recolor",onPress:P},{icon:"\ud83e\uddec",label:"Twin",onPress:x},..."external"===n?[]:[h?{icon:"\ud83d\udc26\u200d\ud83d\udd25",label:"Revive",onPress:p}:{icon:"\ud83e\udee0",label:"End",onPress:E}],{icon:s?"\ud83d\udcc2":"\ud83d\uddc4\ufe0f",label:s?"Unarchive":"Archive",onPress:f}]}},772,[]);
875
+ __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.revivesAsTwin=function(n){return"external"===n||"absorbed"===n},e.narrativeMenuItems=function({role:n,status:o,mcpConnected:l,archived:s=!1,isIsolated:c=!1,canIsolate:t=!0,selectedCount:b=0,onMeld:u,onIsolate:v,onExport:P,onRecolor:x,onTwin:p,onRevive:E,onEnd:I,onArchiveToggle:f}){const h="ended"===o&&!l;return[{icon:"\ud83d\udd96",label:"Meld",onPress:u},...t?[{icon:c?"\ud83c\udfd8\ufe0f":"\ud83c\udfe0",label:c?"Unisolate":"Isolate",onPress:v}]:[],...b>0?[{icon:"\ud83d\udce8",label:`Export ${b} selected`,onPress:()=>P("selected")},{icon:"\ud83d\udce4",label:`Export ${b} excluded`,onPress:()=>P("excluded")}]:[{icon:"\ud83d\udce8",label:"Export",onPress:()=>P("all")}],{icon:"\ud83c\udfa8",label:"Recolor",onPress:x},{icon:"\ud83e\uddec",label:"Twin",onPress:p},..."external"===n?[]:[h?{icon:"\ud83d\udc26\u200d\ud83d\udd25",label:"Revive",onPress:E}:{icon:"\ud83e\udee0",label:"End",onPress:I}],{icon:s?"\ud83d\udcc2":"\ud83d\uddc4\ufe0f",label:s?"Unarchive":"Archive",onPress:f}]}},772,[]);
876
876
  __d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return s}});var e,n=r(d[0]),t=r(d[1]),o=(e=t)&&e.__esModule?e:{default:e},l=r(d[2]);function s({items:e,onClose:s,align:c="below",hue:u="green"}){const p=(0,n.useRef)(null);return(0,n.useEffect)(()=>{const e=e=>{p.current&&!p.current.contains(e.target)&&(e.preventDefault(),e.stopPropagation(),document.addEventListener("click",e=>{e.preventDefault(),e.stopPropagation()},{capture:!0,once:!0}),s())};return document.addEventListener("mousedown",e,!0),()=>document.removeEventListener("mousedown",e,!0)},[s]),(0,l.jsx)(o.default,{ref:p,hue:u,style:{right:16,top:"beside"===c?"50%":"calc(100% + 4px)",transform:"beside"===c?"translateY(-50%)":void 0,padding:4,display:"flex",flexDirection:"column",gap:2,minWidth:120},children:e.map(e=>(0,l.jsxs)("button",{onClick:n=>{n.stopPropagation(),e.onPress()},style:{padding:"10px 14px",borderRadius:6,border:"none",backgroundColor:"transparent",color:"#ccc",fontSize:15,lineHeight:"21px",cursor:"pointer",textAlign:"left",whiteSpace:"nowrap",display:"flex",alignItems:"center",gap:10},onPointerEnter:e=>{e.currentTarget.style.backgroundColor=`rgba(${(0,t.menuHueRgb)(u)}, 0.18)`},onPointerLeave:e=>{e.currentTarget.style.backgroundColor="transparent"},children:[e.icon?(0,l.jsx)("span",{style:{fontSize:20,lineHeight:"20px"},children:e.icon}):null,(0,l.jsx)("span",{children:e.label})]},e.label))})}},773,[11,767,6]);
877
877
  __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MessageSelection",{enumerable:!0,get:function(){return n.MessageSelection}}),e.useMessageSelection=function(s){return(0,t.useMemo)(()=>new n.MessageSelection,[s])},e.useIsSelected=function(n,s){const c=(0,t.useCallback)(t=>n.subscribeSeq(s,t),[n,s]),u=(0,t.useCallback)(()=>n.has(s),[n,s]);return(0,t.useSyncExternalStore)(c,u,u)},e.useSelectedSeqs=function(n){return(0,t.useSyncExternalStore)(n.subscribe,n.getSelected,n.getSelected)};var t=r(d[0]),n=r(d[1])},774,[11,775]);
878
878
  __d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MessageSelection",{enumerable:!0,get:function(){return s}});const t=Object.freeze([]);class s{selected=new Set;snapshot=t;perSeq=new Map;whole=new Set;has=t=>this.selected.has(t);get size(){return this.selected.size}getSelected=()=>this.snapshot;subscribe=t=>(this.whole.add(t),()=>{this.whole.delete(t)});subscribeSeq=(t,s)=>{let c=this.perSeq.get(t);return c||(c=new Set,this.perSeq.set(t,c)),c.add(s),()=>{const c=this.perSeq.get(t);c&&(c.delete(s),0===c.size&&this.perSeq.delete(t))}};toggle=t=>{const s=!this.selected.has(t);return s?this.selected.add(t):this.selected.delete(t),this.commit([t]),s};clear=()=>{if(0===this.selected.size)return[];const t=[...this.selected];return this.selected.clear(),this.commit(t),t};replace=t=>{const s=new Set;for(const c of t)Number.isInteger(c)&&c>0&&s.add(c);const c=[];for(const t of this.selected)s.has(t)||c.push(t);for(const t of s)this.selected.has(t)||c.push(t);0!==c.length&&(this.selected=s,this.commit(c))};commit(s){this.snapshot=0===this.selected.size?t:[...this.selected].sort((t,s)=>t-s);for(const t of s){const s=this.perSeq.get(t);if(s)for(const t of[...s])t()}for(const t of[...this.whole])t()}}},775,[]);
879
879
  __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.glowHueFor=function(o){return t.hueFor(o)},e.recolorGlowHue=function(o){return t.recolor(o)};const t=new(r(d[0]).GlowHues)({getItem:t=>localStorage.getItem(t),setItem:(t,o)=>localStorage.setItem(t,o)})},776,[777]);
880
880
  __d(function(_g,_r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"GLOW_HUES_STORAGE_KEY",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"RECENT_MS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"RECENT_LIMIT",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"MIN_RECOLOR_STEP",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"RECOLOR_CLEARANCE",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"RECOLOR_CLEARANCE_MIN",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"REJECTED_MS",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"REJECTED_LIMIT",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"REJECTED_CLEARANCE",{enumerable:!0,get:function(){return h}}),e.hueDistance=f,e.gapMidpoints=l,e.parseGlowAssignments=m,e.takenHues=b,e.firstHue=p,e.recolorHue=g,Object.defineProperty(e,"GlowHues",{enumerable:!0,get:function(){return O}});var t=_r(_d[0]);const r="brane:glow-hues",n=6048e5,i=12,u=100,s=.5,o=.25,c=36e5,a=4,h=60;function f(t,r){const n=Math.abs(t-r)%360;return Math.min(n,360-n)}const d=t=>(Math.round(t)%360+360)%360;function l(t){const r=[...new Set(t.map(d))].sort((t,r)=>t-r);if(0===r.length)return[];return r.map((t,n)=>{const i=(n+1<r.length?r[n+1]:r[0]+360)-t;return{width:i,mid:d(t+i/2)}}).map((t,r)=>Object.assign({},t,{i:r})).sort((t,r)=>r.width-t.width||t.i-r.i).map(t=>t.mid)}function m(t){if(!t)return{};try{const r=JSON.parse(t);if(!r||"object"!=typeof r||Array.isArray(r))return{};const n={};for(const[t,i]of Object.entries(r)){const r=i;if(r&&Number.isFinite(r.hue)&&Number.isFinite(r.seen)){n[t]={hue:d(r.hue),seen:r.seen};const i=Array.isArray(r.rejected)?r.rejected.filter(t=>t&&Number.isFinite(t.hue)&&Number.isFinite(t.at)):[];i.length&&(n[t].rejected=i.map(t=>({hue:d(t.hue),at:t.at})))}}return n}catch{return{}}}function b(t,r,u){return Object.entries(t).filter(([t,i])=>t!==r&&u-i.seen<=n).sort((t,r)=>r[1].seen-t[1].seen).slice(0,i).map(([,t])=>t.hue)}function p(r,n){return l(n)[0]??(0,t.speakerHue)(r)}function E(t,r){return r.reduce((r,n)=>Math.min(r,f(t,n)),180)}function g(t,r,n={}){const{rejected:i=[],random:c=Math.random}=n,a=[...new Set(r.map(d))],m=i.map(d),b=a.length?l(a).reduce((t,r)=>Math.max(t,E(r,a)),0):180,p=t=>{const r=[];for(let n=0;n<360;n++)E(n,a)>=b*t&&r.push(n);return r},g=p(s),O=p(o),j=r=>r.filter(r=>f(r,t)>=u),y=(t,r)=>t.filter(t=>E(t,m.slice(0,r))>=h),M=[];for(let t=m.length;t>0;t--)M.push(y(j(g),t),y(j(O),t));M.push(j(g),j(O),g.filter(r=>r!==d(t)));const _=M.find(t=>t.length>0);return _?_[Math.min(_.length-1,Math.floor(c()*_.length))]:l([...a,t])[0]}class O{constructor(t,r=Date.now,n=Math.random){this.store=t,this.now=r,this.random=n}read(){try{return m(this.store.getItem(r))}catch{return{}}}write(t){try{this.store.setItem(r,JSON.stringify(t))}catch{}}hueFor(t){const r=this.read(),n=this.now(),i=r[t];if(i)return n-i.seen>=6e4&&(r[t]=Object.assign({},i,{seen:n}),this.write(r)),i.hue;const u=p(t,b(r,t,n));return r[t]={hue:u,seen:n},this.write(r),u}recolor(r){const n=this.read(),i=this.now(),u=n[r]?.hue??(0,t.speakerHue)(r),s=[{hue:u,at:i},...n[r]?.rejected??[]].filter(t=>i-t.at<=c).slice(0,a),o=g(u,b(n,r,i),{rejected:s.map(t=>t.hue),random:this.random});return n[r]={hue:o,seen:i,rejected:s},this.write(n),o}}},777,[771]);
881
- __d(function(g,r,i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"formatActivitySpan",{enumerable:!0,get:function(){return u.formatActivitySpan}}),_e.useActivitySpan=S,_e.NarrativeMetaLine=function({role:e,cost:t,createdAt:o,lastActivity:s,status:u,mcpConnected:c,dimmed:y=!1,style:h}){const b="ended"!==u||c?c?"#66d9a0":"#5b9bd5":"#666",x=y?"#666":"#d8d8dd",p=y?"#555":"#888",j=y?"#5a6a60":"#7bb894",v=S(o,s);return(0,f.jsxs)(n.default,{style:[w.row,h],children:[(0,f.jsx)(n.default,{style:[w.dot,{backgroundColor:b}]}),(0,f.jsxs)(l.default,{style:w.meta,numberOfLines:1,children:[t?(0,f.jsx)(l.default,{style:{color:j},children:t}):null,e?(0,f.jsxs)(l.default,{style:{color:x},children:[t?" ":"","/",e]}):null,null!=v?(0,f.jsxs)(l.default,{style:{color:p},children:[t||e?" ":"","from ",v]}):null]})]})},_e.NarrativeIdentity=function({id:e,foldPath:t,titleStyle:o,align:u="baseline",copyMarginLeft:c=6,dimmed:y=!1,style:h}){return(0,f.jsxs)(n.default,{style:[{flexDirection:"row",alignItems:u,minWidth:0},h],children:[(0,f.jsx)(l.default,{style:[w.nid,o],numberOfLines:1,children:e}),(0,f.jsx)(s.default,{text:e,size:13,padding:0,marginLeft:c}),t?(0,f.jsxs)(l.default,{style:w.fold,numberOfLines:1,children:[(0,f.jsx)(l.default,{style:{color:y?"#555":"#888"},children:"in "}),(0,f.jsx)(l.default,{style:{color:y?"#4a5a50":"#5e8a72"},children:t})]}):null]})};var t=r(d[0]),n=e(r(d[1])),l=e(r(d[2])),o=e(r(d[3])),s=e(r(d[4])),u=r(d[5]),f=r(d[6]);const c=1e3,y=6e4,h=36e5,b=new Map;let x=!1;function p(e,t){x||"undefined"==typeof document||(x=!0,document.addEventListener("visibilitychange",()=>{if(!document.hidden)for(const e of b.values())for(const t of e.subs)t()}));let n=b.get(e);n||(n={timer:null,subs:new Set},b.set(e,n));const l=n;return l.subs.add(t),l.timer||(l.timer=setInterval(()=>{if("undefined"==typeof document||!document.hidden)for(const e of l.subs)e()},e)),()=>{l.subs.delete(t),0===l.subs.size&&l.timer&&(clearInterval(l.timer),l.timer=null,b.delete(e))}}function j(e){const t=Math.floor((Date.now()-e)/1e3);return t<60?c:t<3600?y:t<604800?h:null}function v(e,t){const n="number"==typeof t&&t-e>6e4,l=[j(e),n?j(t):null].filter(e=>null!=e);return l.length?Math.min(...l):null}function S(e,n){const[,l]=(0,t.useReducer)(e=>e+1,0),o=null==e?null:v(e,n);return(0,t.useEffect)(()=>{if(null!=o)return p(o,l)},[o,e,n]),null==e?null:(0,u.formatActivitySpan)(e,n)}const w=o.default.create({row:{flexDirection:"row",alignItems:"center"},dot:{width:8,height:8,borderRadius:4,marginRight:10},nid:{color:"#d8d8dd",fontSize:15,fontWeight:"600",fontFamily:"monospace",flexShrink:1,minWidth:0,transform:[{translateY:1}]},meta:{fontSize:13,fontFamily:"monospace",flexShrink:1,minWidth:0},fold:{marginLeft:8,fontSize:13,fontFamily:"monospace",flexShrink:1,minWidth:0}})},778,[11,13,105,26,779,749,6]);
881
+ __d(function(g,r,i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"formatActivitySpan",{enumerable:!0,get:function(){return u.formatActivitySpan}}),_e.useActivitySpan=S,_e.NarrativeMetaLine=function({role:e,cost:t,createdAt:o,lastActivity:s,status:u,mcpConnected:c,dimmed:y=!1,style:h}){const b="ended"!==u||c?c?"#66d9a0":"#5b9bd5":"#666",x=y?"#666":"#d8d8dd",p=y?"#555":"#888",j=y?"#5a6a60":"#7bb894",v=S(o,s);return(0,f.jsxs)(n.default,{style:[w.row,h],children:[(0,f.jsx)(n.default,{style:[w.dot,{backgroundColor:b}]}),(0,f.jsxs)(l.default,{style:w.meta,numberOfLines:1,children:[t?(0,f.jsx)(l.default,{style:{color:j},children:t}):null,e?(0,f.jsxs)(l.default,{style:{color:x},children:[t?" ":"","/",e]}):null,null!=v?(0,f.jsxs)(l.default,{style:{color:p},children:[t||e?" ":"","from ",v]}):null]})]})},_e.NarrativeIdentity=function({id:e,foldPath:t,titleStyle:o,align:u="baseline",copyMarginLeft:c=6,dimmed:y=!1,style:h}){return(0,f.jsxs)(n.default,{style:[{flexDirection:"row",alignItems:u,minWidth:0},h],children:[(0,f.jsx)(l.default,{style:[w.nid,o],numberOfLines:1,children:e}),(0,f.jsx)(s.default,{text:e,size:13,padding:0,marginLeft:c}),t?(0,f.jsxs)(l.default,{style:w.fold,numberOfLines:1,children:[(0,f.jsx)(l.default,{style:{color:y?"#555":"#888"},children:"in "}),(0,f.jsx)(l.default,{style:{color:y?"#4a5a50":"#5e8a72"},children:t})]}):null]})};var t=r(d[0]),n=e(r(d[1])),l=e(r(d[2])),o=e(r(d[3])),s=e(r(d[4])),u=r(d[5]),f=r(d[6]);const c=1e3,y=6e4,h=36e5,b=new Map;let x=!1;function p(e,t){x||"undefined"==typeof document||(x=!0,document.addEventListener("visibilitychange",()=>{if(!document.hidden)for(const e of b.values())for(const t of e.subs)t()}));let n=b.get(e);n||(n={timer:null,subs:new Set},b.set(e,n));const l=n;return l.subs.add(t),l.timer||(l.timer=setInterval(()=>{if("undefined"==typeof document||!document.hidden)for(const e of l.subs)e()},e)),()=>{l.subs.delete(t),0===l.subs.size&&l.timer&&(clearInterval(l.timer),l.timer=null,b.delete(e))}}function j(e){const t=Math.floor((Date.now()-e)/1e3);return t<60?c:t<3600?y:t<604800?h:null}function v(e,t){const n="number"==typeof t&&t-e>6e4,l=[j(e),n?j(t):null].filter(e=>null!=e);return l.length?Math.min(...l):null}function S(e,n){const[,l]=(0,t.useReducer)(e=>e+1,0),o=null==e?null:v(e,n);return(0,t.useEffect)(()=>{if(null!=o)return p(o,l)},[o,e,n]),null==e?null:(0,u.formatActivitySpan)(e,n)}const w=o.default.create({row:{flexDirection:"row",alignItems:"center"},dot:{width:8,height:8,borderRadius:4,marginRight:10},nid:{color:"#d8d8dd",fontSize:15,fontWeight:"600",fontFamily:"monospace",flexShrink:1,minWidth:0,transform:[{translateY:1}]},meta:{fontSize:13,fontFamily:"monospace",flexShrink:1,minWidth:0},fold:{marginLeft:8,fontSize:13,fontFamily:"monospace",flexShrink:1,minWidth:0}})},778,[11,13,105,26,779,751,6]);
882
882
  __d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return n}});var e=r(d[0]),t=r(d[1]);function n({text:n,size:o=11,padding:s=8,marginLeft:l=0,translateY:p=0}){const[u,c]=(0,e.useState)(!1);return(0,t.jsxs)("button",{type:"button","aria-label":u?`Copied ${n}`:`Copy ${n}`,onClick:e=>{e.stopPropagation(),e.preventDefault(),"undefined"!=typeof navigator&&navigator.clipboard&&(navigator.clipboard.writeText(n),c(!0),setTimeout(()=>c(!1),1200))},onPointerDown:e=>{e.stopPropagation()},style:{background:"none",border:"none",padding:s,margin:0,marginLeft:l,cursor:"pointer",color:u?"#66d9a0":"#888",fontSize:o,lineHeight:1,fontFamily:"inherit",transform:p?`translateY(${p}px)`:void 0,position:"relative"},children:[(0,t.jsx)("span",{style:{visibility:u?"hidden":"visible"},children:"\ud83d\udccb"}),u&&(0,t.jsx)("span",{"aria-hidden":!0,style:{position:"absolute",top:0,right:0,bottom:0,left:0,display:"flex",alignItems:"center",justifyContent:"center"},children:"\u2713"})]})}},779,[11,6]);
883
- __d(function(_g,r,i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return x}});var t=r(d[0]),n=e(r(d[1])),o=e(r(d[2])),l=e(r(d[3])),s=e(r(d[4])),c=e(r(d[5])),u=e(r(d[6])),h=e(r(d[7])),f=r(d[8]),g=e(r(d[9])),p=r(d[10]),y=r(d[11]);function k(e){const t=e.split(":")[0]?.toLowerCase()??"";return"localhost"===t||"127.0.0.1"===t||"::1"===t||"0.0.0.0"===t?{kind:"loopback",hostname:t}:t.endsWith(".ts.net")?{kind:"tailnet",hostname:t}:{kind:"open",hostname:t}}function b(e,t,n){return"undefined"==typeof window?"":(0,p.buildMeldUrl)({hostname:window.location.hostname,protocol:window.location.protocol,search:window.location.search,path:t,conn:e,view:n})}function v(e,n){const[o,l]=(0,t.useState)(null),[s,c]=(0,t.useState)(0),u=n?.host,h=n?.token;return(0,t.useEffect)(()=>{if(!e||void 0===u||void 0===h)return l(null),void c(0);let t,n=!1;return 0===s&&l({state:"minting"}),(0,f.mintDeviceToken)({host:u,token:h}).then(e=>{n||(null!==e?(l({state:"minted",token:e.token,validForMs:e.validForMs}),void 0!==e.validForMs&&(t=setTimeout(()=>c(e=>e+1),Math.max(e.validForMs-6e4,3e4)))):l({state:"legacy"}))},e=>{n||l({state:"failed",error:e.message})}),()=>{n=!0,void 0!==t&&clearTimeout(t)}},[e,u,h,s]),o}function x({visible:e,conn:t,path:u,view:f,onClose:p}){const x=v(e,t),j="minted"===x?.state?x.token:"legacy"===x?.state?t?.token:void 0,C=e&&t&&void 0!==j?b({host:t.host,token:j},u,f??{}):null,T=t?k(t.host):null,M=null!==C&&"loopback"!==T?.kind;return(0,y.jsx)(o.default,{visible:e,transparent:!0,animationType:"fade",onRequestClose:p,children:(0,y.jsx)(l.default,{style:w.backdrop,onPress:p,children:(0,y.jsxs)(l.default,{style:w.card,onPress:e=>e.stopPropagation(),children:[(0,y.jsx)(s.default,{style:w.title,children:"Meld another device"}),"minting"===x?.state&&(0,y.jsx)(n.default,{style:w.minting,color:"#9ad6b3"}),"failed"===x?.state&&(0,y.jsxs)(s.default,{style:w.warning,children:["Couldn't mint a token for the new device: ",x.error]}),M&&(0,y.jsx)(c.default,{style:w.qrWrap,children:(0,y.jsx)(h.default,{value:C,size:232})}),"loopback"===T?.kind&&(0,y.jsxs)(s.default,{style:w.warning,children:[T.hostname," only works on this machine. Run `brane certify` and reconnect over Tailscale to share."]}),C&&(0,y.jsxs)(c.default,{style:w.urlRow,children:[(0,y.jsx)(s.default,{style:w.url,selectable:!0,children:C}),(0,y.jsx)(c.default,{style:w.urlCopy,children:(0,y.jsx)(g.default,{text:C,size:13,padding:4})})]}),"minted"===x?.state&&(0,y.jsxs)(s.default,{style:w.note,children:["This code carries a new token of its own, not this device's.",void 0!==x.validForMs&&` Unscanned, it lapses after ${Math.round(x.validForMs/6e4)} minutes; this sheet replaces it before then.`]}),"legacy"===x?.state&&(0,y.jsx)(s.default,{style:w.warning,children:"This daemon predates per-device tokens, so the code carries this device's own token."}),"tailnet"===T?.kind&&(0,y.jsxs)(s.default,{style:w.note,children:["Safe to display \u2014 ",T.hostname," only resolves inside your tailnet."]}),"open"===T?.kind&&(0,y.jsxs)(s.default,{style:w.warning,children:[T.hostname," isn't a Tailscale hostname \u2014 token is the only gate. Don't display in public."]}),(0,y.jsx)(l.default,{style:w.close,onPress:p,children:(0,y.jsx)(s.default,{style:w.closeText,children:"Close"})})]})})})}const w=u.default.create({backdrop:{flex:1,backgroundColor:"rgba(0,0,0,0.7)",justifyContent:"center",alignItems:"center",padding:24},card:{backgroundColor:"#1e1e1e",borderRadius:12,padding:20,width:"100%",maxWidth:320,alignItems:"center"},title:{color:"#e0e0e0",fontSize:16,fontWeight:"600",marginBottom:16,textAlign:"center"},minting:{marginVertical:24},qrWrap:{backgroundColor:"#fff",padding:12,borderRadius:8},urlRow:{alignSelf:"stretch",marginTop:14,paddingHorizontal:26},urlCopy:{position:"absolute",top:0,bottom:0,right:0,width:26,alignItems:"center",justifyContent:"center"},url:{color:"#9ad6b3",fontSize:11,fontFamily:"monospace",textAlign:"center",wordBreak:"break-all"},note:{color:"#9ad6b3",fontSize:12,marginTop:12,textAlign:"center",lineHeight:17},warning:{color:"#e0a04e",fontSize:13,marginVertical:8,textAlign:"center",lineHeight:18},close:{marginTop:16,paddingHorizontal:18,paddingVertical:8,borderRadius:6,backgroundColor:"#2a2a2a"},closeText:{color:"#ccc",fontSize:14}})},780,[11,416,153,146,105,13,26,781,745,779,747,6]);
883
+ __d(function(_g,r,i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return x}});var t=r(d[0]),n=e(r(d[1])),o=e(r(d[2])),l=e(r(d[3])),s=e(r(d[4])),c=e(r(d[5])),u=e(r(d[6])),h=e(r(d[7])),f=r(d[8]),g=e(r(d[9])),p=r(d[10]),y=r(d[11]);function k(e){const t=e.split(":")[0]?.toLowerCase()??"";return"localhost"===t||"127.0.0.1"===t||"::1"===t||"0.0.0.0"===t?{kind:"loopback",hostname:t}:t.endsWith(".ts.net")?{kind:"tailnet",hostname:t}:{kind:"open",hostname:t}}function b(e,t,n){return"undefined"==typeof window?"":(0,p.buildMeldUrl)({host:window.location.host,protocol:window.location.protocol,search:window.location.search,path:t,conn:e,view:n})}function v(e,n){const[o,l]=(0,t.useState)(null),[s,c]=(0,t.useState)(0),u=n?.host,h=n?.token;return(0,t.useEffect)(()=>{if(!e||void 0===u||void 0===h)return l(null),void c(0);let t,n=!1;return 0===s&&l({state:"minting"}),(0,f.mintDeviceToken)({host:u,token:h}).then(e=>{n||(null!==e?(l({state:"minted",token:e.token,validForMs:e.validForMs}),void 0!==e.validForMs&&(t=setTimeout(()=>c(e=>e+1),Math.max(e.validForMs-6e4,3e4)))):l({state:"legacy"}))},e=>{n||l({state:"failed",error:e.message})}),()=>{n=!0,void 0!==t&&clearTimeout(t)}},[e,u,h,s]),o}function x({visible:e,conn:t,path:u,view:f,onClose:p}){const x=v(e,t),j="minted"===x?.state?x.token:"legacy"===x?.state?t?.token:void 0,C=e&&t&&void 0!==j?b({host:t.host,token:j},u,f??{}):null,T=t?k(t.host):null,M=null!==C&&"loopback"!==T?.kind;return(0,y.jsx)(o.default,{visible:e,transparent:!0,animationType:"fade",onRequestClose:p,children:(0,y.jsx)(l.default,{style:w.backdrop,onPress:p,children:(0,y.jsxs)(l.default,{style:w.card,onPress:e=>e.stopPropagation(),children:[(0,y.jsx)(s.default,{style:w.title,children:"Meld another device"}),"minting"===x?.state&&(0,y.jsx)(n.default,{style:w.minting,color:"#9ad6b3"}),"failed"===x?.state&&(0,y.jsxs)(s.default,{style:w.warning,children:["Couldn't mint a token for the new device: ",x.error]}),M&&(0,y.jsx)(c.default,{style:w.qrWrap,children:(0,y.jsx)(h.default,{value:C,size:232})}),"loopback"===T?.kind&&(0,y.jsxs)(s.default,{style:w.warning,children:[T.hostname," only works on this machine. Run `brane certify` and reconnect over Tailscale to share."]}),C&&(0,y.jsxs)(c.default,{style:w.urlRow,children:[(0,y.jsx)(s.default,{style:w.url,selectable:!0,children:C}),(0,y.jsx)(c.default,{style:w.urlCopy,children:(0,y.jsx)(g.default,{text:C,size:13,padding:4})})]}),"minted"===x?.state&&(0,y.jsxs)(s.default,{style:w.note,children:["This code carries a new token of its own, not this device's.",void 0!==x.validForMs&&` Unscanned, it lapses after ${Math.round(x.validForMs/6e4)} minutes; this sheet replaces it before then.`]}),"legacy"===x?.state&&(0,y.jsx)(s.default,{style:w.warning,children:"This daemon predates per-device tokens, so the code carries this device's own token."}),"tailnet"===T?.kind&&(0,y.jsxs)(s.default,{style:w.note,children:["Safe to display \u2014 ",T.hostname," only resolves inside your tailnet."]}),"open"===T?.kind&&(0,y.jsxs)(s.default,{style:w.warning,children:[T.hostname," isn't a Tailscale hostname \u2014 token is the only gate. Don't display in public."]}),(0,y.jsx)(l.default,{style:w.close,onPress:p,children:(0,y.jsx)(s.default,{style:w.closeText,children:"Close"})})]})})})}const w=u.default.create({backdrop:{flex:1,backgroundColor:"rgba(0,0,0,0.7)",justifyContent:"center",alignItems:"center",padding:24},card:{backgroundColor:"#1e1e1e",borderRadius:12,padding:20,width:"100%",maxWidth:320,alignItems:"center"},title:{color:"#e0e0e0",fontSize:16,fontWeight:"600",marginBottom:16,textAlign:"center"},minting:{marginVertical:24},qrWrap:{backgroundColor:"#fff",padding:12,borderRadius:8},urlRow:{alignSelf:"stretch",marginTop:14,paddingHorizontal:26},urlCopy:{position:"absolute",top:0,bottom:0,right:0,width:26,alignItems:"center",justifyContent:"center"},url:{color:"#9ad6b3",fontSize:11,fontFamily:"monospace",textAlign:"center",wordBreak:"break-all"},note:{color:"#9ad6b3",fontSize:12,marginTop:12,textAlign:"center",lineHeight:17},warning:{color:"#e0a04e",fontSize:13,marginVertical:8,textAlign:"center",lineHeight:18},close:{marginTop:16,paddingHorizontal:18,paddingVertical:8,borderRadius:6,backgroundColor:"#2a2a2a"},closeText:{color:"#ccc",fontSize:14}})},780,[11,416,153,146,105,13,26,781,745,779,747,6]);
884
884
  __d(function(g,_r,_i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"QRCode",{enumerable:!0,get:function(){return p}}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return p}});var t=e(_r(d[0])),r=e(_r(d[1])),n=_r(d[2]),o=e(n);function l(){return l=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},l.apply(null,arguments)}function i(e,t){if(null==e)return{};var r,n,o=u(e,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(n=0;n<l.length;n++)r=l[n],-1===t.indexOf(r)&&{}.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}function u(e,t){if(null==e)return{};var r={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(-1!==t.indexOf(n))continue;r[n]=e[n]}return r}var f=["bgColor","bgD","fgD","fgColor","size","title","viewBoxSize","xmlns"],c={bgColor:t.default.oneOfType([t.default.object,t.default.string]).isRequired,bgD:t.default.string.isRequired,fgColor:t.default.oneOfType([t.default.object,t.default.string]).isRequired,fgD:t.default.string.isRequired,size:t.default.number.isRequired,title:t.default.string,viewBoxSize:t.default.number.isRequired,xmlns:t.default.string},s=(0,n.forwardRef)(function(e,t){var r=e.bgColor,n=e.bgD,u=e.fgD,c=e.fgColor,s=e.size,v=e.title,b=e.viewBoxSize,p=e.xmlns,y=void 0===p?"http://www.w3.org/2000/svg":p,C=i(e,f);return o.default.createElement("svg",l({},C,{height:s,ref:t,viewBox:"0 0 ".concat(b," ").concat(b),width:s,xmlns:y}),v?o.default.createElement("title",null,v):null,o.default.createElement("path",{d:n,fill:r}),o.default.createElement("path",{d:u,fill:c}))});s.displayName="QRCodeSvg",s.propTypes=c;var v=["bgColor","fgColor","level","size","value"];r.default.stringToBytes=function(e){return Array.from((new TextEncoder).encode(e))};var b={bgColor:t.default.oneOfType([t.default.object,t.default.string]),fgColor:t.default.oneOfType([t.default.object,t.default.string]),level:t.default.string,size:t.default.number,value:t.default.string.isRequired},p=(0,n.forwardRef)(function(e,t){var n=e.bgColor,u=void 0===n?"#FFFFFF":n,f=e.fgColor,c=void 0===f?"#000000":f,b=e.level,p=void 0===b?"L":b,y=e.size,C=void 0===y?256:y,w=e.value,O=i(e,v),j=(0,r.default)(0,p);j.addData(w),j.make();var h=j.getModuleCount(),x=Array.from({length:h},function(e,t){return Array.from({length:h},function(e,r){return j.isDark(t,r)})});return o.default.createElement(s,l({},O,{bgColor:u,bgD:x.map(function(e,t){return e.map(function(e,r){return e?"":"M ".concat(r," ").concat(t," l 1 0 0 1 -1 0 Z")}).join(" ")}).join(" "),fgColor:c,fgD:x.map(function(e,t){return e.map(function(e,r){return e?"M ".concat(r," ").concat(t," l 1 0 0 1 -1 0 Z"):""}).join(" ")}).join(" "),ref:t,size:C,viewBoxSize:h}))});p.displayName="QRCode",p.propTypes=b},781,[782,785,11]);
885
885
  __d(function(g,r,i,a,m,e,d){m.exports=r(d[0])()},782,[783]);
886
886
  __d(function(g,r,i,a,m,e,d){'use strict';var n=r(d[0]);function t(){}function o(){}o.resetWarningCache=t,m.exports=function(){function p(t,o,p,c,s,y){if(y!==n){var f=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw f.name='Invariant Violation',f}}function c(){return p}p.isRequired=p;var s={array:p,bigint:p,bool:p,func:p,number:p,object:p,string:p,symbol:p,any:p,arrayOf:c,element:p,elementType:p,instanceOf:c,node:p,objectOf:c,oneOf:c,oneOfType:c,shape:c,exact:c,checkPropTypes:o,resetWarningCache:t};return s.PropTypes=s,s}},783,[784]);
887
887
  __d(function(g,r,i,a,m,e,d){'use strict';m.exports='SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED'},784,[]);
888
888
  __d(function(g,_r,_i,_a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return I}}),Object.defineProperty(_e,"qrcode",{enumerable:!0,get:function(){return t}}),Object.defineProperty(_e,"stringToBytes",{enumerable:!0,get:function(){return P}});const t=function(t,e){let n=t;const r=i[e];let o=null,u=0,c=null;const l=[],f={},s=function(t,e){u=4*n+17,o=(function(t){const e=new Array(t);for(let n=0;n<t;n+=1){e[n]=new Array(t);for(let r=0;r<t;r+=1)e[n][r]=null}return e})(u),a(0,0),a(u-7,0),a(0,u-7),y(),d(),L(t,e),n>=7&&x(t),null==c&&(c=I(n,r,l)),D(c,e)},a=function(t,e){for(let n=-1;n<=7;n+=1)if(!(t+n<=-1||u<=t+n))for(let r=-1;r<=7;r+=1)e+r<=-1||u<=e+r||(o[t+n][e+r]=0<=n&&n<=6&&(0==r||6==r)||0<=r&&r<=6&&(0==n||6==n)||2<=n&&n<=4&&2<=r&&r<=4)},h=function(){let t=0,e=0;for(let n=0;n<8;n+=1){s(!0,n);const r=w.getLostPoint(f);(0==n||t>r)&&(t=r,e=n)}return e},d=function(){for(let t=8;t<u-8;t+=1)null==o[t][6]&&(o[t][6]=t%2==0);for(let t=8;t<u-8;t+=1)null==o[6][t]&&(o[6][t]=t%2==0)},y=function(){const t=w.getPatternPosition(n);for(let e=0;e<t.length;e+=1)for(let n=0;n<t.length;n+=1){const r=t[e],i=t[n];if(null==o[r][i])for(let t=-2;t<=2;t+=1)for(let e=-2;e<=2;e+=1)o[r+t][i+e]=-2==t||2==t||-2==e||2==e||0==t&&0==e}},x=function(t){const e=w.getBCHTypeNumber(n);for(let n=0;n<18;n+=1){const r=!t&&1==(e>>n&1);o[Math.floor(n/3)][n%3+u-8-3]=r}for(let n=0;n<18;n+=1){const r=!t&&1==(e>>n&1);o[n%3+u-8-3][Math.floor(n/3)]=r}},L=function(t,e){const n=r<<3|e,i=w.getBCHTypeInfo(n);for(let e=0;e<15;e+=1){const n=!t&&1==(i>>e&1);e<6?o[e][8]=n:e<8?o[e+1][8]=n:o[u-15+e][8]=n}for(let e=0;e<15;e+=1){const n=!t&&1==(i>>e&1);e<8?o[8][u-e-1]=n:e<9?o[8][15-e-1+1]=n:o[8][15-e-1]=n}o[u-8][8]=!t},D=function(t,e){let n=-1,r=u-1,i=7,c=0;const l=w.getMaskFunction(e);for(let e=u-1;e>0;e-=2)for(6==e&&(e-=1);;){for(let n=0;n<2;n+=1)if(null==o[r][e-n]){let u=!1;c<t.length&&(u=1==(t[c]>>>i&1));l(r,e-n)&&(u=!u),o[r][e-n]=u,i-=1,-1==i&&(c+=1,i=7)}if(r+=n,r<0||u<=r){r-=n,n=-n;break}}},S=function(t,e){let n=0,r=0,o=0;const i=new Array(e.length),u=new Array(e.length);for(let c=0;c<e.length;c+=1){const l=e[c].dataCount,f=e[c].totalCount-l;r=Math.max(r,l),o=Math.max(o,f),i[c]=new Array(l);for(let e=0;e<i[c].length;e+=1)i[c][e]=255&t.getBuffer()[e+n];n+=l;const s=w.getErrorCorrectPolynomial(f),a=p(i[c],s.getLength()-1).mod(s);u[c]=new Array(s.getLength()-1);for(let t=0;t<u[c].length;t+=1){const e=t+a.getLength()-u[c].length;u[c][t]=e>=0?a.getAt(e):0}}let c=0;for(let t=0;t<e.length;t+=1)c+=e[t].totalCount;const l=new Array(c);let f=0;for(let t=0;t<r;t+=1)for(let n=0;n<e.length;n+=1)t<i[n].length&&(l[f]=i[n][t],f+=1);for(let t=0;t<o;t+=1)for(let n=0;n<e.length;n+=1)t<u[n].length&&(l[f]=u[n][t],f+=1);return l},I=function(t,e,n){const r=B.getRSBlocks(t,e),o=k();for(let e=0;e<n.length;e+=1){const r=n[e];o.put(r.getMode(),4),o.put(r.getLength(),w.getLengthInBits(r.getMode(),t)),r.write(o)}let i=0;for(let t=0;t<r.length;t+=1)i+=r[t].dataCount;if(o.getLengthInBits()>8*i)throw'code length overflow. ('+o.getLengthInBits()+'>'+8*i+')';for(o.getLengthInBits()+4<=8*i&&o.put(0,4);o.getLengthInBits()%8!=0;)o.putBit(!1);for(;!(o.getLengthInBits()>=8*i||(o.put(236,8),o.getLengthInBits()>=8*i));)o.put(17,8);return S(o,r)};f.addData=function(t,e){let n=null;switch(e=e||'Byte'){case'Numeric':n=C(t);break;case'Alphanumeric':n=b(t);break;case'Byte':n=A(t);break;case'Kanji':n=M(t);break;default:throw'mode:'+e}l.push(n),c=null},f.isDark=function(t,e){if(t<0||u<=t||e<0||u<=e)throw t+','+e;return o[t][e]},f.getModuleCount=function(){return u},f.make=function(){if(n<1){let t=1;for(;t<40;t++){const e=B.getRSBlocks(t,r),n=k();for(let e=0;e<l.length;e++){const r=l[e];n.put(r.getMode(),4),n.put(r.getLength(),w.getLengthInBits(r.getMode(),t)),r.write(n)}let o=0;for(let t=0;t<e.length;t++)o+=e[t].dataCount;if(n.getLengthInBits()<=8*o)break}n=t}s(!1,h())},f.createTableTag=function(t,e){t=t||2;let n='';n+='<table style="',n+=' border-width: 0px; border-style: none;',n+=' border-collapse: collapse;',n+=' padding: 0px; margin: '+(e=void 0===e?4*t:e)+'px;',n+='">',n+='<tbody>';for(let e=0;e<f.getModuleCount();e+=1){n+='<tr>';for(let r=0;r<f.getModuleCount();r+=1)n+='<td style="',n+=' border-width: 0px; border-style: none;',n+=' border-collapse: collapse;',n+=' padding: 0px; margin: 0px;',n+=' width: '+t+'px;',n+=' height: '+t+'px;',n+=' background-color: ',n+=f.isDark(e,r)?'#000000':'#ffffff',n+=';',n+='"/>';n+='</tr>'}return n+='</tbody>',n+='</table>',n},f.createSvgTag=function(t,e,n,r){let o={};'object'==typeof arguments[0]&&(o=arguments[0],t=o.cellSize,e=o.margin,n=o.alt,r=o.title),t=t||2,e=void 0===e?4*t:e,(n='string'==typeof n?{text:n}:n||{}).text=n.text||null,n.id=n.text?n.id||'qrcode-description':null,(r='string'==typeof r?{text:r}:r||{}).text=r.text||null,r.id=r.text?r.id||'qrcode-title':null;const i=f.getModuleCount()*t+2*e;let u,c,l,s,a,h='';for(a='l'+t+',0 0,'+t+' -'+t+',0 0,-'+t+'z ',h+='<svg version="1.1" xmlns="http://www.w3.org/2000/svg"',h+=o.scalable?'':' width="'+i+'px" height="'+i+'px"',h+=' viewBox="0 0 '+i+' '+i+'" ',h+=' preserveAspectRatio="xMinYMin meet"',h+=r.text||n.text?' role="img" aria-labelledby="'+P([r.id,n.id].join(' ').trim())+'"':'',h+='>',h+=r.text?'<title id="'+P(r.id)+'">'+P(r.text)+'</title>':'',h+=n.text?'<description id="'+P(n.id)+'">'+P(n.text)+'</description>':'',h+='<rect width="100%" height="100%" fill="white" cx="0" cy="0"/>',h+='<path d="',l=0;l<f.getModuleCount();l+=1)for(s=l*t+e,u=0;u<f.getModuleCount();u+=1)f.isDark(l,u)&&(c=u*t+e,h+='M'+c+','+s+a);return h+='" stroke="transparent" fill="black"/>',h+='</svg>',h},f.createDataURL=function(t,e){t=t||2,e=void 0===e?4*t:e;const n=f.getModuleCount()*t+2*e,r=e,o=n-e;return v(n,n,function(e,n){if(r<=e&&e<o&&r<=n&&n<o){const o=Math.floor((e-r)/t),i=Math.floor((n-r)/t);return f.isDark(i,o)?0:1}return 1})},f.createImgTag=function(t,e,n){t=t||2,e=void 0===e?4*t:e;const r=f.getModuleCount()*t+2*e;let o='';return o+='<img',o+=' src="',o+=f.createDataURL(t,e),o+='"',o+=' width="',o+=r,o+='"',o+=' height="',o+=r,o+='"',n&&(o+=' alt="',o+=P(n),o+='"'),o+='/>',o};const P=function(t){let e='';for(let n=0;n<t.length;n+=1){const r=t.charAt(n);switch(r){case'<':e+='&lt;';break;case'>':e+='&gt;';break;case'&':e+='&amp;';break;case'"':e+='&quot;';break;default:e+=r}}return e},T=function(t){t=void 0===t?2:t;const e=1*f.getModuleCount()+2*t,n=t,r=e-t;let o,i,u,c,l;const s={'\u2588\u2588':'\u2588','\u2588 ':'\u2580',' \u2588':'\u2584',' ':' '},a={'\u2588\u2588':'\u2580','\u2588 ':'\u2580',' \u2588':' ',' ':' '};let h='';for(o=0;o<e;o+=2){for(u=Math.floor((o-n)/1),c=Math.floor((o+1-n)/1),i=0;i<e;i+=1)l='\u2588',n<=i&&i<r&&n<=o&&o<r&&f.isDark(u,Math.floor((i-n)/1))&&(l=' '),n<=i&&i<r&&n<=o+1&&o+1<r&&f.isDark(c,Math.floor((i-n)/1))?l+=' ':l+='\u2588',h+=t<1&&o+1>=r?a[l]:s[l];h+='\n'}return e%2&&t>0?h.substring(0,h.length-e-1)+Array(e+1).join('\u2580'):h.substring(0,h.length-1)};return f.createASCII=function(t,e){if((t=t||1)<2)return T(e);t-=1,e=void 0===e?2*t:e;const n=f.getModuleCount()*t+2*e,r=e,o=n-e;let i,u,c,l;const s=Array(t+1).join('\u2588\u2588'),a=Array(t+1).join(' ');let h='',d='';for(i=0;i<n;i+=1){for(c=Math.floor((i-r)/t),d='',u=0;u<n;u+=1)l=1,r<=u&&u<o&&r<=i&&i<o&&f.isDark(c,Math.floor((u-r)/t))&&(l=0),d+=l?s:a;for(c=0;c<t;c+=1)h+=d+'\n'}return h.substring(0,h.length-1)},f.renderTo2dContext=function(t,e){e=e||2;const n=f.getModuleCount();for(let r=0;r<n;r++)for(let o=0;o<n;o++)t.fillStyle=f.isDark(r,o)?'black':'white',t.fillRect(o*e,r*e,e,e)},f};t.stringToBytes=function(t){const e=[];for(let n=0;n<t.length;n+=1){const r=t.charCodeAt(n);e.push(255&r)}return e},t.createStringToBytes=function(t,e){const n=(function(){const n=D(t),r=function(){const t=n.read();if(-1==t)throw'eof';return t};let o=0;const i={};for(;;){const t=n.read();if(-1==t)break;const e=r(),u=r()<<8|r();i[String.fromCharCode(t<<8|e)]=u,o+=1}if(o!=e)throw o+' != '+e;return i})(),r='?'.charCodeAt(0);return function(t){const e=[];for(let o=0;o<t.length;o+=1){const i=t.charCodeAt(o);if(i<128)e.push(i);else{const i=n[t.charAt(o)];'number'==typeof i?(255&i)==i?e.push(i):(e.push(i>>>8),e.push(255&i)):e.push(r)}}return e}};const e=1,n=2,r=4,o=8,i={L:1,M:0,Q:3,H:2},u=0,c=1,l=2,f=3,s=4,a=5,h=6,d=7,w=(function(){const t=[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],i=1335,w=7973,B={},k=function(t){let e=0;for(;0!=t;)e+=1,t>>>=1;return e};return B.getBCHTypeInfo=function(t){let e=t<<10;for(;k(e)-k(i)>=0;)e^=i<<k(e)-k(i);return 21522^(t<<10|e)},B.getBCHTypeNumber=function(t){let e=t<<12;for(;k(e)-k(w)>=0;)e^=w<<k(e)-k(w);return t<<12|e},B.getPatternPosition=function(e){return t[e-1]},B.getMaskFunction=function(t){switch(t){case u:return function(t,e){return(t+e)%2==0};case c:return function(t,e){return t%2==0};case l:return function(t,e){return e%3==0};case f:return function(t,e){return(t+e)%3==0};case s:return function(t,e){return(Math.floor(t/2)+Math.floor(e/3))%2==0};case a:return function(t,e){return t*e%2+t*e%3==0};case h:return function(t,e){return(t*e%2+t*e%3)%2==0};case d:return function(t,e){return(t*e%3+(t+e)%2)%2==0};default:throw'bad maskPattern:'+t}},B.getErrorCorrectPolynomial=function(t){let e=p([1],0);for(let n=0;n<t;n+=1)e=e.multiply(p([1,y.gexp(n)],0));return e},B.getLengthInBits=function(t,i){if(1<=i&&i<10)switch(t){case e:return 10;case n:return 9;case r:case o:return 8;default:throw'mode:'+t}else if(i<27)switch(t){case e:return 12;case n:return 11;case r:return 16;case o:return 10;default:throw'mode:'+t}else{if(!(i<41))throw'type:'+i;switch(t){case e:return 14;case n:return 13;case r:return 16;case o:return 12;default:throw'mode:'+t}}},B.getLostPoint=function(t){const e=t.getModuleCount();let n=0;for(let r=0;r<e;r+=1)for(let o=0;o<e;o+=1){let i=0;const u=t.isDark(r,o);for(let n=-1;n<=1;n+=1)if(!(r+n<0||e<=r+n))for(let c=-1;c<=1;c+=1)o+c<0||e<=o+c||0==n&&0==c||u==t.isDark(r+n,o+c)&&(i+=1);i>5&&(n+=3+i-5)}for(let r=0;r<e-1;r+=1)for(let o=0;o<e-1;o+=1){let e=0;t.isDark(r,o)&&(e+=1),t.isDark(r+1,o)&&(e+=1),t.isDark(r,o+1)&&(e+=1),t.isDark(r+1,o+1)&&(e+=1),0!=e&&4!=e||(n+=3)}for(let r=0;r<e;r+=1)for(let o=0;o<e-6;o+=1)t.isDark(r,o)&&!t.isDark(r,o+1)&&t.isDark(r,o+2)&&t.isDark(r,o+3)&&t.isDark(r,o+4)&&!t.isDark(r,o+5)&&t.isDark(r,o+6)&&(n+=40);for(let r=0;r<e;r+=1)for(let o=0;o<e-6;o+=1)t.isDark(o,r)&&!t.isDark(o+1,r)&&t.isDark(o+2,r)&&t.isDark(o+3,r)&&t.isDark(o+4,r)&&!t.isDark(o+5,r)&&t.isDark(o+6,r)&&(n+=40);let r=0;for(let n=0;n<e;n+=1)for(let o=0;o<e;o+=1)t.isDark(o,n)&&(r+=1);return n+=10*(Math.abs(100*r/e/e-50)/5),n},B})(),y=(function(){const t=new Array(256),e=new Array(256);for(let e=0;e<8;e+=1)t[e]=1<<e;for(let e=8;e<256;e+=1)t[e]=t[e-4]^t[e-5]^t[e-6]^t[e-8];for(let n=0;n<255;n+=1)e[t[n]]=n;const n={glog:function(t){if(t<1)throw'glog('+t+')';return e[t]},gexp:function(e){for(;e<0;)e+=255;for(;e>=256;)e-=255;return t[e]}};return n})(),p=function(t,e){if(void 0===t.length)throw t.length+'/'+e;const n=(function(){let n=0;for(;n<t.length&&0==t[n];)n+=1;const r=new Array(t.length-n+e);for(let e=0;e<t.length-n;e+=1)r[e]=t[e+n];return r})(),r={getAt:function(t){return n[t]},getLength:function(){return n.length},multiply:function(t){const e=new Array(r.getLength()+t.getLength()-1);for(let n=0;n<r.getLength();n+=1)for(let o=0;o<t.getLength();o+=1)e[n+o]^=y.gexp(y.glog(r.getAt(n))+y.glog(t.getAt(o)));return p(e,0)},mod:function(t){if(r.getLength()-t.getLength()<0)return r;const e=y.glog(r.getAt(0))-y.glog(t.getAt(0)),n=new Array(r.getLength());for(let t=0;t<r.getLength();t+=1)n[t]=r.getAt(t);for(let r=0;r<t.getLength();r+=1)n[r]^=y.gexp(y.glog(t.getAt(r))+e);return p(n,0).mod(t)}};return r},B=(function(){const t=[[1,26,19],[1,26,16],[1,26,13],[1,26,9],[1,44,34],[1,44,28],[1,44,22],[1,44,16],[1,70,55],[1,70,44],[2,35,17],[2,35,13],[1,100,80],[2,50,32],[2,50,24],[4,25,9],[1,134,108],[2,67,43],[2,33,15,2,34,16],[2,33,11,2,34,12],[2,86,68],[4,43,27],[4,43,19],[4,43,15],[2,98,78],[4,49,31],[2,32,14,4,33,15],[4,39,13,1,40,14],[2,121,97],[2,60,38,2,61,39],[4,40,18,2,41,19],[4,40,14,2,41,15],[2,146,116],[3,58,36,2,59,37],[4,36,16,4,37,17],[4,36,12,4,37,13],[2,86,68,2,87,69],[4,69,43,1,70,44],[6,43,19,2,44,20],[6,43,15,2,44,16],[4,101,81],[1,80,50,4,81,51],[4,50,22,4,51,23],[3,36,12,8,37,13],[2,116,92,2,117,93],[6,58,36,2,59,37],[4,46,20,6,47,21],[7,42,14,4,43,15],[4,133,107],[8,59,37,1,60,38],[8,44,20,4,45,21],[12,33,11,4,34,12],[3,145,115,1,146,116],[4,64,40,5,65,41],[11,36,16,5,37,17],[11,36,12,5,37,13],[5,109,87,1,110,88],[5,65,41,5,66,42],[5,54,24,7,55,25],[11,36,12,7,37,13],[5,122,98,1,123,99],[7,73,45,3,74,46],[15,43,19,2,44,20],[3,45,15,13,46,16],[1,135,107,5,136,108],[10,74,46,1,75,47],[1,50,22,15,51,23],[2,42,14,17,43,15],[5,150,120,1,151,121],[9,69,43,4,70,44],[17,50,22,1,51,23],[2,42,14,19,43,15],[3,141,113,4,142,114],[3,70,44,11,71,45],[17,47,21,4,48,22],[9,39,13,16,40,14],[3,135,107,5,136,108],[3,67,41,13,68,42],[15,54,24,5,55,25],[15,43,15,10,44,16],[4,144,116,4,145,117],[17,68,42],[17,50,22,6,51,23],[19,46,16,6,47,17],[2,139,111,7,140,112],[17,74,46],[7,54,24,16,55,25],[34,37,13],[4,151,121,5,152,122],[4,75,47,14,76,48],[11,54,24,14,55,25],[16,45,15,14,46,16],[6,147,117,4,148,118],[6,73,45,14,74,46],[11,54,24,16,55,25],[30,46,16,2,47,17],[8,132,106,4,133,107],[8,75,47,13,76,48],[7,54,24,22,55,25],[22,45,15,13,46,16],[10,142,114,2,143,115],[19,74,46,4,75,47],[28,50,22,6,51,23],[33,46,16,4,47,17],[8,152,122,4,153,123],[22,73,45,3,74,46],[8,53,23,26,54,24],[12,45,15,28,46,16],[3,147,117,10,148,118],[3,73,45,23,74,46],[4,54,24,31,55,25],[11,45,15,31,46,16],[7,146,116,7,147,117],[21,73,45,7,74,46],[1,53,23,37,54,24],[19,45,15,26,46,16],[5,145,115,10,146,116],[19,75,47,10,76,48],[15,54,24,25,55,25],[23,45,15,25,46,16],[13,145,115,3,146,116],[2,74,46,29,75,47],[42,54,24,1,55,25],[23,45,15,28,46,16],[17,145,115],[10,74,46,23,75,47],[10,54,24,35,55,25],[19,45,15,35,46,16],[17,145,115,1,146,116],[14,74,46,21,75,47],[29,54,24,19,55,25],[11,45,15,46,46,16],[13,145,115,6,146,116],[14,74,46,23,75,47],[44,54,24,7,55,25],[59,46,16,1,47,17],[12,151,121,7,152,122],[12,75,47,26,76,48],[39,54,24,14,55,25],[22,45,15,41,46,16],[6,151,121,14,152,122],[6,75,47,34,76,48],[46,54,24,10,55,25],[2,45,15,64,46,16],[17,152,122,4,153,123],[29,74,46,14,75,47],[49,54,24,10,55,25],[24,45,15,46,46,16],[4,152,122,18,153,123],[13,74,46,32,75,47],[48,54,24,14,55,25],[42,45,15,32,46,16],[20,147,117,4,148,118],[40,75,47,7,76,48],[43,54,24,22,55,25],[10,45,15,67,46,16],[19,148,118,6,149,119],[18,75,47,31,76,48],[34,54,24,34,55,25],[20,45,15,61,46,16]],e=function(t,e){const n={};return n.totalCount=t,n.dataCount=e,n},n={},r=function(e,n){switch(n){case i.L:return t[4*(e-1)+0];case i.M:return t[4*(e-1)+1];case i.Q:return t[4*(e-1)+2];case i.H:return t[4*(e-1)+3];default:return}};return n.getRSBlocks=function(t,n){const o=r(t,n);if(void 0===o)throw'bad rs block @ typeNumber:'+t+'/errorCorrectionLevel:'+n;const i=o.length/3,u=[];for(let t=0;t<i;t+=1){const n=o[3*t+0],r=o[3*t+1],i=o[3*t+2];for(let t=0;t<n;t+=1)u.push(e(r,i))}return u},n})(),k=function(){const t=[];let e=0;const n={getBuffer:function(){return t},getAt:function(e){const n=Math.floor(e/8);return 1==(t[n]>>>7-e%8&1)},put:function(t,e){for(let r=0;r<e;r+=1)n.putBit(1==(t>>>e-r-1&1))},getLengthInBits:function(){return e},putBit:function(n){const r=Math.floor(e/8);t.length<=r&&t.push(0),n&&(t[r]|=128>>>e%8),e+=1}};return n},C=function(t){const n=e,r=t,o={getMode:function(){return n},getLength:function(t){return r.length},write:function(t){const e=r;let n=0;for(;n+2<e.length;)t.put(i(e.substring(n,n+3)),10),n+=3;n<e.length&&(e.length-n==1?t.put(i(e.substring(n,n+1)),4):e.length-n==2&&t.put(i(e.substring(n,n+2)),7))}},i=function(t){let e=0;for(let n=0;n<t.length;n+=1)e=10*e+u(t.charAt(n));return e},u=function(t){if('0'<=t&&t<='9')return t.charCodeAt(0)-'0'.charCodeAt(0);throw'illegal char :'+t};return o},b=function(t){const e=n,r=t,o={getMode:function(){return e},getLength:function(t){return r.length},write:function(t){const e=r;let n=0;for(;n+1<e.length;)t.put(45*i(e.charAt(n))+i(e.charAt(n+1)),11),n+=2;n<e.length&&t.put(i(e.charAt(n)),6)}},i=function(t){if('0'<=t&&t<='9')return t.charCodeAt(0)-'0'.charCodeAt(0);if('A'<=t&&t<='Z')return t.charCodeAt(0)-'A'.charCodeAt(0)+10;switch(t){case' ':return 36;case'$':return 37;case'%':return 38;case'*':return 39;case'+':return 40;case'-':return 41;case'.':return 42;case'/':return 43;case':':return 44;default:throw'illegal char :'+t}};return o},A=function(e){const n=r,o=t.stringToBytes(e),i={getMode:function(){return n},getLength:function(t){return o.length},write:function(t){for(let e=0;e<o.length;e+=1)t.put(o[e],8)}};return i},M=function(e){const n=o,r=t.stringToBytes;!(function(){const t=r('\u53cb');if(2!=t.length||38726!=(t[0]<<8|t[1]))throw'sjis not supported.'})();const i=r(e),u={getMode:function(){return n},getLength:function(t){return~~(i.length/2)},write:function(t){const e=i;let n=0;for(;n+1<e.length;){let r=(255&e[n])<<8|255&e[n+1];if(33088<=r&&r<=40956)r-=33088;else{if(!(57408<=r&&r<=60351))throw'illegal char at '+(n+1)+'/'+r;r-=49472}r=192*(r>>>8&255)+(255&r),t.put(r,13),n+=2}if(n<e.length)throw'illegal char at '+(n+1)}};return u},x=function(){const t=[],e={writeByte:function(e){t.push(255&e)},writeShort:function(t){e.writeByte(t),e.writeByte(t>>>8)},writeBytes:function(t,n,r){n=n||0,r=r||t.length;for(let o=0;o<r;o+=1)e.writeByte(t[o+n])},writeString:function(t){for(let n=0;n<t.length;n+=1)e.writeByte(t.charCodeAt(n))},toByteArray:function(){return t},toString:function(){let e='';e+='[';for(let n=0;n<t.length;n+=1)n>0&&(e+=','),e+=t[n];return e+=']',e}};return e},L=function(){let t=0,e=0,n=0,r='';const o={},i=function(t){r+=String.fromCharCode(u(63&t))},u=function(t){if(t<0)throw'n:'+t;if(t<26)return 65+t;if(t<52)return t-26+97;if(t<62)return t-52+48;if(62==t)return 43;if(63==t)return 47;throw'n:'+t};return o.writeByte=function(r){for(t=t<<8|255&r,e+=8,n+=1;e>=6;)i(t>>>e-6),e-=6},o.flush=function(){if(e>0&&(i(t<<6-e),t=0,e=0),n%3!=0){const t=3-n%3;for(let e=0;e<t;e+=1)r+='='}},o.toString=function(){return r},o},D=function(t){const e=t;let n=0,r=0,o=0;const i={read:function(){for(;o<8;){if(n>=e.length){if(0==o)return-1;throw'unexpected end of file./'+o}const t=e.charAt(n);if(n+=1,'='==t)return o=0,-1;t.match(/^\s$/)||(r=r<<6|u(t.charCodeAt(0)),o+=6)}const t=r>>>o-8&255;return o-=8,t}},u=function(t){if(65<=t&&t<=90)return t-65;if(97<=t&&t<=122)return t-97+26;if(48<=t&&t<=57)return t-48+52;if(43==t)return 62;if(47==t)return 63;throw'c:'+t};return i},S=function(t,e){const n=t,r=e,o=new Array(t*e),i={setPixel:function(t,e,r){o[e*n+t]=r},write:function(t){t.writeString('GIF87a'),t.writeShort(n),t.writeShort(r),t.writeByte(128),t.writeByte(0),t.writeByte(0),t.writeByte(0),t.writeByte(0),t.writeByte(0),t.writeByte(255),t.writeByte(255),t.writeByte(255),t.writeString(','),t.writeShort(0),t.writeShort(0),t.writeShort(n),t.writeShort(r),t.writeByte(0);const e=c(2);t.writeByte(2);let o=0;for(;e.length-o>255;)t.writeByte(255),t.writeBytes(e,o,255),o+=255;t.writeByte(e.length-o),t.writeBytes(e,o,e.length-o),t.writeByte(0),t.writeString(';')}},u=function(t){const e=t;let n=0,r=0;const o={write:function(t,o){if(t>>>o!=0)throw'length over';for(;n+o>=8;)e.writeByte(255&(t<<n|r)),o-=8-n,t>>>=8-n,r=0,n=0;r|=t<<n,n+=o},flush:function(){n>0&&e.writeByte(r)}};return o},c=function(t){const e=1<<t,n=1+(1<<t);let r=t+1;const i=l();for(let t=0;t<e;t+=1)i.add(String.fromCharCode(t));i.add(String.fromCharCode(e)),i.add(String.fromCharCode(n));const c=x(),f=u(c);f.write(e,r);let s=0,a=String.fromCharCode(o[s]);for(s+=1;s<o.length;){const t=String.fromCharCode(o[s]);s+=1,i.contains(a+t)?a+=t:(f.write(i.indexOf(a),r),i.size()<4095&&(i.size()==1<<r&&(r+=1),i.add(a+t)),a=t)}return f.write(i.indexOf(a),r),f.write(n,r),f.flush(),c.toByteArray()},l=function(){const t={};let e=0;const n={add:function(r){if(n.contains(r))throw'dup key:'+r;t[r]=e,e+=1},size:function(){return e},indexOf:function(e){return t[e]},contains:function(e){return void 0!==t[e]}};return n};return i},v=function(t,e,n){const r=S(t,e);for(let o=0;o<e;o+=1)for(let e=0;e<t;e+=1)r.setPixel(e,o,n(e,o));const o=x();r.write(o);const i=L(),u=o.toByteArray();for(let t=0;t<u.length;t+=1)i.writeByte(u[t]);return i.flush(),'data:image/gif;base64,'+i};var I=t;const P=t.stringToBytes},785,[]);
889
- __d(function(g,r,_i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"darkMarkdownStyles",{enumerable:!0,get:function(){return W}}),Object.defineProperty(_e,"foreignMarkdownStyles",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"systemMarkdownStyles",{enumerable:!0,get:function(){return _}}),Object.defineProperty(_e,"MarkdownContent",{enumerable:!0,get:function(){return E}});var t=r(d[0]),n=e(r(d[1])),o=e(r(d[2]));r(d[3]),r(d[4]);e(r(d[5]));var l=r(d[6]),i=r(d[7]),s=r(d[8]),c=r(d[9]),f=r(d[10]),h=r(d[11]),u=r(d[12]),y=r(d[13]),k=r(d[14]),p=r(d[15]),b=r(d[16]),x=r(d[17]),j=r(d[18]),S=r(d[19]),C=r(d[20]),H=r(d[21]),w=r(d[22]),z=r(d[23]),M=r(d[24]),T=r(d[25]),I=r(d[26]);const L="monospace",v=/^[a-z][a-z0-9+.-]*:/i;function P(e){return{href:e,hrefAttrs:{target:"_blank",rel:"noopener noreferrer"}}}const W={root:{marginVertical:-2},text:{color:"#e0e0e0",fontSize:15,lineHeight:21},paragraph:{marginVertical:8,width:"100%"},strong:{color:"#f0f0f0",fontWeight:"600"},emphasis:{fontStyle:"italic"},link:{color:"#6cb6ff",textDecorationLine:"underline"},heading1:{color:"#f0f0f0",fontSize:26,lineHeight:32,fontWeight:"700",marginTop:16,marginBottom:8},heading2:{color:"#f0f0f0",fontSize:22,lineHeight:28,fontWeight:"700",marginTop:14,marginBottom:6},heading3:{color:"#f0f0f0",fontSize:19,lineHeight:25,fontWeight:"700",marginTop:12,marginBottom:4},heading4:{color:"#e8e8e8",fontSize:17,lineHeight:23,fontWeight:"600",marginTop:10,marginBottom:4},heading5:{color:"#e8e8e8",fontSize:16,lineHeight:22,fontWeight:"600",marginTop:8,marginBottom:2},heading6:{color:"#ccc",fontSize:15,lineHeight:21,fontWeight:"600",marginTop:6,marginBottom:2},inlineCode:{color:"#f8c555",backgroundColor:"#1a1a1a",fontFamily:L,fontSize:13},code:{backgroundColor:"#0d1117",color:"#e0e0e0",fontFamily:L,fontSize:13,padding:10},blockquote:{borderColor:"#555",borderLeftWidth:3,paddingHorizontal:10,marginVertical:2,backgroundColor:"transparent"},thematicBreak:{backgroundColor:"#444",marginVertical:6,height:1},list:{},listItem:{flexDirection:"row",alignItems:"flex-start",justifyContent:"flex-start",gap:6},listBullet:{color:"#e0e0e0",fontSize:15,lineHeight:21},listItemContent:{flex:1},listCheckbox:{width:13,height:13,marginTop:4,borderRadius:3,borderWidth:1,borderColor:"#8a8a8e",alignItems:"center",justifyContent:"center"},listCheckboxChecked:{backgroundColor:"#6cb6ff",borderColor:"#6cb6ff"},listCheckmark:{color:"#111",fontSize:10,lineHeight:11,fontWeight:"700"},table:{borderWidth:1,borderColor:"#555",borderRadius:4,marginVertical:4,overflow:"hidden"},tableRow:{flexDirection:"row",borderBottomWidth:1,borderColor:"#555"},tableRowHeader:{backgroundColor:"rgba(255,255,255,0.08)"},tableCell:{flex:1,paddingHorizontal:8,paddingVertical:4,borderRightWidth:1,borderColor:"#555"},tableCellText:{color:"#e0e0e0",fontSize:13},tableCellHeaderText:{color:"#f0f0f0",fontSize:13,fontWeight:"600"}},O=Object.assign({},W,{text:{color:"#d0d0d0",fontSize:15,lineHeight:21}}),_=Object.assign({},W,{text:{color:"#8a8a8e",fontSize:15,lineHeight:21}}),R=[(0,i.gfmTable)(),(0,c.gfmAutolinkLiteral)(),(0,h.gfmTaskListItem)(),(0,y.math)()],F=[(0,s.gfmTableFromMarkdown)(),(0,f.gfmAutolinkLiteralFromMarkdown)(),(0,u.gfmTaskListItemFromMarkdown)(),(0,k.mathFromMarkdown)()];function B(e){const t=e?.text?.fontSize,n=e?.text?.color,o=e?.text?.lineHeight;return{fontSize:"number"==typeof t?t:15,color:"string"==typeof n?n:"#e0e0e0",lineHeight:`${"number"==typeof o?o:21}px`}}const N={inlineMath:({node:e,styles:t})=>(0,I.jsx)("span",{className:"math math-inline",style:B(t),dangerouslySetInnerHTML:{__html:(0,H.renderMathHtml)(String(e.value??""),!1)}},e.key)};let V=!1;function A(){if(V||"undefined"==typeof document)return;V=!0;const e=document.createElement("style");e.id="brane-math-block",e.textContent=H.MATH_BLOCK_CSS,document.head.appendChild(e)}const D={table:({node:e,styles:t,children:n})=>(0,I.jsx)(o.default,{style:t.table,children:n},e.key),tableRow:({node:e,styles:t,children:n})=>(0,I.jsx)(o.default,{style:t.tableRow,children:n},e.key),tableCell:({node:e,styles:t,children:l,parentStack:i})=>{const s=i.length>=2&&"table"===i[1].type&&i[1].children?.[0]===i[0];return(0,I.jsx)(o.default,{style:t.tableCell,children:(0,I.jsx)(n.default,{style:s?t.tableCellHeaderText:t.tableCellText,children:l})},e.key)}},E=(0,t.memo)(function({content:e,foreign:i=!1,system:s=!1,onNarrativePress:c,onProtocolPress:f,onFilePress:h,fileHref:u,imageSrcResolver:y,knownNarrativeIds:k,knownProtocols:V}){const E=(0,z.useMarkdownLinks)(),$=c??E.onNarrativePress,K=f??E.onProtocolPress,q=k??E.knownNarrativeIds,G=V??E.knownProtocols;A();const U=(0,M.useHorizontalPanGuard)(),J=(0,t.useMemo)(()=>{const e=[...F];return q&&e.push((0,j.mentionLinks)(q)),q&&e.push((0,x.narrativeIdLinks)(q)),G&&e.push((0,C.protocolLinks)(G)),e},[q,G]),Q=(0,t.useMemo)(()=>(0,H.prepareMathMarkdown)(e),[e]),X=(0,t.useMemo)(()=>{const e=Object.assign({},D,N);return e.math=({node:e,styles:t})=>(0,I.jsx)("div",Object.assign({className:"math math-display",style:Object.assign({},B(t),{lineHeight:"normal"})},U,{dangerouslySetInnerHTML:{__html:(0,H.renderMathHtml)(String(e.value??""),!0)}}),e.key),e.code=({node:e,styles:t})=>{const n="string"==typeof e.lang?e.lang:null,o="string"==typeof e.value?e.value:"";return(0,I.jsx)("div",{style:{margin:"4px 0"},children:"mermaid"===n?(0,I.jsx)(b.DiagramView,{source:o}):(0,I.jsx)(p.HighlightedCode,{content:o,lang:n})},e.key)},e.listItem=({node:e,styles:t,children:l,extras:i,parentStack:s})=>{const c=e.checked,f=(0,S.listItemRowMarginTop)((0,S.listIsLoose)(s?.[0]),t.paragraph?.marginVertical??0);return(0,I.jsxs)(o.default,{style:f?[t.listItem,{marginTop:f}]:t.listItem,children:[null==c?i?.customListStyleType?i.customListStyleType:(0,I.jsx)(n.default,{style:t.listBullet,children:i?.listStyleType}):(0,I.jsx)(o.default,{style:[t.listCheckbox,c&&t.listCheckboxChecked],children:c?(0,I.jsx)(n.default,{style:t.listCheckmark,children:"\u2713"}):null}),(0,I.jsx)(o.default,{style:t.listItemContent,children:l})]},e.key)},e.paragraph=({node:e,styles:t,parentStack:o,children:l})=>{const i=o?.findIndex(e=>"listItem"===e.type)??-1,s=(0,S.listParagraphOverride)({inListItem:i>=0,firstBlock:i>=0&&o[i].children?.[0]===e,loose:i>=0&&(0,S.listIsLoose)(o[i+1])});return(0,I.jsx)(n.default,{style:s?[t.paragraph,s]:t.paragraph,children:l},e.key)},e.text=({node:e,styles:t,parentStack:o})=>{const l="string"==typeof e.value?e.value.replace(/\n/g," "):e.value,i=o?.find(e=>"heading"===e.type),s=i?t[`heading${i.depth}`]:t.text;return(0,I.jsx)(n.default,{style:s,maxFontSizeMultiplier:1.2,children:l},e.key)},e.link=({node:e,styles:t,children:o})=>{const l=e.url||"",i=l.match(/^brane:\/\/nid\/([^/]+)(?:\/(\d+))?$/)??l.match(new RegExp(`^${x.NID_REF_PATTERN}$`));if(i&&$){const l=i[1],s=i[2]?Number(i[2]):void 0,c=String(e.children?.[0]?.value??"").startsWith("@");return(0,I.jsx)(n.default,Object.assign({style:[t.link,{fontFamily:L,fontSize:13},c&&{fontWeight:"600"}]},(0,w.inAppLinkProps)((0,w.narrativeHref)(l,s),()=>$(l,s)),{children:o}),e.key)}const s=l.match(/^brane:\/\/protocol\/(.+)$/);if(s&&K){const l=decodeURIComponent(s[1]);return(0,I.jsx)(n.default,{style:[t.link,{fontFamily:L,fontSize:13}],onPress:()=>K(l),children:o},e.key)}return l.startsWith(T.FOLD_LINK_SCHEME)?(0,I.jsx)(n.default,{style:[t.text,{color:T.FOLD_COLOR,fontFamily:L,fontSize:13}],children:o},e.key):v.test(l)?l.startsWith("brane://")?(0,I.jsx)(n.default,{style:t.link,children:o},e.key):(0,I.jsx)(n.default,Object.assign({style:t.link},P(l),{children:o}),e.key):!l||l.startsWith("/")?(0,I.jsx)(n.default,{style:t.link,children:o},e.key):h?(0,I.jsx)(n.default,Object.assign({style:t.link},(0,w.inAppLinkProps)(u?.(l),()=>h(l)),{children:o}),e.key):(0,I.jsx)(n.default,{style:t.link,children:o},e.key)},y&&(e.image=({node:e,styles:t})=>{const o=e.url||"",l=y(o);return l?(0,I.jsx)("img",{src:l,alt:e.alt||"",style:{maxWidth:"100%",borderRadius:4,display:"block",margin:"4px 0"}},e.key):(0,I.jsx)(n.default,{style:t.text,children:e.alt||o},e.key)}),e},[$,K,h,u,y,U]);return(0,I.jsx)(l.Markdown,{markdown:Q,styles:s?_:i?O:W,mergeStyle:!1,syntaxExtensions:R,extensions:J,renderRules:X})})},786,[11,105,13,410,116,122,787,858,863,926,929,935,938,940,946,948,949,952,954,955,956,957,760,950,759,749,6]);
889
+ __d(function(g,r,_i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"darkMarkdownStyles",{enumerable:!0,get:function(){return W}}),Object.defineProperty(_e,"foreignMarkdownStyles",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_e,"systemMarkdownStyles",{enumerable:!0,get:function(){return _}}),Object.defineProperty(_e,"MarkdownContent",{enumerable:!0,get:function(){return E}});var t=r(d[0]),n=e(r(d[1])),o=e(r(d[2]));r(d[3]),r(d[4]);e(r(d[5]));var l=r(d[6]),i=r(d[7]),s=r(d[8]),c=r(d[9]),f=r(d[10]),h=r(d[11]),u=r(d[12]),y=r(d[13]),k=r(d[14]),p=r(d[15]),b=r(d[16]),x=r(d[17]),j=r(d[18]),S=r(d[19]),C=r(d[20]),H=r(d[21]),w=r(d[22]),z=r(d[23]),M=r(d[24]),T=r(d[25]),I=r(d[26]);const L="monospace",v=/^[a-z][a-z0-9+.-]*:/i;function P(e){return{href:e,hrefAttrs:{target:"_blank",rel:"noopener noreferrer"}}}const W={root:{marginVertical:-2},text:{color:"#e0e0e0",fontSize:15,lineHeight:21},paragraph:{marginVertical:8,width:"100%"},strong:{color:"#f0f0f0",fontWeight:"600"},emphasis:{fontStyle:"italic"},link:{color:"#6cb6ff",textDecorationLine:"underline"},heading1:{color:"#f0f0f0",fontSize:26,lineHeight:32,fontWeight:"700",marginTop:16,marginBottom:8},heading2:{color:"#f0f0f0",fontSize:22,lineHeight:28,fontWeight:"700",marginTop:14,marginBottom:6},heading3:{color:"#f0f0f0",fontSize:19,lineHeight:25,fontWeight:"700",marginTop:12,marginBottom:4},heading4:{color:"#e8e8e8",fontSize:17,lineHeight:23,fontWeight:"600",marginTop:10,marginBottom:4},heading5:{color:"#e8e8e8",fontSize:16,lineHeight:22,fontWeight:"600",marginTop:8,marginBottom:2},heading6:{color:"#ccc",fontSize:15,lineHeight:21,fontWeight:"600",marginTop:6,marginBottom:2},inlineCode:{color:"#f8c555",backgroundColor:"#1a1a1a",fontFamily:L,fontSize:13},code:{backgroundColor:"#0d1117",color:"#e0e0e0",fontFamily:L,fontSize:13,padding:10},blockquote:{borderColor:"#555",borderLeftWidth:3,paddingHorizontal:10,marginVertical:2,backgroundColor:"transparent"},thematicBreak:{backgroundColor:"#444",marginVertical:6,height:1},list:{},listItem:{flexDirection:"row",alignItems:"flex-start",justifyContent:"flex-start",gap:6},listBullet:{color:"#e0e0e0",fontSize:15,lineHeight:21},listItemContent:{flex:1},listCheckbox:{width:13,height:13,marginTop:4,borderRadius:3,borderWidth:1,borderColor:"#8a8a8e",alignItems:"center",justifyContent:"center"},listCheckboxChecked:{backgroundColor:"#6cb6ff",borderColor:"#6cb6ff"},listCheckmark:{color:"#111",fontSize:10,lineHeight:11,fontWeight:"700"},table:{borderWidth:1,borderColor:"#555",borderRadius:4,marginVertical:4,overflow:"hidden"},tableRow:{flexDirection:"row",borderBottomWidth:1,borderColor:"#555"},tableRowHeader:{backgroundColor:"rgba(255,255,255,0.08)"},tableCell:{flex:1,paddingHorizontal:8,paddingVertical:4,borderRightWidth:1,borderColor:"#555"},tableCellText:{color:"#e0e0e0",fontSize:13},tableCellHeaderText:{color:"#f0f0f0",fontSize:13,fontWeight:"600"}},O=Object.assign({},W,{text:{color:"#d0d0d0",fontSize:15,lineHeight:21}}),_=Object.assign({},W,{text:{color:"#8a8a8e",fontSize:15,lineHeight:21}}),R=[(0,i.gfmTable)(),(0,c.gfmAutolinkLiteral)(),(0,h.gfmTaskListItem)(),(0,y.math)()],F=[(0,s.gfmTableFromMarkdown)(),(0,f.gfmAutolinkLiteralFromMarkdown)(),(0,u.gfmTaskListItemFromMarkdown)(),(0,k.mathFromMarkdown)()];function B(e){const t=e?.text?.fontSize,n=e?.text?.color,o=e?.text?.lineHeight;return{fontSize:"number"==typeof t?t:15,color:"string"==typeof n?n:"#e0e0e0",lineHeight:`${"number"==typeof o?o:21}px`}}const N={inlineMath:({node:e,styles:t})=>(0,I.jsx)("span",{className:"math math-inline",style:B(t),dangerouslySetInnerHTML:{__html:(0,H.renderMathHtml)(String(e.value??""),!1)}},e.key)};let V=!1;function A(){if(V||"undefined"==typeof document)return;V=!0;const e=document.createElement("style");e.id="brane-math-block",e.textContent=H.MATH_BLOCK_CSS,document.head.appendChild(e)}const D={table:({node:e,styles:t,children:n})=>(0,I.jsx)(o.default,{style:t.table,children:n},e.key),tableRow:({node:e,styles:t,children:n})=>(0,I.jsx)(o.default,{style:t.tableRow,children:n},e.key),tableCell:({node:e,styles:t,children:l,parentStack:i})=>{const s=i.length>=2&&"table"===i[1].type&&i[1].children?.[0]===i[0];return(0,I.jsx)(o.default,{style:t.tableCell,children:(0,I.jsx)(n.default,{style:s?t.tableCellHeaderText:t.tableCellText,children:l})},e.key)}},E=(0,t.memo)(function({content:e,foreign:i=!1,system:s=!1,onNarrativePress:c,onProtocolPress:f,onFilePress:h,fileHref:u,imageSrcResolver:y,knownNarrativeIds:k,knownProtocols:V}){const E=(0,z.useMarkdownLinks)(),$=c??E.onNarrativePress,K=f??E.onProtocolPress,q=k??E.knownNarrativeIds,G=V??E.knownProtocols;A();const U=(0,M.useHorizontalPanGuard)(),J=(0,t.useMemo)(()=>{const e=[...F];return q&&e.push((0,j.mentionLinks)(q)),q&&e.push((0,x.narrativeIdLinks)(q)),G&&e.push((0,C.protocolLinks)(G)),e},[q,G]),Q=(0,t.useMemo)(()=>(0,H.prepareMathMarkdown)(e),[e]),X=(0,t.useMemo)(()=>{const e=Object.assign({},D,N);return e.math=({node:e,styles:t})=>(0,I.jsx)("div",Object.assign({className:"math math-display",style:Object.assign({},B(t),{lineHeight:"normal"})},U,{dangerouslySetInnerHTML:{__html:(0,H.renderMathHtml)(String(e.value??""),!0)}}),e.key),e.code=({node:e,styles:t})=>{const n="string"==typeof e.lang?e.lang:null,o="string"==typeof e.value?e.value:"";return(0,I.jsx)("div",{style:{margin:"4px 0"},children:"mermaid"===n?(0,I.jsx)(b.DiagramView,{source:o}):(0,I.jsx)(p.HighlightedCode,{content:o,lang:n})},e.key)},e.listItem=({node:e,styles:t,children:l,extras:i,parentStack:s})=>{const c=e.checked,f=(0,S.listItemRowMarginTop)((0,S.listIsLoose)(s?.[0]),t.paragraph?.marginVertical??0);return(0,I.jsxs)(o.default,{style:f?[t.listItem,{marginTop:f}]:t.listItem,children:[null==c?i?.customListStyleType?i.customListStyleType:(0,I.jsx)(n.default,{style:t.listBullet,children:i?.listStyleType}):(0,I.jsx)(o.default,{style:[t.listCheckbox,c&&t.listCheckboxChecked],children:c?(0,I.jsx)(n.default,{style:t.listCheckmark,children:"\u2713"}):null}),(0,I.jsx)(o.default,{style:t.listItemContent,children:l})]},e.key)},e.paragraph=({node:e,styles:t,parentStack:o,children:l})=>{const i=o?.findIndex(e=>"listItem"===e.type)??-1,s=(0,S.listParagraphOverride)({inListItem:i>=0,firstBlock:i>=0&&o[i].children?.[0]===e,loose:i>=0&&(0,S.listIsLoose)(o[i+1])});return(0,I.jsx)(n.default,{style:s?[t.paragraph,s]:t.paragraph,children:l},e.key)},e.text=({node:e,styles:t,parentStack:o})=>{const l="string"==typeof e.value?e.value.replace(/\n/g," "):e.value,i=o?.find(e=>"heading"===e.type),s=i?t[`heading${i.depth}`]:t.text;return(0,I.jsx)(n.default,{style:s,maxFontSizeMultiplier:1.2,children:l},e.key)},e.link=({node:e,styles:t,children:o})=>{const l=e.url||"",i=l.match(/^brane:\/\/nid\/([^/]+)(?:\/(\d+))?$/)??l.match(new RegExp(`^${x.NID_REF_PATTERN}$`));if(i&&$){const l=i[1],s=i[2]?Number(i[2]):void 0,c=String(e.children?.[0]?.value??"").startsWith("@");return(0,I.jsx)(n.default,Object.assign({style:[t.link,{fontFamily:L,fontSize:13},c&&{fontWeight:"600"}]},(0,w.inAppLinkProps)((0,w.narrativeHref)(l,s),()=>$(l,s)),{children:o}),e.key)}const s=l.match(/^brane:\/\/protocol\/(.+)$/);if(s&&K){const l=decodeURIComponent(s[1]);return(0,I.jsx)(n.default,{style:[t.link,{fontFamily:L,fontSize:13}],onPress:()=>K(l),children:o},e.key)}return l.startsWith(T.FOLD_LINK_SCHEME)?(0,I.jsx)(n.default,{style:[t.text,{color:T.FOLD_COLOR,fontFamily:L,fontSize:13}],children:o},e.key):v.test(l)?l.startsWith("brane://")?(0,I.jsx)(n.default,{style:t.link,children:o},e.key):(0,I.jsx)(n.default,Object.assign({style:t.link},P(l),{children:o}),e.key):!l||l.startsWith("/")?(0,I.jsx)(n.default,{style:t.link,children:o},e.key):h?(0,I.jsx)(n.default,Object.assign({style:t.link},(0,w.inAppLinkProps)(u?.(l),()=>h(l)),{children:o}),e.key):(0,I.jsx)(n.default,{style:t.link,children:o},e.key)},y&&(e.image=({node:e,styles:t})=>{const o=e.url||"",l=y(o);return l?(0,I.jsx)("img",{src:l,alt:e.alt||"",style:{maxWidth:"100%",borderRadius:4,display:"block",margin:"4px 0"}},e.key):(0,I.jsx)(n.default,{style:t.text,children:e.alt||o},e.key)}),e},[$,K,h,u,y,U]);return(0,I.jsx)(l.Markdown,{markdown:Q,styles:s?_:i?O:W,mergeStyle:!1,syntaxExtensions:R,extensions:J,renderRules:X})})},786,[11,105,13,410,116,122,787,858,863,926,929,935,938,940,946,948,949,952,954,955,956,957,761,950,760,751,6]);
890
890
  __d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"Markdown",{enumerable:!0,get:function(){return u.default}}),r(d[0]);var e,t=r(d[1]),u=(e=t)&&e.__esModule?e:{default:e}},787,[788,789]);
891
891
  __d(function(g,r,i,a,m,e,d){},788,[]);
892
892
  __d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return c}});var e,t=r(d[0]),n=r(d[1]),s=r(d[2]),l=(e=s)&&e.__esModule?e:{default:e},o=r(d[3]),u=r(d[4]);const y=(0,t.memo)(({markdown:e,debug:t,renderRules:s,listBulletStyle:y,styles:c,mergeStyle:f,customBulletElement:k,onLinkPress:_,extensions:b=[],syntaxExtensions:w=[]})=>{const x=(0,n.fromMarkdown)(e,{extensions:w,mdastExtensions:[(0,u.resolveReference)(),(0,o.getKeyFromMarkdown)(),...b]});return new l.default({renderRules:s,debug:t,styles:c,mergeStyle:f,listBulletStyle:y,customBulletElement:k,onLinkPress:_}).render(x)});y.displayName='Markdown';var c=y},789,[11,790,851,856,857]);
@@ -1048,8 +1048,8 @@ __d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',
1048
1048
  __d(function(e,t,r,a,n,i,o){"use strict";Object.defineProperty(i,'__esModule',{value:!0}),Object.defineProperty(i,"ParseError",{enumerable:!0,get:function(){return s}}),Object.defineProperty(i,"SETTINGS_SCHEMA",{enumerable:!0,get:function(){return v}}),Object.defineProperty(i,"__defineFunction",{enumerable:!0,get:function(){return Xt}}),Object.defineProperty(i,"__defineMacro",{enumerable:!0,get:function(){return Fa}}),Object.defineProperty(i,"__defineSymbol",{enumerable:!0,get:function(){return Se}}),Object.defineProperty(i,"__domTree",{enumerable:!0,get:function(){return ti}}),Object.defineProperty(i,"__parse",{enumerable:!0,get:function(){return Zn}}),Object.defineProperty(i,"__renderToDomTree",{enumerable:!0,get:function(){return Jn}}),Object.defineProperty(i,"__renderToHTMLTree",{enumerable:!0,get:function(){return Qn}}),Object.defineProperty(i,"__setFontMetrics",{enumerable:!0,get:function(){return be}}),Object.defineProperty(i,"default",{enumerable:!0,get:function(){return ri}}),Object.defineProperty(i,"render",{enumerable:!0,get:function(){return Wn}}),Object.defineProperty(i,"renderToString",{enumerable:!0,get:function(){return $n}}),Object.defineProperty(i,"version",{enumerable:!0,get:function(){return ei}});class s extends Error{constructor(e,t){var r,a,n="KaTeX parse error: "+e,i=t&&t.loc;if(i&&i.start<=i.end){var o=i.lexer.input;r=i.start,a=i.end,r===o.length?n+=" at end of input: ":n+=" at position "+(r+1)+": ";var l=o.slice(r,a).replace(/[^]/g,"$&\u0332");n+=(r>15?"\u2026"+o.slice(r-15,r):o.slice(0,r))+l+(a+15<o.length?o.slice(a,a+15)+"\u2026":o.slice(a))}super(n),this.name="ParseError",this.position=void 0,this.length=void 0,this.rawMessage=void 0,Object.setPrototypeOf(this,s.prototype),this.position=r,null!=r&&null!=a&&(this.length=a-r),this.rawMessage=e}}var l=/([A-Z])/g,h=e=>e.replace(l,"-$1").toLowerCase(),m={"&":"&amp;",">":"&gt;","<":"&lt;","\"":"&quot;","'":"&#x27;"},c=/[&><"']/g,u=e=>String(e).replace(c,e=>m[e]),p=e=>"ordgroup"===e.type||"color"===e.type?1===e.body.length?p(e.body[0]):e:"font"===e.type?p(e.body):e,d=new Set(["mathord","textord","atom"]),g=e=>d.has(p(e).type),f=e=>{var t=/^[\x00-\x20]*([^\\/#?]*?)(:|&#0*58|&#x0*3a|&colon)/i.exec(e);return t?":"!==t[2]?null:/^[a-zA-Z][a-zA-Z0-9+\-.]*$/.test(t[1])?t[1].toLowerCase():null:"_relative"},v={displayMode:{type:"boolean",description:"Render math in display mode, which puts the math in display style (so \\int and \\sum are large, for example), and centers the math on the page on its own line.",cli:"-d, --display-mode"},output:{type:{enum:["htmlAndMathml","html","mathml"]},description:"Determines the markup language of the output.",cli:"-F, --format <type>"},leqno:{type:"boolean",description:"Render display math in leqno style (left-justified tags)."},fleqn:{type:"boolean",description:"Render display math flush left."},throwOnError:{type:"boolean",default:!0,cli:"-t, --no-throw-on-error",cliDescription:"Render errors (in the color given by --error-color) instead of throwing a ParseError exception when encountering an error."},errorColor:{type:"string",default:"#cc0000",cli:"-c, --error-color <color>",cliDescription:"A color string given in the format 'rgb' or 'rrggbb' (no #). This option determines the color of errors rendered by the -t option.",cliProcessor:e=>"#"+e},macros:{type:"object",cli:"-m, --macro <def>",cliDescription:"Define custom macro of the form '\\foo:expansion' (use multiple -m arguments for multiple macros).",cliDefault:[],cliProcessor:(e,t)=>(t.push(e),t)},minRuleThickness:{type:"number",description:"Specifies a minimum thickness, in ems, for fraction lines, `\\sqrt` top lines, `{array}` vertical lines, `\\hline`, `\\hdashline`, `\\underline`, `\\overline`, and the borders of `\\fbox`, `\\boxed`, and `\\fcolorbox`.",processor:e=>Math.max(0,e),cli:"--min-rule-thickness <size>",cliProcessor:parseFloat},colorIsTextColor:{type:"boolean",description:"Makes \\color behave like LaTeX's 2-argument \\textcolor, instead of LaTeX's one-argument \\color mode change.",cli:"-b, --color-is-text-color"},strict:{type:[{enum:["warn","ignore","error"]},"boolean","function"],description:"Turn on strict / LaTeX faithfulness mode, which throws an error if the input uses features that are not supported by LaTeX.",cli:"-S, --strict",cliDefault:!1},trust:{type:["boolean","function"],description:"Trust the input, enabling all HTML features such as \\url.",cli:"-T, --trust"},maxSize:{type:"number",default:1/0,description:"If non-zero, all user-specified sizes, e.g. in \\rule{500em}{500em}, will be capped to maxSize ems. Otherwise, elements and spaces can be arbitrarily large",processor:e=>Math.max(0,e),cli:"-s, --max-size <n>",cliProcessor:parseInt},maxExpand:{type:"number",default:1e3,description:"Limit the number of macro expansions to the specified number, to prevent e.g. infinite macro loops. If set to Infinity, the macro expander will try to fully expand as in LaTeX.",processor:e=>Math.max(0,e),cli:"-e, --max-expand <n>",cliProcessor:e=>"Infinity"===e?1/0:parseInt(e)},globalGroup:{type:"boolean",cli:!1}};function b(e){if('string'!=typeof e)return e.enum[0];switch(e){case'boolean':return!1;case'string':return'';case'number':return 0;case'object':return{};default:throw new Error("Unexpected schema type; settings must declare an explicit default.")}}function y(e){return Object.prototype.hasOwnProperty.call(e,"default")&&void 0!==e.default?e.default:b(Array.isArray(e.type)?e.type[0]:e.type)}function x(e,t,r,a){var n=Object.prototype.hasOwnProperty.call(r,t)?r[t]:void 0,i=Object.prototype.hasOwnProperty.call(a,"processor")?a.processor:void 0;e[t]=void 0!==n?i?i(n):n:y(a)}class w{constructor(e){for(var t of(void 0===e&&(e={}),this.displayMode=void 0,this.output=void 0,this.leqno=void 0,this.fleqn=void 0,this.throwOnError=void 0,this.errorColor=void 0,this.macros=void 0,this.minRuleThickness=void 0,this.colorIsTextColor=void 0,this.strict=void 0,this.trust=void 0,this.maxSize=void 0,this.maxExpand=void 0,this.globalGroup=void 0,e=e||{},Object.keys(v))){var r=v[t];r&&x(this,t,e,r)}}reportNonstrict(e,t,r){var a=this.strict;if("function"==typeof a&&(a=a(e,t,r)),a&&"ignore"!==a){if(!0===a||"error"===a)throw new s("LaTeX-incompatible input and strict mode is set to 'error': "+t+" ["+e+"]",r);"warn"===a?"undefined"!=typeof console&&console.warn("LaTeX-incompatible input and strict mode is set to 'warn': "+t+" ["+e+"]"):"undefined"!=typeof console&&console.warn("LaTeX-incompatible input and strict mode is set to unrecognized '"+a+"': "+t+" ["+e+"]")}}useStrictBehavior(e,t,r){var a=this.strict;if("function"==typeof a)try{a=a(e,t,r)}catch(e){a="error"}return!(!a||"ignore"===a)&&(!0===a||"error"===a||("warn"===a?("undefined"!=typeof console&&console.warn("LaTeX-incompatible input and strict mode is set to 'warn': "+t+" ["+e+"]"),!1):("undefined"!=typeof console&&console.warn("LaTeX-incompatible input and strict mode is set to unrecognized '"+a+"': "+t+" ["+e+"]"),!1)))}isTrusted(e){if("url"in e&&e.url&&!e.protocol){var t=f(e.url);if(null==t)return!1;e.protocol=t}var r="function"==typeof this.trust?this.trust(e):this.trust;return Boolean(r)}}class k{constructor(e,t,r){this.id=void 0,this.size=void 0,this.cramped=void 0,this.id=e,this.size=t,this.cramped=r}sup(){return S[z[this.id]]}sub(){return S[M[this.id]]}fracNum(){return S[A[this.id]]}fracDen(){return S[T[this.id]]}cramp(){return S[C[this.id]]}text(){return S[B[this.id]]}isTight(){return this.size>=2}}var S=[new k(0,0,!1),new k(1,0,!0),new k(2,1,!1),new k(3,1,!0),new k(4,2,!1),new k(5,2,!0),new k(6,3,!1),new k(7,3,!0)],z=[4,5,4,5,6,7,6,7],M=[5,5,5,5,7,7,7,7],A=[2,3,4,5,6,7,6,7],T=[3,3,5,5,7,7,7,7],C=[1,1,3,3,5,5,7,7],B=[0,1,2,3,2,3,2,3],q={DISPLAY:S[0],TEXT:S[2],SCRIPT:S[4],SCRIPTSCRIPT:S[6]},I=[{name:'latin',blocks:[[256,591],[768,879]]},{name:'cyrillic',blocks:[[1024,1279]]},{name:'armenian',blocks:[[1328,1423]]},{name:'brahmic',blocks:[[2304,4255]]},{name:'georgian',blocks:[[4256,4351]]},{name:"cjk",blocks:[[12288,12543],[19968,40879],[65280,65376]]},{name:'hangul',blocks:[[44032,55215]]}];function O(e){for(var t=0;t<I.length;t++)for(var r=I[t],a=0;a<r.blocks.length;a++){var n=r.blocks[a];if(e>=n[0]&&e<=n[1])return r.name}return null}var R=[];function E(e){for(var t=0;t<R.length;t+=2)if(e>=R[t]&&e<=R[t+1])return!0;return!1}I.forEach(e=>e.blocks.forEach(e=>R.push(...e)));var H=e=>e+" "+e,N=80,D=function(e,t){return"M95,"+(622+e+t)+"\nc-2.7,0,-7.17,-2.7,-13.5,-8c-5.8,-5.3,-9.5,-10,-9.5,-14\nc0,-2,0.3,-3.3,1,-4c1.3,-2.7,23.83,-20.7,67.5,-54\nc44.2,-33.3,65.8,-50.3,66.5,-51c1.3,-1.3,3,-2,5,-2c4.7,0,8.7,3.3,12,10\ns173,378,173,378c0.7,0,35.3,-71,104,-213c68.7,-142,137.5,-285,206.5,-429\nc69,-144,104.5,-217.7,106.5,-221\nl"+e/2.075+" -"+e+"\nc5.3,-9.3,12,-14,20,-14\nH400000v"+(40+e)+"H845.2724\ns-225.272,467,-225.272,467s-235,486,-235,486c-2.7,4.7,-9,7,-19,7\nc-6,0,-10,-1,-12,-3s-194,-422,-194,-422s-65,47,-65,47z\nM"+(834+e)+" "+t+"h400000v"+(40+e)+"h-400000z"},L=function(e,t){return"M263,"+(601+e+t)+"c0.7,0,18,39.7,52,119\nc34,79.3,68.167,158.7,102.5,238c34.3,79.3,51.8,119.3,52.5,120\nc340,-704.7,510.7,-1060.3,512,-1067\nl"+e/2.084+" -"+e+"\nc4.7,-7.3,11,-11,19,-11\nH40000v"+(40+e)+"H1012.3\ns-271.3,567,-271.3,567c-38.7,80.7,-84,175,-136,283c-52,108,-89.167,185.3,-111.5,232\nc-22.3,46.7,-33.8,70.3,-34.5,71c-4.7,4.7,-12.3,7,-23,7s-12,-1,-12,-1\ns-109,-253,-109,-253c-72.7,-168,-109.3,-252,-110,-252c-10.7,8,-22,16.7,-34,26\nc-22,17.3,-33.3,26,-34,26s-26,-26,-26,-26s76,-59,76,-59s76,-60,76,-60z\nM"+(1001+e)+" "+t+"h400000v"+(40+e)+"h-400000z"},P=function(e,t){return"M983 "+(10+e+t)+"\nl"+e/3.13+" -"+e+"\nc4,-6.7,10,-10,18,-10 H400000v"+(40+e)+"\nH1013.1s-83.4,268,-264.1,840c-180.7,572,-277,876.3,-289,913c-4.7,4.7,-12.7,7,-24,7\ns-12,0,-12,0c-1.3,-3.3,-3.7,-11.7,-7,-25c-35.3,-125.3,-106.7,-373.3,-214,-744\nc-10,12,-21,25,-33,39s-32,39,-32,39c-6,-5.3,-15,-14,-27,-26s25,-30,25,-30\nc26.7,-32.7,52,-63,76,-91s52,-60,52,-60s208,722,208,722\nc56,-175.3,126.3,-397.3,211,-666c84.7,-268.7,153.8,-488.2,207.5,-658.5\nc53.7,-170.3,84.5,-266.8,92.5,-289.5z\nM"+(1001+e)+" "+t+"h400000v"+(40+e)+"h-400000z"},F=function(e,t){return"M424,"+(2398+e+t)+"\nc-1.3,-0.7,-38.5,-172,-111.5,-514c-73,-342,-109.8,-513.3,-110.5,-514\nc0,-2,-10.7,14.3,-32,49c-4.7,7.3,-9.8,15.7,-15.5,25c-5.7,9.3,-9.8,16,-12.5,20\ns-5,7,-5,7c-4,-3.3,-8.3,-7.7,-13,-13s-13,-13,-13,-13s76,-122,76,-122s77,-121,77,-121\ns209,968,209,968c0,-2,84.7,-361.7,254,-1079c169.3,-717.3,254.7,-1077.7,256,-1081\nl"+e/4.223+" -"+e+"c4,-6.7,10,-10,18,-10 H400000\nv"+(40+e)+"H1014.6\ns-87.3,378.7,-272.6,1166c-185.3,787.3,-279.3,1182.3,-282,1185\nc-2,6,-10,9,-24,9\nc-8,0,-12,-0.7,-12,-2z M"+(1001+e)+" "+t+"\nh400000v"+(40+e)+"h-400000z"},V=function(e,t){return"M473,"+(2713+e+t)+"\nc339.3,-1799.3,509.3,-2700,510,-2702 l"+e/5.298+" -"+e+"\nc3.3,-7.3,9.3,-11,18,-11 H400000v"+(40+e)+"H1017.7\ns-90.5,478,-276.2,1466c-185.7,988,-279.5,1483,-281.5,1485c-2,6,-10,9,-24,9\nc-8,0,-12,-0.7,-12,-2c0,-1.3,-5.3,-32,-16,-92c-50.7,-293.3,-119.7,-693.3,-207,-1200\nc0,-1.3,-5.3,8.7,-16,30c-10.7,21.3,-21.3,42.7,-32,64s-16,33,-16,33s-26,-26,-26,-26\ns76,-153,76,-153s77,-151,77,-151c0.7,0.7,35.7,202,105,604c67.3,400.7,102,602.7,104,\n606zM"+(1001+e)+" "+t+"h400000v"+(40+e)+"H1017.7z"},G=function(e,t,r){return"M702 "+(e+t)+"H400000"+(40+e)+"\nH742v"+(r-54-t-e)+"l-4 4-4 4c-.667.7 -2 1.5-4 2.5s-4.167 1.833-6.5 2.5-5.5 1-9.5 1\nh-12l-28-84c-16.667-52-96.667 -294.333-240-727l-212 -643 -85 170\nc-4-3.333-8.333-7.667-13 -13l-13-13l77-155 77-156c66 199.333 139 419.667\n219 661 l218 661zM702 "+t+"H400000v"+(40+e)+"H742z"},j=function(e,t,r){t*=1e3;var a="";switch(e){case"sqrtMain":a=D(t,N);break;case"sqrtSize1":a=L(t,N);break;case"sqrtSize2":a=P(t,N);break;case"sqrtSize3":a=F(t,N);break;case"sqrtSize4":a=V(t,N);break;case"sqrtTall":a=G(t,N,r)}return a},U=function(e,t){switch(e){case"\u239c":return H("M291 0 H417 V"+t+" H291z");case"\u2223":return H("M145 0 H188 V"+t+" H145z");case"\u2225":return H("M145 0 H188 V"+t+" H145z")+H("M367 0 H410 V"+t+" H367z");case"\u239f":return H("M457 0 H583 V"+t+" H457z");case"\u23a2":return H("M319 0 H403 V"+t+" H319z");case"\u23a5":return H("M263 0 H347 V"+t+" H263z");case"\u23aa":return H("M384 0 H504 V"+t+" H384z");case"\u23d0":return H("M312 0 H355 V"+t+" H312z");case"\u2016":return H("M257 0 H300 V"+t+" H257z")+H("M478 0 H521 V"+t+" H478z");default:return""}},_={doubleleftarrow:"M262 157\nl10-10c34-36 62.7-77 86-123 3.3-8 5-13.3 5-16 0-5.3-6.7-8-20-8-7.3\n 0-12.2.5-14.5 1.5-2.3 1-4.8 4.5-7.5 10.5-49.3 97.3-121.7 169.3-217 216-28\n 14-57.3 25-88 33-6.7 2-11 3.8-13 5.5-2 1.7-3 4.2-3 7.5s1 5.8 3 7.5\nc2 1.7 6.3 3.5 13 5.5 68 17.3 128.2 47.8 180.5 91.5 52.3 43.7 93.8 96.2 124.5\n 157.5 9.3 8 15.3 12.3 18 13h6c12-.7 18-4 18-10 0-2-1.7-7-5-15-23.3-46-52-87\n-86-123l-10-10h399738v-40H218c328 0 0 0 0 0l-10-8c-26.7-20-65.7-43-117-69 2.7\n-2 6-3.7 10-5 36.7-16 72.3-37.3 107-64l10-8h399782v-40z\nm8 0v40h399730v-40zm0 194v40h399730v-40z",doublerightarrow:"M399738 392l\n-10 10c-34 36-62.7 77-86 123-3.3 8-5 13.3-5 16 0 5.3 6.7 8 20 8 7.3 0 12.2-.5\n 14.5-1.5 2.3-1 4.8-4.5 7.5-10.5 49.3-97.3 121.7-169.3 217-216 28-14 57.3-25 88\n-33 6.7-2 11-3.8 13-5.5 2-1.7 3-4.2 3-7.5s-1-5.8-3-7.5c-2-1.7-6.3-3.5-13-5.5-68\n-17.3-128.2-47.8-180.5-91.5-52.3-43.7-93.8-96.2-124.5-157.5-9.3-8-15.3-12.3-18\n-13h-6c-12 .7-18 4-18 10 0 2 1.7 7 5 15 23.3 46 52 87 86 123l10 10H0v40h399782\nc-328 0 0 0 0 0l10 8c26.7 20 65.7 43 117 69-2.7 2-6 3.7-10 5-36.7 16-72.3 37.3\n-107 64l-10 8H0v40zM0 157v40h399730v-40zm0 194v40h399730v-40z",leftarrow:"M400000 241H110l3-3c68.7-52.7 113.7-120\n 135-202 4-14.7 6-23 6-25 0-7.3-7-11-21-11-8 0-13.2.8-15.5 2.5-2.3 1.7-4.2 5.8\n-5.5 12.5-1.3 4.7-2.7 10.3-4 17-12 48.7-34.8 92-68.5 130S65.3 228.3 18 247\nc-10 4-16 7.7-18 11 0 8.7 6 14.3 18 17 47.3 18.7 87.8 47 121.5 85S196 441.3 208\n 490c.7 2 1.3 5 2 9s1.2 6.7 1.5 8c.3 1.3 1 3.3 2 6s2.2 4.5 3.5 5.5c1.3 1 3.3\n 1.8 6 2.5s6 1 10 1c14 0 21-3.7 21-11 0-2-2-10.3-6-25-20-79.3-65-146.7-135-202\n l-3-3h399890zM100 241v40h399900v-40z",leftbrace:"M6 548l-6-6v-35l6-11c56-104 135.3-181.3 238-232 57.3-28.7 117\n-45 179-50h399577v120H403c-43.3 7-81 15-113 26-100.7 33-179.7 91-237 174-2.7\n 5-6 9-10 13-.7 1-7.3 1-20 1H6z",leftbraceunder:"M0 6l6-6h17c12.688 0 19.313.3 20 1 4 4 7.313 8.3 10 13\n 35.313 51.3 80.813 93.8 136.5 127.5 55.688 33.7 117.188 55.8 184.5 66.5.688\n 0 2 .3 4 1 18.688 2.7 76 4.3 172 5h399450v120H429l-6-1c-124.688-8-235-61.7\n-331-161C60.687 138.7 32.312 99.3 7 54L0 41V6z",leftgroup:"M400000 80\nH435C64 80 168.3 229.4 21 260c-5.9 1.2-18 0-18 0-2 0-3-1-3-3v-38C76 61 257 0\n 435 0h399565z",leftgroupunder:"M400000 262\nH435C64 262 168.3 112.6 21 82c-5.9-1.2-18 0-18 0-2 0-3 1-3 3v38c76 158 257 219\n 435 219h399565z",leftharpoon:"M0 267c.7 5.3 3 10 7 14h399993v-40H93c3.3\n-3.3 10.2-9.5 20.5-18.5s17.8-15.8 22.5-20.5c50.7-52 88-110.3 112-175 4-11.3 5\n-18.3 3-21-1.3-4-7.3-6-18-6-8 0-13 .7-15 2s-4.7 6.7-8 16c-42 98.7-107.3 174.7\n-196 228-6.7 4.7-10.7 8-12 10-1.3 2-2 5.7-2 11zm100-26v40h399900v-40z",leftharpoonplus:"M0 267c.7 5.3 3 10 7 14h399993v-40H93c3.3-3.3 10.2-9.5\n 20.5-18.5s17.8-15.8 22.5-20.5c50.7-52 88-110.3 112-175 4-11.3 5-18.3 3-21-1.3\n-4-7.3-6-18-6-8 0-13 .7-15 2s-4.7 6.7-8 16c-42 98.7-107.3 174.7-196 228-6.7 4.7\n-10.7 8-12 10-1.3 2-2 5.7-2 11zm100-26v40h399900v-40zM0 435v40h400000v-40z\nm0 0v40h400000v-40z",leftharpoondown:"M7 241c-4 4-6.333 8.667-7 14 0 5.333.667 9 2 11s5.333\n 5.333 12 10c90.667 54 156 130 196 228 3.333 10.667 6.333 16.333 9 17 2 .667 5\n 1 9 1h5c10.667 0 16.667-2 18-6 2-2.667 1-9.667-3-21-32-87.333-82.667-157.667\n-152-211l-3-3h399907v-40zM93 281 H400000 v-40L7 241z",leftharpoondownplus:"M7 435c-4 4-6.3 8.7-7 14 0 5.3.7 9 2 11s5.3 5.3 12\n 10c90.7 54 156 130 196 228 3.3 10.7 6.3 16.3 9 17 2 .7 5 1 9 1h5c10.7 0 16.7\n-2 18-6 2-2.7 1-9.7-3-21-32-87.3-82.7-157.7-152-211l-3-3h399907v-40H7zm93 0\nv40h399900v-40zM0 241v40h399900v-40zm0 0v40h399900v-40z",lefthook:"M400000 281 H103s-33-11.2-61-33.5S0 197.3 0 164s14.2-61.2 42.5\n-83.5C70.8 58.2 104 47 142 47 c16.7 0 25 6.7 25 20 0 12-8.7 18.7-26 20-40 3.3\n-68.7 15.7-86 37-10 12-15 25.3-15 40 0 22.7 9.8 40.7 29.5 54 19.7 13.3 43.5 21\n 71.5 23h399859zM103 281v-40h399897v40z",leftlinesegment:H("M40 281 V428 H0 V94 H40 V241 H400000 v40z"),leftbracketunder:H("M0 0 h120 V290 H399995 v120 H0z"),leftbracketover:H("M0 440 h120 V150 H399995 v-120 H0z"),leftmapsto:H("M40 281 V448H0V74H40V241H400000v40z"),leftToFrom:"M0 147h400000v40H0zm0 214c68 40 115.7 95.7 143 167h22c15.3 0 23\n-.3 23-1 0-1.3-5.3-13.7-16-37-18-35.3-41.3-69-70-101l-7-8h399905v-40H95l7-8\nc28.7-32 52-65.7 70-101 10.7-23.3 16-35.7 16-37 0-.7-7.7-1-23-1h-22C115.7 265.3\n 68 321 0 361zm0-174v-40h399900v40zm100 154v40h399900v-40z",longequal:H("M0 50 h400000 v40H0z m0 194h40000v40H0z"),midbrace:"M200428 334\nc-100.7-8.3-195.3-44-280-108-55.3-42-101.7-93-139-153l-9-14c-2.7 4-5.7 8.7-9 14\n-53.3 86.7-123.7 153-211 199-66.7 36-137.3 56.3-212 62H0V214h199568c178.3-11.7\n 311.7-78.3 403-201 6-8 9.7-12 11-12 .7-.7 6.7-1 18-1s17.3.3 18 1c1.3 0 5 4 11\n 12 44.7 59.3 101.3 106.3 170 141s145.3 54.3 229 60h199572v120z",midbraceunder:"M199572 214\nc100.7 8.3 195.3 44 280 108 55.3 42 101.7 93 139 153l9 14c2.7-4 5.7-8.7 9-14\n 53.3-86.7 123.7-153 211-199 66.7-36 137.3-56.3 212-62h199568v120H200432c-178.3\n 11.7-311.7 78.3-403 201-6 8-9.7 12-11 12-.7.7-6.7 1-18 1s-17.3-.3-18-1c-1.3 0\n-5-4-11-12-44.7-59.3-101.3-106.3-170-141s-145.3-54.3-229-60H0V214z",oiintSize1:"M512.6 71.6c272.6 0 320.3 106.8 320.3 178.2 0 70.8-47.7 177.6\n-320.3 177.6S193.1 320.6 193.1 249.8c0-71.4 46.9-178.2 319.5-178.2z\nm368.1 178.2c0-86.4-60.9-215.4-368.1-215.4-306.4 0-367.3 129-367.3 215.4 0 85.8\n60.9 214.8 367.3 214.8 307.2 0 368.1-129 368.1-214.8z",oiintSize2:"M757.8 100.1c384.7 0 451.1 137.6 451.1 230 0 91.3-66.4 228.8\n-451.1 228.8-386.3 0-452.7-137.5-452.7-228.8 0-92.4 66.4-230 452.7-230z\nm502.4 230c0-111.2-82.4-277.2-502.4-277.2s-504 166-504 277.2\nc0 110 84 276 504 276s502.4-166 502.4-276z",oiiintSize1:"M681.4 71.6c408.9 0 480.5 106.8 480.5 178.2 0 70.8-71.6 177.6\n-480.5 177.6S202.1 320.6 202.1 249.8c0-71.4 70.5-178.2 479.3-178.2z\nm525.8 178.2c0-86.4-86.8-215.4-525.7-215.4-437.9 0-524.7 129-524.7 215.4 0\n85.8 86.8 214.8 524.7 214.8 438.9 0 525.7-129 525.7-214.8z",oiiintSize2:"M1021.2 53c603.6 0 707.8 165.8 707.8 277.2 0 110-104.2 275.8\n-707.8 275.8-606 0-710.2-165.8-710.2-275.8C311 218.8 415.2 53 1021.2 53z\nm770.4 277.1c0-131.2-126.4-327.6-770.5-327.6S248.4 198.9 248.4 330.1\nc0 130 128.8 326.4 772.7 326.4s770.5-196.4 770.5-326.4z",rightarrow:"M0 241v40h399891c-47.3 35.3-84 78-110 128\n-16.7 32-27.7 63.7-33 95 0 1.3-.2 2.7-.5 4-.3 1.3-.5 2.3-.5 3 0 7.3 6.7 11 20\n 11 8 0 13.2-.8 15.5-2.5 2.3-1.7 4.2-5.5 5.5-11.5 2-13.3 5.7-27 11-41 14.7-44.7\n 39-84.5 73-119.5s73.7-60.2 119-75.5c6-2 9-5.7 9-11s-3-9-9-11c-45.3-15.3-85\n-40.5-119-75.5s-58.3-74.8-73-119.5c-4.7-14-8.3-27.3-11-40-1.3-6.7-3.2-10.8-5.5\n-12.5-2.3-1.7-7.5-2.5-15.5-2.5-14 0-21 3.7-21 11 0 2 2 10.3 6 25 20.7 83.3 67\n 151.7 139 205zm0 0v40h399900v-40z",rightbrace:"M400000 542l\n-6 6h-17c-12.7 0-19.3-.3-20-1-4-4-7.3-8.3-10-13-35.3-51.3-80.8-93.8-136.5-127.5\ns-117.2-55.8-184.5-66.5c-.7 0-2-.3-4-1-18.7-2.7-76-4.3-172-5H0V214h399571l6 1\nc124.7 8 235 61.7 331 161 31.3 33.3 59.7 72.7 85 118l7 13v35z",rightbraceunder:"M399994 0l6 6v35l-6 11c-56 104-135.3 181.3-238 232-57.3\n 28.7-117 45-179 50H-300V214h399897c43.3-7 81-15 113-26 100.7-33 179.7-91 237\n-174 2.7-5 6-9 10-13 .7-1 7.3-1 20-1h17z",rightgroup:"M0 80h399565c371 0 266.7 149.4 414 180 5.9 1.2 18 0 18 0 2 0\n 3-1 3-3v-38c-76-158-257-219-435-219H0z",rightgroupunder:"M0 262h399565c371 0 266.7-149.4 414-180 5.9-1.2 18 0 18\n 0 2 0 3 1 3 3v38c-76 158-257 219-435 219H0z",rightharpoon:"M0 241v40h399993c4.7-4.7 7-9.3 7-14 0-9.3\n-3.7-15.3-11-18-92.7-56.7-159-133.7-199-231-3.3-9.3-6-14.7-8-16-2-1.3-7-2-15-2\n-10.7 0-16.7 2-18 6-2 2.7-1 9.7 3 21 15.3 42 36.7 81.8 64 119.5 27.3 37.7 58\n 69.2 92 94.5zm0 0v40h399900v-40z",rightharpoonplus:"M0 241v40h399993c4.7-4.7 7-9.3 7-14 0-9.3-3.7-15.3-11\n-18-92.7-56.7-159-133.7-199-231-3.3-9.3-6-14.7-8-16-2-1.3-7-2-15-2-10.7 0-16.7\n 2-18 6-2 2.7-1 9.7 3 21 15.3 42 36.7 81.8 64 119.5 27.3 37.7 58 69.2 92 94.5z\nm0 0v40h399900v-40z m100 194v40h399900v-40zm0 0v40h399900v-40z",rightharpoondown:"M399747 511c0 7.3 6.7 11 20 11 8 0 13-.8 15-2.5s4.7-6.8\n 8-15.5c40-94 99.3-166.3 178-217 13.3-8 20.3-12.3 21-13 5.3-3.3 8.5-5.8 9.5\n-7.5 1-1.7 1.5-5.2 1.5-10.5s-2.3-10.3-7-15H0v40h399908c-34 25.3-64.7 57-92 95\n-27.3 38-48.7 77.7-64 119-3.3 8.7-5 14-5 16zM0 241v40h399900v-40z",rightharpoondownplus:"M399747 705c0 7.3 6.7 11 20 11 8 0 13-.8\n 15-2.5s4.7-6.8 8-15.5c40-94 99.3-166.3 178-217 13.3-8 20.3-12.3 21-13 5.3-3.3\n 8.5-5.8 9.5-7.5 1-1.7 1.5-5.2 1.5-10.5s-2.3-10.3-7-15H0v40h399908c-34 25.3\n-64.7 57-92 95-27.3 38-48.7 77.7-64 119-3.3 8.7-5 14-5 16zM0 435v40h399900v-40z\nm0-194v40h400000v-40zm0 0v40h400000v-40z",righthook:"M399859 241c-764 0 0 0 0 0 40-3.3 68.7-15.7 86-37 10-12 15-25.3\n 15-40 0-22.7-9.8-40.7-29.5-54-19.7-13.3-43.5-21-71.5-23-17.3-1.3-26-8-26-20 0\n-13.3 8.7-20 26-20 38 0 71 11.2 99 33.5 0 0 7 5.6 21 16.7 14 11.2 21 33.5 21\n 66.8s-14 61.2-42 83.5c-28 22.3-61 33.5-99 33.5L0 241z M0 281v-40h399859v40z",rightlinesegment:H("M399960 241 V94 h40 V428 h-40 V281 H0 v-40z"),rightbracketunder:H("M399995 0 h-120 V290 H0 v120 H400000z"),rightbracketover:H("M399995 440 h-120 V150 H0 v-120 H399995z"),rightToFrom:"M400000 167c-70.7-42-118-97.7-142-167h-23c-15.3 0-23 .3-23\n 1 0 1.3 5.3 13.7 16 37 18 35.3 41.3 69 70 101l7 8H0v40h399905l-7 8c-28.7 32\n-52 65.7-70 101-10.7 23.3-16 35.7-16 37 0 .7 7.7 1 23 1h23c24-69.3 71.3-125 142\n-167z M100 147v40h399900v-40zM0 341v40h399900v-40z",twoheadleftarrow:"M0 167c68 40\n 115.7 95.7 143 167h22c15.3 0 23-.3 23-1 0-1.3-5.3-13.7-16-37-18-35.3-41.3-69\n-70-101l-7-8h125l9 7c50.7 39.3 85 86 103 140h46c0-4.7-6.3-18.7-19-42-18-35.3\n-40-67.3-66-96l-9-9h399716v-40H284l9-9c26-28.7 48-60.7 66-96 12.7-23.333 19\n-37.333 19-42h-46c-18 54-52.3 100.7-103 140l-9 7H95l7-8c28.7-32 52-65.7 70-101\n 10.7-23.333 16-35.7 16-37 0-.7-7.7-1-23-1h-22C115.7 71.3 68 127 0 167z",twoheadrightarrow:"M400000 167\nc-68-40-115.7-95.7-143-167h-22c-15.3 0-23 .3-23 1 0 1.3 5.3 13.7 16 37 18 35.3\n 41.3 69 70 101l7 8h-125l-9-7c-50.7-39.3-85-86-103-140h-46c0 4.7 6.3 18.7 19 42\n 18 35.3 40 67.3 66 96l9 9H0v40h399716l-9 9c-26 28.7-48 60.7-66 96-12.7 23.333\n-19 37.333-19 42h46c18-54 52.3-100.7 103-140l9-7h125l-7 8c-28.7 32-52 65.7-70\n 101-10.7 23.333-16 35.7-16 37 0 .7 7.7 1 23 1h22c27.3-71.3 75-127 143-167z",tilde1:"M200 55.538c-77 0-168 73.953-177 73.953-3 0-7\n-2.175-9-5.437L2 97c-1-2-2-4-2-6 0-4 2-7 5-9l20-12C116 12 171 0 207 0c86 0\n 114 68 191 68 78 0 168-68 177-68 4 0 7 2 9 5l12 19c1 2.175 2 4.35 2 6.525 0\n 4.35-2 7.613-5 9.788l-19 13.05c-92 63.077-116.937 75.308-183 76.128\n-68.267.847-113-73.952-191-73.952z",tilde2:"M344 55.266c-142 0-300.638 81.316-311.5 86.418\n-8.01 3.762-22.5 10.91-23.5 5.562L1 120c-1-2-1-3-1-4 0-5 3-9 8-10l18.4-9C160.9\n 31.9 283 0 358 0c148 0 188 122 331 122s314-97 326-97c4 0 8 2 10 7l7 21.114\nc1 2.14 1 3.21 1 4.28 0 5.347-3 9.626-7 10.696l-22.3 12.622C852.6 158.372 751\n 181.476 676 181.476c-149 0-189-126.21-332-126.21z",tilde3:"M786 59C457 59 32 175.242 13 175.242c-6 0-10-3.457\n-11-10.37L.15 138c-1-7 3-12 10-13l19.2-6.4C378.4 40.7 634.3 0 804.3 0c337 0\n 411.8 157 746.8 157 328 0 754-112 773-112 5 0 10 3 11 9l1 14.075c1 8.066-.697\n 16.595-6.697 17.492l-21.052 7.31c-367.9 98.146-609.15 122.696-778.15 122.696\n -338 0-409-156.573-744-156.573z",tilde4:"M786 58C457 58 32 177.487 13 177.487c-6 0-10-3.345\n-11-10.035L.15 143c-1-7 3-12 10-13l22-6.7C381.2 35 637.15 0 807.15 0c337 0 409\n 177 744 177 328 0 754-127 773-127 5 0 10 3 11 9l1 14.794c1 7.805-3 13.38-9\n 14.495l-20.7 5.574c-366.85 99.79-607.3 139.372-776.3 139.372-338 0-409\n -175.236-744-175.236z",vec:"M377 20c0-5.333 1.833-10 5.5-14S391 0 397 0c4.667 0 8.667 1.667 12 5\n3.333 2.667 6.667 9 10 19 6.667 24.667 20.333 43.667 41 57 7.333 4.667 11\n10.667 11 18 0 6-1 10-3 12s-6.667 5-14 9c-28.667 14.667-53.667 35.667-75 63\n-1.333 1.333-3.167 3.5-5.5 6.5s-4 4.833-5 5.5c-1 .667-2.5 1.333-4.5 2s-4.333 1\n-7 1c-4.667 0-9.167-1.833-13.5-5.5S337 184 337 178c0-12.667 15.667-32.333 47-59\nH213l-171-1c-8.667-6-13-12.333-13-19 0-4.667 4.333-11.333 13-20h359\nc-16-25.333-24-45-24-59z",widehat1:"M529 0h5l519 115c5 1 9 5 9 10 0 1-1 2-1 3l-4 22\nc-1 5-5 9-11 9h-2L532 67 19 159h-2c-5 0-9-4-11-9l-5-22c-1-6 2-12 8-13z",widehat2:"M1181 0h2l1171 176c6 0 10 5 10 11l-2 23c-1 6-5 10\n-11 10h-1L1182 67 15 220h-1c-6 0-10-4-11-10l-2-23c-1-6 4-11 10-11z",widehat3:"M1181 0h2l1171 236c6 0 10 5 10 11l-2 23c-1 6-5 10\n-11 10h-1L1182 67 15 280h-1c-6 0-10-4-11-10l-2-23c-1-6 4-11 10-11z",widehat4:"M1181 0h2l1171 296c6 0 10 5 10 11l-2 23c-1 6-5 10\n-11 10h-1L1182 67 15 340h-1c-6 0-10-4-11-10l-2-23c-1-6 4-11 10-11z",widecheck1:"M529,159h5l519,-115c5,-1,9,-5,9,-10c0,-1,-1,-2,-1,-3l-4,-22c-1,\n-5,-5,-9,-11,-9h-2l-512,92l-513,-92h-2c-5,0,-9,4,-11,9l-5,22c-1,6,2,12,8,13z",widecheck2:"M1181,220h2l1171,-176c6,0,10,-5,10,-11l-2,-23c-1,-6,-5,-10,\n-11,-10h-1l-1168,153l-1167,-153h-1c-6,0,-10,4,-11,10l-2,23c-1,6,4,11,10,11z",widecheck3:"M1181,280h2l1171,-236c6,0,10,-5,10,-11l-2,-23c-1,-6,-5,-10,\n-11,-10h-1l-1168,213l-1167,-213h-1c-6,0,-10,4,-11,10l-2,23c-1,6,4,11,10,11z",widecheck4:"M1181,340h2l1171,-296c6,0,10,-5,10,-11l-2,-23c-1,-6,-5,-10,\n-11,-10h-1l-1168,273l-1167,-273h-1c-6,0,-10,4,-11,10l-2,23c-1,6,4,11,10,11z",baraboveleftarrow:"M400000 620h-399890l3 -3c68.7 -52.7 113.7 -120 135 -202\nc4 -14.7 6 -23 6 -25c0 -7.3 -7 -11 -21 -11c-8 0 -13.2 0.8 -15.5 2.5\nc-2.3 1.7 -4.2 5.8 -5.5 12.5c-1.3 4.7 -2.7 10.3 -4 17c-12 48.7 -34.8 92 -68.5 130\ns-74.2 66.3 -121.5 85c-10 4 -16 7.7 -18 11c0 8.7 6 14.3 18 17c47.3 18.7 87.8 47\n121.5 85s56.5 81.3 68.5 130c0.7 2 1.3 5 2 9s1.2 6.7 1.5 8c0.3 1.3 1 3.3 2 6\ns2.2 4.5 3.5 5.5c1.3 1 3.3 1.8 6 2.5s6 1 10 1c14 0 21 -3.7 21 -11\nc0 -2 -2 -10.3 -6 -25c-20 -79.3 -65 -146.7 -135 -202l-3 -3h399890z\nM100 620v40h399900v-40z M0 241v40h399900v-40zM0 241v40h399900v-40z",rightarrowabovebar:"M0 241v40h399891c-47.3 35.3-84 78-110 128-16.7 32\n-27.7 63.7-33 95 0 1.3-.2 2.7-.5 4-.3 1.3-.5 2.3-.5 3 0 7.3 6.7 11 20 11 8 0\n13.2-.8 15.5-2.5 2.3-1.7 4.2-5.5 5.5-11.5 2-13.3 5.7-27 11-41 14.7-44.7 39\n-84.5 73-119.5s73.7-60.2 119-75.5c6-2 9-5.7 9-11s-3-9-9-11c-45.3-15.3-85-40.5\n-119-75.5s-58.3-74.8-73-119.5c-4.7-14-8.3-27.3-11-40-1.3-6.7-3.2-10.8-5.5\n-12.5-2.3-1.7-7.5-2.5-15.5-2.5-14 0-21 3.7-21 11 0 2 2 10.3 6 25 20.7 83.3 67\n151.7 139 205zm96 379h399894v40H0zm0 0h399904v40H0z",baraboveshortleftharpoon:"M507,435c-4,4,-6.3,8.7,-7,14c0,5.3,0.7,9,2,11\nc1.3,2,5.3,5.3,12,10c90.7,54,156,130,196,228c3.3,10.7,6.3,16.3,9,17\nc2,0.7,5,1,9,1c0,0,5,0,5,0c10.7,0,16.7,-2,18,-6c2,-2.7,1,-9.7,-3,-21\nc-32,-87.3,-82.7,-157.7,-152,-211c0,0,-3,-3,-3,-3l399351,0l0,-40\nc-398570,0,-399437,0,-399437,0z M593 435 v40 H399500 v-40z\nM0 281 v-40 H399908 v40z M0 281 v-40 H399908 v40z",rightharpoonaboveshortbar:"M0,241 l0,40c399126,0,399993,0,399993,0\nc4.7,-4.7,7,-9.3,7,-14c0,-9.3,-3.7,-15.3,-11,-18c-92.7,-56.7,-159,-133.7,-199,\n-231c-3.3,-9.3,-6,-14.7,-8,-16c-2,-1.3,-7,-2,-15,-2c-10.7,0,-16.7,2,-18,6\nc-2,2.7,-1,9.7,3,21c15.3,42,36.7,81.8,64,119.5c27.3,37.7,58,69.2,92,94.5z\nM0 241 v40 H399908 v-40z M0 475 v-40 H399500 v40z M0 475 v-40 H399500 v40z",shortbaraboveleftharpoon:"M7,435c-4,4,-6.3,8.7,-7,14c0,5.3,0.7,9,2,11\nc1.3,2,5.3,5.3,12,10c90.7,54,156,130,196,228c3.3,10.7,6.3,16.3,9,17c2,0.7,5,1,9,\n1c0,0,5,0,5,0c10.7,0,16.7,-2,18,-6c2,-2.7,1,-9.7,-3,-21c-32,-87.3,-82.7,-157.7,\n-152,-211c0,0,-3,-3,-3,-3l399907,0l0,-40c-399126,0,-399993,0,-399993,0z\nM93 435 v40 H400000 v-40z M500 241 v40 H400000 v-40z M500 241 v40 H400000 v-40z",shortrightharpoonabovebar:"M53,241l0,40c398570,0,399437,0,399437,0\nc4.7,-4.7,7,-9.3,7,-14c0,-9.3,-3.7,-15.3,-11,-18c-92.7,-56.7,-159,-133.7,-199,\n-231c-3.3,-9.3,-6,-14.7,-8,-16c-2,-1.3,-7,-2,-15,-2c-10.7,0,-16.7,2,-18,6\nc-2,2.7,-1,9.7,3,21c15.3,42,36.7,81.8,64,119.5c27.3,37.7,58,69.2,92,94.5z\nM500 241 v40 H399408 v-40z M500 435 v40 H400000 v-40z"},X=function(e,t){switch(e){case"lbrack":return"M403 1759 V84 H666 V0 H319 V1759 v"+t+" v1759 v84 h347 v-84\nH403z M403 1759 V0 H319 V1759 v"+t+" v1759 v84 h84z";case"rbrack":return"M347 1759 V0 H0 V84 H263 V1759 v"+t+" v1759 H0 v84 H347z\nM347 1759 V0 H263 V1759 v"+t+" v1759 h84z";case"vert":return"M145 15 v585 v"+t+" v585 c2.667,10,9.667,15,21,15\nc10,0,16.667,-5,20,-15 v-585 v"+-t+" v-585 c-2.667,-10,-9.667,-15,-21,-15\nc-10,0,-16.667,5,-20,15z M188 15 H145 v585 v"+t+" v585 h43z";case"doublevert":return"M145 15 v585 v"+t+" v585 c2.667,10,9.667,15,21,15\nc10,0,16.667,-5,20,-15 v-585 v"+-t+" v-585 c-2.667,-10,-9.667,-15,-21,-15\nc-10,0,-16.667,5,-20,15z M188 15 H145 v585 v"+t+" v585 h43z\nM367 15 v585 v"+t+" v585 c2.667,10,9.667,15,21,15\nc10,0,16.667,-5,20,-15 v-585 v"+-t+" v-585 c-2.667,-10,-9.667,-15,-21,-15\nc-10,0,-16.667,5,-20,15z M410 15 H367 v585 v"+t+" v585 h43z";case"lfloor":return"M319 602 V0 H403 V602 v"+t+" v1715 h263 v84 H319z\nMM319 602 V0 H403 V602 v"+t+" v1715 H319z";case"rfloor":return"M319 602 V0 H403 V602 v"+t+" v1799 H0 v-84 H319z\nMM319 602 V0 H403 V602 v"+t+" v1715 H319z";case"lceil":return"M403 1759 V84 H666 V0 H319 V1759 v"+t+" v602 h84z\nM403 1759 V0 H319 V1759 v"+t+" v602 h84z";case"rceil":return"M347 1759 V0 H0 V84 H263 V1759 v"+t+" v602 h84z\nM347 1759 V0 h-84 V1759 v"+t+" v602 h84z";case"lparen":return"M863,9c0,-2,-2,-5,-6,-9c0,0,-17,0,-17,0c-12.7,0,-19.3,0.3,-20,1\nc-5.3,5.3,-10.3,11,-15,17c-242.7,294.7,-395.3,682,-458,1162c-21.3,163.3,-33.3,349,\n-36,557 l0,"+(t+84)+"c0.2,6,0,26,0,60c2,159.3,10,310.7,24,454c53.3,528,210,\n949.7,470,1265c4.7,6,9.7,11.7,15,17c0.7,0.7,7,1,19,1c0,0,18,0,18,0c4,-4,6,-7,6,-9\nc0,-2.7,-3.3,-8.7,-10,-18c-135.3,-192.7,-235.5,-414.3,-300.5,-665c-65,-250.7,-102.5,\n-544.7,-112.5,-882c-2,-104,-3,-167,-3,-189\nl0,-"+(t+92)+"c0,-162.7,5.7,-314,17,-454c20.7,-272,63.7,-513,129,-723c65.3,\n-210,155.3,-396.3,270,-559c6.7,-9.3,10,-15.3,10,-18z";case"rparen":return"M76,0c-16.7,0,-25,3,-25,9c0,2,2,6.3,6,13c21.3,28.7,42.3,60.3,\n63,95c96.7,156.7,172.8,332.5,228.5,527.5c55.7,195,92.8,416.5,111.5,664.5\nc11.3,139.3,17,290.7,17,454c0,28,1.7,43,3.3,45l0,"+(t+9)+"\nc-3,4,-3.3,16.7,-3.3,38c0,162,-5.7,313.7,-17,455c-18.7,248,-55.8,469.3,-111.5,664\nc-55.7,194.7,-131.8,370.3,-228.5,527c-20.7,34.7,-41.7,66.3,-63,95c-2,3.3,-4,7,-6,11\nc0,7.3,5.7,11,17,11c0,0,11,0,11,0c9.3,0,14.3,-0.3,15,-1c5.3,-5.3,10.3,-11,15,-17\nc242.7,-294.7,395.3,-681.7,458,-1161c21.3,-164.7,33.3,-350.7,36,-558\nl0,-"+(t+144)+"c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,\n-470,-1265c-4.7,-6,-9.7,-11.7,-15,-17c-0.7,-0.7,-6.7,-1,-18,-1z";default:throw new Error("Unknown stretchy delimiter.")}};class Y{constructor(e){this.children=void 0,this.classes=void 0,this.height=void 0,this.depth=void 0,this.maxFontSize=void 0,this.style=void 0,this.children=e,this.classes=[],this.height=0,this.depth=0,this.maxFontSize=0,this.style={}}hasClass(e){return this.classes.includes(e)}toNode(){for(var e=document.createDocumentFragment(),t=0;t<this.children.length;t++)e.appendChild(this.children[t].toNode());return e}toMarkup(){for(var e="",t=0;t<this.children.length;t++)e+=this.children[t].toMarkup();return e}toText(){return this.children.map(e=>{if('toText'in e)return e.toText();throw new Error("Expected MathDomNode with toText, got "+e.constructor.name)}).join("")}}var W={pt:1,mm:2.8452755905511813,cm:28.45275590551181,in:72.27,bp:1.00375,pc:12,dd:1.070008643042351,cc:12.84010371650821,nd:1.0669781931464175,nc:12.80373831775701,sp:152587890625e-16,px:1.00375},$={ex:!0,em:!0,mu:!0},Z=function(e){return"string"!=typeof e&&(e=e.unit),e in W||e in $||"ex"===e},K=function(e,t){var r;if(e.unit in W)r=W[e.unit]/t.fontMetrics().ptPerEm/t.sizeMultiplier;else if("mu"===e.unit)r=t.fontMetrics().cssEmPerMu;else{var a;if(a=t.style.isTight()?t.havingStyle(t.style.text()):t,"ex"===e.unit)r=a.fontMetrics().xHeight;else{if("em"!==e.unit)throw new s("Invalid unit: '"+e.unit+"'");r=a.fontMetrics().quad}a!==t&&(r*=a.sizeMultiplier/t.sizeMultiplier)}return Math.min(e.number*r,t.maxSize)},J=function(e){return+e.toFixed(4)+"em"},Q=function(e){return e.filter(e=>e).join(" ")},ee=function(e){var t="";for(var r of Object.keys(e)){var a=e[r];void 0!==a&&(t+=h(r)+":"+a+";")}return t},te=function(e,t,r){if(this.classes=e||[],this.attributes={},this.height=0,this.depth=0,this.maxFontSize=0,this.style=r||{},t){t.style.isTight()&&this.classes.push("mtight");var a=t.getColor();a&&(this.style.color=a)}},re=function(e){var t=document.createElement(e);for(var r of(t.className=Q(this.classes),Object.assign(t.style,this.style),Object.keys(this.attributes)))t.setAttribute(r,this.attributes[r]);for(var a=0;a<this.children.length;a++)t.appendChild(this.children[a].toNode());return t},ae=/[\s"'>/=\x00-\x1f]/,ne=function(e){var t="<"+e;this.classes.length&&(t+=" class=\""+u(Q(this.classes))+"\"");var r=ee(this.style);for(var a of(r&&(t+=" style=\""+u(r)+"\""),Object.keys(this.attributes))){if(ae.test(a))throw new s("Invalid attribute name '"+a+"'");t+=" "+a+"=\""+u(this.attributes[a])+"\""}t+=">";for(var n=0;n<this.children.length;n++)t+=this.children[n].toMarkup();return t+="</"+e+">"};class ie{constructor(e,t,r,a){this.children=void 0,this.attributes=void 0,this.classes=void 0,this.height=void 0,this.depth=void 0,this.width=void 0,this.maxFontSize=void 0,this.style=void 0,this.italic=void 0,te.call(this,e,r,a),this.children=t||[]}setAttribute(e,t){this.attributes[e]=t}hasClass(e){return this.classes.includes(e)}toNode(){return re.call(this,"span")}toMarkup(){return ne.call(this,"span")}}class oe{constructor(e,t,r,a){this.children=void 0,this.attributes=void 0,this.classes=void 0,this.height=void 0,this.depth=void 0,this.maxFontSize=void 0,this.style=void 0,te.call(this,t,a),this.children=r||[],this.setAttribute('href',e)}setAttribute(e,t){this.attributes[e]=t}hasClass(e){return this.classes.includes(e)}toNode(){return re.call(this,"a")}toMarkup(){return ne.call(this,"a")}}class se{constructor(e,t,r){this.src=void 0,this.alt=void 0,this.classes=void 0,this.height=void 0,this.depth=void 0,this.maxFontSize=void 0,this.style=void 0,this.alt=t,this.src=e,this.classes=["mord"],this.height=0,this.depth=0,this.maxFontSize=0,this.style=r}hasClass(e){return this.classes.includes(e)}toNode(){var e=document.createElement("img");return e.src=this.src,e.alt=this.alt,e.className="mord",Object.assign(e.style,this.style),e}toMarkup(){var e="<img src=\""+u(this.src)+"\" alt=\""+u(this.alt)+"\"",t=ee(this.style);return t&&(e+=" style=\""+u(t)+"\""),e+="'/>"}}var le={'\xee':'\u0131\u0302','\xef':'\u0131\u0308','\xed':'\u0131\u0301','\xec':'\u0131\u0300'};class he{constructor(e,t,r,a,n,i,o,s){this.text=void 0,this.height=void 0,this.depth=void 0,this.italic=void 0,this.skew=void 0,this.width=void 0,this.maxFontSize=void 0,this.classes=void 0,this.style=void 0,this.text=e,this.height=t||0,this.depth=r||0,this.italic=a||0,this.skew=n||0,this.width=i||0,this.classes=o||[],this.style=s||{},this.maxFontSize=0;var l=O(this.text.charCodeAt(0));l&&this.classes.push(l+"_fallback"),/[\xee\xef\xed\xec]/.test(this.text)&&(this.text=le[this.text])}hasClass(e){return this.classes.includes(e)}toNode(){var e=document.createTextNode(this.text),t=null;return this.italic>0&&((t=document.createElement("span")).style.marginRight=J(this.italic)),this.classes.length>0&&((t=t||document.createElement("span")).className=Q(this.classes)),Object.keys(this.style).length>0&&(t=t||document.createElement("span"),Object.assign(t.style,this.style)),t?(t.appendChild(e),t):e}toMarkup(){var e=!1,t="<span";this.classes.length&&(e=!0,t+=" class=\"",t+=u(Q(this.classes)),t+="\"");var r="";this.italic>0&&(r+="margin-right:"+J(this.italic)+";"),(r+=ee(this.style))&&(e=!0,t+=" style=\""+u(r)+"\"");var a=u(this.text);return e?(t+=">",t+=a,t+="</span>"):a}}class me{constructor(e,t){this.children=void 0,this.attributes=void 0,this.children=e||[],this.attributes=t||{}}toNode(){var e=document.createElementNS("http://www.w3.org/2000/svg","svg");for(var t of Object.keys(this.attributes))e.setAttribute(t,this.attributes[t]);for(var r=0;r<this.children.length;r++)e.appendChild(this.children[r].toNode());return e}toMarkup(){var e="<svg xmlns=\"http://www.w3.org/2000/svg\"";for(var t of Object.keys(this.attributes))e+=" "+t+"=\""+u(this.attributes[t])+"\"";e+=">";for(var r=0;r<this.children.length;r++)e+=this.children[r].toMarkup();return e+="</svg>"}}class ce{constructor(e,t){this.pathName=void 0,this.alternate=void 0,this.pathName=e,this.alternate=t}toNode(){var e=document.createElementNS("http://www.w3.org/2000/svg","path");return this.alternate?e.setAttribute("d",this.alternate):e.setAttribute("d",_[this.pathName]),e}toMarkup(){return this.alternate?"<path d=\""+u(this.alternate)+"\"/>":"<path d=\""+u(_[this.pathName])+"\"/>"}}class ue{constructor(e){this.attributes=void 0,this.attributes=e||{}}toNode(){var e=document.createElementNS("http://www.w3.org/2000/svg","line");for(var t of Object.keys(this.attributes))e.setAttribute(t,this.attributes[t]);return e}toMarkup(){var e="<line";for(var t of Object.keys(this.attributes))e+=" "+t+"=\""+u(this.attributes[t])+"\"";return e+="/>"}}function pe(e){if(e instanceof he)return e;throw new Error("Expected symbolNode but got "+String(e)+".")}function de(e){if(e instanceof ie)return e;throw new Error("Expected span<HtmlDomNode> but got "+String(e)+".")}var ge={"AMS-Regular":{32:[0,0,0,0,.25],65:[0,.68889,0,0,.72222],66:[0,.68889,0,0,.66667],67:[0,.68889,0,0,.72222],68:[0,.68889,0,0,.72222],69:[0,.68889,0,0,.66667],70:[0,.68889,0,0,.61111],71:[0,.68889,0,0,.77778],72:[0,.68889,0,0,.77778],73:[0,.68889,0,0,.38889],74:[.16667,.68889,0,0,.5],75:[0,.68889,0,0,.77778],76:[0,.68889,0,0,.66667],77:[0,.68889,0,0,.94445],78:[0,.68889,0,0,.72222],79:[.16667,.68889,0,0,.77778],80:[0,.68889,0,0,.61111],81:[.16667,.68889,0,0,.77778],82:[0,.68889,0,0,.72222],83:[0,.68889,0,0,.55556],84:[0,.68889,0,0,.66667],85:[0,.68889,0,0,.72222],86:[0,.68889,0,0,.72222],87:[0,.68889,0,0,1],88:[0,.68889,0,0,.72222],89:[0,.68889,0,0,.72222],90:[0,.68889,0,0,.66667],107:[0,.68889,0,0,.55556],160:[0,0,0,0,.25],165:[0,.675,.025,0,.75],174:[.15559,.69224,0,0,.94666],240:[0,.68889,0,0,.55556],295:[0,.68889,0,0,.54028],710:[0,.825,0,0,2.33334],732:[0,.9,0,0,2.33334],770:[0,.825,0,0,2.33334],771:[0,.9,0,0,2.33334],989:[.08167,.58167,0,0,.77778],1008:[0,.43056,.04028,0,.66667],8245:[0,.54986,0,0,.275],8463:[0,.68889,0,0,.54028],8487:[0,.68889,0,0,.72222],8498:[0,.68889,0,0,.55556],8502:[0,.68889,0,0,.66667],8503:[0,.68889,0,0,.44445],8504:[0,.68889,0,0,.66667],8513:[0,.68889,0,0,.63889],8592:[-.03598,.46402,0,0,.5],8594:[-.03598,.46402,0,0,.5],8602:[-.13313,.36687,0,0,1],8603:[-.13313,.36687,0,0,1],8606:[.01354,.52239,0,0,1],8608:[.01354,.52239,0,0,1],8610:[.01354,.52239,0,0,1.11111],8611:[.01354,.52239,0,0,1.11111],8619:[0,.54986,0,0,1],8620:[0,.54986,0,0,1],8621:[-.13313,.37788,0,0,1.38889],8622:[-.13313,.36687,0,0,1],8624:[0,.69224,0,0,.5],8625:[0,.69224,0,0,.5],8630:[0,.43056,0,0,1],8631:[0,.43056,0,0,1],8634:[.08198,.58198,0,0,.77778],8635:[.08198,.58198,0,0,.77778],8638:[.19444,.69224,0,0,.41667],8639:[.19444,.69224,0,0,.41667],8642:[.19444,.69224,0,0,.41667],8643:[.19444,.69224,0,0,.41667],8644:[.1808,.675,0,0,1],8646:[.1808,.675,0,0,1],8647:[.1808,.675,0,0,1],8648:[.19444,.69224,0,0,.83334],8649:[.1808,.675,0,0,1],8650:[.19444,.69224,0,0,.83334],8651:[.01354,.52239,0,0,1],8652:[.01354,.52239,0,0,1],8653:[-.13313,.36687,0,0,1],8654:[-.13313,.36687,0,0,1],8655:[-.13313,.36687,0,0,1],8666:[.13667,.63667,0,0,1],8667:[.13667,.63667,0,0,1],8669:[-.13313,.37788,0,0,1],8672:[-.064,.437,0,0,1.334],8674:[-.064,.437,0,0,1.334],8705:[0,.825,0,0,.5],8708:[0,.68889,0,0,.55556],8709:[.08167,.58167,0,0,.77778],8717:[0,.43056,0,0,.42917],8722:[-.03598,.46402,0,0,.5],8724:[.08198,.69224,0,0,.77778],8726:[.08167,.58167,0,0,.77778],8733:[0,.69224,0,0,.77778],8736:[0,.69224,0,0,.72222],8737:[0,.69224,0,0,.72222],8738:[.03517,.52239,0,0,.72222],8739:[.08167,.58167,0,0,.22222],8740:[.25142,.74111,0,0,.27778],8741:[.08167,.58167,0,0,.38889],8742:[.25142,.74111,0,0,.5],8756:[0,.69224,0,0,.66667],8757:[0,.69224,0,0,.66667],8764:[-.13313,.36687,0,0,.77778],8765:[-.13313,.37788,0,0,.77778],8769:[-.13313,.36687,0,0,.77778],8770:[-.03625,.46375,0,0,.77778],8774:[.30274,.79383,0,0,.77778],8776:[-.01688,.48312,0,0,.77778],8778:[.08167,.58167,0,0,.77778],8782:[.06062,.54986,0,0,.77778],8783:[.06062,.54986,0,0,.77778],8785:[.08198,.58198,0,0,.77778],8786:[.08198,.58198,0,0,.77778],8787:[.08198,.58198,0,0,.77778],8790:[0,.69224,0,0,.77778],8791:[.22958,.72958,0,0,.77778],8796:[.08198,.91667,0,0,.77778],8806:[.25583,.75583,0,0,.77778],8807:[.25583,.75583,0,0,.77778],8808:[.25142,.75726,0,0,.77778],8809:[.25142,.75726,0,0,.77778],8812:[.25583,.75583,0,0,.5],8814:[.20576,.70576,0,0,.77778],8815:[.20576,.70576,0,0,.77778],8816:[.30274,.79383,0,0,.77778],8817:[.30274,.79383,0,0,.77778],8818:[.22958,.72958,0,0,.77778],8819:[.22958,.72958,0,0,.77778],8822:[.1808,.675,0,0,.77778],8823:[.1808,.675,0,0,.77778],8828:[.13667,.63667,0,0,.77778],8829:[.13667,.63667,0,0,.77778],8830:[.22958,.72958,0,0,.77778],8831:[.22958,.72958,0,0,.77778],8832:[.20576,.70576,0,0,.77778],8833:[.20576,.70576,0,0,.77778],8840:[.30274,.79383,0,0,.77778],8841:[.30274,.79383,0,0,.77778],8842:[.13597,.63597,0,0,.77778],8843:[.13597,.63597,0,0,.77778],8847:[.03517,.54986,0,0,.77778],8848:[.03517,.54986,0,0,.77778],8858:[.08198,.58198,0,0,.77778],8859:[.08198,.58198,0,0,.77778],8861:[.08198,.58198,0,0,.77778],8862:[0,.675,0,0,.77778],8863:[0,.675,0,0,.77778],8864:[0,.675,0,0,.77778],8865:[0,.675,0,0,.77778],8872:[0,.69224,0,0,.61111],8873:[0,.69224,0,0,.72222],8874:[0,.69224,0,0,.88889],8876:[0,.68889,0,0,.61111],8877:[0,.68889,0,0,.61111],8878:[0,.68889,0,0,.72222],8879:[0,.68889,0,0,.72222],8882:[.03517,.54986,0,0,.77778],8883:[.03517,.54986,0,0,.77778],8884:[.13667,.63667,0,0,.77778],8885:[.13667,.63667,0,0,.77778],8888:[0,.54986,0,0,1.11111],8890:[.19444,.43056,0,0,.55556],8891:[.19444,.69224,0,0,.61111],8892:[.19444,.69224,0,0,.61111],8901:[0,.54986,0,0,.27778],8903:[.08167,.58167,0,0,.77778],8905:[.08167,.58167,0,0,.77778],8906:[.08167,.58167,0,0,.77778],8907:[0,.69224,0,0,.77778],8908:[0,.69224,0,0,.77778],8909:[-.03598,.46402,0,0,.77778],8910:[0,.54986,0,0,.76042],8911:[0,.54986,0,0,.76042],8912:[.03517,.54986,0,0,.77778],8913:[.03517,.54986,0,0,.77778],8914:[0,.54986,0,0,.66667],8915:[0,.54986,0,0,.66667],8916:[0,.69224,0,0,.66667],8918:[.0391,.5391,0,0,.77778],8919:[.0391,.5391,0,0,.77778],8920:[.03517,.54986,0,0,1.33334],8921:[.03517,.54986,0,0,1.33334],8922:[.38569,.88569,0,0,.77778],8923:[.38569,.88569,0,0,.77778],8926:[.13667,.63667,0,0,.77778],8927:[.13667,.63667,0,0,.77778],8928:[.30274,.79383,0,0,.77778],8929:[.30274,.79383,0,0,.77778],8934:[.23222,.74111,0,0,.77778],8935:[.23222,.74111,0,0,.77778],8936:[.23222,.74111,0,0,.77778],8937:[.23222,.74111,0,0,.77778],8938:[.20576,.70576,0,0,.77778],8939:[.20576,.70576,0,0,.77778],8940:[.30274,.79383,0,0,.77778],8941:[.30274,.79383,0,0,.77778],8994:[.19444,.69224,0,0,.77778],8995:[.19444,.69224,0,0,.77778],9416:[.15559,.69224,0,0,.90222],9484:[0,.69224,0,0,.5],9488:[0,.69224,0,0,.5],9492:[0,.37788,0,0,.5],9496:[0,.37788,0,0,.5],9585:[.19444,.68889,0,0,.88889],9586:[.19444,.74111,0,0,.88889],9632:[0,.675,0,0,.77778],9633:[0,.675,0,0,.77778],9650:[0,.54986,0,0,.72222],9651:[0,.54986,0,0,.72222],9654:[.03517,.54986,0,0,.77778],9660:[0,.54986,0,0,.72222],9661:[0,.54986,0,0,.72222],9664:[.03517,.54986,0,0,.77778],9674:[.11111,.69224,0,0,.66667],9733:[.19444,.69224,0,0,.94445],10003:[0,.69224,0,0,.83334],10016:[0,.69224,0,0,.83334],10731:[.11111,.69224,0,0,.66667],10846:[.19444,.75583,0,0,.61111],10877:[.13667,.63667,0,0,.77778],10878:[.13667,.63667,0,0,.77778],10885:[.25583,.75583,0,0,.77778],10886:[.25583,.75583,0,0,.77778],10887:[.13597,.63597,0,0,.77778],10888:[.13597,.63597,0,0,.77778],10889:[.26167,.75726,0,0,.77778],10890:[.26167,.75726,0,0,.77778],10891:[.48256,.98256,0,0,.77778],10892:[.48256,.98256,0,0,.77778],10901:[.13667,.63667,0,0,.77778],10902:[.13667,.63667,0,0,.77778],10933:[.25142,.75726,0,0,.77778],10934:[.25142,.75726,0,0,.77778],10935:[.26167,.75726,0,0,.77778],10936:[.26167,.75726,0,0,.77778],10937:[.26167,.75726,0,0,.77778],10938:[.26167,.75726,0,0,.77778],10949:[.25583,.75583,0,0,.77778],10950:[.25583,.75583,0,0,.77778],10955:[.28481,.79383,0,0,.77778],10956:[.28481,.79383,0,0,.77778],57350:[.08167,.58167,0,0,.22222],57351:[.08167,.58167,0,0,.38889],57352:[.08167,.58167,0,0,.77778],57353:[0,.43056,.04028,0,.66667],57356:[.25142,.75726,0,0,.77778],57357:[.25142,.75726,0,0,.77778],57358:[.41951,.91951,0,0,.77778],57359:[.30274,.79383,0,0,.77778],57360:[.30274,.79383,0,0,.77778],57361:[.41951,.91951,0,0,.77778],57366:[.25142,.75726,0,0,.77778],57367:[.25142,.75726,0,0,.77778],57368:[.25142,.75726,0,0,.77778],57369:[.25142,.75726,0,0,.77778],57370:[.13597,.63597,0,0,.77778],57371:[.13597,.63597,0,0,.77778]},"Caligraphic-Regular":{32:[0,0,0,0,.25],65:[0,.68333,0,.19445,.79847],66:[0,.68333,.03041,.13889,.65681],67:[0,.68333,.05834,.13889,.52653],68:[0,.68333,.02778,.08334,.77139],69:[0,.68333,.08944,.11111,.52778],70:[0,.68333,.09931,.11111,.71875],71:[.09722,.68333,.0593,.11111,.59487],72:[0,.68333,.00965,.11111,.84452],73:[0,.68333,.07382,0,.54452],74:[.09722,.68333,.18472,.16667,.67778],75:[0,.68333,.01445,.05556,.76195],76:[0,.68333,0,.13889,.68972],77:[0,.68333,0,.13889,1.2009],78:[0,.68333,.14736,.08334,.82049],79:[0,.68333,.02778,.11111,.79611],80:[0,.68333,.08222,.08334,.69556],81:[.09722,.68333,0,.11111,.81667],82:[0,.68333,0,.08334,.8475],83:[0,.68333,.075,.13889,.60556],84:[0,.68333,.25417,0,.54464],85:[0,.68333,.09931,.08334,.62583],86:[0,.68333,.08222,0,.61278],87:[0,.68333,.08222,.08334,.98778],88:[0,.68333,.14643,.13889,.7133],89:[.09722,.68333,.08222,.08334,.66834],90:[0,.68333,.07944,.13889,.72473],160:[0,0,0,0,.25]},"Fraktur-Regular":{32:[0,0,0,0,.25],33:[0,.69141,0,0,.29574],34:[0,.69141,0,0,.21471],38:[0,.69141,0,0,.73786],39:[0,.69141,0,0,.21201],40:[.24982,.74947,0,0,.38865],41:[.24982,.74947,0,0,.38865],42:[0,.62119,0,0,.27764],43:[.08319,.58283,0,0,.75623],44:[0,.10803,0,0,.27764],45:[.08319,.58283,0,0,.75623],46:[0,.10803,0,0,.27764],47:[.24982,.74947,0,0,.50181],48:[0,.47534,0,0,.50181],49:[0,.47534,0,0,.50181],50:[0,.47534,0,0,.50181],51:[.18906,.47534,0,0,.50181],52:[.18906,.47534,0,0,.50181],53:[.18906,.47534,0,0,.50181],54:[0,.69141,0,0,.50181],55:[.18906,.47534,0,0,.50181],56:[0,.69141,0,0,.50181],57:[.18906,.47534,0,0,.50181],58:[0,.47534,0,0,.21606],59:[.12604,.47534,0,0,.21606],61:[-.13099,.36866,0,0,.75623],63:[0,.69141,0,0,.36245],65:[0,.69141,0,0,.7176],66:[0,.69141,0,0,.88397],67:[0,.69141,0,0,.61254],68:[0,.69141,0,0,.83158],69:[0,.69141,0,0,.66278],70:[.12604,.69141,0,0,.61119],71:[0,.69141,0,0,.78539],72:[.06302,.69141,0,0,.7203],73:[0,.69141,0,0,.55448],74:[.12604,.69141,0,0,.55231],75:[0,.69141,0,0,.66845],76:[0,.69141,0,0,.66602],77:[0,.69141,0,0,1.04953],78:[0,.69141,0,0,.83212],79:[0,.69141,0,0,.82699],80:[.18906,.69141,0,0,.82753],81:[.03781,.69141,0,0,.82699],82:[0,.69141,0,0,.82807],83:[0,.69141,0,0,.82861],84:[0,.69141,0,0,.66899],85:[0,.69141,0,0,.64576],86:[0,.69141,0,0,.83131],87:[0,.69141,0,0,1.04602],88:[0,.69141,0,0,.71922],89:[.18906,.69141,0,0,.83293],90:[.12604,.69141,0,0,.60201],91:[.24982,.74947,0,0,.27764],93:[.24982,.74947,0,0,.27764],94:[0,.69141,0,0,.49965],97:[0,.47534,0,0,.50046],98:[0,.69141,0,0,.51315],99:[0,.47534,0,0,.38946],100:[0,.62119,0,0,.49857],101:[0,.47534,0,0,.40053],102:[.18906,.69141,0,0,.32626],103:[.18906,.47534,0,0,.5037],104:[.18906,.69141,0,0,.52126],105:[0,.69141,0,0,.27899],106:[0,.69141,0,0,.28088],107:[0,.69141,0,0,.38946],108:[0,.69141,0,0,.27953],109:[0,.47534,0,0,.76676],110:[0,.47534,0,0,.52666],111:[0,.47534,0,0,.48885],112:[.18906,.52396,0,0,.50046],113:[.18906,.47534,0,0,.48912],114:[0,.47534,0,0,.38919],115:[0,.47534,0,0,.44266],116:[0,.62119,0,0,.33301],117:[0,.47534,0,0,.5172],118:[0,.52396,0,0,.5118],119:[0,.52396,0,0,.77351],120:[.18906,.47534,0,0,.38865],121:[.18906,.47534,0,0,.49884],122:[.18906,.47534,0,0,.39054],160:[0,0,0,0,.25],8216:[0,.69141,0,0,.21471],8217:[0,.69141,0,0,.21471],58112:[0,.62119,0,0,.49749],58113:[0,.62119,0,0,.4983],58114:[.18906,.69141,0,0,.33328],58115:[.18906,.69141,0,0,.32923],58116:[.18906,.47534,0,0,.50343],58117:[0,.69141,0,0,.33301],58118:[0,.62119,0,0,.33409],58119:[0,.47534,0,0,.50073]},"Main-Bold":{32:[0,0,0,0,.25],33:[0,.69444,0,0,.35],34:[0,.69444,0,0,.60278],35:[.19444,.69444,0,0,.95833],36:[.05556,.75,0,0,.575],37:[.05556,.75,0,0,.95833],38:[0,.69444,0,0,.89444],39:[0,.69444,0,0,.31944],40:[.25,.75,0,0,.44722],41:[.25,.75,0,0,.44722],42:[0,.75,0,0,.575],43:[.13333,.63333,0,0,.89444],44:[.19444,.15556,0,0,.31944],45:[0,.44444,0,0,.38333],46:[0,.15556,0,0,.31944],47:[.25,.75,0,0,.575],48:[0,.64444,0,0,.575],49:[0,.64444,0,0,.575],50:[0,.64444,0,0,.575],51:[0,.64444,0,0,.575],52:[0,.64444,0,0,.575],53:[0,.64444,0,0,.575],54:[0,.64444,0,0,.575],55:[0,.64444,0,0,.575],56:[0,.64444,0,0,.575],57:[0,.64444,0,0,.575],58:[0,.44444,0,0,.31944],59:[.19444,.44444,0,0,.31944],60:[.08556,.58556,0,0,.89444],61:[-.10889,.39111,0,0,.89444],62:[.08556,.58556,0,0,.89444],63:[0,.69444,0,0,.54305],64:[0,.69444,0,0,.89444],65:[0,.68611,0,0,.86944],66:[0,.68611,0,0,.81805],67:[0,.68611,0,0,.83055],68:[0,.68611,0,0,.88194],69:[0,.68611,0,0,.75555],70:[0,.68611,0,0,.72361],71:[0,.68611,0,0,.90416],72:[0,.68611,0,0,.9],73:[0,.68611,0,0,.43611],74:[0,.68611,0,0,.59444],75:[0,.68611,0,0,.90138],76:[0,.68611,0,0,.69166],77:[0,.68611,0,0,1.09166],78:[0,.68611,0,0,.9],79:[0,.68611,0,0,.86388],80:[0,.68611,0,0,.78611],81:[.19444,.68611,0,0,.86388],82:[0,.68611,0,0,.8625],83:[0,.68611,0,0,.63889],84:[0,.68611,0,0,.8],85:[0,.68611,0,0,.88472],86:[0,.68611,.01597,0,.86944],87:[0,.68611,.01597,0,1.18888],88:[0,.68611,0,0,.86944],89:[0,.68611,.02875,0,.86944],90:[0,.68611,0,0,.70277],91:[.25,.75,0,0,.31944],92:[.25,.75,0,0,.575],93:[.25,.75,0,0,.31944],94:[0,.69444,0,0,.575],95:[.31,.13444,.03194,0,.575],97:[0,.44444,0,0,.55902],98:[0,.69444,0,0,.63889],99:[0,.44444,0,0,.51111],100:[0,.69444,0,0,.63889],101:[0,.44444,0,0,.52708],102:[0,.69444,.10903,0,.35139],103:[.19444,.44444,.01597,0,.575],104:[0,.69444,0,0,.63889],105:[0,.69444,0,0,.31944],106:[.19444,.69444,0,0,.35139],107:[0,.69444,0,0,.60694],108:[0,.69444,0,0,.31944],109:[0,.44444,0,0,.95833],110:[0,.44444,0,0,.63889],111:[0,.44444,0,0,.575],112:[.19444,.44444,0,0,.63889],113:[.19444,.44444,0,0,.60694],114:[0,.44444,0,0,.47361],115:[0,.44444,0,0,.45361],116:[0,.63492,0,0,.44722],117:[0,.44444,0,0,.63889],118:[0,.44444,.01597,0,.60694],119:[0,.44444,.01597,0,.83055],120:[0,.44444,0,0,.60694],121:[.19444,.44444,.01597,0,.60694],122:[0,.44444,0,0,.51111],123:[.25,.75,0,0,.575],124:[.25,.75,0,0,.31944],125:[.25,.75,0,0,.575],126:[.35,.34444,0,0,.575],160:[0,0,0,0,.25],163:[0,.69444,0,0,.86853],168:[0,.69444,0,0,.575],172:[0,.44444,0,0,.76666],176:[0,.69444,0,0,.86944],177:[.13333,.63333,0,0,.89444],184:[.17014,0,0,0,.51111],198:[0,.68611,0,0,1.04166],215:[.13333,.63333,0,0,.89444],216:[.04861,.73472,0,0,.89444],223:[0,.69444,0,0,.59722],230:[0,.44444,0,0,.83055],247:[.13333,.63333,0,0,.89444],248:[.09722,.54167,0,0,.575],305:[0,.44444,0,0,.31944],338:[0,.68611,0,0,1.16944],339:[0,.44444,0,0,.89444],567:[.19444,.44444,0,0,.35139],710:[0,.69444,0,0,.575],711:[0,.63194,0,0,.575],713:[0,.59611,0,0,.575],714:[0,.69444,0,0,.575],715:[0,.69444,0,0,.575],728:[0,.69444,0,0,.575],729:[0,.69444,0,0,.31944],730:[0,.69444,0,0,.86944],732:[0,.69444,0,0,.575],733:[0,.69444,0,0,.575],915:[0,.68611,0,0,.69166],916:[0,.68611,0,0,.95833],920:[0,.68611,0,0,.89444],923:[0,.68611,0,0,.80555],926:[0,.68611,0,0,.76666],928:[0,.68611,0,0,.9],931:[0,.68611,0,0,.83055],933:[0,.68611,0,0,.89444],934:[0,.68611,0,0,.83055],936:[0,.68611,0,0,.89444],937:[0,.68611,0,0,.83055],8211:[0,.44444,.03194,0,.575],8212:[0,.44444,.03194,0,1.14999],8216:[0,.69444,0,0,.31944],8217:[0,.69444,0,0,.31944],8220:[0,.69444,0,0,.60278],8221:[0,.69444,0,0,.60278],8224:[.19444,.69444,0,0,.51111],8225:[.19444,.69444,0,0,.51111],8242:[0,.55556,0,0,.34444],8407:[0,.72444,.15486,0,.575],8463:[0,.69444,0,0,.66759],8465:[0,.69444,0,0,.83055],8467:[0,.69444,0,0,.47361],8472:[.19444,.44444,0,0,.74027],8476:[0,.69444,0,0,.83055],8501:[0,.69444,0,0,.70277],8592:[-.10889,.39111,0,0,1.14999],8593:[.19444,.69444,0,0,.575],8594:[-.10889,.39111,0,0,1.14999],8595:[.19444,.69444,0,0,.575],8596:[-.10889,.39111,0,0,1.14999],8597:[.25,.75,0,0,.575],8598:[.19444,.69444,0,0,1.14999],8599:[.19444,.69444,0,0,1.14999],8600:[.19444,.69444,0,0,1.14999],8601:[.19444,.69444,0,0,1.14999],8636:[-.10889,.39111,0,0,1.14999],8637:[-.10889,.39111,0,0,1.14999],8640:[-.10889,.39111,0,0,1.14999],8641:[-.10889,.39111,0,0,1.14999],8656:[-.10889,.39111,0,0,1.14999],8657:[.19444,.69444,0,0,.70277],8658:[-.10889,.39111,0,0,1.14999],8659:[.19444,.69444,0,0,.70277],8660:[-.10889,.39111,0,0,1.14999],8661:[.25,.75,0,0,.70277],8704:[0,.69444,0,0,.63889],8706:[0,.69444,.06389,0,.62847],8707:[0,.69444,0,0,.63889],8709:[.05556,.75,0,0,.575],8711:[0,.68611,0,0,.95833],8712:[.08556,.58556,0,0,.76666],8715:[.08556,.58556,0,0,.76666],8722:[.13333,.63333,0,0,.89444],8723:[.13333,.63333,0,0,.89444],8725:[.25,.75,0,0,.575],8726:[.25,.75,0,0,.575],8727:[-.02778,.47222,0,0,.575],8728:[-.02639,.47361,0,0,.575],8729:[-.02639,.47361,0,0,.575],8730:[.18,.82,0,0,.95833],8733:[0,.44444,0,0,.89444],8734:[0,.44444,0,0,1.14999],8736:[0,.69224,0,0,.72222],8739:[.25,.75,0,0,.31944],8741:[.25,.75,0,0,.575],8743:[0,.55556,0,0,.76666],8744:[0,.55556,0,0,.76666],8745:[0,.55556,0,0,.76666],8746:[0,.55556,0,0,.76666],8747:[.19444,.69444,.12778,0,.56875],8764:[-.10889,.39111,0,0,.89444],8768:[.19444,.69444,0,0,.31944],8771:[.00222,.50222,0,0,.89444],8773:[.027,.638,0,0,.894],8776:[.02444,.52444,0,0,.89444],8781:[.00222,.50222,0,0,.89444],8801:[.00222,.50222,0,0,.89444],8804:[.19667,.69667,0,0,.89444],8805:[.19667,.69667,0,0,.89444],8810:[.08556,.58556,0,0,1.14999],8811:[.08556,.58556,0,0,1.14999],8826:[.08556,.58556,0,0,.89444],8827:[.08556,.58556,0,0,.89444],8834:[.08556,.58556,0,0,.89444],8835:[.08556,.58556,0,0,.89444],8838:[.19667,.69667,0,0,.89444],8839:[.19667,.69667,0,0,.89444],8846:[0,.55556,0,0,.76666],8849:[.19667,.69667,0,0,.89444],8850:[.19667,.69667,0,0,.89444],8851:[0,.55556,0,0,.76666],8852:[0,.55556,0,0,.76666],8853:[.13333,.63333,0,0,.89444],8854:[.13333,.63333,0,0,.89444],8855:[.13333,.63333,0,0,.89444],8856:[.13333,.63333,0,0,.89444],8857:[.13333,.63333,0,0,.89444],8866:[0,.69444,0,0,.70277],8867:[0,.69444,0,0,.70277],8868:[0,.69444,0,0,.89444],8869:[0,.69444,0,0,.89444],8900:[-.02639,.47361,0,0,.575],8901:[-.02639,.47361,0,0,.31944],8902:[-.02778,.47222,0,0,.575],8968:[.25,.75,0,0,.51111],8969:[.25,.75,0,0,.51111],8970:[.25,.75,0,0,.51111],8971:[.25,.75,0,0,.51111],8994:[-.13889,.36111,0,0,1.14999],8995:[-.13889,.36111,0,0,1.14999],9651:[.19444,.69444,0,0,1.02222],9657:[-.02778,.47222,0,0,.575],9661:[.19444,.69444,0,0,1.02222],9667:[-.02778,.47222,0,0,.575],9711:[.19444,.69444,0,0,1.14999],9824:[.12963,.69444,0,0,.89444],9825:[.12963,.69444,0,0,.89444],9826:[.12963,.69444,0,0,.89444],9827:[.12963,.69444,0,0,.89444],9837:[0,.75,0,0,.44722],9838:[.19444,.69444,0,0,.44722],9839:[.19444,.69444,0,0,.44722],10216:[.25,.75,0,0,.44722],10217:[.25,.75,0,0,.44722],10815:[0,.68611,0,0,.9],10927:[.19667,.69667,0,0,.89444],10928:[.19667,.69667,0,0,.89444],57376:[.19444,.69444,0,0,0]},"Main-BoldItalic":{32:[0,0,0,0,.25],33:[0,.69444,.11417,0,.38611],34:[0,.69444,.07939,0,.62055],35:[.19444,.69444,.06833,0,.94444],37:[.05556,.75,.12861,0,.94444],38:[0,.69444,.08528,0,.88555],39:[0,.69444,.12945,0,.35555],40:[.25,.75,.15806,0,.47333],41:[.25,.75,.03306,0,.47333],42:[0,.75,.14333,0,.59111],43:[.10333,.60333,.03306,0,.88555],44:[.19444,.14722,0,0,.35555],45:[0,.44444,.02611,0,.41444],46:[0,.14722,0,0,.35555],47:[.25,.75,.15806,0,.59111],48:[0,.64444,.13167,0,.59111],49:[0,.64444,.13167,0,.59111],50:[0,.64444,.13167,0,.59111],51:[0,.64444,.13167,0,.59111],52:[.19444,.64444,.13167,0,.59111],53:[0,.64444,.13167,0,.59111],54:[0,.64444,.13167,0,.59111],55:[.19444,.64444,.13167,0,.59111],56:[0,.64444,.13167,0,.59111],57:[0,.64444,.13167,0,.59111],58:[0,.44444,.06695,0,.35555],59:[.19444,.44444,.06695,0,.35555],61:[-.10889,.39111,.06833,0,.88555],63:[0,.69444,.11472,0,.59111],64:[0,.69444,.09208,0,.88555],65:[0,.68611,0,0,.86555],66:[0,.68611,.0992,0,.81666],67:[0,.68611,.14208,0,.82666],68:[0,.68611,.09062,0,.87555],69:[0,.68611,.11431,0,.75666],70:[0,.68611,.12903,0,.72722],71:[0,.68611,.07347,0,.89527],72:[0,.68611,.17208,0,.8961],73:[0,.68611,.15681,0,.47166],74:[0,.68611,.145,0,.61055],75:[0,.68611,.14208,0,.89499],76:[0,.68611,0,0,.69777],77:[0,.68611,.17208,0,1.07277],78:[0,.68611,.17208,0,.8961],79:[0,.68611,.09062,0,.85499],80:[0,.68611,.0992,0,.78721],81:[.19444,.68611,.09062,0,.85499],82:[0,.68611,.02559,0,.85944],83:[0,.68611,.11264,0,.64999],84:[0,.68611,.12903,0,.7961],85:[0,.68611,.17208,0,.88083],86:[0,.68611,.18625,0,.86555],87:[0,.68611,.18625,0,1.15999],88:[0,.68611,.15681,0,.86555],89:[0,.68611,.19803,0,.86555],90:[0,.68611,.14208,0,.70888],91:[.25,.75,.1875,0,.35611],93:[.25,.75,.09972,0,.35611],94:[0,.69444,.06709,0,.59111],95:[.31,.13444,.09811,0,.59111],97:[0,.44444,.09426,0,.59111],98:[0,.69444,.07861,0,.53222],99:[0,.44444,.05222,0,.53222],100:[0,.69444,.10861,0,.59111],101:[0,.44444,.085,0,.53222],102:[.19444,.69444,.21778,0,.4],103:[.19444,.44444,.105,0,.53222],104:[0,.69444,.09426,0,.59111],105:[0,.69326,.11387,0,.35555],106:[.19444,.69326,.1672,0,.35555],107:[0,.69444,.11111,0,.53222],108:[0,.69444,.10861,0,.29666],109:[0,.44444,.09426,0,.94444],110:[0,.44444,.09426,0,.64999],111:[0,.44444,.07861,0,.59111],112:[.19444,.44444,.07861,0,.59111],113:[.19444,.44444,.105,0,.53222],114:[0,.44444,.11111,0,.50167],115:[0,.44444,.08167,0,.48694],116:[0,.63492,.09639,0,.385],117:[0,.44444,.09426,0,.62055],118:[0,.44444,.11111,0,.53222],119:[0,.44444,.11111,0,.76777],120:[0,.44444,.12583,0,.56055],121:[.19444,.44444,.105,0,.56166],122:[0,.44444,.13889,0,.49055],126:[.35,.34444,.11472,0,.59111],160:[0,0,0,0,.25],168:[0,.69444,.11473,0,.59111],176:[0,.69444,0,0,.94888],184:[.17014,0,0,0,.53222],198:[0,.68611,.11431,0,1.02277],216:[.04861,.73472,.09062,0,.88555],223:[.19444,.69444,.09736,0,.665],230:[0,.44444,.085,0,.82666],248:[.09722,.54167,.09458,0,.59111],305:[0,.44444,.09426,0,.35555],338:[0,.68611,.11431,0,1.14054],339:[0,.44444,.085,0,.82666],567:[.19444,.44444,.04611,0,.385],710:[0,.69444,.06709,0,.59111],711:[0,.63194,.08271,0,.59111],713:[0,.59444,.10444,0,.59111],714:[0,.69444,.08528,0,.59111],715:[0,.69444,0,0,.59111],728:[0,.69444,.10333,0,.59111],729:[0,.69444,.12945,0,.35555],730:[0,.69444,0,0,.94888],732:[0,.69444,.11472,0,.59111],733:[0,.69444,.11472,0,.59111],915:[0,.68611,.12903,0,.69777],916:[0,.68611,0,0,.94444],920:[0,.68611,.09062,0,.88555],923:[0,.68611,0,0,.80666],926:[0,.68611,.15092,0,.76777],928:[0,.68611,.17208,0,.8961],931:[0,.68611,.11431,0,.82666],933:[0,.68611,.10778,0,.88555],934:[0,.68611,.05632,0,.82666],936:[0,.68611,.10778,0,.88555],937:[0,.68611,.0992,0,.82666],8211:[0,.44444,.09811,0,.59111],8212:[0,.44444,.09811,0,1.18221],8216:[0,.69444,.12945,0,.35555],8217:[0,.69444,.12945,0,.35555],8220:[0,.69444,.16772,0,.62055],8221:[0,.69444,.07939,0,.62055]},"Main-Italic":{32:[0,0,0,0,.25],33:[0,.69444,.12417,0,.30667],34:[0,.69444,.06961,0,.51444],35:[.19444,.69444,.06616,0,.81777],37:[.05556,.75,.13639,0,.81777],38:[0,.69444,.09694,0,.76666],39:[0,.69444,.12417,0,.30667],40:[.25,.75,.16194,0,.40889],41:[.25,.75,.03694,0,.40889],42:[0,.75,.14917,0,.51111],43:[.05667,.56167,.03694,0,.76666],44:[.19444,.10556,0,0,.30667],45:[0,.43056,.02826,0,.35778],46:[0,.10556,0,0,.30667],47:[.25,.75,.16194,0,.51111],48:[0,.64444,.13556,0,.51111],49:[0,.64444,.13556,0,.51111],50:[0,.64444,.13556,0,.51111],51:[0,.64444,.13556,0,.51111],52:[.19444,.64444,.13556,0,.51111],53:[0,.64444,.13556,0,.51111],54:[0,.64444,.13556,0,.51111],55:[.19444,.64444,.13556,0,.51111],56:[0,.64444,.13556,0,.51111],57:[0,.64444,.13556,0,.51111],58:[0,.43056,.0582,0,.30667],59:[.19444,.43056,.0582,0,.30667],61:[-.13313,.36687,.06616,0,.76666],63:[0,.69444,.1225,0,.51111],64:[0,.69444,.09597,0,.76666],65:[0,.68333,0,0,.74333],66:[0,.68333,.10257,0,.70389],67:[0,.68333,.14528,0,.71555],68:[0,.68333,.09403,0,.755],69:[0,.68333,.12028,0,.67833],70:[0,.68333,.13305,0,.65277],71:[0,.68333,.08722,0,.77361],72:[0,.68333,.16389,0,.74333],73:[0,.68333,.15806,0,.38555],74:[0,.68333,.14028,0,.525],75:[0,.68333,.14528,0,.76888],76:[0,.68333,0,0,.62722],77:[0,.68333,.16389,0,.89666],78:[0,.68333,.16389,0,.74333],79:[0,.68333,.09403,0,.76666],80:[0,.68333,.10257,0,.67833],81:[.19444,.68333,.09403,0,.76666],82:[0,.68333,.03868,0,.72944],83:[0,.68333,.11972,0,.56222],84:[0,.68333,.13305,0,.71555],85:[0,.68333,.16389,0,.74333],86:[0,.68333,.18361,0,.74333],87:[0,.68333,.18361,0,.99888],88:[0,.68333,.15806,0,.74333],89:[0,.68333,.19383,0,.74333],90:[0,.68333,.14528,0,.61333],91:[.25,.75,.1875,0,.30667],93:[.25,.75,.10528,0,.30667],94:[0,.69444,.06646,0,.51111],95:[.31,.12056,.09208,0,.51111],97:[0,.43056,.07671,0,.51111],98:[0,.69444,.06312,0,.46],99:[0,.43056,.05653,0,.46],100:[0,.69444,.10333,0,.51111],101:[0,.43056,.07514,0,.46],102:[.19444,.69444,.21194,0,.30667],103:[.19444,.43056,.08847,0,.46],104:[0,.69444,.07671,0,.51111],105:[0,.65536,.1019,0,.30667],106:[.19444,.65536,.14467,0,.30667],107:[0,.69444,.10764,0,.46],108:[0,.69444,.10333,0,.25555],109:[0,.43056,.07671,0,.81777],110:[0,.43056,.07671,0,.56222],111:[0,.43056,.06312,0,.51111],112:[.19444,.43056,.06312,0,.51111],113:[.19444,.43056,.08847,0,.46],114:[0,.43056,.10764,0,.42166],115:[0,.43056,.08208,0,.40889],116:[0,.61508,.09486,0,.33222],117:[0,.43056,.07671,0,.53666],118:[0,.43056,.10764,0,.46],119:[0,.43056,.10764,0,.66444],120:[0,.43056,.12042,0,.46389],121:[.19444,.43056,.08847,0,.48555],122:[0,.43056,.12292,0,.40889],126:[.35,.31786,.11585,0,.51111],160:[0,0,0,0,.25],168:[0,.66786,.10474,0,.51111],176:[0,.69444,0,0,.83129],184:[.17014,0,0,0,.46],198:[0,.68333,.12028,0,.88277],216:[.04861,.73194,.09403,0,.76666],223:[.19444,.69444,.10514,0,.53666],230:[0,.43056,.07514,0,.71555],248:[.09722,.52778,.09194,0,.51111],338:[0,.68333,.12028,0,.98499],339:[0,.43056,.07514,0,.71555],710:[0,.69444,.06646,0,.51111],711:[0,.62847,.08295,0,.51111],713:[0,.56167,.10333,0,.51111],714:[0,.69444,.09694,0,.51111],715:[0,.69444,0,0,.51111],728:[0,.69444,.10806,0,.51111],729:[0,.66786,.11752,0,.30667],730:[0,.69444,0,0,.83129],732:[0,.66786,.11585,0,.51111],733:[0,.69444,.1225,0,.51111],915:[0,.68333,.13305,0,.62722],916:[0,.68333,0,0,.81777],920:[0,.68333,.09403,0,.76666],923:[0,.68333,0,0,.69222],926:[0,.68333,.15294,0,.66444],928:[0,.68333,.16389,0,.74333],931:[0,.68333,.12028,0,.71555],933:[0,.68333,.11111,0,.76666],934:[0,.68333,.05986,0,.71555],936:[0,.68333,.11111,0,.76666],937:[0,.68333,.10257,0,.71555],8211:[0,.43056,.09208,0,.51111],8212:[0,.43056,.09208,0,1.02222],8216:[0,.69444,.12417,0,.30667],8217:[0,.69444,.12417,0,.30667],8220:[0,.69444,.1685,0,.51444],8221:[0,.69444,.06961,0,.51444],8463:[0,.68889,0,0,.54028]},"Main-Regular":{32:[0,0,0,0,.25],33:[0,.69444,0,0,.27778],34:[0,.69444,0,0,.5],35:[.19444,.69444,0,0,.83334],36:[.05556,.75,0,0,.5],37:[.05556,.75,0,0,.83334],38:[0,.69444,0,0,.77778],39:[0,.69444,0,0,.27778],40:[.25,.75,0,0,.38889],41:[.25,.75,0,0,.38889],42:[0,.75,0,0,.5],43:[.08333,.58333,0,0,.77778],44:[.19444,.10556,0,0,.27778],45:[0,.43056,0,0,.33333],46:[0,.10556,0,0,.27778],47:[.25,.75,0,0,.5],48:[0,.64444,0,0,.5],49:[0,.64444,0,0,.5],50:[0,.64444,0,0,.5],51:[0,.64444,0,0,.5],52:[0,.64444,0,0,.5],53:[0,.64444,0,0,.5],54:[0,.64444,0,0,.5],55:[0,.64444,0,0,.5],56:[0,.64444,0,0,.5],57:[0,.64444,0,0,.5],58:[0,.43056,0,0,.27778],59:[.19444,.43056,0,0,.27778],60:[.0391,.5391,0,0,.77778],61:[-.13313,.36687,0,0,.77778],62:[.0391,.5391,0,0,.77778],63:[0,.69444,0,0,.47222],64:[0,.69444,0,0,.77778],65:[0,.68333,0,0,.75],66:[0,.68333,0,0,.70834],67:[0,.68333,0,0,.72222],68:[0,.68333,0,0,.76389],69:[0,.68333,0,0,.68056],70:[0,.68333,0,0,.65278],71:[0,.68333,0,0,.78472],72:[0,.68333,0,0,.75],73:[0,.68333,0,0,.36111],74:[0,.68333,0,0,.51389],75:[0,.68333,0,0,.77778],76:[0,.68333,0,0,.625],77:[0,.68333,0,0,.91667],78:[0,.68333,0,0,.75],79:[0,.68333,0,0,.77778],80:[0,.68333,0,0,.68056],81:[.19444,.68333,0,0,.77778],82:[0,.68333,0,0,.73611],83:[0,.68333,0,0,.55556],84:[0,.68333,0,0,.72222],85:[0,.68333,0,0,.75],86:[0,.68333,.01389,0,.75],87:[0,.68333,.01389,0,1.02778],88:[0,.68333,0,0,.75],89:[0,.68333,.025,0,.75],90:[0,.68333,0,0,.61111],91:[.25,.75,0,0,.27778],92:[.25,.75,0,0,.5],93:[.25,.75,0,0,.27778],94:[0,.69444,0,0,.5],95:[.31,.12056,.02778,0,.5],97:[0,.43056,0,0,.5],98:[0,.69444,0,0,.55556],99:[0,.43056,0,0,.44445],100:[0,.69444,0,0,.55556],101:[0,.43056,0,0,.44445],102:[0,.69444,.07778,0,.30556],103:[.19444,.43056,.01389,0,.5],104:[0,.69444,0,0,.55556],105:[0,.66786,0,0,.27778],106:[.19444,.66786,0,0,.30556],107:[0,.69444,0,0,.52778],108:[0,.69444,0,0,.27778],109:[0,.43056,0,0,.83334],110:[0,.43056,0,0,.55556],111:[0,.43056,0,0,.5],112:[.19444,.43056,0,0,.55556],113:[.19444,.43056,0,0,.52778],114:[0,.43056,0,0,.39167],115:[0,.43056,0,0,.39445],116:[0,.61508,0,0,.38889],117:[0,.43056,0,0,.55556],118:[0,.43056,.01389,0,.52778],119:[0,.43056,.01389,0,.72222],120:[0,.43056,0,0,.52778],121:[.19444,.43056,.01389,0,.52778],122:[0,.43056,0,0,.44445],123:[.25,.75,0,0,.5],124:[.25,.75,0,0,.27778],125:[.25,.75,0,0,.5],126:[.35,.31786,0,0,.5],160:[0,0,0,0,.25],163:[0,.69444,0,0,.76909],167:[.19444,.69444,0,0,.44445],168:[0,.66786,0,0,.5],172:[0,.43056,0,0,.66667],176:[0,.69444,0,0,.75],177:[.08333,.58333,0,0,.77778],182:[.19444,.69444,0,0,.61111],184:[.17014,0,0,0,.44445],198:[0,.68333,0,0,.90278],215:[.08333,.58333,0,0,.77778],216:[.04861,.73194,0,0,.77778],223:[0,.69444,0,0,.5],230:[0,.43056,0,0,.72222],247:[.08333,.58333,0,0,.77778],248:[.09722,.52778,0,0,.5],305:[0,.43056,0,0,.27778],338:[0,.68333,0,0,1.01389],339:[0,.43056,0,0,.77778],567:[.19444,.43056,0,0,.30556],710:[0,.69444,0,0,.5],711:[0,.62847,0,0,.5],713:[0,.56778,0,0,.5],714:[0,.69444,0,0,.5],715:[0,.69444,0,0,.5],728:[0,.69444,0,0,.5],729:[0,.66786,0,0,.27778],730:[0,.69444,0,0,.75],732:[0,.66786,0,0,.5],733:[0,.69444,0,0,.5],915:[0,.68333,0,0,.625],916:[0,.68333,0,0,.83334],920:[0,.68333,0,0,.77778],923:[0,.68333,0,0,.69445],926:[0,.68333,0,0,.66667],928:[0,.68333,0,0,.75],931:[0,.68333,0,0,.72222],933:[0,.68333,0,0,.77778],934:[0,.68333,0,0,.72222],936:[0,.68333,0,0,.77778],937:[0,.68333,0,0,.72222],8211:[0,.43056,.02778,0,.5],8212:[0,.43056,.02778,0,1],8216:[0,.69444,0,0,.27778],8217:[0,.69444,0,0,.27778],8220:[0,.69444,0,0,.5],8221:[0,.69444,0,0,.5],8224:[.19444,.69444,0,0,.44445],8225:[.19444,.69444,0,0,.44445],8230:[0,.123,0,0,1.172],8242:[0,.55556,0,0,.275],8407:[0,.71444,.15382,0,.5],8463:[0,.68889,0,0,.54028],8465:[0,.69444,0,0,.72222],8467:[0,.69444,0,.11111,.41667],8472:[.19444,.43056,0,.11111,.63646],8476:[0,.69444,0,0,.72222],8501:[0,.69444,0,0,.61111],8592:[-.13313,.36687,0,0,1],8593:[.19444,.69444,0,0,.5],8594:[-.13313,.36687,0,0,1],8595:[.19444,.69444,0,0,.5],8596:[-.13313,.36687,0,0,1],8597:[.25,.75,0,0,.5],8598:[.19444,.69444,0,0,1],8599:[.19444,.69444,0,0,1],8600:[.19444,.69444,0,0,1],8601:[.19444,.69444,0,0,1],8614:[.011,.511,0,0,1],8617:[.011,.511,0,0,1.126],8618:[.011,.511,0,0,1.126],8636:[-.13313,.36687,0,0,1],8637:[-.13313,.36687,0,0,1],8640:[-.13313,.36687,0,0,1],8641:[-.13313,.36687,0,0,1],8652:[.011,.671,0,0,1],8656:[-.13313,.36687,0,0,1],8657:[.19444,.69444,0,0,.61111],8658:[-.13313,.36687,0,0,1],8659:[.19444,.69444,0,0,.61111],8660:[-.13313,.36687,0,0,1],8661:[.25,.75,0,0,.61111],8704:[0,.69444,0,0,.55556],8706:[0,.69444,.05556,.08334,.5309],8707:[0,.69444,0,0,.55556],8709:[.05556,.75,0,0,.5],8711:[0,.68333,0,0,.83334],8712:[.0391,.5391,0,0,.66667],8715:[.0391,.5391,0,0,.66667],8722:[.08333,.58333,0,0,.77778],8723:[.08333,.58333,0,0,.77778],8725:[.25,.75,0,0,.5],8726:[.25,.75,0,0,.5],8727:[-.03472,.46528,0,0,.5],8728:[-.05555,.44445,0,0,.5],8729:[-.05555,.44445,0,0,.5],8730:[.2,.8,0,0,.83334],8733:[0,.43056,0,0,.77778],8734:[0,.43056,0,0,1],8736:[0,.69224,0,0,.72222],8739:[.25,.75,0,0,.27778],8741:[.25,.75,0,0,.5],8743:[0,.55556,0,0,.66667],8744:[0,.55556,0,0,.66667],8745:[0,.55556,0,0,.66667],8746:[0,.55556,0,0,.66667],8747:[.19444,.69444,.11111,0,.41667],8764:[-.13313,.36687,0,0,.77778],8768:[.19444,.69444,0,0,.27778],8771:[-.03625,.46375,0,0,.77778],8773:[-.022,.589,0,0,.778],8776:[-.01688,.48312,0,0,.77778],8781:[-.03625,.46375,0,0,.77778],8784:[-.133,.673,0,0,.778],8801:[-.03625,.46375,0,0,.77778],8804:[.13597,.63597,0,0,.77778],8805:[.13597,.63597,0,0,.77778],8810:[.0391,.5391,0,0,1],8811:[.0391,.5391,0,0,1],8826:[.0391,.5391,0,0,.77778],8827:[.0391,.5391,0,0,.77778],8834:[.0391,.5391,0,0,.77778],8835:[.0391,.5391,0,0,.77778],8838:[.13597,.63597,0,0,.77778],8839:[.13597,.63597,0,0,.77778],8846:[0,.55556,0,0,.66667],8849:[.13597,.63597,0,0,.77778],8850:[.13597,.63597,0,0,.77778],8851:[0,.55556,0,0,.66667],8852:[0,.55556,0,0,.66667],8853:[.08333,.58333,0,0,.77778],8854:[.08333,.58333,0,0,.77778],8855:[.08333,.58333,0,0,.77778],8856:[.08333,.58333,0,0,.77778],8857:[.08333,.58333,0,0,.77778],8866:[0,.69444,0,0,.61111],8867:[0,.69444,0,0,.61111],8868:[0,.69444,0,0,.77778],8869:[0,.69444,0,0,.77778],8872:[.249,.75,0,0,.867],8900:[-.05555,.44445,0,0,.5],8901:[-.05555,.44445,0,0,.27778],8902:[-.03472,.46528,0,0,.5],8904:[.005,.505,0,0,.9],8942:[.03,.903,0,0,.278],8943:[-.19,.313,0,0,1.172],8945:[-.1,.823,0,0,1.282],8968:[.25,.75,0,0,.44445],8969:[.25,.75,0,0,.44445],8970:[.25,.75,0,0,.44445],8971:[.25,.75,0,0,.44445],8994:[-.14236,.35764,0,0,1],8995:[-.14236,.35764,0,0,1],9136:[.244,.744,0,0,.412],9137:[.244,.745,0,0,.412],9651:[.19444,.69444,0,0,.88889],9657:[-.03472,.46528,0,0,.5],9661:[.19444,.69444,0,0,.88889],9667:[-.03472,.46528,0,0,.5],9711:[.19444,.69444,0,0,1],9824:[.12963,.69444,0,0,.77778],9825:[.12963,.69444,0,0,.77778],9826:[.12963,.69444,0,0,.77778],9827:[.12963,.69444,0,0,.77778],9837:[0,.75,0,0,.38889],9838:[.19444,.69444,0,0,.38889],9839:[.19444,.69444,0,0,.38889],10216:[.25,.75,0,0,.38889],10217:[.25,.75,0,0,.38889],10222:[.244,.744,0,0,.412],10223:[.244,.745,0,0,.412],10229:[.011,.511,0,0,1.609],10230:[.011,.511,0,0,1.638],10231:[.011,.511,0,0,1.859],10232:[.024,.525,0,0,1.609],10233:[.024,.525,0,0,1.638],10234:[.024,.525,0,0,1.858],10236:[.011,.511,0,0,1.638],10815:[0,.68333,0,0,.75],10927:[.13597,.63597,0,0,.77778],10928:[.13597,.63597,0,0,.77778],57376:[.19444,.69444,0,0,0]},"Math-BoldItalic":{32:[0,0,0,0,.25],48:[0,.44444,0,0,.575],49:[0,.44444,0,0,.575],50:[0,.44444,0,0,.575],51:[.19444,.44444,0,0,.575],52:[.19444,.44444,0,0,.575],53:[.19444,.44444,0,0,.575],54:[0,.64444,0,0,.575],55:[.19444,.44444,0,0,.575],56:[0,.64444,0,0,.575],57:[.19444,.44444,0,0,.575],65:[0,.68611,0,0,.86944],66:[0,.68611,.04835,0,.8664],67:[0,.68611,.06979,0,.81694],68:[0,.68611,.03194,0,.93812],69:[0,.68611,.05451,0,.81007],70:[0,.68611,.15972,0,.68889],71:[0,.68611,0,0,.88673],72:[0,.68611,.08229,0,.98229],73:[0,.68611,.07778,0,.51111],74:[0,.68611,.10069,0,.63125],75:[0,.68611,.06979,0,.97118],76:[0,.68611,0,0,.75555],77:[0,.68611,.11424,0,1.14201],78:[0,.68611,.11424,0,.95034],79:[0,.68611,.03194,0,.83666],80:[0,.68611,.15972,0,.72309],81:[.19444,.68611,0,0,.86861],82:[0,.68611,.00421,0,.87235],83:[0,.68611,.05382,0,.69271],84:[0,.68611,.15972,0,.63663],85:[0,.68611,.11424,0,.80027],86:[0,.68611,.25555,0,.67778],87:[0,.68611,.15972,0,1.09305],88:[0,.68611,.07778,0,.94722],89:[0,.68611,.25555,0,.67458],90:[0,.68611,.06979,0,.77257],97:[0,.44444,0,0,.63287],98:[0,.69444,0,0,.52083],99:[0,.44444,0,0,.51342],100:[0,.69444,0,0,.60972],101:[0,.44444,0,0,.55361],102:[.19444,.69444,.11042,0,.56806],103:[.19444,.44444,.03704,0,.5449],104:[0,.69444,0,0,.66759],105:[0,.69326,0,0,.4048],106:[.19444,.69326,.0622,0,.47083],107:[0,.69444,.01852,0,.6037],108:[0,.69444,.0088,0,.34815],109:[0,.44444,0,0,1.0324],110:[0,.44444,0,0,.71296],111:[0,.44444,0,0,.58472],112:[.19444,.44444,0,0,.60092],113:[.19444,.44444,.03704,0,.54213],114:[0,.44444,.03194,0,.5287],115:[0,.44444,0,0,.53125],116:[0,.63492,0,0,.41528],117:[0,.44444,0,0,.68102],118:[0,.44444,.03704,0,.56666],119:[0,.44444,.02778,0,.83148],120:[0,.44444,0,0,.65903],121:[.19444,.44444,.03704,0,.59028],122:[0,.44444,.04213,0,.55509],160:[0,0,0,0,.25],915:[0,.68611,.15972,0,.65694],916:[0,.68611,0,0,.95833],920:[0,.68611,.03194,0,.86722],923:[0,.68611,0,0,.80555],926:[0,.68611,.07458,0,.84125],928:[0,.68611,.08229,0,.98229],931:[0,.68611,.05451,0,.88507],933:[0,.68611,.15972,0,.67083],934:[0,.68611,0,0,.76666],936:[0,.68611,.11653,0,.71402],937:[0,.68611,.04835,0,.8789],945:[0,.44444,0,0,.76064],946:[.19444,.69444,.03403,0,.65972],947:[.19444,.44444,.06389,0,.59003],948:[0,.69444,.03819,0,.52222],949:[0,.44444,0,0,.52882],950:[.19444,.69444,.06215,0,.50833],951:[.19444,.44444,.03704,0,.6],952:[0,.69444,.03194,0,.5618],953:[0,.44444,0,0,.41204],954:[0,.44444,0,0,.66759],955:[0,.69444,0,0,.67083],956:[.19444,.44444,0,0,.70787],957:[0,.44444,.06898,0,.57685],958:[.19444,.69444,.03021,0,.50833],959:[0,.44444,0,0,.58472],960:[0,.44444,.03704,0,.68241],961:[.19444,.44444,0,0,.6118],962:[.09722,.44444,.07917,0,.42361],963:[0,.44444,.03704,0,.68588],964:[0,.44444,.13472,0,.52083],965:[0,.44444,.03704,0,.63055],966:[.19444,.44444,0,0,.74722],967:[.19444,.44444,0,0,.71805],968:[.19444,.69444,.03704,0,.75833],969:[0,.44444,.03704,0,.71782],977:[0,.69444,0,0,.69155],981:[.19444,.69444,0,0,.7125],982:[0,.44444,.03194,0,.975],1009:[.19444,.44444,0,0,.6118],1013:[0,.44444,0,0,.48333],57649:[0,.44444,0,0,.39352],57911:[.19444,.44444,0,0,.43889]},"Math-Italic":{32:[0,0,0,0,.25],48:[0,.43056,0,0,.5],49:[0,.43056,0,0,.5],50:[0,.43056,0,0,.5],51:[.19444,.43056,0,0,.5],52:[.19444,.43056,0,0,.5],53:[.19444,.43056,0,0,.5],54:[0,.64444,0,0,.5],55:[.19444,.43056,0,0,.5],56:[0,.64444,0,0,.5],57:[.19444,.43056,0,0,.5],65:[0,.68333,0,.13889,.75],66:[0,.68333,.05017,.08334,.75851],67:[0,.68333,.07153,.08334,.71472],68:[0,.68333,.02778,.05556,.82792],69:[0,.68333,.05764,.08334,.7382],70:[0,.68333,.13889,.08334,.64306],71:[0,.68333,0,.08334,.78625],72:[0,.68333,.08125,.05556,.83125],73:[0,.68333,.07847,.11111,.43958],74:[0,.68333,.09618,.16667,.55451],75:[0,.68333,.07153,.05556,.84931],76:[0,.68333,0,.02778,.68056],77:[0,.68333,.10903,.08334,.97014],78:[0,.68333,.10903,.08334,.80347],79:[0,.68333,.02778,.08334,.76278],80:[0,.68333,.13889,.08334,.64201],81:[.19444,.68333,0,.08334,.79056],82:[0,.68333,.00773,.08334,.75929],83:[0,.68333,.05764,.08334,.6132],84:[0,.68333,.13889,.08334,.58438],85:[0,.68333,.10903,.02778,.68278],86:[0,.68333,.22222,0,.58333],87:[0,.68333,.13889,0,.94445],88:[0,.68333,.07847,.08334,.82847],89:[0,.68333,.22222,0,.58056],90:[0,.68333,.07153,.08334,.68264],97:[0,.43056,0,0,.52859],98:[0,.69444,0,0,.42917],99:[0,.43056,0,.05556,.43276],100:[0,.69444,0,.16667,.52049],101:[0,.43056,0,.05556,.46563],102:[.19444,.69444,.10764,.16667,.48959],103:[.19444,.43056,.03588,.02778,.47697],104:[0,.69444,0,0,.57616],105:[0,.65952,0,0,.34451],106:[.19444,.65952,.05724,0,.41181],107:[0,.69444,.03148,0,.5206],108:[0,.69444,.01968,.08334,.29838],109:[0,.43056,0,0,.87801],110:[0,.43056,0,0,.60023],111:[0,.43056,0,.05556,.48472],112:[.19444,.43056,0,.08334,.50313],113:[.19444,.43056,.03588,.08334,.44641],114:[0,.43056,.02778,.05556,.45116],115:[0,.43056,0,.05556,.46875],116:[0,.61508,0,.08334,.36111],117:[0,.43056,0,.02778,.57246],118:[0,.43056,.03588,.02778,.48472],119:[0,.43056,.02691,.08334,.71592],120:[0,.43056,0,.02778,.57153],121:[.19444,.43056,.03588,.05556,.49028],122:[0,.43056,.04398,.05556,.46505],160:[0,0,0,0,.25],915:[0,.68333,.13889,.08334,.61528],916:[0,.68333,0,.16667,.83334],920:[0,.68333,.02778,.08334,.76278],923:[0,.68333,0,.16667,.69445],926:[0,.68333,.07569,.08334,.74236],928:[0,.68333,.08125,.05556,.83125],931:[0,.68333,.05764,.08334,.77986],933:[0,.68333,.13889,.05556,.58333],934:[0,.68333,0,.08334,.66667],936:[0,.68333,.11,.05556,.61222],937:[0,.68333,.05017,.08334,.7724],945:[0,.43056,.0037,.02778,.6397],946:[.19444,.69444,.05278,.08334,.56563],947:[.19444,.43056,.05556,0,.51773],948:[0,.69444,.03785,.05556,.44444],949:[0,.43056,0,.08334,.46632],950:[.19444,.69444,.07378,.08334,.4375],951:[.19444,.43056,.03588,.05556,.49653],952:[0,.69444,.02778,.08334,.46944],953:[0,.43056,0,.05556,.35394],954:[0,.43056,0,0,.57616],955:[0,.69444,0,0,.58334],956:[.19444,.43056,0,.02778,.60255],957:[0,.43056,.06366,.02778,.49398],958:[.19444,.69444,.04601,.11111,.4375],959:[0,.43056,0,.05556,.48472],960:[0,.43056,.03588,0,.57003],961:[.19444,.43056,0,.08334,.51702],962:[.09722,.43056,.07986,.08334,.36285],963:[0,.43056,.03588,0,.57141],964:[0,.43056,.1132,.02778,.43715],965:[0,.43056,.03588,.02778,.54028],966:[.19444,.43056,0,.08334,.65417],967:[.19444,.43056,0,.05556,.62569],968:[.19444,.69444,.03588,.11111,.65139],969:[0,.43056,.03588,0,.62245],977:[0,.69444,0,.08334,.59144],981:[.19444,.69444,0,.08334,.59583],982:[0,.43056,.02778,0,.82813],1009:[.19444,.43056,0,.08334,.51702],1013:[0,.43056,0,.05556,.4059],57649:[0,.43056,0,.02778,.32246],57911:[.19444,.43056,0,.08334,.38403]},"SansSerif-Bold":{32:[0,0,0,0,.25],33:[0,.69444,0,0,.36667],34:[0,.69444,0,0,.55834],35:[.19444,.69444,0,0,.91667],36:[.05556,.75,0,0,.55],37:[.05556,.75,0,0,1.02912],38:[0,.69444,0,0,.83056],39:[0,.69444,0,0,.30556],40:[.25,.75,0,0,.42778],41:[.25,.75,0,0,.42778],42:[0,.75,0,0,.55],43:[.11667,.61667,0,0,.85556],44:[.10556,.13056,0,0,.30556],45:[0,.45833,0,0,.36667],46:[0,.13056,0,0,.30556],47:[.25,.75,0,0,.55],48:[0,.69444,0,0,.55],49:[0,.69444,0,0,.55],50:[0,.69444,0,0,.55],51:[0,.69444,0,0,.55],52:[0,.69444,0,0,.55],53:[0,.69444,0,0,.55],54:[0,.69444,0,0,.55],55:[0,.69444,0,0,.55],56:[0,.69444,0,0,.55],57:[0,.69444,0,0,.55],58:[0,.45833,0,0,.30556],59:[.10556,.45833,0,0,.30556],61:[-.09375,.40625,0,0,.85556],63:[0,.69444,0,0,.51945],64:[0,.69444,0,0,.73334],65:[0,.69444,0,0,.73334],66:[0,.69444,0,0,.73334],67:[0,.69444,0,0,.70278],68:[0,.69444,0,0,.79445],69:[0,.69444,0,0,.64167],70:[0,.69444,0,0,.61111],71:[0,.69444,0,0,.73334],72:[0,.69444,0,0,.79445],73:[0,.69444,0,0,.33056],74:[0,.69444,0,0,.51945],75:[0,.69444,0,0,.76389],76:[0,.69444,0,0,.58056],77:[0,.69444,0,0,.97778],78:[0,.69444,0,0,.79445],79:[0,.69444,0,0,.79445],80:[0,.69444,0,0,.70278],81:[.10556,.69444,0,0,.79445],82:[0,.69444,0,0,.70278],83:[0,.69444,0,0,.61111],84:[0,.69444,0,0,.73334],85:[0,.69444,0,0,.76389],86:[0,.69444,.01528,0,.73334],87:[0,.69444,.01528,0,1.03889],88:[0,.69444,0,0,.73334],89:[0,.69444,.0275,0,.73334],90:[0,.69444,0,0,.67223],91:[.25,.75,0,0,.34306],93:[.25,.75,0,0,.34306],94:[0,.69444,0,0,.55],95:[.35,.10833,.03056,0,.55],97:[0,.45833,0,0,.525],98:[0,.69444,0,0,.56111],99:[0,.45833,0,0,.48889],100:[0,.69444,0,0,.56111],101:[0,.45833,0,0,.51111],102:[0,.69444,.07639,0,.33611],103:[.19444,.45833,.01528,0,.55],104:[0,.69444,0,0,.56111],105:[0,.69444,0,0,.25556],106:[.19444,.69444,0,0,.28611],107:[0,.69444,0,0,.53056],108:[0,.69444,0,0,.25556],109:[0,.45833,0,0,.86667],110:[0,.45833,0,0,.56111],111:[0,.45833,0,0,.55],112:[.19444,.45833,0,0,.56111],113:[.19444,.45833,0,0,.56111],114:[0,.45833,.01528,0,.37222],115:[0,.45833,0,0,.42167],116:[0,.58929,0,0,.40417],117:[0,.45833,0,0,.56111],118:[0,.45833,.01528,0,.5],119:[0,.45833,.01528,0,.74445],120:[0,.45833,0,0,.5],121:[.19444,.45833,.01528,0,.5],122:[0,.45833,0,0,.47639],126:[.35,.34444,0,0,.55],160:[0,0,0,0,.25],168:[0,.69444,0,0,.55],176:[0,.69444,0,0,.73334],180:[0,.69444,0,0,.55],184:[.17014,0,0,0,.48889],305:[0,.45833,0,0,.25556],567:[.19444,.45833,0,0,.28611],710:[0,.69444,0,0,.55],711:[0,.63542,0,0,.55],713:[0,.63778,0,0,.55],728:[0,.69444,0,0,.55],729:[0,.69444,0,0,.30556],730:[0,.69444,0,0,.73334],732:[0,.69444,0,0,.55],733:[0,.69444,0,0,.55],915:[0,.69444,0,0,.58056],916:[0,.69444,0,0,.91667],920:[0,.69444,0,0,.85556],923:[0,.69444,0,0,.67223],926:[0,.69444,0,0,.73334],928:[0,.69444,0,0,.79445],931:[0,.69444,0,0,.79445],933:[0,.69444,0,0,.85556],934:[0,.69444,0,0,.79445],936:[0,.69444,0,0,.85556],937:[0,.69444,0,0,.79445],8211:[0,.45833,.03056,0,.55],8212:[0,.45833,.03056,0,1.10001],8216:[0,.69444,0,0,.30556],8217:[0,.69444,0,0,.30556],8220:[0,.69444,0,0,.55834],8221:[0,.69444,0,0,.55834]},"SansSerif-Italic":{32:[0,0,0,0,.25],33:[0,.69444,.05733,0,.31945],34:[0,.69444,.00316,0,.5],35:[.19444,.69444,.05087,0,.83334],36:[.05556,.75,.11156,0,.5],37:[.05556,.75,.03126,0,.83334],38:[0,.69444,.03058,0,.75834],39:[0,.69444,.07816,0,.27778],40:[.25,.75,.13164,0,.38889],41:[.25,.75,.02536,0,.38889],42:[0,.75,.11775,0,.5],43:[.08333,.58333,.02536,0,.77778],44:[.125,.08333,0,0,.27778],45:[0,.44444,.01946,0,.33333],46:[0,.08333,0,0,.27778],47:[.25,.75,.13164,0,.5],48:[0,.65556,.11156,0,.5],49:[0,.65556,.11156,0,.5],50:[0,.65556,.11156,0,.5],51:[0,.65556,.11156,0,.5],52:[0,.65556,.11156,0,.5],53:[0,.65556,.11156,0,.5],54:[0,.65556,.11156,0,.5],55:[0,.65556,.11156,0,.5],56:[0,.65556,.11156,0,.5],57:[0,.65556,.11156,0,.5],58:[0,.44444,.02502,0,.27778],59:[.125,.44444,.02502,0,.27778],61:[-.13,.37,.05087,0,.77778],63:[0,.69444,.11809,0,.47222],64:[0,.69444,.07555,0,.66667],65:[0,.69444,0,0,.66667],66:[0,.69444,.08293,0,.66667],67:[0,.69444,.11983,0,.63889],68:[0,.69444,.07555,0,.72223],69:[0,.69444,.11983,0,.59722],70:[0,.69444,.13372,0,.56945],71:[0,.69444,.11983,0,.66667],72:[0,.69444,.08094,0,.70834],73:[0,.69444,.13372,0,.27778],74:[0,.69444,.08094,0,.47222],75:[0,.69444,.11983,0,.69445],76:[0,.69444,0,0,.54167],77:[0,.69444,.08094,0,.875],78:[0,.69444,.08094,0,.70834],79:[0,.69444,.07555,0,.73611],80:[0,.69444,.08293,0,.63889],81:[.125,.69444,.07555,0,.73611],82:[0,.69444,.08293,0,.64584],83:[0,.69444,.09205,0,.55556],84:[0,.69444,.13372,0,.68056],85:[0,.69444,.08094,0,.6875],86:[0,.69444,.1615,0,.66667],87:[0,.69444,.1615,0,.94445],88:[0,.69444,.13372,0,.66667],89:[0,.69444,.17261,0,.66667],90:[0,.69444,.11983,0,.61111],91:[.25,.75,.15942,0,.28889],93:[.25,.75,.08719,0,.28889],94:[0,.69444,.0799,0,.5],95:[.35,.09444,.08616,0,.5],97:[0,.44444,.00981,0,.48056],98:[0,.69444,.03057,0,.51667],99:[0,.44444,.08336,0,.44445],100:[0,.69444,.09483,0,.51667],101:[0,.44444,.06778,0,.44445],102:[0,.69444,.21705,0,.30556],103:[.19444,.44444,.10836,0,.5],104:[0,.69444,.01778,0,.51667],105:[0,.67937,.09718,0,.23889],106:[.19444,.67937,.09162,0,.26667],107:[0,.69444,.08336,0,.48889],108:[0,.69444,.09483,0,.23889],109:[0,.44444,.01778,0,.79445],110:[0,.44444,.01778,0,.51667],111:[0,.44444,.06613,0,.5],112:[.19444,.44444,.0389,0,.51667],113:[.19444,.44444,.04169,0,.51667],114:[0,.44444,.10836,0,.34167],115:[0,.44444,.0778,0,.38333],116:[0,.57143,.07225,0,.36111],117:[0,.44444,.04169,0,.51667],118:[0,.44444,.10836,0,.46111],119:[0,.44444,.10836,0,.68334],120:[0,.44444,.09169,0,.46111],121:[.19444,.44444,.10836,0,.46111],122:[0,.44444,.08752,0,.43472],126:[.35,.32659,.08826,0,.5],160:[0,0,0,0,.25],168:[0,.67937,.06385,0,.5],176:[0,.69444,0,0,.73752],184:[.17014,0,0,0,.44445],305:[0,.44444,.04169,0,.23889],567:[.19444,.44444,.04169,0,.26667],710:[0,.69444,.0799,0,.5],711:[0,.63194,.08432,0,.5],713:[0,.60889,.08776,0,.5],714:[0,.69444,.09205,0,.5],715:[0,.69444,0,0,.5],728:[0,.69444,.09483,0,.5],729:[0,.67937,.07774,0,.27778],730:[0,.69444,0,0,.73752],732:[0,.67659,.08826,0,.5],733:[0,.69444,.09205,0,.5],915:[0,.69444,.13372,0,.54167],916:[0,.69444,0,0,.83334],920:[0,.69444,.07555,0,.77778],923:[0,.69444,0,0,.61111],926:[0,.69444,.12816,0,.66667],928:[0,.69444,.08094,0,.70834],931:[0,.69444,.11983,0,.72222],933:[0,.69444,.09031,0,.77778],934:[0,.69444,.04603,0,.72222],936:[0,.69444,.09031,0,.77778],937:[0,.69444,.08293,0,.72222],8211:[0,.44444,.08616,0,.5],8212:[0,.44444,.08616,0,1],8216:[0,.69444,.07816,0,.27778],8217:[0,.69444,.07816,0,.27778],8220:[0,.69444,.14205,0,.5],8221:[0,.69444,.00316,0,.5]},"SansSerif-Regular":{32:[0,0,0,0,.25],33:[0,.69444,0,0,.31945],34:[0,.69444,0,0,.5],35:[.19444,.69444,0,0,.83334],36:[.05556,.75,0,0,.5],37:[.05556,.75,0,0,.83334],38:[0,.69444,0,0,.75834],39:[0,.69444,0,0,.27778],40:[.25,.75,0,0,.38889],41:[.25,.75,0,0,.38889],42:[0,.75,0,0,.5],43:[.08333,.58333,0,0,.77778],44:[.125,.08333,0,0,.27778],45:[0,.44444,0,0,.33333],46:[0,.08333,0,0,.27778],47:[.25,.75,0,0,.5],48:[0,.65556,0,0,.5],49:[0,.65556,0,0,.5],50:[0,.65556,0,0,.5],51:[0,.65556,0,0,.5],52:[0,.65556,0,0,.5],53:[0,.65556,0,0,.5],54:[0,.65556,0,0,.5],55:[0,.65556,0,0,.5],56:[0,.65556,0,0,.5],57:[0,.65556,0,0,.5],58:[0,.44444,0,0,.27778],59:[.125,.44444,0,0,.27778],61:[-.13,.37,0,0,.77778],63:[0,.69444,0,0,.47222],64:[0,.69444,0,0,.66667],65:[0,.69444,0,0,.66667],66:[0,.69444,0,0,.66667],67:[0,.69444,0,0,.63889],68:[0,.69444,0,0,.72223],69:[0,.69444,0,0,.59722],70:[0,.69444,0,0,.56945],71:[0,.69444,0,0,.66667],72:[0,.69444,0,0,.70834],73:[0,.69444,0,0,.27778],74:[0,.69444,0,0,.47222],75:[0,.69444,0,0,.69445],76:[0,.69444,0,0,.54167],77:[0,.69444,0,0,.875],78:[0,.69444,0,0,.70834],79:[0,.69444,0,0,.73611],80:[0,.69444,0,0,.63889],81:[.125,.69444,0,0,.73611],82:[0,.69444,0,0,.64584],83:[0,.69444,0,0,.55556],84:[0,.69444,0,0,.68056],85:[0,.69444,0,0,.6875],86:[0,.69444,.01389,0,.66667],87:[0,.69444,.01389,0,.94445],88:[0,.69444,0,0,.66667],89:[0,.69444,.025,0,.66667],90:[0,.69444,0,0,.61111],91:[.25,.75,0,0,.28889],93:[.25,.75,0,0,.28889],94:[0,.69444,0,0,.5],95:[.35,.09444,.02778,0,.5],97:[0,.44444,0,0,.48056],98:[0,.69444,0,0,.51667],99:[0,.44444,0,0,.44445],100:[0,.69444,0,0,.51667],101:[0,.44444,0,0,.44445],102:[0,.69444,.06944,0,.30556],103:[.19444,.44444,.01389,0,.5],104:[0,.69444,0,0,.51667],105:[0,.67937,0,0,.23889],106:[.19444,.67937,0,0,.26667],107:[0,.69444,0,0,.48889],108:[0,.69444,0,0,.23889],109:[0,.44444,0,0,.79445],110:[0,.44444,0,0,.51667],111:[0,.44444,0,0,.5],112:[.19444,.44444,0,0,.51667],113:[.19444,.44444,0,0,.51667],114:[0,.44444,.01389,0,.34167],115:[0,.44444,0,0,.38333],116:[0,.57143,0,0,.36111],117:[0,.44444,0,0,.51667],118:[0,.44444,.01389,0,.46111],119:[0,.44444,.01389,0,.68334],120:[0,.44444,0,0,.46111],121:[.19444,.44444,.01389,0,.46111],122:[0,.44444,0,0,.43472],126:[.35,.32659,0,0,.5],160:[0,0,0,0,.25],168:[0,.67937,0,0,.5],176:[0,.69444,0,0,.66667],184:[.17014,0,0,0,.44445],305:[0,.44444,0,0,.23889],567:[.19444,.44444,0,0,.26667],710:[0,.69444,0,0,.5],711:[0,.63194,0,0,.5],713:[0,.60889,0,0,.5],714:[0,.69444,0,0,.5],715:[0,.69444,0,0,.5],728:[0,.69444,0,0,.5],729:[0,.67937,0,0,.27778],730:[0,.69444,0,0,.66667],732:[0,.67659,0,0,.5],733:[0,.69444,0,0,.5],915:[0,.69444,0,0,.54167],916:[0,.69444,0,0,.83334],920:[0,.69444,0,0,.77778],923:[0,.69444,0,0,.61111],926:[0,.69444,0,0,.66667],928:[0,.69444,0,0,.70834],931:[0,.69444,0,0,.72222],933:[0,.69444,0,0,.77778],934:[0,.69444,0,0,.72222],936:[0,.69444,0,0,.77778],937:[0,.69444,0,0,.72222],8211:[0,.44444,.02778,0,.5],8212:[0,.44444,.02778,0,1],8216:[0,.69444,0,0,.27778],8217:[0,.69444,0,0,.27778],8220:[0,.69444,0,0,.5],8221:[0,.69444,0,0,.5]},"Script-Regular":{32:[0,0,0,0,.25],65:[0,.7,.22925,0,.80253],66:[0,.7,.04087,0,.90757],67:[0,.7,.1689,0,.66619],68:[0,.7,.09371,0,.77443],69:[0,.7,.18583,0,.56162],70:[0,.7,.13634,0,.89544],71:[0,.7,.17322,0,.60961],72:[0,.7,.29694,0,.96919],73:[0,.7,.19189,0,.80907],74:[.27778,.7,.19189,0,1.05159],75:[0,.7,.31259,0,.91364],76:[0,.7,.19189,0,.87373],77:[0,.7,.15981,0,1.08031],78:[0,.7,.3525,0,.9015],79:[0,.7,.08078,0,.73787],80:[0,.7,.08078,0,1.01262],81:[0,.7,.03305,0,.88282],82:[0,.7,.06259,0,.85],83:[0,.7,.19189,0,.86767],84:[0,.7,.29087,0,.74697],85:[0,.7,.25815,0,.79996],86:[0,.7,.27523,0,.62204],87:[0,.7,.27523,0,.80532],88:[0,.7,.26006,0,.94445],89:[0,.7,.2939,0,.70961],90:[0,.7,.24037,0,.8212],160:[0,0,0,0,.25]},"Size1-Regular":{32:[0,0,0,0,.25],40:[.35001,.85,0,0,.45834],41:[.35001,.85,0,0,.45834],47:[.35001,.85,0,0,.57778],91:[.35001,.85,0,0,.41667],92:[.35001,.85,0,0,.57778],93:[.35001,.85,0,0,.41667],123:[.35001,.85,0,0,.58334],125:[.35001,.85,0,0,.58334],160:[0,0,0,0,.25],710:[0,.72222,0,0,.55556],732:[0,.72222,0,0,.55556],770:[0,.72222,0,0,.55556],771:[0,.72222,0,0,.55556],8214:[-99e-5,.601,0,0,.77778],8593:[1e-5,.6,0,0,.66667],8595:[1e-5,.6,0,0,.66667],8657:[1e-5,.6,0,0,.77778],8659:[1e-5,.6,0,0,.77778],8719:[.25001,.75,0,0,.94445],8720:[.25001,.75,0,0,.94445],8721:[.25001,.75,0,0,1.05556],8730:[.35001,.85,0,0,1],8739:[-.00599,.606,0,0,.33333],8741:[-.00599,.606,0,0,.55556],8747:[.30612,.805,.19445,0,.47222],8748:[.306,.805,.19445,0,.47222],8749:[.306,.805,.19445,0,.47222],8750:[.30612,.805,.19445,0,.47222],8896:[.25001,.75,0,0,.83334],8897:[.25001,.75,0,0,.83334],8898:[.25001,.75,0,0,.83334],8899:[.25001,.75,0,0,.83334],8968:[.35001,.85,0,0,.47222],8969:[.35001,.85,0,0,.47222],8970:[.35001,.85,0,0,.47222],8971:[.35001,.85,0,0,.47222],9168:[-99e-5,.601,0,0,.66667],10216:[.35001,.85,0,0,.47222],10217:[.35001,.85,0,0,.47222],10752:[.25001,.75,0,0,1.11111],10753:[.25001,.75,0,0,1.11111],10754:[.25001,.75,0,0,1.11111],10756:[.25001,.75,0,0,.83334],10758:[.25001,.75,0,0,.83334]},"Size2-Regular":{32:[0,0,0,0,.25],40:[.65002,1.15,0,0,.59722],41:[.65002,1.15,0,0,.59722],47:[.65002,1.15,0,0,.81111],91:[.65002,1.15,0,0,.47222],92:[.65002,1.15,0,0,.81111],93:[.65002,1.15,0,0,.47222],123:[.65002,1.15,0,0,.66667],125:[.65002,1.15,0,0,.66667],160:[0,0,0,0,.25],710:[0,.75,0,0,1],732:[0,.75,0,0,1],770:[0,.75,0,0,1],771:[0,.75,0,0,1],8719:[.55001,1.05,0,0,1.27778],8720:[.55001,1.05,0,0,1.27778],8721:[.55001,1.05,0,0,1.44445],8730:[.65002,1.15,0,0,1],8747:[.86225,1.36,.44445,0,.55556],8748:[.862,1.36,.44445,0,.55556],8749:[.862,1.36,.44445,0,.55556],8750:[.86225,1.36,.44445,0,.55556],8896:[.55001,1.05,0,0,1.11111],8897:[.55001,1.05,0,0,1.11111],8898:[.55001,1.05,0,0,1.11111],8899:[.55001,1.05,0,0,1.11111],8968:[.65002,1.15,0,0,.52778],8969:[.65002,1.15,0,0,.52778],8970:[.65002,1.15,0,0,.52778],8971:[.65002,1.15,0,0,.52778],10216:[.65002,1.15,0,0,.61111],10217:[.65002,1.15,0,0,.61111],10752:[.55001,1.05,0,0,1.51112],10753:[.55001,1.05,0,0,1.51112],10754:[.55001,1.05,0,0,1.51112],10756:[.55001,1.05,0,0,1.11111],10758:[.55001,1.05,0,0,1.11111]},"Size3-Regular":{32:[0,0,0,0,.25],40:[.95003,1.45,0,0,.73611],41:[.95003,1.45,0,0,.73611],47:[.95003,1.45,0,0,1.04445],91:[.95003,1.45,0,0,.52778],92:[.95003,1.45,0,0,1.04445],93:[.95003,1.45,0,0,.52778],123:[.95003,1.45,0,0,.75],125:[.95003,1.45,0,0,.75],160:[0,0,0,0,.25],710:[0,.75,0,0,1.44445],732:[0,.75,0,0,1.44445],770:[0,.75,0,0,1.44445],771:[0,.75,0,0,1.44445],8730:[.95003,1.45,0,0,1],8968:[.95003,1.45,0,0,.58334],8969:[.95003,1.45,0,0,.58334],8970:[.95003,1.45,0,0,.58334],8971:[.95003,1.45,0,0,.58334],10216:[.95003,1.45,0,0,.75],10217:[.95003,1.45,0,0,.75]},"Size4-Regular":{32:[0,0,0,0,.25],40:[1.25003,1.75,0,0,.79167],41:[1.25003,1.75,0,0,.79167],47:[1.25003,1.75,0,0,1.27778],91:[1.25003,1.75,0,0,.58334],92:[1.25003,1.75,0,0,1.27778],93:[1.25003,1.75,0,0,.58334],123:[1.25003,1.75,0,0,.80556],125:[1.25003,1.75,0,0,.80556],160:[0,0,0,0,.25],710:[0,.825,0,0,1.8889],732:[0,.825,0,0,1.8889],770:[0,.825,0,0,1.8889],771:[0,.825,0,0,1.8889],8730:[1.25003,1.75,0,0,1],8968:[1.25003,1.75,0,0,.63889],8969:[1.25003,1.75,0,0,.63889],8970:[1.25003,1.75,0,0,.63889],8971:[1.25003,1.75,0,0,.63889],9115:[.64502,1.155,0,0,.875],9116:[1e-5,.6,0,0,.875],9117:[.64502,1.155,0,0,.875],9118:[.64502,1.155,0,0,.875],9119:[1e-5,.6,0,0,.875],9120:[.64502,1.155,0,0,.875],9121:[.64502,1.155,0,0,.66667],9122:[-99e-5,.601,0,0,.66667],9123:[.64502,1.155,0,0,.66667],9124:[.64502,1.155,0,0,.66667],9125:[-99e-5,.601,0,0,.66667],9126:[.64502,1.155,0,0,.66667],9127:[1e-5,.9,0,0,.88889],9128:[.65002,1.15,0,0,.88889],9129:[.90001,0,0,0,.88889],9130:[0,.3,0,0,.88889],9131:[1e-5,.9,0,0,.88889],9132:[.65002,1.15,0,0,.88889],9133:[.90001,0,0,0,.88889],9143:[.88502,.915,0,0,1.05556],10216:[1.25003,1.75,0,0,.80556],10217:[1.25003,1.75,0,0,.80556],57344:[-.00499,.605,0,0,1.05556],57345:[-.00499,.605,0,0,1.05556],57680:[0,.12,0,0,.45],57681:[0,.12,0,0,.45],57682:[0,.12,0,0,.45],57683:[0,.12,0,0,.45]},"Typewriter-Regular":{32:[0,0,0,0,.525],33:[0,.61111,0,0,.525],34:[0,.61111,0,0,.525],35:[0,.61111,0,0,.525],36:[.08333,.69444,0,0,.525],37:[.08333,.69444,0,0,.525],38:[0,.61111,0,0,.525],39:[0,.61111,0,0,.525],40:[.08333,.69444,0,0,.525],41:[.08333,.69444,0,0,.525],42:[0,.52083,0,0,.525],43:[-.08056,.53055,0,0,.525],44:[.13889,.125,0,0,.525],45:[-.08056,.53055,0,0,.525],46:[0,.125,0,0,.525],47:[.08333,.69444,0,0,.525],48:[0,.61111,0,0,.525],49:[0,.61111,0,0,.525],50:[0,.61111,0,0,.525],51:[0,.61111,0,0,.525],52:[0,.61111,0,0,.525],53:[0,.61111,0,0,.525],54:[0,.61111,0,0,.525],55:[0,.61111,0,0,.525],56:[0,.61111,0,0,.525],57:[0,.61111,0,0,.525],58:[0,.43056,0,0,.525],59:[.13889,.43056,0,0,.525],60:[-.05556,.55556,0,0,.525],61:[-.19549,.41562,0,0,.525],62:[-.05556,.55556,0,0,.525],63:[0,.61111,0,0,.525],64:[0,.61111,0,0,.525],65:[0,.61111,0,0,.525],66:[0,.61111,0,0,.525],67:[0,.61111,0,0,.525],68:[0,.61111,0,0,.525],69:[0,.61111,0,0,.525],70:[0,.61111,0,0,.525],71:[0,.61111,0,0,.525],72:[0,.61111,0,0,.525],73:[0,.61111,0,0,.525],74:[0,.61111,0,0,.525],75:[0,.61111,0,0,.525],76:[0,.61111,0,0,.525],77:[0,.61111,0,0,.525],78:[0,.61111,0,0,.525],79:[0,.61111,0,0,.525],80:[0,.61111,0,0,.525],81:[.13889,.61111,0,0,.525],82:[0,.61111,0,0,.525],83:[0,.61111,0,0,.525],84:[0,.61111,0,0,.525],85:[0,.61111,0,0,.525],86:[0,.61111,0,0,.525],87:[0,.61111,0,0,.525],88:[0,.61111,0,0,.525],89:[0,.61111,0,0,.525],90:[0,.61111,0,0,.525],91:[.08333,.69444,0,0,.525],92:[.08333,.69444,0,0,.525],93:[.08333,.69444,0,0,.525],94:[0,.61111,0,0,.525],95:[.09514,0,0,0,.525],96:[0,.61111,0,0,.525],97:[0,.43056,0,0,.525],98:[0,.61111,0,0,.525],99:[0,.43056,0,0,.525],100:[0,.61111,0,0,.525],101:[0,.43056,0,0,.525],102:[0,.61111,0,0,.525],103:[.22222,.43056,0,0,.525],104:[0,.61111,0,0,.525],105:[0,.61111,0,0,.525],106:[.22222,.61111,0,0,.525],107:[0,.61111,0,0,.525],108:[0,.61111,0,0,.525],109:[0,.43056,0,0,.525],110:[0,.43056,0,0,.525],111:[0,.43056,0,0,.525],112:[.22222,.43056,0,0,.525],113:[.22222,.43056,0,0,.525],114:[0,.43056,0,0,.525],115:[0,.43056,0,0,.525],116:[0,.55358,0,0,.525],117:[0,.43056,0,0,.525],118:[0,.43056,0,0,.525],119:[0,.43056,0,0,.525],120:[0,.43056,0,0,.525],121:[.22222,.43056,0,0,.525],122:[0,.43056,0,0,.525],123:[.08333,.69444,0,0,.525],124:[.08333,.69444,0,0,.525],125:[.08333,.69444,0,0,.525],126:[0,.61111,0,0,.525],127:[0,.61111,0,0,.525],160:[0,0,0,0,.525],176:[0,.61111,0,0,.525],184:[.19445,0,0,0,.525],305:[0,.43056,0,0,.525],567:[.22222,.43056,0,0,.525],711:[0,.56597,0,0,.525],713:[0,.56555,0,0,.525],714:[0,.61111,0,0,.525],715:[0,.61111,0,0,.525],728:[0,.61111,0,0,.525],730:[0,.61111,0,0,.525],770:[0,.61111,0,0,.525],771:[0,.61111,0,0,.525],776:[0,.61111,0,0,.525],915:[0,.61111,0,0,.525],916:[0,.61111,0,0,.525],920:[0,.61111,0,0,.525],923:[0,.61111,0,0,.525],926:[0,.61111,0,0,.525],928:[0,.61111,0,0,.525],931:[0,.61111,0,0,.525],933:[0,.61111,0,0,.525],934:[0,.61111,0,0,.525],936:[0,.61111,0,0,.525],937:[0,.61111,0,0,.525],8216:[0,.61111,0,0,.525],8217:[0,.61111,0,0,.525],8242:[0,.61111,0,0,.525],9251:[.11111,.21944,0,0,.525]}},fe={slant:[.25,.25,.25],space:[0,0,0],stretch:[0,0,0],shrink:[0,0,0],xHeight:[.431,.431,.431],quad:[1,1.171,1.472],extraSpace:[0,0,0],num1:[.677,.732,.925],num2:[.394,.384,.387],num3:[.444,.471,.504],denom1:[.686,.752,1.025],denom2:[.345,.344,.532],sup1:[.413,.503,.504],sup2:[.363,.431,.404],sup3:[.289,.286,.294],sub1:[.15,.143,.2],sub2:[.247,.286,.4],supDrop:[.386,.353,.494],subDrop:[.05,.071,.1],delim1:[2.39,1.7,1.98],delim2:[1.01,1.157,1.42],axisHeight:[.25,.25,.25],defaultRuleThickness:[.04,.049,.049],bigOpSpacing1:[.111,.111,.111],bigOpSpacing2:[.166,.166,.166],bigOpSpacing3:[.2,.2,.2],bigOpSpacing4:[.6,.611,.611],bigOpSpacing5:[.1,.143,.143],sqrtRuleThickness:[.04,.04,.04],ptPerEm:[10,10,10],doubleRuleSep:[.2,.2,.2],arrayRuleWidth:[.04,.04,.04],fboxsep:[.3,.3,.3],fboxrule:[.04,.04,.04]},ve={'\xc5':'A','\xd0':'D','\xde':'o','\xe5':'a','\xf0':'d','\xfe':'o','\u0410':'A','\u0411':'B','\u0412':'B','\u0413':'F','\u0414':'A','\u0415':'E','\u0416':'K','\u0417':'3','\u0418':'N','\u0419':'N','\u041a':'K','\u041b':'N','\u041c':'M','\u041d':'H','\u041e':'O','\u041f':'N','\u0420':'P','\u0421':'C','\u0422':'T','\u0423':'y','\u0424':'O','\u0425':'X','\u0426':'U','\u0427':'h','\u0428':'W','\u0429':'W','\u042a':'B','\u042b':'X','\u042c':'B','\u042d':'3','\u042e':'X','\u042f':'R','\u0430':'a','\u0431':'b','\u0432':'a','\u0433':'r','\u0434':'y','\u0435':'e','\u0436':'m','\u0437':'e','\u0438':'n','\u0439':'n','\u043a':'n','\u043b':'n','\u043c':'m','\u043d':'n','\u043e':'o','\u043f':'n','\u0440':'p','\u0441':'c','\u0442':'o','\u0443':'y','\u0444':'b','\u0445':'x','\u0446':'n','\u0447':'n','\u0448':'w','\u0449':'w','\u044a':'a','\u044b':'m','\u044c':'a','\u044d':'e','\u044e':'m','\u044f':'r'};function be(e,t){ge[e]=t}function ye(e,t,r){if(!ge[t])throw new Error("Font metrics not found for font: "+t+".");var a=e.charCodeAt(0),n=ge[t][a];if(!n&&e[0]in ve&&(a=ve[e[0]].charCodeAt(0),n=ge[t][a]),n||'text'!==r||E(a)&&(n=ge[t][77]),n)return{depth:n[0],height:n[1],italic:n[2],skew:n[3],width:n[4]}}var xe={};function we(e){var t;if(!xe[t=e>=5?0:e>=3?1:2]){var r=xe[t]={cssEmPerMu:fe.quad[t]/18};for(var a of Object.keys(fe))r[a]=fe[a][t]}return xe[t]}var ke={math:{},text:{}};function Se(e,t,r,a,n,i){ke[e][n]={font:t,group:r,replace:a},i&&a&&(ke[e][a]=ke[e][n])}var ze="math",Me="text",Ae="main",Te="ams",Ce="accent-token",Be="bin",qe="close",Ie="inner",Oe="mathord",Re="op-token",Ee="open",He="punct",Ne="rel",De="spacing",Le="textord";Se(ze,Ae,Ne,"\u2261","\\equiv",!0),Se(ze,Ae,Ne,"\u227a","\\prec",!0),Se(ze,Ae,Ne,"\u227b","\\succ",!0),Se(ze,Ae,Ne,"\u223c","\\sim",!0),Se(ze,Ae,Ne,"\u22a5","\\perp"),Se(ze,Ae,Ne,"\u2aaf","\\preceq",!0),Se(ze,Ae,Ne,"\u2ab0","\\succeq",!0),Se(ze,Ae,Ne,"\u2243","\\simeq",!0),Se(ze,Ae,Ne,"\u2223","\\mid",!0),Se(ze,Ae,Ne,"\u226a","\\ll",!0),Se(ze,Ae,Ne,"\u226b","\\gg",!0),Se(ze,Ae,Ne,"\u224d","\\asymp",!0),Se(ze,Ae,Ne,"\u2225","\\parallel"),Se(ze,Ae,Ne,"\u22c8","\\bowtie",!0),Se(ze,Ae,Ne,"\u2323","\\smile",!0),Se(ze,Ae,Ne,"\u2291","\\sqsubseteq",!0),Se(ze,Ae,Ne,"\u2292","\\sqsupseteq",!0),Se(ze,Ae,Ne,"\u2250","\\doteq",!0),Se(ze,Ae,Ne,"\u2322","\\frown",!0),Se(ze,Ae,Ne,"\u220b","\\ni",!0),Se(ze,Ae,Ne,"\u221d","\\propto",!0),Se(ze,Ae,Ne,"\u22a2","\\vdash",!0),Se(ze,Ae,Ne,"\u22a3","\\dashv",!0),Se(ze,Ae,Ne,"\u220b","\\owns"),Se(ze,Ae,He,".","\\ldotp"),Se(ze,Ae,He,"\u22c5","\\cdotp"),Se(ze,Ae,He,"\u22c5","\xb7"),Se(Me,Ae,Le,"\u22c5","\xb7"),Se(ze,Ae,Le,"#","\\#"),Se(Me,Ae,Le,"#","\\#"),Se(ze,Ae,Le,"&","\\&"),Se(Me,Ae,Le,"&","\\&"),Se(ze,Ae,Le,"\u2135","\\aleph",!0),Se(ze,Ae,Le,"\u2200","\\forall",!0),Se(ze,Ae,Le,"\u210f","\\hbar",!0),Se(ze,Ae,Le,"\u2203","\\exists",!0),Se(ze,Ae,Le,"\u2207","\\nabla",!0),Se(ze,Ae,Le,"\u266d","\\flat",!0),Se(ze,Ae,Le,"\u2113","\\ell",!0),Se(ze,Ae,Le,"\u266e","\\natural",!0),Se(ze,Ae,Le,"\u2663","\\clubsuit",!0),Se(ze,Ae,Le,"\u2118","\\wp",!0),Se(ze,Ae,Le,"\u266f","\\sharp",!0),Se(ze,Ae,Le,"\u2662","\\diamondsuit",!0),Se(ze,Ae,Le,"\u211c","\\Re",!0),Se(ze,Ae,Le,"\u2661","\\heartsuit",!0),Se(ze,Ae,Le,"\u2111","\\Im",!0),Se(ze,Ae,Le,"\u2660","\\spadesuit",!0),Se(ze,Ae,Le,"\xa7","\\S",!0),Se(Me,Ae,Le,"\xa7","\\S"),Se(ze,Ae,Le,"\xb6","\\P",!0),Se(Me,Ae,Le,"\xb6","\\P"),Se(ze,Ae,Le,"\u2020","\\dag"),Se(Me,Ae,Le,"\u2020","\\dag"),Se(Me,Ae,Le,"\u2020","\\textdagger"),Se(ze,Ae,Le,"\u2021","\\ddag"),Se(Me,Ae,Le,"\u2021","\\ddag"),Se(Me,Ae,Le,"\u2021","\\textdaggerdbl"),Se(ze,Ae,qe,"\u23b1","\\rmoustache",!0),Se(ze,Ae,Ee,"\u23b0","\\lmoustache",!0),Se(ze,Ae,qe,"\u27ef","\\rgroup",!0),Se(ze,Ae,Ee,"\u27ee","\\lgroup",!0),Se(ze,Ae,Be,"\u2213","\\mp",!0),Se(ze,Ae,Be,"\u2296","\\ominus",!0),Se(ze,Ae,Be,"\u228e","\\uplus",!0),Se(ze,Ae,Be,"\u2293","\\sqcap",!0),Se(ze,Ae,Be,"\u2217","\\ast"),Se(ze,Ae,Be,"\u2294","\\sqcup",!0),Se(ze,Ae,Be,"\u25ef","\\bigcirc",!0),Se(ze,Ae,Be,"\u2219","\\bullet",!0),Se(ze,Ae,Be,"\u2021","\\ddagger"),Se(ze,Ae,Be,"\u2240","\\wr",!0),Se(ze,Ae,Be,"\u2a3f","\\amalg"),Se(ze,Ae,Be,"&","\\And"),Se(ze,Ae,Ne,"\u27f5","\\longleftarrow",!0),Se(ze,Ae,Ne,"\u21d0","\\Leftarrow",!0),Se(ze,Ae,Ne,"\u27f8","\\Longleftarrow",!0),Se(ze,Ae,Ne,"\u27f6","\\longrightarrow",!0),Se(ze,Ae,Ne,"\u21d2","\\Rightarrow",!0),Se(ze,Ae,Ne,"\u27f9","\\Longrightarrow",!0),Se(ze,Ae,Ne,"\u2194","\\leftrightarrow",!0),Se(ze,Ae,Ne,"\u27f7","\\longleftrightarrow",!0),Se(ze,Ae,Ne,"\u21d4","\\Leftrightarrow",!0),Se(ze,Ae,Ne,"\u27fa","\\Longleftrightarrow",!0),Se(ze,Ae,Ne,"\u21a6","\\mapsto",!0),Se(ze,Ae,Ne,"\u27fc","\\longmapsto",!0),Se(ze,Ae,Ne,"\u2197","\\nearrow",!0),Se(ze,Ae,Ne,"\u21a9","\\hookleftarrow",!0),Se(ze,Ae,Ne,"\u21aa","\\hookrightarrow",!0),Se(ze,Ae,Ne,"\u2198","\\searrow",!0),Se(ze,Ae,Ne,"\u21bc","\\leftharpoonup",!0),Se(ze,Ae,Ne,"\u21c0","\\rightharpoonup",!0),Se(ze,Ae,Ne,"\u2199","\\swarrow",!0),Se(ze,Ae,Ne,"\u21bd","\\leftharpoondown",!0),Se(ze,Ae,Ne,"\u21c1","\\rightharpoondown",!0),Se(ze,Ae,Ne,"\u2196","\\nwarrow",!0),Se(ze,Ae,Ne,"\u21cc","\\rightleftharpoons",!0),Se(ze,Te,Ne,"\u226e","\\nless",!0),Se(ze,Te,Ne,"\ue010","\\@nleqslant"),Se(ze,Te,Ne,"\ue011","\\@nleqq"),Se(ze,Te,Ne,"\u2a87","\\lneq",!0),Se(ze,Te,Ne,"\u2268","\\lneqq",!0),Se(ze,Te,Ne,"\ue00c","\\@lvertneqq"),Se(ze,Te,Ne,"\u22e6","\\lnsim",!0),Se(ze,Te,Ne,"\u2a89","\\lnapprox",!0),Se(ze,Te,Ne,"\u2280","\\nprec",!0),Se(ze,Te,Ne,"\u22e0","\\npreceq",!0),Se(ze,Te,Ne,"\u22e8","\\precnsim",!0),Se(ze,Te,Ne,"\u2ab9","\\precnapprox",!0),Se(ze,Te,Ne,"\u2241","\\nsim",!0),Se(ze,Te,Ne,"\ue006","\\@nshortmid"),Se(ze,Te,Ne,"\u2224","\\nmid",!0),Se(ze,Te,Ne,"\u22ac","\\nvdash",!0),Se(ze,Te,Ne,"\u22ad","\\nvDash",!0),Se(ze,Te,Ne,"\u22ea","\\ntriangleleft"),Se(ze,Te,Ne,"\u22ec","\\ntrianglelefteq",!0),Se(ze,Te,Ne,"\u228a","\\subsetneq",!0),Se(ze,Te,Ne,"\ue01a","\\@varsubsetneq"),Se(ze,Te,Ne,"\u2acb","\\subsetneqq",!0),Se(ze,Te,Ne,"\ue017","\\@varsubsetneqq"),Se(ze,Te,Ne,"\u226f","\\ngtr",!0),Se(ze,Te,Ne,"\ue00f","\\@ngeqslant"),Se(ze,Te,Ne,"\ue00e","\\@ngeqq"),Se(ze,Te,Ne,"\u2a88","\\gneq",!0),Se(ze,Te,Ne,"\u2269","\\gneqq",!0),Se(ze,Te,Ne,"\ue00d","\\@gvertneqq"),Se(ze,Te,Ne,"\u22e7","\\gnsim",!0),Se(ze,Te,Ne,"\u2a8a","\\gnapprox",!0),Se(ze,Te,Ne,"\u2281","\\nsucc",!0),Se(ze,Te,Ne,"\u22e1","\\nsucceq",!0),Se(ze,Te,Ne,"\u22e9","\\succnsim",!0),Se(ze,Te,Ne,"\u2aba","\\succnapprox",!0),Se(ze,Te,Ne,"\u2246","\\ncong",!0),Se(ze,Te,Ne,"\ue007","\\@nshortparallel"),Se(ze,Te,Ne,"\u2226","\\nparallel",!0),Se(ze,Te,Ne,"\u22af","\\nVDash",!0),Se(ze,Te,Ne,"\u22eb","\\ntriangleright"),Se(ze,Te,Ne,"\u22ed","\\ntrianglerighteq",!0),Se(ze,Te,Ne,"\ue018","\\@nsupseteqq"),Se(ze,Te,Ne,"\u228b","\\supsetneq",!0),Se(ze,Te,Ne,"\ue01b","\\@varsupsetneq"),Se(ze,Te,Ne,"\u2acc","\\supsetneqq",!0),Se(ze,Te,Ne,"\ue019","\\@varsupsetneqq"),Se(ze,Te,Ne,"\u22ae","\\nVdash",!0),Se(ze,Te,Ne,"\u2ab5","\\precneqq",!0),Se(ze,Te,Ne,"\u2ab6","\\succneqq",!0),Se(ze,Te,Ne,"\ue016","\\@nsubseteqq"),Se(ze,Te,Be,"\u22b4","\\unlhd"),Se(ze,Te,Be,"\u22b5","\\unrhd"),Se(ze,Te,Ne,"\u219a","\\nleftarrow",!0),Se(ze,Te,Ne,"\u219b","\\nrightarrow",!0),Se(ze,Te,Ne,"\u21cd","\\nLeftarrow",!0),Se(ze,Te,Ne,"\u21cf","\\nRightarrow",!0),Se(ze,Te,Ne,"\u21ae","\\nleftrightarrow",!0),Se(ze,Te,Ne,"\u21ce","\\nLeftrightarrow",!0),Se(ze,Te,Ne,"\u25b3","\\vartriangle"),Se(ze,Te,Le,"\u210f","\\hslash"),Se(ze,Te,Le,"\u25bd","\\triangledown"),Se(ze,Te,Le,"\u25ca","\\lozenge"),Se(ze,Te,Le,"\u24c8","\\circledS"),Se(ze,Te,Le,"\xae","\\circledR"),Se(Me,Te,Le,"\xae","\\circledR"),Se(ze,Te,Le,"\u2221","\\measuredangle",!0),Se(ze,Te,Le,"\u2204","\\nexists"),Se(ze,Te,Le,"\u2127","\\mho"),Se(ze,Te,Le,"\u2132","\\Finv",!0),Se(ze,Te,Le,"\u2141","\\Game",!0),Se(ze,Te,Le,"\u2035","\\backprime"),Se(ze,Te,Le,"\u25b2","\\blacktriangle"),Se(ze,Te,Le,"\u25bc","\\blacktriangledown"),Se(ze,Te,Le,"\u25a0","\\blacksquare"),Se(ze,Te,Le,"\u29eb","\\blacklozenge"),Se(ze,Te,Le,"\u2605","\\bigstar"),Se(ze,Te,Le,"\u2222","\\sphericalangle",!0),Se(ze,Te,Le,"\u2201","\\complement",!0),Se(ze,Te,Le,"\xf0","\\eth",!0),Se(Me,Ae,Le,"\xf0","\xf0"),Se(ze,Te,Le,"\u2571","\\diagup"),Se(ze,Te,Le,"\u2572","\\diagdown"),Se(ze,Te,Le,"\u25a1","\\square"),Se(ze,Te,Le,"\u25a1","\\Box"),Se(ze,Te,Le,"\u25ca","\\Diamond"),Se(ze,Te,Le,"\xa5","\\yen",!0),Se(Me,Te,Le,"\xa5","\\yen",!0),Se(ze,Te,Le,"\u2713","\\checkmark",!0),Se(Me,Te,Le,"\u2713","\\checkmark"),Se(ze,Te,Le,"\u2136","\\beth",!0),Se(ze,Te,Le,"\u2138","\\daleth",!0),Se(ze,Te,Le,"\u2137","\\gimel",!0),Se(ze,Te,Le,"\u03dd","\\digamma",!0),Se(ze,Te,Le,"\u03f0","\\varkappa"),Se(ze,Te,Ee,"\u250c","\\@ulcorner",!0),Se(ze,Te,qe,"\u2510","\\@urcorner",!0),Se(ze,Te,Ee,"\u2514","\\@llcorner",!0),Se(ze,Te,qe,"\u2518","\\@lrcorner",!0),Se(ze,Te,Ne,"\u2266","\\leqq",!0),Se(ze,Te,Ne,"\u2a7d","\\leqslant",!0),Se(ze,Te,Ne,"\u2a95","\\eqslantless",!0),Se(ze,Te,Ne,"\u2272","\\lesssim",!0),Se(ze,Te,Ne,"\u2a85","\\lessapprox",!0),Se(ze,Te,Ne,"\u224a","\\approxeq",!0),Se(ze,Te,Be,"\u22d6","\\lessdot"),Se(ze,Te,Ne,"\u22d8","\\lll",!0),Se(ze,Te,Ne,"\u2276","\\lessgtr",!0),Se(ze,Te,Ne,"\u22da","\\lesseqgtr",!0),Se(ze,Te,Ne,"\u2a8b","\\lesseqqgtr",!0),Se(ze,Te,Ne,"\u2251","\\doteqdot"),Se(ze,Te,Ne,"\u2253","\\risingdotseq",!0),Se(ze,Te,Ne,"\u2252","\\fallingdotseq",!0),Se(ze,Te,Ne,"\u223d","\\backsim",!0),Se(ze,Te,Ne,"\u22cd","\\backsimeq",!0),Se(ze,Te,Ne,"\u2ac5","\\subseteqq",!0),Se(ze,Te,Ne,"\u22d0","\\Subset",!0),Se(ze,Te,Ne,"\u228f","\\sqsubset",!0),Se(ze,Te,Ne,"\u227c","\\preccurlyeq",!0),Se(ze,Te,Ne,"\u22de","\\curlyeqprec",!0),Se(ze,Te,Ne,"\u227e","\\precsim",!0),Se(ze,Te,Ne,"\u2ab7","\\precapprox",!0),Se(ze,Te,Ne,"\u22b2","\\vartriangleleft"),Se(ze,Te,Ne,"\u22b4","\\trianglelefteq"),Se(ze,Te,Ne,"\u22a8","\\vDash",!0),Se(ze,Te,Ne,"\u22aa","\\Vvdash",!0),Se(ze,Te,Ne,"\u2323","\\smallsmile"),Se(ze,Te,Ne,"\u2322","\\smallfrown"),Se(ze,Te,Ne,"\u224f","\\bumpeq",!0),Se(ze,Te,Ne,"\u224e","\\Bumpeq",!0),Se(ze,Te,Ne,"\u2267","\\geqq",!0),Se(ze,Te,Ne,"\u2a7e","\\geqslant",!0),Se(ze,Te,Ne,"\u2a96","\\eqslantgtr",!0),Se(ze,Te,Ne,"\u2273","\\gtrsim",!0),Se(ze,Te,Ne,"\u2a86","\\gtrapprox",!0),Se(ze,Te,Be,"\u22d7","\\gtrdot"),Se(ze,Te,Ne,"\u22d9","\\ggg",!0),Se(ze,Te,Ne,"\u2277","\\gtrless",!0),Se(ze,Te,Ne,"\u22db","\\gtreqless",!0),Se(ze,Te,Ne,"\u2a8c","\\gtreqqless",!0),Se(ze,Te,Ne,"\u2256","\\eqcirc",!0),Se(ze,Te,Ne,"\u2257","\\circeq",!0),Se(ze,Te,Ne,"\u225c","\\triangleq",!0),Se(ze,Te,Ne,"\u223c","\\thicksim"),Se(ze,Te,Ne,"\u2248","\\thickapprox"),Se(ze,Te,Ne,"\u2ac6","\\supseteqq",!0),Se(ze,Te,Ne,"\u22d1","\\Supset",!0),Se(ze,Te,Ne,"\u2290","\\sqsupset",!0),Se(ze,Te,Ne,"\u227d","\\succcurlyeq",!0),Se(ze,Te,Ne,"\u22df","\\curlyeqsucc",!0),Se(ze,Te,Ne,"\u227f","\\succsim",!0),Se(ze,Te,Ne,"\u2ab8","\\succapprox",!0),Se(ze,Te,Ne,"\u22b3","\\vartriangleright"),Se(ze,Te,Ne,"\u22b5","\\trianglerighteq"),Se(ze,Te,Ne,"\u22a9","\\Vdash",!0),Se(ze,Te,Ne,"\u2223","\\shortmid"),Se(ze,Te,Ne,"\u2225","\\shortparallel"),Se(ze,Te,Ne,"\u226c","\\between",!0),Se(ze,Te,Ne,"\u22d4","\\pitchfork",!0),Se(ze,Te,Ne,"\u221d","\\varpropto"),Se(ze,Te,Ne,"\u25c0","\\blacktriangleleft"),Se(ze,Te,Ne,"\u2234","\\therefore",!0),Se(ze,Te,Ne,"\u220d","\\backepsilon"),Se(ze,Te,Ne,"\u25b6","\\blacktriangleright"),Se(ze,Te,Ne,"\u2235","\\because",!0),Se(ze,Te,Ne,"\u22d8","\\llless"),Se(ze,Te,Ne,"\u22d9","\\gggtr"),Se(ze,Te,Be,"\u22b2","\\lhd"),Se(ze,Te,Be,"\u22b3","\\rhd"),Se(ze,Te,Ne,"\u2242","\\eqsim",!0),Se(ze,Ae,Ne,"\u22c8","\\Join"),Se(ze,Te,Ne,"\u2251","\\Doteq",!0),Se(ze,Te,Be,"\u2214","\\dotplus",!0),Se(ze,Te,Be,"\u2216","\\smallsetminus"),Se(ze,Te,Be,"\u22d2","\\Cap",!0),Se(ze,Te,Be,"\u22d3","\\Cup",!0),Se(ze,Te,Be,"\u2a5e","\\doublebarwedge",!0),Se(ze,Te,Be,"\u229f","\\boxminus",!0),Se(ze,Te,Be,"\u229e","\\boxplus",!0),Se(ze,Te,Be,"\u22c7","\\divideontimes",!0),Se(ze,Te,Be,"\u22c9","\\ltimes",!0),Se(ze,Te,Be,"\u22ca","\\rtimes",!0),Se(ze,Te,Be,"\u22cb","\\leftthreetimes",!0),Se(ze,Te,Be,"\u22cc","\\rightthreetimes",!0),Se(ze,Te,Be,"\u22cf","\\curlywedge",!0),Se(ze,Te,Be,"\u22ce","\\curlyvee",!0),Se(ze,Te,Be,"\u229d","\\circleddash",!0),Se(ze,Te,Be,"\u229b","\\circledast",!0),Se(ze,Te,Be,"\u22c5","\\centerdot"),Se(ze,Te,Be,"\u22ba","\\intercal",!0),Se(ze,Te,Be,"\u22d2","\\doublecap"),Se(ze,Te,Be,"\u22d3","\\doublecup"),Se(ze,Te,Be,"\u22a0","\\boxtimes",!0),Se(ze,Te,Ne,"\u21e2","\\dashrightarrow",!0),Se(ze,Te,Ne,"\u21e0","\\dashleftarrow",!0),Se(ze,Te,Ne,"\u21c7","\\leftleftarrows",!0),Se(ze,Te,Ne,"\u21c6","\\leftrightarrows",!0),Se(ze,Te,Ne,"\u21da","\\Lleftarrow",!0),Se(ze,Te,Ne,"\u219e","\\twoheadleftarrow",!0),Se(ze,Te,Ne,"\u21a2","\\leftarrowtail",!0),Se(ze,Te,Ne,"\u21ab","\\looparrowleft",!0),Se(ze,Te,Ne,"\u21cb","\\leftrightharpoons",!0),Se(ze,Te,Ne,"\u21b6","\\curvearrowleft",!0),Se(ze,Te,Ne,"\u21ba","\\circlearrowleft",!0),Se(ze,Te,Ne,"\u21b0","\\Lsh",!0),Se(ze,Te,Ne,"\u21c8","\\upuparrows",!0),Se(ze,Te,Ne,"\u21bf","\\upharpoonleft",!0),Se(ze,Te,Ne,"\u21c3","\\downharpoonleft",!0),Se(ze,Ae,Ne,"\u22b6","\\origof",!0),Se(ze,Ae,Ne,"\u22b7","\\imageof",!0),Se(ze,Te,Ne,"\u22b8","\\multimap",!0),Se(ze,Te,Ne,"\u21ad","\\leftrightsquigarrow",!0),Se(ze,Te,Ne,"\u21c9","\\rightrightarrows",!0),Se(ze,Te,Ne,"\u21c4","\\rightleftarrows",!0),Se(ze,Te,Ne,"\u21a0","\\twoheadrightarrow",!0),Se(ze,Te,Ne,"\u21a3","\\rightarrowtail",!0),Se(ze,Te,Ne,"\u21ac","\\looparrowright",!0),Se(ze,Te,Ne,"\u21b7","\\curvearrowright",!0),Se(ze,Te,Ne,"\u21bb","\\circlearrowright",!0),Se(ze,Te,Ne,"\u21b1","\\Rsh",!0),Se(ze,Te,Ne,"\u21ca","\\downdownarrows",!0),Se(ze,Te,Ne,"\u21be","\\upharpoonright",!0),Se(ze,Te,Ne,"\u21c2","\\downharpoonright",!0),Se(ze,Te,Ne,"\u21dd","\\rightsquigarrow",!0),Se(ze,Te,Ne,"\u21dd","\\leadsto"),Se(ze,Te,Ne,"\u21db","\\Rrightarrow",!0),Se(ze,Te,Ne,"\u21be","\\restriction"),Se(ze,Ae,Le,"\u2018","`"),Se(ze,Ae,Le,"$","\\$"),Se(Me,Ae,Le,"$","\\$"),Se(Me,Ae,Le,"$","\\textdollar"),Se(ze,Ae,Le,"%","\\%"),Se(Me,Ae,Le,"%","\\%"),Se(ze,Ae,Le,"_","\\_"),Se(Me,Ae,Le,"_","\\_"),Se(Me,Ae,Le,"_","\\textunderscore"),Se(ze,Ae,Le,"\u2220","\\angle",!0),Se(ze,Ae,Le,"\u221e","\\infty",!0),Se(ze,Ae,Le,"\u2032","\\prime"),Se(ze,Ae,Le,"\u25b3","\\triangle"),Se(ze,Ae,Le,"\u0393","\\Gamma",!0),Se(ze,Ae,Le,"\u0394","\\Delta",!0),Se(ze,Ae,Le,"\u0398","\\Theta",!0),Se(ze,Ae,Le,"\u039b","\\Lambda",!0),Se(ze,Ae,Le,"\u039e","\\Xi",!0),Se(ze,Ae,Le,"\u03a0","\\Pi",!0),Se(ze,Ae,Le,"\u03a3","\\Sigma",!0),Se(ze,Ae,Le,"\u03a5","\\Upsilon",!0),Se(ze,Ae,Le,"\u03a6","\\Phi",!0),Se(ze,Ae,Le,"\u03a8","\\Psi",!0),Se(ze,Ae,Le,"\u03a9","\\Omega",!0),Se(ze,Ae,Le,"A","\u0391"),Se(ze,Ae,Le,"B","\u0392"),Se(ze,Ae,Le,"E","\u0395"),Se(ze,Ae,Le,"Z","\u0396"),Se(ze,Ae,Le,"H","\u0397"),Se(ze,Ae,Le,"I","\u0399"),Se(ze,Ae,Le,"K","\u039a"),Se(ze,Ae,Le,"M","\u039c"),Se(ze,Ae,Le,"N","\u039d"),Se(ze,Ae,Le,"O","\u039f"),Se(ze,Ae,Le,"P","\u03a1"),Se(ze,Ae,Le,"T","\u03a4"),Se(ze,Ae,Le,"X","\u03a7"),Se(ze,Ae,Le,"\xac","\\neg",!0),Se(ze,Ae,Le,"\xac","\\lnot"),Se(ze,Ae,Le,"\u22a4","\\top"),Se(ze,Ae,Le,"\u22a5","\\bot"),Se(ze,Ae,Le,"\u2205","\\emptyset"),Se(ze,Te,Le,"\u2205","\\varnothing"),Se(ze,Ae,Oe,"\u03b1","\\alpha",!0),Se(ze,Ae,Oe,"\u03b2","\\beta",!0),Se(ze,Ae,Oe,"\u03b3","\\gamma",!0),Se(ze,Ae,Oe,"\u03b4","\\delta",!0),Se(ze,Ae,Oe,"\u03f5","\\epsilon",!0),Se(ze,Ae,Oe,"\u03b6","\\zeta",!0),Se(ze,Ae,Oe,"\u03b7","\\eta",!0),Se(ze,Ae,Oe,"\u03b8","\\theta",!0),Se(ze,Ae,Oe,"\u03b9","\\iota",!0),Se(ze,Ae,Oe,"\u03ba","\\kappa",!0),Se(ze,Ae,Oe,"\u03bb","\\lambda",!0),Se(ze,Ae,Oe,"\u03bc","\\mu",!0),Se(ze,Ae,Oe,"\u03bd","\\nu",!0),Se(ze,Ae,Oe,"\u03be","\\xi",!0),Se(ze,Ae,Oe,"\u03bf","\\omicron",!0),Se(ze,Ae,Oe,"\u03c0","\\pi",!0),Se(ze,Ae,Oe,"\u03c1","\\rho",!0),Se(ze,Ae,Oe,"\u03c3","\\sigma",!0),Se(ze,Ae,Oe,"\u03c4","\\tau",!0),Se(ze,Ae,Oe,"\u03c5","\\upsilon",!0),Se(ze,Ae,Oe,"\u03d5","\\phi",!0),Se(ze,Ae,Oe,"\u03c7","\\chi",!0),Se(ze,Ae,Oe,"\u03c8","\\psi",!0),Se(ze,Ae,Oe,"\u03c9","\\omega",!0),Se(ze,Ae,Oe,"\u03b5","\\varepsilon",!0),Se(ze,Ae,Oe,"\u03d1","\\vartheta",!0),Se(ze,Ae,Oe,"\u03d6","\\varpi",!0),Se(ze,Ae,Oe,"\u03f1","\\varrho",!0),Se(ze,Ae,Oe,"\u03c2","\\varsigma",!0),Se(ze,Ae,Oe,"\u03c6","\\varphi",!0),Se(ze,Ae,Be,"\u2217","*",!0),Se(ze,Ae,Be,"+","+"),Se(ze,Ae,Be,"\u2212","-",!0),Se(ze,Ae,Be,"\u22c5","\\cdot",!0),Se(ze,Ae,Be,"\u2218","\\circ",!0),Se(ze,Ae,Be,"\xf7","\\div",!0),Se(ze,Ae,Be,"\xb1","\\pm",!0),Se(ze,Ae,Be,"\xd7","\\times",!0),Se(ze,Ae,Be,"\u2229","\\cap",!0),Se(ze,Ae,Be,"\u222a","\\cup",!0),Se(ze,Ae,Be,"\u2216","\\setminus",!0),Se(ze,Ae,Be,"\u2227","\\land"),Se(ze,Ae,Be,"\u2228","\\lor"),Se(ze,Ae,Be,"\u2227","\\wedge",!0),Se(ze,Ae,Be,"\u2228","\\vee",!0),Se(ze,Ae,Le,"\u221a","\\surd"),Se(ze,Ae,Ee,"\u27e8","\\langle",!0),Se(ze,Ae,Ee,"\u2223","\\lvert"),Se(ze,Ae,Ee,"\u2225","\\lVert"),Se(ze,Ae,qe,"?","?"),Se(ze,Ae,qe,"!","!"),Se(ze,Ae,qe,"\u27e9","\\rangle",!0),Se(ze,Ae,qe,"\u2223","\\rvert"),Se(ze,Ae,qe,"\u2225","\\rVert"),Se(ze,Ae,Ne,"=","="),Se(ze,Ae,Ne,":",":"),Se(ze,Ae,Ne,"\u2248","\\approx",!0),Se(ze,Ae,Ne,"\u2245","\\cong",!0),Se(ze,Ae,Ne,"\u2265","\\ge"),Se(ze,Ae,Ne,"\u2265","\\geq",!0),Se(ze,Ae,Ne,"\u2190","\\gets"),Se(ze,Ae,Ne,">","\\gt",!0),Se(ze,Ae,Ne,"\u2208","\\in",!0),Se(ze,Ae,Ne,"\ue020","\\@not"),Se(ze,Ae,Ne,"\u2282","\\subset",!0),Se(ze,Ae,Ne,"\u2283","\\supset",!0),Se(ze,Ae,Ne,"\u2286","\\subseteq",!0),Se(ze,Ae,Ne,"\u2287","\\supseteq",!0),Se(ze,Te,Ne,"\u2288","\\nsubseteq",!0),Se(ze,Te,Ne,"\u2289","\\nsupseteq",!0),Se(ze,Ae,Ne,"\u22a8","\\models"),Se(ze,Ae,Ne,"\u2190","\\leftarrow",!0),Se(ze,Ae,Ne,"\u2264","\\le"),Se(ze,Ae,Ne,"\u2264","\\leq",!0),Se(ze,Ae,Ne,"<","\\lt",!0),Se(ze,Ae,Ne,"\u2192","\\rightarrow",!0),Se(ze,Ae,Ne,"\u2192","\\to"),Se(ze,Te,Ne,"\u2271","\\ngeq",!0),Se(ze,Te,Ne,"\u2270","\\nleq",!0),Se(ze,Ae,De,"\xa0","\\ "),Se(ze,Ae,De,"\xa0","\\space"),Se(ze,Ae,De,"\xa0","\\nobreakspace"),Se(Me,Ae,De,"\xa0","\\ "),Se(Me,Ae,De,"\xa0"," "),Se(Me,Ae,De,"\xa0","\\space"),Se(Me,Ae,De,"\xa0","\\nobreakspace"),Se(ze,Ae,De,"","\\nobreak"),Se(ze,Ae,De,"","\\allowbreak"),Se(ze,Ae,He,",",","),Se(ze,Ae,He,";",";"),Se(ze,Te,Be,"\u22bc","\\barwedge",!0),Se(ze,Te,Be,"\u22bb","\\veebar",!0),Se(ze,Ae,Be,"\u2299","\\odot",!0),Se(ze,Ae,Be,"\u2295","\\oplus",!0),Se(ze,Ae,Be,"\u2297","\\otimes",!0),Se(ze,Ae,Le,"\u2202","\\partial",!0),Se(ze,Ae,Be,"\u2298","\\oslash",!0),Se(ze,Te,Be,"\u229a","\\circledcirc",!0),Se(ze,Te,Be,"\u22a1","\\boxdot",!0),Se(ze,Ae,Be,"\u25b3","\\bigtriangleup"),Se(ze,Ae,Be,"\u25bd","\\bigtriangledown"),Se(ze,Ae,Be,"\u2020","\\dagger"),Se(ze,Ae,Be,"\u22c4","\\diamond"),Se(ze,Ae,Be,"\u22c6","\\star"),Se(ze,Ae,Be,"\u25c3","\\triangleleft"),Se(ze,Ae,Be,"\u25b9","\\triangleright"),Se(ze,Ae,Ee,"{","\\{"),Se(Me,Ae,Le,"{","\\{"),Se(Me,Ae,Le,"{","\\textbraceleft"),Se(ze,Ae,qe,"}","\\}"),Se(Me,Ae,Le,"}","\\}"),Se(Me,Ae,Le,"}","\\textbraceright"),Se(ze,Ae,Ee,"{","\\lbrace"),Se(ze,Ae,qe,"}","\\rbrace"),Se(ze,Ae,Ee,"[","\\lbrack",!0),Se(Me,Ae,Le,"[","\\lbrack",!0),Se(ze,Ae,qe,"]","\\rbrack",!0),Se(Me,Ae,Le,"]","\\rbrack",!0),Se(ze,Ae,Ee,"(","\\lparen",!0),Se(ze,Ae,qe,")","\\rparen",!0),Se(Me,Ae,Le,"<","\\textless",!0),Se(Me,Ae,Le,">","\\textgreater",!0),Se(ze,Ae,Ee,"\u230a","\\lfloor",!0),Se(ze,Ae,qe,"\u230b","\\rfloor",!0),Se(ze,Ae,Ee,"\u2308","\\lceil",!0),Se(ze,Ae,qe,"\u2309","\\rceil",!0),Se(ze,Ae,Le,"\\","\\backslash"),Se(ze,Ae,Le,"\u2223","|"),Se(ze,Ae,Le,"\u2223","\\vert"),Se(Me,Ae,Le,"|","\\textbar",!0),Se(ze,Ae,Le,"\u2225","\\|"),Se(ze,Ae,Le,"\u2225","\\Vert"),Se(Me,Ae,Le,"\u2225","\\textbardbl"),Se(Me,Ae,Le,"~","\\textasciitilde"),Se(Me,Ae,Le,"\\","\\textbackslash"),Se(Me,Ae,Le,"^","\\textasciicircum"),Se(ze,Ae,Ne,"\u2191","\\uparrow",!0),Se(ze,Ae,Ne,"\u21d1","\\Uparrow",!0),Se(ze,Ae,Ne,"\u2193","\\downarrow",!0),Se(ze,Ae,Ne,"\u21d3","\\Downarrow",!0),Se(ze,Ae,Ne,"\u2195","\\updownarrow",!0),Se(ze,Ae,Ne,"\u21d5","\\Updownarrow",!0),Se(ze,Ae,Re,"\u2210","\\coprod"),Se(ze,Ae,Re,"\u22c1","\\bigvee"),Se(ze,Ae,Re,"\u22c0","\\bigwedge"),Se(ze,Ae,Re,"\u2a04","\\biguplus"),Se(ze,Ae,Re,"\u22c2","\\bigcap"),Se(ze,Ae,Re,"\u22c3","\\bigcup"),Se(ze,Ae,Re,"\u222b","\\int"),Se(ze,Ae,Re,"\u222b","\\intop"),Se(ze,Ae,Re,"\u222c","\\iint"),Se(ze,Ae,Re,"\u222d","\\iiint"),Se(ze,Ae,Re,"\u220f","\\prod"),Se(ze,Ae,Re,"\u2211","\\sum"),Se(ze,Ae,Re,"\u2a02","\\bigotimes"),Se(ze,Ae,Re,"\u2a01","\\bigoplus"),Se(ze,Ae,Re,"\u2a00","\\bigodot"),Se(ze,Ae,Re,"\u222e","\\oint"),Se(ze,Ae,Re,"\u222f","\\oiint"),Se(ze,Ae,Re,"\u2230","\\oiiint"),Se(ze,Ae,Re,"\u2a06","\\bigsqcup"),Se(ze,Ae,Re,"\u222b","\\smallint"),Se(Me,Ae,Ie,"\u2026","\\textellipsis"),Se(ze,Ae,Ie,"\u2026","\\mathellipsis"),Se(Me,Ae,Ie,"\u2026","\\ldots",!0),Se(ze,Ae,Ie,"\u2026","\\ldots",!0),Se(ze,Ae,Ie,"\u22ef","\\@cdots",!0),Se(ze,Ae,Ie,"\u22f1","\\ddots",!0),Se(ze,Ae,Le,"\u22ee","\\varvdots"),Se(Me,Ae,Le,"\u22ee","\\varvdots"),Se(ze,Ae,Ce,"\u02ca","\\acute"),Se(ze,Ae,Ce,"\u02cb","\\grave"),Se(ze,Ae,Ce,"\xa8","\\ddot"),Se(ze,Ae,Ce,"~","\\tilde"),Se(ze,Ae,Ce,"\u02c9","\\bar"),Se(ze,Ae,Ce,"\u02d8","\\breve"),Se(ze,Ae,Ce,"\u02c7","\\check"),Se(ze,Ae,Ce,"^","\\hat"),Se(ze,Ae,Ce,"\u20d7","\\vec"),Se(ze,Ae,Ce,"\u02d9","\\dot"),Se(ze,Ae,Ce,"\u02da","\\mathring"),Se(ze,Ae,Oe,"\ue131","\\@imath"),Se(ze,Ae,Oe,"\ue237","\\@jmath"),Se(ze,Ae,Le,"\u0131","\u0131"),Se(ze,Ae,Le,"\u0237","\u0237"),Se(Me,Ae,Le,"\u0131","\\i",!0),Se(Me,Ae,Le,"\u0237","\\j",!0),Se(Me,Ae,Le,"\xdf","\\ss",!0),Se(Me,Ae,Le,"\xe6","\\ae",!0),Se(Me,Ae,Le,"\u0153","\\oe",!0),Se(Me,Ae,Le,"\xf8","\\o",!0),Se(Me,Ae,Le,"\xc6","\\AE",!0),Se(Me,Ae,Le,"\u0152","\\OE",!0),Se(Me,Ae,Le,"\xd8","\\O",!0),Se(Me,Ae,Ce,"\u02ca","\\'"),Se(Me,Ae,Ce,"\u02cb","\\`"),Se(Me,Ae,Ce,"\u02c6","\\^"),Se(Me,Ae,Ce,"\u02dc","\\~"),Se(Me,Ae,Ce,"\u02c9","\\="),Se(Me,Ae,Ce,"\u02d8","\\u"),Se(Me,Ae,Ce,"\u02d9","\\."),Se(Me,Ae,Ce,"\xb8","\\c"),Se(Me,Ae,Ce,"\u02da","\\r"),Se(Me,Ae,Ce,"\u02c7","\\v"),Se(Me,Ae,Ce,"\xa8",'\\"'),Se(Me,Ae,Ce,"\u02dd","\\H"),Se(Me,Ae,Ce,"\u25ef","\\textcircled");var Pe={"--":!0,"---":!0,"``":!0,"''":!0};Se(Me,Ae,Le,"\u2013","--",!0),Se(Me,Ae,Le,"\u2013","\\textendash"),Se(Me,Ae,Le,"\u2014","---",!0),Se(Me,Ae,Le,"\u2014","\\textemdash"),Se(Me,Ae,Le,"\u2018","`",!0),Se(Me,Ae,Le,"\u2018","\\textquoteleft"),Se(Me,Ae,Le,"\u2019","'",!0),Se(Me,Ae,Le,"\u2019","\\textquoteright"),Se(Me,Ae,Le,"\u201c","``",!0),Se(Me,Ae,Le,"\u201c","\\textquotedblleft"),Se(Me,Ae,Le,"\u201d","''",!0),Se(Me,Ae,Le,"\u201d","\\textquotedblright"),Se(ze,Ae,Le,"\xb0","\\degree",!0),Se(Me,Ae,Le,"\xb0","\\degree"),Se(Me,Ae,Le,"\xb0","\\textdegree",!0),Se(ze,Ae,Le,"\xa3","\\pounds"),Se(ze,Ae,Le,"\xa3","\\mathsterling",!0),Se(Me,Ae,Le,"\xa3","\\pounds"),Se(Me,Ae,Le,"\xa3","\\textsterling",!0),Se(ze,Te,Le,"\u2720","\\maltese"),Se(Me,Te,Le,"\u2720","\\maltese");for(var Fe="0123456789/@.\"",Ve=0;Ve<14;Ve++){var Ge=Fe.charAt(Ve);Se(ze,Ae,Le,Ge,Ge)}for(var je="0123456789!@*()-=+\";:?/.,",Ue=0;Ue<25;Ue++){var _e=je.charAt(Ue);Se(Me,Ae,Le,_e,_e)}for(var Xe,Ye="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",We=0;We<52;We++){var $e=Ye.charAt(We);Se(ze,Ae,Oe,$e,$e),Se(Me,Ae,Le,$e,$e)}Se(ze,Te,Le,"C","\u2102"),Se(Me,Te,Le,"C","\u2102"),Se(ze,Te,Le,"H","\u210d"),Se(Me,Te,Le,"H","\u210d"),Se(ze,Te,Le,"N","\u2115"),Se(Me,Te,Le,"N","\u2115"),Se(ze,Te,Le,"P","\u2119"),Se(Me,Te,Le,"P","\u2119"),Se(ze,Te,Le,"Q","\u211a"),Se(Me,Te,Le,"Q","\u211a"),Se(ze,Te,Le,"R","\u211d"),Se(Me,Te,Le,"R","\u211d"),Se(ze,Te,Le,"Z","\u2124"),Se(Me,Te,Le,"Z","\u2124"),Se(ze,Ae,Oe,"h","\u210e"),Se(Me,Ae,Oe,"h","\u210e");for(var Ze=0;Ze<52;Ze++){var Ke=Ye.charAt(Ze);Se(ze,Ae,Oe,Ke,Xe=String.fromCharCode(55349,56320+Ze)),Se(Me,Ae,Le,Ke,Xe),Se(ze,Ae,Oe,Ke,Xe=String.fromCharCode(55349,56372+Ze)),Se(Me,Ae,Le,Ke,Xe),Se(ze,Ae,Oe,Ke,Xe=String.fromCharCode(55349,56424+Ze)),Se(Me,Ae,Le,Ke,Xe),Se(ze,Ae,Oe,Ke,Xe=String.fromCharCode(55349,56580+Ze)),Se(Me,Ae,Le,Ke,Xe),Se(ze,Ae,Oe,Ke,Xe=String.fromCharCode(55349,56684+Ze)),Se(Me,Ae,Le,Ke,Xe),Se(ze,Ae,Oe,Ke,Xe=String.fromCharCode(55349,56736+Ze)),Se(Me,Ae,Le,Ke,Xe),Se(ze,Ae,Oe,Ke,Xe=String.fromCharCode(55349,56788+Ze)),Se(Me,Ae,Le,Ke,Xe),Se(ze,Ae,Oe,Ke,Xe=String.fromCharCode(55349,56840+Ze)),Se(Me,Ae,Le,Ke,Xe),Se(ze,Ae,Oe,Ke,Xe=String.fromCharCode(55349,56944+Ze)),Se(Me,Ae,Le,Ke,Xe),Ze<26&&(Se(ze,Ae,Oe,Ke,Xe=String.fromCharCode(55349,56632+Ze)),Se(Me,Ae,Le,Ke,Xe),Se(ze,Ae,Oe,Ke,Xe=String.fromCharCode(55349,56476+Ze)),Se(Me,Ae,Le,Ke,Xe))}Se(ze,Ae,Oe,"k",Xe=String.fromCharCode(55349,56668)),Se(Me,Ae,Le,"k",Xe);for(var Je=0;Je<10;Je++){var Qe=Je.toString();Se(ze,Ae,Oe,Qe,Xe=String.fromCharCode(55349,57294+Je)),Se(Me,Ae,Le,Qe,Xe),Se(ze,Ae,Oe,Qe,Xe=String.fromCharCode(55349,57314+Je)),Se(Me,Ae,Le,Qe,Xe),Se(ze,Ae,Oe,Qe,Xe=String.fromCharCode(55349,57324+Je)),Se(Me,Ae,Le,Qe,Xe),Se(ze,Ae,Oe,Qe,Xe=String.fromCharCode(55349,57334+Je)),Se(Me,Ae,Le,Qe,Xe)}for(var et="\xd0\xde\xfe",tt=0;tt<3;tt++){var rt=et.charAt(tt);Se(ze,Ae,Oe,rt,rt),Se(Me,Ae,Le,rt,rt)}var at={mathClass:"mathbf",textClass:"textbf",font:"Main-Bold"},nt={mathClass:"mathnormal",textClass:"textit",font:"Math-Italic"},it={mathClass:"boldsymbol",textClass:"boldsymbol",font:"Main-BoldItalic"},ot={mathClass:"",textClass:"",font:""},st={mathClass:"mathfrak",textClass:"textfrak",font:"Fraktur-Regular"},lt={mathClass:"mathbb",textClass:"textbb",font:"AMS-Regular"},ht={mathClass:"mathboldfrak",textClass:"textboldfrak",font:"Fraktur-Regular"},mt={mathClass:"mathsf",textClass:"textsf",font:"SansSerif-Regular"},ct={mathClass:"mathboldsf",textClass:"textboldsf",font:"SansSerif-Bold"},ut={mathClass:"mathitsf",textClass:"textitsf",font:"SansSerif-Italic"},pt={mathClass:"mathtt",textClass:"texttt",font:"Typewriter-Regular"},dt=[at,at,nt,nt,it,it,{mathClass:"mathscr",textClass:"textscr",font:"Script-Regular"},ot,ot,ot,st,st,lt,lt,ht,ht,mt,mt,ct,ct,ut,ut,ot,ot,pt,pt],gt=[at,ot,mt,ct,pt],ft=e=>{var t=1024*(e.charCodeAt(0)-55296)+(e.charCodeAt(1)-56320)+65536;if(119808<=t&&t<120484){var r=Math.floor((t-119808)/26);return dt[r]}if(120782<=t&&t<=120831){var a=Math.floor((t-120782)/10);return gt[a]}if(120485===t||120486===t)return dt[0];if(120486<t&&t<120782)return ot;throw new s("Unsupported character: "+e)},vt=function(e,t,r){if(ke[r][e]){var a=ke[r][e].replace;a&&(e=a)}return{value:e,metrics:ye(e,t,r)}},bt=function(e,t,r,a,n){var i,o=vt(e,t,r),s=o.metrics;if(e=o.value,s){var l=s.italic;("text"===r||a&&"mathit"===a.font)&&(l=0),i=new he(e,s.height,s.depth,l,s.skew,s.width,n)}else"undefined"!=typeof console&&console.warn("No character metrics for '"+e+"' in style '"+t+"' and mode '"+r+"'"),i=new he(e,0,0,0,0,0,n);if(a){i.maxFontSize=a.sizeMultiplier,a.style.isTight()&&i.classes.push("mtight");var h=a.getColor();h&&(i.style.color=h)}return i},yt=function(e,t,r,a){return void 0===a&&(a=[]),"boldsymbol"===r.font&&vt(e,"Main-Bold",t).metrics?bt(e,"Main-Bold",t,r,a.concat(["mathbf"])):"\\"===e||"main"===ke[t][e].font?bt(e,"Main-Regular",t,r,a):bt(e,"AMS-Regular",t,r,a.concat(["amsrm"]))},xt=function(e,t,r){return"textord"!==r&&vt(e,"Math-BoldItalic",t).metrics?{fontName:"Math-BoldItalic",fontClass:"boldsymbol"}:{fontName:"Main-Bold",fontClass:"mathbf"}},wt=function(e,t){var r="mathord"===e.type?"mathord":"textord",a=e.mode,n=e.text,i=["mord"],o=t.font,s=t.fontFamily,l=t.fontWeight,h=t.fontShape,m="math"===a||"text"===a&&!!o,c=m?o:s,u="",p="";if(55349===n.charCodeAt(0)){var d=ft(n);u=d.font,p=d[a+"Class"]}if(u)return bt(n,u,a,t,i.concat(p));if(c){var g,f;if("boldsymbol"===c){var v=xt(n,a,r);g=v.fontName,f=[v.fontClass]}else m?(g=Ht[o].fontName,f=[o]):(g=Et(s,l,h),f=[s,l,h]);if(vt(n,g,a).metrics)return bt(n,g,a,t,i.concat(f));if(Object.prototype.hasOwnProperty.call(Pe,n)&&"Typewriter"===g.slice(0,10)){for(var b=[],y=0;y<n.length;y++)b.push(bt(n[y],g,a,t,i.concat(f)));return Bt(b)}}if("mathord"===r)return bt(n,"Math-Italic",a,t,i.concat(["mathnormal"]));if("textord"===r){var x=ke[a][n]&&ke[a][n].font;if("ams"===x){var w=Et("amsrm",l,h);return bt(n,w,a,t,i.concat("amsrm",l,h))}if("main"!==x&&x){var k=Et(x,l,h);return bt(n,k,a,t,i.concat(k,l,h))}var S=Et("textrm",l,h);return bt(n,S,a,t,i.concat(l,h))}throw new Error("unexpected type: "+r+" in makeOrd")},kt=(e,t)=>{if(Q(e.classes)!==Q(t.classes)||e.skew!==t.skew||e.maxFontSize!==t.maxFontSize||0!==e.italic&&e.hasClass("mathnormal"))return!1;if(1===e.classes.length){var r=e.classes[0];if("mbin"===r||"mord"===r)return!1}for(var a of Object.keys(e.style))if(e.style[a]!==t.style[a])return!1;for(var n of Object.keys(t.style))if(e.style[n]!==t.style[n])return!1;return!0},St=e=>{for(var t=0;t<e.length-1;t++){var r=e[t],a=e[t+1];r instanceof he&&a instanceof he&&kt(r,a)&&(r.text+=a.text,r.height=Math.max(r.height,a.height),r.depth=Math.max(r.depth,a.depth),r.italic=a.italic,e.splice(t+1,1),t--)}return e},zt=function(e){for(var t=0,r=0,a=0,n=0;n<e.children.length;n++){var i=e.children[n];i.height>t&&(t=i.height),i.depth>r&&(r=i.depth),i.maxFontSize>a&&(a=i.maxFontSize)}e.height=t,e.depth=r,e.maxFontSize=a},Mt=function(e,t,r,a){var n=new ie(e,t,r,a);return zt(n),n},At=(e,t,r,a)=>new ie(e,t,r,a),Tt=function(e,t,r){var a=Mt([e],[],t);return a.height=Math.max(r||t.fontMetrics().defaultRuleThickness,t.minRuleThickness),a.style.borderBottomWidth=J(a.height),a.maxFontSize=1,a},Ct=function(e,t,r,a){var n=new oe(e,t,r,a);return zt(n),n},Bt=function(e){var t=new Y(e);return zt(t),t},qt=function(e,t){return e instanceof Y?Mt([],[e],t):e},It=function(e){if("individualShift"===e.positionType){for(var t=e.children,r=[t[0]],a=-t[0].shift-t[0].elem.depth,n=a,i=1;i<t.length;i++){var o=-t[i].shift-n-t[i].elem.depth,s=o-(t[i-1].elem.height+t[i-1].elem.depth);n+=o,r.push({type:"kern",size:s}),r.push(t[i])}return{children:r,depth:a}}var l;if("top"===e.positionType){for(var h=e.positionData,m=0;m<e.children.length;m++){var c=e.children[m];h-="kern"===c.type?c.size:c.elem.height+c.elem.depth}l=h}else if("bottom"===e.positionType)l=-e.positionData;else{var u=e.children[0];if("elem"!==u.type)throw new Error('First child must have type "elem".');if("shift"===e.positionType)l=-u.elem.depth-e.positionData;else{if("firstBaseline"!==e.positionType)throw new Error("Invalid positionType "+e.positionType+".");l=-u.elem.depth}}return{children:e.children,depth:l}},Ot=function(e,t){for(var r=It(e),a=r.children,n=r.depth,i=0,o=0;o<a.length;o++){var s=a[o];if("elem"===s.type){var l=s.elem;i=Math.max(i,l.maxFontSize,l.height)}}i+=2;var h=Mt(["pstrut"],[]);h.style.height=J(i);for(var m=[],c=n,u=n,p=n,d=0;d<a.length;d++){var g=a[d];if("kern"===g.type)p+=g.size;else{var f=g.elem,v=g.wrapperClasses||[],b=g.wrapperStyle||{},y=Mt(v,[h,f],void 0,b);y.style.top=J(-i-p-f.depth),g.marginLeft&&(y.style.marginLeft=g.marginLeft),g.marginRight&&(y.style.marginRight=g.marginRight),m.push(y),p+=f.height+f.depth}c=Math.min(c,p),u=Math.max(u,p)}var x,w=Mt(["vlist"],m);if(w.style.height=J(u),c<0){var k=Mt([],[]),S=Mt(["vlist"],[k]);S.style.height=J(-c);var z=Mt(["vlist-s"],[new he("\u200b")]);x=[Mt(["vlist-r"],[w,z]),Mt(["vlist-r"],[S])]}else x=[Mt(["vlist-r"],[w])];var M=Mt(["vlist-t"],x);return 2===x.length&&M.classes.push("vlist-t2"),M.height=u,M.depth=-c,M},Rt=(e,t)=>{var r=Mt(["mspace"],[],t),a=K(e,t);return r.style.marginRight=J(a),r},Et=(e,t,r)=>{var a;switch(e){case"amsrm":a="AMS";break;case"textrm":a="Main";break;case"textsf":a="SansSerif";break;case"texttt":a="Typewriter";break;default:a=e}return a+"-"+("textbf"===t&&"textit"===r?"BoldItalic":"textbf"===t?"Bold":"textit"===r?"Italic":"Regular")},Ht={mathbf:{variant:"bold",fontName:"Main-Bold"},mathrm:{variant:"normal",fontName:"Main-Regular"},textit:{variant:"italic",fontName:"Main-Italic"},mathit:{variant:"italic",fontName:"Main-Italic"},mathnormal:{variant:"italic",fontName:"Math-Italic"},mathsfit:{variant:"sans-serif-italic",fontName:"SansSerif-Italic"},mathbb:{variant:"double-struck",fontName:"AMS-Regular"},mathcal:{variant:"script",fontName:"Caligraphic-Regular"},mathfrak:{variant:"fraktur",fontName:"Fraktur-Regular"},mathscr:{variant:"script",fontName:"Script-Regular"},mathsf:{variant:"sans-serif",fontName:"SansSerif-Regular"},mathtt:{variant:"monospace",fontName:"Typewriter-Regular"}},Nt={vec:["vec",.471,.714],oiintSize1:["oiintSize1",.957,.499],oiintSize2:["oiintSize2",1.472,.659],oiiintSize1:["oiiintSize1",1.304,.499],oiiintSize2:["oiiintSize2",1.98,.659]},Dt=function(e,t){var r=Nt[e],a=r[0],n=r[1],i=r[2],o=new ce(a),s=new me([o],{width:J(n),height:J(i),style:"width:"+J(n),viewBox:"0 0 "+1e3*n+" "+1e3*i,preserveAspectRatio:"xMinYMin"}),l=At(["katex-overlay"],[s],t);return l.height=i,l.style.height=J(i),l.style.width=J(n),l},Lt={number:3,unit:"mu"},Pt={number:4,unit:"mu"},Ft={number:5,unit:"mu"},Vt={mord:{mop:Lt,mbin:Pt,mrel:Ft,minner:Lt},mop:{mord:Lt,mop:Lt,mrel:Ft,minner:Lt},mbin:{mord:Pt,mop:Pt,mopen:Pt,minner:Pt},mrel:{mord:Ft,mop:Ft,mopen:Ft,minner:Ft},mopen:{},mclose:{mop:Lt,mbin:Pt,mrel:Ft,minner:Lt},mpunct:{mord:Lt,mop:Lt,mrel:Ft,mopen:Lt,mclose:Lt,mpunct:Lt,minner:Lt},minner:{mord:Lt,mop:Lt,mbin:Pt,mrel:Ft,mopen:Lt,mpunct:Lt,minner:Lt}},Gt={mord:{mop:Lt},mop:{mord:Lt,mop:Lt},mbin:{},mrel:{},mopen:{},mclose:{mop:Lt},mpunct:{},minner:{mop:Lt}},jt={},Ut={},_t={};function Xt(e){for(var t=e.type,r=e.names,a=e.htmlBuilder,n=e.mathmlBuilder,i=0;i<r.length;++i)jt[r[i]]=e;t&&(a&&(Ut[t]=a),n&&(_t[t]=n))}function Yt(e){var t=e.type,r=e.htmlBuilder,a=e.mathmlBuilder;r&&(Ut[t]=r),a&&(_t[t]=a)}var Wt=function(e){return"ordgroup"===e.type&&1===e.body.length?e.body[0]:e},$t=function(e){return"ordgroup"===e.type?e.body:[e]},Zt=new Set(["leftmost","mbin","mopen","mrel","mop","mpunct"]),Kt=new Set(["rightmost","mrel","mclose","mpunct"]),Jt={display:q.DISPLAY,text:q.TEXT,script:q.SCRIPT,scriptscript:q.SCRIPTSCRIPT},Qt={mord:"mord",mop:"mop",mbin:"mbin",mrel:"mrel",mopen:"mopen",mclose:"mclose",mpunct:"mpunct",minner:"minner"},er=function(e,t,r,a){void 0===a&&(a=[null,null]);for(var n=[],i=0;i<e.length;i++){var o=or(e[i],t);if(o instanceof Y){var s=o.children;n.push(...s)}else n.push(o)}if(St(n),!r)return n;var l=t;if(1===e.length){var h=e[0];"sizing"===h.type?l=t.havingSize(h.size):"styling"===h.type&&(l=t.havingStyle(Jt[h.style]))}var m=Mt([a[0]||"leftmost"],[],t),c=Mt([a[1]||"rightmost"],[],t),u="root"===r;return tr(n,(e,t)=>{var r=t.classes[0],a=e.classes[0];"mbin"===r&&Kt.has(a)?t.classes[0]="mord":"mbin"===a&&Zt.has(r)&&(e.classes[0]="mord")},{node:m},c,u),tr(n,(e,t)=>{var r,a,n=nr(t),i=nr(e),o=n&&i?e.hasClass("mtight")?null==(r=Gt[n])?void 0:r[i]:null==(a=Vt[n])?void 0:a[i]:null;if(o)return Rt(o,l)},{node:m},c,u),n},tr=function(e,t,r,a,n){a&&e.push(a);for(var i=0;i<e.length;i++){var o=e[i],s=rr(o);if(s)tr(s.children,t,r,null,n);else{var l=!o.hasClass("mspace");if(l){var h=t(o,r.node);h&&(r.insertAfter?r.insertAfter(h):(e.unshift(h),i++))}l?r.node=o:n&&o.hasClass("katex-newline")&&(r.node=Mt(["leftmost"])),r.insertAfter=(t=>r=>{e.splice(t+1,0,r),i++})(i)}}a&&e.pop()},rr=function(e){return e instanceof Y||e instanceof oe||e instanceof ie&&e.hasClass("enclosing")?e:null},ar=function(e,t){var r=rr(e);if(r){var a=r.children;if(a.length){if("right"===t)return ar(a[a.length-1],"right");if("left"===t)return ar(a[0],"left")}}return e},nr=function(e,t){if(!e)return null;t&&(e=ar(e,t));var r=e.classes[0];return Qt[r]||null},ir=function(e,t){var r=["nulldelimiter"].concat(e.baseSizingClasses());return Mt(t.concat(r))},or=function(e,t,r){if(!e)return Mt();if(Ut[e.type]){var a=Ut[e.type](e,t);if(r&&t.size!==r.size){a=Mt(t.sizingClasses(r),[a],t);var n=t.sizeMultiplier/r.sizeMultiplier;a.height*=n,a.depth*=n}return a}throw new s("Got group of unknown type: '"+e.type+"'")};function sr(e,t){var r=Mt(["katex-base"],e,t),a=Mt(["katex-strut"]);return a.style.height=J(r.height+r.depth),r.depth&&(a.style.verticalAlign=J(-r.depth)),r.children.unshift(a),r}function lr(e,t){var r=null;1===e.length&&"tag"===e[0].type&&(r=e[0].tag,e=e[0].body);var a,n=er(e,t,"root");2===n.length&&n[1].hasClass("katex-tag")&&(a=n.pop());for(var i,o=[],s=[],l=0;l<n.length;l++)if(s.push(n[l]),n[l].hasClass("mbin")||n[l].hasClass("mrel")||n[l].hasClass("allowbreak")){for(var h=!1;l<n.length-1&&n[l+1].hasClass("mspace")&&!n[l+1].hasClass("katex-newline");)l++,s.push(n[l]),n[l].hasClass("nobreak")&&(h=!0);h||(o.push(sr(s,t)),s=[])}else n[l].hasClass("katex-newline")&&(s.pop(),s.length>0&&(o.push(sr(s,t)),s=[]),o.push(n[l]));s.length>0&&o.push(sr(s,t)),r?((i=sr(er(r,t,!0),t)).classes=["katex-tag"],o.push(i)):a&&o.push(a);var m=Mt(["katex-html"],o);if(m.setAttribute("aria-hidden","true"),i){var c=i.children[0];c.style.height=J(m.height+m.depth),m.depth&&(c.style.verticalAlign=J(-m.depth))}return m}function hr(e){return new Y(e)}class mr{constructor(e,t,r){this.type=void 0,this.attributes=void 0,this.children=void 0,this.classes=void 0,this.type=e,this.attributes={},this.children=t||[],this.classes=r||[]}setAttribute(e,t){this.attributes[e]=t}getAttribute(e){return this.attributes[e]}toNode(){var e=document.createElementNS("http://www.w3.org/1998/Math/MathML",this.type);for(var t of Object.entries(this.attributes)){var r=t[0],a=t[1];e.setAttribute(r,a)}this.classes.length>0&&(e.className=Q(this.classes));for(var n=0;n<this.children.length;n++)if(this.children[n]instanceof cr&&this.children[n+1]instanceof cr){for(var i=this.children[n].toText()+this.children[++n].toText();this.children[n+1]instanceof cr;)i+=this.children[++n].toText();e.appendChild(new cr(i).toNode())}else e.appendChild(this.children[n].toNode());return e}toMarkup(){var e="<"+this.type;for(var t of Object.entries(this.attributes)){var r=t[0],a=t[1];e+=" "+r+"=\"",e+=u(a),e+="\""}this.classes.length>0&&(e+=" class =\""+u(Q(this.classes))+"\""),e+=">";for(var n=0;n<this.children.length;n++)e+=this.children[n].toMarkup();return e+="</"+this.type+">"}toText(){return this.children.map(e=>e.toText()).join("")}}class cr{constructor(e){this.text=void 0,this.text=e}toNode(){return document.createTextNode(this.text)}toMarkup(){return u(this.toText())}toText(){return this.text}}class ur{constructor(e){this.width=void 0,this.character=void 0,this.width=e,this.character=e>=.05555&&e<=.05556?"\u200a":e>=.1666&&e<=.1667?"\u2009":e>=.2222&&e<=.2223?"\u2005":e>=.2777&&e<=.2778?"\u2005\u200a":e>=-.05556&&e<=-.05555?"\u200a\u2063":e>=-.1667&&e<=-.1666?"\u2009\u2063":e>=-.2223&&e<=-.2222?"\u205f\u2063":e>=-.2778&&e<=-.2777?"\u2005\u2063":null}toNode(){if(this.character)return document.createTextNode(this.character);var e=document.createElementNS("http://www.w3.org/1998/Math/MathML","mspace");return e.setAttribute("width",J(this.width)),e}toMarkup(){return this.character?"<mtext>"+this.character+"</mtext>":"<mspace width=\""+J(this.width)+"\"/>"}toText(){return this.character?this.character:" "}}var pr=new Set(["\\imath","\\jmath"]),dr=new Set(["mrow","mtable"]),gr=function(e,t,r){var a,n;return ke[t][e]&&ke[t][e].replace&&55349!==e.charCodeAt(0)&&(!Object.prototype.hasOwnProperty.call(Pe,e)||"tt"!==(null==r||null==(a=r.fontFamily)?void 0:a.slice(4,6))&&"tt"!==(null==r||null==(n=r.font)?void 0:n.slice(4,6)))&&(e=ke[t][e].replace),new cr(e)},fr=function(e){return 1===e.length?e[0]:new mr("mrow",e)},vr={mathit:"italic",boldsymbol:e=>"textord"===e.type?"bold":"bold-italic",mathbf:"bold",mathbb:"double-struck",mathsfit:"sans-serif-italic",mathfrak:"fraktur",mathscr:"script",mathcal:"script",mathsf:"sans-serif",mathtt:"monospace"},br=(e,t)=>{if("text"===e.mode){if("texttt"===t.fontFamily)return"monospace";if("textsf"===t.fontFamily)return"textit"===t.fontShape&&"textbf"===t.fontWeight?"sans-serif-bold-italic":"textit"===t.fontShape?"sans-serif-italic":"textbf"===t.fontWeight?"bold-sans-serif":"sans-serif";if("textit"===t.fontShape&&"textbf"===t.fontWeight)return"bold-italic";if("textit"===t.fontShape)return"italic";if("textbf"===t.fontWeight)return"bold"}var r=t.font;if(!r||"mathnormal"===r)return null;var a=e.mode,n=vr[r];if(n)return"function"==typeof n?n(e):n;var i=e.text;if(pr.has(i))return null;if(ke[a][i]){var o=ke[a][i].replace;o&&(i=o)}return ye(i,Ht[r].fontName,a)?Ht[r].variant:null};function yr(e){if(!e)return!1;if('mi'===e.type&&1===e.children.length){var t=e.children[0];return t instanceof cr&&'.'===t.text}if('mo'===e.type&&1===e.children.length&&'true'===e.getAttribute('separator')&&'0em'===e.getAttribute('lspace')&&'0em'===e.getAttribute('rspace')){var r=e.children[0];return r instanceof cr&&','===r.text}return!1}var xr=function(e,t,r){if(1===e.length){var a=kr(e[0],t);return r&&a instanceof mr&&"mo"===a.type&&(a.setAttribute("lspace","0em"),a.setAttribute("rspace","0em")),[a]}for(var n,i=[],o=0;o<e.length;o++){var s=kr(e[o],t);if(s instanceof mr&&n instanceof mr){if('mtext'===s.type&&'mtext'===n.type&&s.getAttribute('mathvariant')===n.getAttribute('mathvariant')){n.children.push(...s.children);continue}if('mn'===s.type&&'mn'===n.type){n.children.push(...s.children);continue}if(yr(s)&&'mn'===n.type){n.children.push(...s.children);continue}if('mn'===s.type&&yr(n))s.children=[...n.children,...s.children],i.pop();else if(('msup'===s.type||'msub'===s.type)&&s.children.length>=1&&('mn'===n.type||yr(n))){var l=s.children[0];l instanceof mr&&'mn'===l.type&&(l.children=[...n.children,...l.children],i.pop())}else if('mi'===n.type&&1===n.children.length){var h=n.children[0];if(h instanceof cr&&'\u0338'===h.text&&('mo'===s.type||'mi'===s.type||'mn'===s.type)){var m=s.children[0];m instanceof cr&&m.text.length>0&&(m.text=m.text.slice(0,1)+"\u0338"+m.text.slice(1),i.pop())}}}i.push(s),n=s}return i},wr=function(e,t,r){return fr(xr(e,t,r))},kr=function(e,t){if(!e)return new mr("mrow");if(_t[e.type])return _t[e.type](e,t);throw new s("Got group of unknown type: '"+e.type+"'")};function Sr(e,t,r,a,n){var i,o=xr(e,r);i=1===o.length&&o[0]instanceof mr&&dr.has(o[0].type)?o[0]:new mr("mrow",o);var s=new mr("annotation",[new cr(t)]);s.setAttribute("encoding","application/x-tex");var l=new mr("semantics",[i,s]),h=new mr("math",[l]);return h.setAttribute("xmlns","http://www.w3.org/1998/Math/MathML"),a&&h.setAttribute("display","block"),Mt([n?"katex":"katex-mathml"],[h])}var zr=[[1,1,1],[2,1,1],[3,1,1],[4,2,1],[5,2,1],[6,3,1],[7,4,2],[8,6,3],[9,7,6],[10,8,7],[11,10,9]],Mr=[.5,.6,.7,.8,.9,1,1.2,1.44,1.728,2.074,2.488],Ar=function(e,t){return t.size<2?e:zr[e-1][t.size-1]};class Tr{constructor(e){this.style=void 0,this.color=void 0,this.size=void 0,this.textSize=void 0,this.phantom=void 0,this.font=void 0,this.fontFamily=void 0,this.fontWeight=void 0,this.fontShape=void 0,this.sizeMultiplier=void 0,this.maxSize=void 0,this.minRuleThickness=void 0,this._fontMetrics=void 0,this.style=e.style,this.color=e.color,this.size=e.size||Tr.BASESIZE,this.textSize=e.textSize||this.size,this.phantom=!!e.phantom,this.font=e.font||"",this.fontFamily=e.fontFamily||"",this.fontWeight=e.fontWeight||"",this.fontShape=e.fontShape||"",this.sizeMultiplier=Mr[this.size-1],this.maxSize=e.maxSize,this.minRuleThickness=e.minRuleThickness,this._fontMetrics=void 0}extend(e){var t={style:this.style,size:this.size,textSize:this.textSize,color:this.color,phantom:this.phantom,font:this.font,fontFamily:this.fontFamily,fontWeight:this.fontWeight,fontShape:this.fontShape,maxSize:this.maxSize,minRuleThickness:this.minRuleThickness};return Object.assign(t,e),new Tr(t)}havingStyle(e){return this.style===e?this:this.extend({style:e,size:Ar(this.textSize,e)})}havingCrampedStyle(){return this.havingStyle(this.style.cramp())}havingSize(e){return this.size===e&&this.textSize===e?this:this.extend({style:this.style.text(),size:e,textSize:e,sizeMultiplier:Mr[e-1]})}havingBaseStyle(e){e=e||this.style.text();var t=Ar(Tr.BASESIZE,e);return this.size===t&&this.textSize===Tr.BASESIZE&&this.style===e?this:this.extend({style:e,size:t})}havingBaseSizing(){var e;switch(this.style.id){case 4:case 5:e=3;break;case 6:case 7:e=1;break;default:e=6}return this.extend({style:this.style.text(),size:e})}withColor(e){return this.extend({color:e})}withPhantom(){return this.extend({phantom:!0})}withFont(e){return this.extend({font:e})}withTextFontFamily(e){return this.extend({fontFamily:e,font:""})}withTextFontWeight(e){return this.extend({fontWeight:e,font:""})}withTextFontShape(e){return this.extend({fontShape:e,font:""})}sizingClasses(e){return e.size!==this.size?["katex-sizing","reset-size"+e.size,"size"+this.size]:[]}baseSizingClasses(){return this.size!==Tr.BASESIZE?["katex-sizing","reset-size"+this.size,"size"+Tr.BASESIZE]:[]}fontMetrics(){return this._fontMetrics||(this._fontMetrics=we(this.size)),this._fontMetrics}getColor(){return this.phantom?"transparent":this.color}}Tr.BASESIZE=6;var Cr=function(e){return new Tr({style:e.displayMode?q.DISPLAY:q.TEXT,maxSize:e.maxSize,minRuleThickness:e.minRuleThickness})},Br=function(e,t){if(t.displayMode){var r=["katex-display"];t.leqno&&r.push("leqno"),t.fleqn&&r.push("fleqn"),e=Mt(r,[e])}return e},qr=function(e,t,r){var a,n=Cr(r);if("mathml"===r.output)return Sr(e,t,n,r.displayMode,!0);if("html"===r.output){var i=lr(e,n);a=Mt(["katex"],[i])}else{var o=Sr(e,t,n,r.displayMode,!1),s=lr(e,n);a=Mt(["katex"],[o,s])}return Br(a,r)},Ir=function(e,t,r){var a=lr(e,Cr(r)),n=Mt(["katex"],[a]);return Br(n,r)},Or={widehat:"^",widecheck:"\u02c7",widetilde:"~",utilde:"~",overleftarrow:"\u2190",underleftarrow:"\u2190",xleftarrow:"\u2190",overrightarrow:"\u2192",underrightarrow:"\u2192",xrightarrow:"\u2192",underbrace:"\u23df",overbrace:"\u23de",underbracket:"\u23b5",overbracket:"\u23b4",overgroup:"\u23e0",undergroup:"\u23e1",overleftrightarrow:"\u2194",underleftrightarrow:"\u2194",xleftrightarrow:"\u2194",Overrightarrow:"\u21d2",xRightarrow:"\u21d2",overleftharpoon:"\u21bc",xleftharpoonup:"\u21bc",overrightharpoon:"\u21c0",xrightharpoonup:"\u21c0",xLeftarrow:"\u21d0",xLeftrightarrow:"\u21d4",xhookleftarrow:"\u21a9",xhookrightarrow:"\u21aa",xmapsto:"\u21a6",xrightharpoondown:"\u21c1",xleftharpoondown:"\u21bd",xrightleftharpoons:"\u21cc",xleftrightharpoons:"\u21cb",xtwoheadleftarrow:"\u219e",xtwoheadrightarrow:"\u21a0",xlongequal:"=",xtofrom:"\u21c4",xrightleftarrows:"\u21c4",xrightequilibrium:"\u21cc",xleftequilibrium:"\u21cb","\\cdrightarrow":"\u2192","\\cdleftarrow":"\u2190","\\cdlongequal":"="},Rr=function(e){var t=new mr("mo",[new cr(Or[e.replace(/^\\/,'')])]);return t.setAttribute("stretchy","true"),t},Er={overrightarrow:[["rightarrow"],.888,522,"xMaxYMin"],overleftarrow:[["leftarrow"],.888,522,"xMinYMin"],underrightarrow:[["rightarrow"],.888,522,"xMaxYMin"],underleftarrow:[["leftarrow"],.888,522,"xMinYMin"],xrightarrow:[["rightarrow"],1.469,522,"xMaxYMin"],"\\cdrightarrow":[["rightarrow"],3,522,"xMaxYMin"],xleftarrow:[["leftarrow"],1.469,522,"xMinYMin"],"\\cdleftarrow":[["leftarrow"],3,522,"xMinYMin"],Overrightarrow:[["doublerightarrow"],.888,560,"xMaxYMin"],xRightarrow:[["doublerightarrow"],1.526,560,"xMaxYMin"],xLeftarrow:[["doubleleftarrow"],1.526,560,"xMinYMin"],overleftharpoon:[["leftharpoon"],.888,522,"xMinYMin"],xleftharpoonup:[["leftharpoon"],.888,522,"xMinYMin"],xleftharpoondown:[["leftharpoondown"],.888,522,"xMinYMin"],overrightharpoon:[["rightharpoon"],.888,522,"xMaxYMin"],xrightharpoonup:[["rightharpoon"],.888,522,"xMaxYMin"],xrightharpoondown:[["rightharpoondown"],.888,522,"xMaxYMin"],xlongequal:[["longequal"],.888,334,"xMinYMin"],"\\cdlongequal":[["longequal"],3,334,"xMinYMin"],xtwoheadleftarrow:[["twoheadleftarrow"],.888,334,"xMinYMin"],xtwoheadrightarrow:[["twoheadrightarrow"],.888,334,"xMaxYMin"],overleftrightarrow:[["leftarrow","rightarrow"],.888,522],overbrace:[["leftbrace","midbrace","rightbrace"],1.6,548],underbrace:[["leftbraceunder","midbraceunder","rightbraceunder"],1.6,548],underleftrightarrow:[["leftarrow","rightarrow"],.888,522],xleftrightarrow:[["leftarrow","rightarrow"],1.75,522],xLeftrightarrow:[["doubleleftarrow","doublerightarrow"],1.75,560],xrightleftharpoons:[["leftharpoondownplus","rightharpoonplus"],1.75,716],xleftrightharpoons:[["leftharpoonplus","rightharpoondownplus"],1.75,716],xhookleftarrow:[["leftarrow","righthook"],1.08,522],xhookrightarrow:[["lefthook","rightarrow"],1.08,522],overlinesegment:[["leftlinesegment","rightlinesegment"],.888,522],underlinesegment:[["leftlinesegment","rightlinesegment"],.888,522],overbracket:[["leftbracketover","rightbracketover"],1.6,440],underbracket:[["leftbracketunder","rightbracketunder"],1.6,410],overgroup:[["leftgroup","rightgroup"],.888,342],undergroup:[["leftgroupunder","rightgroupunder"],.888,342],xmapsto:[["leftmapsto","rightarrow"],1.5,522],xtofrom:[["leftToFrom","rightToFrom"],1.75,528],xrightleftarrows:[["baraboveleftarrow","rightarrowabovebar"],1.75,901],xrightequilibrium:[["baraboveshortleftharpoon","rightharpoonaboveshortbar"],1.75,716],xleftequilibrium:[["shortbaraboveleftharpoon","shortrightharpoonabovebar"],1.75,716]},Hr=new Set(["widehat","widecheck","widetilde","utilde"]),Nr=function(e,t){var r=(function(){var r=4e5,a=e.label.slice(1);if(Hr.has(a)&&'base'in e){var n,i,o,s="ordgroup"===e.base.type?e.base.body.length:1;if(s>5)"widehat"===a||"widecheck"===a?(n=420,r=2364,o=.42,i=a+"4"):(n=312,r=2340,o=.34,i="tilde4");else{var l=[1,1,2,2,3,3][s];"widehat"===a||"widecheck"===a?(r=[0,1062,2364,2364,2364][l],n=[0,239,300,360,420][l],o=[0,.24,.3,.3,.36,.42][l],i=a+l):(r=[0,600,1033,2339,2340][l],n=[0,260,286,306,312][l],o=[0,.26,.286,.3,.306,.34][l],i="tilde"+l)}var h=new ce(i),m=new me([h],{width:"100%",height:J(o),viewBox:"0 0 "+r+" "+n,preserveAspectRatio:"none"});return{span:At([],[m],t),minWidth:0,height:o}}var c=[],u=Er[a];if(!u)throw new Error("No SVG data for \""+a+"\".");var p,d,g=u[0],f=u[1],v=u[2],b=v/1e3,y=g.length;if(1===y){if(4!==u.length)throw new Error("Expected 4-tuple for single-path SVG data \""+a+"\".");p=["hide-tail"],d=[u[3]]}else if(2===y)p=["halfarrow-left","halfarrow-right"],d=["xMinYMin","xMaxYMin"];else{if(3!==y)throw new Error("Correct katexImagesData or update code here to support\n "+y+" children.");p=["brace-left","brace-center","brace-right"],d=["xMinYMin","xMidYMin","xMaxYMin"]}for(var x=0;x<y;x++){var w=new ce(g[x]),k=new me([w],{width:"400em",height:J(b),viewBox:"0 0 "+r+" "+v,preserveAspectRatio:d[x]+" slice"}),S=At([p[x]],[k],t);if(1===y)return{span:S,minWidth:f,height:b};S.style.height=J(b),c.push(S)}return{span:Mt(["katex-stretchy"],c,t),minWidth:f,height:b}})(),a=r.span,n=r.minWidth,i=r.height;return a.height=i,a.style.height=J(i),n>0&&(a.style.minWidth=J(n)),a},Dr=function(e,t,r,a,n){var i,o=e.height+e.depth+r+a;if(/fbox|color|angl/.test(t)){if(i=Mt(["katex-stretchy",t],[],n),"fbox"===t){var s=n.color&&n.getColor();s&&(i.style.borderColor=s)}}else{var l=[];/^[bx]cancel$/.test(t)&&l.push(new ue({x1:"0",y1:"0",x2:"100%",y2:"100%","stroke-width":"0.046em"})),/^x?cancel$/.test(t)&&l.push(new ue({x1:"0",y1:"100%",x2:"100%",y2:"0","stroke-width":"0.046em"}));var h=new me(l,{width:"100%",height:J(o)});i=At([],[h],n)}return i.height=o,i.style.height=J(o),i},Lr=new Set(["bin","close","inner","open","punct","rel"]),Pr=new Set(["accent-token","mathord","op-token","spacing","textord"]);function Fr(e,t){if(!e||e.type!==t)throw new Error("Expected node of type "+t+", but got "+(e?"node of type "+e.type:String(e)));return e}function Vr(e){var t=Gr(e);if(!t)throw new Error("Expected node of symbol group type, but got "+(e?"node of type "+e.type:String(e)));return t}function Gr(e){return"atom"===e.type||Pr.has(e.type)?e:null}function jr(e,t,r){var a="";for(var n of e.body)if("textord"===n.type)a+=n.text;else{if(!r||"spacing"!==n.type||" "!==n.text)throw new s(t,e);a+=" "}return a}var Ur=e=>{return e instanceof he?e:((t=e)instanceof ie||t instanceof oe||t instanceof Y)&&1===e.children.length?Ur(e.children[0]):void 0;var t},_r=(e,t)=>{var r,a,n;e&&"supsub"===e.type?(r=(a=Fr(e.base,"accent")).base,e.base=r,n=de(or(e,t)),e.base=a):r=(a=Fr(e,"accent")).base;var i,o,s=or(r,t.havingCrampedStyle()),l=0;a.isShifty&&g(r)&&(l=null!=(i=null==(o=Ur(s))?void 0:o.skew)?i:0);var h,m="\\c"===a.label,c=m?s.height+s.depth:Math.min(s.height,t.fontMetrics().xHeight);if(a.isStretchy)h=Nr(a,t),h=Ot({positionType:"firstBaseline",children:[{type:"elem",elem:s},{type:"elem",elem:h,wrapperClasses:["svg-align"],wrapperStyle:l>0?{width:"calc(100% - "+J(2*l)+")",marginLeft:J(2*l)}:void 0}]});else{var u,p;"\\vec"===a.label?(u=Dt("vec",t),p=Nt.vec[1]):((u=pe(u=wt({type:"textord",mode:a.mode,text:a.label},t))).italic=0,p=u.width,m&&(c+=u.depth)),h=Mt(["accent-body"],[u]);var d="\\textcircled"===a.label;d&&(h.classes.push('accent-full'),c=s.height);var f=l;d||(f-=p/2),h.style.left=J(f),"\\textcircled"===a.label&&(h.style.top=".2em"),h=Ot({positionType:"firstBaseline",children:[{type:"elem",elem:s},{type:"kern",size:-c},{type:"elem",elem:h}]})}var v=Mt(["mord","katex-accent"],[h],t);return n?(n.children[0]=v,n.height=Math.max(v.height,n.height),n.classes[0]="mord",n):v},Xr=new RegExp(["\\acute","\\grave","\\ddot","\\tilde","\\bar","\\breve","\\check","\\hat","\\vec","\\dot","\\mathring"].map(e=>"\\"+e).join("|"));Xt({type:"accent",names:["\\acute","\\grave","\\ddot","\\tilde","\\bar","\\breve","\\check","\\hat","\\vec","\\dot","\\mathring","\\widecheck","\\widehat","\\widetilde","\\overrightarrow","\\overleftarrow","\\Overrightarrow","\\overleftrightarrow","\\overgroup","\\overlinesegment","\\overleftharpoon","\\overrightharpoon"],numArgs:1,handler:(e,t)=>{var r=Wt(t[0]),a=!Xr.test(e.funcName),n=!a||"\\widehat"===e.funcName||"\\widetilde"===e.funcName||"\\widecheck"===e.funcName;return{type:"accent",mode:e.parser.mode,label:e.funcName,isStretchy:a,isShifty:n,base:r}},htmlBuilder:_r,mathmlBuilder:(e,t)=>{var r=e.isStretchy?Rr(e.label):new mr("mo",[gr(e.label,e.mode)]),a=new mr("mover",[kr(e.base,t),r]);return a.setAttribute("accent","true"),a}}),Xt({type:"accent",names:["\\'","\\`","\\^","\\~","\\=","\\u","\\.",'\\"',"\\c","\\r","\\H","\\v","\\textcircled"],numArgs:1,allowedInText:!0,allowedInMath:!0,argTypes:["primitive"],handler:(e,t)=>{var r=t[0],a=e.parser.mode;return"math"===a&&(e.parser.settings.reportNonstrict("mathVsTextAccents","LaTeX's accent "+e.funcName+" works only in text mode"),a="text"),{type:"accent",mode:a,label:e.funcName,isStretchy:!1,isShifty:!0,base:r}}}),Xt({type:"accentUnder",names:["\\underleftarrow","\\underrightarrow","\\underleftrightarrow","\\undergroup","\\underlinesegment","\\utilde"],numArgs:1,handler:(e,t)=>{var r=e.parser,a=e.funcName,n=t[0];return{type:"accentUnder",mode:r.mode,label:a,base:n}},htmlBuilder:(e,t)=>{var r=or(e.base,t),a=Nr(e,t),n="\\utilde"===e.label?.12:0,i=Ot({positionType:"top",positionData:r.height,children:[{type:"elem",elem:a,wrapperClasses:["svg-align"]},{type:"kern",size:n},{type:"elem",elem:r}]});return Mt(["mord","accentunder"],[i],t)},mathmlBuilder:(e,t)=>{var r=Rr(e.label),a=new mr("munder",[kr(e.base,t),r]);return a.setAttribute("accentunder","true"),a}});var Yr=e=>{var t=new mr("mpadded",e?[e]:[]);return t.setAttribute("width","+0.6em"),t.setAttribute("lspace","0.3em"),t};Xt({type:"xArrow",names:["\\xleftarrow","\\xrightarrow","\\xLeftarrow","\\xRightarrow","\\xleftrightarrow","\\xLeftrightarrow","\\xhookleftarrow","\\xhookrightarrow","\\xmapsto","\\xrightharpoondown","\\xrightharpoonup","\\xleftharpoondown","\\xleftharpoonup","\\xrightleftharpoons","\\xleftrightharpoons","\\xlongequal","\\xtwoheadrightarrow","\\xtwoheadleftarrow","\\xtofrom","\\xrightleftarrows","\\xrightequilibrium","\\xleftequilibrium","\\\\cdrightarrow","\\\\cdleftarrow","\\\\cdlongequal"],numArgs:1,numOptionalArgs:1,handler(e,t,r){var a=e.parser,n=e.funcName;return{type:"xArrow",mode:a.mode,label:n,body:t[0],below:r[0]}},htmlBuilder(e,t){var r,a=t.style,n=t.havingStyle(a.sup()),i=qt(or(e.body,n,t),t),o="\\x"===e.label.slice(0,2)?"x":"cd";i.classes.push(o+"-arrow-pad"),e.below&&(n=t.havingStyle(a.sub()),(r=qt(or(e.below,n,t),t)).classes.push(o+"-arrow-pad"));var s,l=Nr(e,t),h=-t.fontMetrics().axisHeight+.5*l.height,m=-t.fontMetrics().axisHeight-.5*l.height-.111;if((i.depth>.25||"\\xleftequilibrium"===e.label)&&(m-=i.depth),r){var c=-t.fontMetrics().axisHeight+r.height+.5*l.height+.111;s=Ot({positionType:"individualShift",children:[{type:"elem",elem:i,shift:m},{type:"elem",elem:l,shift:h,wrapperClasses:["svg-align"]},{type:"elem",elem:r,shift:c}]})}else s=Ot({positionType:"individualShift",children:[{type:"elem",elem:i,shift:m},{type:"elem",elem:l,shift:h,wrapperClasses:["svg-align"]}]});return Mt(["mrel","x-arrow"],[s],t)},mathmlBuilder(e,t){var r,a=Rr(e.label);if(a.setAttribute("minsize","x"===e.label.charAt(0)?"1.75em":"3.0em"),e.body){var n=Yr(kr(e.body,t));if(e.below){var i=Yr(kr(e.below,t));r=new mr("munderover",[a,i,n])}else r=new mr("mover",[a,n])}else if(e.below){var o=Yr(kr(e.below,t));r=new mr("munder",[a,o])}else r=Yr(),r=new mr("mover",[a,r]);return r}}),Xt({type:"mclass",names:["\\mathord","\\mathbin","\\mathrel","\\mathopen","\\mathclose","\\mathpunct","\\mathinner"],numArgs:1,primitive:!0,handler(e,t){var r=e.parser,a=e.funcName,n=t[0];return{type:"mclass",mode:r.mode,mclass:"m"+a.slice(5),body:$t(n),isCharacterBox:g(n)}},htmlBuilder:function(e,t){var r=er(e.body,t,!0);return Mt([e.mclass],r,t)},mathmlBuilder:function(e,t){var r,a=xr(e.body,t);return"minner"===e.mclass?r=new mr("mpadded",a):"mord"===e.mclass?e.isCharacterBox?(r=a[0]).type="mi":r=new mr("mi",a):(e.isCharacterBox?(r=a[0]).type="mo":r=new mr("mo",a),"mbin"===e.mclass?(r.attributes.lspace="0.22em",r.attributes.rspace="0.22em"):"mpunct"===e.mclass?(r.attributes.lspace="0em",r.attributes.rspace="0.17em"):"mopen"!==e.mclass&&"mclose"!==e.mclass||(r.attributes.lspace="0em",r.attributes.rspace="0em")),r}});var Wr=e=>{var t="ordgroup"===e.type&&e.body.length?e.body[0]:e;return"atom"!==t.type||"bin"!==t.family&&"rel"!==t.family?"mord":"m"+t.family};Xt({type:"mclass",names:["\\@binrel"],numArgs:2,handler:(e,t)=>({type:"mclass",mode:e.parser.mode,mclass:Wr(t[0]),body:$t(t[1]),isCharacterBox:g(t[1])})}),Xt({type:"mclass",names:["\\stackrel","\\overset","\\underset"],numArgs:2,handler(e,t){var r,a=e.parser,n=e.funcName,i=t[1],o=t[0];r="\\stackrel"!==n?Wr(i):"mrel";var s={type:"op",mode:i.mode,limits:!0,alwaysHandleSupSub:!0,parentIsSupSub:!1,symbol:!1,suppressBaseShift:"\\stackrel"!==n,body:$t(i)},l="\\underset"===n?{type:"supsub",mode:o.mode,base:s,sub:o}:{type:"supsub",mode:o.mode,base:s,sup:o};return{type:"mclass",mode:a.mode,mclass:r,body:[l],isCharacterBox:g(l)}}}),Xt({type:"pmb",names:["\\pmb"],numArgs:1,allowedInText:!0,handler:(e,t)=>({type:"pmb",mode:e.parser.mode,mclass:Wr(t[0]),body:$t(t[0])}),htmlBuilder(e,t){var r=er(e.body,t,!0),a=Mt([e.mclass],r,t);return a.style.textShadow="0.02em 0.01em 0.04px",a},mathmlBuilder(e,t){var r=xr(e.body,t),a=new mr("mstyle",r);return a.setAttribute("style","text-shadow: 0.02em 0.01em 0.04px"),a}});var $r={">":"\\\\cdrightarrow","<":"\\\\cdleftarrow","=":"\\\\cdlongequal",A:"\\uparrow",V:"\\downarrow","|":"\\Vert",".":"no arrow"},Zr=()=>({type:"styling",body:[],mode:"math",style:"display",resetFont:!0}),Kr=e=>"textord"===e.type&&"@"===e.text,Jr=(e,t)=>("mathord"===e.type||"atom"===e.type)&&e.text===t;function Qr(e,t,r){var a=$r[e];switch(a){case"\\\\cdrightarrow":case"\\\\cdleftarrow":return r.callFunction(a,[t[0]],[t[1]]);case"\\uparrow":case"\\downarrow":var n={type:"atom",text:a,mode:"math",family:"rel"},i={type:"ordgroup",mode:"math",body:[r.callFunction("\\\\cdleft",[t[0]],[]),r.callFunction("\\Big",[n],[]),r.callFunction("\\\\cdright",[t[1]],[])]};return r.callFunction("\\\\cdparent",[i],[]);case"\\\\cdlongequal":return r.callFunction("\\\\cdlongequal",[],[]);case"\\Vert":return r.callFunction("\\Big",[{type:"textord",text:"\\Vert",mode:"math"}],[]);default:return{type:"textord",text:" ",mode:"math"}}}function ea(e){var t=[];for(e.gullet.beginGroup(),e.gullet.macros.set("\\cr","\\\\\\relax"),e.gullet.beginGroup();;){t.push(e.parseExpression(!1,"\\\\")),e.gullet.endGroup(),e.gullet.beginGroup();var r=e.fetch().text;if("&"!==r&&"\\\\"!==r){if("\\end"===r){0===t[t.length-1].length&&t.pop();break}throw new s("Expected \\\\ or \\cr or \\end",e.nextToken)}e.consume()}for(var a=[],n=[a],i=0;i<t.length;i++){for(var o=t[i],l=Zr(),h=0;h<o.length;h++)if(Kr(o[h])){a.push(l);var m=Vr(o[h+=1]).text,c=new Array(2);if(c[0]={type:"ordgroup",mode:"math",body:[]},c[1]={type:"ordgroup",mode:"math",body:[]},"=|.".includes(m));else{if(!"<>AV".includes(m))throw new s("Expected one of \"<>AV=|.\" after @",o[h]);for(var u=0;u<2;u++){for(var p=!0,d=h+1;d<o.length;d++){if(Jr(o[d],m)){p=!1,h=d;break}if(Kr(o[d]))throw new s("Missing a "+m+" character to complete a CD arrow.",o[d]);c[u].body.push(o[d])}if(p)throw new s("Missing a "+m+" character to complete a CD arrow.",o[h])}}var g={type:"styling",body:[Qr(m,c,e)],mode:"math",style:"display",resetFont:!0};a.push(g),l=Zr()}else l.body.push(o[h]);i%2==0?a.push(l):a.shift(),a=[],n.push(a)}return e.gullet.endGroup(),e.gullet.endGroup(),{type:"array",mode:"math",body:n,arraystretch:1,addJot:!0,rowGaps:[null],cols:new Array(n[0].length).fill({type:"align",align:"c",pregap:.25,postgap:.25}),colSeparationType:"CD",hLinesBeforeRow:new Array(n.length+1).fill([])}}Xt({type:"cdlabel",names:["\\\\cdleft","\\\\cdright"],numArgs:1,handler(e,t){var r=e.parser,a=e.funcName;return{type:"cdlabel",mode:r.mode,side:a.slice(4),label:t[0]}},htmlBuilder(e,t){var r=t.havingStyle(t.style.sup()),a=qt(or(e.label,r,t),t);return a.classes.push("cd-label-"+e.side),a.style.bottom=J(.8-a.depth),a.height=0,a.depth=0,a},mathmlBuilder(e,t){var r=new mr("mrow",[kr(e.label,t)]);return(r=new mr("mpadded",[r])).setAttribute("width","0"),"left"===e.side&&r.setAttribute("lspace","-1width"),r.setAttribute("voffset","0.7em"),(r=new mr("mstyle",[r])).setAttribute("displaystyle","false"),r.setAttribute("scriptlevel","1"),r}}),Xt({type:"cdlabelparent",names:["\\\\cdparent"],numArgs:1,handler:(e,t)=>({type:"cdlabelparent",mode:e.parser.mode,fragment:t[0]}),htmlBuilder(e,t){var r=qt(or(e.fragment,t),t);return r.classes.push("cd-vert-arrow"),r},mathmlBuilder:(e,t)=>new mr("mrow",[kr(e.fragment,t)])}),Xt({type:"textord",names:["\\@char"],numArgs:1,allowedInText:!0,handler(e,t){var r,a=e.parser,n=jr(Fr(t[0],"ordgroup"),"\\@char has non-numeric argument"),i=parseInt(n);if(isNaN(i))throw new s("\\@char has non-numeric argument "+n);if(i<0||i>1114111)throw new s("\\@char with invalid code point "+n);return i<=65535?r=String.fromCharCode(i):(i-=65536,r=String.fromCharCode(55296+(i>>10),56320+(1023&i))),{type:"textord",mode:a.mode,text:r}}});Xt({type:"color",names:["\\textcolor"],numArgs:2,allowedInText:!0,argTypes:["color","original"],handler(e,t){var r=e.parser,a=Fr(t[0],"color-token").color,n=t[1];return{type:"color",mode:r.mode,color:a,body:$t(n)}},htmlBuilder:(e,t)=>{var r=er(e.body,t.withColor(e.color),!1);return Bt(r)},mathmlBuilder:(e,t)=>{var r=xr(e.body,t.withColor(e.color)),a=new mr("mstyle",r);return a.setAttribute("mathcolor",e.color),a}}),Xt({type:"color",names:["\\color"],numArgs:1,allowedInText:!0,argTypes:["color"],handler(e,t){var r=e.parser,a=e.breakOnTokenText,n=Fr(t[0],"color-token").color;r.gullet.macros.set("\\current@color",n);var i=r.parseExpression(!0,a);return{type:"color",mode:r.mode,color:n,body:i}}}),Xt({type:"cr",names:["\\\\"],numArgs:0,numOptionalArgs:0,allowedInText:!0,handler(e,t,r){var a=e.parser,n="["===a.gullet.future().text?a.parseSizeGroup(!0):null,i=!a.settings.displayMode||!a.settings.useStrictBehavior("newLineInDisplayMode","In LaTeX, \\\\ or \\newline does nothing in display mode");return{type:"cr",mode:a.mode,newLine:i,size:n&&Fr(n,"size").value}},htmlBuilder(e,t){var r=Mt(["mspace"],[],t);return e.newLine&&(r.classes.push("katex-newline"),e.size&&(r.style.marginTop=J(K(e.size,t)))),r},mathmlBuilder(e,t){var r=new mr("mspace");return e.newLine&&(r.setAttribute("linebreak","newline"),e.size&&r.setAttribute("height",J(K(e.size,t)))),r}});var ta={"\\global":"\\global","\\long":"\\\\globallong","\\\\globallong":"\\\\globallong","\\def":"\\gdef","\\gdef":"\\gdef","\\edef":"\\xdef","\\xdef":"\\xdef","\\let":"\\\\globallet","\\futurelet":"\\\\globalfuture"},ra=e=>{var t=e.text;if(/^(?:[\\{}$&#^_]|EOF)$/.test(t))throw new s("Expected a control sequence",e);return t},aa=e=>{var t=e.gullet.popToken();return"="===t.text&&" "===(t=e.gullet.popToken()).text&&(t=e.gullet.popToken()),t},na=(e,t,r,a)=>{var n=e.gullet.macros.get(r.text);null==n&&(r.noexpand=!0,n={tokens:[r],numArgs:0,unexpandable:!e.gullet.isExpandable(r.text)}),e.gullet.macros.set(t,n,a)};Xt({type:"internal",names:["\\global","\\long","\\\\globallong"],numArgs:0,allowedInText:!0,handler(e){var t=e.parser,r=e.funcName;t.consumeSpaces();var a=t.fetch();if(ta[a.text])return"\\global"!==r&&"\\\\globallong"!==r||(a.text=ta[a.text]),Fr(t.parseFunction(),"internal");throw new s("Invalid token after macro prefix",a)}}),Xt({type:"internal",names:["\\def","\\gdef","\\edef","\\xdef"],numArgs:0,allowedInText:!0,primitive:!0,handler(e){var t=e.parser,r=e.funcName,a=t.gullet.popToken(),n=a.text;if(/^(?:[\\{}$&#^_]|EOF)$/.test(n))throw new s("Expected a control sequence",a);for(var i,o=0,l=[[]];"{"!==t.gullet.future().text;)if("#"===(a=t.gullet.popToken()).text){if("{"===t.gullet.future().text){i=t.gullet.future(),l[o].push("{");break}if(a=t.gullet.popToken(),!/^[1-9]$/.test(a.text))throw new s("Invalid argument number \""+a.text+"\"");if(parseInt(a.text)!==o+1)throw new s("Argument number \""+a.text+"\" out of order");o++,l.push([])}else{if("EOF"===a.text)throw new s("Expected a macro definition");l[o].push(a.text)}var h=t.gullet.consumeArg().tokens;return i&&h.unshift(i),"\\edef"!==r&&"\\xdef"!==r||(h=t.gullet.expandTokens(h)).reverse(),t.gullet.macros.set(n,{tokens:h,numArgs:o,delimiters:l},r===ta[r]),{type:"internal",mode:t.mode}}}),Xt({type:"internal",names:["\\let","\\\\globallet"],numArgs:0,allowedInText:!0,primitive:!0,handler(e){var t=e.parser,r=e.funcName,a=ra(t.gullet.popToken());t.gullet.consumeSpaces();var n=aa(t);return na(t,a,n,"\\\\globallet"===r),{type:"internal",mode:t.mode}}}),Xt({type:"internal",names:["\\futurelet","\\\\globalfuture"],numArgs:0,allowedInText:!0,primitive:!0,handler(e){var t=e.parser,r=e.funcName,a=ra(t.gullet.popToken()),n=t.gullet.popToken(),i=t.gullet.popToken();return na(t,a,i,"\\\\globalfuture"===r),t.gullet.pushToken(i),t.gullet.pushToken(n),{type:"internal",mode:t.mode}}});var ia=function(e,t,r){var a=ye(ke.math[e]&&ke.math[e].replace||e,t,r);if(!a)throw new Error("Unsupported symbol "+e+" and font size "+t+".");return a},oa=function(e,t,r,a){var n=r.havingBaseStyle(t),i=Mt(a.concat(n.sizingClasses(r)),[e],r),o=n.sizeMultiplier/r.sizeMultiplier;return i.height*=o,i.depth*=o,i.maxFontSize=n.sizeMultiplier,i},sa=function(e,t,r){var a=t.havingBaseStyle(r),n=(1-t.sizeMultiplier/a.sizeMultiplier)*t.fontMetrics().axisHeight;e.classes.push("delimcenter"),e.style.top=J(n),e.height-=n,e.depth+=n},la=function(e,t,r,a,n,i){var o=bt(e,"Main-Regular",n,a),s=oa(o,t,a,i);return r&&sa(s,a,t),s},ha=function(e,t,r,a){return bt(e,"Size"+t+"-Regular",r,a)},ma=function(e,t,r,a,n,i){var o=ha(e,t,n,a),s=oa(Mt(["delimsizing","size"+t],[o],a),q.TEXT,a,i);return r&&sa(s,a,q.TEXT),s},ca=function(e,t,r){return{type:"elem",elem:Mt(["delimsizinginner","Size1-Regular"===t?"delim-size1":"delim-size4"],[Mt([],[bt(e,t,r)])])}},ua=function(e,t,r){var a=ge['Size4-Regular'][e.charCodeAt(0)]?ge['Size4-Regular'][e.charCodeAt(0)][4]:ge['Size1-Regular'][e.charCodeAt(0)][4],n=new ce("inner",U(e,Math.round(1e3*t))),i=new me([n],{width:J(a),height:J(t),style:"width:"+J(a),viewBox:"0 0 "+1e3*a+" "+Math.round(1e3*t),preserveAspectRatio:"xMinYMin"}),o=At([],[i],r);return o.height=t,o.style.height=J(t),o.style.width=J(a),{type:"elem",elem:o}},pa={type:"kern",size:-.008},da=new Set(["|","\\lvert","\\rvert","\\vert"]),ga=new Set(["\\|","\\lVert","\\rVert","\\Vert"]),fa=function(e,t,r,a,n,i){var o,s,l,h,m="",c=0;o=l=h=e,s=null;var u="Size1-Regular";"\\uparrow"===e?l=h="\u23d0":"\\Uparrow"===e?l=h="\u2016":"\\downarrow"===e?o=l="\u23d0":"\\Downarrow"===e?o=l="\u2016":"\\updownarrow"===e?(o="\\uparrow",l="\u23d0",h="\\downarrow"):"\\Updownarrow"===e?(o="\\Uparrow",l="\u2016",h="\\Downarrow"):da.has(e)?(l="\u2223",m="vert",c=333):ga.has(e)?(l="\u2225",m="doublevert",c=556):"["===e||"\\lbrack"===e?(o="\u23a1",l="\u23a2",h="\u23a3",u="Size4-Regular",m="lbrack",c=667):"]"===e||"\\rbrack"===e?(o="\u23a4",l="\u23a5",h="\u23a6",u="Size4-Regular",m="rbrack",c=667):"\\lfloor"===e||"\u230a"===e?(l=o="\u23a2",h="\u23a3",u="Size4-Regular",m="lfloor",c=667):"\\lceil"===e||"\u2308"===e?(o="\u23a1",l=h="\u23a2",u="Size4-Regular",m="lceil",c=667):"\\rfloor"===e||"\u230b"===e?(l=o="\u23a5",h="\u23a6",u="Size4-Regular",m="rfloor",c=667):"\\rceil"===e||"\u2309"===e?(o="\u23a4",l=h="\u23a5",u="Size4-Regular",m="rceil",c=667):"("===e||"\\lparen"===e?(o="\u239b",l="\u239c",h="\u239d",u="Size4-Regular",m="lparen",c=875):")"===e||"\\rparen"===e?(o="\u239e",l="\u239f",h="\u23a0",u="Size4-Regular",m="rparen",c=875):"\\{"===e||"\\lbrace"===e?(o="\u23a7",s="\u23a8",h="\u23a9",l="\u23aa",u="Size4-Regular"):"\\}"===e||"\\rbrace"===e?(o="\u23ab",s="\u23ac",h="\u23ad",l="\u23aa",u="Size4-Regular"):"\\lgroup"===e||"\u27ee"===e?(o="\u23a7",h="\u23a9",l="\u23aa",u="Size4-Regular"):"\\rgroup"===e||"\u27ef"===e?(o="\u23ab",h="\u23ad",l="\u23aa",u="Size4-Regular"):"\\lmoustache"===e||"\u23b0"===e?(o="\u23a7",h="\u23ad",l="\u23aa",u="Size4-Regular"):"\\rmoustache"!==e&&"\u23b1"!==e||(o="\u23ab",h="\u23a9",l="\u23aa",u="Size4-Regular");var p=ia(o,u,n),d=p.height+p.depth,g=ia(l,u,n),f=g.height+g.depth,v=ia(h,u,n),b=v.height+v.depth,y=0,x=1;if(null!==s){var w=ia(s,u,n);y=w.height+w.depth,x=2}var k=d+b+y,S=k+Math.max(0,Math.ceil((t-k)/(x*f)))*x*f,z=a.fontMetrics().axisHeight;r&&(z*=a.sizeMultiplier);var M=S/2-z,A=[];if(m.length>0){var T=S-d-b,C=Math.round(1e3*S),B=X(m,Math.round(1e3*T)),I=new ce(m,B),O=J(c/1e3),R=J(C/1e3),E=new me([I],{width:O,height:R,viewBox:"0 0 "+c+" "+C}),H=At([],[E],a);H.height=C/1e3,H.style.width=O,H.style.height=R,A.push({type:"elem",elem:H})}else{if(A.push(ca(h,u,n)),A.push(pa),null===s){var N=S-d-b+.016;A.push(ua(l,N,a))}else{var D=(S-d-b-y)/2+.016;A.push(ua(l,D,a)),A.push(pa),A.push(ca(s,u,n)),A.push(pa),A.push(ua(l,D,a))}A.push(pa),A.push(ca(o,u,n))}var L=a.havingBaseStyle(q.TEXT),P=Ot({positionType:"bottom",positionData:M,children:A});return oa(Mt(["delimsizing","mult"],[P],L),q.TEXT,a,i)},va=.08,ba=function(e,t,r,a,n){var i=j(e,a,r),o=new ce(e,i),s=new me([o],{width:"400em",height:J(t),viewBox:"0 0 400000 "+r,preserveAspectRatio:"xMinYMin slice"});return At(["hide-tail"],[s],n)},ya=function(e,t){var r,a,n,i,o,s=t.havingBaseSizing(),l=Ba("\\surd",e*s.sizeMultiplier,Ta,s),h=s.sizeMultiplier,m=Math.max(0,t.minRuleThickness-t.fontMetrics().sqrtRuleThickness);return"small"===l.type?(e<1?h=1:e<1.4&&(h=.7),n=(1+m)/h,(r=ba("sqrtMain",a=(1+m+va)/h,i=1e3+1e3*m+80,m,t)).style.minWidth="0.853em",o=.833/h):"large"===l.type?(i=1080*Sa[l.size],n=(Sa[l.size]+m)/h,a=(Sa[l.size]+m+va)/h,(r=ba("sqrtSize"+l.size,a,i,m,t)).style.minWidth="1.02em",o=1/h):(a=e+m+va,n=e+m,i=Math.floor(1e3*e+m)+80,(r=ba("sqrtTall",a,i,m,t)).style.minWidth="0.742em",o=1.056),r.height=n,r.style.height=J(a),{span:r,advanceWidth:o,ruleWidth:(t.fontMetrics().sqrtRuleThickness+m)*h}},xa=new Set(["(","\\lparen",")","\\rparen","[","\\lbrack","]","\\rbrack","\\{","\\lbrace","\\}","\\rbrace","\\lfloor","\\rfloor","\u230a","\u230b","\\lceil","\\rceil","\u2308","\u2309","\\surd"]),wa=new Set(["\\uparrow","\\downarrow","\\updownarrow","\\Uparrow","\\Downarrow","\\Updownarrow","|","\\|","\\vert","\\Vert","\\lvert","\\rvert","\\lVert","\\rVert","\\lgroup","\\rgroup","\u27ee","\u27ef","\\lmoustache","\\rmoustache","\u23b0","\u23b1"]),ka=new Set(["<",">","\\langle","\\rangle","/","\\backslash","\\lt","\\gt"]),Sa=[0,1.2,1.8,2.4,3],za=function(e,t,r,a,n){if("<"===e||"\\lt"===e||"\u27e8"===e?e="\\langle":">"!==e&&"\\gt"!==e&&"\u27e9"!==e||(e="\\rangle"),xa.has(e)||ka.has(e))return ma(e,t,!1,r,a,n);if(wa.has(e))return fa(e,Sa[t],!1,r,a,n);throw new s("Illegal delimiter: '"+e+"'")},Ma=[{type:"small",style:q.SCRIPTSCRIPT},{type:"small",style:q.SCRIPT},{type:"small",style:q.TEXT},{type:"large",size:1},{type:"large",size:2},{type:"large",size:3},{type:"large",size:4}],Aa=[{type:"small",style:q.SCRIPTSCRIPT},{type:"small",style:q.SCRIPT},{type:"small",style:q.TEXT},{type:"stack"}],Ta=[{type:"small",style:q.SCRIPTSCRIPT},{type:"small",style:q.SCRIPT},{type:"small",style:q.TEXT},{type:"large",size:1},{type:"large",size:2},{type:"large",size:3},{type:"large",size:4},{type:"stack"}],Ca=function(e){if("small"===e.type)return"Main-Regular";if("large"===e.type)return"Size"+e.size+"-Regular";if("stack"===e.type)return"Size4-Regular";var t=e.type;throw new Error("Add support for delim type '"+t+"' here.")},Ba=function(e,t,r,a){for(var n=Math.min(2,3-a.style.size);n<r.length;n++){var i=r[n];if("stack"===i.type)break;var o=ia(e,Ca(i),"math"),s=o.height+o.depth;if("small"===i.type)s*=a.havingBaseStyle(i.style).sizeMultiplier;if(s>t)return i}return r[r.length-1]},qa=function(e,t,r,a,n,i){var o;"<"===e||"\\lt"===e||"\u27e8"===e?e="\\langle":">"!==e&&"\\gt"!==e&&"\u27e9"!==e||(e="\\rangle"),o=ka.has(e)?Ma:xa.has(e)?Ta:Aa;var s=Ba(e,t,o,a);return"small"===s.type?la(e,s.style,r,a,n,i):"large"===s.type?ma(e,s.size,r,a,n,i):fa(e,t,r,a,n,i)},Ia=function(e,t,r,a,n,i){var o=a.fontMetrics().axisHeight*a.sizeMultiplier,s=5/a.fontMetrics().ptPerEm,l=Math.max(t-o,r+o),h=Math.max(l/500*901,2*l-s);return qa(e,h,!0,a,n,i)},Oa={"\\bigl":{mclass:"mopen",size:1},"\\Bigl":{mclass:"mopen",size:2},"\\biggl":{mclass:"mopen",size:3},"\\Biggl":{mclass:"mopen",size:4},"\\bigr":{mclass:"mclose",size:1},"\\Bigr":{mclass:"mclose",size:2},"\\biggr":{mclass:"mclose",size:3},"\\Biggr":{mclass:"mclose",size:4},"\\bigm":{mclass:"mrel",size:1},"\\Bigm":{mclass:"mrel",size:2},"\\biggm":{mclass:"mrel",size:3},"\\Biggm":{mclass:"mrel",size:4},"\\big":{mclass:"mord",size:1},"\\Big":{mclass:"mord",size:2},"\\bigg":{mclass:"mord",size:3},"\\Bigg":{mclass:"mord",size:4}},Ra=new Set(["(","\\lparen",")","\\rparen","[","\\lbrack","]","\\rbrack","\\{","\\lbrace","\\}","\\rbrace","\\lfloor","\\rfloor","\u230a","\u230b","\\lceil","\\rceil","\u2308","\u2309","<",">","\\langle","\u27e8","\\rangle","\u27e9","\\lt","\\gt","\\lvert","\\rvert","\\lVert","\\rVert","\\lgroup","\\rgroup","\u27ee","\u27ef","\\lmoustache","\\rmoustache","\u23b0","\u23b1","/","\\backslash","|","\\vert","\\|","\\Vert","\\uparrow","\\Uparrow","\\downarrow","\\Downarrow","\\updownarrow","\\Updownarrow","."]);function Ea(e){return'isMiddle'in e}function Ha(e,t){var r=Gr(e);if(r&&Ra.has(r.text))return r;throw new s(r?"Invalid delimiter '"+r.text+"' after '"+t.funcName+"'":"Invalid delimiter type '"+e.type+"'",e)}function Na(e){if(!e.body)throw new Error("Bug: The leftright ParseNode wasn't fully parsed.")}Xt({type:"delimsizing",names:["\\bigl","\\Bigl","\\biggl","\\Biggl","\\bigr","\\Bigr","\\biggr","\\Biggr","\\bigm","\\Bigm","\\biggm","\\Biggm","\\big","\\Big","\\bigg","\\Bigg"],numArgs:1,argTypes:["primitive"],handler:(e,t)=>{var r=Ha(Wt(t[0]),e);return{type:"delimsizing",mode:e.parser.mode,size:Oa[e.funcName].size,mclass:Oa[e.funcName].mclass,delim:r.text}},htmlBuilder:(e,t)=>"."===e.delim?Mt([e.mclass]):za(e.delim,e.size,t,e.mode,[e.mclass]),mathmlBuilder:e=>{var t=[];"."!==e.delim&&t.push(gr(e.delim,e.mode));var r=new mr("mo",t);"mopen"===e.mclass||"mclose"===e.mclass?r.setAttribute("fence","true"):r.setAttribute("fence","false"),r.setAttribute("stretchy","true");var a=J(Sa[e.size]);return r.setAttribute("minsize",a),r.setAttribute("maxsize",a),r}}),Xt({type:"leftright-right",names:["\\right"],numArgs:1,primitive:!0,handler:(e,t)=>{var r=e.parser.gullet.macros.get("\\current@color");if(r&&"string"!=typeof r)throw new s("\\current@color set to non-string in \\right");return{type:"leftright-right",mode:e.parser.mode,delim:Ha(t[0],e).text,color:r}}}),Xt({type:"leftright",names:["\\left"],numArgs:1,primitive:!0,handler:(e,t)=>{var r=Ha(t[0],e),a=e.parser;++a.leftrightDepth;var n=a.parseExpression(!1);--a.leftrightDepth,a.expect("\\right",!1);var i=Fr(a.parseFunction(),"leftright-right");return{type:"leftright",mode:a.mode,body:n,left:r.text,right:i.delim,rightColor:i.color}},htmlBuilder:(e,t)=>{Na(e);for(var r,a,n=er(e.body,t,!0,["mopen","mclose"]),i=0,o=0,s=!1,l=0;l<n.length;l++){Ea(n[l])?s=!0:(i=Math.max(n[l].height,i),o=Math.max(n[l].depth,o))}if(i*=t.sizeMultiplier,o*=t.sizeMultiplier,r="."===e.left?ir(t,["mopen"]):Ia(e.left,i,o,t,e.mode,["mopen"]),n.unshift(r),s)for(var h=1;h<n.length;h++){var m=n[h];if(Ea(m)){var c=m.isMiddle;n[h]=Ia(c.delim,i,o,c.options,e.mode,[])}}if("."===e.right)a=ir(t,["mclose"]);else{var u=e.rightColor?t.withColor(e.rightColor):t;a=Ia(e.right,i,o,u,e.mode,["mclose"])}return n.push(a),Mt(["minner"],n,t)},mathmlBuilder:(e,t)=>{Na(e);var r=xr(e.body,t);if("."!==e.left){var a=new mr("mo",[gr(e.left,e.mode)]);a.setAttribute("fence","true"),r.unshift(a)}if("."!==e.right){var n=new mr("mo",[gr(e.right,e.mode)]);n.setAttribute("fence","true"),e.rightColor&&n.setAttribute("mathcolor",e.rightColor),r.push(n)}return fr(r)}}),Xt({type:"middle",names:["\\middle"],numArgs:1,primitive:!0,handler:(e,t)=>{var r=Ha(t[0],e);if(!e.parser.leftrightDepth)throw new s("\\middle without preceding \\left",r);return{type:"middle",mode:e.parser.mode,delim:r.text}},htmlBuilder:(e,t)=>{var r;return"."===e.delim?r=ir(t,[]):(r=za(e.delim,1,t,e.mode,[])).isMiddle={delim:e.delim,options:t},r},mathmlBuilder:(e,t)=>{var r="\\vert"===e.delim||"|"===e.delim?gr("|","text"):gr(e.delim,e.mode),a=new mr("mo",[r]);return a.setAttribute("fence","true"),a.setAttribute("lspace","0.05em"),a.setAttribute("rspace","0.05em"),a}});Xt({type:"enclose",names:["\\colorbox"],numArgs:2,allowedInText:!0,argTypes:["color","hbox"],handler(e,t,r){var a=e.parser,n=e.funcName,i=Fr(t[0],"color-token").color,o=t[1];return{type:"enclose",mode:a.mode,label:n,backgroundColor:i,body:o}},htmlBuilder:(e,t)=>{var r,a,n,i,o=qt(or(e.body,t),t),s=e.label.slice(1),l=t.sizeMultiplier,h=g(e.body);if("sout"===s)(r=Mt(["katex-stretchy","katex-sout"])).height=t.fontMetrics().defaultRuleThickness/l,a=-.5*t.fontMetrics().xHeight;else if("phase"===s){var m=K({number:.6,unit:"pt"},t),c=K({number:.35,unit:"ex"},t);l/=t.havingBaseSizing().sizeMultiplier;var u=o.height+o.depth+m+c;o.style.paddingLeft=J(u/2+m);var p=Math.floor(1e3*u*l),d="M400000 "+(n=p)+" H0 L"+n/2+" 0 l65 45 L145 "+(n-80)+" H400000z",f=new me([new ce("phase",d)],{width:"400em",height:J(p/1e3),viewBox:"0 0 400000 "+p,preserveAspectRatio:"xMinYMin slice"});(r=At(["hide-tail"],[f],t)).style.height=J(u),a=o.depth+m+c}else{var v,b;/cancel/.test(s)?h||o.classes.push("cancel-pad"):"angl"===s?o.classes.push("anglpad"):o.classes.push("boxpad");var y=0;/box/.test(s)?(y=Math.max(t.fontMetrics().fboxrule,t.minRuleThickness),b=v=t.fontMetrics().fboxsep+("colorbox"===s?0:y)):"angl"===s?(v=4*(y=Math.max(t.fontMetrics().defaultRuleThickness,t.minRuleThickness)),b=Math.max(0,.25-o.depth)):b=v=h?.2:0,r=Dr(o,s,v,b,t),/fbox|boxed|fcolorbox/.test(s)?(r.style.borderStyle="solid",r.style.borderWidth=J(y)):"angl"===s&&.049!==y&&(r.style.borderTopWidth=J(y),r.style.borderRightWidth=J(y)),a=o.depth+b,e.backgroundColor&&(r.style.backgroundColor=e.backgroundColor,e.borderColor&&(r.style.borderColor=e.borderColor))}if(e.backgroundColor)i=Ot({positionType:"individualShift",children:[{type:"elem",elem:r,shift:a},{type:"elem",elem:o,shift:0}]});else{var x=/cancel|phase/.test(s)?["svg-align"]:[];i=Ot({positionType:"individualShift",children:[{type:"elem",elem:o,shift:0},{type:"elem",elem:r,shift:a,wrapperClasses:x}]})}return/cancel/.test(s)&&(i.height=o.height,i.depth=o.depth),/cancel/.test(s)&&!h?Mt(["mord","cancel-lap"],[i],t):Mt(["mord"],[i],t)},mathmlBuilder:(e,t)=>{var r,a=new mr(e.label.includes("colorbox")?"mpadded":"menclose",[kr(e.body,t)]);switch(e.label){case"\\cancel":a.setAttribute("notation","updiagonalstrike");break;case"\\bcancel":a.setAttribute("notation","downdiagonalstrike");break;case"\\phase":a.setAttribute("notation","phasorangle");break;case"\\sout":a.setAttribute("notation","horizontalstrike");break;case"\\fbox":a.setAttribute("notation","box");break;case"\\angl":a.setAttribute("notation","actuarial");break;case"\\fcolorbox":case"\\colorbox":if(r=t.fontMetrics().fboxsep*t.fontMetrics().ptPerEm,a.setAttribute("width","+"+2*r+"pt"),a.setAttribute("height","+"+2*r+"pt"),a.setAttribute("lspace",r+"pt"),a.setAttribute("voffset",r+"pt"),"\\fcolorbox"===e.label){var n=Math.max(t.fontMetrics().fboxrule,t.minRuleThickness);a.setAttribute("style","border: "+J(n)+" solid "+e.borderColor)}break;case"\\xcancel":a.setAttribute("notation","updiagonalstrike downdiagonalstrike")}return e.backgroundColor&&a.setAttribute("mathbackground",e.backgroundColor),a}}),Xt({type:"enclose",names:["\\fcolorbox"],numArgs:3,allowedInText:!0,argTypes:["color","color","hbox"],handler(e,t,r){var a=e.parser,n=e.funcName,i=Fr(t[0],"color-token").color,o=Fr(t[1],"color-token").color,s=t[2];return{type:"enclose",mode:a.mode,label:n,backgroundColor:o,borderColor:i,body:s}}}),Xt({type:"enclose",names:["\\fbox"],numArgs:1,argTypes:["hbox"],allowedInText:!0,handler:(e,t)=>({type:"enclose",mode:e.parser.mode,label:"\\fbox",body:t[0]})}),Xt({type:"enclose",names:["\\cancel","\\bcancel","\\xcancel","\\phase"],numArgs:1,handler(e,t){var r=e.parser,a=e.funcName,n=t[0];return{type:"enclose",mode:r.mode,label:a,body:n}}}),Xt({type:"enclose",names:["\\sout"],numArgs:1,allowedInText:!0,handler(e,t){var r=e.parser,a=e.funcName;"math"===r.mode&&r.settings.reportNonstrict("mathVsSout","LaTeX's \\sout works only in text mode");var n=t[0];return{type:"enclose",mode:r.mode,label:a,body:n}}}),Xt({type:"enclose",names:["\\angl"],numArgs:1,argTypes:["hbox"],allowedInText:!1,handler:(e,t)=>({type:"enclose",mode:e.parser.mode,label:"\\angl",body:t[0]})});var Da={};function La(e){for(var t=e.type,r=e.names,a=e.props,n=e.handler,i=e.htmlBuilder,o=e.mathmlBuilder,s={type:t,numArgs:a.numArgs||0,allowedInText:!1,numOptionalArgs:0,handler:n},l=0;l<r.length;++l)Da[r[l]]=s;i&&(Ut[t]=i),o&&(_t[t]=o)}var Pa={};function Fa(e,t){Pa[e]=t}class Va{constructor(e,t,r){this.lexer=void 0,this.start=void 0,this.end=void 0,this.lexer=e,this.start=t,this.end=r}static range(e,t){return t?e&&e.loc&&t.loc&&e.loc.lexer===t.loc.lexer?new Va(e.loc.lexer,e.loc.start,t.loc.end):null:e&&e.loc}}class Ga{constructor(e,t){this.text=void 0,this.loc=void 0,this.noexpand=void 0,this.treatAsRelax=void 0,this.text=e,this.loc=t}range(e,t){return new Ga(t,Va.range(this,e))}}function ja(e){var t=[];e.consumeSpaces();var r=e.fetch().text;for("\\relax"===r&&(e.consume(),e.consumeSpaces(),r=e.fetch().text);"\\hline"===r||"\\hdashline"===r;)e.consume(),t.push("\\hdashline"===r),e.consumeSpaces(),r=e.fetch().text;return t}var Ua=e=>{if(!e.parser.settings.displayMode)throw new s("{"+e.envName+"} can be used only in display mode.")},_a=new Set(["gather","gather*"]);function Xa(e){if(!e.includes("ed"))return!e.includes("*")}function Ya(e,t,r){var a=t.hskipBeforeAndAfter,n=t.addJot,i=t.cols,o=t.arraystretch,l=t.colSeparationType,h=t.autoTag,m=t.singleRow,c=t.emptySingleRow,u=t.maxNumCols,p=t.leqno;if(e.gullet.beginGroup(),m||e.gullet.macros.set("\\cr","\\\\\\relax"),!o){var d=e.gullet.expandMacroAsText("\\arraystretch");if(null==d)o=1;else if(!(o=parseFloat(d))||o<0)throw new s("Invalid \\arraystretch: "+d)}e.gullet.beginGroup();var g=[],f=[g],v=[],b=[],y=null!=h?[]:void 0;function x(){h&&e.gullet.macros.set("\\@eqnsw","1",!0)}function w(){y&&(e.gullet.macros.get("\\df@tag")?(y.push(e.subparse([new Ga("\\df@tag")])),e.gullet.macros.set("\\df@tag",void 0,!0)):y.push(Boolean(h)&&"1"===e.gullet.macros.get("\\@eqnsw")))}for(x(),b.push(ja(e));;){var k=e.parseExpression(!1,m?"\\end":"\\\\");e.gullet.endGroup(),e.gullet.beginGroup();var S={type:"ordgroup",mode:e.mode,body:k};r&&(S={type:"styling",mode:e.mode,style:r,resetFont:!0,body:[S]}),g.push(S);var z=e.fetch().text;if("&"===z){if(u&&g.length===u){if(m||l)throw new s("Too many tab characters: &",e.nextToken);e.settings.reportNonstrict("textEnv","Too few columns specified in the {array} column argument.")}e.consume()}else{if("\\end"===z){w(),1!==g.length||"styling"!==S.type||1!==S.body.length||"ordgroup"!==S.body[0].type||0!==S.body[0].body.length||!(f.length>1)&&c||Array.isArray(null==y?void 0:y[y.length-1])||h&&!0===(null==y?void 0:y[y.length-1])||f.pop(),b.length<f.length+1&&b.push([]);break}if("\\\\"!==z)throw new s("Expected & or \\\\ or \\cr or \\end",e.nextToken);e.consume();var M=void 0;" "!==e.gullet.future().text&&(M=e.parseSizeGroup(!0)),v.push(M?M.value:null),w(),b.push(ja(e)),g=[],f.push(g),x()}}return e.gullet.endGroup(),e.gullet.endGroup(),{type:"array",mode:e.mode,addJot:n,arraystretch:o,body:f,cols:i,rowGaps:v,hskipBeforeAndAfter:a,hLinesBeforeRow:b,colSeparationType:l,tags:y,leqno:p}}function Wa(e){return"d"===e.slice(0,1)?"display":"text"}var $a=function(e,t){var r,a,n=e.body.length,i=e.hLinesBeforeRow,o=0,l=new Array(n),h=[],m=Math.max(t.fontMetrics().arrayRuleWidth,t.minRuleThickness),c=1/t.fontMetrics().ptPerEm,u=5*c;e.colSeparationType&&"small"===e.colSeparationType&&(u=t.havingStyle(q.SCRIPT).sizeMultiplier/t.sizeMultiplier*.2778);var p="CD"===e.colSeparationType?K({number:3,unit:"ex"},t):12*c,d=3*c,g=e.arraystretch*p,f=.7*g,v=.3*g,b=0;function y(e){for(var t=0;t<e.length;++t)t>0&&(b+=.25),h.push({pos:b,isDashed:e[t]})}for(y(i[0]),r=0;r<e.body.length;++r){var x=e.body[r],w=f,k=v;o<x.length&&(o=x.length);var S={cells:new Array(x.length),height:0,depth:0,pos:0};for(a=0;a<x.length;++a){var z=or(x[a],t);k<z.depth&&(k=z.depth),w<z.height&&(w=z.height),S.cells[a]=z}var M=e.rowGaps[r],A=0;M&&(A=K(M,t))>0&&(k<(A+=v)&&(k=A),A=0),e.addJot&&r<e.body.length-1&&(k+=d),S.height=w,S.depth=k,b+=w,S.pos=b,b+=k+A,l[r]=S,y(i[r+1])}var T,C,B=b/2+t.fontMetrics().axisHeight,I=e.cols||[],O=[],R=[];if(e.tags&&e.tags.some(e=>e))for(r=0;r<n;++r){var E=l[r],H=E.pos-B,N=e.tags[r],D=void 0;(D=!0===N?Mt(["eqn-num"],[],t):Mt([],!1===N?[]:er(N,t,!0),t)).depth=E.depth,D.height=E.height,R.push({type:"elem",elem:D,shift:H})}for(a=0,C=0;a<o||C<I.length;++a,++C){for(var L,P=I[C],F=!0;"separator"===(null==(V=P)?void 0:V.type);){var V;if(F||((T=Mt(["arraycolsep"],[])).style.width=J(t.fontMetrics().doubleRuleSep),O.push(T)),"|"!==P.separator&&":"!==P.separator)throw new s("Invalid separator type: "+P.separator);var G="|"===P.separator?"solid":"dashed",j=Mt(["vertical-separator"],[],t);j.style.height=J(b),j.style.borderRightWidth=J(m),j.style.borderRightStyle=G,j.style.margin="0 "+J(-m/2);var U=b-B;U&&(j.style.verticalAlign=J(-U)),O.push(j),P=I[++C],F=!1}if(!(a>=o)){var _,X,Y=void 0;if(a>0||e.hskipBeforeAndAfter)0!==(Y=null!=(_=null==(X=P)?void 0:X.pregap)?_:u)&&((T=Mt(["arraycolsep"],[])).style.width=J(Y),O.push(T));var W=[];for(r=0;r<n;++r){var $=l[r],Z=$.cells[a];if(Z){var Q=$.pos-B;Z.depth=$.depth,Z.height=$.height,W.push({type:"elem",elem:Z,shift:Q})}}var ee,te,re=Ot({positionType:"individualShift",children:W}),ae=Mt(["col-align-"+((null==(L=P)?void 0:L.align)||"c")],[re]);if(O.push(ae),a<o-1||e.hskipBeforeAndAfter)0!==(Y=null!=(ee=null==(te=P)?void 0:te.postgap)?ee:u)&&((T=Mt(["arraycolsep"],[])).style.width=J(Y),O.push(T))}}var ne=Mt(["mtable"],O);if(h.length>0){for(var ie=Tt("katex-hline",t,m),oe=Tt("katex-hdashline",t,m),se=[{type:"elem",elem:ne,shift:0}];h.length>0;){var le=h.pop(),he=le.pos-B;le.isDashed?se.push({type:"elem",elem:oe,shift:he}):se.push({type:"elem",elem:ie,shift:he})}ne=Ot({positionType:"individualShift",children:se})}if(0===R.length)return Mt(["mord"],[ne],t);var me=Ot({positionType:"individualShift",children:R}),ce=Mt(["katex-tag"],[me],t);return Bt([ne,ce])},Za={c:"center ",l:"left ",r:"right "},Ka=function(e,t){for(var r=[],a=new mr("mtd",[],["mtr-glue"]),n=new mr("mtd",[],["mml-eqn-num"]),i=0;i<e.body.length;i++){for(var o=e.body[i],s=[],l=0;l<o.length;l++)s.push(new mr("mtd",[kr(o[l],t)]));e.tags&&e.tags[i]&&(s.unshift(a),s.push(a),e.leqno?s.unshift(n):s.push(n)),r.push(new mr("mtr",s))}var h=new mr("mtable",r),m=.5===e.arraystretch?.1:.16+e.arraystretch-1+(e.addJot?.09:0);h.setAttribute("rowspacing",J(m));var c="",u="";if(e.cols&&e.cols.length>0){var p=e.cols,d="",g=!1,f=0,v=p.length;"separator"===p[0].type&&(c+="top ",f=1),"separator"===p[p.length-1].type&&(c+="bottom ",v-=1);for(var b=f;b<v;b++){var y=p[b];"align"===y.type?(u+=Za[y.align],g&&(d+="none "),g=!0):"separator"===y.type&&g&&(d+="|"===y.separator?"solid ":"dashed ",g=!1)}h.setAttribute("columnalign",u.trim()),/[sd]/.test(d)&&h.setAttribute("columnlines",d.trim())}if("align"===e.colSeparationType){for(var x=e.cols||[],w="",k=1;k<x.length;k++)w+=k%2?"0em ":"1em ";h.setAttribute("columnspacing",w.trim())}else"alignat"===e.colSeparationType||"gather"===e.colSeparationType?h.setAttribute("columnspacing","0em"):"small"===e.colSeparationType?h.setAttribute("columnspacing","0.2778em"):"CD"===e.colSeparationType?h.setAttribute("columnspacing","0.5em"):h.setAttribute("columnspacing","1em");var S="",z=e.hLinesBeforeRow;c+=z[0].length>0?"left ":"",c+=z[z.length-1].length>0?"right ":"";for(var M=1;M<z.length-1;M++)S+=0===z[M].length?"none ":z[M][0]?"dashed ":"solid ";return/[sd]/.test(S)&&h.setAttribute("rowlines",S.trim()),""!==c&&(h=new mr("menclose",[h])).setAttribute("notation",c.trim()),e.arraystretch&&e.arraystretch<1&&(h=new mr("mstyle",[h])).setAttribute("scriptlevel","1"),h},Ja=function(e,t){e.envName.includes("ed")||Ua(e);var r=[],a="split"===e.envName,n=Ya(e.parser,{cols:r,addJot:!0,autoTag:a?void 0:Xa(e.envName),emptySingleRow:!0,colSeparationType:e.envName.includes("at")?"alignat":"align",maxNumCols:a?2:void 0,leqno:e.parser.settings.leqno},"display"),i=0,o=0,l={type:"ordgroup",mode:e.mode,body:[]};if(t[0]&&"ordgroup"===t[0].type){var h="Number of columns should be a positive integer",m=jr(t[0],h);if(!/^[0-9]+$/.test(m)||Number(m)<1)throw new s(h,t[0]);i=Number(m),o=2*i}var c=!o;n.body.forEach(function(e){for(var t=1;t<e.length;t+=2){var r=Fr(e[t],"styling");Fr(r.body[0],"ordgroup").body.unshift(l)}if(c)o<e.length&&(o=e.length);else{var a=e.length/2;if(i<a)throw new s("Too many math in a row: expected "+i+", but got "+a,e[0])}});for(var u=0;u<o;++u){var p="r",d=0;u%2==1?p="l":u>0&&c&&(d=1),r[u]={type:"align",align:p,pregap:d,postgap:0}}return n.colSeparationType=c?"align":"alignat",n};La({type:"array",names:["array","darray"],props:{numArgs:1},handler(e,t){var r=(Gr(t[0])?[t[0]]:Fr(t[0],"ordgroup").body).map(function(e){var t=Vr(e).text;if("lcr".includes(t))return{type:"align",align:t};if("|"===t)return{type:"separator",separator:"|"};if(":"===t)return{type:"separator",separator:":"};throw new s("Unknown column alignment: "+t,e)}),a={cols:r,hskipBeforeAndAfter:!0,maxNumCols:r.length};return Ya(e.parser,a,Wa(e.envName))},htmlBuilder:$a,mathmlBuilder:Ka}),La({type:"array",names:["matrix","pmatrix","bmatrix","Bmatrix","vmatrix","Vmatrix","matrix*","pmatrix*","bmatrix*","Bmatrix*","vmatrix*","Vmatrix*"],props:{numArgs:0},handler(e){var t={matrix:null,pmatrix:["(",")"],bmatrix:["[","]"],Bmatrix:["\\{","\\}"],vmatrix:["|","|"],Vmatrix:["\\Vert","\\Vert"]}[e.envName.replace("*","")],r="c",a={hskipBeforeAndAfter:!1,cols:[{type:"align",align:r}]};if("*"===e.envName.charAt(e.envName.length-1)){var n=e.parser;if(n.consumeSpaces(),"["===n.fetch().text){if(n.consume(),n.consumeSpaces(),r=n.fetch().text,!"lcr".includes(r))throw new s("Expected l or c or r",n.nextToken);n.consume(),n.consumeSpaces(),n.expect("]"),n.consume(),a.cols=[{type:"align",align:r}]}}var i=Ya(e.parser,a,Wa(e.envName)),o=Math.max(0,...i.body.map(e=>e.length));return i.cols=new Array(o).fill({type:"align",align:r}),t?{type:"leftright",mode:e.mode,body:[i],left:t[0],right:t[1],rightColor:void 0}:i},htmlBuilder:$a,mathmlBuilder:Ka}),La({type:"array",names:["smallmatrix"],props:{numArgs:0},handler(e){var t=Ya(e.parser,{arraystretch:.5},"script");return t.colSeparationType="small",t},htmlBuilder:$a,mathmlBuilder:Ka}),La({type:"array",names:["subarray"],props:{numArgs:1},handler(e,t){var r=(Gr(t[0])?[t[0]]:Fr(t[0],"ordgroup").body).map(function(e){var t=Vr(e).text;if("lc".includes(t))return{type:"align",align:t};throw new s("Unknown column alignment: "+t,e)});if(r.length>1)throw new s("{subarray} can contain only one column");var a={cols:r,hskipBeforeAndAfter:!1,arraystretch:.5},n=Ya(e.parser,a,"script");if(n.body.length>0&&n.body[0].length>1)throw new s("{subarray} can contain only one column");return n},htmlBuilder:$a,mathmlBuilder:Ka}),La({type:"array",names:["cases","dcases","rcases","drcases"],props:{numArgs:0},handler(e){var t=Ya(e.parser,{arraystretch:1.2,cols:[{type:"align",align:"l",pregap:0,postgap:1},{type:"align",align:"l",pregap:0,postgap:0}]},Wa(e.envName));return{type:"leftright",mode:e.mode,body:[t],left:e.envName.includes("r")?".":"\\{",right:e.envName.includes("r")?"\\}":".",rightColor:void 0}},htmlBuilder:$a,mathmlBuilder:Ka}),La({type:"array",names:["align","align*","aligned","split"],props:{numArgs:0},handler:Ja,htmlBuilder:$a,mathmlBuilder:Ka}),La({type:"array",names:["gathered","gather","gather*"],props:{numArgs:0},handler(e){_a.has(e.envName)&&Ua(e);var t={cols:[{type:"align",align:"c"}],addJot:!0,colSeparationType:"gather",autoTag:Xa(e.envName),emptySingleRow:!0,leqno:e.parser.settings.leqno};return Ya(e.parser,t,"display")},htmlBuilder:$a,mathmlBuilder:Ka}),La({type:"array",names:["alignat","alignat*","alignedat"],props:{numArgs:1},handler:Ja,htmlBuilder:$a,mathmlBuilder:Ka}),La({type:"array",names:["equation","equation*"],props:{numArgs:0},handler(e){Ua(e);var t={autoTag:Xa(e.envName),emptySingleRow:!0,singleRow:!0,maxNumCols:1,leqno:e.parser.settings.leqno};return Ya(e.parser,t,"display")},htmlBuilder:$a,mathmlBuilder:Ka}),La({type:"array",names:["CD"],props:{numArgs:0},handler:e=>(Ua(e),ea(e.parser)),htmlBuilder:$a,mathmlBuilder:Ka}),Fa("\\nonumber","\\gdef\\@eqnsw{0}"),Fa("\\notag","\\nonumber"),Xt({type:"text",names:["\\hline","\\hdashline"],numArgs:0,allowedInText:!0,allowedInMath:!0,handler(e,t){throw new s(e.funcName+" valid only within array environment")}});var Qa=Da;Xt({type:"environment",names:["\\begin","\\end"],numArgs:1,argTypes:["text"],handler(e,t){var r=e.parser,a=e.funcName,n=t[0];if("ordgroup"!==n.type)throw new s("Invalid environment name",n);var i=jr(n,"Environment name should contain only text characters and spaces",!0);if("\\begin"===a){if(!Object.prototype.hasOwnProperty.call(Qa,i))throw new s("No such environment: "+i,n);var o=Qa[i],l=r.parseArguments("\\begin{"+i+"}",o),h=l.args,m=l.optArgs,c={mode:r.mode,envName:i,parser:r},u=o.handler(c,h,m);r.expect("\\end",!1);var p=r.nextToken,d=Fr(r.parseFunction(),"environment");if(d.name!==i)throw new s("Mismatch: \\begin{"+i+"} matched by \\end{"+d.name+"}",p);return u}return{type:"environment",mode:r.mode,name:i,nameGroup:n}}});var en={"\\Bbb":"\\mathbb","\\bold":"\\mathbf","\\frak":"\\mathfrak"};Xt({type:"font",names:["\\mathrm","\\mathit","\\mathbf","\\mathnormal","\\mathsfit","\\mathbb","\\mathcal","\\mathfrak","\\mathscr","\\mathsf","\\mathtt","\\Bbb","\\bold","\\frak"],numArgs:1,allowedInArgument:!0,handler:(e,t)=>{var r=e.parser,a=e.funcName,n=Wt(t[0]),i=a in en?en[a]:a;return{type:"font",mode:r.mode,font:i.slice(1),body:n}},htmlBuilder:(e,t)=>{var r=e.font,a=t.withFont(r);return or(e.body,a)},mathmlBuilder:(e,t)=>{var r=e.font,a=t.withFont(r);return kr(e.body,a)}}),Xt({type:"mclass",names:["\\boldsymbol","\\bm"],numArgs:1,handler:(e,t)=>{var r=e.parser,a=t[0];return{type:"mclass",mode:r.mode,mclass:Wr(a),body:[{type:"font",mode:r.mode,font:"boldsymbol",body:a}],isCharacterBox:g(a)}}}),Xt({type:"font",names:["\\rm","\\sf","\\tt","\\bf","\\it","\\cal"],numArgs:0,allowedInText:!0,handler:(e,t)=>{var r=e.parser,a=e.funcName,n=e.breakOnTokenText,i=r.mode,o=r.parseExpression(!0,n);return{type:"font",mode:i,font:"math"+a.slice(1),body:{type:"ordgroup",mode:r.mode,body:o}}}});var tn=(e,t)=>t?{type:"styling",mode:e.mode,style:t,body:[e]}:e;Xt({type:"genfrac",names:["\\cfrac","\\dfrac","\\frac","\\tfrac","\\dbinom","\\binom","\\tbinom","\\\\atopfrac","\\\\bracefrac","\\\\brackfrac"],numArgs:2,allowedInArgument:!0,handler:(e,t)=>{var r,a=e.parser,n=e.funcName,i=t[0],o=t[1],s=null,l=null;switch(n){case"\\cfrac":case"\\dfrac":case"\\frac":case"\\tfrac":r=!0;break;case"\\\\atopfrac":r=!1;break;case"\\dbinom":case"\\binom":case"\\tbinom":r=!1,s="(",l=")";break;case"\\\\bracefrac":r=!1,s="\\{",l="\\}";break;case"\\\\brackfrac":r=!1,s="[",l="]";break;default:throw new Error("Unrecognized genfrac command")}var h="\\cfrac"===n,m=null;return h||n.startsWith("\\d")?m="display":n.startsWith("\\t")&&(m="text"),tn({type:"genfrac",mode:a.mode,numer:i,denom:o,continued:h,hasBarLine:r,leftDelim:s,rightDelim:l,barSize:null},m)},htmlBuilder:(e,t)=>{var r,a=t.style,n=a.fracNum(),i=a.fracDen();r=t.havingStyle(n);var o=or(e.numer,r,t);if(e.continued){var s=8.5/t.fontMetrics().ptPerEm,l=3.5/t.fontMetrics().ptPerEm;o.height=o.height<s?s:o.height,o.depth=o.depth<l?l:o.depth}r=t.havingStyle(i);var h,m,c,u,p,d,g,f,v,b,y=or(e.denom,r,t);if(e.hasBarLine?(e.barSize?(m=K(e.barSize,t),h=Tt("frac-line",t,m)):h=Tt("frac-line",t),m=h.height,c=h.height):(h=null,m=0,c=t.fontMetrics().defaultRuleThickness),a.size===q.DISPLAY.size?(u=t.fontMetrics().num1,p=m>0?3*c:7*c,d=t.fontMetrics().denom1):(m>0?(u=t.fontMetrics().num2,p=c):(u=t.fontMetrics().num3,p=3*c),d=t.fontMetrics().denom2),h){var x=t.fontMetrics().axisHeight;u-o.depth-(x+.5*m)<p&&(u+=p-(u-o.depth-(x+.5*m))),x-.5*m-(y.height-d)<p&&(d+=p-(x-.5*m-(y.height-d))),g=Ot({positionType:"individualShift",children:[{type:"elem",elem:y,shift:d},{type:"elem",elem:h,shift:-(x-.5*m)},{type:"elem",elem:o,shift:-u}]})}else{var w=u-o.depth-(y.height-d);w<p&&(u+=.5*(p-w),d+=.5*(p-w)),g=Ot({positionType:"individualShift",children:[{type:"elem",elem:y,shift:d},{type:"elem",elem:o,shift:-u}]})}return r=t.havingStyle(a),g.height*=r.sizeMultiplier/t.sizeMultiplier,g.depth*=r.sizeMultiplier/t.sizeMultiplier,f=a.size===q.DISPLAY.size?t.fontMetrics().delim1:a.size===q.SCRIPTSCRIPT.size?t.havingStyle(q.SCRIPT).fontMetrics().delim2:t.fontMetrics().delim2,v=null==e.leftDelim?ir(t,["mopen"]):qa(e.leftDelim,f,!0,t.havingStyle(a),e.mode,["mopen"]),b=e.continued?Mt([]):null==e.rightDelim?ir(t,["mclose"]):qa(e.rightDelim,f,!0,t.havingStyle(a),e.mode,["mclose"]),Mt(["mord"].concat(r.sizingClasses(t)),[v,Mt(["mfrac"],[g]),b],t)},mathmlBuilder:(e,t)=>{var r=new mr("mfrac",[kr(e.numer,t),kr(e.denom,t)]);if(e.hasBarLine){if(e.barSize){var a=K(e.barSize,t);r.setAttribute("linethickness",J(a))}}else r.setAttribute("linethickness","0px");if(null!=e.leftDelim||null!=e.rightDelim){var n=[];if(null!=e.leftDelim){var i=new mr("mo",[new cr(e.leftDelim.replace("\\",""))]);i.setAttribute("fence","true"),n.push(i)}if(n.push(r),null!=e.rightDelim){var o=new mr("mo",[new cr(e.rightDelim.replace("\\",""))]);o.setAttribute("fence","true"),n.push(o)}return fr(n)}return r}}),Xt({type:"infix",names:["\\over","\\choose","\\atop","\\brace","\\brack"],numArgs:0,infix:!0,handler(e){var t,r=e.parser,a=e.funcName,n=e.token;switch(a){case"\\over":t="\\frac";break;case"\\choose":t="\\binom";break;case"\\atop":t="\\\\atopfrac";break;case"\\brace":t="\\\\bracefrac";break;case"\\brack":t="\\\\brackfrac";break;default:throw new Error("Unrecognized infix genfrac command")}return{type:"infix",mode:r.mode,replaceWith:t,token:n}}});var rn=["display","text","script","scriptscript"],an=function(e){var t=null;return e.length>0&&(t="."===(t=e)?null:t),t};Xt({type:"genfrac",names:["\\genfrac"],numArgs:6,allowedInArgument:!0,argTypes:["math","math","size","text","math","math"],handler(e,t){var r,a=e.parser,n=t[4],i=t[5],o=Wt(t[0]),s="atom"===o.type&&"open"===o.family?an(o.text):null,l=Wt(t[1]),h="atom"===l.type&&"close"===l.family?an(l.text):null,m=Fr(t[2],"size"),c=null;r=!!m.isBlank||(c=m.value).number>0;var u=null,p=t[3];if("ordgroup"===p.type){if(p.body.length>0){var d=Fr(p.body[0],"textord");u=rn[Number(d.text)]}}else p=Fr(p,"textord"),u=rn[Number(p.text)];return tn({type:"genfrac",mode:a.mode,numer:n,denom:i,continued:!1,hasBarLine:r,barSize:c,leftDelim:s,rightDelim:h},u)}}),Xt({type:"infix",names:["\\above"],numArgs:1,argTypes:["size"],infix:!0,handler(e,t){var r=e.parser;e.funcName;var a=e.token;return{type:"infix",mode:r.mode,replaceWith:"\\\\abovefrac",size:Fr(t[0],"size").value,token:a}}}),Xt({type:"genfrac",names:["\\\\abovefrac"],numArgs:3,argTypes:["math","size","math"],handler:(e,t)=>{var r=e.parser;e.funcName;var a=t[0],n=Fr(t[1],"infix").size;if(!n)throw new Error("\\\\abovefrac expected size, but got "+String(n));var i=t[2],o=n.number>0;return{type:"genfrac",mode:r.mode,numer:a,denom:i,continued:!1,hasBarLine:o,barSize:n,leftDelim:null,rightDelim:null}}});var nn=(e,t)=>{var r,a,n=t.style;"supsub"===e.type?(r=e.sup?or(e.sup,t.havingStyle(n.sup()),t):or(e.sub,t.havingStyle(n.sub()),t),a=Fr(e.base,"horizBrace")):a=Fr(e,"horizBrace");var i,o=or(a.base,t.havingBaseStyle(q.DISPLAY)),s=Nr(a,t);if(i=a.isOver?Ot({positionType:"firstBaseline",children:[{type:"elem",elem:o},{type:"kern",size:.1},{type:"elem",elem:s,wrapperClasses:["svg-align"]}]}):Ot({positionType:"bottom",positionData:o.depth+.1+s.height,children:[{type:"elem",elem:s,wrapperClasses:["svg-align"]},{type:"kern",size:.1},{type:"elem",elem:o}]}),r){var l=Mt(["minner",a.isOver?"mover":"munder"],[i],t);i=a.isOver?Ot({positionType:"firstBaseline",children:[{type:"elem",elem:l},{type:"kern",size:.2},{type:"elem",elem:r}]}):Ot({positionType:"bottom",positionData:l.depth+.2+r.height+r.depth,children:[{type:"elem",elem:r},{type:"kern",size:.2},{type:"elem",elem:l}]})}return Mt(["minner",a.isOver?"mover":"munder"],[i],t)};Xt({type:"horizBrace",names:["\\overbrace","\\underbrace","\\overbracket","\\underbracket"],numArgs:1,handler(e,t){var r=e.parser,a=e.funcName;return{type:"horizBrace",mode:r.mode,label:a,isOver:a.includes("\\over"),base:t[0]}},htmlBuilder:nn,mathmlBuilder:(e,t)=>{var r=Rr(e.label);return new mr(e.isOver?"mover":"munder",[kr(e.base,t),r])}}),Xt({type:"href",names:["\\href"],numArgs:2,argTypes:["url","original"],allowedInText:!0,handler:(e,t)=>{var r=e.parser,a=t[1],n=Fr(t[0],"url").url;return r.settings.isTrusted({command:"\\href",url:n})?{type:"href",mode:r.mode,href:n,body:$t(a)}:r.formatUnsupportedCmd("\\href")},htmlBuilder:(e,t)=>{var r=er(e.body,t,!1);return Ct(e.href,[],r,t)},mathmlBuilder:(e,t)=>{var r=wr(e.body,t);return r instanceof mr||(r=new mr("mrow",[r])),r.setAttribute("href",e.href),r}}),Xt({type:"href",names:["\\url"],numArgs:1,argTypes:["url"],allowedInText:!0,handler:(e,t)=>{var r=e.parser,a=Fr(t[0],"url").url;if(!r.settings.isTrusted({command:"\\url",url:a}))return r.formatUnsupportedCmd("\\url");for(var n=[],i=0;i<a.length;i++){var o=a[i];"~"===o&&(o="\\textasciitilde"),n.push({type:"textord",mode:"text",text:o})}var s={type:"text",mode:r.mode,font:"\\texttt",body:n};return{type:"href",mode:r.mode,href:a,body:$t(s)}}}),Xt({type:"hbox",names:["\\hbox"],numArgs:1,argTypes:["text"],allowedInText:!0,primitive:!0,handler:(e,t)=>({type:"hbox",mode:e.parser.mode,body:$t(t[0])}),htmlBuilder(e,t){var r=er(e.body,t.withFont(''),!1);return Bt(r)},mathmlBuilder:(e,t)=>new mr("mrow",xr(e.body,t.withFont('')))}),Xt({type:"html",names:["\\htmlClass","\\htmlId","\\htmlStyle","\\htmlData"],numArgs:2,argTypes:["raw","original"],allowedInText:!0,handler:(e,t)=>{var r=e.parser,a=e.funcName;e.token;var n,i=Fr(t[0],"raw").string,o=t[1];r.settings.strict&&r.settings.reportNonstrict("htmlExtension","HTML extension is disabled on strict mode");var l={};switch(a){case"\\htmlClass":l.class=i,n={command:"\\htmlClass",class:i};break;case"\\htmlId":l.id=i,n={command:"\\htmlId",id:i};break;case"\\htmlStyle":l.style=i,n={command:"\\htmlStyle",style:i};break;case"\\htmlData":for(var h=[],m="",c=0;c<i.length;c++)i.startsWith("{,}",c)?(m+=",",c+=2):","===i[c]?(h.push(m),m=""):m+=i[c];h.push(m);for(var u=0;u<h.length;u++){var p=h[u],d=p.indexOf("=");if(d<0)throw new s("\\htmlData key/value '"+p+"' missing equals sign");var g=p.slice(0,d),f=p.slice(d+1);l["data-"+g.trim()]=f}n={command:"\\htmlData",attributes:l};break;default:throw new Error("Unrecognized html command")}return r.settings.isTrusted(n)?{type:"html",mode:r.mode,attributes:l,body:$t(o)}:r.formatUnsupportedCmd(a)},htmlBuilder:(e,t)=>{var r=er(e.body,t,!1),a=["enclosing"];e.attributes.class&&a.push(...e.attributes.class.trim().split(/\s+/));var n=Mt(a,r,t);for(var i of Object.entries(e.attributes)){var o=i[0],s=i[1];"class"!==o&&n.setAttribute(o,s)}return n},mathmlBuilder:(e,t)=>wr(e.body,t)}),Xt({type:"htmlmathml",names:["\\html@mathml"],numArgs:2,allowedInArgument:!0,allowedInText:!0,handler:(e,t)=>({type:"htmlmathml",mode:e.parser.mode,html:$t(t[0]),mathml:$t(t[1])}),htmlBuilder:(e,t)=>{var r=er(e.html,t,!1);return Bt(r)},mathmlBuilder:(e,t)=>wr(e.mathml,t)});var on=function(e){if(/^[-+]? *(\d+(\.\d*)?|\.\d+)$/.test(e))return{number:+e,unit:"bp"};var t=/([-+]?) *(\d+(?:\.\d*)?|\.\d+) *([a-z]{2})/.exec(e);if(!t)throw new s("Invalid size: '"+e+"' in \\includegraphics");var r={number:+(t[1]+t[2]),unit:t[3]};if(!Z(r))throw new s("Invalid unit: '"+r.unit+"' in \\includegraphics.");return r};Xt({type:"includegraphics",names:["\\includegraphics"],numArgs:1,numOptionalArgs:1,argTypes:["raw","url"],allowedInText:!1,handler:(e,t,r)=>{var a=e.parser,n={number:0,unit:"em"},i={number:.9,unit:"em"},o={number:0,unit:"em"},l="";if(r[0])for(var h=Fr(r[0],"raw").string.split(","),m=0;m<h.length;m++){var c=h[m].split("=");if(2===c.length){var u=c[1].trim();switch(c[0].trim()){case"alt":l=u;break;case"width":n=on(u);break;case"height":i=on(u);break;case"totalheight":o=on(u);break;default:throw new s("Invalid key: '"+c[0]+"' in \\includegraphics.")}}}var p=Fr(t[0],"url").url;return""===l&&(l=(l=(l=p).replace(/^.*[\\/]/,'')).substring(0,l.lastIndexOf('.'))),a.settings.isTrusted({command:"\\includegraphics",url:p})?{type:"includegraphics",mode:a.mode,alt:l,width:n,height:i,totalheight:o,src:p}:a.formatUnsupportedCmd("\\includegraphics")},htmlBuilder:(e,t)=>{var r=K(e.height,t),a=0;e.totalheight.number>0&&(a=K(e.totalheight,t)-r);var n=0;e.width.number>0&&(n=K(e.width,t));var i={height:J(r+a)};n>0&&(i.width=J(n)),a>0&&(i.verticalAlign=J(-a));var o=new se(e.src,e.alt,i);return o.height=r,o.depth=a,o},mathmlBuilder:(e,t)=>{var r=new mr("mglyph",[]);r.setAttribute("alt",e.alt);var a=K(e.height,t),n=0;if(e.totalheight.number>0&&(n=K(e.totalheight,t)-a,r.setAttribute("valign",J(-n))),r.setAttribute("height",J(a+n)),e.width.number>0){var i=K(e.width,t);r.setAttribute("width",J(i))}return r.setAttribute("src",e.src),r}}),Xt({type:"kern",names:["\\kern","\\mkern","\\hskip","\\mskip"],numArgs:1,argTypes:["size"],primitive:!0,allowedInText:!0,handler(e,t){var r=e.parser,a=e.funcName,n=Fr(t[0],"size");if(r.settings.strict){var i='m'===a[1],o='mu'===n.value.unit;i?(o||r.settings.reportNonstrict("mathVsTextUnits","LaTeX's "+a+" supports only mu units, not "+n.value.unit+" units"),"math"!==r.mode&&r.settings.reportNonstrict("mathVsTextUnits","LaTeX's "+a+" works only in math mode")):o&&r.settings.reportNonstrict("mathVsTextUnits","LaTeX's "+a+" doesn't support mu units")}return{type:"kern",mode:r.mode,dimension:n.value}},htmlBuilder:(e,t)=>Rt(e.dimension,t),mathmlBuilder(e,t){var r=K(e.dimension,t);return new ur(r)}}),Xt({type:"lap",names:["\\mathllap","\\mathrlap","\\mathclap"],numArgs:1,allowedInText:!0,handler:(e,t)=>{var r=e.parser,a=e.funcName,n=t[0];return{type:"lap",mode:r.mode,alignment:a.slice(5),body:n}},htmlBuilder:(e,t)=>{var r;"clap"===e.alignment?(r=Mt([],[or(e.body,t)]),r=Mt(["katex-inner"],[r],t)):r=Mt(["katex-inner"],[or(e.body,t)]);var a=Mt(["katex-fix"],[]),n=Mt([e.alignment],[r,a],t),i=Mt(["katex-strut"]);return i.style.height=J(n.height+n.depth),n.depth&&(i.style.verticalAlign=J(-n.depth)),n.children.unshift(i),n=Mt(["katex-thinbox"],[n],t),Mt(["mord","katex-vbox"],[n],t)},mathmlBuilder:(e,t)=>{var r=new mr("mpadded",[kr(e.body,t)]);if("rlap"!==e.alignment){var a="llap"===e.alignment?"-1":"-0.5";r.setAttribute("lspace",a+"width")}return r.setAttribute("width","0px"),r}}),Xt({type:"styling",names:["\\(","$"],numArgs:0,allowedInText:!0,allowedInMath:!1,handler(e,t){var r=e.funcName,a=e.parser,n=a.mode;a.switchMode("math");var i="\\("===r?"\\)":"$",o=a.parseExpression(!1,i);return a.expect(i),a.switchMode(n),{type:"styling",mode:a.mode,style:"text",resetFont:!0,body:o}}}),Xt({type:"text",names:["\\)","\\]"],numArgs:0,allowedInText:!0,allowedInMath:!1,handler(e,t){throw new s("Mismatched "+e.funcName)}});var sn=(e,t)=>{switch(t.style.size){case q.DISPLAY.size:return e.display;case q.TEXT.size:return e.text;case q.SCRIPT.size:return e.script;case q.SCRIPTSCRIPT.size:return e.scriptscript;default:return e.text}};Xt({type:"mathchoice",names:["\\mathchoice"],numArgs:4,primitive:!0,handler:(e,t)=>({type:"mathchoice",mode:e.parser.mode,display:$t(t[0]),text:$t(t[1]),script:$t(t[2]),scriptscript:$t(t[3])}),htmlBuilder:(e,t)=>{var r=sn(e,t),a=er(r,t,!1);return Bt(a)},mathmlBuilder:(e,t)=>{var r=sn(e,t);return wr(r,t)}});var ln=(e,t,r,a,n,i,o)=>{e=Mt([],[e]);var s,l,h,m=r&&g(r);if(t){var c=or(t,a.havingStyle(n.sup()),a);l={elem:c,kern:Math.max(a.fontMetrics().bigOpSpacing1,a.fontMetrics().bigOpSpacing3-c.depth)}}if(r){var u=or(r,a.havingStyle(n.sub()),a);s={elem:u,kern:Math.max(a.fontMetrics().bigOpSpacing2,a.fontMetrics().bigOpSpacing4-u.height)}}if(l&&s){var p=a.fontMetrics().bigOpSpacing5+s.elem.height+s.elem.depth+s.kern+e.depth+o;h=Ot({positionType:"bottom",positionData:p,children:[{type:"kern",size:a.fontMetrics().bigOpSpacing5},{type:"elem",elem:s.elem,marginLeft:J(-i)},{type:"kern",size:s.kern},{type:"elem",elem:e},{type:"kern",size:l.kern},{type:"elem",elem:l.elem,marginLeft:J(i)},{type:"kern",size:a.fontMetrics().bigOpSpacing5}]})}else if(s){var d=e.height-o;h=Ot({positionType:"top",positionData:d,children:[{type:"kern",size:a.fontMetrics().bigOpSpacing5},{type:"elem",elem:s.elem,marginLeft:J(-i)},{type:"kern",size:s.kern},{type:"elem",elem:e}]})}else{if(!l)return e;var f=e.depth+o;h=Ot({positionType:"bottom",positionData:f,children:[{type:"elem",elem:e},{type:"kern",size:l.kern},{type:"elem",elem:l.elem,marginLeft:J(i)},{type:"kern",size:a.fontMetrics().bigOpSpacing5}]})}var v=[h];if(s&&0!==i&&!m){var b=Mt(["mspace"],[],a);b.style.marginRight=J(i),v.unshift(b)}return Mt(["mop","op-limits"],v,a)},hn=new Set(["\\smallint"]),mn=(e,t)=>{var r,a,n,i=!1;"supsub"===e.type?(r=e.sup,a=e.sub,n=Fr(e.base,"op"),i=!0):n=Fr(e,"op");var o,s,l=t.style,h=!1;if(l.size===q.DISPLAY.size&&n.symbol&&!hn.has(n.name)&&(h=!0),n.symbol){var m=h?"Size2-Regular":"Size1-Regular",c="";if("\\oiint"!==n.name&&"\\oiiint"!==n.name||(c=n.name.slice(1),n.name="oiint"===c?"\\iint":"\\iiint"),s=(o=bt(n.name,m,"math",t,["mop","op-symbol",h?"large-op":"small-op"])).italic,c.length>0){var u=Dt(c+"Size"+(h?"2":"1"),t);o=Ot({positionType:"individualShift",children:[{type:"elem",elem:o,shift:0},{type:"elem",elem:u,shift:h?.08:0}]}),n.name="\\"+c,o.classes.unshift("mop"),o.italic=s}}else if(n.body){var p=er(n.body,t,!0);1===p.length&&p[0]instanceof he?(o=p[0]).classes[0]="mop":o=Mt(["mop"],p,t)}else{for(var d=[],g=1;g<n.name.length;g++)d.push(yt(n.name[g],n.mode,t));o=Mt(["mop"],d,t)}var f,v=0,b=0;(o instanceof he||"\\oiint"===n.name||"\\oiiint"===n.name)&&!n.suppressBaseShift&&(v=(o.height-o.depth)/2-t.fontMetrics().axisHeight,b=null!=(f=o.italic)?f:0);return i?ln(o,r,a,t,l,b,v):(v&&(o.style.position="relative",o.style.top=J(v)),o)},cn={"\u220f":"\\prod","\u2210":"\\coprod","\u2211":"\\sum","\u22c0":"\\bigwedge","\u22c1":"\\bigvee","\u22c2":"\\bigcap","\u22c3":"\\bigcup","\u2a00":"\\bigodot","\u2a01":"\\bigoplus","\u2a02":"\\bigotimes","\u2a04":"\\biguplus","\u2a06":"\\bigsqcup"};Xt({type:"op",names:["\\coprod","\\bigvee","\\bigwedge","\\biguplus","\\bigcap","\\bigcup","\\intop","\\prod","\\sum","\\bigotimes","\\bigoplus","\\bigodot","\\bigsqcup","\\smallint","\u220f","\u2210","\u2211","\u22c0","\u22c1","\u22c2","\u22c3","\u2a00","\u2a01","\u2a02","\u2a04","\u2a06"],numArgs:0,handler:(e,t)=>{var r=e.parser,a=e.funcName;return 1===a.length&&(a=cn[a]),{type:"op",mode:r.mode,limits:!0,parentIsSupSub:!1,symbol:!0,name:a}},htmlBuilder:mn,mathmlBuilder:(e,t)=>{var r;if(e.symbol)r=new mr("mo",[gr(e.name,e.mode)]),hn.has(e.name)&&r.setAttribute("largeop","false");else if(e.body)r=new mr("mo",xr(e.body,t));else{r=new mr("mi",[new cr(e.name.slice(1))]);var a=new mr("mo",[gr("\u2061","text")]);r=e.parentIsSupSub?new mr("mrow",[r,a]):hr([r,a])}return r}}),Xt({type:"op",names:["\\mathop"],numArgs:1,primitive:!0,handler:(e,t)=>{var r=e.parser,a=t[0];return{type:"op",mode:r.mode,limits:!1,parentIsSupSub:!1,symbol:!1,body:$t(a)}}});var un={"\u222b":"\\int","\u222c":"\\iint","\u222d":"\\iiint","\u222e":"\\oint","\u222f":"\\oiint","\u2230":"\\oiiint"};Xt({type:"op",names:["\\arcsin","\\arccos","\\arctan","\\arctg","\\arcctg","\\arg","\\ch","\\cos","\\cosec","\\cosh","\\cot","\\cotg","\\coth","\\csc","\\ctg","\\cth","\\deg","\\dim","\\exp","\\hom","\\ker","\\lg","\\ln","\\log","\\sec","\\sin","\\sinh","\\sh","\\tan","\\tanh","\\tg","\\th"],numArgs:0,handler(e){var t=e.parser,r=e.funcName;return{type:"op",mode:t.mode,limits:!1,parentIsSupSub:!1,symbol:!1,name:r}}}),Xt({type:"op",names:["\\det","\\gcd","\\inf","\\lim","\\max","\\min","\\Pr","\\sup"],numArgs:0,handler(e){var t=e.parser,r=e.funcName;return{type:"op",mode:t.mode,limits:!0,parentIsSupSub:!1,symbol:!1,name:r}}}),Xt({type:"op",names:["\\int","\\iint","\\iiint","\\oint","\\oiint","\\oiiint","\u222b","\u222c","\u222d","\u222e","\u222f","\u2230"],numArgs:0,allowedInArgument:!0,handler(e){var t=e.parser,r=e.funcName;return 1===r.length&&(r=un[r]),{type:"op",mode:t.mode,limits:!1,parentIsSupSub:!1,symbol:!0,name:r}}});var pn=(e,t)=>{var r,a,n,i,o=!1;if("supsub"===e.type?(r=e.sup,a=e.sub,n=Fr(e.base,"operatorname"),o=!0):n=Fr(e,"operatorname"),n.body.length>0){for(var s=(n.body.map(e=>{var t="text"in e?e.text:void 0;return"string"==typeof t?{type:"textord",mode:e.mode,text:t}:e})),l=er(s,t.withFont("mathrm"),!0),h=0;h<l.length;h++){var m=l[h];m instanceof he&&(m.text=m.text.replace(/\u2212/,"-").replace(/\u2217/,"*"))}i=Mt(["mop"],l,t)}else i=Mt(["mop"],[],t);return o?ln(i,r,a,t,t.style,0,0):i};Xt({type:"operatorname",names:["\\operatorname@","\\operatornamewithlimits"],numArgs:1,handler:(e,t)=>{var r=e.parser,a=e.funcName,n=t[0];return{type:"operatorname",mode:r.mode,body:$t(n),alwaysHandleSupSub:"\\operatornamewithlimits"===a,limits:!1,parentIsSupSub:!1}},htmlBuilder:pn,mathmlBuilder:(e,t)=>{for(var r=xr(e.body,t.withFont("mathrm")),a=!0,n=0;n<r.length;n++){var i=r[n];if(i instanceof ur);else if(i instanceof mr)switch(i.type){case"mi":case"mn":case"mspace":case"mtext":break;case"mo":var o=i.children[0];1===i.children.length&&o instanceof cr?o.text=o.text.replace(/\u2212/,"-").replace(/\u2217/,"*"):a=!1;break;default:a=!1}else a=!1}if(a){var s=r.map(e=>e.toText()).join("");r=[new cr(s)]}var l=new mr("mi",r);l.setAttribute("mathvariant","normal");var h=new mr("mo",[gr("\u2061","text")]);return e.parentIsSupSub?new mr("mrow",[l,h]):hr([l,h])}}),Fa("\\operatorname","\\@ifstar\\operatornamewithlimits\\operatorname@"),Yt({type:"ordgroup",htmlBuilder:(e,t)=>e.semisimple?Bt(er(e.body,t,!1)):Mt(["mord"],er(e.body,t,!0),t),mathmlBuilder:(e,t)=>wr(e.body,t,!0)}),Xt({type:"overline",names:["\\overline"],numArgs:1,handler(e,t){var r=e.parser,a=t[0];return{type:"overline",mode:r.mode,body:a}},htmlBuilder(e,t){var r=or(e.body,t.havingCrampedStyle()),a=Tt("overline-line",t),n=t.fontMetrics().defaultRuleThickness,i=Ot({positionType:"firstBaseline",children:[{type:"elem",elem:r},{type:"kern",size:3*n},{type:"elem",elem:a},{type:"kern",size:n}]});return Mt(["mord","katex-overline"],[i],t)},mathmlBuilder(e,t){var r=new mr("mo",[new cr("\u203e")]);r.setAttribute("stretchy","true");var a=new mr("mover",[kr(e.body,t),r]);return a.setAttribute("accent","true"),a}}),Xt({type:"phantom",names:["\\phantom"],numArgs:1,allowedInText:!0,handler:(e,t)=>{var r=e.parser,a=t[0];return{type:"phantom",mode:r.mode,body:$t(a)}},htmlBuilder:(e,t)=>{var r=er(e.body,t.withPhantom(),!1);return Bt(r)},mathmlBuilder:(e,t)=>{var r=xr(e.body,t);return new mr("mphantom",r)}}),Fa("\\hphantom","\\smash{\\phantom{#1}}"),Xt({type:"vphantom",names:["\\vphantom"],numArgs:1,allowedInText:!0,handler:(e,t)=>{var r=e.parser,a=t[0];return{type:"vphantom",mode:r.mode,body:a}},htmlBuilder:(e,t)=>{var r=Mt(["katex-inner"],[or(e.body,t.withPhantom())]),a=Mt(["katex-fix"],[]);return Mt(["mord","rlap"],[r,a],t)},mathmlBuilder:(e,t)=>{var r=xr($t(e.body),t),a=new mr("mphantom",r),n=new mr("mpadded",[a]);return n.setAttribute("width","0px"),n}}),Xt({type:"raisebox",names:["\\raisebox"],numArgs:2,argTypes:["size","hbox"],allowedInText:!0,handler(e,t){var r=e.parser,a=Fr(t[0],"size").value,n=t[1];return{type:"raisebox",mode:r.mode,dy:a,body:n}},htmlBuilder(e,t){var r=or(e.body,t),a=K(e.dy,t);return Ot({positionType:"shift",positionData:-a,children:[{type:"elem",elem:r}]})},mathmlBuilder(e,t){var r=new mr("mpadded",[kr(e.body,t)]),a=e.dy.number+e.dy.unit;return r.setAttribute("voffset",a),r}});var dn=(e,t)=>({type:"reflectbox",mode:e.parser.mode,body:t[0]});function gn(e,t,r){for(var a=er(e,t,!1),n=t.sizeMultiplier/r.sizeMultiplier,i=0;i<a.length;i++){var o=a[i].classes.indexOf("katex-sizing");o<0?Array.prototype.push.apply(a[i].classes,t.sizingClasses(r)):a[i].classes[o+1]==="reset-size"+t.size&&(a[i].classes[o+1]="reset-size"+r.size),a[i].height*=n,a[i].depth*=n}return Bt(a)}Xt({type:"reflectbox",names:["\\reflectbox"],numArgs:1,argTypes:["hbox"],allowedInText:!0,handler:dn,htmlBuilder:(e,t)=>Mt(["mord","reflectbox"],[or(e.body,t)],t),mathmlBuilder:(e,t)=>kr(e.body,t)}),Xt({type:"reflectbox",names:["\\mathreflectbox"],numArgs:1,argTypes:["math"],handler:dn}),Xt({type:"internal",names:["\\relax"],numArgs:0,allowedInText:!0,allowedInArgument:!0,handler:e=>({type:"internal",mode:e.parser.mode})}),Xt({type:"rule",names:["\\rule"],numArgs:2,numOptionalArgs:1,allowedInText:!0,allowedInMath:!0,argTypes:["size","size","size"],handler(e,t,r){var a=e.parser,n=r[0],i=Fr(t[0],"size"),o=Fr(t[1],"size");return{type:"rule",mode:a.mode,shift:n&&Fr(n,"size").value,width:i.value,height:o.value}},htmlBuilder(e,t){var r=Mt(["mord","katex-rule"],[],t),a=K(e.width,t),n=K(e.height,t),i=e.shift?K(e.shift,t):0;return r.style.borderRightWidth=J(a),r.style.borderTopWidth=J(n),r.style.bottom=J(i),r.width=a,r.height=n+i,r.depth=-i,r.maxFontSize=1.125*n*t.sizeMultiplier,r},mathmlBuilder(e,t){var r=K(e.width,t),a=K(e.height,t),n=e.shift?K(e.shift,t):0,i=t.color&&t.getColor()||"black",o=new mr("mspace");o.setAttribute("mathbackground",i),o.setAttribute("width",J(r)),o.setAttribute("height",J(a));var s=new mr("mpadded",[o]);return n>=0?s.setAttribute("height",J(n)):(s.setAttribute("height",J(n)),s.setAttribute("depth",J(-n))),s.setAttribute("voffset",J(n)),s}});var fn=["\\tiny","\\sixptsize","\\scriptsize","\\footnotesize","\\small","\\normalsize","\\large","\\Large","\\LARGE","\\huge","\\Huge"];Xt({type:"sizing",names:fn,numArgs:0,allowedInText:!0,handler:(e,t)=>{var r=e.breakOnTokenText,a=e.funcName,n=e.parser,i=n.parseExpression(!1,r);return{type:"sizing",mode:n.mode,size:fn.indexOf(a)+1,body:i}},htmlBuilder:(e,t)=>{var r=t.havingSize(e.size);return gn(e.body,r,t)},mathmlBuilder:(e,t)=>{var r=t.havingSize(e.size),a=xr(e.body,r),n=new mr("mstyle",a);return n.setAttribute("mathsize",J(r.sizeMultiplier)),n}}),Xt({type:"smash",names:["\\smash"],numArgs:1,numOptionalArgs:1,allowedInText:!0,handler:(e,t,r)=>{var a=e.parser,n=!1,i=!1,o=r[0]&&Fr(r[0],"ordgroup");if(o)for(var s,l=0;l<o.body.length;++l){if("t"===(s=Vr(o.body[l]).text))n=!0;else{if("b"!==s){n=!1,i=!1;break}i=!0}}else n=!0,i=!0;var h=t[0];return{type:"smash",mode:a.mode,body:h,smashHeight:n,smashDepth:i}},htmlBuilder:(e,t)=>{var r=Mt([],[or(e.body,t)]);if(!e.smashHeight&&!e.smashDepth)return r;if(e.smashHeight&&(r.height=0),e.smashDepth&&(r.depth=0),e.smashHeight&&e.smashDepth)return Mt(["mord","katex-smash"],[r],t);if(r.children)for(var a=0;a<r.children.length;a++)e.smashHeight&&(r.children[a].height=0),e.smashDepth&&(r.children[a].depth=0);var n=Ot({positionType:"firstBaseline",children:[{type:"elem",elem:r}]});return Mt(["mord"],[n],t)},mathmlBuilder:(e,t)=>{var r=new mr("mpadded",[kr(e.body,t)]);return e.smashHeight&&r.setAttribute("height","0px"),e.smashDepth&&r.setAttribute("depth","0px"),r}}),Xt({type:"sqrt",names:["\\sqrt"],numArgs:1,numOptionalArgs:1,handler(e,t,r){var a=e.parser,n=r[0],i=t[0];return{type:"sqrt",mode:a.mode,body:i,index:n}},htmlBuilder(e,t){var r=or(e.body,t.havingCrampedStyle());0===r.height&&(r.height=t.fontMetrics().xHeight),r=qt(r,t);var a=t.fontMetrics().defaultRuleThickness,n=a;t.style.id<q.TEXT.id&&(n=t.fontMetrics().xHeight);var i=a+n/4,o=r.height+r.depth+i+a,s=ya(o,t),l=s.span,h=s.ruleWidth,m=s.advanceWidth,c=l.height-h;c>r.height+r.depth+i&&(i=(i+c-r.height-r.depth)/2);var u=l.height-r.height-i-h;r.style.paddingLeft=J(m);var p=Ot({positionType:"firstBaseline",children:[{type:"elem",elem:r,wrapperClasses:["svg-align"]},{type:"kern",size:-(r.height+u)},{type:"elem",elem:l},{type:"kern",size:h}]});if(e.index){var d=t.havingStyle(q.SCRIPTSCRIPT),g=or(e.index,d,t),f=.6*(p.height-p.depth),v=Ot({positionType:"shift",positionData:-f,children:[{type:"elem",elem:g}]}),b=Mt(["katex-root"],[v]);return Mt(["mord","sqrt"],[b,p],t)}return Mt(["mord","sqrt"],[p],t)},mathmlBuilder(e,t){var r=e.body,a=e.index;return a?new mr("mroot",[kr(r,t),kr(a,t)]):new mr("msqrt",[kr(r,t)])}});var vn={display:q.DISPLAY,text:q.TEXT,script:q.SCRIPT,scriptscript:q.SCRIPTSCRIPT};Xt({type:"styling",names:["\\displaystyle","\\textstyle","\\scriptstyle","\\scriptscriptstyle"],numArgs:0,allowedInText:!0,primitive:!0,handler(e,t){var r=e.breakOnTokenText,a=e.funcName,n=e.parser,i=n.parseExpression(!0,r),o=a.slice(1,a.length-5);if(!(o in vn))throw new Error("Unknown style: "+o);return{type:"styling",mode:n.mode,style:o,body:i}},htmlBuilder(e,t){var r=vn[e.style],a=t.havingStyle(r);return e.resetFont&&(a=a.withFont('')),gn(e.body,a,t)},mathmlBuilder(e,t){var r=vn[e.style],a=t.havingStyle(r);e.resetFont&&(a=a.withFont(''));var n=xr(e.body,a),i=new mr("mstyle",n),o={display:["0","true"],text:["0","false"],script:["1","false"],scriptscript:["2","false"]}[e.style];return i.setAttribute("scriptlevel",o[0]),i.setAttribute("displaystyle",o[1]),i}});var bn=function(e,t){var r=e.base;return r?"op"===r.type?r.limits&&(t.style.size===q.DISPLAY.size||r.alwaysHandleSupSub)?mn:null:"operatorname"===r.type?r.alwaysHandleSupSub&&(t.style.size===q.DISPLAY.size||r.limits)?pn:null:"accent"===r.type?g(r.base)?_r:null:"horizBrace"===r.type&&!e.sub===r.isOver?nn:null:null};Yt({type:"supsub",htmlBuilder(e,t){var r=bn(e,t);if(r)return r(e,t);var a,n,i,o=e.base,s=e.sup,l=e.sub,h=or(o,t),m=t.fontMetrics(),c=0,u=0,p=o&&g(o);if(s){var d=t.havingStyle(t.style.sup());a=or(s,d,t),p||(c=h.height-d.fontMetrics().supDrop*d.sizeMultiplier/t.sizeMultiplier)}if(l){var f=t.havingStyle(t.style.sub());n=or(l,f,t),p||(u=h.depth+f.fontMetrics().subDrop*f.sizeMultiplier/t.sizeMultiplier)}i=t.style===q.DISPLAY?m.sup1:t.style.cramped?m.sup3:m.sup2;var v,b=t.sizeMultiplier,y=J(.5/m.ptPerEm/b),x=null;if(n){var w,k=e.base&&"op"===e.base.type&&e.base.name&&("\\oiint"===e.base.name||"\\oiiint"===e.base.name);if(h instanceof he||k)x=J(-(null!=(w=h.italic)?w:0))}if(a&&n){c=Math.max(c,i,a.depth+.25*m.xHeight),u=Math.max(u,m.sub2);var S=4*m.defaultRuleThickness;if(c-a.depth-(n.height-u)<S){u=S-(c-a.depth)+n.height;var z=.8*m.xHeight-(c-a.depth);z>0&&(c+=z,u-=z)}v=Ot({positionType:"individualShift",children:[{type:"elem",elem:n,shift:u,marginRight:y,marginLeft:x},{type:"elem",elem:a,shift:-c,marginRight:y}]})}else if(n){u=Math.max(u,m.sub1,n.height-.8*m.xHeight),v=Ot({positionType:"shift",positionData:u,children:[{type:"elem",elem:n,marginLeft:x,marginRight:y}]})}else{if(!a)throw new Error("supsub must have either sup or sub.");c=Math.max(c,i,a.depth+.25*m.xHeight),v=Ot({positionType:"shift",positionData:-c,children:[{type:"elem",elem:a,marginRight:y}]})}var M=nr(h,"right")||"mord";return Mt([M],[h,Mt(["msupsub"],[v])],t)},mathmlBuilder(e,t){var r,a=!1;e.base&&"horizBrace"===e.base.type&&!!e.sup===e.base.isOver&&(a=!0,r=e.base.isOver),!e.base||"op"!==e.base.type&&"operatorname"!==e.base.type||(e.base.parentIsSupSub=!0);var n,i=[kr(e.base,t)];if(e.sub&&i.push(kr(e.sub,t)),e.sup&&i.push(kr(e.sup,t)),a)n=r?"mover":"munder";else if(e.sub)if(e.sup){var o=e.base;n=o&&"op"===o.type&&o.limits&&t.style===q.DISPLAY||o&&"operatorname"===o.type&&o.alwaysHandleSupSub&&(t.style===q.DISPLAY||o.limits)?"munderover":"msubsup"}else{var s=e.base;n=s&&"op"===s.type&&s.limits&&(t.style===q.DISPLAY||s.alwaysHandleSupSub)||s&&"operatorname"===s.type&&s.alwaysHandleSupSub&&(s.limits||t.style===q.DISPLAY)?"munder":"msub"}else{var l=e.base;n=l&&"op"===l.type&&l.limits&&(t.style===q.DISPLAY||l.alwaysHandleSupSub)||l&&"operatorname"===l.type&&l.alwaysHandleSupSub&&(l.limits||t.style===q.DISPLAY)?"mover":"msup"}return new mr(n,i)}}),Yt({type:"atom",htmlBuilder:(e,t)=>yt(e.text,e.mode,t,["m"+e.family]),mathmlBuilder(e,t){var r=new mr("mo",[gr(e.text,e.mode)]);if("bin"===e.family){var a=br(e,t);"bold-italic"===a&&r.setAttribute("mathvariant",a)}else"punct"===e.family?r.setAttribute("separator","true"):"open"!==e.family&&"close"!==e.family||r.setAttribute("stretchy","false");return r}});var yn={mi:"italic",mn:"normal",mtext:"normal"};Yt({type:"mathord",htmlBuilder:(e,t)=>wt(e,t),mathmlBuilder(e,t){var r=new mr("mi",[gr(e.text,e.mode,t)]),a=br(e,t)||"italic";return a!==yn[r.type]&&r.setAttribute("mathvariant",a),r}}),Yt({type:"textord",htmlBuilder:(e,t)=>wt(e,t),mathmlBuilder(e,t){var r,a=gr(e.text,e.mode,t),n=br(e,t)||"normal";return r='text'===e.mode?new mr("mtext",[a]):/[0-9]/.test(e.text)?new mr("mn",[a]):"\\prime"===e.text?new mr("mo",[a]):new mr("mi",[a]),n!==yn[r.type]&&r.setAttribute("mathvariant",n),r}});var xn=new Map([["\\nobreak","nobreak"],["\\allowbreak","allowbreak"]]),wn=new Map([[" ",{}],["\\ ",{}],["~",{className:"nobreak"}],["\\space",{}],["\\nobreakspace",{className:"nobreak"}]]);Yt({type:"spacing",htmlBuilder(e,t){var r=wn.get(e.text),a=xn.get(e.text);if(r){var n=r.className||"";if("text"===e.mode){var i=wt(e,t);return i.classes.push(n),i}return Mt(["mspace",n],[yt(e.text,e.mode,t)],t)}if(a)return Mt(["mspace",a],[],t);throw new s("Unknown type of space \""+e.text+"\"")},mathmlBuilder(e,t){if(!wn.has(e.text)){if(xn.has(e.text))return new mr("mspace");throw new s("Unknown type of space \""+e.text+"\"")}return new mr("mtext",[new cr("\xa0")])}});var kn=()=>{var e=new mr("mtd",[]);return e.setAttribute("width","50%"),e};Yt({type:"tag",mathmlBuilder(e,t){var r=new mr("mtable",[new mr("mtr",[kn(),new mr("mtd",[wr(e.body,t)]),kn(),new mr("mtd",[wr(e.tag,t)])])]);return r.setAttribute("width","100%"),r}});var Sn={"\\text":void 0,"\\textrm":"textrm","\\textsf":"textsf","\\texttt":"texttt","\\textnormal":"textrm"},zn={"\\textbf":"textbf","\\textmd":"textmd"},Mn={"\\textit":"textit","\\textup":"textup"},An=(e,t)=>{var r=e.font;return r?Sn[r]?t.withTextFontFamily(Sn[r]):zn[r]?t.withTextFontWeight(zn[r]):"\\emph"===r?"textit"===t.fontShape?t.withTextFontShape("textup"):t.withTextFontShape("textit"):t.withTextFontShape(Mn[r]):t};Xt({type:"text",names:["\\text","\\textrm","\\textsf","\\texttt","\\textnormal","\\textbf","\\textmd","\\textit","\\textup","\\emph"],numArgs:1,argTypes:["text"],allowedInArgument:!0,allowedInText:!0,handler(e,t){var r=e.parser,a=e.funcName,n=t[0];return{type:"text",mode:r.mode,body:$t(n),font:a}},htmlBuilder(e,t){var r=An(e,t),a=er(e.body,r,!0);return Mt(["mord","text"],a,r)},mathmlBuilder(e,t){var r=An(e,t);return wr(e.body,r)}}),Xt({type:"underline",names:["\\underline"],numArgs:1,allowedInText:!0,handler:(e,t)=>({type:"underline",mode:e.parser.mode,body:t[0]}),htmlBuilder(e,t){var r=or(e.body,t),a=Tt("underline-line",t),n=t.fontMetrics().defaultRuleThickness,i=Ot({positionType:"top",positionData:r.height,children:[{type:"kern",size:n},{type:"elem",elem:a},{type:"kern",size:3*n},{type:"elem",elem:r}]});return Mt(["mord","katex-underline"],[i],t)},mathmlBuilder(e,t){var r=new mr("mo",[new cr("\u203e")]);r.setAttribute("stretchy","true");var a=new mr("munder",[kr(e.body,t),r]);return a.setAttribute("accentunder","true"),a}}),Xt({type:"vcenter",names:["\\vcenter"],numArgs:1,argTypes:["original"],allowedInText:!1,handler:(e,t)=>({type:"vcenter",mode:e.parser.mode,body:t[0]}),htmlBuilder(e,t){var r=or(e.body,t),a=t.fontMetrics().axisHeight,n=.5*(r.height-a-(r.depth+a));return Ot({positionType:"shift",positionData:n,children:[{type:"elem",elem:r}]})},mathmlBuilder(e,t){var r=new mr("mpadded",[kr(e.body,t)],["vcenter"]);return new mr("mrow",[r])}}),Xt({type:"verb",names:["\\verb"],numArgs:0,allowedInText:!0,handler(e,t,r){throw new s("\\verb ended by end of line instead of matching delimiter")},htmlBuilder(e,t){for(var r=Tn(e),a=[],n=t.havingStyle(t.style.text()),i=0;i<r.length;i++){var o=r[i];'~'===o&&(o='\\textasciitilde'),a.push(bt(o,"Typewriter-Regular",e.mode,n,["mord","texttt"]))}return Mt(["mord","text"].concat(n.sizingClasses(t)),St(a),n)},mathmlBuilder(e,t){var r=new cr(Tn(e)),a=new mr("mtext",[r]);return a.setAttribute("mathvariant","monospace"),a}});var Tn=e=>e.body.replace(/ /g,e.star?'\u2423':'\xa0'),Cn=jt,Bn=new RegExp("[\u0300-\u036f]+$");class qn{constructor(e,t){this.input=void 0,this.settings=void 0,this.tokenRegex=void 0,this.catcodes=void 0,this.input=e,this.settings=t,this.tokenRegex=new RegExp("([ \r\n\t]+)|\\\\(\n|[ \r\t]+\n?)[ \r\t]*|([!-\\[\\]-\u2027\u202a-\ud7ff\uf900-\uffff][\u0300-\u036f]*|[\ud800-\udbff][\udc00-\udfff][\u0300-\u036f]*|\\\\verb\\*([^]).*?\\4|\\\\verb([^*a-zA-Z]).*?\\5|(\\\\[a-zA-Z@]+)[ \r\n\t]*|\\\\[^\ud800-\udfff])",'g'),this.catcodes={"%":14,"~":13}}setCatcode(e,t){this.catcodes[e]=t}lex(){var e=this.input,t=this.tokenRegex.lastIndex;if(t===e.length)return new Ga("EOF",new Va(this,t,t));var r=this.tokenRegex.exec(e);if(null===r||r.index!==t)throw new s("Unexpected character: '"+e[t]+"'",new Ga(e[t],new Va(this,t,t+1)));var a=r[6]||r[3]||(r[2]?"\\ ":" ");if(14===this.catcodes[a]){var n=e.indexOf('\n',this.tokenRegex.lastIndex);return-1===n?(this.tokenRegex.lastIndex=e.length,this.settings.reportNonstrict("commentAtEnd","% comment has no terminating newline; LaTeX would fail because of commenting the end of math mode (e.g. $)")):this.tokenRegex.lastIndex=n+1,this.lex()}return new Ga(a,new Va(this,t,this.tokenRegex.lastIndex))}}class In{constructor(e,t){void 0===e&&(e={}),void 0===t&&(t={}),this.current=void 0,this.builtins=void 0,this.undefStack=void 0,this.current=t,this.builtins=e,this.undefStack=[]}beginGroup(){this.undefStack.push({})}endGroup(){if(0===this.undefStack.length)throw new s("Unbalanced namespace destruction: attempt to pop global namespace; please report this as a bug");var e=this.undefStack.pop();for(var t of Object.keys(e))void 0===e[t]?delete this.current[t]:this.current[t]=e[t]}endGroups(){for(;this.undefStack.length>0;)this.endGroup()}has(e){return Object.prototype.hasOwnProperty.call(this.current,e)||Object.prototype.hasOwnProperty.call(this.builtins,e)}get(e){return Object.prototype.hasOwnProperty.call(this.current,e)?this.current[e]:Object.prototype.hasOwnProperty.call(this.builtins,e)?this.builtins[e]:void 0}set(e,t,r){if(void 0===r&&(r=!1),r){for(var a=0;a<this.undefStack.length;a++)delete this.undefStack[a][e];this.undefStack.length>0&&(this.undefStack[this.undefStack.length-1][e]=t)}else{var n=this.undefStack[this.undefStack.length-1];n&&!Object.prototype.hasOwnProperty.call(n,e)&&(n[e]=Object.prototype.hasOwnProperty.call(this.current,e)?this.current[e]:void 0)}null==t?delete this.current[e]:this.current[e]=t}}var On=Pa;Fa("\\noexpand",function(e){var t=e.popToken();return e.isExpandable(t.text)&&(t.noexpand=!0,t.treatAsRelax=!0),{tokens:[t],numArgs:0}}),Fa("\\expandafter",function(e){var t=e.popToken();return e.expandOnce(!0),{tokens:[t],numArgs:0}}),Fa("\\@firstoftwo",function(e){return{tokens:e.consumeArgs(2)[0],numArgs:0}}),Fa("\\@secondoftwo",function(e){return{tokens:e.consumeArgs(2)[1],numArgs:0}}),Fa("\\@ifnextchar",function(e){var t=e.consumeArgs(3);e.consumeSpaces();var r=e.future();return 1===t[0].length&&t[0][0].text===r.text?{tokens:t[1],numArgs:0}:{tokens:t[2],numArgs:0}}),Fa("\\@ifstar","\\@ifnextchar *{\\@firstoftwo{#1}}"),Fa("\\TextOrMath",function(e){var t=e.consumeArgs(2);return'text'===e.mode?{tokens:t[0],numArgs:0}:{tokens:t[1],numArgs:0}});var Rn={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,a:10,A:10,b:11,B:11,c:12,C:12,d:13,D:13,e:14,E:14,f:15,F:15};Fa("\\char",function(e){var t,r=e.popToken(),a=0;if("'"===r.text)t=8,r=e.popToken();else if('"'===r.text)t=16,r=e.popToken();else if("`"===r.text)if("\\"===(r=e.popToken()).text[0])a=r.text.charCodeAt(1);else{if("EOF"===r.text)throw new s("\\char` missing argument");a=r.text.charCodeAt(0)}else t=10;if(t){if(null==(a=Rn[r.text])||a>=t)throw new s("Invalid base-"+t+" digit "+r.text);for(var n;null!=(n=Rn[e.future().text])&&n<t;)a*=t,a+=n,e.popToken()}return"\\@char{"+a+"}"});var En=(e,t,r,a)=>{var n=e.consumeArg().tokens;if(1!==n.length)throw new s("\\newcommand's first argument must be a macro name");var i=n[0].text,o=e.isDefined(i);if(o&&!t)throw new s("\\newcommand{"+i+"} attempting to redefine "+i+"; use \\renewcommand");if(!o&&!r)throw new s("\\renewcommand{"+i+"} when command "+i+" does not yet exist; use \\newcommand");var l=0;if(1===(n=e.consumeArg().tokens).length&&"["===n[0].text){for(var h='',m=e.expandNextToken();"]"!==m.text&&"EOF"!==m.text;)h+=m.text,m=e.expandNextToken();if(!h.match(/^\s*[0-9]+\s*$/))throw new s("Invalid number of arguments: "+h);l=parseInt(h),n=e.consumeArg().tokens}return o&&a||e.macros.set(i,{tokens:n,numArgs:l}),''};Fa("\\newcommand",e=>En(e,!1,!0,!1)),Fa("\\renewcommand",e=>En(e,!0,!1,!1)),Fa("\\providecommand",e=>En(e,!0,!0,!0)),Fa("\\message",e=>{var t=e.consumeArgs(1)[0];return console.log(t.reverse().map(e=>e.text).join("")),''}),Fa("\\errmessage",e=>{var t=e.consumeArgs(1)[0];return console.error(t.reverse().map(e=>e.text).join("")),''}),Fa("\\show",e=>{var t=e.popToken(),r=t.text;return console.log(t,e.macros.get(r),Cn[r],ke.math[r],ke.text[r]),''}),Fa("\\bgroup","{"),Fa("\\egroup","}"),Fa("~","\\nobreakspace"),Fa("\\lq","`"),Fa("\\rq","'"),Fa("\\aa","\\r a"),Fa("\\AA","\\r A"),Fa("\\textcopyright","\\html@mathml{\\textcircled{c}}{\\char`\xa9}"),Fa("\\copyright","\\TextOrMath{\\textcopyright}{\\text{\\textcopyright}}"),Fa("\\textregistered","\\html@mathml{\\textcircled{\\scriptsize R}}{\\char`\xae}"),Fa("\u212c","\\mathscr{B}"),Fa("\u2130","\\mathscr{E}"),Fa("\u2131","\\mathscr{F}"),Fa("\u210b","\\mathscr{H}"),Fa("\u2110","\\mathscr{I}"),Fa("\u2112","\\mathscr{L}"),Fa("\u2133","\\mathscr{M}"),Fa("\u211b","\\mathscr{R}"),Fa("\u212d","\\mathfrak{C}"),Fa("\u210c","\\mathfrak{H}"),Fa("\u2128","\\mathfrak{Z}"),Fa("\\Bbbk","\\Bbb{k}"),Fa("\\llap","\\mathllap{\\textrm{#1}}"),Fa("\\rlap","\\mathrlap{\\textrm{#1}}"),Fa("\\clap","\\mathclap{\\textrm{#1}}"),Fa("\\mathstrut","\\vphantom{(}"),Fa("\\underbar","\\underline{\\text{#1}}"),Fa("\\not","\\html@mathml{\\mathrel{\\mathrlap\\@not}\\nobreak}{\\char\"338}"),Fa("\\neq","\\html@mathml{\\mathrel{\\not=}}{\\mathrel{\\char`\u2260}}"),Fa("\\ne","\\neq"),Fa("\u2260","\\neq"),Fa("\\notin","\\html@mathml{\\mathrel{{\\in}\\mathllap{/\\mskip1mu}}}{\\mathrel{\\char`\u2209}}"),Fa("\u2209","\\notin"),Fa("\u2258","\\html@mathml{\\mathrel{=\\kern{-1em}\\raisebox{0.4em}{$\\scriptsize\\frown$}}}{\\mathrel{\\char`\u2258}}"),Fa("\u2259","\\html@mathml{\\stackrel{\\tiny\\wedge}{=}}{\\mathrel{\\char`\u2258}}"),Fa("\u225a","\\html@mathml{\\stackrel{\\tiny\\vee}{=}}{\\mathrel{\\char`\u225a}}"),Fa("\u225b","\\html@mathml{\\stackrel{\\scriptsize\\star}{=}}{\\mathrel{\\char`\u225b}}"),Fa("\u225d","\\html@mathml{\\stackrel{\\tiny\\mathrm{def}}{=}}{\\mathrel{\\char`\u225d}}"),Fa("\u225e","\\html@mathml{\\stackrel{\\tiny\\mathrm{m}}{=}}{\\mathrel{\\char`\u225e}}"),Fa("\u225f","\\html@mathml{\\stackrel{\\tiny?}{=}}{\\mathrel{\\char`\u225f}}"),Fa("\u27c2","\\perp"),Fa("\u203c","\\mathclose{!\\mkern-0.8mu!}"),Fa("\u220c","\\notni"),Fa("\u231c","\\ulcorner"),Fa("\u231d","\\urcorner"),Fa("\u231e","\\llcorner"),Fa("\u231f","\\lrcorner"),Fa("\xa9","\\copyright"),Fa("\xae","\\textregistered"),Fa("\\ulcorner","\\html@mathml{\\@ulcorner}{\\mathop{\\char\"231c}}"),Fa("\\urcorner","\\html@mathml{\\@urcorner}{\\mathop{\\char\"231d}}"),Fa("\\llcorner","\\html@mathml{\\@llcorner}{\\mathop{\\char\"231e}}"),Fa("\\lrcorner","\\html@mathml{\\@lrcorner}{\\mathop{\\char\"231f}}"),Fa("\\vdots","{\\varvdots\\rule{0pt}{15pt}}"),Fa("\u22ee","\\vdots"),Fa("\\varGamma","\\mathit{\\Gamma}"),Fa("\\varDelta","\\mathit{\\Delta}"),Fa("\\varTheta","\\mathit{\\Theta}"),Fa("\\varLambda","\\mathit{\\Lambda}"),Fa("\\varXi","\\mathit{\\Xi}"),Fa("\\varPi","\\mathit{\\Pi}"),Fa("\\varSigma","\\mathit{\\Sigma}"),Fa("\\varUpsilon","\\mathit{\\Upsilon}"),Fa("\\varPhi","\\mathit{\\Phi}"),Fa("\\varPsi","\\mathit{\\Psi}"),Fa("\\varOmega","\\mathit{\\Omega}"),Fa("\\substack","\\begin{subarray}{c}#1\\end{subarray}"),Fa("\\colon","\\nobreak\\mskip2mu\\mathpunct{}\\mathchoice{\\mkern-3mu}{\\mkern-3mu}{}{}{:}\\mskip6mu\\relax"),Fa("\\boxed","\\fbox{$\\displaystyle{#1}$}"),Fa("\\iff","\\DOTSB\\;\\Longleftrightarrow\\;"),Fa("\\implies","\\DOTSB\\;\\Longrightarrow\\;"),Fa("\\impliedby","\\DOTSB\\;\\Longleftarrow\\;"),Fa("\\dddot","{\\overset{\\raisebox{-0.1ex}{\\normalsize ...}}{#1}}"),Fa("\\ddddot","{\\overset{\\raisebox{-0.1ex}{\\normalsize ....}}{#1}}");var Hn={',':'\\dotsc','\\not':'\\dotsb','+':'\\dotsb','=':'\\dotsb','<':'\\dotsb','>':'\\dotsb','-':'\\dotsb','*':'\\dotsb',':':'\\dotsb','\\DOTSB':'\\dotsb','\\coprod':'\\dotsb','\\bigvee':'\\dotsb','\\bigwedge':'\\dotsb','\\biguplus':'\\dotsb','\\bigcap':'\\dotsb','\\bigcup':'\\dotsb','\\prod':'\\dotsb','\\sum':'\\dotsb','\\bigotimes':'\\dotsb','\\bigoplus':'\\dotsb','\\bigodot':'\\dotsb','\\bigsqcup':'\\dotsb','\\And':'\\dotsb','\\longrightarrow':'\\dotsb','\\Longrightarrow':'\\dotsb','\\longleftarrow':'\\dotsb','\\Longleftarrow':'\\dotsb','\\longleftrightarrow':'\\dotsb','\\Longleftrightarrow':'\\dotsb','\\mapsto':'\\dotsb','\\longmapsto':'\\dotsb','\\hookrightarrow':'\\dotsb','\\doteq':'\\dotsb','\\mathbin':'\\dotsb','\\mathrel':'\\dotsb','\\relbar':'\\dotsb','\\Relbar':'\\dotsb','\\xrightarrow':'\\dotsb','\\xleftarrow':'\\dotsb','\\DOTSI':'\\dotsi','\\int':'\\dotsi','\\oint':'\\dotsi','\\iint':'\\dotsi','\\iiint':'\\dotsi','\\iiiint':'\\dotsi','\\idotsint':'\\dotsi','\\DOTSX':'\\dotsx'},Nn=new Set(['bin','rel']);Fa("\\dots",function(e){var t='\\dotso',r=e.expandAfterFuture().text;return r in Hn?t=Hn[r]:('\\not'===r.slice(0,4)||r in ke.math&&Nn.has(ke.math[r].group))&&(t='\\dotsb'),t});var Dn={')':!0,']':!0,'\\rbrack':!0,'\\}':!0,'\\rbrace':!0,'\\rangle':!0,'\\rceil':!0,'\\rfloor':!0,'\\rgroup':!0,'\\rmoustache':!0,'\\right':!0,'\\bigr':!0,'\\biggr':!0,'\\Bigr':!0,'\\Biggr':!0,$:!0,';':!0,'.':!0,',':!0};Fa("\\dotso",function(e){return e.future().text in Dn?"\\ldots\\,":"\\ldots"}),Fa("\\dotsc",function(e){var t=e.future().text;return t in Dn&&','!==t?"\\ldots\\,":"\\ldots"}),Fa("\\cdots",function(e){return e.future().text in Dn?"\\@cdots\\,":"\\@cdots"}),Fa("\\dotsb","\\cdots"),Fa("\\dotsm","\\cdots"),Fa("\\dotsi","\\!\\cdots"),Fa("\\dotsx","\\ldots\\,"),Fa("\\DOTSI","\\relax"),Fa("\\DOTSB","\\relax"),Fa("\\DOTSX","\\relax"),Fa("\\tmspace","\\TextOrMath{\\kern#1#3}{\\mskip#1#2}\\relax"),Fa("\\,","\\tmspace+{3mu}{.1667em}"),Fa("\\thinspace","\\,"),Fa("\\>","\\mskip{4mu}"),Fa("\\:","\\tmspace+{4mu}{.2222em}"),Fa("\\medspace","\\:"),Fa("\\;","\\tmspace+{5mu}{.2777em}"),Fa("\\thickspace","\\;"),Fa("\\!","\\tmspace-{3mu}{.1667em}"),Fa("\\negthinspace","\\!"),Fa("\\negmedspace","\\tmspace-{4mu}{.2222em}"),Fa("\\negthickspace","\\tmspace-{5mu}{.277em}"),Fa("\\enspace","\\kern.5em "),Fa("\\enskip","\\hskip.5em\\relax"),Fa("\\quad","\\hskip1em\\relax"),Fa("\\qquad","\\hskip2em\\relax"),Fa("\\tag","\\@ifstar\\tag@literal\\tag@paren"),Fa("\\tag@paren","\\tag@literal{({#1})}"),Fa("\\tag@literal",e=>{if(e.macros.get("\\df@tag"))throw new s("Multiple \\tag");return"\\gdef\\df@tag{\\text{#1}}"}),Fa("\\bmod","\\mathchoice{\\mskip1mu}{\\mskip1mu}{\\mskip5mu}{\\mskip5mu}\\mathbin{\\rm mod}\\mathchoice{\\mskip1mu}{\\mskip1mu}{\\mskip5mu}{\\mskip5mu}"),Fa("\\pod","\\allowbreak\\mathchoice{\\mkern18mu}{\\mkern8mu}{\\mkern8mu}{\\mkern8mu}(#1)"),Fa("\\pmod","\\pod{{\\rm mod}\\mkern6mu#1}"),Fa("\\mod","\\allowbreak\\mathchoice{\\mkern18mu}{\\mkern12mu}{\\mkern12mu}{\\mkern12mu}{\\rm mod}\\,\\,#1"),Fa("\\newline","\\\\\\relax"),Fa("\\TeX","\\textrm{\\html@mathml{T\\kern-.1667em\\raisebox{-.5ex}{E}\\kern-.125emX}{TeX}}");var Ln=J(ge['Main-Regular']["T".charCodeAt(0)][1]-.7*ge['Main-Regular']["A".charCodeAt(0)][1]);Fa("\\LaTeX","\\textrm{\\html@mathml{L\\kern-.36em\\raisebox{"+Ln+"}{\\scriptstyle A}\\kern-.15em\\TeX}{LaTeX}}"),Fa("\\KaTeX","\\textrm{\\html@mathml{K\\kern-.17em\\raisebox{"+Ln+"}{\\scriptstyle A}\\kern-.15em\\TeX}{KaTeX}}"),Fa("\\hspace","\\@ifstar\\@hspacer\\@hspace"),Fa("\\@hspace","\\hskip #1\\relax"),Fa("\\@hspacer","\\rule{0pt}{0pt}\\hskip #1\\relax"),Fa("\\ordinarycolon",":"),Fa("\\vcentcolon","\\mathrel{\\mathop\\ordinarycolon}"),Fa("\\dblcolon","\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-.9mu}\\vcentcolon}}{\\mathop{\\char\"2237}}"),Fa("\\coloneqq","\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}=}}{\\mathop{\\char\"2254}}"),Fa("\\Coloneqq","\\html@mathml{\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}=}}{\\mathop{\\char\"2237\\char\"3d}}"),Fa("\\coloneq","\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\mathrel{-}}}{\\mathop{\\char\"3a\\char\"2212}}"),Fa("\\Coloneq","\\html@mathml{\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\mathrel{-}}}{\\mathop{\\char\"2237\\char\"2212}}"),Fa("\\eqqcolon","\\html@mathml{\\mathrel{=\\mathrel{\\mkern-1.2mu}\\vcentcolon}}{\\mathop{\\char\"2255}}"),Fa("\\Eqqcolon","\\html@mathml{\\mathrel{=\\mathrel{\\mkern-1.2mu}\\dblcolon}}{\\mathop{\\char\"3d\\char\"2237}}"),Fa("\\eqcolon","\\html@mathml{\\mathrel{\\mathrel{-}\\mathrel{\\mkern-1.2mu}\\vcentcolon}}{\\mathop{\\char\"2239}}"),Fa("\\Eqcolon","\\html@mathml{\\mathrel{\\mathrel{-}\\mathrel{\\mkern-1.2mu}\\dblcolon}}{\\mathop{\\char\"2212\\char\"2237}}"),Fa("\\colonapprox","\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\approx}}{\\mathop{\\char\"3a\\char\"2248}}"),Fa("\\Colonapprox","\\html@mathml{\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\approx}}{\\mathop{\\char\"2237\\char\"2248}}"),Fa("\\colonsim","\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\sim}}{\\mathop{\\char\"3a\\char\"223c}}"),Fa("\\Colonsim","\\html@mathml{\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\sim}}{\\mathop{\\char\"2237\\char\"223c}}"),Fa("\u2237","\\dblcolon"),Fa("\u2239","\\eqcolon"),Fa("\u2254","\\coloneqq"),Fa("\u2255","\\eqqcolon"),Fa("\u2a74","\\Coloneqq"),Fa("\\ratio","\\vcentcolon"),Fa("\\coloncolon","\\dblcolon"),Fa("\\colonequals","\\coloneqq"),Fa("\\coloncolonequals","\\Coloneqq"),Fa("\\equalscolon","\\eqqcolon"),Fa("\\equalscoloncolon","\\Eqqcolon"),Fa("\\colonminus","\\coloneq"),Fa("\\coloncolonminus","\\Coloneq"),Fa("\\minuscolon","\\eqcolon"),Fa("\\minuscoloncolon","\\Eqcolon"),Fa("\\coloncolonapprox","\\Colonapprox"),Fa("\\coloncolonsim","\\Colonsim"),Fa("\\simcolon","\\mathrel{\\sim\\mathrel{\\mkern-1.2mu}\\vcentcolon}"),Fa("\\simcoloncolon","\\mathrel{\\sim\\mathrel{\\mkern-1.2mu}\\dblcolon}"),Fa("\\approxcolon","\\mathrel{\\approx\\mathrel{\\mkern-1.2mu}\\vcentcolon}"),Fa("\\approxcoloncolon","\\mathrel{\\approx\\mathrel{\\mkern-1.2mu}\\dblcolon}"),Fa("\\notni","\\html@mathml{\\not\\ni}{\\mathrel{\\char`\u220c}}"),Fa("\\limsup","\\DOTSB\\operatorname*{lim\\,sup}"),Fa("\\liminf","\\DOTSB\\operatorname*{lim\\,inf}"),Fa("\\injlim","\\DOTSB\\operatorname*{inj\\,lim}"),Fa("\\projlim","\\DOTSB\\operatorname*{proj\\,lim}"),Fa("\\varlimsup","\\DOTSB\\operatorname*{\\overline{lim}}"),Fa("\\varliminf","\\DOTSB\\operatorname*{\\underline{lim}}"),Fa("\\varinjlim","\\DOTSB\\operatorname*{\\underrightarrow{lim}}"),Fa("\\varprojlim","\\DOTSB\\operatorname*{\\underleftarrow{lim}}"),Fa("\\gvertneqq","\\html@mathml{\\@gvertneqq}{\u2269}"),Fa("\\lvertneqq","\\html@mathml{\\@lvertneqq}{\u2268}"),Fa("\\ngeqq","\\html@mathml{\\@ngeqq}{\u2271}"),Fa("\\ngeqslant","\\html@mathml{\\@ngeqslant}{\u2271}"),Fa("\\nleqq","\\html@mathml{\\@nleqq}{\u2270}"),Fa("\\nleqslant","\\html@mathml{\\@nleqslant}{\u2270}"),Fa("\\nshortmid","\\html@mathml{\\@nshortmid}{\u2224}"),Fa("\\nshortparallel","\\html@mathml{\\@nshortparallel}{\u2226}"),Fa("\\nsubseteqq","\\html@mathml{\\@nsubseteqq}{\u2288}"),Fa("\\nsupseteqq","\\html@mathml{\\@nsupseteqq}{\u2289}"),Fa("\\varsubsetneq","\\html@mathml{\\@varsubsetneq}{\u228a}"),Fa("\\varsubsetneqq","\\html@mathml{\\@varsubsetneqq}{\u2acb}"),Fa("\\varsupsetneq","\\html@mathml{\\@varsupsetneq}{\u228b}"),Fa("\\varsupsetneqq","\\html@mathml{\\@varsupsetneqq}{\u2acc}"),Fa("\\imath","\\html@mathml{\\@imath}{\u0131}"),Fa("\\jmath","\\html@mathml{\\@jmath}{\u0237}"),Fa("\\llbracket","\\html@mathml{\\mathopen{[\\mkern-3.2mu[}}{\\mathopen{\\char`\u27e6}}"),Fa("\\rrbracket","\\html@mathml{\\mathclose{]\\mkern-3.2mu]}}{\\mathclose{\\char`\u27e7}}"),Fa("\u27e6","\\llbracket"),Fa("\u27e7","\\rrbracket"),Fa("\\lBrace","\\html@mathml{\\mathopen{\\{\\mkern-3.2mu[}}{\\mathopen{\\char`\u2983}}"),Fa("\\rBrace","\\html@mathml{\\mathclose{]\\mkern-3.2mu\\}}}{\\mathclose{\\char`\u2984}}"),Fa("\u21a4","\\mapsfrom"),Fa("\\mapsfrom","\\html@mathml{\\mathrel{\\mathreflectbox{\\mapsto}}}{\\mathrel{\\char`\u21a4}}"),Fa("\u2983","\\lBrace"),Fa("\u2984","\\rBrace"),Fa("\\minuso","\\mathbin{\\html@mathml{{\\mathrlap{\\mathchoice{\\kern{0.145em}}{\\kern{0.145em}}{\\kern{0.1015em}}{\\kern{0.0725em}}\\circ}{-}}}{\\char`\u29b5}}"),Fa("\u29b5","\\minuso"),Fa("\\darr","\\downarrow"),Fa("\\dArr","\\Downarrow"),Fa("\\Darr","\\Downarrow"),Fa("\\lang","\\langle"),Fa("\\rang","\\rangle"),Fa("\\uarr","\\uparrow"),Fa("\\uArr","\\Uparrow"),Fa("\\Uarr","\\Uparrow"),Fa("\\N","\\mathbb{N}"),Fa("\\R","\\mathbb{R}"),Fa("\\Z","\\mathbb{Z}"),Fa("\\alef","\\aleph"),Fa("\\alefsym","\\aleph"),Fa("\\Alpha","\\mathrm{A}"),Fa("\\Beta","\\mathrm{B}"),Fa("\\bull","\\bullet"),Fa("\\Chi","\\mathrm{X}"),Fa("\\clubs","\\clubsuit"),Fa("\\cnums","\\mathbb{C}"),Fa("\\Complex","\\mathbb{C}"),Fa("\\Dagger","\\ddagger"),Fa("\\diamonds","\\diamondsuit"),Fa("\\empty","\\emptyset"),Fa("\\Epsilon","\\mathrm{E}"),Fa("\\Eta","\\mathrm{H}"),Fa("\\exist","\\exists"),Fa("\\harr","\\leftrightarrow"),Fa("\\hArr","\\Leftrightarrow"),Fa("\\Harr","\\Leftrightarrow"),Fa("\\hearts","\\heartsuit"),Fa("\\image","\\Im"),Fa("\\infin","\\infty"),Fa("\\Iota","\\mathrm{I}"),Fa("\\isin","\\in"),Fa("\\Kappa","\\mathrm{K}"),Fa("\\larr","\\leftarrow"),Fa("\\lArr","\\Leftarrow"),Fa("\\Larr","\\Leftarrow"),Fa("\\lrarr","\\leftrightarrow"),Fa("\\lrArr","\\Leftrightarrow"),Fa("\\Lrarr","\\Leftrightarrow"),Fa("\\Mu","\\mathrm{M}"),Fa("\\natnums","\\mathbb{N}"),Fa("\\Nu","\\mathrm{N}"),Fa("\\Omicron","\\mathrm{O}"),Fa("\\plusmn","\\pm"),Fa("\\rarr","\\rightarrow"),Fa("\\rArr","\\Rightarrow"),Fa("\\Rarr","\\Rightarrow"),Fa("\\real","\\Re"),Fa("\\reals","\\mathbb{R}"),Fa("\\Reals","\\mathbb{R}"),Fa("\\Rho","\\mathrm{P}"),Fa("\\sdot","\\cdot"),Fa("\\sect","\\S"),Fa("\\spades","\\spadesuit"),Fa("\\sub","\\subset"),Fa("\\sube","\\subseteq"),Fa("\\supe","\\supseteq"),Fa("\\Tau","\\mathrm{T}"),Fa("\\thetasym","\\vartheta"),Fa("\\weierp","\\wp"),Fa("\\Zeta","\\mathrm{Z}"),Fa("\\argmin","\\DOTSB\\operatorname*{arg\\,min}"),Fa("\\argmax","\\DOTSB\\operatorname*{arg\\,max}"),Fa("\\plim","\\DOTSB\\mathop{\\operatorname{plim}}\\limits"),Fa("\\bra","\\mathinner{\\langle{#1}|}"),Fa("\\ket","\\mathinner{|{#1}\\rangle}"),Fa("\\braket","\\mathinner{\\langle{#1}\\rangle}"),Fa("\\Bra","\\left\\langle#1\\right|"),Fa("\\Ket","\\left|#1\\right\\rangle");var Pn=e=>t=>{var r=t.consumeArg().tokens,a=t.consumeArg().tokens,n=t.consumeArg().tokens,i=t.consumeArg().tokens,o=t.macros.get("|"),s=t.macros.get("\\|");t.macros.beginGroup();var l=t=>r=>{e&&(r.macros.set("|",o),n.length&&r.macros.set("\\|",s));var i=t;!t&&n.length&&("|"===r.future().text&&(r.popToken(),i=!0));return{tokens:i?n:a,numArgs:0}};t.macros.set("|",l(!1)),n.length&&t.macros.set("\\|",l(!0));var h=t.consumeArg().tokens,m=t.expandTokens([...i,...h,...r]);return t.macros.endGroup(),{tokens:m.reverse(),numArgs:0}};Fa("\\bra@ket",Pn(!1)),Fa("\\bra@set",Pn(!0)),Fa("\\Braket","\\bra@ket{\\left\\langle}{\\,\\middle\\vert\\,}{\\,\\middle\\vert\\,}{\\right\\rangle}"),Fa("\\Set","\\bra@set{\\left\\{\\:}{\\;\\middle\\vert\\;}{\\;\\middle\\Vert\\;}{\\:\\right\\}}"),Fa("\\set","\\bra@set{\\{\\,}{\\mid}{}{\\,\\}}"),Fa("\\angln","{\\angl n}"),Fa("\\blue","\\textcolor{##6495ed}{#1}"),Fa("\\orange","\\textcolor{##ffa500}{#1}"),Fa("\\pink","\\textcolor{##ff00af}{#1}"),Fa("\\red","\\textcolor{##df0030}{#1}"),Fa("\\green","\\textcolor{##28ae7b}{#1}"),Fa("\\gray","\\textcolor{gray}{#1}"),Fa("\\purple","\\textcolor{##9d38bd}{#1}"),Fa("\\blueA","\\textcolor{##ccfaff}{#1}"),Fa("\\blueB","\\textcolor{##80f6ff}{#1}"),Fa("\\blueC","\\textcolor{##63d9ea}{#1}"),Fa("\\blueD","\\textcolor{##11accd}{#1}"),Fa("\\blueE","\\textcolor{##0c7f99}{#1}"),Fa("\\tealA","\\textcolor{##94fff5}{#1}"),Fa("\\tealB","\\textcolor{##26edd5}{#1}"),Fa("\\tealC","\\textcolor{##01d1c1}{#1}"),Fa("\\tealD","\\textcolor{##01a995}{#1}"),Fa("\\tealE","\\textcolor{##208170}{#1}"),Fa("\\greenA","\\textcolor{##b6ffb0}{#1}"),Fa("\\greenB","\\textcolor{##8af281}{#1}"),Fa("\\greenC","\\textcolor{##74cf70}{#1}"),Fa("\\greenD","\\textcolor{##1fab54}{#1}"),Fa("\\greenE","\\textcolor{##0d923f}{#1}"),Fa("\\goldA","\\textcolor{##ffd0a9}{#1}"),Fa("\\goldB","\\textcolor{##ffbb71}{#1}"),Fa("\\goldC","\\textcolor{##ff9c39}{#1}"),Fa("\\goldD","\\textcolor{##e07d10}{#1}"),Fa("\\goldE","\\textcolor{##a75a05}{#1}"),Fa("\\redA","\\textcolor{##fca9a9}{#1}"),Fa("\\redB","\\textcolor{##ff8482}{#1}"),Fa("\\redC","\\textcolor{##f9685d}{#1}"),Fa("\\redD","\\textcolor{##e84d39}{#1}"),Fa("\\redE","\\textcolor{##bc2612}{#1}"),Fa("\\maroonA","\\textcolor{##ffbde0}{#1}"),Fa("\\maroonB","\\textcolor{##ff92c6}{#1}"),Fa("\\maroonC","\\textcolor{##ed5fa6}{#1}"),Fa("\\maroonD","\\textcolor{##ca337c}{#1}"),Fa("\\maroonE","\\textcolor{##9e034e}{#1}"),Fa("\\purpleA","\\textcolor{##ddd7ff}{#1}"),Fa("\\purpleB","\\textcolor{##c6b9fc}{#1}"),Fa("\\purpleC","\\textcolor{##aa87ff}{#1}"),Fa("\\purpleD","\\textcolor{##7854ab}{#1}"),Fa("\\purpleE","\\textcolor{##543b78}{#1}"),Fa("\\mintA","\\textcolor{##f5f9e8}{#1}"),Fa("\\mintB","\\textcolor{##edf2df}{#1}"),Fa("\\mintC","\\textcolor{##e0e5cc}{#1}"),Fa("\\grayA","\\textcolor{##f6f7f7}{#1}"),Fa("\\grayB","\\textcolor{##f0f1f2}{#1}"),Fa("\\grayC","\\textcolor{##e3e5e6}{#1}"),Fa("\\grayD","\\textcolor{##d6d8da}{#1}"),Fa("\\grayE","\\textcolor{##babec2}{#1}"),Fa("\\grayF","\\textcolor{##888d93}{#1}"),Fa("\\grayG","\\textcolor{##626569}{#1}"),Fa("\\grayH","\\textcolor{##3b3e40}{#1}"),Fa("\\grayI","\\textcolor{##21242c}{#1}"),Fa("\\kaBlue","\\textcolor{##314453}{#1}"),Fa("\\kaGreen","\\textcolor{##71B307}{#1}");var Fn={"^":!0,_:!0,"\\limits":!0,"\\nolimits":!0};class Vn{constructor(e,t,r){this.settings=void 0,this.expansionCount=void 0,this.lexer=void 0,this.macros=void 0,this.stack=void 0,this.mode=void 0,this.settings=t,this.expansionCount=0,this.feed(e),this.macros=new In(On,t.macros),this.mode=r,this.stack=[]}feed(e){this.lexer=new qn(e,this.settings)}switchMode(e){this.mode=e}beginGroup(){this.macros.beginGroup()}endGroup(){this.macros.endGroup()}endGroups(){this.macros.endGroups()}future(){return 0===this.stack.length&&this.pushToken(this.lexer.lex()),this.stack[this.stack.length-1]}popToken(){return this.future(),this.stack.pop()}pushToken(e){this.stack.push(e)}pushTokens(e){this.stack.push(...e)}scanArgument(e){var t,r,a;if(e){if(this.consumeSpaces(),"["!==this.future().text)return null;t=this.popToken();var n=this.consumeArg(["]"]);a=n.tokens,r=n.end}else{var i=this.consumeArg();a=i.tokens,t=i.start,r=i.end}return this.pushToken(new Ga("EOF",r.loc)),this.pushTokens(a),new Ga("",Va.range(t,r))}consumeSpaces(){for(;;){if(" "!==this.future().text)break;this.stack.pop()}}consumeArg(e){var t=[],r=e&&e.length>0;r||this.consumeSpaces();var a,n=this.future(),i=0,o=0;do{if(a=this.popToken(),t.push(a),"{"===a.text)++i;else if("}"===a.text){if(-1===--i)throw new s("Extra }",a)}else if("EOF"===a.text)throw new s("Unexpected end of input in a macro argument, expected '"+(e&&r?e[o]:"}")+"'",a);if(e&&r)if((0===i||1===i&&"{"===e[o])&&a.text===e[o]){if(++o===e.length){t.splice(-o,o);break}}else o=0}while(0!==i||r);return"{"===n.text&&"}"===t[t.length-1].text&&(t.pop(),t.shift()),t.reverse(),{tokens:t,start:n,end:a}}consumeArgs(e,t){if(t){if(t.length!==e+1)throw new s("The length of delimiters doesn't match the number of args!");for(var r=t[0],a=0;a<r.length;a++){var n=this.popToken();if(r[a]!==n.text)throw new s("Use of the macro doesn't match its definition",n)}}for(var i=[],o=0;o<e;o++)i.push(this.consumeArg(t&&t[o+1]).tokens);return i}countExpansion(e){if(this.expansionCount+=e,this.expansionCount>this.settings.maxExpand)throw new s("Too many expansions: infinite loop or need to increase maxExpand setting")}expandOnce(e){var t=this.popToken(),r=t.text,a=t.noexpand?null:this._getExpansion(r);if(null==a||e&&a.unexpandable){if(e&&null==a&&"\\"===r[0]&&!this.isDefined(r))throw new s("Undefined control sequence: "+r);return this.pushToken(t),!1}this.countExpansion(1);var n=a.tokens,i=this.consumeArgs(a.numArgs,a.delimiters);if(a.numArgs)for(var o=(n=n.slice()).length-1;o>=0;--o){var l=n[o];if("#"===l.text){if(0===o)throw new s("Incomplete placeholder at end of macro body",l);if("#"===(l=n[--o]).text)n.splice(o+1,1);else{if(!/^[1-9]$/.test(l.text))throw new s("Not a valid argument number",l);n.splice(o,2,...i[+l.text-1])}}}return this.pushTokens(n),n.length}expandAfterFuture(){return this.expandOnce(),this.future()}expandNextToken(){for(;;)if(!1===this.expandOnce()){var e=this.stack.pop();return e.treatAsRelax&&(e.text="\\relax"),e}}expandMacro(e){return this.macros.has(e)?this.expandTokens([new Ga(e)]):void 0}expandTokens(e){var t=[],r=this.stack.length;for(this.pushTokens(e);this.stack.length>r;)if(!1===this.expandOnce(!0)){var a=this.stack.pop();a.treatAsRelax&&(a.noexpand=!1,a.treatAsRelax=!1),t.push(a)}return this.countExpansion(t.length),t}expandMacroAsText(e){var t=this.expandMacro(e);return t?t.map(e=>e.text).join(""):t}_getExpansion(e){var t=this.macros.get(e);if(null==t)return t;if(1===e.length){var r=this.lexer.catcodes[e];if(null!=r&&13!==r)return}var a="function"==typeof t?t(this):t;if("string"==typeof a){var n=0;if(a.includes("#"))for(var i=a.replace(/##/g,"");i.includes("#"+(n+1));)++n;for(var o=new qn(a,this.settings),s=[],l=o.lex();"EOF"!==l.text;)s.push(l),l=o.lex();return s.reverse(),{tokens:s,numArgs:n}}return a}isDefined(e){return this.macros.has(e)||Object.prototype.hasOwnProperty.call(Cn,e)||Object.prototype.hasOwnProperty.call(ke.math,e)||Object.prototype.hasOwnProperty.call(ke.text,e)||Object.prototype.hasOwnProperty.call(Fn,e)}isExpandable(e){var t=this.macros.get(e);return null!=t?"string"==typeof t||"function"==typeof t||!t.unexpandable:Object.prototype.hasOwnProperty.call(Cn,e)&&!Cn[e].primitive}}var Gn=/^[\u208a\u208b\u208c\u208d\u208e\u2080\u2081\u2082\u2083\u2084\u2085\u2086\u2087\u2088\u2089\u2090\u2091\u2095\u1d62\u2c7c\u2096\u2097\u2098\u2099\u2092\u209a\u1d63\u209b\u209c\u1d64\u1d65\u2093\u1d66\u1d67\u1d68\u1d69\u1d6a]/,jn=Object.freeze({'\u208a':'+','\u208b':'-','\u208c':'=','\u208d':'(','\u208e':')','\u2080':'0','\u2081':'1','\u2082':'2','\u2083':'3','\u2084':'4','\u2085':'5','\u2086':'6','\u2087':'7','\u2088':'8','\u2089':'9','\u2090':'a','\u2091':'e','\u2095':'h','\u1d62':'i','\u2c7c':'j','\u2096':'k','\u2097':'l','\u2098':'m','\u2099':'n','\u2092':'o','\u209a':'p','\u1d63':'r','\u209b':'s','\u209c':'t','\u1d64':'u','\u1d65':'v','\u2093':'x','\u1d66':'\u03b2','\u1d67':'\u03b3','\u1d68':'\u03c1','\u1d69':'\u03d5','\u1d6a':'\u03c7','\u207a':'+','\u207b':'-','\u207c':'=','\u207d':'(','\u207e':')','\u2070':'0','\xb9':'1','\xb2':'2','\xb3':'3','\u2074':'4','\u2075':'5','\u2076':'6','\u2077':'7','\u2078':'8','\u2079':'9','\u1d2c':'A','\u1d2e':'B','\u1d30':'D','\u1d31':'E','\u1d33':'G','\u1d34':'H','\u1d35':'I','\u1d36':'J','\u1d37':'K','\u1d38':'L','\u1d39':'M','\u1d3a':'N','\u1d3c':'O','\u1d3e':'P','\u1d3f':'R','\u1d40':'T','\u1d41':'U','\u2c7d':'V','\u1d42':'W','\u1d43':'a','\u1d47':'b','\u1d9c':'c','\u1d48':'d','\u1d49':'e','\u1da0':'f','\u1d4d':'g','\u02b0':'h','\u2071':'i','\u02b2':'j','\u1d4f':'k','\u02e1':'l','\u1d50':'m','\u207f':'n','\u1d52':'o','\u1d56':'p','\u02b3':'r','\u02e2':'s','\u1d57':'t','\u1d58':'u','\u1d5b':'v','\u02b7':'w','\u02e3':'x','\u02b8':'y','\u1dbb':'z','\u1d5d':'\u03b2','\u1d5e':'\u03b3','\u1d5f':'\u03b4','\u1d60':'\u03d5','\u1d61':'\u03c7','\u1dbf':'\u03b8'}),Un={"\u0301":{text:"\\'",math:"\\acute"},"\u0300":{text:"\\`",math:"\\grave"},"\u0308":{text:"\\\"",math:"\\ddot"},"\u0303":{text:"\\~",math:"\\tilde"},"\u0304":{text:"\\=",math:"\\bar"},"\u0306":{text:"\\u",math:"\\breve"},"\u030c":{text:"\\v",math:"\\check"},"\u0302":{text:"\\^",math:"\\hat"},"\u0307":{text:"\\.",math:"\\dot"},"\u030a":{text:"\\r",math:"\\mathring"},"\u030b":{text:"\\H"},"\u0327":{text:"\\c"}},_n={"\xe1":"a\u0301","\xe0":"a\u0300","\xe4":"a\u0308","\u01df":"a\u0308\u0304","\xe3":"a\u0303","\u0101":"a\u0304","\u0103":"a\u0306","\u1eaf":"a\u0306\u0301","\u1eb1":"a\u0306\u0300","\u1eb5":"a\u0306\u0303","\u01ce":"a\u030c","\xe2":"a\u0302","\u1ea5":"a\u0302\u0301","\u1ea7":"a\u0302\u0300","\u1eab":"a\u0302\u0303","\u0227":"a\u0307","\u01e1":"a\u0307\u0304","\xe5":"a\u030a","\u01fb":"a\u030a\u0301","\u1e03":"b\u0307","\u0107":"c\u0301","\u1e09":"c\u0327\u0301","\u010d":"c\u030c","\u0109":"c\u0302","\u010b":"c\u0307","\xe7":"c\u0327","\u010f":"d\u030c","\u1e0b":"d\u0307","\u1e11":"d\u0327","\xe9":"e\u0301","\xe8":"e\u0300","\xeb":"e\u0308","\u1ebd":"e\u0303","\u0113":"e\u0304","\u1e17":"e\u0304\u0301","\u1e15":"e\u0304\u0300","\u0115":"e\u0306","\u1e1d":"e\u0327\u0306","\u011b":"e\u030c","\xea":"e\u0302","\u1ebf":"e\u0302\u0301","\u1ec1":"e\u0302\u0300","\u1ec5":"e\u0302\u0303","\u0117":"e\u0307","\u0229":"e\u0327","\u1e1f":"f\u0307","\u01f5":"g\u0301","\u1e21":"g\u0304","\u011f":"g\u0306","\u01e7":"g\u030c","\u011d":"g\u0302","\u0121":"g\u0307","\u0123":"g\u0327","\u1e27":"h\u0308","\u021f":"h\u030c","\u0125":"h\u0302","\u1e23":"h\u0307","\u1e29":"h\u0327","\xed":"i\u0301","\xec":"i\u0300","\xef":"i\u0308","\u1e2f":"i\u0308\u0301","\u0129":"i\u0303","\u012b":"i\u0304","\u012d":"i\u0306","\u01d0":"i\u030c","\xee":"i\u0302","\u01f0":"j\u030c","\u0135":"j\u0302","\u1e31":"k\u0301","\u01e9":"k\u030c","\u0137":"k\u0327","\u013a":"l\u0301","\u013e":"l\u030c","\u013c":"l\u0327","\u1e3f":"m\u0301","\u1e41":"m\u0307","\u0144":"n\u0301","\u01f9":"n\u0300","\xf1":"n\u0303","\u0148":"n\u030c","\u1e45":"n\u0307","\u0146":"n\u0327","\xf3":"o\u0301","\xf2":"o\u0300","\xf6":"o\u0308","\u022b":"o\u0308\u0304","\xf5":"o\u0303","\u1e4d":"o\u0303\u0301","\u1e4f":"o\u0303\u0308","\u022d":"o\u0303\u0304","\u014d":"o\u0304","\u1e53":"o\u0304\u0301","\u1e51":"o\u0304\u0300","\u014f":"o\u0306","\u01d2":"o\u030c","\xf4":"o\u0302","\u1ed1":"o\u0302\u0301","\u1ed3":"o\u0302\u0300","\u1ed7":"o\u0302\u0303","\u022f":"o\u0307","\u0231":"o\u0307\u0304","\u0151":"o\u030b","\u1e55":"p\u0301","\u1e57":"p\u0307","\u0155":"r\u0301","\u0159":"r\u030c","\u1e59":"r\u0307","\u0157":"r\u0327","\u015b":"s\u0301","\u1e65":"s\u0301\u0307","\u0161":"s\u030c","\u1e67":"s\u030c\u0307","\u015d":"s\u0302","\u1e61":"s\u0307","\u015f":"s\u0327","\u1e97":"t\u0308","\u0165":"t\u030c","\u1e6b":"t\u0307","\u0163":"t\u0327","\xfa":"u\u0301","\xf9":"u\u0300","\xfc":"u\u0308","\u01d8":"u\u0308\u0301","\u01dc":"u\u0308\u0300","\u01d6":"u\u0308\u0304","\u01da":"u\u0308\u030c","\u0169":"u\u0303","\u1e79":"u\u0303\u0301","\u016b":"u\u0304","\u1e7b":"u\u0304\u0308","\u016d":"u\u0306","\u01d4":"u\u030c","\xfb":"u\u0302","\u016f":"u\u030a","\u0171":"u\u030b","\u1e7d":"v\u0303","\u1e83":"w\u0301","\u1e81":"w\u0300","\u1e85":"w\u0308","\u0175":"w\u0302","\u1e87":"w\u0307","\u1e98":"w\u030a","\u1e8d":"x\u0308","\u1e8b":"x\u0307","\xfd":"y\u0301","\u1ef3":"y\u0300","\xff":"y\u0308","\u1ef9":"y\u0303","\u0233":"y\u0304","\u0177":"y\u0302","\u1e8f":"y\u0307","\u1e99":"y\u030a","\u017a":"z\u0301","\u017e":"z\u030c","\u1e91":"z\u0302","\u017c":"z\u0307","\xc1":"A\u0301","\xc0":"A\u0300","\xc4":"A\u0308","\u01de":"A\u0308\u0304","\xc3":"A\u0303","\u0100":"A\u0304","\u0102":"A\u0306","\u1eae":"A\u0306\u0301","\u1eb0":"A\u0306\u0300","\u1eb4":"A\u0306\u0303","\u01cd":"A\u030c","\xc2":"A\u0302","\u1ea4":"A\u0302\u0301","\u1ea6":"A\u0302\u0300","\u1eaa":"A\u0302\u0303","\u0226":"A\u0307","\u01e0":"A\u0307\u0304","\xc5":"A\u030a","\u01fa":"A\u030a\u0301","\u1e02":"B\u0307","\u0106":"C\u0301","\u1e08":"C\u0327\u0301","\u010c":"C\u030c","\u0108":"C\u0302","\u010a":"C\u0307","\xc7":"C\u0327","\u010e":"D\u030c","\u1e0a":"D\u0307","\u1e10":"D\u0327","\xc9":"E\u0301","\xc8":"E\u0300","\xcb":"E\u0308","\u1ebc":"E\u0303","\u0112":"E\u0304","\u1e16":"E\u0304\u0301","\u1e14":"E\u0304\u0300","\u0114":"E\u0306","\u1e1c":"E\u0327\u0306","\u011a":"E\u030c","\xca":"E\u0302","\u1ebe":"E\u0302\u0301","\u1ec0":"E\u0302\u0300","\u1ec4":"E\u0302\u0303","\u0116":"E\u0307","\u0228":"E\u0327","\u1e1e":"F\u0307","\u01f4":"G\u0301","\u1e20":"G\u0304","\u011e":"G\u0306","\u01e6":"G\u030c","\u011c":"G\u0302","\u0120":"G\u0307","\u0122":"G\u0327","\u1e26":"H\u0308","\u021e":"H\u030c","\u0124":"H\u0302","\u1e22":"H\u0307","\u1e28":"H\u0327","\xcd":"I\u0301","\xcc":"I\u0300","\xcf":"I\u0308","\u1e2e":"I\u0308\u0301","\u0128":"I\u0303","\u012a":"I\u0304","\u012c":"I\u0306","\u01cf":"I\u030c","\xce":"I\u0302","\u0130":"I\u0307","\u0134":"J\u0302","\u1e30":"K\u0301","\u01e8":"K\u030c","\u0136":"K\u0327","\u0139":"L\u0301","\u013d":"L\u030c","\u013b":"L\u0327","\u1e3e":"M\u0301","\u1e40":"M\u0307","\u0143":"N\u0301","\u01f8":"N\u0300","\xd1":"N\u0303","\u0147":"N\u030c","\u1e44":"N\u0307","\u0145":"N\u0327","\xd3":"O\u0301","\xd2":"O\u0300","\xd6":"O\u0308","\u022a":"O\u0308\u0304","\xd5":"O\u0303","\u1e4c":"O\u0303\u0301","\u1e4e":"O\u0303\u0308","\u022c":"O\u0303\u0304","\u014c":"O\u0304","\u1e52":"O\u0304\u0301","\u1e50":"O\u0304\u0300","\u014e":"O\u0306","\u01d1":"O\u030c","\xd4":"O\u0302","\u1ed0":"O\u0302\u0301","\u1ed2":"O\u0302\u0300","\u1ed6":"O\u0302\u0303","\u022e":"O\u0307","\u0230":"O\u0307\u0304","\u0150":"O\u030b","\u1e54":"P\u0301","\u1e56":"P\u0307","\u0154":"R\u0301","\u0158":"R\u030c","\u1e58":"R\u0307","\u0156":"R\u0327","\u015a":"S\u0301","\u1e64":"S\u0301\u0307","\u0160":"S\u030c","\u1e66":"S\u030c\u0307","\u015c":"S\u0302","\u1e60":"S\u0307","\u015e":"S\u0327","\u0164":"T\u030c","\u1e6a":"T\u0307","\u0162":"T\u0327","\xda":"U\u0301","\xd9":"U\u0300","\xdc":"U\u0308","\u01d7":"U\u0308\u0301","\u01db":"U\u0308\u0300","\u01d5":"U\u0308\u0304","\u01d9":"U\u0308\u030c","\u0168":"U\u0303","\u1e78":"U\u0303\u0301","\u016a":"U\u0304","\u1e7a":"U\u0304\u0308","\u016c":"U\u0306","\u01d3":"U\u030c","\xdb":"U\u0302","\u016e":"U\u030a","\u0170":"U\u030b","\u1e7c":"V\u0303","\u1e82":"W\u0301","\u1e80":"W\u0300","\u1e84":"W\u0308","\u0174":"W\u0302","\u1e86":"W\u0307","\u1e8c":"X\u0308","\u1e8a":"X\u0307","\xdd":"Y\u0301","\u1ef2":"Y\u0300","\u0178":"Y\u0308","\u1ef8":"Y\u0303","\u0232":"Y\u0304","\u0176":"Y\u0302","\u1e8e":"Y\u0307","\u0179":"Z\u0301","\u017d":"Z\u030c","\u1e90":"Z\u0302","\u017b":"Z\u0307","\u03ac":"\u03b1\u0301","\u1f70":"\u03b1\u0300","\u1fb1":"\u03b1\u0304","\u1fb0":"\u03b1\u0306","\u03ad":"\u03b5\u0301","\u1f72":"\u03b5\u0300","\u03ae":"\u03b7\u0301","\u1f74":"\u03b7\u0300","\u03af":"\u03b9\u0301","\u1f76":"\u03b9\u0300","\u03ca":"\u03b9\u0308","\u0390":"\u03b9\u0308\u0301","\u1fd2":"\u03b9\u0308\u0300","\u1fd1":"\u03b9\u0304","\u1fd0":"\u03b9\u0306","\u03cc":"\u03bf\u0301","\u1f78":"\u03bf\u0300","\u03cd":"\u03c5\u0301","\u1f7a":"\u03c5\u0300","\u03cb":"\u03c5\u0308","\u03b0":"\u03c5\u0308\u0301","\u1fe2":"\u03c5\u0308\u0300","\u1fe1":"\u03c5\u0304","\u1fe0":"\u03c5\u0306","\u03ce":"\u03c9\u0301","\u1f7c":"\u03c9\u0300","\u038e":"\u03a5\u0301","\u1fea":"\u03a5\u0300","\u03ab":"\u03a5\u0308","\u1fe9":"\u03a5\u0304","\u1fe8":"\u03a5\u0306","\u038f":"\u03a9\u0301","\u1ffa":"\u03a9\u0300"};class Xn{constructor(e,t){this.mode=void 0,this.gullet=void 0,this.settings=void 0,this.leftrightDepth=void 0,this.nextToken=void 0,this.mode="math",this.gullet=new Vn(e,t,this.mode),this.settings=t,this.leftrightDepth=0,this.nextToken=null}expect(e,t){if(void 0===t&&(t=!0),this.fetch().text!==e)throw new s("Expected '"+e+"', got '"+this.fetch().text+"'",this.fetch());t&&this.consume()}consume(){this.nextToken=null}fetch(){return null==this.nextToken&&(this.nextToken=this.gullet.expandNextToken()),this.nextToken}switchMode(e){this.mode=e,this.gullet.switchMode(e)}parse(){this.settings.globalGroup||this.gullet.beginGroup(),this.settings.colorIsTextColor&&this.gullet.macros.set("\\color","\\textcolor");try{var e=this.parseExpression(!1);return this.expect("EOF"),this.settings.globalGroup||this.gullet.endGroup(),e}finally{this.gullet.endGroups()}}subparse(e){var t=this.nextToken;this.consume(),this.gullet.pushToken(new Ga("}")),this.gullet.pushTokens(e);var r=this.parseExpression(!1);return this.expect("}"),this.nextToken=t,r}parseExpression(e,t){for(var r=[];;){"math"===this.mode&&this.consumeSpaces();var a=this.fetch();if(Xn.endOfExpression.has(a.text))break;if(t&&a.text===t)break;if(e&&Cn[a.text]&&Cn[a.text].infix)break;var n=this.parseAtom(t);if(!n)break;"internal"!==n.type&&r.push(n)}return"text"===this.mode&&this.formLigatures(r),this.handleInfixNodes(r)}handleInfixNodes(e){for(var t,r=-1,a=0;a<e.length;a++){var n=e[a];if("infix"===n.type){if(-1!==r)throw new s("only one infix operator per group",n.token);r=a,t=n.replaceWith}}if(-1!==r&&t){var i,o,l=e.slice(0,r),h=e.slice(r+1);return i=1===l.length&&"ordgroup"===l[0].type?l[0]:{type:"ordgroup",mode:this.mode,body:l},o=1===h.length&&"ordgroup"===h[0].type?h[0]:{type:"ordgroup",mode:this.mode,body:h},["\\\\abovefrac"===t?this.callFunction(t,[i,e[r],o],[]):this.callFunction(t,[i,o],[])]}return e}handleSupSubscript(e){var t,r=this.fetch(),a=r.text;this.consume(),this.consumeSpaces();do{var n;t=this.parseGroup(e)}while("internal"===(null==(n=t)?void 0:n.type));if(!t)throw new s("Expected group after '"+a+"'",r);return t}formatUnsupportedCmd(e){for(var t=[],r=0;r<e.length;r++)t.push({type:"textord",mode:"text",text:e[r]});var a={type:"text",mode:this.mode,body:t};return{type:"color",mode:this.mode,color:this.settings.errorColor,body:[a]}}parseAtom(e){var t,r,a=this.parseGroup("atom",e);if("internal"===(null==a?void 0:a.type))return a;if("text"===this.mode)return a;for(;;){this.consumeSpaces();var n=this.fetch();if("\\limits"===n.text||"\\nolimits"===n.text){if(a&&"op"===a.type)a.limits="\\limits"===n.text,a.alwaysHandleSupSub=!0;else{if(!a||"operatorname"!==a.type)throw new s("Limit controls must follow a math operator",n);a.alwaysHandleSupSub&&(a.limits="\\limits"===n.text)}this.consume()}else if("^"===n.text){if(t)throw new s("Double superscript",n);t=this.handleSupSubscript("superscript")}else if("_"===n.text){if(r)throw new s("Double subscript",n);r=this.handleSupSubscript("subscript")}else if("'"===n.text){if(t)throw new s("Double superscript",n);var i={type:"textord",mode:this.mode,text:"\\prime"},o=[i];for(this.consume();"'"===this.fetch().text;)o.push(i),this.consume();"^"===this.fetch().text&&o.push(this.handleSupSubscript("superscript")),t={type:"ordgroup",mode:this.mode,body:o}}else{if(!jn[n.text])break;var l=Gn.test(n.text),h=[];for(h.push(new Ga(jn[n.text])),this.consume();;){var m=this.fetch().text;if(!jn[m])break;if(Gn.test(m)!==l)break;h.unshift(new Ga(jn[m])),this.consume()}var c=this.subparse(h);l?r={type:"ordgroup",mode:"math",body:c}:t={type:"ordgroup",mode:"math",body:c}}}return t&&r?{type:"supsub",mode:this.mode,base:a,sup:t,sub:r}:t?{type:"supsub",mode:this.mode,base:a,sup:t}:r?{type:"supsub",mode:this.mode,base:a,sub:r}:a}parseFunction(e,t){var r=this.fetch(),a=r.text,n=Cn[a];if(!n)return null;if(this.consume(),t&&"atom"!==t&&!n.allowedInArgument)throw new s("Got function '"+a+"' with no arguments"+(t?" as "+t:""),r);if("text"===this.mode&&!n.allowedInText)throw new s("Can't use function '"+a+"' in text mode",r);if("math"===this.mode&&!1===n.allowedInMath)throw new s("Can't use function '"+a+"' in math mode",r);var i=this.parseArguments(a,n),o=i.args,l=i.optArgs;return this.callFunction(a,o,l,r,e)}callFunction(e,t,r,a,n){var i={funcName:e,parser:this,token:a,breakOnTokenText:n},o=Cn[e];if(o&&o.handler)return o.handler(i,t,r);throw new s("No function handler for "+e)}parseArguments(e,t){var r,a=null!=(r=t.numOptionalArgs)?r:0,n=t.numArgs+a;if(0===n)return{args:[],optArgs:[]};for(var i=[],o=[],l=0;l<n;l++){var h,m=null==(h=t.argTypes)?void 0:h[l],c=l<a;("primitive"in t&&t.primitive&&null==m||"sqrt"===t.type&&1===l&&null==o[0])&&(m="primitive");var u=this.parseGroupOfType("argument to '"+e+"'",m,c);if(c)o.push(u);else{if(null==u)throw new s("Null argument, please report this as a bug");i.push(u)}}return{args:i,optArgs:o}}parseGroupOfType(e,t,r){switch(t){case"color":return this.parseColorGroup(r);case"size":return this.parseSizeGroup(r);case"url":return this.parseUrlGroup(r);case"math":case"text":return this.parseArgumentGroup(r,t);case"hbox":var a=this.parseArgumentGroup(r,"text");return null!=a?{type:"styling",mode:a.mode,body:[a],style:"text",resetFont:!0}:null;case"raw":var n=this.parseStringGroup(r);return null!=n?{type:"raw",mode:"text",string:n.text}:null;case"primitive":if(r)throw new s("A primitive argument cannot be optional");var i=this.parseGroup(e);if(null==i)throw new s("Expected group as "+e,this.fetch());return i;case"original":case void 0:return this.parseArgumentGroup(r);default:throw new s("Unknown group type as "+e,this.fetch())}}consumeSpaces(){for(;" "===this.fetch().text;)this.consume()}parseStringGroup(e){var t=this.gullet.scanArgument(e);if(null==t)return null;for(var r,a="";"EOF"!==(r=this.fetch()).text;)a+=r.text,this.consume();return this.consume(),t.text=a,t}parseRegexGroup(e,t){for(var r,a=this.fetch(),n=a,i="";"EOF"!==(r=this.fetch()).text&&e.test(i+r.text);)i+=(n=r).text,this.consume();if(""===i)throw new s("Invalid "+t+": '"+a.text+"'",a);return a.range(n,i)}parseColorGroup(e){var t=this.parseStringGroup(e);if(null==t)return null;var r=/^(#[a-f0-9]{3,4}|#[a-f0-9]{6}|#[a-f0-9]{8}|[a-f0-9]{6}|[a-z]+)$/i.exec(t.text);if(!r)throw new s("Invalid color: '"+t.text+"'",t);var a=r[0];return/^[0-9a-f]{6}$/i.test(a)&&(a="#"+a),{type:"color-token",mode:this.mode,color:a}}parseSizeGroup(e){var t,r=!1;if(this.gullet.consumeSpaces(),!(t=e||"{"===this.gullet.future().text?this.parseStringGroup(e):this.parseRegexGroup(/^[-+]? *(?:$|\d+|\d+\.\d*|\.\d*) *[a-z]{0,2} *$/,"size")))return null;e||0!==t.text.length||(t.text="0pt",r=!0);var a=/([-+]?) *(\d+(?:\.\d*)?|\.\d+) *([a-z]{2})/.exec(t.text);if(!a)throw new s("Invalid size: '"+t.text+"'",t);var n={number:+(a[1]+a[2]),unit:a[3]};if(!Z(n))throw new s("Invalid unit: '"+n.unit+"'",t);return{type:"size",mode:this.mode,value:n,isBlank:r}}parseUrlGroup(e){this.gullet.lexer.setCatcode("%",13),this.gullet.lexer.setCatcode("~",12);var t=this.parseStringGroup(e);if(this.gullet.lexer.setCatcode("%",14),this.gullet.lexer.setCatcode("~",13),null==t)return null;var r=t.text.replace(/\\([#$%&~_^{}])/g,'$1');return{type:"url",mode:this.mode,url:r}}parseArgumentGroup(e,t){var r=this.gullet.scanArgument(e);if(null==r)return null;var a=this.mode;t&&this.switchMode(t),this.gullet.beginGroup();var n=this.parseExpression(!1,"EOF");this.expect("EOF"),this.gullet.endGroup();var i={type:"ordgroup",mode:this.mode,loc:r.loc,body:n};return t&&this.switchMode(a),i}parseGroup(e,t){var r,a=this.fetch(),n=a.text;if("{"===n||"\\begingroup"===n){this.consume();var i="{"===n?"}":"\\endgroup";this.gullet.beginGroup();var o=this.parseExpression(!1,i),l=this.fetch();this.expect(i),this.gullet.endGroup(),r={type:"ordgroup",mode:this.mode,loc:Va.range(a,l),body:o,semisimple:"\\begingroup"===n||void 0}}else if(null==(r=this.parseFunction(t,e)||this.parseSymbol())&&"\\"===n[0]&&!Object.prototype.hasOwnProperty.call(Fn,n)){if(this.settings.throwOnError)throw new s("Undefined control sequence: "+n,a);r=this.formatUnsupportedCmd(n),this.consume()}return r}formLigatures(e){for(var t=e.length-1,r=0;r<t;++r){var a=e[r];if("textord"===a.type){var n=a.text,i=e[r+1];if(i&&"textord"===i.type){if("-"===n&&"-"===i.text){var o=e[r+2];r+1<t&&o&&"textord"===o.type&&"-"===o.text?(e.splice(r,3,{type:"textord",mode:"text",loc:Va.range(a,o),text:"---"}),t-=2):(e.splice(r,2,{type:"textord",mode:"text",loc:Va.range(a,i),text:"--"}),t-=1)}"'"!==n&&"`"!==n||i.text!==n||(e.splice(r,2,{type:"textord",mode:"text",loc:Va.range(a,i),text:n+n}),t-=1)}}}}parseSymbol(){var e=this.fetch(),t=e.text;if(/^\\verb[^a-zA-Z]/.test(t)){this.consume();var r=t.slice(5),a="*"===r.charAt(0);if(a&&(r=r.slice(1)),r.length<2||r.charAt(0)!==r.slice(-1))throw new s("\\verb assertion failed --\n please report what input caused this bug");return{type:"verb",mode:"text",body:r=r.slice(1,-1),star:a}}Object.prototype.hasOwnProperty.call(_n,t[0])&&!ke[this.mode][t[0]]&&(this.settings.strict&&"math"===this.mode&&this.settings.reportNonstrict("unicodeTextInMathMode","Accented Unicode text character \""+t[0]+"\" used in math mode",e),t=_n[t[0]]+t.slice(1));var n,i,o=Bn.exec(t);if(o&&('i'===(t=t.substring(0,o.index))?t='\u0131':'j'===t&&(t='\u0237')),ke[this.mode][t]){this.settings.strict&&'math'===this.mode&&et.includes(t)&&this.settings.reportNonstrict("unicodeTextInMathMode","Latin-1/Unicode text character \""+t[0]+"\" used in math mode",e);var l=ke[this.mode][t].group,h=Va.range(e);i=l,n=Lr.has(i)?{type:"atom",mode:this.mode,family:l,loc:h,text:t}:{type:l,mode:this.mode,loc:h,text:t}}else{if(!(t.charCodeAt(0)>=128))return null;this.settings.strict&&(E(t.charCodeAt(0))?"math"===this.mode&&this.settings.reportNonstrict("unicodeTextInMathMode","Unicode text character \""+t[0]+"\" used in math mode",e):this.settings.reportNonstrict("unknownSymbol","Unrecognized Unicode character \""+t[0]+"\" ("+t.charCodeAt(0)+")",e)),n={type:"textord",mode:"text",loc:Va.range(e),text:t}}if(this.consume(),o)for(var m=0;m<o[0].length;m++){var c=o[0][m];if(!Un[c])throw new s("Unknown accent ' "+c+"'",e);var u=Un[c][this.mode]||Un[c].text;if(!u)throw new s("Accent "+c+" unsupported in "+this.mode+" mode",e);n={type:"accent",mode:this.mode,loc:Va.range(e),label:u,isStretchy:!1,isShifty:!0,base:n}}return n}}Xn.endOfExpression=new Set(["}","\\endgroup","\\end","\\right","&"]);var Yn=function(e,t){if(!('string'==typeof e||e instanceof String))throw new TypeError('KaTeX can only parse string typed expression');var r=new Xn(e,t);delete r.gullet.macros.current["\\df@tag"];var a=r.parse();if(delete r.gullet.macros.current["\\current@color"],delete r.gullet.macros.current["\\color"],r.gullet.macros.get("\\df@tag")){if(!t.displayMode)throw new s("\\tag works only in display equations");a=[{type:"tag",mode:"text",body:a,tag:r.subparse([new Ga("\\df@tag")])}]}return a},Wn=function(e,t,r){t.textContent="";var a=Jn(e,r).toNode();t.appendChild(a)};"undefined"!=typeof document&&"CSS1Compat"!==document.compatMode&&("undefined"!=typeof console&&console.warn("Warning: KaTeX doesn't work in quirks mode. Make sure your website has a suitable doctype."),Wn=function(){throw new s("KaTeX doesn't work in quirks mode.")});var $n=function(e,t){return Jn(e,t).toMarkup()},Zn=function(e,t){var r=new w(t);return Yn(e,r)},Kn=function(e,t,r){if(r.throwOnError||!(e instanceof s))throw e;var a=Mt(["katex-error"],[new he(t)]);return a.setAttribute("title",e.toString()),a.setAttribute("style","color:"+r.errorColor),a},Jn=function(e,t){var r=new w(t);try{var a=Yn(e,r);return qr(a,e,r)}catch(t){return Kn(t,e,r)}},Qn=function(e,t){var r=new w(t);try{var a=Yn(e,r);return Ir(a,0,r)}catch(t){return Kn(t,e,r)}},ei="0.18.10",ti={Span:ie,Anchor:oe,SymbolNode:he,SvgNode:me,PathNode:ce,LineNode:ue},ri={version:ei,render:Wn,renderToString:$n,ParseError:s,SETTINGS_SCHEMA:v,__parse:Zn,__renderToDomTree:Jn,__renderToHTMLTree:Qn,__setFontMetrics:be,__defineSymbol:Se,__defineFunction:Xt,__defineMacro:Fa,__domTree:ti}},945,[]);
1049
1049
  __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"mathFromMarkdown",{enumerable:!0,get:function(){return t.mathFromMarkdown}}),Object.defineProperty(e,"mathToMarkdown",{enumerable:!0,get:function(){return t.mathToMarkdown}});var t=r(d[0])},946,[947]);
1050
1050
  __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.mathFromMarkdown=function(){return{enter:{mathFlow:function(t){const n={type:'element',tagName:'code',properties:{className:['language-math','math-display']},children:[]};this.enter({type:'math',meta:null,value:'',data:{hName:'pre',hChildren:[n]}},t)},mathFlowFenceMeta:function(){this.buffer()},mathText:function(t){this.enter({type:'inlineMath',value:'',data:{hName:'code',hProperties:{className:['language-math','math-inline']},hChildren:[]}},t),this.buffer()}},exit:{mathFlow:function(n){const h=this.resume().replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,''),o=this.stack[this.stack.length-1];(0,t.ok)('math'===o.type),this.exit(n),o.value=h;const s=o.data.hChildren[0];(0,t.ok)('element'===s.type),(0,t.ok)('code'===s.tagName),s.children.push({type:'text',value:h}),this.data.mathFlowInside=void 0},mathFlowFence:function(){if(this.data.mathFlowInside)return;this.buffer(),this.data.mathFlowInside=!0},mathFlowFenceMeta:function(){const n=this.resume(),h=this.stack[this.stack.length-1];(0,t.ok)('math'===h.type),h.meta=n},mathFlowValue:n,mathText:function(n){const h=this.resume(),o=this.stack[this.stack.length-1];(0,t.ok)('inlineMath'===o.type),this.exit(n),o.value=h;o.data.hChildren.push({type:'text',value:h})},mathTextData:n}};function n(t){this.config.enter.data.call(this,t),this.config.exit.data.call(this,t)}},e.mathToMarkdown=function(t){let h=(t||{}).singleDollarTextMath;null==h&&(h=!0);return o.peek=function(){return'$'},{unsafe:[{character:'\r',inConstruct:'mathFlowMeta'},{character:'\n',inConstruct:'mathFlowMeta'},{character:'$',after:h?void 0:'\\$',inConstruct:'phrasing'},{character:'$',inConstruct:'mathFlowMeta'},{atBreak:!0,character:'$',after:'\\$'}],handlers:{math:function(t,h,o,s){const c=t.value||'',l=o.createTracker(s),u='$'.repeat(Math.max((0,n.longestStreak)(c,'$')+1,2)),f=o.enter('mathFlow');let p=l.move(u);if(t.meta){const n=o.enter('mathFlowMeta');p+=l.move(o.safe(t.meta,Object.assign({after:'\n',before:p,encode:['$']},l.current()))),n()}p+=l.move('\n'),c&&(p+=l.move(c+'\n'));return p+=l.move(u),f(),p},inlineMath:o}};function o(t,n,o){let s=t.value||'',c=1;for(h||c++;new RegExp('(^|[^$])'+'\\$'.repeat(c)+'([^$]|$)').test(s);)c++;const l='$'.repeat(c);/[^ \r\n]/.test(s)&&(/^[ \r\n]/.test(s)&&/[ \r\n]$/.test(s)||/^\$|\$$/.test(s))&&(s=' '+s+' ');let u=-1;for(;++u<o.unsafe.length;){const t=o.unsafe[u];if(!t.atBreak)continue;const n=o.compilePattern(t);let h;for(;h=n.exec(s);){let t=h.index;10===s.codePointAt(t)&&13===s.codePointAt(t-1)&&t--,s=s.slice(0,t)+' '+s.slice(h.index+1)}}return l+s+l}};var t=r(d[0]),n=r(d[1])},947,[865,876]);
1051
- __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.CodeView=h,e.HighlightedCode=function({content:l,lang:c,showLineNumbers:u=!1}){const{conn:f}=(0,o.useBrane)(),[p,b]=(0,n.useState)(null),x=(0,n.useRef)(0);return(0,n.useEffect)(()=>{if(!f||!c)return void b(null);const n=++x.current;(0,t.fetchHighlight)(f,l,c).then(t=>{x.current===n&&b(t)}).catch(()=>{x.current===n&&b(null)})},[f,l,c]),(0,s.jsx)(h,{content:l,highlight:p,showLineNumbers:u})};var n=r(d[0]);r(d[1]),r(d[2]);var t=r(d[3]),o=r(d[4]),l=r(d[5]),s=r(d[6]);const c="monospace";function u(n){if(n)return{fontStyle:1&n?"italic":void 0,fontWeight:2&n?"bold":void 0,textDecoration:4&n?"underline":void 0}}function h({content:t,highlight:o,line:h,lineEnd:f,showLineNumbers:p=!0}){const b=(0,n.useMemo)(()=>o?.tokens?o.tokens:t.split("\n").map(n=>[{c:n}]),[t,o]),x=o?.bg??"#0d1117",v=o?.fg??"#e0e0e0",y=h??0,j=f??h??0,k=(0,l.useHorizontalPanGuard)();return(0,s.jsx)("div",Object.assign({style:{fontFamily:c,fontSize:13,lineHeight:"19px",color:v,backgroundColor:x,borderRadius:4,padding:"8px 0",overflowX:"auto"}},k,{children:b.map((n,t)=>{const o=t+1,l=0===n.length||1===n.length&&""===n[0].c,c=y>0&&o>=y&&o<=j;return(0,s.jsxs)("div",{id:p?`L${o}`:void 0,style:{display:"flex",whiteSpace:"pre",minWidth:"max-content",backgroundColor:c?"rgba(255, 215, 0, 0.12)":void 0},children:[p&&(0,s.jsx)("span",{"data-find-skip":"",style:{display:"inline-block",minWidth:48,paddingRight:12,textAlign:"right",color:"#555",userSelect:"none"},children:o}),(0,s.jsx)("span",{style:{flex:1,paddingRight:p?12:10,paddingLeft:p?0:10},children:l?"\u200b":n.map((n,t)=>(0,s.jsx)("span",{style:Object.assign({color:n.f??v},u(n.s)),children:n.c},t))})]},o)})}))}},948,[11,116,105,745,736,759,6]);
1052
- __d(function(g,r,i,a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.DiagramView=function({source:c}){const{conn:l}=(0,n.useBrane)(),[m,v]=(0,e.useState)(void 0),h=(0,e.useRef)(0),{onNarrativePress:_}=(0,s.useMarkdownLinks)(),b=(0,u.useHorizontalPanGuard)();(0,e.useEffect)(()=>{if(!l)return void v(null);const e=++h.current;(0,t.fetchDiagram)(l,c).then(t=>{h.current===e&&v(t)}).catch(()=>{h.current===e&&v(null)})},[l,c]);const p=(0,e.useCallback)(e=>{const t=e?.target?.closest?.("a"),n=t?.getAttribute?.("href");if(!n)return;const o=/^brane:\/\/nid\/([^/]+)(?:\/(\d+))?$/.exec(n);o&&_&&(e.preventDefault?.(),_(o[1],o[2]?Number(o[2]):void 0))},[_]);return void 0===m?null:m?(f(),(0,d.jsx)("div",Object.assign({className:"brane-diagram-host",onClick:p,style:{margin:"6px 0",overflowX:"auto",overflowY:"hidden",overscrollBehaviorX:"contain",maxWidth:"100%"}},b,{dangerouslySetInnerHTML:{__html:m.svg}}))):(0,d.jsx)(o.HighlightedCode,{content:c,lang:"mermaid"})};var e=r(_d[0]);r(_d[1]);var t=r(_d[2]),n=r(_d[3]),o=r(_d[4]),s=r(_d[5]),u=r(_d[6]),c=r(_d[7]),d=r(_d[8]);let l=!1;function f(){if(l||"undefined"==typeof document)return;l=!0;const e=document.createElement("style");e.id="brane-diagram-edge-hl",e.textContent=c.DIAGRAM_EDGE_HIGHLIGHT_CSS,document.head.appendChild(e)}},949,[11,116,745,736,948,950,759,951,6]);
1051
+ __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.CodeView=h,e.HighlightedCode=function({content:l,lang:c,showLineNumbers:u=!1}){const{conn:f}=(0,o.useBrane)(),[p,b]=(0,n.useState)(null),x=(0,n.useRef)(0);return(0,n.useEffect)(()=>{if(!f||!c)return void b(null);const n=++x.current;(0,t.fetchHighlight)(f,l,c).then(t=>{x.current===n&&b(t)}).catch(()=>{x.current===n&&b(null)})},[f,l,c]),(0,s.jsx)(h,{content:l,highlight:p,showLineNumbers:u})};var n=r(d[0]);r(d[1]),r(d[2]);var t=r(d[3]),o=r(d[4]),l=r(d[5]),s=r(d[6]);const c="monospace";function u(n){if(n)return{fontStyle:1&n?"italic":void 0,fontWeight:2&n?"bold":void 0,textDecoration:4&n?"underline":void 0}}function h({content:t,highlight:o,line:h,lineEnd:f,showLineNumbers:p=!0}){const b=(0,n.useMemo)(()=>o?.tokens?o.tokens:t.split("\n").map(n=>[{c:n}]),[t,o]),x=o?.bg??"#0d1117",v=o?.fg??"#e0e0e0",y=h??0,j=f??h??0,k=(0,l.useHorizontalPanGuard)();return(0,s.jsx)("div",Object.assign({style:{fontFamily:c,fontSize:13,lineHeight:"19px",color:v,backgroundColor:x,borderRadius:4,padding:"8px 0",overflowX:"auto"}},k,{children:b.map((n,t)=>{const o=t+1,l=0===n.length||1===n.length&&""===n[0].c,c=y>0&&o>=y&&o<=j;return(0,s.jsxs)("div",{id:p?`L${o}`:void 0,style:{display:"flex",whiteSpace:"pre",minWidth:"max-content",backgroundColor:c?"rgba(255, 215, 0, 0.12)":void 0},children:[p&&(0,s.jsx)("span",{"data-find-skip":"",style:{display:"inline-block",minWidth:48,paddingRight:12,textAlign:"right",color:"#555",userSelect:"none"},children:o}),(0,s.jsx)("span",{style:{flex:1,paddingRight:p?12:10,paddingLeft:p?0:10},children:l?"\u200b":n.map((n,t)=>(0,s.jsx)("span",{style:Object.assign({color:n.f??v},u(n.s)),children:n.c},t))})]},o)})}))}},948,[11,116,105,745,736,760,6]);
1052
+ __d(function(g,r,i,a,_m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.DiagramView=function({source:c}){const{conn:l}=(0,n.useBrane)(),[m,v]=(0,e.useState)(void 0),h=(0,e.useRef)(0),{onNarrativePress:_}=(0,s.useMarkdownLinks)(),b=(0,u.useHorizontalPanGuard)();(0,e.useEffect)(()=>{if(!l)return void v(null);const e=++h.current;(0,t.fetchDiagram)(l,c).then(t=>{h.current===e&&v(t)}).catch(()=>{h.current===e&&v(null)})},[l,c]);const p=(0,e.useCallback)(e=>{const t=e?.target?.closest?.("a"),n=t?.getAttribute?.("href");if(!n)return;const o=/^brane:\/\/nid\/([^/]+)(?:\/(\d+))?$/.exec(n);o&&_&&(e.preventDefault?.(),_(o[1],o[2]?Number(o[2]):void 0))},[_]);return void 0===m?null:m?(f(),(0,d.jsx)("div",Object.assign({className:"brane-diagram-host",onClick:p,style:{margin:"6px 0",overflowX:"auto",overflowY:"hidden",overscrollBehaviorX:"contain",maxWidth:"100%"}},b,{dangerouslySetInnerHTML:{__html:m.svg}}))):(0,d.jsx)(o.HighlightedCode,{content:c,lang:"mermaid"})};var e=r(_d[0]);r(_d[1]);var t=r(_d[2]),n=r(_d[3]),o=r(_d[4]),s=r(_d[5]),u=r(_d[6]),c=r(_d[7]),d=r(_d[8]);let l=!1;function f(){if(l||"undefined"==typeof document)return;l=!0;const e=document.createElement("style");e.id="brane-diagram-edge-hl",e.textContent=c.DIAGRAM_EDGE_HIGHLIGHT_CSS,document.head.appendChild(e)}},949,[11,116,745,736,948,950,760,951,6]);
1053
1053
  __d(function(g,r,i,a,m,_e,d){"use strict";const o=["children"];Object.defineProperty(_e,'__esModule',{value:!0}),_e.MarkdownLinksProvider=function(e){let{children:n}=e,P=(0,t.default)(e,o);const v=(0,s.useContext)(u),{protocols:k}=(0,c.useBrane)(),{knownNarrativeIds:w,knownProtocols:f,onNarrativePress:N,onProtocolPress:_}=P,M=(0,s.useMemo)(()=>({knownNarrativeIds:w??v.knownNarrativeIds,knownProtocols:f??v.knownProtocols??k,onNarrativePress:N??v.onNarrativePress,onProtocolPress:_??v.onProtocolPress}),[v,k,w,f,N,_]);return(0,l.jsx)(u.Provider,{value:M,children:n})},_e.useMarkdownLinks=function(){return(0,s.useContext)(u)};var e,n=r(d[0]),t=(e=n)&&e.__esModule?e:{default:e},s=r(d[1]),c=r(d[2]),l=r(d[3]);const u=(0,s.createContext)({})},950,[167,11,736,6]);
1054
1054
  __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"DIAGRAM_EDGE_HIGHLIGHT_CSS",{enumerable:!0,get:function(){return n}});const n="\n.brane-diagram .brane-diagram-edge-hl { cursor: pointer; outline: none; }\n.brane-diagram .brane-diagram-edge-hl:hover,\n.brane-diagram .brane-diagram-edge-hl:focus { opacity: 1; }\n"},951,[]);
1055
1055
  __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"NID_PATTERN",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"NID_REF_PATTERN",{enumerable:!0,get:function(){return u}}),e.braneNidUrl=f,e.linkifyNarrativeIds=function(t,u){(0,n.linkifyRefs)(t,o(u))},e.narrativeIdLinks=function(t,u=f){return 0===t.size?{transforms:[]}:(0,n.refLinks)(o((n,f)=>t.has(n)?u(n,f):null))};var n=r(d[0]);const t="[a-z]+-[0-9a-z]{8}",u=`(${t})(?::(\\d+))?`;function f(n,t){return t?`brane://nid/${n}/${t}`:`brane://nid/${n}`}function o(n){return{pattern:u,boundary:n=>"@"!==n,resolve:t=>{const u=n(t[1],t[2]);return null===u?null:{text:t[0],href:u}}}}},952,[953]);
@@ -1072,26 +1072,28 @@ __d(function(g,r,i,_a,m,e,d){"use strict";function t(t,n){return n<=0?-1:Math.ma
1072
1072
  __d(function(g,r,_i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"HexDoc",{enumerable:!0,get:function(){return i}});var e=r(d[0]),t=r(d[1]),s=r(d[2]);function n(e){const t=atob(e),s=new Uint8Array(t.length);for(let e=0;e<t.length;e++)s[e]=t.charCodeAt(e);return s}class i{pages=new Map;pageBytes=t.HEX_PAGE_BYTES;loading=new Map;version=0;layout=0;rowBytes=t.HEX_ROW_BYTES;root=null;search=null;listeners=new Set;findAbort=null;findTimer=null;segmentsCache=null;constructor(e,t,s,i,h,o){this.conn=e,this.nid=t,this.path=s,this.size=i,this.notice=o??null,this.pages.set(h.offset,{bytes:n(h.data),eof:h.eof})}subscribe=e=>(this.listeners.add(e),()=>this.listeners.delete(e));getVersion=()=>this.version;changed(){this.version++;for(const e of[...this.listeners])e()}segments(){if(this.segmentsCache?.version!==this.version){const e=[...this.pages].map(([e,t])=>({offset:e,length:t.bytes.length,eof:t.eof}));this.segmentsCache={version:this.version,segments:(0,s.hexSegments)(e,this.size)}}return this.segmentsCache.segments}loadedBytes(){let e=0;for(const t of this.pages.values())e+=t.bytes.length;return e}isLoaded(e){return this.pages.has(e)}setRowBytes(e){e!==this.rowBytes&&(this.rowBytes=e,this.layout++,this.changed())}setRoot(e){this.root=e}ensure(t){if(this.pages.has(t))return Promise.resolve();let s=this.loading.get(t);return s||(s=(0,e.fetchFiles)(this.conn,this.nid,this.path,t).then(e=>{if("file"!==e.type||!e.hex)throw new Error("No bytes there");this.pages.set(t,{bytes:n(e.hex.data),eof:e.hex.eof}),e.notice&&(this.notice=e.notice)}).catch(e=>{this.notice=String(e?.message??e)}).finally(()=>{this.loading.delete(t),this.layout++,this.changed()}),this.loading.set(t,s),this.changed()),s}isLoading(e){return this.loading.has(e)}setQuery(e){if((this.search?.query??"")!==e){if(this.cancelFind(),!e)return this.search=null,void this.changed();this.search={query:e,from:0,starts:[],lengths:[],scanned:0,running:!0,stop:null,next:null,error:null},this.changed(),this.findTimer=setTimeout(()=>this.runFind(e,0),200)}}searchOn(){const e=this.search;if(!e||e.running||null===e.next)return;const t=e.next;this.cancelFind(),"cancelled"===e.stop?Object.assign(e,{scanned:t,running:!0,stop:null,next:null,error:null}):this.search={query:e.query,from:t,starts:[],lengths:[],scanned:t,running:!0,stop:null,next:null,error:null},this.changed(),this.runFind(e.query,t)}runFind(t,s){this.findTimer=null;const n=new AbortController;this.findAbort=n;let i=!1;const h=()=>{i=!1,this.findAbort===n&&this.changed()},o=()=>{i||(i=!0,"function"==typeof requestAnimationFrame?requestAnimationFrame(h):setTimeout(h,16))};(0,e.streamFileFind)(this.conn,this.nid,this.path,t,s,e=>{const t=this.search;if(this.findAbort===n&&t)if("hits"===e.type){for(const[s,n]of e.hits)t.starts.push(s),t.lengths.push(n);o()}else"progress"===e.type?(t.scanned=e.scanned,o()):"done"===e.type?(t.scanned=e.scanned,t.stop=e.stop,t.next=e.next):"error"===e.type&&(t.error=e.error)},n.signal).catch(e=>{!n.signal.aborted&&this.search&&(this.search.error=String(e?.message??e))}).finally(()=>{if(this.findAbort!==n)return;this.findAbort=null;const e=this.search;if(e&&(e.running=!1,null===e.stop&&!e.error)){e.stop="cancelled";const t=e.starts.length-1;e.next=t>=0?e.starts[t]+e.lengths[t]:e.from}this.changed()})}cancelFind(){this.findTimer&&clearTimeout(this.findTimer),this.findTimer=null,this.findAbort?.abort(),this.findAbort=null}dispose(){this.cancelFind(),this.search=null}}},969,[745,962,963]);
1073
1073
  __d(function(g,_r,_i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useHexFind=function({doc:n,query:h,enabled:p}){(0,t.useSyncExternalStore)(n?.subscribe??c,n?.getVersion??l);const y=n?.version??0,b=n?.layout??0,x=n?.search??null,C=x?.starts.length??0,[k,E]=(0,t.useState)(-1),R=(0,t.useRef)(-1),w=(0,t.useRef)(null),O=(0,t.useRef)(null),v=(0,t.useRef)(-1),S=(0,t.useRef)(null),A=(0,t.useRef)(new Map),H=(0,t.useRef)(null),N=()=>H.current??=(0,u.registerNames)();(0,t.useEffect)(()=>{n?.setQuery(p?h:""),p&&h||(w.current=null)},[n,h,p]),(0,t.useEffect)(()=>{w.current=null},[n]);const T=(0,t.useCallback)(t=>{const r=(0,u.highlightApi)();if(!r)return;const s=A.current.get(t);s?r.registry.set(N().current,new r.Highlight(...s)):r.registry.delete(N().current),(0,u.repaint)(n?.root??null)},[n]),B=(0,t.useCallback)((t,r)=>{const s=n?.search;t!==R.current&&(R.current=t,t>=0&&s&&(w.current=s.starts[t]),T(t)),r&&E(t)},[n,T]),M=(0,t.useCallback)(t=>{const r=n?.search;if(!(!n||!r||t<0||t>=r.starts.length)){O.current=t;for(const u of(0,s.pagesOfHit)(r.starts[t],r.lengths[t],n.pageBytes))n.ensure(u)}},[n]);(0,t.useEffect)(()=>{if(S.current!==x&&(S.current=x,R.current=-1,E(-1),O.current=null,x&&x.from>0&&(w.current=x.from)),!x||R.current>=0||0===C)return;const t=w.current??0;let r=x.starts.findIndex(r=>r>=t);if(r<0){if(x.running)return;r=0}B(r,!0),M(r)},[x,C,y,B,M]),(0,t.useEffect)(()=>{const t=(0,u.highlightApi)(),r=n?.root??null;if(!t)return;const c=N();if(A.current=new Map,!n||!r||!x||0===C)return t.registry.delete(c.all),t.registry.delete(c.current),void(0,u.repaint)(r);const l=o(r),f=[];for(let t=0;t<C;t++){const r=x.starts[t],u=x.lengths[t];if(!(0,s.pagesOfHit)(r,u,n.pageBytes).every(t=>l.has(t)))continue;const c=i(n,l,r,u);c&&(A.current.set(t,c),f.push(...c))}f.length?t.registry.set(c.all,new t.Highlight(...f)):t.registry.delete(c.all),T(R.current);const h=O.current,p=null!==h?A.current.get(h):void 0;p&&h===R.current&&(O.current=null,(0,u.applyTarget)((0,u.targetOf)(p[0])))},[n,x,C,b,T]),(0,t.useEffect)(()=>()=>{const t=(0,u.highlightApi)();t&&H.current&&(t.registry.delete(H.current.all),t.registry.delete(H.current.current))},[]);const _=(0,t.useCallback)(t=>{const r=n?.search,s=n?.root;if(!n||!r||!s)return;const c=r.starts[t],l=A.current.get(t);if(l)return void(0,u.applyTarget)((0,u.targetOf)(l[0]));const o=f(s,c);if(o){const t=document.createRange();t.selectNodeContents(o),(0,u.applyTarget)((0,u.targetOf)(t))}},[n]),q=(0,t.useCallback)(t=>{if(!C)return;const n=R.current,s=n<0?t>0?0:C-1:(0,r.clampIndex)(n+t,C);B(s,!0),_(s),M(s)},[C,B,_,M]),F=(0,t.useCallback)((t,n)=>{if(!C)return;const s=(0,r.clampIndex)(t,C);B(s,n),(s!==v.current||n)&&(v.current=s,_(s)),n&&(v.current=-1,M(s))},[C,B,_,M]),G=(0,t.useCallback)(()=>q(1),[q]),I=(0,t.useCallback)(()=>q(-1),[q]),P=(0,t.useCallback)(()=>{},[]),j=!!x&&null!==x.next&&null!==x.stop&&"eof"!==x.stop&&"reach"!==x.stop;return{count:C,current:k<C?k:-1,capped:j,lineJump:null,lineFound:!1,next:G,prev:I,seek:F,currentLine:P}};var t=_r(d[0]),r=_r(d[1]),n=_r(d[2]),s=_r(d[3]),u=_r(d[4]);const c=()=>()=>{},l=()=>0;function o(t){const r=new Map;return t.querySelectorAll("[data-hex-page]").forEach(t=>{r.set(Number(t.dataset.hexPage),t)}),r}function i(t,r,u,c){const l=t.rowBytes,o=[];for(const i of(0,s.rowSpans)(u,c,l)){const u=(0,s.pageOf)(i.row,t.pageBytes),c=r.get(u),f=c?.children[(i.row-u)/l],h=f?.children[1]?.firstChild,p=f?.children[2]?.firstChild;if(!h||!p)return null;const y=document.createRange();y.setStart(h,(0,n.hexColumnOf)(i.first,l)),y.setEnd(h,(0,n.hexColumnOf)(i.last,l)+2);const b=document.createRange();b.setStart(p,i.first),b.setEnd(p,i.last+1),o.push(y,b)}return o}function f(t,r){let n=null;return t.querySelectorAll("[data-hex-gap-from]").forEach(t=>{const s=Number(t.dataset.hexGapFrom),u=t.dataset.hexGapTo?Number(t.dataset.hexGapTo):1/0;!n&&r>=s&&r<u&&(n=t)}),n}},970,[11,968,962,963,966]);
1074
1074
  __d(function(_g,r,i,a,m,_e,_d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"HitDrum",{enumerable:!0,get:function(){return s}});var e=r(_d[0]),t=r(_d[1]),n=r(_d[2]);const c=18,o=c/(2*Math.tan(26*Math.PI/360)),u="linear-gradient(to bottom, transparent 0, #000 34%, #000 66%, transparent 100%)";const s=(0,e.forwardRef)(function({count:s,current:l,capped:p,label:d,miss:h,onSeek:f,onStaticStep:v},x){const g=void 0===d&&s>0,[b,M]=(0,e.useState)(l<0?0:l),w=(0,e.useRef)(b),S=(0,e.useRef)(0),y=(0,e.useRef)(null),I=(0,e.useRef)(0),R=(0,e.useRef)(null),k=(0,e.useRef)(Math.round(b)),P=(0,e.useRef)(null),$=(0,e.useRef)(null),Y=(0,e.useRef)(f);Y.current=f;const A=(0,e.useCallback)((e,t)=>{w.current=e,M(e);const n=Math.round(e);n!==k.current&&(k.current=n,t||navigator.vibrate?.(3)),Y.current(e,t)},[]),C=(0,e.useCallback)(()=>{I.current&&cancelAnimationFrame(I.current),I.current=0,y.current=null},[]),E=(0,e.useCallback)((e,n)=>{if(I.current&&cancelAnimationFrame(I.current),y.current=e,S.current=n,"undefined"!=typeof window&&window.matchMedia?.("(prefers-reduced-motion: reduce)").matches)return y.current=null,void A(e,!0);let c=performance.now();const o=n=>{const u=Math.min(.032,(n-c)/1e3);c=n;const s=(0,t.springStep)(w.current,S.current,e,u);if(S.current=s.v,(0,t.springAtRest)(s.x,s.v,e))return I.current=0,y.current=null,S.current=0,void A(e,!0);A(s.x,!1),I.current=requestAnimationFrame(o)};I.current=requestAnimationFrame(o)},[A]),T=(0,e.useCallback)(e=>{if(!g)return void v(e);const n=y.current??(0,t.clampIndex)(w.current,s),c=n+e;c<0||c>=s?E(n,e*t.BUMP_VELOCITY):E(c,S.current)},[g,s,v,E]);(0,e.useImperativeHandle)(x,()=>({step:T}),[T]),(0,e.useEffect)(()=>{R.current||I.current||l<0||(0,t.clampIndex)(w.current,s)!==l&&(w.current=l,k.current=l,M(l))},[l,s]),(0,e.useEffect)(()=>()=>{I.current&&cancelAnimationFrame(I.current),P.current&&clearTimeout(P.current)},[]),(0,e.useEffect)(()=>{const e=$.current;if(!e||!g)return;const n=e=>{e.preventDefault(),C();const n=1===e.deltaMode?16*e.deltaY:e.deltaY,c=Math.max(-1,Math.min(1,n/40));A((0,t.rubberBand)(w.current+c,s),!1),P.current&&clearTimeout(P.current),P.current=setTimeout(()=>E((0,t.clampIndex)(w.current,s),0),140)};return e.addEventListener("wheel",n,{passive:!1}),()=>e.removeEventListener("wheel",n)},[g,s,A,E,C]);const j=`${(0,t.compactCount)(s)}${p?"+":""}`,F=void 0!==d?Math.max(d.length,3):String(s).length+1+j.length,D=h?"#ff8a8a":"#e6e6e6",_=[];if(g){const e=Math.round(b);for(let t=Math.max(0,e-3);t<=Math.min(s-1,e+3);t++){const e=t-b,u=26*e;if(Math.abs(u)>84)continue;const s=Math.max(0,1-Math.abs(e));_.push((0,n.jsx)("div",{style:{position:"absolute",left:0,width:"100%",height:c,lineHeight:"18px",textAlign:"right",whiteSpace:"pre",transform:`rotateX(${-u}deg) translateZ(${o}px)`,backfaceVisibility:"hidden",opacity:.38+.62*s,color:s>.5?D:"#9a9a9a"},children:`${t+1}/${j}`},t))}}return(0,n.jsx)("div",{ref:$,role:g?"spinbutton":"status","aria-label":g?`Match ${(0,t.clampIndex)(b,s)+1} of ${s}${p?" or more":""}`:d,"aria-valuenow":g?(0,t.clampIndex)(b,s)+1:void 0,"aria-valuemin":g?1:void 0,"aria-valuemax":g?s:void 0,title:g?"Swipe or scroll to move between matches":void 0,onMouseDown:e=>e.preventDefault(),onPointerDown:e=>{"mouse"===e.pointerType&&0!==e.button||(C(),R.current={startY:e.clientY,startPos:w.current,moved:!1,samples:[{t:e.timeStamp,y:e.clientY}]},e.currentTarget.setPointerCapture?.(e.pointerId))},onPointerMove:e=>{const n=R.current;if(!n)return;const o=e.clientY-n.startY;!n.moved&&Math.abs(o)<=4||(n.moved=!0,n.samples.push({t:e.timeStamp,y:e.clientY}),n.samples.length>12&&n.samples.shift(),g&&A((0,t.rubberBand)(n.startPos-o/c,s),!1))},onPointerUp:e=>{const n=R.current;if(R.current=null,!n)return;if(!n.moved){const t=e.currentTarget.getBoundingClientRect();return void T(e.clientY<t.top+t.height/2?-1:1)}if(!g)return;const o=1e3*-(0,t.releaseVelocity)(n.samples,e.timeStamp)/c;E((0,t.throwTarget)(w.current,o,s),o)},onPointerCancel:()=>{R.current&&(R.current=null,g&&E((0,t.clampIndex)(w.current,s),0))},style:{position:"relative",width:`calc(${F}ch + 4px)`,height:44,margin:"-4px 4px -4px 16px",flexShrink:0,fontFamily:"ui-monospace, Menlo, monospace",fontSize:13,fontVariantNumeric:"tabular-nums",cursor:g?"ns-resize":"pointer",userSelect:"none",WebkitUserSelect:"none",touchAction:"none",perspective:160,perspectiveOrigin:"calc(100% - 4px) 50%",WebkitMaskImage:g?u:void 0,maskImage:g?u:void 0},children:g?(0,n.jsx)("div",{style:{position:"absolute",left:0,width:"calc(100% - 4px)",top:13,height:c,transformStyle:"preserve-3d",transform:`translateZ(${-o}px)`,pointerEvents:"none"},children:_}):(0,n.jsx)("div",{style:{position:"absolute",left:0,top:0,width:"calc(100% - 4px)",height:"100%",lineHeight:"44px",textAlign:"right",color:D,pointerEvents:"none"},children:d})})})},971,[11,968,6]);
1075
- __d(function(g,r,i,_a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return w}});var t=r(d[0]),l=e(r(d[1])),o=e(r(d[2])),a=e(r(d[3])),n=e(r(d[4])),s=e(r(d[5])),c=e(r(d[6])),u=e(r(d[7])),f=e(r(d[8])),h=r(d[9]),p=e(r(d[10])),x=r(d[11]);const y=["claude","gemini","goose","copilot","cline","codex","crush","amp"],b="",j={display:"block",boxSizing:"border-box",width:"100%",margin:0,backgroundColor:"#222228",color:"#d8d8dd",border:"1px solid #3a3a40",borderRadius:8,padding:"10px 36px 10px 12px",fontSize:14,fontFamily:"monospace",lineHeight:"20px",outline:"none",colorScheme:"dark",cursor:"pointer",appearance:"none",WebkitAppearance:"none",MozAppearance:"none",backgroundImage:"url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'><path d='M1 1.5l5 5 5-5' stroke='%23a8a8b0' stroke-width='1.6' fill='none' stroke-linecap='round' stroke-linejoin='round'/></svg>\")",backgroundRepeat:"no-repeat",backgroundPosition:"right 12px center",backgroundSize:"12px 8px"};function w({visible:e,conn:f,re:w,defaultFoldPath:v,onClose:C,onSpawned:R}){const[T,z]=(0,t.useState)("agent"),[k,A]=(0,t.useState)("claude"),[F,P]=(0,t.useState)([]),[B,L]=(0,t.useState)(b),[I,O]=(0,t.useState)(""),H=(0,t.useRef)(!1),[_,V]=(0,t.useState)("worker"),[W,D]=(0,t.useState)(""),[E,M]=(0,t.useState)([]),[$,U]=(0,t.useState)(null),[q,G]=(0,t.useState)([]),[N,J]=(0,t.useState)(!1),[K,Q]=(0,t.useState)(!1),[X,Y]=(0,t.useState)(!1),[Z,ee]=(0,t.useState)(""),[te,le]=(0,t.useState)(!1),[oe,ae]=(0,t.useState)(null),[ne,de]=(0,t.useState)(null),[re,ie]=(0,t.useState)(null),se=e=>e.last_spawned??e.created_at??0,ce=E.filter(e=>!e.archived).sort((e,t)=>se(t)-se(e)),ue=E.filter(e=>e.archived),fe=(0,t.useCallback)((e,t)=>{const l=e.filter(e=>!e.archived).sort((e,t)=>(t.last_spawned??t.created_at??0)-(e.last_spawned??e.created_at??0));return t&&l.some(e=>e.path===t)?t:v&&l.some(e=>e.path===v)?v:l[0]?.path??null},[v]),he=(0,t.useRef)(!1);(0,t.useEffect)(()=>{e?he.current||(he.current=!0,V(w?"twin":"worker"),z("agent"),A("claude"),L(b),H.current=!1,O(""),D(""),Q(!1),Y(!1),ee(""),ae(null),de(null),ie(null),f&&((0,h.fetchFolds)(f,!0).then(e=>{M(e),U(fe(e,null))}).catch(()=>M([])),(0,h.fetchSpawnHistory)(f).then(G).catch(()=>G([])),(0,h.fetchRunHistory)(f).then(e=>{const t=e.map(e=>e.command);P(t),H.current||L(t[0]??b)}).catch(()=>P([])))):he.current=!1},[e,w,f,v,fe]);const pe=(0,t.useCallback)(async()=>{if(!f||te)return;const e=Z.trim();if(e){le(!0),ae(null);try{const t=await(0,h.addFold)(f,e),l=await(0,h.fetchFolds)(f,!0);M(l),U(t.path),ee(""),Y(!1)}catch(e){ae(e instanceof Error?e.message:String(e))}finally{le(!1)}}},[f,te,Z]),xe=(0,t.useCallback)(async e=>{if(!f)return;const t=!e.archived;ae(null);const l=E.map(l=>l.path===e.path?Object.assign({},l,{archived:t?1:0}):l);M(l),U(o=>o===e.path&&t?fe(l,null):o);try{await(0,h.archiveFold)(f,e.path,t);const l=await(0,h.fetchFolds)(f,!0);M(l),U(e=>fe(l,e))}catch(e){M(E),ae(e instanceof Error?e.message:String(e))}},[f,E,fe]),ge="utility"===T&&!w,me=ge&&B===b,ye=(me?I:B).trim().split(/\s+/).filter(e=>e.length>0),be=(0,t.useCallback)(async()=>{if(!f||N)return;const e=$??ce[0]?.path;if(!e)return;const t=_.trim()||"worker",l=W.trim().split(/\s+/).filter(e=>e.length>0);if(!ge||0!==ye.length){J(!0);try{const o=ge?await(0,h.runUtility)(f,[...ye,...l],e):await(0,h.spawnAgent)(f,k,e,t,void 0,l.length>0?l:void 0,w??void 0);R(o),C()}catch(e){console.error("Spawn failed:",e)}finally{J(!1)}}},[f,N,$,E,_,W,ge,ye,k,w,R,C]),je=!(N||!$||ge&&0===ye.length);return(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(s.default,{visible:e,transparent:!0,animationType:"fade",onRequestClose:C,children:(0,x.jsx)(n.default,{style:S.modalOverlay,onPress:C,children:(0,x.jsxs)(n.default,{style:S.modalContent,onPress:()=>{},children:[(0,x.jsx)(o.default,{style:S.modalTitle,children:w?`/twin with ${w}`:ge?"Run utility":"Spawn agent"}),(0,x.jsxs)(c.default,{style:{flexGrow:0},children:[(0,x.jsxs)(l.default,{style:S.modeRow,children:[(0,x.jsx)(n.default,{onPress:()=>z("agent"),accessibilityRole:"tab",accessibilityState:{selected:!ge},hitSlop:8,children:(0,x.jsx)(o.default,{style:[S.fieldLabel,S.modeLabel,ge&&S.modeLabelDim],children:"Agent"})}),!w&&(0,x.jsx)(n.default,{onPress:()=>z("utility"),accessibilityRole:"tab",accessibilityState:{selected:ge},hitSlop:8,children:(0,x.jsx)(o.default,{style:[S.fieldLabel,S.modeLabel,!ge&&S.modeLabelDim],children:"Utility"})})]}),ge?(0,x.jsxs)("select",{value:B,onChange:e=>{H.current=!0,L(e.target.value)},style:j,children:[F.map(e=>(0,x.jsx)("option",{value:e,children:e},e)),(0,x.jsx)("option",{value:b,children:"Other\u2026"})]}):(0,x.jsx)("select",{value:k,onChange:e=>A(e.target.value),style:j,children:y.map(e=>(0,x.jsx)("option",{value:e,children:e},e))}),me&&(0,x.jsx)(a.default,{style:[S.addInput,{marginTop:6}],value:I,onChangeText:e=>{H.current=!0,O(e)},placeholder:"zsh",placeholderTextColor:"#666",autoCapitalize:"none",autoCorrect:!1,autoFocus:!0}),!ge&&(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(o.default,{style:S.fieldLabel,children:"Role"}),(0,x.jsx)(a.default,{style:S.addInput,value:_,onChangeText:V,placeholder:"worker",placeholderTextColor:"#666",autoCapitalize:"none",autoCorrect:!1})]}),(0,x.jsx)(o.default,{style:S.fieldLabel,children:"CLI args (optional)"}),(0,x.jsx)(a.default,{style:S.addInput,value:W,onChangeText:D,placeholder:ge?"args":"--flag value",placeholderTextColor:"#666",autoCapitalize:"none",autoCorrect:!1}),!ge&&q.length>0&&(0,x.jsxs)("select",{value:"",onChange:e=>{e.target.value&&D(e.target.value),e.target.value=""},style:Object.assign({},j,{marginTop:6}),children:[(0,x.jsx)("option",{value:"",children:"Recent args\u2026"}),q.map((e,t)=>{const l=e.args.join(" ");return(0,x.jsx)("option",{value:l,children:l},`${l}-${t}`)})]}),(0,x.jsx)(o.default,{style:S.fieldLabel,children:"Fold"}),0===ce.length&&!X&&(0,x.jsx)(o.default,{style:S.foldEmptyHint,children:"No folders yet. Add a directory below to spawn agents in it."}),ce.map(e=>{const t=e.path===$;return(0,x.jsxs)(l.default,{style:[S.foldRow,t&&S.foldRowSelected,ne===e.path&&S.foldRowMenuOpen],children:[(0,x.jsxs)(n.default,{style:S.foldRowSelect,onPress:()=>U(e.path),children:[(0,x.jsx)(o.default,{style:S.foldRowDot,children:t?"\u25cf":"\u25cb"}),(0,x.jsx)(o.default,{style:[S.foldRowText,t&&S.foldRowTextSelected],numberOfLines:1,children:e.path})]}),(0,x.jsxs)("div",{style:{position:"relative"},children:[(0,x.jsx)(n.default,{style:S.foldRowAction,onPress:()=>de(t=>t===e.path?null:e.path),accessibilityLabel:`Actions for ${e.path}`,children:(0,x.jsx)(o.default,{style:S.foldRowActionIcon,children:"\u22ef"})}),ne===e.path&&(0,x.jsx)(p.default,{items:[{label:"Archive",icon:"\ud83d\uddc4\ufe0f",onPress:()=>{de(null),ie({fold:e,toArchived:!0})}}],onClose:()=>de(null),align:"beside"})]})]},e.path)}),K&&ue.map(e=>(0,x.jsxs)(l.default,{style:[S.foldRow,S.foldRowArchived,ne===e.path&&S.foldRowMenuOpen],children:[(0,x.jsx)(l.default,{style:S.foldRowSelect,children:(0,x.jsx)(o.default,{style:S.foldRowText,numberOfLines:1,children:e.path})}),(0,x.jsxs)("div",{style:{position:"relative"},children:[(0,x.jsx)(n.default,{style:S.foldRowAction,onPress:()=>de(t=>t===e.path?null:e.path),accessibilityLabel:`Actions for ${e.path}`,children:(0,x.jsx)(o.default,{style:S.foldRowActionIcon,children:"\u22ef"})}),ne===e.path&&(0,x.jsx)(p.default,{items:[{label:"Unarchive",icon:"\ud83d\udcc2",onPress:()=>{de(null),ie({fold:e,toArchived:!1})}}],onClose:()=>de(null),align:"beside"})]})]},e.path)),ue.length>0&&(0,x.jsx)(n.default,{onPress:()=>Q(e=>!e),style:S.foldTextButton,children:(0,x.jsx)(o.default,{style:S.foldTextButtonLabel,children:K?"Hide archived":`Show ${ue.length} hidden`})}),X?(0,x.jsxs)(l.default,{style:S.addFoldForm,children:[(0,x.jsx)(a.default,{style:S.addInput,value:Z,onChangeText:ee,placeholder:"~/dev/my-project",placeholderTextColor:"#666",autoCapitalize:"none",autoCorrect:!1,onSubmitEditing:pe}),(0,x.jsx)(o.default,{style:S.addFoldHint,children:"Must be a directory under your home folder."}),(0,x.jsx)(n.default,{style:[S.addButton,{marginTop:8},(te||!Z.trim())&&{opacity:.5}],onPress:pe,disabled:te||!Z.trim(),children:te?(0,x.jsx)(u.default,{size:"small",color:"#111"}):(0,x.jsx)(o.default,{style:S.addButtonText,children:"Add folder"})})]}):(0,x.jsx)(n.default,{style:S.addFoldButton,onPress:()=>Y(!0),children:(0,x.jsx)(o.default,{style:S.addFoldButtonText,children:"+ Add folder"})}),oe&&(0,x.jsx)(o.default,{style:S.foldErrorText,children:oe})]}),(0,x.jsx)(n.default,{style:[S.addButton,{marginTop:12},!je&&{opacity:.5}],onPress:be,disabled:!je,children:N?(0,x.jsx)(u.default,{size:"small",color:"#111"}):(0,x.jsx)(o.default,{style:S.addButtonText,children:w?"/twin":ge?"Run":"Spawn"})}),(0,x.jsx)(n.default,{style:S.modalCancel,onPress:C,children:(0,x.jsx)(o.default,{style:S.modalCancelText,children:"Cancel"})})]})})}),(0,x.jsx)(s.default,{visible:!!re,transparent:!0,animationType:"fade",onRequestClose:()=>ie(null),children:(0,x.jsx)(n.default,{style:S.modalOverlay,onPress:()=>ie(null),children:(0,x.jsxs)(n.default,{style:[S.modalContent,{maxWidth:340}],onPress:()=>{},children:[(0,x.jsx)(o.default,{style:S.modalTitle,children:re?.toArchived?"Archive fold?":"Unarchive fold?"}),(0,x.jsx)(o.default,{style:S.confirmBody,children:re?.toArchived?"Hide this fold from the spawn list. It's kept and can be unarchived anytime.":"Restore this fold to the spawn list."}),re&&(0,x.jsx)(o.default,{style:S.confirmPath,numberOfLines:1,children:re.fold.path}),(0,x.jsx)(n.default,{style:[S.addButton,{marginTop:16}],onPress:()=>{re&&xe(re.fold),ie(null)},children:(0,x.jsx)(o.default,{style:S.addButtonText,children:re?.toArchived?"Archive":"Unarchive"})}),(0,x.jsx)(n.default,{style:S.modalCancel,onPress:()=>ie(null),children:(0,x.jsx)(o.default,{style:S.modalCancelText,children:"Cancel"})})]})})})]})}const S=f.default.create({modalOverlay:{flex:1,backgroundColor:"rgba(0,0,0,0.6)",justifyContent:"center",alignItems:"center",padding:24},modalContent:{backgroundColor:"#1e1e22",borderRadius:12,padding:20,width:"100%",maxWidth:400,maxHeight:"80%"},modalTitle:{color:"#d8d8dd",fontSize:18,fontWeight:"600",marginBottom:16},fieldLabel:{color:"#aaa",fontSize:12,fontWeight:"600",textTransform:"uppercase",letterSpacing:.5,marginTop:12,marginBottom:6},modeRow:{flexDirection:"row",justifyContent:"space-between",alignItems:"flex-end"},modeLabel:{color:"#d8d8dd"},modeLabelDim:{color:"#66666e"},addInput:{backgroundColor:"#222228",borderRadius:8,paddingHorizontal:12,paddingVertical:10,color:"#d8d8dd",fontSize:14,fontFamily:"monospace",borderWidth:1,borderColor:"#3a3a40"},fieldStaticValue:{backgroundColor:"#222228",borderRadius:8,paddingHorizontal:12,paddingVertical:10,borderWidth:1,borderColor:"#2a2a30"},foldOptionText:{color:"#d8d8dd",fontSize:15,fontFamily:"monospace"},addButton:{backgroundColor:"#5b9bd5",borderRadius:8,paddingVertical:10,alignItems:"center"},addButtonText:{color:"#111",fontSize:14,fontWeight:"600"},modalCancel:{paddingVertical:12,alignItems:"center",marginTop:8},modalCancelText:{color:"#888",fontSize:15},foldEmptyHint:{color:"#888",fontSize:13,fontStyle:"italic",paddingVertical:8},foldRow:{flexDirection:"row",alignItems:"center",backgroundColor:"#2a2a30",borderRadius:8,marginBottom:6,borderWidth:1,borderColor:"transparent"},foldRowSelected:{borderColor:"#5b9bd5",backgroundColor:"#26303a"},foldRowArchived:{opacity:.55,backgroundColor:"#222228"},foldRowMenuOpen:{zIndex:100},foldRowSelect:{flex:1,flexDirection:"row",alignItems:"center",paddingVertical:10,paddingLeft:12,paddingRight:8,gap:8},foldRowDot:{color:"#5b9bd5",fontSize:13,width:12},foldRowText:{flex:1,color:"#c8c8cf",fontSize:14,fontFamily:"monospace"},foldRowTextSelected:{color:"#eaeaef"},foldRowAction:{paddingHorizontal:12,paddingVertical:10,alignSelf:"stretch",justifyContent:"center"},foldRowActionIcon:{fontSize:15},foldTextButton:{paddingVertical:6,alignItems:"center"},foldTextButtonLabel:{color:"#8a8a93",fontSize:13},addFoldForm:{marginTop:6},addFoldHint:{color:"#777",fontSize:12,marginTop:6},addFoldButton:{backgroundColor:"#2a2a30",borderRadius:8,paddingVertical:10,alignItems:"center",marginTop:6},addFoldButtonText:{color:"#8fd4b4",fontSize:14,fontWeight:"600"},foldErrorText:{color:"#e07070",fontSize:13,marginTop:8},confirmBody:{color:"#c8c8cf",fontSize:14,lineHeight:20},confirmPath:{color:"#9fb8d0",fontSize:13,fontFamily:"monospace",marginTop:10}})},972,[11,13,105,145,146,153,122,416,26,745,773,6]);
1075
+ __d(function(g,r,i,_a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return S}});var t=r(d[0]),l=e(r(d[1])),o=e(r(d[2])),a=e(r(d[3])),n=e(r(d[4])),s=e(r(d[5])),c=e(r(d[6])),u=e(r(d[7])),f=e(r(d[8])),h=r(d[9]),p=e(r(d[10])),x=r(d[11]);const y=["claude","gemini","goose","copilot","cline","codex","crush","amp"],b="",j="",w={display:"block",boxSizing:"border-box",width:"100%",margin:0,backgroundColor:"#222228",color:"#d8d8dd",border:"1px solid #3a3a40",borderRadius:8,padding:"10px 36px 10px 12px",fontSize:14,fontFamily:"monospace",lineHeight:"20px",outline:"none",colorScheme:"dark",cursor:"pointer",appearance:"none",WebkitAppearance:"none",MozAppearance:"none",backgroundImage:"url(\"data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'><path d='M1 1.5l5 5 5-5' stroke='%23a8a8b0' stroke-width='1.6' fill='none' stroke-linecap='round' stroke-linejoin='round'/></svg>\")",backgroundRepeat:"no-repeat",backgroundPosition:"right 12px center",backgroundSize:"12px 8px"};function S({visible:e,conn:f,re:S,defaultFoldPath:C,onClose:T,onSpawned:R}){const[z,k]=(0,t.useState)("agent"),[F,A]=(0,t.useState)("claude"),[P,B]=(0,t.useState)(""),[I,L]=(0,t.useState)([]),[O,H]=(0,t.useState)(b),[_,E]=(0,t.useState)(""),V=(0,t.useRef)(!1),[W,D]=(0,t.useState)("worker"),[M,$]=(0,t.useState)(""),[U,q]=(0,t.useState)([]),[G,N]=(0,t.useState)(null),[J,K]=(0,t.useState)([]),[Q,X]=(0,t.useState)(!1),[Y,Z]=(0,t.useState)(null),[ee,te]=(0,t.useState)(!1),[le,oe]=(0,t.useState)(!1),[ae,ne]=(0,t.useState)(""),[de,re]=(0,t.useState)(!1),[ie,se]=(0,t.useState)(null),[ce,ue]=(0,t.useState)(null),[fe,he]=(0,t.useState)(null),pe=e=>e.last_spawned??e.created_at??0,xe=U.filter(e=>!e.archived).sort((e,t)=>pe(t)-pe(e)),ge=U.filter(e=>e.archived),me=(0,t.useCallback)((e,t)=>{const l=e.filter(e=>!e.archived).sort((e,t)=>(t.last_spawned??t.created_at??0)-(e.last_spawned??e.created_at??0));return t&&l.some(e=>e.path===t)?t:C&&l.some(e=>e.path===C)?C:l[0]?.path??null},[C]),ye=(0,t.useRef)(!1);(0,t.useEffect)(()=>{e?ye.current||(ye.current=!0,D(S?"twin":"worker"),k("agent"),A("claude"),B(""),Z(null),H(b),V.current=!1,E(""),$(""),te(!1),oe(!1),ne(""),se(null),ue(null),he(null),f&&((0,h.fetchFolds)(f,!0).then(e=>{q(e),N(me(e,null))}).catch(()=>q([])),(0,h.fetchSpawnHistory)(f).then(K).catch(()=>K([])),(0,h.fetchRunHistory)(f).then(e=>{const t=e.map(e=>e.command);L(t),V.current||H(t[0]??b)}).catch(()=>L([])))):ye.current=!1},[e,S,f,C,me]);const be=(0,t.useCallback)(async()=>{if(!f||de)return;const e=ae.trim();if(e){re(!0),se(null);try{const t=await(0,h.addFold)(f,e),l=await(0,h.fetchFolds)(f,!0);q(l),N(t.path),ne(""),oe(!1)}catch(e){se(e instanceof Error?e.message:String(e))}finally{re(!1)}}},[f,de,ae]),je=(0,t.useCallback)(async e=>{if(!f)return;const t=!e.archived;se(null);const l=U.map(l=>l.path===e.path?Object.assign({},l,{archived:t?1:0}):l);q(l),N(o=>o===e.path&&t?me(l,null):o);try{await(0,h.archiveFold)(f,e.path,t);const l=await(0,h.fetchFolds)(f,!0);q(l),N(e=>me(l,e))}catch(e){q(U),se(e instanceof Error?e.message:String(e))}},[f,U,me]),we="utility"===z&&!S,Se=we&&O===b,ve=(Se?_:O).trim().split(/\s+/).filter(e=>e.length>0),Ce=!we&&F===j,Te=(Ce?P:F).trim().split(/\s+/).filter(e=>e.length>0),Re=(0,t.useCallback)(async()=>{if(!f||Q)return;const e=G??xe[0]?.path;if(!e)return;const t=W.trim()||"worker",l=M.trim().split(/\s+/).filter(e=>e.length>0);if(we&&0===ve.length)return;if(!we&&0===Te.length)return;const o=[...Te.slice(1),...l];X(!0),Z(null);try{const a=we?await(0,h.runUtility)(f,[...ve,...l],e):await(0,h.spawnAgent)(f,Te[0],e,t,void 0,o.length>0?o:void 0,S??void 0);R(a),T()}catch(e){console.error("Spawn failed:",e),Z(e instanceof Error?e.message:String(e))}finally{X(!1)}},[f,Q,G,U,W,M,we,ve,Te,S,R,T]),ze=!Q&&!!G&&(we?ve.length>0:Te.length>0);return(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(s.default,{visible:e,transparent:!0,animationType:"fade",onRequestClose:T,children:(0,x.jsx)(n.default,{style:v.modalOverlay,onPress:T,children:(0,x.jsxs)(n.default,{style:v.modalContent,onPress:()=>{},children:[(0,x.jsx)(o.default,{style:v.modalTitle,children:S?`/twin with ${S}`:we?"Run utility":"Spawn agent"}),(0,x.jsxs)(c.default,{style:{flexGrow:0},children:[(0,x.jsxs)(l.default,{style:v.modeRow,children:[(0,x.jsx)(n.default,{onPress:()=>k("agent"),accessibilityRole:"tab",accessibilityState:{selected:!we},hitSlop:8,children:(0,x.jsx)(o.default,{style:[v.fieldLabel,v.modeLabel,we&&v.modeLabelDim],children:"Agent"})}),!S&&(0,x.jsx)(n.default,{onPress:()=>k("utility"),accessibilityRole:"tab",accessibilityState:{selected:we},hitSlop:8,children:(0,x.jsx)(o.default,{style:[v.fieldLabel,v.modeLabel,!we&&v.modeLabelDim],children:"Utility"})})]}),we?(0,x.jsxs)("select",{value:O,onChange:e=>{V.current=!0,H(e.target.value)},style:w,children:[I.map(e=>(0,x.jsx)("option",{value:e,children:e},e)),(0,x.jsx)("option",{value:b,children:"Other\u2026"})]}):(0,x.jsxs)("select",{value:F,onChange:e=>A(e.target.value),style:w,children:[y.map(e=>(0,x.jsx)("option",{value:e,children:e},e)),(0,x.jsx)("option",{value:j,children:"Other\u2026"})]}),Ce&&(0,x.jsx)(a.default,{style:[v.addInput,{marginTop:6}],value:P,onChangeText:B,placeholder:"aider",placeholderTextColor:"#666",autoCapitalize:"none",autoCorrect:!1,autoFocus:!0}),Se&&(0,x.jsx)(a.default,{style:[v.addInput,{marginTop:6}],value:_,onChangeText:e=>{V.current=!0,E(e)},placeholder:"zsh",placeholderTextColor:"#666",autoCapitalize:"none",autoCorrect:!1,autoFocus:!0}),!we&&(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(o.default,{style:v.fieldLabel,children:"Role"}),(0,x.jsx)(a.default,{style:v.addInput,value:W,onChangeText:D,placeholder:"worker",placeholderTextColor:"#666",autoCapitalize:"none",autoCorrect:!1})]}),(0,x.jsx)(o.default,{style:v.fieldLabel,children:"CLI args (optional)"}),(0,x.jsx)(a.default,{style:v.addInput,value:M,onChangeText:$,placeholder:we?"args":"--flag value",placeholderTextColor:"#666",autoCapitalize:"none",autoCorrect:!1}),!we&&J.length>0&&(0,x.jsxs)("select",{value:"",onChange:e=>{e.target.value&&$(e.target.value),e.target.value=""},style:Object.assign({},w,{marginTop:6}),children:[(0,x.jsx)("option",{value:"",children:"Recent args\u2026"}),J.map((e,t)=>{const l=e.args.join(" ");return(0,x.jsx)("option",{value:l,children:l},`${l}-${t}`)})]}),(0,x.jsx)(o.default,{style:v.fieldLabel,children:"Fold"}),0===xe.length&&!le&&(0,x.jsx)(o.default,{style:v.foldEmptyHint,children:"No folders yet. Add a directory below to spawn agents in it."}),xe.map(e=>{const t=e.path===G;return(0,x.jsxs)(l.default,{style:[v.foldRow,t&&v.foldRowSelected,ce===e.path&&v.foldRowMenuOpen],children:[(0,x.jsxs)(n.default,{style:v.foldRowSelect,onPress:()=>N(e.path),children:[(0,x.jsx)(o.default,{style:v.foldRowDot,children:t?"\u25cf":"\u25cb"}),(0,x.jsx)(o.default,{style:[v.foldRowText,t&&v.foldRowTextSelected],numberOfLines:1,children:e.path})]}),(0,x.jsxs)("div",{style:{position:"relative"},children:[(0,x.jsx)(n.default,{style:v.foldRowAction,onPress:()=>ue(t=>t===e.path?null:e.path),accessibilityLabel:`Actions for ${e.path}`,children:(0,x.jsx)(o.default,{style:v.foldRowActionIcon,children:"\u22ef"})}),ce===e.path&&(0,x.jsx)(p.default,{items:[{label:"Archive",icon:"\ud83d\uddc4\ufe0f",onPress:()=>{ue(null),he({fold:e,toArchived:!0})}}],onClose:()=>ue(null),align:"beside"})]})]},e.path)}),ee&&ge.map(e=>(0,x.jsxs)(l.default,{style:[v.foldRow,v.foldRowArchived,ce===e.path&&v.foldRowMenuOpen],children:[(0,x.jsx)(l.default,{style:v.foldRowSelect,children:(0,x.jsx)(o.default,{style:v.foldRowText,numberOfLines:1,children:e.path})}),(0,x.jsxs)("div",{style:{position:"relative"},children:[(0,x.jsx)(n.default,{style:v.foldRowAction,onPress:()=>ue(t=>t===e.path?null:e.path),accessibilityLabel:`Actions for ${e.path}`,children:(0,x.jsx)(o.default,{style:v.foldRowActionIcon,children:"\u22ef"})}),ce===e.path&&(0,x.jsx)(p.default,{items:[{label:"Unarchive",icon:"\ud83d\udcc2",onPress:()=>{ue(null),he({fold:e,toArchived:!1})}}],onClose:()=>ue(null),align:"beside"})]})]},e.path)),ge.length>0&&(0,x.jsx)(n.default,{onPress:()=>te(e=>!e),style:v.foldTextButton,children:(0,x.jsx)(o.default,{style:v.foldTextButtonLabel,children:ee?"Hide archived":`Show ${ge.length} hidden`})}),le?(0,x.jsxs)(l.default,{style:v.addFoldForm,children:[(0,x.jsx)(a.default,{style:v.addInput,value:ae,onChangeText:ne,placeholder:"~/dev/my-project",placeholderTextColor:"#666",autoCapitalize:"none",autoCorrect:!1,onSubmitEditing:be}),(0,x.jsx)(o.default,{style:v.addFoldHint,children:"Must be a directory under your home folder."}),(0,x.jsx)(n.default,{style:[v.addButton,{marginTop:8},(de||!ae.trim())&&{opacity:.5}],onPress:be,disabled:de||!ae.trim(),children:de?(0,x.jsx)(u.default,{size:"small",color:"#111"}):(0,x.jsx)(o.default,{style:v.addButtonText,children:"Add folder"})})]}):(0,x.jsx)(n.default,{style:v.addFoldButton,onPress:()=>oe(!0),children:(0,x.jsx)(o.default,{style:v.addFoldButtonText,children:"+ Add folder"})}),ie&&(0,x.jsx)(o.default,{style:v.foldErrorText,children:ie})]}),Y&&(0,x.jsx)(o.default,{style:v.foldErrorText,children:Y}),(0,x.jsx)(n.default,{style:[v.addButton,{marginTop:12},!ze&&{opacity:.5}],onPress:Re,disabled:!ze,children:Q?(0,x.jsx)(u.default,{size:"small",color:"#111"}):(0,x.jsx)(o.default,{style:v.addButtonText,children:S?"/twin":we?"Run":"Spawn"})}),(0,x.jsx)(n.default,{style:v.modalCancel,onPress:T,children:(0,x.jsx)(o.default,{style:v.modalCancelText,children:"Cancel"})})]})})}),(0,x.jsx)(s.default,{visible:!!fe,transparent:!0,animationType:"fade",onRequestClose:()=>he(null),children:(0,x.jsx)(n.default,{style:v.modalOverlay,onPress:()=>he(null),children:(0,x.jsxs)(n.default,{style:[v.modalContent,{maxWidth:340}],onPress:()=>{},children:[(0,x.jsx)(o.default,{style:v.modalTitle,children:fe?.toArchived?"Archive fold?":"Unarchive fold?"}),(0,x.jsx)(o.default,{style:v.confirmBody,children:fe?.toArchived?"Hide this fold from the spawn list. It's kept and can be unarchived anytime.":"Restore this fold to the spawn list."}),fe&&(0,x.jsx)(o.default,{style:v.confirmPath,numberOfLines:1,children:fe.fold.path}),(0,x.jsx)(n.default,{style:[v.addButton,{marginTop:16}],onPress:()=>{fe&&je(fe.fold),he(null)},children:(0,x.jsx)(o.default,{style:v.addButtonText,children:fe?.toArchived?"Archive":"Unarchive"})}),(0,x.jsx)(n.default,{style:v.modalCancel,onPress:()=>he(null),children:(0,x.jsx)(o.default,{style:v.modalCancelText,children:"Cancel"})})]})})})]})}const v=f.default.create({modalOverlay:{flex:1,backgroundColor:"rgba(0,0,0,0.6)",justifyContent:"center",alignItems:"center",padding:24},modalContent:{backgroundColor:"#1e1e22",borderRadius:12,padding:20,width:"100%",maxWidth:400,maxHeight:"80%"},modalTitle:{color:"#d8d8dd",fontSize:18,fontWeight:"600",marginBottom:16},fieldLabel:{color:"#aaa",fontSize:12,fontWeight:"600",textTransform:"uppercase",letterSpacing:.5,marginTop:12,marginBottom:6},modeRow:{flexDirection:"row",justifyContent:"space-between",alignItems:"flex-end"},modeLabel:{color:"#d8d8dd"},modeLabelDim:{color:"#66666e"},addInput:{backgroundColor:"#222228",borderRadius:8,paddingHorizontal:12,paddingVertical:10,color:"#d8d8dd",fontSize:14,fontFamily:"monospace",borderWidth:1,borderColor:"#3a3a40"},fieldStaticValue:{backgroundColor:"#222228",borderRadius:8,paddingHorizontal:12,paddingVertical:10,borderWidth:1,borderColor:"#2a2a30"},foldOptionText:{color:"#d8d8dd",fontSize:15,fontFamily:"monospace"},addButton:{backgroundColor:"#5b9bd5",borderRadius:8,paddingVertical:10,alignItems:"center"},addButtonText:{color:"#111",fontSize:14,fontWeight:"600"},modalCancel:{paddingVertical:12,alignItems:"center",marginTop:8},modalCancelText:{color:"#888",fontSize:15},foldEmptyHint:{color:"#888",fontSize:13,fontStyle:"italic",paddingVertical:8},foldRow:{flexDirection:"row",alignItems:"center",backgroundColor:"#2a2a30",borderRadius:8,marginBottom:6,borderWidth:1,borderColor:"transparent"},foldRowSelected:{borderColor:"#5b9bd5",backgroundColor:"#26303a"},foldRowArchived:{opacity:.55,backgroundColor:"#222228"},foldRowMenuOpen:{zIndex:100},foldRowSelect:{flex:1,flexDirection:"row",alignItems:"center",paddingVertical:10,paddingLeft:12,paddingRight:8,gap:8},foldRowDot:{color:"#5b9bd5",fontSize:13,width:12},foldRowText:{flex:1,color:"#c8c8cf",fontSize:14,fontFamily:"monospace"},foldRowTextSelected:{color:"#eaeaef"},foldRowAction:{paddingHorizontal:12,paddingVertical:10,alignSelf:"stretch",justifyContent:"center"},foldRowActionIcon:{fontSize:15},foldTextButton:{paddingVertical:6,alignItems:"center"},foldTextButtonLabel:{color:"#8a8a93",fontSize:13},addFoldForm:{marginTop:6},addFoldHint:{color:"#777",fontSize:12,marginTop:6},addFoldButton:{backgroundColor:"#2a2a30",borderRadius:8,paddingVertical:10,alignItems:"center",marginTop:6},addFoldButtonText:{color:"#8fd4b4",fontSize:14,fontWeight:"600"},foldErrorText:{color:"#e07070",fontSize:13,marginTop:8},confirmBody:{color:"#c8c8cf",fontSize:14,lineHeight:20},confirmPath:{color:"#9fb8d0",fontSize:13,fontFamily:"monospace",marginTop:10}})},972,[11,13,105,145,146,153,122,416,26,745,773,6]);
1076
1076
  __d(function(g,r,_i,a,m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return z}});var t=r(_d[0]),i=r(_d[1]),n=r(_d[2]),o=e(r(_d[3])),l=e(r(_d[4])),s=e(r(_d[5])),c=e(r(_d[6])),u=e(r(_d[7])),d=e(r(_d[8])),f=e(r(_d[9])),h=e(r(_d[10])),w=e(r(_d[11])),p=e(r(_d[12])),k=r(_d[13]),b=r(_d[14]),x=r(_d[15]);const y=3,v=2,j=220,R=160;function C(e,t,i){return[e,t.replace(/\.md$/,""),(i??"").replace(/^#/,"")].join("\0")}function S({heading:e,preview:t,direction:i,onPress:n}){return(0,x.jsxs)(s.default,{onPress:n,style:P.wikiNavItem,children:[(0,x.jsx)(l.default,{style:P.wikiNavArrow,children:"up"===i?"\u2191":"\u2193"}),(0,x.jsxs)(o.default,{style:{flex:1},children:[(0,x.jsx)(l.default,{style:P.wikiNavHeading,numberOfLines:1,children:e??"(intro)"}),!!t&&(0,x.jsx)(l.default,{style:P.wikiNavPreview,numberOfLines:1,children:t})]})]})}function z({conn:e,target:z,onClose:N}){const[T,B]=(0,t.useState)(z),[V,H]=(0,t.useState)(null),[O,W]=(0,t.useState)(!0),[$,A]=(0,t.useState)(null),E=(0,t.useRef)(new Map),L=(0,t.useRef)(new Map),{height:_}=(0,p.default)(),F=(0,t.useRef)(new h.default.Value(0)).current;(0,t.useEffect)(()=>{h.default.timing(F,{toValue:1,duration:j,easing:w.default.out(w.default.cubic),useNativeDriver:!0}).start()},[F]);const I=(0,t.useCallback)(()=>{h.default.timing(F,{toValue:0,duration:R,easing:w.default.in(w.default.cubic),useNativeDriver:!0}).start(()=>N())},[F,N]);(0,t.useEffect)(()=>{E.current.clear(),L.current.clear()},[e]),(0,t.useEffect)(()=>{B(z)},[z.source,z.slug,z.anchor]);const M=(0,t.useCallback)(t=>{const i=C(t.source,t.slug,t.anchor),n=E.current.get(i);if(n)return Promise.resolve(n);const o=L.current.get(i);if(o)return o;const l=(0,b.readWikiSection)(e,{source:t.source,slug:t.slug,anchor:t.anchor,window:y}).then(e=>(E.current.set(i,e),E.current.set(C(e.source,e.slug,e.current.anchor),e),e)).finally(()=>{L.current.delete(i)});return L.current.set(i,l),l},[e]),D=(0,t.useCallback)(async(e,t)=>{const i=[];for(let t=0;t<y;t++)e.next[t]&&i.push({source:e.source,slug:e.slug,anchor:e.next[t].anchor}),e.prev[t]&&i.push({source:e.source,slug:e.slug,anchor:e.prev[t].anchor});let n=0;await Promise.all(Array.from({length:v},async()=>{for(;!t();){const e=i[n++];if(!e)return;await M(e).catch(()=>{})}}))},[M]);(0,t.useEffect)(()=>{let e=!1;const t=()=>e,i=E.current.get(C(T.source,T.slug,T.anchor));return i?(H(i),A(null),W(!1),D(i,t)):(W(!0),A(null),M(T).then(i=>{e||(H(i),W(!1),D(i,t))}).catch(t=>{e||(A(String(t?.message??t)),W(!1))})),()=>{e=!0}},[M,D,T.source,T.slug,T.anchor]);const G=(0,t.useCallback)(e=>{const t=(0,i.resolveWikiLink)(T.slug,e);if(!t)return;const n=t.slug.replace(/\.md$/,"");B(e=>({source:e.source,slug:n,anchor:t.anchor}))},[T.slug]),q=(0,t.useCallback)(e=>{B({source:"protocols",slug:e})},[]),U=(0,t.useCallback)(t=>/^[a-z][a-z0-9+.-]*:/i.test(t)?t:t.startsWith("/")||t.split("/").includes("..")?null:(0,b.wikiAssetUrl)(e,T.source,t),[e,T.source]),Y=(0,n.neighborColumns)(V?.prev??[],V?.next??[]);return(0,x.jsx)(c.default,{visible:!0,animationType:"none",transparent:!0,onRequestClose:I,children:(0,x.jsxs)(o.default,{style:P.wikiReaderOverlay,children:[(0,x.jsx)(s.default,{onPress:I,accessibilityLabel:"Close wiki",style:d.default.absoluteFill}),(0,x.jsxs)(h.default.View,{style:[P.wikiReaderSheet,{transform:[{translateY:F.interpolate({inputRange:[0,1],outputRange:[_,0]})}]}],children:[(0,x.jsxs)(o.default,{style:P.wikiReaderTopBar,children:[(0,x.jsxs)(l.default,{style:P.wikiReaderTitle,numberOfLines:1,children:[T.slug.replace(/\.md$/,"")," ",(0,x.jsxs)(l.default,{style:P.wikiSource,children:[T.source,(0,i.isSharedSlug)(T.slug)?" \xb7 shared":""]})]}),O&&V&&(0,x.jsx)(f.default,{size:"small",color:"#8fd4b4",style:P.wikiReaderBusy}),(0,x.jsx)(s.default,{onPress:I,style:P.wikiReaderClose,children:(0,x.jsx)(l.default,{style:P.wikiReaderCloseText,children:"\u2715"})})]}),O&&!V?(0,x.jsx)(o.default,{style:P.center,children:(0,x.jsx)(f.default,{color:"#8fd4b4"})}):$&&!V?(0,x.jsx)(o.default,{style:P.center,children:(0,x.jsx)(l.default,{style:P.errorText,children:$})}):V?(0,x.jsxs)(u.default,{style:[{flex:1},O&&P.wikiStale],contentContainerStyle:{padding:14},children:[!!$&&(0,x.jsx)(l.default,{style:P.wikiErrorBanner,children:`Couldn't load ${T.slug.replace(/\.md$/,"")}${T.anchor?`#${T.anchor}`:""} \u2014 ${$}`}),Y.above.length>0&&(0,x.jsx)(o.default,{style:P.wikiNavGroup,children:Y.above.map(e=>(0,x.jsx)(S,{heading:e.heading,preview:e.preview,direction:"up",onPress:()=>B(t=>Object.assign({},t,{anchor:e.anchor}))},e.anchor))}),(0,x.jsxs)(l.default,{style:P.wikiPosition,children:[V.position.index+1," / ",V.position.total]}),(0,x.jsx)(k.MarkdownContent,{content:V.current.content,onFilePress:G,onProtocolPress:q,imageSrcResolver:U}),Y.below.length>0&&(0,x.jsx)(o.default,{style:P.wikiNavGroup,children:Y.below.map(e=>(0,x.jsx)(S,{heading:e.heading,preview:e.preview,direction:"down",onPress:()=>B(t=>Object.assign({},t,{anchor:e.anchor}))},e.anchor))})]}):null]})]})})}const P=d.default.create({center:{flex:1,justifyContent:"center",alignItems:"center",padding:20},errorText:{color:"#e07070",fontSize:14,textAlign:"center"},wikiSource:{color:"#7a8a9a",fontSize:11,fontFamily:"monospace",backgroundColor:"#2a2a32",paddingHorizontal:6,paddingVertical:2,borderRadius:4,overflow:"hidden"},wikiReaderOverlay:{flex:1,backgroundColor:"rgba(0,0,0,0.6)",justifyContent:"flex-end"},wikiReaderSheet:{backgroundColor:"#16161a",borderTopLeftRadius:14,borderTopRightRadius:14,maxHeight:"88%",minHeight:"55%",borderWidth:d.default.hairlineWidth,borderColor:"rgba(143, 212, 180, 0.3)"},wikiReaderTopBar:{flexDirection:"row",alignItems:"center",paddingHorizontal:14,paddingVertical:12,borderBottomWidth:d.default.hairlineWidth,borderBottomColor:"#2a2a32"},wikiReaderTitle:{color:"#d8d8dd",fontSize:15,fontWeight:"600",fontFamily:"monospace",flex:1},wikiReaderClose:{paddingHorizontal:8,paddingVertical:2},wikiReaderBusy:{marginRight:6},wikiStale:{opacity:.45},wikiErrorBanner:{color:"#e07070",fontSize:12,marginBottom:10,paddingVertical:6,paddingHorizontal:8,backgroundColor:"rgba(224, 112, 112, 0.1)",borderRadius:6},wikiReaderCloseText:{color:"#888",fontSize:18},wikiPosition:{color:"#667",fontSize:11,fontFamily:"monospace",marginBottom:6},wikiNavGroup:{gap:4,marginVertical:10},wikiNavItem:{flexDirection:"row",alignItems:"center",gap:8,paddingVertical:6,paddingHorizontal:8,backgroundColor:"rgba(143, 212, 180, 0.06)",borderRadius:6},wikiNavArrow:{color:"#8fd4b4",fontSize:14,width:14,textAlign:"center"},wikiNavHeading:{color:"#bcd",fontSize:13,fontWeight:"600"},wikiNavPreview:{color:"#778",fontSize:11}})},973,[11,974,975,13,105,146,153,122,26,416,352,397,443,786,745,6]);
1077
1077
  __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"WIKI_SHARED_DIR",{enumerable:!0,get:function(){return t}}),e.isSharedSlug=function(n){return n.startsWith(`${t}/`)},e.normalizeWikiSlug=n,e.resolveWikiLink=function(t,s){const l=s.trim(),u=l.indexOf("#"),o=u>=0?l.slice(0,u):l,c=u>=0&&l.slice(u+1).trim()||void 0,f=n(t);if(""===o)return void 0!==c?{slug:f,anchor:c}:{slug:f};if(/^[a-z][a-z0-9+.-]*:/i.test(o))return null;if(o.startsWith("/")||o.startsWith("\\"))return null;const h=[...f.includes("/")?f.slice(0,f.lastIndexOf("/")).split("/"):[]];for(const t of o.split("/"))if(""!==t&&"."!==t)if(".."!==t)h.push(t);else{if(0===h.length)return null;h.pop()}if(0===h.length)return null;const p=n(h.join("/"));return void 0!==c?{slug:p,anchor:c}:{slug:p}};const t="shared";function n(t){let n=t.trim().replace(/^\/+/,"");for(;n.startsWith("./");)n=n.slice(2);return(n.split("/").pop()??"").includes(".")?n:`${n}.md`}},974,[]);
1078
1078
  __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.neighborColumns=function(n,o){return{above:[...n].reverse(),below:[...o]}}},975,[]);
1079
1079
  __d(function(g,r,i,a,m,e,d){"use strict";function n(n,t){if(t)for(const o of t)o&&"string"==typeof o.id&&o.id&&n.add(o.id)}Object.defineProperty(e,'__esModule',{value:!0}),e.collectKnownNids=function(t){const o=new Set;t.viewing&&o.add(t.viewing);return n(o,t.pushed),n(o,t.listed),o}},976,[]);
1080
1080
  __d(function(g,r,i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.sortNarratives=function(t){return[...t].sort((t,n)=>{const s=t=>"ended"===t.status?1:0,a=s(t)-s(n);return 0!==a?a:n.created_at-t.created_at})}},977,[]);
1081
- __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.visiblePanes=function(t,c){return n.CANONICAL_TABS.filter(n=>n===t||c.has(n))},e.selectPane=function(n,t,c){const s=new Set(t);return s.add(n),{active:c,pinned:s}};var n=r(d[0])},978,[747]);
1082
- __d(function(g,r,_i,_a,_m,_e,_d){"use strict";const e=["index","style"];function t(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return ie}});var n=t(r(_d[0])),o=r(_d[1]),a=t(r(_d[2])),i=t(r(_d[3])),l=t(r(_d[4])),s=t(r(_d[5])),d=t(r(_d[6])),c=t(r(_d[7])),u=t(r(_d[8])),f=t(r(_d[9])),h=t(r(_d[10])),m=r(_d[11]),p=r(_d[12]);r(_d[13]);var x=r(_d[14]),y=t(r(_d[15])),b=r(_d[16]),j=r(_d[17]),v=r(_d[18]),w=r(_d[19]),S=r(_d[20]),C=r(_d[21]),T=t(r(_d[22])),k=r(_d[23]),B=r(_d[24]),R=t(r(_d[25])),O=t(r(_d[26])),z=t(r(_d[27])),_=t(r(_d[28])),P=r(_d[29]),I=r(_d[30]),E=r(_d[31]),L=r(_d[32]),D=r(_d[33]),W=r(_d[34]);const H=400;function A(t){let{index:o,style:i}=t,l=(0,n.default)(t,e);return(0,W.jsx)(a.default,Object.assign({},l,{style:[i,{zIndex:1e5-o,position:"relative"}]}))}function M({item:e,conn:t,onPress:n,onArchive:l,onMeld:s,onTwin:d,onRevive:c,onEnd:f,menuVisible:h,setMenuVisible:m,hits:p,onHitPress:x}){const T="ended"===e.status?"dead":e.mcp_connected?"live":"idle",k="ended"===e.status?"#666":e.mcp_connected?"#66d9a0":"#5b9bd5",[,B]=(0,o.useState)(0),R=(0,E.isAwaiting)({mcpConnected:e.mcp_connected,awaiting:e.awaiting})?(0,E.awaitingGlow)((0,v.glowHueFor)(e.id)):void 0,O="ended"===e.status?"grey":e.mcp_connected?"green":"blue",z=(0,w.menuHueRgb)(O),_=[`0 0 8px rgba(${z}, 0.9)`,`0 0 18px rgba(${z}, 0.7)`,`0 0 36px rgba(${z}, 0.4)`,`0 1px 12px rgba(${z}, 0.6)`].join(", ");return(0,W.jsx)("div",{style:{borderBottomWidth:u.default.hairlineWidth,borderBottomColor:"#555",borderBottomStyle:"solid",backgroundColor:"#121214",cursor:"pointer",boxShadow:R,transition:"box-shadow 400ms ease"},onClick:()=>n(),children:(0,W.jsxs)("div",{style:{padding:16},children:[(0,W.jsxs)("div",{style:{display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center"},children:[(0,W.jsx)(S.NarrativeIdentity,{id:e.id,foldPath:e.fold_path,style:{flex:1,minWidth:0}}),(0,W.jsxs)("div",{style:{position:"relative"},children:[(0,W.jsx)("button",{onClick:e=>{e.stopPropagation(),m(!h)},style:{background:"none",border:"none",color:k,fontSize:12,textTransform:"uppercase",cursor:"pointer",padding:"4px 8px",marginRight:-9,borderRadius:4,transition:"text-shadow 160ms ease",textShadow:h?_:void 0},children:T}),h&&(0,W.jsx)(y.default,{hue:O,items:(0,b.narrativeMenuItems)({role:e.role,status:e.status,mcpConnected:e.mcp_connected,archived:!!e.archived,isIsolated:"undefined"!=typeof window&&(0,P.isIsolatedHost)(window.location.hostname),onMeld:()=>{m(!1),s()},onIsolate:()=>{m(!1),t&&"undefined"!=typeof window&&window.open((0,P.buildIsolateUrl)({hostname:window.location.hostname,protocol:window.location.protocol,search:window.location.search,path:`/${e.id}`,conn:t,view:{}}),"_blank","noopener,noreferrer")},onExport:()=>{m(!1),t&&(0,b.openNarrativeExport)(t,e.id)},onRecolor:()=>{m(!1),(0,j.bumpRecolorSalt)(e.id),(0,v.recolorGlowHue)(e.id),B(e=>e+1)},onTwin:()=>{m(!1),d()},onRevive:()=>{m(!1),c()},onEnd:()=>{m(!1),f()},onArchiveToggle:()=>{m(!1),l()}}),onClose:()=>m(!1)})]})]}),(0,W.jsx)(S.NarrativeMetaLine,{role:e.role,cost:(0,C.formatCost)(e.cost_amount,e.cost_unit),createdAt:e.created_at,lastActivity:e.last_activity,status:e.status,mcpConnected:e.mcp_connected,style:{marginTop:4}}),e.summary&&(0,W.jsx)("div",{style:{position:"relative",marginTop:4},children:(0,W.jsx)("div",{className:"no-scrollbar",style:{overflowX:"auto",overflowY:"hidden",scrollbarWidth:"none",WebkitOverflowScrolling:"touch",maskImage:"linear-gradient(to right, #000 calc(100% - 40px), transparent)",WebkitMaskImage:"linear-gradient(to right, #000 calc(100% - 40px), transparent)"},children:(0,W.jsx)(i.default,{style:[le.summary,{marginTop:0,whiteSpace:"nowrap"}],children:e.summary})})}),p&&p.length>0&&(0,W.jsx)(a.default,{style:le.hitsContainer,children:p.slice(0,3).map((t,n)=>(0,W.jsx)("div",{onClick:n=>{n.stopPropagation(),x?.(e.id,t.seq)},style:{cursor:"pointer"},children:(0,W.jsx)(i.default,{style:le.hitSnippet,numberOfLines:2,children:t.content})},n))})]})})}function N(e){const t=e.split("\n");let n=0;for(;n<t.length&&(""===t[n].trim()||/^#{1,6}\s/.test(t[n].trim()));)n++;return(t.slice(n).join("\n").trim()||e.trim()).split(/\n[ \t]*\n+/).map(e=>e.replace(/\s*\n\s*/g," ").replace(/[ \t]{2,}/g," ").trim()).filter(Boolean).join("\n")}const $=new Set(["the","and","for","with","that","this","from","are","was","but","not","you"]);function F(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function V(e){return(e.toLowerCase().match(/[\p{L}\p{N}]+/gu)??[]).filter(e=>e.length>=2&&!$.has(e))}function q(e,t){const n=N(e),o=V(t),a=n.toLowerCase();let i=-1;for(const e of o){const t=a.indexOf(e);t>=0&&(i<0||t<i)&&(i=t)}let l=0;if(i>60){l=i-50;const e=n.indexOf(" ",l);e>=0&&e<l+15&&(l=e+1)}const s=Math.min(n.length,l+220);let d=n.slice(l,s);if(l>0&&(d=`\u2026${d}`),s<n.length&&(d=`${d}\u2026`),0===o.length)return[{text:d,match:!1}];const c=new RegExp(`(${o.map(F).sort((e,t)=>t.length-e.length).join("|")})`,"giu"),u=[];let f,h=0;for(;null!==(f=c.exec(d));)f.index>h&&u.push({text:d.slice(h,f.index),match:!1}),u.push({text:f[0],match:!0}),h=f.index+f[0].length,f.index===c.lastIndex&&c.lastIndex++;return h<d.length&&u.push({text:d.slice(h),match:!1}),u}function G({icon:e,label:t,count:n,collapsed:o,onToggle:l,order:d,onToggleOrder:c}){return(0,W.jsxs)(a.default,{style:[le.wikiBar,o&&le.wikiBarCollapsed],children:[(0,W.jsx)(i.default,{style:le.wikiBarIcon,children:e}),(0,W.jsx)(i.default,{style:le.wikiBarLabel,numberOfLines:1,children:t}),(0,W.jsx)(i.default,{style:le.wikiBarCount,numberOfLines:1,children:n}),(0,W.jsx)(a.default,{style:{flex:1}}),d&&c&&!o&&(0,W.jsx)(s.default,{onPress:c,hitSlop:6,style:({pressed:e})=>[le.wikiBarPill,e&&le.wikiBarPillPressed],children:(0,W.jsx)(i.default,{style:le.wikiBarOrderLabel,children:"recent"===d?"Recency":"Relevance"})}),(0,W.jsx)(s.default,{onPress:l,hitSlop:6,style:({pressed:e})=>[le.wikiBarPill,e&&le.wikiBarPillPressed],children:(0,W.jsx)(i.default,{style:le.wikiBarToggle,children:o?"Show":"Hide"})})]})}function Y({results:e,query:t,collapsed:n,onToggle:o,onOpen:l}){return 0===e.length?null:(0,W.jsxs)(a.default,{style:le.wikiSection,children:[(0,W.jsx)(G,{icon:"\ud83d\udcd6",label:"Wiki",count:e.length,collapsed:n,onToggle:o}),!n&&e.map(e=>(0,W.jsxs)(a.default,{style:le.wikiCard,children:[(0,W.jsx)(s.default,{onPress:()=>l(e.source,e.slug,e.hits[0]?.anchor),children:(0,W.jsxs)(a.default,{style:le.wikiCardHeader,children:[(0,W.jsx)(i.default,{style:le.wikiSlug,numberOfLines:1,children:e.slug.replace(/\.md$/,"")}),(0,W.jsx)(i.default,{style:le.wikiSource,children:e.source})]})}),(0,W.jsx)(a.default,{style:le.hitsContainer,children:e.hits.slice(0,3).map((n,o)=>(0,W.jsxs)(s.default,{onPress:()=>l(e.source,e.slug,n.anchor),children:[!!n.anchor&&(0,W.jsxs)(i.default,{style:le.wikiHitCitation,children:["#",n.anchor]}),(0,W.jsx)(i.default,{style:le.hitSnippet,numberOfLines:3,children:q(n.content,t).map((e,t)=>e.match?(0,W.jsx)(i.default,{style:le.hitMatch,children:e.text},t):e.text)})]},o))})]},`${e.source}\0${e.slug}`))]})}function U(e){const t=new Map;for(const n of e)for(const e of n.cost??[]){const n=t.get(e.unit)??{unit:e.unit,amount:0,metered:0};n.amount+=e.amount,n.metered+=e.metered,t.set(e.unit,n)}return[...t.values()].sort((e,t)=>t.metered-e.metered)}const K="\xa0";function Q(e){if(!e?.length)return null;return e.map(e=>{return`${t=(0,C.formatCost)(e.amount,e.unit),(t??"").replace(/(\d) ([A-Za-z])/g,`$1${K}$2`)}${K}(${e.metered})`;var t}).join(" + ")}function X({branes:e,activeBraneId:t,daemons:n,activeDaemon:l,connected:u,onSwitchBrane:m,onSwitchDaemon:p,onAdd:x,onRemove:y,onSignOutOthers:b,conn:j}){const[v,w]=(0,o.useState)(!1),[S,C]=(0,o.useState)(!1),[T,k]=(0,o.useState)(!1),[B,R]=(0,o.useState)(!1),[O,z]=(0,o.useState)(!1),[P,I]=(0,o.useState)(""),[E,L]=(0,o.useState)(""),[D,H]=(0,o.useState)(!1),[A,M]=(0,o.useState)(null),[N,$]=(0,o.useState)(null),[F,V]=(0,o.useState)(!1),q=()=>{w(!1),C(!1),k(!1),z(!1),$(null),V(!1)},G=()=>{B||(k(!1),$(null))},Y=()=>{D||(C(!1),M(null))},K=(0,o.useMemo)(()=>U(e),[e]),X=t?e.find(e=>e.brane_id===t)?.is_home?`${t} (home)`:t:l?.id??"No daemon";return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(s.default,{style:le.daemonChip,onPress:()=>w(!0),children:[(0,W.jsx)(a.default,{style:[le.chipDot,{backgroundColor:u?"#66d9a0":"#e07070"}]}),(0,W.jsx)(i.default,{style:le.chipText,numberOfLines:1,children:X}),(0,W.jsx)(i.default,{style:le.chipChevron,children:"\u25bc"})]}),(0,W.jsx)(d.default,{visible:v,transparent:!0,animationType:"fade",onRequestClose:q,children:(0,W.jsx)(s.default,{style:le.modalOverlay,onPress:q,children:(0,W.jsxs)(s.default,{style:le.modalContent,onPress:()=>{},children:[(0,W.jsx)(i.default,{style:le.modalTitle,children:"Branes"}),(0,W.jsxs)(c.default,{style:{flexGrow:0},children:[(0,W.jsx)(s.default,{style:[le.daemonOption,null===t&&le.daemonOptionActive],onPress:()=>{m(null),w(!1)},children:(0,W.jsxs)(a.default,{style:le.daemonOptionRow,children:[(0,W.jsx)(a.default,{style:[le.daemonDot,{backgroundColor:u?"#66d9a0":"#555"}]}),(0,W.jsxs)(a.default,{style:{flex:1},children:[(0,W.jsx)(i.default,{style:le.daemonName,children:"All branes"}),(0,W.jsx)(i.default,{style:le.daemonHost,children:l?.id}),Q(K)&&(0,W.jsx)(i.default,{style:le.daemonCost,children:Q(K)})]})]})}),e.map(e=>(0,W.jsx)(s.default,{style:[le.daemonOption,e.brane_id===t&&le.daemonOptionActive],onPress:()=>{m(e.brane_id),w(!1)},children:(0,W.jsxs)(a.default,{style:le.daemonOptionRow,children:[(0,W.jsx)(a.default,{style:[le.daemonDot,{backgroundColor:e.active_count>0?"#66d9a0":"#555"}]}),(0,W.jsxs)(a.default,{style:{flex:1},children:[(0,W.jsxs)(i.default,{style:le.daemonName,children:[e.brane_id,e.is_home?" (home)":""]}),(0,W.jsxs)(i.default,{style:le.daemonHost,children:[e.active_count," active, ",e.narrative_count," total",e.absorbed_count>0?` (${e.absorbed_count} absorbed)`:""]}),Q(e.cost)&&(0,W.jsx)(i.default,{style:le.daemonCost,children:Q(e.cost)})]})]})},e.brane_id)),0===e.length&&0===n.length&&(0,W.jsx)(i.default,{style:le.emptyDaemons,children:"No daemons configured"}),n.filter(e=>e.id!==l?.id).map(e=>(0,W.jsx)(s.default,{style:le.daemonOption,onPress:()=>{p(e.id),w(!1)},onLongPress:()=>y(e.id),children:(0,W.jsxs)(a.default,{style:le.daemonOptionRow,children:[(0,W.jsx)(a.default,{style:[le.daemonDot,{backgroundColor:"#555"}]}),(0,W.jsxs)(a.default,{style:{flex:1},children:[(0,W.jsx)(i.default,{style:le.daemonName,children:e.id}),(0,W.jsxs)(i.default,{style:le.daemonHost,children:[e.host," (switch daemon)"]})]})]})},e.id))]}),(0,W.jsx)(s.default,{style:le.addDaemonButton,onPress:()=>C(!0),children:(0,W.jsx)(i.default,{style:le.addDaemonButtonText,children:"+ Add Daemon"})}),l&&!l.revoked&&(0,W.jsx)(s.default,{style:le.addDaemonButton,onPress:()=>z(!0),disabled:!u,children:(0,W.jsx)(i.default,{style:[le.addDaemonButtonText,!u&&{opacity:.5}],children:"Devices"})}),(0,W.jsx)(s.default,{style:le.modalCancel,onPress:q,children:(0,W.jsx)(i.default,{style:le.modalCancelText,children:"Close"})})]})})}),(0,W.jsx)(d.default,{visible:v&&S,transparent:!0,animationType:"fade",onRequestClose:Y,children:(0,W.jsx)(s.default,{style:le.modalOverlay,onPress:Y,children:(0,W.jsxs)(s.default,{style:le.layerCard,onPress:e=>e.stopPropagation(),children:[(0,W.jsx)(i.default,{style:le.layerTitle,children:"Add a daemon"}),(0,W.jsxs)(a.default,{style:le.addForm,children:[(0,W.jsx)(h.default,{style:le.addInput,placeholder:"host:port",placeholderTextColor:"#666",value:P,onChangeText:I,autoCapitalize:"none",autoCorrect:!1,autoFocus:!0}),(0,W.jsx)(h.default,{style:le.addInput,placeholder:"token",placeholderTextColor:"#666",value:E,onChangeText:L,autoCapitalize:"none",autoCorrect:!1,secureTextEntry:!0}),A&&(0,W.jsx)(i.default,{style:le.addError,children:A}),(0,W.jsxs)(a.default,{style:le.layerButtonRow,children:[(0,W.jsx)(s.default,{style:[le.layerCancel,D&&{opacity:.5}],onPress:Y,disabled:D,children:(0,W.jsx)(i.default,{style:le.layerCancelText,children:"Cancel"})}),(0,W.jsx)(s.default,{style:[le.addButton,le.layerConfirm,(D||!P||!E)&&{opacity:.5}],onPress:async()=>{if(P&&E){H(!0),M(null);try{await x(P,E),C(!1),w(!1),I(""),L("")}catch(e){M(String(e))}finally{H(!1)}}},disabled:D||!P||!E,children:D?(0,W.jsx)(f.default,{size:"small",color:"#111"}):(0,W.jsx)(i.default,{style:le.addButtonText,children:"Connect"})})]})]})]})})}),(0,W.jsx)(_.default,{visible:v&&O,conn:j,daemonName:l?.id??"this daemon",onClose:()=>z(!1),onSignOutOthers:()=>k(!0),signedOutOthers:F,connected:u}),(0,W.jsx)(d.default,{visible:v&&T,transparent:!0,animationType:"fade",onRequestClose:G,children:(0,W.jsx)(s.default,{style:le.modalOverlay,onPress:G,children:(0,W.jsxs)(s.default,{style:le.layerCard,onPress:e=>e.stopPropagation(),children:[(0,W.jsx)(i.default,{style:le.layerTitle,children:"Sign out other devices?"}),(0,W.jsxs)(i.default,{style:le.signOutBody,children:[l?.id," will issue a new token. This device keeps its access; every other phone and browser paired with it is signed out until it scans a fresh Meld QR. Running agents and your shell are unaffected."]}),N&&(0,W.jsx)(i.default,{style:le.addError,children:N}),(0,W.jsxs)(a.default,{style:le.layerButtonRow,children:[(0,W.jsx)(s.default,{style:[le.layerCancel,B&&{opacity:.5}],onPress:G,disabled:B,children:(0,W.jsx)(i.default,{style:le.layerCancelText,children:"Cancel"})}),(0,W.jsx)(s.default,{style:[le.signOutButton,le.layerConfirm,B&&{opacity:.5}],onPress:async()=>{R(!0),$(null);try{await b(),V(!0),k(!1)}catch(e){$(String(e))}finally{R(!1)}},disabled:B,children:B?(0,W.jsx)(f.default,{size:"small",color:"#111"}):(0,W.jsx)(i.default,{style:le.addButtonText,children:"Sign out other devices"})})]})]})})})]})}const Z=30,J=.5,ee=64,te=96,ne=52,oe=360;function re(e){return-Math.min(e,te)/te*oe}function ae({refreshing:e,onRefresh:t,scrollOffsetRef:n,children:a}){const i=(0,o.useRef)(null),[l,s]=(0,o.useState)(0),[d,c]=(0,o.useState)(!1),[u,f]=(0,B.useDetentSpin)(e),[h,m]=(0,o.useState)("none"),p=(0,o.useRef)(0),x=(0,o.useRef)(null),y=(0,o.useRef)(!1),b=(0,o.useCallback)(e=>{p.current=e,s(e)},[]);(0,o.useEffect)(()=>{const o=i.current;if(!o)return;const a=()=>(n.current??0)<=0,l=t=>{if(e||1!==t.touches.length||!a())return y.current=!1,void(x.current=null);x.current=t.touches[0].clientY,y.current=!0},s=t=>{if(!y.current||null===x.current||e)return;const n=t.touches[0].clientY-x.current;if(n<=0||!a())return a()||(y.current=!1),0!==p.current&&(b(0),f(0)),void c(!1);t.preventDefault();const o=Math.min(te,n*J);c(!0),m("none"),b(o),f(re(o))},d=()=>{var n;y.current&&(y.current=!1,x.current=null,c(!1),p.current>=ee&&!e?(f((n=re(p.current),Math.round(n/B.RECYCLE_STEP)*B.RECYCLE_STEP)),b(ne),t()):(m("transform 0.4s ease"),f(0),b(0)))};return o.addEventListener("touchstart",l,{passive:!0}),o.addEventListener("touchmove",s,{passive:!1}),o.addEventListener("touchend",d,{passive:!0}),o.addEventListener("touchcancel",d,{passive:!0}),()=>{o.removeEventListener("touchstart",l),o.removeEventListener("touchmove",s),o.removeEventListener("touchend",d),o.removeEventListener("touchcancel",d)}},[e,t,n,b]),(0,o.useEffect)(()=>{if(!e)return 0!==p.current&&b(0),m("none"),void f(0);m("transform 0.18s ease")},[e,b,f]);const j=d?"none":"transform 0.25s ease";return(0,W.jsxs)("div",{ref:i,style:{flex:1,minHeight:0,position:"relative",overflow:"hidden",display:"flex",flexDirection:"column"},children:[(0,W.jsx)("div",{style:{position:"absolute",top:0,left:0,right:0,height:ne,display:"flex",alignItems:"center",justifyContent:"center",transform:`translateY(${l-ne}px)`,transition:j,pointerEvents:"none",zIndex:1},children:(0,W.jsx)(B.RecycleGlyph,{angle:u,transition:h,fontSize:26,opacity:e?1:Math.min(1,l/ee)})}),(0,W.jsx)("div",{style:{flex:1,minHeight:0,display:"flex",flexDirection:"column",transform:`translateY(${l}px)`,transition:j},children:a})]})}function ie(){const{conn:e,connected:t,daemons:n,activeDaemon:d,activeBraneId:c,switchDaemon:u,switchBrane:y,addDaemon:j,removeDaemon:v,rotateActiveToken:w,onStatus:S,onMeta:B,onActivity:_,subscribeActivity:N,unsubscribeActivity:$}=(0,x.useBrane)(),[F,V]=(0,o.useState)([]),[q,U]=(0,o.useState)([]),K=(0,o.useRef)(null),[Q,J]=(0,o.useState)([]),[ee,te]=(0,o.useState)(!0),[ne,oe]=(0,o.useState)(!1),[re,ie]=(0,o.useState)(!1),[se,de]=(0,o.useState)(null),[ce,ue]=(0,o.useState)(null),[fe,he]=(0,o.useState)(null),[me,ge]=(0,o.useState)(null),[pe,xe]=(0,o.useState)(Z),[ye,be]=(0,o.useState)(!1),[je,ve]=(0,o.useState)(""),[we,Se]=(0,o.useState)([]),[Ce,Te]=(0,o.useState)(!1),[ke,Be]=(0,o.useState)([]),[Re,Oe]=(0,o.useState)(!1),[ze,Pe]=(0,o.useState)(!1),[Ie,Ee]=(0,o.useState)("relevance"),[Le,De]=(0,o.useState)(null),We=(0,o.useRef)(null),He=(0,o.useRef)(null),Ae=(0,o.useRef)(null),Me=(0,o.useRef)(0),Ne=(0,m.useRouter)(),$e=(0,p.useIsFocused)(),Fe=(0,o.useRef)(!1);Fe.current=$e;const Ve=(0,o.useRef)(null);(0,o.useEffect)(()=>{if(!$e)return;const e=e=>{if(!Fe.current)return;if(e.defaultPrevented||e.isComposing||!(0,L.isListScrollKey)(e))return;const t=Ae.current?.getScrollableNode();if(!t)return;const n=e.target,o=n?.tagName;if("INPUT"===o||"TEXTAREA"===o||"SELECT"===o||n?.isContentEditable)return;if(n&&t.contains(n))return;if(document.querySelector('[aria-modal="true"]'))return;const a=performance.now(),i=Ve.current,l=i&&a-i.at<H?i.target:t.scrollTop,s=(0,L.listScrollTarget)(e.key,l,t);if(null===s)return;e.preventDefault(),Ve.current={target:s,at:a};const d=window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;t.scroll({top:s,behavior:e.repeat||d?"auto":"smooth"})};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[$e]);const qe=(0,o.useCallback)(async()=>{if(e){ge(null),xe(Z);try{const t=c?{archived:!0,braneIds:[c]}:void 0,[n,o,a]=await Promise.all([(0,C.fetchNarratives)(e,t),(0,C.fetchFolds)(e),(0,C.fetchBranes)(e).catch(()=>[])]);V((0,I.sortNarratives)(n)),J(o),U(a),setTimeout(()=>{Ae.current?.scrollToOffset({offset:0,animated:!1})},50)}catch(e){ge(String(e)),V([]),J([]),U([])}finally{te(!1)}}},[e,c]),Ge=(0,o.useCallback)(async()=>{if(e&&!ne){oe(!0);try{await qe()}finally{oe(!1)}}},[e,ne,qe]);(0,o.useEffect)(()=>{if(e)V([]),J([]),U([]),te(!0),qe();else if(V([]),J([]),U([]),te(!1),0===n.length){const e=setTimeout(()=>{ge(null),te(!1)},100);return()=>clearTimeout(e)}},[e,qe,n.length]);const Ye=(0,o.useCallback)(()=>{e&&ie(!0)},[e]),Ue=(0,o.useCallback)(e=>{V(t=>[e,...t]),Ne.push("utility"===e.role?`/${e.id}?tab=terminal`:`/${e.id}`)},[Ne]),Ke=(0,o.useCallback)(async t=>{if(!e)return;if((0,b.revivesAsTwin)(t.role))return void he(t);const n=t.id;try{const t=(await(0,C.reviveNarrative)(e,n)).nid??n;t!==n&&qe(),Ne.push((0,P.terminalOnlyHref)(t))}catch(e){ge(String(e))}},[e,Ne,qe]),Qe=(0,o.useCallback)(t=>{e&&((0,D.interruptSession)(e,t),Ne.push((0,P.terminalOnlyHref)(t)))},[e,Ne]),Xe=(0,o.useCallback)(async(t,n)=>{if(!e)return;const o=!n;try{await(0,C.archiveNarrative)(e,t,o),V(o?e=>e.filter(e=>e.id!==t):e=>e.map(e=>e.id===t?Object.assign({},e,{archived:!1}):e))}catch(e){ge(String(e))}},[e]),Ze=(0,o.useCallback)(async(e,t)=>{await j(e,t)},[j]);(0,o.useEffect)(()=>S((e,t)=>{V(n=>(0,I.sortNarratives)(n.map(n=>n.id!==e?n:"mcp_connected"===t?Object.assign({},n,{mcp_connected:!0}):"mcp_disconnected"===t?Object.assign({},n,{mcp_connected:!1,awaiting:!1}):t===E.AWAITING_STATUS?Object.assign({},n,{awaiting:!0}):t===E.NOT_AWAITING_STATUS?Object.assign({},n,{awaiting:!1}):Object.assign({},n,{status:t}))))}),[S]),(0,o.useEffect)(()=>B((t,n,o,a)=>{null!=a&&e&&(K.current&&clearTimeout(K.current),K.current=setTimeout(()=>{K.current=null,(0,C.fetchBranes)(e).then(U).catch(()=>{})},2e3)),V(e=>e.map(e=>{if(e.id!==t)return e;if(void 0===o&&null==a)return e;const n=Object.assign({},e);return void 0!==o&&(n.summary=o),null!=a&&(n.cost_amount=a.amount,n.cost_unit=a.unit),n}))}),[B,e]),(0,o.useEffect)(()=>{N();const e=_((e,t,n)=>{V(t=>{const o=t.findIndex(t=>t.id===e);if(o<0)return t;const a=t.slice();return a[o]=Object.assign({},a[o],{last_activity:n}),a})});return()=>{e(),$()}},[_,N,$]);const Je=!e&&0===n.length,[et,tt]=(0,o.useState)([]);(0,o.useEffect)(()=>e&&je.trim()?(Te(!0),We.current&&clearTimeout(We.current),We.current=setTimeout(()=>{(0,C.searchNarratives)(e,je.trim(),30,c?[c]:void 0).then(e=>{Se(e.results),tt(e.narratives||[]),Te(!1)}).catch(()=>{Se([]),tt([]),Te(!1)}),(0,C.searchWiki)(e,je.trim(),10).then(e=>Be(e.results)).catch(()=>Be([]))},300),()=>{We.current&&clearTimeout(We.current)}):(Se([]),tt([]),Be([]),void Te(!1)),[e,je,c]);const nt=(0,o.useMemo)(()=>new Set(F.map(e=>e.id)),[F]),ot=(0,o.useMemo)(()=>{const e=new Map;for(const t of we){const n=e.get(t.narrative_id);n?n.push(t):e.set(t.narrative_id,[t])}return e},[we]),rt=(0,o.useMemo)(()=>{if(!je.trim())return F;const e=je.toLowerCase(),t=new Set(F.filter(t=>t.id.toLowerCase().includes(e)||t.summary?.toLowerCase().includes(e)||t.agent_type?.toLowerCase().includes(e)||t.role?.toLowerCase().includes(e)||t.fold_path?.toLowerCase().includes(e)||ot.has(t.id)).map(e=>e.id)),n=new Map(F.map(e=>[e.id,e])),o=new Map;for(const e of t)o.set(e,n.get(e));for(const e of et)o.has(e.id)||o.set(e.id,e);return[...o.values()]},[F,je,ot,et]),at=(0,o.useMemo)(()=>{const e=new Map;for(const t of we){const n=e.get(t.narrative_id);(void 0===n||t.score>n)&&e.set(t.narrative_id,t.score)}return e},[we]),it=(0,o.useMemo)(()=>{if(je.trim())return[...rt].sort((e,t)=>{if("recent"===Ie)return t.created_at-e.created_at;const n=at.get(e.id)??-1/0,o=at.get(t.id)??-1/0;return n!==o?o-n:t.created_at-e.created_at});const e=[],t=[];for(const n of rt)"ended"!==n.status||n.mcp_connected?e.push(n):t.push(n);return[...e,...t.slice(0,pe)]},[rt,pe,je,Ie,at]);(0,o.useEffect)(()=>{se&&!it.some(e=>e.id===se)&&de(null)},[it,se]);const lt=(0,o.useMemo)(()=>rt.filter(e=>"ended"===e.status&&!e.mcp_connected).length,[rt]),st=(0,o.useCallback)(()=>{xe(e=>Math.min(e+Z,lt))},[lt]);return(0,W.jsxs)(a.default,{style:le.container,children:[(0,W.jsx)(m.Stack.Screen,{options:{header:()=>(0,W.jsxs)(a.default,{style:le.customHeader,children:[(0,W.jsxs)(a.default,{style:le.headerTitleRow,children:[(0,W.jsx)(s.default,{onPress:qe,children:(0,W.jsx)(i.default,{style:Object.assign({color:"#8fd4b4",fontSize:20,fontWeight:"700",letterSpacing:2},{textShadow:["0 0 7px rgba(143, 212, 180, 0.8)","0 0 20px rgba(143, 212, 180, 0.5)","0 0 40px rgba(100, 200, 160, 0.3)","0 2px 12px rgba(80, 180, 140, 0.6)"].join(", ")}),children:"BRANE"})}),(0,W.jsx)(s.default,{onPress:Ye,disabled:!e,style:[le.spawnButton,!e&&le.spawnButtonDisabled],children:(0,W.jsx)(i.default,{style:le.spawnButtonText,children:"Spawn"})}),(0,W.jsx)(X,{branes:q,activeBraneId:c,daemons:n,activeDaemon:d,connected:t,onSwitchBrane:y,onSwitchDaemon:u,onAdd:Ze,onRemove:v,onSignOutOthers:w,conn:e}),(0,W.jsx)(s.default,{onPress:()=>{be(e=>(e?ve(""):setTimeout(()=>He.current?.focus(),100),!e))},style:[le.searchButton,ye&&le.searchButtonActive],children:(0,W.jsx)(i.default,{style:[le.searchButtonText,ye&&le.searchButtonTextActive],children:"\ud83d\udd2c"})})]}),ye&&(0,W.jsx)(a.default,{style:le.searchBar,children:(0,W.jsx)(h.default,{ref:He,style:le.searchInput,placeholder:"Filter narratives...",placeholderTextColor:"#556",value:je,onChangeText:ve,autoFocus:!0,autoCapitalize:"none",autoCorrect:!1,returnKeyType:"search"})})]})}}),d?.revoked?(0,W.jsxs)(a.default,{style:le.center,children:[(0,W.jsxs)(i.default,{style:le.signedOutTitle,children:["Signed out of ",d.id]}),(0,W.jsx)(i.default,{style:le.emptySubtext,children:"Its token was rotated from another device, so the one stored here no longer works. Scan a fresh Meld QR \u2014 or run `brane meld` on that machine \u2014 to reconnect. Nothing else was touched."})]}):ee?(0,W.jsx)(a.default,{style:le.center,children:(0,W.jsx)(f.default,{size:"large",color:"#5b9bd5"})}):me?(0,W.jsx)(a.default,{style:le.center,children:(0,W.jsx)(i.default,{style:le.errorText,children:me})}):Je?(0,W.jsx)(O.default,{title:"No daemons configured",subtitle:"Tap the daemon selector above to add one"}):(0,W.jsx)(ae,{refreshing:ne,onRefresh:Ge,scrollOffsetRef:Me,children:(0,W.jsx)(l.default,{ref:Ae,style:{flex:1},data:je.trim()&&ze?[]:it,keyExtractor:e=>e.id,CellRendererComponent:A,onScroll:e=>{Me.current=e.nativeEvent.contentOffset.y},scrollEventThrottle:16,ListHeaderComponent:je.trim()?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(Y,{results:ke,query:je.trim(),collapsed:Re,onToggle:()=>Oe(e=>!e),onOpen:(e,t,n)=>De({source:e,slug:t,anchor:n})}),(0,W.jsx)(a.default,{style:le.wikiSection,children:(0,W.jsx)(G,{icon:"\ud83d\udcac",label:"Narratives",count:it.length,collapsed:ze,onToggle:()=>Pe(e=>!e),order:Ie,onToggleOrder:()=>Ee(e=>"relevance"===e?"recent":"relevance")})})]}):null,renderItem:({item:t})=>(0,W.jsx)(M,{item:t,conn:e,onPress:()=>Ne.push(`/${t.id}`),onArchive:()=>Xe(t.id,!!t.archived),onMeld:()=>ue(t),onTwin:()=>he(t),onRevive:()=>Ke(t),onEnd:()=>Qe(t.id),menuVisible:se===t.id,setMenuVisible:e=>de(e?t.id:null),hits:ot.get(t.id),onHitPress:(e,t)=>Ne.push(`/${e}?scrollToSeq=${t}`)}),onEndReached:!je.trim()&&pe<lt?st:void 0,onEndReachedThreshold:.3,ListFooterComponent:it.length>0&&!je.trim()?(0,W.jsx)(O.default,{}):null,contentContainerStyle:0!==it.length||je.trim()?void 0:le.emptyFill,ListEmptyComponent:je.trim()?ze?null:(0,W.jsx)(a.default,{style:le.center,children:(0,W.jsx)(i.default,{style:le.emptyText,children:"No narratives match"})}):(0,W.jsx)(O.default,{title:"No narratives yet"})})}),(0,W.jsx)(R.default,{visible:re,conn:e,onClose:()=>{ie(!1),e&&(0,C.fetchFolds)(e).then(J).catch(()=>{})},onSpawned:Ue}),(0,W.jsx)(z.default,{visible:null!==ce,conn:e,path:`/${ce?.id??""}`,onClose:()=>ue(null)}),(0,W.jsx)(R.default,{visible:null!==fe,conn:e,re:fe?.id,defaultFoldPath:fe?.fold_path,onClose:()=>he(null),onSpawned:Ue}),Le&&e&&(0,W.jsx)(k.MarkdownLinksProvider,{knownNarrativeIds:nt,onNarrativePress:(e,t)=>{De(null),Ne.push(null!=t?`/${e}?scrollToSeq=${t}`:`/${e}`)},children:(0,W.jsx)(T.default,{conn:e,target:Le,onClose:()=>De(null)})})]})}const le=u.default.create({container:{flex:1},center:{flex:1,justifyContent:"center",alignItems:"center",padding:20},customHeader:{backgroundColor:"#1a1a1e",paddingTop:10,paddingHorizontal:16,paddingBottom:10,borderBottomWidth:u.default.hairlineWidth,borderBottomColor:"rgb(216, 216, 216)"},headerTitleRow:{flexDirection:"row",alignItems:"center",gap:12},daemonChip:{flexDirection:"row",alignItems:"center",backgroundColor:"#2a2a30",borderRadius:6,paddingHorizontal:10,paddingVertical:6,maxWidth:180},chipDot:{width:8,height:8,borderRadius:4,marginRight:8},chipText:{color:"#d8d8dd",fontSize:15,fontFamily:"monospace"},chipChevron:{color:"#888",fontSize:14,marginLeft:5},daemonOption:{paddingVertical:12,paddingHorizontal:12,borderRadius:8,backgroundColor:"#2a2a30",marginBottom:6},daemonOptionActive:{backgroundColor:"#1a3a2a",borderWidth:1,borderColor:"#3a6a4a"},daemonOptionRow:{flexDirection:"row",alignItems:"center"},daemonDot:{width:8,height:8,borderRadius:4,marginRight:10},daemonName:{color:"#d8d8dd",fontSize:15,fontFamily:"monospace"},daemonCost:{color:"#7bb894",fontSize:12,fontFamily:"monospace",marginTop:2},daemonHost:{color:"#777",fontSize:12,fontFamily:"monospace",marginTop:2},emptyDaemons:{color:"#666",fontSize:14,textAlign:"center",paddingVertical:16},addDaemonButton:{paddingVertical:14,alignItems:"center",borderRadius:8,backgroundColor:"#2a2a30",marginTop:8},addDaemonButtonText:{color:"#8fd4b4",fontSize:15,fontWeight:"600"},addForm:{marginTop:8,gap:8},addInput:{backgroundColor:"#222228",borderRadius:8,paddingHorizontal:12,paddingVertical:10,color:"#d8d8dd",fontSize:14,fontFamily:"monospace",borderWidth:1,borderColor:"#3a3a40"},addError:{color:"#e07070",fontSize:12},addButton:{backgroundColor:"#5b9bd5",borderRadius:8,paddingVertical:10,alignItems:"center"},addButtonText:{color:"#111",fontSize:14,fontWeight:"600"},signOutBody:{color:"#999",fontSize:13,lineHeight:18},layerCard:{backgroundColor:"#1e1e22",borderRadius:12,padding:20,width:"100%",maxWidth:360,borderWidth:1,borderColor:"#3a3a40"},layerTitle:{color:"#d8d8dd",fontSize:16,fontWeight:"600",marginBottom:10},layerButtonRow:{flexDirection:"row",gap:8,marginTop:4},layerCancel:{flex:1,backgroundColor:"#2a2a30",borderRadius:8,paddingVertical:10,alignItems:"center"},layerCancelText:{color:"#aaa",fontSize:14,fontWeight:"600"},layerConfirm:{flex:2},signOutButton:{backgroundColor:"#e0a070",borderRadius:8,paddingVertical:10,alignItems:"center"},signedOutTitle:{color:"#e0a070",fontSize:16,fontWeight:"600",marginBottom:8,textAlign:"center"},fieldLabel:{color:"#aaa",fontSize:12,fontWeight:"600",textTransform:"uppercase",letterSpacing:.5,marginTop:12,marginBottom:6},fieldStaticValue:{backgroundColor:"#222228",borderRadius:8,paddingHorizontal:12,paddingVertical:10,borderWidth:1,borderColor:"#2a2a30"},cardHeader:{flexDirection:"row",justifyContent:"space-between",alignItems:"center"},summary:{color:"#9a9aa0",fontSize:12,marginTop:4,lineHeight:12},status:{fontSize:12,textTransform:"uppercase"},hitsContainer:{marginTop:8,gap:4},hitSnippet:{color:"#b0a890",fontSize:12,lineHeight:17,paddingLeft:10,paddingVertical:3,borderLeftWidth:2,borderLeftColor:"rgba(255, 130, 180, 0.5)",backgroundColor:"rgba(255, 130, 180, 0.04)",borderRadius:2},wikiSection:{paddingHorizontal:14,paddingTop:12,paddingBottom:4},wikiBar:Object.assign({flexDirection:"row",alignItems:"center",gap:6,paddingVertical:11,paddingHorizontal:12,marginBottom:8,borderRadius:8,backgroundColor:"rgba(143, 212, 180, 0.12)",borderWidth:1,borderColor:"rgba(143, 212, 180, 0.35)"},{userSelect:"none"}),wikiBarCollapsed:{backgroundColor:"rgba(143, 212, 180, 0.06)",borderColor:"rgba(143, 212, 180, 0.22)"},wikiBarPillPressed:{backgroundColor:"rgba(143, 212, 180, 0.18)"},wikiBarPill:Object.assign({flexDirection:"row",alignItems:"center",gap:5,paddingVertical:3,paddingHorizontal:8,borderRadius:9,flexShrink:0,backgroundColor:"rgba(0, 0, 0, 0.32)",borderWidth:1,borderColor:"rgba(143, 212, 180, 0.35)"},{cursor:"pointer",userSelect:"none"}),wikiBarOrderLabel:{color:"#cdeede",fontSize:13,fontWeight:"400",letterSpacing:.5,textTransform:"uppercase"},wikiBarIcon:{fontSize:15},wikiBarLabel:{color:"#8fd4b4",fontSize:13,fontWeight:"700",letterSpacing:1,textTransform:"uppercase",flexShrink:1},wikiBarCount:{color:"#bfe6d3",fontSize:12,fontWeight:"700",fontFamily:"monospace",flexShrink:0},wikiBarToggle:{color:"#cdeede",fontSize:13,fontWeight:"400",textTransform:"uppercase",letterSpacing:.5},wikiCard:{backgroundColor:"#1e1e24",borderRadius:8,padding:12,marginBottom:8,borderWidth:u.default.hairlineWidth,borderColor:"rgba(143, 212, 180, 0.25)"},wikiCardHeader:{flexDirection:"row",alignItems:"center",gap:8},wikiSlug:{color:"#d8d8dd",fontSize:15,fontWeight:"600",fontFamily:"monospace",flex:1},wikiSource:{color:"#7a8a9a",fontSize:11,fontFamily:"monospace",backgroundColor:"#2a2a32",paddingHorizontal:6,paddingVertical:2,borderRadius:4,overflow:"hidden"},wikiHitCitation:{color:"#6c9bd5",fontSize:11,fontFamily:"monospace",paddingLeft:10,marginTop:4},hitMatch:{color:"#ffd9ec",fontWeight:"700",backgroundColor:"rgba(255, 130, 180, 0.22)"},emptyFill:{flexGrow:1},emptyText:{color:"#666",fontSize:16},emptySubtext:{color:"#555",fontSize:13,marginTop:8},errorText:{color:"#e07070",fontSize:14,textAlign:"center"},searchButton:{paddingLeft:16,paddingVertical:8,marginLeft:"auto",marginRight:-5},searchButtonActive:{},searchButtonText:{fontSize:20},searchButtonTextActive:Object.assign({},{textShadow:["0 0 10px rgba(255, 130, 180, 0.9)","0 0 25px rgba(255, 110, 165, 0.7)","0 0 50px rgba(255, 100, 155, 0.4)","0 2px 15px rgba(255, 120, 170, 0.6)"].join(", ")}),searchBar:{flexDirection:"row",alignItems:"center",marginTop:10},searchInput:Object.assign({flex:1,color:"#d8d8dd",fontSize:16,fontFamily:"monospace",backgroundColor:"#222228",borderRadius:8,paddingHorizontal:12,paddingVertical:6,borderWidth:1,borderColor:"rgba(255, 130, 180, 0.4)"},{outlineStyle:"none",boxShadow:["0 0 6px rgba(255, 130, 180, 0.5)","0 0 14px rgba(255, 110, 165, 0.35)","0 0 28px rgba(255, 100, 155, 0.2)"].join(", ")}),spawnButton:Object.assign({paddingHorizontal:12,paddingVertical:6,borderRadius:6,backgroundColor:"#5b9bd5",justifyContent:"center",alignItems:"center",marginLeft:0},{boxShadow:["0 0 6px rgba(91, 155, 213, 0.7)","0 0 16px rgba(91, 155, 213, 0.4)","0 2px 10px rgba(70, 130, 200, 0.5)"].join(", ")}),spawnButtonDisabled:{opacity:.4},spawnButtonText:{color:"#111",fontSize:14,fontWeight:"600"},modalOverlay:{flex:1,backgroundColor:"rgba(0,0,0,0.6)",justifyContent:"center",alignItems:"center",padding:24},modalContent:{backgroundColor:"#1e1e22",borderRadius:12,padding:20,width:"100%",maxWidth:400,maxHeight:"80%"},modalTitle:{color:"#d8d8dd",fontSize:18,fontWeight:"600",marginBottom:16},foldOption:{paddingVertical:14,paddingHorizontal:12,borderRadius:8,backgroundColor:"#2a2a30",marginBottom:8},foldOptionText:{color:"#d8d8dd",fontSize:15,fontFamily:"monospace"},modalCancel:{paddingVertical:12,alignItems:"center",marginTop:8},modalCancelText:{color:"#888",fontSize:15}})},979,[167,11,13,105,113,146,153,122,26,416,145,161,165,116,736,773,769,770,776,767,778,745,973,950,965,972,980,780,987,747,977,753,988,764,6]);
1083
- __d(function(g,r,i,a,m,_e,d){"use strict";const e=["title","subtitle"];function t(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return f}});var n=t(r(d[0]));r(d[1]);var l=t(r(d[2])),u=t(r(d[3])),c=t(r(d[4])),s=t(r(d[5])),o=r(d[6]);function f(t){let{title:l,subtitle:f}=t,x=(0,n.default)(t,e);return(0,o.jsxs)(c.default,{style:p.center,children:[(0,o.jsx)(s.default,Object.assign({},x)),l?(0,o.jsx)(u.default,{style:p.emptyText,children:l}):null,f?(0,o.jsx)(u.default,{style:p.emptySubtext,children:f}):null]})}const p=l.default.create({center:{flex:1,justifyContent:"center",alignItems:"center",padding:20,gap:4},emptyText:{color:"#666",fontSize:16,marginTop:20},emptySubtext:{color:"#555",fontSize:13,marginTop:4,textAlign:"center"}})},980,[167,11,26,105,13,981,6]);
1084
- __d(function(_g,_r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return E}});var e=_r(d[0]),t=_r(d[1]),n=_r(d[2]),o=_r(d[3]),i=_r(d[4]),r=_r(d[5]),a=_r(d[6]);const s="#121214",l=i.TERRAIN_ROWS+r.MAX_SPLOTCHES,c="\nattribute vec2 a_pos;\nvoid main() { gl_Position = vec4(a_pos, 0.0, 1.0); }\n",h=`\nprecision highp float;\nuniform vec2 u_res; // drawing buffer size, px\nuniform vec4 u_glyph; // x, y (top-left, px from top-left), w, h (w == h)\nuniform vec2 u_offset; // the noise window's integrated drift: x sway, y lift\nuniform float u_phase; // the noise's integrated time phase (churn)\nuniform sampler2D u_mask;\nuniform vec3 u_bg;\n// Two tables, as float textures read by index, so neither has a size a hand\n// will meet (claude-1cwe8u9p:61). Schemes (src/shared/membrane-palette.ts,\n// packScheme): one row each, the first TERRAIN_ROWS the terrain block\n// (src/shared/membrane-terrain.ts, blockRows / packCell, which adds the\n// cell's seed point as a last texel), the rest the groups'. Splotches\n// (src/shared/membrane-invasion.ts, packSplotches): one row each, oldest\n// first, naming the scheme row they paint in.\nuniform sampler2D u_schemes;\nuniform sampler2D u_splotchTable;\nuniform float u_splotchCount;\nuniform float u_clock; // seconds; animates the dithering of the fronts\nuniform vec2 u_drag; // accumulated drag, glyph widths: world = p - u_drag\nuniform vec2 u_cell0; // the block's centre cell (integer coordinates)\n\n// Classic 3D Perlin (gradient) noise; the third axis is time, so the field\n// evolves continuously and never cycles back on itself.\nvec3 grad3(vec3 p) {\n p = vec3(dot(p, vec3(127.1, 311.7, 74.7)),\n dot(p, vec3(269.5, 183.3, 246.1)),\n dot(p, vec3(113.5, 271.9, 124.6)));\n return -1.0 + 2.0 * fract(sin(p) * 43758.5453123);\n}\nfloat perlin(vec3 p) {\n vec3 i = floor(p), f = fract(p);\n vec3 u = f * f * f * (f * (f * 6.0 - 15.0) + 10.0);\n return mix(\n mix(mix(dot(grad3(i + vec3(0,0,0)), f - vec3(0,0,0)), dot(grad3(i + vec3(1,0,0)), f - vec3(1,0,0)), u.x),\n mix(dot(grad3(i + vec3(0,1,0)), f - vec3(0,1,0)), dot(grad3(i + vec3(1,1,0)), f - vec3(1,1,0)), u.x), u.y),\n mix(mix(dot(grad3(i + vec3(0,0,1)), f - vec3(0,0,1)), dot(grad3(i + vec3(1,0,1)), f - vec3(1,0,1)), u.x),\n mix(dot(grad3(i + vec3(0,1,1)), f - vec3(0,1,1)), dot(grad3(i + vec3(1,1,1)), f - vec3(1,1,1)), u.x), u.y),\n u.z);\n}\nfloat fbm(vec3 p) {\n float v = 0.0, a = 0.5;\n for (int i = 0; i < 5; i++) { v += a * perlin(p); p = p * 2.03 + vec3(1.7, 9.2, 3.1); a *= 0.5; }\n return 0.5 + 0.5 * (v * 1.4);\n}\n\n// OKLab \u2192 linear sRGB (Bj\xf6rn Ottosson), as in membrane-palette.ts.\nvec3 oklabToLinear(vec3 c) {\n float l_ = c.x + 0.3963377774 * c.y + 0.2158037573 * c.z;\n float m_ = c.x - 0.1055613458 * c.y - 0.0638541728 * c.z;\n float s_ = c.x - 0.0894841775 * c.y - 1.2914855480 * c.z;\n float l = l_ * l_ * l_, m = m_ * m_ * m_, s = s_ * s_ * s_;\n return vec3( 4.0767416621 * l - 3.3077115913 * m + 0.2309699292 * s,\n -1.2684380046 * l + 2.6097574011 * m - 0.3413193965 * s,\n -0.0041960863 * l - 0.7034186147 * m + 1.7076147010 * s);\n}\nbool inGamut(vec3 lin) { return all(greaterThanEqual(lin, vec3(-1e-4))) && all(lessThanEqual(lin, vec3(1.0001))); }\n\nvec4 schemeTexel(float row, float col) {\n return texture2D(u_schemes, vec2((col + 0.5) / ${i.TERRAIN_TEXELS}.0, (row + 0.5) / ${l}.0));\n}\nvec2 anchorOf(float row, float k) {\n vec4 t = schemeTexel(row, 2.0 + floor(k * 0.5));\n return mod(k, 2.0) < 0.5 ? t.xy : t.zw;\n}\n// Lightness banding from its parameters (cycles, phase, mid, amplitude) \u2014\n// a scheme's own, or the terrain's blend of several.\nfloat bandingOf(vec4 l, float d) {\n return l.z + l.w * cos(6.28318 * (l.x * d + l.y));\n}\nfloat banding(float row, float d) {\n return bandingOf(schemeTexel(row, 1.0), d);\n}\n// A scheme's anchor color at position u through one pass of its anchors, as\n// an OKLab a/b offset. Each anchor holds, then turns into the next over a\n// window of half-width h.w \u2014 along a straight line through a/b, not around\n// the hue wheel, so the turn passes through no hue the two do not share\n// (abAt in membrane-palette.ts).\nvec2 anchorAt(float row, float u) {\n vec4 h = schemeTexel(row, 0.0); // count, passes per unit thickness, phase, half-width\n float x = fract(u) * h.x;\n float fi = floor(x);\n float f = smoothstep(0.5 - h.w, 0.5 + h.w, x - fi);\n vec2 a = anchorOf(row, fi), b = anchorOf(row, fi + 1.0);\n return mix(a.y * vec2(cos(a.x), sin(a.x)), b.y * vec2(cos(b.x), sin(b.x)), f);\n}\n// The same at thickness d, at the scheme's own cycling rate and phase.\nvec2 anchorAB(float row, float d) {\n vec4 h = schemeTexel(row, 0.0);\n return anchorAt(row, h.y * d + h.z);\n}\n\n// The scheme terrain: the base film's scheme is the cell it is over, in\n// world coordinates (glyph space carried by the drag, so the map scrolls with\n// the film and the lift never moves it). Cells are irregular: each grid cell\n// has a seed point jittered within it (its last texel), and a point wears\n// the nearest seed's scheme \u2014 a Voronoi partition, so no wall is axis-aligned\n// and no two are alike (claude-xaj5pb9b:16). The block's rows are the\n// BLOCK\xd7BLOCK cells around u_cell0, row-major; a point's nearest seeds are\n// in its own cell or the eight around it. Every cell whose seed is within\n// SEAM of the nearest gets a share, falling smoothly with the excess, so\n// nothing is discontinuous (a nearest-two blend jumped wherever the\n// runner-up changed \u2014 claude-xaj5pb9b:21); and the lookup position is\n// displaced by a static fbm, whose large octaves bend the walls and small\n// ones dither them. All of it in world coordinates and out of time, so the\n// map it draws is as fixed as the cells.\n//\n// What the shares blend is the *scheme*, not its colors (claude-xaj5pb9b:27):\n// the banding parameters into one cosine and the hue cycle into one\n// position, and the thickness is then rendered through that single local\n// scheme at full contrast. Averaging each cell's rendered banding instead\n// cancelled two cosines against each other and washed the texture out of\n// every seam (claude-xaj5pb9b:26). The anchors, which come in different\n// counts, are looked up per cell at the shared position and blended.\nfloat terrainRow(vec2 ij) {\n const float R = ${((i.BLOCK-1)/2).toFixed(1)};\n vec2 d = clamp(ij - u_cell0, -R, R);\n return (d.y + R) * ${i.BLOCK}.0 + (d.x + R);\n}\nfloat shareOf(float row, vec2 q, float d1) {\n float excess = distance(q, schemeTexel(row, ${o.SCHEME_TEXELS}.0).xy) - d1;\n return 1.0 - smoothstep(0.0, ${i.SEAM.toFixed(4)}, excess);\n}\nvoid terrain(vec2 p, float d, out float L, out vec2 ab) {\n vec2 w = p - u_drag;\n vec2 q = w + ${(2*i.WARP).toFixed(3)} * (vec2(fbm(vec3(w * ${i.WARP_FREQ.toFixed(3)} + 60.0, 7.0)),\n fbm(vec3(w * ${i.WARP_FREQ.toFixed(3)} + 90.0, 11.0))) - 0.5);\n vec2 c = floor(q / ${i.CELL.toFixed(4)});\n float d1 = 1e9;\n for (int j = -1; j <= 1; j++) {\n for (int i = -1; i <= 1; i++) {\n d1 = min(d1, distance(q, schemeTexel(terrainRow(c + vec2(float(i), float(j))), ${o.SCHEME_TEXELS}.0).xy));\n }\n }\n // The local scheme: banding and hue-cycle parameters blended by share.\n float total = 0.0;\n vec4 light = vec4(0.0);\n vec2 cycle = vec2(0.0); // passes per unit thickness, phase\n for (int j = -1; j <= 1; j++) {\n for (int i = -1; i <= 1; i++) {\n float row = terrainRow(c + vec2(float(i), float(j)));\n float share = shareOf(row, q, d1);\n if (share > 0.0) {\n light += share * schemeTexel(row, 1.0);\n cycle += share * schemeTexel(row, 0.0).yz;\n total += share;\n }\n }\n }\n light /= total;\n cycle /= total;\n L = bandingOf(light, d);\n // The anchors at the shared cycle position, blended by the same shares.\n float u = cycle.x * d + cycle.y;\n ab = vec2(0.0);\n for (int j = -1; j <= 1; j++) {\n for (int i = -1; i <= 1; i++) {\n float row = terrainRow(c + vec2(float(i), float(j)));\n float share = shareOf(row, q, d1);\n if (share > 0.0) ab += share * anchorAt(row, u);\n }\n }\n ab /= total;\n}\n\nvec4 splotchTexel(float i, float col) {\n return texture2D(u_splotchTable, vec2((col + 0.5) / ${r.SPLOTCH_TEXELS}.0, (i + 0.5) / ${r.MAX_SPLOTCHES}.0));\n}\n// Signed distance-like measure to splotch i's outline, negative inside \u2014 the\n// same outline as sdAt in membrane-invasion.ts (upward reach multiplied by\n// its rise, then a stretch along its axis and 2-, 3- and 5-lobed bulges),\n// plus the shared noise dithering. row: its scheme.\nfloat splotchSD(float i, vec2 p, float dither, out float row) {\n vec4 a = splotchTexel(i, 0.0); // x, y, r, scheme row\n row = a.w;\n vec2 q = p - a.xy;\n if (a.z <= 0.0) return 10.0;\n float rise = splotchTexel(i, 3.0).x;\n if (q.y < 0.0) q.y /= rise; // y is down: upward, the outline reaches farther\n if (length(q) > a.z * 2.5 + 0.1) return 10.0; // nowhere near: skip the rest\n vec4 b = splotchTexel(i, 1.0); // angle, aspect, a2, a3\n vec4 c = splotchTexel(i, 2.0); // a5, p2, p3, p5\n float cs = cos(b.x), sn = sin(b.x);\n vec2 l = vec2(cs * q.x + sn * q.y, -sn * q.x + cs * q.y);\n float k = sqrt(b.y);\n float th = atan(l.y, l.x + 1e-6);\n float bulge = 1.0 + b.z * cos(2.0 * th + c.y) + b.w * cos(3.0 * th + c.z) + c.x * cos(5.0 * th + c.w);\n return length(vec2(l.x / k, l.y * k)) - a.z * bulge + dither * 0.16 * min(1.0, a.z * 5.0);\n}\nfloat dithering(vec2 p) { return fbm(vec3(p * 3.5 + 30.0, u_clock * 0.15)) - 0.5; }\n\n// Lightness is the thin film's banding; hue is the scheme's. The terrain,\n// then each splotch over it in order, newest on top. Chroma is cut\n// back only as far as sRGB needs at that lightness, so the palest and darkest\n// bands keep their hue instead of clipping to white or black.\nvec3 paint(float d, vec2 p, float dither) {\n float L;\n vec2 ab;\n terrain(p, d, L, ab);\n for (int i = 0; i < ${r.MAX_SPLOTCHES}; i++) {\n if (float(i) >= u_splotchCount) break;\n float row;\n float claim = 1.0 - smoothstep(-0.012, 0.012, splotchSD(float(i), p, dither, row));\n if (claim > 0.0) { L = mix(L, banding(row, d), claim); ab = mix(ab, anchorAB(row, d), claim); }\n }\n float C = length(ab);\n // The band no scheme may use (BAND_FADE_DEG, membrane-palette.ts): what a\n // turn between anchors on either side of it still passes through is shown\n // neutral, at the banding's lightness, rather than as mustard or olive.\n if (C > 1e-4) { // below that, hue is noise (and atan(0, 0) is undefined)\n float hd = mod(degrees(atan(ab.y, ab.x)), 360.0);\n float fade = smoothstep(${o.BAND_FADE_DEG[0].toFixed(1)}, ${o.BAND_FADE_DEG[1].toFixed(1)}, hd)\n * (1.0 - smoothstep(${o.BAND_FADE_DEG[2].toFixed(1)}, ${o.BAND_FADE_DEG[3].toFixed(1)}, hd));\n ab *= 1.0 - fade;\n C = length(ab);\n }\n vec2 dir = C > 1e-5 ? ab / C : vec2(1.0, 0.0);\n float lo = C;\n if (!inGamut(oklabToLinear(vec3(L, ab)))) {\n float hi = C; lo = 0.0;\n for (int k = 0; k < 8; k++) {\n float mid = 0.5 * (lo + hi);\n if (inGamut(oklabToLinear(vec3(L, dir * mid)))) lo = mid; else hi = mid;\n }\n }\n vec3 lin = clamp(oklabToLinear(vec3(L, dir * lo)), 0.0, 1.0);\n return mix(12.92 * lin, 1.055 * pow(lin, vec3(1.0 / 2.4)) - 0.055, step(0.0031308, lin));\n}\n\n// A slowly draining soap film: the swirl as merged in #464, carried by the\n// integrated drift (u_offset; lifting, the structure forms below and\n// dissolves above) and colored by the terrain and any splotches (paint).\nvec3 film(vec2 p, float c) {\n vec2 q = p * ${n.NOISE_SCALE.toFixed(2)} + u_offset;\n float d = fbm(vec3(q, c * 0.06));\n d += 0.35 * fbm(vec3(q * 2.7 + 10.0, c * 0.09 + 5.0));\n d += 0.30 * (p.y + 0.5); // thinner toward the top, as a real film drains\n // Where a splotch's front is, the film is disturbed: a thin seam of\n // shifted thickness marks the line being fought over. The edge itself is\n // crisp \u2014 the struggle is in its shape and its motion, not in a blur.\n //\n // The seam follows the nearest *visible* front, which is not the nearest\n // outline. Splotches composite oldest first, so walking them in order: one\n // that covers this point is the paint here and hides every older front\n // beneath it; an older front outside it stays a candidate; and a front is\n // no front where the paint on both sides is the same scheme \u2014 a sibling of\n // its own group already covers the point \u2014 so a group's union grows no\n // seams inside it (its inside distance is to the farthest covering\n // sibling's outline). A signed min over every outline got the one case\n // that matters most wrong: a tap landing inside an expanding wash sat deep\n // inside the wash's outline, and its own front, at distance zero, lost the\n // min to the wash's \u22120.3 and drew no seam until the wash was adopted, when\n // the seam appeared all at once (claude-m1ofa51d:16).\n float dither = 0.0, in2 = 100.0, out2 = 100.0, row;\n float over = -1.0; // scheme row of the paint at p; -1 is the terrain\n if (u_splotchCount > 0.5) {\n dither = dithering(p);\n for (int i = 0; i < ${r.MAX_SPLOTCHES}; i++) {\n if (float(i) >= u_splotchCount) break;\n float sd = splotchSD(float(i), p, dither, row);\n if (sd >= 10.0) continue; // nowhere near\n if (sd < 0.0) {\n if (over != row) { in2 = sd * sd; out2 = 100.0; } // new paint on top: older fronts are hidden\n else in2 = max(in2, sd * sd); // a sibling: the union reaches farther\n over = row;\n } else if (over != row) {\n out2 = min(out2, sd * sd);\n }\n }\n }\n d += 0.12 * exp(-min(in2, out2) / 0.0004);\n vec3 col = paint(d, p, dither);\n vec2 lightAt = vec2(-0.22, -0.28);\n float sheen = pow(max(0.0, 1.0 - length(p - lightAt) * 1.5), 2.2);\n col = mix(col, vec3(1.0), sheen * 0.30);\n col *= 0.88 + 0.12 * fbm(vec3(q * 3.0, c * 0.2 + 20.0));\n return col;\n}\n\nvoid main() {\n vec2 frag = vec2(gl_FragCoord.x, u_res.y - gl_FragCoord.y);\n vec2 gs = u_glyph.zw;\n vec2 gc = u_glyph.xy + gs * 0.5;\n vec2 muv = (frag - u_glyph.xy) / gs;\n float m = 0.0;\n if (muv.x >= 0.0 && muv.x <= 1.0 && muv.y >= 0.0 && muv.y <= 1.0) m = texture2D(u_mask, muv).a;\n if (m <= 0.001) { gl_FragColor = vec4(u_bg, 1.0); return; }\n // Glyph-normalized coordinates: the glyph spans -0.5..0.5.\n vec2 p = (frag - gc) / gs.x;\n gl_FragColor = vec4(mix(u_bg, film(p, u_phase), m), 1.0);\n}\n`,f=[60,90],u=.06;function p(e,n=64){const o=document.createElement("canvas");o.width=o.height=n;const i=o.getContext("2d");if(!i)return[[0,0]];i.setTransform(n/t.MO_GLYPH_BOX,0,0,n/t.MO_GLYPH_BOX,0,0),i.fillStyle="#fff",i.fill(e);const r=i.getImageData(0,0,n,n).data,a=[];for(let e=0;e<n;e++)for(let t=0;t<n;t++)r[4*(e*n+t)+3]>0&&a.push([(t+.5)/n-.5,(e+.5)/n-.5]);return a.length?a:[[0,0]]}let v=null;function g(e){const t=parseInt(e.slice(1),16);return[(t>>16&255)/255,(t>>8&255)/255,(255&t)/255]}function w(e,a,w){const E=e.getContext("webgl",{antialias:!1,alpha:!1,premultipliedAlpha:!1});if(!E)return null;const _=E;if(!_.getExtension("OES_texture_float"))return null;const b=(e,t)=>{const n=_.createShader(e);return n?(_.shaderSource(n,t),_.compileShader(n),_.getShaderParameter(n,_.COMPILE_STATUS)?n:(console.warn("Membrane shader:",_.getShaderInfoLog(n)),null)):null},x=b(_.VERTEX_SHADER,c),T=b(_.FRAGMENT_SHADER,h),y=_.createProgram();if(!x||!T||!y)return null;if(_.attachShader(y,x),_.attachShader(y,T),_.linkProgram(y),!_.getProgramParameter(y,_.LINK_STATUS))return console.warn("Membrane link:",_.getProgramInfoLog(y)),null;_.useProgram(y);const L=_.createBuffer();_.bindBuffer(_.ARRAY_BUFFER,L),_.bufferData(_.ARRAY_BUFFER,new Float32Array([-1,-1,1,-1,-1,1,1,1]),_.STATIC_DRAW);const R=_.getAttribLocation(y,"a_pos");_.enableVertexAttribArray(R),_.vertexAttribPointer(R,2,_.FLOAT,!1,0,0);const A=e=>_.getUniformLocation(y,e),S=A("u_res"),P=A("u_glyph"),k=A("u_offset"),M=A("u_phase"),C=A("u_clock"),D=A("u_splotchCount"),O=A("u_drag"),X=A("u_cell0");function I(e,t,n,o){const i=_.createTexture();_.activeTexture(_.TEXTURE0+e),_.bindTexture(_.TEXTURE_2D,i);for(const[e,t]of[[_.TEXTURE_WRAP_S,_.CLAMP_TO_EDGE],[_.TEXTURE_WRAP_T,_.CLAMP_TO_EDGE],[_.TEXTURE_MIN_FILTER,_.NEAREST],[_.TEXTURE_MAG_FILTER,_.NEAREST]])_.texParameteri(_.TEXTURE_2D,e,t);_.uniform1i(A(t),e);const r=new Float32Array(n*o*4);return{tex:i,data:r,upload(){_.activeTexture(_.TEXTURE0+e),_.bindTexture(_.TEXTURE_2D,i),_.texImage2D(_.TEXTURE_2D,0,_.RGBA,n,o,0,_.RGBA,_.FLOAT,r)}}}const F=I(1,"u_schemes",i.TERRAIN_TEXELS,l),B=I(2,"u_splotchTable",r.SPLOTCH_TEXELS,r.MAX_SPLOTCHES),U=()=>f[0]+(f[1]-f[0])*Math.random(),G=v??={terrain:(0,i.createTerrain)(Math.floor(2147483648*Math.random())),drag:[0,0],film:(0,r.emptyFilm)(),schemes:new Map,rows:new Map,motion:(0,n.initialMotionState)(w),t0:performance.now(),holdUntil:U(),frozenAt:0};function j(e,t){F.data.set((0,o.packScheme)(t),e*i.TERRAIN_TEXELS*4),F.upload()}function H(e){const t=new Set(G.rows.values());let n=i.TERRAIN_ROWS;for(;t.has(n);)n++;G.rows.set(e.id,n);const r=(0,o.nextScheme)((0,i.schemesInView)(G.terrain,G.drag),Math.random);G.schemes.set(e.id,r),j(n,r)}let N=null,z=!0;function q(){const e=(0,i.centreCell)(G.drag);!z&&N&&e[0]===N[0]&&e[1]===N[1]||((0,i.blockRows)(G.terrain,G.drag).forEach((e,t)=>F.data.set((0,i.packCell)(e),t*i.TERRAIN_TEXELS*4)),F.upload(),_.uniform2f(X,e[0],e[1]),N=e,z=!1)}function Y(e){(0,i.paintCells)(G.terrain,(0,i.cellsInView)(G.terrain,G.drag),e),z=!0}function $(){const e=new Set(G.film.groups.map(e=>e.id));for(const t of[...G.rows.keys()])e.has(t)||(G.rows.delete(t),G.schemes.delete(t))}const W=p(new Path2D(t.MO_GLYPH_PATH));for(const[e,t]of G.rows){const n=G.schemes.get(e);n&&j(t,n)}const K=(e,t)=>{const n=G.schemes.get(e.id),i=G.schemes.get(t.id);return!!n&&!!i&&(0,o.schemeDistance)(n,i)<u};function V(e,t){if(ce.matches)return void Y((0,o.nextScheme)((0,i.schemesInView)(G.terrain,G.drag),Math.random));const n=(0,r.tap)(G.film,e,t,Math.random);if(G.film=n.film,n.started&&H(n.started),n.recolored){const e=G.rows.get(n.recolored.id),t=G.schemes.get(n.recolored.id)??null;if(void 0!==e){const i=(0,o.nextScheme)(t,Math.random);G.schemes.set(n.recolored.id,i),j(e,i)}}$()}let Q=w;let J=!1;function Z(e){J=e}function ee(e,t){G.motion=(0,n.dragMotion)(G.motion,e,t),G.film=(0,r.shift)(G.film,e,t),G.drag=[G.drag[0]+e,G.drag[1]+t]}const[te,ne,oe]=g(s);_.uniform3f(A("u_bg"),te,ne,oe),_.uniform1i(A("u_mask"),0);const ie=_.createTexture();_.activeTexture(_.TEXTURE0),_.bindTexture(_.TEXTURE_2D,ie),_.texParameteri(_.TEXTURE_2D,_.TEXTURE_WRAP_S,_.CLAMP_TO_EDGE),_.texParameteri(_.TEXTURE_2D,_.TEXTURE_WRAP_T,_.CLAMP_TO_EDGE),_.texParameteri(_.TEXTURE_2D,_.TEXTURE_MIN_FILTER,_.LINEAR),_.texParameteri(_.TEXTURE_2D,_.TEXTURE_MAG_FILTER,_.LINEAR),_.pixelStorei(_.UNPACK_FLIP_Y_WEBGL,!1),_.pixelStorei(_.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1);const re=document.createElement("canvas"),ae=new Path2D(t.MO_GLYPH_PATH);function se(e){const n=Math.max(2,Math.round(e));re.width=n,re.height=n;const o=re.getContext("2d");o&&(o.clearRect(0,0,n,n),o.setTransform(n/t.MO_GLYPH_BOX,0,0,n/t.MO_GLYPH_BOX,0,0),o.fillStyle="#fff",o.fill(ae),_.activeTexture(_.TEXTURE0),_.bindTexture(_.TEXTURE_2D,ie),_.texImage2D(_.TEXTURE_2D,0,_.RGBA,_.RGBA,_.UNSIGNED_BYTE,re))}function le(){const t=window.visualViewport?.scale??1,n=Math.min(5,(window.devicePixelRatio||1)*t),o=a.getBoundingClientRect(),i=Math.max(1,Math.round(o.width*n)),r=Math.max(1,Math.round(o.height*n));e.width===i&&e.height===r||(e.width=i,e.height=r),_.viewport(0,0,i,r),_.uniform2f(S,i,r);const s=Math.min(i,r);_.uniform4f(P,(i-s)/2,(r-s)/2,s,s),se(s)}const ce=window.matchMedia("(prefers-reduced-motion: reduce)");let he=0,de=0,fe=!1;function ue(e){if(de=0,!fe)return;const t=he?(e-he)/1e3:0;he=e;let o=(e-G.t0)/1e3;if(ce.matches)o=G.frozenAt;else{if(G.frozenAt=o,G.motion=(0,n.stepMotion)(G.motion,Q,t,J),(0,r.autoDue)(G.film,G.holdUntil,o)){const[e,t]=W[Math.floor(Math.random()*W.length)],n=(0,r.invade)(G.film,e,t,Math.random);n&&(G.film=n.film,H(n.started)),G.holdUntil=o+U()}G.film=(0,r.step)(G.film,t,K);const e=G.film.groups.find(e=>(0,r.washing)(e,G.film.clock)&&(0,r.covers)(G.film,e.id,W));if(e){const t=G.schemes.get(e.id);t&&Y(t),G.film=(0,r.adopt)(G.film,e.id),G.holdUntil=o+U()}$()}_.uniform2f(k,G.motion.offset[0],G.motion.offset[1]),_.uniform1f(M,G.motion.phase),_.uniform2f(O,G.drag[0],G.drag[1]),q(),B.data.set((0,r.packSplotches)(G.film,e=>G.rows.get(e)??0)),B.upload(),_.uniform1f(D,Math.min(G.film.splotches.length,r.MAX_SPLOTCHES)),_.uniform1f(C,G.film.clock),_.drawArrays(_.TRIANGLE_STRIP,0,4),de=requestAnimationFrame(ue)}function me(){fe=!1,de&&(cancelAnimationFrame(de),de=0)}let pe=!0;const ve=()=>{!document.hidden&&pe?fe||(fe=!0,he=0,de||(de=requestAnimationFrame(ue))):me()},ge=ve;document.addEventListener("visibilitychange",ge);const we="function"==typeof IntersectionObserver?new IntersectionObserver(e=>{pe=e.some(e=>e.isIntersecting),ve()},{threshold:0}):null;we?.observe(a);let Ee=null;const be=(e,t)=>{const n=a.getBoundingClientRect();return[(e-n.left)/n.width-.5,(t-n.top)/n.height-.5]},xe=()=>{if(Ee){Z(!1);try{a.releasePointerCapture(Ee.id)}catch{}Ee=null}},Te=e=>{if(!Ee&&e.isPrimary&&("mouse"!==e.pointerType||0===e.button)){Ee={id:e.pointerId,at:performance.now(),x:e.clientX,y:e.clientY,startX:e.clientX,startY:e.clientY,moved:!1},Z(!0);try{a.setPointerCapture(e.pointerId)}catch{}}},ye=e=>{if(!Ee||e.pointerId!==Ee.id)return;if("touch"!==e.pointerType&&0===e.buttons)return void xe();if(!Ee.moved){if(Math.hypot(e.clientX-Ee.startX,e.clientY-Ee.startY)<=8)return;Ee.moved=!0,Ee.x=Ee.startX,Ee.y=Ee.startY}const t=a.getBoundingClientRect();ee((e.clientX-Ee.x)/t.width,(e.clientY-Ee.y)/t.height),Ee.x=e.clientX,Ee.y=e.clientY},Le=e=>{if(!Ee||e.pointerId!==Ee.id)return;const t=!Ee.moved&&performance.now()-Ee.at<250;xe(),t&&V(...be(e.clientX,e.clientY))},Re=e=>{Ee&&e.pointerId===Ee.id&&xe()},Ae=()=>xe(),Se=()=>{document.hidden&&xe()},Pe=e=>{Ee&&e.preventDefault()},ke=e=>e.preventDefault();a.addEventListener("pointerdown",Te),a.addEventListener("pointermove",ye),a.addEventListener("pointerup",Le),a.addEventListener("pointercancel",Re),a.addEventListener("lostpointercapture",Re),window.addEventListener("pointerup",Le),window.addEventListener("pointercancel",Re),window.addEventListener("blur",Ae),document.addEventListener("visibilitychange",Se),a.addEventListener("touchmove",Pe,{passive:!1}),a.addEventListener("contextmenu",ke);let Me=0;const Ce=()=>{window.clearTimeout(Me),Me=window.setTimeout(le,60)},De=new ResizeObserver(Ce);return De.observe(a),window.visualViewport?.addEventListener("resize",Ce),le(),ve(),{touch:V,hold:Z,drag:ee,setMotion:function(e){Q=e},destroy(){me(),xe(),a.removeEventListener("pointerdown",Te),a.removeEventListener("pointermove",ye),a.removeEventListener("pointerup",Le),a.removeEventListener("pointercancel",Re),a.removeEventListener("lostpointercapture",Re),window.removeEventListener("pointerup",Le),window.removeEventListener("pointercancel",Re),window.removeEventListener("blur",Ae),document.removeEventListener("visibilitychange",Se),a.removeEventListener("touchmove",Pe),a.removeEventListener("contextmenu",ke),De.disconnect(),we?.disconnect(),window.visualViewport?.removeEventListener("resize",Ce),window.clearTimeout(Me),document.removeEventListener("visibilitychange",ge),_.deleteTexture(ie),_.deleteTexture(F.tex),_.deleteTexture(B.tex),_.deleteBuffer(L),_.deleteProgram(y),_.deleteShader(x),_.deleteShader(T),_.getExtension("WEBGL_lose_context")?.loseContext()}}}function E({voice:o,lift:i,sway:r,churn:l}){const c=(0,e.useRef)(null),h=(0,e.useRef)(null),f=(0,e.useRef)(null),[u,p]=(0,e.useState)(!0),v=(0,n.membraneMotion)(o,{lift:i,sway:r,churn:l}),g=(0,e.useRef)(v);g.current=v,(0,e.useEffect)(()=>{const e=c.current,t=h.current;if(!e||!t)return;let n=w(t,e,g.current);if(!n)return void p(!1);f.current=n;const o=e=>{e.preventDefault(),n?.destroy(),n=null,f.current=null},i=()=>{n=w(t,e,g.current),f.current=n};return t.addEventListener("webglcontextlost",o),t.addEventListener("webglcontextrestored",i),()=>{t.removeEventListener("webglcontextlost",o),t.removeEventListener("webglcontextrestored",i),n?.destroy(),f.current=null}},[]),(0,e.useEffect)(()=>{f.current?.setMotion(g.current)},[v.lift,v.sway,v.churn]);const E=(0,e.useCallback)(e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),f.current?.touch(0,0))},[]);return(0,a.jsx)("div",{ref:c,role:"button",tabIndex:0,"aria-label":"Change the colors",onKeyDown:E,style:{width:"min(60vw, 38vh, 360px)",aspectRatio:"1 / 1",maxWidth:"100%",position:"relative",cursor:"pointer",outline:"none",touchAction:"none",userSelect:"none",WebkitUserSelect:"none",WebkitTouchCallout:"none",WebkitTapHighlightColor:"transparent"},children:u?(0,a.jsx)("canvas",{ref:h,"aria-hidden":!0,style:{width:"100%",height:"100%",display:"block",background:s}}):(0,a.jsx)("svg",{viewBox:`0 0 ${t.MO_GLYPH_BOX} ${t.MO_GLYPH_BOX}`,width:"100%",height:"100%","aria-hidden":!0,children:(0,a.jsx)("path",{d:t.MO_GLYPH_PATH,fill:"#3a3a42"})})})}},981,[11,982,983,984,985,986,6]);
1085
- __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MO_GLYPH_BOX",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"MO_GLYPH_PATH",{enumerable:!0,get:function(){return Q}});const L=1e3,Q="M493.98 449.69L493.98 425.61L791.54 425.61L791.54 449.69L493.98 449.69ZM493.98 557.19L493.98 533.11L791.54 533.11L791.54 557.19L493.98 557.19ZM431.20 606.21L431.20 319.83L431.20 275.11L431.20 275.11L547.30 319.83L780.36 319.83L780.36 343.91L543.00 343.91L543.00 571.81Q543.00 576.11 528.81 584.71Q514.62 593.31 492.26 599.76Q469.90 606.21 446.68 606.21L446.68 606.21L431.20 606.21ZM733.92 583.85L733.92 319.83L726.18 319.83L776.92 266.51L878.40 343.05Q875.82 346.49 869.37 350.79Q862.92 355.09 851.74 357.67L851.74 357.67L851.74 552.03Q851.74 555.47 835.83 563.21Q819.92 570.95 797.56 577.40Q775.20 583.85 754.56 583.85L754.56 583.85L733.92 583.85ZM400.24 674.15L393.36 650.07L757.14 650.07L812.18 578.69Q812.18 578.69 829.38 592.02Q846.58 605.35 869.80 624.27Q893.02 643.19 911.08 660.39L911.08 660.39Q907.64 674.15 887.00 674.15L887.00 674.15L400.24 674.15ZM675.44 656.95L685.76 653.51Q694.36 680.17 723.17 703.82Q751.98 727.47 799.28 745.10Q846.58 762.73 911.94 773.05L911.94 773.05L911.94 783.37Q867.22 795.41 844.86 821.64Q822.50 847.87 820.78 904.63L820.78 904.63Q785.52 887.43 760.15 858.19Q734.78 828.95 717.58 793.69Q700.38 758.43 690.06 722.74Q679.74 687.05 675.44 656.95L675.44 656.95ZM132.78 417.01L132.78 148.69L132.78 140.09L132.78 104.83L259.20 148.69L242.86 148.69L242.86 417.01Q242.86 475.49 239.85 539.56Q236.84 603.63 223.94 668.56Q211.04 733.49 180.94 794.12Q150.84 854.75 96.66 906.35L96.66 906.35L87.20 901.19Q111.28 829.81 120.74 748.54Q130.20 667.27 131.49 582.13Q132.78 496.99 132.78 417.01L132.78 417.01ZM184.38 172.77L184.38 148.69L342.62 148.69L342.62 172.77L184.38 172.77ZM184.38 371.43L184.38 347.35L342.62 347.35L342.62 371.43L184.38 371.43ZM184.38 573.53L184.38 549.45L342.62 549.45L342.62 573.53L184.38 573.53ZM284.14 767.89L284.14 148.69L275.54 148.69L325.42 92.79L426.90 171.91Q423.46 176.21 415.72 180.94Q407.98 185.67 395.94 188.25L395.94 188.25L395.94 779.93Q395.94 817.77 387.77 844.43Q379.60 871.09 352.51 886.57Q325.42 902.05 269.52 907.21L269.52 907.21Q268.66 879.69 266.08 859.05Q263.50 838.41 256.62 827.23L256.62 827.23Q250.60 814.33 239.42 805.30Q228.24 796.27 205.02 791.97L205.02 791.97L205.02 779.93Q205.02 779.93 213.19 780.36Q221.36 780.79 232.54 781.65Q243.72 782.51 254.04 782.94Q264.36 783.37 269.52 783.37L269.52 783.37Q278.98 783.37 281.56 779.07Q284.14 774.77 284.14 767.89L284.14 767.89ZM499.14 291.45L499.14 99.67L639.32 110.85Q638.46 118.59 632.87 124.18Q627.28 129.77 610.94 132.35L610.94 132.35L610.94 265.65Q610.94 269.09 596.32 275.54Q581.70 281.99 560.20 286.72Q538.70 291.45 516.34 291.45L516.34 291.45L499.14 291.45ZM661.68 291.45L661.68 99.67L801.86 110.85Q801.00 118.59 795.41 124.18Q789.82 129.77 774.34 132.35L774.34 132.35L774.34 265.65Q774.34 269.09 759.72 275.54Q745.10 281.99 723.17 286.72Q701.24 291.45 678.88 291.45L678.88 291.45L661.68 291.45ZM407.98 219.21L401.10 195.13L797.56 195.13L838.84 133.21Q838.84 133.21 851.74 145.25Q864.64 157.29 882.27 174.06Q899.90 190.83 912.80 205.45L912.80 205.45Q910.22 219.21 890.44 219.21L890.44 219.21L407.98 219.21ZM573.10 533.11L573.10 533.11L695.22 533.11Q692.64 582.99 686.19 628.57Q679.74 674.15 662.54 714.57Q645.34 754.99 611.37 789.82Q577.40 824.65 521.07 853.89Q464.74 883.13 379.60 906.35L379.60 906.35L372.72 895.17Q447.54 858.19 488.39 817.77Q529.24 777.35 546.87 732.20Q564.50 687.05 568.37 637.60Q572.24 588.15 573.10 533.11Z"},982,[]);
1086
- __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MEMBRANE_MOTION",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"DEFAULT_MEMBRANE_VOICE",{enumerable:!0,get:function(){return n}}),e.membraneMotion=function(o=n,f={}){const u=t[o];return{lift:f.lift??u.lift,sway:f.sway??u.sway,churn:f.churn??u.churn}},Object.defineProperty(e,"MOTION_EASE_S",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"MOTION_MAX_DT_S",{enumerable:!0,get:function(){return f}}),e.initialMotionState=function(t){return{motion:Object.assign({},t),offset:[0,0],phase:0}},Object.defineProperty(e,"NOISE_SCALE",{enumerable:!0,get:function(){return u}}),e.stepMotion=function(t,n,u,c=!1){const s=Math.min(Math.max(u,0),f),l=1-Math.exp(-s/o),M=(t,n)=>t+(n-t)*l,O={lift:c?0:M(t.motion.lift,n.lift),sway:c?0:M(t.motion.sway,n.sway),churn:M(t.motion.churn,n.churn)};return{motion:O,offset:[t.offset[0]+O.sway*s,t.offset[1]+O.lift*s],phase:t.phase+O.churn*s}},e.dragMotion=function(t,n,o){return Object.assign({},t,{offset:[t.offset[0]-u*n,t.offset[1]-u*o]})};const t={awake:{lift:.07,sway:.012,churn:1},dormant:{lift:0,sway:.012,churn:.4}},n="awake";const o=.35,f=.1;const u=2.4},983,[]);
1087
- __d(function(g,r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MIN_ANCHORS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"MAX_ANCHORS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"MIN_HUE_SEP_DEG",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"MIN_ANCHOR_DE",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"DISTINCT_AT_L",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"MIN_SCHEME_DISTANCE",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"EXCLUDED_HUE_DEG",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"BAND_FADE_DEG",{enumerable:!0,get:function(){return s}}),e.hueExcluded=i,e.bandFade=f,e.neutralizeBand=l,e.oklabToLinearSrgb=m,e.inSrgbGamut=M,e.fitToGamut=b,e.hueSeparationDeg=d,e.anchorsDistinct=E,Object.defineProperty(e,"SCHEME_FAMILIES",{enumerable:!0,get:function(){return O}}),e.sampleScheme=D,e.abAt=j,e.hueChromaAt=I,e.schemeDistance=C,e.nextScheme=function(t,n){const o=null===t?[]:Array.isArray(t)?t:[t];for(let t=0;t<200;t++){const t=D(n);if(o.every(n=>C(t,n)>=a))return t}return D(n)},Object.defineProperty(e,"SCHEME_TEXELS",{enumerable:!0,get:function(){return N}}),e.packScheme=function(t){const n=new Float32Array(20);return n.set([t.hues.length,...t.hue,...t.light]),n.set(H(t),8),n},e.packAnchors=H;const t=3,n=5,o=28,u=.09,c=[.5,.65,.8],a=.12,h=[60,130],s=[60,75,115,130];function i(t){return t>=h[0]&&t<=h[1]}function f(t){const[n,o,u,c]=s;return p(n,o,t)*(1-p(u,c,t))}function l(t,n){const o=1-f((180*Math.atan2(n,t)/Math.PI+360)%360);return[t*o,n*o]}function m(t,n,o){const u=t+.3963377774*n+.2158037573*o,c=t-.1055613458*n-.0638541728*o,a=t-.0894841775*n-1.291485548*o,h=u*u*u,s=c*c*c,i=a*a*a;return[4.0767416621*h-3.3077115913*s+.2309699292*i,-1.2684380046*h+2.6097574011*s-.3413193965*i,-.0041960863*h-.7034186147*s+1.707614701*i]}function M(t,n,o){return m(t,n,o).every(t=>t>=-1e-4&&t<=1.0001)}function b(t,n,o){const u=n=>[t,n*Math.cos(o),n*Math.sin(o)];if(M(...u(n)))return u(n);let c=0,a=n;for(let t=0;t<20;t++){const t=(c+a)/2;M(...u(t))?c=t:a=t}return u(c)}const y=Math.PI/180,p=(t,n,o)=>{const u=Math.min(1,Math.max(0,(o-t)/(n-t)));return u*u*(3-2*u)};function d(t,n){const o=Math.abs(((t-n)%360+360)%360);return Math.min(o,360-o)}function E(t){for(let n=0;n<t.length;n++)for(let a=n+1;a<t.length;a++){if(d(t[n],t[a])<o)return!1;for(const o of c){const[,c,h]=b(o,.3,t[n]*y),[,s,i]=b(o,.3,t[a]*y);if(Math.hypot(c-s,h-i)<u)return!1}}return!0}const _=(t,n,o)=>n+(o-n)*t(),A=(t,n)=>n[Math.floor(t()*n.length)],S={analogous:(t,n)=>{const o=A(n,[3,4]),u=_(n,30,45);return Array.from({length:o},(n,c)=>t+u*(c-(o-1)/2))},complementary:(t,n)=>{const o=_(n,35,60);return A(n,[[t,t+180,t+o],[t,t+180,t+180+o],[t,t+o,t+180,t+180+o]])},split:(t,n)=>{const o=_(n,25,45);return[t,t+180-o,t+180+o]},triadic:t=>[t,t+120,t+240],tetradic:(t,n)=>{const o=A(n,[60,90]);return[t,t+o,t+180,t+180+o]},accent:(t,n)=>{const o=_(n,30,45);return[t,t+o,t+A(n,[150,180,210])+o/2]},wild:(t,n)=>Array.from({length:A(n,[3,4,5])},()=>_(n,0,360))},O=Object.keys(S);function P(t,n){for(let o=t.length-1;o>0;o--){const u=Math.floor(n()*(o+1));[t[o],t[u]]=[t[u],t[o]]}return t}function D(o){let u,c;do{u=A(o,O),c=S[u](_(o,0,360),o).map(t=>((t+_(o,-8,8))%360+360)%360)}while(c.length<t||c.length>n||c.some(i)||!E(c));const a=P(c,o).map(t=>t*y);return{family:u,hues:a,chromas:a.map(()=>_(o,.15,.32)),light:[_(o,2.4,3.7),o(),_(o,.62,.68),_(o,.27,.32)],hue:[_(o,1,1.5),o(),_(o,.18,.45)]}}function j(t,n,o=t.hue[2]){const u=t.hues.length,c=(n%1+1)%1*u,a=Math.floor(c)%u,h=(a+1)%u,s=p(.5-o,.5+o,c-Math.floor(c)),i=t.chromas[a]*Math.cos(t.hues[a]),f=t.chromas[a]*Math.sin(t.hues[a]);return l(i+(t.chromas[h]*Math.cos(t.hues[h])-i)*s,f+(t.chromas[h]*Math.sin(t.hues[h])-f)*s)}function I(t,n,o=t.hue[2]){const[u,c]=j(t,n,o);return[Math.atan2(c,u),Math.hypot(u,c)]}function C(t,n){let o=0;for(let u=0;u<32;u++){const[c,a]=I(t,u/32,.5),[h,s]=I(n,u/32,.5);o+=Math.hypot(a*Math.cos(c)-s*Math.cos(h),a*Math.sin(c)-s*Math.sin(h))}return o/32}const N=5;function H(t){const o=new Float32Array(12);for(let u=0;u<=n;u++){const n=u%t.hues.length;o[2*u]=t.hues[n],o[2*u+1]=t.chromas[n]}return o}},984,[]);
1088
- __d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CELL",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"JITTER",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"SEAM",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"WARP",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"WARP_FREQ",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"BLOCK",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"TERRAIN_ROWS",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"TERRAIN_TEXELS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"VIEW_MARGIN",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"createTerrain",{enumerable:!0,get:function(){return a}}),e.seededRng=b,e.cellRng=p,Object.defineProperty(e,"cellAt",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"toWorld",{enumerable:!0,get:function(){return E}}),e.centreCell=y,e.cell=P,Object.defineProperty(e,"cellScheme",{enumerable:!0,get:function(){return j}}),e.blend=R,e.blockCells=S,e.blockRows=function(t,n){return S(y(n)).map(([n,r])=>P(t,n,r))},e.cellsInView=C,e.schemesInView=function(t,n){return C(t,n).map(([n,r])=>j(t,n,r))},e.paintCells=function(t,n,r){for(const[c,o]of n)t.cells.set(h(c,o),{seed:P(t,c,o).seed,scheme:r})},e.packCell=function(n){const r=new Float32Array(4*s);return r.set((0,t.packScheme)(n.scheme)),r.set([n.seed[0],n.seed[1],0,0],4*t.SCHEME_TEXELS),r};var t=_r(d[0]);const n=.75,r=.35,c=.25,o=.14,u=1.5,l=5,i=25,s=t.SCHEME_TEXELS+1,f=.21000000000000002,a=t=>({seed:t,cells:new Map}),h=(t,n)=>`${t},${n}`;function b(t){let n=0|t;return()=>{n=n+1831565813|0;let t=Math.imul(n^n>>>15,1|n);return t=t+Math.imul(t^t>>>7,61|t)^t,((t^t>>>14)>>>0)/4294967296}}function p(t,n,r){let c=(0|t)^Math.imul(0|n,2654435761)^Math.imul(0|r,2246822519);return c=Math.imul(c^c>>>16,2146121005),c=Math.imul(c^c>>>15,2221713035),b(c^c>>>16)}const M=t=>Math.floor(t/n),E=(t,n)=>t-n;function y(t){return[M(E(0,t[0])),M(E(0,t[1]))]}const O=[[-1,-1],[0,-1],[1,-1],[-1,0],[1,0],[-1,1],[0,1],[1,1]];function P(c,o,u){const l=h(o,u),i=c.cells.get(l);if(i)return i;const s=p(c.seed,o,u),f=[(o+.5+(2*s()-1)*r)*n,(u+.5+(2*s()-1)*r)*n],a=O.map(([t,n])=>c.cells.get(h(o+t,u+n))?.scheme).filter(t=>!!t),b={seed:f,scheme:(0,t.nextScheme)(a,s)};return c.cells.set(l,b),b}const j=(t,n,r)=>P(t,n,r).scheme,w=t=>{const n=Math.min(1,Math.max(0,t/c));return 1-n*n*(3-2*n)};function R(t,n){const r=M(n[0]),c=M(n[1]),o=[];for(let u=-1;u<=1;u++)for(let l=-1;l<=1;l++){const i=P(t,r+l,c+u).seed;o.push({cell:[r+l,c+u],d:Math.hypot(n[0]-i[0],n[1]-i[1])})}const u=Math.min(...o.map(t=>t.d)),l=o.map(t=>({cell:t.cell,weight:w(t.d-u)})).filter(t=>t.weight>0),i=l.reduce((t,n)=>t+n.weight,0);return l.map(t=>({cell:t.cell,weight:t.weight/i})).sort((t,n)=>n.weight-t.weight)}function S(t){const n=[];for(let r=-2;r<=2;r++)for(let c=-2;c<=2;c++)n.push([t[0]+c,t[1]+r]);return n}const _=32;function A(t){const n=[];for(let r=0;r<=_;r++)for(let c=0;c<=_;c++)n.push([E(1.42*c/_-.71,t[0]),E(1.42*r/_-.71,t[1])]);return n}function C(t,n){const r=new Map;for(const c of A(n))for(const{cell:n}of R(t,c))r.set(h(...n),n);return[...r.values()].sort((t,n)=>t[1]-n[1]||t[0]-n[0])}},985,[984]);
1089
- __d(function(_g,_r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"TAP_RADIUS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"MAX_SPLOTCH_RADIUS",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"BURST_S",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"TAP_EDGE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"PRESSURE_PER_TAP",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"PRESSURE_DRAIN_S",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"CRITICAL_PRESSURE",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"PRESSURE_SPAN",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"MAX_SPEED",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"RECLAIM",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"WOBBLE",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"ASPECT",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"LOBE_MAX",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"WASH_DELAY_S",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"WASH_SPEED",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"RISE",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"RISE_IN_S",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"COVER_MARGIN",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"MAX_SPLOTCHES",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"SPLOTCH_TEXELS",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"emptyFilm",{enumerable:!0,get:function(){return S}}),e.randomShape=A,e.sdAt=_,e.reach=I,e.touching=R,e.tap=function(r,o,u,a){const c=new Map(r.groups.map(t=>[t.id,t])),i=C(r).filter(t=>!k(c.get(t.group),r.clock)),p=i.filter(t=>_(t,o,u)<=-.02).at(-1);if(p){const t=r.groups.map(t=>t.id===p.group?Object.assign({},t,{lastTap:r.clock}):t);return{film:Object.assign({},r,{groups:t}),started:null,recolored:t.find(t=>t.id===p.group)}}const l={x:o,y:u,r:t,phase:0,group:0,shape:j,anchoredAt:null,rise:1},h=i.filter(t=>R(l,t)).at(-1),f=h?c.get(h.group):null,g=r.groups.filter(t=>!t.auto&&!k(t,r.clock)).reduce((t,r)=>!t||r.lastTap>t.lastTap?r:t,null),d=f??(g&&r.clock-g.lastTap<=n?g:null),b=d?null:{id:r.nextId,pressure:0,born:r.clock,lastTap:r.clock,auto:!1,washAt:null},y=(d??b).id,M=(b?[...r.groups,b]:r.groups).map(t=>t.id===y?Object.assign({},t,{pressure:t.pressure+s,lastTap:r.clock}):t),P=Object.assign({},l,{phase:1e3*a(),group:y,shape:A(a)}),O=[...T(r.splotches),P],S=new Set(O.map(t=>t.group));return{film:Object.assign({},r,{groups:M.filter(t=>S.has(t.id)),splotches:O,nextId:b?r.nextId+1:r.nextId}),started:b?M.find(t=>t.id===y):null,recolored:null}},e.shift=function(t,r,n){return 0===r&&0===n?t:Object.assign({},t,{splotches:t.splotches.map(t=>Object.assign({},t,{x:t.x+r,y:t.y+n}))})},e.invade=function(t,r,n,o){if(t.groups.some(t=>t.auto))return null;const s={id:t.nextId,pressure:0,born:t.clock,lastTap:t.clock,auto:!0,washAt:t.clock},u={x:r,y:n,r:.005,phase:1e3*o(),group:s.id,shape:j,anchoredAt:null,rise:1},a=[...T(t.splotches),u],c=new Set(a.map(t=>t.group));return{film:Object.assign({},t,{groups:[...t.groups,s].filter(t=>c.has(t.id)),splotches:a,nextId:t.nextId+1}),started:s}},e.autoDue=function(t,r,n){return n>=r&&!t.groups.some(t=>t.auto)},e.washing=k,e.frontSpeed=L,e.step=function(t,n,o=()=>!1){const s=Math.max(0,Math.min(n,.1)),a=t.clock+s,c=new Map(t.groups.map(t=>[t.id,t])),i=(t,r)=>{const n=c.get(t.group),s=c.get(r.group);return!n.auto&&!s.auto&&(n.id===s.id||o(n,s))},p=new Set(t.splotches.filter(r=>null!==r.anchoredAt||t.splotches.some(t=>t!==r&&i(r,t)&&R(r,t)))),l=t.groups.map(r=>{const n=null===r.washAt&&t.splotches.some(t=>t.group===r.id&&p.has(t));return Object.assign({},r,{washAt:n?a+g:r.washAt,pressure:r.pressure*Math.exp(-s/u)})}),h=new Map(l.map(t=>[t.id,t])),f=t.splotches.map(t=>{const n=h.get(t.group),o=k(n,a),u=p.has(t),c=o?d:L(n.pressure);let i=t.r+(c+.03*w(.5*a+t.phase))*s;o||(i=Math.min(r,i)),(u||o)&&(i=Math.max(t.r,i));const l=o?Math.min(b,t.rise+2*s/y):t.rise;return Object.assign({},t,{r:Math.max(0,i),anchoredAt:u?i:null,rise:l})}).filter(t=>t.r>0),M=new Set(f.map(t=>t.group));return Object.assign({},t,{clock:a,groups:l.filter(t=>M.has(t.id)),splotches:f})},e.covers=function(t,r,n,o=M){const s=t.splotches.filter(t=>t.group===r);return s.length>0&&n.every(([t,r])=>s.some(n=>_(n,t,r)<=-o))},e.adopt=function(t,r){const n=t.groups.find(t=>t.id===r);if(!n)return t;const o=new Set(t.groups.filter(t=>t.id!==r&&t.born>n.born).map(t=>t.id));return Object.assign({},t,{splotches:t.splotches.filter(t=>o.has(t.group)),groups:t.groups.filter(t=>o.has(t.id))})},e.packSplotches=function(t,r){const n=new Float32Array(1024);return C(t).slice(0,P).forEach((t,o)=>{const{angle:s,aspect:u,lobes:[a,c,i],phases:[p,l,h]}=t.shape;n.set([t.x,t.y,t.r,r(t.group),s,u,a,c,i,p,l,h,t.rise,0,0,0],o*O*4)}),n};const t=.09,r=.22,n=2.5,o=.02,s=1,u=30,a=.8,c=1.5,i=.032,p=.35,l=.015,h=[1.2,2.4],f=[.25,.2,.12],g=2,d=.05,b=3,y=2,M=.1,P=64,O=4,S=()=>({splotches:[],groups:[],clock:0,nextId:1}),j={angle:0,aspect:1,lobes:[0,0,0],phases:[0,0,0]};function A(t){return{angle:t()*Math.PI,aspect:(r=h[0],n=h[1],r+(n-r)*t()),lobes:[t()*f[0],t()*f[1],t()*f[2]],phases:[t()*Math.PI*2,t()*Math.PI*2,t()*Math.PI*2]};var r,n}function x(t,r){const[n,o,s]=t.lobes,[u,a,c]=t.phases;return 1+n*Math.cos(2*r+u)+o*Math.cos(3*r+a)+s*Math.cos(5*r+c)}function E(t,r,n){const o=r-t.x,s=n-t.y,u=s<0?s/t.rise:s,a=Math.cos(t.shape.angle),c=Math.sin(t.shape.angle);return[a*o+c*u,-c*o+a*u]}function _(t,r,n){const[o,s]=E(t,r,n),u=Math.sqrt(t.shape.aspect);return Math.hypot(o/u,s*u)-t.r*x(t.shape,Math.atan2(s,o))}function I(t,r,n){const o=Math.hypot(r-t.x,n-t.y);if(0===o)return 0;const s=t.x+(r-t.x)/o,u=t.y+(n-t.y)/o,[a,c]=E(t,s,u),i=Math.sqrt(t.shape.aspect),p=Math.hypot(a/i,c*i);return Math.max(0,t.r*x(t.shape,Math.atan2(c,a))/p)}function R(t,r){return t.r>0&&r.r>0&&Math.hypot(t.x-r.x,t.y-r.y)<I(t,r.x,r.y)+I(r,t.x,t.y)}function w(t){const r=Math.floor(t),n=t-r,o=t=>{const r=43758.5453*Math.sin(127.1*t+311.7);return 2*(r-Math.floor(r))-1},s=n*n*n*(n*(6*n-15)+10);return o(r)*n*(1-s)+o(r+1)*(n-1)*s}function T(t){if(t.length<P)return t;const r=(t.some(t=>null===t.anchoredAt)?t.filter(t=>null===t.anchoredAt):t).reduce((t,r)=>r.r<t.r?r:t);return t.filter(t=>t!==r)}function k(t,r){return null!==t.washAt&&r>=t.washAt}function L(t){const r=Math.max(-1,Math.min(1,(t-a)/c));return i*(r>=0?r:r*p)}function C(t){const r=new Map(t.groups.map(t=>[t.id,t.born]));return t.splotches.map((t,n)=>({s:t,i:n,b:r.get(t.group)??0})).sort((t,r)=>t.b-r.b||t.i-r.i).map(({s:t})=>t)}},986,[]);
1090
- __d(function(g,r,i,_a,m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return p}});var t=r(_d[0]),n=e(r(_d[1])),o=e(r(_d[2])),a=e(r(_d[3])),l=e(r(_d[4])),d=e(r(_d[5])),s=e(r(_d[6])),c=e(r(_d[7])),u=r(_d[8]),f=r(_d[9]),h=r(_d[10]);function x(e){const t=(0,f.relPart)(e);return t.ago?`${t.val} ago`:t.val}function y(e){return"local"===e.kind?"This machine's CLI":e.owner_nid?`Agent ${e.owner_nid}`:"agent"===e.kind?`Agent ${e.label}`:e.unused?"Meld QR not scanned yet":e.device?e.device:e.remote_addr?`Device at ${e.remote_addr}`:"Device not seen yet"}function v(e){const t=`${"agent"===e.kind?"started":"added"} ${x(e.created_at)}${e.minted_by_device?` by ${e.minted_by_device}`:""}`;if(e.unused){if(null===e.expires_at)return t;return`lapses in ${Math.max(1,Math.ceil((e.expires_at-Date.now())/6e4))} min \xb7 ${t}`}const n=[e.connected?"connected now":null!==e.last_used_at?`seen ${x(e.last_used_at)}`:"never used"];return e.remote_addr&&n.push(e.remote_addr),n.push(t),n.join(" \xb7 ")}function b(e){if(null===e.elsewhere_at)return null;const t=[e.last_device,e.last_remote_addr].filter(Boolean).join(" at ");return`Also used from another address${t?` (latest: ${t})`:""}, ${x(e.elsewhere_at)}`}function p({visible:e,conn:d,daemonName:f,onClose:x,onSignOutOthers:p,signedOutOthers:w,connected:_}){const[T,S]=(0,t.useState)(null),[C,z]=(0,t.useState)(!1),[$,O]=(0,t.useState)(null),[W,D]=(0,t.useState)(null),[R,P]=(0,t.useState)(null),[H,I]=(0,t.useState)(new Set),M=(0,t.useCallback)(async()=>{if(d){O(null);try{const e=await(0,u.listDeviceTokens)(d);z(null===e),S(e??[])}catch(e){O(String(e))}}},[d]);(0,t.useEffect)(()=>{e?(S(null),M()):D(null)},[e,M]);const L=async e=>{if(d){if(W!==e.id)return D(e.id),void I(new Set(e.descendants));P(e.id),O(null);try{await(0,u.revokeDeviceToken)(d,e.id,e.descendants.filter(e=>H.has(e))),D(null),await M()}catch(e){O(String(e))}finally{P(null)}}},A=()=>{R||x()},V=new Map((T??[]).map(e=>[e.id,e])),B=[...T??[]].sort((e,t)=>{const n=e=>e.current?0:"local"===e.kind?1:"device"===e.kind?2:3;return n(e)-n(t)||(t.last_used_at??t.created_at)-(e.last_used_at??e.created_at)});return(0,h.jsx)(o.default,{visible:e,transparent:!0,animationType:"fade",onRequestClose:A,children:(0,h.jsx)(a.default,{style:j.overlay,onPress:A,children:(0,h.jsxs)(a.default,{style:j.card,onPress:e=>e.stopPropagation(),children:[(0,h.jsxs)(s.default,{style:j.title,children:["Devices on ",f]}),null!==T||$?C?(0,h.jsx)(s.default,{style:j.body,children:"This daemon is older than the Devices list. Update brane on it to see and revoke devices."}):(0,h.jsx)(l.default,{style:j.list,children:B.map(e=>(0,h.jsxs)(c.default,{style:j.rowWrap,children:[(0,h.jsxs)(c.default,{style:j.row,children:[(0,h.jsxs)(c.default,{style:{flex:1},children:[(0,h.jsxs)(s.default,{style:j.rowTitle,numberOfLines:1,children:[y(e),e.current?(0,h.jsx)(s.default,{style:j.thisDevice,children:" this device"}):null]}),(0,h.jsx)(s.default,{style:j.rowDetail,children:v(e)}),"device"===e.kind&&(0,h.jsxs)(s.default,{style:j.rowLabel,children:["\"",e.label,"\""]}),b(e)&&(0,h.jsx)(s.default,{style:j.rowWarn,children:b(e)}),"adopted"===e.origin&&"device"===e.kind&&(0,h.jsx)(s.default,{style:j.rowWarn,children:"From before tokens were hashed; may have been logged"}),"adopted"===e.origin&&"agent"===e.kind&&(0,h.jsx)(s.default,{style:j.rowLabel,children:"Kept from before agents had their own tokens; replaced when it is next revived"})]}),"local"!==e.kind&&!e.current&&(0,h.jsx)(a.default,{style:[j.revoke,W===e.id&&j.revokeConfirm,null!==R&&{opacity:.5}],onPress:()=>L(e),disabled:null!==R,children:R===e.id?(0,h.jsx)(n.default,{size:"small",color:"#111"}):(0,h.jsx)(s.default,{style:[j.revokeText,W===e.id&&j.revokeConfirmText],children:W===e.id?"Revoke?":"Revoke"})})]}),W===e.id&&(0,h.jsx)(k,{token:e,byId:V,also:H,onToggle:e=>I(t=>{const n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})})]},e.id))}):(0,h.jsx)(n.default,{style:{marginVertical:16},color:"#aaa"}),$&&(0,h.jsx)(s.default,{style:j.error,children:$}),(0,h.jsx)(s.default,{style:j.footnote,children:"A revoked device is signed out until it scans a fresh Meld QR. To keep only this device:"}),(0,h.jsx)(a.default,{style:[j.signOut,(!_||null!==R)&&{opacity:.5}],onPress:p,disabled:!_||null!==R,children:(0,h.jsx)(s.default,{style:j.signOutText,children:w?"Other devices signed out":"Sign out other devices"})}),(0,h.jsx)(a.default,{style:[j.close,null!==R&&{opacity:.5}],onPress:A,disabled:null!==R,children:(0,h.jsx)(s.default,{style:j.closeText,children:"Close"})})]})})})}function k({token:e,byId:t,also:n,onToggle:o}){const l=[e,...e.descendants.map(e=>t.get(e)).filter(e=>!!e)].flatMap(e=>e.agents).filter(e=>"ended"!==e.status),d="agent"===e.kind;return 0!==e.descendants.length||0!==l.length||d?(0,h.jsxs)(c.default,{style:j.cascade,children:[d&&(0,h.jsxs)(s.default,{style:j.cascadeNote,children:["This cuts ",e.owner_nid??"the agent"," off from brane at once; its session keeps running without tools. To bring it back, end its session and revive it."]}),e.descendants.length>0&&(0,h.jsxs)(s.default,{style:j.cascadeHead,children:["Also revoke ",1===e.descendants.length?"the device or agent":`the ${e.descendants.length} devices and agents`," it added:"]}),e.descendants.map(e=>{const l=t.get(e),d=n.has(e);return(0,h.jsxs)(a.default,{style:j.cascadeRow,onPress:()=>o(e),children:[(0,h.jsx)(s.default,{style:[j.checkbox,d&&j.checkboxOn],children:d?"\u2611":"\u2610"}),(0,h.jsx)(s.default,{style:j.cascadeText,numberOfLines:2,children:l?`${y(l)} \xb7 ${v(l)}`:e})]},e)}),l.length>0&&(0,h.jsxs)(s.default,{style:j.cascadeNote,children:["Started ",1===l.length?"1 running agent":`${l.length} running agents`,":"," ",l.map(e=>e.id).join(", "),". Their sessions keep running; revoking their tokens cuts off their brane tools."]})]}):null}const j=d.default.create({overlay:{flex:1,backgroundColor:"rgba(0,0,0,0.6)",justifyContent:"center",alignItems:"center",padding:24},card:{backgroundColor:"#1e1e22",borderRadius:12,padding:20,width:"100%",maxWidth:420,maxHeight:"85%",borderWidth:1,borderColor:"#3a3a40"},title:{color:"#d8d8dd",fontSize:16,fontWeight:"600",marginBottom:10},body:{color:"#999",fontSize:13,lineHeight:18},list:{flexGrow:0},rowWrap:{borderBottomWidth:d.default.hairlineWidth,borderBottomColor:"#3a3a40",paddingVertical:10},row:{flexDirection:"row",alignItems:"center",gap:10},cascade:{marginTop:8,padding:10,borderRadius:8,backgroundColor:"#26262b",gap:6},cascadeHead:{color:"#d8d8dd",fontSize:13},cascadeRow:{flexDirection:"row",alignItems:"flex-start",gap:8},checkbox:{color:"#777",fontSize:16,lineHeight:18},checkboxOn:{color:"#e0a070"},cascadeText:{color:"#aaa",fontSize:12,flex:1,lineHeight:18},cascadeNote:{color:"#888",fontSize:12,lineHeight:16},rowTitle:{color:"#d8d8dd",fontSize:14},thisDevice:{color:"#66d9a0",fontSize:12},rowDetail:{color:"#777",fontSize:12,fontFamily:"monospace",marginTop:2},rowLabel:{color:"#666",fontSize:12,marginTop:2},rowWarn:{color:"#e0a070",fontSize:12,marginTop:2},revoke:{backgroundColor:"#2a2a30",borderRadius:8,paddingVertical:6,paddingHorizontal:12,minWidth:76,alignItems:"center"},revokeConfirm:{backgroundColor:"#e0a070"},revokeText:{color:"#e0a070",fontSize:13,fontWeight:"600"},revokeConfirmText:{color:"#111"},error:{color:"#e07070",fontSize:12,marginTop:8},footnote:{color:"#666",fontSize:12,lineHeight:16,marginTop:12},signOut:{backgroundColor:"#2a2a30",borderRadius:8,paddingVertical:10,alignItems:"center",marginTop:8},signOutText:{color:"#e0a070",fontSize:14,fontWeight:"600"},close:{backgroundColor:"#2a2a30",borderRadius:8,paddingVertical:10,alignItems:"center",marginTop:12},closeText:{color:"#aaa",fontSize:14,fontWeight:"600"}})},987,[11,416,153,146,122,26,105,13,745,749,6]);
1091
- __d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"ARROW_STEP_PX",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"PAGE_FRACTION",{enumerable:!0,get:function(){return t}}),_e.isListScrollKey=function(e){return!(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)&&n.has(e.key)},_e.listScrollTarget=function(n,c,o){const l=Math.max(0,o.scrollHeight-o.clientHeight),u=Math.max(1,o.clientHeight*t);let s;switch(n){case"ArrowUp":s=c-e;break;case"ArrowDown":s=c+e;break;case"PageUp":s=c-u;break;case"PageDown":s=c+u;break;case"Home":return 0;case"End":return l;default:return null}return Math.min(l,Math.max(0,s))};const e=40,t=.875,n=new Set(["PageUp","PageDown","Home","End","ArrowUp","ArrowDown"])},988,[]);
1092
- __d(function(g,r,i,a,_m,e,d){"use strict";var t=this&&this.__createBinding||(Object.create?function(t,n,o,c){void 0===c&&(c=o);var u=Object.getOwnPropertyDescriptor(n,o);u&&!("get"in u?!n.__esModule:u.writable||u.configurable)||(u={enumerable:!0,get:function(){return n[o]}}),Object.defineProperty(t,c,u)}:function(t,n,o,c){void 0===c&&(c=o),t[c]=n[o]}),n=this&&this.__exportStar||function(n,o){for(var c in n)"default"===c||Object.prototype.hasOwnProperty.call(o,c)||t(o,n,c)};Object.defineProperty(e,"__esModule",{value:!0}),n(r(d[0]),e)},989,[738]);
1093
- __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},990,[]);
1094
- __d(function(g,r,_i,a,_m,_e,d){"use strict";var e,t=r(d[0]),n=this&&this.__createBinding||(Object.create?function(e,t,n,o){void 0===o&&(o=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,o,i)}:function(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),i=this&&this.__importStar||(e=function(t){return e=Object.getOwnPropertyNames||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[t.length]=n);return t},e(t)},function(t){if(t&&t.__esModule)return t;var i={};if(null!=t)for(var c=e(t),u=0;u<c.length;u++)"default"!==c[u]&&n(i,t,c[u]);return o(i,t),i});Object.defineProperty(_e,"__esModule",{value:!0}),_e.renderRootComponent=function(e){try{setTimeout(()=>{f._internal_preventAutoHideAsync?.()}),u.startTransition(()=>{(0,c.registerRootComponent)(e)})}catch(e){f.hideAsync();const n=b(e);(0,c.registerRootComponent)(()=>t.jsx(s.View,{})),console.error(n),console.error("A runtime error has occurred while rendering the root component."),setTimeout(()=>{throw n})}};const c=r(d[1]),u=i(r(d[2])),s=r(d[3]),f=i(r(d[4]));function l(e){if('[object Object]'!==Object.prototype.toString.call(e))return!1;const t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}function p(e){return e&&'object'==typeof e&&'string'==typeof e.name&&'string'==typeof e.message}function b(e){return p(e)?e:l(e)?new Error(JSON.stringify(e)):new Error(String(e))}},991,[6,600,11,342,599]);
1081
+ __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.useAppHost=function(n,o){const u=n?.host??null,[c,p]=(0,t.useState)(()=>u?l.get(u)??null:null);return(0,t.useEffect)(()=>{if(!n||!u||!o)return void p(null);if(p(l.get(u)??null),l.has(u))return;let t=!1;return s(n).then(n=>{t||p(n)}).catch(()=>{t||p(null)}),()=>{t=!0}},[n,u,o]),c};var t=r(d[0]),n=r(d[1]),o=r(d[2]);const l=new Map,u=new Map;function s(t){const s=t.host,c=l.get(s);if(void 0!==c)return Promise.resolve(c);let p=u.get(s);return p||(p=(0,n.probeDaemon)(t.host,t.token).then(t=>{const n="string"==typeof t.app_domain&&(0,o.cleanAppHost)(t.app_domain)||null;return l.set(s,n),n}).finally(()=>u.delete(s)),u.set(s,p)),p}},978,[11,745,979]);
1082
+ __d(function(g,r,i,a,_m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.originHost=function(t){try{return new URL(t).host||t}catch{return t}},e.cleanAppHost=function(t){const n=t.trim(),o=/^[a-z][a-z0-9+.-]*:\/\/([^/?#]+)/i.exec(n);return(o?o[1]:n.replace(/[/?#].*$/,"")).toLowerCase()}},979,[]);
1083
+ __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.visiblePanes=function(t,c){return n.CANONICAL_TABS.filter(n=>n===t||c.has(n))},e.selectPane=function(n,t,c){const s=new Set(t);return s.add(n),{active:c,pinned:s}};var n=r(d[0])},980,[747]);
1084
+ __d(function(g,r,_i,_a,_m,_e,_d){"use strict";const e=["index","style"];function t(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return le}});var n=t(r(_d[0])),o=r(_d[1]),a=t(r(_d[2])),i=t(r(_d[3])),l=t(r(_d[4])),s=t(r(_d[5])),d=t(r(_d[6])),c=t(r(_d[7])),u=t(r(_d[8])),f=t(r(_d[9])),h=t(r(_d[10])),m=r(_d[11]),p=r(_d[12]);r(_d[13]);var x=r(_d[14]),y=t(r(_d[15])),b=r(_d[16]),j=r(_d[17]),v=r(_d[18]),w=r(_d[19]),S=r(_d[20]),C=r(_d[21]),T=t(r(_d[22])),k=r(_d[23]),B=r(_d[24]),R=t(r(_d[25])),O=t(r(_d[26])),z=t(r(_d[27])),_=t(r(_d[28])),P=r(_d[29]),I=r(_d[30]),E=r(_d[31]),L=r(_d[32]),H=r(_d[33]),D=r(_d[34]),W=r(_d[35]);const A=400;function M(t){let{index:o,style:i}=t,l=(0,n.default)(t,e);return(0,W.jsx)(a.default,Object.assign({},l,{style:[i,{zIndex:1e5-o,position:"relative"}]}))}function N({item:e,conn:t,onPress:n,onArchive:l,onMeld:s,onTwin:d,onRevive:c,onEnd:f,menuVisible:h,setMenuVisible:m,hits:p,onHitPress:x,isolated:T,appHost:k}){const B="ended"===e.status?"dead":e.mcp_connected?"live":"idle",R="ended"===e.status?"#666":e.mcp_connected?"#66d9a0":"#5b9bd5",[,O]=(0,o.useState)(0),z=(0,L.isAwaiting)({mcpConnected:e.mcp_connected,awaiting:e.awaiting})?(0,L.awaitingGlow)((0,v.glowHueFor)(e.id)):void 0,_="ended"===e.status?"grey":e.mcp_connected?"green":"blue",I=(0,w.menuHueRgb)(_),E=[`0 0 8px rgba(${I}, 0.9)`,`0 0 18px rgba(${I}, 0.7)`,`0 0 36px rgba(${I}, 0.4)`,`0 1px 12px rgba(${I}, 0.6)`].join(", ");return(0,W.jsx)("div",{style:{borderBottomWidth:u.default.hairlineWidth,borderBottomColor:"#555",borderBottomStyle:"solid",backgroundColor:"#121214",cursor:"pointer",boxShadow:z,transition:"box-shadow 400ms ease"},onClick:()=>n(),children:(0,W.jsxs)("div",{style:{padding:16},children:[(0,W.jsxs)("div",{style:{display:"flex",flexDirection:"row",justifyContent:"space-between",alignItems:"center"},children:[(0,W.jsx)(S.NarrativeIdentity,{id:e.id,foldPath:e.fold_path,style:{flex:1,minWidth:0}}),(0,W.jsxs)("div",{style:{position:"relative"},children:[(0,W.jsx)("button",{onClick:e=>{e.stopPropagation(),m(!h)},style:{background:"none",border:"none",color:R,fontSize:12,textTransform:"uppercase",cursor:"pointer",padding:"4px 8px",marginRight:-9,borderRadius:4,transition:"text-shadow 160ms ease",textShadow:h?E:void 0},children:B}),h&&(0,W.jsx)(y.default,{hue:_,items:(0,b.narrativeMenuItems)({role:e.role,status:e.status,mcpConnected:e.mcp_connected,archived:!!e.archived,isIsolated:T,canIsolate:!T||!!k,onMeld:()=>{m(!1),s()},onIsolate:()=>{if(m(!1),!t||"undefined"==typeof window)return;const n=(0,P.buildIsolateUrl)({host:window.location.host,protocol:window.location.protocol,search:window.location.search,path:`/${e.id}`,conn:t,appHost:k,view:{}});n&&window.open(n,"_blank","noopener,noreferrer")},onExport:()=>{m(!1),t&&(0,b.openNarrativeExport)(t,e.id)},onRecolor:()=>{m(!1),(0,j.bumpRecolorSalt)(e.id),(0,v.recolorGlowHue)(e.id),O(e=>e+1)},onTwin:()=>{m(!1),d()},onRevive:()=>{m(!1),c()},onEnd:()=>{m(!1),f()},onArchiveToggle:()=>{m(!1),l()}}),onClose:()=>m(!1)})]})]}),(0,W.jsx)(S.NarrativeMetaLine,{role:e.role,cost:(0,C.formatCost)(e.cost_amount,e.cost_unit),createdAt:e.created_at,lastActivity:e.last_activity,status:e.status,mcpConnected:e.mcp_connected,style:{marginTop:4}}),e.summary&&(0,W.jsx)("div",{style:{position:"relative",marginTop:4},children:(0,W.jsx)("div",{className:"no-scrollbar",style:{overflowX:"auto",overflowY:"hidden",scrollbarWidth:"none",WebkitOverflowScrolling:"touch",maskImage:"linear-gradient(to right, #000 calc(100% - 40px), transparent)",WebkitMaskImage:"linear-gradient(to right, #000 calc(100% - 40px), transparent)"},children:(0,W.jsx)(i.default,{style:[se.summary,{marginTop:0,whiteSpace:"nowrap"}],children:e.summary})})}),p&&p.length>0&&(0,W.jsx)(a.default,{style:se.hitsContainer,children:p.slice(0,3).map((t,n)=>(0,W.jsx)("div",{onClick:n=>{n.stopPropagation(),x?.(e.id,t.seq)},style:{cursor:"pointer"},children:(0,W.jsx)(i.default,{style:se.hitSnippet,numberOfLines:2,children:t.content})},n))})]})})}function $(e){const t=e.split("\n");let n=0;for(;n<t.length&&(""===t[n].trim()||/^#{1,6}\s/.test(t[n].trim()));)n++;return(t.slice(n).join("\n").trim()||e.trim()).split(/\n[ \t]*\n+/).map(e=>e.replace(/\s*\n\s*/g," ").replace(/[ \t]{2,}/g," ").trim()).filter(Boolean).join("\n")}const F=new Set(["the","and","for","with","that","this","from","are","was","but","not","you"]);function V(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function q(e){return(e.toLowerCase().match(/[\p{L}\p{N}]+/gu)??[]).filter(e=>e.length>=2&&!F.has(e))}function G(e,t){const n=$(e),o=q(t),a=n.toLowerCase();let i=-1;for(const e of o){const t=a.indexOf(e);t>=0&&(i<0||t<i)&&(i=t)}let l=0;if(i>60){l=i-50;const e=n.indexOf(" ",l);e>=0&&e<l+15&&(l=e+1)}const s=Math.min(n.length,l+220);let d=n.slice(l,s);if(l>0&&(d=`\u2026${d}`),s<n.length&&(d=`${d}\u2026`),0===o.length)return[{text:d,match:!1}];const c=new RegExp(`(${o.map(V).sort((e,t)=>t.length-e.length).join("|")})`,"giu"),u=[];let f,h=0;for(;null!==(f=c.exec(d));)f.index>h&&u.push({text:d.slice(h,f.index),match:!1}),u.push({text:f[0],match:!0}),h=f.index+f[0].length,f.index===c.lastIndex&&c.lastIndex++;return h<d.length&&u.push({text:d.slice(h),match:!1}),u}function Y({icon:e,label:t,count:n,collapsed:o,onToggle:l,order:d,onToggleOrder:c}){return(0,W.jsxs)(a.default,{style:[se.wikiBar,o&&se.wikiBarCollapsed],children:[(0,W.jsx)(i.default,{style:se.wikiBarIcon,children:e}),(0,W.jsx)(i.default,{style:se.wikiBarLabel,numberOfLines:1,children:t}),(0,W.jsx)(i.default,{style:se.wikiBarCount,numberOfLines:1,children:n}),(0,W.jsx)(a.default,{style:{flex:1}}),d&&c&&!o&&(0,W.jsx)(s.default,{onPress:c,hitSlop:6,style:({pressed:e})=>[se.wikiBarPill,e&&se.wikiBarPillPressed],children:(0,W.jsx)(i.default,{style:se.wikiBarOrderLabel,children:"recent"===d?"Recency":"Relevance"})}),(0,W.jsx)(s.default,{onPress:l,hitSlop:6,style:({pressed:e})=>[se.wikiBarPill,e&&se.wikiBarPillPressed],children:(0,W.jsx)(i.default,{style:se.wikiBarToggle,children:o?"Show":"Hide"})})]})}function U({results:e,query:t,collapsed:n,onToggle:o,onOpen:l}){return 0===e.length?null:(0,W.jsxs)(a.default,{style:se.wikiSection,children:[(0,W.jsx)(Y,{icon:"\ud83d\udcd6",label:"Wiki",count:e.length,collapsed:n,onToggle:o}),!n&&e.map(e=>(0,W.jsxs)(a.default,{style:se.wikiCard,children:[(0,W.jsx)(s.default,{onPress:()=>l(e.source,e.slug,e.hits[0]?.anchor),children:(0,W.jsxs)(a.default,{style:se.wikiCardHeader,children:[(0,W.jsx)(i.default,{style:se.wikiSlug,numberOfLines:1,children:e.slug.replace(/\.md$/,"")}),(0,W.jsx)(i.default,{style:se.wikiSource,children:e.source})]})}),(0,W.jsx)(a.default,{style:se.hitsContainer,children:e.hits.slice(0,3).map((n,o)=>(0,W.jsxs)(s.default,{onPress:()=>l(e.source,e.slug,n.anchor),children:[!!n.anchor&&(0,W.jsxs)(i.default,{style:se.wikiHitCitation,children:["#",n.anchor]}),(0,W.jsx)(i.default,{style:se.hitSnippet,numberOfLines:3,children:G(n.content,t).map((e,t)=>e.match?(0,W.jsx)(i.default,{style:se.hitMatch,children:e.text},t):e.text)})]},o))})]},`${e.source}\0${e.slug}`))]})}function K(e){const t=new Map;for(const n of e)for(const e of n.cost??[]){const n=t.get(e.unit)??{unit:e.unit,amount:0,metered:0};n.amount+=e.amount,n.metered+=e.metered,t.set(e.unit,n)}return[...t.values()].sort((e,t)=>t.metered-e.metered)}const Q="\xa0";function X(e){if(!e?.length)return null;return e.map(e=>{return`${t=(0,C.formatCost)(e.amount,e.unit),(t??"").replace(/(\d) ([A-Za-z])/g,`$1${Q}$2`)}${Q}(${e.metered})`;var t}).join(" + ")}function Z({branes:e,activeBraneId:t,daemons:n,activeDaemon:l,connected:u,onSwitchBrane:m,onSwitchDaemon:p,onAdd:x,onRemove:y,onSignOutOthers:b,conn:j}){const[v,w]=(0,o.useState)(!1),[S,C]=(0,o.useState)(!1),[T,k]=(0,o.useState)(!1),[B,R]=(0,o.useState)(!1),[O,z]=(0,o.useState)(!1),[P,I]=(0,o.useState)(""),[E,L]=(0,o.useState)(""),[H,D]=(0,o.useState)(!1),[A,M]=(0,o.useState)(null),[N,$]=(0,o.useState)(null),[F,V]=(0,o.useState)(!1),q=()=>{w(!1),C(!1),k(!1),z(!1),$(null),V(!1)},G=()=>{B||(k(!1),$(null))},Y=()=>{H||(C(!1),M(null))},U=(0,o.useMemo)(()=>K(e),[e]),Q=t?e.find(e=>e.brane_id===t)?.is_home?`${t} (home)`:t:l?.id??"No daemon";return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(s.default,{style:se.daemonChip,onPress:()=>w(!0),children:[(0,W.jsx)(a.default,{style:[se.chipDot,{backgroundColor:u?"#66d9a0":"#e07070"}]}),(0,W.jsx)(i.default,{style:se.chipText,numberOfLines:1,children:Q}),(0,W.jsx)(i.default,{style:se.chipChevron,children:"\u25bc"})]}),(0,W.jsx)(d.default,{visible:v,transparent:!0,animationType:"fade",onRequestClose:q,children:(0,W.jsx)(s.default,{style:se.modalOverlay,onPress:q,children:(0,W.jsxs)(s.default,{style:se.modalContent,onPress:()=>{},children:[(0,W.jsx)(i.default,{style:se.modalTitle,children:"Branes"}),(0,W.jsxs)(c.default,{style:{flexGrow:0},children:[(0,W.jsx)(s.default,{style:[se.daemonOption,null===t&&se.daemonOptionActive],onPress:()=>{m(null),w(!1)},children:(0,W.jsxs)(a.default,{style:se.daemonOptionRow,children:[(0,W.jsx)(a.default,{style:[se.daemonDot,{backgroundColor:u?"#66d9a0":"#555"}]}),(0,W.jsxs)(a.default,{style:{flex:1},children:[(0,W.jsx)(i.default,{style:se.daemonName,children:"All branes"}),(0,W.jsx)(i.default,{style:se.daemonHost,children:l?.id}),X(U)&&(0,W.jsx)(i.default,{style:se.daemonCost,children:X(U)})]})]})}),e.map(e=>(0,W.jsx)(s.default,{style:[se.daemonOption,e.brane_id===t&&se.daemonOptionActive],onPress:()=>{m(e.brane_id),w(!1)},children:(0,W.jsxs)(a.default,{style:se.daemonOptionRow,children:[(0,W.jsx)(a.default,{style:[se.daemonDot,{backgroundColor:e.active_count>0?"#66d9a0":"#555"}]}),(0,W.jsxs)(a.default,{style:{flex:1},children:[(0,W.jsxs)(i.default,{style:se.daemonName,children:[e.brane_id,e.is_home?" (home)":""]}),(0,W.jsxs)(i.default,{style:se.daemonHost,children:[e.active_count," active, ",e.narrative_count," total",e.absorbed_count>0?` (${e.absorbed_count} absorbed)`:""]}),X(e.cost)&&(0,W.jsx)(i.default,{style:se.daemonCost,children:X(e.cost)})]})]})},e.brane_id)),0===e.length&&0===n.length&&(0,W.jsx)(i.default,{style:se.emptyDaemons,children:"No daemons configured"}),n.filter(e=>e.id!==l?.id).map(e=>(0,W.jsx)(s.default,{style:se.daemonOption,onPress:()=>{p(e.id),w(!1)},onLongPress:()=>y(e.id),children:(0,W.jsxs)(a.default,{style:se.daemonOptionRow,children:[(0,W.jsx)(a.default,{style:[se.daemonDot,{backgroundColor:"#555"}]}),(0,W.jsxs)(a.default,{style:{flex:1},children:[(0,W.jsx)(i.default,{style:se.daemonName,children:e.id}),(0,W.jsxs)(i.default,{style:se.daemonHost,children:[e.host," (switch daemon)"]})]})]})},e.id))]}),(0,W.jsx)(s.default,{style:se.addDaemonButton,onPress:()=>C(!0),children:(0,W.jsx)(i.default,{style:se.addDaemonButtonText,children:"+ Add Daemon"})}),l&&!l.revoked&&(0,W.jsx)(s.default,{style:se.addDaemonButton,onPress:()=>z(!0),disabled:!u,children:(0,W.jsx)(i.default,{style:[se.addDaemonButtonText,!u&&{opacity:.5}],children:"Devices"})}),(0,W.jsx)(s.default,{style:se.modalCancel,onPress:q,children:(0,W.jsx)(i.default,{style:se.modalCancelText,children:"Close"})})]})})}),(0,W.jsx)(d.default,{visible:v&&S,transparent:!0,animationType:"fade",onRequestClose:Y,children:(0,W.jsx)(s.default,{style:se.modalOverlay,onPress:Y,children:(0,W.jsxs)(s.default,{style:se.layerCard,onPress:e=>e.stopPropagation(),children:[(0,W.jsx)(i.default,{style:se.layerTitle,children:"Add a daemon"}),(0,W.jsxs)(a.default,{style:se.addForm,children:[(0,W.jsx)(h.default,{style:se.addInput,placeholder:"host:port",placeholderTextColor:"#666",value:P,onChangeText:I,autoCapitalize:"none",autoCorrect:!1,autoFocus:!0}),(0,W.jsx)(h.default,{style:se.addInput,placeholder:"token",placeholderTextColor:"#666",value:E,onChangeText:L,autoCapitalize:"none",autoCorrect:!1,secureTextEntry:!0}),A&&(0,W.jsx)(i.default,{style:se.addError,children:A}),(0,W.jsxs)(a.default,{style:se.layerButtonRow,children:[(0,W.jsx)(s.default,{style:[se.layerCancel,H&&{opacity:.5}],onPress:Y,disabled:H,children:(0,W.jsx)(i.default,{style:se.layerCancelText,children:"Cancel"})}),(0,W.jsx)(s.default,{style:[se.addButton,se.layerConfirm,(H||!P||!E)&&{opacity:.5}],onPress:async()=>{if(P&&E){D(!0),M(null);try{await x(P,E),C(!1),w(!1),I(""),L("")}catch(e){M(String(e))}finally{D(!1)}}},disabled:H||!P||!E,children:H?(0,W.jsx)(f.default,{size:"small",color:"#111"}):(0,W.jsx)(i.default,{style:se.addButtonText,children:"Connect"})})]})]})]})})}),(0,W.jsx)(_.default,{visible:v&&O,conn:j,daemonName:l?.id??"this daemon",onClose:()=>z(!1),onSignOutOthers:()=>k(!0),signedOutOthers:F,connected:u}),(0,W.jsx)(d.default,{visible:v&&T,transparent:!0,animationType:"fade",onRequestClose:G,children:(0,W.jsx)(s.default,{style:se.modalOverlay,onPress:G,children:(0,W.jsxs)(s.default,{style:se.layerCard,onPress:e=>e.stopPropagation(),children:[(0,W.jsx)(i.default,{style:se.layerTitle,children:"Sign out other devices?"}),(0,W.jsxs)(i.default,{style:se.signOutBody,children:[l?.id," will issue a new token. This device keeps its access; every other phone and browser paired with it is signed out until it scans a fresh Meld QR. Running agents and your shell are unaffected."]}),N&&(0,W.jsx)(i.default,{style:se.addError,children:N}),(0,W.jsxs)(a.default,{style:se.layerButtonRow,children:[(0,W.jsx)(s.default,{style:[se.layerCancel,B&&{opacity:.5}],onPress:G,disabled:B,children:(0,W.jsx)(i.default,{style:se.layerCancelText,children:"Cancel"})}),(0,W.jsx)(s.default,{style:[se.signOutButton,se.layerConfirm,B&&{opacity:.5}],onPress:async()=>{R(!0),$(null);try{await b(),V(!0),k(!1)}catch(e){$(String(e))}finally{R(!1)}},disabled:B,children:B?(0,W.jsx)(f.default,{size:"small",color:"#111"}):(0,W.jsx)(i.default,{style:se.addButtonText,children:"Sign out other devices"})})]})]})})})]})}const J=30,ee=.5,te=64,ne=96,oe=52,re=360;function ae(e){return-Math.min(e,ne)/ne*re}function ie({refreshing:e,onRefresh:t,scrollOffsetRef:n,children:a}){const i=(0,o.useRef)(null),[l,s]=(0,o.useState)(0),[d,c]=(0,o.useState)(!1),[u,f]=(0,B.useDetentSpin)(e),[h,m]=(0,o.useState)("none"),p=(0,o.useRef)(0),x=(0,o.useRef)(null),y=(0,o.useRef)(!1),b=(0,o.useCallback)(e=>{p.current=e,s(e)},[]);(0,o.useEffect)(()=>{const o=i.current;if(!o)return;const a=()=>(n.current??0)<=0,l=t=>{if(e||1!==t.touches.length||!a())return y.current=!1,void(x.current=null);x.current=t.touches[0].clientY,y.current=!0},s=t=>{if(!y.current||null===x.current||e)return;const n=t.touches[0].clientY-x.current;if(n<=0||!a())return a()||(y.current=!1),0!==p.current&&(b(0),f(0)),void c(!1);t.preventDefault();const o=Math.min(ne,n*ee);c(!0),m("none"),b(o),f(ae(o))},d=()=>{var n;y.current&&(y.current=!1,x.current=null,c(!1),p.current>=te&&!e?(f((n=ae(p.current),Math.round(n/B.RECYCLE_STEP)*B.RECYCLE_STEP)),b(oe),t()):(m("transform 0.4s ease"),f(0),b(0)))};return o.addEventListener("touchstart",l,{passive:!0}),o.addEventListener("touchmove",s,{passive:!1}),o.addEventListener("touchend",d,{passive:!0}),o.addEventListener("touchcancel",d,{passive:!0}),()=>{o.removeEventListener("touchstart",l),o.removeEventListener("touchmove",s),o.removeEventListener("touchend",d),o.removeEventListener("touchcancel",d)}},[e,t,n,b]),(0,o.useEffect)(()=>{if(!e)return 0!==p.current&&b(0),m("none"),void f(0);m("transform 0.18s ease")},[e,b,f]);const j=d?"none":"transform 0.25s ease";return(0,W.jsxs)("div",{ref:i,style:{flex:1,minHeight:0,position:"relative",overflow:"hidden",display:"flex",flexDirection:"column"},children:[(0,W.jsx)("div",{style:{position:"absolute",top:0,left:0,right:0,height:oe,display:"flex",alignItems:"center",justifyContent:"center",transform:`translateY(${l-oe}px)`,transition:j,pointerEvents:"none",zIndex:1},children:(0,W.jsx)(B.RecycleGlyph,{angle:u,transition:h,fontSize:26,opacity:e?1:Math.min(1,l/te)})}),(0,W.jsx)("div",{style:{flex:1,minHeight:0,display:"flex",flexDirection:"column",transform:`translateY(${l}px)`,transition:j},children:a})]})}function le(){const{conn:e,connected:t,daemons:n,activeDaemon:d,activeBraneId:c,switchDaemon:u,switchBrane:y,addDaemon:j,removeDaemon:v,rotateActiveToken:w,onStatus:S,onMeta:B,onActivity:_,subscribeActivity:$,unsubscribeActivity:F}=(0,x.useBrane)(),V="undefined"!=typeof window&&!!e&&(0,P.isIsolated)(window.location.host,e.host),q=(0,I.useAppHost)(e,V),[G,K]=(0,o.useState)([]),[Q,X]=(0,o.useState)([]),ee=(0,o.useRef)(null),[te,ne]=(0,o.useState)([]),[oe,re]=(0,o.useState)(!0),[ae,le]=(0,o.useState)(!1),[de,ce]=(0,o.useState)(!1),[ue,fe]=(0,o.useState)(null),[he,me]=(0,o.useState)(null),[pe,ge]=(0,o.useState)(null),[xe,ye]=(0,o.useState)(null),[be,je]=(0,o.useState)(J),[ve,we]=(0,o.useState)(!1),[Se,Ce]=(0,o.useState)(""),[Te,ke]=(0,o.useState)([]),[Be,Re]=(0,o.useState)(!1),[Oe,ze]=(0,o.useState)([]),[Pe,Ie]=(0,o.useState)(!1),[Ee,Le]=(0,o.useState)(!1),[He,De]=(0,o.useState)("relevance"),[We,Ae]=(0,o.useState)(null),Me=(0,o.useRef)(null),Ne=(0,o.useRef)(null),$e=(0,o.useRef)(null),Fe=(0,o.useRef)(0),Ve=(0,m.useRouter)(),qe=(0,p.useIsFocused)(),Ge=(0,o.useRef)(!1);Ge.current=qe;const Ye=(0,o.useRef)(null);(0,o.useEffect)(()=>{if(!qe)return;const e=e=>{if(!Ge.current)return;if(e.defaultPrevented||e.isComposing||!(0,H.isListScrollKey)(e))return;const t=$e.current?.getScrollableNode();if(!t)return;const n=e.target,o=n?.tagName;if("INPUT"===o||"TEXTAREA"===o||"SELECT"===o||n?.isContentEditable)return;if(n&&t.contains(n))return;if(document.querySelector('[aria-modal="true"]'))return;const a=performance.now(),i=Ye.current,l=i&&a-i.at<A?i.target:t.scrollTop,s=(0,H.listScrollTarget)(e.key,l,t);if(null===s)return;e.preventDefault(),Ye.current={target:s,at:a};const d=window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;t.scroll({top:s,behavior:e.repeat||d?"auto":"smooth"})};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[qe]);const Ue=(0,o.useCallback)(async()=>{if(e){ye(null),je(J);try{const t=c?{archived:!0,braneIds:[c]}:void 0,[n,o,a]=await Promise.all([(0,C.fetchNarratives)(e,t),(0,C.fetchFolds)(e),(0,C.fetchBranes)(e).catch(()=>[])]);K((0,E.sortNarratives)(n)),ne(o),X(a),setTimeout(()=>{$e.current?.scrollToOffset({offset:0,animated:!1})},50)}catch(e){ye(String(e)),K([]),ne([]),X([])}finally{re(!1)}}},[e,c]),Ke=(0,o.useCallback)(async()=>{if(e&&!ae){le(!0);try{await Ue()}finally{le(!1)}}},[e,ae,Ue]);(0,o.useEffect)(()=>{if(e)K([]),ne([]),X([]),re(!0),Ue();else if(K([]),ne([]),X([]),re(!1),0===n.length){const e=setTimeout(()=>{ye(null),re(!1)},100);return()=>clearTimeout(e)}},[e,Ue,n.length]);const Qe=(0,o.useCallback)(()=>{e&&ce(!0)},[e]),Xe=(0,o.useCallback)(e=>{K(t=>[e,...t]),Ve.push("utility"===e.role?`/${e.id}?tab=terminal`:`/${e.id}`)},[Ve]),Ze=(0,o.useCallback)(async t=>{if(!e)return;if((0,b.revivesAsTwin)(t.role))return void ge(t);const n=t.id;try{const t=(await(0,C.reviveNarrative)(e,n)).nid??n;t!==n&&Ue(),Ve.push((0,P.terminalOnlyHref)(t))}catch(e){ye(String(e))}},[e,Ve,Ue]),Je=(0,o.useCallback)(t=>{e&&((0,D.interruptSession)(e,t),Ve.push((0,P.terminalOnlyHref)(t)))},[e,Ve]),et=(0,o.useCallback)(async(t,n)=>{if(!e)return;const o=!n;try{await(0,C.archiveNarrative)(e,t,o),K(o?e=>e.filter(e=>e.id!==t):e=>e.map(e=>e.id===t?Object.assign({},e,{archived:!1}):e))}catch(e){ye(String(e))}},[e]),tt=(0,o.useCallback)(async(e,t)=>{await j(e,t)},[j]);(0,o.useEffect)(()=>S((e,t)=>{K(n=>(0,E.sortNarratives)(n.map(n=>n.id!==e?n:"mcp_connected"===t?Object.assign({},n,{mcp_connected:!0}):"mcp_disconnected"===t?Object.assign({},n,{mcp_connected:!1,awaiting:!1}):t===L.AWAITING_STATUS?Object.assign({},n,{awaiting:!0}):t===L.NOT_AWAITING_STATUS?Object.assign({},n,{awaiting:!1}):Object.assign({},n,{status:t}))))}),[S]),(0,o.useEffect)(()=>B((t,n,o,a)=>{null!=a&&e&&(ee.current&&clearTimeout(ee.current),ee.current=setTimeout(()=>{ee.current=null,(0,C.fetchBranes)(e).then(X).catch(()=>{})},2e3)),K(e=>e.map(e=>{if(e.id!==t)return e;if(void 0===o&&null==a)return e;const n=Object.assign({},e);return void 0!==o&&(n.summary=o),null!=a&&(n.cost_amount=a.amount,n.cost_unit=a.unit),n}))}),[B,e]),(0,o.useEffect)(()=>{$();const e=_((e,t,n)=>{K(t=>{const o=t.findIndex(t=>t.id===e);if(o<0)return t;const a=t.slice();return a[o]=Object.assign({},a[o],{last_activity:n}),a})});return()=>{e(),F()}},[_,$,F]);const nt=!e&&0===n.length,[ot,rt]=(0,o.useState)([]);(0,o.useEffect)(()=>e&&Se.trim()?(Re(!0),Me.current&&clearTimeout(Me.current),Me.current=setTimeout(()=>{(0,C.searchNarratives)(e,Se.trim(),30,c?[c]:void 0).then(e=>{ke(e.results),rt(e.narratives||[]),Re(!1)}).catch(()=>{ke([]),rt([]),Re(!1)}),(0,C.searchWiki)(e,Se.trim(),10).then(e=>ze(e.results)).catch(()=>ze([]))},300),()=>{Me.current&&clearTimeout(Me.current)}):(ke([]),rt([]),ze([]),void Re(!1)),[e,Se,c]);const at=(0,o.useMemo)(()=>new Set(G.map(e=>e.id)),[G]),it=(0,o.useMemo)(()=>{const e=new Map;for(const t of Te){const n=e.get(t.narrative_id);n?n.push(t):e.set(t.narrative_id,[t])}return e},[Te]),lt=(0,o.useMemo)(()=>{if(!Se.trim())return G;const e=Se.toLowerCase(),t=new Set(G.filter(t=>t.id.toLowerCase().includes(e)||t.summary?.toLowerCase().includes(e)||t.agent_type?.toLowerCase().includes(e)||t.role?.toLowerCase().includes(e)||t.fold_path?.toLowerCase().includes(e)||it.has(t.id)).map(e=>e.id)),n=new Map(G.map(e=>[e.id,e])),o=new Map;for(const e of t)o.set(e,n.get(e));for(const e of ot)o.has(e.id)||o.set(e.id,e);return[...o.values()]},[G,Se,it,ot]),st=(0,o.useMemo)(()=>{const e=new Map;for(const t of Te){const n=e.get(t.narrative_id);(void 0===n||t.score>n)&&e.set(t.narrative_id,t.score)}return e},[Te]),dt=(0,o.useMemo)(()=>{if(Se.trim())return[...lt].sort((e,t)=>{if("recent"===He)return t.created_at-e.created_at;const n=st.get(e.id)??-1/0,o=st.get(t.id)??-1/0;return n!==o?o-n:t.created_at-e.created_at});const e=[],t=[];for(const n of lt)"ended"!==n.status||n.mcp_connected?e.push(n):t.push(n);return[...e,...t.slice(0,be)]},[lt,be,Se,He,st]);(0,o.useEffect)(()=>{ue&&!dt.some(e=>e.id===ue)&&fe(null)},[dt,ue]);const ct=(0,o.useMemo)(()=>lt.filter(e=>"ended"===e.status&&!e.mcp_connected).length,[lt]),ut=(0,o.useCallback)(()=>{je(e=>Math.min(e+J,ct))},[ct]);return(0,W.jsxs)(a.default,{style:se.container,children:[(0,W.jsx)(m.Stack.Screen,{options:{header:()=>(0,W.jsxs)(a.default,{style:se.customHeader,children:[(0,W.jsxs)(a.default,{style:se.headerTitleRow,children:[(0,W.jsx)(s.default,{onPress:Ue,children:(0,W.jsx)(i.default,{style:Object.assign({color:"#8fd4b4",fontSize:20,fontWeight:"700",letterSpacing:2},{textShadow:["0 0 7px rgba(143, 212, 180, 0.8)","0 0 20px rgba(143, 212, 180, 0.5)","0 0 40px rgba(100, 200, 160, 0.3)","0 2px 12px rgba(80, 180, 140, 0.6)"].join(", ")}),children:"BRANE"})}),(0,W.jsx)(s.default,{onPress:Qe,disabled:!e,style:[se.spawnButton,!e&&se.spawnButtonDisabled],children:(0,W.jsx)(i.default,{style:se.spawnButtonText,children:"Spawn"})}),(0,W.jsx)(Z,{branes:Q,activeBraneId:c,daemons:n,activeDaemon:d,connected:t,onSwitchBrane:y,onSwitchDaemon:u,onAdd:tt,onRemove:v,onSignOutOthers:w,conn:e}),(0,W.jsx)(s.default,{onPress:()=>{we(e=>(e?Ce(""):setTimeout(()=>Ne.current?.focus(),100),!e))},style:[se.searchButton,ve&&se.searchButtonActive],children:(0,W.jsx)(i.default,{style:[se.searchButtonText,ve&&se.searchButtonTextActive],children:"\ud83d\udd2c"})})]}),ve&&(0,W.jsx)(a.default,{style:se.searchBar,children:(0,W.jsx)(h.default,{ref:Ne,style:se.searchInput,placeholder:"Filter narratives...",placeholderTextColor:"#556",value:Se,onChangeText:Ce,autoFocus:!0,autoCapitalize:"none",autoCorrect:!1,returnKeyType:"search"})})]})}}),d?.revoked?(0,W.jsxs)(a.default,{style:se.center,children:[(0,W.jsxs)(i.default,{style:se.signedOutTitle,children:["Signed out of ",d.id]}),(0,W.jsx)(i.default,{style:se.emptySubtext,children:"Its token was rotated from another device, so the one stored here no longer works. Scan a fresh Meld QR \u2014 or run `brane meld` on that machine \u2014 to reconnect. Nothing else was touched."})]}):oe?(0,W.jsx)(a.default,{style:se.center,children:(0,W.jsx)(f.default,{size:"large",color:"#5b9bd5"})}):xe?(0,W.jsx)(a.default,{style:se.center,children:(0,W.jsx)(i.default,{style:se.errorText,children:xe})}):nt?(0,W.jsx)(O.default,{title:"No daemons configured",subtitle:"Tap the daemon selector above to add one"}):(0,W.jsx)(ie,{refreshing:ae,onRefresh:Ke,scrollOffsetRef:Fe,children:(0,W.jsx)(l.default,{ref:$e,style:{flex:1},data:Se.trim()&&Ee?[]:dt,keyExtractor:e=>e.id,CellRendererComponent:M,onScroll:e=>{Fe.current=e.nativeEvent.contentOffset.y},scrollEventThrottle:16,ListHeaderComponent:Se.trim()?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(U,{results:Oe,query:Se.trim(),collapsed:Pe,onToggle:()=>Ie(e=>!e),onOpen:(e,t,n)=>Ae({source:e,slug:t,anchor:n})}),(0,W.jsx)(a.default,{style:se.wikiSection,children:(0,W.jsx)(Y,{icon:"\ud83d\udcac",label:"Narratives",count:dt.length,collapsed:Ee,onToggle:()=>Le(e=>!e),order:He,onToggleOrder:()=>De(e=>"relevance"===e?"recent":"relevance")})})]}):null,renderItem:({item:t})=>(0,W.jsx)(N,{item:t,conn:e,onPress:()=>Ve.push(`/${t.id}`),onArchive:()=>et(t.id,!!t.archived),onMeld:()=>me(t),onTwin:()=>ge(t),onRevive:()=>Ze(t),onEnd:()=>Je(t.id),menuVisible:ue===t.id,setMenuVisible:e=>fe(e?t.id:null),hits:it.get(t.id),onHitPress:(e,t)=>Ve.push(`/${e}?scrollToSeq=${t}`),isolated:V,appHost:q}),onEndReached:!Se.trim()&&be<ct?ut:void 0,onEndReachedThreshold:.3,ListFooterComponent:dt.length>0&&!Se.trim()?(0,W.jsx)(O.default,{}):null,contentContainerStyle:0!==dt.length||Se.trim()?void 0:se.emptyFill,ListEmptyComponent:Se.trim()?Ee?null:(0,W.jsx)(a.default,{style:se.center,children:(0,W.jsx)(i.default,{style:se.emptyText,children:"No narratives match"})}):(0,W.jsx)(O.default,{title:"No narratives yet"})})}),(0,W.jsx)(R.default,{visible:de,conn:e,onClose:()=>{ce(!1),e&&(0,C.fetchFolds)(e).then(ne).catch(()=>{})},onSpawned:Xe}),(0,W.jsx)(z.default,{visible:null!==he,conn:e,path:`/${he?.id??""}`,onClose:()=>me(null)}),(0,W.jsx)(R.default,{visible:null!==pe,conn:e,re:pe?.id,defaultFoldPath:pe?.fold_path,onClose:()=>ge(null),onSpawned:Xe}),We&&e&&(0,W.jsx)(k.MarkdownLinksProvider,{knownNarrativeIds:at,onNarrativePress:(e,t)=>{Ae(null),Ve.push(null!=t?`/${e}?scrollToSeq=${t}`:`/${e}`)},children:(0,W.jsx)(T.default,{conn:e,target:We,onClose:()=>Ae(null)})})]})}const se=u.default.create({container:{flex:1},center:{flex:1,justifyContent:"center",alignItems:"center",padding:20},customHeader:{backgroundColor:"#1a1a1e",paddingTop:10,paddingHorizontal:16,paddingBottom:10,borderBottomWidth:u.default.hairlineWidth,borderBottomColor:"rgb(216, 216, 216)"},headerTitleRow:{flexDirection:"row",alignItems:"center",gap:12},daemonChip:{flexDirection:"row",alignItems:"center",backgroundColor:"#2a2a30",borderRadius:6,paddingHorizontal:10,paddingVertical:6,maxWidth:180},chipDot:{width:8,height:8,borderRadius:4,marginRight:8},chipText:{color:"#d8d8dd",fontSize:15,fontFamily:"monospace"},chipChevron:{color:"#888",fontSize:14,marginLeft:5},daemonOption:{paddingVertical:12,paddingHorizontal:12,borderRadius:8,backgroundColor:"#2a2a30",marginBottom:6},daemonOptionActive:{backgroundColor:"#1a3a2a",borderWidth:1,borderColor:"#3a6a4a"},daemonOptionRow:{flexDirection:"row",alignItems:"center"},daemonDot:{width:8,height:8,borderRadius:4,marginRight:10},daemonName:{color:"#d8d8dd",fontSize:15,fontFamily:"monospace"},daemonCost:{color:"#7bb894",fontSize:12,fontFamily:"monospace",marginTop:2},daemonHost:{color:"#777",fontSize:12,fontFamily:"monospace",marginTop:2},emptyDaemons:{color:"#666",fontSize:14,textAlign:"center",paddingVertical:16},addDaemonButton:{paddingVertical:14,alignItems:"center",borderRadius:8,backgroundColor:"#2a2a30",marginTop:8},addDaemonButtonText:{color:"#8fd4b4",fontSize:15,fontWeight:"600"},addForm:{marginTop:8,gap:8},addInput:{backgroundColor:"#222228",borderRadius:8,paddingHorizontal:12,paddingVertical:10,color:"#d8d8dd",fontSize:14,fontFamily:"monospace",borderWidth:1,borderColor:"#3a3a40"},addError:{color:"#e07070",fontSize:12},addButton:{backgroundColor:"#5b9bd5",borderRadius:8,paddingVertical:10,alignItems:"center"},addButtonText:{color:"#111",fontSize:14,fontWeight:"600"},signOutBody:{color:"#999",fontSize:13,lineHeight:18},layerCard:{backgroundColor:"#1e1e22",borderRadius:12,padding:20,width:"100%",maxWidth:360,borderWidth:1,borderColor:"#3a3a40"},layerTitle:{color:"#d8d8dd",fontSize:16,fontWeight:"600",marginBottom:10},layerButtonRow:{flexDirection:"row",gap:8,marginTop:4},layerCancel:{flex:1,backgroundColor:"#2a2a30",borderRadius:8,paddingVertical:10,alignItems:"center"},layerCancelText:{color:"#aaa",fontSize:14,fontWeight:"600"},layerConfirm:{flex:2},signOutButton:{backgroundColor:"#e0a070",borderRadius:8,paddingVertical:10,alignItems:"center"},signedOutTitle:{color:"#e0a070",fontSize:16,fontWeight:"600",marginBottom:8,textAlign:"center"},fieldLabel:{color:"#aaa",fontSize:12,fontWeight:"600",textTransform:"uppercase",letterSpacing:.5,marginTop:12,marginBottom:6},fieldStaticValue:{backgroundColor:"#222228",borderRadius:8,paddingHorizontal:12,paddingVertical:10,borderWidth:1,borderColor:"#2a2a30"},cardHeader:{flexDirection:"row",justifyContent:"space-between",alignItems:"center"},summary:{color:"#9a9aa0",fontSize:12,marginTop:4,lineHeight:12},status:{fontSize:12,textTransform:"uppercase"},hitsContainer:{marginTop:8,gap:4},hitSnippet:{color:"#b0a890",fontSize:12,lineHeight:17,paddingLeft:10,paddingVertical:3,borderLeftWidth:2,borderLeftColor:"rgba(255, 130, 180, 0.5)",backgroundColor:"rgba(255, 130, 180, 0.04)",borderRadius:2},wikiSection:{paddingHorizontal:14,paddingTop:12,paddingBottom:4},wikiBar:Object.assign({flexDirection:"row",alignItems:"center",gap:6,paddingVertical:11,paddingHorizontal:12,marginBottom:8,borderRadius:8,backgroundColor:"rgba(143, 212, 180, 0.12)",borderWidth:1,borderColor:"rgba(143, 212, 180, 0.35)"},{userSelect:"none"}),wikiBarCollapsed:{backgroundColor:"rgba(143, 212, 180, 0.06)",borderColor:"rgba(143, 212, 180, 0.22)"},wikiBarPillPressed:{backgroundColor:"rgba(143, 212, 180, 0.18)"},wikiBarPill:Object.assign({flexDirection:"row",alignItems:"center",gap:5,paddingVertical:3,paddingHorizontal:8,borderRadius:9,flexShrink:0,backgroundColor:"rgba(0, 0, 0, 0.32)",borderWidth:1,borderColor:"rgba(143, 212, 180, 0.35)"},{cursor:"pointer",userSelect:"none"}),wikiBarOrderLabel:{color:"#cdeede",fontSize:13,fontWeight:"400",letterSpacing:.5,textTransform:"uppercase"},wikiBarIcon:{fontSize:15},wikiBarLabel:{color:"#8fd4b4",fontSize:13,fontWeight:"700",letterSpacing:1,textTransform:"uppercase",flexShrink:1},wikiBarCount:{color:"#bfe6d3",fontSize:12,fontWeight:"700",fontFamily:"monospace",flexShrink:0},wikiBarToggle:{color:"#cdeede",fontSize:13,fontWeight:"400",textTransform:"uppercase",letterSpacing:.5},wikiCard:{backgroundColor:"#1e1e24",borderRadius:8,padding:12,marginBottom:8,borderWidth:u.default.hairlineWidth,borderColor:"rgba(143, 212, 180, 0.25)"},wikiCardHeader:{flexDirection:"row",alignItems:"center",gap:8},wikiSlug:{color:"#d8d8dd",fontSize:15,fontWeight:"600",fontFamily:"monospace",flex:1},wikiSource:{color:"#7a8a9a",fontSize:11,fontFamily:"monospace",backgroundColor:"#2a2a32",paddingHorizontal:6,paddingVertical:2,borderRadius:4,overflow:"hidden"},wikiHitCitation:{color:"#6c9bd5",fontSize:11,fontFamily:"monospace",paddingLeft:10,marginTop:4},hitMatch:{color:"#ffd9ec",fontWeight:"700",backgroundColor:"rgba(255, 130, 180, 0.22)"},emptyFill:{flexGrow:1},emptyText:{color:"#666",fontSize:16},emptySubtext:{color:"#555",fontSize:13,marginTop:8},errorText:{color:"#e07070",fontSize:14,textAlign:"center"},searchButton:{paddingLeft:16,paddingVertical:8,marginLeft:"auto",marginRight:-5},searchButtonActive:{},searchButtonText:{fontSize:20},searchButtonTextActive:Object.assign({},{textShadow:["0 0 10px rgba(255, 130, 180, 0.9)","0 0 25px rgba(255, 110, 165, 0.7)","0 0 50px rgba(255, 100, 155, 0.4)","0 2px 15px rgba(255, 120, 170, 0.6)"].join(", ")}),searchBar:{flexDirection:"row",alignItems:"center",marginTop:10},searchInput:Object.assign({flex:1,color:"#d8d8dd",fontSize:16,fontFamily:"monospace",backgroundColor:"#222228",borderRadius:8,paddingHorizontal:12,paddingVertical:6,borderWidth:1,borderColor:"rgba(255, 130, 180, 0.4)"},{outlineStyle:"none",boxShadow:["0 0 6px rgba(255, 130, 180, 0.5)","0 0 14px rgba(255, 110, 165, 0.35)","0 0 28px rgba(255, 100, 155, 0.2)"].join(", ")}),spawnButton:Object.assign({paddingHorizontal:12,paddingVertical:6,borderRadius:6,backgroundColor:"#5b9bd5",justifyContent:"center",alignItems:"center",marginLeft:0},{boxShadow:["0 0 6px rgba(91, 155, 213, 0.7)","0 0 16px rgba(91, 155, 213, 0.4)","0 2px 10px rgba(70, 130, 200, 0.5)"].join(", ")}),spawnButtonDisabled:{opacity:.4},spawnButtonText:{color:"#111",fontSize:14,fontWeight:"600"},modalOverlay:{flex:1,backgroundColor:"rgba(0,0,0,0.6)",justifyContent:"center",alignItems:"center",padding:24},modalContent:{backgroundColor:"#1e1e22",borderRadius:12,padding:20,width:"100%",maxWidth:400,maxHeight:"80%"},modalTitle:{color:"#d8d8dd",fontSize:18,fontWeight:"600",marginBottom:16},foldOption:{paddingVertical:14,paddingHorizontal:12,borderRadius:8,backgroundColor:"#2a2a30",marginBottom:8},foldOptionText:{color:"#d8d8dd",fontSize:15,fontFamily:"monospace"},modalCancel:{paddingVertical:12,alignItems:"center",marginTop:8},modalCancelText:{color:"#888",fontSize:15}})},981,[167,11,13,105,113,146,153,122,26,416,145,161,165,116,736,773,769,770,776,767,778,745,973,950,965,972,982,780,989,747,978,977,754,990,749,6]);
1085
+ __d(function(g,r,i,a,m,_e,d){"use strict";const e=["title","subtitle"];function t(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return f}});var n=t(r(d[0]));r(d[1]);var l=t(r(d[2])),u=t(r(d[3])),c=t(r(d[4])),s=t(r(d[5])),o=r(d[6]);function f(t){let{title:l,subtitle:f}=t,x=(0,n.default)(t,e);return(0,o.jsxs)(c.default,{style:p.center,children:[(0,o.jsx)(s.default,Object.assign({},x)),l?(0,o.jsx)(u.default,{style:p.emptyText,children:l}):null,f?(0,o.jsx)(u.default,{style:p.emptySubtext,children:f}):null]})}const p=l.default.create({center:{flex:1,justifyContent:"center",alignItems:"center",padding:20,gap:4},emptyText:{color:"#666",fontSize:16,marginTop:20},emptySubtext:{color:"#555",fontSize:13,marginTop:4,textAlign:"center"}})},982,[167,11,26,105,13,983,6]);
1086
+ __d(function(_g,_r,_i,_a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return E}});var e=_r(d[0]),t=_r(d[1]),n=_r(d[2]),o=_r(d[3]),i=_r(d[4]),r=_r(d[5]),a=_r(d[6]);const s="#121214",l=i.TERRAIN_ROWS+r.MAX_SPLOTCHES,c="\nattribute vec2 a_pos;\nvoid main() { gl_Position = vec4(a_pos, 0.0, 1.0); }\n",h=`\nprecision highp float;\nuniform vec2 u_res; // drawing buffer size, px\nuniform vec4 u_glyph; // x, y (top-left, px from top-left), w, h (w == h)\nuniform vec2 u_offset; // the noise window's integrated drift: x sway, y lift\nuniform float u_phase; // the noise's integrated time phase (churn)\nuniform sampler2D u_mask;\nuniform vec3 u_bg;\n// Two tables, as float textures read by index, so neither has a size a hand\n// will meet (claude-1cwe8u9p:61). Schemes (src/shared/membrane-palette.ts,\n// packScheme): one row each, the first TERRAIN_ROWS the terrain block\n// (src/shared/membrane-terrain.ts, blockRows / packCell, which adds the\n// cell's seed point as a last texel), the rest the groups'. Splotches\n// (src/shared/membrane-invasion.ts, packSplotches): one row each, oldest\n// first, naming the scheme row they paint in.\nuniform sampler2D u_schemes;\nuniform sampler2D u_splotchTable;\nuniform float u_splotchCount;\nuniform float u_clock; // seconds; animates the dithering of the fronts\nuniform vec2 u_drag; // accumulated drag, glyph widths: world = p - u_drag\nuniform vec2 u_cell0; // the block's centre cell (integer coordinates)\n\n// Classic 3D Perlin (gradient) noise; the third axis is time, so the field\n// evolves continuously and never cycles back on itself.\nvec3 grad3(vec3 p) {\n p = vec3(dot(p, vec3(127.1, 311.7, 74.7)),\n dot(p, vec3(269.5, 183.3, 246.1)),\n dot(p, vec3(113.5, 271.9, 124.6)));\n return -1.0 + 2.0 * fract(sin(p) * 43758.5453123);\n}\nfloat perlin(vec3 p) {\n vec3 i = floor(p), f = fract(p);\n vec3 u = f * f * f * (f * (f * 6.0 - 15.0) + 10.0);\n return mix(\n mix(mix(dot(grad3(i + vec3(0,0,0)), f - vec3(0,0,0)), dot(grad3(i + vec3(1,0,0)), f - vec3(1,0,0)), u.x),\n mix(dot(grad3(i + vec3(0,1,0)), f - vec3(0,1,0)), dot(grad3(i + vec3(1,1,0)), f - vec3(1,1,0)), u.x), u.y),\n mix(mix(dot(grad3(i + vec3(0,0,1)), f - vec3(0,0,1)), dot(grad3(i + vec3(1,0,1)), f - vec3(1,0,1)), u.x),\n mix(dot(grad3(i + vec3(0,1,1)), f - vec3(0,1,1)), dot(grad3(i + vec3(1,1,1)), f - vec3(1,1,1)), u.x), u.y),\n u.z);\n}\nfloat fbm(vec3 p) {\n float v = 0.0, a = 0.5;\n for (int i = 0; i < 5; i++) { v += a * perlin(p); p = p * 2.03 + vec3(1.7, 9.2, 3.1); a *= 0.5; }\n return 0.5 + 0.5 * (v * 1.4);\n}\n\n// OKLab \u2192 linear sRGB (Bj\xf6rn Ottosson), as in membrane-palette.ts.\nvec3 oklabToLinear(vec3 c) {\n float l_ = c.x + 0.3963377774 * c.y + 0.2158037573 * c.z;\n float m_ = c.x - 0.1055613458 * c.y - 0.0638541728 * c.z;\n float s_ = c.x - 0.0894841775 * c.y - 1.2914855480 * c.z;\n float l = l_ * l_ * l_, m = m_ * m_ * m_, s = s_ * s_ * s_;\n return vec3( 4.0767416621 * l - 3.3077115913 * m + 0.2309699292 * s,\n -1.2684380046 * l + 2.6097574011 * m - 0.3413193965 * s,\n -0.0041960863 * l - 0.7034186147 * m + 1.7076147010 * s);\n}\nbool inGamut(vec3 lin) { return all(greaterThanEqual(lin, vec3(-1e-4))) && all(lessThanEqual(lin, vec3(1.0001))); }\n\nvec4 schemeTexel(float row, float col) {\n return texture2D(u_schemes, vec2((col + 0.5) / ${i.TERRAIN_TEXELS}.0, (row + 0.5) / ${l}.0));\n}\nvec2 anchorOf(float row, float k) {\n vec4 t = schemeTexel(row, 2.0 + floor(k * 0.5));\n return mod(k, 2.0) < 0.5 ? t.xy : t.zw;\n}\n// Lightness banding from its parameters (cycles, phase, mid, amplitude) \u2014\n// a scheme's own, or the terrain's blend of several.\nfloat bandingOf(vec4 l, float d) {\n return l.z + l.w * cos(6.28318 * (l.x * d + l.y));\n}\nfloat banding(float row, float d) {\n return bandingOf(schemeTexel(row, 1.0), d);\n}\n// A scheme's anchor color at position u through one pass of its anchors, as\n// an OKLab a/b offset. Each anchor holds, then turns into the next over a\n// window of half-width h.w \u2014 along a straight line through a/b, not around\n// the hue wheel, so the turn passes through no hue the two do not share\n// (abAt in membrane-palette.ts).\nvec2 anchorAt(float row, float u) {\n vec4 h = schemeTexel(row, 0.0); // count, passes per unit thickness, phase, half-width\n float x = fract(u) * h.x;\n float fi = floor(x);\n float f = smoothstep(0.5 - h.w, 0.5 + h.w, x - fi);\n vec2 a = anchorOf(row, fi), b = anchorOf(row, fi + 1.0);\n return mix(a.y * vec2(cos(a.x), sin(a.x)), b.y * vec2(cos(b.x), sin(b.x)), f);\n}\n// The same at thickness d, at the scheme's own cycling rate and phase.\nvec2 anchorAB(float row, float d) {\n vec4 h = schemeTexel(row, 0.0);\n return anchorAt(row, h.y * d + h.z);\n}\n\n// The scheme terrain: the base film's scheme is the cell it is over, in\n// world coordinates (glyph space carried by the drag, so the map scrolls with\n// the film and the lift never moves it). Cells are irregular: each grid cell\n// has a seed point jittered within it (its last texel), and a point wears\n// the nearest seed's scheme \u2014 a Voronoi partition, so no wall is axis-aligned\n// and no two are alike (claude-xaj5pb9b:16). The block's rows are the\n// BLOCK\xd7BLOCK cells around u_cell0, row-major; a point's nearest seeds are\n// in its own cell or the eight around it. Every cell whose seed is within\n// SEAM of the nearest gets a share, falling smoothly with the excess, so\n// nothing is discontinuous (a nearest-two blend jumped wherever the\n// runner-up changed \u2014 claude-xaj5pb9b:21); and the lookup position is\n// displaced by a static fbm, whose large octaves bend the walls and small\n// ones dither them. All of it in world coordinates and out of time, so the\n// map it draws is as fixed as the cells.\n//\n// What the shares blend is the *scheme*, not its colors (claude-xaj5pb9b:27):\n// the banding parameters into one cosine and the hue cycle into one\n// position, and the thickness is then rendered through that single local\n// scheme at full contrast. Averaging each cell's rendered banding instead\n// cancelled two cosines against each other and washed the texture out of\n// every seam (claude-xaj5pb9b:26). The anchors, which come in different\n// counts, are looked up per cell at the shared position and blended.\nfloat terrainRow(vec2 ij) {\n const float R = ${((i.BLOCK-1)/2).toFixed(1)};\n vec2 d = clamp(ij - u_cell0, -R, R);\n return (d.y + R) * ${i.BLOCK}.0 + (d.x + R);\n}\nfloat shareOf(float row, vec2 q, float d1) {\n float excess = distance(q, schemeTexel(row, ${o.SCHEME_TEXELS}.0).xy) - d1;\n return 1.0 - smoothstep(0.0, ${i.SEAM.toFixed(4)}, excess);\n}\nvoid terrain(vec2 p, float d, out float L, out vec2 ab) {\n vec2 w = p - u_drag;\n vec2 q = w + ${(2*i.WARP).toFixed(3)} * (vec2(fbm(vec3(w * ${i.WARP_FREQ.toFixed(3)} + 60.0, 7.0)),\n fbm(vec3(w * ${i.WARP_FREQ.toFixed(3)} + 90.0, 11.0))) - 0.5);\n vec2 c = floor(q / ${i.CELL.toFixed(4)});\n float d1 = 1e9;\n for (int j = -1; j <= 1; j++) {\n for (int i = -1; i <= 1; i++) {\n d1 = min(d1, distance(q, schemeTexel(terrainRow(c + vec2(float(i), float(j))), ${o.SCHEME_TEXELS}.0).xy));\n }\n }\n // The local scheme: banding and hue-cycle parameters blended by share.\n float total = 0.0;\n vec4 light = vec4(0.0);\n vec2 cycle = vec2(0.0); // passes per unit thickness, phase\n for (int j = -1; j <= 1; j++) {\n for (int i = -1; i <= 1; i++) {\n float row = terrainRow(c + vec2(float(i), float(j)));\n float share = shareOf(row, q, d1);\n if (share > 0.0) {\n light += share * schemeTexel(row, 1.0);\n cycle += share * schemeTexel(row, 0.0).yz;\n total += share;\n }\n }\n }\n light /= total;\n cycle /= total;\n L = bandingOf(light, d);\n // The anchors at the shared cycle position, blended by the same shares.\n float u = cycle.x * d + cycle.y;\n ab = vec2(0.0);\n for (int j = -1; j <= 1; j++) {\n for (int i = -1; i <= 1; i++) {\n float row = terrainRow(c + vec2(float(i), float(j)));\n float share = shareOf(row, q, d1);\n if (share > 0.0) ab += share * anchorAt(row, u);\n }\n }\n ab /= total;\n}\n\nvec4 splotchTexel(float i, float col) {\n return texture2D(u_splotchTable, vec2((col + 0.5) / ${r.SPLOTCH_TEXELS}.0, (i + 0.5) / ${r.MAX_SPLOTCHES}.0));\n}\n// Signed distance-like measure to splotch i's outline, negative inside \u2014 the\n// same outline as sdAt in membrane-invasion.ts (upward reach multiplied by\n// its rise, then a stretch along its axis and 2-, 3- and 5-lobed bulges),\n// plus the shared noise dithering. row: its scheme.\nfloat splotchSD(float i, vec2 p, float dither, out float row) {\n vec4 a = splotchTexel(i, 0.0); // x, y, r, scheme row\n row = a.w;\n vec2 q = p - a.xy;\n if (a.z <= 0.0) return 10.0;\n float rise = splotchTexel(i, 3.0).x;\n if (q.y < 0.0) q.y /= rise; // y is down: upward, the outline reaches farther\n if (length(q) > a.z * 2.5 + 0.1) return 10.0; // nowhere near: skip the rest\n vec4 b = splotchTexel(i, 1.0); // angle, aspect, a2, a3\n vec4 c = splotchTexel(i, 2.0); // a5, p2, p3, p5\n float cs = cos(b.x), sn = sin(b.x);\n vec2 l = vec2(cs * q.x + sn * q.y, -sn * q.x + cs * q.y);\n float k = sqrt(b.y);\n float th = atan(l.y, l.x + 1e-6);\n float bulge = 1.0 + b.z * cos(2.0 * th + c.y) + b.w * cos(3.0 * th + c.z) + c.x * cos(5.0 * th + c.w);\n return length(vec2(l.x / k, l.y * k)) - a.z * bulge + dither * 0.16 * min(1.0, a.z * 5.0);\n}\nfloat dithering(vec2 p) { return fbm(vec3(p * 3.5 + 30.0, u_clock * 0.15)) - 0.5; }\n\n// Lightness is the thin film's banding; hue is the scheme's. The terrain,\n// then each splotch over it in order, newest on top. Chroma is cut\n// back only as far as sRGB needs at that lightness, so the palest and darkest\n// bands keep their hue instead of clipping to white or black.\nvec3 paint(float d, vec2 p, float dither) {\n float L;\n vec2 ab;\n terrain(p, d, L, ab);\n for (int i = 0; i < ${r.MAX_SPLOTCHES}; i++) {\n if (float(i) >= u_splotchCount) break;\n float row;\n float claim = 1.0 - smoothstep(-0.012, 0.012, splotchSD(float(i), p, dither, row));\n if (claim > 0.0) { L = mix(L, banding(row, d), claim); ab = mix(ab, anchorAB(row, d), claim); }\n }\n float C = length(ab);\n // The band no scheme may use (BAND_FADE_DEG, membrane-palette.ts): what a\n // turn between anchors on either side of it still passes through is shown\n // neutral, at the banding's lightness, rather than as mustard or olive.\n if (C > 1e-4) { // below that, hue is noise (and atan(0, 0) is undefined)\n float hd = mod(degrees(atan(ab.y, ab.x)), 360.0);\n float fade = smoothstep(${o.BAND_FADE_DEG[0].toFixed(1)}, ${o.BAND_FADE_DEG[1].toFixed(1)}, hd)\n * (1.0 - smoothstep(${o.BAND_FADE_DEG[2].toFixed(1)}, ${o.BAND_FADE_DEG[3].toFixed(1)}, hd));\n ab *= 1.0 - fade;\n C = length(ab);\n }\n vec2 dir = C > 1e-5 ? ab / C : vec2(1.0, 0.0);\n float lo = C;\n if (!inGamut(oklabToLinear(vec3(L, ab)))) {\n float hi = C; lo = 0.0;\n for (int k = 0; k < 8; k++) {\n float mid = 0.5 * (lo + hi);\n if (inGamut(oklabToLinear(vec3(L, dir * mid)))) lo = mid; else hi = mid;\n }\n }\n vec3 lin = clamp(oklabToLinear(vec3(L, dir * lo)), 0.0, 1.0);\n return mix(12.92 * lin, 1.055 * pow(lin, vec3(1.0 / 2.4)) - 0.055, step(0.0031308, lin));\n}\n\n// A slowly draining soap film: the swirl as merged in #464, carried by the\n// integrated drift (u_offset; lifting, the structure forms below and\n// dissolves above) and colored by the terrain and any splotches (paint).\nvec3 film(vec2 p, float c) {\n vec2 q = p * ${n.NOISE_SCALE.toFixed(2)} + u_offset;\n float d = fbm(vec3(q, c * 0.06));\n d += 0.35 * fbm(vec3(q * 2.7 + 10.0, c * 0.09 + 5.0));\n d += 0.30 * (p.y + 0.5); // thinner toward the top, as a real film drains\n // Where a splotch's front is, the film is disturbed: a thin seam of\n // shifted thickness marks the line being fought over. The edge itself is\n // crisp \u2014 the struggle is in its shape and its motion, not in a blur.\n //\n // The seam follows the nearest *visible* front, which is not the nearest\n // outline. Splotches composite oldest first, so walking them in order: one\n // that covers this point is the paint here and hides every older front\n // beneath it; an older front outside it stays a candidate; and a front is\n // no front where the paint on both sides is the same scheme \u2014 a sibling of\n // its own group already covers the point \u2014 so a group's union grows no\n // seams inside it (its inside distance is to the farthest covering\n // sibling's outline). A signed min over every outline got the one case\n // that matters most wrong: a tap landing inside an expanding wash sat deep\n // inside the wash's outline, and its own front, at distance zero, lost the\n // min to the wash's \u22120.3 and drew no seam until the wash was adopted, when\n // the seam appeared all at once (claude-m1ofa51d:16).\n float dither = 0.0, in2 = 100.0, out2 = 100.0, row;\n float over = -1.0; // scheme row of the paint at p; -1 is the terrain\n if (u_splotchCount > 0.5) {\n dither = dithering(p);\n for (int i = 0; i < ${r.MAX_SPLOTCHES}; i++) {\n if (float(i) >= u_splotchCount) break;\n float sd = splotchSD(float(i), p, dither, row);\n if (sd >= 10.0) continue; // nowhere near\n if (sd < 0.0) {\n if (over != row) { in2 = sd * sd; out2 = 100.0; } // new paint on top: older fronts are hidden\n else in2 = max(in2, sd * sd); // a sibling: the union reaches farther\n over = row;\n } else if (over != row) {\n out2 = min(out2, sd * sd);\n }\n }\n }\n d += 0.12 * exp(-min(in2, out2) / 0.0004);\n vec3 col = paint(d, p, dither);\n vec2 lightAt = vec2(-0.22, -0.28);\n float sheen = pow(max(0.0, 1.0 - length(p - lightAt) * 1.5), 2.2);\n col = mix(col, vec3(1.0), sheen * 0.30);\n col *= 0.88 + 0.12 * fbm(vec3(q * 3.0, c * 0.2 + 20.0));\n return col;\n}\n\nvoid main() {\n vec2 frag = vec2(gl_FragCoord.x, u_res.y - gl_FragCoord.y);\n vec2 gs = u_glyph.zw;\n vec2 gc = u_glyph.xy + gs * 0.5;\n vec2 muv = (frag - u_glyph.xy) / gs;\n float m = 0.0;\n if (muv.x >= 0.0 && muv.x <= 1.0 && muv.y >= 0.0 && muv.y <= 1.0) m = texture2D(u_mask, muv).a;\n if (m <= 0.001) { gl_FragColor = vec4(u_bg, 1.0); return; }\n // Glyph-normalized coordinates: the glyph spans -0.5..0.5.\n vec2 p = (frag - gc) / gs.x;\n gl_FragColor = vec4(mix(u_bg, film(p, u_phase), m), 1.0);\n}\n`,f=[60,90],u=.06;function p(e,n=64){const o=document.createElement("canvas");o.width=o.height=n;const i=o.getContext("2d");if(!i)return[[0,0]];i.setTransform(n/t.MO_GLYPH_BOX,0,0,n/t.MO_GLYPH_BOX,0,0),i.fillStyle="#fff",i.fill(e);const r=i.getImageData(0,0,n,n).data,a=[];for(let e=0;e<n;e++)for(let t=0;t<n;t++)r[4*(e*n+t)+3]>0&&a.push([(t+.5)/n-.5,(e+.5)/n-.5]);return a.length?a:[[0,0]]}let v=null;function g(e){const t=parseInt(e.slice(1),16);return[(t>>16&255)/255,(t>>8&255)/255,(255&t)/255]}function w(e,a,w){const E=e.getContext("webgl",{antialias:!1,alpha:!1,premultipliedAlpha:!1});if(!E)return null;const _=E;if(!_.getExtension("OES_texture_float"))return null;const b=(e,t)=>{const n=_.createShader(e);return n?(_.shaderSource(n,t),_.compileShader(n),_.getShaderParameter(n,_.COMPILE_STATUS)?n:(console.warn("Membrane shader:",_.getShaderInfoLog(n)),null)):null},x=b(_.VERTEX_SHADER,c),T=b(_.FRAGMENT_SHADER,h),y=_.createProgram();if(!x||!T||!y)return null;if(_.attachShader(y,x),_.attachShader(y,T),_.linkProgram(y),!_.getProgramParameter(y,_.LINK_STATUS))return console.warn("Membrane link:",_.getProgramInfoLog(y)),null;_.useProgram(y);const L=_.createBuffer();_.bindBuffer(_.ARRAY_BUFFER,L),_.bufferData(_.ARRAY_BUFFER,new Float32Array([-1,-1,1,-1,-1,1,1,1]),_.STATIC_DRAW);const R=_.getAttribLocation(y,"a_pos");_.enableVertexAttribArray(R),_.vertexAttribPointer(R,2,_.FLOAT,!1,0,0);const A=e=>_.getUniformLocation(y,e),S=A("u_res"),P=A("u_glyph"),k=A("u_offset"),M=A("u_phase"),C=A("u_clock"),D=A("u_splotchCount"),O=A("u_drag"),X=A("u_cell0");function I(e,t,n,o){const i=_.createTexture();_.activeTexture(_.TEXTURE0+e),_.bindTexture(_.TEXTURE_2D,i);for(const[e,t]of[[_.TEXTURE_WRAP_S,_.CLAMP_TO_EDGE],[_.TEXTURE_WRAP_T,_.CLAMP_TO_EDGE],[_.TEXTURE_MIN_FILTER,_.NEAREST],[_.TEXTURE_MAG_FILTER,_.NEAREST]])_.texParameteri(_.TEXTURE_2D,e,t);_.uniform1i(A(t),e);const r=new Float32Array(n*o*4);return{tex:i,data:r,upload(){_.activeTexture(_.TEXTURE0+e),_.bindTexture(_.TEXTURE_2D,i),_.texImage2D(_.TEXTURE_2D,0,_.RGBA,n,o,0,_.RGBA,_.FLOAT,r)}}}const F=I(1,"u_schemes",i.TERRAIN_TEXELS,l),B=I(2,"u_splotchTable",r.SPLOTCH_TEXELS,r.MAX_SPLOTCHES),U=()=>f[0]+(f[1]-f[0])*Math.random(),G=v??={terrain:(0,i.createTerrain)(Math.floor(2147483648*Math.random())),drag:[0,0],film:(0,r.emptyFilm)(),schemes:new Map,rows:new Map,motion:(0,n.initialMotionState)(w),t0:performance.now(),holdUntil:U(),frozenAt:0};function j(e,t){F.data.set((0,o.packScheme)(t),e*i.TERRAIN_TEXELS*4),F.upload()}function H(e){const t=new Set(G.rows.values());let n=i.TERRAIN_ROWS;for(;t.has(n);)n++;G.rows.set(e.id,n);const r=(0,o.nextScheme)((0,i.schemesInView)(G.terrain,G.drag),Math.random);G.schemes.set(e.id,r),j(n,r)}let N=null,z=!0;function q(){const e=(0,i.centreCell)(G.drag);!z&&N&&e[0]===N[0]&&e[1]===N[1]||((0,i.blockRows)(G.terrain,G.drag).forEach((e,t)=>F.data.set((0,i.packCell)(e),t*i.TERRAIN_TEXELS*4)),F.upload(),_.uniform2f(X,e[0],e[1]),N=e,z=!1)}function Y(e){(0,i.paintCells)(G.terrain,(0,i.cellsInView)(G.terrain,G.drag),e),z=!0}function $(){const e=new Set(G.film.groups.map(e=>e.id));for(const t of[...G.rows.keys()])e.has(t)||(G.rows.delete(t),G.schemes.delete(t))}const W=p(new Path2D(t.MO_GLYPH_PATH));for(const[e,t]of G.rows){const n=G.schemes.get(e);n&&j(t,n)}const K=(e,t)=>{const n=G.schemes.get(e.id),i=G.schemes.get(t.id);return!!n&&!!i&&(0,o.schemeDistance)(n,i)<u};function V(e,t){if(ce.matches)return void Y((0,o.nextScheme)((0,i.schemesInView)(G.terrain,G.drag),Math.random));const n=(0,r.tap)(G.film,e,t,Math.random);if(G.film=n.film,n.started&&H(n.started),n.recolored){const e=G.rows.get(n.recolored.id),t=G.schemes.get(n.recolored.id)??null;if(void 0!==e){const i=(0,o.nextScheme)(t,Math.random);G.schemes.set(n.recolored.id,i),j(e,i)}}$()}let Q=w;let J=!1;function Z(e){J=e}function ee(e,t){G.motion=(0,n.dragMotion)(G.motion,e,t),G.film=(0,r.shift)(G.film,e,t),G.drag=[G.drag[0]+e,G.drag[1]+t]}const[te,ne,oe]=g(s);_.uniform3f(A("u_bg"),te,ne,oe),_.uniform1i(A("u_mask"),0);const ie=_.createTexture();_.activeTexture(_.TEXTURE0),_.bindTexture(_.TEXTURE_2D,ie),_.texParameteri(_.TEXTURE_2D,_.TEXTURE_WRAP_S,_.CLAMP_TO_EDGE),_.texParameteri(_.TEXTURE_2D,_.TEXTURE_WRAP_T,_.CLAMP_TO_EDGE),_.texParameteri(_.TEXTURE_2D,_.TEXTURE_MIN_FILTER,_.LINEAR),_.texParameteri(_.TEXTURE_2D,_.TEXTURE_MAG_FILTER,_.LINEAR),_.pixelStorei(_.UNPACK_FLIP_Y_WEBGL,!1),_.pixelStorei(_.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1);const re=document.createElement("canvas"),ae=new Path2D(t.MO_GLYPH_PATH);function se(e){const n=Math.max(2,Math.round(e));re.width=n,re.height=n;const o=re.getContext("2d");o&&(o.clearRect(0,0,n,n),o.setTransform(n/t.MO_GLYPH_BOX,0,0,n/t.MO_GLYPH_BOX,0,0),o.fillStyle="#fff",o.fill(ae),_.activeTexture(_.TEXTURE0),_.bindTexture(_.TEXTURE_2D,ie),_.texImage2D(_.TEXTURE_2D,0,_.RGBA,_.RGBA,_.UNSIGNED_BYTE,re))}function le(){const t=window.visualViewport?.scale??1,n=Math.min(5,(window.devicePixelRatio||1)*t),o=a.getBoundingClientRect(),i=Math.max(1,Math.round(o.width*n)),r=Math.max(1,Math.round(o.height*n));e.width===i&&e.height===r||(e.width=i,e.height=r),_.viewport(0,0,i,r),_.uniform2f(S,i,r);const s=Math.min(i,r);_.uniform4f(P,(i-s)/2,(r-s)/2,s,s),se(s)}const ce=window.matchMedia("(prefers-reduced-motion: reduce)");let he=0,de=0,fe=!1;function ue(e){if(de=0,!fe)return;const t=he?(e-he)/1e3:0;he=e;let o=(e-G.t0)/1e3;if(ce.matches)o=G.frozenAt;else{if(G.frozenAt=o,G.motion=(0,n.stepMotion)(G.motion,Q,t,J),(0,r.autoDue)(G.film,G.holdUntil,o)){const[e,t]=W[Math.floor(Math.random()*W.length)],n=(0,r.invade)(G.film,e,t,Math.random);n&&(G.film=n.film,H(n.started)),G.holdUntil=o+U()}G.film=(0,r.step)(G.film,t,K);const e=G.film.groups.find(e=>(0,r.washing)(e,G.film.clock)&&(0,r.covers)(G.film,e.id,W));if(e){const t=G.schemes.get(e.id);t&&Y(t),G.film=(0,r.adopt)(G.film,e.id),G.holdUntil=o+U()}$()}_.uniform2f(k,G.motion.offset[0],G.motion.offset[1]),_.uniform1f(M,G.motion.phase),_.uniform2f(O,G.drag[0],G.drag[1]),q(),B.data.set((0,r.packSplotches)(G.film,e=>G.rows.get(e)??0)),B.upload(),_.uniform1f(D,Math.min(G.film.splotches.length,r.MAX_SPLOTCHES)),_.uniform1f(C,G.film.clock),_.drawArrays(_.TRIANGLE_STRIP,0,4),de=requestAnimationFrame(ue)}function me(){fe=!1,de&&(cancelAnimationFrame(de),de=0)}let pe=!0;const ve=()=>{!document.hidden&&pe?fe||(fe=!0,he=0,de||(de=requestAnimationFrame(ue))):me()},ge=ve;document.addEventListener("visibilitychange",ge);const we="function"==typeof IntersectionObserver?new IntersectionObserver(e=>{pe=e.some(e=>e.isIntersecting),ve()},{threshold:0}):null;we?.observe(a);let Ee=null;const be=(e,t)=>{const n=a.getBoundingClientRect();return[(e-n.left)/n.width-.5,(t-n.top)/n.height-.5]},xe=()=>{if(Ee){Z(!1);try{a.releasePointerCapture(Ee.id)}catch{}Ee=null}},Te=e=>{if(!Ee&&e.isPrimary&&("mouse"!==e.pointerType||0===e.button)){Ee={id:e.pointerId,at:performance.now(),x:e.clientX,y:e.clientY,startX:e.clientX,startY:e.clientY,moved:!1},Z(!0);try{a.setPointerCapture(e.pointerId)}catch{}}},ye=e=>{if(!Ee||e.pointerId!==Ee.id)return;if("touch"!==e.pointerType&&0===e.buttons)return void xe();if(!Ee.moved){if(Math.hypot(e.clientX-Ee.startX,e.clientY-Ee.startY)<=8)return;Ee.moved=!0,Ee.x=Ee.startX,Ee.y=Ee.startY}const t=a.getBoundingClientRect();ee((e.clientX-Ee.x)/t.width,(e.clientY-Ee.y)/t.height),Ee.x=e.clientX,Ee.y=e.clientY},Le=e=>{if(!Ee||e.pointerId!==Ee.id)return;const t=!Ee.moved&&performance.now()-Ee.at<250;xe(),t&&V(...be(e.clientX,e.clientY))},Re=e=>{Ee&&e.pointerId===Ee.id&&xe()},Ae=()=>xe(),Se=()=>{document.hidden&&xe()},Pe=e=>{Ee&&e.preventDefault()},ke=e=>e.preventDefault();a.addEventListener("pointerdown",Te),a.addEventListener("pointermove",ye),a.addEventListener("pointerup",Le),a.addEventListener("pointercancel",Re),a.addEventListener("lostpointercapture",Re),window.addEventListener("pointerup",Le),window.addEventListener("pointercancel",Re),window.addEventListener("blur",Ae),document.addEventListener("visibilitychange",Se),a.addEventListener("touchmove",Pe,{passive:!1}),a.addEventListener("contextmenu",ke);let Me=0;const Ce=()=>{window.clearTimeout(Me),Me=window.setTimeout(le,60)},De=new ResizeObserver(Ce);return De.observe(a),window.visualViewport?.addEventListener("resize",Ce),le(),ve(),{touch:V,hold:Z,drag:ee,setMotion:function(e){Q=e},destroy(){me(),xe(),a.removeEventListener("pointerdown",Te),a.removeEventListener("pointermove",ye),a.removeEventListener("pointerup",Le),a.removeEventListener("pointercancel",Re),a.removeEventListener("lostpointercapture",Re),window.removeEventListener("pointerup",Le),window.removeEventListener("pointercancel",Re),window.removeEventListener("blur",Ae),document.removeEventListener("visibilitychange",Se),a.removeEventListener("touchmove",Pe),a.removeEventListener("contextmenu",ke),De.disconnect(),we?.disconnect(),window.visualViewport?.removeEventListener("resize",Ce),window.clearTimeout(Me),document.removeEventListener("visibilitychange",ge),_.deleteTexture(ie),_.deleteTexture(F.tex),_.deleteTexture(B.tex),_.deleteBuffer(L),_.deleteProgram(y),_.deleteShader(x),_.deleteShader(T),_.getExtension("WEBGL_lose_context")?.loseContext()}}}function E({voice:o,lift:i,sway:r,churn:l}){const c=(0,e.useRef)(null),h=(0,e.useRef)(null),f=(0,e.useRef)(null),[u,p]=(0,e.useState)(!0),v=(0,n.membraneMotion)(o,{lift:i,sway:r,churn:l}),g=(0,e.useRef)(v);g.current=v,(0,e.useEffect)(()=>{const e=c.current,t=h.current;if(!e||!t)return;let n=w(t,e,g.current);if(!n)return void p(!1);f.current=n;const o=e=>{e.preventDefault(),n?.destroy(),n=null,f.current=null},i=()=>{n=w(t,e,g.current),f.current=n};return t.addEventListener("webglcontextlost",o),t.addEventListener("webglcontextrestored",i),()=>{t.removeEventListener("webglcontextlost",o),t.removeEventListener("webglcontextrestored",i),n?.destroy(),f.current=null}},[]),(0,e.useEffect)(()=>{f.current?.setMotion(g.current)},[v.lift,v.sway,v.churn]);const E=(0,e.useCallback)(e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),f.current?.touch(0,0))},[]);return(0,a.jsx)("div",{ref:c,role:"button",tabIndex:0,"aria-label":"Change the colors",onKeyDown:E,style:{width:"min(60vw, 38vh, 360px)",aspectRatio:"1 / 1",maxWidth:"100%",position:"relative",cursor:"pointer",outline:"none",touchAction:"none",userSelect:"none",WebkitUserSelect:"none",WebkitTouchCallout:"none",WebkitTapHighlightColor:"transparent"},children:u?(0,a.jsx)("canvas",{ref:h,"aria-hidden":!0,style:{width:"100%",height:"100%",display:"block",background:s}}):(0,a.jsx)("svg",{viewBox:`0 0 ${t.MO_GLYPH_BOX} ${t.MO_GLYPH_BOX}`,width:"100%",height:"100%","aria-hidden":!0,children:(0,a.jsx)("path",{d:t.MO_GLYPH_PATH,fill:"#3a3a42"})})})}},983,[11,984,985,986,987,988,6]);
1087
+ __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MO_GLYPH_BOX",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"MO_GLYPH_PATH",{enumerable:!0,get:function(){return Q}});const L=1e3,Q="M493.98 449.69L493.98 425.61L791.54 425.61L791.54 449.69L493.98 449.69ZM493.98 557.19L493.98 533.11L791.54 533.11L791.54 557.19L493.98 557.19ZM431.20 606.21L431.20 319.83L431.20 275.11L431.20 275.11L547.30 319.83L780.36 319.83L780.36 343.91L543.00 343.91L543.00 571.81Q543.00 576.11 528.81 584.71Q514.62 593.31 492.26 599.76Q469.90 606.21 446.68 606.21L446.68 606.21L431.20 606.21ZM733.92 583.85L733.92 319.83L726.18 319.83L776.92 266.51L878.40 343.05Q875.82 346.49 869.37 350.79Q862.92 355.09 851.74 357.67L851.74 357.67L851.74 552.03Q851.74 555.47 835.83 563.21Q819.92 570.95 797.56 577.40Q775.20 583.85 754.56 583.85L754.56 583.85L733.92 583.85ZM400.24 674.15L393.36 650.07L757.14 650.07L812.18 578.69Q812.18 578.69 829.38 592.02Q846.58 605.35 869.80 624.27Q893.02 643.19 911.08 660.39L911.08 660.39Q907.64 674.15 887.00 674.15L887.00 674.15L400.24 674.15ZM675.44 656.95L685.76 653.51Q694.36 680.17 723.17 703.82Q751.98 727.47 799.28 745.10Q846.58 762.73 911.94 773.05L911.94 773.05L911.94 783.37Q867.22 795.41 844.86 821.64Q822.50 847.87 820.78 904.63L820.78 904.63Q785.52 887.43 760.15 858.19Q734.78 828.95 717.58 793.69Q700.38 758.43 690.06 722.74Q679.74 687.05 675.44 656.95L675.44 656.95ZM132.78 417.01L132.78 148.69L132.78 140.09L132.78 104.83L259.20 148.69L242.86 148.69L242.86 417.01Q242.86 475.49 239.85 539.56Q236.84 603.63 223.94 668.56Q211.04 733.49 180.94 794.12Q150.84 854.75 96.66 906.35L96.66 906.35L87.20 901.19Q111.28 829.81 120.74 748.54Q130.20 667.27 131.49 582.13Q132.78 496.99 132.78 417.01L132.78 417.01ZM184.38 172.77L184.38 148.69L342.62 148.69L342.62 172.77L184.38 172.77ZM184.38 371.43L184.38 347.35L342.62 347.35L342.62 371.43L184.38 371.43ZM184.38 573.53L184.38 549.45L342.62 549.45L342.62 573.53L184.38 573.53ZM284.14 767.89L284.14 148.69L275.54 148.69L325.42 92.79L426.90 171.91Q423.46 176.21 415.72 180.94Q407.98 185.67 395.94 188.25L395.94 188.25L395.94 779.93Q395.94 817.77 387.77 844.43Q379.60 871.09 352.51 886.57Q325.42 902.05 269.52 907.21L269.52 907.21Q268.66 879.69 266.08 859.05Q263.50 838.41 256.62 827.23L256.62 827.23Q250.60 814.33 239.42 805.30Q228.24 796.27 205.02 791.97L205.02 791.97L205.02 779.93Q205.02 779.93 213.19 780.36Q221.36 780.79 232.54 781.65Q243.72 782.51 254.04 782.94Q264.36 783.37 269.52 783.37L269.52 783.37Q278.98 783.37 281.56 779.07Q284.14 774.77 284.14 767.89L284.14 767.89ZM499.14 291.45L499.14 99.67L639.32 110.85Q638.46 118.59 632.87 124.18Q627.28 129.77 610.94 132.35L610.94 132.35L610.94 265.65Q610.94 269.09 596.32 275.54Q581.70 281.99 560.20 286.72Q538.70 291.45 516.34 291.45L516.34 291.45L499.14 291.45ZM661.68 291.45L661.68 99.67L801.86 110.85Q801.00 118.59 795.41 124.18Q789.82 129.77 774.34 132.35L774.34 132.35L774.34 265.65Q774.34 269.09 759.72 275.54Q745.10 281.99 723.17 286.72Q701.24 291.45 678.88 291.45L678.88 291.45L661.68 291.45ZM407.98 219.21L401.10 195.13L797.56 195.13L838.84 133.21Q838.84 133.21 851.74 145.25Q864.64 157.29 882.27 174.06Q899.90 190.83 912.80 205.45L912.80 205.45Q910.22 219.21 890.44 219.21L890.44 219.21L407.98 219.21ZM573.10 533.11L573.10 533.11L695.22 533.11Q692.64 582.99 686.19 628.57Q679.74 674.15 662.54 714.57Q645.34 754.99 611.37 789.82Q577.40 824.65 521.07 853.89Q464.74 883.13 379.60 906.35L379.60 906.35L372.72 895.17Q447.54 858.19 488.39 817.77Q529.24 777.35 546.87 732.20Q564.50 687.05 568.37 637.60Q572.24 588.15 573.10 533.11Z"},984,[]);
1088
+ __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MEMBRANE_MOTION",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"DEFAULT_MEMBRANE_VOICE",{enumerable:!0,get:function(){return n}}),e.membraneMotion=function(o=n,f={}){const u=t[o];return{lift:f.lift??u.lift,sway:f.sway??u.sway,churn:f.churn??u.churn}},Object.defineProperty(e,"MOTION_EASE_S",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"MOTION_MAX_DT_S",{enumerable:!0,get:function(){return f}}),e.initialMotionState=function(t){return{motion:Object.assign({},t),offset:[0,0],phase:0}},Object.defineProperty(e,"NOISE_SCALE",{enumerable:!0,get:function(){return u}}),e.stepMotion=function(t,n,u,c=!1){const s=Math.min(Math.max(u,0),f),l=1-Math.exp(-s/o),M=(t,n)=>t+(n-t)*l,O={lift:c?0:M(t.motion.lift,n.lift),sway:c?0:M(t.motion.sway,n.sway),churn:M(t.motion.churn,n.churn)};return{motion:O,offset:[t.offset[0]+O.sway*s,t.offset[1]+O.lift*s],phase:t.phase+O.churn*s}},e.dragMotion=function(t,n,o){return Object.assign({},t,{offset:[t.offset[0]-u*n,t.offset[1]-u*o]})};const t={awake:{lift:.07,sway:.012,churn:1},dormant:{lift:0,sway:.012,churn:.4}},n="awake";const o=.35,f=.1;const u=2.4},985,[]);
1089
+ __d(function(g,r,_i,_a,_m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MIN_ANCHORS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"MAX_ANCHORS",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"MIN_HUE_SEP_DEG",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"MIN_ANCHOR_DE",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"DISTINCT_AT_L",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"MIN_SCHEME_DISTANCE",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"EXCLUDED_HUE_DEG",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"BAND_FADE_DEG",{enumerable:!0,get:function(){return s}}),e.hueExcluded=i,e.bandFade=f,e.neutralizeBand=l,e.oklabToLinearSrgb=m,e.inSrgbGamut=M,e.fitToGamut=b,e.hueSeparationDeg=d,e.anchorsDistinct=E,Object.defineProperty(e,"SCHEME_FAMILIES",{enumerable:!0,get:function(){return O}}),e.sampleScheme=D,e.abAt=j,e.hueChromaAt=I,e.schemeDistance=C,e.nextScheme=function(t,n){const o=null===t?[]:Array.isArray(t)?t:[t];for(let t=0;t<200;t++){const t=D(n);if(o.every(n=>C(t,n)>=a))return t}return D(n)},Object.defineProperty(e,"SCHEME_TEXELS",{enumerable:!0,get:function(){return N}}),e.packScheme=function(t){const n=new Float32Array(20);return n.set([t.hues.length,...t.hue,...t.light]),n.set(H(t),8),n},e.packAnchors=H;const t=3,n=5,o=28,u=.09,c=[.5,.65,.8],a=.12,h=[60,130],s=[60,75,115,130];function i(t){return t>=h[0]&&t<=h[1]}function f(t){const[n,o,u,c]=s;return p(n,o,t)*(1-p(u,c,t))}function l(t,n){const o=1-f((180*Math.atan2(n,t)/Math.PI+360)%360);return[t*o,n*o]}function m(t,n,o){const u=t+.3963377774*n+.2158037573*o,c=t-.1055613458*n-.0638541728*o,a=t-.0894841775*n-1.291485548*o,h=u*u*u,s=c*c*c,i=a*a*a;return[4.0767416621*h-3.3077115913*s+.2309699292*i,-1.2684380046*h+2.6097574011*s-.3413193965*i,-.0041960863*h-.7034186147*s+1.707614701*i]}function M(t,n,o){return m(t,n,o).every(t=>t>=-1e-4&&t<=1.0001)}function b(t,n,o){const u=n=>[t,n*Math.cos(o),n*Math.sin(o)];if(M(...u(n)))return u(n);let c=0,a=n;for(let t=0;t<20;t++){const t=(c+a)/2;M(...u(t))?c=t:a=t}return u(c)}const y=Math.PI/180,p=(t,n,o)=>{const u=Math.min(1,Math.max(0,(o-t)/(n-t)));return u*u*(3-2*u)};function d(t,n){const o=Math.abs(((t-n)%360+360)%360);return Math.min(o,360-o)}function E(t){for(let n=0;n<t.length;n++)for(let a=n+1;a<t.length;a++){if(d(t[n],t[a])<o)return!1;for(const o of c){const[,c,h]=b(o,.3,t[n]*y),[,s,i]=b(o,.3,t[a]*y);if(Math.hypot(c-s,h-i)<u)return!1}}return!0}const _=(t,n,o)=>n+(o-n)*t(),A=(t,n)=>n[Math.floor(t()*n.length)],S={analogous:(t,n)=>{const o=A(n,[3,4]),u=_(n,30,45);return Array.from({length:o},(n,c)=>t+u*(c-(o-1)/2))},complementary:(t,n)=>{const o=_(n,35,60);return A(n,[[t,t+180,t+o],[t,t+180,t+180+o],[t,t+o,t+180,t+180+o]])},split:(t,n)=>{const o=_(n,25,45);return[t,t+180-o,t+180+o]},triadic:t=>[t,t+120,t+240],tetradic:(t,n)=>{const o=A(n,[60,90]);return[t,t+o,t+180,t+180+o]},accent:(t,n)=>{const o=_(n,30,45);return[t,t+o,t+A(n,[150,180,210])+o/2]},wild:(t,n)=>Array.from({length:A(n,[3,4,5])},()=>_(n,0,360))},O=Object.keys(S);function P(t,n){for(let o=t.length-1;o>0;o--){const u=Math.floor(n()*(o+1));[t[o],t[u]]=[t[u],t[o]]}return t}function D(o){let u,c;do{u=A(o,O),c=S[u](_(o,0,360),o).map(t=>((t+_(o,-8,8))%360+360)%360)}while(c.length<t||c.length>n||c.some(i)||!E(c));const a=P(c,o).map(t=>t*y);return{family:u,hues:a,chromas:a.map(()=>_(o,.15,.32)),light:[_(o,2.4,3.7),o(),_(o,.62,.68),_(o,.27,.32)],hue:[_(o,1,1.5),o(),_(o,.18,.45)]}}function j(t,n,o=t.hue[2]){const u=t.hues.length,c=(n%1+1)%1*u,a=Math.floor(c)%u,h=(a+1)%u,s=p(.5-o,.5+o,c-Math.floor(c)),i=t.chromas[a]*Math.cos(t.hues[a]),f=t.chromas[a]*Math.sin(t.hues[a]);return l(i+(t.chromas[h]*Math.cos(t.hues[h])-i)*s,f+(t.chromas[h]*Math.sin(t.hues[h])-f)*s)}function I(t,n,o=t.hue[2]){const[u,c]=j(t,n,o);return[Math.atan2(c,u),Math.hypot(u,c)]}function C(t,n){let o=0;for(let u=0;u<32;u++){const[c,a]=I(t,u/32,.5),[h,s]=I(n,u/32,.5);o+=Math.hypot(a*Math.cos(c)-s*Math.cos(h),a*Math.sin(c)-s*Math.sin(h))}return o/32}const N=5;function H(t){const o=new Float32Array(12);for(let u=0;u<=n;u++){const n=u%t.hues.length;o[2*u]=t.hues[n],o[2*u+1]=t.chromas[n]}return o}},986,[]);
1090
+ __d(function(g,_r,_i,_a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"CELL",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"JITTER",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"SEAM",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"WARP",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"WARP_FREQ",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"BLOCK",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"TERRAIN_ROWS",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"TERRAIN_TEXELS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"VIEW_MARGIN",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"createTerrain",{enumerable:!0,get:function(){return a}}),e.seededRng=b,e.cellRng=p,Object.defineProperty(e,"cellAt",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"toWorld",{enumerable:!0,get:function(){return E}}),e.centreCell=y,e.cell=P,Object.defineProperty(e,"cellScheme",{enumerable:!0,get:function(){return j}}),e.blend=R,e.blockCells=S,e.blockRows=function(t,n){return S(y(n)).map(([n,r])=>P(t,n,r))},e.cellsInView=C,e.schemesInView=function(t,n){return C(t,n).map(([n,r])=>j(t,n,r))},e.paintCells=function(t,n,r){for(const[c,o]of n)t.cells.set(h(c,o),{seed:P(t,c,o).seed,scheme:r})},e.packCell=function(n){const r=new Float32Array(4*s);return r.set((0,t.packScheme)(n.scheme)),r.set([n.seed[0],n.seed[1],0,0],4*t.SCHEME_TEXELS),r};var t=_r(d[0]);const n=.75,r=.35,c=.25,o=.14,u=1.5,l=5,i=25,s=t.SCHEME_TEXELS+1,f=.21000000000000002,a=t=>({seed:t,cells:new Map}),h=(t,n)=>`${t},${n}`;function b(t){let n=0|t;return()=>{n=n+1831565813|0;let t=Math.imul(n^n>>>15,1|n);return t=t+Math.imul(t^t>>>7,61|t)^t,((t^t>>>14)>>>0)/4294967296}}function p(t,n,r){let c=(0|t)^Math.imul(0|n,2654435761)^Math.imul(0|r,2246822519);return c=Math.imul(c^c>>>16,2146121005),c=Math.imul(c^c>>>15,2221713035),b(c^c>>>16)}const M=t=>Math.floor(t/n),E=(t,n)=>t-n;function y(t){return[M(E(0,t[0])),M(E(0,t[1]))]}const O=[[-1,-1],[0,-1],[1,-1],[-1,0],[1,0],[-1,1],[0,1],[1,1]];function P(c,o,u){const l=h(o,u),i=c.cells.get(l);if(i)return i;const s=p(c.seed,o,u),f=[(o+.5+(2*s()-1)*r)*n,(u+.5+(2*s()-1)*r)*n],a=O.map(([t,n])=>c.cells.get(h(o+t,u+n))?.scheme).filter(t=>!!t),b={seed:f,scheme:(0,t.nextScheme)(a,s)};return c.cells.set(l,b),b}const j=(t,n,r)=>P(t,n,r).scheme,w=t=>{const n=Math.min(1,Math.max(0,t/c));return 1-n*n*(3-2*n)};function R(t,n){const r=M(n[0]),c=M(n[1]),o=[];for(let u=-1;u<=1;u++)for(let l=-1;l<=1;l++){const i=P(t,r+l,c+u).seed;o.push({cell:[r+l,c+u],d:Math.hypot(n[0]-i[0],n[1]-i[1])})}const u=Math.min(...o.map(t=>t.d)),l=o.map(t=>({cell:t.cell,weight:w(t.d-u)})).filter(t=>t.weight>0),i=l.reduce((t,n)=>t+n.weight,0);return l.map(t=>({cell:t.cell,weight:t.weight/i})).sort((t,n)=>n.weight-t.weight)}function S(t){const n=[];for(let r=-2;r<=2;r++)for(let c=-2;c<=2;c++)n.push([t[0]+c,t[1]+r]);return n}const _=32;function A(t){const n=[];for(let r=0;r<=_;r++)for(let c=0;c<=_;c++)n.push([E(1.42*c/_-.71,t[0]),E(1.42*r/_-.71,t[1])]);return n}function C(t,n){const r=new Map;for(const c of A(n))for(const{cell:n}of R(t,c))r.set(h(...n),n);return[...r.values()].sort((t,n)=>t[1]-n[1]||t[0]-n[0])}},987,[986]);
1091
+ __d(function(_g,_r,_i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"TAP_RADIUS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"MAX_SPLOTCH_RADIUS",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"BURST_S",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"TAP_EDGE",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"PRESSURE_PER_TAP",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"PRESSURE_DRAIN_S",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"CRITICAL_PRESSURE",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"PRESSURE_SPAN",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"MAX_SPEED",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"RECLAIM",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"WOBBLE",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"ASPECT",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"LOBE_MAX",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"WASH_DELAY_S",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"WASH_SPEED",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"RISE",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"RISE_IN_S",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"COVER_MARGIN",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"MAX_SPLOTCHES",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"SPLOTCH_TEXELS",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"emptyFilm",{enumerable:!0,get:function(){return S}}),e.randomShape=A,e.sdAt=_,e.reach=I,e.touching=R,e.tap=function(r,o,u,a){const c=new Map(r.groups.map(t=>[t.id,t])),i=C(r).filter(t=>!k(c.get(t.group),r.clock)),p=i.filter(t=>_(t,o,u)<=-.02).at(-1);if(p){const t=r.groups.map(t=>t.id===p.group?Object.assign({},t,{lastTap:r.clock}):t);return{film:Object.assign({},r,{groups:t}),started:null,recolored:t.find(t=>t.id===p.group)}}const l={x:o,y:u,r:t,phase:0,group:0,shape:j,anchoredAt:null,rise:1},h=i.filter(t=>R(l,t)).at(-1),f=h?c.get(h.group):null,g=r.groups.filter(t=>!t.auto&&!k(t,r.clock)).reduce((t,r)=>!t||r.lastTap>t.lastTap?r:t,null),d=f??(g&&r.clock-g.lastTap<=n?g:null),b=d?null:{id:r.nextId,pressure:0,born:r.clock,lastTap:r.clock,auto:!1,washAt:null},y=(d??b).id,M=(b?[...r.groups,b]:r.groups).map(t=>t.id===y?Object.assign({},t,{pressure:t.pressure+s,lastTap:r.clock}):t),P=Object.assign({},l,{phase:1e3*a(),group:y,shape:A(a)}),O=[...T(r.splotches),P],S=new Set(O.map(t=>t.group));return{film:Object.assign({},r,{groups:M.filter(t=>S.has(t.id)),splotches:O,nextId:b?r.nextId+1:r.nextId}),started:b?M.find(t=>t.id===y):null,recolored:null}},e.shift=function(t,r,n){return 0===r&&0===n?t:Object.assign({},t,{splotches:t.splotches.map(t=>Object.assign({},t,{x:t.x+r,y:t.y+n}))})},e.invade=function(t,r,n,o){if(t.groups.some(t=>t.auto))return null;const s={id:t.nextId,pressure:0,born:t.clock,lastTap:t.clock,auto:!0,washAt:t.clock},u={x:r,y:n,r:.005,phase:1e3*o(),group:s.id,shape:j,anchoredAt:null,rise:1},a=[...T(t.splotches),u],c=new Set(a.map(t=>t.group));return{film:Object.assign({},t,{groups:[...t.groups,s].filter(t=>c.has(t.id)),splotches:a,nextId:t.nextId+1}),started:s}},e.autoDue=function(t,r,n){return n>=r&&!t.groups.some(t=>t.auto)},e.washing=k,e.frontSpeed=L,e.step=function(t,n,o=()=>!1){const s=Math.max(0,Math.min(n,.1)),a=t.clock+s,c=new Map(t.groups.map(t=>[t.id,t])),i=(t,r)=>{const n=c.get(t.group),s=c.get(r.group);return!n.auto&&!s.auto&&(n.id===s.id||o(n,s))},p=new Set(t.splotches.filter(r=>null!==r.anchoredAt||t.splotches.some(t=>t!==r&&i(r,t)&&R(r,t)))),l=t.groups.map(r=>{const n=null===r.washAt&&t.splotches.some(t=>t.group===r.id&&p.has(t));return Object.assign({},r,{washAt:n?a+g:r.washAt,pressure:r.pressure*Math.exp(-s/u)})}),h=new Map(l.map(t=>[t.id,t])),f=t.splotches.map(t=>{const n=h.get(t.group),o=k(n,a),u=p.has(t),c=o?d:L(n.pressure);let i=t.r+(c+.03*w(.5*a+t.phase))*s;o||(i=Math.min(r,i)),(u||o)&&(i=Math.max(t.r,i));const l=o?Math.min(b,t.rise+2*s/y):t.rise;return Object.assign({},t,{r:Math.max(0,i),anchoredAt:u?i:null,rise:l})}).filter(t=>t.r>0),M=new Set(f.map(t=>t.group));return Object.assign({},t,{clock:a,groups:l.filter(t=>M.has(t.id)),splotches:f})},e.covers=function(t,r,n,o=M){const s=t.splotches.filter(t=>t.group===r);return s.length>0&&n.every(([t,r])=>s.some(n=>_(n,t,r)<=-o))},e.adopt=function(t,r){const n=t.groups.find(t=>t.id===r);if(!n)return t;const o=new Set(t.groups.filter(t=>t.id!==r&&t.born>n.born).map(t=>t.id));return Object.assign({},t,{splotches:t.splotches.filter(t=>o.has(t.group)),groups:t.groups.filter(t=>o.has(t.id))})},e.packSplotches=function(t,r){const n=new Float32Array(1024);return C(t).slice(0,P).forEach((t,o)=>{const{angle:s,aspect:u,lobes:[a,c,i],phases:[p,l,h]}=t.shape;n.set([t.x,t.y,t.r,r(t.group),s,u,a,c,i,p,l,h,t.rise,0,0,0],o*O*4)}),n};const t=.09,r=.22,n=2.5,o=.02,s=1,u=30,a=.8,c=1.5,i=.032,p=.35,l=.015,h=[1.2,2.4],f=[.25,.2,.12],g=2,d=.05,b=3,y=2,M=.1,P=64,O=4,S=()=>({splotches:[],groups:[],clock:0,nextId:1}),j={angle:0,aspect:1,lobes:[0,0,0],phases:[0,0,0]};function A(t){return{angle:t()*Math.PI,aspect:(r=h[0],n=h[1],r+(n-r)*t()),lobes:[t()*f[0],t()*f[1],t()*f[2]],phases:[t()*Math.PI*2,t()*Math.PI*2,t()*Math.PI*2]};var r,n}function x(t,r){const[n,o,s]=t.lobes,[u,a,c]=t.phases;return 1+n*Math.cos(2*r+u)+o*Math.cos(3*r+a)+s*Math.cos(5*r+c)}function E(t,r,n){const o=r-t.x,s=n-t.y,u=s<0?s/t.rise:s,a=Math.cos(t.shape.angle),c=Math.sin(t.shape.angle);return[a*o+c*u,-c*o+a*u]}function _(t,r,n){const[o,s]=E(t,r,n),u=Math.sqrt(t.shape.aspect);return Math.hypot(o/u,s*u)-t.r*x(t.shape,Math.atan2(s,o))}function I(t,r,n){const o=Math.hypot(r-t.x,n-t.y);if(0===o)return 0;const s=t.x+(r-t.x)/o,u=t.y+(n-t.y)/o,[a,c]=E(t,s,u),i=Math.sqrt(t.shape.aspect),p=Math.hypot(a/i,c*i);return Math.max(0,t.r*x(t.shape,Math.atan2(c,a))/p)}function R(t,r){return t.r>0&&r.r>0&&Math.hypot(t.x-r.x,t.y-r.y)<I(t,r.x,r.y)+I(r,t.x,t.y)}function w(t){const r=Math.floor(t),n=t-r,o=t=>{const r=43758.5453*Math.sin(127.1*t+311.7);return 2*(r-Math.floor(r))-1},s=n*n*n*(n*(6*n-15)+10);return o(r)*n*(1-s)+o(r+1)*(n-1)*s}function T(t){if(t.length<P)return t;const r=(t.some(t=>null===t.anchoredAt)?t.filter(t=>null===t.anchoredAt):t).reduce((t,r)=>r.r<t.r?r:t);return t.filter(t=>t!==r)}function k(t,r){return null!==t.washAt&&r>=t.washAt}function L(t){const r=Math.max(-1,Math.min(1,(t-a)/c));return i*(r>=0?r:r*p)}function C(t){const r=new Map(t.groups.map(t=>[t.id,t.born]));return t.splotches.map((t,n)=>({s:t,i:n,b:r.get(t.group)??0})).sort((t,r)=>t.b-r.b||t.i-r.i).map(({s:t})=>t)}},988,[]);
1092
+ __d(function(g,r,i,_a,m,_e,_d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"default",{enumerable:!0,get:function(){return k}});var t=r(_d[0]),n=e(r(_d[1])),o=e(r(_d[2])),a=e(r(_d[3])),l=e(r(_d[4])),d=e(r(_d[5])),s=e(r(_d[6])),c=e(r(_d[7])),u=r(_d[8]),f=r(_d[9]),h=r(_d[10]),x=r(_d[11]);function y(e){const t=(0,f.relPart)(e);return t.ago?`${t.val} ago`:t.val}function p(e){return"local"===e.kind?"This machine's CLI":e.owner_nid?`Agent ${e.owner_nid}`:"agent"===e.kind?`Agent ${e.label}`:e.unused?"Meld QR not scanned yet":e.device?e.device:e.remote_addr?`Device at ${e.remote_addr}`:"Device not seen yet"}function v(e){const t=`${"agent"===e.kind?"started":"added"} ${y(e.created_at)}${e.minted_by_device?` by ${e.minted_by_device}`:""}`;if(e.unused){if(null===e.expires_at)return t;return`lapses in ${Math.max(1,Math.ceil((e.expires_at-Date.now())/6e4))} min \xb7 ${t}`}const n=[e.connected?"connected now":null!==e.last_used_at?`seen ${y(e.last_used_at)}`:"never used"];return e.remote_addr&&n.push(e.remote_addr),e.app_origin&&n.push(`via ${(0,h.originHost)(e.app_origin)}`),n.push(t),n.join(" \xb7 ")}function b(e){if(null===e.elsewhere_at)return null;const t=[e.last_device,e.last_remote_addr].filter(Boolean).join(" at ");return`Also used from another address${t?` (latest: ${t})`:""}, ${y(e.elsewhere_at)}`}function k({visible:e,conn:d,daemonName:f,onClose:h,onSignOutOthers:y,signedOutOthers:k,connected:_}){const[T,S]=(0,t.useState)(null),[C,$]=(0,t.useState)(!1),[z,O]=(0,t.useState)(null),[W,D]=(0,t.useState)(null),[R,H]=(0,t.useState)(null),[P,I]=(0,t.useState)(new Set),M=(0,t.useCallback)(async()=>{if(d){O(null);try{const e=await(0,u.listDeviceTokens)(d);$(null===e),S(e??[])}catch(e){O(String(e))}}},[d]);(0,t.useEffect)(()=>{e?(S(null),M()):D(null)},[e,M]);const L=async e=>{if(d){if(W!==e.id)return D(e.id),void I(new Set(e.descendants));H(e.id),O(null);try{await(0,u.revokeDeviceToken)(d,e.id,e.descendants.filter(e=>P.has(e))),D(null),await M()}catch(e){O(String(e))}finally{H(null)}}},A=()=>{R||h()},V=new Map((T??[]).map(e=>[e.id,e])),B=[...T??[]].sort((e,t)=>{const n=e=>e.current?0:"local"===e.kind?1:"device"===e.kind?2:3;return n(e)-n(t)||(t.last_used_at??t.created_at)-(e.last_used_at??e.created_at)});return(0,x.jsx)(o.default,{visible:e,transparent:!0,animationType:"fade",onRequestClose:A,children:(0,x.jsx)(a.default,{style:w.overlay,onPress:A,children:(0,x.jsxs)(a.default,{style:w.card,onPress:e=>e.stopPropagation(),children:[(0,x.jsxs)(s.default,{style:w.title,children:["Devices on ",f]}),null!==T||z?C?(0,x.jsx)(s.default,{style:w.body,children:"This daemon is older than the Devices list. Update brane on it to see and revoke devices."}):(0,x.jsx)(l.default,{style:w.list,children:B.map(e=>(0,x.jsxs)(c.default,{style:w.rowWrap,children:[(0,x.jsxs)(c.default,{style:w.row,children:[(0,x.jsxs)(c.default,{style:{flex:1},children:[(0,x.jsxs)(s.default,{style:w.rowTitle,numberOfLines:1,children:[p(e),e.current?(0,x.jsx)(s.default,{style:w.thisDevice,children:" this device"}):null]}),(0,x.jsx)(s.default,{style:w.rowDetail,children:v(e)}),"device"===e.kind&&(0,x.jsxs)(s.default,{style:w.rowLabel,children:["\"",e.label,"\""]}),b(e)&&(0,x.jsx)(s.default,{style:w.rowWarn,children:b(e)}),"adopted"===e.origin&&"device"===e.kind&&(0,x.jsx)(s.default,{style:w.rowWarn,children:"From before tokens were hashed; may have been logged"}),"adopted"===e.origin&&"agent"===e.kind&&(0,x.jsx)(s.default,{style:w.rowLabel,children:"Kept from before agents had their own tokens; replaced when it is next revived"})]}),"local"!==e.kind&&!e.current&&(0,x.jsx)(a.default,{style:[w.revoke,W===e.id&&w.revokeConfirm,null!==R&&{opacity:.5}],onPress:()=>L(e),disabled:null!==R,children:R===e.id?(0,x.jsx)(n.default,{size:"small",color:"#111"}):(0,x.jsx)(s.default,{style:[w.revokeText,W===e.id&&w.revokeConfirmText],children:W===e.id?"Revoke?":"Revoke"})})]}),W===e.id&&(0,x.jsx)(j,{token:e,byId:V,also:P,onToggle:e=>I(t=>{const n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})})]},e.id))}):(0,x.jsx)(n.default,{style:{marginVertical:16},color:"#aaa"}),z&&(0,x.jsx)(s.default,{style:w.error,children:z}),(0,x.jsx)(s.default,{style:w.footnote,children:"A revoked device is signed out until it scans a fresh Meld QR. To keep only this device:"}),(0,x.jsx)(a.default,{style:[w.signOut,(!_||null!==R)&&{opacity:.5}],onPress:y,disabled:!_||null!==R,children:(0,x.jsx)(s.default,{style:w.signOutText,children:k?"Other devices signed out":"Sign out other devices"})}),(0,x.jsx)(a.default,{style:[w.close,null!==R&&{opacity:.5}],onPress:A,disabled:null!==R,children:(0,x.jsx)(s.default,{style:w.closeText,children:"Close"})})]})})})}function j({token:e,byId:t,also:n,onToggle:o}){const l=[e,...e.descendants.map(e=>t.get(e)).filter(e=>!!e)].flatMap(e=>e.agents).filter(e=>"ended"!==e.status),d="agent"===e.kind;return 0!==e.descendants.length||0!==l.length||d?(0,x.jsxs)(c.default,{style:w.cascade,children:[d&&(0,x.jsxs)(s.default,{style:w.cascadeNote,children:["This cuts ",e.owner_nid??"the agent"," off from brane at once; its session keeps running without tools. To bring it back, end its session and revive it."]}),e.descendants.length>0&&(0,x.jsxs)(s.default,{style:w.cascadeHead,children:["Also revoke ",1===e.descendants.length?"the device or agent":`the ${e.descendants.length} devices and agents`," it added:"]}),e.descendants.map(e=>{const l=t.get(e),d=n.has(e);return(0,x.jsxs)(a.default,{style:w.cascadeRow,onPress:()=>o(e),children:[(0,x.jsx)(s.default,{style:[w.checkbox,d&&w.checkboxOn],children:d?"\u2611":"\u2610"}),(0,x.jsx)(s.default,{style:w.cascadeText,numberOfLines:2,children:l?`${p(l)} \xb7 ${v(l)}`:e})]},e)}),l.length>0&&(0,x.jsxs)(s.default,{style:w.cascadeNote,children:["Started ",1===l.length?"1 running agent":`${l.length} running agents`,":"," ",l.map(e=>e.id).join(", "),". Their sessions keep running; revoking their tokens cuts off their brane tools."]})]}):null}const w=d.default.create({overlay:{flex:1,backgroundColor:"rgba(0,0,0,0.6)",justifyContent:"center",alignItems:"center",padding:24},card:{backgroundColor:"#1e1e22",borderRadius:12,padding:20,width:"100%",maxWidth:420,maxHeight:"85%",borderWidth:1,borderColor:"#3a3a40"},title:{color:"#d8d8dd",fontSize:16,fontWeight:"600",marginBottom:10},body:{color:"#999",fontSize:13,lineHeight:18},list:{flexGrow:0},rowWrap:{borderBottomWidth:d.default.hairlineWidth,borderBottomColor:"#3a3a40",paddingVertical:10},row:{flexDirection:"row",alignItems:"center",gap:10},cascade:{marginTop:8,padding:10,borderRadius:8,backgroundColor:"#26262b",gap:6},cascadeHead:{color:"#d8d8dd",fontSize:13},cascadeRow:{flexDirection:"row",alignItems:"flex-start",gap:8},checkbox:{color:"#777",fontSize:16,lineHeight:18},checkboxOn:{color:"#e0a070"},cascadeText:{color:"#aaa",fontSize:12,flex:1,lineHeight:18},cascadeNote:{color:"#888",fontSize:12,lineHeight:16},rowTitle:{color:"#d8d8dd",fontSize:14},thisDevice:{color:"#66d9a0",fontSize:12},rowDetail:{color:"#777",fontSize:12,fontFamily:"monospace",marginTop:2},rowLabel:{color:"#666",fontSize:12,marginTop:2},rowWarn:{color:"#e0a070",fontSize:12,marginTop:2},revoke:{backgroundColor:"#2a2a30",borderRadius:8,paddingVertical:6,paddingHorizontal:12,minWidth:76,alignItems:"center"},revokeConfirm:{backgroundColor:"#e0a070"},revokeText:{color:"#e0a070",fontSize:13,fontWeight:"600"},revokeConfirmText:{color:"#111"},error:{color:"#e07070",fontSize:12,marginTop:8},footnote:{color:"#666",fontSize:12,lineHeight:16,marginTop:12},signOut:{backgroundColor:"#2a2a30",borderRadius:8,paddingVertical:10,alignItems:"center",marginTop:8},signOutText:{color:"#e0a070",fontSize:14,fontWeight:"600"},close:{backgroundColor:"#2a2a30",borderRadius:8,paddingVertical:10,alignItems:"center",marginTop:12},closeText:{color:"#aaa",fontSize:14,fontWeight:"600"}})},989,[11,416,153,146,122,26,105,13,745,751,979,6]);
1093
+ __d(function(g,r,i,a,_m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),Object.defineProperty(_e,"ARROW_STEP_PX",{enumerable:!0,get:function(){return e}}),Object.defineProperty(_e,"PAGE_FRACTION",{enumerable:!0,get:function(){return t}}),_e.isListScrollKey=function(e){return!(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)&&n.has(e.key)},_e.listScrollTarget=function(n,c,o){const l=Math.max(0,o.scrollHeight-o.clientHeight),u=Math.max(1,o.clientHeight*t);let s;switch(n){case"ArrowUp":s=c-e;break;case"ArrowDown":s=c+e;break;case"PageUp":s=c-u;break;case"PageDown":s=c+u;break;case"Home":return 0;case"End":return l;default:return null}return Math.min(l,Math.max(0,s))};const e=40,t=.875,n=new Set(["PageUp","PageDown","Home","End","ArrowUp","ArrowDown"])},990,[]);
1094
+ __d(function(g,r,i,a,_m,e,d){"use strict";var t=this&&this.__createBinding||(Object.create?function(t,n,o,c){void 0===c&&(c=o);var u=Object.getOwnPropertyDescriptor(n,o);u&&!("get"in u?!n.__esModule:u.writable||u.configurable)||(u={enumerable:!0,get:function(){return n[o]}}),Object.defineProperty(t,c,u)}:function(t,n,o,c){void 0===c&&(c=o),t[c]=n[o]}),n=this&&this.__exportStar||function(n,o){for(var c in n)"default"===c||Object.prototype.hasOwnProperty.call(o,c)||t(o,n,c)};Object.defineProperty(e,"__esModule",{value:!0}),n(r(d[0]),e)},991,[738]);
1095
+ __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},992,[]);
1096
+ __d(function(g,r,_i,a,_m,_e,d){"use strict";var e,t=r(d[0]),n=this&&this.__createBinding||(Object.create?function(e,t,n,o){void 0===o&&(o=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,o,i)}:function(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),i=this&&this.__importStar||(e=function(t){return e=Object.getOwnPropertyNames||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[t.length]=n);return t},e(t)},function(t){if(t&&t.__esModule)return t;var i={};if(null!=t)for(var c=e(t),u=0;u<c.length;u++)"default"!==c[u]&&n(i,t,c[u]);return o(i,t),i});Object.defineProperty(_e,"__esModule",{value:!0}),_e.renderRootComponent=function(e){try{setTimeout(()=>{f._internal_preventAutoHideAsync?.()}),u.startTransition(()=>{(0,c.registerRootComponent)(e)})}catch(e){f.hideAsync();const n=b(e);(0,c.registerRootComponent)(()=>t.jsx(s.View,{})),console.error(n),console.error("A runtime error has occurred while rendering the root component."),setTimeout(()=>{throw n})}};const c=r(d[1]),u=i(r(d[2])),s=r(d[3]),f=i(r(d[4]));function l(e){if('[object Object]'!==Object.prototype.toString.call(e))return!1;const t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}function p(e){return e&&'object'==typeof e&&'string'==typeof e.name&&'string'==typeof e.message}function b(e){return p(e)?e:l(e)?new Error(JSON.stringify(e)):new Error(String(e))}},993,[6,600,11,342,599]);
1095
1097
  __r(602);
1096
1098
  __r(2);
1097
1099
  __r(0);