pi-web 0.12.1 → 0.12.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@import"https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600;700&display=swap";@layer components;@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-space-y-reverse:0;--tw-divide-y-reverse:0;--tw-border-style:solid;--tw-leading:initial;--tw-font-weight:initial}}}@layer theme{:root,:host{--font-sans:ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";--font-mono:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;--color-white:#fff;--spacing:.25rem;--container-3xl:48rem;--text-xs:.75rem;--text-xs--line-height:calc(1 / .75);--text-sm:.875rem;--text-sm--line-height:calc(1.25 / .875);--text-base:1rem;--text-base--line-height: 1.5 ;--text-lg:1.125rem;--text-lg--line-height:calc(1.75 / 1.125);--font-weight-semibold:600;--leading-relaxed:1.625;--radius-md:.375rem;--radius-lg:.5rem;--radius-xl:.75rem;--default-font-family:var(--font-sans);--default-mono-font-family:var(--font-mono);--color-pi-accent:#5a8080;--color-pi-border-muted:#b0b0b0;--color-pi-success:#588458;--color-pi-error:#a55;--color-pi-warning:#9a7326;--color-pi-muted:#6c6c6c;--color-pi-dim:#767676;--color-pi-text:#1f2933;--color-pi-user-bg:#f6f6f6;--color-pi-tool-pending:#f3f7ff;--color-pi-tool-success:#e8f0e8;--color-pi-md-heading:#9a7326;--color-pi-md-link:#547da7;--color-pi-md-code:#5a8080;--color-pi-md-code-block:#588458;--color-pi-tool-output:#6c6c6c;--color-pi-page-bg:#f8f8f8;--color-pi-card-bg:#fff;--color-pi-control-bg:#fff;--color-pi-control-fg:#1f2933}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;tab-size:4;line-height:1.5;font-family:var(--default-font-family,ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring{outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab,red,red)){::placeholder{color:color-mix(in oklab,currentcolor 50%,transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){appearance:button}::file-selector-button{appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}}@layer utilities{.visible{visibility:visible}.sr-only{clip-path:inset(50%);white-space:nowrap;border-width:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}.absolute{position:absolute}.relative{position:relative}.start{inset-inline-start:var(--spacing)}.top-3{top:calc(var(--spacing) * 3)}.right-3{right:calc(var(--spacing) * 3)}.mx-auto{margin-inline:auto}.my-0{margin-block:calc(var(--spacing) * 0)}.my-2{margin-block:calc(var(--spacing) * 2)}.my-3{margin-block:calc(var(--spacing) * 3)}.mt-1{margin-top:calc(var(--spacing) * 1)}.mt-3{margin-top:calc(var(--spacing) * 3)}.mb-1{margin-bottom:calc(var(--spacing) * 1)}.mb-2{margin-bottom:calc(var(--spacing) * 2)}.mb-3{margin-bottom:calc(var(--spacing) * 3)}.mb-4{margin-bottom:calc(var(--spacing) * 4)}.ml-auto{margin-left:auto}.block{display:block}.contents{display:contents}.flex{display:flex}.hidden{display:none}.inline-flex{display:inline-flex}.aspect-square{aspect-ratio:1}.h-1\.5{height:calc(var(--spacing) * 1.5)}.h-4{height:calc(var(--spacing) * 4)}.h-6{height:calc(var(--spacing) * 6)}.h-10{height:calc(var(--spacing) * 10)}.h-\[var\(--composer-control-size\)\]{height:var(--composer-control-size)}.h-full{height:100%}.max-h-64{max-height:calc(var(--spacing) * 64)}.max-h-\[200px\]{max-height:200px}.min-h-0{min-height:calc(var(--spacing) * 0)}.min-h-\[var\(--composer-control-size\)\]{min-height:var(--composer-control-size)}.w-1\.5{width:calc(var(--spacing) * 1.5)}.w-4{width:calc(var(--spacing) * 4)}.w-6{width:calc(var(--spacing) * 6)}.w-10{width:calc(var(--spacing) * 10)}.w-full{width:100%}.max-w-3xl{max-width:var(--container-3xl)}.max-w-\[180px\]{max-width:180px}.min-w-0{min-width:calc(var(--spacing) * 0)}.flex-1{flex:1}.flex-shrink-0,.shrink-0{flex-shrink:0}.border-collapse{border-collapse:collapse}.cursor-pointer{cursor:pointer}.resize-none{resize:none}.flex-col{flex-direction:column}.flex-row{flex-direction:row}.flex-wrap{flex-wrap:wrap}.items-center{align-items:center}.items-start{align-items:flex-start}.justify-between{justify-content:space-between}.justify-center{justify-content:center}.gap-1{gap:calc(var(--spacing) * 1)}.gap-1\.5{gap:calc(var(--spacing) * 1.5)}.gap-2{gap:calc(var(--spacing) * 2)}.gap-2\.5{gap:calc(var(--spacing) * 2.5)}.gap-3{gap:calc(var(--spacing) * 3)}:where(.space-y-2>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 2) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 2) * calc(1 - var(--tw-space-y-reverse)))}:where(.divide-y>:not(:last-child)){--tw-divide-y-reverse:0;border-bottom-style:var(--tw-border-style);border-top-style:var(--tw-border-style);border-top-width:calc(1px * var(--tw-divide-y-reverse));border-bottom-width:calc(1px * calc(1 - var(--tw-divide-y-reverse)))}:where(.divide-pi-border-muted>:not(:last-child)){border-color:var(--color-pi-border-muted)}.truncate{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.overflow-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.rounded{border-radius:.25rem}.rounded-full{border-radius:3.40282e38px}.rounded-lg{border-radius:var(--radius-lg)}.rounded-md{border-radius:var(--radius-md)}.rounded-xl{border-radius:var(--radius-xl)}.border{border-style:var(--tw-border-style);border-width:1px}.border-t{border-top-style:var(--tw-border-style);border-top-width:1px}.border-b{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.border-dashed{--tw-border-style:dashed;border-style:dashed}.border-pi-border-muted{border-color:var(--color-pi-border-muted)}.bg-pi-accent{background-color:var(--color-pi-accent)}.bg-pi-border-muted{background-color:var(--color-pi-border-muted)}.bg-pi-card-bg{background-color:var(--color-pi-card-bg)}.bg-pi-control-bg{background-color:var(--color-pi-control-bg)}.bg-pi-page-bg{background-color:var(--color-pi-page-bg)}.bg-pi-success{background-color:var(--color-pi-success)}.bg-pi-tool-pending{background-color:var(--color-pi-tool-pending)}.bg-pi-tool-success{background-color:var(--color-pi-tool-success)}.bg-pi-user-bg{background-color:var(--color-pi-user-bg)}.p-0{padding:calc(var(--spacing) * 0)}.p-3{padding:calc(var(--spacing) * 3)}.p-4{padding:calc(var(--spacing) * 4)}.px-1{padding-inline:calc(var(--spacing) * 1)}.px-1\.5{padding-inline:calc(var(--spacing) * 1.5)}.px-2{padding-inline:calc(var(--spacing) * 2)}.px-3{padding-inline:calc(var(--spacing) * 3)}.px-4{padding-inline:calc(var(--spacing) * 4)}.py-0\.5{padding-block:calc(var(--spacing) * .5)}.py-1{padding-block:calc(var(--spacing) * 1)}.py-1\.5{padding-block:calc(var(--spacing) * 1.5)}.py-2{padding-block:calc(var(--spacing) * 2)}.py-2\.5{padding-block:calc(var(--spacing) * 2.5)}.py-3{padding-block:calc(var(--spacing) * 3)}.py-5{padding-block:calc(var(--spacing) * 5)}.py-6{padding-block:calc(var(--spacing) * 6)}.pt-3{padding-top:calc(var(--spacing) * 3)}.pr-8{padding-right:calc(var(--spacing) * 8)}.pb-4{padding-bottom:calc(var(--spacing) * 4)}.text-center{text-align:center}.text-left{text-align:left}.font-mono{font-family:var(--font-mono)}.text-base{font-size:var(--text-base);line-height:var(--tw-leading,var(--text-base--line-height))}.text-lg{font-size:var(--text-lg);line-height:var(--tw-leading,var(--text-lg--line-height))}.text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.text-xs{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.text-\[11px\]{font-size:11px}.leading-5{--tw-leading:calc(var(--spacing) * 5);line-height:calc(var(--spacing) * 5)}.leading-relaxed{--tw-leading:var(--leading-relaxed);line-height:var(--leading-relaxed)}.font-semibold{--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.break-words{overflow-wrap:break-word}.text-pi-accent{color:var(--color-pi-accent)}.text-pi-control-fg{color:var(--color-pi-control-fg)}.text-pi-dim{color:var(--color-pi-dim)}.text-pi-error{color:var(--color-pi-error)}.text-pi-md-code{color:var(--color-pi-md-code)}.text-pi-md-code-block{color:var(--color-pi-md-code-block)}.text-pi-md-heading{color:var(--color-pi-md-heading)}.text-pi-md-link{color:var(--color-pi-md-link)}.text-pi-muted{color:var(--color-pi-muted)}.text-pi-text{color:var(--color-pi-text)}.text-pi-tool-output{color:var(--color-pi-tool-output)}.text-pi-warning{color:var(--color-pi-warning)}.text-white{color:var(--color-white)}.underline{text-decoration-line:underline}.opacity-60{opacity:.6}.outline-none{--tw-outline-style:none;outline-style:none}@media(hover:hover){.hover\:bg-pi-user-bg:hover{background-color:var(--color-pi-user-bg)}.hover\:text-pi-accent:hover{color:var(--color-pi-accent)}.hover\:opacity-90:hover{opacity:.9}}.focus\:border-pi-accent:focus{border-color:var(--color-pi-accent)}.disabled\:cursor-default:disabled{cursor:default}.disabled\:bg-pi-border-muted:disabled{background-color:var(--color-pi-border-muted)}.disabled\:opacity-40:disabled{opacity:.4}.disabled\:opacity-50:disabled{opacity:.5}@media(min-width:48rem){.md\:px-6{padding-inline:calc(var(--spacing) * 6)}.md\:text-lg{font-size:var(--text-lg);line-height:var(--tw-leading,var(--text-lg--line-height))}.md\:text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}}}html,body,#root{height:100dvh;overflow:hidden}:root{--composer-control-size:42px;color-scheme:light}*,:before,:after{font-family:JetBrains Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace!important;font-size:14px!important}@supports (-webkit-touch-callout:none){:root{--composer-control-size:44px}.prompt-input{font-size:16px!important}}@media(prefers-color-scheme:dark){:root{color-scheme:dark;--color-pi-accent:#7ca6a6;--color-pi-border:#6f92b2;--color-pi-border-muted:#3f4b57;--color-pi-success:#78b178;--color-pi-error:#d17a7a;--color-pi-warning:#d1a454;--color-pi-muted:#9aa4ad;--color-pi-dim:#7d8892;--color-pi-text:#e5edf3;--color-pi-user-bg:#1b2430;--color-pi-tool-pending:#3a5f8c;--color-pi-tool-success:#1f2c23;--color-pi-tool-error:#322326;--color-pi-md-heading:#d1a454;--color-pi-md-link:#8fb6d8;--color-pi-md-code:#8fbfbf;--color-pi-md-code-block:#82b182;--color-pi-tool-output:#a8b3bc;--color-pi-page-bg:#10151b;--color-pi-card-bg:#151c24;--color-pi-control-bg:#0f1720;--color-pi-control-fg:#e5edf3;--color-syntax-comment:#8dc891;--color-syntax-keyword:#7fa8ff;--color-syntax-fn:#d8ba86;--color-syntax-var:#9fc3ff;--color-syntax-string:#f0a6a6;--color-syntax-number:#7fd4a5;--color-syntax-type:#7fc8e1}}.prompt-input::placeholder{color:var(--color-pi-muted)}@keyframes pulse-dot{0%,to{opacity:1}50%{opacity:.4}}.animate-pulse-dot{animation:1s infinite pulse-dot}.select-fit-content{field-sizing:content}.tool-io-pre{white-space:pre;tab-size:4;margin:0;line-height:1.3;overflow-x:auto}@property --tw-space-y-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-divide-y-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-leading{syntax:"*";inherits:false}@property --tw-font-weight{syntax:"*";inherits:false}
|
|
@@ -42,6 +42,6 @@ ${JSON.stringify(s,null,2)}`}catch{S+=`
|
|
|
42
42
|
|
|
43
43
|
[unable to serialise args]`}return f&&(S+=`
|
|
44
44
|
|
|
45
|
-
${f}`),S}function Sv(){const i=ch(),r=Xl(),[s,f]=x.useState([]),[d,m]=x.useState([]),[S,_]=x.useState(!1),[b,y]=x.useState(!1),[O,R]=x.useState(""),[L,Z]=x.useState(!1),[q,V]=x.useState(yv),[G,tt]=x.useState(null),[ft,et]=x.useState([]),[At,Tt]=x.useState(!1),[Ht,nt]=x.useState(null),[bt,ue]=x.useState([]),[Mt,ye]=x.useState(null),[Zt,pe]=x.useState("off"),[ie,Qt]=x.useState(""),[N,Q]=x.useState([]),[I,vt]=x.useState([]),[Rt,v]=x.useState(null),[U,X]=x.useState(null),[K,ut]=x.useState(!1),it=x.useMemo(()=>r.pathname.split("/").filter(Boolean),[r.pathname]),dt=it[0],Dt=it[1],Yt=it.length>2,at=x.useMemo(()=>Xm(dt),[dt]),Bt=x.useMemo(()=>Dt==null||Dt===Nr?null:Xm(Dt),[Dt]),yl=it.length===0,pl=it.length===1,be=it.length===2,ce=Dt===Nr,Tn=x.useMemo(()=>{const p=new URLSearchParams(r.search).get("cwd");if(!p)return null;const T=p.trim();return T.length>0?T:null},[r.search]),Zn=x.useRef(null),Ql=x.useRef(null),Se=x.useRef(null),Te=x.useRef(null),Fe=x.useRef(null),ja=x.useRef(null),Ne=x.useRef(null),fe=x.useRef([]),Zl=x.useRef(null),vl=x.useRef([]),Rn=x.useRef(null),Ie=x.useRef(!1),gl=x.useRef(null),bl=x.useRef(new Map),Vn=x.useRef(!1),ve=x.useRef(null),Pe=x.useRef(null),re=x.useRef(!1),tl=x.useRef(!1),Gt=x.useRef(null),el=x.useRef(null),Vl=x.useRef(!1),Kn=x.useRef(null),Ye=x.useMemo(()=>mv(Mt),[Mt]);x.useEffect(()=>{vl.current=s},[s]),x.useEffect(()=>{Rn.current=Bt},[Bt]),x.useEffect(()=>{Ie.current=L},[L]),x.useEffect(()=>{tl.current=b},[b]),x.useEffect(()=>{fe.current=bt},[bt]),x.useEffect(()=>{Zl.current=Mt},[Mt]),x.useEffect(()=>{Pe.current=at},[at]),x.useEffect(()=>{Vn.current=ce},[ce]),x.useEffect(()=>{ce||bl.current.clear()},[ce]),x.useEffect(()=>{Ye||I.length===0||(vt([]),v("Attached files were removed because the selected model does not support file attachments."),Te.current&&(Te.current.value=""))},[I.length,Ye]),x.useEffect(()=>{yl&&V(p=>p===Tn?p:Tn)},[Tn,yl]),x.useEffect(()=>(Wn(),Ge(),()=>{ja.current&&window.clearTimeout(ja.current),Ne.current&&window.clearTimeout(Ne.current),Gt.current&&window.clearInterval(Gt.current),Gt.current=null,el.current?.abort(),el.current=null,Vl.current=!1,Zn.current?.close()}),[]),x.useEffect(()=>{pl&&Ge()},[pl,at]),x.useEffect(()=>{if(!pl)return;const p=window.setInterval(()=>{Ge()},Gm);return()=>window.clearInterval(p)},[pl,at]),x.useEffect(()=>{Ql.current&&requestAnimationFrame(()=>{Ql.current&&(Ql.current.scrollTop=Ql.current.scrollHeight)})},[d,N.length,bt.length,Mt?.id,Mt?.provider]),x.useEffect(()=>{Se.current&&(Se.current.style.height="auto",Se.current.style.height=`${Math.min(Se.current.scrollHeight,200)}px`)},[O]),x.useEffect(()=>{!be||!L||!Nu()||requestAnimationFrame(()=>{const p=Se.current;!p||p.disabled||p.focus()})},[Bt,L,be,ce,at]),x.useEffect(()=>{be||Ie.current&&Yu()},[be]),x.useEffect(()=>{Yt&&i("/",{replace:!0})},[Yt,i]),x.useEffect(()=>{dt!=null&&at==null&&i("/",{replace:!0})},[i,dt,at]),x.useEffect(()=>{dt==null||Dt==null||ce||at!=null&&Bt==null&&i(Cu(at),{replace:!0})},[Bt,ce,i,dt,at,Dt]),x.useEffect(()=>{if(!at||!Bt||Dt==null||ce)return;if(!s.some(T=>T.cwd===at&&T.file===Bt)&&K){const T=ve.current;if(T?.cwd===at&&T?.sessionFile===Bt||re.current)return;i(Cu(at),{replace:!0})}},[Bt,K,ce,i,at,Dt,s]);const Jn=x.useMemo(()=>Array.from(new Set(bt.map(p=>p.provider))),[bt]),$n=x.useMemo(()=>bt.filter(p=>p.provider===ie),[bt,ie]),Sl=Mt?.provider===ie?Mt.id:"",kn=x.useMemo(()=>{const p=Mt?.reasoning===!1?["off"]:yh;return p.includes(Zt)?p:[Zt,...p.filter(T=>T!==Zt)]},[Mt?.reasoning,Zt]),Kl=x.useMemo(()=>Cv(d),[d]),dc=x.useMemo(()=>!q||!G?!1:q!==G,[q,G]),Lu=x.useMemo(()=>at?s.filter(p=>p.cwd===at):[],[at,s]);function Wn(){const p=new WebSocket(ov);Zn.current=p,p.onopen=()=>{if(_(!0),gl.current){const T=gl.current;An(T.cwd,T.sessionFile??null)&&(xe(),ll());return}if(Rn.current||Ie.current){const T=Rn.current,j=T?vl.current.find(Y=>Y.file===T)?.cwd:Pe.current??vl.current[0]?.cwd;if(!T&&!j)return;An(j,T??null)&&(xe(),ll())}},p.onmessage=T=>{let j;try{j=JSON.parse(T.data)}catch{return}j.type==="rpc_event"&&Jl(j.event),j.type==="error"&&(console.error("[pi-web]",j.message),typeof j.message=="string"&&(j.message.toLowerCase().includes("attachment")&&v(j.message),j.message.includes("no active session")&&(Ie.current||gl.current)&&(xe(150),ll()))),j.type==="session_ended"&&(y(!1),Z(!1),ve.current=null,Ge())},p.onclose=()=>{_(!1),y(!1),Z(!1),gl.current=null,bl.current.clear(),ve.current=null,ja.current=window.setTimeout(Wn,2e3)}}function kt(p){return Zn.current?.readyState===WebSocket.OPEN?(Zn.current.send(JSON.stringify(p)),!0):!1}function qu(p,T=12){const j=`route-sync-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;bl.current.set(j,{cwd:p,attemptsLeft:T});const Y=kt({type:"rpc_command",command:{type:"get_state",id:j}});return Y||bl.current.delete(j),Y}function An(p,T){return kt({type:"start_session",sessionFile:T??void 0,cwd:p})?(gl.current=null,ve.current={cwd:p,sessionFile:T??null},Z(!0),Ge(),!0):(gl.current={cwd:p,sessionFile:T},ve.current=null,Z(!1),!1)}function Yu(){kt({type:"detach_session"}),gl.current=null,ve.current=null,Z(!1),y(!1),X(null),Ge()}function Gu(){const p=kt({type:"rpc_command",command:{type:"get_available_models",id:"get_models"}}),T=kt({type:"rpc_command",command:{type:"get_state",id:"get_state"}});return p&&T}function ll(){kt({type:"rpc_command",command:{type:"get_session_stats",id:"get_session_stats"}})}function xe(p=800){Ne.current&&window.clearTimeout(Ne.current),Ne.current=window.setTimeout(()=>{Gu()||xe(p)},p)}async function Ge(){try{const p=await fetch("/api/sessions");f(await p.json())}catch{}finally{ut(!0)}}x.useEffect(()=>{if(!yl)return;const p=new AbortController,T=q?`?cwd=${encodeURIComponent(q)}`:"";return Tt(!0),nt(null),fetch(`/api/folders${T}`,{signal:p.signal}).then(async j=>{if(!j.ok)throw new Error("failed to load folders");return await j.json()}).then(j=>{p.signal.aborted||(V(j.cwd),tt(j.root),et(Array.isArray(j.folders)?j.folders:[]),nt(j.error??null))}).catch(()=>{p.signal.aborted||(et([]),nt("unable to load folders"))}).finally(()=>{p.signal.aborted||Tt(!1)}),()=>p.abort()},[q,yl]),x.useEffect(()=>{if(!be||!at||!Bt||ce){Gt.current&&window.clearInterval(Gt.current),Gt.current=null,el.current?.abort(),el.current=null,Vl.current=!1;return}let p=!1;const T=async()=>{if(p||Vl.current||tl.current&&ve.current?.cwd===at&&ve.current?.sessionFile===Bt)return;Vl.current=!0;const Y=new AbortController;el.current=Y;try{await mc(at,Bt,Y.signal)}catch{}finally{el.current===Y&&(el.current=null),Vl.current=!1}};return T(),Gt.current=window.setInterval(()=>{T()},Gm),()=>{p=!0,Gt.current&&window.clearInterval(Gt.current),Gt.current=null,el.current?.abort(),el.current=null,Vl.current=!1}},[Bt,be,ce,at]);function Fn(p,T){if(typeof p=="string"){T.push({type:"text",content:p,done:!0});return}if(Array.isArray(p)){for(const j of p)if(j.type==="text"&&j.text)T.push({type:"text",content:j.text,done:!0});else if(j.type==="thinking"&&j.thinking)T.push({type:"thinking",content:j.thinking,done:!0});else if(j.type==="image")T.push({type:"text",content:"[attached image]",done:!0});else if(j.type==="toolCall"||j.type==="tool_call"||j.type==="tool_use"){const Y=j.result!==void 0||j.output!==void 0,k=Uu(j.result??j.output??""),F=ql(j.result);T.push({type:"tool",name:j.name||j.toolName||"tool",args:j.args||j.arguments||j.input,content:k.text,details:k.details,done:Y,id:j.id,isError:!!(j.isError??F?.isError)})}}}function nl(p){return p.map(T=>{const j=[];T.content&&Fn(T.content,j);const Y=T.timestamp?Number(T.timestamp):void 0;return{id:T.id||crypto.randomUUID(),role:T.role||"unknown",parts:j,model:T.model,provider:T.provider,timestamp:Number.isFinite(Y)?Y:void 0,usage:T.usage}})}function Wt(p){if(p.length===0)return"0";let T=0,j=0,Y=0;for(const W of p){T+=W.parts.length;for(const st of W.parts)typeof st.content=="string"&&(j+=st.content.length),st.type==="tool"&&Y++}const k=p[p.length-1],F=k.parts.map(W=>`${W.type}:${W.done?1:0}:${W.name||""}:${typeof W.content=="string"?W.content.length:0}`).join("|");return[p.length,T,j,Y,k.role,k.timestamp??"",F].join("::")}function le(p){if(p.length===0)return null;if(Fe.current){const T=p.findIndex(j=>j.id===Fe.current);return T<0?null:{target:p[T],index:T}}for(let T=p.length-1;T>=0;T--)if(p[T].role==="assistant")return{target:p[T],index:T};return null}function Jl(p){if(p?.type)switch(p.type){case"response":{if(p.command==="get_available_models"){const T=(p.data?.models??[]).map(j=>nc(j)).filter(j=>j!=null);T.length>0?(ue(T),fe.current=T,Ne.current&&window.clearTimeout(Ne.current),Zl.current||xe()):xe(),ll()}if(p.command==="get_state"){const T=p.data??{},j=nc(T.model);j?(ye(j),Zl.current=j,Qt(j.provider),Ne.current&&window.clearTimeout(Ne.current),fe.current.length===0&&xe()):xe();const Y=Ou(T.thinkingLevel);Y&&pe(Y);const k=typeof p.id=="string"?p.id:"",F=k?bl.current.get(k):void 0;if(F){bl.current.delete(k);const W=typeof T.sessionFile=="string"?T.sessionFile.split("/").pop()??"":"",st=typeof T.messageCount=="number"?T.messageCount:0;W&&st>0&&Vn.current&&Pe.current===F.cwd?(f(jt=>jt.some(wt=>wt.file===W)?jt:[{id:typeof T.sessionId=="string"&&T.sessionId?T.sessionId:W,file:W,cwd:F.cwd,timestamp:new Date().toISOString(),messageCount:Math.max(st,1)},...jt]),ve.current={cwd:F.cwd,sessionFile:W},re.current=!0,i(Qm(F.cwd,W),{replace:!0})):F.attemptsLeft>0&&Vn.current&&Pe.current===F.cwd&&window.setTimeout(()=>{Vn.current&&Pe.current===F.cwd&&qu(F.cwd,F.attemptsLeft-1)},250)}}if(p.command==="set_model"&&p.success){const T=nc(p.data);T&&(ye(T),Zl.current=T),kt({type:"rpc_command",command:{type:"get_state",id:"get_state"}})}if(p.command==="set_thinking_level"&&p.success){const T=Ou(p.data?.level);T&&pe(T),kt({type:"rpc_command",command:{type:"get_state",id:"get_state"}})}if(p.command==="cycle_thinking_level"&&p.success){const T=Ou(p.data?.level);T&&pe(T),kt({type:"rpc_command",command:{type:"get_state",id:"get_state"}})}p.command==="get_session_stats"&&p.success&&X(p.data);break}case"agent_start":y(!0),Ge();break;case"agent_end":y(!1),Fe.current=null,Ge(),ll(),(fe.current.length===0||!Zl.current)&&xe(),Q(T=>{if(T.length===0)return T;const[j,...Y]=T;return kt({type:"rpc_command",command:{type:"prompt",message:j.message,images:j.images.length>0?j.images:void 0,id:`web-${Date.now()}`}}),Y});break;case"message_start":{const T=p.message;if(!T)break;const j=T.id||crypto.randomUUID(),Y=T.role||"assistant";if(Y==="toolResult"||Y==="tool_result"||Y==="tool")break;const k=[];T.content&&Fn(T.content,k);const F={id:j,role:Y,parts:k,model:T.model,provider:T.provider,timestamp:typeof T.timestamp=="number"?T.timestamp:void 0,usage:T.usage};Y==="assistant"&&(Fe.current=j),m(W=>W.some(st=>st.id===j)?W:[...W,F]);break}case"message_update":{const T=p.assistantMessageEvent,j=T?.type==="thinking_delta",Y=T?.type==="text_delta"||T?.type==="thinking_delta"?T.delta:void 0;if(!Y)break;m(k=>{const F=le(k);if(!F)return k;const W=[...F.target.parts],st=j?"thinking":"text";let jt=W.find(wt=>wt.type===st&&!wt.done);jt||(jt={type:st,content:""},W.push(jt)),jt.content=`${jt.content||""}${Y}`;const De=[...k];return De[F.index]={...F.target,parts:W},De});break}case"message_end":{const T=p.message;if(T?.role&&T.role!=="assistant")break;const j=typeof T?.timestamp=="number"?T.timestamp:void 0,Y=Fe.current;m(k=>k.map(F=>{if(F.id!==Y)return F;const W=j??F.timestamp;if(T?.content){const st=[];return Fn(T.content,st),{...F,parts:st,model:T.model??F.model,provider:T.provider??F.provider,timestamp:W,usage:T.usage??F.usage}}return{...F,parts:F.parts.map(st=>({...st,done:!0})),timestamp:W,usage:T?.usage??F.usage}}));break}case"tool_execution_start":{const T=p.toolCallId||p.id;m(j=>{const Y=le(j);if(!Y)return j;const k=[...Y.target.parts],F=k.findIndex(st=>st.type==="tool"&&st.id&&T&&st.id===T);if(F>=0){const st=k[F];k[F]={...st,type:"tool",name:p.toolName||p.name||st.name||"tool",args:p.args??st.args,content:st.content??"",done:!1,id:T,details:st.details,isError:!1}}else k.push({type:"tool",name:p.toolName||p.name||"tool",args:p.args,content:"",done:!1,id:T,isError:!1});const W=[...j];return W[Y.index]={...Y.target,parts:k},W});break}case"tool_execution_update":{const T=p.toolCallId||p.id,j=p.partialResult!==void 0,Y=Uu(j?p.partialResult:p.output);m(k=>{const F=le(k);if(!F)return k;const W=[...F.target.parts],st=[...W].reverse(),jt=st.find(wt=>wt.type==="tool"&&!wt.done&&(!T||wt.id===T))||st.find(wt=>wt.type==="tool"&&!wt.done);jt&&(p.args!==void 0&&(jt.args=p.args),j?jt.content=Y.text:Y.text&&(jt.content=`${En(jt.content)}${Y.text}`),Y.details!==void 0&&(jt.details=Y.details));const De=[...k];return De[F.index]={...F.target,parts:W},De});break}case"tool_execution_end":{const T=p.toolCallId||p.id,j=Uu(p.result??p.output??""),Y=p.result!==void 0||p.output!==void 0;m(k=>{const F=le(k);if(!F)return k;const W=[...F.target.parts],st=[...W].reverse(),jt=st.find(wt=>wt.type==="tool"&&!wt.done&&(!T||wt.id===T))||st.find(wt=>wt.type==="tool"&&!wt.done);jt&&(p.args!==void 0&&(jt.args=p.args),jt.done=!0,jt.isError=!!p.isError,Y&&(jt.content=j.text),j.details!==void 0&&(jt.details=j.details));const De=[...k];return De[F.index]={...F.target,parts:W},De});break}case"model_changed":{const T=nc(p.model);T&&(ye(T),Zl.current=T);const j=Ou(p.thinkingLevel??p.level);j&&pe(j);break}}}async function Ha(p,T){try{const j=await fetch(`/api/session?cwd=${encodeURIComponent(p)}&filename=${encodeURIComponent(T)}`);if(!j.ok)return;const Y=await j.json(),k=nl(Y);Kn.current=Wt(k),m(k)}catch{}}async function mc(p,T,j){const Y=await fetch(`/api/session?cwd=${encodeURIComponent(p)}&filename=${encodeURIComponent(T)}`,{signal:j});if(!Y.ok)return;const k=await Y.json(),F=nl(k),W=Wt(F);W!==Kn.current&&(Kn.current=W,m(F),Ge())}function Xu(){m([]),R(""),vt([]),v(null),Te.current&&(Te.current.value=""),Fe.current=null,y(!1),X(null),Kn.current=null,Ne.current&&window.clearTimeout(Ne.current)}async function Qu(p,T){if(Ie.current&&ve.current?.sessionFile===T&&ve.current?.cwd===p){Nu()&&Se.current?.focus();return}Xu(),await Ha(p,T),An(p,T)&&(xe(120),ll()),Nu()&&Se.current?.focus()}function _n(p){if(Ie.current&&ve.current?.sessionFile===null&&ve.current?.cwd===p){Nu()&&Se.current?.focus();return}Xu(),An(p,null)&&(xe(120),ll()),Nu()&&Se.current?.focus()}x.useEffect(()=>{if(!at||Dt==null)return;if(ce){_n(at);return}if(!(!Bt||!s.some(T=>T.cwd===at&&T.file===Bt))){if(re.current){re.current=!1,ve.current={cwd:at,sessionFile:Bt};return}Qu(at,Bt)}},[Bt,ce,at,Dt,s]);function Ba(p){const T=vl.current.find(j=>j.file===p)?.cwd;T&&i(Qm(T,p))}function $l(p){i(dv(p))}function kl(p){i(Cu(p))}function zn(p){i(lc(p))}function Wl(){if(!q||!G||q===G)return;const p=q.split("/").filter(Boolean),T=p.length<=1?"/":`/${p.slice(0,-1).join("/")}`;i(lc(T))}function Ft(){q&&kl(q)}function wa(){i(lc(at??q))}function Zu(){if(!at){i(lc(q));return}i(Cu(at))}async function xl(p){if(!p||p.length===0)return;if(!Ye){v("Selected model does not support file attachments.");return}const T=Array.from(p),j=[];let Y=0,k=0;for(const W of T){if(!W.type.startsWith("image/")){Y++;continue}try{const st=await hv(W);j.push({id:crypto.randomUUID(),type:"image",data:st,mimeType:W.type,name:W.name,size:W.size})}catch{k++}}j.length>0&&vt(W=>[...W,...j]);const F=[];Y>0&&F.push(`${Y} non-image file${Y===1?"":"s"} ignored`),k>0&&F.push(`${k} file${k===1?"":"s"} could not be read`),v(F.length>0?F.join(". "):null)}function Fl(){if(L){if(!Ye){v("Selected model does not support file attachments.");return}Te.current?.click()}}function hc(p){vt(T=>T.filter(j=>j.id!==p)),v(null)}function La(){const p=O.trim();if(!p&&I.length===0||!S||!L)return;if(I.length>0&&!Ye){v("Selected model does not support file attachments.");return}const T=I.map(Y=>({type:"image",data:Y.data,mimeType:Y.mimeType}));if(R(""),vt([]),v(null),Te.current&&(Te.current.value=""),ph()&&Se.current?.blur(),b){Q(Y=>[...Y,{id:`queued-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,message:p,images:T}]);return}kt({type:"rpc_command",command:{type:"prompt",message:p,images:T.length>0?T:void 0,id:`web-${Date.now()}`}})&&ce&&at&&qu(at)}function Vu(){kt({type:"rpc_command",command:{type:"abort",id:`abort-${Date.now()}`}})}function yc(p){Qt(p)}function In(p){const T=bt.find(j=>j.id===p&&j.provider===ie);T&&kt({type:"rpc_command",command:{type:"set_model",provider:T.provider,modelId:T.id,id:"set_model"}})}function Pn(p){const T=Ou(p);T&&(pe(T),kt({type:"rpc_command",command:{type:"set_thinking_level",level:T,id:"set_thinking_level"}}))}async function al(p){const T=vl.current.find(Y=>Y.file===p)?.cwd??at??"";try{await fetch(`/api/session?cwd=${encodeURIComponent(T)}&filename=${encodeURIComponent(p)}`,{method:"DELETE"})}catch{}f(Y=>Y.filter(k=>k.file!==p));const j=at??vl.current.find(Y=>Y.file===p)?.cwd;Rn.current===p&&(m([]),R(""),vt([]),v(null),Te.current&&(Te.current.value=""),Fe.current=null,y(!1),Z(!1),X(null),i(j?Cu(j):"/"))}const Re=b?"streaming response":"session status";return B.jsxs("div",{className:"flex flex-col h-full bg-pi-page-bg text-pi-text text-sm font-mono overflow-hidden",children:[yl&&B.jsx("main",{className:"flex-1 overflow-y-auto px-4 py-5 md:px-6",children:B.jsx(Ev,{cwd:q,folders:ft,isLoading:At,error:Ht,canNavigateUp:dc,onBrowseIntoFolder:zn,onBrowseToParent:Wl,onOpenCurrentFolder:Ft})}),pl&&at&&B.jsx("main",{className:"flex-1 overflow-y-auto px-4 py-5 md:px-6",children:B.jsx(Tv,{projectCwd:at,sessions:Lu,onBack:wa,onCreateSession:()=>$l(at),onSelectSession:Ba,onDeleteSession:al})}),pl&&!at&&B.jsx("main",{className:"flex-1 overflow-y-auto px-4 py-5 md:px-6",children:B.jsxs("div",{className:"mx-auto max-w-3xl rounded-xl border border-pi-border-muted bg-pi-card-bg p-4",children:[B.jsx("div",{className:"text-sm text-pi-muted mb-3",children:"no folder selected"}),B.jsx("button",{onClick:wa,className:"px-3 py-1.5 rounded-lg border border-pi-border-muted text-pi-muted hover:text-pi-accent hover:bg-pi-user-bg cursor-pointer",children:"choose folder"})]})}),be&&B.jsxs("main",{className:"flex-1 flex flex-col min-h-0",children:[B.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 md:px-6 border-b border-pi-border-muted bg-pi-card-bg",children:[B.jsxs("div",{className:"min-w-0",children:[B.jsx("div",{className:"text-[11px] text-pi-dim truncate",children:at?sv(at):"folder not selected"}),B.jsx("div",{className:"text-xs truncate text-pi-muted",children:Bt?Bt.split("/").pop():"new session"})]}),B.jsx("button",{onClick:Zu,title:"back to sessions",className:"ml-auto inline-flex items-center justify-center h-10 w-10 shrink-0 aspect-square rounded-lg border border-pi-border-muted text-pi-muted hover:text-pi-accent hover:bg-pi-user-bg cursor-pointer",children:B.jsx("svg",{width:"18",height:"18",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:B.jsx("polyline",{points:"10.5,3 5,8 10.5,13"})})})]}),B.jsx("div",{ref:Ql,className:"flex-1 overflow-y-auto px-4 py-2 md:px-6",children:d.length===0&&N.length===0?B.jsx("div",{className:"flex items-center justify-center h-full text-pi-muted text-base",children:"choose a session and start prompting."}):(()=>{const p=d.filter(Y=>(Y.role==="user"||Y.role==="assistant")&&(Y.role==="user"||Y.parts.some(k=>k.type==="tool"||k.type==="text"&&(k.content??"").trim()))),T=d.filter(Y=>(Y.role==="steering"||Y.role==="system")&&Y.parts.some(k=>k.type==="text"&&(k.content??"").trim())),j=N.map(Y=>{const k=Y.message.trim(),F=Y.images.length>0?Y.images.length===1?"[queued image]":`[${Y.images.length} queued images]`:"[queued message]";return{id:Y.id,role:"steering",parts:[{type:"text",content:k||F,done:!0}]}});return[...p,...T,...j].map(Y=>B.jsx(xv,{msg:Y},Y.id))})()}),B.jsxs("div",{className:"flex items-center gap-3 px-4 py-1.5 md:px-6 border-t border-pi-border-muted bg-pi-card-bg text-xs text-pi-muted flex-wrap",children:[(bt.length>0||Mt)&&B.jsxs("span",{className:"flex items-center gap-2.5 flex-wrap",children:[bt.length>0&&B.jsxs(B.Fragment,{children:[B.jsx("select",{value:ie,onChange:p=>yc(p.target.value),disabled:b,className:"font-mono text-pi-control-fg bg-pi-control-bg border border-pi-border-muted rounded px-1 py-0.5 cursor-pointer disabled:opacity-50 select-fit-content",children:Jn.map(p=>B.jsx("option",{value:p,children:p},p))}),B.jsx("select",{value:Sl,onChange:p=>In(p.target.value),disabled:b,className:"font-mono text-pi-control-fg bg-pi-control-bg border border-pi-border-muted rounded px-1 py-0.5 cursor-pointer disabled:opacity-50 select-fit-content",children:$n.map(p=>B.jsx("option",{value:p.id,children:p.id},p.id))})]}),bt.length===0&&Mt&&B.jsx("span",{children:Mt.id}),L&&B.jsx("select",{value:Zt,onChange:p=>Pn(p.target.value),disabled:!S||b||Mt?.reasoning===!1,"aria-label":"thinking level",title:"thinking level",className:"font-mono text-pi-control-fg bg-pi-control-bg border border-pi-border-muted rounded px-1 py-0.5 cursor-pointer disabled:opacity-50 select-fit-content",children:kn.map(p=>B.jsx("option",{value:p,children:p},p))})]}),U&&B.jsxs("span",{className:"flex items-center gap-2 text-pi-dim ml-auto flex-wrap",children:[U.tokens.input>0&&B.jsxs("span",{children:["↑",Du(U.tokens.input)]}),U.tokens.output>0&&B.jsxs("span",{children:["↓",Du(U.tokens.output)]}),U.tokens.cacheRead>0&&B.jsxs("span",{children:["r",Du(U.tokens.cacheRead)]}),U.tokens.cacheWrite>0&&B.jsxs("span",{children:["w",Du(U.tokens.cacheWrite)]}),U.cost>0&&B.jsxs("span",{children:["$",U.cost.toFixed(2)]}),Mt?.contextWindow&&Kl&&(()=>{const p=Kl/Mt.contextWindow*100,T=p>90?"text-pi-error":p>70?"text-pi-warning":"";return B.jsxs("span",{className:T,children:[p.toFixed(0),"%/",Du(Mt.contextWindow)]})})()]})]}),B.jsxs("div",{className:"px-4 pb-4 pt-3 md:px-6 border-t border-pi-border-muted bg-pi-card-bg",children:[B.jsx("input",{ref:Te,type:"file",accept:"image/*",multiple:!0,className:"hidden",onChange:p=>{xl(p.target.files),p.target.value=""}}),I.length>0&&B.jsx("div",{className:"mb-2 flex flex-wrap gap-1.5",children:I.map(p=>B.jsxs("span",{className:"inline-flex items-center gap-1 rounded-md border border-pi-border-muted bg-pi-user-bg px-2 py-1 text-[11px] text-pi-muted",title:p.name,children:[B.jsxs("span",{className:"max-w-[180px] truncate",children:[p.name," (",Dr(p.size),")"]}),B.jsx("button",{onClick:()=>hc(p.id),title:"remove attachment",className:"inline-flex h-4 w-4 items-center justify-center rounded text-pi-muted hover:text-pi-accent cursor-pointer",children:"×"})]},p.id))}),Rt&&B.jsx("div",{className:"mb-2 text-[11px] text-pi-warning",children:Rt}),B.jsxs("div",{className:"flex gap-2 items-center",children:[B.jsx("span",{className:"sr-only","aria-live":"polite",children:Re}),B.jsx("textarea",{ref:Se,rows:1,placeholder:L?"send a message...":"create or select a session",disabled:!L,value:O,onChange:p=>R(p.target.value),onKeyDown:p=>{p.key==="Enter"&&!p.shiftKey&&(p.preventDefault(),La())},className:"prompt-input flex-1 bg-pi-control-bg text-pi-control-fg border border-pi-border-muted rounded-lg px-3 py-2.5 font-mono leading-5 resize-none min-h-[var(--composer-control-size)] max-h-[200px] outline-none focus:border-pi-accent disabled:opacity-50 disabled:cursor-default"}),B.jsxs("div",{className:"flex flex-row gap-1 flex-shrink-0",children:[B.jsx("button",{onClick:Fl,disabled:!L||!Ye,title:L?Ye?"attach file":"selected model does not support file attachments":"create or select a session","aria-label":"attach file",className:"h-[var(--composer-control-size)] aspect-square inline-flex items-center justify-center flex-shrink-0 rounded-lg border border-pi-border-muted text-pi-muted hover:text-pi-accent hover:bg-pi-user-bg cursor-pointer disabled:opacity-40 disabled:cursor-default",children:B.jsx("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:B.jsx("path",{d:"M6 9.5 10.8 4.7a2.8 2.8 0 1 1 4 4L8.5 15a4 4 0 1 1-5.7-5.7L8.3 3.8"})})}),B.jsx("button",{onClick:La,disabled:!S,title:b?"queue message":"send","aria-label":b?"queue message":"send message",className:"h-[var(--composer-control-size)] aspect-square inline-flex items-center justify-center flex-shrink-0 rounded-lg bg-pi-accent text-white cursor-pointer hover:opacity-90 disabled:opacity-40 disabled:cursor-default disabled:bg-pi-border-muted",children:B.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[B.jsx("line",{x1:"2",y1:"9",x2:"16",y2:"9"}),B.jsx("polyline",{points:"10,3 16,9 10,15"})]})}),B.jsx("button",{onClick:Vu,disabled:!b||!L,title:"stop",className:"h-[var(--composer-control-size)] aspect-square inline-flex items-center justify-center flex-shrink-0 rounded-lg border border-pi-border-muted text-pi-muted hover:text-pi-accent hover:bg-pi-user-bg cursor-pointer disabled:opacity-40 disabled:cursor-default",children:B.jsx("svg",{width:"20",height:"20",viewBox:"0 0 18 18",fill:"currentColor",children:B.jsx("rect",{x:"4",y:"4",width:"10",height:"10",rx:"1.5"})})})]})]})]})]})]})}function xv({msg:i}){const r=i.role==="user",s=i.role==="steering"||i.role==="system",f=i.parts.some(_=>_.type==="text"&&!!(_.content??"").trim()),d=i.parts.some(_=>_.type==="tool"),m=!r&&!s&&d&&!f,S=r?"bg-pi-tool-success border border-pi-border-muted":m?"bg-pi-user-bg border border-pi-border-muted":"bg-pi-card-bg border border-pi-border-muted";return B.jsx("div",{className:"mb-2 min-w-0",children:B.jsx("div",{className:`rounded-lg ${m?"p-0":"px-2 py-1.5"} min-w-0 overflow-hidden ${S}`,children:B.jsx("div",{className:`text-xs md:text-sm leading-relaxed break-words min-w-0 ${s?"text-pi-muted":""}`,children:i.parts.map((_,b)=>B.jsx(Rv,{part:_},`${i.id}-${b}`))})})})}function Ev({cwd:i,folders:r,isLoading:s,error:f,canNavigateUp:d,onBrowseIntoFolder:m,onBrowseToParent:S,onOpenCurrentFolder:_}){return B.jsxs("div",{className:"mx-auto max-w-3xl",children:[B.jsxs("div",{className:"mb-4 flex items-start justify-between gap-3",children:[B.jsxs("div",{className:"min-w-0",children:[B.jsx("h1",{className:"text-base md:text-lg font-semibold text-pi-accent",children:"browse folders"}),B.jsx("p",{className:"text-pi-muted mt-1 truncate",title:i??"",children:i?Da(i):"loading…"})]}),B.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[B.jsx("button",{onClick:_,disabled:!i,title:"open current folder","aria-label":"open current folder",className:"inline-flex items-center justify-center h-10 w-10 shrink-0 aspect-square rounded-lg border border-pi-border-muted text-pi-muted hover:text-pi-accent hover:bg-pi-user-bg cursor-pointer disabled:opacity-40 disabled:cursor-default",children:B.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[B.jsx("path",{d:"M1.5 6.1V4.8a1 1 0 0 1 1-1h3l1.3 1.3h6.7a1 1 0 0 1 1 1v.8"}),B.jsx("path",{d:"M1.5 6.9h13l-1.2 5.2a1 1 0 0 1-1 .8H3.7a1 1 0 0 1-1-.8L1.5 6.9Z"})]})}),B.jsx("button",{onClick:S,disabled:!d,title:"back",className:"inline-flex items-center justify-center h-10 w-10 shrink-0 aspect-square rounded-lg border border-pi-border-muted text-pi-muted hover:text-pi-accent hover:bg-pi-user-bg cursor-pointer disabled:opacity-40 disabled:cursor-default",children:B.jsx("svg",{width:"18",height:"18",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:B.jsx("polyline",{points:"10.5,3 5,8 10.5,13"})})})]})]}),B.jsxs("div",{className:"rounded-xl border border-pi-border-muted bg-pi-card-bg",children:[s&&B.jsx("div",{className:"px-4 py-6 text-center text-pi-muted",children:"loading folders…"}),!s&&f&&B.jsx("div",{className:"px-4 py-6 text-center text-pi-error",children:f}),!s&&!f&&r.length===0&&B.jsx("div",{className:"px-4 py-6 text-center text-pi-muted",children:"no visible folders here."}),!s&&!f&&r.length>0&&B.jsx("div",{className:"divide-y divide-pi-border-muted",children:r.map(b=>B.jsx("button",{onClick:()=>m(b.path),className:"w-full text-left px-4 py-3 hover:bg-pi-user-bg cursor-pointer",title:b.path,children:B.jsx("div",{className:"text-sm text-pi-text truncate",children:b.name})},b.path))})]})]})}function Tv({projectCwd:i,sessions:r,onBack:s,onCreateSession:f,onSelectSession:d,onDeleteSession:m}){return B.jsxs("div",{className:"mx-auto max-w-3xl",children:[B.jsxs("div",{className:"mb-4 flex items-start gap-3 justify-between",children:[B.jsxs("div",{className:"min-w-0",children:[B.jsx("h1",{className:"text-base md:text-lg font-semibold text-pi-accent",children:"choose a session"}),B.jsx("p",{className:"text-pi-muted mt-1 truncate",title:i,children:i})]}),B.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[B.jsx("button",{onClick:f,title:"new session",className:"inline-flex items-center justify-center h-10 w-10 shrink-0 aspect-square rounded-lg border border-pi-border-muted text-pi-muted hover:text-pi-accent hover:bg-pi-user-bg cursor-pointer",children:B.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[B.jsx("line",{x1:"8",y1:"3",x2:"8",y2:"13"}),B.jsx("line",{x1:"3",y1:"8",x2:"13",y2:"8"})]})}),B.jsx("button",{onClick:s,title:"back to folders",className:"inline-flex items-center justify-center h-10 w-10 shrink-0 aspect-square rounded-lg border border-pi-border-muted text-pi-muted hover:text-pi-accent hover:bg-pi-user-bg cursor-pointer",children:B.jsx("svg",{width:"18",height:"18",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:B.jsx("polyline",{points:"10.5,3 5,8 10.5,13"})})})]})]}),r.length===0?B.jsx("div",{className:"rounded-xl border border-dashed border-pi-border-muted bg-pi-card-bg px-4 py-6 text-center text-pi-muted",children:"no sessions in this folder yet."}):B.jsx("div",{className:"space-y-2",children:r.map(S=>{const _=S.firstPrompt||S.id.slice(0,8),b=S.timestamp?new Date(S.timestamp).toLocaleString():"",y=!!S.isWorking,O=!!S.isActive,R=y?"working":O?"active":"idle",L=y?"bg-pi-success animate-pulse-dot":O?"bg-pi-accent":"bg-pi-border-muted";return B.jsxs("div",{className:"group relative w-full text-left rounded-xl border border-pi-border-muted bg-pi-card-bg px-4 py-3 hover:bg-pi-user-bg",children:[B.jsxs("button",{onClick:()=>d(S.file),className:"w-full text-left cursor-pointer",children:[B.jsx("div",{className:"text-sm text-pi-text truncate pr-8",children:_}),B.jsxs("div",{className:"text-[11px] text-pi-muted mt-1 flex items-center gap-1.5 flex-wrap",children:[B.jsxs("span",{children:[S.messageCount," msgs"]}),B.jsx("span",{children:"·"}),B.jsx("span",{children:b}),B.jsx("span",{children:"·"}),B.jsxs("span",{className:"inline-flex items-center gap-1",children:[B.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${L}`}),R]})]})]}),B.jsx("button",{onClick:()=>m(S.file),title:"delete session",className:"absolute top-3 right-3 inline-flex items-center justify-center w-6 h-6 rounded text-pi-muted hover:text-pi-accent hover:bg-pi-user-bg cursor-pointer",children:B.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",children:[B.jsx("line",{x1:"1.5",y1:"1.5",x2:"8.5",y2:"8.5"}),B.jsx("line",{x1:"8.5",y1:"1.5",x2:"1.5",y2:"8.5"})]})})]},S.file)})})]})}function Rv({part:i}){return i.type==="text"?B.jsx("div",{dangerouslySetInnerHTML:{__html:_v(i.content||"")}}):i.type==="thinking"?null:i.type==="tool"?B.jsx(Av,{part:i}):null}function Av({part:i}){const r=x.useMemo(()=>bv(i),[i]),s=i.name==="edit"?"":"max-h-64",f=i.name==="edit"?"overflow-x-auto":"overflow-auto";return B.jsx("div",{className:"my-0 px-1.5 py-1 text-xs overflow-hidden bg-pi-user-bg",children:B.jsx("pre",{className:`tool-io-pre ${s} ${f} ${i.isError?"text-pi-error":"text-pi-tool-output"}`,children:r})})}function _v(i){const r=i.split(`
|
|
46
|
-
`),s=[];let f=0;for(;f<r.length;){const d=r[f];if(/^```/.test(d)){const S=d.slice(3).trim(),_=[];for(f++;f<r.length&&!/^```/.test(r[f]);)_.push(Ur(r[f])),f++;s.push(`<pre class="bg-pi-
|
|
47
|
-
`)}</code></pre>`),f++;continue}if(/^\|/.test(d)&&f+1<r.length&&/^\|[\s\-:|]+\|/.test(r[f+1])){const S=Km(r[f]),_=zv(r[f+1]);f+=2;const b=[];for(;f<r.length&&/^\|/.test(r[f]);)b.push(Km(r[f])),f++;const y=S.map((R,L)=>`<th class="border border-pi-border-muted px-3 py-1.5 bg-pi-page-bg font-semibold text-left" style="${Jm(_[L])}">${ac(R)}</th>`).join(""),O=b.map(R=>`<tr>${R.map((L,Z)=>`<td class="border border-pi-border-muted px-3 py-1.5" style="${Jm(_[Z])}">${ac(L)}</td>`).join("")}</tr>`).join("");s.push(`<div class="overflow-x-auto my-2"><table class="border-collapse text-xs w-full"><thead><tr>${y}</tr></thead><tbody>${O}</tbody></table></div>`);continue}const m=d.match(/^(#{1,6})\s+(.*)/);if(m){const S=m[1].length,_=["text-lg","text-base","text-sm","text-sm","text-xs","text-xs"];s.push(`<h${S} class="font-semibold ${_[S-1]} mt-3 mb-1 text-pi-md-heading">${ac(m[2])}</h${S}>`),f++;continue}if(/^(-{3,}|\*{3,}|_{3,})$/.test(d.trim())){s.push('<hr class="border-t border-pi-border-muted my-3">'),f++;continue}if(d.trim()===""){s.push("<br>"),f++;continue}s.push(`<span>${ac(d)}</span><br>`),f++}return s.join("")}function Km(i){return i.replace(/^\||\|$/g,"").split("|").map(r=>r.trim())}function zv(i){return i.replace(/^\||\|$/g,"").split("|").map(r=>(r=r.trim(),r.startsWith(":")&&r.endsWith(":")?"center":r.endsWith(":")?"right":"left"))}function Jm(i){return`text-align:${i}`}function ac(i){let r=Ur(i);return r=r.replace(/`([^`]+)`/g,'<code class="bg-pi-
|
|
45
|
+
${f}`),S}function Sv(){const i=ch(),r=Xl(),[s,f]=x.useState([]),[d,m]=x.useState([]),[S,_]=x.useState(!1),[b,y]=x.useState(!1),[O,R]=x.useState(""),[L,Z]=x.useState(!1),[q,V]=x.useState(yv),[G,tt]=x.useState(null),[ft,et]=x.useState([]),[At,Tt]=x.useState(!1),[Ht,nt]=x.useState(null),[bt,ue]=x.useState([]),[Mt,ye]=x.useState(null),[Zt,pe]=x.useState("off"),[ie,Qt]=x.useState(""),[N,Q]=x.useState([]),[I,vt]=x.useState([]),[Rt,v]=x.useState(null),[U,X]=x.useState(null),[K,ut]=x.useState(!1),it=x.useMemo(()=>r.pathname.split("/").filter(Boolean),[r.pathname]),dt=it[0],Dt=it[1],Yt=it.length>2,at=x.useMemo(()=>Xm(dt),[dt]),Bt=x.useMemo(()=>Dt==null||Dt===Nr?null:Xm(Dt),[Dt]),yl=it.length===0,pl=it.length===1,be=it.length===2,ce=Dt===Nr,Tn=x.useMemo(()=>{const p=new URLSearchParams(r.search).get("cwd");if(!p)return null;const T=p.trim();return T.length>0?T:null},[r.search]),Zn=x.useRef(null),Ql=x.useRef(null),Se=x.useRef(null),Te=x.useRef(null),Fe=x.useRef(null),ja=x.useRef(null),Ne=x.useRef(null),fe=x.useRef([]),Zl=x.useRef(null),vl=x.useRef([]),Rn=x.useRef(null),Ie=x.useRef(!1),gl=x.useRef(null),bl=x.useRef(new Map),Vn=x.useRef(!1),ve=x.useRef(null),Pe=x.useRef(null),re=x.useRef(!1),tl=x.useRef(!1),Gt=x.useRef(null),el=x.useRef(null),Vl=x.useRef(!1),Kn=x.useRef(null),Ye=x.useMemo(()=>mv(Mt),[Mt]);x.useEffect(()=>{vl.current=s},[s]),x.useEffect(()=>{Rn.current=Bt},[Bt]),x.useEffect(()=>{Ie.current=L},[L]),x.useEffect(()=>{tl.current=b},[b]),x.useEffect(()=>{fe.current=bt},[bt]),x.useEffect(()=>{Zl.current=Mt},[Mt]),x.useEffect(()=>{Pe.current=at},[at]),x.useEffect(()=>{Vn.current=ce},[ce]),x.useEffect(()=>{ce||bl.current.clear()},[ce]),x.useEffect(()=>{Ye||I.length===0||(vt([]),v("Attached files were removed because the selected model does not support file attachments."),Te.current&&(Te.current.value=""))},[I.length,Ye]),x.useEffect(()=>{yl&&V(p=>p===Tn?p:Tn)},[Tn,yl]),x.useEffect(()=>(Wn(),Ge(),()=>{ja.current&&window.clearTimeout(ja.current),Ne.current&&window.clearTimeout(Ne.current),Gt.current&&window.clearInterval(Gt.current),Gt.current=null,el.current?.abort(),el.current=null,Vl.current=!1,Zn.current?.close()}),[]),x.useEffect(()=>{pl&&Ge()},[pl,at]),x.useEffect(()=>{if(!pl)return;const p=window.setInterval(()=>{Ge()},Gm);return()=>window.clearInterval(p)},[pl,at]),x.useEffect(()=>{Ql.current&&requestAnimationFrame(()=>{Ql.current&&(Ql.current.scrollTop=Ql.current.scrollHeight)})},[d,N.length,bt.length,Mt?.id,Mt?.provider]),x.useEffect(()=>{Se.current&&(Se.current.style.height="auto",Se.current.style.height=`${Math.min(Se.current.scrollHeight,200)}px`)},[O]),x.useEffect(()=>{!be||!L||!Nu()||requestAnimationFrame(()=>{const p=Se.current;!p||p.disabled||p.focus()})},[Bt,L,be,ce,at]),x.useEffect(()=>{be||Ie.current&&Yu()},[be]),x.useEffect(()=>{Yt&&i("/",{replace:!0})},[Yt,i]),x.useEffect(()=>{dt!=null&&at==null&&i("/",{replace:!0})},[i,dt,at]),x.useEffect(()=>{dt==null||Dt==null||ce||at!=null&&Bt==null&&i(Cu(at),{replace:!0})},[Bt,ce,i,dt,at,Dt]),x.useEffect(()=>{if(!at||!Bt||Dt==null||ce)return;if(!s.some(T=>T.cwd===at&&T.file===Bt)&&K){const T=ve.current;if(T?.cwd===at&&T?.sessionFile===Bt||re.current)return;i(Cu(at),{replace:!0})}},[Bt,K,ce,i,at,Dt,s]);const Jn=x.useMemo(()=>Array.from(new Set(bt.map(p=>p.provider))),[bt]),$n=x.useMemo(()=>bt.filter(p=>p.provider===ie),[bt,ie]),Sl=Mt?.provider===ie?Mt.id:"",kn=x.useMemo(()=>{const p=Mt?.reasoning===!1?["off"]:yh;return p.includes(Zt)?p:[Zt,...p.filter(T=>T!==Zt)]},[Mt?.reasoning,Zt]),Kl=x.useMemo(()=>Cv(d),[d]),dc=x.useMemo(()=>!q||!G?!1:q!==G,[q,G]),Lu=x.useMemo(()=>at?s.filter(p=>p.cwd===at):[],[at,s]);function Wn(){const p=new WebSocket(ov);Zn.current=p,p.onopen=()=>{if(_(!0),gl.current){const T=gl.current;An(T.cwd,T.sessionFile??null)&&(xe(),ll());return}if(Rn.current||Ie.current){const T=Rn.current,j=T?vl.current.find(Y=>Y.file===T)?.cwd:Pe.current??vl.current[0]?.cwd;if(!T&&!j)return;An(j,T??null)&&(xe(),ll())}},p.onmessage=T=>{let j;try{j=JSON.parse(T.data)}catch{return}j.type==="rpc_event"&&Jl(j.event),j.type==="error"&&(console.error("[pi-web]",j.message),typeof j.message=="string"&&(j.message.toLowerCase().includes("attachment")&&v(j.message),j.message.includes("no active session")&&(Ie.current||gl.current)&&(xe(150),ll()))),j.type==="session_ended"&&(y(!1),Z(!1),ve.current=null,Ge())},p.onclose=()=>{_(!1),y(!1),Z(!1),gl.current=null,bl.current.clear(),ve.current=null,ja.current=window.setTimeout(Wn,2e3)}}function kt(p){return Zn.current?.readyState===WebSocket.OPEN?(Zn.current.send(JSON.stringify(p)),!0):!1}function qu(p,T=12){const j=`route-sync-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;bl.current.set(j,{cwd:p,attemptsLeft:T});const Y=kt({type:"rpc_command",command:{type:"get_state",id:j}});return Y||bl.current.delete(j),Y}function An(p,T){return kt({type:"start_session",sessionFile:T??void 0,cwd:p})?(gl.current=null,ve.current={cwd:p,sessionFile:T??null},Z(!0),Ge(),!0):(gl.current={cwd:p,sessionFile:T},ve.current=null,Z(!1),!1)}function Yu(){kt({type:"detach_session"}),gl.current=null,ve.current=null,Z(!1),y(!1),X(null),Ge()}function Gu(){const p=kt({type:"rpc_command",command:{type:"get_available_models",id:"get_models"}}),T=kt({type:"rpc_command",command:{type:"get_state",id:"get_state"}});return p&&T}function ll(){kt({type:"rpc_command",command:{type:"get_session_stats",id:"get_session_stats"}})}function xe(p=800){Ne.current&&window.clearTimeout(Ne.current),Ne.current=window.setTimeout(()=>{Gu()||xe(p)},p)}async function Ge(){try{const p=await fetch("/api/sessions");f(await p.json())}catch{}finally{ut(!0)}}x.useEffect(()=>{if(!yl)return;const p=new AbortController,T=q?`?cwd=${encodeURIComponent(q)}`:"";return Tt(!0),nt(null),fetch(`/api/folders${T}`,{signal:p.signal}).then(async j=>{if(!j.ok)throw new Error("failed to load folders");return await j.json()}).then(j=>{p.signal.aborted||(V(j.cwd),tt(j.root),et(Array.isArray(j.folders)?j.folders:[]),nt(j.error??null))}).catch(()=>{p.signal.aborted||(et([]),nt("unable to load folders"))}).finally(()=>{p.signal.aborted||Tt(!1)}),()=>p.abort()},[q,yl]),x.useEffect(()=>{if(!be||!at||!Bt||ce){Gt.current&&window.clearInterval(Gt.current),Gt.current=null,el.current?.abort(),el.current=null,Vl.current=!1;return}let p=!1;const T=async()=>{if(p||Vl.current||tl.current&&ve.current?.cwd===at&&ve.current?.sessionFile===Bt)return;Vl.current=!0;const Y=new AbortController;el.current=Y;try{await mc(at,Bt,Y.signal)}catch{}finally{el.current===Y&&(el.current=null),Vl.current=!1}};return T(),Gt.current=window.setInterval(()=>{T()},Gm),()=>{p=!0,Gt.current&&window.clearInterval(Gt.current),Gt.current=null,el.current?.abort(),el.current=null,Vl.current=!1}},[Bt,be,ce,at]);function Fn(p,T){if(typeof p=="string"){T.push({type:"text",content:p,done:!0});return}if(Array.isArray(p)){for(const j of p)if(j.type==="text"&&j.text)T.push({type:"text",content:j.text,done:!0});else if(j.type==="thinking"&&j.thinking)T.push({type:"thinking",content:j.thinking,done:!0});else if(j.type==="image")T.push({type:"text",content:"[attached image]",done:!0});else if(j.type==="toolCall"||j.type==="tool_call"||j.type==="tool_use"){const Y=j.result!==void 0||j.output!==void 0,k=Uu(j.result??j.output??""),F=ql(j.result);T.push({type:"tool",name:j.name||j.toolName||"tool",args:j.args||j.arguments||j.input,content:k.text,details:k.details,done:Y,id:j.id,isError:!!(j.isError??F?.isError)})}}}function nl(p){return p.map(T=>{const j=[];T.content&&Fn(T.content,j);const Y=T.timestamp?Number(T.timestamp):void 0;return{id:T.id||crypto.randomUUID(),role:T.role||"unknown",parts:j,model:T.model,provider:T.provider,timestamp:Number.isFinite(Y)?Y:void 0,usage:T.usage}})}function Wt(p){if(p.length===0)return"0";let T=0,j=0,Y=0;for(const W of p){T+=W.parts.length;for(const st of W.parts)typeof st.content=="string"&&(j+=st.content.length),st.type==="tool"&&Y++}const k=p[p.length-1],F=k.parts.map(W=>`${W.type}:${W.done?1:0}:${W.name||""}:${typeof W.content=="string"?W.content.length:0}`).join("|");return[p.length,T,j,Y,k.role,k.timestamp??"",F].join("::")}function le(p){if(p.length===0)return null;if(Fe.current){const T=p.findIndex(j=>j.id===Fe.current);return T<0?null:{target:p[T],index:T}}for(let T=p.length-1;T>=0;T--)if(p[T].role==="assistant")return{target:p[T],index:T};return null}function Jl(p){if(p?.type)switch(p.type){case"response":{if(p.command==="get_available_models"){const T=(p.data?.models??[]).map(j=>nc(j)).filter(j=>j!=null);T.length>0?(ue(T),fe.current=T,Ne.current&&window.clearTimeout(Ne.current),Zl.current||xe()):xe(),ll()}if(p.command==="get_state"){const T=p.data??{},j=nc(T.model);j?(ye(j),Zl.current=j,Qt(j.provider),Ne.current&&window.clearTimeout(Ne.current),fe.current.length===0&&xe()):xe();const Y=Ou(T.thinkingLevel);Y&&pe(Y);const k=typeof p.id=="string"?p.id:"",F=k?bl.current.get(k):void 0;if(F){bl.current.delete(k);const W=typeof T.sessionFile=="string"?T.sessionFile.split("/").pop()??"":"",st=typeof T.messageCount=="number"?T.messageCount:0;W&&st>0&&Vn.current&&Pe.current===F.cwd?(f(jt=>jt.some(wt=>wt.file===W)?jt:[{id:typeof T.sessionId=="string"&&T.sessionId?T.sessionId:W,file:W,cwd:F.cwd,timestamp:new Date().toISOString(),messageCount:Math.max(st,1)},...jt]),ve.current={cwd:F.cwd,sessionFile:W},re.current=!0,i(Qm(F.cwd,W),{replace:!0})):F.attemptsLeft>0&&Vn.current&&Pe.current===F.cwd&&window.setTimeout(()=>{Vn.current&&Pe.current===F.cwd&&qu(F.cwd,F.attemptsLeft-1)},250)}}if(p.command==="set_model"&&p.success){const T=nc(p.data);T&&(ye(T),Zl.current=T),kt({type:"rpc_command",command:{type:"get_state",id:"get_state"}})}if(p.command==="set_thinking_level"&&p.success){const T=Ou(p.data?.level);T&&pe(T),kt({type:"rpc_command",command:{type:"get_state",id:"get_state"}})}if(p.command==="cycle_thinking_level"&&p.success){const T=Ou(p.data?.level);T&&pe(T),kt({type:"rpc_command",command:{type:"get_state",id:"get_state"}})}p.command==="get_session_stats"&&p.success&&X(p.data);break}case"agent_start":y(!0),Ge();break;case"agent_end":y(!1),Fe.current=null,Ge(),ll(),(fe.current.length===0||!Zl.current)&&xe(),Q(T=>{if(T.length===0)return T;const[j,...Y]=T;return kt({type:"rpc_command",command:{type:"prompt",message:j.message,images:j.images.length>0?j.images:void 0,id:`web-${Date.now()}`}}),Y});break;case"message_start":{const T=p.message;if(!T)break;const j=T.id||crypto.randomUUID(),Y=T.role||"assistant";if(Y==="toolResult"||Y==="tool_result"||Y==="tool")break;const k=[];T.content&&Fn(T.content,k);const F={id:j,role:Y,parts:k,model:T.model,provider:T.provider,timestamp:typeof T.timestamp=="number"?T.timestamp:void 0,usage:T.usage};Y==="assistant"&&(Fe.current=j),m(W=>W.some(st=>st.id===j)?W:[...W,F]);break}case"message_update":{const T=p.assistantMessageEvent,j=T?.type==="thinking_delta",Y=T?.type==="text_delta"||T?.type==="thinking_delta"?T.delta:void 0;if(!Y)break;m(k=>{const F=le(k);if(!F)return k;const W=[...F.target.parts],st=j?"thinking":"text";let jt=W.find(wt=>wt.type===st&&!wt.done);jt||(jt={type:st,content:""},W.push(jt)),jt.content=`${jt.content||""}${Y}`;const De=[...k];return De[F.index]={...F.target,parts:W},De});break}case"message_end":{const T=p.message;if(T?.role&&T.role!=="assistant")break;const j=typeof T?.timestamp=="number"?T.timestamp:void 0,Y=Fe.current;m(k=>k.map(F=>{if(F.id!==Y)return F;const W=j??F.timestamp;if(T?.content){const st=[];return Fn(T.content,st),{...F,parts:st,model:T.model??F.model,provider:T.provider??F.provider,timestamp:W,usage:T.usage??F.usage}}return{...F,parts:F.parts.map(st=>({...st,done:!0})),timestamp:W,usage:T?.usage??F.usage}}));break}case"tool_execution_start":{const T=p.toolCallId||p.id;m(j=>{const Y=le(j);if(!Y)return j;const k=[...Y.target.parts],F=k.findIndex(st=>st.type==="tool"&&st.id&&T&&st.id===T);if(F>=0){const st=k[F];k[F]={...st,type:"tool",name:p.toolName||p.name||st.name||"tool",args:p.args??st.args,content:st.content??"",done:!1,id:T,details:st.details,isError:!1}}else k.push({type:"tool",name:p.toolName||p.name||"tool",args:p.args,content:"",done:!1,id:T,isError:!1});const W=[...j];return W[Y.index]={...Y.target,parts:k},W});break}case"tool_execution_update":{const T=p.toolCallId||p.id,j=p.partialResult!==void 0,Y=Uu(j?p.partialResult:p.output);m(k=>{const F=le(k);if(!F)return k;const W=[...F.target.parts],st=[...W].reverse(),jt=st.find(wt=>wt.type==="tool"&&!wt.done&&(!T||wt.id===T))||st.find(wt=>wt.type==="tool"&&!wt.done);jt&&(p.args!==void 0&&(jt.args=p.args),j?jt.content=Y.text:Y.text&&(jt.content=`${En(jt.content)}${Y.text}`),Y.details!==void 0&&(jt.details=Y.details));const De=[...k];return De[F.index]={...F.target,parts:W},De});break}case"tool_execution_end":{const T=p.toolCallId||p.id,j=Uu(p.result??p.output??""),Y=p.result!==void 0||p.output!==void 0;m(k=>{const F=le(k);if(!F)return k;const W=[...F.target.parts],st=[...W].reverse(),jt=st.find(wt=>wt.type==="tool"&&!wt.done&&(!T||wt.id===T))||st.find(wt=>wt.type==="tool"&&!wt.done);jt&&(p.args!==void 0&&(jt.args=p.args),jt.done=!0,jt.isError=!!p.isError,Y&&(jt.content=j.text),j.details!==void 0&&(jt.details=j.details));const De=[...k];return De[F.index]={...F.target,parts:W},De});break}case"model_changed":{const T=nc(p.model);T&&(ye(T),Zl.current=T);const j=Ou(p.thinkingLevel??p.level);j&&pe(j);break}}}async function Ha(p,T){try{const j=await fetch(`/api/session?cwd=${encodeURIComponent(p)}&filename=${encodeURIComponent(T)}`);if(!j.ok)return;const Y=await j.json(),k=nl(Y);Kn.current=Wt(k),m(k)}catch{}}async function mc(p,T,j){const Y=await fetch(`/api/session?cwd=${encodeURIComponent(p)}&filename=${encodeURIComponent(T)}`,{signal:j});if(!Y.ok)return;const k=await Y.json(),F=nl(k),W=Wt(F);W!==Kn.current&&(Kn.current=W,m(F),Ge())}function Xu(){m([]),R(""),vt([]),v(null),Te.current&&(Te.current.value=""),Fe.current=null,y(!1),X(null),Kn.current=null,Ne.current&&window.clearTimeout(Ne.current)}async function Qu(p,T){if(Ie.current&&ve.current?.sessionFile===T&&ve.current?.cwd===p){Nu()&&Se.current?.focus();return}Xu(),await Ha(p,T),An(p,T)&&(xe(120),ll()),Nu()&&Se.current?.focus()}function _n(p){if(Ie.current&&ve.current?.sessionFile===null&&ve.current?.cwd===p){Nu()&&Se.current?.focus();return}Xu(),An(p,null)&&(xe(120),ll()),Nu()&&Se.current?.focus()}x.useEffect(()=>{if(!at||Dt==null)return;if(ce){_n(at);return}if(!(!Bt||!s.some(T=>T.cwd===at&&T.file===Bt))){if(re.current){re.current=!1,ve.current={cwd:at,sessionFile:Bt};return}Qu(at,Bt)}},[Bt,ce,at,Dt,s]);function Ba(p){const T=vl.current.find(j=>j.file===p)?.cwd;T&&i(Qm(T,p))}function $l(p){i(dv(p))}function kl(p){i(Cu(p))}function zn(p){i(lc(p))}function Wl(){if(!q||!G||q===G)return;const p=q.split("/").filter(Boolean),T=p.length<=1?"/":`/${p.slice(0,-1).join("/")}`;i(lc(T))}function Ft(){q&&kl(q)}function wa(){i(lc(at??q))}function Zu(){if(!at){i(lc(q));return}i(Cu(at))}async function xl(p){if(!p||p.length===0)return;if(!Ye){v("Selected model does not support file attachments.");return}const T=Array.from(p),j=[];let Y=0,k=0;for(const W of T){if(!W.type.startsWith("image/")){Y++;continue}try{const st=await hv(W);j.push({id:crypto.randomUUID(),type:"image",data:st,mimeType:W.type,name:W.name,size:W.size})}catch{k++}}j.length>0&&vt(W=>[...W,...j]);const F=[];Y>0&&F.push(`${Y} non-image file${Y===1?"":"s"} ignored`),k>0&&F.push(`${k} file${k===1?"":"s"} could not be read`),v(F.length>0?F.join(". "):null)}function Fl(){if(L){if(!Ye){v("Selected model does not support file attachments.");return}Te.current?.click()}}function hc(p){vt(T=>T.filter(j=>j.id!==p)),v(null)}function La(){const p=O.trim();if(!p&&I.length===0||!S||!L)return;if(I.length>0&&!Ye){v("Selected model does not support file attachments.");return}const T=I.map(Y=>({type:"image",data:Y.data,mimeType:Y.mimeType}));if(R(""),vt([]),v(null),Te.current&&(Te.current.value=""),ph()&&Se.current?.blur(),b){Q(Y=>[...Y,{id:`queued-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,message:p,images:T}]);return}kt({type:"rpc_command",command:{type:"prompt",message:p,images:T.length>0?T:void 0,id:`web-${Date.now()}`}})&&ce&&at&&qu(at)}function Vu(){kt({type:"rpc_command",command:{type:"abort",id:`abort-${Date.now()}`}})}function yc(p){Qt(p)}function In(p){const T=bt.find(j=>j.id===p&&j.provider===ie);T&&kt({type:"rpc_command",command:{type:"set_model",provider:T.provider,modelId:T.id,id:"set_model"}})}function Pn(p){const T=Ou(p);T&&(pe(T),kt({type:"rpc_command",command:{type:"set_thinking_level",level:T,id:"set_thinking_level"}}))}async function al(p){const T=vl.current.find(Y=>Y.file===p)?.cwd??at??"";try{await fetch(`/api/session?cwd=${encodeURIComponent(T)}&filename=${encodeURIComponent(p)}`,{method:"DELETE"})}catch{}f(Y=>Y.filter(k=>k.file!==p));const j=at??vl.current.find(Y=>Y.file===p)?.cwd;Rn.current===p&&(m([]),R(""),vt([]),v(null),Te.current&&(Te.current.value=""),Fe.current=null,y(!1),Z(!1),X(null),i(j?Cu(j):"/"))}const Re=b?"streaming response":"session status";return B.jsxs("div",{className:"flex flex-col h-full bg-pi-page-bg text-pi-text text-sm font-mono overflow-hidden",children:[yl&&B.jsx("main",{className:"flex-1 overflow-y-auto px-4 py-5 md:px-6",children:B.jsx(Ev,{cwd:q,folders:ft,isLoading:At,error:Ht,canNavigateUp:dc,onBrowseIntoFolder:zn,onBrowseToParent:Wl,onOpenCurrentFolder:Ft})}),pl&&at&&B.jsx("main",{className:"flex-1 overflow-y-auto px-4 py-5 md:px-6",children:B.jsx(Tv,{projectCwd:at,sessions:Lu,onBack:wa,onCreateSession:()=>$l(at),onSelectSession:Ba,onDeleteSession:al})}),pl&&!at&&B.jsx("main",{className:"flex-1 overflow-y-auto px-4 py-5 md:px-6",children:B.jsxs("div",{className:"mx-auto max-w-3xl rounded-xl border border-pi-border-muted bg-pi-card-bg p-4",children:[B.jsx("div",{className:"text-sm text-pi-muted mb-3",children:"no folder selected"}),B.jsx("button",{onClick:wa,className:"px-3 py-1.5 rounded-lg border border-pi-border-muted text-pi-muted hover:text-pi-accent hover:bg-pi-user-bg cursor-pointer",children:"choose folder"})]})}),be&&B.jsxs("main",{className:"flex-1 flex flex-col min-h-0",children:[B.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 md:px-6 border-b border-pi-border-muted bg-pi-card-bg",children:[B.jsxs("div",{className:"min-w-0",children:[B.jsx("div",{className:"text-[11px] text-pi-dim truncate",children:at?sv(at):"folder not selected"}),B.jsx("div",{className:"text-xs truncate text-pi-muted",children:Bt?Bt.split("/").pop():"new session"})]}),B.jsx("button",{onClick:Zu,title:"back to sessions",className:"ml-auto inline-flex items-center justify-center h-10 w-10 shrink-0 aspect-square rounded-lg border border-pi-border-muted text-pi-muted hover:text-pi-accent hover:bg-pi-user-bg cursor-pointer",children:B.jsx("svg",{width:"18",height:"18",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:B.jsx("polyline",{points:"10.5,3 5,8 10.5,13"})})})]}),B.jsx("div",{ref:Ql,className:"flex-1 overflow-y-auto px-4 py-2 md:px-6",children:d.length===0&&N.length===0?B.jsx("div",{className:"flex items-center justify-center h-full text-pi-muted text-base",children:"choose a session and start prompting."}):(()=>{const p=d.filter(Y=>(Y.role==="user"||Y.role==="assistant")&&(Y.role==="user"||Y.parts.some(k=>k.type==="tool"||k.type==="text"&&(k.content??"").trim()))),T=d.filter(Y=>(Y.role==="steering"||Y.role==="system")&&Y.parts.some(k=>k.type==="text"&&(k.content??"").trim())),j=N.map(Y=>{const k=Y.message.trim(),F=Y.images.length>0?Y.images.length===1?"[queued image]":`[${Y.images.length} queued images]`:"[queued message]";return{id:Y.id,role:"steering",parts:[{type:"text",content:k||F,done:!0}]}});return[...p,...T,...j].map(Y=>B.jsx(xv,{msg:Y},Y.id))})()}),B.jsxs("div",{className:"flex items-center gap-3 px-4 py-1.5 md:px-6 border-t border-pi-border-muted bg-pi-card-bg text-xs text-pi-muted flex-wrap",children:[(bt.length>0||Mt)&&B.jsxs("span",{className:"flex items-center gap-2.5 flex-wrap",children:[bt.length>0&&B.jsxs(B.Fragment,{children:[B.jsx("select",{value:ie,onChange:p=>yc(p.target.value),disabled:b,className:"font-mono text-pi-control-fg bg-pi-control-bg border border-pi-border-muted rounded px-1 py-0.5 cursor-pointer disabled:opacity-50 select-fit-content",children:Jn.map(p=>B.jsx("option",{value:p,children:p},p))}),B.jsx("select",{value:Sl,onChange:p=>In(p.target.value),disabled:b,className:"font-mono text-pi-control-fg bg-pi-control-bg border border-pi-border-muted rounded px-1 py-0.5 cursor-pointer disabled:opacity-50 select-fit-content",children:$n.map(p=>B.jsx("option",{value:p.id,children:p.id},p.id))})]}),bt.length===0&&Mt&&B.jsx("span",{children:Mt.id}),L&&B.jsx("select",{value:Zt,onChange:p=>Pn(p.target.value),disabled:!S||b||Mt?.reasoning===!1,"aria-label":"thinking level",title:"thinking level",className:"font-mono text-pi-control-fg bg-pi-control-bg border border-pi-border-muted rounded px-1 py-0.5 cursor-pointer disabled:opacity-50 select-fit-content",children:kn.map(p=>B.jsx("option",{value:p,children:p},p))})]}),U&&B.jsxs("span",{className:"flex items-center gap-2 text-pi-dim ml-auto flex-wrap",children:[U.tokens.input>0&&B.jsxs("span",{children:["↑",Du(U.tokens.input)]}),U.tokens.output>0&&B.jsxs("span",{children:["↓",Du(U.tokens.output)]}),U.tokens.cacheRead>0&&B.jsxs("span",{children:["r",Du(U.tokens.cacheRead)]}),U.tokens.cacheWrite>0&&B.jsxs("span",{children:["w",Du(U.tokens.cacheWrite)]}),U.cost>0&&B.jsxs("span",{children:["$",U.cost.toFixed(2)]}),Mt?.contextWindow&&Kl&&(()=>{const p=Kl/Mt.contextWindow*100,T=p>90?"text-pi-error":p>70?"text-pi-warning":"";return B.jsxs("span",{className:T,children:[p.toFixed(0),"%/",Du(Mt.contextWindow)]})})()]})]}),B.jsxs("div",{className:"px-4 pb-4 pt-3 md:px-6 border-t border-pi-border-muted bg-pi-card-bg",children:[B.jsx("input",{ref:Te,type:"file",accept:"image/*",multiple:!0,className:"hidden",onChange:p=>{xl(p.target.files),p.target.value=""}}),I.length>0&&B.jsx("div",{className:"mb-2 flex flex-wrap gap-1.5",children:I.map(p=>B.jsxs("span",{className:"inline-flex items-center gap-1 rounded-md border border-pi-border-muted bg-pi-user-bg px-2 py-1 text-[11px] text-pi-muted",title:p.name,children:[B.jsxs("span",{className:"max-w-[180px] truncate",children:[p.name," (",Dr(p.size),")"]}),B.jsx("button",{onClick:()=>hc(p.id),title:"remove attachment",className:"inline-flex h-4 w-4 items-center justify-center rounded text-pi-muted hover:text-pi-accent cursor-pointer",children:"×"})]},p.id))}),Rt&&B.jsx("div",{className:"mb-2 text-[11px] text-pi-warning",children:Rt}),B.jsxs("div",{className:"flex gap-2 items-center",children:[B.jsx("span",{className:"sr-only","aria-live":"polite",children:Re}),B.jsx("textarea",{ref:Se,rows:1,placeholder:L?"send a message...":"create or select a session",disabled:!L,value:O,onChange:p=>R(p.target.value),onKeyDown:p=>{p.key==="Enter"&&!p.shiftKey&&(p.preventDefault(),La())},className:"prompt-input flex-1 bg-pi-control-bg text-pi-control-fg border border-pi-border-muted rounded-lg px-3 py-2.5 font-mono leading-5 resize-none min-h-[var(--composer-control-size)] max-h-[200px] outline-none focus:border-pi-accent disabled:opacity-50 disabled:cursor-default"}),B.jsxs("div",{className:"flex flex-row gap-1 flex-shrink-0",children:[B.jsx("button",{onClick:Fl,disabled:!L||!Ye,title:L?Ye?"attach file":"selected model does not support file attachments":"create or select a session","aria-label":"attach file",className:"h-[var(--composer-control-size)] aspect-square inline-flex items-center justify-center flex-shrink-0 rounded-lg border border-pi-border-muted text-pi-muted hover:text-pi-accent hover:bg-pi-user-bg cursor-pointer disabled:opacity-40 disabled:cursor-default",children:B.jsx("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:B.jsx("path",{d:"M6 9.5 10.8 4.7a2.8 2.8 0 1 1 4 4L8.5 15a4 4 0 1 1-5.7-5.7L8.3 3.8"})})}),B.jsx("button",{onClick:La,disabled:!S,title:b?"queue message":"send","aria-label":b?"queue message":"send message",className:"h-[var(--composer-control-size)] aspect-square inline-flex items-center justify-center flex-shrink-0 rounded-lg bg-pi-accent text-white cursor-pointer hover:opacity-90 disabled:opacity-40 disabled:cursor-default disabled:bg-pi-border-muted",children:B.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[B.jsx("line",{x1:"2",y1:"9",x2:"16",y2:"9"}),B.jsx("polyline",{points:"10,3 16,9 10,15"})]})}),B.jsx("button",{onClick:Vu,disabled:!b||!L,title:"stop",className:"h-[var(--composer-control-size)] aspect-square inline-flex items-center justify-center flex-shrink-0 rounded-lg border border-pi-border-muted text-pi-muted hover:text-pi-accent hover:bg-pi-user-bg cursor-pointer disabled:opacity-40 disabled:cursor-default",children:B.jsx("svg",{width:"20",height:"20",viewBox:"0 0 18 18",fill:"currentColor",children:B.jsx("rect",{x:"4",y:"4",width:"10",height:"10",rx:"1.5"})})})]})]})]})]})]})}function xv({msg:i}){const r=i.role==="user",s=i.role==="steering"||i.role==="system",f=i.parts.some(_=>_.type==="text"&&!!(_.content??"").trim()),d=i.parts.some(_=>_.type==="tool"),m=!r&&!s&&d&&!f,S=r?"bg-pi-card-bg border border-pi-border-muted":m?"bg-pi-tool-success border border-pi-border-muted":"bg-pi-tool-pending border border-pi-border-muted";return B.jsx("div",{className:"mb-2 min-w-0",children:B.jsx("div",{className:`rounded-lg ${m?"p-0":"px-2 py-1.5"} min-w-0 overflow-hidden ${S}`,children:B.jsx("div",{className:`text-xs md:text-sm leading-relaxed break-words min-w-0 ${s?"text-pi-muted":""}`,children:i.parts.map((_,b)=>B.jsx(Rv,{part:_},`${i.id}-${b}`))})})})}function Ev({cwd:i,folders:r,isLoading:s,error:f,canNavigateUp:d,onBrowseIntoFolder:m,onBrowseToParent:S,onOpenCurrentFolder:_}){return B.jsxs("div",{className:"mx-auto max-w-3xl",children:[B.jsxs("div",{className:"mb-4 flex items-start justify-between gap-3",children:[B.jsxs("div",{className:"min-w-0",children:[B.jsx("h1",{className:"text-base md:text-lg font-semibold text-pi-accent",children:"browse folders"}),B.jsx("p",{className:"text-pi-muted mt-1 truncate",title:i??"",children:i?Da(i):"loading…"})]}),B.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[B.jsx("button",{onClick:_,disabled:!i,title:"open current folder","aria-label":"open current folder",className:"inline-flex items-center justify-center h-10 w-10 shrink-0 aspect-square rounded-lg border border-pi-border-muted text-pi-muted hover:text-pi-accent hover:bg-pi-user-bg cursor-pointer disabled:opacity-40 disabled:cursor-default",children:B.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[B.jsx("path",{d:"M1.5 6.1V4.8a1 1 0 0 1 1-1h3l1.3 1.3h6.7a1 1 0 0 1 1 1v.8"}),B.jsx("path",{d:"M1.5 6.9h13l-1.2 5.2a1 1 0 0 1-1 .8H3.7a1 1 0 0 1-1-.8L1.5 6.9Z"})]})}),B.jsx("button",{onClick:S,disabled:!d,title:"back",className:"inline-flex items-center justify-center h-10 w-10 shrink-0 aspect-square rounded-lg border border-pi-border-muted text-pi-muted hover:text-pi-accent hover:bg-pi-user-bg cursor-pointer disabled:opacity-40 disabled:cursor-default",children:B.jsx("svg",{width:"18",height:"18",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:B.jsx("polyline",{points:"10.5,3 5,8 10.5,13"})})})]})]}),B.jsxs("div",{className:"rounded-xl border border-pi-border-muted bg-pi-card-bg",children:[s&&B.jsx("div",{className:"px-4 py-6 text-center text-pi-muted",children:"loading folders…"}),!s&&f&&B.jsx("div",{className:"px-4 py-6 text-center text-pi-error",children:f}),!s&&!f&&r.length===0&&B.jsx("div",{className:"px-4 py-6 text-center text-pi-muted",children:"no visible folders here."}),!s&&!f&&r.length>0&&B.jsx("div",{className:"divide-y divide-pi-border-muted",children:r.map(b=>B.jsx("button",{onClick:()=>m(b.path),className:"w-full text-left px-4 py-3 hover:bg-pi-user-bg cursor-pointer",title:b.path,children:B.jsx("div",{className:"text-sm text-pi-text truncate",children:b.name})},b.path))})]})]})}function Tv({projectCwd:i,sessions:r,onBack:s,onCreateSession:f,onSelectSession:d,onDeleteSession:m}){return B.jsxs("div",{className:"mx-auto max-w-3xl",children:[B.jsxs("div",{className:"mb-4 flex items-start gap-3 justify-between",children:[B.jsxs("div",{className:"min-w-0",children:[B.jsx("h1",{className:"text-base md:text-lg font-semibold text-pi-accent",children:"choose a session"}),B.jsx("p",{className:"text-pi-muted mt-1 truncate",title:i,children:i})]}),B.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[B.jsx("button",{onClick:f,title:"new session",className:"inline-flex items-center justify-center h-10 w-10 shrink-0 aspect-square rounded-lg border border-pi-border-muted text-pi-muted hover:text-pi-accent hover:bg-pi-user-bg cursor-pointer",children:B.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[B.jsx("line",{x1:"8",y1:"3",x2:"8",y2:"13"}),B.jsx("line",{x1:"3",y1:"8",x2:"13",y2:"8"})]})}),B.jsx("button",{onClick:s,title:"back to folders",className:"inline-flex items-center justify-center h-10 w-10 shrink-0 aspect-square rounded-lg border border-pi-border-muted text-pi-muted hover:text-pi-accent hover:bg-pi-user-bg cursor-pointer",children:B.jsx("svg",{width:"18",height:"18",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:B.jsx("polyline",{points:"10.5,3 5,8 10.5,13"})})})]})]}),r.length===0?B.jsx("div",{className:"rounded-xl border border-dashed border-pi-border-muted bg-pi-card-bg px-4 py-6 text-center text-pi-muted",children:"no sessions in this folder yet."}):B.jsx("div",{className:"space-y-2",children:r.map(S=>{const _=S.firstPrompt||S.id.slice(0,8),b=S.timestamp?new Date(S.timestamp).toLocaleString():"",y=!!S.isWorking,O=!!S.isActive,R=y?"working":O?"active":"idle",L=y?"bg-pi-success animate-pulse-dot":O?"bg-pi-accent":"bg-pi-border-muted";return B.jsxs("div",{className:"group relative w-full text-left rounded-xl border border-pi-border-muted bg-pi-card-bg px-4 py-3 hover:bg-pi-user-bg",children:[B.jsxs("button",{onClick:()=>d(S.file),className:"w-full text-left cursor-pointer",children:[B.jsx("div",{className:"text-sm text-pi-text truncate pr-8",children:_}),B.jsxs("div",{className:"text-[11px] text-pi-muted mt-1 flex items-center gap-1.5 flex-wrap",children:[B.jsxs("span",{children:[S.messageCount," msgs"]}),B.jsx("span",{children:"·"}),B.jsx("span",{children:b}),B.jsx("span",{children:"·"}),B.jsxs("span",{className:"inline-flex items-center gap-1",children:[B.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${L}`}),R]})]})]}),B.jsx("button",{onClick:()=>m(S.file),title:"delete session",className:"absolute top-3 right-3 inline-flex items-center justify-center w-6 h-6 rounded text-pi-muted hover:text-pi-accent hover:bg-pi-user-bg cursor-pointer",children:B.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",children:[B.jsx("line",{x1:"1.5",y1:"1.5",x2:"8.5",y2:"8.5"}),B.jsx("line",{x1:"8.5",y1:"1.5",x2:"1.5",y2:"8.5"})]})})]},S.file)})})]})}function Rv({part:i}){return i.type==="text"?B.jsx("div",{dangerouslySetInnerHTML:{__html:_v(i.content||"")}}):i.type==="thinking"?null:i.type==="tool"?B.jsx(Av,{part:i}):null}function Av({part:i}){const r=x.useMemo(()=>bv(i),[i]),s=i.name==="edit"?"":"max-h-64",f=i.name==="edit"?"overflow-x-auto":"overflow-auto";return B.jsx("div",{className:"my-0 px-1.5 py-1 text-xs overflow-hidden bg-pi-tool-success",children:B.jsx("pre",{className:`tool-io-pre ${s} ${f} ${i.isError?"text-pi-error":"text-pi-tool-output"}`,children:r})})}function _v(i){const r=i.split(`
|
|
46
|
+
`),s=[];let f=0;for(;f<r.length;){const d=r[f];if(/^```/.test(d)){const S=d.slice(3).trim(),_=[];for(f++;f<r.length&&!/^```/.test(r[f]);)_.push(Ur(r[f])),f++;s.push(`<pre class="bg-pi-tool-success border border-pi-border-muted rounded-lg p-3 overflow-x-auto my-2 text-xs font-mono text-pi-md-code-block"><code${S?` class="language-${Ur(S)}"`:""}>${_.join(`
|
|
47
|
+
`)}</code></pre>`),f++;continue}if(/^\|/.test(d)&&f+1<r.length&&/^\|[\s\-:|]+\|/.test(r[f+1])){const S=Km(r[f]),_=zv(r[f+1]);f+=2;const b=[];for(;f<r.length&&/^\|/.test(r[f]);)b.push(Km(r[f])),f++;const y=S.map((R,L)=>`<th class="border border-pi-border-muted px-3 py-1.5 bg-pi-page-bg font-semibold text-left" style="${Jm(_[L])}">${ac(R)}</th>`).join(""),O=b.map(R=>`<tr>${R.map((L,Z)=>`<td class="border border-pi-border-muted px-3 py-1.5" style="${Jm(_[Z])}">${ac(L)}</td>`).join("")}</tr>`).join("");s.push(`<div class="overflow-x-auto my-2"><table class="border-collapse text-xs w-full"><thead><tr>${y}</tr></thead><tbody>${O}</tbody></table></div>`);continue}const m=d.match(/^(#{1,6})\s+(.*)/);if(m){const S=m[1].length,_=["text-lg","text-base","text-sm","text-sm","text-xs","text-xs"];s.push(`<h${S} class="font-semibold ${_[S-1]} mt-3 mb-1 text-pi-md-heading">${ac(m[2])}</h${S}>`),f++;continue}if(/^(-{3,}|\*{3,}|_{3,})$/.test(d.trim())){s.push('<hr class="border-t border-pi-border-muted my-3">'),f++;continue}if(d.trim()===""){s.push("<br>"),f++;continue}s.push(`<span>${ac(d)}</span><br>`),f++}return s.join("")}function Km(i){return i.replace(/^\||\|$/g,"").split("|").map(r=>r.trim())}function zv(i){return i.replace(/^\||\|$/g,"").split("|").map(r=>(r=r.trim(),r.startsWith(":")&&r.endsWith(":")?"center":r.endsWith(":")?"right":"left"))}function Jm(i){return`text-align:${i}`}function ac(i){let r=Ur(i);return r=r.replace(/`([^`]+)`/g,'<code class="bg-pi-tool-success text-pi-md-code px-1 py-0.5 rounded text-xs font-mono">$1</code>'),r=r.replace(/\*\*\*([^*]+)\*\*\*/g,"<strong><em>$1</em></strong>"),r=r.replace(/\*\*([^*]+)\*\*/g,"<strong>$1</strong>"),r=r.replace(/\*([^*\n]+)\*/g,"<em>$1</em>"),r=r.replace(/~~([^~]+)~~/g,"<del class='opacity-60'>$1</del>"),r=r.replace(/\[([^\]]+)\]\(([^)]+)\)/g,'<a href="$2" target="_blank" rel="noopener" class="text-pi-md-link underline">$1</a>'),r}function Ur(i){return i.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function Mv(i){if(!i)return 0;if(typeof i.totalTokens=="number"&&Number.isFinite(i.totalTokens))return i.totalTokens;const r=typeof i.input=="number"&&Number.isFinite(i.input)?i.input:0,s=typeof i.output=="number"&&Number.isFinite(i.output)?i.output:0,f=typeof i.cacheRead=="number"&&Number.isFinite(i.cacheRead)?i.cacheRead:0,d=typeof i.cacheWrite=="number"&&Number.isFinite(i.cacheWrite)?i.cacheWrite:0;return r+s+f+d}function $m(i){let r=0;for(const s of i.parts){if(s.type==="text"||s.type==="thinking"){r+=(s.content??"").length;continue}if(s.type==="tool"&&(r+=(s.name??"").length,r+=(s.content??"").length,s.args!=null))try{r+=JSON.stringify(s.args).length}catch{}}return Math.ceil(r/4)}function Cv(i){for(let s=i.length-1;s>=0;s--){const f=i[s];if(f.role!=="assistant")continue;const d=Mv(f.usage);if(d<=0)continue;let m=0;for(let S=s+1;S<i.length;S++)m+=$m(i[S]);return d+m}const r=i.reduce((s,f)=>s+$m(f),0);return r>0?r:null}function Du(i){return i<1e3?String(i):i<1e4?`${(i/1e3).toFixed(1)}k`:i<1e6?`${Math.round(i/1e3)}k`:i<1e7?`${(i/1e6).toFixed(1)}m`:`${Math.round(i/1e6)}m`}j0.createRoot(document.getElementById("root")).render(B.jsx(_0.StrictMode,{children:B.jsx(tv,{children:B.jsx(Sv,{})})}));
|
package/dist/index.html
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
6
|
<title>pi-web</title>
|
|
7
|
-
<script type="module" crossorigin src="/assets/index-
|
|
8
|
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
|
7
|
+
<script type="module" crossorigin src="/assets/index-DWBqDvv7.js"></script>
|
|
8
|
+
<link rel="stylesheet" crossorigin href="/assets/index-DSsvAAeA.css">
|
|
9
9
|
</head>
|
|
10
10
|
<body>
|
|
11
11
|
<div id="root"></div>
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
@import"https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600;700&display=swap";@layer components;@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-space-y-reverse:0;--tw-divide-y-reverse:0;--tw-border-style:solid;--tw-leading:initial;--tw-font-weight:initial}}}@layer theme{:root,:host{--font-sans:ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";--font-mono:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;--color-white:#fff;--spacing:.25rem;--container-3xl:48rem;--text-xs:.75rem;--text-xs--line-height:calc(1 / .75);--text-sm:.875rem;--text-sm--line-height:calc(1.25 / .875);--text-base:1rem;--text-base--line-height: 1.5 ;--text-lg:1.125rem;--text-lg--line-height:calc(1.75 / 1.125);--font-weight-semibold:600;--leading-relaxed:1.625;--radius-md:.375rem;--radius-lg:.5rem;--radius-xl:.75rem;--default-font-family:var(--font-sans);--default-mono-font-family:var(--font-mono);--color-pi-accent:#5a8080;--color-pi-border-muted:#b0b0b0;--color-pi-success:#588458;--color-pi-error:#a55;--color-pi-warning:#9a7326;--color-pi-muted:#6c6c6c;--color-pi-dim:#767676;--color-pi-text:#1f2933;--color-pi-user-bg:#f6f6f6;--color-pi-tool-success:#e8f0e8;--color-pi-md-heading:#9a7326;--color-pi-md-link:#547da7;--color-pi-md-code:#5a8080;--color-pi-md-code-block:#588458;--color-pi-tool-output:#6c6c6c;--color-pi-page-bg:#f8f8f8;--color-pi-card-bg:#fff;--color-pi-control-bg:#fff;--color-pi-control-fg:#1f2933}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;tab-size:4;line-height:1.5;font-family:var(--default-font-family,ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring{outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab,red,red)){::placeholder{color:color-mix(in oklab,currentcolor 50%,transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){appearance:button}::file-selector-button{appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}}@layer utilities{.visible{visibility:visible}.sr-only{clip-path:inset(50%);white-space:nowrap;border-width:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}.absolute{position:absolute}.relative{position:relative}.start{inset-inline-start:var(--spacing)}.top-3{top:calc(var(--spacing) * 3)}.right-3{right:calc(var(--spacing) * 3)}.mx-auto{margin-inline:auto}.my-0{margin-block:calc(var(--spacing) * 0)}.my-2{margin-block:calc(var(--spacing) * 2)}.my-3{margin-block:calc(var(--spacing) * 3)}.mt-1{margin-top:calc(var(--spacing) * 1)}.mt-3{margin-top:calc(var(--spacing) * 3)}.mb-1{margin-bottom:calc(var(--spacing) * 1)}.mb-2{margin-bottom:calc(var(--spacing) * 2)}.mb-3{margin-bottom:calc(var(--spacing) * 3)}.mb-4{margin-bottom:calc(var(--spacing) * 4)}.ml-auto{margin-left:auto}.block{display:block}.contents{display:contents}.flex{display:flex}.hidden{display:none}.inline-flex{display:inline-flex}.aspect-square{aspect-ratio:1}.h-1\.5{height:calc(var(--spacing) * 1.5)}.h-4{height:calc(var(--spacing) * 4)}.h-6{height:calc(var(--spacing) * 6)}.h-10{height:calc(var(--spacing) * 10)}.h-\[var\(--composer-control-size\)\]{height:var(--composer-control-size)}.h-full{height:100%}.max-h-64{max-height:calc(var(--spacing) * 64)}.max-h-\[200px\]{max-height:200px}.min-h-0{min-height:calc(var(--spacing) * 0)}.min-h-\[var\(--composer-control-size\)\]{min-height:var(--composer-control-size)}.w-1\.5{width:calc(var(--spacing) * 1.5)}.w-4{width:calc(var(--spacing) * 4)}.w-6{width:calc(var(--spacing) * 6)}.w-10{width:calc(var(--spacing) * 10)}.w-full{width:100%}.max-w-3xl{max-width:var(--container-3xl)}.max-w-\[180px\]{max-width:180px}.min-w-0{min-width:calc(var(--spacing) * 0)}.flex-1{flex:1}.flex-shrink-0,.shrink-0{flex-shrink:0}.border-collapse{border-collapse:collapse}.cursor-pointer{cursor:pointer}.resize-none{resize:none}.flex-col{flex-direction:column}.flex-row{flex-direction:row}.flex-wrap{flex-wrap:wrap}.items-center{align-items:center}.items-start{align-items:flex-start}.justify-between{justify-content:space-between}.justify-center{justify-content:center}.gap-1{gap:calc(var(--spacing) * 1)}.gap-1\.5{gap:calc(var(--spacing) * 1.5)}.gap-2{gap:calc(var(--spacing) * 2)}.gap-2\.5{gap:calc(var(--spacing) * 2.5)}.gap-3{gap:calc(var(--spacing) * 3)}:where(.space-y-2>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 2) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 2) * calc(1 - var(--tw-space-y-reverse)))}:where(.divide-y>:not(:last-child)){--tw-divide-y-reverse:0;border-bottom-style:var(--tw-border-style);border-top-style:var(--tw-border-style);border-top-width:calc(1px * var(--tw-divide-y-reverse));border-bottom-width:calc(1px * calc(1 - var(--tw-divide-y-reverse)))}:where(.divide-pi-border-muted>:not(:last-child)){border-color:var(--color-pi-border-muted)}.truncate{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.overflow-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.rounded{border-radius:.25rem}.rounded-full{border-radius:3.40282e38px}.rounded-lg{border-radius:var(--radius-lg)}.rounded-md{border-radius:var(--radius-md)}.rounded-xl{border-radius:var(--radius-xl)}.border{border-style:var(--tw-border-style);border-width:1px}.border-t{border-top-style:var(--tw-border-style);border-top-width:1px}.border-b{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.border-dashed{--tw-border-style:dashed;border-style:dashed}.border-pi-border-muted{border-color:var(--color-pi-border-muted)}.bg-pi-accent{background-color:var(--color-pi-accent)}.bg-pi-border-muted{background-color:var(--color-pi-border-muted)}.bg-pi-card-bg{background-color:var(--color-pi-card-bg)}.bg-pi-control-bg{background-color:var(--color-pi-control-bg)}.bg-pi-page-bg{background-color:var(--color-pi-page-bg)}.bg-pi-success{background-color:var(--color-pi-success)}.bg-pi-tool-success{background-color:var(--color-pi-tool-success)}.bg-pi-user-bg{background-color:var(--color-pi-user-bg)}.p-0{padding:calc(var(--spacing) * 0)}.p-3{padding:calc(var(--spacing) * 3)}.p-4{padding:calc(var(--spacing) * 4)}.px-1{padding-inline:calc(var(--spacing) * 1)}.px-1\.5{padding-inline:calc(var(--spacing) * 1.5)}.px-2{padding-inline:calc(var(--spacing) * 2)}.px-3{padding-inline:calc(var(--spacing) * 3)}.px-4{padding-inline:calc(var(--spacing) * 4)}.py-0\.5{padding-block:calc(var(--spacing) * .5)}.py-1{padding-block:calc(var(--spacing) * 1)}.py-1\.5{padding-block:calc(var(--spacing) * 1.5)}.py-2{padding-block:calc(var(--spacing) * 2)}.py-2\.5{padding-block:calc(var(--spacing) * 2.5)}.py-3{padding-block:calc(var(--spacing) * 3)}.py-5{padding-block:calc(var(--spacing) * 5)}.py-6{padding-block:calc(var(--spacing) * 6)}.pt-3{padding-top:calc(var(--spacing) * 3)}.pr-8{padding-right:calc(var(--spacing) * 8)}.pb-4{padding-bottom:calc(var(--spacing) * 4)}.text-center{text-align:center}.text-left{text-align:left}.font-mono{font-family:var(--font-mono)}.text-base{font-size:var(--text-base);line-height:var(--tw-leading,var(--text-base--line-height))}.text-lg{font-size:var(--text-lg);line-height:var(--tw-leading,var(--text-lg--line-height))}.text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.text-xs{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.text-\[11px\]{font-size:11px}.leading-5{--tw-leading:calc(var(--spacing) * 5);line-height:calc(var(--spacing) * 5)}.leading-relaxed{--tw-leading:var(--leading-relaxed);line-height:var(--leading-relaxed)}.font-semibold{--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.break-words{overflow-wrap:break-word}.text-pi-accent{color:var(--color-pi-accent)}.text-pi-control-fg{color:var(--color-pi-control-fg)}.text-pi-dim{color:var(--color-pi-dim)}.text-pi-error{color:var(--color-pi-error)}.text-pi-md-code{color:var(--color-pi-md-code)}.text-pi-md-code-block{color:var(--color-pi-md-code-block)}.text-pi-md-heading{color:var(--color-pi-md-heading)}.text-pi-md-link{color:var(--color-pi-md-link)}.text-pi-muted{color:var(--color-pi-muted)}.text-pi-text{color:var(--color-pi-text)}.text-pi-tool-output{color:var(--color-pi-tool-output)}.text-pi-warning{color:var(--color-pi-warning)}.text-white{color:var(--color-white)}.underline{text-decoration-line:underline}.opacity-60{opacity:.6}.outline-none{--tw-outline-style:none;outline-style:none}@media(hover:hover){.hover\:bg-pi-user-bg:hover{background-color:var(--color-pi-user-bg)}.hover\:text-pi-accent:hover{color:var(--color-pi-accent)}.hover\:opacity-90:hover{opacity:.9}}.focus\:border-pi-accent:focus{border-color:var(--color-pi-accent)}.disabled\:cursor-default:disabled{cursor:default}.disabled\:bg-pi-border-muted:disabled{background-color:var(--color-pi-border-muted)}.disabled\:opacity-40:disabled{opacity:.4}.disabled\:opacity-50:disabled{opacity:.5}@media(min-width:48rem){.md\:px-6{padding-inline:calc(var(--spacing) * 6)}.md\:text-lg{font-size:var(--text-lg);line-height:var(--tw-leading,var(--text-lg--line-height))}.md\:text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}}}html,body,#root{height:100dvh;overflow:hidden}:root{--composer-control-size:42px;color-scheme:light}*,:before,:after{font-family:JetBrains Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace!important;font-size:14px!important}@supports (-webkit-touch-callout:none){:root{--composer-control-size:44px}.prompt-input{font-size:16px!important}}@media(prefers-color-scheme:dark){:root{color-scheme:dark;--color-pi-accent:#7ca6a6;--color-pi-border:#6f92b2;--color-pi-border-muted:#3f4b57;--color-pi-success:#78b178;--color-pi-error:#d17a7a;--color-pi-warning:#d1a454;--color-pi-muted:#9aa4ad;--color-pi-dim:#7d8892;--color-pi-text:#e5edf3;--color-pi-user-bg:#1b2430;--color-pi-tool-pending:#212a36;--color-pi-tool-success:#1f2c23;--color-pi-tool-error:#322326;--color-pi-md-heading:#d1a454;--color-pi-md-link:#8fb6d8;--color-pi-md-code:#8fbfbf;--color-pi-md-code-block:#82b182;--color-pi-tool-output:#a8b3bc;--color-pi-page-bg:#10151b;--color-pi-card-bg:#151c24;--color-pi-control-bg:#0f1720;--color-pi-control-fg:#e5edf3;--color-syntax-comment:#8dc891;--color-syntax-keyword:#7fa8ff;--color-syntax-fn:#d8ba86;--color-syntax-var:#9fc3ff;--color-syntax-string:#f0a6a6;--color-syntax-number:#7fd4a5;--color-syntax-type:#7fc8e1}}.prompt-input::placeholder{color:var(--color-pi-muted)}@keyframes pulse-dot{0%,to{opacity:1}50%{opacity:.4}}.animate-pulse-dot{animation:1s infinite pulse-dot}.select-fit-content{field-sizing:content}.tool-io-pre{white-space:pre;tab-size:4;margin:0;line-height:1.3;overflow-x:auto}@property --tw-space-y-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-divide-y-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-leading{syntax:"*";inherits:false}@property --tw-font-weight{syntax:"*";inherits:false}
|