clitrigger 0.2.6 → 0.2.7

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.
@@ -563,7 +563,7 @@ Cancel = delete worktree only`,"todo.retry":"Retry","todo.retryDesc":"Cleans up
563
563
  *
564
564
  * This source code is licensed under the ISC license.
565
565
  * See the LICENSE file in the root directory of this source tree.
566
- */const kse=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]],Cse=Ue("zoom-out",kse);function jse({onLogin:e}){const[t,n]=k.useState(""),[r,i]=k.useState(""),[s,o]=k.useState(!1),{t:a,toggleLang:l}=He(),d=async h=>{if(h.preventDefault(),!!t){i(""),o(!0);try{await e(t)}catch{i(a("login.error"))}finally{o(!1)}}};return c.jsxs("div",{className:"min-h-screen bg-theme-bg flex items-center justify-center px-4 relative",children:[c.jsx("button",{onClick:l,className:"lang-toggle absolute top-6 right-6",children:a("lang.toggle")}),c.jsxs("div",{className:"w-full max-w-sm animate-fade-in",children:[c.jsxs("div",{className:"text-center mb-10",children:[c.jsx("div",{className:"inline-flex items-center justify-center w-16 h-16 rounded-2xl bg-accent/10 mb-5",children:c.jsx(Mv,{size:32,className:"text-accent",strokeWidth:1.5})}),c.jsx("h1",{className:"text-2xl font-semibold text-theme-text",children:a("login.title")}),c.jsx("p",{className:"text-theme-muted text-sm mt-2",children:a("login.subtitle")})]}),c.jsx("form",{onSubmit:d,children:c.jsxs("div",{className:"card p-8",children:[c.jsx("label",{className:"block text-sm font-medium text-theme-text-secondary mb-2",children:a("login.password")}),c.jsx("input",{type:"password",value:t,onChange:h=>n(h.target.value),placeholder:"*************",className:"input-field text-base",autoFocus:!0}),r&&c.jsx("div",{className:"mt-4 py-2.5 px-4 bg-status-error/5 border border-status-error/20 rounded-xl text-sm text-status-error",children:r}),c.jsx("button",{type:"submit",disabled:!t||s,className:"btn-primary w-full mt-6 py-3",children:a(s?"login.loading":"login.submit")})]})}),c.jsx("div",{className:"mt-6 text-center text-xs text-theme-text-tertiary",children:a("login.footer")}),c.jsx("div",{className:"mt-4 px-2 py-3 rounded-xl text-xs text-theme-text-tertiary border leading-relaxed text-center",children:a("login.disclaimer")})]})]})}const CR=8;function Ese({onSetup:e}){const[t,n]=k.useState(""),[r,i]=k.useState(""),[s,o]=k.useState(""),[a,l]=k.useState(!1),{t:d,toggleLang:h}=He(),f=t.length>0&&t.length<CR,p=r.length>0&&t!==r,g=t.length>=CR&&t===r&&!a,S=async _=>{if(_.preventDefault(),!!g){o(""),l(!0);try{await e(t,r)}catch(v){o(v instanceof Error&&v.message?v.message:d("setup.error"))}finally{l(!1)}}};return c.jsxs("div",{className:"min-h-screen bg-theme-bg flex items-center justify-center px-4 relative",children:[c.jsx("button",{onClick:h,className:"lang-toggle absolute top-6 right-6",children:d("lang.toggle")}),c.jsxs("div",{className:"w-full max-w-sm animate-fade-in",children:[c.jsxs("div",{className:"text-center mb-10",children:[c.jsx("div",{className:"inline-flex items-center justify-center w-16 h-16 rounded-2xl bg-accent/10 mb-5",children:c.jsx(Mv,{size:32,className:"text-accent",strokeWidth:1.5})}),c.jsx("h1",{className:"text-2xl font-semibold text-theme-text",children:d("setup.title")}),c.jsx("p",{className:"text-theme-muted text-sm mt-2",children:d("setup.subtitle")})]}),c.jsx("form",{onSubmit:S,children:c.jsxs("div",{className:"card p-8",children:[c.jsx("label",{className:"block text-sm font-medium text-theme-text-secondary mb-2",children:d("setup.password")}),c.jsx("input",{type:"password",value:t,onChange:_=>n(_.target.value),placeholder:"*************",className:"input-field text-base",autoFocus:!0}),f&&c.jsx("p",{className:"mt-1 text-2xs text-status-error",children:d("setup.tooShort")}),c.jsx("label",{className:"block text-sm font-medium text-theme-text-secondary mb-2 mt-5",children:d("setup.confirm")}),c.jsx("input",{type:"password",value:r,onChange:_=>i(_.target.value),placeholder:"*************",className:"input-field text-base"}),p&&c.jsx("p",{className:"mt-1 text-2xs text-status-error",children:d("setup.mismatch")}),s&&c.jsx("div",{className:"mt-4 py-2.5 px-4 bg-status-error/5 border border-status-error/20 rounded-xl text-sm text-status-error",children:s}),c.jsx("button",{type:"submit",disabled:!g,className:"btn-primary w-full mt-6 py-3",children:d(a?"setup.loading":"setup.submit")})]})}),c.jsx("div",{className:"mt-4 px-4 py-3 rounded-xl text-xs text-theme-text-tertiary border leading-relaxed text-center",children:d("setup.tunnelPaused")})]})]})}function Nse(e){return Fe("/api/projects/browse",{initialPath:e})}function Ase(e){return Fe("/api/projects/open-folder",{path:e})}function g9(){return it("/api/projects")}function Tse(e){return it(`/api/projects/${e}`)}function v9(e){return Fe("/api/projects",e)}function jR(e,t){return $n(`/api/projects/${e}`,t)}function x9(e,t){const n=t?`?todoId=${encodeURIComponent(t)}`:"";return it(`/api/projects/${e}/debug-logs${n}`)}function y9(e){return wr(`/api/projects/${e}`)}function Dse(e){return Fe(`/api/projects/${e}/start`)}function Mse(e){return Fe(`/api/projects/${e}/stop`)}function b9(e){return it(`/api/projects/${e}/status`)}function Ose(e){return Fe(`/api/projects/${e}/check-git`)}function Rse(e,t){return it(`/api/projects/${e}/git-status`)}function Pse(e,t=0,n=50,r){const i=new URLSearchParams({skip:String(t),limit:String(n)});return it(`/api/projects/${e}/git-log?${i}`)}function g2(e,t){return it(`/api/projects/${e}/git-refs`)}function Lse(e,t){return Fe(`/api/projects/${e}/git-stage`,{files:t})}function Ise(e,t){return Fe(`/api/projects/${e}/git-unstage`,{files:t})}function w9(e,t){return Fe(`/api/projects/${e}/git-commit`,{message:t})}function _9(e,t,n){return Fe(`/api/projects/${e}/git-pull`,{remote:t,branch:n})}function uN(e,t){return Fe(`/api/projects/${e}/git-push`,t||{})}function zse(e){return it(`/api/projects/${e}/git-remotes`)}function S9(e,t,n){return Fe(`/api/projects/${e}/git-fetch`,{remote:t,prune:n})}function Bse(e,t,n){return Fe(`/api/projects/${e}/git-branch`,{name:t,startPoint:n})}function v2(e,t,n){return Fe(`/api/projects/${e}/git-branch-delete`,{name:t,force:n})}function x2(e,t){return Fe(`/api/projects/${e}/git-checkout`,{branch:t})}function k9(e,t){return Fe(`/api/projects/${e}/git-merge`,{branch:t})}function $se(e,t){return Fe(`/api/projects/${e}/git-stash`,{message:t})}function Fse(e,t){return Fe(`/api/projects/${e}/git-stash-pop`,{index:t})}function Hse(e){return it(`/api/projects/${e}/git-stash-list`)}function qse(e,t,n){return Fe(`/api/projects/${e}/git-discard`,{files:t,all:n})}function Use(e,t,n,r){return Fe(`/api/projects/${e}/git-tag`,{name:t,message:n,commit:r})}function ER(e,t,n){return Fe(`/api/projects/${e}/git-branch-rename`,{oldName:t,newName:n})}function Wse(e,t){return Fe(`/api/projects/${e}/git-rebase`,{onto:t})}function Gse(e,t,n){const r=new URLSearchParams;return t&&r.set("file",t),n&&r.set("staged","true"),it(`/api/projects/${e}/git-diff?${r}`)}function Kse(e,t){const n=new URLSearchParams({hash:t});return it(`/api/projects/${e}/git-commit-files?${n}`)}function NR(e,t,n){const r=new URLSearchParams({hash:t});return n&&r.set("file",n),it(`/api/projects/${e}/git-commit-diff?${r}`)}function AR(e){return it(`/api/projects/${e}/worktrees`)}function TR(e,t,n){return Fe(`/api/projects/${e}/worktree-cleanup`,{worktreePath:t,branchName:n})}function C9(e){const t=new URLSearchParams;e.hours!==void 0&&t.set("hours",String(e.hours)),e.statuses&&e.statuses.length>0&&t.set("statuses",e.statuses.join(","));const n=t.toString();return n?`?${n}`:""}function Vse(e={}){return it(`/api/review/queue${C9(e)}`)}function j9(e={}){return it(`/api/review/summary${C9(e)}`)}function Yse(e){return it(`/api/review/diff/${encodeURIComponent(e)}`)}function Xse(e,t){return it(`/api/review/diff/${encodeURIComponent(e)}/file?path=${encodeURIComponent(t)}`)}function Zse(){return it("/api/favorites")}function Jse(e){return Fe("/api/favorites",e)}function Qse(e,t){return $n(`/api/favorites/${e}`,t)}function eae(e){return wr(`/api/favorites/${e}`)}function tae(e){return Fe(`/api/favorites/${e}/launch`)}function y2(){return it("/api/tunnel/status")}function nae(){return it("/api/tunnel/config")}function rae(e){return $n("/api/tunnel/config",e)}function E9(e){return Fe("/api/tunnel/start",{})}function iae(){return Fe("/api/tunnel/stop")}const N9=k.createContext({theme:"light",toggleTheme:()=>{}});function sae(){const[e,t]=k.useState(()=>{const r=localStorage.getItem("theme");return r==="light"||r==="dark"?r:window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"});k.useEffect(()=>{document.documentElement.setAttribute("data-theme",e),localStorage.setItem("theme",e)},[e]);const n=k.useCallback(()=>{t(r=>r==="light"?"dark":"light")},[]);return{theme:e,toggleTheme:n}}function A9(){return k.useContext(N9)}const T9=k.createContext({enabled:!1,supported:!1,toggleNotification:()=>{},sendNotification:()=>{}});function aae(){const e="Notification"in window,[t,n]=k.useState(()=>e?localStorage.getItem("clitrigger-notifications")==="on"&&Notification.permission==="granted":!1),r=k.useRef(t);k.useEffect(()=>{r.current=t},[t]);const i=k.useCallback(async()=>{if(e)if(r.current)localStorage.setItem("clitrigger-notifications","off"),n(!1);else{if(Notification.permission==="denied"||Notification.permission==="default"&&await Notification.requestPermission()!=="granted")return;localStorage.setItem("clitrigger-notifications","on"),n(!0)}},[e]),s=k.useCallback((o,a)=>{if(!r.current)return;const l=new Notification(o,{body:a});l.onclick=()=>{window.focus(),l.close()}},[]);return{enabled:t,supported:e,toggleNotification:i,sendNotification:s}}function dN(){return k.useContext(T9)}let oae=0;function ah(){const[e,t]=k.useState([]),n=k.useRef(new Map),r=k.useCallback(d=>{t(f=>f.filter(p=>p.id!==d));const h=n.current.get(d);h&&(clearTimeout(h),n.current.delete(d))},[]),i=k.useCallback((d,h="info",f=3500)=>{const p=`toast-${++oae}`;t(S=>[...S,{id:p,message:d,type:h,duration:f}]);const g=setTimeout(()=>r(p),f);return n.current.set(p,g),p},[r]),s=k.useCallback((d,h)=>i(d,"success",h),[i]),o=k.useCallback((d,h)=>i(d,"error",h),[i]),a=k.useCallback((d,h)=>i(d,"info",h),[i]),l=k.useCallback((d,h)=>i(d,"warning",h),[i]);return{toasts:e,show:i,success:s,error:o,info:a,warning:l,dismiss:r}}function oa(...e){return e.filter(Boolean).join(" ")}const lae={sm:"max-w-sm",md:"max-w-md",lg:"max-w-lg",xl:"max-w-xl","2xl":"max-w-2xl"},cae={scale:"animate-scale-in","slide-up":"animate-slide-up"};function zn({open:e,onClose:t,size:n="md",position:r="center",animation:i="scale",disableEscClose:s=!1,disableBackdropClose:o=!1,children:a}){const l=k.useRef(null);return k.useEffect(()=>{if(!e||s)return;const d=h=>{h.key==="Escape"&&t()};return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[e,s,t]),e?yr.createPortal(c.jsx("div",{ref:l,className:oa("fixed inset-0 bg-black/50 backdrop-blur-sm z-modal flex",r==="center"?"items-center justify-center p-4":"items-start justify-center px-4 pt-[20vh]"),onClick:d=>{!o&&d.target===l.current&&t()},children:c.jsx("div",{className:oa("w-full",lae[n],cae[i]),children:a})}),document.body):null}function D9({onSubmit:e,onCancel:t}){const[n,r]=k.useState(""),[i,s]=k.useState(""),[o,a]=k.useState(!1),{t:l}=He(),d=f=>{f.preventDefault(),!(!n.trim()||!i.trim())&&e(n.trim(),i.trim())},h=async()=>{a(!0);try{const f=await Nse(i||void 0);f.path&&s(f.path)}catch{}a(!1)};return c.jsx(zn,{open:!0,onClose:t,size:"md",children:c.jsxs("div",{className:"card p-8 shadow-2xl rounded-2xl",children:[c.jsx("h2",{className:"text-lg font-semibold text-warm-800 mb-6",children:l("form.newProject")}),c.jsxs("form",{onSubmit:d,children:[c.jsxs("div",{className:"mb-5",children:[c.jsx("label",{className:"block text-sm font-medium text-warm-600 mb-2",children:l("form.projectName")}),c.jsx("input",{type:"text",placeholder:"my-project",value:n,onChange:f=>r(f.target.value),className:"input-field",autoFocus:!0})]}),c.jsxs("div",{className:"mb-8",children:[c.jsx("label",{className:"block text-sm font-medium text-warm-600 mb-2",children:l("form.folderPath")}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx("input",{type:"text",placeholder:"C:/Projects/my-project",value:i,onChange:f=>s(f.target.value),className:"input-field text-sm flex-1"}),c.jsx("button",{type:"button",onClick:h,disabled:o,className:"btn-ghost text-sm px-3 shrink-0",title:l("browse.title"),children:o?c.jsx(kn,{size:16,className:"animate-spin"}):c.jsx(Tv,{size:16})})]})]}),c.jsxs("div",{className:"flex justify-end gap-3",children:[c.jsx("button",{type:"button",onClick:t,className:"btn-ghost text-sm",children:l("form.cancel")}),c.jsx("button",{type:"submit",disabled:!n.trim()||!i.trim(),className:"btn-primary text-sm",children:l("form.create")})]})]})]})})}const uae=[{value:"executable",icon:u9},{value:"command",icon:cN},{value:"url",icon:wl}];function dae(e){const t=[],n=/"([^"]*)"|(\S+)/g;let r;for(;(r=n.exec(e))!==null;)t.push(r[1]!==void 0?r[1]:r[2]);return t}function DR(e){if(!e)return"";try{const t=JSON.parse(e);if(Array.isArray(t))return t.map(n=>typeof n=="string"&&/\s/.test(n)?`"${n}"`:String(n)).join(" ")}catch{}return""}function fae({initial:e,onSubmit:t,onCancel:n}){const{t:r}=He(),[i,s]=k.useState((e==null?void 0:e.name)??""),[o,a]=k.useState((e==null?void 0:e.type)??"executable"),[l,d]=k.useState((e==null?void 0:e.target)??""),[h,f]=k.useState(DR((e==null?void 0:e.args)??null)),[p,g]=k.useState((e==null?void 0:e.cwd)??""),[S,_]=k.useState(!1);k.useEffect(()=>{s((e==null?void 0:e.name)??""),a((e==null?void 0:e.type)??"executable"),d((e==null?void 0:e.target)??""),f(DR((e==null?void 0:e.args)??null)),g((e==null?void 0:e.cwd)??"")},[e]);const v=!!e,x=i.trim(),w=l.trim(),b=o!=="url"||/^https?:\/\//i.test(w),C=!!x&&!!w&&b&&!S,N=async A=>{if(A.preventDefault(),!!C){_(!0);try{const T={name:x,type:o,target:w,args:o==="executable"&&h.trim()?dae(h.trim()):null,cwd:o!=="url"&&p.trim()?p.trim():null};await t(T)}finally{_(!1)}}},E=r(o==="executable"?"favorites.form.targetHint.executable":o==="command"?"favorites.form.targetHint.command":"favorites.form.targetHint.url");return c.jsx(zn,{open:!0,onClose:n,size:"md",children:c.jsxs("div",{className:"card p-8 shadow-2xl rounded-2xl",children:[c.jsx("h2",{className:"text-lg font-semibold text-warm-800 mb-6",children:r(v?"favorites.form.title.edit":"favorites.form.title.create")}),c.jsxs("form",{onSubmit:N,children:[c.jsxs("div",{className:"mb-5",children:[c.jsx("label",{className:"block text-sm font-medium text-warm-600 mb-2",children:r("favorites.form.type")}),c.jsx("div",{className:"grid grid-cols-3 gap-2",children:uae.map(({value:A,icon:T})=>c.jsxs("button",{type:"button",onClick:()=>a(A),className:"flex items-center justify-center gap-2 px-3 py-2 rounded-lg text-xs font-medium transition-all border",style:o===A?{backgroundColor:"var(--color-accent)",color:"white",borderColor:"var(--color-accent)"}:{color:"var(--color-text-tertiary)",borderColor:"var(--color-border)"},children:[c.jsx(T,{size:14}),r(`favorites.types.${A}`)]},A))})]}),c.jsxs("div",{className:"mb-5",children:[c.jsx("label",{className:"block text-sm font-medium text-warm-600 mb-2",children:r("favorites.form.name")}),c.jsx("input",{type:"text",value:i,onChange:A=>s(A.target.value),className:"input-field",autoFocus:!0})]}),c.jsxs("div",{className:"mb-5",children:[c.jsx("label",{className:"block text-sm font-medium text-warm-600 mb-2",children:r("favorites.form.target")}),c.jsx("input",{type:"text",value:l,onChange:A=>d(A.target.value),className:"input-field text-sm font-mono",placeholder:E}),c.jsx("p",{className:"mt-1 text-2xs",style:{color:"var(--color-text-muted)"},children:E})]}),o==="executable"&&c.jsxs("div",{className:"mb-5",children:[c.jsx("label",{className:"block text-sm font-medium text-warm-600 mb-2",children:r("favorites.form.args")}),c.jsx("input",{type:"text",value:h,onChange:A=>f(A.target.value),className:"input-field text-sm font-mono",placeholder:'--flag value "with spaces"'})]}),o!=="url"&&c.jsxs("div",{className:"mb-5",children:[c.jsx("label",{className:"block text-sm font-medium text-warm-600 mb-2",children:r("favorites.form.cwd")}),c.jsx("input",{type:"text",value:p,onChange:A=>g(A.target.value),className:"input-field text-sm font-mono",placeholder:"C:/Projects/my-project"})]}),c.jsx("p",{className:"mb-6 text-2xs leading-snug",style:{color:"var(--color-text-muted)"},children:r("favorites.security.notice")}),c.jsxs("div",{className:"flex justify-end gap-3",children:[c.jsx("button",{type:"button",onClick:n,className:"btn-ghost text-sm",children:r("favorites.form.cancel")}),c.jsx("button",{type:"submit",disabled:!C,className:"btn-primary text-sm",children:r(v?"favorites.form.save":"favorites.form.create")})]})]})]})})}const hae=/^([a-z0-9]([a-z0-9-]*[a-z0-9])?\.)+[a-z]{2,}$/i;function mae({onClose:e}){const{t}=He(),{error:n,success:r}=ah(),[i,s]=k.useState(""),[o,a]=k.useState(""),[l,d]=k.useState(""),[h,f]=k.useState(""),[p,g]=k.useState(!1),[S,_]=k.useState(!1),[v,x]=k.useState(!1),[w,b]=k.useState(null);k.useEffect(()=>{let I=!1;return Promise.all([nae(),y2()]).then(([H,$])=>{I||(s(H.tunnelName),a(H.customHostname),d(H.tunnelName),f(H.customHostname),b($))}).catch(()=>{}),()=>{I=!0}},[]);const C=i.trim(),N=o.trim(),E=C!==l.trim()||N!==h.trim(),A=!!N&&(!hae.test(N)||N.toLowerCase()==="localhost"||N.toLowerCase()==="127.0.0.1"),T=!!N&&!C,D=E&&!S&&!A&&!T,P=async()=>{if(D){_(!0);try{const I=await rae({tunnelName:C,customHostname:N});d(I.tunnelName),f(I.customHostname),s(I.tunnelName),a(I.customHostname),r(t("tunnel.saved"))}catch(I){n(I instanceof Error?I.message:t("tunnel.saveFailed"))}finally{_(!1)}}},O=async()=>{x(!0);try{try{await iae()}catch{}const I=await E9();b({status:"running",url:I.url}),r(t("tunnel.restarted"))}catch(I){n(I instanceof Error?I.message:t("tunnel.restartFailed"))}finally{x(!1)}};return c.jsxs("div",{className:"p-8",children:[c.jsx("h2",{className:"text-lg font-semibold text-warm-800 mb-1",children:t("tunnel.title")}),c.jsx("p",{className:"text-xs text-warm-400 mb-6",children:t("tunnel.description")}),w&&c.jsxs("div",{className:"mb-5 p-3 rounded-lg text-xs flex items-center gap-2",style:{backgroundColor:"var(--color-bg-hover)",color:"var(--color-text-tertiary)"},children:[c.jsx("span",{className:`w-2 h-2 rounded-full ${w.status==="running"?"bg-status-success":w.status==="error"?"bg-status-error":"bg-status-pending"}`}),c.jsx("span",{className:"font-medium",children:t(`tunnel.status.${w.status}`)}),w.url&&c.jsx("a",{href:w.url,target:"_blank",rel:"noreferrer",className:"ml-auto font-mono truncate hover:underline",style:{color:"var(--color-accent)"},children:w.url})]}),c.jsxs("div",{className:"mb-4",children:[c.jsx("label",{className:"block text-sm font-medium text-warm-600 mb-2",children:t("tunnel.name.label")}),c.jsx("input",{type:"text",value:i,onChange:I=>s(I.target.value),placeholder:t("tunnel.name.placeholder"),className:"input-field text-sm font-mono"}),c.jsx("p",{className:"mt-1 text-2xs",style:{color:"var(--color-text-muted)"},children:t("tunnel.name.hint")})]}),c.jsxs("div",{className:"mb-4",children:[c.jsx("label",{className:"block text-sm font-medium text-warm-600 mb-2",children:t("tunnel.hostname.label")}),c.jsx("input",{type:"text",value:o,onChange:I=>a(I.target.value),placeholder:t("tunnel.hostname.placeholder"),className:"input-field text-sm font-mono"}),c.jsx("p",{className:"mt-1 text-2xs",style:{color:"var(--color-text-muted)"},children:t("tunnel.hostname.hint")}),A&&c.jsx("p",{className:"mt-1 text-2xs text-status-error",children:t("tunnel.hostname.invalid")}),T&&c.jsx("p",{className:"mt-1 text-2xs text-status-error",children:t("tunnel.hostname.needsName")})]}),c.jsxs("div",{className:"mb-5",children:[c.jsxs("button",{type:"button",onClick:()=>g(!p),className:"flex items-center gap-1 text-xs text-accent-dark hover:text-accent transition-colors",children:[c.jsx("span",{className:`inline-block transition-transform ${p?"rotate-90":""}`,children:"▶"}),t("tunnel.guide.toggle")]}),p&&c.jsxs("div",{className:"mt-3 p-3 bg-warm-50 border border-warm-150 rounded-lg text-xs text-warm-600 space-y-2",children:[c.jsx("p",{className:"font-semibold text-warm-700 mb-1",children:t("tunnel.guide.heading")}),c.jsxs("ol",{className:"list-decimal list-inside space-y-1 ml-1",children:[c.jsx("li",{children:c.jsx("code",{className:"font-mono",children:"cloudflared tunnel login"})}),c.jsx("li",{children:c.jsx("code",{className:"font-mono",children:"cloudflared tunnel create my-app"})}),c.jsx("li",{children:c.jsx("code",{className:"font-mono",children:"cloudflared tunnel route dns my-app app.your-domain.com"})}),c.jsx("li",{children:t("tunnel.guide.step4")})]}),c.jsx("p",{className:"text-2xs text-warm-400 pt-1",children:t("tunnel.guide.note")})]})]}),c.jsxs("div",{className:"flex items-center justify-between gap-3",children:[c.jsx("button",{type:"button",onClick:O,disabled:v,className:"btn-ghost text-sm disabled:opacity-50",children:v?(w==null?void 0:w.status)==="running"?t("tunnel.restarting"):t("tunnel.starting"):(w==null?void 0:w.status)==="running"?t("tunnel.restart"):t("tunnel.start")}),c.jsxs("div",{className:"flex gap-3",children:[e&&c.jsx("button",{type:"button",onClick:e,className:"btn-ghost text-sm",children:t("tunnel.close")}),c.jsx("button",{type:"button",onClick:P,disabled:!D,className:"btn-primary text-sm",children:t(S?"tunnel.saving":"tunnel.save")})]})]})]})}const MR=8;function pae({onClose:e}){const{t}=He(),{error:n,success:r}=ah(),[i,s]=k.useState(""),[o,a]=k.useState(""),[l,d]=k.useState(""),[h,f]=k.useState(!1),p=o.length>0&&o.length<MR,g=l.length>0&&o!==l,S=!!i&&o.length>=MR&&o===l&&!h,_=()=>{s(""),a(""),d("")},v=async()=>{if(S){f(!0);try{await zne(i,o,l),r(t("account.saved")),_()}catch(x){n(x instanceof Error&&x.message?x.message:t("account.saveFailed"))}finally{f(!1)}}};return c.jsxs("div",{className:"p-8",children:[c.jsx("h2",{className:"text-lg font-semibold text-warm-800 mb-1",children:t("account.title")}),c.jsx("p",{className:"text-xs text-warm-400 mb-6",children:t("account.description")}),c.jsxs("div",{className:"mb-4",children:[c.jsx("label",{className:"block text-sm font-medium text-warm-600 mb-2",children:t("account.oldPassword")}),c.jsx("input",{type:"password",value:i,onChange:x=>s(x.target.value),className:"input-field text-sm",autoComplete:"current-password"})]}),c.jsxs("div",{className:"mb-4",children:[c.jsx("label",{className:"block text-sm font-medium text-warm-600 mb-2",children:t("account.newPassword")}),c.jsx("input",{type:"password",value:o,onChange:x=>a(x.target.value),className:"input-field text-sm",autoComplete:"new-password"}),p&&c.jsx("p",{className:"mt-1 text-2xs text-status-error",children:t("account.tooShort")})]}),c.jsxs("div",{className:"mb-6",children:[c.jsx("label",{className:"block text-sm font-medium text-warm-600 mb-2",children:t("account.confirm")}),c.jsx("input",{type:"password",value:l,onChange:x=>d(x.target.value),className:"input-field text-sm",autoComplete:"new-password"}),g&&c.jsx("p",{className:"mt-1 text-2xs text-status-error",children:t("account.mismatch")})]}),c.jsxs("div",{className:"flex items-center justify-end gap-3",children:[e&&c.jsx("button",{type:"button",onClick:e,className:"btn-ghost text-sm",children:t("account.close")}),c.jsx("button",{type:"button",onClick:v,disabled:!S,className:"btn-primary text-sm",children:t(h?"account.saving":"account.save")})]})]})}function fN(){return it("/api/session-tags")}function gae(e){return Fe("/api/session-tags",e)}function vae(e,t){return $n(`/api/session-tags/${e}`,t)}function xae(e){return wr(`/api/session-tags/${e}`)}function hN(){return it("/api/session-settings")}function OR(e){return $n("/api/session-settings",e)}const qe={titleBg:"#2d2d2d",titleText:"#999",bg:"#0c0c0c",text:"#cccccc",dim:"#666666",bright:"#f2f2f2",prompt:"#16c60c",error:"#f14c4c",warning:"#cca700",info:"#569cd6",separator:"#333333"},tn="'Cascadia Code', 'Cascadia Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Courier New', monospace",mN=13,ff=8,hf=28,jf=new Map,Gc=new Map;let fg=mN;function pN(e){return`sessionFontSize:${e}`}function b2(e){return Number.isFinite(e)?Math.max(ff,Math.min(hf,Math.round(e))):fg}function yae(e){if(jf.has(e))return!0;try{return localStorage.getItem(pN(e))!==null}catch{return!1}}function Gp(e){const t=jf.get(e);if(t!==void 0)return t;let n=null;try{const r=localStorage.getItem(pN(e));if(r!==null){const i=parseInt(r,10);Number.isFinite(i)&&(n=b2(i))}}catch{}return n===null?b2(fg):(jf.set(e,n),n)}function w2(e,t){const n=b2(t);if(jf.get(e)===n)return;jf.set(e,n);try{localStorage.setItem(pN(e),String(n))}catch{}const r=Gc.get(e);r&&r.forEach(i=>i(n))}function Sb(e,t){w2(e,Gp(e)+t)}function Kp(e){const t=Math.max(ff,Math.min(hf,Math.round(e)));Number.isFinite(t)&&t!==fg&&(fg=t,Gc.forEach((n,r)=>{yae(r)||n.forEach(i=>i(t))}))}function M9(e){const[t,n]=k.useState(()=>Gp(e));k.useEffect(()=>{n(Gp(e));let s=Gc.get(e);return s||(s=new Set,Gc.set(e,s)),s.add(n),()=>{const o=Gc.get(e);o&&(o.delete(n),o.size===0&&Gc.delete(e))}},[e]);const r=k.useCallback(s=>w2(e,s),[e]),i=k.useCallback(s=>w2(e,Gp(e)+s),[e]);return[t,r,i]}const mf=["#A78BFA","#F472B6","#FB923C","#FBBF24","#34D399","#60A5FA","#F87171","#94A3B8"];function RR(e){for(const t of mf)if(!e.some(n=>n.color.toLowerCase()===t.toLowerCase()))return t;return mf[e.length%mf.length]}function bae({onClose:e}){const{t}=He(),{error:n,success:r}=ah(),[i,s]=k.useState([]),[o,a]=k.useState(!1),[l,d]=k.useState(mN),[h,f]=k.useState(!1),[p,g]=k.useState(!1),S=k.useRef(null),[_,v]=k.useState(""),[x,w]=k.useState(mf[0]),[b,C]=k.useState(!1),[N,E]=k.useState(null),[A,T]=k.useState(""),[D,P]=k.useState(mf[0]),[O,I]=k.useState(!1);k.useEffect(()=>{let U=!1;return Promise.all([fN(),hN()]).then(([J,ee])=>{U||(s(J),a(ee.defaultUseWorktree),d(ee.defaultFontSize),Kp(ee.defaultFontSize),w(RR(J)),f(!0))}).catch(J=>{U||n(J instanceof Error?J.message:"Failed to load")}),()=>{U=!0}},[n]);const H=_.trim(),$=!!H&&!b,z=k.useMemo(()=>[...i].sort((U,J)=>U.sort_order-J.sort_order||U.name.localeCompare(J.name)),[i]);k.useEffect(()=>()=>{S.current&&clearTimeout(S.current)},[]);const K=U=>{if(!Number.isFinite(U))return;const J=Math.max(ff,Math.min(hf,Math.round(U)));d(J),Kp(J),S.current&&clearTimeout(S.current),S.current=setTimeout(()=>{OR({defaultFontSize:J}).then(ee=>{d(ee.defaultFontSize),Kp(ee.defaultFontSize)}).catch(ee=>n(ee instanceof Error?ee.message:"Save failed"))},350)},V=async U=>{g(!0);try{const J=await OR({defaultUseWorktree:U});a(J.defaultUseWorktree),r(t("sessionSettings.saved"))}catch(J){n(J instanceof Error?J.message:"Save failed")}finally{g(!1)}},W=async()=>{if($){C(!0);try{const U=await gae({name:H,color:x});s(J=>[...J,U]),v(""),w(RR([...i,U]))}catch(U){n(U instanceof Error?U.message:"Create failed")}finally{C(!1)}}},L=U=>{E(U.id),T(U.name),P(U.color)},B=()=>{E(null),T("")},F=async()=>{if(!N)return;const U=A.trim();if(U){I(!0);try{const J=await vae(N,{name:U,color:D});s(ee=>ee.map(ne=>ne.id===J.id?J:ne)),B()}catch(J){n(J instanceof Error?J.message:"Save failed")}finally{I(!1)}}},G=async U=>{if(confirm(t("sessionSettings.tags.deleteConfirm").replace("{name}",U.name)))try{await xae(U.id),s(J=>J.filter(ee=>ee.id!==U.id))}catch(J){n(J instanceof Error?J.message:"Delete failed")}};return c.jsxs("div",{className:"p-8",children:[c.jsx("h2",{className:"text-lg font-semibold text-warm-800 mb-1",children:t("sessionSettings.title")}),c.jsx("p",{className:"text-xs text-warm-400 mb-6",children:t("sessionSettings.description")}),c.jsxs("section",{className:"mb-7",children:[c.jsxs("h3",{className:"text-sm font-semibold text-warm-700 mb-2 flex items-center gap-1.5",children:[c.jsx(rh,{size:14}),t("sessionSettings.worktree.title")]}),c.jsxs("label",{className:"flex items-center gap-2 cursor-pointer select-none",children:[c.jsx("input",{type:"checkbox",checked:o,disabled:p||!h,onChange:U=>V(U.target.checked),className:"rounded border-warm-300"}),c.jsx("span",{className:"text-sm text-warm-600",children:t("sessionSettings.worktree.label")})]}),c.jsx("p",{className:"mt-1 text-2xs ml-6",style:{color:"var(--color-text-muted)"},children:t("sessionSettings.worktree.hint")})]}),c.jsxs("section",{className:"mb-7",children:[c.jsxs("h3",{className:"text-sm font-semibold text-warm-700 mb-2 flex items-center gap-1.5",children:[c.jsx(mse,{size:14}),t("sessionSettings.fontSize.title")]}),c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx("input",{type:"range",min:ff,max:hf,step:1,value:l,disabled:!h,onChange:U=>K(parseInt(U.target.value,10)),className:"flex-1 max-w-xs","aria-label":t("sessionSettings.fontSize.label")}),c.jsx("input",{type:"number",min:ff,max:hf,step:1,value:l,disabled:!h,onChange:U=>K(parseInt(U.target.value,10)),className:"input text-sm w-20"}),c.jsx("span",{className:"text-xs text-warm-400",children:"px"})]}),c.jsx("p",{className:"mt-1 text-2xs",style:{color:"var(--color-text-muted)"},children:t("sessionSettings.fontSize.hint")})]}),c.jsxs("section",{children:[c.jsx("h3",{className:"text-sm font-semibold text-warm-700 mb-2",children:t("sessionSettings.tags.title")}),c.jsx("p",{className:"text-xs text-warm-400 mb-3",children:t("sessionSettings.tags.description")}),c.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[c.jsx("input",{type:"color",value:x,onChange:U=>w(U.target.value),className:"w-9 h-9 rounded cursor-pointer border border-warm-200",title:t("sessionSettings.tags.color")}),c.jsx("input",{type:"text",value:_,onChange:U=>v(U.target.value),onKeyDown:U=>{U.key==="Enter"&&(U.preventDefault(),W())},placeholder:t("sessionSettings.tags.namePlaceholder"),className:"input text-sm flex-1",maxLength:32}),c.jsxs("button",{type:"button",onClick:W,disabled:!$,className:"btn-primary text-sm py-1.5 px-3 inline-flex items-center gap-1",children:[c.jsx(bo,{size:14}),t("sessionSettings.tags.add")]})]}),z.length===0?c.jsx("p",{className:"text-xs text-warm-400 italic py-3",children:t("sessionSettings.tags.empty")}):c.jsx("ul",{className:"space-y-1.5",children:z.map(U=>{const J=N===U.id;return c.jsx("li",{className:"flex items-center gap-2 px-3 py-2 rounded-lg border",style:{borderColor:"var(--color-border)"},children:J?c.jsxs(c.Fragment,{children:[c.jsx("input",{type:"color",value:D,onChange:ee=>P(ee.target.value),className:"w-7 h-7 rounded cursor-pointer border border-warm-200"}),c.jsx("input",{type:"text",value:A,onChange:ee=>T(ee.target.value),onKeyDown:ee=>{ee.key==="Enter"&&(ee.preventDefault(),F()),ee.key==="Escape"&&B()},autoFocus:!0,className:"input text-sm flex-1",maxLength:32}),c.jsx("button",{type:"button",onClick:F,disabled:O||!A.trim(),className:"p-1.5 text-status-success hover:bg-status-success/10 rounded",title:t("sessionSettings.tags.save"),children:c.jsx(Ev,{size:14})}),c.jsx("button",{type:"button",onClick:B,className:"p-1.5 text-warm-400 hover:bg-warm-100 rounded",title:t("sessionSettings.tags.cancel"),children:c.jsx(An,{size:14})})]}):c.jsxs(c.Fragment,{children:[c.jsx("span",{className:"w-4 h-4 rounded-full shrink-0 border",style:{backgroundColor:U.color,borderColor:"rgba(0,0,0,0.08)"}}),c.jsx("span",{className:"text-sm text-warm-700 flex-1 truncate",children:U.name}),c.jsx("button",{type:"button",onClick:()=>L(U),className:"p-1.5 text-warm-400 hover:text-warm-700 hover:bg-warm-100 rounded",title:t("sessionSettings.tags.edit"),children:c.jsx(_u,{size:14})}),c.jsx("button",{type:"button",onClick:()=>G(U),className:"p-1.5 text-warm-400 hover:text-status-error hover:bg-warm-100 rounded",title:t("sessionSettings.tags.delete"),children:c.jsx(ai,{size:14})})]})},U.id)})})]}),e&&c.jsx("div",{className:"flex justify-end gap-3 mt-7",children:c.jsx("button",{type:"button",onClick:e,className:"btn-ghost text-sm",children:t("tunnel.close")})})]})}function wae({open:e,onClose:t}){const{t:n}=He(),[r,i]=k.useState("account");if(!e)return null;const s=[{id:"account",label:n("settings.tabs.account"),icon:yie},{id:"session",label:n("settings.tabs.session"),icon:Mv},{id:"tunnel",label:n("settings.tabs.tunnel"),icon:o9}];return c.jsx(zn,{open:e,onClose:t,size:"xl",children:c.jsx("div",{className:"card shadow-2xl rounded-2xl overflow-hidden",children:c.jsxs("div",{className:"flex",style:{minHeight:460},children:[c.jsxs("aside",{className:"w-44 shrink-0 border-r flex flex-col",style:{borderColor:"var(--color-border)",backgroundColor:"var(--color-bg-hover)"},children:[c.jsx("div",{className:"px-4 pt-5 pb-3 text-xs font-semibold uppercase tracking-wider",style:{color:"var(--color-text-muted)"},children:n("settings.title")}),c.jsx("nav",{className:"flex flex-col",children:s.map(({id:o,label:a,icon:l})=>{const d=r===o;return c.jsxs("button",{type:"button",onClick:()=>i(o),className:"flex items-center gap-2 px-4 py-2.5 text-sm transition-colors text-left",style:{color:d?"var(--color-accent)":"var(--color-text-secondary)",backgroundColor:d?"var(--color-bg-primary)":"transparent",fontWeight:d?600:400},children:[c.jsx(l,{size:14}),c.jsx("span",{children:a})]},o)})}),c.jsxs("div",{className:"px-4 py-3 mt-auto text-[11px] tracking-wide",style:{color:"var(--color-text-muted)"},children:["v","0.2.6"]})]}),c.jsxs("div",{className:"flex-1 min-w-0",children:[r==="account"&&c.jsx(pae,{onClose:t}),r==="session"&&c.jsx(bae,{onClose:t}),r==="tunnel"&&c.jsx(mae,{onClose:t})]})]})})})}const _ae={success:i9,error:sN,warning:Av,info:vie},Sae={success:"text-status-success",error:"text-status-error",warning:"text-status-warning",info:"text-accent"},kae={success:"bg-status-success",error:"bg-status-error",warning:"bg-status-warning",info:"bg-accent"};function Cae({toast:e,onDismiss:t}){const[n,r]=k.useState(!1),i=_ae[e.type],s=e.duration??3500;return k.useEffect(()=>{const o=requestAnimationFrame(()=>r(!0));return()=>cancelAnimationFrame(o)},[]),c.jsxs("div",{className:oa("relative flex items-start gap-3 px-4 py-3 rounded-xl shadow-elevated overflow-hidden","bg-theme-card border border-theme-border min-w-[280px] max-w-sm","transition-all duration-300",n?"animate-slide-in-right opacity-100":"opacity-0 translate-x-8"),children:[c.jsx(i,{size:16,className:oa("mt-0.5 flex-shrink-0",Sae[e.type])}),c.jsx("p",{className:"text-xs text-theme-text flex-1 leading-snug",children:e.message}),c.jsx("button",{onClick:()=>t(e.id),className:"p-0.5 rounded text-theme-muted hover:text-theme-text transition-colors flex-shrink-0",children:c.jsx(An,{size:12})}),c.jsx("div",{className:oa("absolute bottom-0 left-0 h-0.5",kae[e.type]),style:{animation:`toastProgress ${s}ms linear forwards`}})]})}function O9({toasts:e,onDismiss:t}){return e.length===0?null:yr.createPortal(c.jsx("div",{className:"fixed bottom-6 right-6 z-toast flex flex-col gap-2 items-end",children:e.map(n=>c.jsx(Cae,{toast:n,onDismiss:t},n.id))}),document.body)}function jae(e){return e==="executable"?u9:e==="command"?cN:wl}function Eae({onLogout:e,authRequired:t,connected:n,onEvent:r,onClose:i}){var ye;const[s,o]=k.useState([]),[a,l]=k.useState({}),[d,h]=k.useState(null),[f,p]=k.useState(!1),[g,S]=k.useState([]),[_,v]=k.useState(!1),[x,w]=k.useState(null),[b,C]=k.useState(!1),[N,E]=k.useState(null),[A,T]=k.useState(!1),D=Ms(),P=th(),{t:O,toggleLang:I}=He(),{theme:H,toggleTheme:$}=A9(),{enabled:z,supported:K,toggleNotification:V}=dN(),{toasts:W,error:L,success:B,info:F,warning:G,dismiss:U}=ah(),J=((ye=D.pathname.match(/^\/projects\/([^/]+)/))==null?void 0:ye[1])||null;k.useEffect(()=>{te(),ne(),y2().then(E).catch(()=>{})},[]);async function ee(){if(!A){T(!0);try{const se=await y2();if(E(se),se.status==="running"&&se.url){await navigator.clipboard.writeText(se.url),B(O("tunnel.urlCopied"));return}const me=await E9(),Se={status:"running",url:me.url};E(Se);try{await navigator.clipboard.writeText(me.url),B(O("tunnel.urlCopied"))}catch{B(me.url)}}catch(se){L(se instanceof Error?se.message:O("tunnel.restartFailed"))}finally{T(!1)}}}function ne(){Zse().then(S).catch(()=>{})}const Y=async se=>{try{x?await Qse(x.id,se):await Jse(se),v(!1),w(null),ne()}catch(me){L(me instanceof Error?me.message:"Failed to save favorite")}},q=async se=>{try{await tae(se)}catch(me){const Se=me instanceof Error?me.message:O("favorites.launchFailed");L(`${O("favorites.launchFailed")}: ${Se}`)}},Z=async(se,me)=>{if(me.preventDefault(),me.stopPropagation(),!!confirm(O("favorites.deleteConfirm")))try{await eae(se),S(Se=>Se.filter(Ge=>Ge.id!==se))}catch(Se){L(Se instanceof Error?Se.message:"Failed to delete favorite")}},Q=(se,me)=>{me.preventDefault(),me.stopPropagation(),w(se),v(!0)};k.useEffect(()=>{const se=()=>te();return window.addEventListener("projects:changed",se),()=>window.removeEventListener("projects:changed",se)},[]),k.useEffect(()=>r(se=>{var me;if(se.type==="project:status-changed"&&se.projectId&&l(Se=>({...Se,[se.projectId]:{running:se.running??0,completed:se.completed??0,total:se.total??0}})),se.type==="todo:status-changed"&&ie(),se.type==="memory:ingest-finished"){const Se=s.find(be=>be.id===se.projectId),Ge=(Se==null?void 0:Se.name)??"",Ze=se.sourceTitle?`“${se.sourceTitle}”`:se.sourceType??"",Ee=Ge?`[${Ge}] `:"";if(se.error){L(`${Ee}${O("wiki.ingest.toast.failed")}: ${se.error}`,6e3);return}const le=se.created??0,Me=se.updated??0,he=se.edgesAdded??0;if(le+Me+he>0){const be=O("wiki.ingest.toast.success").replace("{source}",Ze).replace("{created}",String(le)).replace("{updated}",String(Me)).replace("{edges}",String(he));B(`${Ee}${be}`)}else(me=se.skipped)!=null&&me.parseFailed?G(`${Ee}${O("wiki.ingest.toast.parseFailed").replace("{source}",Ze)}`,5e3):F(`${Ee}${O("wiki.ingest.toast.empty").replace("{source}",Ze)}`,4e3)}}),[r,s,O,L,F,B,G]),k.useEffect(()=>{ie()},[]);function ie(){j9({hours:24}).then(se=>h(se.total_todos)).catch(()=>{})}function te(){g9().then(se=>{o(se),se.forEach(me=>{b9(me.id).then(Se=>{l(Ge=>({...Ge,[me.id]:Se}))}).catch(()=>{})})}).catch(()=>{})}const ae=()=>{i==null||i()},oe=async(se,me)=>{try{await v9({name:se,path:me}),p(!1),window.dispatchEvent(new Event("projects:changed"))}catch{}},de=async(se,me)=>{if(me.preventDefault(),me.stopPropagation(),!!confirm(O("projects.deleteConfirm")))try{await y9(se),o(Se=>Se.filter(Ge=>Ge.id!==se)),window.dispatchEvent(new Event("projects:changed")),J===String(se)&&P("/")}catch{}};return c.jsxs("div",{className:"flex flex-col h-full glass border-none",children:[c.jsx("div",{className:"px-4 pt-5 pb-3",children:c.jsx(Gi,{to:"/",onClick:ae,className:"block",children:c.jsxs("svg",{viewBox:"0 0 200 32",fill:"none",className:"h-6 w-auto",children:[c.jsxs("text",{x:"0",y:"24",fontFamily:"'JetBrains Mono', monospace",fontSize:"22",fontWeight:"500",fill:"var(--color-accent)",opacity:"0.5",children:[">","_"]}),c.jsx("text",{x:"38",y:"24",fontFamily:"'JetBrains Mono', monospace",fontSize:"22",fontWeight:"700",fill:"var(--color-accent)",children:"CLI"}),c.jsx("text",{x:"96",y:"24",fontFamily:"'JetBrains Mono', monospace",fontSize:"22",fontWeight:"500",fill:"var(--color-text-primary)",children:"Trigger"})]})})}),c.jsxs("nav",{className:"px-3 mb-2 space-y-0.5",children:[c.jsxs(Gi,{to:"/",onClick:ae,className:`relative flex items-center gap-3 px-3 py-2 rounded-lg text-sm transition-all duration-200 active:scale-95 ${D.pathname==="/"?"font-medium":""}`,style:D.pathname==="/"?{backgroundColor:"var(--color-bg-hover)",color:"var(--color-text-primary)",boxShadow:"var(--shadow-soft)"}:{color:"var(--color-text-tertiary)"},children:[D.pathname==="/"&&c.jsx("span",{className:"absolute left-0 top-1/4 bottom-1/4 w-[3px] rounded-r-full",style:{backgroundColor:"var(--color-accent)"}}),c.jsx(Sie,{size:16}),O("sidebar.home")]}),c.jsxs(Gi,{to:"/review",onClick:ae,className:`relative flex items-center gap-3 px-3 py-2 rounded-lg text-sm transition-all duration-200 active:scale-95 ${D.pathname==="/review"?"font-medium":""}`,style:D.pathname==="/review"?{backgroundColor:"var(--color-bg-hover)",color:"var(--color-text-primary)",boxShadow:"var(--shadow-soft)"}:{color:"var(--color-text-tertiary)"},children:[D.pathname==="/review"&&c.jsx("span",{className:"absolute left-0 top-1/4 bottom-1/4 w-[3px] rounded-r-full",style:{backgroundColor:"var(--color-accent)"}}),c.jsx(h2,{size:16}),c.jsx("span",{className:"flex-1",children:O("sidebar.review")}),d!==null&&d>0&&c.jsx("span",{className:"text-2xs px-1.5 py-0.5 rounded-full font-medium",style:{backgroundColor:"var(--color-accent)",color:"white"},children:d})]})]}),c.jsx("div",{className:"mx-4 border-t",style:{borderColor:"var(--color-border)"}}),c.jsxs("div",{className:"flex-1 overflow-y-auto px-3 pt-3",children:[c.jsxs("div",{className:"px-3 mb-2 flex items-center justify-between",children:[c.jsx("span",{className:"text-2xs font-semibold uppercase tracking-wider",style:{color:"var(--color-text-muted)"},children:O("sidebar.workspaces")}),c.jsx("button",{onClick:()=>p(!0),className:"flex items-center justify-center w-5 h-5 rounded-md transition-colors hover:bg-theme-hover",style:{color:"var(--color-text-tertiary)"},title:O("projects.new"),children:c.jsx(bo,{size:14,strokeWidth:2})})]}),c.jsx("div",{className:"space-y-0.5",children:s.map(se=>{const me=a[se.id],Se=J===String(se.id),Ge=me&&me.running>0;return c.jsxs(Gi,{to:`/projects/${se.id}`,onClick:ae,className:`relative flex items-center gap-2.5 px-3 py-1.5 rounded-lg text-sm transition-all duration-200 hover:bg-theme-hover active:scale-95 group ${Se?"font-medium":""}`,style:Se?{backgroundColor:"var(--color-bg-hover)",color:"var(--color-text-primary)",boxShadow:"var(--shadow-soft)"}:{color:"var(--color-text-tertiary)"},children:[Se&&c.jsx("span",{className:"absolute left-0 top-1/4 bottom-1/4 w-[3px] rounded-r-full",style:{backgroundColor:"var(--color-accent)"}}),c.jsx("span",{className:`w-2 h-2 rounded-full flex-shrink-0 ${Ge?"bg-status-running animate-pulse":""}`,style:Ge?void 0:{backgroundColor:Se?"var(--color-accent)":"var(--color-text-faint)"}}),c.jsx("span",{className:"truncate flex-1",children:se.name}),c.jsx("button",{onClick:Ze=>de(se.id,Ze),className:"flex-shrink-0 p-0.5 rounded opacity-0 group-hover:opacity-100 transition-all hover:bg-status-error/10",style:{color:"var(--color-text-muted)"},title:O("projects.delete"),children:c.jsx(An,{size:12,strokeWidth:2})})]},se.id)})})]}),f&&c.jsx(D9,{onSubmit:(se,me)=>oe(se,me),onCancel:()=>p(!1)}),c.jsxs("div",{className:"px-3 pt-3 pb-2 border-t",style:{borderColor:"var(--color-border)"},children:[c.jsxs("div",{className:"px-3 mb-2 flex items-center justify-between",children:[c.jsx("span",{className:"text-2xs font-semibold uppercase tracking-wider",style:{color:"var(--color-text-muted)"},children:O("sidebar.favorites")}),c.jsx("button",{onClick:()=>{w(null),v(!0)},className:"flex items-center justify-center w-5 h-5 rounded-md transition-colors hover:bg-theme-hover",style:{color:"var(--color-text-tertiary)"},title:O("favorites.add"),children:c.jsx(bo,{size:14,strokeWidth:2})})]}),c.jsx("div",{className:"space-y-0.5 max-h-48 overflow-y-auto",children:g.map(se=>{const me=jae(se.type);return c.jsxs("button",{onClick:()=>q(se.id),className:"w-full relative flex items-center gap-2.5 px-3 py-1.5 rounded-lg text-sm transition-all duration-200 hover:bg-theme-hover active:scale-95 group",style:{color:"var(--color-text-tertiary)"},title:se.target,children:[c.jsx(me,{size:14,className:"flex-shrink-0"}),c.jsx("span",{className:"truncate flex-1 text-left",children:se.name}),c.jsx("span",{onClick:Se=>Q(se,Se),className:"flex-shrink-0 p-0.5 rounded opacity-0 group-hover:opacity-100 transition-all hover:bg-theme-hover cursor-pointer",style:{color:"var(--color-text-muted)"},title:O("favorites.edit"),children:c.jsx(lN,{size:11,strokeWidth:2})}),c.jsx("span",{onClick:Se=>Z(se.id,Se),className:"flex-shrink-0 p-0.5 rounded opacity-0 group-hover:opacity-100 transition-all hover:bg-status-error/10 cursor-pointer",style:{color:"var(--color-text-muted)"},title:O("favorites.delete"),children:c.jsx(An,{size:12,strokeWidth:2})})]},se.id)})})]}),_&&c.jsx(fae,{initial:x??void 0,onSubmit:Y,onCancel:()=>{v(!1),w(null)}}),c.jsx(wae,{open:b,onClose:()=>C(!1)}),c.jsx(O9,{toasts:W,onDismiss:U}),c.jsx("div",{className:"px-3 pb-4 pt-2",style:{borderTop:"1px solid var(--color-border)"},children:c.jsxs("div",{className:"flex items-center gap-1 px-1",children:[c.jsx("span",{className:`w-1.5 h-1.5 rounded-full flex-shrink-0 mr-1 ${n?"bg-status-success":"bg-status-error"}`,title:n?O("detail.live"):"Disconnected"}),c.jsx("button",{onClick:$,className:"flex items-center justify-center w-8 h-8 rounded-lg transition-colors",style:{color:"var(--color-text-tertiary)"},title:O(H==="light"?"theme.dark":"theme.light"),children:H==="light"?c.jsx($ie,{size:16}):c.jsx(cse,{size:16})}),c.jsx("button",{onClick:I,className:"flex items-center justify-center w-8 h-8 rounded-lg transition-colors text-xs font-medium",style:{color:"var(--color-text-tertiary)"},children:O("lang.toggle")}),K&&c.jsx("button",{onClick:V,className:"flex items-center justify-center w-8 h-8 rounded-lg transition-colors",style:{color:z?"var(--color-accent)":"var(--color-text-tertiary)"},title:"Notification"in window&&Notification.permission==="denied"?O("notification.blocked"):O("notification.toggle"),children:z?c.jsx(dre,{size:16}):c.jsx(cre,{size:16})}),c.jsx("button",{onClick:ee,disabled:A,className:"flex items-center justify-center w-8 h-8 rounded-lg transition-colors disabled:opacity-50",style:{color:(N==null?void 0:N.status)==="running"?"var(--color-accent)":"var(--color-text-tertiary)"},title:(N==null?void 0:N.status)==="running"&&N.url?`${N.url} — ${O("tunnel.urlCopied")}`:O(A?"tunnel.starting":"tunnel.start"),children:c.jsx(o9,{size:16})}),c.jsx("button",{onClick:()=>C(!0),className:"flex items-center justify-center w-8 h-8 rounded-lg transition-colors",style:{color:"var(--color-text-tertiary)"},title:O("settings.title"),children:c.jsx(m9,{size:16})}),t&&c.jsx("button",{onClick:e,className:"flex items-center justify-center w-8 h-8 rounded-lg transition-colors ml-auto",style:{color:"var(--color-text-tertiary)"},title:O("projects.logout"),children:c.jsx(Die,{size:16})})]})})]})}const Nae=80,PR=120,na=180,LR=.03,IR=8;function Aae(){const e=k.useRef(null),t=k.useRef({x:-1e3,y:-1e3}),n=k.useRef([]),r=k.useRef(0);return k.useEffect(()=>{const i=e.current;if(!i)return;const s=i.getContext("2d");if(!s)return;let o=0,a=0;function l(){const g=i.parentElement;g&&(o=g.clientWidth,a=g.clientHeight,i.width=o*window.devicePixelRatio,i.height=a*window.devicePixelRatio,i.style.width=`${o}px`,i.style.height=`${a}px`,s.setTransform(window.devicePixelRatio,0,0,window.devicePixelRatio,0,0),d())}function d(){n.current=[];for(let g=0;g<Nae;g++){const S=Math.random()*o,_=Math.random()*a;n.current.push({x:S,y:_,baseX:S,baseY:_,vx:(Math.random()-.5)*.3,vy:(Math.random()-.5)*.3,size:Math.random()*1.5+.5,alpha:Math.random()*.4+.1})}}function h(g){const S=i.getBoundingClientRect();t.current.x=g.clientX-S.left,t.current.y=g.clientY-S.top}function f(){t.current.x=-1e3,t.current.y=-1e3}function p(){if(!s)return;s.clearRect(0,0,o,a);const g=n.current,S=t.current;for(const _ of g){const v=_.x-S.x,x=_.y-S.y,w=Math.sqrt(v*v+x*x);if(w<na&&w>0){const b=(na-w)/na,C=Math.atan2(x,v);_.vx+=Math.cos(C)*b*IR*.05,_.vy+=Math.sin(C)*b*IR*.05}_.vx+=(_.baseX-_.x)*LR,_.vy+=(_.baseY-_.y)*LR,_.baseX+=(Math.random()-.5)*.1,_.baseY+=(Math.random()-.5)*.1,_.baseX<0&&(_.baseX=0),_.baseX>o&&(_.baseX=o),_.baseY<0&&(_.baseY=0),_.baseY>a&&(_.baseY=a),_.vx*=.92,_.vy*=.92,_.x+=_.vx,_.y+=_.vy}for(let _=0;_<g.length;_++){for(let b=_+1;b<g.length;b++){const C=g[_].x-g[b].x,N=g[_].y-g[b].y,E=Math.sqrt(C*C+N*N);if(E<PR){const A=(1-E/PR)*.15;s.beginPath(),s.strokeStyle=`rgba(75, 141, 255, ${A})`,s.lineWidth=.5,s.moveTo(g[_].x,g[_].y),s.lineTo(g[b].x,g[b].y),s.stroke()}}const v=g[_].x-S.x,x=g[_].y-S.y,w=Math.sqrt(v*v+x*x);if(w<na){const b=(1-w/na)*.3;s.beginPath(),s.strokeStyle=`rgba(75, 141, 255, ${b})`,s.lineWidth=.8,s.moveTo(g[_].x,g[_].y),s.lineTo(S.x,S.y),s.stroke()}}for(const _ of g){const v=_.x-S.x,x=_.y-S.y,w=Math.sqrt(v*v+x*x),b=w<na?_.alpha+(1-w/na)*.5:_.alpha;s.beginPath(),s.arc(_.x,_.y,_.size,0,Math.PI*2),s.fillStyle=`rgba(75, 141, 255, ${b})`,s.fill(),w<na&&(s.beginPath(),s.arc(_.x,_.y,_.size*3,0,Math.PI*2),s.fillStyle=`rgba(75, 141, 255, ${(1-w/na)*.08})`,s.fill())}r.current=requestAnimationFrame(p)}return l(),i.addEventListener("mousemove",h),i.addEventListener("mouseleave",f),window.addEventListener("resize",l),r.current=requestAnimationFrame(p),()=>{cancelAnimationFrame(r.current),i.removeEventListener("mousemove",h),i.removeEventListener("mouseleave",f),window.removeEventListener("resize",l)}},[]),c.jsx("canvas",{ref:e,className:"absolute inset-0 pointer-events-auto",style:{zIndex:0}})}function Tae({children:e,onLogout:t,authRequired:n,connected:r,onEvent:i}){const[s,o]=k.useState(!1);return c.jsxs("div",{className:"flex h-screen bg-theme-bg",children:[c.jsx("aside",{className:`
566
+ */const kse=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]],Cse=Ue("zoom-out",kse);function jse({onLogin:e}){const[t,n]=k.useState(""),[r,i]=k.useState(""),[s,o]=k.useState(!1),{t:a,toggleLang:l}=He(),d=async h=>{if(h.preventDefault(),!!t){i(""),o(!0);try{await e(t)}catch{i(a("login.error"))}finally{o(!1)}}};return c.jsxs("div",{className:"min-h-screen bg-theme-bg flex items-center justify-center px-4 relative",children:[c.jsx("button",{onClick:l,className:"lang-toggle absolute top-6 right-6",children:a("lang.toggle")}),c.jsxs("div",{className:"w-full max-w-sm animate-fade-in",children:[c.jsxs("div",{className:"text-center mb-10",children:[c.jsx("div",{className:"inline-flex items-center justify-center w-16 h-16 rounded-2xl bg-accent/10 mb-5",children:c.jsx(Mv,{size:32,className:"text-accent",strokeWidth:1.5})}),c.jsx("h1",{className:"text-2xl font-semibold text-theme-text",children:a("login.title")}),c.jsx("p",{className:"text-theme-muted text-sm mt-2",children:a("login.subtitle")})]}),c.jsx("form",{onSubmit:d,children:c.jsxs("div",{className:"card p-8",children:[c.jsx("label",{className:"block text-sm font-medium text-theme-text-secondary mb-2",children:a("login.password")}),c.jsx("input",{type:"password",value:t,onChange:h=>n(h.target.value),placeholder:"*************",className:"input-field text-base",autoFocus:!0}),r&&c.jsx("div",{className:"mt-4 py-2.5 px-4 bg-status-error/5 border border-status-error/20 rounded-xl text-sm text-status-error",children:r}),c.jsx("button",{type:"submit",disabled:!t||s,className:"btn-primary w-full mt-6 py-3",children:a(s?"login.loading":"login.submit")})]})}),c.jsx("div",{className:"mt-6 text-center text-xs text-theme-text-tertiary",children:a("login.footer")}),c.jsx("div",{className:"mt-4 px-2 py-3 rounded-xl text-xs text-theme-text-tertiary border leading-relaxed text-center",children:a("login.disclaimer")})]})]})}const CR=8;function Ese({onSetup:e}){const[t,n]=k.useState(""),[r,i]=k.useState(""),[s,o]=k.useState(""),[a,l]=k.useState(!1),{t:d,toggleLang:h}=He(),f=t.length>0&&t.length<CR,p=r.length>0&&t!==r,g=t.length>=CR&&t===r&&!a,S=async _=>{if(_.preventDefault(),!!g){o(""),l(!0);try{await e(t,r)}catch(v){o(v instanceof Error&&v.message?v.message:d("setup.error"))}finally{l(!1)}}};return c.jsxs("div",{className:"min-h-screen bg-theme-bg flex items-center justify-center px-4 relative",children:[c.jsx("button",{onClick:h,className:"lang-toggle absolute top-6 right-6",children:d("lang.toggle")}),c.jsxs("div",{className:"w-full max-w-sm animate-fade-in",children:[c.jsxs("div",{className:"text-center mb-10",children:[c.jsx("div",{className:"inline-flex items-center justify-center w-16 h-16 rounded-2xl bg-accent/10 mb-5",children:c.jsx(Mv,{size:32,className:"text-accent",strokeWidth:1.5})}),c.jsx("h1",{className:"text-2xl font-semibold text-theme-text",children:d("setup.title")}),c.jsx("p",{className:"text-theme-muted text-sm mt-2",children:d("setup.subtitle")})]}),c.jsx("form",{onSubmit:S,children:c.jsxs("div",{className:"card p-8",children:[c.jsx("label",{className:"block text-sm font-medium text-theme-text-secondary mb-2",children:d("setup.password")}),c.jsx("input",{type:"password",value:t,onChange:_=>n(_.target.value),placeholder:"*************",className:"input-field text-base",autoFocus:!0}),f&&c.jsx("p",{className:"mt-1 text-2xs text-status-error",children:d("setup.tooShort")}),c.jsx("label",{className:"block text-sm font-medium text-theme-text-secondary mb-2 mt-5",children:d("setup.confirm")}),c.jsx("input",{type:"password",value:r,onChange:_=>i(_.target.value),placeholder:"*************",className:"input-field text-base"}),p&&c.jsx("p",{className:"mt-1 text-2xs text-status-error",children:d("setup.mismatch")}),s&&c.jsx("div",{className:"mt-4 py-2.5 px-4 bg-status-error/5 border border-status-error/20 rounded-xl text-sm text-status-error",children:s}),c.jsx("button",{type:"submit",disabled:!g,className:"btn-primary w-full mt-6 py-3",children:d(a?"setup.loading":"setup.submit")})]})}),c.jsx("div",{className:"mt-4 px-4 py-3 rounded-xl text-xs text-theme-text-tertiary border leading-relaxed text-center",children:d("setup.tunnelPaused")})]})]})}function Nse(e){return Fe("/api/projects/browse",{initialPath:e})}function Ase(e){return Fe("/api/projects/open-folder",{path:e})}function g9(){return it("/api/projects")}function Tse(e){return it(`/api/projects/${e}`)}function v9(e){return Fe("/api/projects",e)}function jR(e,t){return $n(`/api/projects/${e}`,t)}function x9(e,t){const n=t?`?todoId=${encodeURIComponent(t)}`:"";return it(`/api/projects/${e}/debug-logs${n}`)}function y9(e){return wr(`/api/projects/${e}`)}function Dse(e){return Fe(`/api/projects/${e}/start`)}function Mse(e){return Fe(`/api/projects/${e}/stop`)}function b9(e){return it(`/api/projects/${e}/status`)}function Ose(e){return Fe(`/api/projects/${e}/check-git`)}function Rse(e,t){return it(`/api/projects/${e}/git-status`)}function Pse(e,t=0,n=50,r){const i=new URLSearchParams({skip:String(t),limit:String(n)});return it(`/api/projects/${e}/git-log?${i}`)}function g2(e,t){return it(`/api/projects/${e}/git-refs`)}function Lse(e,t){return Fe(`/api/projects/${e}/git-stage`,{files:t})}function Ise(e,t){return Fe(`/api/projects/${e}/git-unstage`,{files:t})}function w9(e,t){return Fe(`/api/projects/${e}/git-commit`,{message:t})}function _9(e,t,n){return Fe(`/api/projects/${e}/git-pull`,{remote:t,branch:n})}function uN(e,t){return Fe(`/api/projects/${e}/git-push`,t||{})}function zse(e){return it(`/api/projects/${e}/git-remotes`)}function S9(e,t,n){return Fe(`/api/projects/${e}/git-fetch`,{remote:t,prune:n})}function Bse(e,t,n){return Fe(`/api/projects/${e}/git-branch`,{name:t,startPoint:n})}function v2(e,t,n){return Fe(`/api/projects/${e}/git-branch-delete`,{name:t,force:n})}function x2(e,t){return Fe(`/api/projects/${e}/git-checkout`,{branch:t})}function k9(e,t){return Fe(`/api/projects/${e}/git-merge`,{branch:t})}function $se(e,t){return Fe(`/api/projects/${e}/git-stash`,{message:t})}function Fse(e,t){return Fe(`/api/projects/${e}/git-stash-pop`,{index:t})}function Hse(e){return it(`/api/projects/${e}/git-stash-list`)}function qse(e,t,n){return Fe(`/api/projects/${e}/git-discard`,{files:t,all:n})}function Use(e,t,n,r){return Fe(`/api/projects/${e}/git-tag`,{name:t,message:n,commit:r})}function ER(e,t,n){return Fe(`/api/projects/${e}/git-branch-rename`,{oldName:t,newName:n})}function Wse(e,t){return Fe(`/api/projects/${e}/git-rebase`,{onto:t})}function Gse(e,t,n){const r=new URLSearchParams;return t&&r.set("file",t),n&&r.set("staged","true"),it(`/api/projects/${e}/git-diff?${r}`)}function Kse(e,t){const n=new URLSearchParams({hash:t});return it(`/api/projects/${e}/git-commit-files?${n}`)}function NR(e,t,n){const r=new URLSearchParams({hash:t});return n&&r.set("file",n),it(`/api/projects/${e}/git-commit-diff?${r}`)}function AR(e){return it(`/api/projects/${e}/worktrees`)}function TR(e,t,n){return Fe(`/api/projects/${e}/worktree-cleanup`,{worktreePath:t,branchName:n})}function C9(e){const t=new URLSearchParams;e.hours!==void 0&&t.set("hours",String(e.hours)),e.statuses&&e.statuses.length>0&&t.set("statuses",e.statuses.join(","));const n=t.toString();return n?`?${n}`:""}function Vse(e={}){return it(`/api/review/queue${C9(e)}`)}function j9(e={}){return it(`/api/review/summary${C9(e)}`)}function Yse(e){return it(`/api/review/diff/${encodeURIComponent(e)}`)}function Xse(e,t){return it(`/api/review/diff/${encodeURIComponent(e)}/file?path=${encodeURIComponent(t)}`)}function Zse(){return it("/api/favorites")}function Jse(e){return Fe("/api/favorites",e)}function Qse(e,t){return $n(`/api/favorites/${e}`,t)}function eae(e){return wr(`/api/favorites/${e}`)}function tae(e){return Fe(`/api/favorites/${e}/launch`)}function y2(){return it("/api/tunnel/status")}function nae(){return it("/api/tunnel/config")}function rae(e){return $n("/api/tunnel/config",e)}function E9(e){return Fe("/api/tunnel/start",{})}function iae(){return Fe("/api/tunnel/stop")}const N9=k.createContext({theme:"light",toggleTheme:()=>{}});function sae(){const[e,t]=k.useState(()=>{const r=localStorage.getItem("theme");return r==="light"||r==="dark"?r:window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"});k.useEffect(()=>{document.documentElement.setAttribute("data-theme",e),localStorage.setItem("theme",e)},[e]);const n=k.useCallback(()=>{t(r=>r==="light"?"dark":"light")},[]);return{theme:e,toggleTheme:n}}function A9(){return k.useContext(N9)}const T9=k.createContext({enabled:!1,supported:!1,toggleNotification:()=>{},sendNotification:()=>{}});function aae(){const e="Notification"in window,[t,n]=k.useState(()=>e?localStorage.getItem("clitrigger-notifications")==="on"&&Notification.permission==="granted":!1),r=k.useRef(t);k.useEffect(()=>{r.current=t},[t]);const i=k.useCallback(async()=>{if(e)if(r.current)localStorage.setItem("clitrigger-notifications","off"),n(!1);else{if(Notification.permission==="denied"||Notification.permission==="default"&&await Notification.requestPermission()!=="granted")return;localStorage.setItem("clitrigger-notifications","on"),n(!0)}},[e]),s=k.useCallback((o,a)=>{if(!r.current)return;const l=new Notification(o,{body:a});l.onclick=()=>{window.focus(),l.close()}},[]);return{enabled:t,supported:e,toggleNotification:i,sendNotification:s}}function dN(){return k.useContext(T9)}let oae=0;function ah(){const[e,t]=k.useState([]),n=k.useRef(new Map),r=k.useCallback(d=>{t(f=>f.filter(p=>p.id!==d));const h=n.current.get(d);h&&(clearTimeout(h),n.current.delete(d))},[]),i=k.useCallback((d,h="info",f=3500)=>{const p=`toast-${++oae}`;t(S=>[...S,{id:p,message:d,type:h,duration:f}]);const g=setTimeout(()=>r(p),f);return n.current.set(p,g),p},[r]),s=k.useCallback((d,h)=>i(d,"success",h),[i]),o=k.useCallback((d,h)=>i(d,"error",h),[i]),a=k.useCallback((d,h)=>i(d,"info",h),[i]),l=k.useCallback((d,h)=>i(d,"warning",h),[i]);return{toasts:e,show:i,success:s,error:o,info:a,warning:l,dismiss:r}}function oa(...e){return e.filter(Boolean).join(" ")}const lae={sm:"max-w-sm",md:"max-w-md",lg:"max-w-lg",xl:"max-w-xl","2xl":"max-w-2xl"},cae={scale:"animate-scale-in","slide-up":"animate-slide-up"};function zn({open:e,onClose:t,size:n="md",position:r="center",animation:i="scale",disableEscClose:s=!1,disableBackdropClose:o=!1,children:a}){const l=k.useRef(null);return k.useEffect(()=>{if(!e||s)return;const d=h=>{h.key==="Escape"&&t()};return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[e,s,t]),e?yr.createPortal(c.jsx("div",{ref:l,className:oa("fixed inset-0 bg-black/50 backdrop-blur-sm z-modal flex",r==="center"?"items-center justify-center p-4":"items-start justify-center px-4 pt-[20vh]"),onClick:d=>{!o&&d.target===l.current&&t()},children:c.jsx("div",{className:oa("w-full",lae[n],cae[i]),children:a})}),document.body):null}function D9({onSubmit:e,onCancel:t}){const[n,r]=k.useState(""),[i,s]=k.useState(""),[o,a]=k.useState(!1),{t:l}=He(),d=f=>{f.preventDefault(),!(!n.trim()||!i.trim())&&e(n.trim(),i.trim())},h=async()=>{a(!0);try{const f=await Nse(i||void 0);f.path&&s(f.path)}catch{}a(!1)};return c.jsx(zn,{open:!0,onClose:t,size:"md",children:c.jsxs("div",{className:"card p-8 shadow-2xl rounded-2xl",children:[c.jsx("h2",{className:"text-lg font-semibold text-warm-800 mb-6",children:l("form.newProject")}),c.jsxs("form",{onSubmit:d,children:[c.jsxs("div",{className:"mb-5",children:[c.jsx("label",{className:"block text-sm font-medium text-warm-600 mb-2",children:l("form.projectName")}),c.jsx("input",{type:"text",placeholder:"my-project",value:n,onChange:f=>r(f.target.value),className:"input-field",autoFocus:!0})]}),c.jsxs("div",{className:"mb-8",children:[c.jsx("label",{className:"block text-sm font-medium text-warm-600 mb-2",children:l("form.folderPath")}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx("input",{type:"text",placeholder:"C:/Projects/my-project",value:i,onChange:f=>s(f.target.value),className:"input-field text-sm flex-1"}),c.jsx("button",{type:"button",onClick:h,disabled:o,className:"btn-ghost text-sm px-3 shrink-0",title:l("browse.title"),children:o?c.jsx(kn,{size:16,className:"animate-spin"}):c.jsx(Tv,{size:16})})]})]}),c.jsxs("div",{className:"flex justify-end gap-3",children:[c.jsx("button",{type:"button",onClick:t,className:"btn-ghost text-sm",children:l("form.cancel")}),c.jsx("button",{type:"submit",disabled:!n.trim()||!i.trim(),className:"btn-primary text-sm",children:l("form.create")})]})]})]})})}const uae=[{value:"executable",icon:u9},{value:"command",icon:cN},{value:"url",icon:wl}];function dae(e){const t=[],n=/"([^"]*)"|(\S+)/g;let r;for(;(r=n.exec(e))!==null;)t.push(r[1]!==void 0?r[1]:r[2]);return t}function DR(e){if(!e)return"";try{const t=JSON.parse(e);if(Array.isArray(t))return t.map(n=>typeof n=="string"&&/\s/.test(n)?`"${n}"`:String(n)).join(" ")}catch{}return""}function fae({initial:e,onSubmit:t,onCancel:n}){const{t:r}=He(),[i,s]=k.useState((e==null?void 0:e.name)??""),[o,a]=k.useState((e==null?void 0:e.type)??"executable"),[l,d]=k.useState((e==null?void 0:e.target)??""),[h,f]=k.useState(DR((e==null?void 0:e.args)??null)),[p,g]=k.useState((e==null?void 0:e.cwd)??""),[S,_]=k.useState(!1);k.useEffect(()=>{s((e==null?void 0:e.name)??""),a((e==null?void 0:e.type)??"executable"),d((e==null?void 0:e.target)??""),f(DR((e==null?void 0:e.args)??null)),g((e==null?void 0:e.cwd)??"")},[e]);const v=!!e,x=i.trim(),w=l.trim(),b=o!=="url"||/^https?:\/\//i.test(w),C=!!x&&!!w&&b&&!S,N=async A=>{if(A.preventDefault(),!!C){_(!0);try{const T={name:x,type:o,target:w,args:o==="executable"&&h.trim()?dae(h.trim()):null,cwd:o!=="url"&&p.trim()?p.trim():null};await t(T)}finally{_(!1)}}},E=r(o==="executable"?"favorites.form.targetHint.executable":o==="command"?"favorites.form.targetHint.command":"favorites.form.targetHint.url");return c.jsx(zn,{open:!0,onClose:n,size:"md",children:c.jsxs("div",{className:"card p-8 shadow-2xl rounded-2xl",children:[c.jsx("h2",{className:"text-lg font-semibold text-warm-800 mb-6",children:r(v?"favorites.form.title.edit":"favorites.form.title.create")}),c.jsxs("form",{onSubmit:N,children:[c.jsxs("div",{className:"mb-5",children:[c.jsx("label",{className:"block text-sm font-medium text-warm-600 mb-2",children:r("favorites.form.type")}),c.jsx("div",{className:"grid grid-cols-3 gap-2",children:uae.map(({value:A,icon:T})=>c.jsxs("button",{type:"button",onClick:()=>a(A),className:"flex items-center justify-center gap-2 px-3 py-2 rounded-lg text-xs font-medium transition-all border",style:o===A?{backgroundColor:"var(--color-accent)",color:"white",borderColor:"var(--color-accent)"}:{color:"var(--color-text-tertiary)",borderColor:"var(--color-border)"},children:[c.jsx(T,{size:14}),r(`favorites.types.${A}`)]},A))})]}),c.jsxs("div",{className:"mb-5",children:[c.jsx("label",{className:"block text-sm font-medium text-warm-600 mb-2",children:r("favorites.form.name")}),c.jsx("input",{type:"text",value:i,onChange:A=>s(A.target.value),className:"input-field",autoFocus:!0})]}),c.jsxs("div",{className:"mb-5",children:[c.jsx("label",{className:"block text-sm font-medium text-warm-600 mb-2",children:r("favorites.form.target")}),c.jsx("input",{type:"text",value:l,onChange:A=>d(A.target.value),className:"input-field text-sm font-mono",placeholder:E}),c.jsx("p",{className:"mt-1 text-2xs",style:{color:"var(--color-text-muted)"},children:E})]}),o==="executable"&&c.jsxs("div",{className:"mb-5",children:[c.jsx("label",{className:"block text-sm font-medium text-warm-600 mb-2",children:r("favorites.form.args")}),c.jsx("input",{type:"text",value:h,onChange:A=>f(A.target.value),className:"input-field text-sm font-mono",placeholder:'--flag value "with spaces"'})]}),o!=="url"&&c.jsxs("div",{className:"mb-5",children:[c.jsx("label",{className:"block text-sm font-medium text-warm-600 mb-2",children:r("favorites.form.cwd")}),c.jsx("input",{type:"text",value:p,onChange:A=>g(A.target.value),className:"input-field text-sm font-mono",placeholder:"C:/Projects/my-project"})]}),c.jsx("p",{className:"mb-6 text-2xs leading-snug",style:{color:"var(--color-text-muted)"},children:r("favorites.security.notice")}),c.jsxs("div",{className:"flex justify-end gap-3",children:[c.jsx("button",{type:"button",onClick:n,className:"btn-ghost text-sm",children:r("favorites.form.cancel")}),c.jsx("button",{type:"submit",disabled:!C,className:"btn-primary text-sm",children:r(v?"favorites.form.save":"favorites.form.create")})]})]})]})})}const hae=/^([a-z0-9]([a-z0-9-]*[a-z0-9])?\.)+[a-z]{2,}$/i;function mae({onClose:e}){const{t}=He(),{error:n,success:r}=ah(),[i,s]=k.useState(""),[o,a]=k.useState(""),[l,d]=k.useState(""),[h,f]=k.useState(""),[p,g]=k.useState(!1),[S,_]=k.useState(!1),[v,x]=k.useState(!1),[w,b]=k.useState(null);k.useEffect(()=>{let I=!1;return Promise.all([nae(),y2()]).then(([H,$])=>{I||(s(H.tunnelName),a(H.customHostname),d(H.tunnelName),f(H.customHostname),b($))}).catch(()=>{}),()=>{I=!0}},[]);const C=i.trim(),N=o.trim(),E=C!==l.trim()||N!==h.trim(),A=!!N&&(!hae.test(N)||N.toLowerCase()==="localhost"||N.toLowerCase()==="127.0.0.1"),T=!!N&&!C,D=E&&!S&&!A&&!T,P=async()=>{if(D){_(!0);try{const I=await rae({tunnelName:C,customHostname:N});d(I.tunnelName),f(I.customHostname),s(I.tunnelName),a(I.customHostname),r(t("tunnel.saved"))}catch(I){n(I instanceof Error?I.message:t("tunnel.saveFailed"))}finally{_(!1)}}},O=async()=>{x(!0);try{try{await iae()}catch{}const I=await E9();b({status:"running",url:I.url}),r(t("tunnel.restarted"))}catch(I){n(I instanceof Error?I.message:t("tunnel.restartFailed"))}finally{x(!1)}};return c.jsxs("div",{className:"p-8",children:[c.jsx("h2",{className:"text-lg font-semibold text-warm-800 mb-1",children:t("tunnel.title")}),c.jsx("p",{className:"text-xs text-warm-400 mb-6",children:t("tunnel.description")}),w&&c.jsxs("div",{className:"mb-5 p-3 rounded-lg text-xs flex items-center gap-2",style:{backgroundColor:"var(--color-bg-hover)",color:"var(--color-text-tertiary)"},children:[c.jsx("span",{className:`w-2 h-2 rounded-full ${w.status==="running"?"bg-status-success":w.status==="error"?"bg-status-error":"bg-status-pending"}`}),c.jsx("span",{className:"font-medium",children:t(`tunnel.status.${w.status}`)}),w.url&&c.jsx("a",{href:w.url,target:"_blank",rel:"noreferrer",className:"ml-auto font-mono truncate hover:underline",style:{color:"var(--color-accent)"},children:w.url})]}),c.jsxs("div",{className:"mb-4",children:[c.jsx("label",{className:"block text-sm font-medium text-warm-600 mb-2",children:t("tunnel.name.label")}),c.jsx("input",{type:"text",value:i,onChange:I=>s(I.target.value),placeholder:t("tunnel.name.placeholder"),className:"input-field text-sm font-mono"}),c.jsx("p",{className:"mt-1 text-2xs",style:{color:"var(--color-text-muted)"},children:t("tunnel.name.hint")})]}),c.jsxs("div",{className:"mb-4",children:[c.jsx("label",{className:"block text-sm font-medium text-warm-600 mb-2",children:t("tunnel.hostname.label")}),c.jsx("input",{type:"text",value:o,onChange:I=>a(I.target.value),placeholder:t("tunnel.hostname.placeholder"),className:"input-field text-sm font-mono"}),c.jsx("p",{className:"mt-1 text-2xs",style:{color:"var(--color-text-muted)"},children:t("tunnel.hostname.hint")}),A&&c.jsx("p",{className:"mt-1 text-2xs text-status-error",children:t("tunnel.hostname.invalid")}),T&&c.jsx("p",{className:"mt-1 text-2xs text-status-error",children:t("tunnel.hostname.needsName")})]}),c.jsxs("div",{className:"mb-5",children:[c.jsxs("button",{type:"button",onClick:()=>g(!p),className:"flex items-center gap-1 text-xs text-accent-dark hover:text-accent transition-colors",children:[c.jsx("span",{className:`inline-block transition-transform ${p?"rotate-90":""}`,children:"▶"}),t("tunnel.guide.toggle")]}),p&&c.jsxs("div",{className:"mt-3 p-3 bg-warm-50 border border-warm-150 rounded-lg text-xs text-warm-600 space-y-2",children:[c.jsx("p",{className:"font-semibold text-warm-700 mb-1",children:t("tunnel.guide.heading")}),c.jsxs("ol",{className:"list-decimal list-inside space-y-1 ml-1",children:[c.jsx("li",{children:c.jsx("code",{className:"font-mono",children:"cloudflared tunnel login"})}),c.jsx("li",{children:c.jsx("code",{className:"font-mono",children:"cloudflared tunnel create my-app"})}),c.jsx("li",{children:c.jsx("code",{className:"font-mono",children:"cloudflared tunnel route dns my-app app.your-domain.com"})}),c.jsx("li",{children:t("tunnel.guide.step4")})]}),c.jsx("p",{className:"text-2xs text-warm-400 pt-1",children:t("tunnel.guide.note")})]})]}),c.jsxs("div",{className:"flex items-center justify-between gap-3",children:[c.jsx("button",{type:"button",onClick:O,disabled:v,className:"btn-ghost text-sm disabled:opacity-50",children:v?(w==null?void 0:w.status)==="running"?t("tunnel.restarting"):t("tunnel.starting"):(w==null?void 0:w.status)==="running"?t("tunnel.restart"):t("tunnel.start")}),c.jsxs("div",{className:"flex gap-3",children:[e&&c.jsx("button",{type:"button",onClick:e,className:"btn-ghost text-sm",children:t("tunnel.close")}),c.jsx("button",{type:"button",onClick:P,disabled:!D,className:"btn-primary text-sm",children:t(S?"tunnel.saving":"tunnel.save")})]})]})]})}const MR=8;function pae({onClose:e}){const{t}=He(),{error:n,success:r}=ah(),[i,s]=k.useState(""),[o,a]=k.useState(""),[l,d]=k.useState(""),[h,f]=k.useState(!1),p=o.length>0&&o.length<MR,g=l.length>0&&o!==l,S=!!i&&o.length>=MR&&o===l&&!h,_=()=>{s(""),a(""),d("")},v=async()=>{if(S){f(!0);try{await zne(i,o,l),r(t("account.saved")),_()}catch(x){n(x instanceof Error&&x.message?x.message:t("account.saveFailed"))}finally{f(!1)}}};return c.jsxs("div",{className:"p-8",children:[c.jsx("h2",{className:"text-lg font-semibold text-warm-800 mb-1",children:t("account.title")}),c.jsx("p",{className:"text-xs text-warm-400 mb-6",children:t("account.description")}),c.jsxs("div",{className:"mb-4",children:[c.jsx("label",{className:"block text-sm font-medium text-warm-600 mb-2",children:t("account.oldPassword")}),c.jsx("input",{type:"password",value:i,onChange:x=>s(x.target.value),className:"input-field text-sm",autoComplete:"current-password"})]}),c.jsxs("div",{className:"mb-4",children:[c.jsx("label",{className:"block text-sm font-medium text-warm-600 mb-2",children:t("account.newPassword")}),c.jsx("input",{type:"password",value:o,onChange:x=>a(x.target.value),className:"input-field text-sm",autoComplete:"new-password"}),p&&c.jsx("p",{className:"mt-1 text-2xs text-status-error",children:t("account.tooShort")})]}),c.jsxs("div",{className:"mb-6",children:[c.jsx("label",{className:"block text-sm font-medium text-warm-600 mb-2",children:t("account.confirm")}),c.jsx("input",{type:"password",value:l,onChange:x=>d(x.target.value),className:"input-field text-sm",autoComplete:"new-password"}),g&&c.jsx("p",{className:"mt-1 text-2xs text-status-error",children:t("account.mismatch")})]}),c.jsxs("div",{className:"flex items-center justify-end gap-3",children:[e&&c.jsx("button",{type:"button",onClick:e,className:"btn-ghost text-sm",children:t("account.close")}),c.jsx("button",{type:"button",onClick:v,disabled:!S,className:"btn-primary text-sm",children:t(h?"account.saving":"account.save")})]})]})}function fN(){return it("/api/session-tags")}function gae(e){return Fe("/api/session-tags",e)}function vae(e,t){return $n(`/api/session-tags/${e}`,t)}function xae(e){return wr(`/api/session-tags/${e}`)}function hN(){return it("/api/session-settings")}function OR(e){return $n("/api/session-settings",e)}const qe={titleBg:"#2d2d2d",titleText:"#999",bg:"#0c0c0c",text:"#cccccc",dim:"#666666",bright:"#f2f2f2",prompt:"#16c60c",error:"#f14c4c",warning:"#cca700",info:"#569cd6",separator:"#333333"},tn="'Cascadia Code', 'Cascadia Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Courier New', monospace",mN=13,ff=8,hf=28,jf=new Map,Gc=new Map;let fg=mN;function pN(e){return`sessionFontSize:${e}`}function b2(e){return Number.isFinite(e)?Math.max(ff,Math.min(hf,Math.round(e))):fg}function yae(e){if(jf.has(e))return!0;try{return localStorage.getItem(pN(e))!==null}catch{return!1}}function Gp(e){const t=jf.get(e);if(t!==void 0)return t;let n=null;try{const r=localStorage.getItem(pN(e));if(r!==null){const i=parseInt(r,10);Number.isFinite(i)&&(n=b2(i))}}catch{}return n===null?b2(fg):(jf.set(e,n),n)}function w2(e,t){const n=b2(t);if(jf.get(e)===n)return;jf.set(e,n);try{localStorage.setItem(pN(e),String(n))}catch{}const r=Gc.get(e);r&&r.forEach(i=>i(n))}function Sb(e,t){w2(e,Gp(e)+t)}function Kp(e){const t=Math.max(ff,Math.min(hf,Math.round(e)));Number.isFinite(t)&&t!==fg&&(fg=t,Gc.forEach((n,r)=>{yae(r)||n.forEach(i=>i(t))}))}function M9(e){const[t,n]=k.useState(()=>Gp(e));k.useEffect(()=>{n(Gp(e));let s=Gc.get(e);return s||(s=new Set,Gc.set(e,s)),s.add(n),()=>{const o=Gc.get(e);o&&(o.delete(n),o.size===0&&Gc.delete(e))}},[e]);const r=k.useCallback(s=>w2(e,s),[e]),i=k.useCallback(s=>w2(e,Gp(e)+s),[e]);return[t,r,i]}const mf=["#A78BFA","#F472B6","#FB923C","#FBBF24","#34D399","#60A5FA","#F87171","#94A3B8"];function RR(e){for(const t of mf)if(!e.some(n=>n.color.toLowerCase()===t.toLowerCase()))return t;return mf[e.length%mf.length]}function bae({onClose:e}){const{t}=He(),{error:n,success:r}=ah(),[i,s]=k.useState([]),[o,a]=k.useState(!1),[l,d]=k.useState(mN),[h,f]=k.useState(!1),[p,g]=k.useState(!1),S=k.useRef(null),[_,v]=k.useState(""),[x,w]=k.useState(mf[0]),[b,C]=k.useState(!1),[N,E]=k.useState(null),[A,T]=k.useState(""),[D,P]=k.useState(mf[0]),[O,I]=k.useState(!1);k.useEffect(()=>{let U=!1;return Promise.all([fN(),hN()]).then(([J,ee])=>{U||(s(J),a(ee.defaultUseWorktree),d(ee.defaultFontSize),Kp(ee.defaultFontSize),w(RR(J)),f(!0))}).catch(J=>{U||n(J instanceof Error?J.message:"Failed to load")}),()=>{U=!0}},[n]);const H=_.trim(),$=!!H&&!b,z=k.useMemo(()=>[...i].sort((U,J)=>U.sort_order-J.sort_order||U.name.localeCompare(J.name)),[i]);k.useEffect(()=>()=>{S.current&&clearTimeout(S.current)},[]);const K=U=>{if(!Number.isFinite(U))return;const J=Math.max(ff,Math.min(hf,Math.round(U)));d(J),Kp(J),S.current&&clearTimeout(S.current),S.current=setTimeout(()=>{OR({defaultFontSize:J}).then(ee=>{d(ee.defaultFontSize),Kp(ee.defaultFontSize)}).catch(ee=>n(ee instanceof Error?ee.message:"Save failed"))},350)},V=async U=>{g(!0);try{const J=await OR({defaultUseWorktree:U});a(J.defaultUseWorktree),r(t("sessionSettings.saved"))}catch(J){n(J instanceof Error?J.message:"Save failed")}finally{g(!1)}},W=async()=>{if($){C(!0);try{const U=await gae({name:H,color:x});s(J=>[...J,U]),v(""),w(RR([...i,U]))}catch(U){n(U instanceof Error?U.message:"Create failed")}finally{C(!1)}}},L=U=>{E(U.id),T(U.name),P(U.color)},B=()=>{E(null),T("")},F=async()=>{if(!N)return;const U=A.trim();if(U){I(!0);try{const J=await vae(N,{name:U,color:D});s(ee=>ee.map(ne=>ne.id===J.id?J:ne)),B()}catch(J){n(J instanceof Error?J.message:"Save failed")}finally{I(!1)}}},G=async U=>{if(confirm(t("sessionSettings.tags.deleteConfirm").replace("{name}",U.name)))try{await xae(U.id),s(J=>J.filter(ee=>ee.id!==U.id))}catch(J){n(J instanceof Error?J.message:"Delete failed")}};return c.jsxs("div",{className:"p-8",children:[c.jsx("h2",{className:"text-lg font-semibold text-warm-800 mb-1",children:t("sessionSettings.title")}),c.jsx("p",{className:"text-xs text-warm-400 mb-6",children:t("sessionSettings.description")}),c.jsxs("section",{className:"mb-7",children:[c.jsxs("h3",{className:"text-sm font-semibold text-warm-700 mb-2 flex items-center gap-1.5",children:[c.jsx(rh,{size:14}),t("sessionSettings.worktree.title")]}),c.jsxs("label",{className:"flex items-center gap-2 cursor-pointer select-none",children:[c.jsx("input",{type:"checkbox",checked:o,disabled:p||!h,onChange:U=>V(U.target.checked),className:"rounded border-warm-300"}),c.jsx("span",{className:"text-sm text-warm-600",children:t("sessionSettings.worktree.label")})]}),c.jsx("p",{className:"mt-1 text-2xs ml-6",style:{color:"var(--color-text-muted)"},children:t("sessionSettings.worktree.hint")})]}),c.jsxs("section",{className:"mb-7",children:[c.jsxs("h3",{className:"text-sm font-semibold text-warm-700 mb-2 flex items-center gap-1.5",children:[c.jsx(mse,{size:14}),t("sessionSettings.fontSize.title")]}),c.jsxs("div",{className:"flex items-center gap-3",children:[c.jsx("input",{type:"range",min:ff,max:hf,step:1,value:l,disabled:!h,onChange:U=>K(parseInt(U.target.value,10)),className:"flex-1 max-w-xs","aria-label":t("sessionSettings.fontSize.label")}),c.jsx("input",{type:"number",min:ff,max:hf,step:1,value:l,disabled:!h,onChange:U=>K(parseInt(U.target.value,10)),className:"input text-sm w-20"}),c.jsx("span",{className:"text-xs text-warm-400",children:"px"})]}),c.jsx("p",{className:"mt-1 text-2xs",style:{color:"var(--color-text-muted)"},children:t("sessionSettings.fontSize.hint")})]}),c.jsxs("section",{children:[c.jsx("h3",{className:"text-sm font-semibold text-warm-700 mb-2",children:t("sessionSettings.tags.title")}),c.jsx("p",{className:"text-xs text-warm-400 mb-3",children:t("sessionSettings.tags.description")}),c.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[c.jsx("input",{type:"color",value:x,onChange:U=>w(U.target.value),className:"w-9 h-9 rounded cursor-pointer border border-warm-200",title:t("sessionSettings.tags.color")}),c.jsx("input",{type:"text",value:_,onChange:U=>v(U.target.value),onKeyDown:U=>{U.key==="Enter"&&(U.preventDefault(),W())},placeholder:t("sessionSettings.tags.namePlaceholder"),className:"input text-sm flex-1",maxLength:32}),c.jsxs("button",{type:"button",onClick:W,disabled:!$,className:"btn-primary text-sm py-1.5 px-3 inline-flex items-center gap-1",children:[c.jsx(bo,{size:14}),t("sessionSettings.tags.add")]})]}),z.length===0?c.jsx("p",{className:"text-xs text-warm-400 italic py-3",children:t("sessionSettings.tags.empty")}):c.jsx("ul",{className:"space-y-1.5",children:z.map(U=>{const J=N===U.id;return c.jsx("li",{className:"flex items-center gap-2 px-3 py-2 rounded-lg border",style:{borderColor:"var(--color-border)"},children:J?c.jsxs(c.Fragment,{children:[c.jsx("input",{type:"color",value:D,onChange:ee=>P(ee.target.value),className:"w-7 h-7 rounded cursor-pointer border border-warm-200"}),c.jsx("input",{type:"text",value:A,onChange:ee=>T(ee.target.value),onKeyDown:ee=>{ee.key==="Enter"&&(ee.preventDefault(),F()),ee.key==="Escape"&&B()},autoFocus:!0,className:"input text-sm flex-1",maxLength:32}),c.jsx("button",{type:"button",onClick:F,disabled:O||!A.trim(),className:"p-1.5 text-status-success hover:bg-status-success/10 rounded",title:t("sessionSettings.tags.save"),children:c.jsx(Ev,{size:14})}),c.jsx("button",{type:"button",onClick:B,className:"p-1.5 text-warm-400 hover:bg-warm-100 rounded",title:t("sessionSettings.tags.cancel"),children:c.jsx(An,{size:14})})]}):c.jsxs(c.Fragment,{children:[c.jsx("span",{className:"w-4 h-4 rounded-full shrink-0 border",style:{backgroundColor:U.color,borderColor:"rgba(0,0,0,0.08)"}}),c.jsx("span",{className:"text-sm text-warm-700 flex-1 truncate",children:U.name}),c.jsx("button",{type:"button",onClick:()=>L(U),className:"p-1.5 text-warm-400 hover:text-warm-700 hover:bg-warm-100 rounded",title:t("sessionSettings.tags.edit"),children:c.jsx(_u,{size:14})}),c.jsx("button",{type:"button",onClick:()=>G(U),className:"p-1.5 text-warm-400 hover:text-status-error hover:bg-warm-100 rounded",title:t("sessionSettings.tags.delete"),children:c.jsx(ai,{size:14})})]})},U.id)})})]}),e&&c.jsx("div",{className:"flex justify-end gap-3 mt-7",children:c.jsx("button",{type:"button",onClick:e,className:"btn-ghost text-sm",children:t("tunnel.close")})})]})}function wae({open:e,onClose:t}){const{t:n}=He(),[r,i]=k.useState("account");if(!e)return null;const s=[{id:"account",label:n("settings.tabs.account"),icon:yie},{id:"session",label:n("settings.tabs.session"),icon:Mv},{id:"tunnel",label:n("settings.tabs.tunnel"),icon:o9}];return c.jsx(zn,{open:e,onClose:t,size:"xl",children:c.jsx("div",{className:"card shadow-2xl rounded-2xl overflow-hidden",children:c.jsxs("div",{className:"flex",style:{minHeight:460},children:[c.jsxs("aside",{className:"w-44 shrink-0 border-r flex flex-col",style:{borderColor:"var(--color-border)",backgroundColor:"var(--color-bg-hover)"},children:[c.jsx("div",{className:"px-4 pt-5 pb-3 text-xs font-semibold uppercase tracking-wider",style:{color:"var(--color-text-muted)"},children:n("settings.title")}),c.jsx("nav",{className:"flex flex-col",children:s.map(({id:o,label:a,icon:l})=>{const d=r===o;return c.jsxs("button",{type:"button",onClick:()=>i(o),className:"flex items-center gap-2 px-4 py-2.5 text-sm transition-colors text-left",style:{color:d?"var(--color-accent)":"var(--color-text-secondary)",backgroundColor:d?"var(--color-bg-primary)":"transparent",fontWeight:d?600:400},children:[c.jsx(l,{size:14}),c.jsx("span",{children:a})]},o)})}),c.jsxs("div",{className:"px-4 py-3 mt-auto text-[11px] tracking-wide",style:{color:"var(--color-text-muted)"},children:["v","0.2.7"]})]}),c.jsxs("div",{className:"flex-1 min-w-0",children:[r==="account"&&c.jsx(pae,{onClose:t}),r==="session"&&c.jsx(bae,{onClose:t}),r==="tunnel"&&c.jsx(mae,{onClose:t})]})]})})})}const _ae={success:i9,error:sN,warning:Av,info:vie},Sae={success:"text-status-success",error:"text-status-error",warning:"text-status-warning",info:"text-accent"},kae={success:"bg-status-success",error:"bg-status-error",warning:"bg-status-warning",info:"bg-accent"};function Cae({toast:e,onDismiss:t}){const[n,r]=k.useState(!1),i=_ae[e.type],s=e.duration??3500;return k.useEffect(()=>{const o=requestAnimationFrame(()=>r(!0));return()=>cancelAnimationFrame(o)},[]),c.jsxs("div",{className:oa("relative flex items-start gap-3 px-4 py-3 rounded-xl shadow-elevated overflow-hidden","bg-theme-card border border-theme-border min-w-[280px] max-w-sm","transition-all duration-300",n?"animate-slide-in-right opacity-100":"opacity-0 translate-x-8"),children:[c.jsx(i,{size:16,className:oa("mt-0.5 flex-shrink-0",Sae[e.type])}),c.jsx("p",{className:"text-xs text-theme-text flex-1 leading-snug",children:e.message}),c.jsx("button",{onClick:()=>t(e.id),className:"p-0.5 rounded text-theme-muted hover:text-theme-text transition-colors flex-shrink-0",children:c.jsx(An,{size:12})}),c.jsx("div",{className:oa("absolute bottom-0 left-0 h-0.5",kae[e.type]),style:{animation:`toastProgress ${s}ms linear forwards`}})]})}function O9({toasts:e,onDismiss:t}){return e.length===0?null:yr.createPortal(c.jsx("div",{className:"fixed bottom-6 right-6 z-toast flex flex-col gap-2 items-end",children:e.map(n=>c.jsx(Cae,{toast:n,onDismiss:t},n.id))}),document.body)}function jae(e){return e==="executable"?u9:e==="command"?cN:wl}function Eae({onLogout:e,authRequired:t,connected:n,onEvent:r,onClose:i}){var ye;const[s,o]=k.useState([]),[a,l]=k.useState({}),[d,h]=k.useState(null),[f,p]=k.useState(!1),[g,S]=k.useState([]),[_,v]=k.useState(!1),[x,w]=k.useState(null),[b,C]=k.useState(!1),[N,E]=k.useState(null),[A,T]=k.useState(!1),D=Ms(),P=th(),{t:O,toggleLang:I}=He(),{theme:H,toggleTheme:$}=A9(),{enabled:z,supported:K,toggleNotification:V}=dN(),{toasts:W,error:L,success:B,info:F,warning:G,dismiss:U}=ah(),J=((ye=D.pathname.match(/^\/projects\/([^/]+)/))==null?void 0:ye[1])||null;k.useEffect(()=>{te(),ne(),y2().then(E).catch(()=>{})},[]);async function ee(){if(!A){T(!0);try{const se=await y2();if(E(se),se.status==="running"&&se.url){await navigator.clipboard.writeText(se.url),B(O("tunnel.urlCopied"));return}const me=await E9(),Se={status:"running",url:me.url};E(Se);try{await navigator.clipboard.writeText(me.url),B(O("tunnel.urlCopied"))}catch{B(me.url)}}catch(se){L(se instanceof Error?se.message:O("tunnel.restartFailed"))}finally{T(!1)}}}function ne(){Zse().then(S).catch(()=>{})}const Y=async se=>{try{x?await Qse(x.id,se):await Jse(se),v(!1),w(null),ne()}catch(me){L(me instanceof Error?me.message:"Failed to save favorite")}},q=async se=>{try{await tae(se)}catch(me){const Se=me instanceof Error?me.message:O("favorites.launchFailed");L(`${O("favorites.launchFailed")}: ${Se}`)}},Z=async(se,me)=>{if(me.preventDefault(),me.stopPropagation(),!!confirm(O("favorites.deleteConfirm")))try{await eae(se),S(Se=>Se.filter(Ge=>Ge.id!==se))}catch(Se){L(Se instanceof Error?Se.message:"Failed to delete favorite")}},Q=(se,me)=>{me.preventDefault(),me.stopPropagation(),w(se),v(!0)};k.useEffect(()=>{const se=()=>te();return window.addEventListener("projects:changed",se),()=>window.removeEventListener("projects:changed",se)},[]),k.useEffect(()=>r(se=>{var me;if(se.type==="project:status-changed"&&se.projectId&&l(Se=>({...Se,[se.projectId]:{running:se.running??0,completed:se.completed??0,total:se.total??0}})),se.type==="todo:status-changed"&&ie(),se.type==="memory:ingest-finished"){const Se=s.find(be=>be.id===se.projectId),Ge=(Se==null?void 0:Se.name)??"",Ze=se.sourceTitle?`“${se.sourceTitle}”`:se.sourceType??"",Ee=Ge?`[${Ge}] `:"";if(se.error){L(`${Ee}${O("wiki.ingest.toast.failed")}: ${se.error}`,6e3);return}const le=se.created??0,Me=se.updated??0,he=se.edgesAdded??0;if(le+Me+he>0){const be=O("wiki.ingest.toast.success").replace("{source}",Ze).replace("{created}",String(le)).replace("{updated}",String(Me)).replace("{edges}",String(he));B(`${Ee}${be}`)}else(me=se.skipped)!=null&&me.parseFailed?G(`${Ee}${O("wiki.ingest.toast.parseFailed").replace("{source}",Ze)}`,5e3):F(`${Ee}${O("wiki.ingest.toast.empty").replace("{source}",Ze)}`,4e3)}}),[r,s,O,L,F,B,G]),k.useEffect(()=>{ie()},[]);function ie(){j9({hours:24}).then(se=>h(se.total_todos)).catch(()=>{})}function te(){g9().then(se=>{o(se),se.forEach(me=>{b9(me.id).then(Se=>{l(Ge=>({...Ge,[me.id]:Se}))}).catch(()=>{})})}).catch(()=>{})}const ae=()=>{i==null||i()},oe=async(se,me)=>{try{await v9({name:se,path:me}),p(!1),window.dispatchEvent(new Event("projects:changed"))}catch{}},de=async(se,me)=>{if(me.preventDefault(),me.stopPropagation(),!!confirm(O("projects.deleteConfirm")))try{await y9(se),o(Se=>Se.filter(Ge=>Ge.id!==se)),window.dispatchEvent(new Event("projects:changed")),J===String(se)&&P("/")}catch{}};return c.jsxs("div",{className:"flex flex-col h-full glass border-none",children:[c.jsx("div",{className:"px-4 pt-5 pb-3",children:c.jsx(Gi,{to:"/",onClick:ae,className:"block",children:c.jsxs("svg",{viewBox:"0 0 200 32",fill:"none",className:"h-6 w-auto",children:[c.jsxs("text",{x:"0",y:"24",fontFamily:"'JetBrains Mono', monospace",fontSize:"22",fontWeight:"500",fill:"var(--color-accent)",opacity:"0.5",children:[">","_"]}),c.jsx("text",{x:"38",y:"24",fontFamily:"'JetBrains Mono', monospace",fontSize:"22",fontWeight:"700",fill:"var(--color-accent)",children:"CLI"}),c.jsx("text",{x:"96",y:"24",fontFamily:"'JetBrains Mono', monospace",fontSize:"22",fontWeight:"500",fill:"var(--color-text-primary)",children:"Trigger"})]})})}),c.jsxs("nav",{className:"px-3 mb-2 space-y-0.5",children:[c.jsxs(Gi,{to:"/",onClick:ae,className:`relative flex items-center gap-3 px-3 py-2 rounded-lg text-sm transition-all duration-200 active:scale-95 ${D.pathname==="/"?"font-medium":""}`,style:D.pathname==="/"?{backgroundColor:"var(--color-bg-hover)",color:"var(--color-text-primary)",boxShadow:"var(--shadow-soft)"}:{color:"var(--color-text-tertiary)"},children:[D.pathname==="/"&&c.jsx("span",{className:"absolute left-0 top-1/4 bottom-1/4 w-[3px] rounded-r-full",style:{backgroundColor:"var(--color-accent)"}}),c.jsx(Sie,{size:16}),O("sidebar.home")]}),c.jsxs(Gi,{to:"/review",onClick:ae,className:`relative flex items-center gap-3 px-3 py-2 rounded-lg text-sm transition-all duration-200 active:scale-95 ${D.pathname==="/review"?"font-medium":""}`,style:D.pathname==="/review"?{backgroundColor:"var(--color-bg-hover)",color:"var(--color-text-primary)",boxShadow:"var(--shadow-soft)"}:{color:"var(--color-text-tertiary)"},children:[D.pathname==="/review"&&c.jsx("span",{className:"absolute left-0 top-1/4 bottom-1/4 w-[3px] rounded-r-full",style:{backgroundColor:"var(--color-accent)"}}),c.jsx(h2,{size:16}),c.jsx("span",{className:"flex-1",children:O("sidebar.review")}),d!==null&&d>0&&c.jsx("span",{className:"text-2xs px-1.5 py-0.5 rounded-full font-medium",style:{backgroundColor:"var(--color-accent)",color:"white"},children:d})]})]}),c.jsx("div",{className:"mx-4 border-t",style:{borderColor:"var(--color-border)"}}),c.jsxs("div",{className:"flex-1 overflow-y-auto px-3 pt-3",children:[c.jsxs("div",{className:"px-3 mb-2 flex items-center justify-between",children:[c.jsx("span",{className:"text-2xs font-semibold uppercase tracking-wider",style:{color:"var(--color-text-muted)"},children:O("sidebar.workspaces")}),c.jsx("button",{onClick:()=>p(!0),className:"flex items-center justify-center w-5 h-5 rounded-md transition-colors hover:bg-theme-hover",style:{color:"var(--color-text-tertiary)"},title:O("projects.new"),children:c.jsx(bo,{size:14,strokeWidth:2})})]}),c.jsx("div",{className:"space-y-0.5",children:s.map(se=>{const me=a[se.id],Se=J===String(se.id),Ge=me&&me.running>0;return c.jsxs(Gi,{to:`/projects/${se.id}`,onClick:ae,className:`relative flex items-center gap-2.5 px-3 py-1.5 rounded-lg text-sm transition-all duration-200 hover:bg-theme-hover active:scale-95 group ${Se?"font-medium":""}`,style:Se?{backgroundColor:"var(--color-bg-hover)",color:"var(--color-text-primary)",boxShadow:"var(--shadow-soft)"}:{color:"var(--color-text-tertiary)"},children:[Se&&c.jsx("span",{className:"absolute left-0 top-1/4 bottom-1/4 w-[3px] rounded-r-full",style:{backgroundColor:"var(--color-accent)"}}),c.jsx("span",{className:`w-2 h-2 rounded-full flex-shrink-0 ${Ge?"bg-status-running animate-pulse":""}`,style:Ge?void 0:{backgroundColor:Se?"var(--color-accent)":"var(--color-text-faint)"}}),c.jsx("span",{className:"truncate flex-1",children:se.name}),c.jsx("button",{onClick:Ze=>de(se.id,Ze),className:"flex-shrink-0 p-0.5 rounded opacity-0 group-hover:opacity-100 transition-all hover:bg-status-error/10",style:{color:"var(--color-text-muted)"},title:O("projects.delete"),children:c.jsx(An,{size:12,strokeWidth:2})})]},se.id)})})]}),f&&c.jsx(D9,{onSubmit:(se,me)=>oe(se,me),onCancel:()=>p(!1)}),c.jsxs("div",{className:"px-3 pt-3 pb-2 border-t",style:{borderColor:"var(--color-border)"},children:[c.jsxs("div",{className:"px-3 mb-2 flex items-center justify-between",children:[c.jsx("span",{className:"text-2xs font-semibold uppercase tracking-wider",style:{color:"var(--color-text-muted)"},children:O("sidebar.favorites")}),c.jsx("button",{onClick:()=>{w(null),v(!0)},className:"flex items-center justify-center w-5 h-5 rounded-md transition-colors hover:bg-theme-hover",style:{color:"var(--color-text-tertiary)"},title:O("favorites.add"),children:c.jsx(bo,{size:14,strokeWidth:2})})]}),c.jsx("div",{className:"space-y-0.5 max-h-48 overflow-y-auto",children:g.map(se=>{const me=jae(se.type);return c.jsxs("button",{onClick:()=>q(se.id),className:"w-full relative flex items-center gap-2.5 px-3 py-1.5 rounded-lg text-sm transition-all duration-200 hover:bg-theme-hover active:scale-95 group",style:{color:"var(--color-text-tertiary)"},title:se.target,children:[c.jsx(me,{size:14,className:"flex-shrink-0"}),c.jsx("span",{className:"truncate flex-1 text-left",children:se.name}),c.jsx("span",{onClick:Se=>Q(se,Se),className:"flex-shrink-0 p-0.5 rounded opacity-0 group-hover:opacity-100 transition-all hover:bg-theme-hover cursor-pointer",style:{color:"var(--color-text-muted)"},title:O("favorites.edit"),children:c.jsx(lN,{size:11,strokeWidth:2})}),c.jsx("span",{onClick:Se=>Z(se.id,Se),className:"flex-shrink-0 p-0.5 rounded opacity-0 group-hover:opacity-100 transition-all hover:bg-status-error/10 cursor-pointer",style:{color:"var(--color-text-muted)"},title:O("favorites.delete"),children:c.jsx(An,{size:12,strokeWidth:2})})]},se.id)})})]}),_&&c.jsx(fae,{initial:x??void 0,onSubmit:Y,onCancel:()=>{v(!1),w(null)}}),c.jsx(wae,{open:b,onClose:()=>C(!1)}),c.jsx(O9,{toasts:W,onDismiss:U}),c.jsx("div",{className:"px-3 pb-4 pt-2",style:{borderTop:"1px solid var(--color-border)"},children:c.jsxs("div",{className:"flex items-center gap-1 px-1",children:[c.jsx("span",{className:`w-1.5 h-1.5 rounded-full flex-shrink-0 mr-1 ${n?"bg-status-success":"bg-status-error"}`,title:n?O("detail.live"):"Disconnected"}),c.jsx("button",{onClick:$,className:"flex items-center justify-center w-8 h-8 rounded-lg transition-colors",style:{color:"var(--color-text-tertiary)"},title:O(H==="light"?"theme.dark":"theme.light"),children:H==="light"?c.jsx($ie,{size:16}):c.jsx(cse,{size:16})}),c.jsx("button",{onClick:I,className:"flex items-center justify-center w-8 h-8 rounded-lg transition-colors text-xs font-medium",style:{color:"var(--color-text-tertiary)"},children:O("lang.toggle")}),K&&c.jsx("button",{onClick:V,className:"flex items-center justify-center w-8 h-8 rounded-lg transition-colors",style:{color:z?"var(--color-accent)":"var(--color-text-tertiary)"},title:"Notification"in window&&Notification.permission==="denied"?O("notification.blocked"):O("notification.toggle"),children:z?c.jsx(dre,{size:16}):c.jsx(cre,{size:16})}),c.jsx("button",{onClick:ee,disabled:A,className:"flex items-center justify-center w-8 h-8 rounded-lg transition-colors disabled:opacity-50",style:{color:(N==null?void 0:N.status)==="running"?"var(--color-accent)":"var(--color-text-tertiary)"},title:(N==null?void 0:N.status)==="running"&&N.url?`${N.url} — ${O("tunnel.urlCopied")}`:O(A?"tunnel.starting":"tunnel.start"),children:c.jsx(o9,{size:16})}),c.jsx("button",{onClick:()=>C(!0),className:"flex items-center justify-center w-8 h-8 rounded-lg transition-colors",style:{color:"var(--color-text-tertiary)"},title:O("settings.title"),children:c.jsx(m9,{size:16})}),t&&c.jsx("button",{onClick:e,className:"flex items-center justify-center w-8 h-8 rounded-lg transition-colors ml-auto",style:{color:"var(--color-text-tertiary)"},title:O("projects.logout"),children:c.jsx(Die,{size:16})})]})})]})}const Nae=80,PR=120,na=180,LR=.03,IR=8;function Aae(){const e=k.useRef(null),t=k.useRef({x:-1e3,y:-1e3}),n=k.useRef([]),r=k.useRef(0);return k.useEffect(()=>{const i=e.current;if(!i)return;const s=i.getContext("2d");if(!s)return;let o=0,a=0;function l(){const g=i.parentElement;g&&(o=g.clientWidth,a=g.clientHeight,i.width=o*window.devicePixelRatio,i.height=a*window.devicePixelRatio,i.style.width=`${o}px`,i.style.height=`${a}px`,s.setTransform(window.devicePixelRatio,0,0,window.devicePixelRatio,0,0),d())}function d(){n.current=[];for(let g=0;g<Nae;g++){const S=Math.random()*o,_=Math.random()*a;n.current.push({x:S,y:_,baseX:S,baseY:_,vx:(Math.random()-.5)*.3,vy:(Math.random()-.5)*.3,size:Math.random()*1.5+.5,alpha:Math.random()*.4+.1})}}function h(g){const S=i.getBoundingClientRect();t.current.x=g.clientX-S.left,t.current.y=g.clientY-S.top}function f(){t.current.x=-1e3,t.current.y=-1e3}function p(){if(!s)return;s.clearRect(0,0,o,a);const g=n.current,S=t.current;for(const _ of g){const v=_.x-S.x,x=_.y-S.y,w=Math.sqrt(v*v+x*x);if(w<na&&w>0){const b=(na-w)/na,C=Math.atan2(x,v);_.vx+=Math.cos(C)*b*IR*.05,_.vy+=Math.sin(C)*b*IR*.05}_.vx+=(_.baseX-_.x)*LR,_.vy+=(_.baseY-_.y)*LR,_.baseX+=(Math.random()-.5)*.1,_.baseY+=(Math.random()-.5)*.1,_.baseX<0&&(_.baseX=0),_.baseX>o&&(_.baseX=o),_.baseY<0&&(_.baseY=0),_.baseY>a&&(_.baseY=a),_.vx*=.92,_.vy*=.92,_.x+=_.vx,_.y+=_.vy}for(let _=0;_<g.length;_++){for(let b=_+1;b<g.length;b++){const C=g[_].x-g[b].x,N=g[_].y-g[b].y,E=Math.sqrt(C*C+N*N);if(E<PR){const A=(1-E/PR)*.15;s.beginPath(),s.strokeStyle=`rgba(75, 141, 255, ${A})`,s.lineWidth=.5,s.moveTo(g[_].x,g[_].y),s.lineTo(g[b].x,g[b].y),s.stroke()}}const v=g[_].x-S.x,x=g[_].y-S.y,w=Math.sqrt(v*v+x*x);if(w<na){const b=(1-w/na)*.3;s.beginPath(),s.strokeStyle=`rgba(75, 141, 255, ${b})`,s.lineWidth=.8,s.moveTo(g[_].x,g[_].y),s.lineTo(S.x,S.y),s.stroke()}}for(const _ of g){const v=_.x-S.x,x=_.y-S.y,w=Math.sqrt(v*v+x*x),b=w<na?_.alpha+(1-w/na)*.5:_.alpha;s.beginPath(),s.arc(_.x,_.y,_.size,0,Math.PI*2),s.fillStyle=`rgba(75, 141, 255, ${b})`,s.fill(),w<na&&(s.beginPath(),s.arc(_.x,_.y,_.size*3,0,Math.PI*2),s.fillStyle=`rgba(75, 141, 255, ${(1-w/na)*.08})`,s.fill())}r.current=requestAnimationFrame(p)}return l(),i.addEventListener("mousemove",h),i.addEventListener("mouseleave",f),window.addEventListener("resize",l),r.current=requestAnimationFrame(p),()=>{cancelAnimationFrame(r.current),i.removeEventListener("mousemove",h),i.removeEventListener("mouseleave",f),window.removeEventListener("resize",l)}},[]),c.jsx("canvas",{ref:e,className:"absolute inset-0 pointer-events-auto",style:{zIndex:0}})}function Tae({children:e,onLogout:t,authRequired:n,connected:r,onEvent:i}){const[s,o]=k.useState(!1);return c.jsxs("div",{className:"flex h-screen bg-theme-bg",children:[c.jsx("aside",{className:`
567
567
  fixed inset-y-0 left-0 z-40 w-60 flex-shrink-0
568
568
  transform transition-transform duration-200 ease-in-out
569
569
  md:translate-x-0 md:static md:z-auto
@@ -16,7 +16,7 @@
16
16
  </script>
17
17
  <link rel="preconnect" href="https://fonts.googleapis.com" />
18
18
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
19
- <script type="module" crossorigin src="/assets/index-D2Z0cn6L.js"></script>
19
+ <script type="module" crossorigin src="/assets/index-DTfgsypA.js"></script>
20
20
  <link rel="stylesheet" crossorigin href="/assets/index-v9XNxyl1.css">
21
21
  </head>
22
22
  <body>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clitrigger",
3
- "version": "0.2.6",
3
+ "version": "0.2.7",
4
4
  "description": "Spawn isolated git worktrees and orchestrate Claude/Gemini/Codex CLI tasks in parallel from a web UI.",
5
5
  "keywords": [
6
6
  "claude",