@polderlabs/bizar 4.5.1 → 4.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bizar-dash/dist/assets/__vite-browser-external-BIHI7g3E.js +0 -1
- package/bizar-dash/dist/assets/main-B4OfGAwz.js +361 -0
- package/bizar-dash/dist/assets/main-B4OfGAwz.js.map +1 -0
- package/bizar-dash/dist/assets/main-DAlLdW8I.css +1 -0
- package/bizar-dash/dist/assets/{mobile-DQLFCjwJ.js → mobile-BRhoDOUz.js} +1 -2
- package/bizar-dash/dist/assets/{mobile-DQLFCjwJ.js.map → mobile-BRhoDOUz.js.map} +1 -1
- package/bizar-dash/dist/assets/{mobile-O6ANdD4W.js → mobile-lbH6szyX.js} +2 -3
- package/bizar-dash/dist/assets/mobile-lbH6szyX.js.map +1 -0
- package/bizar-dash/dist/index.html +3 -3
- package/bizar-dash/dist/mobile.html +2 -2
- package/bizar-dash/src/server/headroom.mjs +37 -35
- package/bizar-dash/src/server/memory-lightrag.mjs +39 -31
- package/bizar-dash/src/server/mods-loader.mjs +13 -5
- package/bizar-dash/src/server/providers-store.mjs +73 -1
- package/bizar-dash/src/server/routes/chat.mjs +38 -0
- package/bizar-dash/src/server/routes/lightrag.mjs +6 -2
- package/bizar-dash/src/server/routes/memory.mjs +12 -4
- package/bizar-dash/src/server/schedules-runner.mjs +4 -4
- package/bizar-dash/src/server/server.mjs +39 -37
- package/bizar-dash/src/server/watcher.mjs +2 -2
- package/bizar-dash/src/web/App.tsx +40 -6
- package/bizar-dash/src/web/components/Toast.tsx +1 -1
- package/bizar-dash/src/web/components/Topbar.tsx +1 -1
- package/bizar-dash/src/web/lib/api.ts +12 -11
- package/bizar-dash/src/web/styles/chat.css +2 -0
- package/bizar-dash/src/web/styles/main.css +52 -23
- package/bizar-dash/src/web/styles/tasks.css +2 -0
- package/bizar-dash/src/web/views/Memory.tsx +4 -3
- package/bizar-dash/src/web/views/MiniMaxUsage.tsx +3 -2
- package/bizar-dash/src/web/views/Overview.tsx +4 -2
- package/bizar-dash/src/web/views/Settings.tsx +2 -1
- package/bizar-dash/src/web/views/Skills.tsx +3 -2
- package/bizar-dash/src/web/views/Tasks.tsx +4 -3
- package/bizar-dash/src/web/views/memory/MemoryOverview.tsx +8 -6
- package/bizar-dash/tests/cli-bugfixes.test.mjs +151 -0
- package/bizar-dash/tests/frontend-bugfixes.test.mjs +151 -0
- package/bizar-dash/tests/server-bugfixes.test.mjs +318 -0
- package/cli/artifact.mjs +11 -4
- package/cli/bin.mjs +46 -12
- package/cli/doctor.mjs +5 -3
- package/cli/memory.mjs +65 -21
- package/cli/provision.mjs +8 -2
- package/install.sh +1 -2
- package/package.json +3 -3
- package/bizar-dash/dist/assets/main-eWZ4NlCL.css +0 -1
- package/bizar-dash/dist/assets/main-usWhlPWa.js +0 -362
- package/bizar-dash/dist/assets/main-usWhlPWa.js.map +0 -1
- package/bizar-dash/dist/assets/mobile-O6ANdD4W.js.map +0 -1
|
@@ -312,7 +312,7 @@ Error generating stack: `+l.message+`
|
|
|
312
312
|
*
|
|
313
313
|
* This source code is licensed under the ISC license.
|
|
314
314
|
* See the LICENSE file in the root directory of this source tree.
|
|
315
|
-
*/const Zn=J("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);function Mu(...e){return e.filter(Boolean).join(" ")}function Sr(e){if(!e&&e!==0)return"";const t=typeof e=="number"?e:new Date(e).getTime();if(Number.isNaN(t))return"";const n=Date.now()-t;return n<0||n<6e4?"just now":n<36e5?`${Math.floor(n/6e4)}m ago`:n<864e5?`${Math.floor(n/36e5)}h ago`:n<7*864e5?`${Math.floor(n/864e5)}d ago`:new Date(t).toLocaleDateString()}function px(e){if(!e)return"";const t=typeof e=="number"?new Date(e):new Date(e);return Number.isNaN(t.getTime())?"":t.toLocaleString()}function $C(e,t=160){return e?e.length>t?e.slice(0,t)+"…":e:""}const gx={low:"var(--text-dim)",normal:"var(--info)",high:"var(--error)"},Cl="bizar-auth-token",pd="bizar-loopback-trusted";class wa extends Error{constructor(n,r,i){super(n);rt(this,"status");rt(this,"data");this.name="ApiError",this.status=r,this.data=i}}class yx{constructor(){rt(this,"base","/api")}getToken(){try{return localStorage.getItem(Cl)||""}catch{return""}}setToken(t){try{t?localStorage.setItem(Cl,t):localStorage.removeItem(Cl)}catch{}}pickupTokenFromUrl(){try{const t=new URLSearchParams(window.location.search),n=t.get("token");if(!n)return!1;this.setToken(n),t.delete("token");const r=t.toString(),i=r?`${window.location.pathname}?${r}`:window.location.pathname;return history.replaceState(null,"",i),!0}catch{return!1}}urlWithToken(t){const n=this.base+t,r=this.getToken();if(!r)return n;const i=n.includes("?")?"&":"?";return`${n}${i}token=${encodeURIComponent(r)}`}async probeAuthStatus(){try{const t=await this.get("/auth/status");try{localStorage.setItem(pd,t.loopback?"1":"0")}catch{}return t}catch{return{required:!1,loopback:!0,peer:""}}}isLoopbackTrusted(){try{return localStorage.getItem(pd)!=="0"}catch{return!0}}async get(t){return this.req("GET",t)}async post(t,n){return this.req("POST",t,n)}async put(t,n){return this.req("PUT",t,n)}async patch(t,n){return this.req("PATCH",t,n)}async del(t){return this.req("DELETE",t)}async req(t,n,r){const i={"Content-Type":"application/json"},l=this.getToken();l&&(i.Authorization=`Bearer ${l}`);const s={method:t,headers:i};r!=null&&(s.body=typeof r=="string"?r:JSON.stringify(r));const o=await fetch(this.base+n,s);if((o.headers.get("content-type")||"").includes("application/json")){const c=await o.json();if(!o.ok){const f=(c&&typeof c=="object"&&"message"in c?c.message:void 0)||`${t} ${n}: ${o.status}`;throw new wa(f,o.status,c)}return c}const d=await o.text();if(!o.ok)throw new wa(`${t} ${n}: ${o.status} — ${d.slice(0,200)}`,o.status,d);try{return JSON.parse(d)}catch{return d}}}const q=new yx;q.pickupTokenFromUrl();async function xx(e){return e}const Um=w.createContext(null),vx=["button:not([disabled])","[href]","input:not([disabled])","select:not([disabled])","textarea:not([disabled])",'[tabindex]:not([tabindex="-1"])'].join(", ");function kx(){const e=w.useContext(Um);return e||{open:()=>"",close:()=>{},isModalOpen:!1}}function BC({children:e}){const[t,n]=w.useState([]),r=w.useCallback(l=>{n(s=>{if(!l)return s.slice(0,-1);const o=s.findIndex(u=>u.id===l);return o===-1||o!==s.length-1?s:s.slice(0,-1)})},[]),i=w.useCallback(l=>{const s=`m${Math.random().toString(36).slice(2,9)}`;return n(o=>[...o,{...l,id:s}]),s},[]);return w.useEffect(()=>{if(t.length===0)return;const l=s=>{s.key==="Escape"&&(s.stopPropagation(),r())};return document.addEventListener("keydown",l),()=>document.removeEventListener("keydown",l)},[t.length,r]),a.jsxs(Um.Provider,{value:{open:i,close:r,isModalOpen:t.length>0},children:[e,typeof document<"u"&&Dm.createPortal(a.jsx("div",{className:"modal-stack","aria-hidden":t.length===0,children:t.map((l,s)=>a.jsx(wx,{modal:l,onClose:()=>{var o;(o=l.onClose)==null||o.call(l),r(l.id)},depth:s},l.id))}),document.body)]})}function wx({modal:e,onClose:t,depth:n}){const r=w.useRef(null),i=w.useRef(null),l=w.useId(),s=()=>{const o=r.current;return o?Array.from(o.querySelectorAll(vx)).filter(u=>!u.hasAttribute("disabled")&&u.tabIndex!==-1):[]};return w.useEffect(()=>{var d;i.current=document.activeElement instanceof HTMLElement?document.activeElement:null,(d=s()[0]??r.current)==null||d.focus();const u=c=>{var x,b,y;if(c.key!=="Tab")return;const f=s();if(f.length===0){c.preventDefault(),(x=r.current)==null||x.focus();return}const m=f[0],h=f[f.length-1],p=document.activeElement instanceof HTMLElement?document.activeElement:null;if(c.shiftKey){(!p||p===m||!((b=r.current)!=null&&b.contains(p)))&&(c.preventDefault(),h.focus());return}(!p||p===h||!((y=r.current)!=null&&y.contains(p)))&&(c.preventDefault(),m.focus())};return document.addEventListener("keydown",u),()=>{document.removeEventListener("keydown",u);const c=i.current;c&&c.isConnected&&c.focus()}},[]),a.jsx("div",{className:"modal-backdrop",onClick:o=>{o.stopPropagation(),o.target===o.currentTarget&&t()},style:n>0?{background:"rgba(0,0,0,0.4)"}:void 0,children:a.jsxs("div",{ref:r,className:"modal",role:"dialog","aria-modal":"true","aria-labelledby":e.title?l:void 0,tabIndex:-1,onClick:o=>o.stopPropagation(),style:e.width?{maxWidth:e.width}:void 0,children:[e.title&&a.jsxs("header",{className:"modal-header",children:[a.jsx("h2",{id:l,className:"modal-title",children:e.title}),a.jsx("button",{type:"button",className:"icon-btn","aria-label":"Close",onClick:t,children:a.jsx(Zn,{size:16})})]}),a.jsx("div",{className:"modal-body",children:e.children}),e.footer&&a.jsx("footer",{className:"modal-footer",children:e.footer})]})})}const pr=w.forwardRef(function({variant:t="secondary",size:n="md",iconOnly:r=!1,loading:i=!1,disabled:l,className:s,children:o,...u},d){return a.jsxs("button",{ref:d,type:u.type??"button",disabled:l||i,className:Mu("btn",`btn-${t}`,`btn-size-${n}`,r&&"btn-icon",i&&"btn-loading",s),...u,children:[i?a.jsx("span",{className:"btn-spinner","aria-hidden":!0}):null,o]})}),Hm=w.createContext(null);function bx(){const e=w.useContext(Hm);return e||{show:()=>{},info:()=>{},success:()=>{},error:()=>{},warning:()=>{},dismiss:()=>{},toasts:[]}}const Sx={info:tx,success:Y1,error:q1,warning:mx};function UC({children:e}){const[t,n]=w.useState([]),r=w.useRef(1),i=w.useRef(new Map),l=w.useCallback(u=>{n(c=>c.filter(f=>f.id!==u));const d=i.current.get(u);d&&(clearTimeout(d),i.current.delete(u))},[]),s=w.useCallback((u,d="info",c=4e3)=>{const f=r.current++;if(n(m=>[...m,{id:f,kind:d,message:u}]),c>0){const m=setTimeout(()=>l(f),c);i.current.set(f,m)}},[l]);w.useEffect(()=>()=>{for(const u of i.current.values())clearTimeout(u);i.current.clear()},[]);const o=w.useMemo(()=>({show:s,info:(u,d)=>s(u,"info",d),success:(u,d)=>s(u,"success",d),error:(u,d)=>s(u,"error",d),warning:(u,d)=>s(u,"warning",d),dismiss:l,toasts:t}),[s,l,t]);return a.jsxs(Hm.Provider,{value:o,children:[e,a.jsx(Cx,{toasts:t,onDismiss:l})]})}function Cx({toasts:e,onDismiss:t}){return a.jsx("div",{className:"toast-stack","aria-live":"polite",children:e.map(n=>a.jsx(jx,{toast:n,onDismiss:t},n.id))})}function jx({toast:e,onDismiss:t}){const n=Sx[e.kind];return a.jsxs("div",{className:`toast toast-${e.kind}`,role:"status",children:[a.jsx(n,{size:16,className:"toast-icon"}),a.jsx("span",{className:"toast-message",children:e.message}),a.jsx("button",{type:"button",className:"toast-close","aria-label":"Dismiss",onClick:()=>t(e.id),children:a.jsx(Zn,{size:14})})]})}function Nx(){if(typeof location>"u")return"ws://localhost/ws";const e=`${location.protocol==="https:"?"wss":"ws"}://${location.host}/ws`;let t="";try{t=localStorage.getItem(Cl)||""}catch{}return t?`${e}?token=${encodeURIComponent(t)}`:e}class Vm{constructor(t){rt(this,"urlOverride");rt(this,"handlers",new Set);rt(this,"statusHandlers",new Set);rt(this,"ws",null);rt(this,"reconnectDelay",1e3);rt(this,"maxReconnectDelay",15e3);rt(this,"reconnectTimer",null);rt(this,"_status","connecting");rt(this,"pingTimer",null);rt(this,"closed",!1);this.urlOverride=t,this.connect()}on(t){return this.handlers.add(t),()=>{this.handlers.delete(t)}}onStatus(t){return this.statusHandlers.add(t),t(this._status),()=>{this.statusHandlers.delete(t)}}get status(){return this._status}send(t){return this.ws&&this.ws.readyState===WebSocket.OPEN?(this.ws.send(JSON.stringify(t)),!0):!1}close(){var t;this.closed=!0,this.reconnectTimer&&clearTimeout(this.reconnectTimer),this.reconnectTimer=null,this.pingTimer&&clearInterval(this.pingTimer),this.pingTimer=null;try{(t=this.ws)==null||t.close()}catch{}this.ws=null,this.setStatus("disconnected")}connect(){if(this.closed)return;this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.setStatus("connecting");const t=this.urlOverride??Nx();let n;try{n=new WebSocket(t),this.ws=n}catch(r){console.warn("[ws] construct failed:",r),this.scheduleReconnect();return}n.addEventListener("open",()=>{this.ws!==n||this.closed||(this.reconnectDelay=1e3,this.setStatus("connected"),this.pingTimer&&clearInterval(this.pingTimer),this.pingTimer=setInterval(()=>{this._status==="connected"&&this.send({type:"ping"})},3e4))}),n.addEventListener("close",()=>{this.ws===n&&(this.ws=null,this.setStatus("disconnected"),this.pingTimer&&(clearInterval(this.pingTimer),this.pingTimer=null),this.closed||this.scheduleReconnect())}),n.addEventListener("error",()=>{this.ws===n&&console.warn("[ws] error")}),n.addEventListener("message",r=>{let i;try{i=JSON.parse(r.data)}catch{console.warn("[ws] bad message");return}for(const l of this.handlers)try{l(i)}catch(s){console.error("[ws] handler error:",s)}})}scheduleReconnect(){this.closed||this.reconnectTimer||(this.reconnectTimer=setTimeout(()=>{this.reconnectTimer=null,this.connect()},this.reconnectDelay),this.reconnectDelay=Math.min(this.reconnectDelay*1.6,this.maxReconnectDelay))}setStatus(t){this._status=t;for(const n of this.statusHandlers)try{n(t)}catch(r){console.error("[ws] status handler error:",r)}}}const Ex=Object.freeze(Object.defineProperty({__proto__:null,Ws:Vm},Symbol.toStringTag,{value:"Module"}));function ts(e){const t=typeof e=="string"?e:e.mode,n=t==="system"?typeof window<"u"&&window.matchMedia("(prefers-color-scheme: light)").matches?"light":"dark":t==="light"?"light":"dark";return typeof document<"u"&&(n==="light"?document.documentElement.setAttribute("data-theme","light"):document.documentElement.removeAttribute("data-theme")),n}function ui(e){if(typeof document>"u")return;const t=document.documentElement;t.style.setProperty("--accent",e.accent),t.style.setProperty("--success",e.success),t.style.setProperty("--warning",e.warning),t.style.setProperty("--error",e.error),t.style.setProperty("--info",e.info),t.style.setProperty("--accent-bg",gd(e.accent,.12)),t.style.setProperty("--accent-border",gd(e.accent,.4)),e.fontFamily&&t.style.setProperty("--font-sans",`'${e.fontFamily}', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif`),e.fontSize&&t.style.setProperty("--base-font-size",`${e.fontSize}px`),t.dataset.compactMode=e.compactMode?"true":"false",t.dataset.animations=e.animations?"true":"false"}function gd(e,t){const n=/^#?([0-9a-f]{6})$/i.exec(e||"");if(!n)return`rgba(139, 92, 246, ${t})`;const r=parseInt(n[1],16),i=r>>16&255,l=r>>8&255,s=r&255;return`rgba(${i}, ${l}, ${s}, ${t})`}function Wm({size:e="md",className:t,label:n}){return a.jsx("span",{className:Mu("spinner",`spinner-${e}`,t),role:"status","aria-label":n||"Loading"})}function Tx({activeProject:e,sessionCount:t,sessionsOpen:n,infoOpen:r,onToggleSessions:i,onToggleInfo:l,onOpenOverview:s}){return a.jsxs("header",{className:"chat-topbar",children:[a.jsxs("button",{type:"button",className:"chat-topbar-project",onClick:s,children:[a.jsx(Pu,{size:14}),a.jsx("span",{className:"chat-topbar-project-name",children:(e==null?void 0:e.name)??"No project"}),a.jsx(Ss,{size:12})]}),a.jsx("div",{className:"chat-topbar-spacer"}),a.jsxs("button",{type:"button",className:`chat-topbar-btn ${n?"active":""}`,onClick:i,"aria-pressed":n,children:["Sessions (",t,")"]}),a.jsx("button",{type:"button",className:`chat-topbar-btn ${r?"active":""}`,onClick:l,"aria-pressed":r,children:"Info"})]})}function Ix({icon:e,title:t,message:n,action:r}){return a.jsxs("div",{className:"chat-empty-state",children:[e&&a.jsx("div",{className:"chat-empty-state-icon",children:e}),a.jsx("h2",{className:"chat-empty-state-title",children:t}),a.jsx("p",{className:"chat-empty-state-message",children:n}),r&&a.jsx("div",{className:"chat-empty-state-action",children:r})]})}function zx({count:e=3}){return a.jsx("div",{className:"chat-loading-skeleton","aria-label":"Loading messages",children:Array.from({length:e}).map((t,n)=>a.jsxs("div",{className:"chat-loading-skeleton-bubble",children:[a.jsx("div",{className:"chat-loading-skeleton-meta"}),a.jsx("div",{className:"chat-loading-skeleton-line"}),a.jsx("div",{className:"chat-loading-skeleton-line short"})]},n))})}function Px({projectName:e,onPickSuggestion:t}){const n=[{icon:a.jsx(G1,{size:16}),title:e?`Explain ${e}`:"Explain this project",preview:"Give me a tour of the codebase, highlight the architecture, and call out any anti-patterns or hotspots.",prompt:e?`Explain the ${e} project. Give me a tour of the codebase, highlight the architecture, and call out any anti-patterns or hotspots.`:"Explain the current project. Give me a tour of the codebase, highlight the architecture, and call out any anti-patterns or hotspots."},{icon:a.jsx(W1,{size:16}),title:"Summarize recent sessions",preview:"Read my last 5 chat sessions and give me a 3-bullet summary of what I worked on and what got stuck.",prompt:"Read my last 5 chat sessions and give me a 3-bullet summary of what I worked on and what got stuck."},{icon:a.jsx(nx,{size:16}),title:"Suggest a refactor",preview:"Look for the largest, most painful files in this project and propose a concrete refactor for the worst one.",prompt:"Look for the largest, most painful files in this project and propose a concrete refactor for the worst one."},{icon:a.jsx(ex,{size:16}),title:"Find visual regressions",preview:"Open the dashboard, screenshot the Chat tab, and flag any layout problems or anti-patterns you see.",prompt:"Open the dashboard, screenshot the Chat tab, and flag any layout problems or anti-patterns you see."}];return a.jsx("div",{className:"chat-suggestions",children:n.map((r,i)=>a.jsxs("button",{type:"button",className:"chat-suggestion",onClick:()=>t(r.prompt),children:[a.jsxs("div",{className:"chat-suggestion-title",children:[r.icon,a.jsx("span",{children:r.title})]}),a.jsx("div",{className:"chat-suggestion-preview",children:r.preview})]},i))})}function yd({variant:e,projectName:t,onPickSuggestion:n}){if(e==="no-project")return a.jsxs("div",{className:"chat-welcome",children:[a.jsx("h1",{className:"chat-welcome-h1",children:a.jsx("span",{className:"chat-greeting-hello",children:"No project selected."})}),a.jsx("p",{className:"chat-welcome-subtitle",children:"Pick a project in Overview to scope chat sessions."})]});const r=t||"there";return a.jsxs("div",{className:"chat-welcome",children:[a.jsxs("h1",{className:"chat-welcome-h1",children:[a.jsx("span",{className:"chat-greeting-hello",children:"Hello, "}),a.jsxs("span",{className:"chat-greeting-name",children:[r,"."]})]}),a.jsx("p",{className:"chat-welcome-subtitle",children:"How can I help you today?"}),a.jsx(Px,{projectName:t,onPickSuggestion:n})]})}function Ax(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const Mx=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Lx=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Rx={};function xd(e,t){return(Rx.jsx?Lx:Mx).test(e)}const Dx=/[ \t\n\f\r]/g;function _x(e){return typeof e=="object"?e.type==="text"?vd(e.value):!1:vd(e)}function vd(e){return e.replace(Dx,"")===""}class _i{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}_i.prototype.normal={};_i.prototype.property={};_i.prototype.space=void 0;function Qm(e,t){const n={},r={};for(const i of e)Object.assign(n,i.property),Object.assign(r,i.normal);return new _i(n,r,t)}function ba(e){return e.toLowerCase()}class ct{constructor(t,n){this.attribute=n,this.property=t}}ct.prototype.attribute="";ct.prototype.booleanish=!1;ct.prototype.boolean=!1;ct.prototype.commaOrSpaceSeparated=!1;ct.prototype.commaSeparated=!1;ct.prototype.defined=!1;ct.prototype.mustUseProperty=!1;ct.prototype.number=!1;ct.prototype.overloadedBoolean=!1;ct.prototype.property="";ct.prototype.spaceSeparated=!1;ct.prototype.space=void 0;let Ox=0;const ne=Jn(),Re=Jn(),Sa=Jn(),$=Jn(),ve=Jn(),Bn=Jn(),ft=Jn();function Jn(){return 2**++Ox}const Ca=Object.freeze(Object.defineProperty({__proto__:null,boolean:ne,booleanish:Re,commaOrSpaceSeparated:ft,commaSeparated:Bn,number:$,overloadedBoolean:Sa,spaceSeparated:ve},Symbol.toStringTag,{value:"Module"})),ao=Object.keys(Ca);class Lu extends ct{constructor(t,n,r,i){let l=-1;if(super(t,n),kd(this,"space",i),typeof r=="number")for(;++l<ao.length;){const s=ao[l];kd(this,ao[l],(r&Ca[s])===Ca[s])}}}Lu.prototype.defined=!0;function kd(e,t,n){n&&(e[t]=n)}function Or(e){const t={},n={};for(const[r,i]of Object.entries(e.properties)){const l=new Lu(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(l.mustUseProperty=!0),t[r]=l,n[ba(r)]=r,n[ba(l.attribute)]=r}return new _i(t,n,e.space)}const qm=Or({properties:{ariaActiveDescendant:null,ariaAtomic:Re,ariaAutoComplete:null,ariaBusy:Re,ariaChecked:Re,ariaColCount:$,ariaColIndex:$,ariaColSpan:$,ariaControls:ve,ariaCurrent:null,ariaDescribedBy:ve,ariaDetails:null,ariaDisabled:Re,ariaDropEffect:ve,ariaErrorMessage:null,ariaExpanded:Re,ariaFlowTo:ve,ariaGrabbed:Re,ariaHasPopup:null,ariaHidden:Re,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:ve,ariaLevel:$,ariaLive:null,ariaModal:Re,ariaMultiLine:Re,ariaMultiSelectable:Re,ariaOrientation:null,ariaOwns:ve,ariaPlaceholder:null,ariaPosInSet:$,ariaPressed:Re,ariaReadOnly:Re,ariaRelevant:null,ariaRequired:Re,ariaRoleDescription:ve,ariaRowCount:$,ariaRowIndex:$,ariaRowSpan:$,ariaSelected:Re,ariaSetSize:$,ariaSort:null,ariaValueMax:$,ariaValueMin:$,ariaValueNow:$,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function Ym(e,t){return t in e?e[t]:t}function Km(e,t){return Ym(e,t.toLowerCase())}const Fx=Or({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Bn,acceptCharset:ve,accessKey:ve,action:null,allow:null,allowFullScreen:ne,allowPaymentRequest:ne,allowUserMedia:ne,alpha:ne,alt:null,as:null,async:ne,autoCapitalize:null,autoComplete:ve,autoFocus:ne,autoPlay:ne,blocking:ve,capture:null,charSet:null,checked:ne,cite:null,className:ve,closedBy:null,colorSpace:null,cols:$,colSpan:$,command:null,commandFor:null,content:null,contentEditable:Re,controls:ne,controlsList:ve,coords:$|Bn,crossOrigin:null,data:null,dateTime:null,decoding:null,default:ne,defer:ne,dir:null,dirName:null,disabled:ne,download:Sa,draggable:Re,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:ne,formTarget:null,headers:ve,height:$,hidden:Sa,high:$,href:null,hrefLang:null,htmlFor:ve,httpEquiv:ve,id:null,imageSizes:null,imageSrcSet:null,inert:ne,inputMode:null,integrity:null,is:null,isMap:ne,itemId:null,itemProp:ve,itemRef:ve,itemScope:ne,itemType:ve,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:ne,low:$,manifest:null,max:null,maxLength:$,media:null,method:null,min:null,minLength:$,multiple:ne,muted:ne,name:null,nonce:null,noModule:ne,noValidate:ne,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:ne,optimum:$,pattern:null,ping:ve,placeholder:null,playsInline:ne,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:ne,referrerPolicy:null,rel:ve,required:ne,reversed:ne,rows:$,rowSpan:$,sandbox:ve,scope:null,scoped:ne,seamless:ne,selected:ne,shadowRootClonable:ne,shadowRootCustomElementRegistry:ne,shadowRootDelegatesFocus:ne,shadowRootMode:null,shadowRootSerializable:ne,shape:null,size:$,sizes:null,slot:null,span:$,spellCheck:Re,src:null,srcDoc:null,srcLang:null,srcSet:null,start:$,step:null,style:null,tabIndex:$,target:null,title:null,translate:null,type:null,typeMustMatch:ne,useMap:null,value:Re,width:$,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:ve,axis:null,background:null,bgColor:null,border:$,borderColor:null,bottomMargin:$,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:ne,declare:ne,event:null,face:null,frame:null,frameBorder:null,hSpace:$,leftMargin:$,link:null,longDesc:null,lowSrc:null,marginHeight:$,marginWidth:$,noResize:ne,noHref:ne,noShade:ne,noWrap:ne,object:null,profile:null,prompt:null,rev:null,rightMargin:$,rules:null,scheme:null,scrolling:Re,standby:null,summary:null,text:null,topMargin:$,valueType:null,version:null,vAlign:null,vLink:null,vSpace:$,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:ne,disablePictureInPicture:ne,disableRemotePlayback:ne,exportParts:Bn,part:ve,prefix:null,property:null,results:$,security:null,unselectable:null},space:"html",transform:Km}),$x=Or({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",maskType:"mask-type",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:ft,accentHeight:$,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:$,amplitude:$,arabicForm:null,ascent:$,attributeName:null,attributeType:null,azimuth:$,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:$,by:null,calcMode:null,capHeight:$,className:ve,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:$,diffuseConstant:$,direction:null,display:null,dur:null,divisor:$,dominantBaseline:null,download:ne,dx:null,dy:null,edgeMode:null,editable:null,elevation:$,enableBackground:null,end:null,event:null,exponent:$,externalResourcesRequired:null,fill:null,fillOpacity:$,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:Bn,g2:Bn,glyphName:Bn,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:$,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:$,horizOriginX:$,horizOriginY:$,id:null,ideographic:$,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:$,k:$,k1:$,k2:$,k3:$,k4:$,kernelMatrix:ft,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:$,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskType:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:$,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:$,overlineThickness:$,paintOrder:null,panose1:null,path:null,pathLength:$,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:ve,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:$,pointsAtY:$,pointsAtZ:$,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:ft,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:ft,rev:ft,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:ft,requiredFeatures:ft,requiredFonts:ft,requiredFormats:ft,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:$,specularExponent:$,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:$,strikethroughThickness:$,string:null,stroke:null,strokeDashArray:ft,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:$,strokeOpacity:$,strokeWidth:null,style:null,surfaceScale:$,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:ft,tabIndex:$,tableValues:null,target:null,targetX:$,targetY:$,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:ft,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:$,underlineThickness:$,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:$,values:null,vAlphabetic:$,vMathematical:$,vectorEffect:null,vHanging:$,vIdeographic:$,version:null,vertAdvY:$,vertOriginX:$,vertOriginY:$,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:$,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:Ym}),Gm=Or({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),Xm=Or({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:Km}),Zm=Or({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),Bx={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},Ux=/[A-Z]/g,wd=/-[a-z]/g,Hx=/^data[-\w.:]+$/i;function Vx(e,t){const n=ba(t);let r=t,i=ct;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&Hx.test(t)){if(t.charAt(4)==="-"){const l=t.slice(5).replace(wd,Qx);r="data"+l.charAt(0).toUpperCase()+l.slice(1)}else{const l=t.slice(4);if(!wd.test(l)){let s=l.replace(Ux,Wx);s.charAt(0)!=="-"&&(s="-"+s),t="data"+s}}i=Lu}return new i(r,t)}function Wx(e){return"-"+e.toLowerCase()}function Qx(e){return e.charAt(1).toUpperCase()}const qx=Qm([qm,Fx,Gm,Xm,Zm],"html"),Ru=Qm([qm,$x,Gm,Xm,Zm],"svg");function Yx(e){return e.join(" ").trim()}var Du={},bd=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,Kx=/\n/g,Gx=/^\s*/,Xx=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,Zx=/^:\s*/,Jx=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,ev=/^[;\s]*/,tv=/^\s+|\s+$/g,nv=`
|
|
315
|
+
*/const Zn=J("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);function Mu(...e){return e.filter(Boolean).join(" ")}function Sr(e){if(!e&&e!==0)return"";const t=typeof e=="number"?e:new Date(e).getTime();if(Number.isNaN(t))return"";const n=Date.now()-t;return n<0||n<6e4?"just now":n<36e5?`${Math.floor(n/6e4)}m ago`:n<864e5?`${Math.floor(n/36e5)}h ago`:n<7*864e5?`${Math.floor(n/864e5)}d ago`:new Date(t).toLocaleDateString()}function px(e){if(!e)return"";const t=typeof e=="number"?new Date(e):new Date(e);return Number.isNaN(t.getTime())?"":t.toLocaleString()}function $C(e,t=160){return e?e.length>t?e.slice(0,t)+"…":e:""}const gx={low:"var(--text-dim)",normal:"var(--info)",high:"var(--error)"},Cl="bizar-auth-token",pd="bizar-loopback-trusted";class wa extends Error{constructor(n,r,i){super(n);rt(this,"status");rt(this,"data");this.name="ApiError",this.status=r,this.data=i}}class yx{constructor(){rt(this,"base","/api")}getToken(){try{return localStorage.getItem(Cl)||""}catch{return""}}setToken(t){try{t?localStorage.setItem(Cl,t):localStorage.removeItem(Cl)}catch{}}pickupTokenFromUrl(){try{const t=new URLSearchParams(window.location.search),n=t.get("token");if(!n)return!1;this.setToken(n),t.delete("token");const r=t.toString(),i=r?`${window.location.pathname}?${r}`:window.location.pathname;return history.replaceState(null,"",i),!0}catch{return!1}}urlWithToken(t){const n=this.base+t,r=this.getToken();if(!r)return n;const i=n.includes("?")?"&":"?";return`${n}${i}token=${encodeURIComponent(r)}`}async probeAuthStatus(){try{const t=await this.get("/auth/status");try{localStorage.setItem(pd,t.loopback?"1":"0")}catch{}return t}catch{return{required:!1,loopback:!0,peer:""}}}isLoopbackTrusted(){try{return localStorage.getItem(pd)!=="0"}catch{return!0}}async get(t,n){return this.req("GET",t,void 0,n)}async post(t,n,r){return this.req("POST",t,n,r)}async put(t,n,r){return this.req("PUT",t,n,r)}async patch(t,n,r){return this.req("PATCH",t,n,r)}async del(t,n){return this.req("DELETE",t,void 0,n)}async req(t,n,r,i){const l={"Content-Type":"application/json"},s=this.getToken();s&&(l.Authorization=`Bearer ${s}`);const o={method:t,headers:l};r!=null&&(o.body=typeof r=="string"?r:JSON.stringify(r)),i&&(o.signal=i);const u=await fetch(this.base+n,o);if((u.headers.get("content-type")||"").includes("application/json")){const f=await u.json();if(!u.ok){const m=(f&&typeof f=="object"&&"message"in f?f.message:void 0)||`${t} ${n}: ${u.status}`;throw new wa(m,u.status,f)}return f}const c=await u.text();if(!u.ok)throw new wa(`${t} ${n}: ${u.status} — ${c.slice(0,200)}`,u.status,c);try{return JSON.parse(c)}catch{return c}}}const q=new yx;q.pickupTokenFromUrl();async function xx(e){return e}const Um=w.createContext(null),vx=["button:not([disabled])","[href]","input:not([disabled])","select:not([disabled])","textarea:not([disabled])",'[tabindex]:not([tabindex="-1"])'].join(", ");function kx(){const e=w.useContext(Um);return e||{open:()=>"",close:()=>{},isModalOpen:!1}}function BC({children:e}){const[t,n]=w.useState([]),r=w.useCallback(l=>{n(s=>{if(!l)return s.slice(0,-1);const o=s.findIndex(u=>u.id===l);return o===-1||o!==s.length-1?s:s.slice(0,-1)})},[]),i=w.useCallback(l=>{const s=`m${Math.random().toString(36).slice(2,9)}`;return n(o=>[...o,{...l,id:s}]),s},[]);return w.useEffect(()=>{if(t.length===0)return;const l=s=>{s.key==="Escape"&&(s.stopPropagation(),r())};return document.addEventListener("keydown",l),()=>document.removeEventListener("keydown",l)},[t.length,r]),a.jsxs(Um.Provider,{value:{open:i,close:r,isModalOpen:t.length>0},children:[e,typeof document<"u"&&Dm.createPortal(a.jsx("div",{className:"modal-stack","aria-hidden":t.length===0,children:t.map((l,s)=>a.jsx(wx,{modal:l,onClose:()=>{var o;(o=l.onClose)==null||o.call(l),r(l.id)},depth:s},l.id))}),document.body)]})}function wx({modal:e,onClose:t,depth:n}){const r=w.useRef(null),i=w.useRef(null),l=w.useId(),s=()=>{const o=r.current;return o?Array.from(o.querySelectorAll(vx)).filter(u=>!u.hasAttribute("disabled")&&u.tabIndex!==-1):[]};return w.useEffect(()=>{var d;i.current=document.activeElement instanceof HTMLElement?document.activeElement:null,(d=s()[0]??r.current)==null||d.focus();const u=c=>{var x,b,y;if(c.key!=="Tab")return;const f=s();if(f.length===0){c.preventDefault(),(x=r.current)==null||x.focus();return}const m=f[0],h=f[f.length-1],p=document.activeElement instanceof HTMLElement?document.activeElement:null;if(c.shiftKey){(!p||p===m||!((b=r.current)!=null&&b.contains(p)))&&(c.preventDefault(),h.focus());return}(!p||p===h||!((y=r.current)!=null&&y.contains(p)))&&(c.preventDefault(),m.focus())};return document.addEventListener("keydown",u),()=>{document.removeEventListener("keydown",u);const c=i.current;c&&c.isConnected&&c.focus()}},[]),a.jsx("div",{className:"modal-backdrop",onClick:o=>{o.stopPropagation(),o.target===o.currentTarget&&t()},style:n>0?{background:"rgba(0,0,0,0.4)"}:void 0,children:a.jsxs("div",{ref:r,className:"modal",role:"dialog","aria-modal":"true","aria-labelledby":e.title?l:void 0,tabIndex:-1,onClick:o=>o.stopPropagation(),style:e.width?{maxWidth:e.width}:void 0,children:[e.title&&a.jsxs("header",{className:"modal-header",children:[a.jsx("h2",{id:l,className:"modal-title",children:e.title}),a.jsx("button",{type:"button",className:"icon-btn","aria-label":"Close",onClick:t,children:a.jsx(Zn,{size:16})})]}),a.jsx("div",{className:"modal-body",children:e.children}),e.footer&&a.jsx("footer",{className:"modal-footer",children:e.footer})]})})}const pr=w.forwardRef(function({variant:t="secondary",size:n="md",iconOnly:r=!1,loading:i=!1,disabled:l,className:s,children:o,...u},d){return a.jsxs("button",{ref:d,type:u.type??"button",disabled:l||i,className:Mu("btn",`btn-${t}`,`btn-size-${n}`,r&&"btn-icon",i&&"btn-loading",s),...u,children:[i?a.jsx("span",{className:"btn-spinner","aria-hidden":!0}):null,o]})}),Hm=w.createContext(null);function bx(){const e=w.useContext(Hm);return e||{show:()=>{},info:()=>{},success:()=>{},error:()=>{},warning:()=>{},dismiss:()=>{},toasts:[]}}const Sx={info:tx,success:Y1,error:q1,warning:mx};function UC({children:e}){const[t,n]=w.useState([]),r=w.useRef(1),i=w.useRef(new Map),l=w.useCallback(u=>{n(c=>c.filter(f=>f.id!==u));const d=i.current.get(u);d&&(clearTimeout(d),i.current.delete(u))},[]),s=w.useCallback((u,d="info",c=4e3)=>{const f=r.current++;if(n(m=>[...m,{id:f,kind:d,message:u}]),c>0){const m=setTimeout(()=>l(f),c);i.current.set(f,m)}},[l]);w.useEffect(()=>()=>{for(const u of i.current.values())clearTimeout(u);i.current.clear()},[]);const o=w.useMemo(()=>({show:s,info:(u,d)=>s(u,"info",d),success:(u,d)=>s(u,"success",d),error:(u,d)=>s(u,"error",d),warning:(u,d)=>s(u,"warning",d),dismiss:l,toasts:t}),[s,l,t]);return a.jsxs(Hm.Provider,{value:o,children:[e,a.jsx(Cx,{toasts:t,onDismiss:l})]})}function Cx({toasts:e,onDismiss:t}){return a.jsx("div",{className:"toast-stack","aria-live":"polite",children:e.map(n=>a.jsx(jx,{toast:n,onDismiss:t},n.id))})}function jx({toast:e,onDismiss:t}){const n=Sx[e.kind];return a.jsxs("div",{className:`toast toast-${e.kind}`,role:"alert","aria-live":"assertive","aria-atomic":"true",children:[a.jsx(n,{size:16,className:"toast-icon"}),a.jsx("span",{className:"toast-message",children:e.message}),a.jsx("button",{type:"button",className:"toast-close","aria-label":"Dismiss",onClick:()=>t(e.id),children:a.jsx(Zn,{size:14})})]})}function Nx(){if(typeof location>"u")return"ws://localhost/ws";const e=`${location.protocol==="https:"?"wss":"ws"}://${location.host}/ws`;let t="";try{t=localStorage.getItem(Cl)||""}catch{}return t?`${e}?token=${encodeURIComponent(t)}`:e}class Vm{constructor(t){rt(this,"urlOverride");rt(this,"handlers",new Set);rt(this,"statusHandlers",new Set);rt(this,"ws",null);rt(this,"reconnectDelay",1e3);rt(this,"maxReconnectDelay",15e3);rt(this,"reconnectTimer",null);rt(this,"_status","connecting");rt(this,"pingTimer",null);rt(this,"closed",!1);this.urlOverride=t,this.connect()}on(t){return this.handlers.add(t),()=>{this.handlers.delete(t)}}onStatus(t){return this.statusHandlers.add(t),t(this._status),()=>{this.statusHandlers.delete(t)}}get status(){return this._status}send(t){return this.ws&&this.ws.readyState===WebSocket.OPEN?(this.ws.send(JSON.stringify(t)),!0):!1}close(){var t;this.closed=!0,this.reconnectTimer&&clearTimeout(this.reconnectTimer),this.reconnectTimer=null,this.pingTimer&&clearInterval(this.pingTimer),this.pingTimer=null;try{(t=this.ws)==null||t.close()}catch{}this.ws=null,this.setStatus("disconnected")}connect(){if(this.closed)return;this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.setStatus("connecting");const t=this.urlOverride??Nx();let n;try{n=new WebSocket(t),this.ws=n}catch(r){console.warn("[ws] construct failed:",r),this.scheduleReconnect();return}n.addEventListener("open",()=>{this.ws!==n||this.closed||(this.reconnectDelay=1e3,this.setStatus("connected"),this.pingTimer&&clearInterval(this.pingTimer),this.pingTimer=setInterval(()=>{this._status==="connected"&&this.send({type:"ping"})},3e4))}),n.addEventListener("close",()=>{this.ws===n&&(this.ws=null,this.setStatus("disconnected"),this.pingTimer&&(clearInterval(this.pingTimer),this.pingTimer=null),this.closed||this.scheduleReconnect())}),n.addEventListener("error",()=>{this.ws===n&&console.warn("[ws] error")}),n.addEventListener("message",r=>{let i;try{i=JSON.parse(r.data)}catch{console.warn("[ws] bad message");return}for(const l of this.handlers)try{l(i)}catch(s){console.error("[ws] handler error:",s)}})}scheduleReconnect(){this.closed||this.reconnectTimer||(this.reconnectTimer=setTimeout(()=>{this.reconnectTimer=null,this.connect()},this.reconnectDelay),this.reconnectDelay=Math.min(this.reconnectDelay*1.6,this.maxReconnectDelay))}setStatus(t){this._status=t;for(const n of this.statusHandlers)try{n(t)}catch(r){console.error("[ws] status handler error:",r)}}}const Ex=Object.freeze(Object.defineProperty({__proto__:null,Ws:Vm},Symbol.toStringTag,{value:"Module"}));function ts(e){const t=typeof e=="string"?e:e.mode,n=t==="system"?typeof window<"u"&&window.matchMedia("(prefers-color-scheme: light)").matches?"light":"dark":t==="light"?"light":"dark";return typeof document<"u"&&(n==="light"?document.documentElement.setAttribute("data-theme","light"):document.documentElement.removeAttribute("data-theme")),n}function ui(e){if(typeof document>"u")return;const t=document.documentElement;t.style.setProperty("--accent",e.accent),t.style.setProperty("--success",e.success),t.style.setProperty("--warning",e.warning),t.style.setProperty("--error",e.error),t.style.setProperty("--info",e.info),t.style.setProperty("--accent-bg",gd(e.accent,.12)),t.style.setProperty("--accent-border",gd(e.accent,.4)),e.fontFamily&&t.style.setProperty("--font-sans",`'${e.fontFamily}', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif`),e.fontSize&&t.style.setProperty("--base-font-size",`${e.fontSize}px`),t.dataset.compactMode=e.compactMode?"true":"false",t.dataset.animations=e.animations?"true":"false"}function gd(e,t){const n=/^#?([0-9a-f]{6})$/i.exec(e||"");if(!n)return`rgba(139, 92, 246, ${t})`;const r=parseInt(n[1],16),i=r>>16&255,l=r>>8&255,s=r&255;return`rgba(${i}, ${l}, ${s}, ${t})`}function Wm({size:e="md",className:t,label:n}){return a.jsx("span",{className:Mu("spinner",`spinner-${e}`,t),role:"status","aria-label":n||"Loading"})}function Tx({activeProject:e,sessionCount:t,sessionsOpen:n,infoOpen:r,onToggleSessions:i,onToggleInfo:l,onOpenOverview:s}){return a.jsxs("header",{className:"chat-topbar",children:[a.jsxs("button",{type:"button",className:"chat-topbar-project",onClick:s,children:[a.jsx(Pu,{size:14}),a.jsx("span",{className:"chat-topbar-project-name",children:(e==null?void 0:e.name)??"No project"}),a.jsx(Ss,{size:12})]}),a.jsx("div",{className:"chat-topbar-spacer"}),a.jsxs("button",{type:"button",className:`chat-topbar-btn ${n?"active":""}`,onClick:i,"aria-pressed":n,children:["Sessions (",t,")"]}),a.jsx("button",{type:"button",className:`chat-topbar-btn ${r?"active":""}`,onClick:l,"aria-pressed":r,children:"Info"})]})}function Ix({icon:e,title:t,message:n,action:r}){return a.jsxs("div",{className:"chat-empty-state",children:[e&&a.jsx("div",{className:"chat-empty-state-icon",children:e}),a.jsx("h2",{className:"chat-empty-state-title",children:t}),a.jsx("p",{className:"chat-empty-state-message",children:n}),r&&a.jsx("div",{className:"chat-empty-state-action",children:r})]})}function zx({count:e=3}){return a.jsx("div",{className:"chat-loading-skeleton","aria-label":"Loading messages",children:Array.from({length:e}).map((t,n)=>a.jsxs("div",{className:"chat-loading-skeleton-bubble",children:[a.jsx("div",{className:"chat-loading-skeleton-meta"}),a.jsx("div",{className:"chat-loading-skeleton-line"}),a.jsx("div",{className:"chat-loading-skeleton-line short"})]},n))})}function Px({projectName:e,onPickSuggestion:t}){const n=[{icon:a.jsx(G1,{size:16}),title:e?`Explain ${e}`:"Explain this project",preview:"Give me a tour of the codebase, highlight the architecture, and call out any anti-patterns or hotspots.",prompt:e?`Explain the ${e} project. Give me a tour of the codebase, highlight the architecture, and call out any anti-patterns or hotspots.`:"Explain the current project. Give me a tour of the codebase, highlight the architecture, and call out any anti-patterns or hotspots."},{icon:a.jsx(W1,{size:16}),title:"Summarize recent sessions",preview:"Read my last 5 chat sessions and give me a 3-bullet summary of what I worked on and what got stuck.",prompt:"Read my last 5 chat sessions and give me a 3-bullet summary of what I worked on and what got stuck."},{icon:a.jsx(nx,{size:16}),title:"Suggest a refactor",preview:"Look for the largest, most painful files in this project and propose a concrete refactor for the worst one.",prompt:"Look for the largest, most painful files in this project and propose a concrete refactor for the worst one."},{icon:a.jsx(ex,{size:16}),title:"Find visual regressions",preview:"Open the dashboard, screenshot the Chat tab, and flag any layout problems or anti-patterns you see.",prompt:"Open the dashboard, screenshot the Chat tab, and flag any layout problems or anti-patterns you see."}];return a.jsx("div",{className:"chat-suggestions",children:n.map((r,i)=>a.jsxs("button",{type:"button",className:"chat-suggestion",onClick:()=>t(r.prompt),children:[a.jsxs("div",{className:"chat-suggestion-title",children:[r.icon,a.jsx("span",{children:r.title})]}),a.jsx("div",{className:"chat-suggestion-preview",children:r.preview})]},i))})}function yd({variant:e,projectName:t,onPickSuggestion:n}){if(e==="no-project")return a.jsxs("div",{className:"chat-welcome",children:[a.jsx("h1",{className:"chat-welcome-h1",children:a.jsx("span",{className:"chat-greeting-hello",children:"No project selected."})}),a.jsx("p",{className:"chat-welcome-subtitle",children:"Pick a project in Overview to scope chat sessions."})]});const r=t||"there";return a.jsxs("div",{className:"chat-welcome",children:[a.jsxs("h1",{className:"chat-welcome-h1",children:[a.jsx("span",{className:"chat-greeting-hello",children:"Hello, "}),a.jsxs("span",{className:"chat-greeting-name",children:[r,"."]})]}),a.jsx("p",{className:"chat-welcome-subtitle",children:"How can I help you today?"}),a.jsx(Px,{projectName:t,onPickSuggestion:n})]})}function Ax(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const Mx=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Lx=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Rx={};function xd(e,t){return(Rx.jsx?Lx:Mx).test(e)}const Dx=/[ \t\n\f\r]/g;function _x(e){return typeof e=="object"?e.type==="text"?vd(e.value):!1:vd(e)}function vd(e){return e.replace(Dx,"")===""}class _i{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}_i.prototype.normal={};_i.prototype.property={};_i.prototype.space=void 0;function Qm(e,t){const n={},r={};for(const i of e)Object.assign(n,i.property),Object.assign(r,i.normal);return new _i(n,r,t)}function ba(e){return e.toLowerCase()}class ct{constructor(t,n){this.attribute=n,this.property=t}}ct.prototype.attribute="";ct.prototype.booleanish=!1;ct.prototype.boolean=!1;ct.prototype.commaOrSpaceSeparated=!1;ct.prototype.commaSeparated=!1;ct.prototype.defined=!1;ct.prototype.mustUseProperty=!1;ct.prototype.number=!1;ct.prototype.overloadedBoolean=!1;ct.prototype.property="";ct.prototype.spaceSeparated=!1;ct.prototype.space=void 0;let Ox=0;const ne=Jn(),Re=Jn(),Sa=Jn(),$=Jn(),ve=Jn(),Bn=Jn(),ft=Jn();function Jn(){return 2**++Ox}const Ca=Object.freeze(Object.defineProperty({__proto__:null,boolean:ne,booleanish:Re,commaOrSpaceSeparated:ft,commaSeparated:Bn,number:$,overloadedBoolean:Sa,spaceSeparated:ve},Symbol.toStringTag,{value:"Module"})),ao=Object.keys(Ca);class Lu extends ct{constructor(t,n,r,i){let l=-1;if(super(t,n),kd(this,"space",i),typeof r=="number")for(;++l<ao.length;){const s=ao[l];kd(this,ao[l],(r&Ca[s])===Ca[s])}}}Lu.prototype.defined=!0;function kd(e,t,n){n&&(e[t]=n)}function Or(e){const t={},n={};for(const[r,i]of Object.entries(e.properties)){const l=new Lu(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(l.mustUseProperty=!0),t[r]=l,n[ba(r)]=r,n[ba(l.attribute)]=r}return new _i(t,n,e.space)}const qm=Or({properties:{ariaActiveDescendant:null,ariaAtomic:Re,ariaAutoComplete:null,ariaBusy:Re,ariaChecked:Re,ariaColCount:$,ariaColIndex:$,ariaColSpan:$,ariaControls:ve,ariaCurrent:null,ariaDescribedBy:ve,ariaDetails:null,ariaDisabled:Re,ariaDropEffect:ve,ariaErrorMessage:null,ariaExpanded:Re,ariaFlowTo:ve,ariaGrabbed:Re,ariaHasPopup:null,ariaHidden:Re,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:ve,ariaLevel:$,ariaLive:null,ariaModal:Re,ariaMultiLine:Re,ariaMultiSelectable:Re,ariaOrientation:null,ariaOwns:ve,ariaPlaceholder:null,ariaPosInSet:$,ariaPressed:Re,ariaReadOnly:Re,ariaRelevant:null,ariaRequired:Re,ariaRoleDescription:ve,ariaRowCount:$,ariaRowIndex:$,ariaRowSpan:$,ariaSelected:Re,ariaSetSize:$,ariaSort:null,ariaValueMax:$,ariaValueMin:$,ariaValueNow:$,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function Ym(e,t){return t in e?e[t]:t}function Km(e,t){return Ym(e,t.toLowerCase())}const Fx=Or({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Bn,acceptCharset:ve,accessKey:ve,action:null,allow:null,allowFullScreen:ne,allowPaymentRequest:ne,allowUserMedia:ne,alpha:ne,alt:null,as:null,async:ne,autoCapitalize:null,autoComplete:ve,autoFocus:ne,autoPlay:ne,blocking:ve,capture:null,charSet:null,checked:ne,cite:null,className:ve,closedBy:null,colorSpace:null,cols:$,colSpan:$,command:null,commandFor:null,content:null,contentEditable:Re,controls:ne,controlsList:ve,coords:$|Bn,crossOrigin:null,data:null,dateTime:null,decoding:null,default:ne,defer:ne,dir:null,dirName:null,disabled:ne,download:Sa,draggable:Re,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:ne,formTarget:null,headers:ve,height:$,hidden:Sa,high:$,href:null,hrefLang:null,htmlFor:ve,httpEquiv:ve,id:null,imageSizes:null,imageSrcSet:null,inert:ne,inputMode:null,integrity:null,is:null,isMap:ne,itemId:null,itemProp:ve,itemRef:ve,itemScope:ne,itemType:ve,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:ne,low:$,manifest:null,max:null,maxLength:$,media:null,method:null,min:null,minLength:$,multiple:ne,muted:ne,name:null,nonce:null,noModule:ne,noValidate:ne,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:ne,optimum:$,pattern:null,ping:ve,placeholder:null,playsInline:ne,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:ne,referrerPolicy:null,rel:ve,required:ne,reversed:ne,rows:$,rowSpan:$,sandbox:ve,scope:null,scoped:ne,seamless:ne,selected:ne,shadowRootClonable:ne,shadowRootCustomElementRegistry:ne,shadowRootDelegatesFocus:ne,shadowRootMode:null,shadowRootSerializable:ne,shape:null,size:$,sizes:null,slot:null,span:$,spellCheck:Re,src:null,srcDoc:null,srcLang:null,srcSet:null,start:$,step:null,style:null,tabIndex:$,target:null,title:null,translate:null,type:null,typeMustMatch:ne,useMap:null,value:Re,width:$,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:ve,axis:null,background:null,bgColor:null,border:$,borderColor:null,bottomMargin:$,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:ne,declare:ne,event:null,face:null,frame:null,frameBorder:null,hSpace:$,leftMargin:$,link:null,longDesc:null,lowSrc:null,marginHeight:$,marginWidth:$,noResize:ne,noHref:ne,noShade:ne,noWrap:ne,object:null,profile:null,prompt:null,rev:null,rightMargin:$,rules:null,scheme:null,scrolling:Re,standby:null,summary:null,text:null,topMargin:$,valueType:null,version:null,vAlign:null,vLink:null,vSpace:$,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:ne,disablePictureInPicture:ne,disableRemotePlayback:ne,exportParts:Bn,part:ve,prefix:null,property:null,results:$,security:null,unselectable:null},space:"html",transform:Km}),$x=Or({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",maskType:"mask-type",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:ft,accentHeight:$,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:$,amplitude:$,arabicForm:null,ascent:$,attributeName:null,attributeType:null,azimuth:$,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:$,by:null,calcMode:null,capHeight:$,className:ve,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:$,diffuseConstant:$,direction:null,display:null,dur:null,divisor:$,dominantBaseline:null,download:ne,dx:null,dy:null,edgeMode:null,editable:null,elevation:$,enableBackground:null,end:null,event:null,exponent:$,externalResourcesRequired:null,fill:null,fillOpacity:$,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:Bn,g2:Bn,glyphName:Bn,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:$,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:$,horizOriginX:$,horizOriginY:$,id:null,ideographic:$,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:$,k:$,k1:$,k2:$,k3:$,k4:$,kernelMatrix:ft,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:$,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskType:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:$,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:$,overlineThickness:$,paintOrder:null,panose1:null,path:null,pathLength:$,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:ve,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:$,pointsAtY:$,pointsAtZ:$,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:ft,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:ft,rev:ft,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:ft,requiredFeatures:ft,requiredFonts:ft,requiredFormats:ft,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:$,specularExponent:$,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:$,strikethroughThickness:$,string:null,stroke:null,strokeDashArray:ft,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:$,strokeOpacity:$,strokeWidth:null,style:null,surfaceScale:$,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:ft,tabIndex:$,tableValues:null,target:null,targetX:$,targetY:$,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:ft,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:$,underlineThickness:$,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:$,values:null,vAlphabetic:$,vMathematical:$,vectorEffect:null,vHanging:$,vIdeographic:$,version:null,vertAdvY:$,vertOriginX:$,vertOriginY:$,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:$,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:Ym}),Gm=Or({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),Xm=Or({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:Km}),Zm=Or({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),Bx={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},Ux=/[A-Z]/g,wd=/-[a-z]/g,Hx=/^data[-\w.:]+$/i;function Vx(e,t){const n=ba(t);let r=t,i=ct;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&Hx.test(t)){if(t.charAt(4)==="-"){const l=t.slice(5).replace(wd,Qx);r="data"+l.charAt(0).toUpperCase()+l.slice(1)}else{const l=t.slice(4);if(!wd.test(l)){let s=l.replace(Ux,Wx);s.charAt(0)!=="-"&&(s="-"+s),t="data"+s}}i=Lu}return new i(r,t)}function Wx(e){return"-"+e.toLowerCase()}function Qx(e){return e.charAt(1).toUpperCase()}const qx=Qm([qm,Fx,Gm,Xm,Zm],"html"),Ru=Qm([qm,$x,Gm,Xm,Zm],"svg");function Yx(e){return e.join(" ").trim()}var Du={},bd=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,Kx=/\n/g,Gx=/^\s*/,Xx=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,Zx=/^:\s*/,Jx=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,ev=/^[;\s]*/,tv=/^\s+|\s+$/g,nv=`
|
|
316
316
|
`,Sd="/",Cd="*",Ln="",rv="comment",iv="declaration";function lv(e,t){if(typeof e!="string")throw new TypeError("First argument must be a string");if(!e)return[];t=t||{};var n=1,r=1;function i(p){var x=p.match(Kx);x&&(n+=x.length);var b=p.lastIndexOf(nv);r=~b?p.length-b:r+p.length}function l(){var p={line:n,column:r};return function(x){return x.position=new s(p),d(),x}}function s(p){this.start=p,this.end={line:n,column:r},this.source=t.source}s.prototype.content=e;function o(p){var x=new Error(t.source+":"+n+":"+r+": "+p);if(x.reason=p,x.filename=t.source,x.line=n,x.column=r,x.source=e,!t.silent)throw x}function u(p){var x=p.exec(e);if(x){var b=x[0];return i(b),e=e.slice(b.length),x}}function d(){u(Gx)}function c(p){var x;for(p=p||[];x=f();)x!==!1&&p.push(x);return p}function f(){var p=l();if(!(Sd!=e.charAt(0)||Cd!=e.charAt(1))){for(var x=2;Ln!=e.charAt(x)&&(Cd!=e.charAt(x)||Sd!=e.charAt(x+1));)++x;if(x+=2,Ln===e.charAt(x-1))return o("End of comment missing");var b=e.slice(2,x-2);return r+=2,i(b),e=e.slice(x),r+=2,p({type:rv,comment:b})}}function m(){var p=l(),x=u(Xx);if(x){if(f(),!u(Zx))return o("property missing ':'");var b=u(Jx),y=p({type:iv,property:jd(x[0].replace(bd,Ln)),value:b?jd(b[0].replace(bd,Ln)):Ln});return u(ev),y}}function h(){var p=[];c(p);for(var x;x=m();)x!==!1&&(p.push(x),c(p));return p}return d(),h()}function jd(e){return e?e.replace(tv,Ln):Ln}var sv=lv,ov=El&&El.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Du,"__esModule",{value:!0});Du.default=uv;const av=ov(sv);function uv(e,t){let n=null;if(!e||typeof e!="string")return n;const r=(0,av.default)(e),i=typeof t=="function";return r.forEach(l=>{if(l.type!=="declaration")return;const{property:s,value:o}=l;i?t(s,o,l):o&&(n=n||{},n[s]=o)}),n}var Cs={};Object.defineProperty(Cs,"__esModule",{value:!0});Cs.camelCase=void 0;var cv=/^--[a-zA-Z0-9_-]+$/,dv=/-([a-z])/g,fv=/^[^-]+$/,hv=/^-(webkit|moz|ms|o|khtml)-/,mv=/^-(ms)-/,pv=function(e){return!e||fv.test(e)||cv.test(e)},gv=function(e,t){return t.toUpperCase()},Nd=function(e,t){return"".concat(t,"-")},yv=function(e,t){return t===void 0&&(t={}),pv(e)?e:(e=e.toLowerCase(),t.reactCompat?e=e.replace(mv,Nd):e=e.replace(hv,Nd),e.replace(dv,gv))};Cs.camelCase=yv;var xv=El&&El.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},vv=xv(Du),kv=Cs;function ja(e,t){var n={};return!e||typeof e!="string"||(0,vv.default)(e,function(r,i){r&&i&&(n[(0,kv.camelCase)(r,t)]=i)}),n}ja.default=ja;var wv=ja;const bv=Da(wv),Jm=ep("end"),_u=ep("start");function ep(e){return t;function t(n){const r=n&&n.position&&n.position[e]||{};if(typeof r.line=="number"&&r.line>0&&typeof r.column=="number"&&r.column>0)return{line:r.line,column:r.column,offset:typeof r.offset=="number"&&r.offset>-1?r.offset:void 0}}}function Sv(e){const t=_u(e),n=Jm(e);if(t&&n)return{start:t,end:n}}function ci(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?Ed(e.position):"start"in e||"end"in e?Ed(e):"line"in e||"column"in e?Na(e):""}function Na(e){return Td(e&&e.line)+":"+Td(e&&e.column)}function Ed(e){return Na(e&&e.start)+"-"+Na(e&&e.end)}function Td(e){return e&&typeof e=="number"?e:1}class Ge extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let i="",l={},s=!1;if(n&&("line"in n&&"column"in n?l={place:n}:"start"in n&&"end"in n?l={place:n}:"type"in n?l={ancestors:[n],place:n.position}:l={...n}),typeof t=="string"?i=t:!l.cause&&t&&(s=!0,i=t.message,l.cause=t),!l.ruleId&&!l.source&&typeof r=="string"){const u=r.indexOf(":");u===-1?l.ruleId=r:(l.source=r.slice(0,u),l.ruleId=r.slice(u+1))}if(!l.place&&l.ancestors&&l.ancestors){const u=l.ancestors[l.ancestors.length-1];u&&(l.place=u.position)}const o=l.place&&"start"in l.place?l.place.start:l.place;this.ancestors=l.ancestors||void 0,this.cause=l.cause||void 0,this.column=o?o.column:void 0,this.fatal=void 0,this.file="",this.message=i,this.line=o?o.line:void 0,this.name=ci(l.place)||"1:1",this.place=l.place||void 0,this.reason=this.message,this.ruleId=l.ruleId||void 0,this.source=l.source||void 0,this.stack=s&&l.cause&&typeof l.cause.stack=="string"?l.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}Ge.prototype.file="";Ge.prototype.name="";Ge.prototype.reason="";Ge.prototype.message="";Ge.prototype.stack="";Ge.prototype.column=void 0;Ge.prototype.line=void 0;Ge.prototype.ancestors=void 0;Ge.prototype.cause=void 0;Ge.prototype.fatal=void 0;Ge.prototype.place=void 0;Ge.prototype.ruleId=void 0;Ge.prototype.source=void 0;const Ou={}.hasOwnProperty,Cv=new Map,jv=/[A-Z]/g,Nv=new Set(["table","tbody","thead","tfoot","tr"]),Ev=new Set(["td","th"]),tp="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function Tv(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let r;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");r=Dv(n,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");r=Rv(n,t.jsx,t.jsxs)}const i={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?Ru:qx,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},l=np(i,e,void 0);return l&&typeof l!="string"?l:i.create(e,i.Fragment,{children:l||void 0},void 0)}function np(e,t,n){if(t.type==="element")return Iv(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return zv(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return Av(e,t,n);if(t.type==="mdxjsEsm")return Pv(e,t);if(t.type==="root")return Mv(e,t,n);if(t.type==="text")return Lv(e,t)}function Iv(e,t,n){const r=e.schema;let i=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(i=Ru,e.schema=i),e.ancestors.push(t);const l=ip(e,t.tagName,!1),s=_v(e,t);let o=$u(e,t);return Nv.has(t.tagName)&&(o=o.filter(function(u){return typeof u=="string"?!_x(u):!0})),rp(e,s,l,t),Fu(s,o),e.ancestors.pop(),e.schema=r,e.create(t,l,s,n)}function zv(e,t){if(t.data&&t.data.estree&&e.evaluater){const r=t.data.estree.body[0];return r.type,e.evaluater.evaluateExpression(r.expression)}zi(e,t.position)}function Pv(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);zi(e,t.position)}function Av(e,t,n){const r=e.schema;let i=r;t.name==="svg"&&r.space==="html"&&(i=Ru,e.schema=i),e.ancestors.push(t);const l=t.name===null?e.Fragment:ip(e,t.name,!0),s=Ov(e,t),o=$u(e,t);return rp(e,s,l,t),Fu(s,o),e.ancestors.pop(),e.schema=r,e.create(t,l,s,n)}function Mv(e,t,n){const r={};return Fu(r,$u(e,t)),e.create(t,e.Fragment,r,n)}function Lv(e,t){return t.value}function rp(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function Fu(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function Rv(e,t,n){return r;function r(i,l,s,o){const d=Array.isArray(s.children)?n:t;return o?d(l,s,o):d(l,s)}}function Dv(e,t){return n;function n(r,i,l,s){const o=Array.isArray(l.children),u=_u(r);return t(i,l,s,o,{columnNumber:u?u.column-1:void 0,fileName:e,lineNumber:u?u.line:void 0},void 0)}}function _v(e,t){const n={};let r,i;for(i in t.properties)if(i!=="children"&&Ou.call(t.properties,i)){const l=Fv(e,i,t.properties[i]);if(l){const[s,o]=l;e.tableCellAlignToStyle&&s==="align"&&typeof o=="string"&&Ev.has(t.tagName)?r=o:n[s]=o}}if(r){const l=n.style||(n.style={});l[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function Ov(e,t){const n={};for(const r of t.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&e.evaluater){const l=r.data.estree.body[0];l.type;const s=l.expression;s.type;const o=s.properties[0];o.type,Object.assign(n,e.evaluater.evaluateExpression(o.argument))}else zi(e,t.position);else{const i=r.name;let l;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&e.evaluater){const o=r.value.data.estree.body[0];o.type,l=e.evaluater.evaluateExpression(o.expression)}else zi(e,t.position);else l=r.value===null?!0:r.value;n[i]=l}return n}function $u(e,t){const n=[];let r=-1;const i=e.passKeys?new Map:Cv;for(;++r<t.children.length;){const l=t.children[r];let s;if(e.passKeys){const u=l.type==="element"?l.tagName:l.type==="mdxJsxFlowElement"||l.type==="mdxJsxTextElement"?l.name:void 0;if(u){const d=i.get(u)||0;s=u+"-"+d,i.set(u,d+1)}}const o=np(e,l,s);o!==void 0&&n.push(o)}return n}function Fv(e,t,n){const r=Vx(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?Ax(n):Yx(n)),r.property==="style"){let i=typeof n=="object"?n:$v(e,String(n));return e.stylePropertyNameCase==="css"&&(i=Bv(i)),["style",i]}return[e.elementAttributeNameCase==="react"&&r.space?Bx[r.property]||r.property:r.attribute,n]}}function $v(e,t){try{return bv(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,i=new Ge("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:r,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw i.file=e.filePath||void 0,i.url=tp+"#cannot-parse-style-attribute",i}}function ip(e,t,n){let r;if(!n)r={type:"Literal",value:t};else if(t.includes(".")){const i=t.split(".");let l=-1,s;for(;++l<i.length;){const o=xd(i[l])?{type:"Identifier",name:i[l]}:{type:"Literal",value:i[l]};s=s?{type:"MemberExpression",object:s,property:o,computed:!!(l&&o.type==="Literal"),optional:!1}:o}r=s}else r=xd(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const i=r.value;return Ou.call(e.components,i)?e.components[i]:i}if(e.evaluater)return e.evaluater.evaluateExpression(r);zi(e)}function zi(e,t){const n=new Ge("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=tp+"#cannot-handle-mdx-estrees-without-createevaluater",n}function Bv(e){const t={};let n;for(n in e)Ou.call(e,n)&&(t[Uv(n)]=e[n]);return t}function Uv(e){let t=e.replace(jv,Hv);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function Hv(e){return"-"+e.toLowerCase()}const uo={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},Vv={};function Bu(e,t){const n=Vv,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,i=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return lp(e,r,i)}function lp(e,t,n){if(Wv(e)){if("value"in e)return e.type==="html"&&!n?"":e.value;if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return Id(e.children,t,n)}return Array.isArray(e)?Id(e,t,n):""}function Id(e,t,n){const r=[];let i=-1;for(;++i<e.length;)r[i]=lp(e[i],t,n);return r.join("")}function Wv(e){return!!(e&&typeof e=="object")}const zd=document.createElement("i");function Uu(e){const t="&"+e+";";zd.innerHTML=t;const n=zd.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function gt(e,t,n,r){const i=e.length;let l=0,s;if(t<0?t=-t>i?0:i+t:t=t>i?i:t,n=n>0?n:0,r.length<1e4)s=Array.from(r),s.unshift(t,n),e.splice(...s);else for(n&&e.splice(t,n);l<r.length;)s=r.slice(l,l+1e4),s.unshift(t,0),e.splice(...s),l+=1e4,t+=1e4}function St(e,t){return e.length>0?(gt(e,e.length,0,t),e):t}const Pd={}.hasOwnProperty;function sp(e){const t={};let n=-1;for(;++n<e.length;)Qv(t,e[n]);return t}function Qv(e,t){let n;for(n in t){const i=(Pd.call(e,n)?e[n]:void 0)||(e[n]={}),l=t[n];let s;if(l)for(s in l){Pd.call(i,s)||(i[s]=[]);const o=l[s];qv(i[s],Array.isArray(o)?o:o?[o]:[])}}}function qv(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);gt(e,0,0,r)}function op(e,t){const n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"�":String.fromCodePoint(n)}function Lt(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const Ze=En(/[A-Za-z]/),Ye=En(/[\dA-Za-z]/),Yv=En(/[#-'*+\--9=?A-Z^-~]/);function ns(e){return e!==null&&(e<32||e===127)}const Ea=En(/\d/),Kv=En(/[\dA-Fa-f]/),Gv=En(/[!-/:-@[-`{-~]/);function K(e){return e!==null&&e<-2}function ke(e){return e!==null&&(e<0||e===32)}function ue(e){return e===-2||e===-1||e===32}const js=En(new RegExp("\\p{P}|\\p{S}","u")),Yn=En(/\s/);function En(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function Fr(e){const t=[];let n=-1,r=0,i=0;for(;++n<e.length;){const l=e.charCodeAt(n);let s="";if(l===37&&Ye(e.charCodeAt(n+1))&&Ye(e.charCodeAt(n+2)))i=2;else if(l<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(l))||(s=String.fromCharCode(l));else if(l>55295&&l<57344){const o=e.charCodeAt(n+1);l<56320&&o>56319&&o<57344?(s=String.fromCharCode(l,o),i=1):s="�"}else s=String.fromCharCode(l);s&&(t.push(e.slice(r,n),encodeURIComponent(s)),r=n+i+1,s=""),i&&(n+=i,i=0)}return t.join("")+e.slice(r)}function me(e,t,n,r){const i=r?r-1:Number.POSITIVE_INFINITY;let l=0;return s;function s(u){return ue(u)?(e.enter(n),o(u)):t(u)}function o(u){return ue(u)&&l++<i?(e.consume(u),o):(e.exit(n),t(u))}}const Xv={tokenize:Zv};function Zv(e){const t=e.attempt(this.parser.constructs.contentInitial,r,i);let n;return t;function r(o){if(o===null){e.consume(o);return}return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),me(e,t,"linePrefix")}function i(o){return e.enter("paragraph"),l(o)}function l(o){const u=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=u),n=u,s(o)}function s(o){if(o===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(o);return}return K(o)?(e.consume(o),e.exit("chunkText"),l):(e.consume(o),s)}}const Jv={tokenize:ek},Ad={tokenize:tk};function ek(e){const t=this,n=[];let r=0,i,l,s;return o;function o(v){if(r<n.length){const C=n[r];return t.containerState=C[1],e.attempt(C[0].continuation,u,d)(v)}return d(v)}function u(v){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&g();const C=t.events.length;let z=C,E;for(;z--;)if(t.events[z][0]==="exit"&&t.events[z][1].type==="chunkFlow"){E=t.events[z][1].end;break}y(r);let A=C;for(;A<t.events.length;)t.events[A][1].end={...E},A++;return gt(t.events,z+1,0,t.events.slice(C)),t.events.length=A,d(v)}return o(v)}function d(v){if(r===n.length){if(!i)return m(v);if(i.currentConstruct&&i.currentConstruct.concrete)return p(v);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(Ad,c,f)(v)}function c(v){return i&&g(),y(r),m(v)}function f(v){return t.parser.lazy[t.now().line]=r!==n.length,s=t.now().offset,p(v)}function m(v){return t.containerState={},e.attempt(Ad,h,p)(v)}function h(v){return r++,n.push([t.currentConstruct,t.containerState]),m(v)}function p(v){if(v===null){i&&g(),y(0),e.consume(v);return}return i=i||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:i,contentType:"flow",previous:l}),x(v)}function x(v){if(v===null){b(e.exit("chunkFlow"),!0),y(0),e.consume(v);return}return K(v)?(e.consume(v),b(e.exit("chunkFlow")),r=0,t.interrupt=void 0,o):(e.consume(v),x)}function b(v,C){const z=t.sliceStream(v);if(C&&z.push(null),v.previous=l,l&&(l.next=v),l=v,i.defineSkip(v.start),i.write(z),t.parser.lazy[v.start.line]){let E=i.events.length;for(;E--;)if(i.events[E][1].start.offset<s&&(!i.events[E][1].end||i.events[E][1].end.offset>s))return;const A=t.events.length;let L=A,I,k;for(;L--;)if(t.events[L][0]==="exit"&&t.events[L][1].type==="chunkFlow"){if(I){k=t.events[L][1].end;break}I=!0}for(y(r),E=A;E<t.events.length;)t.events[E][1].end={...k},E++;gt(t.events,L+1,0,t.events.slice(A)),t.events.length=E}}function y(v){let C=n.length;for(;C-- >v;){const z=n[C];t.containerState=z[1],z[0].exit.call(t,e)}n.length=v}function g(){i.write([null]),l=void 0,i=void 0,t.containerState._closeFlow=void 0}}function tk(e,t,n){return me(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Ar(e){if(e===null||ke(e)||Yn(e))return 1;if(js(e))return 2}function Ns(e,t,n){const r=[];let i=-1;for(;++i<e.length;){const l=e[i].resolveAll;l&&!r.includes(l)&&(t=l(t,n),r.push(l))}return t}const Ta={name:"attention",resolveAll:nk,tokenize:rk};function nk(e,t){let n=-1,r,i,l,s,o,u,d,c;for(;++n<e.length;)if(e[n][0]==="enter"&&e[n][1].type==="attentionSequence"&&e[n][1]._close){for(r=n;r--;)if(e[r][0]==="exit"&&e[r][1].type==="attentionSequence"&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;u=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const f={...e[r][1].end},m={...e[n][1].start};Md(f,-u),Md(m,u),s={type:u>1?"strongSequence":"emphasisSequence",start:f,end:{...e[r][1].end}},o={type:u>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:m},l={type:u>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[n][1].start}},i={type:u>1?"strong":"emphasis",start:{...s.start},end:{...o.end}},e[r][1].end={...s.start},e[n][1].start={...o.end},d=[],e[r][1].end.offset-e[r][1].start.offset&&(d=St(d,[["enter",e[r][1],t],["exit",e[r][1],t]])),d=St(d,[["enter",i,t],["enter",s,t],["exit",s,t],["enter",l,t]]),d=St(d,Ns(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),d=St(d,[["exit",l,t],["enter",o,t],["exit",o,t],["exit",i,t]]),e[n][1].end.offset-e[n][1].start.offset?(c=2,d=St(d,[["enter",e[n][1],t],["exit",e[n][1],t]])):c=0,gt(e,r-1,n-r+3,d),n=r+d.length-c-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function rk(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=Ar(r);let l;return s;function s(u){return l=u,e.enter("attentionSequence"),o(u)}function o(u){if(u===l)return e.consume(u),o;const d=e.exit("attentionSequence"),c=Ar(u),f=!c||c===2&&i||n.includes(u),m=!i||i===2&&c||n.includes(r);return d._open=!!(l===42?f:f&&(i||!m)),d._close=!!(l===42?m:m&&(c||!f)),t(u)}}function Md(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const ik={name:"autolink",tokenize:lk};function lk(e,t,n){let r=0;return i;function i(h){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(h),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),l}function l(h){return Ze(h)?(e.consume(h),s):h===64?n(h):d(h)}function s(h){return h===43||h===45||h===46||Ye(h)?(r=1,o(h)):d(h)}function o(h){return h===58?(e.consume(h),r=0,u):(h===43||h===45||h===46||Ye(h))&&r++<32?(e.consume(h),o):(r=0,d(h))}function u(h){return h===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(h),e.exit("autolinkMarker"),e.exit("autolink"),t):h===null||h===32||h===60||ns(h)?n(h):(e.consume(h),u)}function d(h){return h===64?(e.consume(h),c):Yv(h)?(e.consume(h),d):n(h)}function c(h){return Ye(h)?f(h):n(h)}function f(h){return h===46?(e.consume(h),r=0,c):h===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(h),e.exit("autolinkMarker"),e.exit("autolink"),t):m(h)}function m(h){if((h===45||Ye(h))&&r++<63){const p=h===45?m:f;return e.consume(h),p}return n(h)}}const Oi={partial:!0,tokenize:sk};function sk(e,t,n){return r;function r(l){return ue(l)?me(e,i,"linePrefix")(l):i(l)}function i(l){return l===null||K(l)?t(l):n(l)}}const ap={continuation:{tokenize:ak},exit:uk,name:"blockQuote",tokenize:ok};function ok(e,t,n){const r=this;return i;function i(s){if(s===62){const o=r.containerState;return o.open||(e.enter("blockQuote",{_container:!0}),o.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(s),e.exit("blockQuoteMarker"),l}return n(s)}function l(s){return ue(s)?(e.enter("blockQuotePrefixWhitespace"),e.consume(s),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(s))}}function ak(e,t,n){const r=this;return i;function i(s){return ue(s)?me(e,l,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(s):l(s)}function l(s){return e.attempt(ap,t,n)(s)}}function uk(e){e.exit("blockQuote")}const up={name:"characterEscape",tokenize:ck};function ck(e,t,n){return r;function r(l){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(l),e.exit("escapeMarker"),i}function i(l){return Gv(l)?(e.enter("characterEscapeValue"),e.consume(l),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(l)}}const cp={name:"characterReference",tokenize:dk};function dk(e,t,n){const r=this;let i=0,l,s;return o;function o(f){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(f),e.exit("characterReferenceMarker"),u}function u(f){return f===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(f),e.exit("characterReferenceMarkerNumeric"),d):(e.enter("characterReferenceValue"),l=31,s=Ye,c(f))}function d(f){return f===88||f===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(f),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),l=6,s=Kv,c):(e.enter("characterReferenceValue"),l=7,s=Ea,c(f))}function c(f){if(f===59&&i){const m=e.exit("characterReferenceValue");return s===Ye&&!Uu(r.sliceSerialize(m))?n(f):(e.enter("characterReferenceMarker"),e.consume(f),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return s(f)&&i++<l?(e.consume(f),c):n(f)}}const Ld={partial:!0,tokenize:hk},Rd={concrete:!0,name:"codeFenced",tokenize:fk};function fk(e,t,n){const r=this,i={partial:!0,tokenize:z};let l=0,s=0,o;return u;function u(E){return d(E)}function d(E){const A=r.events[r.events.length-1];return l=A&&A[1].type==="linePrefix"?A[2].sliceSerialize(A[1],!0).length:0,o=E,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),c(E)}function c(E){return E===o?(s++,e.consume(E),c):s<3?n(E):(e.exit("codeFencedFenceSequence"),ue(E)?me(e,f,"whitespace")(E):f(E))}function f(E){return E===null||K(E)?(e.exit("codeFencedFence"),r.interrupt?t(E):e.check(Ld,x,C)(E)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),m(E))}function m(E){return E===null||K(E)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),f(E)):ue(E)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),me(e,h,"whitespace")(E)):E===96&&E===o?n(E):(e.consume(E),m)}function h(E){return E===null||K(E)?f(E):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),p(E))}function p(E){return E===null||K(E)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),f(E)):E===96&&E===o?n(E):(e.consume(E),p)}function x(E){return e.attempt(i,C,b)(E)}function b(E){return e.enter("lineEnding"),e.consume(E),e.exit("lineEnding"),y}function y(E){return l>0&&ue(E)?me(e,g,"linePrefix",l+1)(E):g(E)}function g(E){return E===null||K(E)?e.check(Ld,x,C)(E):(e.enter("codeFlowValue"),v(E))}function v(E){return E===null||K(E)?(e.exit("codeFlowValue"),g(E)):(e.consume(E),v)}function C(E){return e.exit("codeFenced"),t(E)}function z(E,A,L){let I=0;return k;function k(W){return E.enter("lineEnding"),E.consume(W),E.exit("lineEnding"),j}function j(W){return E.enter("codeFencedFence"),ue(W)?me(E,P,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(W):P(W)}function P(W){return W===o?(E.enter("codeFencedFenceSequence"),B(W)):L(W)}function B(W){return W===o?(I++,E.consume(W),B):I>=s?(E.exit("codeFencedFenceSequence"),ue(W)?me(E,O,"whitespace")(W):O(W)):L(W)}function O(W){return W===null||K(W)?(E.exit("codeFencedFence"),A(W)):L(W)}}}function hk(e,t,n){const r=this;return i;function i(s){return s===null?n(s):(e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),l)}function l(s){return r.parser.lazy[r.now().line]?n(s):t(s)}}const co={name:"codeIndented",tokenize:pk},mk={partial:!0,tokenize:gk};function pk(e,t,n){const r=this;return i;function i(d){return e.enter("codeIndented"),me(e,l,"linePrefix",5)(d)}function l(d){const c=r.events[r.events.length-1];return c&&c[1].type==="linePrefix"&&c[2].sliceSerialize(c[1],!0).length>=4?s(d):n(d)}function s(d){return d===null?u(d):K(d)?e.attempt(mk,s,u)(d):(e.enter("codeFlowValue"),o(d))}function o(d){return d===null||K(d)?(e.exit("codeFlowValue"),s(d)):(e.consume(d),o)}function u(d){return e.exit("codeIndented"),t(d)}}function gk(e,t,n){const r=this;return i;function i(s){return r.parser.lazy[r.now().line]?n(s):K(s)?(e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),i):me(e,l,"linePrefix",5)(s)}function l(s){const o=r.events[r.events.length-1];return o&&o[1].type==="linePrefix"&&o[2].sliceSerialize(o[1],!0).length>=4?t(s):K(s)?i(s):n(s)}}const yk={name:"codeText",previous:vk,resolve:xk,tokenize:kk};function xk(e){let t=e.length-4,n=3,r,i;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(r=n;++r<t;)if(e[r][1].type==="codeTextData"){e[n][1].type="codeTextPadding",e[t][1].type="codeTextPadding",n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!=="lineEnding"&&(i=r):(r===t||e[r][1].type==="lineEnding")&&(e[i][1].type="codeTextData",r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function vk(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function kk(e,t,n){let r=0,i,l;return s;function s(f){return e.enter("codeText"),e.enter("codeTextSequence"),o(f)}function o(f){return f===96?(e.consume(f),r++,o):(e.exit("codeTextSequence"),u(f))}function u(f){return f===null?n(f):f===32?(e.enter("space"),e.consume(f),e.exit("space"),u):f===96?(l=e.enter("codeTextSequence"),i=0,c(f)):K(f)?(e.enter("lineEnding"),e.consume(f),e.exit("lineEnding"),u):(e.enter("codeTextData"),d(f))}function d(f){return f===null||f===32||f===96||K(f)?(e.exit("codeTextData"),u(f)):(e.consume(f),d)}function c(f){return f===96?(e.consume(f),i++,c):i===r?(e.exit("codeTextSequence"),e.exit("codeText"),t(f)):(l.type="codeTextData",d(f))}}class wk{constructor(t){this.left=t?[...t]:[],this.right=[]}get(t){if(t<0||t>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return t<this.left.length?this.left[t]:this.right[this.right.length-t+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(t,n){const r=n??Number.POSITIVE_INFINITY;return r<this.left.length?this.left.slice(t,r):t>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(t,n,r){const i=n||0;this.setCursor(Math.trunc(t));const l=this.right.splice(this.right.length-i,Number.POSITIVE_INFINITY);return r&&Yr(this.left,r),l.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),Yr(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),Yr(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t<this.left.length){const n=this.left.splice(t,Number.POSITIVE_INFINITY);Yr(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);Yr(this.left,n.reverse())}}}function Yr(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function dp(e){const t={};let n=-1,r,i,l,s,o,u,d;const c=new wk(e);for(;++n<c.length;){for(;n in t;)n=t[n];if(r=c.get(n),n&&r[1].type==="chunkFlow"&&c.get(n-1)[1].type==="listItemPrefix"&&(u=r[1]._tokenizer.events,l=0,l<u.length&&u[l][1].type==="lineEndingBlank"&&(l+=2),l<u.length&&u[l][1].type==="content"))for(;++l<u.length&&u[l][1].type!=="content";)u[l][1].type==="chunkText"&&(u[l][1]._isInFirstContentOfListItem=!0,l++);if(r[0]==="enter")r[1].contentType&&(Object.assign(t,bk(c,n)),n=t[n],d=!0);else if(r[1]._container){for(l=n,i=void 0;l--;)if(s=c.get(l),s[1].type==="lineEnding"||s[1].type==="lineEndingBlank")s[0]==="enter"&&(i&&(c.get(i)[1].type="lineEndingBlank"),s[1].type="lineEnding",i=l);else if(!(s[1].type==="linePrefix"||s[1].type==="listItemIndent"))break;i&&(r[1].end={...c.get(i)[1].start},o=c.slice(i,n),o.unshift(r),c.splice(i,n-i+1,o))}}return gt(e,0,Number.POSITIVE_INFINITY,c.slice(0)),!d}function bk(e,t){const n=e.get(t)[1],r=e.get(t)[2];let i=t-1;const l=[];let s=n._tokenizer;s||(s=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(s._contentTypeTextTrailing=!0));const o=s.events,u=[],d={};let c,f,m=-1,h=n,p=0,x=0;const b=[x];for(;h;){for(;e.get(++i)[1]!==h;);l.push(i),h._tokenizer||(c=r.sliceStream(h),h.next||c.push(null),f&&s.defineSkip(h.start),h._isInFirstContentOfListItem&&(s._gfmTasklistFirstContentOfListItem=!0),s.write(c),h._isInFirstContentOfListItem&&(s._gfmTasklistFirstContentOfListItem=void 0)),f=h,h=h.next}for(h=n;++m<o.length;)o[m][0]==="exit"&&o[m-1][0]==="enter"&&o[m][1].type===o[m-1][1].type&&o[m][1].start.line!==o[m][1].end.line&&(x=m+1,b.push(x),h._tokenizer=void 0,h.previous=void 0,h=h.next);for(s.events=[],h?(h._tokenizer=void 0,h.previous=void 0):b.pop(),m=b.length;m--;){const y=o.slice(b[m],b[m+1]),g=l.pop();u.push([g,g+y.length-1]),e.splice(g,2,y)}for(u.reverse(),m=-1;++m<u.length;)d[p+u[m][0]]=p+u[m][1],p+=u[m][1]-u[m][0]-1;return d}const Sk={resolve:jk,tokenize:Nk},Ck={partial:!0,tokenize:Ek};function jk(e){return dp(e),e}function Nk(e,t){let n;return r;function r(o){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),i(o)}function i(o){return o===null?l(o):K(o)?e.check(Ck,s,l)(o):(e.consume(o),i)}function l(o){return e.exit("chunkContent"),e.exit("content"),t(o)}function s(o){return e.consume(o),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,i}}function Ek(e,t,n){const r=this;return i;function i(s){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),me(e,l,"linePrefix")}function l(s){if(s===null||K(s))return n(s);const o=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&o&&o[1].type==="linePrefix"&&o[2].sliceSerialize(o[1],!0).length>=4?t(s):e.interrupt(r.parser.constructs.flow,n,t)(s)}}function fp(e,t,n,r,i,l,s,o,u){const d=u||Number.POSITIVE_INFINITY;let c=0;return f;function f(y){return y===60?(e.enter(r),e.enter(i),e.enter(l),e.consume(y),e.exit(l),m):y===null||y===32||y===41||ns(y)?n(y):(e.enter(r),e.enter(s),e.enter(o),e.enter("chunkString",{contentType:"string"}),x(y))}function m(y){return y===62?(e.enter(l),e.consume(y),e.exit(l),e.exit(i),e.exit(r),t):(e.enter(o),e.enter("chunkString",{contentType:"string"}),h(y))}function h(y){return y===62?(e.exit("chunkString"),e.exit(o),m(y)):y===null||y===60||K(y)?n(y):(e.consume(y),y===92?p:h)}function p(y){return y===60||y===62||y===92?(e.consume(y),h):h(y)}function x(y){return!c&&(y===null||y===41||ke(y))?(e.exit("chunkString"),e.exit(o),e.exit(s),e.exit(r),t(y)):c<d&&y===40?(e.consume(y),c++,x):y===41?(e.consume(y),c--,x):y===null||y===32||y===40||ns(y)?n(y):(e.consume(y),y===92?b:x)}function b(y){return y===40||y===41||y===92?(e.consume(y),x):x(y)}}function hp(e,t,n,r,i,l){const s=this;let o=0,u;return d;function d(h){return e.enter(r),e.enter(i),e.consume(h),e.exit(i),e.enter(l),c}function c(h){return o>999||h===null||h===91||h===93&&!u||h===94&&!o&&"_hiddenFootnoteSupport"in s.parser.constructs?n(h):h===93?(e.exit(l),e.enter(i),e.consume(h),e.exit(i),e.exit(r),t):K(h)?(e.enter("lineEnding"),e.consume(h),e.exit("lineEnding"),c):(e.enter("chunkString",{contentType:"string"}),f(h))}function f(h){return h===null||h===91||h===93||K(h)||o++>999?(e.exit("chunkString"),c(h)):(e.consume(h),u||(u=!ue(h)),h===92?m:f)}function m(h){return h===91||h===92||h===93?(e.consume(h),o++,f):f(h)}}function mp(e,t,n,r,i,l){let s;return o;function o(m){return m===34||m===39||m===40?(e.enter(r),e.enter(i),e.consume(m),e.exit(i),s=m===40?41:m,u):n(m)}function u(m){return m===s?(e.enter(i),e.consume(m),e.exit(i),e.exit(r),t):(e.enter(l),d(m))}function d(m){return m===s?(e.exit(l),u(s)):m===null?n(m):K(m)?(e.enter("lineEnding"),e.consume(m),e.exit("lineEnding"),me(e,d,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),c(m))}function c(m){return m===s||m===null||K(m)?(e.exit("chunkString"),d(m)):(e.consume(m),m===92?f:c)}function f(m){return m===s||m===92?(e.consume(m),c):c(m)}}function di(e,t){let n;return r;function r(i){return K(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),n=!0,r):ue(i)?me(e,r,n?"linePrefix":"lineSuffix")(i):t(i)}}const Tk={name:"definition",tokenize:zk},Ik={partial:!0,tokenize:Pk};function zk(e,t,n){const r=this;let i;return l;function l(h){return e.enter("definition"),s(h)}function s(h){return hp.call(r,e,o,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(h)}function o(h){return i=Lt(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),h===58?(e.enter("definitionMarker"),e.consume(h),e.exit("definitionMarker"),u):n(h)}function u(h){return ke(h)?di(e,d)(h):d(h)}function d(h){return fp(e,c,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(h)}function c(h){return e.attempt(Ik,f,f)(h)}function f(h){return ue(h)?me(e,m,"whitespace")(h):m(h)}function m(h){return h===null||K(h)?(e.exit("definition"),r.parser.defined.push(i),t(h)):n(h)}}function Pk(e,t,n){return r;function r(o){return ke(o)?di(e,i)(o):n(o)}function i(o){return mp(e,l,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(o)}function l(o){return ue(o)?me(e,s,"whitespace")(o):s(o)}function s(o){return o===null||K(o)?t(o):n(o)}}const Ak={name:"hardBreakEscape",tokenize:Mk};function Mk(e,t,n){return r;function r(l){return e.enter("hardBreakEscape"),e.consume(l),i}function i(l){return K(l)?(e.exit("hardBreakEscape"),t(l)):n(l)}}const Lk={name:"headingAtx",resolve:Rk,tokenize:Dk};function Rk(e,t){let n=e.length-2,r=3,i,l;return e[r][1].type==="whitespace"&&(r+=2),n-2>r&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(r===n-1||n-4>r&&e[n-2][1].type==="whitespace")&&(n-=r+1===n?2:4),n>r&&(i={type:"atxHeadingText",start:e[r][1].start,end:e[n][1].end},l={type:"chunkText",start:e[r][1].start,end:e[n][1].end,contentType:"text"},gt(e,r,n-r+1,[["enter",i,t],["enter",l,t],["exit",l,t],["exit",i,t]])),e}function Dk(e,t,n){let r=0;return i;function i(c){return e.enter("atxHeading"),l(c)}function l(c){return e.enter("atxHeadingSequence"),s(c)}function s(c){return c===35&&r++<6?(e.consume(c),s):c===null||ke(c)?(e.exit("atxHeadingSequence"),o(c)):n(c)}function o(c){return c===35?(e.enter("atxHeadingSequence"),u(c)):c===null||K(c)?(e.exit("atxHeading"),t(c)):ue(c)?me(e,o,"whitespace")(c):(e.enter("atxHeadingText"),d(c))}function u(c){return c===35?(e.consume(c),u):(e.exit("atxHeadingSequence"),o(c))}function d(c){return c===null||c===35||ke(c)?(e.exit("atxHeadingText"),o(c)):(e.consume(c),d)}}const _k=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],Dd=["pre","script","style","textarea"],Ok={concrete:!0,name:"htmlFlow",resolveTo:Bk,tokenize:Uk},Fk={partial:!0,tokenize:Vk},$k={partial:!0,tokenize:Hk};function Bk(e){let t=e.length;for(;t--&&!(e[t][0]==="enter"&&e[t][1].type==="htmlFlow"););return t>1&&e[t-2][1].type==="linePrefix"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function Uk(e,t,n){const r=this;let i,l,s,o,u;return d;function d(N){return c(N)}function c(N){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(N),f}function f(N){return N===33?(e.consume(N),m):N===47?(e.consume(N),l=!0,x):N===63?(e.consume(N),i=3,r.interrupt?t:S):Ze(N)?(e.consume(N),s=String.fromCharCode(N),b):n(N)}function m(N){return N===45?(e.consume(N),i=2,h):N===91?(e.consume(N),i=5,o=0,p):Ze(N)?(e.consume(N),i=4,r.interrupt?t:S):n(N)}function h(N){return N===45?(e.consume(N),r.interrupt?t:S):n(N)}function p(N){const ge="CDATA[";return N===ge.charCodeAt(o++)?(e.consume(N),o===ge.length?r.interrupt?t:P:p):n(N)}function x(N){return Ze(N)?(e.consume(N),s=String.fromCharCode(N),b):n(N)}function b(N){if(N===null||N===47||N===62||ke(N)){const ge=N===47,Le=s.toLowerCase();return!ge&&!l&&Dd.includes(Le)?(i=1,r.interrupt?t(N):P(N)):_k.includes(s.toLowerCase())?(i=6,ge?(e.consume(N),y):r.interrupt?t(N):P(N)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(N):l?g(N):v(N))}return N===45||Ye(N)?(e.consume(N),s+=String.fromCharCode(N),b):n(N)}function y(N){return N===62?(e.consume(N),r.interrupt?t:P):n(N)}function g(N){return ue(N)?(e.consume(N),g):k(N)}function v(N){return N===47?(e.consume(N),k):N===58||N===95||Ze(N)?(e.consume(N),C):ue(N)?(e.consume(N),v):k(N)}function C(N){return N===45||N===46||N===58||N===95||Ye(N)?(e.consume(N),C):z(N)}function z(N){return N===61?(e.consume(N),E):ue(N)?(e.consume(N),z):v(N)}function E(N){return N===null||N===60||N===61||N===62||N===96?n(N):N===34||N===39?(e.consume(N),u=N,A):ue(N)?(e.consume(N),E):L(N)}function A(N){return N===u?(e.consume(N),u=null,I):N===null||K(N)?n(N):(e.consume(N),A)}function L(N){return N===null||N===34||N===39||N===47||N===60||N===61||N===62||N===96||ke(N)?z(N):(e.consume(N),L)}function I(N){return N===47||N===62||ue(N)?v(N):n(N)}function k(N){return N===62?(e.consume(N),j):n(N)}function j(N){return N===null||K(N)?P(N):ue(N)?(e.consume(N),j):n(N)}function P(N){return N===45&&i===2?(e.consume(N),de):N===60&&i===1?(e.consume(N),ee):N===62&&i===4?(e.consume(N),Y):N===63&&i===3?(e.consume(N),S):N===93&&i===5?(e.consume(N),V):K(N)&&(i===6||i===7)?(e.exit("htmlFlowData"),e.check(Fk,ie,B)(N)):N===null||K(N)?(e.exit("htmlFlowData"),B(N)):(e.consume(N),P)}function B(N){return e.check($k,O,ie)(N)}function O(N){return e.enter("lineEnding"),e.consume(N),e.exit("lineEnding"),W}function W(N){return N===null||K(N)?B(N):(e.enter("htmlFlowData"),P(N))}function de(N){return N===45?(e.consume(N),S):P(N)}function ee(N){return N===47?(e.consume(N),s="",R):P(N)}function R(N){if(N===62){const ge=s.toLowerCase();return Dd.includes(ge)?(e.consume(N),Y):P(N)}return Ze(N)&&s.length<8?(e.consume(N),s+=String.fromCharCode(N),R):P(N)}function V(N){return N===93?(e.consume(N),S):P(N)}function S(N){return N===62?(e.consume(N),Y):N===45&&i===2?(e.consume(N),S):P(N)}function Y(N){return N===null||K(N)?(e.exit("htmlFlowData"),ie(N)):(e.consume(N),Y)}function ie(N){return e.exit("htmlFlow"),t(N)}}function Hk(e,t,n){const r=this;return i;function i(s){return K(s)?(e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),l):n(s)}function l(s){return r.parser.lazy[r.now().line]?n(s):t(s)}}function Vk(e,t,n){return r;function r(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),e.attempt(Oi,t,n)}}const Wk={name:"htmlText",tokenize:Qk};function Qk(e,t,n){const r=this;let i,l,s;return o;function o(S){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(S),u}function u(S){return S===33?(e.consume(S),d):S===47?(e.consume(S),z):S===63?(e.consume(S),v):Ze(S)?(e.consume(S),L):n(S)}function d(S){return S===45?(e.consume(S),c):S===91?(e.consume(S),l=0,p):Ze(S)?(e.consume(S),g):n(S)}function c(S){return S===45?(e.consume(S),h):n(S)}function f(S){return S===null?n(S):S===45?(e.consume(S),m):K(S)?(s=f,ee(S)):(e.consume(S),f)}function m(S){return S===45?(e.consume(S),h):f(S)}function h(S){return S===62?de(S):S===45?m(S):f(S)}function p(S){const Y="CDATA[";return S===Y.charCodeAt(l++)?(e.consume(S),l===Y.length?x:p):n(S)}function x(S){return S===null?n(S):S===93?(e.consume(S),b):K(S)?(s=x,ee(S)):(e.consume(S),x)}function b(S){return S===93?(e.consume(S),y):x(S)}function y(S){return S===62?de(S):S===93?(e.consume(S),y):x(S)}function g(S){return S===null||S===62?de(S):K(S)?(s=g,ee(S)):(e.consume(S),g)}function v(S){return S===null?n(S):S===63?(e.consume(S),C):K(S)?(s=v,ee(S)):(e.consume(S),v)}function C(S){return S===62?de(S):v(S)}function z(S){return Ze(S)?(e.consume(S),E):n(S)}function E(S){return S===45||Ye(S)?(e.consume(S),E):A(S)}function A(S){return K(S)?(s=A,ee(S)):ue(S)?(e.consume(S),A):de(S)}function L(S){return S===45||Ye(S)?(e.consume(S),L):S===47||S===62||ke(S)?I(S):n(S)}function I(S){return S===47?(e.consume(S),de):S===58||S===95||Ze(S)?(e.consume(S),k):K(S)?(s=I,ee(S)):ue(S)?(e.consume(S),I):de(S)}function k(S){return S===45||S===46||S===58||S===95||Ye(S)?(e.consume(S),k):j(S)}function j(S){return S===61?(e.consume(S),P):K(S)?(s=j,ee(S)):ue(S)?(e.consume(S),j):I(S)}function P(S){return S===null||S===60||S===61||S===62||S===96?n(S):S===34||S===39?(e.consume(S),i=S,B):K(S)?(s=P,ee(S)):ue(S)?(e.consume(S),P):(e.consume(S),O)}function B(S){return S===i?(e.consume(S),i=void 0,W):S===null?n(S):K(S)?(s=B,ee(S)):(e.consume(S),B)}function O(S){return S===null||S===34||S===39||S===60||S===61||S===96?n(S):S===47||S===62||ke(S)?I(S):(e.consume(S),O)}function W(S){return S===47||S===62||ke(S)?I(S):n(S)}function de(S){return S===62?(e.consume(S),e.exit("htmlTextData"),e.exit("htmlText"),t):n(S)}function ee(S){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(S),e.exit("lineEnding"),R}function R(S){return ue(S)?me(e,V,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(S):V(S)}function V(S){return e.enter("htmlTextData"),s(S)}}const Hu={name:"labelEnd",resolveAll:Gk,resolveTo:Xk,tokenize:Zk},qk={tokenize:Jk},Yk={tokenize:e0},Kk={tokenize:t0};function Gk(e){let t=-1;const n=[];for(;++t<e.length;){const r=e[t][1];if(n.push(e[t]),r.type==="labelImage"||r.type==="labelLink"||r.type==="labelEnd"){const i=r.type==="labelImage"?4:2;r.type="data",t+=i}}return e.length!==n.length&>(e,0,e.length,n),e}function Xk(e,t){let n=e.length,r=0,i,l,s,o;for(;n--;)if(i=e[n][1],l){if(i.type==="link"||i.type==="labelLink"&&i._inactive)break;e[n][0]==="enter"&&i.type==="labelLink"&&(i._inactive=!0)}else if(s){if(e[n][0]==="enter"&&(i.type==="labelImage"||i.type==="labelLink")&&!i._balanced&&(l=n,i.type!=="labelLink")){r=2;break}}else i.type==="labelEnd"&&(s=n);const u={type:e[l][1].type==="labelLink"?"link":"image",start:{...e[l][1].start},end:{...e[e.length-1][1].end}},d={type:"label",start:{...e[l][1].start},end:{...e[s][1].end}},c={type:"labelText",start:{...e[l+r+2][1].end},end:{...e[s-2][1].start}};return o=[["enter",u,t],["enter",d,t]],o=St(o,e.slice(l+1,l+r+3)),o=St(o,[["enter",c,t]]),o=St(o,Ns(t.parser.constructs.insideSpan.null,e.slice(l+r+4,s-3),t)),o=St(o,[["exit",c,t],e[s-2],e[s-1],["exit",d,t]]),o=St(o,e.slice(s+1)),o=St(o,[["exit",u,t]]),gt(e,l,e.length,o),e}function Zk(e,t,n){const r=this;let i=r.events.length,l,s;for(;i--;)if((r.events[i][1].type==="labelImage"||r.events[i][1].type==="labelLink")&&!r.events[i][1]._balanced){l=r.events[i][1];break}return o;function o(m){return l?l._inactive?f(m):(s=r.parser.defined.includes(Lt(r.sliceSerialize({start:l.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(m),e.exit("labelMarker"),e.exit("labelEnd"),u):n(m)}function u(m){return m===40?e.attempt(qk,c,s?c:f)(m):m===91?e.attempt(Yk,c,s?d:f)(m):s?c(m):f(m)}function d(m){return e.attempt(Kk,c,f)(m)}function c(m){return t(m)}function f(m){return l._balanced=!0,n(m)}}function Jk(e,t,n){return r;function r(f){return e.enter("resource"),e.enter("resourceMarker"),e.consume(f),e.exit("resourceMarker"),i}function i(f){return ke(f)?di(e,l)(f):l(f)}function l(f){return f===41?c(f):fp(e,s,o,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(f)}function s(f){return ke(f)?di(e,u)(f):c(f)}function o(f){return n(f)}function u(f){return f===34||f===39||f===40?mp(e,d,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(f):c(f)}function d(f){return ke(f)?di(e,c)(f):c(f)}function c(f){return f===41?(e.enter("resourceMarker"),e.consume(f),e.exit("resourceMarker"),e.exit("resource"),t):n(f)}}function e0(e,t,n){const r=this;return i;function i(o){return hp.call(r,e,l,s,"reference","referenceMarker","referenceString")(o)}function l(o){return r.parser.defined.includes(Lt(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(o):n(o)}function s(o){return n(o)}}function t0(e,t,n){return r;function r(l){return e.enter("reference"),e.enter("referenceMarker"),e.consume(l),e.exit("referenceMarker"),i}function i(l){return l===93?(e.enter("referenceMarker"),e.consume(l),e.exit("referenceMarker"),e.exit("reference"),t):n(l)}}const n0={name:"labelStartImage",resolveAll:Hu.resolveAll,tokenize:r0};function r0(e,t,n){const r=this;return i;function i(o){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(o),e.exit("labelImageMarker"),l}function l(o){return o===91?(e.enter("labelMarker"),e.consume(o),e.exit("labelMarker"),e.exit("labelImage"),s):n(o)}function s(o){return o===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(o):t(o)}}const i0={name:"labelStartLink",resolveAll:Hu.resolveAll,tokenize:l0};function l0(e,t,n){const r=this;return i;function i(s){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(s),e.exit("labelMarker"),e.exit("labelLink"),l}function l(s){return s===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(s):t(s)}}const fo={name:"lineEnding",tokenize:s0};function s0(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),me(e,t,"linePrefix")}}const jl={name:"thematicBreak",tokenize:o0};function o0(e,t,n){let r=0,i;return l;function l(d){return e.enter("thematicBreak"),s(d)}function s(d){return i=d,o(d)}function o(d){return d===i?(e.enter("thematicBreakSequence"),u(d)):r>=3&&(d===null||K(d))?(e.exit("thematicBreak"),t(d)):n(d)}function u(d){return d===i?(e.consume(d),r++,u):(e.exit("thematicBreakSequence"),ue(d)?me(e,o,"whitespace")(d):o(d))}}const it={continuation:{tokenize:d0},exit:h0,name:"list",tokenize:c0},a0={partial:!0,tokenize:m0},u0={partial:!0,tokenize:f0};function c0(e,t,n){const r=this,i=r.events[r.events.length-1];let l=i&&i[1].type==="linePrefix"?i[2].sliceSerialize(i[1],!0).length:0,s=0;return o;function o(h){const p=r.containerState.type||(h===42||h===43||h===45?"listUnordered":"listOrdered");if(p==="listUnordered"?!r.containerState.marker||h===r.containerState.marker:Ea(h)){if(r.containerState.type||(r.containerState.type=p,e.enter(p,{_container:!0})),p==="listUnordered")return e.enter("listItemPrefix"),h===42||h===45?e.check(jl,n,d)(h):d(h);if(!r.interrupt||h===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),u(h)}return n(h)}function u(h){return Ea(h)&&++s<10?(e.consume(h),u):(!r.interrupt||s<2)&&(r.containerState.marker?h===r.containerState.marker:h===41||h===46)?(e.exit("listItemValue"),d(h)):n(h)}function d(h){return e.enter("listItemMarker"),e.consume(h),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||h,e.check(Oi,r.interrupt?n:c,e.attempt(a0,m,f))}function c(h){return r.containerState.initialBlankLine=!0,l++,m(h)}function f(h){return ue(h)?(e.enter("listItemPrefixWhitespace"),e.consume(h),e.exit("listItemPrefixWhitespace"),m):n(h)}function m(h){return r.containerState.size=l+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(h)}}function d0(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(Oi,i,l);function i(o){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,me(e,t,"listItemIndent",r.containerState.size+1)(o)}function l(o){return r.containerState.furtherBlankLines||!ue(o)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,s(o)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(u0,t,s)(o))}function s(o){return r.containerState._closeFlow=!0,r.interrupt=void 0,me(e,e.attempt(it,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(o)}}function f0(e,t,n){const r=this;return me(e,i,"listItemIndent",r.containerState.size+1);function i(l){const s=r.events[r.events.length-1];return s&&s[1].type==="listItemIndent"&&s[2].sliceSerialize(s[1],!0).length===r.containerState.size?t(l):n(l)}}function h0(e){e.exit(this.containerState.type)}function m0(e,t,n){const r=this;return me(e,i,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function i(l){const s=r.events[r.events.length-1];return!ue(l)&&s&&s[1].type==="listItemPrefixWhitespace"?t(l):n(l)}}const _d={name:"setextUnderline",resolveTo:p0,tokenize:g0};function p0(e,t){let n=e.length,r,i,l;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){r=n;break}e[n][1].type==="paragraph"&&(i=n)}else e[n][1].type==="content"&&e.splice(n,1),!l&&e[n][1].type==="definition"&&(l=n);const s={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type="setextHeadingText",l?(e.splice(i,0,["enter",s,t]),e.splice(l+1,0,["exit",e[r][1],t]),e[r][1].end={...e[l][1].end}):e[r][1]=s,e.push(["exit",s,t]),e}function g0(e,t,n){const r=this;let i;return l;function l(d){let c=r.events.length,f;for(;c--;)if(r.events[c][1].type!=="lineEnding"&&r.events[c][1].type!=="linePrefix"&&r.events[c][1].type!=="content"){f=r.events[c][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||f)?(e.enter("setextHeadingLine"),i=d,s(d)):n(d)}function s(d){return e.enter("setextHeadingLineSequence"),o(d)}function o(d){return d===i?(e.consume(d),o):(e.exit("setextHeadingLineSequence"),ue(d)?me(e,u,"lineSuffix")(d):u(d))}function u(d){return d===null||K(d)?(e.exit("setextHeadingLine"),t(d)):n(d)}}const y0={tokenize:x0};function x0(e){const t=this,n=e.attempt(Oi,r,e.attempt(this.parser.constructs.flowInitial,i,me(e,e.attempt(this.parser.constructs.flow,i,e.attempt(Sk,i)),"linePrefix")));return n;function r(l){if(l===null){e.consume(l);return}return e.enter("lineEndingBlank"),e.consume(l),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function i(l){if(l===null){e.consume(l);return}return e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const v0={resolveAll:gp()},k0=pp("string"),w0=pp("text");function pp(e){return{resolveAll:gp(e==="text"?b0:void 0),tokenize:t};function t(n){const r=this,i=this.parser.constructs[e],l=n.attempt(i,s,o);return s;function s(c){return d(c)?l(c):o(c)}function o(c){if(c===null){n.consume(c);return}return n.enter("data"),n.consume(c),u}function u(c){return d(c)?(n.exit("data"),l(c)):(n.consume(c),u)}function d(c){if(c===null)return!0;const f=i[c];let m=-1;if(f)for(;++m<f.length;){const h=f[m];if(!h.previous||h.previous.call(r,r.previous))return!0}return!1}}}function gp(e){return t;function t(n,r){let i=-1,l;for(;++i<=n.length;)l===void 0?n[i]&&n[i][1].type==="data"&&(l=i,i++):(!n[i]||n[i][1].type!=="data")&&(i!==l+2&&(n[l][1].end=n[i-1][1].end,n.splice(l+2,i-l-2),i=l+2),l=void 0);return e?e(n,r):n}}function b0(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type==="lineEnding")&&e[n-1][1].type==="data"){const r=e[n-1][1],i=t.sliceStream(r);let l=i.length,s=-1,o=0,u;for(;l--;){const d=i[l];if(typeof d=="string"){for(s=d.length;d.charCodeAt(s-1)===32;)o++,s--;if(s)break;s=-1}else if(d===-2)u=!0,o++;else if(d!==-1){l++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(o=0),o){const d={type:n===e.length||u||o<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:l?s:r.start._bufferIndex+s,_index:r.start._index+l,line:r.end.line,column:r.end.column-o,offset:r.end.offset-o},end:{...r.end}};r.end={...d.start},r.start.offset===r.end.offset?Object.assign(r,d):(e.splice(n,0,["enter",d,t],["exit",d,t]),n+=2)}n++}return e}const S0={42:it,43:it,45:it,48:it,49:it,50:it,51:it,52:it,53:it,54:it,55:it,56:it,57:it,62:ap},C0={91:Tk},j0={[-2]:co,[-1]:co,32:co},N0={35:Lk,42:jl,45:[_d,jl],60:Ok,61:_d,95:jl,96:Rd,126:Rd},E0={38:cp,92:up},T0={[-5]:fo,[-4]:fo,[-3]:fo,33:n0,38:cp,42:Ta,60:[ik,Wk],91:i0,92:[Ak,up],93:Hu,95:Ta,96:yk},I0={null:[Ta,v0]},z0={null:[42,95]},P0={null:[]},A0=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:z0,contentInitial:C0,disable:P0,document:S0,flow:N0,flowInitial:j0,insideSpan:I0,string:E0,text:T0},Symbol.toStringTag,{value:"Module"}));function M0(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const i={},l=[];let s=[],o=[];const u={attempt:A(z),check:A(E),consume:g,enter:v,exit:C,interrupt:A(E,{interrupt:!0})},d={code:null,containerState:{},defineSkip:x,events:[],now:p,parser:e,previous:null,sliceSerialize:m,sliceStream:h,write:f};let c=t.tokenize.call(d,u);return t.resolveAll&&l.push(t),d;function f(j){return s=St(s,j),b(),s[s.length-1]!==null?[]:(L(t,0),d.events=Ns(l,d.events,d),d.events)}function m(j,P){return R0(h(j),P)}function h(j){return L0(s,j)}function p(){const{_bufferIndex:j,_index:P,line:B,column:O,offset:W}=r;return{_bufferIndex:j,_index:P,line:B,column:O,offset:W}}function x(j){i[j.line]=j.column,k()}function b(){let j;for(;r._index<s.length;){const P=s[r._index];if(typeof P=="string")for(j=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===j&&r._bufferIndex<P.length;)y(P.charCodeAt(r._bufferIndex));else y(P)}}function y(j){c=c(j)}function g(j){K(j)?(r.line++,r.column=1,r.offset+=j===-3?2:1,k()):j!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===s[r._index].length&&(r._bufferIndex=-1,r._index++)),d.previous=j}function v(j,P){const B=P||{};return B.type=j,B.start=p(),d.events.push(["enter",B,d]),o.push(B),B}function C(j){const P=o.pop();return P.end=p(),d.events.push(["exit",P,d]),P}function z(j,P){L(j,P.from)}function E(j,P){P.restore()}function A(j,P){return B;function B(O,W,de){let ee,R,V,S;return Array.isArray(O)?ie(O):"tokenize"in O?ie([O]):Y(O);function Y(oe){return Ne;function Ne(H){const te=H!==null&&oe[H],re=H!==null&&oe.null,Se=[...Array.isArray(te)?te:te?[te]:[],...Array.isArray(re)?re:re?[re]:[]];return ie(Se)(H)}}function ie(oe){return ee=oe,R=0,oe.length===0?de:N(oe[R])}function N(oe){return Ne;function Ne(H){return S=I(),V=oe,oe.partial||(d.currentConstruct=oe),oe.name&&d.parser.constructs.disable.null.includes(oe.name)?Le():oe.tokenize.call(P?Object.assign(Object.create(d),P):d,u,ge,Le)(H)}}function ge(oe){return j(V,S),W}function Le(oe){return S.restore(),++R<ee.length?N(ee[R]):de}}}function L(j,P){j.resolveAll&&!l.includes(j)&&l.push(j),j.resolve&>(d.events,P,d.events.length-P,j.resolve(d.events.slice(P),d)),j.resolveTo&&(d.events=j.resolveTo(d.events,d))}function I(){const j=p(),P=d.previous,B=d.currentConstruct,O=d.events.length,W=Array.from(o);return{from:O,restore:de};function de(){r=j,d.previous=P,d.currentConstruct=B,d.events.length=O,o=W,k()}}function k(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function L0(e,t){const n=t.start._index,r=t.start._bufferIndex,i=t.end._index,l=t.end._bufferIndex;let s;if(n===i)s=[e[n].slice(r,l)];else{if(s=e.slice(n,i),r>-1){const o=s[0];typeof o=="string"?s[0]=o.slice(r):s.shift()}l>0&&s.push(e[i].slice(0,l))}return s}function R0(e,t){let n=-1;const r=[];let i;for(;++n<e.length;){const l=e[n];let s;if(typeof l=="string")s=l;else switch(l){case-5:{s="\r";break}case-4:{s=`
|
|
317
317
|
`;break}case-3:{s=`\r
|
|
318
318
|
`;break}case-2:{s=t?" ":" ";break}case-1:{if(!t&&i)continue;s=" ";break}default:s=String.fromCharCode(l)}i=l===-2,r.push(s)}return r.join("")}function D0(e){const r={constructs:sp([A0,...(e||{}).extensions||[]]),content:i(Xv),defined:[],document:i(Jv),flow:i(y0),lazy:{},string:i(k0),text:i(w0)};return r;function i(l){return s;function s(o){return M0(r,l,o)}}}function _0(e){for(;!dp(e););return e}const Od=/[\0\t\n\r]/g;function O0(){let e=1,t="",n=!0,r;return i;function i(l,s,o){const u=[];let d,c,f,m,h;for(l=t+(typeof l=="string"?l.toString():new TextDecoder(s||void 0).decode(l)),f=0,t="",n&&(l.charCodeAt(0)===65279&&f++,n=void 0);f<l.length;){if(Od.lastIndex=f,d=Od.exec(l),m=d&&d.index!==void 0?d.index:l.length,h=l.charCodeAt(m),!d){t=l.slice(f);break}if(h===10&&f===m&&r)u.push(-3),r=void 0;else switch(r&&(u.push(-5),r=void 0),f<m&&(u.push(l.slice(f,m)),e+=m-f),h){case 0:{u.push(65533),e++;break}case 9:{for(c=Math.ceil(e/4)*4,u.push(-2);e++<c;)u.push(-1);break}case 10:{u.push(-4),e=1;break}default:r=!0,e=1}f=m+1}return o&&(r&&u.push(-5),t&&u.push(t),u.push(null)),u}}const F0=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function $0(e){return e.replace(F0,B0)}function B0(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const i=n.charCodeAt(1),l=i===120||i===88;return op(n.slice(l?2:1),l?16:10)}return Uu(n)||e}const yp={}.hasOwnProperty;function U0(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),H0(n)(_0(D0(n).document().write(O0()(e,t,!0))))}function H0(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:l(Ui),autolinkProtocol:I,autolinkEmail:I,atxHeading:l(er),blockQuote:l(re),characterEscape:I,characterReference:I,codeFenced:l(Se),codeFencedFenceInfo:s,codeFencedFenceMeta:s,codeIndented:l(Se,s),codeText:l(Ot,s),codeTextData:I,data:I,codeFlowValue:I,definition:l(ln),definitionDestinationString:s,definitionLabelString:s,definitionTitleString:s,emphasis:l(In),hardBreakEscape:l($i),hardBreakTrailing:l($i),htmlFlow:l(Bi,s),htmlFlowData:I,htmlText:l(Bi,s),htmlTextData:I,image:l(zs),label:s,link:l(Ui),listItem:l(Ps),listItemValue:m,listOrdered:l(Hi,f),listUnordered:l(Hi),paragraph:l(As),reference:N,referenceString:s,resourceDestinationString:s,resourceTitleString:s,setextHeading:l(er),strong:l(Ms),thematicBreak:l(Rs)},exit:{atxHeading:u(),atxHeadingSequence:z,autolink:u(),autolinkEmail:te,autolinkProtocol:H,blockQuote:u(),characterEscapeValue:k,characterReferenceMarkerHexadecimal:Le,characterReferenceMarkerNumeric:Le,characterReferenceValue:oe,characterReference:Ne,codeFenced:u(b),codeFencedFence:x,codeFencedFenceInfo:h,codeFencedFenceMeta:p,codeFlowValue:k,codeIndented:u(y),codeText:u(W),codeTextData:k,data:k,definition:u(),definitionDestinationString:C,definitionLabelString:g,definitionTitleString:v,emphasis:u(),hardBreakEscape:u(P),hardBreakTrailing:u(P),htmlFlow:u(B),htmlFlowData:k,htmlText:u(O),htmlTextData:k,image:u(ee),label:V,labelText:R,lineEnding:j,link:u(de),listItem:u(),listOrdered:u(),listUnordered:u(),paragraph:u(),referenceString:ge,resourceDestinationString:S,resourceTitleString:Y,resource:ie,setextHeading:u(L),setextHeadingLineSequence:A,setextHeadingText:E,strong:u(),thematicBreak:u()}};xp(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(M){let T={type:"root",children:[]};const D={stack:[T],tokenStack:[],config:t,enter:o,exit:d,buffer:s,resume:c,data:n},_=[];let U=-1;for(;++U<M.length;)if(M[U][1].type==="listOrdered"||M[U][1].type==="listUnordered")if(M[U][0]==="enter")_.push(U);else{const G=_.pop();U=i(M,G,U)}for(U=-1;++U<M.length;){const G=t[M[U][0]];yp.call(G,M[U][1].type)&&G[M[U][1].type].call(Object.assign({sliceSerialize:M[U][2].sliceSerialize},D),M[U][1])}if(D.tokenStack.length>0){const G=D.tokenStack[D.tokenStack.length-1];(G[1]||Fd).call(D,void 0,G[0])}for(T.position={start:on(M.length>0?M[0][1].start:{line:1,column:1,offset:0}),end:on(M.length>0?M[M.length-2][1].end:{line:1,column:1,offset:0})},U=-1;++U<t.transforms.length;)T=t.transforms[U](T)||T;return T}function i(M,T,D){let _=T-1,U=-1,G=!1,le,xe,we,X;for(;++_<=D;){const Z=M[_];switch(Z[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{Z[0]==="enter"?U++:U--,X=void 0;break}case"lineEndingBlank":{Z[0]==="enter"&&(le&&!X&&!U&&!we&&(we=_),X=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:X=void 0}if(!U&&Z[0]==="enter"&&Z[1].type==="listItemPrefix"||U===-1&&Z[0]==="exit"&&(Z[1].type==="listUnordered"||Z[1].type==="listOrdered")){if(le){let fe=_;for(xe=void 0;fe--;){const he=M[fe];if(he[1].type==="lineEnding"||he[1].type==="lineEndingBlank"){if(he[0]==="exit")continue;xe&&(M[xe][1].type="lineEndingBlank",G=!0),he[1].type="lineEnding",xe=fe}else if(!(he[1].type==="linePrefix"||he[1].type==="blockQuotePrefix"||he[1].type==="blockQuotePrefixWhitespace"||he[1].type==="blockQuoteMarker"||he[1].type==="listItemIndent"))break}we&&(!xe||we<xe)&&(le._spread=!0),le.end=Object.assign({},xe?M[xe][1].start:Z[1].end),M.splice(xe||_,0,["exit",le,Z[2]]),_++,D++}if(Z[1].type==="listItemPrefix"){const fe={type:"listItem",_spread:!1,start:Object.assign({},Z[1].start),end:void 0};le=fe,M.splice(_,0,["enter",fe,Z[2]]),_++,D++,we=void 0,X=!0}}}return M[T][1]._spread=G,D}function l(M,T){return D;function D(_){o.call(this,M(_),_),T&&T.call(this,_)}}function s(){this.stack.push({type:"fragment",children:[]})}function o(M,T,D){this.stack[this.stack.length-1].children.push(M),this.stack.push(M),this.tokenStack.push([T,D||void 0]),M.position={start:on(T.start),end:void 0}}function u(M){return T;function T(D){M&&M.call(this,D),d.call(this,D)}}function d(M,T){const D=this.stack.pop(),_=this.tokenStack.pop();if(_)_[0].type!==M.type&&(T?T.call(this,M,_[0]):(_[1]||Fd).call(this,M,_[0]));else throw new Error("Cannot close `"+M.type+"` ("+ci({start:M.start,end:M.end})+"): it’s not open");D.position.end=on(M.end)}function c(){return Bu(this.stack.pop())}function f(){this.data.expectingFirstListItemValue=!0}function m(M){if(this.data.expectingFirstListItemValue){const T=this.stack[this.stack.length-2];T.start=Number.parseInt(this.sliceSerialize(M),10),this.data.expectingFirstListItemValue=void 0}}function h(){const M=this.resume(),T=this.stack[this.stack.length-1];T.lang=M}function p(){const M=this.resume(),T=this.stack[this.stack.length-1];T.meta=M}function x(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function b(){const M=this.resume(),T=this.stack[this.stack.length-1];T.value=M.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function y(){const M=this.resume(),T=this.stack[this.stack.length-1];T.value=M.replace(/(\r?\n|\r)$/g,"")}function g(M){const T=this.resume(),D=this.stack[this.stack.length-1];D.label=T,D.identifier=Lt(this.sliceSerialize(M)).toLowerCase()}function v(){const M=this.resume(),T=this.stack[this.stack.length-1];T.title=M}function C(){const M=this.resume(),T=this.stack[this.stack.length-1];T.url=M}function z(M){const T=this.stack[this.stack.length-1];if(!T.depth){const D=this.sliceSerialize(M).length;T.depth=D}}function E(){this.data.setextHeadingSlurpLineEnding=!0}function A(M){const T=this.stack[this.stack.length-1];T.depth=this.sliceSerialize(M).codePointAt(0)===61?1:2}function L(){this.data.setextHeadingSlurpLineEnding=void 0}function I(M){const D=this.stack[this.stack.length-1].children;let _=D[D.length-1];(!_||_.type!=="text")&&(_=Ls(),_.position={start:on(M.start),end:void 0},D.push(_)),this.stack.push(_)}function k(M){const T=this.stack.pop();T.value+=this.sliceSerialize(M),T.position.end=on(M.end)}function j(M){const T=this.stack[this.stack.length-1];if(this.data.atHardBreak){const D=T.children[T.children.length-1];D.position.end=on(M.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(T.type)&&(I.call(this,M),k.call(this,M))}function P(){this.data.atHardBreak=!0}function B(){const M=this.resume(),T=this.stack[this.stack.length-1];T.value=M}function O(){const M=this.resume(),T=this.stack[this.stack.length-1];T.value=M}function W(){const M=this.resume(),T=this.stack[this.stack.length-1];T.value=M}function de(){const M=this.stack[this.stack.length-1];if(this.data.inReference){const T=this.data.referenceType||"shortcut";M.type+="Reference",M.referenceType=T,delete M.url,delete M.title}else delete M.identifier,delete M.label;this.data.referenceType=void 0}function ee(){const M=this.stack[this.stack.length-1];if(this.data.inReference){const T=this.data.referenceType||"shortcut";M.type+="Reference",M.referenceType=T,delete M.url,delete M.title}else delete M.identifier,delete M.label;this.data.referenceType=void 0}function R(M){const T=this.sliceSerialize(M),D=this.stack[this.stack.length-2];D.label=$0(T),D.identifier=Lt(T).toLowerCase()}function V(){const M=this.stack[this.stack.length-1],T=this.resume(),D=this.stack[this.stack.length-1];if(this.data.inReference=!0,D.type==="link"){const _=M.children;D.children=_}else D.alt=T}function S(){const M=this.resume(),T=this.stack[this.stack.length-1];T.url=M}function Y(){const M=this.resume(),T=this.stack[this.stack.length-1];T.title=M}function ie(){this.data.inReference=void 0}function N(){this.data.referenceType="collapsed"}function ge(M){const T=this.resume(),D=this.stack[this.stack.length-1];D.label=T,D.identifier=Lt(this.sliceSerialize(M)).toLowerCase(),this.data.referenceType="full"}function Le(M){this.data.characterReferenceType=M.type}function oe(M){const T=this.sliceSerialize(M),D=this.data.characterReferenceType;let _;D?(_=op(T,D==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):_=Uu(T);const U=this.stack[this.stack.length-1];U.value+=_}function Ne(M){const T=this.stack.pop();T.position.end=on(M.end)}function H(M){k.call(this,M);const T=this.stack[this.stack.length-1];T.url=this.sliceSerialize(M)}function te(M){k.call(this,M);const T=this.stack[this.stack.length-1];T.url="mailto:"+this.sliceSerialize(M)}function re(){return{type:"blockquote",children:[]}}function Se(){return{type:"code",lang:null,meta:null,value:""}}function Ot(){return{type:"inlineCode",value:""}}function ln(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function In(){return{type:"emphasis",children:[]}}function er(){return{type:"heading",depth:0,children:[]}}function $i(){return{type:"break"}}function Bi(){return{type:"html",value:""}}function zs(){return{type:"image",title:null,url:"",alt:null}}function Ui(){return{type:"link",title:null,url:"",children:[]}}function Hi(M){return{type:"list",ordered:M.type==="listOrdered",start:null,spread:M._spread,children:[]}}function Ps(M){return{type:"listItem",spread:M._spread,checked:null,children:[]}}function As(){return{type:"paragraph",children:[]}}function Ms(){return{type:"strong",children:[]}}function Ls(){return{type:"text",value:""}}function Rs(){return{type:"thematicBreak"}}}function on(e){return{line:e.line,column:e.column,offset:e.offset}}function xp(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?xp(e,r):V0(e,r)}}function V0(e,t){let n;for(n in t)if(yp.call(t,n))switch(n){case"canContainEols":{const r=t[n];r&&e[n].push(...r);break}case"transforms":{const r=t[n];r&&e[n].push(...r);break}case"enter":case"exit":{const r=t[n];r&&Object.assign(e[n],r);break}}}function Fd(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+ci({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+ci({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+ci({start:t.start,end:t.end})+") is still open")}function W0(e){const t=this;t.parser=n;function n(r){return U0(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function Q0(e,t){const n={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function q0(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
|
|
@@ -348,5 +348,4 @@ Error generating stack: `+l.message+`
|
|
|
348
348
|
* @license qrcode.react
|
|
349
349
|
* Copyright (c) Paul O'Shannessy
|
|
350
350
|
* SPDX-License-Identifier: ISC
|
|
351
|
-
*/var D2={L:gr.QrCode.Ecc.LOW,M:gr.QrCode.Ecc.MEDIUM,Q:gr.QrCode.Ecc.QUARTILE,H:gr.QrCode.Ecc.HIGH},Jp=128,eg="L",tg="#FFFFFF",ng="#000000",rg=!1,ig=1,_2=4,O2=0,F2=.1;function lg(e,t=0){const n=[];return e.forEach(function(r,i){let l=null;r.forEach(function(s,o){if(!s&&l!==null){n.push(`M${l+t} ${i+t}h${o-l}v1H${l+t}z`),l=null;return}if(o===r.length-1){if(!s)return;l===null?n.push(`M${o+t},${i+t} h1v1H${o+t}z`):n.push(`M${l+t},${i+t} h${o+1-l}v1H${l+t}z`);return}s&&l===null&&(l=o)})}),n.join("")}function sg(e,t){return e.slice().map((n,r)=>r<t.y||r>=t.y+t.h?n:n.map((i,l)=>l<t.x||l>=t.x+t.w?i:!1))}function $2(e,t,n,r){if(r==null)return null;const i=e.length+n*2,l=Math.floor(t*F2),s=i/t,o=(r.width||l)*s,u=(r.height||l)*s,d=r.x==null?e.length/2-o/2:r.x*s,c=r.y==null?e.length/2-u/2:r.y*s,f=r.opacity==null?1:r.opacity;let m=null;if(r.excavate){let p=Math.floor(d),x=Math.floor(c),b=Math.ceil(o+d-p),y=Math.ceil(u+c-x);m={x:p,y:x,w:b,h:y}}const h=r.crossOrigin;return{x:d,y:c,h:u,w:o,excavation:m,opacity:f,crossOrigin:h}}function B2(e,t){return t!=null?Math.max(Math.floor(t),0):e?_2:O2}function og({value:e,level:t,minVersion:n,includeMargin:r,marginSize:i,imageSettings:l,size:s,boostLevel:o}){let u=_e.useMemo(()=>{const p=(Array.isArray(e)?e:[e]).reduce((x,b)=>(x.push(...gr.QrSegment.makeSegments(b)),x),[]);return gr.QrCode.encodeSegments(p,D2[t],n,void 0,void 0,o)},[e,t,n,o]);const{cells:d,margin:c,numCells:f,calculatedImageSettings:m}=_e.useMemo(()=>{let h=u.getModules();const p=B2(r,i),x=h.length+p*2,b=$2(h,s,p,l);return{cells:h,margin:p,numCells:x,calculatedImageSettings:b}},[u,s,l,r,i]);return{qrcode:u,margin:c,cells:d,numCells:f,calculatedImageSettings:m}}var U2=function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0}(),H2=_e.forwardRef(function(t,n){const r=t,{value:i,size:l=Jp,level:s=eg,bgColor:o=tg,fgColor:u=ng,includeMargin:d=rg,minVersion:c=ig,boostLevel:f,marginSize:m,imageSettings:h}=r,x=Ra(r,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:b}=x,y=Ra(x,["style"]),g=h==null?void 0:h.src,v=_e.useRef(null),C=_e.useRef(null),z=_e.useCallback(O=>{v.current=O,typeof n=="function"?n(O):n&&(n.current=O)},[n]),[E,A]=_e.useState(!1),{margin:L,cells:I,numCells:k,calculatedImageSettings:j}=og({value:i,level:s,minVersion:c,boostLevel:f,includeMargin:d,marginSize:m,imageSettings:h,size:l});_e.useEffect(()=>{if(v.current!=null){const O=v.current,W=O.getContext("2d");if(!W)return;let de=I;const ee=C.current,R=j!=null&&ee!==null&&ee.complete&&ee.naturalHeight!==0&&ee.naturalWidth!==0;R&&j.excavation!=null&&(de=sg(I,j.excavation));const V=window.devicePixelRatio||1;O.height=O.width=l*V;const S=l/k*V;W.scale(S,S),W.fillStyle=o,W.fillRect(0,0,k,k),W.fillStyle=u,U2?W.fill(new Path2D(lg(de,L))):I.forEach(function(Y,ie){Y.forEach(function(N,ge){N&&W.fillRect(ge+L,ie+L,1,1)})}),j&&(W.globalAlpha=j.opacity),R&&W.drawImage(ee,j.x+L,j.y+L,j.w,j.h)}}),_e.useEffect(()=>{A(!1)},[g]);const P=La({height:l,width:l},b);let B=null;return g!=null&&(B=_e.createElement("img",{src:g,key:g,style:{display:"none"},onLoad:()=>{A(!0)},ref:C,crossOrigin:j==null?void 0:j.crossOrigin})),_e.createElement(_e.Fragment,null,_e.createElement("canvas",La({style:P,height:l,width:l,ref:z,role:"img"},y)),B)});H2.displayName="QRCodeCanvas";var ag=_e.forwardRef(function(t,n){const r=t,{value:i,size:l=Jp,level:s=eg,bgColor:o=tg,fgColor:u=ng,includeMargin:d=rg,minVersion:c=ig,boostLevel:f,title:m,marginSize:h,imageSettings:p}=r,x=Ra(r,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:b,cells:y,numCells:g,calculatedImageSettings:v}=og({value:i,level:s,minVersion:c,boostLevel:f,includeMargin:d,marginSize:h,imageSettings:p,size:l});let C=y,z=null;p!=null&&v!=null&&(v.excavation!=null&&(C=sg(y,v.excavation)),z=_e.createElement("image",{href:p.src,height:v.h,width:v.w,x:v.x+b,y:v.y+b,preserveAspectRatio:"none",opacity:v.opacity,crossOrigin:v.crossOrigin}));const E=lg(C,b);return _e.createElement("svg",La({height:l,width:l,viewBox:`0 0 ${g} ${g}`,ref:n,role:"img"},x),!!m&&_e.createElement("title",null,m),_e.createElement("path",{fill:o,d:`M0,0 h${g}v${g}H0z`,shapeRendering:"crispEdges"}),_e.createElement("path",{fill:u,d:E,shapeRendering:"crispEdges"}),z)});ag.displayName="QRCodeSVG";function V2({tabs:e,activeTab:t,onChange:n}){return a.jsx("nav",{className:"mobile-bottom-nav",role:"navigation","aria-label":"Mobile navigation",children:e.map(r=>{const i=r.icon;return a.jsxs("button",{type:"button",className:Mu("mobile-nav-btn",t===r.id&&"mobile-nav-btn-active"),onClick:()=>n(r.id),"aria-label":r.label,"aria-current":t===r.id?"page":void 0,children:[a.jsx(i,{size:22}),a.jsx("span",{className:"mobile-nav-label",children:r.label})]},r.id)})})}function Dt({open:e,onClose:t,title:n,children:r,actions:i,maxHeight:l="85vh"}){const s=w.useRef(null),o=w.useRef(null),u=w.useId(),d=w.useRef(null),c=w.useRef(null),f=w.useRef(0),m=w.useRef(0),h=()=>{var y;return((y=s.current)==null?void 0:y.querySelectorAll('button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])'))??[]};if(w.useEffect(()=>{if(!e)return;d.current=document.activeElement instanceof HTMLElement?document.activeElement:null;const y=g=>{var A;if(g.key==="Escape"&&t(),g.key!=="Tab")return;const v=Array.from(h());if(v.length===0){g.preventDefault(),(A=s.current)==null||A.focus();return}const C=v[0],z=v[v.length-1],E=document.activeElement;if(g.shiftKey){(!E||E===C||E===s.current)&&(g.preventDefault(),z==null||z.focus());return}E===z&&(g.preventDefault(),C==null||C.focus())};return window.addEventListener("keydown",y),requestAnimationFrame(()=>{var g,v;((g=o.current)==null?void 0:g.focus())??((v=s.current)==null||v.focus())}),()=>{var g;window.removeEventListener("keydown",y),(g=d.current)==null||g.focus()}},[e,t]),w.useEffect(()=>(e?(m.current=window.scrollY,document.documentElement.style.overflow="hidden",document.body.style.overflow="hidden",document.body.style.position="fixed",document.body.style.top=`-${m.current}px`,document.body.style.left="0",document.body.style.right="0",document.body.style.width="100%"):(document.documentElement.style.overflow="",document.body.style.overflow="",document.body.style.position="",document.body.style.top="",document.body.style.left="",document.body.style.right="",document.body.style.width=""),()=>{document.documentElement.style.overflow="",document.body.style.overflow="",document.body.style.position="",document.body.style.top="",document.body.style.left="",document.body.style.right="",document.body.style.width="",window.scrollTo(0,m.current)}),[e]),!e)return null;const p=y=>{var g;y.isPrimary&&(c.current=y.clientY,f.current=0,(g=s.current)==null||g.setPointerCapture(y.pointerId))},x=y=>{if(c.current==null||!s.current)return;const g=Math.max(0,y.clientY-c.current);f.current=g,s.current.style.transform=`translateY(${g}px)`},b=y=>{if(!s.current)return;y&&s.current.hasPointerCapture(y.pointerId)&&s.current.releasePointerCapture(y.pointerId);const g=f.current;s.current.style.transform="",c.current=null,f.current=0,g>72&&t()};return a.jsx("div",{className:"mobile-sheet-overlay",onClick:t,children:a.jsxs("div",{ref:s,className:"mobile-sheet",style:{maxHeight:l},onClick:y=>y.stopPropagation(),role:"dialog","aria-modal":!0,"aria-label":n?void 0:"Sheet","aria-labelledby":n?u:void 0,tabIndex:-1,children:[a.jsx("div",{className:"mobile-sheet-handle",onPointerDown:p,onPointerMove:x,onPointerUp:b,onPointerCancel:b,"aria-hidden":"true"}),a.jsxs("div",{className:"mobile-sheet-header",children:[n?a.jsx("h3",{id:u,className:"mobile-sheet-title",children:n}):a.jsx("div",{}),a.jsx("button",{ref:o,type:"button",className:"mobile-icon-btn",onClick:t,"aria-label":"Close",children:a.jsx(Zn,{size:18})})]}),a.jsx("div",{className:"mobile-sheet-content",children:r}),i&&a.jsx("div",{className:"mobile-sheet-actions",children:i})]})})}function W2(e){switch(e){case"success":return"✓";case"error":return"✗";case"warning":return"⚠";default:return"ℹ"}}function Q2(e){const t=new Date(e),r=Date.now()-t.getTime();return r<6e4?"just now":r<36e5?`${Math.floor(r/6e4)}m ago`:r<864e5?`${Math.floor(r/36e5)}h ago`:t.toLocaleDateString()}function q2({onSelect:e}){const[t,n]=w.useState(!1),[r,i]=w.useState([]),[l,s]=w.useState(0),o=async()=>{var c;try{const f=await q.get("/notifications");i(f.notifications||[]),s(((c=f.stats)==null?void 0:c.unread)||0)}catch{}};w.useEffect(()=>{o()},[]),w.useEffect(()=>{t&&o()},[t]);const u=async()=>{try{await q.post("/notifications/read-all"),i(c=>c.map(f=>({...f,read:!0}))),s(0)}catch{}},d=async c=>{try{await q.post(`/notifications/${encodeURIComponent(c)}/read`),i(f=>f.map(m=>m.id===c?{...m,read:!0}:m)),s(f=>Math.max(0,f-1))}catch{}};return a.jsxs(a.Fragment,{children:[a.jsxs("button",{type:"button",className:"mobile-icon-btn mobile-notif-btn",onClick:()=>n(!0),"aria-label":`Notifications${l>0?` (${l} unread)`:""}`,children:[a.jsx(cd,{size:20}),l>0&&a.jsx("span",{className:"mobile-notif-badge",children:l>9?"9+":l})]}),a.jsx(Dt,{open:t,onClose:()=>n(!1),title:"Notifications",actions:l>0?a.jsxs("button",{type:"button",className:"mobile-btn mobile-btn-secondary",style:{width:"100%"},onClick:u,children:[a.jsx(Q1,{size:14})," Mark all read"]}):void 0,children:a.jsxs("div",{className:"mobile-notif-list",children:[r.length===0&&a.jsxs("div",{className:"mobile-empty",children:[a.jsx(cd,{size:32}),a.jsx("p",{children:"No notifications"})]}),r.map(c=>a.jsxs("button",{type:"button",className:`mobile-notif-item ${c.read?"read":"unread"}`,onClick:()=>{c.read||d(c.id),e(c),n(!1)},children:[a.jsx("span",{className:`mobile-notif-icon severity-${c.severity}`,children:W2(c.severity)}),a.jsxs("div",{className:"mobile-notif-body",children:[a.jsx("span",{className:"mobile-notif-title",children:c.title||c.message}),c.message&&c.title&&a.jsx("span",{className:"mobile-notif-text",children:c.message}),a.jsx("span",{className:"mobile-notif-time",children:Q2(c.ts)})]}),!c.read&&a.jsx("span",{className:"mobile-notif-dot"})]},c.id))]})})]})}const Y2={activity:"Activity",chat:"Chat",tasks:"Tasks",settings:"Settings",more:"More",plans:"Plans",agents:"Agents",skills:"Skills",mods:"Mods",schedules:"Schedules",history:"History",config:"Config","plan-detail":"Plan","agent-detail":"Agent","task-detail":"Task"};function K2({activeTab:e,snapshot:t,onSearch:n,onNavigate:r}){const[i,l]=w.useState(!1),s=async o=>{try{await q.post(`/projects/${encodeURIComponent(o)}/activate`),l(!1),window.location.reload()}catch{}};return a.jsxs("header",{className:"mobile-topbar",children:[a.jsxs("div",{className:"mobile-topbar-left",children:[a.jsx("span",{className:"mobile-logo",children:"ᛒ"}),(t==null?void 0:t.activeProject)&&a.jsxs("button",{type:"button",className:"mobile-project-btn",onClick:()=>l(!0),"aria-label":"Select project",children:[a.jsx("span",{className:"mobile-project-name",children:t.activeProject.name}),a.jsx(Ss,{size:14})]}),a.jsx("span",{className:"mobile-title",children:Y2[e]||"Bizar"})]}),a.jsxs("div",{className:"mobile-topbar-right",children:[a.jsx("button",{type:"button",className:"mobile-icon-btn",onClick:n,"aria-label":"Search",children:a.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[a.jsx("circle",{cx:"11",cy:"11",r:"8"}),a.jsx("path",{d:"m21 21-4.35-4.35"})]})}),a.jsx(q2,{onSelect:o=>{r("notification",o.link||"",o.meta??null)}}),(t==null?void 0:t.activeProject)&&a.jsx(Dt,{open:i,onClose:()=>l(!1),title:"Projects",children:a.jsx("div",{className:"mobile-project-list",children:(t.projects||[]).map(o=>{var u,d;return a.jsxs("button",{type:"button",className:`mobile-project-item ${o.id===((u=t.activeProject)==null?void 0:u.id)?"active":""}`,onClick:()=>s(o.id),children:[a.jsx("div",{className:"mobile-project-status","data-status":o.status}),a.jsxs("div",{className:"mobile-project-info",children:[a.jsx("span",{className:"mobile-project-item-name",children:o.name}),a.jsx("span",{className:"mobile-project-item-path",children:o.path})]}),o.id===((d=t.activeProject)==null?void 0:d.id)&&a.jsx("span",{className:"mobile-active-badge",children:"active"})]},o.id)})})})]})]})}const G2=["all","tasks","agents","bg","artifacts","mods"],Co={all:"All",tasks:"Tasks",agents:"Agents",bg:"Background",artifacts:"Plans",mods:"Mods"};function X2({snapshot:e,onRefresh:t}){var L;const[n,r]=w.useState(((L=e.overview)==null?void 0:L.recentActivity)||[]),[i,l]=w.useState(!0),[s,o]=w.useState("all"),[u,d]=w.useState(!1),[c,f]=w.useState(null),[m,h]=w.useState(""),[p,x]=w.useState(!1);w.useEffect(()=>{var I;(I=e.overview)!=null&&I.recentActivity?(r(e.overview.recentActivity),l(!1)):b()},[e.overview]);const b=async()=>{var I;try{const k=await q.get("/snapshot");r(((I=k.overview)==null?void 0:I.recentActivity)||[])}catch{}finally{l(!1)}},y=s==="all"?n:n.filter(I=>{var k,j,P,B,O,W;return s==="tasks"?(k=I.kind)==null?void 0:k.startsWith("task"):s==="agents"?(j=I.kind)==null?void 0:j.startsWith("agent"):s==="bg"?((P=I.kind)==null?void 0:P.includes("bg"))||((B=I.kind)==null?void 0:B.includes("schedule")):s==="artifacts"?(O=I.kind)==null?void 0:O.includes("artifacts"):s==="mods"?(W=I.kind)==null?void 0:W.includes("mod"):!0}),g=e.agents||[],v=e.tasks||[],C=v.filter(I=>I.status==="doing"||I.status==="queued"),z=v.filter(I=>I.status==="done"),E=async()=>{if(!(!m.trim()||p)){x(!0);try{await q.post("/chat",{message:m.trim(),agent:"odin"}),h(""),await t().catch(()=>{}),await b()}catch{}finally{x(!1)}}},A=async()=>{await t().catch(()=>{}),await b()};return a.jsxs("div",{className:"mobile-view",children:[a.jsxs("div",{className:"mobile-submit-hero",children:[a.jsx("textarea",{className:"mobile-submit-input",placeholder:"What needs to be done? Describe a task, bug, or refactor for Odin to artifacts…",value:m,onChange:I=>h(I.target.value),rows:2}),a.jsxs("div",{className:"mobile-submit-actions",children:[a.jsx("div",{className:"mobile-submit-chips",children:["Implement feature","Fix bug","Refactor","Investigate","Write tests"].map(I=>a.jsx("button",{type:"button",className:"mobile-submit-chip",onClick:()=>h(k=>k?`${k} ${I}`:I),children:I},I))}),a.jsxs("button",{type:"button",className:"mobile-btn",disabled:!m.trim()||p,onClick:E,children:[a.jsx($m,{size:14})," Submit to Odin"]})]})]}),a.jsxs("div",{className:"mobile-stats",children:[a.jsxs("div",{className:"mobile-stat",children:[a.jsx("div",{className:"mobile-stat-value",children:g.length}),a.jsx("div",{className:"mobile-stat-label",children:"Agents"})]}),a.jsxs("div",{className:"mobile-stat",children:[a.jsx("div",{className:"mobile-stat-value",children:C.length}),a.jsx("div",{className:"mobile-stat-label",children:"Active"})]}),a.jsxs("div",{className:"mobile-stat",children:[a.jsx("div",{className:"mobile-stat-value",children:z.length}),a.jsx("div",{className:"mobile-stat-label",children:"Done"})]}),a.jsxs("div",{className:"mobile-stat",children:[a.jsx("div",{className:"mobile-stat-value",children:e.artifacts.length||0}),a.jsx("div",{className:"mobile-stat-label",children:"Plans"})]})]}),i&&n.length===0&&a.jsx("div",{className:"mobile-loading mobile-loading-inline",children:a.jsx("p",{children:"Loading activity…"})}),a.jsxs("div",{className:"mobile-activity-header",children:[a.jsx("h3",{className:"mobile-section-title",style:{margin:0},children:"Recent Activity"}),a.jsxs("div",{style:{display:"flex",gap:4},children:[a.jsx("button",{type:"button",className:"mobile-icon-btn",onClick:()=>d(I=>!I),"aria-label":u?"Resume":"Pause",children:u?a.jsx(Zl,{size:14}):a.jsx(lx,{size:14})}),a.jsx("button",{type:"button",className:"mobile-icon-btn",onClick:A,"aria-label":"Refresh",children:a.jsx(_t,{size:14})})]})]}),a.jsx("div",{className:"mobile-search-scopes",children:G2.map(I=>a.jsx("button",{type:"button",className:`mobile-scope-chip ${s===I?"active":""}`,onClick:()=>o(I),children:Co[I]},I))}),g.length>0&&a.jsxs("section",{className:"mobile-section",children:[a.jsxs("h3",{className:"mobile-section-title",children:[a.jsx(Dr,{size:14})," Agents"]}),a.jsx("div",{className:"mobile-card-list",children:g.slice(0,6).map(I=>a.jsxs("div",{className:"mobile-agent-card",children:[a.jsx("div",{className:"mobile-agent-dot","data-status":I.status||"idle"}),a.jsxs("div",{className:"mobile-agent-info",children:[a.jsx("span",{className:"mobile-agent-name",children:I.name}),a.jsx("span",{className:"mobile-agent-meta",children:I.status||"idle"})]})]},I.name))})]}),!u&&y.length>0&&a.jsx("section",{className:"mobile-section",children:a.jsx("div",{className:"mobile-card-list",children:y.slice(0,30).map((I,k)=>a.jsxs("button",{type:"button",className:"mobile-event-item",onClick:()=>f(I),children:[a.jsx("span",{className:"mobile-event-kind","data-kind":I.kind,children:Co[I.kind]||I.kind}),a.jsx("span",{className:"mobile-event-msg",children:Z2(I)}),a.jsx("span",{className:"mobile-event-time",children:Sr(I.ts)})]},`${I.ts}-${I.kind}-${k}`))})}),!u&&y.length===0&&n.length>0&&a.jsxs("div",{className:"mobile-empty",children:[a.jsx(xa,{size:40}),a.jsx("p",{children:"No matching activity."}),a.jsx("p",{className:"muted",children:"Try a different filter."})]}),c&&a.jsx(Dt,{open:!0,onClose:()=>f(null),title:Co[c.kind]||c.kind,children:a.jsxs("div",{className:"mobile-agent-detail-meta",children:[a.jsxs("div",{className:"mobile-task-detail-row",children:[a.jsx("span",{children:"Kind"}),a.jsx("span",{children:c.kind})]}),a.jsxs("div",{className:"mobile-task-detail-row",children:[a.jsx("span",{children:"Time"}),a.jsx("span",{children:new Date(c.ts).toLocaleString()})]}),Object.entries(c).filter(([I])=>!["ts","kind"].includes(I)).map(([I,k])=>a.jsxs("div",{className:"mobile-task-detail-row",children:[a.jsx("span",{children:I}),a.jsx("span",{style:{fontSize:12,maxWidth:200,wordBreak:"break-all"},children:typeof k=="object"?JSON.stringify(k):String(k)})]},I))]})}),g.length===0&&C.length===0&&a.jsxs("div",{className:"mobile-empty",children:[a.jsx(xa,{size:40}),a.jsx("p",{children:"No activity yet."}),a.jsx("p",{className:"muted",children:"Start a task or chat to see things here."})]})]})}function Z2(e){const t=e.kind||"";return t.includes("task")?`Task: ${e.title||e.id||"updated"}`:t.includes("agent")?`Agent: ${e.name||"status changed"}`:t.includes("artifacts")?`Plan: ${e.slug||"changed"}`:t.includes("mod")?`Mod: ${e.name||"changed"}`:t.includes("schedule")?`Schedule: ${e.name||"triggered"}`:JSON.stringify(e).slice(0,80)}function Tn({open:e,onClose:t,title:n,children:r,actions:i}){const l=w.useRef(null),s=w.useRef(null),o=w.useRef(null),u=w.useId(),d=w.useRef(0);return w.useEffect(()=>{if(!e)return;o.current=document.activeElement instanceof HTMLElement?document.activeElement:null;const c='button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])',f=m=>{var y,g;if(m.key==="Escape"&&t(),m.key!=="Tab")return;const h=Array.from(((y=l.current)==null?void 0:y.querySelectorAll(c))??[]);if(h.length===0){m.preventDefault(),(g=l.current)==null||g.focus();return}const p=h[0],x=h[h.length-1],b=document.activeElement;if(m.shiftKey){(!b||b===p||b===l.current)&&(m.preventDefault(),x==null||x.focus());return}b===x&&(m.preventDefault(),p==null||p.focus())};return window.addEventListener("keydown",f),d.current=window.scrollY,document.documentElement.style.overflow="hidden",document.body.style.overflow="hidden",document.body.style.position="fixed",document.body.style.top=`-${d.current}px`,document.body.style.left="0",document.body.style.right="0",document.body.style.width="100%",requestAnimationFrame(()=>{var m,h;((m=s.current)==null?void 0:m.focus())??((h=l.current)==null||h.focus())}),()=>{var m;window.removeEventListener("keydown",f),document.documentElement.style.overflow="",document.body.style.overflow="",document.body.style.position="",document.body.style.top="",document.body.style.left="",document.body.style.right="",document.body.style.width="",window.scrollTo(0,d.current),(m=o.current)==null||m.focus()}},[e,t]),e?a.jsx("div",{className:"mobile-modal-overlay",onClick:c=>{c.target===c.currentTarget&&t()},children:a.jsxs("div",{ref:l,className:"mobile-modal",onClick:c=>c.stopPropagation(),role:"dialog","aria-modal":!0,"aria-label":n?void 0:"Modal","aria-labelledby":n?u:void 0,tabIndex:-1,children:[a.jsxs("div",{className:"mobile-modal-header",children:[n?a.jsx("h2",{id:u,className:"mobile-modal-title",children:n}):a.jsx("div",{}),a.jsx("button",{ref:s,type:"button",className:"mobile-icon-btn",onClick:t,"aria-label":"Close",children:a.jsx(Zn,{size:20})})]}),a.jsx("div",{className:"mobile-modal-content",children:r}),i&&a.jsx("div",{className:"mobile-modal-actions",children:i})]})}):null}const ug=["reasoning","code","design","planning","gitops","analysis"],gf={reasoning:"var(--accent)",code:"var(--info)",design:"var(--success)",planning:"var(--warning)",gitops:"var(--error)",analysis:"var(--text-dim)"};function yf({snapshot:e,onBack:t,onOpenAgent:n,selectedAgent:r,onRefresh:i}){const[l,s]=w.useState(e.agents||[]),[o,u]=w.useState(!e.agents),[d,c]=w.useState(""),[f,m]=w.useState(""),[h,p]=w.useState(null),[x,b]=w.useState(!1),[y,g]=w.useState(""),[v,C]=w.useState(!1);w.useEffect(()=>{if(r){const j=l.find(P=>P.name===r);j&&p(j)}},[r,l]);const z=async()=>{try{const j=await q.get("/agents");s(j.agents||[])}catch{}finally{u(!1)}},E=l.filter(j=>{if(d&&j.category!==d)return!1;if(f){const P=f.toLowerCase();if(!j.name.toLowerCase().includes(P)&&!(j.description||"").toLowerCase().includes(P))return!1}return!0}),A=async(j,P)=>{try{await q.post(`/agents/${encodeURIComponent(j)}/invoke`,{prompt:P}),C(!1),g("")}catch{}},L=async j=>{try{await q.post(`/agents/${encodeURIComponent(j)}/restart`),await z()}catch{}},I=async j=>{if(confirm(`Delete agent "${j}"?`))try{await q.del(`/agents/${encodeURIComponent(j)}`),s(P=>P.filter(B=>B.name!==j)),p(null),i==null||i()}catch{}},k=async j=>{try{const P=await q.post("/agents",j);s(B=>[...B,P]),b(!1),i==null||i()}catch{}};return a.jsxs("div",{className:"mobile-view",children:[a.jsxs("div",{className:"mobile-tasks-toolbar",children:[a.jsx("input",{className:"mobile-search-input",type:"text",placeholder:"Search agents…",value:f,onChange:j=>m(j.target.value),style:{flex:1}}),a.jsx("button",{type:"button",className:"mobile-icon-btn",onClick:()=>z(),"aria-label":"Refresh",children:a.jsx(_t,{size:16})}),a.jsx("button",{type:"button",className:"mobile-icon-btn",onClick:()=>b(!0),"aria-label":"New agent",children:a.jsx(xt,{size:16})})]}),a.jsxs("div",{className:"mobile-search-scopes",children:[a.jsx("button",{type:"button",className:`mobile-scope-chip ${d?"":"active"}`,onClick:()=>c(""),children:"All"}),ug.map(j=>a.jsx("button",{type:"button",className:`mobile-scope-chip ${d===j?"active":""}`,onClick:()=>c(j),children:j},j))]}),o?a.jsx("div",{className:"mobile-loading",children:a.jsx("p",{children:"Loading…"})}):E.length===0?a.jsxs("div",{className:"mobile-empty",children:[a.jsx(Dr,{size:40}),a.jsx("p",{children:"No agents found."})]}):a.jsx("div",{className:"mobile-card-list",children:E.map(j=>a.jsxs("button",{type:"button",className:"mobile-list-item mobile-list-item-interactive",onClick:()=>{p(j),n(j.name)},children:[a.jsx("div",{className:"mobile-agent-dot","data-status":j.status||"idle"}),a.jsxs("div",{className:"mobile-list-content",children:[a.jsx("span",{className:"mobile-list-title",children:j.name}),a.jsx("span",{className:"mobile-list-meta",children:j.model||j.mode||"—"})]}),j.category&&a.jsx("span",{className:"mobile-list-badge",style:{color:gf[j.category]||"var(--text-dim)"},children:j.category}),a.jsx("span",{className:"mobile-list-badge","data-status":j.status||"idle",children:j.status||"idle"})]},j.name))}),h&&a.jsx(Dt,{open:!0,onClose:()=>p(null),title:h.name,actions:a.jsxs("div",{className:"mobile-task-detail-actions",children:[a.jsxs("button",{type:"button",className:"mobile-btn",onClick:()=>{g(""),C(!0)},children:[a.jsx(Zl,{size:14})," Invoke"]}),(h.isStuck||h.status==="error"||h.status==="working")&&a.jsxs("button",{type:"button",className:"mobile-btn mobile-btn-secondary",onClick:()=>L(h.name),children:[a.jsx(ux,{size:14})," Restart"]}),a.jsx("button",{type:"button",className:"mobile-btn mobile-btn-danger",onClick:()=>I(h.name),children:a.jsx(_r,{size:14})})]}),children:a.jsxs("div",{className:"mobile-agent-detail",children:[a.jsxs("div",{className:"mobile-agent-detail-status",children:[a.jsx("span",{className:"mobile-agent-dot","data-status":h.status||"idle"}),a.jsx("span",{className:"mobile-agent-detail-status-text",children:h.status||"idle"}),h.category&&a.jsx("span",{className:"mobile-list-badge",style:{color:gf[h.category]},children:h.category})]}),a.jsx("p",{className:"mobile-agent-detail-desc",children:h.description||"No description."}),a.jsxs("div",{className:"mobile-agent-detail-meta",children:[a.jsxs("div",{className:"mobile-task-detail-row",children:[a.jsx("span",{children:"Model"}),a.jsx("span",{className:"mono",children:h.model||"—"})]}),a.jsxs("div",{className:"mobile-task-detail-row",children:[a.jsx("span",{children:"Mode"}),a.jsx("span",{children:h.mode||"subagent"})]}),a.jsxs("div",{className:"mobile-task-detail-row",children:[a.jsx("span",{children:"Path"}),a.jsx("span",{className:"mono",style:{fontSize:11},children:h.path})]}),h.lastError&&a.jsxs("div",{className:"mobile-task-detail-row",style:{color:"var(--error)"},children:[a.jsx("span",{children:"Last error"}),a.jsx("span",{children:h.lastError.message})]}),h.tasksTotal!=null&&h.tasksTotal>0&&a.jsxs("div",{className:"mobile-task-detail-row",children:[a.jsx("span",{children:"Success rate"}),a.jsxs("span",{children:[Math.round((h.successRate||0)*100),"%"]})]}),a.jsxs("div",{className:"mobile-task-detail-row",children:[a.jsx("span",{children:"Last modified"}),a.jsx("span",{children:Sr(h.mtime)})]})]})]})}),a.jsxs(Tn,{open:v,onClose:()=>C(!1),title:`Invoke ${h==null?void 0:h.name}`,actions:a.jsxs("button",{type:"button",className:"mobile-btn",style:{width:"100%"},disabled:!y.trim(),onClick:()=>{h&&A(h.name,y.trim())},children:[a.jsx(Zl,{size:14})," Invoke"]}),children:[a.jsxs("p",{className:"muted",style:{marginBottom:12},children:["Model: ",a.jsx("span",{className:"mono",children:(h==null?void 0:h.model)||"—"})]}),a.jsx("textarea",{className:"mobile-input",rows:5,placeholder:"What should this agent do?",value:y,onChange:j=>g(j.target.value),autoFocus:!0})]}),a.jsx(J2,{open:x,onClose:()=>b(!1),onCreate:k})]})}function J2({open:e,onClose:t,onCreate:n}){const[r,i]=w.useState(""),[l,s]=w.useState(""),[o,u]=w.useState(""),[d,c]=w.useState("subagent"),[f,m]=w.useState("#8b5cf6"),[h,p]=w.useState(""),[x,b]=w.useState(""),[y,g]=w.useState(""),v=C=>{C.preventDefault(),r.trim()&&(n({name:r.trim(),description:l.trim(),model:o,mode:d,color:f,tools:[],tags:x.split(",").map(z=>z.trim()).filter(Boolean),category:h,prompt:y}),i(""),s(""),u(""),c("subagent"),m("#8b5cf6"),p(""),b(""),g(""))};return a.jsx(Tn,{open:e,onClose:t,title:"New Agent",actions:a.jsxs("button",{type:"submit",form:"new-agent-form",className:"mobile-btn",style:{width:"100%"},children:[a.jsx(xt,{size:14})," Create"]}),children:a.jsxs("form",{id:"new-agent-form",onSubmit:v,className:"mobile-task-form",children:[a.jsx("label",{className:"mobile-field-label",children:"Name *"}),a.jsx("input",{className:"mobile-input",type:"text",placeholder:"my-agent",pattern:"[a-z0-9][a-z0-9-]{0,63}",value:r,onChange:C=>i(C.target.value),autoFocus:!0,required:!0}),a.jsx("label",{className:"mobile-field-label",children:"Description"}),a.jsx("input",{className:"mobile-input",type:"text",placeholder:"What does this agent do?",value:l,onChange:C=>s(C.target.value)}),a.jsx("label",{className:"mobile-field-label",children:"Model"}),a.jsx("input",{className:"mobile-input",type:"text",placeholder:"(provider default)",value:o,onChange:C=>u(C.target.value)}),a.jsx("label",{className:"mobile-field-label",children:"Category"}),a.jsxs("select",{className:"mobile-input",value:h,onChange:C=>p(C.target.value),children:[a.jsx("option",{value:"",children:"None"}),ug.map(C=>a.jsx("option",{value:C,children:C},C))]}),a.jsx("label",{className:"mobile-field-label",children:"Tags (comma-separated)"}),a.jsx("input",{className:"mobile-input",type:"text",placeholder:"tag1, tag2",value:x,onChange:C=>b(C.target.value)})]})})}function eC({sessions:e,opencodeSessions:t,activeSessionId:n,activeOpencodeSessionId:r,activeProject:i,creating:l,onCreateSession:s,onSelectSession:o,onSelectOpencodeSession:u}){const[d,c]=w.useState("all"),[f,m]=w.useState(!1),h=30,p=d==="all"?[...e,...t].sort((g,v)=>Number(v.mtime)-Number(g.mtime)):e,x=f?p:p.slice(0,h),b=t.length,y=g=>{if(g.source==="opencode"){u(g);return}o(g.id)};return a.jsxs("div",{className:"chat-sessions",children:[a.jsxs("div",{className:"chat-sessions-header",children:[a.jsx("span",{className:"chat-sessions-header-title",children:"Sessions"}),a.jsx("span",{className:"chat-sessions-count",children:x.length})]}),b>0&&a.jsxs("div",{className:"chat-sessions-toggle",children:[a.jsx("button",{type:"button",className:`chat-sessions-toggle-btn ${d==="bizar"?"active":""}`,onClick:()=>c("bizar"),children:"Bizar"}),a.jsxs("button",{type:"button",className:`chat-sessions-toggle-btn ${d==="all"?"active":""}`,onClick:()=>c("all"),children:["All (",b," opencode)"]})]}),a.jsxs("button",{type:"button",className:"chat-sessions-new",onClick:s,disabled:l||!i,title:i?"Create new session":"Pick a project first","aria-label":"Create new session",children:[l?a.jsx(Wm,{size:"sm"}):a.jsx(xt,{size:14}),a.jsx("span",{children:l?"Creating…":"New session"})]}),e.length===0?a.jsx("div",{className:"chat-sessions-empty",children:a.jsx(Ix,{icon:a.jsx(Jl,{size:20}),title:i?"No sessions yet":"No project",message:i?"Create your first session to start chatting.":"Pick a project in Overview to scope chat sessions.",action:i?a.jsxs(pr,{variant:"primary",size:"sm",onClick:s,loading:l,children:[a.jsx(xt,{size:12})," New session"]}):a.jsxs(pr,{variant:"secondary",size:"sm",onClick:()=>{window.location.hash="#overview"},children:[a.jsx(Pu,{size:12})," Open Overview"]})})}):a.jsx("ul",{className:"chat-sessions-list",children:x.map(g=>{const v=g.source==="opencode",C=v?r===g.id:n===g.id;return a.jsxs("li",{className:`chat-sessions-item ${C?"active":""} ${v?"chat-sessions-item-opencode":""}`,onClick:()=>y(g),title:v?`Open in dashboard: ${g.title||g.id}`:g.id,children:[v&&a.jsx(Z1,{size:10,className:"chat-sessions-item-icon"}),a.jsx("span",{className:"chat-sessions-item-id",children:g.title||g.id}),a.jsx("span",{className:"chat-sessions-item-meta",children:new Date(Number(g.mtime)).toLocaleDateString()})]},v?`oc-${g.id}`:g.id)})}),p.length>h&&a.jsx("button",{type:"button",className:"chat-sessions-show-more",onClick:()=>m(g=>!g),children:f?`Show less (${p.length-h} hidden)`:`Show all ${p.length} sessions`})]})}function tC(e){const{activeSource:t}=e;return a.jsx("div",{className:`chat-composer-wrap chat-composer-source-${t??"none"} legacy`,children:a.jsx("div",{className:"chat-composer-pill",children:a.jsx(T2,{...e})})})}function nC({sessionId:e,messages:t,pinned:n,agent:r,model:i,agents:l,mcps:s,allCommands:o,activeSource:u="bizar",onRename:d,onDelete:c}){const[f,m]=w.useState(!1),[h,p]=w.useState(!1),x=f?l:l.slice(0,4),b=h?o:o.slice(0,4),y=i.includes("/")?i.split("/")[0]:"";return a.jsxs("div",{className:"chat-info",children:[a.jsxs("div",{className:"chat-info-card",children:[a.jsxs("div",{className:"chat-info-card-title",children:[a.jsx(On,{size:14})," Session",a.jsx("span",{className:`chat-source-badge chat-source-${u??"none"}`,style:{marginLeft:"auto"},children:u==="opencode"?"opencode":"bizar chat"})]}),a.jsxs("dl",{className:"env-table",children:[a.jsx("dt",{children:"id"}),a.jsx("dd",{className:"mono",children:e||"Live"}),a.jsx("dt",{children:"Messages"}),a.jsx("dd",{className:"mono",children:t.length}),a.jsx("dt",{children:"Pinned"}),a.jsx("dd",{className:"mono",children:n.size}),a.jsx("dt",{children:"Agent"}),a.jsx("dd",{className:"mono",children:r||"—"}),a.jsx("dt",{children:"Model"}),a.jsx("dd",{className:"mono ellipsis",title:i,children:i||"—"}),y&&a.jsxs(a.Fragment,{children:[a.jsx("dt",{children:"Provider"}),a.jsx("dd",{className:"mono",children:y})]})]}),(d||c)&&a.jsxs("div",{className:"chat-info-actions",children:[d&&a.jsxs("button",{type:"button",className:"btn btn-ghost btn-sm",onClick:d,children:[a.jsx(Au,{size:12,"aria-hidden":!0})," Rename"]}),c&&a.jsxs("button",{type:"button",className:"btn btn-ghost btn-danger btn-sm",onClick:c,children:[a.jsx(_r,{size:12,"aria-hidden":!0})," Delete"]})]})]}),a.jsxs("div",{className:"chat-info-card",children:[a.jsxs("div",{className:"chat-info-card-title",children:[a.jsx(Dr,{size:14})," Agents",a.jsx("span",{className:"chat-info-card-count",children:l.length})]}),a.jsx("ul",{className:"mod-mini-list",children:x.map(g=>a.jsxs("li",{className:"mod-mini",children:[a.jsxs("span",{className:"mod-mini-name",children:["@",g.name]}),a.jsx("span",{className:"mod-mini-meta",children:g.model||g.mode||""})]},g.name))}),l.length>4&&a.jsx("button",{type:"button",className:"chat-info-card-toggle",onClick:()=>m(g=>!g),children:f?"− Show fewer":`+ ${l.length-4} more`})]}),a.jsxs("div",{className:"chat-info-card",children:[a.jsxs("div",{className:"chat-info-card-title",children:[a.jsx(cx,{size:14})," MCPs",a.jsx("span",{className:"chat-info-card-count",children:s.length})]}),a.jsxs("ul",{className:"mod-mini-list",children:[s.length===0?a.jsx("li",{className:"muted",children:"No MCPs configured."}):null,s.map(g=>a.jsxs("li",{className:"mod-mini",children:[a.jsx("span",{className:"mod-mini-name",children:g.id}),a.jsx("span",{className:`mod-mini-pill ${g.enabled?"on":"off"}`,children:g.enabled?"on":"off"})]},g.id))]})]}),a.jsxs("div",{className:"chat-info-card",children:[a.jsxs("button",{type:"button",className:"chat-info-card-title chat-info-card-title-button",onClick:()=>p(g=>!g),"aria-expanded":h,children:[a.jsx(hx,{size:14})," Slash commands",a.jsx("span",{className:"chat-info-card-count",children:o.length}),a.jsx(Ss,{size:12,className:`chat-info-card-chevron ${h?"open":""}`})]}),h&&a.jsx("ul",{className:"mod-mini-list",children:b.map(g=>a.jsxs("li",{children:[a.jsx("code",{children:g.cmd}),a.jsx("span",{className:"muted",children:g.desc})]},g.cmd))})]})]})}function rC({snapshot:e,settings:t,setActiveTab:n,initialTaskId:r,onClearTaskId:i}){const l=bx(),s=kx(),o=A2(e,t,r??"");w.useEffect(()=>{o.setToast({error:O=>l.error(O),success:O=>l.success(O),info:O=>l.info(O),warning:O=>l.warning(O)})},[o,l]);const[u,d]=w.useState(""),[c,f]=w.useState(t.defaultAgent||"odin"),[m,h]=w.useState(t.defaultModel||""),[p,x]=w.useState([]),[b,y]=w.useState(!1),[g,v]=w.useState(!1),C=w.useRef(null),{allCommands:z,suggestions:E,setQuery:A}=L2(e);w.useEffect(()=>{A(u)},[u,A]);const L=()=>{var O;return(O=C.current)==null?void 0:O.click()},I=O=>{const W=O.target.files;if(!W)return;const de=[];for(let ee=0;ee<W.length;ee++)de.push(W[ee].name);x(ee=>{const R=de.filter(V=>!ee.includes(V));return[...ee,...R]}),C.current&&(C.current.value="")},k=async()=>{const O=u.trim();if(!O)return;d(""),A(""),(await o.onSend(O,c,m,p)).ok&&o.jumpToLatest()},j=async()=>{o.busy.create||(await o.onCreateSession(),y(!1))},P=O=>{s.open({title:"Delete message?",children:a.jsx("p",{style:{margin:0},children:"This action cannot be undone."}),footer:a.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"flex-end"},children:[a.jsx(pr,{variant:"secondary",size:"sm",onClick:()=>s.close(),children:"Cancel"}),a.jsx(pr,{variant:"danger",size:"sm",onClick:()=>{s.close(),o.deleteMessage(O)},children:"Delete"})]})})},B=(O,W)=>{s.open({title:"Delete session?",children:a.jsxs("p",{style:{margin:0},children:["Delete ",a.jsx("strong",{children:W}),"? This cannot be undone."]}),footer:a.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"flex-end"},children:[a.jsx(pr,{variant:"secondary",size:"sm",onClick:()=>s.close(),children:"Cancel"}),a.jsx(pr,{variant:"danger",size:"sm",onClick:async()=>{s.close(),await o.deleteSession(O)},children:"Delete"})]})})};return a.jsxs("div",{className:"chat-shell",children:[a.jsx(Tx,{activeProject:e.activeProject,sessionCount:o.sessions.length,sessionsOpen:b,infoOpen:g,onToggleSessions:()=>y(O=>!O),onToggleInfo:()=>v(O=>!O),onOpenOverview:()=>n==null?void 0:n("overview")}),a.jsxs("div",{className:"chat-body",children:[a.jsx("aside",{className:`chat-sessions ${b?"":"chat-sessions-hidden"}`,children:a.jsx(eC,{sessions:o.sessions,opencodeSessions:o.opencodeSessions,activeSessionId:o.sessionId,activeOpencodeSessionId:o.activeOpencodeSessionId,activeProject:e.activeProject,onCreateSession:j,onSelectSession:o.selectBizarSession,onSelectOpencodeSession:O=>o.loadOpencodeSession(O.id),creating:o.busy.create})}),a.jsxs("main",{className:"chat-main",children:[a.jsx(j2,{messages:o.activeSource==="opencode"?o.opencodeMessages:o.bizarMessages,loading:o.loading,activeProject:e.activeProject,sessionId:o.activeSource==="opencode"?o.activeOpencodeSessionId??o.sessionId:o.sessionId,pinned:o.pinned,activeSource:o.activeSource,onPickSuggestion:O=>d(O),onCopy:O=>o.copyMessage(O),onDelete:P,onTogglePin:o.togglePin,onRegenerate:o.onRegenerate}),a.jsx(tC,{agent:c,setAgent:f,model:m,setModel:h,text:u,setText:d,sending:o.sending,activeSource:o.activeSource,onSend:k,attachments:p,setAttachments:x,suggestions:E,onPickSuggestion:O=>d(`${O.split(" ")[0]} `),agents:e.agents||[],onAttach:L,sessionsOpen:b,infoOpen:g}),a.jsx("input",{ref:C,type:"file",multiple:!0,style:{display:"none"},onChange:I})]}),a.jsx("aside",{className:`chat-info ${g?"":"chat-info-hidden"}`,children:a.jsx(nC,{sessionId:o.activeSource==="opencode"?o.activeOpencodeSessionId??o.sessionId:o.sessionId,messages:o.activeSource==="opencode"?o.opencodeMessages:o.bizarMessages,pinned:o.pinned,agent:c,model:m,agents:e.agents||[],mcps:e.mcps||[],allCommands:z,activeSource:o.activeSource,onDelete:()=>{const O=o.activeSource==="opencode"?o.activeOpencodeSessionId:o.sessionId;O&&B(O,O)}})})]})]})}function iC({onBack:e}){const[t,n]=w.useState([]),[r,i]=w.useState(!0),[l,s]=w.useState({}),[o,u]=w.useState(!1),d=async()=>{try{const x=await q.get("/config"),b=Object.entries(x).map(([y,g])=>({key:y,value:g,type:c(g)}));n(b),s(Object.fromEntries(Object.entries(x).map(([y,g])=>[y,g])))}catch{}finally{i(!1)}};w.useEffect(()=>{d()},[]);const c=x=>typeof x=="boolean"?"boolean":typeof x=="number"?"number":typeof x=="string"?"string":Array.isArray(x)?"array":x&&typeof x=="object"?"object":"unknown",f=(x,b)=>{s(y=>({...y,[x]:b}))},m=async()=>{u(!0);try{await q.patch("/config",l),await d()}catch{}finally{u(!1)}},h=(x,b)=>{s(y=>({...y,[x]:b}))},p=x=>{const b=l[x.key];switch(x.type){case"boolean":return a.jsxs("label",{className:"mobile-toggle",children:[a.jsx("input",{type:"checkbox",checked:!!b,onChange:y=>f(x.key,y.target.checked)}),a.jsx("span",{className:"mobile-toggle-slider"})]});case"number":return a.jsx("input",{className:"mobile-input mobile-input-sm",type:"number",inputMode:"numeric",value:String(b??""),onChange:y=>f(x.key,Number(y.target.value))});case"string":return a.jsx("input",{className:"mobile-input mobile-input-sm",type:"text",value:String(b??""),onChange:y=>f(x.key,y.target.value)});case"object":case"array":return a.jsx("textarea",{className:"mobile-input mobile-input-sm",rows:2,value:JSON.stringify(b??null,null,2),onChange:y=>{try{f(x.key,JSON.parse(y.target.value))}catch{}}});default:return a.jsx("span",{className:"mobile-setting-value mono",children:String(b??"null")})}};return a.jsxs("div",{className:"mobile-view",children:[a.jsxs("div",{className:"mobile-tasks-toolbar",children:[a.jsxs("span",{style:{fontSize:14,color:"var(--text-muted)",flex:1},children:[t.length," config entries"]}),a.jsx("button",{type:"button",className:"mobile-icon-btn",onClick:()=>d(),"aria-label":"Refresh",children:a.jsx(_t,{size:16})}),a.jsxs("button",{type:"button",className:"mobile-btn",disabled:o,onClick:()=>m(),children:[a.jsx(Fm,{size:14})," ",o?"Saving…":"Save all"]})]}),r?a.jsx("div",{className:"mobile-loading",children:a.jsx("p",{children:"Loading…"})}):t.length===0?a.jsxs("div",{className:"mobile-empty",children:[a.jsx(Pr,{size:40}),a.jsx("p",{children:"No config entries."})]}):a.jsx("div",{className:"mobile-config-list",children:t.map(x=>a.jsxs("div",{className:"mobile-config-row",children:[a.jsxs("div",{className:"mobile-config-key",children:[a.jsx("span",{className:"mono",children:x.key}),a.jsx("span",{className:"mobile-config-type",children:x.type})]}),a.jsx("div",{className:"mobile-config-value",children:p(x)}),a.jsx("button",{type:"button",className:"mobile-icon-btn",onClick:()=>h(x.key,x.defaultValue),"aria-label":"Reset to default",title:"Reset",children:a.jsx(ax,{size:14})})]},x.key))})]})}function lC({onBack:e}){const[t,n]=w.useState([]),[r,i]=w.useState(!0),[l,s]=w.useState(null),[o,u]=w.useState(""),d=async()=>{try{const h=await q.get("/history");if(Array.isArray(h.history)){n(h.history);return}if(Array.isArray(h.projects)){const p=new Map;for(const x of h.events||[]){const b=x.projectId;if(!b)continue;const y=p.get(b);(!y||new Date(x.ts).getTime()>new Date(y.ts).getTime())&&p.set(b,x)}n(h.projects.map(x=>{const b=p.get(x.id);return{id:x.id,ts:x.lastAccessed||(b==null?void 0:b.ts)||new Date(0).toISOString(),agent:x.name,taskCount:x.tasks.total,summary:`${x.path} · ${x.tasks.done}/${x.tasks.total} done · ${x.plans} plan${x.plans===1?"":"s"}`,output:b?`${b.kind}${b.text?` — ${b.text}`:""}`:"No recent events."}}));return}n([])}catch{}finally{i(!1)}};w.useEffect(()=>{d()},[]);const c=h=>{if(!h)return"—";const p=Math.floor(h/1e3);if(p<60)return`${p}s`;const x=Math.floor(p/60),b=p%60;return`${x}m ${b}s`},f=h=>new Date(h).toLocaleString(),m=o.trim()?t.filter(h=>{const p=o.toLowerCase();return(h.agent||"session").toLowerCase().includes(p)||(h.summary||"").toLowerCase().includes(p)||(h.output||"").toLowerCase().includes(p)}):t;return a.jsxs("div",{className:"mobile-view",children:[a.jsxs("div",{className:"mobile-tasks-toolbar",children:[a.jsx("input",{className:"mobile-search-input",type:"text",placeholder:"Search history…",value:o,onChange:h=>u(h.target.value),style:{flex:1}}),a.jsx("button",{type:"button",className:"mobile-icon-btn",onClick:()=>d(),"aria-label":"Refresh",children:a.jsx(_t,{size:16})})]}),r?a.jsx("div",{className:"mobile-loading",children:a.jsx("p",{children:"Loading…"})}):m.length===0?a.jsxs("div",{className:"mobile-empty",children:[a.jsx(ka,{size:40}),a.jsx("p",{children:t.length===0?"No history yet.":"No matching sessions."})]}):a.jsx("div",{className:"mobile-card-list",children:m.map(h=>a.jsxs("button",{type:"button",className:"mobile-list-item mobile-list-item-interactive",onClick:()=>s(h),children:[a.jsx("div",{className:"mobile-list-icon",children:a.jsx(ka,{size:16})}),a.jsxs("div",{className:"mobile-list-content",children:[a.jsx("span",{className:"mobile-list-title",children:h.agent||"Session"}),a.jsxs("span",{className:"mobile-list-meta",children:[f(h.ts),h.duration?` · ${c(h.duration)}`:"",h.taskCount?` · ${h.taskCount} tasks`:""]})]})]},h.id))}),l&&a.jsxs(Dt,{open:!0,onClose:()=>s(null),title:"Session Detail",children:[a.jsxs("div",{className:"mobile-agent-detail-meta",children:[a.jsxs("div",{className:"mobile-task-detail-row",children:[a.jsx("span",{children:"Agent"}),a.jsx("span",{children:l.agent||"—"})]}),a.jsxs("div",{className:"mobile-task-detail-row",children:[a.jsx("span",{children:"Started"}),a.jsx("span",{children:f(l.ts)})]}),a.jsxs("div",{className:"mobile-task-detail-row",children:[a.jsx("span",{children:"Duration"}),a.jsx("span",{children:c(l.duration)})]}),a.jsxs("div",{className:"mobile-task-detail-row",children:[a.jsx("span",{children:"Tasks"}),a.jsx("span",{children:l.taskCount||0})]})]}),l.summary&&a.jsxs("div",{style:{marginTop:12},children:[a.jsx("h4",{style:{fontSize:12,color:"var(--text-muted)",marginBottom:4},children:"Summary"}),a.jsx("p",{style:{fontSize:13},children:l.summary})]}),l.output&&a.jsxs("div",{style:{marginTop:12},children:[a.jsx("h4",{style:{fontSize:12,color:"var(--text-muted)",marginBottom:4},children:"Output"}),a.jsxs("pre",{className:"mono",style:{fontSize:11,whiteSpace:"pre-wrap",wordBreak:"break-all",background:"var(--bg-elev-2)",padding:8,borderRadius:6},children:[l.output.slice(0,1e3),l.output.length>1e3?"…":""]})]})]})]})}function sC({snapshot:e,onBack:t}){const[n,r]=w.useState(e.mods||[]),[i,l]=w.useState(!e.mods),[s,o]=w.useState(""),[u,d]=w.useState("all"),[c,f]=w.useState(null),m=async()=>{try{const x=await q.get("/mods");r(x.mods||[])}catch{}finally{l(!1)}};w.useEffect(()=>{e.mods?(r(e.mods),l(!1)):m()},[e.mods]);const h=async(x,b)=>{try{await q.patch(`/mods/${encodeURIComponent(x)}`,{enabled:b}),r(y=>y.map(g=>g.id===x?{...g,enabled:b}:g)),(c==null?void 0:c.id)===x&&f(y=>y&&{...y,enabled:b})}catch{}},p=n.filter(x=>{if(u==="enabled"&&!x.enabled||u==="disabled"&&x.enabled)return!1;if(s){const b=s.toLowerCase();return x.name.toLowerCase().includes(b)||x.description.toLowerCase().includes(b)}return!0});return a.jsxs("div",{className:"mobile-view",children:[a.jsxs("div",{className:"mobile-tasks-toolbar",children:[a.jsx("input",{className:"mobile-search-input",type:"text",placeholder:"Search mods…",value:s,onChange:x=>o(x.target.value),style:{flex:1}}),a.jsx("button",{type:"button",className:"mobile-icon-btn",onClick:()=>m(),"aria-label":"Refresh",children:a.jsx(_t,{size:16})})]}),a.jsx("div",{className:"mobile-search-scopes",children:["all","enabled","disabled"].map(x=>a.jsx("button",{type:"button",className:`mobile-scope-chip ${u===x?"active":""}`,onClick:()=>d(x),children:x.charAt(0).toUpperCase()+x.slice(1)},x))}),i?a.jsx("div",{className:"mobile-loading",children:a.jsx("p",{children:"Loading…"})}):p.length===0?a.jsxs("div",{className:"mobile-empty",children:[a.jsx(Pr,{size:40}),a.jsx("p",{children:"No mods found."})]}):a.jsx("div",{className:"mobile-card-list",children:p.map(x=>a.jsxs("button",{type:"button",className:"mobile-list-item mobile-list-item-interactive",onClick:()=>f(x),children:[a.jsx("div",{className:"mobile-list-icon",children:a.jsx(Pr,{size:16})}),a.jsxs("div",{className:"mobile-list-content",children:[a.jsx("span",{className:"mobile-list-title",children:x.name}),a.jsxs("span",{className:"mobile-list-meta",children:["v",x.version," · ",x.author]})]}),a.jsx("span",{className:`mobile-list-badge ${x.enabled?"badge-on":"badge-off"}`,children:x.enabled?"on":"off"})]},x.id))}),c&&a.jsx(Dt,{open:!0,onClose:()=>f(null),title:c.name,actions:a.jsx("div",{className:"mobile-task-detail-actions",children:a.jsxs("button",{type:"button",className:"mobile-btn",style:{flex:1},onClick:()=>{c&&h(c.id,!c.enabled)},children:[a.jsx(Om,{size:14})," ",c.enabled?"Disable":"Enable"]})}),children:a.jsxs("div",{className:"mobile-agent-detail",children:[a.jsx("p",{className:"mobile-agent-detail-desc",children:c.description||"No description."}),a.jsxs("div",{className:"mobile-agent-detail-meta",children:[a.jsxs("div",{className:"mobile-task-detail-row",children:[a.jsx("span",{children:"Version"}),a.jsx("span",{className:"mono",children:c.version})]}),a.jsxs("div",{className:"mobile-task-detail-row",children:[a.jsx("span",{children:"Author"}),a.jsx("span",{children:c.author})]}),a.jsxs("div",{className:"mobile-task-detail-row",children:[a.jsx("span",{children:"Bizar"}),a.jsx("span",{className:"mono",children:c.bizar})]}),a.jsxs("div",{className:"mobile-task-detail-row",children:[a.jsx("span",{children:"Type"}),a.jsx("span",{children:c.type})]}),a.jsxs("div",{className:"mobile-task-detail-row",children:[a.jsx("span",{children:"Permissions"}),a.jsx("span",{children:c.permissions.length})]}),c.installedAt&&a.jsxs("div",{className:"mobile-task-detail-row",children:[a.jsx("span",{children:"Installed"}),a.jsx("span",{children:new Date(c.installedAt).toLocaleDateString()})]})]})]})})]})}function oC({snapshot:e,onNavigate:t}){var s,o,u;const[n,r]=w.useState(""),i=[{id:"artifacts",icon:qn,label:"Plans",count:e.artifacts.length||0,desc:"Visual artifacts with elements & comments"},{id:"agents",icon:Dr,label:"Agents",count:((s=e.agents)==null?void 0:s.length)||0,desc:"The Norse pantheon"},{id:"skills",icon:Pr,label:"Skills",count:null,desc:"Agent capabilities & tools"},{id:"mods",icon:Pr,label:"Mods",count:((o=e.mods)==null?void 0:o.length)||0,desc:"Installed modifications"},{id:"schedules",icon:va,label:"Schedules",count:((u=e.schedules)==null?void 0:u.length)||0,desc:"Cron jobs & automated tasks"},{id:"history",icon:ka,label:"History",count:null,desc:"Past sessions & outputs"},{id:"config",icon:Bm,label:"Config",count:null,desc:"Key-value configuration editor"}],l=n.trim()?i.filter(d=>d.label.toLowerCase().includes(n.toLowerCase())||d.desc.toLowerCase().includes(n.toLowerCase())):i;return a.jsxs("div",{className:"mobile-view",children:[a.jsx("div",{className:"mobile-tasks-toolbar",children:a.jsx("input",{className:"mobile-search-input",type:"text",placeholder:"Search…",value:n,onChange:d=>r(d.target.value),style:{flex:1}})}),a.jsx("div",{className:"mobile-card-list",children:l.map(d=>{const c=d.icon;return a.jsxs("button",{type:"button",className:"mobile-more-nav-item",onClick:()=>t(d.id),children:[a.jsx("div",{className:"mobile-more-nav-icon",children:a.jsx(c,{size:20})}),a.jsxs("div",{className:"mobile-more-nav-content",children:[a.jsxs("span",{className:"mobile-more-nav-label",children:[d.label,d.count!=null&&a.jsx("span",{className:"mobile-more-nav-count",children:d.count})]}),a.jsx("span",{className:"mobile-more-nav-desc",children:d.desc})]}),a.jsx(dd,{size:16,className:"mobile-more-nav-arrow"})]},d.id)})}),a.jsx("div",{className:"mobile-more-footer",children:a.jsxs("a",{href:"/?desktop=1",className:"mobile-more-link",children:["Switch to Desktop ",a.jsx(dd,{size:14})]})})]})}const Ju=[{id:"task",label:"Task",color:"var(--info)"},{id:"note",label:"Note",color:"var(--text-dim)"},{id:"decision",label:"Decision",color:"var(--accent)"},{id:"question",label:"Question",color:"var(--warning)"}];function jo(e){var t;return((t=Ju.find(n=>n.id===e))==null?void 0:t.color)||"var(--text-dim)"}function aC({type:e,size:t=12}){switch(e){case"task":return a.jsx(es,{size:t,style:{color:"var(--info)"}});case"note":return a.jsx(md,{size:t,style:{color:"var(--text-dim)"}});case"decision":return a.jsx(es,{size:t,style:{color:"var(--accent)"}});case"question":return a.jsx(K1,{size:t,style:{color:"var(--warning)"}});default:return a.jsx(md,{size:t})}}function uC({slug:e,onBack:t}){const[n,r]=w.useState(null),[i,l]=w.useState(null),[s,o]=w.useState(!0),[u,d]=w.useState(!1),[c,f]=w.useState(null),[m,h]=w.useState(!1),[p,x]=w.useState(!1),[b,y]=w.useState(!1),[g,v]=w.useState(""),C=async()=>{o(!0);try{const I=await q.get(`/plans/${encodeURIComponent(e)}`);r(I.canvas),l(I.meta)}catch{}finally{o(!1)}};w.useEffect(()=>{C()},[e]);const z=async(I,k,j)=>{try{const P=((n==null?void 0:n.elements)||[]).reduce((O,W)=>Math.max(O,W.x||0),40),B=((n==null?void 0:n.elements)||[]).reduce((O,W)=>Math.max(O,W.y||0),40);await q.post(`/plans/${encodeURIComponent(e)}/elements`,{type:I,title:k,content:j,x:20+P,y:20+B,width:240,height:120}),await C(),x(!1)}catch{}},E=async(I,k)=>{try{await q.put(`/plans/${encodeURIComponent(e)}/elements/${encodeURIComponent(I)}`,k),await C(),f(null)}catch{}},A=async I=>{if(confirm("Delete this element?"))try{await q.del(`/plans/${encodeURIComponent(e)}/elements/${encodeURIComponent(I)}`),f(null),await C()}catch{}},L=async(I,k)=>{try{const j=k?`/plans/${encodeURIComponent(e)}/elements/${encodeURIComponent(k)}/comments`:`/plans/${encodeURIComponent(e)}/comments`;await q.post(j,{text:I,elementId:k}),await C(),v(""),y(!1)}catch{}};return s||!n||!i?a.jsx("div",{className:"mobile-view",children:a.jsx("div",{className:"mobile-loading",children:a.jsx("p",{children:"Loading canvas…"})})}):a.jsxs("div",{className:"mobile-view mobile-view-canvas",children:[a.jsxs("div",{className:"mobile-canvas-bar",children:[a.jsxs("div",{className:"mobile-canvas-meta",children:[a.jsx("span",{className:"mobile-canvas-title",children:i.title||e}),a.jsx("span",{className:"mobile-canvas-status","data-status":i.status,children:i.status})]}),a.jsxs("div",{className:"mobile-canvas-actions",children:[a.jsx("button",{type:"button",className:`mobile-icon-btn ${u?"active":""}`,onClick:()=>d(I=>!I),"aria-label":u?"Done editing":"Edit",children:a.jsx(Au,{size:16})}),a.jsxs("button",{type:"button",className:"mobile-icon-btn",onClick:()=>h(I=>!I),"aria-label":"Comments",children:[a.jsx(On,{size:16}),n.comments.length>0&&a.jsx("span",{className:"mobile-canvas-comment-count",children:n.comments.length})]}),u&&a.jsx("button",{type:"button",className:"mobile-icon-btn",onClick:()=>x(!0),"aria-label":"Add element",children:a.jsx(xt,{size:16})})]})]}),a.jsxs("div",{className:"mobile-canvas-elements",children:[n.elements.length===0&&a.jsxs("div",{className:"mobile-empty",children:[a.jsx("p",{children:"No elements yet."}),u&&a.jsxs("button",{type:"button",className:"mobile-btn",onClick:()=>x(!0),children:[a.jsx(xt,{size:14})," Add Element"]})]}),n.elements.map(I=>a.jsxs("button",{type:"button",className:`mobile-canvas-element ${(c==null?void 0:c.id)===I.id?"selected":""}`,style:{borderColor:jo(I.type)},onClick:()=>{u&&f(I)},"aria-pressed":(c==null?void 0:c.id)===I.id,children:[a.jsxs("div",{className:"mobile-canvas-el-header",style:{background:`${jo(I.type)}18`},children:[a.jsx(aC,{type:I.type,size:12}),a.jsx("span",{className:"mobile-canvas-el-type",style:{color:jo(I.type)},children:I.type}),I.status&&I.status!=="open"&&a.jsx("span",{className:"mobile-canvas-el-status",children:I.status})]}),a.jsx("div",{className:"mobile-canvas-el-title",children:I.title||"Untitled"}),I.content&&a.jsxs("div",{className:"mobile-canvas-el-content",children:[I.content.slice(0,120),I.content.length>120?"…":""]}),a.jsxs("div",{className:"mobile-canvas-el-comments",children:[a.jsx(On,{size:10}),n.comments.filter(k=>k.elementId===I.id).length]})]},I.id))]}),m&&a.jsxs("div",{className:"mobile-canvas-comments",children:[a.jsxs("div",{className:"mobile-canvas-comments-header",children:[a.jsxs("h4",{children:["Comments (",n.comments.length,")"]}),a.jsx("button",{type:"button",className:"mobile-icon-btn",onClick:()=>h(!1),children:a.jsx(Zn,{size:16})})]}),a.jsxs("div",{className:"mobile-canvas-comment-list",children:[n.comments.length===0&&a.jsx("p",{className:"mobile-empty-inline",children:"No comments yet."}),n.comments.map(I=>a.jsxs("div",{className:"mobile-canvas-comment",children:[a.jsxs("div",{className:"mobile-canvas-comment-head",children:[a.jsx("span",{className:"mono",children:I.author}),a.jsx("span",{className:"muted",children:Sr(I.created)})]}),a.jsx("div",{className:"mobile-canvas-comment-text",children:I.text})]},I.id))]}),a.jsxs("div",{className:"mobile-canvas-comment-input",children:[a.jsx("textarea",{className:"mobile-input",rows:2,placeholder:"Add a comment…",value:g,onChange:I=>v(I.target.value)}),a.jsx("button",{type:"button",className:"mobile-btn",disabled:!g.trim(),onClick:()=>{L(g.trim(),null)},children:"Post"})]})]}),c&&a.jsx(Dt,{open:!0,onClose:()=>f(null),title:`Edit ${c.title||c.type}`,actions:a.jsxs("div",{className:"mobile-task-detail-actions",children:[a.jsxs("button",{type:"button",className:"mobile-btn mobile-btn-danger",onClick:()=>A(c.id),children:[a.jsx(_r,{size:14})," Delete"]}),a.jsxs("button",{type:"button",className:"mobile-btn",onClick:()=>y(!0),children:[a.jsx(On,{size:14})," Comment"]})]}),children:a.jsx(cC,{element:c,onSave:I=>E(c.id,I),onClose:()=>f(null)})}),a.jsx(dC,{open:p,onClose:()=>x(!1),onAdd:z}),a.jsx(Tn,{open:b,onClose:()=>y(!1),title:"Add Comment",actions:a.jsxs("button",{type:"button",className:"mobile-btn",style:{width:"100%"},disabled:!g.trim(),onClick:()=>{L(g.trim(),(c==null?void 0:c.id)||null),y(!1)},children:[a.jsx(On,{size:14})," Post"]}),children:a.jsx("textarea",{className:"mobile-input",rows:3,placeholder:"Your comment…",value:g,onChange:I=>v(I.target.value),autoFocus:!0})})]})}function cC({element:e,onSave:t,onClose:n}){const[r,i]=w.useState(e.type),[l,s]=w.useState(e.title||""),[o,u]=w.useState(e.content||""),[d,c]=w.useState(e.status||"open");return a.jsxs("form",{className:"mobile-task-form",onSubmit:f=>{f.preventDefault(),t({type:r,title:l,content:o,status:d}),n()},children:[a.jsx("label",{className:"mobile-field-label",children:"Type"}),a.jsx("select",{className:"mobile-input",value:r,onChange:f=>i(f.target.value),children:Ju.map(f=>a.jsx("option",{value:f.id,children:f.label},f.id))}),a.jsx("label",{className:"mobile-field-label",children:"Title"}),a.jsx("input",{className:"mobile-input",type:"text",value:l,onChange:f=>s(f.target.value)}),a.jsx("label",{className:"mobile-field-label",children:"Status"}),a.jsx("input",{className:"mobile-input",type:"text",value:d,onChange:f=>c(f.target.value),placeholder:"open / done / blocked"}),a.jsx("label",{className:"mobile-field-label",children:"Content (markdown)"}),a.jsx("textarea",{className:"mobile-input",rows:4,value:o,onChange:f=>u(f.target.value)}),a.jsx("button",{type:"submit",className:"mobile-btn",style:{width:"100%",marginTop:8},children:"Save"})]})}function dC({open:e,onClose:t,onAdd:n}){const[r,i]=w.useState("task"),[l,s]=w.useState(""),[o,u]=w.useState(""),d=c=>{c.preventDefault(),l.trim()&&(n(r,l.trim(),o.trim()),s(""),u(""))};return a.jsx(Tn,{open:e,onClose:t,title:"Add Element",actions:a.jsxs("button",{type:"submit",form:"add-el-form",className:"mobile-btn",style:{width:"100%"},children:[a.jsx(xt,{size:14})," Add"]}),children:a.jsxs("form",{id:"add-el-form",onSubmit:d,className:"mobile-task-form",children:[a.jsx("label",{className:"mobile-field-label",children:"Type"}),a.jsx("select",{className:"mobile-input",value:r,onChange:c=>i(c.target.value),children:Ju.map(c=>a.jsx("option",{value:c.id,children:c.label},c.id))}),a.jsx("label",{className:"mobile-field-label",children:"Title *"}),a.jsx("input",{className:"mobile-input",type:"text",placeholder:"Element title",value:l,onChange:c=>s(c.target.value),autoFocus:!0,required:!0}),a.jsx("label",{className:"mobile-field-label",children:"Content (markdown)"}),a.jsx("textarea",{className:"mobile-input",rows:3,placeholder:"Description…",value:o,onChange:c=>u(c.target.value)})]})})}function fC({snapshot:e,onBack:t,onOpenArtifact:n}){const[r,i]=w.useState(e.artifacts||[]),[l,s]=w.useState(!e.artifacts),[o,u]=w.useState(""),[d,c]=w.useState(!1),[f,m]=w.useState(""),[h,p]=w.useState(""),x=async()=>{try{const g=await q.get("/artifacts");i(g.artifacts||[])}catch{}finally{s(!1)}},b=async()=>{if(f.trim())try{const g=await q.post("/artifacts",{slug:f.trim(),title:h.trim()||void 0});c(!1),m(""),p(""),n(g.slug)}catch{}},y=o.trim()?r.filter(g=>(g.title||g.slug||"").toLowerCase().includes(o.toLowerCase())):r;return a.jsxs("div",{className:"mobile-view",children:[a.jsxs("div",{className:"mobile-tasks-toolbar",children:[a.jsx("input",{className:"mobile-search-input",type:"text",placeholder:"Search artifacts…",value:o,onChange:g=>u(g.target.value),style:{flex:1}}),a.jsx("button",{type:"button",className:"mobile-icon-btn",onClick:()=>x(),"aria-label":"Refresh",children:a.jsx(_t,{size:16})})]}),a.jsx("div",{style:{marginBottom:12},children:a.jsxs("button",{type:"button",className:"mobile-btn",style:{width:"100%"},onClick:()=>c(!0),children:[a.jsx(xt,{size:14})," New Artifact"]})}),l?a.jsx("div",{className:"mobile-loading",children:a.jsx("p",{children:"Loading…"})}):y.length===0?a.jsxs("div",{className:"mobile-empty",children:[a.jsx(qn,{size:40}),a.jsx("p",{children:"No artifacts yet."})]}):a.jsx("div",{className:"mobile-card-list",children:y.map(g=>a.jsxs("button",{type:"button",className:"mobile-list-item mobile-list-item-interactive",onClick:()=>n(g.slug),children:[a.jsx("div",{className:"mobile-list-icon",children:a.jsx(qn,{size:16})}),a.jsxs("div",{className:"mobile-list-content",children:[a.jsx("span",{className:"mobile-list-title",children:g.title||g.slug}),a.jsxs("span",{className:"mobile-list-meta",children:[g.status," · ",g.source,g.elementCount!=null?` · ${g.elementCount} elements`:"",g.commentCount!=null?` · ${g.commentCount} comments`:""]})]}),a.jsx("span",{className:"mobile-list-badge","data-status":g.status,children:g.status})]},g.slug))}),a.jsx(Tn,{open:d,onClose:()=>c(!1),title:"New Artifact",actions:a.jsxs("button",{type:"submit",form:"new-plan-form",className:"mobile-btn",style:{width:"100%"},children:[a.jsx(xt,{size:14})," Create"]}),children:a.jsxs("form",{id:"new-plan-form",onSubmit:g=>{g.preventDefault(),b()},className:"mobile-task-form",children:[a.jsx("label",{className:"mobile-field-label",children:"Slug *"}),a.jsx("input",{className:"mobile-input",type:"text",placeholder:"my-plan",pattern:"[a-z0-9][a-z0-9-]{0,63}",value:f,onChange:g=>m(g.target.value),autoFocus:!0,required:!0}),a.jsx("label",{className:"mobile-field-label",children:"Title (optional)"}),a.jsx("input",{className:"mobile-input",type:"text",placeholder:"My Artifact",value:h,onChange:g=>p(g.target.value)})]})})]})}const hC=["cron","interval","once"],mC=["command","agent","webhook"],xf=["UTC","America/New_York","America/Los_Angeles","Europe/London","Europe/Berlin","Asia/Tokyo"],cg=Array.from({length:24},(e,t)=>({value:t,label:t===0?"12 AM":t<12?`${t} AM`:t===12?"12 PM":`${t-12} PM`})),pC=Array.from({length:12},(e,t)=>t*5),dg=[{value:"*",label:"Every day"},{value:"0",label:"Sun"},{value:"1",label:"Mon"},{value:"2",label:"Tue"},{value:"3",label:"Wed"},{value:"4",label:"Thu"},{value:"5",label:"Fri"},{value:"6",label:"Sat"}],gC=[{value:"s",label:"sec"},{value:"m",label:"min"},{value:"h",label:"hr"},{value:"d",label:"day"}];function yC({snapshot:e}){var b;const[t,n]=w.useState(e.schedules||[]),[r,i]=w.useState(!e.schedules),[l,s]=w.useState(""),[o,u]=w.useState(null),[d,c]=w.useState({open:!1}),f=async()=>{try{const y=await q.get("/schedules");n(y.schedules||[])}catch{}finally{i(!1)}};w.useEffect(()=>{e.schedules?(n(e.schedules),i(!1)):f()},[e.schedules]);const m=async(y,g)=>{try{await q.patch(`/schedules/${encodeURIComponent(y)}`,{enabled:g}),n(v=>v.map(C=>C.id===y?{...C,enabled:g}:C)),(o==null?void 0:o.id)===y&&u(v=>v&&{...v,enabled:g})}catch{}},h=async y=>{if(confirm("Delete this schedule?"))try{await q.del(`/schedules/${encodeURIComponent(y)}`),n(g=>g.filter(v=>v.id!==y)),(o==null?void 0:o.id)===y&&u(null)}catch{}},p=async y=>{try{await q.post(`/schedules/${encodeURIComponent(y)}/trigger`)}catch{}},x=l.trim()?t.filter(y=>y.name.toLowerCase().includes(l.toLowerCase())):t;return a.jsxs("div",{className:"mobile-view",children:[a.jsxs("div",{className:"mobile-tasks-toolbar",children:[a.jsx("input",{className:"mobile-search-input",type:"text",placeholder:"Search schedules…",value:l,onChange:y=>s(y.target.value),style:{flex:1}}),a.jsx("button",{type:"button",className:"mobile-icon-btn",onClick:()=>f(),"aria-label":"Refresh",children:a.jsx(_t,{size:16})}),a.jsx("button",{type:"button",className:"mobile-icon-btn",onClick:()=>c({open:!0}),"aria-label":"New schedule",children:a.jsx(xt,{size:16})})]}),r?a.jsx("div",{className:"mobile-loading",children:a.jsx("p",{children:"Loading…"})}):x.length===0?a.jsxs("div",{className:"mobile-empty",children:[a.jsx(va,{size:40}),a.jsx("p",{children:"No schedules found."})]}):a.jsx("div",{className:"mobile-card-list",children:x.map(y=>a.jsxs("button",{type:"button",className:"mobile-list-item mobile-list-item-interactive",onClick:()=>u(y),children:[a.jsx("div",{className:"mobile-list-icon",children:a.jsx(va,{size:16})}),a.jsxs("div",{className:"mobile-list-content",children:[a.jsx("span",{className:"mobile-list-title",children:y.name}),a.jsxs("span",{className:"mobile-list-meta",children:[wf(y)," ·"," ",y.nextRun?`next ${kf(y.nextRun,y.timezone)}`:"no next run"]})]}),a.jsx("span",{className:`mobile-list-badge ${y.enabled?"badge-on":"badge-off"}`,children:y.enabled?"on":"off"})]},y.id))}),o&&a.jsx(Dt,{open:!0,onClose:()=>u(null),title:o.name,actions:a.jsxs("div",{className:"mobile-task-detail-actions",children:[a.jsxs("button",{type:"button",className:"mobile-btn",onClick:()=>{o&&p(o.id)},children:[a.jsx(Zl,{size:14})," Trigger now"]}),a.jsx("button",{type:"button",className:`mobile-btn ${o.enabled?"mobile-btn-secondary":""}`,onClick:()=>{o&&m(o.id,!o.enabled)},children:o.enabled?"Disable":"Enable"}),a.jsxs("button",{type:"button",className:"mobile-btn",onClick:()=>{o&&(c({open:!0,initial:o}),u(null))},children:[a.jsx(Au,{size:14})," Edit"]}),a.jsx("button",{type:"button",className:"mobile-btn mobile-btn-danger",onClick:()=>{o&&h(o.id)},children:a.jsx(_r,{size:14})})]}),children:a.jsx("div",{className:"mobile-agent-detail",children:a.jsxs("div",{className:"mobile-agent-detail-meta",children:[a.jsxs("div",{className:"mobile-task-detail-row",children:[a.jsx("span",{children:"Type"}),a.jsx("span",{children:o.type})]}),a.jsxs("div",{className:"mobile-task-detail-row",children:[a.jsx("span",{children:"Schedule"}),a.jsx("span",{className:"mono",children:wf(o)||o.schedule})]}),o.timezone&&a.jsxs("div",{className:"mobile-task-detail-row",children:[a.jsx("span",{children:"Timezone"}),a.jsx("span",{className:"mono",children:o.timezone})]}),a.jsxs("div",{className:"mobile-task-detail-row",children:[a.jsx("span",{children:"Action"}),a.jsxs("span",{children:[o.action.type,": ",o.action.target]})]}),o.action.type==="agent"&&o.action.prompt&&a.jsxs("div",{className:"mobile-task-detail-row",children:[a.jsx("span",{children:"Prompt"}),a.jsx("span",{style:{fontSize:12},children:o.action.prompt})]}),((b=o.budgetCheck)==null?void 0:b.skipIfBudgetLow)&&a.jsxs("div",{className:"mobile-task-detail-row",children:[a.jsx("span",{children:"Budget gate"}),a.jsxs("span",{children:["skip if ≥ ",o.budgetCheck.maxConcurrent??6," concurrent"]})]}),a.jsxs("div",{className:"mobile-task-detail-row",children:[a.jsx("span",{children:"Next run"}),a.jsx("span",{children:o.nextRun?kf(o.nextRun,o.timezone):"—"})]}),a.jsxs("div",{className:"mobile-task-detail-row",children:[a.jsx("span",{children:"Last run"}),a.jsx("span",{children:o.lastRun?kC(o.lastRun):"—"})]}),o.lastResult&&a.jsxs("div",{className:"mobile-task-detail-row",children:[a.jsx("span",{children:"Last result"}),a.jsx("span",{style:{fontSize:12},children:o.lastResult})]}),o.lastError&&a.jsxs("div",{className:"mobile-task-detail-row",children:[a.jsx("span",{children:"Last error"}),a.jsx("span",{style:{fontSize:12},children:o.lastError})]})]})})}),a.jsx(vC,{open:d.open,initial:d.initial,onClose:()=>c({open:!1}),onSaved:()=>{c({open:!1}),f()}})]})}function vf(e){var r,i;if(!e)return{name:"",type:"cron",cronMinute:0,cronHour:13,cronDow:"0",intervalN:30,intervalUnit:"m",onceAt:"",timezone:"UTC",actionType:"agent",actionTarget:"",actionPrompt:"",skipIfBudgetLow:!1,maxConcurrent:6,enabled:!0};const t=e.type==="cron"?fg(e.schedule):null,n=e.type==="interval"?wC(e.schedule):null;return{name:e.name||"",type:e.type,cronMinute:(t==null?void 0:t.minute)??0,cronHour:(t==null?void 0:t.hour)??9,cronDow:(t==null?void 0:t.dow)??"*",intervalN:(n==null?void 0:n.n)??30,intervalUnit:(n==null?void 0:n.unit)??"m",onceAt:e.type==="once"?bC(e.schedule):"",timezone:e.timezone||"UTC",actionType:e.action.type,actionTarget:e.action.target||"",actionPrompt:e.action.prompt||"",skipIfBudgetLow:!!((r=e.budgetCheck)!=null&&r.skipIfBudgetLow),maxConcurrent:Number.isFinite((i=e.budgetCheck)==null?void 0:i.maxConcurrent)?e.budgetCheck.maxConcurrent:6,enabled:e.enabled!==!1}}function xC(e){if(e.type==="cron")return`${e.cronMinute} ${e.cronHour} * * ${e.cronDow}`;if(e.type==="interval")return`${e.intervalN}${e.intervalUnit}`;if(!e.onceAt)return"";try{return new Date(e.onceAt).toISOString()}catch{return e.onceAt}}function vC({open:e,initial:t,onClose:n,onSaved:r}){const[i,l]=w.useState(()=>vf(t)),[s,o]=w.useState(!1);w.useEffect(()=>{e&&l(vf(t))},[e,t]);const u=(c,f)=>{l(m=>({...m,[c]:f}))},d=async c=>{if(c.preventDefault(),!i.name.trim())return;const f=xC(i);if(f){o(!0);try{const m={name:i.name.trim(),type:i.type,schedule:f,timezone:i.timezone,action:{type:i.actionType,target:i.actionTarget.trim(),...i.actionType==="agent"&&i.actionPrompt.trim()?{prompt:i.actionPrompt.trim()}:{}},budgetCheck:{maxConcurrent:i.maxConcurrent,skipIfBudgetLow:i.skipIfBudgetLow},enabled:i.enabled};t?await q.put(`/schedules/${encodeURIComponent(t.id)}`,m):await q.post("/schedules",m),r()}catch{}finally{o(!1)}}};return a.jsx(Tn,{open:e,onClose:n,title:t?`Edit ${t.name}`:"New schedule",actions:a.jsxs("button",{type:"submit",form:"mobile-schedule-form",className:"mobile-btn",style:{width:"100%"},disabled:s,children:[a.jsx(xt,{size:14})," ",t?"Save":"Create"]}),children:a.jsxs("form",{id:"mobile-schedule-form",onSubmit:d,className:"mobile-task-form",children:[a.jsx("label",{className:"mobile-field-label",children:"Name *"}),a.jsx("input",{className:"mobile-input",type:"text",placeholder:"Weekly review",value:i.name,onChange:c=>u("name",c.target.value),autoFocus:!0,required:!0}),a.jsx("label",{className:"mobile-field-label",children:"Type"}),a.jsx("select",{className:"mobile-input",value:i.type,onChange:c=>u("type",c.target.value),children:hC.map(c=>a.jsx("option",{value:c,children:c},c))}),i.type==="cron"&&a.jsxs(a.Fragment,{children:[a.jsx("label",{className:"mobile-field-label",children:"Day of week"}),a.jsx("select",{className:"mobile-input",value:i.cronDow,onChange:c=>u("cronDow",c.target.value),children:dg.map(c=>a.jsx("option",{value:c.value,children:c.label},c.value))}),a.jsxs("div",{className:"mobile-form-row",children:[a.jsxs("div",{style:{flex:1},children:[a.jsx("label",{className:"mobile-field-label",children:"Hour"}),a.jsx("select",{className:"mobile-input",value:String(i.cronHour),onChange:c=>u("cronHour",parseInt(c.target.value,10)),children:cg.map(c=>a.jsx("option",{value:String(c.value),children:c.label},c.value))})]}),a.jsxs("div",{style:{flex:1},children:[a.jsx("label",{className:"mobile-field-label",children:"Minute"}),a.jsx("select",{className:"mobile-input",value:String(i.cronMinute),onChange:c=>u("cronMinute",parseInt(c.target.value,10)),children:pC.map(c=>a.jsx("option",{value:String(c),children:String(c).padStart(2,"0")},c))})]})]})]}),i.type==="interval"&&a.jsxs("div",{className:"mobile-form-row",children:[a.jsxs("div",{style:{flex:1},children:[a.jsx("label",{className:"mobile-field-label",children:"Every"}),a.jsx("input",{className:"mobile-input",type:"number",min:1,value:i.intervalN,onChange:c=>u("intervalN",parseInt(c.target.value,10)||1)})]}),a.jsxs("div",{style:{flex:1},children:[a.jsx("label",{className:"mobile-field-label",children:"Unit"}),a.jsx("select",{className:"mobile-input",value:i.intervalUnit,onChange:c=>u("intervalUnit",c.target.value),children:gC.map(c=>a.jsx("option",{value:c.value,children:c.label},c.value))})]})]}),i.type==="once"&&a.jsxs(a.Fragment,{children:[a.jsx("label",{className:"mobile-field-label",children:"Run at"}),a.jsx("input",{className:"mobile-input",type:"datetime-local",value:i.onceAt,onChange:c=>u("onceAt",c.target.value)})]}),a.jsx("label",{className:"mobile-field-label",children:"Timezone"}),a.jsx("select",{className:"mobile-input",value:xf.includes(i.timezone)?i.timezone:"UTC",onChange:c=>u("timezone",c.target.value),children:xf.map(c=>a.jsx("option",{value:c,children:c},c))}),a.jsx("label",{className:"mobile-field-label",children:"Action type"}),a.jsx("select",{className:"mobile-input",value:i.actionType,onChange:c=>u("actionType",c.target.value),children:mC.map(c=>a.jsx("option",{value:c,children:c},c))}),a.jsx("label",{className:"mobile-field-label",children:"Target"}),a.jsx("input",{className:"mobile-input",type:"text",placeholder:i.actionType==="webhook"?"https://...":i.actionType==="agent"?"agent or task ref":"echo hello",value:i.actionTarget,onChange:c=>u("actionTarget",c.target.value)}),i.actionType==="agent"&&a.jsxs(a.Fragment,{children:[a.jsx("label",{className:"mobile-field-label",children:"Prompt"}),a.jsx("textarea",{className:"mobile-input",rows:3,placeholder:"What should the agent do?",value:i.actionPrompt,onChange:c=>u("actionPrompt",c.target.value)})]}),a.jsxs("fieldset",{className:"mobile-budget-card",children:[a.jsx("legend",{children:"Budget pre-flight"}),a.jsxs("label",{className:"mobile-checkbox-row",children:[a.jsx("input",{type:"checkbox",checked:i.skipIfBudgetLow,onChange:c=>u("skipIfBudgetLow",c.target.checked)}),a.jsx("span",{children:"Skip if too many bg tasks are running"})]}),a.jsx("label",{className:"mobile-field-label",children:"Cap"}),a.jsx("input",{className:"mobile-input",type:"number",min:1,max:64,value:i.maxConcurrent,onChange:c=>u("maxConcurrent",parseInt(c.target.value,10)||6),disabled:!i.skipIfBudgetLow})]}),a.jsxs("label",{className:"mobile-checkbox-row",children:[a.jsx("input",{type:"checkbox",checked:i.enabled,onChange:c=>u("enabled",c.target.checked)}),a.jsx("span",{children:"Enabled"})]})]})})}function kC(e){const t=Date.now()-new Date(e).getTime();return t<6e4?"just now":t<36e5?`${Math.floor(t/6e4)}m ago`:t<864e5?`${Math.floor(t/36e5)}h ago`:new Date(e).toLocaleDateString()}function kf(e,t){try{return new Date(e).toLocaleString(void 0,{timeZone:t||void 0,weekday:"short",hour:"numeric",minute:"2-digit",month:"short",day:"numeric"})}catch{return new Date(e).toLocaleString()}}function fg(e){if(typeof e!="string")return null;const t=e.trim().split(/\s+/);if(t.length!==5)return null;const[n,r,,,i]=t,l=parseInt(n,10),s=parseInt(r,10);return!Number.isFinite(l)||!Number.isFinite(s)||n!==String(l)||r!==String(s)?null:{minute:l,hour:s,dow:i==="*"?"*":Number.isFinite(parseInt(i,10))?i:"*"}}function wC(e){if(typeof e!="string")return null;const t=/^(\d+)([smhd])$/i.exec(e.trim());return t?{n:parseInt(t[1],10),unit:t[2].toLowerCase()}:null}function bC(e){if(!e)return"";try{const t=new Date(e);if(Number.isNaN(t.getTime()))return"";const n=r=>String(r).padStart(2,"0");return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())}T${n(t.getHours())}:${n(t.getMinutes())}`}catch{return""}}function wf(e){var l,s;if(e.type!=="cron")return e.schedule;const t=fg(e.schedule);if(!t)return e.schedule;const n=((l=dg.find(o=>o.value===t.dow))==null?void 0:l.label)||t.dow,r=((s=cg.find(o=>o.value===t.hour))==null?void 0:s.label)||`${t.hour}`,i=String(t.minute).padStart(2,"0");return n==="Every day"?`Every day ${r} :${i}`:`Every ${n} ${r} :${i}`}const SC=["all","tasks","agents","artifacts","projects","settings"],CC={tasks:es,agents:Dr,plans:qn,projects:Pu,settings:Pr};function jC({open:e,onClose:t,onNavigate:n}){const[r,i]=w.useState(""),[l,s]=w.useState("all"),[o,u]=w.useState([]),[d,c]=w.useState(!1),f=w.useRef(null);w.useEffect(()=>{e&&(i(""),u([]),requestAnimationFrame(()=>{var p;return(p=f.current)==null?void 0:p.focus()}))},[e]),w.useEffect(()=>{if(!r.trim()){u([]);return}const p=setTimeout(async()=>{c(!0);try{const x=await q.get(`/search?q=${encodeURIComponent(r)}&scope=${l}`);u(x.results||[])}catch{u([])}finally{c(!1)}},250);return()=>clearTimeout(p)},[r,l]);const m=p=>{const x=p.item,b=x.id||x.slug||x.name||"";n(p.type,b),t()},h=o.reduce((p,x)=>(p[x.type]||(p[x.type]=[]),p[x.type].push(x),p),{});return a.jsx(Tn,{open:e,onClose:t,title:"Search",children:a.jsxs("div",{className:"mobile-search-container",children:[a.jsxs("div",{className:"mobile-search-input-row",children:[a.jsx(hd,{size:16,style:{color:"var(--text-muted)",flexShrink:0}}),a.jsx("input",{ref:f,className:"mobile-search-field",type:"text",placeholder:"Search…",value:r,onChange:p=>i(p.target.value),enterKeyHint:"search",onKeyDown:p=>{p.key==="Escape"&&t(),p.key==="Enter"&&o.length>0&&m(o[0])}}),r&&a.jsx("button",{type:"button",className:"mobile-icon-btn",onClick:()=>i(""),"aria-label":"Clear",children:a.jsx(Zn,{size:16})})]}),a.jsx("div",{className:"mobile-search-scopes",children:SC.map(p=>a.jsx("button",{type:"button",className:`mobile-scope-chip ${l===p?"active":""}`,onClick:()=>s(p),children:p==="all"?"All":p.charAt(0).toUpperCase()+p.slice(1)},p))}),a.jsxs("div",{className:"mobile-search-results",children:[d&&a.jsx("div",{className:"mobile-search-loading",children:"Searching…"}),!d&&r&&o.length===0&&a.jsxs("div",{className:"mobile-empty",children:[a.jsx(hd,{size:32}),a.jsx("p",{children:"No results found"})]}),!d&&!r&&a.jsx("div",{className:"mobile-empty",children:a.jsx("p",{children:"Type to search across tasks, agents, plans, and more."})}),Object.entries(h).map(([p,x])=>{const b=CC[p]||qn;return a.jsxs("div",{className:"mobile-search-group",children:[a.jsxs("h4",{className:"mobile-search-group-title",children:[a.jsx(b,{size:12})," ",p.charAt(0).toUpperCase()+p.slice(1)," (",x.length,")"]}),x.map((y,g)=>{const v=y.item;return a.jsxs("button",{type:"button",className:"mobile-search-result-item",onClick:()=>m(y),children:[a.jsx("span",{className:"mobile-search-result-title",children:v.title||v.name||v.slug||"(unnamed)"}),v.description&&a.jsx("span",{className:"mobile-search-result-meta",children:v.description.slice(0,80)})]},g)})]},p)})]})]})})}const NC=[{id:"dark",label:"Dark",Icon:ix},{id:"light",label:"Light",Icon:fx},{id:"system",label:"System",Icon:rx}],EC=[{name:"Purple",accent:"#8b5cf6"},{name:"Blue",accent:"#3b82f6"},{name:"Green",accent:"#10b981"},{name:"Orange",accent:"#f97316"},{name:"Red",accent:"#ef4444"},{name:"Pink",accent:"#ec4899"},{name:"Cyan",accent:"#06b6d4"},{name:"Mono",accent:"#6b7280"}];function TC(e){if(e<=0)return"expired";const t=Math.floor(e/1e3),n=Math.floor(t/60),r=t%60;return`${n}:${String(r).padStart(2,"0")}`}function IC({settings:e,snapshot:t,onRefresh:n}){var z,E,A,L,I,k;const[r,i]=w.useState(e),[l,s]=w.useState(!1),[o,u]=w.useState(!1),[d,c]=w.useState(null),[f,m]=w.useState(!1),[h,p]=w.useState(Date.now());w.useEffect(()=>{i(e),s(!1),e.theme&&ui(e.theme)},[e]),w.useEffect(()=>{if(!d)return;const j=setInterval(()=>p(Date.now()),1e3);return()=>clearInterval(j)},[d]);const x=j=>{i(P=>{const B={...P,theme:{...P.theme,...j}};return ts(B.theme),ui(B.theme),B}),s(!0)},b=(j,P)=>{i(B=>({...B,[j]:P})),s(!0)},y=async()=>{u(!0);try{const j=await q.put("/settings",r);i(j.data),s(!1),ts(j.data.theme),ui(j.data.theme),n()}catch{}finally{u(!1)}},g=async()=>{m(!0);try{const j=await q.post("/pair/start");c(j)}catch{}finally{m(!1)}},v=d?d.expiresAt-h:0,C=d!=null&&v<=0;return a.jsxs("div",{className:"mobile-view",children:[l&&a.jsxs("div",{className:"mobile-settings-save-bar",children:[a.jsx("span",{children:"Unsaved changes"}),a.jsxs("button",{type:"button",className:"mobile-btn",disabled:o,onClick:y,children:[a.jsx(Fm,{size:14})," ",o?"Saving…":"Save"]})]}),a.jsxs("section",{className:"mobile-section",children:[a.jsx("h3",{className:"mobile-section-title",children:"Appearance"}),a.jsxs("div",{className:"mobile-card",children:[a.jsxs("div",{className:"mobile-setting-row",children:[a.jsx("span",{className:"mobile-setting-label",children:"Theme"}),a.jsx("div",{className:"mobile-theme-btns",children:NC.map(({id:j,label:P,Icon:B})=>a.jsxs("button",{type:"button",className:`mobile-theme-btn ${r.theme.mode===j?"active":""}`,onClick:()=>x({mode:j}),children:[a.jsx(B,{size:14})," ",P]},j))})]}),a.jsxs("div",{className:"mobile-setting-row",style:{flexDirection:"column",alignItems:"flex-start",gap:8},children:[a.jsx("span",{className:"mobile-setting-label",children:"Accent color"}),a.jsx("div",{className:"mobile-accent-swatches",children:EC.map(j=>a.jsx("button",{type:"button",className:`mobile-accent-swatch ${r.theme.accent===j.accent?"active":""}`,style:{background:j.accent},onClick:()=>x({accent:j.accent}),title:j.name},j.name))})]}),a.jsxs("div",{className:"mobile-setting-row",style:{flexDirection:"column",alignItems:"flex-start",gap:8},children:[a.jsxs("span",{className:"mobile-setting-label",children:["Font size: ",r.theme.fontSize,"px"]}),a.jsx("input",{type:"range",min:12,max:20,value:r.theme.fontSize,onChange:j=>x({fontSize:Number(j.target.value)}),style:{width:"100%"}})]}),a.jsxs("div",{className:"mobile-setting-row",children:[a.jsx("span",{className:"mobile-setting-label",children:"Compact mode"}),a.jsxs("label",{className:"mobile-toggle",children:[a.jsx("input",{type:"checkbox",checked:r.theme.compactMode,onChange:j=>x({compactMode:j.target.checked})}),a.jsx("span",{className:"mobile-toggle-slider"})]})]}),a.jsxs("div",{className:"mobile-setting-row",children:[a.jsx("span",{className:"mobile-setting-label",children:"Animations"}),a.jsxs("label",{className:"mobile-toggle",children:[a.jsx("input",{type:"checkbox",checked:r.theme.animations,onChange:j=>x({animations:j.target.checked})}),a.jsx("span",{className:"mobile-toggle-slider"})]})]})]})]}),a.jsxs("section",{className:"mobile-section",children:[a.jsx("h3",{className:"mobile-section-title",children:"Chat Defaults"}),a.jsxs("div",{className:"mobile-card",children:[a.jsx("label",{className:"mobile-field-label",children:"Default Agent"}),a.jsx("select",{className:"mobile-input",value:r.defaultAgent||"odin",onChange:j=>b("defaultAgent",j.target.value),children:((t==null?void 0:t.agents)||[]).map(j=>a.jsxs("option",{value:j.name,children:["@",j.name]},j.name))}),a.jsx("label",{className:"mobile-field-label",style:{marginTop:8},children:"Default Model"}),a.jsx("input",{className:"mobile-input",type:"text",placeholder:"(auto)",value:r.defaultModel||"",onChange:j=>b("defaultModel",j.target.value)})]})]}),a.jsxs("section",{className:"mobile-section",children:[a.jsx("h3",{className:"mobile-section-title",children:"Notifications"}),a.jsxs("div",{className:"mobile-card",children:[a.jsxs("div",{className:"mobile-setting-row",children:[a.jsx("span",{className:"mobile-setting-label",children:"Agent completion"}),a.jsxs("label",{className:"mobile-toggle",children:[a.jsx("input",{type:"checkbox",checked:!!r.notifications.onAgentComplete,onChange:j=>{i(P=>({...P,notifications:{...P.notifications,onAgentComplete:j.target.checked}})),s(!0)}}),a.jsx("span",{className:"mobile-toggle-slider"})]})]}),a.jsxs("div",{className:"mobile-setting-row",children:[a.jsx("span",{className:"mobile-setting-label",children:"Plan approval"}),a.jsxs("label",{className:"mobile-toggle",children:[a.jsx("input",{type:"checkbox",checked:!!r.notifications.onPlanApproval,onChange:j=>{i(P=>({...P,notifications:{...P.notifications,onPlanApproval:j.target.checked}})),s(!0)}}),a.jsx("span",{className:"mobile-toggle-slider"})]})]})]})]}),a.jsxs("section",{className:"mobile-section",children:[a.jsx("h3",{className:"mobile-section-title",children:"Agent Behavior"}),a.jsxs("div",{className:"mobile-card",children:[a.jsx("label",{className:"mobile-field-label",children:"Max parallel agents"}),a.jsx("input",{className:"mobile-input",type:"number",inputMode:"numeric",min:1,max:20,value:((z=r.agents)==null?void 0:z.maxParallel)??6,onChange:j=>{i(P=>({...P,agents:{...P.agents,maxParallel:Math.max(1,Math.min(20,parseInt(j.target.value,10)||6))}})),s(!0)}}),a.jsx("label",{className:"mobile-field-label",style:{marginTop:8},children:"Stuck threshold (ms)"}),a.jsx("input",{className:"mobile-input",type:"number",inputMode:"numeric",min:6e4,max:36e5,step:6e4,value:((E=r.agents)==null?void 0:E.stuckThresholdMs)??6e5,onChange:j=>{i(P=>({...P,agents:{...P.agents,stuckThresholdMs:Math.max(6e4,parseInt(j.target.value,10)||6e5)}})),s(!0)}}),a.jsxs("div",{className:"mobile-setting-row",style:{marginTop:8},children:[a.jsx("span",{className:"mobile-setting-label",children:"Auto-restart stuck agents"}),a.jsxs("label",{className:"mobile-toggle",children:[a.jsx("input",{type:"checkbox",checked:!!((A=r.agents)!=null&&A.autoRestart),onChange:j=>{i(P=>({...P,agents:{...P.agents,autoRestart:j.target.checked}})),s(!0)}}),a.jsx("span",{className:"mobile-toggle-slider"})]})]})]})]}),a.jsxs("section",{className:"mobile-section",children:[a.jsx("h3",{className:"mobile-section-title",children:"Tailscale Serve"}),a.jsx("div",{className:"mobile-card",children:a.jsxs("p",{className:"muted",style:{fontSize:13},children:["Use ",a.jsx("code",{children:"bizar service"})," commands in the terminal to configure Tailscale serve."]})})]}),a.jsxs("section",{className:"mobile-section",children:[a.jsxs("h3",{className:"mobile-section-title",children:[a.jsx(dx,{size:14})," Companion App"]}),a.jsxs("div",{className:"mobile-card",children:[!d&&a.jsxs("button",{type:"button",className:"mobile-btn",onClick:g,disabled:f,style:{width:"100%"},children:[a.jsx(ox,{size:14})," ",f?"Generating…":"Generate QR Code"]}),d&&!C&&a.jsxs("div",{style:{textAlign:"center"},children:[a.jsx("div",{style:{background:"#fff",padding:12,borderRadius:12,display:"inline-block"},children:a.jsx(ag,{value:d.qrPayload,size:180,level:"M"})}),a.jsxs("div",{style:{marginTop:8,fontSize:12},children:["Expires in ",a.jsx("strong",{children:TC(v)})]}),a.jsx("div",{className:"mono",style:{fontSize:10,wordBreak:"break-all",marginTop:4},children:d.publicUrl})]}),d&&C&&a.jsxs("button",{type:"button",className:"mobile-btn",onClick:g,style:{width:"100%"},children:[a.jsx(_t,{size:14})," Generate new QR"]})]})]}),a.jsxs("section",{className:"mobile-section",children:[a.jsx("h3",{className:"mobile-section-title",children:"About"}),a.jsxs("div",{className:"mobile-card",children:[a.jsxs("div",{className:"mobile-setting-row",children:[a.jsx("span",{className:"mobile-setting-label",children:"Version"}),a.jsx("span",{className:"mobile-setting-value mono",children:((L=r.about)==null?void 0:L.version)||"—"})]}),a.jsxs("div",{className:"mobile-setting-row",children:[a.jsx("span",{className:"mobile-setting-label",children:"Agents"}),a.jsx("span",{className:"mobile-setting-value",children:((I=t==null?void 0:t.agents)==null?void 0:I.length)||0})]}),a.jsxs("div",{className:"mobile-setting-row",children:[a.jsx("span",{className:"mobile-setting-label",children:"Tasks"}),a.jsx("span",{className:"mobile-setting-value",children:((k=t==null?void 0:t.tasks)==null?void 0:k.length)||0})]}),a.jsxs("div",{className:"mobile-setting-row",children:[a.jsx("span",{className:"mobile-setting-label",children:"Plans"}),a.jsx("span",{className:"mobile-setting-value",children:(t==null?void 0:t.artifacts.length)||0})]})]})]}),a.jsx("div",{className:"mobile-view-footer",children:a.jsx("a",{href:"/?desktop=1",className:"mobile-btn mobile-btn-secondary",children:"Switch to Desktop"})})]})}const zC=["languages","framework","design","testing","devops","data","security","integration"];function PC({snapshot:e,onBack:t}){const[n,r]=w.useState([]),[i,l]=w.useState(!0),[s,o]=w.useState(""),[u,d]=w.useState(""),[c,f]=w.useState(null),m=async()=>{try{const x=await q.get("/skills");r(x.skills||[])}catch{}finally{l(!1)}};w.useEffect(()=>{m()},[]);const h=async(x,b)=>{try{await q.patch(`/skills/${encodeURIComponent(x)}`,{enabled:b}),r(y=>y.map(g=>g.id===x?{...g,enabled:b}:g)),(c==null?void 0:c.id)===x&&f(y=>y&&{...y,enabled:b})}catch{}},p=n.filter(x=>{if(u&&x.category!==u)return!1;if(s){const b=s.toLowerCase();return x.name.toLowerCase().includes(b)||x.description.toLowerCase().includes(b)}return!0});return a.jsxs("div",{className:"mobile-view",children:[a.jsxs("div",{className:"mobile-tasks-toolbar",children:[a.jsx("input",{className:"mobile-search-input",type:"text",placeholder:"Search skills…",value:s,onChange:x=>o(x.target.value),style:{flex:1}}),a.jsx("button",{type:"button",className:"mobile-icon-btn",onClick:()=>m(),"aria-label":"Refresh",children:a.jsx(_t,{size:16})})]}),a.jsxs("div",{className:"mobile-search-scopes",children:[a.jsx("button",{type:"button",className:`mobile-scope-chip ${u?"":"active"}`,onClick:()=>d(""),children:"All"}),zC.map(x=>a.jsx("button",{type:"button",className:`mobile-scope-chip ${u===x?"active":""}`,onClick:()=>d(x),children:x},x))]}),i?a.jsx("div",{className:"mobile-loading",children:a.jsx("p",{children:"Loading…"})}):p.length===0?a.jsxs("div",{className:"mobile-empty",children:[a.jsx(Jl,{size:40}),a.jsx("p",{children:"No skills found."})]}):a.jsx("div",{className:"mobile-card-list",children:p.map(x=>a.jsxs("button",{type:"button",className:"mobile-list-item mobile-list-item-interactive",onClick:()=>f(x),children:[a.jsx("div",{className:"mobile-list-icon",children:a.jsx(Jl,{size:16})}),a.jsxs("div",{className:"mobile-list-content",children:[a.jsx("span",{className:"mobile-list-title",children:x.name}),a.jsxs("span",{className:"mobile-list-meta",children:[x.category," · v",x.version]})]}),a.jsx("span",{className:`mobile-list-badge ${x.enabled?"badge-on":"badge-off"}`,children:x.enabled?"on":"off"})]},x.id))}),c&&a.jsx(Dt,{open:!0,onClose:()=>f(null),title:c.name,actions:a.jsxs("button",{type:"button",className:`mobile-btn ${c.enabled?"mobile-btn-secondary":""}`,style:{width:"100%"},onClick:()=>{c&&h(c.id,!c.enabled)},children:[a.jsx(Om,{size:14})," ",c.enabled?"Disable":"Enable"]}),children:a.jsxs("div",{className:"mobile-agent-detail",children:[a.jsx("p",{className:"mobile-agent-detail-desc",children:c.description||"No description."}),a.jsxs("div",{className:"mobile-agent-detail-meta",children:[a.jsxs("div",{className:"mobile-task-detail-row",children:[a.jsx("span",{children:"Category"}),a.jsx("span",{children:c.category})]}),a.jsxs("div",{className:"mobile-task-detail-row",children:[a.jsx("span",{children:"Version"}),a.jsx("span",{className:"mono",children:c.version})]}),a.jsxs("div",{className:"mobile-task-detail-row",children:[a.jsx("span",{children:"Source"}),a.jsx("span",{children:c.source})]}),c.tags.length>0&&a.jsxs("div",{className:"mobile-task-detail-row",children:[a.jsx("span",{children:"Tags"}),a.jsx("span",{children:c.tags.join(", ")})]})]})]})})]})}const AC=["queued","doing","blocked","done"],dl={queued:"Queued",doing:"Doing",blocked:"Blocked",done:"Done"},bf={queued:"doing",doing:"done",blocked:"queued",done:"queued"};function MC(e){const t=e.metadata??{};return!!(t.sessionId||t.bgInstanceId)}function LC(e){var n;const t=e.metadata??{};return!!((n=t.artifactIds)!=null&&n.length||t.artifactId)}function Sf({snapshot:e,onRefresh:t,selectedTaskId:n,onCloseDetail:r,onOpenChat:i,onOpenArtifact:l}){var oe,Ne;const[s,o]=w.useState(e.tasks||[]),[u,d]=w.useState(!e.tasks),[c,f]=w.useState(""),[m,h]=w.useState("queued"),[p,x]=w.useState(null),[b,y]=w.useState(!1),[g,v]=w.useState(null),[C,z]=w.useState([]),[E,A]=w.useState(""),[L,I]=w.useState(null),[k,j]=w.useState(!1),[P,B]=w.useState(""),[O,W]=w.useState("updated");w.useEffect(()=>{var H;if(e.tasks&&(o(e.tasks),d(!1)),n){const te=(H=e.tasks)==null?void 0:H.find(re=>re.id===n);te&&x(te)}},[e.tasks,n]),w.useEffect(()=>{if(n){const H=s.find(te=>te.id===n);H&&x(H)}},[n,s]);const de=async()=>{try{const H=await q.get("/tasks");o(Array.isArray(H)?H:[])}catch{}finally{d(!1)}},ee=async(H,te)=>{o(re=>re.map(Se=>Se.id===H?{...Se,status:te}:Se)),(p==null?void 0:p.id)===H&&x(re=>re&&{...re,status:te});try{await q.patch(`/tasks/${encodeURIComponent(H)}/status`,{status:te})}catch{await de()}},R=async H=>{if(confirm("Delete this task?"))try{await q.del(`/tasks/${encodeURIComponent(H)}`),o(te=>te.filter(re=>re.id!==H)),(p==null?void 0:p.id)===H&&x(null)}catch{await de()}},V=async H=>{try{await q.post(`/tasks/${encodeURIComponent(H)}/archive`),o(te=>te.filter(re=>re.id!==H)),(p==null?void 0:p.id)===H&&x(null)}catch{}},Y=[...s.filter(H=>{var te,re;if(c.trim()){const Se=c.toLowerCase();if(!(H.title||"").toLowerCase().includes(Se)&&!(H.description||"").toLowerCase().includes(Se))return!1}if(P.trim()){const Se=P==="mine"?((re=(te=e.settings)==null?void 0:te.data)==null?void 0:re.defaultAgent)||RC(e):P.replace(/^@/,"");if((H.assignee||"").toLowerCase()!==Se.toLowerCase())return!1}return!0})].sort((H,te)=>{switch(O){case"priority":{const re={high:0,normal:1,low:2};return(re[H.priority]??1)-(re[te.priority]??1)}case"created":return new Date(te.createdAt).getTime()-new Date(H.createdAt).getTime();case"updated":default:return new Date(te.updatedAt).getTime()-new Date(H.updatedAt).getTime()}}),ie=Y.filter(H=>H.status===m),N=e.agents||[],ge=async(H,te,re,Se)=>{try{const Ot=await q.post("/tasks",{title:H,description:te,assignee:re||null,priority:Se});o(ln=>[Ot,...ln]),y(!1)}catch{}},Le=async H=>{j(!0),A(""),I(null),v(H);try{const re=((await q.get(`/tasks/${encodeURIComponent(H)}/artifacts`)).artifacts||[]).map(Se=>Se.id);if(z(re),re.length>0){const[Se,Ot]=await Promise.all([q.get(`/artifacts/${encodeURIComponent(re[0])}`),fetch(q.urlWithToken(`/artifacts/${encodeURIComponent(re[0])}/content`)).then(ln=>ln.text())]);I(Se),A(Ot)}}catch{}finally{j(!1)}};return u?a.jsx("div",{className:"mobile-loading",children:a.jsx("p",{children:"Loading…"})}):a.jsxs("div",{className:"mobile-view mobile-view-tasks",children:[a.jsxs("div",{className:"mobile-tasks-toolbar",children:[a.jsx("input",{className:"mobile-search-input",type:"text",placeholder:"Search tasks…",value:c,onChange:H=>f(H.target.value),style:{flex:1}}),a.jsx("button",{type:"button",className:"mobile-icon-btn",onClick:()=>de(),"aria-label":"Refresh",children:a.jsx(_t,{size:16})})]}),a.jsxs("div",{className:"mobile-tasks-filters",children:[a.jsxs("select",{className:"mobile-filter-select",value:P,onChange:H=>B(H.target.value),children:[a.jsx("option",{value:"",children:"All"}),a.jsx("option",{value:"mine",children:"Mine"}),N.map(H=>a.jsxs("option",{value:`@${H.name}`,children:["@",H.name]},H.name))]}),a.jsxs("select",{className:"mobile-filter-select",value:O,onChange:H=>W(H.target.value),children:[a.jsx("option",{value:"updated",children:"Updated"}),a.jsx("option",{value:"created",children:"Created"}),a.jsx("option",{value:"priority",children:"Priority"})]})]}),a.jsx("div",{className:"mobile-kanban-tabs",children:AC.map(H=>{const te=Y.filter(re=>re.status===H).length;return a.jsxs("button",{type:"button",className:`mobile-kanban-tab ${m===H?"active":""}`,onClick:()=>h(H),children:[dl[H]," (",te,")"]},H)})}),a.jsxs("div",{className:"mobile-card-list",children:[ie.length===0&&a.jsxs("div",{className:"mobile-empty mobile-empty-compact",children:[a.jsxs("p",{children:["No ",dl[m].toLowerCase()," tasks."]}),a.jsx("p",{className:"muted",children:"Create one or switch columns."})]}),ie.map(H=>{var te;return a.jsxs("button",{type:"button",className:"mobile-task-card",onClick:()=>x(H),children:[a.jsx("div",{className:"priority-dot",style:{background:gx[H.priority]||"var(--info)"}}),a.jsxs("div",{className:"task-content",children:[a.jsx("div",{className:"task-title",children:H.title}),a.jsxs("div",{className:"task-meta",children:[H.assignee?`@${H.assignee}`:"unassigned"," · ",Sr(H.updatedAt||H.createdAt),(te=H.dependencies)!=null&&te.length?` · ${H.dependencies.length} deps`:""]})]})]},H.id)})]}),a.jsx("button",{type:"button",className:"mobile-fab",onClick:()=>y(!0),"aria-label":"Add task",children:a.jsx(xt,{size:24})}),a.jsx(Dt,{open:!!p,onClose:()=>{x(null),r==null||r()},title:"Task Detail",actions:p&&a.jsxs("div",{className:"mobile-task-detail-actions",children:[p.status!=="done"&&a.jsxs("button",{type:"button",className:"mobile-btn",style:{flex:1},onClick:()=>{p&&ee(p.id,bf[p.status])},children:["Move to ",dl[bf[p.status]||"queued"]]}),a.jsxs("button",{type:"button",className:"mobile-btn mobile-btn-secondary",onClick:()=>{p&&V(p.id)},children:[a.jsx(V1,{size:14})," Archive"]}),MC(p)&&a.jsxs("button",{type:"button",className:"mobile-btn mobile-btn-secondary",onClick:()=>{i==null||i(p.id)},children:[a.jsx(On,{size:14})," Chat"]}),LC(p)&&a.jsxs("button",{type:"button",className:"mobile-btn mobile-btn-secondary",onClick:()=>{Le(p.id)},children:[a.jsx(qn,{size:14})," Artifact"]}),a.jsx("button",{type:"button",className:"mobile-btn mobile-btn-danger",onClick:()=>{p&&R(p.id)},children:a.jsx(_r,{size:14})})]}),children:p&&a.jsxs("div",{className:"mobile-task-detail",children:[a.jsxs("div",{className:"mobile-task-detail-header",children:[a.jsx("span",{className:`mobile-task-status-badge status-${p.status}`,children:dl[p.status]||p.status}),a.jsx("span",{className:`mobile-task-priority priority-${p.priority}`,children:p.priority})]}),a.jsx("h3",{className:"mobile-task-detail-title",children:p.title}),p.description&&a.jsx("p",{className:"mobile-task-detail-desc",children:p.description}),a.jsxs("div",{className:"mobile-task-detail-meta",children:[p.assignee&&a.jsxs("div",{className:"mobile-task-detail-row",children:[a.jsx("span",{children:"Assignee"}),a.jsxs("span",{children:["@",p.assignee]})]}),p.dueDate&&a.jsxs("div",{className:"mobile-task-detail-row",children:[a.jsx("span",{children:"Due"}),a.jsx("span",{children:new Date(p.dueDate).toLocaleDateString()})]}),p.timeSpent!=null&&a.jsxs("div",{className:"mobile-task-detail-row",children:[a.jsx("span",{children:"Time spent"}),a.jsxs("span",{children:[Math.round(p.timeSpent/6e4),"min"]})]}),(oe=p.dependencies)!=null&&oe.length?a.jsxs("div",{className:"mobile-task-detail-row",children:[a.jsx("span",{children:"Dependencies"}),a.jsx("span",{children:p.dependencies.length})]}):null,(Ne=p.comments)!=null&&Ne.length?a.jsxs("div",{className:"mobile-task-detail-row",children:[a.jsx("span",{children:"Comments"}),a.jsx("span",{children:p.comments.length})]}):null,a.jsxs("div",{className:"mobile-task-detail-row",children:[a.jsx("span",{children:"Created"}),a.jsx("span",{children:Sr(p.createdAt)})]}),a.jsxs("div",{className:"mobile-task-detail-row",children:[a.jsx("span",{children:"Updated"}),a.jsx("span",{children:Sr(p.updatedAt)})]})]})]})}),a.jsx(DC,{open:b,onClose:()=>y(!1),onCreate:ge,agents:N}),a.jsx(Dt,{open:!!g,onClose:()=>{v(null),A(""),I(null)},title:(L==null?void 0:L.name)||"Artifact",actions:C.length>1?a.jsx("div",{className:"mobile-task-detail-actions",children:C.map((H,te)=>a.jsxs("button",{type:"button",className:"mobile-btn mobile-btn-secondary",style:{flex:1},onClick:()=>{j(!0),Promise.all([q.get(`/artifacts/${encodeURIComponent(H)}`),fetch(q.urlWithToken(`/artifacts/${encodeURIComponent(H)}/content`)).then(re=>re.text())]).then(([re,Se])=>{I(re),A(Se),j(!1)}).catch(()=>j(!1))},children:["Artifact ",te+1]},H))}):null,children:a.jsx("div",{className:"mobile-artifact-viewer",children:k?a.jsx("div",{className:"mobile-loading",children:a.jsx("p",{children:"Loading artifact…"})}):E?a.jsx("iframe",{srcDoc:E,className:"mobile-artifact-iframe",sandbox:"allow-scripts allow-forms allow-popups allow-same-origin",title:(L==null?void 0:L.name)||"Artifact",loading:"lazy"}):a.jsxs("div",{className:"mobile-empty",children:[a.jsx(qn,{size:32}),a.jsx("p",{className:"muted",children:"No artifact content available."})]})})})]})}function RC(e){var t,n;return((n=(t=e.settings)==null?void 0:t.data)==null?void 0:n.defaultAgent)||"odin"}function DC({open:e,onClose:t,onCreate:n,agents:r}){const[i,l]=w.useState(""),[s,o]=w.useState(""),[u,d]=w.useState(""),[c,f]=w.useState("normal"),m=h=>{h.preventDefault(),i.trim()&&(n(i.trim(),s.trim(),u,c),l(""),o(""),d(""),f("normal"))};return a.jsx(Tn,{open:e,onClose:t,title:"New Task",actions:a.jsxs("button",{type:"submit",form:"new-task-form",className:"mobile-btn",style:{width:"100%"},children:[a.jsx(xt,{size:14})," Create Task"]}),children:a.jsxs("form",{id:"new-task-form",onSubmit:m,className:"mobile-task-form",children:[a.jsx("label",{className:"mobile-field-label",children:"Title *"}),a.jsx("input",{className:"mobile-input",type:"text",placeholder:"Task title",value:i,onChange:h=>l(h.target.value),autoFocus:!0,required:!0}),a.jsx("label",{className:"mobile-field-label",children:"Description"}),a.jsx("textarea",{className:"mobile-input",rows:3,placeholder:"Optional description",value:s,onChange:h=>o(h.target.value)}),a.jsx("label",{className:"mobile-field-label",children:"Assignee"}),a.jsxs("select",{className:"mobile-input",value:u,onChange:h=>d(h.target.value),children:[a.jsx("option",{value:"",children:"Unassigned"}),r.map(h=>a.jsxs("option",{value:h.name,children:["@",h.name]},h.name))]}),a.jsx("label",{className:"mobile-field-label",children:"Priority"}),a.jsxs("select",{className:"mobile-input",value:c,onChange:h=>f(h.target.value),children:[a.jsx("option",{value:"low",children:"Low"}),a.jsx("option",{value:"normal",children:"Normal"}),a.jsx("option",{value:"high",children:"High"})]})]})})}const _C=[{id:"activity",label:"Activity",icon:xa},{id:"chat",label:"Chat",icon:On},{id:"tasks",label:"Tasks",icon:es},{id:"settings",label:"Settings",icon:Bm},{id:"more",label:"More",icon:J1}];function OC(e){const t=e.meta??{},n=typeof t.taskId=="string"?t.taskId:null,r=typeof t.slug=="string"?t.slug:null,i=typeof t.agent=="string"?t.agent:null;if(n)return{id:"task-detail",taskId:n};if(r)return{id:"artifacts?-detail",slug:r};if(i)return{id:"agent-detail",name:i};const l=e.link??"";return l.startsWith("/artifacts?/")?{id:"artifacts?-detail",slug:decodeURIComponent(l.slice(12))}:l.startsWith("/tasks/")?{id:"task-detail",taskId:decodeURIComponent(l.slice(7))}:l.startsWith("/agents/")?{id:"agent-detail",name:decodeURIComponent(l.slice(8))}:null}function WC(){const[e,t]=w.useState("activity"),[n,r]=w.useState([]),[i,l]=w.useState(!1),[s,o]=w.useState(null),[u,d]=w.useState(null),[c,f]=w.useState(null),[m,h]=w.useState(null),[p,x]=w.useState(!0),[b,y]=w.useState(0),g=w.useMemo(()=>n[n.length-1]??{id:e},[e,n]),v=w.useCallback(k=>{r(j=>[...j,k])},[]),C=w.useCallback(()=>{r(k=>k.slice(0,-1))},[]),z=w.useCallback(k=>{r([]),t(k)},[]),E=w.useCallback(async()=>{var k;try{const j=await q.get("/snapshot");d(j),(k=j.settings)!=null&&k.data&&f(j.settings.data),h(null)}catch(j){throw h(j.message||"Dashboard server unreachable."),j}},[]);w.useEffect(()=>{let k=!1;return Promise.all([q.get("/snapshot").catch(()=>null),q.get("/settings").catch(()=>null),q.probeAuthStatus().catch(()=>null)]).then(([j,P])=>{var O;if(k)return;const B=(P==null?void 0:P.data)??((O=j==null?void 0:j.settings)==null?void 0:O.data)??null;j&&d(j),B&&f(B),h(!j&&!B?"Dashboard server unreachable.":null)}).catch(j=>{k||h(j.message||"Dashboard server unreachable.")}).finally(()=>{k||x(!1)}),()=>{k=!0}},[]),w.useEffect(()=>{c!=null&&c.theme&&(ts(c.theme),ui(c.theme))},[c==null?void 0:c.theme]),w.useEffect(()=>{var P;if(((P=c==null?void 0:c.theme)==null?void 0:P.mode)!=="system")return;const k=window.matchMedia("(prefers-color-scheme: light)"),j=()=>{c!=null&&c.theme&&(ts(c.theme),ui(c.theme))};return k.addEventListener("change",j),()=>k.removeEventListener("change",j)},[c==null?void 0:c.theme]),w.useEffect(()=>{const k=()=>{y(P=>P+1),E().catch(()=>{})},j=()=>{document.visibilityState==="visible"&&k()};return window.addEventListener("online",k),window.addEventListener("pageshow",k),document.addEventListener("visibilitychange",j),()=>{window.removeEventListener("online",k),window.removeEventListener("pageshow",k),document.removeEventListener("visibilitychange",j)}},[E]),w.useEffect(()=>{const k=new Vm,j=k.on(P=>{if(P.type==="snapshot"&&"data"in P&&P.data)d(B=>({...B??{},...P.data}));else if(P.type==="change")E().catch(()=>{});else if(P.type==="tasks:change"){const B=P.task;d(O=>{if(!O)return O;const W=(O.tasks||[]).map(ee=>ee.id===B.id?B:ee),de=W.some(ee=>ee.id===B.id);return{...O,tasks:de?W:[B,...W]}})}else P.type==="tasks:delete"?d(B=>B&&{...B,tasks:(B.tasks||[]).filter(O=>O.id!==P.id)}):P.type==="settings:change"?P.settings&&f(P.settings):P.type==="project:change"||P.type==="agents:change"||P.type==="schedules:change"||P.type==="artifact:change"?E().catch(()=>{}):(P.type==="agent:status"||P.type==="agent:restarted")&&d(B=>{if(!B)return B;const O=(B.agents||[]).map(W=>W.name===P.agent.name?P.agent:W);return{...B,agents:O}})});return()=>{j(),k.close()}},[E,b]);const A=w.useCallback(k=>{(k==="activity"||k==="chat"||k==="tasks"||k==="settings"||k==="more")&&z(k)},[z]),L=w.useCallback((k,j,P)=>{if(k==="notification"){const B=OC({link:j||null,meta:P??null});B&&v(B);return}if(k==="task"&&j){v({id:"task-detail",taskId:j});return}if(k==="artifacts?"&&j){v({id:"artifacts?-detail",slug:j});return}if(k==="agent"&&j){v({id:"agent-detail",name:j});return}if(k==="project"){z("activity");return}k==="setting"&&z("settings")},[z,v]),I=()=>{if(!u||!c)return null;if(n.length>0){const k=n[n.length-1];switch(k.id){case"artifacts?":return a.jsx(fC,{snapshot:u,onBack:C,onOpenArtifact:j=>v({id:"artifacts?-detail",slug:j})});case"agents":return a.jsx(yf,{snapshot:u,onBack:C,onOpenAgent:j=>v({id:"agent-detail",name:j}),onRefresh:E});case"skills":return a.jsx(PC,{snapshot:u,onBack:C});case"mods":return a.jsx(sC,{snapshot:u,onBack:C});case"schedules":return a.jsx(yC,{snapshot:u,onBack:C});case"history":return a.jsx(lC,{onBack:C});case"config":return a.jsx(iC,{onBack:C});case"artifacts?-detail":return a.jsx(uC,{slug:k.slug,onBack:C});case"agent-detail":return a.jsx(yf,{snapshot:u,onBack:C,onOpenAgent:()=>{},onRefresh:E,selectedAgent:k.name});case"task-detail":return a.jsx(Sf,{snapshot:u,onRefresh:E,selectedTaskId:k.taskId,onCloseDetail:C,onOpenChat:j=>{o(j),z("chat")}});default:return null}}switch(e){case"activity":return a.jsx(X2,{snapshot:u,onRefresh:E});case"chat":return a.jsx(rC,{snapshot:u,settings:c,initialTaskId:s,onClearTaskId:()=>o(null)});case"tasks":return a.jsx(Sf,{snapshot:u,onRefresh:E,onOpenChat:k=>{o(k),z("chat")}});case"settings":return a.jsx(IC,{settings:c,snapshot:u,onRefresh:E});case"more":return a.jsx(oC,{snapshot:u,onNavigate:k=>{(k==="artifacts?"||k==="agents"||k==="skills"||k==="mods"||k==="schedules"||k==="history"||k==="config")&&v({id:k})}});default:return null}};return p?a.jsxs("div",{className:"mobile-loading",children:[a.jsx(Wm,{size:"lg"}),a.jsx("p",{children:"Loading Bizar…"})]}):m||!u||!c?a.jsxs("div",{className:"mobile-loading",children:[a.jsx("h2",{children:"Dashboard unavailable"}),a.jsx("p",{children:m||"Dashboard server unreachable."}),a.jsx("p",{className:"muted",children:"Make sure the Bizar dashboard server is running."})]}):a.jsxs("div",{className:"mobile-app",children:[a.jsx(K2,{activeTab:g.id,snapshot:u,onSearch:()=>l(!0),onNavigate:L}),a.jsx("main",{className:"mobile-content",children:I()}),n.length===0&&a.jsx(V2,{tabs:_C,activeTab:e,onChange:A}),n.length>0&&a.jsx("button",{type:"button",className:"mobile-back-btn",onClick:C,"aria-label":"Go back",children:"← Back"}),a.jsx(jC,{open:i,onClose:()=>l(!1),onNavigate:L})]})}export{_e as $,xa as A,Dr as B,q1 as C,cx as D,Z1 as E,Pu as F,hx as G,ka as H,tx as I,Au as J,A2 as K,L2 as L,On as M,Tx as N,j2 as O,xt as P,Fm as Q,_t as R,es as S,mx as T,$C as U,Zl as V,ux as W,Zn as X,md as Y,cb as Z,S2 as _,q as a,V1 as a0,xx as a1,gx as a2,lx as a3,P2 as a4,ui as a5,ax as a6,ix as a7,fx as a8,rx as a9,X1 as aa,ts as ab,Vm as ac,dx as ad,ag as ae,ox as af,W1 as ag,Bm as ah,UC as ai,BC as aj,wa as ak,$1 as al,WC as am,Ss as b,J as c,dd as d,Jl as e,va as f,Pr as g,hd as h,Mu as i,a as j,pr as k,bx as l,cd as m,Y1 as n,Sr as o,qn as p,px as q,w as r,Wm as s,$m as t,kx as u,_r as v,Om as w,Dm as x,Ix as y,T2 as z};
|
|
352
|
-
//# sourceMappingURL=mobile-O6ANdD4W.js.map
|
|
351
|
+
*/var D2={L:gr.QrCode.Ecc.LOW,M:gr.QrCode.Ecc.MEDIUM,Q:gr.QrCode.Ecc.QUARTILE,H:gr.QrCode.Ecc.HIGH},Jp=128,eg="L",tg="#FFFFFF",ng="#000000",rg=!1,ig=1,_2=4,O2=0,F2=.1;function lg(e,t=0){const n=[];return e.forEach(function(r,i){let l=null;r.forEach(function(s,o){if(!s&&l!==null){n.push(`M${l+t} ${i+t}h${o-l}v1H${l+t}z`),l=null;return}if(o===r.length-1){if(!s)return;l===null?n.push(`M${o+t},${i+t} h1v1H${o+t}z`):n.push(`M${l+t},${i+t} h${o+1-l}v1H${l+t}z`);return}s&&l===null&&(l=o)})}),n.join("")}function sg(e,t){return e.slice().map((n,r)=>r<t.y||r>=t.y+t.h?n:n.map((i,l)=>l<t.x||l>=t.x+t.w?i:!1))}function $2(e,t,n,r){if(r==null)return null;const i=e.length+n*2,l=Math.floor(t*F2),s=i/t,o=(r.width||l)*s,u=(r.height||l)*s,d=r.x==null?e.length/2-o/2:r.x*s,c=r.y==null?e.length/2-u/2:r.y*s,f=r.opacity==null?1:r.opacity;let m=null;if(r.excavate){let p=Math.floor(d),x=Math.floor(c),b=Math.ceil(o+d-p),y=Math.ceil(u+c-x);m={x:p,y:x,w:b,h:y}}const h=r.crossOrigin;return{x:d,y:c,h:u,w:o,excavation:m,opacity:f,crossOrigin:h}}function B2(e,t){return t!=null?Math.max(Math.floor(t),0):e?_2:O2}function og({value:e,level:t,minVersion:n,includeMargin:r,marginSize:i,imageSettings:l,size:s,boostLevel:o}){let u=_e.useMemo(()=>{const p=(Array.isArray(e)?e:[e]).reduce((x,b)=>(x.push(...gr.QrSegment.makeSegments(b)),x),[]);return gr.QrCode.encodeSegments(p,D2[t],n,void 0,void 0,o)},[e,t,n,o]);const{cells:d,margin:c,numCells:f,calculatedImageSettings:m}=_e.useMemo(()=>{let h=u.getModules();const p=B2(r,i),x=h.length+p*2,b=$2(h,s,p,l);return{cells:h,margin:p,numCells:x,calculatedImageSettings:b}},[u,s,l,r,i]);return{qrcode:u,margin:c,cells:d,numCells:f,calculatedImageSettings:m}}var U2=function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0}(),H2=_e.forwardRef(function(t,n){const r=t,{value:i,size:l=Jp,level:s=eg,bgColor:o=tg,fgColor:u=ng,includeMargin:d=rg,minVersion:c=ig,boostLevel:f,marginSize:m,imageSettings:h}=r,x=Ra(r,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:b}=x,y=Ra(x,["style"]),g=h==null?void 0:h.src,v=_e.useRef(null),C=_e.useRef(null),z=_e.useCallback(O=>{v.current=O,typeof n=="function"?n(O):n&&(n.current=O)},[n]),[E,A]=_e.useState(!1),{margin:L,cells:I,numCells:k,calculatedImageSettings:j}=og({value:i,level:s,minVersion:c,boostLevel:f,includeMargin:d,marginSize:m,imageSettings:h,size:l});_e.useEffect(()=>{if(v.current!=null){const O=v.current,W=O.getContext("2d");if(!W)return;let de=I;const ee=C.current,R=j!=null&&ee!==null&&ee.complete&&ee.naturalHeight!==0&&ee.naturalWidth!==0;R&&j.excavation!=null&&(de=sg(I,j.excavation));const V=window.devicePixelRatio||1;O.height=O.width=l*V;const S=l/k*V;W.scale(S,S),W.fillStyle=o,W.fillRect(0,0,k,k),W.fillStyle=u,U2?W.fill(new Path2D(lg(de,L))):I.forEach(function(Y,ie){Y.forEach(function(N,ge){N&&W.fillRect(ge+L,ie+L,1,1)})}),j&&(W.globalAlpha=j.opacity),R&&W.drawImage(ee,j.x+L,j.y+L,j.w,j.h)}}),_e.useEffect(()=>{A(!1)},[g]);const P=La({height:l,width:l},b);let B=null;return g!=null&&(B=_e.createElement("img",{src:g,key:g,style:{display:"none"},onLoad:()=>{A(!0)},ref:C,crossOrigin:j==null?void 0:j.crossOrigin})),_e.createElement(_e.Fragment,null,_e.createElement("canvas",La({style:P,height:l,width:l,ref:z,role:"img"},y)),B)});H2.displayName="QRCodeCanvas";var ag=_e.forwardRef(function(t,n){const r=t,{value:i,size:l=Jp,level:s=eg,bgColor:o=tg,fgColor:u=ng,includeMargin:d=rg,minVersion:c=ig,boostLevel:f,title:m,marginSize:h,imageSettings:p}=r,x=Ra(r,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:b,cells:y,numCells:g,calculatedImageSettings:v}=og({value:i,level:s,minVersion:c,boostLevel:f,includeMargin:d,marginSize:h,imageSettings:p,size:l});let C=y,z=null;p!=null&&v!=null&&(v.excavation!=null&&(C=sg(y,v.excavation)),z=_e.createElement("image",{href:p.src,height:v.h,width:v.w,x:v.x+b,y:v.y+b,preserveAspectRatio:"none",opacity:v.opacity,crossOrigin:v.crossOrigin}));const E=lg(C,b);return _e.createElement("svg",La({height:l,width:l,viewBox:`0 0 ${g} ${g}`,ref:n,role:"img"},x),!!m&&_e.createElement("title",null,m),_e.createElement("path",{fill:o,d:`M0,0 h${g}v${g}H0z`,shapeRendering:"crispEdges"}),_e.createElement("path",{fill:u,d:E,shapeRendering:"crispEdges"}),z)});ag.displayName="QRCodeSVG";function V2({tabs:e,activeTab:t,onChange:n}){return a.jsx("nav",{className:"mobile-bottom-nav",role:"navigation","aria-label":"Mobile navigation",children:e.map(r=>{const i=r.icon;return a.jsxs("button",{type:"button",className:Mu("mobile-nav-btn",t===r.id&&"mobile-nav-btn-active"),onClick:()=>n(r.id),"aria-label":r.label,"aria-current":t===r.id?"page":void 0,children:[a.jsx(i,{size:22}),a.jsx("span",{className:"mobile-nav-label",children:r.label})]},r.id)})})}function Dt({open:e,onClose:t,title:n,children:r,actions:i,maxHeight:l="85vh"}){const s=w.useRef(null),o=w.useRef(null),u=w.useId(),d=w.useRef(null),c=w.useRef(null),f=w.useRef(0),m=w.useRef(0),h=()=>{var y;return((y=s.current)==null?void 0:y.querySelectorAll('button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])'))??[]};if(w.useEffect(()=>{if(!e)return;d.current=document.activeElement instanceof HTMLElement?document.activeElement:null;const y=g=>{var A;if(g.key==="Escape"&&t(),g.key!=="Tab")return;const v=Array.from(h());if(v.length===0){g.preventDefault(),(A=s.current)==null||A.focus();return}const C=v[0],z=v[v.length-1],E=document.activeElement;if(g.shiftKey){(!E||E===C||E===s.current)&&(g.preventDefault(),z==null||z.focus());return}E===z&&(g.preventDefault(),C==null||C.focus())};return window.addEventListener("keydown",y),requestAnimationFrame(()=>{var g,v;((g=o.current)==null?void 0:g.focus())??((v=s.current)==null||v.focus())}),()=>{var g;window.removeEventListener("keydown",y),(g=d.current)==null||g.focus()}},[e,t]),w.useEffect(()=>(e?(m.current=window.scrollY,document.documentElement.style.overflow="hidden",document.body.style.overflow="hidden",document.body.style.position="fixed",document.body.style.top=`-${m.current}px`,document.body.style.left="0",document.body.style.right="0",document.body.style.width="100%"):(document.documentElement.style.overflow="",document.body.style.overflow="",document.body.style.position="",document.body.style.top="",document.body.style.left="",document.body.style.right="",document.body.style.width=""),()=>{document.documentElement.style.overflow="",document.body.style.overflow="",document.body.style.position="",document.body.style.top="",document.body.style.left="",document.body.style.right="",document.body.style.width="",window.scrollTo(0,m.current)}),[e]),!e)return null;const p=y=>{var g;y.isPrimary&&(c.current=y.clientY,f.current=0,(g=s.current)==null||g.setPointerCapture(y.pointerId))},x=y=>{if(c.current==null||!s.current)return;const g=Math.max(0,y.clientY-c.current);f.current=g,s.current.style.transform=`translateY(${g}px)`},b=y=>{if(!s.current)return;y&&s.current.hasPointerCapture(y.pointerId)&&s.current.releasePointerCapture(y.pointerId);const g=f.current;s.current.style.transform="",c.current=null,f.current=0,g>72&&t()};return a.jsx("div",{className:"mobile-sheet-overlay",onClick:t,children:a.jsxs("div",{ref:s,className:"mobile-sheet",style:{maxHeight:l},onClick:y=>y.stopPropagation(),role:"dialog","aria-modal":!0,"aria-label":n?void 0:"Sheet","aria-labelledby":n?u:void 0,tabIndex:-1,children:[a.jsx("div",{className:"mobile-sheet-handle",onPointerDown:p,onPointerMove:x,onPointerUp:b,onPointerCancel:b,"aria-hidden":"true"}),a.jsxs("div",{className:"mobile-sheet-header",children:[n?a.jsx("h3",{id:u,className:"mobile-sheet-title",children:n}):a.jsx("div",{}),a.jsx("button",{ref:o,type:"button",className:"mobile-icon-btn",onClick:t,"aria-label":"Close",children:a.jsx(Zn,{size:18})})]}),a.jsx("div",{className:"mobile-sheet-content",children:r}),i&&a.jsx("div",{className:"mobile-sheet-actions",children:i})]})})}function W2(e){switch(e){case"success":return"✓";case"error":return"✗";case"warning":return"⚠";default:return"ℹ"}}function Q2(e){const t=new Date(e),r=Date.now()-t.getTime();return r<6e4?"just now":r<36e5?`${Math.floor(r/6e4)}m ago`:r<864e5?`${Math.floor(r/36e5)}h ago`:t.toLocaleDateString()}function q2({onSelect:e}){const[t,n]=w.useState(!1),[r,i]=w.useState([]),[l,s]=w.useState(0),o=async()=>{var c;try{const f=await q.get("/notifications");i(f.notifications||[]),s(((c=f.stats)==null?void 0:c.unread)||0)}catch{}};w.useEffect(()=>{o()},[]),w.useEffect(()=>{t&&o()},[t]);const u=async()=>{try{await q.post("/notifications/read-all"),i(c=>c.map(f=>({...f,read:!0}))),s(0)}catch{}},d=async c=>{try{await q.post(`/notifications/${encodeURIComponent(c)}/read`),i(f=>f.map(m=>m.id===c?{...m,read:!0}:m)),s(f=>Math.max(0,f-1))}catch{}};return a.jsxs(a.Fragment,{children:[a.jsxs("button",{type:"button",className:"mobile-icon-btn mobile-notif-btn",onClick:()=>n(!0),"aria-label":`Notifications${l>0?` (${l} unread)`:""}`,children:[a.jsx(cd,{size:20}),l>0&&a.jsx("span",{className:"mobile-notif-badge",children:l>9?"9+":l})]}),a.jsx(Dt,{open:t,onClose:()=>n(!1),title:"Notifications",actions:l>0?a.jsxs("button",{type:"button",className:"mobile-btn mobile-btn-secondary",style:{width:"100%"},onClick:u,children:[a.jsx(Q1,{size:14})," Mark all read"]}):void 0,children:a.jsxs("div",{className:"mobile-notif-list",children:[r.length===0&&a.jsxs("div",{className:"mobile-empty",children:[a.jsx(cd,{size:32}),a.jsx("p",{children:"No notifications"})]}),r.map(c=>a.jsxs("button",{type:"button",className:`mobile-notif-item ${c.read?"read":"unread"}`,onClick:()=>{c.read||d(c.id),e(c),n(!1)},children:[a.jsx("span",{className:`mobile-notif-icon severity-${c.severity}`,children:W2(c.severity)}),a.jsxs("div",{className:"mobile-notif-body",children:[a.jsx("span",{className:"mobile-notif-title",children:c.title||c.message}),c.message&&c.title&&a.jsx("span",{className:"mobile-notif-text",children:c.message}),a.jsx("span",{className:"mobile-notif-time",children:Q2(c.ts)})]}),!c.read&&a.jsx("span",{className:"mobile-notif-dot"})]},c.id))]})})]})}const Y2={activity:"Activity",chat:"Chat",tasks:"Tasks",settings:"Settings",more:"More",plans:"Plans",agents:"Agents",skills:"Skills",mods:"Mods",schedules:"Schedules",history:"History",config:"Config","plan-detail":"Plan","agent-detail":"Agent","task-detail":"Task"};function K2({activeTab:e,snapshot:t,onSearch:n,onNavigate:r}){const[i,l]=w.useState(!1),s=async o=>{try{await q.post(`/projects/${encodeURIComponent(o)}/activate`),l(!1),window.location.reload()}catch{}};return a.jsxs("header",{className:"mobile-topbar",children:[a.jsxs("div",{className:"mobile-topbar-left",children:[a.jsx("span",{className:"mobile-logo",children:"ᛒ"}),(t==null?void 0:t.activeProject)&&a.jsxs("button",{type:"button",className:"mobile-project-btn",onClick:()=>l(!0),"aria-label":"Select project",children:[a.jsx("span",{className:"mobile-project-name",children:t.activeProject.name}),a.jsx(Ss,{size:14})]}),a.jsx("span",{className:"mobile-title",children:Y2[e]||"Bizar"})]}),a.jsxs("div",{className:"mobile-topbar-right",children:[a.jsx("button",{type:"button",className:"mobile-icon-btn",onClick:n,"aria-label":"Search",children:a.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[a.jsx("circle",{cx:"11",cy:"11",r:"8"}),a.jsx("path",{d:"m21 21-4.35-4.35"})]})}),a.jsx(q2,{onSelect:o=>{r("notification",o.link||"",o.meta??null)}}),(t==null?void 0:t.activeProject)&&a.jsx(Dt,{open:i,onClose:()=>l(!1),title:"Projects",children:a.jsx("div",{className:"mobile-project-list",children:(t.projects||[]).map(o=>{var u,d;return a.jsxs("button",{type:"button",className:`mobile-project-item ${o.id===((u=t.activeProject)==null?void 0:u.id)?"active":""}`,onClick:()=>s(o.id),children:[a.jsx("div",{className:"mobile-project-status","data-status":o.status}),a.jsxs("div",{className:"mobile-project-info",children:[a.jsx("span",{className:"mobile-project-item-name",children:o.name}),a.jsx("span",{className:"mobile-project-item-path",children:o.path})]}),o.id===((d=t.activeProject)==null?void 0:d.id)&&a.jsx("span",{className:"mobile-active-badge",children:"active"})]},o.id)})})})]})]})}const G2=["all","tasks","agents","bg","artifacts","mods"],Co={all:"All",tasks:"Tasks",agents:"Agents",bg:"Background",artifacts:"Plans",mods:"Mods"};function X2({snapshot:e,onRefresh:t}){var L;const[n,r]=w.useState(((L=e.overview)==null?void 0:L.recentActivity)||[]),[i,l]=w.useState(!0),[s,o]=w.useState("all"),[u,d]=w.useState(!1),[c,f]=w.useState(null),[m,h]=w.useState(""),[p,x]=w.useState(!1);w.useEffect(()=>{var I;(I=e.overview)!=null&&I.recentActivity?(r(e.overview.recentActivity),l(!1)):b()},[e.overview]);const b=async()=>{var I;try{const k=await q.get("/snapshot");r(((I=k.overview)==null?void 0:I.recentActivity)||[])}catch{}finally{l(!1)}},y=s==="all"?n:n.filter(I=>{var k,j,P,B,O,W;return s==="tasks"?(k=I.kind)==null?void 0:k.startsWith("task"):s==="agents"?(j=I.kind)==null?void 0:j.startsWith("agent"):s==="bg"?((P=I.kind)==null?void 0:P.includes("bg"))||((B=I.kind)==null?void 0:B.includes("schedule")):s==="artifacts"?(O=I.kind)==null?void 0:O.includes("artifacts"):s==="mods"?(W=I.kind)==null?void 0:W.includes("mod"):!0}),g=e.agents||[],v=e.tasks||[],C=v.filter(I=>I.status==="doing"||I.status==="queued"),z=v.filter(I=>I.status==="done"),E=async()=>{if(!(!m.trim()||p)){x(!0);try{await q.post("/chat",{message:m.trim(),agent:"odin"}),h(""),await t().catch(()=>{}),await b()}catch{}finally{x(!1)}}},A=async()=>{await t().catch(()=>{}),await b()};return a.jsxs("div",{className:"mobile-view",children:[a.jsxs("div",{className:"mobile-submit-hero",children:[a.jsx("textarea",{className:"mobile-submit-input",placeholder:"What needs to be done? Describe a task, bug, or refactor for Odin to artifacts…",value:m,onChange:I=>h(I.target.value),rows:2}),a.jsxs("div",{className:"mobile-submit-actions",children:[a.jsx("div",{className:"mobile-submit-chips",children:["Implement feature","Fix bug","Refactor","Investigate","Write tests"].map(I=>a.jsx("button",{type:"button",className:"mobile-submit-chip",onClick:()=>h(k=>k?`${k} ${I}`:I),children:I},I))}),a.jsxs("button",{type:"button",className:"mobile-btn",disabled:!m.trim()||p,onClick:E,children:[a.jsx($m,{size:14})," Submit to Odin"]})]})]}),a.jsxs("div",{className:"mobile-stats",children:[a.jsxs("div",{className:"mobile-stat",children:[a.jsx("div",{className:"mobile-stat-value",children:g.length}),a.jsx("div",{className:"mobile-stat-label",children:"Agents"})]}),a.jsxs("div",{className:"mobile-stat",children:[a.jsx("div",{className:"mobile-stat-value",children:C.length}),a.jsx("div",{className:"mobile-stat-label",children:"Active"})]}),a.jsxs("div",{className:"mobile-stat",children:[a.jsx("div",{className:"mobile-stat-value",children:z.length}),a.jsx("div",{className:"mobile-stat-label",children:"Done"})]}),a.jsxs("div",{className:"mobile-stat",children:[a.jsx("div",{className:"mobile-stat-value",children:e.artifacts.length||0}),a.jsx("div",{className:"mobile-stat-label",children:"Plans"})]})]}),i&&n.length===0&&a.jsx("div",{className:"mobile-loading mobile-loading-inline",children:a.jsx("p",{children:"Loading activity…"})}),a.jsxs("div",{className:"mobile-activity-header",children:[a.jsx("h3",{className:"mobile-section-title",style:{margin:0},children:"Recent Activity"}),a.jsxs("div",{style:{display:"flex",gap:4},children:[a.jsx("button",{type:"button",className:"mobile-icon-btn",onClick:()=>d(I=>!I),"aria-label":u?"Resume":"Pause",children:u?a.jsx(Zl,{size:14}):a.jsx(lx,{size:14})}),a.jsx("button",{type:"button",className:"mobile-icon-btn",onClick:A,"aria-label":"Refresh",children:a.jsx(_t,{size:14})})]})]}),a.jsx("div",{className:"mobile-search-scopes",children:G2.map(I=>a.jsx("button",{type:"button",className:`mobile-scope-chip ${s===I?"active":""}`,onClick:()=>o(I),children:Co[I]},I))}),g.length>0&&a.jsxs("section",{className:"mobile-section",children:[a.jsxs("h3",{className:"mobile-section-title",children:[a.jsx(Dr,{size:14})," Agents"]}),a.jsx("div",{className:"mobile-card-list",children:g.slice(0,6).map(I=>a.jsxs("div",{className:"mobile-agent-card",children:[a.jsx("div",{className:"mobile-agent-dot","data-status":I.status||"idle"}),a.jsxs("div",{className:"mobile-agent-info",children:[a.jsx("span",{className:"mobile-agent-name",children:I.name}),a.jsx("span",{className:"mobile-agent-meta",children:I.status||"idle"})]})]},I.name))})]}),!u&&y.length>0&&a.jsx("section",{className:"mobile-section",children:a.jsx("div",{className:"mobile-card-list",children:y.slice(0,30).map((I,k)=>a.jsxs("button",{type:"button",className:"mobile-event-item",onClick:()=>f(I),children:[a.jsx("span",{className:"mobile-event-kind","data-kind":I.kind,children:Co[I.kind]||I.kind}),a.jsx("span",{className:"mobile-event-msg",children:Z2(I)}),a.jsx("span",{className:"mobile-event-time",children:Sr(I.ts)})]},`${I.ts}-${I.kind}-${k}`))})}),!u&&y.length===0&&n.length>0&&a.jsxs("div",{className:"mobile-empty",children:[a.jsx(xa,{size:40}),a.jsx("p",{children:"No matching activity."}),a.jsx("p",{className:"muted",children:"Try a different filter."})]}),c&&a.jsx(Dt,{open:!0,onClose:()=>f(null),title:Co[c.kind]||c.kind,children:a.jsxs("div",{className:"mobile-agent-detail-meta",children:[a.jsxs("div",{className:"mobile-task-detail-row",children:[a.jsx("span",{children:"Kind"}),a.jsx("span",{children:c.kind})]}),a.jsxs("div",{className:"mobile-task-detail-row",children:[a.jsx("span",{children:"Time"}),a.jsx("span",{children:new Date(c.ts).toLocaleString()})]}),Object.entries(c).filter(([I])=>!["ts","kind"].includes(I)).map(([I,k])=>a.jsxs("div",{className:"mobile-task-detail-row",children:[a.jsx("span",{children:I}),a.jsx("span",{style:{fontSize:12,maxWidth:200,wordBreak:"break-all"},children:typeof k=="object"?JSON.stringify(k):String(k)})]},I))]})}),g.length===0&&C.length===0&&a.jsxs("div",{className:"mobile-empty",children:[a.jsx(xa,{size:40}),a.jsx("p",{children:"No activity yet."}),a.jsx("p",{className:"muted",children:"Start a task or chat to see things here."})]})]})}function Z2(e){const t=e.kind||"";return t.includes("task")?`Task: ${e.title||e.id||"updated"}`:t.includes("agent")?`Agent: ${e.name||"status changed"}`:t.includes("artifacts")?`Plan: ${e.slug||"changed"}`:t.includes("mod")?`Mod: ${e.name||"changed"}`:t.includes("schedule")?`Schedule: ${e.name||"triggered"}`:JSON.stringify(e).slice(0,80)}function Tn({open:e,onClose:t,title:n,children:r,actions:i}){const l=w.useRef(null),s=w.useRef(null),o=w.useRef(null),u=w.useId(),d=w.useRef(0);return w.useEffect(()=>{if(!e)return;o.current=document.activeElement instanceof HTMLElement?document.activeElement:null;const c='button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])',f=m=>{var y,g;if(m.key==="Escape"&&t(),m.key!=="Tab")return;const h=Array.from(((y=l.current)==null?void 0:y.querySelectorAll(c))??[]);if(h.length===0){m.preventDefault(),(g=l.current)==null||g.focus();return}const p=h[0],x=h[h.length-1],b=document.activeElement;if(m.shiftKey){(!b||b===p||b===l.current)&&(m.preventDefault(),x==null||x.focus());return}b===x&&(m.preventDefault(),p==null||p.focus())};return window.addEventListener("keydown",f),d.current=window.scrollY,document.documentElement.style.overflow="hidden",document.body.style.overflow="hidden",document.body.style.position="fixed",document.body.style.top=`-${d.current}px`,document.body.style.left="0",document.body.style.right="0",document.body.style.width="100%",requestAnimationFrame(()=>{var m,h;((m=s.current)==null?void 0:m.focus())??((h=l.current)==null||h.focus())}),()=>{var m;window.removeEventListener("keydown",f),document.documentElement.style.overflow="",document.body.style.overflow="",document.body.style.position="",document.body.style.top="",document.body.style.left="",document.body.style.right="",document.body.style.width="",window.scrollTo(0,d.current),(m=o.current)==null||m.focus()}},[e,t]),e?a.jsx("div",{className:"mobile-modal-overlay",onClick:c=>{c.target===c.currentTarget&&t()},children:a.jsxs("div",{ref:l,className:"mobile-modal",onClick:c=>c.stopPropagation(),role:"dialog","aria-modal":!0,"aria-label":n?void 0:"Modal","aria-labelledby":n?u:void 0,tabIndex:-1,children:[a.jsxs("div",{className:"mobile-modal-header",children:[n?a.jsx("h2",{id:u,className:"mobile-modal-title",children:n}):a.jsx("div",{}),a.jsx("button",{ref:s,type:"button",className:"mobile-icon-btn",onClick:t,"aria-label":"Close",children:a.jsx(Zn,{size:20})})]}),a.jsx("div",{className:"mobile-modal-content",children:r}),i&&a.jsx("div",{className:"mobile-modal-actions",children:i})]})}):null}const ug=["reasoning","code","design","planning","gitops","analysis"],gf={reasoning:"var(--accent)",code:"var(--info)",design:"var(--success)",planning:"var(--warning)",gitops:"var(--error)",analysis:"var(--text-dim)"};function yf({snapshot:e,onBack:t,onOpenAgent:n,selectedAgent:r,onRefresh:i}){const[l,s]=w.useState(e.agents||[]),[o,u]=w.useState(!e.agents),[d,c]=w.useState(""),[f,m]=w.useState(""),[h,p]=w.useState(null),[x,b]=w.useState(!1),[y,g]=w.useState(""),[v,C]=w.useState(!1);w.useEffect(()=>{if(r){const j=l.find(P=>P.name===r);j&&p(j)}},[r,l]);const z=async()=>{try{const j=await q.get("/agents");s(j.agents||[])}catch{}finally{u(!1)}},E=l.filter(j=>{if(d&&j.category!==d)return!1;if(f){const P=f.toLowerCase();if(!j.name.toLowerCase().includes(P)&&!(j.description||"").toLowerCase().includes(P))return!1}return!0}),A=async(j,P)=>{try{await q.post(`/agents/${encodeURIComponent(j)}/invoke`,{prompt:P}),C(!1),g("")}catch{}},L=async j=>{try{await q.post(`/agents/${encodeURIComponent(j)}/restart`),await z()}catch{}},I=async j=>{if(confirm(`Delete agent "${j}"?`))try{await q.del(`/agents/${encodeURIComponent(j)}`),s(P=>P.filter(B=>B.name!==j)),p(null),i==null||i()}catch{}},k=async j=>{try{const P=await q.post("/agents",j);s(B=>[...B,P]),b(!1),i==null||i()}catch{}};return a.jsxs("div",{className:"mobile-view",children:[a.jsxs("div",{className:"mobile-tasks-toolbar",children:[a.jsx("input",{className:"mobile-search-input",type:"text",placeholder:"Search agents…",value:f,onChange:j=>m(j.target.value),style:{flex:1}}),a.jsx("button",{type:"button",className:"mobile-icon-btn",onClick:()=>z(),"aria-label":"Refresh",children:a.jsx(_t,{size:16})}),a.jsx("button",{type:"button",className:"mobile-icon-btn",onClick:()=>b(!0),"aria-label":"New agent",children:a.jsx(xt,{size:16})})]}),a.jsxs("div",{className:"mobile-search-scopes",children:[a.jsx("button",{type:"button",className:`mobile-scope-chip ${d?"":"active"}`,onClick:()=>c(""),children:"All"}),ug.map(j=>a.jsx("button",{type:"button",className:`mobile-scope-chip ${d===j?"active":""}`,onClick:()=>c(j),children:j},j))]}),o?a.jsx("div",{className:"mobile-loading",children:a.jsx("p",{children:"Loading…"})}):E.length===0?a.jsxs("div",{className:"mobile-empty",children:[a.jsx(Dr,{size:40}),a.jsx("p",{children:"No agents found."})]}):a.jsx("div",{className:"mobile-card-list",children:E.map(j=>a.jsxs("button",{type:"button",className:"mobile-list-item mobile-list-item-interactive",onClick:()=>{p(j),n(j.name)},children:[a.jsx("div",{className:"mobile-agent-dot","data-status":j.status||"idle"}),a.jsxs("div",{className:"mobile-list-content",children:[a.jsx("span",{className:"mobile-list-title",children:j.name}),a.jsx("span",{className:"mobile-list-meta",children:j.model||j.mode||"—"})]}),j.category&&a.jsx("span",{className:"mobile-list-badge",style:{color:gf[j.category]||"var(--text-dim)"},children:j.category}),a.jsx("span",{className:"mobile-list-badge","data-status":j.status||"idle",children:j.status||"idle"})]},j.name))}),h&&a.jsx(Dt,{open:!0,onClose:()=>p(null),title:h.name,actions:a.jsxs("div",{className:"mobile-task-detail-actions",children:[a.jsxs("button",{type:"button",className:"mobile-btn",onClick:()=>{g(""),C(!0)},children:[a.jsx(Zl,{size:14})," Invoke"]}),(h.isStuck||h.status==="error"||h.status==="working")&&a.jsxs("button",{type:"button",className:"mobile-btn mobile-btn-secondary",onClick:()=>L(h.name),children:[a.jsx(ux,{size:14})," Restart"]}),a.jsx("button",{type:"button",className:"mobile-btn mobile-btn-danger",onClick:()=>I(h.name),children:a.jsx(_r,{size:14})})]}),children:a.jsxs("div",{className:"mobile-agent-detail",children:[a.jsxs("div",{className:"mobile-agent-detail-status",children:[a.jsx("span",{className:"mobile-agent-dot","data-status":h.status||"idle"}),a.jsx("span",{className:"mobile-agent-detail-status-text",children:h.status||"idle"}),h.category&&a.jsx("span",{className:"mobile-list-badge",style:{color:gf[h.category]},children:h.category})]}),a.jsx("p",{className:"mobile-agent-detail-desc",children:h.description||"No description."}),a.jsxs("div",{className:"mobile-agent-detail-meta",children:[a.jsxs("div",{className:"mobile-task-detail-row",children:[a.jsx("span",{children:"Model"}),a.jsx("span",{className:"mono",children:h.model||"—"})]}),a.jsxs("div",{className:"mobile-task-detail-row",children:[a.jsx("span",{children:"Mode"}),a.jsx("span",{children:h.mode||"subagent"})]}),a.jsxs("div",{className:"mobile-task-detail-row",children:[a.jsx("span",{children:"Path"}),a.jsx("span",{className:"mono",style:{fontSize:11},children:h.path})]}),h.lastError&&a.jsxs("div",{className:"mobile-task-detail-row",style:{color:"var(--error)"},children:[a.jsx("span",{children:"Last error"}),a.jsx("span",{children:h.lastError.message})]}),h.tasksTotal!=null&&h.tasksTotal>0&&a.jsxs("div",{className:"mobile-task-detail-row",children:[a.jsx("span",{children:"Success rate"}),a.jsxs("span",{children:[Math.round((h.successRate||0)*100),"%"]})]}),a.jsxs("div",{className:"mobile-task-detail-row",children:[a.jsx("span",{children:"Last modified"}),a.jsx("span",{children:Sr(h.mtime)})]})]})]})}),a.jsxs(Tn,{open:v,onClose:()=>C(!1),title:`Invoke ${h==null?void 0:h.name}`,actions:a.jsxs("button",{type:"button",className:"mobile-btn",style:{width:"100%"},disabled:!y.trim(),onClick:()=>{h&&A(h.name,y.trim())},children:[a.jsx(Zl,{size:14})," Invoke"]}),children:[a.jsxs("p",{className:"muted",style:{marginBottom:12},children:["Model: ",a.jsx("span",{className:"mono",children:(h==null?void 0:h.model)||"—"})]}),a.jsx("textarea",{className:"mobile-input",rows:5,placeholder:"What should this agent do?",value:y,onChange:j=>g(j.target.value),autoFocus:!0})]}),a.jsx(J2,{open:x,onClose:()=>b(!1),onCreate:k})]})}function J2({open:e,onClose:t,onCreate:n}){const[r,i]=w.useState(""),[l,s]=w.useState(""),[o,u]=w.useState(""),[d,c]=w.useState("subagent"),[f,m]=w.useState("#8b5cf6"),[h,p]=w.useState(""),[x,b]=w.useState(""),[y,g]=w.useState(""),v=C=>{C.preventDefault(),r.trim()&&(n({name:r.trim(),description:l.trim(),model:o,mode:d,color:f,tools:[],tags:x.split(",").map(z=>z.trim()).filter(Boolean),category:h,prompt:y}),i(""),s(""),u(""),c("subagent"),m("#8b5cf6"),p(""),b(""),g(""))};return a.jsx(Tn,{open:e,onClose:t,title:"New Agent",actions:a.jsxs("button",{type:"submit",form:"new-agent-form",className:"mobile-btn",style:{width:"100%"},children:[a.jsx(xt,{size:14})," Create"]}),children:a.jsxs("form",{id:"new-agent-form",onSubmit:v,className:"mobile-task-form",children:[a.jsx("label",{className:"mobile-field-label",children:"Name *"}),a.jsx("input",{className:"mobile-input",type:"text",placeholder:"my-agent",pattern:"[a-z0-9][a-z0-9-]{0,63}",value:r,onChange:C=>i(C.target.value),autoFocus:!0,required:!0}),a.jsx("label",{className:"mobile-field-label",children:"Description"}),a.jsx("input",{className:"mobile-input",type:"text",placeholder:"What does this agent do?",value:l,onChange:C=>s(C.target.value)}),a.jsx("label",{className:"mobile-field-label",children:"Model"}),a.jsx("input",{className:"mobile-input",type:"text",placeholder:"(provider default)",value:o,onChange:C=>u(C.target.value)}),a.jsx("label",{className:"mobile-field-label",children:"Category"}),a.jsxs("select",{className:"mobile-input",value:h,onChange:C=>p(C.target.value),children:[a.jsx("option",{value:"",children:"None"}),ug.map(C=>a.jsx("option",{value:C,children:C},C))]}),a.jsx("label",{className:"mobile-field-label",children:"Tags (comma-separated)"}),a.jsx("input",{className:"mobile-input",type:"text",placeholder:"tag1, tag2",value:x,onChange:C=>b(C.target.value)})]})})}function eC({sessions:e,opencodeSessions:t,activeSessionId:n,activeOpencodeSessionId:r,activeProject:i,creating:l,onCreateSession:s,onSelectSession:o,onSelectOpencodeSession:u}){const[d,c]=w.useState("all"),[f,m]=w.useState(!1),h=30,p=d==="all"?[...e,...t].sort((g,v)=>Number(v.mtime)-Number(g.mtime)):e,x=f?p:p.slice(0,h),b=t.length,y=g=>{if(g.source==="opencode"){u(g);return}o(g.id)};return a.jsxs("div",{className:"chat-sessions",children:[a.jsxs("div",{className:"chat-sessions-header",children:[a.jsx("span",{className:"chat-sessions-header-title",children:"Sessions"}),a.jsx("span",{className:"chat-sessions-count",children:x.length})]}),b>0&&a.jsxs("div",{className:"chat-sessions-toggle",children:[a.jsx("button",{type:"button",className:`chat-sessions-toggle-btn ${d==="bizar"?"active":""}`,onClick:()=>c("bizar"),children:"Bizar"}),a.jsxs("button",{type:"button",className:`chat-sessions-toggle-btn ${d==="all"?"active":""}`,onClick:()=>c("all"),children:["All (",b," opencode)"]})]}),a.jsxs("button",{type:"button",className:"chat-sessions-new",onClick:s,disabled:l||!i,title:i?"Create new session":"Pick a project first","aria-label":"Create new session",children:[l?a.jsx(Wm,{size:"sm"}):a.jsx(xt,{size:14}),a.jsx("span",{children:l?"Creating…":"New session"})]}),e.length===0?a.jsx("div",{className:"chat-sessions-empty",children:a.jsx(Ix,{icon:a.jsx(Jl,{size:20}),title:i?"No sessions yet":"No project",message:i?"Create your first session to start chatting.":"Pick a project in Overview to scope chat sessions.",action:i?a.jsxs(pr,{variant:"primary",size:"sm",onClick:s,loading:l,children:[a.jsx(xt,{size:12})," New session"]}):a.jsxs(pr,{variant:"secondary",size:"sm",onClick:()=>{window.location.hash="#overview"},children:[a.jsx(Pu,{size:12})," Open Overview"]})})}):a.jsx("ul",{className:"chat-sessions-list",children:x.map(g=>{const v=g.source==="opencode",C=v?r===g.id:n===g.id;return a.jsxs("li",{className:`chat-sessions-item ${C?"active":""} ${v?"chat-sessions-item-opencode":""}`,onClick:()=>y(g),title:v?`Open in dashboard: ${g.title||g.id}`:g.id,children:[v&&a.jsx(Z1,{size:10,className:"chat-sessions-item-icon"}),a.jsx("span",{className:"chat-sessions-item-id",children:g.title||g.id}),a.jsx("span",{className:"chat-sessions-item-meta",children:new Date(Number(g.mtime)).toLocaleDateString()})]},v?`oc-${g.id}`:g.id)})}),p.length>h&&a.jsx("button",{type:"button",className:"chat-sessions-show-more",onClick:()=>m(g=>!g),children:f?`Show less (${p.length-h} hidden)`:`Show all ${p.length} sessions`})]})}function tC(e){const{activeSource:t}=e;return a.jsx("div",{className:`chat-composer-wrap chat-composer-source-${t??"none"} legacy`,children:a.jsx("div",{className:"chat-composer-pill",children:a.jsx(T2,{...e})})})}function nC({sessionId:e,messages:t,pinned:n,agent:r,model:i,agents:l,mcps:s,allCommands:o,activeSource:u="bizar",onRename:d,onDelete:c}){const[f,m]=w.useState(!1),[h,p]=w.useState(!1),x=f?l:l.slice(0,4),b=h?o:o.slice(0,4),y=i.includes("/")?i.split("/")[0]:"";return a.jsxs("div",{className:"chat-info",children:[a.jsxs("div",{className:"chat-info-card",children:[a.jsxs("div",{className:"chat-info-card-title",children:[a.jsx(On,{size:14})," Session",a.jsx("span",{className:`chat-source-badge chat-source-${u??"none"}`,style:{marginLeft:"auto"},children:u==="opencode"?"opencode":"bizar chat"})]}),a.jsxs("dl",{className:"env-table",children:[a.jsx("dt",{children:"id"}),a.jsx("dd",{className:"mono",children:e||"Live"}),a.jsx("dt",{children:"Messages"}),a.jsx("dd",{className:"mono",children:t.length}),a.jsx("dt",{children:"Pinned"}),a.jsx("dd",{className:"mono",children:n.size}),a.jsx("dt",{children:"Agent"}),a.jsx("dd",{className:"mono",children:r||"—"}),a.jsx("dt",{children:"Model"}),a.jsx("dd",{className:"mono ellipsis",title:i,children:i||"—"}),y&&a.jsxs(a.Fragment,{children:[a.jsx("dt",{children:"Provider"}),a.jsx("dd",{className:"mono",children:y})]})]}),(d||c)&&a.jsxs("div",{className:"chat-info-actions",children:[d&&a.jsxs("button",{type:"button",className:"btn btn-ghost btn-sm",onClick:d,children:[a.jsx(Au,{size:12,"aria-hidden":!0})," Rename"]}),c&&a.jsxs("button",{type:"button",className:"btn btn-ghost btn-danger btn-sm",onClick:c,children:[a.jsx(_r,{size:12,"aria-hidden":!0})," Delete"]})]})]}),a.jsxs("div",{className:"chat-info-card",children:[a.jsxs("div",{className:"chat-info-card-title",children:[a.jsx(Dr,{size:14})," Agents",a.jsx("span",{className:"chat-info-card-count",children:l.length})]}),a.jsx("ul",{className:"mod-mini-list",children:x.map(g=>a.jsxs("li",{className:"mod-mini",children:[a.jsxs("span",{className:"mod-mini-name",children:["@",g.name]}),a.jsx("span",{className:"mod-mini-meta",children:g.model||g.mode||""})]},g.name))}),l.length>4&&a.jsx("button",{type:"button",className:"chat-info-card-toggle",onClick:()=>m(g=>!g),children:f?"− Show fewer":`+ ${l.length-4} more`})]}),a.jsxs("div",{className:"chat-info-card",children:[a.jsxs("div",{className:"chat-info-card-title",children:[a.jsx(cx,{size:14})," MCPs",a.jsx("span",{className:"chat-info-card-count",children:s.length})]}),a.jsxs("ul",{className:"mod-mini-list",children:[s.length===0?a.jsx("li",{className:"muted",children:"No MCPs configured."}):null,s.map(g=>a.jsxs("li",{className:"mod-mini",children:[a.jsx("span",{className:"mod-mini-name",children:g.id}),a.jsx("span",{className:`mod-mini-pill ${g.enabled?"on":"off"}`,children:g.enabled?"on":"off"})]},g.id))]})]}),a.jsxs("div",{className:"chat-info-card",children:[a.jsxs("button",{type:"button",className:"chat-info-card-title chat-info-card-title-button",onClick:()=>p(g=>!g),"aria-expanded":h,children:[a.jsx(hx,{size:14})," Slash commands",a.jsx("span",{className:"chat-info-card-count",children:o.length}),a.jsx(Ss,{size:12,className:`chat-info-card-chevron ${h?"open":""}`})]}),h&&a.jsx("ul",{className:"mod-mini-list",children:b.map(g=>a.jsxs("li",{children:[a.jsx("code",{children:g.cmd}),a.jsx("span",{className:"muted",children:g.desc})]},g.cmd))})]})]})}function rC({snapshot:e,settings:t,setActiveTab:n,initialTaskId:r,onClearTaskId:i}){const l=bx(),s=kx(),o=A2(e,t,r??"");w.useEffect(()=>{o.setToast({error:O=>l.error(O),success:O=>l.success(O),info:O=>l.info(O),warning:O=>l.warning(O)})},[o,l]);const[u,d]=w.useState(""),[c,f]=w.useState(t.defaultAgent||"odin"),[m,h]=w.useState(t.defaultModel||""),[p,x]=w.useState([]),[b,y]=w.useState(!1),[g,v]=w.useState(!1),C=w.useRef(null),{allCommands:z,suggestions:E,setQuery:A}=L2(e);w.useEffect(()=>{A(u)},[u,A]);const L=()=>{var O;return(O=C.current)==null?void 0:O.click()},I=O=>{const W=O.target.files;if(!W)return;const de=[];for(let ee=0;ee<W.length;ee++)de.push(W[ee].name);x(ee=>{const R=de.filter(V=>!ee.includes(V));return[...ee,...R]}),C.current&&(C.current.value="")},k=async()=>{const O=u.trim();if(!O)return;d(""),A(""),(await o.onSend(O,c,m,p)).ok&&o.jumpToLatest()},j=async()=>{o.busy.create||(await o.onCreateSession(),y(!1))},P=O=>{s.open({title:"Delete message?",children:a.jsx("p",{style:{margin:0},children:"This action cannot be undone."}),footer:a.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"flex-end"},children:[a.jsx(pr,{variant:"secondary",size:"sm",onClick:()=>s.close(),children:"Cancel"}),a.jsx(pr,{variant:"danger",size:"sm",onClick:()=>{s.close(),o.deleteMessage(O)},children:"Delete"})]})})},B=(O,W)=>{s.open({title:"Delete session?",children:a.jsxs("p",{style:{margin:0},children:["Delete ",a.jsx("strong",{children:W}),"? This cannot be undone."]}),footer:a.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"flex-end"},children:[a.jsx(pr,{variant:"secondary",size:"sm",onClick:()=>s.close(),children:"Cancel"}),a.jsx(pr,{variant:"danger",size:"sm",onClick:async()=>{s.close(),await o.deleteSession(O)},children:"Delete"})]})})};return a.jsxs("div",{className:"chat-shell",children:[a.jsx(Tx,{activeProject:e.activeProject,sessionCount:o.sessions.length,sessionsOpen:b,infoOpen:g,onToggleSessions:()=>y(O=>!O),onToggleInfo:()=>v(O=>!O),onOpenOverview:()=>n==null?void 0:n("overview")}),a.jsxs("div",{className:"chat-body",children:[a.jsx("aside",{className:`chat-sessions ${b?"":"chat-sessions-hidden"}`,children:a.jsx(eC,{sessions:o.sessions,opencodeSessions:o.opencodeSessions,activeSessionId:o.sessionId,activeOpencodeSessionId:o.activeOpencodeSessionId,activeProject:e.activeProject,onCreateSession:j,onSelectSession:o.selectBizarSession,onSelectOpencodeSession:O=>o.loadOpencodeSession(O.id),creating:o.busy.create})}),a.jsxs("main",{className:"chat-main",children:[a.jsx(j2,{messages:o.activeSource==="opencode"?o.opencodeMessages:o.bizarMessages,loading:o.loading,activeProject:e.activeProject,sessionId:o.activeSource==="opencode"?o.activeOpencodeSessionId??o.sessionId:o.sessionId,pinned:o.pinned,activeSource:o.activeSource,onPickSuggestion:O=>d(O),onCopy:O=>o.copyMessage(O),onDelete:P,onTogglePin:o.togglePin,onRegenerate:o.onRegenerate}),a.jsx(tC,{agent:c,setAgent:f,model:m,setModel:h,text:u,setText:d,sending:o.sending,activeSource:o.activeSource,onSend:k,attachments:p,setAttachments:x,suggestions:E,onPickSuggestion:O=>d(`${O.split(" ")[0]} `),agents:e.agents||[],onAttach:L,sessionsOpen:b,infoOpen:g}),a.jsx("input",{ref:C,type:"file",multiple:!0,style:{display:"none"},onChange:I})]}),a.jsx("aside",{className:`chat-info ${g?"":"chat-info-hidden"}`,children:a.jsx(nC,{sessionId:o.activeSource==="opencode"?o.activeOpencodeSessionId??o.sessionId:o.sessionId,messages:o.activeSource==="opencode"?o.opencodeMessages:o.bizarMessages,pinned:o.pinned,agent:c,model:m,agents:e.agents||[],mcps:e.mcps||[],allCommands:z,activeSource:o.activeSource,onDelete:()=>{const O=o.activeSource==="opencode"?o.activeOpencodeSessionId:o.sessionId;O&&B(O,O)}})})]})]})}function iC({onBack:e}){const[t,n]=w.useState([]),[r,i]=w.useState(!0),[l,s]=w.useState({}),[o,u]=w.useState(!1),d=async()=>{try{const x=await q.get("/config"),b=Object.entries(x).map(([y,g])=>({key:y,value:g,type:c(g)}));n(b),s(Object.fromEntries(Object.entries(x).map(([y,g])=>[y,g])))}catch{}finally{i(!1)}};w.useEffect(()=>{d()},[]);const c=x=>typeof x=="boolean"?"boolean":typeof x=="number"?"number":typeof x=="string"?"string":Array.isArray(x)?"array":x&&typeof x=="object"?"object":"unknown",f=(x,b)=>{s(y=>({...y,[x]:b}))},m=async()=>{u(!0);try{await q.patch("/config",l),await d()}catch{}finally{u(!1)}},h=(x,b)=>{s(y=>({...y,[x]:b}))},p=x=>{const b=l[x.key];switch(x.type){case"boolean":return a.jsxs("label",{className:"mobile-toggle",children:[a.jsx("input",{type:"checkbox",checked:!!b,onChange:y=>f(x.key,y.target.checked)}),a.jsx("span",{className:"mobile-toggle-slider"})]});case"number":return a.jsx("input",{className:"mobile-input mobile-input-sm",type:"number",inputMode:"numeric",value:String(b??""),onChange:y=>f(x.key,Number(y.target.value))});case"string":return a.jsx("input",{className:"mobile-input mobile-input-sm",type:"text",value:String(b??""),onChange:y=>f(x.key,y.target.value)});case"object":case"array":return a.jsx("textarea",{className:"mobile-input mobile-input-sm",rows:2,value:JSON.stringify(b??null,null,2),onChange:y=>{try{f(x.key,JSON.parse(y.target.value))}catch{}}});default:return a.jsx("span",{className:"mobile-setting-value mono",children:String(b??"null")})}};return a.jsxs("div",{className:"mobile-view",children:[a.jsxs("div",{className:"mobile-tasks-toolbar",children:[a.jsxs("span",{style:{fontSize:14,color:"var(--text-muted)",flex:1},children:[t.length," config entries"]}),a.jsx("button",{type:"button",className:"mobile-icon-btn",onClick:()=>d(),"aria-label":"Refresh",children:a.jsx(_t,{size:16})}),a.jsxs("button",{type:"button",className:"mobile-btn",disabled:o,onClick:()=>m(),children:[a.jsx(Fm,{size:14})," ",o?"Saving…":"Save all"]})]}),r?a.jsx("div",{className:"mobile-loading",children:a.jsx("p",{children:"Loading…"})}):t.length===0?a.jsxs("div",{className:"mobile-empty",children:[a.jsx(Pr,{size:40}),a.jsx("p",{children:"No config entries."})]}):a.jsx("div",{className:"mobile-config-list",children:t.map(x=>a.jsxs("div",{className:"mobile-config-row",children:[a.jsxs("div",{className:"mobile-config-key",children:[a.jsx("span",{className:"mono",children:x.key}),a.jsx("span",{className:"mobile-config-type",children:x.type})]}),a.jsx("div",{className:"mobile-config-value",children:p(x)}),a.jsx("button",{type:"button",className:"mobile-icon-btn",onClick:()=>h(x.key,x.defaultValue),"aria-label":"Reset to default",title:"Reset",children:a.jsx(ax,{size:14})})]},x.key))})]})}function lC({onBack:e}){const[t,n]=w.useState([]),[r,i]=w.useState(!0),[l,s]=w.useState(null),[o,u]=w.useState(""),d=async()=>{try{const h=await q.get("/history");if(Array.isArray(h.history)){n(h.history);return}if(Array.isArray(h.projects)){const p=new Map;for(const x of h.events||[]){const b=x.projectId;if(!b)continue;const y=p.get(b);(!y||new Date(x.ts).getTime()>new Date(y.ts).getTime())&&p.set(b,x)}n(h.projects.map(x=>{const b=p.get(x.id);return{id:x.id,ts:x.lastAccessed||(b==null?void 0:b.ts)||new Date(0).toISOString(),agent:x.name,taskCount:x.tasks.total,summary:`${x.path} · ${x.tasks.done}/${x.tasks.total} done · ${x.plans} plan${x.plans===1?"":"s"}`,output:b?`${b.kind}${b.text?` — ${b.text}`:""}`:"No recent events."}}));return}n([])}catch{}finally{i(!1)}};w.useEffect(()=>{d()},[]);const c=h=>{if(!h)return"—";const p=Math.floor(h/1e3);if(p<60)return`${p}s`;const x=Math.floor(p/60),b=p%60;return`${x}m ${b}s`},f=h=>new Date(h).toLocaleString(),m=o.trim()?t.filter(h=>{const p=o.toLowerCase();return(h.agent||"session").toLowerCase().includes(p)||(h.summary||"").toLowerCase().includes(p)||(h.output||"").toLowerCase().includes(p)}):t;return a.jsxs("div",{className:"mobile-view",children:[a.jsxs("div",{className:"mobile-tasks-toolbar",children:[a.jsx("input",{className:"mobile-search-input",type:"text",placeholder:"Search history…",value:o,onChange:h=>u(h.target.value),style:{flex:1}}),a.jsx("button",{type:"button",className:"mobile-icon-btn",onClick:()=>d(),"aria-label":"Refresh",children:a.jsx(_t,{size:16})})]}),r?a.jsx("div",{className:"mobile-loading",children:a.jsx("p",{children:"Loading…"})}):m.length===0?a.jsxs("div",{className:"mobile-empty",children:[a.jsx(ka,{size:40}),a.jsx("p",{children:t.length===0?"No history yet.":"No matching sessions."})]}):a.jsx("div",{className:"mobile-card-list",children:m.map(h=>a.jsxs("button",{type:"button",className:"mobile-list-item mobile-list-item-interactive",onClick:()=>s(h),children:[a.jsx("div",{className:"mobile-list-icon",children:a.jsx(ka,{size:16})}),a.jsxs("div",{className:"mobile-list-content",children:[a.jsx("span",{className:"mobile-list-title",children:h.agent||"Session"}),a.jsxs("span",{className:"mobile-list-meta",children:[f(h.ts),h.duration?` · ${c(h.duration)}`:"",h.taskCount?` · ${h.taskCount} tasks`:""]})]})]},h.id))}),l&&a.jsxs(Dt,{open:!0,onClose:()=>s(null),title:"Session Detail",children:[a.jsxs("div",{className:"mobile-agent-detail-meta",children:[a.jsxs("div",{className:"mobile-task-detail-row",children:[a.jsx("span",{children:"Agent"}),a.jsx("span",{children:l.agent||"—"})]}),a.jsxs("div",{className:"mobile-task-detail-row",children:[a.jsx("span",{children:"Started"}),a.jsx("span",{children:f(l.ts)})]}),a.jsxs("div",{className:"mobile-task-detail-row",children:[a.jsx("span",{children:"Duration"}),a.jsx("span",{children:c(l.duration)})]}),a.jsxs("div",{className:"mobile-task-detail-row",children:[a.jsx("span",{children:"Tasks"}),a.jsx("span",{children:l.taskCount||0})]})]}),l.summary&&a.jsxs("div",{style:{marginTop:12},children:[a.jsx("h4",{style:{fontSize:12,color:"var(--text-muted)",marginBottom:4},children:"Summary"}),a.jsx("p",{style:{fontSize:13},children:l.summary})]}),l.output&&a.jsxs("div",{style:{marginTop:12},children:[a.jsx("h4",{style:{fontSize:12,color:"var(--text-muted)",marginBottom:4},children:"Output"}),a.jsxs("pre",{className:"mono",style:{fontSize:11,whiteSpace:"pre-wrap",wordBreak:"break-all",background:"var(--bg-elev-2)",padding:8,borderRadius:6},children:[l.output.slice(0,1e3),l.output.length>1e3?"…":""]})]})]})]})}function sC({snapshot:e,onBack:t}){const[n,r]=w.useState(e.mods||[]),[i,l]=w.useState(!e.mods),[s,o]=w.useState(""),[u,d]=w.useState("all"),[c,f]=w.useState(null),m=async()=>{try{const x=await q.get("/mods");r(x.mods||[])}catch{}finally{l(!1)}};w.useEffect(()=>{e.mods?(r(e.mods),l(!1)):m()},[e.mods]);const h=async(x,b)=>{try{await q.patch(`/mods/${encodeURIComponent(x)}`,{enabled:b}),r(y=>y.map(g=>g.id===x?{...g,enabled:b}:g)),(c==null?void 0:c.id)===x&&f(y=>y&&{...y,enabled:b})}catch{}},p=n.filter(x=>{if(u==="enabled"&&!x.enabled||u==="disabled"&&x.enabled)return!1;if(s){const b=s.toLowerCase();return x.name.toLowerCase().includes(b)||x.description.toLowerCase().includes(b)}return!0});return a.jsxs("div",{className:"mobile-view",children:[a.jsxs("div",{className:"mobile-tasks-toolbar",children:[a.jsx("input",{className:"mobile-search-input",type:"text",placeholder:"Search mods…",value:s,onChange:x=>o(x.target.value),style:{flex:1}}),a.jsx("button",{type:"button",className:"mobile-icon-btn",onClick:()=>m(),"aria-label":"Refresh",children:a.jsx(_t,{size:16})})]}),a.jsx("div",{className:"mobile-search-scopes",children:["all","enabled","disabled"].map(x=>a.jsx("button",{type:"button",className:`mobile-scope-chip ${u===x?"active":""}`,onClick:()=>d(x),children:x.charAt(0).toUpperCase()+x.slice(1)},x))}),i?a.jsx("div",{className:"mobile-loading",children:a.jsx("p",{children:"Loading…"})}):p.length===0?a.jsxs("div",{className:"mobile-empty",children:[a.jsx(Pr,{size:40}),a.jsx("p",{children:"No mods found."})]}):a.jsx("div",{className:"mobile-card-list",children:p.map(x=>a.jsxs("button",{type:"button",className:"mobile-list-item mobile-list-item-interactive",onClick:()=>f(x),children:[a.jsx("div",{className:"mobile-list-icon",children:a.jsx(Pr,{size:16})}),a.jsxs("div",{className:"mobile-list-content",children:[a.jsx("span",{className:"mobile-list-title",children:x.name}),a.jsxs("span",{className:"mobile-list-meta",children:["v",x.version," · ",x.author]})]}),a.jsx("span",{className:`mobile-list-badge ${x.enabled?"badge-on":"badge-off"}`,children:x.enabled?"on":"off"})]},x.id))}),c&&a.jsx(Dt,{open:!0,onClose:()=>f(null),title:c.name,actions:a.jsx("div",{className:"mobile-task-detail-actions",children:a.jsxs("button",{type:"button",className:"mobile-btn",style:{flex:1},onClick:()=>{c&&h(c.id,!c.enabled)},children:[a.jsx(Om,{size:14})," ",c.enabled?"Disable":"Enable"]})}),children:a.jsxs("div",{className:"mobile-agent-detail",children:[a.jsx("p",{className:"mobile-agent-detail-desc",children:c.description||"No description."}),a.jsxs("div",{className:"mobile-agent-detail-meta",children:[a.jsxs("div",{className:"mobile-task-detail-row",children:[a.jsx("span",{children:"Version"}),a.jsx("span",{className:"mono",children:c.version})]}),a.jsxs("div",{className:"mobile-task-detail-row",children:[a.jsx("span",{children:"Author"}),a.jsx("span",{children:c.author})]}),a.jsxs("div",{className:"mobile-task-detail-row",children:[a.jsx("span",{children:"Bizar"}),a.jsx("span",{className:"mono",children:c.bizar})]}),a.jsxs("div",{className:"mobile-task-detail-row",children:[a.jsx("span",{children:"Type"}),a.jsx("span",{children:c.type})]}),a.jsxs("div",{className:"mobile-task-detail-row",children:[a.jsx("span",{children:"Permissions"}),a.jsx("span",{children:c.permissions.length})]}),c.installedAt&&a.jsxs("div",{className:"mobile-task-detail-row",children:[a.jsx("span",{children:"Installed"}),a.jsx("span",{children:new Date(c.installedAt).toLocaleDateString()})]})]})]})})]})}function oC({snapshot:e,onNavigate:t}){var s,o,u;const[n,r]=w.useState(""),i=[{id:"artifacts",icon:qn,label:"Plans",count:e.artifacts.length||0,desc:"Visual artifacts with elements & comments"},{id:"agents",icon:Dr,label:"Agents",count:((s=e.agents)==null?void 0:s.length)||0,desc:"The Norse pantheon"},{id:"skills",icon:Pr,label:"Skills",count:null,desc:"Agent capabilities & tools"},{id:"mods",icon:Pr,label:"Mods",count:((o=e.mods)==null?void 0:o.length)||0,desc:"Installed modifications"},{id:"schedules",icon:va,label:"Schedules",count:((u=e.schedules)==null?void 0:u.length)||0,desc:"Cron jobs & automated tasks"},{id:"history",icon:ka,label:"History",count:null,desc:"Past sessions & outputs"},{id:"config",icon:Bm,label:"Config",count:null,desc:"Key-value configuration editor"}],l=n.trim()?i.filter(d=>d.label.toLowerCase().includes(n.toLowerCase())||d.desc.toLowerCase().includes(n.toLowerCase())):i;return a.jsxs("div",{className:"mobile-view",children:[a.jsx("div",{className:"mobile-tasks-toolbar",children:a.jsx("input",{className:"mobile-search-input",type:"text",placeholder:"Search…",value:n,onChange:d=>r(d.target.value),style:{flex:1}})}),a.jsx("div",{className:"mobile-card-list",children:l.map(d=>{const c=d.icon;return a.jsxs("button",{type:"button",className:"mobile-more-nav-item",onClick:()=>t(d.id),children:[a.jsx("div",{className:"mobile-more-nav-icon",children:a.jsx(c,{size:20})}),a.jsxs("div",{className:"mobile-more-nav-content",children:[a.jsxs("span",{className:"mobile-more-nav-label",children:[d.label,d.count!=null&&a.jsx("span",{className:"mobile-more-nav-count",children:d.count})]}),a.jsx("span",{className:"mobile-more-nav-desc",children:d.desc})]}),a.jsx(dd,{size:16,className:"mobile-more-nav-arrow"})]},d.id)})}),a.jsx("div",{className:"mobile-more-footer",children:a.jsxs("a",{href:"/?desktop=1",className:"mobile-more-link",children:["Switch to Desktop ",a.jsx(dd,{size:14})]})})]})}const Ju=[{id:"task",label:"Task",color:"var(--info)"},{id:"note",label:"Note",color:"var(--text-dim)"},{id:"decision",label:"Decision",color:"var(--accent)"},{id:"question",label:"Question",color:"var(--warning)"}];function jo(e){var t;return((t=Ju.find(n=>n.id===e))==null?void 0:t.color)||"var(--text-dim)"}function aC({type:e,size:t=12}){switch(e){case"task":return a.jsx(es,{size:t,style:{color:"var(--info)"}});case"note":return a.jsx(md,{size:t,style:{color:"var(--text-dim)"}});case"decision":return a.jsx(es,{size:t,style:{color:"var(--accent)"}});case"question":return a.jsx(K1,{size:t,style:{color:"var(--warning)"}});default:return a.jsx(md,{size:t})}}function uC({slug:e,onBack:t}){const[n,r]=w.useState(null),[i,l]=w.useState(null),[s,o]=w.useState(!0),[u,d]=w.useState(!1),[c,f]=w.useState(null),[m,h]=w.useState(!1),[p,x]=w.useState(!1),[b,y]=w.useState(!1),[g,v]=w.useState(""),C=async()=>{o(!0);try{const I=await q.get(`/plans/${encodeURIComponent(e)}`);r(I.canvas),l(I.meta)}catch{}finally{o(!1)}};w.useEffect(()=>{C()},[e]);const z=async(I,k,j)=>{try{const P=((n==null?void 0:n.elements)||[]).reduce((O,W)=>Math.max(O,W.x||0),40),B=((n==null?void 0:n.elements)||[]).reduce((O,W)=>Math.max(O,W.y||0),40);await q.post(`/plans/${encodeURIComponent(e)}/elements`,{type:I,title:k,content:j,x:20+P,y:20+B,width:240,height:120}),await C(),x(!1)}catch{}},E=async(I,k)=>{try{await q.put(`/plans/${encodeURIComponent(e)}/elements/${encodeURIComponent(I)}`,k),await C(),f(null)}catch{}},A=async I=>{if(confirm("Delete this element?"))try{await q.del(`/plans/${encodeURIComponent(e)}/elements/${encodeURIComponent(I)}`),f(null),await C()}catch{}},L=async(I,k)=>{try{const j=k?`/plans/${encodeURIComponent(e)}/elements/${encodeURIComponent(k)}/comments`:`/plans/${encodeURIComponent(e)}/comments`;await q.post(j,{text:I,elementId:k}),await C(),v(""),y(!1)}catch{}};return s||!n||!i?a.jsx("div",{className:"mobile-view",children:a.jsx("div",{className:"mobile-loading",children:a.jsx("p",{children:"Loading canvas…"})})}):a.jsxs("div",{className:"mobile-view mobile-view-canvas",children:[a.jsxs("div",{className:"mobile-canvas-bar",children:[a.jsxs("div",{className:"mobile-canvas-meta",children:[a.jsx("span",{className:"mobile-canvas-title",children:i.title||e}),a.jsx("span",{className:"mobile-canvas-status","data-status":i.status,children:i.status})]}),a.jsxs("div",{className:"mobile-canvas-actions",children:[a.jsx("button",{type:"button",className:`mobile-icon-btn ${u?"active":""}`,onClick:()=>d(I=>!I),"aria-label":u?"Done editing":"Edit",children:a.jsx(Au,{size:16})}),a.jsxs("button",{type:"button",className:"mobile-icon-btn",onClick:()=>h(I=>!I),"aria-label":"Comments",children:[a.jsx(On,{size:16}),n.comments.length>0&&a.jsx("span",{className:"mobile-canvas-comment-count",children:n.comments.length})]}),u&&a.jsx("button",{type:"button",className:"mobile-icon-btn",onClick:()=>x(!0),"aria-label":"Add element",children:a.jsx(xt,{size:16})})]})]}),a.jsxs("div",{className:"mobile-canvas-elements",children:[n.elements.length===0&&a.jsxs("div",{className:"mobile-empty",children:[a.jsx("p",{children:"No elements yet."}),u&&a.jsxs("button",{type:"button",className:"mobile-btn",onClick:()=>x(!0),children:[a.jsx(xt,{size:14})," Add Element"]})]}),n.elements.map(I=>a.jsxs("button",{type:"button",className:`mobile-canvas-element ${(c==null?void 0:c.id)===I.id?"selected":""}`,style:{borderColor:jo(I.type)},onClick:()=>{u&&f(I)},"aria-pressed":(c==null?void 0:c.id)===I.id,children:[a.jsxs("div",{className:"mobile-canvas-el-header",style:{background:`${jo(I.type)}18`},children:[a.jsx(aC,{type:I.type,size:12}),a.jsx("span",{className:"mobile-canvas-el-type",style:{color:jo(I.type)},children:I.type}),I.status&&I.status!=="open"&&a.jsx("span",{className:"mobile-canvas-el-status",children:I.status})]}),a.jsx("div",{className:"mobile-canvas-el-title",children:I.title||"Untitled"}),I.content&&a.jsxs("div",{className:"mobile-canvas-el-content",children:[I.content.slice(0,120),I.content.length>120?"…":""]}),a.jsxs("div",{className:"mobile-canvas-el-comments",children:[a.jsx(On,{size:10}),n.comments.filter(k=>k.elementId===I.id).length]})]},I.id))]}),m&&a.jsxs("div",{className:"mobile-canvas-comments",children:[a.jsxs("div",{className:"mobile-canvas-comments-header",children:[a.jsxs("h4",{children:["Comments (",n.comments.length,")"]}),a.jsx("button",{type:"button",className:"mobile-icon-btn",onClick:()=>h(!1),children:a.jsx(Zn,{size:16})})]}),a.jsxs("div",{className:"mobile-canvas-comment-list",children:[n.comments.length===0&&a.jsx("p",{className:"mobile-empty-inline",children:"No comments yet."}),n.comments.map(I=>a.jsxs("div",{className:"mobile-canvas-comment",children:[a.jsxs("div",{className:"mobile-canvas-comment-head",children:[a.jsx("span",{className:"mono",children:I.author}),a.jsx("span",{className:"muted",children:Sr(I.created)})]}),a.jsx("div",{className:"mobile-canvas-comment-text",children:I.text})]},I.id))]}),a.jsxs("div",{className:"mobile-canvas-comment-input",children:[a.jsx("textarea",{className:"mobile-input",rows:2,placeholder:"Add a comment…",value:g,onChange:I=>v(I.target.value)}),a.jsx("button",{type:"button",className:"mobile-btn",disabled:!g.trim(),onClick:()=>{L(g.trim(),null)},children:"Post"})]})]}),c&&a.jsx(Dt,{open:!0,onClose:()=>f(null),title:`Edit ${c.title||c.type}`,actions:a.jsxs("div",{className:"mobile-task-detail-actions",children:[a.jsxs("button",{type:"button",className:"mobile-btn mobile-btn-danger",onClick:()=>A(c.id),children:[a.jsx(_r,{size:14})," Delete"]}),a.jsxs("button",{type:"button",className:"mobile-btn",onClick:()=>y(!0),children:[a.jsx(On,{size:14})," Comment"]})]}),children:a.jsx(cC,{element:c,onSave:I=>E(c.id,I),onClose:()=>f(null)})}),a.jsx(dC,{open:p,onClose:()=>x(!1),onAdd:z}),a.jsx(Tn,{open:b,onClose:()=>y(!1),title:"Add Comment",actions:a.jsxs("button",{type:"button",className:"mobile-btn",style:{width:"100%"},disabled:!g.trim(),onClick:()=>{L(g.trim(),(c==null?void 0:c.id)||null),y(!1)},children:[a.jsx(On,{size:14})," Post"]}),children:a.jsx("textarea",{className:"mobile-input",rows:3,placeholder:"Your comment…",value:g,onChange:I=>v(I.target.value),autoFocus:!0})})]})}function cC({element:e,onSave:t,onClose:n}){const[r,i]=w.useState(e.type),[l,s]=w.useState(e.title||""),[o,u]=w.useState(e.content||""),[d,c]=w.useState(e.status||"open");return a.jsxs("form",{className:"mobile-task-form",onSubmit:f=>{f.preventDefault(),t({type:r,title:l,content:o,status:d}),n()},children:[a.jsx("label",{className:"mobile-field-label",children:"Type"}),a.jsx("select",{className:"mobile-input",value:r,onChange:f=>i(f.target.value),children:Ju.map(f=>a.jsx("option",{value:f.id,children:f.label},f.id))}),a.jsx("label",{className:"mobile-field-label",children:"Title"}),a.jsx("input",{className:"mobile-input",type:"text",value:l,onChange:f=>s(f.target.value)}),a.jsx("label",{className:"mobile-field-label",children:"Status"}),a.jsx("input",{className:"mobile-input",type:"text",value:d,onChange:f=>c(f.target.value),placeholder:"open / done / blocked"}),a.jsx("label",{className:"mobile-field-label",children:"Content (markdown)"}),a.jsx("textarea",{className:"mobile-input",rows:4,value:o,onChange:f=>u(f.target.value)}),a.jsx("button",{type:"submit",className:"mobile-btn",style:{width:"100%",marginTop:8},children:"Save"})]})}function dC({open:e,onClose:t,onAdd:n}){const[r,i]=w.useState("task"),[l,s]=w.useState(""),[o,u]=w.useState(""),d=c=>{c.preventDefault(),l.trim()&&(n(r,l.trim(),o.trim()),s(""),u(""))};return a.jsx(Tn,{open:e,onClose:t,title:"Add Element",actions:a.jsxs("button",{type:"submit",form:"add-el-form",className:"mobile-btn",style:{width:"100%"},children:[a.jsx(xt,{size:14})," Add"]}),children:a.jsxs("form",{id:"add-el-form",onSubmit:d,className:"mobile-task-form",children:[a.jsx("label",{className:"mobile-field-label",children:"Type"}),a.jsx("select",{className:"mobile-input",value:r,onChange:c=>i(c.target.value),children:Ju.map(c=>a.jsx("option",{value:c.id,children:c.label},c.id))}),a.jsx("label",{className:"mobile-field-label",children:"Title *"}),a.jsx("input",{className:"mobile-input",type:"text",placeholder:"Element title",value:l,onChange:c=>s(c.target.value),autoFocus:!0,required:!0}),a.jsx("label",{className:"mobile-field-label",children:"Content (markdown)"}),a.jsx("textarea",{className:"mobile-input",rows:3,placeholder:"Description…",value:o,onChange:c=>u(c.target.value)})]})})}function fC({snapshot:e,onBack:t,onOpenArtifact:n}){const[r,i]=w.useState(e.artifacts||[]),[l,s]=w.useState(!e.artifacts),[o,u]=w.useState(""),[d,c]=w.useState(!1),[f,m]=w.useState(""),[h,p]=w.useState(""),x=async()=>{try{const g=await q.get("/artifacts");i(g.artifacts||[])}catch{}finally{s(!1)}},b=async()=>{if(f.trim())try{const g=await q.post("/artifacts",{slug:f.trim(),title:h.trim()||void 0});c(!1),m(""),p(""),n(g.slug)}catch{}},y=o.trim()?r.filter(g=>(g.title||g.slug||"").toLowerCase().includes(o.toLowerCase())):r;return a.jsxs("div",{className:"mobile-view",children:[a.jsxs("div",{className:"mobile-tasks-toolbar",children:[a.jsx("input",{className:"mobile-search-input",type:"text",placeholder:"Search artifacts…",value:o,onChange:g=>u(g.target.value),style:{flex:1}}),a.jsx("button",{type:"button",className:"mobile-icon-btn",onClick:()=>x(),"aria-label":"Refresh",children:a.jsx(_t,{size:16})})]}),a.jsx("div",{style:{marginBottom:12},children:a.jsxs("button",{type:"button",className:"mobile-btn",style:{width:"100%"},onClick:()=>c(!0),children:[a.jsx(xt,{size:14})," New Artifact"]})}),l?a.jsx("div",{className:"mobile-loading",children:a.jsx("p",{children:"Loading…"})}):y.length===0?a.jsxs("div",{className:"mobile-empty",children:[a.jsx(qn,{size:40}),a.jsx("p",{children:"No artifacts yet."})]}):a.jsx("div",{className:"mobile-card-list",children:y.map(g=>a.jsxs("button",{type:"button",className:"mobile-list-item mobile-list-item-interactive",onClick:()=>n(g.slug),children:[a.jsx("div",{className:"mobile-list-icon",children:a.jsx(qn,{size:16})}),a.jsxs("div",{className:"mobile-list-content",children:[a.jsx("span",{className:"mobile-list-title",children:g.title||g.slug}),a.jsxs("span",{className:"mobile-list-meta",children:[g.status," · ",g.source,g.elementCount!=null?` · ${g.elementCount} elements`:"",g.commentCount!=null?` · ${g.commentCount} comments`:""]})]}),a.jsx("span",{className:"mobile-list-badge","data-status":g.status,children:g.status})]},g.slug))}),a.jsx(Tn,{open:d,onClose:()=>c(!1),title:"New Artifact",actions:a.jsxs("button",{type:"submit",form:"new-plan-form",className:"mobile-btn",style:{width:"100%"},children:[a.jsx(xt,{size:14})," Create"]}),children:a.jsxs("form",{id:"new-plan-form",onSubmit:g=>{g.preventDefault(),b()},className:"mobile-task-form",children:[a.jsx("label",{className:"mobile-field-label",children:"Slug *"}),a.jsx("input",{className:"mobile-input",type:"text",placeholder:"my-plan",pattern:"[a-z0-9][a-z0-9-]{0,63}",value:f,onChange:g=>m(g.target.value),autoFocus:!0,required:!0}),a.jsx("label",{className:"mobile-field-label",children:"Title (optional)"}),a.jsx("input",{className:"mobile-input",type:"text",placeholder:"My Artifact",value:h,onChange:g=>p(g.target.value)})]})})]})}const hC=["cron","interval","once"],mC=["command","agent","webhook"],xf=["UTC","America/New_York","America/Los_Angeles","Europe/London","Europe/Berlin","Asia/Tokyo"],cg=Array.from({length:24},(e,t)=>({value:t,label:t===0?"12 AM":t<12?`${t} AM`:t===12?"12 PM":`${t-12} PM`})),pC=Array.from({length:12},(e,t)=>t*5),dg=[{value:"*",label:"Every day"},{value:"0",label:"Sun"},{value:"1",label:"Mon"},{value:"2",label:"Tue"},{value:"3",label:"Wed"},{value:"4",label:"Thu"},{value:"5",label:"Fri"},{value:"6",label:"Sat"}],gC=[{value:"s",label:"sec"},{value:"m",label:"min"},{value:"h",label:"hr"},{value:"d",label:"day"}];function yC({snapshot:e}){var b;const[t,n]=w.useState(e.schedules||[]),[r,i]=w.useState(!e.schedules),[l,s]=w.useState(""),[o,u]=w.useState(null),[d,c]=w.useState({open:!1}),f=async()=>{try{const y=await q.get("/schedules");n(y.schedules||[])}catch{}finally{i(!1)}};w.useEffect(()=>{e.schedules?(n(e.schedules),i(!1)):f()},[e.schedules]);const m=async(y,g)=>{try{await q.patch(`/schedules/${encodeURIComponent(y)}`,{enabled:g}),n(v=>v.map(C=>C.id===y?{...C,enabled:g}:C)),(o==null?void 0:o.id)===y&&u(v=>v&&{...v,enabled:g})}catch{}},h=async y=>{if(confirm("Delete this schedule?"))try{await q.del(`/schedules/${encodeURIComponent(y)}`),n(g=>g.filter(v=>v.id!==y)),(o==null?void 0:o.id)===y&&u(null)}catch{}},p=async y=>{try{await q.post(`/schedules/${encodeURIComponent(y)}/trigger`)}catch{}},x=l.trim()?t.filter(y=>y.name.toLowerCase().includes(l.toLowerCase())):t;return a.jsxs("div",{className:"mobile-view",children:[a.jsxs("div",{className:"mobile-tasks-toolbar",children:[a.jsx("input",{className:"mobile-search-input",type:"text",placeholder:"Search schedules…",value:l,onChange:y=>s(y.target.value),style:{flex:1}}),a.jsx("button",{type:"button",className:"mobile-icon-btn",onClick:()=>f(),"aria-label":"Refresh",children:a.jsx(_t,{size:16})}),a.jsx("button",{type:"button",className:"mobile-icon-btn",onClick:()=>c({open:!0}),"aria-label":"New schedule",children:a.jsx(xt,{size:16})})]}),r?a.jsx("div",{className:"mobile-loading",children:a.jsx("p",{children:"Loading…"})}):x.length===0?a.jsxs("div",{className:"mobile-empty",children:[a.jsx(va,{size:40}),a.jsx("p",{children:"No schedules found."})]}):a.jsx("div",{className:"mobile-card-list",children:x.map(y=>a.jsxs("button",{type:"button",className:"mobile-list-item mobile-list-item-interactive",onClick:()=>u(y),children:[a.jsx("div",{className:"mobile-list-icon",children:a.jsx(va,{size:16})}),a.jsxs("div",{className:"mobile-list-content",children:[a.jsx("span",{className:"mobile-list-title",children:y.name}),a.jsxs("span",{className:"mobile-list-meta",children:[wf(y)," ·"," ",y.nextRun?`next ${kf(y.nextRun,y.timezone)}`:"no next run"]})]}),a.jsx("span",{className:`mobile-list-badge ${y.enabled?"badge-on":"badge-off"}`,children:y.enabled?"on":"off"})]},y.id))}),o&&a.jsx(Dt,{open:!0,onClose:()=>u(null),title:o.name,actions:a.jsxs("div",{className:"mobile-task-detail-actions",children:[a.jsxs("button",{type:"button",className:"mobile-btn",onClick:()=>{o&&p(o.id)},children:[a.jsx(Zl,{size:14})," Trigger now"]}),a.jsx("button",{type:"button",className:`mobile-btn ${o.enabled?"mobile-btn-secondary":""}`,onClick:()=>{o&&m(o.id,!o.enabled)},children:o.enabled?"Disable":"Enable"}),a.jsxs("button",{type:"button",className:"mobile-btn",onClick:()=>{o&&(c({open:!0,initial:o}),u(null))},children:[a.jsx(Au,{size:14})," Edit"]}),a.jsx("button",{type:"button",className:"mobile-btn mobile-btn-danger",onClick:()=>{o&&h(o.id)},children:a.jsx(_r,{size:14})})]}),children:a.jsx("div",{className:"mobile-agent-detail",children:a.jsxs("div",{className:"mobile-agent-detail-meta",children:[a.jsxs("div",{className:"mobile-task-detail-row",children:[a.jsx("span",{children:"Type"}),a.jsx("span",{children:o.type})]}),a.jsxs("div",{className:"mobile-task-detail-row",children:[a.jsx("span",{children:"Schedule"}),a.jsx("span",{className:"mono",children:wf(o)||o.schedule})]}),o.timezone&&a.jsxs("div",{className:"mobile-task-detail-row",children:[a.jsx("span",{children:"Timezone"}),a.jsx("span",{className:"mono",children:o.timezone})]}),a.jsxs("div",{className:"mobile-task-detail-row",children:[a.jsx("span",{children:"Action"}),a.jsxs("span",{children:[o.action.type,": ",o.action.target]})]}),o.action.type==="agent"&&o.action.prompt&&a.jsxs("div",{className:"mobile-task-detail-row",children:[a.jsx("span",{children:"Prompt"}),a.jsx("span",{style:{fontSize:12},children:o.action.prompt})]}),((b=o.budgetCheck)==null?void 0:b.skipIfBudgetLow)&&a.jsxs("div",{className:"mobile-task-detail-row",children:[a.jsx("span",{children:"Budget gate"}),a.jsxs("span",{children:["skip if ≥ ",o.budgetCheck.maxConcurrent??6," concurrent"]})]}),a.jsxs("div",{className:"mobile-task-detail-row",children:[a.jsx("span",{children:"Next run"}),a.jsx("span",{children:o.nextRun?kf(o.nextRun,o.timezone):"—"})]}),a.jsxs("div",{className:"mobile-task-detail-row",children:[a.jsx("span",{children:"Last run"}),a.jsx("span",{children:o.lastRun?kC(o.lastRun):"—"})]}),o.lastResult&&a.jsxs("div",{className:"mobile-task-detail-row",children:[a.jsx("span",{children:"Last result"}),a.jsx("span",{style:{fontSize:12},children:o.lastResult})]}),o.lastError&&a.jsxs("div",{className:"mobile-task-detail-row",children:[a.jsx("span",{children:"Last error"}),a.jsx("span",{style:{fontSize:12},children:o.lastError})]})]})})}),a.jsx(vC,{open:d.open,initial:d.initial,onClose:()=>c({open:!1}),onSaved:()=>{c({open:!1}),f()}})]})}function vf(e){var r,i;if(!e)return{name:"",type:"cron",cronMinute:0,cronHour:13,cronDow:"0",intervalN:30,intervalUnit:"m",onceAt:"",timezone:"UTC",actionType:"agent",actionTarget:"",actionPrompt:"",skipIfBudgetLow:!1,maxConcurrent:6,enabled:!0};const t=e.type==="cron"?fg(e.schedule):null,n=e.type==="interval"?wC(e.schedule):null;return{name:e.name||"",type:e.type,cronMinute:(t==null?void 0:t.minute)??0,cronHour:(t==null?void 0:t.hour)??9,cronDow:(t==null?void 0:t.dow)??"*",intervalN:(n==null?void 0:n.n)??30,intervalUnit:(n==null?void 0:n.unit)??"m",onceAt:e.type==="once"?bC(e.schedule):"",timezone:e.timezone||"UTC",actionType:e.action.type,actionTarget:e.action.target||"",actionPrompt:e.action.prompt||"",skipIfBudgetLow:!!((r=e.budgetCheck)!=null&&r.skipIfBudgetLow),maxConcurrent:Number.isFinite((i=e.budgetCheck)==null?void 0:i.maxConcurrent)?e.budgetCheck.maxConcurrent:6,enabled:e.enabled!==!1}}function xC(e){if(e.type==="cron")return`${e.cronMinute} ${e.cronHour} * * ${e.cronDow}`;if(e.type==="interval")return`${e.intervalN}${e.intervalUnit}`;if(!e.onceAt)return"";try{return new Date(e.onceAt).toISOString()}catch{return e.onceAt}}function vC({open:e,initial:t,onClose:n,onSaved:r}){const[i,l]=w.useState(()=>vf(t)),[s,o]=w.useState(!1);w.useEffect(()=>{e&&l(vf(t))},[e,t]);const u=(c,f)=>{l(m=>({...m,[c]:f}))},d=async c=>{if(c.preventDefault(),!i.name.trim())return;const f=xC(i);if(f){o(!0);try{const m={name:i.name.trim(),type:i.type,schedule:f,timezone:i.timezone,action:{type:i.actionType,target:i.actionTarget.trim(),...i.actionType==="agent"&&i.actionPrompt.trim()?{prompt:i.actionPrompt.trim()}:{}},budgetCheck:{maxConcurrent:i.maxConcurrent,skipIfBudgetLow:i.skipIfBudgetLow},enabled:i.enabled};t?await q.put(`/schedules/${encodeURIComponent(t.id)}`,m):await q.post("/schedules",m),r()}catch{}finally{o(!1)}}};return a.jsx(Tn,{open:e,onClose:n,title:t?`Edit ${t.name}`:"New schedule",actions:a.jsxs("button",{type:"submit",form:"mobile-schedule-form",className:"mobile-btn",style:{width:"100%"},disabled:s,children:[a.jsx(xt,{size:14})," ",t?"Save":"Create"]}),children:a.jsxs("form",{id:"mobile-schedule-form",onSubmit:d,className:"mobile-task-form",children:[a.jsx("label",{className:"mobile-field-label",children:"Name *"}),a.jsx("input",{className:"mobile-input",type:"text",placeholder:"Weekly review",value:i.name,onChange:c=>u("name",c.target.value),autoFocus:!0,required:!0}),a.jsx("label",{className:"mobile-field-label",children:"Type"}),a.jsx("select",{className:"mobile-input",value:i.type,onChange:c=>u("type",c.target.value),children:hC.map(c=>a.jsx("option",{value:c,children:c},c))}),i.type==="cron"&&a.jsxs(a.Fragment,{children:[a.jsx("label",{className:"mobile-field-label",children:"Day of week"}),a.jsx("select",{className:"mobile-input",value:i.cronDow,onChange:c=>u("cronDow",c.target.value),children:dg.map(c=>a.jsx("option",{value:c.value,children:c.label},c.value))}),a.jsxs("div",{className:"mobile-form-row",children:[a.jsxs("div",{style:{flex:1},children:[a.jsx("label",{className:"mobile-field-label",children:"Hour"}),a.jsx("select",{className:"mobile-input",value:String(i.cronHour),onChange:c=>u("cronHour",parseInt(c.target.value,10)),children:cg.map(c=>a.jsx("option",{value:String(c.value),children:c.label},c.value))})]}),a.jsxs("div",{style:{flex:1},children:[a.jsx("label",{className:"mobile-field-label",children:"Minute"}),a.jsx("select",{className:"mobile-input",value:String(i.cronMinute),onChange:c=>u("cronMinute",parseInt(c.target.value,10)),children:pC.map(c=>a.jsx("option",{value:String(c),children:String(c).padStart(2,"0")},c))})]})]})]}),i.type==="interval"&&a.jsxs("div",{className:"mobile-form-row",children:[a.jsxs("div",{style:{flex:1},children:[a.jsx("label",{className:"mobile-field-label",children:"Every"}),a.jsx("input",{className:"mobile-input",type:"number",min:1,value:i.intervalN,onChange:c=>u("intervalN",parseInt(c.target.value,10)||1)})]}),a.jsxs("div",{style:{flex:1},children:[a.jsx("label",{className:"mobile-field-label",children:"Unit"}),a.jsx("select",{className:"mobile-input",value:i.intervalUnit,onChange:c=>u("intervalUnit",c.target.value),children:gC.map(c=>a.jsx("option",{value:c.value,children:c.label},c.value))})]})]}),i.type==="once"&&a.jsxs(a.Fragment,{children:[a.jsx("label",{className:"mobile-field-label",children:"Run at"}),a.jsx("input",{className:"mobile-input",type:"datetime-local",value:i.onceAt,onChange:c=>u("onceAt",c.target.value)})]}),a.jsx("label",{className:"mobile-field-label",children:"Timezone"}),a.jsx("select",{className:"mobile-input",value:xf.includes(i.timezone)?i.timezone:"UTC",onChange:c=>u("timezone",c.target.value),children:xf.map(c=>a.jsx("option",{value:c,children:c},c))}),a.jsx("label",{className:"mobile-field-label",children:"Action type"}),a.jsx("select",{className:"mobile-input",value:i.actionType,onChange:c=>u("actionType",c.target.value),children:mC.map(c=>a.jsx("option",{value:c,children:c},c))}),a.jsx("label",{className:"mobile-field-label",children:"Target"}),a.jsx("input",{className:"mobile-input",type:"text",placeholder:i.actionType==="webhook"?"https://...":i.actionType==="agent"?"agent or task ref":"echo hello",value:i.actionTarget,onChange:c=>u("actionTarget",c.target.value)}),i.actionType==="agent"&&a.jsxs(a.Fragment,{children:[a.jsx("label",{className:"mobile-field-label",children:"Prompt"}),a.jsx("textarea",{className:"mobile-input",rows:3,placeholder:"What should the agent do?",value:i.actionPrompt,onChange:c=>u("actionPrompt",c.target.value)})]}),a.jsxs("fieldset",{className:"mobile-budget-card",children:[a.jsx("legend",{children:"Budget pre-flight"}),a.jsxs("label",{className:"mobile-checkbox-row",children:[a.jsx("input",{type:"checkbox",checked:i.skipIfBudgetLow,onChange:c=>u("skipIfBudgetLow",c.target.checked)}),a.jsx("span",{children:"Skip if too many bg tasks are running"})]}),a.jsx("label",{className:"mobile-field-label",children:"Cap"}),a.jsx("input",{className:"mobile-input",type:"number",min:1,max:64,value:i.maxConcurrent,onChange:c=>u("maxConcurrent",parseInt(c.target.value,10)||6),disabled:!i.skipIfBudgetLow})]}),a.jsxs("label",{className:"mobile-checkbox-row",children:[a.jsx("input",{type:"checkbox",checked:i.enabled,onChange:c=>u("enabled",c.target.checked)}),a.jsx("span",{children:"Enabled"})]})]})})}function kC(e){const t=Date.now()-new Date(e).getTime();return t<6e4?"just now":t<36e5?`${Math.floor(t/6e4)}m ago`:t<864e5?`${Math.floor(t/36e5)}h ago`:new Date(e).toLocaleDateString()}function kf(e,t){try{return new Date(e).toLocaleString(void 0,{timeZone:t||void 0,weekday:"short",hour:"numeric",minute:"2-digit",month:"short",day:"numeric"})}catch{return new Date(e).toLocaleString()}}function fg(e){if(typeof e!="string")return null;const t=e.trim().split(/\s+/);if(t.length!==5)return null;const[n,r,,,i]=t,l=parseInt(n,10),s=parseInt(r,10);return!Number.isFinite(l)||!Number.isFinite(s)||n!==String(l)||r!==String(s)?null:{minute:l,hour:s,dow:i==="*"?"*":Number.isFinite(parseInt(i,10))?i:"*"}}function wC(e){if(typeof e!="string")return null;const t=/^(\d+)([smhd])$/i.exec(e.trim());return t?{n:parseInt(t[1],10),unit:t[2].toLowerCase()}:null}function bC(e){if(!e)return"";try{const t=new Date(e);if(Number.isNaN(t.getTime()))return"";const n=r=>String(r).padStart(2,"0");return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())}T${n(t.getHours())}:${n(t.getMinutes())}`}catch{return""}}function wf(e){var l,s;if(e.type!=="cron")return e.schedule;const t=fg(e.schedule);if(!t)return e.schedule;const n=((l=dg.find(o=>o.value===t.dow))==null?void 0:l.label)||t.dow,r=((s=cg.find(o=>o.value===t.hour))==null?void 0:s.label)||`${t.hour}`,i=String(t.minute).padStart(2,"0");return n==="Every day"?`Every day ${r} :${i}`:`Every ${n} ${r} :${i}`}const SC=["all","tasks","agents","artifacts","projects","settings"],CC={tasks:es,agents:Dr,plans:qn,projects:Pu,settings:Pr};function jC({open:e,onClose:t,onNavigate:n}){const[r,i]=w.useState(""),[l,s]=w.useState("all"),[o,u]=w.useState([]),[d,c]=w.useState(!1),f=w.useRef(null);w.useEffect(()=>{e&&(i(""),u([]),requestAnimationFrame(()=>{var p;return(p=f.current)==null?void 0:p.focus()}))},[e]),w.useEffect(()=>{if(!r.trim()){u([]);return}const p=setTimeout(async()=>{c(!0);try{const x=await q.get(`/search?q=${encodeURIComponent(r)}&scope=${l}`);u(x.results||[])}catch{u([])}finally{c(!1)}},250);return()=>clearTimeout(p)},[r,l]);const m=p=>{const x=p.item,b=x.id||x.slug||x.name||"";n(p.type,b),t()},h=o.reduce((p,x)=>(p[x.type]||(p[x.type]=[]),p[x.type].push(x),p),{});return a.jsx(Tn,{open:e,onClose:t,title:"Search",children:a.jsxs("div",{className:"mobile-search-container",children:[a.jsxs("div",{className:"mobile-search-input-row",children:[a.jsx(hd,{size:16,style:{color:"var(--text-muted)",flexShrink:0}}),a.jsx("input",{ref:f,className:"mobile-search-field",type:"text",placeholder:"Search…",value:r,onChange:p=>i(p.target.value),enterKeyHint:"search",onKeyDown:p=>{p.key==="Escape"&&t(),p.key==="Enter"&&o.length>0&&m(o[0])}}),r&&a.jsx("button",{type:"button",className:"mobile-icon-btn",onClick:()=>i(""),"aria-label":"Clear",children:a.jsx(Zn,{size:16})})]}),a.jsx("div",{className:"mobile-search-scopes",children:SC.map(p=>a.jsx("button",{type:"button",className:`mobile-scope-chip ${l===p?"active":""}`,onClick:()=>s(p),children:p==="all"?"All":p.charAt(0).toUpperCase()+p.slice(1)},p))}),a.jsxs("div",{className:"mobile-search-results",children:[d&&a.jsx("div",{className:"mobile-search-loading",children:"Searching…"}),!d&&r&&o.length===0&&a.jsxs("div",{className:"mobile-empty",children:[a.jsx(hd,{size:32}),a.jsx("p",{children:"No results found"})]}),!d&&!r&&a.jsx("div",{className:"mobile-empty",children:a.jsx("p",{children:"Type to search across tasks, agents, plans, and more."})}),Object.entries(h).map(([p,x])=>{const b=CC[p]||qn;return a.jsxs("div",{className:"mobile-search-group",children:[a.jsxs("h4",{className:"mobile-search-group-title",children:[a.jsx(b,{size:12})," ",p.charAt(0).toUpperCase()+p.slice(1)," (",x.length,")"]}),x.map((y,g)=>{const v=y.item;return a.jsxs("button",{type:"button",className:"mobile-search-result-item",onClick:()=>m(y),children:[a.jsx("span",{className:"mobile-search-result-title",children:v.title||v.name||v.slug||"(unnamed)"}),v.description&&a.jsx("span",{className:"mobile-search-result-meta",children:v.description.slice(0,80)})]},g)})]},p)})]})]})})}const NC=[{id:"dark",label:"Dark",Icon:ix},{id:"light",label:"Light",Icon:fx},{id:"system",label:"System",Icon:rx}],EC=[{name:"Purple",accent:"#8b5cf6"},{name:"Blue",accent:"#3b82f6"},{name:"Green",accent:"#10b981"},{name:"Orange",accent:"#f97316"},{name:"Red",accent:"#ef4444"},{name:"Pink",accent:"#ec4899"},{name:"Cyan",accent:"#06b6d4"},{name:"Mono",accent:"#6b7280"}];function TC(e){if(e<=0)return"expired";const t=Math.floor(e/1e3),n=Math.floor(t/60),r=t%60;return`${n}:${String(r).padStart(2,"0")}`}function IC({settings:e,snapshot:t,onRefresh:n}){var z,E,A,L,I,k;const[r,i]=w.useState(e),[l,s]=w.useState(!1),[o,u]=w.useState(!1),[d,c]=w.useState(null),[f,m]=w.useState(!1),[h,p]=w.useState(Date.now());w.useEffect(()=>{i(e),s(!1),e.theme&&ui(e.theme)},[e]),w.useEffect(()=>{if(!d)return;const j=setInterval(()=>p(Date.now()),1e3);return()=>clearInterval(j)},[d]);const x=j=>{i(P=>{const B={...P,theme:{...P.theme,...j}};return ts(B.theme),ui(B.theme),B}),s(!0)},b=(j,P)=>{i(B=>({...B,[j]:P})),s(!0)},y=async()=>{u(!0);try{const j=await q.put("/settings",r);i(j.data),s(!1),ts(j.data.theme),ui(j.data.theme),n()}catch{}finally{u(!1)}},g=async()=>{m(!0);try{const j=await q.post("/pair/start");c(j)}catch{}finally{m(!1)}},v=d?d.expiresAt-h:0,C=d!=null&&v<=0;return a.jsxs("div",{className:"mobile-view",children:[l&&a.jsxs("div",{className:"mobile-settings-save-bar",children:[a.jsx("span",{children:"Unsaved changes"}),a.jsxs("button",{type:"button",className:"mobile-btn",disabled:o,onClick:y,children:[a.jsx(Fm,{size:14})," ",o?"Saving…":"Save"]})]}),a.jsxs("section",{className:"mobile-section",children:[a.jsx("h3",{className:"mobile-section-title",children:"Appearance"}),a.jsxs("div",{className:"mobile-card",children:[a.jsxs("div",{className:"mobile-setting-row",children:[a.jsx("span",{className:"mobile-setting-label",children:"Theme"}),a.jsx("div",{className:"mobile-theme-btns",children:NC.map(({id:j,label:P,Icon:B})=>a.jsxs("button",{type:"button",className:`mobile-theme-btn ${r.theme.mode===j?"active":""}`,onClick:()=>x({mode:j}),children:[a.jsx(B,{size:14})," ",P]},j))})]}),a.jsxs("div",{className:"mobile-setting-row",style:{flexDirection:"column",alignItems:"flex-start",gap:8},children:[a.jsx("span",{className:"mobile-setting-label",children:"Accent color"}),a.jsx("div",{className:"mobile-accent-swatches",children:EC.map(j=>a.jsx("button",{type:"button",className:`mobile-accent-swatch ${r.theme.accent===j.accent?"active":""}`,style:{background:j.accent},onClick:()=>x({accent:j.accent}),title:j.name},j.name))})]}),a.jsxs("div",{className:"mobile-setting-row",style:{flexDirection:"column",alignItems:"flex-start",gap:8},children:[a.jsxs("span",{className:"mobile-setting-label",children:["Font size: ",r.theme.fontSize,"px"]}),a.jsx("input",{type:"range",min:12,max:20,value:r.theme.fontSize,onChange:j=>x({fontSize:Number(j.target.value)}),style:{width:"100%"}})]}),a.jsxs("div",{className:"mobile-setting-row",children:[a.jsx("span",{className:"mobile-setting-label",children:"Compact mode"}),a.jsxs("label",{className:"mobile-toggle",children:[a.jsx("input",{type:"checkbox",checked:r.theme.compactMode,onChange:j=>x({compactMode:j.target.checked})}),a.jsx("span",{className:"mobile-toggle-slider"})]})]}),a.jsxs("div",{className:"mobile-setting-row",children:[a.jsx("span",{className:"mobile-setting-label",children:"Animations"}),a.jsxs("label",{className:"mobile-toggle",children:[a.jsx("input",{type:"checkbox",checked:r.theme.animations,onChange:j=>x({animations:j.target.checked})}),a.jsx("span",{className:"mobile-toggle-slider"})]})]})]})]}),a.jsxs("section",{className:"mobile-section",children:[a.jsx("h3",{className:"mobile-section-title",children:"Chat Defaults"}),a.jsxs("div",{className:"mobile-card",children:[a.jsx("label",{className:"mobile-field-label",children:"Default Agent"}),a.jsx("select",{className:"mobile-input",value:r.defaultAgent||"odin",onChange:j=>b("defaultAgent",j.target.value),children:((t==null?void 0:t.agents)||[]).map(j=>a.jsxs("option",{value:j.name,children:["@",j.name]},j.name))}),a.jsx("label",{className:"mobile-field-label",style:{marginTop:8},children:"Default Model"}),a.jsx("input",{className:"mobile-input",type:"text",placeholder:"(auto)",value:r.defaultModel||"",onChange:j=>b("defaultModel",j.target.value)})]})]}),a.jsxs("section",{className:"mobile-section",children:[a.jsx("h3",{className:"mobile-section-title",children:"Notifications"}),a.jsxs("div",{className:"mobile-card",children:[a.jsxs("div",{className:"mobile-setting-row",children:[a.jsx("span",{className:"mobile-setting-label",children:"Agent completion"}),a.jsxs("label",{className:"mobile-toggle",children:[a.jsx("input",{type:"checkbox",checked:!!r.notifications.onAgentComplete,onChange:j=>{i(P=>({...P,notifications:{...P.notifications,onAgentComplete:j.target.checked}})),s(!0)}}),a.jsx("span",{className:"mobile-toggle-slider"})]})]}),a.jsxs("div",{className:"mobile-setting-row",children:[a.jsx("span",{className:"mobile-setting-label",children:"Plan approval"}),a.jsxs("label",{className:"mobile-toggle",children:[a.jsx("input",{type:"checkbox",checked:!!r.notifications.onPlanApproval,onChange:j=>{i(P=>({...P,notifications:{...P.notifications,onPlanApproval:j.target.checked}})),s(!0)}}),a.jsx("span",{className:"mobile-toggle-slider"})]})]})]})]}),a.jsxs("section",{className:"mobile-section",children:[a.jsx("h3",{className:"mobile-section-title",children:"Agent Behavior"}),a.jsxs("div",{className:"mobile-card",children:[a.jsx("label",{className:"mobile-field-label",children:"Max parallel agents"}),a.jsx("input",{className:"mobile-input",type:"number",inputMode:"numeric",min:1,max:20,value:((z=r.agents)==null?void 0:z.maxParallel)??6,onChange:j=>{i(P=>({...P,agents:{...P.agents,maxParallel:Math.max(1,Math.min(20,parseInt(j.target.value,10)||6))}})),s(!0)}}),a.jsx("label",{className:"mobile-field-label",style:{marginTop:8},children:"Stuck threshold (ms)"}),a.jsx("input",{className:"mobile-input",type:"number",inputMode:"numeric",min:6e4,max:36e5,step:6e4,value:((E=r.agents)==null?void 0:E.stuckThresholdMs)??6e5,onChange:j=>{i(P=>({...P,agents:{...P.agents,stuckThresholdMs:Math.max(6e4,parseInt(j.target.value,10)||6e5)}})),s(!0)}}),a.jsxs("div",{className:"mobile-setting-row",style:{marginTop:8},children:[a.jsx("span",{className:"mobile-setting-label",children:"Auto-restart stuck agents"}),a.jsxs("label",{className:"mobile-toggle",children:[a.jsx("input",{type:"checkbox",checked:!!((A=r.agents)!=null&&A.autoRestart),onChange:j=>{i(P=>({...P,agents:{...P.agents,autoRestart:j.target.checked}})),s(!0)}}),a.jsx("span",{className:"mobile-toggle-slider"})]})]})]})]}),a.jsxs("section",{className:"mobile-section",children:[a.jsx("h3",{className:"mobile-section-title",children:"Tailscale Serve"}),a.jsx("div",{className:"mobile-card",children:a.jsxs("p",{className:"muted",style:{fontSize:13},children:["Use ",a.jsx("code",{children:"bizar service"})," commands in the terminal to configure Tailscale serve."]})})]}),a.jsxs("section",{className:"mobile-section",children:[a.jsxs("h3",{className:"mobile-section-title",children:[a.jsx(dx,{size:14})," Companion App"]}),a.jsxs("div",{className:"mobile-card",children:[!d&&a.jsxs("button",{type:"button",className:"mobile-btn",onClick:g,disabled:f,style:{width:"100%"},children:[a.jsx(ox,{size:14})," ",f?"Generating…":"Generate QR Code"]}),d&&!C&&a.jsxs("div",{style:{textAlign:"center"},children:[a.jsx("div",{style:{background:"#fff",padding:12,borderRadius:12,display:"inline-block"},children:a.jsx(ag,{value:d.qrPayload,size:180,level:"M"})}),a.jsxs("div",{style:{marginTop:8,fontSize:12},children:["Expires in ",a.jsx("strong",{children:TC(v)})]}),a.jsx("div",{className:"mono",style:{fontSize:10,wordBreak:"break-all",marginTop:4},children:d.publicUrl})]}),d&&C&&a.jsxs("button",{type:"button",className:"mobile-btn",onClick:g,style:{width:"100%"},children:[a.jsx(_t,{size:14})," Generate new QR"]})]})]}),a.jsxs("section",{className:"mobile-section",children:[a.jsx("h3",{className:"mobile-section-title",children:"About"}),a.jsxs("div",{className:"mobile-card",children:[a.jsxs("div",{className:"mobile-setting-row",children:[a.jsx("span",{className:"mobile-setting-label",children:"Version"}),a.jsx("span",{className:"mobile-setting-value mono",children:((L=r.about)==null?void 0:L.version)||"—"})]}),a.jsxs("div",{className:"mobile-setting-row",children:[a.jsx("span",{className:"mobile-setting-label",children:"Agents"}),a.jsx("span",{className:"mobile-setting-value",children:((I=t==null?void 0:t.agents)==null?void 0:I.length)||0})]}),a.jsxs("div",{className:"mobile-setting-row",children:[a.jsx("span",{className:"mobile-setting-label",children:"Tasks"}),a.jsx("span",{className:"mobile-setting-value",children:((k=t==null?void 0:t.tasks)==null?void 0:k.length)||0})]}),a.jsxs("div",{className:"mobile-setting-row",children:[a.jsx("span",{className:"mobile-setting-label",children:"Plans"}),a.jsx("span",{className:"mobile-setting-value",children:(t==null?void 0:t.artifacts.length)||0})]})]})]}),a.jsx("div",{className:"mobile-view-footer",children:a.jsx("a",{href:"/?desktop=1",className:"mobile-btn mobile-btn-secondary",children:"Switch to Desktop"})})]})}const zC=["languages","framework","design","testing","devops","data","security","integration"];function PC({snapshot:e,onBack:t}){const[n,r]=w.useState([]),[i,l]=w.useState(!0),[s,o]=w.useState(""),[u,d]=w.useState(""),[c,f]=w.useState(null),m=async()=>{try{const x=await q.get("/skills");r(x.skills||[])}catch{}finally{l(!1)}};w.useEffect(()=>{m()},[]);const h=async(x,b)=>{try{await q.patch(`/skills/${encodeURIComponent(x)}`,{enabled:b}),r(y=>y.map(g=>g.id===x?{...g,enabled:b}:g)),(c==null?void 0:c.id)===x&&f(y=>y&&{...y,enabled:b})}catch{}},p=n.filter(x=>{if(u&&x.category!==u)return!1;if(s){const b=s.toLowerCase();return x.name.toLowerCase().includes(b)||x.description.toLowerCase().includes(b)}return!0});return a.jsxs("div",{className:"mobile-view",children:[a.jsxs("div",{className:"mobile-tasks-toolbar",children:[a.jsx("input",{className:"mobile-search-input",type:"text",placeholder:"Search skills…",value:s,onChange:x=>o(x.target.value),style:{flex:1}}),a.jsx("button",{type:"button",className:"mobile-icon-btn",onClick:()=>m(),"aria-label":"Refresh",children:a.jsx(_t,{size:16})})]}),a.jsxs("div",{className:"mobile-search-scopes",children:[a.jsx("button",{type:"button",className:`mobile-scope-chip ${u?"":"active"}`,onClick:()=>d(""),children:"All"}),zC.map(x=>a.jsx("button",{type:"button",className:`mobile-scope-chip ${u===x?"active":""}`,onClick:()=>d(x),children:x},x))]}),i?a.jsx("div",{className:"mobile-loading",children:a.jsx("p",{children:"Loading…"})}):p.length===0?a.jsxs("div",{className:"mobile-empty",children:[a.jsx(Jl,{size:40}),a.jsx("p",{children:"No skills found."})]}):a.jsx("div",{className:"mobile-card-list",children:p.map(x=>a.jsxs("button",{type:"button",className:"mobile-list-item mobile-list-item-interactive",onClick:()=>f(x),children:[a.jsx("div",{className:"mobile-list-icon",children:a.jsx(Jl,{size:16})}),a.jsxs("div",{className:"mobile-list-content",children:[a.jsx("span",{className:"mobile-list-title",children:x.name}),a.jsxs("span",{className:"mobile-list-meta",children:[x.category," · v",x.version]})]}),a.jsx("span",{className:`mobile-list-badge ${x.enabled?"badge-on":"badge-off"}`,children:x.enabled?"on":"off"})]},x.id))}),c&&a.jsx(Dt,{open:!0,onClose:()=>f(null),title:c.name,actions:a.jsxs("button",{type:"button",className:`mobile-btn ${c.enabled?"mobile-btn-secondary":""}`,style:{width:"100%"},onClick:()=>{c&&h(c.id,!c.enabled)},children:[a.jsx(Om,{size:14})," ",c.enabled?"Disable":"Enable"]}),children:a.jsxs("div",{className:"mobile-agent-detail",children:[a.jsx("p",{className:"mobile-agent-detail-desc",children:c.description||"No description."}),a.jsxs("div",{className:"mobile-agent-detail-meta",children:[a.jsxs("div",{className:"mobile-task-detail-row",children:[a.jsx("span",{children:"Category"}),a.jsx("span",{children:c.category})]}),a.jsxs("div",{className:"mobile-task-detail-row",children:[a.jsx("span",{children:"Version"}),a.jsx("span",{className:"mono",children:c.version})]}),a.jsxs("div",{className:"mobile-task-detail-row",children:[a.jsx("span",{children:"Source"}),a.jsx("span",{children:c.source})]}),c.tags.length>0&&a.jsxs("div",{className:"mobile-task-detail-row",children:[a.jsx("span",{children:"Tags"}),a.jsx("span",{children:c.tags.join(", ")})]})]})]})})]})}const AC=["queued","doing","blocked","done"],dl={queued:"Queued",doing:"Doing",blocked:"Blocked",done:"Done"},bf={queued:"doing",doing:"done",blocked:"queued",done:"queued"};function MC(e){const t=e.metadata??{};return!!(t.sessionId||t.bgInstanceId)}function LC(e){var n;const t=e.metadata??{};return!!((n=t.artifactIds)!=null&&n.length||t.artifactId)}function Sf({snapshot:e,onRefresh:t,selectedTaskId:n,onCloseDetail:r,onOpenChat:i,onOpenArtifact:l}){var oe,Ne;const[s,o]=w.useState(e.tasks||[]),[u,d]=w.useState(!e.tasks),[c,f]=w.useState(""),[m,h]=w.useState("queued"),[p,x]=w.useState(null),[b,y]=w.useState(!1),[g,v]=w.useState(null),[C,z]=w.useState([]),[E,A]=w.useState(""),[L,I]=w.useState(null),[k,j]=w.useState(!1),[P,B]=w.useState(""),[O,W]=w.useState("updated");w.useEffect(()=>{var H;if(e.tasks&&(o(e.tasks),d(!1)),n){const te=(H=e.tasks)==null?void 0:H.find(re=>re.id===n);te&&x(te)}},[e.tasks,n]),w.useEffect(()=>{if(n){const H=s.find(te=>te.id===n);H&&x(H)}},[n,s]);const de=async()=>{try{const H=await q.get("/tasks");o(Array.isArray(H)?H:[])}catch{}finally{d(!1)}},ee=async(H,te)=>{o(re=>re.map(Se=>Se.id===H?{...Se,status:te}:Se)),(p==null?void 0:p.id)===H&&x(re=>re&&{...re,status:te});try{await q.patch(`/tasks/${encodeURIComponent(H)}/status`,{status:te})}catch{await de()}},R=async H=>{if(confirm("Delete this task?"))try{await q.del(`/tasks/${encodeURIComponent(H)}`),o(te=>te.filter(re=>re.id!==H)),(p==null?void 0:p.id)===H&&x(null)}catch{await de()}},V=async H=>{try{await q.post(`/tasks/${encodeURIComponent(H)}/archive`),o(te=>te.filter(re=>re.id!==H)),(p==null?void 0:p.id)===H&&x(null)}catch{}},Y=[...s.filter(H=>{var te,re;if(c.trim()){const Se=c.toLowerCase();if(!(H.title||"").toLowerCase().includes(Se)&&!(H.description||"").toLowerCase().includes(Se))return!1}if(P.trim()){const Se=P==="mine"?((re=(te=e.settings)==null?void 0:te.data)==null?void 0:re.defaultAgent)||RC(e):P.replace(/^@/,"");if((H.assignee||"").toLowerCase()!==Se.toLowerCase())return!1}return!0})].sort((H,te)=>{switch(O){case"priority":{const re={high:0,normal:1,low:2};return(re[H.priority]??1)-(re[te.priority]??1)}case"created":return new Date(te.createdAt).getTime()-new Date(H.createdAt).getTime();case"updated":default:return new Date(te.updatedAt).getTime()-new Date(H.updatedAt).getTime()}}),ie=Y.filter(H=>H.status===m),N=e.agents||[],ge=async(H,te,re,Se)=>{try{const Ot=await q.post("/tasks",{title:H,description:te,assignee:re||null,priority:Se});o(ln=>[Ot,...ln]),y(!1)}catch{}},Le=async H=>{j(!0),A(""),I(null),v(H);try{const re=((await q.get(`/tasks/${encodeURIComponent(H)}/artifacts`)).artifacts||[]).map(Se=>Se.id);if(z(re),re.length>0){const[Se,Ot]=await Promise.all([q.get(`/artifacts/${encodeURIComponent(re[0])}`),fetch(q.urlWithToken(`/artifacts/${encodeURIComponent(re[0])}/content`)).then(ln=>ln.text())]);I(Se),A(Ot)}}catch{}finally{j(!1)}};return u?a.jsx("div",{className:"mobile-loading",children:a.jsx("p",{children:"Loading…"})}):a.jsxs("div",{className:"mobile-view mobile-view-tasks",children:[a.jsxs("div",{className:"mobile-tasks-toolbar",children:[a.jsx("input",{className:"mobile-search-input",type:"text",placeholder:"Search tasks…",value:c,onChange:H=>f(H.target.value),style:{flex:1}}),a.jsx("button",{type:"button",className:"mobile-icon-btn",onClick:()=>de(),"aria-label":"Refresh",children:a.jsx(_t,{size:16})})]}),a.jsxs("div",{className:"mobile-tasks-filters",children:[a.jsxs("select",{className:"mobile-filter-select",value:P,onChange:H=>B(H.target.value),children:[a.jsx("option",{value:"",children:"All"}),a.jsx("option",{value:"mine",children:"Mine"}),N.map(H=>a.jsxs("option",{value:`@${H.name}`,children:["@",H.name]},H.name))]}),a.jsxs("select",{className:"mobile-filter-select",value:O,onChange:H=>W(H.target.value),children:[a.jsx("option",{value:"updated",children:"Updated"}),a.jsx("option",{value:"created",children:"Created"}),a.jsx("option",{value:"priority",children:"Priority"})]})]}),a.jsx("div",{className:"mobile-kanban-tabs",children:AC.map(H=>{const te=Y.filter(re=>re.status===H).length;return a.jsxs("button",{type:"button",className:`mobile-kanban-tab ${m===H?"active":""}`,onClick:()=>h(H),children:[dl[H]," (",te,")"]},H)})}),a.jsxs("div",{className:"mobile-card-list",children:[ie.length===0&&a.jsxs("div",{className:"mobile-empty mobile-empty-compact",children:[a.jsxs("p",{children:["No ",dl[m].toLowerCase()," tasks."]}),a.jsx("p",{className:"muted",children:"Create one or switch columns."})]}),ie.map(H=>{var te;return a.jsxs("button",{type:"button",className:"mobile-task-card",onClick:()=>x(H),children:[a.jsx("div",{className:"priority-dot",style:{background:gx[H.priority]||"var(--info)"}}),a.jsxs("div",{className:"task-content",children:[a.jsx("div",{className:"task-title",children:H.title}),a.jsxs("div",{className:"task-meta",children:[H.assignee?`@${H.assignee}`:"unassigned"," · ",Sr(H.updatedAt||H.createdAt),(te=H.dependencies)!=null&&te.length?` · ${H.dependencies.length} deps`:""]})]})]},H.id)})]}),a.jsx("button",{type:"button",className:"mobile-fab",onClick:()=>y(!0),"aria-label":"Add task",children:a.jsx(xt,{size:24})}),a.jsx(Dt,{open:!!p,onClose:()=>{x(null),r==null||r()},title:"Task Detail",actions:p&&a.jsxs("div",{className:"mobile-task-detail-actions",children:[p.status!=="done"&&a.jsxs("button",{type:"button",className:"mobile-btn",style:{flex:1},onClick:()=>{p&&ee(p.id,bf[p.status])},children:["Move to ",dl[bf[p.status]||"queued"]]}),a.jsxs("button",{type:"button",className:"mobile-btn mobile-btn-secondary",onClick:()=>{p&&V(p.id)},children:[a.jsx(V1,{size:14})," Archive"]}),MC(p)&&a.jsxs("button",{type:"button",className:"mobile-btn mobile-btn-secondary",onClick:()=>{i==null||i(p.id)},children:[a.jsx(On,{size:14})," Chat"]}),LC(p)&&a.jsxs("button",{type:"button",className:"mobile-btn mobile-btn-secondary",onClick:()=>{Le(p.id)},children:[a.jsx(qn,{size:14})," Artifact"]}),a.jsx("button",{type:"button",className:"mobile-btn mobile-btn-danger",onClick:()=>{p&&R(p.id)},children:a.jsx(_r,{size:14})})]}),children:p&&a.jsxs("div",{className:"mobile-task-detail",children:[a.jsxs("div",{className:"mobile-task-detail-header",children:[a.jsx("span",{className:`mobile-task-status-badge status-${p.status}`,children:dl[p.status]||p.status}),a.jsx("span",{className:`mobile-task-priority priority-${p.priority}`,children:p.priority})]}),a.jsx("h3",{className:"mobile-task-detail-title",children:p.title}),p.description&&a.jsx("p",{className:"mobile-task-detail-desc",children:p.description}),a.jsxs("div",{className:"mobile-task-detail-meta",children:[p.assignee&&a.jsxs("div",{className:"mobile-task-detail-row",children:[a.jsx("span",{children:"Assignee"}),a.jsxs("span",{children:["@",p.assignee]})]}),p.dueDate&&a.jsxs("div",{className:"mobile-task-detail-row",children:[a.jsx("span",{children:"Due"}),a.jsx("span",{children:new Date(p.dueDate).toLocaleDateString()})]}),p.timeSpent!=null&&a.jsxs("div",{className:"mobile-task-detail-row",children:[a.jsx("span",{children:"Time spent"}),a.jsxs("span",{children:[Math.round(p.timeSpent/6e4),"min"]})]}),(oe=p.dependencies)!=null&&oe.length?a.jsxs("div",{className:"mobile-task-detail-row",children:[a.jsx("span",{children:"Dependencies"}),a.jsx("span",{children:p.dependencies.length})]}):null,(Ne=p.comments)!=null&&Ne.length?a.jsxs("div",{className:"mobile-task-detail-row",children:[a.jsx("span",{children:"Comments"}),a.jsx("span",{children:p.comments.length})]}):null,a.jsxs("div",{className:"mobile-task-detail-row",children:[a.jsx("span",{children:"Created"}),a.jsx("span",{children:Sr(p.createdAt)})]}),a.jsxs("div",{className:"mobile-task-detail-row",children:[a.jsx("span",{children:"Updated"}),a.jsx("span",{children:Sr(p.updatedAt)})]})]})]})}),a.jsx(DC,{open:b,onClose:()=>y(!1),onCreate:ge,agents:N}),a.jsx(Dt,{open:!!g,onClose:()=>{v(null),A(""),I(null)},title:(L==null?void 0:L.name)||"Artifact",actions:C.length>1?a.jsx("div",{className:"mobile-task-detail-actions",children:C.map((H,te)=>a.jsxs("button",{type:"button",className:"mobile-btn mobile-btn-secondary",style:{flex:1},onClick:()=>{j(!0),Promise.all([q.get(`/artifacts/${encodeURIComponent(H)}`),fetch(q.urlWithToken(`/artifacts/${encodeURIComponent(H)}/content`)).then(re=>re.text())]).then(([re,Se])=>{I(re),A(Se),j(!1)}).catch(()=>j(!1))},children:["Artifact ",te+1]},H))}):null,children:a.jsx("div",{className:"mobile-artifact-viewer",children:k?a.jsx("div",{className:"mobile-loading",children:a.jsx("p",{children:"Loading artifact…"})}):E?a.jsx("iframe",{srcDoc:E,className:"mobile-artifact-iframe",sandbox:"allow-scripts allow-forms allow-popups allow-same-origin",title:(L==null?void 0:L.name)||"Artifact",loading:"lazy"}):a.jsxs("div",{className:"mobile-empty",children:[a.jsx(qn,{size:32}),a.jsx("p",{className:"muted",children:"No artifact content available."})]})})})]})}function RC(e){var t,n;return((n=(t=e.settings)==null?void 0:t.data)==null?void 0:n.defaultAgent)||"odin"}function DC({open:e,onClose:t,onCreate:n,agents:r}){const[i,l]=w.useState(""),[s,o]=w.useState(""),[u,d]=w.useState(""),[c,f]=w.useState("normal"),m=h=>{h.preventDefault(),i.trim()&&(n(i.trim(),s.trim(),u,c),l(""),o(""),d(""),f("normal"))};return a.jsx(Tn,{open:e,onClose:t,title:"New Task",actions:a.jsxs("button",{type:"submit",form:"new-task-form",className:"mobile-btn",style:{width:"100%"},children:[a.jsx(xt,{size:14})," Create Task"]}),children:a.jsxs("form",{id:"new-task-form",onSubmit:m,className:"mobile-task-form",children:[a.jsx("label",{className:"mobile-field-label",children:"Title *"}),a.jsx("input",{className:"mobile-input",type:"text",placeholder:"Task title",value:i,onChange:h=>l(h.target.value),autoFocus:!0,required:!0}),a.jsx("label",{className:"mobile-field-label",children:"Description"}),a.jsx("textarea",{className:"mobile-input",rows:3,placeholder:"Optional description",value:s,onChange:h=>o(h.target.value)}),a.jsx("label",{className:"mobile-field-label",children:"Assignee"}),a.jsxs("select",{className:"mobile-input",value:u,onChange:h=>d(h.target.value),children:[a.jsx("option",{value:"",children:"Unassigned"}),r.map(h=>a.jsxs("option",{value:h.name,children:["@",h.name]},h.name))]}),a.jsx("label",{className:"mobile-field-label",children:"Priority"}),a.jsxs("select",{className:"mobile-input",value:c,onChange:h=>f(h.target.value),children:[a.jsx("option",{value:"low",children:"Low"}),a.jsx("option",{value:"normal",children:"Normal"}),a.jsx("option",{value:"high",children:"High"})]})]})})}const _C=[{id:"activity",label:"Activity",icon:xa},{id:"chat",label:"Chat",icon:On},{id:"tasks",label:"Tasks",icon:es},{id:"settings",label:"Settings",icon:Bm},{id:"more",label:"More",icon:J1}];function OC(e){const t=e.meta??{},n=typeof t.taskId=="string"?t.taskId:null,r=typeof t.slug=="string"?t.slug:null,i=typeof t.agent=="string"?t.agent:null;if(n)return{id:"task-detail",taskId:n};if(r)return{id:"artifacts?-detail",slug:r};if(i)return{id:"agent-detail",name:i};const l=e.link??"";return l.startsWith("/artifacts?/")?{id:"artifacts?-detail",slug:decodeURIComponent(l.slice(12))}:l.startsWith("/tasks/")?{id:"task-detail",taskId:decodeURIComponent(l.slice(7))}:l.startsWith("/agents/")?{id:"agent-detail",name:decodeURIComponent(l.slice(8))}:null}function WC(){const[e,t]=w.useState("activity"),[n,r]=w.useState([]),[i,l]=w.useState(!1),[s,o]=w.useState(null),[u,d]=w.useState(null),[c,f]=w.useState(null),[m,h]=w.useState(null),[p,x]=w.useState(!0),[b,y]=w.useState(0),g=w.useMemo(()=>n[n.length-1]??{id:e},[e,n]),v=w.useCallback(k=>{r(j=>[...j,k])},[]),C=w.useCallback(()=>{r(k=>k.slice(0,-1))},[]),z=w.useCallback(k=>{r([]),t(k)},[]),E=w.useCallback(async()=>{var k;try{const j=await q.get("/snapshot");d(j),(k=j.settings)!=null&&k.data&&f(j.settings.data),h(null)}catch(j){throw h(j.message||"Dashboard server unreachable."),j}},[]);w.useEffect(()=>{let k=!1;return Promise.all([q.get("/snapshot").catch(()=>null),q.get("/settings").catch(()=>null),q.probeAuthStatus().catch(()=>null)]).then(([j,P])=>{var O;if(k)return;const B=(P==null?void 0:P.data)??((O=j==null?void 0:j.settings)==null?void 0:O.data)??null;j&&d(j),B&&f(B),h(!j&&!B?"Dashboard server unreachable.":null)}).catch(j=>{k||h(j.message||"Dashboard server unreachable.")}).finally(()=>{k||x(!1)}),()=>{k=!0}},[]),w.useEffect(()=>{c!=null&&c.theme&&(ts(c.theme),ui(c.theme))},[c==null?void 0:c.theme]),w.useEffect(()=>{var P;if(((P=c==null?void 0:c.theme)==null?void 0:P.mode)!=="system")return;const k=window.matchMedia("(prefers-color-scheme: light)"),j=()=>{c!=null&&c.theme&&(ts(c.theme),ui(c.theme))};return k.addEventListener("change",j),()=>k.removeEventListener("change",j)},[c==null?void 0:c.theme]),w.useEffect(()=>{const k=()=>{y(P=>P+1),E().catch(()=>{})},j=()=>{document.visibilityState==="visible"&&k()};return window.addEventListener("online",k),window.addEventListener("pageshow",k),document.addEventListener("visibilitychange",j),()=>{window.removeEventListener("online",k),window.removeEventListener("pageshow",k),document.removeEventListener("visibilitychange",j)}},[E]),w.useEffect(()=>{const k=new Vm,j=k.on(P=>{if(P.type==="snapshot"&&"data"in P&&P.data)d(B=>({...B??{},...P.data}));else if(P.type==="change")E().catch(()=>{});else if(P.type==="tasks:change"){const B=P.task;d(O=>{if(!O)return O;const W=(O.tasks||[]).map(ee=>ee.id===B.id?B:ee),de=W.some(ee=>ee.id===B.id);return{...O,tasks:de?W:[B,...W]}})}else P.type==="tasks:delete"?d(B=>B&&{...B,tasks:(B.tasks||[]).filter(O=>O.id!==P.id)}):P.type==="settings:change"?P.settings&&f(P.settings):P.type==="project:change"||P.type==="agents:change"||P.type==="schedules:change"||P.type==="artifact:change"?E().catch(()=>{}):(P.type==="agent:status"||P.type==="agent:restarted")&&d(B=>{if(!B)return B;const O=(B.agents||[]).map(W=>W.name===P.agent.name?P.agent:W);return{...B,agents:O}})});return()=>{j(),k.close()}},[E,b]);const A=w.useCallback(k=>{(k==="activity"||k==="chat"||k==="tasks"||k==="settings"||k==="more")&&z(k)},[z]),L=w.useCallback((k,j,P)=>{if(k==="notification"){const B=OC({link:j||null,meta:P??null});B&&v(B);return}if(k==="task"&&j){v({id:"task-detail",taskId:j});return}if(k==="artifacts?"&&j){v({id:"artifacts?-detail",slug:j});return}if(k==="agent"&&j){v({id:"agent-detail",name:j});return}if(k==="project"){z("activity");return}k==="setting"&&z("settings")},[z,v]),I=()=>{if(!u||!c)return null;if(n.length>0){const k=n[n.length-1];switch(k.id){case"artifacts?":return a.jsx(fC,{snapshot:u,onBack:C,onOpenArtifact:j=>v({id:"artifacts?-detail",slug:j})});case"agents":return a.jsx(yf,{snapshot:u,onBack:C,onOpenAgent:j=>v({id:"agent-detail",name:j}),onRefresh:E});case"skills":return a.jsx(PC,{snapshot:u,onBack:C});case"mods":return a.jsx(sC,{snapshot:u,onBack:C});case"schedules":return a.jsx(yC,{snapshot:u,onBack:C});case"history":return a.jsx(lC,{onBack:C});case"config":return a.jsx(iC,{onBack:C});case"artifacts?-detail":return a.jsx(uC,{slug:k.slug,onBack:C});case"agent-detail":return a.jsx(yf,{snapshot:u,onBack:C,onOpenAgent:()=>{},onRefresh:E,selectedAgent:k.name});case"task-detail":return a.jsx(Sf,{snapshot:u,onRefresh:E,selectedTaskId:k.taskId,onCloseDetail:C,onOpenChat:j=>{o(j),z("chat")}});default:return null}}switch(e){case"activity":return a.jsx(X2,{snapshot:u,onRefresh:E});case"chat":return a.jsx(rC,{snapshot:u,settings:c,initialTaskId:s,onClearTaskId:()=>o(null)});case"tasks":return a.jsx(Sf,{snapshot:u,onRefresh:E,onOpenChat:k=>{o(k),z("chat")}});case"settings":return a.jsx(IC,{settings:c,snapshot:u,onRefresh:E});case"more":return a.jsx(oC,{snapshot:u,onNavigate:k=>{(k==="artifacts?"||k==="agents"||k==="skills"||k==="mods"||k==="schedules"||k==="history"||k==="config")&&v({id:k})}});default:return null}};return p?a.jsxs("div",{className:"mobile-loading",children:[a.jsx(Wm,{size:"lg"}),a.jsx("p",{children:"Loading Bizar…"})]}):m||!u||!c?a.jsxs("div",{className:"mobile-loading",children:[a.jsx("h2",{children:"Dashboard unavailable"}),a.jsx("p",{children:m||"Dashboard server unreachable."}),a.jsx("p",{className:"muted",children:"Make sure the Bizar dashboard server is running."})]}):a.jsxs("div",{className:"mobile-app",children:[a.jsx(K2,{activeTab:g.id,snapshot:u,onSearch:()=>l(!0),onNavigate:L}),a.jsx("main",{className:"mobile-content",children:I()}),n.length===0&&a.jsx(V2,{tabs:_C,activeTab:e,onChange:A}),n.length>0&&a.jsx("button",{type:"button",className:"mobile-back-btn",onClick:C,"aria-label":"Go back",children:"← Back"}),a.jsx(jC,{open:i,onClose:()=>l(!1),onNavigate:L})]})}export{S2 as $,xa as A,Dr as B,q1 as C,T2 as D,Z1 as E,Pu as F,cx as G,ka as H,tx as I,hx as J,Au as K,A2 as L,On as M,L2 as N,Tx as O,xt as P,j2 as Q,_t as R,es as S,mx as T,Fm as U,$C as V,Zl as W,Zn as X,ux as Y,md as Z,cb as _,q as a,V1 as a0,xx as a1,gx as a2,lx as a3,P2 as a4,ui as a5,ax as a6,ix as a7,fx as a8,rx as a9,X1 as aa,ts as ab,Vm as ac,dx as ad,ag as ae,ox as af,W1 as ag,Bm as ah,UC as ai,BC as aj,wa as ak,$1 as al,WC as am,Ss as b,J as c,dd as d,Jl as e,va as f,Pr as g,hd as h,Mu as i,a as j,pr as k,bx as l,cd as m,Y1 as n,Sr as o,qn as p,px as q,w as r,_e as s,Wm as t,kx as u,$m as v,_r as w,Om as x,Dm as y,Ix as z};
|