@clawos-dev/clawd 0.2.308 → 0.2.309
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.cjs +1 -1
- package/dist/share-md-viewer-error.html +1 -1
- package/dist/share-md-viewer.html +1 -1
- package/dist/share-ui/assets/guest-BTdtu4sV.css +32 -0
- package/dist/share-ui/assets/{guest-COD6k16h.js → guest-CTxN2K1h.js} +5 -5
- package/dist/share-ui/guest.html +2 -2
- package/package.json +1 -1
- package/dist/share-ui/assets/guest-D0fgUsUm.css +0 -32
|
@@ -452,7 +452,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
452
452
|
*
|
|
453
453
|
* This source code is licensed under the ISC license.
|
|
454
454
|
* See the LICENSE file in the root directory of this source tree.
|
|
455
|
-
*/const v$=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],x$=he("zap",v$);function AT(e){var t,n,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=AT(e[t]))&&(r&&(r+=" "),r+=n)}else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}function jT(){for(var e,t,n=0,r="",i=arguments.length;n<i;n++)(e=arguments[n])&&(t=AT(e))&&(r&&(r+=" "),r+=t);return r}const _$=(e,t)=>{const n=new Array(e.length+t.length);for(let r=0;r<e.length;r++)n[r]=e[r];for(let r=0;r<t.length;r++)n[e.length+r]=t[r];return n},y$=(e,t)=>({classGroupId:e,validator:t}),LT=(e=new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),Kh="-",yw=[],b$="arbitrary..",w$=e=>{const t=k$(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:o=>{if(o.startsWith("[")&&o.endsWith("]"))return S$(o);const a=o.split(Kh),l=a[0]===""&&a.length>1?1:0;return DT(a,l,t)},getConflictingClassGroupIds:(o,a)=>{if(a){const l=r[o],c=n[o];return l?c?_$(c,l):l:c||yw}return n[o]||yw}}},DT=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;const i=e[t],s=n.nextPart.get(i);if(s){const c=DT(e,t+1,s);if(c)return c}const o=n.validators;if(o===null)return;const a=t===0?e.join(Kh):e.slice(t).join(Kh),l=o.length;for(let c=0;c<l;c++){const u=o[c];if(u.validator(a))return u.classGroupId}},S$=e=>e.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const t=e.slice(1,-1),n=t.indexOf(":"),r=t.slice(0,n);return r?b$+r:void 0})(),k$=e=>{const{theme:t,classGroups:n}=e;return C$(n,t)},C$=(e,t)=>{const n=LT();for(const r in e){const i=e[r];P_(i,n,r,t)}return n},P_=(e,t,n,r)=>{const i=e.length;for(let s=0;s<i;s++){const o=e[s];E$(o,t,n,r)}},E$=(e,t,n,r)=>{if(typeof e=="string"){N$(e,t,n);return}if(typeof e=="function"){T$(e,t,n,r);return}P$(e,t,n,r)},N$=(e,t,n)=>{const r=e===""?t:OT(t,e);r.classGroupId=n},T$=(e,t,n,r)=>{if(I$(e)){P_(e(r),t,n,r);return}t.validators===null&&(t.validators=[]),t.validators.push(y$(n,e))},P$=(e,t,n,r)=>{const i=Object.entries(e),s=i.length;for(let o=0;o<s;o++){const[a,l]=i[o];P_(l,OT(t,a),n,r)}},OT=(e,t)=>{let n=e;const r=t.split(Kh),i=r.length;for(let s=0;s<i;s++){const o=r[s];let a=n.nextPart.get(o);a||(a=LT(),n.nextPart.set(o,a)),n=a}return n},I$=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,R$=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,n=Object.create(null),r=Object.create(null);const i=(s,o)=>{n[s]=o,t++,t>e&&(t=0,r=n,n=Object.create(null))};return{get(s){let o=n[s];if(o!==void 0)return o;if((o=r[s])!==void 0)return i(s,o),o},set(s,o){s in n?n[s]=o:i(s,o)}}},e0="!",bw=":",M$=[],ww=(e,t,n,r,i)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:r,isExternal:i}),A$=e=>{const{prefix:t,experimentalParseClassName:n}=e;let r=i=>{const s=[];let o=0,a=0,l=0,c;const u=i.length;for(let v=0;v<u;v++){const b=i[v];if(o===0&&a===0){if(b===bw){s.push(i.slice(l,v)),l=v+1;continue}if(b==="/"){c=v;continue}}b==="["?o++:b==="]"?o--:b==="("?a++:b===")"&&a--}const d=s.length===0?i:i.slice(l);let f=d,p=!1;d.endsWith(e0)?(f=d.slice(0,-1),p=!0):d.startsWith(e0)&&(f=d.slice(1),p=!0);const m=c&&c>l?c-l:void 0;return ww(s,p,f,m)};if(t){const i=t+bw,s=r;r=o=>o.startsWith(i)?s(o.slice(i.length)):ww(M$,!1,o,void 0,!0)}if(n){const i=r;r=s=>n({className:s,parseClassName:i})}return r},j$=e=>{const t=new Map;return e.orderSensitiveModifiers.forEach((n,r)=>{t.set(n,1e6+r)}),n=>{const r=[];let i=[];for(let s=0;s<n.length;s++){const o=n[s],a=o[0]==="[",l=t.has(o);a||l?(i.length>0&&(i.sort(),r.push(...i),i=[]),r.push(o)):i.push(o)}return i.length>0&&(i.sort(),r.push(...i)),r}},L$=e=>({cache:R$(e.cacheSize),parseClassName:A$(e),sortModifiers:j$(e),...w$(e)}),D$=/\s+/,O$=(e,t)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:i,sortModifiers:s}=t,o=[],a=e.trim().split(D$);let l="";for(let c=a.length-1;c>=0;c-=1){const u=a[c],{isExternal:d,modifiers:f,hasImportantModifier:p,baseClassName:m,maybePostfixModifierPosition:v}=n(u);if(d){l=u+(l.length>0?" "+l:l);continue}let b=!!v,x=r(b?m.substring(0,v):m);if(!x){if(!b){l=u+(l.length>0?" "+l:l);continue}if(x=r(m),!x){l=u+(l.length>0?" "+l:l);continue}b=!1}const _=f.length===0?"":f.length===1?f[0]:s(f).join(":"),y=p?_+e0:_,w=y+x;if(o.indexOf(w)>-1)continue;o.push(w);const S=i(x,b);for(let C=0;C<S.length;++C){const N=S[C];o.push(y+N)}l=u+(l.length>0?" "+l:l)}return l},B$=(...e)=>{let t=0,n,r,i="";for(;t<e.length;)(n=e[t++])&&(r=BT(n))&&(i&&(i+=" "),i+=r);return i},BT=e=>{if(typeof e=="string")return e;let t,n="";for(let r=0;r<e.length;r++)e[r]&&(t=BT(e[r]))&&(n&&(n+=" "),n+=t);return n},z$=(e,...t)=>{let n,r,i,s;const o=l=>{const c=t.reduce((u,d)=>d(u),e());return n=L$(c),r=n.cache.get,i=n.cache.set,s=a,a(l)},a=l=>{const c=r(l);if(c)return c;const u=O$(l,n);return i(l,u),u};return s=o,(...l)=>s(B$(...l))},$$=[],Ft=e=>{const t=n=>n[e]||$$;return t.isThemeGetter=!0,t},zT=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,$T=/^\((?:(\w[\w-]*):)?(.+)\)$/i,F$=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,H$=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,U$=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,W$=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,V$=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,q$=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Xi=e=>F$.test(e),Le=e=>!!e&&!Number.isNaN(Number(e)),Yi=e=>!!e&&Number.isInteger(Number(e)),xm=e=>e.endsWith("%")&&Le(e.slice(0,-1)),vi=e=>H$.test(e),FT=()=>!0,K$=e=>U$.test(e)&&!W$.test(e),I_=()=>!1,G$=e=>V$.test(e),X$=e=>q$.test(e),Y$=e=>!de(e)&&!fe(e),Z$=e=>Os(e,WT,I_),de=e=>zT.test(e),$s=e=>Os(e,VT,K$),Sw=e=>Os(e,sF,Le),Q$=e=>Os(e,KT,FT),J$=e=>Os(e,qT,I_),kw=e=>Os(e,HT,I_),eF=e=>Os(e,UT,X$),ld=e=>Os(e,GT,G$),fe=e=>$T.test(e),Il=e=>Io(e,VT),tF=e=>Io(e,qT),Cw=e=>Io(e,HT),nF=e=>Io(e,WT),rF=e=>Io(e,UT),cd=e=>Io(e,GT,!0),iF=e=>Io(e,KT,!0),Os=(e,t,n)=>{const r=zT.exec(e);return r?r[1]?t(r[1]):n(r[2]):!1},Io=(e,t,n=!1)=>{const r=$T.exec(e);return r?r[1]?t(r[1]):n:!1},HT=e=>e==="position"||e==="percentage",UT=e=>e==="image"||e==="url",WT=e=>e==="length"||e==="size"||e==="bg-size",VT=e=>e==="length",sF=e=>e==="number",qT=e=>e==="family-name",KT=e=>e==="number"||e==="weight",GT=e=>e==="shadow",oF=()=>{const e=Ft("color"),t=Ft("font"),n=Ft("text"),r=Ft("font-weight"),i=Ft("tracking"),s=Ft("leading"),o=Ft("breakpoint"),a=Ft("container"),l=Ft("spacing"),c=Ft("radius"),u=Ft("shadow"),d=Ft("inset-shadow"),f=Ft("text-shadow"),p=Ft("drop-shadow"),m=Ft("blur"),v=Ft("perspective"),b=Ft("aspect"),x=Ft("ease"),_=Ft("animate"),y=()=>["auto","avoid","all","avoid-page","page","left","right","column"],w=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],S=()=>[...w(),fe,de],C=()=>["auto","hidden","clip","visible","scroll"],N=()=>["auto","contain","none"],T=()=>[fe,de,l],M=()=>[Xi,"full","auto",...T()],P=()=>[Yi,"none","subgrid",fe,de],D=()=>["auto",{span:["full",Yi,fe,de]},Yi,fe,de],R=()=>[Yi,"auto",fe,de],I=()=>["auto","min","max","fr",fe,de],O=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],z=()=>["start","end","center","stretch","center-safe","end-safe"],$=()=>["auto",...T()],F=()=>[Xi,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...T()],L=()=>[Xi,"screen","full","dvw","lvw","svw","min","max","fit",...T()],B=()=>[Xi,"screen","full","lh","dvh","lvh","svh","min","max","fit",...T()],E=()=>[e,fe,de],H=()=>[...w(),Cw,kw,{position:[fe,de]}],q=()=>["no-repeat",{repeat:["","x","y","space","round"]}],A=()=>["auto","cover","contain",nF,Z$,{size:[fe,de]}],re=()=>[xm,Il,$s],oe=()=>["","none","full",c,fe,de],V=()=>["",Le,Il,$s],pe=()=>["solid","dashed","dotted","double"],Oe=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],ie=()=>[Le,xm,Cw,kw],Ae=()=>["","none",m,fe,de],Fe=()=>["none",Le,fe,de],We=()=>["none",Le,fe,de],ge=()=>[Le,fe,de],qe=()=>[Xi,"full",...T()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[vi],breakpoint:[vi],color:[FT],container:[vi],"drop-shadow":[vi],ease:["in","out","in-out"],font:[Y$],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[vi],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[vi],shadow:[vi],spacing:["px",Le],text:[vi],"text-shadow":[vi],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Xi,de,fe,b]}],container:["container"],columns:[{columns:[Le,de,fe,a]}],"break-after":[{"break-after":y()}],"break-before":[{"break-before":y()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:S()}],overflow:[{overflow:C()}],"overflow-x":[{"overflow-x":C()}],"overflow-y":[{"overflow-y":C()}],overscroll:[{overscroll:N()}],"overscroll-x":[{"overscroll-x":N()}],"overscroll-y":[{"overscroll-y":N()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:M()}],"inset-x":[{"inset-x":M()}],"inset-y":[{"inset-y":M()}],start:[{"inset-s":M(),start:M()}],end:[{"inset-e":M(),end:M()}],"inset-bs":[{"inset-bs":M()}],"inset-be":[{"inset-be":M()}],top:[{top:M()}],right:[{right:M()}],bottom:[{bottom:M()}],left:[{left:M()}],visibility:["visible","invisible","collapse"],z:[{z:[Yi,"auto",fe,de]}],basis:[{basis:[Xi,"full","auto",a,...T()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[Le,Xi,"auto","initial","none",de]}],grow:[{grow:["",Le,fe,de]}],shrink:[{shrink:["",Le,fe,de]}],order:[{order:[Yi,"first","last","none",fe,de]}],"grid-cols":[{"grid-cols":P()}],"col-start-end":[{col:D()}],"col-start":[{"col-start":R()}],"col-end":[{"col-end":R()}],"grid-rows":[{"grid-rows":P()}],"row-start-end":[{row:D()}],"row-start":[{"row-start":R()}],"row-end":[{"row-end":R()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":I()}],"auto-rows":[{"auto-rows":I()}],gap:[{gap:T()}],"gap-x":[{"gap-x":T()}],"gap-y":[{"gap-y":T()}],"justify-content":[{justify:[...O(),"normal"]}],"justify-items":[{"justify-items":[...z(),"normal"]}],"justify-self":[{"justify-self":["auto",...z()]}],"align-content":[{content:["normal",...O()]}],"align-items":[{items:[...z(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...z(),{baseline:["","last"]}]}],"place-content":[{"place-content":O()}],"place-items":[{"place-items":[...z(),"baseline"]}],"place-self":[{"place-self":["auto",...z()]}],p:[{p:T()}],px:[{px:T()}],py:[{py:T()}],ps:[{ps:T()}],pe:[{pe:T()}],pbs:[{pbs:T()}],pbe:[{pbe:T()}],pt:[{pt:T()}],pr:[{pr:T()}],pb:[{pb:T()}],pl:[{pl:T()}],m:[{m:$()}],mx:[{mx:$()}],my:[{my:$()}],ms:[{ms:$()}],me:[{me:$()}],mbs:[{mbs:$()}],mbe:[{mbe:$()}],mt:[{mt:$()}],mr:[{mr:$()}],mb:[{mb:$()}],ml:[{ml:$()}],"space-x":[{"space-x":T()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":T()}],"space-y-reverse":["space-y-reverse"],size:[{size:F()}],"inline-size":[{inline:["auto",...L()]}],"min-inline-size":[{"min-inline":["auto",...L()]}],"max-inline-size":[{"max-inline":["none",...L()]}],"block-size":[{block:["auto",...B()]}],"min-block-size":[{"min-block":["auto",...B()]}],"max-block-size":[{"max-block":["none",...B()]}],w:[{w:[a,"screen",...F()]}],"min-w":[{"min-w":[a,"screen","none",...F()]}],"max-w":[{"max-w":[a,"screen","none","prose",{screen:[o]},...F()]}],h:[{h:["screen","lh",...F()]}],"min-h":[{"min-h":["screen","lh","none",...F()]}],"max-h":[{"max-h":["screen","lh",...F()]}],"font-size":[{text:["base",n,Il,$s]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,iF,Q$]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",xm,de]}],"font-family":[{font:[tF,J$,t]}],"font-features":[{"font-features":[de]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[i,fe,de]}],"line-clamp":[{"line-clamp":[Le,"none",fe,Sw]}],leading:[{leading:[s,...T()]}],"list-image":[{"list-image":["none",fe,de]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",fe,de]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:E()}],"text-color":[{text:E()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...pe(),"wavy"]}],"text-decoration-thickness":[{decoration:[Le,"from-font","auto",fe,$s]}],"text-decoration-color":[{decoration:E()}],"underline-offset":[{"underline-offset":[Le,"auto",fe,de]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:T()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",fe,de]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",fe,de]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:H()}],"bg-repeat":[{bg:q()}],"bg-size":[{bg:A()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Yi,fe,de],radial:["",fe,de],conic:[Yi,fe,de]},rF,eF]}],"bg-color":[{bg:E()}],"gradient-from-pos":[{from:re()}],"gradient-via-pos":[{via:re()}],"gradient-to-pos":[{to:re()}],"gradient-from":[{from:E()}],"gradient-via":[{via:E()}],"gradient-to":[{to:E()}],rounded:[{rounded:oe()}],"rounded-s":[{"rounded-s":oe()}],"rounded-e":[{"rounded-e":oe()}],"rounded-t":[{"rounded-t":oe()}],"rounded-r":[{"rounded-r":oe()}],"rounded-b":[{"rounded-b":oe()}],"rounded-l":[{"rounded-l":oe()}],"rounded-ss":[{"rounded-ss":oe()}],"rounded-se":[{"rounded-se":oe()}],"rounded-ee":[{"rounded-ee":oe()}],"rounded-es":[{"rounded-es":oe()}],"rounded-tl":[{"rounded-tl":oe()}],"rounded-tr":[{"rounded-tr":oe()}],"rounded-br":[{"rounded-br":oe()}],"rounded-bl":[{"rounded-bl":oe()}],"border-w":[{border:V()}],"border-w-x":[{"border-x":V()}],"border-w-y":[{"border-y":V()}],"border-w-s":[{"border-s":V()}],"border-w-e":[{"border-e":V()}],"border-w-bs":[{"border-bs":V()}],"border-w-be":[{"border-be":V()}],"border-w-t":[{"border-t":V()}],"border-w-r":[{"border-r":V()}],"border-w-b":[{"border-b":V()}],"border-w-l":[{"border-l":V()}],"divide-x":[{"divide-x":V()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":V()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...pe(),"hidden","none"]}],"divide-style":[{divide:[...pe(),"hidden","none"]}],"border-color":[{border:E()}],"border-color-x":[{"border-x":E()}],"border-color-y":[{"border-y":E()}],"border-color-s":[{"border-s":E()}],"border-color-e":[{"border-e":E()}],"border-color-bs":[{"border-bs":E()}],"border-color-be":[{"border-be":E()}],"border-color-t":[{"border-t":E()}],"border-color-r":[{"border-r":E()}],"border-color-b":[{"border-b":E()}],"border-color-l":[{"border-l":E()}],"divide-color":[{divide:E()}],"outline-style":[{outline:[...pe(),"none","hidden"]}],"outline-offset":[{"outline-offset":[Le,fe,de]}],"outline-w":[{outline:["",Le,Il,$s]}],"outline-color":[{outline:E()}],shadow:[{shadow:["","none",u,cd,ld]}],"shadow-color":[{shadow:E()}],"inset-shadow":[{"inset-shadow":["none",d,cd,ld]}],"inset-shadow-color":[{"inset-shadow":E()}],"ring-w":[{ring:V()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:E()}],"ring-offset-w":[{"ring-offset":[Le,$s]}],"ring-offset-color":[{"ring-offset":E()}],"inset-ring-w":[{"inset-ring":V()}],"inset-ring-color":[{"inset-ring":E()}],"text-shadow":[{"text-shadow":["none",f,cd,ld]}],"text-shadow-color":[{"text-shadow":E()}],opacity:[{opacity:[Le,fe,de]}],"mix-blend":[{"mix-blend":[...Oe(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":Oe()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[Le]}],"mask-image-linear-from-pos":[{"mask-linear-from":ie()}],"mask-image-linear-to-pos":[{"mask-linear-to":ie()}],"mask-image-linear-from-color":[{"mask-linear-from":E()}],"mask-image-linear-to-color":[{"mask-linear-to":E()}],"mask-image-t-from-pos":[{"mask-t-from":ie()}],"mask-image-t-to-pos":[{"mask-t-to":ie()}],"mask-image-t-from-color":[{"mask-t-from":E()}],"mask-image-t-to-color":[{"mask-t-to":E()}],"mask-image-r-from-pos":[{"mask-r-from":ie()}],"mask-image-r-to-pos":[{"mask-r-to":ie()}],"mask-image-r-from-color":[{"mask-r-from":E()}],"mask-image-r-to-color":[{"mask-r-to":E()}],"mask-image-b-from-pos":[{"mask-b-from":ie()}],"mask-image-b-to-pos":[{"mask-b-to":ie()}],"mask-image-b-from-color":[{"mask-b-from":E()}],"mask-image-b-to-color":[{"mask-b-to":E()}],"mask-image-l-from-pos":[{"mask-l-from":ie()}],"mask-image-l-to-pos":[{"mask-l-to":ie()}],"mask-image-l-from-color":[{"mask-l-from":E()}],"mask-image-l-to-color":[{"mask-l-to":E()}],"mask-image-x-from-pos":[{"mask-x-from":ie()}],"mask-image-x-to-pos":[{"mask-x-to":ie()}],"mask-image-x-from-color":[{"mask-x-from":E()}],"mask-image-x-to-color":[{"mask-x-to":E()}],"mask-image-y-from-pos":[{"mask-y-from":ie()}],"mask-image-y-to-pos":[{"mask-y-to":ie()}],"mask-image-y-from-color":[{"mask-y-from":E()}],"mask-image-y-to-color":[{"mask-y-to":E()}],"mask-image-radial":[{"mask-radial":[fe,de]}],"mask-image-radial-from-pos":[{"mask-radial-from":ie()}],"mask-image-radial-to-pos":[{"mask-radial-to":ie()}],"mask-image-radial-from-color":[{"mask-radial-from":E()}],"mask-image-radial-to-color":[{"mask-radial-to":E()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":w()}],"mask-image-conic-pos":[{"mask-conic":[Le]}],"mask-image-conic-from-pos":[{"mask-conic-from":ie()}],"mask-image-conic-to-pos":[{"mask-conic-to":ie()}],"mask-image-conic-from-color":[{"mask-conic-from":E()}],"mask-image-conic-to-color":[{"mask-conic-to":E()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:H()}],"mask-repeat":[{mask:q()}],"mask-size":[{mask:A()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",fe,de]}],filter:[{filter:["","none",fe,de]}],blur:[{blur:Ae()}],brightness:[{brightness:[Le,fe,de]}],contrast:[{contrast:[Le,fe,de]}],"drop-shadow":[{"drop-shadow":["","none",p,cd,ld]}],"drop-shadow-color":[{"drop-shadow":E()}],grayscale:[{grayscale:["",Le,fe,de]}],"hue-rotate":[{"hue-rotate":[Le,fe,de]}],invert:[{invert:["",Le,fe,de]}],saturate:[{saturate:[Le,fe,de]}],sepia:[{sepia:["",Le,fe,de]}],"backdrop-filter":[{"backdrop-filter":["","none",fe,de]}],"backdrop-blur":[{"backdrop-blur":Ae()}],"backdrop-brightness":[{"backdrop-brightness":[Le,fe,de]}],"backdrop-contrast":[{"backdrop-contrast":[Le,fe,de]}],"backdrop-grayscale":[{"backdrop-grayscale":["",Le,fe,de]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Le,fe,de]}],"backdrop-invert":[{"backdrop-invert":["",Le,fe,de]}],"backdrop-opacity":[{"backdrop-opacity":[Le,fe,de]}],"backdrop-saturate":[{"backdrop-saturate":[Le,fe,de]}],"backdrop-sepia":[{"backdrop-sepia":["",Le,fe,de]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":T()}],"border-spacing-x":[{"border-spacing-x":T()}],"border-spacing-y":[{"border-spacing-y":T()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",fe,de]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[Le,"initial",fe,de]}],ease:[{ease:["linear","initial",x,fe,de]}],delay:[{delay:[Le,fe,de]}],animate:[{animate:["none",_,fe,de]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[v,fe,de]}],"perspective-origin":[{"perspective-origin":S()}],rotate:[{rotate:Fe()}],"rotate-x":[{"rotate-x":Fe()}],"rotate-y":[{"rotate-y":Fe()}],"rotate-z":[{"rotate-z":Fe()}],scale:[{scale:We()}],"scale-x":[{"scale-x":We()}],"scale-y":[{"scale-y":We()}],"scale-z":[{"scale-z":We()}],"scale-3d":["scale-3d"],skew:[{skew:ge()}],"skew-x":[{"skew-x":ge()}],"skew-y":[{"skew-y":ge()}],transform:[{transform:[fe,de,"","none","gpu","cpu"]}],"transform-origin":[{origin:S()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:qe()}],"translate-x":[{"translate-x":qe()}],"translate-y":[{"translate-y":qe()}],"translate-z":[{"translate-z":qe()}],"translate-none":["translate-none"],accent:[{accent:E()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:E()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",fe,de]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":T()}],"scroll-mx":[{"scroll-mx":T()}],"scroll-my":[{"scroll-my":T()}],"scroll-ms":[{"scroll-ms":T()}],"scroll-me":[{"scroll-me":T()}],"scroll-mbs":[{"scroll-mbs":T()}],"scroll-mbe":[{"scroll-mbe":T()}],"scroll-mt":[{"scroll-mt":T()}],"scroll-mr":[{"scroll-mr":T()}],"scroll-mb":[{"scroll-mb":T()}],"scroll-ml":[{"scroll-ml":T()}],"scroll-p":[{"scroll-p":T()}],"scroll-px":[{"scroll-px":T()}],"scroll-py":[{"scroll-py":T()}],"scroll-ps":[{"scroll-ps":T()}],"scroll-pe":[{"scroll-pe":T()}],"scroll-pbs":[{"scroll-pbs":T()}],"scroll-pbe":[{"scroll-pbe":T()}],"scroll-pt":[{"scroll-pt":T()}],"scroll-pr":[{"scroll-pr":T()}],"scroll-pb":[{"scroll-pb":T()}],"scroll-pl":[{"scroll-pl":T()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",fe,de]}],fill:[{fill:["none",...E()]}],"stroke-w":[{stroke:[Le,Il,$s,Sw]}],stroke:[{stroke:["none",...E()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","inset-bs","inset-be","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pbs","pbe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mbs","mbe","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-bs","border-w-be","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-bs","border-color-be","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mbs","scroll-mbe","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pbs","scroll-pbe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},aF=z$(oF);function ne(...e){return aF(jT(e))}const XT=[{key:"research",Icon:Jv,label:"研究"},{key:"code",Icon:rz,label:"开发"},{key:"loop",Icon:Xz,label:"Loop 任务"},{key:"qa",Icon:NT,label:"问答"},{key:"reading",Icon:$6,label:"阅读"},{key:"debug",Icon:V6,label:"调试"},{key:"idea",Icon:qh,label:"创意"},{key:"doc",Icon:Ds,label:"文档"},{key:"assist",Icon:Nz,label:"助手"}],lF=new Map(XT.map(e=>[e.key,e]));function YT(e){return e?lF.get(e)??null:null}function Gd(e){return e==="codex"?"Codex":"Claude Code"}function R_(e){return e==="claude"?"text-engine-claude":e==="codex"?"text-engine-codex":"text-text-400"}function cF(e){const t=new Date(e),n=Date.now()-t.getTime(),r=Math.floor(n/6e4);if(r<1)return"just now";if(r<60)return`${r}m ago`;const i=Math.floor(r/60);if(i<24)return`${i}h ago`;const s=Math.floor(i/24);return s<7?`${s}d ago`:t.toLocaleDateString()}function Pe(e,t,{checkForDefaultPrevented:n=!0}={}){return function(i){if(e==null||e(i),n===!1||!i.defaultPrevented)return t==null?void 0:t(i)}}function Ew(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function gu(...e){return t=>{let n=!1;const r=e.map(i=>{const s=Ew(i,t);return!n&&typeof s=="function"&&(n=!0),s});if(n)return()=>{for(let i=0;i<r.length;i++){const s=r[i];typeof s=="function"?s():Ew(e[i],null)}}}}function qt(...e){return g.useCallback(gu(...e),e)}function uF(e,t){const n=g.createContext(t),r=s=>{const{children:o,...a}=s,l=g.useMemo(()=>a,Object.values(a));return h.jsx(n.Provider,{value:l,children:o})};r.displayName=e+"Provider";function i(s){const o=g.useContext(n);if(o)return o;if(t!==void 0)return t;throw new Error(`\`${s}\` must be used within \`${e}\``)}return[r,i]}function Ro(e,t=[]){let n=[];function r(s,o){const a=g.createContext(o),l=n.length;n=[...n,o];const c=d=>{var x;const{scope:f,children:p,...m}=d,v=((x=f==null?void 0:f[e])==null?void 0:x[l])||a,b=g.useMemo(()=>m,Object.values(m));return h.jsx(v.Provider,{value:b,children:p})};c.displayName=s+"Provider";function u(d,f){var v;const p=((v=f==null?void 0:f[e])==null?void 0:v[l])||a,m=g.useContext(p);if(m)return m;if(o!==void 0)return o;throw new Error(`\`${d}\` must be used within \`${s}\``)}return[c,u]}const i=()=>{const s=n.map(o=>g.createContext(o));return function(a){const l=(a==null?void 0:a[e])||s;return g.useMemo(()=>({[`__scope${e}`]:{...a,[e]:l}}),[a,l])}};return i.scopeName=e,[r,dF(i,...t)]}function dF(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(i=>({useScope:i(),scopeName:i.scopeName}));return function(s){const o=r.reduce((a,{useScope:l,scopeName:c})=>{const d=l(s)[`__scope${c}`];return{...a,...d}},{});return g.useMemo(()=>({[`__scope${t.scopeName}`]:o}),[o])}};return n.scopeName=t.scopeName,n}var Ps=globalThis!=null&&globalThis.document?g.useLayoutEffect:()=>{},hF=Ya[" useInsertionEffect ".trim().toString()]||Ps;function Qf({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[i,s,o]=fF({defaultProp:t,onChange:n}),a=e!==void 0,l=a?e:i;{const u=g.useRef(e!==void 0);g.useEffect(()=>{const d=u.current;d!==a&&console.warn(`${r} is changing from ${d?"controlled":"uncontrolled"} to ${a?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),u.current=a},[a,r])}const c=g.useCallback(u=>{var d;if(a){const f=pF(u)?u(e):u;f!==e&&((d=o.current)==null||d.call(o,f))}else s(u)},[a,e,s,o]);return[l,c]}function fF({defaultProp:e,onChange:t}){const[n,r]=g.useState(e),i=g.useRef(n),s=g.useRef(t);return hF(()=>{s.current=t},[t]),g.useEffect(()=>{var o;i.current!==n&&((o=s.current)==null||o.call(s,n),i.current=n)},[n,i]),[n,r,s]}function pF(e){return typeof e=="function"}function Wc(e){const t=mF(e),n=g.forwardRef((r,i)=>{const{children:s,...o}=r,a=g.Children.toArray(s),l=a.find(vF);if(l){const c=l.props.children,u=a.map(d=>d===l?g.Children.count(c)>1?g.Children.only(null):g.isValidElement(c)?c.props.children:null:d);return h.jsx(t,{...o,ref:i,children:g.isValidElement(c)?g.cloneElement(c,void 0,u):null})}return h.jsx(t,{...o,ref:i,children:s})});return n.displayName=`${e}.Slot`,n}function mF(e){const t=g.forwardRef((n,r)=>{const{children:i,...s}=n;if(g.isValidElement(i)){const o=_F(i),a=xF(s,i.props);return i.type!==g.Fragment&&(a.ref=r?gu(r,o):o),g.cloneElement(i,a)}return g.Children.count(i)>1?g.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var ZT=Symbol("radix.slottable");function gF(e){const t=({children:n})=>h.jsx(h.Fragment,{children:n});return t.displayName=`${e}.Slottable`,t.__radixId=ZT,t}function vF(e){return g.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===ZT}function xF(e,t){const n={...t};for(const r in t){const i=e[r],s=t[r];/^on[A-Z]/.test(r)?i&&s?n[r]=(...a)=>{const l=s(...a);return i(...a),l}:i&&(n[r]=i):r==="style"?n[r]={...i,...s}:r==="className"&&(n[r]=[i,s].filter(Boolean).join(" "))}return{...e,...n}}function _F(e){var r,i;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(i=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:i.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var yF=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Et=yF.reduce((e,t)=>{const n=Wc(`Primitive.${t}`),r=g.forwardRef((i,s)=>{const{asChild:o,...a}=i,l=o?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),h.jsx(l,{...a,ref:s})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function QT(e,t){e&&hu.flushSync(()=>e.dispatchEvent(t))}function JT(e){const t=e+"CollectionProvider",[n,r]=Ro(t),[i,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),o=v=>{const{scope:b,children:x}=v,_=st.useRef(null),y=st.useRef(new Map).current;return h.jsx(i,{scope:b,itemMap:y,collectionRef:_,children:x})};o.displayName=t;const a=e+"CollectionSlot",l=Wc(a),c=st.forwardRef((v,b)=>{const{scope:x,children:_}=v,y=s(a,x),w=qt(b,y.collectionRef);return h.jsx(l,{ref:w,children:_})});c.displayName=a;const u=e+"CollectionItemSlot",d="data-radix-collection-item",f=Wc(u),p=st.forwardRef((v,b)=>{const{scope:x,children:_,...y}=v,w=st.useRef(null),S=qt(b,w),C=s(u,x);return st.useEffect(()=>(C.itemMap.set(w,{ref:w,...y}),()=>void C.itemMap.delete(w))),h.jsx(f,{[d]:"",ref:S,children:_})});p.displayName=u;function m(v){const b=s(e+"CollectionConsumer",v);return st.useCallback(()=>{const _=b.collectionRef.current;if(!_)return[];const y=Array.from(_.querySelectorAll(`[${d}]`));return Array.from(b.itemMap.values()).sort((C,N)=>y.indexOf(C.ref.current)-y.indexOf(N.ref.current))},[b.collectionRef,b.itemMap])}return[{Provider:o,Slot:c,ItemSlot:p},m,r]}var bF=g.createContext(void 0);function eP(e){const t=g.useContext(bF);return e||t||"ltr"}function ji(e){const t=g.useRef(e);return g.useEffect(()=>{t.current=e}),g.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function wF(e,t=globalThis==null?void 0:globalThis.document){const n=ji(e);g.useEffect(()=>{const r=i=>{i.key==="Escape"&&n(i)};return t.addEventListener("keydown",r,{capture:!0}),()=>t.removeEventListener("keydown",r,{capture:!0})},[n,t])}var SF="DismissableLayer",t0="dismissableLayer.update",kF="dismissableLayer.pointerDownOutside",CF="dismissableLayer.focusOutside",Nw,tP=g.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Jf=g.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:i,onFocusOutside:s,onInteractOutside:o,onDismiss:a,...l}=e,c=g.useContext(tP),[u,d]=g.useState(null),f=(u==null?void 0:u.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,p]=g.useState({}),m=qt(t,N=>d(N)),v=Array.from(c.layers),[b]=[...c.layersWithOutsidePointerEventsDisabled].slice(-1),x=v.indexOf(b),_=u?v.indexOf(u):-1,y=c.layersWithOutsidePointerEventsDisabled.size>0,w=_>=x,S=TF(N=>{const T=N.target,M=[...c.branches].some(P=>P.contains(T));!w||M||(i==null||i(N),o==null||o(N),N.defaultPrevented||a==null||a())},f),C=PF(N=>{const T=N.target;[...c.branches].some(P=>P.contains(T))||(s==null||s(N),o==null||o(N),N.defaultPrevented||a==null||a())},f);return wF(N=>{_===c.layers.size-1&&(r==null||r(N),!N.defaultPrevented&&a&&(N.preventDefault(),a()))},f),g.useEffect(()=>{if(u)return n&&(c.layersWithOutsidePointerEventsDisabled.size===0&&(Nw=f.body.style.pointerEvents,f.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(u)),c.layers.add(u),Tw(),()=>{n&&c.layersWithOutsidePointerEventsDisabled.size===1&&(f.body.style.pointerEvents=Nw)}},[u,f,n,c]),g.useEffect(()=>()=>{u&&(c.layers.delete(u),c.layersWithOutsidePointerEventsDisabled.delete(u),Tw())},[u,c]),g.useEffect(()=>{const N=()=>p({});return document.addEventListener(t0,N),()=>document.removeEventListener(t0,N)},[]),h.jsx(Et.div,{...l,ref:m,style:{pointerEvents:y?w?"auto":"none":void 0,...e.style},onFocusCapture:Pe(e.onFocusCapture,C.onFocusCapture),onBlurCapture:Pe(e.onBlurCapture,C.onBlurCapture),onPointerDownCapture:Pe(e.onPointerDownCapture,S.onPointerDownCapture)})});Jf.displayName=SF;var EF="DismissableLayerBranch",NF=g.forwardRef((e,t)=>{const n=g.useContext(tP),r=g.useRef(null),i=qt(t,r);return g.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),h.jsx(Et.div,{...e,ref:i})});NF.displayName=EF;function TF(e,t=globalThis==null?void 0:globalThis.document){const n=ji(e),r=g.useRef(!1),i=g.useRef(()=>{});return g.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let l=function(){nP(kF,n,c,{discrete:!0})};const c={originalEvent:a};a.pointerType==="touch"?(t.removeEventListener("click",i.current),i.current=l,t.addEventListener("click",i.current,{once:!0})):l()}else t.removeEventListener("click",i.current);r.current=!1},o=window.setTimeout(()=>{t.addEventListener("pointerdown",s)},0);return()=>{window.clearTimeout(o),t.removeEventListener("pointerdown",s),t.removeEventListener("click",i.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function PF(e,t=globalThis==null?void 0:globalThis.document){const n=ji(e),r=g.useRef(!1);return g.useEffect(()=>{const i=s=>{s.target&&!r.current&&nP(CF,n,{originalEvent:s},{discrete:!1})};return t.addEventListener("focusin",i),()=>t.removeEventListener("focusin",i)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function Tw(){const e=new CustomEvent(t0);document.dispatchEvent(e)}function nP(e,t,n,{discrete:r}){const i=n.originalEvent.target,s=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?QT(i,s):i.dispatchEvent(s)}var _m=0;function rP(){g.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Pw()),document.body.insertAdjacentElement("beforeend",e[1]??Pw()),_m++,()=>{_m===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),_m--}},[])}function Pw(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var ym="focusScope.autoFocusOnMount",bm="focusScope.autoFocusOnUnmount",Iw={bubbles:!1,cancelable:!0},IF="FocusScope",M_=g.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:i,onUnmountAutoFocus:s,...o}=e,[a,l]=g.useState(null),c=ji(i),u=ji(s),d=g.useRef(null),f=qt(t,v=>l(v)),p=g.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;g.useEffect(()=>{if(r){let v=function(y){if(p.paused||!a)return;const w=y.target;a.contains(w)?d.current=w:ns(d.current,{select:!0})},b=function(y){if(p.paused||!a)return;const w=y.relatedTarget;w!==null&&(a.contains(w)||ns(d.current,{select:!0}))},x=function(y){if(document.activeElement===document.body)for(const S of y)S.removedNodes.length>0&&ns(a)};document.addEventListener("focusin",v),document.addEventListener("focusout",b);const _=new MutationObserver(x);return a&&_.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",v),document.removeEventListener("focusout",b),_.disconnect()}}},[r,a,p.paused]),g.useEffect(()=>{if(a){Mw.add(p);const v=document.activeElement;if(!a.contains(v)){const x=new CustomEvent(ym,Iw);a.addEventListener(ym,c),a.dispatchEvent(x),x.defaultPrevented||(RF(DF(iP(a)),{select:!0}),document.activeElement===v&&ns(a))}return()=>{a.removeEventListener(ym,c),setTimeout(()=>{const x=new CustomEvent(bm,Iw);a.addEventListener(bm,u),a.dispatchEvent(x),x.defaultPrevented||ns(v??document.body,{select:!0}),a.removeEventListener(bm,u),Mw.remove(p)},0)}}},[a,c,u,p]);const m=g.useCallback(v=>{if(!n&&!r||p.paused)return;const b=v.key==="Tab"&&!v.altKey&&!v.ctrlKey&&!v.metaKey,x=document.activeElement;if(b&&x){const _=v.currentTarget,[y,w]=MF(_);y&&w?!v.shiftKey&&x===w?(v.preventDefault(),n&&ns(y,{select:!0})):v.shiftKey&&x===y&&(v.preventDefault(),n&&ns(w,{select:!0})):x===_&&v.preventDefault()}},[n,r,p.paused]);return h.jsx(Et.div,{tabIndex:-1,...o,ref:f,onKeyDown:m})});M_.displayName=IF;function RF(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(ns(r,{select:t}),document.activeElement!==n)return}function MF(e){const t=iP(e),n=Rw(t,e),r=Rw(t.reverse(),e);return[n,r]}function iP(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const i=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||i?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function Rw(e,t){for(const n of e)if(!AF(n,{upTo:t}))return n}function AF(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function jF(e){return e instanceof HTMLInputElement&&"select"in e}function ns(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&jF(e)&&t&&e.select()}}var Mw=LF();function LF(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=Aw(e,t),e.unshift(t)},remove(t){var n;e=Aw(e,t),(n=e[0])==null||n.resume()}}}function Aw(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function DF(e){return e.filter(t=>t.tagName!=="A")}var OF=Ya[" useId ".trim().toString()]||(()=>{}),BF=0;function oo(e){const[t,n]=g.useState(OF());return Ps(()=>{n(r=>r??String(BF++))},[e]),t?`radix-${t}`:""}const zF=["top","right","bottom","left"],Is=Math.min,Zn=Math.max,Gh=Math.round,ud=Math.floor,ni=e=>({x:e,y:e}),$F={left:"right",right:"left",bottom:"top",top:"bottom"};function n0(e,t,n){return Zn(e,Is(t,n))}function Li(e,t){return typeof e=="function"?e(t):e}function Di(e){return e.split("-")[0]}function al(e){return e.split("-")[1]}function A_(e){return e==="x"?"y":"x"}function j_(e){return e==="y"?"height":"width"}function Yr(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function L_(e){return A_(Yr(e))}function FF(e,t,n){n===void 0&&(n=!1);const r=al(e),i=L_(e),s=j_(i);let o=i==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(o=Xh(o)),[o,Xh(o)]}function HF(e){const t=Xh(e);return[r0(e),t,r0(t)]}function r0(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const jw=["left","right"],Lw=["right","left"],UF=["top","bottom"],WF=["bottom","top"];function VF(e,t,n){switch(e){case"top":case"bottom":return n?t?Lw:jw:t?jw:Lw;case"left":case"right":return t?UF:WF;default:return[]}}function qF(e,t,n,r){const i=al(e);let s=VF(Di(e),n==="start",r);return i&&(s=s.map(o=>o+"-"+i),t&&(s=s.concat(s.map(r0)))),s}function Xh(e){const t=Di(e);return $F[t]+e.slice(t.length)}function KF(e){return{top:0,right:0,bottom:0,left:0,...e}}function sP(e){return typeof e!="number"?KF(e):{top:e,right:e,bottom:e,left:e}}function Yh(e){const{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function Dw(e,t,n){let{reference:r,floating:i}=e;const s=Yr(t),o=L_(t),a=j_(o),l=Di(t),c=s==="y",u=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=r[a]/2-i[a]/2;let p;switch(l){case"top":p={x:u,y:r.y-i.height};break;case"bottom":p={x:u,y:r.y+r.height};break;case"right":p={x:r.x+r.width,y:d};break;case"left":p={x:r.x-i.width,y:d};break;default:p={x:r.x,y:r.y}}switch(al(t)){case"start":p[o]-=f*(n&&c?-1:1);break;case"end":p[o]+=f*(n&&c?-1:1);break}return p}async function GF(e,t){var n;t===void 0&&(t={});const{x:r,y:i,platform:s,rects:o,elements:a,strategy:l}=e,{boundary:c="clippingAncestors",rootBoundary:u="viewport",elementContext:d="floating",altBoundary:f=!1,padding:p=0}=Li(t,e),m=sP(p),b=a[f?d==="floating"?"reference":"floating":d],x=Yh(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(b)))==null||n?b:b.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(a.floating)),boundary:c,rootBoundary:u,strategy:l})),_=d==="floating"?{x:r,y:i,width:o.floating.width,height:o.floating.height}:o.reference,y=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),w=await(s.isElement==null?void 0:s.isElement(y))?await(s.getScale==null?void 0:s.getScale(y))||{x:1,y:1}:{x:1,y:1},S=Yh(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:_,offsetParent:y,strategy:l}):_);return{top:(x.top-S.top+m.top)/w.y,bottom:(S.bottom-x.bottom+m.bottom)/w.y,left:(x.left-S.left+m.left)/w.x,right:(S.right-x.right+m.right)/w.x}}const XF=50,YF=async(e,t,n)=>{const{placement:r="bottom",strategy:i="absolute",middleware:s=[],platform:o}=n,a=o.detectOverflow?o:{...o,detectOverflow:GF},l=await(o.isRTL==null?void 0:o.isRTL(t));let c=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=Dw(c,r,l),f=r,p=0;const m={};for(let v=0;v<s.length;v++){const b=s[v];if(!b)continue;const{name:x,fn:_}=b,{x:y,y:w,data:S,reset:C}=await _({x:u,y:d,initialPlacement:r,placement:f,strategy:i,middlewareData:m,rects:c,platform:a,elements:{reference:e,floating:t}});u=y??u,d=w??d,m[x]={...m[x],...S},C&&p<XF&&(p++,typeof C=="object"&&(C.placement&&(f=C.placement),C.rects&&(c=C.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):C.rects),{x:u,y:d}=Dw(c,f,l)),v=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},ZF=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:i,rects:s,platform:o,elements:a,middlewareData:l}=t,{element:c,padding:u=0}=Li(e,t)||{};if(c==null)return{};const d=sP(u),f={x:n,y:r},p=L_(i),m=j_(p),v=await o.getDimensions(c),b=p==="y",x=b?"top":"left",_=b?"bottom":"right",y=b?"clientHeight":"clientWidth",w=s.reference[m]+s.reference[p]-f[p]-s.floating[m],S=f[p]-s.reference[p],C=await(o.getOffsetParent==null?void 0:o.getOffsetParent(c));let N=C?C[y]:0;(!N||!await(o.isElement==null?void 0:o.isElement(C)))&&(N=a.floating[y]||s.floating[m]);const T=w/2-S/2,M=N/2-v[m]/2-1,P=Is(d[x],M),D=Is(d[_],M),R=P,I=N-v[m]-D,O=N/2-v[m]/2+T,z=n0(R,O,I),$=!l.arrow&&al(i)!=null&&O!==z&&s.reference[m]/2-(O<R?P:D)-v[m]/2<0,F=$?O<R?O-R:O-I:0;return{[p]:f[p]+F,data:{[p]:z,centerOffset:O-z-F,...$&&{alignmentOffset:F}},reset:$}}}),QF=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:i,middlewareData:s,rects:o,initialPlacement:a,platform:l,elements:c}=t,{mainAxis:u=!0,crossAxis:d=!0,fallbackPlacements:f,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:m="none",flipAlignment:v=!0,...b}=Li(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const x=Di(i),_=Yr(a),y=Di(a)===a,w=await(l.isRTL==null?void 0:l.isRTL(c.floating)),S=f||(y||!v?[Xh(a)]:HF(a)),C=m!=="none";!f&&C&&S.push(...qF(a,v,m,w));const N=[a,...S],T=await l.detectOverflow(t,b),M=[];let P=((r=s.flip)==null?void 0:r.overflows)||[];if(u&&M.push(T[x]),d){const O=FF(i,o,w);M.push(T[O[0]],T[O[1]])}if(P=[...P,{placement:i,overflows:M}],!M.every(O=>O<=0)){var D,R;const O=(((D=s.flip)==null?void 0:D.index)||0)+1,z=N[O];if(z&&(!(d==="alignment"?_!==Yr(z):!1)||P.every(L=>Yr(L.placement)===_?L.overflows[0]>0:!0)))return{data:{index:O,overflows:P},reset:{placement:z}};let $=(R=P.filter(F=>F.overflows[0]<=0).sort((F,L)=>F.overflows[1]-L.overflows[1])[0])==null?void 0:R.placement;if(!$)switch(p){case"bestFit":{var I;const F=(I=P.filter(L=>{if(C){const B=Yr(L.placement);return B===_||B==="y"}return!0}).map(L=>[L.placement,L.overflows.filter(B=>B>0).reduce((B,E)=>B+E,0)]).sort((L,B)=>L[1]-B[1])[0])==null?void 0:I[0];F&&($=F);break}case"initialPlacement":$=a;break}if(i!==$)return{reset:{placement:$}}}return{}}}};function Ow(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Bw(e){return zF.some(t=>e[t]>=0)}const JF=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:r}=t,{strategy:i="referenceHidden",...s}=Li(e,t);switch(i){case"referenceHidden":{const o=await r.detectOverflow(t,{...s,elementContext:"reference"}),a=Ow(o,n.reference);return{data:{referenceHiddenOffsets:a,referenceHidden:Bw(a)}}}case"escaped":{const o=await r.detectOverflow(t,{...s,altBoundary:!0}),a=Ow(o,n.floating);return{data:{escapedOffsets:a,escaped:Bw(a)}}}default:return{}}}}},oP=new Set(["left","top"]);async function e8(e,t){const{placement:n,platform:r,elements:i}=e,s=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=Di(n),a=al(n),l=Yr(n)==="y",c=oP.has(o)?-1:1,u=s&&l?-1:1,d=Li(t,e);let{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return a&&typeof m=="number"&&(p=a==="end"?m*-1:m),l?{x:p*u,y:f*c}:{x:f*c,y:p*u}}const t8=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:i,y:s,placement:o,middlewareData:a}=t,l=await e8(t,e);return o===((n=a.offset)==null?void 0:n.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:i+l.x,y:s+l.y,data:{...l,placement:o}}}}},n8=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:i,platform:s}=t,{mainAxis:o=!0,crossAxis:a=!1,limiter:l={fn:x=>{let{x:_,y}=x;return{x:_,y}}},...c}=Li(e,t),u={x:n,y:r},d=await s.detectOverflow(t,c),f=Yr(Di(i)),p=A_(f);let m=u[p],v=u[f];if(o){const x=p==="y"?"top":"left",_=p==="y"?"bottom":"right",y=m+d[x],w=m-d[_];m=n0(y,m,w)}if(a){const x=f==="y"?"top":"left",_=f==="y"?"bottom":"right",y=v+d[x],w=v-d[_];v=n0(y,v,w)}const b=l.fn({...t,[p]:m,[f]:v});return{...b,data:{x:b.x-n,y:b.y-r,enabled:{[p]:o,[f]:a}}}}}},r8=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:i,rects:s,middlewareData:o}=t,{offset:a=0,mainAxis:l=!0,crossAxis:c=!0}=Li(e,t),u={x:n,y:r},d=Yr(i),f=A_(d);let p=u[f],m=u[d];const v=Li(a,t),b=typeof v=="number"?{mainAxis:v,crossAxis:0}:{mainAxis:0,crossAxis:0,...v};if(l){const y=f==="y"?"height":"width",w=s.reference[f]-s.floating[y]+b.mainAxis,S=s.reference[f]+s.reference[y]-b.mainAxis;p<w?p=w:p>S&&(p=S)}if(c){var x,_;const y=f==="y"?"width":"height",w=oP.has(Di(i)),S=s.reference[d]-s.floating[y]+(w&&((x=o.offset)==null?void 0:x[d])||0)+(w?0:b.crossAxis),C=s.reference[d]+s.reference[y]+(w?0:((_=o.offset)==null?void 0:_[d])||0)-(w?b.crossAxis:0);m<S?m=S:m>C&&(m=C)}return{[f]:p,[d]:m}}}},i8=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:i,rects:s,platform:o,elements:a}=t,{apply:l=()=>{},...c}=Li(e,t),u=await o.detectOverflow(t,c),d=Di(i),f=al(i),p=Yr(i)==="y",{width:m,height:v}=s.floating;let b,x;d==="top"||d==="bottom"?(b=d,x=f===(await(o.isRTL==null?void 0:o.isRTL(a.floating))?"start":"end")?"left":"right"):(x=d,b=f==="end"?"top":"bottom");const _=v-u.top-u.bottom,y=m-u.left-u.right,w=Is(v-u[b],_),S=Is(m-u[x],y),C=!t.middlewareData.shift;let N=w,T=S;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(T=y),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(N=_),C&&!f){const P=Zn(u.left,0),D=Zn(u.right,0),R=Zn(u.top,0),I=Zn(u.bottom,0);p?T=m-2*(P!==0||D!==0?P+D:Zn(u.left,u.right)):N=v-2*(R!==0||I!==0?R+I:Zn(u.top,u.bottom))}await l({...t,availableWidth:T,availableHeight:N});const M=await o.getDimensions(a.floating);return m!==M.width||v!==M.height?{reset:{rects:!0}}:{}}}};function ep(){return typeof window<"u"}function ll(e){return aP(e)?(e.nodeName||"").toLowerCase():"#document"}function er(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function di(e){var t;return(t=(aP(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function aP(e){return ep()?e instanceof Node||e instanceof er(e).Node:!1}function Dr(e){return ep()?e instanceof Element||e instanceof er(e).Element:!1}function Fi(e){return ep()?e instanceof HTMLElement||e instanceof er(e).HTMLElement:!1}function zw(e){return!ep()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof er(e).ShadowRoot}function vu(e){const{overflow:t,overflowX:n,overflowY:r,display:i}=Or(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!=="inline"&&i!=="contents"}function s8(e){return/^(table|td|th)$/.test(ll(e))}function tp(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const o8=/transform|translate|scale|rotate|perspective|filter/,a8=/paint|layout|strict|content/,Fs=e=>!!e&&e!=="none";let wm;function D_(e){const t=Dr(e)?Or(e):e;return Fs(t.transform)||Fs(t.translate)||Fs(t.scale)||Fs(t.rotate)||Fs(t.perspective)||!O_()&&(Fs(t.backdropFilter)||Fs(t.filter))||o8.test(t.willChange||"")||a8.test(t.contain||"")}function l8(e){let t=Rs(e);for(;Fi(t)&&!$a(t);){if(D_(t))return t;if(tp(t))return null;t=Rs(t)}return null}function O_(){return wm==null&&(wm=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),wm}function $a(e){return/^(html|body|#document)$/.test(ll(e))}function Or(e){return er(e).getComputedStyle(e)}function np(e){return Dr(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Rs(e){if(ll(e)==="html")return e;const t=e.assignedSlot||e.parentNode||zw(e)&&e.host||di(e);return zw(t)?t.host:t}function lP(e){const t=Rs(e);return $a(t)?e.ownerDocument?e.ownerDocument.body:e.body:Fi(t)&&vu(t)?t:lP(t)}function Vc(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const i=lP(e),s=i===((r=e.ownerDocument)==null?void 0:r.body),o=er(i);if(s){const a=i0(o);return t.concat(o,o.visualViewport||[],vu(i)?i:[],a&&n?Vc(a):[])}else return t.concat(i,Vc(i,[],n))}function i0(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function cP(e){const t=Or(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const i=Fi(e),s=i?e.offsetWidth:n,o=i?e.offsetHeight:r,a=Gh(n)!==s||Gh(r)!==o;return a&&(n=s,r=o),{width:n,height:r,$:a}}function B_(e){return Dr(e)?e:e.contextElement}function Sa(e){const t=B_(e);if(!Fi(t))return ni(1);const n=t.getBoundingClientRect(),{width:r,height:i,$:s}=cP(t);let o=(s?Gh(n.width):n.width)/r,a=(s?Gh(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!a||!Number.isFinite(a))&&(a=1),{x:o,y:a}}const c8=ni(0);function uP(e){const t=er(e);return!O_()||!t.visualViewport?c8:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function u8(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==er(e)?!1:t}function xo(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const i=e.getBoundingClientRect(),s=B_(e);let o=ni(1);t&&(r?Dr(r)&&(o=Sa(r)):o=Sa(e));const a=u8(s,n,r)?uP(s):ni(0);let l=(i.left+a.x)/o.x,c=(i.top+a.y)/o.y,u=i.width/o.x,d=i.height/o.y;if(s){const f=er(s),p=r&&Dr(r)?er(r):r;let m=f,v=i0(m);for(;v&&r&&p!==m;){const b=Sa(v),x=v.getBoundingClientRect(),_=Or(v),y=x.left+(v.clientLeft+parseFloat(_.paddingLeft))*b.x,w=x.top+(v.clientTop+parseFloat(_.paddingTop))*b.y;l*=b.x,c*=b.y,u*=b.x,d*=b.y,l+=y,c+=w,m=er(v),v=i0(m)}}return Yh({width:u,height:d,x:l,y:c})}function rp(e,t){const n=np(e).scrollLeft;return t?t.left+n:xo(di(e)).left+n}function dP(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-rp(e,n),i=n.top+t.scrollTop;return{x:r,y:i}}function d8(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e;const s=i==="fixed",o=di(r),a=t?tp(t.floating):!1;if(r===o||a&&s)return n;let l={scrollLeft:0,scrollTop:0},c=ni(1);const u=ni(0),d=Fi(r);if((d||!d&&!s)&&((ll(r)!=="body"||vu(o))&&(l=np(r)),d)){const p=xo(r);c=Sa(r),u.x=p.x+r.clientLeft,u.y=p.y+r.clientTop}const f=o&&!d&&!s?dP(o,l):ni(0);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-l.scrollLeft*c.x+u.x+f.x,y:n.y*c.y-l.scrollTop*c.y+u.y+f.y}}function h8(e){return Array.from(e.getClientRects())}function f8(e){const t=di(e),n=np(e),r=e.ownerDocument.body,i=Zn(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=Zn(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let o=-n.scrollLeft+rp(e);const a=-n.scrollTop;return Or(r).direction==="rtl"&&(o+=Zn(t.clientWidth,r.clientWidth)-i),{width:i,height:s,x:o,y:a}}const $w=25;function p8(e,t){const n=er(e),r=di(e),i=n.visualViewport;let s=r.clientWidth,o=r.clientHeight,a=0,l=0;if(i){s=i.width,o=i.height;const u=O_();(!u||u&&t==="fixed")&&(a=i.offsetLeft,l=i.offsetTop)}const c=rp(r);if(c<=0){const u=r.ownerDocument,d=u.body,f=getComputedStyle(d),p=u.compatMode==="CSS1Compat"&&parseFloat(f.marginLeft)+parseFloat(f.marginRight)||0,m=Math.abs(r.clientWidth-d.clientWidth-p);m<=$w&&(s-=m)}else c<=$w&&(s+=c);return{width:s,height:o,x:a,y:l}}function m8(e,t){const n=xo(e,!0,t==="fixed"),r=n.top+e.clientTop,i=n.left+e.clientLeft,s=Fi(e)?Sa(e):ni(1),o=e.clientWidth*s.x,a=e.clientHeight*s.y,l=i*s.x,c=r*s.y;return{width:o,height:a,x:l,y:c}}function Fw(e,t,n){let r;if(t==="viewport")r=p8(e,n);else if(t==="document")r=f8(di(e));else if(Dr(t))r=m8(t,n);else{const i=uP(e);r={x:t.x-i.x,y:t.y-i.y,width:t.width,height:t.height}}return Yh(r)}function hP(e,t){const n=Rs(e);return n===t||!Dr(n)||$a(n)?!1:Or(n).position==="fixed"||hP(n,t)}function g8(e,t){const n=t.get(e);if(n)return n;let r=Vc(e,[],!1).filter(a=>Dr(a)&&ll(a)!=="body"),i=null;const s=Or(e).position==="fixed";let o=s?Rs(e):e;for(;Dr(o)&&!$a(o);){const a=Or(o),l=D_(o);!l&&a.position==="fixed"&&(i=null),(s?!l&&!i:!l&&a.position==="static"&&!!i&&(i.position==="absolute"||i.position==="fixed")||vu(o)&&!l&&hP(e,o))?r=r.filter(u=>u!==o):i=a,o=Rs(o)}return t.set(e,r),r}function v8(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e;const o=[...n==="clippingAncestors"?tp(t)?[]:g8(t,this._c):[].concat(n),r],a=Fw(t,o[0],i);let l=a.top,c=a.right,u=a.bottom,d=a.left;for(let f=1;f<o.length;f++){const p=Fw(t,o[f],i);l=Zn(p.top,l),c=Is(p.right,c),u=Is(p.bottom,u),d=Zn(p.left,d)}return{width:c-d,height:u-l,x:d,y:l}}function x8(e){const{width:t,height:n}=cP(e);return{width:t,height:n}}function _8(e,t,n){const r=Fi(t),i=di(t),s=n==="fixed",o=xo(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const l=ni(0);function c(){l.x=rp(i)}if(r||!r&&!s)if((ll(t)!=="body"||vu(i))&&(a=np(t)),r){const p=xo(t,!0,s,t);l.x=p.x+t.clientLeft,l.y=p.y+t.clientTop}else i&&c();s&&!r&&i&&c();const u=i&&!r&&!s?dP(i,a):ni(0),d=o.left+a.scrollLeft-l.x-u.x,f=o.top+a.scrollTop-l.y-u.y;return{x:d,y:f,width:o.width,height:o.height}}function Sm(e){return Or(e).position==="static"}function Hw(e,t){if(!Fi(e)||Or(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return di(e)===n&&(n=n.ownerDocument.body),n}function fP(e,t){const n=er(e);if(tp(e))return n;if(!Fi(e)){let i=Rs(e);for(;i&&!$a(i);){if(Dr(i)&&!Sm(i))return i;i=Rs(i)}return n}let r=Hw(e,t);for(;r&&s8(r)&&Sm(r);)r=Hw(r,t);return r&&$a(r)&&Sm(r)&&!D_(r)?n:r||l8(e)||n}const y8=async function(e){const t=this.getOffsetParent||fP,n=this.getDimensions,r=await n(e.floating);return{reference:_8(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function b8(e){return Or(e).direction==="rtl"}const w8={convertOffsetParentRelativeRectToViewportRelativeRect:d8,getDocumentElement:di,getClippingRect:v8,getOffsetParent:fP,getElementRects:y8,getClientRects:h8,getDimensions:x8,getScale:Sa,isElement:Dr,isRTL:b8};function pP(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function S8(e,t){let n=null,r;const i=di(e);function s(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function o(a,l){a===void 0&&(a=!1),l===void 0&&(l=1),s();const c=e.getBoundingClientRect(),{left:u,top:d,width:f,height:p}=c;if(a||t(),!f||!p)return;const m=ud(d),v=ud(i.clientWidth-(u+f)),b=ud(i.clientHeight-(d+p)),x=ud(u),y={rootMargin:-m+"px "+-v+"px "+-b+"px "+-x+"px",threshold:Zn(0,Is(1,l))||1};let w=!0;function S(C){const N=C[0].intersectionRatio;if(N!==l){if(!w)return o();N?o(!1,N):r=setTimeout(()=>{o(!1,1e-7)},1e3)}N===1&&!pP(c,e.getBoundingClientRect())&&o(),w=!1}try{n=new IntersectionObserver(S,{...y,root:i.ownerDocument})}catch{n=new IntersectionObserver(S,y)}n.observe(e)}return o(!0),s}function k8(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:i=!0,ancestorResize:s=!0,elementResize:o=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:l=!1}=r,c=B_(e),u=i||s?[...c?Vc(c):[],...t?Vc(t):[]]:[];u.forEach(x=>{i&&x.addEventListener("scroll",n,{passive:!0}),s&&x.addEventListener("resize",n)});const d=c&&a?S8(c,n):null;let f=-1,p=null;o&&(p=new ResizeObserver(x=>{let[_]=x;_&&_.target===c&&p&&t&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var y;(y=p)==null||y.observe(t)})),n()}),c&&!l&&p.observe(c),t&&p.observe(t));let m,v=l?xo(e):null;l&&b();function b(){const x=xo(e);v&&!pP(v,x)&&n(),v=x,m=requestAnimationFrame(b)}return n(),()=>{var x;u.forEach(_=>{i&&_.removeEventListener("scroll",n),s&&_.removeEventListener("resize",n)}),d==null||d(),(x=p)==null||x.disconnect(),p=null,l&&cancelAnimationFrame(m)}}const C8=t8,E8=n8,N8=QF,T8=i8,P8=JF,Uw=ZF,I8=r8,R8=(e,t,n)=>{const r=new Map,i={platform:w8,...n},s={...i.platform,_c:r};return YF(e,t,{...i,platform:s})};var M8=typeof document<"u",A8=function(){},Xd=M8?g.useLayoutEffect:A8;function Zh(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!Zh(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){const s=i[r];if(!(s==="_owner"&&e.$$typeof)&&!Zh(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function mP(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Ww(e,t){const n=mP(e);return Math.round(t*n)/n}function km(e){const t=g.useRef(e);return Xd(()=>{t.current=e}),t}function j8(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:i,elements:{reference:s,floating:o}={},transform:a=!0,whileElementsMounted:l,open:c}=e,[u,d]=g.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,p]=g.useState(r);Zh(f,r)||p(r);const[m,v]=g.useState(null),[b,x]=g.useState(null),_=g.useCallback(L=>{L!==C.current&&(C.current=L,v(L))},[]),y=g.useCallback(L=>{L!==N.current&&(N.current=L,x(L))},[]),w=s||m,S=o||b,C=g.useRef(null),N=g.useRef(null),T=g.useRef(u),M=l!=null,P=km(l),D=km(i),R=km(c),I=g.useCallback(()=>{if(!C.current||!N.current)return;const L={placement:t,strategy:n,middleware:f};D.current&&(L.platform=D.current),R8(C.current,N.current,L).then(B=>{const E={...B,isPositioned:R.current!==!1};O.current&&!Zh(T.current,E)&&(T.current=E,hu.flushSync(()=>{d(E)}))})},[f,t,n,D,R]);Xd(()=>{c===!1&&T.current.isPositioned&&(T.current.isPositioned=!1,d(L=>({...L,isPositioned:!1})))},[c]);const O=g.useRef(!1);Xd(()=>(O.current=!0,()=>{O.current=!1}),[]),Xd(()=>{if(w&&(C.current=w),S&&(N.current=S),w&&S){if(P.current)return P.current(w,S,I);I()}},[w,S,I,P,M]);const z=g.useMemo(()=>({reference:C,floating:N,setReference:_,setFloating:y}),[_,y]),$=g.useMemo(()=>({reference:w,floating:S}),[w,S]),F=g.useMemo(()=>{const L={position:n,left:0,top:0};if(!$.floating)return L;const B=Ww($.floating,u.x),E=Ww($.floating,u.y);return a?{...L,transform:"translate("+B+"px, "+E+"px)",...mP($.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:B,top:E}},[n,a,$.floating,u.x,u.y]);return g.useMemo(()=>({...u,update:I,refs:z,elements:$,floatingStyles:F}),[u,I,z,$,F])}const L8=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:i}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?Uw({element:r.current,padding:i}).fn(n):{}:r?Uw({element:r,padding:i}).fn(n):{}}}},D8=(e,t)=>{const n=C8(e);return{name:n.name,fn:n.fn,options:[e,t]}},O8=(e,t)=>{const n=E8(e);return{name:n.name,fn:n.fn,options:[e,t]}},B8=(e,t)=>({fn:I8(e).fn,options:[e,t]}),z8=(e,t)=>{const n=N8(e);return{name:n.name,fn:n.fn,options:[e,t]}},$8=(e,t)=>{const n=T8(e);return{name:n.name,fn:n.fn,options:[e,t]}},F8=(e,t)=>{const n=P8(e);return{name:n.name,fn:n.fn,options:[e,t]}},H8=(e,t)=>{const n=L8(e);return{name:n.name,fn:n.fn,options:[e,t]}};var U8="Arrow",gP=g.forwardRef((e,t)=>{const{children:n,width:r=10,height:i=5,...s}=e;return h.jsx(Et.svg,{...s,ref:t,width:r,height:i,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:h.jsx("polygon",{points:"0,0 30,0 15,10"})})});gP.displayName=U8;var W8=gP;function V8(e){const[t,n]=g.useState(void 0);return Ps(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(i=>{if(!Array.isArray(i)||!i.length)return;const s=i[0];let o,a;if("borderBoxSize"in s){const l=s.borderBoxSize,c=Array.isArray(l)?l[0]:l;o=c.inlineSize,a=c.blockSize}else o=e.offsetWidth,a=e.offsetHeight;n({width:o,height:a})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var z_="Popper",[vP,ip]=Ro(z_),[q8,xP]=vP(z_),_P=e=>{const{__scopePopper:t,children:n}=e,[r,i]=g.useState(null);return h.jsx(q8,{scope:t,anchor:r,onAnchorChange:i,children:n})};_P.displayName=z_;var yP="PopperAnchor",bP=g.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...i}=e,s=xP(yP,n),o=g.useRef(null),a=qt(t,o),l=g.useRef(null);return g.useEffect(()=>{const c=l.current;l.current=(r==null?void 0:r.current)||o.current,c!==l.current&&s.onAnchorChange(l.current)}),r?null:h.jsx(Et.div,{...i,ref:a})});bP.displayName=yP;var $_="PopperContent",[K8,G8]=vP($_),wP=g.forwardRef((e,t)=>{var pe,Oe,ie,Ae,Fe,We;const{__scopePopper:n,side:r="bottom",sideOffset:i=0,align:s="center",alignOffset:o=0,arrowPadding:a=0,avoidCollisions:l=!0,collisionBoundary:c=[],collisionPadding:u=0,sticky:d="partial",hideWhenDetached:f=!1,updatePositionStrategy:p="optimized",onPlaced:m,...v}=e,b=xP($_,n),[x,_]=g.useState(null),y=qt(t,ge=>_(ge)),[w,S]=g.useState(null),C=V8(w),N=(C==null?void 0:C.width)??0,T=(C==null?void 0:C.height)??0,M=r+(s!=="center"?"-"+s:""),P=typeof u=="number"?u:{top:0,right:0,bottom:0,left:0,...u},D=Array.isArray(c)?c:[c],R=D.length>0,I={padding:P,boundary:D.filter(Y8),altBoundary:R},{refs:O,floatingStyles:z,placement:$,isPositioned:F,middlewareData:L}=j8({strategy:"fixed",placement:M,whileElementsMounted:(...ge)=>k8(...ge,{animationFrame:p==="always"}),elements:{reference:b.anchor},middleware:[D8({mainAxis:i+T,alignmentAxis:o}),l&&O8({mainAxis:!0,crossAxis:!1,limiter:d==="partial"?B8():void 0,...I}),l&&z8({...I}),$8({...I,apply:({elements:ge,rects:qe,availableWidth:Gt,availableHeight:wt})=>{const{width:Rt,height:ln}=qe.reference,Bt=ge.floating.style;Bt.setProperty("--radix-popper-available-width",`${Gt}px`),Bt.setProperty("--radix-popper-available-height",`${wt}px`),Bt.setProperty("--radix-popper-anchor-width",`${Rt}px`),Bt.setProperty("--radix-popper-anchor-height",`${ln}px`)}}),w&&H8({element:w,padding:a}),Z8({arrowWidth:N,arrowHeight:T}),f&&F8({strategy:"referenceHidden",...I})]}),[B,E]=CP($),H=ji(m);Ps(()=>{F&&(H==null||H())},[F,H]);const q=(pe=L.arrow)==null?void 0:pe.x,A=(Oe=L.arrow)==null?void 0:Oe.y,re=((ie=L.arrow)==null?void 0:ie.centerOffset)!==0,[oe,V]=g.useState();return Ps(()=>{x&&V(window.getComputedStyle(x).zIndex)},[x]),h.jsx("div",{ref:O.setFloating,"data-radix-popper-content-wrapper":"",style:{...z,transform:F?z.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:oe,"--radix-popper-transform-origin":[(Ae=L.transformOrigin)==null?void 0:Ae.x,(Fe=L.transformOrigin)==null?void 0:Fe.y].join(" "),...((We=L.hide)==null?void 0:We.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:h.jsx(K8,{scope:n,placedSide:B,onArrowChange:S,arrowX:q,arrowY:A,shouldHideArrow:re,children:h.jsx(Et.div,{"data-side":B,"data-align":E,...v,ref:y,style:{...v.style,animation:F?void 0:"none"}})})})});wP.displayName=$_;var SP="PopperArrow",X8={top:"bottom",right:"left",bottom:"top",left:"right"},kP=g.forwardRef(function(t,n){const{__scopePopper:r,...i}=t,s=G8(SP,r),o=X8[s.placedSide];return h.jsx("span",{ref:s.onArrowChange,style:{position:"absolute",left:s.arrowX,top:s.arrowY,[o]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[s.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[s.placedSide],visibility:s.shouldHideArrow?"hidden":void 0},children:h.jsx(W8,{...i,ref:n,style:{...i.style,display:"block"}})})});kP.displayName=SP;function Y8(e){return e!==null}var Z8=e=>({name:"transformOrigin",options:e,fn(t){var b,x,_;const{placement:n,rects:r,middlewareData:i}=t,o=((b=i.arrow)==null?void 0:b.centerOffset)!==0,a=o?0:e.arrowWidth,l=o?0:e.arrowHeight,[c,u]=CP(n),d={start:"0%",center:"50%",end:"100%"}[u],f=(((x=i.arrow)==null?void 0:x.x)??0)+a/2,p=(((_=i.arrow)==null?void 0:_.y)??0)+l/2;let m="",v="";return c==="bottom"?(m=o?d:`${f}px`,v=`${-l}px`):c==="top"?(m=o?d:`${f}px`,v=`${r.floating.height+l}px`):c==="right"?(m=`${-l}px`,v=o?d:`${p}px`):c==="left"&&(m=`${r.floating.width+l}px`,v=o?d:`${p}px`),{data:{x:m,y:v}}}});function CP(e){const[t,n="center"]=e.split("-");return[t,n]}var EP=_P,NP=bP,TP=wP,PP=kP,Q8="Portal",F_=g.forwardRef((e,t)=>{var a;const{container:n,...r}=e,[i,s]=g.useState(!1);Ps(()=>s(!0),[]);const o=n||i&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return o?cv.createPortal(h.jsx(Et.div,{...r,ref:t}),o):null});F_.displayName=Q8;function J8(e,t){return g.useReducer((n,r)=>t[n][r]??n,e)}var Hi=e=>{const{present:t,children:n}=e,r=e9(t),i=typeof n=="function"?n({present:r.isPresent}):g.Children.only(n),s=qt(r.ref,t9(i));return typeof n=="function"||r.isPresent?g.cloneElement(i,{ref:s}):null};Hi.displayName="Presence";function e9(e){const[t,n]=g.useState(),r=g.useRef(null),i=g.useRef(e),s=g.useRef("none"),o=e?"mounted":"unmounted",[a,l]=J8(o,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return g.useEffect(()=>{const c=dd(r.current);s.current=a==="mounted"?c:"none"},[a]),Ps(()=>{const c=r.current,u=i.current;if(u!==e){const f=s.current,p=dd(c);e?l("MOUNT"):p==="none"||(c==null?void 0:c.display)==="none"?l("UNMOUNT"):l(u&&f!==p?"ANIMATION_OUT":"UNMOUNT"),i.current=e}},[e,l]),Ps(()=>{if(t){let c;const u=t.ownerDocument.defaultView??window,d=p=>{const v=dd(r.current).includes(CSS.escape(p.animationName));if(p.target===t&&v&&(l("ANIMATION_END"),!i.current)){const b=t.style.animationFillMode;t.style.animationFillMode="forwards",c=u.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=b)})}},f=p=>{p.target===t&&(s.current=dd(r.current))};return t.addEventListener("animationstart",f),t.addEventListener("animationcancel",d),t.addEventListener("animationend",d),()=>{u.clearTimeout(c),t.removeEventListener("animationstart",f),t.removeEventListener("animationcancel",d),t.removeEventListener("animationend",d)}}else l("ANIMATION_END")},[t,l]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:g.useCallback(c=>{r.current=c?getComputedStyle(c):null,n(c)},[])}}function dd(e){return(e==null?void 0:e.animationName)||"none"}function t9(e){var r,i;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(i=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:i.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var Cm="rovingFocusGroup.onEntryFocus",n9={bubbles:!1,cancelable:!0},xu="RovingFocusGroup",[s0,IP,r9]=JT(xu),[i9,RP]=Ro(xu,[r9]),[s9,o9]=i9(xu),MP=g.forwardRef((e,t)=>h.jsx(s0.Provider,{scope:e.__scopeRovingFocusGroup,children:h.jsx(s0.Slot,{scope:e.__scopeRovingFocusGroup,children:h.jsx(a9,{...e,ref:t})})}));MP.displayName=xu;var a9=g.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:i=!1,dir:s,currentTabStopId:o,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:l,onEntryFocus:c,preventScrollOnEntryFocus:u=!1,...d}=e,f=g.useRef(null),p=qt(t,f),m=eP(s),[v,b]=Qf({prop:o,defaultProp:a??null,onChange:l,caller:xu}),[x,_]=g.useState(!1),y=ji(c),w=IP(n),S=g.useRef(!1),[C,N]=g.useState(0);return g.useEffect(()=>{const T=f.current;if(T)return T.addEventListener(Cm,y),()=>T.removeEventListener(Cm,y)},[y]),h.jsx(s9,{scope:n,orientation:r,dir:m,loop:i,currentTabStopId:v,onItemFocus:g.useCallback(T=>b(T),[b]),onItemShiftTab:g.useCallback(()=>_(!0),[]),onFocusableItemAdd:g.useCallback(()=>N(T=>T+1),[]),onFocusableItemRemove:g.useCallback(()=>N(T=>T-1),[]),children:h.jsx(Et.div,{tabIndex:x||C===0?-1:0,"data-orientation":r,...d,ref:p,style:{outline:"none",...e.style},onMouseDown:Pe(e.onMouseDown,()=>{S.current=!0}),onFocus:Pe(e.onFocus,T=>{const M=!S.current;if(T.target===T.currentTarget&&M&&!x){const P=new CustomEvent(Cm,n9);if(T.currentTarget.dispatchEvent(P),!P.defaultPrevented){const D=w().filter($=>$.focusable),R=D.find($=>$.active),I=D.find($=>$.id===v),z=[R,I,...D].filter(Boolean).map($=>$.ref.current);LP(z,u)}}S.current=!1}),onBlur:Pe(e.onBlur,()=>_(!1))})})}),AP="RovingFocusGroupItem",jP=g.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:s,children:o,...a}=e,l=oo(),c=s||l,u=o9(AP,n),d=u.currentTabStopId===c,f=IP(n),{onFocusableItemAdd:p,onFocusableItemRemove:m,currentTabStopId:v}=u;return g.useEffect(()=>{if(r)return p(),()=>m()},[r,p,m]),h.jsx(s0.ItemSlot,{scope:n,id:c,focusable:r,active:i,children:h.jsx(Et.span,{tabIndex:d?0:-1,"data-orientation":u.orientation,...a,ref:t,onMouseDown:Pe(e.onMouseDown,b=>{r?u.onItemFocus(c):b.preventDefault()}),onFocus:Pe(e.onFocus,()=>u.onItemFocus(c)),onKeyDown:Pe(e.onKeyDown,b=>{if(b.key==="Tab"&&b.shiftKey){u.onItemShiftTab();return}if(b.target!==b.currentTarget)return;const x=u9(b,u.orientation,u.dir);if(x!==void 0){if(b.metaKey||b.ctrlKey||b.altKey||b.shiftKey)return;b.preventDefault();let y=f().filter(w=>w.focusable).map(w=>w.ref.current);if(x==="last")y.reverse();else if(x==="prev"||x==="next"){x==="prev"&&y.reverse();const w=y.indexOf(b.currentTarget);y=u.loop?d9(y,w+1):y.slice(w+1)}setTimeout(()=>LP(y))}}),children:typeof o=="function"?o({isCurrentTabStop:d,hasTabStop:v!=null}):o})})});jP.displayName=AP;var l9={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function c9(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function u9(e,t,n){const r=c9(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return l9[r]}function LP(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function d9(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var h9=MP,f9=jP,p9=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},Wo=new WeakMap,hd=new WeakMap,fd={},Em=0,DP=function(e){return e&&(e.host||DP(e.parentNode))},m9=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=DP(n);return r&&e.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},g9=function(e,t,n,r){var i=m9(t,Array.isArray(e)?e:[e]);fd[n]||(fd[n]=new WeakMap);var s=fd[n],o=[],a=new Set,l=new Set(i),c=function(d){!d||a.has(d)||(a.add(d),c(d.parentNode))};i.forEach(c);var u=function(d){!d||l.has(d)||Array.prototype.forEach.call(d.children,function(f){if(a.has(f))u(f);else try{var p=f.getAttribute(r),m=p!==null&&p!=="false",v=(Wo.get(f)||0)+1,b=(s.get(f)||0)+1;Wo.set(f,v),s.set(f,b),o.push(f),v===1&&m&&hd.set(f,!0),b===1&&f.setAttribute(n,"true"),m||f.setAttribute(r,"true")}catch(x){console.error("aria-hidden: cannot operate on ",f,x)}})};return u(t),a.clear(),Em++,function(){o.forEach(function(d){var f=Wo.get(d)-1,p=s.get(d)-1;Wo.set(d,f),s.set(d,p),f||(hd.has(d)||d.removeAttribute(r),hd.delete(d)),p||d.removeAttribute(n)}),Em--,Em||(Wo=new WeakMap,Wo=new WeakMap,hd=new WeakMap,fd={})}},OP=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),i=p9(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll("[aria-live], script"))),g9(r,i,n,"aria-hidden")):function(){return null}},Xr=function(){return Xr=Object.assign||function(t){for(var n,r=1,i=arguments.length;r<i;r++){n=arguments[r];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(t[s]=n[s])}return t},Xr.apply(this,arguments)};function BP(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}function v9(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,s;r<i;r++)(s||!(r in t))&&(s||(s=Array.prototype.slice.call(t,0,r)),s[r]=t[r]);return e.concat(s||Array.prototype.slice.call(t))}var Yd="right-scroll-bar-position",Zd="width-before-scroll-bar",x9="with-scroll-bars-hidden",_9="--removed-body-scroll-bar-size";function Nm(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function y9(e,t){var n=g.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(r){var i=n.value;i!==r&&(n.value=r,n.callback(r,i))}}}})[0];return n.callback=t,n.facade}var b9=typeof window<"u"?g.useLayoutEffect:g.useEffect,Vw=new WeakMap;function w9(e,t){var n=y9(null,function(r){return e.forEach(function(i){return Nm(i,r)})});return b9(function(){var r=Vw.get(n);if(r){var i=new Set(r),s=new Set(e),o=n.current;i.forEach(function(a){s.has(a)||Nm(a,null)}),s.forEach(function(a){i.has(a)||Nm(a,o)})}Vw.set(n,e)},[e]),n}function S9(e){return e}function k9(e,t){t===void 0&&(t=S9);var n=[],r=!1,i={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(s){var o=t(s,r);return n.push(o),function(){n=n.filter(function(a){return a!==o})}},assignSyncMedium:function(s){for(r=!0;n.length;){var o=n;n=[],o.forEach(s)}n={push:function(a){return s(a)},filter:function(){return n}}},assignMedium:function(s){r=!0;var o=[];if(n.length){var a=n;n=[],a.forEach(s),o=n}var l=function(){var u=o;o=[],u.forEach(s)},c=function(){return Promise.resolve().then(l)};c(),n={push:function(u){o.push(u),c()},filter:function(u){return o=o.filter(u),n}}}};return i}function C9(e){e===void 0&&(e={});var t=k9(null);return t.options=Xr({async:!0,ssr:!1},e),t}var zP=function(e){var t=e.sideCar,n=BP(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return g.createElement(r,Xr({},n))};zP.isSideCarExport=!0;function E9(e,t){return e.useMedium(t),zP}var $P=C9(),Tm=function(){},sp=g.forwardRef(function(e,t){var n=g.useRef(null),r=g.useState({onScrollCapture:Tm,onWheelCapture:Tm,onTouchMoveCapture:Tm}),i=r[0],s=r[1],o=e.forwardProps,a=e.children,l=e.className,c=e.removeScrollBar,u=e.enabled,d=e.shards,f=e.sideCar,p=e.noRelative,m=e.noIsolation,v=e.inert,b=e.allowPinchZoom,x=e.as,_=x===void 0?"div":x,y=e.gapMode,w=BP(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),S=f,C=w9([n,t]),N=Xr(Xr({},w),i);return g.createElement(g.Fragment,null,u&&g.createElement(S,{sideCar:$P,removeScrollBar:c,shards:d,noRelative:p,noIsolation:m,inert:v,setCallbacks:s,allowPinchZoom:!!b,lockRef:n,gapMode:y}),o?g.cloneElement(g.Children.only(a),Xr(Xr({},N),{ref:C})):g.createElement(_,Xr({},N,{className:l,ref:C}),a))});sp.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};sp.classNames={fullWidth:Zd,zeroRight:Yd};var N9=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function T9(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=N9();return t&&e.setAttribute("nonce",t),e}function P9(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function I9(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var R9=function(){var e=0,t=null;return{add:function(n){e==0&&(t=T9())&&(P9(t,n),I9(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},M9=function(){var e=R9();return function(t,n){g.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},FP=function(){var e=M9(),t=function(n){var r=n.styles,i=n.dynamic;return e(r,i),null};return t},A9={left:0,top:0,right:0,gap:0},Pm=function(e){return parseInt(e||"",10)||0},j9=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],r=t[e==="padding"?"paddingTop":"marginTop"],i=t[e==="padding"?"paddingRight":"marginRight"];return[Pm(n),Pm(r),Pm(i)]},L9=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return A9;var t=j9(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},D9=FP(),ka="data-scroll-locked",O9=function(e,t,n,r){var i=e.left,s=e.top,o=e.right,a=e.gap;return n===void 0&&(n="margin"),`
|
|
455
|
+
*/const v$=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],x$=he("zap",v$);function AT(e){var t,n,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=AT(e[t]))&&(r&&(r+=" "),r+=n)}else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}function jT(){for(var e,t,n=0,r="",i=arguments.length;n<i;n++)(e=arguments[n])&&(t=AT(e))&&(r&&(r+=" "),r+=t);return r}const _$=(e,t)=>{const n=new Array(e.length+t.length);for(let r=0;r<e.length;r++)n[r]=e[r];for(let r=0;r<t.length;r++)n[e.length+r]=t[r];return n},y$=(e,t)=>({classGroupId:e,validator:t}),LT=(e=new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),Kh="-",yw=[],b$="arbitrary..",w$=e=>{const t=k$(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:o=>{if(o.startsWith("[")&&o.endsWith("]"))return S$(o);const a=o.split(Kh),l=a[0]===""&&a.length>1?1:0;return DT(a,l,t)},getConflictingClassGroupIds:(o,a)=>{if(a){const l=r[o],c=n[o];return l?c?_$(c,l):l:c||yw}return n[o]||yw}}},DT=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;const i=e[t],s=n.nextPart.get(i);if(s){const c=DT(e,t+1,s);if(c)return c}const o=n.validators;if(o===null)return;const a=t===0?e.join(Kh):e.slice(t).join(Kh),l=o.length;for(let c=0;c<l;c++){const u=o[c];if(u.validator(a))return u.classGroupId}},S$=e=>e.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const t=e.slice(1,-1),n=t.indexOf(":"),r=t.slice(0,n);return r?b$+r:void 0})(),k$=e=>{const{theme:t,classGroups:n}=e;return C$(n,t)},C$=(e,t)=>{const n=LT();for(const r in e){const i=e[r];P_(i,n,r,t)}return n},P_=(e,t,n,r)=>{const i=e.length;for(let s=0;s<i;s++){const o=e[s];E$(o,t,n,r)}},E$=(e,t,n,r)=>{if(typeof e=="string"){N$(e,t,n);return}if(typeof e=="function"){T$(e,t,n,r);return}P$(e,t,n,r)},N$=(e,t,n)=>{const r=e===""?t:OT(t,e);r.classGroupId=n},T$=(e,t,n,r)=>{if(I$(e)){P_(e(r),t,n,r);return}t.validators===null&&(t.validators=[]),t.validators.push(y$(n,e))},P$=(e,t,n,r)=>{const i=Object.entries(e),s=i.length;for(let o=0;o<s;o++){const[a,l]=i[o];P_(l,OT(t,a),n,r)}},OT=(e,t)=>{let n=e;const r=t.split(Kh),i=r.length;for(let s=0;s<i;s++){const o=r[s];let a=n.nextPart.get(o);a||(a=LT(),n.nextPart.set(o,a)),n=a}return n},I$=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,R$=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,n=Object.create(null),r=Object.create(null);const i=(s,o)=>{n[s]=o,t++,t>e&&(t=0,r=n,n=Object.create(null))};return{get(s){let o=n[s];if(o!==void 0)return o;if((o=r[s])!==void 0)return i(s,o),o},set(s,o){s in n?n[s]=o:i(s,o)}}},e0="!",bw=":",M$=[],ww=(e,t,n,r,i)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:r,isExternal:i}),A$=e=>{const{prefix:t,experimentalParseClassName:n}=e;let r=i=>{const s=[];let o=0,a=0,l=0,c;const u=i.length;for(let v=0;v<u;v++){const b=i[v];if(o===0&&a===0){if(b===bw){s.push(i.slice(l,v)),l=v+1;continue}if(b==="/"){c=v;continue}}b==="["?o++:b==="]"?o--:b==="("?a++:b===")"&&a--}const d=s.length===0?i:i.slice(l);let f=d,p=!1;d.endsWith(e0)?(f=d.slice(0,-1),p=!0):d.startsWith(e0)&&(f=d.slice(1),p=!0);const m=c&&c>l?c-l:void 0;return ww(s,p,f,m)};if(t){const i=t+bw,s=r;r=o=>o.startsWith(i)?s(o.slice(i.length)):ww(M$,!1,o,void 0,!0)}if(n){const i=r;r=s=>n({className:s,parseClassName:i})}return r},j$=e=>{const t=new Map;return e.orderSensitiveModifiers.forEach((n,r)=>{t.set(n,1e6+r)}),n=>{const r=[];let i=[];for(let s=0;s<n.length;s++){const o=n[s],a=o[0]==="[",l=t.has(o);a||l?(i.length>0&&(i.sort(),r.push(...i),i=[]),r.push(o)):i.push(o)}return i.length>0&&(i.sort(),r.push(...i)),r}},L$=e=>({cache:R$(e.cacheSize),parseClassName:A$(e),sortModifiers:j$(e),...w$(e)}),D$=/\s+/,O$=(e,t)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:i,sortModifiers:s}=t,o=[],a=e.trim().split(D$);let l="";for(let c=a.length-1;c>=0;c-=1){const u=a[c],{isExternal:d,modifiers:f,hasImportantModifier:p,baseClassName:m,maybePostfixModifierPosition:v}=n(u);if(d){l=u+(l.length>0?" "+l:l);continue}let b=!!v,x=r(b?m.substring(0,v):m);if(!x){if(!b){l=u+(l.length>0?" "+l:l);continue}if(x=r(m),!x){l=u+(l.length>0?" "+l:l);continue}b=!1}const _=f.length===0?"":f.length===1?f[0]:s(f).join(":"),y=p?_+e0:_,w=y+x;if(o.indexOf(w)>-1)continue;o.push(w);const S=i(x,b);for(let C=0;C<S.length;++C){const N=S[C];o.push(y+N)}l=u+(l.length>0?" "+l:l)}return l},B$=(...e)=>{let t=0,n,r,i="";for(;t<e.length;)(n=e[t++])&&(r=BT(n))&&(i&&(i+=" "),i+=r);return i},BT=e=>{if(typeof e=="string")return e;let t,n="";for(let r=0;r<e.length;r++)e[r]&&(t=BT(e[r]))&&(n&&(n+=" "),n+=t);return n},z$=(e,...t)=>{let n,r,i,s;const o=l=>{const c=t.reduce((u,d)=>d(u),e());return n=L$(c),r=n.cache.get,i=n.cache.set,s=a,a(l)},a=l=>{const c=r(l);if(c)return c;const u=O$(l,n);return i(l,u),u};return s=o,(...l)=>s(B$(...l))},$$=[],Ft=e=>{const t=n=>n[e]||$$;return t.isThemeGetter=!0,t},zT=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,$T=/^\((?:(\w[\w-]*):)?(.+)\)$/i,F$=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,H$=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,U$=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,W$=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,V$=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,q$=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Xi=e=>F$.test(e),Le=e=>!!e&&!Number.isNaN(Number(e)),Yi=e=>!!e&&Number.isInteger(Number(e)),xm=e=>e.endsWith("%")&&Le(e.slice(0,-1)),vi=e=>H$.test(e),FT=()=>!0,K$=e=>U$.test(e)&&!W$.test(e),I_=()=>!1,G$=e=>V$.test(e),X$=e=>q$.test(e),Y$=e=>!de(e)&&!fe(e),Z$=e=>Os(e,WT,I_),de=e=>zT.test(e),$s=e=>Os(e,VT,K$),Sw=e=>Os(e,sF,Le),Q$=e=>Os(e,KT,FT),J$=e=>Os(e,qT,I_),kw=e=>Os(e,HT,I_),eF=e=>Os(e,UT,X$),ld=e=>Os(e,GT,G$),fe=e=>$T.test(e),Il=e=>Io(e,VT),tF=e=>Io(e,qT),Cw=e=>Io(e,HT),nF=e=>Io(e,WT),rF=e=>Io(e,UT),cd=e=>Io(e,GT,!0),iF=e=>Io(e,KT,!0),Os=(e,t,n)=>{const r=zT.exec(e);return r?r[1]?t(r[1]):n(r[2]):!1},Io=(e,t,n=!1)=>{const r=$T.exec(e);return r?r[1]?t(r[1]):n:!1},HT=e=>e==="position"||e==="percentage",UT=e=>e==="image"||e==="url",WT=e=>e==="length"||e==="size"||e==="bg-size",VT=e=>e==="length",sF=e=>e==="number",qT=e=>e==="family-name",KT=e=>e==="number"||e==="weight",GT=e=>e==="shadow",oF=()=>{const e=Ft("color"),t=Ft("font"),n=Ft("text"),r=Ft("font-weight"),i=Ft("tracking"),s=Ft("leading"),o=Ft("breakpoint"),a=Ft("container"),l=Ft("spacing"),c=Ft("radius"),u=Ft("shadow"),d=Ft("inset-shadow"),f=Ft("text-shadow"),p=Ft("drop-shadow"),m=Ft("blur"),v=Ft("perspective"),b=Ft("aspect"),x=Ft("ease"),_=Ft("animate"),y=()=>["auto","avoid","all","avoid-page","page","left","right","column"],w=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],S=()=>[...w(),fe,de],C=()=>["auto","hidden","clip","visible","scroll"],N=()=>["auto","contain","none"],T=()=>[fe,de,l],M=()=>[Xi,"full","auto",...T()],P=()=>[Yi,"none","subgrid",fe,de],D=()=>["auto",{span:["full",Yi,fe,de]},Yi,fe,de],R=()=>[Yi,"auto",fe,de],I=()=>["auto","min","max","fr",fe,de],O=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],z=()=>["start","end","center","stretch","center-safe","end-safe"],$=()=>["auto",...T()],F=()=>[Xi,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...T()],L=()=>[Xi,"screen","full","dvw","lvw","svw","min","max","fit",...T()],B=()=>[Xi,"screen","full","lh","dvh","lvh","svh","min","max","fit",...T()],E=()=>[e,fe,de],H=()=>[...w(),Cw,kw,{position:[fe,de]}],q=()=>["no-repeat",{repeat:["","x","y","space","round"]}],A=()=>["auto","cover","contain",nF,Z$,{size:[fe,de]}],re=()=>[xm,Il,$s],oe=()=>["","none","full",c,fe,de],V=()=>["",Le,Il,$s],pe=()=>["solid","dashed","dotted","double"],Oe=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],ie=()=>[Le,xm,Cw,kw],Ae=()=>["","none",m,fe,de],Fe=()=>["none",Le,fe,de],We=()=>["none",Le,fe,de],ge=()=>[Le,fe,de],qe=()=>[Xi,"full",...T()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[vi],breakpoint:[vi],color:[FT],container:[vi],"drop-shadow":[vi],ease:["in","out","in-out"],font:[Y$],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[vi],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[vi],shadow:[vi],spacing:["px",Le],text:[vi],"text-shadow":[vi],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Xi,de,fe,b]}],container:["container"],columns:[{columns:[Le,de,fe,a]}],"break-after":[{"break-after":y()}],"break-before":[{"break-before":y()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:S()}],overflow:[{overflow:C()}],"overflow-x":[{"overflow-x":C()}],"overflow-y":[{"overflow-y":C()}],overscroll:[{overscroll:N()}],"overscroll-x":[{"overscroll-x":N()}],"overscroll-y":[{"overscroll-y":N()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:M()}],"inset-x":[{"inset-x":M()}],"inset-y":[{"inset-y":M()}],start:[{"inset-s":M(),start:M()}],end:[{"inset-e":M(),end:M()}],"inset-bs":[{"inset-bs":M()}],"inset-be":[{"inset-be":M()}],top:[{top:M()}],right:[{right:M()}],bottom:[{bottom:M()}],left:[{left:M()}],visibility:["visible","invisible","collapse"],z:[{z:[Yi,"auto",fe,de]}],basis:[{basis:[Xi,"full","auto",a,...T()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[Le,Xi,"auto","initial","none",de]}],grow:[{grow:["",Le,fe,de]}],shrink:[{shrink:["",Le,fe,de]}],order:[{order:[Yi,"first","last","none",fe,de]}],"grid-cols":[{"grid-cols":P()}],"col-start-end":[{col:D()}],"col-start":[{"col-start":R()}],"col-end":[{"col-end":R()}],"grid-rows":[{"grid-rows":P()}],"row-start-end":[{row:D()}],"row-start":[{"row-start":R()}],"row-end":[{"row-end":R()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":I()}],"auto-rows":[{"auto-rows":I()}],gap:[{gap:T()}],"gap-x":[{"gap-x":T()}],"gap-y":[{"gap-y":T()}],"justify-content":[{justify:[...O(),"normal"]}],"justify-items":[{"justify-items":[...z(),"normal"]}],"justify-self":[{"justify-self":["auto",...z()]}],"align-content":[{content:["normal",...O()]}],"align-items":[{items:[...z(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...z(),{baseline:["","last"]}]}],"place-content":[{"place-content":O()}],"place-items":[{"place-items":[...z(),"baseline"]}],"place-self":[{"place-self":["auto",...z()]}],p:[{p:T()}],px:[{px:T()}],py:[{py:T()}],ps:[{ps:T()}],pe:[{pe:T()}],pbs:[{pbs:T()}],pbe:[{pbe:T()}],pt:[{pt:T()}],pr:[{pr:T()}],pb:[{pb:T()}],pl:[{pl:T()}],m:[{m:$()}],mx:[{mx:$()}],my:[{my:$()}],ms:[{ms:$()}],me:[{me:$()}],mbs:[{mbs:$()}],mbe:[{mbe:$()}],mt:[{mt:$()}],mr:[{mr:$()}],mb:[{mb:$()}],ml:[{ml:$()}],"space-x":[{"space-x":T()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":T()}],"space-y-reverse":["space-y-reverse"],size:[{size:F()}],"inline-size":[{inline:["auto",...L()]}],"min-inline-size":[{"min-inline":["auto",...L()]}],"max-inline-size":[{"max-inline":["none",...L()]}],"block-size":[{block:["auto",...B()]}],"min-block-size":[{"min-block":["auto",...B()]}],"max-block-size":[{"max-block":["none",...B()]}],w:[{w:[a,"screen",...F()]}],"min-w":[{"min-w":[a,"screen","none",...F()]}],"max-w":[{"max-w":[a,"screen","none","prose",{screen:[o]},...F()]}],h:[{h:["screen","lh",...F()]}],"min-h":[{"min-h":["screen","lh","none",...F()]}],"max-h":[{"max-h":["screen","lh",...F()]}],"font-size":[{text:["base",n,Il,$s]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,iF,Q$]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",xm,de]}],"font-family":[{font:[tF,J$,t]}],"font-features":[{"font-features":[de]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[i,fe,de]}],"line-clamp":[{"line-clamp":[Le,"none",fe,Sw]}],leading:[{leading:[s,...T()]}],"list-image":[{"list-image":["none",fe,de]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",fe,de]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:E()}],"text-color":[{text:E()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...pe(),"wavy"]}],"text-decoration-thickness":[{decoration:[Le,"from-font","auto",fe,$s]}],"text-decoration-color":[{decoration:E()}],"underline-offset":[{"underline-offset":[Le,"auto",fe,de]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:T()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",fe,de]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",fe,de]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:H()}],"bg-repeat":[{bg:q()}],"bg-size":[{bg:A()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Yi,fe,de],radial:["",fe,de],conic:[Yi,fe,de]},rF,eF]}],"bg-color":[{bg:E()}],"gradient-from-pos":[{from:re()}],"gradient-via-pos":[{via:re()}],"gradient-to-pos":[{to:re()}],"gradient-from":[{from:E()}],"gradient-via":[{via:E()}],"gradient-to":[{to:E()}],rounded:[{rounded:oe()}],"rounded-s":[{"rounded-s":oe()}],"rounded-e":[{"rounded-e":oe()}],"rounded-t":[{"rounded-t":oe()}],"rounded-r":[{"rounded-r":oe()}],"rounded-b":[{"rounded-b":oe()}],"rounded-l":[{"rounded-l":oe()}],"rounded-ss":[{"rounded-ss":oe()}],"rounded-se":[{"rounded-se":oe()}],"rounded-ee":[{"rounded-ee":oe()}],"rounded-es":[{"rounded-es":oe()}],"rounded-tl":[{"rounded-tl":oe()}],"rounded-tr":[{"rounded-tr":oe()}],"rounded-br":[{"rounded-br":oe()}],"rounded-bl":[{"rounded-bl":oe()}],"border-w":[{border:V()}],"border-w-x":[{"border-x":V()}],"border-w-y":[{"border-y":V()}],"border-w-s":[{"border-s":V()}],"border-w-e":[{"border-e":V()}],"border-w-bs":[{"border-bs":V()}],"border-w-be":[{"border-be":V()}],"border-w-t":[{"border-t":V()}],"border-w-r":[{"border-r":V()}],"border-w-b":[{"border-b":V()}],"border-w-l":[{"border-l":V()}],"divide-x":[{"divide-x":V()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":V()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...pe(),"hidden","none"]}],"divide-style":[{divide:[...pe(),"hidden","none"]}],"border-color":[{border:E()}],"border-color-x":[{"border-x":E()}],"border-color-y":[{"border-y":E()}],"border-color-s":[{"border-s":E()}],"border-color-e":[{"border-e":E()}],"border-color-bs":[{"border-bs":E()}],"border-color-be":[{"border-be":E()}],"border-color-t":[{"border-t":E()}],"border-color-r":[{"border-r":E()}],"border-color-b":[{"border-b":E()}],"border-color-l":[{"border-l":E()}],"divide-color":[{divide:E()}],"outline-style":[{outline:[...pe(),"none","hidden"]}],"outline-offset":[{"outline-offset":[Le,fe,de]}],"outline-w":[{outline:["",Le,Il,$s]}],"outline-color":[{outline:E()}],shadow:[{shadow:["","none",u,cd,ld]}],"shadow-color":[{shadow:E()}],"inset-shadow":[{"inset-shadow":["none",d,cd,ld]}],"inset-shadow-color":[{"inset-shadow":E()}],"ring-w":[{ring:V()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:E()}],"ring-offset-w":[{"ring-offset":[Le,$s]}],"ring-offset-color":[{"ring-offset":E()}],"inset-ring-w":[{"inset-ring":V()}],"inset-ring-color":[{"inset-ring":E()}],"text-shadow":[{"text-shadow":["none",f,cd,ld]}],"text-shadow-color":[{"text-shadow":E()}],opacity:[{opacity:[Le,fe,de]}],"mix-blend":[{"mix-blend":[...Oe(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":Oe()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[Le]}],"mask-image-linear-from-pos":[{"mask-linear-from":ie()}],"mask-image-linear-to-pos":[{"mask-linear-to":ie()}],"mask-image-linear-from-color":[{"mask-linear-from":E()}],"mask-image-linear-to-color":[{"mask-linear-to":E()}],"mask-image-t-from-pos":[{"mask-t-from":ie()}],"mask-image-t-to-pos":[{"mask-t-to":ie()}],"mask-image-t-from-color":[{"mask-t-from":E()}],"mask-image-t-to-color":[{"mask-t-to":E()}],"mask-image-r-from-pos":[{"mask-r-from":ie()}],"mask-image-r-to-pos":[{"mask-r-to":ie()}],"mask-image-r-from-color":[{"mask-r-from":E()}],"mask-image-r-to-color":[{"mask-r-to":E()}],"mask-image-b-from-pos":[{"mask-b-from":ie()}],"mask-image-b-to-pos":[{"mask-b-to":ie()}],"mask-image-b-from-color":[{"mask-b-from":E()}],"mask-image-b-to-color":[{"mask-b-to":E()}],"mask-image-l-from-pos":[{"mask-l-from":ie()}],"mask-image-l-to-pos":[{"mask-l-to":ie()}],"mask-image-l-from-color":[{"mask-l-from":E()}],"mask-image-l-to-color":[{"mask-l-to":E()}],"mask-image-x-from-pos":[{"mask-x-from":ie()}],"mask-image-x-to-pos":[{"mask-x-to":ie()}],"mask-image-x-from-color":[{"mask-x-from":E()}],"mask-image-x-to-color":[{"mask-x-to":E()}],"mask-image-y-from-pos":[{"mask-y-from":ie()}],"mask-image-y-to-pos":[{"mask-y-to":ie()}],"mask-image-y-from-color":[{"mask-y-from":E()}],"mask-image-y-to-color":[{"mask-y-to":E()}],"mask-image-radial":[{"mask-radial":[fe,de]}],"mask-image-radial-from-pos":[{"mask-radial-from":ie()}],"mask-image-radial-to-pos":[{"mask-radial-to":ie()}],"mask-image-radial-from-color":[{"mask-radial-from":E()}],"mask-image-radial-to-color":[{"mask-radial-to":E()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":w()}],"mask-image-conic-pos":[{"mask-conic":[Le]}],"mask-image-conic-from-pos":[{"mask-conic-from":ie()}],"mask-image-conic-to-pos":[{"mask-conic-to":ie()}],"mask-image-conic-from-color":[{"mask-conic-from":E()}],"mask-image-conic-to-color":[{"mask-conic-to":E()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:H()}],"mask-repeat":[{mask:q()}],"mask-size":[{mask:A()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",fe,de]}],filter:[{filter:["","none",fe,de]}],blur:[{blur:Ae()}],brightness:[{brightness:[Le,fe,de]}],contrast:[{contrast:[Le,fe,de]}],"drop-shadow":[{"drop-shadow":["","none",p,cd,ld]}],"drop-shadow-color":[{"drop-shadow":E()}],grayscale:[{grayscale:["",Le,fe,de]}],"hue-rotate":[{"hue-rotate":[Le,fe,de]}],invert:[{invert:["",Le,fe,de]}],saturate:[{saturate:[Le,fe,de]}],sepia:[{sepia:["",Le,fe,de]}],"backdrop-filter":[{"backdrop-filter":["","none",fe,de]}],"backdrop-blur":[{"backdrop-blur":Ae()}],"backdrop-brightness":[{"backdrop-brightness":[Le,fe,de]}],"backdrop-contrast":[{"backdrop-contrast":[Le,fe,de]}],"backdrop-grayscale":[{"backdrop-grayscale":["",Le,fe,de]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Le,fe,de]}],"backdrop-invert":[{"backdrop-invert":["",Le,fe,de]}],"backdrop-opacity":[{"backdrop-opacity":[Le,fe,de]}],"backdrop-saturate":[{"backdrop-saturate":[Le,fe,de]}],"backdrop-sepia":[{"backdrop-sepia":["",Le,fe,de]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":T()}],"border-spacing-x":[{"border-spacing-x":T()}],"border-spacing-y":[{"border-spacing-y":T()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",fe,de]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[Le,"initial",fe,de]}],ease:[{ease:["linear","initial",x,fe,de]}],delay:[{delay:[Le,fe,de]}],animate:[{animate:["none",_,fe,de]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[v,fe,de]}],"perspective-origin":[{"perspective-origin":S()}],rotate:[{rotate:Fe()}],"rotate-x":[{"rotate-x":Fe()}],"rotate-y":[{"rotate-y":Fe()}],"rotate-z":[{"rotate-z":Fe()}],scale:[{scale:We()}],"scale-x":[{"scale-x":We()}],"scale-y":[{"scale-y":We()}],"scale-z":[{"scale-z":We()}],"scale-3d":["scale-3d"],skew:[{skew:ge()}],"skew-x":[{"skew-x":ge()}],"skew-y":[{"skew-y":ge()}],transform:[{transform:[fe,de,"","none","gpu","cpu"]}],"transform-origin":[{origin:S()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:qe()}],"translate-x":[{"translate-x":qe()}],"translate-y":[{"translate-y":qe()}],"translate-z":[{"translate-z":qe()}],"translate-none":["translate-none"],accent:[{accent:E()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:E()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",fe,de]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":T()}],"scroll-mx":[{"scroll-mx":T()}],"scroll-my":[{"scroll-my":T()}],"scroll-ms":[{"scroll-ms":T()}],"scroll-me":[{"scroll-me":T()}],"scroll-mbs":[{"scroll-mbs":T()}],"scroll-mbe":[{"scroll-mbe":T()}],"scroll-mt":[{"scroll-mt":T()}],"scroll-mr":[{"scroll-mr":T()}],"scroll-mb":[{"scroll-mb":T()}],"scroll-ml":[{"scroll-ml":T()}],"scroll-p":[{"scroll-p":T()}],"scroll-px":[{"scroll-px":T()}],"scroll-py":[{"scroll-py":T()}],"scroll-ps":[{"scroll-ps":T()}],"scroll-pe":[{"scroll-pe":T()}],"scroll-pbs":[{"scroll-pbs":T()}],"scroll-pbe":[{"scroll-pbe":T()}],"scroll-pt":[{"scroll-pt":T()}],"scroll-pr":[{"scroll-pr":T()}],"scroll-pb":[{"scroll-pb":T()}],"scroll-pl":[{"scroll-pl":T()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",fe,de]}],fill:[{fill:["none",...E()]}],"stroke-w":[{stroke:[Le,Il,$s,Sw]}],stroke:[{stroke:["none",...E()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","inset-bs","inset-be","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pbs","pbe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mbs","mbe","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-bs","border-w-be","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-bs","border-color-be","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mbs","scroll-mbe","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pbs","scroll-pbe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},aF=z$(oF);function ne(...e){return aF(jT(e))}function Gd(e){return e==="codex"?"Codex":"Claude Code"}function R_(e){return e==="claude"?"text-engine-claude":e==="codex"?"text-engine-codex":"text-text-400"}const XT=[{key:"research",Icon:Jv,label:"研究"},{key:"code",Icon:rz,label:"开发"},{key:"loop",Icon:Xz,label:"Loop 任务"},{key:"qa",Icon:NT,label:"问答"},{key:"reading",Icon:$6,label:"阅读"},{key:"debug",Icon:V6,label:"调试"},{key:"idea",Icon:qh,label:"创意"},{key:"doc",Icon:Ds,label:"文档"},{key:"assist",Icon:Nz,label:"助手"}],lF=new Map(XT.map(e=>[e.key,e]));function YT(e){return e?lF.get(e)??null:null}function ZT(e,t){const n=R_(t),r=YT(e);return r?{Component:r.Icon,colorClass:n}:{Component:f$,colorClass:n}}function cF(e){const t=new Date(e),n=Date.now()-t.getTime(),r=Math.floor(n/6e4);if(r<1)return"just now";if(r<60)return`${r}m ago`;const i=Math.floor(r/60);if(i<24)return`${i}h ago`;const s=Math.floor(i/24);return s<7?`${s}d ago`:t.toLocaleDateString()}function Pe(e,t,{checkForDefaultPrevented:n=!0}={}){return function(i){if(e==null||e(i),n===!1||!i.defaultPrevented)return t==null?void 0:t(i)}}function Ew(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function gu(...e){return t=>{let n=!1;const r=e.map(i=>{const s=Ew(i,t);return!n&&typeof s=="function"&&(n=!0),s});if(n)return()=>{for(let i=0;i<r.length;i++){const s=r[i];typeof s=="function"?s():Ew(e[i],null)}}}}function qt(...e){return g.useCallback(gu(...e),e)}function uF(e,t){const n=g.createContext(t),r=s=>{const{children:o,...a}=s,l=g.useMemo(()=>a,Object.values(a));return h.jsx(n.Provider,{value:l,children:o})};r.displayName=e+"Provider";function i(s){const o=g.useContext(n);if(o)return o;if(t!==void 0)return t;throw new Error(`\`${s}\` must be used within \`${e}\``)}return[r,i]}function Ro(e,t=[]){let n=[];function r(s,o){const a=g.createContext(o),l=n.length;n=[...n,o];const c=d=>{var x;const{scope:f,children:p,...m}=d,v=((x=f==null?void 0:f[e])==null?void 0:x[l])||a,b=g.useMemo(()=>m,Object.values(m));return h.jsx(v.Provider,{value:b,children:p})};c.displayName=s+"Provider";function u(d,f){var v;const p=((v=f==null?void 0:f[e])==null?void 0:v[l])||a,m=g.useContext(p);if(m)return m;if(o!==void 0)return o;throw new Error(`\`${d}\` must be used within \`${s}\``)}return[c,u]}const i=()=>{const s=n.map(o=>g.createContext(o));return function(a){const l=(a==null?void 0:a[e])||s;return g.useMemo(()=>({[`__scope${e}`]:{...a,[e]:l}}),[a,l])}};return i.scopeName=e,[r,dF(i,...t)]}function dF(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(i=>({useScope:i(),scopeName:i.scopeName}));return function(s){const o=r.reduce((a,{useScope:l,scopeName:c})=>{const d=l(s)[`__scope${c}`];return{...a,...d}},{});return g.useMemo(()=>({[`__scope${t.scopeName}`]:o}),[o])}};return n.scopeName=t.scopeName,n}var Ps=globalThis!=null&&globalThis.document?g.useLayoutEffect:()=>{},hF=Ya[" useInsertionEffect ".trim().toString()]||Ps;function Qf({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[i,s,o]=fF({defaultProp:t,onChange:n}),a=e!==void 0,l=a?e:i;{const u=g.useRef(e!==void 0);g.useEffect(()=>{const d=u.current;d!==a&&console.warn(`${r} is changing from ${d?"controlled":"uncontrolled"} to ${a?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),u.current=a},[a,r])}const c=g.useCallback(u=>{var d;if(a){const f=pF(u)?u(e):u;f!==e&&((d=o.current)==null||d.call(o,f))}else s(u)},[a,e,s,o]);return[l,c]}function fF({defaultProp:e,onChange:t}){const[n,r]=g.useState(e),i=g.useRef(n),s=g.useRef(t);return hF(()=>{s.current=t},[t]),g.useEffect(()=>{var o;i.current!==n&&((o=s.current)==null||o.call(s,n),i.current=n)},[n,i]),[n,r,s]}function pF(e){return typeof e=="function"}function Wc(e){const t=mF(e),n=g.forwardRef((r,i)=>{const{children:s,...o}=r,a=g.Children.toArray(s),l=a.find(vF);if(l){const c=l.props.children,u=a.map(d=>d===l?g.Children.count(c)>1?g.Children.only(null):g.isValidElement(c)?c.props.children:null:d);return h.jsx(t,{...o,ref:i,children:g.isValidElement(c)?g.cloneElement(c,void 0,u):null})}return h.jsx(t,{...o,ref:i,children:s})});return n.displayName=`${e}.Slot`,n}function mF(e){const t=g.forwardRef((n,r)=>{const{children:i,...s}=n;if(g.isValidElement(i)){const o=_F(i),a=xF(s,i.props);return i.type!==g.Fragment&&(a.ref=r?gu(r,o):o),g.cloneElement(i,a)}return g.Children.count(i)>1?g.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var QT=Symbol("radix.slottable");function gF(e){const t=({children:n})=>h.jsx(h.Fragment,{children:n});return t.displayName=`${e}.Slottable`,t.__radixId=QT,t}function vF(e){return g.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===QT}function xF(e,t){const n={...t};for(const r in t){const i=e[r],s=t[r];/^on[A-Z]/.test(r)?i&&s?n[r]=(...a)=>{const l=s(...a);return i(...a),l}:i&&(n[r]=i):r==="style"?n[r]={...i,...s}:r==="className"&&(n[r]=[i,s].filter(Boolean).join(" "))}return{...e,...n}}function _F(e){var r,i;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(i=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:i.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var yF=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Et=yF.reduce((e,t)=>{const n=Wc(`Primitive.${t}`),r=g.forwardRef((i,s)=>{const{asChild:o,...a}=i,l=o?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),h.jsx(l,{...a,ref:s})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function JT(e,t){e&&hu.flushSync(()=>e.dispatchEvent(t))}function eP(e){const t=e+"CollectionProvider",[n,r]=Ro(t),[i,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),o=v=>{const{scope:b,children:x}=v,_=st.useRef(null),y=st.useRef(new Map).current;return h.jsx(i,{scope:b,itemMap:y,collectionRef:_,children:x})};o.displayName=t;const a=e+"CollectionSlot",l=Wc(a),c=st.forwardRef((v,b)=>{const{scope:x,children:_}=v,y=s(a,x),w=qt(b,y.collectionRef);return h.jsx(l,{ref:w,children:_})});c.displayName=a;const u=e+"CollectionItemSlot",d="data-radix-collection-item",f=Wc(u),p=st.forwardRef((v,b)=>{const{scope:x,children:_,...y}=v,w=st.useRef(null),S=qt(b,w),C=s(u,x);return st.useEffect(()=>(C.itemMap.set(w,{ref:w,...y}),()=>void C.itemMap.delete(w))),h.jsx(f,{[d]:"",ref:S,children:_})});p.displayName=u;function m(v){const b=s(e+"CollectionConsumer",v);return st.useCallback(()=>{const _=b.collectionRef.current;if(!_)return[];const y=Array.from(_.querySelectorAll(`[${d}]`));return Array.from(b.itemMap.values()).sort((C,N)=>y.indexOf(C.ref.current)-y.indexOf(N.ref.current))},[b.collectionRef,b.itemMap])}return[{Provider:o,Slot:c,ItemSlot:p},m,r]}var bF=g.createContext(void 0);function tP(e){const t=g.useContext(bF);return e||t||"ltr"}function ji(e){const t=g.useRef(e);return g.useEffect(()=>{t.current=e}),g.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function wF(e,t=globalThis==null?void 0:globalThis.document){const n=ji(e);g.useEffect(()=>{const r=i=>{i.key==="Escape"&&n(i)};return t.addEventListener("keydown",r,{capture:!0}),()=>t.removeEventListener("keydown",r,{capture:!0})},[n,t])}var SF="DismissableLayer",t0="dismissableLayer.update",kF="dismissableLayer.pointerDownOutside",CF="dismissableLayer.focusOutside",Nw,nP=g.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Jf=g.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:i,onFocusOutside:s,onInteractOutside:o,onDismiss:a,...l}=e,c=g.useContext(nP),[u,d]=g.useState(null),f=(u==null?void 0:u.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,p]=g.useState({}),m=qt(t,N=>d(N)),v=Array.from(c.layers),[b]=[...c.layersWithOutsidePointerEventsDisabled].slice(-1),x=v.indexOf(b),_=u?v.indexOf(u):-1,y=c.layersWithOutsidePointerEventsDisabled.size>0,w=_>=x,S=TF(N=>{const T=N.target,M=[...c.branches].some(P=>P.contains(T));!w||M||(i==null||i(N),o==null||o(N),N.defaultPrevented||a==null||a())},f),C=PF(N=>{const T=N.target;[...c.branches].some(P=>P.contains(T))||(s==null||s(N),o==null||o(N),N.defaultPrevented||a==null||a())},f);return wF(N=>{_===c.layers.size-1&&(r==null||r(N),!N.defaultPrevented&&a&&(N.preventDefault(),a()))},f),g.useEffect(()=>{if(u)return n&&(c.layersWithOutsidePointerEventsDisabled.size===0&&(Nw=f.body.style.pointerEvents,f.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(u)),c.layers.add(u),Tw(),()=>{n&&c.layersWithOutsidePointerEventsDisabled.size===1&&(f.body.style.pointerEvents=Nw)}},[u,f,n,c]),g.useEffect(()=>()=>{u&&(c.layers.delete(u),c.layersWithOutsidePointerEventsDisabled.delete(u),Tw())},[u,c]),g.useEffect(()=>{const N=()=>p({});return document.addEventListener(t0,N),()=>document.removeEventListener(t0,N)},[]),h.jsx(Et.div,{...l,ref:m,style:{pointerEvents:y?w?"auto":"none":void 0,...e.style},onFocusCapture:Pe(e.onFocusCapture,C.onFocusCapture),onBlurCapture:Pe(e.onBlurCapture,C.onBlurCapture),onPointerDownCapture:Pe(e.onPointerDownCapture,S.onPointerDownCapture)})});Jf.displayName=SF;var EF="DismissableLayerBranch",NF=g.forwardRef((e,t)=>{const n=g.useContext(nP),r=g.useRef(null),i=qt(t,r);return g.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),h.jsx(Et.div,{...e,ref:i})});NF.displayName=EF;function TF(e,t=globalThis==null?void 0:globalThis.document){const n=ji(e),r=g.useRef(!1),i=g.useRef(()=>{});return g.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let l=function(){rP(kF,n,c,{discrete:!0})};const c={originalEvent:a};a.pointerType==="touch"?(t.removeEventListener("click",i.current),i.current=l,t.addEventListener("click",i.current,{once:!0})):l()}else t.removeEventListener("click",i.current);r.current=!1},o=window.setTimeout(()=>{t.addEventListener("pointerdown",s)},0);return()=>{window.clearTimeout(o),t.removeEventListener("pointerdown",s),t.removeEventListener("click",i.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function PF(e,t=globalThis==null?void 0:globalThis.document){const n=ji(e),r=g.useRef(!1);return g.useEffect(()=>{const i=s=>{s.target&&!r.current&&rP(CF,n,{originalEvent:s},{discrete:!1})};return t.addEventListener("focusin",i),()=>t.removeEventListener("focusin",i)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function Tw(){const e=new CustomEvent(t0);document.dispatchEvent(e)}function rP(e,t,n,{discrete:r}){const i=n.originalEvent.target,s=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?JT(i,s):i.dispatchEvent(s)}var _m=0;function iP(){g.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Pw()),document.body.insertAdjacentElement("beforeend",e[1]??Pw()),_m++,()=>{_m===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),_m--}},[])}function Pw(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var ym="focusScope.autoFocusOnMount",bm="focusScope.autoFocusOnUnmount",Iw={bubbles:!1,cancelable:!0},IF="FocusScope",M_=g.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:i,onUnmountAutoFocus:s,...o}=e,[a,l]=g.useState(null),c=ji(i),u=ji(s),d=g.useRef(null),f=qt(t,v=>l(v)),p=g.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;g.useEffect(()=>{if(r){let v=function(y){if(p.paused||!a)return;const w=y.target;a.contains(w)?d.current=w:ns(d.current,{select:!0})},b=function(y){if(p.paused||!a)return;const w=y.relatedTarget;w!==null&&(a.contains(w)||ns(d.current,{select:!0}))},x=function(y){if(document.activeElement===document.body)for(const S of y)S.removedNodes.length>0&&ns(a)};document.addEventListener("focusin",v),document.addEventListener("focusout",b);const _=new MutationObserver(x);return a&&_.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",v),document.removeEventListener("focusout",b),_.disconnect()}}},[r,a,p.paused]),g.useEffect(()=>{if(a){Mw.add(p);const v=document.activeElement;if(!a.contains(v)){const x=new CustomEvent(ym,Iw);a.addEventListener(ym,c),a.dispatchEvent(x),x.defaultPrevented||(RF(DF(sP(a)),{select:!0}),document.activeElement===v&&ns(a))}return()=>{a.removeEventListener(ym,c),setTimeout(()=>{const x=new CustomEvent(bm,Iw);a.addEventListener(bm,u),a.dispatchEvent(x),x.defaultPrevented||ns(v??document.body,{select:!0}),a.removeEventListener(bm,u),Mw.remove(p)},0)}}},[a,c,u,p]);const m=g.useCallback(v=>{if(!n&&!r||p.paused)return;const b=v.key==="Tab"&&!v.altKey&&!v.ctrlKey&&!v.metaKey,x=document.activeElement;if(b&&x){const _=v.currentTarget,[y,w]=MF(_);y&&w?!v.shiftKey&&x===w?(v.preventDefault(),n&&ns(y,{select:!0})):v.shiftKey&&x===y&&(v.preventDefault(),n&&ns(w,{select:!0})):x===_&&v.preventDefault()}},[n,r,p.paused]);return h.jsx(Et.div,{tabIndex:-1,...o,ref:f,onKeyDown:m})});M_.displayName=IF;function RF(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(ns(r,{select:t}),document.activeElement!==n)return}function MF(e){const t=sP(e),n=Rw(t,e),r=Rw(t.reverse(),e);return[n,r]}function sP(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const i=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||i?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function Rw(e,t){for(const n of e)if(!AF(n,{upTo:t}))return n}function AF(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function jF(e){return e instanceof HTMLInputElement&&"select"in e}function ns(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&jF(e)&&t&&e.select()}}var Mw=LF();function LF(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=Aw(e,t),e.unshift(t)},remove(t){var n;e=Aw(e,t),(n=e[0])==null||n.resume()}}}function Aw(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function DF(e){return e.filter(t=>t.tagName!=="A")}var OF=Ya[" useId ".trim().toString()]||(()=>{}),BF=0;function oo(e){const[t,n]=g.useState(OF());return Ps(()=>{n(r=>r??String(BF++))},[e]),t?`radix-${t}`:""}const zF=["top","right","bottom","left"],Is=Math.min,Zn=Math.max,Gh=Math.round,ud=Math.floor,ni=e=>({x:e,y:e}),$F={left:"right",right:"left",bottom:"top",top:"bottom"};function n0(e,t,n){return Zn(e,Is(t,n))}function Li(e,t){return typeof e=="function"?e(t):e}function Di(e){return e.split("-")[0]}function al(e){return e.split("-")[1]}function A_(e){return e==="x"?"y":"x"}function j_(e){return e==="y"?"height":"width"}function Yr(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function L_(e){return A_(Yr(e))}function FF(e,t,n){n===void 0&&(n=!1);const r=al(e),i=L_(e),s=j_(i);let o=i==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(o=Xh(o)),[o,Xh(o)]}function HF(e){const t=Xh(e);return[r0(e),t,r0(t)]}function r0(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const jw=["left","right"],Lw=["right","left"],UF=["top","bottom"],WF=["bottom","top"];function VF(e,t,n){switch(e){case"top":case"bottom":return n?t?Lw:jw:t?jw:Lw;case"left":case"right":return t?UF:WF;default:return[]}}function qF(e,t,n,r){const i=al(e);let s=VF(Di(e),n==="start",r);return i&&(s=s.map(o=>o+"-"+i),t&&(s=s.concat(s.map(r0)))),s}function Xh(e){const t=Di(e);return $F[t]+e.slice(t.length)}function KF(e){return{top:0,right:0,bottom:0,left:0,...e}}function oP(e){return typeof e!="number"?KF(e):{top:e,right:e,bottom:e,left:e}}function Yh(e){const{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function Dw(e,t,n){let{reference:r,floating:i}=e;const s=Yr(t),o=L_(t),a=j_(o),l=Di(t),c=s==="y",u=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=r[a]/2-i[a]/2;let p;switch(l){case"top":p={x:u,y:r.y-i.height};break;case"bottom":p={x:u,y:r.y+r.height};break;case"right":p={x:r.x+r.width,y:d};break;case"left":p={x:r.x-i.width,y:d};break;default:p={x:r.x,y:r.y}}switch(al(t)){case"start":p[o]-=f*(n&&c?-1:1);break;case"end":p[o]+=f*(n&&c?-1:1);break}return p}async function GF(e,t){var n;t===void 0&&(t={});const{x:r,y:i,platform:s,rects:o,elements:a,strategy:l}=e,{boundary:c="clippingAncestors",rootBoundary:u="viewport",elementContext:d="floating",altBoundary:f=!1,padding:p=0}=Li(t,e),m=oP(p),b=a[f?d==="floating"?"reference":"floating":d],x=Yh(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(b)))==null||n?b:b.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(a.floating)),boundary:c,rootBoundary:u,strategy:l})),_=d==="floating"?{x:r,y:i,width:o.floating.width,height:o.floating.height}:o.reference,y=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),w=await(s.isElement==null?void 0:s.isElement(y))?await(s.getScale==null?void 0:s.getScale(y))||{x:1,y:1}:{x:1,y:1},S=Yh(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:_,offsetParent:y,strategy:l}):_);return{top:(x.top-S.top+m.top)/w.y,bottom:(S.bottom-x.bottom+m.bottom)/w.y,left:(x.left-S.left+m.left)/w.x,right:(S.right-x.right+m.right)/w.x}}const XF=50,YF=async(e,t,n)=>{const{placement:r="bottom",strategy:i="absolute",middleware:s=[],platform:o}=n,a=o.detectOverflow?o:{...o,detectOverflow:GF},l=await(o.isRTL==null?void 0:o.isRTL(t));let c=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=Dw(c,r,l),f=r,p=0;const m={};for(let v=0;v<s.length;v++){const b=s[v];if(!b)continue;const{name:x,fn:_}=b,{x:y,y:w,data:S,reset:C}=await _({x:u,y:d,initialPlacement:r,placement:f,strategy:i,middlewareData:m,rects:c,platform:a,elements:{reference:e,floating:t}});u=y??u,d=w??d,m[x]={...m[x],...S},C&&p<XF&&(p++,typeof C=="object"&&(C.placement&&(f=C.placement),C.rects&&(c=C.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):C.rects),{x:u,y:d}=Dw(c,f,l)),v=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},ZF=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:i,rects:s,platform:o,elements:a,middlewareData:l}=t,{element:c,padding:u=0}=Li(e,t)||{};if(c==null)return{};const d=oP(u),f={x:n,y:r},p=L_(i),m=j_(p),v=await o.getDimensions(c),b=p==="y",x=b?"top":"left",_=b?"bottom":"right",y=b?"clientHeight":"clientWidth",w=s.reference[m]+s.reference[p]-f[p]-s.floating[m],S=f[p]-s.reference[p],C=await(o.getOffsetParent==null?void 0:o.getOffsetParent(c));let N=C?C[y]:0;(!N||!await(o.isElement==null?void 0:o.isElement(C)))&&(N=a.floating[y]||s.floating[m]);const T=w/2-S/2,M=N/2-v[m]/2-1,P=Is(d[x],M),D=Is(d[_],M),R=P,I=N-v[m]-D,O=N/2-v[m]/2+T,z=n0(R,O,I),$=!l.arrow&&al(i)!=null&&O!==z&&s.reference[m]/2-(O<R?P:D)-v[m]/2<0,F=$?O<R?O-R:O-I:0;return{[p]:f[p]+F,data:{[p]:z,centerOffset:O-z-F,...$&&{alignmentOffset:F}},reset:$}}}),QF=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:i,middlewareData:s,rects:o,initialPlacement:a,platform:l,elements:c}=t,{mainAxis:u=!0,crossAxis:d=!0,fallbackPlacements:f,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:m="none",flipAlignment:v=!0,...b}=Li(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const x=Di(i),_=Yr(a),y=Di(a)===a,w=await(l.isRTL==null?void 0:l.isRTL(c.floating)),S=f||(y||!v?[Xh(a)]:HF(a)),C=m!=="none";!f&&C&&S.push(...qF(a,v,m,w));const N=[a,...S],T=await l.detectOverflow(t,b),M=[];let P=((r=s.flip)==null?void 0:r.overflows)||[];if(u&&M.push(T[x]),d){const O=FF(i,o,w);M.push(T[O[0]],T[O[1]])}if(P=[...P,{placement:i,overflows:M}],!M.every(O=>O<=0)){var D,R;const O=(((D=s.flip)==null?void 0:D.index)||0)+1,z=N[O];if(z&&(!(d==="alignment"?_!==Yr(z):!1)||P.every(L=>Yr(L.placement)===_?L.overflows[0]>0:!0)))return{data:{index:O,overflows:P},reset:{placement:z}};let $=(R=P.filter(F=>F.overflows[0]<=0).sort((F,L)=>F.overflows[1]-L.overflows[1])[0])==null?void 0:R.placement;if(!$)switch(p){case"bestFit":{var I;const F=(I=P.filter(L=>{if(C){const B=Yr(L.placement);return B===_||B==="y"}return!0}).map(L=>[L.placement,L.overflows.filter(B=>B>0).reduce((B,E)=>B+E,0)]).sort((L,B)=>L[1]-B[1])[0])==null?void 0:I[0];F&&($=F);break}case"initialPlacement":$=a;break}if(i!==$)return{reset:{placement:$}}}return{}}}};function Ow(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Bw(e){return zF.some(t=>e[t]>=0)}const JF=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:r}=t,{strategy:i="referenceHidden",...s}=Li(e,t);switch(i){case"referenceHidden":{const o=await r.detectOverflow(t,{...s,elementContext:"reference"}),a=Ow(o,n.reference);return{data:{referenceHiddenOffsets:a,referenceHidden:Bw(a)}}}case"escaped":{const o=await r.detectOverflow(t,{...s,altBoundary:!0}),a=Ow(o,n.floating);return{data:{escapedOffsets:a,escaped:Bw(a)}}}default:return{}}}}},aP=new Set(["left","top"]);async function e8(e,t){const{placement:n,platform:r,elements:i}=e,s=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=Di(n),a=al(n),l=Yr(n)==="y",c=aP.has(o)?-1:1,u=s&&l?-1:1,d=Li(t,e);let{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return a&&typeof m=="number"&&(p=a==="end"?m*-1:m),l?{x:p*u,y:f*c}:{x:f*c,y:p*u}}const t8=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:i,y:s,placement:o,middlewareData:a}=t,l=await e8(t,e);return o===((n=a.offset)==null?void 0:n.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:i+l.x,y:s+l.y,data:{...l,placement:o}}}}},n8=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:i,platform:s}=t,{mainAxis:o=!0,crossAxis:a=!1,limiter:l={fn:x=>{let{x:_,y}=x;return{x:_,y}}},...c}=Li(e,t),u={x:n,y:r},d=await s.detectOverflow(t,c),f=Yr(Di(i)),p=A_(f);let m=u[p],v=u[f];if(o){const x=p==="y"?"top":"left",_=p==="y"?"bottom":"right",y=m+d[x],w=m-d[_];m=n0(y,m,w)}if(a){const x=f==="y"?"top":"left",_=f==="y"?"bottom":"right",y=v+d[x],w=v-d[_];v=n0(y,v,w)}const b=l.fn({...t,[p]:m,[f]:v});return{...b,data:{x:b.x-n,y:b.y-r,enabled:{[p]:o,[f]:a}}}}}},r8=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:i,rects:s,middlewareData:o}=t,{offset:a=0,mainAxis:l=!0,crossAxis:c=!0}=Li(e,t),u={x:n,y:r},d=Yr(i),f=A_(d);let p=u[f],m=u[d];const v=Li(a,t),b=typeof v=="number"?{mainAxis:v,crossAxis:0}:{mainAxis:0,crossAxis:0,...v};if(l){const y=f==="y"?"height":"width",w=s.reference[f]-s.floating[y]+b.mainAxis,S=s.reference[f]+s.reference[y]-b.mainAxis;p<w?p=w:p>S&&(p=S)}if(c){var x,_;const y=f==="y"?"width":"height",w=aP.has(Di(i)),S=s.reference[d]-s.floating[y]+(w&&((x=o.offset)==null?void 0:x[d])||0)+(w?0:b.crossAxis),C=s.reference[d]+s.reference[y]+(w?0:((_=o.offset)==null?void 0:_[d])||0)-(w?b.crossAxis:0);m<S?m=S:m>C&&(m=C)}return{[f]:p,[d]:m}}}},i8=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:i,rects:s,platform:o,elements:a}=t,{apply:l=()=>{},...c}=Li(e,t),u=await o.detectOverflow(t,c),d=Di(i),f=al(i),p=Yr(i)==="y",{width:m,height:v}=s.floating;let b,x;d==="top"||d==="bottom"?(b=d,x=f===(await(o.isRTL==null?void 0:o.isRTL(a.floating))?"start":"end")?"left":"right"):(x=d,b=f==="end"?"top":"bottom");const _=v-u.top-u.bottom,y=m-u.left-u.right,w=Is(v-u[b],_),S=Is(m-u[x],y),C=!t.middlewareData.shift;let N=w,T=S;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(T=y),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(N=_),C&&!f){const P=Zn(u.left,0),D=Zn(u.right,0),R=Zn(u.top,0),I=Zn(u.bottom,0);p?T=m-2*(P!==0||D!==0?P+D:Zn(u.left,u.right)):N=v-2*(R!==0||I!==0?R+I:Zn(u.top,u.bottom))}await l({...t,availableWidth:T,availableHeight:N});const M=await o.getDimensions(a.floating);return m!==M.width||v!==M.height?{reset:{rects:!0}}:{}}}};function ep(){return typeof window<"u"}function ll(e){return lP(e)?(e.nodeName||"").toLowerCase():"#document"}function er(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function di(e){var t;return(t=(lP(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function lP(e){return ep()?e instanceof Node||e instanceof er(e).Node:!1}function Dr(e){return ep()?e instanceof Element||e instanceof er(e).Element:!1}function Fi(e){return ep()?e instanceof HTMLElement||e instanceof er(e).HTMLElement:!1}function zw(e){return!ep()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof er(e).ShadowRoot}function vu(e){const{overflow:t,overflowX:n,overflowY:r,display:i}=Or(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!=="inline"&&i!=="contents"}function s8(e){return/^(table|td|th)$/.test(ll(e))}function tp(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const o8=/transform|translate|scale|rotate|perspective|filter/,a8=/paint|layout|strict|content/,Fs=e=>!!e&&e!=="none";let wm;function D_(e){const t=Dr(e)?Or(e):e;return Fs(t.transform)||Fs(t.translate)||Fs(t.scale)||Fs(t.rotate)||Fs(t.perspective)||!O_()&&(Fs(t.backdropFilter)||Fs(t.filter))||o8.test(t.willChange||"")||a8.test(t.contain||"")}function l8(e){let t=Rs(e);for(;Fi(t)&&!$a(t);){if(D_(t))return t;if(tp(t))return null;t=Rs(t)}return null}function O_(){return wm==null&&(wm=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),wm}function $a(e){return/^(html|body|#document)$/.test(ll(e))}function Or(e){return er(e).getComputedStyle(e)}function np(e){return Dr(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Rs(e){if(ll(e)==="html")return e;const t=e.assignedSlot||e.parentNode||zw(e)&&e.host||di(e);return zw(t)?t.host:t}function cP(e){const t=Rs(e);return $a(t)?e.ownerDocument?e.ownerDocument.body:e.body:Fi(t)&&vu(t)?t:cP(t)}function Vc(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const i=cP(e),s=i===((r=e.ownerDocument)==null?void 0:r.body),o=er(i);if(s){const a=i0(o);return t.concat(o,o.visualViewport||[],vu(i)?i:[],a&&n?Vc(a):[])}else return t.concat(i,Vc(i,[],n))}function i0(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function uP(e){const t=Or(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const i=Fi(e),s=i?e.offsetWidth:n,o=i?e.offsetHeight:r,a=Gh(n)!==s||Gh(r)!==o;return a&&(n=s,r=o),{width:n,height:r,$:a}}function B_(e){return Dr(e)?e:e.contextElement}function Sa(e){const t=B_(e);if(!Fi(t))return ni(1);const n=t.getBoundingClientRect(),{width:r,height:i,$:s}=uP(t);let o=(s?Gh(n.width):n.width)/r,a=(s?Gh(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!a||!Number.isFinite(a))&&(a=1),{x:o,y:a}}const c8=ni(0);function dP(e){const t=er(e);return!O_()||!t.visualViewport?c8:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function u8(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==er(e)?!1:t}function xo(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const i=e.getBoundingClientRect(),s=B_(e);let o=ni(1);t&&(r?Dr(r)&&(o=Sa(r)):o=Sa(e));const a=u8(s,n,r)?dP(s):ni(0);let l=(i.left+a.x)/o.x,c=(i.top+a.y)/o.y,u=i.width/o.x,d=i.height/o.y;if(s){const f=er(s),p=r&&Dr(r)?er(r):r;let m=f,v=i0(m);for(;v&&r&&p!==m;){const b=Sa(v),x=v.getBoundingClientRect(),_=Or(v),y=x.left+(v.clientLeft+parseFloat(_.paddingLeft))*b.x,w=x.top+(v.clientTop+parseFloat(_.paddingTop))*b.y;l*=b.x,c*=b.y,u*=b.x,d*=b.y,l+=y,c+=w,m=er(v),v=i0(m)}}return Yh({width:u,height:d,x:l,y:c})}function rp(e,t){const n=np(e).scrollLeft;return t?t.left+n:xo(di(e)).left+n}function hP(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-rp(e,n),i=n.top+t.scrollTop;return{x:r,y:i}}function d8(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e;const s=i==="fixed",o=di(r),a=t?tp(t.floating):!1;if(r===o||a&&s)return n;let l={scrollLeft:0,scrollTop:0},c=ni(1);const u=ni(0),d=Fi(r);if((d||!d&&!s)&&((ll(r)!=="body"||vu(o))&&(l=np(r)),d)){const p=xo(r);c=Sa(r),u.x=p.x+r.clientLeft,u.y=p.y+r.clientTop}const f=o&&!d&&!s?hP(o,l):ni(0);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-l.scrollLeft*c.x+u.x+f.x,y:n.y*c.y-l.scrollTop*c.y+u.y+f.y}}function h8(e){return Array.from(e.getClientRects())}function f8(e){const t=di(e),n=np(e),r=e.ownerDocument.body,i=Zn(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=Zn(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let o=-n.scrollLeft+rp(e);const a=-n.scrollTop;return Or(r).direction==="rtl"&&(o+=Zn(t.clientWidth,r.clientWidth)-i),{width:i,height:s,x:o,y:a}}const $w=25;function p8(e,t){const n=er(e),r=di(e),i=n.visualViewport;let s=r.clientWidth,o=r.clientHeight,a=0,l=0;if(i){s=i.width,o=i.height;const u=O_();(!u||u&&t==="fixed")&&(a=i.offsetLeft,l=i.offsetTop)}const c=rp(r);if(c<=0){const u=r.ownerDocument,d=u.body,f=getComputedStyle(d),p=u.compatMode==="CSS1Compat"&&parseFloat(f.marginLeft)+parseFloat(f.marginRight)||0,m=Math.abs(r.clientWidth-d.clientWidth-p);m<=$w&&(s-=m)}else c<=$w&&(s+=c);return{width:s,height:o,x:a,y:l}}function m8(e,t){const n=xo(e,!0,t==="fixed"),r=n.top+e.clientTop,i=n.left+e.clientLeft,s=Fi(e)?Sa(e):ni(1),o=e.clientWidth*s.x,a=e.clientHeight*s.y,l=i*s.x,c=r*s.y;return{width:o,height:a,x:l,y:c}}function Fw(e,t,n){let r;if(t==="viewport")r=p8(e,n);else if(t==="document")r=f8(di(e));else if(Dr(t))r=m8(t,n);else{const i=dP(e);r={x:t.x-i.x,y:t.y-i.y,width:t.width,height:t.height}}return Yh(r)}function fP(e,t){const n=Rs(e);return n===t||!Dr(n)||$a(n)?!1:Or(n).position==="fixed"||fP(n,t)}function g8(e,t){const n=t.get(e);if(n)return n;let r=Vc(e,[],!1).filter(a=>Dr(a)&&ll(a)!=="body"),i=null;const s=Or(e).position==="fixed";let o=s?Rs(e):e;for(;Dr(o)&&!$a(o);){const a=Or(o),l=D_(o);!l&&a.position==="fixed"&&(i=null),(s?!l&&!i:!l&&a.position==="static"&&!!i&&(i.position==="absolute"||i.position==="fixed")||vu(o)&&!l&&fP(e,o))?r=r.filter(u=>u!==o):i=a,o=Rs(o)}return t.set(e,r),r}function v8(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e;const o=[...n==="clippingAncestors"?tp(t)?[]:g8(t,this._c):[].concat(n),r],a=Fw(t,o[0],i);let l=a.top,c=a.right,u=a.bottom,d=a.left;for(let f=1;f<o.length;f++){const p=Fw(t,o[f],i);l=Zn(p.top,l),c=Is(p.right,c),u=Is(p.bottom,u),d=Zn(p.left,d)}return{width:c-d,height:u-l,x:d,y:l}}function x8(e){const{width:t,height:n}=uP(e);return{width:t,height:n}}function _8(e,t,n){const r=Fi(t),i=di(t),s=n==="fixed",o=xo(e,!0,s,t);let a={scrollLeft:0,scrollTop:0};const l=ni(0);function c(){l.x=rp(i)}if(r||!r&&!s)if((ll(t)!=="body"||vu(i))&&(a=np(t)),r){const p=xo(t,!0,s,t);l.x=p.x+t.clientLeft,l.y=p.y+t.clientTop}else i&&c();s&&!r&&i&&c();const u=i&&!r&&!s?hP(i,a):ni(0),d=o.left+a.scrollLeft-l.x-u.x,f=o.top+a.scrollTop-l.y-u.y;return{x:d,y:f,width:o.width,height:o.height}}function Sm(e){return Or(e).position==="static"}function Hw(e,t){if(!Fi(e)||Or(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return di(e)===n&&(n=n.ownerDocument.body),n}function pP(e,t){const n=er(e);if(tp(e))return n;if(!Fi(e)){let i=Rs(e);for(;i&&!$a(i);){if(Dr(i)&&!Sm(i))return i;i=Rs(i)}return n}let r=Hw(e,t);for(;r&&s8(r)&&Sm(r);)r=Hw(r,t);return r&&$a(r)&&Sm(r)&&!D_(r)?n:r||l8(e)||n}const y8=async function(e){const t=this.getOffsetParent||pP,n=this.getDimensions,r=await n(e.floating);return{reference:_8(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function b8(e){return Or(e).direction==="rtl"}const w8={convertOffsetParentRelativeRectToViewportRelativeRect:d8,getDocumentElement:di,getClippingRect:v8,getOffsetParent:pP,getElementRects:y8,getClientRects:h8,getDimensions:x8,getScale:Sa,isElement:Dr,isRTL:b8};function mP(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function S8(e,t){let n=null,r;const i=di(e);function s(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function o(a,l){a===void 0&&(a=!1),l===void 0&&(l=1),s();const c=e.getBoundingClientRect(),{left:u,top:d,width:f,height:p}=c;if(a||t(),!f||!p)return;const m=ud(d),v=ud(i.clientWidth-(u+f)),b=ud(i.clientHeight-(d+p)),x=ud(u),y={rootMargin:-m+"px "+-v+"px "+-b+"px "+-x+"px",threshold:Zn(0,Is(1,l))||1};let w=!0;function S(C){const N=C[0].intersectionRatio;if(N!==l){if(!w)return o();N?o(!1,N):r=setTimeout(()=>{o(!1,1e-7)},1e3)}N===1&&!mP(c,e.getBoundingClientRect())&&o(),w=!1}try{n=new IntersectionObserver(S,{...y,root:i.ownerDocument})}catch{n=new IntersectionObserver(S,y)}n.observe(e)}return o(!0),s}function k8(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:i=!0,ancestorResize:s=!0,elementResize:o=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:l=!1}=r,c=B_(e),u=i||s?[...c?Vc(c):[],...t?Vc(t):[]]:[];u.forEach(x=>{i&&x.addEventListener("scroll",n,{passive:!0}),s&&x.addEventListener("resize",n)});const d=c&&a?S8(c,n):null;let f=-1,p=null;o&&(p=new ResizeObserver(x=>{let[_]=x;_&&_.target===c&&p&&t&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var y;(y=p)==null||y.observe(t)})),n()}),c&&!l&&p.observe(c),t&&p.observe(t));let m,v=l?xo(e):null;l&&b();function b(){const x=xo(e);v&&!mP(v,x)&&n(),v=x,m=requestAnimationFrame(b)}return n(),()=>{var x;u.forEach(_=>{i&&_.removeEventListener("scroll",n),s&&_.removeEventListener("resize",n)}),d==null||d(),(x=p)==null||x.disconnect(),p=null,l&&cancelAnimationFrame(m)}}const C8=t8,E8=n8,N8=QF,T8=i8,P8=JF,Uw=ZF,I8=r8,R8=(e,t,n)=>{const r=new Map,i={platform:w8,...n},s={...i.platform,_c:r};return YF(e,t,{...i,platform:s})};var M8=typeof document<"u",A8=function(){},Xd=M8?g.useLayoutEffect:A8;function Zh(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!Zh(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){const s=i[r];if(!(s==="_owner"&&e.$$typeof)&&!Zh(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function gP(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Ww(e,t){const n=gP(e);return Math.round(t*n)/n}function km(e){const t=g.useRef(e);return Xd(()=>{t.current=e}),t}function j8(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:i,elements:{reference:s,floating:o}={},transform:a=!0,whileElementsMounted:l,open:c}=e,[u,d]=g.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,p]=g.useState(r);Zh(f,r)||p(r);const[m,v]=g.useState(null),[b,x]=g.useState(null),_=g.useCallback(L=>{L!==C.current&&(C.current=L,v(L))},[]),y=g.useCallback(L=>{L!==N.current&&(N.current=L,x(L))},[]),w=s||m,S=o||b,C=g.useRef(null),N=g.useRef(null),T=g.useRef(u),M=l!=null,P=km(l),D=km(i),R=km(c),I=g.useCallback(()=>{if(!C.current||!N.current)return;const L={placement:t,strategy:n,middleware:f};D.current&&(L.platform=D.current),R8(C.current,N.current,L).then(B=>{const E={...B,isPositioned:R.current!==!1};O.current&&!Zh(T.current,E)&&(T.current=E,hu.flushSync(()=>{d(E)}))})},[f,t,n,D,R]);Xd(()=>{c===!1&&T.current.isPositioned&&(T.current.isPositioned=!1,d(L=>({...L,isPositioned:!1})))},[c]);const O=g.useRef(!1);Xd(()=>(O.current=!0,()=>{O.current=!1}),[]),Xd(()=>{if(w&&(C.current=w),S&&(N.current=S),w&&S){if(P.current)return P.current(w,S,I);I()}},[w,S,I,P,M]);const z=g.useMemo(()=>({reference:C,floating:N,setReference:_,setFloating:y}),[_,y]),$=g.useMemo(()=>({reference:w,floating:S}),[w,S]),F=g.useMemo(()=>{const L={position:n,left:0,top:0};if(!$.floating)return L;const B=Ww($.floating,u.x),E=Ww($.floating,u.y);return a?{...L,transform:"translate("+B+"px, "+E+"px)",...gP($.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:B,top:E}},[n,a,$.floating,u.x,u.y]);return g.useMemo(()=>({...u,update:I,refs:z,elements:$,floatingStyles:F}),[u,I,z,$,F])}const L8=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:i}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?Uw({element:r.current,padding:i}).fn(n):{}:r?Uw({element:r,padding:i}).fn(n):{}}}},D8=(e,t)=>{const n=C8(e);return{name:n.name,fn:n.fn,options:[e,t]}},O8=(e,t)=>{const n=E8(e);return{name:n.name,fn:n.fn,options:[e,t]}},B8=(e,t)=>({fn:I8(e).fn,options:[e,t]}),z8=(e,t)=>{const n=N8(e);return{name:n.name,fn:n.fn,options:[e,t]}},$8=(e,t)=>{const n=T8(e);return{name:n.name,fn:n.fn,options:[e,t]}},F8=(e,t)=>{const n=P8(e);return{name:n.name,fn:n.fn,options:[e,t]}},H8=(e,t)=>{const n=L8(e);return{name:n.name,fn:n.fn,options:[e,t]}};var U8="Arrow",vP=g.forwardRef((e,t)=>{const{children:n,width:r=10,height:i=5,...s}=e;return h.jsx(Et.svg,{...s,ref:t,width:r,height:i,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:h.jsx("polygon",{points:"0,0 30,0 15,10"})})});vP.displayName=U8;var W8=vP;function V8(e){const[t,n]=g.useState(void 0);return Ps(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(i=>{if(!Array.isArray(i)||!i.length)return;const s=i[0];let o,a;if("borderBoxSize"in s){const l=s.borderBoxSize,c=Array.isArray(l)?l[0]:l;o=c.inlineSize,a=c.blockSize}else o=e.offsetWidth,a=e.offsetHeight;n({width:o,height:a})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var z_="Popper",[xP,ip]=Ro(z_),[q8,_P]=xP(z_),yP=e=>{const{__scopePopper:t,children:n}=e,[r,i]=g.useState(null);return h.jsx(q8,{scope:t,anchor:r,onAnchorChange:i,children:n})};yP.displayName=z_;var bP="PopperAnchor",wP=g.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...i}=e,s=_P(bP,n),o=g.useRef(null),a=qt(t,o),l=g.useRef(null);return g.useEffect(()=>{const c=l.current;l.current=(r==null?void 0:r.current)||o.current,c!==l.current&&s.onAnchorChange(l.current)}),r?null:h.jsx(Et.div,{...i,ref:a})});wP.displayName=bP;var $_="PopperContent",[K8,G8]=xP($_),SP=g.forwardRef((e,t)=>{var pe,Oe,ie,Ae,Fe,We;const{__scopePopper:n,side:r="bottom",sideOffset:i=0,align:s="center",alignOffset:o=0,arrowPadding:a=0,avoidCollisions:l=!0,collisionBoundary:c=[],collisionPadding:u=0,sticky:d="partial",hideWhenDetached:f=!1,updatePositionStrategy:p="optimized",onPlaced:m,...v}=e,b=_P($_,n),[x,_]=g.useState(null),y=qt(t,ge=>_(ge)),[w,S]=g.useState(null),C=V8(w),N=(C==null?void 0:C.width)??0,T=(C==null?void 0:C.height)??0,M=r+(s!=="center"?"-"+s:""),P=typeof u=="number"?u:{top:0,right:0,bottom:0,left:0,...u},D=Array.isArray(c)?c:[c],R=D.length>0,I={padding:P,boundary:D.filter(Y8),altBoundary:R},{refs:O,floatingStyles:z,placement:$,isPositioned:F,middlewareData:L}=j8({strategy:"fixed",placement:M,whileElementsMounted:(...ge)=>k8(...ge,{animationFrame:p==="always"}),elements:{reference:b.anchor},middleware:[D8({mainAxis:i+T,alignmentAxis:o}),l&&O8({mainAxis:!0,crossAxis:!1,limiter:d==="partial"?B8():void 0,...I}),l&&z8({...I}),$8({...I,apply:({elements:ge,rects:qe,availableWidth:Gt,availableHeight:wt})=>{const{width:Rt,height:ln}=qe.reference,Bt=ge.floating.style;Bt.setProperty("--radix-popper-available-width",`${Gt}px`),Bt.setProperty("--radix-popper-available-height",`${wt}px`),Bt.setProperty("--radix-popper-anchor-width",`${Rt}px`),Bt.setProperty("--radix-popper-anchor-height",`${ln}px`)}}),w&&H8({element:w,padding:a}),Z8({arrowWidth:N,arrowHeight:T}),f&&F8({strategy:"referenceHidden",...I})]}),[B,E]=EP($),H=ji(m);Ps(()=>{F&&(H==null||H())},[F,H]);const q=(pe=L.arrow)==null?void 0:pe.x,A=(Oe=L.arrow)==null?void 0:Oe.y,re=((ie=L.arrow)==null?void 0:ie.centerOffset)!==0,[oe,V]=g.useState();return Ps(()=>{x&&V(window.getComputedStyle(x).zIndex)},[x]),h.jsx("div",{ref:O.setFloating,"data-radix-popper-content-wrapper":"",style:{...z,transform:F?z.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:oe,"--radix-popper-transform-origin":[(Ae=L.transformOrigin)==null?void 0:Ae.x,(Fe=L.transformOrigin)==null?void 0:Fe.y].join(" "),...((We=L.hide)==null?void 0:We.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:h.jsx(K8,{scope:n,placedSide:B,onArrowChange:S,arrowX:q,arrowY:A,shouldHideArrow:re,children:h.jsx(Et.div,{"data-side":B,"data-align":E,...v,ref:y,style:{...v.style,animation:F?void 0:"none"}})})})});SP.displayName=$_;var kP="PopperArrow",X8={top:"bottom",right:"left",bottom:"top",left:"right"},CP=g.forwardRef(function(t,n){const{__scopePopper:r,...i}=t,s=G8(kP,r),o=X8[s.placedSide];return h.jsx("span",{ref:s.onArrowChange,style:{position:"absolute",left:s.arrowX,top:s.arrowY,[o]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[s.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[s.placedSide],visibility:s.shouldHideArrow?"hidden":void 0},children:h.jsx(W8,{...i,ref:n,style:{...i.style,display:"block"}})})});CP.displayName=kP;function Y8(e){return e!==null}var Z8=e=>({name:"transformOrigin",options:e,fn(t){var b,x,_;const{placement:n,rects:r,middlewareData:i}=t,o=((b=i.arrow)==null?void 0:b.centerOffset)!==0,a=o?0:e.arrowWidth,l=o?0:e.arrowHeight,[c,u]=EP(n),d={start:"0%",center:"50%",end:"100%"}[u],f=(((x=i.arrow)==null?void 0:x.x)??0)+a/2,p=(((_=i.arrow)==null?void 0:_.y)??0)+l/2;let m="",v="";return c==="bottom"?(m=o?d:`${f}px`,v=`${-l}px`):c==="top"?(m=o?d:`${f}px`,v=`${r.floating.height+l}px`):c==="right"?(m=`${-l}px`,v=o?d:`${p}px`):c==="left"&&(m=`${r.floating.width+l}px`,v=o?d:`${p}px`),{data:{x:m,y:v}}}});function EP(e){const[t,n="center"]=e.split("-");return[t,n]}var NP=yP,TP=wP,PP=SP,IP=CP,Q8="Portal",F_=g.forwardRef((e,t)=>{var a;const{container:n,...r}=e,[i,s]=g.useState(!1);Ps(()=>s(!0),[]);const o=n||i&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return o?cv.createPortal(h.jsx(Et.div,{...r,ref:t}),o):null});F_.displayName=Q8;function J8(e,t){return g.useReducer((n,r)=>t[n][r]??n,e)}var Hi=e=>{const{present:t,children:n}=e,r=e9(t),i=typeof n=="function"?n({present:r.isPresent}):g.Children.only(n),s=qt(r.ref,t9(i));return typeof n=="function"||r.isPresent?g.cloneElement(i,{ref:s}):null};Hi.displayName="Presence";function e9(e){const[t,n]=g.useState(),r=g.useRef(null),i=g.useRef(e),s=g.useRef("none"),o=e?"mounted":"unmounted",[a,l]=J8(o,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return g.useEffect(()=>{const c=dd(r.current);s.current=a==="mounted"?c:"none"},[a]),Ps(()=>{const c=r.current,u=i.current;if(u!==e){const f=s.current,p=dd(c);e?l("MOUNT"):p==="none"||(c==null?void 0:c.display)==="none"?l("UNMOUNT"):l(u&&f!==p?"ANIMATION_OUT":"UNMOUNT"),i.current=e}},[e,l]),Ps(()=>{if(t){let c;const u=t.ownerDocument.defaultView??window,d=p=>{const v=dd(r.current).includes(CSS.escape(p.animationName));if(p.target===t&&v&&(l("ANIMATION_END"),!i.current)){const b=t.style.animationFillMode;t.style.animationFillMode="forwards",c=u.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=b)})}},f=p=>{p.target===t&&(s.current=dd(r.current))};return t.addEventListener("animationstart",f),t.addEventListener("animationcancel",d),t.addEventListener("animationend",d),()=>{u.clearTimeout(c),t.removeEventListener("animationstart",f),t.removeEventListener("animationcancel",d),t.removeEventListener("animationend",d)}}else l("ANIMATION_END")},[t,l]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:g.useCallback(c=>{r.current=c?getComputedStyle(c):null,n(c)},[])}}function dd(e){return(e==null?void 0:e.animationName)||"none"}function t9(e){var r,i;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(i=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:i.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var Cm="rovingFocusGroup.onEntryFocus",n9={bubbles:!1,cancelable:!0},xu="RovingFocusGroup",[s0,RP,r9]=eP(xu),[i9,MP]=Ro(xu,[r9]),[s9,o9]=i9(xu),AP=g.forwardRef((e,t)=>h.jsx(s0.Provider,{scope:e.__scopeRovingFocusGroup,children:h.jsx(s0.Slot,{scope:e.__scopeRovingFocusGroup,children:h.jsx(a9,{...e,ref:t})})}));AP.displayName=xu;var a9=g.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:i=!1,dir:s,currentTabStopId:o,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:l,onEntryFocus:c,preventScrollOnEntryFocus:u=!1,...d}=e,f=g.useRef(null),p=qt(t,f),m=tP(s),[v,b]=Qf({prop:o,defaultProp:a??null,onChange:l,caller:xu}),[x,_]=g.useState(!1),y=ji(c),w=RP(n),S=g.useRef(!1),[C,N]=g.useState(0);return g.useEffect(()=>{const T=f.current;if(T)return T.addEventListener(Cm,y),()=>T.removeEventListener(Cm,y)},[y]),h.jsx(s9,{scope:n,orientation:r,dir:m,loop:i,currentTabStopId:v,onItemFocus:g.useCallback(T=>b(T),[b]),onItemShiftTab:g.useCallback(()=>_(!0),[]),onFocusableItemAdd:g.useCallback(()=>N(T=>T+1),[]),onFocusableItemRemove:g.useCallback(()=>N(T=>T-1),[]),children:h.jsx(Et.div,{tabIndex:x||C===0?-1:0,"data-orientation":r,...d,ref:p,style:{outline:"none",...e.style},onMouseDown:Pe(e.onMouseDown,()=>{S.current=!0}),onFocus:Pe(e.onFocus,T=>{const M=!S.current;if(T.target===T.currentTarget&&M&&!x){const P=new CustomEvent(Cm,n9);if(T.currentTarget.dispatchEvent(P),!P.defaultPrevented){const D=w().filter($=>$.focusable),R=D.find($=>$.active),I=D.find($=>$.id===v),z=[R,I,...D].filter(Boolean).map($=>$.ref.current);DP(z,u)}}S.current=!1}),onBlur:Pe(e.onBlur,()=>_(!1))})})}),jP="RovingFocusGroupItem",LP=g.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:s,children:o,...a}=e,l=oo(),c=s||l,u=o9(jP,n),d=u.currentTabStopId===c,f=RP(n),{onFocusableItemAdd:p,onFocusableItemRemove:m,currentTabStopId:v}=u;return g.useEffect(()=>{if(r)return p(),()=>m()},[r,p,m]),h.jsx(s0.ItemSlot,{scope:n,id:c,focusable:r,active:i,children:h.jsx(Et.span,{tabIndex:d?0:-1,"data-orientation":u.orientation,...a,ref:t,onMouseDown:Pe(e.onMouseDown,b=>{r?u.onItemFocus(c):b.preventDefault()}),onFocus:Pe(e.onFocus,()=>u.onItemFocus(c)),onKeyDown:Pe(e.onKeyDown,b=>{if(b.key==="Tab"&&b.shiftKey){u.onItemShiftTab();return}if(b.target!==b.currentTarget)return;const x=u9(b,u.orientation,u.dir);if(x!==void 0){if(b.metaKey||b.ctrlKey||b.altKey||b.shiftKey)return;b.preventDefault();let y=f().filter(w=>w.focusable).map(w=>w.ref.current);if(x==="last")y.reverse();else if(x==="prev"||x==="next"){x==="prev"&&y.reverse();const w=y.indexOf(b.currentTarget);y=u.loop?d9(y,w+1):y.slice(w+1)}setTimeout(()=>DP(y))}}),children:typeof o=="function"?o({isCurrentTabStop:d,hasTabStop:v!=null}):o})})});LP.displayName=jP;var l9={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function c9(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function u9(e,t,n){const r=c9(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return l9[r]}function DP(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function d9(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var h9=AP,f9=LP,p9=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},Wo=new WeakMap,hd=new WeakMap,fd={},Em=0,OP=function(e){return e&&(e.host||OP(e.parentNode))},m9=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=OP(n);return r&&e.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},g9=function(e,t,n,r){var i=m9(t,Array.isArray(e)?e:[e]);fd[n]||(fd[n]=new WeakMap);var s=fd[n],o=[],a=new Set,l=new Set(i),c=function(d){!d||a.has(d)||(a.add(d),c(d.parentNode))};i.forEach(c);var u=function(d){!d||l.has(d)||Array.prototype.forEach.call(d.children,function(f){if(a.has(f))u(f);else try{var p=f.getAttribute(r),m=p!==null&&p!=="false",v=(Wo.get(f)||0)+1,b=(s.get(f)||0)+1;Wo.set(f,v),s.set(f,b),o.push(f),v===1&&m&&hd.set(f,!0),b===1&&f.setAttribute(n,"true"),m||f.setAttribute(r,"true")}catch(x){console.error("aria-hidden: cannot operate on ",f,x)}})};return u(t),a.clear(),Em++,function(){o.forEach(function(d){var f=Wo.get(d)-1,p=s.get(d)-1;Wo.set(d,f),s.set(d,p),f||(hd.has(d)||d.removeAttribute(r),hd.delete(d)),p||d.removeAttribute(n)}),Em--,Em||(Wo=new WeakMap,Wo=new WeakMap,hd=new WeakMap,fd={})}},BP=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),i=p9(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll("[aria-live], script"))),g9(r,i,n,"aria-hidden")):function(){return null}},Xr=function(){return Xr=Object.assign||function(t){for(var n,r=1,i=arguments.length;r<i;r++){n=arguments[r];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(t[s]=n[s])}return t},Xr.apply(this,arguments)};function zP(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}function v9(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,s;r<i;r++)(s||!(r in t))&&(s||(s=Array.prototype.slice.call(t,0,r)),s[r]=t[r]);return e.concat(s||Array.prototype.slice.call(t))}var Yd="right-scroll-bar-position",Zd="width-before-scroll-bar",x9="with-scroll-bars-hidden",_9="--removed-body-scroll-bar-size";function Nm(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function y9(e,t){var n=g.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(r){var i=n.value;i!==r&&(n.value=r,n.callback(r,i))}}}})[0];return n.callback=t,n.facade}var b9=typeof window<"u"?g.useLayoutEffect:g.useEffect,Vw=new WeakMap;function w9(e,t){var n=y9(null,function(r){return e.forEach(function(i){return Nm(i,r)})});return b9(function(){var r=Vw.get(n);if(r){var i=new Set(r),s=new Set(e),o=n.current;i.forEach(function(a){s.has(a)||Nm(a,null)}),s.forEach(function(a){i.has(a)||Nm(a,o)})}Vw.set(n,e)},[e]),n}function S9(e){return e}function k9(e,t){t===void 0&&(t=S9);var n=[],r=!1,i={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(s){var o=t(s,r);return n.push(o),function(){n=n.filter(function(a){return a!==o})}},assignSyncMedium:function(s){for(r=!0;n.length;){var o=n;n=[],o.forEach(s)}n={push:function(a){return s(a)},filter:function(){return n}}},assignMedium:function(s){r=!0;var o=[];if(n.length){var a=n;n=[],a.forEach(s),o=n}var l=function(){var u=o;o=[],u.forEach(s)},c=function(){return Promise.resolve().then(l)};c(),n={push:function(u){o.push(u),c()},filter:function(u){return o=o.filter(u),n}}}};return i}function C9(e){e===void 0&&(e={});var t=k9(null);return t.options=Xr({async:!0,ssr:!1},e),t}var $P=function(e){var t=e.sideCar,n=zP(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return g.createElement(r,Xr({},n))};$P.isSideCarExport=!0;function E9(e,t){return e.useMedium(t),$P}var FP=C9(),Tm=function(){},sp=g.forwardRef(function(e,t){var n=g.useRef(null),r=g.useState({onScrollCapture:Tm,onWheelCapture:Tm,onTouchMoveCapture:Tm}),i=r[0],s=r[1],o=e.forwardProps,a=e.children,l=e.className,c=e.removeScrollBar,u=e.enabled,d=e.shards,f=e.sideCar,p=e.noRelative,m=e.noIsolation,v=e.inert,b=e.allowPinchZoom,x=e.as,_=x===void 0?"div":x,y=e.gapMode,w=zP(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),S=f,C=w9([n,t]),N=Xr(Xr({},w),i);return g.createElement(g.Fragment,null,u&&g.createElement(S,{sideCar:FP,removeScrollBar:c,shards:d,noRelative:p,noIsolation:m,inert:v,setCallbacks:s,allowPinchZoom:!!b,lockRef:n,gapMode:y}),o?g.cloneElement(g.Children.only(a),Xr(Xr({},N),{ref:C})):g.createElement(_,Xr({},N,{className:l,ref:C}),a))});sp.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};sp.classNames={fullWidth:Zd,zeroRight:Yd};var N9=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function T9(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=N9();return t&&e.setAttribute("nonce",t),e}function P9(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function I9(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var R9=function(){var e=0,t=null;return{add:function(n){e==0&&(t=T9())&&(P9(t,n),I9(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},M9=function(){var e=R9();return function(t,n){g.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},HP=function(){var e=M9(),t=function(n){var r=n.styles,i=n.dynamic;return e(r,i),null};return t},A9={left:0,top:0,right:0,gap:0},Pm=function(e){return parseInt(e||"",10)||0},j9=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],r=t[e==="padding"?"paddingTop":"marginTop"],i=t[e==="padding"?"paddingRight":"marginRight"];return[Pm(n),Pm(r),Pm(i)]},L9=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return A9;var t=j9(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},D9=HP(),ka="data-scroll-locked",O9=function(e,t,n,r){var i=e.left,s=e.top,o=e.right,a=e.gap;return n===void 0&&(n="margin"),`
|
|
456
456
|
.`.concat(x9,` {
|
|
457
457
|
overflow: hidden `).concat(r,`;
|
|
458
458
|
padding-right: `).concat(a,"px ").concat(r,`;
|
|
@@ -489,10 +489,10 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
489
489
|
body[`).concat(ka,`] {
|
|
490
490
|
`).concat(_9,": ").concat(a,`px;
|
|
491
491
|
}
|
|
492
|
-
`)},qw=function(){var e=parseInt(document.body.getAttribute(ka)||"0",10);return isFinite(e)?e:0},B9=function(){g.useEffect(function(){return document.body.setAttribute(ka,(qw()+1).toString()),function(){var e=qw()-1;e<=0?document.body.removeAttribute(ka):document.body.setAttribute(ka,e.toString())}},[])},z9=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,i=r===void 0?"margin":r;B9();var s=g.useMemo(function(){return L9(i)},[i]);return g.createElement(D9,{styles:O9(s,!t,i,n?"":"!important")})},o0=!1;if(typeof window<"u")try{var pd=Object.defineProperty({},"passive",{get:function(){return o0=!0,!0}});window.addEventListener("test",pd,pd),window.removeEventListener("test",pd,pd)}catch{o0=!1}var Vo=o0?{passive:!1}:!1,$9=function(e){return e.tagName==="TEXTAREA"},
|
|
492
|
+
`)},qw=function(){var e=parseInt(document.body.getAttribute(ka)||"0",10);return isFinite(e)?e:0},B9=function(){g.useEffect(function(){return document.body.setAttribute(ka,(qw()+1).toString()),function(){var e=qw()-1;e<=0?document.body.removeAttribute(ka):document.body.setAttribute(ka,e.toString())}},[])},z9=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,i=r===void 0?"margin":r;B9();var s=g.useMemo(function(){return L9(i)},[i]);return g.createElement(D9,{styles:O9(s,!t,i,n?"":"!important")})},o0=!1;if(typeof window<"u")try{var pd=Object.defineProperty({},"passive",{get:function(){return o0=!0,!0}});window.addEventListener("test",pd,pd),window.removeEventListener("test",pd,pd)}catch{o0=!1}var Vo=o0?{passive:!1}:!1,$9=function(e){return e.tagName==="TEXTAREA"},UP=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!$9(e)&&n[t]==="visible")},F9=function(e){return UP(e,"overflowY")},H9=function(e){return UP(e,"overflowX")},Kw=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var i=WP(e,r);if(i){var s=VP(e,r),o=s[1],a=s[2];if(o>a)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},U9=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},W9=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},WP=function(e,t){return e==="v"?F9(t):H9(t)},VP=function(e,t){return e==="v"?U9(t):W9(t)},V9=function(e,t){return e==="h"&&t==="rtl"?-1:1},q9=function(e,t,n,r,i){var s=V9(e,window.getComputedStyle(t).direction),o=s*r,a=n.target,l=t.contains(a),c=!1,u=o>0,d=0,f=0;do{if(!a)break;var p=VP(e,a),m=p[0],v=p[1],b=p[2],x=v-b-s*m;(m||x)&&WP(e,a)&&(d+=x,f+=m);var _=a.parentNode;a=_&&_.nodeType===Node.DOCUMENT_FRAGMENT_NODE?_.host:_}while(!l&&a!==document.body||l&&(t.contains(a)||t===a));return(u&&Math.abs(d)<1||!u&&Math.abs(f)<1)&&(c=!0),c},md=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Gw=function(e){return[e.deltaX,e.deltaY]},Xw=function(e){return e&&"current"in e?e.current:e},K9=function(e,t){return e[0]===t[0]&&e[1]===t[1]},G9=function(e){return`
|
|
493
493
|
.block-interactivity-`.concat(e,` {pointer-events: none;}
|
|
494
494
|
.allow-interactivity-`).concat(e,` {pointer-events: all;}
|
|
495
|
-
`)},X9=0,qo=[];function Y9(e){var t=g.useRef([]),n=g.useRef([0,0]),r=g.useRef(),i=g.useState(X9++)[0],s=g.useState(FP)[0],o=g.useRef(e);g.useEffect(function(){o.current=e},[e]),g.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(i));var v=v9([e.lockRef.current],(e.shards||[]).map(Xw),!0).filter(Boolean);return v.forEach(function(b){return b.classList.add("allow-interactivity-".concat(i))}),function(){document.body.classList.remove("block-interactivity-".concat(i)),v.forEach(function(b){return b.classList.remove("allow-interactivity-".concat(i))})}}},[e.inert,e.lockRef.current,e.shards]);var a=g.useCallback(function(v,b){if("touches"in v&&v.touches.length===2||v.type==="wheel"&&v.ctrlKey)return!o.current.allowPinchZoom;var x=md(v),_=n.current,y="deltaX"in v?v.deltaX:_[0]-x[0],w="deltaY"in v?v.deltaY:_[1]-x[1],S,C=v.target,N=Math.abs(y)>Math.abs(w)?"h":"v";if("touches"in v&&N==="h"&&C.type==="range")return!1;var T=window.getSelection(),M=T&&T.anchorNode,P=M?M===C||M.contains(C):!1;if(P)return!1;var D=Kw(N,C);if(!D)return!0;if(D?S=N:(S=N==="v"?"h":"v",D=Kw(N,C)),!D)return!1;if(!r.current&&"changedTouches"in v&&(y||w)&&(r.current=S),!S)return!0;var R=r.current||S;return q9(R,b,v,R==="h"?y:w)},[]),l=g.useCallback(function(v){var b=v;if(!(!qo.length||qo[qo.length-1]!==s)){var x="deltaY"in b?Gw(b):md(b),_=t.current.filter(function(S){return S.name===b.type&&(S.target===b.target||b.target===S.shadowParent)&&K9(S.delta,x)})[0];if(_&&_.should){b.cancelable&&b.preventDefault();return}if(!_){var y=(o.current.shards||[]).map(Xw).filter(Boolean).filter(function(S){return S.contains(b.target)}),w=y.length>0?a(b,y[0]):!o.current.noIsolation;w&&b.cancelable&&b.preventDefault()}}},[]),c=g.useCallback(function(v,b,x,_){var y={name:v,delta:b,target:x,should:_,shadowParent:Z9(x)};t.current.push(y),setTimeout(function(){t.current=t.current.filter(function(w){return w!==y})},1)},[]),u=g.useCallback(function(v){n.current=md(v),r.current=void 0},[]),d=g.useCallback(function(v){c(v.type,Gw(v),v.target,a(v,e.lockRef.current))},[]),f=g.useCallback(function(v){c(v.type,md(v),v.target,a(v,e.lockRef.current))},[]);g.useEffect(function(){return qo.push(s),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener("wheel",l,Vo),document.addEventListener("touchmove",l,Vo),document.addEventListener("touchstart",u,Vo),function(){qo=qo.filter(function(v){return v!==s}),document.removeEventListener("wheel",l,Vo),document.removeEventListener("touchmove",l,Vo),document.removeEventListener("touchstart",u,Vo)}},[]);var p=e.removeScrollBar,m=e.inert;return g.createElement(g.Fragment,null,m?g.createElement(s,{styles:G9(i)}):null,p?g.createElement(z9,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function Z9(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const Q9=E9($P,Y9);var H_=g.forwardRef(function(e,t){return g.createElement(sp,Xr({},e,{ref:t,sideCar:Q9}))});H_.classNames=sp.classNames;var a0=["Enter"," "],J9=["ArrowDown","PageUp","Home"],VP=["ArrowUp","PageDown","End"],e7=[...J9,...VP],t7={ltr:[...a0,"ArrowRight"],rtl:[...a0,"ArrowLeft"]},n7={ltr:["ArrowLeft"],rtl:["ArrowRight"]},_u="Menu",[qc,r7,i7]=JT(_u),[Mo,qP]=Ro(_u,[i7,ip,RP]),op=ip(),KP=RP(),[s7,Ao]=Mo(_u),[o7,yu]=Mo(_u),GP=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:s,modal:o=!0}=e,a=op(t),[l,c]=g.useState(null),u=g.useRef(!1),d=ji(s),f=eP(i);return g.useEffect(()=>{const p=()=>{u.current=!0,document.addEventListener("pointerdown",m,{capture:!0,once:!0}),document.addEventListener("pointermove",m,{capture:!0,once:!0})},m=()=>u.current=!1;return document.addEventListener("keydown",p,{capture:!0}),()=>{document.removeEventListener("keydown",p,{capture:!0}),document.removeEventListener("pointerdown",m,{capture:!0}),document.removeEventListener("pointermove",m,{capture:!0})}},[]),h.jsx(EP,{...a,children:h.jsx(s7,{scope:t,open:n,onOpenChange:d,content:l,onContentChange:c,children:h.jsx(o7,{scope:t,onClose:g.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:f,modal:o,children:r})})})};GP.displayName=_u;var a7="MenuAnchor",U_=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,i=op(n);return h.jsx(NP,{...i,...r,ref:t})});U_.displayName=a7;var W_="MenuPortal",[l7,XP]=Mo(W_,{forceMount:void 0}),YP=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:i}=e,s=Ao(W_,t);return h.jsx(l7,{scope:t,forceMount:n,children:h.jsx(Hi,{present:n||s.open,children:h.jsx(F_,{asChild:!0,container:i,children:r})})})};YP.displayName=W_;var xr="MenuContent",[c7,V_]=Mo(xr),ZP=g.forwardRef((e,t)=>{const n=XP(xr,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,s=Ao(xr,e.__scopeMenu),o=yu(xr,e.__scopeMenu);return h.jsx(qc.Provider,{scope:e.__scopeMenu,children:h.jsx(Hi,{present:r||s.open,children:h.jsx(qc.Slot,{scope:e.__scopeMenu,children:o.modal?h.jsx(u7,{...i,ref:t}):h.jsx(d7,{...i,ref:t})})})})}),u7=g.forwardRef((e,t)=>{const n=Ao(xr,e.__scopeMenu),r=g.useRef(null),i=qt(t,r);return g.useEffect(()=>{const s=r.current;if(s)return OP(s)},[]),h.jsx(q_,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:Pe(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),d7=g.forwardRef((e,t)=>{const n=Ao(xr,e.__scopeMenu);return h.jsx(q_,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),h7=Wc("MenuContent.ScrollLock"),q_=g.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:i,onOpenAutoFocus:s,onCloseAutoFocus:o,disableOutsidePointerEvents:a,onEntryFocus:l,onEscapeKeyDown:c,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,disableOutsideScroll:m,...v}=e,b=Ao(xr,n),x=yu(xr,n),_=op(n),y=KP(n),w=r7(n),[S,C]=g.useState(null),N=g.useRef(null),T=qt(t,N,b.onContentChange),M=g.useRef(0),P=g.useRef(""),D=g.useRef(0),R=g.useRef(null),I=g.useRef("right"),O=g.useRef(0),z=m?H_:g.Fragment,$=m?{as:h7,allowPinchZoom:!0}:void 0,F=B=>{var pe,Oe;const E=P.current+B,H=w().filter(ie=>!ie.disabled),q=document.activeElement,A=(pe=H.find(ie=>ie.ref.current===q))==null?void 0:pe.textValue,re=H.map(ie=>ie.textValue),oe=k7(re,E,A),V=(Oe=H.find(ie=>ie.textValue===oe))==null?void 0:Oe.ref.current;(function ie(Ae){P.current=Ae,window.clearTimeout(M.current),Ae!==""&&(M.current=window.setTimeout(()=>ie(""),1e3))})(E),V&&setTimeout(()=>V.focus())};g.useEffect(()=>()=>window.clearTimeout(M.current),[]),rP();const L=g.useCallback(B=>{var H,q;return I.current===((H=R.current)==null?void 0:H.side)&&E7(B,(q=R.current)==null?void 0:q.area)},[]);return h.jsx(c7,{scope:n,searchRef:P,onItemEnter:g.useCallback(B=>{L(B)&&B.preventDefault()},[L]),onItemLeave:g.useCallback(B=>{var E;L(B)||((E=N.current)==null||E.focus(),C(null))},[L]),onTriggerLeave:g.useCallback(B=>{L(B)&&B.preventDefault()},[L]),pointerGraceTimerRef:D,onPointerGraceIntentChange:g.useCallback(B=>{R.current=B},[]),children:h.jsx(z,{...$,children:h.jsx(M_,{asChild:!0,trapped:i,onMountAutoFocus:Pe(s,B=>{var E;B.preventDefault(),(E=N.current)==null||E.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:h.jsx(Jf,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:c,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,children:h.jsx(h9,{asChild:!0,...y,dir:x.dir,orientation:"vertical",loop:r,currentTabStopId:S,onCurrentTabStopIdChange:C,onEntryFocus:Pe(l,B=>{x.isUsingKeyboardRef.current||B.preventDefault()}),preventScrollOnEntryFocus:!0,children:h.jsx(TP,{role:"menu","aria-orientation":"vertical","data-state":fI(b.open),"data-radix-menu-content":"",dir:x.dir,..._,...v,ref:T,style:{outline:"none",...v.style},onKeyDown:Pe(v.onKeyDown,B=>{const H=B.target.closest("[data-radix-menu-content]")===B.currentTarget,q=B.ctrlKey||B.altKey||B.metaKey,A=B.key.length===1;H&&(B.key==="Tab"&&B.preventDefault(),!q&&A&&F(B.key));const re=N.current;if(B.target!==re||!e7.includes(B.key))return;B.preventDefault();const V=w().filter(pe=>!pe.disabled).map(pe=>pe.ref.current);VP.includes(B.key)&&V.reverse(),w7(V)}),onBlur:Pe(e.onBlur,B=>{B.currentTarget.contains(B.target)||(window.clearTimeout(M.current),P.current="")}),onPointerMove:Pe(e.onPointerMove,Kc(B=>{const E=B.target,H=O.current!==B.clientX;if(B.currentTarget.contains(E)&&H){const q=B.clientX>O.current?"right":"left";I.current=q,O.current=B.clientX}}))})})})})})})});ZP.displayName=xr;var f7="MenuGroup",K_=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return h.jsx(Et.div,{role:"group",...r,ref:t})});K_.displayName=f7;var p7="MenuLabel",QP=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return h.jsx(Et.div,{...r,ref:t})});QP.displayName=p7;var Qh="MenuItem",Yw="menu.itemSelect",ap=g.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...i}=e,s=g.useRef(null),o=yu(Qh,e.__scopeMenu),a=V_(Qh,e.__scopeMenu),l=qt(t,s),c=g.useRef(!1),u=()=>{const d=s.current;if(!n&&d){const f=new CustomEvent(Yw,{bubbles:!0,cancelable:!0});d.addEventListener(Yw,p=>r==null?void 0:r(p),{once:!0}),QT(d,f),f.defaultPrevented?c.current=!1:o.onClose()}};return h.jsx(JP,{...i,ref:l,disabled:n,onClick:Pe(e.onClick,u),onPointerDown:d=>{var f;(f=e.onPointerDown)==null||f.call(e,d),c.current=!0},onPointerUp:Pe(e.onPointerUp,d=>{var f;c.current||(f=d.currentTarget)==null||f.click()}),onKeyDown:Pe(e.onKeyDown,d=>{const f=a.searchRef.current!=="";n||f&&d.key===" "||a0.includes(d.key)&&(d.currentTarget.click(),d.preventDefault())})})});ap.displayName=Qh;var JP=g.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:i,...s}=e,o=V_(Qh,n),a=KP(n),l=g.useRef(null),c=qt(t,l),[u,d]=g.useState(!1),[f,p]=g.useState("");return g.useEffect(()=>{const m=l.current;m&&p((m.textContent??"").trim())},[s.children]),h.jsx(qc.ItemSlot,{scope:n,disabled:r,textValue:i??f,children:h.jsx(f9,{asChild:!0,...a,focusable:!r,children:h.jsx(Et.div,{role:"menuitem","data-highlighted":u?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:c,onPointerMove:Pe(e.onPointerMove,Kc(m=>{r?o.onItemLeave(m):(o.onItemEnter(m),m.defaultPrevented||m.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Pe(e.onPointerLeave,Kc(m=>o.onItemLeave(m))),onFocus:Pe(e.onFocus,()=>d(!0)),onBlur:Pe(e.onBlur,()=>d(!1))})})})}),m7="MenuCheckboxItem",eI=g.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...i}=e;return h.jsx(sI,{scope:e.__scopeMenu,checked:n,children:h.jsx(ap,{role:"menuitemcheckbox","aria-checked":Jh(n)?"mixed":n,...i,ref:t,"data-state":X_(n),onSelect:Pe(i.onSelect,()=>r==null?void 0:r(Jh(n)?!0:!n),{checkForDefaultPrevented:!1})})})});eI.displayName=m7;var tI="MenuRadioGroup",[g7,v7]=Mo(tI,{value:void 0,onValueChange:()=>{}}),nI=g.forwardRef((e,t)=>{const{value:n,onValueChange:r,...i}=e,s=ji(r);return h.jsx(g7,{scope:e.__scopeMenu,value:n,onValueChange:s,children:h.jsx(K_,{...i,ref:t})})});nI.displayName=tI;var rI="MenuRadioItem",iI=g.forwardRef((e,t)=>{const{value:n,...r}=e,i=v7(rI,e.__scopeMenu),s=n===i.value;return h.jsx(sI,{scope:e.__scopeMenu,checked:s,children:h.jsx(ap,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":X_(s),onSelect:Pe(r.onSelect,()=>{var o;return(o=i.onValueChange)==null?void 0:o.call(i,n)},{checkForDefaultPrevented:!1})})})});iI.displayName=rI;var G_="MenuItemIndicator",[sI,x7]=Mo(G_,{checked:!1}),oI=g.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...i}=e,s=x7(G_,n);return h.jsx(Hi,{present:r||Jh(s.checked)||s.checked===!0,children:h.jsx(Et.span,{...i,ref:t,"data-state":X_(s.checked)})})});oI.displayName=G_;var _7="MenuSeparator",aI=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return h.jsx(Et.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});aI.displayName=_7;var y7="MenuArrow",lI=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,i=op(n);return h.jsx(PP,{...i,...r,ref:t})});lI.displayName=y7;var b7="MenuSub",[Fie,cI]=Mo(b7),Vl="MenuSubTrigger",uI=g.forwardRef((e,t)=>{const n=Ao(Vl,e.__scopeMenu),r=yu(Vl,e.__scopeMenu),i=cI(Vl,e.__scopeMenu),s=V_(Vl,e.__scopeMenu),o=g.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:l}=s,c={__scopeMenu:e.__scopeMenu},u=g.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=null},[]);return g.useEffect(()=>u,[u]),g.useEffect(()=>{const d=a.current;return()=>{window.clearTimeout(d),l(null)}},[a,l]),h.jsx(U_,{asChild:!0,...c,children:h.jsx(JP,{id:i.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":i.contentId,"data-state":fI(n.open),...e,ref:gu(t,i.onTriggerChange),onClick:d=>{var f;(f=e.onClick)==null||f.call(e,d),!(e.disabled||d.defaultPrevented)&&(d.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:Pe(e.onPointerMove,Kc(d=>{s.onItemEnter(d),!d.defaultPrevented&&!e.disabled&&!n.open&&!o.current&&(s.onPointerGraceIntentChange(null),o.current=window.setTimeout(()=>{n.onOpenChange(!0),u()},100))})),onPointerLeave:Pe(e.onPointerLeave,Kc(d=>{var p,m;u();const f=(p=n.content)==null?void 0:p.getBoundingClientRect();if(f){const v=(m=n.content)==null?void 0:m.dataset.side,b=v==="right",x=b?-5:5,_=f[b?"left":"right"],y=f[b?"right":"left"];s.onPointerGraceIntentChange({area:[{x:d.clientX+x,y:d.clientY},{x:_,y:f.top},{x:y,y:f.top},{x:y,y:f.bottom},{x:_,y:f.bottom}],side:v}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(d),d.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:Pe(e.onKeyDown,d=>{var p;const f=s.searchRef.current!=="";e.disabled||f&&d.key===" "||t7[r.dir].includes(d.key)&&(n.onOpenChange(!0),(p=n.content)==null||p.focus(),d.preventDefault())})})})});uI.displayName=Vl;var dI="MenuSubContent",hI=g.forwardRef((e,t)=>{const n=XP(xr,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,s=Ao(xr,e.__scopeMenu),o=yu(xr,e.__scopeMenu),a=cI(dI,e.__scopeMenu),l=g.useRef(null),c=qt(t,l);return h.jsx(qc.Provider,{scope:e.__scopeMenu,children:h.jsx(Hi,{present:r||s.open,children:h.jsx(qc.Slot,{scope:e.__scopeMenu,children:h.jsx(q_,{id:a.contentId,"aria-labelledby":a.triggerId,...i,ref:c,align:"start",side:o.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:u=>{var d;o.isUsingKeyboardRef.current&&((d=l.current)==null||d.focus()),u.preventDefault()},onCloseAutoFocus:u=>u.preventDefault(),onFocusOutside:Pe(e.onFocusOutside,u=>{u.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:Pe(e.onEscapeKeyDown,u=>{o.onClose(),u.preventDefault()}),onKeyDown:Pe(e.onKeyDown,u=>{var p;const d=u.currentTarget.contains(u.target),f=n7[o.dir].includes(u.key);d&&f&&(s.onOpenChange(!1),(p=a.trigger)==null||p.focus(),u.preventDefault())})})})})})});hI.displayName=dI;function fI(e){return e?"open":"closed"}function Jh(e){return e==="indeterminate"}function X_(e){return Jh(e)?"indeterminate":e?"checked":"unchecked"}function w7(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function S7(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function k7(e,t,n){const i=t.length>1&&Array.from(t).every(c=>c===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let o=S7(e,Math.max(s,0));i.length===1&&(o=o.filter(c=>c!==n));const l=o.find(c=>c.toLowerCase().startsWith(i.toLowerCase()));return l!==n?l:void 0}function C7(e,t){const{x:n,y:r}=e;let i=!1;for(let s=0,o=t.length-1;s<t.length;o=s++){const a=t[s],l=t[o],c=a.x,u=a.y,d=l.x,f=l.y;u>r!=f>r&&n<(d-c)*(r-u)/(f-u)+c&&(i=!i)}return i}function E7(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return C7(n,t)}function Kc(e){return t=>t.pointerType==="mouse"?e(t):void 0}var N7=GP,T7=U_,P7=YP,I7=ZP,R7=K_,M7=QP,A7=ap,j7=eI,L7=nI,D7=iI,O7=oI,B7=aI,z7=lI,$7=uI,F7=hI,lp="DropdownMenu",[H7]=Ro(lp,[qP]),Mn=qP(),[U7,pI]=H7(lp),mI=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:s,onOpenChange:o,modal:a=!0}=e,l=Mn(t),c=g.useRef(null),[u,d]=Qf({prop:i,defaultProp:s??!1,onChange:o,caller:lp});return h.jsx(U7,{scope:t,triggerId:oo(),triggerRef:c,contentId:oo(),open:u,onOpenChange:d,onOpenToggle:g.useCallback(()=>d(f=>!f),[d]),modal:a,children:h.jsx(N7,{...l,open:u,onOpenChange:d,dir:r,modal:a,children:n})})};mI.displayName=lp;var gI="DropdownMenuTrigger",vI=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,s=pI(gI,n),o=Mn(n);return h.jsx(T7,{asChild:!0,...o,children:h.jsx(Et.button,{type:"button",id:s.triggerId,"aria-haspopup":"menu","aria-expanded":s.open,"aria-controls":s.open?s.contentId:void 0,"data-state":s.open?"open":"closed","data-disabled":r?"":void 0,disabled:r,...i,ref:gu(t,s.triggerRef),onPointerDown:Pe(e.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(s.onOpenToggle(),s.open||a.preventDefault())}),onKeyDown:Pe(e.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&s.onOpenToggle(),a.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});vI.displayName=gI;var W7="DropdownMenuPortal",xI=e=>{const{__scopeDropdownMenu:t,...n}=e,r=Mn(t);return h.jsx(P7,{...r,...n})};xI.displayName=W7;var _I="DropdownMenuContent",yI=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=pI(_I,n),s=Mn(n),o=g.useRef(!1);return h.jsx(I7,{id:i.contentId,"aria-labelledby":i.triggerId,...s,...r,ref:t,onCloseAutoFocus:Pe(e.onCloseAutoFocus,a=>{var l;o.current||(l=i.triggerRef.current)==null||l.focus(),o.current=!1,a.preventDefault()}),onInteractOutside:Pe(e.onInteractOutside,a=>{const l=a.detail.originalEvent,c=l.button===0&&l.ctrlKey===!0,u=l.button===2||c;(!i.modal||u)&&(o.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});yI.displayName=_I;var V7="DropdownMenuGroup",q7=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Mn(n);return h.jsx(R7,{...i,...r,ref:t})});q7.displayName=V7;var K7="DropdownMenuLabel",bI=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Mn(n);return h.jsx(M7,{...i,...r,ref:t})});bI.displayName=K7;var G7="DropdownMenuItem",wI=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Mn(n);return h.jsx(A7,{...i,...r,ref:t})});wI.displayName=G7;var X7="DropdownMenuCheckboxItem",SI=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Mn(n);return h.jsx(j7,{...i,...r,ref:t})});SI.displayName=X7;var Y7="DropdownMenuRadioGroup",Z7=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Mn(n);return h.jsx(L7,{...i,...r,ref:t})});Z7.displayName=Y7;var Q7="DropdownMenuRadioItem",J7=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Mn(n);return h.jsx(D7,{...i,...r,ref:t})});J7.displayName=Q7;var eH="DropdownMenuItemIndicator",kI=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Mn(n);return h.jsx(O7,{...i,...r,ref:t})});kI.displayName=eH;var tH="DropdownMenuSeparator",CI=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Mn(n);return h.jsx(B7,{...i,...r,ref:t})});CI.displayName=tH;var nH="DropdownMenuArrow",rH=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Mn(n);return h.jsx(z7,{...i,...r,ref:t})});rH.displayName=nH;var iH="DropdownMenuSubTrigger",sH=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Mn(n);return h.jsx($7,{...i,...r,ref:t})});sH.displayName=iH;var oH="DropdownMenuSubContent",aH=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Mn(n);return h.jsx(F7,{...i,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});aH.displayName=oH;var lH=mI,cH=vI,uH=xI,EI=yI,NI=bI,TI=wI,PI=SI,dH=kI,II=CI;const RI=lH,MI=cH,Y_=g.forwardRef(({className:e,sideOffset:t=4,...n},r)=>h.jsx(uH,{children:h.jsx(EI,{ref:r,sideOffset:t,className:ne("z-50 min-w-[8rem] overflow-hidden rounded-md border border-border bg-elevated p-1","text-text-100 shadow-md",e),...n})}));Y_.displayName=EI.displayName;const cs=g.forwardRef(({className:e,inset:t,...n},r)=>h.jsx(TI,{ref:r,className:ne("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none","focus:bg-bg-200 focus:text-text-100","data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t&&"pl-8",e),...n}));cs.displayName=TI.displayName;const hH=g.forwardRef(({className:e,children:t,checked:n,...r},i)=>h.jsxs(PI,{ref:i,checked:n,className:ne("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-7 pr-2 text-sm outline-none","focus:bg-bg-200 focus:text-text-100","data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...r,children:[h.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:h.jsx(dH,{children:h.jsx(ol,{className:"h-3.5 w-3.5"})})}),t]}));hH.displayName=PI.displayName;const AI=g.forwardRef(({className:e,...t},n)=>h.jsx(II,{ref:n,className:ne("-mx-1 my-1 h-px bg-border",e),...t}));AI.displayName=II.displayName;const fH=g.forwardRef(({className:e,...t},n)=>h.jsx(NI,{ref:n,className:ne("px-2 py-1.5 text-xs font-semibold text-text-400",e),...t}));fH.displayName=NI.displayName;function pH({iconKey:e,tool:t,className:n}){const r=R_(t),i=YT(e);if(!i)return h.jsx(Yf,{className:ne("w-3.5 h-3.5 shrink-0",r,n),"data-testid":"session-icon-default","aria-label":"未分类"});const s=i.Icon;return h.jsx(s,{className:ne("w-3.5 h-3.5 shrink-0",r,n),"data-testid":`session-icon-${i.key}`,"aria-label":i.label})}var mH=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),gH="VisuallyHidden",jI=g.forwardRef((e,t)=>h.jsx(Et.span,{...e,ref:t,style:{...mH,...e.style}}));jI.displayName=gH;var vH=jI,[cp]=Ro("Tooltip",[ip]),up=ip(),LI="TooltipProvider",xH=700,l0="tooltip.open",[_H,Z_]=cp(LI),DI=e=>{const{__scopeTooltip:t,delayDuration:n=xH,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:s}=e,o=g.useRef(!0),a=g.useRef(!1),l=g.useRef(0);return g.useEffect(()=>{const c=l.current;return()=>window.clearTimeout(c)},[]),h.jsx(_H,{scope:t,isOpenDelayedRef:o,delayDuration:n,onOpen:g.useCallback(()=>{window.clearTimeout(l.current),o.current=!1},[]),onClose:g.useCallback(()=>{window.clearTimeout(l.current),l.current=window.setTimeout(()=>o.current=!0,r)},[r]),isPointerInTransitRef:a,onPointerInTransitChange:g.useCallback(c=>{a.current=c},[]),disableHoverableContent:i,children:s})};DI.displayName=LI;var Gc="Tooltip",[yH,dp]=cp(Gc),OI=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:s,disableHoverableContent:o,delayDuration:a}=e,l=Z_(Gc,e.__scopeTooltip),c=up(t),[u,d]=g.useState(null),f=oo(),p=g.useRef(0),m=o??l.disableHoverableContent,v=a??l.delayDuration,b=g.useRef(!1),[x,_]=Qf({prop:r,defaultProp:i??!1,onChange:N=>{N?(l.onOpen(),document.dispatchEvent(new CustomEvent(l0))):l.onClose(),s==null||s(N)},caller:Gc}),y=g.useMemo(()=>x?b.current?"delayed-open":"instant-open":"closed",[x]),w=g.useCallback(()=>{window.clearTimeout(p.current),p.current=0,b.current=!1,_(!0)},[_]),S=g.useCallback(()=>{window.clearTimeout(p.current),p.current=0,_(!1)},[_]),C=g.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{b.current=!0,_(!0),p.current=0},v)},[v,_]);return g.useEffect(()=>()=>{p.current&&(window.clearTimeout(p.current),p.current=0)},[]),h.jsx(EP,{...c,children:h.jsx(yH,{scope:t,contentId:f,open:x,stateAttribute:y,trigger:u,onTriggerChange:d,onTriggerEnter:g.useCallback(()=>{l.isOpenDelayedRef.current?C():w()},[l.isOpenDelayedRef,C,w]),onTriggerLeave:g.useCallback(()=>{m?S():(window.clearTimeout(p.current),p.current=0)},[S,m]),onOpen:w,onClose:S,disableHoverableContent:m,children:n})})};OI.displayName=Gc;var c0="TooltipTrigger",BI=g.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,i=dp(c0,n),s=Z_(c0,n),o=up(n),a=g.useRef(null),l=qt(t,a,i.onTriggerChange),c=g.useRef(!1),u=g.useRef(!1),d=g.useCallback(()=>c.current=!1,[]);return g.useEffect(()=>()=>document.removeEventListener("pointerup",d),[d]),h.jsx(NP,{asChild:!0,...o,children:h.jsx(Et.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:l,onPointerMove:Pe(e.onPointerMove,f=>{f.pointerType!=="touch"&&!u.current&&!s.isPointerInTransitRef.current&&(i.onTriggerEnter(),u.current=!0)}),onPointerLeave:Pe(e.onPointerLeave,()=>{i.onTriggerLeave(),u.current=!1}),onPointerDown:Pe(e.onPointerDown,()=>{i.open&&i.onClose(),c.current=!0,document.addEventListener("pointerup",d,{once:!0})}),onFocus:Pe(e.onFocus,()=>{c.current||i.onOpen()}),onBlur:Pe(e.onBlur,i.onClose),onClick:Pe(e.onClick,i.onClose)})})});BI.displayName=c0;var bH="TooltipPortal",[Hie,wH]=cp(bH,{forceMount:void 0}),Fa="TooltipContent",zI=g.forwardRef((e,t)=>{const n=wH(Fa,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i="top",...s}=e,o=dp(Fa,e.__scopeTooltip);return h.jsx(Hi,{present:r||o.open,children:o.disableHoverableContent?h.jsx($I,{side:i,...s,ref:t}):h.jsx(SH,{side:i,...s,ref:t})})}),SH=g.forwardRef((e,t)=>{const n=dp(Fa,e.__scopeTooltip),r=Z_(Fa,e.__scopeTooltip),i=g.useRef(null),s=qt(t,i),[o,a]=g.useState(null),{trigger:l,onClose:c}=n,u=i.current,{onPointerInTransitChange:d}=r,f=g.useCallback(()=>{a(null),d(!1)},[d]),p=g.useCallback((m,v)=>{const b=m.currentTarget,x={x:m.clientX,y:m.clientY},_=TH(x,b.getBoundingClientRect()),y=PH(x,_),w=IH(v.getBoundingClientRect()),S=MH([...y,...w]);a(S),d(!0)},[d]);return g.useEffect(()=>()=>f(),[f]),g.useEffect(()=>{if(l&&u){const m=b=>p(b,u),v=b=>p(b,l);return l.addEventListener("pointerleave",m),u.addEventListener("pointerleave",v),()=>{l.removeEventListener("pointerleave",m),u.removeEventListener("pointerleave",v)}}},[l,u,p,f]),g.useEffect(()=>{if(o){const m=v=>{const b=v.target,x={x:v.clientX,y:v.clientY},_=(l==null?void 0:l.contains(b))||(u==null?void 0:u.contains(b)),y=!RH(x,o);_?f():y&&(f(),c())};return document.addEventListener("pointermove",m),()=>document.removeEventListener("pointermove",m)}},[l,u,o,c,f]),h.jsx($I,{...e,ref:s})}),[kH,CH]=cp(Gc,{isInside:!1}),EH=gF("TooltipContent"),$I=g.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:s,onPointerDownOutside:o,...a}=e,l=dp(Fa,n),c=up(n),{onClose:u}=l;return g.useEffect(()=>(document.addEventListener(l0,u),()=>document.removeEventListener(l0,u)),[u]),g.useEffect(()=>{if(l.trigger){const d=f=>{const p=f.target;p!=null&&p.contains(l.trigger)&&u()};return window.addEventListener("scroll",d,{capture:!0}),()=>window.removeEventListener("scroll",d,{capture:!0})}},[l.trigger,u]),h.jsx(Jf,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:o,onFocusOutside:d=>d.preventDefault(),onDismiss:u,children:h.jsxs(TP,{"data-state":l.stateAttribute,...c,...a,ref:t,style:{...a.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[h.jsx(EH,{children:r}),h.jsx(kH,{scope:n,isInside:!0,children:h.jsx(vH,{id:l.contentId,role:"tooltip",children:i||r})})]})})});zI.displayName=Fa;var FI="TooltipArrow",NH=g.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,i=up(n);return CH(FI,n).isInside?null:h.jsx(PP,{...i,...r,ref:t})});NH.displayName=FI;function TH(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),s=Math.abs(t.left-e.x);switch(Math.min(n,r,i,s)){case s:return"left";case i:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function PH(e,t,n=5){const r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function IH(e){const{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}function RH(e,t){const{x:n,y:r}=e;let i=!1;for(let s=0,o=t.length-1;s<t.length;o=s++){const a=t[s],l=t[o],c=a.x,u=a.y,d=l.x,f=l.y;u>r!=f>r&&n<(d-c)*(r-u)/(f-u)+c&&(i=!i)}return i}function MH(e){const t=e.slice();return t.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),AH(t)}function AH(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r<e.length;r++){const i=e[r];for(;t.length>=2;){const s=t[t.length-1],o=t[t.length-2];if((s.x-o.x)*(i.y-o.y)>=(s.y-o.y)*(i.x-o.x))t.pop();else break}t.push(i)}t.pop();const n=[];for(let r=e.length-1;r>=0;r--){const i=e[r];for(;n.length>=2;){const s=n[n.length-1],o=n[n.length-2];if((s.x-o.x)*(i.y-o.y)>=(s.y-o.y)*(i.x-o.x))n.pop();else break}n.push(i)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var jH=DI,LH=OI,DH=BI,HI=zI;const Q_=jH,J_=LH,ey=DH,hp=g.forwardRef(({className:e,sideOffset:t=4,...n},r)=>h.jsx(HI,{ref:r,sideOffset:t,className:ne("z-50 overflow-hidden rounded-sm border border-border bg-bg-0 px-2 py-1 text-xs text-text-300 shadow-md",e),...n}));hp.displayName=HI.displayName;function UI({value:e,onChange:t,tool:n}){const r=R_(n);return h.jsx(Q_,{delayDuration:150,children:h.jsx("div",{className:"flex items-center gap-1 flex-wrap","data-testid":"session-icon-picker",children:XT.map(i=>{const s=i.Icon,o=e===i.key;return h.jsxs(J_,{children:[h.jsx(ey,{asChild:!0,children:h.jsx("button",{type:"button",onClick:()=>t(o?null:i.key),"data-testid":`session-icon-option-${i.key}`,"aria-label":i.label,"aria-pressed":o,className:ne("w-8 h-8 rounded-md flex items-center justify-center transition-colors cursor-pointer",o?"bg-text-100/10 ring-1 ring-text-100/30":"hover:bg-text-100/5"),children:h.jsx(s,{className:ne("w-4 h-4",r)})})}),h.jsx(hp,{side:"bottom",children:i.label})]},i.key)})})})}function OH({open:e,initialLabel:t,initialIconKey:n,placeholder:r,onSubmit:i,onCancel:s,tool:o}){const[a,l]=g.useState(t),[c,u]=g.useState(n);return g.useEffect(()=>{e&&(l(t),u(n))},[e,t,n]),g.useEffect(()=>{if(!e)return;const d=f=>{f.key==="Escape"&&s()};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[e,s]),e?hu.createPortal(h.jsx("div",{className:"fixed inset-0 z-[10000] flex items-center justify-center bg-bg-0/40 backdrop-blur-[2px]",onClick:s,"data-testid":"session-edit-dialog-overlay",children:h.jsxs("div",{"data-testid":"session-edit-dialog",className:"w-[420px] max-w-[calc(100vw-32px)] rounded-2xl border border-text-100/[0.12] flex flex-col gap-4 p-5",style:{backgroundColor:"var(--bg-0)",boxShadow:"0 12px 40px rgba(0,0,0,0.04)"},onClick:d=>d.stopPropagation(),children:[h.jsx("div",{className:"text-[15px] font-semibold text-text-100",children:"Edit session"}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-[12px] font-semibold text-text-200 mb-1",children:"Label"}),h.jsx("input",{autoFocus:!0,type:"text",value:a,onChange:d=>l(d.target.value),placeholder:r,"data-testid":"session-edit-dialog-label",className:"w-full px-3 py-2 text-[13px] bg-bg-50 border border-bg-300 rounded-lg focus:outline-none focus:border-text-300 transition-colors"})]}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-[12px] font-semibold text-text-200 mb-1",children:"Icon"}),h.jsx(UI,{value:c,onChange:u,tool:o})]}),h.jsxs("div",{className:"flex justify-end gap-2 pt-1",children:[h.jsx("button",{type:"button",onClick:s,className:"px-4 py-1.5 text-[12px] text-text-300 rounded-lg hover:bg-text-100/5 transition-colors cursor-pointer",children:"Cancel"}),h.jsx("button",{type:"button",onClick:()=>i({label:a.trim(),iconKey:c}),"data-testid":"session-edit-dialog-save",className:"px-4 py-1.5 text-[12px] font-medium text-bg-0 rounded-lg bg-text-100 hover:bg-text-200 transition-colors cursor-pointer",children:"Save"})]})]})}),document.body):null}const BH=10,zH=20,$H=16,FH=20,HH=60,UH=4;function WH({session:e,active:t,hasUnread:n,running:r=!1,awaitingUser:i=!1,onSelect:s,onEdit:o,onDelete:a,onPin:l,onArchive:c,archiveShortcut:u=!1,depth:d=0,chevron:f,showCopyResume:p=!0,contactDisplayName:m}){const[v,b]=g.useState(!1),x=!!e.pinnedAt,_=d===0,y=d===0&&!!c,w=BH+d*zH,S=g.useCallback(async()=>{const M=e.toolSessionId;if(!M)return;const D=`cd ${`'${e.cwd.replace(/'/g,"'\\''")}'`} && claude --resume ${M} --permission-mode bypassPermissions`;try{await navigator.clipboard.writeText(D)}catch{}},[e.toolSessionId,e.cwd]),C=e.appBuilderProject?`[app] ${e.appBuilderProject}`:e.label||e.larkChatName||e.larkChatId||e.cwd.split("/").filter(Boolean).pop()||e.sessionId.slice(0,8),N=e.originOwnerPrincipalId,T=N?`@${m??`…${N.slice(-8)}`}`:null;return h.jsxs(h.Fragment,{children:[h.jsxs("div",{"data-testid":`session-item-${e.sessionId}`,onClick:s,style:{paddingLeft:w,display:"grid",gridTemplateColumns:`${$H}px ${FH}px 1fr auto ${HH}px`,gridTemplateAreas:'"chev icon name dot time" ". . sub sub sub"',columnGap:`${UH}px`,rowGap:"2px",alignItems:"center"},className:ne("group relative rounded-lg cursor-pointer transition-all duration-150 pr-2.5 py-1.5",t?"bg-accent-dim":"hover:bg-sidebar-hover-bg"),children:[t?h.jsx("span",{"aria-hidden":"true",className:"absolute left-0 top-1/2 -translate-y-1/2 w-[3px] h-7 rounded-r-full bg-accent"}):null,h.jsx("div",{style:{gridArea:"chev"},className:"flex items-center justify-center",children:f??null}),h.jsx("div",{style:{gridArea:"icon"},className:"flex items-center justify-center",children:h.jsx(pH,{iconKey:e.iconKey,tool:e.tool})}),h.jsxs("div",{style:{gridArea:"name"},className:"flex items-center gap-1 min-w-0",children:[e.dispatchedFromSessionId?h.jsx(oz,{"data-testid":`dispatched-icon-${e.sessionId}`,className:"w-3 h-3 text-accent shrink-0",strokeWidth:2.25,"aria-label":"dispatched from another session",children:h.jsx("title",{children:"由另一个 session dispatch 派生"})}):null,e.shiftFiredFromSessionId?h.jsx(I6,{"data-testid":`shift-fired-icon-${e.sessionId}`,className:"w-3 h-3 text-accent shrink-0",strokeWidth:2.25,"aria-label":"fired by clawd-shift scheduler",children:h.jsx("title",{children:"由 shift 排班到点 fire 派生"})}):null,e.larkChatId?h.jsx(jz,{"data-testid":`lark-chat-icon-${e.sessionId}`,className:"w-3 h-3 text-accent shrink-0",strokeWidth:2.25,"aria-label":"driven by feishu chat",children:h.jsx("title",{children:e.larkChatType==="p2p"?"飞书私聊会话(对方消息驱动)":"飞书群会话(群成员 @ bot 驱动)"})}):null,h.jsx("span",{"data-testid":`session-title-${e.sessionId}`,className:ne("text-[13px] truncate min-w-0","group-hover:whitespace-normal group-hover:overflow-visible group-hover:break-words",t?"text-text-100 font-medium":"text-text-200"),children:C})]}),i?h.jsx(L6,{"data-testid":`awaiting-dot-${e.sessionId}`,style:{gridArea:"dot"},className:"w-3 h-3 text-warning shrink-0 animate-pulse",strokeWidth:2.25,"aria-label":"awaiting user"}):n?h.jsx("span",{"data-testid":`unread-dot-${e.sessionId}`,style:{gridArea:"dot"},className:"w-2 h-2 rounded-full bg-error shrink-0","aria-label":"unread"}):r?h.jsx("span",{"data-testid":`running-dot-${e.sessionId}`,style:{gridArea:"dot"},className:"w-2 h-2 rounded-full bg-success shrink-0 animate-pulse","aria-label":"running"}):null,h.jsx("span",{style:{gridArea:"time"},className:ne("text-[11px] text-text-400/70 text-right shrink-0","transition-opacity duration-150 group-hover:opacity-0"),children:e.updatedAt?cF(e.updatedAt):""}),h.jsxs("span",{style:{gridArea:"sub"},className:ne("flex items-center gap-1.5 text-[11px] text-text-400/70 min-w-0","group-hover:flex-wrap"),children:[T?h.jsx("span",{"data-testid":`session-mirror-chip-${e.sessionId}`,title:`在 ${T.replace(/^@/,"")} 的设备上`,className:"shrink-0 inline-flex items-center px-1.5 py-0 rounded text-[10px] bg-accent-dim/40 text-accent border border-accent/20 max-w-[120px] truncate",children:T}):null,h.jsx("span",{"data-testid":`session-subtitle-${e.sessionId}`,className:ne("block text-[11px] text-text-400/70 truncate font-mono min-w-0","group-hover:whitespace-normal group-hover:overflow-visible group-hover:break-all"),children:e.cwd.replace(/^\/Users\/[^/]+/,"~")})]}),o||a||l||c?h.jsxs("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 flex items-center opacity-0 group-hover:opacity-100 data-[state=open]:opacity-100 transition-opacity",children:[u&&y&&c?h.jsx("button",{type:"button",title:"归档",onClick:M=>{M.stopPropagation(),c(e.sessionId,!0)},className:"flex items-center justify-center w-7 h-7 rounded-md text-text-400 hover:text-text-100 hover:bg-text-100/5 transition-colors cursor-pointer","aria-label":"archive session","data-testid":`archive-shortcut-${e.sessionId}`,children:h.jsx(xw,{className:"w-4 h-4"})}):null,h.jsxs(RI,{modal:!1,children:[h.jsx(MI,{asChild:!0,children:h.jsx("button",{type:"button",onClick:M=>M.stopPropagation(),className:"flex items-center justify-center w-7 h-7 rounded-md text-text-400 hover:text-text-100 hover:bg-text-100/5 transition-colors cursor-pointer","aria-label":"session actions","data-testid":`session-menu-${e.sessionId}`,children:h.jsx(Qv,{className:"w-4 h-4"})})}),h.jsxs(Y_,{align:"end",onClick:M=>M.stopPropagation(),children:[l&&_&&h.jsxs(cs,{onSelect:()=>l(e.sessionId,!x),"data-testid":`session-${x?"unpin":"pin"}-${e.sessionId}`,children:[x?h.jsx(Hz,{className:"w-3 h-3 mr-2 text-text-400"}):h.jsx(IT,{className:"w-3 h-3 mr-2 text-text-400"}),x?"Unpin":"Pin"]}),y&&c&&h.jsxs(cs,{onSelect:()=>c(e.sessionId,!0),"data-testid":`session-archive-${e.sessionId}`,children:[h.jsx(xw,{className:"w-3 h-3 mr-2 text-text-400"}),"Archive"]}),o&&h.jsxs(cs,{onSelect:()=>b(!0),"data-testid":`session-rename-${e.sessionId}`,children:[h.jsx(PT,{className:"w-3 h-3 mr-2 text-text-400"}),"Rename"]}),p&&e.toolSessionId?h.jsxs(cs,{onSelect:()=>void S(),"data-testid":`session-copy-resume-${e.sessionId}`,children:[h.jsx(mu,{className:"w-3 h-3 mr-2 text-text-400"}),"Copy Resume Command"]}):null,(l||o||p&&e.toolSessionId)&&a&&h.jsx(AI,{}),a&&h.jsxs(cs,{onSelect:()=>void a(e.sessionId),className:"text-destructive focus:text-destructive focus:bg-destructive/10","data-testid":`session-delete-${e.sessionId}`,children:[h.jsx(N_,{className:"w-3 h-3 mr-2"}),"Delete"]})]})]})]}):null]}),o?h.jsx(OH,{open:v,initialLabel:e.label??"",initialIconKey:e.iconKey??null,tool:e.tool,placeholder:e.cwd.split("/").pop()||"",onSubmit:M=>{o(e.sessionId,M),b(!1)},onCancel:()=>b(!1)}):null]})}function ty({node:e,depth:t=0,activeId:n,unreadIds:r,runningIds:i,awaitingIds:s,onSelect:o,onEdit:a,onDelete:l,onPin:c,onArchive:u,archiveShortcut:d,getContactDisplayName:f,showCopyResume:p}){const m=e.children.length>0,{isCollapsed:v,toggle:b}=S6(),x=!v(e.session.sessionId),_=g.useCallback(w=>{w.stopPropagation(),b(e.session.sessionId)},[b,e.session.sessionId]),y=m?h.jsx("button",{type:"button",onClick:_,"data-testid":`session-chevron-${e.session.sessionId}`,"aria-label":x?"collapse":"expand","aria-expanded":x,className:"shrink-0 flex items-center justify-center w-4 h-4 text-text-400 hover:text-text-100 cursor-pointer",children:x?h.jsx(ci,{className:"w-3 h-3"}):h.jsx(ui,{className:"w-3 h-3"})}):null;return h.jsxs("div",{"data-testid":`session-tree-node-${e.session.sessionId}`,children:[h.jsx(WH,{session:e.session,active:n===e.session.sessionId,hasUnread:(r==null?void 0:r.has(e.session.sessionId))??!1,running:(i==null?void 0:i.has(e.session.sessionId))??!1,awaitingUser:(s==null?void 0:s.has(e.session.sessionId))??!1,onSelect:()=>o(e.session.sessionId),onEdit:a,onDelete:l,onPin:c,onArchive:u,archiveShortcut:d,showCopyResume:p,depth:t,chevron:y,contactDisplayName:e.session.originOwnerPrincipalId?f==null?void 0:f(e.session.originOwnerPrincipalId):void 0}),m&&x?h.jsx("div",{"data-testid":`session-tree-children-${e.session.sessionId}`,children:e.children.map(w=>h.jsx(ty,{node:w,depth:t+1,activeId:n,unreadIds:r,runningIds:i,awaitingIds:s,onSelect:o,onEdit:a,onDelete:l,onPin:c,onArchive:u,archiveShortcut:d,getContactDisplayName:f,showCopyResume:p},w.session.sessionId))}):null]})}function VH(e){return e.forkedFromSessionId??e.dispatchedFromSessionId??e.shiftFiredFromSessionId}function WI(e){e=e.filter(s=>!s.ephemeral);const t=new Map;for(const s of e)t.set(s.sessionId,s);const n=new Map,r=[];for(const s of e){const o=VH(s);if(o&&t.has(o)){const a=n.get(o)??[];a.push(s),n.set(o,a)}else r.push(s)}const i=s=>{const a=[...n.get(s.sessionId)??[]].sort((l,c)=>l.createdAt<c.createdAt?-1:l.createdAt>c.createdAt?1:0);return{session:s,children:a.map(i)}};return[...r].sort(qH).map(i)}function VI(e){return[...e].sort((t,n)=>t.session.updatedAt<n.session.updatedAt?1:t.session.updatedAt>n.session.updatedAt?-1:0)}function qH(e,t){const n=typeof e.pinnedAt=="number",r=typeof t.pinnedAt=="number";if(n&&r){const i=typeof e.pinSortOrder=="number",s=typeof t.pinSortOrder=="number";return i&&s?e.pinSortOrder-t.pinSortOrder:i?-1:s?1:t.pinnedAt-e.pinnedAt}return n?-1:r||e.updatedAt<t.updatedAt?1:e.updatedAt>t.updatedAt?-1:0}function KH(e){return e.appBuilderProject?`[app] ${e.appBuilderProject}`:e.label?e.label:e.cwd.split("/").filter(Boolean).pop()??""}function Zw(e,t){const n=t.trim().toLowerCase();return n===""?!0:e.toLowerCase().includes(n)}function qI(e){return e.compositionActive||!!e.nativeIsComposing||e.keyCode===229}function KI(e){return e.key==="Enter"&&!e.shiftKey&&!qI(e)}function GH(e,t){const n=g.useRef(!1),r=g.useCallback(()=>{n.current=!0},[]),i=g.useCallback(()=>{setTimeout(()=>{n.current=!1},0)},[]);return{onKeyDown:g.useCallback(o=>{const a=o.nativeEvent;if(KI({key:o.key,shiftKey:o.shiftKey,compositionActive:n.current,nativeIsComposing:a.isComposing,keyCode:a.keyCode})){o.preventDefault(),e();return}t&&o.key==="Escape"&&(o.preventDefault(),t())},[e,t]),onCompositionStart:r,onCompositionEnd:i}}const XH={isCollapsed:()=>!1,toggle:()=>{},prune:()=>{}};function YH({personas:e,activePersonaId:t,onSelectPersona:n,onCreateSession:r,sessions:i,activeSessionId:s,awaitingIds:o,runningIds:a,unreadIds:l,onSelectSession:c,onDeleteSession:u,ownerPrincipalId:d,creatorDisplayNameByOwnerId:f,isPersonaExpanded:p,onTogglePersonaExpanded:m,onEditSession:v,onPinSession:b,showCopyResume:x,treatSessionsAsRoots:_,searchQuery:y}){const[w,S]=g.useState(null),[C,N]=g.useState(()=>new Set),T=p??(R=>C.has(R)),M=g.useCallback(R=>{if(m){m(R);return}N(I=>{const O=new Set(I);return O.has(R)?O.delete(R):O.add(R),O})},[m]),P=g.useMemo(()=>i==null?void 0:i.filter(R=>!R.ephemeral),[i]);if(e.length===0)return h.jsx(ZH,{});const D=(y??"").trim();return D?h.jsx(C_.Provider,{value:XH,children:h.jsx("div",{"data-testid":"my-personas-list",className:"flex flex-col gap-0.5",children:e.map(R=>{const I=P?P.filter(F=>F.ownerPersonaId===R.personaId).sort((F,L)=>L.updatedAt>F.updatedAt?1:-1):[],O=Zw(R.label,D),z=I.filter(F=>Zw(KH(F),D));if(!O&&z.length===0)return null;const $=O?I:z;return h.jsx(Qw,{persona:R,active:R.personaId===t,editing:!1,onSelectPersona:n,onSubmitCreateSession:()=>{},onCancelCreateSession:()=>{},personaSessions:$,collapsed:!1,onToggleCollapsed:()=>{},activeSessionId:s??null,awaitingIds:o,runningIds:a,unreadIds:l,onSelectSession:c,onDeleteSession:u,onEditSession:v,onPinSession:b,showCopyResume:x,treatSessionsAsRoots:_,ownerPrincipalId:d,creatorDisplayNameByOwnerId:f},R.personaId)})})}):h.jsx("div",{"data-testid":"my-personas-list",className:"flex flex-col gap-0.5",children:e.map(R=>{const I=P?P.filter(O=>O.ownerPersonaId===R.personaId).sort((O,z)=>z.updatedAt>O.updatedAt?1:-1):[];return h.jsx(Qw,{persona:R,active:R.personaId===t,editing:R.personaId===w,onSelectPersona:n,onStartCreateSession:r?()=>S(R.personaId):void 0,onSubmitCreateSession:O=>{S(null),r==null||r(R.personaId,O)},onCancelCreateSession:()=>S(null),personaSessions:I,collapsed:!T(R.personaId),onToggleCollapsed:()=>M(R.personaId),activeSessionId:s??null,awaitingIds:o,runningIds:a,unreadIds:l,onSelectSession:c,onDeleteSession:u,onEditSession:v,onPinSession:b,showCopyResume:x,treatSessionsAsRoots:_,ownerPrincipalId:d,creatorDisplayNameByOwnerId:f},R.personaId)})})}function ZH(){return h.jsx("div",{className:"px-3 py-3 text-[11px] leading-relaxed text-text-400",children:"还没有 persona。点上方 Personas 标题右侧 + 创建第一个。"})}function Qw({persona:e,active:t,editing:n,onSelectPersona:r,onStartCreateSession:i,onSubmitCreateSession:s,onCancelCreateSession:o,personaSessions:a,collapsed:l,onToggleCollapsed:c,activeSessionId:u,awaitingIds:d,runningIds:f,unreadIds:p,onSelectSession:m,onDeleteSession:v,onEditSession:b,onPinSession:x,showCopyResume:_,treatSessionsAsRoots:y,ownerPrincipalId:w,creatorDisplayNameByOwnerId:S}){const C=GI(e.iconKey,e.tool),N=a.length>0,T=!l,M=g.useMemo(()=>{const R=[],I=new Map;for(const O of a){const z=O.creatorPrincipalId;if(O.larkChatId!=null||!z||w&&z===w){R.push(O);continue}const $=z,F=(S==null?void 0:S.get($))??`…${$.slice(-8)}`,L=I.get($);L?L.sessions.push(O):I.set($,{groupKey:$,displayName:F,sessions:[O]})}return{self:R,byPeer:[...I.values()]}},[a,w,S]),P=M.byPeer.length>0,D=g.useMemo(()=>T&&!P?VI(WI(a)):[],[T,P,a]);return h.jsxs("div",{"data-testid":`persona-node-${e.personaId}`,children:[h.jsxs("div",{className:ne("group flex items-center gap-1 px-2 py-1.5 cursor-pointer",t?"bg-accent-dim text-text-100":"hover:bg-bg-200 text-text-200"),onClick:()=>r==null?void 0:r(e.personaId),role:"button",tabIndex:0,children:[N?h.jsx("button",{type:"button",onClick:R=>{R.stopPropagation(),c()},"aria-label":T?"collapse":"expand","aria-expanded":T,"data-testid":`persona-chevron-${e.personaId}`,className:"flex h-4 w-4 shrink-0 items-center justify-center text-text-400 hover:text-text-100",children:T?h.jsx(ci,{className:"h-3 w-3"}):h.jsx(ui,{className:"h-3 w-3"})}):h.jsx("span",{className:"h-4 w-4 shrink-0","aria-hidden":"true"}),h.jsx(C.Component,{className:ne("h-3.5 w-3.5 shrink-0",C.colorClass),"aria-hidden":"true"}),h.jsx("span",{className:"flex-1 truncate text-[13px]",children:e.label}),N?h.jsx("span",{className:"shrink-0 text-[10px] text-text-400 tabular-nums","aria-label":`${a.length} sessions`,children:a.length}):null,i?h.jsx("button",{type:"button",onClick:R=>{R.stopPropagation(),i()},"aria-label":"新建会话",title:"新建会话","data-testid":`persona-create-session-${e.personaId}`,className:"flex h-5 w-5 shrink-0 items-center justify-center rounded text-text-400 opacity-0 hover:bg-text-100/10 hover:text-text-100 focus-visible:opacity-100 group-hover:opacity-100",children:h.jsx(Kz,{className:"h-3.5 w-3.5"})}):null]}),n?h.jsx(QH,{personaId:e.personaId,iconKey:e.iconKey,tool:e.tool,onSubmit:s,onCancel:o}):null,N&&T?h.jsx("div",{"data-testid":`persona-sessions-${e.personaId}`,children:P?h.jsxs(h.Fragment,{children:[M.self.length>0&&h.jsx(Jw,{groupKey:`${e.personaId}-self`,label:"我自己",testId:`persona-sessions-${e.personaId}-self`,sessions:M.self,activeSessionId:u,awaitingIds:d,runningIds:f,unreadIds:p,onSelectSession:m,onDeleteSession:v,onEditSession:b,onPinSession:x,showCopyResume:_}),M.byPeer.map(R=>h.jsx(Jw,{groupKey:`${e.personaId}-peer-${R.groupKey}`,label:R.displayName,testId:`persona-sessions-${e.personaId}-peer-${R.groupKey}`,sessions:R.sessions,activeSessionId:u,awaitingIds:d,runningIds:f,unreadIds:p,onSelectSession:m,onDeleteSession:v,onEditSession:b,onPinSession:x,showCopyResume:_},`${e.personaId}-peer-${R.groupKey}`))]}):D.map(R=>h.jsx(ty,{node:R,depth:y?0:1,activeId:u,unreadIds:p,runningIds:f,awaitingIds:d,onSelect:I=>m==null?void 0:m(I),onDelete:v,onEdit:b,onPin:x,showCopyResume:_},R.session.sessionId))}):null]})}function Jw({label:e,testId:t,sessions:n,activeSessionId:r,awaitingIds:i,runningIds:s,unreadIds:o,onSelectSession:a,onDeleteSession:l,onEditSession:c,onPinSession:u,showCopyResume:d}){const[f,p]=g.useState(!1),m=!f,v=g.useMemo(()=>m?VI(WI(n)):[],[m,n]);return h.jsxs("div",{"data-testid":t,children:[h.jsxs("button",{type:"button",onClick:()=>p(b=>!b),"aria-label":m?"collapse":"expand","aria-expanded":m,"data-testid":`${t}-chevron`,className:"flex items-center gap-1 w-full pl-7 pr-2 py-0.5 text-[11px] text-text-400 hover:text-text-200 transition-colors",children:[m?h.jsx(ci,{className:"h-3 w-3"}):h.jsx(ui,{className:"h-3 w-3"}),h.jsx(T_,{className:"h-3 w-3","aria-hidden":!0}),h.jsx("span",{className:"truncate",children:e}),h.jsx("span",{className:"ml-auto tabular-nums",children:n.length})]}),m&&h.jsx("div",{children:v.map(b=>h.jsx(ty,{node:b,depth:2,activeId:r,unreadIds:o,runningIds:s,awaitingIds:i,onSelect:x=>a==null?void 0:a(x),onDelete:l,onEdit:c,onPin:u,showCopyResume:d},b.session.sessionId))})]})}function QH({personaId:e,iconKey:t,tool:n,onSubmit:r,onCancel:i}){const[s,o]=g.useState(""),a=g.useRef(null),l=GI(t,n),c=s.trim(),u=c.length>0;g.useEffect(()=>{var p;(p=a.current)==null||p.focus()},[]);const d=g.useCallback(()=>{u&&r(c)},[u,c,r]),f=GH(d,i);return h.jsxs("div",{className:"flex items-center gap-1.5 pl-9 pr-2 py-1","data-testid":`persona-new-session-row-${e}`,children:[h.jsx(l.Component,{className:ne("h-3 w-3 shrink-0",l.colorClass),"aria-hidden":"true"}),h.jsx("input",{ref:a,type:"text",value:s,onChange:p=>o(p.target.value),...f,onBlur:i,placeholder:"session label...","data-testid":`persona-new-session-input-${e}`,className:"flex-1 min-w-0 bg-bg-100 border border-text-100/15 rounded px-1.5 py-0.5 text-[12px] text-text-100 placeholder:text-text-400 focus:outline-none focus:border-text-100/40"}),h.jsx("button",{type:"button",onMouseDown:p=>{p.preventDefault(),d()},disabled:!u,"aria-label":"确认",title:"确认(Enter)","data-testid":`persona-new-session-confirm-${e}`,className:"flex h-4 w-4 shrink-0 items-center justify-center rounded text-text-300 hover:bg-text-100/10 hover:text-text-100 disabled:opacity-30 disabled:hover:bg-transparent disabled:hover:text-text-300",children:h.jsx(ol,{className:"h-3 w-3"})}),h.jsx("button",{type:"button",onMouseDown:p=>{p.preventDefault(),i()},"aria-label":"取消",title:"取消(Esc)","data-testid":`persona-new-session-cancel-${e}`,className:"flex h-4 w-4 shrink-0 items-center justify-center rounded text-text-300 hover:bg-text-100/10 hover:text-text-100",children:h.jsx(Rn,{className:"h-3 w-3"})})]})}function GI(e,t){const n=R_(t),r=YT(e);return r?{Component:r.Icon,colorClass:n}:{Component:f$,colorClass:n}}function JH(e,t){const n=getComputedStyle(e),r=parseFloat(n.fontSize);return t*r}function eU(e,t){const n=getComputedStyle(e.ownerDocument.documentElement),r=parseFloat(n.fontSize);return t*r}function tU(e){return e/100*window.innerHeight}function nU(e){return e/100*window.innerWidth}function rU(e){switch(typeof e){case"number":return[e,"px"];case"string":{const t=parseFloat(e);return e.endsWith("%")?[t,"%"]:e.endsWith("px")?[t,"px"]:e.endsWith("rem")?[t,"rem"]:e.endsWith("em")?[t,"em"]:e.endsWith("vh")?[t,"vh"]:e.endsWith("vw")?[t,"vw"]:[t,"%"]}}}function ql({groupSize:e,panelElement:t,styleProp:n}){let r;const[i,s]=rU(n);switch(s){case"%":{r=i/100*e;break}case"px":{r=i;break}case"rem":{r=eU(t,i);break}case"em":{r=JH(t,i);break}case"vh":{r=tU(i);break}case"vw":{r=nU(i);break}}return r}function En(e){return parseFloat(e.toFixed(3))}function Ha({group:e}){const{orientation:t,panels:n}=e;return n.reduce((r,i)=>(r+=t==="horizontal"?i.element.offsetWidth:i.element.offsetHeight,r),0)}function u0(e){const{panels:t}=e,n=Ha({group:e});return n===0?t.map(r=>({groupResizeBehavior:r.panelConstraints.groupResizeBehavior,collapsedSize:0,collapsible:r.panelConstraints.collapsible===!0,defaultSize:void 0,disabled:r.panelConstraints.disabled,minSize:0,maxSize:100,panelId:r.id})):t.map(r=>{const{element:i,panelConstraints:s}=r;let o=0;if(s.collapsedSize!==void 0){const u=ql({groupSize:n,panelElement:i,styleProp:s.collapsedSize});o=En(u/n*100)}let a;if(s.defaultSize!==void 0){const u=ql({groupSize:n,panelElement:i,styleProp:s.defaultSize});a=En(u/n*100)}let l=0;if(s.minSize!==void 0){const u=ql({groupSize:n,panelElement:i,styleProp:s.minSize});l=En(u/n*100)}let c=100;if(s.maxSize!==void 0){const u=ql({groupSize:n,panelElement:i,styleProp:s.maxSize});c=En(u/n*100)}return{groupResizeBehavior:s.groupResizeBehavior,collapsedSize:o,collapsible:s.collapsible===!0,defaultSize:a,disabled:s.disabled,minSize:l,maxSize:c,panelId:r.id}})}function it(e,t="Assertion error"){if(!e)throw Error(t)}function d0(e,t){return Array.from(t).sort(e==="horizontal"?iU:sU)}function iU(e,t){const n=e.element.offsetLeft-t.element.offsetLeft;return n!==0?n:e.element.offsetWidth-t.element.offsetWidth}function sU(e,t){const n=e.element.offsetTop-t.element.offsetTop;return n!==0?n:e.element.offsetHeight-t.element.offsetHeight}function XI(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&e.nodeType===Node.ELEMENT_NODE}function YI(e,t){return{x:e.x>=t.left&&e.x<=t.right?0:Math.min(Math.abs(e.x-t.left),Math.abs(e.x-t.right)),y:e.y>=t.top&&e.y<=t.bottom?0:Math.min(Math.abs(e.y-t.top),Math.abs(e.y-t.bottom))}}function oU({orientation:e,rects:t,targetRect:n}){const r={x:n.x+n.width/2,y:n.y+n.height/2};let i,s=Number.MAX_VALUE;for(const o of t){const{x:a,y:l}=YI(r,o),c=e==="horizontal"?a:l;c<s&&(s=c,i=o)}return it(i,"No rect found"),i}let gd;function aU(){return gd===void 0&&(typeof matchMedia=="function"?gd=!!matchMedia("(pointer:coarse)").matches:gd=!1),gd}function ZI(e){const{element:t,orientation:n,panels:r,separators:i}=e,s=d0(n,Array.from(t.children).filter(XI).map(m=>({element:m}))).map(({element:m})=>m),o=[];let a=!1,l=!1,c=-1,u=-1,d=0,f,p=[];{let m=-1;for(const v of s)v.hasAttribute("data-panel")&&(m++,v.hasAttribute("data-disabled")||(d++,c===-1&&(c=m),u=m))}if(d>1){let m=-1;for(const v of s)if(v.hasAttribute("data-panel")){m++;const b=r.find(x=>x.element===v);if(b){if(f){const x=f.element.getBoundingClientRect(),_=v.getBoundingClientRect();let y;if(l){const w=n==="horizontal"?new DOMRect(x.right,x.top,0,x.height):new DOMRect(x.left,x.bottom,x.width,0),S=n==="horizontal"?new DOMRect(_.left,_.top,0,_.height):new DOMRect(_.left,_.top,_.width,0);switch(p.length){case 0:{y=[w,S];break}case 1:{const C=p[0],N=oU({orientation:n,rects:[x,_],targetRect:C.element.getBoundingClientRect()});y=[C,N===x?S:w];break}default:{y=p;break}}}else p.length?y=p:y=[n==="horizontal"?new DOMRect(x.right,_.top,_.left-x.right,_.height):new DOMRect(_.left,x.bottom,_.width,_.top-x.bottom)];for(const w of y){let S="width"in w?w:w.element.getBoundingClientRect();const C=aU()?e.resizeTargetMinimumSize.coarse:e.resizeTargetMinimumSize.fine;if(S.width<C){const T=C-S.width;S=new DOMRect(S.x-T/2,S.y,S.width+T,S.height)}if(S.height<C){const T=C-S.height;S=new DOMRect(S.x,S.y-T/2,S.width,S.height+T)}const N=m<=c||m>u;!a&&!N&&o.push({group:e,groupSize:Ha({group:e}),panels:[f,b],separator:"width"in w?void 0:w,rect:S}),a=!1}}l=!1,f=b,p=[]}}else if(v.hasAttribute("data-separator")){v.ariaDisabled!==null&&(a=!0);const b=i.find(x=>x.element===v);b?p.push(b):(f=void 0,p=[])}else l=!0}return o}var us;class QI{constructor(){o1(this,us,{})}addListener(t,n){const r=_l(this,us)[t];return r===void 0?_l(this,us)[t]=[n]:r.includes(n)||r.push(n),()=>{this.removeListener(t,n)}}emit(t,n){const r=_l(this,us)[t];if(r!==void 0)if(r.length===1)r[0].call(null,n);else{let i=!1,s=null;const o=Array.from(r);for(let a=0;a<o.length;a++){const l=o[a];try{l.call(null,n)}catch(c){s===null&&(i=!0,s=c)}}if(i)throw s}}removeAllListeners(){a1(this,us,{})}removeListener(t,n){const r=_l(this,us)[t];if(r!==void 0){const i=r.indexOf(n);i>=0&&r.splice(i,1)}}}us=new WeakMap;let Ca={cursorFlags:0,state:"inactive"};const ny=new QI;function _o(){return Ca}function lU(e){return ny.addListener("change",e)}function cU(e){const t=Ca,n={...Ca};n.cursorFlags=e,Ca=n,ny.emit("change",{prev:t,next:n})}function Ea(e){const t=Ca;Ca=e,ny.emit("change",{prev:t,next:e})}const uU=e=>e,Im=()=>{},JI=1,eR=2,tR=4,nR=8,eS=3,tS=12;let vd;function nS(){return vd===void 0&&(vd=!1,typeof window<"u"&&(window.navigator.userAgent.includes("Chrome")||window.navigator.userAgent.includes("Firefox"))&&(vd=!0)),vd}function dU({cursorFlags:e,groups:t,state:n}){let r=0,i=0;switch(n){case"active":case"hover":t.forEach(s=>{if(!s.mutableState.disableCursor)switch(s.orientation){case"horizontal":{r++;break}case"vertical":{i++;break}}})}if(!(r===0&&i===0)){switch(n){case"active":{if(e&&nS()){const s=(e&JI)!==0,o=(e&eR)!==0,a=(e&tR)!==0,l=(e&nR)!==0;if(s)return a?"se-resize":l?"ne-resize":"e-resize";if(o)return a?"sw-resize":l?"nw-resize":"w-resize";if(a)return"s-resize";if(l)return"n-resize"}break}}return nS()?r>0&&i>0?"move":r>0?"ew-resize":"ns-resize":r>0&&i>0?"grab":r>0?"col-resize":"row-resize"}}const rS=new WeakMap;function ry(e){if(e.defaultView===null||e.defaultView===void 0)return;let{prevStyle:t,styleSheet:n}=rS.get(e)??{};n===void 0&&(n=new e.defaultView.CSSStyleSheet,e.adoptedStyleSheets&&(Object.isExtensible(e.adoptedStyleSheets)?e.adoptedStyleSheets.push(n):e.adoptedStyleSheets=[...e.adoptedStyleSheets,n]));const r=_o();switch(r.state){case"active":case"hover":{const i=dU({cursorFlags:r.cursorFlags,groups:r.hitRegions.map(o=>o.group),state:r.state}),s=`*, *:hover {cursor: ${i} !important; }`;if(t===s)return;t=s,i?n.cssRules.length===0?n.insertRule(s):n.replaceSync(s):n.cssRules.length===1&&n.deleteRule(0);break}case"inactive":{t=void 0,n.cssRules.length===1&&n.deleteRule(0);break}}rS.set(e,{prevStyle:t,styleSheet:n})}let Zr=new Map;const rR=new QI;function hU(e){Zr=new Map(Zr),Zr.delete(e)}function iS(e,t){for(const[n]of Zr)if(n.id===e)return n}function ks(e,t){for(const[n,r]of Zr)if(n.id===e)return r;if(t)throw Error(`Could not find data for Group with id ${e}`)}function jo(){return Zr}function iy(e,t){return rR.addListener("groupChange",n=>{n.group.id===e&&t(n)})}function Oi(e,t,n){const r=Zr.get(e);Zr=new Map(Zr),Zr.set(e,t),rR.emit("groupChange",{group:e,isUserInteraction:(n==null?void 0:n.isUserInteraction)===!0,prev:r,next:t})}function iR(e){const t=_o();let n=!1;switch(t.state){case"active":Ea({cursorFlags:0,state:"inactive"}),t.hitRegions.length>0&&(ry(e),n=!0,t.hitRegions.forEach(r=>{const i=ks(r.group.id,!0);Oi(r.group,i,{isUserInteraction:!0})}))}return n}function sS(e){e.defaultPrevented||iR(e.currentTarget)}function fU(e,t,n){let r,i={x:1/0,y:1/0};for(const s of t){const o=YI(n,s.rect);switch(e){case"horizontal":{o.x<=i.x&&(r=s,i=o);break}case"vertical":{o.y<=i.y&&(r=s,i=o);break}}}return r?{distance:i,hitRegion:r}:void 0}function pU(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function mU(e,t){if(e===t)throw new Error("Cannot compare node with itself");const n={a:lS(e),b:lS(t)};let r;for(;n.a.at(-1)===n.b.at(-1);)r=n.a.pop(),n.b.pop();it(r,"Stacking order can only be calculated for elements with a common ancestor");const i={a:aS(oS(n.a)),b:aS(oS(n.b))};if(i.a===i.b){const s=r.childNodes,o={a:n.a.at(-1),b:n.b.at(-1)};let a=s.length;for(;a--;){const l=s[a];if(l===o.a)return 1;if(l===o.b)return-1}}return Math.sign(i.a-i.b)}const gU=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function vU(e){const t=getComputedStyle(sR(e)??e).display;return t==="flex"||t==="inline-flex"}function xU(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||vU(e))||+t.opacity<1||"transform"in t&&t.transform!=="none"||"webkitTransform"in t&&t.webkitTransform!=="none"||"mixBlendMode"in t&&t.mixBlendMode!=="normal"||"filter"in t&&t.filter!=="none"||"webkitFilter"in t&&t.webkitFilter!=="none"||"isolation"in t&&t.isolation==="isolate"||gU.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function oS(e){let t=e.length;for(;t--;){const n=e[t];if(it(n,"Missing node"),xU(n))return n}return null}function aS(e){return e&&Number(getComputedStyle(e).zIndex)||0}function lS(e){const t=[];for(;e;)t.push(e),e=sR(e);return t}function sR(e){const{parentNode:t}=e;return pU(t)?t.host:t}function _U(e,t){return e.x<t.x+t.width&&e.x+e.width>t.x&&e.y<t.y+t.height&&e.y+e.height>t.y}function yU({groupElement:e,hitRegion:t,pointerEventTarget:n}){if(!XI(n)||n.contains(e)||e.contains(n))return!0;if(mU(n,e)>0){let r=n;for(;r;){if(r.contains(e))return!0;if(_U(r.getBoundingClientRect(),t))return!1;r=r.parentElement}}return!0}function sy(e,t){const n=[];return t.forEach((r,i)=>{if(i.disabled)return;const s=ZI(i),o=fU(i.orientation,s,{x:e.clientX,y:e.clientY});o&&o.distance.x<=0&&o.distance.y<=0&&yU({groupElement:i.element,hitRegion:o.hitRegion.rect,pointerEventTarget:e.target})&&n.push(o.hitRegion)}),n}function bU(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n])return!1;return!0}function xn(e,t,n=0){return Math.abs(En(e)-En(t))<=n}function Kr(e,t){return xn(e,t)?0:e>t?1:-1}function pa({overrideDisabledPanels:e,panelConstraints:t,prevSize:n,size:r}){const{collapsedSize:i=0,collapsible:s,disabled:o,maxSize:a=100,minSize:l=0}=t;if(o&&!e)return n;if(Kr(r,l)<0)if(s){const c=(i+l)/2;Kr(r,c)<0?r=i:r=l}else r=l;return r=Math.min(a,r),r=En(r),r}function Xc({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:i,trigger:s}){if(xn(e,0))return t;const o=s==="imperative-api",a=Object.values(t),l=Object.values(i),c=[...a],[u,d]=r;it(u!=null,"Invalid first pivot index"),it(d!=null,"Invalid second pivot index");let f=0;switch(s){case"keyboard":{{const v=e<0?d:u,b=n[v];it(b,`Panel constraints not found for index ${v}`);const{collapsedSize:x=0,collapsible:_,minSize:y=0}=b;if(_){const w=a[v];if(it(w!=null,`Previous layout not found for panel index ${v}`),xn(w,x)){const S=y-w;Kr(S,Math.abs(e))>0&&(e=e<0?0-S:S)}}}{const v=e<0?u:d,b=n[v];it(b,`No panel constraints found for index ${v}`);const{collapsedSize:x=0,collapsible:_,minSize:y=0}=b;if(_){const w=a[v];if(it(w!=null,`Previous layout not found for panel index ${v}`),xn(w,y)){const S=w-x;Kr(S,Math.abs(e))>0&&(e=e<0?0-S:S)}}}break}default:{const v=e<0?d:u,b=n[v];it(b,`Panel constraints not found for index ${v}`);const x=a[v],{collapsible:_,collapsedSize:y,minSize:w}=b;if(_&&Kr(x,w)<0)if(e>0){const S=w-y,C=S/2,N=x+e;Kr(N,w)<0&&(e=Kr(e,C)<=0?0:S)}else{const S=w-y,C=100-S/2,N=x-e;Kr(N,w)<0&&(e=Kr(100+e,C)>0?0:-S)}break}}{const v=e<0?1:-1;let b=e<0?d:u,x=0;for(;;){const y=a[b];it(y!=null,`Previous layout not found for panel index ${b}`);const w=pa({overrideDisabledPanels:o,panelConstraints:n[b],prevSize:y,size:100})-y;if(x+=w,b+=v,b<0||b>=n.length)break}const _=Math.min(Math.abs(e),Math.abs(x));e=e<0?0-_:_}{let v=e<0?u:d;for(;v>=0&&v<n.length;){const b=Math.abs(e)-Math.abs(f),x=a[v];it(x!=null,`Previous layout not found for panel index ${v}`);const _=x-b,y=pa({overrideDisabledPanels:o,panelConstraints:n[v],prevSize:x,size:_});if(!xn(x,y)&&(f+=x-y,c[v]=y,f.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?v--:v++}}if(bU(l,c))return i;{const v=e<0?d:u,b=a[v];it(b!=null,`Previous layout not found for panel index ${v}`);const x=b+f,_=pa({overrideDisabledPanels:o,panelConstraints:n[v],prevSize:b,size:x});if(c[v]=_,!xn(_,x)){let y=x-_,w=e<0?d:u;for(;w>=0&&w<n.length;){const S=c[w];it(S!=null,`Previous layout not found for panel index ${w}`);const C=S+y,N=pa({overrideDisabledPanels:o,panelConstraints:n[w],prevSize:S,size:C});if(xn(S,N)||(y-=N-S,c[w]=N),xn(y,0))break;e>0?w--:w++}}}const p=Object.values(c).reduce((v,b)=>b+v,0);if(!xn(p,100,.1))return i;const m=Object.keys(i);return c.reduce((v,b,x)=>(v[m[x]]=b,v),{})}function yo(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(t[n]===void 0||Kr(e[n],t[n])!==0)return!1;return!0}function bo({layout:e,panelConstraints:t}){const n=Object.values(e),r=[...n],i=r.reduce((a,l)=>a+l,0);if(r.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${r.map(a=>`${a}%`).join(", ")}`);if(!xn(i,100)&&r.length>0)for(let a=0;a<t.length;a++){const l=r[a];it(l!=null,`No layout data found for index ${a}`);const c=100/i*l;r[a]=c}let s=0;for(let a=0;a<t.length;a++){const l=n[a];it(l!=null,`No layout data found for index ${a}`);const c=r[a];it(c!=null,`No layout data found for index ${a}`);const u=pa({overrideDisabledPanels:!0,panelConstraints:t[a],prevSize:l,size:c});c!=u&&(s+=c-u,r[a]=u)}if(!xn(s,0))for(let a=0;a<t.length;a++){const l=r[a];it(l!=null,`No layout data found for index ${a}`);const c=l+s,u=pa({overrideDisabledPanels:!0,panelConstraints:t[a],prevSize:l,size:c});if(l!==u&&(s-=u-l,r[a]=u,xn(s,0)))break}const o=Object.keys(e);return r.reduce((a,l,c)=>(a[o[c]]=l,a),{})}function oR({groupId:e,panelId:t}){const n=()=>{const l=jo();for(const[c,{defaultLayoutDeferred:u,derivedPanelConstraints:d,layout:f,groupSize:p,separatorToPanels:m}]of l)if(c.id===e)return{defaultLayoutDeferred:u,derivedPanelConstraints:d,group:c,groupSize:p,layout:f,separatorToPanels:m};throw Error(`Group ${e} not found`)},r=()=>{const l=n().derivedPanelConstraints.find(c=>c.panelId===t);if(l!==void 0)return l;throw Error(`Panel constraints not found for Panel ${t}`)},i=()=>{const l=n().group.panels.find(c=>c.id===t);if(l!==void 0)return l;throw Error(`Layout not found for Panel ${t}`)},s=()=>{const l=n().layout[t];if(l!==void 0)return l;throw Error(`Layout not found for Panel ${t}`)},o=({nextSize:l,panels:c,prevLayout:u,derivedPanelConstraints:d})=>{const f=s(),p=c.findIndex(b=>b.id===t),m=p===0,v=p===c.length-1;if(v&&l<f&&(m||c.slice(0,p).every((b,x)=>{const _=d[x];return(_==null?void 0:_.collapsible)&&xn(_.collapsedSize,u[_.panelId])}))){const b=c.slice(0,p).reduce((x,_)=>x+u[_.id],0);return{...u,[t]:En(100-b)}}return Xc({delta:v?f-l:l-f,initialLayout:u,panelConstraints:d,pivotIndices:v?[p-1,p]:[p,p+1],prevLayout:u,trigger:"imperative-api"})},a=l=>{const c=s();if(l===c)return;const{defaultLayoutDeferred:u,derivedPanelConstraints:d,group:f,groupSize:p,layout:m,separatorToPanels:v}=n(),b=o({nextSize:l,panels:f.panels,prevLayout:m,derivedPanelConstraints:d}),x=bo({layout:b,panelConstraints:d});yo(m,x)||Oi(f,{defaultLayoutDeferred:u,derivedPanelConstraints:d,groupSize:p,layout:x,separatorToPanels:v})};return{collapse:()=>{const{collapsible:l,collapsedSize:c}=r(),{mutableValues:u}=i(),d=s();l&&d!==c&&(u.expandToSize=d,a(c))},expand:()=>{const{collapsible:l,collapsedSize:c,minSize:u}=r(),{mutableValues:d}=i(),f=s();if(l&&f===c){let p=d.expandToSize??u;p===0&&(p=1),a(p)}},getSize:()=>{const{group:l}=n(),c=s(),{element:u}=i(),d=l.orientation==="horizontal"?u.offsetWidth:u.offsetHeight;return{asPercentage:c,inPixels:d}},isCollapsed:()=>{const{collapsible:l,collapsedSize:c}=r(),u=s();return l&&xn(c,u)},resize:l=>{const{group:c}=n(),{element:u}=i(),d=Ha({group:c}),f=ql({groupSize:d,panelElement:u,styleProp:l}),p=En(f/d*100);a(p)}}}function cS(e){if(e.defaultPrevented)return;const t=jo();sy(e,t).forEach(n=>{if(n.separator&&!n.separator.disableDoubleClick){const r=n.panels.find(i=>i.panelConstraints.defaultSize!==void 0);if(r){const i=r.panelConstraints.defaultSize,s=oR({groupId:n.group.id,panelId:r.id});s&&i!==void 0&&(s.resize(i),e.preventDefault())}}})}function Qd(e){const t=jo();for(const[n]of t)if(n.separators.some(r=>r.element===e))return n;throw Error("Could not find parent Group for separator element")}function aR({groupId:e}){const t=()=>{const n=jo();for(const[r,i]of n)if(r.id===e)return{group:r,...i};throw Error(`Could not find Group with id "${e}"`)};return{getLayout(){const{defaultLayoutDeferred:n,layout:r}=t();return n?{}:r},setLayout(n){const{defaultLayoutDeferred:r,derivedPanelConstraints:i,group:s,groupSize:o,layout:a,separatorToPanels:l}=t(),c=bo({layout:n,panelConstraints:i});return r?a:(yo(a,c)||Oi(s,{defaultLayoutDeferred:r,derivedPanelConstraints:i,groupSize:o,layout:c,separatorToPanels:l}),c)}}}function Hs(e,t){const n=Qd(e),r=ks(n.id,!0),i=n.separators.find(u=>u.element===e);it(i,"Matching separator not found");const s=r.separatorToPanels.get(i);it(s,"Matching panels not found");const o=s.map(u=>n.panels.indexOf(u)),a=aR({groupId:n.id}).getLayout(),l=Xc({delta:t,initialLayout:a,panelConstraints:r.derivedPanelConstraints,pivotIndices:o,prevLayout:a,trigger:"keyboard"}),c=bo({layout:l,panelConstraints:r.derivedPanelConstraints});yo(a,c)||Oi(n,{defaultLayoutDeferred:r.defaultLayoutDeferred,derivedPanelConstraints:r.derivedPanelConstraints,groupSize:r.groupSize,layout:c,separatorToPanels:r.separatorToPanels},{isUserInteraction:!0})}function uS(e){if(e.defaultPrevented)return;const t=e.currentTarget,n=Qd(t);if(!n.disabled)switch(e.key){case"ArrowDown":{e.preventDefault(),n.orientation==="vertical"&&Hs(t,5);break}case"ArrowLeft":{e.preventDefault(),n.orientation==="horizontal"&&Hs(t,-5);break}case"ArrowRight":{e.preventDefault(),n.orientation==="horizontal"&&Hs(t,5);break}case"ArrowUp":{e.preventDefault(),n.orientation==="vertical"&&Hs(t,-5);break}case"End":{e.preventDefault(),Hs(t,100);break}case"Enter":{e.preventDefault();const r=Qd(t),i=ks(r.id,!0),{derivedPanelConstraints:s,layout:o,separatorToPanels:a}=i,l=r.separators.find(f=>f.element===t);it(l,"Matching separator not found");const c=a.get(l);it(c,"Matching panels not found");const u=c[0],d=s.find(f=>f.panelId===u.id);if(it(d,"Panel metadata not found"),d.collapsible){const f=o[u.id],p=d.collapsedSize===f?r.mutableState.expandedPanelSizes[u.id]??d.minSize:d.collapsedSize;Hs(t,p-f)}break}case"F6":{e.preventDefault();const r=Qd(t).separators.map(o=>o.element),i=Array.from(r).findIndex(o=>o===e.currentTarget);it(i!==null,"Index not found");const s=e.shiftKey?i>0?i-1:r.length-1:i+1<r.length?i+1:0;r[s].focus({preventScroll:!0});break}case"Home":{e.preventDefault(),Hs(t,-100);break}}}function dS(e){if(e.defaultPrevented||e.pointerType==="mouse"&&e.button>0)return;const t=jo(),n=sy(e,t),r=new Map;let i=!1;n.forEach(s=>{s.separator&&(i||(i=!0,s.separator.element.focus({focusVisible:!1,preventScroll:!0})));const o=t.get(s.group);o&&r.set(s.group,o.layout)}),Ea({cursorFlags:0,hitRegions:n,initialLayoutMap:r,pointerDownAtPoint:{x:e.clientX,y:e.clientY},state:"active"}),n.length&&e.preventDefault()}function lR({document:e,event:t,hitRegions:n,initialLayoutMap:r,mountedGroups:i,pointerDownAtPoint:s,prevCursorFlags:o}){let a=0;n.forEach(c=>{const{group:u,groupSize:d}=c,{orientation:f,panels:p}=u,{disableCursor:m}=u.mutableState;let v=0;s?f==="horizontal"?v=(t.clientX-s.x)/d*100:v=(t.clientY-s.y)/d*100:f==="horizontal"?v=t.clientX<0?-100:100:v=t.clientY<0?-100:100;const b=r.get(u),x=i.get(u);if(!b||!x)return;const{defaultLayoutDeferred:_,derivedPanelConstraints:y,groupSize:w,layout:S,separatorToPanels:C}=x;if(y&&S&&C){const N=Xc({delta:v,initialLayout:b,panelConstraints:y,pivotIndices:c.panels.map(T=>p.indexOf(T)),prevLayout:S,trigger:"mouse-or-touch"});if(yo(N,S)){if(v!==0&&!m)switch(f){case"horizontal":{a|=v<0?JI:eR;break}case"vertical":{a|=v<0?tR:nR;break}}}else Oi(c.group,{defaultLayoutDeferred:_,derivedPanelConstraints:y,groupSize:w,layout:N,separatorToPanels:C})}});let l=0;t.movementX===0?l|=o&eS:l|=a&eS,t.movementY===0?l|=o&tS:l|=a&tS,cU(l),ry(e)}function hS(e){const t=jo(),n=_o();switch(n.state){case"active":lR({document:e.currentTarget,event:e,hitRegions:n.hitRegions,initialLayoutMap:n.initialLayoutMap,mountedGroups:t,prevCursorFlags:n.cursorFlags})}}function fS(e){var r,i;if(e.defaultPrevented)return;const t=_o(),n=jo();switch(t.state){case"active":{if(e.buttons===0){Ea({cursorFlags:0,state:"inactive"}),t.hitRegions.forEach(s=>{const o=ks(s.group.id,!0);Oi(s.group,o,{isUserInteraction:!0})});return}for(const s of t.hitRegions)if(s.separator){const{element:o}=s.separator;(r=o.hasPointerCapture)!=null&&r.call(o,e.pointerId)||((i=o.setPointerCapture)==null||i.call(o,e.pointerId))}lR({document:e.currentTarget,event:e,hitRegions:t.hitRegions,initialLayoutMap:t.initialLayoutMap,mountedGroups:n,pointerDownAtPoint:t.pointerDownAtPoint,prevCursorFlags:t.cursorFlags});break}default:{const s=sy(e,n);s.length===0?t.state!=="inactive"&&Ea({cursorFlags:0,state:"inactive"}):Ea({cursorFlags:0,hitRegions:s,state:"hover"}),ry(e.currentTarget);break}}}function pS(e){if(e.relatedTarget instanceof HTMLIFrameElement)switch(_o().state){case"hover":Ea({cursorFlags:0,state:"inactive"})}}function mS(e){e.defaultPrevented||e.pointerType==="mouse"&&e.button>0||iR(e.currentTarget)&&e.preventDefault()}function gS(e){let t=0,n=0;const r={};for(const s of e)if(s.defaultSize!==void 0){t++;const o=En(s.defaultSize);n+=o,r[s.panelId]=o}else r[s.panelId]=void 0;const i=e.length-t;if(i!==0){const s=En((100-n)/i);for(const o of e)o.defaultSize===void 0&&(r[o.panelId]=s)}return r}function wU(e,t,n){if(!n[0])return;const r=e.panels.find(l=>l.element===t);if(!r||!r.onResize)return;const i=Ha({group:e}),s=e.orientation==="horizontal"?r.element.offsetWidth:r.element.offsetHeight,o=r.mutableValues.prevSize,a={asPercentage:En(s/i*100),inPixels:s};r.mutableValues.prevSize=a,r.onResize(a,r.id,o)}function SU(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(e[n]!==t[n])return!1;return!0}function kU({group:e,nextGroupSize:t,prevGroupSize:n,prevLayout:r}){if(n<=0||t<=0||n===t)return r;let i=0,s=0,o=!1;const a=new Map,l=[];for(const d of e.panels){const f=r[d.id]??0;switch(d.panelConstraints.groupResizeBehavior){case"preserve-pixel-size":{o=!0;const p=f/100*n,m=En(p/t*100);a.set(d.id,m),i+=m;break}case"preserve-relative-size":default:{l.push(d.id),s+=f;break}}}if(!o||l.length===0)return r;const c=100-i,u={...r};if(a.forEach((d,f)=>{u[f]=d}),s>0)for(const d of l){const f=r[d]??0;u[d]=En(f/s*c)}else{const d=En(c/l.length);for(const f of l)u[f]=d}return u}function CU(e,t){const n=e.map(i=>i.id),r=Object.keys(t);if(n.length!==r.length)return!1;for(const i of n)if(!r.includes(i))return!1;return!0}const Ko=new Map;function EU(e){let t=!0;it(e.element.ownerDocument.defaultView,"Cannot register an unmounted Group");const n=e.element.ownerDocument.defaultView.ResizeObserver,r=new Set,i=new Set,s=new n(m=>{for(const v of m){const{borderBoxSize:b,target:x}=v;if(x===e.element){if(t){const _=Ha({group:e});if(_===0)return;const y=ks(e.id);if(!y)return;const w=u0(e),S=y.defaultLayoutDeferred?gS(w):y.layout,C=kU({group:e,nextGroupSize:_,prevGroupSize:y.groupSize,prevLayout:S}),N=bo({layout:C,panelConstraints:w});if(!y.defaultLayoutDeferred&&yo(y.layout,N)&&SU(y.derivedPanelConstraints,w)&&y.groupSize===_)return;Oi(e,{defaultLayoutDeferred:!1,derivedPanelConstraints:w,groupSize:_,layout:N,separatorToPanels:y.separatorToPanels})}}else wU(e,x,b)}});s.observe(e.element),e.panels.forEach(m=>{it(!r.has(m.id),`Panel ids must be unique; id "${m.id}" was used more than once`),r.add(m.id),m.onResize&&s.observe(m.element)});const o=Ha({group:e}),a=u0(e),l=e.panels.map(({id:m})=>m).join(",");let c=e.mutableState.defaultLayout;c&&(CU(e.panels,c)||(c=void 0));const u=e.mutableState.layouts[l]??c??gS(a),d=bo({layout:u,panelConstraints:a}),f=e.element.ownerDocument;Ko.set(f,(Ko.get(f)??0)+1);const p=new Map;return ZI(e).forEach(m=>{m.separator&&p.set(m.separator,m.panels)}),Oi(e,{defaultLayoutDeferred:o===0,derivedPanelConstraints:a,groupSize:o,layout:d,separatorToPanels:p}),e.separators.forEach(m=>{it(!i.has(m.id),`Separator ids must be unique; id "${m.id}" was used more than once`),i.add(m.id),m.element.addEventListener("keydown",uS)}),Ko.get(f)===1&&(f.addEventListener("contextmenu",sS,!0),f.addEventListener("dblclick",cS,!0),f.addEventListener("pointerdown",dS,!0),f.addEventListener("pointerleave",hS),f.addEventListener("pointermove",fS),f.addEventListener("pointerout",pS),f.addEventListener("pointerup",mS,!0)),function(){t=!1,Ko.set(f,Math.max(0,(Ko.get(f)??0)-1)),hU(e),e.separators.forEach(m=>{m.element.removeEventListener("keydown",uS)}),Ko.get(f)||(f.removeEventListener("contextmenu",sS,!0),f.removeEventListener("dblclick",cS,!0),f.removeEventListener("pointerdown",dS,!0),f.removeEventListener("pointerleave",hS),f.removeEventListener("pointermove",fS),f.removeEventListener("pointerout",pS),f.removeEventListener("pointerup",mS,!0)),s.disconnect()}}function NU(){const[e,t]=g.useState({}),n=g.useCallback(()=>t({}),[]);return[e,n]}function oy(e){const t=g.useId();return`${e??t}`}const Lo=typeof window<"u"?g.useLayoutEffect:g.useEffect;function dc(e){const t=g.useRef(e);return Lo(()=>{t.current=e},[e]),g.useCallback((...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[t])}function ay(...e){return dc(t=>{e.forEach(n=>{if(n)switch(typeof n){case"function":{n(t);break}case"object":{n.current=t;break}}})})}function ly(e){const t=g.useRef({...e});return Lo(()=>{for(const n in e)t.current[n]=e[n]},[e]),t.current}const cR=g.createContext(null);function TU(e,t){const n=g.useRef({getLayout:()=>({}),setLayout:uU});g.useImperativeHandle(t,()=>n.current,[]),Lo(()=>{Object.assign(n.current,aR({groupId:e}))})}function cy({children:e,className:t,defaultLayout:n,disableCursor:r,disabled:i,elementRef:s,groupRef:o,id:a,onLayoutChange:l,onLayoutChanged:c,orientation:u="horizontal",resizeTargetMinimumSize:d={coarse:20,fine:10},style:f,...p}){const m=g.useRef({onLayoutChange:{},onLayoutChanged:{}}),v=dc(D=>{yo(m.current.onLayoutChange,D)||(m.current.onLayoutChange=D,l==null||l(D))}),b=dc((D,R)=>{yo(m.current.onLayoutChanged,D)||(m.current.onLayoutChanged=D,c==null||c(D,{isUserInteraction:R}))}),x=oy(a),_=g.useRef(null),[y,w]=NU(),S=g.useRef({lastExpandedPanelSizes:{},layouts:{},panels:[],resizeTargetMinimumSize:d,separators:[]}),C=ay(_,s);TU(x,o);const N=dc((D,R)=>{const I=_o(),O=iS(D),z=ks(D);if(z){let $=!1;switch(I.state){case"active":{$=I.hitRegions.some(F=>F.group===O);break}}return{flexGrow:z.layout[R]??1,pointerEvents:$?"none":void 0}}if(n!=null&&n[R])return{flexGrow:n==null?void 0:n[R]}}),T=ly({defaultLayout:n,disableCursor:r}),M=g.useMemo(()=>({get disableCursor(){return!!T.disableCursor},getPanelStyles:N,id:x,orientation:u,registerPanel:D=>{const R=S.current;return R.panels=d0(u,[...R.panels,D]),w(),()=>{R.panels=R.panels.filter(I=>I!==D),w()}},registerSeparator:D=>{const R=S.current;return R.separators=d0(u,[...R.separators,D]),w(),()=>{R.separators=R.separators.filter(I=>I!==D),w()}},updatePanelProps:(D,{disabled:R})=>{const I=S.current.panels.find($=>$.id===D);I&&(I.panelConstraints.disabled=R);const O=iS(x),z=ks(x);O&&z&&Oi(O,{...z,derivedPanelConstraints:u0(O)})},updateSeparatorProps:(D,{disabled:R,disableDoubleClick:I})=>{const O=S.current.separators.find(z=>z.id===D);O&&(O.disabled=R,O.disableDoubleClick=I)}}),[N,x,w,u,T]),P=g.useRef(null);return Lo(()=>{const D=_.current;if(D===null)return;const R=S.current;let I;if(T.defaultLayout!==void 0&&Object.keys(T.defaultLayout).length===R.panels.length){I={};for(const E of R.panels){const H=T.defaultLayout[E.id];H!==void 0&&(I[E.id]=H)}}const O={disabled:!!i,element:D,id:x,mutableState:{defaultLayout:I,disableCursor:!!T.disableCursor,expandedPanelSizes:S.current.lastExpandedPanelSizes,layouts:S.current.layouts},orientation:u,panels:R.panels,resizeTargetMinimumSize:R.resizeTargetMinimumSize,separators:R.separators};P.current=O;const z=EU(O),{defaultLayoutDeferred:$,derivedPanelConstraints:F,layout:L}=ks(O.id,!0);!$&&F.length>0&&(v(L),b(L,!1));const B=iy(x,E=>{const{defaultLayoutDeferred:H,derivedPanelConstraints:q,layout:A}=E.next;if(H||q.length===0)return;const re=O.panels.map(({id:V})=>V).join(",");O.mutableState.layouts[re]=A,q.forEach(V=>{if(V.collapsible){const{layout:pe}=E.prev??{};if(pe){const Oe=xn(V.collapsedSize,A[V.panelId]),ie=xn(V.collapsedSize,pe[V.panelId]);Oe&&!ie&&(O.mutableState.expandedPanelSizes[V.panelId]=pe[V.panelId])}}});const oe=_o().state!=="active";v(A),oe&&b(A,E.isUserInteraction)});return()=>{P.current=null,z(),B()}},[i,x,b,v,u,y,T]),g.useEffect(()=>{const D=P.current;D&&(D.mutableState.defaultLayout=n,D.mutableState.disableCursor=!!r)}),h.jsx(cR.Provider,{value:M,children:h.jsx("div",{...p,className:t,"data-group":!0,"data-testid":x,id:x,ref:C,style:{height:"100%",width:"100%",overflow:"hidden",...f,display:"flex",flexDirection:u==="horizontal"?"row":"column",flexWrap:"nowrap",touchAction:u==="horizontal"?"pan-y":"pan-x"},children:e})})}cy.displayName="Group";function uy(){const e=g.useContext(cR);return it(e,"Group Context not found; did you render a Panel or Separator outside of a Group?"),e}function PU(e,t){const{id:n}=uy(),r=g.useRef({collapse:Im,expand:Im,getSize:()=>({asPercentage:0,inPixels:0}),isCollapsed:()=>!1,resize:Im});g.useImperativeHandle(t,()=>r.current,[]),Lo(()=>{Object.assign(r.current,oR({groupId:n,panelId:e}))})}function Yc({children:e,className:t,collapsedSize:n="0%",collapsible:r=!1,defaultSize:i,disabled:s,elementRef:o,groupResizeBehavior:a="preserve-relative-size",id:l,maxSize:c="100%",minSize:u="0%",onResize:d,panelRef:f,style:p,...m}){const v=!!l,b=oy(l),x=ly({disabled:s}),_=g.useRef(null),y=ay(_,o),{getPanelStyles:w,id:S,orientation:C,registerPanel:N,updatePanelProps:T}=uy(),M=d!==null,P=dc((O,z,$)=>{d==null||d(O,l,$)});Lo(()=>{const O=_.current;if(O!==null){const z={element:O,id:b,idIsStable:v,mutableValues:{expandToSize:void 0,prevSize:void 0},onResize:M?P:void 0,panelConstraints:{groupResizeBehavior:a,collapsedSize:n,collapsible:r,defaultSize:i,disabled:x.disabled,maxSize:c,minSize:u}};return N(z)}},[a,n,r,i,M,b,v,c,u,P,N,x]),g.useEffect(()=>{T(b,{disabled:s})},[s,b,T]),PU(b,f);const D=()=>{const O=w(S,b);if(O)return JSON.stringify(O)},R=g.useSyncExternalStore(O=>iy(S,O),D,D);let I;return R?I=JSON.parse(R):i!==void 0?I={flexGrow:void 0,flexShrink:void 0,flexBasis:i}:I={flexGrow:1},h.jsx("div",{...m,"data-disabled":s||void 0,"data-panel":!0,"data-testid":b,id:b,ref:y,style:{...IU,display:"flex",flexBasis:0,flexShrink:1,overflow:"visible",...I},children:h.jsx("div",{className:t,style:{maxHeight:"100%",maxWidth:"100%",flexGrow:1,overflow:"auto",...p,touchAction:C==="horizontal"?"pan-y":"pan-x"},children:e})})}Yc.displayName="Panel";const IU={minHeight:0,maxHeight:"100%",height:"auto",minWidth:0,maxWidth:"100%",width:"auto",border:"none",borderWidth:0,padding:0,margin:0};function RU({layout:e,panelConstraints:t,panelId:n,panelIndex:r}){let i,s;const o=e[n],a=t.find(l=>l.panelId===n);if(a){const l=a.maxSize,c=a.collapsible?a.collapsedSize:a.minSize,u=[r,r+1];s=bo({layout:Xc({delta:c-o,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[n],i=bo({layout:Xc({delta:l-o,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[n]}return{valueControls:n,valueMax:i,valueMin:s,valueNow:o}}function dy({children:e,className:t,disabled:n,disableDoubleClick:r,elementRef:i,id:s,style:o,...a}){const l=oy(s),c=ly({disabled:n,disableDoubleClick:r}),[u,d]=g.useState({}),[f,p]=g.useState("inactive"),[m,v]=g.useState(!1),b=g.useRef(null),x=ay(b,i),{disableCursor:_,id:y,orientation:w,registerSeparator:S,updateSeparatorProps:C}=uy(),N=w==="horizontal"?"vertical":"horizontal";Lo(()=>{const P=b.current;if(P!==null){const D={disabled:c.disabled,disableDoubleClick:c.disableDoubleClick,element:P,id:l},R=S(D),I=lU(z=>{p(z.next.state!=="inactive"&&z.next.hitRegions.some($=>$.separator===D)?z.next.state:"inactive")}),O=iy(y,z=>{const{derivedPanelConstraints:$,layout:F,separatorToPanels:L}=z.next,B=L.get(D);if(B){const E=B[0],H=B.indexOf(E);d(RU({layout:F,panelConstraints:$,panelId:E.id,panelIndex:H}))}});return()=>{I(),O(),R()}}},[y,l,S,c]),g.useEffect(()=>{C(l,{disabled:n,disableDoubleClick:r})},[n,r,l,C]);let T;n&&!_&&(T="not-allowed");let M;if(n)M="disabled";else switch(f){case"active":{M="active";break}default:m?M="focus":M=f}return h.jsx("div",{...a,"aria-controls":u.valueControls,"aria-disabled":n||void 0,"aria-orientation":N,"aria-valuemax":u.valueMax,"aria-valuemin":u.valueMin,"aria-valuenow":u.valueNow,children:e,className:t,"data-separator":M,"data-testid":l,id:l,onBlur:()=>v(!1),onFocus:()=>v(!0),ref:x,role:"separator",style:{flexBasis:"auto",cursor:T,...o,flexGrow:0,flexShrink:0,touchAction:"none"},tabIndex:n?void 0:0})}dy.displayName="Separator";function MU(e,t,n,r=!0){const i=g.useRef({sid:null,tsid:void 0});g.useEffect(()=>{const s=i.current;i.current={sid:t,tsid:n},!(!r||!n||s.sid===t&&(s.tsid===void 0||s.tsid===null)&&typeof n=="string")&&e.sessionObserve({sessionId:t,toolSessionId:n}).catch(()=>{})},[e,t,n,r])}function AU(e,t,n){const r=g.useRef(e),i=g.useRef(t),s=g.useRef(n);s.current=n,g.useEffect(()=>{const o=r.current,a=i.current;r.current=e,i.current=t;const l=o!==e,c=typeof a=="string"&&t==null;!l&&!c||s.current()},[e,t])}const jU=/^Scheduled (?:recurring job|one-shot task) ([0-9a-f]{8}) \(([^)]+)\)/;function LU(e){const t=new Map,n=new Map,r=new Map;for(const i of e)if(i.kind==="tool_call"&&i.tool==="CronCreate"){const s=i.input;if(!s||typeof s.cron!="string"||typeof s.prompt!="string")continue;const o=i.ts;t.set(i.toolUseId,{cron:s.cron,prompt:s.prompt,recurring:s.recurring!==!1,ts:typeof o=="string"?o:"",toolUseId:i.toolUseId})}else if(i.kind==="tool_call"&&i.tool==="CronDelete"){const s=i.input;if(!s||typeof s.id!="string")continue;n.set(i.toolUseId,s.id)}else if(i.kind==="tool_result"){const s=t.get(i.toolUseId);if(s){if(t.delete(i.toolUseId),i.error||typeof i.output!="string")continue;const a=i.output.match(jU);if(!a)continue;r.set(a[1],{id:a[1],cron:s.cron,prompt:s.prompt,recurring:s.recurring,humanSchedule:a[2],createdAt:s.ts,toolUseId:s.toolUseId});continue}const o=n.get(i.toolUseId);o!==void 0&&(n.delete(i.toolUseId),i.error||r.delete(o))}return Array.from(r.values()).sort((i,s)=>i.createdAt.localeCompare(s.createdAt))}const DU=["TaskCreate","TaskUpdate","TaskList","TaskGet"];function OU(e){return DU.includes(e)}function uR(e){return e==="in_progress"||e==="completed"?e:"pending"}function BU(e,t){if(!t||typeof t!="object")return e;const n=t,r=typeof n.subject=="string"&&n.subject?n.subject:typeof n.content=="string"&&n.content?n.content:null;if(!r)return e;const i=typeof n.activeForm=="string"?n.activeForm:void 0,s=typeof n.description=="string"?n.description:void 0;return[...e,{id:String(e.length+1),content:r,status:uR(n.status),activeForm:i,description:s}]}function zU(e,t){if(!t||typeof t!="object")return e;const n=t,r=typeof n.taskId=="string"&&n.taskId?n.taskId:typeof n.id=="string"&&n.id?n.id:null;if(!r)return e;const i=e.findIndex(a=>a.id===r);if(i<0)return e;const s=[...e],o={...s[i]};return"status"in n&&(o.status=uR(n.status)),typeof n.subject=="string"&&(o.content=n.subject),typeof n.content=="string"&&(o.content=n.content),typeof n.activeForm=="string"&&(o.activeForm=n.activeForm),typeof n.description=="string"&&(o.description=n.description),s[i]=o,s}function $U(e){let t=[],n=-1;for(let r=0;r<e.length;r++){const i=e[r];if(i.kind==="task-event")switch(n=r,i.name){case"TaskCreate":t=BU(t,i.input);break;case"TaskUpdate":t=zU(t,i.input);break}}return{tasks:t,lastEventIndex:n}}function FU(e){const{tasks:t,lastEventIndex:n}=$U(e);let r=-1;for(let c=e.length-1;c>=0;c--)if(e[c].kind==="todo-checklist"){r=c;break}const i=[],s=new Map,o=new Map,a=new Map,l=(c,u)=>{var f,p,m;const d={agentId:u.agentId,status:u.status};u.description?d.description=u.description:(f=c.progress)!=null&&f.description&&(d.description=c.progress.description),u.lastToolName?d.lastToolName=u.lastToolName:(p=c.progress)!=null&&p.lastToolName&&(d.lastToolName=c.progress.lastToolName),u.stats?d.stats=u.stats:(m=c.progress)!=null&&m.stats&&(d.stats=c.progress.stats),c.progress=d};for(let c=0;c<e.length;c++){const u=e[c];switch(u.kind){case"tool-call":{const d={kind:"merged-tool",seq:u.seq,tool:u.tool,toolKind:u.toolKind,toolUseId:u.toolUseId,input:u.input,pending:!0};s.set(u.toolUseId,i.length),i.push(d);break}case"tool-result":{const d=s.get(u.toolUseId);if(d!==void 0){const p=i[d];p.output=u.output,p.error=u.error,p.pending=!1,s.delete(u.toolUseId);break}const f=o.get(u.toolUseId);if(f!==void 0){const p=i[f];p.output=u.output,p.error=u.error,p.pending=!1,u.toolResultExtra&&(p.toolResultExtra=u.toolResultExtra);break}break}case"agent-call":{const d={kind:"merged-agent",seq:u.seq,toolUseId:u.toolUseId,description:u.description,input:u.input,pending:!0,notifications:[]};o.set(u.toolUseId,i.length),i.push(d);const f=a.get(u.toolUseId);f&&(l(d,f),a.delete(u.toolUseId));break}case"agent-progress":{const d=o.get(u.toolUseId);if(d!==void 0){l(i[d],u);break}a.set(u.toolUseId,u);break}case"agent-notification":{const d=u.parentToolUseId;if(d){const f=o.get(d);if(f!==void 0){i[f].notifications.push({text:u.text,taskId:u.taskId});break}}i.push({kind:"agent-notification",seq:u.seq,text:u.text,taskId:u.taskId,parentToolUseId:u.parentToolUseId});break}case"todo-checklist":{c===r&&u.todos.length>0&&i.push({kind:"todo-checklist",seq:u.seq,toolUseId:u.toolUseId,todos:u.todos});break}case"task-event":{c===n&&t.length>0&&i.push({kind:"plan-card",seq:u.seq,tasks:t});break}default:i.push(u)}}return i}const HU=/<(system-reminder|related-dir|clawd-shift-fire)\b[^>]*>[\s\S]*?<\/\1>/gi,UU=/<builder-preview\b[^>]*\/>/gi;function dR(e){return e?e.replace(HU,"").replace(UU,"").trim():""}const WU=dR;function VU(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const qU=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,KU=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,GU={};function vS(e,t){return(GU.jsx?KU:qU).test(e)}const XU=/[ \t\n\f\r]/g;function YU(e){return typeof e=="object"?e.type==="text"?xS(e.value):!1:xS(e)}function xS(e){return e.replace(XU,"")===""}class bu{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}bu.prototype.normal={};bu.prototype.property={};bu.prototype.space=void 0;function hR(e,t){const n={},r={};for(const i of e)Object.assign(n,i.property),Object.assign(r,i.normal);return new bu(n,r,t)}function h0(e){return e.toLowerCase()}class Vn{constructor(t,n){this.attribute=n,this.property=t}}Vn.prototype.attribute="";Vn.prototype.booleanish=!1;Vn.prototype.boolean=!1;Vn.prototype.commaOrSpaceSeparated=!1;Vn.prototype.commaSeparated=!1;Vn.prototype.defined=!1;Vn.prototype.mustUseProperty=!1;Vn.prototype.number=!1;Vn.prototype.overloadedBoolean=!1;Vn.prototype.property="";Vn.prototype.spaceSeparated=!1;Vn.prototype.space=void 0;let ZU=0;const Ie=Do(),Mt=Do(),f0=Do(),Y=Do(),lt=Do(),Na=Do(),Xn=Do();function Do(){return 2**++ZU}const p0=Object.freeze(Object.defineProperty({__proto__:null,boolean:Ie,booleanish:Mt,commaOrSpaceSeparated:Xn,commaSeparated:Na,number:Y,overloadedBoolean:f0,spaceSeparated:lt},Symbol.toStringTag,{value:"Module"})),Rm=Object.keys(p0);class hy extends Vn{constructor(t,n,r,i){let s=-1;if(super(t,n),_S(this,"space",i),typeof r=="number")for(;++s<Rm.length;){const o=Rm[s];_S(this,Rm[s],(r&p0[o])===p0[o])}}}hy.prototype.defined=!0;function _S(e,t,n){n&&(e[t]=n)}function cl(e){const t={},n={};for(const[r,i]of Object.entries(e.properties)){const s=new hy(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(s.mustUseProperty=!0),t[r]=s,n[h0(r)]=r,n[h0(s.attribute)]=r}return new bu(t,n,e.space)}const fR=cl({properties:{ariaActiveDescendant:null,ariaAtomic:Mt,ariaAutoComplete:null,ariaBusy:Mt,ariaChecked:Mt,ariaColCount:Y,ariaColIndex:Y,ariaColSpan:Y,ariaControls:lt,ariaCurrent:null,ariaDescribedBy:lt,ariaDetails:null,ariaDisabled:Mt,ariaDropEffect:lt,ariaErrorMessage:null,ariaExpanded:Mt,ariaFlowTo:lt,ariaGrabbed:Mt,ariaHasPopup:null,ariaHidden:Mt,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:lt,ariaLevel:Y,ariaLive:null,ariaModal:Mt,ariaMultiLine:Mt,ariaMultiSelectable:Mt,ariaOrientation:null,ariaOwns:lt,ariaPlaceholder:null,ariaPosInSet:Y,ariaPressed:Mt,ariaReadOnly:Mt,ariaRelevant:null,ariaRequired:Mt,ariaRoleDescription:lt,ariaRowCount:Y,ariaRowIndex:Y,ariaRowSpan:Y,ariaSelected:Mt,ariaSetSize:Y,ariaSort:null,ariaValueMax:Y,ariaValueMin:Y,ariaValueNow:Y,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function pR(e,t){return t in e?e[t]:t}function mR(e,t){return pR(e,t.toLowerCase())}const QU=cl({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Na,acceptCharset:lt,accessKey:lt,action:null,allow:null,allowFullScreen:Ie,allowPaymentRequest:Ie,allowUserMedia:Ie,alt:null,as:null,async:Ie,autoCapitalize:null,autoComplete:lt,autoFocus:Ie,autoPlay:Ie,blocking:lt,capture:null,charSet:null,checked:Ie,cite:null,className:lt,cols:Y,colSpan:null,content:null,contentEditable:Mt,controls:Ie,controlsList:lt,coords:Y|Na,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Ie,defer:Ie,dir:null,dirName:null,disabled:Ie,download:f0,draggable:Mt,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Ie,formTarget:null,headers:lt,height:Y,hidden:f0,high:Y,href:null,hrefLang:null,htmlFor:lt,httpEquiv:lt,id:null,imageSizes:null,imageSrcSet:null,inert:Ie,inputMode:null,integrity:null,is:null,isMap:Ie,itemId:null,itemProp:lt,itemRef:lt,itemScope:Ie,itemType:lt,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Ie,low:Y,manifest:null,max:null,maxLength:Y,media:null,method:null,min:null,minLength:Y,multiple:Ie,muted:Ie,name:null,nonce:null,noModule:Ie,noValidate:Ie,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:Ie,optimum:Y,pattern:null,ping:lt,placeholder:null,playsInline:Ie,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Ie,referrerPolicy:null,rel:lt,required:Ie,reversed:Ie,rows:Y,rowSpan:Y,sandbox:lt,scope:null,scoped:Ie,seamless:Ie,selected:Ie,shadowRootClonable:Ie,shadowRootDelegatesFocus:Ie,shadowRootMode:null,shape:null,size:Y,sizes:null,slot:null,span:Y,spellCheck:Mt,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Y,step:null,style:null,tabIndex:Y,target:null,title:null,translate:null,type:null,typeMustMatch:Ie,useMap:null,value:Mt,width:Y,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:lt,axis:null,background:null,bgColor:null,border:Y,borderColor:null,bottomMargin:Y,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Ie,declare:Ie,event:null,face:null,frame:null,frameBorder:null,hSpace:Y,leftMargin:Y,link:null,longDesc:null,lowSrc:null,marginHeight:Y,marginWidth:Y,noResize:Ie,noHref:Ie,noShade:Ie,noWrap:Ie,object:null,profile:null,prompt:null,rev:null,rightMargin:Y,rules:null,scheme:null,scrolling:Mt,standby:null,summary:null,text:null,topMargin:Y,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Y,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:Ie,disableRemotePlayback:Ie,prefix:null,property:null,results:Y,security:null,unselectable:null},space:"html",transform:mR}),JU=cl({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:Xn,accentHeight:Y,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Y,amplitude:Y,arabicForm:null,ascent:Y,attributeName:null,attributeType:null,azimuth:Y,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Y,by:null,calcMode:null,capHeight:Y,className:lt,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:Y,diffuseConstant:Y,direction:null,display:null,dur:null,divisor:Y,dominantBaseline:null,download:Ie,dx:null,dy:null,edgeMode:null,editable:null,elevation:Y,enableBackground:null,end:null,event:null,exponent:Y,externalResourcesRequired:null,fill:null,fillOpacity:Y,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:Na,g2:Na,glyphName:Na,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Y,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Y,horizOriginX:Y,horizOriginY:Y,id:null,ideographic:Y,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Y,k:Y,k1:Y,k2:Y,k3:Y,k4:Y,kernelMatrix:Xn,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Y,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:Y,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:Y,overlineThickness:Y,paintOrder:null,panose1:null,path:null,pathLength:Y,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:lt,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Y,pointsAtY:Y,pointsAtZ:Y,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Xn,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Xn,rev:Xn,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Xn,requiredFeatures:Xn,requiredFonts:Xn,requiredFormats:Xn,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:Y,specularExponent:Y,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Y,strikethroughThickness:Y,string:null,stroke:null,strokeDashArray:Xn,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Y,strokeOpacity:Y,strokeWidth:null,style:null,surfaceScale:Y,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Xn,tabIndex:Y,tableValues:null,target:null,targetX:Y,targetY:Y,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Xn,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Y,underlineThickness:Y,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Y,values:null,vAlphabetic:Y,vMathematical:Y,vectorEffect:null,vHanging:Y,vIdeographic:Y,version:null,vertAdvY:Y,vertOriginX:Y,vertOriginY:Y,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Y,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:pR}),gR=cl({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),vR=cl({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:mR}),xR=cl({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),eW={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},tW=/[A-Z]/g,yS=/-[a-z]/g,nW=/^data[-\w.:]+$/i;function rW(e,t){const n=h0(t);let r=t,i=Vn;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&nW.test(t)){if(t.charAt(4)==="-"){const s=t.slice(5).replace(yS,sW);r="data"+s.charAt(0).toUpperCase()+s.slice(1)}else{const s=t.slice(4);if(!yS.test(s)){let o=s.replace(tW,iW);o.charAt(0)!=="-"&&(o="-"+o),t="data"+o}}i=hy}return new i(r,t)}function iW(e){return"-"+e.toLowerCase()}function sW(e){return e.charAt(1).toUpperCase()}const oW=hR([fR,QU,gR,vR,xR],"html"),fy=hR([fR,JU,gR,vR,xR],"svg");function aW(e){return e.join(" ").trim()}var py={},bS=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,lW=/\n/g,cW=/^\s*/,uW=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,dW=/^:\s*/,hW=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,fW=/^[;\s]*/,pW=/^\s+|\s+$/g,mW=`
|
|
495
|
+
`)},X9=0,qo=[];function Y9(e){var t=g.useRef([]),n=g.useRef([0,0]),r=g.useRef(),i=g.useState(X9++)[0],s=g.useState(HP)[0],o=g.useRef(e);g.useEffect(function(){o.current=e},[e]),g.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(i));var v=v9([e.lockRef.current],(e.shards||[]).map(Xw),!0).filter(Boolean);return v.forEach(function(b){return b.classList.add("allow-interactivity-".concat(i))}),function(){document.body.classList.remove("block-interactivity-".concat(i)),v.forEach(function(b){return b.classList.remove("allow-interactivity-".concat(i))})}}},[e.inert,e.lockRef.current,e.shards]);var a=g.useCallback(function(v,b){if("touches"in v&&v.touches.length===2||v.type==="wheel"&&v.ctrlKey)return!o.current.allowPinchZoom;var x=md(v),_=n.current,y="deltaX"in v?v.deltaX:_[0]-x[0],w="deltaY"in v?v.deltaY:_[1]-x[1],S,C=v.target,N=Math.abs(y)>Math.abs(w)?"h":"v";if("touches"in v&&N==="h"&&C.type==="range")return!1;var T=window.getSelection(),M=T&&T.anchorNode,P=M?M===C||M.contains(C):!1;if(P)return!1;var D=Kw(N,C);if(!D)return!0;if(D?S=N:(S=N==="v"?"h":"v",D=Kw(N,C)),!D)return!1;if(!r.current&&"changedTouches"in v&&(y||w)&&(r.current=S),!S)return!0;var R=r.current||S;return q9(R,b,v,R==="h"?y:w)},[]),l=g.useCallback(function(v){var b=v;if(!(!qo.length||qo[qo.length-1]!==s)){var x="deltaY"in b?Gw(b):md(b),_=t.current.filter(function(S){return S.name===b.type&&(S.target===b.target||b.target===S.shadowParent)&&K9(S.delta,x)})[0];if(_&&_.should){b.cancelable&&b.preventDefault();return}if(!_){var y=(o.current.shards||[]).map(Xw).filter(Boolean).filter(function(S){return S.contains(b.target)}),w=y.length>0?a(b,y[0]):!o.current.noIsolation;w&&b.cancelable&&b.preventDefault()}}},[]),c=g.useCallback(function(v,b,x,_){var y={name:v,delta:b,target:x,should:_,shadowParent:Z9(x)};t.current.push(y),setTimeout(function(){t.current=t.current.filter(function(w){return w!==y})},1)},[]),u=g.useCallback(function(v){n.current=md(v),r.current=void 0},[]),d=g.useCallback(function(v){c(v.type,Gw(v),v.target,a(v,e.lockRef.current))},[]),f=g.useCallback(function(v){c(v.type,md(v),v.target,a(v,e.lockRef.current))},[]);g.useEffect(function(){return qo.push(s),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener("wheel",l,Vo),document.addEventListener("touchmove",l,Vo),document.addEventListener("touchstart",u,Vo),function(){qo=qo.filter(function(v){return v!==s}),document.removeEventListener("wheel",l,Vo),document.removeEventListener("touchmove",l,Vo),document.removeEventListener("touchstart",u,Vo)}},[]);var p=e.removeScrollBar,m=e.inert;return g.createElement(g.Fragment,null,m?g.createElement(s,{styles:G9(i)}):null,p?g.createElement(z9,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function Z9(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const Q9=E9(FP,Y9);var H_=g.forwardRef(function(e,t){return g.createElement(sp,Xr({},e,{ref:t,sideCar:Q9}))});H_.classNames=sp.classNames;var a0=["Enter"," "],J9=["ArrowDown","PageUp","Home"],qP=["ArrowUp","PageDown","End"],e7=[...J9,...qP],t7={ltr:[...a0,"ArrowRight"],rtl:[...a0,"ArrowLeft"]},n7={ltr:["ArrowLeft"],rtl:["ArrowRight"]},_u="Menu",[qc,r7,i7]=eP(_u),[Mo,KP]=Ro(_u,[i7,ip,MP]),op=ip(),GP=MP(),[s7,Ao]=Mo(_u),[o7,yu]=Mo(_u),XP=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:s,modal:o=!0}=e,a=op(t),[l,c]=g.useState(null),u=g.useRef(!1),d=ji(s),f=tP(i);return g.useEffect(()=>{const p=()=>{u.current=!0,document.addEventListener("pointerdown",m,{capture:!0,once:!0}),document.addEventListener("pointermove",m,{capture:!0,once:!0})},m=()=>u.current=!1;return document.addEventListener("keydown",p,{capture:!0}),()=>{document.removeEventListener("keydown",p,{capture:!0}),document.removeEventListener("pointerdown",m,{capture:!0}),document.removeEventListener("pointermove",m,{capture:!0})}},[]),h.jsx(NP,{...a,children:h.jsx(s7,{scope:t,open:n,onOpenChange:d,content:l,onContentChange:c,children:h.jsx(o7,{scope:t,onClose:g.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:f,modal:o,children:r})})})};XP.displayName=_u;var a7="MenuAnchor",U_=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,i=op(n);return h.jsx(TP,{...i,...r,ref:t})});U_.displayName=a7;var W_="MenuPortal",[l7,YP]=Mo(W_,{forceMount:void 0}),ZP=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:i}=e,s=Ao(W_,t);return h.jsx(l7,{scope:t,forceMount:n,children:h.jsx(Hi,{present:n||s.open,children:h.jsx(F_,{asChild:!0,container:i,children:r})})})};ZP.displayName=W_;var xr="MenuContent",[c7,V_]=Mo(xr),QP=g.forwardRef((e,t)=>{const n=YP(xr,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,s=Ao(xr,e.__scopeMenu),o=yu(xr,e.__scopeMenu);return h.jsx(qc.Provider,{scope:e.__scopeMenu,children:h.jsx(Hi,{present:r||s.open,children:h.jsx(qc.Slot,{scope:e.__scopeMenu,children:o.modal?h.jsx(u7,{...i,ref:t}):h.jsx(d7,{...i,ref:t})})})})}),u7=g.forwardRef((e,t)=>{const n=Ao(xr,e.__scopeMenu),r=g.useRef(null),i=qt(t,r);return g.useEffect(()=>{const s=r.current;if(s)return BP(s)},[]),h.jsx(q_,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:Pe(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),d7=g.forwardRef((e,t)=>{const n=Ao(xr,e.__scopeMenu);return h.jsx(q_,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),h7=Wc("MenuContent.ScrollLock"),q_=g.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:i,onOpenAutoFocus:s,onCloseAutoFocus:o,disableOutsidePointerEvents:a,onEntryFocus:l,onEscapeKeyDown:c,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,disableOutsideScroll:m,...v}=e,b=Ao(xr,n),x=yu(xr,n),_=op(n),y=GP(n),w=r7(n),[S,C]=g.useState(null),N=g.useRef(null),T=qt(t,N,b.onContentChange),M=g.useRef(0),P=g.useRef(""),D=g.useRef(0),R=g.useRef(null),I=g.useRef("right"),O=g.useRef(0),z=m?H_:g.Fragment,$=m?{as:h7,allowPinchZoom:!0}:void 0,F=B=>{var pe,Oe;const E=P.current+B,H=w().filter(ie=>!ie.disabled),q=document.activeElement,A=(pe=H.find(ie=>ie.ref.current===q))==null?void 0:pe.textValue,re=H.map(ie=>ie.textValue),oe=k7(re,E,A),V=(Oe=H.find(ie=>ie.textValue===oe))==null?void 0:Oe.ref.current;(function ie(Ae){P.current=Ae,window.clearTimeout(M.current),Ae!==""&&(M.current=window.setTimeout(()=>ie(""),1e3))})(E),V&&setTimeout(()=>V.focus())};g.useEffect(()=>()=>window.clearTimeout(M.current),[]),iP();const L=g.useCallback(B=>{var H,q;return I.current===((H=R.current)==null?void 0:H.side)&&E7(B,(q=R.current)==null?void 0:q.area)},[]);return h.jsx(c7,{scope:n,searchRef:P,onItemEnter:g.useCallback(B=>{L(B)&&B.preventDefault()},[L]),onItemLeave:g.useCallback(B=>{var E;L(B)||((E=N.current)==null||E.focus(),C(null))},[L]),onTriggerLeave:g.useCallback(B=>{L(B)&&B.preventDefault()},[L]),pointerGraceTimerRef:D,onPointerGraceIntentChange:g.useCallback(B=>{R.current=B},[]),children:h.jsx(z,{...$,children:h.jsx(M_,{asChild:!0,trapped:i,onMountAutoFocus:Pe(s,B=>{var E;B.preventDefault(),(E=N.current)==null||E.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:h.jsx(Jf,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:c,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,children:h.jsx(h9,{asChild:!0,...y,dir:x.dir,orientation:"vertical",loop:r,currentTabStopId:S,onCurrentTabStopIdChange:C,onEntryFocus:Pe(l,B=>{x.isUsingKeyboardRef.current||B.preventDefault()}),preventScrollOnEntryFocus:!0,children:h.jsx(PP,{role:"menu","aria-orientation":"vertical","data-state":pI(b.open),"data-radix-menu-content":"",dir:x.dir,..._,...v,ref:T,style:{outline:"none",...v.style},onKeyDown:Pe(v.onKeyDown,B=>{const H=B.target.closest("[data-radix-menu-content]")===B.currentTarget,q=B.ctrlKey||B.altKey||B.metaKey,A=B.key.length===1;H&&(B.key==="Tab"&&B.preventDefault(),!q&&A&&F(B.key));const re=N.current;if(B.target!==re||!e7.includes(B.key))return;B.preventDefault();const V=w().filter(pe=>!pe.disabled).map(pe=>pe.ref.current);qP.includes(B.key)&&V.reverse(),w7(V)}),onBlur:Pe(e.onBlur,B=>{B.currentTarget.contains(B.target)||(window.clearTimeout(M.current),P.current="")}),onPointerMove:Pe(e.onPointerMove,Kc(B=>{const E=B.target,H=O.current!==B.clientX;if(B.currentTarget.contains(E)&&H){const q=B.clientX>O.current?"right":"left";I.current=q,O.current=B.clientX}}))})})})})})})});QP.displayName=xr;var f7="MenuGroup",K_=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return h.jsx(Et.div,{role:"group",...r,ref:t})});K_.displayName=f7;var p7="MenuLabel",JP=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return h.jsx(Et.div,{...r,ref:t})});JP.displayName=p7;var Qh="MenuItem",Yw="menu.itemSelect",ap=g.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...i}=e,s=g.useRef(null),o=yu(Qh,e.__scopeMenu),a=V_(Qh,e.__scopeMenu),l=qt(t,s),c=g.useRef(!1),u=()=>{const d=s.current;if(!n&&d){const f=new CustomEvent(Yw,{bubbles:!0,cancelable:!0});d.addEventListener(Yw,p=>r==null?void 0:r(p),{once:!0}),JT(d,f),f.defaultPrevented?c.current=!1:o.onClose()}};return h.jsx(eI,{...i,ref:l,disabled:n,onClick:Pe(e.onClick,u),onPointerDown:d=>{var f;(f=e.onPointerDown)==null||f.call(e,d),c.current=!0},onPointerUp:Pe(e.onPointerUp,d=>{var f;c.current||(f=d.currentTarget)==null||f.click()}),onKeyDown:Pe(e.onKeyDown,d=>{const f=a.searchRef.current!=="";n||f&&d.key===" "||a0.includes(d.key)&&(d.currentTarget.click(),d.preventDefault())})})});ap.displayName=Qh;var eI=g.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:i,...s}=e,o=V_(Qh,n),a=GP(n),l=g.useRef(null),c=qt(t,l),[u,d]=g.useState(!1),[f,p]=g.useState("");return g.useEffect(()=>{const m=l.current;m&&p((m.textContent??"").trim())},[s.children]),h.jsx(qc.ItemSlot,{scope:n,disabled:r,textValue:i??f,children:h.jsx(f9,{asChild:!0,...a,focusable:!r,children:h.jsx(Et.div,{role:"menuitem","data-highlighted":u?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:c,onPointerMove:Pe(e.onPointerMove,Kc(m=>{r?o.onItemLeave(m):(o.onItemEnter(m),m.defaultPrevented||m.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Pe(e.onPointerLeave,Kc(m=>o.onItemLeave(m))),onFocus:Pe(e.onFocus,()=>d(!0)),onBlur:Pe(e.onBlur,()=>d(!1))})})})}),m7="MenuCheckboxItem",tI=g.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...i}=e;return h.jsx(oI,{scope:e.__scopeMenu,checked:n,children:h.jsx(ap,{role:"menuitemcheckbox","aria-checked":Jh(n)?"mixed":n,...i,ref:t,"data-state":X_(n),onSelect:Pe(i.onSelect,()=>r==null?void 0:r(Jh(n)?!0:!n),{checkForDefaultPrevented:!1})})})});tI.displayName=m7;var nI="MenuRadioGroup",[g7,v7]=Mo(nI,{value:void 0,onValueChange:()=>{}}),rI=g.forwardRef((e,t)=>{const{value:n,onValueChange:r,...i}=e,s=ji(r);return h.jsx(g7,{scope:e.__scopeMenu,value:n,onValueChange:s,children:h.jsx(K_,{...i,ref:t})})});rI.displayName=nI;var iI="MenuRadioItem",sI=g.forwardRef((e,t)=>{const{value:n,...r}=e,i=v7(iI,e.__scopeMenu),s=n===i.value;return h.jsx(oI,{scope:e.__scopeMenu,checked:s,children:h.jsx(ap,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":X_(s),onSelect:Pe(r.onSelect,()=>{var o;return(o=i.onValueChange)==null?void 0:o.call(i,n)},{checkForDefaultPrevented:!1})})})});sI.displayName=iI;var G_="MenuItemIndicator",[oI,x7]=Mo(G_,{checked:!1}),aI=g.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...i}=e,s=x7(G_,n);return h.jsx(Hi,{present:r||Jh(s.checked)||s.checked===!0,children:h.jsx(Et.span,{...i,ref:t,"data-state":X_(s.checked)})})});aI.displayName=G_;var _7="MenuSeparator",lI=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return h.jsx(Et.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});lI.displayName=_7;var y7="MenuArrow",cI=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,i=op(n);return h.jsx(IP,{...i,...r,ref:t})});cI.displayName=y7;var b7="MenuSub",[Fie,uI]=Mo(b7),Vl="MenuSubTrigger",dI=g.forwardRef((e,t)=>{const n=Ao(Vl,e.__scopeMenu),r=yu(Vl,e.__scopeMenu),i=uI(Vl,e.__scopeMenu),s=V_(Vl,e.__scopeMenu),o=g.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:l}=s,c={__scopeMenu:e.__scopeMenu},u=g.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=null},[]);return g.useEffect(()=>u,[u]),g.useEffect(()=>{const d=a.current;return()=>{window.clearTimeout(d),l(null)}},[a,l]),h.jsx(U_,{asChild:!0,...c,children:h.jsx(eI,{id:i.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":i.contentId,"data-state":pI(n.open),...e,ref:gu(t,i.onTriggerChange),onClick:d=>{var f;(f=e.onClick)==null||f.call(e,d),!(e.disabled||d.defaultPrevented)&&(d.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:Pe(e.onPointerMove,Kc(d=>{s.onItemEnter(d),!d.defaultPrevented&&!e.disabled&&!n.open&&!o.current&&(s.onPointerGraceIntentChange(null),o.current=window.setTimeout(()=>{n.onOpenChange(!0),u()},100))})),onPointerLeave:Pe(e.onPointerLeave,Kc(d=>{var p,m;u();const f=(p=n.content)==null?void 0:p.getBoundingClientRect();if(f){const v=(m=n.content)==null?void 0:m.dataset.side,b=v==="right",x=b?-5:5,_=f[b?"left":"right"],y=f[b?"right":"left"];s.onPointerGraceIntentChange({area:[{x:d.clientX+x,y:d.clientY},{x:_,y:f.top},{x:y,y:f.top},{x:y,y:f.bottom},{x:_,y:f.bottom}],side:v}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(d),d.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:Pe(e.onKeyDown,d=>{var p;const f=s.searchRef.current!=="";e.disabled||f&&d.key===" "||t7[r.dir].includes(d.key)&&(n.onOpenChange(!0),(p=n.content)==null||p.focus(),d.preventDefault())})})})});dI.displayName=Vl;var hI="MenuSubContent",fI=g.forwardRef((e,t)=>{const n=YP(xr,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,s=Ao(xr,e.__scopeMenu),o=yu(xr,e.__scopeMenu),a=uI(hI,e.__scopeMenu),l=g.useRef(null),c=qt(t,l);return h.jsx(qc.Provider,{scope:e.__scopeMenu,children:h.jsx(Hi,{present:r||s.open,children:h.jsx(qc.Slot,{scope:e.__scopeMenu,children:h.jsx(q_,{id:a.contentId,"aria-labelledby":a.triggerId,...i,ref:c,align:"start",side:o.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:u=>{var d;o.isUsingKeyboardRef.current&&((d=l.current)==null||d.focus()),u.preventDefault()},onCloseAutoFocus:u=>u.preventDefault(),onFocusOutside:Pe(e.onFocusOutside,u=>{u.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:Pe(e.onEscapeKeyDown,u=>{o.onClose(),u.preventDefault()}),onKeyDown:Pe(e.onKeyDown,u=>{var p;const d=u.currentTarget.contains(u.target),f=n7[o.dir].includes(u.key);d&&f&&(s.onOpenChange(!1),(p=a.trigger)==null||p.focus(),u.preventDefault())})})})})})});fI.displayName=hI;function pI(e){return e?"open":"closed"}function Jh(e){return e==="indeterminate"}function X_(e){return Jh(e)?"indeterminate":e?"checked":"unchecked"}function w7(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function S7(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function k7(e,t,n){const i=t.length>1&&Array.from(t).every(c=>c===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let o=S7(e,Math.max(s,0));i.length===1&&(o=o.filter(c=>c!==n));const l=o.find(c=>c.toLowerCase().startsWith(i.toLowerCase()));return l!==n?l:void 0}function C7(e,t){const{x:n,y:r}=e;let i=!1;for(let s=0,o=t.length-1;s<t.length;o=s++){const a=t[s],l=t[o],c=a.x,u=a.y,d=l.x,f=l.y;u>r!=f>r&&n<(d-c)*(r-u)/(f-u)+c&&(i=!i)}return i}function E7(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return C7(n,t)}function Kc(e){return t=>t.pointerType==="mouse"?e(t):void 0}var N7=XP,T7=U_,P7=ZP,I7=QP,R7=K_,M7=JP,A7=ap,j7=tI,L7=rI,D7=sI,O7=aI,B7=lI,z7=cI,$7=dI,F7=fI,lp="DropdownMenu",[H7]=Ro(lp,[KP]),Mn=KP(),[U7,mI]=H7(lp),gI=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:s,onOpenChange:o,modal:a=!0}=e,l=Mn(t),c=g.useRef(null),[u,d]=Qf({prop:i,defaultProp:s??!1,onChange:o,caller:lp});return h.jsx(U7,{scope:t,triggerId:oo(),triggerRef:c,contentId:oo(),open:u,onOpenChange:d,onOpenToggle:g.useCallback(()=>d(f=>!f),[d]),modal:a,children:h.jsx(N7,{...l,open:u,onOpenChange:d,dir:r,modal:a,children:n})})};gI.displayName=lp;var vI="DropdownMenuTrigger",xI=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,s=mI(vI,n),o=Mn(n);return h.jsx(T7,{asChild:!0,...o,children:h.jsx(Et.button,{type:"button",id:s.triggerId,"aria-haspopup":"menu","aria-expanded":s.open,"aria-controls":s.open?s.contentId:void 0,"data-state":s.open?"open":"closed","data-disabled":r?"":void 0,disabled:r,...i,ref:gu(t,s.triggerRef),onPointerDown:Pe(e.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(s.onOpenToggle(),s.open||a.preventDefault())}),onKeyDown:Pe(e.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&s.onOpenToggle(),a.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});xI.displayName=vI;var W7="DropdownMenuPortal",_I=e=>{const{__scopeDropdownMenu:t,...n}=e,r=Mn(t);return h.jsx(P7,{...r,...n})};_I.displayName=W7;var yI="DropdownMenuContent",bI=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=mI(yI,n),s=Mn(n),o=g.useRef(!1);return h.jsx(I7,{id:i.contentId,"aria-labelledby":i.triggerId,...s,...r,ref:t,onCloseAutoFocus:Pe(e.onCloseAutoFocus,a=>{var l;o.current||(l=i.triggerRef.current)==null||l.focus(),o.current=!1,a.preventDefault()}),onInteractOutside:Pe(e.onInteractOutside,a=>{const l=a.detail.originalEvent,c=l.button===0&&l.ctrlKey===!0,u=l.button===2||c;(!i.modal||u)&&(o.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});bI.displayName=yI;var V7="DropdownMenuGroup",q7=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Mn(n);return h.jsx(R7,{...i,...r,ref:t})});q7.displayName=V7;var K7="DropdownMenuLabel",wI=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Mn(n);return h.jsx(M7,{...i,...r,ref:t})});wI.displayName=K7;var G7="DropdownMenuItem",SI=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Mn(n);return h.jsx(A7,{...i,...r,ref:t})});SI.displayName=G7;var X7="DropdownMenuCheckboxItem",kI=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Mn(n);return h.jsx(j7,{...i,...r,ref:t})});kI.displayName=X7;var Y7="DropdownMenuRadioGroup",Z7=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Mn(n);return h.jsx(L7,{...i,...r,ref:t})});Z7.displayName=Y7;var Q7="DropdownMenuRadioItem",J7=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Mn(n);return h.jsx(D7,{...i,...r,ref:t})});J7.displayName=Q7;var eH="DropdownMenuItemIndicator",CI=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Mn(n);return h.jsx(O7,{...i,...r,ref:t})});CI.displayName=eH;var tH="DropdownMenuSeparator",EI=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Mn(n);return h.jsx(B7,{...i,...r,ref:t})});EI.displayName=tH;var nH="DropdownMenuArrow",rH=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Mn(n);return h.jsx(z7,{...i,...r,ref:t})});rH.displayName=nH;var iH="DropdownMenuSubTrigger",sH=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Mn(n);return h.jsx($7,{...i,...r,ref:t})});sH.displayName=iH;var oH="DropdownMenuSubContent",aH=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Mn(n);return h.jsx(F7,{...i,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});aH.displayName=oH;var lH=gI,cH=xI,uH=_I,NI=bI,TI=wI,PI=SI,II=kI,dH=CI,RI=EI;const MI=lH,AI=cH,Y_=g.forwardRef(({className:e,sideOffset:t=4,...n},r)=>h.jsx(uH,{children:h.jsx(NI,{ref:r,sideOffset:t,className:ne("z-50 min-w-[8rem] overflow-hidden rounded-md border border-border bg-elevated p-1","text-text-100 shadow-md",e),...n})}));Y_.displayName=NI.displayName;const cs=g.forwardRef(({className:e,inset:t,...n},r)=>h.jsx(PI,{ref:r,className:ne("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none","focus:bg-bg-200 focus:text-text-100","data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t&&"pl-8",e),...n}));cs.displayName=PI.displayName;const hH=g.forwardRef(({className:e,children:t,checked:n,...r},i)=>h.jsxs(II,{ref:i,checked:n,className:ne("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-7 pr-2 text-sm outline-none","focus:bg-bg-200 focus:text-text-100","data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...r,children:[h.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:h.jsx(dH,{children:h.jsx(ol,{className:"h-3.5 w-3.5"})})}),t]}));hH.displayName=II.displayName;const jI=g.forwardRef(({className:e,...t},n)=>h.jsx(RI,{ref:n,className:ne("-mx-1 my-1 h-px bg-border",e),...t}));jI.displayName=RI.displayName;const fH=g.forwardRef(({className:e,...t},n)=>h.jsx(TI,{ref:n,className:ne("px-2 py-1.5 text-xs font-semibold text-text-400",e),...t}));fH.displayName=TI.displayName;function pH({iconKey:e,tool:t,className:n}){const r=R_(t),i=YT(e);if(!i)return h.jsx(Yf,{className:ne("w-3.5 h-3.5 shrink-0",r,n),"data-testid":"session-icon-default","aria-label":"未分类"});const s=i.Icon;return h.jsx(s,{className:ne("w-3.5 h-3.5 shrink-0",r,n),"data-testid":`session-icon-${i.key}`,"aria-label":i.label})}var mH=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),gH="VisuallyHidden",LI=g.forwardRef((e,t)=>h.jsx(Et.span,{...e,ref:t,style:{...mH,...e.style}}));LI.displayName=gH;var vH=LI,[cp]=Ro("Tooltip",[ip]),up=ip(),DI="TooltipProvider",xH=700,l0="tooltip.open",[_H,Z_]=cp(DI),OI=e=>{const{__scopeTooltip:t,delayDuration:n=xH,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:s}=e,o=g.useRef(!0),a=g.useRef(!1),l=g.useRef(0);return g.useEffect(()=>{const c=l.current;return()=>window.clearTimeout(c)},[]),h.jsx(_H,{scope:t,isOpenDelayedRef:o,delayDuration:n,onOpen:g.useCallback(()=>{window.clearTimeout(l.current),o.current=!1},[]),onClose:g.useCallback(()=>{window.clearTimeout(l.current),l.current=window.setTimeout(()=>o.current=!0,r)},[r]),isPointerInTransitRef:a,onPointerInTransitChange:g.useCallback(c=>{a.current=c},[]),disableHoverableContent:i,children:s})};OI.displayName=DI;var Gc="Tooltip",[yH,dp]=cp(Gc),BI=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:s,disableHoverableContent:o,delayDuration:a}=e,l=Z_(Gc,e.__scopeTooltip),c=up(t),[u,d]=g.useState(null),f=oo(),p=g.useRef(0),m=o??l.disableHoverableContent,v=a??l.delayDuration,b=g.useRef(!1),[x,_]=Qf({prop:r,defaultProp:i??!1,onChange:N=>{N?(l.onOpen(),document.dispatchEvent(new CustomEvent(l0))):l.onClose(),s==null||s(N)},caller:Gc}),y=g.useMemo(()=>x?b.current?"delayed-open":"instant-open":"closed",[x]),w=g.useCallback(()=>{window.clearTimeout(p.current),p.current=0,b.current=!1,_(!0)},[_]),S=g.useCallback(()=>{window.clearTimeout(p.current),p.current=0,_(!1)},[_]),C=g.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{b.current=!0,_(!0),p.current=0},v)},[v,_]);return g.useEffect(()=>()=>{p.current&&(window.clearTimeout(p.current),p.current=0)},[]),h.jsx(NP,{...c,children:h.jsx(yH,{scope:t,contentId:f,open:x,stateAttribute:y,trigger:u,onTriggerChange:d,onTriggerEnter:g.useCallback(()=>{l.isOpenDelayedRef.current?C():w()},[l.isOpenDelayedRef,C,w]),onTriggerLeave:g.useCallback(()=>{m?S():(window.clearTimeout(p.current),p.current=0)},[S,m]),onOpen:w,onClose:S,disableHoverableContent:m,children:n})})};BI.displayName=Gc;var c0="TooltipTrigger",zI=g.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,i=dp(c0,n),s=Z_(c0,n),o=up(n),a=g.useRef(null),l=qt(t,a,i.onTriggerChange),c=g.useRef(!1),u=g.useRef(!1),d=g.useCallback(()=>c.current=!1,[]);return g.useEffect(()=>()=>document.removeEventListener("pointerup",d),[d]),h.jsx(TP,{asChild:!0,...o,children:h.jsx(Et.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:l,onPointerMove:Pe(e.onPointerMove,f=>{f.pointerType!=="touch"&&!u.current&&!s.isPointerInTransitRef.current&&(i.onTriggerEnter(),u.current=!0)}),onPointerLeave:Pe(e.onPointerLeave,()=>{i.onTriggerLeave(),u.current=!1}),onPointerDown:Pe(e.onPointerDown,()=>{i.open&&i.onClose(),c.current=!0,document.addEventListener("pointerup",d,{once:!0})}),onFocus:Pe(e.onFocus,()=>{c.current||i.onOpen()}),onBlur:Pe(e.onBlur,i.onClose),onClick:Pe(e.onClick,i.onClose)})})});zI.displayName=c0;var bH="TooltipPortal",[Hie,wH]=cp(bH,{forceMount:void 0}),Fa="TooltipContent",$I=g.forwardRef((e,t)=>{const n=wH(Fa,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i="top",...s}=e,o=dp(Fa,e.__scopeTooltip);return h.jsx(Hi,{present:r||o.open,children:o.disableHoverableContent?h.jsx(FI,{side:i,...s,ref:t}):h.jsx(SH,{side:i,...s,ref:t})})}),SH=g.forwardRef((e,t)=>{const n=dp(Fa,e.__scopeTooltip),r=Z_(Fa,e.__scopeTooltip),i=g.useRef(null),s=qt(t,i),[o,a]=g.useState(null),{trigger:l,onClose:c}=n,u=i.current,{onPointerInTransitChange:d}=r,f=g.useCallback(()=>{a(null),d(!1)},[d]),p=g.useCallback((m,v)=>{const b=m.currentTarget,x={x:m.clientX,y:m.clientY},_=TH(x,b.getBoundingClientRect()),y=PH(x,_),w=IH(v.getBoundingClientRect()),S=MH([...y,...w]);a(S),d(!0)},[d]);return g.useEffect(()=>()=>f(),[f]),g.useEffect(()=>{if(l&&u){const m=b=>p(b,u),v=b=>p(b,l);return l.addEventListener("pointerleave",m),u.addEventListener("pointerleave",v),()=>{l.removeEventListener("pointerleave",m),u.removeEventListener("pointerleave",v)}}},[l,u,p,f]),g.useEffect(()=>{if(o){const m=v=>{const b=v.target,x={x:v.clientX,y:v.clientY},_=(l==null?void 0:l.contains(b))||(u==null?void 0:u.contains(b)),y=!RH(x,o);_?f():y&&(f(),c())};return document.addEventListener("pointermove",m),()=>document.removeEventListener("pointermove",m)}},[l,u,o,c,f]),h.jsx(FI,{...e,ref:s})}),[kH,CH]=cp(Gc,{isInside:!1}),EH=gF("TooltipContent"),FI=g.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:s,onPointerDownOutside:o,...a}=e,l=dp(Fa,n),c=up(n),{onClose:u}=l;return g.useEffect(()=>(document.addEventListener(l0,u),()=>document.removeEventListener(l0,u)),[u]),g.useEffect(()=>{if(l.trigger){const d=f=>{const p=f.target;p!=null&&p.contains(l.trigger)&&u()};return window.addEventListener("scroll",d,{capture:!0}),()=>window.removeEventListener("scroll",d,{capture:!0})}},[l.trigger,u]),h.jsx(Jf,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:o,onFocusOutside:d=>d.preventDefault(),onDismiss:u,children:h.jsxs(PP,{"data-state":l.stateAttribute,...c,...a,ref:t,style:{...a.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[h.jsx(EH,{children:r}),h.jsx(kH,{scope:n,isInside:!0,children:h.jsx(vH,{id:l.contentId,role:"tooltip",children:i||r})})]})})});$I.displayName=Fa;var HI="TooltipArrow",NH=g.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,i=up(n);return CH(HI,n).isInside?null:h.jsx(IP,{...i,...r,ref:t})});NH.displayName=HI;function TH(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),s=Math.abs(t.left-e.x);switch(Math.min(n,r,i,s)){case s:return"left";case i:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function PH(e,t,n=5){const r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function IH(e){const{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}function RH(e,t){const{x:n,y:r}=e;let i=!1;for(let s=0,o=t.length-1;s<t.length;o=s++){const a=t[s],l=t[o],c=a.x,u=a.y,d=l.x,f=l.y;u>r!=f>r&&n<(d-c)*(r-u)/(f-u)+c&&(i=!i)}return i}function MH(e){const t=e.slice();return t.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),AH(t)}function AH(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r<e.length;r++){const i=e[r];for(;t.length>=2;){const s=t[t.length-1],o=t[t.length-2];if((s.x-o.x)*(i.y-o.y)>=(s.y-o.y)*(i.x-o.x))t.pop();else break}t.push(i)}t.pop();const n=[];for(let r=e.length-1;r>=0;r--){const i=e[r];for(;n.length>=2;){const s=n[n.length-1],o=n[n.length-2];if((s.x-o.x)*(i.y-o.y)>=(s.y-o.y)*(i.x-o.x))n.pop();else break}n.push(i)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var jH=OI,LH=BI,DH=zI,UI=$I;const Q_=jH,J_=LH,ey=DH,hp=g.forwardRef(({className:e,sideOffset:t=4,...n},r)=>h.jsx(UI,{ref:r,sideOffset:t,className:ne("z-50 overflow-hidden rounded-sm border border-border bg-bg-0 px-2 py-1 text-xs text-text-300 shadow-md",e),...n}));hp.displayName=UI.displayName;function WI({value:e,onChange:t,tool:n}){const r=R_(n);return h.jsx(Q_,{delayDuration:150,children:h.jsx("div",{className:"flex items-center gap-1 flex-wrap","data-testid":"session-icon-picker",children:XT.map(i=>{const s=i.Icon,o=e===i.key;return h.jsxs(J_,{children:[h.jsx(ey,{asChild:!0,children:h.jsx("button",{type:"button",onClick:()=>t(o?null:i.key),"data-testid":`session-icon-option-${i.key}`,"aria-label":i.label,"aria-pressed":o,className:ne("w-8 h-8 rounded-md flex items-center justify-center transition-colors cursor-pointer",o?"bg-text-100/10 ring-1 ring-text-100/30":"hover:bg-text-100/5"),children:h.jsx(s,{className:ne("w-4 h-4",r)})})}),h.jsx(hp,{side:"bottom",children:i.label})]},i.key)})})})}function OH({open:e,initialLabel:t,initialIconKey:n,placeholder:r,onSubmit:i,onCancel:s,tool:o}){const[a,l]=g.useState(t),[c,u]=g.useState(n);return g.useEffect(()=>{e&&(l(t),u(n))},[e,t,n]),g.useEffect(()=>{if(!e)return;const d=f=>{f.key==="Escape"&&s()};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[e,s]),e?hu.createPortal(h.jsx("div",{className:"fixed inset-0 z-[10000] flex items-center justify-center bg-bg-0/40 backdrop-blur-[2px]",onClick:s,"data-testid":"session-edit-dialog-overlay",children:h.jsxs("div",{"data-testid":"session-edit-dialog",className:"w-[420px] max-w-[calc(100vw-32px)] rounded-2xl border border-text-100/[0.12] flex flex-col gap-4 p-5",style:{backgroundColor:"var(--bg-0)",boxShadow:"0 12px 40px rgba(0,0,0,0.04)"},onClick:d=>d.stopPropagation(),children:[h.jsx("div",{className:"text-[15px] font-semibold text-text-100",children:"Edit session"}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-[12px] font-semibold text-text-200 mb-1",children:"Label"}),h.jsx("input",{autoFocus:!0,type:"text",value:a,onChange:d=>l(d.target.value),placeholder:r,"data-testid":"session-edit-dialog-label",className:"w-full px-3 py-2 text-[13px] bg-bg-50 border border-bg-300 rounded-lg focus:outline-none focus:border-text-300 transition-colors"})]}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-[12px] font-semibold text-text-200 mb-1",children:"Icon"}),h.jsx(WI,{value:c,onChange:u,tool:o})]}),h.jsxs("div",{className:"flex justify-end gap-2 pt-1",children:[h.jsx("button",{type:"button",onClick:s,className:"px-4 py-1.5 text-[12px] text-text-300 rounded-lg hover:bg-text-100/5 transition-colors cursor-pointer",children:"Cancel"}),h.jsx("button",{type:"button",onClick:()=>i({label:a.trim(),iconKey:c}),"data-testid":"session-edit-dialog-save",className:"px-4 py-1.5 text-[12px] font-medium text-bg-0 rounded-lg bg-text-100 hover:bg-text-200 transition-colors cursor-pointer",children:"Save"})]})]})}),document.body):null}const BH=10,zH=20,$H=16,FH=20,HH=60,UH=4;function WH({session:e,active:t,hasUnread:n,running:r=!1,awaitingUser:i=!1,onSelect:s,onEdit:o,onDelete:a,onPin:l,onArchive:c,archiveShortcut:u=!1,depth:d=0,chevron:f,showCopyResume:p=!0,contactDisplayName:m}){const[v,b]=g.useState(!1),x=!!e.pinnedAt,_=d===0,y=d===0&&!!c,w=BH+d*zH,S=g.useCallback(async()=>{const M=e.toolSessionId;if(!M)return;const D=`cd ${`'${e.cwd.replace(/'/g,"'\\''")}'`} && claude --resume ${M} --permission-mode bypassPermissions`;try{await navigator.clipboard.writeText(D)}catch{}},[e.toolSessionId,e.cwd]),C=e.appBuilderProject?`[app] ${e.appBuilderProject}`:e.label||e.larkChatName||e.larkChatId||e.cwd.split("/").filter(Boolean).pop()||e.sessionId.slice(0,8),N=e.originOwnerPrincipalId,T=N?`@${m??`…${N.slice(-8)}`}`:null;return h.jsxs(h.Fragment,{children:[h.jsxs("div",{"data-testid":`session-item-${e.sessionId}`,onClick:s,style:{paddingLeft:w,display:"grid",gridTemplateColumns:`${$H}px ${FH}px 1fr auto ${HH}px`,gridTemplateAreas:'"chev icon name dot time" ". . sub sub sub"',columnGap:`${UH}px`,rowGap:"2px",alignItems:"center"},className:ne("group relative rounded-lg cursor-pointer transition-all duration-150 pr-2.5 py-1.5",t?"bg-accent-dim":"hover:bg-sidebar-hover-bg"),children:[t?h.jsx("span",{"aria-hidden":"true",className:"absolute left-0 top-1/2 -translate-y-1/2 w-[3px] h-7 rounded-r-full bg-accent"}):null,h.jsx("div",{style:{gridArea:"chev"},className:"flex items-center justify-center",children:f??null}),h.jsx("div",{style:{gridArea:"icon"},className:"flex items-center justify-center",children:h.jsx(pH,{iconKey:e.iconKey,tool:e.tool})}),h.jsxs("div",{style:{gridArea:"name"},className:"flex items-center gap-1 min-w-0",children:[e.dispatchedFromSessionId?h.jsx(oz,{"data-testid":`dispatched-icon-${e.sessionId}`,className:"w-3 h-3 text-accent shrink-0",strokeWidth:2.25,"aria-label":"dispatched from another session",children:h.jsx("title",{children:"由另一个 session dispatch 派生"})}):null,e.shiftFiredFromSessionId?h.jsx(I6,{"data-testid":`shift-fired-icon-${e.sessionId}`,className:"w-3 h-3 text-accent shrink-0",strokeWidth:2.25,"aria-label":"fired by clawd-shift scheduler",children:h.jsx("title",{children:"由 shift 排班到点 fire 派生"})}):null,e.larkChatId?h.jsx(jz,{"data-testid":`lark-chat-icon-${e.sessionId}`,className:"w-3 h-3 text-accent shrink-0",strokeWidth:2.25,"aria-label":"driven by feishu chat",children:h.jsx("title",{children:e.larkChatType==="p2p"?"飞书私聊会话(对方消息驱动)":"飞书群会话(群成员 @ bot 驱动)"})}):null,h.jsx("span",{"data-testid":`session-title-${e.sessionId}`,className:ne("text-[13px] truncate min-w-0","group-hover:whitespace-normal group-hover:overflow-visible group-hover:break-words",t?"text-text-100 font-medium":"text-text-200"),children:C})]}),i?h.jsx(L6,{"data-testid":`awaiting-dot-${e.sessionId}`,style:{gridArea:"dot"},className:"w-3 h-3 text-warning shrink-0 animate-pulse",strokeWidth:2.25,"aria-label":"awaiting user"}):n?h.jsx("span",{"data-testid":`unread-dot-${e.sessionId}`,style:{gridArea:"dot"},className:"w-2 h-2 rounded-full bg-error shrink-0","aria-label":"unread"}):r?h.jsx("span",{"data-testid":`running-dot-${e.sessionId}`,style:{gridArea:"dot"},className:"w-2 h-2 rounded-full bg-success shrink-0 animate-pulse","aria-label":"running"}):null,h.jsx("span",{style:{gridArea:"time"},className:ne("text-[11px] text-text-400/70 text-right shrink-0","transition-opacity duration-150 group-hover:opacity-0"),children:e.updatedAt?cF(e.updatedAt):""}),h.jsxs("span",{style:{gridArea:"sub"},className:ne("flex items-center gap-1.5 text-[11px] text-text-400/70 min-w-0","group-hover:flex-wrap"),children:[T?h.jsx("span",{"data-testid":`session-mirror-chip-${e.sessionId}`,title:`在 ${T.replace(/^@/,"")} 的设备上`,className:"shrink-0 inline-flex items-center px-1.5 py-0 rounded text-[10px] bg-accent-dim/40 text-accent border border-accent/20 max-w-[120px] truncate",children:T}):null,h.jsx("span",{"data-testid":`session-subtitle-${e.sessionId}`,className:ne("block text-[11px] text-text-400/70 truncate font-mono min-w-0","group-hover:whitespace-normal group-hover:overflow-visible group-hover:break-all"),children:e.cwd.replace(/^\/Users\/[^/]+/,"~")})]}),o||a||l||c?h.jsxs("div",{className:"absolute right-2 top-1/2 -translate-y-1/2 flex items-center opacity-0 group-hover:opacity-100 data-[state=open]:opacity-100 transition-opacity",children:[u&&y&&c?h.jsx("button",{type:"button",title:"归档",onClick:M=>{M.stopPropagation(),c(e.sessionId,!0)},className:"flex items-center justify-center w-7 h-7 rounded-md text-text-400 hover:text-text-100 hover:bg-text-100/5 transition-colors cursor-pointer","aria-label":"archive session","data-testid":`archive-shortcut-${e.sessionId}`,children:h.jsx(xw,{className:"w-4 h-4"})}):null,h.jsxs(MI,{modal:!1,children:[h.jsx(AI,{asChild:!0,children:h.jsx("button",{type:"button",onClick:M=>M.stopPropagation(),className:"flex items-center justify-center w-7 h-7 rounded-md text-text-400 hover:text-text-100 hover:bg-text-100/5 transition-colors cursor-pointer","aria-label":"session actions","data-testid":`session-menu-${e.sessionId}`,children:h.jsx(Qv,{className:"w-4 h-4"})})}),h.jsxs(Y_,{align:"end",onClick:M=>M.stopPropagation(),children:[l&&_&&h.jsxs(cs,{onSelect:()=>l(e.sessionId,!x),"data-testid":`session-${x?"unpin":"pin"}-${e.sessionId}`,children:[x?h.jsx(Hz,{className:"w-3 h-3 mr-2 text-text-400"}):h.jsx(IT,{className:"w-3 h-3 mr-2 text-text-400"}),x?"Unpin":"Pin"]}),y&&c&&h.jsxs(cs,{onSelect:()=>c(e.sessionId,!0),"data-testid":`session-archive-${e.sessionId}`,children:[h.jsx(xw,{className:"w-3 h-3 mr-2 text-text-400"}),"Archive"]}),o&&h.jsxs(cs,{onSelect:()=>b(!0),"data-testid":`session-rename-${e.sessionId}`,children:[h.jsx(PT,{className:"w-3 h-3 mr-2 text-text-400"}),"Rename"]}),p&&e.toolSessionId?h.jsxs(cs,{onSelect:()=>void S(),"data-testid":`session-copy-resume-${e.sessionId}`,children:[h.jsx(mu,{className:"w-3 h-3 mr-2 text-text-400"}),"Copy Resume Command"]}):null,(l||o||p&&e.toolSessionId)&&a&&h.jsx(jI,{}),a&&h.jsxs(cs,{onSelect:()=>void a(e.sessionId),className:"text-destructive focus:text-destructive focus:bg-destructive/10","data-testid":`session-delete-${e.sessionId}`,children:[h.jsx(N_,{className:"w-3 h-3 mr-2"}),"Delete"]})]})]})]}):null]}),o?h.jsx(OH,{open:v,initialLabel:e.label??"",initialIconKey:e.iconKey??null,tool:e.tool,placeholder:e.cwd.split("/").pop()||"",onSubmit:M=>{o(e.sessionId,M),b(!1)},onCancel:()=>b(!1)}):null]})}function ty({node:e,depth:t=0,activeId:n,unreadIds:r,runningIds:i,awaitingIds:s,onSelect:o,onEdit:a,onDelete:l,onPin:c,onArchive:u,archiveShortcut:d,getContactDisplayName:f,showCopyResume:p}){const m=e.children.length>0,{isCollapsed:v,toggle:b}=S6(),x=!v(e.session.sessionId),_=g.useCallback(w=>{w.stopPropagation(),b(e.session.sessionId)},[b,e.session.sessionId]),y=m?h.jsx("button",{type:"button",onClick:_,"data-testid":`session-chevron-${e.session.sessionId}`,"aria-label":x?"collapse":"expand","aria-expanded":x,className:"shrink-0 flex items-center justify-center w-4 h-4 text-text-400 hover:text-text-100 cursor-pointer",children:x?h.jsx(ci,{className:"w-3 h-3"}):h.jsx(ui,{className:"w-3 h-3"})}):null;return h.jsxs("div",{"data-testid":`session-tree-node-${e.session.sessionId}`,children:[h.jsx(WH,{session:e.session,active:n===e.session.sessionId,hasUnread:(r==null?void 0:r.has(e.session.sessionId))??!1,running:(i==null?void 0:i.has(e.session.sessionId))??!1,awaitingUser:(s==null?void 0:s.has(e.session.sessionId))??!1,onSelect:()=>o(e.session.sessionId),onEdit:a,onDelete:l,onPin:c,onArchive:u,archiveShortcut:d,showCopyResume:p,depth:t,chevron:y,contactDisplayName:e.session.originOwnerPrincipalId?f==null?void 0:f(e.session.originOwnerPrincipalId):void 0}),m&&x?h.jsx("div",{"data-testid":`session-tree-children-${e.session.sessionId}`,children:e.children.map(w=>h.jsx(ty,{node:w,depth:t+1,activeId:n,unreadIds:r,runningIds:i,awaitingIds:s,onSelect:o,onEdit:a,onDelete:l,onPin:c,onArchive:u,archiveShortcut:d,getContactDisplayName:f,showCopyResume:p},w.session.sessionId))}):null]})}function VH(e){return e.forkedFromSessionId??e.dispatchedFromSessionId??e.shiftFiredFromSessionId}function VI(e){e=e.filter(s=>!s.ephemeral);const t=new Map;for(const s of e)t.set(s.sessionId,s);const n=new Map,r=[];for(const s of e){const o=VH(s);if(o&&t.has(o)){const a=n.get(o)??[];a.push(s),n.set(o,a)}else r.push(s)}const i=s=>{const a=[...n.get(s.sessionId)??[]].sort((l,c)=>l.createdAt<c.createdAt?-1:l.createdAt>c.createdAt?1:0);return{session:s,children:a.map(i)}};return[...r].sort(qH).map(i)}function qI(e){return[...e].sort((t,n)=>t.session.updatedAt<n.session.updatedAt?1:t.session.updatedAt>n.session.updatedAt?-1:0)}function qH(e,t){const n=typeof e.pinnedAt=="number",r=typeof t.pinnedAt=="number";if(n&&r){const i=typeof e.pinSortOrder=="number",s=typeof t.pinSortOrder=="number";return i&&s?e.pinSortOrder-t.pinSortOrder:i?-1:s?1:t.pinnedAt-e.pinnedAt}return n?-1:r||e.updatedAt<t.updatedAt?1:e.updatedAt>t.updatedAt?-1:0}function KH(e){return e.appBuilderProject?`[app] ${e.appBuilderProject}`:e.label?e.label:e.cwd.split("/").filter(Boolean).pop()??""}function Zw(e,t){const n=t.trim().toLowerCase();return n===""?!0:e.toLowerCase().includes(n)}function KI(e){return e.compositionActive||!!e.nativeIsComposing||e.keyCode===229}function GI(e){return e.key==="Enter"&&!e.shiftKey&&!KI(e)}function GH(e,t){const n=g.useRef(!1),r=g.useCallback(()=>{n.current=!0},[]),i=g.useCallback(()=>{setTimeout(()=>{n.current=!1},0)},[]);return{onKeyDown:g.useCallback(o=>{const a=o.nativeEvent;if(GI({key:o.key,shiftKey:o.shiftKey,compositionActive:n.current,nativeIsComposing:a.isComposing,keyCode:a.keyCode})){o.preventDefault(),e();return}t&&o.key==="Escape"&&(o.preventDefault(),t())},[e,t]),onCompositionStart:r,onCompositionEnd:i}}const XH={isCollapsed:()=>!1,toggle:()=>{},prune:()=>{}};function YH({personas:e,activePersonaId:t,onSelectPersona:n,onCreateSession:r,sessions:i,activeSessionId:s,awaitingIds:o,runningIds:a,unreadIds:l,onSelectSession:c,onDeleteSession:u,ownerPrincipalId:d,creatorDisplayNameByOwnerId:f,isPersonaExpanded:p,onTogglePersonaExpanded:m,onEditSession:v,onPinSession:b,showCopyResume:x,treatSessionsAsRoots:_,searchQuery:y}){const[w,S]=g.useState(null),[C,N]=g.useState(()=>new Set),T=p??(R=>C.has(R)),M=g.useCallback(R=>{if(m){m(R);return}N(I=>{const O=new Set(I);return O.has(R)?O.delete(R):O.add(R),O})},[m]),P=g.useMemo(()=>i==null?void 0:i.filter(R=>!R.ephemeral),[i]);if(e.length===0)return h.jsx(ZH,{});const D=(y??"").trim();return D?h.jsx(C_.Provider,{value:XH,children:h.jsx("div",{"data-testid":"my-personas-list",className:"flex flex-col gap-0.5",children:e.map(R=>{const I=P?P.filter(F=>F.ownerPersonaId===R.personaId).sort((F,L)=>L.updatedAt>F.updatedAt?1:-1):[],O=Zw(R.label,D),z=I.filter(F=>Zw(KH(F),D));if(!O&&z.length===0)return null;const $=O?I:z;return h.jsx(Qw,{persona:R,active:R.personaId===t,editing:!1,onSelectPersona:n,onSubmitCreateSession:()=>{},onCancelCreateSession:()=>{},personaSessions:$,collapsed:!1,onToggleCollapsed:()=>{},activeSessionId:s??null,awaitingIds:o,runningIds:a,unreadIds:l,onSelectSession:c,onDeleteSession:u,onEditSession:v,onPinSession:b,showCopyResume:x,treatSessionsAsRoots:_,ownerPrincipalId:d,creatorDisplayNameByOwnerId:f},R.personaId)})})}):h.jsx("div",{"data-testid":"my-personas-list",className:"flex flex-col gap-0.5",children:e.map(R=>{const I=P?P.filter(O=>O.ownerPersonaId===R.personaId).sort((O,z)=>z.updatedAt>O.updatedAt?1:-1):[];return h.jsx(Qw,{persona:R,active:R.personaId===t,editing:R.personaId===w,onSelectPersona:n,onStartCreateSession:r?()=>S(R.personaId):void 0,onSubmitCreateSession:O=>{S(null),r==null||r(R.personaId,O)},onCancelCreateSession:()=>S(null),personaSessions:I,collapsed:!T(R.personaId),onToggleCollapsed:()=>M(R.personaId),activeSessionId:s??null,awaitingIds:o,runningIds:a,unreadIds:l,onSelectSession:c,onDeleteSession:u,onEditSession:v,onPinSession:b,showCopyResume:x,treatSessionsAsRoots:_,ownerPrincipalId:d,creatorDisplayNameByOwnerId:f},R.personaId)})})}function ZH(){return h.jsx("div",{className:"px-3 py-3 text-[11px] leading-relaxed text-text-400",children:"还没有 persona。点上方 Personas 标题右侧 + 创建第一个。"})}function Qw({persona:e,active:t,editing:n,onSelectPersona:r,onStartCreateSession:i,onSubmitCreateSession:s,onCancelCreateSession:o,personaSessions:a,collapsed:l,onToggleCollapsed:c,activeSessionId:u,awaitingIds:d,runningIds:f,unreadIds:p,onSelectSession:m,onDeleteSession:v,onEditSession:b,onPinSession:x,showCopyResume:_,treatSessionsAsRoots:y,ownerPrincipalId:w,creatorDisplayNameByOwnerId:S}){const C=ZT(e.iconKey,e.tool),N=a.length>0,T=!l,M=g.useMemo(()=>{const R=[],I=new Map;for(const O of a){const z=O.creatorPrincipalId;if(O.larkChatId!=null||!z||w&&z===w){R.push(O);continue}const $=z,F=(S==null?void 0:S.get($))??`…${$.slice(-8)}`,L=I.get($);L?L.sessions.push(O):I.set($,{groupKey:$,displayName:F,sessions:[O]})}return{self:R,byPeer:[...I.values()]}},[a,w,S]),P=M.byPeer.length>0,D=g.useMemo(()=>T&&!P?qI(VI(a)):[],[T,P,a]);return h.jsxs("div",{"data-testid":`persona-node-${e.personaId}`,children:[h.jsxs("div",{className:ne("group flex items-center gap-1 px-2 py-1.5 cursor-pointer",t?"bg-accent-dim text-text-100":"hover:bg-bg-200 text-text-200"),onClick:()=>r==null?void 0:r(e.personaId),role:"button",tabIndex:0,children:[N?h.jsx("button",{type:"button",onClick:R=>{R.stopPropagation(),c()},"aria-label":T?"collapse":"expand","aria-expanded":T,"data-testid":`persona-chevron-${e.personaId}`,className:"flex h-4 w-4 shrink-0 items-center justify-center text-text-400 hover:text-text-100",children:T?h.jsx(ci,{className:"h-3 w-3"}):h.jsx(ui,{className:"h-3 w-3"})}):h.jsx("span",{className:"h-4 w-4 shrink-0","aria-hidden":"true"}),h.jsx(C.Component,{className:ne("h-3.5 w-3.5 shrink-0",C.colorClass),"aria-hidden":"true"}),h.jsx("span",{className:"flex-1 truncate text-[13px]",children:e.label}),N?h.jsx("span",{className:"shrink-0 text-[10px] text-text-400 tabular-nums","aria-label":`${a.length} sessions`,children:a.length}):null,i?h.jsx("button",{type:"button",onClick:R=>{R.stopPropagation(),i()},"aria-label":"新建会话",title:"新建会话","data-testid":`persona-create-session-${e.personaId}`,className:"flex h-5 w-5 shrink-0 items-center justify-center rounded text-text-400 opacity-0 hover:bg-text-100/10 hover:text-text-100 focus-visible:opacity-100 group-hover:opacity-100",children:h.jsx(Kz,{className:"h-3.5 w-3.5"})}):null]}),n?h.jsx(QH,{personaId:e.personaId,iconKey:e.iconKey,tool:e.tool,onSubmit:s,onCancel:o}):null,N&&T?h.jsx("div",{"data-testid":`persona-sessions-${e.personaId}`,children:P?h.jsxs(h.Fragment,{children:[M.self.length>0&&h.jsx(Jw,{groupKey:`${e.personaId}-self`,label:"我自己",testId:`persona-sessions-${e.personaId}-self`,sessions:M.self,activeSessionId:u,awaitingIds:d,runningIds:f,unreadIds:p,onSelectSession:m,onDeleteSession:v,onEditSession:b,onPinSession:x,showCopyResume:_}),M.byPeer.map(R=>h.jsx(Jw,{groupKey:`${e.personaId}-peer-${R.groupKey}`,label:R.displayName,testId:`persona-sessions-${e.personaId}-peer-${R.groupKey}`,sessions:R.sessions,activeSessionId:u,awaitingIds:d,runningIds:f,unreadIds:p,onSelectSession:m,onDeleteSession:v,onEditSession:b,onPinSession:x,showCopyResume:_},`${e.personaId}-peer-${R.groupKey}`))]}):D.map(R=>h.jsx(ty,{node:R,depth:y?0:1,activeId:u,unreadIds:p,runningIds:f,awaitingIds:d,onSelect:I=>m==null?void 0:m(I),onDelete:v,onEdit:b,onPin:x,showCopyResume:_},R.session.sessionId))}):null]})}function Jw({label:e,testId:t,sessions:n,activeSessionId:r,awaitingIds:i,runningIds:s,unreadIds:o,onSelectSession:a,onDeleteSession:l,onEditSession:c,onPinSession:u,showCopyResume:d}){const[f,p]=g.useState(!1),m=!f,v=g.useMemo(()=>m?qI(VI(n)):[],[m,n]);return h.jsxs("div",{"data-testid":t,children:[h.jsxs("button",{type:"button",onClick:()=>p(b=>!b),"aria-label":m?"collapse":"expand","aria-expanded":m,"data-testid":`${t}-chevron`,className:"flex items-center gap-1 w-full pl-7 pr-2 py-0.5 text-[11px] text-text-400 hover:text-text-200 transition-colors",children:[m?h.jsx(ci,{className:"h-3 w-3"}):h.jsx(ui,{className:"h-3 w-3"}),h.jsx(T_,{className:"h-3 w-3","aria-hidden":!0}),h.jsx("span",{className:"truncate",children:e}),h.jsx("span",{className:"ml-auto tabular-nums",children:n.length})]}),m&&h.jsx("div",{children:v.map(b=>h.jsx(ty,{node:b,depth:2,activeId:r,unreadIds:o,runningIds:s,awaitingIds:i,onSelect:x=>a==null?void 0:a(x),onDelete:l,onEdit:c,onPin:u,showCopyResume:d},b.session.sessionId))})]})}function QH({personaId:e,iconKey:t,tool:n,onSubmit:r,onCancel:i}){const[s,o]=g.useState(""),a=g.useRef(null),l=ZT(t,n),c=s.trim(),u=c.length>0;g.useEffect(()=>{var p;(p=a.current)==null||p.focus()},[]);const d=g.useCallback(()=>{u&&r(c)},[u,c,r]),f=GH(d,i);return h.jsxs("div",{className:"flex items-center gap-1.5 pl-9 pr-2 py-1","data-testid":`persona-new-session-row-${e}`,children:[h.jsx(l.Component,{className:ne("h-3 w-3 shrink-0",l.colorClass),"aria-hidden":"true"}),h.jsx("input",{ref:a,type:"text",value:s,onChange:p=>o(p.target.value),...f,onBlur:i,placeholder:"session label...","data-testid":`persona-new-session-input-${e}`,className:"flex-1 min-w-0 bg-bg-100 border border-text-100/15 rounded px-1.5 py-0.5 text-[12px] text-text-100 placeholder:text-text-400 focus:outline-none focus:border-text-100/40"}),h.jsx("button",{type:"button",onMouseDown:p=>{p.preventDefault(),d()},disabled:!u,"aria-label":"确认",title:"确认(Enter)","data-testid":`persona-new-session-confirm-${e}`,className:"flex h-4 w-4 shrink-0 items-center justify-center rounded text-text-300 hover:bg-text-100/10 hover:text-text-100 disabled:opacity-30 disabled:hover:bg-transparent disabled:hover:text-text-300",children:h.jsx(ol,{className:"h-3 w-3"})}),h.jsx("button",{type:"button",onMouseDown:p=>{p.preventDefault(),i()},"aria-label":"取消",title:"取消(Esc)","data-testid":`persona-new-session-cancel-${e}`,className:"flex h-4 w-4 shrink-0 items-center justify-center rounded text-text-300 hover:bg-text-100/10 hover:text-text-100",children:h.jsx(Rn,{className:"h-3 w-3"})})]})}function JH(e,t){const n=getComputedStyle(e),r=parseFloat(n.fontSize);return t*r}function eU(e,t){const n=getComputedStyle(e.ownerDocument.documentElement),r=parseFloat(n.fontSize);return t*r}function tU(e){return e/100*window.innerHeight}function nU(e){return e/100*window.innerWidth}function rU(e){switch(typeof e){case"number":return[e,"px"];case"string":{const t=parseFloat(e);return e.endsWith("%")?[t,"%"]:e.endsWith("px")?[t,"px"]:e.endsWith("rem")?[t,"rem"]:e.endsWith("em")?[t,"em"]:e.endsWith("vh")?[t,"vh"]:e.endsWith("vw")?[t,"vw"]:[t,"%"]}}}function ql({groupSize:e,panelElement:t,styleProp:n}){let r;const[i,s]=rU(n);switch(s){case"%":{r=i/100*e;break}case"px":{r=i;break}case"rem":{r=eU(t,i);break}case"em":{r=JH(t,i);break}case"vh":{r=tU(i);break}case"vw":{r=nU(i);break}}return r}function En(e){return parseFloat(e.toFixed(3))}function Ha({group:e}){const{orientation:t,panels:n}=e;return n.reduce((r,i)=>(r+=t==="horizontal"?i.element.offsetWidth:i.element.offsetHeight,r),0)}function u0(e){const{panels:t}=e,n=Ha({group:e});return n===0?t.map(r=>({groupResizeBehavior:r.panelConstraints.groupResizeBehavior,collapsedSize:0,collapsible:r.panelConstraints.collapsible===!0,defaultSize:void 0,disabled:r.panelConstraints.disabled,minSize:0,maxSize:100,panelId:r.id})):t.map(r=>{const{element:i,panelConstraints:s}=r;let o=0;if(s.collapsedSize!==void 0){const u=ql({groupSize:n,panelElement:i,styleProp:s.collapsedSize});o=En(u/n*100)}let a;if(s.defaultSize!==void 0){const u=ql({groupSize:n,panelElement:i,styleProp:s.defaultSize});a=En(u/n*100)}let l=0;if(s.minSize!==void 0){const u=ql({groupSize:n,panelElement:i,styleProp:s.minSize});l=En(u/n*100)}let c=100;if(s.maxSize!==void 0){const u=ql({groupSize:n,panelElement:i,styleProp:s.maxSize});c=En(u/n*100)}return{groupResizeBehavior:s.groupResizeBehavior,collapsedSize:o,collapsible:s.collapsible===!0,defaultSize:a,disabled:s.disabled,minSize:l,maxSize:c,panelId:r.id}})}function it(e,t="Assertion error"){if(!e)throw Error(t)}function d0(e,t){return Array.from(t).sort(e==="horizontal"?iU:sU)}function iU(e,t){const n=e.element.offsetLeft-t.element.offsetLeft;return n!==0?n:e.element.offsetWidth-t.element.offsetWidth}function sU(e,t){const n=e.element.offsetTop-t.element.offsetTop;return n!==0?n:e.element.offsetHeight-t.element.offsetHeight}function XI(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&e.nodeType===Node.ELEMENT_NODE}function YI(e,t){return{x:e.x>=t.left&&e.x<=t.right?0:Math.min(Math.abs(e.x-t.left),Math.abs(e.x-t.right)),y:e.y>=t.top&&e.y<=t.bottom?0:Math.min(Math.abs(e.y-t.top),Math.abs(e.y-t.bottom))}}function oU({orientation:e,rects:t,targetRect:n}){const r={x:n.x+n.width/2,y:n.y+n.height/2};let i,s=Number.MAX_VALUE;for(const o of t){const{x:a,y:l}=YI(r,o),c=e==="horizontal"?a:l;c<s&&(s=c,i=o)}return it(i,"No rect found"),i}let gd;function aU(){return gd===void 0&&(typeof matchMedia=="function"?gd=!!matchMedia("(pointer:coarse)").matches:gd=!1),gd}function ZI(e){const{element:t,orientation:n,panels:r,separators:i}=e,s=d0(n,Array.from(t.children).filter(XI).map(m=>({element:m}))).map(({element:m})=>m),o=[];let a=!1,l=!1,c=-1,u=-1,d=0,f,p=[];{let m=-1;for(const v of s)v.hasAttribute("data-panel")&&(m++,v.hasAttribute("data-disabled")||(d++,c===-1&&(c=m),u=m))}if(d>1){let m=-1;for(const v of s)if(v.hasAttribute("data-panel")){m++;const b=r.find(x=>x.element===v);if(b){if(f){const x=f.element.getBoundingClientRect(),_=v.getBoundingClientRect();let y;if(l){const w=n==="horizontal"?new DOMRect(x.right,x.top,0,x.height):new DOMRect(x.left,x.bottom,x.width,0),S=n==="horizontal"?new DOMRect(_.left,_.top,0,_.height):new DOMRect(_.left,_.top,_.width,0);switch(p.length){case 0:{y=[w,S];break}case 1:{const C=p[0],N=oU({orientation:n,rects:[x,_],targetRect:C.element.getBoundingClientRect()});y=[C,N===x?S:w];break}default:{y=p;break}}}else p.length?y=p:y=[n==="horizontal"?new DOMRect(x.right,_.top,_.left-x.right,_.height):new DOMRect(_.left,x.bottom,_.width,_.top-x.bottom)];for(const w of y){let S="width"in w?w:w.element.getBoundingClientRect();const C=aU()?e.resizeTargetMinimumSize.coarse:e.resizeTargetMinimumSize.fine;if(S.width<C){const T=C-S.width;S=new DOMRect(S.x-T/2,S.y,S.width+T,S.height)}if(S.height<C){const T=C-S.height;S=new DOMRect(S.x,S.y-T/2,S.width,S.height+T)}const N=m<=c||m>u;!a&&!N&&o.push({group:e,groupSize:Ha({group:e}),panels:[f,b],separator:"width"in w?void 0:w,rect:S}),a=!1}}l=!1,f=b,p=[]}}else if(v.hasAttribute("data-separator")){v.ariaDisabled!==null&&(a=!0);const b=i.find(x=>x.element===v);b?p.push(b):(f=void 0,p=[])}else l=!0}return o}var us;class QI{constructor(){o1(this,us,{})}addListener(t,n){const r=_l(this,us)[t];return r===void 0?_l(this,us)[t]=[n]:r.includes(n)||r.push(n),()=>{this.removeListener(t,n)}}emit(t,n){const r=_l(this,us)[t];if(r!==void 0)if(r.length===1)r[0].call(null,n);else{let i=!1,s=null;const o=Array.from(r);for(let a=0;a<o.length;a++){const l=o[a];try{l.call(null,n)}catch(c){s===null&&(i=!0,s=c)}}if(i)throw s}}removeAllListeners(){a1(this,us,{})}removeListener(t,n){const r=_l(this,us)[t];if(r!==void 0){const i=r.indexOf(n);i>=0&&r.splice(i,1)}}}us=new WeakMap;let Ca={cursorFlags:0,state:"inactive"};const ny=new QI;function _o(){return Ca}function lU(e){return ny.addListener("change",e)}function cU(e){const t=Ca,n={...Ca};n.cursorFlags=e,Ca=n,ny.emit("change",{prev:t,next:n})}function Ea(e){const t=Ca;Ca=e,ny.emit("change",{prev:t,next:e})}const uU=e=>e,Im=()=>{},JI=1,eR=2,tR=4,nR=8,eS=3,tS=12;let vd;function nS(){return vd===void 0&&(vd=!1,typeof window<"u"&&(window.navigator.userAgent.includes("Chrome")||window.navigator.userAgent.includes("Firefox"))&&(vd=!0)),vd}function dU({cursorFlags:e,groups:t,state:n}){let r=0,i=0;switch(n){case"active":case"hover":t.forEach(s=>{if(!s.mutableState.disableCursor)switch(s.orientation){case"horizontal":{r++;break}case"vertical":{i++;break}}})}if(!(r===0&&i===0)){switch(n){case"active":{if(e&&nS()){const s=(e&JI)!==0,o=(e&eR)!==0,a=(e&tR)!==0,l=(e&nR)!==0;if(s)return a?"se-resize":l?"ne-resize":"e-resize";if(o)return a?"sw-resize":l?"nw-resize":"w-resize";if(a)return"s-resize";if(l)return"n-resize"}break}}return nS()?r>0&&i>0?"move":r>0?"ew-resize":"ns-resize":r>0&&i>0?"grab":r>0?"col-resize":"row-resize"}}const rS=new WeakMap;function ry(e){if(e.defaultView===null||e.defaultView===void 0)return;let{prevStyle:t,styleSheet:n}=rS.get(e)??{};n===void 0&&(n=new e.defaultView.CSSStyleSheet,e.adoptedStyleSheets&&(Object.isExtensible(e.adoptedStyleSheets)?e.adoptedStyleSheets.push(n):e.adoptedStyleSheets=[...e.adoptedStyleSheets,n]));const r=_o();switch(r.state){case"active":case"hover":{const i=dU({cursorFlags:r.cursorFlags,groups:r.hitRegions.map(o=>o.group),state:r.state}),s=`*, *:hover {cursor: ${i} !important; }`;if(t===s)return;t=s,i?n.cssRules.length===0?n.insertRule(s):n.replaceSync(s):n.cssRules.length===1&&n.deleteRule(0);break}case"inactive":{t=void 0,n.cssRules.length===1&&n.deleteRule(0);break}}rS.set(e,{prevStyle:t,styleSheet:n})}let Zr=new Map;const rR=new QI;function hU(e){Zr=new Map(Zr),Zr.delete(e)}function iS(e,t){for(const[n]of Zr)if(n.id===e)return n}function ks(e,t){for(const[n,r]of Zr)if(n.id===e)return r;if(t)throw Error(`Could not find data for Group with id ${e}`)}function jo(){return Zr}function iy(e,t){return rR.addListener("groupChange",n=>{n.group.id===e&&t(n)})}function Oi(e,t,n){const r=Zr.get(e);Zr=new Map(Zr),Zr.set(e,t),rR.emit("groupChange",{group:e,isUserInteraction:(n==null?void 0:n.isUserInteraction)===!0,prev:r,next:t})}function iR(e){const t=_o();let n=!1;switch(t.state){case"active":Ea({cursorFlags:0,state:"inactive"}),t.hitRegions.length>0&&(ry(e),n=!0,t.hitRegions.forEach(r=>{const i=ks(r.group.id,!0);Oi(r.group,i,{isUserInteraction:!0})}))}return n}function sS(e){e.defaultPrevented||iR(e.currentTarget)}function fU(e,t,n){let r,i={x:1/0,y:1/0};for(const s of t){const o=YI(n,s.rect);switch(e){case"horizontal":{o.x<=i.x&&(r=s,i=o);break}case"vertical":{o.y<=i.y&&(r=s,i=o);break}}}return r?{distance:i,hitRegion:r}:void 0}function pU(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function mU(e,t){if(e===t)throw new Error("Cannot compare node with itself");const n={a:lS(e),b:lS(t)};let r;for(;n.a.at(-1)===n.b.at(-1);)r=n.a.pop(),n.b.pop();it(r,"Stacking order can only be calculated for elements with a common ancestor");const i={a:aS(oS(n.a)),b:aS(oS(n.b))};if(i.a===i.b){const s=r.childNodes,o={a:n.a.at(-1),b:n.b.at(-1)};let a=s.length;for(;a--;){const l=s[a];if(l===o.a)return 1;if(l===o.b)return-1}}return Math.sign(i.a-i.b)}const gU=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function vU(e){const t=getComputedStyle(sR(e)??e).display;return t==="flex"||t==="inline-flex"}function xU(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||vU(e))||+t.opacity<1||"transform"in t&&t.transform!=="none"||"webkitTransform"in t&&t.webkitTransform!=="none"||"mixBlendMode"in t&&t.mixBlendMode!=="normal"||"filter"in t&&t.filter!=="none"||"webkitFilter"in t&&t.webkitFilter!=="none"||"isolation"in t&&t.isolation==="isolate"||gU.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function oS(e){let t=e.length;for(;t--;){const n=e[t];if(it(n,"Missing node"),xU(n))return n}return null}function aS(e){return e&&Number(getComputedStyle(e).zIndex)||0}function lS(e){const t=[];for(;e;)t.push(e),e=sR(e);return t}function sR(e){const{parentNode:t}=e;return pU(t)?t.host:t}function _U(e,t){return e.x<t.x+t.width&&e.x+e.width>t.x&&e.y<t.y+t.height&&e.y+e.height>t.y}function yU({groupElement:e,hitRegion:t,pointerEventTarget:n}){if(!XI(n)||n.contains(e)||e.contains(n))return!0;if(mU(n,e)>0){let r=n;for(;r;){if(r.contains(e))return!0;if(_U(r.getBoundingClientRect(),t))return!1;r=r.parentElement}}return!0}function sy(e,t){const n=[];return t.forEach((r,i)=>{if(i.disabled)return;const s=ZI(i),o=fU(i.orientation,s,{x:e.clientX,y:e.clientY});o&&o.distance.x<=0&&o.distance.y<=0&&yU({groupElement:i.element,hitRegion:o.hitRegion.rect,pointerEventTarget:e.target})&&n.push(o.hitRegion)}),n}function bU(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n])return!1;return!0}function xn(e,t,n=0){return Math.abs(En(e)-En(t))<=n}function Kr(e,t){return xn(e,t)?0:e>t?1:-1}function pa({overrideDisabledPanels:e,panelConstraints:t,prevSize:n,size:r}){const{collapsedSize:i=0,collapsible:s,disabled:o,maxSize:a=100,minSize:l=0}=t;if(o&&!e)return n;if(Kr(r,l)<0)if(s){const c=(i+l)/2;Kr(r,c)<0?r=i:r=l}else r=l;return r=Math.min(a,r),r=En(r),r}function Xc({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:i,trigger:s}){if(xn(e,0))return t;const o=s==="imperative-api",a=Object.values(t),l=Object.values(i),c=[...a],[u,d]=r;it(u!=null,"Invalid first pivot index"),it(d!=null,"Invalid second pivot index");let f=0;switch(s){case"keyboard":{{const v=e<0?d:u,b=n[v];it(b,`Panel constraints not found for index ${v}`);const{collapsedSize:x=0,collapsible:_,minSize:y=0}=b;if(_){const w=a[v];if(it(w!=null,`Previous layout not found for panel index ${v}`),xn(w,x)){const S=y-w;Kr(S,Math.abs(e))>0&&(e=e<0?0-S:S)}}}{const v=e<0?u:d,b=n[v];it(b,`No panel constraints found for index ${v}`);const{collapsedSize:x=0,collapsible:_,minSize:y=0}=b;if(_){const w=a[v];if(it(w!=null,`Previous layout not found for panel index ${v}`),xn(w,y)){const S=w-x;Kr(S,Math.abs(e))>0&&(e=e<0?0-S:S)}}}break}default:{const v=e<0?d:u,b=n[v];it(b,`Panel constraints not found for index ${v}`);const x=a[v],{collapsible:_,collapsedSize:y,minSize:w}=b;if(_&&Kr(x,w)<0)if(e>0){const S=w-y,C=S/2,N=x+e;Kr(N,w)<0&&(e=Kr(e,C)<=0?0:S)}else{const S=w-y,C=100-S/2,N=x-e;Kr(N,w)<0&&(e=Kr(100+e,C)>0?0:-S)}break}}{const v=e<0?1:-1;let b=e<0?d:u,x=0;for(;;){const y=a[b];it(y!=null,`Previous layout not found for panel index ${b}`);const w=pa({overrideDisabledPanels:o,panelConstraints:n[b],prevSize:y,size:100})-y;if(x+=w,b+=v,b<0||b>=n.length)break}const _=Math.min(Math.abs(e),Math.abs(x));e=e<0?0-_:_}{let v=e<0?u:d;for(;v>=0&&v<n.length;){const b=Math.abs(e)-Math.abs(f),x=a[v];it(x!=null,`Previous layout not found for panel index ${v}`);const _=x-b,y=pa({overrideDisabledPanels:o,panelConstraints:n[v],prevSize:x,size:_});if(!xn(x,y)&&(f+=x-y,c[v]=y,f.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?v--:v++}}if(bU(l,c))return i;{const v=e<0?d:u,b=a[v];it(b!=null,`Previous layout not found for panel index ${v}`);const x=b+f,_=pa({overrideDisabledPanels:o,panelConstraints:n[v],prevSize:b,size:x});if(c[v]=_,!xn(_,x)){let y=x-_,w=e<0?d:u;for(;w>=0&&w<n.length;){const S=c[w];it(S!=null,`Previous layout not found for panel index ${w}`);const C=S+y,N=pa({overrideDisabledPanels:o,panelConstraints:n[w],prevSize:S,size:C});if(xn(S,N)||(y-=N-S,c[w]=N),xn(y,0))break;e>0?w--:w++}}}const p=Object.values(c).reduce((v,b)=>b+v,0);if(!xn(p,100,.1))return i;const m=Object.keys(i);return c.reduce((v,b,x)=>(v[m[x]]=b,v),{})}function yo(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(t[n]===void 0||Kr(e[n],t[n])!==0)return!1;return!0}function bo({layout:e,panelConstraints:t}){const n=Object.values(e),r=[...n],i=r.reduce((a,l)=>a+l,0);if(r.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${r.map(a=>`${a}%`).join(", ")}`);if(!xn(i,100)&&r.length>0)for(let a=0;a<t.length;a++){const l=r[a];it(l!=null,`No layout data found for index ${a}`);const c=100/i*l;r[a]=c}let s=0;for(let a=0;a<t.length;a++){const l=n[a];it(l!=null,`No layout data found for index ${a}`);const c=r[a];it(c!=null,`No layout data found for index ${a}`);const u=pa({overrideDisabledPanels:!0,panelConstraints:t[a],prevSize:l,size:c});c!=u&&(s+=c-u,r[a]=u)}if(!xn(s,0))for(let a=0;a<t.length;a++){const l=r[a];it(l!=null,`No layout data found for index ${a}`);const c=l+s,u=pa({overrideDisabledPanels:!0,panelConstraints:t[a],prevSize:l,size:c});if(l!==u&&(s-=u-l,r[a]=u,xn(s,0)))break}const o=Object.keys(e);return r.reduce((a,l,c)=>(a[o[c]]=l,a),{})}function oR({groupId:e,panelId:t}){const n=()=>{const l=jo();for(const[c,{defaultLayoutDeferred:u,derivedPanelConstraints:d,layout:f,groupSize:p,separatorToPanels:m}]of l)if(c.id===e)return{defaultLayoutDeferred:u,derivedPanelConstraints:d,group:c,groupSize:p,layout:f,separatorToPanels:m};throw Error(`Group ${e} not found`)},r=()=>{const l=n().derivedPanelConstraints.find(c=>c.panelId===t);if(l!==void 0)return l;throw Error(`Panel constraints not found for Panel ${t}`)},i=()=>{const l=n().group.panels.find(c=>c.id===t);if(l!==void 0)return l;throw Error(`Layout not found for Panel ${t}`)},s=()=>{const l=n().layout[t];if(l!==void 0)return l;throw Error(`Layout not found for Panel ${t}`)},o=({nextSize:l,panels:c,prevLayout:u,derivedPanelConstraints:d})=>{const f=s(),p=c.findIndex(b=>b.id===t),m=p===0,v=p===c.length-1;if(v&&l<f&&(m||c.slice(0,p).every((b,x)=>{const _=d[x];return(_==null?void 0:_.collapsible)&&xn(_.collapsedSize,u[_.panelId])}))){const b=c.slice(0,p).reduce((x,_)=>x+u[_.id],0);return{...u,[t]:En(100-b)}}return Xc({delta:v?f-l:l-f,initialLayout:u,panelConstraints:d,pivotIndices:v?[p-1,p]:[p,p+1],prevLayout:u,trigger:"imperative-api"})},a=l=>{const c=s();if(l===c)return;const{defaultLayoutDeferred:u,derivedPanelConstraints:d,group:f,groupSize:p,layout:m,separatorToPanels:v}=n(),b=o({nextSize:l,panels:f.panels,prevLayout:m,derivedPanelConstraints:d}),x=bo({layout:b,panelConstraints:d});yo(m,x)||Oi(f,{defaultLayoutDeferred:u,derivedPanelConstraints:d,groupSize:p,layout:x,separatorToPanels:v})};return{collapse:()=>{const{collapsible:l,collapsedSize:c}=r(),{mutableValues:u}=i(),d=s();l&&d!==c&&(u.expandToSize=d,a(c))},expand:()=>{const{collapsible:l,collapsedSize:c,minSize:u}=r(),{mutableValues:d}=i(),f=s();if(l&&f===c){let p=d.expandToSize??u;p===0&&(p=1),a(p)}},getSize:()=>{const{group:l}=n(),c=s(),{element:u}=i(),d=l.orientation==="horizontal"?u.offsetWidth:u.offsetHeight;return{asPercentage:c,inPixels:d}},isCollapsed:()=>{const{collapsible:l,collapsedSize:c}=r(),u=s();return l&&xn(c,u)},resize:l=>{const{group:c}=n(),{element:u}=i(),d=Ha({group:c}),f=ql({groupSize:d,panelElement:u,styleProp:l}),p=En(f/d*100);a(p)}}}function cS(e){if(e.defaultPrevented)return;const t=jo();sy(e,t).forEach(n=>{if(n.separator&&!n.separator.disableDoubleClick){const r=n.panels.find(i=>i.panelConstraints.defaultSize!==void 0);if(r){const i=r.panelConstraints.defaultSize,s=oR({groupId:n.group.id,panelId:r.id});s&&i!==void 0&&(s.resize(i),e.preventDefault())}}})}function Qd(e){const t=jo();for(const[n]of t)if(n.separators.some(r=>r.element===e))return n;throw Error("Could not find parent Group for separator element")}function aR({groupId:e}){const t=()=>{const n=jo();for(const[r,i]of n)if(r.id===e)return{group:r,...i};throw Error(`Could not find Group with id "${e}"`)};return{getLayout(){const{defaultLayoutDeferred:n,layout:r}=t();return n?{}:r},setLayout(n){const{defaultLayoutDeferred:r,derivedPanelConstraints:i,group:s,groupSize:o,layout:a,separatorToPanels:l}=t(),c=bo({layout:n,panelConstraints:i});return r?a:(yo(a,c)||Oi(s,{defaultLayoutDeferred:r,derivedPanelConstraints:i,groupSize:o,layout:c,separatorToPanels:l}),c)}}}function Hs(e,t){const n=Qd(e),r=ks(n.id,!0),i=n.separators.find(u=>u.element===e);it(i,"Matching separator not found");const s=r.separatorToPanels.get(i);it(s,"Matching panels not found");const o=s.map(u=>n.panels.indexOf(u)),a=aR({groupId:n.id}).getLayout(),l=Xc({delta:t,initialLayout:a,panelConstraints:r.derivedPanelConstraints,pivotIndices:o,prevLayout:a,trigger:"keyboard"}),c=bo({layout:l,panelConstraints:r.derivedPanelConstraints});yo(a,c)||Oi(n,{defaultLayoutDeferred:r.defaultLayoutDeferred,derivedPanelConstraints:r.derivedPanelConstraints,groupSize:r.groupSize,layout:c,separatorToPanels:r.separatorToPanels},{isUserInteraction:!0})}function uS(e){if(e.defaultPrevented)return;const t=e.currentTarget,n=Qd(t);if(!n.disabled)switch(e.key){case"ArrowDown":{e.preventDefault(),n.orientation==="vertical"&&Hs(t,5);break}case"ArrowLeft":{e.preventDefault(),n.orientation==="horizontal"&&Hs(t,-5);break}case"ArrowRight":{e.preventDefault(),n.orientation==="horizontal"&&Hs(t,5);break}case"ArrowUp":{e.preventDefault(),n.orientation==="vertical"&&Hs(t,-5);break}case"End":{e.preventDefault(),Hs(t,100);break}case"Enter":{e.preventDefault();const r=Qd(t),i=ks(r.id,!0),{derivedPanelConstraints:s,layout:o,separatorToPanels:a}=i,l=r.separators.find(f=>f.element===t);it(l,"Matching separator not found");const c=a.get(l);it(c,"Matching panels not found");const u=c[0],d=s.find(f=>f.panelId===u.id);if(it(d,"Panel metadata not found"),d.collapsible){const f=o[u.id],p=d.collapsedSize===f?r.mutableState.expandedPanelSizes[u.id]??d.minSize:d.collapsedSize;Hs(t,p-f)}break}case"F6":{e.preventDefault();const r=Qd(t).separators.map(o=>o.element),i=Array.from(r).findIndex(o=>o===e.currentTarget);it(i!==null,"Index not found");const s=e.shiftKey?i>0?i-1:r.length-1:i+1<r.length?i+1:0;r[s].focus({preventScroll:!0});break}case"Home":{e.preventDefault(),Hs(t,-100);break}}}function dS(e){if(e.defaultPrevented||e.pointerType==="mouse"&&e.button>0)return;const t=jo(),n=sy(e,t),r=new Map;let i=!1;n.forEach(s=>{s.separator&&(i||(i=!0,s.separator.element.focus({focusVisible:!1,preventScroll:!0})));const o=t.get(s.group);o&&r.set(s.group,o.layout)}),Ea({cursorFlags:0,hitRegions:n,initialLayoutMap:r,pointerDownAtPoint:{x:e.clientX,y:e.clientY},state:"active"}),n.length&&e.preventDefault()}function lR({document:e,event:t,hitRegions:n,initialLayoutMap:r,mountedGroups:i,pointerDownAtPoint:s,prevCursorFlags:o}){let a=0;n.forEach(c=>{const{group:u,groupSize:d}=c,{orientation:f,panels:p}=u,{disableCursor:m}=u.mutableState;let v=0;s?f==="horizontal"?v=(t.clientX-s.x)/d*100:v=(t.clientY-s.y)/d*100:f==="horizontal"?v=t.clientX<0?-100:100:v=t.clientY<0?-100:100;const b=r.get(u),x=i.get(u);if(!b||!x)return;const{defaultLayoutDeferred:_,derivedPanelConstraints:y,groupSize:w,layout:S,separatorToPanels:C}=x;if(y&&S&&C){const N=Xc({delta:v,initialLayout:b,panelConstraints:y,pivotIndices:c.panels.map(T=>p.indexOf(T)),prevLayout:S,trigger:"mouse-or-touch"});if(yo(N,S)){if(v!==0&&!m)switch(f){case"horizontal":{a|=v<0?JI:eR;break}case"vertical":{a|=v<0?tR:nR;break}}}else Oi(c.group,{defaultLayoutDeferred:_,derivedPanelConstraints:y,groupSize:w,layout:N,separatorToPanels:C})}});let l=0;t.movementX===0?l|=o&eS:l|=a&eS,t.movementY===0?l|=o&tS:l|=a&tS,cU(l),ry(e)}function hS(e){const t=jo(),n=_o();switch(n.state){case"active":lR({document:e.currentTarget,event:e,hitRegions:n.hitRegions,initialLayoutMap:n.initialLayoutMap,mountedGroups:t,prevCursorFlags:n.cursorFlags})}}function fS(e){var r,i;if(e.defaultPrevented)return;const t=_o(),n=jo();switch(t.state){case"active":{if(e.buttons===0){Ea({cursorFlags:0,state:"inactive"}),t.hitRegions.forEach(s=>{const o=ks(s.group.id,!0);Oi(s.group,o,{isUserInteraction:!0})});return}for(const s of t.hitRegions)if(s.separator){const{element:o}=s.separator;(r=o.hasPointerCapture)!=null&&r.call(o,e.pointerId)||((i=o.setPointerCapture)==null||i.call(o,e.pointerId))}lR({document:e.currentTarget,event:e,hitRegions:t.hitRegions,initialLayoutMap:t.initialLayoutMap,mountedGroups:n,pointerDownAtPoint:t.pointerDownAtPoint,prevCursorFlags:t.cursorFlags});break}default:{const s=sy(e,n);s.length===0?t.state!=="inactive"&&Ea({cursorFlags:0,state:"inactive"}):Ea({cursorFlags:0,hitRegions:s,state:"hover"}),ry(e.currentTarget);break}}}function pS(e){if(e.relatedTarget instanceof HTMLIFrameElement)switch(_o().state){case"hover":Ea({cursorFlags:0,state:"inactive"})}}function mS(e){e.defaultPrevented||e.pointerType==="mouse"&&e.button>0||iR(e.currentTarget)&&e.preventDefault()}function gS(e){let t=0,n=0;const r={};for(const s of e)if(s.defaultSize!==void 0){t++;const o=En(s.defaultSize);n+=o,r[s.panelId]=o}else r[s.panelId]=void 0;const i=e.length-t;if(i!==0){const s=En((100-n)/i);for(const o of e)o.defaultSize===void 0&&(r[o.panelId]=s)}return r}function wU(e,t,n){if(!n[0])return;const r=e.panels.find(l=>l.element===t);if(!r||!r.onResize)return;const i=Ha({group:e}),s=e.orientation==="horizontal"?r.element.offsetWidth:r.element.offsetHeight,o=r.mutableValues.prevSize,a={asPercentage:En(s/i*100),inPixels:s};r.mutableValues.prevSize=a,r.onResize(a,r.id,o)}function SU(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(e[n]!==t[n])return!1;return!0}function kU({group:e,nextGroupSize:t,prevGroupSize:n,prevLayout:r}){if(n<=0||t<=0||n===t)return r;let i=0,s=0,o=!1;const a=new Map,l=[];for(const d of e.panels){const f=r[d.id]??0;switch(d.panelConstraints.groupResizeBehavior){case"preserve-pixel-size":{o=!0;const p=f/100*n,m=En(p/t*100);a.set(d.id,m),i+=m;break}case"preserve-relative-size":default:{l.push(d.id),s+=f;break}}}if(!o||l.length===0)return r;const c=100-i,u={...r};if(a.forEach((d,f)=>{u[f]=d}),s>0)for(const d of l){const f=r[d]??0;u[d]=En(f/s*c)}else{const d=En(c/l.length);for(const f of l)u[f]=d}return u}function CU(e,t){const n=e.map(i=>i.id),r=Object.keys(t);if(n.length!==r.length)return!1;for(const i of n)if(!r.includes(i))return!1;return!0}const Ko=new Map;function EU(e){let t=!0;it(e.element.ownerDocument.defaultView,"Cannot register an unmounted Group");const n=e.element.ownerDocument.defaultView.ResizeObserver,r=new Set,i=new Set,s=new n(m=>{for(const v of m){const{borderBoxSize:b,target:x}=v;if(x===e.element){if(t){const _=Ha({group:e});if(_===0)return;const y=ks(e.id);if(!y)return;const w=u0(e),S=y.defaultLayoutDeferred?gS(w):y.layout,C=kU({group:e,nextGroupSize:_,prevGroupSize:y.groupSize,prevLayout:S}),N=bo({layout:C,panelConstraints:w});if(!y.defaultLayoutDeferred&&yo(y.layout,N)&&SU(y.derivedPanelConstraints,w)&&y.groupSize===_)return;Oi(e,{defaultLayoutDeferred:!1,derivedPanelConstraints:w,groupSize:_,layout:N,separatorToPanels:y.separatorToPanels})}}else wU(e,x,b)}});s.observe(e.element),e.panels.forEach(m=>{it(!r.has(m.id),`Panel ids must be unique; id "${m.id}" was used more than once`),r.add(m.id),m.onResize&&s.observe(m.element)});const o=Ha({group:e}),a=u0(e),l=e.panels.map(({id:m})=>m).join(",");let c=e.mutableState.defaultLayout;c&&(CU(e.panels,c)||(c=void 0));const u=e.mutableState.layouts[l]??c??gS(a),d=bo({layout:u,panelConstraints:a}),f=e.element.ownerDocument;Ko.set(f,(Ko.get(f)??0)+1);const p=new Map;return ZI(e).forEach(m=>{m.separator&&p.set(m.separator,m.panels)}),Oi(e,{defaultLayoutDeferred:o===0,derivedPanelConstraints:a,groupSize:o,layout:d,separatorToPanels:p}),e.separators.forEach(m=>{it(!i.has(m.id),`Separator ids must be unique; id "${m.id}" was used more than once`),i.add(m.id),m.element.addEventListener("keydown",uS)}),Ko.get(f)===1&&(f.addEventListener("contextmenu",sS,!0),f.addEventListener("dblclick",cS,!0),f.addEventListener("pointerdown",dS,!0),f.addEventListener("pointerleave",hS),f.addEventListener("pointermove",fS),f.addEventListener("pointerout",pS),f.addEventListener("pointerup",mS,!0)),function(){t=!1,Ko.set(f,Math.max(0,(Ko.get(f)??0)-1)),hU(e),e.separators.forEach(m=>{m.element.removeEventListener("keydown",uS)}),Ko.get(f)||(f.removeEventListener("contextmenu",sS,!0),f.removeEventListener("dblclick",cS,!0),f.removeEventListener("pointerdown",dS,!0),f.removeEventListener("pointerleave",hS),f.removeEventListener("pointermove",fS),f.removeEventListener("pointerout",pS),f.removeEventListener("pointerup",mS,!0)),s.disconnect()}}function NU(){const[e,t]=g.useState({}),n=g.useCallback(()=>t({}),[]);return[e,n]}function oy(e){const t=g.useId();return`${e??t}`}const Lo=typeof window<"u"?g.useLayoutEffect:g.useEffect;function dc(e){const t=g.useRef(e);return Lo(()=>{t.current=e},[e]),g.useCallback((...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[t])}function ay(...e){return dc(t=>{e.forEach(n=>{if(n)switch(typeof n){case"function":{n(t);break}case"object":{n.current=t;break}}})})}function ly(e){const t=g.useRef({...e});return Lo(()=>{for(const n in e)t.current[n]=e[n]},[e]),t.current}const cR=g.createContext(null);function TU(e,t){const n=g.useRef({getLayout:()=>({}),setLayout:uU});g.useImperativeHandle(t,()=>n.current,[]),Lo(()=>{Object.assign(n.current,aR({groupId:e}))})}function cy({children:e,className:t,defaultLayout:n,disableCursor:r,disabled:i,elementRef:s,groupRef:o,id:a,onLayoutChange:l,onLayoutChanged:c,orientation:u="horizontal",resizeTargetMinimumSize:d={coarse:20,fine:10},style:f,...p}){const m=g.useRef({onLayoutChange:{},onLayoutChanged:{}}),v=dc(D=>{yo(m.current.onLayoutChange,D)||(m.current.onLayoutChange=D,l==null||l(D))}),b=dc((D,R)=>{yo(m.current.onLayoutChanged,D)||(m.current.onLayoutChanged=D,c==null||c(D,{isUserInteraction:R}))}),x=oy(a),_=g.useRef(null),[y,w]=NU(),S=g.useRef({lastExpandedPanelSizes:{},layouts:{},panels:[],resizeTargetMinimumSize:d,separators:[]}),C=ay(_,s);TU(x,o);const N=dc((D,R)=>{const I=_o(),O=iS(D),z=ks(D);if(z){let $=!1;switch(I.state){case"active":{$=I.hitRegions.some(F=>F.group===O);break}}return{flexGrow:z.layout[R]??1,pointerEvents:$?"none":void 0}}if(n!=null&&n[R])return{flexGrow:n==null?void 0:n[R]}}),T=ly({defaultLayout:n,disableCursor:r}),M=g.useMemo(()=>({get disableCursor(){return!!T.disableCursor},getPanelStyles:N,id:x,orientation:u,registerPanel:D=>{const R=S.current;return R.panels=d0(u,[...R.panels,D]),w(),()=>{R.panels=R.panels.filter(I=>I!==D),w()}},registerSeparator:D=>{const R=S.current;return R.separators=d0(u,[...R.separators,D]),w(),()=>{R.separators=R.separators.filter(I=>I!==D),w()}},updatePanelProps:(D,{disabled:R})=>{const I=S.current.panels.find($=>$.id===D);I&&(I.panelConstraints.disabled=R);const O=iS(x),z=ks(x);O&&z&&Oi(O,{...z,derivedPanelConstraints:u0(O)})},updateSeparatorProps:(D,{disabled:R,disableDoubleClick:I})=>{const O=S.current.separators.find(z=>z.id===D);O&&(O.disabled=R,O.disableDoubleClick=I)}}),[N,x,w,u,T]),P=g.useRef(null);return Lo(()=>{const D=_.current;if(D===null)return;const R=S.current;let I;if(T.defaultLayout!==void 0&&Object.keys(T.defaultLayout).length===R.panels.length){I={};for(const E of R.panels){const H=T.defaultLayout[E.id];H!==void 0&&(I[E.id]=H)}}const O={disabled:!!i,element:D,id:x,mutableState:{defaultLayout:I,disableCursor:!!T.disableCursor,expandedPanelSizes:S.current.lastExpandedPanelSizes,layouts:S.current.layouts},orientation:u,panels:R.panels,resizeTargetMinimumSize:R.resizeTargetMinimumSize,separators:R.separators};P.current=O;const z=EU(O),{defaultLayoutDeferred:$,derivedPanelConstraints:F,layout:L}=ks(O.id,!0);!$&&F.length>0&&(v(L),b(L,!1));const B=iy(x,E=>{const{defaultLayoutDeferred:H,derivedPanelConstraints:q,layout:A}=E.next;if(H||q.length===0)return;const re=O.panels.map(({id:V})=>V).join(",");O.mutableState.layouts[re]=A,q.forEach(V=>{if(V.collapsible){const{layout:pe}=E.prev??{};if(pe){const Oe=xn(V.collapsedSize,A[V.panelId]),ie=xn(V.collapsedSize,pe[V.panelId]);Oe&&!ie&&(O.mutableState.expandedPanelSizes[V.panelId]=pe[V.panelId])}}});const oe=_o().state!=="active";v(A),oe&&b(A,E.isUserInteraction)});return()=>{P.current=null,z(),B()}},[i,x,b,v,u,y,T]),g.useEffect(()=>{const D=P.current;D&&(D.mutableState.defaultLayout=n,D.mutableState.disableCursor=!!r)}),h.jsx(cR.Provider,{value:M,children:h.jsx("div",{...p,className:t,"data-group":!0,"data-testid":x,id:x,ref:C,style:{height:"100%",width:"100%",overflow:"hidden",...f,display:"flex",flexDirection:u==="horizontal"?"row":"column",flexWrap:"nowrap",touchAction:u==="horizontal"?"pan-y":"pan-x"},children:e})})}cy.displayName="Group";function uy(){const e=g.useContext(cR);return it(e,"Group Context not found; did you render a Panel or Separator outside of a Group?"),e}function PU(e,t){const{id:n}=uy(),r=g.useRef({collapse:Im,expand:Im,getSize:()=>({asPercentage:0,inPixels:0}),isCollapsed:()=>!1,resize:Im});g.useImperativeHandle(t,()=>r.current,[]),Lo(()=>{Object.assign(r.current,oR({groupId:n,panelId:e}))})}function Yc({children:e,className:t,collapsedSize:n="0%",collapsible:r=!1,defaultSize:i,disabled:s,elementRef:o,groupResizeBehavior:a="preserve-relative-size",id:l,maxSize:c="100%",minSize:u="0%",onResize:d,panelRef:f,style:p,...m}){const v=!!l,b=oy(l),x=ly({disabled:s}),_=g.useRef(null),y=ay(_,o),{getPanelStyles:w,id:S,orientation:C,registerPanel:N,updatePanelProps:T}=uy(),M=d!==null,P=dc((O,z,$)=>{d==null||d(O,l,$)});Lo(()=>{const O=_.current;if(O!==null){const z={element:O,id:b,idIsStable:v,mutableValues:{expandToSize:void 0,prevSize:void 0},onResize:M?P:void 0,panelConstraints:{groupResizeBehavior:a,collapsedSize:n,collapsible:r,defaultSize:i,disabled:x.disabled,maxSize:c,minSize:u}};return N(z)}},[a,n,r,i,M,b,v,c,u,P,N,x]),g.useEffect(()=>{T(b,{disabled:s})},[s,b,T]),PU(b,f);const D=()=>{const O=w(S,b);if(O)return JSON.stringify(O)},R=g.useSyncExternalStore(O=>iy(S,O),D,D);let I;return R?I=JSON.parse(R):i!==void 0?I={flexGrow:void 0,flexShrink:void 0,flexBasis:i}:I={flexGrow:1},h.jsx("div",{...m,"data-disabled":s||void 0,"data-panel":!0,"data-testid":b,id:b,ref:y,style:{...IU,display:"flex",flexBasis:0,flexShrink:1,overflow:"visible",...I},children:h.jsx("div",{className:t,style:{maxHeight:"100%",maxWidth:"100%",flexGrow:1,overflow:"auto",...p,touchAction:C==="horizontal"?"pan-y":"pan-x"},children:e})})}Yc.displayName="Panel";const IU={minHeight:0,maxHeight:"100%",height:"auto",minWidth:0,maxWidth:"100%",width:"auto",border:"none",borderWidth:0,padding:0,margin:0};function RU({layout:e,panelConstraints:t,panelId:n,panelIndex:r}){let i,s;const o=e[n],a=t.find(l=>l.panelId===n);if(a){const l=a.maxSize,c=a.collapsible?a.collapsedSize:a.minSize,u=[r,r+1];s=bo({layout:Xc({delta:c-o,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[n],i=bo({layout:Xc({delta:l-o,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[n]}return{valueControls:n,valueMax:i,valueMin:s,valueNow:o}}function dy({children:e,className:t,disabled:n,disableDoubleClick:r,elementRef:i,id:s,style:o,...a}){const l=oy(s),c=ly({disabled:n,disableDoubleClick:r}),[u,d]=g.useState({}),[f,p]=g.useState("inactive"),[m,v]=g.useState(!1),b=g.useRef(null),x=ay(b,i),{disableCursor:_,id:y,orientation:w,registerSeparator:S,updateSeparatorProps:C}=uy(),N=w==="horizontal"?"vertical":"horizontal";Lo(()=>{const P=b.current;if(P!==null){const D={disabled:c.disabled,disableDoubleClick:c.disableDoubleClick,element:P,id:l},R=S(D),I=lU(z=>{p(z.next.state!=="inactive"&&z.next.hitRegions.some($=>$.separator===D)?z.next.state:"inactive")}),O=iy(y,z=>{const{derivedPanelConstraints:$,layout:F,separatorToPanels:L}=z.next,B=L.get(D);if(B){const E=B[0],H=B.indexOf(E);d(RU({layout:F,panelConstraints:$,panelId:E.id,panelIndex:H}))}});return()=>{I(),O(),R()}}},[y,l,S,c]),g.useEffect(()=>{C(l,{disabled:n,disableDoubleClick:r})},[n,r,l,C]);let T;n&&!_&&(T="not-allowed");let M;if(n)M="disabled";else switch(f){case"active":{M="active";break}default:m?M="focus":M=f}return h.jsx("div",{...a,"aria-controls":u.valueControls,"aria-disabled":n||void 0,"aria-orientation":N,"aria-valuemax":u.valueMax,"aria-valuemin":u.valueMin,"aria-valuenow":u.valueNow,children:e,className:t,"data-separator":M,"data-testid":l,id:l,onBlur:()=>v(!1),onFocus:()=>v(!0),ref:x,role:"separator",style:{flexBasis:"auto",cursor:T,...o,flexGrow:0,flexShrink:0,touchAction:"none"},tabIndex:n?void 0:0})}dy.displayName="Separator";function MU(e,t,n,r=!0){const i=g.useRef({sid:null,tsid:void 0});g.useEffect(()=>{const s=i.current;i.current={sid:t,tsid:n},!(!r||!n||s.sid===t&&(s.tsid===void 0||s.tsid===null)&&typeof n=="string")&&e.sessionObserve({sessionId:t,toolSessionId:n}).catch(()=>{})},[e,t,n,r])}function AU(e,t,n){const r=g.useRef(e),i=g.useRef(t),s=g.useRef(n);s.current=n,g.useEffect(()=>{const o=r.current,a=i.current;r.current=e,i.current=t;const l=o!==e,c=typeof a=="string"&&t==null;!l&&!c||s.current()},[e,t])}const jU=/^Scheduled (?:recurring job|one-shot task) ([0-9a-f]{8}) \(([^)]+)\)/;function LU(e){const t=new Map,n=new Map,r=new Map;for(const i of e)if(i.kind==="tool_call"&&i.tool==="CronCreate"){const s=i.input;if(!s||typeof s.cron!="string"||typeof s.prompt!="string")continue;const o=i.ts;t.set(i.toolUseId,{cron:s.cron,prompt:s.prompt,recurring:s.recurring!==!1,ts:typeof o=="string"?o:"",toolUseId:i.toolUseId})}else if(i.kind==="tool_call"&&i.tool==="CronDelete"){const s=i.input;if(!s||typeof s.id!="string")continue;n.set(i.toolUseId,s.id)}else if(i.kind==="tool_result"){const s=t.get(i.toolUseId);if(s){if(t.delete(i.toolUseId),i.error||typeof i.output!="string")continue;const a=i.output.match(jU);if(!a)continue;r.set(a[1],{id:a[1],cron:s.cron,prompt:s.prompt,recurring:s.recurring,humanSchedule:a[2],createdAt:s.ts,toolUseId:s.toolUseId});continue}const o=n.get(i.toolUseId);o!==void 0&&(n.delete(i.toolUseId),i.error||r.delete(o))}return Array.from(r.values()).sort((i,s)=>i.createdAt.localeCompare(s.createdAt))}const DU=["TaskCreate","TaskUpdate","TaskList","TaskGet"];function OU(e){return DU.includes(e)}function uR(e){return e==="in_progress"||e==="completed"?e:"pending"}function BU(e,t){if(!t||typeof t!="object")return e;const n=t,r=typeof n.subject=="string"&&n.subject?n.subject:typeof n.content=="string"&&n.content?n.content:null;if(!r)return e;const i=typeof n.activeForm=="string"?n.activeForm:void 0,s=typeof n.description=="string"?n.description:void 0;return[...e,{id:String(e.length+1),content:r,status:uR(n.status),activeForm:i,description:s}]}function zU(e,t){if(!t||typeof t!="object")return e;const n=t,r=typeof n.taskId=="string"&&n.taskId?n.taskId:typeof n.id=="string"&&n.id?n.id:null;if(!r)return e;const i=e.findIndex(a=>a.id===r);if(i<0)return e;const s=[...e],o={...s[i]};return"status"in n&&(o.status=uR(n.status)),typeof n.subject=="string"&&(o.content=n.subject),typeof n.content=="string"&&(o.content=n.content),typeof n.activeForm=="string"&&(o.activeForm=n.activeForm),typeof n.description=="string"&&(o.description=n.description),s[i]=o,s}function $U(e){let t=[],n=-1;for(let r=0;r<e.length;r++){const i=e[r];if(i.kind==="task-event")switch(n=r,i.name){case"TaskCreate":t=BU(t,i.input);break;case"TaskUpdate":t=zU(t,i.input);break}}return{tasks:t,lastEventIndex:n}}function FU(e){const{tasks:t,lastEventIndex:n}=$U(e);let r=-1;for(let c=e.length-1;c>=0;c--)if(e[c].kind==="todo-checklist"){r=c;break}const i=[],s=new Map,o=new Map,a=new Map,l=(c,u)=>{var f,p,m;const d={agentId:u.agentId,status:u.status};u.description?d.description=u.description:(f=c.progress)!=null&&f.description&&(d.description=c.progress.description),u.lastToolName?d.lastToolName=u.lastToolName:(p=c.progress)!=null&&p.lastToolName&&(d.lastToolName=c.progress.lastToolName),u.stats?d.stats=u.stats:(m=c.progress)!=null&&m.stats&&(d.stats=c.progress.stats),c.progress=d};for(let c=0;c<e.length;c++){const u=e[c];switch(u.kind){case"tool-call":{const d={kind:"merged-tool",seq:u.seq,tool:u.tool,toolKind:u.toolKind,toolUseId:u.toolUseId,input:u.input,pending:!0};s.set(u.toolUseId,i.length),i.push(d);break}case"tool-result":{const d=s.get(u.toolUseId);if(d!==void 0){const p=i[d];p.output=u.output,p.error=u.error,p.pending=!1,s.delete(u.toolUseId);break}const f=o.get(u.toolUseId);if(f!==void 0){const p=i[f];p.output=u.output,p.error=u.error,p.pending=!1,u.toolResultExtra&&(p.toolResultExtra=u.toolResultExtra);break}break}case"agent-call":{const d={kind:"merged-agent",seq:u.seq,toolUseId:u.toolUseId,description:u.description,input:u.input,pending:!0,notifications:[]};o.set(u.toolUseId,i.length),i.push(d);const f=a.get(u.toolUseId);f&&(l(d,f),a.delete(u.toolUseId));break}case"agent-progress":{const d=o.get(u.toolUseId);if(d!==void 0){l(i[d],u);break}a.set(u.toolUseId,u);break}case"agent-notification":{const d=u.parentToolUseId;if(d){const f=o.get(d);if(f!==void 0){i[f].notifications.push({text:u.text,taskId:u.taskId});break}}i.push({kind:"agent-notification",seq:u.seq,text:u.text,taskId:u.taskId,parentToolUseId:u.parentToolUseId});break}case"todo-checklist":{c===r&&u.todos.length>0&&i.push({kind:"todo-checklist",seq:u.seq,toolUseId:u.toolUseId,todos:u.todos});break}case"task-event":{c===n&&t.length>0&&i.push({kind:"plan-card",seq:u.seq,tasks:t});break}default:i.push(u)}}return i}const HU=/<(system-reminder|related-dir|clawd-shift-fire)\b[^>]*>[\s\S]*?<\/\1>/gi,UU=/<builder-preview\b[^>]*\/>/gi;function dR(e){return e?e.replace(HU,"").replace(UU,"").trim():""}const WU=dR;function VU(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const qU=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,KU=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,GU={};function vS(e,t){return(GU.jsx?KU:qU).test(e)}const XU=/[ \t\n\f\r]/g;function YU(e){return typeof e=="object"?e.type==="text"?xS(e.value):!1:xS(e)}function xS(e){return e.replace(XU,"")===""}class bu{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}bu.prototype.normal={};bu.prototype.property={};bu.prototype.space=void 0;function hR(e,t){const n={},r={};for(const i of e)Object.assign(n,i.property),Object.assign(r,i.normal);return new bu(n,r,t)}function h0(e){return e.toLowerCase()}class Vn{constructor(t,n){this.attribute=n,this.property=t}}Vn.prototype.attribute="";Vn.prototype.booleanish=!1;Vn.prototype.boolean=!1;Vn.prototype.commaOrSpaceSeparated=!1;Vn.prototype.commaSeparated=!1;Vn.prototype.defined=!1;Vn.prototype.mustUseProperty=!1;Vn.prototype.number=!1;Vn.prototype.overloadedBoolean=!1;Vn.prototype.property="";Vn.prototype.spaceSeparated=!1;Vn.prototype.space=void 0;let ZU=0;const Ie=Do(),Mt=Do(),f0=Do(),Y=Do(),lt=Do(),Na=Do(),Xn=Do();function Do(){return 2**++ZU}const p0=Object.freeze(Object.defineProperty({__proto__:null,boolean:Ie,booleanish:Mt,commaOrSpaceSeparated:Xn,commaSeparated:Na,number:Y,overloadedBoolean:f0,spaceSeparated:lt},Symbol.toStringTag,{value:"Module"})),Rm=Object.keys(p0);class hy extends Vn{constructor(t,n,r,i){let s=-1;if(super(t,n),_S(this,"space",i),typeof r=="number")for(;++s<Rm.length;){const o=Rm[s];_S(this,Rm[s],(r&p0[o])===p0[o])}}}hy.prototype.defined=!0;function _S(e,t,n){n&&(e[t]=n)}function cl(e){const t={},n={};for(const[r,i]of Object.entries(e.properties)){const s=new hy(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(s.mustUseProperty=!0),t[r]=s,n[h0(r)]=r,n[h0(s.attribute)]=r}return new bu(t,n,e.space)}const fR=cl({properties:{ariaActiveDescendant:null,ariaAtomic:Mt,ariaAutoComplete:null,ariaBusy:Mt,ariaChecked:Mt,ariaColCount:Y,ariaColIndex:Y,ariaColSpan:Y,ariaControls:lt,ariaCurrent:null,ariaDescribedBy:lt,ariaDetails:null,ariaDisabled:Mt,ariaDropEffect:lt,ariaErrorMessage:null,ariaExpanded:Mt,ariaFlowTo:lt,ariaGrabbed:Mt,ariaHasPopup:null,ariaHidden:Mt,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:lt,ariaLevel:Y,ariaLive:null,ariaModal:Mt,ariaMultiLine:Mt,ariaMultiSelectable:Mt,ariaOrientation:null,ariaOwns:lt,ariaPlaceholder:null,ariaPosInSet:Y,ariaPressed:Mt,ariaReadOnly:Mt,ariaRelevant:null,ariaRequired:Mt,ariaRoleDescription:lt,ariaRowCount:Y,ariaRowIndex:Y,ariaRowSpan:Y,ariaSelected:Mt,ariaSetSize:Y,ariaSort:null,ariaValueMax:Y,ariaValueMin:Y,ariaValueNow:Y,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function pR(e,t){return t in e?e[t]:t}function mR(e,t){return pR(e,t.toLowerCase())}const QU=cl({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Na,acceptCharset:lt,accessKey:lt,action:null,allow:null,allowFullScreen:Ie,allowPaymentRequest:Ie,allowUserMedia:Ie,alt:null,as:null,async:Ie,autoCapitalize:null,autoComplete:lt,autoFocus:Ie,autoPlay:Ie,blocking:lt,capture:null,charSet:null,checked:Ie,cite:null,className:lt,cols:Y,colSpan:null,content:null,contentEditable:Mt,controls:Ie,controlsList:lt,coords:Y|Na,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Ie,defer:Ie,dir:null,dirName:null,disabled:Ie,download:f0,draggable:Mt,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Ie,formTarget:null,headers:lt,height:Y,hidden:f0,high:Y,href:null,hrefLang:null,htmlFor:lt,httpEquiv:lt,id:null,imageSizes:null,imageSrcSet:null,inert:Ie,inputMode:null,integrity:null,is:null,isMap:Ie,itemId:null,itemProp:lt,itemRef:lt,itemScope:Ie,itemType:lt,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Ie,low:Y,manifest:null,max:null,maxLength:Y,media:null,method:null,min:null,minLength:Y,multiple:Ie,muted:Ie,name:null,nonce:null,noModule:Ie,noValidate:Ie,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:Ie,optimum:Y,pattern:null,ping:lt,placeholder:null,playsInline:Ie,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Ie,referrerPolicy:null,rel:lt,required:Ie,reversed:Ie,rows:Y,rowSpan:Y,sandbox:lt,scope:null,scoped:Ie,seamless:Ie,selected:Ie,shadowRootClonable:Ie,shadowRootDelegatesFocus:Ie,shadowRootMode:null,shape:null,size:Y,sizes:null,slot:null,span:Y,spellCheck:Mt,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Y,step:null,style:null,tabIndex:Y,target:null,title:null,translate:null,type:null,typeMustMatch:Ie,useMap:null,value:Mt,width:Y,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:lt,axis:null,background:null,bgColor:null,border:Y,borderColor:null,bottomMargin:Y,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Ie,declare:Ie,event:null,face:null,frame:null,frameBorder:null,hSpace:Y,leftMargin:Y,link:null,longDesc:null,lowSrc:null,marginHeight:Y,marginWidth:Y,noResize:Ie,noHref:Ie,noShade:Ie,noWrap:Ie,object:null,profile:null,prompt:null,rev:null,rightMargin:Y,rules:null,scheme:null,scrolling:Mt,standby:null,summary:null,text:null,topMargin:Y,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Y,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:Ie,disableRemotePlayback:Ie,prefix:null,property:null,results:Y,security:null,unselectable:null},space:"html",transform:mR}),JU=cl({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:Xn,accentHeight:Y,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Y,amplitude:Y,arabicForm:null,ascent:Y,attributeName:null,attributeType:null,azimuth:Y,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Y,by:null,calcMode:null,capHeight:Y,className:lt,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:Y,diffuseConstant:Y,direction:null,display:null,dur:null,divisor:Y,dominantBaseline:null,download:Ie,dx:null,dy:null,edgeMode:null,editable:null,elevation:Y,enableBackground:null,end:null,event:null,exponent:Y,externalResourcesRequired:null,fill:null,fillOpacity:Y,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:Na,g2:Na,glyphName:Na,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Y,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Y,horizOriginX:Y,horizOriginY:Y,id:null,ideographic:Y,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Y,k:Y,k1:Y,k2:Y,k3:Y,k4:Y,kernelMatrix:Xn,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Y,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:Y,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:Y,overlineThickness:Y,paintOrder:null,panose1:null,path:null,pathLength:Y,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:lt,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Y,pointsAtY:Y,pointsAtZ:Y,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Xn,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Xn,rev:Xn,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Xn,requiredFeatures:Xn,requiredFonts:Xn,requiredFormats:Xn,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:Y,specularExponent:Y,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Y,strikethroughThickness:Y,string:null,stroke:null,strokeDashArray:Xn,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Y,strokeOpacity:Y,strokeWidth:null,style:null,surfaceScale:Y,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Xn,tabIndex:Y,tableValues:null,target:null,targetX:Y,targetY:Y,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Xn,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Y,underlineThickness:Y,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Y,values:null,vAlphabetic:Y,vMathematical:Y,vectorEffect:null,vHanging:Y,vIdeographic:Y,version:null,vertAdvY:Y,vertOriginX:Y,vertOriginY:Y,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Y,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:pR}),gR=cl({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),vR=cl({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:mR}),xR=cl({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),eW={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},tW=/[A-Z]/g,yS=/-[a-z]/g,nW=/^data[-\w.:]+$/i;function rW(e,t){const n=h0(t);let r=t,i=Vn;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&nW.test(t)){if(t.charAt(4)==="-"){const s=t.slice(5).replace(yS,sW);r="data"+s.charAt(0).toUpperCase()+s.slice(1)}else{const s=t.slice(4);if(!yS.test(s)){let o=s.replace(tW,iW);o.charAt(0)!=="-"&&(o="-"+o),t="data"+o}}i=hy}return new i(r,t)}function iW(e){return"-"+e.toLowerCase()}function sW(e){return e.charAt(1).toUpperCase()}const oW=hR([fR,QU,gR,vR,xR],"html"),fy=hR([fR,JU,gR,vR,xR],"svg");function aW(e){return e.join(" ").trim()}var py={},bS=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,lW=/\n/g,cW=/^\s*/,uW=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,dW=/^:\s*/,hW=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,fW=/^[;\s]*/,pW=/^\s+|\s+$/g,mW=`
|
|
496
496
|
`,wS="/",SS="*",Ys="",gW="comment",vW="declaration";function xW(e,t){if(typeof e!="string")throw new TypeError("First argument must be a string");if(!e)return[];t=t||{};var n=1,r=1;function i(m){var v=m.match(lW);v&&(n+=v.length);var b=m.lastIndexOf(mW);r=~b?m.length-b:r+m.length}function s(){var m={line:n,column:r};return function(v){return v.position=new o(m),c(),v}}function o(m){this.start=m,this.end={line:n,column:r},this.source=t.source}o.prototype.content=e;function a(m){var v=new Error(t.source+":"+n+":"+r+": "+m);if(v.reason=m,v.filename=t.source,v.line=n,v.column=r,v.source=e,!t.silent)throw v}function l(m){var v=m.exec(e);if(v){var b=v[0];return i(b),e=e.slice(b.length),v}}function c(){l(cW)}function u(m){var v;for(m=m||[];v=d();)v!==!1&&m.push(v);return m}function d(){var m=s();if(!(wS!=e.charAt(0)||SS!=e.charAt(1))){for(var v=2;Ys!=e.charAt(v)&&(SS!=e.charAt(v)||wS!=e.charAt(v+1));)++v;if(v+=2,Ys===e.charAt(v-1))return a("End of comment missing");var b=e.slice(2,v-2);return r+=2,i(b),e=e.slice(v),r+=2,m({type:gW,comment:b})}}function f(){var m=s(),v=l(uW);if(v){if(d(),!l(dW))return a("property missing ':'");var b=l(hW),x=m({type:vW,property:kS(v[0].replace(bS,Ys)),value:b?kS(b[0].replace(bS,Ys)):Ys});return l(fW),x}}function p(){var m=[];u(m);for(var v;v=f();)v!==!1&&(m.push(v),u(m));return m}return c(),p()}function kS(e){return e?e.replace(pW,Ys):Ys}var _W=xW,yW=ah&&ah.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(py,"__esModule",{value:!0});py.default=wW;const bW=yW(_W);function wW(e,t){let n=null;if(!e||typeof e!="string")return n;const r=(0,bW.default)(e),i=typeof t=="function";return r.forEach(s=>{if(s.type!=="declaration")return;const{property:o,value:a}=s;i?t(o,a,s):a&&(n=n||{},n[o]=a)}),n}var fp={};Object.defineProperty(fp,"__esModule",{value:!0});fp.camelCase=void 0;var SW=/^--[a-zA-Z0-9_-]+$/,kW=/-([a-z])/g,CW=/^[^-]+$/,EW=/^-(webkit|moz|ms|o|khtml)-/,NW=/^-(ms)-/,TW=function(e){return!e||CW.test(e)||SW.test(e)},PW=function(e,t){return t.toUpperCase()},CS=function(e,t){return"".concat(t,"-")},IW=function(e,t){return t===void 0&&(t={}),TW(e)?e:(e=e.toLowerCase(),t.reactCompat?e=e.replace(NW,CS):e=e.replace(EW,CS),e.replace(kW,PW))};fp.camelCase=IW;var RW=ah&&ah.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},MW=RW(py),AW=fp;function m0(e,t){var n={};return!e||typeof e!="string"||(0,MW.default)(e,function(r,i){r&&i&&(n[(0,AW.camelCase)(r,t)]=i)}),n}m0.default=m0;var jW=m0;const LW=ou(jW),_R=yR("end"),my=yR("start");function yR(e){return t;function t(n){const r=n&&n.position&&n.position[e]||{};if(typeof r.line=="number"&&r.line>0&&typeof r.column=="number"&&r.column>0)return{line:r.line,column:r.column,offset:typeof r.offset=="number"&&r.offset>-1?r.offset:void 0}}}function DW(e){const t=my(e),n=_R(e);if(t&&n)return{start:t,end:n}}function hc(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?ES(e.position):"start"in e||"end"in e?ES(e):"line"in e||"column"in e?g0(e):""}function g0(e){return NS(e&&e.line)+":"+NS(e&&e.column)}function ES(e){return g0(e&&e.start)+"-"+g0(e&&e.end)}function NS(e){return e&&typeof e=="number"?e:1}class wn extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let i="",s={},o=!1;if(n&&("line"in n&&"column"in n?s={place:n}:"start"in n&&"end"in n?s={place:n}:"type"in n?s={ancestors:[n],place:n.position}:s={...n}),typeof t=="string"?i=t:!s.cause&&t&&(o=!0,i=t.message,s.cause=t),!s.ruleId&&!s.source&&typeof r=="string"){const l=r.indexOf(":");l===-1?s.ruleId=r:(s.source=r.slice(0,l),s.ruleId=r.slice(l+1))}if(!s.place&&s.ancestors&&s.ancestors){const l=s.ancestors[s.ancestors.length-1];l&&(s.place=l.position)}const a=s.place&&"start"in s.place?s.place.start:s.place;this.ancestors=s.ancestors||void 0,this.cause=s.cause||void 0,this.column=a?a.column:void 0,this.fatal=void 0,this.file="",this.message=i,this.line=a?a.line:void 0,this.name=hc(s.place)||"1:1",this.place=s.place||void 0,this.reason=this.message,this.ruleId=s.ruleId||void 0,this.source=s.source||void 0,this.stack=o&&s.cause&&typeof s.cause.stack=="string"?s.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}wn.prototype.file="";wn.prototype.name="";wn.prototype.reason="";wn.prototype.message="";wn.prototype.stack="";wn.prototype.column=void 0;wn.prototype.line=void 0;wn.prototype.ancestors=void 0;wn.prototype.cause=void 0;wn.prototype.fatal=void 0;wn.prototype.place=void 0;wn.prototype.ruleId=void 0;wn.prototype.source=void 0;const gy={}.hasOwnProperty,OW=new Map,BW=/[A-Z]/g,zW=new Set(["table","tbody","thead","tfoot","tr"]),$W=new Set(["td","th"]),bR="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function FW(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let r;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");r=XW(n,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");r=GW(n,t.jsx,t.jsxs)}const i={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?fy:oW,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},s=wR(i,e,void 0);return s&&typeof s!="string"?s:i.create(e,i.Fragment,{children:s||void 0},void 0)}function wR(e,t,n){if(t.type==="element")return HW(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return UW(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return VW(e,t,n);if(t.type==="mdxjsEsm")return WW(e,t);if(t.type==="root")return qW(e,t,n);if(t.type==="text")return KW(e,t)}function HW(e,t,n){const r=e.schema;let i=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(i=fy,e.schema=i),e.ancestors.push(t);const s=kR(e,t.tagName,!1),o=YW(e,t);let a=xy(e,t);return zW.has(t.tagName)&&(a=a.filter(function(l){return typeof l=="string"?!YU(l):!0})),SR(e,o,s,t),vy(o,a),e.ancestors.pop(),e.schema=r,e.create(t,s,o,n)}function UW(e,t){if(t.data&&t.data.estree&&e.evaluater){const r=t.data.estree.body[0];return r.type,e.evaluater.evaluateExpression(r.expression)}Zc(e,t.position)}function WW(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);Zc(e,t.position)}function VW(e,t,n){const r=e.schema;let i=r;t.name==="svg"&&r.space==="html"&&(i=fy,e.schema=i),e.ancestors.push(t);const s=t.name===null?e.Fragment:kR(e,t.name,!0),o=ZW(e,t),a=xy(e,t);return SR(e,o,s,t),vy(o,a),e.ancestors.pop(),e.schema=r,e.create(t,s,o,n)}function qW(e,t,n){const r={};return vy(r,xy(e,t)),e.create(t,e.Fragment,r,n)}function KW(e,t){return t.value}function SR(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function vy(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function GW(e,t,n){return r;function r(i,s,o,a){const c=Array.isArray(o.children)?n:t;return a?c(s,o,a):c(s,o)}}function XW(e,t){return n;function n(r,i,s,o){const a=Array.isArray(s.children),l=my(r);return t(i,s,o,a,{columnNumber:l?l.column-1:void 0,fileName:e,lineNumber:l?l.line:void 0},void 0)}}function YW(e,t){const n={};let r,i;for(i in t.properties)if(i!=="children"&&gy.call(t.properties,i)){const s=QW(e,i,t.properties[i]);if(s){const[o,a]=s;e.tableCellAlignToStyle&&o==="align"&&typeof a=="string"&&$W.has(t.tagName)?r=a:n[o]=a}}if(r){const s=n.style||(n.style={});s[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function ZW(e,t){const n={};for(const r of t.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&e.evaluater){const s=r.data.estree.body[0];s.type;const o=s.expression;o.type;const a=o.properties[0];a.type,Object.assign(n,e.evaluater.evaluateExpression(a.argument))}else Zc(e,t.position);else{const i=r.name;let s;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&e.evaluater){const a=r.value.data.estree.body[0];a.type,s=e.evaluater.evaluateExpression(a.expression)}else Zc(e,t.position);else s=r.value===null?!0:r.value;n[i]=s}return n}function xy(e,t){const n=[];let r=-1;const i=e.passKeys?new Map:OW;for(;++r<t.children.length;){const s=t.children[r];let o;if(e.passKeys){const l=s.type==="element"?s.tagName:s.type==="mdxJsxFlowElement"||s.type==="mdxJsxTextElement"?s.name:void 0;if(l){const c=i.get(l)||0;o=l+"-"+c,i.set(l,c+1)}}const a=wR(e,s,o);a!==void 0&&n.push(a)}return n}function QW(e,t,n){const r=rW(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?VU(n):aW(n)),r.property==="style"){let i=typeof n=="object"?n:JW(e,String(n));return e.stylePropertyNameCase==="css"&&(i=eV(i)),["style",i]}return[e.elementAttributeNameCase==="react"&&r.space?eW[r.property]||r.property:r.attribute,n]}}function JW(e,t){try{return LW(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,i=new wn("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:r,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw i.file=e.filePath||void 0,i.url=bR+"#cannot-parse-style-attribute",i}}function kR(e,t,n){let r;if(!n)r={type:"Literal",value:t};else if(t.includes(".")){const i=t.split(".");let s=-1,o;for(;++s<i.length;){const a=vS(i[s])?{type:"Identifier",name:i[s]}:{type:"Literal",value:i[s]};o=o?{type:"MemberExpression",object:o,property:a,computed:!!(s&&a.type==="Literal"),optional:!1}:a}r=o}else r=vS(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const i=r.value;return gy.call(e.components,i)?e.components[i]:i}if(e.evaluater)return e.evaluater.evaluateExpression(r);Zc(e)}function Zc(e,t){const n=new wn("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=bR+"#cannot-handle-mdx-estrees-without-createevaluater",n}function eV(e){const t={};let n;for(n in e)gy.call(e,n)&&(t[tV(n)]=e[n]);return t}function tV(e){let t=e.replace(BW,nV);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function nV(e){return"-"+e.toLowerCase()}const Mm={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},rV={};function _y(e,t){const n=rV,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,i=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return CR(e,r,i)}function CR(e,t,n){if(iV(e)){if("value"in e)return e.type==="html"&&!n?"":e.value;if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return TS(e.children,t,n)}return Array.isArray(e)?TS(e,t,n):""}function TS(e,t,n){const r=[];let i=-1;for(;++i<e.length;)r[i]=CR(e[i],t,n);return r.join("")}function iV(e){return!!(e&&typeof e=="object")}const PS=document.createElement("i");function yy(e){const t="&"+e+";";PS.innerHTML=t;const n=PS.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function tr(e,t,n,r){const i=e.length;let s=0,o;if(t<0?t=-t>i?0:i+t:t=t>i?i:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);s<r.length;)o=r.slice(s,s+1e4),o.unshift(t,0),e.splice(...o),s+=1e4,t+=1e4}function mr(e,t){return e.length>0?(tr(e,e.length,0,t),e):t}const IS={}.hasOwnProperty;function ER(e){const t={};let n=-1;for(;++n<e.length;)sV(t,e[n]);return t}function sV(e,t){let n;for(n in t){const i=(IS.call(e,n)?e[n]:void 0)||(e[n]={}),s=t[n];let o;if(s)for(o in s){IS.call(i,o)||(i[o]=[]);const a=s[o];oV(i[o],Array.isArray(a)?a:a?[a]:[])}}}function oV(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);tr(e,0,0,r)}function NR(e,t){const n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"�":String.fromCodePoint(n)}function jr(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const Cn=Bs(/[A-Za-z]/),yn=Bs(/[\dA-Za-z]/),aV=Bs(/[#-'*+\--9=?A-Z^-~]/);function ef(e){return e!==null&&(e<32||e===127)}const v0=Bs(/\d/),lV=Bs(/[\dA-Fa-f]/),cV=Bs(/[!-/:-@[-`{-~]/);function be(e){return e!==null&&e<-2}function ot(e){return e!==null&&(e<0||e===32)}function ze(e){return e===-2||e===-1||e===32}const pp=Bs(new RegExp("\\p{P}|\\p{S}","u")),wo=Bs(/\s/);function Bs(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function ul(e){const t=[];let n=-1,r=0,i=0;for(;++n<e.length;){const s=e.charCodeAt(n);let o="";if(s===37&&yn(e.charCodeAt(n+1))&&yn(e.charCodeAt(n+2)))i=2;else if(s<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(s))||(o=String.fromCharCode(s));else if(s>55295&&s<57344){const a=e.charCodeAt(n+1);s<56320&&a>56319&&a<57344?(o=String.fromCharCode(s,a),i=1):o="�"}else o=String.fromCharCode(s);o&&(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+i+1,o=""),i&&(n+=i,i=0)}return t.join("")+e.slice(r)}function Ve(e,t,n,r){const i=r?r-1:Number.POSITIVE_INFINITY;let s=0;return o;function o(l){return ze(l)?(e.enter(n),a(l)):t(l)}function a(l){return ze(l)&&s++<i?(e.consume(l),a):(e.exit(n),t(l))}}const uV={tokenize:dV};function dV(e){const t=e.attempt(this.parser.constructs.contentInitial,r,i);let n;return t;function r(a){if(a===null){e.consume(a);return}return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),Ve(e,t,"linePrefix")}function i(a){return e.enter("paragraph"),s(a)}function s(a){const l=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=l),n=l,o(a)}function o(a){if(a===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(a);return}return be(a)?(e.consume(a),e.exit("chunkText"),s):(e.consume(a),o)}}const hV={tokenize:fV},RS={tokenize:pV};function fV(e){const t=this,n=[];let r=0,i,s,o;return a;function a(y){if(r<n.length){const w=n[r];return t.containerState=w[1],e.attempt(w[0].continuation,l,c)(y)}return c(y)}function l(y){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&_();const w=t.events.length;let S=w,C;for(;S--;)if(t.events[S][0]==="exit"&&t.events[S][1].type==="chunkFlow"){C=t.events[S][1].end;break}x(r);let N=w;for(;N<t.events.length;)t.events[N][1].end={...C},N++;return tr(t.events,S+1,0,t.events.slice(w)),t.events.length=N,c(y)}return a(y)}function c(y){if(r===n.length){if(!i)return f(y);if(i.currentConstruct&&i.currentConstruct.concrete)return m(y);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(RS,u,d)(y)}function u(y){return i&&_(),x(r),f(y)}function d(y){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,m(y)}function f(y){return t.containerState={},e.attempt(RS,p,m)(y)}function p(y){return r++,n.push([t.currentConstruct,t.containerState]),f(y)}function m(y){if(y===null){i&&_(),x(0),e.consume(y);return}return i=i||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:i,contentType:"flow",previous:s}),v(y)}function v(y){if(y===null){b(e.exit("chunkFlow"),!0),x(0),e.consume(y);return}return be(y)?(e.consume(y),b(e.exit("chunkFlow")),r=0,t.interrupt=void 0,a):(e.consume(y),v)}function b(y,w){const S=t.sliceStream(y);if(w&&S.push(null),y.previous=s,s&&(s.next=y),s=y,i.defineSkip(y.start),i.write(S),t.parser.lazy[y.start.line]){let C=i.events.length;for(;C--;)if(i.events[C][1].start.offset<o&&(!i.events[C][1].end||i.events[C][1].end.offset>o))return;const N=t.events.length;let T=N,M,P;for(;T--;)if(t.events[T][0]==="exit"&&t.events[T][1].type==="chunkFlow"){if(M){P=t.events[T][1].end;break}M=!0}for(x(r),C=N;C<t.events.length;)t.events[C][1].end={...P},C++;tr(t.events,T+1,0,t.events.slice(N)),t.events.length=C}}function x(y){let w=n.length;for(;w-- >y;){const S=n[w];t.containerState=S[1],S[0].exit.call(t,e)}n.length=y}function _(){i.write([null]),s=void 0,i=void 0,t.containerState._closeFlow=void 0}}function pV(e,t,n){return Ve(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Ua(e){if(e===null||ot(e)||wo(e))return 1;if(pp(e))return 2}function mp(e,t,n){const r=[];let i=-1;for(;++i<e.length;){const s=e[i].resolveAll;s&&!r.includes(s)&&(t=s(t,n),r.push(s))}return t}const x0={name:"attention",resolveAll:mV,tokenize:gV};function mV(e,t){let n=-1,r,i,s,o,a,l,c,u;for(;++n<e.length;)if(e[n][0]==="enter"&&e[n][1].type==="attentionSequence"&&e[n][1]._close){for(r=n;r--;)if(e[r][0]==="exit"&&e[r][1].type==="attentionSequence"&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;l=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const d={...e[r][1].end},f={...e[n][1].start};MS(d,-l),MS(f,l),o={type:l>1?"strongSequence":"emphasisSequence",start:d,end:{...e[r][1].end}},a={type:l>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:f},s={type:l>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[n][1].start}},i={type:l>1?"strong":"emphasis",start:{...o.start},end:{...a.end}},e[r][1].end={...o.start},e[n][1].start={...a.end},c=[],e[r][1].end.offset-e[r][1].start.offset&&(c=mr(c,[["enter",e[r][1],t],["exit",e[r][1],t]])),c=mr(c,[["enter",i,t],["enter",o,t],["exit",o,t],["enter",s,t]]),c=mr(c,mp(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),c=mr(c,[["exit",s,t],["enter",a,t],["exit",a,t],["exit",i,t]]),e[n][1].end.offset-e[n][1].start.offset?(u=2,c=mr(c,[["enter",e[n][1],t],["exit",e[n][1],t]])):u=0,tr(e,r-1,n-r+3,c),n=r+c.length-u-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function gV(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=Ua(r);let s;return o;function o(l){return s=l,e.enter("attentionSequence"),a(l)}function a(l){if(l===s)return e.consume(l),a;const c=e.exit("attentionSequence"),u=Ua(l),d=!u||u===2&&i||n.includes(l),f=!i||i===2&&u||n.includes(r);return c._open=!!(s===42?d:d&&(i||!f)),c._close=!!(s===42?f:f&&(u||!d)),t(l)}}function MS(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const vV={name:"autolink",tokenize:xV};function xV(e,t,n){let r=0;return i;function i(p){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),s}function s(p){return Cn(p)?(e.consume(p),o):p===64?n(p):c(p)}function o(p){return p===43||p===45||p===46||yn(p)?(r=1,a(p)):c(p)}function a(p){return p===58?(e.consume(p),r=0,l):(p===43||p===45||p===46||yn(p))&&r++<32?(e.consume(p),a):(r=0,c(p))}function l(p){return p===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.exit("autolink"),t):p===null||p===32||p===60||ef(p)?n(p):(e.consume(p),l)}function c(p){return p===64?(e.consume(p),u):aV(p)?(e.consume(p),c):n(p)}function u(p){return yn(p)?d(p):n(p)}function d(p){return p===46?(e.consume(p),r=0,u):p===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.exit("autolink"),t):f(p)}function f(p){if((p===45||yn(p))&&r++<63){const m=p===45?f:d;return e.consume(p),m}return n(p)}}const wu={partial:!0,tokenize:_V};function _V(e,t,n){return r;function r(s){return ze(s)?Ve(e,i,"linePrefix")(s):i(s)}function i(s){return s===null||be(s)?t(s):n(s)}}const TR={continuation:{tokenize:bV},exit:wV,name:"blockQuote",tokenize:yV};function yV(e,t,n){const r=this;return i;function i(o){if(o===62){const a=r.containerState;return a.open||(e.enter("blockQuote",{_container:!0}),a.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(o),e.exit("blockQuoteMarker"),s}return n(o)}function s(o){return ze(o)?(e.enter("blockQuotePrefixWhitespace"),e.consume(o),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(o))}}function bV(e,t,n){const r=this;return i;function i(o){return ze(o)?Ve(e,s,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(o):s(o)}function s(o){return e.attempt(TR,t,n)(o)}}function wV(e){e.exit("blockQuote")}const PR={name:"characterEscape",tokenize:SV};function SV(e,t,n){return r;function r(s){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(s),e.exit("escapeMarker"),i}function i(s){return cV(s)?(e.enter("characterEscapeValue"),e.consume(s),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(s)}}const IR={name:"characterReference",tokenize:kV};function kV(e,t,n){const r=this;let i=0,s,o;return a;function a(d){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(d),e.exit("characterReferenceMarker"),l}function l(d){return d===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(d),e.exit("characterReferenceMarkerNumeric"),c):(e.enter("characterReferenceValue"),s=31,o=yn,u(d))}function c(d){return d===88||d===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(d),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),s=6,o=lV,u):(e.enter("characterReferenceValue"),s=7,o=v0,u(d))}function u(d){if(d===59&&i){const f=e.exit("characterReferenceValue");return o===yn&&!yy(r.sliceSerialize(f))?n(d):(e.enter("characterReferenceMarker"),e.consume(d),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return o(d)&&i++<s?(e.consume(d),u):n(d)}}const AS={partial:!0,tokenize:EV},jS={concrete:!0,name:"codeFenced",tokenize:CV};function CV(e,t,n){const r=this,i={partial:!0,tokenize:S};let s=0,o=0,a;return l;function l(C){return c(C)}function c(C){const N=r.events[r.events.length-1];return s=N&&N[1].type==="linePrefix"?N[2].sliceSerialize(N[1],!0).length:0,a=C,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),u(C)}function u(C){return C===a?(o++,e.consume(C),u):o<3?n(C):(e.exit("codeFencedFenceSequence"),ze(C)?Ve(e,d,"whitespace")(C):d(C))}function d(C){return C===null||be(C)?(e.exit("codeFencedFence"),r.interrupt?t(C):e.check(AS,v,w)(C)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),f(C))}function f(C){return C===null||be(C)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),d(C)):ze(C)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),Ve(e,p,"whitespace")(C)):C===96&&C===a?n(C):(e.consume(C),f)}function p(C){return C===null||be(C)?d(C):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),m(C))}function m(C){return C===null||be(C)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),d(C)):C===96&&C===a?n(C):(e.consume(C),m)}function v(C){return e.attempt(i,w,b)(C)}function b(C){return e.enter("lineEnding"),e.consume(C),e.exit("lineEnding"),x}function x(C){return s>0&&ze(C)?Ve(e,_,"linePrefix",s+1)(C):_(C)}function _(C){return C===null||be(C)?e.check(AS,v,w)(C):(e.enter("codeFlowValue"),y(C))}function y(C){return C===null||be(C)?(e.exit("codeFlowValue"),_(C)):(e.consume(C),y)}function w(C){return e.exit("codeFenced"),t(C)}function S(C,N,T){let M=0;return P;function P(z){return C.enter("lineEnding"),C.consume(z),C.exit("lineEnding"),D}function D(z){return C.enter("codeFencedFence"),ze(z)?Ve(C,R,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(z):R(z)}function R(z){return z===a?(C.enter("codeFencedFenceSequence"),I(z)):T(z)}function I(z){return z===a?(M++,C.consume(z),I):M>=o?(C.exit("codeFencedFenceSequence"),ze(z)?Ve(C,O,"whitespace")(z):O(z)):T(z)}function O(z){return z===null||be(z)?(C.exit("codeFencedFence"),N(z)):T(z)}}}function EV(e,t,n){const r=this;return i;function i(o){return o===null?n(o):(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),s)}function s(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}const Am={name:"codeIndented",tokenize:TV},NV={partial:!0,tokenize:PV};function TV(e,t,n){const r=this;return i;function i(c){return e.enter("codeIndented"),Ve(e,s,"linePrefix",5)(c)}function s(c){const u=r.events[r.events.length-1];return u&&u[1].type==="linePrefix"&&u[2].sliceSerialize(u[1],!0).length>=4?o(c):n(c)}function o(c){return c===null?l(c):be(c)?e.attempt(NV,o,l)(c):(e.enter("codeFlowValue"),a(c))}function a(c){return c===null||be(c)?(e.exit("codeFlowValue"),o(c)):(e.consume(c),a)}function l(c){return e.exit("codeIndented"),t(c)}}function PV(e,t,n){const r=this;return i;function i(o){return r.parser.lazy[r.now().line]?n(o):be(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),i):Ve(e,s,"linePrefix",5)(o)}function s(o){const a=r.events[r.events.length-1];return a&&a[1].type==="linePrefix"&&a[2].sliceSerialize(a[1],!0).length>=4?t(o):be(o)?i(o):n(o)}}const IV={name:"codeText",previous:MV,resolve:RV,tokenize:AV};function RV(e){let t=e.length-4,n=3,r,i;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(r=n;++r<t;)if(e[r][1].type==="codeTextData"){e[n][1].type="codeTextPadding",e[t][1].type="codeTextPadding",n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!=="lineEnding"&&(i=r):(r===t||e[r][1].type==="lineEnding")&&(e[i][1].type="codeTextData",r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function MV(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function AV(e,t,n){let r=0,i,s;return o;function o(d){return e.enter("codeText"),e.enter("codeTextSequence"),a(d)}function a(d){return d===96?(e.consume(d),r++,a):(e.exit("codeTextSequence"),l(d))}function l(d){return d===null?n(d):d===32?(e.enter("space"),e.consume(d),e.exit("space"),l):d===96?(s=e.enter("codeTextSequence"),i=0,u(d)):be(d)?(e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),l):(e.enter("codeTextData"),c(d))}function c(d){return d===null||d===32||d===96||be(d)?(e.exit("codeTextData"),l(d)):(e.consume(d),c)}function u(d){return d===96?(e.consume(d),i++,u):i===r?(e.exit("codeTextSequence"),e.exit("codeText"),t(d)):(s.type="codeTextData",c(d))}}class jV{constructor(t){this.left=t?[...t]:[],this.right=[]}get(t){if(t<0||t>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return t<this.left.length?this.left[t]:this.right[this.right.length-t+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(t,n){const r=n??Number.POSITIVE_INFINITY;return r<this.left.length?this.left.slice(t,r):t>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(t,n,r){const i=n||0;this.setCursor(Math.trunc(t));const s=this.right.splice(this.right.length-i,Number.POSITIVE_INFINITY);return r&&Rl(this.left,r),s.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),Rl(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),Rl(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t<this.left.length){const n=this.left.splice(t,Number.POSITIVE_INFINITY);Rl(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);Rl(this.left,n.reverse())}}}function Rl(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function RR(e){const t={};let n=-1,r,i,s,o,a,l,c;const u=new jV(e);for(;++n<u.length;){for(;n in t;)n=t[n];if(r=u.get(n),n&&r[1].type==="chunkFlow"&&u.get(n-1)[1].type==="listItemPrefix"&&(l=r[1]._tokenizer.events,s=0,s<l.length&&l[s][1].type==="lineEndingBlank"&&(s+=2),s<l.length&&l[s][1].type==="content"))for(;++s<l.length&&l[s][1].type!=="content";)l[s][1].type==="chunkText"&&(l[s][1]._isInFirstContentOfListItem=!0,s++);if(r[0]==="enter")r[1].contentType&&(Object.assign(t,LV(u,n)),n=t[n],c=!0);else if(r[1]._container){for(s=n,i=void 0;s--;)if(o=u.get(s),o[1].type==="lineEnding"||o[1].type==="lineEndingBlank")o[0]==="enter"&&(i&&(u.get(i)[1].type="lineEndingBlank"),o[1].type="lineEnding",i=s);else if(!(o[1].type==="linePrefix"||o[1].type==="listItemIndent"))break;i&&(r[1].end={...u.get(i)[1].start},a=u.slice(i,n),a.unshift(r),u.splice(i,n-i+1,a))}}return tr(e,0,Number.POSITIVE_INFINITY,u.slice(0)),!c}function LV(e,t){const n=e.get(t)[1],r=e.get(t)[2];let i=t-1;const s=[];let o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));const a=o.events,l=[],c={};let u,d,f=-1,p=n,m=0,v=0;const b=[v];for(;p;){for(;e.get(++i)[1]!==p;);s.push(i),p._tokenizer||(u=r.sliceStream(p),p.next||u.push(null),d&&o.defineSkip(p.start),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(u),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),d=p,p=p.next}for(p=n;++f<a.length;)a[f][0]==="exit"&&a[f-1][0]==="enter"&&a[f][1].type===a[f-1][1].type&&a[f][1].start.line!==a[f][1].end.line&&(v=f+1,b.push(v),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(o.events=[],p?(p._tokenizer=void 0,p.previous=void 0):b.pop(),f=b.length;f--;){const x=a.slice(b[f],b[f+1]),_=s.pop();l.push([_,_+x.length-1]),e.splice(_,2,x)}for(l.reverse(),f=-1;++f<l.length;)c[m+l[f][0]]=m+l[f][1],m+=l[f][1]-l[f][0]-1;return c}const DV={resolve:BV,tokenize:zV},OV={partial:!0,tokenize:$V};function BV(e){return RR(e),e}function zV(e,t){let n;return r;function r(a){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),i(a)}function i(a){return a===null?s(a):be(a)?e.check(OV,o,s)(a):(e.consume(a),i)}function s(a){return e.exit("chunkContent"),e.exit("content"),t(a)}function o(a){return e.consume(a),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,i}}function $V(e,t,n){const r=this;return i;function i(o){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),Ve(e,s,"linePrefix")}function s(o){if(o===null||be(o))return n(o);const a=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&a&&a[1].type==="linePrefix"&&a[2].sliceSerialize(a[1],!0).length>=4?t(o):e.interrupt(r.parser.constructs.flow,n,t)(o)}}function MR(e,t,n,r,i,s,o,a,l){const c=l||Number.POSITIVE_INFINITY;let u=0;return d;function d(x){return x===60?(e.enter(r),e.enter(i),e.enter(s),e.consume(x),e.exit(s),f):x===null||x===32||x===41||ef(x)?n(x):(e.enter(r),e.enter(o),e.enter(a),e.enter("chunkString",{contentType:"string"}),v(x))}function f(x){return x===62?(e.enter(s),e.consume(x),e.exit(s),e.exit(i),e.exit(r),t):(e.enter(a),e.enter("chunkString",{contentType:"string"}),p(x))}function p(x){return x===62?(e.exit("chunkString"),e.exit(a),f(x)):x===null||x===60||be(x)?n(x):(e.consume(x),x===92?m:p)}function m(x){return x===60||x===62||x===92?(e.consume(x),p):p(x)}function v(x){return!u&&(x===null||x===41||ot(x))?(e.exit("chunkString"),e.exit(a),e.exit(o),e.exit(r),t(x)):u<c&&x===40?(e.consume(x),u++,v):x===41?(e.consume(x),u--,v):x===null||x===32||x===40||ef(x)?n(x):(e.consume(x),x===92?b:v)}function b(x){return x===40||x===41||x===92?(e.consume(x),v):v(x)}}function AR(e,t,n,r,i,s){const o=this;let a=0,l;return c;function c(p){return e.enter(r),e.enter(i),e.consume(p),e.exit(i),e.enter(s),u}function u(p){return a>999||p===null||p===91||p===93&&!l||p===94&&!a&&"_hiddenFootnoteSupport"in o.parser.constructs?n(p):p===93?(e.exit(s),e.enter(i),e.consume(p),e.exit(i),e.exit(r),t):be(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),u):(e.enter("chunkString",{contentType:"string"}),d(p))}function d(p){return p===null||p===91||p===93||be(p)||a++>999?(e.exit("chunkString"),u(p)):(e.consume(p),l||(l=!ze(p)),p===92?f:d)}function f(p){return p===91||p===92||p===93?(e.consume(p),a++,d):d(p)}}function jR(e,t,n,r,i,s){let o;return a;function a(f){return f===34||f===39||f===40?(e.enter(r),e.enter(i),e.consume(f),e.exit(i),o=f===40?41:f,l):n(f)}function l(f){return f===o?(e.enter(i),e.consume(f),e.exit(i),e.exit(r),t):(e.enter(s),c(f))}function c(f){return f===o?(e.exit(s),l(o)):f===null?n(f):be(f)?(e.enter("lineEnding"),e.consume(f),e.exit("lineEnding"),Ve(e,c,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),u(f))}function u(f){return f===o||f===null||be(f)?(e.exit("chunkString"),c(f)):(e.consume(f),f===92?d:u)}function d(f){return f===o||f===92?(e.consume(f),u):u(f)}}function fc(e,t){let n;return r;function r(i){return be(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),n=!0,r):ze(i)?Ve(e,r,n?"linePrefix":"lineSuffix")(i):t(i)}}const FV={name:"definition",tokenize:UV},HV={partial:!0,tokenize:WV};function UV(e,t,n){const r=this;let i;return s;function s(p){return e.enter("definition"),o(p)}function o(p){return AR.call(r,e,a,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(p)}function a(p){return i=jr(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),p===58?(e.enter("definitionMarker"),e.consume(p),e.exit("definitionMarker"),l):n(p)}function l(p){return ot(p)?fc(e,c)(p):c(p)}function c(p){return MR(e,u,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(p)}function u(p){return e.attempt(HV,d,d)(p)}function d(p){return ze(p)?Ve(e,f,"whitespace")(p):f(p)}function f(p){return p===null||be(p)?(e.exit("definition"),r.parser.defined.push(i),t(p)):n(p)}}function WV(e,t,n){return r;function r(a){return ot(a)?fc(e,i)(a):n(a)}function i(a){return jR(e,s,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(a)}function s(a){return ze(a)?Ve(e,o,"whitespace")(a):o(a)}function o(a){return a===null||be(a)?t(a):n(a)}}const VV={name:"hardBreakEscape",tokenize:qV};function qV(e,t,n){return r;function r(s){return e.enter("hardBreakEscape"),e.consume(s),i}function i(s){return be(s)?(e.exit("hardBreakEscape"),t(s)):n(s)}}const KV={name:"headingAtx",resolve:GV,tokenize:XV};function GV(e,t){let n=e.length-2,r=3,i,s;return e[r][1].type==="whitespace"&&(r+=2),n-2>r&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(r===n-1||n-4>r&&e[n-2][1].type==="whitespace")&&(n-=r+1===n?2:4),n>r&&(i={type:"atxHeadingText",start:e[r][1].start,end:e[n][1].end},s={type:"chunkText",start:e[r][1].start,end:e[n][1].end,contentType:"text"},tr(e,r,n-r+1,[["enter",i,t],["enter",s,t],["exit",s,t],["exit",i,t]])),e}function XV(e,t,n){let r=0;return i;function i(u){return e.enter("atxHeading"),s(u)}function s(u){return e.enter("atxHeadingSequence"),o(u)}function o(u){return u===35&&r++<6?(e.consume(u),o):u===null||ot(u)?(e.exit("atxHeadingSequence"),a(u)):n(u)}function a(u){return u===35?(e.enter("atxHeadingSequence"),l(u)):u===null||be(u)?(e.exit("atxHeading"),t(u)):ze(u)?Ve(e,a,"whitespace")(u):(e.enter("atxHeadingText"),c(u))}function l(u){return u===35?(e.consume(u),l):(e.exit("atxHeadingSequence"),a(u))}function c(u){return u===null||u===35||ot(u)?(e.exit("atxHeadingText"),a(u)):(e.consume(u),c)}}const YV=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],LS=["pre","script","style","textarea"],ZV={concrete:!0,name:"htmlFlow",resolveTo:eq,tokenize:tq},QV={partial:!0,tokenize:rq},JV={partial:!0,tokenize:nq};function eq(e){let t=e.length;for(;t--&&!(e[t][0]==="enter"&&e[t][1].type==="htmlFlow"););return t>1&&e[t-2][1].type==="linePrefix"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function tq(e,t,n){const r=this;let i,s,o,a,l;return c;function c(A){return u(A)}function u(A){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(A),d}function d(A){return A===33?(e.consume(A),f):A===47?(e.consume(A),s=!0,v):A===63?(e.consume(A),i=3,r.interrupt?t:E):Cn(A)?(e.consume(A),o=String.fromCharCode(A),b):n(A)}function f(A){return A===45?(e.consume(A),i=2,p):A===91?(e.consume(A),i=5,a=0,m):Cn(A)?(e.consume(A),i=4,r.interrupt?t:E):n(A)}function p(A){return A===45?(e.consume(A),r.interrupt?t:E):n(A)}function m(A){const re="CDATA[";return A===re.charCodeAt(a++)?(e.consume(A),a===re.length?r.interrupt?t:R:m):n(A)}function v(A){return Cn(A)?(e.consume(A),o=String.fromCharCode(A),b):n(A)}function b(A){if(A===null||A===47||A===62||ot(A)){const re=A===47,oe=o.toLowerCase();return!re&&!s&&LS.includes(oe)?(i=1,r.interrupt?t(A):R(A)):YV.includes(o.toLowerCase())?(i=6,re?(e.consume(A),x):r.interrupt?t(A):R(A)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(A):s?_(A):y(A))}return A===45||yn(A)?(e.consume(A),o+=String.fromCharCode(A),b):n(A)}function x(A){return A===62?(e.consume(A),r.interrupt?t:R):n(A)}function _(A){return ze(A)?(e.consume(A),_):P(A)}function y(A){return A===47?(e.consume(A),P):A===58||A===95||Cn(A)?(e.consume(A),w):ze(A)?(e.consume(A),y):P(A)}function w(A){return A===45||A===46||A===58||A===95||yn(A)?(e.consume(A),w):S(A)}function S(A){return A===61?(e.consume(A),C):ze(A)?(e.consume(A),S):y(A)}function C(A){return A===null||A===60||A===61||A===62||A===96?n(A):A===34||A===39?(e.consume(A),l=A,N):ze(A)?(e.consume(A),C):T(A)}function N(A){return A===l?(e.consume(A),l=null,M):A===null||be(A)?n(A):(e.consume(A),N)}function T(A){return A===null||A===34||A===39||A===47||A===60||A===61||A===62||A===96||ot(A)?S(A):(e.consume(A),T)}function M(A){return A===47||A===62||ze(A)?y(A):n(A)}function P(A){return A===62?(e.consume(A),D):n(A)}function D(A){return A===null||be(A)?R(A):ze(A)?(e.consume(A),D):n(A)}function R(A){return A===45&&i===2?(e.consume(A),$):A===60&&i===1?(e.consume(A),F):A===62&&i===4?(e.consume(A),H):A===63&&i===3?(e.consume(A),E):A===93&&i===5?(e.consume(A),B):be(A)&&(i===6||i===7)?(e.exit("htmlFlowData"),e.check(QV,q,I)(A)):A===null||be(A)?(e.exit("htmlFlowData"),I(A)):(e.consume(A),R)}function I(A){return e.check(JV,O,q)(A)}function O(A){return e.enter("lineEnding"),e.consume(A),e.exit("lineEnding"),z}function z(A){return A===null||be(A)?I(A):(e.enter("htmlFlowData"),R(A))}function $(A){return A===45?(e.consume(A),E):R(A)}function F(A){return A===47?(e.consume(A),o="",L):R(A)}function L(A){if(A===62){const re=o.toLowerCase();return LS.includes(re)?(e.consume(A),H):R(A)}return Cn(A)&&o.length<8?(e.consume(A),o+=String.fromCharCode(A),L):R(A)}function B(A){return A===93?(e.consume(A),E):R(A)}function E(A){return A===62?(e.consume(A),H):A===45&&i===2?(e.consume(A),E):R(A)}function H(A){return A===null||be(A)?(e.exit("htmlFlowData"),q(A)):(e.consume(A),H)}function q(A){return e.exit("htmlFlow"),t(A)}}function nq(e,t,n){const r=this;return i;function i(o){return be(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),s):n(o)}function s(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}function rq(e,t,n){return r;function r(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),e.attempt(wu,t,n)}}const iq={name:"htmlText",tokenize:sq};function sq(e,t,n){const r=this;let i,s,o;return a;function a(E){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(E),l}function l(E){return E===33?(e.consume(E),c):E===47?(e.consume(E),S):E===63?(e.consume(E),y):Cn(E)?(e.consume(E),T):n(E)}function c(E){return E===45?(e.consume(E),u):E===91?(e.consume(E),s=0,m):Cn(E)?(e.consume(E),_):n(E)}function u(E){return E===45?(e.consume(E),p):n(E)}function d(E){return E===null?n(E):E===45?(e.consume(E),f):be(E)?(o=d,F(E)):(e.consume(E),d)}function f(E){return E===45?(e.consume(E),p):d(E)}function p(E){return E===62?$(E):E===45?f(E):d(E)}function m(E){const H="CDATA[";return E===H.charCodeAt(s++)?(e.consume(E),s===H.length?v:m):n(E)}function v(E){return E===null?n(E):E===93?(e.consume(E),b):be(E)?(o=v,F(E)):(e.consume(E),v)}function b(E){return E===93?(e.consume(E),x):v(E)}function x(E){return E===62?$(E):E===93?(e.consume(E),x):v(E)}function _(E){return E===null||E===62?$(E):be(E)?(o=_,F(E)):(e.consume(E),_)}function y(E){return E===null?n(E):E===63?(e.consume(E),w):be(E)?(o=y,F(E)):(e.consume(E),y)}function w(E){return E===62?$(E):y(E)}function S(E){return Cn(E)?(e.consume(E),C):n(E)}function C(E){return E===45||yn(E)?(e.consume(E),C):N(E)}function N(E){return be(E)?(o=N,F(E)):ze(E)?(e.consume(E),N):$(E)}function T(E){return E===45||yn(E)?(e.consume(E),T):E===47||E===62||ot(E)?M(E):n(E)}function M(E){return E===47?(e.consume(E),$):E===58||E===95||Cn(E)?(e.consume(E),P):be(E)?(o=M,F(E)):ze(E)?(e.consume(E),M):$(E)}function P(E){return E===45||E===46||E===58||E===95||yn(E)?(e.consume(E),P):D(E)}function D(E){return E===61?(e.consume(E),R):be(E)?(o=D,F(E)):ze(E)?(e.consume(E),D):M(E)}function R(E){return E===null||E===60||E===61||E===62||E===96?n(E):E===34||E===39?(e.consume(E),i=E,I):be(E)?(o=R,F(E)):ze(E)?(e.consume(E),R):(e.consume(E),O)}function I(E){return E===i?(e.consume(E),i=void 0,z):E===null?n(E):be(E)?(o=I,F(E)):(e.consume(E),I)}function O(E){return E===null||E===34||E===39||E===60||E===61||E===96?n(E):E===47||E===62||ot(E)?M(E):(e.consume(E),O)}function z(E){return E===47||E===62||ot(E)?M(E):n(E)}function $(E){return E===62?(e.consume(E),e.exit("htmlTextData"),e.exit("htmlText"),t):n(E)}function F(E){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(E),e.exit("lineEnding"),L}function L(E){return ze(E)?Ve(e,B,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(E):B(E)}function B(E){return e.enter("htmlTextData"),o(E)}}const by={name:"labelEnd",resolveAll:cq,resolveTo:uq,tokenize:dq},oq={tokenize:hq},aq={tokenize:fq},lq={tokenize:pq};function cq(e){let t=-1;const n=[];for(;++t<e.length;){const r=e[t][1];if(n.push(e[t]),r.type==="labelImage"||r.type==="labelLink"||r.type==="labelEnd"){const i=r.type==="labelImage"?4:2;r.type="data",t+=i}}return e.length!==n.length&&tr(e,0,e.length,n),e}function uq(e,t){let n=e.length,r=0,i,s,o,a;for(;n--;)if(i=e[n][1],s){if(i.type==="link"||i.type==="labelLink"&&i._inactive)break;e[n][0]==="enter"&&i.type==="labelLink"&&(i._inactive=!0)}else if(o){if(e[n][0]==="enter"&&(i.type==="labelImage"||i.type==="labelLink")&&!i._balanced&&(s=n,i.type!=="labelLink")){r=2;break}}else i.type==="labelEnd"&&(o=n);const l={type:e[s][1].type==="labelLink"?"link":"image",start:{...e[s][1].start},end:{...e[e.length-1][1].end}},c={type:"label",start:{...e[s][1].start},end:{...e[o][1].end}},u={type:"labelText",start:{...e[s+r+2][1].end},end:{...e[o-2][1].start}};return a=[["enter",l,t],["enter",c,t]],a=mr(a,e.slice(s+1,s+r+3)),a=mr(a,[["enter",u,t]]),a=mr(a,mp(t.parser.constructs.insideSpan.null,e.slice(s+r+4,o-3),t)),a=mr(a,[["exit",u,t],e[o-2],e[o-1],["exit",c,t]]),a=mr(a,e.slice(o+1)),a=mr(a,[["exit",l,t]]),tr(e,s,e.length,a),e}function dq(e,t,n){const r=this;let i=r.events.length,s,o;for(;i--;)if((r.events[i][1].type==="labelImage"||r.events[i][1].type==="labelLink")&&!r.events[i][1]._balanced){s=r.events[i][1];break}return a;function a(f){return s?s._inactive?d(f):(o=r.parser.defined.includes(jr(r.sliceSerialize({start:s.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(f),e.exit("labelMarker"),e.exit("labelEnd"),l):n(f)}function l(f){return f===40?e.attempt(oq,u,o?u:d)(f):f===91?e.attempt(aq,u,o?c:d)(f):o?u(f):d(f)}function c(f){return e.attempt(lq,u,d)(f)}function u(f){return t(f)}function d(f){return s._balanced=!0,n(f)}}function hq(e,t,n){return r;function r(d){return e.enter("resource"),e.enter("resourceMarker"),e.consume(d),e.exit("resourceMarker"),i}function i(d){return ot(d)?fc(e,s)(d):s(d)}function s(d){return d===41?u(d):MR(e,o,a,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(d)}function o(d){return ot(d)?fc(e,l)(d):u(d)}function a(d){return n(d)}function l(d){return d===34||d===39||d===40?jR(e,c,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(d):u(d)}function c(d){return ot(d)?fc(e,u)(d):u(d)}function u(d){return d===41?(e.enter("resourceMarker"),e.consume(d),e.exit("resourceMarker"),e.exit("resource"),t):n(d)}}function fq(e,t,n){const r=this;return i;function i(a){return AR.call(r,e,s,o,"reference","referenceMarker","referenceString")(a)}function s(a){return r.parser.defined.includes(jr(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(a):n(a)}function o(a){return n(a)}}function pq(e,t,n){return r;function r(s){return e.enter("reference"),e.enter("referenceMarker"),e.consume(s),e.exit("referenceMarker"),i}function i(s){return s===93?(e.enter("referenceMarker"),e.consume(s),e.exit("referenceMarker"),e.exit("reference"),t):n(s)}}const mq={name:"labelStartImage",resolveAll:by.resolveAll,tokenize:gq};function gq(e,t,n){const r=this;return i;function i(a){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(a),e.exit("labelImageMarker"),s}function s(a){return a===91?(e.enter("labelMarker"),e.consume(a),e.exit("labelMarker"),e.exit("labelImage"),o):n(a)}function o(a){return a===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(a):t(a)}}const vq={name:"labelStartLink",resolveAll:by.resolveAll,tokenize:xq};function xq(e,t,n){const r=this;return i;function i(o){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(o),e.exit("labelMarker"),e.exit("labelLink"),s}function s(o){return o===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(o):t(o)}}const jm={name:"lineEnding",tokenize:_q};function _q(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),Ve(e,t,"linePrefix")}}const Jd={name:"thematicBreak",tokenize:yq};function yq(e,t,n){let r=0,i;return s;function s(c){return e.enter("thematicBreak"),o(c)}function o(c){return i=c,a(c)}function a(c){return c===i?(e.enter("thematicBreakSequence"),l(c)):r>=3&&(c===null||be(c))?(e.exit("thematicBreak"),t(c)):n(c)}function l(c){return c===i?(e.consume(c),r++,l):(e.exit("thematicBreakSequence"),ze(c)?Ve(e,a,"whitespace")(c):a(c))}}const zn={continuation:{tokenize:kq},exit:Eq,name:"list",tokenize:Sq},bq={partial:!0,tokenize:Nq},wq={partial:!0,tokenize:Cq};function Sq(e,t,n){const r=this,i=r.events[r.events.length-1];let s=i&&i[1].type==="linePrefix"?i[2].sliceSerialize(i[1],!0).length:0,o=0;return a;function a(p){const m=r.containerState.type||(p===42||p===43||p===45?"listUnordered":"listOrdered");if(m==="listUnordered"?!r.containerState.marker||p===r.containerState.marker:v0(p)){if(r.containerState.type||(r.containerState.type=m,e.enter(m,{_container:!0})),m==="listUnordered")return e.enter("listItemPrefix"),p===42||p===45?e.check(Jd,n,c)(p):c(p);if(!r.interrupt||p===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),l(p)}return n(p)}function l(p){return v0(p)&&++o<10?(e.consume(p),l):(!r.interrupt||o<2)&&(r.containerState.marker?p===r.containerState.marker:p===41||p===46)?(e.exit("listItemValue"),c(p)):n(p)}function c(p){return e.enter("listItemMarker"),e.consume(p),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||p,e.check(wu,r.interrupt?n:u,e.attempt(bq,f,d))}function u(p){return r.containerState.initialBlankLine=!0,s++,f(p)}function d(p){return ze(p)?(e.enter("listItemPrefixWhitespace"),e.consume(p),e.exit("listItemPrefixWhitespace"),f):n(p)}function f(p){return r.containerState.size=s+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(p)}}function kq(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(wu,i,s);function i(a){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,Ve(e,t,"listItemIndent",r.containerState.size+1)(a)}function s(a){return r.containerState.furtherBlankLines||!ze(a)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(a)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(wq,t,o)(a))}function o(a){return r.containerState._closeFlow=!0,r.interrupt=void 0,Ve(e,e.attempt(zn,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a)}}function Cq(e,t,n){const r=this;return Ve(e,i,"listItemIndent",r.containerState.size+1);function i(s){const o=r.events[r.events.length-1];return o&&o[1].type==="listItemIndent"&&o[2].sliceSerialize(o[1],!0).length===r.containerState.size?t(s):n(s)}}function Eq(e){e.exit(this.containerState.type)}function Nq(e,t,n){const r=this;return Ve(e,i,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function i(s){const o=r.events[r.events.length-1];return!ze(s)&&o&&o[1].type==="listItemPrefixWhitespace"?t(s):n(s)}}const DS={name:"setextUnderline",resolveTo:Tq,tokenize:Pq};function Tq(e,t){let n=e.length,r,i,s;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){r=n;break}e[n][1].type==="paragraph"&&(i=n)}else e[n][1].type==="content"&&e.splice(n,1),!s&&e[n][1].type==="definition"&&(s=n);const o={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type="setextHeadingText",s?(e.splice(i,0,["enter",o,t]),e.splice(s+1,0,["exit",e[r][1],t]),e[r][1].end={...e[s][1].end}):e[r][1]=o,e.push(["exit",o,t]),e}function Pq(e,t,n){const r=this;let i;return s;function s(c){let u=r.events.length,d;for(;u--;)if(r.events[u][1].type!=="lineEnding"&&r.events[u][1].type!=="linePrefix"&&r.events[u][1].type!=="content"){d=r.events[u][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||d)?(e.enter("setextHeadingLine"),i=c,o(c)):n(c)}function o(c){return e.enter("setextHeadingLineSequence"),a(c)}function a(c){return c===i?(e.consume(c),a):(e.exit("setextHeadingLineSequence"),ze(c)?Ve(e,l,"lineSuffix")(c):l(c))}function l(c){return c===null||be(c)?(e.exit("setextHeadingLine"),t(c)):n(c)}}const Iq={tokenize:Rq};function Rq(e){const t=this,n=e.attempt(wu,r,e.attempt(this.parser.constructs.flowInitial,i,Ve(e,e.attempt(this.parser.constructs.flow,i,e.attempt(DV,i)),"linePrefix")));return n;function r(s){if(s===null){e.consume(s);return}return e.enter("lineEndingBlank"),e.consume(s),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function i(s){if(s===null){e.consume(s);return}return e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const Mq={resolveAll:DR()},Aq=LR("string"),jq=LR("text");function LR(e){return{resolveAll:DR(e==="text"?Lq:void 0),tokenize:t};function t(n){const r=this,i=this.parser.constructs[e],s=n.attempt(i,o,a);return o;function o(u){return c(u)?s(u):a(u)}function a(u){if(u===null){n.consume(u);return}return n.enter("data"),n.consume(u),l}function l(u){return c(u)?(n.exit("data"),s(u)):(n.consume(u),l)}function c(u){if(u===null)return!0;const d=i[u];let f=-1;if(d)for(;++f<d.length;){const p=d[f];if(!p.previous||p.previous.call(r,r.previous))return!0}return!1}}}function DR(e){return t;function t(n,r){let i=-1,s;for(;++i<=n.length;)s===void 0?n[i]&&n[i][1].type==="data"&&(s=i,i++):(!n[i]||n[i][1].type!=="data")&&(i!==s+2&&(n[s][1].end=n[i-1][1].end,n.splice(s+2,i-s-2),i=s+2),s=void 0);return e?e(n,r):n}}function Lq(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type==="lineEnding")&&e[n-1][1].type==="data"){const r=e[n-1][1],i=t.sliceStream(r);let s=i.length,o=-1,a=0,l;for(;s--;){const c=i[s];if(typeof c=="string"){for(o=c.length;c.charCodeAt(o-1)===32;)a++,o--;if(o)break;o=-1}else if(c===-2)l=!0,a++;else if(c!==-1){s++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(a=0),a){const c={type:n===e.length||l||a<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:s?o:r.start._bufferIndex+o,_index:r.start._index+s,line:r.end.line,column:r.end.column-a,offset:r.end.offset-a},end:{...r.end}};r.end={...c.start},r.start.offset===r.end.offset?Object.assign(r,c):(e.splice(n,0,["enter",c,t],["exit",c,t]),n+=2)}n++}return e}const Dq={42:zn,43:zn,45:zn,48:zn,49:zn,50:zn,51:zn,52:zn,53:zn,54:zn,55:zn,56:zn,57:zn,62:TR},Oq={91:FV},Bq={[-2]:Am,[-1]:Am,32:Am},zq={35:KV,42:Jd,45:[DS,Jd],60:ZV,61:DS,95:Jd,96:jS,126:jS},$q={38:IR,92:PR},Fq={[-5]:jm,[-4]:jm,[-3]:jm,33:mq,38:IR,42:x0,60:[vV,iq],91:vq,92:[VV,PR],93:by,95:x0,96:IV},Hq={null:[x0,Mq]},Uq={null:[42,95]},Wq={null:[]},Vq=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:Uq,contentInitial:Oq,disable:Wq,document:Dq,flow:zq,flowInitial:Bq,insideSpan:Hq,string:$q,text:Fq},Symbol.toStringTag,{value:"Module"}));function qq(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const i={},s=[];let o=[],a=[];const l={attempt:N(S),check:N(C),consume:_,enter:y,exit:w,interrupt:N(C,{interrupt:!0})},c={code:null,containerState:{},defineSkip:v,events:[],now:m,parser:e,previous:null,sliceSerialize:f,sliceStream:p,write:d};let u=t.tokenize.call(c,l);return t.resolveAll&&s.push(t),c;function d(D){return o=mr(o,D),b(),o[o.length-1]!==null?[]:(T(t,0),c.events=mp(s,c.events,c),c.events)}function f(D,R){return Gq(p(D),R)}function p(D){return Kq(o,D)}function m(){const{_bufferIndex:D,_index:R,line:I,column:O,offset:z}=r;return{_bufferIndex:D,_index:R,line:I,column:O,offset:z}}function v(D){i[D.line]=D.column,P()}function b(){let D;for(;r._index<o.length;){const R=o[r._index];if(typeof R=="string")for(D=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===D&&r._bufferIndex<R.length;)x(R.charCodeAt(r._bufferIndex));else x(R)}}function x(D){u=u(D)}function _(D){be(D)?(r.line++,r.column=1,r.offset+=D===-3?2:1,P()):D!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),c.previous=D}function y(D,R){const I=R||{};return I.type=D,I.start=m(),c.events.push(["enter",I,c]),a.push(I),I}function w(D){const R=a.pop();return R.end=m(),c.events.push(["exit",R,c]),R}function S(D,R){T(D,R.from)}function C(D,R){R.restore()}function N(D,R){return I;function I(O,z,$){let F,L,B,E;return Array.isArray(O)?q(O):"tokenize"in O?q([O]):H(O);function H(V){return pe;function pe(Oe){const ie=Oe!==null&&V[Oe],Ae=Oe!==null&&V.null,Fe=[...Array.isArray(ie)?ie:ie?[ie]:[],...Array.isArray(Ae)?Ae:Ae?[Ae]:[]];return q(Fe)(Oe)}}function q(V){return F=V,L=0,V.length===0?$:A(V[L])}function A(V){return pe;function pe(Oe){return E=M(),B=V,V.partial||(c.currentConstruct=V),V.name&&c.parser.constructs.disable.null.includes(V.name)?oe():V.tokenize.call(R?Object.assign(Object.create(c),R):c,l,re,oe)(Oe)}}function re(V){return D(B,E),z}function oe(V){return E.restore(),++L<F.length?A(F[L]):$}}}function T(D,R){D.resolveAll&&!s.includes(D)&&s.push(D),D.resolve&&tr(c.events,R,c.events.length-R,D.resolve(c.events.slice(R),c)),D.resolveTo&&(c.events=D.resolveTo(c.events,c))}function M(){const D=m(),R=c.previous,I=c.currentConstruct,O=c.events.length,z=Array.from(a);return{from:O,restore:$};function $(){r=D,c.previous=R,c.currentConstruct=I,c.events.length=O,a=z,P()}}function P(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function Kq(e,t){const n=t.start._index,r=t.start._bufferIndex,i=t.end._index,s=t.end._bufferIndex;let o;if(n===i)o=[e[n].slice(r,s)];else{if(o=e.slice(n,i),r>-1){const a=o[0];typeof a=="string"?o[0]=a.slice(r):o.shift()}s>0&&o.push(e[i].slice(0,s))}return o}function Gq(e,t){let n=-1;const r=[];let i;for(;++n<e.length;){const s=e[n];let o;if(typeof s=="string")o=s;else switch(s){case-5:{o="\r";break}case-4:{o=`
|
|
497
497
|
`;break}case-3:{o=`\r
|
|
498
498
|
`;break}case-2:{o=t?" ":" ";break}case-1:{if(!t&&i)continue;o=" ";break}default:o=String.fromCharCode(s)}i=s===-2,r.push(o)}return r.join("")}function Xq(e){const r={constructs:ER([Vq,...(e||{}).extensions||[]]),content:i(uV),defined:[],document:i(hV),flow:i(Iq),lazy:{},string:i(Aq),text:i(jq)};return r;function i(s){return o;function o(a){return qq(r,s,a)}}}function Yq(e){for(;!RR(e););return e}const OS=/[\0\t\n\r]/g;function Zq(){let e=1,t="",n=!0,r;return i;function i(s,o,a){const l=[];let c,u,d,f,p;for(s=t+(typeof s=="string"?s.toString():new TextDecoder(o||void 0).decode(s)),d=0,t="",n&&(s.charCodeAt(0)===65279&&d++,n=void 0);d<s.length;){if(OS.lastIndex=d,c=OS.exec(s),f=c&&c.index!==void 0?c.index:s.length,p=s.charCodeAt(f),!c){t=s.slice(d);break}if(p===10&&d===f&&r)l.push(-3),r=void 0;else switch(r&&(l.push(-5),r=void 0),d<f&&(l.push(s.slice(d,f)),e+=f-d),p){case 0:{l.push(65533),e++;break}case 9:{for(u=Math.ceil(e/4)*4,l.push(-2);e++<u;)l.push(-1);break}case 10:{l.push(-4),e=1;break}default:r=!0,e=1}d=f+1}return a&&(r&&l.push(-5),t&&l.push(t),l.push(null)),l}}const Qq=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function Jq(e){return e.replace(Qq,eK)}function eK(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const i=n.charCodeAt(1),s=i===120||i===88;return NR(n.slice(s?2:1),s?16:10)}return yy(n)||e}const OR={}.hasOwnProperty;function tK(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),nK(n)(Yq(Xq(n).document().write(Zq()(e,t,!0))))}function nK(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:s(Bt),autolinkProtocol:M,autolinkEmail:M,atxHeading:s(Gt),blockQuote:s(Ae),characterEscape:M,characterReference:M,codeFenced:s(Fe),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:s(Fe,o),codeText:s(We,o),codeTextData:M,data:M,codeFlowValue:M,definition:s(ge),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:s(qe),hardBreakEscape:s(wt),hardBreakTrailing:s(wt),htmlFlow:s(Rt,o),htmlFlowData:M,htmlText:s(Rt,o),htmlTextData:M,image:s(ln),label:o,link:s(Bt),listItem:s(Ue),listItemValue:f,listOrdered:s(at,d),listUnordered:s(at),paragraph:s(nt),reference:A,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:s(Gt),strong:s(mt),thematicBreak:s(pn)},exit:{atxHeading:l(),atxHeadingSequence:S,autolink:l(),autolinkEmail:ie,autolinkProtocol:Oe,blockQuote:l(),characterEscapeValue:P,characterReferenceMarkerHexadecimal:oe,characterReferenceMarkerNumeric:oe,characterReferenceValue:V,characterReference:pe,codeFenced:l(b),codeFencedFence:v,codeFencedFenceInfo:p,codeFencedFenceMeta:m,codeFlowValue:P,codeIndented:l(x),codeText:l(z),codeTextData:P,data:P,definition:l(),definitionDestinationString:w,definitionLabelString:_,definitionTitleString:y,emphasis:l(),hardBreakEscape:l(R),hardBreakTrailing:l(R),htmlFlow:l(I),htmlFlowData:P,htmlText:l(O),htmlTextData:P,image:l(F),label:B,labelText:L,lineEnding:D,link:l($),listItem:l(),listOrdered:l(),listUnordered:l(),paragraph:l(),referenceString:re,resourceDestinationString:E,resourceTitleString:H,resource:q,setextHeading:l(T),setextHeadingLineSequence:N,setextHeadingText:C,strong:l(),thematicBreak:l()}};BR(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(U){let Q={type:"root",children:[]};const ve={stack:[Q],tokenStack:[],config:t,enter:a,exit:c,buffer:o,resume:u,data:n},Se=[];let J=-1;for(;++J<U.length;)if(U[J][1].type==="listOrdered"||U[J][1].type==="listUnordered")if(U[J][0]==="enter")Se.push(J);else{const Ye=Se.pop();J=i(U,Ye,J)}for(J=-1;++J<U.length;){const Ye=t[U[J][0]];OR.call(Ye,U[J][1].type)&&Ye[U[J][1].type].call(Object.assign({sliceSerialize:U[J][2].sliceSerialize},ve),U[J][1])}if(ve.tokenStack.length>0){const Ye=ve.tokenStack[ve.tokenStack.length-1];(Ye[1]||BS).call(ve,void 0,Ye[0])}for(Q.position={start:Zi(U.length>0?U[0][1].start:{line:1,column:1,offset:0}),end:Zi(U.length>0?U[U.length-2][1].end:{line:1,column:1,offset:0})},J=-1;++J<t.transforms.length;)Q=t.transforms[J](Q)||Q;return Q}function i(U,Q,ve){let Se=Q-1,J=-1,Ye=!1,Yt,Zt,ue,Te;for(;++Se<=ve;){const Je=U[Se];switch(Je[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{Je[0]==="enter"?J++:J--,Te=void 0;break}case"lineEndingBlank":{Je[0]==="enter"&&(Yt&&!Te&&!J&&!ue&&(ue=Se),Te=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:Te=void 0}if(!J&&Je[0]==="enter"&&Je[1].type==="listItemPrefix"||J===-1&&Je[0]==="exit"&&(Je[1].type==="listUnordered"||Je[1].type==="listOrdered")){if(Yt){let Ln=Se;for(Zt=void 0;Ln--;){const Qt=U[Ln];if(Qt[1].type==="lineEnding"||Qt[1].type==="lineEndingBlank"){if(Qt[0]==="exit")continue;Zt&&(U[Zt][1].type="lineEndingBlank",Ye=!0),Qt[1].type="lineEnding",Zt=Ln}else if(!(Qt[1].type==="linePrefix"||Qt[1].type==="blockQuotePrefix"||Qt[1].type==="blockQuotePrefixWhitespace"||Qt[1].type==="blockQuoteMarker"||Qt[1].type==="listItemIndent"))break}ue&&(!Zt||ue<Zt)&&(Yt._spread=!0),Yt.end=Object.assign({},Zt?U[Zt][1].start:Je[1].end),U.splice(Zt||Se,0,["exit",Yt,Je[2]]),Se++,ve++}if(Je[1].type==="listItemPrefix"){const Ln={type:"listItem",_spread:!1,start:Object.assign({},Je[1].start),end:void 0};Yt=Ln,U.splice(Se,0,["enter",Ln,Je[2]]),Se++,ve++,ue=void 0,Te=!0}}}return U[Q][1]._spread=Ye,ve}function s(U,Q){return ve;function ve(Se){a.call(this,U(Se),Se),Q&&Q.call(this,Se)}}function o(){this.stack.push({type:"fragment",children:[]})}function a(U,Q,ve){this.stack[this.stack.length-1].children.push(U),this.stack.push(U),this.tokenStack.push([Q,ve||void 0]),U.position={start:Zi(Q.start),end:void 0}}function l(U){return Q;function Q(ve){U&&U.call(this,ve),c.call(this,ve)}}function c(U,Q){const ve=this.stack.pop(),Se=this.tokenStack.pop();if(Se)Se[0].type!==U.type&&(Q?Q.call(this,U,Se[0]):(Se[1]||BS).call(this,U,Se[0]));else throw new Error("Cannot close `"+U.type+"` ("+hc({start:U.start,end:U.end})+"): it’s not open");ve.position.end=Zi(U.end)}function u(){return _y(this.stack.pop())}function d(){this.data.expectingFirstListItemValue=!0}function f(U){if(this.data.expectingFirstListItemValue){const Q=this.stack[this.stack.length-2];Q.start=Number.parseInt(this.sliceSerialize(U),10),this.data.expectingFirstListItemValue=void 0}}function p(){const U=this.resume(),Q=this.stack[this.stack.length-1];Q.lang=U}function m(){const U=this.resume(),Q=this.stack[this.stack.length-1];Q.meta=U}function v(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function b(){const U=this.resume(),Q=this.stack[this.stack.length-1];Q.value=U.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function x(){const U=this.resume(),Q=this.stack[this.stack.length-1];Q.value=U.replace(/(\r?\n|\r)$/g,"")}function _(U){const Q=this.resume(),ve=this.stack[this.stack.length-1];ve.label=Q,ve.identifier=jr(this.sliceSerialize(U)).toLowerCase()}function y(){const U=this.resume(),Q=this.stack[this.stack.length-1];Q.title=U}function w(){const U=this.resume(),Q=this.stack[this.stack.length-1];Q.url=U}function S(U){const Q=this.stack[this.stack.length-1];if(!Q.depth){const ve=this.sliceSerialize(U).length;Q.depth=ve}}function C(){this.data.setextHeadingSlurpLineEnding=!0}function N(U){const Q=this.stack[this.stack.length-1];Q.depth=this.sliceSerialize(U).codePointAt(0)===61?1:2}function T(){this.data.setextHeadingSlurpLineEnding=void 0}function M(U){const ve=this.stack[this.stack.length-1].children;let Se=ve[ve.length-1];(!Se||Se.type!=="text")&&(Se=Xt(),Se.position={start:Zi(U.start),end:void 0},ve.push(Se)),this.stack.push(Se)}function P(U){const Q=this.stack.pop();Q.value+=this.sliceSerialize(U),Q.position.end=Zi(U.end)}function D(U){const Q=this.stack[this.stack.length-1];if(this.data.atHardBreak){const ve=Q.children[Q.children.length-1];ve.position.end=Zi(U.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(Q.type)&&(M.call(this,U),P.call(this,U))}function R(){this.data.atHardBreak=!0}function I(){const U=this.resume(),Q=this.stack[this.stack.length-1];Q.value=U}function O(){const U=this.resume(),Q=this.stack[this.stack.length-1];Q.value=U}function z(){const U=this.resume(),Q=this.stack[this.stack.length-1];Q.value=U}function $(){const U=this.stack[this.stack.length-1];if(this.data.inReference){const Q=this.data.referenceType||"shortcut";U.type+="Reference",U.referenceType=Q,delete U.url,delete U.title}else delete U.identifier,delete U.label;this.data.referenceType=void 0}function F(){const U=this.stack[this.stack.length-1];if(this.data.inReference){const Q=this.data.referenceType||"shortcut";U.type+="Reference",U.referenceType=Q,delete U.url,delete U.title}else delete U.identifier,delete U.label;this.data.referenceType=void 0}function L(U){const Q=this.sliceSerialize(U),ve=this.stack[this.stack.length-2];ve.label=Jq(Q),ve.identifier=jr(Q).toLowerCase()}function B(){const U=this.stack[this.stack.length-1],Q=this.resume(),ve=this.stack[this.stack.length-1];if(this.data.inReference=!0,ve.type==="link"){const Se=U.children;ve.children=Se}else ve.alt=Q}function E(){const U=this.resume(),Q=this.stack[this.stack.length-1];Q.url=U}function H(){const U=this.resume(),Q=this.stack[this.stack.length-1];Q.title=U}function q(){this.data.inReference=void 0}function A(){this.data.referenceType="collapsed"}function re(U){const Q=this.resume(),ve=this.stack[this.stack.length-1];ve.label=Q,ve.identifier=jr(this.sliceSerialize(U)).toLowerCase(),this.data.referenceType="full"}function oe(U){this.data.characterReferenceType=U.type}function V(U){const Q=this.sliceSerialize(U),ve=this.data.characterReferenceType;let Se;ve?(Se=NR(Q,ve==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):Se=yy(Q);const J=this.stack[this.stack.length-1];J.value+=Se}function pe(U){const Q=this.stack.pop();Q.position.end=Zi(U.end)}function Oe(U){P.call(this,U);const Q=this.stack[this.stack.length-1];Q.url=this.sliceSerialize(U)}function ie(U){P.call(this,U);const Q=this.stack[this.stack.length-1];Q.url="mailto:"+this.sliceSerialize(U)}function Ae(){return{type:"blockquote",children:[]}}function Fe(){return{type:"code",lang:null,meta:null,value:""}}function We(){return{type:"inlineCode",value:""}}function ge(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function qe(){return{type:"emphasis",children:[]}}function Gt(){return{type:"heading",depth:0,children:[]}}function wt(){return{type:"break"}}function Rt(){return{type:"html",value:""}}function ln(){return{type:"image",title:null,url:"",alt:null}}function Bt(){return{type:"link",title:null,url:"",children:[]}}function at(U){return{type:"list",ordered:U.type==="listOrdered",start:null,spread:U._spread,children:[]}}function Ue(U){return{type:"listItem",spread:U._spread,checked:null,children:[]}}function nt(){return{type:"paragraph",children:[]}}function mt(){return{type:"strong",children:[]}}function Xt(){return{type:"text",value:""}}function pn(){return{type:"thematicBreak"}}}function Zi(e){return{line:e.line,column:e.column,offset:e.offset}}function BR(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?BR(e,r):rK(e,r)}}function rK(e,t){let n;for(n in t)if(OR.call(t,n))switch(n){case"canContainEols":{const r=t[n];r&&e[n].push(...r);break}case"transforms":{const r=t[n];r&&e[n].push(...r);break}case"enter":case"exit":{const r=t[n];r&&Object.assign(e[n],r);break}}}function BS(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+hc({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+hc({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+hc({start:t.start,end:t.end})+") is still open")}function iK(e){const t=this;t.parser=n;function n(r){return tK(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function sK(e,t){const n={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function oK(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
|
|
@@ -523,7 +523,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
523
523
|
`))}function l(p,m,v,b){const x=v.enter("tableCell"),_=v.enter("phrasing"),y=v.containerPhrasing(p,{...b,before:s,after:s});return _(),x(),y}function c(p,m){return lX(p,{align:m,alignDelimiters:r,padding:n,stringLength:i})}function u(p,m,v){const b=p.children;let x=-1;const _=[],y=m.enter("table");for(;++x<b.length;)_[x]=d(b[x],m,v);return y(),_}function d(p,m,v){const b=p.children;let x=-1;const _=[],y=m.enter("tableRow");for(;++x<b.length;)_[x]=l(b[x],p,m,v);return y(),_}function f(p,m,v){let b=lM.inlineCode(p,m,v);return v.stack.includes("tableCell")&&(b=b.replace(/\|/g,"\\$&")),b}}function XX(){return{exit:{taskListCheckValueChecked:uk,taskListCheckValueUnchecked:uk,paragraph:ZX}}}function YX(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:QX}}}function uk(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function ZX(e){const t=this.stack[this.stack.length-2];if(t&&t.type==="listItem"&&typeof t.checked=="boolean"){const n=this.stack[this.stack.length-1];n.type;const r=n.children[0];if(r&&r.type==="text"){const i=t.children;let s=-1,o;for(;++s<i.length;){const a=i[s];if(a.type==="paragraph"){o=a;break}}o===n&&(r.value=r.value.slice(1),r.value.length===0?n.children.shift():n.position&&r.position&&typeof r.position.start.offset=="number"&&(r.position.start.column++,r.position.start.offset++,n.position.start=Object.assign({},r.position.start)))}}this.exit(e)}function QX(e,t,n,r){const i=e.children[0],s=typeof e.checked=="boolean"&&i&&i.type==="paragraph",o="["+(e.checked?"x":" ")+"] ",a=n.createTracker(r);s&&a.move(o);let l=lM.listItem(e,t,n,{...r,...a.current()});return s&&(l=l.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,c)),l;function c(u){return u+o}}function JX(){return[RG(),QG(),nX(),HX(),XX()]}function eY(e){return{extensions:[MG(),JG(e),rX(),GX(e),YX()]}}const tY={tokenize:aY,partial:!0},cM={tokenize:lY,partial:!0},uM={tokenize:cY,partial:!0},dM={tokenize:uY,partial:!0},nY={tokenize:dY,partial:!0},hM={name:"wwwAutolink",tokenize:sY,previous:pM},fM={name:"protocolAutolink",tokenize:oY,previous:mM},Ui={name:"emailAutolink",tokenize:iY,previous:gM},hi={};function rY(){return{text:hi}}let Us=48;for(;Us<123;)hi[Us]=Ui,Us++,Us===58?Us=65:Us===91&&(Us=97);hi[43]=Ui;hi[45]=Ui;hi[46]=Ui;hi[95]=Ui;hi[72]=[Ui,fM];hi[104]=[Ui,fM];hi[87]=[Ui,hM];hi[119]=[Ui,hM];function iY(e,t,n){const r=this;let i,s;return o;function o(d){return!S0(d)||!gM.call(r,r.previous)||Iy(r.events)?n(d):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),a(d))}function a(d){return S0(d)?(e.consume(d),a):d===64?(e.consume(d),l):n(d)}function l(d){return d===46?e.check(nY,u,c)(d):d===45||d===95||yn(d)?(s=!0,e.consume(d),l):u(d)}function c(d){return e.consume(d),i=!0,l}function u(d){return s&&i&&Cn(r.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(d)):n(d)}}function sY(e,t,n){const r=this;return i;function i(o){return o!==87&&o!==119||!pM.call(r,r.previous)||Iy(r.events)?n(o):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(tY,e.attempt(cM,e.attempt(uM,s),n),n)(o))}function s(o){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(o)}}function oY(e,t,n){const r=this;let i="",s=!1;return o;function o(d){return(d===72||d===104)&&mM.call(r,r.previous)&&!Iy(r.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),i+=String.fromCodePoint(d),e.consume(d),a):n(d)}function a(d){if(Cn(d)&&i.length<5)return i+=String.fromCodePoint(d),e.consume(d),a;if(d===58){const f=i.toLowerCase();if(f==="http"||f==="https")return e.consume(d),l}return n(d)}function l(d){return d===47?(e.consume(d),s?c:(s=!0,l)):n(d)}function c(d){return d===null||ef(d)||ot(d)||wo(d)||pp(d)?n(d):e.attempt(cM,e.attempt(uM,u),n)(d)}function u(d){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(d)}}function aY(e,t,n){let r=0;return i;function i(o){return(o===87||o===119)&&r<3?(r++,e.consume(o),i):o===46&&r===3?(e.consume(o),s):n(o)}function s(o){return o===null?n(o):t(o)}}function lY(e,t,n){let r,i,s;return o;function o(c){return c===46||c===95?e.check(dM,l,a)(c):c===null||ot(c)||wo(c)||c!==45&&pp(c)?l(c):(s=!0,e.consume(c),o)}function a(c){return c===95?r=!0:(i=r,r=void 0),e.consume(c),o}function l(c){return i||r||!s?n(c):t(c)}}function cY(e,t){let n=0,r=0;return i;function i(o){return o===40?(n++,e.consume(o),i):o===41&&r<n?s(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?e.check(dM,t,s)(o):o===null||ot(o)||wo(o)?t(o):(e.consume(o),i)}function s(o){return o===41&&r++,e.consume(o),i}}function uY(e,t,n){return r;function r(a){return a===33||a===34||a===39||a===41||a===42||a===44||a===46||a===58||a===59||a===63||a===95||a===126?(e.consume(a),r):a===38?(e.consume(a),s):a===93?(e.consume(a),i):a===60||a===null||ot(a)||wo(a)?t(a):n(a)}function i(a){return a===null||a===40||a===91||ot(a)||wo(a)?t(a):r(a)}function s(a){return Cn(a)?o(a):n(a)}function o(a){return a===59?(e.consume(a),r):Cn(a)?(e.consume(a),o):n(a)}}function dY(e,t,n){return r;function r(s){return e.consume(s),i}function i(s){return yn(s)?n(s):t(s)}}function pM(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||ot(e)}function mM(e){return!Cn(e)}function gM(e){return!(e===47||S0(e))}function S0(e){return e===43||e===45||e===46||e===95||yn(e)}function Iy(e){let t=e.length,n=!1;for(;t--;){const r=e[t][1];if((r.type==="labelLink"||r.type==="labelImage")&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const hY={tokenize:yY,partial:!0};function fY(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:vY,continuation:{tokenize:xY},exit:_Y}},text:{91:{name:"gfmFootnoteCall",tokenize:gY},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:pY,resolveTo:mY}}}}function pY(e,t,n){const r=this;let i=r.events.length;const s=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let o;for(;i--;){const l=r.events[i][1];if(l.type==="labelImage"){o=l;break}if(l.type==="gfmFootnoteCall"||l.type==="labelLink"||l.type==="label"||l.type==="image"||l.type==="link")break}return a;function a(l){if(!o||!o._balanced)return n(l);const c=jr(r.sliceSerialize({start:o.end,end:r.now()}));return c.codePointAt(0)!==94||!s.includes(c.slice(1))?n(l):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(l),e.exit("gfmFootnoteCallLabelMarker"),t(l))}}function mY(e,t){let n=e.length;for(;n--;)if(e[n][1].type==="labelImage"&&e[n][0]==="enter"){e[n][1];break}e[n+1][1].type="data",e[n+3][1].type="gfmFootnoteCallLabelMarker";const r={type:"gfmFootnoteCall",start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;const s={type:"gfmFootnoteCallString",start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:"chunkString",contentType:"string",start:Object.assign({},s.start),end:Object.assign({},s.end)},a=[e[n+1],e[n+2],["enter",r,t],e[n+3],e[n+4],["enter",i,t],["exit",i,t],["enter",s,t],["enter",o,t],["exit",o,t],["exit",s,t],e[e.length-2],e[e.length-1],["exit",r,t]];return e.splice(n,e.length-n+1,...a),e}function gY(e,t,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s=0,o;return a;function a(d){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(d),e.exit("gfmFootnoteCallLabelMarker"),l}function l(d){return d!==94?n(d):(e.enter("gfmFootnoteCallMarker"),e.consume(d),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",c)}function c(d){if(s>999||d===93&&!o||d===null||d===91||ot(d))return n(d);if(d===93){e.exit("chunkString");const f=e.exit("gfmFootnoteCallString");return i.includes(jr(r.sliceSerialize(f)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(d),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(d)}return ot(d)||(o=!0),s++,e.consume(d),d===92?u:c}function u(d){return d===91||d===92||d===93?(e.consume(d),s++,c):c(d)}}function vY(e,t,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s,o=0,a;return l;function l(m){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(m),e.exit("gfmFootnoteDefinitionLabelMarker"),c}function c(m){return m===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(m),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",u):n(m)}function u(m){if(o>999||m===93&&!a||m===null||m===91||ot(m))return n(m);if(m===93){e.exit("chunkString");const v=e.exit("gfmFootnoteDefinitionLabelString");return s=jr(r.sliceSerialize(v)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(m),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),f}return ot(m)||(a=!0),o++,e.consume(m),m===92?d:u}function d(m){return m===91||m===92||m===93?(e.consume(m),o++,u):u(m)}function f(m){return m===58?(e.enter("definitionMarker"),e.consume(m),e.exit("definitionMarker"),i.includes(s)||i.push(s),Ve(e,p,"gfmFootnoteDefinitionWhitespace")):n(m)}function p(m){return t(m)}}function xY(e,t,n){return e.check(wu,t,e.attempt(hY,t,n))}function _Y(e){e.exit("gfmFootnoteDefinition")}function yY(e,t,n){const r=this;return Ve(e,i,"gfmFootnoteDefinitionIndent",5);function i(s){const o=r.events[r.events.length-1];return o&&o[1].type==="gfmFootnoteDefinitionIndent"&&o[2].sliceSerialize(o[1],!0).length===4?t(s):n(s)}}function bY(e){let n=(e||{}).singleTilde;const r={name:"strikethrough",tokenize:s,resolveAll:i};return n==null&&(n=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function i(o,a){let l=-1;for(;++l<o.length;)if(o[l][0]==="enter"&&o[l][1].type==="strikethroughSequenceTemporary"&&o[l][1]._close){let c=l;for(;c--;)if(o[c][0]==="exit"&&o[c][1].type==="strikethroughSequenceTemporary"&&o[c][1]._open&&o[l][1].end.offset-o[l][1].start.offset===o[c][1].end.offset-o[c][1].start.offset){o[l][1].type="strikethroughSequence",o[c][1].type="strikethroughSequence";const u={type:"strikethrough",start:Object.assign({},o[c][1].start),end:Object.assign({},o[l][1].end)},d={type:"strikethroughText",start:Object.assign({},o[c][1].end),end:Object.assign({},o[l][1].start)},f=[["enter",u,a],["enter",o[c][1],a],["exit",o[c][1],a],["enter",d,a]],p=a.parser.constructs.insideSpan.null;p&&tr(f,f.length,0,mp(p,o.slice(c+1,l),a)),tr(f,f.length,0,[["exit",d,a],["enter",o[l][1],a],["exit",o[l][1],a],["exit",u,a]]),tr(o,c-1,l-c+3,f),l=c+f.length-2;break}}for(l=-1;++l<o.length;)o[l][1].type==="strikethroughSequenceTemporary"&&(o[l][1].type="data");return o}function s(o,a,l){const c=this.previous,u=this.events;let d=0;return f;function f(m){return c===126&&u[u.length-1][1].type!=="characterEscape"?l(m):(o.enter("strikethroughSequenceTemporary"),p(m))}function p(m){const v=Ua(c);if(m===126)return d>1?l(m):(o.consume(m),d++,p);if(d<2&&!n)return l(m);const b=o.exit("strikethroughSequenceTemporary"),x=Ua(m);return b._open=!x||x===2&&!!v,b._close=!v||v===2&&!!x,a(m)}}}class wY{constructor(){this.map=[]}add(t,n,r){SY(this,t,n,r)}consume(t){if(this.map.sort(function(s,o){return s[0]-o[0]}),this.map.length===0)return;let n=this.map.length;const r=[];for(;n>0;)n-=1,r.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];r.push(t.slice()),t.length=0;let i=r.pop();for(;i;){for(const s of i)t.push(s);i=r.pop()}this.map.length=0}}function SY(e,t,n,r){let i=0;if(!(n===0&&r.length===0)){for(;i<e.map.length;){if(e.map[i][0]===t){e.map[i][1]+=n,e.map[i][2].push(...r);return}i+=1}e.map.push([t,n,r])}}function kY(e,t){let n=!1;const r=[];for(;t<e.length;){const i=e[t];if(n){if(i[0]==="enter")i[1].type==="tableContent"&&r.push(e[t+1][1].type==="tableDelimiterMarker"?"left":"none");else if(i[1].type==="tableContent"){if(e[t-1][1].type==="tableDelimiterMarker"){const s=r.length-1;r[s]=r[s]==="left"?"center":"right"}}else if(i[1].type==="tableDelimiterRow")break}else i[0]==="enter"&&i[1].type==="tableDelimiterRow"&&(n=!0);t+=1}return r}function CY(){return{flow:{null:{name:"table",tokenize:EY,resolveAll:NY}}}}function EY(e,t,n){const r=this;let i=0,s=0,o;return a;function a(P){let D=r.events.length-1;for(;D>-1;){const O=r.events[D][1].type;if(O==="lineEnding"||O==="linePrefix")D--;else break}const R=D>-1?r.events[D][1].type:null,I=R==="tableHead"||R==="tableRow"?C:l;return I===C&&r.parser.lazy[r.now().line]?n(P):I(P)}function l(P){return e.enter("tableHead"),e.enter("tableRow"),c(P)}function c(P){return P===124||(o=!0,s+=1),u(P)}function u(P){return P===null?n(P):be(P)?s>1?(s=0,r.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(P),e.exit("lineEnding"),p):n(P):ze(P)?Ve(e,u,"whitespace")(P):(s+=1,o&&(o=!1,i+=1),P===124?(e.enter("tableCellDivider"),e.consume(P),e.exit("tableCellDivider"),o=!0,u):(e.enter("data"),d(P)))}function d(P){return P===null||P===124||ot(P)?(e.exit("data"),u(P)):(e.consume(P),P===92?f:d)}function f(P){return P===92||P===124?(e.consume(P),d):d(P)}function p(P){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(P):(e.enter("tableDelimiterRow"),o=!1,ze(P)?Ve(e,m,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(P):m(P))}function m(P){return P===45||P===58?b(P):P===124?(o=!0,e.enter("tableCellDivider"),e.consume(P),e.exit("tableCellDivider"),v):S(P)}function v(P){return ze(P)?Ve(e,b,"whitespace")(P):b(P)}function b(P){return P===58?(s+=1,o=!0,e.enter("tableDelimiterMarker"),e.consume(P),e.exit("tableDelimiterMarker"),x):P===45?(s+=1,x(P)):P===null||be(P)?w(P):S(P)}function x(P){return P===45?(e.enter("tableDelimiterFiller"),_(P)):S(P)}function _(P){return P===45?(e.consume(P),_):P===58?(o=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(P),e.exit("tableDelimiterMarker"),y):(e.exit("tableDelimiterFiller"),y(P))}function y(P){return ze(P)?Ve(e,w,"whitespace")(P):w(P)}function w(P){return P===124?m(P):P===null||be(P)?!o||i!==s?S(P):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(P)):S(P)}function S(P){return n(P)}function C(P){return e.enter("tableRow"),N(P)}function N(P){return P===124?(e.enter("tableCellDivider"),e.consume(P),e.exit("tableCellDivider"),N):P===null||be(P)?(e.exit("tableRow"),t(P)):ze(P)?Ve(e,N,"whitespace")(P):(e.enter("data"),T(P))}function T(P){return P===null||P===124||ot(P)?(e.exit("data"),N(P)):(e.consume(P),P===92?M:T)}function M(P){return P===92||P===124?(e.consume(P),T):T(P)}}function NY(e,t){let n=-1,r=!0,i=0,s=[0,0,0,0],o=[0,0,0,0],a=!1,l=0,c,u,d;const f=new wY;for(;++n<e.length;){const p=e[n],m=p[1];p[0]==="enter"?m.type==="tableHead"?(a=!1,l!==0&&(dk(f,t,l,c,u),u=void 0,l=0),c={type:"table",start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[["enter",c,t]])):m.type==="tableRow"||m.type==="tableDelimiterRow"?(r=!0,d=void 0,s=[0,0,0,0],o=[0,n+1,0,0],a&&(a=!1,u={type:"tableBody",start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[["enter",u,t]])),i=m.type==="tableDelimiterRow"?2:u?3:1):i&&(m.type==="data"||m.type==="tableDelimiterMarker"||m.type==="tableDelimiterFiller")?(r=!1,o[2]===0&&(s[1]!==0&&(o[0]=o[1],d=bd(f,t,s,i,void 0,d),s=[0,0,0,0]),o[2]=n)):m.type==="tableCellDivider"&&(r?r=!1:(s[1]!==0&&(o[0]=o[1],d=bd(f,t,s,i,void 0,d)),s=o,o=[s[1],n,0,0])):m.type==="tableHead"?(a=!0,l=n):m.type==="tableRow"||m.type==="tableDelimiterRow"?(l=n,s[1]!==0?(o[0]=o[1],d=bd(f,t,s,i,n,d)):o[1]!==0&&(d=bd(f,t,o,i,n,d)),i=0):i&&(m.type==="data"||m.type==="tableDelimiterMarker"||m.type==="tableDelimiterFiller")&&(o[3]=n)}for(l!==0&&dk(f,t,l,c,u),f.consume(t.events),n=-1;++n<t.events.length;){const p=t.events[n];p[0]==="enter"&&p[1].type==="table"&&(p[1]._align=kY(t.events,n))}return e}function bd(e,t,n,r,i,s){const o=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",a="tableContent";n[0]!==0&&(s.end=Object.assign({},Jo(t.events,n[0])),e.add(n[0],0,[["exit",s,t]]));const l=Jo(t.events,n[1]);if(s={type:o,start:Object.assign({},l),end:Object.assign({},l)},e.add(n[1],0,[["enter",s,t]]),n[2]!==0){const c=Jo(t.events,n[2]),u=Jo(t.events,n[3]),d={type:a,start:Object.assign({},c),end:Object.assign({},u)};if(e.add(n[2],0,[["enter",d,t]]),r!==2){const f=t.events[n[2]],p=t.events[n[3]];if(f[1].end=Object.assign({},p[1].end),f[1].type="chunkText",f[1].contentType="text",n[3]>n[2]+1){const m=n[2]+1,v=n[3]-n[2]-1;e.add(m,v,[])}}e.add(n[3]+1,0,[["exit",d,t]])}return i!==void 0&&(s.end=Object.assign({},Jo(t.events,i)),e.add(i,0,[["exit",s,t]]),s=void 0),s}function dk(e,t,n,r,i){const s=[],o=Jo(t.events,n);i&&(i.end=Object.assign({},o),s.push(["exit",i,t])),r.end=Object.assign({},o),s.push(["exit",r,t]),e.add(n+1,0,s)}function Jo(e,t){const n=e[t],r=n[0]==="enter"?"start":"end";return n[1][r]}const TY={name:"tasklistCheck",tokenize:IY};function PY(){return{text:{91:TY}}}function IY(e,t,n){const r=this;return i;function i(l){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(l):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(l),e.exit("taskListCheckMarker"),s)}function s(l){return ot(l)?(e.enter("taskListCheckValueUnchecked"),e.consume(l),e.exit("taskListCheckValueUnchecked"),o):l===88||l===120?(e.enter("taskListCheckValueChecked"),e.consume(l),e.exit("taskListCheckValueChecked"),o):n(l)}function o(l){return l===93?(e.enter("taskListCheckMarker"),e.consume(l),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),a):n(l)}function a(l){return be(l)?t(l):ze(l)?e.check({tokenize:RY},t,n)(l):n(l)}}function RY(e,t,n){return Ve(e,r,"whitespace");function r(i){return i===null?n(i):t(i)}}function MY(e){return ER([rY(),fY(),bY(e),CY(),PY()])}const AY={};function eu(e){const t=this,n=e||AY,r=t.data(),i=r.micromarkExtensions||(r.micromarkExtensions=[]),s=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),o=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);i.push(MY(n)),s.push(JX()),o.push(eY(n))}const jY=/<command-name>([\s\S]*?)<\/command-name>/i,LY=/<command-message>([\s\S]*?)<\/command-message>/i,DY=/<command-args>([\s\S]*?)<\/command-args>/i,OY=/<(local-command-[a-z]+|command-(?:stdout|stderr))>[\s\S]*?<\/\1>/gi;function _p(e){if(!e)return{commandName:null,commandMessage:null,commandArgs:null,body:""};const t=e.match(jY),n=e.match(LY),r=e.match(DY);let i=e;return t&&(i=i.replace(t[0],"")),n&&(i=i.replace(n[0],"")),r&&(i=i.replace(r[0],"")),i=i.replace(OY,""),i=i.trim(),{commandName:t?t[1].trim():null,commandMessage:n?n[1].trim():null,commandArgs:r?r[1].trim():null,body:i}}const BY=/\.(png|jpe?g|webp|gif|svg)$/i;function zY(e,t){if((typeof t=="string"?t:null)!==e)return!1;try{const r=new URL(e);return BY.test(r.pathname)}catch{return!1}}function $Y(e){try{return new URL(e).pathname.split("/").filter(Boolean).pop()??""}catch{return""}}const tu={a:({node:e,href:t,children:n,...r})=>typeof t=="string"&&zY(t,n)?h.jsxs("span",{className:"my-1 inline-flex flex-col items-start gap-1 align-top",children:[h.jsx("img",{src:t,alt:$Y(t),className:"max-w-full h-auto rounded border border-border"}),h.jsx("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:"max-w-full truncate text-[11px] text-text-300 underline decoration-dotted underline-offset-2 hover:text-text-100",children:t})]}):h.jsx("a",{...r,href:t,target:"_blank",rel:"noopener noreferrer",children:n})};function FY({text:e,forkTarget:t}){const{body:n}=_p(e);return n?h.jsxs("div",{className:"group flex min-w-0 max-w-full flex-col items-start","data-testid":"msg-line-assistant-wrapper",children:[h.jsx("div",{"data-testid":"msg-line-assistant",className:"assistant-markdown w-full min-w-0 max-w-full py-1 break-words",children:h.jsx(Qc,{remarkPlugins:[eu],components:tu,children:n})}),t?h.jsxs("div",{className:"mt-1 flex flex-row items-center gap-1",children:[t.onFork?h.jsxs("button",{type:"button","data-testid":"assistant-msg-fork","aria-label":"fork from this message",title:"从这条消息派生新 session(截断之后的对话)",onClick:()=>t.onFork(t.messageUuid),className:"inline-flex items-center justify-start gap-1 h-7 w-7 md:h-6 md:w-auto md:px-1.5 rounded-md text-[11px] text-text-400/60 md:text-text-400 hover:bg-text-100/5 hover:text-text-200 md:opacity-0 md:group-hover:opacity-100 md:transition-opacity cursor-pointer",children:[h.jsx(kT,{className:"w-3 h-3",strokeWidth:2}),h.jsx("span",{className:"hidden md:inline",children:"Fork"})]}):null,t.onQuickAsk?h.jsxs("button",{type:"button","data-testid":"assistant-msg-quick-ask","aria-label":"quick ask from this message",title:"快速问答:从这条消息派生临时会话,关闭即删",onClick:()=>t.onQuickAsk(t.messageUuid),className:"inline-flex items-center justify-start gap-1 h-7 w-7 md:h-6 md:w-auto md:px-1.5 rounded-md text-[11px] text-text-400/60 md:text-text-400 hover:bg-text-100/5 hover:text-text-200 md:opacity-0 md:group-hover:opacity-100 md:transition-opacity cursor-pointer",children:[h.jsx(NT,{className:"w-3 h-3",strokeWidth:2}),h.jsx("span",{className:"hidden md:inline",children:"问一下"})]}):null]}):null]}):null}function HY({text:e}){const[t,n]=g.useState(!1);return e?h.jsxs("div",{"data-testid":"msg-line-thinking",className:"text-[12px] text-text-400",children:[h.jsxs("button",{type:"button",onClick:()=>n(r=>!r),className:"flex items-center gap-1 hover:text-text-300 transition-colors cursor-pointer","aria-expanded":t,"data-testid":"msg-line-thinking-toggle",children:[t?h.jsx(ci,{className:"w-3 h-3"}):h.jsx(ui,{className:"w-3 h-3"}),h.jsx("span",{children:"💭 Thinking"})]}),t?h.jsx("div",{className:"ml-4 mt-1 italic text-text-400 whitespace-pre-wrap break-words",children:e}):null]}):null}function vM(e){if(!e)return!1;const n=e.split("#")[0].split("?")[0].toLowerCase();return n.endsWith(".md")||n.endsWith(".markdown")}const UY=new Set(["Write","Edit","MultiEdit","NotebookEdit"]);function k0(e){return UY.has(e)}function WY({tool:e,relPath:t,scope:n,onShareFile:r}){if(!k0(e)||!t||!n||!r)return null;const i=vM(t)?"md-rendered":"raw";return h.jsx("span",{"data-testid":"file-edit-hover-row",className:"inline-flex shrink-0 items-center gap-1",children:h.jsx("span",{role:"button",tabIndex:0,"data-testid":"file-edit-share-btn","aria-label":"Share link",title:"Share link",onClick:s=>{s.stopPropagation(),r(t,i)},onKeyDown:s=>{(s.key==="Enter"||s.key===" ")&&(s.stopPropagation(),s.preventDefault(),r(t,i))},className:"inline-flex h-3.5 w-3.5 items-center justify-center text-text-400 hover:text-text-200 cursor-pointer",children:h.jsx(E_,{className:"h-3.5 w-3.5"})})})}function VY(e){if(!e||typeof e!="object")return null;const t=e;return typeof t.file_path=="string"&&t.file_path||typeof t.notebook_path=="string"&&t.notebook_path||typeof t.path=="string"&&t.path||null||null}function xM(e,t){const[n,r]=g.useState({kind:"idle"});return g.useEffect(()=>{let i=!1,s=null;r({kind:"loading"});const o={};return t&&(o.Authorization=`Bearer ${t}`),fetch(e,{headers:o,credentials:"omit"}).then(async a=>{if(!a.ok)throw new Error(`HTTP ${a.status}`);return a.blob()}).then(a=>{if(i)return;const l=URL.createObjectURL(a);s=l,r({kind:"ready",objectUrl:l})}).catch(a=>{i||r({kind:"error",message:a.message})}),()=>{i=!0,s&&URL.revokeObjectURL(s)}},[e,t]),n}function qY({url:e,bearerToken:t,alt:n,className:r}){const i=xM(e,t);return h.jsxs("div",{"data-testid":"blob-image","data-state":i.kind,className:ne("relative inline-flex items-center justify-center rounded-md border border-border bg-bg-0",r),children:[i.kind==="loading"?h.jsx("div",{className:"flex h-24 w-32 items-center justify-center",children:h.jsx(rr,{className:"h-4 w-4 animate-spin text-text-400"})}):null,i.kind==="error"?h.jsxs("div",{className:"flex h-24 w-32 items-center justify-center gap-1 px-2 text-[11px] text-text-400",children:[h.jsx(Ls,{className:"h-3 w-3"}),h.jsx("span",{title:i.message,children:"加载失败"})]}):null,i.kind==="ready"?h.jsx("img",{src:i.objectUrl,alt:n,className:"block max-h-[180px] max-w-[420px] rounded-md object-contain"}):null]})}function KY({url:e,bearerToken:t,className:n}){const r=xM(e,t);return h.jsxs("div",{"data-testid":"blob-video","data-state":r.kind,className:ne("relative inline-flex items-center justify-center rounded-md border border-border bg-bg-0",n),children:[r.kind==="loading"?h.jsx(rr,{className:"h-4 w-4 animate-spin text-text-400"}):null,r.kind==="error"?h.jsx("span",{className:"px-2 text-[11px] text-text-400",children:"加载失败"}):null,r.kind==="ready"?h.jsx("video",{src:r.objectUrl,controls:!0,className:"block max-h-[240px] max-w-[420px] rounded-md"}):null]})}const GY=new Set([".png",".jpg",".jpeg",".gif",".webp",".svg"]),XY=new Set([".mp4",".webm",".mov"]),YY=new Set([".pdf"]);function ZY(e){const t=e.lastIndexOf("."),n=t>=0?e.slice(t).toLowerCase():"";return GY.has(n)?"image":XY.has(n)?"video":YY.has(n)?"pdf":"binary"}function _M(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(1)} MB`}function QY({relPath:e,scope:t,size:n}){const r=Xf();if(r.actionsLevel==="none")return null;const i=JB(r,t,e);if(!i)return null;const s=ZY(e);return s==="image"?h.jsx("div",{"data-testid":"file-edit-inline-preview","data-kind":"image",className:"mt-2",children:h.jsx(qY,{url:i,bearerToken:r.httpToken,alt:e})}):s==="video"?h.jsx("div",{"data-testid":"file-edit-inline-preview","data-kind":"video",className:"mt-2",children:h.jsx(KY,{url:i,bearerToken:r.httpToken})}):s==="pdf"?h.jsx(JY,{relPath:e,url:i,size:n}):typeof n=="number"&&n>=1024*1024?h.jsxs("div",{"data-testid":"file-edit-inline-preview","data-kind":"binary",className:"mt-2 inline-flex items-center gap-1.5 rounded border border-border bg-bg-50 px-2 py-1 text-[11px] text-text-400",children:[h.jsx(Ds,{className:"h-3 w-3"}),h.jsx("span",{className:"font-mono",children:e.split("/").pop()}),h.jsx("span",{children:"·"}),h.jsx("span",{children:_M(n)})]}):null}function JY({relPath:e,url:t,size:n}){return h.jsxs("a",{"data-testid":"file-edit-inline-preview","data-kind":"pdf",href:t,target:"_blank",rel:"noopener noreferrer",className:"mt-2 inline-flex items-center gap-1.5 rounded border border-border bg-bg-50 px-2 py-1 text-[11px] text-text-300 hover:bg-bg-100",children:[h.jsx(Ds,{className:"h-3 w-3"}),h.jsx("span",{className:"font-mono",children:e.split("/").pop()}),typeof n=="number"?h.jsxs(h.Fragment,{children:[h.jsx("span",{children:"·"}),h.jsx("span",{children:_M(n)})]}):null,h.jsx(Hc,{className:"h-3 w-3"})]})}const eZ={Bash:RT,Read:Ds,Edit:PT,Write:hz,Grep:Jv,Glob:Jv};function tZ(e){return eZ[e]??m$}function nZ(e){if(!e||typeof e!="object")return"";const t=e,n=t.command??t.file_path??t.path??t.pattern??t.query??t.url??t.description;if(typeof n=="string")return n;for(const r of Object.values(t))if(typeof r=="string"&&r)return r;return""}function yM({tool:e,input:t,output:n,error:r,pending:i=!1,expandedBody:s,fileScope:o,onOpenInTab:a,onPreviewMarkdown:l,onShareFile:c}){const[u,d]=g.useState(!1),f=!!r,p=tZ(e),m=nZ(t),v=VY(t);return h.jsxs("div",{"data-testid":"msg-line-tool","data-tool":e,className:ne("group min-w-0 max-w-full rounded-md border px-3 py-2 text-[13px]",f?"border-destructive/40 bg-destructive/5":"border-border bg-bg-50"),children:[h.jsxs("button",{type:"button",onClick:()=>d(b=>!b),"aria-expanded":u,"data-testid":"msg-line-tool-header",className:"flex w-full items-center gap-2 text-left cursor-pointer min-w-0",children:[f?h.jsx(Ls,{className:"w-4 h-4 text-destructive shrink-0"}):h.jsx(p,{className:ne("w-4 h-4 shrink-0",i?"text-text-400":"text-text-300")}),h.jsx("span",{className:"font-medium text-text-100 shrink-0",children:e}),m?(()=>{if(f||!k0(e)||!v)return null;const x=vM(v)&&l?l:a;return x?h.jsx("span",{role:"button",tabIndex:0,"data-testid":"msg-line-tool-preview","data-clickable":"true",title:m,onClick:_=>{_.stopPropagation(),x(v)},onKeyDown:_=>{(_.key==="Enter"||_.key===" ")&&(_.stopPropagation(),_.preventDefault(),x(v))},className:"text-[12px] text-accent font-mono truncate min-w-0 max-w-full cursor-pointer underline underline-offset-2 hover:opacity-80",children:m}):null})()??h.jsx("span",{"data-testid":"msg-line-tool-preview",className:"text-[12px] text-text-400 font-mono truncate min-w-0 max-w-full",title:m,children:m}):null,h.jsx("span",{"aria-hidden":"true","data-testid":"msg-line-tool-header-spacer",className:"flex-1 min-w-0 self-stretch"}),i?h.jsx(rr,{"data-testid":"msg-line-tool-pending",className:"w-3 h-3 text-text-400 animate-spin shrink-0"}):null,!f&&o?h.jsx(WY,{tool:e,relPath:v,scope:o,...c?{onShareFile:c}:{}}):null]}),u?s!==void 0?h.jsxs("div",{"data-testid":"msg-line-tool-body",className:"mt-2 min-w-0 text-[12px]",children:[s,f?h.jsxs("div",{className:"mt-2",children:[h.jsx("div",{className:"text-destructive mb-0.5",children:"error"}),h.jsx("pre",{className:"min-w-0 max-w-full bg-bg-0 border border-destructive/40 rounded p-2 overflow-auto text-destructive",children:String(r)})]}):null]}):h.jsxs("div",{"data-testid":"msg-line-tool-body",className:"mt-2 min-w-0 space-y-1 text-[12px]",children:[h.jsxs("div",{children:[h.jsx("div",{className:"text-text-400 mb-0.5",children:"input"}),h.jsx("pre",{className:"min-w-0 max-w-full bg-bg-0 border border-border rounded p-2 overflow-auto text-text-200",children:JSON.stringify(t,null,2)})]}),n!==void 0?h.jsxs("div",{children:[h.jsx("div",{className:"text-text-400 mb-0.5",children:"output"}),h.jsx("pre",{className:"min-w-0 max-w-full bg-bg-0 border border-border rounded p-2 overflow-auto text-text-200",children:typeof n=="string"?n:JSON.stringify(n,null,2)})]}):null,f?h.jsxs("div",{children:[h.jsx("div",{className:"text-destructive mb-0.5",children:"error"}),h.jsx("pre",{className:"min-w-0 max-w-full bg-bg-0 border border-destructive/40 rounded p-2 overflow-auto text-destructive",children:String(r)})]}):null]}):null,!f&&o&&v&&k0(e)?h.jsx(QY,{relPath:v,scope:o}):null]})}var rZ=Symbol.for("react.lazy"),sf=Ya[" use ".trim().toString()];function iZ(e){return typeof e=="object"&&e!==null&&"then"in e}function bM(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===rZ&&"_payload"in e&&iZ(e._payload)}function sZ(e){const t=aZ(e),n=g.forwardRef((r,i)=>{let{children:s,...o}=r;bM(s)&&typeof sf=="function"&&(s=sf(s._payload));const a=g.Children.toArray(s),l=a.find(cZ);if(l){const c=l.props.children,u=a.map(d=>d===l?g.Children.count(c)>1?g.Children.only(null):g.isValidElement(c)?c.props.children:null:d);return h.jsx(t,{...o,ref:i,children:g.isValidElement(c)?g.cloneElement(c,void 0,u):null})}return h.jsx(t,{...o,ref:i,children:s})});return n.displayName=`${e}.Slot`,n}var oZ=sZ("Slot");function aZ(e){const t=g.forwardRef((n,r)=>{let{children:i,...s}=n;if(bM(i)&&typeof sf=="function"&&(i=sf(i._payload)),g.isValidElement(i)){const o=dZ(i),a=uZ(s,i.props);return i.type!==g.Fragment&&(a.ref=r?gu(r,o):o),g.cloneElement(i,a)}return g.Children.count(i)>1?g.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var lZ=Symbol("radix.slottable");function cZ(e){return g.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===lZ}function uZ(e,t){const n={...t};for(const r in t){const i=e[r],s=t[r];/^on[A-Z]/.test(r)?i&&s?n[r]=(...a)=>{const l=s(...a);return i(...a),l}:i&&(n[r]=i):r==="style"?n[r]={...i,...s}:r==="className"&&(n[r]=[i,s].filter(Boolean).join(" "))}return{...e,...n}}function dZ(e){var r,i;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(i=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:i.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}const hk=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,fk=jT,hZ=(e,t)=>n=>{var r;if((t==null?void 0:t.variants)==null)return fk(e,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:i,defaultVariants:s}=t,o=Object.keys(i).map(c=>{const u=n==null?void 0:n[c],d=s==null?void 0:s[c];if(u===null)return null;const f=hk(u)||hk(d);return i[c][f]}),a=n&&Object.entries(n).reduce((c,u)=>{let[d,f]=u;return f===void 0||(c[d]=f),c},{}),l=t==null||(r=t.compoundVariants)===null||r===void 0?void 0:r.reduce((c,u)=>{let{class:d,className:f,...p}=u;return Object.entries(p).every(m=>{let[v,b]=m;return Array.isArray(b)?b.includes({...s,...a}[v]):{...s,...a}[v]===b})?[...c,d,f]:c},[]);return fk(e,o,l,n==null?void 0:n.class,n==null?void 0:n.className)},fZ=hZ("inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",{variants:{variant:{default:"bg-accent text-accent-contrast hover:bg-accent-hover",destructive:"bg-destructive text-white hover:bg-destructive-hover",outline:"border border-border bg-transparent text-text-100 hover:bg-bg-200",ghost:"bg-transparent text-text-200 hover:bg-bg-200 hover:text-text-100"},size:{sm:"h-8 px-3 text-xs",md:"h-9 px-4",lg:"h-11 px-6 text-base"}},defaultVariants:{variant:"default",size:"md"}}),ri=g.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...i},s)=>{const o=r?oZ:"button";return h.jsx(o,{ref:s,className:ne(fZ({variant:t,size:n}),e),...i})});ri.displayName="Button";function pZ({tool:e,input:t,onRespond:n,onInterrupt:r}){return h.jsxs("div",{"data-testid":"msg-line-permission",className:"min-w-0 max-w-full rounded-md border border-warning/40 bg-warning-dim/60 px-3 py-2.5 text-[13px]",children:[h.jsxs("div",{className:"flex min-w-0 items-center gap-2 mb-1.5",children:[h.jsx(r$,{className:"w-4 h-4 text-warning shrink-0"}),h.jsxs("span",{className:"min-w-0 font-medium text-text-100 truncate",children:["权限请求:",e]}),r?h.jsx("button",{type:"button",onClick:r,"data-testid":"msg-line-permission-interrupt","aria-label":"interrupt current turn",title:"中断当前轮次(不杀进程)",className:"ml-auto h-6 w-6 rounded-md flex items-center justify-center text-text-400 hover:bg-text-100/10 hover:text-text-200 transition-colors cursor-pointer",children:h.jsx(TT,{className:"w-3.5 h-3.5",strokeWidth:2})}):null]}),h.jsx("pre",{className:"min-w-0 max-w-full bg-bg-0 border border-border rounded p-2 mb-2 max-h-[140px] overflow-auto text-[12px] text-text-200",children:JSON.stringify(t,null,2)}),h.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[h.jsx(ri,{size:"sm",variant:"default",onClick:()=>n(!0,!1),"data-testid":"msg-line-permission-allow",children:"Allow"}),h.jsx(ri,{size:"sm",variant:"outline",onClick:()=>n(!0,!0),"data-testid":"msg-line-permission-allow-always",children:"Allow Always"}),h.jsx(ri,{size:"sm",variant:"destructive",onClick:()=>n(!1,!1),"data-testid":"msg-line-permission-deny",children:"Deny"})]})]})}function mZ({message:e}){return h.jsxs("div",{"data-testid":"msg-line-error",className:"flex min-w-0 max-w-full items-start gap-2 text-destructive text-[13px] rounded-md border border-destructive/40 bg-destructive/5 px-3 py-2",children:[h.jsx(Uc,{className:"w-4 h-4 shrink-0 mt-0.5"}),h.jsx("span",{className:"min-w-0 whitespace-pre-wrap break-words [overflow-wrap:anywhere]",children:e})]})}const pk=/\[attachment:(image|file):([^\]]+)\]/g;function gZ(e){const t=[];let n;for(;(n=pk.exec(e))!==null;){const i=n[2],s=decodeURIComponent(i.split("/").pop()??"file");t.push({type:n[1],url:i,fileName:s})}const r=e.replace(pk,"").trim();return{attachments:t,text:r}}function vZ(e,t){const n=t.filter(i=>i.status==="done"&&i.url);return n.length===0?e:n.map(i=>`[attachment:${i.mimeType.startsWith("image/")?"image":"file"}:${i.url}]`).join(`
|
|
524
524
|
`)+`
|
|
525
525
|
`+e}const xZ=/\[skill:(.+?):(\/[^\]]+)\]/g;function _Z(e){const t=[],n=e.replace(xZ,(r,i)=>(t.push(i),""));return{skills:t,text:t.length>0?n.trim():e}}function yZ({text:e,senderDisplayName:t,rewindTarget:n}){const r=dR(e),{attachments:i,text:s}=gZ(r),{skills:o,text:a}=_Z(s),{commandName:l,body:c}=_p(a),u=c.length>0;return u||i.length>0||!!l||o.length>0?(l||o.length>0)&&!u&&i.length===0?h.jsxs("div",{className:"flex min-w-0 max-w-full justify-end gap-1.5 py-2 mt-2","data-testid":"msg-line-user",children:[o.map((f,p)=>h.jsxs("span",{"data-testid":"user-skill-chip",className:"inline-flex items-center rounded-md bg-bg-200/60 px-2 py-0.5 text-[11px] font-mono text-text-300",children:["/",f]},`${f}-${p}`)),l?h.jsx("span",{className:"inline-flex items-center rounded-md bg-bg-200/60 px-2 py-0.5 text-[11px] font-mono text-text-300",children:l}):null]}):h.jsxs("div",{className:"group flex min-w-0 max-w-full flex-col items-end py-2 mt-2","data-testid":"msg-line-user",children:[h.jsxs("div",{className:"min-w-0 max-w-[85%] rounded-2xl rounded-br-sm bg-accent px-3.5 py-2 whitespace-pre-wrap break-words [overflow-wrap:anywhere]",children:[i.length>0?h.jsx(bZ,{attachments:i}):null,o.length>0?h.jsx("div",{className:ne("flex flex-wrap gap-1.5",(u||l)&&"mb-1.5"),children:o.map((f,p)=>h.jsxs("span",{"data-testid":"user-skill-chip",className:"inline-flex items-center rounded-md bg-white/15 px-2 py-0.5 text-[11px] font-mono text-white/90",children:["/",f]},`${f}-${p}`))}):null,l?h.jsx("div",{className:ne("flex",u&&"mb-1.5"),children:h.jsx("span",{"data-testid":"user-command-chip",className:"inline-flex items-center rounded-md bg-white/15 px-2 py-0.5 text-[11px] font-mono text-white/90",children:l})}):null,u?h.jsx("div",{className:"text-[14px] text-white font-medium leading-relaxed",children:c}):null]}),t?h.jsx("div",{"data-testid":"user-msg-sender-label",className:"mt-1 text-[11px] text-text-400",children:t}):null,n?h.jsxs("button",{type:"button","data-testid":"user-msg-rewind","aria-label":"rewind to this message",title:"回退到这条消息(会撤销之后 CC 的文件编辑)",onClick:()=>n.onRewind(n.userMessageId),className:"mt-1 inline-flex items-center gap-1 h-6 px-1.5 rounded-md text-[11px] text-text-400 hover:bg-text-100/5 hover:text-text-200 opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer",children:[h.jsx(MT,{className:"w-3 h-3",strokeWidth:2}),h.jsx("span",{children:"Rewind"})]}):null]}):null}function bZ({attachments:e}){return h.jsx("div",{className:"flex flex-wrap gap-1.5 mb-1.5","data-testid":"user-attachment-row",children:e.map(t=>h.jsx(wZ,{attachment:t},t.url))})}function wZ({attachment:e}){return e.type==="image"?h.jsx("img",{src:e.url,alt:e.fileName,"data-testid":"user-attachment-image",className:"h-16 w-16 rounded object-cover shrink-0 border border-bg-300/50"}):h.jsxs("div",{"data-testid":"user-attachment-file",className:"flex items-center gap-1.5 rounded-md border border-bg-300 bg-bg-100/60 px-2 py-1 text-[12px] text-text-200",children:[h.jsx(Ds,{className:"h-3.5 w-3.5 text-text-400 shrink-0"}),h.jsx("span",{className:"max-w-[140px] truncate",children:e.fileName})]})}const SZ={"task-notification":"子任务通知","slash-command":"斜杠命令","local-command":"本地命令输出","system-reminder":"系统提醒","skill-hint":"Skill 注入","meta-text":"系统消息","attachment-skills":"技能列表","attachment-deferred-tools":"Deferred 工具变更"},kZ={"task-notification":_w,"slash-command":o$,"local-command":RT,"system-reminder":_w,"skill-hint":qh,"meta-text":CT,"attachment-skills":qh,"attachment-deferred-tools":Vz};function CZ({metaKind:e,text:t}){const[n,r]=g.useState(!1),i=kZ[e];if(e==="slash-command"){const{commandName:o,commandMessage:a,commandArgs:l,body:c}=_p(t),u=o??(a?`/${a}`:null),d=!!(l&&l.length>0),f=c.length>0;return!u&&!d&&!f?null:h.jsxs("div",{"data-testid":"msg-line-user-meta","data-meta-kind":e,className:"flex min-w-0 max-w-full flex-col items-end gap-0.5 py-1",children:[h.jsxs("div",{className:"flex min-w-0 items-center gap-2 max-w-full",children:[u?h.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-md bg-bg-200/60 px-2 py-0.5 text-[11px] font-mono text-text-300 shrink-0",children:[h.jsx(i,{className:"w-3 h-3 opacity-70"}),u]}):null,d?h.jsx("span",{"data-testid":"user-meta-command-args",className:"min-w-0 text-[12px] text-text-200 whitespace-pre-wrap break-words max-w-[70ch] [overflow-wrap:anywhere]",children:l}):null]}),f?h.jsx("span",{className:"ml-2 max-w-[60%] truncate text-[11px] text-text-400",children:c}):null]})}const s=t.replace(/\s+/g," ").trim().slice(0,80);return h.jsxs("div",{"data-testid":"msg-line-user-meta","data-meta-kind":e,className:"flex min-w-0 max-w-full flex-col items-start gap-1 py-1",children:[h.jsxs("button",{type:"button","aria-expanded":n,onClick:()=>r(o=>!o),className:ne("group inline-flex items-center gap-1.5 rounded-md border border-bg-200/60 bg-bg-100/40","px-2 py-1 text-[11px] text-text-400 hover:bg-bg-200/40 transition-colors max-w-full"),children:[h.jsx(i,{className:"w-3 h-3 opacity-70 shrink-0"}),h.jsx("span",{className:"font-medium shrink-0",children:SZ[e]}),h.jsx("span",{className:"truncate text-text-400/80 max-w-[60ch]",children:s}),n?h.jsx(ci,{className:"w-3 h-3 opacity-60 shrink-0"}):h.jsx(ui,{className:"w-3 h-3 opacity-60 shrink-0"})]}),n?h.jsx("pre",{"data-testid":"user-meta-body",className:"w-full max-w-full whitespace-pre-wrap break-words text-[11px] text-text-400 bg-bg-50/60 rounded-md p-2 border border-bg-200/60 [overflow-wrap:anywhere]",children:t}):null]})}function EZ({text:e,metaSource:t}){return t==="owner"?h.jsx("div",{className:"flex min-w-0 max-w-full flex-col items-start py-1.5","data-testid":"msg-line-owner-meta",children:h.jsxs("div",{className:ne("inline-flex min-w-0 max-w-[85%] items-start gap-2 rounded-md","border-l-[3px] border-accent bg-accent-dim px-3 py-2"),children:[h.jsx(Mz,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-accent","aria-label":"补充信息"}),h.jsx("span",{className:"min-w-0 text-[12px] leading-relaxed text-text-100 whitespace-pre-wrap break-words [overflow-wrap:anywhere]",children:e})]})}):h.jsxs("div",{className:"flex min-w-0 max-w-full items-start gap-1.5 py-1 text-[11px] text-text-400","data-testid":"msg-line-cc-meta",children:[h.jsx(CT,{className:"mt-0.5 h-3 w-3 shrink-0"}),h.jsx("span",{className:"min-w-0 whitespace-pre-wrap break-words [overflow-wrap:anywhere]",children:e})]})}function $r(e,t){const r=new RegExp(`<${t}\\b[^>]*>([\\s\\S]*?)</${t}>`,"i").exec(e);if(!r)return;const i=r[1].trim();return i||void 0}function qm(e,t){const r=new RegExp(`${t}\\s*=\\s*"([^"]+)"`,"i").exec(e);if(!r)return;const i=Number(r[1]);return Number.isFinite(i)?i:void 0}function wM(e){var i,s,o;const t={};if(!e)return t;t.taskId=$r(e,"task-id"),t.toolUseId=$r(e,"tool-use-id"),t.outputFile=$r(e,"output-file"),t.status=$r(e,"status"),t.summary=$r(e,"summary"),t.result=$r(e,"result");const n=$r(e,"usage");if(n){const a=(i=/<total_tokens>\s*(\d+)\s*<\/total_tokens>/i.exec(n))==null?void 0:i[1],l=(s=/<tool_uses>\s*(\d+)\s*<\/tool_uses>/i.exec(n))==null?void 0:s[1],c=(o=/<duration_ms>\s*(\d+)\s*<\/duration_ms>/i.exec(n))==null?void 0:o[1];a&&(t.totalTokens=Number(a)),l&&(t.toolUses=Number(l)),c&&(t.durationMs=Number(c))}const r=$r(e,"worktree");if(r)t.worktreePath=$r(r,"worktreePath"),t.worktreeBranch=$r(r,"worktreeBranch");else{const a=/<worktree\b([^>]*)\/>/i.exec(e);if(a){const l=a[1],c=/worktreePath\s*=\s*"([^"]+)"/i.exec(l),u=/worktreeBranch\s*=\s*"([^"]+)"/i.exec(l);c&&(t.worktreePath=c[1]),u&&(t.worktreeBranch=u[1])}}if(t.totalTokens===void 0&&t.toolUses===void 0&&t.durationMs===void 0){const a=qm(e,"total_tokens"),l=qm(e,"tool_uses"),c=qm(e,"duration_ms");a!==void 0&&(t.totalTokens=a),l!==void 0&&(t.toolUses=l),c!==void 0&&(t.durationMs=c)}return t}function NZ(e){if(!e||!Number.isFinite(e))return null;if(e<1e3)return`${e}ms`;const t=e/1e3;if(t<60)return`${t.toFixed(1)}s`;const n=Math.floor(t/60),r=Math.round(t-n*60);return`${n}m${r.toString().padStart(2,"0")}s`}function TZ({text:e,taskId:t,parentToolUseId:n}){const r=g.useMemo(()=>wM(e),[e]),[i,s]=g.useState(!1),o=t??r.taskId,a=n??r.toolUseId,l=r.status==="failed"?h.jsx(Ls,{className:"w-3.5 h-3.5 text-error"}):r.status==="completed"?h.jsx(Zf,{className:"w-3.5 h-3.5 text-success"}):h.jsx(Yf,{className:"w-3.5 h-3.5 text-text-400"}),c=r.status??"unknown",u=NZ(r.durationMs);return h.jsxs("div",{"data-testid":"msg-line-agent-notification","data-task-id":o??"","data-parent-tool-use-id":a??"",className:"my-1 min-w-0 max-w-full rounded-md border border-bg-200/60 bg-bg-100/40",children:[h.jsxs("button",{type:"button","aria-expanded":i,onClick:()=>s(d=>!d),className:ne("flex w-full min-w-0 items-start gap-2 px-2.5 py-1.5 text-left text-[12px]","hover:bg-bg-200/40 rounded-md transition-colors"),children:[h.jsx("span",{className:"mt-[2px] shrink-0",children:l}),h.jsxs("span",{className:"flex-1 min-w-0",children:[h.jsxs("span",{className:"flex items-center gap-2 flex-wrap",children:[h.jsx("span",{className:"font-medium text-text-200",children:"子任务"}),h.jsx("span",{className:"text-text-400 text-[11px] font-mono",children:o?o.slice(0,12):"未知"}),h.jsx("span",{className:"text-text-400 text-[11px] uppercase tracking-wide",children:c}),u?h.jsxs("span",{className:"text-text-400 text-[11px] tabular-nums",children:["· ",u]}):null,r.totalTokens?h.jsxs("span",{className:"text-text-400 text-[11px] tabular-nums",children:["· ",r.totalTokens," tok"]}):null,r.toolUses?h.jsxs("span",{className:"text-text-400 text-[11px] tabular-nums",children:["· ",r.toolUses," tools"]}):null]}),r.summary?h.jsx("span",{className:"block truncate text-text-300 text-[12px] mt-0.5",children:r.summary}):null]}),i?h.jsx(ci,{className:"w-3.5 h-3.5 mt-[3px] text-text-400 shrink-0"}):h.jsx(ui,{className:"w-3.5 h-3.5 mt-[3px] text-text-400 shrink-0"})]}),i?h.jsxs("div",{"data-testid":"agent-notification-body",className:"min-w-0 border-t border-bg-200/60 px-3 py-2 text-[12px] text-text-300 space-y-2",children:[r.worktreePath||r.worktreeBranch?h.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-text-400",children:[h.jsx(kT,{className:"w-3 h-3"}),r.worktreeBranch?h.jsx("span",{className:"font-mono",children:r.worktreeBranch}):null,r.worktreePath?h.jsx("span",{className:"truncate font-mono",children:r.worktreePath}):null]}):null,r.outputFile?h.jsxs("div",{className:"text-[11px] text-text-400",children:[h.jsx("span",{children:"输出文件:"}),h.jsx("span",{className:"font-mono",children:r.outputFile})]}):null,a?h.jsxs("div",{className:"text-[11px] text-text-400",children:[h.jsx("span",{children:"父工具调用:"}),h.jsx("span",{className:"font-mono",children:a})]}):null,r.result?h.jsx("div",{"data-testid":"agent-notification-result",className:"assistant-markdown text-[12px] leading-relaxed break-words",children:h.jsx(Qc,{remarkPlugins:[eu],components:tu,children:r.result})}):h.jsx("div",{className:"text-[11px] text-text-400 italic",children:"无详细结果"})]}):null]})}const SM=g.createContext(null);function PZ({children:e}){const[t,n]=g.useState({agentId:null}),r=g.useCallback((o,a)=>{n({agentId:o,agentType:a})},[]),i=g.useCallback(()=>{n(o=>({agentId:null,agentType:o.agentType}))},[]),s=g.useMemo(()=>({state:t,open:r,close:i}),[t,r,i]);return h.jsx(SM.Provider,{value:s,children:e})}function kM(){return g.useContext(SM)}function IZ(e){if(e==null)return null;if(typeof e=="string")return e;if(Array.isArray(e)){const t=[];for(const n of e)if(n&&typeof n=="object"){const r=n;r.type==="text"&&typeof r.text=="string"&&t.push(r.text)}else typeof n=="string"&&t.push(n);return t.length?t.join(`
|
|
526
|
-
`):null}if(typeof e=="object"){const t=e;if(typeof t.text=="string")return t.text}return null}function mk(e){if(!e||!Number.isFinite(e))return null;if(e<1e3)return`${e}ms`;const t=e/1e3;if(t<60)return`${t.toFixed(1)}s`;const n=Math.floor(t/60),r=Math.round(t-n*60);return`${n}m${r.toString().padStart(2,"0")}s`}function RZ(e){return!e||!Number.isFinite(e)?null:e<1e3?`${e} tok`:e<1e4?`${(e/1e3).toFixed(1)}k tok`:`${Math.round(e/1e3)}k tok`}const MZ={readCount:"read",searchCount:"search",bashCount:"bash",editFileCount:"edit",linesAdded:"+lines",linesRemoved:"-lines",otherToolCount:"other"};function AZ(e){if(!e)return[];const t=[];for(const[n,r]of Object.entries(e)){if(!r||r<=0)continue;const i=MZ[n]??n;t.push(`${i}:${r}`)}return t}function jZ({description:e,input:t,output:n,error:r,pending:i,notifications:s,toolResultExtra:o,progress:a}){const[l,c]=g.useState(!1),u=kM(),d=g.useMemo(()=>{if(!t||typeof t!="object")return null;const T=t;return typeof T.prompt=="string"?T.prompt:null},[t]),f=(o==null?void 0:o.prompt)??d,p=g.useMemo(()=>IZ(n),[n]),m=o==null?void 0:o.stats,v=a==null?void 0:a.stats,b=mk((m==null?void 0:m.durationMs)??(v==null?void 0:v.durationMs)),x=RZ((m==null?void 0:m.tokens)??(v==null?void 0:v.tokens)),_=AZ(m==null?void 0:m.toolStats),y=i&&(a!=null&&a.lastToolName)?`now:${a.lastToolName}`:null,w=!!(o!=null&&o.agentType||b||x||_.length>0||y),S=(o==null?void 0:o.agentId)??(a==null?void 0:a.agentId),C=g.useMemo(()=>s.map(T=>({taskId:T.taskId,text:T.text,parsed:wM(T.text)})),[s]),N=r?h.jsx(Ls,{className:"w-3.5 h-3.5 text-error"}):i?h.jsx(rr,{className:"w-3.5 h-3.5 text-blue-400 animate-spin"}):h.jsx(Zf,{className:"w-3.5 h-3.5 text-green-500"});return h.jsxs("div",{"data-testid":"msg-line-agent-call","data-pending":i?"true":"false","data-has-error":r?"true":"false","data-notification-count":s.length,"data-has-stats":w?"true":"false","data-agent-id":S??"",className:"my-1 min-w-0 max-w-full rounded-md border border-bg-200/60 bg-bg-100/30",children:[h.jsxs("button",{type:"button","aria-expanded":l,onClick:()=>c(T=>!T),className:ne("flex w-full min-w-0 items-center gap-2 px-2.5 py-1.5 text-left text-[13px]","hover:bg-bg-200/40 rounded-md transition-colors"),children:[h.jsx("span",{className:"w-5 h-5 flex items-center justify-center text-[10px] rounded bg-violet-500/10 text-violet-500 shrink-0","aria-hidden":!0,children:h.jsx(x$,{className:"w-3 h-3"})}),h.jsx("span",{className:"shrink-0",children:N}),h.jsx("span",{className:"flex-1 min-w-0 truncate font-medium text-text-200",children:e}),w?null:s.length>0?h.jsxs("span",{className:"text-[11px] text-text-400 tabular-nums shrink-0",children:[s.length," 次通知"]}):null,S&&(u!=null&&u.open)?h.jsx("span",{role:"button",tabIndex:0,"data-testid":"open-subagent-btn-header","data-agent-id":S,"aria-label":"打开子 agent 对话",onClick:T=>{T.stopPropagation(),u.open(S,o==null?void 0:o.agentType)},onKeyDown:T=>{(T.key==="Enter"||T.key===" ")&&(T.stopPropagation(),T.preventDefault(),u.open(S,o==null?void 0:o.agentType))},className:"shrink-0 inline-flex items-center justify-center w-3.5 h-3.5 text-text-400 hover:text-text-200",children:h.jsx(Hc,{className:"w-3.5 h-3.5"})}):null,l?h.jsx(ci,{className:"w-3.5 h-3.5 text-text-400 shrink-0"}):h.jsx(ui,{className:"w-3.5 h-3.5 text-text-400 shrink-0"})]}),i&&(a!=null&&a.description)?h.jsx("div",{"data-testid":"agent-call-progress-desc",className:"px-3 pt-0 pb-1 text-[12px] text-text-300 truncate",children:a.description}):null,w?h.jsxs("div",{"data-testid":"agent-call-stats",className:"flex items-center gap-1.5 flex-wrap px-3 pb-1.5 pt-0 text-[11px] text-text-400",children:[o!=null&&o.agentType?h.jsx("span",{"data-testid":"agent-call-stats-type",className:"inline-flex items-center rounded-sm bg-violet-500/10 px-1.5 py-0.5 text-violet-400 font-medium",children:o.agentType}):null,b?h.jsx("span",{className:"tabular-nums",children:b}):null,x?h.jsx("span",{className:"tabular-nums",children:x}):null,y?h.jsx("span",{"data-testid":"agent-call-stats-now",className:"font-mono tabular-nums text-blue-400",children:y}):null,_.map(T=>h.jsx("span",{className:"font-mono tabular-nums text-text-400/80",children:T},T)),s.length>0?h.jsxs("span",{className:"tabular-nums text-text-400/70",children:["· ",s.length," 次通知"]}):null]}):null,l?h.jsxs("div",{"data-testid":"agent-call-body",className:"min-w-0 border-t border-bg-200/60 px-3 py-2 space-y-3",children:[r?h.jsx("div",{className:"text-[12px] text-error whitespace-pre-wrap",children:r}):null,C.map((T,M)=>{const P=T.parsed,D=mk(P.durationMs);return h.jsxs("div",{"data-testid":"agent-call-notification","data-task-id":T.taskId??"",className:"min-w-0 rounded-md border border-bg-200/60 bg-bg-0/40 p-2 space-y-1.5",children:[h.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-text-400 flex-wrap",children:[h.jsx("span",{className:"font-mono",children:(T.taskId??P.taskId??"未知").slice(0,12)}),h.jsx("span",{className:"uppercase tracking-wide",children:P.status??"unknown"}),D?h.jsxs("span",{className:"tabular-nums",children:["· ",D]}):null,P.totalTokens?h.jsxs("span",{className:"tabular-nums",children:["· ",P.totalTokens," tok"]}):null,P.toolUses?h.jsxs("span",{className:"tabular-nums",children:["· ",P.toolUses," tools"]}):null,P.worktreeBranch?h.jsxs("span",{className:"font-mono",children:["· ",P.worktreeBranch]}):null]}),P.summary?h.jsx("div",{className:"text-[12px] text-text-300",children:P.summary}):null,P.result?h.jsx("div",{"data-testid":"agent-call-notification-result",className:"assistant-markdown text-[12px] leading-relaxed break-words",children:h.jsx(Qc,{remarkPlugins:[eu],components:tu,children:P.result})}):null]},`${T.taskId??"n"}-${M}`)}),f?h.jsxs("div",{"data-testid":"agent-call-prompt-block",className:"min-w-0 space-y-1",children:[h.jsx("div",{className:"text-[11px] text-text-400 font-medium",children:"任务指令"}),h.jsx("pre",{"data-testid":"agent-call-prompt",className:"max-w-full whitespace-pre-wrap break-words text-[11px] text-text-300 bg-bg-50/60 rounded p-2 border border-bg-200/60 max-h-64 overflow-auto [overflow-wrap:anywhere]",children:f})]}):null,p?h.jsxs("div",{"data-testid":"agent-call-result-block",className:"min-w-0 space-y-1",children:[h.jsx("div",{className:"text-[11px] text-text-400 font-medium",children:"子 agent 报告"}),h.jsx("div",{"data-testid":"agent-call-result",className:"assistant-markdown text-[12px] leading-relaxed break-words",children:h.jsx(Qc,{remarkPlugins:[eu],components:tu,children:p})})]}):null,!p&&C.length===0&&!r&&!f?h.jsx("div",{className:"text-[11px] text-text-400 italic",children:"无详细信息"}):null,S&&(u!=null&&u.open)?h.jsx("div",{className:"flex justify-end",children:h.jsxs("button",{type:"button","data-testid":"open-subagent-btn","data-agent-id":S,onClick:()=>u.open(S,o==null?void 0:o.agentType),className:ne("inline-flex items-center gap-1 rounded-md border border-bg-200/60","bg-bg-100/40 hover:bg-bg-200/40 transition-colors","px-2 py-1 text-[11px] text-text-300"),children:[h.jsx(Hc,{className:"w-3 h-3"}),h.jsx("span",{children:"打开子 agent 对话"})]})}):null]}):null]})}function CM({title:e,items:t,live:n,progressColor:r="bg-green-500",listKind:i,children:s}){const[o,a]=g.useState(!!n),l=t.length,c=t.filter(d=>d.status==="completed").length,u=l>0?Math.round(c/l*100):0;return h.jsxs("div",{"data-testid":"msg-line-checklist","data-list-kind":i,className:"min-w-0 max-w-full py-1",children:[h.jsxs("button",{type:"button",onClick:()=>a(d=>!d),"aria-expanded":o,className:"flex items-center gap-2.5 w-full text-left rounded-md px-1.5 py-1 hover:bg-text-100/5 cursor-pointer",children:[o?h.jsx(ci,{className:"w-3.5 h-3.5 text-text-400 shrink-0"}):h.jsx(ui,{className:"w-3.5 h-3.5 text-text-400 shrink-0"}),h.jsx("span",{className:"text-[13px] font-medium text-text-200",children:e}),h.jsxs("span",{className:"text-[11px] text-text-400 tabular-nums",children:[c,"/",l]}),h.jsx("div",{className:"flex-1 max-w-[120px] h-1.5 rounded-full bg-text-100/10 overflow-hidden",children:h.jsx("div",{className:ne("h-full rounded-full transition-all duration-300",r),style:{width:`${u}%`}})})]}),o?h.jsxs("div",{"data-testid":"checklist-body",className:"ml-6 mt-0.5",children:[h.jsx("div",{className:"space-y-px",children:t.map((d,f)=>h.jsxs("div",{className:"flex min-w-0 items-start gap-2 py-0.5 px-1",children:[h.jsx("span",{className:"w-4 h-4 mt-0.5 flex items-center justify-center shrink-0",children:d.status==="completed"?h.jsx(ol,{className:"w-3.5 h-3.5 text-green-500"}):d.status==="in_progress"&&n?h.jsx(rr,{className:"w-3.5 h-3.5 text-blue-400 animate-spin"}):h.jsx("span",{className:"w-2 h-2 rounded-full border border-text-400/40"})}),h.jsx("span",{className:ne("min-w-0 text-[13px] leading-snug break-words [overflow-wrap:anywhere]",d.status==="completed"?"text-text-400 line-through":"text-text-200"),children:d.status==="in_progress"&&d.activeForm?d.activeForm:d.content})]},`${f}-${d.content}`))}),s]}):null]})}function LZ({todos:e,live:t}){return h.jsx(CM,{title:"Tasks",items:e,live:t,progressColor:"bg-green-500",listKind:"todo"})}function DZ({tasks:e,live:t}){return h.jsx(CM,{title:"Plan",items:e,live:t,progressColor:"bg-blue-500",listKind:"plan"})}function OZ(e){if(!e||!Number.isFinite(e))return null;const t=Date.now()-e;if(t<0)return null;const n=Math.floor(t/1e3);if(n<60)return`${n}s ago`;const r=Math.floor(n/60);if(r<60)return`${r}m ago`;const i=Math.floor(r/60);if(i<24)return`${i}h ago`;const s=Math.floor(i/24);if(s<7)return`${s}d ago`;const o=Math.floor(s/7);return o<5?`${o}w ago`:new Date(e).toISOString().slice(0,10)}function BZ(e){return(e.split("/").pop()??e)||e}function zZ({memories:e}){return!e||e.length===0?null:h.jsxs("div",{"data-testid":"memory-callout",className:"my-1 min-w-0 max-w-full rounded-md border border-bg-200/60 bg-bg-100/30",children:[h.jsxs("div",{className:"flex items-center gap-1.5 px-2.5 py-1.5 text-[12px] text-text-300 border-b border-bg-200/60",children:[h.jsx(B6,{className:"w-3.5 h-3.5 text-amber-500 shrink-0"}),h.jsx("span",{className:"font-medium",children:"项目记忆"}),h.jsxs("span",{className:"text-text-400 tabular-nums",children:["· ",e.length]})]}),h.jsx("ul",{className:"divide-y divide-bg-200/40",children:e.map(t=>h.jsx($Z,{memory:t},t.path))})]})}function $Z({memory:e}){const[t,n]=g.useState(!1),r=OZ(e.mtimeMs),i=e.content.replace(/\s+/g," ").trim().slice(0,80);return h.jsxs("li",{className:"px-2.5 py-1.5",children:[h.jsxs("button",{type:"button","aria-expanded":t,onClick:()=>n(s=>!s),className:ne("flex w-full items-center gap-1.5 text-left text-[12px]","hover:bg-bg-200/30 rounded-sm py-0.5"),children:[t?h.jsx(ci,{className:"w-3 h-3 text-text-400 shrink-0"}):h.jsx(ui,{className:"w-3 h-3 text-text-400 shrink-0"}),h.jsx("span",{className:"font-mono text-text-300 shrink-0 max-w-[20ch] truncate",title:e.path,children:BZ(e.path)}),h.jsx("span",{className:"flex-1 min-w-0 truncate text-text-400/80",children:i}),r?h.jsx("span",{className:"shrink-0 text-[11px] text-text-400 tabular-nums",children:r}):null]}),t?h.jsx("pre",{"data-testid":"memory-callout-body",className:"mt-1 max-w-full whitespace-pre-wrap break-words text-[12px] text-text-300 bg-bg-50/60 rounded-md p-2 border border-bg-200/60 [overflow-wrap:anywhere]",children:e.content}):null]})}function FZ({toolUseId:e,questions:t,onSubmit:n,onCancel:r,submittedAnswers:i}){const[s,o]=g.useState({}),[a,l]=g.useState({}),[c,u]=g.useState({}),[d,f]=g.useState(!1),[p,m]=g.useState(!1),v=i!==void 0&&Object.keys(i).length>0,b=v||p,x=!n&&!v,_=(S,C)=>{const N={labels:new Set,freeText:""};if(!v||!i)return N;const T=i[S];if(typeof T!="string")return N;const M=T.split(",").map(I=>I.trim()).filter(Boolean),P=new Set(C.map(I=>I.label)),D=new Set,R=[];for(const I of M)P.has(I)?D.add(I):R.push(I);return{labels:D,freeText:R.join(", ")}},y=g.useMemo(()=>t.every(S=>{if((c[S.question]??"").trim().length>0)return!0;if(S.multiSelect){const N=a[S.question];return!!(N&&N.size>0)}return typeof s[S.question]=="string"&&s[S.question].length>0}),[t,s,a,c]),w=async()=>{if(!y||d||b||x||!n)return;const S={};for(const C of t){const N=(c[C.question]??"").trim();if(C.multiSelect){const T=a[C.question],M=T?C.options.filter(P=>T.has(P.label)).map(P=>P.label):[];if(N.length>0&&M.push(N),M.length===0)continue;S[C.question]=M.join(", ")}else if(N.length>0)S[C.question]=N;else{const T=s[C.question];typeof T=="string"&&(S[C.question]=T)}}f(!0);try{await n(S),m(!0)}finally{f(!1)}};return h.jsxs("div",{"data-testid":"msg-line-question","data-tool-use-id":e,className:"min-w-0 max-w-full rounded-md border border-accent/40 bg-accent/5 px-3 py-2.5 text-[13px]",children:[h.jsxs("div",{className:"flex min-w-0 items-center gap-2 mb-2",children:[h.jsx(Q6,{className:"w-4 h-4 text-accent shrink-0"}),h.jsx("span",{className:"min-w-0 font-medium text-text-100",children:"需要你的回答 / Need your answer"}),t.length>1?h.jsxs("span",{className:"ml-auto text-[12px] text-text-400","data-testid":"msg-line-question-count",children:[t.length," 个问题"]}):null]}),h.jsx("div",{className:"flex flex-col gap-3 mb-3",children:t.map((S,C)=>{const N=`q-${C}`,T=`${e}-${C}`,M=_(S.question,S.options),P=b||x,D=c[S.question]??"",R=v?M.freeText:p?(c[S.question]??"").trim():"";return h.jsxs("div",{"data-testid":"msg-line-question-item",children:[S.question?h.jsx("div",{className:"text-text-200 mb-1.5",children:S.question}):null,h.jsx("div",{className:"flex flex-col gap-1",children:S.options.map((I,O)=>{var F;const z=`${N}-${O}`,$=v?M.labels.has(I.label):S.multiSelect?!!((F=a[S.question])!=null&&F.has(I.label)):s[S.question]===I.label;return h.jsxs("label",{className:"flex min-w-0 items-start gap-2 cursor-pointer select-none py-1 px-2 rounded hover:bg-bg-100",children:[h.jsx("input",{type:S.multiSelect?"checkbox":"radio",name:T,value:I.label,checked:$,disabled:b||x,onChange:()=>{b||x||(S.multiSelect?l(L=>{const B=new Set(L[S.question]??[]);return B.has(I.label)?B.delete(I.label):B.add(I.label),{...L,[S.question]:B}}):o(L=>({...L,[S.question]:I.label})))},className:"mt-0.5","data-testid":"msg-line-question-option"}),h.jsxs("span",{className:"flex min-w-0 flex-col",children:[h.jsx("span",{className:"text-text-100 [overflow-wrap:anywhere]",children:I.label}),I.description?h.jsx("span",{className:"text-[12px] text-text-400 [overflow-wrap:anywhere]",children:I.description}):null]})]},z)})}),P?R.length>0?h.jsx("div",{className:"mt-2 rounded-lg border border-accent/15 bg-bg-100/60 px-3 py-2 text-[13px] leading-relaxed text-text-200 [overflow-wrap:anywhere]","data-testid":"msg-line-question-freetext-result",children:R}):null:h.jsx("textarea",{rows:3,value:D,placeholder:"或自行输入回答...",onChange:I=>{const O=I.target.value;u(z=>({...z,[S.question]:O}))},className:"mt-2 w-full resize-y rounded-lg border border-accent/20 bg-bg-000/60 px-3 py-2 text-[13px] leading-relaxed text-text-100 placeholder:text-text-400 outline-none transition-colors focus:border-accent/60 focus:bg-bg-000","data-testid":"msg-line-question-freetext"})]},N)})}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(ri,{size:"sm",variant:"default",onClick:()=>void w(),disabled:!y||d||b||x,"data-testid":"msg-line-question-submit",children:b?"已提交 / Submitted":x?"已结束 / Ended":"提交 / Submit"}),r&&!b&&!x?h.jsx(ri,{size:"sm",variant:"ghost",onClick:()=>void r(),disabled:d,"data-testid":"msg-line-question-cancel",children:"跳过 / Skip"}):null]})]})}function HZ({toolUseId:e,questions:t,historicalAnswers:n,realtimeAnswers:r,onSubmit:i,onCancel:s}){const o=r??n,a=g.useCallback(async c=>{i&&await i(e,c)},[i,e]),l=g.useCallback(async()=>{s&&await s(e)},[s,e]);return h.jsx(FZ,{toolUseId:e,questions:t,onSubmit:i?a:void 0,...s?{onCancel:l}:{},submittedAnswers:o})}function UZ(){const e=new Map,t=(n,r)=>`${n}::${r}`;return{register(n,r,i){e.set(t(n,r),i)},resolve(n,r){return n?e.get(t(n,r))??null:null},reset(){e.clear()}}}const ku=UZ();function EM({lines:e,onPermissionRespond:t,onPermissionInterrupt:n,topSlot:r,onRewind:i,rewindableUserMessageIds:s,onFork:o,onQuickAsk:a,realtimeQuestionAnswers:l,onSubmitQuestion:c,onCancelQuestion:u,liveQuestionToolUseIds:d,fileSharingScope:f,onShareFile:p,onOpenInTab:m,onPreviewMarkdown:v}){const b=g.useMemo(()=>FU(e),[e]);return h.jsxs("div",{"data-testid":"message-list",className:"flex w-full min-w-0 max-w-full flex-col gap-2 px-4 py-3",children:[r,b.map(x=>WZ(x,{onRewind:i,rewindableUserMessageIds:s,onPermissionRespond:t,onPermissionInterrupt:n,onFork:o,onQuickAsk:a,realtimeQuestionAnswers:l,onSubmitQuestion:c,onCancelQuestion:u,liveQuestionToolUseIds:d,fileSharingScope:f,onShareFile:p,onOpenInTab:m,onPreviewMarkdown:v}))]})}function WZ(e,t){const{onRewind:n,rewindableUserMessageIds:r,onPermissionRespond:i,onPermissionInterrupt:s,onFork:o,onQuickAsk:a,realtimeQuestionAnswers:l,onSubmitQuestion:c,onCancelQuestion:u,liveQuestionToolUseIds:d,fileSharingScope:f,onShareFile:p,onOpenInTab:m,onPreviewMarkdown:v}=t,b=`${e.kind}-${e.seq}`;switch(e.kind){case"session-init":return null;case"user-text":{const x=typeof e.uuid=="string"?e.uuid:void 0,_=!!(n&&x&&(!r||r.has(x)));return h.jsx(yZ,{text:e.text,senderDisplayName:e.senderDisplayName,rewindTarget:_&&x&&n?{userMessageId:x,onRewind:n}:void 0},b)}case"user-meta":return h.jsx(CZ,{metaKind:e.metaKind,text:e.text},b);case"meta-text":return h.jsx(EZ,{text:e.text,metaSource:e.metaSource},b);case"agent-notification":return h.jsx(TZ,{text:e.text,taskId:e.taskId,parentToolUseId:e.parentToolUseId},b);case"assistant-text":{const x=typeof e.uuid=="string"?e.uuid:void 0,_=x&&(o||a)?{messageUuid:x,onFork:o,onQuickAsk:a}:void 0;return h.jsx(FY,{text:WU(e.text),forkTarget:_},b)}case"assistant-thinking":return h.jsx(HY,{text:e.text},b);case"permission-inline":return h.jsx(pZ,{tool:e.tool,input:e.input,onRespond:i??(()=>{}),onInterrupt:s},b);case"error":return h.jsx(mZ,{message:e.message},b);case"turn-end":return null;case"merged-tool":return VZ(e,b,{fileSharingScope:f,onShareFile:p,onOpenInTab:m,onPreviewMarkdown:v});case"merged-agent":return h.jsx(jZ,{description:e.description,input:e.input,output:e.output,error:e.error,pending:e.pending,notifications:e.notifications,toolResultExtra:e.toolResultExtra,progress:e.progress},b);case"plan-card":return h.jsx(DZ,{tasks:e.tasks},b);case"todo-checklist":return h.jsx(LZ,{todos:e.todos},b);case"memory-callout":return h.jsx(zZ,{memories:e.memories},b);case"question-card":{const x=d===void 0||d.has(e.toolUseId);return h.jsx(HZ,{toolUseId:e.toolUseId,questions:e.questions,historicalAnswers:e.submittedAnswers,realtimeAnswers:l==null?void 0:l[e.toolUseId],onSubmit:x?c:void 0,...x&&u?{onCancel:u}:{}},b)}default:return null}}function VZ(e,t,n){const r=ku.resolve(e.toolKind,e.tool),i=r?r.render({input:e.input,output:e.output,error:e.error,pending:e.pending,toolUseId:e.toolUseId,...n.fileSharingScope?{fileScope:n.fileSharingScope}:{},...n.onShareFile?{onShareFile:n.onShareFile}:{},...n.onOpenInTab?{onOpenInTab:n.onOpenInTab}:{},...n.onPreviewMarkdown?{onPreviewMarkdown:n.onPreviewMarkdown}:{}}):null;return h.jsx(st.Fragment,{children:i??h.jsx(yM,{tool:e.tool,input:e.input,output:e.output,error:e.error,pending:e.pending,...n.fileSharingScope?{fileScope:n.fileSharingScope}:{},...n.onShareFile?{onShareFile:n.onShareFile}:{},...n.onOpenInTab?{onOpenInTab:n.onOpenInTab}:{},...n.onPreviewMarkdown?{onPreviewMarkdown:n.onPreviewMarkdown}:{}})},t)}const qZ={builtin:"Commands",global:"Global",project:"Project",plugin:"Plugin"},gk={builtin:0,global:1,project:2,plugin:3};function KZ({query:e,skills:t,activeIndex:n,onActiveIndexChange:r,onSelect:i,onEmpty:s}){const o=g.useRef(null),a=g.useMemo(()=>NM(t,e),[t,e]),l=g.useMemo(()=>{const c=new Set;let u=null;for(let d=0;d<a.length;d++)a[d].source!==u&&(c.add(d),u=a[d].source);return c},[a]);return g.useEffect(()=>{a.length===0&&(s==null||s())},[a.length,s]),g.useEffect(()=>{var c;try{(c=o.current)==null||c.scrollIntoView({block:"nearest"})}catch{}},[n]),a.length===0?null:h.jsx("div",{"data-testid":"cc-skill-selector",className:"absolute bottom-full left-0 right-0 z-50 mb-1.5 max-h-[320px] overflow-y-auto rounded-2xl border border-bg-300 bg-bg-50 shadow-lg",children:a.map((c,u)=>{const d=u===n,f=l.has(u);return h.jsxs(st.Fragment,{children:[f?h.jsx("div",{className:"sticky top-0 z-10 bg-bg-50/95 backdrop-blur-sm px-4 py-2 text-[10px] font-semibold uppercase tracking-wider text-text-400/70 border-b border-bg-200/60",children:qZ[c.source]}):null,h.jsxs("div",{ref:d?o:void 0,"data-testid":`cc-skill-item-${c.name}`,onMouseEnter:()=>r(u),onClick:()=>i(c),className:ne("flex items-center gap-2.5 px-4 py-2 cursor-pointer transition-colors duration-75",d?"bg-[var(--text-100-dim)]":"hover:bg-bg-100/60"),children:[h.jsxs("code",{className:"text-[12px] font-mono font-semibold text-text-100 shrink-0",children:["/",c.name]}),c.description?h.jsx("span",{className:"text-[11px] text-text-300 truncate ml-auto",children:c.description}):null]})]},`${c.source}/${c.name}`)})})}function NM(e,t){const n=t.trim().toLowerCase(),r=n?e.filter(i=>i.name.toLowerCase().includes(n)||(i.description??"").toLowerCase().includes(n)):e.slice();return r.sort((i,s)=>(gk[i.source]??9)-(gk[s.source]??9)),r.slice(0,30)}const GZ={builtin:"Built-in",global:"Global",project:"Project",policy:"Policy",plugin:"Plugin",persona:"My personas",contact:"People","remote-persona":"Remote personas"},vk={builtin:0,global:1,project:2,policy:3,plugin:4,persona:5,contact:6,"remote-persona":7};function of(e){switch(e.kind){case"persona":return"persona";case"contact":return"contact";case"remote-persona":return"remote-persona";case"cc-agent":return e.agent.source}}function XZ(e){switch(e.kind){case"persona":return`persona/${e.persona.personaId}`;case"contact":return`contact/${e.contact.deviceId}`;case"remote-persona":return`remote/${e.deviceId}/${e.persona.personaId}`;case"cc-agent":return`${e.agent.source}/${e.agent.name}`}}function YZ(e){switch(e.kind){case"persona":return`${e.persona.personaId} ${e.persona.label}`.toLowerCase();case"contact":return`${e.contact.displayName} ${e.contact.deviceId}`.toLowerCase();case"remote-persona":return`${e.persona.personaId} ${e.persona.label}`.toLowerCase();case"cc-agent":{const t=e.agent;return`${t.name} ${t.description??""} ${t.whenToUse??""}`.toLowerCase()}}}function ZZ(e){switch(e.kind){case"persona":return{displayName:`@persona/${e.persona.personaId}`,description:e.persona.label,testid:`cc-agent-item-persona-${e.persona.personaId}`};case"contact":return{displayName:`@${e.contact.displayName}`,description:e.contact.deviceId,testid:`cc-agent-item-contact-${e.contact.deviceId}`};case"remote-persona":return{displayName:`@persona/${e.persona.personaId}`,description:e.persona.label,testid:`cc-agent-item-remote-${e.deviceId}-${e.persona.personaId}`};case"cc-agent":return{displayName:`@${e.agent.name}`,description:e.agent.description,whenToUse:e.agent.whenToUse,plugin:e.agent.plugin,testid:`cc-agent-item-${e.agent.name}`}}}function TM(e,t){const n=t.trim().toLowerCase(),r=n?e.filter(i=>YZ(i).includes(n)):e.slice();return r.sort((i,s)=>(vk[of(i)]??9)-(vk[of(s)]??9)),r.slice(0,30)}function xk({query:e,entries:t,activeIndex:n,onActiveIndexChange:r,onSelect:i,onEmpty:s}){const o=g.useRef(null),a=g.useMemo(()=>TM(t,e),[t,e]),l=g.useMemo(()=>{const c=new Set;let u=null;for(let d=0;d<a.length;d++){const f=of(a[d]);f!==u&&(c.add(d),u=f)}return c},[a]);return g.useEffect(()=>{a.length===0&&(s==null||s())},[a.length,s]),g.useEffect(()=>{var c;try{(c=o.current)==null||c.scrollIntoView({block:"nearest"})}catch{}},[n]),a.length===0?null:h.jsx("div",{"data-testid":"cc-agent-selector",className:"absolute bottom-full left-0 right-0 z-50 mb-1.5 max-h-[320px] overflow-y-auto rounded-2xl border border-bg-300 bg-bg-50 shadow-lg",children:a.map((c,u)=>{const d=u===n,f=l.has(u),p=of(c),m=ZZ(c);return h.jsxs(st.Fragment,{children:[f?h.jsx("div",{"data-testid":`cc-agent-group-header-${p}`,"data-source":p,className:"sticky top-0 z-10 bg-bg-50/95 backdrop-blur-sm px-4 py-2 text-[10px] font-semibold uppercase tracking-wider text-text-400/70 border-b border-bg-200/60",children:GZ[p]}):null,h.jsxs("div",{ref:d?o:void 0,"data-testid":m.testid,onMouseEnter:()=>r(u),onClick:()=>i(c),className:ne("flex items-center gap-2.5 px-4 py-2 cursor-pointer transition-colors duration-75",d?"bg-[var(--text-100-dim)]":"hover:bg-bg-100/60"),children:[h.jsx("code",{className:"text-[12px] font-mono font-semibold text-text-100 shrink-0",children:m.displayName}),m.description?h.jsx("span",{className:"text-[11px] text-text-300 truncate ml-2",children:m.description}):null,m.whenToUse?h.jsx("span",{className:"text-[10px] text-text-400/70 italic truncate ml-auto",children:m.whenToUse}):null,m.plugin?h.jsx("span",{className:"text-[10px] text-text-400/70 ml-2 shrink-0",children:m.plugin}):null]})]},XZ(c))})})}function QZ({attachment:e,onRemove:t,onOpenPreview:n}){const r=e.mimeType.startsWith("image/"),i=e.status==="error",s=e.status==="uploading",o=r&&e.status==="done"&&!!e.previewUrl&&!!n;return h.jsxs("div",{"data-testid":`attachment-pill-${e.id}`,className:ne("group relative flex items-center gap-1.5 rounded-lg border px-2 py-1.5 text-[12px] transition-colors",i?"border-red-400/40 bg-red-500/5":"border-bg-300 bg-bg-100"),children:[r&&e.previewUrl?h.jsxs("div",{className:"relative h-7 w-7 shrink-0",children:[h.jsx("img",{src:e.previewUrl,alt:e.fileName,onClick:o?n:void 0,"data-testid":`attachment-thumb-${e.id}`,className:ne("h-7 w-7 rounded object-cover",o&&"cursor-pointer hover:opacity-80",s&&"opacity-40")}),s?h.jsx(rr,{"data-testid":`attachment-spinner-${e.id}`,className:"absolute inset-0 m-auto h-3.5 w-3.5 animate-spin text-text-200"}):null]}):h.jsx("div",{className:"relative flex h-7 w-7 items-center justify-center rounded bg-text-100/5 shrink-0",children:s?h.jsx(rr,{"data-testid":`attachment-spinner-${e.id}`,className:"h-3.5 w-3.5 animate-spin text-text-400"}):h.jsx(Ds,{className:"h-3.5 w-3.5 text-text-400"})}),h.jsx("span",{className:ne("max-w-[120px] truncate text-text-200",s&&"text-text-400"),title:e.error??e.fileName,children:e.fileName}),i?h.jsx(Ls,{className:"h-3 w-3 text-red-400 shrink-0"}):null,h.jsx("button",{type:"button",onClick:t,"data-testid":`attachment-remove-${e.id}`,className:"flex h-4 w-4 items-center justify-center rounded-full text-text-400 hover:text-text-100 hover:bg-text-100/10 transition-colors cursor-pointer shrink-0","aria-label":"remove",children:h.jsx(Rn,{className:"h-3 w-3"})})]})}function JZ({attachments:e,onRemove:t,onOpenPreview:n}){return e.length===0?null:h.jsx("div",{"data-testid":"attachment-row",className:"flex flex-wrap gap-1.5 mb-2 px-1",children:e.map(r=>h.jsx(QZ,{attachment:r,onRemove:()=>t(r.id),onOpenPreview:n?()=>n(r):void 0},r.id))})}class Kl extends Error{constructor(t,n,r){super(n),this.code=t,this.status=r,this.name="UploadAttachmentError"}}async function eQ(e){if(!e.httpBaseUrl)throw new Kl("TUNNEL_NOT_READY","daemon httpBaseUrl unavailable");if(!e.httpToken)throw new Kl("NO_AUTH","daemon httpToken unavailable");const t=new URLSearchParams({sessionId:e.sessionId,fileName:e.file.name,mimeType:e.file.type||"application/octet-stream"}),n=`${e.httpBaseUrl.replace(/\/$/,"")}/attachments/upload?${t.toString()}`;let r;try{r=await fetch(n,{method:"POST",headers:{Authorization:`Bearer ${e.httpToken}`,"Content-Type":e.file.type||"application/octet-stream"},body:e.file})}catch(i){throw new Kl("NETWORK_ERROR",i.message)}if(!r.ok){let i="UPLOAD_FAILED",s=`HTTP ${r.status}`;try{const o=await r.json();o.code&&(i=o.code),o.message&&(s=o.message)}catch{}throw new Kl(i,s,r.status)}return await r.json()}const _k=25*1024*1024,tQ="image/*,.txt,.md,.markdown,.csv,.json,.log,.yaml,.yml,.html,.xml,.pdf",nQ=["image/","text/"],rQ=new Set(["application/json","application/xml","application/x-yaml","application/yaml","application/pdf"]),iQ=new Set(["txt","md","markdown","csv","json","log","yaml","yml","html","xml","pdf"]);function sQ(e){var r;const t=(e.type||"").toLowerCase();if(t&&nQ.some(i=>t.startsWith(i))||t&&rQ.has(t))return!0;const n=((r=e.name.split(".").pop())==null?void 0:r.toLowerCase())??"";return n.length>0&&iQ.has(n)}let oQ=0;const aQ=()=>`att-${++oQ}-${Date.now()}`;function lQ(e){return new Promise((t,n)=>{const r=new FileReader;r.onload=()=>t(typeof r.result=="string"?r.result:""),r.onerror=()=>n(r.error??new Error("read failed")),r.readAsDataURL(e)})}function cQ(e){const[t,n]=g.useState(e.initial??[]),r=g.useCallback(async o=>{const a=Array.from(o);if(a.length===0)return;const l=[],c=[],u=[];for(const d of a){const f={id:aQ(),fileName:d.name,mimeType:d.type||"application/octet-stream"};if(!sQ(d)){c.push({...f,url:null,status:"error",error:"不支持的文件类型"});continue}if(d.size>_k){c.push({...f,url:null,status:"error",error:`超过 ${Math.round(_k/1024/1024)}MB 上限`});continue}if(e.sessionId==null){u.push({id:f.id,file:d,mimeType:f.mimeType}),c.push({...f,url:null,status:"uploading"});continue}const p=f.mimeType.startsWith("image/")?URL.createObjectURL(d):void 0;c.push({...f,url:null,status:"uploading",...p?{previewUrl:p}:{}}),l.push({id:f.id,file:d})}n(d=>[...d,...c]);for(const d of u)try{const f=await lQ(d.file);n(p=>p.map(m=>m.id===d.id?{...m,url:f,status:"done",...d.mimeType.startsWith("image/")?{previewUrl:f}:{}}:m))}catch(f){n(p=>p.map(m=>m.id===d.id?{...m,status:"error",error:f.message??"read failed"}:m))}l.length!==0&&await Promise.all(l.map(async d=>{try{const f=await eQ({httpBaseUrl:e.httpBaseUrl,httpToken:e.httpToken,sessionId:e.sessionId,file:d.file});n(p=>p.map(m=>m.id===d.id?{...m,url:f.url,status:"done"}:m))}catch(f){const p=f instanceof Kl?f.code:"UPLOAD_FAILED",m=f.message??"upload failed";n(v=>v.map(b=>b.id===d.id?{...b,status:"error",error:`${p}: ${m}`}:b))}}))},[e.sessionId,e.httpBaseUrl,e.httpToken]),i=g.useCallback(o=>{n(a=>a.filter(l=>l.id!==o))},[]),s=g.useCallback(()=>{n([])},[]);return{attachments:t,setAttachments:n,addFiles:r,removeAttachment:i,clearAttachments:s}}const C0=new Map,uQ=[];function yk(e){if(e)return C0.get(e)}function bk(e,t){e&&(t.draft.length===0&&t.attachments.length===0?C0.delete(e):C0.set(e,t))}function dQ(e,t){return e.replace(/(^|\s)\/(\S+)/g,(n,r,i)=>{const s=t.find(o=>o.name===i&&o.path);return s!=null&&s.path?`${r}[skill:${i}:${s.path}]`:n})}function hQ({api:e,cwd:t,sessionKey:n,onSend:r,disabled:i,onNewSession:s,onClearSession:o,tool:a,spawnableContacts:l=uQ,ensureRemotePersonas:c,remotePersonasByDeviceId:u}){const d=yk(n),[f,p]=g.useState((d==null?void 0:d.draft)??""),[m,v]=g.useState(!1),b=g.useRef(null),x=g.useRef(!1),_=g.useCallback(()=>{x.current=!0},[]),y=g.useCallback(()=>{x.current=!1},[]),w=Xf(),{attachments:S,setAttachments:C,addFiles:N,removeAttachment:T,clearAttachments:M}=cQ({httpBaseUrl:w.httpBaseUrl,httpToken:w.httpToken,sessionId:n,initial:(d==null?void 0:d.attachments)??[]}),[P,D]=g.useState([]),[R,I]=g.useState(!1),[O,z]=g.useState(0),[$,F]=g.useState(!1),[L,B]=g.useState([]),[E,H]=g.useState(!1),[q,A]=g.useState(0),[re,oe]=g.useState(!1),[V,pe]=g.useState([]),[Oe,ie]=g.useState(!1),[Ae,Fe]=g.useState(null),[We,ge]=g.useState(!1),qe=g.useRef(null),Gt=g.useMemo(()=>{const ue=[];return s&&ue.push({name:"new",source:"builtin",description:"在当前目录下新建会话"}),o&&n&&ue.push({name:"clear",source:"builtin",description:"清除当前会话"}),ue},[s,o,n]),wt=g.useMemo(()=>[...Gt,...P],[Gt,P]),Rt=g.useMemo(()=>{const ue=f.match(/^\/(\S*)$/);return ue?ue[1]:null},[f]),ln=Rt!==null&&!$,Bt=g.useMemo(()=>Rt!==null?NM(wt,Rt):[],[wt,Rt]),at=g.useMemo(()=>{const ue=f.match(/^@(\S*)$/);return ue?ue[1]:null},[f]),Ue=at!==null&&!re,nt=g.useMemo(()=>Ae?((u==null?void 0:u.get(Ae.deviceId))??[]).map(Te=>({kind:"remote-persona",persona:Te,deviceId:Ae.deviceId})):[...L.map(ue=>({kind:"cc-agent",agent:ue})),...V.map(ue=>({kind:"persona",persona:ue})),...l.map(ue=>({kind:"contact",contact:ue}))],[Ae,u,L,V,l]),mt=g.useMemo(()=>at!==null?TM(nt,at):[],[nt,at]),Xt=g.useRef(f);g.useEffect(()=>{f!==Xt.current&&(F(!1),oe(!1),Xt.current=f)},[f]);const pn=g.useCallback(()=>{F(!0)},[]),U=g.useCallback(()=>{oe(!0)},[]),Q=g.useRef(f),ve=g.useRef(S);g.useEffect(()=>{Q.current=f},[f]),g.useEffect(()=>{ve.current=S},[S]);const Se=g.useRef(n);g.useEffect(()=>{const ue=Se.current;if(ue===n)return;bk(ue,{draft:Q.current,attachments:ve.current});const Te=yk(n);p((Te==null?void 0:Te.draft)??""),C((Te==null?void 0:Te.attachments)??[]),z(0),A(0),F(!1),oe(!1),Fe(null),qe.current=null,ge(!1),queueMicrotask(()=>{Te!=null&&Te.draft?PM(b.current):Xo(b.current)}),Se.current=n},[n,C]),g.useEffect(()=>()=>{bk(Se.current,{draft:Q.current,attachments:ve.current})},[]),g.useEffect(()=>{z(0)},[Rt]),g.useEffect(()=>{A(0)},[at]),g.useEffect(()=>{at===null&&Ae&&(Fe(null),qe.current=null,ge(!1))},[at,Ae]),g.useEffect(()=>{if(!ln||R)return;if(!e){I(!0);return}let ue=!1;return(async()=>{try{const Te=await e.skillsList(t,a);ue||(D(Te.skills??[]),I(!0))}catch{ue||I(!0)}})(),()=>{ue=!0}},[ln,R,e,t,a]),g.useEffect(()=>{if(!Ue||E)return;if(!e){H(!0);return}let ue=!1;return(async()=>{try{const Te=await e.agentsList(t,a);ue||(B(Te.agents??[]),H(!0))}catch{ue||H(!0)}})(),()=>{ue=!0}},[Ue,E,e,t,a]),g.useEffect(()=>{if(!Ue||Oe)return;if(!e){ie(!0);return}let ue=!1;return(async()=>{try{const Te=await e.personaList();ue||(pe((Te.personas??[]).map(Je=>({personaId:Je.personaId,label:Je.label,iconKey:Je.iconKey}))),ie(!0))}catch{ue||ie(!0)}})(),()=>{ue=!0}},[Ue,Oe,e]);const J=g.useCallback(ue=>{switch(ue.kind){case"persona":p(`@persona/${ue.persona.personaId} `);break;case"cc-agent":p(`@"${ue.agent.name} (agent)" `);break;case"contact":{const Te=ue.contact.deviceId;Fe({deviceId:Te,displayName:ue.contact.displayName}),qe.current=Te,ge(!0),Promise.resolve(c==null?void 0:c(Te)).finally(()=>{qe.current===Te&&ge(!1)}),p("@"),oe(!1),setTimeout(()=>{var Je;return(Je=b.current)==null?void 0:Je.focus()},0);return}case"remote-persona":p(`@persona/${ue.persona.personaId}@${ue.deviceId} `),Fe(null);break}oe(!1),setTimeout(()=>{var Te;return(Te=b.current)==null?void 0:Te.focus()},0)},[c]),Ye=g.useCallback(()=>{Fe(null),qe.current=null,ge(!1),p("@"),setTimeout(()=>{var ue;return(ue=b.current)==null?void 0:ue.focus()},0)},[]),Yt=g.useCallback(ue=>{if(ue.source==="builtin"&&ue.name==="new"&&s){p(""),M(),Xo(b.current),s(t);return}if(ue.source==="builtin"&&ue.name==="clear"&&o){p(""),M(),Xo(b.current),o();return}p(`/${ue.name} `),setTimeout(()=>{var Te;return(Te=b.current)==null?void 0:Te.focus()},0)},[s,t,M,o]),Zt=g.useCallback(async()=>{const ue=f.trim(),Te=S.filter(Je=>Je.status==="done");if(!(!ue&&Te.length===0)&&!(m||i)){if(ue==="/new"&&s){v(!0);try{await s(t),p(""),M(),Xo(b.current)}finally{v(!1)}return}if(ue==="/clear"&&o){v(!0);try{await o(),p(""),M(),Xo(b.current)}finally{v(!1)}return}v(!0);try{const Je=a==="codex"?dQ(ue,P):ue,Ln=vZ(Je,S);await r(Ln),p(""),M(),Xo(b.current)}finally{v(!1)}}},[f,S,m,i,r,s,t,M,o,a,P]);return{draft:f,setDraft:p,sending:m,textareaRef:b,isComposingRef:x,onCompositionStart:_,onCompositionEnd:y,attachments:S,addFiles:N,removeAttachment:T,skillSelectorVisible:ln,filteredSkills:Bt,slashQuery:Rt??"",activeSkillIdx:O,setActiveSkillIdx:z,selectSkill:Yt,dismissSkillSelector:pn,agentSelectorVisible:Ue,filteredAgents:mt,mentionQuery:at,activeAgentIdx:q,setActiveAgentIdx:A,selectAgent:J,dismissAgentSelector:U,drilldown:Ae,drilldownLoading:We,exitDrilldown:Ye,doSend:Zt}}const fQ=120;function PM(e){e&&(e.style.height="auto",e.style.height=`${Math.min(e.scrollHeight,fQ)}px`)}function Xo(e){e&&(e.style.height="auto")}const pQ={spawnableContacts:[],ensureRemotePersonas:()=>Promise.resolve(),remotePersonasByDeviceId:new Map},mQ=g.createContext(pQ);function gQ(){return g.useContext(mQ)}function vQ({url:e,fileName:t,onClose:n}){const[r,i]=g.useState(!1);g.useEffect(()=>{const o=a=>{a.key==="Escape"&&n()};return document.addEventListener("keydown",o),()=>document.removeEventListener("keydown",o)},[n]);const s=async()=>{try{const a=await(await fetch(e)).blob();await navigator.clipboard.write([new ClipboardItem({[a.type]:a})]),i(!0),setTimeout(()=>i(!1),2e3)}catch{wk(e,t)}};return h.jsx("div",{"data-testid":"image-lightbox",className:"fixed inset-0 z-[9999] flex items-center justify-center bg-black/60",onClick:n,role:"dialog","aria-modal":"true",children:h.jsxs("div",{className:"relative",onClick:o=>o.stopPropagation(),children:[h.jsx("img",{src:e,alt:t,className:"max-h-[90vh] max-w-[92vw] rounded-lg object-contain shadow-2xl"}),h.jsxs("div",{className:"absolute right-2 top-2 flex items-center gap-1.5",children:[h.jsxs("button",{type:"button",onClick:s,"data-testid":"image-lightbox-copy",className:"flex cursor-pointer items-center gap-1 rounded-full border border-bg-300 bg-bg-50/95 px-2 py-0.5 text-[11px] font-medium text-text-200 shadow transition-colors hover:bg-bg-100",children:[h.jsx(mu,{className:"h-3 w-3"}),r?"Copied":"Copy"]}),h.jsxs("button",{type:"button",onClick:()=>wk(e,t),"data-testid":"image-lightbox-save",className:"flex cursor-pointer items-center gap-1 rounded-full border border-bg-300 bg-bg-50/95 px-2 py-0.5 text-[11px] font-medium text-text-200 shadow transition-colors hover:bg-bg-100",children:[h.jsx(lz,{className:"h-3.5 w-3.5"}),"Save"]}),h.jsx("button",{type:"button",onClick:n,"data-testid":"image-lightbox-close","aria-label":"close",className:"flex h-6 w-6 cursor-pointer items-center justify-center rounded-full border border-bg-300 bg-bg-50/95 text-text-300 transition-colors hover:bg-bg-100 hover:text-text-100",children:h.jsx(Rn,{className:"h-3 w-3"})})]})]})})}function wk(e,t){const n=document.createElement("a");n.href=e,n.download=t||"image",n.click()}function xQ({meta:e,api:t,cwd:n,tool:r,onSend:i,sessionKey:s,disabled:o=!1,placeholder:a,className:l,awaitingUser:c=!1,onAbort:u,onNewSession:d,onClearSession:f}){const p=(e==null?void 0:e.streamInProgress)??!1,m=g.useRef(null),v=gQ(),b=hQ({...t?{api:t}:{},cwd:n,...r?{tool:r}:{},sessionKey:s,onSend:i,disabled:o,...d?{onNewSession:d}:{},...f?{onClearSession:f}:{},spawnableContacts:v.spawnableContacts,ensureRemotePersonas:v.ensureRemotePersonas,remotePersonasByDeviceId:v.remotePersonasByDeviceId}),{draft:x,setDraft:_,sending:y,textareaRef:w,attachments:S,addFiles:C,removeAttachment:N,skillSelectorVisible:T,filteredSkills:M,slashQuery:P,activeSkillIdx:D,setActiveSkillIdx:R,selectSkill:I,dismissSkillSelector:O,agentSelectorVisible:z,filteredAgents:$,mentionQuery:F,activeAgentIdx:L,setActiveAgentIdx:B,selectAgent:E,dismissAgentSelector:H,drilldown:q,drilldownLoading:A,exitDrilldown:re,doSend:oe}=b,V=!!t,pe=y||o||p,ie=(x.trim().length>0||S.some(J=>J.status==="done"))&&!o&&!y&&!c,Ae=a??(c?"Answer the question above first...":pe?"Queue a message...":`Message ${Gd(r)}...`),Fe=g.useRef(!1),We=g.useCallback(()=>{Fe.current=!0},[]),ge=g.useCallback(()=>{Fe.current=!1},[]),qe=g.useCallback(J=>{if(T&&M.length>0){if(J.key==="ArrowDown")return J.preventDefault(),R(D>=M.length-1?0:D+1),!0;if(J.key==="ArrowUp")return J.preventDefault(),R(D<=0?M.length-1:D-1),!0;if(J.key==="Tab"||J.key==="Enter"&&!J.shiftKey){J.preventDefault();const Ye=M[D];return Ye&&I(Ye),!0}if(J.key==="Escape")return J.preventDefault(),O(),!0}return!1},[T,M,D,R,I,O]),Gt=g.useCallback(J=>{if(z&&$.length>0){if(J.key==="ArrowDown")return J.preventDefault(),B(L>=$.length-1?0:L+1),!0;if(J.key==="ArrowUp")return J.preventDefault(),B(L<=0?$.length-1:L-1),!0;if(J.key==="Tab"||J.key==="Enter"&&!J.shiftKey){J.preventDefault();const Ye=$[L];return Ye&&E(Ye),!0}if(J.key==="Escape")return J.preventDefault(),q?re():H(),!0}return!1},[z,$,L,B,E,H,q,re]),wt=g.useCallback(J=>{const Ye=J.nativeEvent;J.key==="Enter"&&qI({compositionActive:Fe.current,nativeIsComposing:Ye.isComposing,keyCode:Ye.keyCode})||qe(J)||Gt(J)||KI({key:J.key,shiftKey:J.shiftKey,compositionActive:Fe.current,nativeIsComposing:Ye.isComposing,keyCode:Ye.keyCode})&&(J.preventDefault(),ie&&oe())},[qe,Gt,ie,oe]),Rt=g.useCallback(J=>{_(J.target.value),PM(J.target)},[_]),ln=g.useCallback(J=>{J.target.files&&C(J.target.files),J.target.value=""},[C]),Bt=g.useCallback(J=>{if(!V)return;const Ye=Array.from(J.clipboardData.items).map(Yt=>Yt.getAsFile()).filter(Yt=>!!(Yt&&Yt.type.startsWith("image/")));Ye.length!==0&&(J.preventDefault(),C(Ye))},[C,V]),[at,Ue]=g.useState(null),nt=g.useCallback(J=>{J.previewUrl&&Ue({url:J.previewUrl,name:J.fileName})},[]),[mt,Xt]=g.useState(!1),pn=g.useCallback(J=>{V&&(J.preventDefault(),Xt(!0))},[V]),U=g.useCallback(()=>Xt(!1),[]),Q=g.useCallback(J=>{V&&(J.preventDefault(),Xt(!1),J.dataTransfer.files.length>0&&C(J.dataTransfer.files))},[C,V]),ve=p&&!c&&typeof u=="function",Se=o||c;return h.jsxs("div",{"data-testid":"chat-input",className:ne("shrink-0 border-t border-bg-300/20 px-4 py-3",l),onDragOver:pn,onDragLeave:U,onDrop:Q,children:[h.jsxs("div",{className:"max-w-3xl mx-auto relative",children:[V?h.jsx("input",{ref:m,type:"file",multiple:!0,accept:tQ,hidden:!0,onChange:ln,"data-testid":"chat-input-file"}):null,h.jsxs("div",{"data-testid":"chat-input-bare",className:ne("flex flex-col gap-2"),children:[c||y||p?h.jsxs("div",{"data-testid":"chat-input-status-bar",className:"flex items-center gap-2 text-[12px] text-text-400",children:[h.jsxs("div",{className:"flex gap-1",children:[h.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-text-400-dim-fg animate-bounce",style:{animationDelay:"0ms"}}),h.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-text-400-dim-fg animate-bounce",style:{animationDelay:"150ms"}}),h.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-text-400-dim-fg animate-bounce",style:{animationDelay:"300ms"}})]}),h.jsx("span",{children:c?"Waiting for your answer":`${r==="codex"?"Codex":"Claude"} is working`})]}):null,T?h.jsx(KZ,{query:P,skills:M,activeIndex:D,onActiveIndexChange:R,onSelect:I}):null,z?q?!v.remotePersonasByDeviceId.has(q.deviceId)&&A?h.jsx("div",{"data-testid":"cc-agent-remote-loading",className:"absolute bottom-full left-0 right-0 z-50 mb-1.5 rounded-2xl border border-bg-300 bg-bg-50 px-4 py-3 text-[12px] text-text-300 shadow-lg",children:`正在加载 @${q.displayName} 的 persona…`}):$.length>0?h.jsx(xk,{query:F??"",entries:$,activeIndex:L,onActiveIndexChange:B,onSelect:E}):h.jsx("div",{"data-testid":"cc-agent-remote-empty",className:"absolute bottom-full left-0 right-0 z-50 mb-1.5 rounded-2xl border border-bg-300 bg-bg-50 px-4 py-3 text-[12px] text-text-300 shadow-lg",children:`@${q.displayName} 暂无可派活的 persona(可能离线或未公开)`}):h.jsx(xk,{query:F??"",entries:$,activeIndex:L,onActiveIndexChange:B,onSelect:E}):null,S.length>0?h.jsx(JZ,{attachments:S,onRemove:N,onOpenPreview:nt}):null,h.jsxs("div",{"data-testid":"bare-chat-input-frame",className:ne("flex items-end gap-2 rounded-xl border border-bg-300 bg-bg-50 px-3 py-2 transition-colors duration-200",Se?"opacity-60":null,mt?"border-accent/60 bg-accent/5":null),children:[V?h.jsx("button",{type:"button",onClick:()=>{var J;return(J=m.current)==null?void 0:J.click()},disabled:pe,"data-testid":"chat-input-attach","aria-label":"attach files",className:ne("flex h-8 w-8 shrink-0 self-end items-center justify-center rounded-md transition-colors",pe?"cursor-default text-text-400/50":"cursor-pointer text-text-400 hover:bg-text-100/5 hover:text-text-200"),children:h.jsx(Bz,{className:"h-4 w-4"})}):null,h.jsx("textarea",{ref:w,"data-testid":"chat-input-textarea",value:x,onChange:Rt,onKeyDown:wt,onCompositionStart:We,onCompositionEnd:ge,onPaste:Bt,placeholder:Ae,disabled:Se,readOnly:Se,rows:1,className:"flex-1 resize-none bg-transparent border-0 outline-none text-[14px] text-text-100 placeholder:text-text-400 leading-relaxed py-1 min-h-[22px] max-h-[120px] overflow-y-auto disabled:cursor-not-allowed"}),h.jsxs("div",{className:"flex items-center gap-1.5 shrink-0 pb-0.5",children:[ve?h.jsx("button",{type:"button",onClick:u,"data-testid":"chat-input-abort","aria-label":"interrupt",title:"中断当前轮次(不杀进程)",className:"h-8 w-8 rounded-full flex items-center justify-center border border-text-400/40 text-text-400 hover:bg-text-100/5 hover:text-text-100 transition-colors cursor-pointer",children:h.jsx(TT,{className:"w-3.5 h-3.5",strokeWidth:2.5})}):null,h.jsx("button",{type:"button",onClick:()=>{ie&&oe()},disabled:!ie,"data-testid":"chat-input-send","aria-label":"send",className:ne("h-8 w-8 rounded-full flex items-center justify-center transition-colors",ie?"bg-accent text-white hover:bg-accent-hover cursor-pointer shadow-sm":"bg-[var(--text-400-dim)] text-[var(--text-400-dim-fg)] cursor-default"),children:h.jsx(A6,{className:"w-4 h-4",strokeWidth:2.5})})]})]})]})]}),at?h.jsx(vQ,{url:at.url,fileName:at.name,onClose:()=>Ue(null)}):null]})}function _Q(e){const t=e.replace(/\/+$/,""),n=t.lastIndexOf("/");return n>=0?t.slice(n+1):t}function yQ({meta:e,tool:t,connState:n,onOpenConfig:r,models:i,liveGitBranch:s,liveWorktreeRoot:o,onForceStop:a,cronActiveCount:l,onCronClick:c,onOpenFiles:u,onTogglePin:d,isHolded:f=!1,onToggleHold:p,personaName:m,onOpenPersona:v,className:b}){const x=e.procAlive??!1,_=e.streamInProgress??!1,y=e.permissionMode,w=y&&y!=="default"?y:null,S=w==="bypassPermissions"?"YOLO":w==="plan"?"Plan":null,C=e.model??"",N=bQ(i,C),T=e.contextPct??null,M=T==null?"":T>=80?"text-red-400":T>=50?"text-amber-400":"text-text-500",P=s!==void 0?s:e.gitBranch??null,D=o??e.cwd??"",I=!!e.sessionLabel&&e.sessionLabel!==e.sessionId?e.sessionLabel:_Q(D),O=D,z=e.pinnedAt!=null;return h.jsxs("div",{"data-testid":"chat-header",className:ne("relative flex flex-col justify-center shrink-0 px-4 pr-14 py-2 gap-1",b),children:[h.jsxs("div",{className:"flex items-center min-w-0 gap-2 text-[13px]",children:[d?h.jsx("button",{type:"button",onClick:()=>d(!z),"data-testid":"chat-header-pin-toggle","data-pinned":z?"true":"false","aria-pressed":z,title:z?"Unpin session":"Pin session",className:ne("shrink-0 inline-flex items-center justify-center h-5 w-5 rounded-md cursor-pointer transition-colors",z?"text-amber-400 hover:bg-amber-500/10":"text-text-500 hover:text-text-200 hover:bg-text-100/5"),children:h.jsx(IT,{className:ne("w-3.5 h-3.5",z&&"fill-current")})}):null,p?h.jsx("button",{type:"button",onClick:()=>p(!f),"data-testid":"chat-header-hold-toggle","data-holded":f?"true":"false","aria-pressed":f,title:f?"Release hold":"Hold session",className:ne("shrink-0 inline-flex items-center justify-center h-5 w-5 rounded-md cursor-pointer transition-colors",f?"text-amber-400 hover:bg-amber-500/10":"text-text-500 hover:text-text-200 hover:bg-text-100/5"),children:h.jsx(H6,{className:ne("w-3.5 h-3.5",f&&"fill-current")})}):null,h.jsx("span",{className:"font-semibold text-text-100 truncate","data-testid":"chat-header-worktree",title:O,children:I}),P?h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"text-text-500 shrink-0",children:":"}),h.jsx("span",{className:"font-mono text-text-300 truncate","data-testid":"chat-header-git",title:P,children:P})]}):null]}),h.jsxs("div",{className:"flex items-center min-w-0 gap-2 text-[11px]",children:[S?h.jsxs(h.Fragment,{children:[h.jsx("button",{type:"button",onClick:()=>r==null?void 0:r("desktop"),"data-testid":"chat-header-mode-chip",className:ne("hidden md:inline-flex shrink-0 px-2 py-0.5 rounded-md font-semibold cursor-pointer transition-colors",w==="bypassPermissions"?"bg-red-500/15 text-red-400 hover:bg-red-500/25":"bg-blue-500/15 text-blue-400 hover:bg-blue-500/25"),children:S}),h.jsx("button",{type:"button",onClick:()=>r==null?void 0:r("mobile"),"aria-hidden":"true",tabIndex:-1,className:ne("inline-flex md:hidden shrink-0 px-2 py-0.5 rounded-md font-semibold cursor-pointer transition-colors",w==="bypassPermissions"?"bg-red-500/15 text-red-400 hover:bg-red-500/25":"bg-blue-500/15 text-blue-400 hover:bg-blue-500/25"),children:S})]}):null,C||i?h.jsxs(h.Fragment,{children:[h.jsx("button",{type:"button",onClick:()=>r==null?void 0:r("desktop"),"data-testid":"chat-header-model-chip",className:"hidden md:inline-flex shrink-0 font-mono text-text-400 cursor-pointer hover:text-text-200 transition-colors",children:N}),h.jsx("button",{type:"button",onClick:()=>r==null?void 0:r("mobile"),"aria-hidden":"true",tabIndex:-1,className:"inline-flex md:hidden shrink-0 font-mono text-text-400 cursor-pointer hover:text-text-200 transition-colors",children:N})]}):null,T!=null?h.jsxs("span",{className:ne("shrink-0 font-mono",M),"data-testid":"chat-header-ctx",children:["ctx:",T,"%"]}):null,h.jsxs("span",{"data-testid":"chat-header-proc-status",className:"inline-flex items-center gap-1 text-text-500 shrink-0",title:_?`${Gd(t)} 正在跑当前 turn`:x?`${Gd(t)} 进程仍活,等下一轮输入`:`${Gd(t)} 进程未运行(发送消息会自动启动)`,children:[h.jsx("span",{className:ne("w-1.5 h-1.5 rounded-full",_?"bg-green-500":"bg-text-400/50")}),h.jsx("span",{children:_?"running":"idle"})]}),x&&a?h.jsxs("button",{type:"button",onClick:a,"data-testid":"chat-header-force-stop",title:t==="codex"?"强制停止 Codex 进程":"强制停止 Claude Code 进程(会丢失 initialize / 预热缓存)",className:"shrink-0 inline-flex items-center gap-1 h-5 px-2 rounded-md text-text-400 hover:bg-red-500/10 hover:text-red-400 transition-colors cursor-pointer",children:[h.jsx(Dz,{className:"w-3 h-3"}),h.jsx("span",{children:"Stop"})]}):null,m&&v||u||l&&l>0&&c?h.jsx("span",{className:"text-text-500 shrink-0","aria-hidden":"true",children:"·"}):null,m&&v?h.jsxs("button",{type:"button",onClick:v,"data-testid":"chat-header-persona",title:m,className:"shrink-0 inline-flex items-center gap-1 h-5 px-2 rounded-md text-text-300 hover:bg-bg-200 hover:text-text-100 transition-colors cursor-pointer",children:[h.jsx(T_,{className:"w-3 h-3"}),h.jsx("span",{className:"truncate max-w-[80px] md:max-w-[120px]",children:m})]}):null,u?h.jsxs("button",{type:"button",onClick:u,"data-testid":"chat-header-files",title:"Edited Files",className:"shrink-0 inline-flex items-center gap-1 h-5 px-2 rounded-md text-text-300 hover:bg-bg-200 hover:text-text-100 transition-colors cursor-pointer",children:[h.jsx(mz,{className:"w-3 h-3"}),h.jsx("span",{className:"hidden md:inline",children:"Edited Files"})]}):null,l&&l>0&&c?h.jsxs("button",{type:"button","data-testid":"chat-header-cron-button",onClick:c,"aria-label":"Cron tasks",title:`${l} active cron task${l===1?"":"s"}`,className:"shrink-0 inline-flex items-center gap-1 h-5 px-2 rounded-md text-text-400 hover:bg-accent-dim hover:text-accent transition-colors cursor-pointer",children:[h.jsx(tz,{className:"w-3 h-3"}),h.jsx("span",{"data-testid":"chat-header-cron-badge",className:"font-mono",children:l})]}):null]}),r?h.jsxs(h.Fragment,{children:[h.jsx("button",{type:"button","aria-label":"Session settings","data-testid":"chat-header-settings",onClick:()=>r("desktop"),title:"Session settings",className:"hidden md:flex absolute right-4 top-3 z-10 h-7 w-7 items-center justify-center rounded-md bg-transparent text-text-300 transition-colors duration-150 hover:bg-bg-200 hover:text-text-100 cursor-pointer outline-none",children:h.jsx(Qv,{className:"w-4 h-4"})}),h.jsx("button",{type:"button","aria-label":"Session settings","data-testid":"chat-header-settings-mobile",onClick:()=>r("mobile"),title:"Session settings",className:"flex md:hidden absolute right-4 top-3 z-10 h-7 w-7 items-center justify-center rounded-md bg-transparent text-text-300 transition-colors duration-150 hover:bg-bg-200 hover:text-text-100 cursor-pointer outline-none",children:h.jsx(Qv,{className:"w-4 h-4"})})]}):null]})}function bQ(e,t){if(!t)return"default";const n=t.toLowerCase(),r=[["opus","Opus"],["sonnet","Sonnet"],["haiku","Haiku"]];for(const[a,l]of r){if(!n.includes(a))continue;const c=n.match(new RegExp(`${a}-(\\d+)-(\\d+)`));return c?`${l} ${c[1]}.${c[2]}`:l}const i=e??[],s=i.find(a=>a.id===t);if(s)return s.label;const o=i.find(a=>a.id&&t.toLowerCase().includes(a.id.toLowerCase()));return o?o.label:t}function wQ(e){return e==="TodoWrite"}function SQ(e){if(!e||typeof e!="object")return null;const t=e;if(!Array.isArray(t.todos))return null;const n=[];for(const r of t.todos){if(!r||typeof r!="object")continue;const i=r,s=typeof i.content=="string"?i.content:"";if(!s)continue;const o=i.status==="in_progress"||i.status==="completed"?i.status:"pending",a=typeof i.activeForm=="string"?i.activeForm:void 0;n.push({content:s,status:o,activeForm:a})}return n}function kQ(e,t,n){var s;const r=[],i=new Map;for(let o=0;o<e.length;o++){const a=e[o],l=typeof a.seq=="number"?a.seq:o;switch(a.kind){case"session_init":r.push({kind:"session-init",seq:l,toolSessionId:a.toolSessionId});break;case"text":Sk(r,l,"assistant-text",a.text,a.partialId,a.uuid);break;case"thinking":Sk(r,l,"assistant-thinking",a.text,a.partialId);break;case"user_text":{a.meta==="task-notification"?r.push({kind:"agent-notification",seq:l,text:a.text,taskId:a.taskId,parentToolUseId:a.parentToolUseId}):a.meta?r.push({kind:"user-meta",seq:l,metaKind:a.meta,text:a.text}):r.push({kind:"user-text",seq:l,text:a.text,uuid:a.uuid,senderDisplayName:(s=a.sender)==null?void 0:s.displayName});break}case"tool_call":IM(r,l,a.toolUseId,a.tool,a.input,a.toolKind);break;case"tool_result":{const c=i.get(a.toolUseId);if(c!==void 0){if(a.askQuestionAnswers){const d=r[c];d.submittedAnswers=a.askQuestionAnswers}i.delete(a.toolUseId);break}const u={kind:"tool-result",seq:l,toolUseId:a.toolUseId,output:a.output,error:a.error};a.toolResultExtra&&(u.toolResultExtra=a.toolResultExtra),r.push(u);break}case"attachment_memories":r.push({kind:"memory-callout",seq:l,memories:a.memories});break;case"permission_request":{if(!t||a.requestId!==t)break;r.push({kind:"permission-inline",seq:l,requestId:a.requestId,tool:a.tool,input:a.input});break}case"ask_user_question":i.set(a.toolUseId,r.length),r.push({kind:"question-card",seq:l,toolUseId:a.toolUseId,questions:a.questions});break;case"turn_end":r.push({kind:"turn-end",seq:l});break;case"subagent_progress":{const c={kind:"agent-progress",seq:l,toolUseId:a.toolUseId,agentId:a.agentId,status:a.status};a.description&&(c.description=a.description),a.lastToolName&&(c.lastToolName=a.lastToolName),a.prompt&&(c.prompt=a.prompt),a.stats&&(c.stats=a.stats),r.push(c);break}case"error":r.push({kind:"error",seq:l,message:a.message});break}}return r}function IM(e,t,n,r,i,s){if(wQ(r)){const o=SQ(i);if(o){e.push({kind:"todo-checklist",seq:t,toolUseId:n,todos:o});return}}if(r==="Agent"){const o=i??{},a=typeof o.description=="string"&&o.description?o.description:typeof o.subagent_type=="string"&&o.subagent_type?o.subagent_type:"Subagent";e.push({kind:"agent-call",seq:t,toolUseId:n,description:a,input:i});return}if(OU(r)){e.push({kind:"task-event",seq:t,toolUseId:n,name:r,input:i});return}e.push({kind:"tool-call",seq:t,toolUseId:n,tool:r,toolKind:s,input:i})}function Sk(e,t,n,r,i,s){let o=-1;for(let c=e.length-1;c>=0;c--)if(e[c].kind===n){o=c;break}const a=o>=0?e[o]:null;if(i){if(a&&a.partialId===i){const u=n==="assistant-text"?{kind:n,seq:a.seq,text:a.text+r,partialId:i,...s?{uuid:s}:{}}:{kind:n,seq:a.seq,text:a.text+r,partialId:i};e[o]=u;return}const c=n==="assistant-text"?{kind:n,seq:t,text:r,partialId:i,...s?{uuid:s}:{}}:{kind:n,seq:t,text:r,partialId:i};e.push(c);return}if(a&&a.partialId){const c=n==="assistant-text"?{kind:n,seq:a.seq,text:r,...s?{uuid:s}:{}}:{kind:n,seq:a.seq,text:r};e[o]=c;return}const l=n==="assistant-text"?{kind:n,seq:t,text:r,...s?{uuid:s}:{}}:{kind:n,seq:t,text:r};e.push(l)}const CQ="AskUserQuestion";function RM(e,t=0,n){var o;const r=[],i=new Map;let s=t;for(const a of e){const l=s++,c=a.toolUseId??`hist-${l}`;switch(a.kind){case"user-text":if(a.meta==="task-notification")r.push({kind:"agent-notification",seq:l,text:a.text??"",taskId:a.taskId,parentToolUseId:a.parentToolUseId});else if(a.meta)r.push({kind:"user-meta",seq:l,metaKind:a.meta,text:a.text??""});else{const u=(o=MB.exec(a.text??""))==null?void 0:o[1];r.push({kind:"user-text",seq:l,text:a.text??"",uuid:a.uuid,...u?{senderDisplayName:u}:{}})}break;case"assistant-text":r.push({kind:"assistant-text",seq:l,text:a.text??"",uuid:a.uuid});break;case"tool_call":{if(a.tool===CQ){const u=a.input??{},d=Array.isArray(u.questions)?u.questions:[];i.set(c,r.length),r.push({kind:"question-card",seq:l,toolUseId:c,questions:d});break}IM(r,l,c,a.tool??"",a.input,n);break}case"tool_result":{const u=i.get(c);if(u!==void 0){if(a.askQuestionAnswers){const f=r[u];f.submittedAnswers=a.askQuestionAnswers}i.delete(c);break}const d={kind:"tool-result",seq:l,toolUseId:c,output:a.output};a.error!==void 0&&(d.error=a.error),a.toolResultExtra&&(d.toolResultExtra=a.toolResultExtra),r.push(d);break}case"attachment_memories":a.memories&&a.memories.length>0&&r.push({kind:"memory-callout",seq:l,memories:a.memories});break}}return r}function EQ({api:e,cwd:t,toolSessionId:n}){const r=kM(),i=(r==null?void 0:r.state.agentId)??null,s=r==null?void 0:r.state.agentType,[o,a]=g.useState([]),[l,c]=g.useState(!1),[u,d]=g.useState(null);g.useEffect(()=>{if(!i)return;let p=!1;return c(!0),d(null),a([]),e.historySubagentRead({cwd:t,toolSessionId:n,subagentId:i}).then(m=>{p||a(m.messages??[])}).catch(m=>{p||d(m instanceof Error?m.message:String(m))}).finally(()=>{p||c(!1)}),()=>{p=!0}},[i,t,n,e]);const f=g.useMemo(()=>o.length>0?RM(o,0,"claude"):[],[o]);return!r||!i?null:h.jsxs("div",{"data-testid":"subagent-drawer","data-agent-id":i,className:ne("fixed inset-y-0 right-0 z-50 w-[min(560px,92vw)]","flex flex-col border-l border-bg-200/60 bg-bg-50 shadow-xl"),style:{paddingTop:"env(safe-area-inset-top)"},children:[h.jsxs("div",{className:"flex flex-col gap-0.5 px-3 py-2 border-b border-bg-200/60",children:[h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s?h.jsx("span",{className:"inline-flex items-center rounded-sm bg-violet-500/10 px-1.5 py-0.5 text-[11px] text-violet-400 font-medium",children:s}):null,h.jsx("span",{className:"font-mono text-[11px] text-text-400 truncate",title:i,children:i})]}),h.jsx("button",{type:"button","aria-label":"关闭",onClick:()=>r.close(),className:"p-1 rounded hover:bg-bg-200/50 text-text-400 hover:text-text-200",children:h.jsx(Rn,{className:"w-4 h-4"})})]}),!l&&!u&&o.length>0?h.jsxs("div",{className:"text-[11px] text-text-400",children:[o.length," 条消息 · 首条为主会话派发的任务指令"]}):null]}),h.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto overflow-x-hidden px-3 py-2",children:l?h.jsxs("div",{className:"flex items-center gap-2 text-[12px] text-text-400",children:[h.jsx(rr,{className:"w-3.5 h-3.5 animate-spin"}),h.jsx("span",{children:"加载中…"})]}):u?h.jsxs("div",{className:"flex items-center gap-2 text-[12px] text-error",children:[h.jsx(Ls,{className:"w-3.5 h-3.5"}),h.jsx("span",{children:u})]}):f.length===0?h.jsx("div",{className:"text-[12px] text-text-400 italic",children:"无消息"}):h.jsx(EM,{lines:f})})]})}function kk(e,t){let n=0;for(const r of e.lines)r.startsWith(t)&&n++;return n}function NQ(e,t){const n=e.findIndex(c=>c.kind==="user-text"&&c.uuid===t);if(n<0)return{userMessageId:t,files:[],totalInsertions:0,totalDeletions:0,anchorFound:!1};let r=e.length;for(let c=n+1;c<e.length;c++)if(e[c].kind==="user-text"){r=c;break}const i=[],s=new Map;for(let c=n+1;c<r;c++){const u=e[c];if(u.kind!=="tool-result")continue;const d=u.toolResultExtra;if(!(d!=null&&d.filePath)||!d.structuredPatch||d.structuredPatch.length===0)continue;const f=d.filePath;let p=s.get(f);p||(p={filePath:f,hunks:[],insertions:0,deletions:0},s.set(f,p),i.push(f));for(const m of d.structuredPatch)p.hunks.push(m),p.insertions+=kk(m,"+"),p.deletions+=kk(m,"-")}const o=i.map(c=>s.get(c)),a=o.reduce((c,u)=>c+u.insertions,0),l=o.reduce((c,u)=>c+u.deletions,0);return{userMessageId:t,files:o,totalInsertions:a,totalDeletions:l,anchorFound:!0}}function TQ({open:e,onOpenChange:t,api:n,sessionId:r,userMessageId:i,lines:s,procAlive:o,onApplied:a,onNoChanges:l}){const c=g.useMemo(()=>NQ(s,i),[s,i]),[u,d]=g.useState(null),[f,p]=g.useState(!1),[m,v]=g.useState(!1),[b,x]=g.useState(null);g.useEffect(()=>{if(!e)return;let C=!1;return p(!0),d(null),(async()=>{try{const N=await n.sessionRewindDiff({sessionId:r,userMessageId:i});C||(d(N),!N.canRewind&&!N.error&&N.files.length===0&&(l==null||l(i)))}catch{C||d(null)}finally{C||p(!1)}})(),()=>{C=!0}},[e,n,r,i]);const _=g.useMemo(()=>{if(u){const C=!u.canRewind&&!u.error&&u.files.length===0;if(u.canRewind||C)return{source:"rpc",anchorFound:!0,files:u.files.map(N=>({filePath:N.filePath,hunks:N.hunks,insertions:N.insertions,deletions:N.deletions})),totalInsertions:u.totalInsertions,totalDeletions:u.totalDeletions}}return{source:"local",anchorFound:c.anchorFound,files:c.files,totalInsertions:c.totalInsertions,totalDeletions:c.totalDeletions,rpcError:u==null?void 0:u.error}},[u,c]),y=g.useCallback(async()=>{v(!0),x(null);try{const C=await n.sessionRewind({sessionId:r,userMessageId:i,dryRun:!1});if(!C.canRewind){x(C.error??"回退失败");return}a==null||a(),t(!1)}catch(C){x(C.message||"回退失败")}finally{v(!1)}},[n,r,i,a,t]);if(!e)return null;const w=_.files.length>0,S=!f&&!m&&_.anchorFound&&w&&!b;return h.jsxs("div",{"data-testid":"rewind-preview-drawer",className:"fixed right-0 top-0 bottom-0 z-40 flex flex-col border-l border-bg-300/40 bg-bg-0 shadow-xl",style:{width:480,minWidth:480},children:[h.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-bg-300/30 shrink-0",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(MT,{className:"w-4 h-4 text-text-300"}),h.jsx("span",{className:"text-[14px] font-semibold text-text-100",children:"Rewind 预览"})]}),h.jsx("button",{type:"button",onClick:()=>t(!1),"data-testid":"rewind-drawer-close",className:"flex items-center justify-center w-7 h-7 rounded-md text-text-400 hover:bg-text-100/5 hover:text-text-200 cursor-pointer","aria-label":"close",children:h.jsx(Rn,{className:"w-4 h-4"})})]}),b?h.jsxs("div",{"data-testid":"rewind-error-banner",className:"mx-4 mt-3 flex items-start gap-2 rounded-md border border-red-400/40 bg-red-500/10 px-3 py-2 text-[12px] text-red-400",children:[h.jsx(Uc,{className:"w-4 h-4 shrink-0 mt-0.5"}),h.jsx("span",{children:b})]}):null,h.jsx("div",{className:"flex-1 overflow-y-auto px-4 py-3 space-y-3",children:f?h.jsxs("div",{"data-testid":"rewind-loading",className:"flex items-center gap-2 text-[12px] text-text-400",children:[h.jsx(rr,{className:"w-3.5 h-3.5 animate-spin"}),h.jsx("span",{children:"正在读取快照…"})]}):_.anchorFound?w?h.jsxs(h.Fragment,{children:[h.jsxs("div",{"data-testid":"rewind-summary",className:"rounded-md border border-bg-300 bg-bg-100/40 px-3 py-2 text-[12px] text-text-200",children:[h.jsxs("div",{children:["将回退 ",h.jsx("span",{className:"font-semibold text-text-100",children:_.files.length})," ","个文件,",h.jsxs("span",{className:"text-green-500 font-mono",children:["+",_.totalInsertions]})," / ",h.jsxs("span",{className:"text-red-400 font-mono",children:["-",_.totalDeletions]})]}),_.source==="local"?h.jsx("div",{"data-testid":"rewind-source-hint",className:"mt-1 text-text-400 text-[11px]",children:"基于对话里 tool_result 估算(未读到 CC 快照,数字可能与实际磁盘略有差异)"}):null]}),_.files.map(C=>h.jsx(IQ,{file:C},C.filePath))]}):h.jsxs("div",{"data-testid":"rewind-no-changes",className:"rounded-md border border-bg-300 bg-bg-100/60 px-3 py-2 text-[12px] text-text-300 space-y-1",children:[h.jsx("div",{children:"磁盘上的文件已经和这个时刻的快照完全一致——没有需要回退的改动。"}),h.jsx("div",{className:"text-text-400 text-[11px]",children:"可能这条消息之后 Claude 没落盘编辑,或之前已经 rewind 过了。"})]}):h.jsx("div",{"data-testid":"rewind-no-anchor",className:"rounded-md border border-bg-300 bg-bg-100/60 px-3 py-2 text-[12px] text-text-300",children:"未能在当前消息流中找到对应的用户消息(可能已被历史裁剪)。"})}),h.jsxs("div",{className:"flex flex-col gap-2 px-4 py-3 border-t border-bg-300/30 shrink-0",children:[w&&_.anchorFound&&!o?h.jsxs("div",{"data-testid":"rewind-needs-cc",className:"flex items-start gap-2 rounded-md border border-bg-300 bg-bg-100/60 px-3 py-2 text-[12px] text-text-300",children:[h.jsx(Uc,{className:"w-4 h-4 shrink-0 mt-0.5 text-warning"}),h.jsx("span",{children:'Claude Code 进程当前未运行。点击"确认回退"时会自动启动它再执行 — 可能需要等一两秒。'})]}):null,h.jsxs("div",{className:"flex items-center justify-end gap-2",children:[h.jsx("button",{type:"button",onClick:()=>t(!1),className:"h-8 px-3 rounded-md text-[12px] text-text-300 hover:bg-text-100/5 cursor-pointer",children:"取消"}),h.jsx("button",{type:"button",disabled:!S,onClick:()=>void y(),"data-testid":"rewind-apply",className:ne("h-8 px-3 rounded-md text-[12px] font-medium transition-colors",S?"bg-accent text-white hover:bg-accent-hover cursor-pointer":"bg-bg-200 text-text-400 cursor-not-allowed"),children:m?"回退中…":"确认回退"})]})]})]})}function PQ(e){return e.replace(/^\/Users\/[^/]+/,"~")}function IQ({file:e}){const[t,n]=g.useState(!0);return h.jsxs("div",{"data-testid":"rewind-file-block","data-file":e.filePath,className:"rounded-md border border-bg-300 overflow-hidden bg-bg-0",children:[h.jsxs("button",{type:"button",onClick:()=>n(r=>!r),className:"w-full flex items-center gap-1.5 px-3 py-2 text-[12px] hover:bg-text-100/5 cursor-pointer",children:[t?h.jsx(ci,{className:"w-3.5 h-3.5 text-text-400 shrink-0"}):h.jsx(ui,{className:"w-3.5 h-3.5 text-text-400 shrink-0"}),h.jsx("span",{className:"font-mono text-text-200 truncate flex-1 text-left",title:e.filePath,children:PQ(e.filePath)}),h.jsxs("span",{className:"font-mono shrink-0 text-text-400",children:[h.jsxs("span",{className:"text-green-500",children:["+",e.insertions]})," ",h.jsxs("span",{className:"text-red-400",children:["-",e.deletions]})]})]}),t?h.jsx("div",{className:"border-t border-bg-300",children:e.hunks.map(r=>h.jsx(RQ,{hunk:r},`${r.oldStart}-${r.oldLines}-${r.newStart}-${r.newLines}`))}):null]})}function RQ({hunk:e}){const t=`@@ -${e.oldStart},${e.oldLines} +${e.newStart},${e.newLines} @@`;return h.jsxs("div",{className:"text-[11px] font-mono leading-relaxed",children:[h.jsx("div",{className:"px-3 py-1 text-text-400 bg-bg-100/40 border-b border-bg-300",children:t}),e.lines.map((n,r)=>{const i=n.charAt(0),s=i==="+"?"bg-green-500/10 text-green-300":i==="-"?"bg-red-500/10 text-red-300":"text-text-300";return h.jsx("div",{className:ne("px-3 whitespace-pre",s),children:n.length>0?n:" "},r)})]})}var yp="Dialog",[MM]=Ro(yp),[MQ,Br]=MM(yp),AM=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:s,modal:o=!0}=e,a=g.useRef(null),l=g.useRef(null),[c,u]=Qf({prop:r,defaultProp:i??!1,onChange:s,caller:yp});return h.jsx(MQ,{scope:t,triggerRef:a,contentRef:l,contentId:oo(),titleId:oo(),descriptionId:oo(),open:c,onOpenChange:u,onOpenToggle:g.useCallback(()=>u(d=>!d),[u]),modal:o,children:n})};AM.displayName=yp;var jM="DialogTrigger",AQ=g.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=Br(jM,n),s=qt(t,i.triggerRef);return h.jsx(Et.button,{type:"button","aria-haspopup":"dialog","aria-expanded":i.open,"aria-controls":i.contentId,"data-state":Ay(i.open),...r,ref:s,onClick:Pe(e.onClick,i.onOpenToggle)})});AQ.displayName=jM;var Ry="DialogPortal",[jQ,LM]=MM(Ry,{forceMount:void 0}),DM=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:i}=e,s=Br(Ry,t);return h.jsx(jQ,{scope:t,forceMount:n,children:g.Children.map(r,o=>h.jsx(Hi,{present:n||s.open,children:h.jsx(F_,{asChild:!0,container:i,children:o})}))})};DM.displayName=Ry;var af="DialogOverlay",OM=g.forwardRef((e,t)=>{const n=LM(af,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,s=Br(af,e.__scopeDialog);return s.modal?h.jsx(Hi,{present:r||s.open,children:h.jsx(DQ,{...i,ref:t})}):null});OM.displayName=af;var LQ=Wc("DialogOverlay.RemoveScroll"),DQ=g.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=Br(af,n);return h.jsx(H_,{as:LQ,allowPinchZoom:!0,shards:[i.contentRef],children:h.jsx(Et.div,{"data-state":Ay(i.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),So="DialogContent",BM=g.forwardRef((e,t)=>{const n=LM(So,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,s=Br(So,e.__scopeDialog);return h.jsx(Hi,{present:r||s.open,children:s.modal?h.jsx(OQ,{...i,ref:t}):h.jsx(BQ,{...i,ref:t})})});BM.displayName=So;var OQ=g.forwardRef((e,t)=>{const n=Br(So,e.__scopeDialog),r=g.useRef(null),i=qt(t,n.contentRef,r);return g.useEffect(()=>{const s=r.current;if(s)return OP(s)},[]),h.jsx(zM,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Pe(e.onCloseAutoFocus,s=>{var o;s.preventDefault(),(o=n.triggerRef.current)==null||o.focus()}),onPointerDownOutside:Pe(e.onPointerDownOutside,s=>{const o=s.detail.originalEvent,a=o.button===0&&o.ctrlKey===!0;(o.button===2||a)&&s.preventDefault()}),onFocusOutside:Pe(e.onFocusOutside,s=>s.preventDefault())})}),BQ=g.forwardRef((e,t)=>{const n=Br(So,e.__scopeDialog),r=g.useRef(!1),i=g.useRef(!1);return h.jsx(zM,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{var o,a;(o=e.onCloseAutoFocus)==null||o.call(e,s),s.defaultPrevented||(r.current||(a=n.triggerRef.current)==null||a.focus(),s.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:s=>{var l,c;(l=e.onInteractOutside)==null||l.call(e,s),s.defaultPrevented||(r.current=!0,s.detail.originalEvent.type==="pointerdown"&&(i.current=!0));const o=s.target;((c=n.triggerRef.current)==null?void 0:c.contains(o))&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&i.current&&s.preventDefault()}})}),zM=g.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:s,...o}=e,a=Br(So,n),l=g.useRef(null),c=qt(t,l);return rP(),h.jsxs(h.Fragment,{children:[h.jsx(M_,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:s,children:h.jsx(Jf,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":Ay(a.open),...o,ref:c,onDismiss:()=>a.onOpenChange(!1)})}),h.jsxs(h.Fragment,{children:[h.jsx(zQ,{titleId:a.titleId}),h.jsx(FQ,{contentRef:l,descriptionId:a.descriptionId})]})]})}),My="DialogTitle",$M=g.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=Br(My,n);return h.jsx(Et.h2,{id:i.titleId,...r,ref:t})});$M.displayName=My;var FM="DialogDescription",HM=g.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=Br(FM,n);return h.jsx(Et.p,{id:i.descriptionId,...r,ref:t})});HM.displayName=FM;var UM="DialogClose",WM=g.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=Br(UM,n);return h.jsx(Et.button,{type:"button",...r,ref:t,onClick:Pe(e.onClick,()=>i.onOpenChange(!1))})});WM.displayName=UM;function Ay(e){return e?"open":"closed"}var VM="DialogTitleWarning",[Uie,qM]=uF(VM,{contentName:So,titleName:My,docsSlug:"dialog"}),zQ=({titleId:e})=>{const t=qM(VM),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
|
|
526
|
+
`):null}if(typeof e=="object"){const t=e;if(typeof t.text=="string")return t.text}return null}function mk(e){if(!e||!Number.isFinite(e))return null;if(e<1e3)return`${e}ms`;const t=e/1e3;if(t<60)return`${t.toFixed(1)}s`;const n=Math.floor(t/60),r=Math.round(t-n*60);return`${n}m${r.toString().padStart(2,"0")}s`}function RZ(e){return!e||!Number.isFinite(e)?null:e<1e3?`${e} tok`:e<1e4?`${(e/1e3).toFixed(1)}k tok`:`${Math.round(e/1e3)}k tok`}const MZ={readCount:"read",searchCount:"search",bashCount:"bash",editFileCount:"edit",linesAdded:"+lines",linesRemoved:"-lines",otherToolCount:"other"};function AZ(e){if(!e)return[];const t=[];for(const[n,r]of Object.entries(e)){if(!r||r<=0)continue;const i=MZ[n]??n;t.push(`${i}:${r}`)}return t}function jZ({description:e,input:t,output:n,error:r,pending:i,notifications:s,toolResultExtra:o,progress:a}){const[l,c]=g.useState(!1),u=kM(),d=g.useMemo(()=>{if(!t||typeof t!="object")return null;const T=t;return typeof T.prompt=="string"?T.prompt:null},[t]),f=(o==null?void 0:o.prompt)??d,p=g.useMemo(()=>IZ(n),[n]),m=o==null?void 0:o.stats,v=a==null?void 0:a.stats,b=mk((m==null?void 0:m.durationMs)??(v==null?void 0:v.durationMs)),x=RZ((m==null?void 0:m.tokens)??(v==null?void 0:v.tokens)),_=AZ(m==null?void 0:m.toolStats),y=i&&(a!=null&&a.lastToolName)?`now:${a.lastToolName}`:null,w=!!(o!=null&&o.agentType||b||x||_.length>0||y),S=(o==null?void 0:o.agentId)??(a==null?void 0:a.agentId),C=g.useMemo(()=>s.map(T=>({taskId:T.taskId,text:T.text,parsed:wM(T.text)})),[s]),N=r?h.jsx(Ls,{className:"w-3.5 h-3.5 text-error"}):i?h.jsx(rr,{className:"w-3.5 h-3.5 text-blue-400 animate-spin"}):h.jsx(Zf,{className:"w-3.5 h-3.5 text-green-500"});return h.jsxs("div",{"data-testid":"msg-line-agent-call","data-pending":i?"true":"false","data-has-error":r?"true":"false","data-notification-count":s.length,"data-has-stats":w?"true":"false","data-agent-id":S??"",className:"my-1 min-w-0 max-w-full rounded-md border border-bg-200/60 bg-bg-100/30",children:[h.jsxs("button",{type:"button","aria-expanded":l,onClick:()=>c(T=>!T),className:ne("flex w-full min-w-0 items-center gap-2 px-2.5 py-1.5 text-left text-[13px]","hover:bg-bg-200/40 rounded-md transition-colors"),children:[h.jsx("span",{className:"w-5 h-5 flex items-center justify-center text-[10px] rounded bg-violet-500/10 text-violet-500 shrink-0","aria-hidden":!0,children:h.jsx(x$,{className:"w-3 h-3"})}),h.jsx("span",{className:"shrink-0",children:N}),h.jsx("span",{className:"flex-1 min-w-0 truncate font-medium text-text-200",children:e}),w?null:s.length>0?h.jsxs("span",{className:"text-[11px] text-text-400 tabular-nums shrink-0",children:[s.length," 次通知"]}):null,S&&(u!=null&&u.open)?h.jsx("span",{role:"button",tabIndex:0,"data-testid":"open-subagent-btn-header","data-agent-id":S,"aria-label":"打开子 agent 对话",onClick:T=>{T.stopPropagation(),u.open(S,o==null?void 0:o.agentType)},onKeyDown:T=>{(T.key==="Enter"||T.key===" ")&&(T.stopPropagation(),T.preventDefault(),u.open(S,o==null?void 0:o.agentType))},className:"shrink-0 inline-flex items-center justify-center w-3.5 h-3.5 text-text-400 hover:text-text-200",children:h.jsx(Hc,{className:"w-3.5 h-3.5"})}):null,l?h.jsx(ci,{className:"w-3.5 h-3.5 text-text-400 shrink-0"}):h.jsx(ui,{className:"w-3.5 h-3.5 text-text-400 shrink-0"})]}),i&&(a!=null&&a.description)?h.jsx("div",{"data-testid":"agent-call-progress-desc",className:"px-3 pt-0 pb-1 text-[12px] text-text-300 truncate",children:a.description}):null,w?h.jsxs("div",{"data-testid":"agent-call-stats",className:"flex items-center gap-1.5 flex-wrap px-3 pb-1.5 pt-0 text-[11px] text-text-400",children:[o!=null&&o.agentType?h.jsx("span",{"data-testid":"agent-call-stats-type",className:"inline-flex items-center rounded-sm bg-violet-500/10 px-1.5 py-0.5 text-violet-400 font-medium",children:o.agentType}):null,b?h.jsx("span",{className:"tabular-nums",children:b}):null,x?h.jsx("span",{className:"tabular-nums",children:x}):null,y?h.jsx("span",{"data-testid":"agent-call-stats-now",className:"font-mono tabular-nums text-blue-400",children:y}):null,_.map(T=>h.jsx("span",{className:"font-mono tabular-nums text-text-400/80",children:T},T)),s.length>0?h.jsxs("span",{className:"tabular-nums text-text-400/70",children:["· ",s.length," 次通知"]}):null]}):null,l?h.jsxs("div",{"data-testid":"agent-call-body",className:"min-w-0 border-t border-bg-200/60 px-3 py-2 space-y-3",children:[r?h.jsx("div",{className:"text-[12px] text-error whitespace-pre-wrap",children:r}):null,C.map((T,M)=>{const P=T.parsed,D=mk(P.durationMs);return h.jsxs("div",{"data-testid":"agent-call-notification","data-task-id":T.taskId??"",className:"min-w-0 rounded-md border border-bg-200/60 bg-bg-0/40 p-2 space-y-1.5",children:[h.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-text-400 flex-wrap",children:[h.jsx("span",{className:"font-mono",children:(T.taskId??P.taskId??"未知").slice(0,12)}),h.jsx("span",{className:"uppercase tracking-wide",children:P.status??"unknown"}),D?h.jsxs("span",{className:"tabular-nums",children:["· ",D]}):null,P.totalTokens?h.jsxs("span",{className:"tabular-nums",children:["· ",P.totalTokens," tok"]}):null,P.toolUses?h.jsxs("span",{className:"tabular-nums",children:["· ",P.toolUses," tools"]}):null,P.worktreeBranch?h.jsxs("span",{className:"font-mono",children:["· ",P.worktreeBranch]}):null]}),P.summary?h.jsx("div",{className:"text-[12px] text-text-300",children:P.summary}):null,P.result?h.jsx("div",{"data-testid":"agent-call-notification-result",className:"assistant-markdown text-[12px] leading-relaxed break-words",children:h.jsx(Qc,{remarkPlugins:[eu],components:tu,children:P.result})}):null]},`${T.taskId??"n"}-${M}`)}),f?h.jsxs("div",{"data-testid":"agent-call-prompt-block",className:"min-w-0 space-y-1",children:[h.jsx("div",{className:"text-[11px] text-text-400 font-medium",children:"任务指令"}),h.jsx("pre",{"data-testid":"agent-call-prompt",className:"max-w-full whitespace-pre-wrap break-words text-[11px] text-text-300 bg-bg-50/60 rounded p-2 border border-bg-200/60 max-h-64 overflow-auto [overflow-wrap:anywhere]",children:f})]}):null,p?h.jsxs("div",{"data-testid":"agent-call-result-block",className:"min-w-0 space-y-1",children:[h.jsx("div",{className:"text-[11px] text-text-400 font-medium",children:"子 agent 报告"}),h.jsx("div",{"data-testid":"agent-call-result",className:"assistant-markdown text-[12px] leading-relaxed break-words",children:h.jsx(Qc,{remarkPlugins:[eu],components:tu,children:p})})]}):null,!p&&C.length===0&&!r&&!f?h.jsx("div",{className:"text-[11px] text-text-400 italic",children:"无详细信息"}):null,S&&(u!=null&&u.open)?h.jsx("div",{className:"flex justify-end",children:h.jsxs("button",{type:"button","data-testid":"open-subagent-btn","data-agent-id":S,onClick:()=>u.open(S,o==null?void 0:o.agentType),className:ne("inline-flex items-center gap-1 rounded-md border border-bg-200/60","bg-bg-100/40 hover:bg-bg-200/40 transition-colors","px-2 py-1 text-[11px] text-text-300"),children:[h.jsx(Hc,{className:"w-3 h-3"}),h.jsx("span",{children:"打开子 agent 对话"})]})}):null]}):null]})}function CM({title:e,items:t,live:n,progressColor:r="bg-green-500",listKind:i,children:s}){const[o,a]=g.useState(!!n),l=t.length,c=t.filter(d=>d.status==="completed").length,u=l>0?Math.round(c/l*100):0;return h.jsxs("div",{"data-testid":"msg-line-checklist","data-list-kind":i,className:"min-w-0 max-w-full py-1",children:[h.jsxs("button",{type:"button",onClick:()=>a(d=>!d),"aria-expanded":o,className:"flex items-center gap-2.5 w-full text-left rounded-md px-1.5 py-1 hover:bg-text-100/5 cursor-pointer",children:[o?h.jsx(ci,{className:"w-3.5 h-3.5 text-text-400 shrink-0"}):h.jsx(ui,{className:"w-3.5 h-3.5 text-text-400 shrink-0"}),h.jsx("span",{className:"text-[13px] font-medium text-text-200",children:e}),h.jsxs("span",{className:"text-[11px] text-text-400 tabular-nums",children:[c,"/",l]}),h.jsx("div",{className:"flex-1 max-w-[120px] h-1.5 rounded-full bg-text-100/10 overflow-hidden",children:h.jsx("div",{className:ne("h-full rounded-full transition-all duration-300",r),style:{width:`${u}%`}})})]}),o?h.jsxs("div",{"data-testid":"checklist-body",className:"ml-6 mt-0.5",children:[h.jsx("div",{className:"space-y-px",children:t.map((d,f)=>h.jsxs("div",{className:"flex min-w-0 items-start gap-2 py-0.5 px-1",children:[h.jsx("span",{className:"w-4 h-4 mt-0.5 flex items-center justify-center shrink-0",children:d.status==="completed"?h.jsx(ol,{className:"w-3.5 h-3.5 text-green-500"}):d.status==="in_progress"&&n?h.jsx(rr,{className:"w-3.5 h-3.5 text-blue-400 animate-spin"}):h.jsx("span",{className:"w-2 h-2 rounded-full border border-text-400/40"})}),h.jsx("span",{className:ne("min-w-0 text-[13px] leading-snug break-words [overflow-wrap:anywhere]",d.status==="completed"?"text-text-400 line-through":"text-text-200"),children:d.status==="in_progress"&&d.activeForm?d.activeForm:d.content})]},`${f}-${d.content}`))}),s]}):null]})}function LZ({todos:e,live:t}){return h.jsx(CM,{title:"Tasks",items:e,live:t,progressColor:"bg-green-500",listKind:"todo"})}function DZ({tasks:e,live:t}){return h.jsx(CM,{title:"Plan",items:e,live:t,progressColor:"bg-blue-500",listKind:"plan"})}function OZ(e){if(!e||!Number.isFinite(e))return null;const t=Date.now()-e;if(t<0)return null;const n=Math.floor(t/1e3);if(n<60)return`${n}s ago`;const r=Math.floor(n/60);if(r<60)return`${r}m ago`;const i=Math.floor(r/60);if(i<24)return`${i}h ago`;const s=Math.floor(i/24);if(s<7)return`${s}d ago`;const o=Math.floor(s/7);return o<5?`${o}w ago`:new Date(e).toISOString().slice(0,10)}function BZ(e){return(e.split("/").pop()??e)||e}function zZ({memories:e}){return!e||e.length===0?null:h.jsxs("div",{"data-testid":"memory-callout",className:"my-1 min-w-0 max-w-full rounded-md border border-bg-200/60 bg-bg-100/30",children:[h.jsxs("div",{className:"flex items-center gap-1.5 px-2.5 py-1.5 text-[12px] text-text-300 border-b border-bg-200/60",children:[h.jsx(B6,{className:"w-3.5 h-3.5 text-amber-500 shrink-0"}),h.jsx("span",{className:"font-medium",children:"项目记忆"}),h.jsxs("span",{className:"text-text-400 tabular-nums",children:["· ",e.length]})]}),h.jsx("ul",{className:"divide-y divide-bg-200/40",children:e.map(t=>h.jsx($Z,{memory:t},t.path))})]})}function $Z({memory:e}){const[t,n]=g.useState(!1),r=OZ(e.mtimeMs),i=e.content.replace(/\s+/g," ").trim().slice(0,80);return h.jsxs("li",{className:"px-2.5 py-1.5",children:[h.jsxs("button",{type:"button","aria-expanded":t,onClick:()=>n(s=>!s),className:ne("flex w-full items-center gap-1.5 text-left text-[12px]","hover:bg-bg-200/30 rounded-sm py-0.5"),children:[t?h.jsx(ci,{className:"w-3 h-3 text-text-400 shrink-0"}):h.jsx(ui,{className:"w-3 h-3 text-text-400 shrink-0"}),h.jsx("span",{className:"font-mono text-text-300 shrink-0 max-w-[20ch] truncate",title:e.path,children:BZ(e.path)}),h.jsx("span",{className:"flex-1 min-w-0 truncate text-text-400/80",children:i}),r?h.jsx("span",{className:"shrink-0 text-[11px] text-text-400 tabular-nums",children:r}):null]}),t?h.jsx("pre",{"data-testid":"memory-callout-body",className:"mt-1 max-w-full whitespace-pre-wrap break-words text-[12px] text-text-300 bg-bg-50/60 rounded-md p-2 border border-bg-200/60 [overflow-wrap:anywhere]",children:e.content}):null]})}function FZ({toolUseId:e,questions:t,onSubmit:n,onCancel:r,submittedAnswers:i}){const[s,o]=g.useState({}),[a,l]=g.useState({}),[c,u]=g.useState({}),[d,f]=g.useState(!1),[p,m]=g.useState(!1),v=i!==void 0&&Object.keys(i).length>0,b=v||p,x=!n&&!v,_=(S,C)=>{const N={labels:new Set,freeText:""};if(!v||!i)return N;const T=i[S];if(typeof T!="string")return N;const M=T.split(",").map(I=>I.trim()).filter(Boolean),P=new Set(C.map(I=>I.label)),D=new Set,R=[];for(const I of M)P.has(I)?D.add(I):R.push(I);return{labels:D,freeText:R.join(", ")}},y=g.useMemo(()=>t.every(S=>{if((c[S.question]??"").trim().length>0)return!0;if(S.multiSelect){const N=a[S.question];return!!(N&&N.size>0)}return typeof s[S.question]=="string"&&s[S.question].length>0}),[t,s,a,c]),w=async()=>{if(!y||d||b||x||!n)return;const S={};for(const C of t){const N=(c[C.question]??"").trim();if(C.multiSelect){const T=a[C.question],M=T?C.options.filter(P=>T.has(P.label)).map(P=>P.label):[];if(N.length>0&&M.push(N),M.length===0)continue;S[C.question]=M.join(", ")}else if(N.length>0)S[C.question]=N;else{const T=s[C.question];typeof T=="string"&&(S[C.question]=T)}}f(!0);try{await n(S),m(!0)}finally{f(!1)}};return h.jsxs("div",{"data-testid":"msg-line-question","data-tool-use-id":e,className:"min-w-0 max-w-full rounded-md border border-accent/40 bg-accent/5 px-3 py-2.5 text-[13px]",children:[h.jsxs("div",{className:"flex min-w-0 items-center gap-2 mb-2",children:[h.jsx(Q6,{className:"w-4 h-4 text-accent shrink-0"}),h.jsx("span",{className:"min-w-0 font-medium text-text-100",children:"需要你的回答 / Need your answer"}),t.length>1?h.jsxs("span",{className:"ml-auto text-[12px] text-text-400","data-testid":"msg-line-question-count",children:[t.length," 个问题"]}):null]}),h.jsx("div",{className:"flex flex-col gap-3 mb-3",children:t.map((S,C)=>{const N=`q-${C}`,T=`${e}-${C}`,M=_(S.question,S.options),P=b||x,D=c[S.question]??"",R=v?M.freeText:p?(c[S.question]??"").trim():"";return h.jsxs("div",{"data-testid":"msg-line-question-item",children:[S.question?h.jsx("div",{className:"text-text-200 mb-1.5",children:S.question}):null,h.jsx("div",{className:"flex flex-col gap-1",children:S.options.map((I,O)=>{var F;const z=`${N}-${O}`,$=v?M.labels.has(I.label):S.multiSelect?!!((F=a[S.question])!=null&&F.has(I.label)):s[S.question]===I.label;return h.jsxs("label",{className:"flex min-w-0 items-start gap-2 cursor-pointer select-none py-1 px-2 rounded hover:bg-bg-100",children:[h.jsx("input",{type:S.multiSelect?"checkbox":"radio",name:T,value:I.label,checked:$,disabled:b||x,onChange:()=>{b||x||(S.multiSelect?l(L=>{const B=new Set(L[S.question]??[]);return B.has(I.label)?B.delete(I.label):B.add(I.label),{...L,[S.question]:B}}):o(L=>({...L,[S.question]:I.label})))},className:"mt-0.5","data-testid":"msg-line-question-option"}),h.jsxs("span",{className:"flex min-w-0 flex-col",children:[h.jsx("span",{className:"text-text-100 [overflow-wrap:anywhere]",children:I.label}),I.description?h.jsx("span",{className:"text-[12px] text-text-400 [overflow-wrap:anywhere]",children:I.description}):null]})]},z)})}),P?R.length>0?h.jsx("div",{className:"mt-2 rounded-lg border border-accent/15 bg-bg-100/60 px-3 py-2 text-[13px] leading-relaxed text-text-200 [overflow-wrap:anywhere]","data-testid":"msg-line-question-freetext-result",children:R}):null:h.jsx("textarea",{rows:3,value:D,placeholder:"或自行输入回答...",onChange:I=>{const O=I.target.value;u(z=>({...z,[S.question]:O}))},className:"mt-2 w-full resize-y rounded-lg border border-accent/20 bg-bg-000/60 px-3 py-2 text-[13px] leading-relaxed text-text-100 placeholder:text-text-400 outline-none transition-colors focus:border-accent/60 focus:bg-bg-000","data-testid":"msg-line-question-freetext"})]},N)})}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(ri,{size:"sm",variant:"default",onClick:()=>void w(),disabled:!y||d||b||x,"data-testid":"msg-line-question-submit",children:b?"已提交 / Submitted":x?"已结束 / Ended":"提交 / Submit"}),r&&!b&&!x?h.jsx(ri,{size:"sm",variant:"ghost",onClick:()=>void r(),disabled:d,"data-testid":"msg-line-question-cancel",children:"跳过 / Skip"}):null]})]})}function HZ({toolUseId:e,questions:t,historicalAnswers:n,realtimeAnswers:r,onSubmit:i,onCancel:s}){const o=r??n,a=g.useCallback(async c=>{i&&await i(e,c)},[i,e]),l=g.useCallback(async()=>{s&&await s(e)},[s,e]);return h.jsx(FZ,{toolUseId:e,questions:t,onSubmit:i?a:void 0,...s?{onCancel:l}:{},submittedAnswers:o})}function UZ(){const e=new Map,t=(n,r)=>`${n}::${r}`;return{register(n,r,i){e.set(t(n,r),i)},resolve(n,r){return n?e.get(t(n,r))??null:null},reset(){e.clear()}}}const ku=UZ();function EM({lines:e,onPermissionRespond:t,onPermissionInterrupt:n,topSlot:r,onRewind:i,rewindableUserMessageIds:s,onFork:o,onQuickAsk:a,realtimeQuestionAnswers:l,onSubmitQuestion:c,onCancelQuestion:u,liveQuestionToolUseIds:d,fileSharingScope:f,onShareFile:p,onOpenInTab:m,onPreviewMarkdown:v}){const b=g.useMemo(()=>FU(e),[e]);return h.jsxs("div",{"data-testid":"message-list",className:"flex w-full min-w-0 max-w-full flex-col gap-2 px-4 py-3",children:[r,b.map(x=>WZ(x,{onRewind:i,rewindableUserMessageIds:s,onPermissionRespond:t,onPermissionInterrupt:n,onFork:o,onQuickAsk:a,realtimeQuestionAnswers:l,onSubmitQuestion:c,onCancelQuestion:u,liveQuestionToolUseIds:d,fileSharingScope:f,onShareFile:p,onOpenInTab:m,onPreviewMarkdown:v}))]})}function WZ(e,t){const{onRewind:n,rewindableUserMessageIds:r,onPermissionRespond:i,onPermissionInterrupt:s,onFork:o,onQuickAsk:a,realtimeQuestionAnswers:l,onSubmitQuestion:c,onCancelQuestion:u,liveQuestionToolUseIds:d,fileSharingScope:f,onShareFile:p,onOpenInTab:m,onPreviewMarkdown:v}=t,b=`${e.kind}-${e.seq}`;switch(e.kind){case"session-init":return null;case"user-text":{const x=typeof e.uuid=="string"?e.uuid:void 0,_=!!(n&&x&&(!r||r.has(x)));return h.jsx(yZ,{text:e.text,senderDisplayName:e.senderDisplayName,rewindTarget:_&&x&&n?{userMessageId:x,onRewind:n}:void 0},b)}case"user-meta":return h.jsx(CZ,{metaKind:e.metaKind,text:e.text},b);case"meta-text":return h.jsx(EZ,{text:e.text,metaSource:e.metaSource},b);case"agent-notification":return h.jsx(TZ,{text:e.text,taskId:e.taskId,parentToolUseId:e.parentToolUseId},b);case"assistant-text":{const x=typeof e.uuid=="string"?e.uuid:void 0,_=x&&(o||a)?{messageUuid:x,onFork:o,onQuickAsk:a}:void 0;return h.jsx(FY,{text:WU(e.text),forkTarget:_},b)}case"assistant-thinking":return h.jsx(HY,{text:e.text},b);case"permission-inline":return h.jsx(pZ,{tool:e.tool,input:e.input,onRespond:i??(()=>{}),onInterrupt:s},b);case"error":return h.jsx(mZ,{message:e.message},b);case"turn-end":return null;case"merged-tool":return VZ(e,b,{fileSharingScope:f,onShareFile:p,onOpenInTab:m,onPreviewMarkdown:v});case"merged-agent":return h.jsx(jZ,{description:e.description,input:e.input,output:e.output,error:e.error,pending:e.pending,notifications:e.notifications,toolResultExtra:e.toolResultExtra,progress:e.progress},b);case"plan-card":return h.jsx(DZ,{tasks:e.tasks},b);case"todo-checklist":return h.jsx(LZ,{todos:e.todos},b);case"memory-callout":return h.jsx(zZ,{memories:e.memories},b);case"question-card":{const x=d===void 0||d.has(e.toolUseId);return h.jsx(HZ,{toolUseId:e.toolUseId,questions:e.questions,historicalAnswers:e.submittedAnswers,realtimeAnswers:l==null?void 0:l[e.toolUseId],onSubmit:x?c:void 0,...x&&u?{onCancel:u}:{}},b)}default:return null}}function VZ(e,t,n){const r=ku.resolve(e.toolKind,e.tool),i=r?r.render({input:e.input,output:e.output,error:e.error,pending:e.pending,toolUseId:e.toolUseId,...n.fileSharingScope?{fileScope:n.fileSharingScope}:{},...n.onShareFile?{onShareFile:n.onShareFile}:{},...n.onOpenInTab?{onOpenInTab:n.onOpenInTab}:{},...n.onPreviewMarkdown?{onPreviewMarkdown:n.onPreviewMarkdown}:{}}):null;return h.jsx(st.Fragment,{children:i??h.jsx(yM,{tool:e.tool,input:e.input,output:e.output,error:e.error,pending:e.pending,...n.fileSharingScope?{fileScope:n.fileSharingScope}:{},...n.onShareFile?{onShareFile:n.onShareFile}:{},...n.onOpenInTab?{onOpenInTab:n.onOpenInTab}:{},...n.onPreviewMarkdown?{onPreviewMarkdown:n.onPreviewMarkdown}:{}})},t)}const qZ={builtin:"Commands",global:"Global",project:"Project",plugin:"Plugin"},gk={builtin:0,global:1,project:2,plugin:3};function KZ({query:e,skills:t,activeIndex:n,onActiveIndexChange:r,onSelect:i,onEmpty:s}){const o=g.useRef(null),a=g.useMemo(()=>NM(t,e),[t,e]),l=g.useMemo(()=>{const c=new Set;let u=null;for(let d=0;d<a.length;d++)a[d].source!==u&&(c.add(d),u=a[d].source);return c},[a]);return g.useEffect(()=>{a.length===0&&(s==null||s())},[a.length,s]),g.useEffect(()=>{var c;try{(c=o.current)==null||c.scrollIntoView({block:"nearest"})}catch{}},[n]),a.length===0?null:h.jsx("div",{"data-testid":"cc-skill-selector",className:"absolute bottom-full left-0 right-0 z-50 mb-1.5 max-h-[320px] overflow-y-auto rounded-2xl border border-bg-300 bg-bg-50 shadow-lg",children:a.map((c,u)=>{const d=u===n,f=l.has(u);return h.jsxs(st.Fragment,{children:[f?h.jsx("div",{className:"sticky top-0 z-10 bg-bg-50/95 backdrop-blur-sm px-4 py-2 text-[10px] font-semibold uppercase tracking-wider text-text-400/70 border-b border-bg-200/60",children:qZ[c.source]}):null,h.jsxs("div",{ref:d?o:void 0,"data-testid":`cc-skill-item-${c.name}`,onMouseEnter:()=>r(u),onClick:()=>i(c),className:ne("flex items-center gap-2.5 px-4 py-2 cursor-pointer transition-colors duration-75",d?"bg-[var(--text-100-dim)]":"hover:bg-bg-100/60"),children:[h.jsxs("code",{className:"text-[12px] font-mono font-semibold text-text-100 shrink-0",children:["/",c.name]}),c.description?h.jsx("span",{className:"text-[11px] text-text-300 truncate ml-auto",children:c.description}):null]})]},`${c.source}/${c.name}`)})})}function NM(e,t){const n=t.trim().toLowerCase(),r=n?e.filter(i=>i.name.toLowerCase().includes(n)||(i.description??"").toLowerCase().includes(n)):e.slice();return r.sort((i,s)=>(gk[i.source]??9)-(gk[s.source]??9)),r.slice(0,30)}const GZ={builtin:"Built-in",global:"Global",project:"Project",policy:"Policy",plugin:"Plugin",persona:"My personas",contact:"People","remote-persona":"Remote personas"},vk={builtin:0,global:1,project:2,policy:3,plugin:4,persona:5,contact:6,"remote-persona":7};function of(e){switch(e.kind){case"persona":return"persona";case"contact":return"contact";case"remote-persona":return"remote-persona";case"cc-agent":return e.agent.source}}function XZ(e){switch(e.kind){case"persona":return`persona/${e.persona.personaId}`;case"contact":return`contact/${e.contact.deviceId}`;case"remote-persona":return`remote/${e.deviceId}/${e.persona.personaId}`;case"cc-agent":return`${e.agent.source}/${e.agent.name}`}}function YZ(e){switch(e.kind){case"persona":return`${e.persona.personaId} ${e.persona.label}`.toLowerCase();case"contact":return`${e.contact.displayName} ${e.contact.deviceId}`.toLowerCase();case"remote-persona":return`${e.persona.personaId} ${e.persona.label}`.toLowerCase();case"cc-agent":{const t=e.agent;return`${t.name} ${t.description??""} ${t.whenToUse??""}`.toLowerCase()}}}function ZZ(e){switch(e.kind){case"persona":return{displayName:`@persona/${e.persona.personaId}`,description:e.persona.label,testid:`cc-agent-item-persona-${e.persona.personaId}`};case"contact":return{displayName:`@${e.contact.displayName}`,description:e.contact.deviceId,testid:`cc-agent-item-contact-${e.contact.deviceId}`};case"remote-persona":return{displayName:`@persona/${e.persona.personaId}`,description:e.persona.label,testid:`cc-agent-item-remote-${e.deviceId}-${e.persona.personaId}`};case"cc-agent":return{displayName:`@${e.agent.name}`,description:e.agent.description,whenToUse:e.agent.whenToUse,plugin:e.agent.plugin,testid:`cc-agent-item-${e.agent.name}`}}}function TM(e,t){const n=t.trim().toLowerCase(),r=n?e.filter(i=>YZ(i).includes(n)):e.slice();return r.sort((i,s)=>(vk[of(i)]??9)-(vk[of(s)]??9)),r.slice(0,30)}function xk({query:e,entries:t,activeIndex:n,onActiveIndexChange:r,onSelect:i,onEmpty:s}){const o=g.useRef(null),a=g.useMemo(()=>TM(t,e),[t,e]),l=g.useMemo(()=>{const c=new Set;let u=null;for(let d=0;d<a.length;d++){const f=of(a[d]);f!==u&&(c.add(d),u=f)}return c},[a]);return g.useEffect(()=>{a.length===0&&(s==null||s())},[a.length,s]),g.useEffect(()=>{var c;try{(c=o.current)==null||c.scrollIntoView({block:"nearest"})}catch{}},[n]),a.length===0?null:h.jsx("div",{"data-testid":"cc-agent-selector",className:"absolute bottom-full left-0 right-0 z-50 mb-1.5 max-h-[320px] overflow-y-auto rounded-2xl border border-bg-300 bg-bg-50 shadow-lg",children:a.map((c,u)=>{const d=u===n,f=l.has(u),p=of(c),m=ZZ(c);return h.jsxs(st.Fragment,{children:[f?h.jsx("div",{"data-testid":`cc-agent-group-header-${p}`,"data-source":p,className:"sticky top-0 z-10 bg-bg-50/95 backdrop-blur-sm px-4 py-2 text-[10px] font-semibold uppercase tracking-wider text-text-400/70 border-b border-bg-200/60",children:GZ[p]}):null,h.jsxs("div",{ref:d?o:void 0,"data-testid":m.testid,onMouseEnter:()=>r(u),onClick:()=>i(c),className:ne("flex items-center gap-2.5 px-4 py-2 cursor-pointer transition-colors duration-75",d?"bg-[var(--text-100-dim)]":"hover:bg-bg-100/60"),children:[h.jsx("code",{className:"text-[12px] font-mono font-semibold text-text-100 shrink-0",children:m.displayName}),m.description?h.jsx("span",{className:"text-[11px] text-text-300 truncate ml-2",children:m.description}):null,m.whenToUse?h.jsx("span",{className:"text-[10px] text-text-400/70 italic truncate ml-auto",children:m.whenToUse}):null,m.plugin?h.jsx("span",{className:"text-[10px] text-text-400/70 ml-2 shrink-0",children:m.plugin}):null]})]},XZ(c))})})}function QZ({attachment:e,onRemove:t,onOpenPreview:n}){const r=e.mimeType.startsWith("image/"),i=e.status==="error",s=e.status==="uploading",o=r&&e.status==="done"&&!!e.previewUrl&&!!n;return h.jsxs("div",{"data-testid":`attachment-pill-${e.id}`,className:ne("group relative flex items-center gap-1.5 rounded-lg border px-2 py-1.5 text-[12px] transition-colors",i?"border-red-400/40 bg-red-500/5":"border-bg-300 bg-bg-100"),children:[r&&e.previewUrl?h.jsxs("div",{className:"relative h-7 w-7 shrink-0",children:[h.jsx("img",{src:e.previewUrl,alt:e.fileName,onClick:o?n:void 0,"data-testid":`attachment-thumb-${e.id}`,className:ne("h-7 w-7 rounded object-cover",o&&"cursor-pointer hover:opacity-80",s&&"opacity-40")}),s?h.jsx(rr,{"data-testid":`attachment-spinner-${e.id}`,className:"absolute inset-0 m-auto h-3.5 w-3.5 animate-spin text-text-200"}):null]}):h.jsx("div",{className:"relative flex h-7 w-7 items-center justify-center rounded bg-text-100/5 shrink-0",children:s?h.jsx(rr,{"data-testid":`attachment-spinner-${e.id}`,className:"h-3.5 w-3.5 animate-spin text-text-400"}):h.jsx(Ds,{className:"h-3.5 w-3.5 text-text-400"})}),h.jsx("span",{className:ne("max-w-[120px] truncate text-text-200",s&&"text-text-400"),title:e.error??e.fileName,children:e.fileName}),i?h.jsx(Ls,{className:"h-3 w-3 text-red-400 shrink-0"}):null,h.jsx("button",{type:"button",onClick:t,"data-testid":`attachment-remove-${e.id}`,className:"flex h-4 w-4 items-center justify-center rounded-full text-text-400 hover:text-text-100 hover:bg-text-100/10 transition-colors cursor-pointer shrink-0","aria-label":"remove",children:h.jsx(Rn,{className:"h-3 w-3"})})]})}function JZ({attachments:e,onRemove:t,onOpenPreview:n}){return e.length===0?null:h.jsx("div",{"data-testid":"attachment-row",className:"flex flex-wrap gap-1.5 mb-2 px-1",children:e.map(r=>h.jsx(QZ,{attachment:r,onRemove:()=>t(r.id),onOpenPreview:n?()=>n(r):void 0},r.id))})}class Kl extends Error{constructor(t,n,r){super(n),this.code=t,this.status=r,this.name="UploadAttachmentError"}}async function eQ(e){if(!e.httpBaseUrl)throw new Kl("TUNNEL_NOT_READY","daemon httpBaseUrl unavailable");if(!e.httpToken)throw new Kl("NO_AUTH","daemon httpToken unavailable");const t=new URLSearchParams({sessionId:e.sessionId,fileName:e.file.name,mimeType:e.file.type||"application/octet-stream"}),n=`${e.httpBaseUrl.replace(/\/$/,"")}/attachments/upload?${t.toString()}`;let r;try{r=await fetch(n,{method:"POST",headers:{Authorization:`Bearer ${e.httpToken}`,"Content-Type":e.file.type||"application/octet-stream"},body:e.file})}catch(i){throw new Kl("NETWORK_ERROR",i.message)}if(!r.ok){let i="UPLOAD_FAILED",s=`HTTP ${r.status}`;try{const o=await r.json();o.code&&(i=o.code),o.message&&(s=o.message)}catch{}throw new Kl(i,s,r.status)}return await r.json()}const _k=25*1024*1024,tQ="image/*,.txt,.md,.markdown,.csv,.json,.log,.yaml,.yml,.html,.xml,.pdf",nQ=["image/","text/"],rQ=new Set(["application/json","application/xml","application/x-yaml","application/yaml","application/pdf"]),iQ=new Set(["txt","md","markdown","csv","json","log","yaml","yml","html","xml","pdf"]);function sQ(e){var r;const t=(e.type||"").toLowerCase();if(t&&nQ.some(i=>t.startsWith(i))||t&&rQ.has(t))return!0;const n=((r=e.name.split(".").pop())==null?void 0:r.toLowerCase())??"";return n.length>0&&iQ.has(n)}let oQ=0;const aQ=()=>`att-${++oQ}-${Date.now()}`;function lQ(e){return new Promise((t,n)=>{const r=new FileReader;r.onload=()=>t(typeof r.result=="string"?r.result:""),r.onerror=()=>n(r.error??new Error("read failed")),r.readAsDataURL(e)})}function cQ(e){const[t,n]=g.useState(e.initial??[]),r=g.useCallback(async o=>{const a=Array.from(o);if(a.length===0)return;const l=[],c=[],u=[];for(const d of a){const f={id:aQ(),fileName:d.name,mimeType:d.type||"application/octet-stream"};if(!sQ(d)){c.push({...f,url:null,status:"error",error:"不支持的文件类型"});continue}if(d.size>_k){c.push({...f,url:null,status:"error",error:`超过 ${Math.round(_k/1024/1024)}MB 上限`});continue}if(e.sessionId==null){u.push({id:f.id,file:d,mimeType:f.mimeType}),c.push({...f,url:null,status:"uploading"});continue}const p=f.mimeType.startsWith("image/")?URL.createObjectURL(d):void 0;c.push({...f,url:null,status:"uploading",...p?{previewUrl:p}:{}}),l.push({id:f.id,file:d})}n(d=>[...d,...c]);for(const d of u)try{const f=await lQ(d.file);n(p=>p.map(m=>m.id===d.id?{...m,url:f,status:"done",...d.mimeType.startsWith("image/")?{previewUrl:f}:{}}:m))}catch(f){n(p=>p.map(m=>m.id===d.id?{...m,status:"error",error:f.message??"read failed"}:m))}l.length!==0&&await Promise.all(l.map(async d=>{try{const f=await eQ({httpBaseUrl:e.httpBaseUrl,httpToken:e.httpToken,sessionId:e.sessionId,file:d.file});n(p=>p.map(m=>m.id===d.id?{...m,url:f.url,status:"done"}:m))}catch(f){const p=f instanceof Kl?f.code:"UPLOAD_FAILED",m=f.message??"upload failed";n(v=>v.map(b=>b.id===d.id?{...b,status:"error",error:`${p}: ${m}`}:b))}}))},[e.sessionId,e.httpBaseUrl,e.httpToken]),i=g.useCallback(o=>{n(a=>a.filter(l=>l.id!==o))},[]),s=g.useCallback(()=>{n([])},[]);return{attachments:t,setAttachments:n,addFiles:r,removeAttachment:i,clearAttachments:s}}const C0=new Map,uQ=[];function yk(e){if(e)return C0.get(e)}function bk(e,t){e&&(t.draft.length===0&&t.attachments.length===0?C0.delete(e):C0.set(e,t))}function dQ(e,t){return e.replace(/(^|\s)\/(\S+)/g,(n,r,i)=>{const s=t.find(o=>o.name===i&&o.path);return s!=null&&s.path?`${r}[skill:${i}:${s.path}]`:n})}function hQ({api:e,cwd:t,sessionKey:n,onSend:r,disabled:i,onNewSession:s,onClearSession:o,tool:a,spawnableContacts:l=uQ,ensureRemotePersonas:c,remotePersonasByDeviceId:u}){const d=yk(n),[f,p]=g.useState((d==null?void 0:d.draft)??""),[m,v]=g.useState(!1),b=g.useRef(null),x=g.useRef(!1),_=g.useCallback(()=>{x.current=!0},[]),y=g.useCallback(()=>{x.current=!1},[]),w=Xf(),{attachments:S,setAttachments:C,addFiles:N,removeAttachment:T,clearAttachments:M}=cQ({httpBaseUrl:w.httpBaseUrl,httpToken:w.httpToken,sessionId:n,initial:(d==null?void 0:d.attachments)??[]}),[P,D]=g.useState([]),[R,I]=g.useState(!1),[O,z]=g.useState(0),[$,F]=g.useState(!1),[L,B]=g.useState([]),[E,H]=g.useState(!1),[q,A]=g.useState(0),[re,oe]=g.useState(!1),[V,pe]=g.useState([]),[Oe,ie]=g.useState(!1),[Ae,Fe]=g.useState(null),[We,ge]=g.useState(!1),qe=g.useRef(null),Gt=g.useMemo(()=>{const ue=[];return s&&ue.push({name:"new",source:"builtin",description:"在当前目录下新建会话"}),o&&n&&ue.push({name:"clear",source:"builtin",description:"清除当前会话"}),ue},[s,o,n]),wt=g.useMemo(()=>[...Gt,...P],[Gt,P]),Rt=g.useMemo(()=>{const ue=f.match(/^\/(\S*)$/);return ue?ue[1]:null},[f]),ln=Rt!==null&&!$,Bt=g.useMemo(()=>Rt!==null?NM(wt,Rt):[],[wt,Rt]),at=g.useMemo(()=>{const ue=f.match(/^@(\S*)$/);return ue?ue[1]:null},[f]),Ue=at!==null&&!re,nt=g.useMemo(()=>Ae?((u==null?void 0:u.get(Ae.deviceId))??[]).map(Te=>({kind:"remote-persona",persona:Te,deviceId:Ae.deviceId})):[...L.map(ue=>({kind:"cc-agent",agent:ue})),...V.map(ue=>({kind:"persona",persona:ue})),...l.map(ue=>({kind:"contact",contact:ue}))],[Ae,u,L,V,l]),mt=g.useMemo(()=>at!==null?TM(nt,at):[],[nt,at]),Xt=g.useRef(f);g.useEffect(()=>{f!==Xt.current&&(F(!1),oe(!1),Xt.current=f)},[f]);const pn=g.useCallback(()=>{F(!0)},[]),U=g.useCallback(()=>{oe(!0)},[]),Q=g.useRef(f),ve=g.useRef(S);g.useEffect(()=>{Q.current=f},[f]),g.useEffect(()=>{ve.current=S},[S]);const Se=g.useRef(n);g.useEffect(()=>{const ue=Se.current;if(ue===n)return;bk(ue,{draft:Q.current,attachments:ve.current});const Te=yk(n);p((Te==null?void 0:Te.draft)??""),C((Te==null?void 0:Te.attachments)??[]),z(0),A(0),F(!1),oe(!1),Fe(null),qe.current=null,ge(!1),queueMicrotask(()=>{Te!=null&&Te.draft?PM(b.current):Xo(b.current)}),Se.current=n},[n,C]),g.useEffect(()=>()=>{bk(Se.current,{draft:Q.current,attachments:ve.current})},[]),g.useEffect(()=>{z(0)},[Rt]),g.useEffect(()=>{A(0)},[at]),g.useEffect(()=>{at===null&&Ae&&(Fe(null),qe.current=null,ge(!1))},[at,Ae]),g.useEffect(()=>{if(!ln||R)return;if(!e){I(!0);return}let ue=!1;return(async()=>{try{const Te=await e.skillsList(t,a);ue||(D(Te.skills??[]),I(!0))}catch{ue||I(!0)}})(),()=>{ue=!0}},[ln,R,e,t,a]),g.useEffect(()=>{if(!Ue||E)return;if(!e){H(!0);return}let ue=!1;return(async()=>{try{const Te=await e.agentsList(t,a);ue||(B(Te.agents??[]),H(!0))}catch{ue||H(!0)}})(),()=>{ue=!0}},[Ue,E,e,t,a]),g.useEffect(()=>{if(!Ue||Oe)return;if(!e){ie(!0);return}let ue=!1;return(async()=>{try{const Te=await e.personaList();ue||(pe((Te.personas??[]).map(Je=>({personaId:Je.personaId,label:Je.label,iconKey:Je.iconKey}))),ie(!0))}catch{ue||ie(!0)}})(),()=>{ue=!0}},[Ue,Oe,e]);const J=g.useCallback(ue=>{switch(ue.kind){case"persona":p(`@persona/${ue.persona.personaId} `);break;case"cc-agent":p(`@"${ue.agent.name} (agent)" `);break;case"contact":{const Te=ue.contact.deviceId;Fe({deviceId:Te,displayName:ue.contact.displayName}),qe.current=Te,ge(!0),Promise.resolve(c==null?void 0:c(Te)).finally(()=>{qe.current===Te&&ge(!1)}),p("@"),oe(!1),setTimeout(()=>{var Je;return(Je=b.current)==null?void 0:Je.focus()},0);return}case"remote-persona":p(`@persona/${ue.persona.personaId}@${ue.deviceId} `),Fe(null);break}oe(!1),setTimeout(()=>{var Te;return(Te=b.current)==null?void 0:Te.focus()},0)},[c]),Ye=g.useCallback(()=>{Fe(null),qe.current=null,ge(!1),p("@"),setTimeout(()=>{var ue;return(ue=b.current)==null?void 0:ue.focus()},0)},[]),Yt=g.useCallback(ue=>{if(ue.source==="builtin"&&ue.name==="new"&&s){p(""),M(),Xo(b.current),s(t);return}if(ue.source==="builtin"&&ue.name==="clear"&&o){p(""),M(),Xo(b.current),o();return}p(`/${ue.name} `),setTimeout(()=>{var Te;return(Te=b.current)==null?void 0:Te.focus()},0)},[s,t,M,o]),Zt=g.useCallback(async()=>{const ue=f.trim(),Te=S.filter(Je=>Je.status==="done");if(!(!ue&&Te.length===0)&&!(m||i)){if(ue==="/new"&&s){v(!0);try{await s(t),p(""),M(),Xo(b.current)}finally{v(!1)}return}if(ue==="/clear"&&o){v(!0);try{await o(),p(""),M(),Xo(b.current)}finally{v(!1)}return}v(!0);try{const Je=a==="codex"?dQ(ue,P):ue,Ln=vZ(Je,S);await r(Ln),p(""),M(),Xo(b.current)}finally{v(!1)}}},[f,S,m,i,r,s,t,M,o,a,P]);return{draft:f,setDraft:p,sending:m,textareaRef:b,isComposingRef:x,onCompositionStart:_,onCompositionEnd:y,attachments:S,addFiles:N,removeAttachment:T,skillSelectorVisible:ln,filteredSkills:Bt,slashQuery:Rt??"",activeSkillIdx:O,setActiveSkillIdx:z,selectSkill:Yt,dismissSkillSelector:pn,agentSelectorVisible:Ue,filteredAgents:mt,mentionQuery:at,activeAgentIdx:q,setActiveAgentIdx:A,selectAgent:J,dismissAgentSelector:U,drilldown:Ae,drilldownLoading:We,exitDrilldown:Ye,doSend:Zt}}const fQ=120;function PM(e){e&&(e.style.height="auto",e.style.height=`${Math.min(e.scrollHeight,fQ)}px`)}function Xo(e){e&&(e.style.height="auto")}const pQ={spawnableContacts:[],ensureRemotePersonas:()=>Promise.resolve(),remotePersonasByDeviceId:new Map},mQ=g.createContext(pQ);function gQ(){return g.useContext(mQ)}function vQ({url:e,fileName:t,onClose:n}){const[r,i]=g.useState(!1);g.useEffect(()=>{const o=a=>{a.key==="Escape"&&n()};return document.addEventListener("keydown",o),()=>document.removeEventListener("keydown",o)},[n]);const s=async()=>{try{const a=await(await fetch(e)).blob();await navigator.clipboard.write([new ClipboardItem({[a.type]:a})]),i(!0),setTimeout(()=>i(!1),2e3)}catch{wk(e,t)}};return h.jsx("div",{"data-testid":"image-lightbox",className:"fixed inset-0 z-[9999] flex items-center justify-center bg-black/60",onClick:n,role:"dialog","aria-modal":"true",children:h.jsxs("div",{className:"relative",onClick:o=>o.stopPropagation(),children:[h.jsx("img",{src:e,alt:t,className:"max-h-[90vh] max-w-[92vw] rounded-lg object-contain shadow-2xl"}),h.jsxs("div",{className:"absolute right-2 top-2 flex items-center gap-1.5",children:[h.jsxs("button",{type:"button",onClick:s,"data-testid":"image-lightbox-copy",className:"flex cursor-pointer items-center gap-1 rounded-full border border-bg-300 bg-bg-50/95 px-2 py-0.5 text-[11px] font-medium text-text-200 shadow transition-colors hover:bg-bg-100",children:[h.jsx(mu,{className:"h-3 w-3"}),r?"Copied":"Copy"]}),h.jsxs("button",{type:"button",onClick:()=>wk(e,t),"data-testid":"image-lightbox-save",className:"flex cursor-pointer items-center gap-1 rounded-full border border-bg-300 bg-bg-50/95 px-2 py-0.5 text-[11px] font-medium text-text-200 shadow transition-colors hover:bg-bg-100",children:[h.jsx(lz,{className:"h-3.5 w-3.5"}),"Save"]}),h.jsx("button",{type:"button",onClick:n,"data-testid":"image-lightbox-close","aria-label":"close",className:"flex h-6 w-6 cursor-pointer items-center justify-center rounded-full border border-bg-300 bg-bg-50/95 text-text-300 transition-colors hover:bg-bg-100 hover:text-text-100",children:h.jsx(Rn,{className:"h-3 w-3"})})]})]})})}function wk(e,t){const n=document.createElement("a");n.href=e,n.download=t||"image",n.click()}function xQ({meta:e,api:t,cwd:n,tool:r,onSend:i,sessionKey:s,disabled:o=!1,placeholder:a,className:l,awaitingUser:c=!1,onAbort:u,onNewSession:d,onClearSession:f}){const p=(e==null?void 0:e.streamInProgress)??!1,m=g.useRef(null),v=gQ(),b=hQ({...t?{api:t}:{},cwd:n,...r?{tool:r}:{},sessionKey:s,onSend:i,disabled:o,...d?{onNewSession:d}:{},...f?{onClearSession:f}:{},spawnableContacts:v.spawnableContacts,ensureRemotePersonas:v.ensureRemotePersonas,remotePersonasByDeviceId:v.remotePersonasByDeviceId}),{draft:x,setDraft:_,sending:y,textareaRef:w,attachments:S,addFiles:C,removeAttachment:N,skillSelectorVisible:T,filteredSkills:M,slashQuery:P,activeSkillIdx:D,setActiveSkillIdx:R,selectSkill:I,dismissSkillSelector:O,agentSelectorVisible:z,filteredAgents:$,mentionQuery:F,activeAgentIdx:L,setActiveAgentIdx:B,selectAgent:E,dismissAgentSelector:H,drilldown:q,drilldownLoading:A,exitDrilldown:re,doSend:oe}=b,V=!!t,pe=y||o||p,ie=(x.trim().length>0||S.some(J=>J.status==="done"))&&!o&&!y&&!c,Ae=a??(c?"Answer the question above first...":pe?"Queue a message...":`Message ${Gd(r)}...`),Fe=g.useRef(!1),We=g.useCallback(()=>{Fe.current=!0},[]),ge=g.useCallback(()=>{Fe.current=!1},[]),qe=g.useCallback(J=>{if(T&&M.length>0){if(J.key==="ArrowDown")return J.preventDefault(),R(D>=M.length-1?0:D+1),!0;if(J.key==="ArrowUp")return J.preventDefault(),R(D<=0?M.length-1:D-1),!0;if(J.key==="Tab"||J.key==="Enter"&&!J.shiftKey){J.preventDefault();const Ye=M[D];return Ye&&I(Ye),!0}if(J.key==="Escape")return J.preventDefault(),O(),!0}return!1},[T,M,D,R,I,O]),Gt=g.useCallback(J=>{if(z&&$.length>0){if(J.key==="ArrowDown")return J.preventDefault(),B(L>=$.length-1?0:L+1),!0;if(J.key==="ArrowUp")return J.preventDefault(),B(L<=0?$.length-1:L-1),!0;if(J.key==="Tab"||J.key==="Enter"&&!J.shiftKey){J.preventDefault();const Ye=$[L];return Ye&&E(Ye),!0}if(J.key==="Escape")return J.preventDefault(),q?re():H(),!0}return!1},[z,$,L,B,E,H,q,re]),wt=g.useCallback(J=>{const Ye=J.nativeEvent;J.key==="Enter"&&KI({compositionActive:Fe.current,nativeIsComposing:Ye.isComposing,keyCode:Ye.keyCode})||qe(J)||Gt(J)||GI({key:J.key,shiftKey:J.shiftKey,compositionActive:Fe.current,nativeIsComposing:Ye.isComposing,keyCode:Ye.keyCode})&&(J.preventDefault(),ie&&oe())},[qe,Gt,ie,oe]),Rt=g.useCallback(J=>{_(J.target.value),PM(J.target)},[_]),ln=g.useCallback(J=>{J.target.files&&C(J.target.files),J.target.value=""},[C]),Bt=g.useCallback(J=>{if(!V)return;const Ye=Array.from(J.clipboardData.items).map(Yt=>Yt.getAsFile()).filter(Yt=>!!(Yt&&Yt.type.startsWith("image/")));Ye.length!==0&&(J.preventDefault(),C(Ye))},[C,V]),[at,Ue]=g.useState(null),nt=g.useCallback(J=>{J.previewUrl&&Ue({url:J.previewUrl,name:J.fileName})},[]),[mt,Xt]=g.useState(!1),pn=g.useCallback(J=>{V&&(J.preventDefault(),Xt(!0))},[V]),U=g.useCallback(()=>Xt(!1),[]),Q=g.useCallback(J=>{V&&(J.preventDefault(),Xt(!1),J.dataTransfer.files.length>0&&C(J.dataTransfer.files))},[C,V]),ve=p&&!c&&typeof u=="function",Se=o||c;return h.jsxs("div",{"data-testid":"chat-input",className:ne("shrink-0 border-t border-bg-300/20 px-4 py-3",l),onDragOver:pn,onDragLeave:U,onDrop:Q,children:[h.jsxs("div",{className:"max-w-3xl mx-auto relative",children:[V?h.jsx("input",{ref:m,type:"file",multiple:!0,accept:tQ,hidden:!0,onChange:ln,"data-testid":"chat-input-file"}):null,h.jsxs("div",{"data-testid":"chat-input-bare",className:ne("flex flex-col gap-2"),children:[c||y||p?h.jsxs("div",{"data-testid":"chat-input-status-bar",className:"flex items-center gap-2 text-[12px] text-text-400",children:[h.jsxs("div",{className:"flex gap-1",children:[h.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-text-400-dim-fg animate-bounce",style:{animationDelay:"0ms"}}),h.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-text-400-dim-fg animate-bounce",style:{animationDelay:"150ms"}}),h.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-text-400-dim-fg animate-bounce",style:{animationDelay:"300ms"}})]}),h.jsx("span",{children:c?"Waiting for your answer":`${r==="codex"?"Codex":"Claude"} is working`})]}):null,T?h.jsx(KZ,{query:P,skills:M,activeIndex:D,onActiveIndexChange:R,onSelect:I}):null,z?q?!v.remotePersonasByDeviceId.has(q.deviceId)&&A?h.jsx("div",{"data-testid":"cc-agent-remote-loading",className:"absolute bottom-full left-0 right-0 z-50 mb-1.5 rounded-2xl border border-bg-300 bg-bg-50 px-4 py-3 text-[12px] text-text-300 shadow-lg",children:`正在加载 @${q.displayName} 的 persona…`}):$.length>0?h.jsx(xk,{query:F??"",entries:$,activeIndex:L,onActiveIndexChange:B,onSelect:E}):h.jsx("div",{"data-testid":"cc-agent-remote-empty",className:"absolute bottom-full left-0 right-0 z-50 mb-1.5 rounded-2xl border border-bg-300 bg-bg-50 px-4 py-3 text-[12px] text-text-300 shadow-lg",children:`@${q.displayName} 暂无可派活的 persona(可能离线或未公开)`}):h.jsx(xk,{query:F??"",entries:$,activeIndex:L,onActiveIndexChange:B,onSelect:E}):null,S.length>0?h.jsx(JZ,{attachments:S,onRemove:N,onOpenPreview:nt}):null,h.jsxs("div",{"data-testid":"bare-chat-input-frame",className:ne("flex items-end gap-2 rounded-xl border border-bg-300 bg-bg-50 px-3 py-2 transition-colors duration-200",Se?"opacity-60":null,mt?"border-accent/60 bg-accent/5":null),children:[V?h.jsx("button",{type:"button",onClick:()=>{var J;return(J=m.current)==null?void 0:J.click()},disabled:pe,"data-testid":"chat-input-attach","aria-label":"attach files",className:ne("flex h-8 w-8 shrink-0 self-end items-center justify-center rounded-md transition-colors",pe?"cursor-default text-text-400/50":"cursor-pointer text-text-400 hover:bg-text-100/5 hover:text-text-200"),children:h.jsx(Bz,{className:"h-4 w-4"})}):null,h.jsx("textarea",{ref:w,"data-testid":"chat-input-textarea",value:x,onChange:Rt,onKeyDown:wt,onCompositionStart:We,onCompositionEnd:ge,onPaste:Bt,placeholder:Ae,disabled:Se,readOnly:Se,rows:1,className:"flex-1 resize-none bg-transparent border-0 outline-none text-[14px] text-text-100 placeholder:text-text-400 leading-relaxed py-1 min-h-[22px] max-h-[120px] overflow-y-auto disabled:cursor-not-allowed"}),h.jsxs("div",{className:"flex items-center gap-1.5 shrink-0 pb-0.5",children:[ve?h.jsx("button",{type:"button",onClick:u,"data-testid":"chat-input-abort","aria-label":"interrupt",title:"中断当前轮次(不杀进程)",className:"h-8 w-8 rounded-full flex items-center justify-center border border-text-400/40 text-text-400 hover:bg-text-100/5 hover:text-text-100 transition-colors cursor-pointer",children:h.jsx(TT,{className:"w-3.5 h-3.5",strokeWidth:2.5})}):null,h.jsx("button",{type:"button",onClick:()=>{ie&&oe()},disabled:!ie,"data-testid":"chat-input-send","aria-label":"send",className:ne("h-8 w-8 rounded-full flex items-center justify-center transition-colors",ie?"bg-accent text-white hover:bg-accent-hover cursor-pointer shadow-sm":"bg-[var(--text-400-dim)] text-[var(--text-400-dim-fg)] cursor-default"),children:h.jsx(A6,{className:"w-4 h-4",strokeWidth:2.5})})]})]})]})]}),at?h.jsx(vQ,{url:at.url,fileName:at.name,onClose:()=>Ue(null)}):null]})}function _Q(e){const t=e.replace(/\/+$/,""),n=t.lastIndexOf("/");return n>=0?t.slice(n+1):t}function yQ({meta:e,tool:t,connState:n,onOpenConfig:r,models:i,liveGitBranch:s,liveWorktreeRoot:o,onForceStop:a,cronActiveCount:l,onCronClick:c,onOpenFiles:u,onTogglePin:d,isHolded:f=!1,onToggleHold:p,personaName:m,onOpenPersona:v,className:b}){const x=e.procAlive??!1,_=e.streamInProgress??!1,y=e.permissionMode,w=y&&y!=="default"?y:null,S=w==="bypassPermissions"?"YOLO":w==="plan"?"Plan":null,C=e.model??"",N=bQ(i,C),T=e.contextPct??null,M=T==null?"":T>=80?"text-red-400":T>=50?"text-amber-400":"text-text-500",P=s!==void 0?s:e.gitBranch??null,D=o??e.cwd??"",I=!!e.sessionLabel&&e.sessionLabel!==e.sessionId?e.sessionLabel:_Q(D),O=D,z=e.pinnedAt!=null;return h.jsxs("div",{"data-testid":"chat-header",className:ne("relative flex flex-col justify-center shrink-0 px-4 pr-14 py-2 gap-1",b),children:[h.jsxs("div",{className:"flex items-center min-w-0 gap-2 text-[13px]",children:[d?h.jsx("button",{type:"button",onClick:()=>d(!z),"data-testid":"chat-header-pin-toggle","data-pinned":z?"true":"false","aria-pressed":z,title:z?"Unpin session":"Pin session",className:ne("shrink-0 inline-flex items-center justify-center h-5 w-5 rounded-md cursor-pointer transition-colors",z?"text-amber-400 hover:bg-amber-500/10":"text-text-500 hover:text-text-200 hover:bg-text-100/5"),children:h.jsx(IT,{className:ne("w-3.5 h-3.5",z&&"fill-current")})}):null,p?h.jsx("button",{type:"button",onClick:()=>p(!f),"data-testid":"chat-header-hold-toggle","data-holded":f?"true":"false","aria-pressed":f,title:f?"Release hold":"Hold session",className:ne("shrink-0 inline-flex items-center justify-center h-5 w-5 rounded-md cursor-pointer transition-colors",f?"text-amber-400 hover:bg-amber-500/10":"text-text-500 hover:text-text-200 hover:bg-text-100/5"),children:h.jsx(H6,{className:ne("w-3.5 h-3.5",f&&"fill-current")})}):null,h.jsx("span",{className:"font-semibold text-text-100 truncate","data-testid":"chat-header-worktree",title:O,children:I}),P?h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"text-text-500 shrink-0",children:":"}),h.jsx("span",{className:"font-mono text-text-300 truncate","data-testid":"chat-header-git",title:P,children:P})]}):null]}),h.jsxs("div",{className:"flex items-center min-w-0 gap-2 text-[11px]",children:[S?h.jsxs(h.Fragment,{children:[h.jsx("button",{type:"button",onClick:()=>r==null?void 0:r("desktop"),"data-testid":"chat-header-mode-chip",className:ne("hidden md:inline-flex shrink-0 px-2 py-0.5 rounded-md font-semibold cursor-pointer transition-colors",w==="bypassPermissions"?"bg-red-500/15 text-red-400 hover:bg-red-500/25":"bg-blue-500/15 text-blue-400 hover:bg-blue-500/25"),children:S}),h.jsx("button",{type:"button",onClick:()=>r==null?void 0:r("mobile"),"aria-hidden":"true",tabIndex:-1,className:ne("inline-flex md:hidden shrink-0 px-2 py-0.5 rounded-md font-semibold cursor-pointer transition-colors",w==="bypassPermissions"?"bg-red-500/15 text-red-400 hover:bg-red-500/25":"bg-blue-500/15 text-blue-400 hover:bg-blue-500/25"),children:S})]}):null,C||i?h.jsxs(h.Fragment,{children:[h.jsx("button",{type:"button",onClick:()=>r==null?void 0:r("desktop"),"data-testid":"chat-header-model-chip",className:"hidden md:inline-flex shrink-0 font-mono text-text-400 cursor-pointer hover:text-text-200 transition-colors",children:N}),h.jsx("button",{type:"button",onClick:()=>r==null?void 0:r("mobile"),"aria-hidden":"true",tabIndex:-1,className:"inline-flex md:hidden shrink-0 font-mono text-text-400 cursor-pointer hover:text-text-200 transition-colors",children:N})]}):null,T!=null?h.jsxs("span",{className:ne("shrink-0 font-mono",M),"data-testid":"chat-header-ctx",children:["ctx:",T,"%"]}):null,h.jsxs("span",{"data-testid":"chat-header-proc-status",className:"inline-flex items-center gap-1 text-text-500 shrink-0",title:_?`${Gd(t)} 正在跑当前 turn`:x?`${Gd(t)} 进程仍活,等下一轮输入`:`${Gd(t)} 进程未运行(发送消息会自动启动)`,children:[h.jsx("span",{className:ne("w-1.5 h-1.5 rounded-full",_?"bg-green-500":"bg-text-400/50")}),h.jsx("span",{children:_?"running":"idle"})]}),x&&a?h.jsxs("button",{type:"button",onClick:a,"data-testid":"chat-header-force-stop",title:t==="codex"?"强制停止 Codex 进程":"强制停止 Claude Code 进程(会丢失 initialize / 预热缓存)",className:"shrink-0 inline-flex items-center gap-1 h-5 px-2 rounded-md text-text-400 hover:bg-red-500/10 hover:text-red-400 transition-colors cursor-pointer",children:[h.jsx(Dz,{className:"w-3 h-3"}),h.jsx("span",{children:"Stop"})]}):null,m&&v||u||l&&l>0&&c?h.jsx("span",{className:"text-text-500 shrink-0","aria-hidden":"true",children:"·"}):null,m&&v?h.jsxs("button",{type:"button",onClick:v,"data-testid":"chat-header-persona",title:m,className:"shrink-0 inline-flex items-center gap-1 h-5 px-2 rounded-md text-text-300 hover:bg-bg-200 hover:text-text-100 transition-colors cursor-pointer",children:[h.jsx(T_,{className:"w-3 h-3"}),h.jsx("span",{className:"truncate max-w-[80px] md:max-w-[120px]",children:m})]}):null,u?h.jsxs("button",{type:"button",onClick:u,"data-testid":"chat-header-files",title:"Edited Files",className:"shrink-0 inline-flex items-center gap-1 h-5 px-2 rounded-md text-text-300 hover:bg-bg-200 hover:text-text-100 transition-colors cursor-pointer",children:[h.jsx(mz,{className:"w-3 h-3"}),h.jsx("span",{className:"hidden md:inline",children:"Edited Files"})]}):null,l&&l>0&&c?h.jsxs("button",{type:"button","data-testid":"chat-header-cron-button",onClick:c,"aria-label":"Cron tasks",title:`${l} active cron task${l===1?"":"s"}`,className:"shrink-0 inline-flex items-center gap-1 h-5 px-2 rounded-md text-text-400 hover:bg-accent-dim hover:text-accent transition-colors cursor-pointer",children:[h.jsx(tz,{className:"w-3 h-3"}),h.jsx("span",{"data-testid":"chat-header-cron-badge",className:"font-mono",children:l})]}):null]}),r?h.jsxs(h.Fragment,{children:[h.jsx("button",{type:"button","aria-label":"Session settings","data-testid":"chat-header-settings",onClick:()=>r("desktop"),title:"Session settings",className:"hidden md:flex absolute right-4 top-3 z-10 h-7 w-7 items-center justify-center rounded-md bg-transparent text-text-300 transition-colors duration-150 hover:bg-bg-200 hover:text-text-100 cursor-pointer outline-none",children:h.jsx(Qv,{className:"w-4 h-4"})}),h.jsx("button",{type:"button","aria-label":"Session settings","data-testid":"chat-header-settings-mobile",onClick:()=>r("mobile"),title:"Session settings",className:"flex md:hidden absolute right-4 top-3 z-10 h-7 w-7 items-center justify-center rounded-md bg-transparent text-text-300 transition-colors duration-150 hover:bg-bg-200 hover:text-text-100 cursor-pointer outline-none",children:h.jsx(Qv,{className:"w-4 h-4"})})]}):null]})}function bQ(e,t){if(!t)return"default";const n=t.toLowerCase(),r=[["opus","Opus"],["sonnet","Sonnet"],["haiku","Haiku"]];for(const[a,l]of r){if(!n.includes(a))continue;const c=n.match(new RegExp(`${a}-(\\d+)-(\\d+)`));return c?`${l} ${c[1]}.${c[2]}`:l}const i=e??[],s=i.find(a=>a.id===t);if(s)return s.label;const o=i.find(a=>a.id&&t.toLowerCase().includes(a.id.toLowerCase()));return o?o.label:t}function wQ(e){return e==="TodoWrite"}function SQ(e){if(!e||typeof e!="object")return null;const t=e;if(!Array.isArray(t.todos))return null;const n=[];for(const r of t.todos){if(!r||typeof r!="object")continue;const i=r,s=typeof i.content=="string"?i.content:"";if(!s)continue;const o=i.status==="in_progress"||i.status==="completed"?i.status:"pending",a=typeof i.activeForm=="string"?i.activeForm:void 0;n.push({content:s,status:o,activeForm:a})}return n}function kQ(e,t,n){var s;const r=[],i=new Map;for(let o=0;o<e.length;o++){const a=e[o],l=typeof a.seq=="number"?a.seq:o;switch(a.kind){case"session_init":r.push({kind:"session-init",seq:l,toolSessionId:a.toolSessionId});break;case"text":Sk(r,l,"assistant-text",a.text,a.partialId,a.uuid);break;case"thinking":Sk(r,l,"assistant-thinking",a.text,a.partialId);break;case"user_text":{a.meta==="task-notification"?r.push({kind:"agent-notification",seq:l,text:a.text,taskId:a.taskId,parentToolUseId:a.parentToolUseId}):a.meta?r.push({kind:"user-meta",seq:l,metaKind:a.meta,text:a.text}):r.push({kind:"user-text",seq:l,text:a.text,uuid:a.uuid,senderDisplayName:(s=a.sender)==null?void 0:s.displayName});break}case"tool_call":IM(r,l,a.toolUseId,a.tool,a.input,a.toolKind);break;case"tool_result":{const c=i.get(a.toolUseId);if(c!==void 0){if(a.askQuestionAnswers){const d=r[c];d.submittedAnswers=a.askQuestionAnswers}i.delete(a.toolUseId);break}const u={kind:"tool-result",seq:l,toolUseId:a.toolUseId,output:a.output,error:a.error};a.toolResultExtra&&(u.toolResultExtra=a.toolResultExtra),r.push(u);break}case"attachment_memories":r.push({kind:"memory-callout",seq:l,memories:a.memories});break;case"permission_request":{if(!t||a.requestId!==t)break;r.push({kind:"permission-inline",seq:l,requestId:a.requestId,tool:a.tool,input:a.input});break}case"ask_user_question":i.set(a.toolUseId,r.length),r.push({kind:"question-card",seq:l,toolUseId:a.toolUseId,questions:a.questions});break;case"turn_end":r.push({kind:"turn-end",seq:l});break;case"subagent_progress":{const c={kind:"agent-progress",seq:l,toolUseId:a.toolUseId,agentId:a.agentId,status:a.status};a.description&&(c.description=a.description),a.lastToolName&&(c.lastToolName=a.lastToolName),a.prompt&&(c.prompt=a.prompt),a.stats&&(c.stats=a.stats),r.push(c);break}case"error":r.push({kind:"error",seq:l,message:a.message});break}}return r}function IM(e,t,n,r,i,s){if(wQ(r)){const o=SQ(i);if(o){e.push({kind:"todo-checklist",seq:t,toolUseId:n,todos:o});return}}if(r==="Agent"){const o=i??{},a=typeof o.description=="string"&&o.description?o.description:typeof o.subagent_type=="string"&&o.subagent_type?o.subagent_type:"Subagent";e.push({kind:"agent-call",seq:t,toolUseId:n,description:a,input:i});return}if(OU(r)){e.push({kind:"task-event",seq:t,toolUseId:n,name:r,input:i});return}e.push({kind:"tool-call",seq:t,toolUseId:n,tool:r,toolKind:s,input:i})}function Sk(e,t,n,r,i,s){let o=-1;for(let c=e.length-1;c>=0;c--)if(e[c].kind===n){o=c;break}const a=o>=0?e[o]:null;if(i){if(a&&a.partialId===i){const u=n==="assistant-text"?{kind:n,seq:a.seq,text:a.text+r,partialId:i,...s?{uuid:s}:{}}:{kind:n,seq:a.seq,text:a.text+r,partialId:i};e[o]=u;return}const c=n==="assistant-text"?{kind:n,seq:t,text:r,partialId:i,...s?{uuid:s}:{}}:{kind:n,seq:t,text:r,partialId:i};e.push(c);return}if(a&&a.partialId){const c=n==="assistant-text"?{kind:n,seq:a.seq,text:r,...s?{uuid:s}:{}}:{kind:n,seq:a.seq,text:r};e[o]=c;return}const l=n==="assistant-text"?{kind:n,seq:t,text:r,...s?{uuid:s}:{}}:{kind:n,seq:t,text:r};e.push(l)}const CQ="AskUserQuestion";function RM(e,t=0,n){var o;const r=[],i=new Map;let s=t;for(const a of e){const l=s++,c=a.toolUseId??`hist-${l}`;switch(a.kind){case"user-text":if(a.meta==="task-notification")r.push({kind:"agent-notification",seq:l,text:a.text??"",taskId:a.taskId,parentToolUseId:a.parentToolUseId});else if(a.meta)r.push({kind:"user-meta",seq:l,metaKind:a.meta,text:a.text??""});else{const u=(o=MB.exec(a.text??""))==null?void 0:o[1];r.push({kind:"user-text",seq:l,text:a.text??"",uuid:a.uuid,...u?{senderDisplayName:u}:{}})}break;case"assistant-text":r.push({kind:"assistant-text",seq:l,text:a.text??"",uuid:a.uuid});break;case"tool_call":{if(a.tool===CQ){const u=a.input??{},d=Array.isArray(u.questions)?u.questions:[];i.set(c,r.length),r.push({kind:"question-card",seq:l,toolUseId:c,questions:d});break}IM(r,l,c,a.tool??"",a.input,n);break}case"tool_result":{const u=i.get(c);if(u!==void 0){if(a.askQuestionAnswers){const f=r[u];f.submittedAnswers=a.askQuestionAnswers}i.delete(c);break}const d={kind:"tool-result",seq:l,toolUseId:c,output:a.output};a.error!==void 0&&(d.error=a.error),a.toolResultExtra&&(d.toolResultExtra=a.toolResultExtra),r.push(d);break}case"attachment_memories":a.memories&&a.memories.length>0&&r.push({kind:"memory-callout",seq:l,memories:a.memories});break}}return r}function EQ({api:e,cwd:t,toolSessionId:n}){const r=kM(),i=(r==null?void 0:r.state.agentId)??null,s=r==null?void 0:r.state.agentType,[o,a]=g.useState([]),[l,c]=g.useState(!1),[u,d]=g.useState(null);g.useEffect(()=>{if(!i)return;let p=!1;return c(!0),d(null),a([]),e.historySubagentRead({cwd:t,toolSessionId:n,subagentId:i}).then(m=>{p||a(m.messages??[])}).catch(m=>{p||d(m instanceof Error?m.message:String(m))}).finally(()=>{p||c(!1)}),()=>{p=!0}},[i,t,n,e]);const f=g.useMemo(()=>o.length>0?RM(o,0,"claude"):[],[o]);return!r||!i?null:h.jsxs("div",{"data-testid":"subagent-drawer","data-agent-id":i,className:ne("fixed inset-y-0 right-0 z-50 w-[min(560px,92vw)]","flex flex-col border-l border-bg-200/60 bg-bg-50 shadow-xl"),style:{paddingTop:"env(safe-area-inset-top)"},children:[h.jsxs("div",{className:"flex flex-col gap-0.5 px-3 py-2 border-b border-bg-200/60",children:[h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s?h.jsx("span",{className:"inline-flex items-center rounded-sm bg-violet-500/10 px-1.5 py-0.5 text-[11px] text-violet-400 font-medium",children:s}):null,h.jsx("span",{className:"font-mono text-[11px] text-text-400 truncate",title:i,children:i})]}),h.jsx("button",{type:"button","aria-label":"关闭",onClick:()=>r.close(),className:"p-1 rounded hover:bg-bg-200/50 text-text-400 hover:text-text-200",children:h.jsx(Rn,{className:"w-4 h-4"})})]}),!l&&!u&&o.length>0?h.jsxs("div",{className:"text-[11px] text-text-400",children:[o.length," 条消息 · 首条为主会话派发的任务指令"]}):null]}),h.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto overflow-x-hidden px-3 py-2",children:l?h.jsxs("div",{className:"flex items-center gap-2 text-[12px] text-text-400",children:[h.jsx(rr,{className:"w-3.5 h-3.5 animate-spin"}),h.jsx("span",{children:"加载中…"})]}):u?h.jsxs("div",{className:"flex items-center gap-2 text-[12px] text-error",children:[h.jsx(Ls,{className:"w-3.5 h-3.5"}),h.jsx("span",{children:u})]}):f.length===0?h.jsx("div",{className:"text-[12px] text-text-400 italic",children:"无消息"}):h.jsx(EM,{lines:f})})]})}function kk(e,t){let n=0;for(const r of e.lines)r.startsWith(t)&&n++;return n}function NQ(e,t){const n=e.findIndex(c=>c.kind==="user-text"&&c.uuid===t);if(n<0)return{userMessageId:t,files:[],totalInsertions:0,totalDeletions:0,anchorFound:!1};let r=e.length;for(let c=n+1;c<e.length;c++)if(e[c].kind==="user-text"){r=c;break}const i=[],s=new Map;for(let c=n+1;c<r;c++){const u=e[c];if(u.kind!=="tool-result")continue;const d=u.toolResultExtra;if(!(d!=null&&d.filePath)||!d.structuredPatch||d.structuredPatch.length===0)continue;const f=d.filePath;let p=s.get(f);p||(p={filePath:f,hunks:[],insertions:0,deletions:0},s.set(f,p),i.push(f));for(const m of d.structuredPatch)p.hunks.push(m),p.insertions+=kk(m,"+"),p.deletions+=kk(m,"-")}const o=i.map(c=>s.get(c)),a=o.reduce((c,u)=>c+u.insertions,0),l=o.reduce((c,u)=>c+u.deletions,0);return{userMessageId:t,files:o,totalInsertions:a,totalDeletions:l,anchorFound:!0}}function TQ({open:e,onOpenChange:t,api:n,sessionId:r,userMessageId:i,lines:s,procAlive:o,onApplied:a,onNoChanges:l}){const c=g.useMemo(()=>NQ(s,i),[s,i]),[u,d]=g.useState(null),[f,p]=g.useState(!1),[m,v]=g.useState(!1),[b,x]=g.useState(null);g.useEffect(()=>{if(!e)return;let C=!1;return p(!0),d(null),(async()=>{try{const N=await n.sessionRewindDiff({sessionId:r,userMessageId:i});C||(d(N),!N.canRewind&&!N.error&&N.files.length===0&&(l==null||l(i)))}catch{C||d(null)}finally{C||p(!1)}})(),()=>{C=!0}},[e,n,r,i]);const _=g.useMemo(()=>{if(u){const C=!u.canRewind&&!u.error&&u.files.length===0;if(u.canRewind||C)return{source:"rpc",anchorFound:!0,files:u.files.map(N=>({filePath:N.filePath,hunks:N.hunks,insertions:N.insertions,deletions:N.deletions})),totalInsertions:u.totalInsertions,totalDeletions:u.totalDeletions}}return{source:"local",anchorFound:c.anchorFound,files:c.files,totalInsertions:c.totalInsertions,totalDeletions:c.totalDeletions,rpcError:u==null?void 0:u.error}},[u,c]),y=g.useCallback(async()=>{v(!0),x(null);try{const C=await n.sessionRewind({sessionId:r,userMessageId:i,dryRun:!1});if(!C.canRewind){x(C.error??"回退失败");return}a==null||a(),t(!1)}catch(C){x(C.message||"回退失败")}finally{v(!1)}},[n,r,i,a,t]);if(!e)return null;const w=_.files.length>0,S=!f&&!m&&_.anchorFound&&w&&!b;return h.jsxs("div",{"data-testid":"rewind-preview-drawer",className:"fixed right-0 top-0 bottom-0 z-40 flex flex-col border-l border-bg-300/40 bg-bg-0 shadow-xl",style:{width:480,minWidth:480},children:[h.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-bg-300/30 shrink-0",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(MT,{className:"w-4 h-4 text-text-300"}),h.jsx("span",{className:"text-[14px] font-semibold text-text-100",children:"Rewind 预览"})]}),h.jsx("button",{type:"button",onClick:()=>t(!1),"data-testid":"rewind-drawer-close",className:"flex items-center justify-center w-7 h-7 rounded-md text-text-400 hover:bg-text-100/5 hover:text-text-200 cursor-pointer","aria-label":"close",children:h.jsx(Rn,{className:"w-4 h-4"})})]}),b?h.jsxs("div",{"data-testid":"rewind-error-banner",className:"mx-4 mt-3 flex items-start gap-2 rounded-md border border-red-400/40 bg-red-500/10 px-3 py-2 text-[12px] text-red-400",children:[h.jsx(Uc,{className:"w-4 h-4 shrink-0 mt-0.5"}),h.jsx("span",{children:b})]}):null,h.jsx("div",{className:"flex-1 overflow-y-auto px-4 py-3 space-y-3",children:f?h.jsxs("div",{"data-testid":"rewind-loading",className:"flex items-center gap-2 text-[12px] text-text-400",children:[h.jsx(rr,{className:"w-3.5 h-3.5 animate-spin"}),h.jsx("span",{children:"正在读取快照…"})]}):_.anchorFound?w?h.jsxs(h.Fragment,{children:[h.jsxs("div",{"data-testid":"rewind-summary",className:"rounded-md border border-bg-300 bg-bg-100/40 px-3 py-2 text-[12px] text-text-200",children:[h.jsxs("div",{children:["将回退 ",h.jsx("span",{className:"font-semibold text-text-100",children:_.files.length})," ","个文件,",h.jsxs("span",{className:"text-green-500 font-mono",children:["+",_.totalInsertions]})," / ",h.jsxs("span",{className:"text-red-400 font-mono",children:["-",_.totalDeletions]})]}),_.source==="local"?h.jsx("div",{"data-testid":"rewind-source-hint",className:"mt-1 text-text-400 text-[11px]",children:"基于对话里 tool_result 估算(未读到 CC 快照,数字可能与实际磁盘略有差异)"}):null]}),_.files.map(C=>h.jsx(IQ,{file:C},C.filePath))]}):h.jsxs("div",{"data-testid":"rewind-no-changes",className:"rounded-md border border-bg-300 bg-bg-100/60 px-3 py-2 text-[12px] text-text-300 space-y-1",children:[h.jsx("div",{children:"磁盘上的文件已经和这个时刻的快照完全一致——没有需要回退的改动。"}),h.jsx("div",{className:"text-text-400 text-[11px]",children:"可能这条消息之后 Claude 没落盘编辑,或之前已经 rewind 过了。"})]}):h.jsx("div",{"data-testid":"rewind-no-anchor",className:"rounded-md border border-bg-300 bg-bg-100/60 px-3 py-2 text-[12px] text-text-300",children:"未能在当前消息流中找到对应的用户消息(可能已被历史裁剪)。"})}),h.jsxs("div",{className:"flex flex-col gap-2 px-4 py-3 border-t border-bg-300/30 shrink-0",children:[w&&_.anchorFound&&!o?h.jsxs("div",{"data-testid":"rewind-needs-cc",className:"flex items-start gap-2 rounded-md border border-bg-300 bg-bg-100/60 px-3 py-2 text-[12px] text-text-300",children:[h.jsx(Uc,{className:"w-4 h-4 shrink-0 mt-0.5 text-warning"}),h.jsx("span",{children:'Claude Code 进程当前未运行。点击"确认回退"时会自动启动它再执行 — 可能需要等一两秒。'})]}):null,h.jsxs("div",{className:"flex items-center justify-end gap-2",children:[h.jsx("button",{type:"button",onClick:()=>t(!1),className:"h-8 px-3 rounded-md text-[12px] text-text-300 hover:bg-text-100/5 cursor-pointer",children:"取消"}),h.jsx("button",{type:"button",disabled:!S,onClick:()=>void y(),"data-testid":"rewind-apply",className:ne("h-8 px-3 rounded-md text-[12px] font-medium transition-colors",S?"bg-accent text-white hover:bg-accent-hover cursor-pointer":"bg-bg-200 text-text-400 cursor-not-allowed"),children:m?"回退中…":"确认回退"})]})]})]})}function PQ(e){return e.replace(/^\/Users\/[^/]+/,"~")}function IQ({file:e}){const[t,n]=g.useState(!0);return h.jsxs("div",{"data-testid":"rewind-file-block","data-file":e.filePath,className:"rounded-md border border-bg-300 overflow-hidden bg-bg-0",children:[h.jsxs("button",{type:"button",onClick:()=>n(r=>!r),className:"w-full flex items-center gap-1.5 px-3 py-2 text-[12px] hover:bg-text-100/5 cursor-pointer",children:[t?h.jsx(ci,{className:"w-3.5 h-3.5 text-text-400 shrink-0"}):h.jsx(ui,{className:"w-3.5 h-3.5 text-text-400 shrink-0"}),h.jsx("span",{className:"font-mono text-text-200 truncate flex-1 text-left",title:e.filePath,children:PQ(e.filePath)}),h.jsxs("span",{className:"font-mono shrink-0 text-text-400",children:[h.jsxs("span",{className:"text-green-500",children:["+",e.insertions]})," ",h.jsxs("span",{className:"text-red-400",children:["-",e.deletions]})]})]}),t?h.jsx("div",{className:"border-t border-bg-300",children:e.hunks.map(r=>h.jsx(RQ,{hunk:r},`${r.oldStart}-${r.oldLines}-${r.newStart}-${r.newLines}`))}):null]})}function RQ({hunk:e}){const t=`@@ -${e.oldStart},${e.oldLines} +${e.newStart},${e.newLines} @@`;return h.jsxs("div",{className:"text-[11px] font-mono leading-relaxed",children:[h.jsx("div",{className:"px-3 py-1 text-text-400 bg-bg-100/40 border-b border-bg-300",children:t}),e.lines.map((n,r)=>{const i=n.charAt(0),s=i==="+"?"bg-green-500/10 text-green-300":i==="-"?"bg-red-500/10 text-red-300":"text-text-300";return h.jsx("div",{className:ne("px-3 whitespace-pre",s),children:n.length>0?n:" "},r)})]})}var yp="Dialog",[MM]=Ro(yp),[MQ,Br]=MM(yp),AM=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:s,modal:o=!0}=e,a=g.useRef(null),l=g.useRef(null),[c,u]=Qf({prop:r,defaultProp:i??!1,onChange:s,caller:yp});return h.jsx(MQ,{scope:t,triggerRef:a,contentRef:l,contentId:oo(),titleId:oo(),descriptionId:oo(),open:c,onOpenChange:u,onOpenToggle:g.useCallback(()=>u(d=>!d),[u]),modal:o,children:n})};AM.displayName=yp;var jM="DialogTrigger",AQ=g.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=Br(jM,n),s=qt(t,i.triggerRef);return h.jsx(Et.button,{type:"button","aria-haspopup":"dialog","aria-expanded":i.open,"aria-controls":i.contentId,"data-state":Ay(i.open),...r,ref:s,onClick:Pe(e.onClick,i.onOpenToggle)})});AQ.displayName=jM;var Ry="DialogPortal",[jQ,LM]=MM(Ry,{forceMount:void 0}),DM=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:i}=e,s=Br(Ry,t);return h.jsx(jQ,{scope:t,forceMount:n,children:g.Children.map(r,o=>h.jsx(Hi,{present:n||s.open,children:h.jsx(F_,{asChild:!0,container:i,children:o})}))})};DM.displayName=Ry;var af="DialogOverlay",OM=g.forwardRef((e,t)=>{const n=LM(af,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,s=Br(af,e.__scopeDialog);return s.modal?h.jsx(Hi,{present:r||s.open,children:h.jsx(DQ,{...i,ref:t})}):null});OM.displayName=af;var LQ=Wc("DialogOverlay.RemoveScroll"),DQ=g.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=Br(af,n);return h.jsx(H_,{as:LQ,allowPinchZoom:!0,shards:[i.contentRef],children:h.jsx(Et.div,{"data-state":Ay(i.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),So="DialogContent",BM=g.forwardRef((e,t)=>{const n=LM(So,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,s=Br(So,e.__scopeDialog);return h.jsx(Hi,{present:r||s.open,children:s.modal?h.jsx(OQ,{...i,ref:t}):h.jsx(BQ,{...i,ref:t})})});BM.displayName=So;var OQ=g.forwardRef((e,t)=>{const n=Br(So,e.__scopeDialog),r=g.useRef(null),i=qt(t,n.contentRef,r);return g.useEffect(()=>{const s=r.current;if(s)return BP(s)},[]),h.jsx(zM,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Pe(e.onCloseAutoFocus,s=>{var o;s.preventDefault(),(o=n.triggerRef.current)==null||o.focus()}),onPointerDownOutside:Pe(e.onPointerDownOutside,s=>{const o=s.detail.originalEvent,a=o.button===0&&o.ctrlKey===!0;(o.button===2||a)&&s.preventDefault()}),onFocusOutside:Pe(e.onFocusOutside,s=>s.preventDefault())})}),BQ=g.forwardRef((e,t)=>{const n=Br(So,e.__scopeDialog),r=g.useRef(!1),i=g.useRef(!1);return h.jsx(zM,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{var o,a;(o=e.onCloseAutoFocus)==null||o.call(e,s),s.defaultPrevented||(r.current||(a=n.triggerRef.current)==null||a.focus(),s.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:s=>{var l,c;(l=e.onInteractOutside)==null||l.call(e,s),s.defaultPrevented||(r.current=!0,s.detail.originalEvent.type==="pointerdown"&&(i.current=!0));const o=s.target;((c=n.triggerRef.current)==null?void 0:c.contains(o))&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&i.current&&s.preventDefault()}})}),zM=g.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:s,...o}=e,a=Br(So,n),l=g.useRef(null),c=qt(t,l);return iP(),h.jsxs(h.Fragment,{children:[h.jsx(M_,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:s,children:h.jsx(Jf,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":Ay(a.open),...o,ref:c,onDismiss:()=>a.onOpenChange(!1)})}),h.jsxs(h.Fragment,{children:[h.jsx(zQ,{titleId:a.titleId}),h.jsx(FQ,{contentRef:l,descriptionId:a.descriptionId})]})]})}),My="DialogTitle",$M=g.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=Br(My,n);return h.jsx(Et.h2,{id:i.titleId,...r,ref:t})});$M.displayName=My;var FM="DialogDescription",HM=g.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=Br(FM,n);return h.jsx(Et.p,{id:i.descriptionId,...r,ref:t})});HM.displayName=FM;var UM="DialogClose",WM=g.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=Br(UM,n);return h.jsx(Et.button,{type:"button",...r,ref:t,onClick:Pe(e.onClick,()=>i.onOpenChange(!1))})});WM.displayName=UM;function Ay(e){return e?"open":"closed"}var VM="DialogTitleWarning",[Uie,qM]=uF(VM,{contentName:So,titleName:My,docsSlug:"dialog"}),zQ=({titleId:e})=>{const t=qM(VM),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
|
|
527
527
|
|
|
528
528
|
If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
529
529
|
|
|
@@ -571,4 +571,4 @@ Make sure your charset is UTF-8`);n=(n>>>8&255)*192+(n&255),e.put(n,13)}};var Bn
|
|
|
571
571
|
The chosen QR Code version cannot contain this amount of data.
|
|
572
572
|
Minimum version required to store current data is: `+s+`.
|
|
573
573
|
`);const o=Qne(t,n,i),a=Tp.getSymbolSize(t),l=new Fne(a);return Kne(l,t),Gne(l),Xne(l,t),fg(l,n,0),t>=7&&Yne(l,t),Zne(l,o),isNaN(r)&&(r=ux.getBestMask(l,fg.bind(null,l,n))),ux.applyMask(r,l),fg(l,n,r),{modules:l,version:t,errorCorrectionLevel:n,maskPattern:r,segments:i}}KA.create=function(t,n){if(typeof t>"u"||t==="")throw new Error("No input text");let r=dg.M,i,s;return typeof n<"u"&&(r=dg.from(n.errorCorrectionLevel,dg.M),i=mf.from(n.version),s=ux.from(n.maskPattern),n.toSJISFunc&&Tp.setToSJISFunction(n.toSJISFunc)),ere(t,i,r,s)};var o5={},Qy={};(function(e){function t(n){if(typeof n=="number"&&(n=n.toString()),typeof n!="string")throw new Error("Color should be defined as hex string");let r=n.slice().replace("#","").split("");if(r.length<3||r.length===5||r.length>8)throw new Error("Invalid hex color: "+n);(r.length===3||r.length===4)&&(r=Array.prototype.concat.apply([],r.map(function(s){return[s,s]}))),r.length===6&&r.push("F","F");const i=parseInt(r.join(""),16);return{r:i>>24&255,g:i>>16&255,b:i>>8&255,a:i&255,hex:"#"+r.slice(0,6).join("")}}e.getOptions=function(r){r||(r={}),r.color||(r.color={});const i=typeof r.margin>"u"||r.margin===null||r.margin<0?4:r.margin,s=r.width&&r.width>=21?r.width:void 0,o=r.scale||4;return{width:s,scale:s?4:o,margin:i,color:{dark:t(r.color.dark||"#000000ff"),light:t(r.color.light||"#ffffffff")},type:r.type,rendererOpts:r.rendererOpts||{}}},e.getScale=function(r,i){return i.width&&i.width>=r+i.margin*2?i.width/(r+i.margin*2):i.scale},e.getImageWidth=function(r,i){const s=e.getScale(r,i);return Math.floor((r+i.margin*2)*s)},e.qrToImageData=function(r,i,s){const o=i.modules.size,a=i.modules.data,l=e.getScale(o,s),c=Math.floor((o+s.margin*2)*l),u=s.margin*l,d=[s.color.light,s.color.dark];for(let f=0;f<c;f++)for(let p=0;p<c;p++){let m=(f*c+p)*4,v=s.color.light;if(f>=u&&p>=u&&f<c-u&&p<c-u){const b=Math.floor((f-u)/l),x=Math.floor((p-u)/l);v=d[a[b*o+x]?1:0]}r[m++]=v.r,r[m++]=v.g,r[m++]=v.b,r[m]=v.a}}})(Qy);(function(e){const t=Qy;function n(i,s,o){i.clearRect(0,0,s.width,s.height),s.style||(s.style={}),s.height=o,s.width=o,s.style.height=o+"px",s.style.width=o+"px"}function r(){try{return document.createElement("canvas")}catch{throw new Error("You need to specify a canvas element")}}e.render=function(s,o,a){let l=a,c=o;typeof l>"u"&&(!o||!o.getContext)&&(l=o,o=void 0),o||(c=r()),l=t.getOptions(l);const u=t.getImageWidth(s.modules.size,l),d=c.getContext("2d"),f=d.createImageData(u,u);return t.qrToImageData(f.data,s,l),n(d,c,u),d.putImageData(f,0,0),c},e.renderToDataURL=function(s,o,a){let l=a;typeof l>"u"&&(!o||!o.getContext)&&(l=o,o=void 0),l||(l={});const c=e.render(s,o,l),u=l.type||"image/png",d=l.rendererOpts||{};return c.toDataURL(u,d.quality)}})(o5);var a5={};const tre=Qy;function kC(e,t){const n=e.a/255,r=t+'="'+e.hex+'"';return n<1?r+" "+t+'-opacity="'+n.toFixed(2).slice(1)+'"':r}function pg(e,t,n){let r=e+t;return typeof n<"u"&&(r+=" "+n),r}function nre(e,t,n){let r="",i=0,s=!1,o=0;for(let a=0;a<e.length;a++){const l=Math.floor(a%t),c=Math.floor(a/t);!l&&!s&&(s=!0),e[a]?(o++,a>0&&l>0&&e[a-1]||(r+=s?pg("M",l+n,.5+c+n):pg("m",i,0),i=0,s=!1),l+1<t&&e[a+1]||(r+=pg("h",o),o=0)):i++}return r}a5.render=function(t,n,r){const i=tre.getOptions(n),s=t.modules.size,o=t.modules.data,a=s+i.margin*2,l=i.color.light.a?"<path "+kC(i.color.light,"fill")+' d="M0 0h'+a+"v"+a+'H0z"/>':"",c="<path "+kC(i.color.dark,"stroke")+' d="'+nre(o,s,i.margin)+'"/>',u='viewBox="0 0 '+a+" "+a+'"',f='<svg xmlns="http://www.w3.org/2000/svg" '+(i.width?'width="'+i.width+'" height="'+i.width+'" ':"")+u+' shape-rendering="crispEdges">'+l+c+`</svg>
|
|
574
|
-
`;return typeof r=="function"&&r(null,f),f};const rre=xne,hx=KA,l5=o5,ire=a5;function Jy(e,t,n,r,i){const s=[].slice.call(arguments,1),o=s.length,a=typeof s[o-1]=="function";if(!a&&!rre())throw new Error("Callback required as last argument");if(a){if(o<2)throw new Error("Too few arguments provided");o===2?(i=n,n=t,t=r=void 0):o===3&&(t.getContext&&typeof i>"u"?(i=r,r=void 0):(i=r,r=n,n=t,t=void 0))}else{if(o<1)throw new Error("Too few arguments provided");return o===1?(n=t,t=r=void 0):o===2&&!t.getContext&&(r=n,n=t,t=void 0),new Promise(function(l,c){try{const u=hx.create(n,r);l(e(u,t,r))}catch(u){c(u)}})}try{const l=hx.create(n,r);i(null,e(l,t,r))}catch(l){i(l)}}Pu.create=hx.create;Pu.toCanvas=Jy.bind(null,l5.render);Pu.toDataURL=Jy.bind(null,l5.renderToDataURL);Pu.toString=Jy.bind(null,function(e,t,n){return ire.render(e,n)});const e1=KM,sre=GM,c5=g.forwardRef(({className:e,...t},n)=>h.jsx(jy,{ref:n,className:ne("fixed inset-0 z-50 bg-black/50 backdrop-blur-sm",e),...t}));c5.displayName=jy.displayName;const Pp=g.forwardRef(({className:e,children:t,...n},r)=>h.jsxs(sre,{children:[h.jsx(c5,{}),h.jsxs(Ly,{ref:r,className:ne("fixed left-1/2 top-1/2 z-50 grid w-full max-w-lg -translate-x-1/2 -translate-y-1/2","gap-4 rounded-lg border border-border bg-elevated p-6 shadow-lg",e),...n,children:[t,h.jsxs(XM,{className:"absolute right-4 top-4 rounded-sm opacity-70 transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-accent",children:[h.jsx(Rn,{className:"h-4 w-4"}),h.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Pp.displayName=Ly.displayName;const Ip=({className:e,...t})=>h.jsx("div",{className:ne("flex flex-col space-y-1.5 text-left",e),...t});Ip.displayName="DialogHeader";const t1=({className:e,...t})=>h.jsx("div",{className:ne("flex flex-row justify-end gap-2",e),...t});t1.displayName="DialogFooter";const Rp=g.forwardRef(({className:e,...t},n)=>h.jsx(Dy,{ref:n,className:ne("text-lg font-semibold leading-none text-text-100",e),...t}));Rp.displayName=Dy.displayName;const u5=g.forwardRef(({className:e,...t},n)=>h.jsx(Oy,{ref:n,className:ne("text-sm text-text-300",e),...t}));u5.displayName=Oy.displayName;function ore({persona:e,open:t,onClose:n,onTogglePublic:r,guestShareUrl:i,onChangeIcon:s,onDelete:o,embedded:a,onLoadPersonality:l,onSavePersonality:c,onDirtyChange:u,initialPersonality:d,onShareCapability:f,readOnly:p=!1,onChangeTool:m,larkBot:v}){const[b,x]=g.useState(!1),[_,y]=g.useState(!1),w=()=>{i&&navigator.clipboard.writeText(i).then(()=>{y(!0),setTimeout(()=>y(!1),2e3)})},S=N=>{x(N),u==null||u(N)},C=()=>{b&&!window.confirm("修改未保存,确定关闭?")||n()};return t?h.jsxs(h.Fragment,{children:[!a&&h.jsx("div",{className:"absolute inset-0 z-30 bg-black/30",onClick:C,"aria-hidden":"true"}),h.jsxs("aside",{className:a?"flex h-full w-full flex-col bg-bg-0":"absolute right-0 top-0 z-40 flex h-full w-[420px] flex-col bg-bg-0 border-l border-border shadow-xl","data-testid":"persona-settings-drawer",children:[h.jsxs("header",{className:"flex items-center justify-between border-b border-border px-4 py-3 shrink-0",children:[h.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[h.jsx(e$,{className:"h-4 w-4 text-text-300"}),h.jsx("span",{className:"text-[13px] font-medium text-text-100 truncate",children:"Persona 设置"})]}),h.jsx("button",{type:"button",onClick:C,"aria-label":"关闭",className:"rounded-sm p-1.5 text-text-400 hover:bg-bg-200 hover:text-text-100",children:h.jsx(Rn,{className:"h-4 w-4"})})]}),h.jsxs("div",{className:"flex-1 overflow-y-auto p-6 flex flex-col gap-4",children:[h.jsxs("header",{className:"flex items-start justify-between gap-3",children:[h.jsxs("div",{className:"flex flex-col gap-0.5 min-w-0",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("h2",{className:"text-lg font-semibold text-text-100 truncate",children:e.label}),e.public?h.jsxs("span",{className:"inline-flex items-center gap-1 rounded-sm bg-bg-200 px-1.5 py-0.5 text-[10px] text-text-200",children:[h.jsx(wz,{className:"h-3 w-3"})," 公开"]}):h.jsxs("span",{className:"inline-flex items-center gap-1 rounded-sm bg-error-dim px-1.5 py-0.5 text-[10px] text-error",children:[h.jsx(yz,{className:"h-3 w-3"})," 已关闭"]})]}),h.jsx("span",{className:"font-mono text-[11px] text-text-400 truncate","data-testid":"persona-id-subtitle",children:e.personaId})]}),h.jsxs("div",{className:"flex items-center gap-1",children:[f?h.jsxs("button",{type:"button",onClick:f,"aria-label":"分享给他人",title:"分享给他人",className:"inline-flex items-center gap-1 rounded-sm px-2 py-1.5 text-xs text-text-200 hover:bg-bg-200 hover:text-text-100",children:[h.jsx(E_,{className:"h-3.5 w-3.5"}),"分享"]}):null,o?h.jsx("button",{type:"button",onClick:o,"aria-label":"删除 persona",className:"rounded-sm p-1.5 text-text-400 hover:bg-bg-200 hover:text-error",children:h.jsx(N_,{className:"h-4 w-4"})}):null]})]}),h.jsx("hr",{className:"border-border"}),r?h.jsxs(h.Fragment,{children:[h.jsxs("section",{className:"flex items-center justify-between gap-3",children:[h.jsxs("div",{className:"flex flex-col gap-0.5",children:[h.jsx("span",{className:"text-[13px] font-medium text-text-100",children:"公开访问"}),h.jsx("span",{className:"text-[11px] text-text-400",children:"开启后这个 persona 才会出现在「邀请联系人」的可选列表里。关闭即拒所有新分享(已颁出的 token 不受影响)。"})]}),h.jsx(dre,{checked:e.public??!1,onChange:N=>r(N)})]}),e.public?h.jsxs("section",{className:"flex flex-col gap-1.5","data-testid":"guest-share-link",children:[h.jsxs("div",{className:"flex items-center gap-1.5",children:[h.jsx(ET,{className:"h-3.5 w-3.5 text-text-400","aria-hidden":!0}),h.jsx("span",{className:"text-[13px] font-medium text-text-100",children:"访客分享链接"})]}),i?h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("input",{readOnly:!0,value:i,onFocus:N=>N.currentTarget.select(),className:"min-w-0 flex-1 truncate rounded border border-border bg-bg-100 px-2 py-1 text-[12px] text-text-200","data-testid":"guest-share-link-input"}),h.jsx("button",{type:"button",onClick:w,className:"flex shrink-0 items-center gap-1 rounded border border-border px-2 py-1 text-[12px] text-text-200 hover:bg-bg-200","data-testid":"guest-share-link-copy",children:_?h.jsxs(h.Fragment,{children:[h.jsx(ol,{className:"h-3 w-3"})," 已复制"]}):h.jsxs(h.Fragment,{children:[h.jsx(mu,{className:"h-3 w-3"})," 复制"]})})]}),h.jsx("span",{className:"text-[11px] text-text-400",children:"任何 TTC 员工打开此链接(飞书登录)即可在该 persona 下交互。"})]}):h.jsx("span",{className:"text-[11px] text-text-400","data-testid":"guest-share-link-no-tunnel",children:"需先开启 tunnel(公网访问)才能生成可分享给外部的链接。"})]}):null,h.jsx("hr",{className:"border-border"})]}):null,v?h.jsxs(h.Fragment,{children:[h.jsx(ure,{...v}),h.jsx("hr",{className:"border-border"})]}):null,s?h.jsxs("section",{className:"flex flex-col gap-1.5",children:[h.jsx("span",{className:"text-[13px] font-medium text-text-100",children:"默认图标"}),h.jsx("span",{className:"text-[11px] text-text-400",children:"新建该 persona 的 session 会默认继承此图标。"}),h.jsx(UI,{value:e.iconKey??null,onChange:s,tool:e.tool})]}):null,s?h.jsx("hr",{className:"border-border"}):null,m&&!p?h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"flex flex-col gap-1.5",children:[h.jsx("span",{className:"text-[12px] font-medium text-text-200",children:"Agent"}),h.jsx("div",{className:"flex gap-2",children:["claude","codex"].map(N=>h.jsx("button",{type:"button","data-testid":`persona-edit-tool-${N}`,onClick:()=>m(N),className:ne("flex-1 rounded-md border px-3 py-2 text-[12px]",(e.tool??"claude")===N?"border-accent bg-accent/10 text-accent":"border-bg-300 text-text-300"),children:N==="claude"?"Claude Code":"Codex"},N))}),h.jsx("span",{className:"text-[11px] text-text-400",children:"切换只影响之后新建的会话,已有会话保持原 tool。"})]}),h.jsx("hr",{className:"border-border"})]}):null,l?h.jsxs(h.Fragment,{children:[h.jsx(mre,{onLoad:l,...c?{onSave:c}:{},onDirtyChange:S,initialPersonality:d,readOnly:p}),h.jsx("hr",{className:"border-border"})]}):null,h.jsx(hre,{settings:e.sandboxSettings??null}),h.jsx("hr",{className:"border-border"}),h.jsx(fre,{skills:e.skills??[]}),h.jsx("hr",{className:"border-border"}),h.jsx(pre,{plugins:e.plugins??[]})]})]})]}):null}function are({qrUrl:e,busy:t,onCancel:n}){const[r,i]=g.useState(null);return g.useEffect(()=>{let s=!1;return Pu.toDataURL(e,{width:240,margin:1}).then(o=>{s||i(o)}).catch(()=>{s||i(null)}),()=>{s=!0}},[e]),h.jsx(e1,{open:!0,onOpenChange:s=>s||n==null?void 0:n(),children:h.jsxs(Pp,{className:"max-w-xs","data-testid":"lark-bot-qr-dialog",onInteractOutside:s=>s.preventDefault(),onEscapeKeyDown:s=>s.preventDefault(),children:[h.jsx(Ip,{children:h.jsx(Rp,{children:"扫码关联飞书 Bot"})}),h.jsxs("div",{className:"flex flex-col items-center gap-2",children:[r?h.jsx("img",{src:r,alt:"飞书扫码创建应用二维码",className:"h-60 w-60 rounded bg-white p-2","data-testid":"lark-bot-qr-img"}):h.jsx("div",{className:"flex h-60 w-60 items-center justify-center text-[12px] text-text-400",children:"二维码生成中…"}),h.jsx("span",{className:"text-center text-[12px] text-text-300",children:"用手机飞书扫码,按页面提示创建应用。确认后自动完成关联。"}),n?h.jsx("button",{type:"button",disabled:t,onClick:n,className:"rounded border border-border px-3 py-1.5 text-[12px] text-text-300 hover:bg-bg-200 disabled:opacity-50","data-testid":"lark-bot-provision-cancel",children:"取消"}):null]})]})})}const lre={expired:"二维码已过期,请重新扫码。",cancelled:"已取消。",access_denied:"你在飞书上取消了本次授权。",lark_protocol_error:"飞书返回了未预期的响应,请重试。",cloud_unreachable:"云端暂时不可达,请稍后重试。",internal_error:"关联失败。若飞书中已创建应用,可在开发者后台删除后重试,或改用手动绑定填入其凭证。"},cre=new Set(["expired","access_denied","lark_protocol_error","cloud_unreachable","internal_error"]);function ure({status:e,onProvision:t,onCancelProvision:n,onBindManual:r,onUnbind:i}){const[s,o]=g.useState(!1),[a,l]=g.useState(null),[c,u]=g.useState(""),[d,f]=g.useState(""),[p,m]=g.useState(null),v=_=>{_&&(o(!0),l(null),_().catch(y=>l(y instanceof Error?y.message:String(y))).finally(()=>o(!1)))},b=()=>{m(null),v(t)},x=h.jsxs("div",{className:"flex items-center gap-1.5",children:[h.jsx(Yf,{className:"h-3.5 w-3.5 text-text-400","aria-hidden":!0}),h.jsx("span",{className:"text-[13px] font-medium text-text-100",children:"飞书 Bot"})]});return e?h.jsxs("section",{className:"flex flex-col gap-1.5","data-testid":"lark-bot-section",children:[x,e.state==="unbound"||e.state==="provisioning"?h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"text-[11px] text-text-400",children:"关联一个飞书 bot 后,这个 persona 就是它:拉进群后群成员 @ 它提问、或直接私聊它, 推理跑在你本机,回复自动发回去。"}),t?h.jsx("button",{type:"button",disabled:s||e.state==="provisioning",onClick:b,className:"self-start rounded border border-border bg-bg-200 px-3 py-1.5 text-[12px] font-medium text-text-100 hover:bg-bg-300 disabled:opacity-50","data-testid":"lark-bot-provision",children:e.state==="provisioning"?"等待扫码…":"扫码关联飞书 Bot"}):null,e.state==="unbound"&&e.errorReason&&!p?h.jsxs("div",{className:"flex flex-col gap-1.5 rounded border border-error bg-error-dim px-2 py-1.5","data-testid":"lark-bot-provision-error",children:[h.jsx("span",{className:"text-[11px] text-error",children:lre[e.errorReason]}),h.jsxs("div",{className:"flex gap-1.5",children:[cre.has(e.errorReason)&&t?h.jsx("button",{type:"button",disabled:s,onClick:b,className:"rounded border border-border px-2 py-1 text-[11px] text-text-100 hover:bg-bg-200 disabled:opacity-50","data-testid":"lark-bot-provision-retry",children:"重新扫码"}):null,h.jsx("button",{type:"button",onClick:()=>m(e.errorReason??null),className:"rounded border border-border px-2 py-1 text-[11px] text-text-300 hover:bg-bg-200","data-testid":"lark-bot-provision-error-dismiss",children:"知道了"})]})]}):null,e.state==="provisioning"&&e.qrUrl?h.jsx(are,{qrUrl:e.qrUrl,busy:s,onCancel:n?()=>v(n):void 0}):null,r&&e.state==="unbound"?h.jsxs("details",{"data-testid":"lark-bot-manual-details",children:[h.jsx("summary",{className:"cursor-pointer text-[11px] text-text-400 hover:text-text-300",children:"已有飞书应用?手动填入凭证"}),h.jsxs("div",{className:"mt-1.5 flex flex-col gap-1.5","data-testid":"lark-bot-manual-form",children:[h.jsx("span",{className:"text-[11px] text-text-400",children:"先在飞书开放平台(open.feishu.cn)创建企业自建应用并启用机器人能力,再填入凭证:"}),h.jsx("input",{value:c,onChange:_=>u(_.target.value),placeholder:"App ID(cli_ 开头)",className:"rounded border border-border bg-bg-100 px-2 py-1 text-[12px] text-text-200","data-testid":"lark-bot-manual-appid"}),h.jsx("input",{value:d,onChange:_=>f(_.target.value),type:"password",placeholder:"App Secret",className:"rounded border border-border bg-bg-100 px-2 py-1 text-[12px] text-text-200","data-testid":"lark-bot-manual-secret"}),h.jsx("button",{type:"button",disabled:s||!c||!d,onClick:()=>v(()=>r({appId:c,appSecret:d})),className:"self-start rounded border border-border px-3 py-1.5 text-[12px] text-text-100 hover:bg-bg-200 disabled:opacity-50","data-testid":"lark-bot-manual-submit",children:s?"绑定中…":"绑定"})]})]}):null]}):null,e.state==="bound"||e.state==="broken"?h.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.state==="broken"?h.jsxs("div",{className:"rounded border border-error bg-error-dim px-2 py-1.5 text-[11px] text-error","data-testid":"lark-bot-broken",children:["Bot 凭证失效:",e.brokenReason??"未知原因","。请解绑后重新填入有效凭证绑定。"]}):null,h.jsxs("div",{className:"flex items-center gap-2 text-[12px] text-text-200",children:[h.jsx("span",{className:"font-medium text-text-100",children:e.botName??"未命名 bot"}),e.appId?h.jsx("span",{className:"text-[11px] text-text-400",children:e.appId}):null]}),h.jsx("span",{className:"text-[11px] text-text-400",children:"把 bot 拉进任意飞书群,群成员 @ 它即可提问。"}),e.groups.length>0?h.jsx("ul",{className:"flex flex-col gap-0.5","data-testid":"lark-bot-groups",children:e.groups.map(_=>h.jsxs("li",{className:"text-[11px] text-text-300 truncate",children:["· ",_.chatName??_.chatId]},_.chatId))}):h.jsx("span",{className:"text-[11px] text-text-400","data-testid":"lark-bot-groups-empty",children:"还没有服务中的群。"}),i?h.jsx("button",{type:"button",disabled:s,onClick:()=>v(i),className:"self-start rounded border border-border px-3 py-1.5 text-[12px] text-error hover:bg-error-dim disabled:opacity-50","data-testid":"lark-bot-unbind",children:"解绑"}):null]}):null,a?h.jsx("div",{className:"rounded border border-error bg-error-dim px-2 py-1.5 text-[11px] text-error","data-testid":"lark-bot-error",children:a}):null]}):h.jsxs("section",{className:"flex flex-col gap-1.5","data-testid":"lark-bot-section",children:[x,h.jsx("span",{className:"text-[11px] text-text-400",children:"状态加载中…"})]})}function dre({checked:e,onChange:t}){return h.jsx("button",{type:"button",role:"switch","aria-checked":e,onClick:()=>t(!e),"data-testid":"persona-public-toggle",className:ne("relative inline-flex h-6 w-11 shrink-0 items-center rounded-full transition-colors",e?"bg-success":"bg-bg-300"),children:h.jsx("span",{className:ne("inline-block h-5 w-5 rounded-full bg-bg-0 shadow transition-transform",e?"translate-x-[22px]":"translate-x-0.5")})})}function hre({settings:e}){var t,n,r,i,s,o,a,l,c,u,d,f,p;return h.jsxs("section",{className:"flex flex-col gap-2","data-testid":"persona-sandbox-setting-section",children:[h.jsxs("header",{className:"flex flex-col gap-0.5",children:[h.jsx("span",{className:"text-[13px] font-medium text-text-100",children:"Sandbox Setting"}),h.jsx("span",{className:"text-[11px] text-text-400",children:"约束此 persona 的沙箱权限(只读,需通过文件修改)。"})]}),e==null?h.jsx("span",{className:"text-[12px] text-text-300","data-testid":"persona-sandbox-setting-empty",children:"暂无 sandbox 配置"}):h.jsxs("div",{className:"flex flex-col gap-1.5 rounded-md border border-border bg-bg-100 px-3 py-2",children:[h.jsx(Id,{label:"权限默认模式",value:((t=e.permissions)==null?void 0:t.defaultMode)??"—"}),h.jsx(Id,{label:"沙箱启用",value:mg((n=e.sandbox)==null?void 0:n.enabled)}),h.jsx(Id,{label:"沙箱内自动放行 Bash",value:mg((r=e.sandbox)==null?void 0:r.autoAllowBashIfSandboxed)}),h.jsx(Id,{label:"允许非沙箱命令",value:mg((i=e.sandbox)==null?void 0:i.allowUnsandboxedCommands)}),h.jsxs("div",{className:"mt-1 flex flex-col gap-1.5 border-t border-border pt-1.5",children:[h.jsx(zl,{label:"沙箱外命令",paths:(s=e.sandbox)==null?void 0:s.excludedCommands}),h.jsx(zl,{label:"允许读取",paths:(a=(o=e.sandbox)==null?void 0:o.filesystem)==null?void 0:a.allowRead}),h.jsx(zl,{label:"拒绝读取",paths:(c=(l=e.sandbox)==null?void 0:l.filesystem)==null?void 0:c.denyRead}),h.jsx(zl,{label:"允许写入",paths:(d=(u=e.sandbox)==null?void 0:u.filesystem)==null?void 0:d.allowWrite}),h.jsx(zl,{label:"拒绝写入",paths:(p=(f=e.sandbox)==null?void 0:f.filesystem)==null?void 0:p.denyWrite})]})]})]})}function mg(e){return e===!0?"是":e===!1?"否":"—"}function Id({label:e,value:t}){return h.jsxs("div",{className:"flex items-center justify-between gap-3 text-[12px]",children:[h.jsx("span",{className:"text-text-300",children:e}),h.jsx("span",{className:"font-mono text-text-100",children:t})]})}function zl({label:e,paths:t}){const n=!t||t.length===0;return h.jsxs("div",{className:"flex flex-col gap-1",children:[h.jsx("span",{className:"text-[11px] text-text-300",children:e}),n?h.jsx("span",{className:"text-[11px] text-text-400",children:"—"}):h.jsx("div",{className:"flex flex-wrap gap-1",children:t.map((r,i)=>h.jsx("span",{className:"rounded-sm border border-border bg-bg-0 px-1.5 py-0.5 font-mono text-[11px] text-text-200",children:r},`${e}-${i}-${r}`))})]})}function fre({skills:e}){return h.jsxs("section",{className:"flex flex-col gap-2","data-testid":"persona-skills-section",children:[h.jsxs("header",{className:"flex flex-col gap-0.5",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:"text-[13px] font-medium text-text-100",children:"Persona Skills"}),h.jsx("span",{className:"rounded-sm border border-border px-1.5 py-0.5 text-[10px] text-text-300",children:e.length})]}),h.jsxs("span",{className:"text-[11px] text-text-400",children:["此 persona 私有 skills(来自"," ",h.jsx("code",{className:"font-mono",children:"<persona-dir>/.claude/skills/"}),")。"]})]}),e.length===0?h.jsx("span",{className:"text-[12px] text-text-300","data-testid":"persona-skills-empty",children:"暂无 skills"}):h.jsx("ul",{className:"flex flex-col divide-y divide-border rounded-md border border-border bg-bg-100",children:e.map(t=>h.jsxs("li",{className:"flex flex-col gap-0.5 px-3 py-2","data-testid":"persona-skill-row",children:[h.jsx("span",{className:"font-mono text-[13px] text-text-100",children:t.name}),t.description?h.jsx("span",{className:"text-[12px] text-text-300",children:t.description}):h.jsx("span",{className:"text-[11px] text-text-400 italic",children:"无描述"})]},t.name))})]})}function pre({plugins:e}){return h.jsxs("section",{className:"flex flex-col gap-2","data-testid":"persona-plugins-section",children:[h.jsxs("header",{className:"flex flex-col gap-0.5",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:"text-[13px] font-medium text-text-100",children:"Enabled Plugins"}),h.jsx("span",{className:"rounded-sm border border-border px-1.5 py-0.5 text-[10px] text-text-300",children:e.length})]}),h.jsxs("span",{className:"text-[11px] text-text-400",children:["此 persona 已启用的插件(来自"," ",h.jsx("code",{className:"font-mono",children:"<persona-dir>/.claude/settings.json"})," ","的 ",h.jsx("code",{className:"font-mono",children:"enabledPlugins"}),")。"]})]}),e.length===0?h.jsx("span",{className:"text-[12px] text-text-300","data-testid":"persona-plugins-empty",children:"暂无启用插件"}):h.jsx("ul",{className:"flex flex-col divide-y divide-border rounded-md border border-border bg-bg-100",children:e.map(t=>h.jsx("li",{className:"flex flex-col gap-0.5 px-3 py-2","data-testid":"persona-plugin-row",children:h.jsx("span",{className:"font-mono text-[13px] text-text-100",children:t.id})},t.id))})]})}function mre({onLoad:e,onSave:t,onDirtyChange:n,initialPersonality:r,readOnly:i=!1}){const s=r!==void 0,[o,a]=g.useState(s),[l,c]=g.useState(s?r:""),[u,d]=g.useState(s?r:""),[f,p]=g.useState(null),[m,v]=g.useState(!1),[b,x]=g.useState(null),_=st.useRef(e),y=st.useRef(t),w=st.useRef(n);st.useEffect(()=>{_.current=e,y.current=t,w.current=n});const S=st.useCallback(()=>{a(!1),p(null),_.current().then(M=>{c(M),d(M),a(!0)}).catch(M=>{p(M instanceof Error?M.message:String(M))})},[]);st.useEffect(()=>{s||S()},[s,S]);const C=!i&&o&&u!==l;st.useEffect(()=>{i||w.current(C)},[C,i]);const N=()=>{y.current&&(v(!0),x(null),y.current(u).then(()=>{c(u),v(!1)}).catch(M=>{x(M instanceof Error?M.message:String(M)),v(!1)}))},T=()=>{d(l),x(null)};return h.jsxs("section",{className:"flex flex-col gap-2","data-testid":"persona-personality-section",children:[h.jsx("span",{className:"text-[12px] font-medium text-text-200",children:"人格 (Personality)"}),f?h.jsxs("div",{"data-testid":"persona-personality-load-error",className:"rounded-md border border-error bg-error-dim px-3 py-2 text-[12px] text-error flex items-center justify-between gap-2",children:[h.jsxs("span",{children:["加载失败:",f]}),h.jsx("button",{type:"button",onClick:S,className:"rounded-sm border border-error px-2 py-0.5 text-[11px] hover:bg-error/10",children:"重试"})]}):null,b?h.jsxs("div",{"data-testid":"persona-personality-save-error",className:"rounded-md border border-error bg-error-dim px-3 py-2 text-[12px] text-error",children:["保存失败:",b]}):null,h.jsx("textarea",{"data-testid":"persona-personality-textarea",value:u,onChange:M=>d(M.target.value),readOnly:i,disabled:!i&&(!o||m),placeholder:o?"":"加载中…",rows:8,className:"min-h-[8rem] max-h-[18rem] resize-y rounded-md border border-border bg-bg-100 px-2 py-1.5 font-mono text-[11px] text-text-100 disabled:opacity-60"}),!i&&h.jsxs("p",{className:"text-[10px] text-text-400",children:["写入到 ",h.jsx("code",{className:"font-mono",children:"<persona-dir>/CLAUDE.md"}),"。 修改只对新启动的 sub-session 生效。"]}),o&&C?h.jsxs("div",{className:"flex justify-end gap-2",children:[h.jsx("button",{type:"button",onClick:T,disabled:m,className:"rounded-sm border border-border px-2 py-1 text-[12px] text-text-200 hover:bg-bg-200 disabled:opacity-60",children:"放弃"}),h.jsx("button",{type:"button",onClick:N,disabled:m,"data-testid":"persona-personality-save-btn",className:"rounded-sm bg-accent-dim px-2 py-1 text-[12px] text-text-100 hover:opacity-90 disabled:opacity-60",children:m?"保存中…":"保存"})]}):null]})}const gre={state:"unbound",groups:[]};function vre(e,t){const[n,r]=g.useState(null);g.useEffect(()=>{if(!e)return;let l=!1;r(null);const c=async()=>{try{const f=await e.request("larkBot:status",{personaId:t});l||r(f)}catch{l||r(gre)}};c();const u=e.on("larkBot:state",f=>{const p=f;if(p.personaId!==t)return;const{personaId:m,...v}=p;r(v)}),d=e.on("daemon:connected",()=>{c()});return()=>{l=!0,u(),d()}},[e,t]);const i=g.useCallback(async()=>{e&&await e.request("larkBot:provision",{personaId:t})},[e,t]),s=g.useCallback(async()=>{e&&await e.request("larkBot:provisionCancel",{personaId:t})},[e,t]),o=g.useCallback(async l=>{e&&await e.request("larkBot:bindManual",{personaId:t,...l})},[e,t]),a=g.useCallback(async()=>{e&&await e.request("larkBot:unbind",{personaId:t})},[e,t]);return{status:n,provision:i,cancelProvision:s,bindManual:o,unbind:a}}function xre({personaId:e,open:t,onClose:n,api:r,embedded:i,onDirtyChange:s,onShareCapability:o,viewerRole:a="owner"}){const{persona:l}=yT(e),c=v6(e),u=x6(),d=_6(),{httpBaseUrl:f}=Xf(),p=$i(),m=vre(a==="guest"?null:p,e),v=g.useMemo(()=>!(l!=null&&l.public)||!f||/^https?:\/\/(127\.0\.0\.1|localhost|0\.0\.0\.0|\[?::1\]?)([:/]|$)/i.test(f)?null:`${f}/s/${e}`,[l==null?void 0:l.public,f,e]),b=g.useCallback(N=>{u(e,{public:N}).catch(T=>{Re("persona","togglePublic failed",T)})},[u,e]),x=g.useCallback(N=>{u(e,{iconKey:N}).catch(T=>{Re("persona","changeIcon failed",T)})},[u,e]),_=g.useCallback(N=>{u(e,{tool:N}).catch(T=>{Re("persona","changeTool failed",T)})},[u,e]),y=g.useCallback(()=>{l&&confirm(`删除 persona "${l.label}"?`)&&(d(e).catch(N=>{Re("persona","delete failed",N)}),n())},[l,d,e,n]),w=g.useCallback(async()=>c.loaded?c.personality:(await c.refresh()).personality,[c]),S=g.useCallback(async N=>{await u(e,{personality:N}),await c.refresh()},[u,e,c]);if(!l)return null;const C=a==="guest";return h.jsx(ore,{embedded:i,persona:{...l,skills:c.skills,plugins:c.plugins,sandboxSettings:c.sandboxSettings},open:t,onClose:n,onLoadPersonality:w,onDirtyChange:s,readOnly:C,...C?{}:{onTogglePublic:b,guestShareUrl:v,onChangeIcon:x,onChangeTool:_,onDelete:y,onSavePersonality:S,larkBot:{status:m.status,onProvision:m.provision,onCancelProvision:m.cancelProvision,onBindManual:m.bindManual,onUnbind:m.unbind},...o?{onShareCapability:o}:{}}})}function _re({api:e,open:t,onOpenChange:n,personaId:r,personaName:i,viewerRole:s}){return t?h.jsxs("div",{"data-testid":"persona-drawer",className:"fixed inset-y-0 right-0 z-50 flex w-[420px] flex-col border-l border-border bg-elevated shadow-2xl",children:[h.jsxs("div",{className:"flex items-center justify-between border-b border-border px-4 py-3",children:[h.jsxs("div",{className:"flex min-w-0 items-center gap-2 text-[13px] font-semibold text-text-100",children:[h.jsx(T_,{className:"h-4 w-4 shrink-0"}),h.jsxs("span",{className:"truncate",title:i,children:["Persona · ",i]})]}),h.jsx("button",{type:"button",onClick:()=>n(!1),className:"flex h-7 w-7 items-center justify-center rounded text-text-400 hover:bg-bg-200 hover:text-text-100","aria-label":"Close drawer",children:h.jsx(Rn,{className:"h-4 w-4"})})]}),h.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:h.jsx(xre,{personaId:r,open:!0,onClose:()=>n(!1),api:e,embedded:!0,...s?{viewerRole:s}:{}},r)})]}):null}function yre(e){try{const t=new URL(e);return t.protocol==="ws:"?t.protocol="http:":t.protocol==="wss:"&&(t.protocol="https:"),`${t.protocol}//${t.host}`}catch{return e}}function bre(e,t){try{const n=new URL(e),r=new URL(t);return n.protocol=r.protocol,n.host=r.host,n.toString()}catch{return e}}async function n1(e,t,n,r,i){const s=await e.attachmentSignUrl({sessionId:n,relPath:r,...i!==void 0?{ttlSeconds:i}:{}});return bre(s.url,yre(t.url))}async function wre(e,t,n,r,i=60){const s=window.open("about:blank","_blank");try{const o=await n1(e,t,n,r,i);s?s.location.href=o:window.open(o,"_blank")}catch(o){throw s&&s.close(),o}}async function Sre(e){var t;try{if((t=navigator.clipboard)!=null&&t.writeText)return await navigator.clipboard.writeText(e),!0}catch{}try{const n=document.createElement("textarea");n.value=e,n.style.position="fixed",n.style.left="-9999px",n.style.top="0",n.setAttribute("readonly",""),document.body.appendChild(n),n.select();const r=document.execCommand("copy");return document.body.removeChild(n),r}catch{return!1}}const kre={...tu,h1:({node:e,...t})=>h.jsx("h1",{...t,className:"mt-4 mb-3 text-[18px] font-semibold leading-tight text-text-100"}),h2:({node:e,...t})=>h.jsx("h2",{...t,className:"mt-4 mb-2 text-[16px] font-semibold leading-tight text-text-100"}),h3:({node:e,...t})=>h.jsx("h3",{...t,className:"mt-3 mb-2 text-[14px] font-semibold leading-tight text-text-100"}),h4:({node:e,...t})=>h.jsx("h4",{...t,className:"mt-3 mb-1 text-[13px] font-semibold text-text-100"}),h5:({node:e,...t})=>h.jsx("h5",{...t,className:"mt-2 mb-1 text-[12px] font-semibold text-text-100"}),h6:({node:e,...t})=>h.jsx("h6",{...t,className:"mt-2 mb-1 text-[12px] font-semibold text-text-300"}),p:({node:e,...t})=>h.jsx("p",{...t,className:"my-2 leading-relaxed"}),ul:({node:e,...t})=>h.jsx("ul",{...t,className:"my-2 list-disc space-y-1 pl-5"}),ol:({node:e,...t})=>h.jsx("ol",{...t,className:"my-2 list-decimal space-y-1 pl-5"}),li:({node:e,...t})=>h.jsx("li",{...t,className:"leading-relaxed"}),blockquote:({node:e,...t})=>h.jsx("blockquote",{...t,className:"my-2 border-l-2 border-border pl-3 italic text-text-300"}),code:({node:e,className:t,children:n,...r})=>t?h.jsx("code",{...r,className:`${t} font-mono text-[12px]`,children:n}):h.jsx("code",{...r,className:"rounded bg-bg-50 px-1 py-0.5 font-mono text-[12px] text-text-100",children:n}),pre:({node:e,...t})=>h.jsx("pre",{...t,className:"my-2 overflow-auto rounded border border-border bg-bg-0 p-3 text-[12px] font-mono text-text-100"}),hr:({node:e,...t})=>h.jsx("hr",{...t,className:"my-3 border-border"}),table:({node:e,...t})=>h.jsx("table",{...t,className:"my-2 w-full border-collapse text-[12px]"}),thead:({node:e,...t})=>h.jsx("thead",{...t,className:"bg-bg-50"}),th:({node:e,...t})=>h.jsx("th",{...t,className:"border border-border px-2 py-1 text-left font-semibold"}),td:({node:e,...t})=>h.jsx("td",{...t,className:"border border-border px-2 py-1"}),strong:({node:e,...t})=>h.jsx("strong",{...t,className:"font-semibold text-text-100"}),em:({node:e,...t})=>h.jsx("em",{...t,className:"italic"})};function Cre(e){const t=e.split("/");return t[t.length-1]||e}function d5({relPath:e,loadMarkdown:t,headerRight:n,showTitleBar:r=!1}){const[i,s]=g.useState(null),[o,a]=g.useState(null),[l,c]=g.useState(!1);return g.useEffect(()=>{if(!e)return;let u=!1;return c(!0),a(null),s(null),(async()=>{try{const d=await t(e);if(u)return;s(d)}catch(d){if(u)return;a(d.message||String(d))}finally{u||c(!1)}})(),()=>{u=!0}},[e,t]),h.jsxs("div",{className:"flex flex-col h-full",children:[r&&e?h.jsxs("div",{className:"flex items-center justify-between border-b border-border px-3 py-2",children:[h.jsx("div",{"data-testid":"md-preview-title",className:"truncate text-[13px] font-medium text-text-100",title:e,children:Cre(e)}),h.jsx("div",{className:"flex items-center gap-1",children:n})]}):null,h.jsx("div",{className:"flex-1 overflow-auto px-4 py-3 text-[13px] text-text-100",children:l?h.jsx("div",{"data-testid":"md-preview-loading",className:"text-text-400",children:"Loading…"}):o?h.jsx("div",{"data-testid":"md-preview-error",className:"text-destructive whitespace-pre-wrap",children:o}):i!==null?h.jsx("div",{"data-testid":"md-preview-content",className:"max-w-none",children:h.jsx(Qc,{remarkPlugins:[eu],components:kre,children:i})}):null})]})}function Ere({open:e,onOpenChange:t,relPath:n,loadMarkdown:r,onShare:i}){return e?h.jsx("div",{"data-testid":"md-preview-drawer",className:"fixed inset-y-0 right-0 z-50 flex w-1/2 max-w-[900px] flex-col border-l border-border bg-elevated shadow-2xl",children:h.jsx(d5,{relPath:n,loadMarkdown:r,showTitleBar:!0,headerRight:h.jsxs(h.Fragment,{children:[i?h.jsx("button",{type:"button","data-testid":"md-preview-share","aria-label":"Share rendered preview link",onClick:i,className:"inline-flex h-6 w-6 items-center justify-center rounded text-text-400 hover:bg-bg-50 hover:text-text-200",children:h.jsx(ET,{className:"h-4 w-4"})}):null,h.jsx("button",{type:"button","aria-label":"Close preview",onClick:()=>t(!1),className:"inline-flex h-6 w-6 items-center justify-center rounded text-text-400 hover:bg-bg-50 hover:text-text-200",children:h.jsx(Rn,{className:"h-4 w-4"})})]})})}):null}function Nre({left:e,right:t,stage:n,onExpand:r,onCollapse:i}){const s=n==="stopped",[o,a]=g.useState(!1);async function l(){if(!o){a(!0);try{await r()}catch{}finally{a(!1)}}}async function c(){if(!o){a(!0);try{await i()}catch{}finally{a(!1)}}}return h.jsxs("div",{className:"flex h-full w-full min-h-0","data-testid":"two-pane-layout",children:[h.jsxs("div",{className:"relative flex min-w-0 flex-1 flex-col","data-testid":"two-pane-left",children:[s&&h.jsx("button",{type:"button",disabled:o,className:"absolute right-14 top-2 z-10 rounded border border-border bg-elevated px-2 py-1 text-[12px] text-text-100 hover:bg-bg-200 disabled:opacity-50 disabled:cursor-not-allowed",onClick:l,children:o?"启动中…":"展开预览"}),e]}),!s&&h.jsxs("div",{className:"flex w-1/2 min-w-[320px] flex-col border-l border-bg-200","data-testid":"two-pane-right",children:[h.jsx("div",{className:"flex items-center justify-end gap-2 border-b border-bg-200 bg-bg-50 px-2 py-1",children:h.jsx("button",{type:"button",disabled:o,className:"rounded px-2 py-1 text-[12px] text-text-300 hover:bg-bg-100 disabled:opacity-50",onClick:c,children:"收起预览"})}),h.jsx("div",{className:"min-h-0 flex-1",children:t})]})]})}const Tre=6173,Pre=6182;function Ire({open:e,onOpenChange:t,projectName:n,currentPort:r,allUsedPorts:i,onUpdate:s}){const o=[];for(let v=Tre;v<=Pre;v++)(v===r||!i.includes(v))&&o.push(v);const[a,l]=g.useState(r),[c,u]=g.useState(!1),[d,f]=g.useState(null),p=a!==r&&!c;async function m(){if(p){u(!0),f(null);try{await s(a),t(!1)}catch(v){f((v==null?void 0:v.message)??String(v))}finally{u(!1)}}}return h.jsx(e1,{open:e,onOpenChange:t,children:h.jsxs(Pp,{className:"max-w-md",children:[h.jsxs(Ip,{children:[h.jsxs(Rp,{children:["改端口 · ",n]}),h.jsxs(u5,{children:["手改通常发生在系统其他进程占了默认分配的端口、dev server 起不来时。 提交后 daemon 会停 dev server → 写 ",h.jsx("code",{className:"mx-1 rounded bg-bg-100 px-1 py-0.5 text-[11px]",children:".clawd-project.json"})," → 用新端口重新起。"]})]}),h.jsxs("div",{className:"flex flex-col gap-2",children:[h.jsx("label",{className:"text-xs text-text-400",children:"新端口(仅显示段内可用 + 当前端口)"}),h.jsx("select",{className:"h-9 rounded-md border border-border bg-elevated px-3 py-1 text-sm text-text-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent",value:a,onChange:v=>l(Number(v.target.value)),disabled:c,children:o.map(v=>h.jsxs("option",{value:v,children:[v,v===r?"(当前)":""]},v))}),o.length===1&&h.jsx("div",{className:"text-[11px] text-text-400",children:"端口段已全被其它 project 占用,没有可换的;先删一个 idle project 释放端口。"}),d&&h.jsx("div",{className:"rounded border border-destructive/30 bg-destructive/5 px-3 py-2 text-[12px] text-destructive",children:d})]}),h.jsxs(t1,{children:[h.jsx(ri,{variant:"ghost",onClick:()=>t(!1),disabled:c,children:"取消"}),h.jsx(ri,{onClick:m,disabled:!p,children:c?"应用中…":"应用新端口"})]})]})})}const CC=[{stage:"build",label:"构建"},{stage:"deploy",label:"部署到阿里云"},{stage:"verify",label:"验证可访问性"}];function Rre({currentStage:e,onCancel:t}){const n=CC.findIndex(r=>r.stage===e);return h.jsxs("div",{"data-testid":"publish-progress",className:"flex items-center gap-3 border-b border-bg-200 bg-bg-50 px-3 py-1.5 text-[12px]",children:[CC.map((r,i)=>{const s=i<n,o=i===n,a=s?"text-text-300":o?"text-text-200":"text-text-500/50";return h.jsxs("span",{className:`flex items-center gap-1 ${a}`,children:[s?h.jsx(Zf,{className:"size-3.5"}):o?h.jsx(rr,{className:"size-3.5 animate-spin"}):h.jsx(ST,{className:"size-3.5"}),h.jsxs("span",{children:[r.label,o?"中…":""]})]},r.stage)}),h.jsx("button",{type:"button",onClick:t,className:"ml-auto rounded px-2 py-0.5 text-[11px] text-text-400 hover:bg-bg-100 hover:text-text-200",children:"取消"})]})}const Mre={build:"构建",deploy:"部署",verify:"验证"};function Are({stage:e,onRetry:t,onDismiss:n}){return h.jsxs("div",{"data-testid":"publish-interrupted-banner",className:"flex items-center gap-2 border-b border-yellow-400/40 bg-yellow-400/10 px-3 py-1.5 text-[12px]",children:[h.jsx(Uc,{className:"size-3.5 text-yellow-500"}),h.jsxs("span",{className:"text-text-200",children:["上次发布在 ",h.jsxs("strong",{className:"font-medium",children:["[",Mre[e],"]"]})," ","阶段被中断(daemon 重启)"]}),h.jsx("button",{type:"button",onClick:t,className:"ml-auto rounded bg-accent-main-100 px-2 py-0.5 text-[11px] text-oncolor-100 hover:opacity-90",children:"重新发布"}),h.jsx("button",{type:"button",onClick:n,className:"rounded px-2 py-0.5 text-[11px] text-text-400 hover:bg-bg-100 hover:text-text-200",children:"取消"})]})}const jre={build:"构建",deploy:"部署",verify:"验证",unknown:"未知"};function Lre({stage:e,onFocusChat:t,onClose:n}){return h.jsxs("div",{"data-testid":"publish-failed-banner",className:"flex items-center gap-2 border-b border-destructive/40 bg-destructive/10 px-3 py-1.5 text-[12px]",children:[h.jsx(Ls,{className:"size-3.5 text-destructive"}),h.jsxs("button",{type:"button",onClick:t,className:"flex-1 text-left text-text-200 hover:underline",children:["发布失败:",h.jsxs("strong",{className:"font-medium",children:["[",jre[e],"]"]})," ","已通知 assistant 接管 →"]}),h.jsx("button",{type:"button",onClick:n,"aria-label":"关闭失败提示",className:"rounded p-0.5 text-text-400 hover:bg-bg-100 hover:text-text-200",children:h.jsx(Rn,{className:"size-3.5"})})]})}const EC={"install-pending":{label:"等装依赖…",step:"1/3"},installing:{label:"安装依赖中…(可能要几十秒到几分钟)",step:"2/3"},"starting-dev-server":{label:"启动 dev server…(等监听端口才挂 iframe)",step:"3/3"}};function Dre({project:e,previewHost:t,previewScheme:n,onUpdatePort:r,allUsedPorts:i,publishSlot:s,publishInFlightStage:o,onDismissPublishJob:a,onRetryPublish:l,publishFailureBanner:c,onPublishFailureBannerClose:u,onPublishFailureBannerFocusChat:d}){var x,_;const[f,p]=g.useState(!1);if(!e)return h.jsx("div",{className:"flex h-full w-full items-center justify-center p-6 text-center text-[13px] text-text-400",children:"未绑定 project"});const m=e.stage??(e.isRunning?"running":"stopped"),v=t?`${n}://${t}/preview/${e.port}/`:null,b=e.prodUrl??null;return h.jsxs("div",{className:"flex h-full w-full flex-col","data-testid":"preview-pane",children:[h.jsxs("header",{className:"flex items-center justify-between gap-2 border-b border-bg-200 bg-bg-50 px-3 py-1.5",children:[h.jsxs("div",{className:"flex items-center gap-2 text-[12px]",children:[h.jsx("span",{className:"font-medium text-text-200",children:e.name}),h.jsx("span",{className:"rounded bg-bg-100 px-1.5 py-0.5 text-[11px] text-text-400",children:e.port}),h.jsx("span",{className:"text-[10px] uppercase tracking-wider text-text-500",children:m==="running"?"dev":m})]}),h.jsxs("div",{className:"flex items-center gap-2",children:[b?h.jsxs("a",{href:b,target:"_blank",rel:"noopener noreferrer",title:`打开线上:${b}`,className:"inline-flex items-center gap-1 rounded border border-bg-200 px-2 py-0.5 text-[11px] text-text-300 hover:bg-bg-100",children:[h.jsx(Hc,{className:"size-3"}),"打开线上"]}):null,s,h.jsxs(RI,{children:[h.jsx(MI,{asChild:!0,children:h.jsx("button",{type:"button","aria-label":"Project settings",className:"rounded p-1 text-text-400 hover:bg-bg-100",children:h.jsx(Qz,{className:"size-3.5"})})}),h.jsxs(Y_,{align:"end",children:[h.jsx(cs,{onSelect:()=>p(!0),children:"Update Port…"}),h.jsxs(cs,{disabled:!0,title:"rename not supported yet",onSelect:y=>y.preventDefault(),children:["Name: ",e.name]})]})]})]})]}),c?h.jsx(Lre,{stage:c.stage,onClose:()=>u==null?void 0:u(),onFocusChat:()=>d==null?void 0:d()}):null,((x=e.publishJob)==null?void 0:x.status)==="in-flight"?h.jsx(Rre,{currentStage:o??e.publishJob.stage,onCancel:()=>void(a==null?void 0:a())}):null,((_=e.publishJob)==null?void 0:_.status)==="interrupted"?h.jsx(Are,{stage:e.publishJob.stage,onRetry:()=>void(l==null?void 0:l()),onDismiss:()=>void(a==null?void 0:a())}):null,h.jsx("div",{className:"min-h-0 flex-1",children:m==="failed"?h.jsx(Ore,{reason:e.stageReason}):m==="stopped"?null:m==="running"?v?h.jsx("iframe",{"data-testid":"preview-iframe",className:"size-full border-0 bg-white",src:v,title:"preview"}):h.jsx(NC,{label:"等 tunnel 起来…",step:"-"}):h.jsx(NC,{label:EC[m].label,step:EC[m].step})}),h.jsx(Ire,{open:f,onOpenChange:p,projectName:e.name,currentPort:e.port,allUsedPorts:i,onUpdate:async y=>{await r(y)}})]})}function NC({label:e,step:t}){return h.jsxs("div",{"data-testid":"preview-spinner",className:"flex h-full w-full flex-col items-center justify-center gap-3 p-6 text-center",children:[h.jsx(rr,{className:"size-6 animate-spin text-accent-main-100"}),h.jsx("div",{className:"text-[13px] text-text-200",children:e}),h.jsx("div",{className:"text-[11px] uppercase tracking-wider text-text-500",children:t}),h.jsx("div",{className:"mt-2 max-w-[300px] text-[11px] text-text-500",children:"左侧 chat 可看 assistant 详细进度"})]})}function Ore({reason:e}){return h.jsxs("div",{"data-testid":"preview-failed",className:"flex h-full w-full flex-col items-center justify-center gap-3 p-6 text-center",children:[h.jsx(Ls,{className:"size-6 text-destructive"}),h.jsx("div",{className:"text-[13px] text-text-200",children:"project 启动失败"}),h.jsx("div",{className:"max-w-[400px] text-[12px] text-text-400",children:e??"未知原因 —— 看 ~/.clawd/clawd.log 排查"}),h.jsx("div",{className:"mt-1 max-w-[300px] text-[11px] text-text-500",children:"左侧 chat 可看 assistant 详细进度 / 跟它说怎么修"})]})}function Bre({error:e,onClose:t}){const[n,r]=g.useState(!1),i=async()=>{var a;if(!e)return;const s=e.message;let o=!1;try{(a=navigator.clipboard)!=null&&a.writeText&&(await navigator.clipboard.writeText(s),o=!0)}catch{o=!1}if(!o){const l=document.createElement("textarea");l.value=s,l.style.position="fixed",l.style.opacity="0",document.body.appendChild(l),l.select();try{document.execCommand("copy"),o=!0}catch{o=!1}finally{document.body.removeChild(l)}}o&&(r(!0),setTimeout(()=>r(!1),1500))};return h.jsx(e1,{open:!!e,onOpenChange:s=>{s||(r(!1),t())},children:h.jsxs(Pp,{className:"max-w-lg",children:[h.jsx(Ip,{children:h.jsx(Rp,{children:(e==null?void 0:e.title)??"错误"})}),h.jsx("pre",{"data-testid":"rpc-error-message",className:"max-h-72 overflow-auto whitespace-pre-wrap break-words rounded border border-bg-200 bg-bg-50 px-3 py-2 text-[12px] text-text-200",children:(e==null?void 0:e.message)??""}),h.jsxs(t1,{children:[h.jsx(ri,{variant:"ghost",onClick:i,className:"gap-1.5",children:n?h.jsxs(h.Fragment,{children:[h.jsx(ol,{className:"size-3.5"}),"已复制"]}):h.jsxs(h.Fragment,{children:[h.jsx(mu,{className:"size-3.5"}),"复制"]})}),h.jsx(ri,{onClick:t,children:"关闭"})]})]})})}function zre(e,t){for(const n of[e,t])if(n)try{const r=new URL(n),i=r.protocol==="https:"||r.protocol==="wss:"?"https":"http";return{host:r.host,scheme:i}}catch{}return{host:null,scheme:"https"}}const $re={codex:"on-request",claude:"bypassPermissions"};function Fre(e){const t={cwd:e.cwd,permissionMode:e.sourcePermissionMode??$re[e.sourceTool??"claude"]??"bypassPermissions",forkedFromSessionId:e.sourceSessionId};return e.sourceOwnerPersonaId&&(t.ownerPersonaId=e.sourceOwnerPersonaId),e.sourceTool&&(t.tool=e.sourceTool),t}async function Hre(e,t,n,r={}){if(!t.toolSessionId)return null;const i=await e.sessionCreate({...Fre({cwd:t.cwd,sourceSessionId:t.sessionId,sourcePermissionMode:t.permissionMode,sourceOwnerPersonaId:t.ownerPersonaId,sourceTool:t.tool}),...r.ephemeral?{ephemeral:!0}:{}});try{const{forkedToolSessionId:s}=await e.sessionFork({cwd:t.cwd,toolSessionId:t.toolSessionId,messageUuid:n,targetCwd:i.cwd});await e.sessionResume(i.sessionId,s)}catch(s){throw e.sessionDelete(i.sessionId).catch(o=>Re("quick-ask","fork rollback failed",o)),s}return i}async function Ure(e,t,n){return Hre(e,t,n,{ephemeral:!0})}function Rd(e){return e!=null&&e.ephemeral!==!1}async function Wre(e,t){return!t.stillEphemeral||!t.nextHold?!1:(await e.sessionUpdate(t.sessionId,{ephemeral:!1}),!0)}const Vre=300;function qre(e){return e&&typeof e=="object"&&"value"in e?e.value:e}function h5(e,t){const n=l_(),[r,i]=g.useState(null),s=g.useRef(null);g.useEffect(()=>{let a=!1;return(async()=>{try{const l=await n.kv.get(e);if(a)return;const c=qre(l);typeof c=="number"&&Number.isFinite(c)&&c>0?i(c):i(t)}catch{a||i(t)}})(),()=>{a=!0}},[n,e,t]);const o=g.useCallback(a=>{s.current&&clearTimeout(s.current),s.current=setTimeout(()=>{s.current=null,n.kv.set(e,a).catch(()=>{})},Vre)},[n,e]);return g.useEffect(()=>()=>{s.current&&(clearTimeout(s.current),s.current=null)},[]),{initialSize:r??t,setSize:o,loading:r===null}}function Kre(){return{quickAsk:null,mds:[],active:null}}function Gre(e,t){return{...e,quickAsk:{sessionId:t.sessionId,ephemeral:!0},active:"quick-ask"}}function Xre(e,t){const n=e.mds.includes(t);return{...e,mds:n?e.mds:[...e.mds,t],active:{kind:"md",relPath:t}}}function Yre(e){if(!e.quickAsk)return e;const t=e.active==="quick-ask",n=e.mds[0],r=t?n?{kind:"md",relPath:n}:null:e.active;return{...e,quickAsk:null,active:r}}function Zre(e){return e.quickAsk?{...e,quickAsk:{...e.quickAsk,ephemeral:!1}}:e}function Qre(e,t){const n=e.mds.indexOf(t);if(n<0)return e;const r=e.mds.filter(l=>l!==t);if(!(e.active!==null&&e.active!=="quick-ask"&&e.active.relPath===t))return{...e,mds:r};const s=r[n],o=n>0?r[n-1]:void 0;let a=null;return s?a={kind:"md",relPath:s}:o?a={kind:"md",relPath:o}:e.quickAsk&&(a="quick-ask"),{...e,mds:r,active:a}}function Jre(e,t){return{...e,active:t}}function eie(e,t){return e===null||t===null||e==="quick-ask"||t==="quick-ask"?e===t:e.relPath===t.relPath}function f5(e){return e.quickAsk!==null||e.mds.length>0}function tie(e){return e.split("/").pop()||e}function nie({state:e,api:t,onSwitchTab:n,onCloseQuickAsk:r,onCloseMd:i,loadMarkdown:s,quickAskSession:o,onToggleHold:a,holdIds:l}){if(!f5(e))return null;const c=[];e.quickAsk&&c.push({id:"quick-ask",label:"问一下",title:"问一下",icon:h.jsx(qh,{className:"w-3.5 h-3.5"})});for(const u of e.mds)c.push({id:{kind:"md",relPath:u},label:tie(u),title:u,icon:h.jsx(Ds,{className:"w-3.5 h-3.5"})});return h.jsxs("div",{className:"flex flex-col h-full bg-bg-0 border-l border-text-100/10",children:[h.jsx(Q_,{delayDuration:200,skipDelayDuration:100,children:h.jsx("div",{className:["flex items-stretch h-9 border-b border-text-100/10 shrink-0 overflow-x-auto","[scrollbar-width:none] [-ms-overflow-style:none]","[&::-webkit-scrollbar]:hidden"].join(" "),role:"tablist",children:c.map(u=>{const d=eie(e.active,u.id),f=u.id==="quick-ask"?"quick-ask":`md:${u.id.relPath}`;return h.jsxs(J_,{children:[h.jsx(ey,{asChild:!0,children:h.jsxs("div",{role:"tab","aria-selected":d,"data-tab-title":u.title,onClick:()=>n(u.id),className:["group relative flex items-center gap-2 px-3 h-full cursor-pointer select-none","text-[12px] max-w-[180px] shrink-0 transition-colors duration-100",d?"text-text-100":"text-text-400 hover:text-text-100 hover:bg-text-100/[0.04]"].join(" "),children:[u.icon,h.jsx("span",{className:"truncate",children:u.label}),h.jsx("button",{type:"button","aria-label":`关闭 ${u.label}`,className:["ml-1 rounded p-0.5 shrink-0 transition-opacity","hover:bg-text-100/10",d?"opacity-70 hover:opacity-100":"opacity-0 group-hover:opacity-70"].join(" "),onClick:p=>{p.stopPropagation(),u.id==="quick-ask"?r():i(u.id.relPath)},children:h.jsx(Rn,{className:"w-3 h-3"})}),d?h.jsx("span",{"aria-hidden":"true",className:"absolute left-2 right-2 -bottom-px h-[2px] rounded-full bg-accent"}):null]})}),h.jsx(hp,{side:"bottom",align:"start",className:"max-w-sm break-all",children:u.title})]},f)})})}),h.jsxs("div",{className:"flex-1 min-h-0 overflow-hidden relative",children:[e.quickAsk&&o?h.jsx("div",{className:"absolute inset-0",style:{display:e.active==="quick-ask"?"block":"none"},children:h.jsx(iie,{session:o,api:t,holdIds:l,...a?{onToggleHold:a}:{}})}):null,e.mds.map(u=>{const d=e.active!==null&&e.active!=="quick-ask"&&e.active.relPath===u;return h.jsx("div",{className:"absolute inset-0",style:{display:d?"block":"none"},children:h.jsx(d5,{relPath:u,loadMarkdown:s,showTitleBar:!1})},`md-body:${u}`)})]})]})}function rie({state:e,extras:t}){const{api:n,session:r,holdIds:i,onToggleHold:s}=t,o=$i(),[a,l]=g.useState(Kre()),c=g.useRef(a);c.current=a;const u=g.useRef(!1),d=g.useCallback(async N=>{const T=c.current.quickAsk,M=await Ure(n,r,N);if(M){if(u.current){n.sessionDelete(M.sessionId).catch(()=>{});return}Rd(T)&&n.sessionDelete(T.sessionId).catch(()=>{}),l(P=>Gre(P,{sessionId:M.sessionId}))}},[n,r]),f=g.useCallback(async(N,T)=>{const M=c.current.quickAsk,P=(M==null?void 0:M.sessionId)===N;try{await Wre(n,{sessionId:N,stillEphemeral:P&&Rd(M),nextHold:T})&&l(R=>Zre(R))}catch(D){Re("quick-ask","promote failed",D);return}s==null||s(N,T)},[n,s]),p=g.useCallback(N=>{l(T=>Xre(T,N))},[]),m=g.useCallback(N=>{l(T=>Jre(T,N))},[]),v=g.useCallback(()=>{const N=c.current.quickAsk;Rd(N)&&n.sessionDelete(N.sessionId).catch(()=>{}),l(T=>Yre(T))},[n]),b=g.useCallback(N=>{l(T=>Qre(T,N))},[]);g.useEffect(()=>()=>{u.current=!0;const N=c.current.quickAsk;Rd(N)&&n.sessionDelete(N.sessionId).catch(()=>{})},[]);const x=oi("sessions")??[],_=a.quickAsk?x.find(N=>N.sessionId===a.quickAsk.sessionId)??{sessionId:a.quickAsk.sessionId,cwd:r.cwd,tool:r.tool}:null,y=g.useCallback(async N=>{const T=await n1(n,o,r.sessionId,N,60),M=await fetch(T);if(!M.ok)throw new Error(`fetch ${M.status} ${M.statusText}`);return M.text()},[n,o,r.sessionId]),w=h.jsx(r1,{state:e,extras:t,onQuickAskInternal:d,onPreviewMdInternal:p}),{initialSize:S,setSize:C}=h5("chat-panel-right-slot-width",480);return f5(a)?h.jsxs(cy,{orientation:"horizontal",className:"flex-1 flex min-w-0 min-h-0",children:[h.jsx(Yc,{id:"chat",minSize:"400px",children:w}),h.jsx(dy,{className:"w-1 bg-text-100/10 hover:bg-text-100/25 transition-colors cursor-col-resize"}),h.jsx(Yc,{id:"right-slot",defaultSize:`${S}px`,minSize:"360px",maxSize:"800px",onResize:N=>C(N.inPixels),children:h.jsx(nie,{state:a,api:n,onSwitchTab:m,onCloseQuickAsk:v,onCloseMd:b,loadMarkdown:y,quickAskSession:_,holdIds:i,onToggleHold:f})})]}):w}function iie({session:e,api:t,holdIds:n,onToggleHold:r}){const i=qA(e.sessionId);return h.jsx(r1,{state:i,extras:{session:e,api:t,holdIds:n,...r?{onToggleHold:r}:{}}})}function sie({extras:e}){const t=qA(e.session.sessionId);if(e.session.appBuilderProject){const n=h.jsx(r1,{state:t,extras:e});return h.jsx(oie,{state:t,chat:n,extras:e})}return h.jsx(rie,{state:t,extras:e})}function oie({state:e,chat:t,extras:n}){var T;const r=oi("daemon-info"),i=$i(),s=n.api,o=n.session,a=o.appBuilderProject,[l,c]=g.useState(null),u=g.useCallback(()=>{s.appBuilderGetProject(o.sessionId).then(M=>c(M.project)).catch(()=>c(null))},[s,o.sessionId]);g.useEffect(()=>{u()},[u]);const[d,f]=g.useState([]),p=g.useCallback(()=>{s.appBuilderListProjects().then(M=>f(M.projects)).catch(()=>f([]))},[s]);g.useEffect(()=>{p()},[p]),g.useEffect(()=>i.on("appBuilder:project-updated",P=>{const D=P;D!=null&&D.project&&(D.project.name===a&&c(D.project),f(R=>{const I=R.findIndex(z=>z.name===D.project.name);if(I<0)return[...R,D.project];const O=R.slice();return O[I]=D.project,O}))}),[i,a]);const{host:m,scheme:v}=zre(i.url,r==null?void 0:r.tunnelUrl),[b,x]=g.useState(void 0),[_,y]=g.useState(null);g.useEffect(()=>{const M=i.on("appBuilder:publish-progress",D=>{const R=D;!R||R.name!==a||R.status==="started"&&x(R.stage)}),P=i.on("appBuilder:publish-failed",D=>{const R=D;!R||R.name!==a||(x(void 0),y({stage:R.stage}))});return()=>{M(),P()}},[i,a]),g.useEffect(()=>{x(void 0),y(null)},[a]);const[w,S]=g.useState(null),C=h.jsx("button",{type:"button",className:"rounded bg-accent-main-100 px-2.5 py-1 text-[12px] text-oncolor-100 hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-50",disabled:((T=l==null?void 0:l.publishJob)==null?void 0:T.status)==="in-flight",onClick:async()=>{try{await s.appBuilderPublish(a)}catch(M){S({title:"发布请求失败",message:(M==null?void 0:M.message)??String(M)})}},children:"发布上线"}),N=(l==null?void 0:l.stage)??(l!=null&&l.isRunning?"running":"stopped");return h.jsxs(h.Fragment,{children:[h.jsx(Nre,{left:t,stage:N,onExpand:async()=>{await s.appBuilderStartDevServer(o.sessionId)},onCollapse:async()=>{await s.appBuilderStopDevServer(o.sessionId)},right:h.jsx(Dre,{project:l,previewHost:m,previewScheme:v,allUsedPorts:d.map(M=>M.port),onUpdatePort:async M=>{await s.appBuilderUpdateProjectPort(a,M),p()},publishSlot:C,publishInFlightStage:b,onDismissPublishJob:async()=>{try{await s.appBuilderDismissPublishJob(a)}catch(M){S({title:"取消发布失败",message:(M==null?void 0:M.message)??String(M)})}},onRetryPublish:async()=>{try{await s.appBuilderPublish(a)}catch(M){S({title:"重新发布失败",message:(M==null?void 0:M.message)??String(M)})}},publishFailureBanner:_,onPublishFailureBannerClose:()=>y(null),onPublishFailureBannerFocusChat:()=>{}})}),h.jsx(Bre,{error:w,onClose:()=>S(null)})]})}function aie({headerMeta:e,connState:t,models:n,liveGitBranch:r,liveWorktreeRoot:i,onOpenConfig:s,onForceStop:o,cronActiveCount:a,onCronClick:l,lines:c,pendingPermissions:u,procAlive:d,rewindableUserMessageIds:f,onPermissionRespond:p,onPermissionInterrupt:m,onRewind:v,onFork:b,onQuickAsk:x,topSlot:_,realtimeQuestionAnswers:y,onSubmitQuestion:w,onCancelQuestion:S,liveQuestionToolUseIds:C,api:N,cwd:T,tool:M,sessionKey:P,onSend:D,awaitingUser:R,onAbort:I,onNewSession:O,onClearSession:z,chatRootRef:$,chatBodyRef:F,topSentinelRef:L,drawers:B,xtermSlot:E,fileSharingScope:H,onShareFile:q,onOpenInTab:A,onPreviewMarkdown:re,onOpenFiles:oe,onTogglePin:V,isHolded:pe,onToggleHold:Oe,personaName:ie,onOpenPersona:Ae}){return h.jsx(PZ,{children:h.jsxs("div",{ref:$,"data-cc-chat-root":"",className:"flex flex-col h-full bg-bg-0",children:[h.jsx(yQ,{meta:e,...M?{tool:M}:{},connState:t,...n?{models:n}:{},...r!==void 0?{liveGitBranch:r}:{},...i!==void 0?{liveWorktreeRoot:i}:{},...s?{onOpenConfig:s}:{},...o?{onForceStop:o}:{},cronActiveCount:a,...l?{onCronClick:l}:{},...oe?{onOpenFiles:oe}:{},...V?{onTogglePin:V}:{},isHolded:pe??!1,...Oe?{onToggleHold:Oe}:{},...ie?{personaName:ie}:{},...Ae?{onOpenPersona:Ae}:{}}),h.jsxs("div",{ref:F,"data-testid":"chat-body",className:"flex-1 overflow-y-auto min-h-0",style:{overflowAnchor:"none"},children:[L?h.jsx("div",{ref:L,"data-testid":"top-sentinel","aria-hidden":"true",style:{height:1}}):null,h.jsx(EM,{lines:c,...p?{onPermissionRespond:p}:{},...m&&d?{onPermissionInterrupt:m}:{},topSlot:_,...v?{onRewind:v}:{},rewindableUserMessageIds:f,...b?{onFork:b}:{},...x?{onQuickAsk:x}:{},realtimeQuestionAnswers:y,onSubmitQuestion:w,...S?{onCancelQuestion:S}:{},liveQuestionToolUseIds:C,...H?{fileSharingScope:H}:{},...q?{onShareFile:q}:{},...A?{onOpenInTab:A}:{},...re?{onPreviewMarkdown:re}:{}})]}),E,e.larkChatName?h.jsx("div",{className:"mx-3 mb-3 rounded-lg border border-border bg-bg-200 px-3 py-2 text-[12px] text-text-400","data-testid":"lark-readonly-notice",children:e.larkChatType==="p2p"?`此会话由与「${e.larkChatName}」的飞书私聊驱动——对方消息触发,这里仅供观察。`:`此会话由飞书群「${e.larkChatName}」驱动——群成员 @ bot 提问触发,这里仅供观察。`}):h.jsx(xQ,{meta:e,...N?{api:N}:{},cwd:T,...M?{tool:M}:{},sessionKey:P,onSend:D,awaitingUser:R,...I?{onAbort:I}:{},...O?{onNewSession:O}:{},...z?{onClearSession:z}:{}}),B]})})}function r1({state:e,extras:t,onQuickAskInternal:n,onPreviewMdInternal:r}){const{session:i,api:s,models:o,liveGitBranch:a,liveWorktreeRoot:l,onNewSession:c,onTurnEnd:u,onOpenConfig:d,onFork:f,onQuickAsk:p,viewerRole:m,holdIds:v,onToggleHold:b}=t,{capabilities:x}=Gy(i.tool||"claude"),_=(x==null?void 0:x.features)??mT(i.tool),[y,w]=g.useState(null),[S,C]=g.useState(!1),[N,T]=g.useState(!1),M=Xf(),P=!!s&&M.actionsLevel==="owner"&&_.fileSharing,D=yT(i.ownerPersonaId??null).persona,R=(D==null?void 0:D.label)??null,I=!!R&&!!i.ownerPersonaId,O=g.useCallback(()=>{T(!1),C(!0)},[]),z=g.useCallback(()=>{C(!1),T(!0)},[]),$=g.useCallback((Z,xe)=>{w({kind:Z,text:xe}),setTimeout(()=>{w(ye=>(ye==null?void 0:ye.text)===xe?null:ye)},2e3)},[]),F=$i(),L=GB(),B=VA(i.sessionId,i.toolSessionId),{events:E,pendingQuestions:H,clearQuestion:q,markQuestionSubmitted:A,status:re}=B,oe=e.historyLoading,V=eA(re);g.useEffect(()=>{Re("chat-panel","sessionStatus",{sessionId:i.sessionId,sessionStatus:re,procAlive:V})},[re,V,i.sessionId]);const pe=e.lines,Oe=e.pendingPermissions,ie=Oe[0]??null,Ae=g.useMemo(()=>LU(E),[E]),[Fe,We]=g.useState(!1),[ge,qe]=g.useState(null),[Gt,wt]=g.useState(()=>new Set);MU(s,i.sessionId,i.toolSessionId,_.observe);const Rt=g.useRef(i.sessionId);g.useEffect(()=>{if(Rt.current=i.sessionId,!_.rewind){qe(null);return}let Z=!1;return qe(null),(async()=>{try{const xe=await s.sessionRewindableMessageIds(i.sessionId);if(Z)return;qe(new Set(xe.userMessageIds))}catch{Z||qe(null)}})(),()=>{Z=!0}},[s,i.sessionId,_.rewind]);const ln=g.useCallback(()=>{const Z=i.sessionId;s.sessionRewindableMessageIds(Z).then(xe=>{Rt.current===Z&&qe(new Set(xe.userMessageIds))}).catch(()=>{})},[s,i.sessionId]),Bt=g.useMemo(()=>{if(ge!==null){const Ze=new Set(ge);for(const pi of Gt)Ze.delete(pi);return Ze}const Z=new Set(["Edit","Write","MultiEdit","NotebookEdit"]),xe=new Set;let ye=null;for(const Ze of pe)Ze.kind==="user-text"?ye=Ze.uuid??null:ye&&Ze.kind==="tool-call"&&Z.has(Ze.tool)&&!Gt.has(ye)&&xe.add(ye);return xe},[pe,Gt,ge]),at=g.useRef(u);at.current=u,AU(i.sessionId,i.toolSessionId,()=>{pn(null),wt(new Set)});const Ue=KQ({sessionStatus:re}),nt=g.useRef(null);g.useEffect(()=>{var ye;const Z=nt.current,xe=(Z==null?void 0:Z.sid)===i.sessionId;xe&&Z.phase===Ue||(nt.current={sid:i.sessionId,phase:Ue},Re("session-phase",Ue,{sid:i.sessionId,phase:Ue,prev:xe?Z.phase:null,desc:qQ[Ue]}),xe&&Z.phase==="turn-running"&&Ue!=="turn-running"&&((ye=at.current)==null||ye.call(at),ln()))},[Ue,i.sessionId,ln]);const mt=g.useCallback(()=>{s.sessionInterrupt(i.sessionId).catch(()=>{})},[s,i.sessionId]),[Xt,pn]=g.useState(null),U=g.useCallback(Z=>{pn(Z)},[]),[Q,ve]=g.useState(!1),Se=g.useCallback(()=>{s.sessionStop(i.sessionId).catch(()=>{}),ve(!1)},[s,i.sessionId]),J=g.useCallback(Z=>{s.pinSession(i.sessionId,Z).catch(xe=>{Re("chat-panel","pinSession failed",{err:xe==null?void 0:xe.message})})},[s,i.sessionId]),Ye=(v==null?void 0:v.has(i.sessionId))??!1,Yt=g.useCallback(Z=>{b==null||b(i.sessionId,Z)},[b,i.sessionId]),Zt=g.useRef(0),ue=g.useRef(null);g.useEffect(()=>{const Z=xe=>{if(xe.key!=="Escape")return;if(!V){Zt.current=0;return}if(xe.isComposing)return;const Ze=xe.target;if(Ze&&Ze.closest("[data-cc-chat-root]")!==ue.current)return;const pi=Date.now();pi-Zt.current<2e3?(Zt.current=0,ve(!0)):(Zt.current=pi,mt())};return window.addEventListener("keydown",Z),()=>window.removeEventListener("keydown",Z)},[mt,V]);const Te=g.useRef(null),Je=g.useRef(null),Ln=g.useRef(!0),Qt=g.useRef(null),fl=g.useRef(0),Bo=g.useRef(0);g.useEffect(()=>{Ln.current=!0,Qt.current=null,fl.current=0,Bo.current=0},[i.sessionId]),g.useEffect(()=>{We(!1)},[i.sessionId]);const Ru=g.useRef(e);Ru.current=e;const Mu=g.useCallback(()=>{var ye;const Z=Te.current;if(!Z||Qt.current!==null)return;const xe=Ru.current;xe.historyDone||xe.historyLoading||(Qt.current={distFromBottom:Z.scrollHeight-Z.scrollTop},(ye=xe.loadMoreHistory)==null||ye.call(xe))},[]);g.useEffect(()=>{const Z=Te.current,xe=Je.current;if(!Z||!xe)return;const ye=new IntersectionObserver(Ze=>{for(const pi of Ze)pi.isIntersecting&&Mu()},{root:Z,threshold:0});return ye.observe(xe),()=>ye.disconnect()},[Mu]),g.useEffect(()=>{const Z=Te.current;if(!Z)return;const xe=150,ye=Ze=>{Date.now()<Bo.current&&(Ze.preventDefault(),Bo.current=Date.now()+xe)};return Z.addEventListener("wheel",ye,{passive:!1}),()=>Z.removeEventListener("wheel",ye)},[]),g.useEffect(()=>{const Z=Te.current;if(!Z)return;const xe=32,ye=()=>{const Ze=Z.scrollHeight-Z.scrollTop-Z.clientHeight;Ln.current=Ze<=xe};return Z.addEventListener("scroll",ye,{passive:!0}),()=>Z.removeEventListener("scroll",ye)},[]),g.useLayoutEffect(()=>{const Z=Te.current;if(!Z)return;const xe=fl.current,ye=pe.length;fl.current=ye;const Ze=Qt.current;if(Ze!==null&&ye>xe){Qt.current=null,Z.scrollTop=Z.scrollHeight-Ze.distFromBottom,Bo.current=Date.now()+200;return}Ze!==null&&(Qt.current={distFromBottom:Z.scrollHeight-Z.scrollTop}),Ln.current&&(Z.scrollTop=Z.scrollHeight)},[pe,ie==null?void 0:ie.requestId]);const Mp=g.useMemo(()=>{const Z={};for(const[xe,ye]of Object.entries(H))ye.submittedAnswers&&(Z[xe]=ye.submittedAnswers);return Z},[H]),Ap=g.useMemo(()=>new Set(Object.keys(H)),[H]),Au=g.useCallback(async(Z,xe)=>{try{await s.answerQuestion({sessionId:i.sessionId,toolUseId:Z,answers:xe}),A(Z,xe)}catch{}},[s,i.sessionId,A]),zo=g.useCallback(async Z=>{try{await s.cancelQuestion({sessionId:i.sessionId,toolUseId:Z}),q(Z)}catch{}},[s,i.sessionId,q]),$o=g.useCallback(async(Z,xe)=>{var ye;if(ie)try{await((ye=e.respondPermission)==null?void 0:ye.call(e,ie.requestId,Z?"allow":"deny"))}catch{}},[e,ie]),pl=g.useCallback(async()=>{const Z=i.sessionId;try{await s.sessionStop(Z)}catch{}e.clearSession?await e.clearSession():await s.sessionNew(Z)},[e,s,i.sessionId]),ml=g.useMemo(()=>oe&&pe.length===0?h.jsx("div",{className:"flex justify-center py-4","data-testid":"history-loading",children:h.jsx(rr,{className:"w-4 h-4 text-text-400 animate-spin"})}):e.historyDone?null:h.jsx("div",{className:"flex justify-center py-2",children:h.jsx("button",{type:"button",onClick:()=>{var Z;return void((Z=e.loadMoreHistory)==null?void 0:Z.call(e))},disabled:oe,"data-testid":"history-load-more",className:"text-[12px] text-text-400 hover:text-text-200 cursor-pointer px-3 py-1 rounded-md border border-bg-300 hover:bg-bg-100 transition-colors disabled:opacity-60",children:oe?"加载中…":"Load earlier messages"})}),[oe,pe.length,e.historyDone,e.loadMoreHistory]),qi=e.meta,Ki=h.jsxs(h.Fragment,{children:[i.toolSessionId&&_.subagents?h.jsx(EQ,{api:s,cwd:i.cwd,toolSessionId:i.toolSessionId}):null,Xt&&_.rewind?h.jsx(TQ,{open:!0,onOpenChange:Z=>{Z||pn(null)},api:s,sessionId:i.sessionId,userMessageId:Xt,lines:pe,procAlive:V,onNoChanges:Z=>{wt(xe=>{if(xe.has(Z))return xe;const ye=new Set(xe);return ye.add(Z),ye})}}):null,Q?h.jsx(lie,{onConfirm:Se,onCancel:()=>ve(!1)}):null,h.jsx(VQ,{open:Fe,onClose:()=>We(!1),jobs:Ae})]}),gl={kind:"session",sessionId:i.sessionId},ju=g.useCallback(async Z=>{if(s)try{await wre(s,F,i.sessionId,Z)}catch(xe){const ye=xe.message;Re("chat-panel","open-in-tab failed",{err:ye}),$("err",`Open in tab 失败:${ye}`)}},[s,F,i.sessionId,$]),[zt,vl]=g.useState(!1),[xl,Tt]=g.useState(null),$t=g.useCallback(Z=>{if(r){r(Z);return}Tt(Z),vl(!0)},[r]),ar=g.useCallback(async Z=>{if(!s)throw new Error("daemon api not ready");const xe=await n1(s,F,i.sessionId,Z,60),ye=await fetch(xe);if(!ye.ok)throw new Error(`fetch ${ye.status} ${ye.statusText}`);return await ye.text()},[s,F,i.sessionId]),Dn=g.useCallback(async(Z,xe)=>{if(s)try{const{url:ye}=await s.attachmentSignUrl({sessionId:i.sessionId,relPath:Z,ttlSeconds:86400,...xe?{view:xe}:{}}),Ze=await Sre(ye);$(Ze?"ok":"err",Ze?"分享链接已复制到剪贴板(24h 有效)":"复制失败:请手动复制")}catch(ye){const Ze=ye.message;Re("chat-panel","share-file failed",{err:Ze}),$("err",`生成分享链接失败:${Ze}`)}},[s,i.sessionId,$]);return h.jsxs(h.Fragment,{children:[h.jsx(aie,{headerMeta:qi,connState:e.connState,...o?{models:o}:{},...a!==void 0?{liveGitBranch:a}:{},...l!==void 0?{liveWorktreeRoot:l}:{},...d?{onOpenConfig:d}:{},onForceStop:()=>ve(!0),cronActiveCount:Ae.length,onCronClick:()=>We(!0),lines:pe,pendingPermissions:Oe,procAlive:V,rewindableUserMessageIds:Bt,onPermissionRespond:$o,onPermissionInterrupt:mt,onRewind:_.rewind?U:void 0,...f&&_.fork?{onFork:f}:{},...n&&_.fork?{onQuickAsk:n}:p&&_.fork?{onQuickAsk:p}:{},topSlot:ml,realtimeQuestionAnswers:Mp,onSubmitQuestion:Au,onCancelQuestion:zo,liveQuestionToolUseIds:Ap,api:s,cwd:i.cwd,...i.tool?{tool:i.tool}:{},sessionKey:i.sessionId,onSend:e.sendText,awaitingUser:Oe.length>0||Object.values(H).some(Z=>!Z.submittedAnswers),onAbort:mt,...c?{onNewSession:c}:{},onClearSession:pl,chatRootRef:ue,chatBodyRef:Te,topSentinelRef:Je,drawers:Ki,xtermSlot:L==="tui"&&V&&_.tui?h.jsx(ane,{sessionId:i.sessionId,client:F},i.sessionId):null,fileSharingScope:gl,...s?{onShareFile:Dn}:{},...s?{onOpenInTab:ju}:{},...s?{onPreviewMarkdown:$t}:{},...P?{onOpenFiles:O}:{},onTogglePin:J,isHolded:Ye,...b?{onToggleHold:Yt}:{},...I?{personaName:R}:{},...I?{onOpenPersona:z}:{}}),P&&s?h.jsx(fne,{api:s,open:S,onOpenChange:C,scope:gl,sessionId:i.sessionId,onShareFile:Dn,onOpenInTab:ju}):null,s?h.jsx(Ere,{open:zt,onOpenChange:vl,relPath:xl,loadMarkdown:ar,onShare:xl?()=>void Dn(xl,"md-rendered"):void 0}):null,I&&s&&i.ownerPersonaId?h.jsx(_re,{api:s,open:N,onOpenChange:T,personaId:i.ownerPersonaId,personaName:R??"",...m?{viewerRole:m}:{}}):null,y?h.jsx("div",{"data-testid":"share-toast",role:"status","aria-live":"polite",className:y.kind==="ok"?"fixed left-1/2 top-4 z-50 -translate-x-1/2 rounded-md border border-emerald-500/40 bg-emerald-500/10 px-3 py-2 text-[12px] text-emerald-700 shadow-md dark:text-emerald-300":"fixed left-1/2 top-4 z-50 -translate-x-1/2 rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-[12px] text-destructive shadow-md",children:y.text}):null]})}function lie({onConfirm:e,onCancel:t}){return h.jsx("div",{role:"dialog","aria-modal":"true","data-testid":"force-stop-confirm",className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40",onClick:t,children:h.jsxs("div",{className:"max-w-sm w-[92%] rounded-lg border border-red-400/40 bg-bg-0 p-4 shadow-xl",onClick:n=>n.stopPropagation(),children:[h.jsxs("div",{className:"flex items-start gap-2 mb-3",children:[h.jsx(Uc,{className:"w-5 h-5 text-red-500 shrink-0 mt-0.5"}),h.jsx("div",{className:"text-[14px] text-text-100",children:"强制停止会话进程?会丢失 initialize / 预热缓存,下一次发送需要重新 spawn。"})]}),h.jsxs("div",{className:"flex justify-end gap-2",children:[h.jsx("button",{type:"button",onClick:t,className:"h-8 px-3 rounded-md text-[12px] text-text-300 hover:bg-text-100/5 cursor-pointer",children:"取消"}),h.jsx("button",{type:"button","data-testid":"force-stop-confirm-ok",onClick:e,className:"h-8 px-3 rounded-md bg-red-500 text-white text-[12px] font-medium hover:bg-red-600 cursor-pointer",children:"强制停止"})]})]})})}function cie(e,t,n){const r=e?t.find(s=>s.id===e):void 0;if(r!=null&&r.efforts&&r.efforts.length>0)return{options:r.efforts,defaultValue:r.defaultEffort??""};const i=n.find(s=>s.name==="effort");return{options:(i==null?void 0:i.options)??[],defaultValue:typeof(i==null?void 0:i.default)=="string"?i.default:""}}function uie({current:e,models:t,onSelect:n}){return h.jsxs("div",{children:[h.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider text-text-400/70 mb-2",children:"Model"}),h.jsx("div",{className:"flex flex-wrap gap-1.5","data-testid":"config-model-selector",children:t.map(r=>{const i=(e||"")===r.id;return h.jsx("button",{type:"button",onClick:()=>n(r.id),"data-testid":`config-model-${r.id||"default"}`,className:ne("px-3 py-1.5 rounded-lg text-[12px] font-medium transition-colors cursor-pointer",i?"bg-accent text-white shadow-sm":"bg-bg-100 text-text-300 hover:bg-bg-200 hover:text-text-100"),children:r.label},r.id||"default")})})]})}function die({current:e,modes:t,onSelect:n}){var i;const r=(i=t.find(s=>s.id===(e||"")))==null?void 0:i.description;return h.jsxs("div",{children:[h.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider text-text-400/70 mb-2",children:"Permission Mode"}),h.jsx("div",{className:"flex flex-wrap gap-1.5","data-testid":"config-mode-selector",children:t.map(s=>{const o=(e||"")===s.id;return h.jsx("button",{type:"button",onClick:()=>n(s.id),"data-testid":`config-mode-${s.id||"default"}`,className:ne("px-3 py-1.5 rounded-lg text-[12px] font-medium transition-colors cursor-pointer",o?"bg-accent text-white shadow-sm":"bg-bg-100 text-text-300 hover:bg-bg-200 hover:text-text-100"),children:s.label},s.id||"default")})}),r?h.jsx("p",{className:"text-[11px] text-text-400 mt-1.5",children:r}):null]})}function hie({open:e,onOpenChange:t,session:n,onPatch:r,embedded:i=!1,viewerRole:s="owner"}){var m;const{capabilities:o}=Gy(e?n.tool||"claude":null),a=(o==null?void 0:o.models)??[],l=(o==null?void 0:o.permissionModes)??[],c=((m=o==null?void 0:o.configSchema.find(v=>v.name==="permissionMode"))==null?void 0:m.default)??"",u=n.permissionMode&&l.some(v=>v.id===n.permissionMode)?n.permissionMode:c,d=g.useMemo(()=>(o==null?void 0:o.configSchema.filter(v=>v.scope==="tool-specific"))??[],[o]),f=(o==null?void 0:o.toolSessionIdLabel)??"Tool Session ID";if(!e)return null;const p=h.jsxs("div",{className:"flex-1 min-h-0 flex flex-col px-4 py-4 gap-6 overflow-y-auto",children:[h.jsxs("div",{className:"shrink-0",children:[h.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider text-text-400/70 mb-1",children:"Working Directory"}),h.jsx("div",{className:"text-[12px] font-mono text-text-300 bg-bg-100 rounded-lg px-3 py-2 truncate","data-testid":"config-cwd",title:n.cwd,children:n.cwd})]}),h.jsx("div",{className:"shrink-0",children:h.jsx(uie,{current:n.model??"",models:a,onSelect:v=>void r({model:v})})}),h.jsx("div",{className:"shrink-0",children:h.jsx(die,{current:u,modes:l,onSelect:v=>void r({permissionMode:v})})}),d.length>0?h.jsx("div",{className:"shrink-0",children:h.jsx(fie,{fields:d,models:a,session:n,onPatch:r})}):null,h.jsx("div",{className:"shrink-0",children:h.jsx(TC,{testId:"config-session-id",label:"Clawd Session ID",value:n.sessionId})}),n.toolSessionId?h.jsx("div",{className:"shrink-0",children:h.jsx(TC,{testId:"config-tool-session-id",label:f,value:n.toolSessionId})}):null]});return i?h.jsxs("div",{"data-testid":"config-drawer",className:"h-full w-full flex flex-col",children:[h.jsx("div",{className:"flex items-center px-4 py-3 border-b border-bg-300/30 shrink-0",children:h.jsx("span",{className:"text-[14px] font-semibold text-text-100",children:"Session Settings"})}),p]}):h.jsxs("div",{"data-testid":"config-drawer",className:"h-full w-full flex flex-col border-l border-bg-300/40 bg-bg-0 min-w-0",children:[h.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-bg-300/30 shrink-0",children:[h.jsx("span",{className:"text-[14px] font-semibold text-text-100",children:"Session Settings"}),h.jsx("button",{type:"button",onClick:()=>t(!1),"data-testid":"config-drawer-close",className:"flex items-center justify-center w-7 h-7 rounded-md text-text-400 hover:text-text-100 hover:bg-text-100/5 transition-colors cursor-pointer","aria-label":"Close",children:h.jsx(Rn,{className:"w-4 h-4"})})]}),p]})}function TC({testId:e,label:t,value:n}){const[r,i]=g.useState(!1),s=g.useRef(null);g.useEffect(()=>()=>{s.current&&clearTimeout(s.current)},[]);const o=()=>{typeof navigator>"u"||!navigator.clipboard||navigator.clipboard.writeText(n).then(()=>{i(!0),s.current&&clearTimeout(s.current),s.current=setTimeout(()=>i(!1),2e3)},()=>{})};return h.jsxs("div",{"data-testid":e,children:[h.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider text-text-400/70 mb-1",children:t}),h.jsxs("button",{type:"button",onClick:o,"data-testid":`${e}-copy`,title:r?"Copied":`Copy: ${n}`,className:"w-full flex items-center gap-2 text-[12px] font-mono text-text-300 bg-bg-100 hover:bg-bg-200 rounded-lg px-3 py-2 transition-colors cursor-pointer text-left group",children:[h.jsx("span",{className:"truncate flex-1 min-w-0","data-testid":`${e}-value`,children:n}),r?h.jsx(ol,{className:"w-3.5 h-3.5 shrink-0 text-accent"}):h.jsx(mu,{className:"w-3.5 h-3.5 shrink-0 opacity-60 group-hover:opacity-100 transition-opacity"})]})]})}function fie({fields:e,models:t,session:n,onPatch:r}){return h.jsxs("div",{"data-testid":"config-advanced",children:[h.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider text-text-400/70 mb-2",children:"Advanced"}),h.jsx("div",{className:"space-y-3",children:e.map(i=>h.jsx(pie,{field:i,models:t,session:n,onPatch:r},i.name))})]})}function pie({field:e,models:t,session:n,onPatch:r}){const i=e.name==="effort"?cie(n.model??"",t,[e]):{options:e.options??[],defaultValue:e.default??""},s=i.options;if(e.type!=="select"||s.length===0)return null;const o=n[e.name]??"",a=s.some(l=>l.value===o)?o:i.defaultValue;return h.jsxs("div",{"data-testid":`config-advanced-${e.name}`,children:[h.jsx("div",{className:"text-[11px] text-text-400 mb-1.5",children:e.label}),h.jsx("div",{className:"flex flex-wrap gap-1.5",children:s.map(l=>{const c=a===l.value;return h.jsx("button",{type:"button","data-testid":`config-advanced-${e.name}-${l.value||"default"}`,onClick:()=>void r({[e.name]:l.value}),className:ne("px-3 py-1.5 rounded-lg text-[12px] font-medium transition-colors cursor-pointer",c?"bg-accent text-white shadow-sm":"bg-bg-100 text-text-300 hover:bg-bg-200 hover:text-text-100"),children:l.label},l.value||"default")})})]})}function mie(e,t,n=0){const[r,i]=g.useState(null),[s,o]=g.useState(!1),a=g.useCallback(async()=>{if(!t){i(null);return}o(!0);try{const l=await e.getGitBranch(t);i(l.branch??null)}catch{i(null)}finally{o(!1)}},[e,t]);return g.useEffect(()=>{a()},[a,n]),{branch:r,loading:s,refresh:()=>void a()}}function gie(e,t,n=0){const[r,i]=g.useState(null),[s,o]=g.useState(!1),a=g.useCallback(async()=>{if(!t){i(null);return}o(!0);try{const l=await e.getGitRoot(t);i(l.gitRoot??null)}catch{i(null)}finally{o(!1)}},[e,t]);return g.useEffect(()=>{a()},[a,n]),{worktreeRoot:r,loading:s,refresh:()=>void a()}}function vie({api:e,session:t,focused:n,totalPanes:r,onFocus:i,onClose:s,onNewSession:o,onOpenConfig:a,onConfigPatch:l,onFork:c,onQuickAsk:u,className:d,viewerRole:f="owner",holdIds:p,onToggleHold:m}){const{capabilities:v}=Gy(t.tool),[b,x]=g.useState(0),[_,y]=g.useState(!1),{initialSize:w,setSize:S}=h5("clawd:panel:config-px",360),{branch:C}=mie(e,t.cwd,b),{worktreeRoot:N}=gie(e,t.cwd,b),T=r>1,M=P=>{P==="desktop"?y(!0):a()};return h.jsxs("div",{className:`group/pane relative flex-1 ${d??"flex"} flex-row min-w-0 min-h-0 overflow-hidden ${T?`rounded-md border transition-colors ${n?"border-accent ring-1 ring-accent":"border-border"}`:""}`,onMouseDown:i,"data-testid":`session-pane-${t.sessionId}`,children:[h.jsxs(cy,{orientation:"horizontal",className:"flex-1 flex min-w-0 min-h-0",children:[h.jsx(Yc,{id:"chat",minSize:"400px",children:h.jsx("div",{className:"flex flex-col min-w-0 min-h-0 h-full",children:h.jsx(xie,{api:e,session:t,models:v==null?void 0:v.models,liveGitBranch:C,liveWorktreeRoot:N,onNewSession:o,onTurnEnd:()=>x(P=>P+1),onOpenConfig:M,onFork:c,onQuickAsk:u,viewerRole:f,holdIds:p,onToggleHold:m})})}),_&&h.jsxs(h.Fragment,{children:[h.jsx(dy,{className:"hidden md:block w-1 bg-text-100/10 hover:bg-text-100/25 transition-colors cursor-col-resize"}),h.jsx(Yc,{id:"config",defaultSize:`${w}px`,minSize:"360px",maxSize:"560px",onResize:P=>S(P.inPixels),children:h.jsx("div",{className:"hidden md:flex h-full",children:h.jsx(hie,{open:_,onOpenChange:y,session:t,onPatch:l,viewerRole:f})})})]})]}),T&&h.jsx("button",{type:"button",onClick:P=>{P.stopPropagation(),s()},className:"absolute top-1.5 right-1.5 z-10 p-1 rounded-md bg-bg-100/80 backdrop-blur-sm border border-border opacity-0 group-hover/pane:opacity-100 transition-opacity text-text-400 hover:text-text-100 hover:bg-bg-200","aria-label":"close pane","data-testid":`session-pane-close-${t.sessionId}`,children:h.jsx(Rn,{className:"w-3.5 h-3.5"})})]})}function xie({api:e,session:t,models:n,liveGitBranch:r,liveWorktreeRoot:i,onNewSession:s,onTurnEnd:o,onOpenConfig:a,onFork:l,onQuickAsk:c,viewerRole:u,holdIds:d,onToggleHold:f}){return h.jsx(sie,{extras:{session:t,api:e,...n?{models:n}:{},...r!==void 0?{liveGitBranch:r}:{},...i!==void 0?{liveWorktreeRoot:i}:{},onNewSession:s,onTurnEnd:o,onOpenConfig:a,...l?{onFork:p=>{l(p)}}:{},...c?{onQuickAsk:p=>{c(p)}}:{},...u?{viewerRole:u}:{},...d?{holdIds:d}:{},...f?{onToggleHold:f}:{}}})}function _ie({personas:e,sessions:t,api:n,selfPrincipalId:r,selectedPersonaId:i,selectedSessionId:s,selectedSession:o,onSelectPersona:a,onSelectSession:l,onCreateSession:c,onDeleteSession:u,onEditSession:d,onCloseSession:f,onConfigPatch:p}){return h.jsxs("div",{className:"flex h-screen min-h-0 bg-bg-50","data-testid":"guest-share-page",children:[h.jsx("aside",{className:"w-[280px] shrink-0 overflow-y-auto border-r border-border bg-bg-50",children:h.jsx(YH,{personas:e,sessions:t,activePersonaId:i,activeSessionId:s,onSelectPersona:a,onSelectSession:l,onCreateSession:c,onDeleteSession:u,onEditSession:d,showCopyResume:!1,treatSessionsAsRoots:!0,...r?{ownerPrincipalId:r}:{},isPersonaExpanded:()=>!0})}),h.jsx("main",{className:"flex-1 min-w-0 min-h-0 flex",children:o?h.jsx(vie,{api:n,session:o,focused:!0,totalPanes:1,onFocus:()=>{},onClose:f,onNewSession:()=>{},onOpenConfig:()=>{},onConfigPatch:p,viewerRole:"guest"}):h.jsx("div",{className:"flex flex-1 items-center justify-center p-6 text-xs text-text-400","data-testid":"guest-share-empty",children:"选择左侧 persona 开始对话"})})]})}function yie(){const e=$i(),t=g.useMemo(()=>new k_(e),[e]),n=m6(e),{sessions:r,refresh:i}=g6(n),{personas:s}=_T(),o=w6(),a=g.useMemo(()=>{const w=window.location.pathname.match(/^\/s\/([^/]+)/);return w?decodeURIComponent(w[1]):null},[]),l=g.useMemo(()=>r.filter(w=>!w.ephemeral&&w.larkChatId==null),[r]),c=g.useMemo(()=>a?s.filter(w=>w.personaId===a):s,[s,a]),[u,d]=g.useState(null),[f,p]=g.useState(null),[m,v]=g.useState(null);g.useEffect(()=>{let w=!1;return e.request("whoami",{}).then(S=>{w||d(S.capability.id)}).catch(()=>{}),()=>{w=!0}},[e]),g.useEffect(()=>{a&&p(a)},[a]);const b=g.useCallback(async(w,S)=>{const C=await t.sessionCreate({ownerPersonaId:w,...S.trim()?{label:S.trim()}:{}});await i(),p(w),v(C.sessionId)},[t,i]),x=g.useCallback(async w=>{await t.sessionDelete(w),await i(),v(S=>S===w?null:S)},[t,i]),_=g.useCallback(async(w,S)=>{await t.sessionUpdate(w,{label:S.label,iconKey:S.iconKey===null?"":S.iconKey}),await i()},[t,i]),y=g.useMemo(()=>l.find(w=>w.sessionId===m)??null,[l,m]);return h.jsx(C_.Provider,{value:o,children:h.jsx(_ie,{personas:c,sessions:l,api:t,selfPrincipalId:u,selectedPersonaId:f,selectedSessionId:m,selectedSession:y,onSelectPersona:p,onSelectSession:v,onCreateSession:(w,S)=>void b(w,S),onDeleteSession:w=>void x(w),onEditSession:(w,S)=>void _(w,S),onCloseSession:()=>v(null),onConfigPatch:async()=>{}})})}const PC="https://app.ttcadvisory.com";function bie({onAuthed:e}){const[t,n]=g.useState(!1),[r,i]=g.useState(null),s=g.useRef(null);g.useEffect(()=>()=>{s.current&&window.removeEventListener("message",s.current)},[]);const o=g.useCallback(()=>{s.current&&(window.removeEventListener("message",s.current),s.current=null),n(!0),i(null);const a=window.location.origin,l=`${PC}/auth/authorize?callback_url=${encodeURIComponent(a)}&auto=1`,c=async d=>{if(d.origin!==PC)return;const f=d.data;if((f==null?void 0:f.type)==="AUTH_CANCEL"){u(),n(!1);return}if(!((f==null?void 0:f.type)!=="AUTH_SUCCESS"||!f.token)){u();try{const p=await fetch(`${window.location.origin}/share/exchange`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({ttcToken:f.token})});if(!p.ok){const v=await p.json().catch(()=>({}));throw new Error(v.code??`exchange failed (${p.status})`)}const m=await p.json();if(!m.visitorToken)throw new Error("no visitorToken in response");e(m.visitorToken)}catch(p){i(p instanceof Error?p.message:String(p)),n(!1)}}},u=()=>{window.removeEventListener("message",c),s.current=null};s.current=d=>void c(d),window.addEventListener("message",s.current),window.open(l,"ttc-login","width=480,height=640")},[e]);return h.jsx("div",{className:"flex min-h-screen items-center justify-center bg-bg-50 p-6 font-sans text-text-100","data-testid":"guest-login",children:h.jsxs("div",{className:"flex w-full max-w-xs flex-col gap-3 rounded-lg border border-border bg-bg-100 px-5 py-6",children:[h.jsx("h1",{className:"text-base font-semibold",children:"登录后进入分享"}),h.jsx("p",{className:"text-[11px] leading-snug text-text-400",children:"使用飞书账号登录,即可在浏览器里与分享给你的 persona 交互,无需安装。"}),r?h.jsxs("p",{className:"text-[11px] leading-snug text-error","data-testid":"guest-login-error",children:["登录失败:",r]}):null,h.jsx("button",{type:"button",disabled:t,onClick:()=>o(),"data-testid":"guest-login-button",className:"w-full rounded border border-border bg-bg-50 px-2 py-1.5 text-xs text-text-200 transition-colors hover:bg-text-100/5 hover:text-text-100 disabled:opacity-50",children:t?"请在弹窗中完成授权…":"飞书登录"})]})})}const fx="clawd-visitor:token";function wie(e,t){const r=`${e.protocol==="https:"?"wss:":"ws:"}//${e.host}`;return t!=null&&t.devPath?`${r}${t.devPath}`:r}function Sie(){return{async getUrl(e){const t=localStorage.getItem(fx);if(!t)throw new Error("NO_VISITOR_TOKEN");const n=wie(window.location,{});return await uT(e).upsert({id:"guest",name:"访客",mode:"remote",url:n,token:t}),{url:n}}}}function kie(e){const t=n=>{document.documentElement.classList.toggle("dark",n==="dark")};return t(e.theme.mode),e.onThemeChange(n=>t(n.mode))}function Cie(){const e=$i(),t=g.useMemo(()=>p6(e),[e]);return h.jsx(XB,{cache:t.cache,children:h.jsx(QB,{children:h.jsx(yie,{})})})}function Eie({host:e}){const[t]=g.useState(()=>localStorage.getItem(fx)),[n,r]=g.useState(!1),[i,s]=g.useState(null);return g.useEffect(()=>kie(e),[e]),g.useEffect(()=>{if(!t)return;let o=!1;return Sie().getUrl(e).then(()=>{o||r(!0)}).catch(a=>{o||s(a instanceof Error?a.message:String(a))}),()=>{o=!0}},[e,t]),t?h.jsx(xb,{host:e,children:h.jsx(Zb,{children:i?h.jsxs("div",{className:"flex min-h-screen items-center justify-center bg-bg-50 p-6 text-center text-xs text-error","data-testid":"guest-share-connect-error",children:["连接失败:",i]}):n?h.jsx(KB,{host:e,children:h.jsx(Cie,{})}):h.jsx("div",{className:"flex min-h-screen items-center justify-center bg-bg-50 p-6 text-xs text-text-400",children:"正在连接…"})})}):h.jsx(xb,{host:e,children:h.jsx(Zb,{children:h.jsx(bie,{onAuthed:o=>{localStorage.setItem(fx,o),window.location.reload()}})})})}function Nie({filePath:e,oldString:t,newString:n,content:r}){const i=g.useMemo(()=>r!=null?r.split(/\r?\n/).map(s=>({type:"add",text:s})):Tie(t??"",n??""),[t,n,r]);return h.jsxs("div",{"data-testid":"inline-diff",className:"min-w-0 max-w-full rounded-lg border border-bg-300/60 bg-bg-50 overflow-hidden text-[12px] font-mono",children:[h.jsx("div",{className:"flex min-w-0 items-center gap-2 px-3 py-1.5 border-b border-bg-300/40 bg-bg-100/30",children:h.jsx("span",{className:"min-w-0 text-text-400 truncate",title:e,children:e})}),h.jsx("div",{className:"max-h-[320px] max-w-full overflow-auto",children:i.map((s,o)=>h.jsxs("div",{"data-testid":`diff-line-${s.type}`,className:ne("flex min-w-max gap-2 px-3 py-0.5 whitespace-pre",s.type==="add"?"bg-success/10 text-success":s.type==="remove"?"bg-error/10 text-error":"text-text-300"),children:[h.jsx("span",{className:"w-3 shrink-0 select-none opacity-60",children:s.type==="add"?"+":s.type==="remove"?"-":" "}),h.jsx("span",{className:"flex-1",children:s.text||" "})]},o))})]})}function Tie(e,t){const n=e.split(/\r?\n/),r=t.split(/\r?\n/),i=n.length,s=r.length,o=Array.from({length:i+1},()=>new Array(s+1).fill(0));for(let u=i-1;u>=0;u--)for(let d=s-1;d>=0;d--)o[u][d]=n[u]===r[d]?o[u+1][d+1]+1:Math.max(o[u+1][d],o[u][d+1]);const a=[];let l=0,c=0;for(;l<i&&c<s;)n[l]===r[c]?(a.push({type:"equal",text:n[l]}),l++,c++):o[l+1][c]>=o[l][c+1]?(a.push({type:"remove",text:n[l]}),l++):(a.push({type:"add",text:r[c]}),c++);for(;l<i;)a.push({type:"remove",text:n[l++]});for(;c<s;)a.push({type:"add",text:r[c++]});return a}function Pie({items:e}){return e.length===0?null:h.jsxs("div",{"data-testid":"todo-checklist",className:"rounded-lg border border-bg-300/60 bg-bg-50 px-3 py-2 text-[13px]",children:[h.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider text-text-400/70 mb-1.5",children:"Todos"}),h.jsx("ul",{className:"flex flex-col gap-1",children:e.map((t,n)=>{const r=t.status==="in_progress"&&t.activeForm||t.content;return h.jsxs("li",{"data-testid":`todo-item-${t.status}`,className:"flex items-start gap-2",children:[h.jsx(Iie,{status:t.status}),h.jsx("span",{className:ne("flex-1 leading-snug",t.status==="completed"?"text-text-400 line-through":t.status==="in_progress"?"text-text-100 font-medium":"text-text-200"),children:r})]},n)})})]})}function Iie({status:e}){return e==="completed"?h.jsx(Zf,{className:"w-3.5 h-3.5 text-success mt-0.5 shrink-0"}):e==="in_progress"?h.jsx(rr,{className:"w-3.5 h-3.5 text-warning mt-0.5 shrink-0 animate-spin"}):h.jsx(ST,{className:"w-3.5 h-3.5 text-text-400 mt-0.5 shrink-0"})}function Rie(e){const t=e??{};return Array.isArray(t.todos)?t.todos.map(n=>{if(!n||typeof n!="object")return null;const r=n,i=typeof r.content=="string"?r.content:"",s=r.status==="pending"||r.status==="in_progress"||r.status==="completed"?r.status:"pending",o=typeof r.activeForm=="string"?r.activeForm:void 0;return{content:i,status:s,activeForm:o}}).filter(n=>n!==null):[]}function Mie({description:e,prompt:t,subagentType:n}){return h.jsxs("div",{"data-testid":"task-checklist",className:"rounded-lg border border-bg-300/60 bg-bg-50 px-3 py-2 text-[13px]",children:[h.jsxs("div",{className:"flex items-center gap-2 text-text-200 font-medium",children:[h.jsx(Yf,{className:"w-3.5 h-3.5 text-accent shrink-0"}),h.jsx("span",{className:"truncate",children:e||"subagent task"}),n?h.jsx("span",{className:"shrink-0 px-1.5 py-0.5 rounded-md text-[10px] font-mono bg-accent/10 text-accent",children:n}):null]}),t?h.jsx("div",{className:"mt-1 text-[12px] text-text-400 leading-snug line-clamp-3",children:t}):null]})}function Aie(e){const t=e??{};return{description:typeof t.description=="string"?t.description:"",prompt:typeof t.prompt=="string"?t.prompt:void 0,subagentType:typeof t.subagent_type=="string"?t.subagent_type:void 0}}const jie={render:({input:e})=>st.createElement(Pie,{items:Rie(e)})},Lie={render:({input:e})=>{const{description:t,prompt:n,subagentType:r}=Aie(e);return st.createElement(Mie,{description:t,prompt:n,subagentType:r})}},p5={render:({input:e,output:t,error:n,pending:r,fileScope:i,onShareFile:s,onOpenInTab:o,onPreviewMarkdown:a})=>{const l=Oie(e),c=l?st.createElement(Nie,{filePath:l.filePath,oldString:l.oldString,newString:l.newString,content:l.content}):void 0;return st.createElement(yM,{tool:Die(e),input:e,output:t,error:n,pending:r,expandedBody:c,...i?{fileScope:i}:{},...s?{onShareFile:s}:{},...o?{onOpenInTab:o}:{},...a?{onPreviewMarkdown:a}:{}})}};function Die(e){const t=e??{};return"content"in t&&t.content!==void 0?"Write":("old_string"in t&&t.old_string!==void 0,"Edit")}function Oie(e){const t=e??{},n=typeof t.file_path=="string"?t.file_path:null;if(!n)return null;const r=typeof t.old_string=="string"?t.old_string:void 0,i=typeof t.new_string=="string"?t.new_string:void 0,s=typeof t.content=="string"?t.content:void 0;return r==null&&i==null&&s==null?null:{filePath:n,oldString:r,newString:i,content:s}}ku.register("claude","TodoWrite",jie);ku.register("claude","Task",Lie);ku.register("claude","Edit",p5);ku.register("claude","Write",p5);const m5=document.getElementById("root");if(!m5)throw new Error("guest-main: #root not found");const Bie=X4({});gg.createRoot(m5).render(h.jsx(st.StrictMode,{children:h.jsx(Eie,{host:Bie})}));
|
|
574
|
+
`;return typeof r=="function"&&r(null,f),f};const rre=xne,hx=KA,l5=o5,ire=a5;function Jy(e,t,n,r,i){const s=[].slice.call(arguments,1),o=s.length,a=typeof s[o-1]=="function";if(!a&&!rre())throw new Error("Callback required as last argument");if(a){if(o<2)throw new Error("Too few arguments provided");o===2?(i=n,n=t,t=r=void 0):o===3&&(t.getContext&&typeof i>"u"?(i=r,r=void 0):(i=r,r=n,n=t,t=void 0))}else{if(o<1)throw new Error("Too few arguments provided");return o===1?(n=t,t=r=void 0):o===2&&!t.getContext&&(r=n,n=t,t=void 0),new Promise(function(l,c){try{const u=hx.create(n,r);l(e(u,t,r))}catch(u){c(u)}})}try{const l=hx.create(n,r);i(null,e(l,t,r))}catch(l){i(l)}}Pu.create=hx.create;Pu.toCanvas=Jy.bind(null,l5.render);Pu.toDataURL=Jy.bind(null,l5.renderToDataURL);Pu.toString=Jy.bind(null,function(e,t,n){return ire.render(e,n)});const e1=KM,sre=GM,c5=g.forwardRef(({className:e,...t},n)=>h.jsx(jy,{ref:n,className:ne("fixed inset-0 z-50 bg-black/50 backdrop-blur-sm",e),...t}));c5.displayName=jy.displayName;const Pp=g.forwardRef(({className:e,children:t,...n},r)=>h.jsxs(sre,{children:[h.jsx(c5,{}),h.jsxs(Ly,{ref:r,className:ne("fixed left-1/2 top-1/2 z-50 grid w-full max-w-lg -translate-x-1/2 -translate-y-1/2","gap-4 rounded-lg border border-border bg-elevated p-6 shadow-lg",e),...n,children:[t,h.jsxs(XM,{className:"absolute right-4 top-4 rounded-sm opacity-70 transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-accent",children:[h.jsx(Rn,{className:"h-4 w-4"}),h.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Pp.displayName=Ly.displayName;const Ip=({className:e,...t})=>h.jsx("div",{className:ne("flex flex-col space-y-1.5 text-left",e),...t});Ip.displayName="DialogHeader";const t1=({className:e,...t})=>h.jsx("div",{className:ne("flex flex-row justify-end gap-2",e),...t});t1.displayName="DialogFooter";const Rp=g.forwardRef(({className:e,...t},n)=>h.jsx(Dy,{ref:n,className:ne("text-lg font-semibold leading-none text-text-100",e),...t}));Rp.displayName=Dy.displayName;const u5=g.forwardRef(({className:e,...t},n)=>h.jsx(Oy,{ref:n,className:ne("text-sm text-text-300",e),...t}));u5.displayName=Oy.displayName;function ore({persona:e,open:t,onClose:n,onTogglePublic:r,guestShareUrl:i,onChangeIcon:s,onDelete:o,embedded:a,onLoadPersonality:l,onSavePersonality:c,onDirtyChange:u,initialPersonality:d,onShareCapability:f,readOnly:p=!1,onChangeTool:m,larkBot:v}){const[b,x]=g.useState(!1),[_,y]=g.useState(!1),w=()=>{i&&navigator.clipboard.writeText(i).then(()=>{y(!0),setTimeout(()=>y(!1),2e3)})},S=N=>{x(N),u==null||u(N)},C=()=>{b&&!window.confirm("修改未保存,确定关闭?")||n()};return t?h.jsxs(h.Fragment,{children:[!a&&h.jsx("div",{className:"absolute inset-0 z-30 bg-black/30",onClick:C,"aria-hidden":"true"}),h.jsxs("aside",{className:a?"flex h-full w-full flex-col bg-bg-0":"absolute right-0 top-0 z-40 flex h-full w-[420px] flex-col bg-bg-0 border-l border-border shadow-xl","data-testid":"persona-settings-drawer",children:[h.jsxs("header",{className:"flex items-center justify-between border-b border-border px-4 py-3 shrink-0",children:[h.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[h.jsx(e$,{className:"h-4 w-4 text-text-300"}),h.jsx("span",{className:"text-[13px] font-medium text-text-100 truncate",children:"Persona 设置"})]}),h.jsx("button",{type:"button",onClick:C,"aria-label":"关闭",className:"rounded-sm p-1.5 text-text-400 hover:bg-bg-200 hover:text-text-100",children:h.jsx(Rn,{className:"h-4 w-4"})})]}),h.jsxs("div",{className:"flex-1 overflow-y-auto p-6 flex flex-col gap-4",children:[h.jsxs("header",{className:"flex items-start justify-between gap-3",children:[h.jsxs("div",{className:"flex flex-col gap-0.5 min-w-0",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("h2",{className:"text-lg font-semibold text-text-100 truncate",children:e.label}),e.public?h.jsxs("span",{className:"inline-flex items-center gap-1 rounded-sm bg-bg-200 px-1.5 py-0.5 text-[10px] text-text-200",children:[h.jsx(wz,{className:"h-3 w-3"})," 公开"]}):h.jsxs("span",{className:"inline-flex items-center gap-1 rounded-sm bg-error-dim px-1.5 py-0.5 text-[10px] text-error",children:[h.jsx(yz,{className:"h-3 w-3"})," 已关闭"]})]}),h.jsx("span",{className:"font-mono text-[11px] text-text-400 truncate","data-testid":"persona-id-subtitle",children:e.personaId})]}),h.jsxs("div",{className:"flex items-center gap-1",children:[f?h.jsxs("button",{type:"button",onClick:f,"aria-label":"分享给他人",title:"分享给他人",className:"inline-flex items-center gap-1 rounded-sm px-2 py-1.5 text-xs text-text-200 hover:bg-bg-200 hover:text-text-100",children:[h.jsx(E_,{className:"h-3.5 w-3.5"}),"分享"]}):null,o?h.jsx("button",{type:"button",onClick:o,"aria-label":"删除 persona",className:"rounded-sm p-1.5 text-text-400 hover:bg-bg-200 hover:text-error",children:h.jsx(N_,{className:"h-4 w-4"})}):null]})]}),h.jsx("hr",{className:"border-border"}),r?h.jsxs(h.Fragment,{children:[h.jsxs("section",{className:"flex items-center justify-between gap-3",children:[h.jsxs("div",{className:"flex flex-col gap-0.5",children:[h.jsx("span",{className:"text-[13px] font-medium text-text-100",children:"公开访问"}),h.jsx("span",{className:"text-[11px] text-text-400",children:"开启后这个 persona 才会出现在「邀请联系人」的可选列表里。关闭即拒所有新分享(已颁出的 token 不受影响)。"})]}),h.jsx(dre,{checked:e.public??!1,onChange:N=>r(N)})]}),e.public?h.jsxs("section",{className:"flex flex-col gap-1.5","data-testid":"guest-share-link",children:[h.jsxs("div",{className:"flex items-center gap-1.5",children:[h.jsx(ET,{className:"h-3.5 w-3.5 text-text-400","aria-hidden":!0}),h.jsx("span",{className:"text-[13px] font-medium text-text-100",children:"访客分享链接"})]}),i?h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("input",{readOnly:!0,value:i,onFocus:N=>N.currentTarget.select(),className:"min-w-0 flex-1 truncate rounded border border-border bg-bg-100 px-2 py-1 text-[12px] text-text-200","data-testid":"guest-share-link-input"}),h.jsx("button",{type:"button",onClick:w,className:"flex shrink-0 items-center gap-1 rounded border border-border px-2 py-1 text-[12px] text-text-200 hover:bg-bg-200","data-testid":"guest-share-link-copy",children:_?h.jsxs(h.Fragment,{children:[h.jsx(ol,{className:"h-3 w-3"})," 已复制"]}):h.jsxs(h.Fragment,{children:[h.jsx(mu,{className:"h-3 w-3"})," 复制"]})})]}),h.jsx("span",{className:"text-[11px] text-text-400",children:"任何 TTC 员工打开此链接(飞书登录)即可在该 persona 下交互。"})]}):h.jsx("span",{className:"text-[11px] text-text-400","data-testid":"guest-share-link-no-tunnel",children:"需先开启 tunnel(公网访问)才能生成可分享给外部的链接。"})]}):null,h.jsx("hr",{className:"border-border"})]}):null,v?h.jsxs(h.Fragment,{children:[h.jsx(ure,{...v}),h.jsx("hr",{className:"border-border"})]}):null,s?h.jsxs("section",{className:"flex flex-col gap-1.5",children:[h.jsx("span",{className:"text-[13px] font-medium text-text-100",children:"默认图标"}),h.jsx("span",{className:"text-[11px] text-text-400",children:"新建该 persona 的 session 会默认继承此图标。"}),h.jsx(WI,{value:e.iconKey??null,onChange:s,tool:e.tool})]}):null,s?h.jsx("hr",{className:"border-border"}):null,m&&!p?h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"flex flex-col gap-1.5",children:[h.jsx("span",{className:"text-[12px] font-medium text-text-200",children:"Agent"}),h.jsx("div",{className:"flex gap-2",children:["claude","codex"].map(N=>h.jsx("button",{type:"button","data-testid":`persona-edit-tool-${N}`,onClick:()=>m(N),className:ne("flex-1 rounded-md border px-3 py-2 text-[12px]",(e.tool??"claude")===N?"border-accent bg-accent/10 text-accent":"border-bg-300 text-text-300"),children:N==="claude"?"Claude Code":"Codex"},N))}),h.jsx("span",{className:"text-[11px] text-text-400",children:"切换只影响之后新建的会话,已有会话保持原 tool。"})]}),h.jsx("hr",{className:"border-border"})]}):null,l?h.jsxs(h.Fragment,{children:[h.jsx(mre,{onLoad:l,...c?{onSave:c}:{},onDirtyChange:S,initialPersonality:d,readOnly:p}),h.jsx("hr",{className:"border-border"})]}):null,h.jsx(hre,{settings:e.sandboxSettings??null}),h.jsx("hr",{className:"border-border"}),h.jsx(fre,{skills:e.skills??[]}),h.jsx("hr",{className:"border-border"}),h.jsx(pre,{plugins:e.plugins??[]})]})]})]}):null}function are({qrUrl:e,busy:t,onCancel:n}){const[r,i]=g.useState(null);return g.useEffect(()=>{let s=!1;return Pu.toDataURL(e,{width:240,margin:1}).then(o=>{s||i(o)}).catch(()=>{s||i(null)}),()=>{s=!0}},[e]),h.jsx(e1,{open:!0,onOpenChange:s=>s||n==null?void 0:n(),children:h.jsxs(Pp,{className:"max-w-xs","data-testid":"lark-bot-qr-dialog",onInteractOutside:s=>s.preventDefault(),onEscapeKeyDown:s=>s.preventDefault(),children:[h.jsx(Ip,{children:h.jsx(Rp,{children:"扫码关联飞书 Bot"})}),h.jsxs("div",{className:"flex flex-col items-center gap-2",children:[r?h.jsx("img",{src:r,alt:"飞书扫码创建应用二维码",className:"h-60 w-60 rounded bg-white p-2","data-testid":"lark-bot-qr-img"}):h.jsx("div",{className:"flex h-60 w-60 items-center justify-center text-[12px] text-text-400",children:"二维码生成中…"}),h.jsx("span",{className:"text-center text-[12px] text-text-300",children:"用手机飞书扫码,按页面提示创建应用。确认后自动完成关联。"}),n?h.jsx("button",{type:"button",disabled:t,onClick:n,className:"rounded border border-border px-3 py-1.5 text-[12px] text-text-300 hover:bg-bg-200 disabled:opacity-50","data-testid":"lark-bot-provision-cancel",children:"取消"}):null]})]})})}const lre={expired:"二维码已过期,请重新扫码。",cancelled:"已取消。",access_denied:"你在飞书上取消了本次授权。",lark_protocol_error:"飞书返回了未预期的响应,请重试。",cloud_unreachable:"云端暂时不可达,请稍后重试。",internal_error:"关联失败。若飞书中已创建应用,可在开发者后台删除后重试,或改用手动绑定填入其凭证。"},cre=new Set(["expired","access_denied","lark_protocol_error","cloud_unreachable","internal_error"]);function ure({status:e,onProvision:t,onCancelProvision:n,onBindManual:r,onUnbind:i}){const[s,o]=g.useState(!1),[a,l]=g.useState(null),[c,u]=g.useState(""),[d,f]=g.useState(""),[p,m]=g.useState(null),v=_=>{_&&(o(!0),l(null),_().catch(y=>l(y instanceof Error?y.message:String(y))).finally(()=>o(!1)))},b=()=>{m(null),v(t)},x=h.jsxs("div",{className:"flex items-center gap-1.5",children:[h.jsx(Yf,{className:"h-3.5 w-3.5 text-text-400","aria-hidden":!0}),h.jsx("span",{className:"text-[13px] font-medium text-text-100",children:"飞书 Bot"})]});return e?h.jsxs("section",{className:"flex flex-col gap-1.5","data-testid":"lark-bot-section",children:[x,e.state==="unbound"||e.state==="provisioning"?h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"text-[11px] text-text-400",children:"关联一个飞书 bot 后,这个 persona 就是它:拉进群后群成员 @ 它提问、或直接私聊它, 推理跑在你本机,回复自动发回去。"}),t?h.jsx("button",{type:"button",disabled:s||e.state==="provisioning",onClick:b,className:"self-start rounded border border-border bg-bg-200 px-3 py-1.5 text-[12px] font-medium text-text-100 hover:bg-bg-300 disabled:opacity-50","data-testid":"lark-bot-provision",children:e.state==="provisioning"?"等待扫码…":"扫码关联飞书 Bot"}):null,e.state==="unbound"&&e.errorReason&&!p?h.jsxs("div",{className:"flex flex-col gap-1.5 rounded border border-error bg-error-dim px-2 py-1.5","data-testid":"lark-bot-provision-error",children:[h.jsx("span",{className:"text-[11px] text-error",children:lre[e.errorReason]}),h.jsxs("div",{className:"flex gap-1.5",children:[cre.has(e.errorReason)&&t?h.jsx("button",{type:"button",disabled:s,onClick:b,className:"rounded border border-border px-2 py-1 text-[11px] text-text-100 hover:bg-bg-200 disabled:opacity-50","data-testid":"lark-bot-provision-retry",children:"重新扫码"}):null,h.jsx("button",{type:"button",onClick:()=>m(e.errorReason??null),className:"rounded border border-border px-2 py-1 text-[11px] text-text-300 hover:bg-bg-200","data-testid":"lark-bot-provision-error-dismiss",children:"知道了"})]})]}):null,e.state==="provisioning"&&e.qrUrl?h.jsx(are,{qrUrl:e.qrUrl,busy:s,onCancel:n?()=>v(n):void 0}):null,r&&e.state==="unbound"?h.jsxs("details",{"data-testid":"lark-bot-manual-details",children:[h.jsx("summary",{className:"cursor-pointer text-[11px] text-text-400 hover:text-text-300",children:"已有飞书应用?手动填入凭证"}),h.jsxs("div",{className:"mt-1.5 flex flex-col gap-1.5","data-testid":"lark-bot-manual-form",children:[h.jsx("span",{className:"text-[11px] text-text-400",children:"先在飞书开放平台(open.feishu.cn)创建企业自建应用并启用机器人能力,再填入凭证:"}),h.jsx("input",{value:c,onChange:_=>u(_.target.value),placeholder:"App ID(cli_ 开头)",className:"rounded border border-border bg-bg-100 px-2 py-1 text-[12px] text-text-200","data-testid":"lark-bot-manual-appid"}),h.jsx("input",{value:d,onChange:_=>f(_.target.value),type:"password",placeholder:"App Secret",className:"rounded border border-border bg-bg-100 px-2 py-1 text-[12px] text-text-200","data-testid":"lark-bot-manual-secret"}),h.jsx("button",{type:"button",disabled:s||!c||!d,onClick:()=>v(()=>r({appId:c,appSecret:d})),className:"self-start rounded border border-border px-3 py-1.5 text-[12px] text-text-100 hover:bg-bg-200 disabled:opacity-50","data-testid":"lark-bot-manual-submit",children:s?"绑定中…":"绑定"})]})]}):null]}):null,e.state==="bound"||e.state==="broken"?h.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.state==="broken"?h.jsxs("div",{className:"rounded border border-error bg-error-dim px-2 py-1.5 text-[11px] text-error","data-testid":"lark-bot-broken",children:["Bot 凭证失效:",e.brokenReason??"未知原因","。请解绑后重新填入有效凭证绑定。"]}):null,h.jsxs("div",{className:"flex items-center gap-2 text-[12px] text-text-200",children:[h.jsx("span",{className:"font-medium text-text-100",children:e.botName??"未命名 bot"}),e.appId?h.jsx("span",{className:"text-[11px] text-text-400",children:e.appId}):null]}),h.jsx("span",{className:"text-[11px] text-text-400",children:"把 bot 拉进任意飞书群,群成员 @ 它即可提问。"}),e.groups.length>0?h.jsx("ul",{className:"flex flex-col gap-0.5","data-testid":"lark-bot-groups",children:e.groups.map(_=>h.jsxs("li",{className:"text-[11px] text-text-300 truncate",children:["· ",_.chatName??_.chatId]},_.chatId))}):h.jsx("span",{className:"text-[11px] text-text-400","data-testid":"lark-bot-groups-empty",children:"还没有服务中的群。"}),i?h.jsx("button",{type:"button",disabled:s,onClick:()=>v(i),className:"self-start rounded border border-border px-3 py-1.5 text-[12px] text-error hover:bg-error-dim disabled:opacity-50","data-testid":"lark-bot-unbind",children:"解绑"}):null]}):null,a?h.jsx("div",{className:"rounded border border-error bg-error-dim px-2 py-1.5 text-[11px] text-error","data-testid":"lark-bot-error",children:a}):null]}):h.jsxs("section",{className:"flex flex-col gap-1.5","data-testid":"lark-bot-section",children:[x,h.jsx("span",{className:"text-[11px] text-text-400",children:"状态加载中…"})]})}function dre({checked:e,onChange:t}){return h.jsx("button",{type:"button",role:"switch","aria-checked":e,onClick:()=>t(!e),"data-testid":"persona-public-toggle",className:ne("relative inline-flex h-6 w-11 shrink-0 items-center rounded-full transition-colors",e?"bg-success":"bg-bg-300"),children:h.jsx("span",{className:ne("inline-block h-5 w-5 rounded-full bg-bg-0 shadow transition-transform",e?"translate-x-[22px]":"translate-x-0.5")})})}function hre({settings:e}){var t,n,r,i,s,o,a,l,c,u,d,f,p;return h.jsxs("section",{className:"flex flex-col gap-2","data-testid":"persona-sandbox-setting-section",children:[h.jsxs("header",{className:"flex flex-col gap-0.5",children:[h.jsx("span",{className:"text-[13px] font-medium text-text-100",children:"Sandbox Setting"}),h.jsx("span",{className:"text-[11px] text-text-400",children:"约束此 persona 的沙箱权限(只读,需通过文件修改)。"})]}),e==null?h.jsx("span",{className:"text-[12px] text-text-300","data-testid":"persona-sandbox-setting-empty",children:"暂无 sandbox 配置"}):h.jsxs("div",{className:"flex flex-col gap-1.5 rounded-md border border-border bg-bg-100 px-3 py-2",children:[h.jsx(Id,{label:"权限默认模式",value:((t=e.permissions)==null?void 0:t.defaultMode)??"—"}),h.jsx(Id,{label:"沙箱启用",value:mg((n=e.sandbox)==null?void 0:n.enabled)}),h.jsx(Id,{label:"沙箱内自动放行 Bash",value:mg((r=e.sandbox)==null?void 0:r.autoAllowBashIfSandboxed)}),h.jsx(Id,{label:"允许非沙箱命令",value:mg((i=e.sandbox)==null?void 0:i.allowUnsandboxedCommands)}),h.jsxs("div",{className:"mt-1 flex flex-col gap-1.5 border-t border-border pt-1.5",children:[h.jsx(zl,{label:"沙箱外命令",paths:(s=e.sandbox)==null?void 0:s.excludedCommands}),h.jsx(zl,{label:"允许读取",paths:(a=(o=e.sandbox)==null?void 0:o.filesystem)==null?void 0:a.allowRead}),h.jsx(zl,{label:"拒绝读取",paths:(c=(l=e.sandbox)==null?void 0:l.filesystem)==null?void 0:c.denyRead}),h.jsx(zl,{label:"允许写入",paths:(d=(u=e.sandbox)==null?void 0:u.filesystem)==null?void 0:d.allowWrite}),h.jsx(zl,{label:"拒绝写入",paths:(p=(f=e.sandbox)==null?void 0:f.filesystem)==null?void 0:p.denyWrite})]})]})]})}function mg(e){return e===!0?"是":e===!1?"否":"—"}function Id({label:e,value:t}){return h.jsxs("div",{className:"flex items-center justify-between gap-3 text-[12px]",children:[h.jsx("span",{className:"text-text-300",children:e}),h.jsx("span",{className:"font-mono text-text-100",children:t})]})}function zl({label:e,paths:t}){const n=!t||t.length===0;return h.jsxs("div",{className:"flex flex-col gap-1",children:[h.jsx("span",{className:"text-[11px] text-text-300",children:e}),n?h.jsx("span",{className:"text-[11px] text-text-400",children:"—"}):h.jsx("div",{className:"flex flex-wrap gap-1",children:t.map((r,i)=>h.jsx("span",{className:"rounded-sm border border-border bg-bg-0 px-1.5 py-0.5 font-mono text-[11px] text-text-200",children:r},`${e}-${i}-${r}`))})]})}function fre({skills:e}){return h.jsxs("section",{className:"flex flex-col gap-2","data-testid":"persona-skills-section",children:[h.jsxs("header",{className:"flex flex-col gap-0.5",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:"text-[13px] font-medium text-text-100",children:"Persona Skills"}),h.jsx("span",{className:"rounded-sm border border-border px-1.5 py-0.5 text-[10px] text-text-300",children:e.length})]}),h.jsxs("span",{className:"text-[11px] text-text-400",children:["此 persona 私有 skills(来自"," ",h.jsx("code",{className:"font-mono",children:"<persona-dir>/.claude/skills/"}),")。"]})]}),e.length===0?h.jsx("span",{className:"text-[12px] text-text-300","data-testid":"persona-skills-empty",children:"暂无 skills"}):h.jsx("ul",{className:"flex flex-col divide-y divide-border rounded-md border border-border bg-bg-100",children:e.map(t=>h.jsxs("li",{className:"flex flex-col gap-0.5 px-3 py-2","data-testid":"persona-skill-row",children:[h.jsx("span",{className:"font-mono text-[13px] text-text-100",children:t.name}),t.description?h.jsx("span",{className:"text-[12px] text-text-300",children:t.description}):h.jsx("span",{className:"text-[11px] text-text-400 italic",children:"无描述"})]},t.name))})]})}function pre({plugins:e}){return h.jsxs("section",{className:"flex flex-col gap-2","data-testid":"persona-plugins-section",children:[h.jsxs("header",{className:"flex flex-col gap-0.5",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:"text-[13px] font-medium text-text-100",children:"Enabled Plugins"}),h.jsx("span",{className:"rounded-sm border border-border px-1.5 py-0.5 text-[10px] text-text-300",children:e.length})]}),h.jsxs("span",{className:"text-[11px] text-text-400",children:["此 persona 已启用的插件(来自"," ",h.jsx("code",{className:"font-mono",children:"<persona-dir>/.claude/settings.json"})," ","的 ",h.jsx("code",{className:"font-mono",children:"enabledPlugins"}),")。"]})]}),e.length===0?h.jsx("span",{className:"text-[12px] text-text-300","data-testid":"persona-plugins-empty",children:"暂无启用插件"}):h.jsx("ul",{className:"flex flex-col divide-y divide-border rounded-md border border-border bg-bg-100",children:e.map(t=>h.jsx("li",{className:"flex flex-col gap-0.5 px-3 py-2","data-testid":"persona-plugin-row",children:h.jsx("span",{className:"font-mono text-[13px] text-text-100",children:t.id})},t.id))})]})}function mre({onLoad:e,onSave:t,onDirtyChange:n,initialPersonality:r,readOnly:i=!1}){const s=r!==void 0,[o,a]=g.useState(s),[l,c]=g.useState(s?r:""),[u,d]=g.useState(s?r:""),[f,p]=g.useState(null),[m,v]=g.useState(!1),[b,x]=g.useState(null),_=st.useRef(e),y=st.useRef(t),w=st.useRef(n);st.useEffect(()=>{_.current=e,y.current=t,w.current=n});const S=st.useCallback(()=>{a(!1),p(null),_.current().then(M=>{c(M),d(M),a(!0)}).catch(M=>{p(M instanceof Error?M.message:String(M))})},[]);st.useEffect(()=>{s||S()},[s,S]);const C=!i&&o&&u!==l;st.useEffect(()=>{i||w.current(C)},[C,i]);const N=()=>{y.current&&(v(!0),x(null),y.current(u).then(()=>{c(u),v(!1)}).catch(M=>{x(M instanceof Error?M.message:String(M)),v(!1)}))},T=()=>{d(l),x(null)};return h.jsxs("section",{className:"flex flex-col gap-2","data-testid":"persona-personality-section",children:[h.jsx("span",{className:"text-[12px] font-medium text-text-200",children:"人格 (Personality)"}),f?h.jsxs("div",{"data-testid":"persona-personality-load-error",className:"rounded-md border border-error bg-error-dim px-3 py-2 text-[12px] text-error flex items-center justify-between gap-2",children:[h.jsxs("span",{children:["加载失败:",f]}),h.jsx("button",{type:"button",onClick:S,className:"rounded-sm border border-error px-2 py-0.5 text-[11px] hover:bg-error/10",children:"重试"})]}):null,b?h.jsxs("div",{"data-testid":"persona-personality-save-error",className:"rounded-md border border-error bg-error-dim px-3 py-2 text-[12px] text-error",children:["保存失败:",b]}):null,h.jsx("textarea",{"data-testid":"persona-personality-textarea",value:u,onChange:M=>d(M.target.value),readOnly:i,disabled:!i&&(!o||m),placeholder:o?"":"加载中…",rows:8,className:"min-h-[8rem] max-h-[18rem] resize-y rounded-md border border-border bg-bg-100 px-2 py-1.5 font-mono text-[11px] text-text-100 disabled:opacity-60"}),!i&&h.jsxs("p",{className:"text-[10px] text-text-400",children:["写入到 ",h.jsx("code",{className:"font-mono",children:"<persona-dir>/CLAUDE.md"}),"。 修改只对新启动的 sub-session 生效。"]}),o&&C?h.jsxs("div",{className:"flex justify-end gap-2",children:[h.jsx("button",{type:"button",onClick:T,disabled:m,className:"rounded-sm border border-border px-2 py-1 text-[12px] text-text-200 hover:bg-bg-200 disabled:opacity-60",children:"放弃"}),h.jsx("button",{type:"button",onClick:N,disabled:m,"data-testid":"persona-personality-save-btn",className:"rounded-sm bg-accent-dim px-2 py-1 text-[12px] text-text-100 hover:opacity-90 disabled:opacity-60",children:m?"保存中…":"保存"})]}):null]})}const gre={state:"unbound",groups:[]};function vre(e,t){const[n,r]=g.useState(null);g.useEffect(()=>{if(!e)return;let l=!1;r(null);const c=async()=>{try{const f=await e.request("larkBot:status",{personaId:t});l||r(f)}catch{l||r(gre)}};c();const u=e.on("larkBot:state",f=>{const p=f;if(p.personaId!==t)return;const{personaId:m,...v}=p;r(v)}),d=e.on("daemon:connected",()=>{c()});return()=>{l=!0,u(),d()}},[e,t]);const i=g.useCallback(async()=>{e&&await e.request("larkBot:provision",{personaId:t})},[e,t]),s=g.useCallback(async()=>{e&&await e.request("larkBot:provisionCancel",{personaId:t})},[e,t]),o=g.useCallback(async l=>{e&&await e.request("larkBot:bindManual",{personaId:t,...l})},[e,t]),a=g.useCallback(async()=>{e&&await e.request("larkBot:unbind",{personaId:t})},[e,t]);return{status:n,provision:i,cancelProvision:s,bindManual:o,unbind:a}}function xre({personaId:e,open:t,onClose:n,api:r,embedded:i,onDirtyChange:s,onShareCapability:o,viewerRole:a="owner"}){const{persona:l}=yT(e),c=v6(e),u=x6(),d=_6(),{httpBaseUrl:f}=Xf(),p=$i(),m=vre(a==="guest"?null:p,e),v=g.useMemo(()=>!(l!=null&&l.public)||!f||/^https?:\/\/(127\.0\.0\.1|localhost|0\.0\.0\.0|\[?::1\]?)([:/]|$)/i.test(f)?null:`${f}/s/${e}`,[l==null?void 0:l.public,f,e]),b=g.useCallback(N=>{u(e,{public:N}).catch(T=>{Re("persona","togglePublic failed",T)})},[u,e]),x=g.useCallback(N=>{u(e,{iconKey:N}).catch(T=>{Re("persona","changeIcon failed",T)})},[u,e]),_=g.useCallback(N=>{u(e,{tool:N}).catch(T=>{Re("persona","changeTool failed",T)})},[u,e]),y=g.useCallback(()=>{l&&confirm(`删除 persona "${l.label}"?`)&&(d(e).catch(N=>{Re("persona","delete failed",N)}),n())},[l,d,e,n]),w=g.useCallback(async()=>c.loaded?c.personality:(await c.refresh()).personality,[c]),S=g.useCallback(async N=>{await u(e,{personality:N}),await c.refresh()},[u,e,c]);if(!l)return null;const C=a==="guest";return h.jsx(ore,{embedded:i,persona:{...l,skills:c.skills,plugins:c.plugins,sandboxSettings:c.sandboxSettings},open:t,onClose:n,onLoadPersonality:w,onDirtyChange:s,readOnly:C,...C?{}:{onTogglePublic:b,guestShareUrl:v,onChangeIcon:x,onChangeTool:_,onDelete:y,onSavePersonality:S,larkBot:{status:m.status,onProvision:m.provision,onCancelProvision:m.cancelProvision,onBindManual:m.bindManual,onUnbind:m.unbind},...o?{onShareCapability:o}:{}}})}function _re({api:e,open:t,onOpenChange:n,personaId:r,personaName:i,viewerRole:s}){return t?h.jsxs("div",{"data-testid":"persona-drawer",className:"fixed inset-y-0 right-0 z-50 flex w-[420px] flex-col border-l border-border bg-elevated shadow-2xl",children:[h.jsxs("div",{className:"flex items-center justify-between border-b border-border px-4 py-3",children:[h.jsxs("div",{className:"flex min-w-0 items-center gap-2 text-[13px] font-semibold text-text-100",children:[h.jsx(T_,{className:"h-4 w-4 shrink-0"}),h.jsxs("span",{className:"truncate",title:i,children:["Persona · ",i]})]}),h.jsx("button",{type:"button",onClick:()=>n(!1),className:"flex h-7 w-7 items-center justify-center rounded text-text-400 hover:bg-bg-200 hover:text-text-100","aria-label":"Close drawer",children:h.jsx(Rn,{className:"h-4 w-4"})})]}),h.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:h.jsx(xre,{personaId:r,open:!0,onClose:()=>n(!1),api:e,embedded:!0,...s?{viewerRole:s}:{}},r)})]}):null}function yre(e){try{const t=new URL(e);return t.protocol==="ws:"?t.protocol="http:":t.protocol==="wss:"&&(t.protocol="https:"),`${t.protocol}//${t.host}`}catch{return e}}function bre(e,t){try{const n=new URL(e),r=new URL(t);return n.protocol=r.protocol,n.host=r.host,n.toString()}catch{return e}}async function n1(e,t,n,r,i){const s=await e.attachmentSignUrl({sessionId:n,relPath:r,...i!==void 0?{ttlSeconds:i}:{}});return bre(s.url,yre(t.url))}async function wre(e,t,n,r,i=60){const s=window.open("about:blank","_blank");try{const o=await n1(e,t,n,r,i);s?s.location.href=o:window.open(o,"_blank")}catch(o){throw s&&s.close(),o}}async function Sre(e){var t;try{if((t=navigator.clipboard)!=null&&t.writeText)return await navigator.clipboard.writeText(e),!0}catch{}try{const n=document.createElement("textarea");n.value=e,n.style.position="fixed",n.style.left="-9999px",n.style.top="0",n.setAttribute("readonly",""),document.body.appendChild(n),n.select();const r=document.execCommand("copy");return document.body.removeChild(n),r}catch{return!1}}const kre={...tu,h1:({node:e,...t})=>h.jsx("h1",{...t,className:"mt-4 mb-3 text-[18px] font-semibold leading-tight text-text-100"}),h2:({node:e,...t})=>h.jsx("h2",{...t,className:"mt-4 mb-2 text-[16px] font-semibold leading-tight text-text-100"}),h3:({node:e,...t})=>h.jsx("h3",{...t,className:"mt-3 mb-2 text-[14px] font-semibold leading-tight text-text-100"}),h4:({node:e,...t})=>h.jsx("h4",{...t,className:"mt-3 mb-1 text-[13px] font-semibold text-text-100"}),h5:({node:e,...t})=>h.jsx("h5",{...t,className:"mt-2 mb-1 text-[12px] font-semibold text-text-100"}),h6:({node:e,...t})=>h.jsx("h6",{...t,className:"mt-2 mb-1 text-[12px] font-semibold text-text-300"}),p:({node:e,...t})=>h.jsx("p",{...t,className:"my-2 leading-relaxed"}),ul:({node:e,...t})=>h.jsx("ul",{...t,className:"my-2 list-disc space-y-1 pl-5"}),ol:({node:e,...t})=>h.jsx("ol",{...t,className:"my-2 list-decimal space-y-1 pl-5"}),li:({node:e,...t})=>h.jsx("li",{...t,className:"leading-relaxed"}),blockquote:({node:e,...t})=>h.jsx("blockquote",{...t,className:"my-2 border-l-2 border-border pl-3 italic text-text-300"}),code:({node:e,className:t,children:n,...r})=>t?h.jsx("code",{...r,className:`${t} font-mono text-[12px]`,children:n}):h.jsx("code",{...r,className:"rounded bg-bg-50 px-1 py-0.5 font-mono text-[12px] text-text-100",children:n}),pre:({node:e,...t})=>h.jsx("pre",{...t,className:"my-2 overflow-auto rounded border border-border bg-bg-0 p-3 text-[12px] font-mono text-text-100"}),hr:({node:e,...t})=>h.jsx("hr",{...t,className:"my-3 border-border"}),table:({node:e,...t})=>h.jsx("table",{...t,className:"my-2 w-full border-collapse text-[12px]"}),thead:({node:e,...t})=>h.jsx("thead",{...t,className:"bg-bg-50"}),th:({node:e,...t})=>h.jsx("th",{...t,className:"border border-border px-2 py-1 text-left font-semibold"}),td:({node:e,...t})=>h.jsx("td",{...t,className:"border border-border px-2 py-1"}),strong:({node:e,...t})=>h.jsx("strong",{...t,className:"font-semibold text-text-100"}),em:({node:e,...t})=>h.jsx("em",{...t,className:"italic"})};function Cre(e){const t=e.split("/");return t[t.length-1]||e}function d5({relPath:e,loadMarkdown:t,headerRight:n,showTitleBar:r=!1}){const[i,s]=g.useState(null),[o,a]=g.useState(null),[l,c]=g.useState(!1);return g.useEffect(()=>{if(!e)return;let u=!1;return c(!0),a(null),s(null),(async()=>{try{const d=await t(e);if(u)return;s(d)}catch(d){if(u)return;a(d.message||String(d))}finally{u||c(!1)}})(),()=>{u=!0}},[e,t]),h.jsxs("div",{className:"flex flex-col h-full",children:[r&&e?h.jsxs("div",{className:"flex items-center justify-between border-b border-border px-3 py-2",children:[h.jsx("div",{"data-testid":"md-preview-title",className:"truncate text-[13px] font-medium text-text-100",title:e,children:Cre(e)}),h.jsx("div",{className:"flex items-center gap-1",children:n})]}):null,h.jsx("div",{className:"flex-1 overflow-auto px-4 py-3 text-[13px] text-text-100",children:l?h.jsx("div",{"data-testid":"md-preview-loading",className:"text-text-400",children:"Loading…"}):o?h.jsx("div",{"data-testid":"md-preview-error",className:"text-destructive whitespace-pre-wrap",children:o}):i!==null?h.jsx("div",{"data-testid":"md-preview-content",className:"max-w-none",children:h.jsx(Qc,{remarkPlugins:[eu],components:kre,children:i})}):null})]})}function Ere({open:e,onOpenChange:t,relPath:n,loadMarkdown:r,onShare:i}){return e?h.jsx("div",{"data-testid":"md-preview-drawer",className:"fixed inset-y-0 right-0 z-50 flex w-1/2 max-w-[900px] flex-col border-l border-border bg-elevated shadow-2xl",children:h.jsx(d5,{relPath:n,loadMarkdown:r,showTitleBar:!0,headerRight:h.jsxs(h.Fragment,{children:[i?h.jsx("button",{type:"button","data-testid":"md-preview-share","aria-label":"Share rendered preview link",onClick:i,className:"inline-flex h-6 w-6 items-center justify-center rounded text-text-400 hover:bg-bg-50 hover:text-text-200",children:h.jsx(ET,{className:"h-4 w-4"})}):null,h.jsx("button",{type:"button","aria-label":"Close preview",onClick:()=>t(!1),className:"inline-flex h-6 w-6 items-center justify-center rounded text-text-400 hover:bg-bg-50 hover:text-text-200",children:h.jsx(Rn,{className:"h-4 w-4"})})]})})}):null}function Nre({left:e,right:t,stage:n,onExpand:r,onCollapse:i}){const s=n==="stopped",[o,a]=g.useState(!1);async function l(){if(!o){a(!0);try{await r()}catch{}finally{a(!1)}}}async function c(){if(!o){a(!0);try{await i()}catch{}finally{a(!1)}}}return h.jsxs("div",{className:"flex h-full w-full min-h-0","data-testid":"two-pane-layout",children:[h.jsxs("div",{className:"relative flex min-w-0 flex-1 flex-col","data-testid":"two-pane-left",children:[s&&h.jsx("button",{type:"button",disabled:o,className:"absolute right-14 top-2 z-10 rounded border border-border bg-elevated px-2 py-1 text-[12px] text-text-100 hover:bg-bg-200 disabled:opacity-50 disabled:cursor-not-allowed",onClick:l,children:o?"启动中…":"展开预览"}),e]}),!s&&h.jsxs("div",{className:"flex w-1/2 min-w-[320px] flex-col border-l border-bg-200","data-testid":"two-pane-right",children:[h.jsx("div",{className:"flex items-center justify-end gap-2 border-b border-bg-200 bg-bg-50 px-2 py-1",children:h.jsx("button",{type:"button",disabled:o,className:"rounded px-2 py-1 text-[12px] text-text-300 hover:bg-bg-100 disabled:opacity-50",onClick:c,children:"收起预览"})}),h.jsx("div",{className:"min-h-0 flex-1",children:t})]})]})}const Tre=6173,Pre=6182;function Ire({open:e,onOpenChange:t,projectName:n,currentPort:r,allUsedPorts:i,onUpdate:s}){const o=[];for(let v=Tre;v<=Pre;v++)(v===r||!i.includes(v))&&o.push(v);const[a,l]=g.useState(r),[c,u]=g.useState(!1),[d,f]=g.useState(null),p=a!==r&&!c;async function m(){if(p){u(!0),f(null);try{await s(a),t(!1)}catch(v){f((v==null?void 0:v.message)??String(v))}finally{u(!1)}}}return h.jsx(e1,{open:e,onOpenChange:t,children:h.jsxs(Pp,{className:"max-w-md",children:[h.jsxs(Ip,{children:[h.jsxs(Rp,{children:["改端口 · ",n]}),h.jsxs(u5,{children:["手改通常发生在系统其他进程占了默认分配的端口、dev server 起不来时。 提交后 daemon 会停 dev server → 写 ",h.jsx("code",{className:"mx-1 rounded bg-bg-100 px-1 py-0.5 text-[11px]",children:".clawd-project.json"})," → 用新端口重新起。"]})]}),h.jsxs("div",{className:"flex flex-col gap-2",children:[h.jsx("label",{className:"text-xs text-text-400",children:"新端口(仅显示段内可用 + 当前端口)"}),h.jsx("select",{className:"h-9 rounded-md border border-border bg-elevated px-3 py-1 text-sm text-text-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent",value:a,onChange:v=>l(Number(v.target.value)),disabled:c,children:o.map(v=>h.jsxs("option",{value:v,children:[v,v===r?"(当前)":""]},v))}),o.length===1&&h.jsx("div",{className:"text-[11px] text-text-400",children:"端口段已全被其它 project 占用,没有可换的;先删一个 idle project 释放端口。"}),d&&h.jsx("div",{className:"rounded border border-destructive/30 bg-destructive/5 px-3 py-2 text-[12px] text-destructive",children:d})]}),h.jsxs(t1,{children:[h.jsx(ri,{variant:"ghost",onClick:()=>t(!1),disabled:c,children:"取消"}),h.jsx(ri,{onClick:m,disabled:!p,children:c?"应用中…":"应用新端口"})]})]})})}const CC=[{stage:"build",label:"构建"},{stage:"deploy",label:"部署到阿里云"},{stage:"verify",label:"验证可访问性"}];function Rre({currentStage:e,onCancel:t}){const n=CC.findIndex(r=>r.stage===e);return h.jsxs("div",{"data-testid":"publish-progress",className:"flex items-center gap-3 border-b border-bg-200 bg-bg-50 px-3 py-1.5 text-[12px]",children:[CC.map((r,i)=>{const s=i<n,o=i===n,a=s?"text-text-300":o?"text-text-200":"text-text-500/50";return h.jsxs("span",{className:`flex items-center gap-1 ${a}`,children:[s?h.jsx(Zf,{className:"size-3.5"}):o?h.jsx(rr,{className:"size-3.5 animate-spin"}):h.jsx(ST,{className:"size-3.5"}),h.jsxs("span",{children:[r.label,o?"中…":""]})]},r.stage)}),h.jsx("button",{type:"button",onClick:t,className:"ml-auto rounded px-2 py-0.5 text-[11px] text-text-400 hover:bg-bg-100 hover:text-text-200",children:"取消"})]})}const Mre={build:"构建",deploy:"部署",verify:"验证"};function Are({stage:e,onRetry:t,onDismiss:n}){return h.jsxs("div",{"data-testid":"publish-interrupted-banner",className:"flex items-center gap-2 border-b border-yellow-400/40 bg-yellow-400/10 px-3 py-1.5 text-[12px]",children:[h.jsx(Uc,{className:"size-3.5 text-yellow-500"}),h.jsxs("span",{className:"text-text-200",children:["上次发布在 ",h.jsxs("strong",{className:"font-medium",children:["[",Mre[e],"]"]})," ","阶段被中断(daemon 重启)"]}),h.jsx("button",{type:"button",onClick:t,className:"ml-auto rounded bg-accent-main-100 px-2 py-0.5 text-[11px] text-oncolor-100 hover:opacity-90",children:"重新发布"}),h.jsx("button",{type:"button",onClick:n,className:"rounded px-2 py-0.5 text-[11px] text-text-400 hover:bg-bg-100 hover:text-text-200",children:"取消"})]})}const jre={build:"构建",deploy:"部署",verify:"验证",unknown:"未知"};function Lre({stage:e,onFocusChat:t,onClose:n}){return h.jsxs("div",{"data-testid":"publish-failed-banner",className:"flex items-center gap-2 border-b border-destructive/40 bg-destructive/10 px-3 py-1.5 text-[12px]",children:[h.jsx(Ls,{className:"size-3.5 text-destructive"}),h.jsxs("button",{type:"button",onClick:t,className:"flex-1 text-left text-text-200 hover:underline",children:["发布失败:",h.jsxs("strong",{className:"font-medium",children:["[",jre[e],"]"]})," ","已通知 assistant 接管 →"]}),h.jsx("button",{type:"button",onClick:n,"aria-label":"关闭失败提示",className:"rounded p-0.5 text-text-400 hover:bg-bg-100 hover:text-text-200",children:h.jsx(Rn,{className:"size-3.5"})})]})}const EC={"install-pending":{label:"等装依赖…",step:"1/3"},installing:{label:"安装依赖中…(可能要几十秒到几分钟)",step:"2/3"},"starting-dev-server":{label:"启动 dev server…(等监听端口才挂 iframe)",step:"3/3"}};function Dre({project:e,previewHost:t,previewScheme:n,onUpdatePort:r,allUsedPorts:i,publishSlot:s,publishInFlightStage:o,onDismissPublishJob:a,onRetryPublish:l,publishFailureBanner:c,onPublishFailureBannerClose:u,onPublishFailureBannerFocusChat:d}){var x,_;const[f,p]=g.useState(!1);if(!e)return h.jsx("div",{className:"flex h-full w-full items-center justify-center p-6 text-center text-[13px] text-text-400",children:"未绑定 project"});const m=e.stage??(e.isRunning?"running":"stopped"),v=t?`${n}://${t}/preview/${e.port}/`:null,b=e.prodUrl??null;return h.jsxs("div",{className:"flex h-full w-full flex-col","data-testid":"preview-pane",children:[h.jsxs("header",{className:"flex items-center justify-between gap-2 border-b border-bg-200 bg-bg-50 px-3 py-1.5",children:[h.jsxs("div",{className:"flex items-center gap-2 text-[12px]",children:[h.jsx("span",{className:"font-medium text-text-200",children:e.name}),h.jsx("span",{className:"rounded bg-bg-100 px-1.5 py-0.5 text-[11px] text-text-400",children:e.port}),h.jsx("span",{className:"text-[10px] uppercase tracking-wider text-text-500",children:m==="running"?"dev":m})]}),h.jsxs("div",{className:"flex items-center gap-2",children:[b?h.jsxs("a",{href:b,target:"_blank",rel:"noopener noreferrer",title:`打开线上:${b}`,className:"inline-flex items-center gap-1 rounded border border-bg-200 px-2 py-0.5 text-[11px] text-text-300 hover:bg-bg-100",children:[h.jsx(Hc,{className:"size-3"}),"打开线上"]}):null,s,h.jsxs(MI,{children:[h.jsx(AI,{asChild:!0,children:h.jsx("button",{type:"button","aria-label":"Project settings",className:"rounded p-1 text-text-400 hover:bg-bg-100",children:h.jsx(Qz,{className:"size-3.5"})})}),h.jsxs(Y_,{align:"end",children:[h.jsx(cs,{onSelect:()=>p(!0),children:"Update Port…"}),h.jsxs(cs,{disabled:!0,title:"rename not supported yet",onSelect:y=>y.preventDefault(),children:["Name: ",e.name]})]})]})]})]}),c?h.jsx(Lre,{stage:c.stage,onClose:()=>u==null?void 0:u(),onFocusChat:()=>d==null?void 0:d()}):null,((x=e.publishJob)==null?void 0:x.status)==="in-flight"?h.jsx(Rre,{currentStage:o??e.publishJob.stage,onCancel:()=>void(a==null?void 0:a())}):null,((_=e.publishJob)==null?void 0:_.status)==="interrupted"?h.jsx(Are,{stage:e.publishJob.stage,onRetry:()=>void(l==null?void 0:l()),onDismiss:()=>void(a==null?void 0:a())}):null,h.jsx("div",{className:"min-h-0 flex-1",children:m==="failed"?h.jsx(Ore,{reason:e.stageReason}):m==="stopped"?null:m==="running"?v?h.jsx("iframe",{"data-testid":"preview-iframe",className:"size-full border-0 bg-white",src:v,title:"preview"}):h.jsx(NC,{label:"等 tunnel 起来…",step:"-"}):h.jsx(NC,{label:EC[m].label,step:EC[m].step})}),h.jsx(Ire,{open:f,onOpenChange:p,projectName:e.name,currentPort:e.port,allUsedPorts:i,onUpdate:async y=>{await r(y)}})]})}function NC({label:e,step:t}){return h.jsxs("div",{"data-testid":"preview-spinner",className:"flex h-full w-full flex-col items-center justify-center gap-3 p-6 text-center",children:[h.jsx(rr,{className:"size-6 animate-spin text-accent-main-100"}),h.jsx("div",{className:"text-[13px] text-text-200",children:e}),h.jsx("div",{className:"text-[11px] uppercase tracking-wider text-text-500",children:t}),h.jsx("div",{className:"mt-2 max-w-[300px] text-[11px] text-text-500",children:"左侧 chat 可看 assistant 详细进度"})]})}function Ore({reason:e}){return h.jsxs("div",{"data-testid":"preview-failed",className:"flex h-full w-full flex-col items-center justify-center gap-3 p-6 text-center",children:[h.jsx(Ls,{className:"size-6 text-destructive"}),h.jsx("div",{className:"text-[13px] text-text-200",children:"project 启动失败"}),h.jsx("div",{className:"max-w-[400px] text-[12px] text-text-400",children:e??"未知原因 —— 看 ~/.clawd/clawd.log 排查"}),h.jsx("div",{className:"mt-1 max-w-[300px] text-[11px] text-text-500",children:"左侧 chat 可看 assistant 详细进度 / 跟它说怎么修"})]})}function Bre({error:e,onClose:t}){const[n,r]=g.useState(!1),i=async()=>{var a;if(!e)return;const s=e.message;let o=!1;try{(a=navigator.clipboard)!=null&&a.writeText&&(await navigator.clipboard.writeText(s),o=!0)}catch{o=!1}if(!o){const l=document.createElement("textarea");l.value=s,l.style.position="fixed",l.style.opacity="0",document.body.appendChild(l),l.select();try{document.execCommand("copy"),o=!0}catch{o=!1}finally{document.body.removeChild(l)}}o&&(r(!0),setTimeout(()=>r(!1),1500))};return h.jsx(e1,{open:!!e,onOpenChange:s=>{s||(r(!1),t())},children:h.jsxs(Pp,{className:"max-w-lg",children:[h.jsx(Ip,{children:h.jsx(Rp,{children:(e==null?void 0:e.title)??"错误"})}),h.jsx("pre",{"data-testid":"rpc-error-message",className:"max-h-72 overflow-auto whitespace-pre-wrap break-words rounded border border-bg-200 bg-bg-50 px-3 py-2 text-[12px] text-text-200",children:(e==null?void 0:e.message)??""}),h.jsxs(t1,{children:[h.jsx(ri,{variant:"ghost",onClick:i,className:"gap-1.5",children:n?h.jsxs(h.Fragment,{children:[h.jsx(ol,{className:"size-3.5"}),"已复制"]}):h.jsxs(h.Fragment,{children:[h.jsx(mu,{className:"size-3.5"}),"复制"]})}),h.jsx(ri,{onClick:t,children:"关闭"})]})]})})}function zre(e,t){for(const n of[e,t])if(n)try{const r=new URL(n),i=r.protocol==="https:"||r.protocol==="wss:"?"https":"http";return{host:r.host,scheme:i}}catch{}return{host:null,scheme:"https"}}const $re={codex:"on-request",claude:"bypassPermissions"};function Fre(e){const t={cwd:e.cwd,permissionMode:e.sourcePermissionMode??$re[e.sourceTool??"claude"]??"bypassPermissions",forkedFromSessionId:e.sourceSessionId};return e.sourceOwnerPersonaId&&(t.ownerPersonaId=e.sourceOwnerPersonaId),e.sourceTool&&(t.tool=e.sourceTool),t}async function Hre(e,t,n,r={}){if(!t.toolSessionId)return null;const i=await e.sessionCreate({...Fre({cwd:t.cwd,sourceSessionId:t.sessionId,sourcePermissionMode:t.permissionMode,sourceOwnerPersonaId:t.ownerPersonaId,sourceTool:t.tool}),...r.ephemeral?{ephemeral:!0}:{}});try{const{forkedToolSessionId:s}=await e.sessionFork({cwd:t.cwd,toolSessionId:t.toolSessionId,messageUuid:n,targetCwd:i.cwd});await e.sessionResume(i.sessionId,s)}catch(s){throw e.sessionDelete(i.sessionId).catch(o=>Re("quick-ask","fork rollback failed",o)),s}return i}async function Ure(e,t,n){return Hre(e,t,n,{ephemeral:!0})}function Rd(e){return e!=null&&e.ephemeral!==!1}async function Wre(e,t){return!t.stillEphemeral||!t.nextHold?!1:(await e.sessionUpdate(t.sessionId,{ephemeral:!1}),!0)}const Vre=300;function qre(e){return e&&typeof e=="object"&&"value"in e?e.value:e}function h5(e,t){const n=l_(),[r,i]=g.useState(null),s=g.useRef(null);g.useEffect(()=>{let a=!1;return(async()=>{try{const l=await n.kv.get(e);if(a)return;const c=qre(l);typeof c=="number"&&Number.isFinite(c)&&c>0?i(c):i(t)}catch{a||i(t)}})(),()=>{a=!0}},[n,e,t]);const o=g.useCallback(a=>{s.current&&clearTimeout(s.current),s.current=setTimeout(()=>{s.current=null,n.kv.set(e,a).catch(()=>{})},Vre)},[n,e]);return g.useEffect(()=>()=>{s.current&&(clearTimeout(s.current),s.current=null)},[]),{initialSize:r??t,setSize:o,loading:r===null}}function Kre(){return{quickAsk:null,mds:[],active:null}}function Gre(e,t){return{...e,quickAsk:{sessionId:t.sessionId,ephemeral:!0},active:"quick-ask"}}function Xre(e,t){const n=e.mds.includes(t);return{...e,mds:n?e.mds:[...e.mds,t],active:{kind:"md",relPath:t}}}function Yre(e){if(!e.quickAsk)return e;const t=e.active==="quick-ask",n=e.mds[0],r=t?n?{kind:"md",relPath:n}:null:e.active;return{...e,quickAsk:null,active:r}}function Zre(e){return e.quickAsk?{...e,quickAsk:{...e.quickAsk,ephemeral:!1}}:e}function Qre(e,t){const n=e.mds.indexOf(t);if(n<0)return e;const r=e.mds.filter(l=>l!==t);if(!(e.active!==null&&e.active!=="quick-ask"&&e.active.relPath===t))return{...e,mds:r};const s=r[n],o=n>0?r[n-1]:void 0;let a=null;return s?a={kind:"md",relPath:s}:o?a={kind:"md",relPath:o}:e.quickAsk&&(a="quick-ask"),{...e,mds:r,active:a}}function Jre(e,t){return{...e,active:t}}function eie(e,t){return e===null||t===null||e==="quick-ask"||t==="quick-ask"?e===t:e.relPath===t.relPath}function f5(e){return e.quickAsk!==null||e.mds.length>0}function tie(e){return e.split("/").pop()||e}function nie({state:e,api:t,onSwitchTab:n,onCloseQuickAsk:r,onCloseMd:i,loadMarkdown:s,quickAskSession:o,onToggleHold:a,holdIds:l}){if(!f5(e))return null;const c=[];e.quickAsk&&c.push({id:"quick-ask",label:"问一下",title:"问一下",icon:h.jsx(qh,{className:"w-3.5 h-3.5"})});for(const u of e.mds)c.push({id:{kind:"md",relPath:u},label:tie(u),title:u,icon:h.jsx(Ds,{className:"w-3.5 h-3.5"})});return h.jsxs("div",{className:"flex flex-col h-full bg-bg-0 border-l border-text-100/10",children:[h.jsx(Q_,{delayDuration:200,skipDelayDuration:100,children:h.jsx("div",{className:["flex items-stretch h-9 border-b border-text-100/10 shrink-0 overflow-x-auto","[scrollbar-width:none] [-ms-overflow-style:none]","[&::-webkit-scrollbar]:hidden"].join(" "),role:"tablist",children:c.map(u=>{const d=eie(e.active,u.id),f=u.id==="quick-ask"?"quick-ask":`md:${u.id.relPath}`;return h.jsxs(J_,{children:[h.jsx(ey,{asChild:!0,children:h.jsxs("div",{role:"tab","aria-selected":d,"data-tab-title":u.title,onClick:()=>n(u.id),className:["group relative flex items-center gap-2 px-3 h-full cursor-pointer select-none","text-[12px] max-w-[180px] shrink-0 transition-colors duration-100",d?"text-text-100":"text-text-400 hover:text-text-100 hover:bg-text-100/[0.04]"].join(" "),children:[u.icon,h.jsx("span",{className:"truncate",children:u.label}),h.jsx("button",{type:"button","aria-label":`关闭 ${u.label}`,className:["ml-1 rounded p-0.5 shrink-0 transition-opacity","hover:bg-text-100/10",d?"opacity-70 hover:opacity-100":"opacity-0 group-hover:opacity-70"].join(" "),onClick:p=>{p.stopPropagation(),u.id==="quick-ask"?r():i(u.id.relPath)},children:h.jsx(Rn,{className:"w-3 h-3"})}),d?h.jsx("span",{"aria-hidden":"true",className:"absolute left-2 right-2 -bottom-px h-[2px] rounded-full bg-accent"}):null]})}),h.jsx(hp,{side:"bottom",align:"start",className:"max-w-sm break-all",children:u.title})]},f)})})}),h.jsxs("div",{className:"flex-1 min-h-0 overflow-hidden relative",children:[e.quickAsk&&o?h.jsx("div",{className:"absolute inset-0",style:{display:e.active==="quick-ask"?"block":"none"},children:h.jsx(iie,{session:o,api:t,holdIds:l,...a?{onToggleHold:a}:{}})}):null,e.mds.map(u=>{const d=e.active!==null&&e.active!=="quick-ask"&&e.active.relPath===u;return h.jsx("div",{className:"absolute inset-0",style:{display:d?"block":"none"},children:h.jsx(d5,{relPath:u,loadMarkdown:s,showTitleBar:!1})},`md-body:${u}`)})]})]})}function rie({state:e,extras:t}){const{api:n,session:r,holdIds:i,onToggleHold:s}=t,o=$i(),[a,l]=g.useState(Kre()),c=g.useRef(a);c.current=a;const u=g.useRef(!1),d=g.useCallback(async N=>{const T=c.current.quickAsk,M=await Ure(n,r,N);if(M){if(u.current){n.sessionDelete(M.sessionId).catch(()=>{});return}Rd(T)&&n.sessionDelete(T.sessionId).catch(()=>{}),l(P=>Gre(P,{sessionId:M.sessionId}))}},[n,r]),f=g.useCallback(async(N,T)=>{const M=c.current.quickAsk,P=(M==null?void 0:M.sessionId)===N;try{await Wre(n,{sessionId:N,stillEphemeral:P&&Rd(M),nextHold:T})&&l(R=>Zre(R))}catch(D){Re("quick-ask","promote failed",D);return}s==null||s(N,T)},[n,s]),p=g.useCallback(N=>{l(T=>Xre(T,N))},[]),m=g.useCallback(N=>{l(T=>Jre(T,N))},[]),v=g.useCallback(()=>{const N=c.current.quickAsk;Rd(N)&&n.sessionDelete(N.sessionId).catch(()=>{}),l(T=>Yre(T))},[n]),b=g.useCallback(N=>{l(T=>Qre(T,N))},[]);g.useEffect(()=>()=>{u.current=!0;const N=c.current.quickAsk;Rd(N)&&n.sessionDelete(N.sessionId).catch(()=>{})},[]);const x=oi("sessions")??[],_=a.quickAsk?x.find(N=>N.sessionId===a.quickAsk.sessionId)??{sessionId:a.quickAsk.sessionId,cwd:r.cwd,tool:r.tool}:null,y=g.useCallback(async N=>{const T=await n1(n,o,r.sessionId,N,60),M=await fetch(T);if(!M.ok)throw new Error(`fetch ${M.status} ${M.statusText}`);return M.text()},[n,o,r.sessionId]),w=h.jsx(r1,{state:e,extras:t,onQuickAskInternal:d,onPreviewMdInternal:p}),{initialSize:S,setSize:C}=h5("chat-panel-right-slot-width",480);return f5(a)?h.jsxs(cy,{orientation:"horizontal",className:"flex-1 flex min-w-0 min-h-0",children:[h.jsx(Yc,{id:"chat",minSize:"400px",children:w}),h.jsx(dy,{className:"w-1 bg-text-100/10 hover:bg-text-100/25 transition-colors cursor-col-resize"}),h.jsx(Yc,{id:"right-slot",defaultSize:`${S}px`,minSize:"360px",maxSize:"800px",onResize:N=>C(N.inPixels),children:h.jsx(nie,{state:a,api:n,onSwitchTab:m,onCloseQuickAsk:v,onCloseMd:b,loadMarkdown:y,quickAskSession:_,holdIds:i,onToggleHold:f})})]}):w}function iie({session:e,api:t,holdIds:n,onToggleHold:r}){const i=qA(e.sessionId);return h.jsx(r1,{state:i,extras:{session:e,api:t,holdIds:n,...r?{onToggleHold:r}:{}}})}function sie({extras:e}){const t=qA(e.session.sessionId);if(e.session.appBuilderProject){const n=h.jsx(r1,{state:t,extras:e});return h.jsx(oie,{state:t,chat:n,extras:e})}return h.jsx(rie,{state:t,extras:e})}function oie({state:e,chat:t,extras:n}){var T;const r=oi("daemon-info"),i=$i(),s=n.api,o=n.session,a=o.appBuilderProject,[l,c]=g.useState(null),u=g.useCallback(()=>{s.appBuilderGetProject(o.sessionId).then(M=>c(M.project)).catch(()=>c(null))},[s,o.sessionId]);g.useEffect(()=>{u()},[u]);const[d,f]=g.useState([]),p=g.useCallback(()=>{s.appBuilderListProjects().then(M=>f(M.projects)).catch(()=>f([]))},[s]);g.useEffect(()=>{p()},[p]),g.useEffect(()=>i.on("appBuilder:project-updated",P=>{const D=P;D!=null&&D.project&&(D.project.name===a&&c(D.project),f(R=>{const I=R.findIndex(z=>z.name===D.project.name);if(I<0)return[...R,D.project];const O=R.slice();return O[I]=D.project,O}))}),[i,a]);const{host:m,scheme:v}=zre(i.url,r==null?void 0:r.tunnelUrl),[b,x]=g.useState(void 0),[_,y]=g.useState(null);g.useEffect(()=>{const M=i.on("appBuilder:publish-progress",D=>{const R=D;!R||R.name!==a||R.status==="started"&&x(R.stage)}),P=i.on("appBuilder:publish-failed",D=>{const R=D;!R||R.name!==a||(x(void 0),y({stage:R.stage}))});return()=>{M(),P()}},[i,a]),g.useEffect(()=>{x(void 0),y(null)},[a]);const[w,S]=g.useState(null),C=h.jsx("button",{type:"button",className:"rounded bg-accent-main-100 px-2.5 py-1 text-[12px] text-oncolor-100 hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-50",disabled:((T=l==null?void 0:l.publishJob)==null?void 0:T.status)==="in-flight",onClick:async()=>{try{await s.appBuilderPublish(a)}catch(M){S({title:"发布请求失败",message:(M==null?void 0:M.message)??String(M)})}},children:"发布上线"}),N=(l==null?void 0:l.stage)??(l!=null&&l.isRunning?"running":"stopped");return h.jsxs(h.Fragment,{children:[h.jsx(Nre,{left:t,stage:N,onExpand:async()=>{await s.appBuilderStartDevServer(o.sessionId)},onCollapse:async()=>{await s.appBuilderStopDevServer(o.sessionId)},right:h.jsx(Dre,{project:l,previewHost:m,previewScheme:v,allUsedPorts:d.map(M=>M.port),onUpdatePort:async M=>{await s.appBuilderUpdateProjectPort(a,M),p()},publishSlot:C,publishInFlightStage:b,onDismissPublishJob:async()=>{try{await s.appBuilderDismissPublishJob(a)}catch(M){S({title:"取消发布失败",message:(M==null?void 0:M.message)??String(M)})}},onRetryPublish:async()=>{try{await s.appBuilderPublish(a)}catch(M){S({title:"重新发布失败",message:(M==null?void 0:M.message)??String(M)})}},publishFailureBanner:_,onPublishFailureBannerClose:()=>y(null),onPublishFailureBannerFocusChat:()=>{}})}),h.jsx(Bre,{error:w,onClose:()=>S(null)})]})}function aie({headerMeta:e,connState:t,models:n,liveGitBranch:r,liveWorktreeRoot:i,onOpenConfig:s,onForceStop:o,cronActiveCount:a,onCronClick:l,lines:c,pendingPermissions:u,procAlive:d,rewindableUserMessageIds:f,onPermissionRespond:p,onPermissionInterrupt:m,onRewind:v,onFork:b,onQuickAsk:x,topSlot:_,realtimeQuestionAnswers:y,onSubmitQuestion:w,onCancelQuestion:S,liveQuestionToolUseIds:C,api:N,cwd:T,tool:M,sessionKey:P,onSend:D,awaitingUser:R,onAbort:I,onNewSession:O,onClearSession:z,chatRootRef:$,chatBodyRef:F,topSentinelRef:L,drawers:B,xtermSlot:E,fileSharingScope:H,onShareFile:q,onOpenInTab:A,onPreviewMarkdown:re,onOpenFiles:oe,onTogglePin:V,isHolded:pe,onToggleHold:Oe,personaName:ie,onOpenPersona:Ae}){return h.jsx(PZ,{children:h.jsxs("div",{ref:$,"data-cc-chat-root":"",className:"flex flex-col h-full bg-bg-0",children:[h.jsx(yQ,{meta:e,...M?{tool:M}:{},connState:t,...n?{models:n}:{},...r!==void 0?{liveGitBranch:r}:{},...i!==void 0?{liveWorktreeRoot:i}:{},...s?{onOpenConfig:s}:{},...o?{onForceStop:o}:{},cronActiveCount:a,...l?{onCronClick:l}:{},...oe?{onOpenFiles:oe}:{},...V?{onTogglePin:V}:{},isHolded:pe??!1,...Oe?{onToggleHold:Oe}:{},...ie?{personaName:ie}:{},...Ae?{onOpenPersona:Ae}:{}}),h.jsxs("div",{ref:F,"data-testid":"chat-body",className:"flex-1 overflow-y-auto min-h-0",style:{overflowAnchor:"none"},children:[L?h.jsx("div",{ref:L,"data-testid":"top-sentinel","aria-hidden":"true",style:{height:1}}):null,h.jsx(EM,{lines:c,...p?{onPermissionRespond:p}:{},...m&&d?{onPermissionInterrupt:m}:{},topSlot:_,...v?{onRewind:v}:{},rewindableUserMessageIds:f,...b?{onFork:b}:{},...x?{onQuickAsk:x}:{},realtimeQuestionAnswers:y,onSubmitQuestion:w,...S?{onCancelQuestion:S}:{},liveQuestionToolUseIds:C,...H?{fileSharingScope:H}:{},...q?{onShareFile:q}:{},...A?{onOpenInTab:A}:{},...re?{onPreviewMarkdown:re}:{}})]}),E,e.larkChatName?h.jsx("div",{className:"mx-3 mb-3 rounded-lg border border-border bg-bg-200 px-3 py-2 text-[12px] text-text-400","data-testid":"lark-readonly-notice",children:e.larkChatType==="p2p"?`此会话由与「${e.larkChatName}」的飞书私聊驱动——对方消息触发,这里仅供观察。`:`此会话由飞书群「${e.larkChatName}」驱动——群成员 @ bot 提问触发,这里仅供观察。`}):h.jsx(xQ,{meta:e,...N?{api:N}:{},cwd:T,...M?{tool:M}:{},sessionKey:P,onSend:D,awaitingUser:R,...I?{onAbort:I}:{},...O?{onNewSession:O}:{},...z?{onClearSession:z}:{}}),B]})})}function r1({state:e,extras:t,onQuickAskInternal:n,onPreviewMdInternal:r}){const{session:i,api:s,models:o,liveGitBranch:a,liveWorktreeRoot:l,onNewSession:c,onTurnEnd:u,onOpenConfig:d,onFork:f,onQuickAsk:p,viewerRole:m,holdIds:v,onToggleHold:b}=t,{capabilities:x}=Gy(i.tool||"claude"),_=(x==null?void 0:x.features)??mT(i.tool),[y,w]=g.useState(null),[S,C]=g.useState(!1),[N,T]=g.useState(!1),M=Xf(),P=!!s&&M.actionsLevel==="owner"&&_.fileSharing,D=yT(i.ownerPersonaId??null).persona,R=(D==null?void 0:D.label)??null,I=!!R&&!!i.ownerPersonaId,O=g.useCallback(()=>{T(!1),C(!0)},[]),z=g.useCallback(()=>{C(!1),T(!0)},[]),$=g.useCallback((Z,xe)=>{w({kind:Z,text:xe}),setTimeout(()=>{w(ye=>(ye==null?void 0:ye.text)===xe?null:ye)},2e3)},[]),F=$i(),L=GB(),B=VA(i.sessionId,i.toolSessionId),{events:E,pendingQuestions:H,clearQuestion:q,markQuestionSubmitted:A,status:re}=B,oe=e.historyLoading,V=eA(re);g.useEffect(()=>{Re("chat-panel","sessionStatus",{sessionId:i.sessionId,sessionStatus:re,procAlive:V})},[re,V,i.sessionId]);const pe=e.lines,Oe=e.pendingPermissions,ie=Oe[0]??null,Ae=g.useMemo(()=>LU(E),[E]),[Fe,We]=g.useState(!1),[ge,qe]=g.useState(null),[Gt,wt]=g.useState(()=>new Set);MU(s,i.sessionId,i.toolSessionId,_.observe);const Rt=g.useRef(i.sessionId);g.useEffect(()=>{if(Rt.current=i.sessionId,!_.rewind){qe(null);return}let Z=!1;return qe(null),(async()=>{try{const xe=await s.sessionRewindableMessageIds(i.sessionId);if(Z)return;qe(new Set(xe.userMessageIds))}catch{Z||qe(null)}})(),()=>{Z=!0}},[s,i.sessionId,_.rewind]);const ln=g.useCallback(()=>{const Z=i.sessionId;s.sessionRewindableMessageIds(Z).then(xe=>{Rt.current===Z&&qe(new Set(xe.userMessageIds))}).catch(()=>{})},[s,i.sessionId]),Bt=g.useMemo(()=>{if(ge!==null){const Ze=new Set(ge);for(const pi of Gt)Ze.delete(pi);return Ze}const Z=new Set(["Edit","Write","MultiEdit","NotebookEdit"]),xe=new Set;let ye=null;for(const Ze of pe)Ze.kind==="user-text"?ye=Ze.uuid??null:ye&&Ze.kind==="tool-call"&&Z.has(Ze.tool)&&!Gt.has(ye)&&xe.add(ye);return xe},[pe,Gt,ge]),at=g.useRef(u);at.current=u,AU(i.sessionId,i.toolSessionId,()=>{pn(null),wt(new Set)});const Ue=KQ({sessionStatus:re}),nt=g.useRef(null);g.useEffect(()=>{var ye;const Z=nt.current,xe=(Z==null?void 0:Z.sid)===i.sessionId;xe&&Z.phase===Ue||(nt.current={sid:i.sessionId,phase:Ue},Re("session-phase",Ue,{sid:i.sessionId,phase:Ue,prev:xe?Z.phase:null,desc:qQ[Ue]}),xe&&Z.phase==="turn-running"&&Ue!=="turn-running"&&((ye=at.current)==null||ye.call(at),ln()))},[Ue,i.sessionId,ln]);const mt=g.useCallback(()=>{s.sessionInterrupt(i.sessionId).catch(()=>{})},[s,i.sessionId]),[Xt,pn]=g.useState(null),U=g.useCallback(Z=>{pn(Z)},[]),[Q,ve]=g.useState(!1),Se=g.useCallback(()=>{s.sessionStop(i.sessionId).catch(()=>{}),ve(!1)},[s,i.sessionId]),J=g.useCallback(Z=>{s.pinSession(i.sessionId,Z).catch(xe=>{Re("chat-panel","pinSession failed",{err:xe==null?void 0:xe.message})})},[s,i.sessionId]),Ye=(v==null?void 0:v.has(i.sessionId))??!1,Yt=g.useCallback(Z=>{b==null||b(i.sessionId,Z)},[b,i.sessionId]),Zt=g.useRef(0),ue=g.useRef(null);g.useEffect(()=>{const Z=xe=>{if(xe.key!=="Escape")return;if(!V){Zt.current=0;return}if(xe.isComposing)return;const Ze=xe.target;if(Ze&&Ze.closest("[data-cc-chat-root]")!==ue.current)return;const pi=Date.now();pi-Zt.current<2e3?(Zt.current=0,ve(!0)):(Zt.current=pi,mt())};return window.addEventListener("keydown",Z),()=>window.removeEventListener("keydown",Z)},[mt,V]);const Te=g.useRef(null),Je=g.useRef(null),Ln=g.useRef(!0),Qt=g.useRef(null),fl=g.useRef(0),Bo=g.useRef(0);g.useEffect(()=>{Ln.current=!0,Qt.current=null,fl.current=0,Bo.current=0},[i.sessionId]),g.useEffect(()=>{We(!1)},[i.sessionId]);const Ru=g.useRef(e);Ru.current=e;const Mu=g.useCallback(()=>{var ye;const Z=Te.current;if(!Z||Qt.current!==null)return;const xe=Ru.current;xe.historyDone||xe.historyLoading||(Qt.current={distFromBottom:Z.scrollHeight-Z.scrollTop},(ye=xe.loadMoreHistory)==null||ye.call(xe))},[]);g.useEffect(()=>{const Z=Te.current,xe=Je.current;if(!Z||!xe)return;const ye=new IntersectionObserver(Ze=>{for(const pi of Ze)pi.isIntersecting&&Mu()},{root:Z,threshold:0});return ye.observe(xe),()=>ye.disconnect()},[Mu]),g.useEffect(()=>{const Z=Te.current;if(!Z)return;const xe=150,ye=Ze=>{Date.now()<Bo.current&&(Ze.preventDefault(),Bo.current=Date.now()+xe)};return Z.addEventListener("wheel",ye,{passive:!1}),()=>Z.removeEventListener("wheel",ye)},[]),g.useEffect(()=>{const Z=Te.current;if(!Z)return;const xe=32,ye=()=>{const Ze=Z.scrollHeight-Z.scrollTop-Z.clientHeight;Ln.current=Ze<=xe};return Z.addEventListener("scroll",ye,{passive:!0}),()=>Z.removeEventListener("scroll",ye)},[]),g.useLayoutEffect(()=>{const Z=Te.current;if(!Z)return;const xe=fl.current,ye=pe.length;fl.current=ye;const Ze=Qt.current;if(Ze!==null&&ye>xe){Qt.current=null,Z.scrollTop=Z.scrollHeight-Ze.distFromBottom,Bo.current=Date.now()+200;return}Ze!==null&&(Qt.current={distFromBottom:Z.scrollHeight-Z.scrollTop}),Ln.current&&(Z.scrollTop=Z.scrollHeight)},[pe,ie==null?void 0:ie.requestId]);const Mp=g.useMemo(()=>{const Z={};for(const[xe,ye]of Object.entries(H))ye.submittedAnswers&&(Z[xe]=ye.submittedAnswers);return Z},[H]),Ap=g.useMemo(()=>new Set(Object.keys(H)),[H]),Au=g.useCallback(async(Z,xe)=>{try{await s.answerQuestion({sessionId:i.sessionId,toolUseId:Z,answers:xe}),A(Z,xe)}catch{}},[s,i.sessionId,A]),zo=g.useCallback(async Z=>{try{await s.cancelQuestion({sessionId:i.sessionId,toolUseId:Z}),q(Z)}catch{}},[s,i.sessionId,q]),$o=g.useCallback(async(Z,xe)=>{var ye;if(ie)try{await((ye=e.respondPermission)==null?void 0:ye.call(e,ie.requestId,Z?"allow":"deny"))}catch{}},[e,ie]),pl=g.useCallback(async()=>{const Z=i.sessionId;try{await s.sessionStop(Z)}catch{}e.clearSession?await e.clearSession():await s.sessionNew(Z)},[e,s,i.sessionId]),ml=g.useMemo(()=>oe&&pe.length===0?h.jsx("div",{className:"flex justify-center py-4","data-testid":"history-loading",children:h.jsx(rr,{className:"w-4 h-4 text-text-400 animate-spin"})}):e.historyDone?null:h.jsx("div",{className:"flex justify-center py-2",children:h.jsx("button",{type:"button",onClick:()=>{var Z;return void((Z=e.loadMoreHistory)==null?void 0:Z.call(e))},disabled:oe,"data-testid":"history-load-more",className:"text-[12px] text-text-400 hover:text-text-200 cursor-pointer px-3 py-1 rounded-md border border-bg-300 hover:bg-bg-100 transition-colors disabled:opacity-60",children:oe?"加载中…":"Load earlier messages"})}),[oe,pe.length,e.historyDone,e.loadMoreHistory]),qi=e.meta,Ki=h.jsxs(h.Fragment,{children:[i.toolSessionId&&_.subagents?h.jsx(EQ,{api:s,cwd:i.cwd,toolSessionId:i.toolSessionId}):null,Xt&&_.rewind?h.jsx(TQ,{open:!0,onOpenChange:Z=>{Z||pn(null)},api:s,sessionId:i.sessionId,userMessageId:Xt,lines:pe,procAlive:V,onNoChanges:Z=>{wt(xe=>{if(xe.has(Z))return xe;const ye=new Set(xe);return ye.add(Z),ye})}}):null,Q?h.jsx(lie,{onConfirm:Se,onCancel:()=>ve(!1)}):null,h.jsx(VQ,{open:Fe,onClose:()=>We(!1),jobs:Ae})]}),gl={kind:"session",sessionId:i.sessionId},ju=g.useCallback(async Z=>{if(s)try{await wre(s,F,i.sessionId,Z)}catch(xe){const ye=xe.message;Re("chat-panel","open-in-tab failed",{err:ye}),$("err",`Open in tab 失败:${ye}`)}},[s,F,i.sessionId,$]),[zt,vl]=g.useState(!1),[xl,Tt]=g.useState(null),$t=g.useCallback(Z=>{if(r){r(Z);return}Tt(Z),vl(!0)},[r]),ar=g.useCallback(async Z=>{if(!s)throw new Error("daemon api not ready");const xe=await n1(s,F,i.sessionId,Z,60),ye=await fetch(xe);if(!ye.ok)throw new Error(`fetch ${ye.status} ${ye.statusText}`);return await ye.text()},[s,F,i.sessionId]),Dn=g.useCallback(async(Z,xe)=>{if(s)try{const{url:ye}=await s.attachmentSignUrl({sessionId:i.sessionId,relPath:Z,ttlSeconds:86400,...xe?{view:xe}:{}}),Ze=await Sre(ye);$(Ze?"ok":"err",Ze?"分享链接已复制到剪贴板(24h 有效)":"复制失败:请手动复制")}catch(ye){const Ze=ye.message;Re("chat-panel","share-file failed",{err:Ze}),$("err",`生成分享链接失败:${Ze}`)}},[s,i.sessionId,$]);return h.jsxs(h.Fragment,{children:[h.jsx(aie,{headerMeta:qi,connState:e.connState,...o?{models:o}:{},...a!==void 0?{liveGitBranch:a}:{},...l!==void 0?{liveWorktreeRoot:l}:{},...d?{onOpenConfig:d}:{},onForceStop:()=>ve(!0),cronActiveCount:Ae.length,onCronClick:()=>We(!0),lines:pe,pendingPermissions:Oe,procAlive:V,rewindableUserMessageIds:Bt,onPermissionRespond:$o,onPermissionInterrupt:mt,onRewind:_.rewind?U:void 0,...f&&_.fork?{onFork:f}:{},...n&&_.fork?{onQuickAsk:n}:p&&_.fork?{onQuickAsk:p}:{},topSlot:ml,realtimeQuestionAnswers:Mp,onSubmitQuestion:Au,onCancelQuestion:zo,liveQuestionToolUseIds:Ap,api:s,cwd:i.cwd,...i.tool?{tool:i.tool}:{},sessionKey:i.sessionId,onSend:e.sendText,awaitingUser:Oe.length>0||Object.values(H).some(Z=>!Z.submittedAnswers),onAbort:mt,...c?{onNewSession:c}:{},onClearSession:pl,chatRootRef:ue,chatBodyRef:Te,topSentinelRef:Je,drawers:Ki,xtermSlot:L==="tui"&&V&&_.tui?h.jsx(ane,{sessionId:i.sessionId,client:F},i.sessionId):null,fileSharingScope:gl,...s?{onShareFile:Dn}:{},...s?{onOpenInTab:ju}:{},...s?{onPreviewMarkdown:$t}:{},...P?{onOpenFiles:O}:{},onTogglePin:J,isHolded:Ye,...b?{onToggleHold:Yt}:{},...I?{personaName:R}:{},...I?{onOpenPersona:z}:{}}),P&&s?h.jsx(fne,{api:s,open:S,onOpenChange:C,scope:gl,sessionId:i.sessionId,onShareFile:Dn,onOpenInTab:ju}):null,s?h.jsx(Ere,{open:zt,onOpenChange:vl,relPath:xl,loadMarkdown:ar,onShare:xl?()=>void Dn(xl,"md-rendered"):void 0}):null,I&&s&&i.ownerPersonaId?h.jsx(_re,{api:s,open:N,onOpenChange:T,personaId:i.ownerPersonaId,personaName:R??"",...m?{viewerRole:m}:{}}):null,y?h.jsx("div",{"data-testid":"share-toast",role:"status","aria-live":"polite",className:y.kind==="ok"?"fixed left-1/2 top-4 z-50 -translate-x-1/2 rounded-md border border-emerald-500/40 bg-emerald-500/10 px-3 py-2 text-[12px] text-emerald-700 shadow-md dark:text-emerald-300":"fixed left-1/2 top-4 z-50 -translate-x-1/2 rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-[12px] text-destructive shadow-md",children:y.text}):null]})}function lie({onConfirm:e,onCancel:t}){return h.jsx("div",{role:"dialog","aria-modal":"true","data-testid":"force-stop-confirm",className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40",onClick:t,children:h.jsxs("div",{className:"max-w-sm w-[92%] rounded-lg border border-red-400/40 bg-bg-0 p-4 shadow-xl",onClick:n=>n.stopPropagation(),children:[h.jsxs("div",{className:"flex items-start gap-2 mb-3",children:[h.jsx(Uc,{className:"w-5 h-5 text-red-500 shrink-0 mt-0.5"}),h.jsx("div",{className:"text-[14px] text-text-100",children:"强制停止会话进程?会丢失 initialize / 预热缓存,下一次发送需要重新 spawn。"})]}),h.jsxs("div",{className:"flex justify-end gap-2",children:[h.jsx("button",{type:"button",onClick:t,className:"h-8 px-3 rounded-md text-[12px] text-text-300 hover:bg-text-100/5 cursor-pointer",children:"取消"}),h.jsx("button",{type:"button","data-testid":"force-stop-confirm-ok",onClick:e,className:"h-8 px-3 rounded-md bg-red-500 text-white text-[12px] font-medium hover:bg-red-600 cursor-pointer",children:"强制停止"})]})]})})}function cie(e,t,n){const r=e?t.find(s=>s.id===e):void 0;if(r!=null&&r.efforts&&r.efforts.length>0)return{options:r.efforts,defaultValue:r.defaultEffort??""};const i=n.find(s=>s.name==="effort");return{options:(i==null?void 0:i.options)??[],defaultValue:typeof(i==null?void 0:i.default)=="string"?i.default:""}}function uie({current:e,models:t,onSelect:n}){return h.jsxs("div",{children:[h.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider text-text-400/70 mb-2",children:"Model"}),h.jsx("div",{className:"flex flex-wrap gap-1.5","data-testid":"config-model-selector",children:t.map(r=>{const i=(e||"")===r.id;return h.jsx("button",{type:"button",onClick:()=>n(r.id),"data-testid":`config-model-${r.id||"default"}`,className:ne("px-3 py-1.5 rounded-lg text-[12px] font-medium transition-colors cursor-pointer",i?"bg-accent text-white shadow-sm":"bg-bg-100 text-text-300 hover:bg-bg-200 hover:text-text-100"),children:r.label},r.id||"default")})})]})}function die({current:e,modes:t,onSelect:n}){var i;const r=(i=t.find(s=>s.id===(e||"")))==null?void 0:i.description;return h.jsxs("div",{children:[h.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider text-text-400/70 mb-2",children:"Permission Mode"}),h.jsx("div",{className:"flex flex-wrap gap-1.5","data-testid":"config-mode-selector",children:t.map(s=>{const o=(e||"")===s.id;return h.jsx("button",{type:"button",onClick:()=>n(s.id),"data-testid":`config-mode-${s.id||"default"}`,className:ne("px-3 py-1.5 rounded-lg text-[12px] font-medium transition-colors cursor-pointer",o?"bg-accent text-white shadow-sm":"bg-bg-100 text-text-300 hover:bg-bg-200 hover:text-text-100"),children:s.label},s.id||"default")})}),r?h.jsx("p",{className:"text-[11px] text-text-400 mt-1.5",children:r}):null]})}function hie({open:e,onOpenChange:t,session:n,onPatch:r,embedded:i=!1,viewerRole:s="owner"}){var m;const{capabilities:o}=Gy(e?n.tool||"claude":null),a=(o==null?void 0:o.models)??[],l=(o==null?void 0:o.permissionModes)??[],c=((m=o==null?void 0:o.configSchema.find(v=>v.name==="permissionMode"))==null?void 0:m.default)??"",u=n.permissionMode&&l.some(v=>v.id===n.permissionMode)?n.permissionMode:c,d=g.useMemo(()=>(o==null?void 0:o.configSchema.filter(v=>v.scope==="tool-specific"))??[],[o]),f=(o==null?void 0:o.toolSessionIdLabel)??"Tool Session ID";if(!e)return null;const p=h.jsxs("div",{className:"flex-1 min-h-0 flex flex-col px-4 py-4 gap-6 overflow-y-auto",children:[h.jsxs("div",{className:"shrink-0",children:[h.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider text-text-400/70 mb-1",children:"Working Directory"}),h.jsx("div",{className:"text-[12px] font-mono text-text-300 bg-bg-100 rounded-lg px-3 py-2 truncate","data-testid":"config-cwd",title:n.cwd,children:n.cwd})]}),h.jsx("div",{className:"shrink-0",children:h.jsx(uie,{current:n.model??"",models:a,onSelect:v=>void r({model:v})})}),h.jsx("div",{className:"shrink-0",children:h.jsx(die,{current:u,modes:l,onSelect:v=>void r({permissionMode:v})})}),d.length>0?h.jsx("div",{className:"shrink-0",children:h.jsx(fie,{fields:d,models:a,session:n,onPatch:r})}):null,h.jsx("div",{className:"shrink-0",children:h.jsx(TC,{testId:"config-session-id",label:"Clawd Session ID",value:n.sessionId})}),n.toolSessionId?h.jsx("div",{className:"shrink-0",children:h.jsx(TC,{testId:"config-tool-session-id",label:f,value:n.toolSessionId})}):null]});return i?h.jsxs("div",{"data-testid":"config-drawer",className:"h-full w-full flex flex-col",children:[h.jsx("div",{className:"flex items-center px-4 py-3 border-b border-bg-300/30 shrink-0",children:h.jsx("span",{className:"text-[14px] font-semibold text-text-100",children:"Session Settings"})}),p]}):h.jsxs("div",{"data-testid":"config-drawer",className:"h-full w-full flex flex-col border-l border-bg-300/40 bg-bg-0 min-w-0",children:[h.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-bg-300/30 shrink-0",children:[h.jsx("span",{className:"text-[14px] font-semibold text-text-100",children:"Session Settings"}),h.jsx("button",{type:"button",onClick:()=>t(!1),"data-testid":"config-drawer-close",className:"flex items-center justify-center w-7 h-7 rounded-md text-text-400 hover:text-text-100 hover:bg-text-100/5 transition-colors cursor-pointer","aria-label":"Close",children:h.jsx(Rn,{className:"w-4 h-4"})})]}),p]})}function TC({testId:e,label:t,value:n}){const[r,i]=g.useState(!1),s=g.useRef(null);g.useEffect(()=>()=>{s.current&&clearTimeout(s.current)},[]);const o=()=>{typeof navigator>"u"||!navigator.clipboard||navigator.clipboard.writeText(n).then(()=>{i(!0),s.current&&clearTimeout(s.current),s.current=setTimeout(()=>i(!1),2e3)},()=>{})};return h.jsxs("div",{"data-testid":e,children:[h.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider text-text-400/70 mb-1",children:t}),h.jsxs("button",{type:"button",onClick:o,"data-testid":`${e}-copy`,title:r?"Copied":`Copy: ${n}`,className:"w-full flex items-center gap-2 text-[12px] font-mono text-text-300 bg-bg-100 hover:bg-bg-200 rounded-lg px-3 py-2 transition-colors cursor-pointer text-left group",children:[h.jsx("span",{className:"truncate flex-1 min-w-0","data-testid":`${e}-value`,children:n}),r?h.jsx(ol,{className:"w-3.5 h-3.5 shrink-0 text-accent"}):h.jsx(mu,{className:"w-3.5 h-3.5 shrink-0 opacity-60 group-hover:opacity-100 transition-opacity"})]})]})}function fie({fields:e,models:t,session:n,onPatch:r}){return h.jsxs("div",{"data-testid":"config-advanced",children:[h.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider text-text-400/70 mb-2",children:"Advanced"}),h.jsx("div",{className:"space-y-3",children:e.map(i=>h.jsx(pie,{field:i,models:t,session:n,onPatch:r},i.name))})]})}function pie({field:e,models:t,session:n,onPatch:r}){const i=e.name==="effort"?cie(n.model??"",t,[e]):{options:e.options??[],defaultValue:e.default??""},s=i.options;if(e.type!=="select"||s.length===0)return null;const o=n[e.name]??"",a=s.some(l=>l.value===o)?o:i.defaultValue;return h.jsxs("div",{"data-testid":`config-advanced-${e.name}`,children:[h.jsx("div",{className:"text-[11px] text-text-400 mb-1.5",children:e.label}),h.jsx("div",{className:"flex flex-wrap gap-1.5",children:s.map(l=>{const c=a===l.value;return h.jsx("button",{type:"button","data-testid":`config-advanced-${e.name}-${l.value||"default"}`,onClick:()=>void r({[e.name]:l.value}),className:ne("px-3 py-1.5 rounded-lg text-[12px] font-medium transition-colors cursor-pointer",c?"bg-accent text-white shadow-sm":"bg-bg-100 text-text-300 hover:bg-bg-200 hover:text-text-100"),children:l.label},l.value||"default")})})]})}function mie(e,t,n=0){const[r,i]=g.useState(null),[s,o]=g.useState(!1),a=g.useCallback(async()=>{if(!t){i(null);return}o(!0);try{const l=await e.getGitBranch(t);i(l.branch??null)}catch{i(null)}finally{o(!1)}},[e,t]);return g.useEffect(()=>{a()},[a,n]),{branch:r,loading:s,refresh:()=>void a()}}function gie(e,t,n=0){const[r,i]=g.useState(null),[s,o]=g.useState(!1),a=g.useCallback(async()=>{if(!t){i(null);return}o(!0);try{const l=await e.getGitRoot(t);i(l.gitRoot??null)}catch{i(null)}finally{o(!1)}},[e,t]);return g.useEffect(()=>{a()},[a,n]),{worktreeRoot:r,loading:s,refresh:()=>void a()}}function vie({api:e,session:t,focused:n,totalPanes:r,onFocus:i,onClose:s,onNewSession:o,onOpenConfig:a,onConfigPatch:l,onFork:c,onQuickAsk:u,className:d,viewerRole:f="owner",holdIds:p,onToggleHold:m}){const{capabilities:v}=Gy(t.tool),[b,x]=g.useState(0),[_,y]=g.useState(!1),{initialSize:w,setSize:S}=h5("clawd:panel:config-px",360),{branch:C}=mie(e,t.cwd,b),{worktreeRoot:N}=gie(e,t.cwd,b),T=r>1,M=P=>{P==="desktop"?y(!0):a()};return h.jsxs("div",{className:`group/pane relative flex-1 ${d??"flex"} flex-row min-w-0 min-h-0 overflow-hidden ${T?`rounded-md border transition-colors ${n?"border-accent ring-1 ring-accent":"border-border"}`:""}`,onMouseDown:i,"data-testid":`session-pane-${t.sessionId}`,children:[h.jsxs(cy,{orientation:"horizontal",className:"flex-1 flex min-w-0 min-h-0",children:[h.jsx(Yc,{id:"chat",minSize:"400px",children:h.jsx("div",{className:"flex flex-col min-w-0 min-h-0 h-full",children:h.jsx(xie,{api:e,session:t,models:v==null?void 0:v.models,liveGitBranch:C,liveWorktreeRoot:N,onNewSession:o,onTurnEnd:()=>x(P=>P+1),onOpenConfig:M,onFork:c,onQuickAsk:u,viewerRole:f,holdIds:p,onToggleHold:m})})}),_&&h.jsxs(h.Fragment,{children:[h.jsx(dy,{className:"hidden md:block w-1 bg-text-100/10 hover:bg-text-100/25 transition-colors cursor-col-resize"}),h.jsx(Yc,{id:"config",defaultSize:`${w}px`,minSize:"360px",maxSize:"560px",onResize:P=>S(P.inPixels),children:h.jsx("div",{className:"hidden md:flex h-full",children:h.jsx(hie,{open:_,onOpenChange:y,session:t,onPatch:l,viewerRole:f})})})]})]}),T&&h.jsx("button",{type:"button",onClick:P=>{P.stopPropagation(),s()},className:"absolute top-1.5 right-1.5 z-10 p-1 rounded-md bg-bg-100/80 backdrop-blur-sm border border-border opacity-0 group-hover/pane:opacity-100 transition-opacity text-text-400 hover:text-text-100 hover:bg-bg-200","aria-label":"close pane","data-testid":`session-pane-close-${t.sessionId}`,children:h.jsx(Rn,{className:"w-3.5 h-3.5"})})]})}function xie({api:e,session:t,models:n,liveGitBranch:r,liveWorktreeRoot:i,onNewSession:s,onTurnEnd:o,onOpenConfig:a,onFork:l,onQuickAsk:c,viewerRole:u,holdIds:d,onToggleHold:f}){return h.jsx(sie,{extras:{session:t,api:e,...n?{models:n}:{},...r!==void 0?{liveGitBranch:r}:{},...i!==void 0?{liveWorktreeRoot:i}:{},onNewSession:s,onTurnEnd:o,onOpenConfig:a,...l?{onFork:p=>{l(p)}}:{},...c?{onQuickAsk:p=>{c(p)}}:{},...u?{viewerRole:u}:{},...d?{holdIds:d}:{},...f?{onToggleHold:f}:{}}})}function _ie({personas:e,sessions:t,api:n,selfPrincipalId:r,selectedPersonaId:i,selectedSessionId:s,selectedSession:o,onSelectPersona:a,onSelectSession:l,onCreateSession:c,onDeleteSession:u,onEditSession:d,onCloseSession:f,onConfigPatch:p}){return h.jsxs("div",{className:"flex h-screen min-h-0 bg-bg-50","data-testid":"guest-share-page",children:[h.jsx("aside",{className:"w-[280px] shrink-0 overflow-y-auto border-r border-border bg-bg-50",children:h.jsx(YH,{personas:e,sessions:t,activePersonaId:i,activeSessionId:s,onSelectPersona:a,onSelectSession:l,onCreateSession:c,onDeleteSession:u,onEditSession:d,showCopyResume:!1,treatSessionsAsRoots:!0,...r?{ownerPrincipalId:r}:{},isPersonaExpanded:()=>!0})}),h.jsx("main",{className:"flex-1 min-w-0 min-h-0 flex",children:o?h.jsx(vie,{api:n,session:o,focused:!0,totalPanes:1,onFocus:()=>{},onClose:f,onNewSession:()=>{},onOpenConfig:()=>{},onConfigPatch:p,viewerRole:"guest"}):h.jsx("div",{className:"flex flex-1 items-center justify-center p-6 text-xs text-text-400","data-testid":"guest-share-empty",children:"选择左侧 persona 开始对话"})})]})}function yie(){const e=$i(),t=g.useMemo(()=>new k_(e),[e]),n=m6(e),{sessions:r,refresh:i}=g6(n),{personas:s}=_T(),o=w6(),a=g.useMemo(()=>{const w=window.location.pathname.match(/^\/s\/([^/]+)/);return w?decodeURIComponent(w[1]):null},[]),l=g.useMemo(()=>r.filter(w=>!w.ephemeral&&w.larkChatId==null),[r]),c=g.useMemo(()=>a?s.filter(w=>w.personaId===a):s,[s,a]),[u,d]=g.useState(null),[f,p]=g.useState(null),[m,v]=g.useState(null);g.useEffect(()=>{let w=!1;return e.request("whoami",{}).then(S=>{w||d(S.capability.id)}).catch(()=>{}),()=>{w=!0}},[e]),g.useEffect(()=>{a&&p(a)},[a]);const b=g.useCallback(async(w,S)=>{const C=await t.sessionCreate({ownerPersonaId:w,...S.trim()?{label:S.trim()}:{}});await i(),p(w),v(C.sessionId)},[t,i]),x=g.useCallback(async w=>{await t.sessionDelete(w),await i(),v(S=>S===w?null:S)},[t,i]),_=g.useCallback(async(w,S)=>{await t.sessionUpdate(w,{label:S.label,iconKey:S.iconKey===null?"":S.iconKey}),await i()},[t,i]),y=g.useMemo(()=>l.find(w=>w.sessionId===m)??null,[l,m]);return h.jsx(C_.Provider,{value:o,children:h.jsx(_ie,{personas:c,sessions:l,api:t,selfPrincipalId:u,selectedPersonaId:f,selectedSessionId:m,selectedSession:y,onSelectPersona:p,onSelectSession:v,onCreateSession:(w,S)=>void b(w,S),onDeleteSession:w=>void x(w),onEditSession:(w,S)=>void _(w,S),onCloseSession:()=>v(null),onConfigPatch:async()=>{}})})}const PC="https://app.ttcadvisory.com";function bie({onAuthed:e}){const[t,n]=g.useState(!1),[r,i]=g.useState(null),s=g.useRef(null);g.useEffect(()=>()=>{s.current&&window.removeEventListener("message",s.current)},[]);const o=g.useCallback(()=>{s.current&&(window.removeEventListener("message",s.current),s.current=null),n(!0),i(null);const a=window.location.origin,l=`${PC}/auth/authorize?callback_url=${encodeURIComponent(a)}&auto=1`,c=async d=>{if(d.origin!==PC)return;const f=d.data;if((f==null?void 0:f.type)==="AUTH_CANCEL"){u(),n(!1);return}if(!((f==null?void 0:f.type)!=="AUTH_SUCCESS"||!f.token)){u();try{const p=await fetch(`${window.location.origin}/share/exchange`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({ttcToken:f.token})});if(!p.ok){const v=await p.json().catch(()=>({}));throw new Error(v.code??`exchange failed (${p.status})`)}const m=await p.json();if(!m.visitorToken)throw new Error("no visitorToken in response");e(m.visitorToken)}catch(p){i(p instanceof Error?p.message:String(p)),n(!1)}}},u=()=>{window.removeEventListener("message",c),s.current=null};s.current=d=>void c(d),window.addEventListener("message",s.current),window.open(l,"ttc-login","width=480,height=640")},[e]);return h.jsx("div",{className:"flex min-h-screen items-center justify-center bg-bg-50 p-6 font-sans text-text-100","data-testid":"guest-login",children:h.jsxs("div",{className:"flex w-full max-w-xs flex-col gap-3 rounded-lg border border-border bg-bg-100 px-5 py-6",children:[h.jsx("h1",{className:"text-base font-semibold",children:"登录后进入分享"}),h.jsx("p",{className:"text-[11px] leading-snug text-text-400",children:"使用飞书账号登录,即可在浏览器里与分享给你的 persona 交互,无需安装。"}),r?h.jsxs("p",{className:"text-[11px] leading-snug text-error","data-testid":"guest-login-error",children:["登录失败:",r]}):null,h.jsx("button",{type:"button",disabled:t,onClick:()=>o(),"data-testid":"guest-login-button",className:"w-full rounded border border-border bg-bg-50 px-2 py-1.5 text-xs text-text-200 transition-colors hover:bg-text-100/5 hover:text-text-100 disabled:opacity-50",children:t?"请在弹窗中完成授权…":"飞书登录"})]})})}const fx="clawd-visitor:token";function wie(e,t){const r=`${e.protocol==="https:"?"wss:":"ws:"}//${e.host}`;return t!=null&&t.devPath?`${r}${t.devPath}`:r}function Sie(){return{async getUrl(e){const t=localStorage.getItem(fx);if(!t)throw new Error("NO_VISITOR_TOKEN");const n=wie(window.location,{});return await uT(e).upsert({id:"guest",name:"访客",mode:"remote",url:n,token:t}),{url:n}}}}function kie(e){const t=n=>{document.documentElement.classList.toggle("dark",n==="dark")};return t(e.theme.mode),e.onThemeChange(n=>t(n.mode))}function Cie(){const e=$i(),t=g.useMemo(()=>p6(e),[e]);return h.jsx(XB,{cache:t.cache,children:h.jsx(QB,{children:h.jsx(yie,{})})})}function Eie({host:e}){const[t]=g.useState(()=>localStorage.getItem(fx)),[n,r]=g.useState(!1),[i,s]=g.useState(null);return g.useEffect(()=>kie(e),[e]),g.useEffect(()=>{if(!t)return;let o=!1;return Sie().getUrl(e).then(()=>{o||r(!0)}).catch(a=>{o||s(a instanceof Error?a.message:String(a))}),()=>{o=!0}},[e,t]),t?h.jsx(xb,{host:e,children:h.jsx(Zb,{children:i?h.jsxs("div",{className:"flex min-h-screen items-center justify-center bg-bg-50 p-6 text-center text-xs text-error","data-testid":"guest-share-connect-error",children:["连接失败:",i]}):n?h.jsx(KB,{host:e,children:h.jsx(Cie,{})}):h.jsx("div",{className:"flex min-h-screen items-center justify-center bg-bg-50 p-6 text-xs text-text-400",children:"正在连接…"})})}):h.jsx(xb,{host:e,children:h.jsx(Zb,{children:h.jsx(bie,{onAuthed:o=>{localStorage.setItem(fx,o),window.location.reload()}})})})}function Nie({filePath:e,oldString:t,newString:n,content:r}){const i=g.useMemo(()=>r!=null?r.split(/\r?\n/).map(s=>({type:"add",text:s})):Tie(t??"",n??""),[t,n,r]);return h.jsxs("div",{"data-testid":"inline-diff",className:"min-w-0 max-w-full rounded-lg border border-bg-300/60 bg-bg-50 overflow-hidden text-[12px] font-mono",children:[h.jsx("div",{className:"flex min-w-0 items-center gap-2 px-3 py-1.5 border-b border-bg-300/40 bg-bg-100/30",children:h.jsx("span",{className:"min-w-0 text-text-400 truncate",title:e,children:e})}),h.jsx("div",{className:"max-h-[320px] max-w-full overflow-auto",children:i.map((s,o)=>h.jsxs("div",{"data-testid":`diff-line-${s.type}`,className:ne("flex min-w-max gap-2 px-3 py-0.5 whitespace-pre",s.type==="add"?"bg-success/10 text-success":s.type==="remove"?"bg-error/10 text-error":"text-text-300"),children:[h.jsx("span",{className:"w-3 shrink-0 select-none opacity-60",children:s.type==="add"?"+":s.type==="remove"?"-":" "}),h.jsx("span",{className:"flex-1",children:s.text||" "})]},o))})]})}function Tie(e,t){const n=e.split(/\r?\n/),r=t.split(/\r?\n/),i=n.length,s=r.length,o=Array.from({length:i+1},()=>new Array(s+1).fill(0));for(let u=i-1;u>=0;u--)for(let d=s-1;d>=0;d--)o[u][d]=n[u]===r[d]?o[u+1][d+1]+1:Math.max(o[u+1][d],o[u][d+1]);const a=[];let l=0,c=0;for(;l<i&&c<s;)n[l]===r[c]?(a.push({type:"equal",text:n[l]}),l++,c++):o[l+1][c]>=o[l][c+1]?(a.push({type:"remove",text:n[l]}),l++):(a.push({type:"add",text:r[c]}),c++);for(;l<i;)a.push({type:"remove",text:n[l++]});for(;c<s;)a.push({type:"add",text:r[c++]});return a}function Pie({items:e}){return e.length===0?null:h.jsxs("div",{"data-testid":"todo-checklist",className:"rounded-lg border border-bg-300/60 bg-bg-50 px-3 py-2 text-[13px]",children:[h.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider text-text-400/70 mb-1.5",children:"Todos"}),h.jsx("ul",{className:"flex flex-col gap-1",children:e.map((t,n)=>{const r=t.status==="in_progress"&&t.activeForm||t.content;return h.jsxs("li",{"data-testid":`todo-item-${t.status}`,className:"flex items-start gap-2",children:[h.jsx(Iie,{status:t.status}),h.jsx("span",{className:ne("flex-1 leading-snug",t.status==="completed"?"text-text-400 line-through":t.status==="in_progress"?"text-text-100 font-medium":"text-text-200"),children:r})]},n)})})]})}function Iie({status:e}){return e==="completed"?h.jsx(Zf,{className:"w-3.5 h-3.5 text-success mt-0.5 shrink-0"}):e==="in_progress"?h.jsx(rr,{className:"w-3.5 h-3.5 text-warning mt-0.5 shrink-0 animate-spin"}):h.jsx(ST,{className:"w-3.5 h-3.5 text-text-400 mt-0.5 shrink-0"})}function Rie(e){const t=e??{};return Array.isArray(t.todos)?t.todos.map(n=>{if(!n||typeof n!="object")return null;const r=n,i=typeof r.content=="string"?r.content:"",s=r.status==="pending"||r.status==="in_progress"||r.status==="completed"?r.status:"pending",o=typeof r.activeForm=="string"?r.activeForm:void 0;return{content:i,status:s,activeForm:o}}).filter(n=>n!==null):[]}function Mie({description:e,prompt:t,subagentType:n}){return h.jsxs("div",{"data-testid":"task-checklist",className:"rounded-lg border border-bg-300/60 bg-bg-50 px-3 py-2 text-[13px]",children:[h.jsxs("div",{className:"flex items-center gap-2 text-text-200 font-medium",children:[h.jsx(Yf,{className:"w-3.5 h-3.5 text-accent shrink-0"}),h.jsx("span",{className:"truncate",children:e||"subagent task"}),n?h.jsx("span",{className:"shrink-0 px-1.5 py-0.5 rounded-md text-[10px] font-mono bg-accent/10 text-accent",children:n}):null]}),t?h.jsx("div",{className:"mt-1 text-[12px] text-text-400 leading-snug line-clamp-3",children:t}):null]})}function Aie(e){const t=e??{};return{description:typeof t.description=="string"?t.description:"",prompt:typeof t.prompt=="string"?t.prompt:void 0,subagentType:typeof t.subagent_type=="string"?t.subagent_type:void 0}}const jie={render:({input:e})=>st.createElement(Pie,{items:Rie(e)})},Lie={render:({input:e})=>{const{description:t,prompt:n,subagentType:r}=Aie(e);return st.createElement(Mie,{description:t,prompt:n,subagentType:r})}},p5={render:({input:e,output:t,error:n,pending:r,fileScope:i,onShareFile:s,onOpenInTab:o,onPreviewMarkdown:a})=>{const l=Oie(e),c=l?st.createElement(Nie,{filePath:l.filePath,oldString:l.oldString,newString:l.newString,content:l.content}):void 0;return st.createElement(yM,{tool:Die(e),input:e,output:t,error:n,pending:r,expandedBody:c,...i?{fileScope:i}:{},...s?{onShareFile:s}:{},...o?{onOpenInTab:o}:{},...a?{onPreviewMarkdown:a}:{}})}};function Die(e){const t=e??{};return"content"in t&&t.content!==void 0?"Write":("old_string"in t&&t.old_string!==void 0,"Edit")}function Oie(e){const t=e??{},n=typeof t.file_path=="string"?t.file_path:null;if(!n)return null;const r=typeof t.old_string=="string"?t.old_string:void 0,i=typeof t.new_string=="string"?t.new_string:void 0,s=typeof t.content=="string"?t.content:void 0;return r==null&&i==null&&s==null?null:{filePath:n,oldString:r,newString:i,content:s}}ku.register("claude","TodoWrite",jie);ku.register("claude","Task",Lie);ku.register("claude","Edit",p5);ku.register("claude","Write",p5);const m5=document.getElementById("root");if(!m5)throw new Error("guest-main: #root not found");const Bie=X4({});gg.createRoot(m5).render(h.jsx(st.StrictMode,{children:h.jsx(Eie,{host:Bie})}));
|