@coralai/sps-cli 0.65.46 → 0.65.47
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/console/routes/fs.d.ts.map +1 -1
- package/dist/console/routes/fs.js +12 -0
- package/dist/console/routes/fs.js.map +1 -1
- package/dist/console-assets/assets/{ShowcasePage-qOjeWeUs.js → ShowcasePage-1P7DtNt1.js} +1 -1
- package/dist/console-assets/assets/{index-f9HN8ZBW.js → index-C5mRGv7W.js} +3 -3
- package/dist/console-assets/index.html +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ShowcasePage-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ShowcasePage-1P7DtNt1.js","assets/ShowcasePage-EkuegwaP.css"])))=>i.map(i=>d[i]);
|
|
2
2
|
var Jz=Object.defineProperty;var pN=e=>{throw TypeError(e)};var e4=(e,t,n)=>t in e?Jz(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var mN=(e,t,n)=>e4(e,typeof t!="symbol"?t+"":t,n),wb=(e,t,n)=>t.has(e)||pN("Cannot "+n);var J=(e,t,n)=>(wb(e,t,"read from private field"),n?n.call(e):t.get(e)),it=(e,t,n)=>t.has(e)?pN("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),qe=(e,t,n,i)=>(wb(e,t,"write to private field"),i?i.call(e,n):t.set(e,n),n),Et=(e,t,n)=>(wb(e,t,"access private method"),n);var Fh=(e,t,n,i)=>({set _(s){qe(e,t,s,n)},get _(){return J(e,t,i)}});(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))i(s);new MutationObserver(s=>{for(const r of s)if(r.type==="childList")for(const o of r.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&i(o)}).observe(document,{childList:!0,subtree:!0});function n(s){const r={};return s.integrity&&(r.integrity=s.integrity),s.referrerPolicy&&(r.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?r.credentials="include":s.crossOrigin==="anonymous"?r.credentials="omit":r.credentials="same-origin",r}function i(s){if(s.ep)return;s.ep=!0;const r=n(s);fetch(s.href,r)}})();function cf(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Eb={exports:{}},Ju={};/**
|
|
3
3
|
* @license React
|
|
4
4
|
* react-jsx-runtime.production.js
|
|
@@ -664,7 +664,7 @@ void main() {
|
|
|
664
664
|
`},f]}}const mG=e=>({IMPORTANT:{scope:"meta",begin:"!important"},BLOCK_COMMENT:e.C_BLOCK_COMMENT_MODE,HEXCOLOR:{scope:"number",begin:/#(([0-9a-fA-F]{3,4})|(([0-9a-fA-F]{2}){3,4}))\b/},FUNCTION_DISPATCH:{className:"built_in",begin:/[\w-]+(?=\()/},ATTRIBUTE_SELECTOR_MODE:{scope:"selector-attr",begin:/\[/,end:/\]/,illegal:"$",contains:[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},CSS_NUMBER_MODE:{scope:"number",begin:e.NUMBER_RE+"(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?",relevance:0},CSS_VARIABLE:{className:"attr",begin:/--[A-Za-z_][A-Za-z0-9_-]*/}}),gG=["a","abbr","address","article","aside","audio","b","blockquote","body","button","canvas","caption","cite","code","dd","del","details","dfn","div","dl","dt","em","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","html","i","iframe","img","input","ins","kbd","label","legend","li","main","mark","menu","nav","object","ol","optgroup","option","p","picture","q","quote","samp","section","select","source","span","strong","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","ul","var","video"],yG=["defs","g","marker","mask","pattern","svg","switch","symbol","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feFlood","feGaussianBlur","feImage","feMerge","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","linearGradient","radialGradient","stop","circle","ellipse","image","line","path","polygon","polyline","rect","text","use","textPath","tspan","foreignObject","clipPath"],bG=[...gG,...yG],xG=["any-hover","any-pointer","aspect-ratio","color","color-gamut","color-index","device-aspect-ratio","device-height","device-width","display-mode","forced-colors","grid","height","hover","inverted-colors","monochrome","orientation","overflow-block","overflow-inline","pointer","prefers-color-scheme","prefers-contrast","prefers-reduced-motion","prefers-reduced-transparency","resolution","scan","scripting","update","width","min-width","max-width","min-height","max-height"].sort().reverse(),bR=["active","any-link","blank","checked","current","default","defined","dir","disabled","drop","empty","enabled","first","first-child","first-of-type","fullscreen","future","focus","focus-visible","focus-within","has","host","host-context","hover","indeterminate","in-range","invalid","is","lang","last-child","last-of-type","left","link","local-link","not","nth-child","nth-col","nth-last-child","nth-last-col","nth-last-of-type","nth-of-type","only-child","only-of-type","optional","out-of-range","past","placeholder-shown","read-only","read-write","required","right","root","scope","target","target-within","user-invalid","valid","visited","where"].sort().reverse(),xR=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),vG=["accent-color","align-content","align-items","align-self","alignment-baseline","all","anchor-name","animation","animation-composition","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-range","animation-range-end","animation-range-start","animation-timeline","animation-timing-function","appearance","aspect-ratio","backdrop-filter","backface-visibility","background","background-attachment","background-blend-mode","background-clip","background-color","background-image","background-origin","background-position","background-position-x","background-position-y","background-repeat","background-size","baseline-shift","block-size","border","border-block","border-block-color","border-block-end","border-block-end-color","border-block-end-style","border-block-end-width","border-block-start","border-block-start-color","border-block-start-style","border-block-start-width","border-block-style","border-block-width","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-collapse","border-color","border-end-end-radius","border-end-start-radius","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-inline","border-inline-color","border-inline-end","border-inline-end-color","border-inline-end-style","border-inline-end-width","border-inline-start","border-inline-start-color","border-inline-start-style","border-inline-start-width","border-inline-style","border-inline-width","border-left","border-left-color","border-left-style","border-left-width","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-spacing","border-start-end-radius","border-start-start-radius","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-align","box-decoration-break","box-direction","box-flex","box-flex-group","box-lines","box-ordinal-group","box-orient","box-pack","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","caret-color","clear","clip","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","color-scheme","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","contain","contain-intrinsic-block-size","contain-intrinsic-height","contain-intrinsic-inline-size","contain-intrinsic-size","contain-intrinsic-width","container","container-name","container-type","content","content-visibility","counter-increment","counter-reset","counter-set","cue","cue-after","cue-before","cursor","cx","cy","direction","display","dominant-baseline","empty-cells","enable-background","field-sizing","fill","fill-opacity","fill-rule","filter","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","flood-color","flood-opacity","flow","font","font-display","font-family","font-feature-settings","font-kerning","font-language-override","font-optical-sizing","font-palette","font-size","font-size-adjust","font-smooth","font-smoothing","font-stretch","font-style","font-synthesis","font-synthesis-position","font-synthesis-small-caps","font-synthesis-style","font-synthesis-weight","font-variant","font-variant-alternates","font-variant-caps","font-variant-east-asian","font-variant-emoji","font-variant-ligatures","font-variant-numeric","font-variant-position","font-variation-settings","font-weight","forced-color-adjust","gap","glyph-orientation-horizontal","glyph-orientation-vertical","grid","grid-area","grid-auto-columns","grid-auto-flow","grid-auto-rows","grid-column","grid-column-end","grid-column-start","grid-gap","grid-row","grid-row-end","grid-row-start","grid-template","grid-template-areas","grid-template-columns","grid-template-rows","hanging-punctuation","height","hyphenate-character","hyphenate-limit-chars","hyphens","icon","image-orientation","image-rendering","image-resolution","ime-mode","initial-letter","initial-letter-align","inline-size","inset","inset-area","inset-block","inset-block-end","inset-block-start","inset-inline","inset-inline-end","inset-inline-start","isolation","justify-content","justify-items","justify-self","kerning","left","letter-spacing","lighting-color","line-break","line-height","line-height-step","list-style","list-style-image","list-style-position","list-style-type","margin","margin-block","margin-block-end","margin-block-start","margin-bottom","margin-inline","margin-inline-end","margin-inline-start","margin-left","margin-right","margin-top","margin-trim","marker","marker-end","marker-mid","marker-start","marks","mask","mask-border","mask-border-mode","mask-border-outset","mask-border-repeat","mask-border-slice","mask-border-source","mask-border-width","mask-clip","mask-composite","mask-image","mask-mode","mask-origin","mask-position","mask-repeat","mask-size","mask-type","masonry-auto-flow","math-depth","math-shift","math-style","max-block-size","max-height","max-inline-size","max-width","min-block-size","min-height","min-inline-size","min-width","mix-blend-mode","nav-down","nav-index","nav-left","nav-right","nav-up","none","normal","object-fit","object-position","offset","offset-anchor","offset-distance","offset-path","offset-position","offset-rotate","opacity","order","orphans","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-anchor","overflow-block","overflow-clip-margin","overflow-inline","overflow-wrap","overflow-x","overflow-y","overlay","overscroll-behavior","overscroll-behavior-block","overscroll-behavior-inline","overscroll-behavior-x","overscroll-behavior-y","padding","padding-block","padding-block-end","padding-block-start","padding-bottom","padding-inline","padding-inline-end","padding-inline-start","padding-left","padding-right","padding-top","page","page-break-after","page-break-before","page-break-inside","paint-order","pause","pause-after","pause-before","perspective","perspective-origin","place-content","place-items","place-self","pointer-events","position","position-anchor","position-visibility","print-color-adjust","quotes","r","resize","rest","rest-after","rest-before","right","rotate","row-gap","ruby-align","ruby-position","scale","scroll-behavior","scroll-margin","scroll-margin-block","scroll-margin-block-end","scroll-margin-block-start","scroll-margin-bottom","scroll-margin-inline","scroll-margin-inline-end","scroll-margin-inline-start","scroll-margin-left","scroll-margin-right","scroll-margin-top","scroll-padding","scroll-padding-block","scroll-padding-block-end","scroll-padding-block-start","scroll-padding-bottom","scroll-padding-inline","scroll-padding-inline-end","scroll-padding-inline-start","scroll-padding-left","scroll-padding-right","scroll-padding-top","scroll-snap-align","scroll-snap-stop","scroll-snap-type","scroll-timeline","scroll-timeline-axis","scroll-timeline-name","scrollbar-color","scrollbar-gutter","scrollbar-width","shape-image-threshold","shape-margin","shape-outside","shape-rendering","speak","speak-as","src","stop-color","stop-opacity","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","tab-size","table-layout","text-align","text-align-all","text-align-last","text-anchor","text-combine-upright","text-decoration","text-decoration-color","text-decoration-line","text-decoration-skip","text-decoration-skip-ink","text-decoration-style","text-decoration-thickness","text-emphasis","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-indent","text-justify","text-orientation","text-overflow","text-rendering","text-shadow","text-size-adjust","text-transform","text-underline-offset","text-underline-position","text-wrap","text-wrap-mode","text-wrap-style","timeline-scope","top","touch-action","transform","transform-box","transform-origin","transform-style","transition","transition-behavior","transition-delay","transition-duration","transition-property","transition-timing-function","translate","unicode-bidi","user-modify","user-select","vector-effect","vertical-align","view-timeline","view-timeline-axis","view-timeline-inset","view-timeline-name","view-transition-name","visibility","voice-balance","voice-duration","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","white-space","white-space-collapse","widows","width","will-change","word-break","word-spacing","word-wrap","writing-mode","x","y","z-index","zoom"].sort().reverse(),wG=bR.concat(xR).sort().reverse();function EG(e){const t=mG(e),n=wG,i="and or not only",s="[\\w-]+",r="("+s+"|@\\{"+s+"\\})",o=[],c=[],u=function(S){return{className:"string",begin:"~?"+S+".*?"+S}},f=function(S,T,A){return{className:S,begin:T,relevance:A}},p={$pattern:/[a-z-]+/,keyword:i,attribute:xG.join(" ")},m={begin:"\\(",end:"\\)",contains:c,keywords:p,relevance:0};c.push(e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,u("'"),u('"'),t.CSS_NUMBER_MODE,{begin:"(url|data-uri)\\(",starts:{className:"string",end:"[\\)\\n]",excludeEnd:!0}},t.HEXCOLOR,m,f("variable","@@?"+s,10),f("variable","@\\{"+s+"\\}"),f("built_in","~?`[^`]*?`"),{className:"attribute",begin:s+"\\s*:",end:":",returnBegin:!0,excludeEnd:!0},t.IMPORTANT,{beginKeywords:"and not"},t.FUNCTION_DISPATCH);const y=c.concat({begin:/\{/,end:/\}/,contains:o}),b={beginKeywords:"when",endsWithParent:!0,contains:[{beginKeywords:"and not"}].concat(c)},x={begin:r+"\\s*:",returnBegin:!0,end:/[;}]/,relevance:0,contains:[{begin:/-(webkit|moz|ms|o)-/},t.CSS_VARIABLE,{className:"attribute",begin:"\\b("+vG.join("|")+")\\b",end:/(?=:)/,starts:{endsWithParent:!0,illegal:"[<=$]",relevance:0,contains:c}}]},v={className:"keyword",begin:"@(import|media|charset|font-face|(-[a-z]+-)?keyframes|supports|document|namespace|page|viewport|host)\\b",starts:{end:"[;{}]",keywords:p,returnEnd:!0,contains:c,relevance:0}},w={className:"variable",variants:[{begin:"@"+s+"\\s*:",relevance:15},{begin:"@"+s}],starts:{end:"[;}]",returnEnd:!0,contains:y}},k={variants:[{begin:"[\\.#:&\\[>]",end:"[;{}]"},{begin:r,end:/\{/}],returnBegin:!0,returnEnd:!0,illegal:`[<='$"]`,relevance:0,contains:[e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,b,f("keyword","all\\b"),f("variable","@\\{"+s+"\\}"),{begin:"\\b("+bG.join("|")+")\\b",className:"selector-tag"},t.CSS_NUMBER_MODE,f("selector-tag",r,0),f("selector-id","#"+r),f("selector-class","\\."+r,0),f("selector-tag","&",0),t.ATTRIBUTE_SELECTOR_MODE,{className:"selector-pseudo",begin:":("+bR.join("|")+")"},{className:"selector-pseudo",begin:":(:)?("+xR.join("|")+")"},{begin:/\(/,end:/\)/,relevance:0,contains:y},{begin:"!important"},t.FUNCTION_DISPATCH]},C={begin:s+`:(:)?(${n.join("|")})`,returnBegin:!0,contains:[k]};return o.push(e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,v,w,C,x,k,b,t.FUNCTION_DISPATCH),{name:"Less",case_insensitive:!0,illegal:`[=>'/<($"]`,contains:o}}function kG(e){const t="\\[=*\\[",n="\\]=*\\]",i={begin:t,end:n,contains:["self"]},s=[e.COMMENT("--(?!"+t+")","$"),e.COMMENT("--"+t,n,{contains:[i],relevance:10})];return{name:"Lua",aliases:["pluto"],keywords:{$pattern:e.UNDERSCORE_IDENT_RE,literal:"true false nil",keyword:"and break do else elseif end for goto if in local not or repeat return then until while",built_in:"_G _ENV _VERSION __index __newindex __mode __call __metatable __tostring __len __gc __add __sub __mul __div __mod __pow __concat __unm __eq __lt __le assert collectgarbage dofile error getfenv getmetatable ipairs load loadfile loadstring module next pairs pcall print rawequal rawget rawset require select setfenv setmetatable tonumber tostring type unpack xpcall arg self coroutine resume yield status wrap create running debug getupvalue debug sethook getmetatable gethook setmetatable setlocal traceback setfenv getinfo setupvalue getlocal getregistry getfenv io lines write close flush open output type read stderr stdin input stdout popen tmpfile math log max acos huge ldexp pi cos tanh pow deg tan cosh sinh random randomseed frexp ceil floor rad abs sqrt modf asin min mod fmod log10 atan2 exp sin atan os exit setlocale date getenv difftime remove time clock tmpname rename execute package preload loadlib loaded loaders cpath config path seeall string sub upper len gfind rep find match char dump gmatch reverse byte format gsub lower table setn insert getn foreachi maxn foreach concat sort remove"},contains:s.concat([{className:"function",beginKeywords:"function",end:"\\)",contains:[e.inherit(e.TITLE_MODE,{begin:"([_a-zA-Z]\\w*\\.)*([_a-zA-Z]\\w*:)?[_a-zA-Z]\\w*"}),{className:"params",begin:"\\(",endsWithParent:!0,contains:s}].concat(s)},e.C_NUMBER_MODE,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,{className:"string",begin:t,end:n,contains:[i],relevance:5}])}}function SG(e){const t={className:"variable",variants:[{begin:"\\$\\("+e.UNDERSCORE_IDENT_RE+"\\)",contains:[e.BACKSLASH_ESCAPE]},{begin:/\$[@%<?\^\+\*]/}]},n={className:"string",begin:/"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,t]},i={className:"variable",begin:/\$\([\w-]+\s/,end:/\)/,keywords:{built_in:"subst patsubst strip findstring filter filter-out sort word wordlist firstword lastword dir notdir suffix basename addsuffix addprefix join wildcard realpath abspath error warning shell origin flavor foreach if or and call eval file value"},contains:[t,n]},s={begin:"^"+e.UNDERSCORE_IDENT_RE+"\\s*(?=[:+?]?=)"},r={className:"meta",begin:/^\.PHONY:/,end:/$/,keywords:{$pattern:/[\.\w]+/,keyword:".PHONY"}},o={className:"section",begin:/^[^\s]+:/,end:/$/,contains:[t]};return{name:"Makefile",aliases:["mk","mak","make"],keywords:{$pattern:/[\w-]+/,keyword:"define endef undefine ifdef ifndef ifeq ifneq else endif include -include sinclude override export unexport private vpath"},contains:[e.HASH_COMMENT_MODE,t,n,i,s,r,o]}}function NG(e){const t=e.regex,n={begin:/<\/?[A-Za-z_]/,end:">",subLanguage:"xml",relevance:0},i={begin:"^[-\\*]{3,}",end:"$"},s={className:"code",variants:[{begin:"(`{3,})[^`](.|\\n)*?\\1`*[ ]*"},{begin:"(~{3,})[^~](.|\\n)*?\\1~*[ ]*"},{begin:"```",end:"```+[ ]*$"},{begin:"~~~",end:"~~~+[ ]*$"},{begin:"`.+?`"},{begin:"(?=^( {4}|\\t))",contains:[{begin:"^( {4}|\\t)",end:"(\\n)$"}],relevance:0}]},r={className:"bullet",begin:"^[ ]*([*+-]|(\\d+\\.))(?=\\s+)",end:"\\s+",excludeEnd:!0},o={begin:/^\[[^\n]+\]:/,returnBegin:!0,contains:[{className:"symbol",begin:/\[/,end:/\]/,excludeBegin:!0,excludeEnd:!0},{className:"link",begin:/:\s*/,end:/$/,excludeBegin:!0}]},c=/[A-Za-z][A-Za-z0-9+.-]*/,u={variants:[{begin:/\[.+?\]\[.*?\]/,relevance:0},{begin:/\[.+?\]\(((data|javascript|mailto):|(?:http|ftp)s?:\/\/).*?\)/,relevance:2},{begin:t.concat(/\[.+?\]\(/,c,/:\/\/.*?\)/),relevance:2},{begin:/\[.+?\]\([./?&#].*?\)/,relevance:1},{begin:/\[.*?\]\(.*?\)/,relevance:0}],returnBegin:!0,contains:[{match:/\[(?=\])/},{className:"string",relevance:0,begin:"\\[",end:"\\]",excludeBegin:!0,returnEnd:!0},{className:"link",relevance:0,begin:"\\]\\(",end:"\\)",excludeBegin:!0,excludeEnd:!0},{className:"symbol",relevance:0,begin:"\\]\\[",end:"\\]",excludeBegin:!0,excludeEnd:!0}]},f={className:"strong",contains:[],variants:[{begin:/_{2}(?!\s)/,end:/_{2}/},{begin:/\*{2}(?!\s)/,end:/\*{2}/}]},p={className:"emphasis",contains:[],variants:[{begin:/\*(?![*\s])/,end:/\*/},{begin:/_(?![_\s])/,end:/_/,relevance:0}]},m=e.inherit(f,{contains:[]}),y=e.inherit(p,{contains:[]});f.contains.push(y),p.contains.push(m);let b=[n,u];return[f,p,m,y].forEach(k=>{k.contains=k.contains.concat(b)}),b=b.concat(f,p),{name:"Markdown",aliases:["md","mkdown","mkd"],contains:[{className:"section",variants:[{begin:"^#{1,6}",end:"$",contains:b},{begin:"(?=^.+?\\n[=-]{2,}$)",contains:[{begin:"^[=-]*$"},{begin:"^",end:"\\n",contains:b}]}]},n,r,f,p,{className:"quote",begin:"^>\\s+",contains:b,end:"$"},s,i,u,o,{scope:"literal",match:/&([a-zA-Z0-9]+|#[0-9]{1,7}|#[Xx][0-9a-fA-F]{1,6});/}]}}function _G(e){const t={className:"built_in",begin:"\\b(AV|CA|CF|CG|CI|CL|CM|CN|CT|MK|MP|MTK|MTL|NS|SCN|SK|UI|WK|XC)\\w+"},n=/[a-zA-Z@][a-zA-Z0-9_]*/,c={"variable.language":["this","super"],$pattern:n,keyword:["while","export","sizeof","typedef","const","struct","for","union","volatile","static","mutable","if","do","return","goto","enum","else","break","extern","asm","case","default","register","explicit","typename","switch","continue","inline","readonly","assign","readwrite","self","@synchronized","id","typeof","nonatomic","IBOutlet","IBAction","strong","weak","copy","in","out","inout","bycopy","byref","oneway","__strong","__weak","__block","__autoreleasing","@private","@protected","@public","@try","@property","@end","@throw","@catch","@finally","@autoreleasepool","@synthesize","@dynamic","@selector","@optional","@required","@encode","@package","@import","@defs","@compatibility_alias","__bridge","__bridge_transfer","__bridge_retained","__bridge_retain","__covariant","__contravariant","__kindof","_Nonnull","_Nullable","_Null_unspecified","__FUNCTION__","__PRETTY_FUNCTION__","__attribute__","getter","setter","retain","unsafe_unretained","nonnull","nullable","null_unspecified","null_resettable","class","instancetype","NS_DESIGNATED_INITIALIZER","NS_UNAVAILABLE","NS_REQUIRES_SUPER","NS_RETURNS_INNER_POINTER","NS_INLINE","NS_AVAILABLE","NS_DEPRECATED","NS_ENUM","NS_OPTIONS","NS_SWIFT_UNAVAILABLE","NS_ASSUME_NONNULL_BEGIN","NS_ASSUME_NONNULL_END","NS_REFINED_FOR_SWIFT","NS_SWIFT_NAME","NS_SWIFT_NOTHROW","NS_DURING","NS_HANDLER","NS_ENDHANDLER","NS_VALUERETURN","NS_VOIDRETURN"],literal:["false","true","FALSE","TRUE","nil","YES","NO","NULL"],built_in:["dispatch_once_t","dispatch_queue_t","dispatch_sync","dispatch_async","dispatch_once"],type:["int","float","char","unsigned","signed","short","long","double","wchar_t","unichar","void","bool","BOOL","id|0","_Bool"]},u={$pattern:n,keyword:["@interface","@class","@protocol","@implementation"]};return{name:"Objective-C",aliases:["mm","objc","obj-c","obj-c++","objective-c++"],keywords:c,illegal:"</",contains:[t,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,e.C_NUMBER_MODE,e.QUOTE_STRING_MODE,e.APOS_STRING_MODE,{className:"string",variants:[{begin:'@"',end:'"',illegal:"\\n",contains:[e.BACKSLASH_ESCAPE]}]},{className:"meta",begin:/#\s*[a-z]+\b/,end:/$/,keywords:{keyword:"if else elif endif define undef warning error line pragma ifdef ifndef include"},contains:[{begin:/\\\n/,relevance:0},e.inherit(e.QUOTE_STRING_MODE,{className:"string"}),{className:"string",begin:/<.*?>/,end:/$/,illegal:"\\n"},e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{className:"class",begin:"("+u.keyword.join("|")+")\\b",end:/(\{|$)/,excludeEnd:!0,keywords:u,contains:[e.UNDERSCORE_TITLE_MODE]},{begin:"\\."+e.UNDERSCORE_IDENT_RE,relevance:0}]}}function CG(e){const t=e.regex,n=["abs","accept","alarm","and","atan2","bind","binmode","bless","break","caller","chdir","chmod","chomp","chop","chown","chr","chroot","class","close","closedir","connect","continue","cos","crypt","dbmclose","dbmopen","defined","delete","die","do","dump","each","else","elsif","endgrent","endhostent","endnetent","endprotoent","endpwent","endservent","eof","eval","exec","exists","exit","exp","fcntl","field","fileno","flock","for","foreach","fork","format","formline","getc","getgrent","getgrgid","getgrnam","gethostbyaddr","gethostbyname","gethostent","getlogin","getnetbyaddr","getnetbyname","getnetent","getpeername","getpgrp","getpriority","getprotobyname","getprotobynumber","getprotoent","getpwent","getpwnam","getpwuid","getservbyname","getservbyport","getservent","getsockname","getsockopt","given","glob","gmtime","goto","grep","gt","hex","if","index","int","ioctl","join","keys","kill","last","lc","lcfirst","length","link","listen","local","localtime","log","lstat","lt","ma","map","method","mkdir","msgctl","msgget","msgrcv","msgsnd","my","ne","next","no","not","oct","open","opendir","or","ord","our","pack","package","pipe","pop","pos","print","printf","prototype","push","q|0","qq","quotemeta","qw","qx","rand","read","readdir","readline","readlink","readpipe","recv","redo","ref","rename","require","reset","return","reverse","rewinddir","rindex","rmdir","say","scalar","seek","seekdir","select","semctl","semget","semop","send","setgrent","sethostent","setnetent","setpgrp","setpriority","setprotoent","setpwent","setservent","setsockopt","shift","shmctl","shmget","shmread","shmwrite","shutdown","sin","sleep","socket","socketpair","sort","splice","split","sprintf","sqrt","srand","stat","state","study","sub","substr","symlink","syscall","sysopen","sysread","sysseek","system","syswrite","tell","telldir","tie","tied","time","times","tr","truncate","uc","ucfirst","umask","undef","unless","unlink","unpack","unshift","untie","until","use","utime","values","vec","wait","waitpid","wantarray","warn","when","while","write","x|0","xor","y|0"],i=/[dualxmsipngr]{0,12}/,s={$pattern:/[\w.]+/,keyword:n.join(" ")},r={className:"subst",begin:"[$@]\\{",end:"\\}",keywords:s},o={begin:/->\{/,end:/\}/},c={scope:"attr",match:/\s+:\s*\w+(\s*\(.*?\))?/},u={scope:"variable",variants:[{begin:/\$\d/},{begin:t.concat(/[$%@](?!")(\^\w\b|#\w+(::\w+)*|\{\w+\}|\w+(::\w*)*)/,"(?![A-Za-z])(?![@$%])")},{begin:/[$%@](?!")[^\s\w{=]|\$=/,relevance:0}],contains:[c]},f={className:"number",variants:[{match:/0?\.[0-9][0-9_]+\b/},{match:/\bv?(0|[1-9][0-9_]*(\.[0-9_]+)?|[1-9][0-9_]*)\b/},{match:/\b0[0-7][0-7_]*\b/},{match:/\b0x[0-9a-fA-F][0-9a-fA-F_]*\b/},{match:/\b0b[0-1][0-1_]*\b/}],relevance:0},p=[e.BACKSLASH_ESCAPE,r,u],m=[/!/,/\//,/\|/,/\?/,/'/,/"/,/#/],y=(v,w,k="\\1")=>{const C=k==="\\1"?k:t.concat(k,w);return t.concat(t.concat("(?:",v,")"),w,/(?:\\.|[^\\\/])*?/,C,/(?:\\.|[^\\\/])*?/,k,i)},b=(v,w,k)=>t.concat(t.concat("(?:",v,")"),w,/(?:\\.|[^\\\/])*?/,k,i),x=[u,e.HASH_COMMENT_MODE,e.COMMENT(/^=\w/,/=cut/,{endsWithParent:!0}),o,{className:"string",contains:p,variants:[{begin:"q[qwxr]?\\s*\\(",end:"\\)",relevance:5},{begin:"q[qwxr]?\\s*\\[",end:"\\]",relevance:5},{begin:"q[qwxr]?\\s*\\{",end:"\\}",relevance:5},{begin:"q[qwxr]?\\s*\\|",end:"\\|",relevance:5},{begin:"q[qwxr]?\\s*<",end:">",relevance:5},{begin:"qw\\s+q",end:"q",relevance:5},{begin:"'",end:"'",contains:[e.BACKSLASH_ESCAPE]},{begin:'"',end:'"'},{begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE]},{begin:/\{\w+\}/,relevance:0},{begin:"-?\\w+\\s*=>",relevance:0}]},f,{begin:"(\\/\\/|"+e.RE_STARTERS_RE+"|\\b(split|return|print|reverse|grep)\\b)\\s*",keywords:"split return print reverse grep",relevance:0,contains:[e.HASH_COMMENT_MODE,{className:"regexp",variants:[{begin:y("s|tr|y",t.either(...m,{capture:!0}))},{begin:y("s|tr|y","\\(","\\)")},{begin:y("s|tr|y","\\[","\\]")},{begin:y("s|tr|y","\\{","\\}")}],relevance:2},{className:"regexp",variants:[{begin:/(m|qr)\/\//,relevance:0},{begin:b("(?:m|qr)?",/\//,/\//)},{begin:b("m|qr",t.either(...m,{capture:!0}),/\1/)},{begin:b("m|qr",/\(/,/\)/)},{begin:b("m|qr",/\[/,/\]/)},{begin:b("m|qr",/\{/,/\}/)}]}]},{className:"function",beginKeywords:"sub method",end:"(\\s*\\(.*?\\))?[;{]",excludeEnd:!0,relevance:5,contains:[e.TITLE_MODE,c]},{className:"class",beginKeywords:"class",end:"[;{]",excludeEnd:!0,relevance:5,contains:[e.TITLE_MODE,c,f]},{begin:"-\\w\\b",relevance:0},{begin:"^__DATA__$",end:"^__END__$",subLanguage:"mojolicious",contains:[{begin:"^@@.*",end:"$",className:"comment"}]}];return r.contains=x,o.contains=x,{name:"Perl",aliases:["pl","pm"],keywords:s,contains:x}}function TG(e){const t=e.regex,n=/(?![A-Za-z0-9])(?![$])/,i=t.concat(/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/,n),s=t.concat(/(\\?[A-Z][a-z0-9_\x7f-\xff]+|\\?[A-Z]+(?=[A-Z][a-z0-9_\x7f-\xff])){1,}/,n),r=t.concat(/[A-Z]+/,n),o={scope:"variable",match:"\\$+"+i},c={scope:"meta",variants:[{begin:/<\?php/,relevance:10},{begin:/<\?=/},{begin:/<\?/,relevance:.1},{begin:/\?>/}]},u={scope:"subst",variants:[{begin:/\$\w+/},{begin:/\{\$/,end:/\}/}]},f=e.inherit(e.APOS_STRING_MODE,{illegal:null}),p=e.inherit(e.QUOTE_STRING_MODE,{illegal:null,contains:e.QUOTE_STRING_MODE.contains.concat(u)}),m={begin:/<<<[ \t]*(?:(\w+)|"(\w+)")\n/,end:/[ \t]*(\w+)\b/,contains:e.QUOTE_STRING_MODE.contains.concat(u),"on:begin":(R,O)=>{O.data._beginMatch=R[1]||R[2]},"on:end":(R,O)=>{O.data._beginMatch!==R[1]&&O.ignoreMatch()}},y=e.END_SAME_AS_BEGIN({begin:/<<<[ \t]*'(\w+)'\n/,end:/[ \t]*(\w+)\b/}),b=`[
|
|
665
665
|
]`,x={scope:"string",variants:[p,f,m,y]},v={scope:"number",variants:[{begin:"\\b0[bB][01]+(?:_[01]+)*\\b"},{begin:"\\b0[oO][0-7]+(?:_[0-7]+)*\\b"},{begin:"\\b0[xX][\\da-fA-F]+(?:_[\\da-fA-F]+)*\\b"},{begin:"(?:\\b\\d+(?:_\\d+)*(\\.(?:\\d+(?:_\\d+)*))?|\\B\\.\\d+)(?:[eE][+-]?\\d+)?"}],relevance:0},w=["false","null","true"],k=["__CLASS__","__DIR__","__FILE__","__FUNCTION__","__COMPILER_HALT_OFFSET__","__LINE__","__METHOD__","__NAMESPACE__","__TRAIT__","die","echo","exit","include","include_once","print","require","require_once","array","abstract","and","as","binary","bool","boolean","break","callable","case","catch","class","clone","const","continue","declare","default","do","double","else","elseif","empty","enddeclare","endfor","endforeach","endif","endswitch","endwhile","enum","eval","extends","final","finally","float","for","foreach","from","global","goto","if","implements","instanceof","insteadof","int","integer","interface","isset","iterable","list","match|0","mixed","new","never","object","or","private","protected","public","readonly","real","return","string","switch","throw","trait","try","unset","use","var","void","while","xor","yield"],C=["Error|0","AppendIterator","ArgumentCountError","ArithmeticError","ArrayIterator","ArrayObject","AssertionError","BadFunctionCallException","BadMethodCallException","CachingIterator","CallbackFilterIterator","CompileError","Countable","DirectoryIterator","DivisionByZeroError","DomainException","EmptyIterator","ErrorException","Exception","FilesystemIterator","FilterIterator","GlobIterator","InfiniteIterator","InvalidArgumentException","IteratorIterator","LengthException","LimitIterator","LogicException","MultipleIterator","NoRewindIterator","OutOfBoundsException","OutOfRangeException","OuterIterator","OverflowException","ParentIterator","ParseError","RangeException","RecursiveArrayIterator","RecursiveCachingIterator","RecursiveCallbackFilterIterator","RecursiveDirectoryIterator","RecursiveFilterIterator","RecursiveIterator","RecursiveIteratorIterator","RecursiveRegexIterator","RecursiveTreeIterator","RegexIterator","RuntimeException","SeekableIterator","SplDoublyLinkedList","SplFileInfo","SplFileObject","SplFixedArray","SplHeap","SplMaxHeap","SplMinHeap","SplObjectStorage","SplObserver","SplPriorityQueue","SplQueue","SplStack","SplSubject","SplTempFileObject","TypeError","UnderflowException","UnexpectedValueException","UnhandledMatchError","ArrayAccess","BackedEnum","Closure","Fiber","Generator","Iterator","IteratorAggregate","Serializable","Stringable","Throwable","Traversable","UnitEnum","WeakReference","WeakMap","Directory","__PHP_Incomplete_Class","parent","php_user_filter","self","static","stdClass"],T={keyword:k,literal:(R=>{const O=[];return R.forEach(z=>{O.push(z),z.toLowerCase()===z?O.push(z.toUpperCase()):O.push(z.toLowerCase())}),O})(w),built_in:C},A=R=>R.map(O=>O.replace(/\|\d+$/,"")),j={variants:[{match:[/new/,t.concat(b,"+"),t.concat("(?!",A(C).join("\\b|"),"\\b)"),s],scope:{1:"keyword",4:"title.class"}}]},M=t.concat(i,"\\b(?!\\()"),D={variants:[{match:[t.concat(/::/,t.lookahead(/(?!class\b)/)),M],scope:{2:"variable.constant"}},{match:[/::/,/class/],scope:{2:"variable.language"}},{match:[s,t.concat(/::/,t.lookahead(/(?!class\b)/)),M],scope:{1:"title.class",3:"variable.constant"}},{match:[s,t.concat("::",t.lookahead(/(?!class\b)/))],scope:{1:"title.class"}},{match:[s,/::/,/class/],scope:{1:"title.class",3:"variable.language"}}]},P={scope:"attr",match:t.concat(i,t.lookahead(":"),t.lookahead(/(?!::)/))},I={relevance:0,begin:/\(/,end:/\)/,keywords:T,contains:[P,o,D,e.C_BLOCK_COMMENT_MODE,x,v,j]},B={relevance:0,match:[/\b/,t.concat("(?!fn\\b|function\\b|",A(k).join("\\b|"),"|",A(C).join("\\b|"),"\\b)"),i,t.concat(b,"*"),t.lookahead(/(?=\()/)],scope:{3:"title.function.invoke"},contains:[I]};I.contains.push(B);const q=[P,D,e.C_BLOCK_COMMENT_MODE,x,v,j],G={begin:t.concat(/#\[\s*\\?/,t.either(s,r)),beginScope:"meta",end:/]/,endScope:"meta",keywords:{literal:w,keyword:["new","array"]},contains:[{begin:/\[/,end:/]/,keywords:{literal:w,keyword:["new","array"]},contains:["self",...q]},...q,{scope:"meta",variants:[{match:s},{match:r}]}]};return{case_insensitive:!1,keywords:T,contains:[G,e.HASH_COMMENT_MODE,e.COMMENT("//","$"),e.COMMENT("/\\*","\\*/",{contains:[{scope:"doctag",match:"@[A-Za-z]+"}]}),{match:/__halt_compiler\(\);/,keywords:"__halt_compiler",starts:{scope:"comment",end:e.MATCH_NOTHING_RE,contains:[{match:/\?>/,scope:"meta",endsParent:!0}]}},c,{scope:"variable.language",match:/\$this\b/},o,B,D,{match:[/const/,/\s/,i],scope:{1:"keyword",3:"variable.constant"}},j,{scope:"function",relevance:0,beginKeywords:"fn function",end:/[;{]/,excludeEnd:!0,illegal:"[$%\\[]",contains:[{beginKeywords:"use"},e.UNDERSCORE_TITLE_MODE,{begin:"=>",endsParent:!0},{scope:"params",begin:"\\(",end:"\\)",excludeBegin:!0,excludeEnd:!0,keywords:T,contains:["self",G,o,D,e.C_BLOCK_COMMENT_MODE,x,v]}]},{scope:"class",variants:[{beginKeywords:"enum",illegal:/[($"]/},{beginKeywords:"class interface trait",illegal:/[:($"]/}],relevance:0,end:/\{/,excludeEnd:!0,contains:[{beginKeywords:"extends implements"},e.UNDERSCORE_TITLE_MODE]},{beginKeywords:"namespace",relevance:0,end:";",illegal:/[.']/,contains:[e.inherit(e.UNDERSCORE_TITLE_MODE,{scope:"title.class"})]},{beginKeywords:"use",relevance:0,end:";",contains:[{match:/\b(as|const|function)\b/,scope:"keyword"},e.UNDERSCORE_TITLE_MODE]},x,v]}}function AG(e){return{name:"PHP template",subLanguage:"xml",contains:[{begin:/<\?(php|=)?/,end:/\?>/,subLanguage:"php",contains:[{begin:"/\\*",end:"\\*/",skip:!0},{begin:'b"',end:'"',skip:!0},{begin:"b'",end:"'",skip:!0},e.inherit(e.APOS_STRING_MODE,{illegal:null,className:null,contains:null,skip:!0}),e.inherit(e.QUOTE_STRING_MODE,{illegal:null,className:null,contains:null,skip:!0})]}]}}function jG(e){return{name:"Plain text",aliases:["text","txt"],disableAutodetect:!0}}function MG(e){const t=e.regex,n=new RegExp("[\\p{XID_Start}_]\\p{XID_Continue}*","u"),i=["and","as","assert","async","await","break","case","class","continue","def","del","elif","else","except","finally","for","from","global","if","import","in","is","lambda","match","nonlocal|10","not","or","pass","raise","return","try","while","with","yield"],c={$pattern:/[A-Za-z]\w+|__\w+__/,keyword:i,built_in:["__import__","abs","all","any","ascii","bin","bool","breakpoint","bytearray","bytes","callable","chr","classmethod","compile","complex","delattr","dict","dir","divmod","enumerate","eval","exec","filter","float","format","frozenset","getattr","globals","hasattr","hash","help","hex","id","input","int","isinstance","issubclass","iter","len","list","locals","map","max","memoryview","min","next","object","oct","open","ord","pow","print","property","range","repr","reversed","round","set","setattr","slice","sorted","staticmethod","str","sum","super","tuple","type","vars","zip"],literal:["__debug__","Ellipsis","False","None","NotImplemented","True"],type:["Any","Callable","Coroutine","Dict","List","Literal","Generic","Optional","Sequence","Set","Tuple","Type","Union"]},u={className:"meta",begin:/^(>>>|\.\.\.) /},f={className:"subst",begin:/\{/,end:/\}/,keywords:c,illegal:/#/},p={begin:/\{\{/,relevance:0},m={className:"string",contains:[e.BACKSLASH_ESCAPE],variants:[{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?'''/,end:/'''/,contains:[e.BACKSLASH_ESCAPE,u],relevance:10},{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?"""/,end:/"""/,contains:[e.BACKSLASH_ESCAPE,u],relevance:10},{begin:/([fF][rR]|[rR][fF]|[fF])'''/,end:/'''/,contains:[e.BACKSLASH_ESCAPE,u,p,f]},{begin:/([fF][rR]|[rR][fF]|[fF])"""/,end:/"""/,contains:[e.BACKSLASH_ESCAPE,u,p,f]},{begin:/([uU]|[rR])'/,end:/'/,relevance:10},{begin:/([uU]|[rR])"/,end:/"/,relevance:10},{begin:/([bB]|[bB][rR]|[rR][bB])'/,end:/'/},{begin:/([bB]|[bB][rR]|[rR][bB])"/,end:/"/},{begin:/([fF][rR]|[rR][fF]|[fF])'/,end:/'/,contains:[e.BACKSLASH_ESCAPE,p,f]},{begin:/([fF][rR]|[rR][fF]|[fF])"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,p,f]},e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},y="[0-9](_?[0-9])*",b=`(\\b(${y}))?\\.(${y})|\\b(${y})\\.`,x=`\\b|${i.join("|")}`,v={className:"number",relevance:0,variants:[{begin:`(\\b(${y})|(${b}))[eE][+-]?(${y})[jJ]?(?=${x})`},{begin:`(${b})[jJ]?`},{begin:`\\b([1-9](_?[0-9])*|0+(_?0)*)[lLjJ]?(?=${x})`},{begin:`\\b0[bB](_?[01])+[lL]?(?=${x})`},{begin:`\\b0[oO](_?[0-7])+[lL]?(?=${x})`},{begin:`\\b0[xX](_?[0-9a-fA-F])+[lL]?(?=${x})`},{begin:`\\b(${y})[jJ](?=${x})`}]},w={className:"comment",begin:t.lookahead(/# type:/),end:/$/,keywords:c,contains:[{begin:/# type:/},{begin:/#/,end:/\b\B/,endsWithParent:!0}]},k={className:"params",variants:[{className:"",begin:/\(\s*\)/,skip:!0},{begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:c,contains:["self",u,v,m,e.HASH_COMMENT_MODE]}]};return f.contains=[m,v,u],{name:"Python",aliases:["py","gyp","ipython"],unicodeRegex:!0,keywords:c,illegal:/(<\/|\?)|=>/,contains:[u,v,{scope:"variable.language",match:/\bself\b/},{beginKeywords:"if",relevance:0},{match:/\bor\b/,scope:"keyword"},m,w,e.HASH_COMMENT_MODE,{match:[/\bdef/,/\s+/,n],scope:{1:"keyword",3:"title.function"},contains:[k]},{variants:[{match:[/\bclass/,/\s+/,n,/\s*/,/\(\s*/,n,/\s*\)/]},{match:[/\bclass/,/\s+/,n]}],scope:{1:"keyword",3:"title.class",6:"title.class.inherited"}},{className:"meta",begin:/^[\t ]*@/,end:/(?=#)|$/,contains:[v,k,m]}]}}function RG(e){return{aliases:["pycon"],contains:[{className:"meta.prompt",starts:{end:/ |$/,starts:{end:"$",subLanguage:"python"}},variants:[{begin:/^>>>(?=[ ]|$)/},{begin:/^\.\.\.(?=[ ]|$)/}]}]}}function DG(e){const t=e.regex,n=/(?:(?:[a-zA-Z]|\.[._a-zA-Z])[._a-zA-Z0-9]*)|\.(?!\d)/,i=t.either(/0[xX][0-9a-fA-F]+\.[0-9a-fA-F]*[pP][+-]?\d+i?/,/0[xX][0-9a-fA-F]+(?:[pP][+-]?\d+)?[Li]?/,/(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?[Li]?/),s=/[=!<>:]=|\|\||&&|:::?|<-|<<-|->>|->|\|>|[-+*\/?!$&|:<=>@^~]|\*\*/,r=t.either(/[()]/,/[{}]/,/\[\[/,/[[\]]/,/\\/,/,/);return{name:"R",keywords:{$pattern:n,keyword:"function if in break next repeat else for while",literal:"NULL NA TRUE FALSE Inf NaN NA_integer_|10 NA_real_|10 NA_character_|10 NA_complex_|10",built_in:"LETTERS letters month.abb month.name pi T F abs acos acosh all any anyNA Arg as.call as.character as.complex as.double as.environment as.integer as.logical as.null.default as.numeric as.raw asin asinh atan atanh attr attributes baseenv browser c call ceiling class Conj cos cosh cospi cummax cummin cumprod cumsum digamma dim dimnames emptyenv exp expression floor forceAndCall gamma gc.time globalenv Im interactive invisible is.array is.atomic is.call is.character is.complex is.double is.environment is.expression is.finite is.function is.infinite is.integer is.language is.list is.logical is.matrix is.na is.name is.nan is.null is.numeric is.object is.pairlist is.raw is.recursive is.single is.symbol lazyLoadDBfetch length lgamma list log max min missing Mod names nargs nzchar oldClass on.exit pos.to.env proc.time prod quote range Re rep retracemem return round seq_along seq_len seq.int sign signif sin sinh sinpi sqrt standardGeneric substitute sum switch tan tanh tanpi tracemem trigamma trunc unclass untracemem UseMethod xtfrm"},contains:[e.COMMENT(/#'/,/$/,{contains:[{scope:"doctag",match:/@examples/,starts:{end:t.lookahead(t.either(/\n^#'\s*(?=@[a-zA-Z]+)/,/\n^(?!#')/)),endsParent:!0}},{scope:"doctag",begin:"@param",end:/$/,contains:[{scope:"variable",variants:[{match:n},{match:/`(?:\\.|[^`\\])+`/}],endsParent:!0}]},{scope:"doctag",match:/@[a-zA-Z]+/},{scope:"keyword",match:/\\[a-zA-Z]+/}]}),e.HASH_COMMENT_MODE,{scope:"string",contains:[e.BACKSLASH_ESCAPE],variants:[e.END_SAME_AS_BEGIN({begin:/[rR]"(-*)\(/,end:/\)(-*)"/}),e.END_SAME_AS_BEGIN({begin:/[rR]"(-*)\{/,end:/\}(-*)"/}),e.END_SAME_AS_BEGIN({begin:/[rR]"(-*)\[/,end:/\](-*)"/}),e.END_SAME_AS_BEGIN({begin:/[rR]'(-*)\(/,end:/\)(-*)'/}),e.END_SAME_AS_BEGIN({begin:/[rR]'(-*)\{/,end:/\}(-*)'/}),e.END_SAME_AS_BEGIN({begin:/[rR]'(-*)\[/,end:/\](-*)'/}),{begin:'"',end:'"',relevance:0},{begin:"'",end:"'",relevance:0}]},{relevance:0,variants:[{scope:{1:"operator",2:"number"},match:[s,i]},{scope:{1:"operator",2:"number"},match:[/%[^%]*%/,i]},{scope:{1:"punctuation",2:"number"},match:[r,i]},{scope:{2:"number"},match:[/[^a-zA-Z0-9._]|^/,i]}]},{scope:{3:"operator"},match:[n,/\s+/,/<-/,/\s+/]},{scope:"operator",relevance:0,variants:[{match:s},{match:/%[^%]*%/}]},{scope:"punctuation",relevance:0,match:r},{begin:"`",end:"`",contains:[{begin:/\\./}]}]}}function OG(e){const t=e.regex,n="([a-zA-Z_]\\w*[!?=]?|[-+~]@|<<|>>|=~|===?|<=>|[<>]=?|\\*\\*|[-/+%^&*~`|]|\\[\\]=?)",i=t.either(/\b([A-Z]+[a-z0-9]+)+/,/\b([A-Z]+[a-z0-9]+)+[A-Z]+/),s=t.concat(i,/(::\w+)*/),o={"variable.constant":["__FILE__","__LINE__","__ENCODING__"],"variable.language":["self","super"],keyword:["alias","and","begin","BEGIN","break","case","class","defined","do","else","elsif","end","END","ensure","for","if","in","module","next","not","or","redo","require","rescue","retry","return","then","undef","unless","until","when","while","yield",...["include","extend","prepend","public","private","protected","raise","throw"]],built_in:["proc","lambda","attr_accessor","attr_reader","attr_writer","define_method","private_constant","module_function"],literal:["true","false","nil"]},c={className:"doctag",begin:"@[A-Za-z]+"},u={begin:"#<",end:">"},f=[e.COMMENT("#","$",{contains:[c]}),e.COMMENT("^=begin","^=end",{contains:[c],relevance:10}),e.COMMENT("^__END__",e.MATCH_NOTHING_RE)],p={className:"subst",begin:/#\{/,end:/\}/,keywords:o},m={className:"string",contains:[e.BACKSLASH_ESCAPE,p],variants:[{begin:/'/,end:/'/},{begin:/"/,end:/"/},{begin:/`/,end:/`/},{begin:/%[qQwWx]?\(/,end:/\)/},{begin:/%[qQwWx]?\[/,end:/\]/},{begin:/%[qQwWx]?\{/,end:/\}/},{begin:/%[qQwWx]?</,end:/>/},{begin:/%[qQwWx]?\//,end:/\//},{begin:/%[qQwWx]?%/,end:/%/},{begin:/%[qQwWx]?-/,end:/-/},{begin:/%[qQwWx]?\|/,end:/\|/},{begin:/\B\?(\\\d{1,3})/},{begin:/\B\?(\\x[A-Fa-f0-9]{1,2})/},{begin:/\B\?(\\u\{?[A-Fa-f0-9]{1,6}\}?)/},{begin:/\B\?(\\M-\\C-|\\M-\\c|\\c\\M-|\\M-|\\C-\\M-)[\x20-\x7e]/},{begin:/\B\?\\(c|C-)[\x20-\x7e]/},{begin:/\B\?\\?\S/},{begin:t.concat(/<<[-~]?'?/,t.lookahead(/(\w+)(?=\W)[^\n]*\n(?:[^\n]*\n)*?\s*\1\b/)),contains:[e.END_SAME_AS_BEGIN({begin:/(\w+)/,end:/(\w+)/,contains:[e.BACKSLASH_ESCAPE,p]})]}]},y="[1-9](_?[0-9])*|0",b="[0-9](_?[0-9])*",x={className:"number",relevance:0,variants:[{begin:`\\b(${y})(\\.(${b}))?([eE][+-]?(${b})|r)?i?\\b`},{begin:"\\b0[dD][0-9](_?[0-9])*r?i?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*r?i?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*r?i?\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*r?i?\\b"},{begin:"\\b0(_?[0-7])+r?i?\\b"}]},v={variants:[{match:/\(\)/},{className:"params",begin:/\(/,end:/(?=\))/,excludeBegin:!0,endsParent:!0,keywords:o}]},j=[m,{variants:[{match:[/class\s+/,s,/\s+<\s+/,s]},{match:[/\b(class|module)\s+/,s]}],scope:{2:"title.class",4:"title.class.inherited"},keywords:o},{match:[/(include|extend)\s+/,s],scope:{2:"title.class"},keywords:o},{relevance:0,match:[s,/\.new[. (]/],scope:{1:"title.class"}},{relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"},{relevance:0,match:i,scope:"title.class"},{match:[/def/,/\s+/,n],scope:{1:"keyword",3:"title.function"},contains:[v]},{begin:e.IDENT_RE+"::"},{className:"symbol",begin:e.UNDERSCORE_IDENT_RE+"(!|\\?)?:",relevance:0},{className:"symbol",begin:":(?!\\s)",contains:[m,{begin:n}],relevance:0},x,{className:"variable",begin:"(\\$\\W)|((\\$|@@?)(\\w+))(?=[^@$?])(?![A-Za-z])(?![@$?'])"},{className:"params",begin:/\|(?!=)/,end:/\|/,excludeBegin:!0,excludeEnd:!0,relevance:0,keywords:o},{begin:"("+e.RE_STARTERS_RE+"|unless)\\s*",keywords:"unless",contains:[{className:"regexp",contains:[e.BACKSLASH_ESCAPE,p],illegal:/\n/,variants:[{begin:"/",end:"/[a-z]*"},{begin:/%r\{/,end:/\}[a-z]*/},{begin:"%r\\(",end:"\\)[a-z]*"},{begin:"%r!",end:"![a-z]*"},{begin:"%r\\[",end:"\\][a-z]*"}]}].concat(u,f),relevance:0}].concat(u,f);p.contains=j,v.contains=j;const I=[{begin:/^\s*=>/,starts:{end:"$",contains:j}},{className:"meta.prompt",begin:"^("+"[>?]>"+"|"+"[\\w#]+\\(\\w+\\):\\d+:\\d+[>*]"+"|"+"(\\w+-)?\\d+\\.\\d+\\.\\d+(p\\d+)?[^\\d][^>]+>"+")(?=[ ])",starts:{end:"$",keywords:o,contains:j}}];return f.unshift(u),{name:"Ruby",aliases:["rb","gemspec","podspec","thor","irb"],keywords:o,illegal:/\/\*/,contains:[e.SHEBANG({binary:"ruby"})].concat(I).concat(f).concat(j)}}function LG(e){const t=e.regex,n=/(r#)?/,i=t.concat(n,e.UNDERSCORE_IDENT_RE),s=t.concat(n,e.IDENT_RE),r={className:"title.function.invoke",relevance:0,begin:t.concat(/\b/,/(?!let|for|while|if|else|match\b)/,s,t.lookahead(/\s*\(/))},o="([ui](8|16|32|64|128|size)|f(32|64))?",c=["abstract","as","async","await","become","box","break","const","continue","crate","do","dyn","else","enum","extern","false","final","fn","for","if","impl","in","let","loop","macro","match","mod","move","mut","override","priv","pub","ref","return","self","Self","static","struct","super","trait","true","try","type","typeof","union","unsafe","unsized","use","virtual","where","while","yield"],u=["true","false","Some","None","Ok","Err"],f=["drop ","Copy","Send","Sized","Sync","Drop","Fn","FnMut","FnOnce","ToOwned","Clone","Debug","PartialEq","PartialOrd","Eq","Ord","AsRef","AsMut","Into","From","Default","Iterator","Extend","IntoIterator","DoubleEndedIterator","ExactSizeIterator","SliceConcatExt","ToString","assert!","assert_eq!","bitflags!","bytes!","cfg!","col!","concat!","concat_idents!","debug_assert!","debug_assert_eq!","env!","eprintln!","panic!","file!","format!","format_args!","include_bytes!","include_str!","line!","local_data_key!","module_path!","option_env!","print!","println!","select!","stringify!","try!","unimplemented!","unreachable!","vec!","write!","writeln!","macro_rules!","assert_ne!","debug_assert_ne!"],p=["i8","i16","i32","i64","i128","isize","u8","u16","u32","u64","u128","usize","f32","f64","str","char","bool","Box","Option","Result","String","Vec"];return{name:"Rust",aliases:["rs"],keywords:{$pattern:e.IDENT_RE+"!?",type:p,keyword:c,literal:u,built_in:f},illegal:"</",contains:[e.C_LINE_COMMENT_MODE,e.COMMENT("/\\*","\\*/",{contains:["self"]}),e.inherit(e.QUOTE_STRING_MODE,{begin:/b?"/,illegal:null}),{className:"symbol",begin:/'[a-zA-Z_][a-zA-Z0-9_]*(?!')/},{scope:"string",variants:[{begin:/b?r(#*)"(.|\n)*?"\1(?!#)/},{begin:/b?'/,end:/'/,contains:[{scope:"char.escape",match:/\\('|\w|x\w{2}|u\w{4}|U\w{8})/}]}]},{className:"number",variants:[{begin:"\\b0b([01_]+)"+o},{begin:"\\b0o([0-7_]+)"+o},{begin:"\\b0x([A-Fa-f0-9_]+)"+o},{begin:"\\b(\\d[\\d_]*(\\.[0-9_]+)?([eE][+-]?[0-9_]+)?)"+o}],relevance:0},{begin:[/fn/,/\s+/,i],className:{1:"keyword",3:"title.function"}},{className:"meta",begin:"#!?\\[",end:"\\]",contains:[{className:"string",begin:/"/,end:/"/,contains:[e.BACKSLASH_ESCAPE]}]},{begin:[/let/,/\s+/,/(?:mut\s+)?/,i],className:{1:"keyword",3:"keyword",4:"variable"}},{begin:[/for/,/\s+/,i,/\s+/,/in/],className:{1:"keyword",3:"variable",5:"keyword"}},{begin:[/type/,/\s+/,i],className:{1:"keyword",3:"title.class"}},{begin:[/(?:trait|enum|struct|union|impl|for)/,/\s+/,i],className:{1:"keyword",3:"title.class"}},{begin:e.IDENT_RE+"::",keywords:{keyword:"Self",built_in:f,type:p}},{className:"punctuation",begin:"->"},r]}}const IG=e=>({IMPORTANT:{scope:"meta",begin:"!important"},BLOCK_COMMENT:e.C_BLOCK_COMMENT_MODE,HEXCOLOR:{scope:"number",begin:/#(([0-9a-fA-F]{3,4})|(([0-9a-fA-F]{2}){3,4}))\b/},FUNCTION_DISPATCH:{className:"built_in",begin:/[\w-]+(?=\()/},ATTRIBUTE_SELECTOR_MODE:{scope:"selector-attr",begin:/\[/,end:/\]/,illegal:"$",contains:[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},CSS_NUMBER_MODE:{scope:"number",begin:e.NUMBER_RE+"(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?",relevance:0},CSS_VARIABLE:{className:"attr",begin:/--[A-Za-z_][A-Za-z0-9_-]*/}}),PG=["a","abbr","address","article","aside","audio","b","blockquote","body","button","canvas","caption","cite","code","dd","del","details","dfn","div","dl","dt","em","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","html","i","iframe","img","input","ins","kbd","label","legend","li","main","mark","menu","nav","object","ol","optgroup","option","p","picture","q","quote","samp","section","select","source","span","strong","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","ul","var","video"],zG=["defs","g","marker","mask","pattern","svg","switch","symbol","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feFlood","feGaussianBlur","feImage","feMerge","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","linearGradient","radialGradient","stop","circle","ellipse","image","line","path","polygon","polyline","rect","text","use","textPath","tspan","foreignObject","clipPath"],BG=[...PG,...zG],UG=["any-hover","any-pointer","aspect-ratio","color","color-gamut","color-index","device-aspect-ratio","device-height","device-width","display-mode","forced-colors","grid","height","hover","inverted-colors","monochrome","orientation","overflow-block","overflow-inline","pointer","prefers-color-scheme","prefers-contrast","prefers-reduced-motion","prefers-reduced-transparency","resolution","scan","scripting","update","width","min-width","max-width","min-height","max-height"].sort().reverse(),FG=["active","any-link","blank","checked","current","default","defined","dir","disabled","drop","empty","enabled","first","first-child","first-of-type","fullscreen","future","focus","focus-visible","focus-within","has","host","host-context","hover","indeterminate","in-range","invalid","is","lang","last-child","last-of-type","left","link","local-link","not","nth-child","nth-col","nth-last-child","nth-last-col","nth-last-of-type","nth-of-type","only-child","only-of-type","optional","out-of-range","past","placeholder-shown","read-only","read-write","required","right","root","scope","target","target-within","user-invalid","valid","visited","where"].sort().reverse(),$G=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),qG=["accent-color","align-content","align-items","align-self","alignment-baseline","all","anchor-name","animation","animation-composition","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-range","animation-range-end","animation-range-start","animation-timeline","animation-timing-function","appearance","aspect-ratio","backdrop-filter","backface-visibility","background","background-attachment","background-blend-mode","background-clip","background-color","background-image","background-origin","background-position","background-position-x","background-position-y","background-repeat","background-size","baseline-shift","block-size","border","border-block","border-block-color","border-block-end","border-block-end-color","border-block-end-style","border-block-end-width","border-block-start","border-block-start-color","border-block-start-style","border-block-start-width","border-block-style","border-block-width","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-collapse","border-color","border-end-end-radius","border-end-start-radius","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-inline","border-inline-color","border-inline-end","border-inline-end-color","border-inline-end-style","border-inline-end-width","border-inline-start","border-inline-start-color","border-inline-start-style","border-inline-start-width","border-inline-style","border-inline-width","border-left","border-left-color","border-left-style","border-left-width","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-spacing","border-start-end-radius","border-start-start-radius","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-align","box-decoration-break","box-direction","box-flex","box-flex-group","box-lines","box-ordinal-group","box-orient","box-pack","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","caret-color","clear","clip","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","color-scheme","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","contain","contain-intrinsic-block-size","contain-intrinsic-height","contain-intrinsic-inline-size","contain-intrinsic-size","contain-intrinsic-width","container","container-name","container-type","content","content-visibility","counter-increment","counter-reset","counter-set","cue","cue-after","cue-before","cursor","cx","cy","direction","display","dominant-baseline","empty-cells","enable-background","field-sizing","fill","fill-opacity","fill-rule","filter","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","flood-color","flood-opacity","flow","font","font-display","font-family","font-feature-settings","font-kerning","font-language-override","font-optical-sizing","font-palette","font-size","font-size-adjust","font-smooth","font-smoothing","font-stretch","font-style","font-synthesis","font-synthesis-position","font-synthesis-small-caps","font-synthesis-style","font-synthesis-weight","font-variant","font-variant-alternates","font-variant-caps","font-variant-east-asian","font-variant-emoji","font-variant-ligatures","font-variant-numeric","font-variant-position","font-variation-settings","font-weight","forced-color-adjust","gap","glyph-orientation-horizontal","glyph-orientation-vertical","grid","grid-area","grid-auto-columns","grid-auto-flow","grid-auto-rows","grid-column","grid-column-end","grid-column-start","grid-gap","grid-row","grid-row-end","grid-row-start","grid-template","grid-template-areas","grid-template-columns","grid-template-rows","hanging-punctuation","height","hyphenate-character","hyphenate-limit-chars","hyphens","icon","image-orientation","image-rendering","image-resolution","ime-mode","initial-letter","initial-letter-align","inline-size","inset","inset-area","inset-block","inset-block-end","inset-block-start","inset-inline","inset-inline-end","inset-inline-start","isolation","justify-content","justify-items","justify-self","kerning","left","letter-spacing","lighting-color","line-break","line-height","line-height-step","list-style","list-style-image","list-style-position","list-style-type","margin","margin-block","margin-block-end","margin-block-start","margin-bottom","margin-inline","margin-inline-end","margin-inline-start","margin-left","margin-right","margin-top","margin-trim","marker","marker-end","marker-mid","marker-start","marks","mask","mask-border","mask-border-mode","mask-border-outset","mask-border-repeat","mask-border-slice","mask-border-source","mask-border-width","mask-clip","mask-composite","mask-image","mask-mode","mask-origin","mask-position","mask-repeat","mask-size","mask-type","masonry-auto-flow","math-depth","math-shift","math-style","max-block-size","max-height","max-inline-size","max-width","min-block-size","min-height","min-inline-size","min-width","mix-blend-mode","nav-down","nav-index","nav-left","nav-right","nav-up","none","normal","object-fit","object-position","offset","offset-anchor","offset-distance","offset-path","offset-position","offset-rotate","opacity","order","orphans","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-anchor","overflow-block","overflow-clip-margin","overflow-inline","overflow-wrap","overflow-x","overflow-y","overlay","overscroll-behavior","overscroll-behavior-block","overscroll-behavior-inline","overscroll-behavior-x","overscroll-behavior-y","padding","padding-block","padding-block-end","padding-block-start","padding-bottom","padding-inline","padding-inline-end","padding-inline-start","padding-left","padding-right","padding-top","page","page-break-after","page-break-before","page-break-inside","paint-order","pause","pause-after","pause-before","perspective","perspective-origin","place-content","place-items","place-self","pointer-events","position","position-anchor","position-visibility","print-color-adjust","quotes","r","resize","rest","rest-after","rest-before","right","rotate","row-gap","ruby-align","ruby-position","scale","scroll-behavior","scroll-margin","scroll-margin-block","scroll-margin-block-end","scroll-margin-block-start","scroll-margin-bottom","scroll-margin-inline","scroll-margin-inline-end","scroll-margin-inline-start","scroll-margin-left","scroll-margin-right","scroll-margin-top","scroll-padding","scroll-padding-block","scroll-padding-block-end","scroll-padding-block-start","scroll-padding-bottom","scroll-padding-inline","scroll-padding-inline-end","scroll-padding-inline-start","scroll-padding-left","scroll-padding-right","scroll-padding-top","scroll-snap-align","scroll-snap-stop","scroll-snap-type","scroll-timeline","scroll-timeline-axis","scroll-timeline-name","scrollbar-color","scrollbar-gutter","scrollbar-width","shape-image-threshold","shape-margin","shape-outside","shape-rendering","speak","speak-as","src","stop-color","stop-opacity","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","tab-size","table-layout","text-align","text-align-all","text-align-last","text-anchor","text-combine-upright","text-decoration","text-decoration-color","text-decoration-line","text-decoration-skip","text-decoration-skip-ink","text-decoration-style","text-decoration-thickness","text-emphasis","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-indent","text-justify","text-orientation","text-overflow","text-rendering","text-shadow","text-size-adjust","text-transform","text-underline-offset","text-underline-position","text-wrap","text-wrap-mode","text-wrap-style","timeline-scope","top","touch-action","transform","transform-box","transform-origin","transform-style","transition","transition-behavior","transition-delay","transition-duration","transition-property","transition-timing-function","translate","unicode-bidi","user-modify","user-select","vector-effect","vertical-align","view-timeline","view-timeline-axis","view-timeline-inset","view-timeline-name","view-transition-name","visibility","voice-balance","voice-duration","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","white-space","white-space-collapse","widows","width","will-change","word-break","word-spacing","word-wrap","writing-mode","x","y","z-index","zoom"].sort().reverse();function HG(e){const t=IG(e),n=$G,i=FG,s="@[a-z-]+",r="and or not only",c={className:"variable",begin:"(\\$"+"[a-zA-Z-][a-zA-Z0-9_-]*"+")\\b",relevance:0};return{name:"SCSS",case_insensitive:!0,illegal:"[=/|']",contains:[e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,t.CSS_NUMBER_MODE,{className:"selector-id",begin:"#[A-Za-z0-9_-]+",relevance:0},{className:"selector-class",begin:"\\.[A-Za-z0-9_-]+",relevance:0},t.ATTRIBUTE_SELECTOR_MODE,{className:"selector-tag",begin:"\\b("+BG.join("|")+")\\b",relevance:0},{className:"selector-pseudo",begin:":("+i.join("|")+")"},{className:"selector-pseudo",begin:":(:)?("+n.join("|")+")"},c,{begin:/\(/,end:/\)/,contains:[t.CSS_NUMBER_MODE]},t.CSS_VARIABLE,{className:"attribute",begin:"\\b("+qG.join("|")+")\\b"},{begin:"\\b(whitespace|wait|w-resize|visible|vertical-text|vertical-ideographic|uppercase|upper-roman|upper-alpha|underline|transparent|top|thin|thick|text|text-top|text-bottom|tb-rl|table-header-group|table-footer-group|sw-resize|super|strict|static|square|solid|small-caps|separate|se-resize|scroll|s-resize|rtl|row-resize|ridge|right|repeat|repeat-y|repeat-x|relative|progress|pointer|overline|outside|outset|oblique|nowrap|not-allowed|normal|none|nw-resize|no-repeat|no-drop|newspaper|ne-resize|n-resize|move|middle|medium|ltr|lr-tb|lowercase|lower-roman|lower-alpha|loose|list-item|line|line-through|line-edge|lighter|left|keep-all|justify|italic|inter-word|inter-ideograph|inside|inset|inline|inline-block|inherit|inactive|ideograph-space|ideograph-parenthesis|ideograph-numeric|ideograph-alpha|horizontal|hidden|help|hand|groove|fixed|ellipsis|e-resize|double|dotted|distribute|distribute-space|distribute-letter|distribute-all-lines|disc|disabled|default|decimal|dashed|crosshair|collapse|col-resize|circle|char|center|capitalize|break-word|break-all|bottom|both|bolder|bold|block|bidi-override|below|baseline|auto|always|all-scroll|absolute|table|table-cell)\\b"},{begin:/:/,end:/[;}{]/,relevance:0,contains:[t.BLOCK_COMMENT,c,t.HEXCOLOR,t.CSS_NUMBER_MODE,e.QUOTE_STRING_MODE,e.APOS_STRING_MODE,t.IMPORTANT,t.FUNCTION_DISPATCH]},{begin:"@(page|font-face)",keywords:{$pattern:s,keyword:"@page @font-face"}},{begin:"@",end:"[{;]",returnBegin:!0,keywords:{$pattern:/[a-z-]+/,keyword:r,attribute:UG.join(" ")},contains:[{begin:s,className:"keyword"},{begin:/[a-z-]+(?=:)/,className:"attribute"},c,e.QUOTE_STRING_MODE,e.APOS_STRING_MODE,t.HEXCOLOR,t.CSS_NUMBER_MODE]},t.FUNCTION_DISPATCH]}}function VG(e){return{name:"Shell Session",aliases:["console","shellsession"],contains:[{className:"meta.prompt",begin:/^\s{0,3}[/~\w\d[\]()@-]*[>%$#][ ]?/,starts:{end:/[^\\](?=\s*$)/,subLanguage:"bash"}}]}}function KG(e){const t=e.regex,n=e.COMMENT("--","$"),i={scope:"string",variants:[{begin:/'/,end:/'/,contains:[{match:/''/}]}]},s={begin:/"/,end:/"/,contains:[{match:/""/}]},r=["true","false","unknown"],o=["double precision","large object","with timezone","without timezone"],c=["bigint","binary","blob","boolean","char","character","clob","date","dec","decfloat","decimal","float","int","integer","interval","nchar","nclob","national","numeric","real","row","smallint","time","timestamp","varchar","varying","varbinary"],u=["add","asc","collation","desc","final","first","last","view"],f=["abs","acos","all","allocate","alter","and","any","are","array","array_agg","array_max_cardinality","as","asensitive","asin","asymmetric","at","atan","atomic","authorization","avg","begin","begin_frame","begin_partition","between","bigint","binary","blob","boolean","both","by","call","called","cardinality","cascaded","case","cast","ceil","ceiling","char","char_length","character","character_length","check","classifier","clob","close","coalesce","collate","collect","column","commit","condition","connect","constraint","contains","convert","copy","corr","corresponding","cos","cosh","count","covar_pop","covar_samp","create","cross","cube","cume_dist","current","current_catalog","current_date","current_default_transform_group","current_path","current_role","current_row","current_schema","current_time","current_timestamp","current_path","current_role","current_transform_group_for_type","current_user","cursor","cycle","date","day","deallocate","dec","decimal","decfloat","declare","default","define","delete","dense_rank","deref","describe","deterministic","disconnect","distinct","double","drop","dynamic","each","element","else","empty","end","end_frame","end_partition","end-exec","equals","escape","every","except","exec","execute","exists","exp","external","extract","false","fetch","filter","first_value","float","floor","for","foreign","frame_row","free","from","full","function","fusion","get","global","grant","group","grouping","groups","having","hold","hour","identity","in","indicator","initial","inner","inout","insensitive","insert","int","integer","intersect","intersection","interval","into","is","join","json_array","json_arrayagg","json_exists","json_object","json_objectagg","json_query","json_table","json_table_primitive","json_value","lag","language","large","last_value","lateral","lead","leading","left","like","like_regex","listagg","ln","local","localtime","localtimestamp","log","log10","lower","match","match_number","match_recognize","matches","max","member","merge","method","min","minute","mod","modifies","module","month","multiset","national","natural","nchar","nclob","new","no","none","normalize","not","nth_value","ntile","null","nullif","numeric","octet_length","occurrences_regex","of","offset","old","omit","on","one","only","open","or","order","out","outer","over","overlaps","overlay","parameter","partition","pattern","per","percent","percent_rank","percentile_cont","percentile_disc","period","portion","position","position_regex","power","precedes","precision","prepare","primary","procedure","ptf","range","rank","reads","real","recursive","ref","references","referencing","regr_avgx","regr_avgy","regr_count","regr_intercept","regr_r2","regr_slope","regr_sxx","regr_sxy","regr_syy","release","result","return","returns","revoke","right","rollback","rollup","row","row_number","rows","running","savepoint","scope","scroll","search","second","seek","select","sensitive","session_user","set","show","similar","sin","sinh","skip","smallint","some","specific","specifictype","sql","sqlexception","sqlstate","sqlwarning","sqrt","start","static","stddev_pop","stddev_samp","submultiset","subset","substring","substring_regex","succeeds","sum","symmetric","system","system_time","system_user","table","tablesample","tan","tanh","then","time","timestamp","timezone_hour","timezone_minute","to","trailing","translate","translate_regex","translation","treat","trigger","trim","trim_array","true","truncate","uescape","union","unique","unknown","unnest","update","upper","user","using","value","values","value_of","var_pop","var_samp","varbinary","varchar","varying","versioning","when","whenever","where","width_bucket","window","with","within","without","year"],p=["abs","acos","array_agg","asin","atan","avg","cast","ceil","ceiling","coalesce","corr","cos","cosh","count","covar_pop","covar_samp","cume_dist","dense_rank","deref","element","exp","extract","first_value","floor","json_array","json_arrayagg","json_exists","json_object","json_objectagg","json_query","json_table","json_table_primitive","json_value","lag","last_value","lead","listagg","ln","log","log10","lower","max","min","mod","nth_value","ntile","nullif","percent_rank","percentile_cont","percentile_disc","position","position_regex","power","rank","regr_avgx","regr_avgy","regr_count","regr_intercept","regr_r2","regr_slope","regr_sxx","regr_sxy","regr_syy","row_number","sin","sinh","sqrt","stddev_pop","stddev_samp","substring","substring_regex","sum","tan","tanh","translate","translate_regex","treat","trim","trim_array","unnest","upper","value_of","var_pop","var_samp","width_bucket"],m=["current_catalog","current_date","current_default_transform_group","current_path","current_role","current_schema","current_transform_group_for_type","current_user","session_user","system_time","system_user","current_time","localtime","current_timestamp","localtimestamp"],y=["create table","insert into","primary key","foreign key","not null","alter table","add constraint","grouping sets","on overflow","character set","respect nulls","ignore nulls","nulls first","nulls last","depth first","breadth first"],b=p,x=[...f,...u].filter(A=>!p.includes(A)),v={scope:"variable",match:/@[a-z0-9][a-z0-9_]*/},w={scope:"operator",match:/[-+*/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?/,relevance:0},k={match:t.concat(/\b/,t.either(...b),/\s*\(/),relevance:0,keywords:{built_in:b}};function C(A){return t.concat(/\b/,t.either(...A.map(j=>j.replace(/\s+/,"\\s+"))),/\b/)}const S={scope:"keyword",match:C(y),relevance:0};function T(A,{exceptions:j,when:M}={}){const D=M;return j=j||[],A.map(P=>P.match(/\|\d+$/)||j.includes(P)?P:D(P)?`${P}|0`:P)}return{name:"SQL",case_insensitive:!0,illegal:/[{}]|<\//,keywords:{$pattern:/\b[\w\.]+/,keyword:T(x,{when:A=>A.length<3}),literal:r,type:c,built_in:m},contains:[{scope:"type",match:C(o)},S,k,v,i,s,e.C_NUMBER_MODE,e.C_BLOCK_COMMENT_MODE,n,w]}}function vR(e){return e?typeof e=="string"?e:e.source:null}function od(e){return an("(?=",e,")")}function an(...e){return e.map(n=>vR(n)).join("")}function GG(e){const t=e[e.length-1];return typeof t=="object"&&t.constructor===Object?(e.splice(e.length-1,1),t):{}}function Ci(...e){return"("+(GG(e).capture?"":"?:")+e.map(i=>vR(i)).join("|")+")"}const N1=e=>an(/\b/,e,/\w$/.test(e)?/\b/:/\B/),WG=["Protocol","Type"].map(N1),w2=["init","self"].map(N1),YG=["Any","Self"],Jb=["actor","any","associatedtype","async","await",/as\?/,/as!/,"as","borrowing","break","case","catch","class","consume","consuming","continue","convenience","copy","default","defer","deinit","didSet","distributed","do","dynamic","each","else","enum","extension","fallthrough",/fileprivate\(set\)/,"fileprivate","final","for","func","get","guard","if","import","indirect","infix",/init\?/,/init!/,"inout",/internal\(set\)/,"internal","in","is","isolated","nonisolated","lazy","let","macro","mutating","nonmutating",/open\(set\)/,"open","operator","optional","override","package","postfix","precedencegroup","prefix",/private\(set\)/,"private","protocol",/public\(set\)/,"public","repeat","required","rethrows","return","set","some","static","struct","subscript","super","switch","throws","throw",/try\?/,/try!/,"try","typealias",/unowned\(safe\)/,/unowned\(unsafe\)/,"unowned","var","weak","where","while","willSet"],E2=["false","nil","true"],XG=["assignment","associativity","higherThan","left","lowerThan","none","right"],QG=["#colorLiteral","#column","#dsohandle","#else","#elseif","#endif","#error","#file","#fileID","#fileLiteral","#filePath","#function","#if","#imageLiteral","#keyPath","#line","#selector","#sourceLocation","#warning"],k2=["abs","all","any","assert","assertionFailure","debugPrint","dump","fatalError","getVaList","isKnownUniquelyReferenced","max","min","numericCast","pointwiseMax","pointwiseMin","precondition","preconditionFailure","print","readLine","repeatElement","sequence","stride","swap","swift_unboxFromSwiftValueWithType","transcode","type","unsafeBitCast","unsafeDowncast","withExtendedLifetime","withUnsafeMutablePointer","withUnsafePointer","withVaList","withoutActuallyEscaping","zip"],wR=Ci(/[/=\-+!*%<>&|^~?]/,/[\u00A1-\u00A7]/,/[\u00A9\u00AB]/,/[\u00AC\u00AE]/,/[\u00B0\u00B1]/,/[\u00B6\u00BB\u00BF\u00D7\u00F7]/,/[\u2016-\u2017]/,/[\u2020-\u2027]/,/[\u2030-\u203E]/,/[\u2041-\u2053]/,/[\u2055-\u205E]/,/[\u2190-\u23FF]/,/[\u2500-\u2775]/,/[\u2794-\u2BFF]/,/[\u2E00-\u2E7F]/,/[\u3001-\u3003]/,/[\u3008-\u3020]/,/[\u3030]/),ER=Ci(wR,/[\u0300-\u036F]/,/[\u1DC0-\u1DFF]/,/[\u20D0-\u20FF]/,/[\uFE00-\uFE0F]/,/[\uFE20-\uFE2F]/),ex=an(wR,ER,"*"),kR=Ci(/[a-zA-Z_]/,/[\u00A8\u00AA\u00AD\u00AF\u00B2-\u00B5\u00B7-\u00BA]/,/[\u00BC-\u00BE\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u00FF]/,/[\u0100-\u02FF\u0370-\u167F\u1681-\u180D\u180F-\u1DBF]/,/[\u1E00-\u1FFF]/,/[\u200B-\u200D\u202A-\u202E\u203F-\u2040\u2054\u2060-\u206F]/,/[\u2070-\u20CF\u2100-\u218F\u2460-\u24FF\u2776-\u2793]/,/[\u2C00-\u2DFF\u2E80-\u2FFF]/,/[\u3004-\u3007\u3021-\u302F\u3031-\u303F\u3040-\uD7FF]/,/[\uF900-\uFD3D\uFD40-\uFDCF\uFDF0-\uFE1F\uFE30-\uFE44]/,/[\uFE47-\uFEFE\uFF00-\uFFFD]/),sm=Ci(kR,/\d/,/[\u0300-\u036F\u1DC0-\u1DFF\u20D0-\u20FF\uFE20-\uFE2F]/),pr=an(kR,sm,"*"),Jh=an(/[A-Z]/,sm,"*"),ZG=["attached","autoclosure",an(/convention\(/,Ci("swift","block","c"),/\)/),"discardableResult","dynamicCallable","dynamicMemberLookup","escaping","freestanding","frozen","GKInspectable","IBAction","IBDesignable","IBInspectable","IBOutlet","IBSegueAction","inlinable","main","nonobjc","NSApplicationMain","NSCopying","NSManaged",an(/objc\(/,pr,/\)/),"objc","objcMembers","propertyWrapper","requires_stored_property_inits","resultBuilder","Sendable","testable","UIApplicationMain","unchecked","unknown","usableFromInline","warn_unqualified_access"],JG=["iOS","iOSApplicationExtension","macOS","macOSApplicationExtension","macCatalyst","macCatalystApplicationExtension","watchOS","watchOSApplicationExtension","tvOS","tvOSApplicationExtension","swift"];function eW(e){const t={match:/\s+/,relevance:0},n=e.COMMENT("/\\*","\\*/",{contains:["self"]}),i=[e.C_LINE_COMMENT_MODE,n],s={match:[/\./,Ci(...WG,...w2)],className:{2:"keyword"}},r={match:an(/\./,Ci(...Jb)),relevance:0},o=Jb.filter(ke=>typeof ke=="string").concat(["_|0"]),c=Jb.filter(ke=>typeof ke!="string").concat(YG).map(N1),u={variants:[{className:"keyword",match:Ci(...c,...w2)}]},f={$pattern:Ci(/\b\w+/,/#\w+/),keyword:o.concat(QG),literal:E2},p=[s,r,u],m={match:an(/\./,Ci(...k2)),relevance:0},y={className:"built_in",match:an(/\b/,Ci(...k2),/(?=\()/)},b=[m,y],x={match:/->/,relevance:0},v={className:"operator",relevance:0,variants:[{match:ex},{match:`\\.(\\.|${ER})+`}]},w=[x,v],k="([0-9]_*)+",C="([0-9a-fA-F]_*)+",S={className:"number",relevance:0,variants:[{match:`\\b(${k})(\\.(${k}))?([eE][+-]?(${k}))?\\b`},{match:`\\b0x(${C})(\\.(${C}))?([pP][+-]?(${k}))?\\b`},{match:/\b0o([0-7]_*)+\b/},{match:/\b0b([01]_*)+\b/}]},T=(ke="")=>({className:"subst",variants:[{match:an(/\\/,ke,/[0\\tnr"']/)},{match:an(/\\/,ke,/u\{[0-9a-fA-F]{1,8}\}/)}]}),A=(ke="")=>({className:"subst",match:an(/\\/,ke,/[\t ]*(?:[\r\n]|\r\n)/)}),j=(ke="")=>({className:"subst",label:"interpol",begin:an(/\\/,ke,/\(/),end:/\)/}),M=(ke="")=>({begin:an(ke,/"""/),end:an(/"""/,ke),contains:[T(ke),A(ke),j(ke)]}),D=(ke="")=>({begin:an(ke,/"/),end:an(/"/,ke),contains:[T(ke),j(ke)]}),P={className:"string",variants:[M(),M("#"),M("##"),M("###"),D(),D("#"),D("##"),D("###")]},I=[e.BACKSLASH_ESCAPE,{begin:/\[/,end:/\]/,relevance:0,contains:[e.BACKSLASH_ESCAPE]}],B={begin:/\/[^\s](?=[^/\n]*\/)/,end:/\//,contains:I},q=ke=>{const Ue=an(ke,/\//),Oe=an(/\//,ke);return{begin:Ue,end:Oe,contains:[...I,{scope:"comment",begin:`#(?!.*${Oe})`,end:/$/}]}},G={scope:"regexp",variants:[q("###"),q("##"),q("#"),B]},R={match:an(/`/,pr,/`/)},O={className:"variable",match:/\$\d+/},z={className:"variable",match:`\\$${sm}+`},W=[R,O,z],X={match:/(@|#(un)?)available/,scope:"keyword",starts:{contains:[{begin:/\(/,end:/\)/,keywords:JG,contains:[...w,S,P]}]}},K={scope:"keyword",match:an(/@/,Ci(...ZG),od(Ci(/\(/,/\s+/)))},U={scope:"meta",match:an(/@/,pr)},F=[X,K,U],Y={match:od(/\b[A-Z]/),relevance:0,contains:[{className:"type",match:an(/(AV|CA|CF|CG|CI|CL|CM|CN|CT|MK|MP|MTK|MTL|NS|SCN|SK|UI|WK|XC)/,sm,"+")},{className:"type",match:Jh,relevance:0},{match:/[?!]+/,relevance:0},{match:/\.\.\./,relevance:0},{match:an(/\s+&\s+/,od(Jh)),relevance:0}]},$={begin:/</,end:/>/,keywords:f,contains:[...i,...p,...F,x,Y]};Y.contains.push($);const ie={match:an(pr,/\s*:/),keywords:"_|0",relevance:0},be={begin:/\(/,end:/\)/,relevance:0,keywords:f,contains:["self",ie,...i,G,...p,...b,...w,S,P,...W,...F,Y]},ce={begin:/</,end:/>/,keywords:"repeat each",contains:[...i,Y]},Ne={begin:Ci(od(an(pr,/\s*:/)),od(an(pr,/\s+/,pr,/\s*:/))),end:/:/,relevance:0,contains:[{className:"keyword",match:/\b_\b/},{className:"params",match:pr}]},oe={begin:/\(/,end:/\)/,keywords:f,contains:[Ne,...i,...p,...w,S,P,...F,Y,be],endsParent:!0,illegal:/["']/},pe={match:[/(func|macro)/,/\s+/,Ci(R.match,pr,ex)],className:{1:"keyword",3:"title.function"},contains:[ce,oe,t],illegal:[/\[/,/%/]},re={match:[/\b(?:subscript|init[?!]?)/,/\s*(?=[<(])/],className:{1:"keyword"},contains:[ce,oe,t],illegal:/\[|%/},ee={match:[/operator/,/\s+/,ex],className:{1:"keyword",3:"title"}},ge={begin:[/precedencegroup/,/\s+/,Jh],className:{1:"keyword",3:"title"},contains:[Y],keywords:[...XG,...E2],end:/}/},Ce={match:[/class\b/,/\s+/,/func\b/,/\s+/,/\b[A-Za-z_][A-Za-z0-9_]*\b/],scope:{1:"keyword",3:"keyword",5:"title.function"}},Ie={match:[/class\b/,/\s+/,/var\b/],scope:{1:"keyword",3:"keyword"}},ae={begin:[/(struct|protocol|class|extension|enum|actor)/,/\s+/,pr,/\s*/],beginScope:{1:"keyword",3:"title.class"},keywords:f,contains:[ce,...p,{begin:/:/,end:/\{/,keywords:f,contains:[{scope:"title.class.inherited",match:Jh},...p],relevance:0}]};for(const ke of P.variants){const Ue=ke.contains.find(ht=>ht.label==="interpol");Ue.keywords=f;const Oe=[...p,...b,...w,S,P,...W];Ue.contains=[...Oe,{begin:/\(/,end:/\)/,contains:["self",...Oe]}]}return{name:"Swift",keywords:f,contains:[...i,pe,re,Ce,Ie,ae,ee,ge,{beginKeywords:"import",end:/$/,contains:[...i],relevance:0},G,...p,...b,...w,S,P,...W,...F,Y,be]}}const rm="[A-Za-z$_][0-9A-Za-z$_]*",SR=["as","in","of","if","for","while","finally","var","new","function","do","return","void","else","break","catch","instanceof","with","throw","case","default","try","switch","continue","typeof","delete","let","yield","const","class","debugger","async","await","static","import","from","export","extends","using"],NR=["true","false","null","undefined","NaN","Infinity"],_R=["Object","Function","Boolean","Symbol","Math","Date","Number","BigInt","String","RegExp","Array","Float32Array","Float64Array","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Int32Array","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array","Set","Map","WeakSet","WeakMap","ArrayBuffer","SharedArrayBuffer","Atomics","DataView","JSON","Promise","Generator","GeneratorFunction","AsyncFunction","Reflect","Proxy","Intl","WebAssembly"],CR=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],TR=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],AR=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","global"],jR=[].concat(TR,_R,CR);function tW(e){const t=e.regex,n=(X,{after:K})=>{const U="</"+X[0].slice(1);return X.input.indexOf(U,K)!==-1},i=rm,s={begin:"<>",end:"</>"},r=/<[A-Za-z0-9\\._:-]+\s*\/>/,o={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(X,K)=>{const U=X[0].length+X.index,F=X.input[U];if(F==="<"||F===","){K.ignoreMatch();return}F===">"&&(n(X,{after:U})||K.ignoreMatch());let Y;const $=X.input.substring(U);if(Y=$.match(/^\s*=/)){K.ignoreMatch();return}if((Y=$.match(/^\s+extends\s+/))&&Y.index===0){K.ignoreMatch();return}}},c={$pattern:rm,keyword:SR,literal:NR,built_in:jR,"variable.language":AR},u="[0-9](_?[0-9])*",f=`\\.(${u})`,p="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",m={className:"number",variants:[{begin:`(\\b(${p})((${f})|\\.)?|(${f}))[eE][+-]?(${u})\\b`},{begin:`\\b(${p})\\b((${f})\\b|\\.)?|(${f})\\b`},{begin:"\\b(0|[1-9](_?[0-9])*)n\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*n?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*n?\\b"},{begin:"\\b0[0-7]+n?\\b"}],relevance:0},y={className:"subst",begin:"\\$\\{",end:"\\}",keywords:c,contains:[]},b={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,y],subLanguage:"xml"}},x={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,y],subLanguage:"css"}},v={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,y],subLanguage:"graphql"}},w={className:"string",begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,y]},C={className:"comment",variants:[e.COMMENT(/\/\*\*(?!\/)/,"\\*/",{relevance:0,contains:[{begin:"(?=@[A-Za-z]+)",relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"},{className:"type",begin:"\\{",end:"\\}",excludeEnd:!0,excludeBegin:!0,relevance:0},{className:"variable",begin:i+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),e.C_BLOCK_COMMENT_MODE,e.C_LINE_COMMENT_MODE]},S=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,b,x,v,w,{match:/\$\d+/},m];y.contains=S.concat({begin:/\{/,end:/\}/,keywords:c,contains:["self"].concat(S)});const T=[].concat(C,y.contains),A=T.concat([{begin:/(\s*)\(/,end:/\)/,keywords:c,contains:["self"].concat(T)}]),j={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:c,contains:A},M={variants:[{match:[/class/,/\s+/,i,/\s+/,/extends/,/\s+/,t.concat(i,"(",t.concat(/\./,i),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,i],scope:{1:"keyword",3:"title.class"}}]},D={relevance:0,match:t.either(/\bJSON/,/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),className:"title.class",keywords:{_:[..._R,...CR]}},P={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},I={variants:[{match:[/function/,/\s+/,i,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[j],illegal:/%/},B={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function q(X){return t.concat("(?!",X.join("|"),")")}const G={match:t.concat(/\b/,q([...TR,"super","import"].map(X=>`${X}\\s*\\(`)),i,t.lookahead(/\s*\(/)),className:"title.function",relevance:0},R={begin:t.concat(/\./,t.lookahead(t.concat(i,/(?![0-9A-Za-z$_(])/))),end:i,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},O={match:[/get|set/,/\s+/,i,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},j]},z="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+e.UNDERSCORE_IDENT_RE+")\\s*=>",W={match:[/const|var|let/,/\s+/,i,/\s*/,/=\s*/,/(async\s*)?/,t.lookahead(z)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[j]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:c,exports:{PARAMS_CONTAINS:A,CLASS_REFERENCE:D},illegal:/#(?![$_A-z])/,contains:[e.SHEBANG({label:"shebang",binary:"node",relevance:5}),P,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,b,x,v,w,C,{match:/\$\d+/},m,D,{scope:"attr",match:i+t.lookahead(":"),relevance:0},W,{begin:"("+e.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[C,e.REGEXP_MODE,{className:"function",begin:z,returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{begin:e.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:c,contains:A}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:s.begin,end:s.end},{match:r},{begin:o.begin,"on:begin":o.isTrulyOpeningTag,end:o.end}],subLanguage:"xml",contains:[{begin:o.begin,end:o.end,skip:!0,contains:["self"]}]}]},I,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+e.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[j,e.inherit(e.TITLE_MODE,{begin:i,className:"title.function"})]},{match:/\.\.\./,relevance:0},R,{match:"\\$"+i,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[j]},G,B,M,O,{match:/\$[(.]/}]}}function nW(e){const t=e.regex,n=tW(e),i=rm,s=["any","void","number","boolean","string","object","never","symbol","bigint","unknown"],r={begin:[/namespace/,/\s+/,e.IDENT_RE],beginScope:{1:"keyword",3:"title.class"}},o={beginKeywords:"interface",end:/\{/,excludeEnd:!0,keywords:{keyword:"interface extends",built_in:s},contains:[n.exports.CLASS_REFERENCE]},c={className:"meta",relevance:10,begin:/^\s*['"]use strict['"]/},u=["type","interface","public","private","protected","implements","declare","abstract","readonly","enum","override","satisfies"],f={$pattern:rm,keyword:SR.concat(u),literal:NR,built_in:jR.concat(s),"variable.language":AR},p={className:"meta",begin:"@"+i},m=(v,w,k)=>{const C=v.contains.findIndex(S=>S.label===w);if(C===-1)throw new Error("can not find mode to replace");v.contains.splice(C,1,k)};Object.assign(n.keywords,f),n.exports.PARAMS_CONTAINS.push(p);const y=n.contains.find(v=>v.scope==="attr"),b=Object.assign({},y,{match:t.concat(i,t.lookahead(/\s*\?:/))});n.exports.PARAMS_CONTAINS.push([n.exports.CLASS_REFERENCE,y,b]),n.contains=n.contains.concat([p,r,o,b]),m(n,"shebang",e.SHEBANG()),m(n,"use_strict",c);const x=n.contains.find(v=>v.label==="func.def");return x.relevance=0,Object.assign(n,{name:"TypeScript",aliases:["ts","tsx","mts","cts"]}),n}function iW(e){const t=e.regex,n={className:"string",begin:/"(""|[^/n])"C\b/},i={className:"string",begin:/"/,end:/"/,illegal:/\n/,contains:[{begin:/""/}]},s=/\d{1,2}\/\d{1,2}\/\d{4}/,r=/\d{4}-\d{1,2}-\d{1,2}/,o=/(\d|1[012])(:\d+){0,2} *(AM|PM)/,c=/\d{1,2}(:\d{1,2}){1,2}/,u={className:"literal",variants:[{begin:t.concat(/# */,t.either(r,s),/ *#/)},{begin:t.concat(/# */,c,/ *#/)},{begin:t.concat(/# */,o,/ *#/)},{begin:t.concat(/# */,t.either(r,s),/ +/,t.either(o,c),/ *#/)}]},f={className:"number",relevance:0,variants:[{begin:/\b\d[\d_]*((\.[\d_]+(E[+-]?[\d_]+)?)|(E[+-]?[\d_]+))[RFD@!#]?/},{begin:/\b\d[\d_]*((U?[SIL])|[%&])?/},{begin:/&H[\dA-F_]+((U?[SIL])|[%&])?/},{begin:/&O[0-7_]+((U?[SIL])|[%&])?/},{begin:/&B[01_]+((U?[SIL])|[%&])?/}]},p={className:"label",begin:/^\w+:/},m=e.COMMENT(/'''/,/$/,{contains:[{className:"doctag",begin:/<\/?/,end:/>/}]}),y=e.COMMENT(null,/$/,{variants:[{begin:/'/},{begin:/([\t ]|^)REM(?=\s)/}]});return{name:"Visual Basic .NET",aliases:["vb"],case_insensitive:!0,classNameAliases:{label:"symbol"},keywords:{keyword:"addhandler alias aggregate ansi as async assembly auto binary by byref byval call case catch class compare const continue custom declare default delegate dim distinct do each equals else elseif end enum erase error event exit explicit finally for friend from function get global goto group handles if implements imports in inherits interface into iterator join key let lib loop me mid module mustinherit mustoverride mybase myclass namespace narrowing new next notinheritable notoverridable of off on operator option optional order overloads overridable overrides paramarray partial preserve private property protected public raiseevent readonly redim removehandler resume return select set shadows shared skip static step stop structure strict sub synclock take text then throw to try unicode until using when where while widening with withevents writeonly yield",built_in:"addressof and andalso await directcast gettype getxmlnamespace is isfalse isnot istrue like mod nameof new not or orelse trycast typeof xor cbool cbyte cchar cdate cdbl cdec cint clng cobj csbyte cshort csng cstr cuint culng cushort",type:"boolean byte char date decimal double integer long object sbyte short single string uinteger ulong ushort",literal:"true false nothing"},illegal:"//|\\{|\\}|endif|gosub|variant|wend|^\\$ ",contains:[n,i,u,f,p,m,y,{className:"meta",begin:/[\t ]*#(const|disable|else|elseif|enable|end|externalsource|if|region)\b/,end:/$/,keywords:{keyword:"const disable else elseif enable end externalsource if region then"},contains:[y]}]}}function sW(e){e.regex;const t=e.COMMENT(/\(;/,/;\)/);t.contains.push("self");const n=e.COMMENT(/;;/,/$/),i=["anyfunc","block","br","br_if","br_table","call","call_indirect","data","drop","elem","else","end","export","func","global.get","global.set","local.get","local.set","local.tee","get_global","get_local","global","if","import","local","loop","memory","memory.grow","memory.size","module","mut","nop","offset","param","result","return","select","set_global","set_local","start","table","tee_local","then","type","unreachable"],s={begin:[/(?:func|call|call_indirect)/,/\s+/,/\$[^\s)]+/],className:{1:"keyword",3:"title.function"}},r={className:"variable",begin:/\$[\w_]+/},o={match:/(\((?!;)|\))+/,className:"punctuation",relevance:0},c={className:"number",relevance:0,match:/[+-]?\b(?:\d(?:_?\d)*(?:\.\d(?:_?\d)*)?(?:[eE][+-]?\d(?:_?\d)*)?|0x[\da-fA-F](?:_?[\da-fA-F])*(?:\.[\da-fA-F](?:_?[\da-fA-D])*)?(?:[pP][+-]?\d(?:_?\d)*)?)\b|\binf\b|\bnan(?::0x[\da-fA-F](?:_?[\da-fA-D])*)?\b/},u={match:/(i32|i64|f32|f64)(?!\.)/,className:"type"},f={className:"keyword",match:/\b(f32|f64|i32|i64)(?:\.(?:abs|add|and|ceil|clz|const|convert_[su]\/i(?:32|64)|copysign|ctz|demote\/f64|div(?:_[su])?|eqz?|extend_[su]\/i32|floor|ge(?:_[su])?|gt(?:_[su])?|le(?:_[su])?|load(?:(?:8|16|32)_[su])?|lt(?:_[su])?|max|min|mul|nearest|neg?|or|popcnt|promote\/f32|reinterpret\/[fi](?:32|64)|rem_[su]|rot[lr]|shl|shr_[su]|store(?:8|16|32)?|sqrt|sub|trunc(?:_[su]\/f(?:32|64))?|wrap\/i64|xor))\b/};return{name:"WebAssembly",keywords:{$pattern:/[\w.]+/,keyword:i},contains:[n,t,{match:[/(?:offset|align)/,/\s*/,/=/],className:{1:"keyword",3:"operator"}},r,o,s,e.QUOTE_STRING_MODE,u,f,c]}}function rW(e){const t=e.regex,n=t.concat(/[\p{L}_]/u,t.optional(/[\p{L}0-9_.-]*:/u),/[\p{L}0-9_.-]*/u),i=/[\p{L}0-9._:-]+/u,s={className:"symbol",begin:/&[a-z]+;|&#[0-9]+;|&#x[a-f0-9]+;/},r={begin:/\s/,contains:[{className:"keyword",begin:/#?[a-z_][a-z1-9_-]+/,illegal:/\n/}]},o=e.inherit(r,{begin:/\(/,end:/\)/}),c=e.inherit(e.APOS_STRING_MODE,{className:"string"}),u=e.inherit(e.QUOTE_STRING_MODE,{className:"string"}),f={endsWithParent:!0,illegal:/</,relevance:0,contains:[{className:"attr",begin:i,relevance:0},{begin:/=\s*/,relevance:0,contains:[{className:"string",endsParent:!0,variants:[{begin:/"/,end:/"/,contains:[s]},{begin:/'/,end:/'/,contains:[s]},{begin:/[^\s"'=<>`]+/}]}]}]};return{name:"HTML, XML",aliases:["html","xhtml","rss","atom","xjb","xsd","xsl","plist","wsf","svg"],case_insensitive:!0,unicodeRegex:!0,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,relevance:10,contains:[r,u,c,o,{begin:/\[/,end:/\]/,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,contains:[r,o,u,c]}]}]},e.COMMENT(/<!--/,/-->/,{relevance:10}),{begin:/<!\[CDATA\[/,end:/\]\]>/,relevance:10},s,{className:"meta",end:/\?>/,variants:[{begin:/<\?xml/,relevance:10,contains:[u]},{begin:/<\?[a-z][a-z0-9]+/}]},{className:"tag",begin:/<style(?=\s|>)/,end:/>/,keywords:{name:"style"},contains:[f],starts:{end:/<\/style>/,returnEnd:!0,subLanguage:["css","xml"]}},{className:"tag",begin:/<script(?=\s|>)/,end:/>/,keywords:{name:"script"},contains:[f],starts:{end:/<\/script>/,returnEnd:!0,subLanguage:["javascript","handlebars","xml"]}},{className:"tag",begin:/<>|<\/>/},{className:"tag",begin:t.concat(/</,t.lookahead(t.concat(n,t.either(/\/>/,/>/,/\s/)))),end:/\/?>/,contains:[{className:"name",begin:n,relevance:0,starts:f}]},{className:"tag",begin:t.concat(/<\//,t.lookahead(t.concat(n,/>/))),contains:[{className:"name",begin:n,relevance:0},{begin:/>/,relevance:0,endsParent:!0}]}]}}function aW(e){const t="true false yes no null",n="[\\w#;/?:@&=+$,.~*'()[\\]]+",i={className:"attr",variants:[{begin:/[\w*@][\w*@ :()\./-]*:(?=[ \t]|$)/},{begin:/"[\w*@][\w*@ :()\./-]*":(?=[ \t]|$)/},{begin:/'[\w*@][\w*@ :()\./-]*':(?=[ \t]|$)/}]},s={className:"template-variable",variants:[{begin:/\{\{/,end:/\}\}/},{begin:/%\{/,end:/\}/}]},r={className:"string",relevance:0,begin:/'/,end:/'/,contains:[{match:/''/,scope:"char.escape",relevance:0}]},o={className:"string",relevance:0,variants:[{begin:/"/,end:/"/},{begin:/\S+/}],contains:[e.BACKSLASH_ESCAPE,s]},c=e.inherit(o,{variants:[{begin:/'/,end:/'/,contains:[{begin:/''/,relevance:0}]},{begin:/"/,end:/"/},{begin:/[^\s,{}[\]]+/}]}),y={className:"number",begin:"\\b"+"[0-9]{4}(-[0-9][0-9]){0,2}"+"([Tt \\t][0-9][0-9]?(:[0-9][0-9]){2})?"+"(\\.[0-9]*)?"+"([ \\t])*(Z|[-+][0-9][0-9]?(:[0-9][0-9])?)?"+"\\b"},b={end:",",endsWithParent:!0,excludeEnd:!0,keywords:t,relevance:0},x={begin:/\{/,end:/\}/,contains:[b],illegal:"\\n",relevance:0},v={begin:"\\[",end:"\\]",contains:[b],illegal:"\\n",relevance:0},w=[i,{className:"meta",begin:"^---\\s*$",relevance:10},{className:"string",begin:"[\\|>]([1-9]?[+-])?[ ]*\\n( +)[^ ][^\\n]*\\n(\\2[^\\n]+\\n?)*"},{begin:"<%[%=-]?",end:"[%-]?%>",subLanguage:"ruby",excludeBegin:!0,excludeEnd:!0,relevance:0},{className:"type",begin:"!\\w+!"+n},{className:"type",begin:"!<"+n+">"},{className:"type",begin:"!"+n},{className:"type",begin:"!!"+n},{className:"meta",begin:"&"+e.UNDERSCORE_IDENT_RE+"$"},{className:"meta",begin:"\\*"+e.UNDERSCORE_IDENT_RE+"$"},{className:"bullet",begin:"-(?=[ ]|$)",relevance:0},e.HASH_COMMENT_MODE,{beginKeywords:t,keywords:{literal:t}},y,{className:"number",begin:e.C_NUMBER_RE+"\\b",relevance:0},x,v,r,o],k=[...w];return k.pop(),k.push(c),b.contains=k,{name:"YAML",case_insensitive:!0,aliases:["yml"],contains:w}}const oW={arduino:$7,bash:q7,c:H7,cpp:V7,csharp:K7,css:tG,diff:nG,go:iG,graphql:sG,ini:rG,java:aG,javascript:dG,json:fG,kotlin:pG,less:EG,lua:kG,makefile:SG,markdown:NG,objectivec:_G,perl:CG,php:TG,"php-template":AG,plaintext:jG,python:MG,"python-repl":RG,r:DG,ruby:OG,rust:LG,scss:HG,shell:VG,sql:KG,swift:eW,typescript:nW,vbnet:iW,wasm:sW,xml:rW,yaml:aW};var tx,S2;function lW(){if(S2)return tx;S2=1;function e(Q){return Q instanceof Map?Q.clear=Q.delete=Q.set=function(){throw new Error("map is read-only")}:Q instanceof Set&&(Q.add=Q.clear=Q.delete=function(){throw new Error("set is read-only")}),Object.freeze(Q),Object.getOwnPropertyNames(Q).forEach(we=>{const Pe=Q[we],ct=typeof Pe;(ct==="object"||ct==="function")&&!Object.isFrozen(Pe)&&e(Pe)}),Q}class t{constructor(we){we.data===void 0&&(we.data={}),this.data=we.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}}function n(Q){return Q.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function i(Q,...we){const Pe=Object.create(null);for(const ct in Q)Pe[ct]=Q[ct];return we.forEach(function(ct){for(const Qt in ct)Pe[Qt]=ct[Qt]}),Pe}const s="</span>",r=Q=>!!Q.scope,o=(Q,{prefix:we})=>{if(Q.startsWith("language:"))return Q.replace("language:","language-");if(Q.includes(".")){const Pe=Q.split(".");return[`${we}${Pe.shift()}`,...Pe.map((ct,Qt)=>`${ct}${"_".repeat(Qt+1)}`)].join(" ")}return`${we}${Q}`};class c{constructor(we,Pe){this.buffer="",this.classPrefix=Pe.classPrefix,we.walk(this)}addText(we){this.buffer+=n(we)}openNode(we){if(!r(we))return;const Pe=o(we.scope,{prefix:this.classPrefix});this.span(Pe)}closeNode(we){r(we)&&(this.buffer+=s)}value(){return this.buffer}span(we){this.buffer+=`<span class="${we}">`}}const u=(Q={})=>{const we={children:[]};return Object.assign(we,Q),we};class f{constructor(){this.rootNode=u(),this.stack=[this.rootNode]}get top(){return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(we){this.top.children.push(we)}openNode(we){const Pe=u({scope:we});this.add(Pe),this.stack.push(Pe)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(we){return this.constructor._walk(we,this.rootNode)}static _walk(we,Pe){return typeof Pe=="string"?we.addText(Pe):Pe.children&&(we.openNode(Pe),Pe.children.forEach(ct=>this._walk(we,ct)),we.closeNode(Pe)),we}static _collapse(we){typeof we!="string"&&we.children&&(we.children.every(Pe=>typeof Pe=="string")?we.children=[we.children.join("")]:we.children.forEach(Pe=>{f._collapse(Pe)}))}}class p extends f{constructor(we){super(),this.options=we}addText(we){we!==""&&this.add(we)}startScope(we){this.openNode(we)}endScope(){this.closeNode()}__addSublanguage(we,Pe){const ct=we.root;Pe&&(ct.scope=`language:${Pe}`),this.add(ct)}toHTML(){return new c(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}}function m(Q){return Q?typeof Q=="string"?Q:Q.source:null}function y(Q){return v("(?=",Q,")")}function b(Q){return v("(?:",Q,")*")}function x(Q){return v("(?:",Q,")?")}function v(...Q){return Q.map(Pe=>m(Pe)).join("")}function w(Q){const we=Q[Q.length-1];return typeof we=="object"&&we.constructor===Object?(Q.splice(Q.length-1,1),we):{}}function k(...Q){return"("+(w(Q).capture?"":"?:")+Q.map(ct=>m(ct)).join("|")+")"}function C(Q){return new RegExp(Q.toString()+"|").exec("").length-1}function S(Q,we){const Pe=Q&&Q.exec(we);return Pe&&Pe.index===0}const T=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;function A(Q,{joinWith:we}){let Pe=0;return Q.map(ct=>{Pe+=1;const Qt=Pe;let Ht=m(ct),He="";for(;Ht.length>0;){const Fe=T.exec(Ht);if(!Fe){He+=Ht;break}He+=Ht.substring(0,Fe.index),Ht=Ht.substring(Fe.index+Fe[0].length),Fe[0][0]==="\\"&&Fe[1]?He+="\\"+String(Number(Fe[1])+Qt):(He+=Fe[0],Fe[0]==="("&&Pe++)}return He}).map(ct=>`(${ct})`).join(we)}const j=/\b\B/,M="[a-zA-Z]\\w*",D="[a-zA-Z_]\\w*",P="\\b\\d+(\\.\\d+)?",I="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",B="\\b(0b[01]+)",q="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",G=(Q={})=>{const we=/^#![ ]*\//;return Q.binary&&(Q.begin=v(we,/.*\b/,Q.binary,/\b.*/)),i({scope:"meta",begin:we,end:/$/,relevance:0,"on:begin":(Pe,ct)=>{Pe.index!==0&&ct.ignoreMatch()}},Q)},R={begin:"\\\\[\\s\\S]",relevance:0},O={scope:"string",begin:"'",end:"'",illegal:"\\n",contains:[R]},z={scope:"string",begin:'"',end:'"',illegal:"\\n",contains:[R]},W={begin:/\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/},X=function(Q,we,Pe={}){const ct=i({scope:"comment",begin:Q,end:we,contains:[]},Pe);ct.contains.push({scope:"doctag",begin:"[ ]*(?=(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):)",end:/(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):/,excludeBegin:!0,relevance:0});const Qt=k("I","a","is","so","us","to","at","if","in","it","on",/[A-Za-z]+['](d|ve|re|ll|t|s|n)/,/[A-Za-z]+[-][a-z]+/,/[A-Za-z][a-z]{2,}/);return ct.contains.push({begin:v(/[ ]+/,"(",Qt,/[.]?[:]?([.][ ]|[ ])/,"){3}")}),ct},K=X("//","$"),U=X("/\\*","\\*/"),F=X("#","$"),Y={scope:"number",begin:P,relevance:0},$={scope:"number",begin:I,relevance:0},ie={scope:"number",begin:B,relevance:0},be={scope:"regexp",begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[R,{begin:/\[/,end:/\]/,relevance:0,contains:[R]}]},ce={scope:"title",begin:M,relevance:0},Ne={scope:"title",begin:D,relevance:0},oe={begin:"\\.\\s*"+D,relevance:0};var re=Object.freeze({__proto__:null,APOS_STRING_MODE:O,BACKSLASH_ESCAPE:R,BINARY_NUMBER_MODE:ie,BINARY_NUMBER_RE:B,COMMENT:X,C_BLOCK_COMMENT_MODE:U,C_LINE_COMMENT_MODE:K,C_NUMBER_MODE:$,C_NUMBER_RE:I,END_SAME_AS_BEGIN:function(Q){return Object.assign(Q,{"on:begin":(we,Pe)=>{Pe.data._beginMatch=we[1]},"on:end":(we,Pe)=>{Pe.data._beginMatch!==we[1]&&Pe.ignoreMatch()}})},HASH_COMMENT_MODE:F,IDENT_RE:M,MATCH_NOTHING_RE:j,METHOD_GUARD:oe,NUMBER_MODE:Y,NUMBER_RE:P,PHRASAL_WORDS_MODE:W,QUOTE_STRING_MODE:z,REGEXP_MODE:be,RE_STARTERS_RE:q,SHEBANG:G,TITLE_MODE:ce,UNDERSCORE_IDENT_RE:D,UNDERSCORE_TITLE_MODE:Ne});function ee(Q,we){Q.input[Q.index-1]==="."&&we.ignoreMatch()}function ge(Q,we){Q.className!==void 0&&(Q.scope=Q.className,delete Q.className)}function Ce(Q,we){we&&Q.beginKeywords&&(Q.begin="\\b("+Q.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)",Q.__beforeBegin=ee,Q.keywords=Q.keywords||Q.beginKeywords,delete Q.beginKeywords,Q.relevance===void 0&&(Q.relevance=0))}function Ie(Q,we){Array.isArray(Q.illegal)&&(Q.illegal=k(...Q.illegal))}function ae(Q,we){if(Q.match){if(Q.begin||Q.end)throw new Error("begin & end are not supported with match");Q.begin=Q.match,delete Q.match}}function ke(Q,we){Q.relevance===void 0&&(Q.relevance=1)}const Ue=(Q,we)=>{if(!Q.beforeMatch)return;if(Q.starts)throw new Error("beforeMatch cannot be used with starts");const Pe=Object.assign({},Q);Object.keys(Q).forEach(ct=>{delete Q[ct]}),Q.keywords=Pe.keywords,Q.begin=v(Pe.beforeMatch,y(Pe.begin)),Q.starts={relevance:0,contains:[Object.assign(Pe,{endsParent:!0})]},Q.relevance=0,delete Pe.beforeMatch},Oe=["of","and","for","in","not","or","if","then","parent","list","value"],ht="keyword";function tt(Q,we,Pe=ht){const ct=Object.create(null);return typeof Q=="string"?Qt(Pe,Q.split(" ")):Array.isArray(Q)?Qt(Pe,Q):Object.keys(Q).forEach(function(Ht){Object.assign(ct,tt(Q[Ht],we,Ht))}),ct;function Qt(Ht,He){we&&(He=He.map(Fe=>Fe.toLowerCase())),He.forEach(function(Fe){const rt=Fe.split("|");ct[rt[0]]=[Ht,jt(rt[0],rt[1])]})}}function jt(Q,we){return we?Number(we):Nt(Q)?0:1}function Nt(Q){return Oe.includes(Q.toLowerCase())}const pt={},Me=Q=>{console.error(Q)},We=(Q,...we)=>{console.log(`WARN: ${Q}`,...we)},ne=(Q,we)=>{pt[`${Q}/${we}`]||(console.log(`Deprecated as of ${Q}. ${we}`),pt[`${Q}/${we}`]=!0)},ve=new Error;function Re(Q,we,{key:Pe}){let ct=0;const Qt=Q[Pe],Ht={},He={};for(let Fe=1;Fe<=we.length;Fe++)He[Fe+ct]=Qt[Fe],Ht[Fe+ct]=!0,ct+=C(we[Fe-1]);Q[Pe]=He,Q[Pe]._emit=Ht,Q[Pe]._multi=!0}function ye(Q){if(Array.isArray(Q.begin)){if(Q.skip||Q.excludeBegin||Q.returnBegin)throw Me("skip, excludeBegin, returnBegin not compatible with beginScope: {}"),ve;if(typeof Q.beginScope!="object"||Q.beginScope===null)throw Me("beginScope must be object"),ve;Re(Q,Q.begin,{key:"beginScope"}),Q.begin=A(Q.begin,{joinWith:""})}}function Je(Q){if(Array.isArray(Q.end)){if(Q.skip||Q.excludeEnd||Q.returnEnd)throw Me("skip, excludeEnd, returnEnd not compatible with endScope: {}"),ve;if(typeof Q.endScope!="object"||Q.endScope===null)throw Me("endScope must be object"),ve;Re(Q,Q.end,{key:"endScope"}),Q.end=A(Q.end,{joinWith:""})}}function It(Q){Q.scope&&typeof Q.scope=="object"&&Q.scope!==null&&(Q.beginScope=Q.scope,delete Q.scope)}function Wt(Q){It(Q),typeof Q.beginScope=="string"&&(Q.beginScope={_wrap:Q.beginScope}),typeof Q.endScope=="string"&&(Q.endScope={_wrap:Q.endScope}),ye(Q),Je(Q)}function he(Q){function we(He,Fe){return new RegExp(m(He),"m"+(Q.case_insensitive?"i":"")+(Q.unicodeRegex?"u":"")+(Fe?"g":""))}class Pe{constructor(){this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}addRule(Fe,rt){rt.position=this.position++,this.matchIndexes[this.matchAt]=rt,this.regexes.push([rt,Fe]),this.matchAt+=C(Fe)+1}compile(){this.regexes.length===0&&(this.exec=()=>null);const Fe=this.regexes.map(rt=>rt[1]);this.matcherRe=we(A(Fe,{joinWith:"|"}),!0),this.lastIndex=0}exec(Fe){this.matcherRe.lastIndex=this.lastIndex;const rt=this.matcherRe.exec(Fe);if(!rt)return null;const hn=rt.findIndex((ki,us)=>us>0&&ki!==void 0),on=this.matchIndexes[hn];return rt.splice(0,hn),Object.assign(rt,on)}}class ct{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(Fe){if(this.multiRegexes[Fe])return this.multiRegexes[Fe];const rt=new Pe;return this.rules.slice(Fe).forEach(([hn,on])=>rt.addRule(hn,on)),rt.compile(),this.multiRegexes[Fe]=rt,rt}resumingScanAtSamePosition(){return this.regexIndex!==0}considerAll(){this.regexIndex=0}addRule(Fe,rt){this.rules.push([Fe,rt]),rt.type==="begin"&&this.count++}exec(Fe){const rt=this.getMatcher(this.regexIndex);rt.lastIndex=this.lastIndex;let hn=rt.exec(Fe);if(this.resumingScanAtSamePosition()&&!(hn&&hn.index===this.lastIndex)){const on=this.getMatcher(0);on.lastIndex=this.lastIndex+1,hn=on.exec(Fe)}return hn&&(this.regexIndex+=hn.position+1,this.regexIndex===this.count&&this.considerAll()),hn}}function Qt(He){const Fe=new ct;return He.contains.forEach(rt=>Fe.addRule(rt.begin,{rule:rt,type:"begin"})),He.terminatorEnd&&Fe.addRule(He.terminatorEnd,{type:"end"}),He.illegal&&Fe.addRule(He.illegal,{type:"illegal"}),Fe}function Ht(He,Fe){const rt=He;if(He.isCompiled)return rt;[ge,ae,Wt,Ue].forEach(on=>on(He,Fe)),Q.compilerExtensions.forEach(on=>on(He,Fe)),He.__beforeBegin=null,[Ce,Ie,ke].forEach(on=>on(He,Fe)),He.isCompiled=!0;let hn=null;return typeof He.keywords=="object"&&He.keywords.$pattern&&(He.keywords=Object.assign({},He.keywords),hn=He.keywords.$pattern,delete He.keywords.$pattern),hn=hn||/\w+/,He.keywords&&(He.keywords=tt(He.keywords,Q.case_insensitive)),rt.keywordPatternRe=we(hn,!0),Fe&&(He.begin||(He.begin=/\B|\b/),rt.beginRe=we(rt.begin),!He.end&&!He.endsWithParent&&(He.end=/\B|\b/),He.end&&(rt.endRe=we(rt.end)),rt.terminatorEnd=m(rt.end)||"",He.endsWithParent&&Fe.terminatorEnd&&(rt.terminatorEnd+=(He.end?"|":"")+Fe.terminatorEnd)),He.illegal&&(rt.illegalRe=we(He.illegal)),He.contains||(He.contains=[]),He.contains=[].concat(...He.contains.map(function(on){return Te(on==="self"?He:on)})),He.contains.forEach(function(on){Ht(on,rt)}),He.starts&&Ht(He.starts,Fe),rt.matcher=Qt(rt),rt}if(Q.compilerExtensions||(Q.compilerExtensions=[]),Q.contains&&Q.contains.includes("self"))throw new Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");return Q.classNameAliases=i(Q.classNameAliases||{}),Ht(Q)}function le(Q){return Q?Q.endsWithParent||le(Q.starts):!1}function Te(Q){return Q.variants&&!Q.cachedVariants&&(Q.cachedVariants=Q.variants.map(function(we){return i(Q,{variants:null},we)})),Q.cachedVariants?Q.cachedVariants:le(Q)?i(Q,{starts:Q.starts?i(Q.starts):null}):Object.isFrozen(Q)?i(Q):Q}var Ae="11.11.1";class Qe extends Error{constructor(we,Pe){super(we),this.name="HTMLInjectionError",this.html=Pe}}const st=n,$e=i,nt=Symbol("nomatch"),qt=7,Xt=function(Q){const we=Object.create(null),Pe=Object.create(null),ct=[];let Qt=!0;const Ht="Could not find the language '{}', did you forget to load/include a language module?",He={disableAutodetect:!0,name:"Plain text",contains:[]};let Fe={ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:"hljs-",cssSelector:"pre code",languages:null,__emitter:p};function rt(je){return Fe.noHighlightRe.test(je)}function hn(je){let Ye=je.className+" ";Ye+=je.parentNode?je.parentNode.className:"";const xt=Fe.languageDetectRe.exec(Ye);if(xt){const Pt=Xn(xt[1]);return Pt||(We(Ht.replace("{}",xt[1])),We("Falling back to no-highlight mode for this block.",je)),Pt?xt[1]:"no-highlight"}return Ye.split(/\s+/).find(Pt=>rt(Pt)||Xn(Pt))}function on(je,Ye,xt){let Pt="",gn="";typeof Ye=="object"?(Pt=je,xt=Ye.ignoreIllegals,gn=Ye.language):(ne("10.7.0","highlight(lang, code, ...args) has been deprecated."),ne("10.7.0",`Please use highlight(code, options) instead.
|
|
666
666
|
https://github.com/highlightjs/highlight.js/issues/2277`),gn=je,Pt=Ye),xt===void 0&&(xt=!0);const Un={code:Pt,language:gn};Qn("before:highlight",Un);const ci=Un.result?Un.result:ki(Un.language,Un.code,xt);return ci.code=Un.code,Qn("after:highlight",ci),ci}function ki(je,Ye,xt,Pt){const gn=Object.create(null);function Un(Le,Ke){return Le.keywords[Ke]}function ci(){if(!lt.keywords){_n.addText(Kt);return}let Le=0;lt.keywordPatternRe.lastIndex=0;let Ke=lt.keywordPatternRe.exec(Kt),gt="";for(;Ke;){gt+=Kt.substring(Le,Ke.index);const V=Mn.case_insensitive?Ke[0].toLowerCase():Ke[0],xe=Un(lt,V);if(xe){const[ze,_t]=xe;if(_n.addText(gt),gt="",gn[V]=(gn[V]||0)+1,gn[V]<=qt&&(Ps+=_t),ze.startsWith("_"))gt+=Ke[0];else{const ut=Mn.classNameAliases[ze]||ze;ni(Ke[0],ut)}}else gt+=Ke[0];Le=lt.keywordPatternRe.lastIndex,Ke=lt.keywordPatternRe.exec(Kt)}gt+=Kt.substring(Le),_n.addText(gt)}function ti(){if(Kt==="")return;let Le=null;if(typeof lt.subLanguage=="string"){if(!we[lt.subLanguage]){_n.addText(Kt);return}Le=ki(lt.subLanguage,Kt,!0,Sl[lt.subLanguage]),Sl[lt.subLanguage]=Le._top}else Le=ds(Kt,lt.subLanguage.length?lt.subLanguage:null);lt.relevance>0&&(Ps+=Le.relevance),_n.__addSublanguage(Le._emitter,Le.language)}function Vt(){lt.subLanguage!=null?ti():ci(),Kt=""}function ni(Le,Ke){Le!==""&&(_n.startScope(Ke),_n.addText(Le),_n.endScope())}function Or(Le,Ke){let gt=1;const V=Ke.length-1;for(;gt<=V;){if(!Le._emit[gt]){gt++;continue}const xe=Mn.classNameAliases[Le[gt]]||Le[gt],ze=Ke[gt];xe?ni(ze,xe):(Kt=ze,ci(),Kt=""),gt++}}function ii(Le,Ke){return Le.scope&&typeof Le.scope=="string"&&_n.openNode(Mn.classNameAliases[Le.scope]||Le.scope),Le.beginScope&&(Le.beginScope._wrap?(ni(Kt,Mn.classNameAliases[Le.beginScope._wrap]||Le.beginScope._wrap),Kt=""):Le.beginScope._multi&&(Or(Le.beginScope,Ke),Kt="")),lt=Object.create(Le,{parent:{value:lt}}),lt}function si(Le,Ke,gt){let V=S(Le.endRe,gt);if(V){if(Le["on:end"]){const xe=new t(Le);Le["on:end"](Ke,xe),xe.isMatchIgnored&&(V=!1)}if(V){for(;Le.endsParent&&Le.parent;)Le=Le.parent;return Le}}if(Le.endsWithParent)return si(Le.parent,Ke,gt)}function Ls(Le){return lt.matcher.regexIndex===0?(Kt+=Le[0],1):(Bs=!0,0)}function ma(Le){const Ke=Le[0],gt=Le.rule,V=new t(gt),xe=[gt.__beforeBegin,gt["on:begin"]];for(const ze of xe)if(ze&&(ze(Le,V),V.isMatchIgnored))return Ls(Ke);return gt.skip?Kt+=Ke:(gt.excludeBegin&&(Kt+=Ke),Vt(),!gt.returnBegin&&!gt.excludeBegin&&(Kt=Ke)),ii(gt,Le),gt.returnBegin?0:Ke.length}function ri(Le){const Ke=Le[0],gt=Ye.substring(Le.index),V=si(lt,Le,gt);if(!V)return nt;const xe=lt;lt.endScope&<.endScope._wrap?(Vt(),ni(Ke,lt.endScope._wrap)):lt.endScope&<.endScope._multi?(Vt(),Or(lt.endScope,Le)):xe.skip?Kt+=Ke:(xe.returnEnd||xe.excludeEnd||(Kt+=Ke),Vt(),xe.excludeEnd&&(Kt=Ke));do lt.scope&&_n.closeNode(),!lt.skip&&!lt.subLanguage&&(Ps+=lt.relevance),lt=lt.parent;while(lt!==V.parent);return V.starts&&ii(V.starts,Le),xe.returnEnd?0:Ke.length}function Wi(){const Le=[];for(let Ke=lt;Ke!==Mn;Ke=Ke.parent)Ke.scope&&Le.unshift(Ke.scope);Le.forEach(Ke=>_n.openNode(Ke))}let yi={};function Is(Le,Ke){const gt=Ke&&Ke[0];if(Kt+=Le,gt==null)return Vt(),0;if(yi.type==="begin"&&Ke.type==="end"&&yi.index===Ke.index&>===""){if(Kt+=Ye.slice(Ke.index,Ke.index+1),!Qt){const V=new Error(`0 width match regex (${je})`);throw V.languageName=je,V.badRule=yi.rule,V}return 1}if(yi=Ke,Ke.type==="begin")return ma(Ke);if(Ke.type==="illegal"&&!xt){const V=new Error('Illegal lexeme "'+gt+'" for mode "'+(lt.scope||"<unnamed>")+'"');throw V.mode=lt,V}else if(Ke.type==="end"){const V=ri(Ke);if(V!==nt)return V}if(Ke.type==="illegal"&>==="")return Kt+=`
|
|
667
|
-
`,1;if(go>1e5&&go>Ke.index*3)throw new Error("potential infinite loop, way more iterations than matches");return Kt+=gt,gt.length}const Mn=Xn(je);if(!Mn)throw Me(Ht.replace("{}",je)),new Error('Unknown language: "'+je+'"');const rr=he(Mn);let ar="",lt=Pt||rr;const Sl={},_n=new Fe.__emitter(Fe);Wi();let Kt="",Ps=0,zs=0,go=0,Bs=!1;try{if(Mn.__emitTokens)Mn.__emitTokens(Ye,_n);else{for(lt.matcher.considerAll();;){go++,Bs?Bs=!1:lt.matcher.considerAll(),lt.matcher.lastIndex=zs;const Le=lt.matcher.exec(Ye);if(!Le)break;const Ke=Ye.substring(zs,Le.index),gt=Is(Ke,Le);zs=Le.index+gt}Is(Ye.substring(zs))}return _n.finalize(),ar=_n.toHTML(),{language:je,value:ar,relevance:Ps,illegal:!1,_emitter:_n,_top:lt}}catch(Le){if(Le.message&&Le.message.includes("Illegal"))return{language:je,value:st(Ye),illegal:!0,relevance:0,_illegalBy:{message:Le.message,index:zs,context:Ye.slice(zs-100,zs+100),mode:Le.mode,resultSoFar:ar},_emitter:_n};if(Qt)return{language:je,value:st(Ye),illegal:!1,relevance:0,errorRaised:Le,_emitter:_n,_top:lt};throw Le}}function us(je){const Ye={value:st(je),illegal:!1,relevance:0,_top:He,_emitter:new Fe.__emitter(Fe)};return Ye._emitter.addText(je),Ye}function ds(je,Ye){Ye=Ye||Fe.languages||Object.keys(we);const xt=us(je),Pt=Ye.filter(Xn).filter(Si).map(Vt=>ki(Vt,je,!1));Pt.unshift(xt);const gn=Pt.sort((Vt,ni)=>{if(Vt.relevance!==ni.relevance)return ni.relevance-Vt.relevance;if(Vt.language&&ni.language){if(Xn(Vt.language).supersetOf===ni.language)return 1;if(Xn(ni.language).supersetOf===Vt.language)return-1}return 0}),[Un,ci]=gn,ti=Un;return ti.secondBest=ci,ti}function Di(je,Ye,xt){const Pt=Ye&&Pe[Ye]||xt;je.classList.add("hljs"),je.classList.add(`language-${Pt}`)}function pn(je){let Ye=null;const xt=hn(je);if(rt(xt))return;if(Qn("before:highlightElement",{el:je,language:xt}),je.dataset.highlighted){console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",je);return}if(je.children.length>0&&(Fe.ignoreUnescapedHTML||(console.warn("One of your code blocks includes unescaped HTML. This is a potentially serious security risk."),console.warn("https://github.com/highlightjs/highlight.js/wiki/security"),console.warn("The element with unescaped HTML:"),console.warn(je)),Fe.throwUnescapedHTML))throw new Qe("One of your code blocks includes unescaped HTML.",je.innerHTML);Ye=je;const Pt=Ye.textContent,gn=xt?on(Pt,{language:xt,ignoreIllegals:!0}):ds(Pt);je.innerHTML=gn.value,je.dataset.highlighted="yes",Di(je,xt,gn.language),je.result={language:gn.language,re:gn.relevance,relevance:gn.relevance},gn.secondBest&&(je.secondBest={language:gn.secondBest.language,relevance:gn.secondBest.relevance}),Qn("after:highlightElement",{el:je,result:gn,text:Pt})}function In(je){Fe=$e(Fe,je)}const Yn=()=>{Os(),ne("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")};function Ds(){Os(),ne("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")}let jr=!1;function Os(){function je(){Os()}if(document.readyState==="loading"){jr||window.addEventListener("DOMContentLoaded",je,!1),jr=!0;return}document.querySelectorAll(Fe.cssSelector).forEach(pn)}function Mr(je,Ye){let xt=null;try{xt=Ye(Q)}catch(Pt){if(Me("Language definition for '{}' could not be registered.".replace("{}",je)),Qt)Me(Pt);else throw Pt;xt=He}xt.name||(xt.name=je),we[je]=xt,xt.rawDefinition=Ye.bind(null,Q),xt.aliases&&Gi(xt.aliases,{languageName:je})}function fs(je){delete we[je];for(const Ye of Object.keys(Pe))Pe[Ye]===je&&delete Pe[Ye]}function Rr(){return Object.keys(we)}function Xn(je){return je=(je||"").toLowerCase(),we[je]||we[Pe[je]]}function Gi(je,{languageName:Ye}){typeof je=="string"&&(je=[je]),je.forEach(xt=>{Pe[xt.toLowerCase()]=Ye})}function Si(je){const Ye=Xn(je);return Ye&&!Ye.disableAutodetect}function hs(je){je["before:highlightBlock"]&&!je["before:highlightElement"]&&(je["before:highlightElement"]=Ye=>{je["before:highlightBlock"](Object.assign({block:Ye.el},Ye))}),je["after:highlightBlock"]&&!je["after:highlightElement"]&&(je["after:highlightElement"]=Ye=>{je["after:highlightBlock"](Object.assign({block:Ye.el},Ye))})}function vn(je){hs(je),ct.push(je)}function Dr(je){const Ye=ct.indexOf(je);Ye!==-1&&ct.splice(Ye,1)}function Qn(je,Ye){const xt=je;ct.forEach(function(Pt){Pt[xt]&&Pt[xt](Ye)})}function jn(je){return ne("10.7.0","highlightBlock will be removed entirely in v12.0"),ne("10.7.0","Please use highlightElement now."),pn(je)}Object.assign(Q,{highlight:on,highlightAuto:ds,highlightAll:Os,highlightElement:pn,highlightBlock:jn,configure:In,initHighlighting:Yn,initHighlightingOnLoad:Ds,registerLanguage:Mr,unregisterLanguage:fs,listLanguages:Rr,getLanguage:Xn,registerAliases:Gi,autoDetection:Si,inherit:$e,addPlugin:vn,removePlugin:Dr}),Q.debugMode=function(){Qt=!1},Q.safeMode=function(){Qt=!0},Q.versionString=Ae,Q.regex={concat:v,lookahead:y,either:k,optional:x,anyNumberOfTimes:b};for(const je in re)typeof re[je]=="object"&&e(re[je]);return Object.assign(Q,re),Q},Dt=Xt({});return Dt.newInstance=()=>Xt({}),tx=Dt,Dt.HighlightJS=Dt,Dt.default=Dt,tx}var cW=lW();const uW=cf(cW),N2={},dW="hljs-";function fW(e){const t=uW.newInstance();return e&&r(e),{highlight:n,highlightAuto:i,listLanguages:s,register:r,registerAlias:o,registered:c};function n(u,f,p){const m=p||N2,y=typeof m.prefix=="string"?m.prefix:dW;if(!t.getLanguage(u))throw new Error("Unknown language: `"+u+"` is not registered");t.configure({__emitter:hW,classPrefix:y});const b=t.highlight(f,{ignoreIllegals:!0,language:u});if(b.errorRaised)throw new Error("Could not highlight with `Highlight.js`",{cause:b.errorRaised});const x=b._emitter.root,v=x.data;return v.language=b.language,v.relevance=b.relevance,x}function i(u,f){const m=(f||N2).subset||s();let y=-1,b=0,x;for(;++y<m.length;){const v=m[y];if(!t.getLanguage(v))continue;const w=n(v,u,f);w.data&&w.data.relevance!==void 0&&w.data.relevance>b&&(b=w.data.relevance,x=w)}return x||{type:"root",children:[],data:{language:void 0,relevance:b}}}function s(){return t.listLanguages()}function r(u,f){if(typeof u=="string")t.registerLanguage(u,f);else{let p;for(p in u)Object.hasOwn(u,p)&&t.registerLanguage(p,u[p])}}function o(u,f){if(typeof u=="string")t.registerAliases(typeof f=="string"?f:[...f],{languageName:u});else{let p;for(p in u)if(Object.hasOwn(u,p)){const m=u[p];t.registerAliases(typeof m=="string"?m:[...m],{languageName:p})}}}function c(u){return!!t.getLanguage(u)}}class hW{constructor(t){this.options=t,this.root={type:"root",children:[],data:{language:void 0,relevance:0}},this.stack=[this.root]}addText(t){if(t==="")return;const n=this.stack[this.stack.length-1],i=n.children[n.children.length-1];i&&i.type==="text"?i.value+=t:n.children.push({type:"text",value:t})}startScope(t){this.openNode(String(t))}endScope(){this.closeNode()}__addSublanguage(t,n){const i=this.stack[this.stack.length-1],s=t.root.children;n?i.children.push({type:"element",tagName:"span",properties:{className:[n]},children:s}):i.children.push(...s)}openNode(t){const n=this,i=t.split(".").map(function(o,c){return c?o+"_".repeat(c):n.options.classPrefix+o}),s=this.stack[this.stack.length-1],r={type:"element",tagName:"span",properties:{className:i},children:[]};s.children.push(r),this.stack.push(r)}closeNode(){this.stack.pop()}finalize(){}toHTML(){return""}}const pW={};function _1(e){const t=e||pW,n=t.aliases,i=t.detect||!1,s=t.languages||oW,r=t.plainText,o=t.prefix,c=t.subset;let u="hljs";const f=fW(s);if(n&&f.registerAlias(n),o){const p=o.indexOf("-");u=p===-1?o:o.slice(0,p)}return function(p,m){$m(p,"element",function(y,b,x){if(y.tagName!=="code"||!x||x.type!=="element"||x.tagName!=="pre")return;const v=mW(y);if(v===!1||!v&&!i||v&&r&&r.includes(v))return;Array.isArray(y.properties.className)||(y.properties.className=[]),y.properties.className.includes(u)||y.properties.className.unshift(u);const w=O7(y,{whitespace:"pre"});let k;try{k=v?f.highlight(v,w,{prefix:o}):f.highlightAuto(w,{prefix:o,subset:c})}catch(C){const S=C;if(v&&/Unknown language/.test(S.message)){m.message("Cannot highlight as `"+v+"`, it’s not registered",{ancestors:[x,y],cause:S,place:y.position,ruleId:"missing-language",source:"rehype-highlight"});return}throw S}!v&&k.data&&k.data.language&&y.properties.className.push("language-"+k.data.language),k.children.length>0&&(y.children=k.children)})}}function mW(e){const t=e.properties.className;let n=-1;if(!Array.isArray(t))return;let i;for(;++n<t.length;){const s=String(t[n]);if(s==="no-highlight"||s==="nohighlight")return!1;!i&&s.slice(0,5)==="lang-"&&(i=s.slice(5)),!i&&s.slice(0,9)==="language-"&&(i=s.slice(9))}return i}function MR({text:e}){return e?d.jsx("div",{className:"prose-chat text-sm break-words font-[family-name:var(--font-body)]",children:d.jsx(x1,{remarkPlugins:[k1],rehypePlugins:[_1],children:e})}):null}const gW=["chat.message","chat.message.pending","chat.message.snapshot","chat.message.chunk.text","chat.message.chunk.thinking","chat.message.chunk.tool_use","chat.message.chunk.tool_update","chat.message.chunk.interaction","chat.message.interaction.updated","chat.message.complete","chat.message.error","chat.resync.required"];function pi(e){return typeof e=="string"?e:""}function _2(e,t){return typeof e=="number"&&Number.isFinite(e)?e:t}function yW(e,t,n){if(!t||typeof t!="object"||!n)return null;const i=t,s=pi(i.sessionId);if(s&&s!==n)return null;const r=n,o=typeof i.seq=="number"?i.seq:void 0,c=pi(i.assistantId)||pi(i.turnId);switch(e){case"chat.message":return i.message?{type:"message.appended",sessionId:r,message:i.message,seq:o}:null;case"chat.message.pending":return c?{type:"turn.pending",sessionId:r,turnId:c,seq:o}:null;case"chat.message.snapshot":return c?{type:"turn.snapshot",sessionId:r,turnId:c,blocks:i.blocks??[],seq:o}:null;case"chat.message.chunk.text":return c&&typeof i.text=="string"?{type:"text.delta",sessionId:r,turnId:c,text:i.text,seq:o}:null;case"chat.message.chunk.thinking":return c&&typeof i.text=="string"?{type:"thinking.delta",sessionId:r,turnId:c,text:i.text,seq:o}:null;case"chat.message.chunk.tool_use":return c&&pi(i.id)?{type:"tool_use.started",sessionId:r,turnId:c,id:pi(i.id),title:pi(i.title),kind:pi(i.kind),status:pi(i.status),input:i.input,locations:i.locations,seq:o}:null;case"chat.message.chunk.tool_update":return c&&pi(i.id)?{type:"tool_use.updated",sessionId:r,turnId:c,id:pi(i.id),status:pi(i.status),input:i.input,locations:i.locations,seq:o}:null;case"chat.message.chunk.interaction":return c&&pi(i.id)?{type:"interaction.required",sessionId:r,turnId:c,id:pi(i.id),kind:pi(i.kind),title:pi(i.title),schema:i.schema,...i.respond==="message"||i.respond==="endpoint"?{respond:i.respond}:{},revision:_2(i.revision,1),seq:o}:null;case"chat.message.interaction.updated":return pi(i.interactionId)?{type:"interaction.updated",sessionId:r,interactionId:pi(i.interactionId),status:i.status==="cancelled"?"cancelled":"answered",revision:_2(i.revision,1),answer:i.answer,seq:o}:null;case"chat.message.complete":return c&&i.message?{type:"turn.completed",sessionId:r,turnId:c,message:i.message,seq:o}:null;case"chat.resync.required":return{type:"resync.required",sessionId:r,...typeof i.reason=="string"?{reason:i.reason}:{}};case"chat.message.error":return{type:"turn.failed",sessionId:r,...c?{turnId:c}:{},...i.message?{message:i.message}:{},seq:o};default:return null}}const bW="optim-";function O0(e,t){return{sessionId:e,turnId:t,blocks:[],done:!1,finalMessage:null}}function ld(e,t){return e.pending&&e.pending.turnId===t?e.pending:O0(e.sessionId,t)}function L0(e,t){if(e.some(i=>i.id===t.id))return e;const n=e.findIndex(i=>i.role==="user"&&i.id.startsWith(bW)&&i.role===t.role&&i.content===t.content);if(n>=0){const i=[...e];return i[n]=t,i}return[...e,t]}function xW(e,t,n){let i=!1;const s=e.map(r=>{var o;return(o=r.blocks)!=null&&o.some(c=>c.type==="interaction"&&c.id===t)?(i=!0,{...r,blocks:r.blocks.map(c=>c.type==="interaction"&&c.id===t?{...c,...n}:c)}):r});return i?s:e}function vW(e,t){if(t.sessionId!==e.sessionId)return e;const n="turnId"in t?t.turnId:void 0;if(typeof t.seq=="number"&&t.seq>0){const i=n===void 0||n===e.seqTurnId;if(i&&t.seq<=e.lastSeq)return e;i&&e.lastSeq>0&&t.seq>e.lastSeq+1&&(e={...e,gapDetected:!0}),e={...e,lastSeq:t.seq,...n!==void 0?{seqTurnId:n}:{}}}switch(t.type){case"message.appended":return{...e,messages:L0(e.messages,t.message)};case"turn.pending":return{...e,pending:O0(e.sessionId,t.turnId)};case"turn.snapshot":return{...e,pending:{...O0(e.sessionId,t.turnId),blocks:[...t.blocks]}};case"text.delta":{const i=ld(e,t.turnId),s=[...i.blocks],r=s[s.length-1];return r&&r.type==="text"?s[s.length-1]={...r,text:r.text+t.text}:s.push({type:"text",text:t.text}),{...e,pending:{...i,blocks:s}}}case"thinking.delta":{const i=ld(e,t.turnId);return{...e,pending:{...i,thinking:(i.thinking??"")+t.text}}}case"tool_use.started":{const i=ld(e,t.turnId),s={type:"tool_use",id:t.id,title:t.title,kind:t.kind,status:t.status,input:t.input,locations:t.locations},r=i.blocks.findIndex(c=>c.type==="tool_use"&&c.id===t.id),o=[...i.blocks];if(r>=0){const c=o[r];o[r]={...s,input:c.input??t.input}}else o.push(s);return{...e,pending:{...i,blocks:o}}}case"tool_use.updated":{if(!e.pending||e.pending.turnId!==t.turnId)return e;const i=e.pending;return{...e,pending:{...i,blocks:i.blocks.map(s=>s.type==="tool_use"&&s.id===t.id?{...s,status:t.status,input:s.input??t.input,locations:s.locations??t.locations}:s)}}}case"interaction.required":{const i=ld(e,t.turnId),s=i.blocks.findIndex(c=>c.type==="interaction"&&c.id===t.id),r={type:"interaction",id:t.id,kind:t.kind,title:t.title,schema:t.schema,...t.respond?{respond:t.respond}:{},revision:t.revision,status:"pending"},o=[...i.blocks];return s>=0?o[s]=r:o.push(r),{...e,pending:{...i,blocks:o}}}case"interaction.updated":{const i={status:t.status,revision:t.revision,...t.answer!==void 0?{answer:t.answer}:{}},s=e.pending,r=s&&s.blocks.some(o=>o.type==="interaction"&&o.id===t.interactionId)?{...s,blocks:s.blocks.map(o=>o.type==="interaction"&&o.id===t.interactionId?{...o,...i}:o)}:s;return{...e,pending:r,messages:xW(e.messages,t.interactionId,i)}}case"turn.completed":{const i=ld(e,t.turnId);return{...e,pending:{...i,done:!0,finalMessage:t.message}}}case"resync.required":return{...e,gapDetected:!0};case"turn.failed":{const i=!!e.pending&&(!t.turnId||e.pending.turnId===t.turnId);return{...e,pending:i?null:e.pending,messages:t.message?L0(e.messages,t.message):e.messages}}default:return e}}function wW(e){const t=e.pending;return!(t!=null&&t.done)||!t.finalMessage?e:{...e,messages:L0(e.messages,t.finalMessage),pending:null}}function RR(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.title=="string"&&Array.isArray(t.fields)}function DR(e){return e==="multiselect"||e==="checkbox"}function OR(e){return e==="number"||e==="slider"}function EW(e){return e.default!==void 0?e.default:DR(e.type)?[]:e.type==="toggle"?!1:OR(e.type)?e.min??0:""}function kW(e,t){const n={};for(const i of e.fields)n[i.id]=t&&i.id in t?t[i.id]:EW(i);return n}function LR(e,t){const n=new Map(e.fields.map(s=>[s.id,s])),i=(s,r)=>{if(!s.dependsOn||r>16)return!0;const o=n.get(s.dependsOn.field);return!o||!i(o,r+1)?!1:t[s.dependsOn.field]===s.dependsOn.equals};return e.fields.filter(s=>i(s,0))}function IR(e){return e==null||e===""?!0:Array.isArray(e)&&e.length===0}function SW(e,t){return LR(e,t).filter(n=>n.required&&IR(t[n.id]))}function NW(e,t){const n={};for(const i of LR(e,t)){const s=t[i.id];if(!(IR(s)&&i.type!=="toggle"))if(OR(i.type)&&typeof s=="string"){const r=Number(s);n[i.id]=Number.isFinite(r)?r:s}else DR(i.type)?n[i.id]=Array.isArray(s)?s:[s]:n[i.id]=s}return n}function _W(e,t){const n=[];for(const i of e.fields){const s=t[i.id];if(s===void 0)continue;const r=c=>{var f;const u=(f=i.options)==null?void 0:f.find(p=>p.value===c);return u?u.label:String(c)},o=Array.isArray(s)?s.map(r).join("、"):r(s);o&&n.push(e.fields.length===1?o:`${i.label}:${o}`)}return n.join(" · ")}function CW(e){var n;const t=[];for(const i of e.messages)for(const s of i.blocks??[])s.type==="interaction"&&s.status==="pending"&&t.push(s);for(const i of((n=e.pending)==null?void 0:n.blocks)??[])i.type==="interaction"&&i.status==="pending"&&t.push(i);return t}function TW(e){const t=CW(e);return t.length>0?t[t.length-1]:null}const AW=40;function I0(e,t){return e.type==="text"?Math.max(0,e.text.length-t):0}function jW(e,t){return e.map((i,s)=>t[s]??0)}function MW(e,t){return e.every((n,i)=>I0(n,t[i]??0)===0)}function RW(e,t){const n=jW(e,t),i=e.reduce((r,o,c)=>r+I0(o,n[c]??0),0);if(i<=0)return t.length===n.length?t:n;let s=Math.max(1,Math.ceil(i/AW));return e.map((r,o)=>{const c=n[o]??0,u=I0(r,c);if(u<=0||s<=0)return c;const f=Math.min(u,s);return s-=f,c+f})}function DW(){return St("/api/chat/sessions")}function Ap(e){return St(`/api/chat/sessions/${e}`)}async function PR(e={}){const t=await fetch("/api/chat/sessions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok)throw new Error(`${t.status}: ${await t.text()}`);return await t.json()}async function OW(e,t=!1){const n=await fetch(`/api/chat/sessions/${e}${t?"?workspace=1":""}`,{method:"DELETE"});if(!n.ok)throw new Error(`${n.status}`);return n.status===204?{workspaceRemoved:!1}:await n.json()}async function LW(e,t,n,i){const s=await fetch(`/api/chat/sessions/${e}/messages`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:t,attachments:n,interaction:i})});if(!s.ok)throw new Error(`${s.status}: ${await s.text()}`);return await s.json()}async function zR(e){const t=await fetch(`/api/chat/sessions/${e}/interrupt`,{method:"POST"});if(!t.ok&&t.status!==204)throw new Error(`${t.status}: ${await t.text()}`)}async function P0(e,t,n,i){const s=await fetch(`/api/chat/sessions/${e}/interactions/${t}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({answer:n,expectedRevision:i})});if(!s.ok)throw new Error(`${s.status}: ${await s.text()}`);return await s.json()}async function IW(e,t,n){const i=await fetch(`/api/chat/sessions/${e}/interactions/${t}/cancel`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({expectedRevision:n})});if(!i.ok&&i.status!==204)throw new Error(`${i.status}: ${await i.text()}`)}function PW(e,t){const n=t?`?since=${encodeURIComponent(t)}`:"";return St(`/api/chat/sessions/${e}/messages${n}`)}function BR(e){const t=e?`?path=${encodeURIComponent(e)}`:"";return St(`/api/fs/browse${t}`)}async function zW(e,t){const n=await fetch("/api/fs/mkdir",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:e,name:t})});if(!n.ok){const i=await n.text();throw new Error(`${n.status}: ${i}`)}return await n.json()}const UR=50*1024*1024;async function nx(e,t){if(t.size>UR)throw new Error(`文件超过 50 MB 上限(当前 ${(t.size/1024/1024).toFixed(2)} MB)`);const n=new FormData;n.append("sessionId",e),n.append("file",t,t.name);const i=await fetch("/api/fs/upload",{method:"POST",body:n});if(!i.ok){const s=await i.text();throw new Error(`${i.status}: ${s}`)}return await i.json()}function $o(e,t){return`/api/fs/file?${new URLSearchParams({path:t,sessionId:e}).toString()}`}function BW(e){return/\.(png|jpe?g|gif|webp|svg|bmp|avif)$/i.test(e)}function FR(e,t){if(e.title!=="mcp__sps__generate_asset"||e.status!=="completed"&&e.status!=="complete")return null;const n=e.input;if(!n||n.kind!=="image"||!n.outPath)return null;const i=n.outPath,s=i.startsWith("/")?i:t?`${t.replace(/\/+$/,"")}/${i}`:null;return s&&BW(s)?s:null}function UW(e,t){const n=[];for(const i of e){if(i.type!=="tool_use")continue;const s=FR(i,t);s&&!n.includes(s)&&n.push(s)}return n}function FW({sessionId:e,path:t,onPreview:n}){const[i,s]=_.useState(!1);return i?null:d.jsx("button",{type:"button",onClick:n,className:"block w-fit max-w-full border-2 border-[var(--color-text)] hover:shadow-[3px_3px_0_var(--color-text)] transition-shadow",title:"预览","aria-label":"预览",children:d.jsx("img",{src:$o(e,t),alt:"生成的图片",className:"block max-h-96 max-w-full object-contain",loading:"lazy",onError:()=>s(!0)})})}function $W({sessionId:e,path:t,onClose:n}){return _.useEffect(()=>{const i=s=>{s.key==="Escape"&&(s.preventDefault(),n())};return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[n]),d.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-[rgba(45,55,72,0.6)] p-4",role:"presentation",onClick:n,children:d.jsx("img",{src:$o(e,t),alt:"预览",className:"max-w-full max-h-[85vh] object-contain",onClick:i=>i.stopPropagation()})})}function qW(e){if(e==null||typeof e!="object")return typeof e=="string"?e:"";const t=e,n=s=>typeof t[s]=="string"?t[s]:void 0;return n("file_path")??n("path")??n("notebook_path")??n("command")??n("pattern")??n("query")??n("url")??n("name")??n("description")??n("prompt")??Object.values(t).find(s=>typeof s=="string"&&s.trim())??""}function HW({tool:e,live:t}){const[n,i]=_.useState(!1),s=e.status==="completed"||e.status==="complete",r=e.status==="failed",o=e.status==="interrupted"||!s&&!r&&!t,c=!s&&!r&&!o,u=qW(e.input),f=e.input!=null&&(typeof e.input!="object"||Object.keys(e.input).length>0);return d.jsxs("div",{className:"border border-[var(--surface-card-border)] rounded-lg overflow-hidden bg-[var(--color-bg-cream)]",children:[d.jsxs("button",{type:"button",onClick:()=>i(p=>!p),className:"w-full flex items-center gap-2 px-3 py-2 text-xs font-[family-name:var(--font-mono)] hover:bg-[var(--surface-control-hover)] transition-colors",children:[d.jsx(pf,{size:12,strokeWidth:3,className:["transition-transform flex-shrink-0",n?"rotate-90":""].join(" ")}),d.jsx(Kj,{size:12,strokeWidth:2.5,className:"flex-shrink-0"}),d.jsx("span",{className:"font-bold flex-shrink-0",children:e.title||e.kind}),d.jsx("span",{className:"flex-1 text-left text-[var(--color-text-muted)] truncate",title:u,children:u}),c&&d.jsx(mt,{size:12,strokeWidth:3,className:"animate-spin text-[var(--color-running)] flex-shrink-0"}),s&&d.jsx(Qp,{size:12,strokeWidth:2.5,className:"text-[var(--color-running)] flex-shrink-0"}),r&&d.jsx(Dj,{size:12,strokeWidth:2.5,className:"text-[var(--color-crashed)] flex-shrink-0"}),o&&d.jsx("span",{className:"text-[10px] text-[var(--color-text-muted)] border border-[var(--surface-card-border)] rounded px-1 flex-shrink-0",title:"回合已结束,该工具未回报结果",children:"已中断"})]}),n&&d.jsxs("div",{className:"px-3 py-2 text-xs font-[family-name:var(--font-mono)] text-[var(--color-text-muted)] border-t border-[var(--surface-card-border)] space-y-1",children:[f?d.jsx("pre",{className:"whitespace-pre-wrap break-all text-[var(--color-text)] max-h-72 overflow-auto",children:typeof e.input=="string"?e.input:JSON.stringify(e.input,null,2)}):d.jsx("div",{children:"无参数"}),d.jsxs("div",{className:"opacity-60",children:["id: ",e.id," · ",e.status]})]})]})}function VW(e){return RR(e)?{...e.description?{description:e.description}:{},properties:Object.fromEntries(e.fields.map(t=>[t.id,{title:t.label,type:t.type==="toggle"||t.type==="checkbox"?"boolean":t.type==="number"||t.type==="slider"?"number":"string",...t.options?{enum:t.options.map(n=>n.value)}:{},...t.type==="textarea"?{format:"textarea"}:{},...t.default!==void 0?{default:t.default}:{},...t.hint?{description:t.hint}:{}}])),required:e.fields.filter(t=>t.required).map(t=>t.id)}:e&&typeof e=="object"&&!Array.isArray(e)?e:{}}function KW({interaction:e,sessionId:t,onOpenForm:n}){const i=VW(e.schema),s=i.properties??{},r=new Set(i.required??[]),[o,c]=_.useState(()=>Object.fromEntries(Object.entries(s).filter(([,C])=>C.default!==void 0).map(([C,S])=>[C,S.default]))),[u,f]=_.useState(e.status==="pending"?"idle":e.status),[p,m]=_.useState(""),y=u==="answered"||u==="cancelled"||e.status!=="pending",b=e.kind==="form"&&!!n,x=u==="cancelled"||e.status==="cancelled",v=C=>{const S={...o};C!==void 0&&(S.approved=C);for(const[T,A]of Object.entries(s))A.type==="number"&&typeof S[T]=="string"&&(S[T]=Number(S[T]));return S},w=async C=>{if(!t||y)return;m("");const S=v(C),T=[...r].filter(A=>S[A]===void 0||S[A]===null||S[A]==="");if(T.length>0){m(`请填写:${T.map(A=>{var j;return((j=s[A])==null?void 0:j.title)??A}).join("、")}`);return}f("submitting");try{await P0(t,e.id,S,e.revision),f("answered")}catch(A){f("idle"),m(A instanceof Error?A.message:String(A))}},k=async()=>{if(!(!t||y)){m(""),f("cancelling");try{await IW(t,e.id,e.revision),f("cancelled")}catch(C){f("idle"),m(C instanceof Error?C.message:String(C))}}};return d.jsxs("section",{className:"border-2 border-[var(--color-text)] bg-[var(--color-bg-cream)] p-3 space-y-3","aria-label":e.title,children:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx(x6,{size:16,strokeWidth:2.5}),d.jsx("strong",{className:"text-sm",children:e.title})]}),i.description&&d.jsx("p",{className:"text-xs text-[var(--color-text-muted)]",children:i.description}),!y&&e.kind!=="approval"&&!b&&d.jsx("div",{className:"space-y-3",children:Object.entries(s).map(([C,S])=>{const T=S.title??C,A="w-full border border-[var(--surface-card-border)] bg-white px-2 py-1.5 text-sm";return d.jsxs("label",{className:"block text-xs font-semibold space-y-1",children:[d.jsxs("span",{children:[T,r.has(C)?" *":""]}),Array.isArray(S.enum)?d.jsxs("select",{className:A,value:String(o[C]??""),onChange:j=>c(M=>({...M,[C]:j.target.value})),children:[d.jsx("option",{value:"",children:"请选择"}),S.enum.map(j=>d.jsx("option",{value:String(j),children:String(j)},String(j)))]}):S.type==="boolean"?d.jsx("input",{type:"checkbox",checked:o[C]===!0,onChange:j=>c(M=>({...M,[C]:j.target.checked}))}):S.format==="textarea"?d.jsx("textarea",{className:A,rows:4,value:String(o[C]??""),onChange:j=>c(M=>({...M,[C]:j.target.value}))}):d.jsx("input",{className:A,type:S.type==="number"?"number":"text",value:String(o[C]??""),onChange:j=>c(M=>({...M,[C]:j.target.value}))})]},C)})}),!y&&e.kind==="approval"&&d.jsxs("label",{className:"block text-xs font-semibold space-y-1",children:[d.jsx("span",{children:"拒绝原因(可选)"}),d.jsx("input",{className:"w-full border border-[var(--surface-card-border)] bg-white px-2 py-1.5 text-sm",value:String(o.reason??""),onChange:C=>c(S=>({...S,reason:C.target.value}))})]}),p&&d.jsx("p",{className:"text-xs text-[var(--color-crashed)]",children:p}),y?d.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs font-semibold text-[var(--color-text-muted)]",children:[d.jsx("span",{children:x?"已取消,不能继续执行":"已提交,Agent 正在继续"}),b&&!x&&d.jsx("button",{type:"button",className:"border border-[var(--surface-card-border)] px-2 py-1 text-xs",onClick:()=>n(e),children:"查看已填内容"})]}):d.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.kind==="approval"?d.jsxs(d.Fragment,{children:[d.jsx("button",{type:"button",className:"border border-[var(--color-text)] px-3 py-1.5 text-xs font-bold bg-[var(--color-running)]",disabled:!t||u!=="idle",onClick:()=>void w(!0),children:"批准"}),d.jsx("button",{type:"button",className:"border border-[var(--color-text)] px-3 py-1.5 text-xs font-bold",disabled:!t||u!=="idle",onClick:()=>void w(!1),children:"拒绝"})]}):b?d.jsx("button",{type:"button",className:"border border-[var(--color-text)] px-3 py-1.5 text-xs font-bold bg-[var(--color-running)]",disabled:!t||u!=="idle",onClick:()=>n(e),children:"点击填写配置"}):d.jsx("button",{type:"button",className:"border border-[var(--color-text)] px-3 py-1.5 text-xs font-bold bg-[var(--color-running)]",disabled:!t||u!=="idle",onClick:()=>void w(),children:"提交并继续"}),d.jsx("button",{type:"button",className:"border border-[var(--surface-card-border)] px-3 py-1.5 text-xs",disabled:!t||u!=="idle",onClick:()=>void k(),children:"取消任务"}),(u==="submitting"||u==="cancelling")&&d.jsx(mt,{size:14,className:"animate-spin self-center"})]})]})}function $R({text:e}){const[t,n]=_.useState(""),i=_.useRef(e);return i.current=e,_.useEffect(()=>{n(s=>e.startsWith(s)?s:"")},[e]),_.useEffect(()=>{const s=window.setInterval(()=>{n(r=>{const o=i.current;if(r.length>=o.length)return r;const c=Math.max(1,Math.ceil((o.length-r.length)/8));return o.slice(0,r.length+c)})},25);return()=>window.clearInterval(s)},[]),d.jsx("div",{className:"prose-chat text-sm whitespace-pre-wrap break-words font-[family-name:var(--font-body)]",children:t})}function GW({block:e,streaming:t,sessionId:n,onOpenForm:i}){return e.type==="text"?t?d.jsx($R,{text:e.text}):d.jsx(MR,{text:e.text}):e.type==="interaction"?d.jsx(KW,{interaction:e,sessionId:n,onOpenForm:i}):d.jsx(HW,{tool:e,live:t===!0})}const ix={title:"生图配置",description:"填好点「开始生成」;懒得填就点「让 AI 来填」,我按你说的补全。",submitLabel:"开始生成",fields:[{id:"prompt",label:"画面描述",type:"textarea",required:!0,placeholder:"主体 + 场景 + 动作 + 细节,越具体越好",hint:"想画什么"},{id:"style",label:"风格",type:"select",default:"realistic",options:[{value:"realistic",label:"写实"},{value:"3d-render",label:"3D 渲染"},{value:"anime",label:"动漫/二次元"},{value:"oil-painting",label:"油画"},{value:"watercolor",label:"水彩"},{value:"cyberpunk",label:"赛博朋克"},{value:"flat-illustration",label:"扁平插画"},{value:"cinematic",label:"电影感"}]},{id:"aspect",label:"画幅",type:"select",default:"1:1",options:[{value:"1:1",label:"正方形 1:1"},{value:"16:9",label:"横屏 16:9"},{value:"9:16",label:"竖屏 9:16"},{value:"4:3",label:"4:3"},{value:"3:4",label:"3:4"}]},{id:"lighting",label:"光线 / 氛围",type:"text",advanced:!0,placeholder:"如 柔和逆光、霓虹夜色、清晨薄雾"},{id:"mood",label:"情绪基调",type:"text",advanced:!0,placeholder:"如 宁静、孤独、热烈"},{id:"reference",label:"参考图",type:"image-ref",advanced:!0,hint:"可选:上传或贴 URL,做 img2img 风格参考"}]};function C2({spec:e,onSubmit:t,onSkip:n,onUpload:i,disabled:s,initialValues:r,layout:o="card",previewUrl:c}){const[u,f]=_.useState(()=>kW(e,r)),[p,m]=_.useState(!1),[y,b]=_.useState(!1),[x,v]=_.useState(!1),w=s||x,k=(I,B)=>f(q=>({...q,[I]:B})),{basic:C,advanced:S}=_.useMemo(()=>({basic:e.fields.filter(I=>!I.advanced),advanced:e.fields.filter(I=>I.advanced)}),[e.fields]),T=()=>SW(e,u),A=()=>{if(w)return;if(T().length){b(!0);return}t(NW(e,u)),b(!0),v(!0)},j=()=>{w||(n(),v(!0))},M=I=>{const B=new Map;for(const q of I){const G=q.group??"";(B.get(G)??B.set(G,[]).get(G)).push(q)}return[...B.entries()]},D=_.useMemo(()=>{const I=q=>q.type==="textarea",B=q=>q.type==="image-ref"||q.type==="file";return{prose:e.fields.filter(I),media:e.fields.filter(B),params:e.fields.filter(q=>!I(q)&&!B(q))}},[e.fields]),P=(I,B=!1)=>d.jsx(qR,{f:I,value:u[I.id],set:k,showErr:y,onUpload:i,dropzone:B,previewUrl:c},I.id);return o==="region"?d.jsxs("div",{className:["cfg-region",w?"is-locked":""].join(" "),children:[d.jsxs("div",{className:"cfg-region-head",children:[d.jsxs("span",{className:"cfg-region-title",children:[e.title,x&&" ✓"]}),e.description&&d.jsx("span",{className:"cfg-region-desc",children:e.description})]}),d.jsxs("div",{className:"cfg-region-body",children:[D.prose.length>0&&d.jsx("div",{className:"cfg-region-prose",children:D.prose.map(I=>P(I))}),D.params.length>0&&d.jsx("div",{className:"cfg-region-params",children:D.params.map(I=>P(I))}),D.media.length>0&&d.jsx("div",{className:"cfg-region-media",children:D.media.map(I=>P(I,!0))})]}),d.jsxs("div",{className:"cfg-region-actions",children:[d.jsxs("button",{type:"button",className:"nb-btn text-xs",onClick:j,disabled:w,children:[d.jsx(ao,{size:13,strokeWidth:2.5})," ",e.skipLabel??"让 AI 来填"]}),d.jsx("button",{type:"button",className:"nb-btn nb-btn-primary text-sm",onClick:A,disabled:w,children:e.submitLabel??"提交"})]})]}):d.jsxs("div",{className:["nb-card flex flex-col gap-3",w?"opacity-60 pointer-events-none":""].join(" "),children:[d.jsxs("div",{children:[d.jsxs("div",{className:"font-[family-name:var(--font-heading)] font-bold text-base",children:[e.title,x&&" ✓"]}),e.description&&d.jsx("div",{className:"text-xs text-[var(--color-text-muted)] mt-0.5",children:e.description})]}),M(C).map(([I,B])=>d.jsx(T2,{name:I,fields:B,values:u,set:k,showErr:y,onUpload:i},I||"default")),S.length>0&&d.jsxs("div",{className:"border-t border-dashed border-[var(--surface-card-border)] pt-2",children:[d.jsxs("button",{type:"button",className:"flex items-center gap-1 text-xs text-[var(--color-text-muted)] hover:text-[var(--color-text)]",onClick:()=>m(I=>!I),children:[p?d.jsx(uo,{size:14}):d.jsx(pf,{size:14})," 高级选项"]}),p&&d.jsx("div",{className:"mt-2 flex flex-col gap-3",children:M(S).map(([I,B])=>d.jsx(T2,{name:I,fields:B,values:u,set:k,showErr:y,onUpload:i},I||"adv"))})]}),d.jsxs("div",{className:"flex gap-2 justify-end pt-1",children:[d.jsxs("button",{type:"button",className:"nb-btn text-xs",onClick:j,disabled:w,children:[d.jsx(ao,{size:13,strokeWidth:2.5})," ",e.skipLabel??"让 AI 来填"]}),d.jsx("button",{type:"button",className:"nb-btn nb-btn-primary text-xs",onClick:A,disabled:w,children:e.submitLabel??"提交"})]})]})}function T2({name:e,fields:t,values:n,set:i,showErr:s,onUpload:r}){return d.jsxs("div",{className:"grid grid-cols-[repeat(auto-fit,minmax(15rem,1fr))] gap-x-4 gap-y-3 items-start",children:[e&&d.jsx("div",{className:"col-span-full text-xs font-bold text-[var(--color-text-muted)] uppercase tracking-wide",children:e}),t.map(o=>d.jsx(qR,{f:o,value:n[o.id],set:i,showErr:s,onUpload:r},o.id))]})}function WW(e){return e==="textarea"||e==="image-ref"||e==="file"}function qR({f:e,value:t,set:n,showErr:i,onUpload:s,dropzone:r,previewUrl:o}){const[c,u]=_.useState(!1),f=async b=>{if(!(!b||!s)){u(!0);try{n(e.id,await s(b))}catch{}finally{u(!1)}}},p=i&&e.required&&(t===""||t==null||Array.isArray(t)&&t.length===0),m=Array.isArray(t)?t:[],y=b=>n(e.id,m.includes(b)?m.filter(x=>x!==b):[...m,b]);return d.jsxs("label",{className:["flex flex-col gap-1",WW(e.type)?"col-span-full":""].join(" "),children:[d.jsxs("span",{className:"text-sm font-bold",children:[e.label,e.required&&d.jsx("span",{className:"text-[var(--color-crashed)]",children:" *"})]}),e.type==="text"&&d.jsx("input",{className:"nb-input w-full text-sm",value:t,placeholder:e.placeholder,onChange:b=>n(e.id,b.target.value)}),e.type==="textarea"&&d.jsx("textarea",{className:"nb-input w-full text-sm",style:{minHeight:72,resize:"vertical"},value:t,placeholder:e.placeholder,onChange:b=>n(e.id,b.target.value)}),e.type==="number"&&d.jsx("input",{type:"number",className:"nb-input w-full text-sm",value:t,min:e.min,max:e.max,step:e.step,onChange:b=>n(e.id,b.target.valueAsNumber)}),e.type==="slider"&&d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("input",{type:"range",className:"flex-1",value:t,min:e.min??0,max:e.max??100,step:e.step??1,onChange:b=>n(e.id,b.target.valueAsNumber)}),d.jsx("span",{className:"text-xs font-[family-name:var(--font-mono)] w-8 text-right",children:String(t)})]}),e.type==="select"&&d.jsx("select",{className:"nb-input w-full text-sm",value:t,onChange:b=>n(e.id,b.target.value),children:(e.options??[]).map(b=>d.jsx("option",{value:b.value,children:b.label},b.value))}),e.type==="radio"&&d.jsx("div",{className:"flex flex-wrap gap-2",children:(e.options??[]).map(b=>d.jsx("button",{type:"button",onClick:()=>n(e.id,b.value),className:["px-3 py-1.5 rounded-lg border-2 text-sm transition-all",t===b.value?"bg-[var(--color-accent-mint)] border-[var(--color-text)] font-bold":"bg-[var(--color-bg)] border-[var(--color-border-light)] hover:border-[var(--color-text)]"].join(" "),children:b.label},b.value))}),(e.type==="multiselect"||e.type==="checkbox")&&d.jsx("div",{className:"flex flex-wrap gap-2",children:(e.options??[]).map(b=>d.jsx("button",{type:"button",onClick:()=>y(b.value),className:["px-3 py-1.5 rounded-lg border-2 text-sm transition-all",m.includes(b.value)?"bg-[var(--color-accent-mint)] border-[var(--color-text)] font-bold":"bg-[var(--color-bg)] border-[var(--color-border-light)] hover:border-[var(--color-text)]"].join(" "),children:b.label},b.value))}),e.type==="toggle"&&d.jsxs("label",{className:"flex items-center gap-2 cursor-pointer select-none",children:[d.jsx("input",{type:"checkbox",className:"w-4 h-4",checked:t,onChange:b=>n(e.id,b.target.checked)}),d.jsx("span",{className:"text-xs text-[var(--color-text-muted)]",children:t?"开":"关"})]}),e.type==="color"&&d.jsx("input",{type:"color",className:"w-12 h-8 rounded border-2 border-[var(--color-text)]",value:t||"#000000",onChange:b=>n(e.id,b.target.value)}),(e.type==="image-ref"||e.type==="file")&&r&&d.jsxs("div",{className:"cfg-dropzone-wrap",children:[d.jsxs("label",{className:"cfg-dropzone","data-filled":t?"true":"false",children:[t&&o&&e.type==="image-ref"?d.jsx("img",{className:"cfg-dropzone-thumb",src:o(t),alt:""}):d.jsx("span",{className:"cfg-dropzone-hint",children:c?"上传中…":t?String(t).split("/").pop():s?"点击上传":"贴 URL"}),s&&d.jsx("input",{type:"file",className:"hidden",accept:e.accept??(e.type==="image-ref"?"image/*":void 0),onChange:b=>{var x;f((x=b.target.files)==null?void 0:x[0]),b.target.value=""},disabled:c})]}),d.jsx("input",{className:"nb-input w-full text-xs font-[family-name:var(--font-mono)]",value:t,placeholder:"或粘贴 URL",onChange:b=>n(e.id,b.target.value)})]}),(e.type==="image-ref"||e.type==="file")&&!r&&d.jsxs("div",{className:"flex flex-col gap-1.5",children:[s&&d.jsxs("label",{className:"nb-btn text-xs w-fit cursor-pointer",children:[c?"上传中…":t?"重新选择":"选择文件",d.jsx("input",{type:"file",className:"hidden",accept:e.accept??(e.type==="image-ref"?"image/*":void 0),onChange:b=>{var x;f((x=b.target.files)==null?void 0:x[0]),b.target.value=""},disabled:c})]}),d.jsx("input",{className:"nb-input w-full text-sm font-[family-name:var(--font-mono)]",value:t,placeholder:e.placeholder??(s?"或粘贴 URL":"粘贴图片/文件 URL"),onChange:b=>n(e.id,b.target.value)})]}),e.hint&&d.jsx("span",{className:"text-xs text-[var(--color-text-muted)]",children:e.hint}),p&&d.jsx("span",{className:"text-xs text-[var(--color-crashed)]",children:"必填"})]})}function sx(){if(!(typeof window>"u"))return window.SpeechRecognition??window.webkitSpeechRecognition}function YW({onComplete:e,onError:t}){const[n,i]=_.useState(!1),[s,r]=_.useState(""),o=_.useRef(null),c=_.useRef(""),u=_.useRef(""),f=_.useRef(0),p=_.useRef(!1),m=_.useRef(!1),y=_.useRef(null),b=_.useRef(e),x=_.useRef(t);b.current=e,x.current=t;const v=_.useCallback(()=>{y.current!==null&&(window.clearTimeout(y.current),y.current=null)},[]),w=_.useCallback(()=>{i(!1);const A=u.current.trim();c.current="",u.current="",A?b.current(A):x.current("no-speech")},[]),k=_.useCallback(()=>{f.current+=1,p.current=!1,m.current=!0,v();const A=o.current;o.current=null,A==null||A.abort(),c.current="",u.current="",r(""),i(!1)},[v]),C=_.useCallback(A=>{const j=sx();if(!j||A!==f.current||!p.current)return!1;const M=new j;M.continuous=!0,M.interimResults=!0,M.lang=navigator.language||"zh-CN",M.onresult=D=>{var I;if(A!==f.current)return;let P="";for(let B=D.resultIndex;B<D.results.length;B+=1){const q=D.results[B],G=((I=q==null?void 0:q[0])==null?void 0:I.transcript.trim())??"";q!=null&&q.isFinal&&G?c.current=`${c.current} ${G}`.trim():G&&(P+=` ${G}`)}u.current=`${c.current}${P}`.trim(),r(u.current)},M.onerror=D=>{A===f.current&&(D.error==="no-speech"||D.error==="aborted"||D.error==="network"||(p.current=!1,m.current=!0,i(!1),x.current(D.error)))},M.onend=()=>{if(A===f.current){if(o.current===M&&(o.current=null),m.current){m.current=!1;return}if(!p.current){w();return}i(!0),v(),y.current=window.setTimeout(()=>{y.current=null,C(A)},180)}},o.current=M;try{return M.start(),i(!0),!0}catch{return o.current=null,p.current=!1,i(!1),x.current("start-failed"),!1}},[v,w]),S=_.useCallback(()=>{p.current=!1,v();const A=o.current;A?A.stop():w()},[v,w]),T=_.useCallback(()=>{if(!sx())return x.current("unsupported"),!1;k();const j=f.current;return p.current=!0,m.current=!1,c.current="",u.current="",r(""),C(j)},[k,C]);return _.useEffect(()=>k,[k]),{cancel:k,isListening:n,start:T,stop:S,supported:!!sx(),transcript:s}}function XW(){const[e,t]=_.useState("inactive"),[n,i]=_.useState(null),s=_.useRef(null),r=_.useRef(null),o=_.useRef(0),c=_.useCallback(()=>{var f,p;o.current+=1,(f=r.current)==null||f.getTracks().forEach(m=>m.stop()),r.current=null,(p=s.current)==null||p.close(),s.current=null,i(null),t("inactive")},[]),u=_.useCallback(async()=>{var y;if(!((y=navigator.mediaDevices)!=null&&y.getUserMedia)||typeof AudioContext>"u"){t("unsupported");return}c();const f=o.current;t("requesting");let p=null,m=null;try{if(p=await navigator.mediaDevices.getUserMedia({audio:{autoGainControl:!0,echoCancellation:!0,noiseSuppression:!0}}),f!==o.current){p.getTracks().forEach(v=>v.stop());return}if(m=new AudioContext,m.state==="suspended"&&await m.resume(),f!==o.current){p.getTracks().forEach(v=>v.stop()),m.close();return}const b=m.createMediaStreamSource(p),x=m.createAnalyser();x.fftSize=2048,x.smoothingTimeConstant=.72,b.connect(x),r.current=p,s.current=m,i(x),t("active")}catch{p==null||p.getTracks().forEach(b=>b.stop()),m==null||m.close(),f===o.current&&t("denied")}},[c]);return _.useEffect(()=>c,[c]),{analyser:n,start:u,status:e,stop:c}}const QW=.12,A2=1e3,ZW=1e4,JW=150;function eY(e,t){t.bytes.length!==e.fftSize&&(t.bytes=new Uint8Array(new ArrayBuffer(e.fftSize))),e.getByteTimeDomainData(t.bytes);let n=0;for(const i of t.bytes){const s=(i-128)/128;n+=s*s}return Math.min(1,Math.sqrt(n/t.bytes.length)*3.4)}function tY(e){const{enabled:t,phase:n,suspended:i,analyser:s,silenceMs:r=2e3}=e,o=_.useRef(e);o.current=e;const c=_.useRef(0),u=_.useRef(0),f=_.useRef(0),p=_.useRef(0),m=_.useRef("");_.useEffect(()=>{const y=Date.now();n==="idle"?c.current=y+A2:n==="listening"&&(u.current=y,p.current=y,f.current=y,m.current="")},[n]),_.useEffect(()=>{if(!(n==="listening"||t&&n==="idle"))return;const y={bytes:new Uint8Array(new ArrayBuffer(0))},b=window.setInterval(()=>{const x=o.current,v=Date.now();if(document.hidden)return;if((x.analyser?eY(x.analyser,y):0)>QW&&(f.current=v),x.phase==="idle"){if(!x.enabled||x.suspended||v<c.current)return;x.transcript.trim().length>0&&(c.current=v+A2,x.onTrigger());return}x.transcript!==m.current&&(m.current=x.transcript,p.current=v);const k=v-Math.max(p.current,f.current);x.transcript.trim()?k>=(x.silenceMs??2e3)&&x.onEndpoint():v-u.current>=ZW&&x.onAbort()},JW);return()=>window.clearInterval(b)},[t,n,i,s,r])}function j2({checked:e,onChange:t,onIcon:n,offIcon:i,title:s,ariaLabel:r}){return d.jsxs("label",{className:"icon-toggle",title:s,children:[d.jsx("input",{type:"checkbox",checked:e,onChange:o=>t(o.target.checked),"aria-label":r}),d.jsxs("span",{className:"icon-toggle-btn","aria-hidden":"true",children:[d.jsx("span",{className:"icon-toggle-ico on",children:n}),d.jsx("span",{className:"icon-toggle-ico off",children:i})]})]})}function nY(e,t){return{sessionId:e.sessionId,id:e.turnId,done:e.done,finalMessage:e.finalMessage,...e.thinking?{thinking:e.thinking}:{},blocks:e.blocks.map((n,i)=>n.type==="text"?{type:"text",target:n.text,displayed:n.text.slice(0,t[i]??0)}:n)}}function iY(e,t){var C;const n=tn(),[i,s]=_.useState(null),[r,o]=_.useState([]),[c,u]=_.useState(!1),f=_.useRef(t);f.current=t;const p=_.useRef(null),m=_.useRef({lastSeq:0,gapDetected:!1}),y=ot({queryKey:["chat-session",e],queryFn:()=>Ap(e??""),enabled:!!e,refetchInterval:(t==null?void 0:t.pollMs)===0?!1:(t==null?void 0:t.pollMs)??4e3});_.useEffect(()=>{if(!e)return;p.current=null,m.current={lastSeq:0,gapDetected:!1},s(null),o([]);let S=null,T=null,A=!1,j=!0;const M=()=>{A||(S=new EventSource(`/stream/chat/${encodeURIComponent(e)}`),S.addEventListener("error",()=>{(S==null?void 0:S.readyState)!==EventSource.CLOSED||T!=null||(T=setTimeout(()=>{T=null,S==null||S.close(),M()},5e3))}),D(S))},D=P=>{P.addEventListener("open",()=>{if(j){j=!1;return}const B=n.getQueryData(["chat-session",e]),q=B!=null&&B.messages.length?B.messages[B.messages.length-1].ts:void 0;PW(e,q).then(G=>{G.data.length!==0&&n.setQueryData(["chat-session",e],R=>{if(!R)return R;const O=new Set(R.messages.map(W=>W.id)),z=G.data.filter(W=>!O.has(W.id));return z.length===0?R:{...R,messages:[...R.messages,...z],lastMessageAt:z[z.length-1].ts,messageCount:R.messageCount+z.length}})}).catch(()=>{})});const I=(B,q)=>{var X,K,U,F,Y,$;let G;try{G=JSON.parse(q)}catch{return}const R=yW(B,G,e);if(!R)return;const O=n.getQueryData(["chat-session",e]),z={sessionId:e,messages:(O==null?void 0:O.messages)??[],pending:p.current,...m.current},W=vW(z,R);if(W!==z)switch(m.current={lastSeq:W.lastSeq,gapDetected:W.gapDetected,...W.seqTurnId!==void 0?{seqTurnId:W.seqTurnId}:{}},W.pending!==z.pending&&(p.current=W.pending,s(W.pending)),W.messages!==z.messages&&n.setQueryData(["chat-session",e],ie=>{if(!ie)return ie;const be=W.messages.length-ie.messages.length,ce=W.messages[W.messages.length-1];return{...ie,messages:W.messages,...be>0&&ce?{lastMessageAt:ce.ts,messageCount:ie.messageCount+be}:{}}}),W.gapDetected&&!z.gapDetected&&(m.current={...m.current,gapDetected:!1},n.invalidateQueries({queryKey:["chat-session",e]})),R.type){case"turn.pending":(K=(X=f.current)==null?void 0:X.onTurnStart)==null||K.call(X);break;case"text.delta":(F=(U=f.current)==null?void 0:U.onAssistantChunk)==null||F.call(U,R.text);break;case"turn.failed":u(!1),($=(Y=f.current)==null?void 0:Y.onError)==null||$.call(Y,R.message??null);break}};for(const B of gW)P.addEventListener(B,q=>I(B,q.data))};return M(),()=>{A=!0,T!=null&&clearTimeout(T),S==null||S.close()}},[e,n]),_.useEffect(()=>{u(!1)},[e]),_.useEffect(()=>{var T,A;if(!i||i.sessionId!==e)return;if(MW(i.blocks,r)){if(!i.done||!i.finalMessage)return;const j=i.finalMessage,M=n.getQueryData(["chat-session",e]),D=wW({sessionId:e,messages:(M==null?void 0:M.messages)??[],pending:i,...m.current});n.setQueryData(["chat-session",e],P=>!P||P.messages.some(I=>I.id===j.id)?P:{...P,messages:D.messages,lastMessageAt:j.ts,messageCount:P.messageCount+1}),n.invalidateQueries({queryKey:["chat-sessions"]}),n.invalidateQueries({queryKey:["chat-session",e]}),p.current=null,s(null),o([]),u(!1),(A=(T=f.current)==null?void 0:T.onAssistantComplete)==null||A.call(T,j);return}const S=setTimeout(()=>{o(j=>RW(i.blocks,j))},25);return()=>clearTimeout(S)},[i,r,n,e]);const b=_.useCallback(async(S,T,A)=>{var P,I,B,q;if(c)return;let j=e;if(!j&&(j=await((I=(P=f.current)==null?void 0:P.ensureSessionId)==null?void 0:I.call(P))??null,!j))return;const M=T&&T.length>0?T:void 0,D={id:`optim-${Date.now()}`,role:"user",content:S,ts:new Date().toISOString(),status:"complete",...M?{attachments:M}:{}};n.setQueryData(["chat-session",j],G=>G?{...G,messages:[...G.messages,D],lastMessageAt:D.ts,messageCount:G.messageCount+1}:{id:j,createdAt:D.ts,lastMessageAt:D.ts,title:S.slice(0,60)||"…",project:null,messageCount:1,messages:[D]}),u(!0),(q=(B=f.current)==null?void 0:B.onTurnStart)==null||q.call(B);try{await LW(j,S,M,A)}catch(G){throw u(!1),G}},[c,e,n]),x=_.useCallback(async()=>{e&&await zR(e)},[e]),v=i&&i.sessionId===e?nY(i,r):null,w=((C=y.data)==null?void 0:C.messages)??[],k=e?TW({messages:w,pending:i&&i.sessionId===e?i:null}):null;return{detail:y.data??null,messages:w,isLoading:y.isLoading,activePending:v,activeInteraction:k,sending:c,send:b,interrupt:x}}function sY(e){return{id:e.id,role:e.role,content:e.content,status:e.status??"complete",...e.blocks&&e.blocks.length?{blocks:e.blocks}:{},...e.attachments&&e.attachments.length?{attachments:e.attachments}:{},...e.truncated?{truncated:!0}:{},...e.ts?{ts:e.ts}:{}}}function rY(e){const t=e.blocks.map(i=>i.type==="text"?{type:"text",text:i.target}:{...i}),n=e.blocks.reduce((i,s)=>s.type==="text"?i+s.target:i,"");return{id:e.id,role:"assistant",content:n,status:"streaming",blocks:t}}function aY(e){var y;const[t,n]=_.useState(null),i=_.useRef(null),s=_.useRef(e);s.current=e;const r=_.useCallback(b=>{i.current=b,n(b)},[]),o=_.useCallback(async()=>{if(i.current)return i.current;const b=await PR({title:"Voice conversation",dedicated:!0});return r(b.id),b.id},[r]),c=iY(t,{ensureSessionId:o,onAssistantChunk:b=>s.current.onAssistantChunk(b),onAssistantComplete:b=>s.current.onAssistantComplete(b.content),onTurnStart:()=>s.current.onThinking(),onError:b=>s.current.onError(new Error((b==null?void 0:b.content)??"Response failed"))}),u=_.useMemo(()=>{const b=c.activePending,x=c.messages.filter(v=>b?v.id===b.id||b.finalMessage&&v.id===b.finalMessage.id?!1:v.status!=="streaming":!0).map(sY);return b?[...x,rY(b)]:x},[c.messages,c.activePending]),f=_.useCallback(async(b,x,v)=>{try{await c.send(b,x,v)}catch(w){s.current.onError(w instanceof Error?w:new Error(String(w)))}},[c]),p=_.useCallback((b,x)=>{r(b)},[r]),m=_.useCallback(()=>{r(null)},[r]);return{isSending:c.sending,messages:u,activeInteraction:c.activeInteraction,thinking:(y=c.activePending)==null?void 0:y.thinking,send:f,sessionId:t,resume:p,reset:m,ensureSession:o}}function C1(){return St("/api/providers")}function HR(e){const t=[];for(const n of e)for(const i of n.models)t.push({providerId:n.id,model:i,label:`${i} · ${n.name}`});return t}const VR=HR;async function oY(e,t){const n=await fetch("/api/providers",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({kind:e,entry:t})});if(!n.ok)throw new Error(`${n.status}: ${await n.text()}`);return n.json()}async function lY(e,t){const n=await fetch(`/api/providers/${e}/${encodeURIComponent(t)}`,{method:"DELETE"});if(!n.ok)throw new Error(`${n.status}: ${await n.text()}`);return n.json()}function cY({title:e,body:t,confirm:n,cancel:i,onConfirm:s,onCancel:r,danger:o}){const c=Xe();return _.useEffect(()=>{const u=f=>{f.key==="Escape"&&r()};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[r]),d.jsx("div",{role:"dialog","aria-modal":"true","aria-labelledby":"confirm-title",className:"fixed inset-0 z-50 flex items-center justify-center p-6 bg-black/30",children:d.jsxs("div",{className:"nb-card max-w-md w-full",children:[d.jsx("h2",{id:"confirm-title",className:"font-[family-name:var(--font-heading)] text-xl font-bold mb-2",children:e}),d.jsx("p",{className:"text-sm text-[var(--color-text-muted)] mb-5",children:t}),d.jsxs("div",{className:"flex gap-3 justify-end",children:[d.jsx("button",{className:"nb-btn",onClick:r,type:"button",children:i??c("dialog.cancel.default")}),d.jsx("button",{className:o?"nb-btn nb-btn-danger":"nb-btn nb-btn-yellow",onClick:async()=>{await s()},type:"button",children:n})]})]})})}const KR=_.createContext(null);function uY({children:e}){const t=Xe(),[n,i]=_.useState(null),s=_.useCallback(c=>new Promise(u=>{i({kind:"confirm",opts:c,resolve:f=>{i(null),u(f)}})}),[]),r=_.useCallback(c=>new Promise(u=>{i({kind:"alert",opts:c,resolve:()=>{i(null),u()}})}),[]),o=_.useCallback(c=>new Promise(u=>{i({kind:"prompt",opts:c,resolve:f=>{i(null),u(f)}})}),[]);return d.jsxs(KR.Provider,{value:{confirm:s,alert:r,prompt:o},children:[e,(n==null?void 0:n.kind)==="confirm"&&d.jsx(cY,{title:n.opts.title,body:n.opts.body,confirm:n.opts.confirm??t("dialog.confirm.default"),cancel:n.opts.cancel,danger:n.opts.danger,onConfirm:()=>n.resolve(!0),onCancel:()=>n.resolve(!1)}),(n==null?void 0:n.kind)==="alert"&&d.jsx(dY,{title:n.opts.title,body:n.opts.body,confirm:n.opts.confirm??t("dialog.alert.default"),onClose:()=>n.resolve()}),(n==null?void 0:n.kind)==="prompt"&&d.jsx(fY,{title:n.opts.title,body:n.opts.body,placeholder:n.opts.placeholder,defaultValue:n.opts.defaultValue,confirm:n.opts.confirm??t("dialog.confirm.default"),cancel:n.opts.cancel??t("dialog.cancel.default"),onConfirm:c=>n.resolve(c),onCancel:()=>n.resolve(null)})]})}function Bn(){const e=_.useContext(KR);if(!e)throw new Error("useDialog must be used inside <DialogProvider>");return e}function dY({title:e,body:t,confirm:n,onClose:i}){return _.useEffect(()=>{const s=r=>{(r.key==="Escape"||r.key==="Enter")&&i()};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[i]),d.jsx("div",{role:"dialog","aria-modal":"true",className:"fixed inset-0 z-50 flex items-center justify-center p-6 bg-black/30",children:d.jsxs("div",{className:"nb-card max-w-md w-full",children:[d.jsx("h2",{className:"font-[family-name:var(--font-heading)] text-xl font-bold mb-2",children:e}),d.jsx("p",{className:"text-sm text-[var(--color-text-muted)] mb-5 whitespace-pre-wrap break-words",children:t}),d.jsx("div",{className:"flex gap-3 justify-end",children:d.jsx("button",{className:"nb-btn nb-btn-primary",onClick:i,type:"button",autoFocus:!0,children:n})})]})})}function fY({title:e,body:t,placeholder:n,defaultValue:i,confirm:s,cancel:r,onConfirm:o,onCancel:c}){const[u,f]=_.useState(i??""),p=_.useRef(null);_.useEffect(()=>{var b,x;(b=p.current)==null||b.focus(),(x=p.current)==null||x.select();const y=v=>{v.key==="Escape"&&c()};return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[c]);const m=()=>{const y=u.trim();y&&o(y)};return d.jsx("div",{role:"dialog","aria-modal":"true",className:"fixed inset-0 z-50 flex items-center justify-center p-6 bg-black/30",children:d.jsxs("div",{className:"nb-card max-w-md w-full",children:[d.jsx("h2",{className:"font-[family-name:var(--font-heading)] text-xl font-bold mb-2",children:e}),t&&d.jsx("p",{className:"text-sm text-[var(--color-text-muted)] mb-3 whitespace-pre-wrap break-words",children:t}),d.jsx("input",{ref:p,type:"text",className:"nb-input w-full mb-5",placeholder:n,value:u,onChange:y=>f(y.target.value),onKeyDown:y=>{y.key==="Enter"&&!y.nativeEvent.isComposing&&(y.preventDefault(),m())}}),d.jsxs("div",{className:"flex gap-3 justify-end",children:[d.jsx("button",{className:"nb-btn",onClick:c,type:"button",children:r}),d.jsx("button",{className:"nb-btn nb-btn-primary",onClick:m,type:"button",disabled:!u.trim(),children:s})]})]})})}function T1({initialPath:e,onCancel:t,onSelect:n,title:i,mode:s="directory"}){var C,S,T;const r=Xe(),{prompt:o,alert:c}=Bn(),u=i??r("dirPicker.title.default"),[f,p]=_.useState(e??null),[m,y]=_.useState(null),b=ot({queryKey:["fs-browse",f],queryFn:()=>BR(f??void 0),staleTime:0,gcTime:0}),x=((C=b.data)==null?void 0:C.path)??f??"",v=((S=b.data)==null?void 0:S.parent)??null,w=((T=b.data)==null?void 0:T.home)??null,k=async()=>{var j;if(!x)return;const A=(j=await o({title:r("dirPicker.newDir"),body:r("dirPicker.newDir.prompt"),placeholder:r("dirPicker.newDir.placeholder"),confirm:r("dirPicker.newDir.create")}))==null?void 0:j.trim();if(A)try{const M=await zW(x,A);p(M.path)}catch(M){c({title:r("dirPicker.newDir.error.title"),body:M instanceof Error?M.message:String(M)})}};return _.useEffect(()=>{const A=j=>{j.key==="Escape"&&(j.preventDefault(),t())};return window.addEventListener("keydown",A),()=>window.removeEventListener("keydown",A)},[t]),d.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-[rgba(45,55,72,0.5)] p-4",role:"presentation",children:d.jsxs("div",{className:"nb-card bg-[var(--color-bg)] max-w-lg w-full h-[70vh] min-h-0 overflow-hidden p-5 flex flex-col",role:"dialog","aria-modal":"true","aria-label":u,children:[d.jsxs("header",{className:"flex items-center justify-between mb-3 shrink-0",children:[d.jsx("div",{className:"flex items-center gap-2 min-w-0",children:d.jsx("h3",{className:"font-[family-name:var(--font-heading)] font-bold text-base truncate",children:u})}),d.jsx("button",{type:"button",className:"p-1 hover:bg-[var(--surface-control-hover)] rounded",onClick:t,"aria-label":r("dirPicker.close.aria"),children:d.jsx(En,{size:14,strokeWidth:3})})]}),d.jsxs("div",{className:"flex items-center gap-2 mb-3 shrink-0",children:[d.jsx("button",{type:"button",className:"nb-btn flex-shrink-0",style:{padding:"4px 10px",fontSize:12},onClick:()=>v&&p(v),disabled:!v||b.isLoading,"aria-label":r("dirPicker.up.aria"),title:r("dirPicker.up.title"),children:d.jsx(FB,{size:12,strokeWidth:3})}),d.jsx("button",{type:"button",className:"nb-btn flex-shrink-0",style:{padding:"4px 10px",fontSize:12},onClick:()=>w&&p(w),disabled:!w||b.isLoading,"aria-label":r("dirPicker.home.aria"),title:r("dirPicker.home.title"),children:d.jsx(zj,{size:12,strokeWidth:3})}),d.jsx("button",{type:"button",className:"nb-btn flex-shrink-0",style:{padding:"4px 10px",fontSize:12},onClick:()=>void k(),disabled:!x||b.isLoading||b.isError,"aria-label":r("dirPicker.newDir.aria"),title:r("dirPicker.newDir.aria"),children:d.jsx(vU,{size:12,strokeWidth:3})}),d.jsx("div",{className:"flex-1 min-w-0 nb-input font-[family-name:var(--font-mono)] text-xs px-2 py-1.5 truncate",title:x,dir:"rtl",children:x||"..."})]}),d.jsx("div",{className:"scroll-frame flex-1 border-2 border-[var(--color-text)] rounded-lg bg-[var(--color-bg-cream)] min-h-0",children:d.jsxs("div",{className:"scroll-frame-body h-full",children:[b.isLoading&&d.jsxs("div",{className:"flex items-center justify-center py-12 text-[var(--color-text-muted)]",children:[d.jsx(mt,{size:16,strokeWidth:3,className:"animate-spin mr-2"}),r("dirPicker.loading")]}),b.isError&&d.jsxs("div",{className:"p-4 text-sm text-[var(--color-crashed)]",children:[d.jsx("p",{className:"font-bold mb-1",children:r("dirPicker.error.title")}),d.jsx("p",{className:"text-xs font-[family-name:var(--font-mono)] break-all",children:b.error instanceof Error?b.error.message:String(b.error)})]}),b.data&&d.jsxs("ul",{className:"divide-y-2 divide-[var(--color-text)]/20",children:[b.data.entries.length===0&&d.jsx("li",{className:"p-4 text-xs text-[var(--color-text-subtle)] italic text-center",children:r("dirPicker.empty")}),b.data.entries.map(A=>{const j=(()=>{const P=x.endsWith("/")||x.endsWith("\\")?"":"/";return`${x}${P}${A.name}`})(),M=s==="file"&&m===j,D=A.isDirectory||s==="file";return d.jsx("li",{children:d.jsxs("button",{type:"button",className:["w-full flex items-center gap-2 px-3 py-2 text-left text-sm font-[family-name:var(--font-mono)]","disabled:opacity-50 disabled:cursor-not-allowed",M?"bg-[var(--color-accent-mint)] font-bold":"hover:bg-[var(--color-accent-mint)]"].join(" "),disabled:!D,onClick:()=>{A.isDirectory?(y(null),p(j)):s==="file"&&y(j)},onDoubleClick:()=>{s==="file"&&!A.isDirectory&&n(j)},title:A.isDirectory?r("dirPicker.enter.aria",{name:A.name}):s==="file"?r("dirPicker.pickFile.aria",{name:A.name}):r("dirPicker.fileLocked"),children:[A.isDirectory?d.jsx(Pj,{size:14,strokeWidth:2.5,className:"flex-shrink-0 text-[var(--color-text)]"}):d.jsx("span",{className:"w-3.5 h-3.5 flex-shrink-0"}),d.jsx("span",{className:"truncate",children:A.name}),A.isDirectory&&d.jsx(pf,{size:12,strokeWidth:2.5,className:"ml-auto flex-shrink-0 text-[var(--color-text-muted)]"})]})},A.name)})]})]})}),d.jsxs("div",{className:"flex gap-2 justify-end pt-3 shrink-0",children:[d.jsx("button",{type:"button",className:"nb-btn",onClick:t,children:r("dirPicker.cancel")}),s==="file"?d.jsxs("button",{type:"button",className:"nb-btn nb-btn-primary",onClick:()=>m&&n(m),disabled:!m||b.isLoading||b.isError,title:m??r("dirPicker.useFile.tooltip.empty"),children:[d.jsx(Qp,{size:14,strokeWidth:3}),r("dirPicker.useFile")]}):d.jsxs("button",{type:"button",className:"nb-btn nb-btn-primary",onClick:()=>n(x),disabled:!x||b.isLoading||b.isError,children:[d.jsx(Qp,{size:14,strokeWidth:3}),r("dirPicker.useDir")]})]})]})})}function hY({onCancel:e,onCreate:t}){var A,j;const n=Xe(),[i,s]=_.useState(""),[r,o]=_.useState(""),[c,u]=_.useState("claude"),[f,p]=_.useState(""),[m,y]=_.useState(!1),[b,x]=_.useState(!1),[v,w]=_.useState(!1),k=ot({queryKey:["providers"],queryFn:C1}),C=ot({queryKey:["system-agents"],queryFn:s1}),S=VR((c==="openai"?(A=k.data)==null?void 0:A.openai:(j=k.data)==null?void 0:j.anthropic)??[]);_.useEffect(()=>{p(""),y(!1)},[c]),_.useEffect(()=>{var P;if(m)return;const M=(P=C.data)==null?void 0:P.agents.worker;if(!M)return;const D=`${M.providerId||"official"}::${M.model}`;S.some(I=>`${I.providerId}::${I.model}`===D)&&p(D)},[C.data,S,m]),_.useEffect(()=>{if(v)return;const M=D=>{D.key==="Escape"&&(D.preventDefault(),e())};return window.addEventListener("keydown",M),()=>window.removeEventListener("keydown",M)},[e,v]);const T=async()=>{if(!b){x(!0);try{const[M,D]=f?f.split("::"):[void 0,void 0];t({title:i.trim()||void 0,cwd:r.trim()||void 0,agentKind:c,model:D,providerId:M})}finally{x(!1)}}};return d.jsxs("div",{className:"fixed inset-0 z-40 flex items-center justify-center bg-[rgba(45,55,72,0.4)] p-4",role:"presentation",children:[d.jsxs("div",{className:"nb-card bg-[var(--color-bg)] max-w-md w-full p-5",role:"dialog","aria-modal":"true","aria-label":n("chat.newSession.title.aria"),children:[d.jsxs("header",{className:"flex items-center justify-between mb-4",children:[d.jsx("h2",{className:"font-[family-name:var(--font-heading)] font-bold text-lg",children:n("chat.newSession.title")}),d.jsx("button",{type:"button",className:"p-1 hover:bg-[var(--surface-control-hover)] rounded",onClick:e,"aria-label":n("chat.newSession.close.aria"),children:d.jsx(En,{size:16,strokeWidth:3})})]}),d.jsxs("div",{className:"flex flex-col gap-4",children:[d.jsxs("div",{children:[d.jsx("span",{className:"block text-xs font-bold mb-1.5 uppercase tracking-wider",children:n("chat.newSession.field.agent")}),d.jsx("div",{className:"flex gap-2",role:"group","aria-label":n("chat.newSession.field.agent"),children:["claude","openai"].map(M=>d.jsx("button",{type:"button",onClick:()=>u(M),"aria-pressed":c===M,className:["flex-1 px-3 py-1.5 rounded-lg border-2 text-sm font-bold capitalize transition-all",c===M?"bg-[var(--color-accent-mint)] border-[var(--color-text)] shadow-[2px_2px_0_var(--color-text)]":"bg-[var(--color-bg)] border-[var(--color-border-light)] hover:border-[var(--color-text)]"].join(" "),children:M},M))})]}),d.jsxs("div",{children:[d.jsx("label",{htmlFor:"new-session-model",className:"block text-xs font-bold mb-1.5 uppercase tracking-wider",children:n("chat.newSession.field.model")}),d.jsxs("select",{id:"new-session-model",className:"nb-input w-full font-[family-name:var(--font-mono)] text-sm",value:f,onChange:M=>{y(!0),p(M.target.value)},children:[d.jsx("option",{value:"",children:n("chat.newSession.field.model.default")}),S.map(M=>d.jsx("option",{value:`${M.providerId}::${M.model}`,children:M.label},`${M.providerId}::${M.model}`))]})]}),d.jsxs("div",{children:[d.jsx("label",{htmlFor:"new-session-title",className:"block text-xs font-bold mb-1.5 uppercase tracking-wider",children:n("chat.newSession.field.title")}),d.jsx("input",{id:"new-session-title",type:"text",className:"nb-input w-full",placeholder:n("chat.newSession.field.title.placeholder"),value:i,onChange:M=>s(M.target.value),autoFocus:!0})]}),d.jsxs("div",{children:[d.jsx("label",{htmlFor:"new-session-cwd",className:"block text-xs font-bold mb-1.5 uppercase tracking-wider",children:n("chat.newSession.field.cwd")}),d.jsxs("div",{className:"flex gap-2",children:[d.jsx("input",{id:"new-session-cwd",type:"text",className:"nb-input flex-1 font-[family-name:var(--font-mono)] text-sm",placeholder:"/home/coral/projects/my-app",value:r,onChange:M=>o(M.target.value)}),d.jsxs("button",{type:"button",className:"nb-btn flex-shrink-0",onClick:()=>w(!0),"aria-label":n("chat.newSession.field.cwd.browseAria"),title:n("chat.newSession.field.cwd.browseAria"),children:[d.jsx(Xv,{size:14,strokeWidth:2.5}),n("chat.newSession.field.cwd.browse")]})]}),d.jsxs("p",{className:"text-[11px] text-[var(--color-text-muted)] mt-1.5 leading-relaxed",children:[d.jsx(Pj,{size:10,strokeWidth:2.5,className:"inline mr-1 -mt-0.5"}),n("chat.newSession.field.cwd.help1")," ",n("chat.newSession.field.cwd.help2")]})]}),d.jsxs("div",{className:"flex gap-2 justify-end pt-2",children:[d.jsx("button",{type:"button",className:"nb-btn",onClick:e,children:n("chat.newSession.cancel")}),d.jsxs("button",{type:"button",className:"nb-btn nb-btn-primary",onClick:T,disabled:b,children:[b?d.jsx(mt,{size:14,strokeWidth:3,className:"animate-spin"}):d.jsx(Gn,{size:14,strokeWidth:3}),n("chat.newSession.create")]})]})]})]}),v&&d.jsx(T1,{initialPath:r.trim()||void 0,onCancel:()=>w(!1),onSelect:M=>{o(M),w(!1)}})]})}const GR=_.createContext({});function pY(e){const t=_.useRef(null);return t.current===null&&(t.current=e()),t.current}const mY=typeof window<"u",gY=mY?_.useLayoutEffect:_.useEffect,A1=_.createContext(null);function j1(e,t){e.indexOf(t)===-1&&e.push(t)}function am(e,t){const n=e.indexOf(t);n>-1&&e.splice(n,1)}const Nr=(e,t,n)=>n>t?t:n<e?e:n;let M1=()=>{};const oo={},WR=e=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(e),YR=e=>typeof e=="object"&&e!==null,XR=e=>/^0[^.\s]+$/u.test(e);function QR(e){let t;return()=>(t===void 0&&(t=e()),t)}const Cs=e=>e,vf=(...e)=>e.reduce((t,n)=>i=>n(t(i))),Bd=(e,t,n)=>{const i=t-e;return i?(n-e)/i:1};class R1{constructor(){this.subscriptions=[]}add(t){return j1(this.subscriptions,t),()=>am(this.subscriptions,t)}notify(t,n,i){const s=this.subscriptions.length;if(s)if(s===1)this.subscriptions[0](t,n,i);else for(let r=0;r<s;r++){const o=this.subscriptions[r];o&&o(t,n,i)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}}const os=e=>e*1e3,_s=e=>e/1e3,ZR=(e,t)=>t?e*(1e3/t):0,JR=(e,t,n)=>(((1-3*n+3*t)*e+(3*n-6*t))*e+3*t)*e,yY=1e-7,bY=12;function xY(e,t,n,i,s){let r,o,c=0;do o=t+(n-t)/2,r=JR(o,i,s)-e,r>0?n=o:t=o;while(Math.abs(r)>yY&&++c<bY);return o}function wf(e,t,n,i){if(e===t&&n===i)return Cs;const s=r=>xY(r,0,1,e,n);return r=>r===0||r===1?r:JR(s(r),t,i)}const eD=e=>t=>t<=.5?e(2*t)/2:(2-e(2*(1-t)))/2,tD=e=>t=>1-e(1-t),nD=wf(.33,1.53,.69,.99),D1=tD(nD),iD=eD(D1),sD=e=>e>=1?1:(e*=2)<1?.5*D1(e):.5*(2-Math.pow(2,-10*(e-1))),O1=e=>1-Math.sin(Math.acos(e)),rD=tD(O1),aD=eD(O1),vY=wf(.42,0,1,1),wY=wf(0,0,.58,1),oD=wf(.42,0,.58,1),EY=e=>Array.isArray(e)&&typeof e[0]!="number",lD=e=>Array.isArray(e)&&typeof e[0]=="number",kY={linear:Cs,easeIn:vY,easeInOut:oD,easeOut:wY,circIn:O1,circInOut:aD,circOut:rD,backIn:D1,backInOut:iD,backOut:nD,anticipate:sD},SY=e=>typeof e=="string",M2=e=>{if(lD(e)){M1(e.length===4);const[t,n,i,s]=e;return wf(t,n,i,s)}else if(SY(e))return kY[e];return e},ep=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function NY(e){let t=new Set,n=new Set,i=!1,s=!1;const r=new WeakSet;let o={delta:0,timestamp:0,isProcessing:!1};function c(f){r.has(f)&&(u.schedule(f),e()),f(o)}const u={schedule:(f,p=!1,m=!1)=>{const b=m&&i?t:n;return p&&r.add(f),b.add(f),f},cancel:f=>{n.delete(f),r.delete(f)},process:f=>{if(o=f,i){s=!0;return}i=!0;const p=t;t=n,n=p,t.forEach(c),t.clear(),i=!1,s&&(s=!1,u.process(f))}};return u}const _Y=40;function cD(e,t){let n=!1,i=!0;const s={delta:0,timestamp:0,isProcessing:!1},r=()=>n=!0,o=ep.reduce((S,T)=>(S[T]=NY(r),S),{}),{setup:c,read:u,resolveKeyframes:f,preUpdate:p,update:m,preRender:y,render:b,postRender:x}=o,v=()=>{const S=oo.useManualTiming,T=S?s.timestamp:performance.now();n=!1,S||(s.delta=i?1e3/60:Math.max(Math.min(T-s.timestamp,_Y),1)),s.timestamp=T,s.isProcessing=!0,c.process(s),u.process(s),f.process(s),p.process(s),m.process(s),y.process(s),b.process(s),x.process(s),s.isProcessing=!1,n&&t&&(i=!1,e(v))},w=()=>{n=!0,i=!0,s.isProcessing||e(v)};return{schedule:ep.reduce((S,T)=>{const A=o[T];return S[T]=(j,M=!1,D=!1)=>(n||w(),A.schedule(j,M,D)),S},{}),cancel:S=>{for(let T=0;T<ep.length;T++)o[ep[T]].cancel(S)},state:s,steps:o}}const{schedule:un,cancel:lo,state:mi,steps:rx}=cD(typeof requestAnimationFrame<"u"?requestAnimationFrame:Cs,!0);let jp;function CY(){jp=void 0}const Mi={now:()=>(jp===void 0&&Mi.set(mi.isProcessing||oo.useManualTiming?mi.timestamp:performance.now()),jp),set:e=>{jp=e,queueMicrotask(CY)}},uD=e=>t=>typeof t=="string"&&t.startsWith(e),dD=uD("--"),TY=uD("var(--"),L1=e=>TY(e)?AY.test(e.split("/*")[0].trim()):!1,AY=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function R2(e){return typeof e!="string"?!1:e.split("/*")[0].includes("var(--")}const iu={test:e=>typeof e=="number",parse:parseFloat,transform:e=>e},Ud={...iu,transform:e=>Nr(0,1,e)},tp={...iu,default:1},_d=e=>Math.round(e*1e5)/1e5,I1=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function jY(e){return e==null}const MY=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,P1=(e,t)=>n=>!!(typeof n=="string"&&MY.test(n)&&n.startsWith(e)||t&&!jY(n)&&Object.prototype.hasOwnProperty.call(n,t)),fD=(e,t,n)=>i=>{if(typeof i!="string")return i;const[s,r,o,c]=i.match(I1);return{[e]:parseFloat(s),[t]:parseFloat(r),[n]:parseFloat(o),alpha:c!==void 0?parseFloat(c):1}},RY=e=>Nr(0,255,e),ax={...iu,transform:e=>Math.round(RY(e))},qo={test:P1("rgb","red"),parse:fD("red","green","blue"),transform:({red:e,green:t,blue:n,alpha:i=1})=>"rgba("+ax.transform(e)+", "+ax.transform(t)+", "+ax.transform(n)+", "+_d(Ud.transform(i))+")"};function DY(e){let t="",n="",i="",s="";return e.length>5?(t=e.substring(1,3),n=e.substring(3,5),i=e.substring(5,7),s=e.substring(7,9)):(t=e.substring(1,2),n=e.substring(2,3),i=e.substring(3,4),s=e.substring(4,5),t+=t,n+=n,i+=i,s+=s),{red:parseInt(t,16),green:parseInt(n,16),blue:parseInt(i,16),alpha:s?parseInt(s,16)/255:1}}const z0={test:P1("#"),parse:DY,transform:qo.transform},Ef=e=>({test:t=>typeof t=="string"&&t.endsWith(e)&&t.split(" ").length===1,parse:parseFloat,transform:t=>`${t}${e}`}),Jr=Ef("deg"),Er=Ef("%"),Ge=Ef("px"),OY=Ef("vh"),LY=Ef("vw"),D2={...Er,parse:e=>Er.parse(e)/100,transform:e=>Er.transform(e*100)},dc={test:P1("hsl","hue"),parse:fD("hue","saturation","lightness"),transform:({hue:e,saturation:t,lightness:n,alpha:i=1})=>"hsla("+Math.round(e)+", "+Er.transform(_d(t))+", "+Er.transform(_d(n))+", "+_d(Ud.transform(i))+")"},Kn={test:e=>qo.test(e)||z0.test(e)||dc.test(e),parse:e=>qo.test(e)?qo.parse(e):dc.test(e)?dc.parse(e):z0.parse(e),transform:e=>typeof e=="string"?e:e.hasOwnProperty("red")?qo.transform(e):dc.transform(e),getAnimatableNone:e=>{const t=Kn.parse(e);return t.alpha=0,Kn.transform(t)}},IY=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function PY(e){var t,n;return isNaN(e)&&typeof e=="string"&&(((t=e.match(I1))==null?void 0:t.length)||0)+(((n=e.match(IY))==null?void 0:n.length)||0)>0}const hD="number",pD="color",zY="var",BY="var(",O2="${}",UY=/var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)/giu;function $c(e){const t=e.toString(),n=[],i={color:[],number:[],var:[]},s=[];let r=0;const c=t.replace(UY,u=>(Kn.test(u)?(i.color.push(r),s.push(pD),n.push(Kn.parse(u))):u.startsWith(BY)?(i.var.push(r),s.push(zY),n.push(u)):(i.number.push(r),s.push(hD),n.push(parseFloat(u))),++r,O2)).split(O2);return{values:n,split:c,indexes:i,types:s}}function FY(e){return $c(e).values}function mD({split:e,types:t}){const n=e.length;return i=>{let s="";for(let r=0;r<n;r++)if(s+=e[r],i[r]!==void 0){const o=t[r];o===hD?s+=_d(i[r]):o===pD?s+=Kn.transform(i[r]):s+=i[r]}return s}}function $Y(e){return mD($c(e))}const qY=e=>typeof e=="number"?0:Kn.test(e)?Kn.getAnimatableNone(e):e,HY=(e,t)=>typeof e=="number"?t!=null&&t.trim().endsWith("/")?e:0:qY(e);function VY(e){const t=$c(e);return mD(t)(t.values.map((i,s)=>HY(i,t.split[s])))}const er={test:PY,parse:FY,createTransformer:$Y,getAnimatableNone:VY};function ox(e,t,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*(2/3-n)*6:e}function KY({hue:e,saturation:t,lightness:n,alpha:i}){e/=360,t/=100,n/=100;let s=0,r=0,o=0;if(!t)s=r=o=n;else{const c=n<.5?n*(1+t):n+t-n*t,u=2*n-c;s=ox(u,c,e+1/3),r=ox(u,c,e),o=ox(u,c,e-1/3)}return{red:Math.round(s*255),green:Math.round(r*255),blue:Math.round(o*255),alpha:i}}function om(e,t){return n=>n>0?t:e}const cn=(e,t,n)=>e+(t-e)*n,lx=(e,t,n)=>{const i=e*e,s=n*(t*t-i)+i;return s<0?0:Math.sqrt(s)},GY=[z0,qo,dc],WY=e=>GY.find(t=>t.test(e));function L2(e){const t=WY(e);if(!t)return!1;let n=t.parse(e);return t===dc&&(n=KY(n)),n}const I2=(e,t)=>{const n=L2(e),i=L2(t);if(!n||!i)return om(e,t);const s={...n};return r=>(s.red=lx(n.red,i.red,r),s.green=lx(n.green,i.green,r),s.blue=lx(n.blue,i.blue,r),s.alpha=cn(n.alpha,i.alpha,r),qo.transform(s))},B0=new Set(["none","hidden"]);function YY(e,t){return B0.has(e)?n=>n<=0?e:t:n=>n>=1?t:e}function XY(e,t){return n=>cn(e,t,n)}function z1(e){return typeof e=="number"?XY:typeof e=="string"?L1(e)?om:Kn.test(e)?I2:JY:Array.isArray(e)?gD:typeof e=="object"?Kn.test(e)?I2:QY:om}function gD(e,t){const n=[...e],i=n.length,s=e.map((r,o)=>z1(r)(r,t[o]));return r=>{for(let o=0;o<i;o++)n[o]=s[o](r);return n}}function QY(e,t){const n={...e,...t},i={};for(const s in n)e[s]!==void 0&&t[s]!==void 0&&(i[s]=z1(e[s])(e[s],t[s]));return s=>{for(const r in i)n[r]=i[r](s);return n}}function ZY(e,t){const n=[],i={color:0,var:0,number:0};for(let s=0;s<t.values.length;s++){const r=t.types[s],o=e.indexes[r][i[r]],c=e.values[o]??0;n[s]=c,i[r]++}return n}const JY=(e,t)=>{const n=er.createTransformer(t),i=$c(e),s=$c(t);return i.indexes.var.length===s.indexes.var.length&&i.indexes.color.length===s.indexes.color.length&&i.indexes.number.length>=s.indexes.number.length?B0.has(e)&&!s.values.length||B0.has(t)&&!i.values.length?YY(e,t):vf(gD(ZY(i,s),s.values),n):om(e,t)};function yD(e,t,n){return typeof e=="number"&&typeof t=="number"&&typeof n=="number"?cn(e,t,n):z1(e)(e,t)}const eX=e=>{const t=({timestamp:n})=>e(n);return{start:(n=!0)=>un.update(t,n),stop:()=>lo(t),now:()=>mi.isProcessing?mi.timestamp:Mi.now()}},bD=(e,t,n=10)=>{let i="";const s=Math.max(Math.round(t/n),2);for(let r=0;r<s;r++)i+=Math.round(e(r/(s-1))*1e4)/1e4+", ";return`linear(${i.substring(0,i.length-2)})`},lm=2e4;function B1(e){let t=0;const n=50;let i=e.next(t);for(;!i.done&&t<lm;)t+=n,i=e.next(t);return t>=lm?1/0:t}function tX(e,t=100,n){const i=n({...e,keyframes:[0,t]}),s=Math.min(B1(i),lm);return{type:"keyframes",ease:r=>i.next(s*r).value/t,duration:_s(s)}}const Ln={stiffness:100,damping:10,mass:1,velocity:0,duration:800,bounce:.3,visualDuration:.3,restSpeed:{granular:.01,default:2},restDelta:{granular:.005,default:.5},minDuration:.01,maxDuration:10,minDamping:.05,maxDamping:1};function U0(e,t){return e*Math.sqrt(1-t*t)}const nX=12;function iX(e,t,n){let i=n;for(let s=1;s<nX;s++)i=i-e(i)/t(i);return i}const cx=.001;function sX({duration:e=Ln.duration,bounce:t=Ln.bounce,velocity:n=Ln.velocity,mass:i=Ln.mass}){let s,r,o=1-t;o=Nr(Ln.minDamping,Ln.maxDamping,o),e=Nr(Ln.minDuration,Ln.maxDuration,_s(e)),o<1?(s=f=>{const p=f*o,m=p*e,y=p-n,b=U0(f,o),x=Math.exp(-m);return cx-y/b*x},r=f=>{const m=f*o*e,y=m*n+n,b=Math.pow(o,2)*Math.pow(f,2)*e,x=Math.exp(-m),v=U0(Math.pow(f,2),o);return(-s(f)+cx>0?-1:1)*((y-b)*x)/v}):(s=f=>{const p=Math.exp(-f*e),m=(f-n)*e+1;return-cx+p*m},r=f=>{const p=Math.exp(-f*e),m=(n-f)*(e*e);return p*m});const c=5/e,u=iX(s,r,c);if(e=os(e),isNaN(u))return{stiffness:Ln.stiffness,damping:Ln.damping,duration:e};{const f=Math.pow(u,2)*i;return{stiffness:f,damping:o*2*Math.sqrt(i*f),duration:e}}}const rX=["duration","bounce"],aX=["stiffness","damping","mass"];function P2(e,t){return t.some(n=>e[n]!==void 0)}function oX(e){let t={velocity:Ln.velocity,stiffness:Ln.stiffness,damping:Ln.damping,mass:Ln.mass,isResolvedFromDuration:!1,...e};if(!P2(e,aX)&&P2(e,rX))if(t.velocity=0,e.visualDuration){const n=e.visualDuration,i=2*Math.PI/(n*1.2),s=i*i,r=2*Nr(.05,1,1-(e.bounce||0))*Math.sqrt(s);t={...t,mass:Ln.mass,stiffness:s,damping:r}}else{const n=sX({...e,velocity:0});t={...t,...n,mass:Ln.mass},t.isResolvedFromDuration=!0}return t}function cm(e=Ln.visualDuration,t=Ln.bounce){const n=typeof e!="object"?{visualDuration:e,keyframes:[0,1],bounce:t}:e;let{restSpeed:i,restDelta:s}=n;const r=n.keyframes[0],o=n.keyframes[n.keyframes.length-1],c={done:!1,value:r},{stiffness:u,damping:f,mass:p,duration:m,velocity:y,isResolvedFromDuration:b}=oX({...n,velocity:-_s(n.velocity||0)}),x=y||0,v=f/(2*Math.sqrt(u*p)),w=o-r,k=_s(Math.sqrt(u/p)),C=Math.abs(w)<5;i||(i=C?Ln.restSpeed.granular:Ln.restSpeed.default),s||(s=C?Ln.restDelta.granular:Ln.restDelta.default);let S,T,A,j,M,D;if(v<1)A=U0(k,v),j=(x+v*k*w)/A,S=I=>{const B=Math.exp(-v*k*I);return o-B*(j*Math.sin(A*I)+w*Math.cos(A*I))},M=v*k*j+w*A,D=v*k*w-j*A,T=I=>Math.exp(-v*k*I)*(M*Math.sin(A*I)+D*Math.cos(A*I));else if(v===1){S=B=>o-Math.exp(-k*B)*(w+(x+k*w)*B);const I=x+k*w;T=B=>Math.exp(-k*B)*(k*I*B-x)}else{const I=k*Math.sqrt(v*v-1);S=R=>{const O=Math.exp(-v*k*R),z=Math.min(I*R,300);return o-O*((x+v*k*w)*Math.sinh(z)+I*w*Math.cosh(z))/I};const B=(x+v*k*w)/I,q=v*k*B-w*I,G=v*k*w-B*I;T=R=>{const O=Math.exp(-v*k*R),z=Math.min(I*R,300);return O*(q*Math.sinh(z)+G*Math.cosh(z))}}const P={calculatedDuration:b&&m||null,velocity:I=>os(T(I)),next:I=>{if(!b&&v<1){const q=Math.exp(-v*k*I),G=Math.sin(A*I),R=Math.cos(A*I),O=o-q*(j*G+w*R),z=os(q*(M*G+D*R));return c.done=Math.abs(z)<=i&&Math.abs(o-O)<=s,c.value=c.done?o:O,c}const B=S(I);if(b)c.done=I>=m;else{const q=os(T(I));c.done=Math.abs(q)<=i&&Math.abs(o-B)<=s}return c.value=c.done?o:B,c},toString:()=>{const I=Math.min(B1(P),lm),B=bD(q=>P.next(I*q).value,I,30);return I+"ms "+B},toTransition:()=>{}};return P}cm.applyToOptions=e=>{const t=tX(e,100,cm);return e.ease=t.ease,e.duration=os(t.duration),e.type="keyframes",e};const lX=5;function xD(e,t,n){const i=Math.max(t-lX,0);return ZR(n-e(i),t-i)}function F0({keyframes:e,velocity:t=0,power:n=.8,timeConstant:i=325,bounceDamping:s=10,bounceStiffness:r=500,modifyTarget:o,min:c,max:u,restDelta:f=.5,restSpeed:p}){const m=e[0],y={done:!1,value:m},b=D=>c!==void 0&&D<c||u!==void 0&&D>u,x=D=>c===void 0?u:u===void 0||Math.abs(c-D)<Math.abs(u-D)?c:u;let v=n*t;const w=m+v,k=o===void 0?w:o(w);k!==w&&(v=k-m);const C=D=>-v*Math.exp(-D/i),S=D=>k+C(D),T=D=>{const P=C(D),I=S(D);y.done=Math.abs(P)<=f,y.value=y.done?k:I};let A,j;const M=D=>{b(y.value)&&(A=D,j=cm({keyframes:[y.value,x(y.value)],velocity:xD(S,D,y.value),damping:s,stiffness:r,restDelta:f,restSpeed:p}))};return M(0),{calculatedDuration:null,next:D=>{let P=!1;return!j&&A===void 0&&(P=!0,T(D),M(D)),A!==void 0&&D>=A?j.next(D-A):(!P&&T(D),y)}}}function cX(e,t,n){const i=[],s=n||oo.mix||yD,r=e.length-1;for(let o=0;o<r;o++){let c=s(e[o],e[o+1]);if(t){const u=Array.isArray(t)?t[o]||Cs:t;c=vf(u,c)}i.push(c)}return i}function uX(e,t,{clamp:n=!0,ease:i,mixer:s}={}){const r=e.length;if(M1(r===t.length),r===1)return()=>t[0];if(r===2&&t[0]===t[1])return()=>t[1];const o=e[0]===e[1];e[0]>e[r-1]&&(e=[...e].reverse(),t=[...t].reverse());const c=cX(t,i,s),u=c.length,f=p=>{if(o&&p<e[0])return t[0];let m=0;if(u>1)for(;m<e.length-2&&!(p<e[m+1]);m++);const y=Bd(e[m],e[m+1],p);return c[m](y)};return n?p=>f(Nr(e[0],e[r-1],p)):f}function dX(e,t){const n=e[e.length-1];for(let i=1;i<=t;i++){const s=Bd(0,t,i);e.push(cn(n,1,s))}}function fX(e){const t=[0];return dX(t,e.length-1),t}function hX(e,t){return e.map(n=>n*t)}function pX(e,t){return e.map(()=>t||oD).splice(0,e.length-1)}function Cd({duration:e=300,keyframes:t,times:n,ease:i="easeInOut"}){const s=EY(i)?i.map(M2):M2(i),r={done:!1,value:t[0]},o=hX(n&&n.length===t.length?n:fX(t),e),c=uX(o,t,{ease:Array.isArray(s)?s:pX(t,s)});return{calculatedDuration:e,next:u=>(r.value=c(u),r.done=u>=e,r)}}const mX=e=>e!==null;function qm(e,{repeat:t,repeatType:n="loop"},i,s=1){const r=e.filter(mX),c=s<0||t&&n!=="loop"&&t%2===1?0:r.length-1;return!c||i===void 0?r[c]:i}const gX={decay:F0,inertia:F0,tween:Cd,keyframes:Cd,spring:cm};function vD(e){typeof e.type=="string"&&(e.type=gX[e.type])}class U1{constructor(){this.updateFinished()}get finished(){return this._finished}updateFinished(){this._finished=new Promise(t=>{this.resolve=t})}notifyFinished(){this.resolve()}then(t,n){return this.finished.then(t,n)}}const yX=e=>e/100;class um extends U1{constructor(t){super(),this.state="idle",this.startTime=null,this.isStopped=!1,this.currentTime=0,this.holdTime=null,this.playbackSpeed=1,this.delayState={done:!1,value:void 0},this.stop=()=>{var i,s;const{motionValue:n}=this.options;n&&n.updatedAt!==Mi.now()&&this.tick(Mi.now()),this.isStopped=!0,this.state!=="idle"&&(this.teardown(),(s=(i=this.options).onStop)==null||s.call(i))},this.options=t,this.initAnimation(),this.play(),t.autoplay===!1&&this.pause()}initAnimation(){const{options:t}=this;vD(t);const{type:n=Cd,repeat:i=0,repeatDelay:s=0,repeatType:r,velocity:o=0}=t;let{keyframes:c}=t;const u=n||Cd;u!==Cd&&typeof c[0]!="number"&&(this.mixKeyframes=vf(yX,yD(c[0],c[1])),c=[0,100]);const f=u({...t,keyframes:c});r==="mirror"&&(this.mirroredGenerator=u({...t,keyframes:[...c].reverse(),velocity:-o})),f.calculatedDuration===null&&(f.calculatedDuration=B1(f));const{calculatedDuration:p}=f;this.calculatedDuration=p,this.resolvedDuration=p+s,this.totalDuration=this.resolvedDuration*(i+1)-s,this.generator=f}updateTime(t){const n=Math.round(t-this.startTime)*this.playbackSpeed;this.holdTime!==null?this.currentTime=this.holdTime:this.currentTime=n}tick(t,n=!1){const{generator:i,totalDuration:s,mixKeyframes:r,mirroredGenerator:o,resolvedDuration:c,calculatedDuration:u}=this;if(this.startTime===null)return i.next(0);const{delay:f=0,keyframes:p,repeat:m,repeatType:y,repeatDelay:b,type:x,onUpdate:v,finalKeyframe:w}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,t):this.speed<0&&(this.startTime=Math.min(t-s/this.speed,this.startTime)),n?this.currentTime=t:this.updateTime(t);const k=this.currentTime-f*(this.playbackSpeed>=0?1:-1),C=this.playbackSpeed>=0?k<0:k>s;this.currentTime=Math.max(k,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=s);let S=this.currentTime,T=i;if(m){const D=Math.min(this.currentTime,s)/c;let P=Math.floor(D),I=D%1;!I&&D>=1&&(I=1),I===1&&P--,P=Math.min(P,m+1),!!(P%2)&&(y==="reverse"?(I=1-I,b&&(I-=b/c)):y==="mirror"&&(T=o)),S=Nr(0,1,I)*c}let A;C?(this.delayState.value=p[0],A=this.delayState):A=T.next(S),r&&!C&&(A.value=r(A.value));let{done:j}=A;!C&&u!==null&&(j=this.playbackSpeed>=0?this.currentTime>=s:this.currentTime<=0);const M=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&j);return M&&x!==F0&&(A.value=qm(p,this.options,w,this.speed)),v&&v(A.value),M&&this.finish(),A}then(t,n){return this.finished.then(t,n)}get duration(){return _s(this.calculatedDuration)}get iterationDuration(){const{delay:t=0}=this.options||{};return this.duration+_s(t)}get time(){return _s(this.currentTime)}set time(t){t=os(t),this.currentTime=t,this.startTime===null||this.holdTime!==null||this.playbackSpeed===0?this.holdTime=t:this.driver&&(this.startTime=this.driver.now()-t/this.playbackSpeed),this.driver?this.driver.start(!1):(this.startTime=0,this.state="paused",this.holdTime=t,this.tick(t))}getGeneratorVelocity(){const t=this.currentTime;if(t<=0)return this.options.velocity||0;if(this.generator.velocity)return this.generator.velocity(t);const n=this.generator.next(t).value;return xD(i=>this.generator.next(i).value,t,n)}get speed(){return this.playbackSpeed}set speed(t){const n=this.playbackSpeed!==t;n&&this.driver&&this.updateTime(Mi.now()),this.playbackSpeed=t,n&&this.driver&&(this.time=_s(this.currentTime))}play(){var s,r;if(this.isStopped)return;const{driver:t=eX,startTime:n}=this.options;this.driver||(this.driver=t(o=>this.tick(o))),(r=(s=this.options).onPlay)==null||r.call(s);const i=this.driver.now();this.state==="finished"?(this.updateFinished(),this.startTime=i):this.holdTime!==null?this.startTime=i-this.holdTime:this.startTime||(this.startTime=n??i),this.state==="finished"&&this.speed<0&&(this.startTime+=this.calculatedDuration),this.holdTime=null,this.state="running",this.driver.start()}pause(){this.state="paused",this.updateTime(Mi.now()),this.holdTime=this.currentTime}complete(){this.state!=="running"&&this.play(),this.state="finished",this.holdTime=null}finish(){var t,n;this.notifyFinished(),this.teardown(),this.state="finished",(n=(t=this.options).onComplete)==null||n.call(t)}cancel(){var t,n;this.holdTime=null,this.startTime=0,this.tick(0),this.teardown(),(n=(t=this.options).onCancel)==null||n.call(t)}teardown(){this.state="idle",this.stopDriver(),this.startTime=this.holdTime=null}stopDriver(){this.driver&&(this.driver.stop(),this.driver=void 0)}sample(t){return this.startTime=0,this.tick(t,!0)}attachTimeline(t){var n;return this.options.allowFlatten&&(this.options.type="keyframes",this.options.ease="linear",this.initAnimation()),(n=this.driver)==null||n.stop(),t.observe(this)}}function bX(e){for(let t=1;t<e.length;t++)e[t]??(e[t]=e[t-1])}const Ho=e=>e*180/Math.PI,$0=e=>{const t=Ho(Math.atan2(e[1],e[0]));return q0(t)},xX={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:e=>(Math.abs(e[0])+Math.abs(e[3]))/2,rotate:$0,rotateZ:$0,skewX:e=>Ho(Math.atan(e[1])),skewY:e=>Ho(Math.atan(e[2])),skew:e=>(Math.abs(e[1])+Math.abs(e[2]))/2},q0=e=>(e=e%360,e<0&&(e+=360),e),z2=$0,B2=e=>Math.sqrt(e[0]*e[0]+e[1]*e[1]),U2=e=>Math.sqrt(e[4]*e[4]+e[5]*e[5]),vX={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:B2,scaleY:U2,scale:e=>(B2(e)+U2(e))/2,rotateX:e=>q0(Ho(Math.atan2(e[6],e[5]))),rotateY:e=>q0(Ho(Math.atan2(-e[2],e[0]))),rotateZ:z2,rotate:z2,skewX:e=>Ho(Math.atan(e[4])),skewY:e=>Ho(Math.atan(e[1])),skew:e=>(Math.abs(e[1])+Math.abs(e[4]))/2};function H0(e){return e.includes("scale")?1:0}function V0(e,t){if(!e||e==="none")return H0(t);const n=e.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let i,s;if(n)i=vX,s=n;else{const c=e.match(/^matrix\(([-\d.e\s,]+)\)$/u);i=xX,s=c}if(!s)return H0(t);const r=i[t],o=s[1].split(",").map(EX);return typeof r=="function"?r(o):o[r]}const wX=(e,t)=>{const{transform:n="none"}=getComputedStyle(e);return V0(n,t)};function EX(e){return parseFloat(e.trim())}const su=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],ru=new Set([...su,"pathRotation"]),F2=e=>e===iu||e===Ge,kX=new Set(["x","y","z"]),SX=su.filter(e=>!kX.has(e));function NX(e){const t=[];return SX.forEach(n=>{const i=e.getValue(n);i!==void 0&&(t.push([n,i.get()]),i.set(n.startsWith("scale")?1:0))}),t}const to={width:({x:e},{paddingLeft:t="0",paddingRight:n="0",boxSizing:i})=>{const s=e.max-e.min;return i==="border-box"?s:s-parseFloat(t)-parseFloat(n)},height:({y:e},{paddingTop:t="0",paddingBottom:n="0",boxSizing:i})=>{const s=e.max-e.min;return i==="border-box"?s:s-parseFloat(t)-parseFloat(n)},top:(e,{top:t})=>parseFloat(t),left:(e,{left:t})=>parseFloat(t),bottom:({y:e},{top:t})=>parseFloat(t)+(e.max-e.min),right:({x:e},{left:t})=>parseFloat(t)+(e.max-e.min),x:(e,{transform:t})=>V0(t,"x"),y:(e,{transform:t})=>V0(t,"y")};to.translateX=to.x;to.translateY=to.y;const sl=new Set;let K0=!1,G0=!1,W0=!1;function wD(){if(G0){const e=Array.from(sl).filter(i=>i.needsMeasurement),t=new Set(e.map(i=>i.element)),n=new Map;t.forEach(i=>{const s=NX(i);s.length&&(n.set(i,s),i.render())}),e.forEach(i=>i.measureInitialState()),t.forEach(i=>{i.render();const s=n.get(i);s&&s.forEach(([r,o])=>{var c;(c=i.getValue(r))==null||c.set(o)})}),e.forEach(i=>i.measureEndState()),e.forEach(i=>{i.suspendedScrollY!==void 0&&window.scrollTo(0,i.suspendedScrollY)})}G0=!1,K0=!1,sl.forEach(e=>e.complete(W0)),sl.clear()}function ED(){sl.forEach(e=>{e.readKeyframes(),e.needsMeasurement&&(G0=!0)})}function _X(){W0=!0,ED(),wD(),W0=!1}class F1{constructor(t,n,i,s,r,o=!1){this.state="pending",this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...t],this.onComplete=n,this.name=i,this.motionValue=s,this.element=r,this.isAsync=o}scheduleResolve(){this.state="scheduled",this.isAsync?(sl.add(this),K0||(K0=!0,un.read(ED),un.resolveKeyframes(wD))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:t,name:n,element:i,motionValue:s}=this;if(t[0]===null){const r=s==null?void 0:s.get(),o=t[t.length-1];if(r!==void 0)t[0]=r;else if(i&&n){const c=i.readValue(n,o);c!=null&&(t[0]=c)}t[0]===void 0&&(t[0]=o),s&&r===void 0&&s.set(t[0])}bX(t)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(t=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,t),sl.delete(this)}cancel(){this.state==="scheduled"&&(sl.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const CX=e=>e.startsWith("--");function kD(e,t,n){CX(t)?e.style.setProperty(t,n):e.style[t]=n}const TX={};function SD(e,t){const n=QR(e);return()=>TX[t]??n()}const AX=SD(()=>window.ScrollTimeline!==void 0,"scrollTimeline"),ND=SD(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),md=([e,t,n,i])=>`cubic-bezier(${e}, ${t}, ${n}, ${i})`,$2={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:md([0,.65,.55,1]),circOut:md([.55,0,1,.45]),backIn:md([.31,.01,.66,-.59]),backOut:md([.33,1.53,.69,.99])};function _D(e,t){if(e)return typeof e=="function"?ND()?bD(e,t):"ease-out":lD(e)?md(e):Array.isArray(e)?e.map(n=>_D(n,t)||$2.easeOut):$2[e]}function jX(e,t,n,{delay:i=0,duration:s=300,repeat:r=0,repeatType:o="loop",ease:c="easeOut",times:u}={},f=void 0){const p={[t]:n};u&&(p.offset=u);const m=_D(c,s);Array.isArray(m)&&(p.easing=m);const y={delay:i,duration:s,easing:Array.isArray(m)?"linear":m,fill:"both",iterations:r+1,direction:o==="reverse"?"alternate":"normal"};return f&&(y.pseudoElement=f),e.animate(p,y)}function CD(e){return typeof e=="function"&&"applyToOptions"in e}function MX({type:e,...t}){return CD(e)&&ND()?e.applyToOptions(t):(t.duration??(t.duration=300),t.ease??(t.ease="easeOut"),t)}class TD extends U1{constructor(t){if(super(),this.finishedTime=null,this.isStopped=!1,this.manualStartTime=null,!t)return;const{element:n,name:i,keyframes:s,pseudoElement:r,allowFlatten:o=!1,finalKeyframe:c,onComplete:u}=t;this.isPseudoElement=!!r,this.allowFlatten=o,this.options=t,M1(typeof t.type!="string");const f=MX(t);this.animation=jX(n,i,s,f,r),f.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!r){const p=qm(s,this.options,c,this.speed);this.updateMotionValue&&this.updateMotionValue(p),kD(n,i,p),this.animation.cancel()}u==null||u(),this.notifyFinished()}}play(){this.isStopped||(this.manualStartTime=null,this.animation.play(),this.state==="finished"&&this.updateFinished())}pause(){this.animation.pause()}complete(){var t,n;(n=(t=this.animation).finish)==null||n.call(t)}cancel(){try{this.animation.cancel()}catch{}}stop(){if(this.isStopped)return;this.isStopped=!0;const{state:t}=this;t==="idle"||t==="finished"||(this.updateMotionValue?this.updateMotionValue():this.commitStyles(),this.isPseudoElement||this.cancel())}commitStyles(){var n,i,s;const t=(n=this.options)==null?void 0:n.element;!this.isPseudoElement&&(t!=null&&t.isConnected)&&((s=(i=this.animation).commitStyles)==null||s.call(i))}get duration(){var n,i;const t=((i=(n=this.animation.effect)==null?void 0:n.getComputedTiming)==null?void 0:i.call(n).duration)||0;return _s(Number(t))}get iterationDuration(){const{delay:t=0}=this.options||{};return this.duration+_s(t)}get time(){return _s(Number(this.animation.currentTime)||0)}set time(t){const n=this.finishedTime!==null;this.manualStartTime=null,this.finishedTime=null,this.animation.currentTime=os(t),n&&this.animation.pause()}get speed(){return this.animation.playbackRate}set speed(t){t<0&&(this.finishedTime=null),this.animation.playbackRate=t}get state(){return this.finishedTime!==null?"finished":this.animation.playState}get startTime(){return this.manualStartTime??Number(this.animation.startTime)}set startTime(t){this.manualStartTime=this.animation.startTime=t}attachTimeline({timeline:t,rangeStart:n,rangeEnd:i,observe:s}){var r;return this.allowFlatten&&((r=this.animation.effect)==null||r.updateTiming({easing:"linear"})),this.animation.onfinish=null,t&&AX()?(this.animation.timeline=t,n&&(this.animation.rangeStart=n),i&&(this.animation.rangeEnd=i),Cs):s(this)}}const AD={anticipate:sD,backInOut:iD,circInOut:aD};function RX(e){return e in AD}function DX(e){typeof e.ease=="string"&&RX(e.ease)&&(e.ease=AD[e.ease])}const ux=10;class OX extends TD{constructor(t){DX(t),vD(t),super(t),t.startTime!==void 0&&t.autoplay!==!1&&(this.startTime=t.startTime),this.options=t}updateMotionValue(t){const{motionValue:n,onUpdate:i,onComplete:s,element:r,...o}=this.options;if(!n)return;if(t!==void 0){n.set(t);return}const c=new um({...o,autoplay:!1}),u=Math.max(ux,Mi.now()-this.startTime),f=Nr(0,ux,u-ux),p=c.sample(u).value,{name:m}=this.options;r&&m&&kD(r,m,p),n.setWithVelocity(c.sample(Math.max(0,u-f)).value,p,f),c.stop()}}const q2=(e,t)=>t==="zIndex"?!1:!!(typeof e=="number"||Array.isArray(e)||typeof e=="string"&&(er.test(e)||e==="0")&&!e.startsWith("url("));function LX(e){const t=e[0];if(e.length===1)return!0;for(let n=0;n<e.length;n++)if(e[n]!==t)return!0}function IX(e,t,n,i){const s=e[0];if(s===null)return!1;if(t==="display"||t==="visibility")return!0;const r=e[e.length-1],o=q2(s,t),c=q2(r,t);return!o||!c?!1:LX(e)||(n==="spring"||CD(n))&&i}function Y0(e){e.duration=0,e.type="keyframes"}const jD=new Set(["opacity","clipPath","filter","transform"]),PX=/^(?:oklch|oklab|lab|lch|color|color-mix|light-dark)\(/;function zX(e){for(let t=0;t<e.length;t++)if(typeof e[t]=="string"&&PX.test(e[t]))return!0;return!1}const BX=new Set(["color","backgroundColor","outlineColor","fill","stroke","borderColor","borderTopColor","borderRightColor","borderBottomColor","borderLeftColor"]),UX=QR(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));function FX(e){var m;const{motionValue:t,name:n,repeatDelay:i,repeatType:s,damping:r,type:o,keyframes:c}=e;if(!(((m=t==null?void 0:t.owner)==null?void 0:m.current)instanceof HTMLElement))return!1;const{onUpdate:f,transformTemplate:p}=t.owner.getProps();return UX()&&n&&(jD.has(n)||BX.has(n)&&zX(c))&&(n!=="transform"||!p)&&!f&&!i&&s!=="mirror"&&r!==0&&o!=="inertia"}const $X=40;class qX extends U1{constructor({autoplay:t=!0,delay:n=0,type:i="keyframes",repeat:s=0,repeatDelay:r=0,repeatType:o="loop",keyframes:c,name:u,motionValue:f,element:p,...m}){var x;super(),this.stop=()=>{var v,w;this._animation&&(this._animation.stop(),(v=this.stopTimeline)==null||v.call(this)),(w=this.keyframeResolver)==null||w.cancel()},this.createdAt=Mi.now();const y={autoplay:t,delay:n,type:i,repeat:s,repeatDelay:r,repeatType:o,name:u,motionValue:f,element:p,...m},b=(p==null?void 0:p.KeyframeResolver)||F1;this.keyframeResolver=new b(c,(v,w,k)=>this.onKeyframesResolved(v,w,y,!k),u,f,p),(x=this.keyframeResolver)==null||x.scheduleResolve()}onKeyframesResolved(t,n,i,s){var k,C;this.keyframeResolver=void 0;const{name:r,type:o,velocity:c,delay:u,isHandoff:f,onUpdate:p}=i;this.resolvedAt=Mi.now();let m=!0;IX(t,r,o,c)||(m=!1,(oo.instantAnimations||!u)&&(p==null||p(qm(t,i,n))),t[0]=t[t.length-1],Y0(i),i.repeat=0);const b={startTime:s?this.resolvedAt?this.resolvedAt-this.createdAt>$X?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:n,...i,keyframes:t},x=m&&!f&&FX(b),v=(C=(k=b.motionValue)==null?void 0:k.owner)==null?void 0:C.current;let w;if(x)try{w=new OX({...b,element:v})}catch{w=new um(b)}else w=new um(b);w.finished.then(()=>{this.notifyFinished()}).catch(Cs),this.pendingTimeline&&(this.stopTimeline=w.attachTimeline(this.pendingTimeline),this.pendingTimeline=void 0),this._animation=w}get finished(){return this._animation?this.animation.finished:this._finished}then(t,n){return this.finished.finally(t).then(()=>{})}get animation(){var t;return this._animation||((t=this.keyframeResolver)==null||t.resume(),_X()),this._animation}get duration(){return this.animation.duration}get iterationDuration(){return this.animation.iterationDuration}get time(){return this.animation.time}set time(t){this.animation.time=t}get speed(){return this.animation.speed}get state(){return this.animation.state}set speed(t){this.animation.speed=t}get startTime(){return this.animation.startTime}attachTimeline(t){return this._animation?this.stopTimeline=this.animation.attachTimeline(t):this.pendingTimeline=t,()=>this.stop()}play(){this.animation.play()}pause(){this.animation.pause()}complete(){this.animation.complete()}cancel(){var t;this._animation&&this.animation.cancel(),(t=this.keyframeResolver)==null||t.cancel()}}function MD(e,t,n,i=0,s=1){const r=Array.from(e).sort((f,p)=>f.sortNodePosition(p)).indexOf(t),o=e.size,c=(o-1)*i;return typeof n=="function"?n(r,o):s===1?r*i:c-r*i}const H2=30,HX=e=>!isNaN(parseFloat(e));class VX{constructor(t,n={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=i=>{var r;const s=Mi.now();if(this.updatedAt!==s&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(i),this.current!==this.prev&&((r=this.events.change)==null||r.notify(this.current),this.dependents))for(const o of this.dependents)o.dirty()},this.hasAnimated=!1,this.setCurrent(t),this.owner=n.owner}setCurrent(t){this.current=t,this.updatedAt=Mi.now(),this.canTrackVelocity===null&&t!==void 0&&(this.canTrackVelocity=HX(this.current))}setPrevFrameValue(t=this.current){this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt}onChange(t){return this.on("change",t)}on(t,n){this.events[t]||(this.events[t]=new R1);const i=this.events[t].add(n);return t==="change"?()=>{i(),un.read(()=>{this.events.change.getSize()||this.stop()})}:i}clearListeners(){for(const t in this.events)this.events[t].clear()}attach(t,n){this.passiveEffect=t,this.stopPassiveEffect=n}set(t){this.passiveEffect?this.passiveEffect(t,this.updateAndNotify):this.updateAndNotify(t)}setWithVelocity(t,n,i){this.set(n),this.prev=void 0,this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt-i}jump(t,n=!0){this.updateAndNotify(t),this.prev=t,this.prevUpdatedAt=this.prevFrameValue=void 0,n&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}dirty(){var t;(t=this.events.change)==null||t.notify(this.current)}addDependent(t){this.dependents||(this.dependents=new Set),this.dependents.add(t)}removeDependent(t){this.dependents&&this.dependents.delete(t)}get(){return this.current}getPrevious(){return this.prev}getVelocity(){const t=Mi.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||t-this.updatedAt>H2)return 0;const n=Math.min(this.updatedAt-this.prevUpdatedAt,H2);return ZR(parseFloat(this.current)-parseFloat(this.prevFrameValue),n)}start(t){return this.stop(),new Promise(n=>{this.hasAnimated=!0,this.animation=t(n),this.events.animationStart&&this.events.animationStart.notify()}).then(()=>{this.events.animationComplete&&this.events.animationComplete.notify(),this.clearAnimation()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){delete this.animation}destroy(){var t,n;(t=this.dependents)==null||t.clear(),(n=this.events.destroy)==null||n.notify(),this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}}function qc(e,t){return new VX(e,t)}function RD(e,t){if(e!=null&&e.inherit&&t){const{inherit:n,...i}=e;return{...t,...i}}return e}function $1(e,t){const n=(e==null?void 0:e[t])??(e==null?void 0:e.default)??e;return n!==e?RD(n,e):n}const KX={type:"spring",stiffness:500,damping:25,restSpeed:10},GX=e=>({type:"spring",stiffness:550,damping:e===0?2*Math.sqrt(550):30,restSpeed:10}),WX={type:"keyframes",duration:.8},YX={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},XX=(e,{keyframes:t})=>t.length>2?WX:ru.has(e)?e.startsWith("scale")?GX(t[1]):KX:YX,QX=new Set(["when","delay","delayChildren","staggerChildren","staggerDirection","repeat","repeatType","repeatDelay","from","elapsed"]);function ZX(e){for(const t in e)if(!QX.has(t))return!0;return!1}const q1=(e,t,n,i={},s,r)=>o=>{const c=$1(i,e)||{},u=c.delay||i.delay||0;let{elapsed:f=0}=i;f=f-os(u);const p={keyframes:Array.isArray(n)?n:[null,n],ease:"easeOut",velocity:t.getVelocity(),...c,delay:-f,onUpdate:y=>{t.set(y),c.onUpdate&&c.onUpdate(y)},onComplete:()=>{o(),c.onComplete&&c.onComplete()},name:e,motionValue:t,element:r?void 0:s};ZX(c)||Object.assign(p,XX(e,p)),p.duration&&(p.duration=os(p.duration)),p.repeatDelay&&(p.repeatDelay=os(p.repeatDelay)),p.from!==void 0&&(p.keyframes[0]=p.from);let m=!1;if((p.type===!1||p.duration===0&&!p.repeatDelay)&&(Y0(p),p.delay===0&&(m=!0)),(oo.instantAnimations||oo.skipAnimations||s!=null&&s.shouldSkipAnimations||c.skipAnimations)&&(m=!0,Y0(p),p.delay=0),p.allowFlatten=!c.type&&!c.ease,m&&!r&&t.get()!==void 0){const y=qm(p.keyframes,c);if(y!==void 0){un.update(()=>{p.onUpdate(y),p.onComplete()});return}}return c.isSync?new um(p):new qX(p)},JX=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function eQ(e){const t=JX.exec(e);if(!t)return[,];const[,n,i,s]=t;return[`--${n??i}`,s]}function DD(e,t,n=1){const[i,s]=eQ(e);if(!i)return;const r=window.getComputedStyle(t).getPropertyValue(i);if(r){const o=r.trim();return WR(o)?parseFloat(o):o}return L1(s)?DD(s,t,n+1):s}function V2(e){const t=[{},{}];return e==null||e.values.forEach((n,i)=>{t[0][i]=n.get(),t[1][i]=n.getVelocity()}),t}function H1(e,t,n,i){if(typeof t=="function"){const[s,r]=V2(i);t=t(n!==void 0?n:e.custom,s,r)}if(typeof t=="string"&&(t=e.variants&&e.variants[t]),typeof t=="function"){const[s,r]=V2(i);t=t(n!==void 0?n:e.custom,s,r)}return t}function rl(e,t,n){const i=e.getProps();return H1(i,t,n!==void 0?n:i.custom,e)}const OD=new Set(["width","height","top","left","right","bottom",...su]),X0=e=>Array.isArray(e);function tQ(e,t,n){e.hasValue(t)?e.getValue(t).set(n):e.addValue(t,qc(n))}function nQ(e){return X0(e)?e[e.length-1]||0:e}function iQ(e,t){const n=rl(e,t);let{transitionEnd:i={},transition:s={},...r}=n||{};r={...r,...i};for(const o in r){const c=nQ(r[o]);tQ(e,o,c)}}const gi=e=>!!(e&&e.getVelocity);function sQ(e){return!!(gi(e)&&e.add)}function Q0(e,t){const n=e.getValue("willChange");if(sQ(n))return n.add(t);if(!n&&oo.WillChange){const i=new oo.WillChange("auto");e.addValue("willChange",i),i.add(t)}}function V1(e){return e.replace(/([A-Z])/g,t=>`-${t.toLowerCase()}`)}const rQ="framerAppearId",LD="data-"+V1(rQ);function ID(e){return e.props[LD]}function aQ({protectedKeys:e,needsAnimating:t},n){const i=e.hasOwnProperty(n)&&t[n]!==!0;return t[n]=!1,i}function PD(e,t,{delay:n=0,transitionOverride:i,type:s}={}){let{transition:r,transitionEnd:o,...c}=t;const u=e.getDefaultTransition();r=r?RD(r,u):u;const f=r==null?void 0:r.reduceMotion,p=r==null?void 0:r.skipAnimations;i&&(r=i);const m=[],y=s&&e.animationState&&e.animationState.getState()[s],b=r==null?void 0:r.path;b&&b.animateVisualElement(e,c,r,n,m);for(const x in c){const v=e.getValue(x,e.latestValues[x]??null),w=c[x];if(w===void 0||y&&aQ(y,x))continue;const k={delay:n,...$1(r||{},x)};p&&(k.skipAnimations=!0);const C=v.get();if(C!==void 0&&!v.isAnimating()&&!Array.isArray(w)&&w===C&&!k.velocity){un.update(()=>v.set(w));continue}let S=!1;if(window.MotionHandoffAnimation){const j=ID(e);if(j){const M=window.MotionHandoffAnimation(j,x,un);M!==null&&(k.startTime=M,S=!0)}}Q0(e,x);const T=f??e.shouldReduceMotion;v.start(q1(x,v,w,T&&OD.has(x)?{type:!1}:k,e,S));const A=v.animation;A&&m.push(A)}if(o){const x=()=>un.update(()=>{o&&iQ(e,o)});m.length?Promise.all(m).then(x):x()}return m}function Z0(e,t,n={}){var u;const i=rl(e,t,n.type==="exit"?(u=e.presenceContext)==null?void 0:u.custom:void 0);let{transition:s=e.getDefaultTransition()||{}}=i||{};n.transitionOverride&&(s=n.transitionOverride);const r=i?()=>Promise.all(PD(e,i,n)):()=>Promise.resolve(),o=e.variantChildren&&e.variantChildren.size?(f=0)=>{const{delayChildren:p=0,staggerChildren:m,staggerDirection:y}=s;return oQ(e,t,f,p,m,y,n)}:()=>Promise.resolve(),{when:c}=s;if(c){const[f,p]=c==="beforeChildren"?[r,o]:[o,r];return f().then(()=>p())}else return Promise.all([r(),o(n.delay)])}function oQ(e,t,n=0,i=0,s=0,r=1,o){const c=[];for(const u of e.variantChildren)u.notify("AnimationStart",t),c.push(Z0(u,t,{...o,delay:n+(typeof i=="function"?0:i)+MD(e.variantChildren,u,i,s,r)}).then(()=>u.notify("AnimationComplete",t)));return Promise.all(c)}function lQ(e,t,n={}){e.notify("AnimationStart",t);let i;if(Array.isArray(t)){const s=t.map(r=>Z0(e,r,n));i=Promise.all(s)}else if(typeof t=="string")i=Z0(e,t,n);else{const s=typeof t=="function"?rl(e,t,n.custom):t;i=Promise.all(PD(e,s,n))}return i.then(()=>{e.notify("AnimationComplete",t)})}const cQ={test:e=>e==="auto",parse:e=>e},zD=e=>t=>t.test(e),BD=[iu,Ge,Er,Jr,LY,OY,cQ],K2=e=>BD.find(zD(e));function uQ(e){return typeof e=="number"?e===0:e!==null?e==="none"||e==="0"||XR(e):!0}const dQ=new Set(["brightness","contrast","saturate","opacity"]);function fQ(e){const[t,n]=e.slice(0,-1).split("(");if(t==="drop-shadow")return e;const[i]=n.match(I1)||[];if(!i)return e;const s=n.replace(i,"");let r=dQ.has(t)?1:0;return i!==n&&(r*=100),t+"("+r+s+")"}const hQ=/\b([a-z-]*)\(.*?\)/gu,J0={...er,getAnimatableNone:e=>{const t=e.match(hQ);return t?t.map(fQ).join(" "):e}},ev={...er,getAnimatableNone:e=>{const t=er.parse(e);return er.createTransformer(e)(t.map(i=>typeof i=="number"?0:typeof i=="object"?{...i,alpha:1}:i))}},G2={...iu,transform:Math.round},pQ={rotate:Jr,pathRotation:Jr,rotateX:Jr,rotateY:Jr,rotateZ:Jr,scale:tp,scaleX:tp,scaleY:tp,scaleZ:tp,skew:Jr,skewX:Jr,skewY:Jr,distance:Ge,translateX:Ge,translateY:Ge,translateZ:Ge,x:Ge,y:Ge,z:Ge,perspective:Ge,transformPerspective:Ge,opacity:Ud,originX:D2,originY:D2,originZ:Ge},dm={borderWidth:Ge,borderTopWidth:Ge,borderRightWidth:Ge,borderBottomWidth:Ge,borderLeftWidth:Ge,borderRadius:Ge,borderTopLeftRadius:Ge,borderTopRightRadius:Ge,borderBottomRightRadius:Ge,borderBottomLeftRadius:Ge,width:Ge,maxWidth:Ge,height:Ge,maxHeight:Ge,top:Ge,right:Ge,bottom:Ge,left:Ge,inset:Ge,insetBlock:Ge,insetBlockStart:Ge,insetBlockEnd:Ge,insetInline:Ge,insetInlineStart:Ge,insetInlineEnd:Ge,padding:Ge,paddingTop:Ge,paddingRight:Ge,paddingBottom:Ge,paddingLeft:Ge,paddingBlock:Ge,paddingBlockStart:Ge,paddingBlockEnd:Ge,paddingInline:Ge,paddingInlineStart:Ge,paddingInlineEnd:Ge,margin:Ge,marginTop:Ge,marginRight:Ge,marginBottom:Ge,marginLeft:Ge,marginBlock:Ge,marginBlockStart:Ge,marginBlockEnd:Ge,marginInline:Ge,marginInlineStart:Ge,marginInlineEnd:Ge,fontSize:Ge,backgroundPositionX:Ge,backgroundPositionY:Ge,...pQ,zIndex:G2,fillOpacity:Ud,strokeOpacity:Ud,numOctaves:G2},mQ={...dm,color:Kn,backgroundColor:Kn,outlineColor:Kn,fill:Kn,stroke:Kn,borderColor:Kn,borderTopColor:Kn,borderRightColor:Kn,borderBottomColor:Kn,borderLeftColor:Kn,filter:J0,WebkitFilter:J0,mask:ev,WebkitMask:ev},UD=e=>mQ[e],gQ=new Set([J0,ev]);function FD(e,t){let n=UD(e);return gQ.has(n)||(n=er),n.getAnimatableNone?n.getAnimatableNone(t):void 0}const yQ=new Set(["auto","none","0"]);function bQ(e,t,n){let i=0,s;for(;i<e.length&&!s;){const r=e[i];typeof r=="string"&&!yQ.has(r)&&$c(r).values.length&&(s=e[i]),i++}if(s&&n)for(const r of t)e[r]=FD(n,s)}class xQ extends F1{constructor(t,n,i,s,r){super(t,n,i,s,r,!0)}readKeyframes(){const{unresolvedKeyframes:t,element:n,name:i}=this;if(!n||!n.current)return;super.readKeyframes();for(let p=0;p<t.length;p++){let m=t[p];if(typeof m=="string"&&(m=m.trim(),L1(m))){const y=DD(m,n.current);y!==void 0&&(t[p]=y),p===t.length-1&&(this.finalKeyframe=m)}}if(this.resolveNoneKeyframes(),!OD.has(i)||t.length!==2)return;const[s,r]=t,o=K2(s),c=K2(r),u=R2(s),f=R2(r);if(u!==f&&to[i]){this.needsMeasurement=!0;return}if(o!==c)if(F2(o)&&F2(c))for(let p=0;p<t.length;p++){const m=t[p];typeof m=="string"&&(t[p]=parseFloat(m))}else to[i]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){const{unresolvedKeyframes:t,name:n}=this,i=[];for(let s=0;s<t.length;s++)(t[s]===null||uQ(t[s]))&&i.push(s);i.length&&bQ(t,i,n)}measureInitialState(){const{element:t,unresolvedKeyframes:n,name:i}=this;if(!t||!t.current)return;i==="height"&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=to[i](t.measureViewportBox(),window.getComputedStyle(t.current)),n[0]=this.measuredOrigin;const s=n[n.length-1];s!==void 0&&t.getValue(i,s).jump(s,!1)}measureEndState(){var c;const{element:t,name:n,unresolvedKeyframes:i}=this;if(!t||!t.current)return;const s=t.getValue(n);s&&s.jump(this.measuredOrigin,!1);const r=i.length-1,o=i[r];i[r]=to[n](t.measureViewportBox(),window.getComputedStyle(t.current)),o!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=o),(c=this.removedTransforms)!=null&&c.length&&this.removedTransforms.forEach(([u,f])=>{t.getValue(u).set(f)}),this.resolveNoneKeyframes()}}const K1=["borderTopLeftRadius","borderTopRightRadius","borderBottomRightRadius","borderBottomLeftRadius"];function G1(e,t,n){if(e==null)return[];if(e instanceof EventTarget)return[e];if(typeof e=="string"){const s=document.querySelectorAll(e);return s?Array.from(s):[]}return Array.from(e).filter(i=>i!=null)}const tv=(e,t)=>t&&typeof e=="number"?t.transform(e):e;function vQ(e){return YR(e)&&"offsetHeight"in e&&!("ownerSVGElement"in e)}const{schedule:W1}=cD(queueMicrotask,!1),Vs={x:!1,y:!1};function $D(){return Vs.x||Vs.y}function wQ(e){return e==="x"||e==="y"?Vs[e]?null:(Vs[e]=!0,()=>{Vs[e]=!1}):Vs.x||Vs.y?null:(Vs.x=Vs.y=!0,()=>{Vs.x=Vs.y=!1})}function qD(e,t){const n=G1(e),i=new AbortController,s={passive:!0,...t,signal:i.signal};return[n,s,()=>i.abort()]}function EQ(e){return!(e.pointerType==="touch"||$D())}function kQ(e,t,n={}){const[i,s,r]=qD(e,n);return i.forEach(o=>{let c=!1,u=!1,f;const p=()=>{o.removeEventListener("pointerleave",x)},m=w=>{f&&(f(w),f=void 0),p()},y=w=>{c=!1,window.removeEventListener("pointerup",y),window.removeEventListener("pointercancel",y),u&&(u=!1,m(w))},b=()=>{c=!0,window.addEventListener("pointerup",y,s),window.addEventListener("pointercancel",y,s)},x=w=>{if(w.pointerType!=="touch"){if(c){u=!0;return}m(w)}},v=w=>{if(!EQ(w))return;u=!1;const k=t(o,w);typeof k=="function"&&(f=k,o.addEventListener("pointerleave",x,s))};o.addEventListener("pointerenter",v,s),o.addEventListener("pointerdown",b,s)}),r}const HD=(e,t)=>t?e===t?!0:HD(e,t.parentElement):!1,Y1=e=>e.pointerType==="mouse"?typeof e.button!="number"||e.button<=0:e.isPrimary!==!1,SQ=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function NQ(e){return SQ.has(e.tagName)||e.isContentEditable===!0}const _Q=new Set(["INPUT","SELECT","TEXTAREA"]);function CQ(e){return _Q.has(e.tagName)||e.isContentEditable===!0}const Mp=new WeakSet;function W2(e){return t=>{t.key==="Enter"&&e(t)}}function dx(e,t){e.dispatchEvent(new PointerEvent("pointer"+t,{isPrimary:!0,bubbles:!0}))}const TQ=(e,t)=>{const n=e.currentTarget;if(!n)return;const i=W2(()=>{if(Mp.has(n))return;dx(n,"down");const s=W2(()=>{dx(n,"up")}),r=()=>dx(n,"cancel");n.addEventListener("keyup",s,t),n.addEventListener("blur",r,t)});n.addEventListener("keydown",i,t),n.addEventListener("blur",()=>n.removeEventListener("keydown",i),t)};function Y2(e){return Y1(e)&&!$D()}const X2=new WeakSet;function AQ(e,t,n={}){const[i,s,r]=qD(e,n),o=c=>{const u=c.currentTarget;if(!Y2(c)||X2.has(c))return;Mp.add(u),n.stopPropagation&&X2.add(c);const f=t(u,c),p={...s,capture:!0},m=(x,v)=>{window.removeEventListener("pointerup",y,p),window.removeEventListener("pointercancel",b,p),Mp.has(u)&&Mp.delete(u),Y2(x)&&typeof f=="function"&&f(x,{success:v})},y=x=>{m(x,u===window||u===document||n.useGlobalTarget||HD(u,x.target))},b=x=>{m(x,!1)};window.addEventListener("pointerup",y,p),window.addEventListener("pointercancel",b,p)};return i.forEach(c=>{(n.useGlobalTarget?window:c).addEventListener("pointerdown",o,s),vQ(c)&&(c.addEventListener("focus",f=>TQ(f,s)),!NQ(c)&&!c.hasAttribute("tabindex")&&(c.tabIndex=0))}),r}function X1(e){return YR(e)&&"ownerSVGElement"in e}const Rp=new WeakMap;let qa;const VD=(e,t,n)=>(i,s)=>s&&s[0]?s[0][e+"Size"]:X1(i)&&"getBBox"in i?i.getBBox()[t]:i[n],jQ=VD("inline","width","offsetWidth"),MQ=VD("block","height","offsetHeight");function RQ({target:e,borderBoxSize:t}){var n;(n=Rp.get(e))==null||n.forEach(i=>{i(e,{get width(){return jQ(e,t)},get height(){return MQ(e,t)}})})}function DQ(e){e.forEach(RQ)}function OQ(){typeof ResizeObserver>"u"||(qa=new ResizeObserver(DQ))}function LQ(e,t){qa||OQ();const n=G1(e);return n.forEach(i=>{let s=Rp.get(i);s||(s=new Set,Rp.set(i,s)),s.add(t),qa==null||qa.observe(i)}),()=>{n.forEach(i=>{const s=Rp.get(i);s==null||s.delete(t),s!=null&&s.size||qa==null||qa.unobserve(i)})}}const Dp=new Set;let fc;function IQ(){fc=()=>{const e={get width(){return window.innerWidth},get height(){return window.innerHeight}};Dp.forEach(t=>t(e))},window.addEventListener("resize",fc)}function PQ(e){return Dp.add(e),fc||IQ(),()=>{Dp.delete(e),!Dp.size&&typeof fc=="function"&&(window.removeEventListener("resize",fc),fc=void 0)}}function Q2(e,t){return typeof e=="function"?PQ(e):LQ(e,t)}function zQ(e){return X1(e)&&e.tagName==="svg"}const BQ=[...BD,Kn,er],UQ=e=>BQ.find(zD(e)),Z2=()=>({translate:0,scale:1,origin:0,originPoint:0}),hc=()=>({x:Z2(),y:Z2()}),J2=()=>({min:0,max:0}),Jn=()=>({x:J2(),y:J2()}),FQ=new WeakMap;function Hm(e){return e!==null&&typeof e=="object"&&typeof e.start=="function"}function Fd(e){return typeof e=="string"||Array.isArray(e)}const Q1=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],Z1=["initial",...Q1];function Vm(e){return Hm(e.animate)||Z1.some(t=>Fd(e[t]))}function KD(e){return!!(Vm(e)||e.variants)}function $Q(e,t,n){for(const i in t){const s=t[i],r=n[i];if(gi(s))e.addValue(i,s);else if(gi(r))e.addValue(i,qc(s,{owner:e}));else if(r!==s)if(e.hasValue(i)){const o=e.getValue(i);o.liveStyle===!0?o.jump(s):o.hasAnimated||o.set(s)}else{const o=e.getStaticValue(i);e.addValue(i,qc(o!==void 0?o:s,{owner:e}))}}for(const i in n)t[i]===void 0&&e.removeValue(i);return t}const nv={current:null},GD={current:!1},qQ=typeof window<"u";function HQ(){if(GD.current=!0,!!qQ)if(window.matchMedia){const e=window.matchMedia("(prefers-reduced-motion)"),t=()=>nv.current=e.matches;e.addEventListener("change",t),t()}else nv.current=!1}const eC=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];let fm={};function WD(e){fm=e}function VQ(){return fm}class KQ{scrapeMotionValuesFromProps(t,n,i){return{}}constructor({parent:t,props:n,presenceContext:i,reducedMotionConfig:s,skipAnimations:r,blockInitialAnimation:o,visualState:c},u={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.shouldSkipAnimations=!1,this.values=new Map,this.KeyframeResolver=F1,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.hasBeenMounted=!1,this.events={},this.propEventSubscriptions={},this.notifyUpdate=()=>this.notify("Update",this.latestValues),this.render=()=>{this.current&&(this.triggerBuild(),this.renderInstance(this.current,this.renderState,this.props.style,this.projection))},this.renderScheduledAt=0,this.scheduleRender=()=>{const b=Mi.now();this.renderScheduledAt<b&&(this.renderScheduledAt=b,un.render(this.render,!1,!0))};const{latestValues:f,renderState:p}=c;this.latestValues=f,this.baseTarget={...f},this.initialValues=n.initial?{...f}:{},this.renderState=p,this.parent=t,this.props=n,this.presenceContext=i,this.depth=t?t.depth+1:0,this.reducedMotionConfig=s,this.skipAnimationsConfig=r,this.options=u,this.blockInitialAnimation=!!o,this.isControllingVariants=Vm(n),this.isVariantNode=KD(n),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(t&&t.current);const{willChange:m,...y}=this.scrapeMotionValuesFromProps(n,{},this);for(const b in y){const x=y[b];f[b]!==void 0&&gi(x)&&x.set(f[b])}}mount(t){var n,i;if(this.hasBeenMounted)for(const s in this.initialValues)(n=this.values.get(s))==null||n.jump(this.initialValues[s]),this.latestValues[s]=this.initialValues[s];this.current=t,FQ.set(t,this),this.projection&&!this.projection.instance&&this.projection.mount(t),this.parent&&this.isVariantNode&&!this.isControllingVariants&&(this.removeFromVariantTree=this.parent.addVariantChild(this)),this.values.forEach((s,r)=>this.bindToMotionValue(r,s)),this.reducedMotionConfig==="never"?this.shouldReduceMotion=!1:this.reducedMotionConfig==="always"?this.shouldReduceMotion=!0:(GD.current||HQ(),this.shouldReduceMotion=nv.current),this.shouldSkipAnimations=this.skipAnimationsConfig??!1,(i=this.parent)==null||i.addChild(this),this.update(this.props,this.presenceContext),this.hasBeenMounted=!0}unmount(){var t;this.projection&&this.projection.unmount(),lo(this.notifyUpdate),lo(this.render),this.valueSubscriptions.forEach(n=>n()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),(t=this.parent)==null||t.removeChild(this);for(const n in this.events)this.events[n].clear();for(const n in this.features){const i=this.features[n];i&&(i.unmount(),i.isMounted=!1)}this.current=null}addChild(t){this.children.add(t),this.enteringChildren??(this.enteringChildren=new Set),this.enteringChildren.add(t)}removeChild(t){this.children.delete(t),this.enteringChildren&&this.enteringChildren.delete(t)}bindToMotionValue(t,n){if(this.valueSubscriptions.has(t)&&this.valueSubscriptions.get(t)(),n.accelerate&&jD.has(t)&&this.current instanceof HTMLElement){const{factory:o,keyframes:c,times:u,ease:f,duration:p}=n.accelerate,m=new TD({element:this.current,name:t,keyframes:c,times:u,ease:f,duration:os(p)}),y=o(m);this.valueSubscriptions.set(t,()=>{y(),m.cancel()});return}const i=ru.has(t);i&&this.onBindTransform&&this.onBindTransform();const s=n.on("change",o=>{this.latestValues[t]=o,this.props.onUpdate&&un.preRender(this.notifyUpdate),i&&this.projection&&(this.projection.isTransformDirty=!0),this.scheduleRender()});let r;typeof window<"u"&&window.MotionCheckAppearSync&&(r=window.MotionCheckAppearSync(this,t,n)),this.valueSubscriptions.set(t,()=>{s(),r&&r()})}sortNodePosition(t){return!this.current||!this.sortInstanceNodePosition||this.type!==t.type?0:this.sortInstanceNodePosition(this.current,t.current)}updateFeatures(){let t="animation";for(t in fm){const n=fm[t];if(!n)continue;const{isEnabled:i,Feature:s}=n;if(!this.features[t]&&s&&i(this.props)&&(this.features[t]=new s(this)),this.features[t]){const r=this.features[t];r.isMounted?r.update():(r.mount(),r.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):Jn()}getStaticValue(t){return this.latestValues[t]}setStaticValue(t,n){this.latestValues[t]=n}update(t,n){(t.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=t,this.prevPresenceContext=this.presenceContext,this.presenceContext=n;for(let i=0;i<eC.length;i++){const s=eC[i];this.propEventSubscriptions[s]&&(this.propEventSubscriptions[s](),delete this.propEventSubscriptions[s]);const r="on"+s,o=t[r];o&&(this.propEventSubscriptions[s]=this.on(s,o))}this.prevMotionValues=$Q(this,this.scrapeMotionValuesFromProps(t,this.prevProps||{},this),this.prevMotionValues),this.handleChildMotionValue&&this.handleChildMotionValue()}getProps(){return this.props}getVariant(t){return this.props.variants?this.props.variants[t]:void 0}getDefaultTransition(){return this.props.transition}getTransformPagePoint(){return this.props.transformPagePoint}getClosestVariantNode(){return this.isVariantNode?this:this.parent?this.parent.getClosestVariantNode():void 0}addVariantChild(t){const n=this.getClosestVariantNode();if(n)return n.variantChildren&&n.variantChildren.add(t),()=>n.variantChildren.delete(t)}addValue(t,n){const i=this.values.get(t);n!==i&&(i&&this.removeValue(t),this.bindToMotionValue(t,n),this.values.set(t,n),this.latestValues[t]=n.get())}removeValue(t){this.values.delete(t);const n=this.valueSubscriptions.get(t);n&&(n(),this.valueSubscriptions.delete(t)),delete this.latestValues[t],this.removeValueFromRenderState(t,this.renderState)}hasValue(t){return this.values.has(t)}getValue(t,n){if(this.props.values&&this.props.values[t])return this.props.values[t];let i=this.values.get(t);return i===void 0&&n!==void 0&&(i=qc(n===null?void 0:n,{owner:this}),this.addValue(t,i)),i}readValue(t,n){let i=this.latestValues[t]!==void 0||!this.current?this.latestValues[t]:this.getBaseTargetFromProps(this.props,t)??this.readValueFromInstance(this.current,t,this.options);return i!=null&&(typeof i=="string"&&(WR(i)||XR(i))?i=parseFloat(i):!UQ(i)&&er.test(n)&&(i=FD(t,n)),this.setBaseTarget(t,gi(i)?i.get():i)),gi(i)?i.get():i}setBaseTarget(t,n){this.baseTarget[t]=n}getBaseTarget(t){var r;const{initial:n}=this.props;let i;if(typeof n=="string"||typeof n=="object"){const o=H1(this.props,n,(r=this.presenceContext)==null?void 0:r.custom);o&&(i=o[t])}if(n&&i!==void 0)return i;const s=this.getBaseTargetFromProps(this.props,t);return s!==void 0&&!gi(s)?s:this.initialValues[t]!==void 0&&i===void 0?void 0:this.baseTarget[t]}on(t,n){return this.events[t]||(this.events[t]=new R1),this.events[t].add(n)}notify(t,...n){this.events[t]&&this.events[t].notify(...n)}scheduleRenderMicrotask(){W1.render(this.render)}}class YD extends KQ{constructor(){super(...arguments),this.KeyframeResolver=xQ}sortInstanceNodePosition(t,n){return t.compareDocumentPosition(n)&2?1:-1}getBaseTargetFromProps(t,n){const i=t.style;return i?i[n]:void 0}removeValueFromRenderState(t,{vars:n,style:i}){delete n[t],delete i[t]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);const{children:t}=this.props;gi(t)&&(this.childSubscription=t.on("change",n=>{this.current&&(this.current.textContent=`${n}`)}))}}class po{constructor(t){this.isMounted=!1,this.node=t}update(){}}function XD({top:e,left:t,right:n,bottom:i}){return{x:{min:t,max:n},y:{min:e,max:i}}}function GQ({x:e,y:t}){return{top:t.min,right:e.max,bottom:t.max,left:e.min}}function WQ(e,t){if(!t)return e;const n=t({x:e.left,y:e.top}),i=t({x:e.right,y:e.bottom});return{top:n.y,left:n.x,bottom:i.y,right:i.x}}function fx(e){return e===void 0||e===1}function iv({scale:e,scaleX:t,scaleY:n}){return!fx(e)||!fx(t)||!fx(n)}function Bo(e){return iv(e)||QD(e)||e.z||e.rotate||e.rotateX||e.rotateY||e.skewX||e.skewY}function QD(e){return tC(e.x)||tC(e.y)}function tC(e){return e&&e!=="0%"}function hm(e,t,n){const i=e-n,s=t*i;return n+s}function nC(e,t,n,i,s){return s!==void 0&&(e=hm(e,s,i)),hm(e,n,i)+t}function sv(e,t=0,n=1,i,s){e.min=nC(e.min,t,n,i,s),e.max=nC(e.max,t,n,i,s)}function ZD(e,{x:t,y:n}){sv(e.x,t.translate,t.scale,t.originPoint),sv(e.y,n.translate,n.scale,n.originPoint)}const iC=.999999999999,sC=1.0000000000001;function YQ(e,t,n,i=!1){var c;const s=n.length;if(!s)return;t.x=t.y=1;let r,o;for(let u=0;u<s;u++){r=n[u],o=r.projectionDelta;const{visualElement:f}=r.options;f&&f.props.style&&f.props.style.display==="contents"||(i&&r.options.layoutScroll&&r.scroll&&r!==r.root&&(vr(e.x,-r.scroll.offset.x),vr(e.y,-r.scroll.offset.y)),o&&(t.x*=o.x.scale,t.y*=o.y.scale,ZD(e,o)),i&&Bo(r.latestValues)&&Op(e,r.latestValues,(c=r.layout)==null?void 0:c.layoutBox))}t.x<sC&&t.x>iC&&(t.x=1),t.y<sC&&t.y>iC&&(t.y=1)}function vr(e,t){e.min+=t,e.max+=t}function rC(e,t,n,i,s=.5){const r=cn(e.min,e.max,s);sv(e,t,n,r,i)}function aC(e,t){return typeof e=="string"?parseFloat(e)/100*(t.max-t.min):e}function Op(e,t,n){const i=n??e;rC(e.x,aC(t.x,i.x),t.scaleX,t.scale,t.originX),rC(e.y,aC(t.y,i.y),t.scaleY,t.scale,t.originY)}function JD(e,t){return XD(WQ(e.getBoundingClientRect(),t))}function XQ(e,t,n){const i=JD(e,n),{scroll:s}=t;return s&&(vr(i.x,s.offset.x),vr(i.y,s.offset.y)),i}const QQ={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},ZQ=su.length;function JQ(e,t,n){let i="",s=!0;for(let o=0;o<ZQ;o++){const c=su[o],u=e[c];if(u===void 0)continue;let f=!0;if(typeof u=="number")f=u===(c.startsWith("scale")?1:0);else{const p=parseFloat(u);f=c.startsWith("scale")?p===1:p===0}if(!f||n){const p=tv(u,dm[c]);if(!f){s=!1;const m=QQ[c]||c;i+=`${m}(${p}) `}n&&(t[c]=p)}}const r=e.pathRotation;return r&&(s=!1,i+=`rotate(${tv(r,dm.pathRotation)}) `),i=i.trim(),n?i=n(t,s?"":i):s&&(i="none"),i}function J1(e,t,n){const{style:i,vars:s,transformOrigin:r}=e;let o=!1,c=!1;for(const u in t){const f=t[u];if(ru.has(u)){o=!0;continue}else if(dD(u)){s[u]=f;continue}else{const p=tv(f,dm[u]);u.startsWith("origin")?(c=!0,r[u]=p):i[u]=p}}if(t.transform||(o||n?i.transform=JQ(t,e.transform,n):i.transform&&(i.transform="none")),c){const{originX:u="50%",originY:f="50%",originZ:p=0}=r;i.transformOrigin=`${u} ${f} ${p}`}}function eO(e,{style:t,vars:n},i,s){const r=e.style;let o;for(o in t)r[o]=t[o];s==null||s.applyProjectionStyles(r,i);for(o in n)r.setProperty(o,n[o])}function oC(e,t){return t.max===t.min?0:e/(t.max-t.min)*100}const cd={correct:(e,t)=>{if(!t.target)return e;if(typeof e=="string")if(Ge.test(e))e=parseFloat(e);else return e;const n=oC(e,t.target.x),i=oC(e,t.target.y);return`${n}% ${i}%`}},eZ={correct:(e,{treeScale:t,projectionDelta:n})=>{const i=e,s=er.parse(e);if(s.length>5)return i;const r=er.createTransformer(e),o=typeof s[0]!="number"?1:0,c=n.x.scale*t.x,u=n.y.scale*t.y;s[0+o]/=c,s[1+o]/=u;const f=cn(c,u,.5);return typeof s[2+o]=="number"&&(s[2+o]/=f),typeof s[3+o]=="number"&&(s[3+o]/=f),r(s)}},rv={borderRadius:{...cd,applyTo:[...K1]},borderTopLeftRadius:cd,borderTopRightRadius:cd,borderBottomLeftRadius:cd,borderBottomRightRadius:cd,boxShadow:eZ};function tO(e,{layout:t,layoutId:n}){return ru.has(e)||e.startsWith("origin")||(t||n!==void 0)&&(!!rv[e]||e==="opacity")}function ew(e,t,n){var o;const i=e.style,s=t==null?void 0:t.style,r={};if(!i)return r;for(const c in i)(gi(i[c])||s&&gi(s[c])||tO(c,e)||((o=n==null?void 0:n.getValue(c))==null?void 0:o.liveStyle)!==void 0)&&(r[c]=i[c]);return r}function tZ(e){return window.getComputedStyle(e)}class nZ extends YD{constructor(){super(...arguments),this.type="html",this.renderInstance=eO}readValueFromInstance(t,n){var i;if(ru.has(n))return(i=this.projection)!=null&&i.isProjecting?H0(n):wX(t,n);{const s=tZ(t),r=(dD(n)?s.getPropertyValue(n):s[n])||0;return typeof r=="string"?r.trim():r}}measureInstanceViewportBox(t,{transformPagePoint:n}){return JD(t,n)}build(t,n,i){J1(t,n,i.transformTemplate)}scrapeMotionValuesFromProps(t,n,i){return ew(t,n,i)}}const iZ={offset:"stroke-dashoffset",array:"stroke-dasharray"},sZ={offset:"strokeDashoffset",array:"strokeDasharray"};function rZ(e,t,n=1,i=0,s=!0){e.pathLength=1;const r=s?iZ:sZ;e[r.offset]=`${-i}`,e[r.array]=`${t} ${n}`}const aZ=["offsetDistance","offsetPath","offsetRotate","offsetAnchor"];function nO(e,{attrX:t,attrY:n,attrScale:i,pathLength:s,pathSpacing:r=1,pathOffset:o=0,...c},u,f,p){if(J1(e,c,f),u){e.style.viewBox&&(e.attrs.viewBox=e.style.viewBox);return}e.attrs=e.style,e.style={};const{attrs:m,style:y}=e;m.transform&&(y.transform=m.transform,delete m.transform),(y.transform||m.transformOrigin)&&(y.transformOrigin=m.transformOrigin??"50% 50%",delete m.transformOrigin),y.transform&&(y.transformBox=(p==null?void 0:p.transformBox)??"fill-box",delete m.transformBox);for(const b of aZ)m[b]!==void 0&&(y[b]=m[b],delete m[b]);t!==void 0&&(m.x=t),n!==void 0&&(m.y=n),i!==void 0&&(m.scale=i),s!==void 0&&rZ(m,s,r,o,!1)}const iO=new Set(["baseFrequency","diffuseConstant","kernelMatrix","kernelUnitLength","keySplines","keyTimes","limitingConeAngle","markerHeight","markerWidth","numOctaves","targetX","targetY","surfaceScale","specularConstant","specularExponent","stdDeviation","tableValues","viewBox","gradientTransform","pathLength","startOffset","textLength","lengthAdjust"]),sO=e=>typeof e=="string"&&e.toLowerCase()==="svg";function oZ(e,t,n,i){eO(e,t,void 0,i);for(const s in t.attrs)e.setAttribute(iO.has(s)?s:V1(s),t.attrs[s])}function rO(e,t,n){const i=ew(e,t,n);for(const s in e)if(gi(e[s])||gi(t[s])){const r=su.indexOf(s)!==-1?"attr"+s.charAt(0).toUpperCase()+s.substring(1):s;i[r]=e[s]}return i}class lZ extends YD{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=Jn}getBaseTargetFromProps(t,n){return t[n]}readValueFromInstance(t,n){if(ru.has(n)){const i=UD(n);return i&&i.default||0}return n=iO.has(n)?n:V1(n),t.getAttribute(n)}scrapeMotionValuesFromProps(t,n,i){return rO(t,n,i)}build(t,n,i){nO(t,n,this.isSVGTag,i.transformTemplate,i.style)}renderInstance(t,n,i,s){oZ(t,n,i,s)}mount(t){this.isSVGTag=sO(t.tagName),super.mount(t)}}const cZ=Z1.length;function aO(e){if(!e)return;if(!e.isControllingVariants){const n=e.parent?aO(e.parent)||{}:{};return e.props.initial!==void 0&&(n.initial=e.props.initial),n}const t={};for(let n=0;n<cZ;n++){const i=Z1[n],s=e.props[i];(Fd(s)||s===!1)&&(t[i]=s)}return t}function oO(e,t){if(!Array.isArray(t))return!1;const n=t.length;if(n!==e.length)return!1;for(let i=0;i<n;i++)if(t[i]!==e[i])return!1;return!0}const uZ=[...Q1].reverse(),dZ=Q1.length;function fZ(e){return t=>Promise.all(t.map(({animation:n,options:i})=>lQ(e,n,i)))}function hZ(e){let t=fZ(e),n=lC(),i=!0,s=!1;const r=f=>(p,m)=>{var b;const y=rl(e,m,f==="exit"?(b=e.presenceContext)==null?void 0:b.custom:void 0);if(y){const{transition:x,transitionEnd:v,...w}=y;p={...p,...w,...v}}return p};function o(f){t=f(e)}function c(f){const{props:p}=e,m=aO(e.parent)||{},y=[],b=new Set;let x={},v=1/0;for(let k=0;k<dZ;k++){const C=uZ[k],S=n[C],T=p[C]!==void 0?p[C]:m[C],A=Fd(T),j=C===f?S.isActive:null;j===!1&&(v=k);let M=T===m[C]&&T!==p[C]&&A;if(M&&(i||s)&&e.manuallyAnimateOnMount&&(M=!1),S.protectedKeys={...x},!S.isActive&&j===null||!T&&!S.prevProp||Hm(T)||typeof T=="boolean")continue;if(C==="exit"&&S.isActive&&j!==!0){S.prevResolvedValues&&(x={...x,...S.prevResolvedValues});continue}const D=pZ(S.prevProp,T);let P=D||C===f&&S.isActive&&!M&&A||k>v&&A,I=!1;const B=Array.isArray(T)?T:[T];let q=B.reduce(r(C),{});j===!1&&(q={});const{prevResolvedValues:G={}}=S,R={...G,...q},O=X=>{P=!0,b.has(X)&&(I=!0,b.delete(X)),S.needsAnimating[X]=!0;const K=e.getValue(X);K&&(K.liveStyle=!1)};for(const X in R){const K=q[X],U=G[X];if(x.hasOwnProperty(X))continue;let F=!1;X0(K)&&X0(U)?F=!oO(K,U)||D:F=K!==U,F?K!=null?O(X):b.add(X):K!==void 0&&b.has(X)?O(X):S.protectedKeys[X]=!0}S.prevProp=T,S.prevResolvedValues=q,S.isActive&&(x={...x,...q}),(i||s)&&e.blockInitialAnimation&&(P=!1);const z=M&&D;P&&(!z||I)&&y.push(...B.map(X=>{const K={type:C};if(typeof X=="string"&&(i||s)&&!z&&e.manuallyAnimateOnMount&&e.parent){const{parent:U}=e,F=rl(U,X);if(U.enteringChildren&&F){const{delayChildren:Y}=F.transition||{};K.delay=MD(U.enteringChildren,e,Y)}}return{animation:X,options:K}}))}if(b.size){const k={};if(typeof p.initial!="boolean"){const C=rl(e,Array.isArray(p.initial)?p.initial[0]:p.initial);C&&C.transition&&(k.transition=C.transition)}b.forEach(C=>{const S=e.getBaseTarget(C),T=e.getValue(C);T&&(T.liveStyle=!0),k[C]=S??null}),y.push({animation:k})}let w=!!y.length;return i&&(p.initial===!1||p.initial===p.animate)&&!e.manuallyAnimateOnMount&&(w=!1),i=!1,s=!1,w?t(y):Promise.resolve()}function u(f,p){var y;if(n[f].isActive===p)return Promise.resolve();(y=e.variantChildren)==null||y.forEach(b=>{var x;return(x=b.animationState)==null?void 0:x.setActive(f,p)}),n[f].isActive=p;const m=c(f);for(const b in n)n[b].protectedKeys={};return m}return{animateChanges:c,setActive:u,setAnimateFunction:o,getState:()=>n,reset:()=>{n=lC(),s=!0}}}function pZ(e,t){return typeof t=="string"?t!==e:Array.isArray(t)?!oO(t,e):!1}function Oo(e=!1){return{isActive:e,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function lC(){return{animate:Oo(!0),whileInView:Oo(),whileHover:Oo(),whileTap:Oo(),whileDrag:Oo(),whileFocus:Oo(),exit:Oo()}}function av(e,t){e.min=t.min,e.max=t.max}function qs(e,t){av(e.x,t.x),av(e.y,t.y)}function cC(e,t){e.translate=t.translate,e.scale=t.scale,e.originPoint=t.originPoint,e.origin=t.origin}const lO=1e-4,mZ=1-lO,gZ=1+lO,cO=.01,yZ=0-cO,bZ=0+cO;function Ri(e){return e.max-e.min}function xZ(e,t,n){return Math.abs(e-t)<=n}function uC(e,t,n,i=.5){e.origin=i,e.originPoint=cn(t.min,t.max,e.origin),e.scale=Ri(n)/Ri(t),e.translate=cn(n.min,n.max,e.origin)-e.originPoint,(e.scale>=mZ&&e.scale<=gZ||isNaN(e.scale))&&(e.scale=1),(e.translate>=yZ&&e.translate<=bZ||isNaN(e.translate))&&(e.translate=0)}function Td(e,t,n,i){uC(e.x,t.x,n.x,i?i.originX:void 0),uC(e.y,t.y,n.y,i?i.originY:void 0)}function dC(e,t,n,i=0){const s=i?cn(n.min,n.max,i):n.min;e.min=s+t.min,e.max=e.min+Ri(t)}function vZ(e,t,n,i){dC(e.x,t.x,n.x,i==null?void 0:i.x),dC(e.y,t.y,n.y,i==null?void 0:i.y)}function fC(e,t,n,i=0){const s=i?cn(n.min,n.max,i):n.min;e.min=t.min-s,e.max=e.min+Ri(t)}function pm(e,t,n,i){fC(e.x,t.x,n.x,i==null?void 0:i.x),fC(e.y,t.y,n.y,i==null?void 0:i.y)}function hC(e,t,n,i,s){return e-=t,e=hm(e,1/n,i),s!==void 0&&(e=hm(e,1/s,i)),e}function wZ(e,t=0,n=1,i=.5,s,r=e,o=e){if(Er.test(t)&&(t=parseFloat(t),t=cn(o.min,o.max,t/100)-o.min),typeof t!="number")return;let c=cn(r.min,r.max,i);e===r&&(c-=t),e.min=hC(e.min,t,n,c,s),e.max=hC(e.max,t,n,c,s)}function pC(e,t,[n,i,s],r,o){wZ(e,t[n],t[i],t[s],t.scale,r,o)}const EZ=["x","scaleX","originX"],kZ=["y","scaleY","originY"];function mC(e,t,n,i){pC(e.x,t,EZ,n?n.x:void 0,i?i.x:void 0),pC(e.y,t,kZ,n?n.y:void 0,i?i.y:void 0)}function gC(e){return e.translate===0&&e.scale===1}function uO(e){return gC(e.x)&&gC(e.y)}function yC(e,t){return e.min===t.min&&e.max===t.max}function SZ(e,t){return yC(e.x,t.x)&&yC(e.y,t.y)}function bC(e,t){return Math.round(e.min)===Math.round(t.min)&&Math.round(e.max)===Math.round(t.max)}function dO(e,t){return bC(e.x,t.x)&&bC(e.y,t.y)}function xC(e){return Ri(e.x)/Ri(e.y)}function vC(e,t){return e.translate===t.translate&&e.scale===t.scale&&e.originPoint===t.originPoint}function gr(e){return[e("x"),e("y")]}function NZ(e,t,n){let i="";const s=e.x.translate/t.x,r=e.y.translate/t.y,o=(n==null?void 0:n.z)||0;if((s||r||o)&&(i=`translate3d(${s}px, ${r}px, ${o}px) `),(t.x!==1||t.y!==1)&&(i+=`scale(${1/t.x}, ${1/t.y}) `),n){const{transformPerspective:f,rotate:p,pathRotation:m,rotateX:y,rotateY:b,skewX:x,skewY:v}=n;f&&(i=`perspective(${f}px) ${i}`),p&&(i+=`rotate(${p}deg) `),m&&(i+=`rotate(${m}deg) `),y&&(i+=`rotateX(${y}deg) `),b&&(i+=`rotateY(${b}deg) `),x&&(i+=`skewX(${x}deg) `),v&&(i+=`skewY(${v}deg) `)}const c=e.x.scale*t.x,u=e.y.scale*t.y;return(c!==1||u!==1)&&(i+=`scale(${c}, ${u})`),i||"none"}const _Z=K1.length,wC=e=>typeof e=="string"?parseFloat(e):e,EC=e=>typeof e=="number"||Ge.test(e);function CZ(e,t,n,i,s,r){s?(e.opacity=cn(0,n.opacity??1,TZ(i)),e.opacityExit=cn(t.opacity??1,0,AZ(i))):r&&(e.opacity=cn(t.opacity??1,n.opacity??1,i));for(let o=0;o<_Z;o++){const c=K1[o];let u=kC(t,c),f=kC(n,c);if(u===void 0&&f===void 0)continue;u||(u=0),f||(f=0),u===0||f===0||EC(u)===EC(f)?(e[c]=Math.max(cn(wC(u),wC(f),i),0),(Er.test(f)||Er.test(u))&&(e[c]+="%")):e[c]=f}(t.rotate||n.rotate)&&(e.rotate=cn(t.rotate||0,n.rotate||0,i))}function kC(e,t){return e[t]!==void 0?e[t]:e.borderRadius}const TZ=fO(0,.5,rD),AZ=fO(.5,.95,Cs);function fO(e,t,n){return i=>i<e?0:i>t?1:n(Bd(e,t,i))}function jZ(e,t,n){const i=gi(e)?e:qc(e);return i.start(q1("",i,t,n)),i.animation}function $d(e,t,n,i={passive:!0}){return e.addEventListener(t,n,i),()=>e.removeEventListener(t,n,i)}const MZ=(e,t)=>e.depth-t.depth;class RZ{constructor(){this.children=[],this.isDirty=!1}add(t){j1(this.children,t),this.isDirty=!0}remove(t){am(this.children,t),this.isDirty=!0}forEach(t){this.isDirty&&this.children.sort(MZ),this.isDirty=!1,this.children.forEach(t)}}function DZ(e,t){const n=Mi.now(),i=({timestamp:s})=>{const r=s-n;r>=t&&(lo(i),e(r-t))};return un.setup(i,!0),()=>lo(i)}function Lp(e){return gi(e)?e.get():e}class OZ{constructor(){this.members=[]}add(t){j1(this.members,t);for(let n=this.members.length-1;n>=0;n--){const i=this.members[n];if(i===t||i===this.lead||i===this.prevLead)continue;const s=i.instance;(!s||s.isConnected===!1)&&!i.snapshot&&(am(this.members,i),i.unmount())}t.scheduleRender()}remove(t){if(am(this.members,t),t===this.prevLead&&(this.prevLead=void 0),t===this.lead){const n=this.members[this.members.length-1];n&&this.promote(n)}}relegate(t){var n;for(let i=this.members.indexOf(t)-1;i>=0;i--){const s=this.members[i];if(s.isPresent!==!1&&((n=s.instance)==null?void 0:n.isConnected)!==!1)return this.promote(s),!0}return!1}promote(t,n){var s;const i=this.lead;if(t!==i&&(this.prevLead=i,this.lead=t,t.show(),i)){i.updateSnapshot(),t.scheduleRender();const{layoutDependency:r}=i.options,{layoutDependency:o}=t.options;(r===void 0||r!==o)&&(t.resumeFrom=i,n&&(i.preserveOpacity=!0),i.snapshot&&(t.snapshot=i.snapshot,t.snapshot.latestValues=i.animationValues||i.latestValues),(s=t.root)!=null&&s.isUpdating&&(t.isLayoutDirty=!0)),t.options.crossfade===!1&&i.hide()}}exitAnimationComplete(){this.members.forEach(t=>{var n,i,s,r,o;(i=(n=t.options).onExitComplete)==null||i.call(n),(o=(s=t.resumingFrom)==null?void 0:(r=s.options).onExitComplete)==null||o.call(r)})}scheduleRender(){this.members.forEach(t=>t.instance&&t.scheduleRender(!1))}removeLeadSnapshot(){var t;(t=this.lead)!=null&&t.snapshot&&(this.lead.snapshot=void 0)}}const Ip={hasAnimatedSinceResize:!0,hasEverUpdated:!1},hx=["","X","Y","Z"],LZ=1e3;let IZ=0;function px(e,t,n,i){const{latestValues:s}=t;s[e]&&(n[e]=s[e],t.setStaticValue(e,0),i&&(i[e]=0))}function hO(e){if(e.hasCheckedOptimisedAppear=!0,e.root===e)return;const{visualElement:t}=e.options;if(!t)return;const n=ID(t);if(window.MotionHasOptimisedAnimation(n,"transform")){const{layout:s,layoutId:r}=e.options;window.MotionCancelOptimisedAnimation(n,"transform",un,!(s||r))}const{parent:i}=e;i&&!i.hasCheckedOptimisedAppear&&hO(i)}function pO({attachResizeListener:e,defaultParent:t,measureScroll:n,checkIsScrollRoot:i,resetTransform:s}){return class{constructor(o={},c=t==null?void 0:t()){this.id=IZ++,this.animationId=0,this.animationCommitId=0,this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.isProjectionDirty=!1,this.isSharedProjectionDirty=!1,this.isTransformDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.hasCheckedOptimisedAppear=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.hasTreeAnimated=!1,this.layoutVersion=0,this.updateScheduled=!1,this.scheduleUpdate=()=>this.update(),this.projectionUpdateScheduled=!1,this.checkUpdateFailed=()=>{this.isUpdating&&(this.isUpdating=!1,this.clearAllSnapshots())},this.updateProjection=()=>{this.projectionUpdateScheduled=!1,this.nodes.forEach(BZ),this.nodes.forEach(VZ),this.nodes.forEach(KZ),this.nodes.forEach(UZ)},this.resolvedRelativeTargetAt=0,this.linkedParentVersion=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=o,this.root=c?c.root||c:this,this.path=c?[...c.path,c]:[],this.parent=c,this.depth=c?c.depth+1:0;for(let u=0;u<this.path.length;u++)this.path[u].shouldResetTransform=!0;this.root===this&&(this.nodes=new RZ)}addEventListener(o,c){return this.eventHandlers.has(o)||this.eventHandlers.set(o,new R1),this.eventHandlers.get(o).add(c)}notifyListeners(o,...c){const u=this.eventHandlers.get(o);u&&u.notify(...c)}hasListeners(o){return this.eventHandlers.has(o)}mount(o){if(this.instance)return;this.isSVG=X1(o)&&!zQ(o),this.instance=o;const{layoutId:c,layout:u,visualElement:f}=this.options;if(f&&!f.current&&f.mount(o),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),this.root.hasTreeAnimated&&(u||c)&&(this.isLayoutDirty=!0),e){let p,m=0;const y=()=>this.root.updateBlockedByResize=!1;un.read(()=>{m=window.innerWidth}),e(o,()=>{const b=window.innerWidth;b!==m&&(m=b,this.root.updateBlockedByResize=!0,p&&p(),p=DZ(y,250),Ip.hasAnimatedSinceResize&&(Ip.hasAnimatedSinceResize=!1,this.nodes.forEach(_C)))})}c&&this.root.registerSharedNode(c,this),this.options.animate!==!1&&f&&(c||u)&&this.addEventListener("didUpdate",({delta:p,hasLayoutChanged:m,hasRelativeLayoutChanged:y,layout:b})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const x=this.options.transition||f.getDefaultTransition()||QZ,{onLayoutAnimationStart:v,onLayoutAnimationComplete:w}=f.getProps(),k=!this.targetLayout||!dO(this.targetLayout,b),C=!m&&y;if(this.options.layoutRoot||this.resumeFrom||C||m&&(k||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);const S={...$1(x,"layout"),onPlay:v,onComplete:w};(f.shouldReduceMotion||this.options.layoutRoot)&&(S.delay=0,S.type=!1),this.startAnimation(S),this.setAnimationOrigin(p,C,S.path)}else m||_C(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=b})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);const o=this.getStack();o&&o.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),lo(this.updateProjection)}blockUpdate(){this.updateManuallyBlocked=!0}unblockUpdate(){this.updateManuallyBlocked=!1}isUpdateBlocked(){return this.updateManuallyBlocked||this.updateBlockedByResize}isTreeAnimationBlocked(){return this.isAnimationBlocked||this.parent&&this.parent.isTreeAnimationBlocked()||!1}startUpdate(){this.isUpdateBlocked()||(this.isUpdating=!0,this.nodes&&this.nodes.forEach(GZ),this.animationId++)}getTransformTemplate(){const{visualElement:o}=this.options;return o&&o.getProps().transformTemplate}willUpdate(o=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&hO(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let p=0;p<this.path.length;p++){const m=this.path[p];m.shouldResetTransform=!0,(typeof m.latestValues.x=="string"||typeof m.latestValues.y=="string")&&(m.isLayoutDirty=!0),m.updateScroll("snapshot"),m.options.layoutRoot&&m.willUpdate(!1)}const{layoutId:c,layout:u}=this.options;if(c===void 0&&!u)return;const f=this.getTransformTemplate();this.prevTransformTemplateValue=f?f(this.latestValues,""):void 0,this.updateSnapshot(),o&&this.notifyListeners("willUpdate")}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){const u=this.updateBlockedByResize;this.unblockUpdate(),this.updateBlockedByResize=!1,this.clearAllSnapshots(),u&&this.nodes.forEach($Z),this.nodes.forEach(SC);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(NC);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(qZ),this.nodes.forEach(HZ),this.nodes.forEach(PZ),this.nodes.forEach(zZ)):this.nodes.forEach(NC),this.clearAllSnapshots();const c=Mi.now();mi.delta=Nr(0,1e3/60,c-mi.timestamp),mi.timestamp=c,mi.isProcessing=!0,rx.update.process(mi),rx.preRender.process(mi),rx.render.process(mi),mi.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,W1.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(FZ),this.sharedNodes.forEach(WZ)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,un.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){un.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!Ri(this.snapshot.measuredBox.x)&&!Ri(this.snapshot.measuredBox.y)&&(this.snapshot=void 0))}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let u=0;u<this.path.length;u++)this.path[u].updateScroll();const o=this.layout;this.layout=this.measure(!1),this.layoutVersion++,this.layoutCorrected||(this.layoutCorrected=Jn()),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners("measure",this.layout.layoutBox);const{visualElement:c}=this.options;c&&c.notify("LayoutMeasure",this.layout.layoutBox,o?o.layoutBox:void 0)}updateScroll(o="measure"){let c=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===o&&(c=!1),c&&this.instance){const u=i(this.instance);this.scroll={animationId:this.root.animationId,phase:o,isRoot:u,offset:n(this.instance),wasRoot:this.scroll?this.scroll.isRoot:u}}}resetTransform(){if(!s)return;const o=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,c=this.projectionDelta&&!uO(this.projectionDelta),u=this.getTransformTemplate(),f=u?u(this.latestValues,""):void 0,p=f!==this.prevTransformTemplateValue;o&&this.instance&&(c||Bo(this.latestValues)||p)&&(s(this.instance,f),this.shouldResetTransform=!1,this.scheduleRender())}measure(o=!0){const c=this.measurePageBox();let u=this.removeElementScroll(c);return o&&(u=this.removeTransform(u)),ZZ(u),{animationId:this.root.animationId,measuredBox:c,layoutBox:u,latestValues:{},source:this.id}}measurePageBox(){var f;const{visualElement:o}=this.options;if(!o)return Jn();const c=o.measureViewportBox();if(!(((f=this.scroll)==null?void 0:f.wasRoot)||this.path.some(JZ))){const{scroll:p}=this.root;p&&(vr(c.x,p.offset.x),vr(c.y,p.offset.y))}return c}removeElementScroll(o){var u;const c=Jn();if(qs(c,o),(u=this.scroll)!=null&&u.wasRoot)return c;for(let f=0;f<this.path.length;f++){const p=this.path[f],{scroll:m,options:y}=p;p!==this.root&&m&&y.layoutScroll&&(m.wasRoot&&qs(c,o),vr(c.x,m.offset.x),vr(c.y,m.offset.y))}return c}applyTransform(o,c=!1,u){var p,m;const f=u||Jn();qs(f,o);for(let y=0;y<this.path.length;y++){const b=this.path[y];!c&&b.options.layoutScroll&&b.scroll&&b!==b.root&&(vr(f.x,-b.scroll.offset.x),vr(f.y,-b.scroll.offset.y)),Bo(b.latestValues)&&Op(f,b.latestValues,(p=b.layout)==null?void 0:p.layoutBox)}return Bo(this.latestValues)&&Op(f,this.latestValues,(m=this.layout)==null?void 0:m.layoutBox),f}removeTransform(o){var u;const c=Jn();qs(c,o);for(let f=0;f<this.path.length;f++){const p=this.path[f];if(!Bo(p.latestValues))continue;let m;p.instance&&(iv(p.latestValues)&&p.updateSnapshot(),m=Jn(),qs(m,p.measurePageBox())),mC(c,p.latestValues,(u=p.snapshot)==null?void 0:u.layoutBox,m)}return Bo(this.latestValues)&&mC(c,this.latestValues),c}setTargetDelta(o){this.targetDelta=o,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(o){this.options={...this.options,...o,crossfade:o.crossfade!==void 0?o.crossfade:!0}}clearMeasurements(){this.scroll=void 0,this.layout=void 0,this.snapshot=void 0,this.prevTransformTemplateValue=void 0,this.targetDelta=void 0,this.target=void 0,this.isLayoutDirty=!1}forceRelativeParentToResolveTarget(){this.relativeParent&&this.relativeParent.resolvedRelativeTargetAt!==mi.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(o=!1){var b;const c=this.getLead();this.isProjectionDirty||(this.isProjectionDirty=c.isProjectionDirty),this.isTransformDirty||(this.isTransformDirty=c.isTransformDirty),this.isSharedProjectionDirty||(this.isSharedProjectionDirty=c.isSharedProjectionDirty);const u=!!this.resumingFrom||this!==c;if(!(o||u&&this.isSharedProjectionDirty||this.isProjectionDirty||(b=this.parent)!=null&&b.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;const{layout:p,layoutId:m}=this.options;if(!this.layout||!(p||m))return;this.resolvedRelativeTargetAt=mi.timestamp;const y=this.getClosestProjectingParent();y&&this.linkedParentVersion!==y.layoutVersion&&!y.options.layoutRoot&&this.removeRelativeTarget(),!this.targetDelta&&!this.relativeTarget&&(this.options.layoutAnchor!==!1&&y&&y.layout?this.createRelativeTarget(y,this.layout.layoutBox,y.layout.layoutBox):this.removeRelativeTarget()),!(!this.relativeTarget&&!this.targetDelta)&&(this.target||(this.target=Jn(),this.targetWithTransforms=Jn()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),vZ(this.target,this.relativeTarget,this.relativeParent.target,this.options.layoutAnchor||void 0)):this.targetDelta?(this.resumingFrom?this.applyTransform(this.layout.layoutBox,!1,this.target):qs(this.target,this.layout.layoutBox),ZD(this.target,this.targetDelta)):qs(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget&&(this.attemptToResolveRelativeTarget=!1,this.options.layoutAnchor!==!1&&y&&!!y.resumingFrom==!!this.resumingFrom&&!y.options.layoutScroll&&y.target&&this.animationProgress!==1?this.createRelativeTarget(y,this.target,y.target):this.relativeParent=this.relativeTarget=void 0))}getClosestProjectingParent(){if(!(!this.parent||iv(this.parent.latestValues)||QD(this.parent.latestValues)))return this.parent.isProjecting()?this.parent:this.parent.getClosestProjectingParent()}isProjecting(){return!!((this.relativeTarget||this.targetDelta||this.options.layoutRoot)&&this.layout)}createRelativeTarget(o,c,u){this.relativeParent=o,this.linkedParentVersion=o.layoutVersion,this.forceRelativeParentToResolveTarget(),this.relativeTarget=Jn(),this.relativeTargetOrigin=Jn(),pm(this.relativeTargetOrigin,c,u,this.options.layoutAnchor||void 0),qs(this.relativeTarget,this.relativeTargetOrigin)}removeRelativeTarget(){this.relativeParent=this.relativeTarget=void 0}calcProjection(){var x;const o=this.getLead(),c=!!this.resumingFrom||this!==o;let u=!0;if((this.isProjectionDirty||(x=this.parent)!=null&&x.isProjectionDirty)&&(u=!1),c&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(u=!1),this.resolvedRelativeTargetAt===mi.timestamp&&(u=!1),u)return;const{layout:f,layoutId:p}=this.options;if(this.isTreeAnimating=!!(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!(f||p))return;qs(this.layoutCorrected,this.layout.layoutBox);const m=this.treeScale.x,y=this.treeScale.y;YQ(this.layoutCorrected,this.treeScale,this.path,c),o.layout&&!o.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(o.target=o.layout.layoutBox,o.targetWithTransforms=Jn());const{target:b}=o;if(!b){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(cC(this.prevProjectionDelta.x,this.projectionDelta.x),cC(this.prevProjectionDelta.y,this.projectionDelta.y)),Td(this.projectionDelta,this.layoutCorrected,b,this.latestValues),(this.treeScale.x!==m||this.treeScale.y!==y||!vC(this.projectionDelta.x,this.prevProjectionDelta.x)||!vC(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners("projectionUpdate",b))}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(o=!0){var c;if((c=this.options.visualElement)==null||c.scheduleRender(),o){const u=this.getStack();u&&u.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=hc(),this.projectionDelta=hc(),this.projectionDeltaWithTransform=hc()}setAnimationOrigin(o,c=!1,u){const f=this.snapshot,p=f?f.latestValues:{},m={...this.latestValues},y=hc();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!c;const b=Jn(),x=f?f.source:void 0,v=this.layout?this.layout.source:void 0,w=x!==v,k=this.getStack(),C=!k||k.members.length<=1,S=!!(w&&!C&&this.options.crossfade===!0&&!this.path.some(XZ));this.animationProgress=0;let T;const A=u==null?void 0:u.interpolateProjection(o);this.mixTargetDelta=j=>{const M=j/1e3,D=A==null?void 0:A(M);D?(y.x.translate=D.x,y.x.scale=cn(o.x.scale,1,M),y.x.origin=o.x.origin,y.x.originPoint=o.x.originPoint,y.y.translate=D.y,y.y.scale=cn(o.y.scale,1,M),y.y.origin=o.y.origin,y.y.originPoint=o.y.originPoint):(CC(y.x,o.x,M),CC(y.y,o.y,M)),this.setTargetDelta(y),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(pm(b,this.layout.layoutBox,this.relativeParent.layout.layoutBox,this.options.layoutAnchor||void 0),YZ(this.relativeTarget,this.relativeTargetOrigin,b,M),T&&SZ(this.relativeTarget,T)&&(this.isProjectionDirty=!1),T||(T=Jn()),qs(T,this.relativeTarget)),w&&(this.animationValues=m,CZ(m,p,this.latestValues,M,S,C)),D&&D.rotate!==void 0&&(this.animationValues||(this.animationValues=m),this.animationValues.pathRotation=D.rotate),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=M},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(o){var c,u,f;this.notifyListeners("animationStart"),(c=this.currentAnimation)==null||c.stop(),(f=(u=this.resumingFrom)==null?void 0:u.currentAnimation)==null||f.stop(),this.pendingAnimation&&(lo(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=un.update(()=>{Ip.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=qc(0)),this.motionValue.jump(0,!1),this.currentAnimation=jZ(this.motionValue,[0,1e3],{...o,velocity:0,isSync:!0,onUpdate:p=>{this.mixTargetDelta(p),o.onUpdate&&o.onUpdate(p)},onComplete:()=>{o.onComplete&&o.onComplete(),this.completeAnimation()}}),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0})}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0);const o=this.getStack();o&&o.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(LZ),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const o=this.getLead();let{targetWithTransforms:c,target:u,layout:f,latestValues:p}=o;if(!(!c||!u||!f)){if(this!==o&&this.layout&&f&&mO(this.options.animationType,this.layout.layoutBox,f.layoutBox)){u=this.target||Jn();const m=Ri(this.layout.layoutBox.x);u.x.min=o.target.x.min,u.x.max=u.x.min+m;const y=Ri(this.layout.layoutBox.y);u.y.min=o.target.y.min,u.y.max=u.y.min+y}qs(c,u),Op(c,p),Td(this.projectionDeltaWithTransform,this.layoutCorrected,c,p)}}registerSharedNode(o,c){this.sharedNodes.has(o)||this.sharedNodes.set(o,new OZ),this.sharedNodes.get(o).add(c);const f=c.options.initialPromotionConfig;c.promote({transition:f?f.transition:void 0,preserveFollowOpacity:f&&f.shouldPreserveFollowOpacity?f.shouldPreserveFollowOpacity(c):void 0})}isLead(){const o=this.getStack();return o?o.lead===this:!0}getLead(){var c;const{layoutId:o}=this.options;return o?((c=this.getStack())==null?void 0:c.lead)||this:this}getPrevLead(){var c;const{layoutId:o}=this.options;return o?(c=this.getStack())==null?void 0:c.prevLead:void 0}getStack(){const{layoutId:o}=this.options;if(o)return this.root.sharedNodes.get(o)}promote({needsReset:o,transition:c,preserveFollowOpacity:u}={}){const f=this.getStack();f&&f.promote(this,u),o&&(this.projectionDelta=void 0,this.needsReset=!0),c&&this.setOptions({transition:c})}relegate(){const o=this.getStack();return o?o.relegate(this):!1}resetSkewAndRotation(){const{visualElement:o}=this.options;if(!o)return;let c=!1;const{latestValues:u}=o;if((u.z||u.rotate||u.rotateX||u.rotateY||u.rotateZ||u.skewX||u.skewY)&&(c=!0),!c)return;const f={};u.z&&px("z",o,f,this.animationValues);for(let p=0;p<hx.length;p++)px(`rotate${hx[p]}`,o,f,this.animationValues),px(`skew${hx[p]}`,o,f,this.animationValues);o.render();for(const p in f)o.setStaticValue(p,f[p]),this.animationValues&&(this.animationValues[p]=f[p]);o.scheduleRender()}applyProjectionStyles(o,c){if(!this.instance||this.isSVG)return;if(!this.isVisible){o.visibility="hidden";return}const u=this.getTransformTemplate();if(this.needsReset){this.needsReset=!1,o.visibility="",o.opacity="",o.pointerEvents=Lp(c==null?void 0:c.pointerEvents)||"",o.transform=u?u(this.latestValues,""):"none";return}const f=this.getLead();if(!this.projectionDelta||!this.layout||!f.target){this.options.layoutId&&(o.opacity=this.latestValues.opacity!==void 0?this.latestValues.opacity:1,o.pointerEvents=Lp(c==null?void 0:c.pointerEvents)||""),this.hasProjected&&!Bo(this.latestValues)&&(o.transform=u?u({},""):"none",this.hasProjected=!1);return}o.visibility="";const p=f.animationValues||f.latestValues;this.applyTransformsToTarget();let m=NZ(this.projectionDeltaWithTransform,this.treeScale,p);u&&(m=u(p,m)),o.transform=m;const{x:y,y:b}=this.projectionDelta;o.transformOrigin=`${y.origin*100}% ${b.origin*100}% 0`,f.animationValues?o.opacity=f===this?p.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:p.opacityExit:o.opacity=f===this?p.opacity!==void 0?p.opacity:"":p.opacityExit!==void 0?p.opacityExit:0;for(const x in rv){if(p[x]===void 0)continue;const{correct:v,applyTo:w,isCSSVariable:k}=rv[x],C=m==="none"?p[x]:v(p[x],f);if(w){const S=w.length;for(let T=0;T<S;T++)o[w[T]]=C}else k?this.options.visualElement.renderState.vars[x]=C:o[x]=C}this.options.layoutId&&(o.pointerEvents=f===this?Lp(c==null?void 0:c.pointerEvents)||"":"none")}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(o=>{var c;return(c=o.currentAnimation)==null?void 0:c.stop()}),this.root.nodes.forEach(SC),this.root.sharedNodes.clear()}}}function PZ(e){e.updateLayout()}function zZ(e){var n;const t=((n=e.resumeFrom)==null?void 0:n.snapshot)||e.snapshot;if(e.isLead()&&e.layout&&t&&e.hasListeners("didUpdate")){const{layoutBox:i,measuredBox:s}=e.layout,{animationType:r}=e.options,o=t.source!==e.layout.source;if(r==="size")gr(m=>{const y=o?t.measuredBox[m]:t.layoutBox[m],b=Ri(y);y.min=i[m].min,y.max=y.min+b});else if(r==="x"||r==="y"){const m=r==="x"?"y":"x";av(o?t.measuredBox[m]:t.layoutBox[m],i[m])}else mO(r,t.layoutBox,i)&&gr(m=>{const y=o?t.measuredBox[m]:t.layoutBox[m],b=Ri(i[m]);y.max=y.min+b,e.relativeTarget&&!e.currentAnimation&&(e.isProjectionDirty=!0,e.relativeTarget[m].max=e.relativeTarget[m].min+b)});const c=hc();Td(c,i,t.layoutBox);const u=hc();o?Td(u,e.applyTransform(s,!0),t.measuredBox):Td(u,i,t.layoutBox);const f=!uO(c);let p=!1;if(!e.resumeFrom){const m=e.getClosestProjectingParent();if(m&&!m.resumeFrom){const{snapshot:y,layout:b}=m;if(y&&b){const x=e.options.layoutAnchor||void 0,v=Jn();pm(v,t.layoutBox,y.layoutBox,x);const w=Jn();pm(w,i,b.layoutBox,x),dO(v,w)||(p=!0),m.options.layoutRoot&&(e.relativeTarget=w,e.relativeTargetOrigin=v,e.relativeParent=m)}}}e.notifyListeners("didUpdate",{layout:i,snapshot:t,delta:u,layoutDelta:c,hasLayoutChanged:f,hasRelativeLayoutChanged:p})}else if(e.isLead()){const{onExitComplete:i}=e.options;i&&i()}e.options.transition=void 0}function BZ(e){e.parent&&(e.isProjecting()||(e.isProjectionDirty=e.parent.isProjectionDirty),e.isSharedProjectionDirty||(e.isSharedProjectionDirty=!!(e.isProjectionDirty||e.parent.isProjectionDirty||e.parent.isSharedProjectionDirty)),e.isTransformDirty||(e.isTransformDirty=e.parent.isTransformDirty))}function UZ(e){e.isProjectionDirty=e.isSharedProjectionDirty=e.isTransformDirty=!1}function FZ(e){e.clearSnapshot()}function SC(e){e.clearMeasurements()}function $Z(e){e.isLayoutDirty=!0,e.updateLayout()}function NC(e){e.isLayoutDirty=!1}function qZ(e){e.isAnimationBlocked&&e.layout&&!e.isLayoutDirty&&(e.snapshot=e.layout,e.isLayoutDirty=!0)}function HZ(e){const{visualElement:t}=e.options;t&&t.getProps().onBeforeLayoutMeasure&&t.notify("BeforeLayoutMeasure"),e.resetTransform()}function _C(e){e.finishAnimation(),e.targetDelta=e.relativeTarget=e.target=void 0,e.isProjectionDirty=!0}function VZ(e){e.resolveTargetDelta()}function KZ(e){e.calcProjection()}function GZ(e){e.resetSkewAndRotation()}function WZ(e){e.removeLeadSnapshot()}function CC(e,t,n){e.translate=cn(t.translate,0,n),e.scale=cn(t.scale,1,n),e.origin=t.origin,e.originPoint=t.originPoint}function TC(e,t,n,i){e.min=cn(t.min,n.min,i),e.max=cn(t.max,n.max,i)}function YZ(e,t,n,i){TC(e.x,t.x,n.x,i),TC(e.y,t.y,n.y,i)}function XZ(e){return e.animationValues&&e.animationValues.opacityExit!==void 0}const QZ={duration:.45,ease:[.4,0,.1,1]},AC=e=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(e),jC=AC("applewebkit/")&&!AC("chrome/")?Math.round:Cs;function MC(e){e.min=jC(e.min),e.max=jC(e.max)}function ZZ(e){MC(e.x),MC(e.y)}function mO(e,t,n){return e==="position"||e==="preserve-aspect"&&!xZ(xC(t),xC(n),.2)}function JZ(e){var t;return e!==e.root&&((t=e.scroll)==null?void 0:t.wasRoot)}const eJ=pO({attachResizeListener:(e,t)=>$d(e,"resize",t),measureScroll:()=>{var e,t;return{x:document.documentElement.scrollLeft||((e=document.body)==null?void 0:e.scrollLeft)||0,y:document.documentElement.scrollTop||((t=document.body)==null?void 0:t.scrollTop)||0}},checkIsScrollRoot:()=>!0}),mx={current:void 0},gO=pO({measureScroll:e=>({x:e.scrollLeft,y:e.scrollTop}),defaultParent:()=>{if(!mx.current){const e=new eJ({});e.mount(window),e.setOptions({layoutScroll:!0}),mx.current=e}return mx.current},resetTransform:(e,t)=>{e.style.transform=t!==void 0?t:"none"},checkIsScrollRoot:e=>window.getComputedStyle(e).position==="fixed"}),yO=_.createContext({transformPagePoint:e=>e,isStatic:!1,reducedMotion:"never"});function tJ(e=!0){const t=_.useContext(A1);if(t===null)return[!0,null];const{isPresent:n,onExitComplete:i,register:s}=t,r=_.useId();_.useEffect(()=>{if(e)return s(r)},[e]);const o=_.useCallback(()=>e&&i&&i(r),[r,i,e]);return!n&&i?[!1,o]:[!0]}const bO=_.createContext({strict:!1}),RC={animation:["animate","variants","whileHover","whileTap","exit","whileInView","whileFocus","whileDrag"],exit:["exit"],drag:["drag","dragControls"],focus:["whileFocus"],hover:["whileHover","onHoverStart","onHoverEnd"],tap:["whileTap","onTap","onTapStart","onTapCancel"],pan:["onPan","onPanStart","onPanSessionStart","onPanEnd"],inView:["whileInView","onViewportEnter","onViewportLeave"],layout:["layout","layoutId"]};let DC=!1;function nJ(){if(DC)return;const e={};for(const t in RC)e[t]={isEnabled:n=>RC[t].some(i=>!!n[i])};WD(e),DC=!0}function xO(){return nJ(),VQ()}function iJ(e){const t=xO();for(const n in e)t[n]={...t[n],...e[n]};WD(t)}const sJ=new Set(["animate","exit","variants","initial","style","values","variants","transition","transformTemplate","custom","inherit","onBeforeLayoutMeasure","onAnimationStart","onAnimationComplete","onUpdate","onDragStart","onDrag","onDragEnd","onMeasureDragConstraints","onDirectionLock","onDragTransitionEnd","_dragX","_dragY","onHoverStart","onHoverEnd","onViewportEnter","onViewportLeave","globalTapTarget","propagate","ignoreStrict","viewport"]);function mm(e){return e.startsWith("while")||e.startsWith("drag")&&e!=="draggable"||e.startsWith("layout")||e.startsWith("onTap")||e.startsWith("onPan")||e.startsWith("onLayout")||sJ.has(e)}let vO=e=>!mm(e);function rJ(e){typeof e=="function"&&(vO=t=>t.startsWith("on")?!mm(t):e(t))}try{rJ(require("@emotion/is-prop-valid").default)}catch{}function aJ(e,t,n){const i={};for(const s in e)s==="values"&&typeof e.values=="object"||gi(e[s])||(vO(s)||n===!0&&mm(s)||!t&&!mm(s)||e.draggable&&s.startsWith("onDrag"))&&(i[s]=e[s]);return i}const Km=_.createContext({});function oJ(e,t){if(Vm(e)){const{initial:n,animate:i}=e;return{initial:n===!1||Fd(n)?n:void 0,animate:Fd(i)?i:void 0}}return e.inherit!==!1?t:{}}function lJ(e){const{initial:t,animate:n}=oJ(e,_.useContext(Km));return _.useMemo(()=>({initial:t,animate:n}),[OC(t),OC(n)])}function OC(e){return Array.isArray(e)?e.join(" "):e}const tw=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function wO(e,t,n){for(const i in t)!gi(t[i])&&!tO(i,n)&&(e[i]=t[i])}function cJ({transformTemplate:e},t){return _.useMemo(()=>{const n=tw();return J1(n,t,e),Object.assign({},n.vars,n.style)},[t])}function uJ(e,t){const n=e.style||{},i={};return wO(i,n,e),Object.assign(i,cJ(e,t)),i}function dJ(e,t){const n={},i=uJ(e,t);return e.drag&&e.dragListener!==!1&&(n.draggable=!1,i.userSelect=i.WebkitUserSelect=i.WebkitTouchCallout="none",i.touchAction=e.drag===!0?"none":`pan-${e.drag==="x"?"y":"x"}`),e.tabIndex===void 0&&(e.onTap||e.onTapStart||e.whileTap)&&(n.tabIndex=0),n.style=i,n}const EO=()=>({...tw(),attrs:{}});function fJ(e,t,n,i){const s=_.useMemo(()=>{const r=EO();return nO(r,t,sO(i),e.transformTemplate,e.style),{...r.attrs,style:{...r.style}}},[t]);if(e.style){const r={};wO(r,e.style,e),s.style={...r,...s.style}}return s}const hJ=["animate","circle","defs","desc","ellipse","g","image","line","filter","marker","mask","metadata","path","pattern","polygon","polyline","rect","stop","switch","symbol","svg","text","tspan","use","view"];function nw(e){return typeof e!="string"||e.includes("-")?!1:!!(hJ.indexOf(e)>-1||/[A-Z]/u.test(e))}function pJ(e,t,n,{latestValues:i},s,r=!1,o){const u=(o??nw(e)?fJ:dJ)(t,i,s,e),f=aJ(t,typeof e=="string",r),p=e!==_.Fragment?{...f,...u,ref:n}:{},{children:m}=t,y=_.useMemo(()=>gi(m)?m.get():m,[m]);return _.createElement(e,{...p,children:y})}function mJ({scrapeMotionValuesFromProps:e,createRenderState:t},n,i,s){return{latestValues:gJ(n,i,s,e),renderState:t()}}function gJ(e,t,n,i){const s={},r=i(e,{});for(const y in r)s[y]=Lp(r[y]);let{initial:o,animate:c}=e;const u=Vm(e),f=KD(e);t&&f&&!u&&e.inherit!==!1&&(o===void 0&&(o=t.initial),c===void 0&&(c=t.animate));let p=n?n.initial===!1:!1;p=p||o===!1;const m=p?c:o;if(m&&typeof m!="boolean"&&!Hm(m)){const y=Array.isArray(m)?m:[m];for(let b=0;b<y.length;b++){const x=H1(e,y[b]);if(x){const{transitionEnd:v,transition:w,...k}=x;for(const C in k){let S=k[C];if(Array.isArray(S)){const T=p?S.length-1:0;S=S[T]}S!==null&&(s[C]=S)}for(const C in v)s[C]=v[C]}}}return s}const kO=e=>(t,n)=>{const i=_.useContext(Km),s=_.useContext(A1),r=()=>mJ(e,t,i,s);return n?r():pY(r)},yJ=kO({scrapeMotionValuesFromProps:ew,createRenderState:tw}),bJ=kO({scrapeMotionValuesFromProps:rO,createRenderState:EO}),xJ=Symbol.for("motionComponentSymbol");function vJ(e,t,n){const i=_.useRef(n);_.useInsertionEffect(()=>{i.current=n});const s=_.useRef(null);return _.useCallback(r=>{var c;r&&((c=e.onMount)==null||c.call(e,r)),t&&(r?t.mount(r):t.unmount());const o=i.current;if(typeof o=="function")if(r){const u=o(r);typeof u=="function"&&(s.current=u)}else s.current?(s.current(),s.current=null):o(r);else o&&(o.current=r)},[t])}const SO=_.createContext({});function uc(e){return e&&typeof e=="object"&&Object.prototype.hasOwnProperty.call(e,"current")}function wJ(e,t,n,i,s,r){var S,T;const{visualElement:o}=_.useContext(Km),c=_.useContext(bO),u=_.useContext(A1),f=_.useContext(yO),p=f.reducedMotion,m=f.skipAnimations,y=_.useRef(null),b=_.useRef(!1);i=i||c.renderer,!y.current&&i&&(y.current=i(e,{visualState:t,parent:o,props:n,presenceContext:u,blockInitialAnimation:u?u.initial===!1:!1,reducedMotionConfig:p,skipAnimations:m,isSVG:r}),b.current&&y.current&&(y.current.manuallyAnimateOnMount=!0));const x=y.current,v=_.useContext(SO);x&&!x.projection&&s&&(x.type==="html"||x.type==="svg")&&EJ(y.current,n,s,v);const w=_.useRef(!1);_.useInsertionEffect(()=>{x&&w.current&&x.update(n,u)});const k=n[LD],C=_.useRef(!!k&&typeof window<"u"&&!((S=window.MotionHandoffIsComplete)!=null&&S.call(window,k))&&((T=window.MotionHasOptimisedAnimation)==null?void 0:T.call(window,k)));return gY(()=>{b.current=!0,x&&(w.current=!0,window.MotionIsMounted=!0,x.updateFeatures(),x.scheduleRenderMicrotask(),C.current&&x.animationState&&x.animationState.animateChanges())}),_.useEffect(()=>{x&&(!C.current&&x.animationState&&x.animationState.animateChanges(),C.current&&(queueMicrotask(()=>{var A;(A=window.MotionHandoffMarkAsComplete)==null||A.call(window,k)}),C.current=!1),x.enteringChildren=void 0)}),x}function EJ(e,t,n,i){const{layoutId:s,layout:r,drag:o,dragConstraints:c,layoutScroll:u,layoutRoot:f,layoutAnchor:p,layoutCrossfade:m}=t;e.projection=new n(e.latestValues,t["data-framer-portal-id"]?void 0:NO(e.parent)),e.projection.setOptions({layoutId:s,layout:r,alwaysMeasureLayout:!!o||c&&uc(c),visualElement:e,animationType:typeof r=="string"?r:"both",initialPromotionConfig:i,crossfade:m,layoutScroll:u,layoutRoot:f,layoutAnchor:p})}function NO(e){if(e)return e.options.allowProjection!==!1?e.projection:NO(e.parent)}function gx(e,{forwardMotionProps:t=!1,type:n}={},i,s){i&&iJ(i);const r=n?n==="svg":nw(e),o=r?bJ:yJ;function c(f,p){let m;const y={..._.useContext(yO),...f,layoutId:kJ(f)},{isStatic:b}=y,x=lJ(f),v=o(f,b);if(!b&&typeof window<"u"){SJ();const w=NJ(y);m=w.MeasureLayout,x.visualElement=wJ(e,v,y,s,w.ProjectionNode,r)}return d.jsxs(Km.Provider,{value:x,children:[m&&x.visualElement?d.jsx(m,{visualElement:x.visualElement,...y}):null,pJ(e,f,vJ(v,x.visualElement,p),v,b,t,r)]})}c.displayName=`motion.${typeof e=="string"?e:`create(${e.displayName??e.name??""})`}`;const u=_.forwardRef(c);return u[xJ]=e,u}function kJ({layoutId:e}){const t=_.useContext(GR).id;return t&&e!==void 0?t+"-"+e:e}function SJ(e,t){_.useContext(bO).strict}function NJ(e){const t=xO(),{drag:n,layout:i}=t;if(!n&&!i)return{};const s={...n,...i};return{MeasureLayout:n!=null&&n.isEnabled(e)||i!=null&&i.isEnabled(e)?s.MeasureLayout:void 0,ProjectionNode:s.ProjectionNode}}function _J(e,t){if(typeof Proxy>"u")return gx;const n=new Map,i=(r,o)=>gx(r,o,e,t),s=(r,o)=>i(r,o);return new Proxy(s,{get:(r,o)=>o==="create"?i:(n.has(o)||n.set(o,gx(o,void 0,e,t)),n.get(o))})}const CJ=(e,t)=>t.isSVG??nw(e)?new lZ(t):new nZ(t,{allowProjection:e!==_.Fragment});class TJ extends po{constructor(t){super(t),t.animationState||(t.animationState=hZ(t))}updateAnimationControlsSubscription(){const{animate:t}=this.node.getProps();Hm(t)&&(this.unmountControls=t.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:t}=this.node.getProps(),{animate:n}=this.node.prevProps||{};t!==n&&this.updateAnimationControlsSubscription()}unmount(){var t;this.node.animationState.reset(),(t=this.unmountControls)==null||t.call(this)}}let AJ=0;class jJ extends po{constructor(){super(...arguments),this.id=AJ++,this.isExitComplete=!1}update(){var r;if(!this.node.presenceContext)return;const{isPresent:t,onExitComplete:n}=this.node.presenceContext,{isPresent:i}=this.node.prevPresenceContext||{};if(!this.node.animationState||t===i)return;if(t&&i===!1){if(this.isExitComplete){const{initial:o,custom:c}=this.node.getProps();if(typeof o=="string"||typeof o=="object"&&o!==null&&!Array.isArray(o)){const u=rl(this.node,o,c);if(u){const{transition:f,transitionEnd:p,...m}=u;for(const y in m)(r=this.node.getValue(y))==null||r.jump(m[y])}}this.node.animationState.reset(),this.node.animationState.animateChanges()}else this.node.animationState.setActive("exit",!1);this.isExitComplete=!1;return}const s=this.node.animationState.setActive("exit",!t);n&&!t&&s.then(()=>{this.isExitComplete=!0,n(this.id)})}mount(){const{register:t,onExitComplete:n}=this.node.presenceContext||{};n&&n(this.id),t&&(this.unmount=t(this.id))}unmount(){}}const MJ={animation:{Feature:TJ},exit:{Feature:jJ}};function kf(e){return{point:{x:e.pageX,y:e.pageY}}}const RJ=e=>t=>Y1(t)&&e(t,kf(t));function Ad(e,t,n,i){return $d(e,t,RJ(n),i)}const _O=({current:e})=>e?e.ownerDocument.defaultView:null,LC=(e,t)=>Math.abs(e-t);function DJ(e,t){const n=LC(e.x,t.x),i=LC(e.y,t.y);return Math.sqrt(n**2+i**2)}const IC=new Set(["auto","scroll"]);class CO{constructor(t,n,{transformPagePoint:i,contextWindow:s=window,dragSnapToOrigin:r=!1,distanceThreshold:o=3,element:c}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.lastRawMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.scrollPositions=new Map,this.removeScrollListeners=null,this.onElementScroll=x=>{this.handleScroll(x.target)},this.onWindowScroll=()=>{this.handleScroll(window)},this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;this.lastRawMoveEventInfo&&(this.lastMoveEventInfo=np(this.lastRawMoveEventInfo,this.transformPagePoint));const x=yx(this.lastMoveEventInfo,this.history),v=this.startEvent!==null,w=DJ(x.offset,{x:0,y:0})>=this.distanceThreshold;if(!v&&!w)return;const{point:k}=x,{timestamp:C}=mi;this.history.push({...k,timestamp:C});const{onStart:S,onMove:T}=this.handlers;v||(S&&S(this.lastMoveEvent,x),this.startEvent=this.lastMoveEvent),T&&T(this.lastMoveEvent,x)},this.handlePointerMove=(x,v)=>{this.lastMoveEvent=x,this.lastRawMoveEventInfo=v,this.lastMoveEventInfo=np(v,this.transformPagePoint),un.update(this.updatePoint,!0)},this.handlePointerUp=(x,v)=>{this.end();const{onEnd:w,onSessionEnd:k,resumeAnimation:C}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&C&&C(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const S=yx(x.type==="pointercancel"?this.lastMoveEventInfo:np(v,this.transformPagePoint),this.history);this.startEvent&&w&&w(x,S),k&&k(x,S)},!Y1(t))return;this.dragSnapToOrigin=r,this.handlers=n,this.transformPagePoint=i,this.distanceThreshold=o,this.contextWindow=s||window;const u=kf(t),f=np(u,this.transformPagePoint),{point:p}=f,{timestamp:m}=mi;this.history=[{...p,timestamp:m}];const{onSessionStart:y}=n;y&&y(t,yx(f,this.history));const b={passive:!0,capture:!0};this.removeListeners=vf(Ad(this.contextWindow,"pointermove",this.handlePointerMove,b),Ad(this.contextWindow,"pointerup",this.handlePointerUp,b),Ad(this.contextWindow,"pointercancel",this.handlePointerUp,b)),c&&this.startScrollTracking(c)}startScrollTracking(t){let n=t.parentElement;for(;n;){const i=getComputedStyle(n);(IC.has(i.overflowX)||IC.has(i.overflowY))&&this.scrollPositions.set(n,{x:n.scrollLeft,y:n.scrollTop}),n=n.parentElement}this.scrollPositions.set(window,{x:window.scrollX,y:window.scrollY}),window.addEventListener("scroll",this.onElementScroll,{capture:!0}),window.addEventListener("scroll",this.onWindowScroll),this.removeScrollListeners=()=>{window.removeEventListener("scroll",this.onElementScroll,{capture:!0}),window.removeEventListener("scroll",this.onWindowScroll)}}handleScroll(t){const n=this.scrollPositions.get(t);if(!n)return;const i=t===window,s=i?{x:window.scrollX,y:window.scrollY}:{x:t.scrollLeft,y:t.scrollTop},r={x:s.x-n.x,y:s.y-n.y};r.x===0&&r.y===0||(i?this.lastMoveEventInfo&&(this.lastMoveEventInfo.point.x+=r.x,this.lastMoveEventInfo.point.y+=r.y):this.history.length>0&&(this.history[0].x-=r.x,this.history[0].y-=r.y),this.scrollPositions.set(t,s),un.update(this.updatePoint,!0))}updateHandlers(t){this.handlers=t}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),lo(this.updatePoint)}}function np(e,t){return t?{point:t(e.point)}:e}function PC(e,t){return{x:e.x-t.x,y:e.y-t.y}}function yx({point:e},t){return{point:e,delta:PC(e,TO(t)),offset:PC(e,OJ(t)),velocity:LJ(t,.1)}}function OJ(e){return e[0]}function TO(e){return e[e.length-1]}function LJ(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,i=null;const s=TO(e);for(;n>=0&&(i=e[n],!(s.timestamp-i.timestamp>os(t)));)n--;if(!i)return{x:0,y:0};i===e[0]&&e.length>2&&s.timestamp-i.timestamp>os(t)*2&&(i=e[1]);const r=_s(s.timestamp-i.timestamp);if(r===0)return{x:0,y:0};const o={x:(s.x-i.x)/r,y:(s.y-i.y)/r};return o.x===1/0&&(o.x=0),o.y===1/0&&(o.y=0),o}function IJ(e,{min:t,max:n},i){return t!==void 0&&e<t?e=i?cn(t,e,i.min):Math.max(e,t):n!==void 0&&e>n&&(e=i?cn(n,e,i.max):Math.min(e,n)),e}function zC(e,t,n){return{min:t!==void 0?e.min+t:void 0,max:n!==void 0?e.max+n-(e.max-e.min):void 0}}function PJ(e,{top:t,left:n,bottom:i,right:s}){return{x:zC(e.x,n,s),y:zC(e.y,t,i)}}function BC(e,t){let n=t.min-e.min,i=t.max-e.max;return t.max-t.min<e.max-e.min&&([n,i]=[i,n]),{min:n,max:i}}function zJ(e,t){return{x:BC(e.x,t.x),y:BC(e.y,t.y)}}function BJ(e,t){let n=.5;const i=Ri(e),s=Ri(t);return s>i?n=Bd(t.min,t.max-i,e.min):i>s&&(n=Bd(e.min,e.max-s,t.min)),Nr(0,1,n)}function UJ(e,t){const n={};return t.min!==void 0&&(n.min=t.min-e.min),t.max!==void 0&&(n.max=t.max-e.min),n}const ov=.35;function FJ(e=ov){return e===!1?e=0:e===!0&&(e=ov),{x:UC(e,"left","right"),y:UC(e,"top","bottom")}}function UC(e,t,n){return{min:FC(e,t),max:FC(e,n)}}function FC(e,t){return typeof e=="number"?e:e[t]||0}const $J=new WeakMap;class qJ{constructor(t){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=Jn(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=t}start(t,{snapToCursor:n=!1,distanceThreshold:i}={}){const{presenceContext:s}=this.visualElement;if(s&&s.isPresent===!1)return;const r=m=>{n&&this.snapToCursor(kf(m).point),this.stopAnimation()},o=(m,y)=>{const{drag:b,dragPropagation:x,onDragStart:v}=this.getProps();if(b&&!x&&(this.openDragLock&&this.openDragLock(),this.openDragLock=wQ(b),!this.openDragLock))return;this.latestPointerEvent=m,this.latestPanInfo=y,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),gr(k=>{let C=this.getAxisMotionValue(k).get()||0;if(Er.test(C)){const{projection:S}=this.visualElement;if(S&&S.layout){const T=S.layout.layoutBox[k];T&&(C=Ri(T)*(parseFloat(C)/100))}}this.originPoint[k]=C}),v&&un.update(()=>v(m,y),!1,!0),Q0(this.visualElement,"transform");const{animationState:w}=this.visualElement;w&&w.setActive("whileDrag",!0)},c=(m,y)=>{this.latestPointerEvent=m,this.latestPanInfo=y;const{dragPropagation:b,dragDirectionLock:x,onDirectionLock:v,onDrag:w}=this.getProps();if(!b&&!this.openDragLock)return;const{offset:k}=y;if(x&&this.currentDirection===null){this.currentDirection=VJ(k),this.currentDirection!==null&&v&&v(this.currentDirection);return}this.updateAxis("x",y.point,k),this.updateAxis("y",y.point,k),this.visualElement.render(),w&&un.update(()=>w(m,y),!1,!0)},u=(m,y)=>{this.latestPointerEvent=m,this.latestPanInfo=y,this.stop(m,y),this.latestPointerEvent=null,this.latestPanInfo=null},f=()=>{const{dragSnapToOrigin:m}=this.getProps();(m||this.constraints)&&this.startAnimation({x:0,y:0})},{dragSnapToOrigin:p}=this.getProps();this.panSession=new CO(t,{onSessionStart:r,onStart:o,onMove:c,onSessionEnd:u,resumeAnimation:f},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:p,distanceThreshold:i,contextWindow:_O(this.visualElement),element:this.visualElement.current})}stop(t,n){const i=t||this.latestPointerEvent,s=n||this.latestPanInfo,r=this.isDragging;if(this.cancel(),!r||!s||!i)return;const{velocity:o}=s;this.startAnimation(o);const{onDragEnd:c}=this.getProps();c&&un.postRender(()=>c(i,s))}cancel(){this.isDragging=!1;const{projection:t,animationState:n}=this.visualElement;t&&(t.isAnimationBlocked=!1),this.endPanSession();const{dragPropagation:i}=this.getProps();!i&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),n&&n.setActive("whileDrag",!1)}endPanSession(){this.panSession&&this.panSession.end(),this.panSession=void 0}updateAxis(t,n,i){const{drag:s}=this.getProps();if(!i||!ip(t,s,this.currentDirection))return;const r=this.getAxisMotionValue(t);let o=this.originPoint[t]+i[t];this.constraints&&this.constraints[t]&&(o=IJ(o,this.constraints[t],this.elastic[t])),r.set(o)}resolveConstraints(){var r;const{dragConstraints:t,dragElastic:n}=this.getProps(),i=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):(r=this.visualElement.projection)==null?void 0:r.layout,s=this.constraints;t&&uc(t)?this.constraints||(this.constraints=this.resolveRefConstraints()):t&&i?this.constraints=PJ(i.layoutBox,t):this.constraints=!1,this.elastic=FJ(n),s!==this.constraints&&!uc(t)&&i&&this.constraints&&!this.hasMutatedConstraints&&gr(o=>{this.constraints!==!1&&this.getAxisMotionValue(o)&&(this.constraints[o]=UJ(i.layoutBox[o],this.constraints[o]))})}resolveRefConstraints(){const{dragConstraints:t,onMeasureDragConstraints:n}=this.getProps();if(!t||!uc(t))return!1;const i=t.current,{projection:s}=this.visualElement;if(!s||!s.layout)return!1;s.root&&(s.root.scroll=void 0,s.root.updateScroll());const r=XQ(i,s.root,this.visualElement.getTransformPagePoint());let o=zJ(s.layout.layoutBox,r);if(n){const c=n(GQ(o));this.hasMutatedConstraints=!!c,c&&(o=XD(c))}return o}startAnimation(t){const{drag:n,dragMomentum:i,dragElastic:s,dragTransition:r,dragSnapToOrigin:o,onDragTransitionEnd:c}=this.getProps(),u=this.constraints||{},f=gr(p=>{if(!ip(p,n,this.currentDirection))return;let m=u&&u[p]||{};(o===!0||o===p)&&(m={min:0,max:0});const y=s?200:1e6,b=s?40:1e7,x={type:"inertia",velocity:i?t[p]:0,bounceStiffness:y,bounceDamping:b,timeConstant:750,restDelta:1,restSpeed:10,...r,...m};return this.startAxisValueAnimation(p,x)});return Promise.all(f).then(c)}startAxisValueAnimation(t,n){const i=this.getAxisMotionValue(t);return Q0(this.visualElement,t),i.start(q1(t,i,0,n,this.visualElement,!1))}stopAnimation(){gr(t=>this.getAxisMotionValue(t).stop())}getAxisMotionValue(t){const n=`_drag${t.toUpperCase()}`,s=this.visualElement.getProps()[n];return s||this.visualElement.getValue(t,this.visualElement.latestValues[t]??0)}snapToCursor(t){gr(n=>{const{drag:i}=this.getProps();if(!ip(n,i,this.currentDirection))return;const{projection:s}=this.visualElement,r=this.getAxisMotionValue(n);if(s&&s.layout){const{min:o,max:c}=s.layout.layoutBox[n],u=r.get()||0;r.set(t[n]-cn(o,c,.5)+u)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:t,dragConstraints:n}=this.getProps(),{projection:i}=this.visualElement;if(!uc(n)||!i||!this.constraints)return;this.stopAnimation();const s={x:0,y:0};gr(o=>{const c=this.getAxisMotionValue(o);if(c&&this.constraints!==!1){const u=c.get();s[o]=BJ({min:u,max:u},this.constraints[o])}});const{transformTemplate:r}=this.visualElement.getProps();this.visualElement.current.style.transform=r?r({},""):"none",i.root&&i.root.updateScroll(),i.updateLayout(),this.constraints=!1,this.resolveConstraints(),gr(o=>{if(!ip(o,t,null))return;const c=this.getAxisMotionValue(o),{min:u,max:f}=this.constraints[o];c.set(cn(u,f,s[o]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;$J.set(this.visualElement,this);const t=this.visualElement.current,n=Ad(t,"pointerdown",f=>{const{drag:p,dragListener:m=!0}=this.getProps(),y=f.target,b=y!==t&&CQ(y);p&&m&&!b&&this.start(f)});let i;const s=()=>{const{dragConstraints:f}=this.getProps();uc(f)&&f.current&&(this.constraints=this.resolveRefConstraints(),i||(i=HJ(t,f.current,()=>this.scalePositionWithinConstraints())))},{projection:r}=this.visualElement,o=r.addEventListener("measure",s);r&&!r.layout&&(r.root&&r.root.updateScroll(),r.updateLayout()),un.read(s);const c=$d(window,"resize",()=>this.scalePositionWithinConstraints()),u=r.addEventListener("didUpdate",(({delta:f,hasLayoutChanged:p})=>{this.isDragging&&p&&(gr(m=>{const y=this.getAxisMotionValue(m);y&&(this.originPoint[m]+=f[m].translate,y.set(y.get()+f[m].translate))}),this.visualElement.render())}));return()=>{c(),n(),o(),u&&u(),i&&i()}}getProps(){const t=this.visualElement.getProps(),{drag:n=!1,dragDirectionLock:i=!1,dragPropagation:s=!1,dragConstraints:r=!1,dragElastic:o=ov,dragMomentum:c=!0}=t;return{...t,drag:n,dragDirectionLock:i,dragPropagation:s,dragConstraints:r,dragElastic:o,dragMomentum:c}}}function $C(e){let t=!0;return()=>{if(t){t=!1;return}e()}}function HJ(e,t,n){const i=Q2(e,$C(n)),s=Q2(t,$C(n));return()=>{i(),s()}}function ip(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function VJ(e,t=10){let n=null;return Math.abs(e.y)>t?n="y":Math.abs(e.x)>t&&(n="x"),n}class KJ extends po{constructor(t){super(t),this.removeGroupControls=Cs,this.removeListeners=Cs,this.controls=new qJ(t)}mount(){const{dragControls:t}=this.node.getProps();t&&(this.removeGroupControls=t.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||Cs}update(){const{dragControls:t}=this.node.getProps(),{dragControls:n}=this.node.prevProps||{};t!==n&&(this.removeGroupControls(),t&&(this.removeGroupControls=t.subscribe(this.controls)))}unmount(){this.removeGroupControls(),this.removeListeners(),this.controls.isDragging||this.controls.endPanSession()}}const bx=e=>(t,n)=>{e&&un.update(()=>e(t,n),!1,!0)};class GJ extends po{constructor(){super(...arguments),this.removePointerDownListener=Cs}onPointerDown(t){this.session=new CO(t,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:_O(this.node)})}createPanHandlers(){const{onPanSessionStart:t,onPanStart:n,onPan:i,onPanEnd:s}=this.node.getProps();return{onSessionStart:bx(t),onStart:bx(n),onMove:bx(i),onEnd:(r,o)=>{delete this.session,s&&un.postRender(()=>s(r,o))}}}mount(){this.removePointerDownListener=Ad(this.node.current,"pointerdown",t=>this.onPointerDown(t))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}let xx=!1;class WJ extends _.Component{componentDidMount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:i,layoutId:s}=this.props,{projection:r}=t;r&&(n.group&&n.group.add(r),i&&i.register&&s&&i.register(r),xx&&r.root.didUpdate(),r.addEventListener("animationComplete",()=>{this.safeToRemove()}),r.setOptions({...r.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),Ip.hasEverUpdated=!0}getSnapshotBeforeUpdate(t){const{layoutDependency:n,visualElement:i,drag:s,isPresent:r}=this.props,{projection:o}=i;return o&&(o.isPresent=r,t.layoutDependency!==n&&o.setOptions({...o.options,layoutDependency:n}),xx=!0,s||t.layoutDependency!==n||n===void 0||t.isPresent!==r?o.willUpdate():this.safeToRemove(),t.isPresent!==r&&(r?o.promote():o.relegate()||un.postRender(()=>{const c=o.getStack();(!c||!c.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{visualElement:t,layoutAnchor:n}=this.props,{projection:i}=t;i&&(i.options.layoutAnchor=n,i.root.didUpdate(),W1.postRender(()=>{!i.currentAnimation&&i.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:i}=this.props,{projection:s}=t;xx=!0,s&&(s.scheduleCheckAfterUnmount(),n&&n.group&&n.group.remove(s),i&&i.deregister&&i.deregister(s))}safeToRemove(){const{safeToRemove:t}=this.props;t&&t()}render(){return null}}function AO(e){const[t,n]=tJ(),i=_.useContext(GR);return d.jsx(WJ,{...e,layoutGroup:i,switchLayoutGroup:_.useContext(SO),isPresent:t,safeToRemove:n})}const YJ={pan:{Feature:GJ},drag:{Feature:KJ,ProjectionNode:gO,MeasureLayout:AO}};function qC(e,t,n){const{props:i}=e;e.animationState&&i.whileHover&&e.animationState.setActive("whileHover",n==="Start");const s="onHover"+n,r=i[s];r&&un.postRender(()=>r(t,kf(t)))}class XJ extends po{mount(){const{current:t}=this.node;t&&(this.unmount=kQ(t,(n,i)=>(qC(this.node,i,"Start"),s=>qC(this.node,s,"End"))))}unmount(){}}class QJ extends po{constructor(){super(...arguments),this.isActive=!1}onFocus(){let t=!1;try{t=this.node.current.matches(":focus-visible")}catch{t=!0}!t||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!1),this.isActive=!1)}mount(){this.unmount=vf($d(this.node.current,"focus",()=>this.onFocus()),$d(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function HC(e,t,n){const{props:i}=e;if(e.current instanceof HTMLButtonElement&&e.current.disabled)return;e.animationState&&i.whileTap&&e.animationState.setActive("whileTap",n==="Start");const s="onTap"+(n==="End"?"":n),r=i[s];r&&un.postRender(()=>r(t,kf(t)))}class ZJ extends po{mount(){const{current:t}=this.node;if(!t)return;const{globalTapTarget:n,propagate:i}=this.node.props;this.unmount=AQ(t,(s,r)=>(HC(this.node,r,"Start"),(o,{success:c})=>HC(this.node,o,c?"End":"Cancel")),{useGlobalTarget:n,stopPropagation:(i==null?void 0:i.tap)===!1})}unmount(){}}const lv=new WeakMap,vx=new WeakMap,JJ=e=>{const t=lv.get(e.target);t&&t(e)},eee=e=>{e.forEach(JJ)};function tee({root:e,...t}){const n=e||document;vx.has(n)||vx.set(n,{});const i=vx.get(n),s=JSON.stringify(t);return i[s]||(i[s]=new IntersectionObserver(eee,{root:e,...t})),i[s]}function nee(e,t,n){const i=tee(t);return lv.set(e,n),i.observe(e),()=>{lv.delete(e),i.unobserve(e)}}const iee={some:0,all:1};class see extends po{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){var u;(u=this.stopObserver)==null||u.call(this);const{viewport:t={}}=this.node.getProps(),{root:n,margin:i,amount:s="some",once:r}=t,o={root:n?n.current:void 0,rootMargin:i,threshold:typeof s=="number"?s:iee[s]},c=f=>{const{isIntersecting:p}=f;if(this.isInView===p||(this.isInView=p,r&&!p&&this.hasEnteredView))return;p&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",p);const{onViewportEnter:m,onViewportLeave:y}=this.node.getProps(),b=p?m:y;b&&b(f)};this.stopObserver=nee(this.node.current,o,c)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:t,prevProps:n}=this.node;["amount","margin","root"].some(ree(t,n))&&this.startObserver()}unmount(){var t;(t=this.stopObserver)==null||t.call(this),this.hasEnteredView=!1,this.isInView=!1}}function ree({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}const aee={inView:{Feature:see},tap:{Feature:ZJ},focus:{Feature:QJ},hover:{Feature:XJ}},oee={layout:{ProjectionNode:gO,MeasureLayout:AO}},lee={...MJ,...aee,...YJ,...oee},cee=_J(lee,CJ),uee={some:0,all:1};function dee(e,t,{root:n,margin:i,amount:s="some"}={}){const r=G1(e),o=new WeakMap,c=f=>{f.forEach(p=>{const m=o.get(p.target);if(p.isIntersecting!==!!m)if(p.isIntersecting){const y=t(p.target,p);typeof y=="function"?o.set(p.target,y):u.unobserve(p.target)}else typeof m=="function"&&(m(p),o.delete(p.target))})},u=new IntersectionObserver(c,{root:n,rootMargin:i,threshold:typeof s=="number"?s:uee[s]});return r.forEach(f=>u.observe(f)),()=>u.disconnect()}function fee(e,{root:t,margin:n,amount:i,once:s=!1,initial:r=!1}={}){const[o,c]=_.useState(r);return _.useEffect(()=>{if(!e.current||s&&o)return;const u=()=>(c(!0),s?void 0:()=>c(!1)),f={root:t&&t.current||void 0,margin:n,amount:i};return dee(e.current,u,f)},[t,e,n,s,i]),o}function au({children:e,index:t,className:n="",delay:i=.1,amount:s=.5,root:r}){const o=_.useRef(null),c=fee(o,{amount:s,once:!1,root:r});return d.jsx(cee.div,{ref:o,"data-index":t,initial:{scale:.7,opacity:0},animate:c?{scale:1,opacity:1}:{scale:.7,opacity:0},transition:{duration:.2,delay:i},className:n,children:e})}async function hee(e,t={}){const n=e.trim();if(!n)return null;try{const i=await fetch("/api/tts",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({text:n,voice:t.voice,speed:t.speed}),signal:t.signal});if(!i.ok)return null;const s=await i.arrayBuffer();return s.byteLength>0?s:null}catch{return null}}function pee(){return typeof window>"u"?null:window.AudioContext??window.webkitAudioContext??null}function mee(){const e=_.useRef(null),t=_.useRef(null),n=_.useRef(null),i=_.useRef(Promise.resolve()),s=_.useRef(!1),[r,o]=_.useState(null),c=_.useCallback(()=>{if(e.current)return e.current;const b=pee();if(!b)return null;const x=new b,v=x.createAnalyser();return v.fftSize=2048,v.connect(x.destination),e.current=x,t.current=v,o(v),x},[]),u=_.useCallback(()=>{const b=c();(b==null?void 0:b.state)==="suspended"&&b.resume()},[c]),f=_.useCallback(async(b,x)=>{const v=c(),w=t.current;if(!v||!w)throw new Error("no-audio-context");const k=await v.decodeAudioData(b.slice(0));x()&&(v.state==="suspended"&&await v.resume(),await new Promise(C=>{const S=v.createBufferSource();S.buffer=k,S.connect(w),n.current=S,S.onended=()=>{n.current===S&&(n.current=null),C()},S.start()}))},[c]),p=_.useCallback((b,x)=>new Promise(v=>{if(typeof window>"u"||!window.speechSynthesis||!x()){v();return}const w=new SpeechSynthesisUtterance(b);w.lang=navigator.language||"zh-CN",w.rate=1,w.onend=()=>v(),w.onerror=()=>v(),window.speechSynthesis.speak(w)}),[]),m=_.useCallback((b,x,v,w)=>{if(!b.trim()){v();return}const k=hee(b);i.current=i.current.then(async()=>{try{if(!x())return;const C=await k;if(!x())return;if(C){s.current=!0,w==null||w();try{await f(C,x)}catch{}return}s.current||(w==null||w(),await p(b,x))}finally{v()}})},[f,p]),y=_.useCallback(()=>{var b,x;try{(b=n.current)==null||b.stop()}catch{}n.current=null,typeof window<"u"&&((x=window.speechSynthesis)==null||x.cancel()),i.current=Promise.resolve()},[]);return _.useEffect(()=>()=>{var b,x,v;try{(b=n.current)==null||b.stop()}catch{}typeof window<"u"&&((x=window.speechSynthesis)==null||x.cancel()),(v=e.current)==null||v.close()},[]),{enqueue:m,cancel:y,resume:u,analyser:r}}const VC=900;function gee({phase:e,inputAnalyser:t,outputAnalyser:n=null,outputText:i,thinkingConfig:s}){const r=_.useRef(null),o=_.useRef({phase:e,outputText:i,thinkingConfig:s});o.current={phase:e,outputText:i,thinkingConfig:s};const c=_.useRef(null);return _.useEffect(()=>{var W;const u=r.current;if(!u)return;const f=u.getContext("2d");if(!f)return;let p=o.current.phase,m=p,y=performance.now()-VC;const b=((W=window.matchMedia)==null?void 0:W.call(window,"(prefers-reduced-motion: reduce)").matches)??!1,x=new Uint8Array(new ArrayBuffer((t==null?void 0:t.fftSize)??2048)),v=new Uint8Array(new ArrayBuffer((n==null?void 0:n.fftSize)??2048)),w=new Float32Array(256),k=new Float32Array(256);let C=0,S=0,T=0,A=1,j=0,M=0;const D=window.getComputedStyle(u),P={cyan:D.getPropertyValue("--voice-cyan").trim(),blue:D.getPropertyValue("--voice-blue").trim(),violet:D.getPropertyValue("--voice-violet").trim(),pink:D.getPropertyValue("--voice-pink").trim(),amber:D.getPropertyValue("--voice-amber").trim(),mint:D.getPropertyValue("--voice-mint").trim()},I=Math.min(window.devicePixelRatio||1,2);let B=0,q=null;const G=X=>{const K=u.getBoundingClientRect();A=X,S=Math.max(1,Math.round(K.width)),T=Math.max(1,Math.round(K.height)),u.width=Math.round(S*A),u.height=Math.round(T*A),f.setTransform(A,0,0,A,0,0)},R=X=>{const{phase:K,outputText:U,thinkingConfig:F}=o.current;K!==p&&(m=p,p=K,y=X);const Y=X/1e3,$=b?1:Math.min(1,(X-y)/VC),ie=$*$*(3-2*$);KC(t,x,w),KC(n,v,k),j+=(WC(w)-j)*.08,M+=(WC(k)-M)*.08,f.clearRect(0,0,S,T),ie<1&&m!==p&&GC(f,m,S,T,Y,1-ie,w,k,j,M,U,P,F),GC(f,p,S,T,Y,ie,w,k,j,M,U,P,F),b||(C=window.requestAnimationFrame(R))};c.current=()=>R(performance.now());const O=()=>{const X=performance.now(),K=X-B<200;B=X,G(K?1:I),q&&(clearTimeout(q),q=null),K&&(q=setTimeout(()=>{q=null,G(I),b&&R(performance.now())},150))};O(),R(performance.now());const z=typeof ResizeObserver>"u"?null:new ResizeObserver(()=>{O(),b&&R(performance.now())});return z==null||z.observe(u),window.addEventListener("resize",O),()=>{window.cancelAnimationFrame(C),q&&clearTimeout(q),c.current=null,z==null||z.disconnect(),window.removeEventListener("resize",O)}},[t,n]),_.useEffect(()=>{var f,p;(((f=window.matchMedia)==null?void 0:f.call(window,"(prefers-reduced-motion: reduce)").matches)??!1)&&((p=c.current)==null||p.call(c))},[e,i,s]),d.jsx("canvas",{ref:r,className:"voice-canvas","aria-hidden":"true"})}function KC(e,t,n){if(!e){n.fill(0);return}e.getByteTimeDomainData(t);const i=t.length/n.length;for(let s=0;s<n.length;s+=1){const r=t[Math.min(t.length-1,Math.floor(s*i))]??128;n[s]=(r-128)/128}}function GC(e,t,n,i,s,r,o,c,u,f,p,m,y){t==="idle"&&yee(e,n,i,s,r,m),t==="listening"&&bee(e,n,i,s,r,o,u,m),t==="thinking"&&xee(e,n,i,s,r,m,y),t==="speaking"&&vee(e,n,i,s,r,c,f,p,m)}function yee(e,t,n,i,s,r){const o=[r.blue,r.violet];e.save(),e.globalCompositeOperation="screen",o.forEach((c,u)=>{e.beginPath();for(let f=0;f<=180;f+=1){const p=f/180,m=Math.sin(Math.PI*p),y=n/2+Math.sin(p*Math.PI*3+i*.42+u)*n*.018*m;f===0?e.moveTo(p*t,y):e.lineTo(p*t,y)}e.strokeStyle=c,e.lineWidth=2+u*2,e.globalAlpha=s*(.28+u*.08),e.shadowColor=c,e.shadowBlur=12,e.stroke()}),e.restore()}function bee(e,t,n,i,s,r,o,c){const u=[c.cyan,c.blue,c.violet,c.pink,c.mint];e.save(),e.globalCompositeOperation="screen",u.forEach((f,p)=>{MO(e,t,n,i,p,u.length,f,s,.12+o*.62,.7,m=>jO(r,m))}),e.restore()}function xee(e,t,n,i,s,r,o){const c=[r.pink,r.amber,r.violet,r.blue,r.cyan,r.mint],u=o.colors.length>0?o.colors:c,f=Math.min(8,Math.max(1,Math.round(o.count))),p=Array.from({length:f},(M,D)=>u[D%u.length]??r.violet),m=t/2,y=n/2,b=Math.min(t,n),x=Math.max(0,o.amplitude),v=Math.max(.2,o.waviness),w=Math.max(.1,o.scale),k=Math.max(0,o.saturation),C=Math.max(0,.4+o.intensity),S=`hue-rotate(${o.hueShift*360}deg) saturate(${k}) brightness(${C})`,T=Math.max(0,o.glow),A=T*(8+w*4),j=Math.min(.72,T*.16)*(.55+o.intensity*.45);e.save(),e.globalCompositeOperation="source-over",p.forEach((M,D)=>{const P=D%2===0?1:-1,I=i*Math.max(0,o.speed),B=I*(.72+D*.06)*P+D*(.92+o.spread*.2),q=D%3===0?-1:1,G=I*(1.5+D*.12)*q+D*.83,R=b*(.055+o.spread*.035+D%3*.01)*x,O=m+Math.cos(B*.78+D)*R,z=y+Math.sin(B*.66+D)*R*.72,W=b*(.14+o.thickness*.08+D%3*.012)*w,X=96,K=Math.max(2,Math.min(8,Math.round(2+v))),U=K+2,F=[];for(let pe=0;pe<X;pe+=1){const re=pe/X*Math.PI*2,ee=1+Math.sin(re*K+G)*x*.09+Math.cos(re*U-G*.74+D*.7)*x*.05;F.push({x:O+Math.cos(re+B)*W*ee,y:z+Math.sin(re+B)*W*ee*(.84+D%2*.07)})}const Y=F[0],$=F[F.length-1];if(!Y||!$)return;const ie=B+D*.47,be=Math.cos(ie)*W*1.15,ce=Math.sin(ie)*W*1.15,Ne=e.createLinearGradient(O-be,z-ce,O+be,z+ce),oe=Math.max(1,u.length);for(let pe=0;pe<=oe;pe+=1){const re=u[(pe+D)%u.length]??M;Ne.addColorStop(pe/oe,re)}e.beginPath(),e.moveTo(($.x+Y.x)/2,($.y+Y.y)/2);for(let pe=0;pe<F.length;pe+=1){const re=F[pe],ee=F[(pe+1)%F.length];!re||!ee||e.quadraticCurveTo(re.x,re.y,(re.x+ee.x)/2,(re.y+ee.y)/2)}e.closePath(),A>0&&o.intensity>0&&[1.55,.72].forEach((pe,re)=>{e.save(),e.globalCompositeOperation="screen",e.filter=`${S} blur(${A*pe*(re===0?.58:.24)}px)`,e.fillStyle=Ne,e.globalAlpha=s*o.opacity*j*(re===0?.72:.92),e.fill(),e.restore()}),e.save(),e.globalCompositeOperation="screen",e.filter=S,e.fillStyle=Ne,e.globalAlpha=s*o.opacity*(.3+D%3*.025),e.fill(),e.restore()}),e.restore()}function vee(e,t,n,i,s,r,o,c,u){const f=[u.mint,u.cyan,u.blue,u.violet,u.pink],p=o>.006;e.save(),e.globalCompositeOperation="screen",f.forEach((m,y)=>{MO(e,t,n,i*.86,y,f.length,m,s,.34+o*.36,1.45,b=>p?jO(r,b):wee(c,b,i,y))}),e.restore()}function wee(e,t,n,i){const s=e||"SPS",r=(n*1.6+t*s.length*.72+i*.46)%s.length,o=s.charCodeAt(Math.floor(r))||83,c=.18+o%13/42,u=2.2+o%5*.16;return Math.sin(t*Math.PI*u-n*(.72+o%4*.08)+i*.74)*c}function WC(e){let t=0;for(const n of e)t+=n*n;return Math.min(1,Math.sqrt(t/e.length)*3.2)}function jO(e,t){const n=Math.round(t*(e.length-1));let i=0,s=0;for(let r=-6;r<=6;r+=1){const o=Math.max(0,Math.min(e.length-1,n+r));i+=e[o]??0,s+=1}return i/s}function MO(e,t,n,i,s,r,o,c,u,f,p){const y=[],b=[],x=s%2===0?1:-1,v=s*1.18+i*(.32+s*.018)*x;for(let k=0;k<=84;k+=1){const C=k/84,S=Math.pow(Math.sin(Math.PI*C),.42),T=Math.pow(Math.sin(Math.PI*C),.9),A=Math.sin(C*Math.PI*(2.2+s*.18)+v),j=Math.sin(C*Math.PI*1.25-v*.58+s)*.38,M=p(C)*n*(.02+u*.025);y.push(n/2+(s-(r-1)/2)*n*.013+(A+j)*n*(.038+u*.038)*f*S+M*S),b.push(n*(.05+s*.005)*(.9+u*.38)*(.88+Math.sin(C*Math.PI*2-v)*.12)*T)}e.beginPath(),y.forEach((k,C)=>{const S=C/84*t,T=k-(b[C]??0);C===0?e.moveTo(S,T):e.lineTo(S,T)});for(let k=84;k>=0;k-=1)e.lineTo(k/84*t,(y[k]??n/2)+(b[k]??0));e.closePath();const w=e.createLinearGradient(0,0,t,0);w.addColorStop(0,"transparent"),w.addColorStop(.1,o),w.addColorStop(.9,o),w.addColorStop(1,"transparent"),e.fillStyle=w,e.globalAlpha=c*(.22+s*.03),e.shadowColor=o,e.shadowBlur=28+s*4,e.fill()}const Eee=[{id:"idle",labelKey:"home.phase.idle",icon:iU},{id:"listening",labelKey:"home.phase.listening",icon:Ij},{id:"thinking",labelKey:"home.phase.thinking",icon:VB},{id:"speaking",labelKey:"home.phase.speaking",icon:Vj}],sp=["#f97316","#7c3aed","#06b6d4"],gd={idle:{colors:sp,count:6,speed:1,amplitude:.2,waviness:.8,thickness:.7,glow:1.5,taper:1.4,spread:.9,hueShift:0,intensity:.4,saturation:3,opacity:1,scale:2},listening:{colors:sp,count:6,speed:1.7,amplitude:1.4,waviness:1.1,thickness:.75,glow:4.2,taper:1.4,spread:1.7,hueShift:0,intensity:.8,saturation:3,opacity:1,scale:2.1},thinking:{colors:sp,count:6,speed:1.5,amplitude:1.2,waviness:1.5,thickness:.8,glow:4,taper:4.7,spread:2,hueShift:0,intensity:.9,saturation:3,opacity:1,scale:1.6},speaking:{colors:sp,count:6,speed:1.5,amplitude:2.3,waviness:2.5,thickness:1.4,glow:4,taper:1.6,spread:2,hueShift:0,intensity:.9,saturation:3,opacity:1,scale:2.35}},kee=[{key:"count",labelKey:"home.customize.count",min:1,max:8,step:1},{key:"speed",labelKey:"home.customize.speed",min:0,max:2,step:.05},{key:"amplitude",labelKey:"home.customize.amplitude",min:0,max:2.5,step:.05},{key:"waviness",labelKey:"home.customize.waviness",min:.2,max:3,step:.05},{key:"thickness",labelKey:"home.customize.thickness",min:.1,max:1.5,step:.05},{key:"glow",labelKey:"home.customize.glow",min:0,max:5,step:.1},{key:"taper",labelKey:"home.customize.taper",min:.2,max:6,step:.1},{key:"spread",labelKey:"home.customize.spread",min:0,max:2.5,step:.05},{key:"hueShift",labelKey:"home.customize.hueShift",min:0,max:1,step:.01},{key:"intensity",labelKey:"home.customize.intensity",min:0,max:1,step:.05},{key:"saturation",labelKey:"home.customize.saturation",min:0,max:3,step:.05},{key:"opacity",labelKey:"home.customize.opacity",min:0,max:1,step:.05},{key:"scale",labelKey:"home.customize.scale",min:.5,max:2.5,step:.05}];function yd(e){return{...e,colors:[...e.colors]}}function See(){return{idle:yd(gd.idle),listening:yd(gd.listening),thinking:yd(gd.thinking),speaking:yd(gd.speaking)}}function Nee(e,t){e.getByteTimeDomainData(t);let n=0;for(const i of t){const s=(i-128)/128;n+=s*s}return Math.min(1,Math.sqrt(n/t.length)*3.4)}function YC(e){return e.replace(/```[\s\S]*?```/g,"").replace(/[`*_>#\[\]()]/g,"").replace(/\s+/g," ").trim()}function cv(e){return/\.(png|jpe?g|gif|webp|svg|bmp|avif)$/i.test(e)}function RO(e){const t=e.lastIndexOf(".");return((t>=0?e.slice(t+1):"")||"file").toUpperCase().slice(0,5)}const DO="mcp__sps__present_form";function _ee(e){var i;if(!e)return null;let t=null;if(Array.isArray(e.fields)&&e.fields.length>0?t=e:e.template==="image"&&(t={...ix,title:e.title||ix.title,description:e.description??ix.description,...e.submitLabel?{submitLabel:e.submitLabel}:{},...e.skipLabel?{skipLabel:e.skipLabel}:{}}),!t||!((i=t.fields)!=null&&i.length))return null;const n=e.defaults;return n&&typeof n=="object"&&(t={...t,fields:t.fields.map(s=>s.id in n?{...s,default:n[s.id]}:s)}),t}function Cee(e){var n;if(!e)return null;const t=e.filter(i=>i.type==="tool_use"&&i.title===DO);return _ee((n=t[t.length-1])==null?void 0:n.input)}function XC(e){if(RR(e.schema))return{submitLabel:"提交并继续",...e.schema};const t=e.schema&&typeof e.schema=="object"&&!Array.isArray(e.schema)?e.schema:{},n=new Set(t.required??[]),i=Object.entries(t.properties??{}).map(([s,r])=>({id:s,label:r.title??s,type:Array.isArray(r.enum)?"select":r.type==="boolean"?"toggle":r.type==="number"?"number":r.format==="textarea"?"textarea":"text",...Array.isArray(r.enum)?{options:r.enum.map(o=>({value:String(o),label:String(o)}))}:{},...r.default!==void 0?{default:r.default}:{},...n.has(s)?{required:!0}:{},...typeof r.description=="string"?{hint:r.description}:{}}));return{title:e.title,...t.description?{description:t.description}:{},submitLabel:"提交并继续",fields:i}}const OO="[表单已提交]",LO="[让 AI 来定";function Tee(e,t){for(let n=t+1;n<e.length;n++){const i=e[n],s=i==null?void 0:i.content;if((i==null?void 0:i.role)==="user"&&typeof s=="string"&&(s.startsWith(OO)||s.startsWith(LO)))return!0}return!1}function Aee(e,t){for(let n=t+1;n<e.length;n++){const i=e[n],s=i==null?void 0:i.content;if(!((i==null?void 0:i.role)!=="user"||typeof s!="string")){if(s.startsWith(LO))return;if(s.startsWith(OO)){const r=s.match(/```json\s*([\s\S]*?)```/);if(!(r!=null&&r[1]))return;try{return JSON.parse(r[1])}catch{return}}}}}function jee({sessionId:e,paths:t,onImagePreview:n}){return!e||!t.length?null:d.jsx("div",{className:"voice-msg-attachments",children:t.map(i=>{const s=i.split("/").pop()??i,r=$o(e,i);return cv(i)&&n?d.jsx("button",{type:"button",className:"voice-msg-attach",title:s,onClick:()=>n(i),children:d.jsx("img",{src:r,alt:s})},i):d.jsx("a",{href:r,target:"_blank",rel:"noreferrer",className:"voice-msg-attach",title:s,children:cv(i)?d.jsx("img",{src:r,alt:s}):d.jsxs(d.Fragment,{children:[d.jsx(Uc,{size:22,strokeWidth:1.7,"aria-hidden":"true"}),d.jsx("span",{className:"voice-msg-attach-ext",children:RO(s)})]})},i)})})}const Lo="sps.home.session",Mee=720*60*1e3;function Ree(e){if(!e)return"";try{const t=new Date(e),n=new Date;return t.toDateString()===n.toDateString()?t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):t.toLocaleDateString([],{month:"numeric",day:"numeric"})}catch{return""}}function Dee(e){if(!e)return"";try{return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}catch{return""}}function QC(e){return e.map(t=>{var n;return{id:t.id,role:t.role,content:t.content||(((n=t.blocks)==null?void 0:n.map(i=>i.type==="text"?i.text:"").join(""))??""),status:"complete",...t.blocks&&t.blocks.length?{blocks:t.blocks}:{}}})}function wx({outputAnalyser:e=null}){var Ke,gt;const t=Xe(),{sessionId:n}=qv(),[i,s]=_.useState("idle"),r=_.useRef("idle");r.current=i;const[o,c]=aa("sps.voice.autoListen",!1),[u,f]=_.useState("idle"),[p,m]=_.useState(!1),[y,b]=_.useState(""),[x,v]=aa("sps.sessions.listOpen",!1),[w,k]=_.useState(0),[C,S]=aa("sps.sessions.originTab","all"),[T,A]=_.useState(!1),[j]=_.useState(()=>{var V;return((V=window.matchMedia)==null?void 0:V.call(window,"(max-width: 700px)").matches)??!1}),[M,D]=_.useState(j),[P,I]=_.useState(""),[B,q]=_.useState(60),G=_.useRef(null),[R,O]=_.useState(()=>r9()?"draw":"done"),[z,W]=_.useState(See),X=_.useRef(null),K=_.useRef(null),U=_.useRef(null),F=_.useRef(null),Y=_.useRef(!0),[$,ie]=_.useState(!1),be=_.useCallback(()=>{const V=U.current;return!V||V.scrollHeight-V.scrollTop-V.clientHeight<40},[]),ce=_.useCallback(()=>{const V=U.current;V&&(typeof V.scrollTo=="function"?V.scrollTo({top:V.scrollHeight,behavior:"smooth"}):V.scrollTop=V.scrollHeight),Y.current=!0,ie(!1)},[]),Ne=_.useCallback(()=>{const V=U.current;V&&(typeof V.scrollTo=="function"?V.scrollTo({top:V.scrollHeight,behavior:"instant"}):V.scrollTop=V.scrollHeight)},[]),oe=_.useCallback(()=>{const V=be();Y.current=V,ie(!V)},[be]),pe=_.useRef(0),re=_.useRef(0),ee=_.useRef(0),ge=_.useRef(""),Ce=_.useRef(!1),Ie=_.useRef(!1),ae=_.useRef(!1),ke=XW(),Ue=mee(),Oe=z[i],ht=z[u],tt=V=>{V===re.current&&Ce.current&&ee.current===0&&s("idle")},jt=V=>{const xe=YC(V);if(!xe)return;const ze=re.current;ee.current+=1,Ue.enqueue(xe,()=>ze===re.current,()=>{ze===re.current&&(ee.current=Math.max(0,ee.current-1),tt(ze))})},Nt=V=>{ge.current+=V;let xe=ge.current.match(/^([\s\S]*?[。!?.!?])([\s\S]*)$/);for(;xe;)jt(xe[1]??""),ge.current=xe[2]??"",xe=ge.current.match(/^([\s\S]*?[。!?.!?])([\s\S]*)$/)},pt=()=>{re.current+=1,ee.current=0,ge.current="",Ce.current=!1,Ue.cancel()},Me=V=>{var xe;(xe=navigator.clipboard)==null||xe.writeText(V).catch(()=>{})},[We,ne]=_.useState(null),ve=_.useRef(0),Re=(V,xe)=>{if(We&&We.id===V){ve.current+=1,pt(),ne(null);return}const ze=YC(xe);if(!ze)return;ve.current+=1,pt();const _t=ve.current,ut=()=>_t===ve.current;Ue.resume(),ne({id:V,phase:"loading"}),Ue.enqueue(ze,ut,()=>{ut()&&ne(null)},()=>{ut()&&ne({id:V,phase:"playing"})})},ye=aY({onAssistantChunk:V=>{Ie.current=!0,ae.current&&(s("speaking"),Nt(V))},onAssistantComplete:V=>{Ce.current=!0,ae.current&&(Ie.current?ge.current.trim()&&jt(ge.current):jt(V)),ge.current="",tt(re.current)},onError:()=>{b(t("home.error.response")),s("idle")},onThinking:()=>{pt(),Ie.current=!1,b(""),s("thinking")}});_.useEffect(()=>{const V=`sps.home.draft:${ye.sessionId??"new"}`;I(localStorage.getItem(V)??"")},[ye.sessionId]);const Je=_.useCallback(V=>{I(V);try{localStorage.setItem(`sps.home.draft:${ye.sessionId??"new"}`,V)}catch{}},[ye.sessionId]),It=_.useCallback(()=>{I("");try{localStorage.removeItem(`sps.home.draft:${ye.sessionId??"new"}`)}catch{}},[ye.sessionId]);_.useEffect(()=>{const V=localStorage.getItem(Lo);if(!V)return;let xe={};try{xe=JSON.parse(V)}catch{}if(!n){if(!xe.id||!xe.ts||Date.now()-xe.ts>Mee){localStorage.removeItem(Lo);return}Ap(xe.id).then(ze=>{ye.resume(ze.id,QC(ze.messages)),Te(ze)}).catch(()=>localStorage.removeItem(Lo))}},[]),_.useEffect(()=>{ye.sessionId&&localStorage.setItem(Lo,JSON.stringify({id:ye.sessionId,ts:Date.now()}))},[ye.sessionId,ye.messages.length]);const[Wt,he]=_.useState([]),[le,Te]=_.useState(null),[Ae,Qe]=_.useState(null),[st,$e]=_.useState(null),[nt,qt]=_.useState(null),[Xt,Dt]=_.useState(null),Q=(()=>{const V=ye.activeInteraction;return V&&(V.kind==="form"||V.kind==="choices")?V:null})(),we=Q?XC(Q):null,[Pe,ct]=_.useState(""),[Qt,Ht]=_.useState(0),He=(V,xe,ze)=>{ct("");const _t=_W(xe,ze)||"(已确认)";if(V.respond==="message"){ye.send(_t,void 0,{id:V.id,answer:ze});return}const ut=ye.sessionId;if(!ut)return;const yn=Object.fromEntries(Object.entries(ze).filter(([,Zt])=>Zt!==""&&Zt!=null));P0(ut,V.id,yn,V.revision).catch(Zt=>{ct(Zt instanceof Error?Zt.message:String(Zt)),Ht(ps=>ps+1)})},[Fe,rt]=_.useState(!1);_.useEffect(()=>{if(!Xt)return;const V=xe=>{xe.key==="Escape"&&(xe.preventDefault(),Dt(null))};return window.addEventListener("keydown",V),()=>window.removeEventListener("keydown",V)},[Xt]),_.useEffect(()=>{if(!ye.sessionId){Te(null),he([]);return}ye.isSending||Ap(ye.sessionId).then(V=>{he(V.artifacts??[]),Te(V)}).catch(()=>{})},[ye.sessionId,ye.isSending,ye.messages.length]);const hn=tn(),ki=((Ke=ot({queryKey:["chat-sessions"],queryFn:DW,refetchInterval:5e3}).data)==null?void 0:Ke.data)??[],us=[...new Set(ki.map(V=>V.origin??"sps"))].sort(),ds=C!=="all"&&!us.includes(C)?"all":C,Di=ds==="all"?ki:ki.filter(V=>(V.origin??"sps")===ds),pn=V=>V.lastMessageAt??V.createdAt,In=b0(Di,pn,7),Yn=b0(In.older,pn,30),Ds=V=>V.id===ye.sessionId,jr=[...In.recent,...w>=1?Yn.recent:Yn.recent.filter(Ds),...w>=2?Yn.older:Yn.older.filter(Ds)],Os=Yn.recent.length+Yn.older.length,Mr=Yn.older.length,fs=V=>{V!==ye.sessionId&&Ap(V).then(xe=>{ye.resume(V,QC(xe.messages)),Te(xe),he(xe.artifacts??[]),s("idle"),b(""),localStorage.setItem(Lo,JSON.stringify({id:V,ts:Date.now()}))}).catch(()=>{})};_.useEffect(()=>{n&&n!==ye.sessionId&&fs(n)},[n]);const Rr=V=>{A(!1),PR({...V,dedicated:!V.cwd}).then(xe=>{ye.resume(xe.id,[]),he([]),Te(null),rt(!1),s("idle"),b(""),localStorage.setItem(Lo,JSON.stringify({id:xe.id,ts:Date.now()})),hn.invalidateQueries({queryKey:["chat-sessions"]})}).catch(()=>{})},Xn=/\.(png|jpe?g|gif|webp|avif|svg|bmp)$/i,Gi=/\.(md|markdown|txt|log|json|ya?ml|csv|tsv|html?|css|jsx?|tsx?|py|sh|toml|ini|sql)$/i,Si=V=>{const xe=le==null?void 0:le.cwd;return xe?V.startsWith("/")?V:`${xe.replace(/\/$/,"")}/${V}`:null},hs=V=>{const xe=Si(V),ze=ye.sessionId;if(!xe||!ze)return;if(Xn.test(V)){Qe(xe);return}const _t=$o(ze,xe);if(!Gi.test(V)){window.open(_t,"_blank","noopener");return}$e({rel:V,text:null}),fetch(_t).then(ut=>ut.ok?ut.text():Promise.reject(new Error(String(ut.status)))).then(ut=>$e({rel:V,text:ut})).catch(ut=>$e({rel:V,text:null,error:ut instanceof Error?ut.message:String(ut)}))},vn=(V,xe)=>{xe.stopPropagation(),qt({id:V})},Dr=(V,xe)=>{qt(null),OW(V,xe).then(()=>{hn.invalidateQueries({queryKey:["chat-sessions"]}),V===ye.sessionId&&ma()}).catch(()=>{})},Qn=YW({onComplete:V=>{ke.stop(),ae.current=!0;const xe=Wi.map(ze=>ze.path);Y.current=!0,ie(!1),ye.send(V,xe.length?xe:void 0),xe.length&&yi([])},onError:V=>{ke.stop(),b(t(V==="unsupported"?"home.error.recognitionUnsupported":"home.error.recognition")),s("idle")}}),jn=_.useRef(Qn);jn.current=Qn;const je=()=>{i!=="idle"||ye.isSending||ii||(b(""),Ue.resume(),pt(),Qn.start()&&(s("listening"),ke.start()))},Ye=()=>{i==="listening"?Qn.stop():je()},xt=_.useRef(Ye);xt.current=Ye;const Pt=V=>{c(V),b(""),V?Ue.resume():r.current==="idle"&&jn.current.isListening&&jn.current.cancel()};_.useEffect(()=>{if(!(o&&i==="idle"&&!M&&Qn.supported))return;const xe=window.setTimeout(()=>{jn.current.isListening||jn.current.start()},400);return()=>{window.clearTimeout(xe),r.current==="idle"&&jn.current.isListening&&jn.current.cancel()}},[o,i,M,Qn.supported]);const gn=()=>{i!=="idle"||ye.isSending||ii||jn.current.isListening&&(b(""),Ue.resume(),pt(),s("listening"),ke.start())};tY({enabled:o,phase:i,suspended:M||ye.isSending,analyser:ke.analyser,transcript:Qn.transcript,onTrigger:gn,onEndpoint:()=>jn.current.stop(),onAbort:()=>{jn.current.cancel(),ke.stop(),s("idle")}});const Un=22,ci=18,ti=()=>{const V=G.current;if(!V)return;V.style.height="auto";const xe=Un*3+ci,ze=Math.min(V.scrollHeight,xe);V.style.height=`${ze}px`,V.style.overflowY=V.scrollHeight>xe?"auto":"hidden",q(Math.max(60,ze+16))},Vt=()=>{q(60);const V=G.current;V&&(V.style.height="auto",V.style.overflowY="hidden")},ni=()=>{const V=P.trim();if(!V&&Wi.length===0||ye.isSending)return;const xe=Wi.map(ze=>ze.path);It(),Vt(),yi([]),b(""),ae.current=!1,Y.current=!0,ie(!1),ye.send(V,xe.length?xe:void 0)},Or=i==="thinking"||i==="speaking",ii=((le==null?void 0:le.readonly)??!1)&&(le==null?void 0:le.id)===ye.sessionId,si=M&&!Or&&!ii,Ls=_.useRef(!1);_.useEffect(()=>{if(!Ls.current){Ls.current=!0;return}if(j)return;document.documentElement.dataset.morphing="true";const V=setTimeout(()=>{delete document.documentElement.dataset.morphing},850);return()=>clearTimeout(V)},[i,si,j]),_.useEffect(()=>()=>{delete document.documentElement.dataset.morphing},[]),_.useEffect(()=>{if(M||o||ii)return;const V=xe=>{if(xe.code!=="Space"&&xe.key!==" "||xe.repeat)return;const ze=xe.target;ze&&(ze.tagName==="INPUT"||ze.tagName==="TEXTAREA"||ze.isContentEditable)||(xe.preventDefault(),xt.current())};return window.addEventListener("keydown",V),()=>window.removeEventListener("keydown",V)},[M,o,ii]);const ma=()=>{ye.reset(),localStorage.removeItem(Lo),he([]),rt(!1),s("idle"),b(""),It(),Vt()},ri=()=>{ye.sessionId&&zR(ye.sessionId).catch(()=>{}),pt(),s("idle")},[Wi,yi]=_.useState([]),[Is,Mn]=_.useState(!1),[rr,ar]=_.useState(!1),lt=async V=>{if(V.size>UR){b(`文件超过 50 MB(${(V.size/1024/1024).toFixed(1)} MB):${V.name}`);return}Mn(!0);try{const xe=await ye.ensureSession(),ze=await nx(xe,V);yi(_t=>[..._t,{path:ze.path,name:ze.name}])}catch(xe){b(xe instanceof Error?xe.message:String(xe))}finally{Mn(!1)}},Sl=V=>{yi(xe=>xe.filter(ze=>ze.path!==V))};_.useEffect(()=>{var yn;const V=X.current;if(!V)return;if(((yn=window.matchMedia)==null?void 0:yn.call(window,"(prefers-reduced-motion: reduce)").matches)??!1){V.style.setProperty("--voice-activity","0"),V.style.setProperty("--voice-scale","1");return}let ze=0,_t=new Uint8Array(new ArrayBuffer(2048));const ut=Zt=>{const ps=i==="listening"?ke.analyser:i==="speaking"?Ue.analyser??e:null;ps&&_t.length!==ps.fftSize&&(_t=new Uint8Array(new ArrayBuffer(ps.fftSize)));let Lr=ps?Nee(ps,_t):0;if(!ps&&i==="speaking"){const Nl=Zt/1e3;Lr=.16+(.5+Math.sin(Nl*6.8)*.5)*.34+(.5+Math.sin(Nl*11.4+1.2)*.5)*.16}const or=Lr>pe.current?.16:.065;pe.current+=(Lr-pe.current)*or,V.style.setProperty("--voice-scale",(1+pe.current*.065).toFixed(4)),V.style.setProperty("--voice-activity",pe.current.toFixed(3)),ze=window.requestAnimationFrame(ut)};return ze=window.requestAnimationFrame(ut),()=>window.cancelAnimationFrame(ze)},[ke.analyser,Ue.analyser,e,i]),_.useEffect(()=>{Y.current&&Ne()},[i,Qn.transcript,ye.messages,Ne]);const _n=ye.messages.some(V=>V.status==="streaming");_.useEffect(()=>{if(!_n)return;let V=0;const xe=()=>{const ze=U.current;ze&&Y.current&&ze.scrollHeight-ze.scrollTop-ze.clientHeight>=1&&Ne(),V=window.requestAnimationFrame(xe)};return V=window.requestAnimationFrame(xe),()=>window.cancelAnimationFrame(V)},[_n,Ne]),_.useEffect(()=>{if(Qe(null),!ye.sessionId)return;Y.current=!0,ie(!1);const V=window.setTimeout(()=>{Y.current&&Ne()},400);return()=>window.clearTimeout(V)},[ye.sessionId]),_.useEffect(()=>{if(!p)return;const V=xe=>{xe.key==="Escape"&&m(!1)};return window.addEventListener("keydown",V),()=>window.removeEventListener("keydown",V)},[p]),_.useEffect(()=>()=>{pt(),ke.stop()},[]);const Kt=_.useMemo(()=>({amplitude:Oe.amplitude,colors:Oe.colors,count:Oe.count,glow:Oe.glow,hueShift:Oe.hueShift,intensity:Oe.intensity,opacity:Oe.opacity,saturation:Oe.saturation,scale:Oe.scale,speed:Oe.speed,spread:Oe.spread,thickness:Oe.thickness,waviness:Oe.waviness}),[Oe]),Ps=(V,xe)=>{if(!Number.isFinite(xe))return;const ze=Math.min(V.max,Math.max(V.min,xe));W(_t=>({..._t,[u]:{..._t[u],[V.key]:ze}}))},zs=(V,xe)=>{W(ze=>{const _t=[...ze[u].colors];return _t[V]=xe,{...ze,[u]:{...ze[u],colors:_t}}})},go=_.useMemo(()=>{var V;return((V=[...ye.messages].reverse().find(xe=>xe.role==="assistant"))==null?void 0:V.content)??""},[ye.messages]),Bs=i==="listening"&&ke.status==="requesting"?t("home.mic.requesting"):t(`home.phase.${i}`),Le=ye.messages.some(V=>V.role==="assistant"&&V.status==="streaming");return d.jsxs("div",{className:"home-shell","data-list-open":x?"true":"false",children:[T&&d.jsx(hY,{onCancel:()=>A(!1),onCreate:Rr}),Ae&&ye.sessionId&&d.jsx($W,{sessionId:ye.sessionId,path:Ae,onClose:()=>Qe(null)}),st&&d.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-[rgba(45,55,72,0.6)] p-4",role:"presentation",onClick:()=>$e(null),children:d.jsxs("div",{className:"nb-card w-full max-w-3xl max-h-[85vh] flex flex-col gap-2",onClick:V=>V.stopPropagation(),children:[d.jsxs("div",{className:"flex items-center gap-3",children:[d.jsx("span",{className:"font-[family-name:var(--font-heading)] font-bold text-sm flex-1 min-w-0 truncate",children:st.rel}),ye.sessionId&&Si(st.rel)&&d.jsx("a",{className:"nb-btn text-xs",href:$o(ye.sessionId,Si(st.rel)),download:st.rel.split("/").pop(),children:t("home.artifacts.download")}),d.jsx("button",{type:"button",className:"nb-btn text-xs",onClick:()=>$e(null),children:t("common.close")})]}),d.jsx("pre",{className:"file-preview-body",children:st.error?`${t("home.artifacts.loadFailed")}: ${st.error}`:st.text??t("home.artifacts.loading")})]})}),nt&&d.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-[rgba(45,55,72,0.6)] p-4",role:"presentation",onClick:()=>qt(null),children:d.jsxs("div",{className:"nb-card w-full max-w-md flex flex-col gap-3",onClick:V=>V.stopPropagation(),children:[d.jsx("div",{className:"font-[family-name:var(--font-heading)] font-bold text-base",children:t("home.sessions.deleteTitle")}),d.jsx("p",{className:"text-xs text-[var(--color-text-muted)] leading-relaxed m-0",children:t("home.sessions.deleteHint")}),d.jsxs("div",{className:"flex flex-wrap gap-2 justify-end pt-1",children:[d.jsx("button",{type:"button",className:"nb-btn text-xs",onClick:()=>qt(null),children:t("common.cancel")}),d.jsx("button",{type:"button",className:"nb-btn text-xs",onClick:()=>Dr(nt.id,!1),children:t("home.sessions.deleteSessionOnly")}),d.jsx("button",{type:"button",className:"nb-btn text-xs",style:{borderColor:"var(--color-crashed)",color:"var(--color-crashed)"},onClick:()=>Dr(nt.id,!0),children:t("home.sessions.deleteWithWorkspace")})]})]})}),Xt&&d.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-[rgba(45,55,72,0.6)] p-4",role:"presentation",onClick:()=>Dt(null),children:d.jsxs("div",{className:"w-full max-w-lg max-h-[88vh] overflow-auto",onClick:V=>V.stopPropagation(),children:[Xt.error&&d.jsxs("div",{className:"nb-card mb-2 px-3 py-2 text-xs text-[var(--color-crashed)]",children:["提交失败:",Xt.error]}),d.jsx(C2,{spec:Xt.spec,disabled:Xt.readOnly,initialValues:Xt.values,onSubmit:V=>{const xe=Xt.interaction;if(xe){const ze=Object.fromEntries(Object.entries(V).filter(([,ut])=>ut!==""&&ut!=null)),_t=ye.sessionId;if(!_t)return;P0(_t,xe.id,ze,xe.revision).then(()=>Dt(null)).catch(ut=>Dt(yn=>yn&&{...yn,values:V,error:ut instanceof Error?ut.message:String(ut),panelKey:(yn.panelKey??0)+1}));return}ye.send("[表单已提交]\n```json\n"+JSON.stringify(V,null,2)+"\n```"),Dt(null)},onSkip:()=>{ye.send("[让 AI 来定,按各字段推荐值 + 我们的对话补全,不用再逐项问我]"),Dt(null)},onUpload:async V=>{const xe=await ye.ensureSession();return(await nx(xe,V)).path}},Xt.panelKey??0)]})}),d.jsx("aside",{className:`home-sessions ${x?"is-open":""}`,children:x?d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"home-sessions-head",children:[d.jsx("span",{className:"home-sessions-title",children:t("chat.list.title")}),d.jsxs("div",{className:"home-sessions-head-actions",children:[d.jsx("button",{type:"button",className:"nb-btn",style:{padding:"5px 8px"},onClick:()=>A(!0),"aria-label":t("chat.list.new"),title:t("chat.list.new"),children:d.jsx(Gn,{size:14,strokeWidth:3})}),d.jsx("button",{type:"button",className:"nb-btn",style:{padding:"5px 8px"},onClick:()=>v(!1),"aria-label":t("home.sessions.collapse"),title:t("home.sessions.collapse"),children:d.jsx(YN,{size:14,strokeWidth:2.2})})]})]}),us.length>1&&d.jsx(eM,{origins:us,active:ds,allLabel:t("home.sessions.tabAll"),onChange:S}),d.jsxs("div",{className:"home-sessions-list",children:[jr.map((V,xe)=>d.jsx(au,{index:xe,children:d.jsxs("div",{className:`home-session-row ${V.id===ye.sessionId?"is-active":""}`,children:[d.jsxs("button",{type:"button",className:"home-session-main",onClick:()=>fs(V.id),title:V.title,children:[d.jsx($U,{size:13,strokeWidth:2.5,className:"shrink-0"}),d.jsx("span",{className:"home-session-title",children:V.title}),V.source==="cli"&&d.jsx("span",{className:"nb-badge text-[9px] shrink-0",title:t("chat.cliBadge.tooltip"),children:t("chat.cliBadge")}),d.jsxs("span",{className:"home-session-meta",style:{display:"flex",gap:6,alignItems:"center"},children:[V.lastMessageAt&&d.jsx("span",{title:new Date(V.lastMessageAt).toLocaleString(),children:Ree(V.lastMessageAt)}),d.jsx("span",{style:{opacity:.6},children:V.messageCount})]})]}),d.jsx("button",{type:"button",className:"home-session-del",onClick:ze=>vn(V.id,ze),"aria-label":t("home.sessions.delete"),title:t("home.sessions.delete"),children:d.jsx(Rs,{size:16,strokeWidth:2.4})})]})},V.id)),w===0&&Os>0&&d.jsx("button",{type:"button",className:"nb-btn text-xs self-start mt-1",onClick:()=>k(1),children:t("home.sessions.expandWeek",{count:Os})}),w===1&&(Mr>0?d.jsx("button",{type:"button",className:"nb-btn text-xs self-start mt-1",onClick:()=>k(2),children:t("home.sessions.expandMonth",{count:Mr})}):d.jsx("button",{type:"button",className:"nb-btn text-xs self-start mt-1",onClick:()=>k(0),children:t("home.sessions.collapseOld")})),w===2&&d.jsx("button",{type:"button",className:"nb-btn text-xs self-start mt-1",onClick:()=>k(0),children:t("home.sessions.collapseOld")})]})]}):d.jsx("button",{type:"button",className:"home-sessions-rail",onClick:()=>v(!0),"aria-label":t("home.sessions.open"),title:t("home.sessions.open"),children:d.jsx(YN,{size:18,strokeWidth:2.2})})}),d.jsxs("section",{className:["voice-home",R==="draw"?"voice-home--intro-hidden":"",R==="reveal"?"voice-home--intro-reveal":""].join(" "),"aria-labelledby":"voice-home-title",children:[R!=="done"&&d.jsx(i9,{targetRef:X,panelRef:K,onReveal:()=>O("reveal"),onDone:()=>O("done")}),d.jsxs("div",{ref:K,className:"voice-conversation","data-phase":i,children:[le&&d.jsxs("div",{className:"voice-convo-header",children:[d.jsxs("button",{type:"button",className:"voice-convo-title-btn",onClick:()=>rt(V=>!V),"aria-expanded":Fe,children:[d.jsx("span",{className:"voice-convo-title",children:le.title}),d.jsx(uo,{size:15,strokeWidth:2.5,className:["voice-convo-chevron",Fe?"is-open":""].join(" ")})]}),Fe&&d.jsxs("dl",{className:"voice-convo-details",children:[le.model&&d.jsxs(d.Fragment,{children:[d.jsx("dt",{children:"模型"}),d.jsx("dd",{children:le.model})]}),d.jsx("dt",{children:"session"}),d.jsx("dd",{children:le.id}),le.claudeSessionId&&d.jsxs(d.Fragment,{children:[d.jsx("dt",{children:"claude"}),d.jsx("dd",{children:le.claudeSessionId})]}),le.cwd&&d.jsxs(d.Fragment,{children:[d.jsx("dt",{children:"目录"}),d.jsx("dd",{children:le.cwd})]})]})]}),d.jsxs("div",{className:"relative flex-1 min-h-0 flex flex-col",children:[d.jsxs("div",{ref:U,className:"voice-message-stream","aria-live":"polite",onScroll:oe,children:[ye.messages.length===0&&i==="idle"&&d.jsxs("div",{className:"voice-empty-state",children:[d.jsx(WN,{size:18,strokeWidth:2,"aria-hidden":"true"}),d.jsx("p",{children:t("home.conversation.empty")})]}),ye.messages.map((V,xe)=>{var ze,_t;return d.jsxs("article",{className:`voice-message voice-message-${V.role}`,"data-streaming":V.status==="streaming",children:[d.jsxs("span",{children:[V.role==="user"?t("home.conversation.you"):t("home.conversation.ai"),V.role==="assistant"&&V.status==="streaming"&&d.jsxs("span",{className:"voice-live-status","data-phase":i,style:{marginLeft:8},children:[d.jsx("span",{"aria-hidden":"true"}),Bs]}),V.ts&&d.jsx("span",{style:{marginLeft:6,fontSize:10,opacity:.5,textTransform:"none",fontWeight:400,letterSpacing:0},title:new Date(V.ts).toLocaleString(),children:Dee(V.ts)})]}),d.jsxs("div",{className:"voice-bubble",children:[V.attachments&&V.attachments.length>0&&d.jsx(jee,{sessionId:ye.sessionId,paths:V.attachments,onImagePreview:ut=>Qe(ut)}),V.role==="assistant"&&V.status==="streaming"&&!V.content&&!((ze=V.blocks)!=null&&ze.length)&&d.jsxs("p",{className:"voice-thinking-line",children:[((_t=ye.thinking)==null?void 0:_t.trim())||t("home.conversation.thinking"),d.jsx("i",{"aria-hidden":"true"})]}),V.blocks&&V.blocks.length?d.jsxs("div",{className:"voice-blocks",children:[V.blocks.map((ut,yn)=>ut.type==="tool_use"&&FR(ut,(le==null?void 0:le.cwd)??null)||ut.type==="tool_use"&&ut.title===DO||ut.type==="interaction"&&Q&&ut.id===Q.id?null:d.jsx(GW,{block:ut,streaming:V.status==="streaming",sessionId:ye.sessionId??void 0,onOpenForm:Zt=>Dt({spec:XC(Zt),readOnly:Zt.status!=="pending",values:Zt.status!=="pending"&&Zt.answer&&typeof Zt.answer=="object"?Zt.answer:void 0,...Zt.status==="pending"&&Zt.respond!=="message"?{interaction:{id:Zt.id,revision:Zt.revision}}:{}})},yn)),(()=>{const ut=Cee(V.blocks);if(!ut)return null;const yn=Tee(ye.messages,xe);return d.jsx("div",{className:"mt-1",children:d.jsxs("button",{type:"button",className:yn?"nb-btn text-xs":"nb-btn nb-btn-primary text-sm",onClick:()=>Dt({spec:ut,readOnly:yn,values:yn?Aee(ye.messages,xe):void 0}),children:[d.jsx(XN,{size:14,strokeWidth:2.5}),yn?`${ut.title} · 已提交 ✓(点击查看)`:`${ut.title} · 点击填写配置`]})})})(),(()=>{const ut=UW(V.blocks,(le==null?void 0:le.cwd)??null);return ut.length>0&&ye.sessionId?d.jsx("div",{className:"flex flex-col items-start gap-2 mt-1",children:ut.map(yn=>d.jsx(FW,{sessionId:ye.sessionId,path:yn,onPreview:()=>Qe(yn)},yn))}):null})()]}):V.status==="streaming"?d.jsx($R,{text:V.content}):d.jsx(MR,{text:V.content}),V.truncated&&d.jsx("p",{className:"mt-2 px-2 py-1 rounded-md text-[11px] font-semibold bg-[var(--color-stuck-bg)] text-[var(--color-stuck)] border-2 border-[var(--color-stuck)]",children:t("chat.message.truncated")}),V.role==="assistant"&&V.status!=="streaming"&&V.content&&d.jsxs("div",{className:"voice-bubble-actions",children:[d.jsx("button",{type:"button",onClick:()=>Me(V.content),"aria-label":t("home.copy"),title:t("home.copy"),children:d.jsx(Oj,{size:13,strokeWidth:2.5})}),d.jsx("button",{type:"button",onClick:()=>Re(V.id,V.content),"aria-label":(We==null?void 0:We.id)===V.id?t("home.stop"):t("home.play"),title:(We==null?void 0:We.id)===V.id?t("home.stop"):t("home.play"),"data-active":(We==null?void 0:We.id)===V.id?"true":void 0,children:(We==null?void 0:We.id)===V.id?We.phase==="loading"?d.jsx(mt,{size:13,strokeWidth:2.5,className:"animate-spin"}):d.jsx(m0,{size:16,strokeWidth:2.4,fill:"currentColor"}):d.jsx(Vj,{size:13,strokeWidth:2.5})})]})]})]},V.id)}),i==="listening"&&d.jsxs("article",{className:"voice-message voice-message-user voice-message-live",children:[d.jsx("span",{children:t("home.conversation.you")}),d.jsx("p",{children:Qn.transcript||t("home.conversation.listening")})]}),i==="thinking"&&!Le&&d.jsxs("article",{className:"voice-message voice-message-assistant voice-message-thinking",children:[d.jsxs("span",{children:[t("home.conversation.ai"),d.jsxs("span",{className:"voice-live-status","data-phase":i,style:{marginLeft:8},children:[d.jsx("span",{"aria-hidden":"true"}),Bs]})]}),d.jsxs("p",{children:[((gt=ye.thinking)==null?void 0:gt.trim())||t("home.conversation.thinking"),d.jsx("i",{"aria-hidden":"true"})]})]})]}),$&&d.jsx("button",{type:"button",onClick:ce,"aria-label":t("logs.scroll.bottom.aria"),title:t("logs.scroll.bottom.aria"),className:"absolute bottom-3 right-4 z-10 w-9 h-9 flex items-center justify-center rounded-full border-2 border-[var(--color-text)] bg-[var(--color-bg)] shadow-[2px_2px_0_var(--color-text)] hover:shadow-[3px_3px_0_var(--color-text)] transition-shadow",children:d.jsx(zB,{size:16,strokeWidth:2.5})})]}),Wt.length>0&&d.jsxs("div",{className:"voice-artifacts","aria-label":t("home.artifacts.label"),children:[d.jsx(Uc,{size:13,strokeWidth:2.5,"aria-hidden":"true"}),d.jsxs("span",{className:"voice-artifacts-title",children:[t("home.artifacts.label")," (",Wt.length,")"]}),d.jsxs("div",{className:"voice-artifacts-list",children:[Wt.slice(0,6).map(V=>d.jsx("button",{type:"button",className:"voice-artifacts-chip is-clickable",title:`${V}(点击查看/下载)`,onClick:()=>hs(V),children:V.split("/").pop()},V)),Wt.length>6&&d.jsxs("span",{className:"voice-artifacts-chip",children:["+",Wt.length-6]})]})]}),Q&&we&&d.jsxs("div",{className:"interaction-dock","aria-label":Q.title,children:[Pe&&d.jsxs("div",{className:"interaction-dock-error",children:["提交失败:",Pe]}),d.jsx(C2,{spec:we,layout:"region",...ye.sessionId?{previewUrl:V=>$o(ye.sessionId,V)}:{},onSubmit:V=>He(Q,we,V),onSkip:()=>{ye.send("[让 AI 来定,按各字段推荐值 + 我们的对话补全,不用再逐项问我]")},onUpload:async V=>{const xe=await ye.ensureSession();return(await nx(xe,V)).path}},`${Q.id}:${Qt}`)]}),d.jsxs("div",{className:"voice-dock","data-drag":rr?"true":"false",onDragOver:V=>{V.dataTransfer.types.includes("Files")&&(V.preventDefault(),V.dataTransfer.dropEffect="copy",rr||ar(!0))},onDragLeave:V=>{V.currentTarget.contains(V.relatedTarget)||ar(!1)},onDrop:V=>{if(V.dataTransfer.types.includes("Files")){V.preventDefault(),ar(!1);for(const xe of Array.from(V.dataTransfer.files??[]))lt(xe)}},children:[y&&d.jsx("p",{className:"voice-error",role:"alert",children:y}),ii&&d.jsxs("div",{style:{padding:"10px 14px",margin:"0 0 8px",borderRadius:12,border:"2px solid var(--color-text)",background:"var(--color-bg-soft)",fontSize:13,lineHeight:1.5},children:[d.jsx("strong",{children:t("chat.cli.banner.bold")})," — ",t("chat.cli.banner"),d.jsxs("code",{style:{display:"block",marginTop:6,fontFamily:"var(--font-mono)",fontSize:12,opacity:.85},children:["sps agent --chat --name ",(ye.sessionId??"").replace(/^session-/,"")]})]}),(Wi.length>0||Is)&&d.jsxs("div",{className:"voice-attachments",children:[Wi.map(V=>d.jsxs("div",{className:"voice-attach-thumb",title:V.name,children:[cv(V.path)&&ye.sessionId?d.jsx("img",{src:$o(ye.sessionId,V.path),alt:V.name}):d.jsxs("div",{className:"voice-attach-doc",children:[d.jsx(Uc,{size:30,strokeWidth:1.6,"aria-hidden":"true"}),d.jsx("span",{className:"voice-attach-ext",children:RO(V.name)}),d.jsx("span",{className:"voice-attach-name",children:V.name})]}),d.jsx("button",{type:"button",className:"voice-attach-del",onClick:()=>Sl(V.path),"aria-label":t("home.attach.remove"),title:t("home.attach.remove"),children:d.jsx(En,{size:13,strokeWidth:3})})]},V.path)),Is&&d.jsx("div",{className:"voice-attach-thumb is-loading",children:d.jsx(mt,{size:16,className:"animate-spin"})})]}),d.jsxs("div",{className:"voice-orb-button","data-mode":si?"text":"voice",style:{...si?{"--pill-h":`${B}px`}:{},...ii?{opacity:.35,pointerEvents:"none"}:{}},children:[d.jsxs("div",{ref:X,className:"voice-flow-glass","data-phase":i,"data-mode":si?"text":"voice","data-glass":!j&&i!=="thinking"&&!si?"on":"off",role:"img","aria-label":t("home.visualizer.aria"),children:[d.jsx(gee,{phase:i,inputAnalyser:ke.analyser,outputText:go||t("home.message.speaking"),thinkingConfig:Kt}),!j&&d.jsx(rM,{active:i!=="thinking",activityLevelRef:pe,activityAnalyser:i==="listening"?ke.analyser:i==="speaking"?Ue.analyser??e:null,glass:i!=="thinking"&&!si,refraction:1.2,dispersion:1,glassSize:1,amplitude:Oe.amplitude,className:"voice-active-strands",colors:Oe.colors,count:Oe.count,glow:Oe.glow,hueShift:Oe.hueShift,intensity:Oe.intensity,opacity:Oe.opacity,saturation:Oe.saturation,scale:Oe.scale,speed:Oe.speed,spread:Oe.spread,taper:Oe.taper,thickness:Oe.thickness,waviness:Oe.waviness}),si&&d.jsxs("div",{className:"voice-input-inner",children:[d.jsx("textarea",{ref:G,className:"voice-input-field",rows:1,value:P,onChange:V=>{Je(V.target.value),ti()},onKeyDown:V=>{V.key==="Enter"&&!V.shiftKey&&!V.nativeEvent.isComposing&&(V.preventDefault(),ni())},onPaste:V=>{var ze;const xe=Array.from(((ze=V.clipboardData)==null?void 0:ze.items)??[]).filter(_t=>_t.kind==="file"&&_t.type.startsWith("image/"));if(xe.length!==0){V.preventDefault();for(const _t of xe){const ut=_t.getAsFile();ut&<(ut)}}},placeholder:t("home.text.placeholder"),"aria-label":t("home.text.placeholder")}),d.jsx("input",{ref:F,type:"file",multiple:!0,className:"hidden",onChange:V=>{for(const xe of Array.from(V.target.files??[]))lt(xe);V.target.value=""}}),d.jsx("button",{type:"button",className:"flex items-center justify-center w-9 h-9 rounded-full text-[var(--color-text-muted)] hover:text-[var(--color-text)] hover:bg-[var(--surface-control-hover)] transition-colors shrink-0",onClick:()=>{var V;return(V=F.current)==null?void 0:V.click()},disabled:ye.isSending,"aria-label":t("home.attach"),title:t("home.attach"),children:d.jsx(JU,{size:16,strokeWidth:2.5})}),d.jsx("button",{type:"button",className:"voice-send-btn",onClick:ni,disabled:!P.trim()||ye.isSending,"aria-label":t("home.text.send"),title:t("home.text.send"),children:d.jsx(m6,{size:16,strokeWidth:2.5})})]})]}),!M&&d.jsx("button",{type:"button",className:"voice-orb-hit",disabled:i==="thinking"||i==="speaking"||ii,"aria-label":t(i==="listening"?"home.voice.stop":"home.voice.start"),"aria-pressed":i==="listening",onClick:Ye}),Or&&d.jsx("button",{type:"button",className:"voice-stop-btn",onClick:ri,"aria-label":t("home.interrupt"),title:t("home.interrupt"),children:d.jsx(m0,{size:18,strokeWidth:0,fill:"currentColor","aria-hidden":"true"})})]}),d.jsx("p",{className:"voice-dock-label",children:t(M?"home.text.hint":i==="listening"?"home.voice.finish":i==="idle"&&o?"home.auto.armedOpen":`home.voice.${i}`)}),d.jsxs("div",{className:"voice-toggle-stack",children:[d.jsx(j2,{checked:M,onChange:D,title:t("home.inputToggle"),ariaLabel:t("home.inputToggle"),onIcon:d.jsx(WN,{size:16,strokeWidth:2.4}),offIcon:d.jsx(IU,{size:16,strokeWidth:2.4})}),!M&&!ii&&d.jsx(j2,{checked:o,onChange:Pt,title:t("home.auto.tip"),ariaLabel:t("home.auto.toggle"),onIcon:d.jsx(Ij,{size:16,strokeWidth:2.4}),offIcon:d.jsx(fU,{size:16,strokeWidth:2.4})})]})]})]}),p&&d.jsx("div",{className:"voice-debug-backdrop",role:"presentation",onMouseDown:V=>{V.target===V.currentTarget&&m(!1)},children:d.jsxs("section",{className:"voice-debug-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"voice-debug-title",children:[d.jsxs("header",{className:"voice-debug-header",children:[d.jsxs("div",{children:[d.jsx(XN,{size:16,strokeWidth:2.2,"aria-hidden":"true"}),d.jsx("h2",{id:"voice-debug-title",children:t("home.customize.title")})]}),d.jsxs("div",{children:[d.jsx("button",{type:"button","aria-label":t("home.customize.reset"),title:t("home.customize.reset"),onClick:()=>W(V=>({...V,[u]:yd(gd[u])})),children:d.jsx(Jv,{size:15,strokeWidth:2.2,"aria-hidden":"true"})}),d.jsx("button",{type:"button","aria-label":t("home.debug.close"),title:t("home.debug.close"),onClick:()=>m(!1),children:d.jsx(En,{size:16,strokeWidth:2.2,"aria-hidden":"true"})})]})]}),d.jsx("div",{className:"voice-debug-phases",role:"group","aria-label":t("home.phase.aria"),children:Eee.map(V=>{const xe=V.icon;return d.jsxs("button",{type:"button","aria-pressed":u===V.id,onClick:()=>f(V.id),children:[d.jsx(xe,{size:15,strokeWidth:2.2,"aria-hidden":"true"}),t(V.labelKey)]},V.id)})}),d.jsxs("div",{className:"voice-debug-body",children:[d.jsxs("fieldset",{className:"voice-customizer-group",children:[d.jsx("legend",{children:t("home.customize.colors")}),ht.colors.map((V,xe)=>d.jsxs("label",{className:"voice-color-control",children:[d.jsx("span",{children:t(`home.customize.color${xe+1}`)}),d.jsx("input",{type:"color",value:V,onChange:ze=>zs(xe,ze.target.value)}),d.jsx("code",{children:V.toUpperCase()})]},xe))]}),d.jsxs("fieldset",{className:"voice-customizer-group",children:[d.jsx("legend",{children:t("home.customize.parameters")}),kee.map(V=>{const xe=t(V.labelKey),ze=ht[V.key];return d.jsxs("label",{className:"voice-parameter-control",children:[d.jsx("span",{children:xe}),d.jsx("input",{type:"number",min:V.min,max:V.max,step:V.step,value:ze,"aria-label":`${xe} value`,onChange:_t=>Ps(V,Number(_t.target.value))}),d.jsx("input",{type:"range",min:V.min,max:V.max,step:V.step,value:ze,"aria-label":xe,onChange:_t=>Ps(V,Number(_t.target.value))})]},V.key)})]})]})]})})]})]})}const rp=e=>e.lastActivityAt?Date.parse(e.lastActivityAt):0;function IO(e,t){const n=[...e];return t==="name"?n.sort((i,s)=>i.name.localeCompare(s.name)):t==="date"?n.sort((i,s)=>rp(s)-rp(i)):n.sort((i,s)=>{const r=i.pipelineStatus==="running"?1:0,o=s.pipelineStatus==="running"?1:0;return r!==o?o-r:rp(s)-rp(i)})}function Oee(e){const t=new URLSearchParams;return e.project&&t.set("project",e.project),e.worker&&t.set("worker",e.worker),t.set("limit",String(e.limit)),e.since&&t.set("since",e.since),e.file&&t.set("file",e.file),St(`/api/logs?${t}`)}function Lee(e){return St(`/api/logs/sources?project=${encodeURIComponent(e)}`)}const Iee=["error","warn","info","debug"],Pee=["error","warn","info"];function zee({project:e,initialWorker:t}){const n=Xe(),i=t??"",[s,r]=_.useState([]),[o,c]=_.useState(!0),[u,f]=_.useState(()=>new Set(Pee)),[p,m]=_.useState(""),y=_.useRef(null),[b,x]=_.useState(""),{data:v}=ot({queryKey:["log-sources",e],queryFn:()=>Lee(e),enabled:!!e,refetchInterval:5e3}),w=_.useMemo(()=>(v==null?void 0:v.sources)??[],[v]),k=w.find(A=>A.key===b)??(i?w.find(A=>A.worker===Number(i)):void 0)??w.find(A=>A.kind==="pipeline")??w[0],C=k==null?void 0:k.file;_.useEffect(()=>{r([])},[e,C]);const{data:S}=ot({queryKey:["logs",e,C],queryFn:()=>Oee({project:e,file:C,limit:500}),enabled:!!e,refetchInterval:2500});_.useEffect(()=>{S!=null&&S.data&&r(S.data)},[S]),_.useEffect(()=>{if(!o)return;const A=y.current;A&&(A.scrollTop=A.scrollHeight)},[s,o]);const T=_.useMemo(()=>{const A=p.toLowerCase();return s.filter(j=>!(!u.has(j.level)||A&&!j.msg.toLowerCase().includes(A)))},[s,u,p]);return d.jsxs("div",{className:"flex h-full min-h-0 max-w-full flex-col gap-3",children:[d.jsxs("div",{className:"flex shrink-0 items-center gap-1.5 flex-wrap",children:[w.filter(A=>A.worker==null).map(A=>d.jsx(ZC,{s:A,active:(k==null?void 0:k.key)===A.key,onClick:()=>x(A.key)},A.key)),d.jsx("div",{className:"flex flex-1 min-w-0 items-center gap-1.5 flex-wrap",children:w.filter(A=>A.worker!=null).map(A=>d.jsx(ZC,{s:A,active:(k==null?void 0:k.key)===A.key,onClick:()=>x(A.key)},A.key))}),Iee.map(A=>d.jsx(Bee,{level:A,enabled:u.has(A),onToggle:()=>{f(j=>{const M=new Set(j);return M.has(A)?M.delete(A):M.add(A),M})}},A)),d.jsxs("div",{className:"relative min-w-[160px] max-w-xs",children:[d.jsx(mf,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-[var(--color-text-subtle)]"}),d.jsx("input",{className:"nb-input pl-9 w-full",placeholder:n("logs.filter.keyword.placeholder"),value:p,onChange:A=>m(A.target.value),"aria-label":n("logs.filter.keyword.aria")})]})]}),d.jsxs("div",{className:"scroll-frame flex min-h-0 flex-1 flex-col rounded-2xl border border-[var(--surface-card-border)] bg-[var(--color-bg-soft)]",children:[d.jsxs("div",{className:"px-4 py-2 bg-[var(--surface-table-head)] border-b-2 border-[var(--color-text)]/15 flex shrink-0 items-center justify-between font-[family-name:var(--font-mono)] text-xs",children:[d.jsxs("span",{className:"text-[var(--color-text-muted)]",children:[(S==null?void 0:S.file)??`~/.coral/projects/${e}/logs/*.log`," · ",s.length," lines"]}),d.jsx("span",{className:"nb-status",style:{background:"var(--color-running-bg)",color:"var(--color-running)"},children:"live"})]}),d.jsxs("div",{ref:y,className:"scroll-frame-body flex-1 bg-surface-input font-[family-name:var(--font-mono)] text-[12px] leading-[22px] p-2",onScroll:A=>{const j=A.currentTarget,M=j.scrollHeight-j.scrollTop-j.clientHeight<40;c(M)},children:[T.map((A,j)=>d.jsx(Uee,{line:A},j)),T.length===0&&d.jsx("div",{className:"text-center py-12 text-[var(--color-text-subtle)]",children:n("logs.empty.match")})]})]})]})}function Bee({level:e,enabled:t,onToggle:n}){const i={error:"var(--color-crashed-bg)",warn:"var(--color-stuck-bg)",info:"var(--color-secondary)",debug:"var(--color-accent-purple)"},s={error:"var(--color-crashed)",warn:"var(--color-stuck)",info:"var(--color-text)",debug:"var(--color-text)"};return d.jsx("button",{type:"button",onClick:n,"aria-pressed":t,className:["px-2.5 py-1 rounded-full text-xs font-bold border-[2px] border-[var(--color-text)] font-[family-name:var(--font-mono)] tracking-wide",t?"shadow-[1px_1px_0_var(--color-text)]":"bg-white text-[var(--color-text-muted)]"].join(" "),style:t?{background:i[e],color:s[e]}:{},children:e.toUpperCase()})}function Uee({line:e}){var n;const t={error:"bg-[var(--color-crashed-bg)] text-[var(--color-crashed)] border border-[var(--color-crashed-bg)]",warn:"bg-[var(--color-stuck-bg)] text-[var(--color-stuck)] border border-[var(--color-stuck-bg)]",info:"bg-[var(--color-info-bg)] text-[var(--color-info)] border border-[var(--color-info-bg)]",debug:"",trace:""};return d.jsxs("div",{className:"grid gap-2 px-2 py-0.5 rounded hover:bg-[var(--surface-control-hover)] grid-cols-[100px_60px_1fr]",children:[d.jsx("span",{className:"text-[var(--color-text-subtle)] whitespace-nowrap",children:e.ts?((n=e.ts.split("T")[1])==null?void 0:n.replace("Z",""))??e.ts:"--"}),d.jsx("span",{className:`text-center font-bold ${t[e.level]??""}`,style:{borderRadius:4,padding:"0 6px"},children:e.level.toUpperCase()}),d.jsx("span",{className:"truncate text-[var(--color-text)]",children:e.msg})]})}function ZC({s:e,active:t,onClick:n}){const i=e.status==="running"?"var(--color-running)":e.status==="error"?"var(--color-crashed)":"var(--color-idle)";return d.jsxs("button",{type:"button",onClick:n,"aria-pressed":t,"aria-label":`查看${e.label}日志`,className:["px-2.5 py-1 rounded-full text-xs font-bold border-[2px] border-[var(--color-text)] flex items-center gap-1.5",t?"bg-[var(--color-primary)] text-[var(--color-text)] shadow-[1px_1px_0_var(--color-text)]":"bg-white text-[var(--color-text-muted)]"].join(" "),children:[e.worker!=null&&d.jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:i,display:"inline-block"},"aria-hidden":!0}),e.label]})}function ou({options:e,value:t,onChange:n,ariaLabel:i,className:s=""}){const r=_.useRef(null),[o,c]=_.useState(null),u=Math.max(0,e.findIndex(f=>f.value===t));return _.useLayoutEffect(()=>{const f=r.current;if(!f)return;const p=()=>{const y=f.querySelector(`[data-idx="${u}"]`);if(!y)return;const b=f.getBoundingClientRect(),x=y.getBoundingClientRect();c({x:x.left-b.left-f.clientLeft,w:x.width})};p();const m=new ResizeObserver(p);return m.observe(f),()=>m.disconnect()},[u,e.length]),d.jsxs("div",{ref:r,className:`slide-tabs ${s}`,role:"tablist","aria-label":i,children:[o&&d.jsx("span",{className:"slide-tabs-bg","aria-hidden":"true",style:{transform:`translateX(${o.x}px)`,width:o.w}}),e.map((f,p)=>d.jsx("button",{"data-idx":p,type:"button",role:"tab","aria-selected":f.value===t,onClick:()=>n(f.value),className:`slide-tabs-label ${f.value===t?"is-active":""}`,children:f.label},f.value))]})}const iw=Symbol.for("yaml.alias"),uv=Symbol.for("yaml.document"),so=Symbol.for("yaml.map"),PO=Symbol.for("yaml.pair"),_r=Symbol.for("yaml.scalar"),lu=Symbol.for("yaml.seq"),As=Symbol.for("yaml.node.type"),mo=e=>!!e&&typeof e=="object"&&e[As]===iw,wl=e=>!!e&&typeof e=="object"&&e[As]===uv,cu=e=>!!e&&typeof e=="object"&&e[As]===so,kn=e=>!!e&&typeof e=="object"&&e[As]===PO,fn=e=>!!e&&typeof e=="object"&&e[As]===_r,uu=e=>!!e&&typeof e=="object"&&e[As]===lu;function Cn(e){if(e&&typeof e=="object")switch(e[As]){case so:case lu:return!0}return!1}function An(e){if(e&&typeof e=="object")switch(e[As]){case iw:case so:case _r:case lu:return!0}return!1}const zO=e=>(fn(e)||Cn(e))&&!!e.anchor,Hi=Symbol("break visit"),BO=Symbol("skip children"),kr=Symbol("remove node");function El(e,t){const n=UO(t);wl(e)?pc(null,e.contents,n,Object.freeze([e]))===kr&&(e.contents=null):pc(null,e,n,Object.freeze([]))}El.BREAK=Hi;El.SKIP=BO;El.REMOVE=kr;function pc(e,t,n,i){const s=FO(e,t,n,i);if(An(s)||kn(s))return $O(e,i,s),pc(e,s,n,i);if(typeof s!="symbol"){if(Cn(t)){i=Object.freeze(i.concat(t));for(let r=0;r<t.items.length;++r){const o=pc(r,t.items[r],n,i);if(typeof o=="number")r=o-1;else{if(o===Hi)return Hi;o===kr&&(t.items.splice(r,1),r-=1)}}}else if(kn(t)){i=Object.freeze(i.concat(t));const r=pc("key",t.key,n,i);if(r===Hi)return Hi;r===kr&&(t.key=null);const o=pc("value",t.value,n,i);if(o===Hi)return Hi;o===kr&&(t.value=null)}}return s}async function Gm(e,t){const n=UO(t);wl(e)?await mc(null,e.contents,n,Object.freeze([e]))===kr&&(e.contents=null):await mc(null,e,n,Object.freeze([]))}Gm.BREAK=Hi;Gm.SKIP=BO;Gm.REMOVE=kr;async function mc(e,t,n,i){const s=await FO(e,t,n,i);if(An(s)||kn(s))return $O(e,i,s),mc(e,s,n,i);if(typeof s!="symbol"){if(Cn(t)){i=Object.freeze(i.concat(t));for(let r=0;r<t.items.length;++r){const o=await mc(r,t.items[r],n,i);if(typeof o=="number")r=o-1;else{if(o===Hi)return Hi;o===kr&&(t.items.splice(r,1),r-=1)}}}else if(kn(t)){i=Object.freeze(i.concat(t));const r=await mc("key",t.key,n,i);if(r===Hi)return Hi;r===kr&&(t.key=null);const o=await mc("value",t.value,n,i);if(o===Hi)return Hi;o===kr&&(t.value=null)}}return s}function UO(e){return typeof e=="object"&&(e.Collection||e.Node||e.Value)?Object.assign({Alias:e.Node,Map:e.Node,Scalar:e.Node,Seq:e.Node},e.Value&&{Map:e.Value,Scalar:e.Value,Seq:e.Value},e.Collection&&{Map:e.Collection,Seq:e.Collection},e):e}function FO(e,t,n,i){var s,r,o,c,u;if(typeof n=="function")return n(e,t,i);if(cu(t))return(s=n.Map)==null?void 0:s.call(n,e,t,i);if(uu(t))return(r=n.Seq)==null?void 0:r.call(n,e,t,i);if(kn(t))return(o=n.Pair)==null?void 0:o.call(n,e,t,i);if(fn(t))return(c=n.Scalar)==null?void 0:c.call(n,e,t,i);if(mo(t))return(u=n.Alias)==null?void 0:u.call(n,e,t,i)}function $O(e,t,n){const i=t[t.length-1];if(Cn(i))i.items[e]=n;else if(kn(i))e==="key"?i.key=n:i.value=n;else if(wl(i))i.contents=n;else{const s=mo(i)?"alias":"scalar";throw new Error(`Cannot replace node with ${s} parent`)}}const Fee={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},$ee=e=>e.replace(/[!,[\]{}]/g,t=>Fee[t]);class Ai{constructor(t,n){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},Ai.defaultYaml,t),this.tags=Object.assign({},Ai.defaultTags,n)}clone(){const t=new Ai(this.yaml,this.tags);return t.docStart=this.docStart,t}atDocument(){const t=new Ai(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:Ai.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},Ai.defaultTags);break}return t}add(t,n){this.atNextDocument&&(this.yaml={explicit:Ai.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},Ai.defaultTags),this.atNextDocument=!1);const i=t.trim().split(/[ \t]+/),s=i.shift();switch(s){case"%TAG":{if(i.length!==2&&(n(0,"%TAG directive should contain exactly two parts"),i.length<2))return!1;const[r,o]=i;return this.tags[r]=o,!0}case"%YAML":{if(this.yaml.explicit=!0,i.length!==1)return n(0,"%YAML directive should contain exactly one part"),!1;const[r]=i;if(r==="1.1"||r==="1.2")return this.yaml.version=r,!0;{const o=/^\d+\.\d+$/.test(r);return n(6,`Unsupported YAML version ${r}`,o),!1}}default:return n(0,`Unknown directive ${s}`,!0),!1}}tagName(t,n){if(t==="!")return"!";if(t[0]!=="!")return n(`Not a valid tag: ${t}`),null;if(t[1]==="<"){const o=t.slice(2,-1);return o==="!"||o==="!!"?(n(`Verbatim tags aren't resolved, so ${t} is invalid.`),null):(t[t.length-1]!==">"&&n("Verbatim tags must end with a >"),o)}const[,i,s]=t.match(/^(.*!)([^!]*)$/s);s||n(`The ${t} tag has no suffix`);const r=this.tags[i];if(r)try{return r+decodeURIComponent(s)}catch(o){return n(String(o)),null}return i==="!"?t:(n(`Could not resolve tag: ${t}`),null)}tagString(t){for(const[n,i]of Object.entries(this.tags))if(t.startsWith(i))return n+$ee(t.substring(i.length));return t[0]==="!"?t:`!<${t}>`}toString(t){const n=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],i=Object.entries(this.tags);let s;if(t&&i.length>0&&An(t.contents)){const r={};El(t.contents,(o,c)=>{An(c)&&c.tag&&(r[c.tag]=!0)}),s=Object.keys(r)}else s=[];for(const[r,o]of i)r==="!!"&&o==="tag:yaml.org,2002:"||(!t||s.some(c=>c.startsWith(o)))&&n.push(`%TAG ${r} ${o}`);return n.join(`
|
|
667
|
+
`,1;if(go>1e5&&go>Ke.index*3)throw new Error("potential infinite loop, way more iterations than matches");return Kt+=gt,gt.length}const Mn=Xn(je);if(!Mn)throw Me(Ht.replace("{}",je)),new Error('Unknown language: "'+je+'"');const rr=he(Mn);let ar="",lt=Pt||rr;const Sl={},_n=new Fe.__emitter(Fe);Wi();let Kt="",Ps=0,zs=0,go=0,Bs=!1;try{if(Mn.__emitTokens)Mn.__emitTokens(Ye,_n);else{for(lt.matcher.considerAll();;){go++,Bs?Bs=!1:lt.matcher.considerAll(),lt.matcher.lastIndex=zs;const Le=lt.matcher.exec(Ye);if(!Le)break;const Ke=Ye.substring(zs,Le.index),gt=Is(Ke,Le);zs=Le.index+gt}Is(Ye.substring(zs))}return _n.finalize(),ar=_n.toHTML(),{language:je,value:ar,relevance:Ps,illegal:!1,_emitter:_n,_top:lt}}catch(Le){if(Le.message&&Le.message.includes("Illegal"))return{language:je,value:st(Ye),illegal:!0,relevance:0,_illegalBy:{message:Le.message,index:zs,context:Ye.slice(zs-100,zs+100),mode:Le.mode,resultSoFar:ar},_emitter:_n};if(Qt)return{language:je,value:st(Ye),illegal:!1,relevance:0,errorRaised:Le,_emitter:_n,_top:lt};throw Le}}function us(je){const Ye={value:st(je),illegal:!1,relevance:0,_top:He,_emitter:new Fe.__emitter(Fe)};return Ye._emitter.addText(je),Ye}function ds(je,Ye){Ye=Ye||Fe.languages||Object.keys(we);const xt=us(je),Pt=Ye.filter(Xn).filter(Si).map(Vt=>ki(Vt,je,!1));Pt.unshift(xt);const gn=Pt.sort((Vt,ni)=>{if(Vt.relevance!==ni.relevance)return ni.relevance-Vt.relevance;if(Vt.language&&ni.language){if(Xn(Vt.language).supersetOf===ni.language)return 1;if(Xn(ni.language).supersetOf===Vt.language)return-1}return 0}),[Un,ci]=gn,ti=Un;return ti.secondBest=ci,ti}function Di(je,Ye,xt){const Pt=Ye&&Pe[Ye]||xt;je.classList.add("hljs"),je.classList.add(`language-${Pt}`)}function pn(je){let Ye=null;const xt=hn(je);if(rt(xt))return;if(Qn("before:highlightElement",{el:je,language:xt}),je.dataset.highlighted){console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",je);return}if(je.children.length>0&&(Fe.ignoreUnescapedHTML||(console.warn("One of your code blocks includes unescaped HTML. This is a potentially serious security risk."),console.warn("https://github.com/highlightjs/highlight.js/wiki/security"),console.warn("The element with unescaped HTML:"),console.warn(je)),Fe.throwUnescapedHTML))throw new Qe("One of your code blocks includes unescaped HTML.",je.innerHTML);Ye=je;const Pt=Ye.textContent,gn=xt?on(Pt,{language:xt,ignoreIllegals:!0}):ds(Pt);je.innerHTML=gn.value,je.dataset.highlighted="yes",Di(je,xt,gn.language),je.result={language:gn.language,re:gn.relevance,relevance:gn.relevance},gn.secondBest&&(je.secondBest={language:gn.secondBest.language,relevance:gn.secondBest.relevance}),Qn("after:highlightElement",{el:je,result:gn,text:Pt})}function In(je){Fe=$e(Fe,je)}const Yn=()=>{Os(),ne("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")};function Ds(){Os(),ne("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")}let jr=!1;function Os(){function je(){Os()}if(document.readyState==="loading"){jr||window.addEventListener("DOMContentLoaded",je,!1),jr=!0;return}document.querySelectorAll(Fe.cssSelector).forEach(pn)}function Mr(je,Ye){let xt=null;try{xt=Ye(Q)}catch(Pt){if(Me("Language definition for '{}' could not be registered.".replace("{}",je)),Qt)Me(Pt);else throw Pt;xt=He}xt.name||(xt.name=je),we[je]=xt,xt.rawDefinition=Ye.bind(null,Q),xt.aliases&&Gi(xt.aliases,{languageName:je})}function fs(je){delete we[je];for(const Ye of Object.keys(Pe))Pe[Ye]===je&&delete Pe[Ye]}function Rr(){return Object.keys(we)}function Xn(je){return je=(je||"").toLowerCase(),we[je]||we[Pe[je]]}function Gi(je,{languageName:Ye}){typeof je=="string"&&(je=[je]),je.forEach(xt=>{Pe[xt.toLowerCase()]=Ye})}function Si(je){const Ye=Xn(je);return Ye&&!Ye.disableAutodetect}function hs(je){je["before:highlightBlock"]&&!je["before:highlightElement"]&&(je["before:highlightElement"]=Ye=>{je["before:highlightBlock"](Object.assign({block:Ye.el},Ye))}),je["after:highlightBlock"]&&!je["after:highlightElement"]&&(je["after:highlightElement"]=Ye=>{je["after:highlightBlock"](Object.assign({block:Ye.el},Ye))})}function vn(je){hs(je),ct.push(je)}function Dr(je){const Ye=ct.indexOf(je);Ye!==-1&&ct.splice(Ye,1)}function Qn(je,Ye){const xt=je;ct.forEach(function(Pt){Pt[xt]&&Pt[xt](Ye)})}function jn(je){return ne("10.7.0","highlightBlock will be removed entirely in v12.0"),ne("10.7.0","Please use highlightElement now."),pn(je)}Object.assign(Q,{highlight:on,highlightAuto:ds,highlightAll:Os,highlightElement:pn,highlightBlock:jn,configure:In,initHighlighting:Yn,initHighlightingOnLoad:Ds,registerLanguage:Mr,unregisterLanguage:fs,listLanguages:Rr,getLanguage:Xn,registerAliases:Gi,autoDetection:Si,inherit:$e,addPlugin:vn,removePlugin:Dr}),Q.debugMode=function(){Qt=!1},Q.safeMode=function(){Qt=!0},Q.versionString=Ae,Q.regex={concat:v,lookahead:y,either:k,optional:x,anyNumberOfTimes:b};for(const je in re)typeof re[je]=="object"&&e(re[je]);return Object.assign(Q,re),Q},Dt=Xt({});return Dt.newInstance=()=>Xt({}),tx=Dt,Dt.HighlightJS=Dt,Dt.default=Dt,tx}var cW=lW();const uW=cf(cW),N2={},dW="hljs-";function fW(e){const t=uW.newInstance();return e&&r(e),{highlight:n,highlightAuto:i,listLanguages:s,register:r,registerAlias:o,registered:c};function n(u,f,p){const m=p||N2,y=typeof m.prefix=="string"?m.prefix:dW;if(!t.getLanguage(u))throw new Error("Unknown language: `"+u+"` is not registered");t.configure({__emitter:hW,classPrefix:y});const b=t.highlight(f,{ignoreIllegals:!0,language:u});if(b.errorRaised)throw new Error("Could not highlight with `Highlight.js`",{cause:b.errorRaised});const x=b._emitter.root,v=x.data;return v.language=b.language,v.relevance=b.relevance,x}function i(u,f){const m=(f||N2).subset||s();let y=-1,b=0,x;for(;++y<m.length;){const v=m[y];if(!t.getLanguage(v))continue;const w=n(v,u,f);w.data&&w.data.relevance!==void 0&&w.data.relevance>b&&(b=w.data.relevance,x=w)}return x||{type:"root",children:[],data:{language:void 0,relevance:b}}}function s(){return t.listLanguages()}function r(u,f){if(typeof u=="string")t.registerLanguage(u,f);else{let p;for(p in u)Object.hasOwn(u,p)&&t.registerLanguage(p,u[p])}}function o(u,f){if(typeof u=="string")t.registerAliases(typeof f=="string"?f:[...f],{languageName:u});else{let p;for(p in u)if(Object.hasOwn(u,p)){const m=u[p];t.registerAliases(typeof m=="string"?m:[...m],{languageName:p})}}}function c(u){return!!t.getLanguage(u)}}class hW{constructor(t){this.options=t,this.root={type:"root",children:[],data:{language:void 0,relevance:0}},this.stack=[this.root]}addText(t){if(t==="")return;const n=this.stack[this.stack.length-1],i=n.children[n.children.length-1];i&&i.type==="text"?i.value+=t:n.children.push({type:"text",value:t})}startScope(t){this.openNode(String(t))}endScope(){this.closeNode()}__addSublanguage(t,n){const i=this.stack[this.stack.length-1],s=t.root.children;n?i.children.push({type:"element",tagName:"span",properties:{className:[n]},children:s}):i.children.push(...s)}openNode(t){const n=this,i=t.split(".").map(function(o,c){return c?o+"_".repeat(c):n.options.classPrefix+o}),s=this.stack[this.stack.length-1],r={type:"element",tagName:"span",properties:{className:i},children:[]};s.children.push(r),this.stack.push(r)}closeNode(){this.stack.pop()}finalize(){}toHTML(){return""}}const pW={};function _1(e){const t=e||pW,n=t.aliases,i=t.detect||!1,s=t.languages||oW,r=t.plainText,o=t.prefix,c=t.subset;let u="hljs";const f=fW(s);if(n&&f.registerAlias(n),o){const p=o.indexOf("-");u=p===-1?o:o.slice(0,p)}return function(p,m){$m(p,"element",function(y,b,x){if(y.tagName!=="code"||!x||x.type!=="element"||x.tagName!=="pre")return;const v=mW(y);if(v===!1||!v&&!i||v&&r&&r.includes(v))return;Array.isArray(y.properties.className)||(y.properties.className=[]),y.properties.className.includes(u)||y.properties.className.unshift(u);const w=O7(y,{whitespace:"pre"});let k;try{k=v?f.highlight(v,w,{prefix:o}):f.highlightAuto(w,{prefix:o,subset:c})}catch(C){const S=C;if(v&&/Unknown language/.test(S.message)){m.message("Cannot highlight as `"+v+"`, it’s not registered",{ancestors:[x,y],cause:S,place:y.position,ruleId:"missing-language",source:"rehype-highlight"});return}throw S}!v&&k.data&&k.data.language&&y.properties.className.push("language-"+k.data.language),k.children.length>0&&(y.children=k.children)})}}function mW(e){const t=e.properties.className;let n=-1;if(!Array.isArray(t))return;let i;for(;++n<t.length;){const s=String(t[n]);if(s==="no-highlight"||s==="nohighlight")return!1;!i&&s.slice(0,5)==="lang-"&&(i=s.slice(5)),!i&&s.slice(0,9)==="language-"&&(i=s.slice(9))}return i}function MR({text:e}){return e?d.jsx("div",{className:"prose-chat text-sm break-words font-[family-name:var(--font-body)]",children:d.jsx(x1,{remarkPlugins:[k1],rehypePlugins:[_1],children:e})}):null}const gW=["chat.message","chat.message.pending","chat.message.snapshot","chat.message.chunk.text","chat.message.chunk.thinking","chat.message.chunk.tool_use","chat.message.chunk.tool_update","chat.message.chunk.interaction","chat.message.interaction.updated","chat.message.complete","chat.message.error","chat.resync.required"];function pi(e){return typeof e=="string"?e:""}function _2(e,t){return typeof e=="number"&&Number.isFinite(e)?e:t}function yW(e,t,n){if(!t||typeof t!="object"||!n)return null;const i=t,s=pi(i.sessionId);if(s&&s!==n)return null;const r=n,o=typeof i.seq=="number"?i.seq:void 0,c=pi(i.assistantId)||pi(i.turnId);switch(e){case"chat.message":return i.message?{type:"message.appended",sessionId:r,message:i.message,seq:o}:null;case"chat.message.pending":return c?{type:"turn.pending",sessionId:r,turnId:c,seq:o}:null;case"chat.message.snapshot":return c?{type:"turn.snapshot",sessionId:r,turnId:c,blocks:i.blocks??[],seq:o}:null;case"chat.message.chunk.text":return c&&typeof i.text=="string"?{type:"text.delta",sessionId:r,turnId:c,text:i.text,seq:o}:null;case"chat.message.chunk.thinking":return c&&typeof i.text=="string"?{type:"thinking.delta",sessionId:r,turnId:c,text:i.text,seq:o}:null;case"chat.message.chunk.tool_use":return c&&pi(i.id)?{type:"tool_use.started",sessionId:r,turnId:c,id:pi(i.id),title:pi(i.title),kind:pi(i.kind),status:pi(i.status),input:i.input,locations:i.locations,seq:o}:null;case"chat.message.chunk.tool_update":return c&&pi(i.id)?{type:"tool_use.updated",sessionId:r,turnId:c,id:pi(i.id),status:pi(i.status),input:i.input,locations:i.locations,seq:o}:null;case"chat.message.chunk.interaction":return c&&pi(i.id)?{type:"interaction.required",sessionId:r,turnId:c,id:pi(i.id),kind:pi(i.kind),title:pi(i.title),schema:i.schema,...i.respond==="message"||i.respond==="endpoint"?{respond:i.respond}:{},revision:_2(i.revision,1),seq:o}:null;case"chat.message.interaction.updated":return pi(i.interactionId)?{type:"interaction.updated",sessionId:r,interactionId:pi(i.interactionId),status:i.status==="cancelled"?"cancelled":"answered",revision:_2(i.revision,1),answer:i.answer,seq:o}:null;case"chat.message.complete":return c&&i.message?{type:"turn.completed",sessionId:r,turnId:c,message:i.message,seq:o}:null;case"chat.resync.required":return{type:"resync.required",sessionId:r,...typeof i.reason=="string"?{reason:i.reason}:{}};case"chat.message.error":return{type:"turn.failed",sessionId:r,...c?{turnId:c}:{},...i.message?{message:i.message}:{},seq:o};default:return null}}const bW="optim-";function O0(e,t){return{sessionId:e,turnId:t,blocks:[],done:!1,finalMessage:null}}function ld(e,t){return e.pending&&e.pending.turnId===t?e.pending:O0(e.sessionId,t)}function L0(e,t){if(e.some(i=>i.id===t.id))return e;const n=e.findIndex(i=>i.role==="user"&&i.id.startsWith(bW)&&i.role===t.role&&i.content===t.content);if(n>=0){const i=[...e];return i[n]=t,i}return[...e,t]}function xW(e,t,n){let i=!1;const s=e.map(r=>{var o;return(o=r.blocks)!=null&&o.some(c=>c.type==="interaction"&&c.id===t)?(i=!0,{...r,blocks:r.blocks.map(c=>c.type==="interaction"&&c.id===t?{...c,...n}:c)}):r});return i?s:e}function vW(e,t){if(t.sessionId!==e.sessionId)return e;const n="turnId"in t?t.turnId:void 0;if(typeof t.seq=="number"&&t.seq>0){const i=n===void 0||n===e.seqTurnId;if(i&&t.seq<=e.lastSeq)return e;i&&e.lastSeq>0&&t.seq>e.lastSeq+1&&(e={...e,gapDetected:!0}),e={...e,lastSeq:t.seq,...n!==void 0?{seqTurnId:n}:{}}}switch(t.type){case"message.appended":return{...e,messages:L0(e.messages,t.message)};case"turn.pending":return{...e,pending:O0(e.sessionId,t.turnId)};case"turn.snapshot":return{...e,pending:{...O0(e.sessionId,t.turnId),blocks:[...t.blocks]}};case"text.delta":{const i=ld(e,t.turnId),s=[...i.blocks],r=s[s.length-1];return r&&r.type==="text"?s[s.length-1]={...r,text:r.text+t.text}:s.push({type:"text",text:t.text}),{...e,pending:{...i,blocks:s}}}case"thinking.delta":{const i=ld(e,t.turnId);return{...e,pending:{...i,thinking:(i.thinking??"")+t.text}}}case"tool_use.started":{const i=ld(e,t.turnId),s={type:"tool_use",id:t.id,title:t.title,kind:t.kind,status:t.status,input:t.input,locations:t.locations},r=i.blocks.findIndex(c=>c.type==="tool_use"&&c.id===t.id),o=[...i.blocks];if(r>=0){const c=o[r];o[r]={...s,input:c.input??t.input}}else o.push(s);return{...e,pending:{...i,blocks:o}}}case"tool_use.updated":{if(!e.pending||e.pending.turnId!==t.turnId)return e;const i=e.pending;return{...e,pending:{...i,blocks:i.blocks.map(s=>s.type==="tool_use"&&s.id===t.id?{...s,status:t.status,input:s.input??t.input,locations:s.locations??t.locations}:s)}}}case"interaction.required":{const i=ld(e,t.turnId),s=i.blocks.findIndex(c=>c.type==="interaction"&&c.id===t.id),r={type:"interaction",id:t.id,kind:t.kind,title:t.title,schema:t.schema,...t.respond?{respond:t.respond}:{},revision:t.revision,status:"pending"},o=[...i.blocks];return s>=0?o[s]=r:o.push(r),{...e,pending:{...i,blocks:o}}}case"interaction.updated":{const i={status:t.status,revision:t.revision,...t.answer!==void 0?{answer:t.answer}:{}},s=e.pending,r=s&&s.blocks.some(o=>o.type==="interaction"&&o.id===t.interactionId)?{...s,blocks:s.blocks.map(o=>o.type==="interaction"&&o.id===t.interactionId?{...o,...i}:o)}:s;return{...e,pending:r,messages:xW(e.messages,t.interactionId,i)}}case"turn.completed":{const i=ld(e,t.turnId);return{...e,pending:{...i,done:!0,finalMessage:t.message}}}case"resync.required":return{...e,gapDetected:!0};case"turn.failed":{const i=!!e.pending&&(!t.turnId||e.pending.turnId===t.turnId);return{...e,pending:i?null:e.pending,messages:t.message?L0(e.messages,t.message):e.messages}}default:return e}}function wW(e){const t=e.pending;return!(t!=null&&t.done)||!t.finalMessage?e:{...e,messages:L0(e.messages,t.finalMessage),pending:null}}function RR(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.title=="string"&&Array.isArray(t.fields)}function DR(e){return e==="multiselect"||e==="checkbox"}function OR(e){return e==="number"||e==="slider"}function EW(e){return e.default!==void 0?e.default:DR(e.type)?[]:e.type==="toggle"?!1:OR(e.type)?e.min??0:""}function kW(e,t){const n={};for(const i of e.fields)n[i.id]=t&&i.id in t?t[i.id]:EW(i);return n}function LR(e,t){const n=new Map(e.fields.map(s=>[s.id,s])),i=(s,r)=>{if(!s.dependsOn||r>16)return!0;const o=n.get(s.dependsOn.field);return!o||!i(o,r+1)?!1:t[s.dependsOn.field]===s.dependsOn.equals};return e.fields.filter(s=>i(s,0))}function IR(e){return e==null||e===""?!0:Array.isArray(e)&&e.length===0}function SW(e,t){return LR(e,t).filter(n=>n.required&&IR(t[n.id]))}function NW(e,t){const n={};for(const i of LR(e,t)){const s=t[i.id];if(!(IR(s)&&i.type!=="toggle"))if(OR(i.type)&&typeof s=="string"){const r=Number(s);n[i.id]=Number.isFinite(r)?r:s}else DR(i.type)?n[i.id]=Array.isArray(s)?s:[s]:n[i.id]=s}return n}function _W(e,t){const n=[];for(const i of e.fields){const s=t[i.id];if(s===void 0)continue;const r=c=>{var f;const u=(f=i.options)==null?void 0:f.find(p=>p.value===c);return u?u.label:String(c)},o=Array.isArray(s)?s.map(r).join("、"):r(s);o&&n.push(e.fields.length===1?o:`${i.label}:${o}`)}return n.join(" · ")}function CW(e){var n;const t=[];for(const i of e.messages)for(const s of i.blocks??[])s.type==="interaction"&&s.status==="pending"&&t.push(s);for(const i of((n=e.pending)==null?void 0:n.blocks)??[])i.type==="interaction"&&i.status==="pending"&&t.push(i);return t}function TW(e){const t=CW(e);return t.length>0?t[t.length-1]:null}const AW=40;function I0(e,t){return e.type==="text"?Math.max(0,e.text.length-t):0}function jW(e,t){return e.map((i,s)=>t[s]??0)}function MW(e,t){return e.every((n,i)=>I0(n,t[i]??0)===0)}function RW(e,t){const n=jW(e,t),i=e.reduce((r,o,c)=>r+I0(o,n[c]??0),0);if(i<=0)return t.length===n.length?t:n;let s=Math.max(1,Math.ceil(i/AW));return e.map((r,o)=>{const c=n[o]??0,u=I0(r,c);if(u<=0||s<=0)return c;const f=Math.min(u,s);return s-=f,c+f})}function DW(){return St("/api/chat/sessions")}function Ap(e){return St(`/api/chat/sessions/${e}`)}async function PR(e={}){const t=await fetch("/api/chat/sessions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok)throw new Error(`${t.status}: ${await t.text()}`);return await t.json()}async function OW(e,t=!1){const n=await fetch(`/api/chat/sessions/${e}${t?"?workspace=1":""}`,{method:"DELETE"});if(!n.ok)throw new Error(`${n.status}`);return n.status===204?{workspaceRemoved:!1}:await n.json()}async function LW(e,t,n,i){const s=await fetch(`/api/chat/sessions/${e}/messages`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:t,attachments:n,interaction:i})});if(!s.ok)throw new Error(`${s.status}: ${await s.text()}`);return await s.json()}async function zR(e){const t=await fetch(`/api/chat/sessions/${e}/interrupt`,{method:"POST"});if(!t.ok&&t.status!==204)throw new Error(`${t.status}: ${await t.text()}`)}async function P0(e,t,n,i){const s=await fetch(`/api/chat/sessions/${e}/interactions/${t}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({answer:n,expectedRevision:i})});if(!s.ok)throw new Error(`${s.status}: ${await s.text()}`);return await s.json()}async function IW(e,t,n){const i=await fetch(`/api/chat/sessions/${e}/interactions/${t}/cancel`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({expectedRevision:n})});if(!i.ok&&i.status!==204)throw new Error(`${i.status}: ${await i.text()}`)}function PW(e,t){const n=t?`?since=${encodeURIComponent(t)}`:"";return St(`/api/chat/sessions/${e}/messages${n}`)}function BR(e){const t=e?`?path=${encodeURIComponent(e)}`:"";return St(`/api/fs/browse${t}`)}async function zW(e,t){const n=await fetch("/api/fs/mkdir",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:e,name:t})});if(!n.ok){const i=await n.text();throw new Error(`${n.status}: ${i}`)}return await n.json()}const UR=50*1024*1024;async function nx(e,t){if(t.size>UR)throw new Error(`文件超过 50 MB 上限(当前 ${(t.size/1024/1024).toFixed(2)} MB)`);const n=new FormData;n.append("sessionId",e),n.append("file",t,t.name);const i=await fetch("/api/fs/upload",{method:"POST",body:n});if(!i.ok){const s=await i.text();throw new Error(`${i.status}: ${s}`)}return await i.json()}function $o(e,t){return`/api/fs/file?${new URLSearchParams({path:t,sessionId:e}).toString()}`}function BW(e){return/\.(png|jpe?g|gif|webp|svg|bmp|avif)$/i.test(e)}function FR(e,t){if(e.title!=="mcp__sps__generate_asset"||e.status!=="completed"&&e.status!=="complete")return null;const n=e.input;if(!n||n.kind!=="image"||!n.outPath)return null;const i=n.outPath,s=i.startsWith("/")?i:t?`${t.replace(/\/+$/,"")}/${i}`:null;return s&&BW(s)?s:null}function UW(e,t){const n=[];for(const i of e){if(i.type!=="tool_use")continue;const s=FR(i,t);s&&!n.includes(s)&&n.push(s)}return n}function FW({sessionId:e,path:t,onPreview:n}){const[i,s]=_.useState(!1);return i?null:d.jsx("button",{type:"button",onClick:n,className:"block w-fit max-w-full border-2 border-[var(--color-text)] hover:shadow-[3px_3px_0_var(--color-text)] transition-shadow",title:"预览","aria-label":"预览",children:d.jsx("img",{src:$o(e,t),alt:"生成的图片",className:"block max-h-96 max-w-full object-contain",loading:"lazy",onError:()=>s(!0)})})}function $W({sessionId:e,path:t,onClose:n}){return _.useEffect(()=>{const i=s=>{s.key==="Escape"&&(s.preventDefault(),n())};return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[n]),d.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-[rgba(45,55,72,0.6)] p-4",role:"presentation",onClick:n,children:d.jsx("img",{src:$o(e,t),alt:"预览",className:"max-w-full max-h-[85vh] object-contain",onClick:i=>i.stopPropagation()})})}function qW(e){if(e==null||typeof e!="object")return typeof e=="string"?e:"";const t=e,n=s=>typeof t[s]=="string"?t[s]:void 0;return n("file_path")??n("path")??n("notebook_path")??n("command")??n("pattern")??n("query")??n("url")??n("name")??n("description")??n("prompt")??Object.values(t).find(s=>typeof s=="string"&&s.trim())??""}function HW({tool:e,live:t}){const[n,i]=_.useState(!1),s=e.status==="completed"||e.status==="complete",r=e.status==="failed",o=e.status==="interrupted"||!s&&!r&&!t,c=!s&&!r&&!o,u=qW(e.input),f=e.input!=null&&(typeof e.input!="object"||Object.keys(e.input).length>0);return d.jsxs("div",{className:"border border-[var(--surface-card-border)] rounded-lg overflow-hidden bg-[var(--color-bg-cream)]",children:[d.jsxs("button",{type:"button",onClick:()=>i(p=>!p),className:"w-full flex items-center gap-2 px-3 py-2 text-xs font-[family-name:var(--font-mono)] hover:bg-[var(--surface-control-hover)] transition-colors",children:[d.jsx(pf,{size:12,strokeWidth:3,className:["transition-transform flex-shrink-0",n?"rotate-90":""].join(" ")}),d.jsx(Kj,{size:12,strokeWidth:2.5,className:"flex-shrink-0"}),d.jsx("span",{className:"font-bold flex-shrink-0",children:e.title||e.kind}),d.jsx("span",{className:"flex-1 text-left text-[var(--color-text-muted)] truncate",title:u,children:u}),c&&d.jsx(mt,{size:12,strokeWidth:3,className:"animate-spin text-[var(--color-running)] flex-shrink-0"}),s&&d.jsx(Qp,{size:12,strokeWidth:2.5,className:"text-[var(--color-running)] flex-shrink-0"}),r&&d.jsx(Dj,{size:12,strokeWidth:2.5,className:"text-[var(--color-crashed)] flex-shrink-0"}),o&&d.jsx("span",{className:"text-[10px] text-[var(--color-text-muted)] border border-[var(--surface-card-border)] rounded px-1 flex-shrink-0",title:"回合已结束,该工具未回报结果",children:"已中断"})]}),n&&d.jsxs("div",{className:"px-3 py-2 text-xs font-[family-name:var(--font-mono)] text-[var(--color-text-muted)] border-t border-[var(--surface-card-border)] space-y-1",children:[f?d.jsx("pre",{className:"whitespace-pre-wrap break-all text-[var(--color-text)] max-h-72 overflow-auto",children:typeof e.input=="string"?e.input:JSON.stringify(e.input,null,2)}):d.jsx("div",{children:"无参数"}),d.jsxs("div",{className:"opacity-60",children:["id: ",e.id," · ",e.status]})]})]})}function VW(e){return RR(e)?{...e.description?{description:e.description}:{},properties:Object.fromEntries(e.fields.map(t=>[t.id,{title:t.label,type:t.type==="toggle"||t.type==="checkbox"?"boolean":t.type==="number"||t.type==="slider"?"number":"string",...t.options?{enum:t.options.map(n=>n.value)}:{},...t.type==="textarea"?{format:"textarea"}:{},...t.default!==void 0?{default:t.default}:{},...t.hint?{description:t.hint}:{}}])),required:e.fields.filter(t=>t.required).map(t=>t.id)}:e&&typeof e=="object"&&!Array.isArray(e)?e:{}}function KW({interaction:e,sessionId:t,onOpenForm:n}){const i=VW(e.schema),s=i.properties??{},r=new Set(i.required??[]),[o,c]=_.useState(()=>Object.fromEntries(Object.entries(s).filter(([,C])=>C.default!==void 0).map(([C,S])=>[C,S.default]))),[u,f]=_.useState(e.status==="pending"?"idle":e.status),[p,m]=_.useState(""),y=u==="answered"||u==="cancelled"||e.status!=="pending",b=e.kind==="form"&&!!n,x=u==="cancelled"||e.status==="cancelled",v=C=>{const S={...o};C!==void 0&&(S.approved=C);for(const[T,A]of Object.entries(s))A.type==="number"&&typeof S[T]=="string"&&(S[T]=Number(S[T]));return S},w=async C=>{if(!t||y)return;m("");const S=v(C),T=[...r].filter(A=>S[A]===void 0||S[A]===null||S[A]==="");if(T.length>0){m(`请填写:${T.map(A=>{var j;return((j=s[A])==null?void 0:j.title)??A}).join("、")}`);return}f("submitting");try{await P0(t,e.id,S,e.revision),f("answered")}catch(A){f("idle"),m(A instanceof Error?A.message:String(A))}},k=async()=>{if(!(!t||y)){m(""),f("cancelling");try{await IW(t,e.id,e.revision),f("cancelled")}catch(C){f("idle"),m(C instanceof Error?C.message:String(C))}}};return d.jsxs("section",{className:"border-2 border-[var(--color-text)] bg-[var(--color-bg-cream)] p-3 space-y-3","aria-label":e.title,children:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx(x6,{size:16,strokeWidth:2.5}),d.jsx("strong",{className:"text-sm",children:e.title})]}),i.description&&d.jsx("p",{className:"text-xs text-[var(--color-text-muted)]",children:i.description}),!y&&e.kind!=="approval"&&!b&&d.jsx("div",{className:"space-y-3",children:Object.entries(s).map(([C,S])=>{const T=S.title??C,A="w-full border border-[var(--surface-card-border)] bg-white px-2 py-1.5 text-sm";return d.jsxs("label",{className:"block text-xs font-semibold space-y-1",children:[d.jsxs("span",{children:[T,r.has(C)?" *":""]}),Array.isArray(S.enum)?d.jsxs("select",{className:A,value:String(o[C]??""),onChange:j=>c(M=>({...M,[C]:j.target.value})),children:[d.jsx("option",{value:"",children:"请选择"}),S.enum.map(j=>d.jsx("option",{value:String(j),children:String(j)},String(j)))]}):S.type==="boolean"?d.jsx("input",{type:"checkbox",checked:o[C]===!0,onChange:j=>c(M=>({...M,[C]:j.target.checked}))}):S.format==="textarea"?d.jsx("textarea",{className:A,rows:4,value:String(o[C]??""),onChange:j=>c(M=>({...M,[C]:j.target.value}))}):d.jsx("input",{className:A,type:S.type==="number"?"number":"text",value:String(o[C]??""),onChange:j=>c(M=>({...M,[C]:j.target.value}))})]},C)})}),!y&&e.kind==="approval"&&d.jsxs("label",{className:"block text-xs font-semibold space-y-1",children:[d.jsx("span",{children:"拒绝原因(可选)"}),d.jsx("input",{className:"w-full border border-[var(--surface-card-border)] bg-white px-2 py-1.5 text-sm",value:String(o.reason??""),onChange:C=>c(S=>({...S,reason:C.target.value}))})]}),p&&d.jsx("p",{className:"text-xs text-[var(--color-crashed)]",children:p}),y?d.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs font-semibold text-[var(--color-text-muted)]",children:[d.jsx("span",{children:x?"已取消,不能继续执行":"已提交,Agent 正在继续"}),b&&!x&&d.jsx("button",{type:"button",className:"border border-[var(--surface-card-border)] px-2 py-1 text-xs",onClick:()=>n(e),children:"查看已填内容"})]}):d.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.kind==="approval"?d.jsxs(d.Fragment,{children:[d.jsx("button",{type:"button",className:"border border-[var(--color-text)] px-3 py-1.5 text-xs font-bold bg-[var(--color-running)]",disabled:!t||u!=="idle",onClick:()=>void w(!0),children:"批准"}),d.jsx("button",{type:"button",className:"border border-[var(--color-text)] px-3 py-1.5 text-xs font-bold",disabled:!t||u!=="idle",onClick:()=>void w(!1),children:"拒绝"})]}):b?d.jsx("button",{type:"button",className:"border border-[var(--color-text)] px-3 py-1.5 text-xs font-bold bg-[var(--color-running)]",disabled:!t||u!=="idle",onClick:()=>n(e),children:"点击填写配置"}):d.jsx("button",{type:"button",className:"border border-[var(--color-text)] px-3 py-1.5 text-xs font-bold bg-[var(--color-running)]",disabled:!t||u!=="idle",onClick:()=>void w(),children:"提交并继续"}),d.jsx("button",{type:"button",className:"border border-[var(--surface-card-border)] px-3 py-1.5 text-xs",disabled:!t||u!=="idle",onClick:()=>void k(),children:"取消任务"}),(u==="submitting"||u==="cancelling")&&d.jsx(mt,{size:14,className:"animate-spin self-center"})]})]})}function $R({text:e}){const[t,n]=_.useState(""),i=_.useRef(e);return i.current=e,_.useEffect(()=>{n(s=>e.startsWith(s)?s:"")},[e]),_.useEffect(()=>{const s=window.setInterval(()=>{n(r=>{const o=i.current;if(r.length>=o.length)return r;const c=Math.max(1,Math.ceil((o.length-r.length)/8));return o.slice(0,r.length+c)})},25);return()=>window.clearInterval(s)},[]),d.jsx("div",{className:"prose-chat text-sm whitespace-pre-wrap break-words font-[family-name:var(--font-body)]",children:t})}function GW({block:e,streaming:t,sessionId:n,onOpenForm:i}){return e.type==="text"?t?d.jsx($R,{text:e.text}):d.jsx(MR,{text:e.text}):e.type==="interaction"?d.jsx(KW,{interaction:e,sessionId:n,onOpenForm:i}):d.jsx(HW,{tool:e,live:t===!0})}const ix={title:"生图配置",description:"填好点「开始生成」;懒得填就点「让 AI 来填」,我按你说的补全。",submitLabel:"开始生成",fields:[{id:"prompt",label:"画面描述",type:"textarea",required:!0,placeholder:"主体 + 场景 + 动作 + 细节,越具体越好",hint:"想画什么"},{id:"style",label:"风格",type:"select",default:"realistic",options:[{value:"realistic",label:"写实"},{value:"3d-render",label:"3D 渲染"},{value:"anime",label:"动漫/二次元"},{value:"oil-painting",label:"油画"},{value:"watercolor",label:"水彩"},{value:"cyberpunk",label:"赛博朋克"},{value:"flat-illustration",label:"扁平插画"},{value:"cinematic",label:"电影感"}]},{id:"aspect",label:"画幅",type:"select",default:"1:1",options:[{value:"1:1",label:"正方形 1:1"},{value:"16:9",label:"横屏 16:9"},{value:"9:16",label:"竖屏 9:16"},{value:"4:3",label:"4:3"},{value:"3:4",label:"3:4"}]},{id:"lighting",label:"光线 / 氛围",type:"text",advanced:!0,placeholder:"如 柔和逆光、霓虹夜色、清晨薄雾"},{id:"mood",label:"情绪基调",type:"text",advanced:!0,placeholder:"如 宁静、孤独、热烈"},{id:"reference",label:"参考图",type:"image-ref",advanced:!0,hint:"可选:上传或贴 URL,做 img2img 风格参考"}]};function C2({spec:e,onSubmit:t,onSkip:n,onUpload:i,disabled:s,initialValues:r,layout:o="card",previewUrl:c}){const[u,f]=_.useState(()=>kW(e,r)),[p,m]=_.useState(!1),[y,b]=_.useState(!1),[x,v]=_.useState(!1),w=s||x,k=(I,B)=>f(q=>({...q,[I]:B})),{basic:C,advanced:S}=_.useMemo(()=>({basic:e.fields.filter(I=>!I.advanced),advanced:e.fields.filter(I=>I.advanced)}),[e.fields]),T=()=>SW(e,u),A=()=>{if(w)return;if(T().length){b(!0);return}t(NW(e,u)),b(!0),v(!0)},j=()=>{w||(n(),v(!0))},M=I=>{const B=new Map;for(const q of I){const G=q.group??"";(B.get(G)??B.set(G,[]).get(G)).push(q)}return[...B.entries()]},D=_.useMemo(()=>{const I=q=>q.type==="textarea",B=q=>q.type==="image-ref"||q.type==="file";return{prose:e.fields.filter(I),media:e.fields.filter(B),params:e.fields.filter(q=>!I(q)&&!B(q))}},[e.fields]),P=(I,B=!1)=>d.jsx(qR,{f:I,value:u[I.id],set:k,showErr:y,onUpload:i,dropzone:B,previewUrl:c},I.id);return o==="region"?d.jsxs("div",{className:["cfg-region",w?"is-locked":""].join(" "),children:[d.jsxs("div",{className:"cfg-region-head",children:[d.jsxs("span",{className:"cfg-region-title",children:[e.title,x&&" ✓"]}),e.description&&d.jsx("span",{className:"cfg-region-desc",children:e.description})]}),d.jsxs("div",{className:"cfg-region-body",children:[D.prose.length>0&&d.jsx("div",{className:"cfg-region-prose",children:D.prose.map(I=>P(I))}),D.params.length>0&&d.jsx("div",{className:"cfg-region-params",children:D.params.map(I=>P(I))}),D.media.length>0&&d.jsx("div",{className:"cfg-region-media",children:D.media.map(I=>P(I,!0))})]}),d.jsxs("div",{className:"cfg-region-actions",children:[d.jsxs("button",{type:"button",className:"nb-btn text-xs",onClick:j,disabled:w,children:[d.jsx(ao,{size:13,strokeWidth:2.5})," ",e.skipLabel??"让 AI 来填"]}),d.jsx("button",{type:"button",className:"nb-btn nb-btn-primary text-sm",onClick:A,disabled:w,children:e.submitLabel??"提交"})]})]}):d.jsxs("div",{className:["nb-card flex flex-col gap-3",w?"opacity-60 pointer-events-none":""].join(" "),children:[d.jsxs("div",{children:[d.jsxs("div",{className:"font-[family-name:var(--font-heading)] font-bold text-base",children:[e.title,x&&" ✓"]}),e.description&&d.jsx("div",{className:"text-xs text-[var(--color-text-muted)] mt-0.5",children:e.description})]}),M(C).map(([I,B])=>d.jsx(T2,{name:I,fields:B,values:u,set:k,showErr:y,onUpload:i},I||"default")),S.length>0&&d.jsxs("div",{className:"border-t border-dashed border-[var(--surface-card-border)] pt-2",children:[d.jsxs("button",{type:"button",className:"flex items-center gap-1 text-xs text-[var(--color-text-muted)] hover:text-[var(--color-text)]",onClick:()=>m(I=>!I),children:[p?d.jsx(uo,{size:14}):d.jsx(pf,{size:14})," 高级选项"]}),p&&d.jsx("div",{className:"mt-2 flex flex-col gap-3",children:M(S).map(([I,B])=>d.jsx(T2,{name:I,fields:B,values:u,set:k,showErr:y,onUpload:i},I||"adv"))})]}),d.jsxs("div",{className:"flex gap-2 justify-end pt-1",children:[d.jsxs("button",{type:"button",className:"nb-btn text-xs",onClick:j,disabled:w,children:[d.jsx(ao,{size:13,strokeWidth:2.5})," ",e.skipLabel??"让 AI 来填"]}),d.jsx("button",{type:"button",className:"nb-btn nb-btn-primary text-xs",onClick:A,disabled:w,children:e.submitLabel??"提交"})]})]})}function T2({name:e,fields:t,values:n,set:i,showErr:s,onUpload:r}){return d.jsxs("div",{className:"grid grid-cols-[repeat(auto-fit,minmax(15rem,1fr))] gap-x-4 gap-y-3 items-start",children:[e&&d.jsx("div",{className:"col-span-full text-xs font-bold text-[var(--color-text-muted)] uppercase tracking-wide",children:e}),t.map(o=>d.jsx(qR,{f:o,value:n[o.id],set:i,showErr:s,onUpload:r},o.id))]})}function WW(e){return e==="textarea"||e==="image-ref"||e==="file"}function qR({f:e,value:t,set:n,showErr:i,onUpload:s,dropzone:r,previewUrl:o}){const[c,u]=_.useState(!1),f=async b=>{if(!(!b||!s)){u(!0);try{n(e.id,await s(b))}catch{}finally{u(!1)}}},p=i&&e.required&&(t===""||t==null||Array.isArray(t)&&t.length===0),m=Array.isArray(t)?t:[],y=b=>n(e.id,m.includes(b)?m.filter(x=>x!==b):[...m,b]);return d.jsxs("label",{className:["flex flex-col gap-1",WW(e.type)?"col-span-full":""].join(" "),children:[d.jsxs("span",{className:"text-sm font-bold",children:[e.label,e.required&&d.jsx("span",{className:"text-[var(--color-crashed)]",children:" *"})]}),e.type==="text"&&d.jsx("input",{className:"nb-input w-full text-sm",value:t,placeholder:e.placeholder,onChange:b=>n(e.id,b.target.value)}),e.type==="textarea"&&d.jsx("textarea",{className:"nb-input w-full text-sm",style:{minHeight:72,resize:"vertical"},value:t,placeholder:e.placeholder,onChange:b=>n(e.id,b.target.value)}),e.type==="number"&&d.jsx("input",{type:"number",className:"nb-input w-full text-sm",value:t,min:e.min,max:e.max,step:e.step,onChange:b=>n(e.id,b.target.valueAsNumber)}),e.type==="slider"&&d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("input",{type:"range",className:"flex-1",value:t,min:e.min??0,max:e.max??100,step:e.step??1,onChange:b=>n(e.id,b.target.valueAsNumber)}),d.jsx("span",{className:"text-xs font-[family-name:var(--font-mono)] w-8 text-right",children:String(t)})]}),e.type==="select"&&d.jsx("select",{className:"nb-input w-full text-sm",value:t,onChange:b=>n(e.id,b.target.value),children:(e.options??[]).map(b=>d.jsx("option",{value:b.value,children:b.label},b.value))}),e.type==="radio"&&d.jsx("div",{className:"flex flex-wrap gap-2",children:(e.options??[]).map(b=>d.jsx("button",{type:"button",onClick:()=>n(e.id,b.value),className:["px-3 py-1.5 rounded-lg border-2 text-sm transition-all",t===b.value?"bg-[var(--color-accent-mint)] border-[var(--color-text)] font-bold":"bg-[var(--color-bg)] border-[var(--color-border-light)] hover:border-[var(--color-text)]"].join(" "),children:b.label},b.value))}),(e.type==="multiselect"||e.type==="checkbox")&&d.jsx("div",{className:"flex flex-wrap gap-2",children:(e.options??[]).map(b=>d.jsx("button",{type:"button",onClick:()=>y(b.value),className:["px-3 py-1.5 rounded-lg border-2 text-sm transition-all",m.includes(b.value)?"bg-[var(--color-accent-mint)] border-[var(--color-text)] font-bold":"bg-[var(--color-bg)] border-[var(--color-border-light)] hover:border-[var(--color-text)]"].join(" "),children:b.label},b.value))}),e.type==="toggle"&&d.jsxs("label",{className:"flex items-center gap-2 cursor-pointer select-none",children:[d.jsx("input",{type:"checkbox",className:"w-4 h-4",checked:t,onChange:b=>n(e.id,b.target.checked)}),d.jsx("span",{className:"text-xs text-[var(--color-text-muted)]",children:t?"开":"关"})]}),e.type==="color"&&d.jsx("input",{type:"color",className:"w-12 h-8 rounded border-2 border-[var(--color-text)]",value:t||"#000000",onChange:b=>n(e.id,b.target.value)}),(e.type==="image-ref"||e.type==="file")&&r&&d.jsxs("div",{className:"cfg-dropzone-wrap",children:[d.jsxs("label",{className:"cfg-dropzone","data-filled":t?"true":"false",children:[t&&o&&e.type==="image-ref"?d.jsx("img",{className:"cfg-dropzone-thumb",src:o(t),alt:""}):d.jsx("span",{className:"cfg-dropzone-hint",children:c?"上传中…":t?String(t).split("/").pop():s?"点击上传":"贴 URL"}),s&&d.jsx("input",{type:"file",className:"hidden",accept:e.accept??(e.type==="image-ref"?"image/*":void 0),onChange:b=>{var x;f((x=b.target.files)==null?void 0:x[0]),b.target.value=""},disabled:c})]}),d.jsx("input",{className:"nb-input w-full text-xs font-[family-name:var(--font-mono)]",value:t,placeholder:"或粘贴 URL",onChange:b=>n(e.id,b.target.value)})]}),(e.type==="image-ref"||e.type==="file")&&!r&&d.jsxs("div",{className:"flex flex-col gap-1.5",children:[s&&d.jsxs("label",{className:"nb-btn text-xs w-fit cursor-pointer",children:[c?"上传中…":t?"重新选择":"选择文件",d.jsx("input",{type:"file",className:"hidden",accept:e.accept??(e.type==="image-ref"?"image/*":void 0),onChange:b=>{var x;f((x=b.target.files)==null?void 0:x[0]),b.target.value=""},disabled:c})]}),d.jsx("input",{className:"nb-input w-full text-sm font-[family-name:var(--font-mono)]",value:t,placeholder:e.placeholder??(s?"或粘贴 URL":"粘贴图片/文件 URL"),onChange:b=>n(e.id,b.target.value)})]}),e.hint&&d.jsx("span",{className:"text-xs text-[var(--color-text-muted)]",children:e.hint}),p&&d.jsx("span",{className:"text-xs text-[var(--color-crashed)]",children:"必填"})]})}function sx(){if(!(typeof window>"u"))return window.SpeechRecognition??window.webkitSpeechRecognition}function YW({onComplete:e,onError:t}){const[n,i]=_.useState(!1),[s,r]=_.useState(""),o=_.useRef(null),c=_.useRef(""),u=_.useRef(""),f=_.useRef(0),p=_.useRef(!1),m=_.useRef(!1),y=_.useRef(null),b=_.useRef(e),x=_.useRef(t);b.current=e,x.current=t;const v=_.useCallback(()=>{y.current!==null&&(window.clearTimeout(y.current),y.current=null)},[]),w=_.useCallback(()=>{i(!1);const A=u.current.trim();c.current="",u.current="",A?b.current(A):x.current("no-speech")},[]),k=_.useCallback(()=>{f.current+=1,p.current=!1,m.current=!0,v();const A=o.current;o.current=null,A==null||A.abort(),c.current="",u.current="",r(""),i(!1)},[v]),C=_.useCallback(A=>{const j=sx();if(!j||A!==f.current||!p.current)return!1;const M=new j;M.continuous=!0,M.interimResults=!0,M.lang=navigator.language||"zh-CN",M.onresult=D=>{var I;if(A!==f.current)return;let P="";for(let B=D.resultIndex;B<D.results.length;B+=1){const q=D.results[B],G=((I=q==null?void 0:q[0])==null?void 0:I.transcript.trim())??"";q!=null&&q.isFinal&&G?c.current=`${c.current} ${G}`.trim():G&&(P+=` ${G}`)}u.current=`${c.current}${P}`.trim(),r(u.current)},M.onerror=D=>{A===f.current&&(D.error==="no-speech"||D.error==="aborted"||D.error==="network"||(p.current=!1,m.current=!0,i(!1),x.current(D.error)))},M.onend=()=>{if(A===f.current){if(o.current===M&&(o.current=null),m.current){m.current=!1;return}if(!p.current){w();return}i(!0),v(),y.current=window.setTimeout(()=>{y.current=null,C(A)},180)}},o.current=M;try{return M.start(),i(!0),!0}catch{return o.current=null,p.current=!1,i(!1),x.current("start-failed"),!1}},[v,w]),S=_.useCallback(()=>{p.current=!1,v();const A=o.current;A?A.stop():w()},[v,w]),T=_.useCallback(()=>{if(!sx())return x.current("unsupported"),!1;k();const j=f.current;return p.current=!0,m.current=!1,c.current="",u.current="",r(""),C(j)},[k,C]);return _.useEffect(()=>k,[k]),{cancel:k,isListening:n,start:T,stop:S,supported:!!sx(),transcript:s}}function XW(){const[e,t]=_.useState("inactive"),[n,i]=_.useState(null),s=_.useRef(null),r=_.useRef(null),o=_.useRef(0),c=_.useCallback(()=>{var f,p;o.current+=1,(f=r.current)==null||f.getTracks().forEach(m=>m.stop()),r.current=null,(p=s.current)==null||p.close(),s.current=null,i(null),t("inactive")},[]),u=_.useCallback(async()=>{var y;if(!((y=navigator.mediaDevices)!=null&&y.getUserMedia)||typeof AudioContext>"u"){t("unsupported");return}c();const f=o.current;t("requesting");let p=null,m=null;try{if(p=await navigator.mediaDevices.getUserMedia({audio:{autoGainControl:!0,echoCancellation:!0,noiseSuppression:!0}}),f!==o.current){p.getTracks().forEach(v=>v.stop());return}if(m=new AudioContext,m.state==="suspended"&&await m.resume(),f!==o.current){p.getTracks().forEach(v=>v.stop()),m.close();return}const b=m.createMediaStreamSource(p),x=m.createAnalyser();x.fftSize=2048,x.smoothingTimeConstant=.72,b.connect(x),r.current=p,s.current=m,i(x),t("active")}catch{p==null||p.getTracks().forEach(b=>b.stop()),m==null||m.close(),f===o.current&&t("denied")}},[c]);return _.useEffect(()=>c,[c]),{analyser:n,start:u,status:e,stop:c}}const QW=.12,A2=1e3,ZW=1e4,JW=150;function eY(e,t){t.bytes.length!==e.fftSize&&(t.bytes=new Uint8Array(new ArrayBuffer(e.fftSize))),e.getByteTimeDomainData(t.bytes);let n=0;for(const i of t.bytes){const s=(i-128)/128;n+=s*s}return Math.min(1,Math.sqrt(n/t.bytes.length)*3.4)}function tY(e){const{enabled:t,phase:n,suspended:i,analyser:s,silenceMs:r=2e3}=e,o=_.useRef(e);o.current=e;const c=_.useRef(0),u=_.useRef(0),f=_.useRef(0),p=_.useRef(0),m=_.useRef("");_.useEffect(()=>{const y=Date.now();n==="idle"?c.current=y+A2:n==="listening"&&(u.current=y,p.current=y,f.current=y,m.current="")},[n]),_.useEffect(()=>{if(!(n==="listening"||t&&n==="idle"))return;const y={bytes:new Uint8Array(new ArrayBuffer(0))},b=window.setInterval(()=>{const x=o.current,v=Date.now();if(document.hidden)return;if((x.analyser?eY(x.analyser,y):0)>QW&&(f.current=v),x.phase==="idle"){if(!x.enabled||x.suspended||v<c.current)return;x.transcript.trim().length>0&&(c.current=v+A2,x.onTrigger());return}x.transcript!==m.current&&(m.current=x.transcript,p.current=v);const k=v-Math.max(p.current,f.current);x.transcript.trim()?k>=(x.silenceMs??2e3)&&x.onEndpoint():v-u.current>=ZW&&x.onAbort()},JW);return()=>window.clearInterval(b)},[t,n,i,s,r])}function j2({checked:e,onChange:t,onIcon:n,offIcon:i,title:s,ariaLabel:r}){return d.jsxs("label",{className:"icon-toggle",title:s,children:[d.jsx("input",{type:"checkbox",checked:e,onChange:o=>t(o.target.checked),"aria-label":r}),d.jsxs("span",{className:"icon-toggle-btn","aria-hidden":"true",children:[d.jsx("span",{className:"icon-toggle-ico on",children:n}),d.jsx("span",{className:"icon-toggle-ico off",children:i})]})]})}function nY(e,t){return{sessionId:e.sessionId,id:e.turnId,done:e.done,finalMessage:e.finalMessage,...e.thinking?{thinking:e.thinking}:{},blocks:e.blocks.map((n,i)=>n.type==="text"?{type:"text",target:n.text,displayed:n.text.slice(0,t[i]??0)}:n)}}function iY(e,t){var C;const n=tn(),[i,s]=_.useState(null),[r,o]=_.useState([]),[c,u]=_.useState(!1),f=_.useRef(t);f.current=t;const p=_.useRef(null),m=_.useRef({lastSeq:0,gapDetected:!1}),y=ot({queryKey:["chat-session",e],queryFn:()=>Ap(e??""),enabled:!!e,refetchInterval:(t==null?void 0:t.pollMs)===0?!1:(t==null?void 0:t.pollMs)??4e3});_.useEffect(()=>{if(!e)return;p.current=null,m.current={lastSeq:0,gapDetected:!1},s(null),o([]);let S=null,T=null,A=!1,j=!0;const M=()=>{A||(S=new EventSource(`/stream/chat/${encodeURIComponent(e)}`),S.addEventListener("error",()=>{(S==null?void 0:S.readyState)!==EventSource.CLOSED||T!=null||(T=setTimeout(()=>{T=null,S==null||S.close(),M()},5e3))}),D(S))},D=P=>{P.addEventListener("open",()=>{if(j){j=!1;return}const B=n.getQueryData(["chat-session",e]),q=B!=null&&B.messages.length?B.messages[B.messages.length-1].ts:void 0;PW(e,q).then(G=>{G.data.length!==0&&n.setQueryData(["chat-session",e],R=>{if(!R)return R;const O=new Set(R.messages.map(W=>W.id)),z=G.data.filter(W=>!O.has(W.id));return z.length===0?R:{...R,messages:[...R.messages,...z],lastMessageAt:z[z.length-1].ts,messageCount:R.messageCount+z.length}})}).catch(()=>{})});const I=(B,q)=>{var X,K,U,F,Y,$;let G;try{G=JSON.parse(q)}catch{return}const R=yW(B,G,e);if(!R)return;const O=n.getQueryData(["chat-session",e]),z={sessionId:e,messages:(O==null?void 0:O.messages)??[],pending:p.current,...m.current},W=vW(z,R);if(W!==z)switch(m.current={lastSeq:W.lastSeq,gapDetected:W.gapDetected,...W.seqTurnId!==void 0?{seqTurnId:W.seqTurnId}:{}},W.pending!==z.pending&&(p.current=W.pending,s(W.pending)),W.messages!==z.messages&&n.setQueryData(["chat-session",e],ie=>{if(!ie)return ie;const be=W.messages.length-ie.messages.length,ce=W.messages[W.messages.length-1];return{...ie,messages:W.messages,...be>0&&ce?{lastMessageAt:ce.ts,messageCount:ie.messageCount+be}:{}}}),W.gapDetected&&!z.gapDetected&&(m.current={...m.current,gapDetected:!1},n.invalidateQueries({queryKey:["chat-session",e]})),R.type){case"turn.pending":(K=(X=f.current)==null?void 0:X.onTurnStart)==null||K.call(X);break;case"text.delta":(F=(U=f.current)==null?void 0:U.onAssistantChunk)==null||F.call(U,R.text);break;case"turn.failed":u(!1),($=(Y=f.current)==null?void 0:Y.onError)==null||$.call(Y,R.message??null);break}};for(const B of gW)P.addEventListener(B,q=>I(B,q.data))};return M(),()=>{A=!0,T!=null&&clearTimeout(T),S==null||S.close()}},[e,n]),_.useEffect(()=>{u(!1)},[e]),_.useEffect(()=>{var T,A;if(!i||i.sessionId!==e)return;if(MW(i.blocks,r)){if(!i.done||!i.finalMessage)return;const j=i.finalMessage,M=n.getQueryData(["chat-session",e]),D=wW({sessionId:e,messages:(M==null?void 0:M.messages)??[],pending:i,...m.current});n.setQueryData(["chat-session",e],P=>!P||P.messages.some(I=>I.id===j.id)?P:{...P,messages:D.messages,lastMessageAt:j.ts,messageCount:P.messageCount+1}),n.invalidateQueries({queryKey:["chat-sessions"]}),n.invalidateQueries({queryKey:["chat-session",e]}),p.current=null,s(null),o([]),u(!1),(A=(T=f.current)==null?void 0:T.onAssistantComplete)==null||A.call(T,j);return}const S=setTimeout(()=>{o(j=>RW(i.blocks,j))},25);return()=>clearTimeout(S)},[i,r,n,e]);const b=_.useCallback(async(S,T,A)=>{var P,I,B,q;if(c)return;let j=e;if(!j&&(j=await((I=(P=f.current)==null?void 0:P.ensureSessionId)==null?void 0:I.call(P))??null,!j))return;const M=T&&T.length>0?T:void 0,D={id:`optim-${Date.now()}`,role:"user",content:S,ts:new Date().toISOString(),status:"complete",...M?{attachments:M}:{}};n.setQueryData(["chat-session",j],G=>G?{...G,messages:[...G.messages,D],lastMessageAt:D.ts,messageCount:G.messageCount+1}:{id:j,createdAt:D.ts,lastMessageAt:D.ts,title:S.slice(0,60)||"…",project:null,messageCount:1,messages:[D]}),u(!0),(q=(B=f.current)==null?void 0:B.onTurnStart)==null||q.call(B);try{await LW(j,S,M,A)}catch(G){throw u(!1),G}},[c,e,n]),x=_.useCallback(async()=>{e&&await zR(e)},[e]),v=i&&i.sessionId===e?nY(i,r):null,w=((C=y.data)==null?void 0:C.messages)??[],k=e?TW({messages:w,pending:i&&i.sessionId===e?i:null}):null;return{detail:y.data??null,messages:w,isLoading:y.isLoading,activePending:v,activeInteraction:k,sending:c,send:b,interrupt:x}}function sY(e){return{id:e.id,role:e.role,content:e.content,status:e.status??"complete",...e.blocks&&e.blocks.length?{blocks:e.blocks}:{},...e.attachments&&e.attachments.length?{attachments:e.attachments}:{},...e.truncated?{truncated:!0}:{},...e.ts?{ts:e.ts}:{}}}function rY(e){const t=e.blocks.map(i=>i.type==="text"?{type:"text",text:i.target}:{...i}),n=e.blocks.reduce((i,s)=>s.type==="text"?i+s.target:i,"");return{id:e.id,role:"assistant",content:n,status:"streaming",blocks:t}}function aY(e){var y;const[t,n]=_.useState(null),i=_.useRef(null),s=_.useRef(e);s.current=e;const r=_.useCallback(b=>{i.current=b,n(b)},[]),o=_.useCallback(async()=>{if(i.current)return i.current;const b=await PR({title:"Voice conversation",dedicated:!0});return r(b.id),b.id},[r]),c=iY(t,{ensureSessionId:o,onAssistantChunk:b=>s.current.onAssistantChunk(b),onAssistantComplete:b=>s.current.onAssistantComplete(b.content),onTurnStart:()=>s.current.onThinking(),onError:b=>s.current.onError(new Error((b==null?void 0:b.content)??"Response failed"))}),u=_.useMemo(()=>{const b=c.activePending,x=c.messages.filter(v=>b?v.id===b.id||b.finalMessage&&v.id===b.finalMessage.id?!1:v.status!=="streaming":!0).map(sY);return b?[...x,rY(b)]:x},[c.messages,c.activePending]),f=_.useCallback(async(b,x,v)=>{try{await c.send(b,x,v)}catch(w){s.current.onError(w instanceof Error?w:new Error(String(w)))}},[c]),p=_.useCallback((b,x)=>{r(b)},[r]),m=_.useCallback(()=>{r(null)},[r]);return{isSending:c.sending,messages:u,activeInteraction:c.activeInteraction,thinking:(y=c.activePending)==null?void 0:y.thinking,send:f,sessionId:t,resume:p,reset:m,ensureSession:o}}function C1(){return St("/api/providers")}function HR(e){const t=[];for(const n of e)for(const i of n.models)t.push({providerId:n.id,model:i,label:`${i} · ${n.name}`});return t}const VR=HR;async function oY(e,t){const n=await fetch("/api/providers",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({kind:e,entry:t})});if(!n.ok)throw new Error(`${n.status}: ${await n.text()}`);return n.json()}async function lY(e,t){const n=await fetch(`/api/providers/${e}/${encodeURIComponent(t)}`,{method:"DELETE"});if(!n.ok)throw new Error(`${n.status}: ${await n.text()}`);return n.json()}function cY({title:e,body:t,confirm:n,cancel:i,onConfirm:s,onCancel:r,danger:o}){const c=Xe();return _.useEffect(()=>{const u=f=>{f.key==="Escape"&&r()};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[r]),d.jsx("div",{role:"dialog","aria-modal":"true","aria-labelledby":"confirm-title",className:"fixed inset-0 z-50 flex items-center justify-center p-6 bg-black/30",children:d.jsxs("div",{className:"nb-card max-w-md w-full",children:[d.jsx("h2",{id:"confirm-title",className:"font-[family-name:var(--font-heading)] text-xl font-bold mb-2",children:e}),d.jsx("p",{className:"text-sm text-[var(--color-text-muted)] mb-5",children:t}),d.jsxs("div",{className:"flex gap-3 justify-end",children:[d.jsx("button",{className:"nb-btn",onClick:r,type:"button",children:i??c("dialog.cancel.default")}),d.jsx("button",{className:o?"nb-btn nb-btn-danger":"nb-btn nb-btn-yellow",onClick:async()=>{await s()},type:"button",children:n})]})]})})}const KR=_.createContext(null);function uY({children:e}){const t=Xe(),[n,i]=_.useState(null),s=_.useCallback(c=>new Promise(u=>{i({kind:"confirm",opts:c,resolve:f=>{i(null),u(f)}})}),[]),r=_.useCallback(c=>new Promise(u=>{i({kind:"alert",opts:c,resolve:()=>{i(null),u()}})}),[]),o=_.useCallback(c=>new Promise(u=>{i({kind:"prompt",opts:c,resolve:f=>{i(null),u(f)}})}),[]);return d.jsxs(KR.Provider,{value:{confirm:s,alert:r,prompt:o},children:[e,(n==null?void 0:n.kind)==="confirm"&&d.jsx(cY,{title:n.opts.title,body:n.opts.body,confirm:n.opts.confirm??t("dialog.confirm.default"),cancel:n.opts.cancel,danger:n.opts.danger,onConfirm:()=>n.resolve(!0),onCancel:()=>n.resolve(!1)}),(n==null?void 0:n.kind)==="alert"&&d.jsx(dY,{title:n.opts.title,body:n.opts.body,confirm:n.opts.confirm??t("dialog.alert.default"),onClose:()=>n.resolve()}),(n==null?void 0:n.kind)==="prompt"&&d.jsx(fY,{title:n.opts.title,body:n.opts.body,placeholder:n.opts.placeholder,defaultValue:n.opts.defaultValue,confirm:n.opts.confirm??t("dialog.confirm.default"),cancel:n.opts.cancel??t("dialog.cancel.default"),onConfirm:c=>n.resolve(c),onCancel:()=>n.resolve(null)})]})}function Bn(){const e=_.useContext(KR);if(!e)throw new Error("useDialog must be used inside <DialogProvider>");return e}function dY({title:e,body:t,confirm:n,onClose:i}){return _.useEffect(()=>{const s=r=>{(r.key==="Escape"||r.key==="Enter")&&i()};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[i]),d.jsx("div",{role:"dialog","aria-modal":"true",className:"fixed inset-0 z-50 flex items-center justify-center p-6 bg-black/30",children:d.jsxs("div",{className:"nb-card max-w-md w-full",children:[d.jsx("h2",{className:"font-[family-name:var(--font-heading)] text-xl font-bold mb-2",children:e}),d.jsx("p",{className:"text-sm text-[var(--color-text-muted)] mb-5 whitespace-pre-wrap break-words",children:t}),d.jsx("div",{className:"flex gap-3 justify-end",children:d.jsx("button",{className:"nb-btn nb-btn-primary",onClick:i,type:"button",autoFocus:!0,children:n})})]})})}function fY({title:e,body:t,placeholder:n,defaultValue:i,confirm:s,cancel:r,onConfirm:o,onCancel:c}){const[u,f]=_.useState(i??""),p=_.useRef(null);_.useEffect(()=>{var b,x;(b=p.current)==null||b.focus(),(x=p.current)==null||x.select();const y=v=>{v.key==="Escape"&&c()};return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[c]);const m=()=>{const y=u.trim();y&&o(y)};return d.jsx("div",{role:"dialog","aria-modal":"true",className:"fixed inset-0 z-50 flex items-center justify-center p-6 bg-black/30",children:d.jsxs("div",{className:"nb-card max-w-md w-full",children:[d.jsx("h2",{className:"font-[family-name:var(--font-heading)] text-xl font-bold mb-2",children:e}),t&&d.jsx("p",{className:"text-sm text-[var(--color-text-muted)] mb-3 whitespace-pre-wrap break-words",children:t}),d.jsx("input",{ref:p,type:"text",className:"nb-input w-full mb-5",placeholder:n,value:u,onChange:y=>f(y.target.value),onKeyDown:y=>{y.key==="Enter"&&!y.nativeEvent.isComposing&&(y.preventDefault(),m())}}),d.jsxs("div",{className:"flex gap-3 justify-end",children:[d.jsx("button",{className:"nb-btn",onClick:c,type:"button",children:r}),d.jsx("button",{className:"nb-btn nb-btn-primary",onClick:m,type:"button",disabled:!u.trim(),children:s})]})]})})}function T1({initialPath:e,onCancel:t,onSelect:n,title:i,mode:s="directory"}){var C,S,T;const r=Xe(),{prompt:o,alert:c}=Bn(),u=i??r("dirPicker.title.default"),[f,p]=_.useState(e??null),[m,y]=_.useState(null),b=ot({queryKey:["fs-browse",f],queryFn:()=>BR(f??void 0),staleTime:0,gcTime:0}),x=((C=b.data)==null?void 0:C.path)??f??"",v=((S=b.data)==null?void 0:S.parent)??null,w=((T=b.data)==null?void 0:T.home)??null,k=async()=>{var j;if(!x)return;const A=(j=await o({title:r("dirPicker.newDir"),body:r("dirPicker.newDir.prompt"),placeholder:r("dirPicker.newDir.placeholder"),confirm:r("dirPicker.newDir.create")}))==null?void 0:j.trim();if(A)try{const M=await zW(x,A);p(M.path)}catch(M){c({title:r("dirPicker.newDir.error.title"),body:M instanceof Error?M.message:String(M)})}};return _.useEffect(()=>{const A=j=>{j.key==="Escape"&&(j.preventDefault(),t())};return window.addEventListener("keydown",A),()=>window.removeEventListener("keydown",A)},[t]),d.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-[rgba(45,55,72,0.5)] p-4",role:"presentation",children:d.jsxs("div",{className:"nb-card bg-[var(--color-bg)] max-w-lg w-full h-[70vh] min-h-0 overflow-hidden p-5 flex flex-col",role:"dialog","aria-modal":"true","aria-label":u,children:[d.jsxs("header",{className:"flex items-center justify-between mb-3 shrink-0",children:[d.jsx("div",{className:"flex items-center gap-2 min-w-0",children:d.jsx("h3",{className:"font-[family-name:var(--font-heading)] font-bold text-base truncate",children:u})}),d.jsx("button",{type:"button",className:"p-1 hover:bg-[var(--surface-control-hover)] rounded",onClick:t,"aria-label":r("dirPicker.close.aria"),children:d.jsx(En,{size:14,strokeWidth:3})})]}),d.jsxs("div",{className:"flex items-center gap-2 mb-3 shrink-0",children:[d.jsx("button",{type:"button",className:"nb-btn flex-shrink-0",style:{padding:"4px 10px",fontSize:12},onClick:()=>v&&p(v),disabled:!v||b.isLoading,"aria-label":r("dirPicker.up.aria"),title:r("dirPicker.up.title"),children:d.jsx(FB,{size:12,strokeWidth:3})}),d.jsx("button",{type:"button",className:"nb-btn flex-shrink-0",style:{padding:"4px 10px",fontSize:12},onClick:()=>w&&p(w),disabled:!w||b.isLoading,"aria-label":r("dirPicker.home.aria"),title:r("dirPicker.home.title"),children:d.jsx(zj,{size:12,strokeWidth:3})}),d.jsx("button",{type:"button",className:"nb-btn flex-shrink-0",style:{padding:"4px 10px",fontSize:12},onClick:()=>void k(),disabled:!x||b.isLoading||b.isError,"aria-label":r("dirPicker.newDir.aria"),title:r("dirPicker.newDir.aria"),children:d.jsx(vU,{size:12,strokeWidth:3})}),d.jsx("div",{className:"flex-1 min-w-0 nb-input font-[family-name:var(--font-mono)] text-xs px-2 py-1.5 truncate",title:x,dir:"rtl",children:x||"..."})]}),d.jsx("div",{className:"scroll-frame flex-1 border-2 border-[var(--color-text)] rounded-lg bg-[var(--color-bg-cream)] min-h-0",children:d.jsxs("div",{className:"scroll-frame-body h-full",children:[b.isLoading&&d.jsxs("div",{className:"flex items-center justify-center py-12 text-[var(--color-text-muted)]",children:[d.jsx(mt,{size:16,strokeWidth:3,className:"animate-spin mr-2"}),r("dirPicker.loading")]}),b.isError&&d.jsxs("div",{className:"p-4 text-sm text-[var(--color-crashed)]",children:[d.jsx("p",{className:"font-bold mb-1",children:r("dirPicker.error.title")}),d.jsx("p",{className:"text-xs font-[family-name:var(--font-mono)] break-all",children:b.error instanceof Error?b.error.message:String(b.error)})]}),b.data&&d.jsxs("ul",{className:"divide-y-2 divide-[var(--color-text)]/20",children:[b.data.entries.length===0&&d.jsx("li",{className:"p-4 text-xs text-[var(--color-text-subtle)] italic text-center",children:r("dirPicker.empty")}),b.data.entries.map(A=>{const j=(()=>{const P=x.endsWith("/")||x.endsWith("\\")?"":"/";return`${x}${P}${A.name}`})(),M=s==="file"&&m===j,D=A.isDirectory||s==="file";return d.jsx("li",{children:d.jsxs("button",{type:"button",className:["w-full flex items-center gap-2 px-3 py-2 text-left text-sm font-[family-name:var(--font-mono)]","disabled:opacity-50 disabled:cursor-not-allowed",M?"bg-[var(--color-accent-mint)] font-bold":"hover:bg-[var(--color-accent-mint)]"].join(" "),disabled:!D,onClick:()=>{A.isDirectory?(y(null),p(j)):s==="file"&&y(j)},onDoubleClick:()=>{s==="file"&&!A.isDirectory&&n(j)},title:A.isDirectory?r("dirPicker.enter.aria",{name:A.name}):s==="file"?r("dirPicker.pickFile.aria",{name:A.name}):r("dirPicker.fileLocked"),children:[A.isDirectory?d.jsx(Pj,{size:14,strokeWidth:2.5,className:"flex-shrink-0 text-[var(--color-text)]"}):d.jsx("span",{className:"w-3.5 h-3.5 flex-shrink-0"}),d.jsx("span",{className:"truncate",children:A.name}),A.isDirectory&&d.jsx(pf,{size:12,strokeWidth:2.5,className:"ml-auto flex-shrink-0 text-[var(--color-text-muted)]"})]})},A.name)})]})]})}),d.jsxs("div",{className:"flex gap-2 justify-end pt-3 shrink-0",children:[d.jsx("button",{type:"button",className:"nb-btn",onClick:t,children:r("dirPicker.cancel")}),s==="file"?d.jsxs("button",{type:"button",className:"nb-btn nb-btn-primary",onClick:()=>m&&n(m),disabled:!m||b.isLoading||b.isError,title:m??r("dirPicker.useFile.tooltip.empty"),children:[d.jsx(Qp,{size:14,strokeWidth:3}),r("dirPicker.useFile")]}):d.jsxs("button",{type:"button",className:"nb-btn nb-btn-primary",onClick:()=>n(x),disabled:!x||b.isLoading||b.isError,children:[d.jsx(Qp,{size:14,strokeWidth:3}),r("dirPicker.useDir")]})]})]})})}function hY({onCancel:e,onCreate:t}){var A,j;const n=Xe(),[i,s]=_.useState(""),[r,o]=_.useState(""),[c,u]=_.useState("claude"),[f,p]=_.useState(""),[m,y]=_.useState(!1),[b,x]=_.useState(!1),[v,w]=_.useState(!1),k=ot({queryKey:["providers"],queryFn:C1}),C=ot({queryKey:["system-agents"],queryFn:s1}),S=VR((c==="openai"?(A=k.data)==null?void 0:A.openai:(j=k.data)==null?void 0:j.anthropic)??[]);_.useEffect(()=>{p(""),y(!1)},[c]),_.useEffect(()=>{var P;if(m)return;const M=(P=C.data)==null?void 0:P.agents.worker;if(!M)return;const D=`${M.providerId||"official"}::${M.model}`;S.some(I=>`${I.providerId}::${I.model}`===D)&&p(D)},[C.data,S,m]),_.useEffect(()=>{if(v)return;const M=D=>{D.key==="Escape"&&(D.preventDefault(),e())};return window.addEventListener("keydown",M),()=>window.removeEventListener("keydown",M)},[e,v]);const T=async()=>{if(!b){x(!0);try{const[M,D]=f?f.split("::"):[void 0,void 0];t({title:i.trim()||void 0,cwd:r.trim()||void 0,agentKind:c,model:D,providerId:M})}finally{x(!1)}}};return d.jsxs("div",{className:"fixed inset-0 z-40 flex items-center justify-center bg-[rgba(45,55,72,0.4)] p-4",role:"presentation",children:[d.jsxs("div",{className:"nb-card bg-[var(--color-bg)] max-w-md w-full p-5",role:"dialog","aria-modal":"true","aria-label":n("chat.newSession.title.aria"),children:[d.jsxs("header",{className:"flex items-center justify-between mb-4",children:[d.jsx("h2",{className:"font-[family-name:var(--font-heading)] font-bold text-lg",children:n("chat.newSession.title")}),d.jsx("button",{type:"button",className:"p-1 hover:bg-[var(--surface-control-hover)] rounded",onClick:e,"aria-label":n("chat.newSession.close.aria"),children:d.jsx(En,{size:16,strokeWidth:3})})]}),d.jsxs("div",{className:"flex flex-col gap-4",children:[d.jsxs("div",{children:[d.jsx("span",{className:"block text-xs font-bold mb-1.5 uppercase tracking-wider",children:n("chat.newSession.field.agent")}),d.jsx("div",{className:"flex gap-2",role:"group","aria-label":n("chat.newSession.field.agent"),children:["claude","openai"].map(M=>d.jsx("button",{type:"button",onClick:()=>u(M),"aria-pressed":c===M,className:["flex-1 px-3 py-1.5 rounded-lg border-2 text-sm font-bold capitalize transition-all",c===M?"bg-[var(--color-accent-mint)] border-[var(--color-text)] shadow-[2px_2px_0_var(--color-text)]":"bg-[var(--color-bg)] border-[var(--color-border-light)] hover:border-[var(--color-text)]"].join(" "),children:M},M))})]}),d.jsxs("div",{children:[d.jsx("label",{htmlFor:"new-session-model",className:"block text-xs font-bold mb-1.5 uppercase tracking-wider",children:n("chat.newSession.field.model")}),d.jsxs("select",{id:"new-session-model",className:"nb-input w-full font-[family-name:var(--font-mono)] text-sm",value:f,onChange:M=>{y(!0),p(M.target.value)},children:[d.jsx("option",{value:"",children:n("chat.newSession.field.model.default")}),S.map(M=>d.jsx("option",{value:`${M.providerId}::${M.model}`,children:M.label},`${M.providerId}::${M.model}`))]})]}),d.jsxs("div",{children:[d.jsx("label",{htmlFor:"new-session-title",className:"block text-xs font-bold mb-1.5 uppercase tracking-wider",children:n("chat.newSession.field.title")}),d.jsx("input",{id:"new-session-title",type:"text",className:"nb-input w-full",placeholder:n("chat.newSession.field.title.placeholder"),value:i,onChange:M=>s(M.target.value),autoFocus:!0})]}),d.jsxs("div",{children:[d.jsx("label",{htmlFor:"new-session-cwd",className:"block text-xs font-bold mb-1.5 uppercase tracking-wider",children:n("chat.newSession.field.cwd")}),d.jsxs("div",{className:"flex gap-2",children:[d.jsx("input",{id:"new-session-cwd",type:"text",className:"nb-input flex-1 font-[family-name:var(--font-mono)] text-sm",placeholder:"/home/coral/projects/my-app",value:r,onChange:M=>o(M.target.value)}),d.jsxs("button",{type:"button",className:"nb-btn flex-shrink-0",onClick:()=>w(!0),"aria-label":n("chat.newSession.field.cwd.browseAria"),title:n("chat.newSession.field.cwd.browseAria"),children:[d.jsx(Xv,{size:14,strokeWidth:2.5}),n("chat.newSession.field.cwd.browse")]})]}),d.jsxs("p",{className:"text-[11px] text-[var(--color-text-muted)] mt-1.5 leading-relaxed",children:[d.jsx(Pj,{size:10,strokeWidth:2.5,className:"inline mr-1 -mt-0.5"}),n("chat.newSession.field.cwd.help1")," ",n("chat.newSession.field.cwd.help2")]})]}),d.jsxs("div",{className:"flex gap-2 justify-end pt-2",children:[d.jsx("button",{type:"button",className:"nb-btn",onClick:e,children:n("chat.newSession.cancel")}),d.jsxs("button",{type:"button",className:"nb-btn nb-btn-primary",onClick:T,disabled:b,children:[b?d.jsx(mt,{size:14,strokeWidth:3,className:"animate-spin"}):d.jsx(Gn,{size:14,strokeWidth:3}),n("chat.newSession.create")]})]})]})]}),v&&d.jsx(T1,{initialPath:r.trim()||void 0,onCancel:()=>w(!1),onSelect:M=>{o(M),w(!1)}})]})}const GR=_.createContext({});function pY(e){const t=_.useRef(null);return t.current===null&&(t.current=e()),t.current}const mY=typeof window<"u",gY=mY?_.useLayoutEffect:_.useEffect,A1=_.createContext(null);function j1(e,t){e.indexOf(t)===-1&&e.push(t)}function am(e,t){const n=e.indexOf(t);n>-1&&e.splice(n,1)}const Nr=(e,t,n)=>n>t?t:n<e?e:n;let M1=()=>{};const oo={},WR=e=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(e),YR=e=>typeof e=="object"&&e!==null,XR=e=>/^0[^.\s]+$/u.test(e);function QR(e){let t;return()=>(t===void 0&&(t=e()),t)}const Cs=e=>e,vf=(...e)=>e.reduce((t,n)=>i=>n(t(i))),Bd=(e,t,n)=>{const i=t-e;return i?(n-e)/i:1};class R1{constructor(){this.subscriptions=[]}add(t){return j1(this.subscriptions,t),()=>am(this.subscriptions,t)}notify(t,n,i){const s=this.subscriptions.length;if(s)if(s===1)this.subscriptions[0](t,n,i);else for(let r=0;r<s;r++){const o=this.subscriptions[r];o&&o(t,n,i)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}}const os=e=>e*1e3,_s=e=>e/1e3,ZR=(e,t)=>t?e*(1e3/t):0,JR=(e,t,n)=>(((1-3*n+3*t)*e+(3*n-6*t))*e+3*t)*e,yY=1e-7,bY=12;function xY(e,t,n,i,s){let r,o,c=0;do o=t+(n-t)/2,r=JR(o,i,s)-e,r>0?n=o:t=o;while(Math.abs(r)>yY&&++c<bY);return o}function wf(e,t,n,i){if(e===t&&n===i)return Cs;const s=r=>xY(r,0,1,e,n);return r=>r===0||r===1?r:JR(s(r),t,i)}const eD=e=>t=>t<=.5?e(2*t)/2:(2-e(2*(1-t)))/2,tD=e=>t=>1-e(1-t),nD=wf(.33,1.53,.69,.99),D1=tD(nD),iD=eD(D1),sD=e=>e>=1?1:(e*=2)<1?.5*D1(e):.5*(2-Math.pow(2,-10*(e-1))),O1=e=>1-Math.sin(Math.acos(e)),rD=tD(O1),aD=eD(O1),vY=wf(.42,0,1,1),wY=wf(0,0,.58,1),oD=wf(.42,0,.58,1),EY=e=>Array.isArray(e)&&typeof e[0]!="number",lD=e=>Array.isArray(e)&&typeof e[0]=="number",kY={linear:Cs,easeIn:vY,easeInOut:oD,easeOut:wY,circIn:O1,circInOut:aD,circOut:rD,backIn:D1,backInOut:iD,backOut:nD,anticipate:sD},SY=e=>typeof e=="string",M2=e=>{if(lD(e)){M1(e.length===4);const[t,n,i,s]=e;return wf(t,n,i,s)}else if(SY(e))return kY[e];return e},ep=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function NY(e){let t=new Set,n=new Set,i=!1,s=!1;const r=new WeakSet;let o={delta:0,timestamp:0,isProcessing:!1};function c(f){r.has(f)&&(u.schedule(f),e()),f(o)}const u={schedule:(f,p=!1,m=!1)=>{const b=m&&i?t:n;return p&&r.add(f),b.add(f),f},cancel:f=>{n.delete(f),r.delete(f)},process:f=>{if(o=f,i){s=!0;return}i=!0;const p=t;t=n,n=p,t.forEach(c),t.clear(),i=!1,s&&(s=!1,u.process(f))}};return u}const _Y=40;function cD(e,t){let n=!1,i=!0;const s={delta:0,timestamp:0,isProcessing:!1},r=()=>n=!0,o=ep.reduce((S,T)=>(S[T]=NY(r),S),{}),{setup:c,read:u,resolveKeyframes:f,preUpdate:p,update:m,preRender:y,render:b,postRender:x}=o,v=()=>{const S=oo.useManualTiming,T=S?s.timestamp:performance.now();n=!1,S||(s.delta=i?1e3/60:Math.max(Math.min(T-s.timestamp,_Y),1)),s.timestamp=T,s.isProcessing=!0,c.process(s),u.process(s),f.process(s),p.process(s),m.process(s),y.process(s),b.process(s),x.process(s),s.isProcessing=!1,n&&t&&(i=!1,e(v))},w=()=>{n=!0,i=!0,s.isProcessing||e(v)};return{schedule:ep.reduce((S,T)=>{const A=o[T];return S[T]=(j,M=!1,D=!1)=>(n||w(),A.schedule(j,M,D)),S},{}),cancel:S=>{for(let T=0;T<ep.length;T++)o[ep[T]].cancel(S)},state:s,steps:o}}const{schedule:un,cancel:lo,state:mi,steps:rx}=cD(typeof requestAnimationFrame<"u"?requestAnimationFrame:Cs,!0);let jp;function CY(){jp=void 0}const Mi={now:()=>(jp===void 0&&Mi.set(mi.isProcessing||oo.useManualTiming?mi.timestamp:performance.now()),jp),set:e=>{jp=e,queueMicrotask(CY)}},uD=e=>t=>typeof t=="string"&&t.startsWith(e),dD=uD("--"),TY=uD("var(--"),L1=e=>TY(e)?AY.test(e.split("/*")[0].trim()):!1,AY=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function R2(e){return typeof e!="string"?!1:e.split("/*")[0].includes("var(--")}const iu={test:e=>typeof e=="number",parse:parseFloat,transform:e=>e},Ud={...iu,transform:e=>Nr(0,1,e)},tp={...iu,default:1},_d=e=>Math.round(e*1e5)/1e5,I1=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function jY(e){return e==null}const MY=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,P1=(e,t)=>n=>!!(typeof n=="string"&&MY.test(n)&&n.startsWith(e)||t&&!jY(n)&&Object.prototype.hasOwnProperty.call(n,t)),fD=(e,t,n)=>i=>{if(typeof i!="string")return i;const[s,r,o,c]=i.match(I1);return{[e]:parseFloat(s),[t]:parseFloat(r),[n]:parseFloat(o),alpha:c!==void 0?parseFloat(c):1}},RY=e=>Nr(0,255,e),ax={...iu,transform:e=>Math.round(RY(e))},qo={test:P1("rgb","red"),parse:fD("red","green","blue"),transform:({red:e,green:t,blue:n,alpha:i=1})=>"rgba("+ax.transform(e)+", "+ax.transform(t)+", "+ax.transform(n)+", "+_d(Ud.transform(i))+")"};function DY(e){let t="",n="",i="",s="";return e.length>5?(t=e.substring(1,3),n=e.substring(3,5),i=e.substring(5,7),s=e.substring(7,9)):(t=e.substring(1,2),n=e.substring(2,3),i=e.substring(3,4),s=e.substring(4,5),t+=t,n+=n,i+=i,s+=s),{red:parseInt(t,16),green:parseInt(n,16),blue:parseInt(i,16),alpha:s?parseInt(s,16)/255:1}}const z0={test:P1("#"),parse:DY,transform:qo.transform},Ef=e=>({test:t=>typeof t=="string"&&t.endsWith(e)&&t.split(" ").length===1,parse:parseFloat,transform:t=>`${t}${e}`}),Jr=Ef("deg"),Er=Ef("%"),Ge=Ef("px"),OY=Ef("vh"),LY=Ef("vw"),D2={...Er,parse:e=>Er.parse(e)/100,transform:e=>Er.transform(e*100)},dc={test:P1("hsl","hue"),parse:fD("hue","saturation","lightness"),transform:({hue:e,saturation:t,lightness:n,alpha:i=1})=>"hsla("+Math.round(e)+", "+Er.transform(_d(t))+", "+Er.transform(_d(n))+", "+_d(Ud.transform(i))+")"},Kn={test:e=>qo.test(e)||z0.test(e)||dc.test(e),parse:e=>qo.test(e)?qo.parse(e):dc.test(e)?dc.parse(e):z0.parse(e),transform:e=>typeof e=="string"?e:e.hasOwnProperty("red")?qo.transform(e):dc.transform(e),getAnimatableNone:e=>{const t=Kn.parse(e);return t.alpha=0,Kn.transform(t)}},IY=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function PY(e){var t,n;return isNaN(e)&&typeof e=="string"&&(((t=e.match(I1))==null?void 0:t.length)||0)+(((n=e.match(IY))==null?void 0:n.length)||0)>0}const hD="number",pD="color",zY="var",BY="var(",O2="${}",UY=/var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)/giu;function $c(e){const t=e.toString(),n=[],i={color:[],number:[],var:[]},s=[];let r=0;const c=t.replace(UY,u=>(Kn.test(u)?(i.color.push(r),s.push(pD),n.push(Kn.parse(u))):u.startsWith(BY)?(i.var.push(r),s.push(zY),n.push(u)):(i.number.push(r),s.push(hD),n.push(parseFloat(u))),++r,O2)).split(O2);return{values:n,split:c,indexes:i,types:s}}function FY(e){return $c(e).values}function mD({split:e,types:t}){const n=e.length;return i=>{let s="";for(let r=0;r<n;r++)if(s+=e[r],i[r]!==void 0){const o=t[r];o===hD?s+=_d(i[r]):o===pD?s+=Kn.transform(i[r]):s+=i[r]}return s}}function $Y(e){return mD($c(e))}const qY=e=>typeof e=="number"?0:Kn.test(e)?Kn.getAnimatableNone(e):e,HY=(e,t)=>typeof e=="number"?t!=null&&t.trim().endsWith("/")?e:0:qY(e);function VY(e){const t=$c(e);return mD(t)(t.values.map((i,s)=>HY(i,t.split[s])))}const er={test:PY,parse:FY,createTransformer:$Y,getAnimatableNone:VY};function ox(e,t,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*(2/3-n)*6:e}function KY({hue:e,saturation:t,lightness:n,alpha:i}){e/=360,t/=100,n/=100;let s=0,r=0,o=0;if(!t)s=r=o=n;else{const c=n<.5?n*(1+t):n+t-n*t,u=2*n-c;s=ox(u,c,e+1/3),r=ox(u,c,e),o=ox(u,c,e-1/3)}return{red:Math.round(s*255),green:Math.round(r*255),blue:Math.round(o*255),alpha:i}}function om(e,t){return n=>n>0?t:e}const cn=(e,t,n)=>e+(t-e)*n,lx=(e,t,n)=>{const i=e*e,s=n*(t*t-i)+i;return s<0?0:Math.sqrt(s)},GY=[z0,qo,dc],WY=e=>GY.find(t=>t.test(e));function L2(e){const t=WY(e);if(!t)return!1;let n=t.parse(e);return t===dc&&(n=KY(n)),n}const I2=(e,t)=>{const n=L2(e),i=L2(t);if(!n||!i)return om(e,t);const s={...n};return r=>(s.red=lx(n.red,i.red,r),s.green=lx(n.green,i.green,r),s.blue=lx(n.blue,i.blue,r),s.alpha=cn(n.alpha,i.alpha,r),qo.transform(s))},B0=new Set(["none","hidden"]);function YY(e,t){return B0.has(e)?n=>n<=0?e:t:n=>n>=1?t:e}function XY(e,t){return n=>cn(e,t,n)}function z1(e){return typeof e=="number"?XY:typeof e=="string"?L1(e)?om:Kn.test(e)?I2:JY:Array.isArray(e)?gD:typeof e=="object"?Kn.test(e)?I2:QY:om}function gD(e,t){const n=[...e],i=n.length,s=e.map((r,o)=>z1(r)(r,t[o]));return r=>{for(let o=0;o<i;o++)n[o]=s[o](r);return n}}function QY(e,t){const n={...e,...t},i={};for(const s in n)e[s]!==void 0&&t[s]!==void 0&&(i[s]=z1(e[s])(e[s],t[s]));return s=>{for(const r in i)n[r]=i[r](s);return n}}function ZY(e,t){const n=[],i={color:0,var:0,number:0};for(let s=0;s<t.values.length;s++){const r=t.types[s],o=e.indexes[r][i[r]],c=e.values[o]??0;n[s]=c,i[r]++}return n}const JY=(e,t)=>{const n=er.createTransformer(t),i=$c(e),s=$c(t);return i.indexes.var.length===s.indexes.var.length&&i.indexes.color.length===s.indexes.color.length&&i.indexes.number.length>=s.indexes.number.length?B0.has(e)&&!s.values.length||B0.has(t)&&!i.values.length?YY(e,t):vf(gD(ZY(i,s),s.values),n):om(e,t)};function yD(e,t,n){return typeof e=="number"&&typeof t=="number"&&typeof n=="number"?cn(e,t,n):z1(e)(e,t)}const eX=e=>{const t=({timestamp:n})=>e(n);return{start:(n=!0)=>un.update(t,n),stop:()=>lo(t),now:()=>mi.isProcessing?mi.timestamp:Mi.now()}},bD=(e,t,n=10)=>{let i="";const s=Math.max(Math.round(t/n),2);for(let r=0;r<s;r++)i+=Math.round(e(r/(s-1))*1e4)/1e4+", ";return`linear(${i.substring(0,i.length-2)})`},lm=2e4;function B1(e){let t=0;const n=50;let i=e.next(t);for(;!i.done&&t<lm;)t+=n,i=e.next(t);return t>=lm?1/0:t}function tX(e,t=100,n){const i=n({...e,keyframes:[0,t]}),s=Math.min(B1(i),lm);return{type:"keyframes",ease:r=>i.next(s*r).value/t,duration:_s(s)}}const Ln={stiffness:100,damping:10,mass:1,velocity:0,duration:800,bounce:.3,visualDuration:.3,restSpeed:{granular:.01,default:2},restDelta:{granular:.005,default:.5},minDuration:.01,maxDuration:10,minDamping:.05,maxDamping:1};function U0(e,t){return e*Math.sqrt(1-t*t)}const nX=12;function iX(e,t,n){let i=n;for(let s=1;s<nX;s++)i=i-e(i)/t(i);return i}const cx=.001;function sX({duration:e=Ln.duration,bounce:t=Ln.bounce,velocity:n=Ln.velocity,mass:i=Ln.mass}){let s,r,o=1-t;o=Nr(Ln.minDamping,Ln.maxDamping,o),e=Nr(Ln.minDuration,Ln.maxDuration,_s(e)),o<1?(s=f=>{const p=f*o,m=p*e,y=p-n,b=U0(f,o),x=Math.exp(-m);return cx-y/b*x},r=f=>{const m=f*o*e,y=m*n+n,b=Math.pow(o,2)*Math.pow(f,2)*e,x=Math.exp(-m),v=U0(Math.pow(f,2),o);return(-s(f)+cx>0?-1:1)*((y-b)*x)/v}):(s=f=>{const p=Math.exp(-f*e),m=(f-n)*e+1;return-cx+p*m},r=f=>{const p=Math.exp(-f*e),m=(n-f)*(e*e);return p*m});const c=5/e,u=iX(s,r,c);if(e=os(e),isNaN(u))return{stiffness:Ln.stiffness,damping:Ln.damping,duration:e};{const f=Math.pow(u,2)*i;return{stiffness:f,damping:o*2*Math.sqrt(i*f),duration:e}}}const rX=["duration","bounce"],aX=["stiffness","damping","mass"];function P2(e,t){return t.some(n=>e[n]!==void 0)}function oX(e){let t={velocity:Ln.velocity,stiffness:Ln.stiffness,damping:Ln.damping,mass:Ln.mass,isResolvedFromDuration:!1,...e};if(!P2(e,aX)&&P2(e,rX))if(t.velocity=0,e.visualDuration){const n=e.visualDuration,i=2*Math.PI/(n*1.2),s=i*i,r=2*Nr(.05,1,1-(e.bounce||0))*Math.sqrt(s);t={...t,mass:Ln.mass,stiffness:s,damping:r}}else{const n=sX({...e,velocity:0});t={...t,...n,mass:Ln.mass},t.isResolvedFromDuration=!0}return t}function cm(e=Ln.visualDuration,t=Ln.bounce){const n=typeof e!="object"?{visualDuration:e,keyframes:[0,1],bounce:t}:e;let{restSpeed:i,restDelta:s}=n;const r=n.keyframes[0],o=n.keyframes[n.keyframes.length-1],c={done:!1,value:r},{stiffness:u,damping:f,mass:p,duration:m,velocity:y,isResolvedFromDuration:b}=oX({...n,velocity:-_s(n.velocity||0)}),x=y||0,v=f/(2*Math.sqrt(u*p)),w=o-r,k=_s(Math.sqrt(u/p)),C=Math.abs(w)<5;i||(i=C?Ln.restSpeed.granular:Ln.restSpeed.default),s||(s=C?Ln.restDelta.granular:Ln.restDelta.default);let S,T,A,j,M,D;if(v<1)A=U0(k,v),j=(x+v*k*w)/A,S=I=>{const B=Math.exp(-v*k*I);return o-B*(j*Math.sin(A*I)+w*Math.cos(A*I))},M=v*k*j+w*A,D=v*k*w-j*A,T=I=>Math.exp(-v*k*I)*(M*Math.sin(A*I)+D*Math.cos(A*I));else if(v===1){S=B=>o-Math.exp(-k*B)*(w+(x+k*w)*B);const I=x+k*w;T=B=>Math.exp(-k*B)*(k*I*B-x)}else{const I=k*Math.sqrt(v*v-1);S=R=>{const O=Math.exp(-v*k*R),z=Math.min(I*R,300);return o-O*((x+v*k*w)*Math.sinh(z)+I*w*Math.cosh(z))/I};const B=(x+v*k*w)/I,q=v*k*B-w*I,G=v*k*w-B*I;T=R=>{const O=Math.exp(-v*k*R),z=Math.min(I*R,300);return O*(q*Math.sinh(z)+G*Math.cosh(z))}}const P={calculatedDuration:b&&m||null,velocity:I=>os(T(I)),next:I=>{if(!b&&v<1){const q=Math.exp(-v*k*I),G=Math.sin(A*I),R=Math.cos(A*I),O=o-q*(j*G+w*R),z=os(q*(M*G+D*R));return c.done=Math.abs(z)<=i&&Math.abs(o-O)<=s,c.value=c.done?o:O,c}const B=S(I);if(b)c.done=I>=m;else{const q=os(T(I));c.done=Math.abs(q)<=i&&Math.abs(o-B)<=s}return c.value=c.done?o:B,c},toString:()=>{const I=Math.min(B1(P),lm),B=bD(q=>P.next(I*q).value,I,30);return I+"ms "+B},toTransition:()=>{}};return P}cm.applyToOptions=e=>{const t=tX(e,100,cm);return e.ease=t.ease,e.duration=os(t.duration),e.type="keyframes",e};const lX=5;function xD(e,t,n){const i=Math.max(t-lX,0);return ZR(n-e(i),t-i)}function F0({keyframes:e,velocity:t=0,power:n=.8,timeConstant:i=325,bounceDamping:s=10,bounceStiffness:r=500,modifyTarget:o,min:c,max:u,restDelta:f=.5,restSpeed:p}){const m=e[0],y={done:!1,value:m},b=D=>c!==void 0&&D<c||u!==void 0&&D>u,x=D=>c===void 0?u:u===void 0||Math.abs(c-D)<Math.abs(u-D)?c:u;let v=n*t;const w=m+v,k=o===void 0?w:o(w);k!==w&&(v=k-m);const C=D=>-v*Math.exp(-D/i),S=D=>k+C(D),T=D=>{const P=C(D),I=S(D);y.done=Math.abs(P)<=f,y.value=y.done?k:I};let A,j;const M=D=>{b(y.value)&&(A=D,j=cm({keyframes:[y.value,x(y.value)],velocity:xD(S,D,y.value),damping:s,stiffness:r,restDelta:f,restSpeed:p}))};return M(0),{calculatedDuration:null,next:D=>{let P=!1;return!j&&A===void 0&&(P=!0,T(D),M(D)),A!==void 0&&D>=A?j.next(D-A):(!P&&T(D),y)}}}function cX(e,t,n){const i=[],s=n||oo.mix||yD,r=e.length-1;for(let o=0;o<r;o++){let c=s(e[o],e[o+1]);if(t){const u=Array.isArray(t)?t[o]||Cs:t;c=vf(u,c)}i.push(c)}return i}function uX(e,t,{clamp:n=!0,ease:i,mixer:s}={}){const r=e.length;if(M1(r===t.length),r===1)return()=>t[0];if(r===2&&t[0]===t[1])return()=>t[1];const o=e[0]===e[1];e[0]>e[r-1]&&(e=[...e].reverse(),t=[...t].reverse());const c=cX(t,i,s),u=c.length,f=p=>{if(o&&p<e[0])return t[0];let m=0;if(u>1)for(;m<e.length-2&&!(p<e[m+1]);m++);const y=Bd(e[m],e[m+1],p);return c[m](y)};return n?p=>f(Nr(e[0],e[r-1],p)):f}function dX(e,t){const n=e[e.length-1];for(let i=1;i<=t;i++){const s=Bd(0,t,i);e.push(cn(n,1,s))}}function fX(e){const t=[0];return dX(t,e.length-1),t}function hX(e,t){return e.map(n=>n*t)}function pX(e,t){return e.map(()=>t||oD).splice(0,e.length-1)}function Cd({duration:e=300,keyframes:t,times:n,ease:i="easeInOut"}){const s=EY(i)?i.map(M2):M2(i),r={done:!1,value:t[0]},o=hX(n&&n.length===t.length?n:fX(t),e),c=uX(o,t,{ease:Array.isArray(s)?s:pX(t,s)});return{calculatedDuration:e,next:u=>(r.value=c(u),r.done=u>=e,r)}}const mX=e=>e!==null;function qm(e,{repeat:t,repeatType:n="loop"},i,s=1){const r=e.filter(mX),c=s<0||t&&n!=="loop"&&t%2===1?0:r.length-1;return!c||i===void 0?r[c]:i}const gX={decay:F0,inertia:F0,tween:Cd,keyframes:Cd,spring:cm};function vD(e){typeof e.type=="string"&&(e.type=gX[e.type])}class U1{constructor(){this.updateFinished()}get finished(){return this._finished}updateFinished(){this._finished=new Promise(t=>{this.resolve=t})}notifyFinished(){this.resolve()}then(t,n){return this.finished.then(t,n)}}const yX=e=>e/100;class um extends U1{constructor(t){super(),this.state="idle",this.startTime=null,this.isStopped=!1,this.currentTime=0,this.holdTime=null,this.playbackSpeed=1,this.delayState={done:!1,value:void 0},this.stop=()=>{var i,s;const{motionValue:n}=this.options;n&&n.updatedAt!==Mi.now()&&this.tick(Mi.now()),this.isStopped=!0,this.state!=="idle"&&(this.teardown(),(s=(i=this.options).onStop)==null||s.call(i))},this.options=t,this.initAnimation(),this.play(),t.autoplay===!1&&this.pause()}initAnimation(){const{options:t}=this;vD(t);const{type:n=Cd,repeat:i=0,repeatDelay:s=0,repeatType:r,velocity:o=0}=t;let{keyframes:c}=t;const u=n||Cd;u!==Cd&&typeof c[0]!="number"&&(this.mixKeyframes=vf(yX,yD(c[0],c[1])),c=[0,100]);const f=u({...t,keyframes:c});r==="mirror"&&(this.mirroredGenerator=u({...t,keyframes:[...c].reverse(),velocity:-o})),f.calculatedDuration===null&&(f.calculatedDuration=B1(f));const{calculatedDuration:p}=f;this.calculatedDuration=p,this.resolvedDuration=p+s,this.totalDuration=this.resolvedDuration*(i+1)-s,this.generator=f}updateTime(t){const n=Math.round(t-this.startTime)*this.playbackSpeed;this.holdTime!==null?this.currentTime=this.holdTime:this.currentTime=n}tick(t,n=!1){const{generator:i,totalDuration:s,mixKeyframes:r,mirroredGenerator:o,resolvedDuration:c,calculatedDuration:u}=this;if(this.startTime===null)return i.next(0);const{delay:f=0,keyframes:p,repeat:m,repeatType:y,repeatDelay:b,type:x,onUpdate:v,finalKeyframe:w}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,t):this.speed<0&&(this.startTime=Math.min(t-s/this.speed,this.startTime)),n?this.currentTime=t:this.updateTime(t);const k=this.currentTime-f*(this.playbackSpeed>=0?1:-1),C=this.playbackSpeed>=0?k<0:k>s;this.currentTime=Math.max(k,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=s);let S=this.currentTime,T=i;if(m){const D=Math.min(this.currentTime,s)/c;let P=Math.floor(D),I=D%1;!I&&D>=1&&(I=1),I===1&&P--,P=Math.min(P,m+1),!!(P%2)&&(y==="reverse"?(I=1-I,b&&(I-=b/c)):y==="mirror"&&(T=o)),S=Nr(0,1,I)*c}let A;C?(this.delayState.value=p[0],A=this.delayState):A=T.next(S),r&&!C&&(A.value=r(A.value));let{done:j}=A;!C&&u!==null&&(j=this.playbackSpeed>=0?this.currentTime>=s:this.currentTime<=0);const M=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&j);return M&&x!==F0&&(A.value=qm(p,this.options,w,this.speed)),v&&v(A.value),M&&this.finish(),A}then(t,n){return this.finished.then(t,n)}get duration(){return _s(this.calculatedDuration)}get iterationDuration(){const{delay:t=0}=this.options||{};return this.duration+_s(t)}get time(){return _s(this.currentTime)}set time(t){t=os(t),this.currentTime=t,this.startTime===null||this.holdTime!==null||this.playbackSpeed===0?this.holdTime=t:this.driver&&(this.startTime=this.driver.now()-t/this.playbackSpeed),this.driver?this.driver.start(!1):(this.startTime=0,this.state="paused",this.holdTime=t,this.tick(t))}getGeneratorVelocity(){const t=this.currentTime;if(t<=0)return this.options.velocity||0;if(this.generator.velocity)return this.generator.velocity(t);const n=this.generator.next(t).value;return xD(i=>this.generator.next(i).value,t,n)}get speed(){return this.playbackSpeed}set speed(t){const n=this.playbackSpeed!==t;n&&this.driver&&this.updateTime(Mi.now()),this.playbackSpeed=t,n&&this.driver&&(this.time=_s(this.currentTime))}play(){var s,r;if(this.isStopped)return;const{driver:t=eX,startTime:n}=this.options;this.driver||(this.driver=t(o=>this.tick(o))),(r=(s=this.options).onPlay)==null||r.call(s);const i=this.driver.now();this.state==="finished"?(this.updateFinished(),this.startTime=i):this.holdTime!==null?this.startTime=i-this.holdTime:this.startTime||(this.startTime=n??i),this.state==="finished"&&this.speed<0&&(this.startTime+=this.calculatedDuration),this.holdTime=null,this.state="running",this.driver.start()}pause(){this.state="paused",this.updateTime(Mi.now()),this.holdTime=this.currentTime}complete(){this.state!=="running"&&this.play(),this.state="finished",this.holdTime=null}finish(){var t,n;this.notifyFinished(),this.teardown(),this.state="finished",(n=(t=this.options).onComplete)==null||n.call(t)}cancel(){var t,n;this.holdTime=null,this.startTime=0,this.tick(0),this.teardown(),(n=(t=this.options).onCancel)==null||n.call(t)}teardown(){this.state="idle",this.stopDriver(),this.startTime=this.holdTime=null}stopDriver(){this.driver&&(this.driver.stop(),this.driver=void 0)}sample(t){return this.startTime=0,this.tick(t,!0)}attachTimeline(t){var n;return this.options.allowFlatten&&(this.options.type="keyframes",this.options.ease="linear",this.initAnimation()),(n=this.driver)==null||n.stop(),t.observe(this)}}function bX(e){for(let t=1;t<e.length;t++)e[t]??(e[t]=e[t-1])}const Ho=e=>e*180/Math.PI,$0=e=>{const t=Ho(Math.atan2(e[1],e[0]));return q0(t)},xX={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:e=>(Math.abs(e[0])+Math.abs(e[3]))/2,rotate:$0,rotateZ:$0,skewX:e=>Ho(Math.atan(e[1])),skewY:e=>Ho(Math.atan(e[2])),skew:e=>(Math.abs(e[1])+Math.abs(e[2]))/2},q0=e=>(e=e%360,e<0&&(e+=360),e),z2=$0,B2=e=>Math.sqrt(e[0]*e[0]+e[1]*e[1]),U2=e=>Math.sqrt(e[4]*e[4]+e[5]*e[5]),vX={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:B2,scaleY:U2,scale:e=>(B2(e)+U2(e))/2,rotateX:e=>q0(Ho(Math.atan2(e[6],e[5]))),rotateY:e=>q0(Ho(Math.atan2(-e[2],e[0]))),rotateZ:z2,rotate:z2,skewX:e=>Ho(Math.atan(e[4])),skewY:e=>Ho(Math.atan(e[1])),skew:e=>(Math.abs(e[1])+Math.abs(e[4]))/2};function H0(e){return e.includes("scale")?1:0}function V0(e,t){if(!e||e==="none")return H0(t);const n=e.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let i,s;if(n)i=vX,s=n;else{const c=e.match(/^matrix\(([-\d.e\s,]+)\)$/u);i=xX,s=c}if(!s)return H0(t);const r=i[t],o=s[1].split(",").map(EX);return typeof r=="function"?r(o):o[r]}const wX=(e,t)=>{const{transform:n="none"}=getComputedStyle(e);return V0(n,t)};function EX(e){return parseFloat(e.trim())}const su=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],ru=new Set([...su,"pathRotation"]),F2=e=>e===iu||e===Ge,kX=new Set(["x","y","z"]),SX=su.filter(e=>!kX.has(e));function NX(e){const t=[];return SX.forEach(n=>{const i=e.getValue(n);i!==void 0&&(t.push([n,i.get()]),i.set(n.startsWith("scale")?1:0))}),t}const to={width:({x:e},{paddingLeft:t="0",paddingRight:n="0",boxSizing:i})=>{const s=e.max-e.min;return i==="border-box"?s:s-parseFloat(t)-parseFloat(n)},height:({y:e},{paddingTop:t="0",paddingBottom:n="0",boxSizing:i})=>{const s=e.max-e.min;return i==="border-box"?s:s-parseFloat(t)-parseFloat(n)},top:(e,{top:t})=>parseFloat(t),left:(e,{left:t})=>parseFloat(t),bottom:({y:e},{top:t})=>parseFloat(t)+(e.max-e.min),right:({x:e},{left:t})=>parseFloat(t)+(e.max-e.min),x:(e,{transform:t})=>V0(t,"x"),y:(e,{transform:t})=>V0(t,"y")};to.translateX=to.x;to.translateY=to.y;const sl=new Set;let K0=!1,G0=!1,W0=!1;function wD(){if(G0){const e=Array.from(sl).filter(i=>i.needsMeasurement),t=new Set(e.map(i=>i.element)),n=new Map;t.forEach(i=>{const s=NX(i);s.length&&(n.set(i,s),i.render())}),e.forEach(i=>i.measureInitialState()),t.forEach(i=>{i.render();const s=n.get(i);s&&s.forEach(([r,o])=>{var c;(c=i.getValue(r))==null||c.set(o)})}),e.forEach(i=>i.measureEndState()),e.forEach(i=>{i.suspendedScrollY!==void 0&&window.scrollTo(0,i.suspendedScrollY)})}G0=!1,K0=!1,sl.forEach(e=>e.complete(W0)),sl.clear()}function ED(){sl.forEach(e=>{e.readKeyframes(),e.needsMeasurement&&(G0=!0)})}function _X(){W0=!0,ED(),wD(),W0=!1}class F1{constructor(t,n,i,s,r,o=!1){this.state="pending",this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...t],this.onComplete=n,this.name=i,this.motionValue=s,this.element=r,this.isAsync=o}scheduleResolve(){this.state="scheduled",this.isAsync?(sl.add(this),K0||(K0=!0,un.read(ED),un.resolveKeyframes(wD))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:t,name:n,element:i,motionValue:s}=this;if(t[0]===null){const r=s==null?void 0:s.get(),o=t[t.length-1];if(r!==void 0)t[0]=r;else if(i&&n){const c=i.readValue(n,o);c!=null&&(t[0]=c)}t[0]===void 0&&(t[0]=o),s&&r===void 0&&s.set(t[0])}bX(t)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(t=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,t),sl.delete(this)}cancel(){this.state==="scheduled"&&(sl.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const CX=e=>e.startsWith("--");function kD(e,t,n){CX(t)?e.style.setProperty(t,n):e.style[t]=n}const TX={};function SD(e,t){const n=QR(e);return()=>TX[t]??n()}const AX=SD(()=>window.ScrollTimeline!==void 0,"scrollTimeline"),ND=SD(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),md=([e,t,n,i])=>`cubic-bezier(${e}, ${t}, ${n}, ${i})`,$2={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:md([0,.65,.55,1]),circOut:md([.55,0,1,.45]),backIn:md([.31,.01,.66,-.59]),backOut:md([.33,1.53,.69,.99])};function _D(e,t){if(e)return typeof e=="function"?ND()?bD(e,t):"ease-out":lD(e)?md(e):Array.isArray(e)?e.map(n=>_D(n,t)||$2.easeOut):$2[e]}function jX(e,t,n,{delay:i=0,duration:s=300,repeat:r=0,repeatType:o="loop",ease:c="easeOut",times:u}={},f=void 0){const p={[t]:n};u&&(p.offset=u);const m=_D(c,s);Array.isArray(m)&&(p.easing=m);const y={delay:i,duration:s,easing:Array.isArray(m)?"linear":m,fill:"both",iterations:r+1,direction:o==="reverse"?"alternate":"normal"};return f&&(y.pseudoElement=f),e.animate(p,y)}function CD(e){return typeof e=="function"&&"applyToOptions"in e}function MX({type:e,...t}){return CD(e)&&ND()?e.applyToOptions(t):(t.duration??(t.duration=300),t.ease??(t.ease="easeOut"),t)}class TD extends U1{constructor(t){if(super(),this.finishedTime=null,this.isStopped=!1,this.manualStartTime=null,!t)return;const{element:n,name:i,keyframes:s,pseudoElement:r,allowFlatten:o=!1,finalKeyframe:c,onComplete:u}=t;this.isPseudoElement=!!r,this.allowFlatten=o,this.options=t,M1(typeof t.type!="string");const f=MX(t);this.animation=jX(n,i,s,f,r),f.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!r){const p=qm(s,this.options,c,this.speed);this.updateMotionValue&&this.updateMotionValue(p),kD(n,i,p),this.animation.cancel()}u==null||u(),this.notifyFinished()}}play(){this.isStopped||(this.manualStartTime=null,this.animation.play(),this.state==="finished"&&this.updateFinished())}pause(){this.animation.pause()}complete(){var t,n;(n=(t=this.animation).finish)==null||n.call(t)}cancel(){try{this.animation.cancel()}catch{}}stop(){if(this.isStopped)return;this.isStopped=!0;const{state:t}=this;t==="idle"||t==="finished"||(this.updateMotionValue?this.updateMotionValue():this.commitStyles(),this.isPseudoElement||this.cancel())}commitStyles(){var n,i,s;const t=(n=this.options)==null?void 0:n.element;!this.isPseudoElement&&(t!=null&&t.isConnected)&&((s=(i=this.animation).commitStyles)==null||s.call(i))}get duration(){var n,i;const t=((i=(n=this.animation.effect)==null?void 0:n.getComputedTiming)==null?void 0:i.call(n).duration)||0;return _s(Number(t))}get iterationDuration(){const{delay:t=0}=this.options||{};return this.duration+_s(t)}get time(){return _s(Number(this.animation.currentTime)||0)}set time(t){const n=this.finishedTime!==null;this.manualStartTime=null,this.finishedTime=null,this.animation.currentTime=os(t),n&&this.animation.pause()}get speed(){return this.animation.playbackRate}set speed(t){t<0&&(this.finishedTime=null),this.animation.playbackRate=t}get state(){return this.finishedTime!==null?"finished":this.animation.playState}get startTime(){return this.manualStartTime??Number(this.animation.startTime)}set startTime(t){this.manualStartTime=this.animation.startTime=t}attachTimeline({timeline:t,rangeStart:n,rangeEnd:i,observe:s}){var r;return this.allowFlatten&&((r=this.animation.effect)==null||r.updateTiming({easing:"linear"})),this.animation.onfinish=null,t&&AX()?(this.animation.timeline=t,n&&(this.animation.rangeStart=n),i&&(this.animation.rangeEnd=i),Cs):s(this)}}const AD={anticipate:sD,backInOut:iD,circInOut:aD};function RX(e){return e in AD}function DX(e){typeof e.ease=="string"&&RX(e.ease)&&(e.ease=AD[e.ease])}const ux=10;class OX extends TD{constructor(t){DX(t),vD(t),super(t),t.startTime!==void 0&&t.autoplay!==!1&&(this.startTime=t.startTime),this.options=t}updateMotionValue(t){const{motionValue:n,onUpdate:i,onComplete:s,element:r,...o}=this.options;if(!n)return;if(t!==void 0){n.set(t);return}const c=new um({...o,autoplay:!1}),u=Math.max(ux,Mi.now()-this.startTime),f=Nr(0,ux,u-ux),p=c.sample(u).value,{name:m}=this.options;r&&m&&kD(r,m,p),n.setWithVelocity(c.sample(Math.max(0,u-f)).value,p,f),c.stop()}}const q2=(e,t)=>t==="zIndex"?!1:!!(typeof e=="number"||Array.isArray(e)||typeof e=="string"&&(er.test(e)||e==="0")&&!e.startsWith("url("));function LX(e){const t=e[0];if(e.length===1)return!0;for(let n=0;n<e.length;n++)if(e[n]!==t)return!0}function IX(e,t,n,i){const s=e[0];if(s===null)return!1;if(t==="display"||t==="visibility")return!0;const r=e[e.length-1],o=q2(s,t),c=q2(r,t);return!o||!c?!1:LX(e)||(n==="spring"||CD(n))&&i}function Y0(e){e.duration=0,e.type="keyframes"}const jD=new Set(["opacity","clipPath","filter","transform"]),PX=/^(?:oklch|oklab|lab|lch|color|color-mix|light-dark)\(/;function zX(e){for(let t=0;t<e.length;t++)if(typeof e[t]=="string"&&PX.test(e[t]))return!0;return!1}const BX=new Set(["color","backgroundColor","outlineColor","fill","stroke","borderColor","borderTopColor","borderRightColor","borderBottomColor","borderLeftColor"]),UX=QR(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));function FX(e){var m;const{motionValue:t,name:n,repeatDelay:i,repeatType:s,damping:r,type:o,keyframes:c}=e;if(!(((m=t==null?void 0:t.owner)==null?void 0:m.current)instanceof HTMLElement))return!1;const{onUpdate:f,transformTemplate:p}=t.owner.getProps();return UX()&&n&&(jD.has(n)||BX.has(n)&&zX(c))&&(n!=="transform"||!p)&&!f&&!i&&s!=="mirror"&&r!==0&&o!=="inertia"}const $X=40;class qX extends U1{constructor({autoplay:t=!0,delay:n=0,type:i="keyframes",repeat:s=0,repeatDelay:r=0,repeatType:o="loop",keyframes:c,name:u,motionValue:f,element:p,...m}){var x;super(),this.stop=()=>{var v,w;this._animation&&(this._animation.stop(),(v=this.stopTimeline)==null||v.call(this)),(w=this.keyframeResolver)==null||w.cancel()},this.createdAt=Mi.now();const y={autoplay:t,delay:n,type:i,repeat:s,repeatDelay:r,repeatType:o,name:u,motionValue:f,element:p,...m},b=(p==null?void 0:p.KeyframeResolver)||F1;this.keyframeResolver=new b(c,(v,w,k)=>this.onKeyframesResolved(v,w,y,!k),u,f,p),(x=this.keyframeResolver)==null||x.scheduleResolve()}onKeyframesResolved(t,n,i,s){var k,C;this.keyframeResolver=void 0;const{name:r,type:o,velocity:c,delay:u,isHandoff:f,onUpdate:p}=i;this.resolvedAt=Mi.now();let m=!0;IX(t,r,o,c)||(m=!1,(oo.instantAnimations||!u)&&(p==null||p(qm(t,i,n))),t[0]=t[t.length-1],Y0(i),i.repeat=0);const b={startTime:s?this.resolvedAt?this.resolvedAt-this.createdAt>$X?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:n,...i,keyframes:t},x=m&&!f&&FX(b),v=(C=(k=b.motionValue)==null?void 0:k.owner)==null?void 0:C.current;let w;if(x)try{w=new OX({...b,element:v})}catch{w=new um(b)}else w=new um(b);w.finished.then(()=>{this.notifyFinished()}).catch(Cs),this.pendingTimeline&&(this.stopTimeline=w.attachTimeline(this.pendingTimeline),this.pendingTimeline=void 0),this._animation=w}get finished(){return this._animation?this.animation.finished:this._finished}then(t,n){return this.finished.finally(t).then(()=>{})}get animation(){var t;return this._animation||((t=this.keyframeResolver)==null||t.resume(),_X()),this._animation}get duration(){return this.animation.duration}get iterationDuration(){return this.animation.iterationDuration}get time(){return this.animation.time}set time(t){this.animation.time=t}get speed(){return this.animation.speed}get state(){return this.animation.state}set speed(t){this.animation.speed=t}get startTime(){return this.animation.startTime}attachTimeline(t){return this._animation?this.stopTimeline=this.animation.attachTimeline(t):this.pendingTimeline=t,()=>this.stop()}play(){this.animation.play()}pause(){this.animation.pause()}complete(){this.animation.complete()}cancel(){var t;this._animation&&this.animation.cancel(),(t=this.keyframeResolver)==null||t.cancel()}}function MD(e,t,n,i=0,s=1){const r=Array.from(e).sort((f,p)=>f.sortNodePosition(p)).indexOf(t),o=e.size,c=(o-1)*i;return typeof n=="function"?n(r,o):s===1?r*i:c-r*i}const H2=30,HX=e=>!isNaN(parseFloat(e));class VX{constructor(t,n={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=i=>{var r;const s=Mi.now();if(this.updatedAt!==s&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(i),this.current!==this.prev&&((r=this.events.change)==null||r.notify(this.current),this.dependents))for(const o of this.dependents)o.dirty()},this.hasAnimated=!1,this.setCurrent(t),this.owner=n.owner}setCurrent(t){this.current=t,this.updatedAt=Mi.now(),this.canTrackVelocity===null&&t!==void 0&&(this.canTrackVelocity=HX(this.current))}setPrevFrameValue(t=this.current){this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt}onChange(t){return this.on("change",t)}on(t,n){this.events[t]||(this.events[t]=new R1);const i=this.events[t].add(n);return t==="change"?()=>{i(),un.read(()=>{this.events.change.getSize()||this.stop()})}:i}clearListeners(){for(const t in this.events)this.events[t].clear()}attach(t,n){this.passiveEffect=t,this.stopPassiveEffect=n}set(t){this.passiveEffect?this.passiveEffect(t,this.updateAndNotify):this.updateAndNotify(t)}setWithVelocity(t,n,i){this.set(n),this.prev=void 0,this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt-i}jump(t,n=!0){this.updateAndNotify(t),this.prev=t,this.prevUpdatedAt=this.prevFrameValue=void 0,n&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}dirty(){var t;(t=this.events.change)==null||t.notify(this.current)}addDependent(t){this.dependents||(this.dependents=new Set),this.dependents.add(t)}removeDependent(t){this.dependents&&this.dependents.delete(t)}get(){return this.current}getPrevious(){return this.prev}getVelocity(){const t=Mi.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||t-this.updatedAt>H2)return 0;const n=Math.min(this.updatedAt-this.prevUpdatedAt,H2);return ZR(parseFloat(this.current)-parseFloat(this.prevFrameValue),n)}start(t){return this.stop(),new Promise(n=>{this.hasAnimated=!0,this.animation=t(n),this.events.animationStart&&this.events.animationStart.notify()}).then(()=>{this.events.animationComplete&&this.events.animationComplete.notify(),this.clearAnimation()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){delete this.animation}destroy(){var t,n;(t=this.dependents)==null||t.clear(),(n=this.events.destroy)==null||n.notify(),this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}}function qc(e,t){return new VX(e,t)}function RD(e,t){if(e!=null&&e.inherit&&t){const{inherit:n,...i}=e;return{...t,...i}}return e}function $1(e,t){const n=(e==null?void 0:e[t])??(e==null?void 0:e.default)??e;return n!==e?RD(n,e):n}const KX={type:"spring",stiffness:500,damping:25,restSpeed:10},GX=e=>({type:"spring",stiffness:550,damping:e===0?2*Math.sqrt(550):30,restSpeed:10}),WX={type:"keyframes",duration:.8},YX={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},XX=(e,{keyframes:t})=>t.length>2?WX:ru.has(e)?e.startsWith("scale")?GX(t[1]):KX:YX,QX=new Set(["when","delay","delayChildren","staggerChildren","staggerDirection","repeat","repeatType","repeatDelay","from","elapsed"]);function ZX(e){for(const t in e)if(!QX.has(t))return!0;return!1}const q1=(e,t,n,i={},s,r)=>o=>{const c=$1(i,e)||{},u=c.delay||i.delay||0;let{elapsed:f=0}=i;f=f-os(u);const p={keyframes:Array.isArray(n)?n:[null,n],ease:"easeOut",velocity:t.getVelocity(),...c,delay:-f,onUpdate:y=>{t.set(y),c.onUpdate&&c.onUpdate(y)},onComplete:()=>{o(),c.onComplete&&c.onComplete()},name:e,motionValue:t,element:r?void 0:s};ZX(c)||Object.assign(p,XX(e,p)),p.duration&&(p.duration=os(p.duration)),p.repeatDelay&&(p.repeatDelay=os(p.repeatDelay)),p.from!==void 0&&(p.keyframes[0]=p.from);let m=!1;if((p.type===!1||p.duration===0&&!p.repeatDelay)&&(Y0(p),p.delay===0&&(m=!0)),(oo.instantAnimations||oo.skipAnimations||s!=null&&s.shouldSkipAnimations||c.skipAnimations)&&(m=!0,Y0(p),p.delay=0),p.allowFlatten=!c.type&&!c.ease,m&&!r&&t.get()!==void 0){const y=qm(p.keyframes,c);if(y!==void 0){un.update(()=>{p.onUpdate(y),p.onComplete()});return}}return c.isSync?new um(p):new qX(p)},JX=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function eQ(e){const t=JX.exec(e);if(!t)return[,];const[,n,i,s]=t;return[`--${n??i}`,s]}function DD(e,t,n=1){const[i,s]=eQ(e);if(!i)return;const r=window.getComputedStyle(t).getPropertyValue(i);if(r){const o=r.trim();return WR(o)?parseFloat(o):o}return L1(s)?DD(s,t,n+1):s}function V2(e){const t=[{},{}];return e==null||e.values.forEach((n,i)=>{t[0][i]=n.get(),t[1][i]=n.getVelocity()}),t}function H1(e,t,n,i){if(typeof t=="function"){const[s,r]=V2(i);t=t(n!==void 0?n:e.custom,s,r)}if(typeof t=="string"&&(t=e.variants&&e.variants[t]),typeof t=="function"){const[s,r]=V2(i);t=t(n!==void 0?n:e.custom,s,r)}return t}function rl(e,t,n){const i=e.getProps();return H1(i,t,n!==void 0?n:i.custom,e)}const OD=new Set(["width","height","top","left","right","bottom",...su]),X0=e=>Array.isArray(e);function tQ(e,t,n){e.hasValue(t)?e.getValue(t).set(n):e.addValue(t,qc(n))}function nQ(e){return X0(e)?e[e.length-1]||0:e}function iQ(e,t){const n=rl(e,t);let{transitionEnd:i={},transition:s={},...r}=n||{};r={...r,...i};for(const o in r){const c=nQ(r[o]);tQ(e,o,c)}}const gi=e=>!!(e&&e.getVelocity);function sQ(e){return!!(gi(e)&&e.add)}function Q0(e,t){const n=e.getValue("willChange");if(sQ(n))return n.add(t);if(!n&&oo.WillChange){const i=new oo.WillChange("auto");e.addValue("willChange",i),i.add(t)}}function V1(e){return e.replace(/([A-Z])/g,t=>`-${t.toLowerCase()}`)}const rQ="framerAppearId",LD="data-"+V1(rQ);function ID(e){return e.props[LD]}function aQ({protectedKeys:e,needsAnimating:t},n){const i=e.hasOwnProperty(n)&&t[n]!==!0;return t[n]=!1,i}function PD(e,t,{delay:n=0,transitionOverride:i,type:s}={}){let{transition:r,transitionEnd:o,...c}=t;const u=e.getDefaultTransition();r=r?RD(r,u):u;const f=r==null?void 0:r.reduceMotion,p=r==null?void 0:r.skipAnimations;i&&(r=i);const m=[],y=s&&e.animationState&&e.animationState.getState()[s],b=r==null?void 0:r.path;b&&b.animateVisualElement(e,c,r,n,m);for(const x in c){const v=e.getValue(x,e.latestValues[x]??null),w=c[x];if(w===void 0||y&&aQ(y,x))continue;const k={delay:n,...$1(r||{},x)};p&&(k.skipAnimations=!0);const C=v.get();if(C!==void 0&&!v.isAnimating()&&!Array.isArray(w)&&w===C&&!k.velocity){un.update(()=>v.set(w));continue}let S=!1;if(window.MotionHandoffAnimation){const j=ID(e);if(j){const M=window.MotionHandoffAnimation(j,x,un);M!==null&&(k.startTime=M,S=!0)}}Q0(e,x);const T=f??e.shouldReduceMotion;v.start(q1(x,v,w,T&&OD.has(x)?{type:!1}:k,e,S));const A=v.animation;A&&m.push(A)}if(o){const x=()=>un.update(()=>{o&&iQ(e,o)});m.length?Promise.all(m).then(x):x()}return m}function Z0(e,t,n={}){var u;const i=rl(e,t,n.type==="exit"?(u=e.presenceContext)==null?void 0:u.custom:void 0);let{transition:s=e.getDefaultTransition()||{}}=i||{};n.transitionOverride&&(s=n.transitionOverride);const r=i?()=>Promise.all(PD(e,i,n)):()=>Promise.resolve(),o=e.variantChildren&&e.variantChildren.size?(f=0)=>{const{delayChildren:p=0,staggerChildren:m,staggerDirection:y}=s;return oQ(e,t,f,p,m,y,n)}:()=>Promise.resolve(),{when:c}=s;if(c){const[f,p]=c==="beforeChildren"?[r,o]:[o,r];return f().then(()=>p())}else return Promise.all([r(),o(n.delay)])}function oQ(e,t,n=0,i=0,s=0,r=1,o){const c=[];for(const u of e.variantChildren)u.notify("AnimationStart",t),c.push(Z0(u,t,{...o,delay:n+(typeof i=="function"?0:i)+MD(e.variantChildren,u,i,s,r)}).then(()=>u.notify("AnimationComplete",t)));return Promise.all(c)}function lQ(e,t,n={}){e.notify("AnimationStart",t);let i;if(Array.isArray(t)){const s=t.map(r=>Z0(e,r,n));i=Promise.all(s)}else if(typeof t=="string")i=Z0(e,t,n);else{const s=typeof t=="function"?rl(e,t,n.custom):t;i=Promise.all(PD(e,s,n))}return i.then(()=>{e.notify("AnimationComplete",t)})}const cQ={test:e=>e==="auto",parse:e=>e},zD=e=>t=>t.test(e),BD=[iu,Ge,Er,Jr,LY,OY,cQ],K2=e=>BD.find(zD(e));function uQ(e){return typeof e=="number"?e===0:e!==null?e==="none"||e==="0"||XR(e):!0}const dQ=new Set(["brightness","contrast","saturate","opacity"]);function fQ(e){const[t,n]=e.slice(0,-1).split("(");if(t==="drop-shadow")return e;const[i]=n.match(I1)||[];if(!i)return e;const s=n.replace(i,"");let r=dQ.has(t)?1:0;return i!==n&&(r*=100),t+"("+r+s+")"}const hQ=/\b([a-z-]*)\(.*?\)/gu,J0={...er,getAnimatableNone:e=>{const t=e.match(hQ);return t?t.map(fQ).join(" "):e}},ev={...er,getAnimatableNone:e=>{const t=er.parse(e);return er.createTransformer(e)(t.map(i=>typeof i=="number"?0:typeof i=="object"?{...i,alpha:1}:i))}},G2={...iu,transform:Math.round},pQ={rotate:Jr,pathRotation:Jr,rotateX:Jr,rotateY:Jr,rotateZ:Jr,scale:tp,scaleX:tp,scaleY:tp,scaleZ:tp,skew:Jr,skewX:Jr,skewY:Jr,distance:Ge,translateX:Ge,translateY:Ge,translateZ:Ge,x:Ge,y:Ge,z:Ge,perspective:Ge,transformPerspective:Ge,opacity:Ud,originX:D2,originY:D2,originZ:Ge},dm={borderWidth:Ge,borderTopWidth:Ge,borderRightWidth:Ge,borderBottomWidth:Ge,borderLeftWidth:Ge,borderRadius:Ge,borderTopLeftRadius:Ge,borderTopRightRadius:Ge,borderBottomRightRadius:Ge,borderBottomLeftRadius:Ge,width:Ge,maxWidth:Ge,height:Ge,maxHeight:Ge,top:Ge,right:Ge,bottom:Ge,left:Ge,inset:Ge,insetBlock:Ge,insetBlockStart:Ge,insetBlockEnd:Ge,insetInline:Ge,insetInlineStart:Ge,insetInlineEnd:Ge,padding:Ge,paddingTop:Ge,paddingRight:Ge,paddingBottom:Ge,paddingLeft:Ge,paddingBlock:Ge,paddingBlockStart:Ge,paddingBlockEnd:Ge,paddingInline:Ge,paddingInlineStart:Ge,paddingInlineEnd:Ge,margin:Ge,marginTop:Ge,marginRight:Ge,marginBottom:Ge,marginLeft:Ge,marginBlock:Ge,marginBlockStart:Ge,marginBlockEnd:Ge,marginInline:Ge,marginInlineStart:Ge,marginInlineEnd:Ge,fontSize:Ge,backgroundPositionX:Ge,backgroundPositionY:Ge,...pQ,zIndex:G2,fillOpacity:Ud,strokeOpacity:Ud,numOctaves:G2},mQ={...dm,color:Kn,backgroundColor:Kn,outlineColor:Kn,fill:Kn,stroke:Kn,borderColor:Kn,borderTopColor:Kn,borderRightColor:Kn,borderBottomColor:Kn,borderLeftColor:Kn,filter:J0,WebkitFilter:J0,mask:ev,WebkitMask:ev},UD=e=>mQ[e],gQ=new Set([J0,ev]);function FD(e,t){let n=UD(e);return gQ.has(n)||(n=er),n.getAnimatableNone?n.getAnimatableNone(t):void 0}const yQ=new Set(["auto","none","0"]);function bQ(e,t,n){let i=0,s;for(;i<e.length&&!s;){const r=e[i];typeof r=="string"&&!yQ.has(r)&&$c(r).values.length&&(s=e[i]),i++}if(s&&n)for(const r of t)e[r]=FD(n,s)}class xQ extends F1{constructor(t,n,i,s,r){super(t,n,i,s,r,!0)}readKeyframes(){const{unresolvedKeyframes:t,element:n,name:i}=this;if(!n||!n.current)return;super.readKeyframes();for(let p=0;p<t.length;p++){let m=t[p];if(typeof m=="string"&&(m=m.trim(),L1(m))){const y=DD(m,n.current);y!==void 0&&(t[p]=y),p===t.length-1&&(this.finalKeyframe=m)}}if(this.resolveNoneKeyframes(),!OD.has(i)||t.length!==2)return;const[s,r]=t,o=K2(s),c=K2(r),u=R2(s),f=R2(r);if(u!==f&&to[i]){this.needsMeasurement=!0;return}if(o!==c)if(F2(o)&&F2(c))for(let p=0;p<t.length;p++){const m=t[p];typeof m=="string"&&(t[p]=parseFloat(m))}else to[i]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){const{unresolvedKeyframes:t,name:n}=this,i=[];for(let s=0;s<t.length;s++)(t[s]===null||uQ(t[s]))&&i.push(s);i.length&&bQ(t,i,n)}measureInitialState(){const{element:t,unresolvedKeyframes:n,name:i}=this;if(!t||!t.current)return;i==="height"&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=to[i](t.measureViewportBox(),window.getComputedStyle(t.current)),n[0]=this.measuredOrigin;const s=n[n.length-1];s!==void 0&&t.getValue(i,s).jump(s,!1)}measureEndState(){var c;const{element:t,name:n,unresolvedKeyframes:i}=this;if(!t||!t.current)return;const s=t.getValue(n);s&&s.jump(this.measuredOrigin,!1);const r=i.length-1,o=i[r];i[r]=to[n](t.measureViewportBox(),window.getComputedStyle(t.current)),o!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=o),(c=this.removedTransforms)!=null&&c.length&&this.removedTransforms.forEach(([u,f])=>{t.getValue(u).set(f)}),this.resolveNoneKeyframes()}}const K1=["borderTopLeftRadius","borderTopRightRadius","borderBottomRightRadius","borderBottomLeftRadius"];function G1(e,t,n){if(e==null)return[];if(e instanceof EventTarget)return[e];if(typeof e=="string"){const s=document.querySelectorAll(e);return s?Array.from(s):[]}return Array.from(e).filter(i=>i!=null)}const tv=(e,t)=>t&&typeof e=="number"?t.transform(e):e;function vQ(e){return YR(e)&&"offsetHeight"in e&&!("ownerSVGElement"in e)}const{schedule:W1}=cD(queueMicrotask,!1),Vs={x:!1,y:!1};function $D(){return Vs.x||Vs.y}function wQ(e){return e==="x"||e==="y"?Vs[e]?null:(Vs[e]=!0,()=>{Vs[e]=!1}):Vs.x||Vs.y?null:(Vs.x=Vs.y=!0,()=>{Vs.x=Vs.y=!1})}function qD(e,t){const n=G1(e),i=new AbortController,s={passive:!0,...t,signal:i.signal};return[n,s,()=>i.abort()]}function EQ(e){return!(e.pointerType==="touch"||$D())}function kQ(e,t,n={}){const[i,s,r]=qD(e,n);return i.forEach(o=>{let c=!1,u=!1,f;const p=()=>{o.removeEventListener("pointerleave",x)},m=w=>{f&&(f(w),f=void 0),p()},y=w=>{c=!1,window.removeEventListener("pointerup",y),window.removeEventListener("pointercancel",y),u&&(u=!1,m(w))},b=()=>{c=!0,window.addEventListener("pointerup",y,s),window.addEventListener("pointercancel",y,s)},x=w=>{if(w.pointerType!=="touch"){if(c){u=!0;return}m(w)}},v=w=>{if(!EQ(w))return;u=!1;const k=t(o,w);typeof k=="function"&&(f=k,o.addEventListener("pointerleave",x,s))};o.addEventListener("pointerenter",v,s),o.addEventListener("pointerdown",b,s)}),r}const HD=(e,t)=>t?e===t?!0:HD(e,t.parentElement):!1,Y1=e=>e.pointerType==="mouse"?typeof e.button!="number"||e.button<=0:e.isPrimary!==!1,SQ=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function NQ(e){return SQ.has(e.tagName)||e.isContentEditable===!0}const _Q=new Set(["INPUT","SELECT","TEXTAREA"]);function CQ(e){return _Q.has(e.tagName)||e.isContentEditable===!0}const Mp=new WeakSet;function W2(e){return t=>{t.key==="Enter"&&e(t)}}function dx(e,t){e.dispatchEvent(new PointerEvent("pointer"+t,{isPrimary:!0,bubbles:!0}))}const TQ=(e,t)=>{const n=e.currentTarget;if(!n)return;const i=W2(()=>{if(Mp.has(n))return;dx(n,"down");const s=W2(()=>{dx(n,"up")}),r=()=>dx(n,"cancel");n.addEventListener("keyup",s,t),n.addEventListener("blur",r,t)});n.addEventListener("keydown",i,t),n.addEventListener("blur",()=>n.removeEventListener("keydown",i),t)};function Y2(e){return Y1(e)&&!$D()}const X2=new WeakSet;function AQ(e,t,n={}){const[i,s,r]=qD(e,n),o=c=>{const u=c.currentTarget;if(!Y2(c)||X2.has(c))return;Mp.add(u),n.stopPropagation&&X2.add(c);const f=t(u,c),p={...s,capture:!0},m=(x,v)=>{window.removeEventListener("pointerup",y,p),window.removeEventListener("pointercancel",b,p),Mp.has(u)&&Mp.delete(u),Y2(x)&&typeof f=="function"&&f(x,{success:v})},y=x=>{m(x,u===window||u===document||n.useGlobalTarget||HD(u,x.target))},b=x=>{m(x,!1)};window.addEventListener("pointerup",y,p),window.addEventListener("pointercancel",b,p)};return i.forEach(c=>{(n.useGlobalTarget?window:c).addEventListener("pointerdown",o,s),vQ(c)&&(c.addEventListener("focus",f=>TQ(f,s)),!NQ(c)&&!c.hasAttribute("tabindex")&&(c.tabIndex=0))}),r}function X1(e){return YR(e)&&"ownerSVGElement"in e}const Rp=new WeakMap;let qa;const VD=(e,t,n)=>(i,s)=>s&&s[0]?s[0][e+"Size"]:X1(i)&&"getBBox"in i?i.getBBox()[t]:i[n],jQ=VD("inline","width","offsetWidth"),MQ=VD("block","height","offsetHeight");function RQ({target:e,borderBoxSize:t}){var n;(n=Rp.get(e))==null||n.forEach(i=>{i(e,{get width(){return jQ(e,t)},get height(){return MQ(e,t)}})})}function DQ(e){e.forEach(RQ)}function OQ(){typeof ResizeObserver>"u"||(qa=new ResizeObserver(DQ))}function LQ(e,t){qa||OQ();const n=G1(e);return n.forEach(i=>{let s=Rp.get(i);s||(s=new Set,Rp.set(i,s)),s.add(t),qa==null||qa.observe(i)}),()=>{n.forEach(i=>{const s=Rp.get(i);s==null||s.delete(t),s!=null&&s.size||qa==null||qa.unobserve(i)})}}const Dp=new Set;let fc;function IQ(){fc=()=>{const e={get width(){return window.innerWidth},get height(){return window.innerHeight}};Dp.forEach(t=>t(e))},window.addEventListener("resize",fc)}function PQ(e){return Dp.add(e),fc||IQ(),()=>{Dp.delete(e),!Dp.size&&typeof fc=="function"&&(window.removeEventListener("resize",fc),fc=void 0)}}function Q2(e,t){return typeof e=="function"?PQ(e):LQ(e,t)}function zQ(e){return X1(e)&&e.tagName==="svg"}const BQ=[...BD,Kn,er],UQ=e=>BQ.find(zD(e)),Z2=()=>({translate:0,scale:1,origin:0,originPoint:0}),hc=()=>({x:Z2(),y:Z2()}),J2=()=>({min:0,max:0}),Jn=()=>({x:J2(),y:J2()}),FQ=new WeakMap;function Hm(e){return e!==null&&typeof e=="object"&&typeof e.start=="function"}function Fd(e){return typeof e=="string"||Array.isArray(e)}const Q1=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],Z1=["initial",...Q1];function Vm(e){return Hm(e.animate)||Z1.some(t=>Fd(e[t]))}function KD(e){return!!(Vm(e)||e.variants)}function $Q(e,t,n){for(const i in t){const s=t[i],r=n[i];if(gi(s))e.addValue(i,s);else if(gi(r))e.addValue(i,qc(s,{owner:e}));else if(r!==s)if(e.hasValue(i)){const o=e.getValue(i);o.liveStyle===!0?o.jump(s):o.hasAnimated||o.set(s)}else{const o=e.getStaticValue(i);e.addValue(i,qc(o!==void 0?o:s,{owner:e}))}}for(const i in n)t[i]===void 0&&e.removeValue(i);return t}const nv={current:null},GD={current:!1},qQ=typeof window<"u";function HQ(){if(GD.current=!0,!!qQ)if(window.matchMedia){const e=window.matchMedia("(prefers-reduced-motion)"),t=()=>nv.current=e.matches;e.addEventListener("change",t),t()}else nv.current=!1}const eC=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];let fm={};function WD(e){fm=e}function VQ(){return fm}class KQ{scrapeMotionValuesFromProps(t,n,i){return{}}constructor({parent:t,props:n,presenceContext:i,reducedMotionConfig:s,skipAnimations:r,blockInitialAnimation:o,visualState:c},u={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.shouldSkipAnimations=!1,this.values=new Map,this.KeyframeResolver=F1,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.hasBeenMounted=!1,this.events={},this.propEventSubscriptions={},this.notifyUpdate=()=>this.notify("Update",this.latestValues),this.render=()=>{this.current&&(this.triggerBuild(),this.renderInstance(this.current,this.renderState,this.props.style,this.projection))},this.renderScheduledAt=0,this.scheduleRender=()=>{const b=Mi.now();this.renderScheduledAt<b&&(this.renderScheduledAt=b,un.render(this.render,!1,!0))};const{latestValues:f,renderState:p}=c;this.latestValues=f,this.baseTarget={...f},this.initialValues=n.initial?{...f}:{},this.renderState=p,this.parent=t,this.props=n,this.presenceContext=i,this.depth=t?t.depth+1:0,this.reducedMotionConfig=s,this.skipAnimationsConfig=r,this.options=u,this.blockInitialAnimation=!!o,this.isControllingVariants=Vm(n),this.isVariantNode=KD(n),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(t&&t.current);const{willChange:m,...y}=this.scrapeMotionValuesFromProps(n,{},this);for(const b in y){const x=y[b];f[b]!==void 0&&gi(x)&&x.set(f[b])}}mount(t){var n,i;if(this.hasBeenMounted)for(const s in this.initialValues)(n=this.values.get(s))==null||n.jump(this.initialValues[s]),this.latestValues[s]=this.initialValues[s];this.current=t,FQ.set(t,this),this.projection&&!this.projection.instance&&this.projection.mount(t),this.parent&&this.isVariantNode&&!this.isControllingVariants&&(this.removeFromVariantTree=this.parent.addVariantChild(this)),this.values.forEach((s,r)=>this.bindToMotionValue(r,s)),this.reducedMotionConfig==="never"?this.shouldReduceMotion=!1:this.reducedMotionConfig==="always"?this.shouldReduceMotion=!0:(GD.current||HQ(),this.shouldReduceMotion=nv.current),this.shouldSkipAnimations=this.skipAnimationsConfig??!1,(i=this.parent)==null||i.addChild(this),this.update(this.props,this.presenceContext),this.hasBeenMounted=!0}unmount(){var t;this.projection&&this.projection.unmount(),lo(this.notifyUpdate),lo(this.render),this.valueSubscriptions.forEach(n=>n()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),(t=this.parent)==null||t.removeChild(this);for(const n in this.events)this.events[n].clear();for(const n in this.features){const i=this.features[n];i&&(i.unmount(),i.isMounted=!1)}this.current=null}addChild(t){this.children.add(t),this.enteringChildren??(this.enteringChildren=new Set),this.enteringChildren.add(t)}removeChild(t){this.children.delete(t),this.enteringChildren&&this.enteringChildren.delete(t)}bindToMotionValue(t,n){if(this.valueSubscriptions.has(t)&&this.valueSubscriptions.get(t)(),n.accelerate&&jD.has(t)&&this.current instanceof HTMLElement){const{factory:o,keyframes:c,times:u,ease:f,duration:p}=n.accelerate,m=new TD({element:this.current,name:t,keyframes:c,times:u,ease:f,duration:os(p)}),y=o(m);this.valueSubscriptions.set(t,()=>{y(),m.cancel()});return}const i=ru.has(t);i&&this.onBindTransform&&this.onBindTransform();const s=n.on("change",o=>{this.latestValues[t]=o,this.props.onUpdate&&un.preRender(this.notifyUpdate),i&&this.projection&&(this.projection.isTransformDirty=!0),this.scheduleRender()});let r;typeof window<"u"&&window.MotionCheckAppearSync&&(r=window.MotionCheckAppearSync(this,t,n)),this.valueSubscriptions.set(t,()=>{s(),r&&r()})}sortNodePosition(t){return!this.current||!this.sortInstanceNodePosition||this.type!==t.type?0:this.sortInstanceNodePosition(this.current,t.current)}updateFeatures(){let t="animation";for(t in fm){const n=fm[t];if(!n)continue;const{isEnabled:i,Feature:s}=n;if(!this.features[t]&&s&&i(this.props)&&(this.features[t]=new s(this)),this.features[t]){const r=this.features[t];r.isMounted?r.update():(r.mount(),r.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):Jn()}getStaticValue(t){return this.latestValues[t]}setStaticValue(t,n){this.latestValues[t]=n}update(t,n){(t.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=t,this.prevPresenceContext=this.presenceContext,this.presenceContext=n;for(let i=0;i<eC.length;i++){const s=eC[i];this.propEventSubscriptions[s]&&(this.propEventSubscriptions[s](),delete this.propEventSubscriptions[s]);const r="on"+s,o=t[r];o&&(this.propEventSubscriptions[s]=this.on(s,o))}this.prevMotionValues=$Q(this,this.scrapeMotionValuesFromProps(t,this.prevProps||{},this),this.prevMotionValues),this.handleChildMotionValue&&this.handleChildMotionValue()}getProps(){return this.props}getVariant(t){return this.props.variants?this.props.variants[t]:void 0}getDefaultTransition(){return this.props.transition}getTransformPagePoint(){return this.props.transformPagePoint}getClosestVariantNode(){return this.isVariantNode?this:this.parent?this.parent.getClosestVariantNode():void 0}addVariantChild(t){const n=this.getClosestVariantNode();if(n)return n.variantChildren&&n.variantChildren.add(t),()=>n.variantChildren.delete(t)}addValue(t,n){const i=this.values.get(t);n!==i&&(i&&this.removeValue(t),this.bindToMotionValue(t,n),this.values.set(t,n),this.latestValues[t]=n.get())}removeValue(t){this.values.delete(t);const n=this.valueSubscriptions.get(t);n&&(n(),this.valueSubscriptions.delete(t)),delete this.latestValues[t],this.removeValueFromRenderState(t,this.renderState)}hasValue(t){return this.values.has(t)}getValue(t,n){if(this.props.values&&this.props.values[t])return this.props.values[t];let i=this.values.get(t);return i===void 0&&n!==void 0&&(i=qc(n===null?void 0:n,{owner:this}),this.addValue(t,i)),i}readValue(t,n){let i=this.latestValues[t]!==void 0||!this.current?this.latestValues[t]:this.getBaseTargetFromProps(this.props,t)??this.readValueFromInstance(this.current,t,this.options);return i!=null&&(typeof i=="string"&&(WR(i)||XR(i))?i=parseFloat(i):!UQ(i)&&er.test(n)&&(i=FD(t,n)),this.setBaseTarget(t,gi(i)?i.get():i)),gi(i)?i.get():i}setBaseTarget(t,n){this.baseTarget[t]=n}getBaseTarget(t){var r;const{initial:n}=this.props;let i;if(typeof n=="string"||typeof n=="object"){const o=H1(this.props,n,(r=this.presenceContext)==null?void 0:r.custom);o&&(i=o[t])}if(n&&i!==void 0)return i;const s=this.getBaseTargetFromProps(this.props,t);return s!==void 0&&!gi(s)?s:this.initialValues[t]!==void 0&&i===void 0?void 0:this.baseTarget[t]}on(t,n){return this.events[t]||(this.events[t]=new R1),this.events[t].add(n)}notify(t,...n){this.events[t]&&this.events[t].notify(...n)}scheduleRenderMicrotask(){W1.render(this.render)}}class YD extends KQ{constructor(){super(...arguments),this.KeyframeResolver=xQ}sortInstanceNodePosition(t,n){return t.compareDocumentPosition(n)&2?1:-1}getBaseTargetFromProps(t,n){const i=t.style;return i?i[n]:void 0}removeValueFromRenderState(t,{vars:n,style:i}){delete n[t],delete i[t]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);const{children:t}=this.props;gi(t)&&(this.childSubscription=t.on("change",n=>{this.current&&(this.current.textContent=`${n}`)}))}}class po{constructor(t){this.isMounted=!1,this.node=t}update(){}}function XD({top:e,left:t,right:n,bottom:i}){return{x:{min:t,max:n},y:{min:e,max:i}}}function GQ({x:e,y:t}){return{top:t.min,right:e.max,bottom:t.max,left:e.min}}function WQ(e,t){if(!t)return e;const n=t({x:e.left,y:e.top}),i=t({x:e.right,y:e.bottom});return{top:n.y,left:n.x,bottom:i.y,right:i.x}}function fx(e){return e===void 0||e===1}function iv({scale:e,scaleX:t,scaleY:n}){return!fx(e)||!fx(t)||!fx(n)}function Bo(e){return iv(e)||QD(e)||e.z||e.rotate||e.rotateX||e.rotateY||e.skewX||e.skewY}function QD(e){return tC(e.x)||tC(e.y)}function tC(e){return e&&e!=="0%"}function hm(e,t,n){const i=e-n,s=t*i;return n+s}function nC(e,t,n,i,s){return s!==void 0&&(e=hm(e,s,i)),hm(e,n,i)+t}function sv(e,t=0,n=1,i,s){e.min=nC(e.min,t,n,i,s),e.max=nC(e.max,t,n,i,s)}function ZD(e,{x:t,y:n}){sv(e.x,t.translate,t.scale,t.originPoint),sv(e.y,n.translate,n.scale,n.originPoint)}const iC=.999999999999,sC=1.0000000000001;function YQ(e,t,n,i=!1){var c;const s=n.length;if(!s)return;t.x=t.y=1;let r,o;for(let u=0;u<s;u++){r=n[u],o=r.projectionDelta;const{visualElement:f}=r.options;f&&f.props.style&&f.props.style.display==="contents"||(i&&r.options.layoutScroll&&r.scroll&&r!==r.root&&(vr(e.x,-r.scroll.offset.x),vr(e.y,-r.scroll.offset.y)),o&&(t.x*=o.x.scale,t.y*=o.y.scale,ZD(e,o)),i&&Bo(r.latestValues)&&Op(e,r.latestValues,(c=r.layout)==null?void 0:c.layoutBox))}t.x<sC&&t.x>iC&&(t.x=1),t.y<sC&&t.y>iC&&(t.y=1)}function vr(e,t){e.min+=t,e.max+=t}function rC(e,t,n,i,s=.5){const r=cn(e.min,e.max,s);sv(e,t,n,r,i)}function aC(e,t){return typeof e=="string"?parseFloat(e)/100*(t.max-t.min):e}function Op(e,t,n){const i=n??e;rC(e.x,aC(t.x,i.x),t.scaleX,t.scale,t.originX),rC(e.y,aC(t.y,i.y),t.scaleY,t.scale,t.originY)}function JD(e,t){return XD(WQ(e.getBoundingClientRect(),t))}function XQ(e,t,n){const i=JD(e,n),{scroll:s}=t;return s&&(vr(i.x,s.offset.x),vr(i.y,s.offset.y)),i}const QQ={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},ZQ=su.length;function JQ(e,t,n){let i="",s=!0;for(let o=0;o<ZQ;o++){const c=su[o],u=e[c];if(u===void 0)continue;let f=!0;if(typeof u=="number")f=u===(c.startsWith("scale")?1:0);else{const p=parseFloat(u);f=c.startsWith("scale")?p===1:p===0}if(!f||n){const p=tv(u,dm[c]);if(!f){s=!1;const m=QQ[c]||c;i+=`${m}(${p}) `}n&&(t[c]=p)}}const r=e.pathRotation;return r&&(s=!1,i+=`rotate(${tv(r,dm.pathRotation)}) `),i=i.trim(),n?i=n(t,s?"":i):s&&(i="none"),i}function J1(e,t,n){const{style:i,vars:s,transformOrigin:r}=e;let o=!1,c=!1;for(const u in t){const f=t[u];if(ru.has(u)){o=!0;continue}else if(dD(u)){s[u]=f;continue}else{const p=tv(f,dm[u]);u.startsWith("origin")?(c=!0,r[u]=p):i[u]=p}}if(t.transform||(o||n?i.transform=JQ(t,e.transform,n):i.transform&&(i.transform="none")),c){const{originX:u="50%",originY:f="50%",originZ:p=0}=r;i.transformOrigin=`${u} ${f} ${p}`}}function eO(e,{style:t,vars:n},i,s){const r=e.style;let o;for(o in t)r[o]=t[o];s==null||s.applyProjectionStyles(r,i);for(o in n)r.setProperty(o,n[o])}function oC(e,t){return t.max===t.min?0:e/(t.max-t.min)*100}const cd={correct:(e,t)=>{if(!t.target)return e;if(typeof e=="string")if(Ge.test(e))e=parseFloat(e);else return e;const n=oC(e,t.target.x),i=oC(e,t.target.y);return`${n}% ${i}%`}},eZ={correct:(e,{treeScale:t,projectionDelta:n})=>{const i=e,s=er.parse(e);if(s.length>5)return i;const r=er.createTransformer(e),o=typeof s[0]!="number"?1:0,c=n.x.scale*t.x,u=n.y.scale*t.y;s[0+o]/=c,s[1+o]/=u;const f=cn(c,u,.5);return typeof s[2+o]=="number"&&(s[2+o]/=f),typeof s[3+o]=="number"&&(s[3+o]/=f),r(s)}},rv={borderRadius:{...cd,applyTo:[...K1]},borderTopLeftRadius:cd,borderTopRightRadius:cd,borderBottomLeftRadius:cd,borderBottomRightRadius:cd,boxShadow:eZ};function tO(e,{layout:t,layoutId:n}){return ru.has(e)||e.startsWith("origin")||(t||n!==void 0)&&(!!rv[e]||e==="opacity")}function ew(e,t,n){var o;const i=e.style,s=t==null?void 0:t.style,r={};if(!i)return r;for(const c in i)(gi(i[c])||s&&gi(s[c])||tO(c,e)||((o=n==null?void 0:n.getValue(c))==null?void 0:o.liveStyle)!==void 0)&&(r[c]=i[c]);return r}function tZ(e){return window.getComputedStyle(e)}class nZ extends YD{constructor(){super(...arguments),this.type="html",this.renderInstance=eO}readValueFromInstance(t,n){var i;if(ru.has(n))return(i=this.projection)!=null&&i.isProjecting?H0(n):wX(t,n);{const s=tZ(t),r=(dD(n)?s.getPropertyValue(n):s[n])||0;return typeof r=="string"?r.trim():r}}measureInstanceViewportBox(t,{transformPagePoint:n}){return JD(t,n)}build(t,n,i){J1(t,n,i.transformTemplate)}scrapeMotionValuesFromProps(t,n,i){return ew(t,n,i)}}const iZ={offset:"stroke-dashoffset",array:"stroke-dasharray"},sZ={offset:"strokeDashoffset",array:"strokeDasharray"};function rZ(e,t,n=1,i=0,s=!0){e.pathLength=1;const r=s?iZ:sZ;e[r.offset]=`${-i}`,e[r.array]=`${t} ${n}`}const aZ=["offsetDistance","offsetPath","offsetRotate","offsetAnchor"];function nO(e,{attrX:t,attrY:n,attrScale:i,pathLength:s,pathSpacing:r=1,pathOffset:o=0,...c},u,f,p){if(J1(e,c,f),u){e.style.viewBox&&(e.attrs.viewBox=e.style.viewBox);return}e.attrs=e.style,e.style={};const{attrs:m,style:y}=e;m.transform&&(y.transform=m.transform,delete m.transform),(y.transform||m.transformOrigin)&&(y.transformOrigin=m.transformOrigin??"50% 50%",delete m.transformOrigin),y.transform&&(y.transformBox=(p==null?void 0:p.transformBox)??"fill-box",delete m.transformBox);for(const b of aZ)m[b]!==void 0&&(y[b]=m[b],delete m[b]);t!==void 0&&(m.x=t),n!==void 0&&(m.y=n),i!==void 0&&(m.scale=i),s!==void 0&&rZ(m,s,r,o,!1)}const iO=new Set(["baseFrequency","diffuseConstant","kernelMatrix","kernelUnitLength","keySplines","keyTimes","limitingConeAngle","markerHeight","markerWidth","numOctaves","targetX","targetY","surfaceScale","specularConstant","specularExponent","stdDeviation","tableValues","viewBox","gradientTransform","pathLength","startOffset","textLength","lengthAdjust"]),sO=e=>typeof e=="string"&&e.toLowerCase()==="svg";function oZ(e,t,n,i){eO(e,t,void 0,i);for(const s in t.attrs)e.setAttribute(iO.has(s)?s:V1(s),t.attrs[s])}function rO(e,t,n){const i=ew(e,t,n);for(const s in e)if(gi(e[s])||gi(t[s])){const r=su.indexOf(s)!==-1?"attr"+s.charAt(0).toUpperCase()+s.substring(1):s;i[r]=e[s]}return i}class lZ extends YD{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=Jn}getBaseTargetFromProps(t,n){return t[n]}readValueFromInstance(t,n){if(ru.has(n)){const i=UD(n);return i&&i.default||0}return n=iO.has(n)?n:V1(n),t.getAttribute(n)}scrapeMotionValuesFromProps(t,n,i){return rO(t,n,i)}build(t,n,i){nO(t,n,this.isSVGTag,i.transformTemplate,i.style)}renderInstance(t,n,i,s){oZ(t,n,i,s)}mount(t){this.isSVGTag=sO(t.tagName),super.mount(t)}}const cZ=Z1.length;function aO(e){if(!e)return;if(!e.isControllingVariants){const n=e.parent?aO(e.parent)||{}:{};return e.props.initial!==void 0&&(n.initial=e.props.initial),n}const t={};for(let n=0;n<cZ;n++){const i=Z1[n],s=e.props[i];(Fd(s)||s===!1)&&(t[i]=s)}return t}function oO(e,t){if(!Array.isArray(t))return!1;const n=t.length;if(n!==e.length)return!1;for(let i=0;i<n;i++)if(t[i]!==e[i])return!1;return!0}const uZ=[...Q1].reverse(),dZ=Q1.length;function fZ(e){return t=>Promise.all(t.map(({animation:n,options:i})=>lQ(e,n,i)))}function hZ(e){let t=fZ(e),n=lC(),i=!0,s=!1;const r=f=>(p,m)=>{var b;const y=rl(e,m,f==="exit"?(b=e.presenceContext)==null?void 0:b.custom:void 0);if(y){const{transition:x,transitionEnd:v,...w}=y;p={...p,...w,...v}}return p};function o(f){t=f(e)}function c(f){const{props:p}=e,m=aO(e.parent)||{},y=[],b=new Set;let x={},v=1/0;for(let k=0;k<dZ;k++){const C=uZ[k],S=n[C],T=p[C]!==void 0?p[C]:m[C],A=Fd(T),j=C===f?S.isActive:null;j===!1&&(v=k);let M=T===m[C]&&T!==p[C]&&A;if(M&&(i||s)&&e.manuallyAnimateOnMount&&(M=!1),S.protectedKeys={...x},!S.isActive&&j===null||!T&&!S.prevProp||Hm(T)||typeof T=="boolean")continue;if(C==="exit"&&S.isActive&&j!==!0){S.prevResolvedValues&&(x={...x,...S.prevResolvedValues});continue}const D=pZ(S.prevProp,T);let P=D||C===f&&S.isActive&&!M&&A||k>v&&A,I=!1;const B=Array.isArray(T)?T:[T];let q=B.reduce(r(C),{});j===!1&&(q={});const{prevResolvedValues:G={}}=S,R={...G,...q},O=X=>{P=!0,b.has(X)&&(I=!0,b.delete(X)),S.needsAnimating[X]=!0;const K=e.getValue(X);K&&(K.liveStyle=!1)};for(const X in R){const K=q[X],U=G[X];if(x.hasOwnProperty(X))continue;let F=!1;X0(K)&&X0(U)?F=!oO(K,U)||D:F=K!==U,F?K!=null?O(X):b.add(X):K!==void 0&&b.has(X)?O(X):S.protectedKeys[X]=!0}S.prevProp=T,S.prevResolvedValues=q,S.isActive&&(x={...x,...q}),(i||s)&&e.blockInitialAnimation&&(P=!1);const z=M&&D;P&&(!z||I)&&y.push(...B.map(X=>{const K={type:C};if(typeof X=="string"&&(i||s)&&!z&&e.manuallyAnimateOnMount&&e.parent){const{parent:U}=e,F=rl(U,X);if(U.enteringChildren&&F){const{delayChildren:Y}=F.transition||{};K.delay=MD(U.enteringChildren,e,Y)}}return{animation:X,options:K}}))}if(b.size){const k={};if(typeof p.initial!="boolean"){const C=rl(e,Array.isArray(p.initial)?p.initial[0]:p.initial);C&&C.transition&&(k.transition=C.transition)}b.forEach(C=>{const S=e.getBaseTarget(C),T=e.getValue(C);T&&(T.liveStyle=!0),k[C]=S??null}),y.push({animation:k})}let w=!!y.length;return i&&(p.initial===!1||p.initial===p.animate)&&!e.manuallyAnimateOnMount&&(w=!1),i=!1,s=!1,w?t(y):Promise.resolve()}function u(f,p){var y;if(n[f].isActive===p)return Promise.resolve();(y=e.variantChildren)==null||y.forEach(b=>{var x;return(x=b.animationState)==null?void 0:x.setActive(f,p)}),n[f].isActive=p;const m=c(f);for(const b in n)n[b].protectedKeys={};return m}return{animateChanges:c,setActive:u,setAnimateFunction:o,getState:()=>n,reset:()=>{n=lC(),s=!0}}}function pZ(e,t){return typeof t=="string"?t!==e:Array.isArray(t)?!oO(t,e):!1}function Oo(e=!1){return{isActive:e,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function lC(){return{animate:Oo(!0),whileInView:Oo(),whileHover:Oo(),whileTap:Oo(),whileDrag:Oo(),whileFocus:Oo(),exit:Oo()}}function av(e,t){e.min=t.min,e.max=t.max}function qs(e,t){av(e.x,t.x),av(e.y,t.y)}function cC(e,t){e.translate=t.translate,e.scale=t.scale,e.originPoint=t.originPoint,e.origin=t.origin}const lO=1e-4,mZ=1-lO,gZ=1+lO,cO=.01,yZ=0-cO,bZ=0+cO;function Ri(e){return e.max-e.min}function xZ(e,t,n){return Math.abs(e-t)<=n}function uC(e,t,n,i=.5){e.origin=i,e.originPoint=cn(t.min,t.max,e.origin),e.scale=Ri(n)/Ri(t),e.translate=cn(n.min,n.max,e.origin)-e.originPoint,(e.scale>=mZ&&e.scale<=gZ||isNaN(e.scale))&&(e.scale=1),(e.translate>=yZ&&e.translate<=bZ||isNaN(e.translate))&&(e.translate=0)}function Td(e,t,n,i){uC(e.x,t.x,n.x,i?i.originX:void 0),uC(e.y,t.y,n.y,i?i.originY:void 0)}function dC(e,t,n,i=0){const s=i?cn(n.min,n.max,i):n.min;e.min=s+t.min,e.max=e.min+Ri(t)}function vZ(e,t,n,i){dC(e.x,t.x,n.x,i==null?void 0:i.x),dC(e.y,t.y,n.y,i==null?void 0:i.y)}function fC(e,t,n,i=0){const s=i?cn(n.min,n.max,i):n.min;e.min=t.min-s,e.max=e.min+Ri(t)}function pm(e,t,n,i){fC(e.x,t.x,n.x,i==null?void 0:i.x),fC(e.y,t.y,n.y,i==null?void 0:i.y)}function hC(e,t,n,i,s){return e-=t,e=hm(e,1/n,i),s!==void 0&&(e=hm(e,1/s,i)),e}function wZ(e,t=0,n=1,i=.5,s,r=e,o=e){if(Er.test(t)&&(t=parseFloat(t),t=cn(o.min,o.max,t/100)-o.min),typeof t!="number")return;let c=cn(r.min,r.max,i);e===r&&(c-=t),e.min=hC(e.min,t,n,c,s),e.max=hC(e.max,t,n,c,s)}function pC(e,t,[n,i,s],r,o){wZ(e,t[n],t[i],t[s],t.scale,r,o)}const EZ=["x","scaleX","originX"],kZ=["y","scaleY","originY"];function mC(e,t,n,i){pC(e.x,t,EZ,n?n.x:void 0,i?i.x:void 0),pC(e.y,t,kZ,n?n.y:void 0,i?i.y:void 0)}function gC(e){return e.translate===0&&e.scale===1}function uO(e){return gC(e.x)&&gC(e.y)}function yC(e,t){return e.min===t.min&&e.max===t.max}function SZ(e,t){return yC(e.x,t.x)&&yC(e.y,t.y)}function bC(e,t){return Math.round(e.min)===Math.round(t.min)&&Math.round(e.max)===Math.round(t.max)}function dO(e,t){return bC(e.x,t.x)&&bC(e.y,t.y)}function xC(e){return Ri(e.x)/Ri(e.y)}function vC(e,t){return e.translate===t.translate&&e.scale===t.scale&&e.originPoint===t.originPoint}function gr(e){return[e("x"),e("y")]}function NZ(e,t,n){let i="";const s=e.x.translate/t.x,r=e.y.translate/t.y,o=(n==null?void 0:n.z)||0;if((s||r||o)&&(i=`translate3d(${s}px, ${r}px, ${o}px) `),(t.x!==1||t.y!==1)&&(i+=`scale(${1/t.x}, ${1/t.y}) `),n){const{transformPerspective:f,rotate:p,pathRotation:m,rotateX:y,rotateY:b,skewX:x,skewY:v}=n;f&&(i=`perspective(${f}px) ${i}`),p&&(i+=`rotate(${p}deg) `),m&&(i+=`rotate(${m}deg) `),y&&(i+=`rotateX(${y}deg) `),b&&(i+=`rotateY(${b}deg) `),x&&(i+=`skewX(${x}deg) `),v&&(i+=`skewY(${v}deg) `)}const c=e.x.scale*t.x,u=e.y.scale*t.y;return(c!==1||u!==1)&&(i+=`scale(${c}, ${u})`),i||"none"}const _Z=K1.length,wC=e=>typeof e=="string"?parseFloat(e):e,EC=e=>typeof e=="number"||Ge.test(e);function CZ(e,t,n,i,s,r){s?(e.opacity=cn(0,n.opacity??1,TZ(i)),e.opacityExit=cn(t.opacity??1,0,AZ(i))):r&&(e.opacity=cn(t.opacity??1,n.opacity??1,i));for(let o=0;o<_Z;o++){const c=K1[o];let u=kC(t,c),f=kC(n,c);if(u===void 0&&f===void 0)continue;u||(u=0),f||(f=0),u===0||f===0||EC(u)===EC(f)?(e[c]=Math.max(cn(wC(u),wC(f),i),0),(Er.test(f)||Er.test(u))&&(e[c]+="%")):e[c]=f}(t.rotate||n.rotate)&&(e.rotate=cn(t.rotate||0,n.rotate||0,i))}function kC(e,t){return e[t]!==void 0?e[t]:e.borderRadius}const TZ=fO(0,.5,rD),AZ=fO(.5,.95,Cs);function fO(e,t,n){return i=>i<e?0:i>t?1:n(Bd(e,t,i))}function jZ(e,t,n){const i=gi(e)?e:qc(e);return i.start(q1("",i,t,n)),i.animation}function $d(e,t,n,i={passive:!0}){return e.addEventListener(t,n,i),()=>e.removeEventListener(t,n,i)}const MZ=(e,t)=>e.depth-t.depth;class RZ{constructor(){this.children=[],this.isDirty=!1}add(t){j1(this.children,t),this.isDirty=!0}remove(t){am(this.children,t),this.isDirty=!0}forEach(t){this.isDirty&&this.children.sort(MZ),this.isDirty=!1,this.children.forEach(t)}}function DZ(e,t){const n=Mi.now(),i=({timestamp:s})=>{const r=s-n;r>=t&&(lo(i),e(r-t))};return un.setup(i,!0),()=>lo(i)}function Lp(e){return gi(e)?e.get():e}class OZ{constructor(){this.members=[]}add(t){j1(this.members,t);for(let n=this.members.length-1;n>=0;n--){const i=this.members[n];if(i===t||i===this.lead||i===this.prevLead)continue;const s=i.instance;(!s||s.isConnected===!1)&&!i.snapshot&&(am(this.members,i),i.unmount())}t.scheduleRender()}remove(t){if(am(this.members,t),t===this.prevLead&&(this.prevLead=void 0),t===this.lead){const n=this.members[this.members.length-1];n&&this.promote(n)}}relegate(t){var n;for(let i=this.members.indexOf(t)-1;i>=0;i--){const s=this.members[i];if(s.isPresent!==!1&&((n=s.instance)==null?void 0:n.isConnected)!==!1)return this.promote(s),!0}return!1}promote(t,n){var s;const i=this.lead;if(t!==i&&(this.prevLead=i,this.lead=t,t.show(),i)){i.updateSnapshot(),t.scheduleRender();const{layoutDependency:r}=i.options,{layoutDependency:o}=t.options;(r===void 0||r!==o)&&(t.resumeFrom=i,n&&(i.preserveOpacity=!0),i.snapshot&&(t.snapshot=i.snapshot,t.snapshot.latestValues=i.animationValues||i.latestValues),(s=t.root)!=null&&s.isUpdating&&(t.isLayoutDirty=!0)),t.options.crossfade===!1&&i.hide()}}exitAnimationComplete(){this.members.forEach(t=>{var n,i,s,r,o;(i=(n=t.options).onExitComplete)==null||i.call(n),(o=(s=t.resumingFrom)==null?void 0:(r=s.options).onExitComplete)==null||o.call(r)})}scheduleRender(){this.members.forEach(t=>t.instance&&t.scheduleRender(!1))}removeLeadSnapshot(){var t;(t=this.lead)!=null&&t.snapshot&&(this.lead.snapshot=void 0)}}const Ip={hasAnimatedSinceResize:!0,hasEverUpdated:!1},hx=["","X","Y","Z"],LZ=1e3;let IZ=0;function px(e,t,n,i){const{latestValues:s}=t;s[e]&&(n[e]=s[e],t.setStaticValue(e,0),i&&(i[e]=0))}function hO(e){if(e.hasCheckedOptimisedAppear=!0,e.root===e)return;const{visualElement:t}=e.options;if(!t)return;const n=ID(t);if(window.MotionHasOptimisedAnimation(n,"transform")){const{layout:s,layoutId:r}=e.options;window.MotionCancelOptimisedAnimation(n,"transform",un,!(s||r))}const{parent:i}=e;i&&!i.hasCheckedOptimisedAppear&&hO(i)}function pO({attachResizeListener:e,defaultParent:t,measureScroll:n,checkIsScrollRoot:i,resetTransform:s}){return class{constructor(o={},c=t==null?void 0:t()){this.id=IZ++,this.animationId=0,this.animationCommitId=0,this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.isProjectionDirty=!1,this.isSharedProjectionDirty=!1,this.isTransformDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.hasCheckedOptimisedAppear=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.hasTreeAnimated=!1,this.layoutVersion=0,this.updateScheduled=!1,this.scheduleUpdate=()=>this.update(),this.projectionUpdateScheduled=!1,this.checkUpdateFailed=()=>{this.isUpdating&&(this.isUpdating=!1,this.clearAllSnapshots())},this.updateProjection=()=>{this.projectionUpdateScheduled=!1,this.nodes.forEach(BZ),this.nodes.forEach(VZ),this.nodes.forEach(KZ),this.nodes.forEach(UZ)},this.resolvedRelativeTargetAt=0,this.linkedParentVersion=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=o,this.root=c?c.root||c:this,this.path=c?[...c.path,c]:[],this.parent=c,this.depth=c?c.depth+1:0;for(let u=0;u<this.path.length;u++)this.path[u].shouldResetTransform=!0;this.root===this&&(this.nodes=new RZ)}addEventListener(o,c){return this.eventHandlers.has(o)||this.eventHandlers.set(o,new R1),this.eventHandlers.get(o).add(c)}notifyListeners(o,...c){const u=this.eventHandlers.get(o);u&&u.notify(...c)}hasListeners(o){return this.eventHandlers.has(o)}mount(o){if(this.instance)return;this.isSVG=X1(o)&&!zQ(o),this.instance=o;const{layoutId:c,layout:u,visualElement:f}=this.options;if(f&&!f.current&&f.mount(o),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),this.root.hasTreeAnimated&&(u||c)&&(this.isLayoutDirty=!0),e){let p,m=0;const y=()=>this.root.updateBlockedByResize=!1;un.read(()=>{m=window.innerWidth}),e(o,()=>{const b=window.innerWidth;b!==m&&(m=b,this.root.updateBlockedByResize=!0,p&&p(),p=DZ(y,250),Ip.hasAnimatedSinceResize&&(Ip.hasAnimatedSinceResize=!1,this.nodes.forEach(_C)))})}c&&this.root.registerSharedNode(c,this),this.options.animate!==!1&&f&&(c||u)&&this.addEventListener("didUpdate",({delta:p,hasLayoutChanged:m,hasRelativeLayoutChanged:y,layout:b})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const x=this.options.transition||f.getDefaultTransition()||QZ,{onLayoutAnimationStart:v,onLayoutAnimationComplete:w}=f.getProps(),k=!this.targetLayout||!dO(this.targetLayout,b),C=!m&&y;if(this.options.layoutRoot||this.resumeFrom||C||m&&(k||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);const S={...$1(x,"layout"),onPlay:v,onComplete:w};(f.shouldReduceMotion||this.options.layoutRoot)&&(S.delay=0,S.type=!1),this.startAnimation(S),this.setAnimationOrigin(p,C,S.path)}else m||_C(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=b})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);const o=this.getStack();o&&o.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),lo(this.updateProjection)}blockUpdate(){this.updateManuallyBlocked=!0}unblockUpdate(){this.updateManuallyBlocked=!1}isUpdateBlocked(){return this.updateManuallyBlocked||this.updateBlockedByResize}isTreeAnimationBlocked(){return this.isAnimationBlocked||this.parent&&this.parent.isTreeAnimationBlocked()||!1}startUpdate(){this.isUpdateBlocked()||(this.isUpdating=!0,this.nodes&&this.nodes.forEach(GZ),this.animationId++)}getTransformTemplate(){const{visualElement:o}=this.options;return o&&o.getProps().transformTemplate}willUpdate(o=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&hO(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let p=0;p<this.path.length;p++){const m=this.path[p];m.shouldResetTransform=!0,(typeof m.latestValues.x=="string"||typeof m.latestValues.y=="string")&&(m.isLayoutDirty=!0),m.updateScroll("snapshot"),m.options.layoutRoot&&m.willUpdate(!1)}const{layoutId:c,layout:u}=this.options;if(c===void 0&&!u)return;const f=this.getTransformTemplate();this.prevTransformTemplateValue=f?f(this.latestValues,""):void 0,this.updateSnapshot(),o&&this.notifyListeners("willUpdate")}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){const u=this.updateBlockedByResize;this.unblockUpdate(),this.updateBlockedByResize=!1,this.clearAllSnapshots(),u&&this.nodes.forEach($Z),this.nodes.forEach(SC);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(NC);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(qZ),this.nodes.forEach(HZ),this.nodes.forEach(PZ),this.nodes.forEach(zZ)):this.nodes.forEach(NC),this.clearAllSnapshots();const c=Mi.now();mi.delta=Nr(0,1e3/60,c-mi.timestamp),mi.timestamp=c,mi.isProcessing=!0,rx.update.process(mi),rx.preRender.process(mi),rx.render.process(mi),mi.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,W1.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(FZ),this.sharedNodes.forEach(WZ)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,un.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){un.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!Ri(this.snapshot.measuredBox.x)&&!Ri(this.snapshot.measuredBox.y)&&(this.snapshot=void 0))}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let u=0;u<this.path.length;u++)this.path[u].updateScroll();const o=this.layout;this.layout=this.measure(!1),this.layoutVersion++,this.layoutCorrected||(this.layoutCorrected=Jn()),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners("measure",this.layout.layoutBox);const{visualElement:c}=this.options;c&&c.notify("LayoutMeasure",this.layout.layoutBox,o?o.layoutBox:void 0)}updateScroll(o="measure"){let c=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===o&&(c=!1),c&&this.instance){const u=i(this.instance);this.scroll={animationId:this.root.animationId,phase:o,isRoot:u,offset:n(this.instance),wasRoot:this.scroll?this.scroll.isRoot:u}}}resetTransform(){if(!s)return;const o=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,c=this.projectionDelta&&!uO(this.projectionDelta),u=this.getTransformTemplate(),f=u?u(this.latestValues,""):void 0,p=f!==this.prevTransformTemplateValue;o&&this.instance&&(c||Bo(this.latestValues)||p)&&(s(this.instance,f),this.shouldResetTransform=!1,this.scheduleRender())}measure(o=!0){const c=this.measurePageBox();let u=this.removeElementScroll(c);return o&&(u=this.removeTransform(u)),ZZ(u),{animationId:this.root.animationId,measuredBox:c,layoutBox:u,latestValues:{},source:this.id}}measurePageBox(){var f;const{visualElement:o}=this.options;if(!o)return Jn();const c=o.measureViewportBox();if(!(((f=this.scroll)==null?void 0:f.wasRoot)||this.path.some(JZ))){const{scroll:p}=this.root;p&&(vr(c.x,p.offset.x),vr(c.y,p.offset.y))}return c}removeElementScroll(o){var u;const c=Jn();if(qs(c,o),(u=this.scroll)!=null&&u.wasRoot)return c;for(let f=0;f<this.path.length;f++){const p=this.path[f],{scroll:m,options:y}=p;p!==this.root&&m&&y.layoutScroll&&(m.wasRoot&&qs(c,o),vr(c.x,m.offset.x),vr(c.y,m.offset.y))}return c}applyTransform(o,c=!1,u){var p,m;const f=u||Jn();qs(f,o);for(let y=0;y<this.path.length;y++){const b=this.path[y];!c&&b.options.layoutScroll&&b.scroll&&b!==b.root&&(vr(f.x,-b.scroll.offset.x),vr(f.y,-b.scroll.offset.y)),Bo(b.latestValues)&&Op(f,b.latestValues,(p=b.layout)==null?void 0:p.layoutBox)}return Bo(this.latestValues)&&Op(f,this.latestValues,(m=this.layout)==null?void 0:m.layoutBox),f}removeTransform(o){var u;const c=Jn();qs(c,o);for(let f=0;f<this.path.length;f++){const p=this.path[f];if(!Bo(p.latestValues))continue;let m;p.instance&&(iv(p.latestValues)&&p.updateSnapshot(),m=Jn(),qs(m,p.measurePageBox())),mC(c,p.latestValues,(u=p.snapshot)==null?void 0:u.layoutBox,m)}return Bo(this.latestValues)&&mC(c,this.latestValues),c}setTargetDelta(o){this.targetDelta=o,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(o){this.options={...this.options,...o,crossfade:o.crossfade!==void 0?o.crossfade:!0}}clearMeasurements(){this.scroll=void 0,this.layout=void 0,this.snapshot=void 0,this.prevTransformTemplateValue=void 0,this.targetDelta=void 0,this.target=void 0,this.isLayoutDirty=!1}forceRelativeParentToResolveTarget(){this.relativeParent&&this.relativeParent.resolvedRelativeTargetAt!==mi.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(o=!1){var b;const c=this.getLead();this.isProjectionDirty||(this.isProjectionDirty=c.isProjectionDirty),this.isTransformDirty||(this.isTransformDirty=c.isTransformDirty),this.isSharedProjectionDirty||(this.isSharedProjectionDirty=c.isSharedProjectionDirty);const u=!!this.resumingFrom||this!==c;if(!(o||u&&this.isSharedProjectionDirty||this.isProjectionDirty||(b=this.parent)!=null&&b.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;const{layout:p,layoutId:m}=this.options;if(!this.layout||!(p||m))return;this.resolvedRelativeTargetAt=mi.timestamp;const y=this.getClosestProjectingParent();y&&this.linkedParentVersion!==y.layoutVersion&&!y.options.layoutRoot&&this.removeRelativeTarget(),!this.targetDelta&&!this.relativeTarget&&(this.options.layoutAnchor!==!1&&y&&y.layout?this.createRelativeTarget(y,this.layout.layoutBox,y.layout.layoutBox):this.removeRelativeTarget()),!(!this.relativeTarget&&!this.targetDelta)&&(this.target||(this.target=Jn(),this.targetWithTransforms=Jn()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),vZ(this.target,this.relativeTarget,this.relativeParent.target,this.options.layoutAnchor||void 0)):this.targetDelta?(this.resumingFrom?this.applyTransform(this.layout.layoutBox,!1,this.target):qs(this.target,this.layout.layoutBox),ZD(this.target,this.targetDelta)):qs(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget&&(this.attemptToResolveRelativeTarget=!1,this.options.layoutAnchor!==!1&&y&&!!y.resumingFrom==!!this.resumingFrom&&!y.options.layoutScroll&&y.target&&this.animationProgress!==1?this.createRelativeTarget(y,this.target,y.target):this.relativeParent=this.relativeTarget=void 0))}getClosestProjectingParent(){if(!(!this.parent||iv(this.parent.latestValues)||QD(this.parent.latestValues)))return this.parent.isProjecting()?this.parent:this.parent.getClosestProjectingParent()}isProjecting(){return!!((this.relativeTarget||this.targetDelta||this.options.layoutRoot)&&this.layout)}createRelativeTarget(o,c,u){this.relativeParent=o,this.linkedParentVersion=o.layoutVersion,this.forceRelativeParentToResolveTarget(),this.relativeTarget=Jn(),this.relativeTargetOrigin=Jn(),pm(this.relativeTargetOrigin,c,u,this.options.layoutAnchor||void 0),qs(this.relativeTarget,this.relativeTargetOrigin)}removeRelativeTarget(){this.relativeParent=this.relativeTarget=void 0}calcProjection(){var x;const o=this.getLead(),c=!!this.resumingFrom||this!==o;let u=!0;if((this.isProjectionDirty||(x=this.parent)!=null&&x.isProjectionDirty)&&(u=!1),c&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(u=!1),this.resolvedRelativeTargetAt===mi.timestamp&&(u=!1),u)return;const{layout:f,layoutId:p}=this.options;if(this.isTreeAnimating=!!(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!(f||p))return;qs(this.layoutCorrected,this.layout.layoutBox);const m=this.treeScale.x,y=this.treeScale.y;YQ(this.layoutCorrected,this.treeScale,this.path,c),o.layout&&!o.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(o.target=o.layout.layoutBox,o.targetWithTransforms=Jn());const{target:b}=o;if(!b){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(cC(this.prevProjectionDelta.x,this.projectionDelta.x),cC(this.prevProjectionDelta.y,this.projectionDelta.y)),Td(this.projectionDelta,this.layoutCorrected,b,this.latestValues),(this.treeScale.x!==m||this.treeScale.y!==y||!vC(this.projectionDelta.x,this.prevProjectionDelta.x)||!vC(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners("projectionUpdate",b))}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(o=!0){var c;if((c=this.options.visualElement)==null||c.scheduleRender(),o){const u=this.getStack();u&&u.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=hc(),this.projectionDelta=hc(),this.projectionDeltaWithTransform=hc()}setAnimationOrigin(o,c=!1,u){const f=this.snapshot,p=f?f.latestValues:{},m={...this.latestValues},y=hc();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!c;const b=Jn(),x=f?f.source:void 0,v=this.layout?this.layout.source:void 0,w=x!==v,k=this.getStack(),C=!k||k.members.length<=1,S=!!(w&&!C&&this.options.crossfade===!0&&!this.path.some(XZ));this.animationProgress=0;let T;const A=u==null?void 0:u.interpolateProjection(o);this.mixTargetDelta=j=>{const M=j/1e3,D=A==null?void 0:A(M);D?(y.x.translate=D.x,y.x.scale=cn(o.x.scale,1,M),y.x.origin=o.x.origin,y.x.originPoint=o.x.originPoint,y.y.translate=D.y,y.y.scale=cn(o.y.scale,1,M),y.y.origin=o.y.origin,y.y.originPoint=o.y.originPoint):(CC(y.x,o.x,M),CC(y.y,o.y,M)),this.setTargetDelta(y),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(pm(b,this.layout.layoutBox,this.relativeParent.layout.layoutBox,this.options.layoutAnchor||void 0),YZ(this.relativeTarget,this.relativeTargetOrigin,b,M),T&&SZ(this.relativeTarget,T)&&(this.isProjectionDirty=!1),T||(T=Jn()),qs(T,this.relativeTarget)),w&&(this.animationValues=m,CZ(m,p,this.latestValues,M,S,C)),D&&D.rotate!==void 0&&(this.animationValues||(this.animationValues=m),this.animationValues.pathRotation=D.rotate),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=M},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(o){var c,u,f;this.notifyListeners("animationStart"),(c=this.currentAnimation)==null||c.stop(),(f=(u=this.resumingFrom)==null?void 0:u.currentAnimation)==null||f.stop(),this.pendingAnimation&&(lo(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=un.update(()=>{Ip.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=qc(0)),this.motionValue.jump(0,!1),this.currentAnimation=jZ(this.motionValue,[0,1e3],{...o,velocity:0,isSync:!0,onUpdate:p=>{this.mixTargetDelta(p),o.onUpdate&&o.onUpdate(p)},onComplete:()=>{o.onComplete&&o.onComplete(),this.completeAnimation()}}),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0})}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0);const o=this.getStack();o&&o.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(LZ),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const o=this.getLead();let{targetWithTransforms:c,target:u,layout:f,latestValues:p}=o;if(!(!c||!u||!f)){if(this!==o&&this.layout&&f&&mO(this.options.animationType,this.layout.layoutBox,f.layoutBox)){u=this.target||Jn();const m=Ri(this.layout.layoutBox.x);u.x.min=o.target.x.min,u.x.max=u.x.min+m;const y=Ri(this.layout.layoutBox.y);u.y.min=o.target.y.min,u.y.max=u.y.min+y}qs(c,u),Op(c,p),Td(this.projectionDeltaWithTransform,this.layoutCorrected,c,p)}}registerSharedNode(o,c){this.sharedNodes.has(o)||this.sharedNodes.set(o,new OZ),this.sharedNodes.get(o).add(c);const f=c.options.initialPromotionConfig;c.promote({transition:f?f.transition:void 0,preserveFollowOpacity:f&&f.shouldPreserveFollowOpacity?f.shouldPreserveFollowOpacity(c):void 0})}isLead(){const o=this.getStack();return o?o.lead===this:!0}getLead(){var c;const{layoutId:o}=this.options;return o?((c=this.getStack())==null?void 0:c.lead)||this:this}getPrevLead(){var c;const{layoutId:o}=this.options;return o?(c=this.getStack())==null?void 0:c.prevLead:void 0}getStack(){const{layoutId:o}=this.options;if(o)return this.root.sharedNodes.get(o)}promote({needsReset:o,transition:c,preserveFollowOpacity:u}={}){const f=this.getStack();f&&f.promote(this,u),o&&(this.projectionDelta=void 0,this.needsReset=!0),c&&this.setOptions({transition:c})}relegate(){const o=this.getStack();return o?o.relegate(this):!1}resetSkewAndRotation(){const{visualElement:o}=this.options;if(!o)return;let c=!1;const{latestValues:u}=o;if((u.z||u.rotate||u.rotateX||u.rotateY||u.rotateZ||u.skewX||u.skewY)&&(c=!0),!c)return;const f={};u.z&&px("z",o,f,this.animationValues);for(let p=0;p<hx.length;p++)px(`rotate${hx[p]}`,o,f,this.animationValues),px(`skew${hx[p]}`,o,f,this.animationValues);o.render();for(const p in f)o.setStaticValue(p,f[p]),this.animationValues&&(this.animationValues[p]=f[p]);o.scheduleRender()}applyProjectionStyles(o,c){if(!this.instance||this.isSVG)return;if(!this.isVisible){o.visibility="hidden";return}const u=this.getTransformTemplate();if(this.needsReset){this.needsReset=!1,o.visibility="",o.opacity="",o.pointerEvents=Lp(c==null?void 0:c.pointerEvents)||"",o.transform=u?u(this.latestValues,""):"none";return}const f=this.getLead();if(!this.projectionDelta||!this.layout||!f.target){this.options.layoutId&&(o.opacity=this.latestValues.opacity!==void 0?this.latestValues.opacity:1,o.pointerEvents=Lp(c==null?void 0:c.pointerEvents)||""),this.hasProjected&&!Bo(this.latestValues)&&(o.transform=u?u({},""):"none",this.hasProjected=!1);return}o.visibility="";const p=f.animationValues||f.latestValues;this.applyTransformsToTarget();let m=NZ(this.projectionDeltaWithTransform,this.treeScale,p);u&&(m=u(p,m)),o.transform=m;const{x:y,y:b}=this.projectionDelta;o.transformOrigin=`${y.origin*100}% ${b.origin*100}% 0`,f.animationValues?o.opacity=f===this?p.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:p.opacityExit:o.opacity=f===this?p.opacity!==void 0?p.opacity:"":p.opacityExit!==void 0?p.opacityExit:0;for(const x in rv){if(p[x]===void 0)continue;const{correct:v,applyTo:w,isCSSVariable:k}=rv[x],C=m==="none"?p[x]:v(p[x],f);if(w){const S=w.length;for(let T=0;T<S;T++)o[w[T]]=C}else k?this.options.visualElement.renderState.vars[x]=C:o[x]=C}this.options.layoutId&&(o.pointerEvents=f===this?Lp(c==null?void 0:c.pointerEvents)||"":"none")}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(o=>{var c;return(c=o.currentAnimation)==null?void 0:c.stop()}),this.root.nodes.forEach(SC),this.root.sharedNodes.clear()}}}function PZ(e){e.updateLayout()}function zZ(e){var n;const t=((n=e.resumeFrom)==null?void 0:n.snapshot)||e.snapshot;if(e.isLead()&&e.layout&&t&&e.hasListeners("didUpdate")){const{layoutBox:i,measuredBox:s}=e.layout,{animationType:r}=e.options,o=t.source!==e.layout.source;if(r==="size")gr(m=>{const y=o?t.measuredBox[m]:t.layoutBox[m],b=Ri(y);y.min=i[m].min,y.max=y.min+b});else if(r==="x"||r==="y"){const m=r==="x"?"y":"x";av(o?t.measuredBox[m]:t.layoutBox[m],i[m])}else mO(r,t.layoutBox,i)&&gr(m=>{const y=o?t.measuredBox[m]:t.layoutBox[m],b=Ri(i[m]);y.max=y.min+b,e.relativeTarget&&!e.currentAnimation&&(e.isProjectionDirty=!0,e.relativeTarget[m].max=e.relativeTarget[m].min+b)});const c=hc();Td(c,i,t.layoutBox);const u=hc();o?Td(u,e.applyTransform(s,!0),t.measuredBox):Td(u,i,t.layoutBox);const f=!uO(c);let p=!1;if(!e.resumeFrom){const m=e.getClosestProjectingParent();if(m&&!m.resumeFrom){const{snapshot:y,layout:b}=m;if(y&&b){const x=e.options.layoutAnchor||void 0,v=Jn();pm(v,t.layoutBox,y.layoutBox,x);const w=Jn();pm(w,i,b.layoutBox,x),dO(v,w)||(p=!0),m.options.layoutRoot&&(e.relativeTarget=w,e.relativeTargetOrigin=v,e.relativeParent=m)}}}e.notifyListeners("didUpdate",{layout:i,snapshot:t,delta:u,layoutDelta:c,hasLayoutChanged:f,hasRelativeLayoutChanged:p})}else if(e.isLead()){const{onExitComplete:i}=e.options;i&&i()}e.options.transition=void 0}function BZ(e){e.parent&&(e.isProjecting()||(e.isProjectionDirty=e.parent.isProjectionDirty),e.isSharedProjectionDirty||(e.isSharedProjectionDirty=!!(e.isProjectionDirty||e.parent.isProjectionDirty||e.parent.isSharedProjectionDirty)),e.isTransformDirty||(e.isTransformDirty=e.parent.isTransformDirty))}function UZ(e){e.isProjectionDirty=e.isSharedProjectionDirty=e.isTransformDirty=!1}function FZ(e){e.clearSnapshot()}function SC(e){e.clearMeasurements()}function $Z(e){e.isLayoutDirty=!0,e.updateLayout()}function NC(e){e.isLayoutDirty=!1}function qZ(e){e.isAnimationBlocked&&e.layout&&!e.isLayoutDirty&&(e.snapshot=e.layout,e.isLayoutDirty=!0)}function HZ(e){const{visualElement:t}=e.options;t&&t.getProps().onBeforeLayoutMeasure&&t.notify("BeforeLayoutMeasure"),e.resetTransform()}function _C(e){e.finishAnimation(),e.targetDelta=e.relativeTarget=e.target=void 0,e.isProjectionDirty=!0}function VZ(e){e.resolveTargetDelta()}function KZ(e){e.calcProjection()}function GZ(e){e.resetSkewAndRotation()}function WZ(e){e.removeLeadSnapshot()}function CC(e,t,n){e.translate=cn(t.translate,0,n),e.scale=cn(t.scale,1,n),e.origin=t.origin,e.originPoint=t.originPoint}function TC(e,t,n,i){e.min=cn(t.min,n.min,i),e.max=cn(t.max,n.max,i)}function YZ(e,t,n,i){TC(e.x,t.x,n.x,i),TC(e.y,t.y,n.y,i)}function XZ(e){return e.animationValues&&e.animationValues.opacityExit!==void 0}const QZ={duration:.45,ease:[.4,0,.1,1]},AC=e=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(e),jC=AC("applewebkit/")&&!AC("chrome/")?Math.round:Cs;function MC(e){e.min=jC(e.min),e.max=jC(e.max)}function ZZ(e){MC(e.x),MC(e.y)}function mO(e,t,n){return e==="position"||e==="preserve-aspect"&&!xZ(xC(t),xC(n),.2)}function JZ(e){var t;return e!==e.root&&((t=e.scroll)==null?void 0:t.wasRoot)}const eJ=pO({attachResizeListener:(e,t)=>$d(e,"resize",t),measureScroll:()=>{var e,t;return{x:document.documentElement.scrollLeft||((e=document.body)==null?void 0:e.scrollLeft)||0,y:document.documentElement.scrollTop||((t=document.body)==null?void 0:t.scrollTop)||0}},checkIsScrollRoot:()=>!0}),mx={current:void 0},gO=pO({measureScroll:e=>({x:e.scrollLeft,y:e.scrollTop}),defaultParent:()=>{if(!mx.current){const e=new eJ({});e.mount(window),e.setOptions({layoutScroll:!0}),mx.current=e}return mx.current},resetTransform:(e,t)=>{e.style.transform=t!==void 0?t:"none"},checkIsScrollRoot:e=>window.getComputedStyle(e).position==="fixed"}),yO=_.createContext({transformPagePoint:e=>e,isStatic:!1,reducedMotion:"never"});function tJ(e=!0){const t=_.useContext(A1);if(t===null)return[!0,null];const{isPresent:n,onExitComplete:i,register:s}=t,r=_.useId();_.useEffect(()=>{if(e)return s(r)},[e]);const o=_.useCallback(()=>e&&i&&i(r),[r,i,e]);return!n&&i?[!1,o]:[!0]}const bO=_.createContext({strict:!1}),RC={animation:["animate","variants","whileHover","whileTap","exit","whileInView","whileFocus","whileDrag"],exit:["exit"],drag:["drag","dragControls"],focus:["whileFocus"],hover:["whileHover","onHoverStart","onHoverEnd"],tap:["whileTap","onTap","onTapStart","onTapCancel"],pan:["onPan","onPanStart","onPanSessionStart","onPanEnd"],inView:["whileInView","onViewportEnter","onViewportLeave"],layout:["layout","layoutId"]};let DC=!1;function nJ(){if(DC)return;const e={};for(const t in RC)e[t]={isEnabled:n=>RC[t].some(i=>!!n[i])};WD(e),DC=!0}function xO(){return nJ(),VQ()}function iJ(e){const t=xO();for(const n in e)t[n]={...t[n],...e[n]};WD(t)}const sJ=new Set(["animate","exit","variants","initial","style","values","variants","transition","transformTemplate","custom","inherit","onBeforeLayoutMeasure","onAnimationStart","onAnimationComplete","onUpdate","onDragStart","onDrag","onDragEnd","onMeasureDragConstraints","onDirectionLock","onDragTransitionEnd","_dragX","_dragY","onHoverStart","onHoverEnd","onViewportEnter","onViewportLeave","globalTapTarget","propagate","ignoreStrict","viewport"]);function mm(e){return e.startsWith("while")||e.startsWith("drag")&&e!=="draggable"||e.startsWith("layout")||e.startsWith("onTap")||e.startsWith("onPan")||e.startsWith("onLayout")||sJ.has(e)}let vO=e=>!mm(e);function rJ(e){typeof e=="function"&&(vO=t=>t.startsWith("on")?!mm(t):e(t))}try{rJ(require("@emotion/is-prop-valid").default)}catch{}function aJ(e,t,n){const i={};for(const s in e)s==="values"&&typeof e.values=="object"||gi(e[s])||(vO(s)||n===!0&&mm(s)||!t&&!mm(s)||e.draggable&&s.startsWith("onDrag"))&&(i[s]=e[s]);return i}const Km=_.createContext({});function oJ(e,t){if(Vm(e)){const{initial:n,animate:i}=e;return{initial:n===!1||Fd(n)?n:void 0,animate:Fd(i)?i:void 0}}return e.inherit!==!1?t:{}}function lJ(e){const{initial:t,animate:n}=oJ(e,_.useContext(Km));return _.useMemo(()=>({initial:t,animate:n}),[OC(t),OC(n)])}function OC(e){return Array.isArray(e)?e.join(" "):e}const tw=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function wO(e,t,n){for(const i in t)!gi(t[i])&&!tO(i,n)&&(e[i]=t[i])}function cJ({transformTemplate:e},t){return _.useMemo(()=>{const n=tw();return J1(n,t,e),Object.assign({},n.vars,n.style)},[t])}function uJ(e,t){const n=e.style||{},i={};return wO(i,n,e),Object.assign(i,cJ(e,t)),i}function dJ(e,t){const n={},i=uJ(e,t);return e.drag&&e.dragListener!==!1&&(n.draggable=!1,i.userSelect=i.WebkitUserSelect=i.WebkitTouchCallout="none",i.touchAction=e.drag===!0?"none":`pan-${e.drag==="x"?"y":"x"}`),e.tabIndex===void 0&&(e.onTap||e.onTapStart||e.whileTap)&&(n.tabIndex=0),n.style=i,n}const EO=()=>({...tw(),attrs:{}});function fJ(e,t,n,i){const s=_.useMemo(()=>{const r=EO();return nO(r,t,sO(i),e.transformTemplate,e.style),{...r.attrs,style:{...r.style}}},[t]);if(e.style){const r={};wO(r,e.style,e),s.style={...r,...s.style}}return s}const hJ=["animate","circle","defs","desc","ellipse","g","image","line","filter","marker","mask","metadata","path","pattern","polygon","polyline","rect","stop","switch","symbol","svg","text","tspan","use","view"];function nw(e){return typeof e!="string"||e.includes("-")?!1:!!(hJ.indexOf(e)>-1||/[A-Z]/u.test(e))}function pJ(e,t,n,{latestValues:i},s,r=!1,o){const u=(o??nw(e)?fJ:dJ)(t,i,s,e),f=aJ(t,typeof e=="string",r),p=e!==_.Fragment?{...f,...u,ref:n}:{},{children:m}=t,y=_.useMemo(()=>gi(m)?m.get():m,[m]);return _.createElement(e,{...p,children:y})}function mJ({scrapeMotionValuesFromProps:e,createRenderState:t},n,i,s){return{latestValues:gJ(n,i,s,e),renderState:t()}}function gJ(e,t,n,i){const s={},r=i(e,{});for(const y in r)s[y]=Lp(r[y]);let{initial:o,animate:c}=e;const u=Vm(e),f=KD(e);t&&f&&!u&&e.inherit!==!1&&(o===void 0&&(o=t.initial),c===void 0&&(c=t.animate));let p=n?n.initial===!1:!1;p=p||o===!1;const m=p?c:o;if(m&&typeof m!="boolean"&&!Hm(m)){const y=Array.isArray(m)?m:[m];for(let b=0;b<y.length;b++){const x=H1(e,y[b]);if(x){const{transitionEnd:v,transition:w,...k}=x;for(const C in k){let S=k[C];if(Array.isArray(S)){const T=p?S.length-1:0;S=S[T]}S!==null&&(s[C]=S)}for(const C in v)s[C]=v[C]}}}return s}const kO=e=>(t,n)=>{const i=_.useContext(Km),s=_.useContext(A1),r=()=>mJ(e,t,i,s);return n?r():pY(r)},yJ=kO({scrapeMotionValuesFromProps:ew,createRenderState:tw}),bJ=kO({scrapeMotionValuesFromProps:rO,createRenderState:EO}),xJ=Symbol.for("motionComponentSymbol");function vJ(e,t,n){const i=_.useRef(n);_.useInsertionEffect(()=>{i.current=n});const s=_.useRef(null);return _.useCallback(r=>{var c;r&&((c=e.onMount)==null||c.call(e,r)),t&&(r?t.mount(r):t.unmount());const o=i.current;if(typeof o=="function")if(r){const u=o(r);typeof u=="function"&&(s.current=u)}else s.current?(s.current(),s.current=null):o(r);else o&&(o.current=r)},[t])}const SO=_.createContext({});function uc(e){return e&&typeof e=="object"&&Object.prototype.hasOwnProperty.call(e,"current")}function wJ(e,t,n,i,s,r){var S,T;const{visualElement:o}=_.useContext(Km),c=_.useContext(bO),u=_.useContext(A1),f=_.useContext(yO),p=f.reducedMotion,m=f.skipAnimations,y=_.useRef(null),b=_.useRef(!1);i=i||c.renderer,!y.current&&i&&(y.current=i(e,{visualState:t,parent:o,props:n,presenceContext:u,blockInitialAnimation:u?u.initial===!1:!1,reducedMotionConfig:p,skipAnimations:m,isSVG:r}),b.current&&y.current&&(y.current.manuallyAnimateOnMount=!0));const x=y.current,v=_.useContext(SO);x&&!x.projection&&s&&(x.type==="html"||x.type==="svg")&&EJ(y.current,n,s,v);const w=_.useRef(!1);_.useInsertionEffect(()=>{x&&w.current&&x.update(n,u)});const k=n[LD],C=_.useRef(!!k&&typeof window<"u"&&!((S=window.MotionHandoffIsComplete)!=null&&S.call(window,k))&&((T=window.MotionHasOptimisedAnimation)==null?void 0:T.call(window,k)));return gY(()=>{b.current=!0,x&&(w.current=!0,window.MotionIsMounted=!0,x.updateFeatures(),x.scheduleRenderMicrotask(),C.current&&x.animationState&&x.animationState.animateChanges())}),_.useEffect(()=>{x&&(!C.current&&x.animationState&&x.animationState.animateChanges(),C.current&&(queueMicrotask(()=>{var A;(A=window.MotionHandoffMarkAsComplete)==null||A.call(window,k)}),C.current=!1),x.enteringChildren=void 0)}),x}function EJ(e,t,n,i){const{layoutId:s,layout:r,drag:o,dragConstraints:c,layoutScroll:u,layoutRoot:f,layoutAnchor:p,layoutCrossfade:m}=t;e.projection=new n(e.latestValues,t["data-framer-portal-id"]?void 0:NO(e.parent)),e.projection.setOptions({layoutId:s,layout:r,alwaysMeasureLayout:!!o||c&&uc(c),visualElement:e,animationType:typeof r=="string"?r:"both",initialPromotionConfig:i,crossfade:m,layoutScroll:u,layoutRoot:f,layoutAnchor:p})}function NO(e){if(e)return e.options.allowProjection!==!1?e.projection:NO(e.parent)}function gx(e,{forwardMotionProps:t=!1,type:n}={},i,s){i&&iJ(i);const r=n?n==="svg":nw(e),o=r?bJ:yJ;function c(f,p){let m;const y={..._.useContext(yO),...f,layoutId:kJ(f)},{isStatic:b}=y,x=lJ(f),v=o(f,b);if(!b&&typeof window<"u"){SJ();const w=NJ(y);m=w.MeasureLayout,x.visualElement=wJ(e,v,y,s,w.ProjectionNode,r)}return d.jsxs(Km.Provider,{value:x,children:[m&&x.visualElement?d.jsx(m,{visualElement:x.visualElement,...y}):null,pJ(e,f,vJ(v,x.visualElement,p),v,b,t,r)]})}c.displayName=`motion.${typeof e=="string"?e:`create(${e.displayName??e.name??""})`}`;const u=_.forwardRef(c);return u[xJ]=e,u}function kJ({layoutId:e}){const t=_.useContext(GR).id;return t&&e!==void 0?t+"-"+e:e}function SJ(e,t){_.useContext(bO).strict}function NJ(e){const t=xO(),{drag:n,layout:i}=t;if(!n&&!i)return{};const s={...n,...i};return{MeasureLayout:n!=null&&n.isEnabled(e)||i!=null&&i.isEnabled(e)?s.MeasureLayout:void 0,ProjectionNode:s.ProjectionNode}}function _J(e,t){if(typeof Proxy>"u")return gx;const n=new Map,i=(r,o)=>gx(r,o,e,t),s=(r,o)=>i(r,o);return new Proxy(s,{get:(r,o)=>o==="create"?i:(n.has(o)||n.set(o,gx(o,void 0,e,t)),n.get(o))})}const CJ=(e,t)=>t.isSVG??nw(e)?new lZ(t):new nZ(t,{allowProjection:e!==_.Fragment});class TJ extends po{constructor(t){super(t),t.animationState||(t.animationState=hZ(t))}updateAnimationControlsSubscription(){const{animate:t}=this.node.getProps();Hm(t)&&(this.unmountControls=t.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:t}=this.node.getProps(),{animate:n}=this.node.prevProps||{};t!==n&&this.updateAnimationControlsSubscription()}unmount(){var t;this.node.animationState.reset(),(t=this.unmountControls)==null||t.call(this)}}let AJ=0;class jJ extends po{constructor(){super(...arguments),this.id=AJ++,this.isExitComplete=!1}update(){var r;if(!this.node.presenceContext)return;const{isPresent:t,onExitComplete:n}=this.node.presenceContext,{isPresent:i}=this.node.prevPresenceContext||{};if(!this.node.animationState||t===i)return;if(t&&i===!1){if(this.isExitComplete){const{initial:o,custom:c}=this.node.getProps();if(typeof o=="string"||typeof o=="object"&&o!==null&&!Array.isArray(o)){const u=rl(this.node,o,c);if(u){const{transition:f,transitionEnd:p,...m}=u;for(const y in m)(r=this.node.getValue(y))==null||r.jump(m[y])}}this.node.animationState.reset(),this.node.animationState.animateChanges()}else this.node.animationState.setActive("exit",!1);this.isExitComplete=!1;return}const s=this.node.animationState.setActive("exit",!t);n&&!t&&s.then(()=>{this.isExitComplete=!0,n(this.id)})}mount(){const{register:t,onExitComplete:n}=this.node.presenceContext||{};n&&n(this.id),t&&(this.unmount=t(this.id))}unmount(){}}const MJ={animation:{Feature:TJ},exit:{Feature:jJ}};function kf(e){return{point:{x:e.pageX,y:e.pageY}}}const RJ=e=>t=>Y1(t)&&e(t,kf(t));function Ad(e,t,n,i){return $d(e,t,RJ(n),i)}const _O=({current:e})=>e?e.ownerDocument.defaultView:null,LC=(e,t)=>Math.abs(e-t);function DJ(e,t){const n=LC(e.x,t.x),i=LC(e.y,t.y);return Math.sqrt(n**2+i**2)}const IC=new Set(["auto","scroll"]);class CO{constructor(t,n,{transformPagePoint:i,contextWindow:s=window,dragSnapToOrigin:r=!1,distanceThreshold:o=3,element:c}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.lastRawMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.scrollPositions=new Map,this.removeScrollListeners=null,this.onElementScroll=x=>{this.handleScroll(x.target)},this.onWindowScroll=()=>{this.handleScroll(window)},this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;this.lastRawMoveEventInfo&&(this.lastMoveEventInfo=np(this.lastRawMoveEventInfo,this.transformPagePoint));const x=yx(this.lastMoveEventInfo,this.history),v=this.startEvent!==null,w=DJ(x.offset,{x:0,y:0})>=this.distanceThreshold;if(!v&&!w)return;const{point:k}=x,{timestamp:C}=mi;this.history.push({...k,timestamp:C});const{onStart:S,onMove:T}=this.handlers;v||(S&&S(this.lastMoveEvent,x),this.startEvent=this.lastMoveEvent),T&&T(this.lastMoveEvent,x)},this.handlePointerMove=(x,v)=>{this.lastMoveEvent=x,this.lastRawMoveEventInfo=v,this.lastMoveEventInfo=np(v,this.transformPagePoint),un.update(this.updatePoint,!0)},this.handlePointerUp=(x,v)=>{this.end();const{onEnd:w,onSessionEnd:k,resumeAnimation:C}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&C&&C(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const S=yx(x.type==="pointercancel"?this.lastMoveEventInfo:np(v,this.transformPagePoint),this.history);this.startEvent&&w&&w(x,S),k&&k(x,S)},!Y1(t))return;this.dragSnapToOrigin=r,this.handlers=n,this.transformPagePoint=i,this.distanceThreshold=o,this.contextWindow=s||window;const u=kf(t),f=np(u,this.transformPagePoint),{point:p}=f,{timestamp:m}=mi;this.history=[{...p,timestamp:m}];const{onSessionStart:y}=n;y&&y(t,yx(f,this.history));const b={passive:!0,capture:!0};this.removeListeners=vf(Ad(this.contextWindow,"pointermove",this.handlePointerMove,b),Ad(this.contextWindow,"pointerup",this.handlePointerUp,b),Ad(this.contextWindow,"pointercancel",this.handlePointerUp,b)),c&&this.startScrollTracking(c)}startScrollTracking(t){let n=t.parentElement;for(;n;){const i=getComputedStyle(n);(IC.has(i.overflowX)||IC.has(i.overflowY))&&this.scrollPositions.set(n,{x:n.scrollLeft,y:n.scrollTop}),n=n.parentElement}this.scrollPositions.set(window,{x:window.scrollX,y:window.scrollY}),window.addEventListener("scroll",this.onElementScroll,{capture:!0}),window.addEventListener("scroll",this.onWindowScroll),this.removeScrollListeners=()=>{window.removeEventListener("scroll",this.onElementScroll,{capture:!0}),window.removeEventListener("scroll",this.onWindowScroll)}}handleScroll(t){const n=this.scrollPositions.get(t);if(!n)return;const i=t===window,s=i?{x:window.scrollX,y:window.scrollY}:{x:t.scrollLeft,y:t.scrollTop},r={x:s.x-n.x,y:s.y-n.y};r.x===0&&r.y===0||(i?this.lastMoveEventInfo&&(this.lastMoveEventInfo.point.x+=r.x,this.lastMoveEventInfo.point.y+=r.y):this.history.length>0&&(this.history[0].x-=r.x,this.history[0].y-=r.y),this.scrollPositions.set(t,s),un.update(this.updatePoint,!0))}updateHandlers(t){this.handlers=t}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),lo(this.updatePoint)}}function np(e,t){return t?{point:t(e.point)}:e}function PC(e,t){return{x:e.x-t.x,y:e.y-t.y}}function yx({point:e},t){return{point:e,delta:PC(e,TO(t)),offset:PC(e,OJ(t)),velocity:LJ(t,.1)}}function OJ(e){return e[0]}function TO(e){return e[e.length-1]}function LJ(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,i=null;const s=TO(e);for(;n>=0&&(i=e[n],!(s.timestamp-i.timestamp>os(t)));)n--;if(!i)return{x:0,y:0};i===e[0]&&e.length>2&&s.timestamp-i.timestamp>os(t)*2&&(i=e[1]);const r=_s(s.timestamp-i.timestamp);if(r===0)return{x:0,y:0};const o={x:(s.x-i.x)/r,y:(s.y-i.y)/r};return o.x===1/0&&(o.x=0),o.y===1/0&&(o.y=0),o}function IJ(e,{min:t,max:n},i){return t!==void 0&&e<t?e=i?cn(t,e,i.min):Math.max(e,t):n!==void 0&&e>n&&(e=i?cn(n,e,i.max):Math.min(e,n)),e}function zC(e,t,n){return{min:t!==void 0?e.min+t:void 0,max:n!==void 0?e.max+n-(e.max-e.min):void 0}}function PJ(e,{top:t,left:n,bottom:i,right:s}){return{x:zC(e.x,n,s),y:zC(e.y,t,i)}}function BC(e,t){let n=t.min-e.min,i=t.max-e.max;return t.max-t.min<e.max-e.min&&([n,i]=[i,n]),{min:n,max:i}}function zJ(e,t){return{x:BC(e.x,t.x),y:BC(e.y,t.y)}}function BJ(e,t){let n=.5;const i=Ri(e),s=Ri(t);return s>i?n=Bd(t.min,t.max-i,e.min):i>s&&(n=Bd(e.min,e.max-s,t.min)),Nr(0,1,n)}function UJ(e,t){const n={};return t.min!==void 0&&(n.min=t.min-e.min),t.max!==void 0&&(n.max=t.max-e.min),n}const ov=.35;function FJ(e=ov){return e===!1?e=0:e===!0&&(e=ov),{x:UC(e,"left","right"),y:UC(e,"top","bottom")}}function UC(e,t,n){return{min:FC(e,t),max:FC(e,n)}}function FC(e,t){return typeof e=="number"?e:e[t]||0}const $J=new WeakMap;class qJ{constructor(t){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=Jn(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=t}start(t,{snapToCursor:n=!1,distanceThreshold:i}={}){const{presenceContext:s}=this.visualElement;if(s&&s.isPresent===!1)return;const r=m=>{n&&this.snapToCursor(kf(m).point),this.stopAnimation()},o=(m,y)=>{const{drag:b,dragPropagation:x,onDragStart:v}=this.getProps();if(b&&!x&&(this.openDragLock&&this.openDragLock(),this.openDragLock=wQ(b),!this.openDragLock))return;this.latestPointerEvent=m,this.latestPanInfo=y,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),gr(k=>{let C=this.getAxisMotionValue(k).get()||0;if(Er.test(C)){const{projection:S}=this.visualElement;if(S&&S.layout){const T=S.layout.layoutBox[k];T&&(C=Ri(T)*(parseFloat(C)/100))}}this.originPoint[k]=C}),v&&un.update(()=>v(m,y),!1,!0),Q0(this.visualElement,"transform");const{animationState:w}=this.visualElement;w&&w.setActive("whileDrag",!0)},c=(m,y)=>{this.latestPointerEvent=m,this.latestPanInfo=y;const{dragPropagation:b,dragDirectionLock:x,onDirectionLock:v,onDrag:w}=this.getProps();if(!b&&!this.openDragLock)return;const{offset:k}=y;if(x&&this.currentDirection===null){this.currentDirection=VJ(k),this.currentDirection!==null&&v&&v(this.currentDirection);return}this.updateAxis("x",y.point,k),this.updateAxis("y",y.point,k),this.visualElement.render(),w&&un.update(()=>w(m,y),!1,!0)},u=(m,y)=>{this.latestPointerEvent=m,this.latestPanInfo=y,this.stop(m,y),this.latestPointerEvent=null,this.latestPanInfo=null},f=()=>{const{dragSnapToOrigin:m}=this.getProps();(m||this.constraints)&&this.startAnimation({x:0,y:0})},{dragSnapToOrigin:p}=this.getProps();this.panSession=new CO(t,{onSessionStart:r,onStart:o,onMove:c,onSessionEnd:u,resumeAnimation:f},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:p,distanceThreshold:i,contextWindow:_O(this.visualElement),element:this.visualElement.current})}stop(t,n){const i=t||this.latestPointerEvent,s=n||this.latestPanInfo,r=this.isDragging;if(this.cancel(),!r||!s||!i)return;const{velocity:o}=s;this.startAnimation(o);const{onDragEnd:c}=this.getProps();c&&un.postRender(()=>c(i,s))}cancel(){this.isDragging=!1;const{projection:t,animationState:n}=this.visualElement;t&&(t.isAnimationBlocked=!1),this.endPanSession();const{dragPropagation:i}=this.getProps();!i&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),n&&n.setActive("whileDrag",!1)}endPanSession(){this.panSession&&this.panSession.end(),this.panSession=void 0}updateAxis(t,n,i){const{drag:s}=this.getProps();if(!i||!ip(t,s,this.currentDirection))return;const r=this.getAxisMotionValue(t);let o=this.originPoint[t]+i[t];this.constraints&&this.constraints[t]&&(o=IJ(o,this.constraints[t],this.elastic[t])),r.set(o)}resolveConstraints(){var r;const{dragConstraints:t,dragElastic:n}=this.getProps(),i=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):(r=this.visualElement.projection)==null?void 0:r.layout,s=this.constraints;t&&uc(t)?this.constraints||(this.constraints=this.resolveRefConstraints()):t&&i?this.constraints=PJ(i.layoutBox,t):this.constraints=!1,this.elastic=FJ(n),s!==this.constraints&&!uc(t)&&i&&this.constraints&&!this.hasMutatedConstraints&&gr(o=>{this.constraints!==!1&&this.getAxisMotionValue(o)&&(this.constraints[o]=UJ(i.layoutBox[o],this.constraints[o]))})}resolveRefConstraints(){const{dragConstraints:t,onMeasureDragConstraints:n}=this.getProps();if(!t||!uc(t))return!1;const i=t.current,{projection:s}=this.visualElement;if(!s||!s.layout)return!1;s.root&&(s.root.scroll=void 0,s.root.updateScroll());const r=XQ(i,s.root,this.visualElement.getTransformPagePoint());let o=zJ(s.layout.layoutBox,r);if(n){const c=n(GQ(o));this.hasMutatedConstraints=!!c,c&&(o=XD(c))}return o}startAnimation(t){const{drag:n,dragMomentum:i,dragElastic:s,dragTransition:r,dragSnapToOrigin:o,onDragTransitionEnd:c}=this.getProps(),u=this.constraints||{},f=gr(p=>{if(!ip(p,n,this.currentDirection))return;let m=u&&u[p]||{};(o===!0||o===p)&&(m={min:0,max:0});const y=s?200:1e6,b=s?40:1e7,x={type:"inertia",velocity:i?t[p]:0,bounceStiffness:y,bounceDamping:b,timeConstant:750,restDelta:1,restSpeed:10,...r,...m};return this.startAxisValueAnimation(p,x)});return Promise.all(f).then(c)}startAxisValueAnimation(t,n){const i=this.getAxisMotionValue(t);return Q0(this.visualElement,t),i.start(q1(t,i,0,n,this.visualElement,!1))}stopAnimation(){gr(t=>this.getAxisMotionValue(t).stop())}getAxisMotionValue(t){const n=`_drag${t.toUpperCase()}`,s=this.visualElement.getProps()[n];return s||this.visualElement.getValue(t,this.visualElement.latestValues[t]??0)}snapToCursor(t){gr(n=>{const{drag:i}=this.getProps();if(!ip(n,i,this.currentDirection))return;const{projection:s}=this.visualElement,r=this.getAxisMotionValue(n);if(s&&s.layout){const{min:o,max:c}=s.layout.layoutBox[n],u=r.get()||0;r.set(t[n]-cn(o,c,.5)+u)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:t,dragConstraints:n}=this.getProps(),{projection:i}=this.visualElement;if(!uc(n)||!i||!this.constraints)return;this.stopAnimation();const s={x:0,y:0};gr(o=>{const c=this.getAxisMotionValue(o);if(c&&this.constraints!==!1){const u=c.get();s[o]=BJ({min:u,max:u},this.constraints[o])}});const{transformTemplate:r}=this.visualElement.getProps();this.visualElement.current.style.transform=r?r({},""):"none",i.root&&i.root.updateScroll(),i.updateLayout(),this.constraints=!1,this.resolveConstraints(),gr(o=>{if(!ip(o,t,null))return;const c=this.getAxisMotionValue(o),{min:u,max:f}=this.constraints[o];c.set(cn(u,f,s[o]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;$J.set(this.visualElement,this);const t=this.visualElement.current,n=Ad(t,"pointerdown",f=>{const{drag:p,dragListener:m=!0}=this.getProps(),y=f.target,b=y!==t&&CQ(y);p&&m&&!b&&this.start(f)});let i;const s=()=>{const{dragConstraints:f}=this.getProps();uc(f)&&f.current&&(this.constraints=this.resolveRefConstraints(),i||(i=HJ(t,f.current,()=>this.scalePositionWithinConstraints())))},{projection:r}=this.visualElement,o=r.addEventListener("measure",s);r&&!r.layout&&(r.root&&r.root.updateScroll(),r.updateLayout()),un.read(s);const c=$d(window,"resize",()=>this.scalePositionWithinConstraints()),u=r.addEventListener("didUpdate",(({delta:f,hasLayoutChanged:p})=>{this.isDragging&&p&&(gr(m=>{const y=this.getAxisMotionValue(m);y&&(this.originPoint[m]+=f[m].translate,y.set(y.get()+f[m].translate))}),this.visualElement.render())}));return()=>{c(),n(),o(),u&&u(),i&&i()}}getProps(){const t=this.visualElement.getProps(),{drag:n=!1,dragDirectionLock:i=!1,dragPropagation:s=!1,dragConstraints:r=!1,dragElastic:o=ov,dragMomentum:c=!0}=t;return{...t,drag:n,dragDirectionLock:i,dragPropagation:s,dragConstraints:r,dragElastic:o,dragMomentum:c}}}function $C(e){let t=!0;return()=>{if(t){t=!1;return}e()}}function HJ(e,t,n){const i=Q2(e,$C(n)),s=Q2(t,$C(n));return()=>{i(),s()}}function ip(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function VJ(e,t=10){let n=null;return Math.abs(e.y)>t?n="y":Math.abs(e.x)>t&&(n="x"),n}class KJ extends po{constructor(t){super(t),this.removeGroupControls=Cs,this.removeListeners=Cs,this.controls=new qJ(t)}mount(){const{dragControls:t}=this.node.getProps();t&&(this.removeGroupControls=t.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||Cs}update(){const{dragControls:t}=this.node.getProps(),{dragControls:n}=this.node.prevProps||{};t!==n&&(this.removeGroupControls(),t&&(this.removeGroupControls=t.subscribe(this.controls)))}unmount(){this.removeGroupControls(),this.removeListeners(),this.controls.isDragging||this.controls.endPanSession()}}const bx=e=>(t,n)=>{e&&un.update(()=>e(t,n),!1,!0)};class GJ extends po{constructor(){super(...arguments),this.removePointerDownListener=Cs}onPointerDown(t){this.session=new CO(t,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:_O(this.node)})}createPanHandlers(){const{onPanSessionStart:t,onPanStart:n,onPan:i,onPanEnd:s}=this.node.getProps();return{onSessionStart:bx(t),onStart:bx(n),onMove:bx(i),onEnd:(r,o)=>{delete this.session,s&&un.postRender(()=>s(r,o))}}}mount(){this.removePointerDownListener=Ad(this.node.current,"pointerdown",t=>this.onPointerDown(t))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}let xx=!1;class WJ extends _.Component{componentDidMount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:i,layoutId:s}=this.props,{projection:r}=t;r&&(n.group&&n.group.add(r),i&&i.register&&s&&i.register(r),xx&&r.root.didUpdate(),r.addEventListener("animationComplete",()=>{this.safeToRemove()}),r.setOptions({...r.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),Ip.hasEverUpdated=!0}getSnapshotBeforeUpdate(t){const{layoutDependency:n,visualElement:i,drag:s,isPresent:r}=this.props,{projection:o}=i;return o&&(o.isPresent=r,t.layoutDependency!==n&&o.setOptions({...o.options,layoutDependency:n}),xx=!0,s||t.layoutDependency!==n||n===void 0||t.isPresent!==r?o.willUpdate():this.safeToRemove(),t.isPresent!==r&&(r?o.promote():o.relegate()||un.postRender(()=>{const c=o.getStack();(!c||!c.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{visualElement:t,layoutAnchor:n}=this.props,{projection:i}=t;i&&(i.options.layoutAnchor=n,i.root.didUpdate(),W1.postRender(()=>{!i.currentAnimation&&i.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:i}=this.props,{projection:s}=t;xx=!0,s&&(s.scheduleCheckAfterUnmount(),n&&n.group&&n.group.remove(s),i&&i.deregister&&i.deregister(s))}safeToRemove(){const{safeToRemove:t}=this.props;t&&t()}render(){return null}}function AO(e){const[t,n]=tJ(),i=_.useContext(GR);return d.jsx(WJ,{...e,layoutGroup:i,switchLayoutGroup:_.useContext(SO),isPresent:t,safeToRemove:n})}const YJ={pan:{Feature:GJ},drag:{Feature:KJ,ProjectionNode:gO,MeasureLayout:AO}};function qC(e,t,n){const{props:i}=e;e.animationState&&i.whileHover&&e.animationState.setActive("whileHover",n==="Start");const s="onHover"+n,r=i[s];r&&un.postRender(()=>r(t,kf(t)))}class XJ extends po{mount(){const{current:t}=this.node;t&&(this.unmount=kQ(t,(n,i)=>(qC(this.node,i,"Start"),s=>qC(this.node,s,"End"))))}unmount(){}}class QJ extends po{constructor(){super(...arguments),this.isActive=!1}onFocus(){let t=!1;try{t=this.node.current.matches(":focus-visible")}catch{t=!0}!t||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!1),this.isActive=!1)}mount(){this.unmount=vf($d(this.node.current,"focus",()=>this.onFocus()),$d(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function HC(e,t,n){const{props:i}=e;if(e.current instanceof HTMLButtonElement&&e.current.disabled)return;e.animationState&&i.whileTap&&e.animationState.setActive("whileTap",n==="Start");const s="onTap"+(n==="End"?"":n),r=i[s];r&&un.postRender(()=>r(t,kf(t)))}class ZJ extends po{mount(){const{current:t}=this.node;if(!t)return;const{globalTapTarget:n,propagate:i}=this.node.props;this.unmount=AQ(t,(s,r)=>(HC(this.node,r,"Start"),(o,{success:c})=>HC(this.node,o,c?"End":"Cancel")),{useGlobalTarget:n,stopPropagation:(i==null?void 0:i.tap)===!1})}unmount(){}}const lv=new WeakMap,vx=new WeakMap,JJ=e=>{const t=lv.get(e.target);t&&t(e)},eee=e=>{e.forEach(JJ)};function tee({root:e,...t}){const n=e||document;vx.has(n)||vx.set(n,{});const i=vx.get(n),s=JSON.stringify(t);return i[s]||(i[s]=new IntersectionObserver(eee,{root:e,...t})),i[s]}function nee(e,t,n){const i=tee(t);return lv.set(e,n),i.observe(e),()=>{lv.delete(e),i.unobserve(e)}}const iee={some:0,all:1};class see extends po{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){var u;(u=this.stopObserver)==null||u.call(this);const{viewport:t={}}=this.node.getProps(),{root:n,margin:i,amount:s="some",once:r}=t,o={root:n?n.current:void 0,rootMargin:i,threshold:typeof s=="number"?s:iee[s]},c=f=>{const{isIntersecting:p}=f;if(this.isInView===p||(this.isInView=p,r&&!p&&this.hasEnteredView))return;p&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",p);const{onViewportEnter:m,onViewportLeave:y}=this.node.getProps(),b=p?m:y;b&&b(f)};this.stopObserver=nee(this.node.current,o,c)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:t,prevProps:n}=this.node;["amount","margin","root"].some(ree(t,n))&&this.startObserver()}unmount(){var t;(t=this.stopObserver)==null||t.call(this),this.hasEnteredView=!1,this.isInView=!1}}function ree({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}const aee={inView:{Feature:see},tap:{Feature:ZJ},focus:{Feature:QJ},hover:{Feature:XJ}},oee={layout:{ProjectionNode:gO,MeasureLayout:AO}},lee={...MJ,...aee,...YJ,...oee},cee=_J(lee,CJ),uee={some:0,all:1};function dee(e,t,{root:n,margin:i,amount:s="some"}={}){const r=G1(e),o=new WeakMap,c=f=>{f.forEach(p=>{const m=o.get(p.target);if(p.isIntersecting!==!!m)if(p.isIntersecting){const y=t(p.target,p);typeof y=="function"?o.set(p.target,y):u.unobserve(p.target)}else typeof m=="function"&&(m(p),o.delete(p.target))})},u=new IntersectionObserver(c,{root:n,rootMargin:i,threshold:typeof s=="number"?s:uee[s]});return r.forEach(f=>u.observe(f)),()=>u.disconnect()}function fee(e,{root:t,margin:n,amount:i,once:s=!1,initial:r=!1}={}){const[o,c]=_.useState(r);return _.useEffect(()=>{if(!e.current||s&&o)return;const u=()=>(c(!0),s?void 0:()=>c(!1)),f={root:t&&t.current||void 0,margin:n,amount:i};return dee(e.current,u,f)},[t,e,n,s,i]),o}function au({children:e,index:t,className:n="",delay:i=.1,amount:s=.5,root:r}){const o=_.useRef(null),c=fee(o,{amount:s,once:!1,root:r});return d.jsx(cee.div,{ref:o,"data-index":t,initial:{scale:.7,opacity:0},animate:c?{scale:1,opacity:1}:{scale:.7,opacity:0},transition:{duration:.2,delay:i},className:n,children:e})}async function hee(e,t={}){const n=e.trim();if(!n)return null;try{const i=await fetch("/api/tts",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({text:n,voice:t.voice,speed:t.speed}),signal:t.signal});if(!i.ok)return null;const s=await i.arrayBuffer();return s.byteLength>0?s:null}catch{return null}}function pee(){return typeof window>"u"?null:window.AudioContext??window.webkitAudioContext??null}function mee(){const e=_.useRef(null),t=_.useRef(null),n=_.useRef(null),i=_.useRef(Promise.resolve()),s=_.useRef(!1),[r,o]=_.useState(null),c=_.useCallback(()=>{if(e.current)return e.current;const b=pee();if(!b)return null;const x=new b,v=x.createAnalyser();return v.fftSize=2048,v.connect(x.destination),e.current=x,t.current=v,o(v),x},[]),u=_.useCallback(()=>{const b=c();(b==null?void 0:b.state)==="suspended"&&b.resume()},[c]),f=_.useCallback(async(b,x)=>{const v=c(),w=t.current;if(!v||!w)throw new Error("no-audio-context");const k=await v.decodeAudioData(b.slice(0));x()&&(v.state==="suspended"&&await v.resume(),await new Promise(C=>{const S=v.createBufferSource();S.buffer=k,S.connect(w),n.current=S,S.onended=()=>{n.current===S&&(n.current=null),C()},S.start()}))},[c]),p=_.useCallback((b,x)=>new Promise(v=>{if(typeof window>"u"||!window.speechSynthesis||!x()){v();return}const w=new SpeechSynthesisUtterance(b);w.lang=navigator.language||"zh-CN",w.rate=1,w.onend=()=>v(),w.onerror=()=>v(),window.speechSynthesis.speak(w)}),[]),m=_.useCallback((b,x,v,w)=>{if(!b.trim()){v();return}const k=hee(b);i.current=i.current.then(async()=>{try{if(!x())return;const C=await k;if(!x())return;if(C){s.current=!0,w==null||w();try{await f(C,x)}catch{}return}s.current||(w==null||w(),await p(b,x))}finally{v()}})},[f,p]),y=_.useCallback(()=>{var b,x;try{(b=n.current)==null||b.stop()}catch{}n.current=null,typeof window<"u"&&((x=window.speechSynthesis)==null||x.cancel()),i.current=Promise.resolve()},[]);return _.useEffect(()=>()=>{var b,x,v;try{(b=n.current)==null||b.stop()}catch{}typeof window<"u"&&((x=window.speechSynthesis)==null||x.cancel()),(v=e.current)==null||v.close()},[]),{enqueue:m,cancel:y,resume:u,analyser:r}}const VC=900;function gee({phase:e,inputAnalyser:t,outputAnalyser:n=null,outputText:i,thinkingConfig:s}){const r=_.useRef(null),o=_.useRef({phase:e,outputText:i,thinkingConfig:s});o.current={phase:e,outputText:i,thinkingConfig:s};const c=_.useRef(null);return _.useEffect(()=>{var W;const u=r.current;if(!u)return;const f=u.getContext("2d");if(!f)return;let p=o.current.phase,m=p,y=performance.now()-VC;const b=((W=window.matchMedia)==null?void 0:W.call(window,"(prefers-reduced-motion: reduce)").matches)??!1,x=new Uint8Array(new ArrayBuffer((t==null?void 0:t.fftSize)??2048)),v=new Uint8Array(new ArrayBuffer((n==null?void 0:n.fftSize)??2048)),w=new Float32Array(256),k=new Float32Array(256);let C=0,S=0,T=0,A=1,j=0,M=0;const D=window.getComputedStyle(u),P={cyan:D.getPropertyValue("--voice-cyan").trim(),blue:D.getPropertyValue("--voice-blue").trim(),violet:D.getPropertyValue("--voice-violet").trim(),pink:D.getPropertyValue("--voice-pink").trim(),amber:D.getPropertyValue("--voice-amber").trim(),mint:D.getPropertyValue("--voice-mint").trim()},I=Math.min(window.devicePixelRatio||1,2);let B=0,q=null;const G=X=>{const K=u.getBoundingClientRect();A=X,S=Math.max(1,Math.round(K.width)),T=Math.max(1,Math.round(K.height)),u.width=Math.round(S*A),u.height=Math.round(T*A),f.setTransform(A,0,0,A,0,0)},R=X=>{const{phase:K,outputText:U,thinkingConfig:F}=o.current;K!==p&&(m=p,p=K,y=X);const Y=X/1e3,$=b?1:Math.min(1,(X-y)/VC),ie=$*$*(3-2*$);KC(t,x,w),KC(n,v,k),j+=(WC(w)-j)*.08,M+=(WC(k)-M)*.08,f.clearRect(0,0,S,T),ie<1&&m!==p&&GC(f,m,S,T,Y,1-ie,w,k,j,M,U,P,F),GC(f,p,S,T,Y,ie,w,k,j,M,U,P,F),b||(C=window.requestAnimationFrame(R))};c.current=()=>R(performance.now());const O=()=>{const X=performance.now(),K=X-B<200;B=X,G(K?1:I),q&&(clearTimeout(q),q=null),K&&(q=setTimeout(()=>{q=null,G(I),b&&R(performance.now())},150))};O(),R(performance.now());const z=typeof ResizeObserver>"u"?null:new ResizeObserver(()=>{O(),b&&R(performance.now())});return z==null||z.observe(u),window.addEventListener("resize",O),()=>{window.cancelAnimationFrame(C),q&&clearTimeout(q),c.current=null,z==null||z.disconnect(),window.removeEventListener("resize",O)}},[t,n]),_.useEffect(()=>{var f,p;(((f=window.matchMedia)==null?void 0:f.call(window,"(prefers-reduced-motion: reduce)").matches)??!1)&&((p=c.current)==null||p.call(c))},[e,i,s]),d.jsx("canvas",{ref:r,className:"voice-canvas","aria-hidden":"true"})}function KC(e,t,n){if(!e){n.fill(0);return}e.getByteTimeDomainData(t);const i=t.length/n.length;for(let s=0;s<n.length;s+=1){const r=t[Math.min(t.length-1,Math.floor(s*i))]??128;n[s]=(r-128)/128}}function GC(e,t,n,i,s,r,o,c,u,f,p,m,y){t==="idle"&&yee(e,n,i,s,r,m),t==="listening"&&bee(e,n,i,s,r,o,u,m),t==="thinking"&&xee(e,n,i,s,r,m,y),t==="speaking"&&vee(e,n,i,s,r,c,f,p,m)}function yee(e,t,n,i,s,r){const o=[r.blue,r.violet];e.save(),e.globalCompositeOperation="screen",o.forEach((c,u)=>{e.beginPath();for(let f=0;f<=180;f+=1){const p=f/180,m=Math.sin(Math.PI*p),y=n/2+Math.sin(p*Math.PI*3+i*.42+u)*n*.018*m;f===0?e.moveTo(p*t,y):e.lineTo(p*t,y)}e.strokeStyle=c,e.lineWidth=2+u*2,e.globalAlpha=s*(.28+u*.08),e.shadowColor=c,e.shadowBlur=12,e.stroke()}),e.restore()}function bee(e,t,n,i,s,r,o,c){const u=[c.cyan,c.blue,c.violet,c.pink,c.mint];e.save(),e.globalCompositeOperation="screen",u.forEach((f,p)=>{MO(e,t,n,i,p,u.length,f,s,.12+o*.62,.7,m=>jO(r,m))}),e.restore()}function xee(e,t,n,i,s,r,o){const c=[r.pink,r.amber,r.violet,r.blue,r.cyan,r.mint],u=o.colors.length>0?o.colors:c,f=Math.min(8,Math.max(1,Math.round(o.count))),p=Array.from({length:f},(M,D)=>u[D%u.length]??r.violet),m=t/2,y=n/2,b=Math.min(t,n),x=Math.max(0,o.amplitude),v=Math.max(.2,o.waviness),w=Math.max(.1,o.scale),k=Math.max(0,o.saturation),C=Math.max(0,.4+o.intensity),S=`hue-rotate(${o.hueShift*360}deg) saturate(${k}) brightness(${C})`,T=Math.max(0,o.glow),A=T*(8+w*4),j=Math.min(.72,T*.16)*(.55+o.intensity*.45);e.save(),e.globalCompositeOperation="source-over",p.forEach((M,D)=>{const P=D%2===0?1:-1,I=i*Math.max(0,o.speed),B=I*(.72+D*.06)*P+D*(.92+o.spread*.2),q=D%3===0?-1:1,G=I*(1.5+D*.12)*q+D*.83,R=b*(.055+o.spread*.035+D%3*.01)*x,O=m+Math.cos(B*.78+D)*R,z=y+Math.sin(B*.66+D)*R*.72,W=b*(.14+o.thickness*.08+D%3*.012)*w,X=96,K=Math.max(2,Math.min(8,Math.round(2+v))),U=K+2,F=[];for(let pe=0;pe<X;pe+=1){const re=pe/X*Math.PI*2,ee=1+Math.sin(re*K+G)*x*.09+Math.cos(re*U-G*.74+D*.7)*x*.05;F.push({x:O+Math.cos(re+B)*W*ee,y:z+Math.sin(re+B)*W*ee*(.84+D%2*.07)})}const Y=F[0],$=F[F.length-1];if(!Y||!$)return;const ie=B+D*.47,be=Math.cos(ie)*W*1.15,ce=Math.sin(ie)*W*1.15,Ne=e.createLinearGradient(O-be,z-ce,O+be,z+ce),oe=Math.max(1,u.length);for(let pe=0;pe<=oe;pe+=1){const re=u[(pe+D)%u.length]??M;Ne.addColorStop(pe/oe,re)}e.beginPath(),e.moveTo(($.x+Y.x)/2,($.y+Y.y)/2);for(let pe=0;pe<F.length;pe+=1){const re=F[pe],ee=F[(pe+1)%F.length];!re||!ee||e.quadraticCurveTo(re.x,re.y,(re.x+ee.x)/2,(re.y+ee.y)/2)}e.closePath(),A>0&&o.intensity>0&&[1.55,.72].forEach((pe,re)=>{e.save(),e.globalCompositeOperation="screen",e.filter=`${S} blur(${A*pe*(re===0?.58:.24)}px)`,e.fillStyle=Ne,e.globalAlpha=s*o.opacity*j*(re===0?.72:.92),e.fill(),e.restore()}),e.save(),e.globalCompositeOperation="screen",e.filter=S,e.fillStyle=Ne,e.globalAlpha=s*o.opacity*(.3+D%3*.025),e.fill(),e.restore()}),e.restore()}function vee(e,t,n,i,s,r,o,c,u){const f=[u.mint,u.cyan,u.blue,u.violet,u.pink],p=o>.006;e.save(),e.globalCompositeOperation="screen",f.forEach((m,y)=>{MO(e,t,n,i*.86,y,f.length,m,s,.34+o*.36,1.45,b=>p?jO(r,b):wee(c,b,i,y))}),e.restore()}function wee(e,t,n,i){const s=e||"SPS",r=(n*1.6+t*s.length*.72+i*.46)%s.length,o=s.charCodeAt(Math.floor(r))||83,c=.18+o%13/42,u=2.2+o%5*.16;return Math.sin(t*Math.PI*u-n*(.72+o%4*.08)+i*.74)*c}function WC(e){let t=0;for(const n of e)t+=n*n;return Math.min(1,Math.sqrt(t/e.length)*3.2)}function jO(e,t){const n=Math.round(t*(e.length-1));let i=0,s=0;for(let r=-6;r<=6;r+=1){const o=Math.max(0,Math.min(e.length-1,n+r));i+=e[o]??0,s+=1}return i/s}function MO(e,t,n,i,s,r,o,c,u,f,p){const y=[],b=[],x=s%2===0?1:-1,v=s*1.18+i*(.32+s*.018)*x;for(let k=0;k<=84;k+=1){const C=k/84,S=Math.pow(Math.sin(Math.PI*C),.42),T=Math.pow(Math.sin(Math.PI*C),.9),A=Math.sin(C*Math.PI*(2.2+s*.18)+v),j=Math.sin(C*Math.PI*1.25-v*.58+s)*.38,M=p(C)*n*(.02+u*.025);y.push(n/2+(s-(r-1)/2)*n*.013+(A+j)*n*(.038+u*.038)*f*S+M*S),b.push(n*(.05+s*.005)*(.9+u*.38)*(.88+Math.sin(C*Math.PI*2-v)*.12)*T)}e.beginPath(),y.forEach((k,C)=>{const S=C/84*t,T=k-(b[C]??0);C===0?e.moveTo(S,T):e.lineTo(S,T)});for(let k=84;k>=0;k-=1)e.lineTo(k/84*t,(y[k]??n/2)+(b[k]??0));e.closePath();const w=e.createLinearGradient(0,0,t,0);w.addColorStop(0,"transparent"),w.addColorStop(.1,o),w.addColorStop(.9,o),w.addColorStop(1,"transparent"),e.fillStyle=w,e.globalAlpha=c*(.22+s*.03),e.shadowColor=o,e.shadowBlur=28+s*4,e.fill()}const Eee=[{id:"idle",labelKey:"home.phase.idle",icon:iU},{id:"listening",labelKey:"home.phase.listening",icon:Ij},{id:"thinking",labelKey:"home.phase.thinking",icon:VB},{id:"speaking",labelKey:"home.phase.speaking",icon:Vj}],sp=["#f97316","#7c3aed","#06b6d4"],gd={idle:{colors:sp,count:6,speed:1,amplitude:.2,waviness:.8,thickness:.7,glow:1.5,taper:1.4,spread:.9,hueShift:0,intensity:.4,saturation:3,opacity:1,scale:2},listening:{colors:sp,count:6,speed:1.7,amplitude:1.4,waviness:1.1,thickness:.75,glow:4.2,taper:1.4,spread:1.7,hueShift:0,intensity:.8,saturation:3,opacity:1,scale:2.1},thinking:{colors:sp,count:6,speed:1.5,amplitude:1.2,waviness:1.5,thickness:.8,glow:4,taper:4.7,spread:2,hueShift:0,intensity:.9,saturation:3,opacity:1,scale:1.6},speaking:{colors:sp,count:6,speed:1.5,amplitude:2.3,waviness:2.5,thickness:1.4,glow:4,taper:1.6,spread:2,hueShift:0,intensity:.9,saturation:3,opacity:1,scale:2.35}},kee=[{key:"count",labelKey:"home.customize.count",min:1,max:8,step:1},{key:"speed",labelKey:"home.customize.speed",min:0,max:2,step:.05},{key:"amplitude",labelKey:"home.customize.amplitude",min:0,max:2.5,step:.05},{key:"waviness",labelKey:"home.customize.waviness",min:.2,max:3,step:.05},{key:"thickness",labelKey:"home.customize.thickness",min:.1,max:1.5,step:.05},{key:"glow",labelKey:"home.customize.glow",min:0,max:5,step:.1},{key:"taper",labelKey:"home.customize.taper",min:.2,max:6,step:.1},{key:"spread",labelKey:"home.customize.spread",min:0,max:2.5,step:.05},{key:"hueShift",labelKey:"home.customize.hueShift",min:0,max:1,step:.01},{key:"intensity",labelKey:"home.customize.intensity",min:0,max:1,step:.05},{key:"saturation",labelKey:"home.customize.saturation",min:0,max:3,step:.05},{key:"opacity",labelKey:"home.customize.opacity",min:0,max:1,step:.05},{key:"scale",labelKey:"home.customize.scale",min:.5,max:2.5,step:.05}];function yd(e){return{...e,colors:[...e.colors]}}function See(){return{idle:yd(gd.idle),listening:yd(gd.listening),thinking:yd(gd.thinking),speaking:yd(gd.speaking)}}function Nee(e,t){e.getByteTimeDomainData(t);let n=0;for(const i of t){const s=(i-128)/128;n+=s*s}return Math.min(1,Math.sqrt(n/t.length)*3.4)}function YC(e){return e.replace(/```[\s\S]*?```/g,"").replace(/[`*_>#\[\]()]/g,"").replace(/\s+/g," ").trim()}function cv(e){return/\.(png|jpe?g|gif|webp|svg|bmp|avif)$/i.test(e)}function RO(e){const t=e.lastIndexOf(".");return((t>=0?e.slice(t+1):"")||"file").toUpperCase().slice(0,5)}const DO="mcp__sps__present_form";function _ee(e){var i;if(!e)return null;let t=null;if(Array.isArray(e.fields)&&e.fields.length>0?t=e:e.template==="image"&&(t={...ix,title:e.title||ix.title,description:e.description??ix.description,...e.submitLabel?{submitLabel:e.submitLabel}:{},...e.skipLabel?{skipLabel:e.skipLabel}:{}}),!t||!((i=t.fields)!=null&&i.length))return null;const n=e.defaults;return n&&typeof n=="object"&&(t={...t,fields:t.fields.map(s=>s.id in n?{...s,default:n[s.id]}:s)}),t}function Cee(e){var n;if(!e)return null;const t=e.filter(i=>i.type==="tool_use"&&i.title===DO);return _ee((n=t[t.length-1])==null?void 0:n.input)}function XC(e){if(RR(e.schema))return{submitLabel:"提交并继续",...e.schema};const t=e.schema&&typeof e.schema=="object"&&!Array.isArray(e.schema)?e.schema:{},n=new Set(t.required??[]),i=Object.entries(t.properties??{}).map(([s,r])=>({id:s,label:r.title??s,type:Array.isArray(r.enum)?"select":r.type==="boolean"?"toggle":r.type==="number"?"number":r.format==="textarea"?"textarea":"text",...Array.isArray(r.enum)?{options:r.enum.map(o=>({value:String(o),label:String(o)}))}:{},...r.default!==void 0?{default:r.default}:{},...n.has(s)?{required:!0}:{},...typeof r.description=="string"?{hint:r.description}:{}}));return{title:e.title,...t.description?{description:t.description}:{},submitLabel:"提交并继续",fields:i}}const OO="[表单已提交]",LO="[让 AI 来定";function Tee(e,t){for(let n=t+1;n<e.length;n++){const i=e[n],s=i==null?void 0:i.content;if((i==null?void 0:i.role)==="user"&&typeof s=="string"&&(s.startsWith(OO)||s.startsWith(LO)))return!0}return!1}function Aee(e,t){for(let n=t+1;n<e.length;n++){const i=e[n],s=i==null?void 0:i.content;if(!((i==null?void 0:i.role)!=="user"||typeof s!="string")){if(s.startsWith(LO))return;if(s.startsWith(OO)){const r=s.match(/```json\s*([\s\S]*?)```/);if(!(r!=null&&r[1]))return;try{return JSON.parse(r[1])}catch{return}}}}}function jee({sessionId:e,paths:t,onImagePreview:n}){return!e||!t.length?null:d.jsx("div",{className:"voice-msg-attachments",children:t.map(i=>{const s=i.split("/").pop()??i,r=$o(e,i);return cv(i)&&n?d.jsx("button",{type:"button",className:"voice-msg-attach",title:s,onClick:()=>n(i),children:d.jsx("img",{src:r,alt:s,loading:"lazy",decoding:"async"})},i):d.jsx("a",{href:r,target:"_blank",rel:"noreferrer",className:"voice-msg-attach",title:s,children:cv(i)?d.jsx("img",{src:r,alt:s,loading:"lazy",decoding:"async"}):d.jsxs(d.Fragment,{children:[d.jsx(Uc,{size:22,strokeWidth:1.7,"aria-hidden":"true"}),d.jsx("span",{className:"voice-msg-attach-ext",children:RO(s)})]})},i)})})}const Lo="sps.home.session",Mee=720*60*1e3;function Ree(e){if(!e)return"";try{const t=new Date(e),n=new Date;return t.toDateString()===n.toDateString()?t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):t.toLocaleDateString([],{month:"numeric",day:"numeric"})}catch{return""}}function Dee(e){if(!e)return"";try{return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}catch{return""}}function QC(e){return e.map(t=>{var n;return{id:t.id,role:t.role,content:t.content||(((n=t.blocks)==null?void 0:n.map(i=>i.type==="text"?i.text:"").join(""))??""),status:"complete",...t.blocks&&t.blocks.length?{blocks:t.blocks}:{}}})}function wx({outputAnalyser:e=null}){var Ke,gt;const t=Xe(),{sessionId:n}=qv(),[i,s]=_.useState("idle"),r=_.useRef("idle");r.current=i;const[o,c]=aa("sps.voice.autoListen",!1),[u,f]=_.useState("idle"),[p,m]=_.useState(!1),[y,b]=_.useState(""),[x,v]=aa("sps.sessions.listOpen",!1),[w,k]=_.useState(0),[C,S]=aa("sps.sessions.originTab","all"),[T,A]=_.useState(!1),[j]=_.useState(()=>{var V;return((V=window.matchMedia)==null?void 0:V.call(window,"(max-width: 700px)").matches)??!1}),[M,D]=_.useState(j),[P,I]=_.useState(""),[B,q]=_.useState(60),G=_.useRef(null),[R,O]=_.useState(()=>r9()?"draw":"done"),[z,W]=_.useState(See),X=_.useRef(null),K=_.useRef(null),U=_.useRef(null),F=_.useRef(null),Y=_.useRef(!0),[$,ie]=_.useState(!1),be=_.useCallback(()=>{const V=U.current;return!V||V.scrollHeight-V.scrollTop-V.clientHeight<40},[]),ce=_.useCallback(()=>{const V=U.current;V&&(typeof V.scrollTo=="function"?V.scrollTo({top:V.scrollHeight,behavior:"smooth"}):V.scrollTop=V.scrollHeight),Y.current=!0,ie(!1)},[]),Ne=_.useCallback(()=>{const V=U.current;V&&(typeof V.scrollTo=="function"?V.scrollTo({top:V.scrollHeight,behavior:"instant"}):V.scrollTop=V.scrollHeight)},[]),oe=_.useCallback(()=>{const V=be();Y.current=V,ie(!V)},[be]),pe=_.useRef(0),re=_.useRef(0),ee=_.useRef(0),ge=_.useRef(""),Ce=_.useRef(!1),Ie=_.useRef(!1),ae=_.useRef(!1),ke=XW(),Ue=mee(),Oe=z[i],ht=z[u],tt=V=>{V===re.current&&Ce.current&&ee.current===0&&s("idle")},jt=V=>{const xe=YC(V);if(!xe)return;const ze=re.current;ee.current+=1,Ue.enqueue(xe,()=>ze===re.current,()=>{ze===re.current&&(ee.current=Math.max(0,ee.current-1),tt(ze))})},Nt=V=>{ge.current+=V;let xe=ge.current.match(/^([\s\S]*?[。!?.!?])([\s\S]*)$/);for(;xe;)jt(xe[1]??""),ge.current=xe[2]??"",xe=ge.current.match(/^([\s\S]*?[。!?.!?])([\s\S]*)$/)},pt=()=>{re.current+=1,ee.current=0,ge.current="",Ce.current=!1,Ue.cancel()},Me=V=>{var xe;(xe=navigator.clipboard)==null||xe.writeText(V).catch(()=>{})},[We,ne]=_.useState(null),ve=_.useRef(0),Re=(V,xe)=>{if(We&&We.id===V){ve.current+=1,pt(),ne(null);return}const ze=YC(xe);if(!ze)return;ve.current+=1,pt();const _t=ve.current,ut=()=>_t===ve.current;Ue.resume(),ne({id:V,phase:"loading"}),Ue.enqueue(ze,ut,()=>{ut()&&ne(null)},()=>{ut()&&ne({id:V,phase:"playing"})})},ye=aY({onAssistantChunk:V=>{Ie.current=!0,ae.current&&(s("speaking"),Nt(V))},onAssistantComplete:V=>{Ce.current=!0,ae.current&&(Ie.current?ge.current.trim()&&jt(ge.current):jt(V)),ge.current="",tt(re.current)},onError:()=>{b(t("home.error.response")),s("idle")},onThinking:()=>{pt(),Ie.current=!1,b(""),s("thinking")}});_.useEffect(()=>{const V=`sps.home.draft:${ye.sessionId??"new"}`;I(localStorage.getItem(V)??"")},[ye.sessionId]);const Je=_.useCallback(V=>{I(V);try{localStorage.setItem(`sps.home.draft:${ye.sessionId??"new"}`,V)}catch{}},[ye.sessionId]),It=_.useCallback(()=>{I("");try{localStorage.removeItem(`sps.home.draft:${ye.sessionId??"new"}`)}catch{}},[ye.sessionId]);_.useEffect(()=>{const V=localStorage.getItem(Lo);if(!V)return;let xe={};try{xe=JSON.parse(V)}catch{}if(!n){if(!xe.id||!xe.ts||Date.now()-xe.ts>Mee){localStorage.removeItem(Lo);return}Ap(xe.id).then(ze=>{ye.resume(ze.id,QC(ze.messages)),Te(ze)}).catch(()=>localStorage.removeItem(Lo))}},[]),_.useEffect(()=>{ye.sessionId&&localStorage.setItem(Lo,JSON.stringify({id:ye.sessionId,ts:Date.now()}))},[ye.sessionId,ye.messages.length]);const[Wt,he]=_.useState([]),[le,Te]=_.useState(null),[Ae,Qe]=_.useState(null),[st,$e]=_.useState(null),[nt,qt]=_.useState(null),[Xt,Dt]=_.useState(null),Q=(()=>{const V=ye.activeInteraction;return V&&(V.kind==="form"||V.kind==="choices")?V:null})(),we=Q?XC(Q):null,[Pe,ct]=_.useState(""),[Qt,Ht]=_.useState(0),He=(V,xe,ze)=>{ct("");const _t=_W(xe,ze)||"(已确认)";if(V.respond==="message"){ye.send(_t,void 0,{id:V.id,answer:ze});return}const ut=ye.sessionId;if(!ut)return;const yn=Object.fromEntries(Object.entries(ze).filter(([,Zt])=>Zt!==""&&Zt!=null));P0(ut,V.id,yn,V.revision).catch(Zt=>{ct(Zt instanceof Error?Zt.message:String(Zt)),Ht(ps=>ps+1)})},[Fe,rt]=_.useState(!1);_.useEffect(()=>{if(!Xt)return;const V=xe=>{xe.key==="Escape"&&(xe.preventDefault(),Dt(null))};return window.addEventListener("keydown",V),()=>window.removeEventListener("keydown",V)},[Xt]),_.useEffect(()=>{if(!ye.sessionId){Te(null),he([]);return}ye.isSending||Ap(ye.sessionId).then(V=>{he(V.artifacts??[]),Te(V)}).catch(()=>{})},[ye.sessionId,ye.isSending,ye.messages.length]);const hn=tn(),ki=((Ke=ot({queryKey:["chat-sessions"],queryFn:DW,refetchInterval:5e3}).data)==null?void 0:Ke.data)??[],us=[...new Set(ki.map(V=>V.origin??"sps"))].sort(),ds=C!=="all"&&!us.includes(C)?"all":C,Di=ds==="all"?ki:ki.filter(V=>(V.origin??"sps")===ds),pn=V=>V.lastMessageAt??V.createdAt,In=b0(Di,pn,7),Yn=b0(In.older,pn,30),Ds=V=>V.id===ye.sessionId,jr=[...In.recent,...w>=1?Yn.recent:Yn.recent.filter(Ds),...w>=2?Yn.older:Yn.older.filter(Ds)],Os=Yn.recent.length+Yn.older.length,Mr=Yn.older.length,fs=V=>{V!==ye.sessionId&&Ap(V).then(xe=>{ye.resume(V,QC(xe.messages)),Te(xe),he(xe.artifacts??[]),s("idle"),b(""),localStorage.setItem(Lo,JSON.stringify({id:V,ts:Date.now()}))}).catch(()=>{})};_.useEffect(()=>{n&&n!==ye.sessionId&&fs(n)},[n]);const Rr=V=>{A(!1),PR({...V,dedicated:!V.cwd}).then(xe=>{ye.resume(xe.id,[]),he([]),Te(null),rt(!1),s("idle"),b(""),localStorage.setItem(Lo,JSON.stringify({id:xe.id,ts:Date.now()})),hn.invalidateQueries({queryKey:["chat-sessions"]})}).catch(()=>{})},Xn=/\.(png|jpe?g|gif|webp|avif|svg|bmp)$/i,Gi=/\.(md|markdown|txt|log|json|ya?ml|csv|tsv|html?|css|jsx?|tsx?|py|sh|toml|ini|sql)$/i,Si=V=>{const xe=le==null?void 0:le.cwd;return xe?V.startsWith("/")?V:`${xe.replace(/\/$/,"")}/${V}`:null},hs=V=>{const xe=Si(V),ze=ye.sessionId;if(!xe||!ze)return;if(Xn.test(V)){Qe(xe);return}const _t=$o(ze,xe);if(!Gi.test(V)){window.open(_t,"_blank","noopener");return}$e({rel:V,text:null}),fetch(_t).then(ut=>ut.ok?ut.text():Promise.reject(new Error(String(ut.status)))).then(ut=>$e({rel:V,text:ut})).catch(ut=>$e({rel:V,text:null,error:ut instanceof Error?ut.message:String(ut)}))},vn=(V,xe)=>{xe.stopPropagation(),qt({id:V})},Dr=(V,xe)=>{qt(null),OW(V,xe).then(()=>{hn.invalidateQueries({queryKey:["chat-sessions"]}),V===ye.sessionId&&ma()}).catch(()=>{})},Qn=YW({onComplete:V=>{ke.stop(),ae.current=!0;const xe=Wi.map(ze=>ze.path);Y.current=!0,ie(!1),ye.send(V,xe.length?xe:void 0),xe.length&&yi([])},onError:V=>{ke.stop(),b(t(V==="unsupported"?"home.error.recognitionUnsupported":"home.error.recognition")),s("idle")}}),jn=_.useRef(Qn);jn.current=Qn;const je=()=>{i!=="idle"||ye.isSending||ii||(b(""),Ue.resume(),pt(),Qn.start()&&(s("listening"),ke.start()))},Ye=()=>{i==="listening"?Qn.stop():je()},xt=_.useRef(Ye);xt.current=Ye;const Pt=V=>{c(V),b(""),V?Ue.resume():r.current==="idle"&&jn.current.isListening&&jn.current.cancel()};_.useEffect(()=>{if(!(o&&i==="idle"&&!M&&Qn.supported))return;const xe=window.setTimeout(()=>{jn.current.isListening||jn.current.start()},400);return()=>{window.clearTimeout(xe),r.current==="idle"&&jn.current.isListening&&jn.current.cancel()}},[o,i,M,Qn.supported]);const gn=()=>{i!=="idle"||ye.isSending||ii||jn.current.isListening&&(b(""),Ue.resume(),pt(),s("listening"),ke.start())};tY({enabled:o,phase:i,suspended:M||ye.isSending,analyser:ke.analyser,transcript:Qn.transcript,onTrigger:gn,onEndpoint:()=>jn.current.stop(),onAbort:()=>{jn.current.cancel(),ke.stop(),s("idle")}});const Un=22,ci=18,ti=()=>{const V=G.current;if(!V)return;V.style.height="auto";const xe=Un*3+ci,ze=Math.min(V.scrollHeight,xe);V.style.height=`${ze}px`,V.style.overflowY=V.scrollHeight>xe?"auto":"hidden",q(Math.max(60,ze+16))},Vt=()=>{q(60);const V=G.current;V&&(V.style.height="auto",V.style.overflowY="hidden")},ni=()=>{const V=P.trim();if(!V&&Wi.length===0||ye.isSending)return;const xe=Wi.map(ze=>ze.path);It(),Vt(),yi([]),b(""),ae.current=!1,Y.current=!0,ie(!1),ye.send(V,xe.length?xe:void 0)},Or=i==="thinking"||i==="speaking",ii=((le==null?void 0:le.readonly)??!1)&&(le==null?void 0:le.id)===ye.sessionId,si=M&&!Or&&!ii,Ls=_.useRef(!1);_.useEffect(()=>{if(!Ls.current){Ls.current=!0;return}if(j)return;document.documentElement.dataset.morphing="true";const V=setTimeout(()=>{delete document.documentElement.dataset.morphing},850);return()=>clearTimeout(V)},[i,si,j]),_.useEffect(()=>()=>{delete document.documentElement.dataset.morphing},[]),_.useEffect(()=>{if(M||o||ii)return;const V=xe=>{if(xe.code!=="Space"&&xe.key!==" "||xe.repeat)return;const ze=xe.target;ze&&(ze.tagName==="INPUT"||ze.tagName==="TEXTAREA"||ze.isContentEditable)||(xe.preventDefault(),xt.current())};return window.addEventListener("keydown",V),()=>window.removeEventListener("keydown",V)},[M,o,ii]);const ma=()=>{ye.reset(),localStorage.removeItem(Lo),he([]),rt(!1),s("idle"),b(""),It(),Vt()},ri=()=>{ye.sessionId&&zR(ye.sessionId).catch(()=>{}),pt(),s("idle")},[Wi,yi]=_.useState([]),[Is,Mn]=_.useState(!1),[rr,ar]=_.useState(!1),lt=async V=>{if(V.size>UR){b(`文件超过 50 MB(${(V.size/1024/1024).toFixed(1)} MB):${V.name}`);return}Mn(!0);try{const xe=await ye.ensureSession(),ze=await nx(xe,V);yi(_t=>[..._t,{path:ze.path,name:ze.name}])}catch(xe){b(xe instanceof Error?xe.message:String(xe))}finally{Mn(!1)}},Sl=V=>{yi(xe=>xe.filter(ze=>ze.path!==V))};_.useEffect(()=>{var yn;const V=X.current;if(!V)return;if(((yn=window.matchMedia)==null?void 0:yn.call(window,"(prefers-reduced-motion: reduce)").matches)??!1){V.style.setProperty("--voice-activity","0"),V.style.setProperty("--voice-scale","1");return}let ze=0,_t=new Uint8Array(new ArrayBuffer(2048));const ut=Zt=>{const ps=i==="listening"?ke.analyser:i==="speaking"?Ue.analyser??e:null;ps&&_t.length!==ps.fftSize&&(_t=new Uint8Array(new ArrayBuffer(ps.fftSize)));let Lr=ps?Nee(ps,_t):0;if(!ps&&i==="speaking"){const Nl=Zt/1e3;Lr=.16+(.5+Math.sin(Nl*6.8)*.5)*.34+(.5+Math.sin(Nl*11.4+1.2)*.5)*.16}const or=Lr>pe.current?.16:.065;pe.current+=(Lr-pe.current)*or,V.style.setProperty("--voice-scale",(1+pe.current*.065).toFixed(4)),V.style.setProperty("--voice-activity",pe.current.toFixed(3)),ze=window.requestAnimationFrame(ut)};return ze=window.requestAnimationFrame(ut),()=>window.cancelAnimationFrame(ze)},[ke.analyser,Ue.analyser,e,i]),_.useEffect(()=>{Y.current&&Ne()},[i,Qn.transcript,ye.messages,Ne]);const _n=ye.messages.some(V=>V.status==="streaming");_.useEffect(()=>{if(!_n)return;let V=0;const xe=()=>{const ze=U.current;ze&&Y.current&&ze.scrollHeight-ze.scrollTop-ze.clientHeight>=1&&Ne(),V=window.requestAnimationFrame(xe)};return V=window.requestAnimationFrame(xe),()=>window.cancelAnimationFrame(V)},[_n,Ne]),_.useEffect(()=>{if(Qe(null),!ye.sessionId)return;Y.current=!0,ie(!1);const V=window.setTimeout(()=>{Y.current&&Ne()},400);return()=>window.clearTimeout(V)},[ye.sessionId]),_.useEffect(()=>{if(!p)return;const V=xe=>{xe.key==="Escape"&&m(!1)};return window.addEventListener("keydown",V),()=>window.removeEventListener("keydown",V)},[p]),_.useEffect(()=>()=>{pt(),ke.stop()},[]);const Kt=_.useMemo(()=>({amplitude:Oe.amplitude,colors:Oe.colors,count:Oe.count,glow:Oe.glow,hueShift:Oe.hueShift,intensity:Oe.intensity,opacity:Oe.opacity,saturation:Oe.saturation,scale:Oe.scale,speed:Oe.speed,spread:Oe.spread,thickness:Oe.thickness,waviness:Oe.waviness}),[Oe]),Ps=(V,xe)=>{if(!Number.isFinite(xe))return;const ze=Math.min(V.max,Math.max(V.min,xe));W(_t=>({..._t,[u]:{..._t[u],[V.key]:ze}}))},zs=(V,xe)=>{W(ze=>{const _t=[...ze[u].colors];return _t[V]=xe,{...ze,[u]:{...ze[u],colors:_t}}})},go=_.useMemo(()=>{var V;return((V=[...ye.messages].reverse().find(xe=>xe.role==="assistant"))==null?void 0:V.content)??""},[ye.messages]),Bs=i==="listening"&&ke.status==="requesting"?t("home.mic.requesting"):t(`home.phase.${i}`),Le=ye.messages.some(V=>V.role==="assistant"&&V.status==="streaming");return d.jsxs("div",{className:"home-shell","data-list-open":x?"true":"false",children:[T&&d.jsx(hY,{onCancel:()=>A(!1),onCreate:Rr}),Ae&&ye.sessionId&&d.jsx($W,{sessionId:ye.sessionId,path:Ae,onClose:()=>Qe(null)}),st&&d.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-[rgba(45,55,72,0.6)] p-4",role:"presentation",onClick:()=>$e(null),children:d.jsxs("div",{className:"nb-card w-full max-w-3xl max-h-[85vh] flex flex-col gap-2",onClick:V=>V.stopPropagation(),children:[d.jsxs("div",{className:"flex items-center gap-3",children:[d.jsx("span",{className:"font-[family-name:var(--font-heading)] font-bold text-sm flex-1 min-w-0 truncate",children:st.rel}),ye.sessionId&&Si(st.rel)&&d.jsx("a",{className:"nb-btn text-xs",href:$o(ye.sessionId,Si(st.rel)),download:st.rel.split("/").pop(),children:t("home.artifacts.download")}),d.jsx("button",{type:"button",className:"nb-btn text-xs",onClick:()=>$e(null),children:t("common.close")})]}),d.jsx("pre",{className:"file-preview-body",children:st.error?`${t("home.artifacts.loadFailed")}: ${st.error}`:st.text??t("home.artifacts.loading")})]})}),nt&&d.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-[rgba(45,55,72,0.6)] p-4",role:"presentation",onClick:()=>qt(null),children:d.jsxs("div",{className:"nb-card w-full max-w-md flex flex-col gap-3",onClick:V=>V.stopPropagation(),children:[d.jsx("div",{className:"font-[family-name:var(--font-heading)] font-bold text-base",children:t("home.sessions.deleteTitle")}),d.jsx("p",{className:"text-xs text-[var(--color-text-muted)] leading-relaxed m-0",children:t("home.sessions.deleteHint")}),d.jsxs("div",{className:"flex flex-wrap gap-2 justify-end pt-1",children:[d.jsx("button",{type:"button",className:"nb-btn text-xs",onClick:()=>qt(null),children:t("common.cancel")}),d.jsx("button",{type:"button",className:"nb-btn text-xs",onClick:()=>Dr(nt.id,!1),children:t("home.sessions.deleteSessionOnly")}),d.jsx("button",{type:"button",className:"nb-btn text-xs",style:{borderColor:"var(--color-crashed)",color:"var(--color-crashed)"},onClick:()=>Dr(nt.id,!0),children:t("home.sessions.deleteWithWorkspace")})]})]})}),Xt&&d.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-[rgba(45,55,72,0.6)] p-4",role:"presentation",onClick:()=>Dt(null),children:d.jsxs("div",{className:"w-full max-w-lg max-h-[88vh] overflow-auto",onClick:V=>V.stopPropagation(),children:[Xt.error&&d.jsxs("div",{className:"nb-card mb-2 px-3 py-2 text-xs text-[var(--color-crashed)]",children:["提交失败:",Xt.error]}),d.jsx(C2,{spec:Xt.spec,disabled:Xt.readOnly,initialValues:Xt.values,onSubmit:V=>{const xe=Xt.interaction;if(xe){const ze=Object.fromEntries(Object.entries(V).filter(([,ut])=>ut!==""&&ut!=null)),_t=ye.sessionId;if(!_t)return;P0(_t,xe.id,ze,xe.revision).then(()=>Dt(null)).catch(ut=>Dt(yn=>yn&&{...yn,values:V,error:ut instanceof Error?ut.message:String(ut),panelKey:(yn.panelKey??0)+1}));return}ye.send("[表单已提交]\n```json\n"+JSON.stringify(V,null,2)+"\n```"),Dt(null)},onSkip:()=>{ye.send("[让 AI 来定,按各字段推荐值 + 我们的对话补全,不用再逐项问我]"),Dt(null)},onUpload:async V=>{const xe=await ye.ensureSession();return(await nx(xe,V)).path}},Xt.panelKey??0)]})}),d.jsx("aside",{className:`home-sessions ${x?"is-open":""}`,children:x?d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"home-sessions-head",children:[d.jsx("span",{className:"home-sessions-title",children:t("chat.list.title")}),d.jsxs("div",{className:"home-sessions-head-actions",children:[d.jsx("button",{type:"button",className:"nb-btn",style:{padding:"5px 8px"},onClick:()=>A(!0),"aria-label":t("chat.list.new"),title:t("chat.list.new"),children:d.jsx(Gn,{size:14,strokeWidth:3})}),d.jsx("button",{type:"button",className:"nb-btn",style:{padding:"5px 8px"},onClick:()=>v(!1),"aria-label":t("home.sessions.collapse"),title:t("home.sessions.collapse"),children:d.jsx(YN,{size:14,strokeWidth:2.2})})]})]}),us.length>1&&d.jsx(eM,{origins:us,active:ds,allLabel:t("home.sessions.tabAll"),onChange:S}),d.jsxs("div",{className:"home-sessions-list",children:[jr.map((V,xe)=>d.jsx(au,{index:xe,children:d.jsxs("div",{className:`home-session-row ${V.id===ye.sessionId?"is-active":""}`,children:[d.jsxs("button",{type:"button",className:"home-session-main",onClick:()=>fs(V.id),title:V.title,children:[d.jsx($U,{size:13,strokeWidth:2.5,className:"shrink-0"}),d.jsx("span",{className:"home-session-title",children:V.title}),V.source==="cli"&&d.jsx("span",{className:"nb-badge text-[9px] shrink-0",title:t("chat.cliBadge.tooltip"),children:t("chat.cliBadge")}),d.jsxs("span",{className:"home-session-meta",style:{display:"flex",gap:6,alignItems:"center"},children:[V.lastMessageAt&&d.jsx("span",{title:new Date(V.lastMessageAt).toLocaleString(),children:Ree(V.lastMessageAt)}),d.jsx("span",{style:{opacity:.6},children:V.messageCount})]})]}),d.jsx("button",{type:"button",className:"home-session-del",onClick:ze=>vn(V.id,ze),"aria-label":t("home.sessions.delete"),title:t("home.sessions.delete"),children:d.jsx(Rs,{size:16,strokeWidth:2.4})})]})},V.id)),w===0&&Os>0&&d.jsx("button",{type:"button",className:"nb-btn text-xs self-start mt-1",onClick:()=>k(1),children:t("home.sessions.expandWeek",{count:Os})}),w===1&&(Mr>0?d.jsx("button",{type:"button",className:"nb-btn text-xs self-start mt-1",onClick:()=>k(2),children:t("home.sessions.expandMonth",{count:Mr})}):d.jsx("button",{type:"button",className:"nb-btn text-xs self-start mt-1",onClick:()=>k(0),children:t("home.sessions.collapseOld")})),w===2&&d.jsx("button",{type:"button",className:"nb-btn text-xs self-start mt-1",onClick:()=>k(0),children:t("home.sessions.collapseOld")})]})]}):d.jsx("button",{type:"button",className:"home-sessions-rail",onClick:()=>v(!0),"aria-label":t("home.sessions.open"),title:t("home.sessions.open"),children:d.jsx(YN,{size:18,strokeWidth:2.2})})}),d.jsxs("section",{className:["voice-home",R==="draw"?"voice-home--intro-hidden":"",R==="reveal"?"voice-home--intro-reveal":""].join(" "),"aria-labelledby":"voice-home-title",children:[R!=="done"&&d.jsx(i9,{targetRef:X,panelRef:K,onReveal:()=>O("reveal"),onDone:()=>O("done")}),d.jsxs("div",{ref:K,className:"voice-conversation","data-phase":i,children:[le&&d.jsxs("div",{className:"voice-convo-header",children:[d.jsxs("button",{type:"button",className:"voice-convo-title-btn",onClick:()=>rt(V=>!V),"aria-expanded":Fe,children:[d.jsx("span",{className:"voice-convo-title",children:le.title}),d.jsx(uo,{size:15,strokeWidth:2.5,className:["voice-convo-chevron",Fe?"is-open":""].join(" ")})]}),Fe&&d.jsxs("dl",{className:"voice-convo-details",children:[le.model&&d.jsxs(d.Fragment,{children:[d.jsx("dt",{children:"模型"}),d.jsx("dd",{children:le.model})]}),d.jsx("dt",{children:"session"}),d.jsx("dd",{children:le.id}),le.claudeSessionId&&d.jsxs(d.Fragment,{children:[d.jsx("dt",{children:"claude"}),d.jsx("dd",{children:le.claudeSessionId})]}),le.cwd&&d.jsxs(d.Fragment,{children:[d.jsx("dt",{children:"目录"}),d.jsx("dd",{children:le.cwd})]})]})]}),d.jsxs("div",{className:"relative flex-1 min-h-0 flex flex-col",children:[d.jsxs("div",{ref:U,className:"voice-message-stream","aria-live":"polite",onScroll:oe,children:[ye.messages.length===0&&i==="idle"&&d.jsxs("div",{className:"voice-empty-state",children:[d.jsx(WN,{size:18,strokeWidth:2,"aria-hidden":"true"}),d.jsx("p",{children:t("home.conversation.empty")})]}),ye.messages.map((V,xe)=>{var ze,_t;return d.jsxs("article",{className:`voice-message voice-message-${V.role}`,"data-streaming":V.status==="streaming",children:[d.jsxs("span",{children:[V.role==="user"?t("home.conversation.you"):t("home.conversation.ai"),V.role==="assistant"&&V.status==="streaming"&&d.jsxs("span",{className:"voice-live-status","data-phase":i,style:{marginLeft:8},children:[d.jsx("span",{"aria-hidden":"true"}),Bs]}),V.ts&&d.jsx("span",{style:{marginLeft:6,fontSize:10,opacity:.5,textTransform:"none",fontWeight:400,letterSpacing:0},title:new Date(V.ts).toLocaleString(),children:Dee(V.ts)})]}),d.jsxs("div",{className:"voice-bubble",children:[V.attachments&&V.attachments.length>0&&d.jsx(jee,{sessionId:ye.sessionId,paths:V.attachments,onImagePreview:ut=>Qe(ut)}),V.role==="assistant"&&V.status==="streaming"&&!V.content&&!((ze=V.blocks)!=null&&ze.length)&&d.jsxs("p",{className:"voice-thinking-line",children:[((_t=ye.thinking)==null?void 0:_t.trim())||t("home.conversation.thinking"),d.jsx("i",{"aria-hidden":"true"})]}),V.blocks&&V.blocks.length?d.jsxs("div",{className:"voice-blocks",children:[V.blocks.map((ut,yn)=>ut.type==="tool_use"&&FR(ut,(le==null?void 0:le.cwd)??null)||ut.type==="tool_use"&&ut.title===DO||ut.type==="interaction"&&Q&&ut.id===Q.id?null:d.jsx(GW,{block:ut,streaming:V.status==="streaming",sessionId:ye.sessionId??void 0,onOpenForm:Zt=>Dt({spec:XC(Zt),readOnly:Zt.status!=="pending",values:Zt.status!=="pending"&&Zt.answer&&typeof Zt.answer=="object"?Zt.answer:void 0,...Zt.status==="pending"&&Zt.respond!=="message"?{interaction:{id:Zt.id,revision:Zt.revision}}:{}})},yn)),(()=>{const ut=Cee(V.blocks);if(!ut)return null;const yn=Tee(ye.messages,xe);return d.jsx("div",{className:"mt-1",children:d.jsxs("button",{type:"button",className:yn?"nb-btn text-xs":"nb-btn nb-btn-primary text-sm",onClick:()=>Dt({spec:ut,readOnly:yn,values:yn?Aee(ye.messages,xe):void 0}),children:[d.jsx(XN,{size:14,strokeWidth:2.5}),yn?`${ut.title} · 已提交 ✓(点击查看)`:`${ut.title} · 点击填写配置`]})})})(),(()=>{const ut=UW(V.blocks,(le==null?void 0:le.cwd)??null);return ut.length>0&&ye.sessionId?d.jsx("div",{className:"flex flex-col items-start gap-2 mt-1",children:ut.map(yn=>d.jsx(FW,{sessionId:ye.sessionId,path:yn,onPreview:()=>Qe(yn)},yn))}):null})()]}):V.status==="streaming"?d.jsx($R,{text:V.content}):d.jsx(MR,{text:V.content}),V.truncated&&d.jsx("p",{className:"mt-2 px-2 py-1 rounded-md text-[11px] font-semibold bg-[var(--color-stuck-bg)] text-[var(--color-stuck)] border-2 border-[var(--color-stuck)]",children:t("chat.message.truncated")}),V.role==="assistant"&&V.status!=="streaming"&&V.content&&d.jsxs("div",{className:"voice-bubble-actions",children:[d.jsx("button",{type:"button",onClick:()=>Me(V.content),"aria-label":t("home.copy"),title:t("home.copy"),children:d.jsx(Oj,{size:13,strokeWidth:2.5})}),d.jsx("button",{type:"button",onClick:()=>Re(V.id,V.content),"aria-label":(We==null?void 0:We.id)===V.id?t("home.stop"):t("home.play"),title:(We==null?void 0:We.id)===V.id?t("home.stop"):t("home.play"),"data-active":(We==null?void 0:We.id)===V.id?"true":void 0,children:(We==null?void 0:We.id)===V.id?We.phase==="loading"?d.jsx(mt,{size:13,strokeWidth:2.5,className:"animate-spin"}):d.jsx(m0,{size:16,strokeWidth:2.4,fill:"currentColor"}):d.jsx(Vj,{size:13,strokeWidth:2.5})})]})]})]},V.id)}),i==="listening"&&d.jsxs("article",{className:"voice-message voice-message-user voice-message-live",children:[d.jsx("span",{children:t("home.conversation.you")}),d.jsx("p",{children:Qn.transcript||t("home.conversation.listening")})]}),i==="thinking"&&!Le&&d.jsxs("article",{className:"voice-message voice-message-assistant voice-message-thinking",children:[d.jsxs("span",{children:[t("home.conversation.ai"),d.jsxs("span",{className:"voice-live-status","data-phase":i,style:{marginLeft:8},children:[d.jsx("span",{"aria-hidden":"true"}),Bs]})]}),d.jsxs("p",{children:[((gt=ye.thinking)==null?void 0:gt.trim())||t("home.conversation.thinking"),d.jsx("i",{"aria-hidden":"true"})]})]})]}),$&&d.jsx("button",{type:"button",onClick:ce,"aria-label":t("logs.scroll.bottom.aria"),title:t("logs.scroll.bottom.aria"),className:"absolute bottom-3 right-4 z-10 w-9 h-9 flex items-center justify-center rounded-full border-2 border-[var(--color-text)] bg-[var(--color-bg)] shadow-[2px_2px_0_var(--color-text)] hover:shadow-[3px_3px_0_var(--color-text)] transition-shadow",children:d.jsx(zB,{size:16,strokeWidth:2.5})})]}),Wt.length>0&&d.jsxs("div",{className:"voice-artifacts","aria-label":t("home.artifacts.label"),children:[d.jsx(Uc,{size:13,strokeWidth:2.5,"aria-hidden":"true"}),d.jsxs("span",{className:"voice-artifacts-title",children:[t("home.artifacts.label")," (",Wt.length,")"]}),d.jsxs("div",{className:"voice-artifacts-list",children:[Wt.slice(0,6).map(V=>d.jsx("button",{type:"button",className:"voice-artifacts-chip is-clickable",title:`${V}(点击查看/下载)`,onClick:()=>hs(V),children:V.split("/").pop()},V)),Wt.length>6&&d.jsxs("span",{className:"voice-artifacts-chip",children:["+",Wt.length-6]})]})]}),Q&&we&&d.jsxs("div",{className:"interaction-dock","aria-label":Q.title,children:[Pe&&d.jsxs("div",{className:"interaction-dock-error",children:["提交失败:",Pe]}),d.jsx(C2,{spec:we,layout:"region",...ye.sessionId?{previewUrl:V=>$o(ye.sessionId,V)}:{},onSubmit:V=>He(Q,we,V),onSkip:()=>{ye.send("[让 AI 来定,按各字段推荐值 + 我们的对话补全,不用再逐项问我]")},onUpload:async V=>{const xe=await ye.ensureSession();return(await nx(xe,V)).path}},`${Q.id}:${Qt}`)]}),d.jsxs("div",{className:"voice-dock","data-drag":rr?"true":"false",onDragOver:V=>{V.dataTransfer.types.includes("Files")&&(V.preventDefault(),V.dataTransfer.dropEffect="copy",rr||ar(!0))},onDragLeave:V=>{V.currentTarget.contains(V.relatedTarget)||ar(!1)},onDrop:V=>{if(V.dataTransfer.types.includes("Files")){V.preventDefault(),ar(!1);for(const xe of Array.from(V.dataTransfer.files??[]))lt(xe)}},children:[y&&d.jsx("p",{className:"voice-error",role:"alert",children:y}),ii&&d.jsxs("div",{style:{padding:"10px 14px",margin:"0 0 8px",borderRadius:12,border:"2px solid var(--color-text)",background:"var(--color-bg-soft)",fontSize:13,lineHeight:1.5},children:[d.jsx("strong",{children:t("chat.cli.banner.bold")})," — ",t("chat.cli.banner"),d.jsxs("code",{style:{display:"block",marginTop:6,fontFamily:"var(--font-mono)",fontSize:12,opacity:.85},children:["sps agent --chat --name ",(ye.sessionId??"").replace(/^session-/,"")]})]}),(Wi.length>0||Is)&&d.jsxs("div",{className:"voice-attachments",children:[Wi.map(V=>d.jsxs("div",{className:"voice-attach-thumb",title:V.name,children:[cv(V.path)&&ye.sessionId?d.jsx("img",{src:$o(ye.sessionId,V.path),alt:V.name,loading:"lazy",decoding:"async"}):d.jsxs("div",{className:"voice-attach-doc",children:[d.jsx(Uc,{size:30,strokeWidth:1.6,"aria-hidden":"true"}),d.jsx("span",{className:"voice-attach-ext",children:RO(V.name)}),d.jsx("span",{className:"voice-attach-name",children:V.name})]}),d.jsx("button",{type:"button",className:"voice-attach-del",onClick:()=>Sl(V.path),"aria-label":t("home.attach.remove"),title:t("home.attach.remove"),children:d.jsx(En,{size:13,strokeWidth:3})})]},V.path)),Is&&d.jsx("div",{className:"voice-attach-thumb is-loading",children:d.jsx(mt,{size:16,className:"animate-spin"})})]}),d.jsxs("div",{className:"voice-orb-button","data-mode":si?"text":"voice",style:{...si?{"--pill-h":`${B}px`}:{},...ii?{opacity:.35,pointerEvents:"none"}:{}},children:[d.jsxs("div",{ref:X,className:"voice-flow-glass","data-phase":i,"data-mode":si?"text":"voice","data-glass":!j&&i!=="thinking"&&!si?"on":"off",role:"img","aria-label":t("home.visualizer.aria"),children:[d.jsx(gee,{phase:i,inputAnalyser:ke.analyser,outputText:go||t("home.message.speaking"),thinkingConfig:Kt}),!j&&d.jsx(rM,{active:i!=="thinking",activityLevelRef:pe,activityAnalyser:i==="listening"?ke.analyser:i==="speaking"?Ue.analyser??e:null,glass:i!=="thinking"&&!si,refraction:1.2,dispersion:1,glassSize:1,amplitude:Oe.amplitude,className:"voice-active-strands",colors:Oe.colors,count:Oe.count,glow:Oe.glow,hueShift:Oe.hueShift,intensity:Oe.intensity,opacity:Oe.opacity,saturation:Oe.saturation,scale:Oe.scale,speed:Oe.speed,spread:Oe.spread,taper:Oe.taper,thickness:Oe.thickness,waviness:Oe.waviness}),si&&d.jsxs("div",{className:"voice-input-inner",children:[d.jsx("textarea",{ref:G,className:"voice-input-field",rows:1,value:P,onChange:V=>{Je(V.target.value),ti()},onKeyDown:V=>{V.key==="Enter"&&!V.shiftKey&&!V.nativeEvent.isComposing&&(V.preventDefault(),ni())},onPaste:V=>{var ze;const xe=Array.from(((ze=V.clipboardData)==null?void 0:ze.items)??[]).filter(_t=>_t.kind==="file"&&_t.type.startsWith("image/"));if(xe.length!==0){V.preventDefault();for(const _t of xe){const ut=_t.getAsFile();ut&<(ut)}}},placeholder:t("home.text.placeholder"),"aria-label":t("home.text.placeholder")}),d.jsx("input",{ref:F,type:"file",multiple:!0,className:"hidden",onChange:V=>{for(const xe of Array.from(V.target.files??[]))lt(xe);V.target.value=""}}),d.jsx("button",{type:"button",className:"flex items-center justify-center w-9 h-9 rounded-full text-[var(--color-text-muted)] hover:text-[var(--color-text)] hover:bg-[var(--surface-control-hover)] transition-colors shrink-0",onClick:()=>{var V;return(V=F.current)==null?void 0:V.click()},disabled:ye.isSending,"aria-label":t("home.attach"),title:t("home.attach"),children:d.jsx(JU,{size:16,strokeWidth:2.5})}),d.jsx("button",{type:"button",className:"voice-send-btn",onClick:ni,disabled:!P.trim()||ye.isSending,"aria-label":t("home.text.send"),title:t("home.text.send"),children:d.jsx(m6,{size:16,strokeWidth:2.5})})]})]}),!M&&d.jsx("button",{type:"button",className:"voice-orb-hit",disabled:i==="thinking"||i==="speaking"||ii,"aria-label":t(i==="listening"?"home.voice.stop":"home.voice.start"),"aria-pressed":i==="listening",onClick:Ye}),Or&&d.jsx("button",{type:"button",className:"voice-stop-btn",onClick:ri,"aria-label":t("home.interrupt"),title:t("home.interrupt"),children:d.jsx(m0,{size:18,strokeWidth:0,fill:"currentColor","aria-hidden":"true"})})]}),d.jsx("p",{className:"voice-dock-label",children:t(M?"home.text.hint":i==="listening"?"home.voice.finish":i==="idle"&&o?"home.auto.armedOpen":`home.voice.${i}`)}),d.jsxs("div",{className:"voice-toggle-stack",children:[d.jsx(j2,{checked:M,onChange:D,title:t("home.inputToggle"),ariaLabel:t("home.inputToggle"),onIcon:d.jsx(WN,{size:16,strokeWidth:2.4}),offIcon:d.jsx(IU,{size:16,strokeWidth:2.4})}),!M&&!ii&&d.jsx(j2,{checked:o,onChange:Pt,title:t("home.auto.tip"),ariaLabel:t("home.auto.toggle"),onIcon:d.jsx(Ij,{size:16,strokeWidth:2.4}),offIcon:d.jsx(fU,{size:16,strokeWidth:2.4})})]})]})]}),p&&d.jsx("div",{className:"voice-debug-backdrop",role:"presentation",onMouseDown:V=>{V.target===V.currentTarget&&m(!1)},children:d.jsxs("section",{className:"voice-debug-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"voice-debug-title",children:[d.jsxs("header",{className:"voice-debug-header",children:[d.jsxs("div",{children:[d.jsx(XN,{size:16,strokeWidth:2.2,"aria-hidden":"true"}),d.jsx("h2",{id:"voice-debug-title",children:t("home.customize.title")})]}),d.jsxs("div",{children:[d.jsx("button",{type:"button","aria-label":t("home.customize.reset"),title:t("home.customize.reset"),onClick:()=>W(V=>({...V,[u]:yd(gd[u])})),children:d.jsx(Jv,{size:15,strokeWidth:2.2,"aria-hidden":"true"})}),d.jsx("button",{type:"button","aria-label":t("home.debug.close"),title:t("home.debug.close"),onClick:()=>m(!1),children:d.jsx(En,{size:16,strokeWidth:2.2,"aria-hidden":"true"})})]})]}),d.jsx("div",{className:"voice-debug-phases",role:"group","aria-label":t("home.phase.aria"),children:Eee.map(V=>{const xe=V.icon;return d.jsxs("button",{type:"button","aria-pressed":u===V.id,onClick:()=>f(V.id),children:[d.jsx(xe,{size:15,strokeWidth:2.2,"aria-hidden":"true"}),t(V.labelKey)]},V.id)})}),d.jsxs("div",{className:"voice-debug-body",children:[d.jsxs("fieldset",{className:"voice-customizer-group",children:[d.jsx("legend",{children:t("home.customize.colors")}),ht.colors.map((V,xe)=>d.jsxs("label",{className:"voice-color-control",children:[d.jsx("span",{children:t(`home.customize.color${xe+1}`)}),d.jsx("input",{type:"color",value:V,onChange:ze=>zs(xe,ze.target.value)}),d.jsx("code",{children:V.toUpperCase()})]},xe))]}),d.jsxs("fieldset",{className:"voice-customizer-group",children:[d.jsx("legend",{children:t("home.customize.parameters")}),kee.map(V=>{const xe=t(V.labelKey),ze=ht[V.key];return d.jsxs("label",{className:"voice-parameter-control",children:[d.jsx("span",{children:xe}),d.jsx("input",{type:"number",min:V.min,max:V.max,step:V.step,value:ze,"aria-label":`${xe} value`,onChange:_t=>Ps(V,Number(_t.target.value))}),d.jsx("input",{type:"range",min:V.min,max:V.max,step:V.step,value:ze,"aria-label":xe,onChange:_t=>Ps(V,Number(_t.target.value))})]},V.key)})]})]})]})})]})]})}const rp=e=>e.lastActivityAt?Date.parse(e.lastActivityAt):0;function IO(e,t){const n=[...e];return t==="name"?n.sort((i,s)=>i.name.localeCompare(s.name)):t==="date"?n.sort((i,s)=>rp(s)-rp(i)):n.sort((i,s)=>{const r=i.pipelineStatus==="running"?1:0,o=s.pipelineStatus==="running"?1:0;return r!==o?o-r:rp(s)-rp(i)})}function Oee(e){const t=new URLSearchParams;return e.project&&t.set("project",e.project),e.worker&&t.set("worker",e.worker),t.set("limit",String(e.limit)),e.since&&t.set("since",e.since),e.file&&t.set("file",e.file),St(`/api/logs?${t}`)}function Lee(e){return St(`/api/logs/sources?project=${encodeURIComponent(e)}`)}const Iee=["error","warn","info","debug"],Pee=["error","warn","info"];function zee({project:e,initialWorker:t}){const n=Xe(),i=t??"",[s,r]=_.useState([]),[o,c]=_.useState(!0),[u,f]=_.useState(()=>new Set(Pee)),[p,m]=_.useState(""),y=_.useRef(null),[b,x]=_.useState(""),{data:v}=ot({queryKey:["log-sources",e],queryFn:()=>Lee(e),enabled:!!e,refetchInterval:5e3}),w=_.useMemo(()=>(v==null?void 0:v.sources)??[],[v]),k=w.find(A=>A.key===b)??(i?w.find(A=>A.worker===Number(i)):void 0)??w.find(A=>A.kind==="pipeline")??w[0],C=k==null?void 0:k.file;_.useEffect(()=>{r([])},[e,C]);const{data:S}=ot({queryKey:["logs",e,C],queryFn:()=>Oee({project:e,file:C,limit:500}),enabled:!!e,refetchInterval:2500});_.useEffect(()=>{S!=null&&S.data&&r(S.data)},[S]),_.useEffect(()=>{if(!o)return;const A=y.current;A&&(A.scrollTop=A.scrollHeight)},[s,o]);const T=_.useMemo(()=>{const A=p.toLowerCase();return s.filter(j=>!(!u.has(j.level)||A&&!j.msg.toLowerCase().includes(A)))},[s,u,p]);return d.jsxs("div",{className:"flex h-full min-h-0 max-w-full flex-col gap-3",children:[d.jsxs("div",{className:"flex shrink-0 items-center gap-1.5 flex-wrap",children:[w.filter(A=>A.worker==null).map(A=>d.jsx(ZC,{s:A,active:(k==null?void 0:k.key)===A.key,onClick:()=>x(A.key)},A.key)),d.jsx("div",{className:"flex flex-1 min-w-0 items-center gap-1.5 flex-wrap",children:w.filter(A=>A.worker!=null).map(A=>d.jsx(ZC,{s:A,active:(k==null?void 0:k.key)===A.key,onClick:()=>x(A.key)},A.key))}),Iee.map(A=>d.jsx(Bee,{level:A,enabled:u.has(A),onToggle:()=>{f(j=>{const M=new Set(j);return M.has(A)?M.delete(A):M.add(A),M})}},A)),d.jsxs("div",{className:"relative min-w-[160px] max-w-xs",children:[d.jsx(mf,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-[var(--color-text-subtle)]"}),d.jsx("input",{className:"nb-input pl-9 w-full",placeholder:n("logs.filter.keyword.placeholder"),value:p,onChange:A=>m(A.target.value),"aria-label":n("logs.filter.keyword.aria")})]})]}),d.jsxs("div",{className:"scroll-frame flex min-h-0 flex-1 flex-col rounded-2xl border border-[var(--surface-card-border)] bg-[var(--color-bg-soft)]",children:[d.jsxs("div",{className:"px-4 py-2 bg-[var(--surface-table-head)] border-b-2 border-[var(--color-text)]/15 flex shrink-0 items-center justify-between font-[family-name:var(--font-mono)] text-xs",children:[d.jsxs("span",{className:"text-[var(--color-text-muted)]",children:[(S==null?void 0:S.file)??`~/.coral/projects/${e}/logs/*.log`," · ",s.length," lines"]}),d.jsx("span",{className:"nb-status",style:{background:"var(--color-running-bg)",color:"var(--color-running)"},children:"live"})]}),d.jsxs("div",{ref:y,className:"scroll-frame-body flex-1 bg-surface-input font-[family-name:var(--font-mono)] text-[12px] leading-[22px] p-2",onScroll:A=>{const j=A.currentTarget,M=j.scrollHeight-j.scrollTop-j.clientHeight<40;c(M)},children:[T.map((A,j)=>d.jsx(Uee,{line:A},j)),T.length===0&&d.jsx("div",{className:"text-center py-12 text-[var(--color-text-subtle)]",children:n("logs.empty.match")})]})]})]})}function Bee({level:e,enabled:t,onToggle:n}){const i={error:"var(--color-crashed-bg)",warn:"var(--color-stuck-bg)",info:"var(--color-secondary)",debug:"var(--color-accent-purple)"},s={error:"var(--color-crashed)",warn:"var(--color-stuck)",info:"var(--color-text)",debug:"var(--color-text)"};return d.jsx("button",{type:"button",onClick:n,"aria-pressed":t,className:["px-2.5 py-1 rounded-full text-xs font-bold border-[2px] border-[var(--color-text)] font-[family-name:var(--font-mono)] tracking-wide",t?"shadow-[1px_1px_0_var(--color-text)]":"bg-white text-[var(--color-text-muted)]"].join(" "),style:t?{background:i[e],color:s[e]}:{},children:e.toUpperCase()})}function Uee({line:e}){var n;const t={error:"bg-[var(--color-crashed-bg)] text-[var(--color-crashed)] border border-[var(--color-crashed-bg)]",warn:"bg-[var(--color-stuck-bg)] text-[var(--color-stuck)] border border-[var(--color-stuck-bg)]",info:"bg-[var(--color-info-bg)] text-[var(--color-info)] border border-[var(--color-info-bg)]",debug:"",trace:""};return d.jsxs("div",{className:"grid gap-2 px-2 py-0.5 rounded hover:bg-[var(--surface-control-hover)] grid-cols-[100px_60px_1fr]",children:[d.jsx("span",{className:"text-[var(--color-text-subtle)] whitespace-nowrap",children:e.ts?((n=e.ts.split("T")[1])==null?void 0:n.replace("Z",""))??e.ts:"--"}),d.jsx("span",{className:`text-center font-bold ${t[e.level]??""}`,style:{borderRadius:4,padding:"0 6px"},children:e.level.toUpperCase()}),d.jsx("span",{className:"truncate text-[var(--color-text)]",children:e.msg})]})}function ZC({s:e,active:t,onClick:n}){const i=e.status==="running"?"var(--color-running)":e.status==="error"?"var(--color-crashed)":"var(--color-idle)";return d.jsxs("button",{type:"button",onClick:n,"aria-pressed":t,"aria-label":`查看${e.label}日志`,className:["px-2.5 py-1 rounded-full text-xs font-bold border-[2px] border-[var(--color-text)] flex items-center gap-1.5",t?"bg-[var(--color-primary)] text-[var(--color-text)] shadow-[1px_1px_0_var(--color-text)]":"bg-white text-[var(--color-text-muted)]"].join(" "),children:[e.worker!=null&&d.jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:i,display:"inline-block"},"aria-hidden":!0}),e.label]})}function ou({options:e,value:t,onChange:n,ariaLabel:i,className:s=""}){const r=_.useRef(null),[o,c]=_.useState(null),u=Math.max(0,e.findIndex(f=>f.value===t));return _.useLayoutEffect(()=>{const f=r.current;if(!f)return;const p=()=>{const y=f.querySelector(`[data-idx="${u}"]`);if(!y)return;const b=f.getBoundingClientRect(),x=y.getBoundingClientRect();c({x:x.left-b.left-f.clientLeft,w:x.width})};p();const m=new ResizeObserver(p);return m.observe(f),()=>m.disconnect()},[u,e.length]),d.jsxs("div",{ref:r,className:`slide-tabs ${s}`,role:"tablist","aria-label":i,children:[o&&d.jsx("span",{className:"slide-tabs-bg","aria-hidden":"true",style:{transform:`translateX(${o.x}px)`,width:o.w}}),e.map((f,p)=>d.jsx("button",{"data-idx":p,type:"button",role:"tab","aria-selected":f.value===t,onClick:()=>n(f.value),className:`slide-tabs-label ${f.value===t?"is-active":""}`,children:f.label},f.value))]})}const iw=Symbol.for("yaml.alias"),uv=Symbol.for("yaml.document"),so=Symbol.for("yaml.map"),PO=Symbol.for("yaml.pair"),_r=Symbol.for("yaml.scalar"),lu=Symbol.for("yaml.seq"),As=Symbol.for("yaml.node.type"),mo=e=>!!e&&typeof e=="object"&&e[As]===iw,wl=e=>!!e&&typeof e=="object"&&e[As]===uv,cu=e=>!!e&&typeof e=="object"&&e[As]===so,kn=e=>!!e&&typeof e=="object"&&e[As]===PO,fn=e=>!!e&&typeof e=="object"&&e[As]===_r,uu=e=>!!e&&typeof e=="object"&&e[As]===lu;function Cn(e){if(e&&typeof e=="object")switch(e[As]){case so:case lu:return!0}return!1}function An(e){if(e&&typeof e=="object")switch(e[As]){case iw:case so:case _r:case lu:return!0}return!1}const zO=e=>(fn(e)||Cn(e))&&!!e.anchor,Hi=Symbol("break visit"),BO=Symbol("skip children"),kr=Symbol("remove node");function El(e,t){const n=UO(t);wl(e)?pc(null,e.contents,n,Object.freeze([e]))===kr&&(e.contents=null):pc(null,e,n,Object.freeze([]))}El.BREAK=Hi;El.SKIP=BO;El.REMOVE=kr;function pc(e,t,n,i){const s=FO(e,t,n,i);if(An(s)||kn(s))return $O(e,i,s),pc(e,s,n,i);if(typeof s!="symbol"){if(Cn(t)){i=Object.freeze(i.concat(t));for(let r=0;r<t.items.length;++r){const o=pc(r,t.items[r],n,i);if(typeof o=="number")r=o-1;else{if(o===Hi)return Hi;o===kr&&(t.items.splice(r,1),r-=1)}}}else if(kn(t)){i=Object.freeze(i.concat(t));const r=pc("key",t.key,n,i);if(r===Hi)return Hi;r===kr&&(t.key=null);const o=pc("value",t.value,n,i);if(o===Hi)return Hi;o===kr&&(t.value=null)}}return s}async function Gm(e,t){const n=UO(t);wl(e)?await mc(null,e.contents,n,Object.freeze([e]))===kr&&(e.contents=null):await mc(null,e,n,Object.freeze([]))}Gm.BREAK=Hi;Gm.SKIP=BO;Gm.REMOVE=kr;async function mc(e,t,n,i){const s=await FO(e,t,n,i);if(An(s)||kn(s))return $O(e,i,s),mc(e,s,n,i);if(typeof s!="symbol"){if(Cn(t)){i=Object.freeze(i.concat(t));for(let r=0;r<t.items.length;++r){const o=await mc(r,t.items[r],n,i);if(typeof o=="number")r=o-1;else{if(o===Hi)return Hi;o===kr&&(t.items.splice(r,1),r-=1)}}}else if(kn(t)){i=Object.freeze(i.concat(t));const r=await mc("key",t.key,n,i);if(r===Hi)return Hi;r===kr&&(t.key=null);const o=await mc("value",t.value,n,i);if(o===Hi)return Hi;o===kr&&(t.value=null)}}return s}function UO(e){return typeof e=="object"&&(e.Collection||e.Node||e.Value)?Object.assign({Alias:e.Node,Map:e.Node,Scalar:e.Node,Seq:e.Node},e.Value&&{Map:e.Value,Scalar:e.Value,Seq:e.Value},e.Collection&&{Map:e.Collection,Seq:e.Collection},e):e}function FO(e,t,n,i){var s,r,o,c,u;if(typeof n=="function")return n(e,t,i);if(cu(t))return(s=n.Map)==null?void 0:s.call(n,e,t,i);if(uu(t))return(r=n.Seq)==null?void 0:r.call(n,e,t,i);if(kn(t))return(o=n.Pair)==null?void 0:o.call(n,e,t,i);if(fn(t))return(c=n.Scalar)==null?void 0:c.call(n,e,t,i);if(mo(t))return(u=n.Alias)==null?void 0:u.call(n,e,t,i)}function $O(e,t,n){const i=t[t.length-1];if(Cn(i))i.items[e]=n;else if(kn(i))e==="key"?i.key=n:i.value=n;else if(wl(i))i.contents=n;else{const s=mo(i)?"alias":"scalar";throw new Error(`Cannot replace node with ${s} parent`)}}const Fee={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},$ee=e=>e.replace(/[!,[\]{}]/g,t=>Fee[t]);class Ai{constructor(t,n){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},Ai.defaultYaml,t),this.tags=Object.assign({},Ai.defaultTags,n)}clone(){const t=new Ai(this.yaml,this.tags);return t.docStart=this.docStart,t}atDocument(){const t=new Ai(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:Ai.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},Ai.defaultTags);break}return t}add(t,n){this.atNextDocument&&(this.yaml={explicit:Ai.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},Ai.defaultTags),this.atNextDocument=!1);const i=t.trim().split(/[ \t]+/),s=i.shift();switch(s){case"%TAG":{if(i.length!==2&&(n(0,"%TAG directive should contain exactly two parts"),i.length<2))return!1;const[r,o]=i;return this.tags[r]=o,!0}case"%YAML":{if(this.yaml.explicit=!0,i.length!==1)return n(0,"%YAML directive should contain exactly one part"),!1;const[r]=i;if(r==="1.1"||r==="1.2")return this.yaml.version=r,!0;{const o=/^\d+\.\d+$/.test(r);return n(6,`Unsupported YAML version ${r}`,o),!1}}default:return n(0,`Unknown directive ${s}`,!0),!1}}tagName(t,n){if(t==="!")return"!";if(t[0]!=="!")return n(`Not a valid tag: ${t}`),null;if(t[1]==="<"){const o=t.slice(2,-1);return o==="!"||o==="!!"?(n(`Verbatim tags aren't resolved, so ${t} is invalid.`),null):(t[t.length-1]!==">"&&n("Verbatim tags must end with a >"),o)}const[,i,s]=t.match(/^(.*!)([^!]*)$/s);s||n(`The ${t} tag has no suffix`);const r=this.tags[i];if(r)try{return r+decodeURIComponent(s)}catch(o){return n(String(o)),null}return i==="!"?t:(n(`Could not resolve tag: ${t}`),null)}tagString(t){for(const[n,i]of Object.entries(this.tags))if(t.startsWith(i))return n+$ee(t.substring(i.length));return t[0]==="!"?t:`!<${t}>`}toString(t){const n=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],i=Object.entries(this.tags);let s;if(t&&i.length>0&&An(t.contents)){const r={};El(t.contents,(o,c)=>{An(c)&&c.tag&&(r[c.tag]=!0)}),s=Object.keys(r)}else s=[];for(const[r,o]of i)r==="!!"&&o==="tag:yaml.org,2002:"||(!t||s.some(c=>c.startsWith(o)))&&n.push(`%TAG ${r} ${o}`);return n.join(`
|
|
668
668
|
`)}}Ai.defaultYaml={explicit:!1,version:"1.2"};Ai.defaultTags={"!!":"tag:yaml.org,2002:"};function qO(e){if(/[\x00-\x19\s,[\]{}]/.test(e)){const n=`Anchor must not contain whitespace or control characters: ${JSON.stringify(e)}`;throw new Error(n)}return!0}function HO(e){const t=new Set;return El(e,{Value(n,i){i.anchor&&t.add(i.anchor)}}),t}function VO(e,t){for(let n=1;;++n){const i=`${e}${n}`;if(!t.has(i))return i}}function qee(e,t){const n=[],i=new Map;let s=null;return{onAnchor:r=>{n.push(r),s??(s=HO(e));const o=VO(t,s);return s.add(o),o},setAnchors:()=>{for(const r of n){const o=i.get(r);if(typeof o=="object"&&o.anchor&&(fn(o.node)||Cn(o.node)))o.node.anchor=o.anchor;else{const c=new Error("Failed to resolve repeated object (this should not happen)");throw c.source=r,c}}},sourceObjects:i}}function gc(e,t,n,i){if(i&&typeof i=="object")if(Array.isArray(i))for(let s=0,r=i.length;s<r;++s){const o=i[s],c=gc(e,i,String(s),o);c===void 0?delete i[s]:c!==o&&(i[s]=c)}else if(i instanceof Map)for(const s of Array.from(i.keys())){const r=i.get(s),o=gc(e,i,s,r);o===void 0?i.delete(s):o!==r&&i.set(s,o)}else if(i instanceof Set)for(const s of Array.from(i)){const r=gc(e,i,s,s);r===void 0?i.delete(s):r!==s&&(i.delete(s),i.add(r))}else for(const[s,r]of Object.entries(i)){const o=gc(e,i,s,r);o===void 0?delete i[s]:o!==r&&(i[s]=o)}return e.call(t,n,i)}function Ts(e,t,n){if(Array.isArray(e))return e.map((i,s)=>Ts(i,String(s),n));if(e&&typeof e.toJSON=="function"){if(!n||!zO(e))return e.toJSON(t,n);const i={aliasCount:0,count:1,res:void 0};n.anchors.set(e,i),n.onCreate=r=>{i.res=r,delete n.onCreate};const s=e.toJSON(t,n);return n.onCreate&&n.onCreate(s),s}return typeof e=="bigint"&&!(n!=null&&n.keep)?Number(e):e}class sw{constructor(t){Object.defineProperty(this,As,{value:t})}clone(){const t=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(t.range=this.range.slice()),t}toJS(t,{mapAsMap:n,maxAliasCount:i,onAnchor:s,reviver:r}={}){if(!wl(t))throw new TypeError("A document argument is required");const o={anchors:new Map,doc:t,keep:!0,mapAsMap:n===!0,mapKeyWarned:!1,maxAliasCount:typeof i=="number"?i:100},c=Ts(this,"",o);if(typeof s=="function")for(const{count:u,res:f}of o.anchors.values())s(f,u);return typeof r=="function"?gc(r,{"":c},"",c):c}}class Wm extends sw{constructor(t){super(iw),this.source=t,Object.defineProperty(this,"tag",{set(){throw new Error("Alias nodes cannot have tags")}})}resolve(t,n){let i;n!=null&&n.aliasResolveCache?i=n.aliasResolveCache:(i=[],El(t,{Node:(r,o)=>{(mo(o)||zO(o))&&i.push(o)}}),n&&(n.aliasResolveCache=i));let s;for(const r of i){if(r===this)break;r.anchor===this.source&&(s=r)}return s}toJSON(t,n){if(!n)return{source:this.source};const{anchors:i,doc:s,maxAliasCount:r}=n,o=this.resolve(s,n);if(!o){const u=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new ReferenceError(u)}let c=i.get(o);if(c||(Ts(o,null,n),c=i.get(o)),(c==null?void 0:c.res)===void 0){const u="This should not happen: Alias anchor was not resolved?";throw new ReferenceError(u)}if(r>=0&&(c.count+=1,c.aliasCount===0&&(c.aliasCount=Pp(s,o,i)),c.count*c.aliasCount>r)){const u="Excessive alias count indicates a resource exhaustion attack";throw new ReferenceError(u)}return c.res}toString(t,n,i){const s=`*${this.source}`;if(t){if(qO(this.source),t.options.verifyAliasOrder&&!t.anchors.has(this.source)){const r=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new Error(r)}if(t.implicitKey)return`${s} `}return s}}function Pp(e,t,n){if(mo(t)){const i=t.resolve(e),s=n&&i&&n.get(i);return s?s.count*s.aliasCount:0}else if(Cn(t)){let i=0;for(const s of t.items){const r=Pp(e,s,n);r>i&&(i=r)}return i}else if(kn(t)){const i=Pp(e,t.key,n),s=Pp(e,t.value,n);return Math.max(i,s)}return 1}const KO=e=>!e||typeof e!="function"&&typeof e!="object";class bt extends sw{constructor(t){super(_r),this.value=t}toJSON(t,n){return n!=null&&n.keep?this.value:Ts(this.value,t,n)}toString(){return String(this.value)}}bt.BLOCK_FOLDED="BLOCK_FOLDED";bt.BLOCK_LITERAL="BLOCK_LITERAL";bt.PLAIN="PLAIN";bt.QUOTE_DOUBLE="QUOTE_DOUBLE";bt.QUOTE_SINGLE="QUOTE_SINGLE";const Hee="tag:yaml.org,2002:";function Vee(e,t,n){if(t){const i=n.filter(r=>r.tag===t),s=i.find(r=>!r.format)??i[0];if(!s)throw new Error(`Tag ${t} not found`);return s}return n.find(i=>{var s;return((s=i.identify)==null?void 0:s.call(i,e))&&!i.format})}function qd(e,t,n){var m,y,b;if(wl(e)&&(e=e.contents),An(e))return e;if(kn(e)){const x=(y=(m=n.schema[so]).createNode)==null?void 0:y.call(m,n.schema,null,n);return x.items.push(e),x}(e instanceof String||e instanceof Number||e instanceof Boolean||typeof BigInt<"u"&&e instanceof BigInt)&&(e=e.valueOf());const{aliasDuplicateObjects:i,onAnchor:s,onTagObj:r,schema:o,sourceObjects:c}=n;let u;if(i&&e&&typeof e=="object"){if(u=c.get(e),u)return u.anchor??(u.anchor=s(e)),new Wm(u.anchor);u={anchor:null,node:null},c.set(e,u)}t!=null&&t.startsWith("!!")&&(t=Hee+t.slice(2));let f=Vee(e,t,o.tags);if(!f){if(e&&typeof e.toJSON=="function"&&(e=e.toJSON()),!e||typeof e!="object"){const x=new bt(e);return u&&(u.node=x),x}f=e instanceof Map?o[so]:Symbol.iterator in Object(e)?o[lu]:o[so]}r&&(r(f),delete n.onTagObj);const p=f!=null&&f.createNode?f.createNode(n.schema,e,n):typeof((b=f==null?void 0:f.nodeClass)==null?void 0:b.from)=="function"?f.nodeClass.from(n.schema,e,n):new bt(e);return t?p.tag=t:f.default||(p.tag=f.tag),u&&(u.node=p),p}function gm(e,t,n){let i=n;for(let s=t.length-1;s>=0;--s){const r=t[s];if(typeof r=="number"&&Number.isInteger(r)&&r>=0){const o=[];o[r]=i,i=o}else i=new Map([[r,i]])}return qd(i,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw new Error("This should not happen, please report a bug.")},schema:e,sourceObjects:new Map})}const bd=e=>e==null||typeof e=="object"&&!!e[Symbol.iterator]().next().done;class GO extends sw{constructor(t,n){super(t),Object.defineProperty(this,"schema",{value:n,configurable:!0,enumerable:!1,writable:!0})}clone(t){const n=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return t&&(n.schema=t),n.items=n.items.map(i=>An(i)||kn(i)?i.clone(t):i),this.range&&(n.range=this.range.slice()),n}addIn(t,n){if(bd(t))this.add(n);else{const[i,...s]=t,r=this.get(i,!0);if(Cn(r))r.addIn(s,n);else if(r===void 0&&this.schema)this.set(i,gm(this.schema,s,n));else throw new Error(`Expected YAML collection at ${i}. Remaining path: ${s}`)}}deleteIn(t){const[n,...i]=t;if(i.length===0)return this.delete(n);const s=this.get(n,!0);if(Cn(s))return s.deleteIn(i);throw new Error(`Expected YAML collection at ${n}. Remaining path: ${i}`)}getIn(t,n){const[i,...s]=t,r=this.get(i,!0);return s.length===0?!n&&fn(r)?r.value:r:Cn(r)?r.getIn(s,n):void 0}hasAllNullValues(t){return this.items.every(n=>{if(!kn(n))return!1;const i=n.value;return i==null||t&&fn(i)&&i.value==null&&!i.commentBefore&&!i.comment&&!i.tag})}hasIn(t){const[n,...i]=t;if(i.length===0)return this.has(n);const s=this.get(n,!0);return Cn(s)?s.hasIn(i):!1}setIn(t,n){const[i,...s]=t;if(s.length===0)this.set(i,n);else{const r=this.get(i,!0);if(Cn(r))r.setIn(s,n);else if(r===void 0&&this.schema)this.set(i,gm(this.schema,s,n));else throw new Error(`Expected YAML collection at ${i}. Remaining path: ${s}`)}}}const Kee=e=>e.replace(/^(?!$)(?: $)?/gm,"#");function sa(e,t){return/^\n+$/.test(e)?e.substring(1):t?e.replace(/^(?! *$)/gm,t):e}const Vo=(e,t,n)=>e.endsWith(`
|
|
669
669
|
`)?sa(n,t):n.includes(`
|
|
670
670
|
`)?`
|
|
@@ -842,4 +842,4 @@ description: ...
|
|
|
842
842
|
`)),p=f.reduce((m,y)=>m.concat(...y),[]);return[f,p]}return[[],[]]},[e]);return _.useEffect(()=>{const u=(t==null?void 0:t.target)??fA,f=(t==null?void 0:t.actInsideInputWithModifier)??!0;if(e!==null){const p=b=>{var w,k;if(s.current=b.ctrlKey||b.metaKey||b.shiftKey||b.altKey,(!s.current||s.current&&!f)&&GI(b))return!1;const v=pA(b.code,c);if(r.current.add(b[v]),hA(o,r.current,!1)){const C=((k=(w=b.composedPath)==null?void 0:w.call(b))==null?void 0:k[0])||b.target,S=(C==null?void 0:C.nodeName)==="BUTTON"||(C==null?void 0:C.nodeName)==="A";t.preventDefault!==!1&&(s.current||!S)&&b.preventDefault(),i(!0)}},m=b=>{const x=pA(b.code,c);hA(o,r.current,!0)?(i(!1),r.current.clear()):r.current.delete(b[x]),b.key==="Meta"&&r.current.clear(),s.current=!1},y=()=>{r.current.clear(),i(!1)};return u==null||u.addEventListener("keydown",p),u==null||u.addEventListener("keyup",m),window.addEventListener("blur",y),window.addEventListener("contextmenu",y),()=>{u==null||u.removeEventListener("keydown",p),u==null||u.removeEventListener("keyup",m),window.removeEventListener("blur",y),window.removeEventListener("contextmenu",y)}}},[e,i]),n}function hA(e,t,n){return e.filter(i=>n||i.length===t.size).some(i=>i.every(s=>t.has(s)))}function pA(e,t){return t.includes(e)?"code":"key"}const Hce=()=>{const e=Nn();return _.useMemo(()=>({zoomIn:async t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1.2,t):!1},zoomOut:async t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1/1.2,t):!1},zoomTo:async(t,n)=>{const{panZoom:i}=e.getState();return i?i.scaleTo(t,n):!1},getZoom:()=>e.getState().transform[2],setViewport:async(t,n)=>{const{transform:[i,s,r],panZoom:o}=e.getState();return o?(await o.setViewport({x:t.x??i,y:t.y??s,zoom:t.zoom??r},n),!0):!1},getViewport:()=>{const[t,n,i]=e.getState().transform;return{x:t,y:n,zoom:i}},setCenter:async(t,n,i)=>e.getState().setCenter(t,n,i),fitBounds:async(t,n)=>{const{width:i,height:s,minZoom:r,maxZoom:o,panZoom:c}=e.getState(),u=jw(t,i,s,r,o,(n==null?void 0:n.padding)??.1);return c?(await c.setViewport(u,{duration:n==null?void 0:n.duration,ease:n==null?void 0:n.ease,interpolate:n==null?void 0:n.interpolate}),!0):!1},screenToFlowPosition:(t,n={})=>{const{transform:i,snapGrid:s,snapToGrid:r,domNode:o}=e.getState();if(!o)return t;const{x:c,y:u}=o.getBoundingClientRect(),f={x:t.x-c,y:t.y-u},p=n.snapGrid??s,m=n.snapToGrid??r;return Rf(f,i,m,p)},flowToScreenPosition:t=>{const{transform:n,domNode:i}=e.getState();if(!i)return t;const{x:s,y:r}=i.getBoundingClientRect(),o=Xc(t,n);return{x:o.x+s,y:o.y+r}}}),[])};function gP(e,t){const n=[],i=new Map,s=[];for(const r of e)if(r.type==="add"){s.push(r);continue}else if(r.type==="remove"||r.type==="replace")i.set(r.id,[r]);else{const o=i.get(r.id);o?o.push(r):i.set(r.id,[r])}for(const r of t){const o=i.get(r.id);if(!o){n.push(r);continue}if(o[0].type==="remove")continue;if(o[0].type==="replace"){n.push({...o[0].item});continue}const c={...r};for(const u of o)Vce(u,c);n.push(c)}return s.length&&s.forEach(r=>{r.index!==void 0?n.splice(r.index,0,{...r.item}):n.push({...r.item})}),n}function Vce(e,t){switch(e.type){case"select":{t.selected=e.selected;break}case"position":{typeof e.position<"u"&&(t.position=e.position),typeof e.dragging<"u"&&(t.dragging=e.dragging);break}case"dimensions":{typeof e.dimensions<"u"&&(t.measured={...e.dimensions},e.setAttributes&&((e.setAttributes===!0||e.setAttributes==="width")&&(t.width=e.dimensions.width),(e.setAttributes===!0||e.setAttributes==="height")&&(t.height=e.dimensions.height))),typeof e.resizing=="boolean"&&(t.resizing=e.resizing);break}}}function yP(e,t){return gP(e,t)}function bP(e,t){return gP(e,t)}function Uo(e,t){return{id:e,type:"select",selected:t}}function xc(e,t=new Set,n=!1){const i=[];for(const[s,r]of e){const o=t.has(s);!(r.selected===void 0&&!o)&&r.selected!==o&&(n&&(r.selected=o),i.push(Uo(r.id,o)))}return i}function mA({items:e=[],lookup:t}){var s;const n=[],i=new Map(e.map(r=>[r.id,r]));for(const[r,o]of e.entries()){const c=t.get(o.id),u=((s=c==null?void 0:c.internals)==null?void 0:s.userNode)??c;u!==void 0&&u!==o&&n.push({id:o.id,item:o,type:"replace"}),u===void 0&&n.push({item:o,type:"add",index:r})}for(const[r]of t)i.get(r)===void 0&&n.push({id:r,type:"remove"});return n}function gA(e){return{id:e.id,type:"remove"}}const xP=qI();function vP(e,t,n={}){return Mle(e,t,{...n,onError:n.onError??xP})}function Kce(e,t,n,i={shouldReplaceId:!0}){return Rle(e,t,n,{...i,onError:i.onError??xP})}const yA=e=>yle(e),Gce=e=>zI(e);function wP(e){return _.forwardRef(e)}const Wce=typeof window<"u"?_.useLayoutEffect:_.useEffect;function bA(e){const[t,n]=_.useState(BigInt(0)),[i]=_.useState(()=>Yce(()=>n(s=>s+BigInt(1))));return Wce(()=>{const s=i.get();s.length&&(e(s),i.reset())},[t]),i}function Yce(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}const EP=_.createContext(null);function Xce({children:e}){const t=Nn(),n=_.useCallback(c=>{const{nodes:u=[],setNodes:f,hasDefaultNodes:p,onNodesChange:m,nodeLookup:y,fitViewQueued:b,onNodesChangeMiddlewareMap:x}=t.getState();let v=u;for(const k of c)v=typeof k=="function"?k(v):k;let w=mA({items:v,lookup:y});for(const k of x.values())w=k(w);p&&f(v),w.length>0?m==null||m(w):b&&window.requestAnimationFrame(()=>{const{fitViewQueued:k,nodes:C,setNodes:S}=t.getState();k&&S(C)})},[]),i=bA(n),s=_.useCallback(c=>{const{edges:u=[],setEdges:f,hasDefaultEdges:p,onEdgesChange:m,edgeLookup:y}=t.getState();let b=u;for(const x of c)b=typeof x=="function"?x(b):x;p?f(b):m&&m(mA({items:b,lookup:y}))},[]),r=bA(s),o=_.useMemo(()=>({nodeQueue:i,edgeQueue:r}),[]);return d.jsx(EP.Provider,{value:o,children:e})}function Qce(){const e=_.useContext(EP);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const Zce=e=>!!e.panZoom;function vg(){const e=Hce(),t=Nn(),n=Qce(),i=Bt(Zce),s=_.useMemo(()=>{const r=m=>t.getState().nodeLookup.get(m),o=m=>{n.nodeQueue.push(m)},c=m=>{n.edgeQueue.push(m)},u=m=>{var k,C;const{nodeLookup:y,nodeOrigin:b}=t.getState(),x=yA(m)?m:y.get(m.id),v=x.parentId?VI(x.position,x.measured,x.parentId,y,b):x.position,w={...x,position:v,width:((k=x.measured)==null?void 0:k.width)??x.width,height:((C=x.measured)==null?void 0:C.height)??x.height};return ef(w)},f=(m,y,b={replace:!1})=>{o(x=>x.map(v=>{if(v.id===m){const w=typeof y=="function"?y(v):y;return b.replace&&yA(w)?w:{...v,...w}}return v}))},p=(m,y,b={replace:!1})=>{c(x=>x.map(v=>{if(v.id===m){const w=typeof y=="function"?y(v):y;return b.replace&&Gce(w)?w:{...v,...w}}return v}))};return{getNodes:()=>t.getState().nodes.map(m=>({...m})),getNode:m=>{var y;return(y=r(m))==null?void 0:y.internals.userNode},getInternalNode:r,getEdges:()=>{const{edges:m=[]}=t.getState();return m.map(y=>({...y}))},getEdge:m=>t.getState().edgeLookup.get(m),setNodes:o,setEdges:c,addNodes:m=>{const y=Array.isArray(m)?m:[m];n.nodeQueue.push(b=>[...b,...y])},addEdges:m=>{const y=Array.isArray(m)?m:[m];n.edgeQueue.push(b=>[...b,...y])},toObject:()=>{const{nodes:m=[],edges:y=[],transform:b}=t.getState(),[x,v,w]=b;return{nodes:m.map(k=>({...k})),edges:y.map(k=>({...k})),viewport:{x,y:v,zoom:w}}},deleteElements:async({nodes:m=[],edges:y=[]})=>{const{nodes:b,edges:x,onNodesDelete:v,onEdgesDelete:w,triggerNodeChanges:k,triggerEdgeChanges:C,onDelete:S,onBeforeDelete:T}=t.getState(),{nodes:A,edges:j}=await Ele({nodesToRemove:m,edgesToRemove:y,nodes:b,edges:x,onBeforeDelete:T}),M=j.length>0,D=A.length>0;if(M){const P=j.map(gA);w==null||w(j),C(P)}if(D){const P=A.map(gA);v==null||v(A),k(P)}return(D||M)&&(S==null||S({nodes:A,edges:j})),{deletedNodes:A,deletedEdges:j}},getIntersectingNodes:(m,y=!0,b)=>{const x=$T(m),v=x?m:u(m),w=b!==void 0;return v?(b||t.getState().nodes).filter(k=>{const C=t.getState().nodeLookup.get(k.id);if(C&&!x&&(k.id===m.id||!C.internals.positionAbsolute))return!1;const S=ef(w?k:C),T=Mm(S,v);return y&&T>0||T>=S.width*S.height||T>=v.width*v.height}):[]},isNodeIntersecting:(m,y,b=!0)=>{const v=$T(m)?m:u(m);if(!v)return!1;const w=Mm(v,y);return b&&w>0||w>=y.width*y.height||w>=v.width*v.height},updateNode:f,updateNodeData:(m,y,b={replace:!1})=>{f(m,x=>{const v=typeof y=="function"?y(x):y;return b.replace?{...x,data:v}:{...x,data:{...x.data,...v}}},b)},updateEdge:p,updateEdgeData:(m,y,b={replace:!1})=>{p(m,x=>{const v=typeof y=="function"?y(x):y;return b.replace?{...x,data:v}:{...x,data:{...x.data,...v}}},b)},getNodesBounds:m=>{const{nodeLookup:y,nodeOrigin:b}=t.getState();return ble(m,{nodeLookup:y,nodeOrigin:b})},getHandleConnections:({type:m,id:y,nodeId:b})=>{var x;return Array.from(((x=t.getState().connectionLookup.get(`${b}-${m}${y?`-${y}`:""}`))==null?void 0:x.values())??[])},getNodeConnections:({type:m,handleId:y,nodeId:b})=>{var x;return Array.from(((x=t.getState().connectionLookup.get(`${b}${m?y?`-${m}-${y}`:`-${m}`:""}`))==null?void 0:x.values())??[])},fitView:async m=>{const y=t.getState().fitViewResolver??Nle();return t.setState({fitViewQueued:!0,fitViewOptions:m,fitViewResolver:y}),n.nodeQueue.push(b=>[...b]),y.promise}}},[]);return _.useMemo(()=>({...s,...e,viewportInitialized:i}),[i])}const xA=e=>e.selected,Jce=typeof window<"u"?window:void 0;function eue({deleteKeyCode:e,multiSelectionKeyCode:t}){const n=Nn(),{deleteElements:i}=vg(),s=nf(e,{actInsideInputWithModifier:!1}),r=nf(t,{target:Jce});_.useEffect(()=>{if(s){const{edges:o,nodes:c}=n.getState();i({nodes:c.filter(xA),edges:o.filter(xA)}),n.setState({nodesSelectionActive:!1})}},[s]),_.useEffect(()=>{n.setState({multiSelectionActive:r})},[r])}function tue(e){const t=Nn();_.useEffect(()=>{const n=()=>{var s,r,o,c;if(!e.current||!(((r=(s=e.current).checkVisibility)==null?void 0:r.call(s))??!0))return!1;const i=Mw(e.current);(i.height===0||i.width===0)&&((c=(o=t.getState()).onError)==null||c.call(o,"004",cs.error004())),t.setState({width:i.width||500,height:i.height||500})};if(e.current){n(),window.addEventListener("resize",n);const i=new ResizeObserver(()=>n());return i.observe(e.current),()=>{window.removeEventListener("resize",n),i&&e.current&&i.unobserve(e.current)}}},[])}const wg={position:"absolute",width:"100%",height:"100%",top:0,left:0},nue=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function iue({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:i=!1,panOnScrollSpeed:s=.5,panOnScrollMode:r=ol.Free,zoomOnDoubleClick:o=!0,panOnDrag:c=!0,defaultViewport:u,translateExtent:f,minZoom:p,maxZoom:m,zoomActivationKeyCode:y,preventScrolling:b=!0,children:x,noWheelClassName:v,noPanClassName:w,onViewportChange:k,isControlledViewport:C,paneClickDistance:S,selectionOnDrag:T}){const A=Nn(),j=_.useRef(null),{userSelectionActive:M,lib:D,connectionInProgress:P}=Bt(nue,Sn),I=nf(y),B=_.useRef();tue(j);const q=_.useCallback(G=>{k==null||k({x:G[0],y:G[1],zoom:G[2]}),C||A.setState({transform:G})},[k,C]);return _.useEffect(()=>{if(j.current){B.current=lce({domNode:j.current,minZoom:p,maxZoom:m,translateExtent:f,viewport:u,onDraggingChange:z=>A.setState(W=>W.paneDragging===z?W:{paneDragging:z}),onPanZoomStart:(z,W)=>{const{onViewportChangeStart:X,onMoveStart:K}=A.getState();K==null||K(z,W),X==null||X(W)},onPanZoom:(z,W)=>{const{onViewportChange:X,onMove:K}=A.getState();K==null||K(z,W),X==null||X(W)},onPanZoomEnd:(z,W)=>{const{onViewportChangeEnd:X,onMoveEnd:K}=A.getState();K==null||K(z,W),X==null||X(W)}});const{x:G,y:R,zoom:O}=B.current.getViewport();return A.setState({panZoom:B.current,transform:[G,R,O],domNode:j.current.closest(".react-flow")}),()=>{var z;(z=B.current)==null||z.destroy()}}},[]),_.useEffect(()=>{var G;(G=B.current)==null||G.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:i,panOnScrollSpeed:s,panOnScrollMode:r,zoomOnDoubleClick:o,panOnDrag:c,zoomActivationKeyPressed:I,preventScrolling:b,noPanClassName:w,userSelectionActive:M,noWheelClassName:v,lib:D,onTransformChange:q,connectionInProgress:P,selectionOnDrag:T,paneClickDistance:S})},[e,t,n,i,s,r,o,c,I,b,w,M,v,D,q,P,T,S]),d.jsx("div",{className:"react-flow__renderer",ref:j,style:wg,children:x})}const sue=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function rue(){const{userSelectionActive:e,userSelectionRect:t}=Bt(sue,Sn);return e&&t?d.jsx("div",{className:"react-flow__selection react-flow__container",style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}const Gx=(e,t)=>n=>{n.target===t.current&&(e==null||e(n))},aue=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging,panBy:e.panBy,autoPanSpeed:e.autoPanSpeed});function oue({isSelecting:e,selectionKeyPressed:t,selectionMode:n=Jd.Full,panOnDrag:i,autoPanOnSelection:s,paneClickDistance:r,selectionOnDrag:o,onSelectionStart:c,onSelectionEnd:u,onPaneClick:f,onPaneContextMenu:p,onPaneScroll:m,onPaneMouseEnter:y,onPaneMouseMove:b,onPaneMouseLeave:x,children:v}){const w=_.useRef(0),k=Nn(),{userSelectionActive:C,elementsSelectable:S,dragging:T,panBy:A,autoPanSpeed:j}=Bt(aue,Sn),M=S&&(e||C),D=_.useRef(null),P=_.useRef(),I=_.useRef(new Set),B=_.useRef(new Set),q=_.useRef(!1),G=_.useRef(!1),R=_.useRef({x:0,y:0}),O=_.useRef(!1),z=oe=>{if(G.current||q.current||k.getState().connection.inProgress){G.current=!1,q.current=!1;return}f==null||f(oe),k.getState().resetSelectedElements(),k.setState({nodesSelectionActive:!1})},W=oe=>{if(Array.isArray(i)&&(i!=null&&i.includes(2))){oe.preventDefault();return}p==null||p(oe)},X=m?oe=>m(oe):void 0,K=oe=>{G.current&&(oe.stopPropagation(),G.current=!1)},U=oe=>{var Ue,Oe;const{domNode:pe,transform:re}=k.getState();if(P.current=pe==null?void 0:pe.getBoundingClientRect(),!P.current)return;const ee=oe.target===D.current;if(!ee&&!!oe.target.closest(".nokey")||!e||!(o&&ee||t)||oe.button!==0||!oe.isPrimary)return;(Oe=(Ue=oe.target)==null?void 0:Ue.setPointerCapture)==null||Oe.call(Ue,oe.pointerId),G.current=!1;const{x:Ie,y:ae}=Qs(oe.nativeEvent,P.current),ke=Rf({x:Ie,y:ae},re);k.setState({userSelectionRect:{width:0,height:0,startX:ke.x,startY:ke.y,x:Ie,y:ae}}),ee||(oe.stopPropagation(),oe.preventDefault())};function F(oe,pe){const{userSelectionRect:re}=k.getState();if(!re)return;const{transform:ee,nodeLookup:ge,edgeLookup:Ce,connectionLookup:Ie,triggerNodeChanges:ae,triggerEdgeChanges:ke,defaultEdgeOptions:Ue}=k.getState(),Oe={x:re.startX,y:re.startY},{x:ht,y:tt}=Xc(Oe,ee),jt={startX:Oe.x,startY:Oe.y,x:oe<ht?oe:ht,y:pe<tt?pe:tt,width:Math.abs(oe-ht),height:Math.abs(pe-tt)},Nt=I.current,pt=B.current;I.current=new Set(Tw(ge,jt,ee,n===Jd.Partial,!0).map(We=>We.id)),B.current=new Set;const Me=(Ue==null?void 0:Ue.selectable)??!0;for(const We of I.current){const ne=Ie.get(We);if(ne)for(const{edgeId:ve}of ne.values()){const Re=Ce.get(ve);Re&&(Re.selectable??Me)&&B.current.add(ve)}}if(!qT(Nt,I.current)){const We=xc(ge,I.current,!0);ae(We)}if(!qT(pt,B.current)){const We=xc(Ce,B.current);ke(We)}k.setState({userSelectionRect:jt,userSelectionActive:!0,nodesSelectionActive:!1})}function Y(){if(!s||!P.current)return;const[oe,pe]=Aw(R.current,P.current,j);A({x:oe,y:pe}).then(re=>{if(!G.current||!re){w.current=requestAnimationFrame(Y);return}const{x:ee,y:ge}=R.current;F(ee,ge),w.current=requestAnimationFrame(Y)})}const $=()=>{cancelAnimationFrame(w.current),w.current=0,O.current=!1};_.useEffect(()=>()=>$(),[]);const ie=oe=>{const{userSelectionRect:pe,transform:re,resetSelectedElements:ee}=k.getState();if(!P.current||!pe)return;const{x:ge,y:Ce}=Qs(oe.nativeEvent,P.current);R.current={x:ge,y:Ce};const Ie=Xc({x:pe.startX,y:pe.startY},re);if(!G.current){const ae=t?0:r;if(Math.hypot(ge-Ie.x,Ce-Ie.y)<=ae)return;ee(),c==null||c(oe)}G.current=!0,O.current||(Y(),O.current=!0),F(ge,Ce)},be=oe=>{var pe,re;if(!M){oe.target===D.current&&k.getState().connection.inProgress&&(q.current=!0);return}oe.button===0&&((re=(pe=oe.target)==null?void 0:pe.releasePointerCapture)==null||re.call(pe,oe.pointerId),!C&&oe.target===D.current&&k.getState().userSelectionRect&&(z==null||z(oe)),k.setState({userSelectionActive:!1,userSelectionRect:null}),G.current&&(u==null||u(oe),k.setState({nodesSelectionActive:I.current.size>0})),$())},ce=oe=>{var pe,re;(re=(pe=oe.target)==null?void 0:pe.releasePointerCapture)==null||re.call(pe,oe.pointerId),$()},Ne=i===!0||Array.isArray(i)&&i.includes(0);return d.jsxs("div",{className:Wn(["react-flow__pane",{draggable:Ne,dragging:T,selection:e}]),onClick:M?void 0:Gx(z,D),onContextMenu:Gx(W,D),onWheel:Gx(X,D),onPointerEnter:M?void 0:y,onPointerMove:M?ie:b,onPointerUp:be,onPointerCancel:M?ce:void 0,onPointerDownCapture:M?U:void 0,onClickCapture:M?K:void 0,onPointerLeave:x,ref:D,style:wg,children:[v,d.jsx(rue,{})]})}function Dv({id:e,store:t,unselect:n=!1,nodeRef:i}){const{addSelectedNodes:s,unselectNodesAndEdges:r,multiSelectionActive:o,nodeLookup:c,onError:u}=t.getState(),f=c.get(e);if(!f){u==null||u("012",cs.error012(e));return}t.setState({nodesSelectionActive:!1}),f.selected?(n||f.selected&&o)&&(r({nodes:[f],edges:[]}),requestAnimationFrame(()=>{var p;return(p=i==null?void 0:i.current)==null?void 0:p.blur()})):s([e])}function kP({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:i,nodeId:s,isSelectable:r,nodeClickDistance:o}){const c=Nn(),[u,f]=_.useState(!1),p=_.useRef();return _.useEffect(()=>{p.current=Wle({getStoreItems:()=>c.getState(),onNodeMouseDown:m=>{Dv({id:m,store:c,nodeRef:e})},onDragStart:()=>{f(!0)},onDragStop:()=>{f(!1)}})},[]),_.useEffect(()=>{if(!(t||!e.current||!p.current))return p.current.update({noDragClassName:n,handleSelector:i,domNode:e.current,isSelectable:r,nodeId:s,nodeClickDistance:o}),()=>{var m;(m=p.current)==null||m.destroy()}},[n,i,t,r,e,s,o]),u}const lue=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function SP(){const e=Nn();return _.useCallback(n=>{const{nodeExtent:i,snapToGrid:s,snapGrid:r,nodesDraggable:o,onError:c,updateNodePositions:u,nodeLookup:f,nodeOrigin:p}=e.getState(),m=new Map,y=lue(o),b=s?r[0]:5,x=s?r[1]:5,v=n.direction.x*b*n.factor,w=n.direction.y*x*n.factor;for(const[,k]of f){if(!y(k))continue;let C={x:k.internals.positionAbsolute.x+v,y:k.internals.positionAbsolute.y+w};s&&(C=Mf(C,r));const{position:S,positionAbsolute:T}=BI({nodeId:k.id,nextPosition:C,nodeLookup:f,nodeExtent:i,nodeOrigin:p,onError:c});k.position=S,k.internals.positionAbsolute=T,m.set(k.id,k)}u(m)},[])}const Pw=_.createContext(null),cue=Pw.Provider;Pw.Consumer;const NP=()=>_.useContext(Pw),uue=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),_P=_.createContext(null);function due({children:e}){const t=Bt(uue,Sn);return d.jsx(_P.Provider,{value:t,children:e})}function fue(){const e=_.useContext(_P);if(!e)throw new Error("useHandleConfig must be used within a HandleConfigProvider");return e}const hue={connectingFrom:!1,connectingTo:!1,clickConnecting:!1,isPossibleEndHandle:!0,connectionInProcess:!1,clickConnectionInProcess:!1,valid:!1},pue=(e,t,n)=>i=>{const{connectionClickStartHandle:s,connectionMode:r,connection:o}=i,{fromHandle:c,toHandle:u,isValid:f}=o;if(!c&&!s)return hue;const p=(u==null?void 0:u.nodeId)===e&&(u==null?void 0:u.id)===t&&(u==null?void 0:u.type)===n;return{connectingFrom:(c==null?void 0:c.nodeId)===e&&(c==null?void 0:c.id)===t&&(c==null?void 0:c.type)===n,connectingTo:p,clickConnecting:(s==null?void 0:s.nodeId)===e&&(s==null?void 0:s.id)===t&&(s==null?void 0:s.type)===n,isPossibleEndHandle:r===Wc.Strict?(c==null?void 0:c.type)!==n:e!==(c==null?void 0:c.nodeId)||t!==(c==null?void 0:c.id),connectionInProcess:!!c,clickConnectionInProcess:!!s,valid:p&&f}};function mue({type:e="source",position:t=et.Top,isValidConnection:n,isConnectable:i=!0,isConnectableStart:s=!0,isConnectableEnd:r=!0,id:o,onConnect:c,children:u,className:f,onMouseDown:p,onTouchStart:m,...y},b){var O,z;const x=o||null,v=e==="target",w=Nn(),k=NP(),{connectOnClick:C,noPanClassName:S,rfId:T}=fue(),{connectingFrom:A,connectingTo:j,clickConnecting:M,isPossibleEndHandle:D,connectionInProcess:P,clickConnectionInProcess:I,valid:B}=Bt(pue(k,x,e),Sn);k||(z=(O=w.getState()).onError)==null||z.call(O,"010",cs.error010());const q=W=>{const{defaultEdgeOptions:X,onConnect:K,hasDefaultEdges:U}=w.getState(),F={...X,...W};if(U){const{edges:Y,setEdges:$,onError:ie}=w.getState();$(vP(F,Y,{onError:ie}))}K==null||K(F),c==null||c(F)},G=W=>{if(!k)return;const X=WI(W.nativeEvent);if(s&&(X&&W.button===0||!X)){const K=w.getState();Rv.onPointerDown(W.nativeEvent,{handleDomNode:W.currentTarget,autoPanOnConnect:K.autoPanOnConnect,connectionMode:K.connectionMode,connectionRadius:K.connectionRadius,domNode:K.domNode,nodeLookup:K.nodeLookup,lib:K.lib,isTarget:v,handleId:x,nodeId:k,flowId:K.rfId,panBy:K.panBy,cancelConnection:K.cancelConnection,onConnectStart:K.onConnectStart,onConnectEnd:(...U)=>{var F,Y;return(Y=(F=w.getState()).onConnectEnd)==null?void 0:Y.call(F,...U)},updateConnection:K.updateConnection,onConnect:q,isValidConnection:n||((...U)=>{var F,Y;return((Y=(F=w.getState()).isValidConnection)==null?void 0:Y.call(F,...U))??!0}),getTransform:()=>w.getState().transform,getFromHandle:()=>w.getState().connection.fromHandle,autoPanSpeed:K.autoPanSpeed,dragThreshold:K.connectionDragThreshold})}X?p==null||p(W):m==null||m(W)},R=W=>{const{onClickConnectStart:X,onClickConnectEnd:K,connectionClickStartHandle:U,connectionMode:F,isValidConnection:Y,lib:$,rfId:ie,nodeLookup:be,connection:ce}=w.getState();if(!k||!U&&!s)return;if(!U){X==null||X(W.nativeEvent,{nodeId:k,handleId:x,handleType:e}),w.setState({connectionClickStartHandle:{nodeId:k,type:e,id:x}});return}const Ne=KI(W.target),oe=n||Y,{connection:pe,isValid:re}=Rv.isValid(W.nativeEvent,{handle:{nodeId:k,id:x,type:e},connectionMode:F,fromNodeId:U.nodeId,fromHandleId:U.id||null,fromType:U.type,isValidConnection:oe,flowId:ie,doc:Ne,lib:$,nodeLookup:be});re&&pe&&q(pe);const ee=structuredClone(ce);delete ee.inProgress,ee.toPosition=ee.toHandle?ee.toHandle.position:null,K==null||K(W,ee),w.setState({connectionClickStartHandle:null})};return d.jsx("div",{"data-handleid":x,"data-nodeid":k,"data-handlepos":t,"data-id":`${T}-${k}-${x}-${e}`,className:Wn(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",S,f,{source:!v,target:v,connectable:i,connectablestart:s,connectableend:r,clickconnecting:M,connectingfrom:A,connectingto:j,valid:B,connectionindicator:i&&(!P||D)&&(P||I?r:s)}]),onMouseDown:G,onTouchStart:G,onClick:C?R:void 0,ref:b,...y,children:u})}const no=_.memo(wP(mue));function gue({data:e,isConnectable:t,sourcePosition:n=et.Bottom}){return d.jsxs(d.Fragment,{children:[e==null?void 0:e.label,d.jsx(no,{type:"source",position:n,isConnectable:t})]})}function yue({data:e,isConnectable:t,targetPosition:n=et.Top,sourcePosition:i=et.Bottom}){return d.jsxs(d.Fragment,{children:[d.jsx(no,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label,d.jsx(no,{type:"source",position:i,isConnectable:t})]})}function bue(){return null}function xue({data:e,isConnectable:t,targetPosition:n=et.Top}){return d.jsxs(d.Fragment,{children:[d.jsx(no,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label]})}const Rm={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},vA={input:gue,default:yue,output:xue,group:bue};function vue(e){var t,n,i,s;return e.internals.handleBounds===void 0?{width:e.width??e.initialWidth??((t=e.style)==null?void 0:t.width),height:e.height??e.initialHeight??((n=e.style)==null?void 0:n.height)}:{width:e.width??((i=e.style)==null?void 0:i.width),height:e.height??((s=e.style)==null?void 0:s.height)}}const wue=e=>{const{width:t,height:n,x:i,y:s}=jf(e.nodeLookup,{filter:r=>!!r.selected});return{width:Xs(t)?t:null,height:Xs(n)?n:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${i}px,${s}px)`}};function Eue({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const i=Nn(),{width:s,height:r,transformString:o,userSelectionActive:c}=Bt(wue,Sn),u=SP(),f=_.useRef(null);_.useEffect(()=>{var b;n||(b=f.current)==null||b.focus({preventScroll:!0})},[n]);const p=!c&&s!==null&&r!==null;if(kP({nodeRef:f,disabled:!p}),!p)return null;const m=e?b=>{const x=i.getState().nodes.filter(v=>v.selected);e(b,x)}:void 0,y=b=>{Object.prototype.hasOwnProperty.call(Rm,b.key)&&(b.preventDefault(),u({direction:Rm[b.key],factor:b.shiftKey?4:1}))};return d.jsx("div",{className:Wn(["react-flow__nodesselection","react-flow__container",t]),style:{transform:o},children:d.jsx("div",{ref:f,className:"react-flow__nodesselection-rect",onContextMenu:m,tabIndex:n?void 0:-1,onKeyDown:n?void 0:y,style:{width:s,height:r}})})}const wA=typeof window<"u"?window:void 0,kue=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function CP({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:i,onPaneMouseLeave:s,onPaneContextMenu:r,onPaneScroll:o,paneClickDistance:c,deleteKeyCode:u,selectionKeyCode:f,selectionOnDrag:p,selectionMode:m,onSelectionStart:y,onSelectionEnd:b,multiSelectionKeyCode:x,panActivationKeyCode:v,zoomActivationKeyCode:w,elementsSelectable:k,zoomOnScroll:C,zoomOnPinch:S,panOnScroll:T,panOnScrollSpeed:A,panOnScrollMode:j,zoomOnDoubleClick:M,panOnDrag:D,autoPanOnSelection:P,defaultViewport:I,translateExtent:B,minZoom:q,maxZoom:G,preventScrolling:R,onSelectionContextMenu:O,noWheelClassName:z,noPanClassName:W,disableKeyboardA11y:X,onViewportChange:K,isControlledViewport:U}){const{nodesSelectionActive:F,userSelectionActive:Y}=Bt(kue,Sn),$=nf(f,{target:wA}),ie=nf(v,{target:wA}),be=ie||D,ce=ie||T,Ne=p&&be!==!0,oe=$||Y||Ne;return eue({deleteKeyCode:u,multiSelectionKeyCode:x}),d.jsx(iue,{onPaneContextMenu:r,elementsSelectable:k,zoomOnScroll:C,zoomOnPinch:S,panOnScroll:ce,panOnScrollSpeed:A,panOnScrollMode:j,zoomOnDoubleClick:M,panOnDrag:!$&&be,defaultViewport:I,translateExtent:B,minZoom:q,maxZoom:G,zoomActivationKeyCode:w,preventScrolling:R,noWheelClassName:z,noPanClassName:W,onViewportChange:K,isControlledViewport:U,paneClickDistance:c,selectionOnDrag:Ne,children:d.jsxs(oue,{onSelectionStart:y,onSelectionEnd:b,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:i,onPaneMouseLeave:s,onPaneContextMenu:r,onPaneScroll:o,panOnDrag:be,autoPanOnSelection:P,isSelecting:!!oe,selectionMode:m,selectionKeyPressed:$,paneClickDistance:c,selectionOnDrag:Ne,children:[e,F&&d.jsx(Eue,{onSelectionContextMenu:O,noPanClassName:W,disableKeyboardA11y:X})]})})}CP.displayName="FlowRenderer";const Sue=_.memo(CP),Nue=e=>t=>e?Tw(t.nodeLookup,{x:0,y:0,width:t.width,height:t.height},t.transform,!0).map(n=>n.id):Array.from(t.nodeLookup.keys());function _ue(e){return Bt(_.useCallback(Nue(e),[e]),Sn)}const Cue=e=>e.updateNodeInternals;function Tue(){const e=Bt(Cue),[t]=_.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(n=>{const i=new Map;n.forEach(s=>{const r=s.target.getAttribute("data-id");i.set(r,{id:r,nodeElement:s.target,force:!0})}),e(i)}));return _.useEffect(()=>()=>{t==null||t.disconnect()},[t]),t}function Aue({node:e,nodeType:t,hasDimensions:n,resizeObserver:i}){const s=Nn(),r=_.useRef(null),o=_.useRef(null),c=_.useRef(e.sourcePosition),u=_.useRef(e.targetPosition),f=_.useRef(t),p=n&&!!e.internals.handleBounds;return _.useEffect(()=>{r.current&&!e.hidden&&(!p||o.current!==r.current)&&(o.current&&(i==null||i.unobserve(o.current)),i==null||i.observe(r.current),o.current=r.current)},[p,e.hidden]),_.useEffect(()=>()=>{o.current&&(i==null||i.unobserve(o.current),o.current=null)},[]),_.useEffect(()=>{if(r.current){const m=f.current!==t,y=c.current!==e.sourcePosition,b=u.current!==e.targetPosition;(m||y||b)&&(f.current=t,c.current=e.sourcePosition,u.current=e.targetPosition,s.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:r.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),r}function jue({id:e,onClick:t,onMouseEnter:n,onMouseMove:i,onMouseLeave:s,onContextMenu:r,onDoubleClick:o,nodesDraggable:c,elementsSelectable:u,nodesConnectable:f,nodesFocusable:p,resizeObserver:m,noDragClassName:y,noPanClassName:b,disableKeyboardA11y:x,rfId:v,nodeTypes:w,nodeClickDistance:k,onError:C}){const{node:S,internals:T,isParent:A}=Bt(oe=>{const pe=oe.nodeLookup.get(e),re=oe.parentLookup.has(e);return{node:pe,internals:pe.internals,isParent:re}},Sn);let j=S.type||"default",M=(w==null?void 0:w[j])||vA[j];M===void 0&&(C==null||C("003",cs.error003(j)),j="default",M=(w==null?void 0:w.default)||vA.default);const D=!!(S.draggable||c&&typeof S.draggable>"u"),P=!!(S.selectable||u&&typeof S.selectable>"u"),I=!!(S.connectable||f&&typeof S.connectable>"u"),B=!!(S.focusable||p&&typeof S.focusable>"u"),q=Nn(),G=HI(S),R=Aue({node:S,nodeType:j,hasDimensions:G,resizeObserver:m}),O=kP({nodeRef:R,disabled:S.hidden||!D,noDragClassName:y,handleSelector:S.dragHandle,nodeId:e,isSelectable:P,nodeClickDistance:k}),z=SP();if(S.hidden)return null;const W=pa(S),X=vue(S),K=P||D||t||n||i||s,U=n?oe=>n(oe,{...T.userNode}):void 0,F=i?oe=>i(oe,{...T.userNode}):void 0,Y=s?oe=>s(oe,{...T.userNode}):void 0,$=r?oe=>r(oe,{...T.userNode}):void 0,ie=o?oe=>o(oe,{...T.userNode}):void 0,be=oe=>{const{selectNodesOnDrag:pe,nodeDragThreshold:re}=q.getState();P&&(!pe||!D||re>0)&&Dv({id:e,store:q,nodeRef:R}),t&&t(oe,{...T.userNode})},ce=oe=>{if(!(GI(oe.nativeEvent)||x)){if(OI.includes(oe.key)&&P){const pe=oe.key==="Escape";Dv({id:e,store:q,unselect:pe,nodeRef:R})}else if(D&&S.selected&&Object.prototype.hasOwnProperty.call(Rm,oe.key)){oe.preventDefault();const{ariaLabelConfig:pe}=q.getState();q.setState({ariaLiveMessage:pe["node.a11yDescription.ariaLiveMessage"]({direction:oe.key.replace("Arrow","").toLowerCase(),x:~~T.positionAbsolute.x,y:~~T.positionAbsolute.y})}),z({direction:Rm[oe.key],factor:oe.shiftKey?4:1})}}},Ne=()=>{var Ie;if(x||!((Ie=R.current)!=null&&Ie.matches(":focus-visible")))return;const{transform:oe,width:pe,height:re,autoPanOnNodeFocus:ee,setCenter:ge}=q.getState();if(!ee)return;Tw(new Map([[e,S]]),{x:0,y:0,width:pe,height:re},oe,!0).length>0||ge(S.position.x+W.width/2,S.position.y+W.height/2,{zoom:oe[2]})};return d.jsx("div",{className:Wn(["react-flow__node",`react-flow__node-${j}`,{[b]:D},S.className,{selected:S.selected,selectable:P,parent:A,draggable:D,dragging:O}]),ref:R,style:{zIndex:T.z,transform:`translate(${T.positionAbsolute.x}px,${T.positionAbsolute.y}px)`,pointerEvents:K?"all":"none",visibility:G?"visible":"hidden",...S.style,...X},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:U,onMouseMove:F,onMouseLeave:Y,onContextMenu:$,onClick:be,onDoubleClick:ie,onKeyDown:B?ce:void 0,tabIndex:B?0:void 0,onFocus:B?Ne:void 0,role:S.ariaRole??(B?"group":void 0),"aria-roledescription":"node","aria-describedby":x?void 0:`${hP}-${v}`,"aria-label":S.ariaLabel,...S.domAttributes,children:d.jsx(cue,{value:e,children:d.jsx(M,{id:e,data:S.data,type:j,positionAbsoluteX:T.positionAbsolute.x,positionAbsoluteY:T.positionAbsolute.y,selected:S.selected??!1,selectable:P,draggable:D,deletable:S.deletable??!0,isConnectable:I,sourcePosition:S.sourcePosition,targetPosition:S.targetPosition,dragging:O,dragHandle:S.dragHandle,zIndex:T.z,parentId:S.parentId,...W})})})}var Mue=_.memo(jue);const Rue=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function TP(e){const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:i,elementsSelectable:s,onError:r}=Bt(Rue,Sn),o=_ue(e.onlyRenderVisibleElements),c=Tue();return d.jsx("div",{className:"react-flow__nodes",style:wg,children:o.map(u=>d.jsx(Mue,{id:u,nodeTypes:e.nodeTypes,nodeExtent:e.nodeExtent,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,resizeObserver:c,nodesDraggable:t,nodesConnectable:n,nodesFocusable:i,elementsSelectable:s,nodeClickDistance:e.nodeClickDistance,onError:r},u))})}TP.displayName="NodeRenderer";const Due=_.memo(TP);function Oue(e){return Bt(_.useCallback(n=>{if(!e)return n.edges.map(s=>s.id);const i=[];if(n.width&&n.height)for(const s of n.edges){const r=n.nodeLookup.get(s.source),o=n.nodeLookup.get(s.target);r&&o&&Ale({sourceNode:r,targetNode:o,width:n.width,height:n.height,transform:n.transform})&&i.push(s.id)}return i},[e]),Sn)}const Lue=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e}};return d.jsx("polyline",{className:"arrow",style:n,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},Iue=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e,fill:e}};return d.jsx("polyline",{className:"arrowclosed",style:n,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},EA={[Am.Arrow]:Lue,[Am.ArrowClosed]:Iue};function Pue(e){const t=Nn();return _.useMemo(()=>{var s,r;return Object.prototype.hasOwnProperty.call(EA,e)?EA[e]:((r=(s=t.getState()).onError)==null||r.call(s,"009",cs.error009(e)),null)},[e])}const zue=({id:e,type:t,color:n,width:i=12.5,height:s=12.5,markerUnits:r="strokeWidth",strokeWidth:o,orient:c="auto-start-reverse"})=>{const u=Pue(t);return u?d.jsx("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${i}`,markerHeight:`${s}`,viewBox:"-10 -10 20 20",markerUnits:r,orient:c,refX:"0",refY:"0",children:d.jsx(u,{color:n,strokeWidth:o})}):null},AP=({defaultColor:e,rfId:t})=>{const n=Bt(r=>r.edges),i=Bt(r=>r.defaultEdgeOptions),s=_.useMemo(()=>Ple(n,{id:t,defaultColor:e,defaultMarkerStart:i==null?void 0:i.markerStart,defaultMarkerEnd:i==null?void 0:i.markerEnd}),[n,i,t,e]);return s.length?d.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:d.jsx("defs",{children:s.map(r=>d.jsx(zue,{id:r.id,type:r.type,color:r.color,width:r.width,height:r.height,markerUnits:r.markerUnits,strokeWidth:r.strokeWidth,orient:r.orient},r.id))})}):null};AP.displayName="MarkerDefinitions";var Bue=_.memo(AP);function jP({x:e,y:t,label:n,labelStyle:i,labelShowBg:s=!0,labelBgStyle:r,labelBgPadding:o=[2,4],labelBgBorderRadius:c=2,children:u,className:f,...p}){const[m,y]=_.useState({x:1,y:0,width:0,height:0}),b=Wn(["react-flow__edge-textwrapper",f]),x=_.useRef(null);return _.useEffect(()=>{if(x.current){const v=x.current.getBBox();y({x:v.x,y:v.y,width:v.width,height:v.height})}},[n]),n?d.jsxs("g",{transform:`translate(${e-m.width/2} ${t-m.height/2})`,className:b,visibility:m.width?"visible":"hidden",...p,children:[s&&d.jsx("rect",{width:m.width+2*o[0],x:-o[0],y:-o[1],height:m.height+2*o[1],className:"react-flow__edge-textbg",style:r,rx:c,ry:c}),d.jsx("text",{className:"react-flow__edge-text",y:m.height/2,dy:"0.3em",ref:x,style:i,children:n}),u]}):null}jP.displayName="EdgeText";const Uue=_.memo(jP);function Eg({path:e,labelX:t,labelY:n,label:i,labelStyle:s,labelShowBg:r,labelBgStyle:o,labelBgPadding:c,labelBgBorderRadius:u,interactionWidth:f=20,...p}){return d.jsxs(d.Fragment,{children:[d.jsx("path",{...p,d:e,fill:"none",className:Wn(["react-flow__edge-path",p.className])}),f?d.jsx("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:f,className:"react-flow__edge-interaction"}):null,i&&Xs(t)&&Xs(n)?d.jsx(Uue,{x:t,y:n,label:i,labelStyle:s,labelShowBg:r,labelBgStyle:o,labelBgPadding:c,labelBgBorderRadius:u}):null]})}function kA({pos:e,x1:t,y1:n,x2:i,y2:s}){return e===et.Left||e===et.Right?[.5*(t+i),n]:[t,.5*(n+s)]}function MP({sourceX:e,sourceY:t,sourcePosition:n=et.Bottom,targetX:i,targetY:s,targetPosition:r=et.Top}){const[o,c]=kA({pos:n,x1:e,y1:t,x2:i,y2:s}),[u,f]=kA({pos:r,x1:i,y1:s,x2:e,y2:t}),[p,m,y,b]=YI({sourceX:e,sourceY:t,targetX:i,targetY:s,sourceControlX:o,sourceControlY:c,targetControlX:u,targetControlY:f});return[`M${e},${t} C${o},${c} ${u},${f} ${i},${s}`,p,m,y,b]}function RP(e){return _.memo(({id:t,sourceX:n,sourceY:i,targetX:s,targetY:r,sourcePosition:o,targetPosition:c,label:u,labelStyle:f,labelShowBg:p,labelBgStyle:m,labelBgPadding:y,labelBgBorderRadius:b,style:x,markerEnd:v,markerStart:w,interactionWidth:k})=>{const[C,S,T]=MP({sourceX:n,sourceY:i,sourcePosition:o,targetX:s,targetY:r,targetPosition:c}),A=e.isInternal?void 0:t;return d.jsx(Eg,{id:A,path:C,labelX:S,labelY:T,label:u,labelStyle:f,labelShowBg:p,labelBgStyle:m,labelBgPadding:y,labelBgBorderRadius:b,style:x,markerEnd:v,markerStart:w,interactionWidth:k})})}const Fue=RP({isInternal:!1}),DP=RP({isInternal:!0});Fue.displayName="SimpleBezierEdge";DP.displayName="SimpleBezierEdgeInternal";function OP(e){return _.memo(({id:t,sourceX:n,sourceY:i,targetX:s,targetY:r,label:o,labelStyle:c,labelShowBg:u,labelBgStyle:f,labelBgPadding:p,labelBgBorderRadius:m,style:y,sourcePosition:b=et.Bottom,targetPosition:x=et.Top,markerEnd:v,markerStart:w,pathOptions:k,interactionWidth:C})=>{const[S,T,A]=Av({sourceX:n,sourceY:i,sourcePosition:b,targetX:s,targetY:r,targetPosition:x,borderRadius:k==null?void 0:k.borderRadius,offset:k==null?void 0:k.offset,stepPosition:k==null?void 0:k.stepPosition}),j=e.isInternal?void 0:t;return d.jsx(Eg,{id:j,path:S,labelX:T,labelY:A,label:o,labelStyle:c,labelShowBg:u,labelBgStyle:f,labelBgPadding:p,labelBgBorderRadius:m,style:y,markerEnd:v,markerStart:w,interactionWidth:C})})}const LP=OP({isInternal:!1}),IP=OP({isInternal:!0});LP.displayName="SmoothStepEdge";IP.displayName="SmoothStepEdgeInternal";function PP(e){return _.memo(({id:t,...n})=>{var s;const i=e.isInternal?void 0:t;return d.jsx(LP,{...n,id:i,pathOptions:_.useMemo(()=>{var r;return{borderRadius:0,offset:(r=n.pathOptions)==null?void 0:r.offset}},[(s=n.pathOptions)==null?void 0:s.offset])})})}const $ue=PP({isInternal:!1}),zP=PP({isInternal:!0});$ue.displayName="StepEdge";zP.displayName="StepEdgeInternal";function BP(e){return _.memo(({id:t,sourceX:n,sourceY:i,targetX:s,targetY:r,label:o,labelStyle:c,labelShowBg:u,labelBgStyle:f,labelBgPadding:p,labelBgBorderRadius:m,style:y,markerEnd:b,markerStart:x,interactionWidth:v})=>{const[w,k,C]=JI({sourceX:n,sourceY:i,targetX:s,targetY:r}),S=e.isInternal?void 0:t;return d.jsx(Eg,{id:S,path:w,labelX:k,labelY:C,label:o,labelStyle:c,labelShowBg:u,labelBgStyle:f,labelBgPadding:p,labelBgBorderRadius:m,style:y,markerEnd:b,markerStart:x,interactionWidth:v})})}const que=BP({isInternal:!1}),UP=BP({isInternal:!0});que.displayName="StraightEdge";UP.displayName="StraightEdgeInternal";function FP(e){return _.memo(({id:t,sourceX:n,sourceY:i,targetX:s,targetY:r,sourcePosition:o=et.Bottom,targetPosition:c=et.Top,label:u,labelStyle:f,labelShowBg:p,labelBgStyle:m,labelBgPadding:y,labelBgBorderRadius:b,style:x,markerEnd:v,markerStart:w,pathOptions:k,interactionWidth:C})=>{const[S,T,A]=XI({sourceX:n,sourceY:i,sourcePosition:o,targetX:s,targetY:r,targetPosition:c,curvature:k==null?void 0:k.curvature}),j=e.isInternal?void 0:t;return d.jsx(Eg,{id:j,path:S,labelX:T,labelY:A,label:u,labelStyle:f,labelShowBg:p,labelBgStyle:m,labelBgPadding:y,labelBgBorderRadius:b,style:x,markerEnd:v,markerStart:w,interactionWidth:C})})}const Hue=FP({isInternal:!1}),$P=FP({isInternal:!0});Hue.displayName="BezierEdge";$P.displayName="BezierEdgeInternal";const SA={default:$P,straight:UP,step:zP,smoothstep:IP,simplebezier:DP},NA={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null,zIndex:void 0},Vue=(e,t,n)=>n===et.Left?e-t:n===et.Right?e+t:e,Kue=(e,t,n)=>n===et.Top?e-t:n===et.Bottom?e+t:e,_A="react-flow__edgeupdater";function CA({position:e,centerX:t,centerY:n,radius:i=10,onMouseDown:s,onMouseEnter:r,onMouseOut:o,type:c}){return d.jsx("circle",{onMouseDown:s,onMouseEnter:r,onMouseOut:o,className:Wn([_A,`${_A}-${c}`]),cx:Vue(t,i,e),cy:Kue(n,i,e),r:i,stroke:"transparent",fill:"transparent"})}function Gue({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:i,sourceY:s,targetX:r,targetY:o,sourcePosition:c,targetPosition:u,onReconnect:f,onReconnectStart:p,onReconnectEnd:m,setReconnecting:y,setUpdateHover:b}){const x=Nn(),v=(T,A)=>{if(T.button!==0)return;const{autoPanOnConnect:j,domNode:M,connectionMode:D,connectionRadius:P,lib:I,onConnectStart:B,cancelConnection:q,nodeLookup:G,rfId:R,panBy:O,updateConnection:z}=x.getState(),W=A.type==="target",X=(F,Y)=>{y(!1),m==null||m(F,n,A.type,Y)},K=F=>f==null?void 0:f(n,F),U=(F,Y)=>{y(!0),p==null||p(T,n,A.type),B==null||B(F,Y)};Rv.onPointerDown(T.nativeEvent,{autoPanOnConnect:j,connectionMode:D,connectionRadius:P,domNode:M,handleId:A.id,nodeId:A.nodeId,nodeLookup:G,isTarget:W,edgeUpdaterType:A.type,lib:I,flowId:R,cancelConnection:q,panBy:O,isValidConnection:(...F)=>{var Y,$;return(($=(Y=x.getState()).isValidConnection)==null?void 0:$.call(Y,...F))??!0},onConnect:K,onConnectStart:U,onConnectEnd:(...F)=>{var Y,$;return($=(Y=x.getState()).onConnectEnd)==null?void 0:$.call(Y,...F)},onReconnectEnd:X,updateConnection:z,getTransform:()=>x.getState().transform,getFromHandle:()=>x.getState().connection.fromHandle,dragThreshold:x.getState().connectionDragThreshold,handleDomNode:T.currentTarget})},w=T=>v(T,{nodeId:n.target,id:n.targetHandle??null,type:"target"}),k=T=>v(T,{nodeId:n.source,id:n.sourceHandle??null,type:"source"}),C=()=>b(!0),S=()=>b(!1);return d.jsxs(d.Fragment,{children:[(e===!0||e==="source")&&d.jsx(CA,{position:c,centerX:i,centerY:s,radius:t,onMouseDown:w,onMouseEnter:C,onMouseOut:S,type:"source"}),(e===!0||e==="target")&&d.jsx(CA,{position:u,centerX:r,centerY:o,radius:t,onMouseDown:k,onMouseEnter:C,onMouseOut:S,type:"target"})]})}function Wue({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:i,onClick:s,onDoubleClick:r,onContextMenu:o,onMouseEnter:c,onMouseMove:u,onMouseLeave:f,reconnectRadius:p,onReconnect:m,onReconnectStart:y,onReconnectEnd:b,rfId:x,edgeTypes:v,noPanClassName:w,onError:k,disableKeyboardA11y:C}){let S=Bt(ge=>ge.edgeLookup.get(e));const T=Bt(ge=>ge.defaultEdgeOptions);S=T?{...T,...S}:S;let A=S.type||"default",j=(v==null?void 0:v[A])||SA[A];j===void 0&&(k==null||k("011",cs.error011(A)),A="default",j=(v==null?void 0:v.default)||SA.default);const M=!!(S.focusable||t&&typeof S.focusable>"u"),D=typeof m<"u"&&(S.reconnectable||n&&typeof S.reconnectable>"u"),P=!!(S.selectable||i&&typeof S.selectable>"u"),I=_.useRef(null),[B,q]=_.useState(!1),[G,R]=_.useState(!1),O=Nn(),{zIndex:z=S.zIndex,sourceX:W,sourceY:X,targetX:K,targetY:U,sourcePosition:F,targetPosition:Y}=Bt(_.useCallback(ge=>{const Ce=ge.nodeLookup.get(S.source),Ie=ge.nodeLookup.get(S.target);if(!Ce||!Ie)return NA;const ae=Ile({id:e,sourceNode:Ce,targetNode:Ie,sourceHandle:S.sourceHandle||null,targetHandle:S.targetHandle||null,connectionMode:ge.connectionMode,onError:k}),ke=Tle({selected:S.selected,zIndex:S.zIndex,sourceNode:Ce,targetNode:Ie,elevateOnSelect:ge.elevateEdgesOnSelect,zIndexMode:ge.zIndexMode});return{...ae||NA,zIndex:ke}},[S.source,S.target,S.sourceHandle,S.targetHandle,S.selected,S.zIndex]),Sn),$=_.useMemo(()=>S.markerStart?`url('#${jv(S.markerStart,x)}')`:void 0,[S.markerStart,x]),ie=_.useMemo(()=>S.markerEnd?`url('#${jv(S.markerEnd,x)}')`:void 0,[S.markerEnd,x]);if(S.hidden||W===null||X===null||K===null||U===null)return null;const be=ge=>{var ke;const{addSelectedEdges:Ce,unselectNodesAndEdges:Ie,multiSelectionActive:ae}=O.getState();P&&(O.setState({nodesSelectionActive:!1}),S.selected&&ae?(Ie({nodes:[],edges:[S]}),(ke=I.current)==null||ke.blur()):Ce([e])),s&&s(ge,S)},ce=r?ge=>{r(ge,{...S})}:void 0,Ne=o?ge=>{o(ge,{...S})}:void 0,oe=c?ge=>{c(ge,{...S})}:void 0,pe=u?ge=>{u(ge,{...S})}:void 0,re=f?ge=>{f(ge,{...S})}:void 0,ee=ge=>{var Ce;if(!C&&OI.includes(ge.key)&&P){const{unselectNodesAndEdges:Ie,addSelectedEdges:ae}=O.getState();ge.key==="Escape"?((Ce=I.current)==null||Ce.blur(),Ie({edges:[S]})):ae([e])}};return d.jsx("svg",{style:{zIndex:z},children:d.jsxs("g",{className:Wn(["react-flow__edge",`react-flow__edge-${A}`,S.className,w,{selected:S.selected,animated:S.animated,inactive:!P&&!s,updating:B,selectable:P}]),onClick:be,onDoubleClick:ce,onContextMenu:Ne,onMouseEnter:oe,onMouseMove:pe,onMouseLeave:re,onKeyDown:M?ee:void 0,tabIndex:M?0:void 0,role:S.ariaRole??(M?"group":"img"),"aria-roledescription":"edge","data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":S.ariaLabel===null?void 0:S.ariaLabel||`Edge from ${S.source} to ${S.target}`,"aria-describedby":M?`${pP}-${x}`:void 0,ref:I,...S.domAttributes,children:[!G&&d.jsx(j,{id:e,source:S.source,target:S.target,type:S.type,selected:S.selected,animated:S.animated,selectable:P,deletable:S.deletable??!0,label:S.label,labelStyle:S.labelStyle,labelShowBg:S.labelShowBg,labelBgStyle:S.labelBgStyle,labelBgPadding:S.labelBgPadding,labelBgBorderRadius:S.labelBgBorderRadius,sourceX:W,sourceY:X,targetX:K,targetY:U,sourcePosition:F,targetPosition:Y,data:S.data,style:S.style,sourceHandleId:S.sourceHandle,targetHandleId:S.targetHandle,markerStart:$,markerEnd:ie,pathOptions:"pathOptions"in S?S.pathOptions:void 0,interactionWidth:S.interactionWidth}),D&&d.jsx(Gue,{edge:S,isReconnectable:D,reconnectRadius:p,onReconnect:m,onReconnectStart:y,onReconnectEnd:b,sourceX:W,sourceY:X,targetX:K,targetY:U,sourcePosition:F,targetPosition:Y,setUpdateHover:q,setReconnecting:R})]})})}var Yue=_.memo(Wue);const Xue=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function qP({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:i,noPanClassName:s,onReconnect:r,onEdgeContextMenu:o,onEdgeMouseEnter:c,onEdgeMouseMove:u,onEdgeMouseLeave:f,onEdgeClick:p,reconnectRadius:m,onEdgeDoubleClick:y,onReconnectStart:b,onReconnectEnd:x,disableKeyboardA11y:v}){const{edgesFocusable:w,edgesReconnectable:k,elementsSelectable:C,onError:S}=Bt(Xue,Sn),T=Oue(t);return d.jsxs("div",{className:"react-flow__edges",children:[d.jsx(Bue,{defaultColor:e,rfId:n}),T.map(A=>d.jsx(Yue,{id:A,edgesFocusable:w,edgesReconnectable:k,elementsSelectable:C,noPanClassName:s,onReconnect:r,onContextMenu:o,onMouseEnter:c,onMouseMove:u,onMouseLeave:f,onClick:p,reconnectRadius:m,onDoubleClick:y,onReconnectStart:b,onReconnectEnd:x,rfId:n,onError:S,edgeTypes:i,disableKeyboardA11y:v},A))]})}qP.displayName="EdgeRenderer";const Que=_.memo(qP),Zue=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function Jue({children:e}){const t=Bt(Zue);return d.jsx("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:t},children:e})}function ede(e){const t=vg(),n=_.useRef(!1);_.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const tde=e=>{var t;return(t=e.panZoom)==null?void 0:t.syncViewport};function nde(e){const t=Bt(tde),n=Nn();return _.useEffect(()=>{e&&(t==null||t(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function ide(e){return e.connection.inProgress?{...e.connection,to:Rf(e.connection.to,e.transform)}:{...e.connection}}function sde(e){return ide}function rde(e){const t=sde();return Bt(t,Sn)}const ade=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function ode({containerStyle:e,style:t,type:n,component:i}){const{nodesConnectable:s,width:r,height:o,isValid:c,inProgress:u}=Bt(ade,Sn);return!(r&&s&&u)?null:d.jsx("svg",{style:e,width:r,height:o,className:"react-flow__connectionline react-flow__container",children:d.jsx("g",{className:Wn(["react-flow__connection",PI(c)]),children:d.jsx(HP,{style:t,type:n,CustomComponent:i,isValid:c})})})}const HP=({style:e,type:t=Va.Bezier,CustomComponent:n,isValid:i})=>{const{inProgress:s,from:r,fromNode:o,fromHandle:c,fromPosition:u,to:f,toNode:p,toHandle:m,toPosition:y,pointer:b}=rde();if(!s)return;if(n)return d.jsx(n,{connectionLineType:t,connectionLineStyle:e,fromNode:o,fromHandle:c,fromX:r.x,fromY:r.y,toX:f.x,toY:f.y,fromPosition:u,toPosition:y,connectionStatus:PI(i),toNode:p,toHandle:m,pointer:b});let x="";const v={sourceX:r.x,sourceY:r.y,sourcePosition:u,targetX:f.x,targetY:f.y,targetPosition:y};switch(t){case Va.Bezier:[x]=XI(v);break;case Va.SimpleBezier:[x]=MP(v);break;case Va.Step:[x]=Av({...v,borderRadius:0});break;case Va.SmoothStep:[x]=Av(v);break;default:[x]=JI(v)}return d.jsx("path",{d:x,fill:"none",className:"react-flow__connection-path",style:e})};HP.displayName="ConnectionLine";const lde={};function TA(e=lde){_.useRef(e),Nn(),_.useEffect(()=>{},[e])}function cde(){Nn(),_.useRef(!1),_.useEffect(()=>{},[])}function VP({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:i,onEdgeClick:s,onNodeDoubleClick:r,onEdgeDoubleClick:o,onNodeMouseEnter:c,onNodeMouseMove:u,onNodeMouseLeave:f,onNodeContextMenu:p,onSelectionContextMenu:m,onSelectionStart:y,onSelectionEnd:b,connectionLineType:x,connectionLineStyle:v,connectionLineComponent:w,connectionLineContainerStyle:k,selectionKeyCode:C,selectionOnDrag:S,selectionMode:T,multiSelectionKeyCode:A,panActivationKeyCode:j,zoomActivationKeyCode:M,deleteKeyCode:D,onlyRenderVisibleElements:P,elementsSelectable:I,defaultViewport:B,translateExtent:q,minZoom:G,maxZoom:R,preventScrolling:O,defaultMarkerColor:z,zoomOnScroll:W,zoomOnPinch:X,panOnScroll:K,panOnScrollSpeed:U,panOnScrollMode:F,zoomOnDoubleClick:Y,panOnDrag:$,autoPanOnSelection:ie,onPaneClick:be,onPaneMouseEnter:ce,onPaneMouseMove:Ne,onPaneMouseLeave:oe,onPaneScroll:pe,onPaneContextMenu:re,paneClickDistance:ee,nodeClickDistance:ge,onEdgeContextMenu:Ce,onEdgeMouseEnter:Ie,onEdgeMouseMove:ae,onEdgeMouseLeave:ke,reconnectRadius:Ue,onReconnect:Oe,onReconnectStart:ht,onReconnectEnd:tt,noDragClassName:jt,noWheelClassName:Nt,noPanClassName:pt,disableKeyboardA11y:Me,nodeExtent:We,rfId:ne,viewport:ve,onViewportChange:Re}){return TA(e),TA(t),cde(),ede(n),nde(ve),d.jsx(Sue,{onPaneClick:be,onPaneMouseEnter:ce,onPaneMouseMove:Ne,onPaneMouseLeave:oe,onPaneContextMenu:re,onPaneScroll:pe,paneClickDistance:ee,deleteKeyCode:D,selectionKeyCode:C,selectionOnDrag:S,selectionMode:T,onSelectionStart:y,onSelectionEnd:b,multiSelectionKeyCode:A,panActivationKeyCode:j,zoomActivationKeyCode:M,elementsSelectable:I,zoomOnScroll:W,zoomOnPinch:X,zoomOnDoubleClick:Y,panOnScroll:K,panOnScrollSpeed:U,panOnScrollMode:F,panOnDrag:$,autoPanOnSelection:ie,defaultViewport:B,translateExtent:q,minZoom:G,maxZoom:R,onSelectionContextMenu:m,preventScrolling:O,noDragClassName:jt,noWheelClassName:Nt,noPanClassName:pt,disableKeyboardA11y:Me,onViewportChange:Re,isControlledViewport:!!ve,children:d.jsxs(Jue,{children:[d.jsx(Que,{edgeTypes:t,onEdgeClick:s,onEdgeDoubleClick:o,onReconnect:Oe,onReconnectStart:ht,onReconnectEnd:tt,onlyRenderVisibleElements:P,onEdgeContextMenu:Ce,onEdgeMouseEnter:Ie,onEdgeMouseMove:ae,onEdgeMouseLeave:ke,reconnectRadius:Ue,defaultMarkerColor:z,noPanClassName:pt,disableKeyboardA11y:Me,rfId:ne}),d.jsx(ode,{style:v,type:x,component:w,containerStyle:k}),d.jsx("div",{className:"react-flow__edgelabel-renderer"}),d.jsx(Due,{nodeTypes:e,onNodeClick:i,onNodeDoubleClick:r,onNodeMouseEnter:c,onNodeMouseMove:u,onNodeMouseLeave:f,onNodeContextMenu:p,nodeClickDistance:ge,onlyRenderVisibleElements:P,noPanClassName:pt,noDragClassName:jt,disableKeyboardA11y:Me,nodeExtent:We,rfId:ne}),d.jsx("div",{className:"react-flow__viewport-portal"})]})})}VP.displayName="GraphView";const ude=_.memo(VP),dde=qI(),AA=({nodes:e,edges:t,defaultNodes:n,defaultEdges:i,width:s,height:r,fitView:o,fitViewOptions:c,minZoom:u=.5,maxZoom:f=2,nodeOrigin:p,nodeExtent:m,zIndexMode:y="basic"}={})=>{const b=new Map,x=new Map,v=new Map,w=new Map,k=i??t??[],C=n??e??[],S=p??[0,0],T=m??Zd;nP(v,w,k);const{nodesInitialized:A}=Mv(C,b,x,{nodeOrigin:S,nodeExtent:T,zIndexMode:y});let j=[0,0,1];if(o&&s&&r){const M=jf(b,{filter:B=>!!((B.width||B.initialWidth)&&(B.height||B.initialHeight))}),{x:D,y:P,zoom:I}=jw(M,s,r,u,f,(c==null?void 0:c.padding)??.1);j=[D,P,I]}return{rfId:"1",width:s??0,height:r??0,transform:j,nodes:C,nodesInitialized:A,nodeLookup:b,parentLookup:x,edges:k,edgeLookup:w,connectionLookup:v,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:i!==void 0,panZoom:null,minZoom:u,maxZoom:f,translateExtent:Zd,nodeExtent:T,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:Wc.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:S,nodeDragThreshold:1,connectionDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!0,selectNodesOnDrag:!0,multiSelectionActive:!1,fitViewQueued:o??!1,fitViewOptions:c,fitViewResolver:null,connection:{...II},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:dde,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:LI,zIndexMode:y,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},fde=({nodes:e,edges:t,defaultNodes:n,defaultEdges:i,width:s,height:r,fitView:o,fitViewOptions:c,minZoom:u,maxZoom:f,nodeOrigin:p,nodeExtent:m,zIndexMode:y})=>Nce((b,x)=>{async function v(){const{nodeLookup:w,panZoom:k,fitViewOptions:C,fitViewResolver:S,width:T,height:A,minZoom:j,maxZoom:M}=x();k&&(await wle({nodes:w,width:T,height:A,panZoom:k,minZoom:j,maxZoom:M},C),S==null||S.resolve(!0),b({fitViewResolver:null}))}return{...AA({nodes:e,edges:t,width:s,height:r,fitView:o,fitViewOptions:c,minZoom:u,maxZoom:f,nodeOrigin:p,nodeExtent:m,defaultNodes:n,defaultEdges:i,zIndexMode:y}),setNodes:w=>{const{nodeLookup:k,parentLookup:C,nodeOrigin:S,elevateNodesOnSelect:T,fitViewQueued:A,zIndexMode:j,nodesSelectionActive:M}=x(),{nodesInitialized:D,hasSelectedNodes:P}=Mv(w,k,C,{nodeOrigin:S,nodeExtent:m,elevateNodesOnSelect:T,checkEquality:!0,zIndexMode:j}),I=M&&P;A&&D?(v(),b({nodes:w,nodesInitialized:D,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:I})):b({nodes:w,nodesInitialized:D,nodesSelectionActive:I})},setEdges:w=>{const{connectionLookup:k,edgeLookup:C}=x();nP(k,C,w),b({edges:w})},setDefaultNodesAndEdges:(w,k)=>{if(w){const{setNodes:C}=x();C(w),b({hasDefaultNodes:!0})}if(k){const{setEdges:C}=x();C(k),b({hasDefaultEdges:!0})}},updateNodeInternals:w=>{const{triggerNodeChanges:k,nodeLookup:C,parentLookup:S,domNode:T,nodeOrigin:A,nodeExtent:j,debug:M,fitViewQueued:D,zIndexMode:P}=x(),{changes:I,updatedInternals:B}=Hle(w,C,S,T,A,j,P);B&&(Ule(C,S,{nodeOrigin:A,nodeExtent:j,zIndexMode:P}),D?(v(),b({fitViewQueued:!1,fitViewOptions:void 0})):b({}),(I==null?void 0:I.length)>0&&(M&&console.log("React Flow: trigger node changes",I),k==null||k(I)))},updateNodePositions:(w,k=!1)=>{const C=[];let S=[];const{nodeLookup:T,triggerNodeChanges:A,connection:j,updateConnection:M,onNodesChangeMiddlewareMap:D}=x();for(const[P,I]of w){const B=T.get(P),q=!!(B!=null&&B.expandParent&&(B!=null&&B.parentId)&&(I!=null&&I.position)),G={id:P,type:"position",position:q?{x:Math.max(0,I.position.x),y:Math.max(0,I.position.y)}:I.position,dragging:k};if(B&&j.inProgress&&j.fromNode.id===B.id){const R=yl(B,j.fromHandle,et.Left,!0);M({...j,from:R})}q&&B.parentId&&C.push({id:P,parentId:B.parentId,rect:{...I.internals.positionAbsolute,width:I.measured.width??0,height:I.measured.height??0}}),S.push(G)}if(C.length>0){const{parentLookup:P,nodeOrigin:I}=x(),B=Iw(C,T,P,I);S.push(...B)}for(const P of D.values())S=P(S);A(S)},triggerNodeChanges:w=>{const{onNodesChange:k,setNodes:C,nodes:S,hasDefaultNodes:T,debug:A}=x();if(w!=null&&w.length){if(T){const j=yP(w,S);C(j)}A&&console.log("React Flow: trigger node changes",w),k==null||k(w)}},triggerEdgeChanges:w=>{const{onEdgesChange:k,setEdges:C,edges:S,hasDefaultEdges:T,debug:A}=x();if(w!=null&&w.length){if(T){const j=bP(w,S);C(j)}A&&console.log("React Flow: trigger edge changes",w),k==null||k(w)}},addSelectedNodes:w=>{const{multiSelectionActive:k,edgeLookup:C,nodeLookup:S,triggerNodeChanges:T,triggerEdgeChanges:A}=x();if(k){const j=w.map(M=>Uo(M,!0));T(j);return}T(xc(S,new Set([...w]),!0)),A(xc(C))},addSelectedEdges:w=>{const{multiSelectionActive:k,edgeLookup:C,nodeLookup:S,triggerNodeChanges:T,triggerEdgeChanges:A}=x();if(k){const j=w.map(M=>Uo(M,!0));A(j);return}A(xc(C,new Set([...w]))),T(xc(S,new Set,!0))},unselectNodesAndEdges:({nodes:w,edges:k}={})=>{const{edges:C,nodes:S,nodeLookup:T,triggerNodeChanges:A,triggerEdgeChanges:j}=x(),M=w||S,D=k||C,P=[];for(const B of M){if(!B.selected)continue;const q=T.get(B.id);q&&(q.selected=!1),P.push(Uo(B.id,!1))}const I=[];for(const B of D)B.selected&&I.push(Uo(B.id,!1));A(P),j(I)},setMinZoom:w=>{const{panZoom:k,maxZoom:C}=x();k==null||k.setScaleExtent([w,C]),b({minZoom:w})},setMaxZoom:w=>{const{panZoom:k,minZoom:C}=x();k==null||k.setScaleExtent([C,w]),b({maxZoom:w})},setTranslateExtent:w=>{var k;(k=x().panZoom)==null||k.setTranslateExtent(w),b({translateExtent:w})},resetSelectedElements:()=>{const{edges:w,nodes:k,triggerNodeChanges:C,triggerEdgeChanges:S,elementsSelectable:T}=x();if(!T)return;const A=k.reduce((M,D)=>D.selected?[...M,Uo(D.id,!1)]:M,[]),j=w.reduce((M,D)=>D.selected?[...M,Uo(D.id,!1)]:M,[]);C(A),S(j)},setNodeExtent:w=>{const{nodes:k,nodeLookup:C,parentLookup:S,nodeOrigin:T,elevateNodesOnSelect:A,nodeExtent:j,zIndexMode:M}=x();w[0][0]===j[0][0]&&w[0][1]===j[0][1]&&w[1][0]===j[1][0]&&w[1][1]===j[1][1]||(Mv(k,C,S,{nodeOrigin:T,nodeExtent:w,elevateNodesOnSelect:A,checkEquality:!1,zIndexMode:M}),b({nodeExtent:w}))},panBy:w=>{const{transform:k,width:C,height:S,panZoom:T,translateExtent:A}=x();return Vle({delta:w,panZoom:T,transform:k,translateExtent:A,width:C,height:S})},setCenter:async(w,k,C)=>{const{width:S,height:T,maxZoom:A,panZoom:j}=x();if(!j)return!1;const M=typeof(C==null?void 0:C.zoom)<"u"?C.zoom:A;return await j.setViewport({x:S/2-w*M,y:T/2-k*M,zoom:M},{duration:C==null?void 0:C.duration,ease:C==null?void 0:C.ease,interpolate:C==null?void 0:C.interpolate}),!0},cancelConnection:()=>{b({connection:{...II}})},updateConnection:w=>{b({connection:w})},reset:()=>b({...AA()})}},Object.is);function KP({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:i,initialWidth:s,initialHeight:r,initialMinZoom:o,initialMaxZoom:c,initialFitViewOptions:u,fitView:f,nodeOrigin:p,nodeExtent:m,zIndexMode:y,children:b}){const[x]=_.useState(()=>fde({nodes:e,edges:t,defaultNodes:n,defaultEdges:i,width:s,height:r,fitView:f,minZoom:o,maxZoom:c,fitViewOptions:u,nodeOrigin:p,nodeExtent:m,zIndexMode:y}));return d.jsx(_ce,{value:x,children:d.jsx(Xce,{children:d.jsx(due,{children:b})})})}function hde({children:e,nodes:t,edges:n,defaultNodes:i,defaultEdges:s,width:r,height:o,fitView:c,fitViewOptions:u,minZoom:f,maxZoom:p,nodeOrigin:m,nodeExtent:y,zIndexMode:b}){return _.useContext(bg)?d.jsx(d.Fragment,{children:e}):d.jsx(KP,{initialNodes:t,initialEdges:n,defaultNodes:i,defaultEdges:s,initialWidth:r,initialHeight:o,fitView:c,initialFitViewOptions:u,initialMinZoom:f,initialMaxZoom:p,nodeOrigin:m,nodeExtent:y,zIndexMode:b,children:e})}const pde={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function mde({nodes:e,edges:t,defaultNodes:n,defaultEdges:i,className:s,nodeTypes:r,edgeTypes:o,onNodeClick:c,onEdgeClick:u,onInit:f,onMove:p,onMoveStart:m,onMoveEnd:y,onConnect:b,onConnectStart:x,onConnectEnd:v,onClickConnectStart:w,onClickConnectEnd:k,onNodeMouseEnter:C,onNodeMouseMove:S,onNodeMouseLeave:T,onNodeContextMenu:A,onNodeDoubleClick:j,onNodeDragStart:M,onNodeDrag:D,onNodeDragStop:P,onNodesDelete:I,onEdgesDelete:B,onDelete:q,onSelectionChange:G,onSelectionDragStart:R,onSelectionDrag:O,onSelectionDragStop:z,onSelectionContextMenu:W,onSelectionStart:X,onSelectionEnd:K,onBeforeDelete:U,connectionMode:F,connectionLineType:Y=Va.Bezier,connectionLineStyle:$,connectionLineComponent:ie,connectionLineContainerStyle:be,deleteKeyCode:ce="Backspace",selectionKeyCode:Ne="Shift",selectionOnDrag:oe=!1,selectionMode:pe=Jd.Full,panActivationKeyCode:re="Space",multiSelectionKeyCode:ee=tf()?"Meta":"Control",zoomActivationKeyCode:ge=tf()?"Meta":"Control",snapToGrid:Ce,snapGrid:Ie,onlyRenderVisibleElements:ae=!1,selectNodesOnDrag:ke,nodesDraggable:Ue,autoPanOnNodeFocus:Oe,nodesConnectable:ht,nodesFocusable:tt,nodeOrigin:jt=mP,edgesFocusable:Nt,edgesReconnectable:pt,elementsSelectable:Me=!0,defaultViewport:We=Bce,minZoom:ne=.5,maxZoom:ve=2,translateExtent:Re=Zd,preventScrolling:ye=!0,nodeExtent:Je,defaultMarkerColor:It="#b1b1b7",zoomOnScroll:Wt=!0,zoomOnPinch:he=!0,panOnScroll:le=!1,panOnScrollSpeed:Te=.5,panOnScrollMode:Ae=ol.Free,zoomOnDoubleClick:Qe=!0,panOnDrag:st=!0,onPaneClick:$e,onPaneMouseEnter:nt,onPaneMouseMove:qt,onPaneMouseLeave:Xt,onPaneScroll:Dt,onPaneContextMenu:Q,paneClickDistance:we=1,nodeClickDistance:Pe=0,children:ct,onReconnect:Qt,onReconnectStart:Ht,onReconnectEnd:He,onEdgeContextMenu:Fe,onEdgeDoubleClick:rt,onEdgeMouseEnter:hn,onEdgeMouseMove:on,onEdgeMouseLeave:ki,reconnectRadius:us=10,onNodesChange:ds,onEdgesChange:Di,noDragClassName:pn="nodrag",noWheelClassName:In="nowheel",noPanClassName:Yn="nopan",fitView:Ds,fitViewOptions:jr,connectOnClick:Os,attributionPosition:Mr,proOptions:fs,defaultEdgeOptions:Rr,elevateNodesOnSelect:Xn=!0,elevateEdgesOnSelect:Gi=!1,disableKeyboardA11y:Si=!1,autoPanOnConnect:hs,autoPanOnNodeDrag:vn,autoPanOnSelection:Dr=!0,autoPanSpeed:Qn,connectionRadius:jn,isValidConnection:je,onError:Ye,style:xt,id:Pt,nodeDragThreshold:gn,connectionDragThreshold:Un,viewport:ci,onViewportChange:ti,width:Vt,height:ni,colorMode:Or="light",debug:ii,onScroll:si,ariaLabelConfig:Ls,zIndexMode:ma="basic",...ri},Wi){const yi=Pt||"1",Is=qce(Or),Mn=_.useCallback(rr=>{rr.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),si==null||si(rr)},[si]);return d.jsx("div",{"data-testid":"rf__wrapper",...ri,onScroll:Mn,style:{...xt,...pde},ref:Wi,className:Wn(["react-flow",s,Is]),id:Pt,role:"application",children:d.jsxs(hde,{nodes:e,edges:t,width:Vt,height:ni,fitView:Ds,fitViewOptions:jr,minZoom:ne,maxZoom:ve,nodeOrigin:jt,nodeExtent:Je,zIndexMode:ma,children:[d.jsx($ce,{nodes:e,edges:t,defaultNodes:n,defaultEdges:i,onConnect:b,onConnectStart:x,onConnectEnd:v,onClickConnectStart:w,onClickConnectEnd:k,nodesDraggable:Ue,autoPanOnNodeFocus:Oe,nodesConnectable:ht,nodesFocusable:tt,edgesFocusable:Nt,edgesReconnectable:pt,elementsSelectable:Me,elevateNodesOnSelect:Xn,elevateEdgesOnSelect:Gi,minZoom:ne,maxZoom:ve,nodeExtent:Je,onNodesChange:ds,onEdgesChange:Di,snapToGrid:Ce,snapGrid:Ie,connectionMode:F,translateExtent:Re,connectOnClick:Os,defaultEdgeOptions:Rr,fitView:Ds,fitViewOptions:jr,onNodesDelete:I,onEdgesDelete:B,onDelete:q,onNodeDragStart:M,onNodeDrag:D,onNodeDragStop:P,onSelectionDrag:O,onSelectionDragStart:R,onSelectionDragStop:z,onMove:p,onMoveStart:m,onMoveEnd:y,noPanClassName:Yn,nodeOrigin:jt,rfId:yi,autoPanOnConnect:hs,autoPanOnNodeDrag:vn,autoPanSpeed:Qn,onError:Ye,connectionRadius:jn,isValidConnection:je,selectNodesOnDrag:ke,nodeDragThreshold:gn,connectionDragThreshold:Un,onBeforeDelete:U,debug:ii,ariaLabelConfig:Ls,zIndexMode:ma}),d.jsx(ude,{onInit:f,onNodeClick:c,onEdgeClick:u,onNodeMouseEnter:C,onNodeMouseMove:S,onNodeMouseLeave:T,onNodeContextMenu:A,onNodeDoubleClick:j,nodeTypes:r,edgeTypes:o,connectionLineType:Y,connectionLineStyle:$,connectionLineComponent:ie,connectionLineContainerStyle:be,selectionKeyCode:Ne,selectionOnDrag:oe,selectionMode:pe,deleteKeyCode:ce,multiSelectionKeyCode:ee,panActivationKeyCode:re,zoomActivationKeyCode:ge,onlyRenderVisibleElements:ae,defaultViewport:We,translateExtent:Re,minZoom:ne,maxZoom:ve,preventScrolling:ye,zoomOnScroll:Wt,zoomOnPinch:he,zoomOnDoubleClick:Qe,panOnScroll:le,panOnScrollSpeed:Te,panOnScrollMode:Ae,panOnDrag:st,autoPanOnSelection:Dr,onPaneClick:$e,onPaneMouseEnter:nt,onPaneMouseMove:qt,onPaneMouseLeave:Xt,onPaneScroll:Dt,onPaneContextMenu:Q,paneClickDistance:we,nodeClickDistance:Pe,onSelectionContextMenu:W,onSelectionStart:X,onSelectionEnd:K,onReconnect:Qt,onReconnectStart:Ht,onReconnectEnd:He,onEdgeContextMenu:Fe,onEdgeDoubleClick:rt,onEdgeMouseEnter:hn,onEdgeMouseMove:on,onEdgeMouseLeave:ki,reconnectRadius:us,defaultMarkerColor:It,noDragClassName:pn,noWheelClassName:In,noPanClassName:Yn,rfId:yi,disableKeyboardA11y:Si,nodeExtent:Je,viewport:ci,onViewportChange:ti}),d.jsx(zce,{onSelectionChange:G}),ct,d.jsx(Dce,{proOptions:fs,position:Mr}),d.jsx(Rce,{rfId:yi,disableKeyboardA11y:Si})]})})}var gde=wP(mde);function yde(e){const[t,n]=_.useState(e),i=_.useCallback(s=>n(r=>yP(s,r)),[]);return[t,n,i]}function bde(e){const[t,n]=_.useState(e),i=_.useCallback(s=>n(r=>bP(s,r)),[]);return[t,n,i]}function xde({dimensions:e,lineWidth:t,variant:n,className:i}){return d.jsx("path",{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:Wn(["react-flow__background-pattern",n,i])})}function vde({radius:e,className:t}){return d.jsx("circle",{cx:e,cy:e,r:e,className:Wn(["react-flow__background-pattern","dots",t])})}var la;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(la||(la={}));const wde={[la.Dots]:1,[la.Lines]:1,[la.Cross]:6},Ede=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function GP({id:e,variant:t=la.Dots,gap:n=20,size:i,lineWidth:s=1,offset:r=0,color:o,bgColor:c,style:u,className:f,patternClassName:p}){const m=_.useRef(null),{transform:y,patternId:b}=Bt(Ede,Sn),x=i||wde[t],v=t===la.Dots,w=t===la.Cross,k=Array.isArray(n)?n:[n,n],C=[k[0]*y[2]||1,k[1]*y[2]||1],S=x*y[2],T=Array.isArray(r)?r:[r,r],A=w?[S,S]:C,j=[T[0]*y[2]||1+A[0]/2,T[1]*y[2]||1+A[1]/2],M=`${b}${e||""}`;return d.jsxs("svg",{className:Wn(["react-flow__background",f]),style:{...u,...wg,"--xy-background-color-props":c,"--xy-background-pattern-color-props":o},ref:m,"data-testid":"rf__background",children:[d.jsx("pattern",{id:M,x:y[0]%C[0],y:y[1]%C[1],width:C[0],height:C[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${j[0]},-${j[1]})`,children:v?d.jsx(vde,{radius:S/2,className:p}):d.jsx(xde,{dimensions:A,lineWidth:s,variant:t,className:p})}),d.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${M})`})]})}GP.displayName="Background";const kde=_.memo(GP);function Sde(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:d.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function Nde(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:d.jsx("path",{d:"M0 0h32v4.2H0z"})})}function _de(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:d.jsx("path",{d:"M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z"})})}function Cde(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:d.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z"})})}function Tde(){return d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:d.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"})})}function wd({children:e,className:t,...n}){return d.jsx("button",{type:"button",className:Wn(["react-flow__controls-button",t]),...n,children:e})}const Ade=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function WP({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:i=!0,fitViewOptions:s,onZoomIn:r,onZoomOut:o,onFitView:c,onInteractiveChange:u,className:f,children:p,position:m="bottom-left",orientation:y="vertical","aria-label":b}){const x=Nn(),{isInteractive:v,minZoomReached:w,maxZoomReached:k,ariaLabelConfig:C}=Bt(Ade,Sn),{zoomIn:S,zoomOut:T,fitView:A}=vg(),j=()=>{S(),r==null||r()},M=()=>{T(),o==null||o()},D=()=>{A(s),c==null||c()},P=()=>{x.setState({nodesDraggable:!v,nodesConnectable:!v,elementsSelectable:!v}),u==null||u(!v)},I=y==="horizontal"?"horizontal":"vertical";return d.jsxs(xg,{className:Wn(["react-flow__controls",I,f]),position:m,style:e,"data-testid":"rf__controls","aria-label":b??C["controls.ariaLabel"],children:[t&&d.jsxs(d.Fragment,{children:[d.jsx(wd,{onClick:j,className:"react-flow__controls-zoomin",title:C["controls.zoomIn.ariaLabel"],"aria-label":C["controls.zoomIn.ariaLabel"],disabled:k,children:d.jsx(Sde,{})}),d.jsx(wd,{onClick:M,className:"react-flow__controls-zoomout",title:C["controls.zoomOut.ariaLabel"],"aria-label":C["controls.zoomOut.ariaLabel"],disabled:w,children:d.jsx(Nde,{})})]}),n&&d.jsx(wd,{className:"react-flow__controls-fitview",onClick:D,title:C["controls.fitView.ariaLabel"],"aria-label":C["controls.fitView.ariaLabel"],children:d.jsx(_de,{})}),i&&d.jsx(wd,{className:"react-flow__controls-interactive",onClick:P,title:C["controls.interactive.ariaLabel"],"aria-label":C["controls.interactive.ariaLabel"],children:v?d.jsx(Tde,{}):d.jsx(Cde,{})}),p]})}WP.displayName="Controls";const jde=_.memo(WP);function Mde({id:e,x:t,y:n,width:i,height:s,style:r,color:o,strokeColor:c,strokeWidth:u,className:f,borderRadius:p,shapeRendering:m,selected:y,onClick:b}){const{background:x,backgroundColor:v}=r||{},w=o||x||v;return d.jsx("rect",{className:Wn(["react-flow__minimap-node",{selected:y},f]),x:t,y:n,rx:p,ry:p,width:i,height:s,style:{fill:w,stroke:c,strokeWidth:u},shapeRendering:m,onClick:b?k=>b(k,e):void 0})}const Rde=_.memo(Mde),Dde=e=>e.nodes.map(t=>t.id),Wx=e=>e instanceof Function?e:()=>e;function Ode({nodeStrokeColor:e,nodeColor:t,nodeClassName:n="",nodeBorderRadius:i=5,nodeStrokeWidth:s,nodeComponent:r=Rde,onClick:o}){const c=Bt(Dde,Sn),u=Wx(t),f=Wx(e),p=Wx(n),m=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return d.jsx(d.Fragment,{children:c.map(y=>d.jsx(Ide,{id:y,nodeColorFunc:u,nodeStrokeColorFunc:f,nodeClassNameFunc:p,nodeBorderRadius:i,nodeStrokeWidth:s,NodeComponent:r,onClick:o,shapeRendering:m},y))})}function Lde({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:i,nodeBorderRadius:s,nodeStrokeWidth:r,shapeRendering:o,NodeComponent:c,onClick:u}){const{node:f,x:p,y:m,width:y,height:b}=Bt(x=>{const v=x.nodeLookup.get(e);if(!v)return{node:void 0,x:0,y:0,width:0,height:0};const w=v.internals.userNode,{x:k,y:C}=v.internals.positionAbsolute,{width:S,height:T}=pa(w);return{node:w,x:k,y:C,width:S,height:T}},Sn);return!f||f.hidden||!HI(f)?null:d.jsx(c,{x:p,y:m,width:y,height:b,style:f.style,selected:!!f.selected,className:i(f),color:t(f),borderRadius:s,strokeColor:n(f),strokeWidth:r,shapeRendering:o,onClick:u,id:f.id})}const Ide=_.memo(Lde);var Pde=_.memo(Ode);const zde=200,Bde=150,Ude=e=>!e.hidden,Fde=e=>{const t={x:-e.transform[0]/e.transform[2],y:-e.transform[1]/e.transform[2],width:e.width/e.transform[2],height:e.height/e.transform[2]};return{viewBB:t,boundingRect:e.nodeLookup.size>0?FI(jf(e.nodeLookup,{filter:Ude}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},$de="react-flow__minimap-desc";function YP({style:e,className:t,nodeStrokeColor:n,nodeColor:i,nodeClassName:s="",nodeBorderRadius:r=5,nodeStrokeWidth:o,nodeComponent:c,bgColor:u,maskColor:f,maskStrokeColor:p,maskStrokeWidth:m,position:y="bottom-right",onClick:b,onNodeClick:x,pannable:v=!1,zoomable:w=!1,ariaLabel:k,inversePan:C,zoomStep:S=1,offsetScale:T=5}){const A=Nn(),j=_.useRef(null),{boundingRect:M,viewBB:D,rfId:P,panZoom:I,translateExtent:B,flowWidth:q,flowHeight:G,ariaLabelConfig:R}=Bt(Fde,Sn),O=(e==null?void 0:e.width)??zde,z=(e==null?void 0:e.height)??Bde,W=M.width/O,X=M.height/z,K=Math.max(W,X),U=K*O,F=K*z,Y=T*K,$=M.x-(U-M.width)/2-Y,ie=M.y-(F-M.height)/2-Y,be=U+Y*2,ce=F+Y*2,Ne=`${$de}-${P}`,oe=_.useRef(0),pe=_.useRef();oe.current=K,_.useEffect(()=>{if(j.current&&I)return pe.current=ece({domNode:j.current,panZoom:I,getTransform:()=>A.getState().transform,getViewScale:()=>oe.current}),()=>{var Ce;(Ce=pe.current)==null||Ce.destroy()}},[I]),_.useEffect(()=>{var Ce;(Ce=pe.current)==null||Ce.update({translateExtent:B,width:q,height:G,inversePan:C,pannable:v,zoomStep:S,zoomable:w})},[v,w,C,S,B,q,G]);const re=b?Ce=>{var ke;const[Ie,ae]=((ke=pe.current)==null?void 0:ke.pointer(Ce))||[0,0];b(Ce,{x:Ie,y:ae})}:void 0,ee=x?_.useCallback((Ce,Ie)=>{const ae=A.getState().nodeLookup.get(Ie).internals.userNode;x(Ce,ae)},[]):void 0,ge=k??R["minimap.ariaLabel"];return d.jsx(xg,{position:y,style:{...e,"--xy-minimap-background-color-props":typeof u=="string"?u:void 0,"--xy-minimap-mask-background-color-props":typeof f=="string"?f:void 0,"--xy-minimap-mask-stroke-color-props":typeof p=="string"?p:void 0,"--xy-minimap-mask-stroke-width-props":typeof m=="number"?m*K:void 0,"--xy-minimap-node-background-color-props":typeof i=="string"?i:void 0,"--xy-minimap-node-stroke-color-props":typeof n=="string"?n:void 0,"--xy-minimap-node-stroke-width-props":typeof o=="number"?o:void 0},className:Wn(["react-flow__minimap",t]),"data-testid":"rf__minimap",children:d.jsxs("svg",{width:O,height:z,viewBox:`${$} ${ie} ${be} ${ce}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":Ne,ref:j,onClick:re,children:[ge&&d.jsx("title",{id:Ne,children:ge}),d.jsx(Pde,{onClick:ee,nodeColor:i,nodeStrokeColor:n,nodeBorderRadius:r,nodeClassName:s,nodeStrokeWidth:o,nodeComponent:c}),d.jsx("path",{className:"react-flow__minimap-mask",d:`M${$-Y},${ie-Y}h${be+Y*2}v${ce+Y*2}h${-be-Y*2}z
|
|
843
843
|
M${D.x},${D.y}h${D.width}v${D.height}h${-D.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}YP.displayName="MiniMap";_.memo(YP);const qde=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,Hde={[Qc.Line]:"right",[Qc.Handle]:"bottom-right"};function Vde({nodeId:e,position:t,variant:n=Qc.Handle,className:i,style:s=void 0,children:r,color:o,minWidth:c=10,minHeight:u=10,maxWidth:f=Number.MAX_VALUE,maxHeight:p=Number.MAX_VALUE,keepAspectRatio:m=!1,resizeDirection:y,autoScale:b=!0,shouldResize:x,onResizeStart:v,onResize:w,onResizeEnd:k}){const C=NP(),S=typeof e=="string"?e:C,T=Nn(),A=_.useRef(null),j=n===Qc.Handle,M=Bt(_.useCallback(qde(j&&b),[j,b]),Sn),D=_.useRef(null),P=t??Hde[n];_.useEffect(()=>{if(!(!A.current||!S))return D.current||(D.current=hce({domNode:A.current,nodeId:S,getStoreItems:()=>{const{nodeLookup:B,transform:q,snapGrid:G,snapToGrid:R,nodeOrigin:O,domNode:z}=T.getState();return{nodeLookup:B,transform:q,snapGrid:G,snapToGrid:R,nodeOrigin:O,paneDomNode:z}},onChange:(B,q)=>{const{triggerNodeChanges:G,nodeLookup:R,parentLookup:O,nodeOrigin:z}=T.getState(),W=[],X={x:B.x,y:B.y},K=R.get(S);if(K&&K.expandParent&&K.parentId){const U=K.origin??z,F=B.width??K.measured.width??0,Y=B.height??K.measured.height??0,$={id:K.id,parentId:K.parentId,rect:{width:F,height:Y,...VI({x:B.x??K.position.x,y:B.y??K.position.y},{width:F,height:Y},K.parentId,R,U)}},ie=Iw([$],R,O,z);W.push(...ie),X.x=B.x?Math.max(U[0]*F,B.x):void 0,X.y=B.y?Math.max(U[1]*Y,B.y):void 0}if(X.x!==void 0&&X.y!==void 0){const U={id:S,type:"position",position:{...X}};W.push(U)}if(B.width!==void 0&&B.height!==void 0){const F={id:S,type:"dimensions",resizing:!0,setAttributes:y?y==="horizontal"?"width":"height":!0,dimensions:{width:B.width,height:B.height}};W.push(F)}for(const U of q){const F={...U,type:"position"};W.push(F)}G(W)},onEnd:({width:B,height:q})=>{const G={id:S,type:"dimensions",resizing:!1,dimensions:{width:B,height:q}};T.getState().triggerNodeChanges([G])}})),D.current.update({controlPosition:P,boundaries:{minWidth:c,minHeight:u,maxWidth:f,maxHeight:p},keepAspectRatio:m,resizeDirection:y,onResizeStart:v,onResize:w,onResizeEnd:k,shouldResize:x}),()=>{var B;(B=D.current)==null||B.destroy()}},[P,c,u,f,p,m,v,w,k,x]);const I=P.split("-");return d.jsx("div",{className:Wn(["react-flow__resize-control","nodrag",...I,n,i]),ref:A,style:{...s,scale:M,...o&&{[j?"backgroundColor":"borderColor"]:o}},children:r})}_.memo(Vde);function Kde(e){return St(`/api/projects/${encodeURIComponent(e)}/flow`)}function Gde(e,t){return Pm(`/api/projects/${encodeURIComponent(e)}/flow`,t)}const Ov={done:"var(--color-running)",doing:"var(--color-running)",todo:"var(--color-text-subtle)",stuck:"var(--color-crashed)"},jA=["var(--color-accent-mint)","var(--color-accent-pink)","var(--color-accent-purple)","var(--color-accent-yellow)","var(--color-running-bg)","var(--color-idle-bg)"];function Wde(e){let t=0;for(let n=0;n<e.length;n+=1)t=t*31+e.charCodeAt(n)>>>0;return jA[t%jA.length]}const Ep={width:9,height:9,background:"var(--color-bg)",border:"1px solid var(--color-border-light)"},Yde=_.memo(function({id:t,data:n,selected:i}){const s=n,r=s.skills.split(",").map(o=>o.trim()).filter(Boolean);return d.jsxs("div",{className:`flow-node-glow${i?" is-selected":""}${s.status==="doing"?" is-running":""}`,children:[d.jsx(no,{id:"l",type:"target",position:et.Left,style:Ep}),d.jsx(no,{id:"t",type:"target",position:et.Top,style:Ep}),d.jsxs("div",{className:"rounded-2xl border border-[var(--color-border-light)] bg-[var(--color-bg-soft)] overflow-hidden cursor-pointer flex flex-col",style:{width:260,height:158,boxShadow:"var(--surface-card-border) 0 0 0 1px inset"},children:[d.jsxs("div",{className:"flex items-center gap-2 px-2.5 py-1.5 border-b border-[var(--color-border-light)]",style:{background:Wde(t)},children:[d.jsxs("span",{className:"font-[family-name:var(--font-mono)] text-xs font-bold text-[var(--color-text)]",children:["#",s.seq]}),d.jsxs("span",{className:"relative shrink-0 ml-auto flex items-center justify-center w-2.5 h-2.5",title:s.status,children:[s.status==="doing"&&d.jsx("span",{className:"absolute inline-flex w-full h-full rounded-full animate-ping opacity-60",style:{background:Ov.doing}}),d.jsx("span",{className:"relative w-2.5 h-2.5 rounded-full",style:{background:Ov[s.status]??"var(--color-text-subtle)"}})]})]}),d.jsxs("div",{className:"px-2.5 py-2 flex-1 min-h-0 overflow-hidden",children:[d.jsx("p",{className:"text-[13px] font-semibold text-[var(--color-text)] leading-snug line-clamp-3",children:s.title||"任务"}),r.length>0&&d.jsx("div",{className:"flex flex-wrap gap-1 mt-2 max-h-[46px] overflow-hidden",children:r.slice(0,6).map(o=>d.jsx("span",{className:"text-[10px] font-[family-name:var(--font-mono)] px-1.5 py-0.5 rounded bg-[var(--surface-code)] text-[var(--color-text)]",children:o},o))})]})]}),d.jsx(no,{id:"r",type:"source",position:et.Right,style:Ep}),d.jsx(no,{id:"b",type:"source",position:et.Bottom,style:Ep})]})});function Xde(e){if(!e)return"";const t=e.split(`
|
|
844
844
|
`),n=t.findIndex(s=>/^##\s+描述\s*$/.test(s));if(n===-1)return"";let i=t.length;for(let s=n+1;s<t.length;s+=1)if(/^##\s+/.test(t[s]??"")){i=s;break}return t.slice(n+1,i).join(`
|
|
845
|
-
`).trim()}function Qde(e,t){return t.includes("NEEDS-FIX")?"stuck":e==="Done"?"done":e==="Inprogress"?"doing":"todo"}function Zde({project:e,seq:t,onClose:n,onChanged:i,onDelete:s}){var G;const r=Xe(),[o,c]=_.useState(!0),[u,f]=_.useState(!1),[p,m]=_.useState(""),[y,b]=_.useState(""),[x,v]=_.useState(new Set),[w,k]=_.useState(""),[C,S]=_.useState("todo"),[T,A]=_.useState(null),[j,M]=_.useState(""),D=ot({queryKey:["skills-all",e],queryFn:()=>og(e)}),P=((G=D.data)==null?void 0:G.data)??[];_.useEffect(()=>{const R=O=>{O.key==="Escape"&&n()};return window.addEventListener("keydown",R),()=>window.removeEventListener("keydown",R)},[n]),_.useEffect(()=>{let R=!1;return c(!0),qL(e,t).then(O=>{R||(m(O.title),v(new Set(O.skills??[])),b(Xde(O.body)),k(O.state),S(Qde(O.state,O.labels??[])),A(typeof O.order=="number"?O.order:null))}).catch(()=>{}).finally(()=>{R||c(!1)}),()=>{R=!0}},[e,t]);const I=R=>{v(O=>{const z=new Set(O);return z.has(R)?z.delete(R):z.add(R),z})},B=async()=>{M(""),f(!0);try{await wm(e,t,{title:p.trim()||r("flow.node.default"),description:y,skills:[...x]}),i(),n()}catch(R){M(R instanceof Error?R.message:String(R)),f(!1)}},q=()=>s(t);return d.jsx("div",{role:"dialog","aria-modal":"true",className:"fixed inset-0 z-40 flex items-center justify-center p-4 md:p-6 bg-black/30 overflow-hidden",onClick:n,children:d.jsxs("div",{className:"nb-card w-full max-w-4xl flex flex-col bg-[var(--color-bg)]",style:{maxHeight:"calc(100vh - 48px)"},onClick:R=>R.stopPropagation(),children:[d.jsxs("header",{className:"flex items-start justify-between gap-4 mb-4 flex-shrink-0",children:[d.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[d.jsxs("span",{className:"font-[family-name:var(--font-mono)] font-bold text-xs px-2 py-0.5 bg-[var(--color-accent-purple)] border-2 border-[var(--color-text)] rounded-full",children:["#",t]}),w&&d.jsxs("span",{className:"inline-flex items-center gap-1.5 text-xs px-2 py-0.5 border-2 border-[var(--color-text)] rounded-full font-semibold",children:[d.jsx("span",{className:"w-2.5 h-2.5 rounded-full inline-block border border-[var(--color-text)]",style:{background:Ov[C]??"gray"}}),w]}),T!=null&&d.jsx("span",{className:"font-[family-name:var(--font-mono)] text-xs px-2 py-0.5 bg-[var(--color-accent-mint)] border-2 border-[var(--color-text)] rounded-full font-semibold",title:r("flow.lane.orderTip"),children:r("flow.lane.wave",{n:T})})]}),d.jsx("button",{onClick:n,className:"nb-btn nb-btn-mint p-2 flex-shrink-0","aria-label":r("flow.node.close"),type:"button",children:d.jsx(En,{size:14,strokeWidth:3})})]}),o?d.jsxs("div",{className:"flex items-center gap-2 text-sm text-[var(--color-text-muted)] py-10 justify-center",children:[d.jsx(mt,{size:16,className:"animate-spin"})," …"]}):d.jsxs(d.Fragment,{children:[j&&d.jsx("div",{className:"text-sm text-[var(--color-crashed)] mb-3",children:j}),d.jsxs("div",{className:"grid min-h-0 flex-1 grid-cols-1 gap-4 overflow-y-auto pr-1 md:grid-cols-[minmax(0,1fr)_minmax(260px,340px)] md:overflow-hidden md:pr-0",children:[d.jsxs("div",{className:"flex min-h-0 flex-col gap-4 md:overflow-y-auto md:pr-1",children:[d.jsxs("label",{className:"flex flex-col gap-1.5",children:[d.jsx("span",{className:"text-sm font-bold",children:r("flow.node.title")}),d.jsx("input",{className:"nb-input w-full text-base font-semibold",value:p,onChange:R=>m(R.target.value),autoFocus:!0})]}),d.jsxs("label",{className:"flex flex-1 min-h-0 flex-col gap-1.5",children:[d.jsx("span",{className:"text-sm font-bold",children:r("flow.node.desc")}),d.jsx("textarea",{className:"nb-input w-full flex-1 min-h-0",style:{minHeight:200,resize:"vertical"},value:y,onChange:R=>b(R.target.value)})]})]}),d.jsxs("section",{className:"flex min-h-[200px] flex-col gap-2 md:min-h-0 md:overflow-hidden",children:[d.jsx("span",{className:"text-sm font-bold",children:r("flow.node.skills")}),d.jsx("div",{className:"scroll-frame min-h-0 flex-1 rounded-lg border-2 border-[var(--color-border-light)] bg-[var(--color-bg-cream)]",children:d.jsxs("div",{className:"scroll-frame-body h-full p-2",children:[D.isLoading&&d.jsx(mt,{size:14,className:"animate-spin text-[var(--color-text-muted)]"}),P.length>0&&d.jsx("div",{className:"flex flex-wrap gap-2",children:P.map(R=>{const O=x.has(R.name);return d.jsx("button",{type:"button",onClick:()=>I(R.name),className:["max-w-full break-all px-2.5 py-1 text-left text-xs font-[family-name:var(--font-mono)] rounded-full border-2 transition-all",O?"bg-[var(--color-accent-mint)] border-[var(--color-text)] shadow-[2px_2px_0_var(--color-text)] font-bold":"bg-[var(--color-bg)] border-[var(--color-border-light)] hover:border-[var(--color-text)]"].join(" "),"aria-pressed":O,children:R.name},R.name)})})]})}),x.size>0&&d.jsx("p",{className:"max-h-14 overflow-y-auto break-words text-xs text-[var(--color-text-muted)]",children:[...x].join(", ")})]})]}),d.jsxs("div",{className:"flex gap-2 justify-between mt-4 pt-3 border-t-2 border-dashed border-[var(--color-text)] flex-shrink-0",children:[d.jsxs("button",{type:"button",className:"nb-btn nb-btn-danger",onClick:()=>void q(),disabled:u,children:[d.jsx(Rs,{size:14,strokeWidth:2.4})," ",r("flow.node.delete")]}),d.jsxs("button",{type:"button",className:"nb-btn nb-btn-cta",onClick:()=>void B(),disabled:u,children:[u?d.jsx(mt,{size:14,className:"animate-spin"}):null,r("flow.node.save")]})]})]})]})})}const Jde=_.memo(function({data:t}){const n=t;return d.jsxs("div",{className:"relative w-full h-full rounded-2xl border-2 border-dashed border-[var(--color-text)]",children:[d.jsx("div",{className:"absolute inset-0 rounded-2xl",style:{background:n.color,opacity:.16}}),d.jsxs("span",{className:"absolute top-1.5 left-2.5 inline-flex items-center gap-1.5 px-2 py-0.5 text-[11px] font-bold rounded-md border-2 border-[var(--color-text)] bg-[var(--color-bg)] text-[var(--color-text)] whitespace-nowrap max-w-[90%]",children:[d.jsx("span",{className:"truncate",children:n.label}),n.sub&&d.jsx("span",{className:"font-normal text-[var(--color-text-muted)]",children:n.sub})]})]})});function efe(e){const t=e;if(typeof t.seq=="number")return t.seq;const n=/#(\d+)/.exec(t.output??"");return n?Number(n[1]):null}const tfe={task:Yde,waveBox:Jde},MA="sps.flow.lastProject",RA="sps.flow.mode";function DA(e){return(e.labels??[]).includes("NEEDS-FIX")?"stuck":e.state==="Done"?"done":e.state==="Inprogress"?"doing":"todo"}function nfe(e){return e==="done"?{animated:!1,style:{stroke:"var(--color-running)",strokeWidth:2.5}}:e==="doing"?{animated:!1,className:"arrange-flow-edge-working",style:{stroke:"var(--color-running)",strokeWidth:3,strokeDasharray:"8 6"}}:e==="stuck"?{animated:!1,style:{stroke:"var(--color-crashed)",strokeWidth:2.5,strokeDasharray:"6 4"}}:{animated:!1,style:{stroke:"var(--color-accent-yellow)",strokeWidth:2.5,strokeDasharray:"6 4"}}}const ll=260,cl=158,Dm=28,kp=ll+120,Yx=cl+28,OA=16,LA=44,Sp=60,Xx=100,IA=["var(--color-accent-mint)","var(--color-accent-pink)","var(--color-accent-yellow)","var(--color-accent-purple)","var(--color-running-bg)","var(--color-idle-bg)"];function hd(e){const t=new Map;for(const n of e){const i=t.get(n.order)??[];i.push(n),t.set(n.order,i)}return[...t.entries()].sort((n,i)=>n[0]-i[0]).map(([,n])=>n.sort((i,s)=>i.seq-s.seq))}function ife(e,t){return Math.abs(e.x-t.x)<ll+Dm&&Math.abs(e.y-t.y)<cl+Dm}function sfe(e){for(let t=0;t<80;t+=1)for(let n=0;n<8;n+=1){const i={x:60+n*(ll+Dm),y:60+t*(cl+Dm)};if(!e.some(s=>ife(i,s)))return i}return{x:60,y:60}}function PA(e){return{x:e.position.x+ll/2,y:e.position.y+cl/2}}function rfe(e,t,n){const i=n.x-t.x,s=n.y-t.y,r=i*i+s*s;if(r===0)return Math.hypot(e.x-t.x,e.y-t.y);let o=((e.x-t.x)*i+(e.y-t.y)*s)/r;return o=Math.max(0,Math.min(1,o)),Math.hypot(e.x-(t.x+o*i),e.y-(t.y+o*s))}function afe(){var ye,Je,It,Wt;const e=Xe(),t=tn(),n=bl(),{confirm:i}=Bn(),{screenToFlowPosition:s,fitView:r}=vg(),o=_.useRef([]),[c,u]=_.useState(()=>localStorage.getItem(MA)??""),[f,p]=_.useState(()=>localStorage.getItem(RA)==="lanes"?"lanes":"free"),[m,y]=_.useState(!1),[b,x,v]=yde([]),[w,k,C]=bde([]),[S,T]=_.useState(null),[A,j]=_.useState(null),[M,D]=_.useState(!1),[P,I]=_.useState(""),[B,q]=_.useState(null),[G,R]=_.useState(null),[O,z]=_.useState(0),W=_.useRef({}),X=_.useRef(w);X.current=w;const K=_.useRef(b);K.current=b;const U=_.useRef(null),F=_.useRef(null),Y=_.useRef(new Set),$=_.useRef(""),ie=_.useRef(null);KL(c||null);const be=ot({queryKey:["cards",c],queryFn:()=>$L(c),enabled:!!c,refetchInterval:3e3}),ce=((ye=be.data)==null?void 0:ye.data)??[],oe=((Wt=(It=(Je=ot({queryKey:["projects"],queryFn:fo,refetchInterval:3e3}).data)==null?void 0:Je.data)==null?void 0:It.find(he=>he.name===c))==null?void 0:Wt.pipelineStatus)==="running",pe=_.useMemo(()=>{const he={};for(const le of ce)he[String(le.seq)]=DA(le);return he},[ce]),re=_.useMemo(()=>{if(f!=="lanes")return[];const he=hd(ce),le=[];for(let Te=1;Te<he.length;Te+=1)for(const Ae of he[Te-1]??[])for(const Qe of he[Te]??[])le.push({id:`w${Ae.seq}-${Qe.seq}`,source:String(Ae.seq),target:String(Qe.seq),sourceHandle:"r",targetHandle:"l",animated:!1,selectable:!1,deletable:!1});return le},[f,ce]),ee=_.useMemo(()=>(f==="lanes"?re:w).map(he=>{const le=nfe(pe[he.target]);return he.selected?{...he,...le,style:{...le.style,strokeWidth:6}}:{...he,...le}}),[f,re,w,pe]),ge=_.useCallback(()=>{t.invalidateQueries({queryKey:["cards",c]})},[t,c]),Ce=_.useCallback(()=>{!c||U.current!==c||(ie.current&&clearTimeout(ie.current),ie.current=setTimeout(()=>{Gde(c,{positions:W.current,edges:X.current.map(he=>({id:he.id,source:he.source,target:he.target,sourceHandle:he.sourceHandle??null,targetHandle:he.targetHandle??null}))}).catch(()=>{})},600))},[c]);_.useEffect(()=>{if(U.current=null,T(null),R(null),W.current={},Y.current=new Set,$.current="",x([]),k([]),!c)return;localStorage.setItem(MA,c);let he=!1;return Kde(c).then(le=>{he||(W.current=le.positions??{},k((le.edges??[]).map(Te=>({id:Te.id,source:Te.source,target:Te.target,sourceHandle:Te.sourceHandle??void 0,targetHandle:Te.targetHandle??void 0,animated:!1}))))}).catch(()=>{}).finally(()=>{he||(U.current=c,z(le=>le+1))}),()=>{he=!0}},[c,x,k]),_.useEffect(()=>{if(!c||U.current!==c)return;const he=`${f}|`+ce.map($e=>`${$e.seq}:${$e.title}:${$e.state}:${$e.order}:${($e.skills??[]).join("|")}`).join(",");if(he===$.current)return;$.current=he;const le=$e=>({seq:String($e.seq),title:$e.title,skills:($e.skills??[]).join(", "),status:DA($e),label:$e.title,desc:""});if(f==="lanes"){const $e=hd(ce),nt=$e.map((Xt,Dt)=>({id:`wave-${Dt}`,type:"waveBox",position:{x:Sp+Dt*kp-OA,y:Xx-LA},data:{label:e("flow.lane.wave",{n:Dt+1}),sub:Xt.length>1?e("flow.lane.parallel",{n:Xt.length}):"",color:IA[Dt%IA.length]},style:{width:ll+OA*2,height:LA+(Xt.length-1)*Yx+cl+14},draggable:!1,selectable:!1,zIndex:0})),qt=$e.flatMap((Xt,Dt)=>Xt.map((Q,we)=>({id:String(Q.seq),type:"task",position:{x:Sp+Dt*kp,y:Xx+we*Yx},deletable:!1,zIndex:1,data:le(Q)})));x([...nt,...qt]);return}const Te=new Map(K.current.map($e=>[$e.id,$e.position])),Ae=[];for(const $e of ce){const nt=Te.get(String($e.seq))??W.current[String($e.seq)];nt&&Ae.push(nt)}let Qe=!1;const st=ce.map($e=>{const nt=String($e.seq);let qt=Te.get(nt)??W.current[nt];return qt||(qt=sfe(Ae),Ae.push(qt),Qe=!0),W.current[nt]=qt,{id:nt,type:"task",position:qt,deletable:!1,data:le($e)}});x(st),Qe&&Ce()},[ce,c,f,O,x,Ce,e]),_.useEffect(()=>{if(U.current!==c)return;const he=new Set(ce.map(le=>String(le.seq)));k(le=>{const Te=le.filter(Ae=>he.has(Ae.source)&&he.has(Ae.target));return Te.length!==le.length&&Ce(),Te.length===le.length?le:Te})},[ce,c,k,Ce]),_.useEffect(()=>{if(!c||U.current!==c||f!=="free"||ce.length<2)return;const he=hd(ce),le=[];for(let Qe=1;Qe<he.length;Qe+=1)for(const st of he[Qe-1]??[])for(const $e of he[Qe]??[])le.push({id:`seed-${st.seq}-${$e.seq}`,source:String(st.seq),target:String($e.seq),sourceHandle:"r",targetHandle:"l",animated:!1});const Te=X.current,Ae=F.current!==c;if(F.current=c,Ae&&Te.length===0)le.length>0&&(k(le),Ce());else{const Qe=new Set;for(const nt of Te)Qe.add(nt.source),Qe.add(nt.target);const st=new Set(Te.map(nt=>`${nt.source}->${nt.target}`)),$e=new Set(ce.map(nt=>String(nt.seq)).filter(nt=>!Y.current.has(nt)&&!Qe.has(nt)));if($e.size>0){const nt=le.filter(qt=>($e.has(qt.source)||$e.has(qt.target))&&!st.has(`${qt.source}->${qt.target}`));nt.length>0&&(k([...Te,...nt]),Ce())}}Y.current=new Set(ce.map(Qe=>String(Qe.seq)))},[ce,c,f,O,k,Ce]);const Ie=_.useCallback(he=>{if(v(he),f!=="free")return;let le=!1;for(const Te of he)Te.type==="position"&&Te.position&&(W.current[Te.id]=Te.position,le=!0);le&&Ce()},[v,Ce,f]),ae=_.useCallback(he=>{f==="free"&&(k(le=>vP({...he,animated:!1},le)),Ce())},[k,Ce,f]),ke=_.useCallback(()=>{if(f!=="free"||ce.length===0)return;const he=hd(ce),le={},Te=[];he.forEach((Ae,Qe)=>{if(Ae.forEach((st,$e)=>{le[String(st.seq)]={x:Sp+Qe*kp,y:Xx+$e*Yx}}),Qe>0)for(const st of he[Qe-1]??[])for(const $e of Ae)Te.push({id:`seed-${st.seq}-${$e.seq}`,source:String(st.seq),target:String($e.seq),sourceHandle:"r",targetHandle:"l",animated:!1})}),W.current={...W.current,...le},x(Ae=>Ae.map(Qe=>le[Qe.id]?{...Qe,position:le[Qe.id]}:Qe)),k(Te),Ce(),setTimeout(()=>r({padding:.2,duration:300}),60)},[f,ce,x,k,Ce,r]),Ue=_.useCallback(async he=>{if(!await i({title:e("flow.confirm.deleteTitle"),body:e("flow.confirm.deleteBody",{seq:he}),danger:!0,confirm:e("flow.node.delete")}))return;I("");const Te=X.current.filter(Ae=>Ae.source===String(he)||Ae.target===String(he)).map(Ae=>({...Ae}));try{await HL(c,he),o.current.push({seq:he,edges:Te})}catch(Ae){I(Ae instanceof Error?Ae.message:String(Ae))}finally{T(Ae=>Ae===he?null:Ae),j(Ae=>Ae===he?null:Ae),$.current="",z(Ae=>Ae+1),ge()}},[c,i,e,ge]),Oe=_.useCallback(async()=>{const he=o.current.pop();if(he){I("");try{await Jne(c,he.seq),k(le=>{const Te=new Set(le.map(Ae=>Ae.id));return[...le,...he.edges.filter(Ae=>!Te.has(Ae.id))]}),Ce(),ge()}catch(le){I(le instanceof Error?le.message:String(le))}}},[c,k,Ce,ge]),ht=_.useCallback((he,le)=>{var st;if(f!=="free"||le.isValid)return;const Te=le.fromNode;if(!Te||!c)return;const Ae="changedTouches"in he?he.changedTouches[0]:he;if(!Ae)return;const Qe=s({x:Ae.clientX,y:Ae.clientY});q({fromId:Te.id,fromHandle:((st=le.fromHandle)==null?void 0:st.id)??null,clientX:Ae.clientX,clientY:Ae.clientY,flowX:Qe.x,flowY:Qe.y})},[f,c,s]),tt=_.useCallback(async()=>{const he=B;if(q(null),!(!he||!c))try{const le=await gv(c,{title:`${e("flow.node.default")} ${ce.length+1}`,initialState:"Planning"}),Te=efe(le);if(Te==null)return;const Ae=String(Te);W.current[Ae]={x:he.flowX-ll/2,y:he.flowY-cl/2},k(Qe=>[...Qe,{id:`e-${he.fromId}-${Ae}-drop`,source:he.fromId,target:Ae,sourceHandle:he.fromHandle??void 0,animated:!1}]),Ce(),ge()}catch(le){I(le instanceof Error?le.message:String(le))}},[B,c,ce.length,k,Ce,e,ge]);_.useEffect(()=>{if(!B)return;const he=le=>{le.key==="Escape"&&q(null)};return window.addEventListener("keydown",he),()=>window.removeEventListener("keydown",he)},[B]);const jt=_.useCallback((he,le)=>{f==="free"&&(k(Te=>Kce(he,le,Te)),Ce())},[f,k,Ce]);_.useEffect(()=>{const he=le=>{if(le.key!=="Delete"&&le.key!=="Backspace"||A!=null)return;const Te=le.target;Te&&(Te.tagName==="INPUT"||Te.tagName==="TEXTAREA"||Te.isContentEditable)||S!=null&&(le.preventDefault(),Ue(S))};return window.addEventListener("keydown",he),()=>window.removeEventListener("keydown",he)},[S,A,Ue]),_.useEffect(()=>{const he=le=>{if(!(le.metaKey||le.ctrlKey)||le.key!=="z"&&le.key!=="Z"||A!=null)return;const Te=le.target;Te&&(Te.tagName==="INPUT"||Te.tagName==="TEXTAREA"||Te.isContentEditable)||(le.preventDefault(),Oe())};return window.addEventListener("keydown",he),()=>window.removeEventListener("keydown",he)},[A,Oe]);const Nt=_.useCallback(async he=>{if(c){y(!0),I("");try{const le=new Map(ce.map(Te=>[Te.seq,Te.order]));for(let Te=0;Te<he.length;Te+=1)for(const Ae of he[Te]??[])le.get(Ae)!==Te+1&&await wm(c,Ae,{order:Te+1});ge()}catch(le){I(le instanceof Error?le.message:String(le))}finally{y(!1)}}},[c,ce,ge]),pt=_.useCallback(he=>{const le=Number(he.id);if(!Number.isInteger(le))return;const Te=hd(ce).map($e=>$e.map(nt=>nt.seq)),Ae=(he.position.x-Sp)/kp,Qe=Math.round(Ae),st=Te.map($e=>$e.filter(nt=>nt!==le));if(Qe>=0&&Qe<Te.length&&Math.abs(Ae-Qe)<=.35)st[Qe].push(le);else{const $e=Math.max(0,Math.min(st.length,Math.ceil(Ae)));st.splice($e,0,[le])}Nt(st.filter($e=>$e.length>0)).finally(()=>{$.current="",z($e=>$e+1)})},[ce,Nt]),Me=_.useCallback((he,le)=>{if(f==="lanes"){pt(le);return}const Te=new Map(K.current.map(nt=>[nt.id,nt])),Ae={x:le.position.x+ll/2,y:le.position.y+cl/2};let Qe=null,st=40;for(const nt of X.current){if(nt.source===le.id||nt.target===le.id)continue;const qt=Te.get(nt.source),Xt=Te.get(nt.target);if(!qt||!Xt)continue;const Dt=rfe(Ae,PA(qt),PA(Xt));Dt<st&&(st=Dt,Qe=nt)}if(!Qe)return;const $e=Qe;k(nt=>[...nt.filter(qt=>qt.id!==$e.id),{id:`e-${$e.source}-${le.id}-${$e.id}`,source:$e.source,target:le.id,animated:!1},{id:`e-${le.id}-${$e.target}-${$e.id}`,source:le.id,target:$e.target,animated:!1}]),Ce()},[f,pt,k,Ce]),We=_.useCallback(he=>{p(he),localStorage.setItem(RA,he)},[]);_.useEffect(()=>{const he=setTimeout(()=>{r({padding:.2,duration:300})},80);return()=>clearTimeout(he)},[f,r]);const ne=async()=>{if(c){I("");try{await gv(c,{title:`${e("flow.node.default")} ${ce.length+1}`,initialState:"Planning"}),ge()}catch(he){I(he instanceof Error?he.message:String(he))}}},ve=async()=>{if(I(""),R(null),!c)return I(e("flow.err.noProject"));if(ce.length===0)return I(e("flow.err.noNodes"));D(!0);try{const he=ce.filter(Ae=>Ae.state==="Planning"),le=he.length;let Te=0;R({phase:"creating",made:Te,total:le});for(const Ae of he)await wm(c,Ae.seq,{state:"Backlog",labels:Array.from(new Set([...Ae.labels??[],"AI-PIPELINE"]))}),Te+=1,R({phase:"creating",made:Te,total:le});R({phase:"starting",made:Te,total:le}),await VL(c),ge(),R({phase:"done",made:Te,total:le})}catch(he){I(he instanceof Error?he.message:String(he))}finally{D(!1)}},Re=be.isLoading&&!!c;return d.jsxs("div",{className:"flex flex-col h-full",children:[d.jsxs("header",{className:"flex items-center gap-3 flex-wrap px-4 py-3 border-b border-[var(--surface-card-border)]",children:[d.jsxs("h1",{className:"text-lg font-[family-name:var(--font-heading)] flex items-center gap-2",children:[d.jsx(GN,{size:18,strokeWidth:2.4}),e("nav.arrange")]}),d.jsx(YL,{current:c,onChange:u}),d.jsxs("div",{className:"flex gap-1",role:"group","aria-label":e("flow.mode.aria"),children:[d.jsxs("button",{type:"button",className:["nb-btn",f==="free"?"nb-btn-primary":""].join(" "),"aria-pressed":f==="free",onClick:()=>We("free"),children:[d.jsx(GN,{size:14,strokeWidth:2.4})," ",e("flow.mode.free")]}),d.jsxs("button",{type:"button",className:["nb-btn",f==="lanes"?"nb-btn-primary":""].join(" "),"aria-pressed":f==="lanes",onClick:()=>We("lanes"),children:[d.jsx(aU,{size:14,strokeWidth:2.4})," ",e("flow.mode.lanes")]})]}),Re&&d.jsx(mt,{size:15,className:"animate-spin text-[var(--color-text-muted)]"}),d.jsxs("button",{type:"button",className:"nb-btn",onClick:()=>void ne(),disabled:!c||Re,children:[d.jsx(Gn,{size:15,strokeWidth:2.4})," ",e("flow.addNode")]}),d.jsxs("button",{type:"button",className:"nb-btn nb-btn-cta ml-auto",onClick:()=>void ve(),disabled:M||oe||Re||!c,title:oe?e("flow.pipelineRunning"):void 0,children:[M||oe?d.jsx(mt,{size:15,className:"animate-spin"}):d.jsx(Im,{size:15,strokeWidth:2.4}),e(M?"flow.running":oe?"flow.pipelineRunning":"flow.run")]})]}),!c&&d.jsx("div",{className:"px-4 py-2 text-sm text-[var(--color-text-muted)] border-b border-[var(--surface-card-border)]",children:e("flow.pickProject")}),P&&d.jsx("div",{className:"px-4 py-2 text-sm text-[var(--color-crashed)] bg-[var(--color-crashed-bg)] border-b border-[var(--surface-card-border)]",children:P}),G&&d.jsxs("div",{className:"px-4 py-2 text-sm flex items-center gap-3 bg-[var(--surface-input)] border-b border-[var(--surface-card-border)]",children:[G.phase==="creating"&&d.jsxs("span",{children:[e("flow.status.creating")," ",G.made,"/",G.total,"…"]}),G.phase==="starting"&&d.jsx("span",{children:e("flow.status.starting")}),G.phase==="done"&&d.jsxs(d.Fragment,{children:[d.jsxs("span",{className:"text-[var(--color-running)] font-bold",children:["✓ ",e("flow.status.done").replace("{n}",String(G.made))]}),d.jsx("button",{type:"button",className:"nb-btn nb-btn-blue",onClick:()=>n(`/board?project=${encodeURIComponent(c)}`),children:e("flow.goBoard")})]})]}),d.jsx("div",{className:"flex-1 min-h-0 arrange-flow-shell",children:d.jsxs(gde,{nodes:b,edges:ee,nodeTypes:tfe,connectionRadius:160,nodesConnectable:f==="free",edgesReconnectable:f==="free",deleteKeyCode:A!=null?null:["Delete","Backspace"],onNodesChange:Ie,onEdgesChange:he=>{f==="free"&&(C(he),Ce())},onConnect:ae,onConnectEnd:ht,onReconnect:jt,onNodeClick:(he,le)=>{const Te=Number(le.id);Number.isInteger(Te)&&j(Te)},onNodeDragStop:Me,onSelectionChange:({nodes:he})=>{const le=he[0]?Number(he[0].id):null;T(le!=null&&Number.isInteger(le)?le:null)},fitView:!0,children:[d.jsx(kde,{variant:la.Dots,gap:18,size:1}),d.jsx(jde,{children:f==="free"&&d.jsx(wd,{onClick:ke,title:e("flow.tidy"),"aria-label":e("flow.tidy"),children:d.jsx(Uj,{size:14,strokeWidth:2.4})})})]})}),B&&d.jsx("div",{className:"fixed inset-0 z-30",onClick:()=>q(null),children:d.jsxs("button",{type:"button",className:"nb-btn nb-btn-cta absolute -translate-x-1/2 -translate-y-1/2",style:{left:B.clientX,top:B.clientY},onClick:he=>{he.stopPropagation(),tt()},children:[d.jsx(Gn,{size:14,strokeWidth:2.4})," ",e("flow.pending.create")]})}),m&&d.jsxs("div",{className:"px-4 py-1 text-xs text-[var(--color-text-muted)] border-t border-[var(--surface-card-border)] flex items-center gap-2",children:[d.jsx(mt,{size:12,className:"animate-spin"})," ",e("flow.lane.applying")]}),d.jsx("footer",{className:"px-4 py-2 text-xs text-[var(--color-text-muted)] border-t border-[var(--surface-card-border)]",children:e(f==="free"?"flow.hint":"flow.lane.hint")}),A!=null&&c&&d.jsx(Zde,{project:c,seq:A,onClose:()=>j(null),onChanged:ge,onDelete:he=>void Ue(he)})]})}function ofe(){return d.jsx(KP,{children:d.jsx(afe,{})})}function lfe(){const e=Xe();return d.jsxs("div",{className:"nb-card max-w-2xl mt-12",children:[d.jsx("h1",{className:"font-[family-name:var(--font-heading)] text-4xl font-bold mb-2",children:e("notFound.title")}),d.jsx("p",{className:"text-[var(--color-text-muted)] mb-6",children:e("notFound.body")}),d.jsx(Bc,{to:"/",className:"nb-btn nb-btn-mint inline-flex",children:e("notFound.home")})]})}const cfe=_.lazy(()=>AB(()=>import("./ShowcasePage-qOjeWeUs.js"),__vite__mapDeps([0,1])));function ufe(){return d.jsx(SF,{children:d.jsxs(G5,{children:[d.jsx(oi,{path:"/showcase",element:d.jsx(_.Suspense,{fallback:null,children:d.jsx(cfe,{})})}),d.jsxs(oi,{element:d.jsx(QN,{contentMode:"workspace"}),children:[d.jsx(oi,{index:!0,element:d.jsx(wx,{})}),d.jsx(oi,{path:"/projects",element:d.jsx(mT,{})}),d.jsx(oi,{path:"/projects/:name",element:d.jsx(mT,{})}),d.jsx(oi,{path:"/board",element:d.jsx(vie,{})}),d.jsx(oi,{path:"/prompts",element:d.jsx(Oie,{})}),d.jsx(oi,{path:"/chat",element:d.jsx(wx,{})}),d.jsx(oi,{path:"/chat/:sessionId",element:d.jsx(wx,{})}),d.jsx(oi,{path:"/arrange",element:d.jsx(ofe,{})})]}),d.jsxs(oi,{element:d.jsx(QN,{contentMode:"document"}),children:[d.jsx(oi,{path:"/projects/new",element:d.jsx(FL,{})}),d.jsx(oi,{path:"/skills",element:d.jsx(Cie,{})}),d.jsx(oi,{path:"/system",element:d.jsx(Zie,{})}),d.jsx(oi,{path:"/memory",element:d.jsx(use,{})}),d.jsx(oi,{path:"/plugins",element:d.jsx(Sse,{})}),d.jsx(oi,{path:"*",element:d.jsx(lfe,{})})]})]})})}kF();X6();const dfe=new L4({defaultOptions:{queries:{staleTime:3e4,refetchOnWindowFocus:!1}}}),XP=document.getElementById("root");if(!XP)throw new Error("#root not found");u4.createRoot(XP).render(d.jsx(_.StrictMode,{children:d.jsx(U6,{children:d.jsx(I4,{client:dfe,children:d.jsx(bB,{children:d.jsx(uY,{children:d.jsx(ufe,{})})})})})}));export{Mj as A,iU as C,Ij as E,Bc as L,Qv as P,m0 as S,zB as a,Be as c,d as j,_ as r,Yj as u};
|
|
845
|
+
`).trim()}function Qde(e,t){return t.includes("NEEDS-FIX")?"stuck":e==="Done"?"done":e==="Inprogress"?"doing":"todo"}function Zde({project:e,seq:t,onClose:n,onChanged:i,onDelete:s}){var G;const r=Xe(),[o,c]=_.useState(!0),[u,f]=_.useState(!1),[p,m]=_.useState(""),[y,b]=_.useState(""),[x,v]=_.useState(new Set),[w,k]=_.useState(""),[C,S]=_.useState("todo"),[T,A]=_.useState(null),[j,M]=_.useState(""),D=ot({queryKey:["skills-all",e],queryFn:()=>og(e)}),P=((G=D.data)==null?void 0:G.data)??[];_.useEffect(()=>{const R=O=>{O.key==="Escape"&&n()};return window.addEventListener("keydown",R),()=>window.removeEventListener("keydown",R)},[n]),_.useEffect(()=>{let R=!1;return c(!0),qL(e,t).then(O=>{R||(m(O.title),v(new Set(O.skills??[])),b(Xde(O.body)),k(O.state),S(Qde(O.state,O.labels??[])),A(typeof O.order=="number"?O.order:null))}).catch(()=>{}).finally(()=>{R||c(!1)}),()=>{R=!0}},[e,t]);const I=R=>{v(O=>{const z=new Set(O);return z.has(R)?z.delete(R):z.add(R),z})},B=async()=>{M(""),f(!0);try{await wm(e,t,{title:p.trim()||r("flow.node.default"),description:y,skills:[...x]}),i(),n()}catch(R){M(R instanceof Error?R.message:String(R)),f(!1)}},q=()=>s(t);return d.jsx("div",{role:"dialog","aria-modal":"true",className:"fixed inset-0 z-40 flex items-center justify-center p-4 md:p-6 bg-black/30 overflow-hidden",onClick:n,children:d.jsxs("div",{className:"nb-card w-full max-w-4xl flex flex-col bg-[var(--color-bg)]",style:{maxHeight:"calc(100vh - 48px)"},onClick:R=>R.stopPropagation(),children:[d.jsxs("header",{className:"flex items-start justify-between gap-4 mb-4 flex-shrink-0",children:[d.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[d.jsxs("span",{className:"font-[family-name:var(--font-mono)] font-bold text-xs px-2 py-0.5 bg-[var(--color-accent-purple)] border-2 border-[var(--color-text)] rounded-full",children:["#",t]}),w&&d.jsxs("span",{className:"inline-flex items-center gap-1.5 text-xs px-2 py-0.5 border-2 border-[var(--color-text)] rounded-full font-semibold",children:[d.jsx("span",{className:"w-2.5 h-2.5 rounded-full inline-block border border-[var(--color-text)]",style:{background:Ov[C]??"gray"}}),w]}),T!=null&&d.jsx("span",{className:"font-[family-name:var(--font-mono)] text-xs px-2 py-0.5 bg-[var(--color-accent-mint)] border-2 border-[var(--color-text)] rounded-full font-semibold",title:r("flow.lane.orderTip"),children:r("flow.lane.wave",{n:T})})]}),d.jsx("button",{onClick:n,className:"nb-btn nb-btn-mint p-2 flex-shrink-0","aria-label":r("flow.node.close"),type:"button",children:d.jsx(En,{size:14,strokeWidth:3})})]}),o?d.jsxs("div",{className:"flex items-center gap-2 text-sm text-[var(--color-text-muted)] py-10 justify-center",children:[d.jsx(mt,{size:16,className:"animate-spin"})," …"]}):d.jsxs(d.Fragment,{children:[j&&d.jsx("div",{className:"text-sm text-[var(--color-crashed)] mb-3",children:j}),d.jsxs("div",{className:"grid min-h-0 flex-1 grid-cols-1 gap-4 overflow-y-auto pr-1 md:grid-cols-[minmax(0,1fr)_minmax(260px,340px)] md:overflow-hidden md:pr-0",children:[d.jsxs("div",{className:"flex min-h-0 flex-col gap-4 md:overflow-y-auto md:pr-1",children:[d.jsxs("label",{className:"flex flex-col gap-1.5",children:[d.jsx("span",{className:"text-sm font-bold",children:r("flow.node.title")}),d.jsx("input",{className:"nb-input w-full text-base font-semibold",value:p,onChange:R=>m(R.target.value),autoFocus:!0})]}),d.jsxs("label",{className:"flex flex-1 min-h-0 flex-col gap-1.5",children:[d.jsx("span",{className:"text-sm font-bold",children:r("flow.node.desc")}),d.jsx("textarea",{className:"nb-input w-full flex-1 min-h-0",style:{minHeight:200,resize:"vertical"},value:y,onChange:R=>b(R.target.value)})]})]}),d.jsxs("section",{className:"flex min-h-[200px] flex-col gap-2 md:min-h-0 md:overflow-hidden",children:[d.jsx("span",{className:"text-sm font-bold",children:r("flow.node.skills")}),d.jsx("div",{className:"scroll-frame min-h-0 flex-1 rounded-lg border-2 border-[var(--color-border-light)] bg-[var(--color-bg-cream)]",children:d.jsxs("div",{className:"scroll-frame-body h-full p-2",children:[D.isLoading&&d.jsx(mt,{size:14,className:"animate-spin text-[var(--color-text-muted)]"}),P.length>0&&d.jsx("div",{className:"flex flex-wrap gap-2",children:P.map(R=>{const O=x.has(R.name);return d.jsx("button",{type:"button",onClick:()=>I(R.name),className:["max-w-full break-all px-2.5 py-1 text-left text-xs font-[family-name:var(--font-mono)] rounded-full border-2 transition-all",O?"bg-[var(--color-accent-mint)] border-[var(--color-text)] shadow-[2px_2px_0_var(--color-text)] font-bold":"bg-[var(--color-bg)] border-[var(--color-border-light)] hover:border-[var(--color-text)]"].join(" "),"aria-pressed":O,children:R.name},R.name)})})]})}),x.size>0&&d.jsx("p",{className:"max-h-14 overflow-y-auto break-words text-xs text-[var(--color-text-muted)]",children:[...x].join(", ")})]})]}),d.jsxs("div",{className:"flex gap-2 justify-between mt-4 pt-3 border-t-2 border-dashed border-[var(--color-text)] flex-shrink-0",children:[d.jsxs("button",{type:"button",className:"nb-btn nb-btn-danger",onClick:()=>void q(),disabled:u,children:[d.jsx(Rs,{size:14,strokeWidth:2.4})," ",r("flow.node.delete")]}),d.jsxs("button",{type:"button",className:"nb-btn nb-btn-cta",onClick:()=>void B(),disabled:u,children:[u?d.jsx(mt,{size:14,className:"animate-spin"}):null,r("flow.node.save")]})]})]})]})})}const Jde=_.memo(function({data:t}){const n=t;return d.jsxs("div",{className:"relative w-full h-full rounded-2xl border-2 border-dashed border-[var(--color-text)]",children:[d.jsx("div",{className:"absolute inset-0 rounded-2xl",style:{background:n.color,opacity:.16}}),d.jsxs("span",{className:"absolute top-1.5 left-2.5 inline-flex items-center gap-1.5 px-2 py-0.5 text-[11px] font-bold rounded-md border-2 border-[var(--color-text)] bg-[var(--color-bg)] text-[var(--color-text)] whitespace-nowrap max-w-[90%]",children:[d.jsx("span",{className:"truncate",children:n.label}),n.sub&&d.jsx("span",{className:"font-normal text-[var(--color-text-muted)]",children:n.sub})]})]})});function efe(e){const t=e;if(typeof t.seq=="number")return t.seq;const n=/#(\d+)/.exec(t.output??"");return n?Number(n[1]):null}const tfe={task:Yde,waveBox:Jde},MA="sps.flow.lastProject",RA="sps.flow.mode";function DA(e){return(e.labels??[]).includes("NEEDS-FIX")?"stuck":e.state==="Done"?"done":e.state==="Inprogress"?"doing":"todo"}function nfe(e){return e==="done"?{animated:!1,style:{stroke:"var(--color-running)",strokeWidth:2.5}}:e==="doing"?{animated:!1,className:"arrange-flow-edge-working",style:{stroke:"var(--color-running)",strokeWidth:3,strokeDasharray:"8 6"}}:e==="stuck"?{animated:!1,style:{stroke:"var(--color-crashed)",strokeWidth:2.5,strokeDasharray:"6 4"}}:{animated:!1,style:{stroke:"var(--color-accent-yellow)",strokeWidth:2.5,strokeDasharray:"6 4"}}}const ll=260,cl=158,Dm=28,kp=ll+120,Yx=cl+28,OA=16,LA=44,Sp=60,Xx=100,IA=["var(--color-accent-mint)","var(--color-accent-pink)","var(--color-accent-yellow)","var(--color-accent-purple)","var(--color-running-bg)","var(--color-idle-bg)"];function hd(e){const t=new Map;for(const n of e){const i=t.get(n.order)??[];i.push(n),t.set(n.order,i)}return[...t.entries()].sort((n,i)=>n[0]-i[0]).map(([,n])=>n.sort((i,s)=>i.seq-s.seq))}function ife(e,t){return Math.abs(e.x-t.x)<ll+Dm&&Math.abs(e.y-t.y)<cl+Dm}function sfe(e){for(let t=0;t<80;t+=1)for(let n=0;n<8;n+=1){const i={x:60+n*(ll+Dm),y:60+t*(cl+Dm)};if(!e.some(s=>ife(i,s)))return i}return{x:60,y:60}}function PA(e){return{x:e.position.x+ll/2,y:e.position.y+cl/2}}function rfe(e,t,n){const i=n.x-t.x,s=n.y-t.y,r=i*i+s*s;if(r===0)return Math.hypot(e.x-t.x,e.y-t.y);let o=((e.x-t.x)*i+(e.y-t.y)*s)/r;return o=Math.max(0,Math.min(1,o)),Math.hypot(e.x-(t.x+o*i),e.y-(t.y+o*s))}function afe(){var ye,Je,It,Wt;const e=Xe(),t=tn(),n=bl(),{confirm:i}=Bn(),{screenToFlowPosition:s,fitView:r}=vg(),o=_.useRef([]),[c,u]=_.useState(()=>localStorage.getItem(MA)??""),[f,p]=_.useState(()=>localStorage.getItem(RA)==="lanes"?"lanes":"free"),[m,y]=_.useState(!1),[b,x,v]=yde([]),[w,k,C]=bde([]),[S,T]=_.useState(null),[A,j]=_.useState(null),[M,D]=_.useState(!1),[P,I]=_.useState(""),[B,q]=_.useState(null),[G,R]=_.useState(null),[O,z]=_.useState(0),W=_.useRef({}),X=_.useRef(w);X.current=w;const K=_.useRef(b);K.current=b;const U=_.useRef(null),F=_.useRef(null),Y=_.useRef(new Set),$=_.useRef(""),ie=_.useRef(null);KL(c||null);const be=ot({queryKey:["cards",c],queryFn:()=>$L(c),enabled:!!c,refetchInterval:3e3}),ce=((ye=be.data)==null?void 0:ye.data)??[],oe=((Wt=(It=(Je=ot({queryKey:["projects"],queryFn:fo,refetchInterval:3e3}).data)==null?void 0:Je.data)==null?void 0:It.find(he=>he.name===c))==null?void 0:Wt.pipelineStatus)==="running",pe=_.useMemo(()=>{const he={};for(const le of ce)he[String(le.seq)]=DA(le);return he},[ce]),re=_.useMemo(()=>{if(f!=="lanes")return[];const he=hd(ce),le=[];for(let Te=1;Te<he.length;Te+=1)for(const Ae of he[Te-1]??[])for(const Qe of he[Te]??[])le.push({id:`w${Ae.seq}-${Qe.seq}`,source:String(Ae.seq),target:String(Qe.seq),sourceHandle:"r",targetHandle:"l",animated:!1,selectable:!1,deletable:!1});return le},[f,ce]),ee=_.useMemo(()=>(f==="lanes"?re:w).map(he=>{const le=nfe(pe[he.target]);return he.selected?{...he,...le,style:{...le.style,strokeWidth:6}}:{...he,...le}}),[f,re,w,pe]),ge=_.useCallback(()=>{t.invalidateQueries({queryKey:["cards",c]})},[t,c]),Ce=_.useCallback(()=>{!c||U.current!==c||(ie.current&&clearTimeout(ie.current),ie.current=setTimeout(()=>{Gde(c,{positions:W.current,edges:X.current.map(he=>({id:he.id,source:he.source,target:he.target,sourceHandle:he.sourceHandle??null,targetHandle:he.targetHandle??null}))}).catch(()=>{})},600))},[c]);_.useEffect(()=>{if(U.current=null,T(null),R(null),W.current={},Y.current=new Set,$.current="",x([]),k([]),!c)return;localStorage.setItem(MA,c);let he=!1;return Kde(c).then(le=>{he||(W.current=le.positions??{},k((le.edges??[]).map(Te=>({id:Te.id,source:Te.source,target:Te.target,sourceHandle:Te.sourceHandle??void 0,targetHandle:Te.targetHandle??void 0,animated:!1}))))}).catch(()=>{}).finally(()=>{he||(U.current=c,z(le=>le+1))}),()=>{he=!0}},[c,x,k]),_.useEffect(()=>{if(!c||U.current!==c)return;const he=`${f}|`+ce.map($e=>`${$e.seq}:${$e.title}:${$e.state}:${$e.order}:${($e.skills??[]).join("|")}`).join(",");if(he===$.current)return;$.current=he;const le=$e=>({seq:String($e.seq),title:$e.title,skills:($e.skills??[]).join(", "),status:DA($e),label:$e.title,desc:""});if(f==="lanes"){const $e=hd(ce),nt=$e.map((Xt,Dt)=>({id:`wave-${Dt}`,type:"waveBox",position:{x:Sp+Dt*kp-OA,y:Xx-LA},data:{label:e("flow.lane.wave",{n:Dt+1}),sub:Xt.length>1?e("flow.lane.parallel",{n:Xt.length}):"",color:IA[Dt%IA.length]},style:{width:ll+OA*2,height:LA+(Xt.length-1)*Yx+cl+14},draggable:!1,selectable:!1,zIndex:0})),qt=$e.flatMap((Xt,Dt)=>Xt.map((Q,we)=>({id:String(Q.seq),type:"task",position:{x:Sp+Dt*kp,y:Xx+we*Yx},deletable:!1,zIndex:1,data:le(Q)})));x([...nt,...qt]);return}const Te=new Map(K.current.map($e=>[$e.id,$e.position])),Ae=[];for(const $e of ce){const nt=Te.get(String($e.seq))??W.current[String($e.seq)];nt&&Ae.push(nt)}let Qe=!1;const st=ce.map($e=>{const nt=String($e.seq);let qt=Te.get(nt)??W.current[nt];return qt||(qt=sfe(Ae),Ae.push(qt),Qe=!0),W.current[nt]=qt,{id:nt,type:"task",position:qt,deletable:!1,data:le($e)}});x(st),Qe&&Ce()},[ce,c,f,O,x,Ce,e]),_.useEffect(()=>{if(U.current!==c)return;const he=new Set(ce.map(le=>String(le.seq)));k(le=>{const Te=le.filter(Ae=>he.has(Ae.source)&&he.has(Ae.target));return Te.length!==le.length&&Ce(),Te.length===le.length?le:Te})},[ce,c,k,Ce]),_.useEffect(()=>{if(!c||U.current!==c||f!=="free"||ce.length<2)return;const he=hd(ce),le=[];for(let Qe=1;Qe<he.length;Qe+=1)for(const st of he[Qe-1]??[])for(const $e of he[Qe]??[])le.push({id:`seed-${st.seq}-${$e.seq}`,source:String(st.seq),target:String($e.seq),sourceHandle:"r",targetHandle:"l",animated:!1});const Te=X.current,Ae=F.current!==c;if(F.current=c,Ae&&Te.length===0)le.length>0&&(k(le),Ce());else{const Qe=new Set;for(const nt of Te)Qe.add(nt.source),Qe.add(nt.target);const st=new Set(Te.map(nt=>`${nt.source}->${nt.target}`)),$e=new Set(ce.map(nt=>String(nt.seq)).filter(nt=>!Y.current.has(nt)&&!Qe.has(nt)));if($e.size>0){const nt=le.filter(qt=>($e.has(qt.source)||$e.has(qt.target))&&!st.has(`${qt.source}->${qt.target}`));nt.length>0&&(k([...Te,...nt]),Ce())}}Y.current=new Set(ce.map(Qe=>String(Qe.seq)))},[ce,c,f,O,k,Ce]);const Ie=_.useCallback(he=>{if(v(he),f!=="free")return;let le=!1;for(const Te of he)Te.type==="position"&&Te.position&&(W.current[Te.id]=Te.position,le=!0);le&&Ce()},[v,Ce,f]),ae=_.useCallback(he=>{f==="free"&&(k(le=>vP({...he,animated:!1},le)),Ce())},[k,Ce,f]),ke=_.useCallback(()=>{if(f!=="free"||ce.length===0)return;const he=hd(ce),le={},Te=[];he.forEach((Ae,Qe)=>{if(Ae.forEach((st,$e)=>{le[String(st.seq)]={x:Sp+Qe*kp,y:Xx+$e*Yx}}),Qe>0)for(const st of he[Qe-1]??[])for(const $e of Ae)Te.push({id:`seed-${st.seq}-${$e.seq}`,source:String(st.seq),target:String($e.seq),sourceHandle:"r",targetHandle:"l",animated:!1})}),W.current={...W.current,...le},x(Ae=>Ae.map(Qe=>le[Qe.id]?{...Qe,position:le[Qe.id]}:Qe)),k(Te),Ce(),setTimeout(()=>r({padding:.2,duration:300}),60)},[f,ce,x,k,Ce,r]),Ue=_.useCallback(async he=>{if(!await i({title:e("flow.confirm.deleteTitle"),body:e("flow.confirm.deleteBody",{seq:he}),danger:!0,confirm:e("flow.node.delete")}))return;I("");const Te=X.current.filter(Ae=>Ae.source===String(he)||Ae.target===String(he)).map(Ae=>({...Ae}));try{await HL(c,he),o.current.push({seq:he,edges:Te})}catch(Ae){I(Ae instanceof Error?Ae.message:String(Ae))}finally{T(Ae=>Ae===he?null:Ae),j(Ae=>Ae===he?null:Ae),$.current="",z(Ae=>Ae+1),ge()}},[c,i,e,ge]),Oe=_.useCallback(async()=>{const he=o.current.pop();if(he){I("");try{await Jne(c,he.seq),k(le=>{const Te=new Set(le.map(Ae=>Ae.id));return[...le,...he.edges.filter(Ae=>!Te.has(Ae.id))]}),Ce(),ge()}catch(le){I(le instanceof Error?le.message:String(le))}}},[c,k,Ce,ge]),ht=_.useCallback((he,le)=>{var st;if(f!=="free"||le.isValid)return;const Te=le.fromNode;if(!Te||!c)return;const Ae="changedTouches"in he?he.changedTouches[0]:he;if(!Ae)return;const Qe=s({x:Ae.clientX,y:Ae.clientY});q({fromId:Te.id,fromHandle:((st=le.fromHandle)==null?void 0:st.id)??null,clientX:Ae.clientX,clientY:Ae.clientY,flowX:Qe.x,flowY:Qe.y})},[f,c,s]),tt=_.useCallback(async()=>{const he=B;if(q(null),!(!he||!c))try{const le=await gv(c,{title:`${e("flow.node.default")} ${ce.length+1}`,initialState:"Planning"}),Te=efe(le);if(Te==null)return;const Ae=String(Te);W.current[Ae]={x:he.flowX-ll/2,y:he.flowY-cl/2},k(Qe=>[...Qe,{id:`e-${he.fromId}-${Ae}-drop`,source:he.fromId,target:Ae,sourceHandle:he.fromHandle??void 0,animated:!1}]),Ce(),ge()}catch(le){I(le instanceof Error?le.message:String(le))}},[B,c,ce.length,k,Ce,e,ge]);_.useEffect(()=>{if(!B)return;const he=le=>{le.key==="Escape"&&q(null)};return window.addEventListener("keydown",he),()=>window.removeEventListener("keydown",he)},[B]);const jt=_.useCallback((he,le)=>{f==="free"&&(k(Te=>Kce(he,le,Te)),Ce())},[f,k,Ce]);_.useEffect(()=>{const he=le=>{if(le.key!=="Delete"&&le.key!=="Backspace"||A!=null)return;const Te=le.target;Te&&(Te.tagName==="INPUT"||Te.tagName==="TEXTAREA"||Te.isContentEditable)||S!=null&&(le.preventDefault(),Ue(S))};return window.addEventListener("keydown",he),()=>window.removeEventListener("keydown",he)},[S,A,Ue]),_.useEffect(()=>{const he=le=>{if(!(le.metaKey||le.ctrlKey)||le.key!=="z"&&le.key!=="Z"||A!=null)return;const Te=le.target;Te&&(Te.tagName==="INPUT"||Te.tagName==="TEXTAREA"||Te.isContentEditable)||(le.preventDefault(),Oe())};return window.addEventListener("keydown",he),()=>window.removeEventListener("keydown",he)},[A,Oe]);const Nt=_.useCallback(async he=>{if(c){y(!0),I("");try{const le=new Map(ce.map(Te=>[Te.seq,Te.order]));for(let Te=0;Te<he.length;Te+=1)for(const Ae of he[Te]??[])le.get(Ae)!==Te+1&&await wm(c,Ae,{order:Te+1});ge()}catch(le){I(le instanceof Error?le.message:String(le))}finally{y(!1)}}},[c,ce,ge]),pt=_.useCallback(he=>{const le=Number(he.id);if(!Number.isInteger(le))return;const Te=hd(ce).map($e=>$e.map(nt=>nt.seq)),Ae=(he.position.x-Sp)/kp,Qe=Math.round(Ae),st=Te.map($e=>$e.filter(nt=>nt!==le));if(Qe>=0&&Qe<Te.length&&Math.abs(Ae-Qe)<=.35)st[Qe].push(le);else{const $e=Math.max(0,Math.min(st.length,Math.ceil(Ae)));st.splice($e,0,[le])}Nt(st.filter($e=>$e.length>0)).finally(()=>{$.current="",z($e=>$e+1)})},[ce,Nt]),Me=_.useCallback((he,le)=>{if(f==="lanes"){pt(le);return}const Te=new Map(K.current.map(nt=>[nt.id,nt])),Ae={x:le.position.x+ll/2,y:le.position.y+cl/2};let Qe=null,st=40;for(const nt of X.current){if(nt.source===le.id||nt.target===le.id)continue;const qt=Te.get(nt.source),Xt=Te.get(nt.target);if(!qt||!Xt)continue;const Dt=rfe(Ae,PA(qt),PA(Xt));Dt<st&&(st=Dt,Qe=nt)}if(!Qe)return;const $e=Qe;k(nt=>[...nt.filter(qt=>qt.id!==$e.id),{id:`e-${$e.source}-${le.id}-${$e.id}`,source:$e.source,target:le.id,animated:!1},{id:`e-${le.id}-${$e.target}-${$e.id}`,source:le.id,target:$e.target,animated:!1}]),Ce()},[f,pt,k,Ce]),We=_.useCallback(he=>{p(he),localStorage.setItem(RA,he)},[]);_.useEffect(()=>{const he=setTimeout(()=>{r({padding:.2,duration:300})},80);return()=>clearTimeout(he)},[f,r]);const ne=async()=>{if(c){I("");try{await gv(c,{title:`${e("flow.node.default")} ${ce.length+1}`,initialState:"Planning"}),ge()}catch(he){I(he instanceof Error?he.message:String(he))}}},ve=async()=>{if(I(""),R(null),!c)return I(e("flow.err.noProject"));if(ce.length===0)return I(e("flow.err.noNodes"));D(!0);try{const he=ce.filter(Ae=>Ae.state==="Planning"),le=he.length;let Te=0;R({phase:"creating",made:Te,total:le});for(const Ae of he)await wm(c,Ae.seq,{state:"Backlog",labels:Array.from(new Set([...Ae.labels??[],"AI-PIPELINE"]))}),Te+=1,R({phase:"creating",made:Te,total:le});R({phase:"starting",made:Te,total:le}),await VL(c),ge(),R({phase:"done",made:Te,total:le})}catch(he){I(he instanceof Error?he.message:String(he))}finally{D(!1)}},Re=be.isLoading&&!!c;return d.jsxs("div",{className:"flex flex-col h-full",children:[d.jsxs("header",{className:"flex items-center gap-3 flex-wrap px-4 py-3 border-b border-[var(--surface-card-border)]",children:[d.jsxs("h1",{className:"text-lg font-[family-name:var(--font-heading)] flex items-center gap-2",children:[d.jsx(GN,{size:18,strokeWidth:2.4}),e("nav.arrange")]}),d.jsx(YL,{current:c,onChange:u}),d.jsxs("div",{className:"flex gap-1",role:"group","aria-label":e("flow.mode.aria"),children:[d.jsxs("button",{type:"button",className:["nb-btn",f==="free"?"nb-btn-primary":""].join(" "),"aria-pressed":f==="free",onClick:()=>We("free"),children:[d.jsx(GN,{size:14,strokeWidth:2.4})," ",e("flow.mode.free")]}),d.jsxs("button",{type:"button",className:["nb-btn",f==="lanes"?"nb-btn-primary":""].join(" "),"aria-pressed":f==="lanes",onClick:()=>We("lanes"),children:[d.jsx(aU,{size:14,strokeWidth:2.4})," ",e("flow.mode.lanes")]})]}),Re&&d.jsx(mt,{size:15,className:"animate-spin text-[var(--color-text-muted)]"}),d.jsxs("button",{type:"button",className:"nb-btn",onClick:()=>void ne(),disabled:!c||Re,children:[d.jsx(Gn,{size:15,strokeWidth:2.4})," ",e("flow.addNode")]}),d.jsxs("button",{type:"button",className:"nb-btn nb-btn-cta ml-auto",onClick:()=>void ve(),disabled:M||oe||Re||!c,title:oe?e("flow.pipelineRunning"):void 0,children:[M||oe?d.jsx(mt,{size:15,className:"animate-spin"}):d.jsx(Im,{size:15,strokeWidth:2.4}),e(M?"flow.running":oe?"flow.pipelineRunning":"flow.run")]})]}),!c&&d.jsx("div",{className:"px-4 py-2 text-sm text-[var(--color-text-muted)] border-b border-[var(--surface-card-border)]",children:e("flow.pickProject")}),P&&d.jsx("div",{className:"px-4 py-2 text-sm text-[var(--color-crashed)] bg-[var(--color-crashed-bg)] border-b border-[var(--surface-card-border)]",children:P}),G&&d.jsxs("div",{className:"px-4 py-2 text-sm flex items-center gap-3 bg-[var(--surface-input)] border-b border-[var(--surface-card-border)]",children:[G.phase==="creating"&&d.jsxs("span",{children:[e("flow.status.creating")," ",G.made,"/",G.total,"…"]}),G.phase==="starting"&&d.jsx("span",{children:e("flow.status.starting")}),G.phase==="done"&&d.jsxs(d.Fragment,{children:[d.jsxs("span",{className:"text-[var(--color-running)] font-bold",children:["✓ ",e("flow.status.done").replace("{n}",String(G.made))]}),d.jsx("button",{type:"button",className:"nb-btn nb-btn-blue",onClick:()=>n(`/board?project=${encodeURIComponent(c)}`),children:e("flow.goBoard")})]})]}),d.jsx("div",{className:"flex-1 min-h-0 arrange-flow-shell",children:d.jsxs(gde,{nodes:b,edges:ee,nodeTypes:tfe,connectionRadius:160,nodesConnectable:f==="free",edgesReconnectable:f==="free",deleteKeyCode:A!=null?null:["Delete","Backspace"],onNodesChange:Ie,onEdgesChange:he=>{f==="free"&&(C(he),Ce())},onConnect:ae,onConnectEnd:ht,onReconnect:jt,onNodeClick:(he,le)=>{const Te=Number(le.id);Number.isInteger(Te)&&j(Te)},onNodeDragStop:Me,onSelectionChange:({nodes:he})=>{const le=he[0]?Number(he[0].id):null;T(le!=null&&Number.isInteger(le)?le:null)},fitView:!0,children:[d.jsx(kde,{variant:la.Dots,gap:18,size:1}),d.jsx(jde,{children:f==="free"&&d.jsx(wd,{onClick:ke,title:e("flow.tidy"),"aria-label":e("flow.tidy"),children:d.jsx(Uj,{size:14,strokeWidth:2.4})})})]})}),B&&d.jsx("div",{className:"fixed inset-0 z-30",onClick:()=>q(null),children:d.jsxs("button",{type:"button",className:"nb-btn nb-btn-cta absolute -translate-x-1/2 -translate-y-1/2",style:{left:B.clientX,top:B.clientY},onClick:he=>{he.stopPropagation(),tt()},children:[d.jsx(Gn,{size:14,strokeWidth:2.4})," ",e("flow.pending.create")]})}),m&&d.jsxs("div",{className:"px-4 py-1 text-xs text-[var(--color-text-muted)] border-t border-[var(--surface-card-border)] flex items-center gap-2",children:[d.jsx(mt,{size:12,className:"animate-spin"})," ",e("flow.lane.applying")]}),d.jsx("footer",{className:"px-4 py-2 text-xs text-[var(--color-text-muted)] border-t border-[var(--surface-card-border)]",children:e(f==="free"?"flow.hint":"flow.lane.hint")}),A!=null&&c&&d.jsx(Zde,{project:c,seq:A,onClose:()=>j(null),onChanged:ge,onDelete:he=>void Ue(he)})]})}function ofe(){return d.jsx(KP,{children:d.jsx(afe,{})})}function lfe(){const e=Xe();return d.jsxs("div",{className:"nb-card max-w-2xl mt-12",children:[d.jsx("h1",{className:"font-[family-name:var(--font-heading)] text-4xl font-bold mb-2",children:e("notFound.title")}),d.jsx("p",{className:"text-[var(--color-text-muted)] mb-6",children:e("notFound.body")}),d.jsx(Bc,{to:"/",className:"nb-btn nb-btn-mint inline-flex",children:e("notFound.home")})]})}const cfe=_.lazy(()=>AB(()=>import("./ShowcasePage-1P7DtNt1.js"),__vite__mapDeps([0,1])));function ufe(){return d.jsx(SF,{children:d.jsxs(G5,{children:[d.jsx(oi,{path:"/showcase",element:d.jsx(_.Suspense,{fallback:null,children:d.jsx(cfe,{})})}),d.jsxs(oi,{element:d.jsx(QN,{contentMode:"workspace"}),children:[d.jsx(oi,{index:!0,element:d.jsx(wx,{})}),d.jsx(oi,{path:"/projects",element:d.jsx(mT,{})}),d.jsx(oi,{path:"/projects/:name",element:d.jsx(mT,{})}),d.jsx(oi,{path:"/board",element:d.jsx(vie,{})}),d.jsx(oi,{path:"/prompts",element:d.jsx(Oie,{})}),d.jsx(oi,{path:"/chat",element:d.jsx(wx,{})}),d.jsx(oi,{path:"/chat/:sessionId",element:d.jsx(wx,{})}),d.jsx(oi,{path:"/arrange",element:d.jsx(ofe,{})})]}),d.jsxs(oi,{element:d.jsx(QN,{contentMode:"document"}),children:[d.jsx(oi,{path:"/projects/new",element:d.jsx(FL,{})}),d.jsx(oi,{path:"/skills",element:d.jsx(Cie,{})}),d.jsx(oi,{path:"/system",element:d.jsx(Zie,{})}),d.jsx(oi,{path:"/memory",element:d.jsx(use,{})}),d.jsx(oi,{path:"/plugins",element:d.jsx(Sse,{})}),d.jsx(oi,{path:"*",element:d.jsx(lfe,{})})]})]})})}kF();X6();const dfe=new L4({defaultOptions:{queries:{staleTime:3e4,refetchOnWindowFocus:!1}}}),XP=document.getElementById("root");if(!XP)throw new Error("#root not found");u4.createRoot(XP).render(d.jsx(_.StrictMode,{children:d.jsx(U6,{children:d.jsx(I4,{client:dfe,children:d.jsx(bB,{children:d.jsx(uY,{children:d.jsx(ufe,{})})})})})}));export{Mj as A,iU as C,Ij as E,Bc as L,Qv as P,m0 as S,zB as a,Be as c,d as j,_ as r,Yj as u};
|