@coralai/sps-cli 0.65.20 → 0.65.22

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.
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ShowcasePage-lGZ30wQv.js","assets/ShowcasePage-EkuegwaP.css"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ShowcasePage-BAs5NC0m.js","assets/ShowcasePage-EkuegwaP.css"])))=>i.map(i=>d[i]);
2
2
  var Fz=Object.defineProperty;var oN=e=>{throw TypeError(e)};var $z=(e,t,n)=>t in e?Fz(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var lN=(e,t,n)=>$z(e,typeof t!="symbol"?t+"":t,n),xb=(e,t,n)=>t.has(e)||oN("Cannot "+n);var ee=(e,t,n)=>(xb(e,t,"read from private field"),n?n.call(e):t.get(e)),nt=(e,t,n)=>t.has(e)?oN("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Be=(e,t,n,i)=>(xb(e,t,"write to private field"),i?i.call(e,n):t.set(e,n),n),kt=(e,t,n)=>(xb(e,t,"access private method"),n);var Ih=(e,t,n,i)=>({set _(s){Be(e,t,s,n)},get _(){return ee(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 a of s)if(a.type==="childList")for(const o of a.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&i(o)}).observe(document,{childList:!0,subtree:!0});function n(s){const a={};return s.integrity&&(a.integrity=s.integrity),s.referrerPolicy&&(a.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?a.credentials="include":s.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function i(s){if(s.ep)return;s.ep=!0;const a=n(s);fetch(s.href,a)}})();function nf(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var vb={exports:{}},Wu={};/**
3
3
  * @license React
4
4
  * react-jsx-runtime.production.js
@@ -674,7 +674,7 @@ void main() {
674
674
  `},f]}}const aG=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_-]*/}}),oG=["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"],lG=["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"],cG=[...oG,...lG],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(),fR=["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(),hR=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),dG=["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(),fG=fR.concat(hR).sort().reverse();function hG(e){const t=aG(e),n=fG,i="and or not only",s="[\\w-]+",a="("+s+"|@\\{"+s+"\\})",o=[],c=[],u=function(k){return{className:"string",begin:"~?"+k+".*?"+k}},f=function(k,T,A){return{className:k,begin:T,relevance:A}},m={$pattern:/[a-z-]+/,keyword:i,attribute:uG.join(" ")},p={begin:"\\(",end:"\\)",contains:c,keywords:m,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,p,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:a+"\\s*:",returnBegin:!0,end:/[;}]/,relevance:0,contains:[{begin:/-(webkit|moz|ms|o)-/},t.CSS_VARIABLE,{className:"attribute",begin:"\\b("+dG.join("|")+")\\b",end:/(?=:)/,starts:{endsWithParent:!0,illegal:"[<=$]",relevance:0,contains:c}}]},w={className:"keyword",begin:"@(import|media|charset|font-face|(-[a-z]+-)?keyframes|supports|document|namespace|page|viewport|host)\\b",starts:{end:"[;{}]",keywords:m,returnEnd:!0,contains:c,relevance:0}},E={className:"variable",variants:[{begin:"@"+s+"\\s*:",relevance:15},{begin:"@"+s}],starts:{end:"[;}]",returnEnd:!0,contains:y}},v={variants:[{begin:"[\\.#:&\\[>]",end:"[;{}]"},{begin:a,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("+cG.join("|")+")\\b",className:"selector-tag"},t.CSS_NUMBER_MODE,f("selector-tag",a,0),f("selector-id","#"+a),f("selector-class","\\."+a,0),f("selector-tag","&",0),t.ATTRIBUTE_SELECTOR_MODE,{className:"selector-pseudo",begin:":("+fR.join("|")+")"},{className:"selector-pseudo",begin:":(:)?("+hR.join("|")+")"},{begin:/\(/,end:/\)/,relevance:0,contains:y},{begin:"!important"},t.FUNCTION_DISPATCH]},_={begin:s+`:(:)?(${n.join("|")})`,returnBegin:!0,contains:[v]};return o.push(e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,w,E,_,x,v,b,t.FUNCTION_DISPATCH),{name:"Less",case_insensitive:!0,illegal:`[=>'/<($"]`,contains:o}}function pG(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 mG(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*(?=[:+?]?=)"},a={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,a,o]}}function gG(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}]},a={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}/}]},m={className:"emphasis",contains:[],variants:[{begin:/\*(?![*\s])/,end:/\*/},{begin:/_(?![_\s])/,end:/_/,relevance:0}]},p=e.inherit(f,{contains:[]}),y=e.inherit(m,{contains:[]});f.contains.push(y),m.contains.push(p);let b=[n,u];return[f,m,p,y].forEach(v=>{v.contains=v.contains.concat(b)}),b=b.concat(f,m),{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,a,f,m,{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 yG(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 bG(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(" ")},a={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},m=[e.BACKSLASH_ESCAPE,a,u],p=[/!/,/\//,/\|/,/\?/,/'/,/"/,/#/],y=(w,E,v="\\1")=>{const _=v==="\\1"?v:t.concat(v,E);return t.concat(t.concat("(?:",w,")"),E,/(?:\\.|[^\\\/])*?/,_,/(?:\\.|[^\\\/])*?/,v,i)},b=(w,E,v)=>t.concat(t.concat("(?:",w,")"),E,/(?:\\.|[^\\\/])*?/,v,i),x=[u,e.HASH_COMMENT_MODE,e.COMMENT(/^=\w/,/=cut/,{endsWithParent:!0}),o,{className:"string",contains:m,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(...p,{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(...p,{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 a.contains=x,o.contains=x,{name:"Perl",aliases:["pl","pm"],keywords:s,contains:x}}function xG(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),a=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}),m=e.inherit(e.QUOTE_STRING_MODE,{illegal:null,contains:e.QUOTE_STRING_MODE.contains.concat(u)}),p={begin:/<<<[ \t]*(?:(\w+)|"(\w+)")\n/,end:/[ \t]*(\w+)\b/,contains:e.QUOTE_STRING_MODE.contains.concat(u),"on:begin":(O,R)=>{R.data._beginMatch=O[1]||O[2]},"on:end":(O,R)=>{R.data._beginMatch!==O[1]&&R.ignoreMatch()}},y=e.END_SAME_AS_BEGIN({begin:/<<<[ \t]*'(\w+)'\n/,end:/[ \t]*(\w+)\b/}),b=`[
675
675
  ]`,x={scope:"string",variants:[m,f,p,y]},w={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},E=["false","null","true"],v=["__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"],_=["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:v,literal:(O=>{const R=[];return O.forEach(z=>{R.push(z),z.toLowerCase()===z?R.push(z.toUpperCase()):R.push(z.toLowerCase())}),R})(E),built_in:_},A=O=>O.map(R=>R.replace(/\|\d+$/,"")),j={variants:[{match:[/new/,t.concat(b,"+"),t.concat("(?!",A(_).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"}}]},I={scope:"attr",match:t.concat(i,t.lookahead(":"),t.lookahead(/(?!::)/))},P={relevance:0,begin:/\(/,end:/\)/,keywords:T,contains:[I,o,D,e.C_BLOCK_COMMENT_MODE,x,w,j]},U={relevance:0,match:[/\b/,t.concat("(?!fn\\b|function\\b|",A(v).join("\\b|"),"|",A(_).join("\\b|"),"\\b)"),i,t.concat(b,"*"),t.lookahead(/(?=\()/)],scope:{3:"title.function.invoke"},contains:[P]};P.contains.push(U);const q=[I,D,e.C_BLOCK_COMMENT_MODE,x,w,j],V={begin:t.concat(/#\[\s*\\?/,t.either(s,a)),beginScope:"meta",end:/]/,endScope:"meta",keywords:{literal:E,keyword:["new","array"]},contains:[{begin:/\[/,end:/]/,keywords:{literal:E,keyword:["new","array"]},contains:["self",...q]},...q,{scope:"meta",variants:[{match:s},{match:a}]}]};return{case_insensitive:!1,keywords:T,contains:[V,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,U,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",V,o,D,e.C_BLOCK_COMMENT_MODE,x,w]}]},{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,w]}}function vG(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 wG(e){return{name:"Plain text",aliases:["text","txt"],disableAutodetect:!0}}function EG(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:/#/},m={begin:/\{\{/,relevance:0},p={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,m,f]},{begin:/([fF][rR]|[rR][fF]|[fF])"""/,end:/"""/,contains:[e.BACKSLASH_ESCAPE,u,m,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,m,f]},{begin:/([fF][rR]|[rR][fF]|[fF])"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,m,f]},e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},y="[0-9](_?[0-9])*",b=`(\\b(${y}))?\\.(${y})|\\b(${y})\\.`,x=`\\b|${i.join("|")}`,w={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})`}]},E={className:"comment",begin:t.lookahead(/# type:/),end:/$/,keywords:c,contains:[{begin:/# type:/},{begin:/#/,end:/\b\B/,endsWithParent:!0}]},v={className:"params",variants:[{className:"",begin:/\(\s*\)/,skip:!0},{begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:c,contains:["self",u,w,p,e.HASH_COMMENT_MODE]}]};return f.contains=[p,w,u],{name:"Python",aliases:["py","gyp","ipython"],unicodeRegex:!0,keywords:c,illegal:/(<\/|\?)|=>/,contains:[u,w,{scope:"variable.language",match:/\bself\b/},{beginKeywords:"if",relevance:0},{match:/\bor\b/,scope:"keyword"},p,E,e.HASH_COMMENT_MODE,{match:[/\bdef/,/\s+/,n],scope:{1:"keyword",3:"title.function"},contains:[v]},{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:[w,v,p]}]}}function SG(e){return{aliases:["pycon"],contains:[{className:"meta.prompt",starts:{end:/ |$/,starts:{end:"$",subLanguage:"python"}},variants:[{begin:/^>>>(?=[ ]|$)/},{begin:/^\.\.\.(?=[ ]|$)/}]}]}}function kG(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=/[=!<>:]=|\|\||&&|:::?|<-|<<-|->>|->|\|>|[-+*\/?!$&|:<=>@^~]|\*\*/,a=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:[a,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:a},{begin:"`",end:"`",contains:[{begin:/\\./}]}]}}function NG(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)],m={className:"subst",begin:/#\{/,end:/\}/,keywords:o},p={className:"string",contains:[e.BACKSLASH_ESCAPE,m],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,m]})]}]},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"}]},w={variants:[{match:/\(\)/},{className:"params",begin:/\(/,end:/(?=\))/,excludeBegin:!0,endsParent:!0,keywords:o}]},j=[p,{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:[w]},{begin:e.IDENT_RE+"::"},{className:"symbol",begin:e.UNDERSCORE_IDENT_RE+"(!|\\?)?:",relevance:0},{className:"symbol",begin:":(?!\\s)",contains:[p,{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,m],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);m.contains=j,w.contains=j;const P=[{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(P).concat(f).concat(j)}}function _G(e){const t=e.regex,n=/(r#)?/,i=t.concat(n,e.UNDERSCORE_IDENT_RE),s=t.concat(n,e.IDENT_RE),a={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!"],m=["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:m,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:m}},{className:"punctuation",begin:"->"},a]}}const CG=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_-]*/}}),TG=["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"],AG=["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"],jG=[...TG,...AG],MG=["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(),RG=["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(),DG=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),OG=["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 LG(e){const t=CG(e),n=DG,i=RG,s="@[a-z-]+",a="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("+jG.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("+OG.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:a,attribute:MG.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 IG(e){return{name:"Shell Session",aliases:["console","shellsession"],contains:[{className:"meta.prompt",begin:/^\s{0,3}[/~\w\d[\]()@-]*[>%$#][ ]?/,starts:{end:/[^\\](?=\s*$)/,subLanguage:"bash"}}]}}function PG(e){const t=e.regex,n=e.COMMENT("--","$"),i={scope:"string",variants:[{begin:/'/,end:/'/,contains:[{match:/''/}]}]},s={begin:/"/,end:/"/,contains:[{match:/""/}]},a=["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"],m=["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"],p=["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=m,x=[...f,...u].filter(A=>!m.includes(A)),w={scope:"variable",match:/@[a-z0-9][a-z0-9_]*/},E={scope:"operator",match:/[-+*/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?/,relevance:0},v={match:t.concat(/\b/,t.either(...b),/\s*\(/),relevance:0,keywords:{built_in:b}};function _(A){return t.concat(/\b/,t.either(...A.map(j=>j.replace(/\s+/,"\\s+"))),/\b/)}const k={scope:"keyword",match:_(y),relevance:0};function T(A,{exceptions:j,when:M}={}){const D=M;return j=j||[],A.map(I=>I.match(/\|\d+$/)||j.includes(I)?I:D(I)?`${I}|0`:I)}return{name:"SQL",case_insensitive:!0,illegal:/[{}]|<\//,keywords:{$pattern:/\b[\w\.]+/,keyword:T(x,{when:A=>A.length<3}),literal:a,type:c,built_in:p},contains:[{scope:"type",match:_(o)},k,v,w,i,s,e.C_NUMBER_MODE,e.C_BLOCK_COMMENT_MODE,n,E]}}function pR(e){return e?typeof e=="string"?e:e.source:null}function nd(e){return an("(?=",e,")")}function an(...e){return e.map(n=>pR(n)).join("")}function zG(e){const t=e[e.length-1];return typeof t=="object"&&t.constructor===Object?(e.splice(e.length-1,1),t):{}}function Ei(...e){return"("+(zG(e).capture?"":"?:")+e.map(i=>pR(i)).join("|")+")"}const y1=e=>an(/\b/,e,/\w$/.test(e)?/\b/:/\B/),BG=["Protocol","Type"].map(y1),p2=["init","self"].map(y1),UG=["Any","Self"],Qb=["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"],m2=["false","nil","true"],FG=["assignment","associativity","higherThan","left","lowerThan","none","right"],$G=["#colorLiteral","#column","#dsohandle","#else","#elseif","#endif","#error","#file","#fileID","#fileLiteral","#filePath","#function","#if","#imageLiteral","#keyPath","#line","#selector","#sourceLocation","#warning"],g2=["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"],mR=Ei(/[/=\-+!*%<>&|^~?]/,/[\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]/),gR=Ei(mR,/[\u0300-\u036F]/,/[\u1DC0-\u1DFF]/,/[\u20D0-\u20FF]/,/[\uFE00-\uFE0F]/,/[\uFE20-\uFE2F]/),Zb=an(mR,gR,"*"),yR=Ei(/[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]/),Jp=Ei(yR,/\d/,/[\u0300-\u036F\u1DC0-\u1DFF\u20D0-\u20FF\uFE20-\uFE2F]/),rr=an(yR,Jp,"*"),Wh=an(/[A-Z]/,Jp,"*"),qG=["attached","autoclosure",an(/convention\(/,Ei("swift","block","c"),/\)/),"discardableResult","dynamicCallable","dynamicMemberLookup","escaping","freestanding","frozen","GKInspectable","IBAction","IBDesignable","IBInspectable","IBOutlet","IBSegueAction","inlinable","main","nonobjc","NSApplicationMain","NSCopying","NSManaged",an(/objc\(/,rr,/\)/),"objc","objcMembers","propertyWrapper","requires_stored_property_inits","resultBuilder","Sendable","testable","UIApplicationMain","unchecked","unknown","usableFromInline","warn_unqualified_access"],HG=["iOS","iOSApplicationExtension","macOS","macOSApplicationExtension","macCatalyst","macCatalystApplicationExtension","watchOS","watchOSApplicationExtension","tvOS","tvOSApplicationExtension","swift"];function VG(e){const t={match:/\s+/,relevance:0},n=e.COMMENT("/\\*","\\*/",{contains:["self"]}),i=[e.C_LINE_COMMENT_MODE,n],s={match:[/\./,Ei(...BG,...p2)],className:{2:"keyword"}},a={match:an(/\./,Ei(...Qb)),relevance:0},o=Qb.filter(Se=>typeof Se=="string").concat(["_|0"]),c=Qb.filter(Se=>typeof Se!="string").concat(UG).map(y1),u={variants:[{className:"keyword",match:Ei(...c,...p2)}]},f={$pattern:Ei(/\b\w+/,/#\w+/),keyword:o.concat($G),literal:m2},m=[s,a,u],p={match:an(/\./,Ei(...g2)),relevance:0},y={className:"built_in",match:an(/\b/,Ei(...g2),/(?=\()/)},b=[p,y],x={match:/->/,relevance:0},w={className:"operator",relevance:0,variants:[{match:Zb},{match:`\\.(\\.|${gR})+`}]},E=[x,w],v="([0-9]_*)+",_="([0-9a-fA-F]_*)+",k={className:"number",relevance:0,variants:[{match:`\\b(${v})(\\.(${v}))?([eE][+-]?(${v}))?\\b`},{match:`\\b0x(${_})(\\.(${_}))?([pP][+-]?(${v}))?\\b`},{match:/\b0o([0-7]_*)+\b/},{match:/\b0b([01]_*)+\b/}]},T=(Se="")=>({className:"subst",variants:[{match:an(/\\/,Se,/[0\\tnr"']/)},{match:an(/\\/,Se,/u\{[0-9a-fA-F]{1,8}\}/)}]}),A=(Se="")=>({className:"subst",match:an(/\\/,Se,/[\t ]*(?:[\r\n]|\r\n)/)}),j=(Se="")=>({className:"subst",label:"interpol",begin:an(/\\/,Se,/\(/),end:/\)/}),M=(Se="")=>({begin:an(Se,/"""/),end:an(/"""/,Se),contains:[T(Se),A(Se),j(Se)]}),D=(Se="")=>({begin:an(Se,/"/),end:an(/"/,Se),contains:[T(Se),j(Se)]}),I={className:"string",variants:[M(),M("#"),M("##"),M("###"),D(),D("#"),D("##"),D("###")]},P=[e.BACKSLASH_ESCAPE,{begin:/\[/,end:/\]/,relevance:0,contains:[e.BACKSLASH_ESCAPE]}],U={begin:/\/[^\s](?=[^/\n]*\/)/,end:/\//,contains:P},q=Se=>{const Re=an(Se,/\//),Qe=an(/\//,Se);return{begin:Re,end:Qe,contains:[...P,{scope:"comment",begin:`#(?!.*${Qe})`,end:/$/}]}},V={scope:"regexp",variants:[q("###"),q("##"),q("#"),U]},O={match:an(/`/,rr,/`/)},R={className:"variable",match:/\$\d+/},z={className:"variable",match:`\\$${Jp}+`},G=[O,R,z],X={match:/(@|#(un)?)available/,scope:"keyword",starts:{contains:[{begin:/\(/,end:/\)/,keywords:HG,contains:[...E,k,I]}]}},K={scope:"keyword",match:an(/@/,Ei(...qG),nd(Ei(/\(/,/\s+/)))},B={scope:"meta",match:an(/@/,rr)},F=[X,K,B],W={match:nd(/\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)/,Jp,"+")},{className:"type",match:Wh,relevance:0},{match:/[?!]+/,relevance:0},{match:/\.\.\./,relevance:0},{match:an(/\s+&\s+/,nd(Wh)),relevance:0}]},$={begin:/</,end:/>/,keywords:f,contains:[...i,...m,...F,x,W]};W.contains.push($);const ae={match:an(rr,/\s*:/),keywords:"_|0",relevance:0},xe={begin:/\(/,end:/\)/,relevance:0,keywords:f,contains:["self",ae,...i,V,...m,...b,...E,k,I,...G,...F,W]},le={begin:/</,end:/>/,keywords:"repeat each",contains:[...i,W]},Ne={begin:Ei(nd(an(rr,/\s*:/)),nd(an(rr,/\s+/,rr,/\s*:/))),end:/:/,relevance:0,contains:[{className:"keyword",match:/\b_\b/},{className:"params",match:rr}]},re={begin:/\(/,end:/\)/,keywords:f,contains:[Ne,...i,...m,...E,k,I,...F,W,xe],endsParent:!0,illegal:/["']/},me={match:[/(func|macro)/,/\s+/,Ei(O.match,rr,Zb)],className:{1:"keyword",3:"title.function"},contains:[le,re,t],illegal:[/\[/,/%/]},se={match:[/\b(?:subscript|init[?!]?)/,/\s*(?=[<(])/],className:{1:"keyword"},contains:[le,re,t],illegal:/\[|%/},Q={match:[/operator/,/\s+/,Zb],className:{1:"keyword",3:"title"}},ye={begin:[/precedencegroup/,/\s+/,Wh],className:{1:"keyword",3:"title"},contains:[W],keywords:[...FG,...m2],end:/}/},_e={match:[/class\b/,/\s+/,/func\b/,/\s+/,/\b[A-Za-z_][A-Za-z0-9_]*\b/],scope:{1:"keyword",3:"keyword",5:"title.function"}},ze={match:[/class\b/,/\s+/,/var\b/],scope:{1:"keyword",3:"keyword"}},fe={begin:[/(struct|protocol|class|extension|enum|actor)/,/\s+/,rr,/\s*/],beginScope:{1:"keyword",3:"title.class"},keywords:f,contains:[le,...m,{begin:/:/,end:/\{/,keywords:f,contains:[{scope:"title.class.inherited",match:Wh},...m],relevance:0}]};for(const Se of I.variants){const Re=Se.contains.find(ht=>ht.label==="interpol");Re.keywords=f;const Qe=[...m,...b,...E,k,I,...G];Re.contains=[...Qe,{begin:/\(/,end:/\)/,contains:["self",...Qe]}]}return{name:"Swift",keywords:f,contains:[...i,me,se,_e,ze,fe,Q,ye,{beginKeywords:"import",end:/$/,contains:[...i],relevance:0},V,...m,...b,...E,k,I,...G,...F,W,xe]}}const em="[A-Za-z$_][0-9A-Za-z$_]*",bR=["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"],xR=["true","false","null","undefined","NaN","Infinity"],vR=["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"],wR=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],ER=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],SR=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","global"],kR=[].concat(ER,vR,wR);function KG(e){const t=e.regex,n=(X,{after:K})=>{const B="</"+X[0].slice(1);return X.input.indexOf(B,K)!==-1},i=em,s={begin:"<>",end:"</>"},a=/<[A-Za-z0-9\\._:-]+\s*\/>/,o={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(X,K)=>{const B=X[0].length+X.index,F=X.input[B];if(F==="<"||F===","){K.ignoreMatch();return}F===">"&&(n(X,{after:B})||K.ignoreMatch());let W;const $=X.input.substring(B);if(W=$.match(/^\s*=/)){K.ignoreMatch();return}if((W=$.match(/^\s+extends\s+/))&&W.index===0){K.ignoreMatch();return}}},c={$pattern:em,keyword:bR,literal:xR,built_in:kR,"variable.language":SR},u="[0-9](_?[0-9])*",f=`\\.(${u})`,m="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",p={className:"number",variants:[{begin:`(\\b(${m})((${f})|\\.)?|(${f}))[eE][+-]?(${u})\\b`},{begin:`\\b(${m})\\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"}},w={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,y],subLanguage:"graphql"}},E={className:"string",begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,y]},_={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]},k=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,b,x,w,E,{match:/\$\d+/},p];y.contains=k.concat({begin:/\{/,end:/\}/,keywords:c,contains:["self"].concat(k)});const T=[].concat(_,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:{_:[...vR,...wR]}},I={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},P={variants:[{match:[/function/,/\s+/,i,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[j],illegal:/%/},U={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function q(X){return t.concat("(?!",X.join("|"),")")}const V={match:t.concat(/\b/,q([...ER,"super","import"].map(X=>`${X}\\s*\\(`)),i,t.lookahead(/\s*\(/)),className:"title.function",relevance:0},O={begin:t.concat(/\./,t.lookahead(t.concat(i,/(?![0-9A-Za-z$_(])/))),end:i,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},R={match:[/get|set/,/\s+/,i,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},j]},z="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+e.UNDERSCORE_IDENT_RE+")\\s*=>",G={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}),I,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,b,x,w,E,_,{match:/\$\d+/},p,D,{scope:"attr",match:i+t.lookahead(":"),relevance:0},G,{begin:"("+e.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[_,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:a},{begin:o.begin,"on:begin":o.isTrulyOpeningTag,end:o.end}],subLanguage:"xml",contains:[{begin:o.begin,end:o.end,skip:!0,contains:["self"]}]}]},P,{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},O,{match:"\\$"+i,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[j]},V,U,M,R,{match:/\$[(.]/}]}}function GG(e){const t=e.regex,n=KG(e),i=em,s=["any","void","number","boolean","string","object","never","symbol","bigint","unknown"],a={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:em,keyword:bR.concat(u),literal:xR,built_in:kR.concat(s),"variable.language":SR},m={className:"meta",begin:"@"+i},p=(w,E,v)=>{const _=w.contains.findIndex(k=>k.label===E);if(_===-1)throw new Error("can not find mode to replace");w.contains.splice(_,1,v)};Object.assign(n.keywords,f),n.exports.PARAMS_CONTAINS.push(m);const y=n.contains.find(w=>w.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([m,a,o,b]),p(n,"shebang",e.SHEBANG()),p(n,"use_strict",c);const x=n.contains.find(w=>w.label==="func.def");return x.relevance=0,Object.assign(n,{name:"TypeScript",aliases:["ts","tsx","mts","cts"]}),n}function WG(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}/,a=/\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(a,s),/ *#/)},{begin:t.concat(/# */,c,/ *#/)},{begin:t.concat(/# */,o,/ *#/)},{begin:t.concat(/# */,t.either(a,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])|[%&])?/}]},m={className:"label",begin:/^\w+:/},p=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,m,p,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 YG(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"}},a={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"}},a,o,s,e.QUOTE_STRING_MODE,u,f,c]}}function XG(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]+;/},a={begin:/\s/,contains:[{className:"keyword",begin:/#?[a-z_][a-z1-9_-]+/,illegal:/\n/}]},o=e.inherit(a,{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:[a,u,c,o,{begin:/\[/,end:/\]/,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,contains:[a,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 QG(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:/\}/}]},a={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},w={begin:"\\[",end:"\\]",contains:[b],illegal:"\\n",relevance:0},E=[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,w,a,o],v=[...E];return v.pop(),v.push(c),b.contains=v,{name:"YAML",case_insensitive:!0,aliases:["yml"],contains:E}}const ZG={arduino:D7,bash:O7,c:L7,cpp:I7,csharp:P7,css:K7,diff:G7,go:W7,graphql:Y7,ini:X7,java:Q7,javascript:nG,json:iG,kotlin:rG,less:hG,lua:pG,makefile:mG,markdown:gG,objectivec:yG,perl:bG,php:xG,"php-template":vG,plaintext:wG,python:EG,"python-repl":SG,r:kG,ruby:NG,rust:_G,scss:LG,shell:IG,sql:PG,swift:VG,typescript:GG,vbnet:WG,wasm:YG,xml:XG,yaml:QG};var Jb,y2;function JG(){if(y2)return Jb;y2=1;function e(Z){return Z instanceof Map?Z.clear=Z.delete=Z.set=function(){throw new Error("map is read-only")}:Z instanceof Set&&(Z.add=Z.clear=Z.delete=function(){throw new Error("set is read-only")}),Object.freeze(Z),Object.getOwnPropertyNames(Z).forEach(be=>{const Ie=Z[be],ut=typeof Ie;(ut==="object"||ut==="function")&&!Object.isFrozen(Ie)&&e(Ie)}),Z}class t{constructor(be){be.data===void 0&&(be.data={}),this.data=be.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}}function n(Z){return Z.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#x27;")}function i(Z,...be){const Ie=Object.create(null);for(const ut in Z)Ie[ut]=Z[ut];return be.forEach(function(ut){for(const Yt in ut)Ie[Yt]=ut[Yt]}),Ie}const s="</span>",a=Z=>!!Z.scope,o=(Z,{prefix:be})=>{if(Z.startsWith("language:"))return Z.replace("language:","language-");if(Z.includes(".")){const Ie=Z.split(".");return[`${be}${Ie.shift()}`,...Ie.map((ut,Yt)=>`${ut}${"_".repeat(Yt+1)}`)].join(" ")}return`${be}${Z}`};class c{constructor(be,Ie){this.buffer="",this.classPrefix=Ie.classPrefix,be.walk(this)}addText(be){this.buffer+=n(be)}openNode(be){if(!a(be))return;const Ie=o(be.scope,{prefix:this.classPrefix});this.span(Ie)}closeNode(be){a(be)&&(this.buffer+=s)}value(){return this.buffer}span(be){this.buffer+=`<span class="${be}">`}}const u=(Z={})=>{const be={children:[]};return Object.assign(be,Z),be};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(be){this.top.children.push(be)}openNode(be){const Ie=u({scope:be});this.add(Ie),this.stack.push(Ie)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(be){return this.constructor._walk(be,this.rootNode)}static _walk(be,Ie){return typeof Ie=="string"?be.addText(Ie):Ie.children&&(be.openNode(Ie),Ie.children.forEach(ut=>this._walk(be,ut)),be.closeNode(Ie)),be}static _collapse(be){typeof be!="string"&&be.children&&(be.children.every(Ie=>typeof Ie=="string")?be.children=[be.children.join("")]:be.children.forEach(Ie=>{f._collapse(Ie)}))}}class m extends f{constructor(be){super(),this.options=be}addText(be){be!==""&&this.add(be)}startScope(be){this.openNode(be)}endScope(){this.closeNode()}__addSublanguage(be,Ie){const ut=be.root;Ie&&(ut.scope=`language:${Ie}`),this.add(ut)}toHTML(){return new c(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}}function p(Z){return Z?typeof Z=="string"?Z:Z.source:null}function y(Z){return w("(?=",Z,")")}function b(Z){return w("(?:",Z,")*")}function x(Z){return w("(?:",Z,")?")}function w(...Z){return Z.map(Ie=>p(Ie)).join("")}function E(Z){const be=Z[Z.length-1];return typeof be=="object"&&be.constructor===Object?(Z.splice(Z.length-1,1),be):{}}function v(...Z){return"("+(E(Z).capture?"":"?:")+Z.map(ut=>p(ut)).join("|")+")"}function _(Z){return new RegExp(Z.toString()+"|").exec("").length-1}function k(Z,be){const Ie=Z&&Z.exec(be);return Ie&&Ie.index===0}const T=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;function A(Z,{joinWith:be}){let Ie=0;return Z.map(ut=>{Ie+=1;const Yt=Ie;let Tt=p(ut),$e="";for(;Tt.length>0;){const Ue=T.exec(Tt);if(!Ue){$e+=Tt;break}$e+=Tt.substring(0,Ue.index),Tt=Tt.substring(Ue.index+Ue[0].length),Ue[0][0]==="\\"&&Ue[1]?$e+="\\"+String(Number(Ue[1])+Yt):($e+=Ue[0],Ue[0]==="("&&Ie++)}return $e}).map(ut=>`(${ut})`).join(be)}const j=/\b\B/,M="[a-zA-Z]\\w*",D="[a-zA-Z_]\\w*",I="\\b\\d+(\\.\\d+)?",P="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",U="\\b(0b[01]+)",q="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",V=(Z={})=>{const be=/^#![ ]*\//;return Z.binary&&(Z.begin=w(be,/.*\b/,Z.binary,/\b.*/)),i({scope:"meta",begin:be,end:/$/,relevance:0,"on:begin":(Ie,ut)=>{Ie.index!==0&&ut.ignoreMatch()}},Z)},O={begin:"\\\\[\\s\\S]",relevance:0},R={scope:"string",begin:"'",end:"'",illegal:"\\n",contains:[O]},z={scope:"string",begin:'"',end:'"',illegal:"\\n",contains:[O]},G={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(Z,be,Ie={}){const ut=i({scope:"comment",begin:Z,end:be,contains:[]},Ie);ut.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 Yt=v("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 ut.contains.push({begin:w(/[ ]+/,"(",Yt,/[.]?[:]?([.][ ]|[ ])/,"){3}")}),ut},K=X("//","$"),B=X("/\\*","\\*/"),F=X("#","$"),W={scope:"number",begin:I,relevance:0},$={scope:"number",begin:P,relevance:0},ae={scope:"number",begin:U,relevance:0},xe={scope:"regexp",begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[O,{begin:/\[/,end:/\]/,relevance:0,contains:[O]}]},le={scope:"title",begin:M,relevance:0},Ne={scope:"title",begin:D,relevance:0},re={begin:"\\.\\s*"+D,relevance:0};var se=Object.freeze({__proto__:null,APOS_STRING_MODE:R,BACKSLASH_ESCAPE:O,BINARY_NUMBER_MODE:ae,BINARY_NUMBER_RE:U,COMMENT:X,C_BLOCK_COMMENT_MODE:B,C_LINE_COMMENT_MODE:K,C_NUMBER_MODE:$,C_NUMBER_RE:P,END_SAME_AS_BEGIN:function(Z){return Object.assign(Z,{"on:begin":(be,Ie)=>{Ie.data._beginMatch=be[1]},"on:end":(be,Ie)=>{Ie.data._beginMatch!==be[1]&&Ie.ignoreMatch()}})},HASH_COMMENT_MODE:F,IDENT_RE:M,MATCH_NOTHING_RE:j,METHOD_GUARD:re,NUMBER_MODE:W,NUMBER_RE:I,PHRASAL_WORDS_MODE:G,QUOTE_STRING_MODE:z,REGEXP_MODE:xe,RE_STARTERS_RE:q,SHEBANG:V,TITLE_MODE:le,UNDERSCORE_IDENT_RE:D,UNDERSCORE_TITLE_MODE:Ne});function Q(Z,be){Z.input[Z.index-1]==="."&&be.ignoreMatch()}function ye(Z,be){Z.className!==void 0&&(Z.scope=Z.className,delete Z.className)}function _e(Z,be){be&&Z.beginKeywords&&(Z.begin="\\b("+Z.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)",Z.__beforeBegin=Q,Z.keywords=Z.keywords||Z.beginKeywords,delete Z.beginKeywords,Z.relevance===void 0&&(Z.relevance=0))}function ze(Z,be){Array.isArray(Z.illegal)&&(Z.illegal=v(...Z.illegal))}function fe(Z,be){if(Z.match){if(Z.begin||Z.end)throw new Error("begin & end are not supported with match");Z.begin=Z.match,delete Z.match}}function Se(Z,be){Z.relevance===void 0&&(Z.relevance=1)}const Re=(Z,be)=>{if(!Z.beforeMatch)return;if(Z.starts)throw new Error("beforeMatch cannot be used with starts");const Ie=Object.assign({},Z);Object.keys(Z).forEach(ut=>{delete Z[ut]}),Z.keywords=Ie.keywords,Z.begin=w(Ie.beforeMatch,y(Ie.begin)),Z.starts={relevance:0,contains:[Object.assign(Ie,{endsParent:!0})]},Z.relevance=0,delete Ie.beforeMatch},Qe=["of","and","for","in","not","or","if","then","parent","list","value"],ht="keyword";function it(Z,be,Ie=ht){const ut=Object.create(null);return typeof Z=="string"?Yt(Ie,Z.split(" ")):Array.isArray(Z)?Yt(Ie,Z):Object.keys(Z).forEach(function(Tt){Object.assign(ut,it(Z[Tt],be,Tt))}),ut;function Yt(Tt,$e){be&&($e=$e.map(Ue=>Ue.toLowerCase())),$e.forEach(function(Ue){const ot=Ue.split("|");ut[ot[0]]=[Tt,Bt(ot[0],ot[1])]})}}function Bt(Z,be){return be?Number(be):mt(Z)?0:1}function mt(Z){return Qe.includes(Z.toLowerCase())}const wt={},Te=Z=>{console.error(Z)},ct=(Z,...be)=>{console.log(`WARN: ${Z}`,...be)},ne=(Z,be)=>{wt[`${Z}/${be}`]||(console.log(`Deprecated as of ${Z}. ${be}`),wt[`${Z}/${be}`]=!0)},we=new Error;function he(Z,be,{key:Ie}){let ut=0;const Yt=Z[Ie],Tt={},$e={};for(let Ue=1;Ue<=be.length;Ue++)$e[Ue+ut]=Yt[Ue],Tt[Ue+ut]=!0,ut+=_(be[Ue-1]);Z[Ie]=$e,Z[Ie]._emit=Tt,Z[Ie]._multi=!0}function Ve(Z){if(Array.isArray(Z.begin)){if(Z.skip||Z.excludeBegin||Z.returnBegin)throw Te("skip, excludeBegin, returnBegin not compatible with beginScope: {}"),we;if(typeof Z.beginScope!="object"||Z.beginScope===null)throw Te("beginScope must be object"),we;he(Z,Z.begin,{key:"beginScope"}),Z.begin=A(Z.begin,{joinWith:""})}}function Ze(Z){if(Array.isArray(Z.end)){if(Z.skip||Z.excludeEnd||Z.returnEnd)throw Te("skip, excludeEnd, returnEnd not compatible with endScope: {}"),we;if(typeof Z.endScope!="object"||Z.endScope===null)throw Te("endScope must be object"),we;he(Z,Z.end,{key:"endScope"}),Z.end=A(Z.end,{joinWith:""})}}function Ct(Z){Z.scope&&typeof Z.scope=="object"&&Z.scope!==null&&(Z.beginScope=Z.scope,delete Z.scope)}function Gt(Z){Ct(Z),typeof Z.beginScope=="string"&&(Z.beginScope={_wrap:Z.beginScope}),typeof Z.endScope=="string"&&(Z.endScope={_wrap:Z.endScope}),Ve(Z),Ze(Z)}function ce(Z){function be($e,Ue){return new RegExp(p($e),"m"+(Z.case_insensitive?"i":"")+(Z.unicodeRegex?"u":"")+(Ue?"g":""))}class Ie{constructor(){this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}addRule(Ue,ot){ot.position=this.position++,this.matchIndexes[this.matchAt]=ot,this.regexes.push([ot,Ue]),this.matchAt+=_(Ue)+1}compile(){this.regexes.length===0&&(this.exec=()=>null);const Ue=this.regexes.map(ot=>ot[1]);this.matcherRe=be(A(Ue,{joinWith:"|"}),!0),this.lastIndex=0}exec(Ue){this.matcherRe.lastIndex=this.lastIndex;const ot=this.matcherRe.exec(Ue);if(!ot)return null;const hn=ot.findIndex((Vi,Ys)=>Ys>0&&Vi!==void 0),Zt=this.matchIndexes[hn];return ot.splice(0,hn),Object.assign(ot,Zt)}}class ut{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(Ue){if(this.multiRegexes[Ue])return this.multiRegexes[Ue];const ot=new Ie;return this.rules.slice(Ue).forEach(([hn,Zt])=>ot.addRule(hn,Zt)),ot.compile(),this.multiRegexes[Ue]=ot,ot}resumingScanAtSamePosition(){return this.regexIndex!==0}considerAll(){this.regexIndex=0}addRule(Ue,ot){this.rules.push([Ue,ot]),ot.type==="begin"&&this.count++}exec(Ue){const ot=this.getMatcher(this.regexIndex);ot.lastIndex=this.lastIndex;let hn=ot.exec(Ue);if(this.resumingScanAtSamePosition()&&!(hn&&hn.index===this.lastIndex)){const Zt=this.getMatcher(0);Zt.lastIndex=this.lastIndex+1,hn=Zt.exec(Ue)}return hn&&(this.regexIndex+=hn.position+1,this.regexIndex===this.count&&this.considerAll()),hn}}function Yt($e){const Ue=new ut;return $e.contains.forEach(ot=>Ue.addRule(ot.begin,{rule:ot,type:"begin"})),$e.terminatorEnd&&Ue.addRule($e.terminatorEnd,{type:"end"}),$e.illegal&&Ue.addRule($e.illegal,{type:"illegal"}),Ue}function Tt($e,Ue){const ot=$e;if($e.isCompiled)return ot;[ye,fe,Gt,Re].forEach(Zt=>Zt($e,Ue)),Z.compilerExtensions.forEach(Zt=>Zt($e,Ue)),$e.__beforeBegin=null,[_e,ze,Se].forEach(Zt=>Zt($e,Ue)),$e.isCompiled=!0;let hn=null;return typeof $e.keywords=="object"&&$e.keywords.$pattern&&($e.keywords=Object.assign({},$e.keywords),hn=$e.keywords.$pattern,delete $e.keywords.$pattern),hn=hn||/\w+/,$e.keywords&&($e.keywords=it($e.keywords,Z.case_insensitive)),ot.keywordPatternRe=be(hn,!0),Ue&&($e.begin||($e.begin=/\B|\b/),ot.beginRe=be(ot.begin),!$e.end&&!$e.endsWithParent&&($e.end=/\B|\b/),$e.end&&(ot.endRe=be(ot.end)),ot.terminatorEnd=p(ot.end)||"",$e.endsWithParent&&Ue.terminatorEnd&&(ot.terminatorEnd+=($e.end?"|":"")+Ue.terminatorEnd)),$e.illegal&&(ot.illegalRe=be($e.illegal)),$e.contains||($e.contains=[]),$e.contains=[].concat(...$e.contains.map(function(Zt){return Ce(Zt==="self"?$e:Zt)})),$e.contains.forEach(function(Zt){Tt(Zt,ot)}),$e.starts&&Tt($e.starts,Ue),ot.matcher=Yt(ot),ot}if(Z.compilerExtensions||(Z.compilerExtensions=[]),Z.contains&&Z.contains.includes("self"))throw new Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");return Z.classNameAliases=i(Z.classNameAliases||{}),Tt(Z)}function pe(Z){return Z?Z.endsWithParent||pe(Z.starts):!1}function Ce(Z){return Z.variants&&!Z.cachedVariants&&(Z.cachedVariants=Z.variants.map(function(be){return i(Z,{variants:null},be)})),Z.cachedVariants?Z.cachedVariants:pe(Z)?i(Z,{starts:Z.starts?i(Z.starts):null}):Object.isFrozen(Z)?i(Z):Z}var je="11.11.1";class qe extends Error{constructor(be,Ie){super(be),this.name="HTMLInjectionError",this.html=Ie}}const st=n,Fe=i,et=Symbol("nomatch"),Qt=7,Yn=function(Z){const be=Object.create(null),Ie=Object.create(null),ut=[];let Yt=!0;const Tt="Could not find the language '{}', did you forget to load/include a language module?",$e={disableAutodetect:!0,name:"Plain text",contains:[]};let Ue={ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:"hljs-",cssSelector:"pre code",languages:null,__emitter:m};function ot(Me){return Ue.noHighlightRe.test(Me)}function hn(Me){let Ge=Me.className+" ";Ge+=Me.parentNode?Me.parentNode.className:"";const xt=Ue.languageDetectRe.exec(Ge);if(xt){const Rt=Bn(xt[1]);return Rt||(ct(Tt.replace("{}",xt[1])),ct("Falling back to no-highlight mode for this block.",Me)),Rt?xt[1]:"no-highlight"}return Ge.split(/\s+/).find(Rt=>ot(Rt)||Bn(Rt))}function Zt(Me,Ge,xt){let Rt="",on="";typeof Ge=="object"?(Rt=Me,xt=Ge.ignoreIllegals,on=Ge.language):(ne("10.7.0","highlight(lang, code, ...args) has been deprecated."),ne("10.7.0",`Please use highlight(code, options) instead.
676
676
  https://github.com/highlightjs/highlight.js/issues/2277`),on=Me,Rt=Ge),xt===void 0&&(xt=!0);const Un={code:Rt,language:on};xi("before:highlight",Un);const ei=Un.result?Un.result:Vi(Un.language,Un.code,xt);return ei.code=Un.code,xi("after:highlight",ei),ei}function Vi(Me,Ge,xt,Rt){const on=Object.create(null);function Un(Le,We){return Le.keywords[We]}function ei(){if(!tt.keywords){jn.addText($t);return}let Le=0;tt.keywordPatternRe.lastIndex=0;let We=tt.keywordPatternRe.exec($t),vt="";for(;We;){vt+=$t.substring(Le,We.index);const Dt=pt.case_insensitive?We[0].toLowerCase():We[0],Nn=Un(tt,Dt);if(Nn){const[ls,au]=Nn;if(jn.addText(vt),vt="",on[Dt]=(on[Dt]||0)+1,on[Dt]<=Qt&&(ca+=au),ls.startsWith("_"))vt+=We[0];else{const Cf=pt.classNameAliases[ls]||ls;ai(We[0],Cf)}}else vt+=We[0];Le=tt.keywordPatternRe.lastIndex,We=tt.keywordPatternRe.exec($t)}vt+=$t.substring(Le),jn.addText(vt)}function ti(){if($t==="")return;let Le=null;if(typeof tt.subLanguage=="string"){if(!be[tt.subLanguage]){jn.addText($t);return}Le=Vi(tt.subLanguage,$t,!0,la[tt.subLanguage]),la[tt.subLanguage]=Le._top}else Le=Jn($t,tt.subLanguage.length?tt.subLanguage:null);tt.relevance>0&&(ca+=Le.relevance),jn.__addSublanguage(Le._emitter,Le.language)}function Vt(){tt.subLanguage!=null?ti():ei(),$t=""}function ai(Le,We){Le!==""&&(jn.startScope(We),jn.addText(Le),jn.endScope())}function aa(Le,We){let vt=1;const Dt=We.length-1;for(;vt<=Dt;){if(!Le._emit[vt]){vt++;continue}const Nn=pt.classNameAliases[Le[vt]]||Le[vt],ls=We[vt];Nn?ai(ls,Nn):($t=ls,ei(),$t=""),vt++}}function Cs(Le,We){return Le.scope&&typeof Le.scope=="string"&&jn.openNode(pt.classNameAliases[Le.scope]||Le.scope),Le.beginScope&&(Le.beginScope._wrap?(ai($t,pt.classNameAliases[Le.beginScope._wrap]||Le.beginScope._wrap),$t=""):Le.beginScope._multi&&(aa(Le.beginScope,We),$t="")),tt=Object.create(Le,{parent:{value:tt}}),tt}function os(Le,We,vt){let Dt=k(Le.endRe,vt);if(Dt){if(Le["on:end"]){const Nn=new t(Le);Le["on:end"](We,Nn),Nn.isMatchIgnored&&(Dt=!1)}if(Dt){for(;Le.endsParent&&Le.parent;)Le=Le.parent;return Le}}if(Le.endsWithParent)return os(Le.parent,We,vt)}function Ts(Le){return tt.matcher.regexIndex===0?($t+=Le[0],1):(ua=!0,0)}function Er(Le){const We=Le[0],vt=Le.rule,Dt=new t(vt),Nn=[vt.__beforeBegin,vt["on:begin"]];for(const ls of Nn)if(ls&&(ls(Le,Dt),Dt.isMatchIgnored))return Ts(We);return vt.skip?$t+=We:(vt.excludeBegin&&($t+=We),Vt(),!vt.returnBegin&&!vt.excludeBegin&&($t=We)),Cs(vt,Le),vt.returnBegin?0:We.length}function Y(Le){const We=Le[0],vt=Ge.substring(Le.index),Dt=os(tt,Le,vt);if(!Dt)return et;const Nn=tt;tt.endScope&&tt.endScope._wrap?(Vt(),ai(We,tt.endScope._wrap)):tt.endScope&&tt.endScope._multi?(Vt(),aa(tt.endScope,Le)):Nn.skip?$t+=We:(Nn.returnEnd||Nn.excludeEnd||($t+=We),Vt(),Nn.excludeEnd&&($t=We));do tt.scope&&jn.closeNode(),!tt.skip&&!tt.subLanguage&&(ca+=tt.relevance),tt=tt.parent;while(tt!==Dt.parent);return Dt.starts&&Cs(Dt.starts,Le),Nn.returnEnd?0:We.length}function Ae(){const Le=[];for(let We=tt;We!==pt;We=We.parent)We.scope&&Le.unshift(We.scope);Le.forEach(We=>jn.openNode(We))}let Oe={};function gt(Le,We){const vt=We&&We[0];if($t+=Le,vt==null)return Vt(),0;if(Oe.type==="begin"&&We.type==="end"&&Oe.index===We.index&&vt===""){if($t+=Ge.slice(We.index,We.index+1),!Yt){const Dt=new Error(`0 width match regex (${Me})`);throw Dt.languageName=Me,Dt.badRule=Oe.rule,Dt}return 1}if(Oe=We,We.type==="begin")return Er(We);if(We.type==="illegal"&&!xt){const Dt=new Error('Illegal lexeme "'+vt+'" for mode "'+(tt.scope||"<unnamed>")+'"');throw Dt.mode=tt,Dt}else if(We.type==="end"){const Dt=Y(We);if(Dt!==et)return Dt}if(We.type==="illegal"&&vt==="")return $t+=`
677
- `,1;if(ru>1e5&&ru>We.index*3)throw new Error("potential infinite loop, way more iterations than matches");return $t+=vt,vt.length}const pt=Bn(Me);if(!pt)throw Te(Tt.replace("{}",Me)),new Error('Unknown language: "'+Me+'"');const ji=ce(pt);let oa="",tt=Rt||ji;const la={},jn=new Ue.__emitter(Ue);Ae();let $t="",ca=0,Sr=0,ru=0,ua=!1;try{if(pt.__emitTokens)pt.__emitTokens(Ge,jn);else{for(tt.matcher.considerAll();;){ru++,ua?ua=!1:tt.matcher.considerAll(),tt.matcher.lastIndex=Sr;const Le=tt.matcher.exec(Ge);if(!Le)break;const We=Ge.substring(Sr,Le.index),vt=gt(We,Le);Sr=Le.index+vt}gt(Ge.substring(Sr))}return jn.finalize(),oa=jn.toHTML(),{language:Me,value:oa,relevance:ca,illegal:!1,_emitter:jn,_top:tt}}catch(Le){if(Le.message&&Le.message.includes("Illegal"))return{language:Me,value:st(Ge),illegal:!0,relevance:0,_illegalBy:{message:Le.message,index:Sr,context:Ge.slice(Sr-100,Sr+100),mode:Le.mode,resultSoFar:oa},_emitter:jn};if(Yt)return{language:Me,value:st(Ge),illegal:!1,relevance:0,errorRaised:Le,_emitter:jn,_top:tt};throw Le}}function Ys(Me){const Ge={value:st(Me),illegal:!1,relevance:0,_top:$e,_emitter:new Ue.__emitter(Ue)};return Ge._emitter.addText(Me),Ge}function Jn(Me,Ge){Ge=Ge||Ue.languages||Object.keys(be);const xt=Ys(Me),Rt=Ge.filter(Bn).filter(In).map(Vt=>Vi(Vt,Me,!1));Rt.unshift(xt);const on=Rt.sort((Vt,ai)=>{if(Vt.relevance!==ai.relevance)return ai.relevance-Vt.relevance;if(Vt.language&&ai.language){if(Bn(Vt.language).supersetOf===ai.language)return 1;if(Bn(ai.language).supersetOf===Vt.language)return-1}return 0}),[Un,ei]=on,ti=Un;return ti.secondBest=ei,ti}function kn(Me,Ge,xt){const Rt=Ge&&Ie[Ge]||xt;Me.classList.add("hljs"),Me.classList.add(`language-${Rt}`)}function mn(Me){let Ge=null;const xt=hn(Me);if(ot(xt))return;if(xi("before:highlightElement",{el:Me,language:xt}),Me.dataset.highlighted){console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",Me);return}if(Me.children.length>0&&(Ue.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(Me)),Ue.throwUnescapedHTML))throw new qe("One of your code blocks includes unescaped HTML.",Me.innerHTML);Ge=Me;const Rt=Ge.textContent,on=xt?Zt(Rt,{language:xt,ignoreIllegals:!0}):Jn(Rt);Me.innerHTML=on.value,Me.dataset.highlighted="yes",kn(Me,xt,on.language),Me.result={language:on.language,re:on.relevance,relevance:on.relevance},on.secondBest&&(Me.secondBest={language:on.secondBest.language,relevance:on.secondBest.relevance}),xi("after:highlightElement",{el:Me,result:on,text:Rt})}function An(Me){Ue=Fe(Ue,Me)}const Ti=()=>{Qs(),ne("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")};function Xs(){Qs(),ne("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")}let wr=!1;function Qs(){function Me(){Qs()}if(document.readyState==="loading"){wr||window.addEventListener("DOMContentLoaded",Me,!1),wr=!0;return}document.querySelectorAll(Ue.cssSelector).forEach(mn)}function sa(Me,Ge){let xt=null;try{xt=Ge(Z)}catch(Rt){if(Te("Language definition for '{}' could not be registered.".replace("{}",Me)),Yt)Te(Rt);else throw Rt;xt=$e}xt.name||(xt.name=Me),be[Me]=xt,xt.rawDefinition=Ge.bind(null,Z),xt.aliases&&Ai(xt.aliases,{languageName:Me})}function _s(Me){delete be[Me];for(const Ge of Object.keys(Ie))Ie[Ge]===Me&&delete Ie[Ge]}function Zs(){return Object.keys(be)}function Bn(Me){return Me=(Me||"").toLowerCase(),be[Me]||be[Ie[Me]]}function Ai(Me,{languageName:Ge}){typeof Me=="string"&&(Me=[Me]),Me.forEach(xt=>{Ie[xt.toLowerCase()]=Ge})}function In(Me){const Ge=Bn(Me);return Ge&&!Ge.disableAutodetect}function ri(Me){Me["before:highlightBlock"]&&!Me["before:highlightElement"]&&(Me["before:highlightElement"]=Ge=>{Me["before:highlightBlock"](Object.assign({block:Ge.el},Ge))}),Me["after:highlightBlock"]&&!Me["after:highlightElement"]&&(Me["after:highlightElement"]=Ge=>{Me["after:highlightBlock"](Object.assign({block:Ge.el},Ge))})}function bn(Me){ri(Me),ut.push(Me)}function ra(Me){const Ge=ut.indexOf(Me);Ge!==-1&&ut.splice(Ge,1)}function xi(Me,Ge){const xt=Me;ut.forEach(function(Rt){Rt[xt]&&Rt[xt](Ge)})}function hi(Me){return ne("10.7.0","highlightBlock will be removed entirely in v12.0"),ne("10.7.0","Please use highlightElement now."),mn(Me)}Object.assign(Z,{highlight:Zt,highlightAuto:Jn,highlightAll:Qs,highlightElement:mn,highlightBlock:hi,configure:An,initHighlighting:Ti,initHighlightingOnLoad:Xs,registerLanguage:sa,unregisterLanguage:_s,listLanguages:Zs,getLanguage:Bn,registerAliases:Ai,autoDetection:In,inherit:Fe,addPlugin:bn,removePlugin:ra}),Z.debugMode=function(){Yt=!1},Z.safeMode=function(){Yt=!0},Z.versionString=je,Z.regex={concat:w,lookahead:y,either:v,optional:x,anyNumberOfTimes:b};for(const Me in se)typeof se[Me]=="object"&&e(se[Me]);return Object.assign(Z,se),Z},Wt=Yn({});return Wt.newInstance=()=>Yn({}),Jb=Wt,Wt.HighlightJS=Wt,Wt.default=Wt,Jb}var eW=JG();const tW=nf(eW),b2={},nW="hljs-";function iW(e){const t=tW.newInstance();return e&&a(e),{highlight:n,highlightAuto:i,listLanguages:s,register:a,registerAlias:o,registered:c};function n(u,f,m){const p=m||b2,y=typeof p.prefix=="string"?p.prefix:nW;if(!t.getLanguage(u))throw new Error("Unknown language: `"+u+"` is not registered");t.configure({__emitter:sW,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,w=x.data;return w.language=b.language,w.relevance=b.relevance,x}function i(u,f){const p=(f||b2).subset||s();let y=-1,b=0,x;for(;++y<p.length;){const w=p[y];if(!t.getLanguage(w))continue;const E=n(w,u,f);E.data&&E.data.relevance!==void 0&&E.data.relevance>b&&(b=E.data.relevance,x=E)}return x||{type:"root",children:[],data:{language:void 0,relevance:b}}}function s(){return t.listLanguages()}function a(u,f){if(typeof u=="string")t.registerLanguage(u,f);else{let m;for(m in u)Object.hasOwn(u,m)&&t.registerLanguage(m,u[m])}}function o(u,f){if(typeof u=="string")t.registerAliases(typeof f=="string"?f:[...f],{languageName:u});else{let m;for(m in u)if(Object.hasOwn(u,m)){const p=u[m];t.registerAliases(typeof p=="string"?p:[...p],{languageName:m})}}}function c(u){return!!t.getLanguage(u)}}class sW{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],a={type:"element",tagName:"span",properties:{className:i},children:[]};s.children.push(a),this.stack.push(a)}closeNode(){this.stack.pop()}finalize(){}toHTML(){return""}}const rW={};function b1(e){const t=e||rW,n=t.aliases,i=t.detect||!1,s=t.languages||ZG,a=t.plainText,o=t.prefix,c=t.subset;let u="hljs";const f=iW(s);if(n&&f.registerAlias(n),o){const m=o.indexOf("-");u=m===-1?o:o.slice(0,m)}return function(m,p){Pm(m,"element",function(y,b,x){if(y.tagName!=="code"||!x||x.type!=="element"||x.tagName!=="pre")return;const w=aW(y);if(w===!1||!w&&!i||w&&a&&a.includes(w))return;Array.isArray(y.properties.className)||(y.properties.className=[]),y.properties.className.includes(u)||y.properties.className.unshift(u);const E=N7(y,{whitespace:"pre"});let v;try{v=w?f.highlight(w,E,{prefix:o}):f.highlightAuto(E,{prefix:o,subset:c})}catch(_){const k=_;if(w&&/Unknown language/.test(k.message)){p.message("Cannot highlight as `"+w+"`, it’s not registered",{ancestors:[x,y],cause:k,place:y.position,ruleId:"missing-language",source:"rehype-highlight"});return}throw k}!w&&v.data&&v.data.language&&y.properties.className.push("language-"+v.data.language),v.children.length>0&&(y.children=v.children)})}}function aW(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 NR({text:e}){return e?d.jsx("div",{className:"prose-chat text-sm break-words font-[family-name:var(--font-body)]",children:d.jsx(d1,{remarkPlugins:[m1],rehypePlugins:[b1],children:e})}):null}function oW(){return _t("/api/chat/sessions")}function kp(e){return _t(`/api/chat/sessions/${e}`)}async function _R(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 lW(e){const t=await fetch(`/api/chat/sessions/${e}`,{method:"DELETE"});if(!t.ok)throw new Error(`${t.status}`)}async function x2(e,t,n){const i=await fetch(`/api/chat/sessions/${e}/messages`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:t,attachments:n})});if(!i.ok)throw new Error(`${i.status}: ${await i.text()}`);return await i.json()}async function CR(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 TR(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 cW(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 uW(e,t){const n=t?`?since=${encodeURIComponent(t)}`:"";return _t(`/api/chat/sessions/${e}/messages${n}`)}function AR(e){const t=e?`?path=${encodeURIComponent(e)}`:"";return _t(`/api/fs/browse${t}`)}async function dW(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 jR=50*1024*1024;async function v2(e,t){if(t.size>jR)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 zm(e,t){return`/api/fs/file?${new URLSearchParams({path:t,sessionId:e}).toString()}`}function fW(e){return/\.(png|jpe?g|gif|webp|svg|bmp|avif)$/i.test(e)}function MR(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&&fW(s)?s:null}function hW(e,t){const n=[];for(const i of e){if(i.type!=="tool_use")continue;const s=MR(i,t);s&&!n.includes(s)&&n.push(s)}return n}function pW({sessionId:e,path:t,onPreview:n}){return 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:zm(e,t),alt:"生成的图片",className:"block max-h-96 max-w-full object-contain",loading:"lazy"})})}function mW({sessionId:e,path:t,onClose:n}){return C.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:zm(e,t),alt:"预览",className:"max-w-full max-h-[85vh] object-contain",onClick:i=>i.stopPropagation()})})}function gW(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 yW({tool:e,live:t}){const[n,i]=C.useState(!1),s=e.status==="completed"||e.status==="complete",a=e.status==="failed",o=e.status==="interrupted"||!s&&!a&&!t,c=!s&&!a&&!o,u=gW(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(m=>!m),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(lf,{size:12,strokeWidth:3,className:["transition-transform flex-shrink-0",n?"rotate-90":""].join(" ")}),d.jsx(Uj,{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(lt,{size:12,strokeWidth:3,className:"animate-spin text-[var(--color-running)] flex-shrink-0"}),s&&d.jsx(Kp,{size:12,strokeWidth:2.5,className:"text-[var(--color-running)] flex-shrink-0"}),a&&d.jsx(_j,{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 bW({interaction:e,sessionId:t,onOpenForm:n}){const i=e.schema&&typeof e.schema=="object"&&!Array.isArray(e.schema)?e.schema:{},s=i.properties??{},a=new Set(i.required??[]),[o,c]=C.useState(()=>Object.fromEntries(Object.entries(s).filter(([,_])=>_.default!==void 0).map(([_,k])=>[_,k.default]))),[u,f]=C.useState(e.status==="pending"?"idle":e.status),[m,p]=C.useState(""),y=u==="answered"||u==="cancelled"||e.status!=="pending",b=e.kind==="form"&&!!n,x=u==="cancelled"||e.status==="cancelled",w=_=>{const k={...o};_!==void 0&&(k.approved=_);for(const[T,A]of Object.entries(s))A.type==="number"&&typeof k[T]=="string"&&(k[T]=Number(k[T]));return k},E=async _=>{if(!t||y)return;p("");const k=w(_),T=[...a].filter(A=>k[A]===void 0||k[A]===null||k[A]==="");if(T.length>0){p(`请填写:${T.map(A=>{var j;return((j=s[A])==null?void 0:j.title)??A}).join("、")}`);return}f("submitting");try{await TR(t,e.id,k,e.revision),f("answered")}catch(A){f("idle"),p(A instanceof Error?A.message:String(A))}},v=async()=>{if(!(!t||y)){p(""),f("cancelling");try{await cW(t,e.id,e.revision),f("cancelled")}catch(_){f("idle"),p(_ instanceof Error?_.message:String(_))}}};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(d6,{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(([_,k])=>{const T=k.title??_,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,a.has(_)?" *":""]}),Array.isArray(k.enum)?d.jsxs("select",{className:A,value:String(o[_]??""),onChange:j=>c(M=>({...M,[_]:j.target.value})),children:[d.jsx("option",{value:"",children:"请选择"}),k.enum.map(j=>d.jsx("option",{value:String(j),children:String(j)},String(j)))]}):k.type==="boolean"?d.jsx("input",{type:"checkbox",checked:o[_]===!0,onChange:j=>c(M=>({...M,[_]:j.target.checked}))}):k.format==="textarea"?d.jsx("textarea",{className:A,rows:4,value:String(o[_]??""),onChange:j=>c(M=>({...M,[_]:j.target.value}))}):d.jsx("input",{className:A,type:k.type==="number"?"number":"text",value:String(o[_]??""),onChange:j=>c(M=>({...M,[_]:j.target.value}))})]},_)})}),!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(k=>({...k,reason:_.target.value}))})]}),m&&d.jsx("p",{className:"text-xs text-[var(--color-crashed)]",children:m}),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 E(!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 E(!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 E(),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 v(),children:"取消任务"}),(u==="submitting"||u==="cancelling")&&d.jsx(lt,{size:14,className:"animate-spin self-center"})]})]})}function RR({text:e}){const[t,n]=C.useState(""),i=C.useRef(e);return i.current=e,C.useEffect(()=>{n(s=>e.startsWith(s)?s:"")},[e]),C.useEffect(()=>{const s=window.setInterval(()=>{n(a=>{const o=i.current;if(a.length>=o.length)return a;const c=Math.max(1,Math.ceil((o.length-a.length)/8));return o.slice(0,a.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 xW({block:e,streaming:t,sessionId:n,onOpenForm:i}){return e.type==="text"?t?d.jsx(RR,{text:e.text}):d.jsx(NR,{text:e.text}):e.type==="interaction"?d.jsx(bW,{interaction:e,sessionId:n,onOpenForm:i}):d.jsx(yW,{tool:e,live:t===!0})}const ex={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 vW(e){return e.default!==void 0?e.default:e.type==="multiselect"||e.type==="checkbox"?[]:e.type==="toggle"?!1:e.type==="number"||e.type==="slider"?e.min??0:""}function wW({spec:e,onSubmit:t,onSkip:n,onUpload:i,disabled:s,initialValues:a}){const[o,c]=C.useState(()=>Object.fromEntries(e.fields.map(j=>[j.id,a&&j.id in a?a[j.id]:vW(j)]))),[u,f]=C.useState(!1),[m,p]=C.useState(!1),[y,b]=C.useState(!1),x=s||y,w=(j,M)=>c(D=>({...D,[j]:M})),{basic:E,advanced:v}=C.useMemo(()=>({basic:e.fields.filter(j=>!j.advanced),advanced:e.fields.filter(j=>j.advanced)}),[e.fields]),_=()=>e.fields.filter(j=>j.required&&(o[j.id]===""||o[j.id]==null||Array.isArray(o[j.id])&&o[j.id].length===0)),k=()=>{if(x)return;if(_().length){p(!0);return}t(o),p(!0),b(!0)},T=()=>{x||(n(),b(!0))},A=j=>{const M=new Map;for(const D of j){const I=D.group??"";(M.get(I)??M.set(I,[]).get(I)).push(D)}return[...M.entries()]};return d.jsxs("div",{className:["nb-card flex flex-col gap-3 max-w-lg",x?"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,y&&" ✓"]}),e.description&&d.jsx("div",{className:"text-xs text-[var(--color-text-muted)] mt-0.5",children:e.description})]}),A(E).map(([j,M])=>d.jsx(w2,{name:j,fields:M,values:o,set:w,showErr:m,onUpload:i},j||"default")),v.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:()=>f(j=>!j),children:[u?d.jsx(so,{size:14}):d.jsx(lf,{size:14})," 高级选项"]}),u&&d.jsx("div",{className:"mt-2 flex flex-col gap-3",children:A(v).map(([j,M])=>d.jsx(w2,{name:j,fields:M,values:o,set:w,showErr:m,onUpload:i},j||"adv"))})]}),d.jsxs("div",{className:"flex gap-2 justify-end pt-1",children:[d.jsxs("button",{type:"button",className:"nb-btn text-xs",onClick:T,disabled:x,children:[d.jsx(il,{size:13,strokeWidth:2.5})," ",e.skipLabel??"让 AI 来填"]}),d.jsx("button",{type:"button",className:"nb-btn nb-btn-primary text-xs",onClick:k,disabled:x,children:e.submitLabel??"提交"})]})]})}function w2({name:e,fields:t,values:n,set:i,showErr:s,onUpload:a}){return d.jsxs("div",{className:"flex flex-col gap-3",children:[e&&d.jsx("div",{className:"text-xs font-bold text-[var(--color-text-muted)] uppercase tracking-wide",children:e}),t.map(o=>d.jsx(EW,{f:o,value:n[o.id],set:i,showErr:s,onUpload:a},o.id))]})}function EW({f:e,value:t,set:n,showErr:i,onUpload:s}){const[a,o]=C.useState(!1),c=async p=>{if(!(!p||!s)){o(!0);try{n(e.id,await s(p))}catch{}finally{o(!1)}}},u=i&&e.required&&(t===""||t==null||Array.isArray(t)&&t.length===0),f=Array.isArray(t)?t:[],m=p=>n(e.id,f.includes(p)?f.filter(y=>y!==p):[...f,p]);return d.jsxs("label",{className:"flex flex-col gap-1",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:p=>n(e.id,p.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:p=>n(e.id,p.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:p=>n(e.id,p.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:p=>n(e.id,p.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:p=>n(e.id,p.target.value),children:(e.options??[]).map(p=>d.jsx("option",{value:p.value,children:p.label},p.value))}),e.type==="radio"&&d.jsx("div",{className:"flex flex-wrap gap-2",children:(e.options??[]).map(p=>d.jsx("button",{type:"button",onClick:()=>n(e.id,p.value),className:["px-3 py-1.5 rounded-lg border-2 text-sm transition-all",t===p.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:p.label},p.value))}),(e.type==="multiselect"||e.type==="checkbox")&&d.jsx("div",{className:"flex flex-wrap gap-2",children:(e.options??[]).map(p=>d.jsx("button",{type:"button",onClick:()=>m(p.value),className:["px-3 py-1.5 rounded-lg border-2 text-sm transition-all",f.includes(p.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:p.label},p.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:p=>n(e.id,p.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:p=>n(e.id,p.target.value)}),(e.type==="image-ref"||e.type==="file")&&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:[a?"上传中…":t?"重新选择":"选择文件",d.jsx("input",{type:"file",className:"hidden",accept:e.accept??(e.type==="image-ref"?"image/*":void 0),onChange:p=>{var y;c((y=p.target.files)==null?void 0:y[0]),p.target.value=""},disabled:a})]}),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:p=>n(e.id,p.target.value)})]}),e.hint&&d.jsx("span",{className:"text-xs text-[var(--color-text-muted)]",children:e.hint}),u&&d.jsx("span",{className:"text-xs text-[var(--color-crashed)]",children:"必填"})]})}function tx(){if(!(typeof window>"u"))return window.SpeechRecognition??window.webkitSpeechRecognition}function SW({onComplete:e,onError:t}){const[n,i]=C.useState(!1),[s,a]=C.useState(""),o=C.useRef(null),c=C.useRef(""),u=C.useRef(""),f=C.useRef(0),m=C.useRef(!1),p=C.useRef(!1),y=C.useRef(null),b=C.useRef(e),x=C.useRef(t);b.current=e,x.current=t;const w=C.useCallback(()=>{y.current!==null&&(window.clearTimeout(y.current),y.current=null)},[]),E=C.useCallback(()=>{i(!1);const A=u.current.trim();c.current="",u.current="",A?b.current(A):x.current("no-speech")},[]),v=C.useCallback(()=>{f.current+=1,m.current=!1,p.current=!0,w();const A=o.current;o.current=null,A==null||A.abort(),c.current="",u.current="",a(""),i(!1)},[w]),_=C.useCallback(A=>{const j=tx();if(!j||A!==f.current||!m.current)return!1;const M=new j;M.continuous=!0,M.interimResults=!0,M.lang=navigator.language||"zh-CN",M.onresult=D=>{var P;if(A!==f.current)return;let I="";for(let U=D.resultIndex;U<D.results.length;U+=1){const q=D.results[U],V=((P=q==null?void 0:q[0])==null?void 0:P.transcript.trim())??"";q!=null&&q.isFinal&&V?c.current=`${c.current} ${V}`.trim():V&&(I+=` ${V}`)}u.current=`${c.current}${I}`.trim(),a(u.current)},M.onerror=D=>{A===f.current&&(D.error==="no-speech"||D.error==="aborted"||D.error==="network"||(m.current=!1,p.current=!0,i(!1),x.current(D.error)))},M.onend=()=>{if(A===f.current){if(o.current===M&&(o.current=null),p.current){p.current=!1;return}if(!m.current){E();return}i(!0),w(),y.current=window.setTimeout(()=>{y.current=null,_(A)},180)}},o.current=M;try{return M.start(),i(!0),!0}catch{return o.current=null,m.current=!1,i(!1),x.current("start-failed"),!1}},[w,E]),k=C.useCallback(()=>{m.current=!1,w();const A=o.current;A?A.stop():E()},[w,E]),T=C.useCallback(()=>{if(!tx())return x.current("unsupported"),!1;v();const j=f.current;return m.current=!0,p.current=!1,c.current="",u.current="",a(""),_(j)},[v,_]);return C.useEffect(()=>v,[v]),{cancel:v,isListening:n,start:T,stop:k,supported:!!tx(),transcript:s}}function kW(){const[e,t]=C.useState("inactive"),[n,i]=C.useState(null),s=C.useRef(null),a=C.useRef(null),o=C.useRef(0),c=C.useCallback(()=>{var f,m;o.current+=1,(f=a.current)==null||f.getTracks().forEach(p=>p.stop()),a.current=null,(m=s.current)==null||m.close(),s.current=null,i(null),t("inactive")},[]),u=C.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 m=null,p=null;try{if(m=await navigator.mediaDevices.getUserMedia({audio:{autoGainControl:!0,echoCancellation:!0,noiseSuppression:!0}}),f!==o.current){m.getTracks().forEach(w=>w.stop());return}if(p=new AudioContext,p.state==="suspended"&&await p.resume(),f!==o.current){m.getTracks().forEach(w=>w.stop()),p.close();return}const b=p.createMediaStreamSource(m),x=p.createAnalyser();x.fftSize=2048,x.smoothingTimeConstant=.72,b.connect(x),a.current=m,s.current=p,i(x),t("active")}catch{m==null||m.getTracks().forEach(b=>b.stop()),p==null||p.close(),f===o.current&&t("denied")}},[c]);return C.useEffect(()=>c,[c]),{analyser:n,start:u,status:e,stop:c}}const NW=.12,E2=1e3,_W=1e4,CW=150;function TW(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 AW(e){const{enabled:t,phase:n,suspended:i,analyser:s,silenceMs:a=2e3}=e,o=C.useRef(e);o.current=e;const c=C.useRef(0),u=C.useRef(0),f=C.useRef(0),m=C.useRef(0),p=C.useRef("");C.useEffect(()=>{const y=Date.now();n==="idle"?c.current=y+E2:n==="listening"&&(u.current=y,m.current=y,f.current=y,p.current="")},[n]),C.useEffect(()=>{if(!(n==="listening"||t&&n==="idle"))return;const y={bytes:new Uint8Array(new ArrayBuffer(0))},b=window.setInterval(()=>{const x=o.current,w=Date.now();if(document.hidden)return;if((x.analyser?TW(x.analyser,y):0)>NW&&(f.current=w),x.phase==="idle"){if(!x.enabled||x.suspended||w<c.current)return;x.transcript.trim().length>0&&(c.current=w+E2,x.onTrigger());return}x.transcript!==p.current&&(p.current=x.transcript,m.current=w);const v=w-Math.max(m.current,f.current);x.transcript.trim()?v>=(x.silenceMs??2e3)&&x.onEndpoint():w-u.current>=_W&&x.onAbort()},CW);return()=>window.clearInterval(b)},[t,n,i,s,a])}function S2({checked:e,onChange:t,onIcon:n,offIcon:i,title:s,ariaLabel:a}){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":a}),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 jW(e){return e.type==="text"?{type:"text",target:e.text,displayed:e.text}:{...e}}function MW(e,t){var y;const n=tn(),[i,s]=C.useState(null),[a,o]=C.useState(!1),c=C.useRef(t);c.current=t;const u=at({queryKey:["chat-session",e],queryFn:()=>kp(e??""),enabled:!!e,refetchInterval:(t==null?void 0:t.pollMs)===0?!1:(t==null?void 0:t.pollMs)??4e3});C.useEffect(()=>{if(!e)return;const b=new EventSource(`/stream/chat/${encodeURIComponent(e)}`);let x=!0;return b.addEventListener("open",()=>{if(x){x=!1;return}const w=n.getQueryData(["chat-session",e]),E=w!=null&&w.messages.length?w.messages[w.messages.length-1].ts:void 0;uW(e,E).then(v=>{v.data.length!==0&&n.setQueryData(["chat-session",e],_=>{if(!_)return _;const k=new Set(_.messages.map(A=>A.id)),T=v.data.filter(A=>!k.has(A.id));return T.length===0?_:{..._,messages:[..._.messages,...T],lastMessageAt:T[T.length-1].ts,messageCount:_.messageCount+T.length}})}).catch(()=>{})}),b.addEventListener("chat.message",w=>{try{const E=JSON.parse(w.data);n.setQueryData(["chat-session",e],v=>{if(!v||v.messages.some(k=>k.id===E.message.id))return v;const _=v.messages.findIndex(k=>k.role==="user"&&k.id.startsWith("optim-")&&k.content===E.message.content);if(_>=0){const k=[...v.messages];return k[_]=E.message,{...v,messages:k}}return{...v,messages:[...v.messages,E.message]}})}catch{}}),b.addEventListener("chat.message.pending",w=>{var E,v;try{const _=JSON.parse(w.data);s({sessionId:e,id:_.assistantId,blocks:[],done:!1,finalMessage:null}),(v=(E=c.current)==null?void 0:E.onTurnStart)==null||v.call(E)}catch{}}),b.addEventListener("chat.message.snapshot",w=>{try{const E=JSON.parse(w.data);s({sessionId:e,id:E.assistantId,blocks:E.blocks.map(jW),done:!1,finalMessage:null})}catch{}}),b.addEventListener("chat.message.chunk.text",w=>{var E,v;try{const _=JSON.parse(w.data);s(k=>{const T=k&&k.id===_.assistantId?k:{sessionId:e,id:_.assistantId,blocks:[],done:!1,finalMessage:null},A=[...T.blocks],j=A[A.length-1];return j&&j.type==="text"?A[A.length-1]={...j,target:j.target+_.text}:A.push({type:"text",target:_.text,displayed:""}),{...T,blocks:A}}),(v=(E=c.current)==null?void 0:E.onAssistantChunk)==null||v.call(E,_.text)}catch{}}),b.addEventListener("chat.message.chunk.tool_use",w=>{try{const E=JSON.parse(w.data);s(v=>{const _=v&&v.id===E.assistantId?v:{sessionId:e,id:E.assistantId,blocks:[],done:!1,finalMessage:null};return{..._,blocks:[..._.blocks,{type:"tool_use",id:E.id,title:E.title,kind:E.kind,status:E.status,input:E.input,locations:E.locations}]}})}catch{}}),b.addEventListener("chat.message.chunk.tool_update",w=>{try{const E=JSON.parse(w.data);s(v=>!v||v.id!==E.assistantId?v:{...v,blocks:v.blocks.map(_=>_.type==="tool_use"&&_.id===E.id?{..._,status:E.status,input:_.input??E.input,locations:_.locations??E.locations}:_)})}catch{}}),b.addEventListener("chat.message.chunk.interaction",w=>{try{const E=JSON.parse(w.data);s(v=>{const _=v&&v.id===E.assistantId?v:{sessionId:e,id:E.assistantId,blocks:[],done:!1,finalMessage:null};return{..._,blocks:[..._.blocks,{type:"interaction",id:E.id,kind:E.kind,title:E.title,schema:E.schema,revision:E.revision,status:E.status}]}})}catch{}}),b.addEventListener("chat.message.interaction.updated",w=>{try{const E=JSON.parse(w.data);n.setQueryData(["chat-session",e],v=>v&&{...v,messages:v.messages.map(_=>{var k;return{..._,blocks:(k=_.blocks)==null?void 0:k.map(T=>T.type==="interaction"&&T.id===E.interactionId?{...T,status:E.status,revision:E.revision,answer:E.answer}:T)}})})}catch{}}),b.addEventListener("chat.message.complete",w=>{try{const E=JSON.parse(w.data);s(v=>({...v&&v.id===E.assistantId?v:{sessionId:e,id:E.assistantId,blocks:[],done:!1,finalMessage:null},done:!0,finalMessage:E.message}))}catch{}}),b.addEventListener("chat.message.error",w=>{var E,v;try{const _=JSON.parse(w.data);s(T=>T&&T.sessionId===e&&(!_.assistantId||T.id===_.assistantId||T.id===_.turnId)?null:T),o(!1);const k=_.message;k&&n.setQueryData(["chat-session",e],T=>!T||T.messages.some(A=>A.id===k.id)?T:{...T,messages:[...T.messages,k],lastMessageAt:k.ts,messageCount:T.messageCount+1}),(v=(E=c.current)==null?void 0:E.onError)==null||v.call(E,k??null)}catch{}}),()=>b.close()},[e,n]),C.useEffect(()=>{o(!1)},[e]),C.useEffect(()=>{var w,E;if(!i||i.sessionId!==e)return;const b=i.blocks.reduce((v,_)=>_.type==="text"?v+(_.target.length-_.displayed.length):v,0);if(b<=0){if(i.done&&i.finalMessage){const v=i.finalMessage;n.setQueryData(["chat-session",e],_=>!_||_.messages.some(k=>k.id===v.id)?_:{..._,messages:[..._.messages,v],lastMessageAt:v.ts,messageCount:_.messageCount+1}),n.invalidateQueries({queryKey:["chat-sessions"]}),n.invalidateQueries({queryKey:["chat-session",e]}),s(null),o(!1),(E=(w=c.current)==null?void 0:w.onAssistantComplete)==null||E.call(w,v)}return}const x=setTimeout(()=>{s(v=>{if(!v)return v;let _=Math.max(1,Math.ceil(b/40));const k=v.blocks.map(T=>{if(T.type!=="text"||_<=0)return T;const A=T.target.length-T.displayed.length;if(A<=0)return T;const j=Math.min(A,_);return _-=j,{...T,displayed:T.target.slice(0,T.displayed.length+j)}});return{...v,blocks:k}})},25);return()=>clearTimeout(x)},[i,n,e]);const f=C.useCallback(async(b,x)=>{var _,k,T,A;if(a)return;let w=e;if(!w&&(w=await((k=(_=c.current)==null?void 0:_.ensureSessionId)==null?void 0:k.call(_))??null,!w))return;const E=x&&x.length>0?x:void 0,v={id:`optim-${Date.now()}`,role:"user",content:b,ts:new Date().toISOString(),status:"complete",...E?{attachments:E}:{}};n.setQueryData(["chat-session",w],j=>j?{...j,messages:[...j.messages,v],lastMessageAt:v.ts,messageCount:j.messageCount+1}:{id:w,createdAt:v.ts,lastMessageAt:v.ts,title:b.slice(0,60)||"…",project:null,messageCount:1,messages:[v]}),o(!0),(A=(T=c.current)==null?void 0:T.onTurnStart)==null||A.call(T);try{await(E?x2(w,b,E):x2(w,b))}catch(j){throw o(!1),j}},[a,e,n]),m=C.useCallback(async()=>{e&&await CR(e)},[e]),p=i&&i.sessionId===e?i:null;return{detail:u.data??null,messages:((y=u.data)==null?void 0:y.messages)??[],isLoading:u.isLoading,activePending:p,sending:a,send:f,interrupt:m}}function RW(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 DW(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 OW(e){const[t,n]=C.useState(null),i=C.useRef(null),s=C.useRef(e);s.current=e;const a=C.useCallback(y=>{i.current=y,n(y)},[]),o=C.useCallback(async()=>{if(i.current)return i.current;const y=await _R({title:"Voice conversation",dedicated:!0});return a(y.id),y.id},[a]),c=MW(t,{ensureSessionId:o,onAssistantChunk:y=>s.current.onAssistantChunk(y),onAssistantComplete:y=>s.current.onAssistantComplete(y.content),onTurnStart:()=>s.current.onThinking(),onError:y=>s.current.onError(new Error((y==null?void 0:y.content)??"Response failed"))}),u=C.useMemo(()=>{const y=c.activePending,b=c.messages.filter(x=>y?x.id===y.id||y.finalMessage&&x.id===y.finalMessage.id?!1:x.status!=="streaming":!0).map(RW);return y?[...b,DW(y)]:b},[c.messages,c.activePending]),f=C.useCallback(async(y,b)=>{try{await c.send(y,b)}catch(x){s.current.onError(x instanceof Error?x:new Error(String(x)))}},[c]),m=C.useCallback((y,b)=>{a(y)},[a]),p=C.useCallback(()=>{a(null)},[a]);return{isSending:c.sending,messages:u,send:f,sessionId:t,resume:m,reset:p,ensureSession:o}}function x1(){return _t("/api/providers")}function DR(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 OR=DR;async function LW(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 IW(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 PW({title:e,body:t,confirm:n,cancel:i,onConfirm:s,onCancel:a,danger:o}){const c=Xe();return C.useEffect(()=>{const u=f=>{f.key==="Escape"&&a()};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[a]),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:a,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 LR=C.createContext(null);function zW({children:e}){const t=Xe(),[n,i]=C.useState(null),s=C.useCallback(c=>new Promise(u=>{i({kind:"confirm",opts:c,resolve:f=>{i(null),u(f)}})}),[]),a=C.useCallback(c=>new Promise(u=>{i({kind:"alert",opts:c,resolve:()=>{i(null),u()}})}),[]),o=C.useCallback(c=>new Promise(u=>{i({kind:"prompt",opts:c,resolve:f=>{i(null),u(f)}})}),[]);return d.jsxs(LR.Provider,{value:{confirm:s,alert:a,prompt:o},children:[e,(n==null?void 0:n.kind)==="confirm"&&d.jsx(PW,{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(BW,{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(UW,{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 Ln(){const e=C.useContext(LR);if(!e)throw new Error("useDialog must be used inside <DialogProvider>");return e}function BW({title:e,body:t,confirm:n,onClose:i}){return C.useEffect(()=>{const s=a=>{(a.key==="Escape"||a.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 UW({title:e,body:t,placeholder:n,defaultValue:i,confirm:s,cancel:a,onConfirm:o,onCancel:c}){const[u,f]=C.useState(i??""),m=C.useRef(null);C.useEffect(()=>{var b,x;(b=m.current)==null||b.focus(),(x=m.current)==null||x.select();const y=w=>{w.key==="Escape"&&c()};return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[c]);const p=()=>{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:m,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(),p())}}),d.jsxs("div",{className:"flex gap-3 justify-end",children:[d.jsx("button",{className:"nb-btn",onClick:c,type:"button",children:a}),d.jsx("button",{className:"nb-btn nb-btn-primary",onClick:p,type:"button",disabled:!u.trim(),children:s})]})]})})}function v1({initialPath:e,onCancel:t,onSelect:n,title:i,mode:s="directory"}){var _,k,T;const a=Xe(),{prompt:o,alert:c}=Ln(),u=i??a("dirPicker.title.default"),[f,m]=C.useState(e??null),[p,y]=C.useState(null),b=at({queryKey:["fs-browse",f],queryFn:()=>AR(f??void 0),staleTime:0,gcTime:0}),x=((_=b.data)==null?void 0:_.path)??f??"",w=((k=b.data)==null?void 0:k.parent)??null,E=((T=b.data)==null?void 0:T.home)??null,v=async()=>{var j;if(!x)return;const A=(j=await o({title:a("dirPicker.newDir"),body:a("dirPicker.newDir.prompt"),placeholder:a("dirPicker.newDir.placeholder"),confirm:a("dirPicker.newDir.create")}))==null?void 0:j.trim();if(A)try{const M=await dW(x,A);m(M.path)}catch(M){c({title:a("dirPicker.newDir.error.title"),body:M instanceof Error?M.message:String(M)})}};return C.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":a("dirPicker.close.aria"),children:d.jsx(vn,{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:()=>w&&m(w),disabled:!w||b.isLoading,"aria-label":a("dirPicker.up.aria"),title:a("dirPicker.up.title"),children:d.jsx(AB,{size:12,strokeWidth:3})}),d.jsx("button",{type:"button",className:"nb-btn flex-shrink-0",style:{padding:"4px 10px",fontSize:12},onClick:()=>E&&m(E),disabled:!E||b.isLoading,"aria-label":a("dirPicker.home.aria"),title:a("dirPicker.home.title"),children:d.jsx(Mj,{size:12,strokeWidth:3})}),d.jsx("button",{type:"button",className:"nb-btn flex-shrink-0",style:{padding:"4px 10px",fontSize:12},onClick:()=>void v(),disabled:!x||b.isLoading||b.isError,"aria-label":a("dirPicker.newDir.aria"),title:a("dirPicker.newDir.aria"),children:d.jsx(uU,{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(lt,{size:16,strokeWidth:3,className:"animate-spin mr-2"}),a("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:a("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:a("dirPicker.empty")}),b.data.entries.map(A=>{const j=(()=>{const I=x.endsWith("/")||x.endsWith("\\")?"":"/";return`${x}${I}${A.name}`})(),M=s==="file"&&p===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),m(j)):s==="file"&&y(j)},onDoubleClick:()=>{s==="file"&&!A.isDirectory&&n(j)},title:A.isDirectory?a("dirPicker.enter.aria",{name:A.name}):s==="file"?a("dirPicker.pickFile.aria",{name:A.name}):a("dirPicker.fileLocked"),children:[A.isDirectory?d.jsx(jj,{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(lf,{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:a("dirPicker.cancel")}),s==="file"?d.jsxs("button",{type:"button",className:"nb-btn nb-btn-primary",onClick:()=>p&&n(p),disabled:!p||b.isLoading||b.isError,title:p??a("dirPicker.useFile.tooltip.empty"),children:[d.jsx(Kp,{size:14,strokeWidth:3}),a("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(Kp,{size:14,strokeWidth:3}),a("dirPicker.useDir")]})]})]})})}function FW({onCancel:e,onCreate:t}){var A,j;const n=Xe(),[i,s]=C.useState(""),[a,o]=C.useState(""),[c,u]=C.useState("claude"),[f,m]=C.useState(""),[p,y]=C.useState(!1),[b,x]=C.useState(!1),[w,E]=C.useState(!1),v=at({queryKey:["providers"],queryFn:x1}),_=at({queryKey:["system-agents"],queryFn:Xv}),k=OR((c==="openai"?(A=v.data)==null?void 0:A.openai:(j=v.data)==null?void 0:j.anthropic)??[]);C.useEffect(()=>{m(""),y(!1)},[c]),C.useEffect(()=>{var I;if(p)return;const M=(I=_.data)==null?void 0:I.agents.worker;if(!M)return;const D=`${M.providerId||"official"}::${M.model}`;k.some(P=>`${P.providerId}::${P.model}`===D)&&m(D)},[_.data,k,p]),C.useEffect(()=>{if(w)return;const M=D=>{D.key==="Escape"&&(D.preventDefault(),e())};return window.addEventListener("keydown",M),()=>window.removeEventListener("keydown",M)},[e,w]);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:a.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(vn,{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),m(M.target.value)},children:[d.jsx("option",{value:"",children:n("chat.newSession.field.model.default")}),k.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:a,onChange:M=>o(M.target.value)}),d.jsxs("button",{type:"button",className:"nb-btn flex-shrink-0",onClick:()=>E(!0),"aria-label":n("chat.newSession.field.cwd.browseAria"),title:n("chat.newSession.field.cwd.browseAria"),children:[d.jsx(qv,{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(jj,{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(lt,{size:14,strokeWidth:3,className:"animate-spin"}):d.jsx(Gn,{size:14,strokeWidth:3}),n("chat.newSession.create")]})]})]})]}),w&&d.jsx(v1,{initialPath:a.trim()||void 0,onCancel:()=>E(!1),onSelect:M=>{o(M),E(!1)}})]})}const IR=C.createContext({});function $W(e){const t=C.useRef(null);return t.current===null&&(t.current=e()),t.current}const qW=typeof window<"u",HW=qW?C.useLayoutEffect:C.useEffect,w1=C.createContext(null);function E1(e,t){e.indexOf(t)===-1&&e.push(t)}function tm(e,t){const n=e.indexOf(t);n>-1&&e.splice(n,1)}const gr=(e,t,n)=>n>t?t:n<e?e:n;let S1=()=>{};const to={},PR=e=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(e),zR=e=>typeof e=="object"&&e!==null,BR=e=>/^0[^.\s]+$/u.test(e);function UR(e){let t;return()=>(t===void 0&&(t=e()),t)}const ws=e=>e,pf=(...e)=>e.reduce((t,n)=>i=>n(t(i))),Dd=(e,t,n)=>{const i=t-e;return i?(n-e)/i:1};class k1{constructor(){this.subscriptions=[]}add(t){return E1(this.subscriptions,t),()=>tm(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 a=0;a<s;a++){const o=this.subscriptions[a];o&&o(t,n,i)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}}const ss=e=>e*1e3,vs=e=>e/1e3,FR=(e,t)=>t?e*(1e3/t):0,$R=(e,t,n)=>(((1-3*n+3*t)*e+(3*n-6*t))*e+3*t)*e,VW=1e-7,KW=12;function GW(e,t,n,i,s){let a,o,c=0;do o=t+(n-t)/2,a=$R(o,i,s)-e,a>0?n=o:t=o;while(Math.abs(a)>VW&&++c<KW);return o}function mf(e,t,n,i){if(e===t&&n===i)return ws;const s=a=>GW(a,0,1,e,n);return a=>a===0||a===1?a:$R(s(a),t,i)}const qR=e=>t=>t<=.5?e(2*t)/2:(2-e(2*(1-t)))/2,HR=e=>t=>1-e(1-t),VR=mf(.33,1.53,.69,.99),N1=HR(VR),KR=qR(N1),GR=e=>e>=1?1:(e*=2)<1?.5*N1(e):.5*(2-Math.pow(2,-10*(e-1))),_1=e=>1-Math.sin(Math.acos(e)),WR=HR(_1),YR=qR(_1),WW=mf(.42,0,1,1),YW=mf(0,0,.58,1),XR=mf(.42,0,.58,1),XW=e=>Array.isArray(e)&&typeof e[0]!="number",QR=e=>Array.isArray(e)&&typeof e[0]=="number",QW={linear:ws,easeIn:WW,easeInOut:XR,easeOut:YW,circIn:_1,circInOut:YR,circOut:WR,backIn:N1,backInOut:KR,backOut:VR,anticipate:GR},ZW=e=>typeof e=="string",k2=e=>{if(QR(e)){S1(e.length===4);const[t,n,i,s]=e;return mf(t,n,i,s)}else if(ZW(e))return QW[e];return e},Yh=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function JW(e){let t=new Set,n=new Set,i=!1,s=!1;const a=new WeakSet;let o={delta:0,timestamp:0,isProcessing:!1};function c(f){a.has(f)&&(u.schedule(f),e()),f(o)}const u={schedule:(f,m=!1,p=!1)=>{const b=p&&i?t:n;return m&&a.add(f),b.add(f),f},cancel:f=>{n.delete(f),a.delete(f)},process:f=>{if(o=f,i){s=!0;return}i=!0;const m=t;t=n,n=m,t.forEach(c),t.clear(),i=!1,s&&(s=!1,u.process(f))}};return u}const eY=40;function ZR(e,t){let n=!1,i=!0;const s={delta:0,timestamp:0,isProcessing:!1},a=()=>n=!0,o=Yh.reduce((k,T)=>(k[T]=JW(a),k),{}),{setup:c,read:u,resolveKeyframes:f,preUpdate:m,update:p,preRender:y,render:b,postRender:x}=o,w=()=>{const k=to.useManualTiming,T=k?s.timestamp:performance.now();n=!1,k||(s.delta=i?1e3/60:Math.max(Math.min(T-s.timestamp,eY),1)),s.timestamp=T,s.isProcessing=!0,c.process(s),u.process(s),f.process(s),m.process(s),p.process(s),y.process(s),b.process(s),x.process(s),s.isProcessing=!1,n&&t&&(i=!1,e(w))},E=()=>{n=!0,i=!0,s.isProcessing||e(w)};return{schedule:Yh.reduce((k,T)=>{const A=o[T];return k[T]=(j,M=!1,D=!1)=>(n||E(),A.schedule(j,M,D)),k},{}),cancel:k=>{for(let T=0;T<Yh.length;T++)o[Yh[T]].cancel(k)},state:s,steps:o}}const{schedule:un,cancel:no,state:di,steps:nx}=ZR(typeof requestAnimationFrame<"u"?requestAnimationFrame:ws,!0);let Np;function tY(){Np=void 0}const _i={now:()=>(Np===void 0&&_i.set(di.isProcessing||to.useManualTiming?di.timestamp:performance.now()),Np),set:e=>{Np=e,queueMicrotask(tY)}},JR=e=>t=>typeof t=="string"&&t.startsWith(e),eD=JR("--"),nY=JR("var(--"),C1=e=>nY(e)?iY.test(e.split("/*")[0].trim()):!1,iY=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function N2(e){return typeof e!="string"?!1:e.split("/*")[0].includes("var(--")}const Yc={test:e=>typeof e=="number",parse:parseFloat,transform:e=>e},Od={...Yc,transform:e=>gr(0,1,e)},Xh={...Yc,default:1},vd=e=>Math.round(e*1e5)/1e5,T1=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function sY(e){return e==null}const rY=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,A1=(e,t)=>n=>!!(typeof n=="string"&&rY.test(n)&&n.startsWith(e)||t&&!sY(n)&&Object.prototype.hasOwnProperty.call(n,t)),tD=(e,t,n)=>i=>{if(typeof i!="string")return i;const[s,a,o,c]=i.match(T1);return{[e]:parseFloat(s),[t]:parseFloat(a),[n]:parseFloat(o),alpha:c!==void 0?parseFloat(c):1}},aY=e=>gr(0,255,e),ix={...Yc,transform:e=>Math.round(aY(e))},Lo={test:A1("rgb","red"),parse:tD("red","green","blue"),transform:({red:e,green:t,blue:n,alpha:i=1})=>"rgba("+ix.transform(e)+", "+ix.transform(t)+", "+ix.transform(n)+", "+vd(Od.transform(i))+")"};function oY(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 M0={test:A1("#"),parse:oY,transform:Lo.transform},gf=e=>({test:t=>typeof t=="string"&&t.endsWith(e)&&t.split(" ").length===1,parse:parseFloat,transform:t=>`${t}${e}`}),$r=gf("deg"),hr=gf("%"),Ke=gf("px"),lY=gf("vh"),cY=gf("vw"),_2={...hr,parse:e=>hr.parse(e)/100,transform:e=>hr.transform(e*100)},ic={test:A1("hsl","hue"),parse:tD("hue","saturation","lightness"),transform:({hue:e,saturation:t,lightness:n,alpha:i=1})=>"hsla("+Math.round(e)+", "+hr.transform(vd(t))+", "+hr.transform(vd(n))+", "+vd(Od.transform(i))+")"},Kn={test:e=>Lo.test(e)||M0.test(e)||ic.test(e),parse:e=>Lo.test(e)?Lo.parse(e):ic.test(e)?ic.parse(e):M0.parse(e),transform:e=>typeof e=="string"?e:e.hasOwnProperty("red")?Lo.transform(e):ic.transform(e),getAnimatableNone:e=>{const t=Kn.parse(e);return t.alpha=0,Kn.transform(t)}},uY=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function dY(e){var t,n;return isNaN(e)&&typeof e=="string"&&(((t=e.match(T1))==null?void 0:t.length)||0)+(((n=e.match(uY))==null?void 0:n.length)||0)>0}const nD="number",iD="color",fY="var",hY="var(",C2="${}",pY=/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 Oc(e){const t=e.toString(),n=[],i={color:[],number:[],var:[]},s=[];let a=0;const c=t.replace(pY,u=>(Kn.test(u)?(i.color.push(a),s.push(iD),n.push(Kn.parse(u))):u.startsWith(hY)?(i.var.push(a),s.push(fY),n.push(u)):(i.number.push(a),s.push(nD),n.push(parseFloat(u))),++a,C2)).split(C2);return{values:n,split:c,indexes:i,types:s}}function mY(e){return Oc(e).values}function sD({split:e,types:t}){const n=e.length;return i=>{let s="";for(let a=0;a<n;a++)if(s+=e[a],i[a]!==void 0){const o=t[a];o===nD?s+=vd(i[a]):o===iD?s+=Kn.transform(i[a]):s+=i[a]}return s}}function gY(e){return sD(Oc(e))}const yY=e=>typeof e=="number"?0:Kn.test(e)?Kn.getAnimatableNone(e):e,bY=(e,t)=>typeof e=="number"?t!=null&&t.trim().endsWith("/")?e:0:yY(e);function xY(e){const t=Oc(e);return sD(t)(t.values.map((i,s)=>bY(i,t.split[s])))}const qs={test:dY,parse:mY,createTransformer:gY,getAnimatableNone:xY};function sx(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 vY({hue:e,saturation:t,lightness:n,alpha:i}){e/=360,t/=100,n/=100;let s=0,a=0,o=0;if(!t)s=a=o=n;else{const c=n<.5?n*(1+t):n+t-n*t,u=2*n-c;s=sx(u,c,e+1/3),a=sx(u,c,e),o=sx(u,c,e-1/3)}return{red:Math.round(s*255),green:Math.round(a*255),blue:Math.round(o*255),alpha:i}}function nm(e,t){return n=>n>0?t:e}const cn=(e,t,n)=>e+(t-e)*n,rx=(e,t,n)=>{const i=e*e,s=n*(t*t-i)+i;return s<0?0:Math.sqrt(s)},wY=[M0,Lo,ic],EY=e=>wY.find(t=>t.test(e));function T2(e){const t=EY(e);if(!t)return!1;let n=t.parse(e);return t===ic&&(n=vY(n)),n}const A2=(e,t)=>{const n=T2(e),i=T2(t);if(!n||!i)return nm(e,t);const s={...n};return a=>(s.red=rx(n.red,i.red,a),s.green=rx(n.green,i.green,a),s.blue=rx(n.blue,i.blue,a),s.alpha=cn(n.alpha,i.alpha,a),Lo.transform(s))},R0=new Set(["none","hidden"]);function SY(e,t){return R0.has(e)?n=>n<=0?e:t:n=>n>=1?t:e}function kY(e,t){return n=>cn(e,t,n)}function j1(e){return typeof e=="number"?kY:typeof e=="string"?C1(e)?nm:Kn.test(e)?A2:CY:Array.isArray(e)?rD:typeof e=="object"?Kn.test(e)?A2:NY:nm}function rD(e,t){const n=[...e],i=n.length,s=e.map((a,o)=>j1(a)(a,t[o]));return a=>{for(let o=0;o<i;o++)n[o]=s[o](a);return n}}function NY(e,t){const n={...e,...t},i={};for(const s in n)e[s]!==void 0&&t[s]!==void 0&&(i[s]=j1(e[s])(e[s],t[s]));return s=>{for(const a in i)n[a]=i[a](s);return n}}function _Y(e,t){const n=[],i={color:0,var:0,number:0};for(let s=0;s<t.values.length;s++){const a=t.types[s],o=e.indexes[a][i[a]],c=e.values[o]??0;n[s]=c,i[a]++}return n}const CY=(e,t)=>{const n=qs.createTransformer(t),i=Oc(e),s=Oc(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?R0.has(e)&&!s.values.length||R0.has(t)&&!i.values.length?SY(e,t):pf(rD(_Y(i,s),s.values),n):nm(e,t)};function aD(e,t,n){return typeof e=="number"&&typeof t=="number"&&typeof n=="number"?cn(e,t,n):j1(e)(e,t)}const TY=e=>{const t=({timestamp:n})=>e(n);return{start:(n=!0)=>un.update(t,n),stop:()=>no(t),now:()=>di.isProcessing?di.timestamp:_i.now()}},oD=(e,t,n=10)=>{let i="";const s=Math.max(Math.round(t/n),2);for(let a=0;a<s;a++)i+=Math.round(e(a/(s-1))*1e4)/1e4+", ";return`linear(${i.substring(0,i.length-2)})`},im=2e4;function M1(e){let t=0;const n=50;let i=e.next(t);for(;!i.done&&t<im;)t+=n,i=e.next(t);return t>=im?1/0:t}function AY(e,t=100,n){const i=n({...e,keyframes:[0,t]}),s=Math.min(M1(i),im);return{type:"keyframes",ease:a=>i.next(s*a).value/t,duration:vs(s)}}const On={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 D0(e,t){return e*Math.sqrt(1-t*t)}const jY=12;function MY(e,t,n){let i=n;for(let s=1;s<jY;s++)i=i-e(i)/t(i);return i}const ax=.001;function RY({duration:e=On.duration,bounce:t=On.bounce,velocity:n=On.velocity,mass:i=On.mass}){let s,a,o=1-t;o=gr(On.minDamping,On.maxDamping,o),e=gr(On.minDuration,On.maxDuration,vs(e)),o<1?(s=f=>{const m=f*o,p=m*e,y=m-n,b=D0(f,o),x=Math.exp(-p);return ax-y/b*x},a=f=>{const p=f*o*e,y=p*n+n,b=Math.pow(o,2)*Math.pow(f,2)*e,x=Math.exp(-p),w=D0(Math.pow(f,2),o);return(-s(f)+ax>0?-1:1)*((y-b)*x)/w}):(s=f=>{const m=Math.exp(-f*e),p=(f-n)*e+1;return-ax+m*p},a=f=>{const m=Math.exp(-f*e),p=(n-f)*(e*e);return m*p});const c=5/e,u=MY(s,a,c);if(e=ss(e),isNaN(u))return{stiffness:On.stiffness,damping:On.damping,duration:e};{const f=Math.pow(u,2)*i;return{stiffness:f,damping:o*2*Math.sqrt(i*f),duration:e}}}const DY=["duration","bounce"],OY=["stiffness","damping","mass"];function j2(e,t){return t.some(n=>e[n]!==void 0)}function LY(e){let t={velocity:On.velocity,stiffness:On.stiffness,damping:On.damping,mass:On.mass,isResolvedFromDuration:!1,...e};if(!j2(e,OY)&&j2(e,DY))if(t.velocity=0,e.visualDuration){const n=e.visualDuration,i=2*Math.PI/(n*1.2),s=i*i,a=2*gr(.05,1,1-(e.bounce||0))*Math.sqrt(s);t={...t,mass:On.mass,stiffness:s,damping:a}}else{const n=RY({...e,velocity:0});t={...t,...n,mass:On.mass},t.isResolvedFromDuration=!0}return t}function sm(e=On.visualDuration,t=On.bounce){const n=typeof e!="object"?{visualDuration:e,keyframes:[0,1],bounce:t}:e;let{restSpeed:i,restDelta:s}=n;const a=n.keyframes[0],o=n.keyframes[n.keyframes.length-1],c={done:!1,value:a},{stiffness:u,damping:f,mass:m,duration:p,velocity:y,isResolvedFromDuration:b}=LY({...n,velocity:-vs(n.velocity||0)}),x=y||0,w=f/(2*Math.sqrt(u*m)),E=o-a,v=vs(Math.sqrt(u/m)),_=Math.abs(E)<5;i||(i=_?On.restSpeed.granular:On.restSpeed.default),s||(s=_?On.restDelta.granular:On.restDelta.default);let k,T,A,j,M,D;if(w<1)A=D0(v,w),j=(x+w*v*E)/A,k=P=>{const U=Math.exp(-w*v*P);return o-U*(j*Math.sin(A*P)+E*Math.cos(A*P))},M=w*v*j+E*A,D=w*v*E-j*A,T=P=>Math.exp(-w*v*P)*(M*Math.sin(A*P)+D*Math.cos(A*P));else if(w===1){k=U=>o-Math.exp(-v*U)*(E+(x+v*E)*U);const P=x+v*E;T=U=>Math.exp(-v*U)*(v*P*U-x)}else{const P=v*Math.sqrt(w*w-1);k=O=>{const R=Math.exp(-w*v*O),z=Math.min(P*O,300);return o-R*((x+w*v*E)*Math.sinh(z)+P*E*Math.cosh(z))/P};const U=(x+w*v*E)/P,q=w*v*U-E*P,V=w*v*E-U*P;T=O=>{const R=Math.exp(-w*v*O),z=Math.min(P*O,300);return R*(q*Math.sinh(z)+V*Math.cosh(z))}}const I={calculatedDuration:b&&p||null,velocity:P=>ss(T(P)),next:P=>{if(!b&&w<1){const q=Math.exp(-w*v*P),V=Math.sin(A*P),O=Math.cos(A*P),R=o-q*(j*V+E*O),z=ss(q*(M*V+D*O));return c.done=Math.abs(z)<=i&&Math.abs(o-R)<=s,c.value=c.done?o:R,c}const U=k(P);if(b)c.done=P>=p;else{const q=ss(T(P));c.done=Math.abs(q)<=i&&Math.abs(o-U)<=s}return c.value=c.done?o:U,c},toString:()=>{const P=Math.min(M1(I),im),U=oD(q=>I.next(P*q).value,P,30);return P+"ms "+U},toTransition:()=>{}};return I}sm.applyToOptions=e=>{const t=AY(e,100,sm);return e.ease=t.ease,e.duration=ss(t.duration),e.type="keyframes",e};const IY=5;function lD(e,t,n){const i=Math.max(t-IY,0);return FR(n-e(i),t-i)}function O0({keyframes:e,velocity:t=0,power:n=.8,timeConstant:i=325,bounceDamping:s=10,bounceStiffness:a=500,modifyTarget:o,min:c,max:u,restDelta:f=.5,restSpeed:m}){const p=e[0],y={done:!1,value:p},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 w=n*t;const E=p+w,v=o===void 0?E:o(E);v!==E&&(w=v-p);const _=D=>-w*Math.exp(-D/i),k=D=>v+_(D),T=D=>{const I=_(D),P=k(D);y.done=Math.abs(I)<=f,y.value=y.done?v:P};let A,j;const M=D=>{b(y.value)&&(A=D,j=sm({keyframes:[y.value,x(y.value)],velocity:lD(k,D,y.value),damping:s,stiffness:a,restDelta:f,restSpeed:m}))};return M(0),{calculatedDuration:null,next:D=>{let I=!1;return!j&&A===void 0&&(I=!0,T(D),M(D)),A!==void 0&&D>=A?j.next(D-A):(!I&&T(D),y)}}}function PY(e,t,n){const i=[],s=n||to.mix||aD,a=e.length-1;for(let o=0;o<a;o++){let c=s(e[o],e[o+1]);if(t){const u=Array.isArray(t)?t[o]||ws:t;c=pf(u,c)}i.push(c)}return i}function zY(e,t,{clamp:n=!0,ease:i,mixer:s}={}){const a=e.length;if(S1(a===t.length),a===1)return()=>t[0];if(a===2&&t[0]===t[1])return()=>t[1];const o=e[0]===e[1];e[0]>e[a-1]&&(e=[...e].reverse(),t=[...t].reverse());const c=PY(t,i,s),u=c.length,f=m=>{if(o&&m<e[0])return t[0];let p=0;if(u>1)for(;p<e.length-2&&!(m<e[p+1]);p++);const y=Dd(e[p],e[p+1],m);return c[p](y)};return n?m=>f(gr(e[0],e[a-1],m)):f}function BY(e,t){const n=e[e.length-1];for(let i=1;i<=t;i++){const s=Dd(0,t,i);e.push(cn(n,1,s))}}function UY(e){const t=[0];return BY(t,e.length-1),t}function FY(e,t){return e.map(n=>n*t)}function $Y(e,t){return e.map(()=>t||XR).splice(0,e.length-1)}function wd({duration:e=300,keyframes:t,times:n,ease:i="easeInOut"}){const s=XW(i)?i.map(k2):k2(i),a={done:!1,value:t[0]},o=FY(n&&n.length===t.length?n:UY(t),e),c=zY(o,t,{ease:Array.isArray(s)?s:$Y(t,s)});return{calculatedDuration:e,next:u=>(a.value=c(u),a.done=u>=e,a)}}const qY=e=>e!==null;function Bm(e,{repeat:t,repeatType:n="loop"},i,s=1){const a=e.filter(qY),c=s<0||t&&n!=="loop"&&t%2===1?0:a.length-1;return!c||i===void 0?a[c]:i}const HY={decay:O0,inertia:O0,tween:wd,keyframes:wd,spring:sm};function cD(e){typeof e.type=="string"&&(e.type=HY[e.type])}class R1{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 VY=e=>e/100;class rm extends R1{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!==_i.now()&&this.tick(_i.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;cD(t);const{type:n=wd,repeat:i=0,repeatDelay:s=0,repeatType:a,velocity:o=0}=t;let{keyframes:c}=t;const u=n||wd;u!==wd&&typeof c[0]!="number"&&(this.mixKeyframes=pf(VY,aD(c[0],c[1])),c=[0,100]);const f=u({...t,keyframes:c});a==="mirror"&&(this.mirroredGenerator=u({...t,keyframes:[...c].reverse(),velocity:-o})),f.calculatedDuration===null&&(f.calculatedDuration=M1(f));const{calculatedDuration:m}=f;this.calculatedDuration=m,this.resolvedDuration=m+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:a,mirroredGenerator:o,resolvedDuration:c,calculatedDuration:u}=this;if(this.startTime===null)return i.next(0);const{delay:f=0,keyframes:m,repeat:p,repeatType:y,repeatDelay:b,type:x,onUpdate:w,finalKeyframe:E}=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 v=this.currentTime-f*(this.playbackSpeed>=0?1:-1),_=this.playbackSpeed>=0?v<0:v>s;this.currentTime=Math.max(v,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=s);let k=this.currentTime,T=i;if(p){const D=Math.min(this.currentTime,s)/c;let I=Math.floor(D),P=D%1;!P&&D>=1&&(P=1),P===1&&I--,I=Math.min(I,p+1),!!(I%2)&&(y==="reverse"?(P=1-P,b&&(P-=b/c)):y==="mirror"&&(T=o)),k=gr(0,1,P)*c}let A;_?(this.delayState.value=m[0],A=this.delayState):A=T.next(k),a&&!_&&(A.value=a(A.value));let{done:j}=A;!_&&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!==O0&&(A.value=Bm(m,this.options,E,this.speed)),w&&w(A.value),M&&this.finish(),A}then(t,n){return this.finished.then(t,n)}get duration(){return vs(this.calculatedDuration)}get iterationDuration(){const{delay:t=0}=this.options||{};return this.duration+vs(t)}get time(){return vs(this.currentTime)}set time(t){t=ss(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 lD(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(_i.now()),this.playbackSpeed=t,n&&this.driver&&(this.time=vs(this.currentTime))}play(){var s,a;if(this.isStopped)return;const{driver:t=TY,startTime:n}=this.options;this.driver||(this.driver=t(o=>this.tick(o))),(a=(s=this.options).onPlay)==null||a.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(_i.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 KY(e){for(let t=1;t<e.length;t++)e[t]??(e[t]=e[t-1])}const Io=e=>e*180/Math.PI,L0=e=>{const t=Io(Math.atan2(e[1],e[0]));return I0(t)},GY={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:e=>(Math.abs(e[0])+Math.abs(e[3]))/2,rotate:L0,rotateZ:L0,skewX:e=>Io(Math.atan(e[1])),skewY:e=>Io(Math.atan(e[2])),skew:e=>(Math.abs(e[1])+Math.abs(e[2]))/2},I0=e=>(e=e%360,e<0&&(e+=360),e),M2=L0,R2=e=>Math.sqrt(e[0]*e[0]+e[1]*e[1]),D2=e=>Math.sqrt(e[4]*e[4]+e[5]*e[5]),WY={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:R2,scaleY:D2,scale:e=>(R2(e)+D2(e))/2,rotateX:e=>I0(Io(Math.atan2(e[6],e[5]))),rotateY:e=>I0(Io(Math.atan2(-e[2],e[0]))),rotateZ:M2,rotate:M2,skewX:e=>Io(Math.atan(e[4])),skewY:e=>Io(Math.atan(e[1])),skew:e=>(Math.abs(e[1])+Math.abs(e[4]))/2};function P0(e){return e.includes("scale")?1:0}function z0(e,t){if(!e||e==="none")return P0(t);const n=e.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let i,s;if(n)i=WY,s=n;else{const c=e.match(/^matrix\(([-\d.e\s,]+)\)$/u);i=GY,s=c}if(!s)return P0(t);const a=i[t],o=s[1].split(",").map(XY);return typeof a=="function"?a(o):o[a]}const YY=(e,t)=>{const{transform:n="none"}=getComputedStyle(e);return z0(n,t)};function XY(e){return parseFloat(e.trim())}const Xc=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],Qc=new Set([...Xc,"pathRotation"]),O2=e=>e===Yc||e===Ke,QY=new Set(["x","y","z"]),ZY=Xc.filter(e=>!QY.has(e));function JY(e){const t=[];return ZY.forEach(n=>{const i=e.getValue(n);i!==void 0&&(t.push([n,i.get()]),i.set(n.startsWith("scale")?1:0))}),t}const Qa={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})=>z0(t,"x"),y:(e,{transform:t})=>z0(t,"y")};Qa.translateX=Qa.x;Qa.translateY=Qa.y;const Xo=new Set;let B0=!1,U0=!1,F0=!1;function uD(){if(U0){const e=Array.from(Xo).filter(i=>i.needsMeasurement),t=new Set(e.map(i=>i.element)),n=new Map;t.forEach(i=>{const s=JY(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(([a,o])=>{var c;(c=i.getValue(a))==null||c.set(o)})}),e.forEach(i=>i.measureEndState()),e.forEach(i=>{i.suspendedScrollY!==void 0&&window.scrollTo(0,i.suspendedScrollY)})}U0=!1,B0=!1,Xo.forEach(e=>e.complete(F0)),Xo.clear()}function dD(){Xo.forEach(e=>{e.readKeyframes(),e.needsMeasurement&&(U0=!0)})}function eX(){F0=!0,dD(),uD(),F0=!1}class D1{constructor(t,n,i,s,a,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=a,this.isAsync=o}scheduleResolve(){this.state="scheduled",this.isAsync?(Xo.add(this),B0||(B0=!0,un.read(dD),un.resolveKeyframes(uD))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:t,name:n,element:i,motionValue:s}=this;if(t[0]===null){const a=s==null?void 0:s.get(),o=t[t.length-1];if(a!==void 0)t[0]=a;else if(i&&n){const c=i.readValue(n,o);c!=null&&(t[0]=c)}t[0]===void 0&&(t[0]=o),s&&a===void 0&&s.set(t[0])}KY(t)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(t=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,t),Xo.delete(this)}cancel(){this.state==="scheduled"&&(Xo.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const tX=e=>e.startsWith("--");function fD(e,t,n){tX(t)?e.style.setProperty(t,n):e.style[t]=n}const nX={};function hD(e,t){const n=UR(e);return()=>nX[t]??n()}const iX=hD(()=>window.ScrollTimeline!==void 0,"scrollTimeline"),pD=hD(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),cd=([e,t,n,i])=>`cubic-bezier(${e}, ${t}, ${n}, ${i})`,L2={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:cd([0,.65,.55,1]),circOut:cd([.55,0,1,.45]),backIn:cd([.31,.01,.66,-.59]),backOut:cd([.33,1.53,.69,.99])};function mD(e,t){if(e)return typeof e=="function"?pD()?oD(e,t):"ease-out":QR(e)?cd(e):Array.isArray(e)?e.map(n=>mD(n,t)||L2.easeOut):L2[e]}function sX(e,t,n,{delay:i=0,duration:s=300,repeat:a=0,repeatType:o="loop",ease:c="easeOut",times:u}={},f=void 0){const m={[t]:n};u&&(m.offset=u);const p=mD(c,s);Array.isArray(p)&&(m.easing=p);const y={delay:i,duration:s,easing:Array.isArray(p)?"linear":p,fill:"both",iterations:a+1,direction:o==="reverse"?"alternate":"normal"};return f&&(y.pseudoElement=f),e.animate(m,y)}function gD(e){return typeof e=="function"&&"applyToOptions"in e}function rX({type:e,...t}){return gD(e)&&pD()?e.applyToOptions(t):(t.duration??(t.duration=300),t.ease??(t.ease="easeOut"),t)}class yD extends R1{constructor(t){if(super(),this.finishedTime=null,this.isStopped=!1,this.manualStartTime=null,!t)return;const{element:n,name:i,keyframes:s,pseudoElement:a,allowFlatten:o=!1,finalKeyframe:c,onComplete:u}=t;this.isPseudoElement=!!a,this.allowFlatten=o,this.options=t,S1(typeof t.type!="string");const f=rX(t);this.animation=sX(n,i,s,f,a),f.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!a){const m=Bm(s,this.options,c,this.speed);this.updateMotionValue&&this.updateMotionValue(m),fD(n,i,m),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 vs(Number(t))}get iterationDuration(){const{delay:t=0}=this.options||{};return this.duration+vs(t)}get time(){return vs(Number(this.animation.currentTime)||0)}set time(t){const n=this.finishedTime!==null;this.manualStartTime=null,this.finishedTime=null,this.animation.currentTime=ss(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 a;return this.allowFlatten&&((a=this.animation.effect)==null||a.updateTiming({easing:"linear"})),this.animation.onfinish=null,t&&iX()?(this.animation.timeline=t,n&&(this.animation.rangeStart=n),i&&(this.animation.rangeEnd=i),ws):s(this)}}const bD={anticipate:GR,backInOut:KR,circInOut:YR};function aX(e){return e in bD}function oX(e){typeof e.ease=="string"&&aX(e.ease)&&(e.ease=bD[e.ease])}const ox=10;class lX extends yD{constructor(t){oX(t),cD(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:a,...o}=this.options;if(!n)return;if(t!==void 0){n.set(t);return}const c=new rm({...o,autoplay:!1}),u=Math.max(ox,_i.now()-this.startTime),f=gr(0,ox,u-ox),m=c.sample(u).value,{name:p}=this.options;a&&p&&fD(a,p,m),n.setWithVelocity(c.sample(Math.max(0,u-f)).value,m,f),c.stop()}}const I2=(e,t)=>t==="zIndex"?!1:!!(typeof e=="number"||Array.isArray(e)||typeof e=="string"&&(qs.test(e)||e==="0")&&!e.startsWith("url("));function cX(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 uX(e,t,n,i){const s=e[0];if(s===null)return!1;if(t==="display"||t==="visibility")return!0;const a=e[e.length-1],o=I2(s,t),c=I2(a,t);return!o||!c?!1:cX(e)||(n==="spring"||gD(n))&&i}function $0(e){e.duration=0,e.type="keyframes"}const xD=new Set(["opacity","clipPath","filter","transform"]),dX=/^(?:oklch|oklab|lab|lch|color|color-mix|light-dark)\(/;function fX(e){for(let t=0;t<e.length;t++)if(typeof e[t]=="string"&&dX.test(e[t]))return!0;return!1}const hX=new Set(["color","backgroundColor","outlineColor","fill","stroke","borderColor","borderTopColor","borderRightColor","borderBottomColor","borderLeftColor"]),pX=UR(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));function mX(e){var p;const{motionValue:t,name:n,repeatDelay:i,repeatType:s,damping:a,type:o,keyframes:c}=e;if(!(((p=t==null?void 0:t.owner)==null?void 0:p.current)instanceof HTMLElement))return!1;const{onUpdate:f,transformTemplate:m}=t.owner.getProps();return pX()&&n&&(xD.has(n)||hX.has(n)&&fX(c))&&(n!=="transform"||!m)&&!f&&!i&&s!=="mirror"&&a!==0&&o!=="inertia"}const gX=40;class yX extends R1{constructor({autoplay:t=!0,delay:n=0,type:i="keyframes",repeat:s=0,repeatDelay:a=0,repeatType:o="loop",keyframes:c,name:u,motionValue:f,element:m,...p}){var x;super(),this.stop=()=>{var w,E;this._animation&&(this._animation.stop(),(w=this.stopTimeline)==null||w.call(this)),(E=this.keyframeResolver)==null||E.cancel()},this.createdAt=_i.now();const y={autoplay:t,delay:n,type:i,repeat:s,repeatDelay:a,repeatType:o,name:u,motionValue:f,element:m,...p},b=(m==null?void 0:m.KeyframeResolver)||D1;this.keyframeResolver=new b(c,(w,E,v)=>this.onKeyframesResolved(w,E,y,!v),u,f,m),(x=this.keyframeResolver)==null||x.scheduleResolve()}onKeyframesResolved(t,n,i,s){var v,_;this.keyframeResolver=void 0;const{name:a,type:o,velocity:c,delay:u,isHandoff:f,onUpdate:m}=i;this.resolvedAt=_i.now();let p=!0;uX(t,a,o,c)||(p=!1,(to.instantAnimations||!u)&&(m==null||m(Bm(t,i,n))),t[0]=t[t.length-1],$0(i),i.repeat=0);const b={startTime:s?this.resolvedAt?this.resolvedAt-this.createdAt>gX?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:n,...i,keyframes:t},x=p&&!f&&mX(b),w=(_=(v=b.motionValue)==null?void 0:v.owner)==null?void 0:_.current;let E;if(x)try{E=new lX({...b,element:w})}catch{E=new rm(b)}else E=new rm(b);E.finished.then(()=>{this.notifyFinished()}).catch(ws),this.pendingTimeline&&(this.stopTimeline=E.attachTimeline(this.pendingTimeline),this.pendingTimeline=void 0),this._animation=E}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(),eX()),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 vD(e,t,n,i=0,s=1){const a=Array.from(e).sort((f,m)=>f.sortNodePosition(m)).indexOf(t),o=e.size,c=(o-1)*i;return typeof n=="function"?n(a,o):s===1?a*i:c-a*i}const P2=30,bX=e=>!isNaN(parseFloat(e));class xX{constructor(t,n={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=i=>{var a;const s=_i.now();if(this.updatedAt!==s&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(i),this.current!==this.prev&&((a=this.events.change)==null||a.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=_i.now(),this.canTrackVelocity===null&&t!==void 0&&(this.canTrackVelocity=bX(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 k1);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=_i.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||t-this.updatedAt>P2)return 0;const n=Math.min(this.updatedAt-this.prevUpdatedAt,P2);return FR(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 Lc(e,t){return new xX(e,t)}function wD(e,t){if(e!=null&&e.inherit&&t){const{inherit:n,...i}=e;return{...t,...i}}return e}function O1(e,t){const n=(e==null?void 0:e[t])??(e==null?void 0:e.default)??e;return n!==e?wD(n,e):n}const vX={type:"spring",stiffness:500,damping:25,restSpeed:10},wX=e=>({type:"spring",stiffness:550,damping:e===0?2*Math.sqrt(550):30,restSpeed:10}),EX={type:"keyframes",duration:.8},SX={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},kX=(e,{keyframes:t})=>t.length>2?EX:Qc.has(e)?e.startsWith("scale")?wX(t[1]):vX:SX,NX=new Set(["when","delay","delayChildren","staggerChildren","staggerDirection","repeat","repeatType","repeatDelay","from","elapsed"]);function _X(e){for(const t in e)if(!NX.has(t))return!0;return!1}const L1=(e,t,n,i={},s,a)=>o=>{const c=O1(i,e)||{},u=c.delay||i.delay||0;let{elapsed:f=0}=i;f=f-ss(u);const m={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:a?void 0:s};_X(c)||Object.assign(m,kX(e,m)),m.duration&&(m.duration=ss(m.duration)),m.repeatDelay&&(m.repeatDelay=ss(m.repeatDelay)),m.from!==void 0&&(m.keyframes[0]=m.from);let p=!1;if((m.type===!1||m.duration===0&&!m.repeatDelay)&&($0(m),m.delay===0&&(p=!0)),(to.instantAnimations||to.skipAnimations||s!=null&&s.shouldSkipAnimations||c.skipAnimations)&&(p=!0,$0(m),m.delay=0),m.allowFlatten=!c.type&&!c.ease,p&&!a&&t.get()!==void 0){const y=Bm(m.keyframes,c);if(y!==void 0){un.update(()=>{m.onUpdate(y),m.onComplete()});return}}return c.isSync?new rm(m):new yX(m)},CX=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function TX(e){const t=CX.exec(e);if(!t)return[,];const[,n,i,s]=t;return[`--${n??i}`,s]}function ED(e,t,n=1){const[i,s]=TX(e);if(!i)return;const a=window.getComputedStyle(t).getPropertyValue(i);if(a){const o=a.trim();return PR(o)?parseFloat(o):o}return C1(s)?ED(s,t,n+1):s}function z2(e){const t=[{},{}];return e==null||e.values.forEach((n,i)=>{t[0][i]=n.get(),t[1][i]=n.getVelocity()}),t}function I1(e,t,n,i){if(typeof t=="function"){const[s,a]=z2(i);t=t(n!==void 0?n:e.custom,s,a)}if(typeof t=="string"&&(t=e.variants&&e.variants[t]),typeof t=="function"){const[s,a]=z2(i);t=t(n!==void 0?n:e.custom,s,a)}return t}function Qo(e,t,n){const i=e.getProps();return I1(i,t,n!==void 0?n:i.custom,e)}const SD=new Set(["width","height","top","left","right","bottom",...Xc]),q0=e=>Array.isArray(e);function AX(e,t,n){e.hasValue(t)?e.getValue(t).set(n):e.addValue(t,Lc(n))}function jX(e){return q0(e)?e[e.length-1]||0:e}function MX(e,t){const n=Qo(e,t);let{transitionEnd:i={},transition:s={},...a}=n||{};a={...a,...i};for(const o in a){const c=jX(a[o]);AX(e,o,c)}}const fi=e=>!!(e&&e.getVelocity);function RX(e){return!!(fi(e)&&e.add)}function H0(e,t){const n=e.getValue("willChange");if(RX(n))return n.add(t);if(!n&&to.WillChange){const i=new to.WillChange("auto");e.addValue("willChange",i),i.add(t)}}function P1(e){return e.replace(/([A-Z])/g,t=>`-${t.toLowerCase()}`)}const DX="framerAppearId",kD="data-"+P1(DX);function ND(e){return e.props[kD]}function OX({protectedKeys:e,needsAnimating:t},n){const i=e.hasOwnProperty(n)&&t[n]!==!0;return t[n]=!1,i}function _D(e,t,{delay:n=0,transitionOverride:i,type:s}={}){let{transition:a,transitionEnd:o,...c}=t;const u=e.getDefaultTransition();a=a?wD(a,u):u;const f=a==null?void 0:a.reduceMotion,m=a==null?void 0:a.skipAnimations;i&&(a=i);const p=[],y=s&&e.animationState&&e.animationState.getState()[s],b=a==null?void 0:a.path;b&&b.animateVisualElement(e,c,a,n,p);for(const x in c){const w=e.getValue(x,e.latestValues[x]??null),E=c[x];if(E===void 0||y&&OX(y,x))continue;const v={delay:n,...O1(a||{},x)};m&&(v.skipAnimations=!0);const _=w.get();if(_!==void 0&&!w.isAnimating()&&!Array.isArray(E)&&E===_&&!v.velocity){un.update(()=>w.set(E));continue}let k=!1;if(window.MotionHandoffAnimation){const j=ND(e);if(j){const M=window.MotionHandoffAnimation(j,x,un);M!==null&&(v.startTime=M,k=!0)}}H0(e,x);const T=f??e.shouldReduceMotion;w.start(L1(x,w,E,T&&SD.has(x)?{type:!1}:v,e,k));const A=w.animation;A&&p.push(A)}if(o){const x=()=>un.update(()=>{o&&MX(e,o)});p.length?Promise.all(p).then(x):x()}return p}function V0(e,t,n={}){var u;const i=Qo(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 a=i?()=>Promise.all(_D(e,i,n)):()=>Promise.resolve(),o=e.variantChildren&&e.variantChildren.size?(f=0)=>{const{delayChildren:m=0,staggerChildren:p,staggerDirection:y}=s;return LX(e,t,f,m,p,y,n)}:()=>Promise.resolve(),{when:c}=s;if(c){const[f,m]=c==="beforeChildren"?[a,o]:[o,a];return f().then(()=>m())}else return Promise.all([a(),o(n.delay)])}function LX(e,t,n=0,i=0,s=0,a=1,o){const c=[];for(const u of e.variantChildren)u.notify("AnimationStart",t),c.push(V0(u,t,{...o,delay:n+(typeof i=="function"?0:i)+vD(e.variantChildren,u,i,s,a)}).then(()=>u.notify("AnimationComplete",t)));return Promise.all(c)}function IX(e,t,n={}){e.notify("AnimationStart",t);let i;if(Array.isArray(t)){const s=t.map(a=>V0(e,a,n));i=Promise.all(s)}else if(typeof t=="string")i=V0(e,t,n);else{const s=typeof t=="function"?Qo(e,t,n.custom):t;i=Promise.all(_D(e,s,n))}return i.then(()=>{e.notify("AnimationComplete",t)})}const PX={test:e=>e==="auto",parse:e=>e},CD=e=>t=>t.test(e),TD=[Yc,Ke,hr,$r,cY,lY,PX],B2=e=>TD.find(CD(e));function zX(e){return typeof e=="number"?e===0:e!==null?e==="none"||e==="0"||BR(e):!0}const BX=new Set(["brightness","contrast","saturate","opacity"]);function UX(e){const[t,n]=e.slice(0,-1).split("(");if(t==="drop-shadow")return e;const[i]=n.match(T1)||[];if(!i)return e;const s=n.replace(i,"");let a=BX.has(t)?1:0;return i!==n&&(a*=100),t+"("+a+s+")"}const FX=/\b([a-z-]*)\(.*?\)/gu,K0={...qs,getAnimatableNone:e=>{const t=e.match(FX);return t?t.map(UX).join(" "):e}},G0={...qs,getAnimatableNone:e=>{const t=qs.parse(e);return qs.createTransformer(e)(t.map(i=>typeof i=="number"?0:typeof i=="object"?{...i,alpha:1}:i))}},U2={...Yc,transform:Math.round},$X={rotate:$r,pathRotation:$r,rotateX:$r,rotateY:$r,rotateZ:$r,scale:Xh,scaleX:Xh,scaleY:Xh,scaleZ:Xh,skew:$r,skewX:$r,skewY:$r,distance:Ke,translateX:Ke,translateY:Ke,translateZ:Ke,x:Ke,y:Ke,z:Ke,perspective:Ke,transformPerspective:Ke,opacity:Od,originX:_2,originY:_2,originZ:Ke},am={borderWidth:Ke,borderTopWidth:Ke,borderRightWidth:Ke,borderBottomWidth:Ke,borderLeftWidth:Ke,borderRadius:Ke,borderTopLeftRadius:Ke,borderTopRightRadius:Ke,borderBottomRightRadius:Ke,borderBottomLeftRadius:Ke,width:Ke,maxWidth:Ke,height:Ke,maxHeight:Ke,top:Ke,right:Ke,bottom:Ke,left:Ke,inset:Ke,insetBlock:Ke,insetBlockStart:Ke,insetBlockEnd:Ke,insetInline:Ke,insetInlineStart:Ke,insetInlineEnd:Ke,padding:Ke,paddingTop:Ke,paddingRight:Ke,paddingBottom:Ke,paddingLeft:Ke,paddingBlock:Ke,paddingBlockStart:Ke,paddingBlockEnd:Ke,paddingInline:Ke,paddingInlineStart:Ke,paddingInlineEnd:Ke,margin:Ke,marginTop:Ke,marginRight:Ke,marginBottom:Ke,marginLeft:Ke,marginBlock:Ke,marginBlockStart:Ke,marginBlockEnd:Ke,marginInline:Ke,marginInlineStart:Ke,marginInlineEnd:Ke,fontSize:Ke,backgroundPositionX:Ke,backgroundPositionY:Ke,...$X,zIndex:U2,fillOpacity:Od,strokeOpacity:Od,numOctaves:U2},qX={...am,color:Kn,backgroundColor:Kn,outlineColor:Kn,fill:Kn,stroke:Kn,borderColor:Kn,borderTopColor:Kn,borderRightColor:Kn,borderBottomColor:Kn,borderLeftColor:Kn,filter:K0,WebkitFilter:K0,mask:G0,WebkitMask:G0},AD=e=>qX[e],HX=new Set([K0,G0]);function jD(e,t){let n=AD(e);return HX.has(n)||(n=qs),n.getAnimatableNone?n.getAnimatableNone(t):void 0}const VX=new Set(["auto","none","0"]);function KX(e,t,n){let i=0,s;for(;i<e.length&&!s;){const a=e[i];typeof a=="string"&&!VX.has(a)&&Oc(a).values.length&&(s=e[i]),i++}if(s&&n)for(const a of t)e[a]=jD(n,s)}class GX extends D1{constructor(t,n,i,s,a){super(t,n,i,s,a,!0)}readKeyframes(){const{unresolvedKeyframes:t,element:n,name:i}=this;if(!n||!n.current)return;super.readKeyframes();for(let m=0;m<t.length;m++){let p=t[m];if(typeof p=="string"&&(p=p.trim(),C1(p))){const y=ED(p,n.current);y!==void 0&&(t[m]=y),m===t.length-1&&(this.finalKeyframe=p)}}if(this.resolveNoneKeyframes(),!SD.has(i)||t.length!==2)return;const[s,a]=t,o=B2(s),c=B2(a),u=N2(s),f=N2(a);if(u!==f&&Qa[i]){this.needsMeasurement=!0;return}if(o!==c)if(O2(o)&&O2(c))for(let m=0;m<t.length;m++){const p=t[m];typeof p=="string"&&(t[m]=parseFloat(p))}else Qa[i]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){const{unresolvedKeyframes:t,name:n}=this,i=[];for(let s=0;s<t.length;s++)(t[s]===null||zX(t[s]))&&i.push(s);i.length&&KX(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=Qa[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 a=i.length-1,o=i[a];i[a]=Qa[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 z1=["borderTopLeftRadius","borderTopRightRadius","borderBottomRightRadius","borderBottomLeftRadius"];function B1(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 W0=(e,t)=>t&&typeof e=="number"?t.transform(e):e;function WX(e){return zR(e)&&"offsetHeight"in e&&!("ownerSVGElement"in e)}const{schedule:U1}=ZR(queueMicrotask,!1),Os={x:!1,y:!1};function MD(){return Os.x||Os.y}function YX(e){return e==="x"||e==="y"?Os[e]?null:(Os[e]=!0,()=>{Os[e]=!1}):Os.x||Os.y?null:(Os.x=Os.y=!0,()=>{Os.x=Os.y=!1})}function RD(e,t){const n=B1(e),i=new AbortController,s={passive:!0,...t,signal:i.signal};return[n,s,()=>i.abort()]}function XX(e){return!(e.pointerType==="touch"||MD())}function QX(e,t,n={}){const[i,s,a]=RD(e,n);return i.forEach(o=>{let c=!1,u=!1,f;const m=()=>{o.removeEventListener("pointerleave",x)},p=E=>{f&&(f(E),f=void 0),m()},y=E=>{c=!1,window.removeEventListener("pointerup",y),window.removeEventListener("pointercancel",y),u&&(u=!1,p(E))},b=()=>{c=!0,window.addEventListener("pointerup",y,s),window.addEventListener("pointercancel",y,s)},x=E=>{if(E.pointerType!=="touch"){if(c){u=!0;return}p(E)}},w=E=>{if(!XX(E))return;u=!1;const v=t(o,E);typeof v=="function"&&(f=v,o.addEventListener("pointerleave",x,s))};o.addEventListener("pointerenter",w,s),o.addEventListener("pointerdown",b,s)}),a}const DD=(e,t)=>t?e===t?!0:DD(e,t.parentElement):!1,F1=e=>e.pointerType==="mouse"?typeof e.button!="number"||e.button<=0:e.isPrimary!==!1,ZX=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function JX(e){return ZX.has(e.tagName)||e.isContentEditable===!0}const eQ=new Set(["INPUT","SELECT","TEXTAREA"]);function tQ(e){return eQ.has(e.tagName)||e.isContentEditable===!0}const _p=new WeakSet;function F2(e){return t=>{t.key==="Enter"&&e(t)}}function lx(e,t){e.dispatchEvent(new PointerEvent("pointer"+t,{isPrimary:!0,bubbles:!0}))}const nQ=(e,t)=>{const n=e.currentTarget;if(!n)return;const i=F2(()=>{if(_p.has(n))return;lx(n,"down");const s=F2(()=>{lx(n,"up")}),a=()=>lx(n,"cancel");n.addEventListener("keyup",s,t),n.addEventListener("blur",a,t)});n.addEventListener("keydown",i,t),n.addEventListener("blur",()=>n.removeEventListener("keydown",i),t)};function $2(e){return F1(e)&&!MD()}const q2=new WeakSet;function iQ(e,t,n={}){const[i,s,a]=RD(e,n),o=c=>{const u=c.currentTarget;if(!$2(c)||q2.has(c))return;_p.add(u),n.stopPropagation&&q2.add(c);const f=t(u,c),m={...s,capture:!0},p=(x,w)=>{window.removeEventListener("pointerup",y,m),window.removeEventListener("pointercancel",b,m),_p.has(u)&&_p.delete(u),$2(x)&&typeof f=="function"&&f(x,{success:w})},y=x=>{p(x,u===window||u===document||n.useGlobalTarget||DD(u,x.target))},b=x=>{p(x,!1)};window.addEventListener("pointerup",y,m),window.addEventListener("pointercancel",b,m)};return i.forEach(c=>{(n.useGlobalTarget?window:c).addEventListener("pointerdown",o,s),WX(c)&&(c.addEventListener("focus",f=>nQ(f,s)),!JX(c)&&!c.hasAttribute("tabindex")&&(c.tabIndex=0))}),a}function $1(e){return zR(e)&&"ownerSVGElement"in e}const Cp=new WeakMap;let Ba;const OD=(e,t,n)=>(i,s)=>s&&s[0]?s[0][e+"Size"]:$1(i)&&"getBBox"in i?i.getBBox()[t]:i[n],sQ=OD("inline","width","offsetWidth"),rQ=OD("block","height","offsetHeight");function aQ({target:e,borderBoxSize:t}){var n;(n=Cp.get(e))==null||n.forEach(i=>{i(e,{get width(){return sQ(e,t)},get height(){return rQ(e,t)}})})}function oQ(e){e.forEach(aQ)}function lQ(){typeof ResizeObserver>"u"||(Ba=new ResizeObserver(oQ))}function cQ(e,t){Ba||lQ();const n=B1(e);return n.forEach(i=>{let s=Cp.get(i);s||(s=new Set,Cp.set(i,s)),s.add(t),Ba==null||Ba.observe(i)}),()=>{n.forEach(i=>{const s=Cp.get(i);s==null||s.delete(t),s!=null&&s.size||Ba==null||Ba.unobserve(i)})}}const Tp=new Set;let sc;function uQ(){sc=()=>{const e={get width(){return window.innerWidth},get height(){return window.innerHeight}};Tp.forEach(t=>t(e))},window.addEventListener("resize",sc)}function dQ(e){return Tp.add(e),sc||uQ(),()=>{Tp.delete(e),!Tp.size&&typeof sc=="function"&&(window.removeEventListener("resize",sc),sc=void 0)}}function H2(e,t){return typeof e=="function"?dQ(e):cQ(e,t)}function fQ(e){return $1(e)&&e.tagName==="svg"}const hQ=[...TD,Kn,qs],pQ=e=>hQ.find(CD(e)),V2=()=>({translate:0,scale:1,origin:0,originPoint:0}),rc=()=>({x:V2(),y:V2()}),K2=()=>({min:0,max:0}),Qn=()=>({x:K2(),y:K2()}),mQ=new WeakMap;function Um(e){return e!==null&&typeof e=="object"&&typeof e.start=="function"}function Ld(e){return typeof e=="string"||Array.isArray(e)}const q1=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],H1=["initial",...q1];function Fm(e){return Um(e.animate)||H1.some(t=>Ld(e[t]))}function LD(e){return!!(Fm(e)||e.variants)}function gQ(e,t,n){for(const i in t){const s=t[i],a=n[i];if(fi(s))e.addValue(i,s);else if(fi(a))e.addValue(i,Lc(s,{owner:e}));else if(a!==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,Lc(o!==void 0?o:s,{owner:e}))}}for(const i in n)t[i]===void 0&&e.removeValue(i);return t}const Y0={current:null},ID={current:!1},yQ=typeof window<"u";function bQ(){if(ID.current=!0,!!yQ)if(window.matchMedia){const e=window.matchMedia("(prefers-reduced-motion)"),t=()=>Y0.current=e.matches;e.addEventListener("change",t),t()}else Y0.current=!1}const G2=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];let om={};function PD(e){om=e}function xQ(){return om}class vQ{scrapeMotionValuesFromProps(t,n,i){return{}}constructor({parent:t,props:n,presenceContext:i,reducedMotionConfig:s,skipAnimations:a,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=D1,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=_i.now();this.renderScheduledAt<b&&(this.renderScheduledAt=b,un.render(this.render,!1,!0))};const{latestValues:f,renderState:m}=c;this.latestValues=f,this.baseTarget={...f},this.initialValues=n.initial?{...f}:{},this.renderState=m,this.parent=t,this.props=n,this.presenceContext=i,this.depth=t?t.depth+1:0,this.reducedMotionConfig=s,this.skipAnimationsConfig=a,this.options=u,this.blockInitialAnimation=!!o,this.isControllingVariants=Fm(n),this.isVariantNode=LD(n),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(t&&t.current);const{willChange:p,...y}=this.scrapeMotionValuesFromProps(n,{},this);for(const b in y){const x=y[b];f[b]!==void 0&&fi(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,mQ.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,a)=>this.bindToMotionValue(a,s)),this.reducedMotionConfig==="never"?this.shouldReduceMotion=!1:this.reducedMotionConfig==="always"?this.shouldReduceMotion=!0:(ID.current||bQ(),this.shouldReduceMotion=Y0.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(),no(this.notifyUpdate),no(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&&xD.has(t)&&this.current instanceof HTMLElement){const{factory:o,keyframes:c,times:u,ease:f,duration:m}=n.accelerate,p=new yD({element:this.current,name:t,keyframes:c,times:u,ease:f,duration:ss(m)}),y=o(p);this.valueSubscriptions.set(t,()=>{y(),p.cancel()});return}const i=Qc.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 a;typeof window<"u"&&window.MotionCheckAppearSync&&(a=window.MotionCheckAppearSync(this,t,n)),this.valueSubscriptions.set(t,()=>{s(),a&&a()})}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 om){const n=om[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 a=this.features[t];a.isMounted?a.update():(a.mount(),a.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):Qn()}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<G2.length;i++){const s=G2[i];this.propEventSubscriptions[s]&&(this.propEventSubscriptions[s](),delete this.propEventSubscriptions[s]);const a="on"+s,o=t[a];o&&(this.propEventSubscriptions[s]=this.on(s,o))}this.prevMotionValues=gQ(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=Lc(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"&&(PR(i)||BR(i))?i=parseFloat(i):!pQ(i)&&qs.test(n)&&(i=jD(t,n)),this.setBaseTarget(t,fi(i)?i.get():i)),fi(i)?i.get():i}setBaseTarget(t,n){this.baseTarget[t]=n}getBaseTarget(t){var a;const{initial:n}=this.props;let i;if(typeof n=="string"||typeof n=="object"){const o=I1(this.props,n,(a=this.presenceContext)==null?void 0:a.custom);o&&(i=o[t])}if(n&&i!==void 0)return i;const s=this.getBaseTargetFromProps(this.props,t);return s!==void 0&&!fi(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 k1),this.events[t].add(n)}notify(t,...n){this.events[t]&&this.events[t].notify(...n)}scheduleRenderMicrotask(){U1.render(this.render)}}class zD extends vQ{constructor(){super(...arguments),this.KeyframeResolver=GX}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;fi(t)&&(this.childSubscription=t.on("change",n=>{this.current&&(this.current.textContent=`${n}`)}))}}class oo{constructor(t){this.isMounted=!1,this.node=t}update(){}}function BD({top:e,left:t,right:n,bottom:i}){return{x:{min:t,max:n},y:{min:e,max:i}}}function wQ({x:e,y:t}){return{top:t.min,right:e.max,bottom:t.max,left:e.min}}function EQ(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 cx(e){return e===void 0||e===1}function X0({scale:e,scaleX:t,scaleY:n}){return!cx(e)||!cx(t)||!cx(n)}function Ro(e){return X0(e)||UD(e)||e.z||e.rotate||e.rotateX||e.rotateY||e.skewX||e.skewY}function UD(e){return W2(e.x)||W2(e.y)}function W2(e){return e&&e!=="0%"}function lm(e,t,n){const i=e-n,s=t*i;return n+s}function Y2(e,t,n,i,s){return s!==void 0&&(e=lm(e,s,i)),lm(e,n,i)+t}function Q0(e,t=0,n=1,i,s){e.min=Y2(e.min,t,n,i,s),e.max=Y2(e.max,t,n,i,s)}function FD(e,{x:t,y:n}){Q0(e.x,t.translate,t.scale,t.originPoint),Q0(e.y,n.translate,n.scale,n.originPoint)}const X2=.999999999999,Q2=1.0000000000001;function SQ(e,t,n,i=!1){var c;const s=n.length;if(!s)return;t.x=t.y=1;let a,o;for(let u=0;u<s;u++){a=n[u],o=a.projectionDelta;const{visualElement:f}=a.options;f&&f.props.style&&f.props.style.display==="contents"||(i&&a.options.layoutScroll&&a.scroll&&a!==a.root&&(dr(e.x,-a.scroll.offset.x),dr(e.y,-a.scroll.offset.y)),o&&(t.x*=o.x.scale,t.y*=o.y.scale,FD(e,o)),i&&Ro(a.latestValues)&&Ap(e,a.latestValues,(c=a.layout)==null?void 0:c.layoutBox))}t.x<Q2&&t.x>X2&&(t.x=1),t.y<Q2&&t.y>X2&&(t.y=1)}function dr(e,t){e.min+=t,e.max+=t}function Z2(e,t,n,i,s=.5){const a=cn(e.min,e.max,s);Q0(e,t,n,a,i)}function J2(e,t){return typeof e=="string"?parseFloat(e)/100*(t.max-t.min):e}function Ap(e,t,n){const i=n??e;Z2(e.x,J2(t.x,i.x),t.scaleX,t.scale,t.originX),Z2(e.y,J2(t.y,i.y),t.scaleY,t.scale,t.originY)}function $D(e,t){return BD(EQ(e.getBoundingClientRect(),t))}function kQ(e,t,n){const i=$D(e,n),{scroll:s}=t;return s&&(dr(i.x,s.offset.x),dr(i.y,s.offset.y)),i}const NQ={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},_Q=Xc.length;function CQ(e,t,n){let i="",s=!0;for(let o=0;o<_Q;o++){const c=Xc[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 m=parseFloat(u);f=c.startsWith("scale")?m===1:m===0}if(!f||n){const m=W0(u,am[c]);if(!f){s=!1;const p=NQ[c]||c;i+=`${p}(${m}) `}n&&(t[c]=m)}}const a=e.pathRotation;return a&&(s=!1,i+=`rotate(${W0(a,am.pathRotation)}) `),i=i.trim(),n?i=n(t,s?"":i):s&&(i="none"),i}function V1(e,t,n){const{style:i,vars:s,transformOrigin:a}=e;let o=!1,c=!1;for(const u in t){const f=t[u];if(Qc.has(u)){o=!0;continue}else if(eD(u)){s[u]=f;continue}else{const m=W0(f,am[u]);u.startsWith("origin")?(c=!0,a[u]=m):i[u]=m}}if(t.transform||(o||n?i.transform=CQ(t,e.transform,n):i.transform&&(i.transform="none")),c){const{originX:u="50%",originY:f="50%",originZ:m=0}=a;i.transformOrigin=`${u} ${f} ${m}`}}function qD(e,{style:t,vars:n},i,s){const a=e.style;let o;for(o in t)a[o]=t[o];s==null||s.applyProjectionStyles(a,i);for(o in n)a.setProperty(o,n[o])}function eC(e,t){return t.max===t.min?0:e/(t.max-t.min)*100}const id={correct:(e,t)=>{if(!t.target)return e;if(typeof e=="string")if(Ke.test(e))e=parseFloat(e);else return e;const n=eC(e,t.target.x),i=eC(e,t.target.y);return`${n}% ${i}%`}},TQ={correct:(e,{treeScale:t,projectionDelta:n})=>{const i=e,s=qs.parse(e);if(s.length>5)return i;const a=qs.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),a(s)}},Z0={borderRadius:{...id,applyTo:[...z1]},borderTopLeftRadius:id,borderTopRightRadius:id,borderBottomLeftRadius:id,borderBottomRightRadius:id,boxShadow:TQ};function HD(e,{layout:t,layoutId:n}){return Qc.has(e)||e.startsWith("origin")||(t||n!==void 0)&&(!!Z0[e]||e==="opacity")}function K1(e,t,n){var o;const i=e.style,s=t==null?void 0:t.style,a={};if(!i)return a;for(const c in i)(fi(i[c])||s&&fi(s[c])||HD(c,e)||((o=n==null?void 0:n.getValue(c))==null?void 0:o.liveStyle)!==void 0)&&(a[c]=i[c]);return a}function AQ(e){return window.getComputedStyle(e)}class jQ extends zD{constructor(){super(...arguments),this.type="html",this.renderInstance=qD}readValueFromInstance(t,n){var i;if(Qc.has(n))return(i=this.projection)!=null&&i.isProjecting?P0(n):YY(t,n);{const s=AQ(t),a=(eD(n)?s.getPropertyValue(n):s[n])||0;return typeof a=="string"?a.trim():a}}measureInstanceViewportBox(t,{transformPagePoint:n}){return $D(t,n)}build(t,n,i){V1(t,n,i.transformTemplate)}scrapeMotionValuesFromProps(t,n,i){return K1(t,n,i)}}const MQ={offset:"stroke-dashoffset",array:"stroke-dasharray"},RQ={offset:"strokeDashoffset",array:"strokeDasharray"};function DQ(e,t,n=1,i=0,s=!0){e.pathLength=1;const a=s?MQ:RQ;e[a.offset]=`${-i}`,e[a.array]=`${t} ${n}`}const OQ=["offsetDistance","offsetPath","offsetRotate","offsetAnchor"];function VD(e,{attrX:t,attrY:n,attrScale:i,pathLength:s,pathSpacing:a=1,pathOffset:o=0,...c},u,f,m){if(V1(e,c,f),u){e.style.viewBox&&(e.attrs.viewBox=e.style.viewBox);return}e.attrs=e.style,e.style={};const{attrs:p,style:y}=e;p.transform&&(y.transform=p.transform,delete p.transform),(y.transform||p.transformOrigin)&&(y.transformOrigin=p.transformOrigin??"50% 50%",delete p.transformOrigin),y.transform&&(y.transformBox=(m==null?void 0:m.transformBox)??"fill-box",delete p.transformBox);for(const b of OQ)p[b]!==void 0&&(y[b]=p[b],delete p[b]);t!==void 0&&(p.x=t),n!==void 0&&(p.y=n),i!==void 0&&(p.scale=i),s!==void 0&&DQ(p,s,a,o,!1)}const KD=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"]),GD=e=>typeof e=="string"&&e.toLowerCase()==="svg";function LQ(e,t,n,i){qD(e,t,void 0,i);for(const s in t.attrs)e.setAttribute(KD.has(s)?s:P1(s),t.attrs[s])}function WD(e,t,n){const i=K1(e,t,n);for(const s in e)if(fi(e[s])||fi(t[s])){const a=Xc.indexOf(s)!==-1?"attr"+s.charAt(0).toUpperCase()+s.substring(1):s;i[a]=e[s]}return i}class IQ extends zD{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=Qn}getBaseTargetFromProps(t,n){return t[n]}readValueFromInstance(t,n){if(Qc.has(n)){const i=AD(n);return i&&i.default||0}return n=KD.has(n)?n:P1(n),t.getAttribute(n)}scrapeMotionValuesFromProps(t,n,i){return WD(t,n,i)}build(t,n,i){VD(t,n,this.isSVGTag,i.transformTemplate,i.style)}renderInstance(t,n,i,s){LQ(t,n,i,s)}mount(t){this.isSVGTag=GD(t.tagName),super.mount(t)}}const PQ=H1.length;function YD(e){if(!e)return;if(!e.isControllingVariants){const n=e.parent?YD(e.parent)||{}:{};return e.props.initial!==void 0&&(n.initial=e.props.initial),n}const t={};for(let n=0;n<PQ;n++){const i=H1[n],s=e.props[i];(Ld(s)||s===!1)&&(t[i]=s)}return t}function XD(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 zQ=[...q1].reverse(),BQ=q1.length;function UQ(e){return t=>Promise.all(t.map(({animation:n,options:i})=>IX(e,n,i)))}function FQ(e){let t=UQ(e),n=tC(),i=!0,s=!1;const a=f=>(m,p)=>{var b;const y=Qo(e,p,f==="exit"?(b=e.presenceContext)==null?void 0:b.custom:void 0);if(y){const{transition:x,transitionEnd:w,...E}=y;m={...m,...E,...w}}return m};function o(f){t=f(e)}function c(f){const{props:m}=e,p=YD(e.parent)||{},y=[],b=new Set;let x={},w=1/0;for(let v=0;v<BQ;v++){const _=zQ[v],k=n[_],T=m[_]!==void 0?m[_]:p[_],A=Ld(T),j=_===f?k.isActive:null;j===!1&&(w=v);let M=T===p[_]&&T!==m[_]&&A;if(M&&(i||s)&&e.manuallyAnimateOnMount&&(M=!1),k.protectedKeys={...x},!k.isActive&&j===null||!T&&!k.prevProp||Um(T)||typeof T=="boolean")continue;if(_==="exit"&&k.isActive&&j!==!0){k.prevResolvedValues&&(x={...x,...k.prevResolvedValues});continue}const D=$Q(k.prevProp,T);let I=D||_===f&&k.isActive&&!M&&A||v>w&&A,P=!1;const U=Array.isArray(T)?T:[T];let q=U.reduce(a(_),{});j===!1&&(q={});const{prevResolvedValues:V={}}=k,O={...V,...q},R=X=>{I=!0,b.has(X)&&(P=!0,b.delete(X)),k.needsAnimating[X]=!0;const K=e.getValue(X);K&&(K.liveStyle=!1)};for(const X in O){const K=q[X],B=V[X];if(x.hasOwnProperty(X))continue;let F=!1;q0(K)&&q0(B)?F=!XD(K,B)||D:F=K!==B,F?K!=null?R(X):b.add(X):K!==void 0&&b.has(X)?R(X):k.protectedKeys[X]=!0}k.prevProp=T,k.prevResolvedValues=q,k.isActive&&(x={...x,...q}),(i||s)&&e.blockInitialAnimation&&(I=!1);const z=M&&D;I&&(!z||P)&&y.push(...U.map(X=>{const K={type:_};if(typeof X=="string"&&(i||s)&&!z&&e.manuallyAnimateOnMount&&e.parent){const{parent:B}=e,F=Qo(B,X);if(B.enteringChildren&&F){const{delayChildren:W}=F.transition||{};K.delay=vD(B.enteringChildren,e,W)}}return{animation:X,options:K}}))}if(b.size){const v={};if(typeof m.initial!="boolean"){const _=Qo(e,Array.isArray(m.initial)?m.initial[0]:m.initial);_&&_.transition&&(v.transition=_.transition)}b.forEach(_=>{const k=e.getBaseTarget(_),T=e.getValue(_);T&&(T.liveStyle=!0),v[_]=k??null}),y.push({animation:v})}let E=!!y.length;return i&&(m.initial===!1||m.initial===m.animate)&&!e.manuallyAnimateOnMount&&(E=!1),i=!1,s=!1,E?t(y):Promise.resolve()}function u(f,m){var y;if(n[f].isActive===m)return Promise.resolve();(y=e.variantChildren)==null||y.forEach(b=>{var x;return(x=b.animationState)==null?void 0:x.setActive(f,m)}),n[f].isActive=m;const p=c(f);for(const b in n)n[b].protectedKeys={};return p}return{animateChanges:c,setActive:u,setAnimateFunction:o,getState:()=>n,reset:()=>{n=tC(),s=!0}}}function $Q(e,t){return typeof t=="string"?t!==e:Array.isArray(t)?!XD(t,e):!1}function Co(e=!1){return{isActive:e,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function tC(){return{animate:Co(!0),whileInView:Co(),whileHover:Co(),whileTap:Co(),whileDrag:Co(),whileFocus:Co(),exit:Co()}}function J0(e,t){e.min=t.min,e.max=t.max}function Rs(e,t){J0(e.x,t.x),J0(e.y,t.y)}function nC(e,t){e.translate=t.translate,e.scale=t.scale,e.originPoint=t.originPoint,e.origin=t.origin}const QD=1e-4,qQ=1-QD,HQ=1+QD,ZD=.01,VQ=0-ZD,KQ=0+ZD;function Ci(e){return e.max-e.min}function GQ(e,t,n){return Math.abs(e-t)<=n}function iC(e,t,n,i=.5){e.origin=i,e.originPoint=cn(t.min,t.max,e.origin),e.scale=Ci(n)/Ci(t),e.translate=cn(n.min,n.max,e.origin)-e.originPoint,(e.scale>=qQ&&e.scale<=HQ||isNaN(e.scale))&&(e.scale=1),(e.translate>=VQ&&e.translate<=KQ||isNaN(e.translate))&&(e.translate=0)}function Ed(e,t,n,i){iC(e.x,t.x,n.x,i?i.originX:void 0),iC(e.y,t.y,n.y,i?i.originY:void 0)}function sC(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+Ci(t)}function WQ(e,t,n,i){sC(e.x,t.x,n.x,i==null?void 0:i.x),sC(e.y,t.y,n.y,i==null?void 0:i.y)}function rC(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+Ci(t)}function cm(e,t,n,i){rC(e.x,t.x,n.x,i==null?void 0:i.x),rC(e.y,t.y,n.y,i==null?void 0:i.y)}function aC(e,t,n,i,s){return e-=t,e=lm(e,1/n,i),s!==void 0&&(e=lm(e,1/s,i)),e}function YQ(e,t=0,n=1,i=.5,s,a=e,o=e){if(hr.test(t)&&(t=parseFloat(t),t=cn(o.min,o.max,t/100)-o.min),typeof t!="number")return;let c=cn(a.min,a.max,i);e===a&&(c-=t),e.min=aC(e.min,t,n,c,s),e.max=aC(e.max,t,n,c,s)}function oC(e,t,[n,i,s],a,o){YQ(e,t[n],t[i],t[s],t.scale,a,o)}const XQ=["x","scaleX","originX"],QQ=["y","scaleY","originY"];function lC(e,t,n,i){oC(e.x,t,XQ,n?n.x:void 0,i?i.x:void 0),oC(e.y,t,QQ,n?n.y:void 0,i?i.y:void 0)}function cC(e){return e.translate===0&&e.scale===1}function JD(e){return cC(e.x)&&cC(e.y)}function uC(e,t){return e.min===t.min&&e.max===t.max}function ZQ(e,t){return uC(e.x,t.x)&&uC(e.y,t.y)}function dC(e,t){return Math.round(e.min)===Math.round(t.min)&&Math.round(e.max)===Math.round(t.max)}function eO(e,t){return dC(e.x,t.x)&&dC(e.y,t.y)}function fC(e){return Ci(e.x)/Ci(e.y)}function hC(e,t){return e.translate===t.translate&&e.scale===t.scale&&e.originPoint===t.originPoint}function or(e){return[e("x"),e("y")]}function JQ(e,t,n){let i="";const s=e.x.translate/t.x,a=e.y.translate/t.y,o=(n==null?void 0:n.z)||0;if((s||a||o)&&(i=`translate3d(${s}px, ${a}px, ${o}px) `),(t.x!==1||t.y!==1)&&(i+=`scale(${1/t.x}, ${1/t.y}) `),n){const{transformPerspective:f,rotate:m,pathRotation:p,rotateX:y,rotateY:b,skewX:x,skewY:w}=n;f&&(i=`perspective(${f}px) ${i}`),m&&(i+=`rotate(${m}deg) `),p&&(i+=`rotate(${p}deg) `),y&&(i+=`rotateX(${y}deg) `),b&&(i+=`rotateY(${b}deg) `),x&&(i+=`skewX(${x}deg) `),w&&(i+=`skewY(${w}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 eZ=z1.length,pC=e=>typeof e=="string"?parseFloat(e):e,mC=e=>typeof e=="number"||Ke.test(e);function tZ(e,t,n,i,s,a){s?(e.opacity=cn(0,n.opacity??1,nZ(i)),e.opacityExit=cn(t.opacity??1,0,iZ(i))):a&&(e.opacity=cn(t.opacity??1,n.opacity??1,i));for(let o=0;o<eZ;o++){const c=z1[o];let u=gC(t,c),f=gC(n,c);if(u===void 0&&f===void 0)continue;u||(u=0),f||(f=0),u===0||f===0||mC(u)===mC(f)?(e[c]=Math.max(cn(pC(u),pC(f),i),0),(hr.test(f)||hr.test(u))&&(e[c]+="%")):e[c]=f}(t.rotate||n.rotate)&&(e.rotate=cn(t.rotate||0,n.rotate||0,i))}function gC(e,t){return e[t]!==void 0?e[t]:e.borderRadius}const nZ=tO(0,.5,WR),iZ=tO(.5,.95,ws);function tO(e,t,n){return i=>i<e?0:i>t?1:n(Dd(e,t,i))}function sZ(e,t,n){const i=fi(e)?e:Lc(e);return i.start(L1("",i,t,n)),i.animation}function Id(e,t,n,i={passive:!0}){return e.addEventListener(t,n,i),()=>e.removeEventListener(t,n,i)}const rZ=(e,t)=>e.depth-t.depth;class aZ{constructor(){this.children=[],this.isDirty=!1}add(t){E1(this.children,t),this.isDirty=!0}remove(t){tm(this.children,t),this.isDirty=!0}forEach(t){this.isDirty&&this.children.sort(rZ),this.isDirty=!1,this.children.forEach(t)}}function oZ(e,t){const n=_i.now(),i=({timestamp:s})=>{const a=s-n;a>=t&&(no(i),e(a-t))};return un.setup(i,!0),()=>no(i)}function jp(e){return fi(e)?e.get():e}class lZ{constructor(){this.members=[]}add(t){E1(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&&(tm(this.members,i),i.unmount())}t.scheduleRender()}remove(t){if(tm(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:a}=i.options,{layoutDependency:o}=t.options;(a===void 0||a!==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,a,o;(i=(n=t.options).onExitComplete)==null||i.call(n),(o=(s=t.resumingFrom)==null?void 0:(a=s.options).onExitComplete)==null||o.call(a)})}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 Mp={hasAnimatedSinceResize:!0,hasEverUpdated:!1},ux=["","X","Y","Z"],cZ=1e3;let uZ=0;function dx(e,t,n,i){const{latestValues:s}=t;s[e]&&(n[e]=s[e],t.setStaticValue(e,0),i&&(i[e]=0))}function nO(e){if(e.hasCheckedOptimisedAppear=!0,e.root===e)return;const{visualElement:t}=e.options;if(!t)return;const n=ND(t);if(window.MotionHasOptimisedAnimation(n,"transform")){const{layout:s,layoutId:a}=e.options;window.MotionCancelOptimisedAnimation(n,"transform",un,!(s||a))}const{parent:i}=e;i&&!i.hasCheckedOptimisedAppear&&nO(i)}function iO({attachResizeListener:e,defaultParent:t,measureScroll:n,checkIsScrollRoot:i,resetTransform:s}){return class{constructor(o={},c=t==null?void 0:t()){this.id=uZ++,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(hZ),this.nodes.forEach(xZ),this.nodes.forEach(vZ),this.nodes.forEach(pZ)},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 aZ)}addEventListener(o,c){return this.eventHandlers.has(o)||this.eventHandlers.set(o,new k1),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=$1(o)&&!fQ(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 m,p=0;const y=()=>this.root.updateBlockedByResize=!1;un.read(()=>{p=window.innerWidth}),e(o,()=>{const b=window.innerWidth;b!==p&&(p=b,this.root.updateBlockedByResize=!0,m&&m(),m=oZ(y,250),Mp.hasAnimatedSinceResize&&(Mp.hasAnimatedSinceResize=!1,this.nodes.forEach(xC)))})}c&&this.root.registerSharedNode(c,this),this.options.animate!==!1&&f&&(c||u)&&this.addEventListener("didUpdate",({delta:m,hasLayoutChanged:p,hasRelativeLayoutChanged:y,layout:b})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const x=this.options.transition||f.getDefaultTransition()||NZ,{onLayoutAnimationStart:w,onLayoutAnimationComplete:E}=f.getProps(),v=!this.targetLayout||!eO(this.targetLayout,b),_=!p&&y;if(this.options.layoutRoot||this.resumeFrom||_||p&&(v||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);const k={...O1(x,"layout"),onPlay:w,onComplete:E};(f.shouldReduceMotion||this.options.layoutRoot)&&(k.delay=0,k.type=!1),this.startAnimation(k),this.setAnimationOrigin(m,_,k.path)}else p||xC(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(),no(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(wZ),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&&nO(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let m=0;m<this.path.length;m++){const p=this.path[m];p.shouldResetTransform=!0,(typeof p.latestValues.x=="string"||typeof p.latestValues.y=="string")&&(p.isLayoutDirty=!0),p.updateScroll("snapshot"),p.options.layoutRoot&&p.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(gZ),this.nodes.forEach(yC);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(bC);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(yZ),this.nodes.forEach(bZ),this.nodes.forEach(dZ),this.nodes.forEach(fZ)):this.nodes.forEach(bC),this.clearAllSnapshots();const c=_i.now();di.delta=gr(0,1e3/60,c-di.timestamp),di.timestamp=c,di.isProcessing=!0,nx.update.process(di),nx.preRender.process(di),nx.render.process(di),di.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,U1.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(mZ),this.sharedNodes.forEach(EZ)}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&&!Ci(this.snapshot.measuredBox.x)&&!Ci(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=Qn()),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&&!JD(this.projectionDelta),u=this.getTransformTemplate(),f=u?u(this.latestValues,""):void 0,m=f!==this.prevTransformTemplateValue;o&&this.instance&&(c||Ro(this.latestValues)||m)&&(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)),_Z(u),{animationId:this.root.animationId,measuredBox:c,layoutBox:u,latestValues:{},source:this.id}}measurePageBox(){var f;const{visualElement:o}=this.options;if(!o)return Qn();const c=o.measureViewportBox();if(!(((f=this.scroll)==null?void 0:f.wasRoot)||this.path.some(CZ))){const{scroll:m}=this.root;m&&(dr(c.x,m.offset.x),dr(c.y,m.offset.y))}return c}removeElementScroll(o){var u;const c=Qn();if(Rs(c,o),(u=this.scroll)!=null&&u.wasRoot)return c;for(let f=0;f<this.path.length;f++){const m=this.path[f],{scroll:p,options:y}=m;m!==this.root&&p&&y.layoutScroll&&(p.wasRoot&&Rs(c,o),dr(c.x,p.offset.x),dr(c.y,p.offset.y))}return c}applyTransform(o,c=!1,u){var m,p;const f=u||Qn();Rs(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&&(dr(f.x,-b.scroll.offset.x),dr(f.y,-b.scroll.offset.y)),Ro(b.latestValues)&&Ap(f,b.latestValues,(m=b.layout)==null?void 0:m.layoutBox)}return Ro(this.latestValues)&&Ap(f,this.latestValues,(p=this.layout)==null?void 0:p.layoutBox),f}removeTransform(o){var u;const c=Qn();Rs(c,o);for(let f=0;f<this.path.length;f++){const m=this.path[f];if(!Ro(m.latestValues))continue;let p;m.instance&&(X0(m.latestValues)&&m.updateSnapshot(),p=Qn(),Rs(p,m.measurePageBox())),lC(c,m.latestValues,(u=m.snapshot)==null?void 0:u.layoutBox,p)}return Ro(this.latestValues)&&lC(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!==di.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:m,layoutId:p}=this.options;if(!this.layout||!(m||p))return;this.resolvedRelativeTargetAt=di.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=Qn(),this.targetWithTransforms=Qn()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),WQ(this.target,this.relativeTarget,this.relativeParent.target,this.options.layoutAnchor||void 0)):this.targetDelta?(this.resumingFrom?this.applyTransform(this.layout.layoutBox,!1,this.target):Rs(this.target,this.layout.layoutBox),FD(this.target,this.targetDelta)):Rs(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||X0(this.parent.latestValues)||UD(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=Qn(),this.relativeTargetOrigin=Qn(),cm(this.relativeTargetOrigin,c,u,this.options.layoutAnchor||void 0),Rs(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===di.timestamp&&(u=!1),u)return;const{layout:f,layoutId:m}=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||m))return;Rs(this.layoutCorrected,this.layout.layoutBox);const p=this.treeScale.x,y=this.treeScale.y;SQ(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=Qn());const{target:b}=o;if(!b){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(nC(this.prevProjectionDelta.x,this.projectionDelta.x),nC(this.prevProjectionDelta.y,this.projectionDelta.y)),Ed(this.projectionDelta,this.layoutCorrected,b,this.latestValues),(this.treeScale.x!==p||this.treeScale.y!==y||!hC(this.projectionDelta.x,this.prevProjectionDelta.x)||!hC(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=rc(),this.projectionDelta=rc(),this.projectionDeltaWithTransform=rc()}setAnimationOrigin(o,c=!1,u){const f=this.snapshot,m=f?f.latestValues:{},p={...this.latestValues},y=rc();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!c;const b=Qn(),x=f?f.source:void 0,w=this.layout?this.layout.source:void 0,E=x!==w,v=this.getStack(),_=!v||v.members.length<=1,k=!!(E&&!_&&this.options.crossfade===!0&&!this.path.some(kZ));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):(vC(y.x,o.x,M),vC(y.y,o.y,M)),this.setTargetDelta(y),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(cm(b,this.layout.layoutBox,this.relativeParent.layout.layoutBox,this.options.layoutAnchor||void 0),SZ(this.relativeTarget,this.relativeTargetOrigin,b,M),T&&ZQ(this.relativeTarget,T)&&(this.isProjectionDirty=!1),T||(T=Qn()),Rs(T,this.relativeTarget)),E&&(this.animationValues=p,tZ(p,m,this.latestValues,M,k,_)),D&&D.rotate!==void 0&&(this.animationValues||(this.animationValues=p),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&&(no(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=un.update(()=>{Mp.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=Lc(0)),this.motionValue.jump(0,!1),this.currentAnimation=sZ(this.motionValue,[0,1e3],{...o,velocity:0,isSync:!0,onUpdate:m=>{this.mixTargetDelta(m),o.onUpdate&&o.onUpdate(m)},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(cZ),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const o=this.getLead();let{targetWithTransforms:c,target:u,layout:f,latestValues:m}=o;if(!(!c||!u||!f)){if(this!==o&&this.layout&&f&&sO(this.options.animationType,this.layout.layoutBox,f.layoutBox)){u=this.target||Qn();const p=Ci(this.layout.layoutBox.x);u.x.min=o.target.x.min,u.x.max=u.x.min+p;const y=Ci(this.layout.layoutBox.y);u.y.min=o.target.y.min,u.y.max=u.y.min+y}Rs(c,u),Ap(c,m),Ed(this.projectionDeltaWithTransform,this.layoutCorrected,c,m)}}registerSharedNode(o,c){this.sharedNodes.has(o)||this.sharedNodes.set(o,new lZ),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&&dx("z",o,f,this.animationValues);for(let m=0;m<ux.length;m++)dx(`rotate${ux[m]}`,o,f,this.animationValues),dx(`skew${ux[m]}`,o,f,this.animationValues);o.render();for(const m in f)o.setStaticValue(m,f[m]),this.animationValues&&(this.animationValues[m]=f[m]);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=jp(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=jp(c==null?void 0:c.pointerEvents)||""),this.hasProjected&&!Ro(this.latestValues)&&(o.transform=u?u({},""):"none",this.hasProjected=!1);return}o.visibility="";const m=f.animationValues||f.latestValues;this.applyTransformsToTarget();let p=JQ(this.projectionDeltaWithTransform,this.treeScale,m);u&&(p=u(m,p)),o.transform=p;const{x:y,y:b}=this.projectionDelta;o.transformOrigin=`${y.origin*100}% ${b.origin*100}% 0`,f.animationValues?o.opacity=f===this?m.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:m.opacityExit:o.opacity=f===this?m.opacity!==void 0?m.opacity:"":m.opacityExit!==void 0?m.opacityExit:0;for(const x in Z0){if(m[x]===void 0)continue;const{correct:w,applyTo:E,isCSSVariable:v}=Z0[x],_=p==="none"?m[x]:w(m[x],f);if(E){const k=E.length;for(let T=0;T<k;T++)o[E[T]]=_}else v?this.options.visualElement.renderState.vars[x]=_:o[x]=_}this.options.layoutId&&(o.pointerEvents=f===this?jp(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(yC),this.root.sharedNodes.clear()}}}function dZ(e){e.updateLayout()}function fZ(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:a}=e.options,o=t.source!==e.layout.source;if(a==="size")or(p=>{const y=o?t.measuredBox[p]:t.layoutBox[p],b=Ci(y);y.min=i[p].min,y.max=y.min+b});else if(a==="x"||a==="y"){const p=a==="x"?"y":"x";J0(o?t.measuredBox[p]:t.layoutBox[p],i[p])}else sO(a,t.layoutBox,i)&&or(p=>{const y=o?t.measuredBox[p]:t.layoutBox[p],b=Ci(i[p]);y.max=y.min+b,e.relativeTarget&&!e.currentAnimation&&(e.isProjectionDirty=!0,e.relativeTarget[p].max=e.relativeTarget[p].min+b)});const c=rc();Ed(c,i,t.layoutBox);const u=rc();o?Ed(u,e.applyTransform(s,!0),t.measuredBox):Ed(u,i,t.layoutBox);const f=!JD(c);let m=!1;if(!e.resumeFrom){const p=e.getClosestProjectingParent();if(p&&!p.resumeFrom){const{snapshot:y,layout:b}=p;if(y&&b){const x=e.options.layoutAnchor||void 0,w=Qn();cm(w,t.layoutBox,y.layoutBox,x);const E=Qn();cm(E,i,b.layoutBox,x),eO(w,E)||(m=!0),p.options.layoutRoot&&(e.relativeTarget=E,e.relativeTargetOrigin=w,e.relativeParent=p)}}}e.notifyListeners("didUpdate",{layout:i,snapshot:t,delta:u,layoutDelta:c,hasLayoutChanged:f,hasRelativeLayoutChanged:m})}else if(e.isLead()){const{onExitComplete:i}=e.options;i&&i()}e.options.transition=void 0}function hZ(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 pZ(e){e.isProjectionDirty=e.isSharedProjectionDirty=e.isTransformDirty=!1}function mZ(e){e.clearSnapshot()}function yC(e){e.clearMeasurements()}function gZ(e){e.isLayoutDirty=!0,e.updateLayout()}function bC(e){e.isLayoutDirty=!1}function yZ(e){e.isAnimationBlocked&&e.layout&&!e.isLayoutDirty&&(e.snapshot=e.layout,e.isLayoutDirty=!0)}function bZ(e){const{visualElement:t}=e.options;t&&t.getProps().onBeforeLayoutMeasure&&t.notify("BeforeLayoutMeasure"),e.resetTransform()}function xC(e){e.finishAnimation(),e.targetDelta=e.relativeTarget=e.target=void 0,e.isProjectionDirty=!0}function xZ(e){e.resolveTargetDelta()}function vZ(e){e.calcProjection()}function wZ(e){e.resetSkewAndRotation()}function EZ(e){e.removeLeadSnapshot()}function vC(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 wC(e,t,n,i){e.min=cn(t.min,n.min,i),e.max=cn(t.max,n.max,i)}function SZ(e,t,n,i){wC(e.x,t.x,n.x,i),wC(e.y,t.y,n.y,i)}function kZ(e){return e.animationValues&&e.animationValues.opacityExit!==void 0}const NZ={duration:.45,ease:[.4,0,.1,1]},EC=e=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(e),SC=EC("applewebkit/")&&!EC("chrome/")?Math.round:ws;function kC(e){e.min=SC(e.min),e.max=SC(e.max)}function _Z(e){kC(e.x),kC(e.y)}function sO(e,t,n){return e==="position"||e==="preserve-aspect"&&!GQ(fC(t),fC(n),.2)}function CZ(e){var t;return e!==e.root&&((t=e.scroll)==null?void 0:t.wasRoot)}const TZ=iO({attachResizeListener:(e,t)=>Id(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}),fx={current:void 0},rO=iO({measureScroll:e=>({x:e.scrollLeft,y:e.scrollTop}),defaultParent:()=>{if(!fx.current){const e=new TZ({});e.mount(window),e.setOptions({layoutScroll:!0}),fx.current=e}return fx.current},resetTransform:(e,t)=>{e.style.transform=t!==void 0?t:"none"},checkIsScrollRoot:e=>window.getComputedStyle(e).position==="fixed"}),aO=C.createContext({transformPagePoint:e=>e,isStatic:!1,reducedMotion:"never"});function AZ(e=!0){const t=C.useContext(w1);if(t===null)return[!0,null];const{isPresent:n,onExitComplete:i,register:s}=t,a=C.useId();C.useEffect(()=>{if(e)return s(a)},[e]);const o=C.useCallback(()=>e&&i&&i(a),[a,i,e]);return!n&&i?[!1,o]:[!0]}const oO=C.createContext({strict:!1}),NC={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 _C=!1;function jZ(){if(_C)return;const e={};for(const t in NC)e[t]={isEnabled:n=>NC[t].some(i=>!!n[i])};PD(e),_C=!0}function lO(){return jZ(),xQ()}function MZ(e){const t=lO();for(const n in e)t[n]={...t[n],...e[n]};PD(t)}const RZ=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 um(e){return e.startsWith("while")||e.startsWith("drag")&&e!=="draggable"||e.startsWith("layout")||e.startsWith("onTap")||e.startsWith("onPan")||e.startsWith("onLayout")||RZ.has(e)}let cO=e=>!um(e);function DZ(e){typeof e=="function"&&(cO=t=>t.startsWith("on")?!um(t):e(t))}try{DZ(require("@emotion/is-prop-valid").default)}catch{}function OZ(e,t,n){const i={};for(const s in e)s==="values"&&typeof e.values=="object"||fi(e[s])||(cO(s)||n===!0&&um(s)||!t&&!um(s)||e.draggable&&s.startsWith("onDrag"))&&(i[s]=e[s]);return i}const $m=C.createContext({});function LZ(e,t){if(Fm(e)){const{initial:n,animate:i}=e;return{initial:n===!1||Ld(n)?n:void 0,animate:Ld(i)?i:void 0}}return e.inherit!==!1?t:{}}function IZ(e){const{initial:t,animate:n}=LZ(e,C.useContext($m));return C.useMemo(()=>({initial:t,animate:n}),[CC(t),CC(n)])}function CC(e){return Array.isArray(e)?e.join(" "):e}const G1=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function uO(e,t,n){for(const i in t)!fi(t[i])&&!HD(i,n)&&(e[i]=t[i])}function PZ({transformTemplate:e},t){return C.useMemo(()=>{const n=G1();return V1(n,t,e),Object.assign({},n.vars,n.style)},[t])}function zZ(e,t){const n=e.style||{},i={};return uO(i,n,e),Object.assign(i,PZ(e,t)),i}function BZ(e,t){const n={},i=zZ(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 dO=()=>({...G1(),attrs:{}});function UZ(e,t,n,i){const s=C.useMemo(()=>{const a=dO();return VD(a,t,GD(i),e.transformTemplate,e.style),{...a.attrs,style:{...a.style}}},[t]);if(e.style){const a={};uO(a,e.style,e),s.style={...a,...s.style}}return s}const FZ=["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 W1(e){return typeof e!="string"||e.includes("-")?!1:!!(FZ.indexOf(e)>-1||/[A-Z]/u.test(e))}function $Z(e,t,n,{latestValues:i},s,a=!1,o){const u=(o??W1(e)?UZ:BZ)(t,i,s,e),f=OZ(t,typeof e=="string",a),m=e!==C.Fragment?{...f,...u,ref:n}:{},{children:p}=t,y=C.useMemo(()=>fi(p)?p.get():p,[p]);return C.createElement(e,{...m,children:y})}function qZ({scrapeMotionValuesFromProps:e,createRenderState:t},n,i,s){return{latestValues:HZ(n,i,s,e),renderState:t()}}function HZ(e,t,n,i){const s={},a=i(e,{});for(const y in a)s[y]=jp(a[y]);let{initial:o,animate:c}=e;const u=Fm(e),f=LD(e);t&&f&&!u&&e.inherit!==!1&&(o===void 0&&(o=t.initial),c===void 0&&(c=t.animate));let m=n?n.initial===!1:!1;m=m||o===!1;const p=m?c:o;if(p&&typeof p!="boolean"&&!Um(p)){const y=Array.isArray(p)?p:[p];for(let b=0;b<y.length;b++){const x=I1(e,y[b]);if(x){const{transitionEnd:w,transition:E,...v}=x;for(const _ in v){let k=v[_];if(Array.isArray(k)){const T=m?k.length-1:0;k=k[T]}k!==null&&(s[_]=k)}for(const _ in w)s[_]=w[_]}}}return s}const fO=e=>(t,n)=>{const i=C.useContext($m),s=C.useContext(w1),a=()=>qZ(e,t,i,s);return n?a():$W(a)},VZ=fO({scrapeMotionValuesFromProps:K1,createRenderState:G1}),KZ=fO({scrapeMotionValuesFromProps:WD,createRenderState:dO}),GZ=Symbol.for("motionComponentSymbol");function WZ(e,t,n){const i=C.useRef(n);C.useInsertionEffect(()=>{i.current=n});const s=C.useRef(null);return C.useCallback(a=>{var c;a&&((c=e.onMount)==null||c.call(e,a)),t&&(a?t.mount(a):t.unmount());const o=i.current;if(typeof o=="function")if(a){const u=o(a);typeof u=="function"&&(s.current=u)}else s.current?(s.current(),s.current=null):o(a);else o&&(o.current=a)},[t])}const hO=C.createContext({});function nc(e){return e&&typeof e=="object"&&Object.prototype.hasOwnProperty.call(e,"current")}function YZ(e,t,n,i,s,a){var k,T;const{visualElement:o}=C.useContext($m),c=C.useContext(oO),u=C.useContext(w1),f=C.useContext(aO),m=f.reducedMotion,p=f.skipAnimations,y=C.useRef(null),b=C.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:m,skipAnimations:p,isSVG:a}),b.current&&y.current&&(y.current.manuallyAnimateOnMount=!0));const x=y.current,w=C.useContext(hO);x&&!x.projection&&s&&(x.type==="html"||x.type==="svg")&&XZ(y.current,n,s,w);const E=C.useRef(!1);C.useInsertionEffect(()=>{x&&E.current&&x.update(n,u)});const v=n[kD],_=C.useRef(!!v&&typeof window<"u"&&!((k=window.MotionHandoffIsComplete)!=null&&k.call(window,v))&&((T=window.MotionHasOptimisedAnimation)==null?void 0:T.call(window,v)));return HW(()=>{b.current=!0,x&&(E.current=!0,window.MotionIsMounted=!0,x.updateFeatures(),x.scheduleRenderMicrotask(),_.current&&x.animationState&&x.animationState.animateChanges())}),C.useEffect(()=>{x&&(!_.current&&x.animationState&&x.animationState.animateChanges(),_.current&&(queueMicrotask(()=>{var A;(A=window.MotionHandoffMarkAsComplete)==null||A.call(window,v)}),_.current=!1),x.enteringChildren=void 0)}),x}function XZ(e,t,n,i){const{layoutId:s,layout:a,drag:o,dragConstraints:c,layoutScroll:u,layoutRoot:f,layoutAnchor:m,layoutCrossfade:p}=t;e.projection=new n(e.latestValues,t["data-framer-portal-id"]?void 0:pO(e.parent)),e.projection.setOptions({layoutId:s,layout:a,alwaysMeasureLayout:!!o||c&&nc(c),visualElement:e,animationType:typeof a=="string"?a:"both",initialPromotionConfig:i,crossfade:p,layoutScroll:u,layoutRoot:f,layoutAnchor:m})}function pO(e){if(e)return e.options.allowProjection!==!1?e.projection:pO(e.parent)}function hx(e,{forwardMotionProps:t=!1,type:n}={},i,s){i&&MZ(i);const a=n?n==="svg":W1(e),o=a?KZ:VZ;function c(f,m){let p;const y={...C.useContext(aO),...f,layoutId:QZ(f)},{isStatic:b}=y,x=IZ(f),w=o(f,b);if(!b&&typeof window<"u"){ZZ();const E=JZ(y);p=E.MeasureLayout,x.visualElement=YZ(e,w,y,s,E.ProjectionNode,a)}return d.jsxs($m.Provider,{value:x,children:[p&&x.visualElement?d.jsx(p,{visualElement:x.visualElement,...y}):null,$Z(e,f,WZ(w,x.visualElement,m),w,b,t,a)]})}c.displayName=`motion.${typeof e=="string"?e:`create(${e.displayName??e.name??""})`}`;const u=C.forwardRef(c);return u[GZ]=e,u}function QZ({layoutId:e}){const t=C.useContext(IR).id;return t&&e!==void 0?t+"-"+e:e}function ZZ(e,t){C.useContext(oO).strict}function JZ(e){const t=lO(),{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 eJ(e,t){if(typeof Proxy>"u")return hx;const n=new Map,i=(a,o)=>hx(a,o,e,t),s=(a,o)=>i(a,o);return new Proxy(s,{get:(a,o)=>o==="create"?i:(n.has(o)||n.set(o,hx(o,void 0,e,t)),n.get(o))})}const tJ=(e,t)=>t.isSVG??W1(e)?new IQ(t):new jQ(t,{allowProjection:e!==C.Fragment});class nJ extends oo{constructor(t){super(t),t.animationState||(t.animationState=FQ(t))}updateAnimationControlsSubscription(){const{animate:t}=this.node.getProps();Um(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 iJ=0;class sJ extends oo{constructor(){super(...arguments),this.id=iJ++,this.isExitComplete=!1}update(){var a;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=Qo(this.node,o,c);if(u){const{transition:f,transitionEnd:m,...p}=u;for(const y in p)(a=this.node.getValue(y))==null||a.jump(p[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 rJ={animation:{Feature:nJ},exit:{Feature:sJ}};function yf(e){return{point:{x:e.pageX,y:e.pageY}}}const aJ=e=>t=>F1(t)&&e(t,yf(t));function Sd(e,t,n,i){return Id(e,t,aJ(n),i)}const mO=({current:e})=>e?e.ownerDocument.defaultView:null,TC=(e,t)=>Math.abs(e-t);function oJ(e,t){const n=TC(e.x,t.x),i=TC(e.y,t.y);return Math.sqrt(n**2+i**2)}const AC=new Set(["auto","scroll"]);class gO{constructor(t,n,{transformPagePoint:i,contextWindow:s=window,dragSnapToOrigin:a=!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=Qh(this.lastRawMoveEventInfo,this.transformPagePoint));const x=px(this.lastMoveEventInfo,this.history),w=this.startEvent!==null,E=oJ(x.offset,{x:0,y:0})>=this.distanceThreshold;if(!w&&!E)return;const{point:v}=x,{timestamp:_}=di;this.history.push({...v,timestamp:_});const{onStart:k,onMove:T}=this.handlers;w||(k&&k(this.lastMoveEvent,x),this.startEvent=this.lastMoveEvent),T&&T(this.lastMoveEvent,x)},this.handlePointerMove=(x,w)=>{this.lastMoveEvent=x,this.lastRawMoveEventInfo=w,this.lastMoveEventInfo=Qh(w,this.transformPagePoint),un.update(this.updatePoint,!0)},this.handlePointerUp=(x,w)=>{this.end();const{onEnd:E,onSessionEnd:v,resumeAnimation:_}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&_&&_(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const k=px(x.type==="pointercancel"?this.lastMoveEventInfo:Qh(w,this.transformPagePoint),this.history);this.startEvent&&E&&E(x,k),v&&v(x,k)},!F1(t))return;this.dragSnapToOrigin=a,this.handlers=n,this.transformPagePoint=i,this.distanceThreshold=o,this.contextWindow=s||window;const u=yf(t),f=Qh(u,this.transformPagePoint),{point:m}=f,{timestamp:p}=di;this.history=[{...m,timestamp:p}];const{onSessionStart:y}=n;y&&y(t,px(f,this.history));const b={passive:!0,capture:!0};this.removeListeners=pf(Sd(this.contextWindow,"pointermove",this.handlePointerMove,b),Sd(this.contextWindow,"pointerup",this.handlePointerUp,b),Sd(this.contextWindow,"pointercancel",this.handlePointerUp,b)),c&&this.startScrollTracking(c)}startScrollTracking(t){let n=t.parentElement;for(;n;){const i=getComputedStyle(n);(AC.has(i.overflowX)||AC.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},a={x:s.x-n.x,y:s.y-n.y};a.x===0&&a.y===0||(i?this.lastMoveEventInfo&&(this.lastMoveEventInfo.point.x+=a.x,this.lastMoveEventInfo.point.y+=a.y):this.history.length>0&&(this.history[0].x-=a.x,this.history[0].y-=a.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(),no(this.updatePoint)}}function Qh(e,t){return t?{point:t(e.point)}:e}function jC(e,t){return{x:e.x-t.x,y:e.y-t.y}}function px({point:e},t){return{point:e,delta:jC(e,yO(t)),offset:jC(e,lJ(t)),velocity:cJ(t,.1)}}function lJ(e){return e[0]}function yO(e){return e[e.length-1]}function cJ(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,i=null;const s=yO(e);for(;n>=0&&(i=e[n],!(s.timestamp-i.timestamp>ss(t)));)n--;if(!i)return{x:0,y:0};i===e[0]&&e.length>2&&s.timestamp-i.timestamp>ss(t)*2&&(i=e[1]);const a=vs(s.timestamp-i.timestamp);if(a===0)return{x:0,y:0};const o={x:(s.x-i.x)/a,y:(s.y-i.y)/a};return o.x===1/0&&(o.x=0),o.y===1/0&&(o.y=0),o}function uJ(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 MC(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 dJ(e,{top:t,left:n,bottom:i,right:s}){return{x:MC(e.x,n,s),y:MC(e.y,t,i)}}function RC(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 fJ(e,t){return{x:RC(e.x,t.x),y:RC(e.y,t.y)}}function hJ(e,t){let n=.5;const i=Ci(e),s=Ci(t);return s>i?n=Dd(t.min,t.max-i,e.min):i>s&&(n=Dd(e.min,e.max-s,t.min)),gr(0,1,n)}function pJ(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 ev=.35;function mJ(e=ev){return e===!1?e=0:e===!0&&(e=ev),{x:DC(e,"left","right"),y:DC(e,"top","bottom")}}function DC(e,t,n){return{min:OC(e,t),max:OC(e,n)}}function OC(e,t){return typeof e=="number"?e:e[t]||0}const gJ=new WeakMap;class yJ{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=Qn(),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 a=p=>{n&&this.snapToCursor(yf(p).point),this.stopAnimation()},o=(p,y)=>{const{drag:b,dragPropagation:x,onDragStart:w}=this.getProps();if(b&&!x&&(this.openDragLock&&this.openDragLock(),this.openDragLock=YX(b),!this.openDragLock))return;this.latestPointerEvent=p,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),or(v=>{let _=this.getAxisMotionValue(v).get()||0;if(hr.test(_)){const{projection:k}=this.visualElement;if(k&&k.layout){const T=k.layout.layoutBox[v];T&&(_=Ci(T)*(parseFloat(_)/100))}}this.originPoint[v]=_}),w&&un.update(()=>w(p,y),!1,!0),H0(this.visualElement,"transform");const{animationState:E}=this.visualElement;E&&E.setActive("whileDrag",!0)},c=(p,y)=>{this.latestPointerEvent=p,this.latestPanInfo=y;const{dragPropagation:b,dragDirectionLock:x,onDirectionLock:w,onDrag:E}=this.getProps();if(!b&&!this.openDragLock)return;const{offset:v}=y;if(x&&this.currentDirection===null){this.currentDirection=xJ(v),this.currentDirection!==null&&w&&w(this.currentDirection);return}this.updateAxis("x",y.point,v),this.updateAxis("y",y.point,v),this.visualElement.render(),E&&un.update(()=>E(p,y),!1,!0)},u=(p,y)=>{this.latestPointerEvent=p,this.latestPanInfo=y,this.stop(p,y),this.latestPointerEvent=null,this.latestPanInfo=null},f=()=>{const{dragSnapToOrigin:p}=this.getProps();(p||this.constraints)&&this.startAnimation({x:0,y:0})},{dragSnapToOrigin:m}=this.getProps();this.panSession=new gO(t,{onSessionStart:a,onStart:o,onMove:c,onSessionEnd:u,resumeAnimation:f},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:m,distanceThreshold:i,contextWindow:mO(this.visualElement),element:this.visualElement.current})}stop(t,n){const i=t||this.latestPointerEvent,s=n||this.latestPanInfo,a=this.isDragging;if(this.cancel(),!a||!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||!Zh(t,s,this.currentDirection))return;const a=this.getAxisMotionValue(t);let o=this.originPoint[t]+i[t];this.constraints&&this.constraints[t]&&(o=uJ(o,this.constraints[t],this.elastic[t])),a.set(o)}resolveConstraints(){var a;const{dragConstraints:t,dragElastic:n}=this.getProps(),i=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):(a=this.visualElement.projection)==null?void 0:a.layout,s=this.constraints;t&&nc(t)?this.constraints||(this.constraints=this.resolveRefConstraints()):t&&i?this.constraints=dJ(i.layoutBox,t):this.constraints=!1,this.elastic=mJ(n),s!==this.constraints&&!nc(t)&&i&&this.constraints&&!this.hasMutatedConstraints&&or(o=>{this.constraints!==!1&&this.getAxisMotionValue(o)&&(this.constraints[o]=pJ(i.layoutBox[o],this.constraints[o]))})}resolveRefConstraints(){const{dragConstraints:t,onMeasureDragConstraints:n}=this.getProps();if(!t||!nc(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 a=kQ(i,s.root,this.visualElement.getTransformPagePoint());let o=fJ(s.layout.layoutBox,a);if(n){const c=n(wQ(o));this.hasMutatedConstraints=!!c,c&&(o=BD(c))}return o}startAnimation(t){const{drag:n,dragMomentum:i,dragElastic:s,dragTransition:a,dragSnapToOrigin:o,onDragTransitionEnd:c}=this.getProps(),u=this.constraints||{},f=or(m=>{if(!Zh(m,n,this.currentDirection))return;let p=u&&u[m]||{};(o===!0||o===m)&&(p={min:0,max:0});const y=s?200:1e6,b=s?40:1e7,x={type:"inertia",velocity:i?t[m]:0,bounceStiffness:y,bounceDamping:b,timeConstant:750,restDelta:1,restSpeed:10,...a,...p};return this.startAxisValueAnimation(m,x)});return Promise.all(f).then(c)}startAxisValueAnimation(t,n){const i=this.getAxisMotionValue(t);return H0(this.visualElement,t),i.start(L1(t,i,0,n,this.visualElement,!1))}stopAnimation(){or(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){or(n=>{const{drag:i}=this.getProps();if(!Zh(n,i,this.currentDirection))return;const{projection:s}=this.visualElement,a=this.getAxisMotionValue(n);if(s&&s.layout){const{min:o,max:c}=s.layout.layoutBox[n],u=a.get()||0;a.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(!nc(n)||!i||!this.constraints)return;this.stopAnimation();const s={x:0,y:0};or(o=>{const c=this.getAxisMotionValue(o);if(c&&this.constraints!==!1){const u=c.get();s[o]=hJ({min:u,max:u},this.constraints[o])}});const{transformTemplate:a}=this.visualElement.getProps();this.visualElement.current.style.transform=a?a({},""):"none",i.root&&i.root.updateScroll(),i.updateLayout(),this.constraints=!1,this.resolveConstraints(),or(o=>{if(!Zh(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;gJ.set(this.visualElement,this);const t=this.visualElement.current,n=Sd(t,"pointerdown",f=>{const{drag:m,dragListener:p=!0}=this.getProps(),y=f.target,b=y!==t&&tQ(y);m&&p&&!b&&this.start(f)});let i;const s=()=>{const{dragConstraints:f}=this.getProps();nc(f)&&f.current&&(this.constraints=this.resolveRefConstraints(),i||(i=bJ(t,f.current,()=>this.scalePositionWithinConstraints())))},{projection:a}=this.visualElement,o=a.addEventListener("measure",s);a&&!a.layout&&(a.root&&a.root.updateScroll(),a.updateLayout()),un.read(s);const c=Id(window,"resize",()=>this.scalePositionWithinConstraints()),u=a.addEventListener("didUpdate",(({delta:f,hasLayoutChanged:m})=>{this.isDragging&&m&&(or(p=>{const y=this.getAxisMotionValue(p);y&&(this.originPoint[p]+=f[p].translate,y.set(y.get()+f[p].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:a=!1,dragElastic:o=ev,dragMomentum:c=!0}=t;return{...t,drag:n,dragDirectionLock:i,dragPropagation:s,dragConstraints:a,dragElastic:o,dragMomentum:c}}}function LC(e){let t=!0;return()=>{if(t){t=!1;return}e()}}function bJ(e,t,n){const i=H2(e,LC(n)),s=H2(t,LC(n));return()=>{i(),s()}}function Zh(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function xJ(e,t=10){let n=null;return Math.abs(e.y)>t?n="y":Math.abs(e.x)>t&&(n="x"),n}class vJ extends oo{constructor(t){super(t),this.removeGroupControls=ws,this.removeListeners=ws,this.controls=new yJ(t)}mount(){const{dragControls:t}=this.node.getProps();t&&(this.removeGroupControls=t.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||ws}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 mx=e=>(t,n)=>{e&&un.update(()=>e(t,n),!1,!0)};class wJ extends oo{constructor(){super(...arguments),this.removePointerDownListener=ws}onPointerDown(t){this.session=new gO(t,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:mO(this.node)})}createPanHandlers(){const{onPanSessionStart:t,onPanStart:n,onPan:i,onPanEnd:s}=this.node.getProps();return{onSessionStart:mx(t),onStart:mx(n),onMove:mx(i),onEnd:(a,o)=>{delete this.session,s&&un.postRender(()=>s(a,o))}}}mount(){this.removePointerDownListener=Sd(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 gx=!1;class EJ extends C.Component{componentDidMount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:i,layoutId:s}=this.props,{projection:a}=t;a&&(n.group&&n.group.add(a),i&&i.register&&s&&i.register(a),gx&&a.root.didUpdate(),a.addEventListener("animationComplete",()=>{this.safeToRemove()}),a.setOptions({...a.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),Mp.hasEverUpdated=!0}getSnapshotBeforeUpdate(t){const{layoutDependency:n,visualElement:i,drag:s,isPresent:a}=this.props,{projection:o}=i;return o&&(o.isPresent=a,t.layoutDependency!==n&&o.setOptions({...o.options,layoutDependency:n}),gx=!0,s||t.layoutDependency!==n||n===void 0||t.isPresent!==a?o.willUpdate():this.safeToRemove(),t.isPresent!==a&&(a?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(),U1.postRender(()=>{!i.currentAnimation&&i.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:i}=this.props,{projection:s}=t;gx=!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 bO(e){const[t,n]=AZ(),i=C.useContext(IR);return d.jsx(EJ,{...e,layoutGroup:i,switchLayoutGroup:C.useContext(hO),isPresent:t,safeToRemove:n})}const SJ={pan:{Feature:wJ},drag:{Feature:vJ,ProjectionNode:rO,MeasureLayout:bO}};function IC(e,t,n){const{props:i}=e;e.animationState&&i.whileHover&&e.animationState.setActive("whileHover",n==="Start");const s="onHover"+n,a=i[s];a&&un.postRender(()=>a(t,yf(t)))}class kJ extends oo{mount(){const{current:t}=this.node;t&&(this.unmount=QX(t,(n,i)=>(IC(this.node,i,"Start"),s=>IC(this.node,s,"End"))))}unmount(){}}class NJ extends oo{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=pf(Id(this.node.current,"focus",()=>this.onFocus()),Id(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function PC(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),a=i[s];a&&un.postRender(()=>a(t,yf(t)))}class _J extends oo{mount(){const{current:t}=this.node;if(!t)return;const{globalTapTarget:n,propagate:i}=this.node.props;this.unmount=iQ(t,(s,a)=>(PC(this.node,a,"Start"),(o,{success:c})=>PC(this.node,o,c?"End":"Cancel")),{useGlobalTarget:n,stopPropagation:(i==null?void 0:i.tap)===!1})}unmount(){}}const tv=new WeakMap,yx=new WeakMap,CJ=e=>{const t=tv.get(e.target);t&&t(e)},TJ=e=>{e.forEach(CJ)};function AJ({root:e,...t}){const n=e||document;yx.has(n)||yx.set(n,{});const i=yx.get(n),s=JSON.stringify(t);return i[s]||(i[s]=new IntersectionObserver(TJ,{root:e,...t})),i[s]}function jJ(e,t,n){const i=AJ(t);return tv.set(e,n),i.observe(e),()=>{tv.delete(e),i.unobserve(e)}}const MJ={some:0,all:1};class RJ extends oo{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:a}=t,o={root:n?n.current:void 0,rootMargin:i,threshold:typeof s=="number"?s:MJ[s]},c=f=>{const{isIntersecting:m}=f;if(this.isInView===m||(this.isInView=m,a&&!m&&this.hasEnteredView))return;m&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",m);const{onViewportEnter:p,onViewportLeave:y}=this.node.getProps(),b=m?p:y;b&&b(f)};this.stopObserver=jJ(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(DJ(t,n))&&this.startObserver()}unmount(){var t;(t=this.stopObserver)==null||t.call(this),this.hasEnteredView=!1,this.isInView=!1}}function DJ({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}const OJ={inView:{Feature:RJ},tap:{Feature:_J},focus:{Feature:NJ},hover:{Feature:kJ}},LJ={layout:{ProjectionNode:rO,MeasureLayout:bO}},IJ={...rJ,...OJ,...SJ,...LJ},PJ=eJ(IJ,tJ),zJ={some:0,all:1};function BJ(e,t,{root:n,margin:i,amount:s="some"}={}){const a=B1(e),o=new WeakMap,c=f=>{f.forEach(m=>{const p=o.get(m.target);if(m.isIntersecting!==!!p)if(m.isIntersecting){const y=t(m.target,m);typeof y=="function"?o.set(m.target,y):u.unobserve(m.target)}else typeof p=="function"&&(p(m),o.delete(m.target))})},u=new IntersectionObserver(c,{root:n,rootMargin:i,threshold:typeof s=="number"?s:zJ[s]});return a.forEach(f=>u.observe(f)),()=>u.disconnect()}function UJ(e,{root:t,margin:n,amount:i,once:s=!1,initial:a=!1}={}){const[o,c]=C.useState(a);return C.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 BJ(e.current,u,f)},[t,e,n,s,i]),o}function Zc({children:e,index:t,className:n="",delay:i=.1,amount:s=.5,root:a}){const o=C.useRef(null),c=UJ(o,{amount:s,once:!1,root:a});return d.jsx(PJ.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 FJ(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 $J(){return typeof window>"u"?null:window.AudioContext??window.webkitAudioContext??null}function qJ(){const e=C.useRef(null),t=C.useRef(null),n=C.useRef(null),i=C.useRef(Promise.resolve()),s=C.useRef(!1),[a,o]=C.useState(null),c=C.useCallback(()=>{if(e.current)return e.current;const b=$J();if(!b)return null;const x=new b,w=x.createAnalyser();return w.fftSize=2048,w.connect(x.destination),e.current=x,t.current=w,o(w),x},[]),u=C.useCallback(()=>{const b=c();(b==null?void 0:b.state)==="suspended"&&b.resume()},[c]),f=C.useCallback(async(b,x)=>{const w=c(),E=t.current;if(!w||!E)throw new Error("no-audio-context");const v=await w.decodeAudioData(b.slice(0));x()&&(w.state==="suspended"&&await w.resume(),await new Promise(_=>{const k=w.createBufferSource();k.buffer=v,k.connect(E),n.current=k,k.onended=()=>{n.current===k&&(n.current=null),_()},k.start()}))},[c]),m=C.useCallback((b,x)=>new Promise(w=>{if(typeof window>"u"||!window.speechSynthesis||!x()){w();return}const E=new SpeechSynthesisUtterance(b);E.lang=navigator.language||"zh-CN",E.rate=1,E.onend=()=>w(),E.onerror=()=>w(),window.speechSynthesis.speak(E)}),[]),p=C.useCallback((b,x,w,E)=>{if(!b.trim()){w();return}const v=FJ(b);i.current=i.current.then(async()=>{try{if(!x())return;const _=await v;if(!x())return;if(_){s.current=!0,E==null||E();try{await f(_,x)}catch{}return}s.current||(E==null||E(),await m(b,x))}finally{w()}})},[f,m]),y=C.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 C.useEffect(()=>()=>{var b,x,w;try{(b=n.current)==null||b.stop()}catch{}typeof window<"u"&&((x=window.speechSynthesis)==null||x.cancel()),(w=e.current)==null||w.close()},[]),{enqueue:p,cancel:y,resume:u,analyser:a}}const HJ=900;function VJ({phase:e,inputAnalyser:t,outputAnalyser:n=null,outputText:i,thinkingConfig:s}){const a=C.useRef(null),o=C.useRef(e);return C.useEffect(()=>{var U;const c=a.current;if(!c)return;const u=c.getContext("2d");if(!u)return;const f=o.current;o.current=e;const m=performance.now(),p=((U=window.matchMedia)==null?void 0:U.call(window,"(prefers-reduced-motion: reduce)").matches)??!1,y=new Uint8Array(new ArrayBuffer((t==null?void 0:t.fftSize)??2048)),b=new Uint8Array(new ArrayBuffer((n==null?void 0:n.fftSize)??2048)),x=new Float32Array(256),w=new Float32Array(256);let E=0,v=0,_=0,k=1,T=0,A=0;const j=window.getComputedStyle(c),M={cyan:j.getPropertyValue("--voice-cyan").trim(),blue:j.getPropertyValue("--voice-blue").trim(),violet:j.getPropertyValue("--voice-violet").trim(),pink:j.getPropertyValue("--voice-pink").trim(),amber:j.getPropertyValue("--voice-amber").trim(),mint:j.getPropertyValue("--voice-mint").trim()},D=()=>{const q=c.getBoundingClientRect();k=Math.min(window.devicePixelRatio||1,2),v=Math.max(1,Math.round(q.width)),_=Math.max(1,Math.round(q.height)),c.width=Math.round(v*k),c.height=Math.round(_*k),u.setTransform(k,0,0,k,0,0)},I=q=>{const V=q/1e3,O=p?1:Math.min(1,(q-m)/HJ),R=O*O*(3-2*O);zC(t,y,x),zC(n,b,w),T+=(UC(x)-T)*.08,A+=(UC(w)-A)*.08,u.clearRect(0,0,v,_),R<1&&f!==e&&BC(u,f,v,_,V,1-R,x,w,T,A,i,M,s),BC(u,e,v,_,V,R,x,w,T,A,i,M,s),p||(E=window.requestAnimationFrame(I))};D(),I(performance.now());const P=typeof ResizeObserver>"u"?null:new ResizeObserver(()=>{D(),p&&I(performance.now())});return P==null||P.observe(c),window.addEventListener("resize",D),()=>{window.cancelAnimationFrame(E),P==null||P.disconnect(),window.removeEventListener("resize",D)}},[t,n,i,e,s]),d.jsx("canvas",{ref:a,className:"voice-canvas","aria-hidden":"true"})}function zC(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 a=t[Math.min(t.length-1,Math.floor(s*i))]??128;n[s]=(a-128)/128}}function BC(e,t,n,i,s,a,o,c,u,f,m,p,y){t==="idle"&&KJ(e,n,i,s,a,p),t==="listening"&&GJ(e,n,i,s,a,o,u,p),t==="thinking"&&WJ(e,n,i,s,a,p,y),t==="speaking"&&YJ(e,n,i,s,a,c,f,m,p)}function KJ(e,t,n,i,s,a){const o=[a.blue,a.violet];e.save(),e.globalCompositeOperation="screen",o.forEach((c,u)=>{e.beginPath();for(let f=0;f<=180;f+=1){const m=f/180,p=Math.sin(Math.PI*m),y=n/2+Math.sin(m*Math.PI*3+i*.42+u)*n*.018*p;f===0?e.moveTo(m*t,y):e.lineTo(m*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 GJ(e,t,n,i,s,a,o,c){const u=[c.cyan,c.blue,c.violet,c.pink,c.mint];e.save(),e.globalCompositeOperation="screen",u.forEach((f,m)=>{vO(e,t,n,i,m,u.length,f,s,.12+o*.62,.7,p=>xO(a,p))}),e.restore()}function WJ(e,t,n,i,s,a,o){const c=[a.pink,a.amber,a.violet,a.blue,a.cyan,a.mint],u=o.colors.length>0?o.colors:c,f=Math.min(8,Math.max(1,Math.round(o.count))),m=Array.from({length:f},(M,D)=>u[D%u.length]??a.violet),p=t/2,y=n/2,b=Math.min(t,n),x=Math.max(0,o.amplitude),w=Math.max(.2,o.waviness),E=Math.max(.1,o.scale),v=Math.max(0,o.saturation),_=Math.max(0,.4+o.intensity),k=`hue-rotate(${o.hueShift*360}deg) saturate(${v}) brightness(${_})`,T=Math.max(0,o.glow),A=T*(8+E*4),j=Math.min(.72,T*.16)*(.55+o.intensity*.45);e.save(),e.globalCompositeOperation="source-over",m.forEach((M,D)=>{const I=D%2===0?1:-1,P=i*Math.max(0,o.speed),U=P*(.72+D*.06)*I+D*(.92+o.spread*.2),q=D%3===0?-1:1,V=P*(1.5+D*.12)*q+D*.83,O=b*(.055+o.spread*.035+D%3*.01)*x,R=p+Math.cos(U*.78+D)*O,z=y+Math.sin(U*.66+D)*O*.72,G=b*(.14+o.thickness*.08+D%3*.012)*E,X=96,K=Math.max(2,Math.min(8,Math.round(2+w))),B=K+2,F=[];for(let me=0;me<X;me+=1){const se=me/X*Math.PI*2,Q=1+Math.sin(se*K+V)*x*.09+Math.cos(se*B-V*.74+D*.7)*x*.05;F.push({x:R+Math.cos(se+U)*G*Q,y:z+Math.sin(se+U)*G*Q*(.84+D%2*.07)})}const W=F[0],$=F[F.length-1];if(!W||!$)return;const ae=U+D*.47,xe=Math.cos(ae)*G*1.15,le=Math.sin(ae)*G*1.15,Ne=e.createLinearGradient(R-xe,z-le,R+xe,z+le),re=Math.max(1,u.length);for(let me=0;me<=re;me+=1){const se=u[(me+D)%u.length]??M;Ne.addColorStop(me/re,se)}e.beginPath(),e.moveTo(($.x+W.x)/2,($.y+W.y)/2);for(let me=0;me<F.length;me+=1){const se=F[me],Q=F[(me+1)%F.length];!se||!Q||e.quadraticCurveTo(se.x,se.y,(se.x+Q.x)/2,(se.y+Q.y)/2)}e.closePath(),A>0&&o.intensity>0&&[1.55,.72].forEach((me,se)=>{e.save(),e.globalCompositeOperation="screen",e.filter=`${k} blur(${A*me*(se===0?.58:.24)}px)`,e.fillStyle=Ne,e.globalAlpha=s*o.opacity*j*(se===0?.72:.92),e.fill(),e.restore()}),e.save(),e.globalCompositeOperation="screen",e.filter=k,e.fillStyle=Ne,e.globalAlpha=s*o.opacity*(.3+D%3*.025),e.fill(),e.restore()}),e.restore()}function YJ(e,t,n,i,s,a,o,c,u){const f=[u.mint,u.cyan,u.blue,u.violet,u.pink],m=o>.006;e.save(),e.globalCompositeOperation="screen",f.forEach((p,y)=>{vO(e,t,n,i*.86,y,f.length,p,s,.34+o*.36,1.45,b=>m?xO(a,b):XJ(c,b,i,y))}),e.restore()}function XJ(e,t,n,i){const s=e||"SPS",a=(n*1.6+t*s.length*.72+i*.46)%s.length,o=s.charCodeAt(Math.floor(a))||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 UC(e){let t=0;for(const n of e)t+=n*n;return Math.min(1,Math.sqrt(t/e.length)*3.2)}function xO(e,t){const n=Math.round(t*(e.length-1));let i=0,s=0;for(let a=-6;a<=6;a+=1){const o=Math.max(0,Math.min(e.length-1,n+a));i+=e[o]??0,s+=1}return i/s}function vO(e,t,n,i,s,a,o,c,u,f,m){const y=[],b=[],x=s%2===0?1:-1,w=s*1.18+i*(.32+s*.018)*x;for(let v=0;v<=84;v+=1){const _=v/84,k=Math.pow(Math.sin(Math.PI*_),.42),T=Math.pow(Math.sin(Math.PI*_),.9),A=Math.sin(_*Math.PI*(2.2+s*.18)+w),j=Math.sin(_*Math.PI*1.25-w*.58+s)*.38,M=m(_)*n*(.02+u*.025);y.push(n/2+(s-(a-1)/2)*n*.013+(A+j)*n*(.038+u*.038)*f*k+M*k),b.push(n*(.05+s*.005)*(.9+u*.38)*(.88+Math.sin(_*Math.PI*2-w)*.12)*T)}e.beginPath(),y.forEach((v,_)=>{const k=_/84*t,T=v-(b[_]??0);_===0?e.moveTo(k,T):e.lineTo(k,T)});for(let v=84;v>=0;v-=1)e.lineTo(v/84*t,(y[v]??n/2)+(b[v]??0));e.closePath();const E=e.createLinearGradient(0,0,t,0);E.addColorStop(0,"transparent"),E.addColorStop(.1,o),E.addColorStop(.9,o),E.addColorStop(1,"transparent"),e.fillStyle=E,e.globalAlpha=c*(.22+s*.03),e.shadowColor=o,e.shadowBlur=28+s*4,e.fill()}const QJ=[{id:"idle",labelKey:"home.phase.idle",icon:VB},{id:"listening",labelKey:"home.phase.listening",icon:Aj},{id:"thinking",labelKey:"home.phase.thinking",icon:DB},{id:"speaking",labelKey:"home.phase.speaking",icon:Bj}],Jh=["#f97316","#7c3aed","#06b6d4"],ud={idle:{colors:Jh,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:Jh,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:Jh,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:Jh,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}},ZJ=[{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 dd(e){return{...e,colors:[...e.colors]}}function JJ(){return{idle:dd(ud.idle),listening:dd(ud.listening),thinking:dd(ud.thinking),speaking:dd(ud.speaking)}}function eee(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 FC(e){return e.replace(/```[\s\S]*?```/g,"").replace(/[`*_>#\[\]()]/g,"").replace(/\s+/g," ").trim()}function nv(e){return/\.(png|jpe?g|gif|webp|svg|bmp|avif)$/i.test(e)}function wO(e){const t=e.lastIndexOf(".");return((t>=0?e.slice(t+1):"")||"file").toUpperCase().slice(0,5)}const EO="mcp__sps__present_form";function tee(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={...ex,title:e.title||ex.title,description:e.description??ex.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 nee(e){var n;if(!e)return null;const t=e.filter(i=>i.type==="tool_use"&&i.title===EO);return tee((n=t[t.length-1])==null?void 0:n.input)}function iee(e){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,a])=>({id:s,label:a.title??s,type:Array.isArray(a.enum)?"select":a.type==="boolean"?"toggle":a.type==="number"?"number":a.format==="textarea"?"textarea":"text",...Array.isArray(a.enum)?{options:a.enum.map(o=>({value:String(o),label:String(o)}))}:{},...a.default!==void 0?{default:a.default}:{},...n.has(s)?{required:!0}:{},...typeof a.description=="string"?{hint:a.description}:{}}));return{title:e.title,...t.description?{description:t.description}:{},submitLabel:"提交并继续",fields:i}}const SO="[表单已提交]",kO="[让 AI 来定";function see(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(SO)||s.startsWith(kO)))return!0}return!1}function ree(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(kO))return;if(s.startsWith(SO)){const a=s.match(/```json\s*([\s\S]*?)```/);if(!(a!=null&&a[1]))return;try{return JSON.parse(a[1])}catch{return}}}}}function aee({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,a=zm(e,i);return nv(i)&&n?d.jsx("button",{type:"button",className:"voice-msg-attach",title:s,onClick:()=>n(i),children:d.jsx("img",{src:a,alt:s})},i):d.jsx("a",{href:a,target:"_blank",rel:"noreferrer",className:"voice-msg-attach",title:s,children:nv(i)?d.jsx("img",{src:a,alt:s}):d.jsxs(d.Fragment,{children:[d.jsx(Rc,{size:22,strokeWidth:1.7,"aria-hidden":"true"}),d.jsx("span",{className:"voice-msg-attach-ext",children:wO(s)})]})},i)})})}const To="sps.home.session",oee=720*60*1e3;function lee(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 cee(e){if(!e)return"";try{return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}catch{return""}}function $C(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 bx({outputAnalyser:e=null}){var Ts,Er;const t=Xe(),{sessionId:n}=Iv(),[i,s]=C.useState("idle"),a=C.useRef("idle");a.current=i;const[o,c]=Yr("sps.voice.autoListen",!1),[u,f]=C.useState("idle"),[m,p]=C.useState(!1),[y,b]=C.useState(""),[x,w]=Yr("sps.sessions.listOpen",!1),[E,v]=C.useState(0),[_,k]=Yr("sps.sessions.originTab","all"),[T,A]=C.useState(!1),[j,M]=C.useState(!1),[D,I]=C.useState(""),[P,U]=C.useState(60),q=C.useRef(null),[V,O]=C.useState(()=>X$()?"draw":"done"),[R,z]=C.useState(JJ),G=C.useRef(null),X=C.useRef(null),K=C.useRef(null),B=C.useRef(null),F=C.useRef(!0),[W,$]=C.useState(!1),ae=C.useCallback(()=>{const Y=K.current;return!Y||Y.scrollHeight-Y.scrollTop-Y.clientHeight<40},[]),xe=C.useCallback(()=>{const Y=K.current;Y&&(typeof Y.scrollTo=="function"?Y.scrollTo({top:Y.scrollHeight,behavior:"smooth"}):Y.scrollTop=Y.scrollHeight),F.current=!0,$(!1)},[]),le=C.useCallback(()=>{const Y=K.current;Y&&(typeof Y.scrollTo=="function"?Y.scrollTo({top:Y.scrollHeight,behavior:"instant"}):Y.scrollTop=Y.scrollHeight)},[]),Ne=C.useCallback(()=>{const Y=ae();F.current=Y,$(!Y)},[ae]),re=C.useRef(0),me=C.useRef(0),se=C.useRef(0),Q=C.useRef(""),ye=C.useRef(!1),_e=C.useRef(!1),ze=C.useRef(!1),fe=kW(),Se=qJ(),Re=R[i],Qe=R[u],ht=Y=>{Y===me.current&&ye.current&&se.current===0&&s("idle")},it=Y=>{const Ae=FC(Y);if(!Ae)return;const Oe=me.current;se.current+=1,Se.enqueue(Ae,()=>Oe===me.current,()=>{Oe===me.current&&(se.current=Math.max(0,se.current-1),ht(Oe))})},Bt=Y=>{Q.current+=Y;let Ae=Q.current.match(/^([\s\S]*?[。!?.!?])([\s\S]*)$/);for(;Ae;)it(Ae[1]??""),Q.current=Ae[2]??"",Ae=Q.current.match(/^([\s\S]*?[。!?.!?])([\s\S]*)$/)},mt=()=>{me.current+=1,se.current=0,Q.current="",ye.current=!1,Se.cancel()},wt=Y=>{var Ae;(Ae=navigator.clipboard)==null||Ae.writeText(Y).catch(()=>{})},[Te,ct]=C.useState(null),ne=C.useRef(0),we=(Y,Ae)=>{if(Te&&Te.id===Y){ne.current+=1,mt(),ct(null);return}const Oe=FC(Ae);if(!Oe)return;ne.current+=1,mt();const gt=ne.current,pt=()=>gt===ne.current;Se.resume(),ct({id:Y,phase:"loading"}),Se.enqueue(Oe,pt,()=>{pt()&&ct(null)},()=>{pt()&&ct({id:Y,phase:"playing"})})},he=OW({onAssistantChunk:Y=>{_e.current=!0,ze.current&&(s("speaking"),Bt(Y))},onAssistantComplete:Y=>{ye.current=!0,ze.current&&(_e.current?Q.current.trim()&&it(Q.current):it(Y)),Q.current="",ht(me.current)},onError:()=>{b(t("home.error.response")),s("idle")},onThinking:()=>{mt(),_e.current=!1,b(""),s("thinking")}});C.useEffect(()=>{const Y=`sps.home.draft:${he.sessionId??"new"}`;I(localStorage.getItem(Y)??"")},[he.sessionId]);const Ve=C.useCallback(Y=>{I(Y);try{localStorage.setItem(`sps.home.draft:${he.sessionId??"new"}`,Y)}catch{}},[he.sessionId]),Ze=C.useCallback(()=>{I("");try{localStorage.removeItem(`sps.home.draft:${he.sessionId??"new"}`)}catch{}},[he.sessionId]);C.useEffect(()=>{const Y=localStorage.getItem(To);if(!Y)return;let Ae={};try{Ae=JSON.parse(Y)}catch{}if(!n){if(!Ae.id||!Ae.ts||Date.now()-Ae.ts>oee){localStorage.removeItem(To);return}kp(Ae.id).then(Oe=>{he.resume(Oe.id,$C(Oe.messages)),pe(Oe)}).catch(()=>localStorage.removeItem(To))}},[]),C.useEffect(()=>{he.sessionId&&localStorage.setItem(To,JSON.stringify({id:he.sessionId,ts:Date.now()}))},[he.sessionId,he.messages.length]);const[Ct,Gt]=C.useState([]),[ce,pe]=C.useState(null),[Ce,je]=C.useState(null),[qe,st]=C.useState(null),[Fe,et]=C.useState(!1);C.useEffect(()=>{if(!qe)return;const Y=Ae=>{Ae.key==="Escape"&&(Ae.preventDefault(),st(null))};return window.addEventListener("keydown",Y),()=>window.removeEventListener("keydown",Y)},[qe]),C.useEffect(()=>{if(!he.sessionId){pe(null),Gt([]);return}he.isSending||kp(he.sessionId).then(Y=>{Gt(Y.artifacts??[]),pe(Y)}).catch(()=>{})},[he.sessionId,he.isSending,he.messages.length]);const Qt=tn(),Wt=((Ts=at({queryKey:["chat-sessions"],queryFn:oW,refetchInterval:5e3}).data)==null?void 0:Ts.data)??[],Z=[...new Set(Wt.map(Y=>Y.origin??"sps"))].sort(),be=_!=="all"&&!Z.includes(_)?"all":_,Ie=be==="all"?Wt:Wt.filter(Y=>(Y.origin??"sps")===be),ut=Y=>Y.lastMessageAt??Y.createdAt,Yt=m0(Ie,ut,7),Tt=m0(Yt.older,ut,30),$e=Y=>Y.id===he.sessionId,Ue=[...Yt.recent,...E>=1?Tt.recent:Tt.recent.filter($e),...E>=2?Tt.older:Tt.older.filter($e)],ot=Tt.recent.length+Tt.older.length,hn=Tt.older.length,Zt=Y=>{Y!==he.sessionId&&kp(Y).then(Ae=>{he.resume(Y,$C(Ae.messages)),pe(Ae),Gt(Ae.artifacts??[]),s("idle"),b(""),localStorage.setItem(To,JSON.stringify({id:Y,ts:Date.now()}))}).catch(()=>{})};C.useEffect(()=>{n&&n!==he.sessionId&&Zt(n)},[n]);const Vi=Y=>{A(!1),_R({...Y,dedicated:!Y.cwd}).then(Ae=>{he.resume(Ae.id,[]),Gt([]),pe(null),et(!1),s("idle"),b(""),localStorage.setItem(To,JSON.stringify({id:Ae.id,ts:Date.now()})),Qt.invalidateQueries({queryKey:["chat-sessions"]})}).catch(()=>{})},Ys=(Y,Ae)=>{Ae.stopPropagation(),window.confirm(t("home.sessions.deleteConfirm"))&&lW(Y).then(()=>{Qt.invalidateQueries({queryKey:["chat-sessions"]}),Y===he.sessionId&&bn()}).catch(()=>{})},Jn=SW({onComplete:Y=>{fe.stop(),ze.current=!0;const Ae=xi.map(Oe=>Oe.path);F.current=!0,$(!1),he.send(Y,Ae.length?Ae:void 0),Ae.length&&hi([])},onError:Y=>{fe.stop(),b(t(Y==="unsupported"?"home.error.recognitionUnsupported":"home.error.recognition")),s("idle")}}),kn=C.useRef(Jn);kn.current=Jn;const mn=()=>{i!=="idle"||he.isSending||In||(b(""),Se.resume(),mt(),Jn.start()&&(s("listening"),fe.start()))},An=()=>{i==="listening"?Jn.stop():mn()},Ti=C.useRef(An);Ti.current=An;const Xs=Y=>{c(Y),b(""),Y?Se.resume():a.current==="idle"&&kn.current.isListening&&kn.current.cancel()};C.useEffect(()=>{if(!(o&&i==="idle"&&!j&&Jn.supported))return;const Ae=window.setTimeout(()=>{kn.current.isListening||kn.current.start()},400);return()=>{window.clearTimeout(Ae),a.current==="idle"&&kn.current.isListening&&kn.current.cancel()}},[o,i,j,Jn.supported]);const wr=()=>{i!=="idle"||he.isSending||In||kn.current.isListening&&(b(""),Se.resume(),mt(),s("listening"),fe.start())};AW({enabled:o,phase:i,suspended:j||he.isSending,analyser:fe.analyser,transcript:Jn.transcript,onTrigger:wr,onEndpoint:()=>kn.current.stop(),onAbort:()=>{kn.current.cancel(),fe.stop(),s("idle")}});const Qs=22,sa=18,_s=()=>{const Y=q.current;if(!Y)return;Y.style.height="auto";const Ae=Qs*3+sa,Oe=Math.min(Y.scrollHeight,Ae);Y.style.height=`${Oe}px`,Y.style.overflowY=Y.scrollHeight>Ae?"auto":"hidden",U(Math.max(60,Oe+16))},Zs=()=>{U(60);const Y=q.current;Y&&(Y.style.height="auto",Y.style.overflowY="hidden")},Bn=()=>{const Y=D.trim();if(!Y&&xi.length===0||he.isSending)return;const Ae=xi.map(Oe=>Oe.path);Ze(),Zs(),hi([]),b(""),ze.current=!1,F.current=!0,$(!1),he.send(Y,Ae.length?Ae:void 0)},Ai=i==="thinking"||i==="speaking",In=((ce==null?void 0:ce.readonly)??!1)&&(ce==null?void 0:ce.id)===he.sessionId,ri=j&&!Ai&&!In;C.useEffect(()=>{if(j||o||In)return;const Y=Ae=>{if(Ae.code!=="Space"&&Ae.key!==" "||Ae.repeat)return;const Oe=Ae.target;Oe&&(Oe.tagName==="INPUT"||Oe.tagName==="TEXTAREA"||Oe.isContentEditable)||(Ae.preventDefault(),Ti.current())};return window.addEventListener("keydown",Y),()=>window.removeEventListener("keydown",Y)},[j,o,In]);const bn=()=>{he.reset(),localStorage.removeItem(To),Gt([]),et(!1),s("idle"),b(""),Ze(),Zs()},ra=()=>{he.sessionId&&CR(he.sessionId).catch(()=>{}),mt(),s("idle")},[xi,hi]=C.useState([]),[Me,Ge]=C.useState(!1),[xt,Rt]=C.useState(!1),on=async Y=>{if(Y.size>jR){b(`文件超过 50 MB(${(Y.size/1024/1024).toFixed(1)} MB):${Y.name}`);return}Ge(!0);try{const Ae=await he.ensureSession(),Oe=await v2(Ae,Y);hi(gt=>[...gt,{path:Oe.path,name:Oe.name}])}catch(Ae){b(Ae instanceof Error?Ae.message:String(Ae))}finally{Ge(!1)}},Un=Y=>{hi(Ae=>Ae.filter(Oe=>Oe.path!==Y))};C.useEffect(()=>{var ji;const Y=G.current;if(!Y)return;if(((ji=window.matchMedia)==null?void 0:ji.call(window,"(prefers-reduced-motion: reduce)").matches)??!1){Y.style.setProperty("--voice-activity","0"),Y.style.setProperty("--voice-scale","1");return}let Oe=0,gt=new Uint8Array(new ArrayBuffer(2048));const pt=oa=>{const tt=i==="listening"?fe.analyser:i==="speaking"?Se.analyser??e:null;tt&&gt.length!==tt.fftSize&&(gt=new Uint8Array(new ArrayBuffer(tt.fftSize)));let la=tt?eee(tt,gt):0;if(!tt&&i==="speaking"){const $t=oa/1e3;la=.16+(.5+Math.sin($t*6.8)*.5)*.34+(.5+Math.sin($t*11.4+1.2)*.5)*.16}const jn=la>re.current?.16:.065;re.current+=(la-re.current)*jn,Y.style.setProperty("--voice-scale",(1+re.current*.065).toFixed(4)),Y.style.setProperty("--voice-activity",re.current.toFixed(3)),Oe=window.requestAnimationFrame(pt)};return Oe=window.requestAnimationFrame(pt),()=>window.cancelAnimationFrame(Oe)},[fe.analyser,Se.analyser,e,i]),C.useEffect(()=>{F.current&&le()},[i,Jn.transcript,he.messages,le]);const ei=he.messages.some(Y=>Y.status==="streaming");C.useEffect(()=>{if(!ei)return;let Y=0;const Ae=()=>{const Oe=K.current;Oe&&F.current&&Oe.scrollHeight-Oe.scrollTop-Oe.clientHeight>=1&&le(),Y=window.requestAnimationFrame(Ae)};return Y=window.requestAnimationFrame(Ae),()=>window.cancelAnimationFrame(Y)},[ei,le]),C.useEffect(()=>{if(je(null),!he.sessionId)return;F.current=!0,$(!1);const Y=window.setTimeout(()=>{F.current&&le()},400);return()=>window.clearTimeout(Y)},[he.sessionId]),C.useEffect(()=>{if(!m)return;const Y=Ae=>{Ae.key==="Escape"&&p(!1)};return window.addEventListener("keydown",Y),()=>window.removeEventListener("keydown",Y)},[m]),C.useEffect(()=>()=>{mt(),fe.stop()},[]);const ti=C.useMemo(()=>({amplitude:Re.amplitude,colors:Re.colors,count:Re.count,glow:Re.glow,hueShift:Re.hueShift,intensity:Re.intensity,opacity:Re.opacity,saturation:Re.saturation,scale:Re.scale,speed:Re.speed,spread:Re.spread,thickness:Re.thickness,waviness:Re.waviness}),[Re]),Vt=(Y,Ae)=>{if(!Number.isFinite(Ae))return;const Oe=Math.min(Y.max,Math.max(Y.min,Ae));z(gt=>({...gt,[u]:{...gt[u],[Y.key]:Oe}}))},ai=(Y,Ae)=>{z(Oe=>{const gt=[...Oe[u].colors];return gt[Y]=Ae,{...Oe,[u]:{...Oe[u],colors:gt}}})},aa=((Er=[...he.messages].reverse().find(Y=>Y.role==="assistant"))==null?void 0:Er.content)??"",Cs=i==="listening"&&fe.status==="requesting"?t("home.mic.requesting"):t(`home.phase.${i}`),os=he.messages.some(Y=>Y.role==="assistant"&&Y.status==="streaming");return d.jsxs("div",{className:"home-shell","data-list-open":x?"true":"false",children:[T&&d.jsx(FW,{onCancel:()=>A(!1),onCreate:Vi}),Ce&&he.sessionId&&d.jsx(mW,{sessionId:he.sessionId,path:Ce,onClose:()=>je(null)}),qe&&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:()=>st(null),children:d.jsxs("div",{className:"w-full max-w-lg max-h-[88vh] overflow-auto",onClick:Y=>Y.stopPropagation(),children:[qe.error&&d.jsxs("div",{className:"nb-card mb-2 px-3 py-2 text-xs text-[var(--color-crashed)]",children:["提交失败:",qe.error]}),d.jsx(wW,{spec:qe.spec,disabled:qe.readOnly,initialValues:qe.values,onSubmit:Y=>{const Ae=qe.interaction;if(Ae){const Oe=Object.fromEntries(Object.entries(Y).filter(([,pt])=>pt!==""&&pt!=null)),gt=he.sessionId;if(!gt)return;TR(gt,Ae.id,Oe,Ae.revision).then(()=>st(null)).catch(pt=>st(ji=>ji&&{...ji,values:Y,error:pt instanceof Error?pt.message:String(pt),panelKey:(ji.panelKey??0)+1}));return}he.send("[表单已提交]\n```json\n"+JSON.stringify(Y,null,2)+"\n```"),st(null)},onSkip:()=>{he.send("[让 AI 来定,按各字段推荐值 + 我们的对话补全,不用再逐项问我]"),st(null)},onUpload:async Y=>{const Ae=await he.ensureSession();return(await v2(Ae,Y)).path}},qe.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:()=>w(!1),"aria-label":t("home.sessions.collapse"),title:t("home.sessions.collapse"),children:d.jsx($N,{size:14,strokeWidth:2.2})})]})]}),Z.length>1&&d.jsxs("div",{className:"home-sessions-tabs",role:"tablist",children:[d.jsx("button",{type:"button",role:"tab","aria-selected":be==="all",className:`home-sessions-tab ${be==="all"?"is-active":""}`,onClick:()=>k("all"),children:t("home.sessions.tabAll")}),Z.map(Y=>d.jsx("button",{type:"button",role:"tab","aria-selected":be===Y,className:`home-sessions-tab ${be===Y?"is-active":""}`,onClick:()=>k(Y),children:Wj[Y]??Y},Y))]}),d.jsxs("div",{className:"home-sessions-list",children:[Ue.map((Y,Ae)=>d.jsx(Zc,{index:Ae,children:d.jsxs("div",{className:`home-session-row ${Y.id===he.sessionId?"is-active":""}`,children:[d.jsxs("button",{type:"button",className:"home-session-main",onClick:()=>Zt(Y.id),title:Y.title,children:[d.jsx(OU,{size:13,strokeWidth:2.5,className:"shrink-0"}),d.jsx("span",{className:"home-session-title",children:Y.title}),Y.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:[Y.lastMessageAt&&d.jsx("span",{title:new Date(Y.lastMessageAt).toLocaleString(),children:lee(Y.lastMessageAt)}),d.jsx("span",{style:{opacity:.6},children:Y.messageCount})]})]}),d.jsx("button",{type:"button",className:"home-session-del",onClick:Oe=>Ys(Y.id,Oe),"aria-label":t("home.sessions.delete"),title:t("home.sessions.delete"),children:d.jsx(qi,{size:16,strokeWidth:2.4})})]})},Y.id)),E===0&&ot>0&&d.jsx("button",{type:"button",className:"nb-btn text-xs self-start mt-1",onClick:()=>v(1),children:t("home.sessions.expandWeek",{count:ot})}),E===1&&(hn>0?d.jsx("button",{type:"button",className:"nb-btn text-xs self-start mt-1",onClick:()=>v(2),children:t("home.sessions.expandMonth",{count:hn})}):d.jsx("button",{type:"button",className:"nb-btn text-xs self-start mt-1",onClick:()=>v(0),children:t("home.sessions.collapseOld")})),E===2&&d.jsx("button",{type:"button",className:"nb-btn text-xs self-start mt-1",onClick:()=>v(0),children:t("home.sessions.collapseOld")})]})]}):d.jsx("button",{type:"button",className:"home-sessions-rail",onClick:()=>w(!0),"aria-label":t("home.sessions.open"),title:t("home.sessions.open"),children:d.jsx($N,{size:18,strokeWidth:2.2})})}),d.jsxs("section",{className:["voice-home",V==="draw"?"voice-home--intro-hidden":"",V==="reveal"?"voice-home--intro-reveal":""].join(" "),"aria-labelledby":"voice-home-title",children:[V!=="done"&&d.jsx(W$,{targetRef:G,panelRef:X,onReveal:()=>O("reveal"),onDone:()=>O("done")}),d.jsxs("div",{ref:X,className:"voice-conversation","data-phase":i,children:[ce&&d.jsxs("div",{className:"voice-convo-header",children:[d.jsxs("button",{type:"button",className:"voice-convo-title-btn",onClick:()=>et(Y=>!Y),"aria-expanded":Fe,children:[d.jsx("span",{className:"voice-convo-title",children:ce.title}),d.jsx(so,{size:15,strokeWidth:2.5,className:["voice-convo-chevron",Fe?"is-open":""].join(" ")})]}),Fe&&d.jsxs("dl",{className:"voice-convo-details",children:[ce.model&&d.jsxs(d.Fragment,{children:[d.jsx("dt",{children:"模型"}),d.jsx("dd",{children:ce.model})]}),d.jsx("dt",{children:"session"}),d.jsx("dd",{children:ce.id}),ce.claudeSessionId&&d.jsxs(d.Fragment,{children:[d.jsx("dt",{children:"claude"}),d.jsx("dd",{children:ce.claudeSessionId})]}),ce.cwd&&d.jsxs(d.Fragment,{children:[d.jsx("dt",{children:"目录"}),d.jsx("dd",{children:ce.cwd})]})]})]}),d.jsxs("div",{className:"relative flex-1 min-h-0 flex flex-col",children:[d.jsxs("div",{ref:K,className:"voice-message-stream","aria-live":"polite",onScroll:Ne,children:[he.messages.length===0&&i==="idle"&&d.jsxs("div",{className:"voice-empty-state",children:[d.jsx(FN,{size:18,strokeWidth:2,"aria-hidden":"true"}),d.jsx("p",{children:t("home.conversation.empty")})]}),he.messages.map((Y,Ae)=>d.jsxs("article",{className:`voice-message voice-message-${Y.role}`,"data-streaming":Y.status==="streaming",children:[d.jsxs("span",{children:[Y.role==="user"?t("home.conversation.you"):t("home.conversation.ai"),Y.role==="assistant"&&Y.status==="streaming"&&d.jsxs("span",{className:"voice-live-status","data-phase":i,style:{marginLeft:8},children:[d.jsx("span",{"aria-hidden":"true"}),Cs]}),Y.ts&&d.jsx("span",{style:{marginLeft:6,fontSize:10,opacity:.5,textTransform:"none",fontWeight:400,letterSpacing:0},title:new Date(Y.ts).toLocaleString(),children:cee(Y.ts)})]}),d.jsxs("div",{className:"voice-bubble",children:[Y.attachments&&Y.attachments.length>0&&d.jsx(aee,{sessionId:he.sessionId,paths:Y.attachments,onImagePreview:Oe=>je(Oe)}),Y.blocks&&Y.blocks.length?d.jsxs("div",{className:"voice-blocks",children:[Y.blocks.map((Oe,gt)=>Oe.type==="tool_use"&&MR(Oe,(ce==null?void 0:ce.cwd)??null)||Oe.type==="tool_use"&&Oe.title===EO?null:d.jsx(xW,{block:Oe,streaming:Y.status==="streaming",sessionId:he.sessionId??void 0,onOpenForm:pt=>st({spec:iee(pt),readOnly:pt.status!=="pending",values:pt.status!=="pending"&&pt.answer&&typeof pt.answer=="object"?pt.answer:void 0,...pt.status==="pending"?{interaction:{id:pt.id,revision:pt.revision}}:{}})},gt)),(()=>{const Oe=nee(Y.blocks);if(!Oe)return null;const gt=see(he.messages,Ae);return d.jsx("div",{className:"mt-1",children:d.jsxs("button",{type:"button",className:gt?"nb-btn text-xs":"nb-btn nb-btn-primary text-sm",onClick:()=>st({spec:Oe,readOnly:gt,values:gt?ree(he.messages,Ae):void 0}),children:[d.jsx(qN,{size:14,strokeWidth:2.5}),gt?`${Oe.title} · 已提交 ✓(点击查看)`:`${Oe.title} · 点击填写配置`]})})})(),(()=>{const Oe=hW(Y.blocks,(ce==null?void 0:ce.cwd)??null);return Oe.length>0&&he.sessionId?d.jsx("div",{className:"flex flex-col items-start gap-2 mt-1",children:Oe.map(gt=>d.jsx(pW,{sessionId:he.sessionId,path:gt,onPreview:()=>je(gt)},gt))}):null})()]}):Y.status==="streaming"?d.jsx(RR,{text:Y.content}):d.jsx(NR,{text:Y.content}),Y.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")}),Y.role==="assistant"&&Y.status!=="streaming"&&Y.content&&d.jsxs("div",{className:"voice-bubble-actions",children:[d.jsx("button",{type:"button",onClick:()=>wt(Y.content),"aria-label":t("home.copy"),title:t("home.copy"),children:d.jsx(Cj,{size:13,strokeWidth:2.5})}),d.jsx("button",{type:"button",onClick:()=>we(Y.id,Y.content),"aria-label":(Te==null?void 0:Te.id)===Y.id?t("home.stop"):t("home.play"),title:(Te==null?void 0:Te.id)===Y.id?t("home.stop"):t("home.play"),"data-active":(Te==null?void 0:Te.id)===Y.id?"true":void 0,children:(Te==null?void 0:Te.id)===Y.id?Te.phase==="loading"?d.jsx(lt,{size:13,strokeWidth:2.5,className:"animate-spin"}):d.jsx(f0,{size:16,strokeWidth:2.4,fill:"currentColor"}):d.jsx(Bj,{size:13,strokeWidth:2.5})})]})]})]},Y.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:Jn.transcript||t("home.conversation.listening")})]}),i==="thinking"&&!os&&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"}),Cs]})]}),d.jsxs("p",{children:[t("home.conversation.thinking"),d.jsx("i",{"aria-hidden":"true"})]})]})]}),W&&d.jsx("button",{type:"button",onClick:xe,"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(_B,{size:16,strokeWidth:2.5})})]}),Ct.length>0&&d.jsxs("div",{className:"voice-artifacts","aria-label":t("home.artifacts.label"),children:[d.jsx(Rc,{size:13,strokeWidth:2.5,"aria-hidden":"true"}),d.jsxs("span",{className:"voice-artifacts-title",children:[t("home.artifacts.label")," (",Ct.length,")"]}),d.jsxs("div",{className:"voice-artifacts-list",children:[Ct.slice(0,6).map(Y=>d.jsx("span",{className:"voice-artifacts-chip",title:Y,children:Y.split("/").pop()},Y)),Ct.length>6&&d.jsxs("span",{className:"voice-artifacts-chip",children:["+",Ct.length-6]})]})]}),d.jsxs("div",{className:"voice-dock","data-drag":xt?"true":"false",onDragOver:Y=>{Y.dataTransfer.types.includes("Files")&&(Y.preventDefault(),Y.dataTransfer.dropEffect="copy",xt||Rt(!0))},onDragLeave:Y=>{Y.currentTarget.contains(Y.relatedTarget)||Rt(!1)},onDrop:Y=>{if(Y.dataTransfer.types.includes("Files")){Y.preventDefault(),Rt(!1);for(const Ae of Array.from(Y.dataTransfer.files??[]))on(Ae)}},children:[y&&d.jsx("p",{className:"voice-error",role:"alert",children:y}),In&&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 ",(he.sessionId??"").replace(/^session-/,"")]})]}),(xi.length>0||Me)&&d.jsxs("div",{className:"voice-attachments",children:[xi.map(Y=>d.jsxs("div",{className:"voice-attach-thumb",title:Y.name,children:[nv(Y.path)&&he.sessionId?d.jsx("img",{src:zm(he.sessionId,Y.path),alt:Y.name}):d.jsxs("div",{className:"voice-attach-doc",children:[d.jsx(Rc,{size:30,strokeWidth:1.6,"aria-hidden":"true"}),d.jsx("span",{className:"voice-attach-ext",children:wO(Y.name)}),d.jsx("span",{className:"voice-attach-name",children:Y.name})]}),d.jsx("button",{type:"button",className:"voice-attach-del",onClick:()=>Un(Y.path),"aria-label":t("home.attach.remove"),title:t("home.attach.remove"),children:d.jsx(vn,{size:13,strokeWidth:3})})]},Y.path)),Me&&d.jsx("div",{className:"voice-attach-thumb is-loading",children:d.jsx(lt,{size:16,className:"animate-spin"})})]}),d.jsxs("div",{className:"voice-orb-button","data-mode":ri?"text":"voice",style:{...ri?{"--pill-h":`${P}px`}:{},...In?{opacity:.35,pointerEvents:"none"}:{}},children:[d.jsxs("div",{ref:G,className:"voice-flow-glass","data-phase":i,"data-mode":ri?"text":"voice","data-glass":i!=="thinking"&&!ri?"on":"off",role:"img","aria-label":t("home.visualizer.aria"),children:[d.jsx(VJ,{phase:i,inputAnalyser:fe.analyser,outputText:aa||t("home.message.speaking"),thinkingConfig:ti}),d.jsx(Jj,{active:i!=="thinking",activityLevelRef:re,activityAnalyser:i==="listening"?fe.analyser:i==="speaking"?Se.analyser??e:null,glass:i!=="thinking"&&!ri,refraction:1.2,dispersion:1,glassSize:1,amplitude:Re.amplitude,className:"voice-active-strands",colors:Re.colors,count:Re.count,glow:Re.glow,hueShift:Re.hueShift,intensity:Re.intensity,opacity:Re.opacity,saturation:Re.saturation,scale:Re.scale,speed:Re.speed,spread:Re.spread,taper:Re.taper,thickness:Re.thickness,waviness:Re.waviness}),ri&&d.jsxs("div",{className:"voice-input-inner",children:[d.jsx("textarea",{ref:q,className:"voice-input-field",rows:1,value:D,onChange:Y=>{Ve(Y.target.value),_s()},onKeyDown:Y=>{Y.key==="Enter"&&!Y.shiftKey&&!Y.nativeEvent.isComposing&&(Y.preventDefault(),Bn())},onPaste:Y=>{var Oe;const Ae=Array.from(((Oe=Y.clipboardData)==null?void 0:Oe.items)??[]).filter(gt=>gt.kind==="file"&&gt.type.startsWith("image/"));if(Ae.length!==0){Y.preventDefault();for(const gt of Ae){const pt=gt.getAsFile();pt&&on(pt)}}},placeholder:t("home.text.placeholder"),"aria-label":t("home.text.placeholder")}),d.jsx("input",{ref:B,type:"file",multiple:!0,className:"hidden",onChange:Y=>{for(const Ae of Array.from(Y.target.files??[]))on(Ae);Y.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 Y;return(Y=B.current)==null?void 0:Y.click()},disabled:he.isSending,"aria-label":t("home.attach"),title:t("home.attach"),children:d.jsx(VU,{size:16,strokeWidth:2.5})}),d.jsx("button",{type:"button",className:"voice-send-btn",onClick:Bn,disabled:!D.trim()||he.isSending,"aria-label":t("home.text.send"),title:t("home.text.send"),children:d.jsx(o6,{size:16,strokeWidth:2.5})})]})]}),!j&&d.jsx("button",{type:"button",className:"voice-orb-hit",disabled:i==="thinking"||i==="speaking"||In,"aria-label":t(i==="listening"?"home.voice.stop":"home.voice.start"),"aria-pressed":i==="listening",onClick:An}),Ai&&d.jsx("button",{type:"button",className:"voice-stop-btn",onClick:ra,"aria-label":t("home.interrupt"),title:t("home.interrupt"),children:d.jsx(f0,{size:18,strokeWidth:0,fill:"currentColor","aria-hidden":"true"})})]}),d.jsx("p",{className:"voice-dock-label",children:t(j?"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(S2,{checked:j,onChange:M,title:t("home.inputToggle"),ariaLabel:t("home.inputToggle"),onIcon:d.jsx(FN,{size:16,strokeWidth:2.4}),offIcon:d.jsx(TU,{size:16,strokeWidth:2.4})}),!j&&!In&&d.jsx(S2,{checked:o,onChange:Xs,title:t("home.auto.tip"),ariaLabel:t("home.auto.toggle"),onIcon:d.jsx(Aj,{size:16,strokeWidth:2.4}),offIcon:d.jsx(eU,{size:16,strokeWidth:2.4})})]})]})]}),m&&d.jsx("div",{className:"voice-debug-backdrop",role:"presentation",onMouseDown:Y=>{Y.target===Y.currentTarget&&p(!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(qN,{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:()=>z(Y=>({...Y,[u]:dd(ud[u])})),children:d.jsx(Kv,{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:()=>p(!1),children:d.jsx(vn,{size:16,strokeWidth:2.2,"aria-hidden":"true"})})]})]}),d.jsx("div",{className:"voice-debug-phases",role:"group","aria-label":t("home.phase.aria"),children:QJ.map(Y=>{const Ae=Y.icon;return d.jsxs("button",{type:"button","aria-pressed":u===Y.id,onClick:()=>f(Y.id),children:[d.jsx(Ae,{size:15,strokeWidth:2.2,"aria-hidden":"true"}),t(Y.labelKey)]},Y.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")}),Qe.colors.map((Y,Ae)=>d.jsxs("label",{className:"voice-color-control",children:[d.jsx("span",{children:t(`home.customize.color${Ae+1}`)}),d.jsx("input",{type:"color",value:Y,onChange:Oe=>ai(Ae,Oe.target.value)}),d.jsx("code",{children:Y.toUpperCase()})]},Ae))]}),d.jsxs("fieldset",{className:"voice-customizer-group",children:[d.jsx("legend",{children:t("home.customize.parameters")}),ZJ.map(Y=>{const Ae=t(Y.labelKey),Oe=Qe[Y.key];return d.jsxs("label",{className:"voice-parameter-control",children:[d.jsx("span",{children:Ae}),d.jsx("input",{type:"number",min:Y.min,max:Y.max,step:Y.step,value:Oe,"aria-label":`${Ae} value`,onChange:gt=>Vt(Y,Number(gt.target.value))}),d.jsx("input",{type:"range",min:Y.min,max:Y.max,step:Y.step,value:Oe,"aria-label":Ae,onChange:gt=>Vt(Y,Number(gt.target.value))})]},Y.key)})]})]})]})})]})]})}const ep=e=>e.lastActivityAt?Date.parse(e.lastActivityAt):0;function NO(e,t){const n=[...e];return t==="name"?n.sort((i,s)=>i.name.localeCompare(s.name)):t==="date"?n.sort((i,s)=>ep(s)-ep(i)):n.sort((i,s)=>{const a=i.pipelineStatus==="running"?1:0,o=s.pipelineStatus==="running"?1:0;return a!==o?o-a:ep(s)-ep(i)})}function uee(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),_t(`/api/logs?${t}`)}function dee(e){return _t(`/api/logs/sources?project=${encodeURIComponent(e)}`)}const fee=["error","warn","info","debug"],hee=["error","warn","info"];function pee({project:e,initialWorker:t}){const n=Xe(),i=t??"",[s,a]=C.useState([]),[o,c]=C.useState(!0),[u,f]=C.useState(()=>new Set(hee)),[m,p]=C.useState(""),y=C.useRef(null),[b,x]=C.useState(""),{data:w}=at({queryKey:["log-sources",e],queryFn:()=>dee(e),enabled:!!e,refetchInterval:5e3}),E=C.useMemo(()=>(w==null?void 0:w.sources)??[],[w]),v=E.find(A=>A.key===b)??(i?E.find(A=>A.worker===Number(i)):void 0)??E.find(A=>A.kind==="pipeline")??E[0],_=v==null?void 0:v.file;C.useEffect(()=>{a([])},[e,_]);const{data:k}=at({queryKey:["logs",e,_],queryFn:()=>uee({project:e,file:_,limit:500}),enabled:!!e,refetchInterval:2500});C.useEffect(()=>{k!=null&&k.data&&a(k.data)},[k]),C.useEffect(()=>{if(!o)return;const A=y.current;A&&(A.scrollTop=A.scrollHeight)},[s,o]);const T=C.useMemo(()=>{const A=m.toLowerCase();return s.filter(j=>!(!u.has(j.level)||A&&!j.msg.toLowerCase().includes(A)))},[s,u,m]);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:[E.filter(A=>A.worker==null).map(A=>d.jsx(qC,{s:A,active:(v==null?void 0:v.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:E.filter(A=>A.worker!=null).map(A=>d.jsx(qC,{s:A,active:(v==null?void 0:v.key)===A.key,onClick:()=>x(A.key)},A.key))}),fee.map(A=>d.jsx(mee,{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(cf,{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:m,onChange:A=>p(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:[(k==null?void 0:k.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(gee,{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 mee({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 gee({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 qC({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 rl({options:e,value:t,onChange:n,ariaLabel:i,className:s=""}){const a=C.useRef(null),[o,c]=C.useState(null),u=Math.max(0,e.findIndex(f=>f.value===t));return C.useLayoutEffect(()=>{const f=a.current;if(!f)return;const m=()=>{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})};m();const p=new ResizeObserver(m);return p.observe(f),()=>p.disconnect()},[u,e.length]),d.jsxs("div",{ref:a,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,m)=>d.jsx("button",{"data-idx":m,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 Y1=Symbol.for("yaml.alias"),iv=Symbol.for("yaml.document"),eo=Symbol.for("yaml.map"),_O=Symbol.for("yaml.pair"),yr=Symbol.for("yaml.scalar"),Jc=Symbol.for("yaml.seq"),Ss=Symbol.for("yaml.node.type"),lo=e=>!!e&&typeof e=="object"&&e[Ss]===Y1,ml=e=>!!e&&typeof e=="object"&&e[Ss]===iv,eu=e=>!!e&&typeof e=="object"&&e[Ss]===eo,wn=e=>!!e&&typeof e=="object"&&e[Ss]===_O,fn=e=>!!e&&typeof e=="object"&&e[Ss]===yr,tu=e=>!!e&&typeof e=="object"&&e[Ss]===Jc;function _n(e){if(e&&typeof e=="object")switch(e[Ss]){case eo:case Jc:return!0}return!1}function Tn(e){if(e&&typeof e=="object")switch(e[Ss]){case Y1:case eo:case yr:case Jc:return!0}return!1}const CO=e=>(fn(e)||_n(e))&&!!e.anchor,Fi=Symbol("break visit"),TO=Symbol("skip children"),pr=Symbol("remove node");function gl(e,t){const n=AO(t);ml(e)?ac(null,e.contents,n,Object.freeze([e]))===pr&&(e.contents=null):ac(null,e,n,Object.freeze([]))}gl.BREAK=Fi;gl.SKIP=TO;gl.REMOVE=pr;function ac(e,t,n,i){const s=jO(e,t,n,i);if(Tn(s)||wn(s))return MO(e,i,s),ac(e,s,n,i);if(typeof s!="symbol"){if(_n(t)){i=Object.freeze(i.concat(t));for(let a=0;a<t.items.length;++a){const o=ac(a,t.items[a],n,i);if(typeof o=="number")a=o-1;else{if(o===Fi)return Fi;o===pr&&(t.items.splice(a,1),a-=1)}}}else if(wn(t)){i=Object.freeze(i.concat(t));const a=ac("key",t.key,n,i);if(a===Fi)return Fi;a===pr&&(t.key=null);const o=ac("value",t.value,n,i);if(o===Fi)return Fi;o===pr&&(t.value=null)}}return s}async function qm(e,t){const n=AO(t);ml(e)?await oc(null,e.contents,n,Object.freeze([e]))===pr&&(e.contents=null):await oc(null,e,n,Object.freeze([]))}qm.BREAK=Fi;qm.SKIP=TO;qm.REMOVE=pr;async function oc(e,t,n,i){const s=await jO(e,t,n,i);if(Tn(s)||wn(s))return MO(e,i,s),oc(e,s,n,i);if(typeof s!="symbol"){if(_n(t)){i=Object.freeze(i.concat(t));for(let a=0;a<t.items.length;++a){const o=await oc(a,t.items[a],n,i);if(typeof o=="number")a=o-1;else{if(o===Fi)return Fi;o===pr&&(t.items.splice(a,1),a-=1)}}}else if(wn(t)){i=Object.freeze(i.concat(t));const a=await oc("key",t.key,n,i);if(a===Fi)return Fi;a===pr&&(t.key=null);const o=await oc("value",t.value,n,i);if(o===Fi)return Fi;o===pr&&(t.value=null)}}return s}function AO(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 jO(e,t,n,i){var s,a,o,c,u;if(typeof n=="function")return n(e,t,i);if(eu(t))return(s=n.Map)==null?void 0:s.call(n,e,t,i);if(tu(t))return(a=n.Seq)==null?void 0:a.call(n,e,t,i);if(wn(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(lo(t))return(u=n.Alias)==null?void 0:u.call(n,e,t,i)}function MO(e,t,n){const i=t[t.length-1];if(_n(i))i.items[e]=n;else if(wn(i))e==="key"?i.key=n:i.value=n;else if(ml(i))i.contents=n;else{const s=lo(i)?"alias":"scalar";throw new Error(`Cannot replace node with ${s} parent`)}}const yee={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},bee=e=>e.replace(/[!,[\]{}]/g,t=>yee[t]);class ki{constructor(t,n){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},ki.defaultYaml,t),this.tags=Object.assign({},ki.defaultTags,n)}clone(){const t=new ki(this.yaml,this.tags);return t.docStart=this.docStart,t}atDocument(){const t=new ki(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:ki.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},ki.defaultTags);break}return t}add(t,n){this.atNextDocument&&(this.yaml={explicit:ki.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},ki.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[a,o]=i;return this.tags[a]=o,!0}case"%YAML":{if(this.yaml.explicit=!0,i.length!==1)return n(0,"%YAML directive should contain exactly one part"),!1;const[a]=i;if(a==="1.1"||a==="1.2")return this.yaml.version=a,!0;{const o=/^\d+\.\d+$/.test(a);return n(6,`Unsupported YAML version ${a}`,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 a=this.tags[i];if(a)try{return a+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+bee(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&&Tn(t.contents)){const a={};gl(t.contents,(o,c)=>{Tn(c)&&c.tag&&(a[c.tag]=!0)}),s=Object.keys(a)}else s=[];for(const[a,o]of i)a==="!!"&&o==="tag:yaml.org,2002:"||(!t||s.some(c=>c.startsWith(o)))&&n.push(`%TAG ${a} ${o}`);return n.join(`
677
+ `,1;if(ru>1e5&&ru>We.index*3)throw new Error("potential infinite loop, way more iterations than matches");return $t+=vt,vt.length}const pt=Bn(Me);if(!pt)throw Te(Tt.replace("{}",Me)),new Error('Unknown language: "'+Me+'"');const ji=ce(pt);let oa="",tt=Rt||ji;const la={},jn=new Ue.__emitter(Ue);Ae();let $t="",ca=0,Sr=0,ru=0,ua=!1;try{if(pt.__emitTokens)pt.__emitTokens(Ge,jn);else{for(tt.matcher.considerAll();;){ru++,ua?ua=!1:tt.matcher.considerAll(),tt.matcher.lastIndex=Sr;const Le=tt.matcher.exec(Ge);if(!Le)break;const We=Ge.substring(Sr,Le.index),vt=gt(We,Le);Sr=Le.index+vt}gt(Ge.substring(Sr))}return jn.finalize(),oa=jn.toHTML(),{language:Me,value:oa,relevance:ca,illegal:!1,_emitter:jn,_top:tt}}catch(Le){if(Le.message&&Le.message.includes("Illegal"))return{language:Me,value:st(Ge),illegal:!0,relevance:0,_illegalBy:{message:Le.message,index:Sr,context:Ge.slice(Sr-100,Sr+100),mode:Le.mode,resultSoFar:oa},_emitter:jn};if(Yt)return{language:Me,value:st(Ge),illegal:!1,relevance:0,errorRaised:Le,_emitter:jn,_top:tt};throw Le}}function Ys(Me){const Ge={value:st(Me),illegal:!1,relevance:0,_top:$e,_emitter:new Ue.__emitter(Ue)};return Ge._emitter.addText(Me),Ge}function Jn(Me,Ge){Ge=Ge||Ue.languages||Object.keys(be);const xt=Ys(Me),Rt=Ge.filter(Bn).filter(In).map(Vt=>Vi(Vt,Me,!1));Rt.unshift(xt);const on=Rt.sort((Vt,ai)=>{if(Vt.relevance!==ai.relevance)return ai.relevance-Vt.relevance;if(Vt.language&&ai.language){if(Bn(Vt.language).supersetOf===ai.language)return 1;if(Bn(ai.language).supersetOf===Vt.language)return-1}return 0}),[Un,ei]=on,ti=Un;return ti.secondBest=ei,ti}function kn(Me,Ge,xt){const Rt=Ge&&Ie[Ge]||xt;Me.classList.add("hljs"),Me.classList.add(`language-${Rt}`)}function mn(Me){let Ge=null;const xt=hn(Me);if(ot(xt))return;if(xi("before:highlightElement",{el:Me,language:xt}),Me.dataset.highlighted){console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",Me);return}if(Me.children.length>0&&(Ue.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(Me)),Ue.throwUnescapedHTML))throw new qe("One of your code blocks includes unescaped HTML.",Me.innerHTML);Ge=Me;const Rt=Ge.textContent,on=xt?Zt(Rt,{language:xt,ignoreIllegals:!0}):Jn(Rt);Me.innerHTML=on.value,Me.dataset.highlighted="yes",kn(Me,xt,on.language),Me.result={language:on.language,re:on.relevance,relevance:on.relevance},on.secondBest&&(Me.secondBest={language:on.secondBest.language,relevance:on.secondBest.relevance}),xi("after:highlightElement",{el:Me,result:on,text:Rt})}function An(Me){Ue=Fe(Ue,Me)}const Ti=()=>{Qs(),ne("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")};function Xs(){Qs(),ne("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")}let wr=!1;function Qs(){function Me(){Qs()}if(document.readyState==="loading"){wr||window.addEventListener("DOMContentLoaded",Me,!1),wr=!0;return}document.querySelectorAll(Ue.cssSelector).forEach(mn)}function sa(Me,Ge){let xt=null;try{xt=Ge(Z)}catch(Rt){if(Te("Language definition for '{}' could not be registered.".replace("{}",Me)),Yt)Te(Rt);else throw Rt;xt=$e}xt.name||(xt.name=Me),be[Me]=xt,xt.rawDefinition=Ge.bind(null,Z),xt.aliases&&Ai(xt.aliases,{languageName:Me})}function _s(Me){delete be[Me];for(const Ge of Object.keys(Ie))Ie[Ge]===Me&&delete Ie[Ge]}function Zs(){return Object.keys(be)}function Bn(Me){return Me=(Me||"").toLowerCase(),be[Me]||be[Ie[Me]]}function Ai(Me,{languageName:Ge}){typeof Me=="string"&&(Me=[Me]),Me.forEach(xt=>{Ie[xt.toLowerCase()]=Ge})}function In(Me){const Ge=Bn(Me);return Ge&&!Ge.disableAutodetect}function ri(Me){Me["before:highlightBlock"]&&!Me["before:highlightElement"]&&(Me["before:highlightElement"]=Ge=>{Me["before:highlightBlock"](Object.assign({block:Ge.el},Ge))}),Me["after:highlightBlock"]&&!Me["after:highlightElement"]&&(Me["after:highlightElement"]=Ge=>{Me["after:highlightBlock"](Object.assign({block:Ge.el},Ge))})}function bn(Me){ri(Me),ut.push(Me)}function ra(Me){const Ge=ut.indexOf(Me);Ge!==-1&&ut.splice(Ge,1)}function xi(Me,Ge){const xt=Me;ut.forEach(function(Rt){Rt[xt]&&Rt[xt](Ge)})}function hi(Me){return ne("10.7.0","highlightBlock will be removed entirely in v12.0"),ne("10.7.0","Please use highlightElement now."),mn(Me)}Object.assign(Z,{highlight:Zt,highlightAuto:Jn,highlightAll:Qs,highlightElement:mn,highlightBlock:hi,configure:An,initHighlighting:Ti,initHighlightingOnLoad:Xs,registerLanguage:sa,unregisterLanguage:_s,listLanguages:Zs,getLanguage:Bn,registerAliases:Ai,autoDetection:In,inherit:Fe,addPlugin:bn,removePlugin:ra}),Z.debugMode=function(){Yt=!1},Z.safeMode=function(){Yt=!0},Z.versionString=je,Z.regex={concat:w,lookahead:y,either:v,optional:x,anyNumberOfTimes:b};for(const Me in se)typeof se[Me]=="object"&&e(se[Me]);return Object.assign(Z,se),Z},Wt=Yn({});return Wt.newInstance=()=>Yn({}),Jb=Wt,Wt.HighlightJS=Wt,Wt.default=Wt,Jb}var eW=JG();const tW=nf(eW),b2={},nW="hljs-";function iW(e){const t=tW.newInstance();return e&&a(e),{highlight:n,highlightAuto:i,listLanguages:s,register:a,registerAlias:o,registered:c};function n(u,f,m){const p=m||b2,y=typeof p.prefix=="string"?p.prefix:nW;if(!t.getLanguage(u))throw new Error("Unknown language: `"+u+"` is not registered");t.configure({__emitter:sW,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,w=x.data;return w.language=b.language,w.relevance=b.relevance,x}function i(u,f){const p=(f||b2).subset||s();let y=-1,b=0,x;for(;++y<p.length;){const w=p[y];if(!t.getLanguage(w))continue;const E=n(w,u,f);E.data&&E.data.relevance!==void 0&&E.data.relevance>b&&(b=E.data.relevance,x=E)}return x||{type:"root",children:[],data:{language:void 0,relevance:b}}}function s(){return t.listLanguages()}function a(u,f){if(typeof u=="string")t.registerLanguage(u,f);else{let m;for(m in u)Object.hasOwn(u,m)&&t.registerLanguage(m,u[m])}}function o(u,f){if(typeof u=="string")t.registerAliases(typeof f=="string"?f:[...f],{languageName:u});else{let m;for(m in u)if(Object.hasOwn(u,m)){const p=u[m];t.registerAliases(typeof p=="string"?p:[...p],{languageName:m})}}}function c(u){return!!t.getLanguage(u)}}class sW{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],a={type:"element",tagName:"span",properties:{className:i},children:[]};s.children.push(a),this.stack.push(a)}closeNode(){this.stack.pop()}finalize(){}toHTML(){return""}}const rW={};function b1(e){const t=e||rW,n=t.aliases,i=t.detect||!1,s=t.languages||ZG,a=t.plainText,o=t.prefix,c=t.subset;let u="hljs";const f=iW(s);if(n&&f.registerAlias(n),o){const m=o.indexOf("-");u=m===-1?o:o.slice(0,m)}return function(m,p){Pm(m,"element",function(y,b,x){if(y.tagName!=="code"||!x||x.type!=="element"||x.tagName!=="pre")return;const w=aW(y);if(w===!1||!w&&!i||w&&a&&a.includes(w))return;Array.isArray(y.properties.className)||(y.properties.className=[]),y.properties.className.includes(u)||y.properties.className.unshift(u);const E=N7(y,{whitespace:"pre"});let v;try{v=w?f.highlight(w,E,{prefix:o}):f.highlightAuto(E,{prefix:o,subset:c})}catch(_){const k=_;if(w&&/Unknown language/.test(k.message)){p.message("Cannot highlight as `"+w+"`, it’s not registered",{ancestors:[x,y],cause:k,place:y.position,ruleId:"missing-language",source:"rehype-highlight"});return}throw k}!w&&v.data&&v.data.language&&y.properties.className.push("language-"+v.data.language),v.children.length>0&&(y.children=v.children)})}}function aW(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 NR({text:e}){return e?d.jsx("div",{className:"prose-chat text-sm break-words font-[family-name:var(--font-body)]",children:d.jsx(d1,{remarkPlugins:[m1],rehypePlugins:[b1],children:e})}):null}function oW(){return _t("/api/chat/sessions")}function kp(e){return _t(`/api/chat/sessions/${e}`)}async function _R(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 lW(e){const t=await fetch(`/api/chat/sessions/${e}`,{method:"DELETE"});if(!t.ok)throw new Error(`${t.status}`)}async function x2(e,t,n){const i=await fetch(`/api/chat/sessions/${e}/messages`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:t,attachments:n})});if(!i.ok)throw new Error(`${i.status}: ${await i.text()}`);return await i.json()}async function CR(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 TR(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 cW(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 uW(e,t){const n=t?`?since=${encodeURIComponent(t)}`:"";return _t(`/api/chat/sessions/${e}/messages${n}`)}function AR(e){const t=e?`?path=${encodeURIComponent(e)}`:"";return _t(`/api/fs/browse${t}`)}async function dW(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 jR=50*1024*1024;async function v2(e,t){if(t.size>jR)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 zm(e,t){return`/api/fs/file?${new URLSearchParams({path:t,sessionId:e}).toString()}`}function fW(e){return/\.(png|jpe?g|gif|webp|svg|bmp|avif)$/i.test(e)}function MR(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&&fW(s)?s:null}function hW(e,t){const n=[];for(const i of e){if(i.type!=="tool_use")continue;const s=MR(i,t);s&&!n.includes(s)&&n.push(s)}return n}function pW({sessionId:e,path:t,onPreview:n}){const[i,s]=C.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:zm(e,t),alt:"生成的图片",className:"block max-h-96 max-w-full object-contain",loading:"lazy",onError:()=>s(!0)})})}function mW({sessionId:e,path:t,onClose:n}){return C.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:zm(e,t),alt:"预览",className:"max-w-full max-h-[85vh] object-contain",onClick:i=>i.stopPropagation()})})}function gW(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 yW({tool:e,live:t}){const[n,i]=C.useState(!1),s=e.status==="completed"||e.status==="complete",a=e.status==="failed",o=e.status==="interrupted"||!s&&!a&&!t,c=!s&&!a&&!o,u=gW(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(m=>!m),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(lf,{size:12,strokeWidth:3,className:["transition-transform flex-shrink-0",n?"rotate-90":""].join(" ")}),d.jsx(Uj,{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(lt,{size:12,strokeWidth:3,className:"animate-spin text-[var(--color-running)] flex-shrink-0"}),s&&d.jsx(Kp,{size:12,strokeWidth:2.5,className:"text-[var(--color-running)] flex-shrink-0"}),a&&d.jsx(_j,{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 bW({interaction:e,sessionId:t,onOpenForm:n}){const i=e.schema&&typeof e.schema=="object"&&!Array.isArray(e.schema)?e.schema:{},s=i.properties??{},a=new Set(i.required??[]),[o,c]=C.useState(()=>Object.fromEntries(Object.entries(s).filter(([,_])=>_.default!==void 0).map(([_,k])=>[_,k.default]))),[u,f]=C.useState(e.status==="pending"?"idle":e.status),[m,p]=C.useState(""),y=u==="answered"||u==="cancelled"||e.status!=="pending",b=e.kind==="form"&&!!n,x=u==="cancelled"||e.status==="cancelled",w=_=>{const k={...o};_!==void 0&&(k.approved=_);for(const[T,A]of Object.entries(s))A.type==="number"&&typeof k[T]=="string"&&(k[T]=Number(k[T]));return k},E=async _=>{if(!t||y)return;p("");const k=w(_),T=[...a].filter(A=>k[A]===void 0||k[A]===null||k[A]==="");if(T.length>0){p(`请填写:${T.map(A=>{var j;return((j=s[A])==null?void 0:j.title)??A}).join("、")}`);return}f("submitting");try{await TR(t,e.id,k,e.revision),f("answered")}catch(A){f("idle"),p(A instanceof Error?A.message:String(A))}},v=async()=>{if(!(!t||y)){p(""),f("cancelling");try{await cW(t,e.id,e.revision),f("cancelled")}catch(_){f("idle"),p(_ instanceof Error?_.message:String(_))}}};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(d6,{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(([_,k])=>{const T=k.title??_,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,a.has(_)?" *":""]}),Array.isArray(k.enum)?d.jsxs("select",{className:A,value:String(o[_]??""),onChange:j=>c(M=>({...M,[_]:j.target.value})),children:[d.jsx("option",{value:"",children:"请选择"}),k.enum.map(j=>d.jsx("option",{value:String(j),children:String(j)},String(j)))]}):k.type==="boolean"?d.jsx("input",{type:"checkbox",checked:o[_]===!0,onChange:j=>c(M=>({...M,[_]:j.target.checked}))}):k.format==="textarea"?d.jsx("textarea",{className:A,rows:4,value:String(o[_]??""),onChange:j=>c(M=>({...M,[_]:j.target.value}))}):d.jsx("input",{className:A,type:k.type==="number"?"number":"text",value:String(o[_]??""),onChange:j=>c(M=>({...M,[_]:j.target.value}))})]},_)})}),!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(k=>({...k,reason:_.target.value}))})]}),m&&d.jsx("p",{className:"text-xs text-[var(--color-crashed)]",children:m}),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 E(!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 E(!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 E(),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 v(),children:"取消任务"}),(u==="submitting"||u==="cancelling")&&d.jsx(lt,{size:14,className:"animate-spin self-center"})]})]})}function RR({text:e}){const[t,n]=C.useState(""),i=C.useRef(e);return i.current=e,C.useEffect(()=>{n(s=>e.startsWith(s)?s:"")},[e]),C.useEffect(()=>{const s=window.setInterval(()=>{n(a=>{const o=i.current;if(a.length>=o.length)return a;const c=Math.max(1,Math.ceil((o.length-a.length)/8));return o.slice(0,a.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 xW({block:e,streaming:t,sessionId:n,onOpenForm:i}){return e.type==="text"?t?d.jsx(RR,{text:e.text}):d.jsx(NR,{text:e.text}):e.type==="interaction"?d.jsx(bW,{interaction:e,sessionId:n,onOpenForm:i}):d.jsx(yW,{tool:e,live:t===!0})}const ex={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 vW(e){return e.default!==void 0?e.default:e.type==="multiselect"||e.type==="checkbox"?[]:e.type==="toggle"?!1:e.type==="number"||e.type==="slider"?e.min??0:""}function wW({spec:e,onSubmit:t,onSkip:n,onUpload:i,disabled:s,initialValues:a}){const[o,c]=C.useState(()=>Object.fromEntries(e.fields.map(j=>[j.id,a&&j.id in a?a[j.id]:vW(j)]))),[u,f]=C.useState(!1),[m,p]=C.useState(!1),[y,b]=C.useState(!1),x=s||y,w=(j,M)=>c(D=>({...D,[j]:M})),{basic:E,advanced:v}=C.useMemo(()=>({basic:e.fields.filter(j=>!j.advanced),advanced:e.fields.filter(j=>j.advanced)}),[e.fields]),_=()=>e.fields.filter(j=>j.required&&(o[j.id]===""||o[j.id]==null||Array.isArray(o[j.id])&&o[j.id].length===0)),k=()=>{if(x)return;if(_().length){p(!0);return}t(o),p(!0),b(!0)},T=()=>{x||(n(),b(!0))},A=j=>{const M=new Map;for(const D of j){const I=D.group??"";(M.get(I)??M.set(I,[]).get(I)).push(D)}return[...M.entries()]};return d.jsxs("div",{className:["nb-card flex flex-col gap-3 max-w-lg",x?"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,y&&" ✓"]}),e.description&&d.jsx("div",{className:"text-xs text-[var(--color-text-muted)] mt-0.5",children:e.description})]}),A(E).map(([j,M])=>d.jsx(w2,{name:j,fields:M,values:o,set:w,showErr:m,onUpload:i},j||"default")),v.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:()=>f(j=>!j),children:[u?d.jsx(so,{size:14}):d.jsx(lf,{size:14})," 高级选项"]}),u&&d.jsx("div",{className:"mt-2 flex flex-col gap-3",children:A(v).map(([j,M])=>d.jsx(w2,{name:j,fields:M,values:o,set:w,showErr:m,onUpload:i},j||"adv"))})]}),d.jsxs("div",{className:"flex gap-2 justify-end pt-1",children:[d.jsxs("button",{type:"button",className:"nb-btn text-xs",onClick:T,disabled:x,children:[d.jsx(il,{size:13,strokeWidth:2.5})," ",e.skipLabel??"让 AI 来填"]}),d.jsx("button",{type:"button",className:"nb-btn nb-btn-primary text-xs",onClick:k,disabled:x,children:e.submitLabel??"提交"})]})]})}function w2({name:e,fields:t,values:n,set:i,showErr:s,onUpload:a}){return d.jsxs("div",{className:"flex flex-col gap-3",children:[e&&d.jsx("div",{className:"text-xs font-bold text-[var(--color-text-muted)] uppercase tracking-wide",children:e}),t.map(o=>d.jsx(EW,{f:o,value:n[o.id],set:i,showErr:s,onUpload:a},o.id))]})}function EW({f:e,value:t,set:n,showErr:i,onUpload:s}){const[a,o]=C.useState(!1),c=async p=>{if(!(!p||!s)){o(!0);try{n(e.id,await s(p))}catch{}finally{o(!1)}}},u=i&&e.required&&(t===""||t==null||Array.isArray(t)&&t.length===0),f=Array.isArray(t)?t:[],m=p=>n(e.id,f.includes(p)?f.filter(y=>y!==p):[...f,p]);return d.jsxs("label",{className:"flex flex-col gap-1",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:p=>n(e.id,p.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:p=>n(e.id,p.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:p=>n(e.id,p.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:p=>n(e.id,p.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:p=>n(e.id,p.target.value),children:(e.options??[]).map(p=>d.jsx("option",{value:p.value,children:p.label},p.value))}),e.type==="radio"&&d.jsx("div",{className:"flex flex-wrap gap-2",children:(e.options??[]).map(p=>d.jsx("button",{type:"button",onClick:()=>n(e.id,p.value),className:["px-3 py-1.5 rounded-lg border-2 text-sm transition-all",t===p.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:p.label},p.value))}),(e.type==="multiselect"||e.type==="checkbox")&&d.jsx("div",{className:"flex flex-wrap gap-2",children:(e.options??[]).map(p=>d.jsx("button",{type:"button",onClick:()=>m(p.value),className:["px-3 py-1.5 rounded-lg border-2 text-sm transition-all",f.includes(p.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:p.label},p.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:p=>n(e.id,p.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:p=>n(e.id,p.target.value)}),(e.type==="image-ref"||e.type==="file")&&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:[a?"上传中…":t?"重新选择":"选择文件",d.jsx("input",{type:"file",className:"hidden",accept:e.accept??(e.type==="image-ref"?"image/*":void 0),onChange:p=>{var y;c((y=p.target.files)==null?void 0:y[0]),p.target.value=""},disabled:a})]}),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:p=>n(e.id,p.target.value)})]}),e.hint&&d.jsx("span",{className:"text-xs text-[var(--color-text-muted)]",children:e.hint}),u&&d.jsx("span",{className:"text-xs text-[var(--color-crashed)]",children:"必填"})]})}function tx(){if(!(typeof window>"u"))return window.SpeechRecognition??window.webkitSpeechRecognition}function SW({onComplete:e,onError:t}){const[n,i]=C.useState(!1),[s,a]=C.useState(""),o=C.useRef(null),c=C.useRef(""),u=C.useRef(""),f=C.useRef(0),m=C.useRef(!1),p=C.useRef(!1),y=C.useRef(null),b=C.useRef(e),x=C.useRef(t);b.current=e,x.current=t;const w=C.useCallback(()=>{y.current!==null&&(window.clearTimeout(y.current),y.current=null)},[]),E=C.useCallback(()=>{i(!1);const A=u.current.trim();c.current="",u.current="",A?b.current(A):x.current("no-speech")},[]),v=C.useCallback(()=>{f.current+=1,m.current=!1,p.current=!0,w();const A=o.current;o.current=null,A==null||A.abort(),c.current="",u.current="",a(""),i(!1)},[w]),_=C.useCallback(A=>{const j=tx();if(!j||A!==f.current||!m.current)return!1;const M=new j;M.continuous=!0,M.interimResults=!0,M.lang=navigator.language||"zh-CN",M.onresult=D=>{var P;if(A!==f.current)return;let I="";for(let U=D.resultIndex;U<D.results.length;U+=1){const q=D.results[U],V=((P=q==null?void 0:q[0])==null?void 0:P.transcript.trim())??"";q!=null&&q.isFinal&&V?c.current=`${c.current} ${V}`.trim():V&&(I+=` ${V}`)}u.current=`${c.current}${I}`.trim(),a(u.current)},M.onerror=D=>{A===f.current&&(D.error==="no-speech"||D.error==="aborted"||D.error==="network"||(m.current=!1,p.current=!0,i(!1),x.current(D.error)))},M.onend=()=>{if(A===f.current){if(o.current===M&&(o.current=null),p.current){p.current=!1;return}if(!m.current){E();return}i(!0),w(),y.current=window.setTimeout(()=>{y.current=null,_(A)},180)}},o.current=M;try{return M.start(),i(!0),!0}catch{return o.current=null,m.current=!1,i(!1),x.current("start-failed"),!1}},[w,E]),k=C.useCallback(()=>{m.current=!1,w();const A=o.current;A?A.stop():E()},[w,E]),T=C.useCallback(()=>{if(!tx())return x.current("unsupported"),!1;v();const j=f.current;return m.current=!0,p.current=!1,c.current="",u.current="",a(""),_(j)},[v,_]);return C.useEffect(()=>v,[v]),{cancel:v,isListening:n,start:T,stop:k,supported:!!tx(),transcript:s}}function kW(){const[e,t]=C.useState("inactive"),[n,i]=C.useState(null),s=C.useRef(null),a=C.useRef(null),o=C.useRef(0),c=C.useCallback(()=>{var f,m;o.current+=1,(f=a.current)==null||f.getTracks().forEach(p=>p.stop()),a.current=null,(m=s.current)==null||m.close(),s.current=null,i(null),t("inactive")},[]),u=C.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 m=null,p=null;try{if(m=await navigator.mediaDevices.getUserMedia({audio:{autoGainControl:!0,echoCancellation:!0,noiseSuppression:!0}}),f!==o.current){m.getTracks().forEach(w=>w.stop());return}if(p=new AudioContext,p.state==="suspended"&&await p.resume(),f!==o.current){m.getTracks().forEach(w=>w.stop()),p.close();return}const b=p.createMediaStreamSource(m),x=p.createAnalyser();x.fftSize=2048,x.smoothingTimeConstant=.72,b.connect(x),a.current=m,s.current=p,i(x),t("active")}catch{m==null||m.getTracks().forEach(b=>b.stop()),p==null||p.close(),f===o.current&&t("denied")}},[c]);return C.useEffect(()=>c,[c]),{analyser:n,start:u,status:e,stop:c}}const NW=.12,E2=1e3,_W=1e4,CW=150;function TW(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 AW(e){const{enabled:t,phase:n,suspended:i,analyser:s,silenceMs:a=2e3}=e,o=C.useRef(e);o.current=e;const c=C.useRef(0),u=C.useRef(0),f=C.useRef(0),m=C.useRef(0),p=C.useRef("");C.useEffect(()=>{const y=Date.now();n==="idle"?c.current=y+E2:n==="listening"&&(u.current=y,m.current=y,f.current=y,p.current="")},[n]),C.useEffect(()=>{if(!(n==="listening"||t&&n==="idle"))return;const y={bytes:new Uint8Array(new ArrayBuffer(0))},b=window.setInterval(()=>{const x=o.current,w=Date.now();if(document.hidden)return;if((x.analyser?TW(x.analyser,y):0)>NW&&(f.current=w),x.phase==="idle"){if(!x.enabled||x.suspended||w<c.current)return;x.transcript.trim().length>0&&(c.current=w+E2,x.onTrigger());return}x.transcript!==p.current&&(p.current=x.transcript,m.current=w);const v=w-Math.max(m.current,f.current);x.transcript.trim()?v>=(x.silenceMs??2e3)&&x.onEndpoint():w-u.current>=_W&&x.onAbort()},CW);return()=>window.clearInterval(b)},[t,n,i,s,a])}function S2({checked:e,onChange:t,onIcon:n,offIcon:i,title:s,ariaLabel:a}){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":a}),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 jW(e){return e.type==="text"?{type:"text",target:e.text,displayed:e.text}:{...e}}function MW(e,t){var y;const n=tn(),[i,s]=C.useState(null),[a,o]=C.useState(!1),c=C.useRef(t);c.current=t;const u=at({queryKey:["chat-session",e],queryFn:()=>kp(e??""),enabled:!!e,refetchInterval:(t==null?void 0:t.pollMs)===0?!1:(t==null?void 0:t.pollMs)??4e3});C.useEffect(()=>{if(!e)return;const b=new EventSource(`/stream/chat/${encodeURIComponent(e)}`);let x=!0;return b.addEventListener("open",()=>{if(x){x=!1;return}const w=n.getQueryData(["chat-session",e]),E=w!=null&&w.messages.length?w.messages[w.messages.length-1].ts:void 0;uW(e,E).then(v=>{v.data.length!==0&&n.setQueryData(["chat-session",e],_=>{if(!_)return _;const k=new Set(_.messages.map(A=>A.id)),T=v.data.filter(A=>!k.has(A.id));return T.length===0?_:{..._,messages:[..._.messages,...T],lastMessageAt:T[T.length-1].ts,messageCount:_.messageCount+T.length}})}).catch(()=>{})}),b.addEventListener("chat.message",w=>{try{const E=JSON.parse(w.data);n.setQueryData(["chat-session",e],v=>{if(!v||v.messages.some(k=>k.id===E.message.id))return v;const _=v.messages.findIndex(k=>k.role==="user"&&k.id.startsWith("optim-")&&k.content===E.message.content);if(_>=0){const k=[...v.messages];return k[_]=E.message,{...v,messages:k}}return{...v,messages:[...v.messages,E.message]}})}catch{}}),b.addEventListener("chat.message.pending",w=>{var E,v;try{const _=JSON.parse(w.data);s({sessionId:e,id:_.assistantId,blocks:[],done:!1,finalMessage:null}),(v=(E=c.current)==null?void 0:E.onTurnStart)==null||v.call(E)}catch{}}),b.addEventListener("chat.message.snapshot",w=>{try{const E=JSON.parse(w.data);s({sessionId:e,id:E.assistantId,blocks:E.blocks.map(jW),done:!1,finalMessage:null})}catch{}}),b.addEventListener("chat.message.chunk.text",w=>{var E,v;try{const _=JSON.parse(w.data);s(k=>{const T=k&&k.id===_.assistantId?k:{sessionId:e,id:_.assistantId,blocks:[],done:!1,finalMessage:null},A=[...T.blocks],j=A[A.length-1];return j&&j.type==="text"?A[A.length-1]={...j,target:j.target+_.text}:A.push({type:"text",target:_.text,displayed:""}),{...T,blocks:A}}),(v=(E=c.current)==null?void 0:E.onAssistantChunk)==null||v.call(E,_.text)}catch{}}),b.addEventListener("chat.message.chunk.tool_use",w=>{try{const E=JSON.parse(w.data);s(v=>{const _=v&&v.id===E.assistantId?v:{sessionId:e,id:E.assistantId,blocks:[],done:!1,finalMessage:null};return{..._,blocks:[..._.blocks,{type:"tool_use",id:E.id,title:E.title,kind:E.kind,status:E.status,input:E.input,locations:E.locations}]}})}catch{}}),b.addEventListener("chat.message.chunk.tool_update",w=>{try{const E=JSON.parse(w.data);s(v=>!v||v.id!==E.assistantId?v:{...v,blocks:v.blocks.map(_=>_.type==="tool_use"&&_.id===E.id?{..._,status:E.status,input:_.input??E.input,locations:_.locations??E.locations}:_)})}catch{}}),b.addEventListener("chat.message.chunk.interaction",w=>{try{const E=JSON.parse(w.data);s(v=>{const _=v&&v.id===E.assistantId?v:{sessionId:e,id:E.assistantId,blocks:[],done:!1,finalMessage:null};return{..._,blocks:[..._.blocks,{type:"interaction",id:E.id,kind:E.kind,title:E.title,schema:E.schema,revision:E.revision,status:E.status}]}})}catch{}}),b.addEventListener("chat.message.interaction.updated",w=>{try{const E=JSON.parse(w.data);n.setQueryData(["chat-session",e],v=>v&&{...v,messages:v.messages.map(_=>{var k;return{..._,blocks:(k=_.blocks)==null?void 0:k.map(T=>T.type==="interaction"&&T.id===E.interactionId?{...T,status:E.status,revision:E.revision,answer:E.answer}:T)}})})}catch{}}),b.addEventListener("chat.message.complete",w=>{try{const E=JSON.parse(w.data);s(v=>({...v&&v.id===E.assistantId?v:{sessionId:e,id:E.assistantId,blocks:[],done:!1,finalMessage:null},done:!0,finalMessage:E.message}))}catch{}}),b.addEventListener("chat.message.error",w=>{var E,v;try{const _=JSON.parse(w.data);s(T=>T&&T.sessionId===e&&(!_.assistantId||T.id===_.assistantId||T.id===_.turnId)?null:T),o(!1);const k=_.message;k&&n.setQueryData(["chat-session",e],T=>!T||T.messages.some(A=>A.id===k.id)?T:{...T,messages:[...T.messages,k],lastMessageAt:k.ts,messageCount:T.messageCount+1}),(v=(E=c.current)==null?void 0:E.onError)==null||v.call(E,k??null)}catch{}}),()=>b.close()},[e,n]),C.useEffect(()=>{o(!1)},[e]),C.useEffect(()=>{var w,E;if(!i||i.sessionId!==e)return;const b=i.blocks.reduce((v,_)=>_.type==="text"?v+(_.target.length-_.displayed.length):v,0);if(b<=0){if(i.done&&i.finalMessage){const v=i.finalMessage;n.setQueryData(["chat-session",e],_=>!_||_.messages.some(k=>k.id===v.id)?_:{..._,messages:[..._.messages,v],lastMessageAt:v.ts,messageCount:_.messageCount+1}),n.invalidateQueries({queryKey:["chat-sessions"]}),n.invalidateQueries({queryKey:["chat-session",e]}),s(null),o(!1),(E=(w=c.current)==null?void 0:w.onAssistantComplete)==null||E.call(w,v)}return}const x=setTimeout(()=>{s(v=>{if(!v)return v;let _=Math.max(1,Math.ceil(b/40));const k=v.blocks.map(T=>{if(T.type!=="text"||_<=0)return T;const A=T.target.length-T.displayed.length;if(A<=0)return T;const j=Math.min(A,_);return _-=j,{...T,displayed:T.target.slice(0,T.displayed.length+j)}});return{...v,blocks:k}})},25);return()=>clearTimeout(x)},[i,n,e]);const f=C.useCallback(async(b,x)=>{var _,k,T,A;if(a)return;let w=e;if(!w&&(w=await((k=(_=c.current)==null?void 0:_.ensureSessionId)==null?void 0:k.call(_))??null,!w))return;const E=x&&x.length>0?x:void 0,v={id:`optim-${Date.now()}`,role:"user",content:b,ts:new Date().toISOString(),status:"complete",...E?{attachments:E}:{}};n.setQueryData(["chat-session",w],j=>j?{...j,messages:[...j.messages,v],lastMessageAt:v.ts,messageCount:j.messageCount+1}:{id:w,createdAt:v.ts,lastMessageAt:v.ts,title:b.slice(0,60)||"…",project:null,messageCount:1,messages:[v]}),o(!0),(A=(T=c.current)==null?void 0:T.onTurnStart)==null||A.call(T);try{await(E?x2(w,b,E):x2(w,b))}catch(j){throw o(!1),j}},[a,e,n]),m=C.useCallback(async()=>{e&&await CR(e)},[e]),p=i&&i.sessionId===e?i:null;return{detail:u.data??null,messages:((y=u.data)==null?void 0:y.messages)??[],isLoading:u.isLoading,activePending:p,sending:a,send:f,interrupt:m}}function RW(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 DW(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 OW(e){const[t,n]=C.useState(null),i=C.useRef(null),s=C.useRef(e);s.current=e;const a=C.useCallback(y=>{i.current=y,n(y)},[]),o=C.useCallback(async()=>{if(i.current)return i.current;const y=await _R({title:"Voice conversation",dedicated:!0});return a(y.id),y.id},[a]),c=MW(t,{ensureSessionId:o,onAssistantChunk:y=>s.current.onAssistantChunk(y),onAssistantComplete:y=>s.current.onAssistantComplete(y.content),onTurnStart:()=>s.current.onThinking(),onError:y=>s.current.onError(new Error((y==null?void 0:y.content)??"Response failed"))}),u=C.useMemo(()=>{const y=c.activePending,b=c.messages.filter(x=>y?x.id===y.id||y.finalMessage&&x.id===y.finalMessage.id?!1:x.status!=="streaming":!0).map(RW);return y?[...b,DW(y)]:b},[c.messages,c.activePending]),f=C.useCallback(async(y,b)=>{try{await c.send(y,b)}catch(x){s.current.onError(x instanceof Error?x:new Error(String(x)))}},[c]),m=C.useCallback((y,b)=>{a(y)},[a]),p=C.useCallback(()=>{a(null)},[a]);return{isSending:c.sending,messages:u,send:f,sessionId:t,resume:m,reset:p,ensureSession:o}}function x1(){return _t("/api/providers")}function DR(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 OR=DR;async function LW(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 IW(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 PW({title:e,body:t,confirm:n,cancel:i,onConfirm:s,onCancel:a,danger:o}){const c=Xe();return C.useEffect(()=>{const u=f=>{f.key==="Escape"&&a()};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[a]),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:a,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 LR=C.createContext(null);function zW({children:e}){const t=Xe(),[n,i]=C.useState(null),s=C.useCallback(c=>new Promise(u=>{i({kind:"confirm",opts:c,resolve:f=>{i(null),u(f)}})}),[]),a=C.useCallback(c=>new Promise(u=>{i({kind:"alert",opts:c,resolve:()=>{i(null),u()}})}),[]),o=C.useCallback(c=>new Promise(u=>{i({kind:"prompt",opts:c,resolve:f=>{i(null),u(f)}})}),[]);return d.jsxs(LR.Provider,{value:{confirm:s,alert:a,prompt:o},children:[e,(n==null?void 0:n.kind)==="confirm"&&d.jsx(PW,{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(BW,{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(UW,{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 Ln(){const e=C.useContext(LR);if(!e)throw new Error("useDialog must be used inside <DialogProvider>");return e}function BW({title:e,body:t,confirm:n,onClose:i}){return C.useEffect(()=>{const s=a=>{(a.key==="Escape"||a.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 UW({title:e,body:t,placeholder:n,defaultValue:i,confirm:s,cancel:a,onConfirm:o,onCancel:c}){const[u,f]=C.useState(i??""),m=C.useRef(null);C.useEffect(()=>{var b,x;(b=m.current)==null||b.focus(),(x=m.current)==null||x.select();const y=w=>{w.key==="Escape"&&c()};return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[c]);const p=()=>{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:m,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(),p())}}),d.jsxs("div",{className:"flex gap-3 justify-end",children:[d.jsx("button",{className:"nb-btn",onClick:c,type:"button",children:a}),d.jsx("button",{className:"nb-btn nb-btn-primary",onClick:p,type:"button",disabled:!u.trim(),children:s})]})]})})}function v1({initialPath:e,onCancel:t,onSelect:n,title:i,mode:s="directory"}){var _,k,T;const a=Xe(),{prompt:o,alert:c}=Ln(),u=i??a("dirPicker.title.default"),[f,m]=C.useState(e??null),[p,y]=C.useState(null),b=at({queryKey:["fs-browse",f],queryFn:()=>AR(f??void 0),staleTime:0,gcTime:0}),x=((_=b.data)==null?void 0:_.path)??f??"",w=((k=b.data)==null?void 0:k.parent)??null,E=((T=b.data)==null?void 0:T.home)??null,v=async()=>{var j;if(!x)return;const A=(j=await o({title:a("dirPicker.newDir"),body:a("dirPicker.newDir.prompt"),placeholder:a("dirPicker.newDir.placeholder"),confirm:a("dirPicker.newDir.create")}))==null?void 0:j.trim();if(A)try{const M=await dW(x,A);m(M.path)}catch(M){c({title:a("dirPicker.newDir.error.title"),body:M instanceof Error?M.message:String(M)})}};return C.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":a("dirPicker.close.aria"),children:d.jsx(vn,{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:()=>w&&m(w),disabled:!w||b.isLoading,"aria-label":a("dirPicker.up.aria"),title:a("dirPicker.up.title"),children:d.jsx(AB,{size:12,strokeWidth:3})}),d.jsx("button",{type:"button",className:"nb-btn flex-shrink-0",style:{padding:"4px 10px",fontSize:12},onClick:()=>E&&m(E),disabled:!E||b.isLoading,"aria-label":a("dirPicker.home.aria"),title:a("dirPicker.home.title"),children:d.jsx(Mj,{size:12,strokeWidth:3})}),d.jsx("button",{type:"button",className:"nb-btn flex-shrink-0",style:{padding:"4px 10px",fontSize:12},onClick:()=>void v(),disabled:!x||b.isLoading||b.isError,"aria-label":a("dirPicker.newDir.aria"),title:a("dirPicker.newDir.aria"),children:d.jsx(uU,{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(lt,{size:16,strokeWidth:3,className:"animate-spin mr-2"}),a("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:a("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:a("dirPicker.empty")}),b.data.entries.map(A=>{const j=(()=>{const I=x.endsWith("/")||x.endsWith("\\")?"":"/";return`${x}${I}${A.name}`})(),M=s==="file"&&p===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),m(j)):s==="file"&&y(j)},onDoubleClick:()=>{s==="file"&&!A.isDirectory&&n(j)},title:A.isDirectory?a("dirPicker.enter.aria",{name:A.name}):s==="file"?a("dirPicker.pickFile.aria",{name:A.name}):a("dirPicker.fileLocked"),children:[A.isDirectory?d.jsx(jj,{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(lf,{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:a("dirPicker.cancel")}),s==="file"?d.jsxs("button",{type:"button",className:"nb-btn nb-btn-primary",onClick:()=>p&&n(p),disabled:!p||b.isLoading||b.isError,title:p??a("dirPicker.useFile.tooltip.empty"),children:[d.jsx(Kp,{size:14,strokeWidth:3}),a("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(Kp,{size:14,strokeWidth:3}),a("dirPicker.useDir")]})]})]})})}function FW({onCancel:e,onCreate:t}){var A,j;const n=Xe(),[i,s]=C.useState(""),[a,o]=C.useState(""),[c,u]=C.useState("claude"),[f,m]=C.useState(""),[p,y]=C.useState(!1),[b,x]=C.useState(!1),[w,E]=C.useState(!1),v=at({queryKey:["providers"],queryFn:x1}),_=at({queryKey:["system-agents"],queryFn:Xv}),k=OR((c==="openai"?(A=v.data)==null?void 0:A.openai:(j=v.data)==null?void 0:j.anthropic)??[]);C.useEffect(()=>{m(""),y(!1)},[c]),C.useEffect(()=>{var I;if(p)return;const M=(I=_.data)==null?void 0:I.agents.worker;if(!M)return;const D=`${M.providerId||"official"}::${M.model}`;k.some(P=>`${P.providerId}::${P.model}`===D)&&m(D)},[_.data,k,p]),C.useEffect(()=>{if(w)return;const M=D=>{D.key==="Escape"&&(D.preventDefault(),e())};return window.addEventListener("keydown",M),()=>window.removeEventListener("keydown",M)},[e,w]);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:a.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(vn,{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),m(M.target.value)},children:[d.jsx("option",{value:"",children:n("chat.newSession.field.model.default")}),k.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:a,onChange:M=>o(M.target.value)}),d.jsxs("button",{type:"button",className:"nb-btn flex-shrink-0",onClick:()=>E(!0),"aria-label":n("chat.newSession.field.cwd.browseAria"),title:n("chat.newSession.field.cwd.browseAria"),children:[d.jsx(qv,{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(jj,{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(lt,{size:14,strokeWidth:3,className:"animate-spin"}):d.jsx(Gn,{size:14,strokeWidth:3}),n("chat.newSession.create")]})]})]})]}),w&&d.jsx(v1,{initialPath:a.trim()||void 0,onCancel:()=>E(!1),onSelect:M=>{o(M),E(!1)}})]})}const IR=C.createContext({});function $W(e){const t=C.useRef(null);return t.current===null&&(t.current=e()),t.current}const qW=typeof window<"u",HW=qW?C.useLayoutEffect:C.useEffect,w1=C.createContext(null);function E1(e,t){e.indexOf(t)===-1&&e.push(t)}function tm(e,t){const n=e.indexOf(t);n>-1&&e.splice(n,1)}const gr=(e,t,n)=>n>t?t:n<e?e:n;let S1=()=>{};const to={},PR=e=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(e),zR=e=>typeof e=="object"&&e!==null,BR=e=>/^0[^.\s]+$/u.test(e);function UR(e){let t;return()=>(t===void 0&&(t=e()),t)}const ws=e=>e,pf=(...e)=>e.reduce((t,n)=>i=>n(t(i))),Dd=(e,t,n)=>{const i=t-e;return i?(n-e)/i:1};class k1{constructor(){this.subscriptions=[]}add(t){return E1(this.subscriptions,t),()=>tm(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 a=0;a<s;a++){const o=this.subscriptions[a];o&&o(t,n,i)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}}const ss=e=>e*1e3,vs=e=>e/1e3,FR=(e,t)=>t?e*(1e3/t):0,$R=(e,t,n)=>(((1-3*n+3*t)*e+(3*n-6*t))*e+3*t)*e,VW=1e-7,KW=12;function GW(e,t,n,i,s){let a,o,c=0;do o=t+(n-t)/2,a=$R(o,i,s)-e,a>0?n=o:t=o;while(Math.abs(a)>VW&&++c<KW);return o}function mf(e,t,n,i){if(e===t&&n===i)return ws;const s=a=>GW(a,0,1,e,n);return a=>a===0||a===1?a:$R(s(a),t,i)}const qR=e=>t=>t<=.5?e(2*t)/2:(2-e(2*(1-t)))/2,HR=e=>t=>1-e(1-t),VR=mf(.33,1.53,.69,.99),N1=HR(VR),KR=qR(N1),GR=e=>e>=1?1:(e*=2)<1?.5*N1(e):.5*(2-Math.pow(2,-10*(e-1))),_1=e=>1-Math.sin(Math.acos(e)),WR=HR(_1),YR=qR(_1),WW=mf(.42,0,1,1),YW=mf(0,0,.58,1),XR=mf(.42,0,.58,1),XW=e=>Array.isArray(e)&&typeof e[0]!="number",QR=e=>Array.isArray(e)&&typeof e[0]=="number",QW={linear:ws,easeIn:WW,easeInOut:XR,easeOut:YW,circIn:_1,circInOut:YR,circOut:WR,backIn:N1,backInOut:KR,backOut:VR,anticipate:GR},ZW=e=>typeof e=="string",k2=e=>{if(QR(e)){S1(e.length===4);const[t,n,i,s]=e;return mf(t,n,i,s)}else if(ZW(e))return QW[e];return e},Yh=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function JW(e){let t=new Set,n=new Set,i=!1,s=!1;const a=new WeakSet;let o={delta:0,timestamp:0,isProcessing:!1};function c(f){a.has(f)&&(u.schedule(f),e()),f(o)}const u={schedule:(f,m=!1,p=!1)=>{const b=p&&i?t:n;return m&&a.add(f),b.add(f),f},cancel:f=>{n.delete(f),a.delete(f)},process:f=>{if(o=f,i){s=!0;return}i=!0;const m=t;t=n,n=m,t.forEach(c),t.clear(),i=!1,s&&(s=!1,u.process(f))}};return u}const eY=40;function ZR(e,t){let n=!1,i=!0;const s={delta:0,timestamp:0,isProcessing:!1},a=()=>n=!0,o=Yh.reduce((k,T)=>(k[T]=JW(a),k),{}),{setup:c,read:u,resolveKeyframes:f,preUpdate:m,update:p,preRender:y,render:b,postRender:x}=o,w=()=>{const k=to.useManualTiming,T=k?s.timestamp:performance.now();n=!1,k||(s.delta=i?1e3/60:Math.max(Math.min(T-s.timestamp,eY),1)),s.timestamp=T,s.isProcessing=!0,c.process(s),u.process(s),f.process(s),m.process(s),p.process(s),y.process(s),b.process(s),x.process(s),s.isProcessing=!1,n&&t&&(i=!1,e(w))},E=()=>{n=!0,i=!0,s.isProcessing||e(w)};return{schedule:Yh.reduce((k,T)=>{const A=o[T];return k[T]=(j,M=!1,D=!1)=>(n||E(),A.schedule(j,M,D)),k},{}),cancel:k=>{for(let T=0;T<Yh.length;T++)o[Yh[T]].cancel(k)},state:s,steps:o}}const{schedule:un,cancel:no,state:di,steps:nx}=ZR(typeof requestAnimationFrame<"u"?requestAnimationFrame:ws,!0);let Np;function tY(){Np=void 0}const _i={now:()=>(Np===void 0&&_i.set(di.isProcessing||to.useManualTiming?di.timestamp:performance.now()),Np),set:e=>{Np=e,queueMicrotask(tY)}},JR=e=>t=>typeof t=="string"&&t.startsWith(e),eD=JR("--"),nY=JR("var(--"),C1=e=>nY(e)?iY.test(e.split("/*")[0].trim()):!1,iY=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function N2(e){return typeof e!="string"?!1:e.split("/*")[0].includes("var(--")}const Yc={test:e=>typeof e=="number",parse:parseFloat,transform:e=>e},Od={...Yc,transform:e=>gr(0,1,e)},Xh={...Yc,default:1},vd=e=>Math.round(e*1e5)/1e5,T1=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function sY(e){return e==null}const rY=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,A1=(e,t)=>n=>!!(typeof n=="string"&&rY.test(n)&&n.startsWith(e)||t&&!sY(n)&&Object.prototype.hasOwnProperty.call(n,t)),tD=(e,t,n)=>i=>{if(typeof i!="string")return i;const[s,a,o,c]=i.match(T1);return{[e]:parseFloat(s),[t]:parseFloat(a),[n]:parseFloat(o),alpha:c!==void 0?parseFloat(c):1}},aY=e=>gr(0,255,e),ix={...Yc,transform:e=>Math.round(aY(e))},Lo={test:A1("rgb","red"),parse:tD("red","green","blue"),transform:({red:e,green:t,blue:n,alpha:i=1})=>"rgba("+ix.transform(e)+", "+ix.transform(t)+", "+ix.transform(n)+", "+vd(Od.transform(i))+")"};function oY(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 M0={test:A1("#"),parse:oY,transform:Lo.transform},gf=e=>({test:t=>typeof t=="string"&&t.endsWith(e)&&t.split(" ").length===1,parse:parseFloat,transform:t=>`${t}${e}`}),$r=gf("deg"),hr=gf("%"),Ke=gf("px"),lY=gf("vh"),cY=gf("vw"),_2={...hr,parse:e=>hr.parse(e)/100,transform:e=>hr.transform(e*100)},ic={test:A1("hsl","hue"),parse:tD("hue","saturation","lightness"),transform:({hue:e,saturation:t,lightness:n,alpha:i=1})=>"hsla("+Math.round(e)+", "+hr.transform(vd(t))+", "+hr.transform(vd(n))+", "+vd(Od.transform(i))+")"},Kn={test:e=>Lo.test(e)||M0.test(e)||ic.test(e),parse:e=>Lo.test(e)?Lo.parse(e):ic.test(e)?ic.parse(e):M0.parse(e),transform:e=>typeof e=="string"?e:e.hasOwnProperty("red")?Lo.transform(e):ic.transform(e),getAnimatableNone:e=>{const t=Kn.parse(e);return t.alpha=0,Kn.transform(t)}},uY=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function dY(e){var t,n;return isNaN(e)&&typeof e=="string"&&(((t=e.match(T1))==null?void 0:t.length)||0)+(((n=e.match(uY))==null?void 0:n.length)||0)>0}const nD="number",iD="color",fY="var",hY="var(",C2="${}",pY=/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 Oc(e){const t=e.toString(),n=[],i={color:[],number:[],var:[]},s=[];let a=0;const c=t.replace(pY,u=>(Kn.test(u)?(i.color.push(a),s.push(iD),n.push(Kn.parse(u))):u.startsWith(hY)?(i.var.push(a),s.push(fY),n.push(u)):(i.number.push(a),s.push(nD),n.push(parseFloat(u))),++a,C2)).split(C2);return{values:n,split:c,indexes:i,types:s}}function mY(e){return Oc(e).values}function sD({split:e,types:t}){const n=e.length;return i=>{let s="";for(let a=0;a<n;a++)if(s+=e[a],i[a]!==void 0){const o=t[a];o===nD?s+=vd(i[a]):o===iD?s+=Kn.transform(i[a]):s+=i[a]}return s}}function gY(e){return sD(Oc(e))}const yY=e=>typeof e=="number"?0:Kn.test(e)?Kn.getAnimatableNone(e):e,bY=(e,t)=>typeof e=="number"?t!=null&&t.trim().endsWith("/")?e:0:yY(e);function xY(e){const t=Oc(e);return sD(t)(t.values.map((i,s)=>bY(i,t.split[s])))}const qs={test:dY,parse:mY,createTransformer:gY,getAnimatableNone:xY};function sx(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 vY({hue:e,saturation:t,lightness:n,alpha:i}){e/=360,t/=100,n/=100;let s=0,a=0,o=0;if(!t)s=a=o=n;else{const c=n<.5?n*(1+t):n+t-n*t,u=2*n-c;s=sx(u,c,e+1/3),a=sx(u,c,e),o=sx(u,c,e-1/3)}return{red:Math.round(s*255),green:Math.round(a*255),blue:Math.round(o*255),alpha:i}}function nm(e,t){return n=>n>0?t:e}const cn=(e,t,n)=>e+(t-e)*n,rx=(e,t,n)=>{const i=e*e,s=n*(t*t-i)+i;return s<0?0:Math.sqrt(s)},wY=[M0,Lo,ic],EY=e=>wY.find(t=>t.test(e));function T2(e){const t=EY(e);if(!t)return!1;let n=t.parse(e);return t===ic&&(n=vY(n)),n}const A2=(e,t)=>{const n=T2(e),i=T2(t);if(!n||!i)return nm(e,t);const s={...n};return a=>(s.red=rx(n.red,i.red,a),s.green=rx(n.green,i.green,a),s.blue=rx(n.blue,i.blue,a),s.alpha=cn(n.alpha,i.alpha,a),Lo.transform(s))},R0=new Set(["none","hidden"]);function SY(e,t){return R0.has(e)?n=>n<=0?e:t:n=>n>=1?t:e}function kY(e,t){return n=>cn(e,t,n)}function j1(e){return typeof e=="number"?kY:typeof e=="string"?C1(e)?nm:Kn.test(e)?A2:CY:Array.isArray(e)?rD:typeof e=="object"?Kn.test(e)?A2:NY:nm}function rD(e,t){const n=[...e],i=n.length,s=e.map((a,o)=>j1(a)(a,t[o]));return a=>{for(let o=0;o<i;o++)n[o]=s[o](a);return n}}function NY(e,t){const n={...e,...t},i={};for(const s in n)e[s]!==void 0&&t[s]!==void 0&&(i[s]=j1(e[s])(e[s],t[s]));return s=>{for(const a in i)n[a]=i[a](s);return n}}function _Y(e,t){const n=[],i={color:0,var:0,number:0};for(let s=0;s<t.values.length;s++){const a=t.types[s],o=e.indexes[a][i[a]],c=e.values[o]??0;n[s]=c,i[a]++}return n}const CY=(e,t)=>{const n=qs.createTransformer(t),i=Oc(e),s=Oc(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?R0.has(e)&&!s.values.length||R0.has(t)&&!i.values.length?SY(e,t):pf(rD(_Y(i,s),s.values),n):nm(e,t)};function aD(e,t,n){return typeof e=="number"&&typeof t=="number"&&typeof n=="number"?cn(e,t,n):j1(e)(e,t)}const TY=e=>{const t=({timestamp:n})=>e(n);return{start:(n=!0)=>un.update(t,n),stop:()=>no(t),now:()=>di.isProcessing?di.timestamp:_i.now()}},oD=(e,t,n=10)=>{let i="";const s=Math.max(Math.round(t/n),2);for(let a=0;a<s;a++)i+=Math.round(e(a/(s-1))*1e4)/1e4+", ";return`linear(${i.substring(0,i.length-2)})`},im=2e4;function M1(e){let t=0;const n=50;let i=e.next(t);for(;!i.done&&t<im;)t+=n,i=e.next(t);return t>=im?1/0:t}function AY(e,t=100,n){const i=n({...e,keyframes:[0,t]}),s=Math.min(M1(i),im);return{type:"keyframes",ease:a=>i.next(s*a).value/t,duration:vs(s)}}const On={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 D0(e,t){return e*Math.sqrt(1-t*t)}const jY=12;function MY(e,t,n){let i=n;for(let s=1;s<jY;s++)i=i-e(i)/t(i);return i}const ax=.001;function RY({duration:e=On.duration,bounce:t=On.bounce,velocity:n=On.velocity,mass:i=On.mass}){let s,a,o=1-t;o=gr(On.minDamping,On.maxDamping,o),e=gr(On.minDuration,On.maxDuration,vs(e)),o<1?(s=f=>{const m=f*o,p=m*e,y=m-n,b=D0(f,o),x=Math.exp(-p);return ax-y/b*x},a=f=>{const p=f*o*e,y=p*n+n,b=Math.pow(o,2)*Math.pow(f,2)*e,x=Math.exp(-p),w=D0(Math.pow(f,2),o);return(-s(f)+ax>0?-1:1)*((y-b)*x)/w}):(s=f=>{const m=Math.exp(-f*e),p=(f-n)*e+1;return-ax+m*p},a=f=>{const m=Math.exp(-f*e),p=(n-f)*(e*e);return m*p});const c=5/e,u=MY(s,a,c);if(e=ss(e),isNaN(u))return{stiffness:On.stiffness,damping:On.damping,duration:e};{const f=Math.pow(u,2)*i;return{stiffness:f,damping:o*2*Math.sqrt(i*f),duration:e}}}const DY=["duration","bounce"],OY=["stiffness","damping","mass"];function j2(e,t){return t.some(n=>e[n]!==void 0)}function LY(e){let t={velocity:On.velocity,stiffness:On.stiffness,damping:On.damping,mass:On.mass,isResolvedFromDuration:!1,...e};if(!j2(e,OY)&&j2(e,DY))if(t.velocity=0,e.visualDuration){const n=e.visualDuration,i=2*Math.PI/(n*1.2),s=i*i,a=2*gr(.05,1,1-(e.bounce||0))*Math.sqrt(s);t={...t,mass:On.mass,stiffness:s,damping:a}}else{const n=RY({...e,velocity:0});t={...t,...n,mass:On.mass},t.isResolvedFromDuration=!0}return t}function sm(e=On.visualDuration,t=On.bounce){const n=typeof e!="object"?{visualDuration:e,keyframes:[0,1],bounce:t}:e;let{restSpeed:i,restDelta:s}=n;const a=n.keyframes[0],o=n.keyframes[n.keyframes.length-1],c={done:!1,value:a},{stiffness:u,damping:f,mass:m,duration:p,velocity:y,isResolvedFromDuration:b}=LY({...n,velocity:-vs(n.velocity||0)}),x=y||0,w=f/(2*Math.sqrt(u*m)),E=o-a,v=vs(Math.sqrt(u/m)),_=Math.abs(E)<5;i||(i=_?On.restSpeed.granular:On.restSpeed.default),s||(s=_?On.restDelta.granular:On.restDelta.default);let k,T,A,j,M,D;if(w<1)A=D0(v,w),j=(x+w*v*E)/A,k=P=>{const U=Math.exp(-w*v*P);return o-U*(j*Math.sin(A*P)+E*Math.cos(A*P))},M=w*v*j+E*A,D=w*v*E-j*A,T=P=>Math.exp(-w*v*P)*(M*Math.sin(A*P)+D*Math.cos(A*P));else if(w===1){k=U=>o-Math.exp(-v*U)*(E+(x+v*E)*U);const P=x+v*E;T=U=>Math.exp(-v*U)*(v*P*U-x)}else{const P=v*Math.sqrt(w*w-1);k=O=>{const R=Math.exp(-w*v*O),z=Math.min(P*O,300);return o-R*((x+w*v*E)*Math.sinh(z)+P*E*Math.cosh(z))/P};const U=(x+w*v*E)/P,q=w*v*U-E*P,V=w*v*E-U*P;T=O=>{const R=Math.exp(-w*v*O),z=Math.min(P*O,300);return R*(q*Math.sinh(z)+V*Math.cosh(z))}}const I={calculatedDuration:b&&p||null,velocity:P=>ss(T(P)),next:P=>{if(!b&&w<1){const q=Math.exp(-w*v*P),V=Math.sin(A*P),O=Math.cos(A*P),R=o-q*(j*V+E*O),z=ss(q*(M*V+D*O));return c.done=Math.abs(z)<=i&&Math.abs(o-R)<=s,c.value=c.done?o:R,c}const U=k(P);if(b)c.done=P>=p;else{const q=ss(T(P));c.done=Math.abs(q)<=i&&Math.abs(o-U)<=s}return c.value=c.done?o:U,c},toString:()=>{const P=Math.min(M1(I),im),U=oD(q=>I.next(P*q).value,P,30);return P+"ms "+U},toTransition:()=>{}};return I}sm.applyToOptions=e=>{const t=AY(e,100,sm);return e.ease=t.ease,e.duration=ss(t.duration),e.type="keyframes",e};const IY=5;function lD(e,t,n){const i=Math.max(t-IY,0);return FR(n-e(i),t-i)}function O0({keyframes:e,velocity:t=0,power:n=.8,timeConstant:i=325,bounceDamping:s=10,bounceStiffness:a=500,modifyTarget:o,min:c,max:u,restDelta:f=.5,restSpeed:m}){const p=e[0],y={done:!1,value:p},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 w=n*t;const E=p+w,v=o===void 0?E:o(E);v!==E&&(w=v-p);const _=D=>-w*Math.exp(-D/i),k=D=>v+_(D),T=D=>{const I=_(D),P=k(D);y.done=Math.abs(I)<=f,y.value=y.done?v:P};let A,j;const M=D=>{b(y.value)&&(A=D,j=sm({keyframes:[y.value,x(y.value)],velocity:lD(k,D,y.value),damping:s,stiffness:a,restDelta:f,restSpeed:m}))};return M(0),{calculatedDuration:null,next:D=>{let I=!1;return!j&&A===void 0&&(I=!0,T(D),M(D)),A!==void 0&&D>=A?j.next(D-A):(!I&&T(D),y)}}}function PY(e,t,n){const i=[],s=n||to.mix||aD,a=e.length-1;for(let o=0;o<a;o++){let c=s(e[o],e[o+1]);if(t){const u=Array.isArray(t)?t[o]||ws:t;c=pf(u,c)}i.push(c)}return i}function zY(e,t,{clamp:n=!0,ease:i,mixer:s}={}){const a=e.length;if(S1(a===t.length),a===1)return()=>t[0];if(a===2&&t[0]===t[1])return()=>t[1];const o=e[0]===e[1];e[0]>e[a-1]&&(e=[...e].reverse(),t=[...t].reverse());const c=PY(t,i,s),u=c.length,f=m=>{if(o&&m<e[0])return t[0];let p=0;if(u>1)for(;p<e.length-2&&!(m<e[p+1]);p++);const y=Dd(e[p],e[p+1],m);return c[p](y)};return n?m=>f(gr(e[0],e[a-1],m)):f}function BY(e,t){const n=e[e.length-1];for(let i=1;i<=t;i++){const s=Dd(0,t,i);e.push(cn(n,1,s))}}function UY(e){const t=[0];return BY(t,e.length-1),t}function FY(e,t){return e.map(n=>n*t)}function $Y(e,t){return e.map(()=>t||XR).splice(0,e.length-1)}function wd({duration:e=300,keyframes:t,times:n,ease:i="easeInOut"}){const s=XW(i)?i.map(k2):k2(i),a={done:!1,value:t[0]},o=FY(n&&n.length===t.length?n:UY(t),e),c=zY(o,t,{ease:Array.isArray(s)?s:$Y(t,s)});return{calculatedDuration:e,next:u=>(a.value=c(u),a.done=u>=e,a)}}const qY=e=>e!==null;function Bm(e,{repeat:t,repeatType:n="loop"},i,s=1){const a=e.filter(qY),c=s<0||t&&n!=="loop"&&t%2===1?0:a.length-1;return!c||i===void 0?a[c]:i}const HY={decay:O0,inertia:O0,tween:wd,keyframes:wd,spring:sm};function cD(e){typeof e.type=="string"&&(e.type=HY[e.type])}class R1{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 VY=e=>e/100;class rm extends R1{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!==_i.now()&&this.tick(_i.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;cD(t);const{type:n=wd,repeat:i=0,repeatDelay:s=0,repeatType:a,velocity:o=0}=t;let{keyframes:c}=t;const u=n||wd;u!==wd&&typeof c[0]!="number"&&(this.mixKeyframes=pf(VY,aD(c[0],c[1])),c=[0,100]);const f=u({...t,keyframes:c});a==="mirror"&&(this.mirroredGenerator=u({...t,keyframes:[...c].reverse(),velocity:-o})),f.calculatedDuration===null&&(f.calculatedDuration=M1(f));const{calculatedDuration:m}=f;this.calculatedDuration=m,this.resolvedDuration=m+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:a,mirroredGenerator:o,resolvedDuration:c,calculatedDuration:u}=this;if(this.startTime===null)return i.next(0);const{delay:f=0,keyframes:m,repeat:p,repeatType:y,repeatDelay:b,type:x,onUpdate:w,finalKeyframe:E}=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 v=this.currentTime-f*(this.playbackSpeed>=0?1:-1),_=this.playbackSpeed>=0?v<0:v>s;this.currentTime=Math.max(v,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=s);let k=this.currentTime,T=i;if(p){const D=Math.min(this.currentTime,s)/c;let I=Math.floor(D),P=D%1;!P&&D>=1&&(P=1),P===1&&I--,I=Math.min(I,p+1),!!(I%2)&&(y==="reverse"?(P=1-P,b&&(P-=b/c)):y==="mirror"&&(T=o)),k=gr(0,1,P)*c}let A;_?(this.delayState.value=m[0],A=this.delayState):A=T.next(k),a&&!_&&(A.value=a(A.value));let{done:j}=A;!_&&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!==O0&&(A.value=Bm(m,this.options,E,this.speed)),w&&w(A.value),M&&this.finish(),A}then(t,n){return this.finished.then(t,n)}get duration(){return vs(this.calculatedDuration)}get iterationDuration(){const{delay:t=0}=this.options||{};return this.duration+vs(t)}get time(){return vs(this.currentTime)}set time(t){t=ss(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 lD(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(_i.now()),this.playbackSpeed=t,n&&this.driver&&(this.time=vs(this.currentTime))}play(){var s,a;if(this.isStopped)return;const{driver:t=TY,startTime:n}=this.options;this.driver||(this.driver=t(o=>this.tick(o))),(a=(s=this.options).onPlay)==null||a.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(_i.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 KY(e){for(let t=1;t<e.length;t++)e[t]??(e[t]=e[t-1])}const Io=e=>e*180/Math.PI,L0=e=>{const t=Io(Math.atan2(e[1],e[0]));return I0(t)},GY={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:e=>(Math.abs(e[0])+Math.abs(e[3]))/2,rotate:L0,rotateZ:L0,skewX:e=>Io(Math.atan(e[1])),skewY:e=>Io(Math.atan(e[2])),skew:e=>(Math.abs(e[1])+Math.abs(e[2]))/2},I0=e=>(e=e%360,e<0&&(e+=360),e),M2=L0,R2=e=>Math.sqrt(e[0]*e[0]+e[1]*e[1]),D2=e=>Math.sqrt(e[4]*e[4]+e[5]*e[5]),WY={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:R2,scaleY:D2,scale:e=>(R2(e)+D2(e))/2,rotateX:e=>I0(Io(Math.atan2(e[6],e[5]))),rotateY:e=>I0(Io(Math.atan2(-e[2],e[0]))),rotateZ:M2,rotate:M2,skewX:e=>Io(Math.atan(e[4])),skewY:e=>Io(Math.atan(e[1])),skew:e=>(Math.abs(e[1])+Math.abs(e[4]))/2};function P0(e){return e.includes("scale")?1:0}function z0(e,t){if(!e||e==="none")return P0(t);const n=e.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let i,s;if(n)i=WY,s=n;else{const c=e.match(/^matrix\(([-\d.e\s,]+)\)$/u);i=GY,s=c}if(!s)return P0(t);const a=i[t],o=s[1].split(",").map(XY);return typeof a=="function"?a(o):o[a]}const YY=(e,t)=>{const{transform:n="none"}=getComputedStyle(e);return z0(n,t)};function XY(e){return parseFloat(e.trim())}const Xc=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],Qc=new Set([...Xc,"pathRotation"]),O2=e=>e===Yc||e===Ke,QY=new Set(["x","y","z"]),ZY=Xc.filter(e=>!QY.has(e));function JY(e){const t=[];return ZY.forEach(n=>{const i=e.getValue(n);i!==void 0&&(t.push([n,i.get()]),i.set(n.startsWith("scale")?1:0))}),t}const Qa={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})=>z0(t,"x"),y:(e,{transform:t})=>z0(t,"y")};Qa.translateX=Qa.x;Qa.translateY=Qa.y;const Xo=new Set;let B0=!1,U0=!1,F0=!1;function uD(){if(U0){const e=Array.from(Xo).filter(i=>i.needsMeasurement),t=new Set(e.map(i=>i.element)),n=new Map;t.forEach(i=>{const s=JY(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(([a,o])=>{var c;(c=i.getValue(a))==null||c.set(o)})}),e.forEach(i=>i.measureEndState()),e.forEach(i=>{i.suspendedScrollY!==void 0&&window.scrollTo(0,i.suspendedScrollY)})}U0=!1,B0=!1,Xo.forEach(e=>e.complete(F0)),Xo.clear()}function dD(){Xo.forEach(e=>{e.readKeyframes(),e.needsMeasurement&&(U0=!0)})}function eX(){F0=!0,dD(),uD(),F0=!1}class D1{constructor(t,n,i,s,a,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=a,this.isAsync=o}scheduleResolve(){this.state="scheduled",this.isAsync?(Xo.add(this),B0||(B0=!0,un.read(dD),un.resolveKeyframes(uD))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:t,name:n,element:i,motionValue:s}=this;if(t[0]===null){const a=s==null?void 0:s.get(),o=t[t.length-1];if(a!==void 0)t[0]=a;else if(i&&n){const c=i.readValue(n,o);c!=null&&(t[0]=c)}t[0]===void 0&&(t[0]=o),s&&a===void 0&&s.set(t[0])}KY(t)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(t=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,t),Xo.delete(this)}cancel(){this.state==="scheduled"&&(Xo.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const tX=e=>e.startsWith("--");function fD(e,t,n){tX(t)?e.style.setProperty(t,n):e.style[t]=n}const nX={};function hD(e,t){const n=UR(e);return()=>nX[t]??n()}const iX=hD(()=>window.ScrollTimeline!==void 0,"scrollTimeline"),pD=hD(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),cd=([e,t,n,i])=>`cubic-bezier(${e}, ${t}, ${n}, ${i})`,L2={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:cd([0,.65,.55,1]),circOut:cd([.55,0,1,.45]),backIn:cd([.31,.01,.66,-.59]),backOut:cd([.33,1.53,.69,.99])};function mD(e,t){if(e)return typeof e=="function"?pD()?oD(e,t):"ease-out":QR(e)?cd(e):Array.isArray(e)?e.map(n=>mD(n,t)||L2.easeOut):L2[e]}function sX(e,t,n,{delay:i=0,duration:s=300,repeat:a=0,repeatType:o="loop",ease:c="easeOut",times:u}={},f=void 0){const m={[t]:n};u&&(m.offset=u);const p=mD(c,s);Array.isArray(p)&&(m.easing=p);const y={delay:i,duration:s,easing:Array.isArray(p)?"linear":p,fill:"both",iterations:a+1,direction:o==="reverse"?"alternate":"normal"};return f&&(y.pseudoElement=f),e.animate(m,y)}function gD(e){return typeof e=="function"&&"applyToOptions"in e}function rX({type:e,...t}){return gD(e)&&pD()?e.applyToOptions(t):(t.duration??(t.duration=300),t.ease??(t.ease="easeOut"),t)}class yD extends R1{constructor(t){if(super(),this.finishedTime=null,this.isStopped=!1,this.manualStartTime=null,!t)return;const{element:n,name:i,keyframes:s,pseudoElement:a,allowFlatten:o=!1,finalKeyframe:c,onComplete:u}=t;this.isPseudoElement=!!a,this.allowFlatten=o,this.options=t,S1(typeof t.type!="string");const f=rX(t);this.animation=sX(n,i,s,f,a),f.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!a){const m=Bm(s,this.options,c,this.speed);this.updateMotionValue&&this.updateMotionValue(m),fD(n,i,m),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 vs(Number(t))}get iterationDuration(){const{delay:t=0}=this.options||{};return this.duration+vs(t)}get time(){return vs(Number(this.animation.currentTime)||0)}set time(t){const n=this.finishedTime!==null;this.manualStartTime=null,this.finishedTime=null,this.animation.currentTime=ss(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 a;return this.allowFlatten&&((a=this.animation.effect)==null||a.updateTiming({easing:"linear"})),this.animation.onfinish=null,t&&iX()?(this.animation.timeline=t,n&&(this.animation.rangeStart=n),i&&(this.animation.rangeEnd=i),ws):s(this)}}const bD={anticipate:GR,backInOut:KR,circInOut:YR};function aX(e){return e in bD}function oX(e){typeof e.ease=="string"&&aX(e.ease)&&(e.ease=bD[e.ease])}const ox=10;class lX extends yD{constructor(t){oX(t),cD(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:a,...o}=this.options;if(!n)return;if(t!==void 0){n.set(t);return}const c=new rm({...o,autoplay:!1}),u=Math.max(ox,_i.now()-this.startTime),f=gr(0,ox,u-ox),m=c.sample(u).value,{name:p}=this.options;a&&p&&fD(a,p,m),n.setWithVelocity(c.sample(Math.max(0,u-f)).value,m,f),c.stop()}}const I2=(e,t)=>t==="zIndex"?!1:!!(typeof e=="number"||Array.isArray(e)||typeof e=="string"&&(qs.test(e)||e==="0")&&!e.startsWith("url("));function cX(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 uX(e,t,n,i){const s=e[0];if(s===null)return!1;if(t==="display"||t==="visibility")return!0;const a=e[e.length-1],o=I2(s,t),c=I2(a,t);return!o||!c?!1:cX(e)||(n==="spring"||gD(n))&&i}function $0(e){e.duration=0,e.type="keyframes"}const xD=new Set(["opacity","clipPath","filter","transform"]),dX=/^(?:oklch|oklab|lab|lch|color|color-mix|light-dark)\(/;function fX(e){for(let t=0;t<e.length;t++)if(typeof e[t]=="string"&&dX.test(e[t]))return!0;return!1}const hX=new Set(["color","backgroundColor","outlineColor","fill","stroke","borderColor","borderTopColor","borderRightColor","borderBottomColor","borderLeftColor"]),pX=UR(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));function mX(e){var p;const{motionValue:t,name:n,repeatDelay:i,repeatType:s,damping:a,type:o,keyframes:c}=e;if(!(((p=t==null?void 0:t.owner)==null?void 0:p.current)instanceof HTMLElement))return!1;const{onUpdate:f,transformTemplate:m}=t.owner.getProps();return pX()&&n&&(xD.has(n)||hX.has(n)&&fX(c))&&(n!=="transform"||!m)&&!f&&!i&&s!=="mirror"&&a!==0&&o!=="inertia"}const gX=40;class yX extends R1{constructor({autoplay:t=!0,delay:n=0,type:i="keyframes",repeat:s=0,repeatDelay:a=0,repeatType:o="loop",keyframes:c,name:u,motionValue:f,element:m,...p}){var x;super(),this.stop=()=>{var w,E;this._animation&&(this._animation.stop(),(w=this.stopTimeline)==null||w.call(this)),(E=this.keyframeResolver)==null||E.cancel()},this.createdAt=_i.now();const y={autoplay:t,delay:n,type:i,repeat:s,repeatDelay:a,repeatType:o,name:u,motionValue:f,element:m,...p},b=(m==null?void 0:m.KeyframeResolver)||D1;this.keyframeResolver=new b(c,(w,E,v)=>this.onKeyframesResolved(w,E,y,!v),u,f,m),(x=this.keyframeResolver)==null||x.scheduleResolve()}onKeyframesResolved(t,n,i,s){var v,_;this.keyframeResolver=void 0;const{name:a,type:o,velocity:c,delay:u,isHandoff:f,onUpdate:m}=i;this.resolvedAt=_i.now();let p=!0;uX(t,a,o,c)||(p=!1,(to.instantAnimations||!u)&&(m==null||m(Bm(t,i,n))),t[0]=t[t.length-1],$0(i),i.repeat=0);const b={startTime:s?this.resolvedAt?this.resolvedAt-this.createdAt>gX?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:n,...i,keyframes:t},x=p&&!f&&mX(b),w=(_=(v=b.motionValue)==null?void 0:v.owner)==null?void 0:_.current;let E;if(x)try{E=new lX({...b,element:w})}catch{E=new rm(b)}else E=new rm(b);E.finished.then(()=>{this.notifyFinished()}).catch(ws),this.pendingTimeline&&(this.stopTimeline=E.attachTimeline(this.pendingTimeline),this.pendingTimeline=void 0),this._animation=E}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(),eX()),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 vD(e,t,n,i=0,s=1){const a=Array.from(e).sort((f,m)=>f.sortNodePosition(m)).indexOf(t),o=e.size,c=(o-1)*i;return typeof n=="function"?n(a,o):s===1?a*i:c-a*i}const P2=30,bX=e=>!isNaN(parseFloat(e));class xX{constructor(t,n={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=i=>{var a;const s=_i.now();if(this.updatedAt!==s&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(i),this.current!==this.prev&&((a=this.events.change)==null||a.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=_i.now(),this.canTrackVelocity===null&&t!==void 0&&(this.canTrackVelocity=bX(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 k1);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=_i.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||t-this.updatedAt>P2)return 0;const n=Math.min(this.updatedAt-this.prevUpdatedAt,P2);return FR(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 Lc(e,t){return new xX(e,t)}function wD(e,t){if(e!=null&&e.inherit&&t){const{inherit:n,...i}=e;return{...t,...i}}return e}function O1(e,t){const n=(e==null?void 0:e[t])??(e==null?void 0:e.default)??e;return n!==e?wD(n,e):n}const vX={type:"spring",stiffness:500,damping:25,restSpeed:10},wX=e=>({type:"spring",stiffness:550,damping:e===0?2*Math.sqrt(550):30,restSpeed:10}),EX={type:"keyframes",duration:.8},SX={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},kX=(e,{keyframes:t})=>t.length>2?EX:Qc.has(e)?e.startsWith("scale")?wX(t[1]):vX:SX,NX=new Set(["when","delay","delayChildren","staggerChildren","staggerDirection","repeat","repeatType","repeatDelay","from","elapsed"]);function _X(e){for(const t in e)if(!NX.has(t))return!0;return!1}const L1=(e,t,n,i={},s,a)=>o=>{const c=O1(i,e)||{},u=c.delay||i.delay||0;let{elapsed:f=0}=i;f=f-ss(u);const m={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:a?void 0:s};_X(c)||Object.assign(m,kX(e,m)),m.duration&&(m.duration=ss(m.duration)),m.repeatDelay&&(m.repeatDelay=ss(m.repeatDelay)),m.from!==void 0&&(m.keyframes[0]=m.from);let p=!1;if((m.type===!1||m.duration===0&&!m.repeatDelay)&&($0(m),m.delay===0&&(p=!0)),(to.instantAnimations||to.skipAnimations||s!=null&&s.shouldSkipAnimations||c.skipAnimations)&&(p=!0,$0(m),m.delay=0),m.allowFlatten=!c.type&&!c.ease,p&&!a&&t.get()!==void 0){const y=Bm(m.keyframes,c);if(y!==void 0){un.update(()=>{m.onUpdate(y),m.onComplete()});return}}return c.isSync?new rm(m):new yX(m)},CX=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function TX(e){const t=CX.exec(e);if(!t)return[,];const[,n,i,s]=t;return[`--${n??i}`,s]}function ED(e,t,n=1){const[i,s]=TX(e);if(!i)return;const a=window.getComputedStyle(t).getPropertyValue(i);if(a){const o=a.trim();return PR(o)?parseFloat(o):o}return C1(s)?ED(s,t,n+1):s}function z2(e){const t=[{},{}];return e==null||e.values.forEach((n,i)=>{t[0][i]=n.get(),t[1][i]=n.getVelocity()}),t}function I1(e,t,n,i){if(typeof t=="function"){const[s,a]=z2(i);t=t(n!==void 0?n:e.custom,s,a)}if(typeof t=="string"&&(t=e.variants&&e.variants[t]),typeof t=="function"){const[s,a]=z2(i);t=t(n!==void 0?n:e.custom,s,a)}return t}function Qo(e,t,n){const i=e.getProps();return I1(i,t,n!==void 0?n:i.custom,e)}const SD=new Set(["width","height","top","left","right","bottom",...Xc]),q0=e=>Array.isArray(e);function AX(e,t,n){e.hasValue(t)?e.getValue(t).set(n):e.addValue(t,Lc(n))}function jX(e){return q0(e)?e[e.length-1]||0:e}function MX(e,t){const n=Qo(e,t);let{transitionEnd:i={},transition:s={},...a}=n||{};a={...a,...i};for(const o in a){const c=jX(a[o]);AX(e,o,c)}}const fi=e=>!!(e&&e.getVelocity);function RX(e){return!!(fi(e)&&e.add)}function H0(e,t){const n=e.getValue("willChange");if(RX(n))return n.add(t);if(!n&&to.WillChange){const i=new to.WillChange("auto");e.addValue("willChange",i),i.add(t)}}function P1(e){return e.replace(/([A-Z])/g,t=>`-${t.toLowerCase()}`)}const DX="framerAppearId",kD="data-"+P1(DX);function ND(e){return e.props[kD]}function OX({protectedKeys:e,needsAnimating:t},n){const i=e.hasOwnProperty(n)&&t[n]!==!0;return t[n]=!1,i}function _D(e,t,{delay:n=0,transitionOverride:i,type:s}={}){let{transition:a,transitionEnd:o,...c}=t;const u=e.getDefaultTransition();a=a?wD(a,u):u;const f=a==null?void 0:a.reduceMotion,m=a==null?void 0:a.skipAnimations;i&&(a=i);const p=[],y=s&&e.animationState&&e.animationState.getState()[s],b=a==null?void 0:a.path;b&&b.animateVisualElement(e,c,a,n,p);for(const x in c){const w=e.getValue(x,e.latestValues[x]??null),E=c[x];if(E===void 0||y&&OX(y,x))continue;const v={delay:n,...O1(a||{},x)};m&&(v.skipAnimations=!0);const _=w.get();if(_!==void 0&&!w.isAnimating()&&!Array.isArray(E)&&E===_&&!v.velocity){un.update(()=>w.set(E));continue}let k=!1;if(window.MotionHandoffAnimation){const j=ND(e);if(j){const M=window.MotionHandoffAnimation(j,x,un);M!==null&&(v.startTime=M,k=!0)}}H0(e,x);const T=f??e.shouldReduceMotion;w.start(L1(x,w,E,T&&SD.has(x)?{type:!1}:v,e,k));const A=w.animation;A&&p.push(A)}if(o){const x=()=>un.update(()=>{o&&MX(e,o)});p.length?Promise.all(p).then(x):x()}return p}function V0(e,t,n={}){var u;const i=Qo(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 a=i?()=>Promise.all(_D(e,i,n)):()=>Promise.resolve(),o=e.variantChildren&&e.variantChildren.size?(f=0)=>{const{delayChildren:m=0,staggerChildren:p,staggerDirection:y}=s;return LX(e,t,f,m,p,y,n)}:()=>Promise.resolve(),{when:c}=s;if(c){const[f,m]=c==="beforeChildren"?[a,o]:[o,a];return f().then(()=>m())}else return Promise.all([a(),o(n.delay)])}function LX(e,t,n=0,i=0,s=0,a=1,o){const c=[];for(const u of e.variantChildren)u.notify("AnimationStart",t),c.push(V0(u,t,{...o,delay:n+(typeof i=="function"?0:i)+vD(e.variantChildren,u,i,s,a)}).then(()=>u.notify("AnimationComplete",t)));return Promise.all(c)}function IX(e,t,n={}){e.notify("AnimationStart",t);let i;if(Array.isArray(t)){const s=t.map(a=>V0(e,a,n));i=Promise.all(s)}else if(typeof t=="string")i=V0(e,t,n);else{const s=typeof t=="function"?Qo(e,t,n.custom):t;i=Promise.all(_D(e,s,n))}return i.then(()=>{e.notify("AnimationComplete",t)})}const PX={test:e=>e==="auto",parse:e=>e},CD=e=>t=>t.test(e),TD=[Yc,Ke,hr,$r,cY,lY,PX],B2=e=>TD.find(CD(e));function zX(e){return typeof e=="number"?e===0:e!==null?e==="none"||e==="0"||BR(e):!0}const BX=new Set(["brightness","contrast","saturate","opacity"]);function UX(e){const[t,n]=e.slice(0,-1).split("(");if(t==="drop-shadow")return e;const[i]=n.match(T1)||[];if(!i)return e;const s=n.replace(i,"");let a=BX.has(t)?1:0;return i!==n&&(a*=100),t+"("+a+s+")"}const FX=/\b([a-z-]*)\(.*?\)/gu,K0={...qs,getAnimatableNone:e=>{const t=e.match(FX);return t?t.map(UX).join(" "):e}},G0={...qs,getAnimatableNone:e=>{const t=qs.parse(e);return qs.createTransformer(e)(t.map(i=>typeof i=="number"?0:typeof i=="object"?{...i,alpha:1}:i))}},U2={...Yc,transform:Math.round},$X={rotate:$r,pathRotation:$r,rotateX:$r,rotateY:$r,rotateZ:$r,scale:Xh,scaleX:Xh,scaleY:Xh,scaleZ:Xh,skew:$r,skewX:$r,skewY:$r,distance:Ke,translateX:Ke,translateY:Ke,translateZ:Ke,x:Ke,y:Ke,z:Ke,perspective:Ke,transformPerspective:Ke,opacity:Od,originX:_2,originY:_2,originZ:Ke},am={borderWidth:Ke,borderTopWidth:Ke,borderRightWidth:Ke,borderBottomWidth:Ke,borderLeftWidth:Ke,borderRadius:Ke,borderTopLeftRadius:Ke,borderTopRightRadius:Ke,borderBottomRightRadius:Ke,borderBottomLeftRadius:Ke,width:Ke,maxWidth:Ke,height:Ke,maxHeight:Ke,top:Ke,right:Ke,bottom:Ke,left:Ke,inset:Ke,insetBlock:Ke,insetBlockStart:Ke,insetBlockEnd:Ke,insetInline:Ke,insetInlineStart:Ke,insetInlineEnd:Ke,padding:Ke,paddingTop:Ke,paddingRight:Ke,paddingBottom:Ke,paddingLeft:Ke,paddingBlock:Ke,paddingBlockStart:Ke,paddingBlockEnd:Ke,paddingInline:Ke,paddingInlineStart:Ke,paddingInlineEnd:Ke,margin:Ke,marginTop:Ke,marginRight:Ke,marginBottom:Ke,marginLeft:Ke,marginBlock:Ke,marginBlockStart:Ke,marginBlockEnd:Ke,marginInline:Ke,marginInlineStart:Ke,marginInlineEnd:Ke,fontSize:Ke,backgroundPositionX:Ke,backgroundPositionY:Ke,...$X,zIndex:U2,fillOpacity:Od,strokeOpacity:Od,numOctaves:U2},qX={...am,color:Kn,backgroundColor:Kn,outlineColor:Kn,fill:Kn,stroke:Kn,borderColor:Kn,borderTopColor:Kn,borderRightColor:Kn,borderBottomColor:Kn,borderLeftColor:Kn,filter:K0,WebkitFilter:K0,mask:G0,WebkitMask:G0},AD=e=>qX[e],HX=new Set([K0,G0]);function jD(e,t){let n=AD(e);return HX.has(n)||(n=qs),n.getAnimatableNone?n.getAnimatableNone(t):void 0}const VX=new Set(["auto","none","0"]);function KX(e,t,n){let i=0,s;for(;i<e.length&&!s;){const a=e[i];typeof a=="string"&&!VX.has(a)&&Oc(a).values.length&&(s=e[i]),i++}if(s&&n)for(const a of t)e[a]=jD(n,s)}class GX extends D1{constructor(t,n,i,s,a){super(t,n,i,s,a,!0)}readKeyframes(){const{unresolvedKeyframes:t,element:n,name:i}=this;if(!n||!n.current)return;super.readKeyframes();for(let m=0;m<t.length;m++){let p=t[m];if(typeof p=="string"&&(p=p.trim(),C1(p))){const y=ED(p,n.current);y!==void 0&&(t[m]=y),m===t.length-1&&(this.finalKeyframe=p)}}if(this.resolveNoneKeyframes(),!SD.has(i)||t.length!==2)return;const[s,a]=t,o=B2(s),c=B2(a),u=N2(s),f=N2(a);if(u!==f&&Qa[i]){this.needsMeasurement=!0;return}if(o!==c)if(O2(o)&&O2(c))for(let m=0;m<t.length;m++){const p=t[m];typeof p=="string"&&(t[m]=parseFloat(p))}else Qa[i]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){const{unresolvedKeyframes:t,name:n}=this,i=[];for(let s=0;s<t.length;s++)(t[s]===null||zX(t[s]))&&i.push(s);i.length&&KX(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=Qa[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 a=i.length-1,o=i[a];i[a]=Qa[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 z1=["borderTopLeftRadius","borderTopRightRadius","borderBottomRightRadius","borderBottomLeftRadius"];function B1(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 W0=(e,t)=>t&&typeof e=="number"?t.transform(e):e;function WX(e){return zR(e)&&"offsetHeight"in e&&!("ownerSVGElement"in e)}const{schedule:U1}=ZR(queueMicrotask,!1),Os={x:!1,y:!1};function MD(){return Os.x||Os.y}function YX(e){return e==="x"||e==="y"?Os[e]?null:(Os[e]=!0,()=>{Os[e]=!1}):Os.x||Os.y?null:(Os.x=Os.y=!0,()=>{Os.x=Os.y=!1})}function RD(e,t){const n=B1(e),i=new AbortController,s={passive:!0,...t,signal:i.signal};return[n,s,()=>i.abort()]}function XX(e){return!(e.pointerType==="touch"||MD())}function QX(e,t,n={}){const[i,s,a]=RD(e,n);return i.forEach(o=>{let c=!1,u=!1,f;const m=()=>{o.removeEventListener("pointerleave",x)},p=E=>{f&&(f(E),f=void 0),m()},y=E=>{c=!1,window.removeEventListener("pointerup",y),window.removeEventListener("pointercancel",y),u&&(u=!1,p(E))},b=()=>{c=!0,window.addEventListener("pointerup",y,s),window.addEventListener("pointercancel",y,s)},x=E=>{if(E.pointerType!=="touch"){if(c){u=!0;return}p(E)}},w=E=>{if(!XX(E))return;u=!1;const v=t(o,E);typeof v=="function"&&(f=v,o.addEventListener("pointerleave",x,s))};o.addEventListener("pointerenter",w,s),o.addEventListener("pointerdown",b,s)}),a}const DD=(e,t)=>t?e===t?!0:DD(e,t.parentElement):!1,F1=e=>e.pointerType==="mouse"?typeof e.button!="number"||e.button<=0:e.isPrimary!==!1,ZX=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function JX(e){return ZX.has(e.tagName)||e.isContentEditable===!0}const eQ=new Set(["INPUT","SELECT","TEXTAREA"]);function tQ(e){return eQ.has(e.tagName)||e.isContentEditable===!0}const _p=new WeakSet;function F2(e){return t=>{t.key==="Enter"&&e(t)}}function lx(e,t){e.dispatchEvent(new PointerEvent("pointer"+t,{isPrimary:!0,bubbles:!0}))}const nQ=(e,t)=>{const n=e.currentTarget;if(!n)return;const i=F2(()=>{if(_p.has(n))return;lx(n,"down");const s=F2(()=>{lx(n,"up")}),a=()=>lx(n,"cancel");n.addEventListener("keyup",s,t),n.addEventListener("blur",a,t)});n.addEventListener("keydown",i,t),n.addEventListener("blur",()=>n.removeEventListener("keydown",i),t)};function $2(e){return F1(e)&&!MD()}const q2=new WeakSet;function iQ(e,t,n={}){const[i,s,a]=RD(e,n),o=c=>{const u=c.currentTarget;if(!$2(c)||q2.has(c))return;_p.add(u),n.stopPropagation&&q2.add(c);const f=t(u,c),m={...s,capture:!0},p=(x,w)=>{window.removeEventListener("pointerup",y,m),window.removeEventListener("pointercancel",b,m),_p.has(u)&&_p.delete(u),$2(x)&&typeof f=="function"&&f(x,{success:w})},y=x=>{p(x,u===window||u===document||n.useGlobalTarget||DD(u,x.target))},b=x=>{p(x,!1)};window.addEventListener("pointerup",y,m),window.addEventListener("pointercancel",b,m)};return i.forEach(c=>{(n.useGlobalTarget?window:c).addEventListener("pointerdown",o,s),WX(c)&&(c.addEventListener("focus",f=>nQ(f,s)),!JX(c)&&!c.hasAttribute("tabindex")&&(c.tabIndex=0))}),a}function $1(e){return zR(e)&&"ownerSVGElement"in e}const Cp=new WeakMap;let Ba;const OD=(e,t,n)=>(i,s)=>s&&s[0]?s[0][e+"Size"]:$1(i)&&"getBBox"in i?i.getBBox()[t]:i[n],sQ=OD("inline","width","offsetWidth"),rQ=OD("block","height","offsetHeight");function aQ({target:e,borderBoxSize:t}){var n;(n=Cp.get(e))==null||n.forEach(i=>{i(e,{get width(){return sQ(e,t)},get height(){return rQ(e,t)}})})}function oQ(e){e.forEach(aQ)}function lQ(){typeof ResizeObserver>"u"||(Ba=new ResizeObserver(oQ))}function cQ(e,t){Ba||lQ();const n=B1(e);return n.forEach(i=>{let s=Cp.get(i);s||(s=new Set,Cp.set(i,s)),s.add(t),Ba==null||Ba.observe(i)}),()=>{n.forEach(i=>{const s=Cp.get(i);s==null||s.delete(t),s!=null&&s.size||Ba==null||Ba.unobserve(i)})}}const Tp=new Set;let sc;function uQ(){sc=()=>{const e={get width(){return window.innerWidth},get height(){return window.innerHeight}};Tp.forEach(t=>t(e))},window.addEventListener("resize",sc)}function dQ(e){return Tp.add(e),sc||uQ(),()=>{Tp.delete(e),!Tp.size&&typeof sc=="function"&&(window.removeEventListener("resize",sc),sc=void 0)}}function H2(e,t){return typeof e=="function"?dQ(e):cQ(e,t)}function fQ(e){return $1(e)&&e.tagName==="svg"}const hQ=[...TD,Kn,qs],pQ=e=>hQ.find(CD(e)),V2=()=>({translate:0,scale:1,origin:0,originPoint:0}),rc=()=>({x:V2(),y:V2()}),K2=()=>({min:0,max:0}),Qn=()=>({x:K2(),y:K2()}),mQ=new WeakMap;function Um(e){return e!==null&&typeof e=="object"&&typeof e.start=="function"}function Ld(e){return typeof e=="string"||Array.isArray(e)}const q1=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],H1=["initial",...q1];function Fm(e){return Um(e.animate)||H1.some(t=>Ld(e[t]))}function LD(e){return!!(Fm(e)||e.variants)}function gQ(e,t,n){for(const i in t){const s=t[i],a=n[i];if(fi(s))e.addValue(i,s);else if(fi(a))e.addValue(i,Lc(s,{owner:e}));else if(a!==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,Lc(o!==void 0?o:s,{owner:e}))}}for(const i in n)t[i]===void 0&&e.removeValue(i);return t}const Y0={current:null},ID={current:!1},yQ=typeof window<"u";function bQ(){if(ID.current=!0,!!yQ)if(window.matchMedia){const e=window.matchMedia("(prefers-reduced-motion)"),t=()=>Y0.current=e.matches;e.addEventListener("change",t),t()}else Y0.current=!1}const G2=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];let om={};function PD(e){om=e}function xQ(){return om}class vQ{scrapeMotionValuesFromProps(t,n,i){return{}}constructor({parent:t,props:n,presenceContext:i,reducedMotionConfig:s,skipAnimations:a,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=D1,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=_i.now();this.renderScheduledAt<b&&(this.renderScheduledAt=b,un.render(this.render,!1,!0))};const{latestValues:f,renderState:m}=c;this.latestValues=f,this.baseTarget={...f},this.initialValues=n.initial?{...f}:{},this.renderState=m,this.parent=t,this.props=n,this.presenceContext=i,this.depth=t?t.depth+1:0,this.reducedMotionConfig=s,this.skipAnimationsConfig=a,this.options=u,this.blockInitialAnimation=!!o,this.isControllingVariants=Fm(n),this.isVariantNode=LD(n),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(t&&t.current);const{willChange:p,...y}=this.scrapeMotionValuesFromProps(n,{},this);for(const b in y){const x=y[b];f[b]!==void 0&&fi(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,mQ.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,a)=>this.bindToMotionValue(a,s)),this.reducedMotionConfig==="never"?this.shouldReduceMotion=!1:this.reducedMotionConfig==="always"?this.shouldReduceMotion=!0:(ID.current||bQ(),this.shouldReduceMotion=Y0.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(),no(this.notifyUpdate),no(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&&xD.has(t)&&this.current instanceof HTMLElement){const{factory:o,keyframes:c,times:u,ease:f,duration:m}=n.accelerate,p=new yD({element:this.current,name:t,keyframes:c,times:u,ease:f,duration:ss(m)}),y=o(p);this.valueSubscriptions.set(t,()=>{y(),p.cancel()});return}const i=Qc.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 a;typeof window<"u"&&window.MotionCheckAppearSync&&(a=window.MotionCheckAppearSync(this,t,n)),this.valueSubscriptions.set(t,()=>{s(),a&&a()})}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 om){const n=om[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 a=this.features[t];a.isMounted?a.update():(a.mount(),a.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):Qn()}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<G2.length;i++){const s=G2[i];this.propEventSubscriptions[s]&&(this.propEventSubscriptions[s](),delete this.propEventSubscriptions[s]);const a="on"+s,o=t[a];o&&(this.propEventSubscriptions[s]=this.on(s,o))}this.prevMotionValues=gQ(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=Lc(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"&&(PR(i)||BR(i))?i=parseFloat(i):!pQ(i)&&qs.test(n)&&(i=jD(t,n)),this.setBaseTarget(t,fi(i)?i.get():i)),fi(i)?i.get():i}setBaseTarget(t,n){this.baseTarget[t]=n}getBaseTarget(t){var a;const{initial:n}=this.props;let i;if(typeof n=="string"||typeof n=="object"){const o=I1(this.props,n,(a=this.presenceContext)==null?void 0:a.custom);o&&(i=o[t])}if(n&&i!==void 0)return i;const s=this.getBaseTargetFromProps(this.props,t);return s!==void 0&&!fi(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 k1),this.events[t].add(n)}notify(t,...n){this.events[t]&&this.events[t].notify(...n)}scheduleRenderMicrotask(){U1.render(this.render)}}class zD extends vQ{constructor(){super(...arguments),this.KeyframeResolver=GX}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;fi(t)&&(this.childSubscription=t.on("change",n=>{this.current&&(this.current.textContent=`${n}`)}))}}class oo{constructor(t){this.isMounted=!1,this.node=t}update(){}}function BD({top:e,left:t,right:n,bottom:i}){return{x:{min:t,max:n},y:{min:e,max:i}}}function wQ({x:e,y:t}){return{top:t.min,right:e.max,bottom:t.max,left:e.min}}function EQ(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 cx(e){return e===void 0||e===1}function X0({scale:e,scaleX:t,scaleY:n}){return!cx(e)||!cx(t)||!cx(n)}function Ro(e){return X0(e)||UD(e)||e.z||e.rotate||e.rotateX||e.rotateY||e.skewX||e.skewY}function UD(e){return W2(e.x)||W2(e.y)}function W2(e){return e&&e!=="0%"}function lm(e,t,n){const i=e-n,s=t*i;return n+s}function Y2(e,t,n,i,s){return s!==void 0&&(e=lm(e,s,i)),lm(e,n,i)+t}function Q0(e,t=0,n=1,i,s){e.min=Y2(e.min,t,n,i,s),e.max=Y2(e.max,t,n,i,s)}function FD(e,{x:t,y:n}){Q0(e.x,t.translate,t.scale,t.originPoint),Q0(e.y,n.translate,n.scale,n.originPoint)}const X2=.999999999999,Q2=1.0000000000001;function SQ(e,t,n,i=!1){var c;const s=n.length;if(!s)return;t.x=t.y=1;let a,o;for(let u=0;u<s;u++){a=n[u],o=a.projectionDelta;const{visualElement:f}=a.options;f&&f.props.style&&f.props.style.display==="contents"||(i&&a.options.layoutScroll&&a.scroll&&a!==a.root&&(dr(e.x,-a.scroll.offset.x),dr(e.y,-a.scroll.offset.y)),o&&(t.x*=o.x.scale,t.y*=o.y.scale,FD(e,o)),i&&Ro(a.latestValues)&&Ap(e,a.latestValues,(c=a.layout)==null?void 0:c.layoutBox))}t.x<Q2&&t.x>X2&&(t.x=1),t.y<Q2&&t.y>X2&&(t.y=1)}function dr(e,t){e.min+=t,e.max+=t}function Z2(e,t,n,i,s=.5){const a=cn(e.min,e.max,s);Q0(e,t,n,a,i)}function J2(e,t){return typeof e=="string"?parseFloat(e)/100*(t.max-t.min):e}function Ap(e,t,n){const i=n??e;Z2(e.x,J2(t.x,i.x),t.scaleX,t.scale,t.originX),Z2(e.y,J2(t.y,i.y),t.scaleY,t.scale,t.originY)}function $D(e,t){return BD(EQ(e.getBoundingClientRect(),t))}function kQ(e,t,n){const i=$D(e,n),{scroll:s}=t;return s&&(dr(i.x,s.offset.x),dr(i.y,s.offset.y)),i}const NQ={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},_Q=Xc.length;function CQ(e,t,n){let i="",s=!0;for(let o=0;o<_Q;o++){const c=Xc[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 m=parseFloat(u);f=c.startsWith("scale")?m===1:m===0}if(!f||n){const m=W0(u,am[c]);if(!f){s=!1;const p=NQ[c]||c;i+=`${p}(${m}) `}n&&(t[c]=m)}}const a=e.pathRotation;return a&&(s=!1,i+=`rotate(${W0(a,am.pathRotation)}) `),i=i.trim(),n?i=n(t,s?"":i):s&&(i="none"),i}function V1(e,t,n){const{style:i,vars:s,transformOrigin:a}=e;let o=!1,c=!1;for(const u in t){const f=t[u];if(Qc.has(u)){o=!0;continue}else if(eD(u)){s[u]=f;continue}else{const m=W0(f,am[u]);u.startsWith("origin")?(c=!0,a[u]=m):i[u]=m}}if(t.transform||(o||n?i.transform=CQ(t,e.transform,n):i.transform&&(i.transform="none")),c){const{originX:u="50%",originY:f="50%",originZ:m=0}=a;i.transformOrigin=`${u} ${f} ${m}`}}function qD(e,{style:t,vars:n},i,s){const a=e.style;let o;for(o in t)a[o]=t[o];s==null||s.applyProjectionStyles(a,i);for(o in n)a.setProperty(o,n[o])}function eC(e,t){return t.max===t.min?0:e/(t.max-t.min)*100}const id={correct:(e,t)=>{if(!t.target)return e;if(typeof e=="string")if(Ke.test(e))e=parseFloat(e);else return e;const n=eC(e,t.target.x),i=eC(e,t.target.y);return`${n}% ${i}%`}},TQ={correct:(e,{treeScale:t,projectionDelta:n})=>{const i=e,s=qs.parse(e);if(s.length>5)return i;const a=qs.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),a(s)}},Z0={borderRadius:{...id,applyTo:[...z1]},borderTopLeftRadius:id,borderTopRightRadius:id,borderBottomLeftRadius:id,borderBottomRightRadius:id,boxShadow:TQ};function HD(e,{layout:t,layoutId:n}){return Qc.has(e)||e.startsWith("origin")||(t||n!==void 0)&&(!!Z0[e]||e==="opacity")}function K1(e,t,n){var o;const i=e.style,s=t==null?void 0:t.style,a={};if(!i)return a;for(const c in i)(fi(i[c])||s&&fi(s[c])||HD(c,e)||((o=n==null?void 0:n.getValue(c))==null?void 0:o.liveStyle)!==void 0)&&(a[c]=i[c]);return a}function AQ(e){return window.getComputedStyle(e)}class jQ extends zD{constructor(){super(...arguments),this.type="html",this.renderInstance=qD}readValueFromInstance(t,n){var i;if(Qc.has(n))return(i=this.projection)!=null&&i.isProjecting?P0(n):YY(t,n);{const s=AQ(t),a=(eD(n)?s.getPropertyValue(n):s[n])||0;return typeof a=="string"?a.trim():a}}measureInstanceViewportBox(t,{transformPagePoint:n}){return $D(t,n)}build(t,n,i){V1(t,n,i.transformTemplate)}scrapeMotionValuesFromProps(t,n,i){return K1(t,n,i)}}const MQ={offset:"stroke-dashoffset",array:"stroke-dasharray"},RQ={offset:"strokeDashoffset",array:"strokeDasharray"};function DQ(e,t,n=1,i=0,s=!0){e.pathLength=1;const a=s?MQ:RQ;e[a.offset]=`${-i}`,e[a.array]=`${t} ${n}`}const OQ=["offsetDistance","offsetPath","offsetRotate","offsetAnchor"];function VD(e,{attrX:t,attrY:n,attrScale:i,pathLength:s,pathSpacing:a=1,pathOffset:o=0,...c},u,f,m){if(V1(e,c,f),u){e.style.viewBox&&(e.attrs.viewBox=e.style.viewBox);return}e.attrs=e.style,e.style={};const{attrs:p,style:y}=e;p.transform&&(y.transform=p.transform,delete p.transform),(y.transform||p.transformOrigin)&&(y.transformOrigin=p.transformOrigin??"50% 50%",delete p.transformOrigin),y.transform&&(y.transformBox=(m==null?void 0:m.transformBox)??"fill-box",delete p.transformBox);for(const b of OQ)p[b]!==void 0&&(y[b]=p[b],delete p[b]);t!==void 0&&(p.x=t),n!==void 0&&(p.y=n),i!==void 0&&(p.scale=i),s!==void 0&&DQ(p,s,a,o,!1)}const KD=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"]),GD=e=>typeof e=="string"&&e.toLowerCase()==="svg";function LQ(e,t,n,i){qD(e,t,void 0,i);for(const s in t.attrs)e.setAttribute(KD.has(s)?s:P1(s),t.attrs[s])}function WD(e,t,n){const i=K1(e,t,n);for(const s in e)if(fi(e[s])||fi(t[s])){const a=Xc.indexOf(s)!==-1?"attr"+s.charAt(0).toUpperCase()+s.substring(1):s;i[a]=e[s]}return i}class IQ extends zD{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=Qn}getBaseTargetFromProps(t,n){return t[n]}readValueFromInstance(t,n){if(Qc.has(n)){const i=AD(n);return i&&i.default||0}return n=KD.has(n)?n:P1(n),t.getAttribute(n)}scrapeMotionValuesFromProps(t,n,i){return WD(t,n,i)}build(t,n,i){VD(t,n,this.isSVGTag,i.transformTemplate,i.style)}renderInstance(t,n,i,s){LQ(t,n,i,s)}mount(t){this.isSVGTag=GD(t.tagName),super.mount(t)}}const PQ=H1.length;function YD(e){if(!e)return;if(!e.isControllingVariants){const n=e.parent?YD(e.parent)||{}:{};return e.props.initial!==void 0&&(n.initial=e.props.initial),n}const t={};for(let n=0;n<PQ;n++){const i=H1[n],s=e.props[i];(Ld(s)||s===!1)&&(t[i]=s)}return t}function XD(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 zQ=[...q1].reverse(),BQ=q1.length;function UQ(e){return t=>Promise.all(t.map(({animation:n,options:i})=>IX(e,n,i)))}function FQ(e){let t=UQ(e),n=tC(),i=!0,s=!1;const a=f=>(m,p)=>{var b;const y=Qo(e,p,f==="exit"?(b=e.presenceContext)==null?void 0:b.custom:void 0);if(y){const{transition:x,transitionEnd:w,...E}=y;m={...m,...E,...w}}return m};function o(f){t=f(e)}function c(f){const{props:m}=e,p=YD(e.parent)||{},y=[],b=new Set;let x={},w=1/0;for(let v=0;v<BQ;v++){const _=zQ[v],k=n[_],T=m[_]!==void 0?m[_]:p[_],A=Ld(T),j=_===f?k.isActive:null;j===!1&&(w=v);let M=T===p[_]&&T!==m[_]&&A;if(M&&(i||s)&&e.manuallyAnimateOnMount&&(M=!1),k.protectedKeys={...x},!k.isActive&&j===null||!T&&!k.prevProp||Um(T)||typeof T=="boolean")continue;if(_==="exit"&&k.isActive&&j!==!0){k.prevResolvedValues&&(x={...x,...k.prevResolvedValues});continue}const D=$Q(k.prevProp,T);let I=D||_===f&&k.isActive&&!M&&A||v>w&&A,P=!1;const U=Array.isArray(T)?T:[T];let q=U.reduce(a(_),{});j===!1&&(q={});const{prevResolvedValues:V={}}=k,O={...V,...q},R=X=>{I=!0,b.has(X)&&(P=!0,b.delete(X)),k.needsAnimating[X]=!0;const K=e.getValue(X);K&&(K.liveStyle=!1)};for(const X in O){const K=q[X],B=V[X];if(x.hasOwnProperty(X))continue;let F=!1;q0(K)&&q0(B)?F=!XD(K,B)||D:F=K!==B,F?K!=null?R(X):b.add(X):K!==void 0&&b.has(X)?R(X):k.protectedKeys[X]=!0}k.prevProp=T,k.prevResolvedValues=q,k.isActive&&(x={...x,...q}),(i||s)&&e.blockInitialAnimation&&(I=!1);const z=M&&D;I&&(!z||P)&&y.push(...U.map(X=>{const K={type:_};if(typeof X=="string"&&(i||s)&&!z&&e.manuallyAnimateOnMount&&e.parent){const{parent:B}=e,F=Qo(B,X);if(B.enteringChildren&&F){const{delayChildren:W}=F.transition||{};K.delay=vD(B.enteringChildren,e,W)}}return{animation:X,options:K}}))}if(b.size){const v={};if(typeof m.initial!="boolean"){const _=Qo(e,Array.isArray(m.initial)?m.initial[0]:m.initial);_&&_.transition&&(v.transition=_.transition)}b.forEach(_=>{const k=e.getBaseTarget(_),T=e.getValue(_);T&&(T.liveStyle=!0),v[_]=k??null}),y.push({animation:v})}let E=!!y.length;return i&&(m.initial===!1||m.initial===m.animate)&&!e.manuallyAnimateOnMount&&(E=!1),i=!1,s=!1,E?t(y):Promise.resolve()}function u(f,m){var y;if(n[f].isActive===m)return Promise.resolve();(y=e.variantChildren)==null||y.forEach(b=>{var x;return(x=b.animationState)==null?void 0:x.setActive(f,m)}),n[f].isActive=m;const p=c(f);for(const b in n)n[b].protectedKeys={};return p}return{animateChanges:c,setActive:u,setAnimateFunction:o,getState:()=>n,reset:()=>{n=tC(),s=!0}}}function $Q(e,t){return typeof t=="string"?t!==e:Array.isArray(t)?!XD(t,e):!1}function Co(e=!1){return{isActive:e,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function tC(){return{animate:Co(!0),whileInView:Co(),whileHover:Co(),whileTap:Co(),whileDrag:Co(),whileFocus:Co(),exit:Co()}}function J0(e,t){e.min=t.min,e.max=t.max}function Rs(e,t){J0(e.x,t.x),J0(e.y,t.y)}function nC(e,t){e.translate=t.translate,e.scale=t.scale,e.originPoint=t.originPoint,e.origin=t.origin}const QD=1e-4,qQ=1-QD,HQ=1+QD,ZD=.01,VQ=0-ZD,KQ=0+ZD;function Ci(e){return e.max-e.min}function GQ(e,t,n){return Math.abs(e-t)<=n}function iC(e,t,n,i=.5){e.origin=i,e.originPoint=cn(t.min,t.max,e.origin),e.scale=Ci(n)/Ci(t),e.translate=cn(n.min,n.max,e.origin)-e.originPoint,(e.scale>=qQ&&e.scale<=HQ||isNaN(e.scale))&&(e.scale=1),(e.translate>=VQ&&e.translate<=KQ||isNaN(e.translate))&&(e.translate=0)}function Ed(e,t,n,i){iC(e.x,t.x,n.x,i?i.originX:void 0),iC(e.y,t.y,n.y,i?i.originY:void 0)}function sC(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+Ci(t)}function WQ(e,t,n,i){sC(e.x,t.x,n.x,i==null?void 0:i.x),sC(e.y,t.y,n.y,i==null?void 0:i.y)}function rC(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+Ci(t)}function cm(e,t,n,i){rC(e.x,t.x,n.x,i==null?void 0:i.x),rC(e.y,t.y,n.y,i==null?void 0:i.y)}function aC(e,t,n,i,s){return e-=t,e=lm(e,1/n,i),s!==void 0&&(e=lm(e,1/s,i)),e}function YQ(e,t=0,n=1,i=.5,s,a=e,o=e){if(hr.test(t)&&(t=parseFloat(t),t=cn(o.min,o.max,t/100)-o.min),typeof t!="number")return;let c=cn(a.min,a.max,i);e===a&&(c-=t),e.min=aC(e.min,t,n,c,s),e.max=aC(e.max,t,n,c,s)}function oC(e,t,[n,i,s],a,o){YQ(e,t[n],t[i],t[s],t.scale,a,o)}const XQ=["x","scaleX","originX"],QQ=["y","scaleY","originY"];function lC(e,t,n,i){oC(e.x,t,XQ,n?n.x:void 0,i?i.x:void 0),oC(e.y,t,QQ,n?n.y:void 0,i?i.y:void 0)}function cC(e){return e.translate===0&&e.scale===1}function JD(e){return cC(e.x)&&cC(e.y)}function uC(e,t){return e.min===t.min&&e.max===t.max}function ZQ(e,t){return uC(e.x,t.x)&&uC(e.y,t.y)}function dC(e,t){return Math.round(e.min)===Math.round(t.min)&&Math.round(e.max)===Math.round(t.max)}function eO(e,t){return dC(e.x,t.x)&&dC(e.y,t.y)}function fC(e){return Ci(e.x)/Ci(e.y)}function hC(e,t){return e.translate===t.translate&&e.scale===t.scale&&e.originPoint===t.originPoint}function or(e){return[e("x"),e("y")]}function JQ(e,t,n){let i="";const s=e.x.translate/t.x,a=e.y.translate/t.y,o=(n==null?void 0:n.z)||0;if((s||a||o)&&(i=`translate3d(${s}px, ${a}px, ${o}px) `),(t.x!==1||t.y!==1)&&(i+=`scale(${1/t.x}, ${1/t.y}) `),n){const{transformPerspective:f,rotate:m,pathRotation:p,rotateX:y,rotateY:b,skewX:x,skewY:w}=n;f&&(i=`perspective(${f}px) ${i}`),m&&(i+=`rotate(${m}deg) `),p&&(i+=`rotate(${p}deg) `),y&&(i+=`rotateX(${y}deg) `),b&&(i+=`rotateY(${b}deg) `),x&&(i+=`skewX(${x}deg) `),w&&(i+=`skewY(${w}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 eZ=z1.length,pC=e=>typeof e=="string"?parseFloat(e):e,mC=e=>typeof e=="number"||Ke.test(e);function tZ(e,t,n,i,s,a){s?(e.opacity=cn(0,n.opacity??1,nZ(i)),e.opacityExit=cn(t.opacity??1,0,iZ(i))):a&&(e.opacity=cn(t.opacity??1,n.opacity??1,i));for(let o=0;o<eZ;o++){const c=z1[o];let u=gC(t,c),f=gC(n,c);if(u===void 0&&f===void 0)continue;u||(u=0),f||(f=0),u===0||f===0||mC(u)===mC(f)?(e[c]=Math.max(cn(pC(u),pC(f),i),0),(hr.test(f)||hr.test(u))&&(e[c]+="%")):e[c]=f}(t.rotate||n.rotate)&&(e.rotate=cn(t.rotate||0,n.rotate||0,i))}function gC(e,t){return e[t]!==void 0?e[t]:e.borderRadius}const nZ=tO(0,.5,WR),iZ=tO(.5,.95,ws);function tO(e,t,n){return i=>i<e?0:i>t?1:n(Dd(e,t,i))}function sZ(e,t,n){const i=fi(e)?e:Lc(e);return i.start(L1("",i,t,n)),i.animation}function Id(e,t,n,i={passive:!0}){return e.addEventListener(t,n,i),()=>e.removeEventListener(t,n,i)}const rZ=(e,t)=>e.depth-t.depth;class aZ{constructor(){this.children=[],this.isDirty=!1}add(t){E1(this.children,t),this.isDirty=!0}remove(t){tm(this.children,t),this.isDirty=!0}forEach(t){this.isDirty&&this.children.sort(rZ),this.isDirty=!1,this.children.forEach(t)}}function oZ(e,t){const n=_i.now(),i=({timestamp:s})=>{const a=s-n;a>=t&&(no(i),e(a-t))};return un.setup(i,!0),()=>no(i)}function jp(e){return fi(e)?e.get():e}class lZ{constructor(){this.members=[]}add(t){E1(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&&(tm(this.members,i),i.unmount())}t.scheduleRender()}remove(t){if(tm(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:a}=i.options,{layoutDependency:o}=t.options;(a===void 0||a!==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,a,o;(i=(n=t.options).onExitComplete)==null||i.call(n),(o=(s=t.resumingFrom)==null?void 0:(a=s.options).onExitComplete)==null||o.call(a)})}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 Mp={hasAnimatedSinceResize:!0,hasEverUpdated:!1},ux=["","X","Y","Z"],cZ=1e3;let uZ=0;function dx(e,t,n,i){const{latestValues:s}=t;s[e]&&(n[e]=s[e],t.setStaticValue(e,0),i&&(i[e]=0))}function nO(e){if(e.hasCheckedOptimisedAppear=!0,e.root===e)return;const{visualElement:t}=e.options;if(!t)return;const n=ND(t);if(window.MotionHasOptimisedAnimation(n,"transform")){const{layout:s,layoutId:a}=e.options;window.MotionCancelOptimisedAnimation(n,"transform",un,!(s||a))}const{parent:i}=e;i&&!i.hasCheckedOptimisedAppear&&nO(i)}function iO({attachResizeListener:e,defaultParent:t,measureScroll:n,checkIsScrollRoot:i,resetTransform:s}){return class{constructor(o={},c=t==null?void 0:t()){this.id=uZ++,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(hZ),this.nodes.forEach(xZ),this.nodes.forEach(vZ),this.nodes.forEach(pZ)},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 aZ)}addEventListener(o,c){return this.eventHandlers.has(o)||this.eventHandlers.set(o,new k1),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=$1(o)&&!fQ(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 m,p=0;const y=()=>this.root.updateBlockedByResize=!1;un.read(()=>{p=window.innerWidth}),e(o,()=>{const b=window.innerWidth;b!==p&&(p=b,this.root.updateBlockedByResize=!0,m&&m(),m=oZ(y,250),Mp.hasAnimatedSinceResize&&(Mp.hasAnimatedSinceResize=!1,this.nodes.forEach(xC)))})}c&&this.root.registerSharedNode(c,this),this.options.animate!==!1&&f&&(c||u)&&this.addEventListener("didUpdate",({delta:m,hasLayoutChanged:p,hasRelativeLayoutChanged:y,layout:b})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const x=this.options.transition||f.getDefaultTransition()||NZ,{onLayoutAnimationStart:w,onLayoutAnimationComplete:E}=f.getProps(),v=!this.targetLayout||!eO(this.targetLayout,b),_=!p&&y;if(this.options.layoutRoot||this.resumeFrom||_||p&&(v||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);const k={...O1(x,"layout"),onPlay:w,onComplete:E};(f.shouldReduceMotion||this.options.layoutRoot)&&(k.delay=0,k.type=!1),this.startAnimation(k),this.setAnimationOrigin(m,_,k.path)}else p||xC(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(),no(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(wZ),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&&nO(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let m=0;m<this.path.length;m++){const p=this.path[m];p.shouldResetTransform=!0,(typeof p.latestValues.x=="string"||typeof p.latestValues.y=="string")&&(p.isLayoutDirty=!0),p.updateScroll("snapshot"),p.options.layoutRoot&&p.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(gZ),this.nodes.forEach(yC);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(bC);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(yZ),this.nodes.forEach(bZ),this.nodes.forEach(dZ),this.nodes.forEach(fZ)):this.nodes.forEach(bC),this.clearAllSnapshots();const c=_i.now();di.delta=gr(0,1e3/60,c-di.timestamp),di.timestamp=c,di.isProcessing=!0,nx.update.process(di),nx.preRender.process(di),nx.render.process(di),di.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,U1.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(mZ),this.sharedNodes.forEach(EZ)}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&&!Ci(this.snapshot.measuredBox.x)&&!Ci(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=Qn()),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&&!JD(this.projectionDelta),u=this.getTransformTemplate(),f=u?u(this.latestValues,""):void 0,m=f!==this.prevTransformTemplateValue;o&&this.instance&&(c||Ro(this.latestValues)||m)&&(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)),_Z(u),{animationId:this.root.animationId,measuredBox:c,layoutBox:u,latestValues:{},source:this.id}}measurePageBox(){var f;const{visualElement:o}=this.options;if(!o)return Qn();const c=o.measureViewportBox();if(!(((f=this.scroll)==null?void 0:f.wasRoot)||this.path.some(CZ))){const{scroll:m}=this.root;m&&(dr(c.x,m.offset.x),dr(c.y,m.offset.y))}return c}removeElementScroll(o){var u;const c=Qn();if(Rs(c,o),(u=this.scroll)!=null&&u.wasRoot)return c;for(let f=0;f<this.path.length;f++){const m=this.path[f],{scroll:p,options:y}=m;m!==this.root&&p&&y.layoutScroll&&(p.wasRoot&&Rs(c,o),dr(c.x,p.offset.x),dr(c.y,p.offset.y))}return c}applyTransform(o,c=!1,u){var m,p;const f=u||Qn();Rs(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&&(dr(f.x,-b.scroll.offset.x),dr(f.y,-b.scroll.offset.y)),Ro(b.latestValues)&&Ap(f,b.latestValues,(m=b.layout)==null?void 0:m.layoutBox)}return Ro(this.latestValues)&&Ap(f,this.latestValues,(p=this.layout)==null?void 0:p.layoutBox),f}removeTransform(o){var u;const c=Qn();Rs(c,o);for(let f=0;f<this.path.length;f++){const m=this.path[f];if(!Ro(m.latestValues))continue;let p;m.instance&&(X0(m.latestValues)&&m.updateSnapshot(),p=Qn(),Rs(p,m.measurePageBox())),lC(c,m.latestValues,(u=m.snapshot)==null?void 0:u.layoutBox,p)}return Ro(this.latestValues)&&lC(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!==di.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:m,layoutId:p}=this.options;if(!this.layout||!(m||p))return;this.resolvedRelativeTargetAt=di.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=Qn(),this.targetWithTransforms=Qn()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),WQ(this.target,this.relativeTarget,this.relativeParent.target,this.options.layoutAnchor||void 0)):this.targetDelta?(this.resumingFrom?this.applyTransform(this.layout.layoutBox,!1,this.target):Rs(this.target,this.layout.layoutBox),FD(this.target,this.targetDelta)):Rs(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||X0(this.parent.latestValues)||UD(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=Qn(),this.relativeTargetOrigin=Qn(),cm(this.relativeTargetOrigin,c,u,this.options.layoutAnchor||void 0),Rs(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===di.timestamp&&(u=!1),u)return;const{layout:f,layoutId:m}=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||m))return;Rs(this.layoutCorrected,this.layout.layoutBox);const p=this.treeScale.x,y=this.treeScale.y;SQ(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=Qn());const{target:b}=o;if(!b){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(nC(this.prevProjectionDelta.x,this.projectionDelta.x),nC(this.prevProjectionDelta.y,this.projectionDelta.y)),Ed(this.projectionDelta,this.layoutCorrected,b,this.latestValues),(this.treeScale.x!==p||this.treeScale.y!==y||!hC(this.projectionDelta.x,this.prevProjectionDelta.x)||!hC(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=rc(),this.projectionDelta=rc(),this.projectionDeltaWithTransform=rc()}setAnimationOrigin(o,c=!1,u){const f=this.snapshot,m=f?f.latestValues:{},p={...this.latestValues},y=rc();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!c;const b=Qn(),x=f?f.source:void 0,w=this.layout?this.layout.source:void 0,E=x!==w,v=this.getStack(),_=!v||v.members.length<=1,k=!!(E&&!_&&this.options.crossfade===!0&&!this.path.some(kZ));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):(vC(y.x,o.x,M),vC(y.y,o.y,M)),this.setTargetDelta(y),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(cm(b,this.layout.layoutBox,this.relativeParent.layout.layoutBox,this.options.layoutAnchor||void 0),SZ(this.relativeTarget,this.relativeTargetOrigin,b,M),T&&ZQ(this.relativeTarget,T)&&(this.isProjectionDirty=!1),T||(T=Qn()),Rs(T,this.relativeTarget)),E&&(this.animationValues=p,tZ(p,m,this.latestValues,M,k,_)),D&&D.rotate!==void 0&&(this.animationValues||(this.animationValues=p),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&&(no(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=un.update(()=>{Mp.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=Lc(0)),this.motionValue.jump(0,!1),this.currentAnimation=sZ(this.motionValue,[0,1e3],{...o,velocity:0,isSync:!0,onUpdate:m=>{this.mixTargetDelta(m),o.onUpdate&&o.onUpdate(m)},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(cZ),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const o=this.getLead();let{targetWithTransforms:c,target:u,layout:f,latestValues:m}=o;if(!(!c||!u||!f)){if(this!==o&&this.layout&&f&&sO(this.options.animationType,this.layout.layoutBox,f.layoutBox)){u=this.target||Qn();const p=Ci(this.layout.layoutBox.x);u.x.min=o.target.x.min,u.x.max=u.x.min+p;const y=Ci(this.layout.layoutBox.y);u.y.min=o.target.y.min,u.y.max=u.y.min+y}Rs(c,u),Ap(c,m),Ed(this.projectionDeltaWithTransform,this.layoutCorrected,c,m)}}registerSharedNode(o,c){this.sharedNodes.has(o)||this.sharedNodes.set(o,new lZ),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&&dx("z",o,f,this.animationValues);for(let m=0;m<ux.length;m++)dx(`rotate${ux[m]}`,o,f,this.animationValues),dx(`skew${ux[m]}`,o,f,this.animationValues);o.render();for(const m in f)o.setStaticValue(m,f[m]),this.animationValues&&(this.animationValues[m]=f[m]);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=jp(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=jp(c==null?void 0:c.pointerEvents)||""),this.hasProjected&&!Ro(this.latestValues)&&(o.transform=u?u({},""):"none",this.hasProjected=!1);return}o.visibility="";const m=f.animationValues||f.latestValues;this.applyTransformsToTarget();let p=JQ(this.projectionDeltaWithTransform,this.treeScale,m);u&&(p=u(m,p)),o.transform=p;const{x:y,y:b}=this.projectionDelta;o.transformOrigin=`${y.origin*100}% ${b.origin*100}% 0`,f.animationValues?o.opacity=f===this?m.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:m.opacityExit:o.opacity=f===this?m.opacity!==void 0?m.opacity:"":m.opacityExit!==void 0?m.opacityExit:0;for(const x in Z0){if(m[x]===void 0)continue;const{correct:w,applyTo:E,isCSSVariable:v}=Z0[x],_=p==="none"?m[x]:w(m[x],f);if(E){const k=E.length;for(let T=0;T<k;T++)o[E[T]]=_}else v?this.options.visualElement.renderState.vars[x]=_:o[x]=_}this.options.layoutId&&(o.pointerEvents=f===this?jp(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(yC),this.root.sharedNodes.clear()}}}function dZ(e){e.updateLayout()}function fZ(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:a}=e.options,o=t.source!==e.layout.source;if(a==="size")or(p=>{const y=o?t.measuredBox[p]:t.layoutBox[p],b=Ci(y);y.min=i[p].min,y.max=y.min+b});else if(a==="x"||a==="y"){const p=a==="x"?"y":"x";J0(o?t.measuredBox[p]:t.layoutBox[p],i[p])}else sO(a,t.layoutBox,i)&&or(p=>{const y=o?t.measuredBox[p]:t.layoutBox[p],b=Ci(i[p]);y.max=y.min+b,e.relativeTarget&&!e.currentAnimation&&(e.isProjectionDirty=!0,e.relativeTarget[p].max=e.relativeTarget[p].min+b)});const c=rc();Ed(c,i,t.layoutBox);const u=rc();o?Ed(u,e.applyTransform(s,!0),t.measuredBox):Ed(u,i,t.layoutBox);const f=!JD(c);let m=!1;if(!e.resumeFrom){const p=e.getClosestProjectingParent();if(p&&!p.resumeFrom){const{snapshot:y,layout:b}=p;if(y&&b){const x=e.options.layoutAnchor||void 0,w=Qn();cm(w,t.layoutBox,y.layoutBox,x);const E=Qn();cm(E,i,b.layoutBox,x),eO(w,E)||(m=!0),p.options.layoutRoot&&(e.relativeTarget=E,e.relativeTargetOrigin=w,e.relativeParent=p)}}}e.notifyListeners("didUpdate",{layout:i,snapshot:t,delta:u,layoutDelta:c,hasLayoutChanged:f,hasRelativeLayoutChanged:m})}else if(e.isLead()){const{onExitComplete:i}=e.options;i&&i()}e.options.transition=void 0}function hZ(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 pZ(e){e.isProjectionDirty=e.isSharedProjectionDirty=e.isTransformDirty=!1}function mZ(e){e.clearSnapshot()}function yC(e){e.clearMeasurements()}function gZ(e){e.isLayoutDirty=!0,e.updateLayout()}function bC(e){e.isLayoutDirty=!1}function yZ(e){e.isAnimationBlocked&&e.layout&&!e.isLayoutDirty&&(e.snapshot=e.layout,e.isLayoutDirty=!0)}function bZ(e){const{visualElement:t}=e.options;t&&t.getProps().onBeforeLayoutMeasure&&t.notify("BeforeLayoutMeasure"),e.resetTransform()}function xC(e){e.finishAnimation(),e.targetDelta=e.relativeTarget=e.target=void 0,e.isProjectionDirty=!0}function xZ(e){e.resolveTargetDelta()}function vZ(e){e.calcProjection()}function wZ(e){e.resetSkewAndRotation()}function EZ(e){e.removeLeadSnapshot()}function vC(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 wC(e,t,n,i){e.min=cn(t.min,n.min,i),e.max=cn(t.max,n.max,i)}function SZ(e,t,n,i){wC(e.x,t.x,n.x,i),wC(e.y,t.y,n.y,i)}function kZ(e){return e.animationValues&&e.animationValues.opacityExit!==void 0}const NZ={duration:.45,ease:[.4,0,.1,1]},EC=e=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(e),SC=EC("applewebkit/")&&!EC("chrome/")?Math.round:ws;function kC(e){e.min=SC(e.min),e.max=SC(e.max)}function _Z(e){kC(e.x),kC(e.y)}function sO(e,t,n){return e==="position"||e==="preserve-aspect"&&!GQ(fC(t),fC(n),.2)}function CZ(e){var t;return e!==e.root&&((t=e.scroll)==null?void 0:t.wasRoot)}const TZ=iO({attachResizeListener:(e,t)=>Id(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}),fx={current:void 0},rO=iO({measureScroll:e=>({x:e.scrollLeft,y:e.scrollTop}),defaultParent:()=>{if(!fx.current){const e=new TZ({});e.mount(window),e.setOptions({layoutScroll:!0}),fx.current=e}return fx.current},resetTransform:(e,t)=>{e.style.transform=t!==void 0?t:"none"},checkIsScrollRoot:e=>window.getComputedStyle(e).position==="fixed"}),aO=C.createContext({transformPagePoint:e=>e,isStatic:!1,reducedMotion:"never"});function AZ(e=!0){const t=C.useContext(w1);if(t===null)return[!0,null];const{isPresent:n,onExitComplete:i,register:s}=t,a=C.useId();C.useEffect(()=>{if(e)return s(a)},[e]);const o=C.useCallback(()=>e&&i&&i(a),[a,i,e]);return!n&&i?[!1,o]:[!0]}const oO=C.createContext({strict:!1}),NC={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 _C=!1;function jZ(){if(_C)return;const e={};for(const t in NC)e[t]={isEnabled:n=>NC[t].some(i=>!!n[i])};PD(e),_C=!0}function lO(){return jZ(),xQ()}function MZ(e){const t=lO();for(const n in e)t[n]={...t[n],...e[n]};PD(t)}const RZ=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 um(e){return e.startsWith("while")||e.startsWith("drag")&&e!=="draggable"||e.startsWith("layout")||e.startsWith("onTap")||e.startsWith("onPan")||e.startsWith("onLayout")||RZ.has(e)}let cO=e=>!um(e);function DZ(e){typeof e=="function"&&(cO=t=>t.startsWith("on")?!um(t):e(t))}try{DZ(require("@emotion/is-prop-valid").default)}catch{}function OZ(e,t,n){const i={};for(const s in e)s==="values"&&typeof e.values=="object"||fi(e[s])||(cO(s)||n===!0&&um(s)||!t&&!um(s)||e.draggable&&s.startsWith("onDrag"))&&(i[s]=e[s]);return i}const $m=C.createContext({});function LZ(e,t){if(Fm(e)){const{initial:n,animate:i}=e;return{initial:n===!1||Ld(n)?n:void 0,animate:Ld(i)?i:void 0}}return e.inherit!==!1?t:{}}function IZ(e){const{initial:t,animate:n}=LZ(e,C.useContext($m));return C.useMemo(()=>({initial:t,animate:n}),[CC(t),CC(n)])}function CC(e){return Array.isArray(e)?e.join(" "):e}const G1=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function uO(e,t,n){for(const i in t)!fi(t[i])&&!HD(i,n)&&(e[i]=t[i])}function PZ({transformTemplate:e},t){return C.useMemo(()=>{const n=G1();return V1(n,t,e),Object.assign({},n.vars,n.style)},[t])}function zZ(e,t){const n=e.style||{},i={};return uO(i,n,e),Object.assign(i,PZ(e,t)),i}function BZ(e,t){const n={},i=zZ(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 dO=()=>({...G1(),attrs:{}});function UZ(e,t,n,i){const s=C.useMemo(()=>{const a=dO();return VD(a,t,GD(i),e.transformTemplate,e.style),{...a.attrs,style:{...a.style}}},[t]);if(e.style){const a={};uO(a,e.style,e),s.style={...a,...s.style}}return s}const FZ=["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 W1(e){return typeof e!="string"||e.includes("-")?!1:!!(FZ.indexOf(e)>-1||/[A-Z]/u.test(e))}function $Z(e,t,n,{latestValues:i},s,a=!1,o){const u=(o??W1(e)?UZ:BZ)(t,i,s,e),f=OZ(t,typeof e=="string",a),m=e!==C.Fragment?{...f,...u,ref:n}:{},{children:p}=t,y=C.useMemo(()=>fi(p)?p.get():p,[p]);return C.createElement(e,{...m,children:y})}function qZ({scrapeMotionValuesFromProps:e,createRenderState:t},n,i,s){return{latestValues:HZ(n,i,s,e),renderState:t()}}function HZ(e,t,n,i){const s={},a=i(e,{});for(const y in a)s[y]=jp(a[y]);let{initial:o,animate:c}=e;const u=Fm(e),f=LD(e);t&&f&&!u&&e.inherit!==!1&&(o===void 0&&(o=t.initial),c===void 0&&(c=t.animate));let m=n?n.initial===!1:!1;m=m||o===!1;const p=m?c:o;if(p&&typeof p!="boolean"&&!Um(p)){const y=Array.isArray(p)?p:[p];for(let b=0;b<y.length;b++){const x=I1(e,y[b]);if(x){const{transitionEnd:w,transition:E,...v}=x;for(const _ in v){let k=v[_];if(Array.isArray(k)){const T=m?k.length-1:0;k=k[T]}k!==null&&(s[_]=k)}for(const _ in w)s[_]=w[_]}}}return s}const fO=e=>(t,n)=>{const i=C.useContext($m),s=C.useContext(w1),a=()=>qZ(e,t,i,s);return n?a():$W(a)},VZ=fO({scrapeMotionValuesFromProps:K1,createRenderState:G1}),KZ=fO({scrapeMotionValuesFromProps:WD,createRenderState:dO}),GZ=Symbol.for("motionComponentSymbol");function WZ(e,t,n){const i=C.useRef(n);C.useInsertionEffect(()=>{i.current=n});const s=C.useRef(null);return C.useCallback(a=>{var c;a&&((c=e.onMount)==null||c.call(e,a)),t&&(a?t.mount(a):t.unmount());const o=i.current;if(typeof o=="function")if(a){const u=o(a);typeof u=="function"&&(s.current=u)}else s.current?(s.current(),s.current=null):o(a);else o&&(o.current=a)},[t])}const hO=C.createContext({});function nc(e){return e&&typeof e=="object"&&Object.prototype.hasOwnProperty.call(e,"current")}function YZ(e,t,n,i,s,a){var k,T;const{visualElement:o}=C.useContext($m),c=C.useContext(oO),u=C.useContext(w1),f=C.useContext(aO),m=f.reducedMotion,p=f.skipAnimations,y=C.useRef(null),b=C.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:m,skipAnimations:p,isSVG:a}),b.current&&y.current&&(y.current.manuallyAnimateOnMount=!0));const x=y.current,w=C.useContext(hO);x&&!x.projection&&s&&(x.type==="html"||x.type==="svg")&&XZ(y.current,n,s,w);const E=C.useRef(!1);C.useInsertionEffect(()=>{x&&E.current&&x.update(n,u)});const v=n[kD],_=C.useRef(!!v&&typeof window<"u"&&!((k=window.MotionHandoffIsComplete)!=null&&k.call(window,v))&&((T=window.MotionHasOptimisedAnimation)==null?void 0:T.call(window,v)));return HW(()=>{b.current=!0,x&&(E.current=!0,window.MotionIsMounted=!0,x.updateFeatures(),x.scheduleRenderMicrotask(),_.current&&x.animationState&&x.animationState.animateChanges())}),C.useEffect(()=>{x&&(!_.current&&x.animationState&&x.animationState.animateChanges(),_.current&&(queueMicrotask(()=>{var A;(A=window.MotionHandoffMarkAsComplete)==null||A.call(window,v)}),_.current=!1),x.enteringChildren=void 0)}),x}function XZ(e,t,n,i){const{layoutId:s,layout:a,drag:o,dragConstraints:c,layoutScroll:u,layoutRoot:f,layoutAnchor:m,layoutCrossfade:p}=t;e.projection=new n(e.latestValues,t["data-framer-portal-id"]?void 0:pO(e.parent)),e.projection.setOptions({layoutId:s,layout:a,alwaysMeasureLayout:!!o||c&&nc(c),visualElement:e,animationType:typeof a=="string"?a:"both",initialPromotionConfig:i,crossfade:p,layoutScroll:u,layoutRoot:f,layoutAnchor:m})}function pO(e){if(e)return e.options.allowProjection!==!1?e.projection:pO(e.parent)}function hx(e,{forwardMotionProps:t=!1,type:n}={},i,s){i&&MZ(i);const a=n?n==="svg":W1(e),o=a?KZ:VZ;function c(f,m){let p;const y={...C.useContext(aO),...f,layoutId:QZ(f)},{isStatic:b}=y,x=IZ(f),w=o(f,b);if(!b&&typeof window<"u"){ZZ();const E=JZ(y);p=E.MeasureLayout,x.visualElement=YZ(e,w,y,s,E.ProjectionNode,a)}return d.jsxs($m.Provider,{value:x,children:[p&&x.visualElement?d.jsx(p,{visualElement:x.visualElement,...y}):null,$Z(e,f,WZ(w,x.visualElement,m),w,b,t,a)]})}c.displayName=`motion.${typeof e=="string"?e:`create(${e.displayName??e.name??""})`}`;const u=C.forwardRef(c);return u[GZ]=e,u}function QZ({layoutId:e}){const t=C.useContext(IR).id;return t&&e!==void 0?t+"-"+e:e}function ZZ(e,t){C.useContext(oO).strict}function JZ(e){const t=lO(),{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 eJ(e,t){if(typeof Proxy>"u")return hx;const n=new Map,i=(a,o)=>hx(a,o,e,t),s=(a,o)=>i(a,o);return new Proxy(s,{get:(a,o)=>o==="create"?i:(n.has(o)||n.set(o,hx(o,void 0,e,t)),n.get(o))})}const tJ=(e,t)=>t.isSVG??W1(e)?new IQ(t):new jQ(t,{allowProjection:e!==C.Fragment});class nJ extends oo{constructor(t){super(t),t.animationState||(t.animationState=FQ(t))}updateAnimationControlsSubscription(){const{animate:t}=this.node.getProps();Um(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 iJ=0;class sJ extends oo{constructor(){super(...arguments),this.id=iJ++,this.isExitComplete=!1}update(){var a;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=Qo(this.node,o,c);if(u){const{transition:f,transitionEnd:m,...p}=u;for(const y in p)(a=this.node.getValue(y))==null||a.jump(p[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 rJ={animation:{Feature:nJ},exit:{Feature:sJ}};function yf(e){return{point:{x:e.pageX,y:e.pageY}}}const aJ=e=>t=>F1(t)&&e(t,yf(t));function Sd(e,t,n,i){return Id(e,t,aJ(n),i)}const mO=({current:e})=>e?e.ownerDocument.defaultView:null,TC=(e,t)=>Math.abs(e-t);function oJ(e,t){const n=TC(e.x,t.x),i=TC(e.y,t.y);return Math.sqrt(n**2+i**2)}const AC=new Set(["auto","scroll"]);class gO{constructor(t,n,{transformPagePoint:i,contextWindow:s=window,dragSnapToOrigin:a=!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=Qh(this.lastRawMoveEventInfo,this.transformPagePoint));const x=px(this.lastMoveEventInfo,this.history),w=this.startEvent!==null,E=oJ(x.offset,{x:0,y:0})>=this.distanceThreshold;if(!w&&!E)return;const{point:v}=x,{timestamp:_}=di;this.history.push({...v,timestamp:_});const{onStart:k,onMove:T}=this.handlers;w||(k&&k(this.lastMoveEvent,x),this.startEvent=this.lastMoveEvent),T&&T(this.lastMoveEvent,x)},this.handlePointerMove=(x,w)=>{this.lastMoveEvent=x,this.lastRawMoveEventInfo=w,this.lastMoveEventInfo=Qh(w,this.transformPagePoint),un.update(this.updatePoint,!0)},this.handlePointerUp=(x,w)=>{this.end();const{onEnd:E,onSessionEnd:v,resumeAnimation:_}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&_&&_(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const k=px(x.type==="pointercancel"?this.lastMoveEventInfo:Qh(w,this.transformPagePoint),this.history);this.startEvent&&E&&E(x,k),v&&v(x,k)},!F1(t))return;this.dragSnapToOrigin=a,this.handlers=n,this.transformPagePoint=i,this.distanceThreshold=o,this.contextWindow=s||window;const u=yf(t),f=Qh(u,this.transformPagePoint),{point:m}=f,{timestamp:p}=di;this.history=[{...m,timestamp:p}];const{onSessionStart:y}=n;y&&y(t,px(f,this.history));const b={passive:!0,capture:!0};this.removeListeners=pf(Sd(this.contextWindow,"pointermove",this.handlePointerMove,b),Sd(this.contextWindow,"pointerup",this.handlePointerUp,b),Sd(this.contextWindow,"pointercancel",this.handlePointerUp,b)),c&&this.startScrollTracking(c)}startScrollTracking(t){let n=t.parentElement;for(;n;){const i=getComputedStyle(n);(AC.has(i.overflowX)||AC.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},a={x:s.x-n.x,y:s.y-n.y};a.x===0&&a.y===0||(i?this.lastMoveEventInfo&&(this.lastMoveEventInfo.point.x+=a.x,this.lastMoveEventInfo.point.y+=a.y):this.history.length>0&&(this.history[0].x-=a.x,this.history[0].y-=a.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(),no(this.updatePoint)}}function Qh(e,t){return t?{point:t(e.point)}:e}function jC(e,t){return{x:e.x-t.x,y:e.y-t.y}}function px({point:e},t){return{point:e,delta:jC(e,yO(t)),offset:jC(e,lJ(t)),velocity:cJ(t,.1)}}function lJ(e){return e[0]}function yO(e){return e[e.length-1]}function cJ(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,i=null;const s=yO(e);for(;n>=0&&(i=e[n],!(s.timestamp-i.timestamp>ss(t)));)n--;if(!i)return{x:0,y:0};i===e[0]&&e.length>2&&s.timestamp-i.timestamp>ss(t)*2&&(i=e[1]);const a=vs(s.timestamp-i.timestamp);if(a===0)return{x:0,y:0};const o={x:(s.x-i.x)/a,y:(s.y-i.y)/a};return o.x===1/0&&(o.x=0),o.y===1/0&&(o.y=0),o}function uJ(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 MC(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 dJ(e,{top:t,left:n,bottom:i,right:s}){return{x:MC(e.x,n,s),y:MC(e.y,t,i)}}function RC(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 fJ(e,t){return{x:RC(e.x,t.x),y:RC(e.y,t.y)}}function hJ(e,t){let n=.5;const i=Ci(e),s=Ci(t);return s>i?n=Dd(t.min,t.max-i,e.min):i>s&&(n=Dd(e.min,e.max-s,t.min)),gr(0,1,n)}function pJ(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 ev=.35;function mJ(e=ev){return e===!1?e=0:e===!0&&(e=ev),{x:DC(e,"left","right"),y:DC(e,"top","bottom")}}function DC(e,t,n){return{min:OC(e,t),max:OC(e,n)}}function OC(e,t){return typeof e=="number"?e:e[t]||0}const gJ=new WeakMap;class yJ{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=Qn(),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 a=p=>{n&&this.snapToCursor(yf(p).point),this.stopAnimation()},o=(p,y)=>{const{drag:b,dragPropagation:x,onDragStart:w}=this.getProps();if(b&&!x&&(this.openDragLock&&this.openDragLock(),this.openDragLock=YX(b),!this.openDragLock))return;this.latestPointerEvent=p,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),or(v=>{let _=this.getAxisMotionValue(v).get()||0;if(hr.test(_)){const{projection:k}=this.visualElement;if(k&&k.layout){const T=k.layout.layoutBox[v];T&&(_=Ci(T)*(parseFloat(_)/100))}}this.originPoint[v]=_}),w&&un.update(()=>w(p,y),!1,!0),H0(this.visualElement,"transform");const{animationState:E}=this.visualElement;E&&E.setActive("whileDrag",!0)},c=(p,y)=>{this.latestPointerEvent=p,this.latestPanInfo=y;const{dragPropagation:b,dragDirectionLock:x,onDirectionLock:w,onDrag:E}=this.getProps();if(!b&&!this.openDragLock)return;const{offset:v}=y;if(x&&this.currentDirection===null){this.currentDirection=xJ(v),this.currentDirection!==null&&w&&w(this.currentDirection);return}this.updateAxis("x",y.point,v),this.updateAxis("y",y.point,v),this.visualElement.render(),E&&un.update(()=>E(p,y),!1,!0)},u=(p,y)=>{this.latestPointerEvent=p,this.latestPanInfo=y,this.stop(p,y),this.latestPointerEvent=null,this.latestPanInfo=null},f=()=>{const{dragSnapToOrigin:p}=this.getProps();(p||this.constraints)&&this.startAnimation({x:0,y:0})},{dragSnapToOrigin:m}=this.getProps();this.panSession=new gO(t,{onSessionStart:a,onStart:o,onMove:c,onSessionEnd:u,resumeAnimation:f},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:m,distanceThreshold:i,contextWindow:mO(this.visualElement),element:this.visualElement.current})}stop(t,n){const i=t||this.latestPointerEvent,s=n||this.latestPanInfo,a=this.isDragging;if(this.cancel(),!a||!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||!Zh(t,s,this.currentDirection))return;const a=this.getAxisMotionValue(t);let o=this.originPoint[t]+i[t];this.constraints&&this.constraints[t]&&(o=uJ(o,this.constraints[t],this.elastic[t])),a.set(o)}resolveConstraints(){var a;const{dragConstraints:t,dragElastic:n}=this.getProps(),i=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):(a=this.visualElement.projection)==null?void 0:a.layout,s=this.constraints;t&&nc(t)?this.constraints||(this.constraints=this.resolveRefConstraints()):t&&i?this.constraints=dJ(i.layoutBox,t):this.constraints=!1,this.elastic=mJ(n),s!==this.constraints&&!nc(t)&&i&&this.constraints&&!this.hasMutatedConstraints&&or(o=>{this.constraints!==!1&&this.getAxisMotionValue(o)&&(this.constraints[o]=pJ(i.layoutBox[o],this.constraints[o]))})}resolveRefConstraints(){const{dragConstraints:t,onMeasureDragConstraints:n}=this.getProps();if(!t||!nc(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 a=kQ(i,s.root,this.visualElement.getTransformPagePoint());let o=fJ(s.layout.layoutBox,a);if(n){const c=n(wQ(o));this.hasMutatedConstraints=!!c,c&&(o=BD(c))}return o}startAnimation(t){const{drag:n,dragMomentum:i,dragElastic:s,dragTransition:a,dragSnapToOrigin:o,onDragTransitionEnd:c}=this.getProps(),u=this.constraints||{},f=or(m=>{if(!Zh(m,n,this.currentDirection))return;let p=u&&u[m]||{};(o===!0||o===m)&&(p={min:0,max:0});const y=s?200:1e6,b=s?40:1e7,x={type:"inertia",velocity:i?t[m]:0,bounceStiffness:y,bounceDamping:b,timeConstant:750,restDelta:1,restSpeed:10,...a,...p};return this.startAxisValueAnimation(m,x)});return Promise.all(f).then(c)}startAxisValueAnimation(t,n){const i=this.getAxisMotionValue(t);return H0(this.visualElement,t),i.start(L1(t,i,0,n,this.visualElement,!1))}stopAnimation(){or(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){or(n=>{const{drag:i}=this.getProps();if(!Zh(n,i,this.currentDirection))return;const{projection:s}=this.visualElement,a=this.getAxisMotionValue(n);if(s&&s.layout){const{min:o,max:c}=s.layout.layoutBox[n],u=a.get()||0;a.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(!nc(n)||!i||!this.constraints)return;this.stopAnimation();const s={x:0,y:0};or(o=>{const c=this.getAxisMotionValue(o);if(c&&this.constraints!==!1){const u=c.get();s[o]=hJ({min:u,max:u},this.constraints[o])}});const{transformTemplate:a}=this.visualElement.getProps();this.visualElement.current.style.transform=a?a({},""):"none",i.root&&i.root.updateScroll(),i.updateLayout(),this.constraints=!1,this.resolveConstraints(),or(o=>{if(!Zh(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;gJ.set(this.visualElement,this);const t=this.visualElement.current,n=Sd(t,"pointerdown",f=>{const{drag:m,dragListener:p=!0}=this.getProps(),y=f.target,b=y!==t&&tQ(y);m&&p&&!b&&this.start(f)});let i;const s=()=>{const{dragConstraints:f}=this.getProps();nc(f)&&f.current&&(this.constraints=this.resolveRefConstraints(),i||(i=bJ(t,f.current,()=>this.scalePositionWithinConstraints())))},{projection:a}=this.visualElement,o=a.addEventListener("measure",s);a&&!a.layout&&(a.root&&a.root.updateScroll(),a.updateLayout()),un.read(s);const c=Id(window,"resize",()=>this.scalePositionWithinConstraints()),u=a.addEventListener("didUpdate",(({delta:f,hasLayoutChanged:m})=>{this.isDragging&&m&&(or(p=>{const y=this.getAxisMotionValue(p);y&&(this.originPoint[p]+=f[p].translate,y.set(y.get()+f[p].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:a=!1,dragElastic:o=ev,dragMomentum:c=!0}=t;return{...t,drag:n,dragDirectionLock:i,dragPropagation:s,dragConstraints:a,dragElastic:o,dragMomentum:c}}}function LC(e){let t=!0;return()=>{if(t){t=!1;return}e()}}function bJ(e,t,n){const i=H2(e,LC(n)),s=H2(t,LC(n));return()=>{i(),s()}}function Zh(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function xJ(e,t=10){let n=null;return Math.abs(e.y)>t?n="y":Math.abs(e.x)>t&&(n="x"),n}class vJ extends oo{constructor(t){super(t),this.removeGroupControls=ws,this.removeListeners=ws,this.controls=new yJ(t)}mount(){const{dragControls:t}=this.node.getProps();t&&(this.removeGroupControls=t.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||ws}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 mx=e=>(t,n)=>{e&&un.update(()=>e(t,n),!1,!0)};class wJ extends oo{constructor(){super(...arguments),this.removePointerDownListener=ws}onPointerDown(t){this.session=new gO(t,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:mO(this.node)})}createPanHandlers(){const{onPanSessionStart:t,onPanStart:n,onPan:i,onPanEnd:s}=this.node.getProps();return{onSessionStart:mx(t),onStart:mx(n),onMove:mx(i),onEnd:(a,o)=>{delete this.session,s&&un.postRender(()=>s(a,o))}}}mount(){this.removePointerDownListener=Sd(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 gx=!1;class EJ extends C.Component{componentDidMount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:i,layoutId:s}=this.props,{projection:a}=t;a&&(n.group&&n.group.add(a),i&&i.register&&s&&i.register(a),gx&&a.root.didUpdate(),a.addEventListener("animationComplete",()=>{this.safeToRemove()}),a.setOptions({...a.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),Mp.hasEverUpdated=!0}getSnapshotBeforeUpdate(t){const{layoutDependency:n,visualElement:i,drag:s,isPresent:a}=this.props,{projection:o}=i;return o&&(o.isPresent=a,t.layoutDependency!==n&&o.setOptions({...o.options,layoutDependency:n}),gx=!0,s||t.layoutDependency!==n||n===void 0||t.isPresent!==a?o.willUpdate():this.safeToRemove(),t.isPresent!==a&&(a?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(),U1.postRender(()=>{!i.currentAnimation&&i.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:i}=this.props,{projection:s}=t;gx=!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 bO(e){const[t,n]=AZ(),i=C.useContext(IR);return d.jsx(EJ,{...e,layoutGroup:i,switchLayoutGroup:C.useContext(hO),isPresent:t,safeToRemove:n})}const SJ={pan:{Feature:wJ},drag:{Feature:vJ,ProjectionNode:rO,MeasureLayout:bO}};function IC(e,t,n){const{props:i}=e;e.animationState&&i.whileHover&&e.animationState.setActive("whileHover",n==="Start");const s="onHover"+n,a=i[s];a&&un.postRender(()=>a(t,yf(t)))}class kJ extends oo{mount(){const{current:t}=this.node;t&&(this.unmount=QX(t,(n,i)=>(IC(this.node,i,"Start"),s=>IC(this.node,s,"End"))))}unmount(){}}class NJ extends oo{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=pf(Id(this.node.current,"focus",()=>this.onFocus()),Id(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function PC(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),a=i[s];a&&un.postRender(()=>a(t,yf(t)))}class _J extends oo{mount(){const{current:t}=this.node;if(!t)return;const{globalTapTarget:n,propagate:i}=this.node.props;this.unmount=iQ(t,(s,a)=>(PC(this.node,a,"Start"),(o,{success:c})=>PC(this.node,o,c?"End":"Cancel")),{useGlobalTarget:n,stopPropagation:(i==null?void 0:i.tap)===!1})}unmount(){}}const tv=new WeakMap,yx=new WeakMap,CJ=e=>{const t=tv.get(e.target);t&&t(e)},TJ=e=>{e.forEach(CJ)};function AJ({root:e,...t}){const n=e||document;yx.has(n)||yx.set(n,{});const i=yx.get(n),s=JSON.stringify(t);return i[s]||(i[s]=new IntersectionObserver(TJ,{root:e,...t})),i[s]}function jJ(e,t,n){const i=AJ(t);return tv.set(e,n),i.observe(e),()=>{tv.delete(e),i.unobserve(e)}}const MJ={some:0,all:1};class RJ extends oo{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:a}=t,o={root:n?n.current:void 0,rootMargin:i,threshold:typeof s=="number"?s:MJ[s]},c=f=>{const{isIntersecting:m}=f;if(this.isInView===m||(this.isInView=m,a&&!m&&this.hasEnteredView))return;m&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",m);const{onViewportEnter:p,onViewportLeave:y}=this.node.getProps(),b=m?p:y;b&&b(f)};this.stopObserver=jJ(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(DJ(t,n))&&this.startObserver()}unmount(){var t;(t=this.stopObserver)==null||t.call(this),this.hasEnteredView=!1,this.isInView=!1}}function DJ({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}const OJ={inView:{Feature:RJ},tap:{Feature:_J},focus:{Feature:NJ},hover:{Feature:kJ}},LJ={layout:{ProjectionNode:rO,MeasureLayout:bO}},IJ={...rJ,...OJ,...SJ,...LJ},PJ=eJ(IJ,tJ),zJ={some:0,all:1};function BJ(e,t,{root:n,margin:i,amount:s="some"}={}){const a=B1(e),o=new WeakMap,c=f=>{f.forEach(m=>{const p=o.get(m.target);if(m.isIntersecting!==!!p)if(m.isIntersecting){const y=t(m.target,m);typeof y=="function"?o.set(m.target,y):u.unobserve(m.target)}else typeof p=="function"&&(p(m),o.delete(m.target))})},u=new IntersectionObserver(c,{root:n,rootMargin:i,threshold:typeof s=="number"?s:zJ[s]});return a.forEach(f=>u.observe(f)),()=>u.disconnect()}function UJ(e,{root:t,margin:n,amount:i,once:s=!1,initial:a=!1}={}){const[o,c]=C.useState(a);return C.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 BJ(e.current,u,f)},[t,e,n,s,i]),o}function Zc({children:e,index:t,className:n="",delay:i=.1,amount:s=.5,root:a}){const o=C.useRef(null),c=UJ(o,{amount:s,once:!1,root:a});return d.jsx(PJ.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 FJ(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 $J(){return typeof window>"u"?null:window.AudioContext??window.webkitAudioContext??null}function qJ(){const e=C.useRef(null),t=C.useRef(null),n=C.useRef(null),i=C.useRef(Promise.resolve()),s=C.useRef(!1),[a,o]=C.useState(null),c=C.useCallback(()=>{if(e.current)return e.current;const b=$J();if(!b)return null;const x=new b,w=x.createAnalyser();return w.fftSize=2048,w.connect(x.destination),e.current=x,t.current=w,o(w),x},[]),u=C.useCallback(()=>{const b=c();(b==null?void 0:b.state)==="suspended"&&b.resume()},[c]),f=C.useCallback(async(b,x)=>{const w=c(),E=t.current;if(!w||!E)throw new Error("no-audio-context");const v=await w.decodeAudioData(b.slice(0));x()&&(w.state==="suspended"&&await w.resume(),await new Promise(_=>{const k=w.createBufferSource();k.buffer=v,k.connect(E),n.current=k,k.onended=()=>{n.current===k&&(n.current=null),_()},k.start()}))},[c]),m=C.useCallback((b,x)=>new Promise(w=>{if(typeof window>"u"||!window.speechSynthesis||!x()){w();return}const E=new SpeechSynthesisUtterance(b);E.lang=navigator.language||"zh-CN",E.rate=1,E.onend=()=>w(),E.onerror=()=>w(),window.speechSynthesis.speak(E)}),[]),p=C.useCallback((b,x,w,E)=>{if(!b.trim()){w();return}const v=FJ(b);i.current=i.current.then(async()=>{try{if(!x())return;const _=await v;if(!x())return;if(_){s.current=!0,E==null||E();try{await f(_,x)}catch{}return}s.current||(E==null||E(),await m(b,x))}finally{w()}})},[f,m]),y=C.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 C.useEffect(()=>()=>{var b,x,w;try{(b=n.current)==null||b.stop()}catch{}typeof window<"u"&&((x=window.speechSynthesis)==null||x.cancel()),(w=e.current)==null||w.close()},[]),{enqueue:p,cancel:y,resume:u,analyser:a}}const HJ=900;function VJ({phase:e,inputAnalyser:t,outputAnalyser:n=null,outputText:i,thinkingConfig:s}){const a=C.useRef(null),o=C.useRef(e);return C.useEffect(()=>{var U;const c=a.current;if(!c)return;const u=c.getContext("2d");if(!u)return;const f=o.current;o.current=e;const m=performance.now(),p=((U=window.matchMedia)==null?void 0:U.call(window,"(prefers-reduced-motion: reduce)").matches)??!1,y=new Uint8Array(new ArrayBuffer((t==null?void 0:t.fftSize)??2048)),b=new Uint8Array(new ArrayBuffer((n==null?void 0:n.fftSize)??2048)),x=new Float32Array(256),w=new Float32Array(256);let E=0,v=0,_=0,k=1,T=0,A=0;const j=window.getComputedStyle(c),M={cyan:j.getPropertyValue("--voice-cyan").trim(),blue:j.getPropertyValue("--voice-blue").trim(),violet:j.getPropertyValue("--voice-violet").trim(),pink:j.getPropertyValue("--voice-pink").trim(),amber:j.getPropertyValue("--voice-amber").trim(),mint:j.getPropertyValue("--voice-mint").trim()},D=()=>{const q=c.getBoundingClientRect();k=Math.min(window.devicePixelRatio||1,2),v=Math.max(1,Math.round(q.width)),_=Math.max(1,Math.round(q.height)),c.width=Math.round(v*k),c.height=Math.round(_*k),u.setTransform(k,0,0,k,0,0)},I=q=>{const V=q/1e3,O=p?1:Math.min(1,(q-m)/HJ),R=O*O*(3-2*O);zC(t,y,x),zC(n,b,w),T+=(UC(x)-T)*.08,A+=(UC(w)-A)*.08,u.clearRect(0,0,v,_),R<1&&f!==e&&BC(u,f,v,_,V,1-R,x,w,T,A,i,M,s),BC(u,e,v,_,V,R,x,w,T,A,i,M,s),p||(E=window.requestAnimationFrame(I))};D(),I(performance.now());const P=typeof ResizeObserver>"u"?null:new ResizeObserver(()=>{D(),p&&I(performance.now())});return P==null||P.observe(c),window.addEventListener("resize",D),()=>{window.cancelAnimationFrame(E),P==null||P.disconnect(),window.removeEventListener("resize",D)}},[t,n,i,e,s]),d.jsx("canvas",{ref:a,className:"voice-canvas","aria-hidden":"true"})}function zC(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 a=t[Math.min(t.length-1,Math.floor(s*i))]??128;n[s]=(a-128)/128}}function BC(e,t,n,i,s,a,o,c,u,f,m,p,y){t==="idle"&&KJ(e,n,i,s,a,p),t==="listening"&&GJ(e,n,i,s,a,o,u,p),t==="thinking"&&WJ(e,n,i,s,a,p,y),t==="speaking"&&YJ(e,n,i,s,a,c,f,m,p)}function KJ(e,t,n,i,s,a){const o=[a.blue,a.violet];e.save(),e.globalCompositeOperation="screen",o.forEach((c,u)=>{e.beginPath();for(let f=0;f<=180;f+=1){const m=f/180,p=Math.sin(Math.PI*m),y=n/2+Math.sin(m*Math.PI*3+i*.42+u)*n*.018*p;f===0?e.moveTo(m*t,y):e.lineTo(m*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 GJ(e,t,n,i,s,a,o,c){const u=[c.cyan,c.blue,c.violet,c.pink,c.mint];e.save(),e.globalCompositeOperation="screen",u.forEach((f,m)=>{vO(e,t,n,i,m,u.length,f,s,.12+o*.62,.7,p=>xO(a,p))}),e.restore()}function WJ(e,t,n,i,s,a,o){const c=[a.pink,a.amber,a.violet,a.blue,a.cyan,a.mint],u=o.colors.length>0?o.colors:c,f=Math.min(8,Math.max(1,Math.round(o.count))),m=Array.from({length:f},(M,D)=>u[D%u.length]??a.violet),p=t/2,y=n/2,b=Math.min(t,n),x=Math.max(0,o.amplitude),w=Math.max(.2,o.waviness),E=Math.max(.1,o.scale),v=Math.max(0,o.saturation),_=Math.max(0,.4+o.intensity),k=`hue-rotate(${o.hueShift*360}deg) saturate(${v}) brightness(${_})`,T=Math.max(0,o.glow),A=T*(8+E*4),j=Math.min(.72,T*.16)*(.55+o.intensity*.45);e.save(),e.globalCompositeOperation="source-over",m.forEach((M,D)=>{const I=D%2===0?1:-1,P=i*Math.max(0,o.speed),U=P*(.72+D*.06)*I+D*(.92+o.spread*.2),q=D%3===0?-1:1,V=P*(1.5+D*.12)*q+D*.83,O=b*(.055+o.spread*.035+D%3*.01)*x,R=p+Math.cos(U*.78+D)*O,z=y+Math.sin(U*.66+D)*O*.72,G=b*(.14+o.thickness*.08+D%3*.012)*E,X=96,K=Math.max(2,Math.min(8,Math.round(2+w))),B=K+2,F=[];for(let me=0;me<X;me+=1){const se=me/X*Math.PI*2,Q=1+Math.sin(se*K+V)*x*.09+Math.cos(se*B-V*.74+D*.7)*x*.05;F.push({x:R+Math.cos(se+U)*G*Q,y:z+Math.sin(se+U)*G*Q*(.84+D%2*.07)})}const W=F[0],$=F[F.length-1];if(!W||!$)return;const ae=U+D*.47,xe=Math.cos(ae)*G*1.15,le=Math.sin(ae)*G*1.15,Ne=e.createLinearGradient(R-xe,z-le,R+xe,z+le),re=Math.max(1,u.length);for(let me=0;me<=re;me+=1){const se=u[(me+D)%u.length]??M;Ne.addColorStop(me/re,se)}e.beginPath(),e.moveTo(($.x+W.x)/2,($.y+W.y)/2);for(let me=0;me<F.length;me+=1){const se=F[me],Q=F[(me+1)%F.length];!se||!Q||e.quadraticCurveTo(se.x,se.y,(se.x+Q.x)/2,(se.y+Q.y)/2)}e.closePath(),A>0&&o.intensity>0&&[1.55,.72].forEach((me,se)=>{e.save(),e.globalCompositeOperation="screen",e.filter=`${k} blur(${A*me*(se===0?.58:.24)}px)`,e.fillStyle=Ne,e.globalAlpha=s*o.opacity*j*(se===0?.72:.92),e.fill(),e.restore()}),e.save(),e.globalCompositeOperation="screen",e.filter=k,e.fillStyle=Ne,e.globalAlpha=s*o.opacity*(.3+D%3*.025),e.fill(),e.restore()}),e.restore()}function YJ(e,t,n,i,s,a,o,c,u){const f=[u.mint,u.cyan,u.blue,u.violet,u.pink],m=o>.006;e.save(),e.globalCompositeOperation="screen",f.forEach((p,y)=>{vO(e,t,n,i*.86,y,f.length,p,s,.34+o*.36,1.45,b=>m?xO(a,b):XJ(c,b,i,y))}),e.restore()}function XJ(e,t,n,i){const s=e||"SPS",a=(n*1.6+t*s.length*.72+i*.46)%s.length,o=s.charCodeAt(Math.floor(a))||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 UC(e){let t=0;for(const n of e)t+=n*n;return Math.min(1,Math.sqrt(t/e.length)*3.2)}function xO(e,t){const n=Math.round(t*(e.length-1));let i=0,s=0;for(let a=-6;a<=6;a+=1){const o=Math.max(0,Math.min(e.length-1,n+a));i+=e[o]??0,s+=1}return i/s}function vO(e,t,n,i,s,a,o,c,u,f,m){const y=[],b=[],x=s%2===0?1:-1,w=s*1.18+i*(.32+s*.018)*x;for(let v=0;v<=84;v+=1){const _=v/84,k=Math.pow(Math.sin(Math.PI*_),.42),T=Math.pow(Math.sin(Math.PI*_),.9),A=Math.sin(_*Math.PI*(2.2+s*.18)+w),j=Math.sin(_*Math.PI*1.25-w*.58+s)*.38,M=m(_)*n*(.02+u*.025);y.push(n/2+(s-(a-1)/2)*n*.013+(A+j)*n*(.038+u*.038)*f*k+M*k),b.push(n*(.05+s*.005)*(.9+u*.38)*(.88+Math.sin(_*Math.PI*2-w)*.12)*T)}e.beginPath(),y.forEach((v,_)=>{const k=_/84*t,T=v-(b[_]??0);_===0?e.moveTo(k,T):e.lineTo(k,T)});for(let v=84;v>=0;v-=1)e.lineTo(v/84*t,(y[v]??n/2)+(b[v]??0));e.closePath();const E=e.createLinearGradient(0,0,t,0);E.addColorStop(0,"transparent"),E.addColorStop(.1,o),E.addColorStop(.9,o),E.addColorStop(1,"transparent"),e.fillStyle=E,e.globalAlpha=c*(.22+s*.03),e.shadowColor=o,e.shadowBlur=28+s*4,e.fill()}const QJ=[{id:"idle",labelKey:"home.phase.idle",icon:VB},{id:"listening",labelKey:"home.phase.listening",icon:Aj},{id:"thinking",labelKey:"home.phase.thinking",icon:DB},{id:"speaking",labelKey:"home.phase.speaking",icon:Bj}],Jh=["#f97316","#7c3aed","#06b6d4"],ud={idle:{colors:Jh,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:Jh,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:Jh,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:Jh,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}},ZJ=[{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 dd(e){return{...e,colors:[...e.colors]}}function JJ(){return{idle:dd(ud.idle),listening:dd(ud.listening),thinking:dd(ud.thinking),speaking:dd(ud.speaking)}}function eee(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 FC(e){return e.replace(/```[\s\S]*?```/g,"").replace(/[`*_>#\[\]()]/g,"").replace(/\s+/g," ").trim()}function nv(e){return/\.(png|jpe?g|gif|webp|svg|bmp|avif)$/i.test(e)}function wO(e){const t=e.lastIndexOf(".");return((t>=0?e.slice(t+1):"")||"file").toUpperCase().slice(0,5)}const EO="mcp__sps__present_form";function tee(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={...ex,title:e.title||ex.title,description:e.description??ex.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 nee(e){var n;if(!e)return null;const t=e.filter(i=>i.type==="tool_use"&&i.title===EO);return tee((n=t[t.length-1])==null?void 0:n.input)}function iee(e){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,a])=>({id:s,label:a.title??s,type:Array.isArray(a.enum)?"select":a.type==="boolean"?"toggle":a.type==="number"?"number":a.format==="textarea"?"textarea":"text",...Array.isArray(a.enum)?{options:a.enum.map(o=>({value:String(o),label:String(o)}))}:{},...a.default!==void 0?{default:a.default}:{},...n.has(s)?{required:!0}:{},...typeof a.description=="string"?{hint:a.description}:{}}));return{title:e.title,...t.description?{description:t.description}:{},submitLabel:"提交并继续",fields:i}}const SO="[表单已提交]",kO="[让 AI 来定";function see(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(SO)||s.startsWith(kO)))return!0}return!1}function ree(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(kO))return;if(s.startsWith(SO)){const a=s.match(/```json\s*([\s\S]*?)```/);if(!(a!=null&&a[1]))return;try{return JSON.parse(a[1])}catch{return}}}}}function aee({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,a=zm(e,i);return nv(i)&&n?d.jsx("button",{type:"button",className:"voice-msg-attach",title:s,onClick:()=>n(i),children:d.jsx("img",{src:a,alt:s})},i):d.jsx("a",{href:a,target:"_blank",rel:"noreferrer",className:"voice-msg-attach",title:s,children:nv(i)?d.jsx("img",{src:a,alt:s}):d.jsxs(d.Fragment,{children:[d.jsx(Rc,{size:22,strokeWidth:1.7,"aria-hidden":"true"}),d.jsx("span",{className:"voice-msg-attach-ext",children:wO(s)})]})},i)})})}const To="sps.home.session",oee=720*60*1e3;function lee(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 cee(e){if(!e)return"";try{return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}catch{return""}}function $C(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 bx({outputAnalyser:e=null}){var Ts,Er;const t=Xe(),{sessionId:n}=Iv(),[i,s]=C.useState("idle"),a=C.useRef("idle");a.current=i;const[o,c]=Yr("sps.voice.autoListen",!1),[u,f]=C.useState("idle"),[m,p]=C.useState(!1),[y,b]=C.useState(""),[x,w]=Yr("sps.sessions.listOpen",!1),[E,v]=C.useState(0),[_,k]=Yr("sps.sessions.originTab","all"),[T,A]=C.useState(!1),[j,M]=C.useState(!1),[D,I]=C.useState(""),[P,U]=C.useState(60),q=C.useRef(null),[V,O]=C.useState(()=>X$()?"draw":"done"),[R,z]=C.useState(JJ),G=C.useRef(null),X=C.useRef(null),K=C.useRef(null),B=C.useRef(null),F=C.useRef(!0),[W,$]=C.useState(!1),ae=C.useCallback(()=>{const Y=K.current;return!Y||Y.scrollHeight-Y.scrollTop-Y.clientHeight<40},[]),xe=C.useCallback(()=>{const Y=K.current;Y&&(typeof Y.scrollTo=="function"?Y.scrollTo({top:Y.scrollHeight,behavior:"smooth"}):Y.scrollTop=Y.scrollHeight),F.current=!0,$(!1)},[]),le=C.useCallback(()=>{const Y=K.current;Y&&(typeof Y.scrollTo=="function"?Y.scrollTo({top:Y.scrollHeight,behavior:"instant"}):Y.scrollTop=Y.scrollHeight)},[]),Ne=C.useCallback(()=>{const Y=ae();F.current=Y,$(!Y)},[ae]),re=C.useRef(0),me=C.useRef(0),se=C.useRef(0),Q=C.useRef(""),ye=C.useRef(!1),_e=C.useRef(!1),ze=C.useRef(!1),fe=kW(),Se=qJ(),Re=R[i],Qe=R[u],ht=Y=>{Y===me.current&&ye.current&&se.current===0&&s("idle")},it=Y=>{const Ae=FC(Y);if(!Ae)return;const Oe=me.current;se.current+=1,Se.enqueue(Ae,()=>Oe===me.current,()=>{Oe===me.current&&(se.current=Math.max(0,se.current-1),ht(Oe))})},Bt=Y=>{Q.current+=Y;let Ae=Q.current.match(/^([\s\S]*?[。!?.!?])([\s\S]*)$/);for(;Ae;)it(Ae[1]??""),Q.current=Ae[2]??"",Ae=Q.current.match(/^([\s\S]*?[。!?.!?])([\s\S]*)$/)},mt=()=>{me.current+=1,se.current=0,Q.current="",ye.current=!1,Se.cancel()},wt=Y=>{var Ae;(Ae=navigator.clipboard)==null||Ae.writeText(Y).catch(()=>{})},[Te,ct]=C.useState(null),ne=C.useRef(0),we=(Y,Ae)=>{if(Te&&Te.id===Y){ne.current+=1,mt(),ct(null);return}const Oe=FC(Ae);if(!Oe)return;ne.current+=1,mt();const gt=ne.current,pt=()=>gt===ne.current;Se.resume(),ct({id:Y,phase:"loading"}),Se.enqueue(Oe,pt,()=>{pt()&&ct(null)},()=>{pt()&&ct({id:Y,phase:"playing"})})},he=OW({onAssistantChunk:Y=>{_e.current=!0,ze.current&&(s("speaking"),Bt(Y))},onAssistantComplete:Y=>{ye.current=!0,ze.current&&(_e.current?Q.current.trim()&&it(Q.current):it(Y)),Q.current="",ht(me.current)},onError:()=>{b(t("home.error.response")),s("idle")},onThinking:()=>{mt(),_e.current=!1,b(""),s("thinking")}});C.useEffect(()=>{const Y=`sps.home.draft:${he.sessionId??"new"}`;I(localStorage.getItem(Y)??"")},[he.sessionId]);const Ve=C.useCallback(Y=>{I(Y);try{localStorage.setItem(`sps.home.draft:${he.sessionId??"new"}`,Y)}catch{}},[he.sessionId]),Ze=C.useCallback(()=>{I("");try{localStorage.removeItem(`sps.home.draft:${he.sessionId??"new"}`)}catch{}},[he.sessionId]);C.useEffect(()=>{const Y=localStorage.getItem(To);if(!Y)return;let Ae={};try{Ae=JSON.parse(Y)}catch{}if(!n){if(!Ae.id||!Ae.ts||Date.now()-Ae.ts>oee){localStorage.removeItem(To);return}kp(Ae.id).then(Oe=>{he.resume(Oe.id,$C(Oe.messages)),pe(Oe)}).catch(()=>localStorage.removeItem(To))}},[]),C.useEffect(()=>{he.sessionId&&localStorage.setItem(To,JSON.stringify({id:he.sessionId,ts:Date.now()}))},[he.sessionId,he.messages.length]);const[Ct,Gt]=C.useState([]),[ce,pe]=C.useState(null),[Ce,je]=C.useState(null),[qe,st]=C.useState(null),[Fe,et]=C.useState(!1);C.useEffect(()=>{if(!qe)return;const Y=Ae=>{Ae.key==="Escape"&&(Ae.preventDefault(),st(null))};return window.addEventListener("keydown",Y),()=>window.removeEventListener("keydown",Y)},[qe]),C.useEffect(()=>{if(!he.sessionId){pe(null),Gt([]);return}he.isSending||kp(he.sessionId).then(Y=>{Gt(Y.artifacts??[]),pe(Y)}).catch(()=>{})},[he.sessionId,he.isSending,he.messages.length]);const Qt=tn(),Wt=((Ts=at({queryKey:["chat-sessions"],queryFn:oW,refetchInterval:5e3}).data)==null?void 0:Ts.data)??[],Z=[...new Set(Wt.map(Y=>Y.origin??"sps"))].sort(),be=_!=="all"&&!Z.includes(_)?"all":_,Ie=be==="all"?Wt:Wt.filter(Y=>(Y.origin??"sps")===be),ut=Y=>Y.lastMessageAt??Y.createdAt,Yt=m0(Ie,ut,7),Tt=m0(Yt.older,ut,30),$e=Y=>Y.id===he.sessionId,Ue=[...Yt.recent,...E>=1?Tt.recent:Tt.recent.filter($e),...E>=2?Tt.older:Tt.older.filter($e)],ot=Tt.recent.length+Tt.older.length,hn=Tt.older.length,Zt=Y=>{Y!==he.sessionId&&kp(Y).then(Ae=>{he.resume(Y,$C(Ae.messages)),pe(Ae),Gt(Ae.artifacts??[]),s("idle"),b(""),localStorage.setItem(To,JSON.stringify({id:Y,ts:Date.now()}))}).catch(()=>{})};C.useEffect(()=>{n&&n!==he.sessionId&&Zt(n)},[n]);const Vi=Y=>{A(!1),_R({...Y,dedicated:!Y.cwd}).then(Ae=>{he.resume(Ae.id,[]),Gt([]),pe(null),et(!1),s("idle"),b(""),localStorage.setItem(To,JSON.stringify({id:Ae.id,ts:Date.now()})),Qt.invalidateQueries({queryKey:["chat-sessions"]})}).catch(()=>{})},Ys=(Y,Ae)=>{Ae.stopPropagation(),window.confirm(t("home.sessions.deleteConfirm"))&&lW(Y).then(()=>{Qt.invalidateQueries({queryKey:["chat-sessions"]}),Y===he.sessionId&&bn()}).catch(()=>{})},Jn=SW({onComplete:Y=>{fe.stop(),ze.current=!0;const Ae=xi.map(Oe=>Oe.path);F.current=!0,$(!1),he.send(Y,Ae.length?Ae:void 0),Ae.length&&hi([])},onError:Y=>{fe.stop(),b(t(Y==="unsupported"?"home.error.recognitionUnsupported":"home.error.recognition")),s("idle")}}),kn=C.useRef(Jn);kn.current=Jn;const mn=()=>{i!=="idle"||he.isSending||In||(b(""),Se.resume(),mt(),Jn.start()&&(s("listening"),fe.start()))},An=()=>{i==="listening"?Jn.stop():mn()},Ti=C.useRef(An);Ti.current=An;const Xs=Y=>{c(Y),b(""),Y?Se.resume():a.current==="idle"&&kn.current.isListening&&kn.current.cancel()};C.useEffect(()=>{if(!(o&&i==="idle"&&!j&&Jn.supported))return;const Ae=window.setTimeout(()=>{kn.current.isListening||kn.current.start()},400);return()=>{window.clearTimeout(Ae),a.current==="idle"&&kn.current.isListening&&kn.current.cancel()}},[o,i,j,Jn.supported]);const wr=()=>{i!=="idle"||he.isSending||In||kn.current.isListening&&(b(""),Se.resume(),mt(),s("listening"),fe.start())};AW({enabled:o,phase:i,suspended:j||he.isSending,analyser:fe.analyser,transcript:Jn.transcript,onTrigger:wr,onEndpoint:()=>kn.current.stop(),onAbort:()=>{kn.current.cancel(),fe.stop(),s("idle")}});const Qs=22,sa=18,_s=()=>{const Y=q.current;if(!Y)return;Y.style.height="auto";const Ae=Qs*3+sa,Oe=Math.min(Y.scrollHeight,Ae);Y.style.height=`${Oe}px`,Y.style.overflowY=Y.scrollHeight>Ae?"auto":"hidden",U(Math.max(60,Oe+16))},Zs=()=>{U(60);const Y=q.current;Y&&(Y.style.height="auto",Y.style.overflowY="hidden")},Bn=()=>{const Y=D.trim();if(!Y&&xi.length===0||he.isSending)return;const Ae=xi.map(Oe=>Oe.path);Ze(),Zs(),hi([]),b(""),ze.current=!1,F.current=!0,$(!1),he.send(Y,Ae.length?Ae:void 0)},Ai=i==="thinking"||i==="speaking",In=((ce==null?void 0:ce.readonly)??!1)&&(ce==null?void 0:ce.id)===he.sessionId,ri=j&&!Ai&&!In;C.useEffect(()=>{if(j||o||In)return;const Y=Ae=>{if(Ae.code!=="Space"&&Ae.key!==" "||Ae.repeat)return;const Oe=Ae.target;Oe&&(Oe.tagName==="INPUT"||Oe.tagName==="TEXTAREA"||Oe.isContentEditable)||(Ae.preventDefault(),Ti.current())};return window.addEventListener("keydown",Y),()=>window.removeEventListener("keydown",Y)},[j,o,In]);const bn=()=>{he.reset(),localStorage.removeItem(To),Gt([]),et(!1),s("idle"),b(""),Ze(),Zs()},ra=()=>{he.sessionId&&CR(he.sessionId).catch(()=>{}),mt(),s("idle")},[xi,hi]=C.useState([]),[Me,Ge]=C.useState(!1),[xt,Rt]=C.useState(!1),on=async Y=>{if(Y.size>jR){b(`文件超过 50 MB(${(Y.size/1024/1024).toFixed(1)} MB):${Y.name}`);return}Ge(!0);try{const Ae=await he.ensureSession(),Oe=await v2(Ae,Y);hi(gt=>[...gt,{path:Oe.path,name:Oe.name}])}catch(Ae){b(Ae instanceof Error?Ae.message:String(Ae))}finally{Ge(!1)}},Un=Y=>{hi(Ae=>Ae.filter(Oe=>Oe.path!==Y))};C.useEffect(()=>{var ji;const Y=G.current;if(!Y)return;if(((ji=window.matchMedia)==null?void 0:ji.call(window,"(prefers-reduced-motion: reduce)").matches)??!1){Y.style.setProperty("--voice-activity","0"),Y.style.setProperty("--voice-scale","1");return}let Oe=0,gt=new Uint8Array(new ArrayBuffer(2048));const pt=oa=>{const tt=i==="listening"?fe.analyser:i==="speaking"?Se.analyser??e:null;tt&&gt.length!==tt.fftSize&&(gt=new Uint8Array(new ArrayBuffer(tt.fftSize)));let la=tt?eee(tt,gt):0;if(!tt&&i==="speaking"){const $t=oa/1e3;la=.16+(.5+Math.sin($t*6.8)*.5)*.34+(.5+Math.sin($t*11.4+1.2)*.5)*.16}const jn=la>re.current?.16:.065;re.current+=(la-re.current)*jn,Y.style.setProperty("--voice-scale",(1+re.current*.065).toFixed(4)),Y.style.setProperty("--voice-activity",re.current.toFixed(3)),Oe=window.requestAnimationFrame(pt)};return Oe=window.requestAnimationFrame(pt),()=>window.cancelAnimationFrame(Oe)},[fe.analyser,Se.analyser,e,i]),C.useEffect(()=>{F.current&&le()},[i,Jn.transcript,he.messages,le]);const ei=he.messages.some(Y=>Y.status==="streaming");C.useEffect(()=>{if(!ei)return;let Y=0;const Ae=()=>{const Oe=K.current;Oe&&F.current&&Oe.scrollHeight-Oe.scrollTop-Oe.clientHeight>=1&&le(),Y=window.requestAnimationFrame(Ae)};return Y=window.requestAnimationFrame(Ae),()=>window.cancelAnimationFrame(Y)},[ei,le]),C.useEffect(()=>{if(je(null),!he.sessionId)return;F.current=!0,$(!1);const Y=window.setTimeout(()=>{F.current&&le()},400);return()=>window.clearTimeout(Y)},[he.sessionId]),C.useEffect(()=>{if(!m)return;const Y=Ae=>{Ae.key==="Escape"&&p(!1)};return window.addEventListener("keydown",Y),()=>window.removeEventListener("keydown",Y)},[m]),C.useEffect(()=>()=>{mt(),fe.stop()},[]);const ti=C.useMemo(()=>({amplitude:Re.amplitude,colors:Re.colors,count:Re.count,glow:Re.glow,hueShift:Re.hueShift,intensity:Re.intensity,opacity:Re.opacity,saturation:Re.saturation,scale:Re.scale,speed:Re.speed,spread:Re.spread,thickness:Re.thickness,waviness:Re.waviness}),[Re]),Vt=(Y,Ae)=>{if(!Number.isFinite(Ae))return;const Oe=Math.min(Y.max,Math.max(Y.min,Ae));z(gt=>({...gt,[u]:{...gt[u],[Y.key]:Oe}}))},ai=(Y,Ae)=>{z(Oe=>{const gt=[...Oe[u].colors];return gt[Y]=Ae,{...Oe,[u]:{...Oe[u],colors:gt}}})},aa=((Er=[...he.messages].reverse().find(Y=>Y.role==="assistant"))==null?void 0:Er.content)??"",Cs=i==="listening"&&fe.status==="requesting"?t("home.mic.requesting"):t(`home.phase.${i}`),os=he.messages.some(Y=>Y.role==="assistant"&&Y.status==="streaming");return d.jsxs("div",{className:"home-shell","data-list-open":x?"true":"false",children:[T&&d.jsx(FW,{onCancel:()=>A(!1),onCreate:Vi}),Ce&&he.sessionId&&d.jsx(mW,{sessionId:he.sessionId,path:Ce,onClose:()=>je(null)}),qe&&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:()=>st(null),children:d.jsxs("div",{className:"w-full max-w-lg max-h-[88vh] overflow-auto",onClick:Y=>Y.stopPropagation(),children:[qe.error&&d.jsxs("div",{className:"nb-card mb-2 px-3 py-2 text-xs text-[var(--color-crashed)]",children:["提交失败:",qe.error]}),d.jsx(wW,{spec:qe.spec,disabled:qe.readOnly,initialValues:qe.values,onSubmit:Y=>{const Ae=qe.interaction;if(Ae){const Oe=Object.fromEntries(Object.entries(Y).filter(([,pt])=>pt!==""&&pt!=null)),gt=he.sessionId;if(!gt)return;TR(gt,Ae.id,Oe,Ae.revision).then(()=>st(null)).catch(pt=>st(ji=>ji&&{...ji,values:Y,error:pt instanceof Error?pt.message:String(pt),panelKey:(ji.panelKey??0)+1}));return}he.send("[表单已提交]\n```json\n"+JSON.stringify(Y,null,2)+"\n```"),st(null)},onSkip:()=>{he.send("[让 AI 来定,按各字段推荐值 + 我们的对话补全,不用再逐项问我]"),st(null)},onUpload:async Y=>{const Ae=await he.ensureSession();return(await v2(Ae,Y)).path}},qe.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:()=>w(!1),"aria-label":t("home.sessions.collapse"),title:t("home.sessions.collapse"),children:d.jsx($N,{size:14,strokeWidth:2.2})})]})]}),Z.length>1&&d.jsxs("div",{className:"home-sessions-tabs",role:"tablist",children:[d.jsx("button",{type:"button",role:"tab","aria-selected":be==="all",className:`home-sessions-tab ${be==="all"?"is-active":""}`,onClick:()=>k("all"),children:t("home.sessions.tabAll")}),Z.map(Y=>d.jsx("button",{type:"button",role:"tab","aria-selected":be===Y,className:`home-sessions-tab ${be===Y?"is-active":""}`,onClick:()=>k(Y),children:Wj[Y]??Y},Y))]}),d.jsxs("div",{className:"home-sessions-list",children:[Ue.map((Y,Ae)=>d.jsx(Zc,{index:Ae,children:d.jsxs("div",{className:`home-session-row ${Y.id===he.sessionId?"is-active":""}`,children:[d.jsxs("button",{type:"button",className:"home-session-main",onClick:()=>Zt(Y.id),title:Y.title,children:[d.jsx(OU,{size:13,strokeWidth:2.5,className:"shrink-0"}),d.jsx("span",{className:"home-session-title",children:Y.title}),Y.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:[Y.lastMessageAt&&d.jsx("span",{title:new Date(Y.lastMessageAt).toLocaleString(),children:lee(Y.lastMessageAt)}),d.jsx("span",{style:{opacity:.6},children:Y.messageCount})]})]}),d.jsx("button",{type:"button",className:"home-session-del",onClick:Oe=>Ys(Y.id,Oe),"aria-label":t("home.sessions.delete"),title:t("home.sessions.delete"),children:d.jsx(qi,{size:16,strokeWidth:2.4})})]})},Y.id)),E===0&&ot>0&&d.jsx("button",{type:"button",className:"nb-btn text-xs self-start mt-1",onClick:()=>v(1),children:t("home.sessions.expandWeek",{count:ot})}),E===1&&(hn>0?d.jsx("button",{type:"button",className:"nb-btn text-xs self-start mt-1",onClick:()=>v(2),children:t("home.sessions.expandMonth",{count:hn})}):d.jsx("button",{type:"button",className:"nb-btn text-xs self-start mt-1",onClick:()=>v(0),children:t("home.sessions.collapseOld")})),E===2&&d.jsx("button",{type:"button",className:"nb-btn text-xs self-start mt-1",onClick:()=>v(0),children:t("home.sessions.collapseOld")})]})]}):d.jsx("button",{type:"button",className:"home-sessions-rail",onClick:()=>w(!0),"aria-label":t("home.sessions.open"),title:t("home.sessions.open"),children:d.jsx($N,{size:18,strokeWidth:2.2})})}),d.jsxs("section",{className:["voice-home",V==="draw"?"voice-home--intro-hidden":"",V==="reveal"?"voice-home--intro-reveal":""].join(" "),"aria-labelledby":"voice-home-title",children:[V!=="done"&&d.jsx(W$,{targetRef:G,panelRef:X,onReveal:()=>O("reveal"),onDone:()=>O("done")}),d.jsxs("div",{ref:X,className:"voice-conversation","data-phase":i,children:[ce&&d.jsxs("div",{className:"voice-convo-header",children:[d.jsxs("button",{type:"button",className:"voice-convo-title-btn",onClick:()=>et(Y=>!Y),"aria-expanded":Fe,children:[d.jsx("span",{className:"voice-convo-title",children:ce.title}),d.jsx(so,{size:15,strokeWidth:2.5,className:["voice-convo-chevron",Fe?"is-open":""].join(" ")})]}),Fe&&d.jsxs("dl",{className:"voice-convo-details",children:[ce.model&&d.jsxs(d.Fragment,{children:[d.jsx("dt",{children:"模型"}),d.jsx("dd",{children:ce.model})]}),d.jsx("dt",{children:"session"}),d.jsx("dd",{children:ce.id}),ce.claudeSessionId&&d.jsxs(d.Fragment,{children:[d.jsx("dt",{children:"claude"}),d.jsx("dd",{children:ce.claudeSessionId})]}),ce.cwd&&d.jsxs(d.Fragment,{children:[d.jsx("dt",{children:"目录"}),d.jsx("dd",{children:ce.cwd})]})]})]}),d.jsxs("div",{className:"relative flex-1 min-h-0 flex flex-col",children:[d.jsxs("div",{ref:K,className:"voice-message-stream","aria-live":"polite",onScroll:Ne,children:[he.messages.length===0&&i==="idle"&&d.jsxs("div",{className:"voice-empty-state",children:[d.jsx(FN,{size:18,strokeWidth:2,"aria-hidden":"true"}),d.jsx("p",{children:t("home.conversation.empty")})]}),he.messages.map((Y,Ae)=>d.jsxs("article",{className:`voice-message voice-message-${Y.role}`,"data-streaming":Y.status==="streaming",children:[d.jsxs("span",{children:[Y.role==="user"?t("home.conversation.you"):t("home.conversation.ai"),Y.role==="assistant"&&Y.status==="streaming"&&d.jsxs("span",{className:"voice-live-status","data-phase":i,style:{marginLeft:8},children:[d.jsx("span",{"aria-hidden":"true"}),Cs]}),Y.ts&&d.jsx("span",{style:{marginLeft:6,fontSize:10,opacity:.5,textTransform:"none",fontWeight:400,letterSpacing:0},title:new Date(Y.ts).toLocaleString(),children:cee(Y.ts)})]}),d.jsxs("div",{className:"voice-bubble",children:[Y.attachments&&Y.attachments.length>0&&d.jsx(aee,{sessionId:he.sessionId,paths:Y.attachments,onImagePreview:Oe=>je(Oe)}),Y.blocks&&Y.blocks.length?d.jsxs("div",{className:"voice-blocks",children:[Y.blocks.map((Oe,gt)=>Oe.type==="tool_use"&&MR(Oe,(ce==null?void 0:ce.cwd)??null)||Oe.type==="tool_use"&&Oe.title===EO?null:d.jsx(xW,{block:Oe,streaming:Y.status==="streaming",sessionId:he.sessionId??void 0,onOpenForm:pt=>st({spec:iee(pt),readOnly:pt.status!=="pending",values:pt.status!=="pending"&&pt.answer&&typeof pt.answer=="object"?pt.answer:void 0,...pt.status==="pending"?{interaction:{id:pt.id,revision:pt.revision}}:{}})},gt)),(()=>{const Oe=nee(Y.blocks);if(!Oe)return null;const gt=see(he.messages,Ae);return d.jsx("div",{className:"mt-1",children:d.jsxs("button",{type:"button",className:gt?"nb-btn text-xs":"nb-btn nb-btn-primary text-sm",onClick:()=>st({spec:Oe,readOnly:gt,values:gt?ree(he.messages,Ae):void 0}),children:[d.jsx(qN,{size:14,strokeWidth:2.5}),gt?`${Oe.title} · 已提交 ✓(点击查看)`:`${Oe.title} · 点击填写配置`]})})})(),(()=>{const Oe=hW(Y.blocks,(ce==null?void 0:ce.cwd)??null);return Oe.length>0&&he.sessionId?d.jsx("div",{className:"flex flex-col items-start gap-2 mt-1",children:Oe.map(gt=>d.jsx(pW,{sessionId:he.sessionId,path:gt,onPreview:()=>je(gt)},gt))}):null})()]}):Y.status==="streaming"?d.jsx(RR,{text:Y.content}):d.jsx(NR,{text:Y.content}),Y.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")}),Y.role==="assistant"&&Y.status!=="streaming"&&Y.content&&d.jsxs("div",{className:"voice-bubble-actions",children:[d.jsx("button",{type:"button",onClick:()=>wt(Y.content),"aria-label":t("home.copy"),title:t("home.copy"),children:d.jsx(Cj,{size:13,strokeWidth:2.5})}),d.jsx("button",{type:"button",onClick:()=>we(Y.id,Y.content),"aria-label":(Te==null?void 0:Te.id)===Y.id?t("home.stop"):t("home.play"),title:(Te==null?void 0:Te.id)===Y.id?t("home.stop"):t("home.play"),"data-active":(Te==null?void 0:Te.id)===Y.id?"true":void 0,children:(Te==null?void 0:Te.id)===Y.id?Te.phase==="loading"?d.jsx(lt,{size:13,strokeWidth:2.5,className:"animate-spin"}):d.jsx(f0,{size:16,strokeWidth:2.4,fill:"currentColor"}):d.jsx(Bj,{size:13,strokeWidth:2.5})})]})]})]},Y.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:Jn.transcript||t("home.conversation.listening")})]}),i==="thinking"&&!os&&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"}),Cs]})]}),d.jsxs("p",{children:[t("home.conversation.thinking"),d.jsx("i",{"aria-hidden":"true"})]})]})]}),W&&d.jsx("button",{type:"button",onClick:xe,"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(_B,{size:16,strokeWidth:2.5})})]}),Ct.length>0&&d.jsxs("div",{className:"voice-artifacts","aria-label":t("home.artifacts.label"),children:[d.jsx(Rc,{size:13,strokeWidth:2.5,"aria-hidden":"true"}),d.jsxs("span",{className:"voice-artifacts-title",children:[t("home.artifacts.label")," (",Ct.length,")"]}),d.jsxs("div",{className:"voice-artifacts-list",children:[Ct.slice(0,6).map(Y=>d.jsx("span",{className:"voice-artifacts-chip",title:Y,children:Y.split("/").pop()},Y)),Ct.length>6&&d.jsxs("span",{className:"voice-artifacts-chip",children:["+",Ct.length-6]})]})]}),d.jsxs("div",{className:"voice-dock","data-drag":xt?"true":"false",onDragOver:Y=>{Y.dataTransfer.types.includes("Files")&&(Y.preventDefault(),Y.dataTransfer.dropEffect="copy",xt||Rt(!0))},onDragLeave:Y=>{Y.currentTarget.contains(Y.relatedTarget)||Rt(!1)},onDrop:Y=>{if(Y.dataTransfer.types.includes("Files")){Y.preventDefault(),Rt(!1);for(const Ae of Array.from(Y.dataTransfer.files??[]))on(Ae)}},children:[y&&d.jsx("p",{className:"voice-error",role:"alert",children:y}),In&&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 ",(he.sessionId??"").replace(/^session-/,"")]})]}),(xi.length>0||Me)&&d.jsxs("div",{className:"voice-attachments",children:[xi.map(Y=>d.jsxs("div",{className:"voice-attach-thumb",title:Y.name,children:[nv(Y.path)&&he.sessionId?d.jsx("img",{src:zm(he.sessionId,Y.path),alt:Y.name}):d.jsxs("div",{className:"voice-attach-doc",children:[d.jsx(Rc,{size:30,strokeWidth:1.6,"aria-hidden":"true"}),d.jsx("span",{className:"voice-attach-ext",children:wO(Y.name)}),d.jsx("span",{className:"voice-attach-name",children:Y.name})]}),d.jsx("button",{type:"button",className:"voice-attach-del",onClick:()=>Un(Y.path),"aria-label":t("home.attach.remove"),title:t("home.attach.remove"),children:d.jsx(vn,{size:13,strokeWidth:3})})]},Y.path)),Me&&d.jsx("div",{className:"voice-attach-thumb is-loading",children:d.jsx(lt,{size:16,className:"animate-spin"})})]}),d.jsxs("div",{className:"voice-orb-button","data-mode":ri?"text":"voice",style:{...ri?{"--pill-h":`${P}px`}:{},...In?{opacity:.35,pointerEvents:"none"}:{}},children:[d.jsxs("div",{ref:G,className:"voice-flow-glass","data-phase":i,"data-mode":ri?"text":"voice","data-glass":i!=="thinking"&&!ri?"on":"off",role:"img","aria-label":t("home.visualizer.aria"),children:[d.jsx(VJ,{phase:i,inputAnalyser:fe.analyser,outputText:aa||t("home.message.speaking"),thinkingConfig:ti}),d.jsx(Jj,{active:i!=="thinking",activityLevelRef:re,activityAnalyser:i==="listening"?fe.analyser:i==="speaking"?Se.analyser??e:null,glass:i!=="thinking"&&!ri,refraction:1.2,dispersion:1,glassSize:1,amplitude:Re.amplitude,className:"voice-active-strands",colors:Re.colors,count:Re.count,glow:Re.glow,hueShift:Re.hueShift,intensity:Re.intensity,opacity:Re.opacity,saturation:Re.saturation,scale:Re.scale,speed:Re.speed,spread:Re.spread,taper:Re.taper,thickness:Re.thickness,waviness:Re.waviness}),ri&&d.jsxs("div",{className:"voice-input-inner",children:[d.jsx("textarea",{ref:q,className:"voice-input-field",rows:1,value:D,onChange:Y=>{Ve(Y.target.value),_s()},onKeyDown:Y=>{Y.key==="Enter"&&!Y.shiftKey&&!Y.nativeEvent.isComposing&&(Y.preventDefault(),Bn())},onPaste:Y=>{var Oe;const Ae=Array.from(((Oe=Y.clipboardData)==null?void 0:Oe.items)??[]).filter(gt=>gt.kind==="file"&&gt.type.startsWith("image/"));if(Ae.length!==0){Y.preventDefault();for(const gt of Ae){const pt=gt.getAsFile();pt&&on(pt)}}},placeholder:t("home.text.placeholder"),"aria-label":t("home.text.placeholder")}),d.jsx("input",{ref:B,type:"file",multiple:!0,className:"hidden",onChange:Y=>{for(const Ae of Array.from(Y.target.files??[]))on(Ae);Y.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 Y;return(Y=B.current)==null?void 0:Y.click()},disabled:he.isSending,"aria-label":t("home.attach"),title:t("home.attach"),children:d.jsx(VU,{size:16,strokeWidth:2.5})}),d.jsx("button",{type:"button",className:"voice-send-btn",onClick:Bn,disabled:!D.trim()||he.isSending,"aria-label":t("home.text.send"),title:t("home.text.send"),children:d.jsx(o6,{size:16,strokeWidth:2.5})})]})]}),!j&&d.jsx("button",{type:"button",className:"voice-orb-hit",disabled:i==="thinking"||i==="speaking"||In,"aria-label":t(i==="listening"?"home.voice.stop":"home.voice.start"),"aria-pressed":i==="listening",onClick:An}),Ai&&d.jsx("button",{type:"button",className:"voice-stop-btn",onClick:ra,"aria-label":t("home.interrupt"),title:t("home.interrupt"),children:d.jsx(f0,{size:18,strokeWidth:0,fill:"currentColor","aria-hidden":"true"})})]}),d.jsx("p",{className:"voice-dock-label",children:t(j?"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(S2,{checked:j,onChange:M,title:t("home.inputToggle"),ariaLabel:t("home.inputToggle"),onIcon:d.jsx(FN,{size:16,strokeWidth:2.4}),offIcon:d.jsx(TU,{size:16,strokeWidth:2.4})}),!j&&!In&&d.jsx(S2,{checked:o,onChange:Xs,title:t("home.auto.tip"),ariaLabel:t("home.auto.toggle"),onIcon:d.jsx(Aj,{size:16,strokeWidth:2.4}),offIcon:d.jsx(eU,{size:16,strokeWidth:2.4})})]})]})]}),m&&d.jsx("div",{className:"voice-debug-backdrop",role:"presentation",onMouseDown:Y=>{Y.target===Y.currentTarget&&p(!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(qN,{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:()=>z(Y=>({...Y,[u]:dd(ud[u])})),children:d.jsx(Kv,{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:()=>p(!1),children:d.jsx(vn,{size:16,strokeWidth:2.2,"aria-hidden":"true"})})]})]}),d.jsx("div",{className:"voice-debug-phases",role:"group","aria-label":t("home.phase.aria"),children:QJ.map(Y=>{const Ae=Y.icon;return d.jsxs("button",{type:"button","aria-pressed":u===Y.id,onClick:()=>f(Y.id),children:[d.jsx(Ae,{size:15,strokeWidth:2.2,"aria-hidden":"true"}),t(Y.labelKey)]},Y.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")}),Qe.colors.map((Y,Ae)=>d.jsxs("label",{className:"voice-color-control",children:[d.jsx("span",{children:t(`home.customize.color${Ae+1}`)}),d.jsx("input",{type:"color",value:Y,onChange:Oe=>ai(Ae,Oe.target.value)}),d.jsx("code",{children:Y.toUpperCase()})]},Ae))]}),d.jsxs("fieldset",{className:"voice-customizer-group",children:[d.jsx("legend",{children:t("home.customize.parameters")}),ZJ.map(Y=>{const Ae=t(Y.labelKey),Oe=Qe[Y.key];return d.jsxs("label",{className:"voice-parameter-control",children:[d.jsx("span",{children:Ae}),d.jsx("input",{type:"number",min:Y.min,max:Y.max,step:Y.step,value:Oe,"aria-label":`${Ae} value`,onChange:gt=>Vt(Y,Number(gt.target.value))}),d.jsx("input",{type:"range",min:Y.min,max:Y.max,step:Y.step,value:Oe,"aria-label":Ae,onChange:gt=>Vt(Y,Number(gt.target.value))})]},Y.key)})]})]})]})})]})]})}const ep=e=>e.lastActivityAt?Date.parse(e.lastActivityAt):0;function NO(e,t){const n=[...e];return t==="name"?n.sort((i,s)=>i.name.localeCompare(s.name)):t==="date"?n.sort((i,s)=>ep(s)-ep(i)):n.sort((i,s)=>{const a=i.pipelineStatus==="running"?1:0,o=s.pipelineStatus==="running"?1:0;return a!==o?o-a:ep(s)-ep(i)})}function uee(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),_t(`/api/logs?${t}`)}function dee(e){return _t(`/api/logs/sources?project=${encodeURIComponent(e)}`)}const fee=["error","warn","info","debug"],hee=["error","warn","info"];function pee({project:e,initialWorker:t}){const n=Xe(),i=t??"",[s,a]=C.useState([]),[o,c]=C.useState(!0),[u,f]=C.useState(()=>new Set(hee)),[m,p]=C.useState(""),y=C.useRef(null),[b,x]=C.useState(""),{data:w}=at({queryKey:["log-sources",e],queryFn:()=>dee(e),enabled:!!e,refetchInterval:5e3}),E=C.useMemo(()=>(w==null?void 0:w.sources)??[],[w]),v=E.find(A=>A.key===b)??(i?E.find(A=>A.worker===Number(i)):void 0)??E.find(A=>A.kind==="pipeline")??E[0],_=v==null?void 0:v.file;C.useEffect(()=>{a([])},[e,_]);const{data:k}=at({queryKey:["logs",e,_],queryFn:()=>uee({project:e,file:_,limit:500}),enabled:!!e,refetchInterval:2500});C.useEffect(()=>{k!=null&&k.data&&a(k.data)},[k]),C.useEffect(()=>{if(!o)return;const A=y.current;A&&(A.scrollTop=A.scrollHeight)},[s,o]);const T=C.useMemo(()=>{const A=m.toLowerCase();return s.filter(j=>!(!u.has(j.level)||A&&!j.msg.toLowerCase().includes(A)))},[s,u,m]);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:[E.filter(A=>A.worker==null).map(A=>d.jsx(qC,{s:A,active:(v==null?void 0:v.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:E.filter(A=>A.worker!=null).map(A=>d.jsx(qC,{s:A,active:(v==null?void 0:v.key)===A.key,onClick:()=>x(A.key)},A.key))}),fee.map(A=>d.jsx(mee,{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(cf,{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:m,onChange:A=>p(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:[(k==null?void 0:k.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(gee,{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 mee({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 gee({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 qC({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 rl({options:e,value:t,onChange:n,ariaLabel:i,className:s=""}){const a=C.useRef(null),[o,c]=C.useState(null),u=Math.max(0,e.findIndex(f=>f.value===t));return C.useLayoutEffect(()=>{const f=a.current;if(!f)return;const m=()=>{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})};m();const p=new ResizeObserver(m);return p.observe(f),()=>p.disconnect()},[u,e.length]),d.jsxs("div",{ref:a,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,m)=>d.jsx("button",{"data-idx":m,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 Y1=Symbol.for("yaml.alias"),iv=Symbol.for("yaml.document"),eo=Symbol.for("yaml.map"),_O=Symbol.for("yaml.pair"),yr=Symbol.for("yaml.scalar"),Jc=Symbol.for("yaml.seq"),Ss=Symbol.for("yaml.node.type"),lo=e=>!!e&&typeof e=="object"&&e[Ss]===Y1,ml=e=>!!e&&typeof e=="object"&&e[Ss]===iv,eu=e=>!!e&&typeof e=="object"&&e[Ss]===eo,wn=e=>!!e&&typeof e=="object"&&e[Ss]===_O,fn=e=>!!e&&typeof e=="object"&&e[Ss]===yr,tu=e=>!!e&&typeof e=="object"&&e[Ss]===Jc;function _n(e){if(e&&typeof e=="object")switch(e[Ss]){case eo:case Jc:return!0}return!1}function Tn(e){if(e&&typeof e=="object")switch(e[Ss]){case Y1:case eo:case yr:case Jc:return!0}return!1}const CO=e=>(fn(e)||_n(e))&&!!e.anchor,Fi=Symbol("break visit"),TO=Symbol("skip children"),pr=Symbol("remove node");function gl(e,t){const n=AO(t);ml(e)?ac(null,e.contents,n,Object.freeze([e]))===pr&&(e.contents=null):ac(null,e,n,Object.freeze([]))}gl.BREAK=Fi;gl.SKIP=TO;gl.REMOVE=pr;function ac(e,t,n,i){const s=jO(e,t,n,i);if(Tn(s)||wn(s))return MO(e,i,s),ac(e,s,n,i);if(typeof s!="symbol"){if(_n(t)){i=Object.freeze(i.concat(t));for(let a=0;a<t.items.length;++a){const o=ac(a,t.items[a],n,i);if(typeof o=="number")a=o-1;else{if(o===Fi)return Fi;o===pr&&(t.items.splice(a,1),a-=1)}}}else if(wn(t)){i=Object.freeze(i.concat(t));const a=ac("key",t.key,n,i);if(a===Fi)return Fi;a===pr&&(t.key=null);const o=ac("value",t.value,n,i);if(o===Fi)return Fi;o===pr&&(t.value=null)}}return s}async function qm(e,t){const n=AO(t);ml(e)?await oc(null,e.contents,n,Object.freeze([e]))===pr&&(e.contents=null):await oc(null,e,n,Object.freeze([]))}qm.BREAK=Fi;qm.SKIP=TO;qm.REMOVE=pr;async function oc(e,t,n,i){const s=await jO(e,t,n,i);if(Tn(s)||wn(s))return MO(e,i,s),oc(e,s,n,i);if(typeof s!="symbol"){if(_n(t)){i=Object.freeze(i.concat(t));for(let a=0;a<t.items.length;++a){const o=await oc(a,t.items[a],n,i);if(typeof o=="number")a=o-1;else{if(o===Fi)return Fi;o===pr&&(t.items.splice(a,1),a-=1)}}}else if(wn(t)){i=Object.freeze(i.concat(t));const a=await oc("key",t.key,n,i);if(a===Fi)return Fi;a===pr&&(t.key=null);const o=await oc("value",t.value,n,i);if(o===Fi)return Fi;o===pr&&(t.value=null)}}return s}function AO(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 jO(e,t,n,i){var s,a,o,c,u;if(typeof n=="function")return n(e,t,i);if(eu(t))return(s=n.Map)==null?void 0:s.call(n,e,t,i);if(tu(t))return(a=n.Seq)==null?void 0:a.call(n,e,t,i);if(wn(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(lo(t))return(u=n.Alias)==null?void 0:u.call(n,e,t,i)}function MO(e,t,n){const i=t[t.length-1];if(_n(i))i.items[e]=n;else if(wn(i))e==="key"?i.key=n:i.value=n;else if(ml(i))i.contents=n;else{const s=lo(i)?"alias":"scalar";throw new Error(`Cannot replace node with ${s} parent`)}}const yee={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},bee=e=>e.replace(/[!,[\]{}]/g,t=>yee[t]);class ki{constructor(t,n){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},ki.defaultYaml,t),this.tags=Object.assign({},ki.defaultTags,n)}clone(){const t=new ki(this.yaml,this.tags);return t.docStart=this.docStart,t}atDocument(){const t=new ki(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:ki.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},ki.defaultTags);break}return t}add(t,n){this.atNextDocument&&(this.yaml={explicit:ki.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},ki.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[a,o]=i;return this.tags[a]=o,!0}case"%YAML":{if(this.yaml.explicit=!0,i.length!==1)return n(0,"%YAML directive should contain exactly one part"),!1;const[a]=i;if(a==="1.1"||a==="1.2")return this.yaml.version=a,!0;{const o=/^\d+\.\d+$/.test(a);return n(6,`Unsupported YAML version ${a}`,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 a=this.tags[i];if(a)try{return a+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+bee(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&&Tn(t.contents)){const a={};gl(t.contents,(o,c)=>{Tn(c)&&c.tag&&(a[c.tag]=!0)}),s=Object.keys(a)}else s=[];for(const[a,o]of i)a==="!!"&&o==="tag:yaml.org,2002:"||(!t||s.some(c=>c.startsWith(o)))&&n.push(`%TAG ${a} ${o}`);return n.join(`
678
678
  `)}}ki.defaultYaml={explicit:!1,version:"1.2"};ki.defaultTags={"!!":"tag:yaml.org,2002:"};function RO(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 DO(e){const t=new Set;return gl(e,{Value(n,i){i.anchor&&t.add(i.anchor)}}),t}function OO(e,t){for(let n=1;;++n){const i=`${e}${n}`;if(!t.has(i))return i}}function xee(e,t){const n=[],i=new Map;let s=null;return{onAnchor:a=>{n.push(a),s??(s=DO(e));const o=OO(t,s);return s.add(o),o},setAnchors:()=>{for(const a of n){const o=i.get(a);if(typeof o=="object"&&o.anchor&&(fn(o.node)||_n(o.node)))o.node.anchor=o.anchor;else{const c=new Error("Failed to resolve repeated object (this should not happen)");throw c.source=a,c}}},sourceObjects:i}}function lc(e,t,n,i){if(i&&typeof i=="object")if(Array.isArray(i))for(let s=0,a=i.length;s<a;++s){const o=i[s],c=lc(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 a=i.get(s),o=lc(e,i,s,a);o===void 0?i.delete(s):o!==a&&i.set(s,o)}else if(i instanceof Set)for(const s of Array.from(i)){const a=lc(e,i,s,s);a===void 0?i.delete(s):a!==s&&(i.delete(s),i.add(a))}else for(const[s,a]of Object.entries(i)){const o=lc(e,i,s,a);o===void 0?delete i[s]:o!==a&&(i[s]=o)}return e.call(t,n,i)}function Es(e,t,n){if(Array.isArray(e))return e.map((i,s)=>Es(i,String(s),n));if(e&&typeof e.toJSON=="function"){if(!n||!CO(e))return e.toJSON(t,n);const i={aliasCount:0,count:1,res:void 0};n.anchors.set(e,i),n.onCreate=a=>{i.res=a,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 X1{constructor(t){Object.defineProperty(this,Ss,{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:a}={}){if(!ml(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=Es(this,"",o);if(typeof s=="function")for(const{count:u,res:f}of o.anchors.values())s(f,u);return typeof a=="function"?lc(a,{"":c},"",c):c}}class Hm extends X1{constructor(t){super(Y1),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=[],gl(t,{Node:(a,o)=>{(lo(o)||CO(o))&&i.push(o)}}),n&&(n.aliasResolveCache=i));let s;for(const a of i){if(a===this)break;a.anchor===this.source&&(s=a)}return s}toJSON(t,n){if(!n)return{source:this.source};const{anchors:i,doc:s,maxAliasCount:a}=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||(Es(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(a>=0&&(c.count+=1,c.aliasCount===0&&(c.aliasCount=Rp(s,o,i)),c.count*c.aliasCount>a)){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(RO(this.source),t.options.verifyAliasOrder&&!t.anchors.has(this.source)){const a=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new Error(a)}if(t.implicitKey)return`${s} `}return s}}function Rp(e,t,n){if(lo(t)){const i=t.resolve(e),s=n&&i&&n.get(i);return s?s.count*s.aliasCount:0}else if(_n(t)){let i=0;for(const s of t.items){const a=Rp(e,s,n);a>i&&(i=a)}return i}else if(wn(t)){const i=Rp(e,t.key,n),s=Rp(e,t.value,n);return Math.max(i,s)}return 1}const LO=e=>!e||typeof e!="function"&&typeof e!="object";class bt extends X1{constructor(t){super(yr),this.value=t}toJSON(t,n){return n!=null&&n.keep?this.value:Es(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 vee="tag:yaml.org,2002:";function wee(e,t,n){if(t){const i=n.filter(a=>a.tag===t),s=i.find(a=>!a.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 Pd(e,t,n){var p,y,b;if(ml(e)&&(e=e.contents),Tn(e))return e;if(wn(e)){const x=(y=(p=n.schema[eo]).createNode)==null?void 0:y.call(p,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:a,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 Hm(u.anchor);u={anchor:null,node:null},c.set(e,u)}t!=null&&t.startsWith("!!")&&(t=vee+t.slice(2));let f=wee(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[eo]:Symbol.iterator in Object(e)?o[Jc]:o[eo]}a&&(a(f),delete n.onTagObj);const m=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?m.tag=t:f.default||(m.tag=f.tag),u&&(u.node=m),m}function dm(e,t,n){let i=n;for(let s=t.length-1;s>=0;--s){const a=t[s];if(typeof a=="number"&&Number.isInteger(a)&&a>=0){const o=[];o[a]=i,i=o}else i=new Map([[a,i]])}return Pd(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 fd=e=>e==null||typeof e=="object"&&!!e[Symbol.iterator]().next().done;class IO extends X1{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=>Tn(i)||wn(i)?i.clone(t):i),this.range&&(n.range=this.range.slice()),n}addIn(t,n){if(fd(t))this.add(n);else{const[i,...s]=t,a=this.get(i,!0);if(_n(a))a.addIn(s,n);else if(a===void 0&&this.schema)this.set(i,dm(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(_n(s))return s.deleteIn(i);throw new Error(`Expected YAML collection at ${n}. Remaining path: ${i}`)}getIn(t,n){const[i,...s]=t,a=this.get(i,!0);return s.length===0?!n&&fn(a)?a.value:a:_n(a)?a.getIn(s,n):void 0}hasAllNullValues(t){return this.items.every(n=>{if(!wn(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 _n(s)?s.hasIn(i):!1}setIn(t,n){const[i,...s]=t;if(s.length===0)this.set(i,n);else{const a=this.get(i,!0);if(_n(a))a.setIn(s,n);else if(a===void 0&&this.schema)this.set(i,dm(this.schema,s,n));else throw new Error(`Expected YAML collection at ${i}. Remaining path: ${s}`)}}}const Eee=e=>e.replace(/^(?!$)(?: $)?/gm,"#");function Gr(e,t){return/^\n+$/.test(e)?e.substring(1):t?e.replace(/^(?! *$)/gm,t):e}const Po=(e,t,n)=>e.endsWith(`
679
679
  `)?Gr(n,t):n.includes(`
680
680
  `)?`
@@ -852,4 +852,4 @@ description: ...
852
852
  `)),m=f.reduce((p,y)=>p.concat(...y),[]);return[f,m]}return[[],[]]},[e]);return C.useEffect(()=>{const u=(t==null?void 0:t.target)??rA,f=(t==null?void 0:t.actInsideInputWithModifier)??!0;if(e!==null){const m=b=>{var E,v;if(s.current=b.ctrlKey||b.metaKey||b.shiftKey||b.altKey,(!s.current||s.current&&!f)&&LI(b))return!1;const w=oA(b.code,c);if(a.current.add(b[w]),aA(o,a.current,!1)){const _=((v=(E=b.composedPath)==null?void 0:E.call(b))==null?void 0:v[0])||b.target,k=(_==null?void 0:_.nodeName)==="BUTTON"||(_==null?void 0:_.nodeName)==="A";t.preventDefault!==!1&&(s.current||!k)&&b.preventDefault(),i(!0)}},p=b=>{const x=oA(b.code,c);aA(o,a.current,!0)?(i(!1),a.current.clear()):a.current.delete(b[x]),b.key==="Meta"&&a.current.clear(),s.current=!1},y=()=>{a.current.clear(),i(!1)};return u==null||u.addEventListener("keydown",m),u==null||u.addEventListener("keyup",p),window.addEventListener("blur",y),window.addEventListener("contextmenu",y),()=>{u==null||u.removeEventListener("keydown",m),u==null||u.removeEventListener("keyup",p),window.removeEventListener("blur",y),window.removeEventListener("contextmenu",y)}}},[e,i]),n}function aA(e,t,n){return e.filter(i=>n||i.length===t.size).some(i=>i.every(s=>t.has(s)))}function oA(e,t){return t.includes(e)?"code":"key"}const Ece=()=>{const e=Sn();return C.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,a],panZoom:o}=e.getState();return o?(await o.setViewport({x:t.x??i,y:t.y??s,zoom:t.zoom??a},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:a,maxZoom:o,panZoom:c}=e.getState(),u=Sw(t,i,s,a,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:a,domNode:o}=e.getState();if(!o)return t;const{x:c,y:u}=o.getBoundingClientRect(),f={x:t.x-c,y:t.y-u},m=n.snapGrid??s,p=n.snapToGrid??a;return _f(f,i,p,m)},flowToScreenPosition:t=>{const{transform:n,domNode:i}=e.getState();if(!i)return t;const{x:s,y:a}=i.getBoundingClientRect(),o=$c(t,n);return{x:o.x+s,y:o.y+a}}}),[])};function sP(e,t){const n=[],i=new Map,s=[];for(const a of e)if(a.type==="add"){s.push(a);continue}else if(a.type==="remove"||a.type==="replace")i.set(a.id,[a]);else{const o=i.get(a.id);o?o.push(a):i.set(a.id,[a])}for(const a of t){const o=i.get(a.id);if(!o){n.push(a);continue}if(o[0].type==="remove")continue;if(o[0].type==="replace"){n.push({...o[0].item});continue}const c={...a};for(const u of o)Sce(u,c);n.push(c)}return s.length&&s.forEach(a=>{a.index!==void 0?n.splice(a.index,0,{...a.item}):n.push({...a.item})}),n}function Sce(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 rP(e,t){return sP(e,t)}function aP(e,t){return sP(e,t)}function Do(e,t){return{id:e,type:"select",selected:t}}function dc(e,t=new Set,n=!1){const i=[];for(const[s,a]of e){const o=t.has(s);!(a.selected===void 0&&!o)&&a.selected!==o&&(n&&(a.selected=o),i.push(Do(a.id,o)))}return i}function lA({items:e=[],lookup:t}){var s;const n=[],i=new Map(e.map(a=>[a.id,a]));for(const[a,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:a})}for(const[a]of t)i.get(a)===void 0&&n.push({id:a,type:"remove"});return n}function cA(e){return{id:e.id,type:"remove"}}const oP=MI();function lP(e,t,n={}){return cle(e,t,{...n,onError:n.onError??oP})}function kce(e,t,n,i={shouldReplaceId:!0}){return ule(e,t,n,{...i,onError:i.onError??oP})}const uA=e=>Yoe(e),Nce=e=>_I(e);function cP(e){return C.forwardRef(e)}const _ce=typeof window<"u"?C.useLayoutEffect:C.useEffect;function dA(e){const[t,n]=C.useState(BigInt(0)),[i]=C.useState(()=>Cce(()=>n(s=>s+BigInt(1))));return _ce(()=>{const s=i.get();s.length&&(e(s),i.reset())},[t]),i}function Cce(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}const uP=C.createContext(null);function Tce({children:e}){const t=Sn(),n=C.useCallback(c=>{const{nodes:u=[],setNodes:f,hasDefaultNodes:m,onNodesChange:p,nodeLookup:y,fitViewQueued:b,onNodesChangeMiddlewareMap:x}=t.getState();let w=u;for(const v of c)w=typeof v=="function"?v(w):v;let E=lA({items:w,lookup:y});for(const v of x.values())E=v(E);m&&f(w),E.length>0?p==null||p(E):b&&window.requestAnimationFrame(()=>{const{fitViewQueued:v,nodes:_,setNodes:k}=t.getState();v&&k(_)})},[]),i=dA(n),s=C.useCallback(c=>{const{edges:u=[],setEdges:f,hasDefaultEdges:m,onEdgesChange:p,edgeLookup:y}=t.getState();let b=u;for(const x of c)b=typeof x=="function"?x(b):x;m?f(b):p&&p(lA({items:b,lookup:y}))},[]),a=dA(s),o=C.useMemo(()=>({nodeQueue:i,edgeQueue:a}),[]);return d.jsx(uP.Provider,{value:o,children:e})}function Ace(){const e=C.useContext(uP);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const jce=e=>!!e.panZoom;function gg(){const e=Ece(),t=Sn(),n=Ace(),i=Ft(jce),s=C.useMemo(()=>{const a=p=>t.getState().nodeLookup.get(p),o=p=>{n.nodeQueue.push(p)},c=p=>{n.edgeQueue.push(p)},u=p=>{var v,_;const{nodeLookup:y,nodeOrigin:b}=t.getState(),x=uA(p)?p:y.get(p.id),w=x.parentId?DI(x.position,x.measured,x.parentId,y,b):x.position,E={...x,position:w,width:((v=x.measured)==null?void 0:v.width)??x.width,height:((_=x.measured)==null?void 0:_.height)??x.height};return Wd(E)},f=(p,y,b={replace:!1})=>{o(x=>x.map(w=>{if(w.id===p){const E=typeof y=="function"?y(w):y;return b.replace&&uA(E)?E:{...w,...E}}return w}))},m=(p,y,b={replace:!1})=>{c(x=>x.map(w=>{if(w.id===p){const E=typeof y=="function"?y(w):y;return b.replace&&Nce(E)?E:{...w,...E}}return w}))};return{getNodes:()=>t.getState().nodes.map(p=>({...p})),getNode:p=>{var y;return(y=a(p))==null?void 0:y.internals.userNode},getInternalNode:a,getEdges:()=>{const{edges:p=[]}=t.getState();return p.map(y=>({...y}))},getEdge:p=>t.getState().edgeLookup.get(p),setNodes:o,setEdges:c,addNodes:p=>{const y=Array.isArray(p)?p:[p];n.nodeQueue.push(b=>[...b,...y])},addEdges:p=>{const y=Array.isArray(p)?p:[p];n.edgeQueue.push(b=>[...b,...y])},toObject:()=>{const{nodes:p=[],edges:y=[],transform:b}=t.getState(),[x,w,E]=b;return{nodes:p.map(v=>({...v})),edges:y.map(v=>({...v})),viewport:{x,y:w,zoom:E}}},deleteElements:async({nodes:p=[],edges:y=[]})=>{const{nodes:b,edges:x,onNodesDelete:w,onEdgesDelete:E,triggerNodeChanges:v,triggerEdgeChanges:_,onDelete:k,onBeforeDelete:T}=t.getState(),{nodes:A,edges:j}=await ele({nodesToRemove:p,edgesToRemove:y,nodes:b,edges:x,onBeforeDelete:T}),M=j.length>0,D=A.length>0;if(M){const I=j.map(cA);E==null||E(j),_(I)}if(D){const I=A.map(cA);w==null||w(A),v(I)}return(D||M)&&(k==null||k({nodes:A,edges:j})),{deletedNodes:A,deletedEdges:j}},getIntersectingNodes:(p,y=!0,b)=>{const x=LT(p),w=x?p:u(p),E=b!==void 0;return w?(b||t.getState().nodes).filter(v=>{const _=t.getState().nodeLookup.get(v.id);if(_&&!x&&(v.id===p.id||!_.internals.positionAbsolute))return!1;const k=Wd(E?v:_),T=_m(k,w);return y&&T>0||T>=k.width*k.height||T>=w.width*w.height}):[]},isNodeIntersecting:(p,y,b=!0)=>{const w=LT(p)?p:u(p);if(!w)return!1;const E=_m(w,y);return b&&E>0||E>=y.width*y.height||E>=w.width*w.height},updateNode:f,updateNodeData:(p,y,b={replace:!1})=>{f(p,x=>{const w=typeof y=="function"?y(x):y;return b.replace?{...x,data:w}:{...x,data:{...x.data,...w}}},b)},updateEdge:m,updateEdgeData:(p,y,b={replace:!1})=>{m(p,x=>{const w=typeof y=="function"?y(x):y;return b.replace?{...x,data:w}:{...x,data:{...x.data,...w}}},b)},getNodesBounds:p=>{const{nodeLookup:y,nodeOrigin:b}=t.getState();return Xoe(p,{nodeLookup:y,nodeOrigin:b})},getHandleConnections:({type:p,id:y,nodeId:b})=>{var x;return Array.from(((x=t.getState().connectionLookup.get(`${b}-${p}${y?`-${y}`:""}`))==null?void 0:x.values())??[])},getNodeConnections:({type:p,handleId:y,nodeId:b})=>{var x;return Array.from(((x=t.getState().connectionLookup.get(`${b}${p?y?`-${p}-${y}`:`-${p}`:""}`))==null?void 0:x.values())??[])},fitView:async p=>{const y=t.getState().fitViewResolver??ile();return t.setState({fitViewQueued:!0,fitViewOptions:p,fitViewResolver:y}),n.nodeQueue.push(b=>[...b]),y.promise}}},[]);return C.useMemo(()=>({...s,...e,viewportInitialized:i}),[i])}const fA=e=>e.selected,Mce=typeof window<"u"?window:void 0;function Rce({deleteKeyCode:e,multiSelectionKeyCode:t}){const n=Sn(),{deleteElements:i}=gg(),s=Xd(e,{actInsideInputWithModifier:!1}),a=Xd(t,{target:Mce});C.useEffect(()=>{if(s){const{edges:o,nodes:c}=n.getState();i({nodes:c.filter(fA),edges:o.filter(fA)}),n.setState({nodesSelectionActive:!1})}},[s]),C.useEffect(()=>{n.setState({multiSelectionActive:a})},[a])}function Dce(e){const t=Sn();C.useEffect(()=>{const n=()=>{var s,a,o,c;if(!e.current||!(((a=(s=e.current).checkVisibility)==null?void 0:a.call(s))??!0))return!1;const i=kw(e.current);(i.height===0||i.width===0)&&((c=(o=t.getState()).onError)==null||c.call(o,"004",as.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 yg={position:"absolute",width:"100%",height:"100%",top:0,left:0},Oce=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function Lce({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:i=!1,panOnScrollSpeed:s=.5,panOnScrollMode:a=Jo.Free,zoomOnDoubleClick:o=!0,panOnDrag:c=!0,defaultViewport:u,translateExtent:f,minZoom:m,maxZoom:p,zoomActivationKeyCode:y,preventScrolling:b=!0,children:x,noWheelClassName:w,noPanClassName:E,onViewportChange:v,isControlledViewport:_,paneClickDistance:k,selectionOnDrag:T}){const A=Sn(),j=C.useRef(null),{userSelectionActive:M,lib:D,connectionInProgress:I}=Ft(Oce,En),P=Xd(y),U=C.useRef();Dce(j);const q=C.useCallback(V=>{v==null||v({x:V[0],y:V[1],zoom:V[2]}),_||A.setState({transform:V})},[v,_]);return C.useEffect(()=>{if(j.current){U.current=Ule({domNode:j.current,minZoom:m,maxZoom:p,translateExtent:f,viewport:u,onDraggingChange:z=>A.setState(G=>G.paneDragging===z?G:{paneDragging:z}),onPanZoomStart:(z,G)=>{const{onViewportChangeStart:X,onMoveStart:K}=A.getState();K==null||K(z,G),X==null||X(G)},onPanZoom:(z,G)=>{const{onViewportChange:X,onMove:K}=A.getState();K==null||K(z,G),X==null||X(G)},onPanZoomEnd:(z,G)=>{const{onViewportChangeEnd:X,onMoveEnd:K}=A.getState();K==null||K(z,G),X==null||X(G)}});const{x:V,y:O,zoom:R}=U.current.getViewport();return A.setState({panZoom:U.current,transform:[V,O,R],domNode:j.current.closest(".react-flow")}),()=>{var z;(z=U.current)==null||z.destroy()}}},[]),C.useEffect(()=>{var V;(V=U.current)==null||V.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:i,panOnScrollSpeed:s,panOnScrollMode:a,zoomOnDoubleClick:o,panOnDrag:c,zoomActivationKeyPressed:P,preventScrolling:b,noPanClassName:E,userSelectionActive:M,noWheelClassName:w,lib:D,onTransformChange:q,connectionInProgress:I,selectionOnDrag:T,paneClickDistance:k})},[e,t,n,i,s,a,o,c,P,b,E,M,w,D,q,I,T,k]),d.jsx("div",{className:"react-flow__renderer",ref:j,style:yg,children:x})}const Ice=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function Pce(){const{userSelectionActive:e,userSelectionRect:t}=Ft(Ice,En);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 Hx=(e,t)=>n=>{n.target===t.current&&(e==null||e(n))},zce=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging,panBy:e.panBy,autoPanSpeed:e.autoPanSpeed});function Bce({isSelecting:e,selectionKeyPressed:t,selectionMode:n=Gd.Full,panOnDrag:i,autoPanOnSelection:s,paneClickDistance:a,selectionOnDrag:o,onSelectionStart:c,onSelectionEnd:u,onPaneClick:f,onPaneContextMenu:m,onPaneScroll:p,onPaneMouseEnter:y,onPaneMouseMove:b,onPaneMouseLeave:x,children:w}){const E=C.useRef(0),v=Sn(),{userSelectionActive:_,elementsSelectable:k,dragging:T,panBy:A,autoPanSpeed:j}=Ft(zce,En),M=k&&(e||_),D=C.useRef(null),I=C.useRef(),P=C.useRef(new Set),U=C.useRef(new Set),q=C.useRef(!1),V=C.useRef(!1),O=C.useRef({x:0,y:0}),R=C.useRef(!1),z=re=>{if(V.current||q.current||v.getState().connection.inProgress){V.current=!1,q.current=!1;return}f==null||f(re),v.getState().resetSelectedElements(),v.setState({nodesSelectionActive:!1})},G=re=>{if(Array.isArray(i)&&(i!=null&&i.includes(2))){re.preventDefault();return}m==null||m(re)},X=p?re=>p(re):void 0,K=re=>{V.current&&(re.stopPropagation(),V.current=!1)},B=re=>{var Re,Qe;const{domNode:me,transform:se}=v.getState();if(I.current=me==null?void 0:me.getBoundingClientRect(),!I.current)return;const Q=re.target===D.current;if(!Q&&!!re.target.closest(".nokey")||!e||!(o&&Q||t)||re.button!==0||!re.isPrimary)return;(Qe=(Re=re.target)==null?void 0:Re.setPointerCapture)==null||Qe.call(Re,re.pointerId),V.current=!1;const{x:ze,y:fe}=Us(re.nativeEvent,I.current),Se=_f({x:ze,y:fe},se);v.setState({userSelectionRect:{width:0,height:0,startX:Se.x,startY:Se.y,x:ze,y:fe}}),Q||(re.stopPropagation(),re.preventDefault())};function F(re,me){const{userSelectionRect:se}=v.getState();if(!se)return;const{transform:Q,nodeLookup:ye,edgeLookup:_e,connectionLookup:ze,triggerNodeChanges:fe,triggerEdgeChanges:Se,defaultEdgeOptions:Re}=v.getState(),Qe={x:se.startX,y:se.startY},{x:ht,y:it}=$c(Qe,Q),Bt={startX:Qe.x,startY:Qe.y,x:re<ht?re:ht,y:me<it?me:it,width:Math.abs(re-ht),height:Math.abs(me-it)},mt=P.current,wt=U.current;P.current=new Set(ww(ye,Bt,Q,n===Gd.Partial,!0).map(ct=>ct.id)),U.current=new Set;const Te=(Re==null?void 0:Re.selectable)??!0;for(const ct of P.current){const ne=ze.get(ct);if(ne)for(const{edgeId:we}of ne.values()){const he=_e.get(we);he&&(he.selectable??Te)&&U.current.add(we)}}if(!IT(mt,P.current)){const ct=dc(ye,P.current,!0);fe(ct)}if(!IT(wt,U.current)){const ct=dc(_e,U.current);Se(ct)}v.setState({userSelectionRect:Bt,userSelectionActive:!0,nodesSelectionActive:!1})}function W(){if(!s||!I.current)return;const[re,me]=Ew(O.current,I.current,j);A({x:re,y:me}).then(se=>{if(!V.current||!se){E.current=requestAnimationFrame(W);return}const{x:Q,y:ye}=O.current;F(Q,ye),E.current=requestAnimationFrame(W)})}const $=()=>{cancelAnimationFrame(E.current),E.current=0,R.current=!1};C.useEffect(()=>()=>$(),[]);const ae=re=>{const{userSelectionRect:me,transform:se,resetSelectedElements:Q}=v.getState();if(!I.current||!me)return;const{x:ye,y:_e}=Us(re.nativeEvent,I.current);O.current={x:ye,y:_e};const ze=$c({x:me.startX,y:me.startY},se);if(!V.current){const fe=t?0:a;if(Math.hypot(ye-ze.x,_e-ze.y)<=fe)return;Q(),c==null||c(re)}V.current=!0,R.current||(W(),R.current=!0),F(ye,_e)},xe=re=>{var me,se;if(!M){re.target===D.current&&v.getState().connection.inProgress&&(q.current=!0);return}re.button===0&&((se=(me=re.target)==null?void 0:me.releasePointerCapture)==null||se.call(me,re.pointerId),!_&&re.target===D.current&&v.getState().userSelectionRect&&(z==null||z(re)),v.setState({userSelectionActive:!1,userSelectionRect:null}),V.current&&(u==null||u(re),v.setState({nodesSelectionActive:P.current.size>0})),$())},le=re=>{var me,se;(se=(me=re.target)==null?void 0:me.releasePointerCapture)==null||se.call(me,re.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:Hx(z,D),onContextMenu:Hx(G,D),onWheel:Hx(X,D),onPointerEnter:M?void 0:y,onPointerMove:M?ae:b,onPointerUp:xe,onPointerCancel:M?le:void 0,onPointerDownCapture:M?B:void 0,onClickCapture:M?K:void 0,onPointerLeave:x,ref:D,style:yg,children:[w,d.jsx(Pce,{})]})}function _v({id:e,store:t,unselect:n=!1,nodeRef:i}){const{addSelectedNodes:s,unselectNodesAndEdges:a,multiSelectionActive:o,nodeLookup:c,onError:u}=t.getState(),f=c.get(e);if(!f){u==null||u("012",as.error012(e));return}t.setState({nodesSelectionActive:!1}),f.selected?(n||f.selected&&o)&&(a({nodes:[f],edges:[]}),requestAnimationFrame(()=>{var m;return(m=i==null?void 0:i.current)==null?void 0:m.blur()})):s([e])}function dP({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:i,nodeId:s,isSelectable:a,nodeClickDistance:o}){const c=Sn(),[u,f]=C.useState(!1),m=C.useRef();return C.useEffect(()=>{m.current=_le({getStoreItems:()=>c.getState(),onNodeMouseDown:p=>{_v({id:p,store:c,nodeRef:e})},onDragStart:()=>{f(!0)},onDragStop:()=>{f(!1)}})},[]),C.useEffect(()=>{if(!(t||!e.current||!m.current))return m.current.update({noDragClassName:n,handleSelector:i,domNode:e.current,isSelectable:a,nodeId:s,nodeClickDistance:o}),()=>{var p;(p=m.current)==null||p.destroy()}},[n,i,t,a,e,s,o]),u}const Uce=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function fP(){const e=Sn();return C.useCallback(n=>{const{nodeExtent:i,snapToGrid:s,snapGrid:a,nodesDraggable:o,onError:c,updateNodePositions:u,nodeLookup:f,nodeOrigin:m}=e.getState(),p=new Map,y=Uce(o),b=s?a[0]:5,x=s?a[1]:5,w=n.direction.x*b*n.factor,E=n.direction.y*x*n.factor;for(const[,v]of f){if(!y(v))continue;let _={x:v.internals.positionAbsolute.x+w,y:v.internals.positionAbsolute.y+E};s&&(_=Nf(_,a));const{position:k,positionAbsolute:T}=CI({nodeId:v.id,nextPosition:_,nodeLookup:f,nodeExtent:i,nodeOrigin:m,onError:c});v.position=k,v.internals.positionAbsolute=T,p.set(v.id,v)}u(p)},[])}const jw=C.createContext(null),Fce=jw.Provider;jw.Consumer;const hP=()=>C.useContext(jw),$ce=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),pP=C.createContext(null);function qce({children:e}){const t=Ft($ce,En);return d.jsx(pP.Provider,{value:t,children:e})}function Hce(){const e=C.useContext(pP);if(!e)throw new Error("useHandleConfig must be used within a HandleConfigProvider");return e}const Vce={connectingFrom:!1,connectingTo:!1,clickConnecting:!1,isPossibleEndHandle:!0,connectionInProcess:!1,clickConnectionInProcess:!1,valid:!1},Kce=(e,t,n)=>i=>{const{connectionClickStartHandle:s,connectionMode:a,connection:o}=i,{fromHandle:c,toHandle:u,isValid:f}=o;if(!c&&!s)return Vce;const m=(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:m,clickConnecting:(s==null?void 0:s.nodeId)===e&&(s==null?void 0:s.id)===t&&(s==null?void 0:s.type)===n,isPossibleEndHandle:a===Uc.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:m&&f}};function Gce({type:e="source",position:t=Je.Top,isValidConnection:n,isConnectable:i=!0,isConnectableStart:s=!0,isConnectableEnd:a=!0,id:o,onConnect:c,children:u,className:f,onMouseDown:m,onTouchStart:p,...y},b){var R,z;const x=o||null,w=e==="target",E=Sn(),v=hP(),{connectOnClick:_,noPanClassName:k,rfId:T}=Hce(),{connectingFrom:A,connectingTo:j,clickConnecting:M,isPossibleEndHandle:D,connectionInProcess:I,clickConnectionInProcess:P,valid:U}=Ft(Kce(v,x,e),En);v||(z=(R=E.getState()).onError)==null||z.call(R,"010",as.error010());const q=G=>{const{defaultEdgeOptions:X,onConnect:K,hasDefaultEdges:B}=E.getState(),F={...X,...G};if(B){const{edges:W,setEdges:$,onError:ae}=E.getState();$(lP(F,W,{onError:ae}))}K==null||K(F),c==null||c(F)},V=G=>{if(!v)return;const X=II(G.nativeEvent);if(s&&(X&&G.button===0||!X)){const K=E.getState();Nv.onPointerDown(G.nativeEvent,{handleDomNode:G.currentTarget,autoPanOnConnect:K.autoPanOnConnect,connectionMode:K.connectionMode,connectionRadius:K.connectionRadius,domNode:K.domNode,nodeLookup:K.nodeLookup,lib:K.lib,isTarget:w,handleId:x,nodeId:v,flowId:K.rfId,panBy:K.panBy,cancelConnection:K.cancelConnection,onConnectStart:K.onConnectStart,onConnectEnd:(...B)=>{var F,W;return(W=(F=E.getState()).onConnectEnd)==null?void 0:W.call(F,...B)},updateConnection:K.updateConnection,onConnect:q,isValidConnection:n||((...B)=>{var F,W;return((W=(F=E.getState()).isValidConnection)==null?void 0:W.call(F,...B))??!0}),getTransform:()=>E.getState().transform,getFromHandle:()=>E.getState().connection.fromHandle,autoPanSpeed:K.autoPanSpeed,dragThreshold:K.connectionDragThreshold})}X?m==null||m(G):p==null||p(G)},O=G=>{const{onClickConnectStart:X,onClickConnectEnd:K,connectionClickStartHandle:B,connectionMode:F,isValidConnection:W,lib:$,rfId:ae,nodeLookup:xe,connection:le}=E.getState();if(!v||!B&&!s)return;if(!B){X==null||X(G.nativeEvent,{nodeId:v,handleId:x,handleType:e}),E.setState({connectionClickStartHandle:{nodeId:v,type:e,id:x}});return}const Ne=OI(G.target),re=n||W,{connection:me,isValid:se}=Nv.isValid(G.nativeEvent,{handle:{nodeId:v,id:x,type:e},connectionMode:F,fromNodeId:B.nodeId,fromHandleId:B.id||null,fromType:B.type,isValidConnection:re,flowId:ae,doc:Ne,lib:$,nodeLookup:xe});se&&me&&q(me);const Q=structuredClone(le);delete Q.inProgress,Q.toPosition=Q.toHandle?Q.toHandle.position:null,K==null||K(G,Q),E.setState({connectionClickStartHandle:null})};return d.jsx("div",{"data-handleid":x,"data-nodeid":v,"data-handlepos":t,"data-id":`${T}-${v}-${x}-${e}`,className:Wn(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",k,f,{source:!w,target:w,connectable:i,connectablestart:s,connectableend:a,clickconnecting:M,connectingfrom:A,connectingto:j,valid:U,connectionindicator:i&&(!I||D)&&(I||P?a:s)}]),onMouseDown:V,onTouchStart:V,onClick:_?O:void 0,ref:b,...y,children:u})}const Za=C.memo(cP(Gce));function Wce({data:e,isConnectable:t,sourcePosition:n=Je.Bottom}){return d.jsxs(d.Fragment,{children:[e==null?void 0:e.label,d.jsx(Za,{type:"source",position:n,isConnectable:t})]})}function Yce({data:e,isConnectable:t,targetPosition:n=Je.Top,sourcePosition:i=Je.Bottom}){return d.jsxs(d.Fragment,{children:[d.jsx(Za,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label,d.jsx(Za,{type:"source",position:i,isConnectable:t})]})}function Xce(){return null}function Qce({data:e,isConnectable:t,targetPosition:n=Je.Top}){return d.jsxs(d.Fragment,{children:[d.jsx(Za,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label]})}const Cm={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},hA={input:Wce,default:Yce,output:Qce,group:Xce};function Zce(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 Jce=e=>{const{width:t,height:n,x:i,y:s}=kf(e.nodeLookup,{filter:a=>!!a.selected});return{width:Bs(t)?t:null,height:Bs(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=Sn(),{width:s,height:a,transformString:o,userSelectionActive:c}=Ft(Jce,En),u=fP(),f=C.useRef(null);C.useEffect(()=>{var b;n||(b=f.current)==null||b.focus({preventScroll:!0})},[n]);const m=!c&&s!==null&&a!==null;if(dP({nodeRef:f,disabled:!m}),!m)return null;const p=e?b=>{const x=i.getState().nodes.filter(w=>w.selected);e(b,x)}:void 0,y=b=>{Object.prototype.hasOwnProperty.call(Cm,b.key)&&(b.preventDefault(),u({direction:Cm[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:p,tabIndex:n?void 0:-1,onKeyDown:n?void 0:y,style:{width:s,height:a}})})}const pA=typeof window<"u"?window:void 0,tue=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function mP({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:i,onPaneMouseLeave:s,onPaneContextMenu:a,onPaneScroll:o,paneClickDistance:c,deleteKeyCode:u,selectionKeyCode:f,selectionOnDrag:m,selectionMode:p,onSelectionStart:y,onSelectionEnd:b,multiSelectionKeyCode:x,panActivationKeyCode:w,zoomActivationKeyCode:E,elementsSelectable:v,zoomOnScroll:_,zoomOnPinch:k,panOnScroll:T,panOnScrollSpeed:A,panOnScrollMode:j,zoomOnDoubleClick:M,panOnDrag:D,autoPanOnSelection:I,defaultViewport:P,translateExtent:U,minZoom:q,maxZoom:V,preventScrolling:O,onSelectionContextMenu:R,noWheelClassName:z,noPanClassName:G,disableKeyboardA11y:X,onViewportChange:K,isControlledViewport:B}){const{nodesSelectionActive:F,userSelectionActive:W}=Ft(tue,En),$=Xd(f,{target:pA}),ae=Xd(w,{target:pA}),xe=ae||D,le=ae||T,Ne=m&&xe!==!0,re=$||W||Ne;return Rce({deleteKeyCode:u,multiSelectionKeyCode:x}),d.jsx(Lce,{onPaneContextMenu:a,elementsSelectable:v,zoomOnScroll:_,zoomOnPinch:k,panOnScroll:le,panOnScrollSpeed:A,panOnScrollMode:j,zoomOnDoubleClick:M,panOnDrag:!$&&xe,defaultViewport:P,translateExtent:U,minZoom:q,maxZoom:V,zoomActivationKeyCode:E,preventScrolling:O,noWheelClassName:z,noPanClassName:G,onViewportChange:K,isControlledViewport:B,paneClickDistance:c,selectionOnDrag:Ne,children:d.jsxs(Bce,{onSelectionStart:y,onSelectionEnd:b,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:i,onPaneMouseLeave:s,onPaneContextMenu:a,onPaneScroll:o,panOnDrag:xe,autoPanOnSelection:I,isSelecting:!!re,selectionMode:p,selectionKeyPressed:$,paneClickDistance:c,selectionOnDrag:Ne,children:[e,F&&d.jsx(eue,{onSelectionContextMenu:R,noPanClassName:G,disableKeyboardA11y:X})]})})}mP.displayName="FlowRenderer";const nue=C.memo(mP),iue=e=>t=>e?ww(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 sue(e){return Ft(C.useCallback(iue(e),[e]),En)}const rue=e=>e.updateNodeInternals;function aue(){const e=Ft(rue),[t]=C.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(n=>{const i=new Map;n.forEach(s=>{const a=s.target.getAttribute("data-id");i.set(a,{id:a,nodeElement:s.target,force:!0})}),e(i)}));return C.useEffect(()=>()=>{t==null||t.disconnect()},[t]),t}function oue({node:e,nodeType:t,hasDimensions:n,resizeObserver:i}){const s=Sn(),a=C.useRef(null),o=C.useRef(null),c=C.useRef(e.sourcePosition),u=C.useRef(e.targetPosition),f=C.useRef(t),m=n&&!!e.internals.handleBounds;return C.useEffect(()=>{a.current&&!e.hidden&&(!m||o.current!==a.current)&&(o.current&&(i==null||i.unobserve(o.current)),i==null||i.observe(a.current),o.current=a.current)},[m,e.hidden]),C.useEffect(()=>()=>{o.current&&(i==null||i.unobserve(o.current),o.current=null)},[]),C.useEffect(()=>{if(a.current){const p=f.current!==t,y=c.current!==e.sourcePosition,b=u.current!==e.targetPosition;(p||y||b)&&(f.current=t,c.current=e.sourcePosition,u.current=e.targetPosition,s.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:a.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),a}function lue({id:e,onClick:t,onMouseEnter:n,onMouseMove:i,onMouseLeave:s,onContextMenu:a,onDoubleClick:o,nodesDraggable:c,elementsSelectable:u,nodesConnectable:f,nodesFocusable:m,resizeObserver:p,noDragClassName:y,noPanClassName:b,disableKeyboardA11y:x,rfId:w,nodeTypes:E,nodeClickDistance:v,onError:_}){const{node:k,internals:T,isParent:A}=Ft(re=>{const me=re.nodeLookup.get(e),se=re.parentLookup.has(e);return{node:me,internals:me.internals,isParent:se}},En);let j=k.type||"default",M=(E==null?void 0:E[j])||hA[j];M===void 0&&(_==null||_("003",as.error003(j)),j="default",M=(E==null?void 0:E.default)||hA.default);const D=!!(k.draggable||c&&typeof k.draggable>"u"),I=!!(k.selectable||u&&typeof k.selectable>"u"),P=!!(k.connectable||f&&typeof k.connectable>"u"),U=!!(k.focusable||m&&typeof k.focusable>"u"),q=Sn(),V=RI(k),O=oue({node:k,nodeType:j,hasDimensions:V,resizeObserver:p}),R=dP({nodeRef:O,disabled:k.hidden||!D,noDragClassName:y,handleSelector:k.dragHandle,nodeId:e,isSelectable:I,nodeClickDistance:v}),z=fP();if(k.hidden)return null;const G=ia(k),X=Zce(k),K=I||D||t||n||i||s,B=n?re=>n(re,{...T.userNode}):void 0,F=i?re=>i(re,{...T.userNode}):void 0,W=s?re=>s(re,{...T.userNode}):void 0,$=a?re=>a(re,{...T.userNode}):void 0,ae=o?re=>o(re,{...T.userNode}):void 0,xe=re=>{const{selectNodesOnDrag:me,nodeDragThreshold:se}=q.getState();I&&(!me||!D||se>0)&&_v({id:e,store:q,nodeRef:O}),t&&t(re,{...T.userNode})},le=re=>{if(!(LI(re.nativeEvent)||x)){if(EI.includes(re.key)&&I){const me=re.key==="Escape";_v({id:e,store:q,unselect:me,nodeRef:O})}else if(D&&k.selected&&Object.prototype.hasOwnProperty.call(Cm,re.key)){re.preventDefault();const{ariaLabelConfig:me}=q.getState();q.setState({ariaLiveMessage:me["node.a11yDescription.ariaLiveMessage"]({direction:re.key.replace("Arrow","").toLowerCase(),x:~~T.positionAbsolute.x,y:~~T.positionAbsolute.y})}),z({direction:Cm[re.key],factor:re.shiftKey?4:1})}}},Ne=()=>{var ze;if(x||!((ze=O.current)!=null&&ze.matches(":focus-visible")))return;const{transform:re,width:me,height:se,autoPanOnNodeFocus:Q,setCenter:ye}=q.getState();if(!Q)return;ww(new Map([[e,k]]),{x:0,y:0,width:me,height:se},re,!0).length>0||ye(k.position.x+G.width/2,k.position.y+G.height/2,{zoom:re[2]})};return d.jsx("div",{className:Wn(["react-flow__node",`react-flow__node-${j}`,{[b]:D},k.className,{selected:k.selected,selectable:I,parent:A,draggable:D,dragging:R}]),ref:O,style:{zIndex:T.z,transform:`translate(${T.positionAbsolute.x}px,${T.positionAbsolute.y}px)`,pointerEvents:K?"all":"none",visibility:V?"visible":"hidden",...k.style,...X},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:B,onMouseMove:F,onMouseLeave:W,onContextMenu:$,onClick:xe,onDoubleClick:ae,onKeyDown:U?le:void 0,tabIndex:U?0:void 0,onFocus:U?Ne:void 0,role:k.ariaRole??(U?"group":void 0),"aria-roledescription":"node","aria-describedby":x?void 0:`${tP}-${w}`,"aria-label":k.ariaLabel,...k.domAttributes,children:d.jsx(Fce,{value:e,children:d.jsx(M,{id:e,data:k.data,type:j,positionAbsoluteX:T.positionAbsolute.x,positionAbsoluteY:T.positionAbsolute.y,selected:k.selected??!1,selectable:I,draggable:D,deletable:k.deletable??!0,isConnectable:P,sourcePosition:k.sourcePosition,targetPosition:k.targetPosition,dragging:R,dragHandle:k.dragHandle,zIndex:T.z,parentId:k.parentId,...G})})})}var cue=C.memo(lue);const uue=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function gP(e){const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:i,elementsSelectable:s,onError:a}=Ft(uue,En),o=sue(e.onlyRenderVisibleElements),c=aue();return d.jsx("div",{className:"react-flow__nodes",style:yg,children:o.map(u=>d.jsx(cue,{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:a},u))})}gP.displayName="NodeRenderer";const due=C.memo(gP);function fue(e){return Ft(C.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 a=n.nodeLookup.get(s.source),o=n.nodeLookup.get(s.target);a&&o&&ole({sourceNode:a,targetNode:o,width:n.width,height:n.height,transform:n.transform})&&i.push(s.id)}return i},[e]),En)}const hue=({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"})},pue=({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"})},mA={[km.Arrow]:hue,[km.ArrowClosed]:pue};function mue(e){const t=Sn();return C.useMemo(()=>{var s,a;return Object.prototype.hasOwnProperty.call(mA,e)?mA[e]:((a=(s=t.getState()).onError)==null||a.call(s,"009",as.error009(e)),null)},[e])}const gue=({id:e,type:t,color:n,width:i=12.5,height:s=12.5,markerUnits:a="strokeWidth",strokeWidth:o,orient:c="auto-start-reverse"})=>{const u=mue(t);return u?d.jsx("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${i}`,markerHeight:`${s}`,viewBox:"-10 -10 20 20",markerUnits:a,orient:c,refX:"0",refY:"0",children:d.jsx(u,{color:n,strokeWidth:o})}):null},yP=({defaultColor:e,rfId:t})=>{const n=Ft(a=>a.edges),i=Ft(a=>a.defaultEdgeOptions),s=C.useMemo(()=>mle(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(a=>d.jsx(gue,{id:a.id,type:a.type,color:a.color,width:a.width,height:a.height,markerUnits:a.markerUnits,strokeWidth:a.strokeWidth,orient:a.orient},a.id))})}):null};yP.displayName="MarkerDefinitions";var yue=C.memo(yP);function bP({x:e,y:t,label:n,labelStyle:i,labelShowBg:s=!0,labelBgStyle:a,labelBgPadding:o=[2,4],labelBgBorderRadius:c=2,children:u,className:f,...m}){const[p,y]=C.useState({x:1,y:0,width:0,height:0}),b=Wn(["react-flow__edge-textwrapper",f]),x=C.useRef(null);return C.useEffect(()=>{if(x.current){const w=x.current.getBBox();y({x:w.x,y:w.y,width:w.width,height:w.height})}},[n]),n?d.jsxs("g",{transform:`translate(${e-p.width/2} ${t-p.height/2})`,className:b,visibility:p.width?"visible":"hidden",...m,children:[s&&d.jsx("rect",{width:p.width+2*o[0],x:-o[0],y:-o[1],height:p.height+2*o[1],className:"react-flow__edge-textbg",style:a,rx:c,ry:c}),d.jsx("text",{className:"react-flow__edge-text",y:p.height/2,dy:"0.3em",ref:x,style:i,children:n}),u]}):null}bP.displayName="EdgeText";const bue=C.memo(bP);function bg({path:e,labelX:t,labelY:n,label:i,labelStyle:s,labelShowBg:a,labelBgStyle:o,labelBgPadding:c,labelBgBorderRadius:u,interactionWidth:f=20,...m}){return d.jsxs(d.Fragment,{children:[d.jsx("path",{...m,d:e,fill:"none",className:Wn(["react-flow__edge-path",m.className])}),f?d.jsx("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:f,className:"react-flow__edge-interaction"}):null,i&&Bs(t)&&Bs(n)?d.jsx(bue,{x:t,y:n,label:i,labelStyle:s,labelShowBg:a,labelBgStyle:o,labelBgPadding:c,labelBgBorderRadius:u}):null]})}function gA({pos:e,x1:t,y1:n,x2:i,y2:s}){return e===Je.Left||e===Je.Right?[.5*(t+i),n]:[t,.5*(n+s)]}function xP({sourceX:e,sourceY:t,sourcePosition:n=Je.Bottom,targetX:i,targetY:s,targetPosition:a=Je.Top}){const[o,c]=gA({pos:n,x1:e,y1:t,x2:i,y2:s}),[u,f]=gA({pos:a,x1:i,y1:s,x2:e,y2:t}),[m,p,y,b]=PI({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}`,m,p,y,b]}function vP(e){return C.memo(({id:t,sourceX:n,sourceY:i,targetX:s,targetY:a,sourcePosition:o,targetPosition:c,label:u,labelStyle:f,labelShowBg:m,labelBgStyle:p,labelBgPadding:y,labelBgBorderRadius:b,style:x,markerEnd:w,markerStart:E,interactionWidth:v})=>{const[_,k,T]=xP({sourceX:n,sourceY:i,sourcePosition:o,targetX:s,targetY:a,targetPosition:c}),A=e.isInternal?void 0:t;return d.jsx(bg,{id:A,path:_,labelX:k,labelY:T,label:u,labelStyle:f,labelShowBg:m,labelBgStyle:p,labelBgPadding:y,labelBgBorderRadius:b,style:x,markerEnd:w,markerStart:E,interactionWidth:v})})}const xue=vP({isInternal:!1}),wP=vP({isInternal:!0});xue.displayName="SimpleBezierEdge";wP.displayName="SimpleBezierEdgeInternal";function EP(e){return C.memo(({id:t,sourceX:n,sourceY:i,targetX:s,targetY:a,label:o,labelStyle:c,labelShowBg:u,labelBgStyle:f,labelBgPadding:m,labelBgBorderRadius:p,style:y,sourcePosition:b=Je.Bottom,targetPosition:x=Je.Top,markerEnd:w,markerStart:E,pathOptions:v,interactionWidth:_})=>{const[k,T,A]=Ev({sourceX:n,sourceY:i,sourcePosition:b,targetX:s,targetY:a,targetPosition:x,borderRadius:v==null?void 0:v.borderRadius,offset:v==null?void 0:v.offset,stepPosition:v==null?void 0:v.stepPosition}),j=e.isInternal?void 0:t;return d.jsx(bg,{id:j,path:k,labelX:T,labelY:A,label:o,labelStyle:c,labelShowBg:u,labelBgStyle:f,labelBgPadding:m,labelBgBorderRadius:p,style:y,markerEnd:w,markerStart:E,interactionWidth:_})})}const SP=EP({isInternal:!1}),kP=EP({isInternal:!0});SP.displayName="SmoothStepEdge";kP.displayName="SmoothStepEdgeInternal";function NP(e){return C.memo(({id:t,...n})=>{var s;const i=e.isInternal?void 0:t;return d.jsx(SP,{...n,id:i,pathOptions:C.useMemo(()=>{var a;return{borderRadius:0,offset:(a=n.pathOptions)==null?void 0:a.offset}},[(s=n.pathOptions)==null?void 0:s.offset])})})}const vue=NP({isInternal:!1}),_P=NP({isInternal:!0});vue.displayName="StepEdge";_P.displayName="StepEdgeInternal";function CP(e){return C.memo(({id:t,sourceX:n,sourceY:i,targetX:s,targetY:a,label:o,labelStyle:c,labelShowBg:u,labelBgStyle:f,labelBgPadding:m,labelBgBorderRadius:p,style:y,markerEnd:b,markerStart:x,interactionWidth:w})=>{const[E,v,_]=FI({sourceX:n,sourceY:i,targetX:s,targetY:a}),k=e.isInternal?void 0:t;return d.jsx(bg,{id:k,path:E,labelX:v,labelY:_,label:o,labelStyle:c,labelShowBg:u,labelBgStyle:f,labelBgPadding:m,labelBgBorderRadius:p,style:y,markerEnd:b,markerStart:x,interactionWidth:w})})}const wue=CP({isInternal:!1}),TP=CP({isInternal:!0});wue.displayName="StraightEdge";TP.displayName="StraightEdgeInternal";function AP(e){return C.memo(({id:t,sourceX:n,sourceY:i,targetX:s,targetY:a,sourcePosition:o=Je.Bottom,targetPosition:c=Je.Top,label:u,labelStyle:f,labelShowBg:m,labelBgStyle:p,labelBgPadding:y,labelBgBorderRadius:b,style:x,markerEnd:w,markerStart:E,pathOptions:v,interactionWidth:_})=>{const[k,T,A]=zI({sourceX:n,sourceY:i,sourcePosition:o,targetX:s,targetY:a,targetPosition:c,curvature:v==null?void 0:v.curvature}),j=e.isInternal?void 0:t;return d.jsx(bg,{id:j,path:k,labelX:T,labelY:A,label:u,labelStyle:f,labelShowBg:m,labelBgStyle:p,labelBgPadding:y,labelBgBorderRadius:b,style:x,markerEnd:w,markerStart:E,interactionWidth:_})})}const Eue=AP({isInternal:!1}),jP=AP({isInternal:!0});Eue.displayName="BezierEdge";jP.displayName="BezierEdgeInternal";const yA={default:jP,straight:TP,step:_P,smoothstep:kP,simplebezier:wP},bA={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null,zIndex:void 0},Sue=(e,t,n)=>n===Je.Left?e-t:n===Je.Right?e+t:e,kue=(e,t,n)=>n===Je.Top?e-t:n===Je.Bottom?e+t:e,xA="react-flow__edgeupdater";function vA({position:e,centerX:t,centerY:n,radius:i=10,onMouseDown:s,onMouseEnter:a,onMouseOut:o,type:c}){return d.jsx("circle",{onMouseDown:s,onMouseEnter:a,onMouseOut:o,className:Wn([xA,`${xA}-${c}`]),cx:Sue(t,i,e),cy:kue(n,i,e),r:i,stroke:"transparent",fill:"transparent"})}function Nue({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:i,sourceY:s,targetX:a,targetY:o,sourcePosition:c,targetPosition:u,onReconnect:f,onReconnectStart:m,onReconnectEnd:p,setReconnecting:y,setUpdateHover:b}){const x=Sn(),w=(T,A)=>{if(T.button!==0)return;const{autoPanOnConnect:j,domNode:M,connectionMode:D,connectionRadius:I,lib:P,onConnectStart:U,cancelConnection:q,nodeLookup:V,rfId:O,panBy:R,updateConnection:z}=x.getState(),G=A.type==="target",X=(F,W)=>{y(!1),p==null||p(F,n,A.type,W)},K=F=>f==null?void 0:f(n,F),B=(F,W)=>{y(!0),m==null||m(T,n,A.type),U==null||U(F,W)};Nv.onPointerDown(T.nativeEvent,{autoPanOnConnect:j,connectionMode:D,connectionRadius:I,domNode:M,handleId:A.id,nodeId:A.nodeId,nodeLookup:V,isTarget:G,edgeUpdaterType:A.type,lib:P,flowId:O,cancelConnection:q,panBy:R,isValidConnection:(...F)=>{var W,$;return(($=(W=x.getState()).isValidConnection)==null?void 0:$.call(W,...F))??!0},onConnect:K,onConnectStart:B,onConnectEnd:(...F)=>{var W,$;return($=(W=x.getState()).onConnectEnd)==null?void 0:$.call(W,...F)},onReconnectEnd:X,updateConnection:z,getTransform:()=>x.getState().transform,getFromHandle:()=>x.getState().connection.fromHandle,dragThreshold:x.getState().connectionDragThreshold,handleDomNode:T.currentTarget})},E=T=>w(T,{nodeId:n.target,id:n.targetHandle??null,type:"target"}),v=T=>w(T,{nodeId:n.source,id:n.sourceHandle??null,type:"source"}),_=()=>b(!0),k=()=>b(!1);return d.jsxs(d.Fragment,{children:[(e===!0||e==="source")&&d.jsx(vA,{position:c,centerX:i,centerY:s,radius:t,onMouseDown:E,onMouseEnter:_,onMouseOut:k,type:"source"}),(e===!0||e==="target")&&d.jsx(vA,{position:u,centerX:a,centerY:o,radius:t,onMouseDown:v,onMouseEnter:_,onMouseOut:k,type:"target"})]})}function _ue({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:i,onClick:s,onDoubleClick:a,onContextMenu:o,onMouseEnter:c,onMouseMove:u,onMouseLeave:f,reconnectRadius:m,onReconnect:p,onReconnectStart:y,onReconnectEnd:b,rfId:x,edgeTypes:w,noPanClassName:E,onError:v,disableKeyboardA11y:_}){let k=Ft(ye=>ye.edgeLookup.get(e));const T=Ft(ye=>ye.defaultEdgeOptions);k=T?{...T,...k}:k;let A=k.type||"default",j=(w==null?void 0:w[A])||yA[A];j===void 0&&(v==null||v("011",as.error011(A)),A="default",j=(w==null?void 0:w.default)||yA.default);const M=!!(k.focusable||t&&typeof k.focusable>"u"),D=typeof p<"u"&&(k.reconnectable||n&&typeof k.reconnectable>"u"),I=!!(k.selectable||i&&typeof k.selectable>"u"),P=C.useRef(null),[U,q]=C.useState(!1),[V,O]=C.useState(!1),R=Sn(),{zIndex:z=k.zIndex,sourceX:G,sourceY:X,targetX:K,targetY:B,sourcePosition:F,targetPosition:W}=Ft(C.useCallback(ye=>{const _e=ye.nodeLookup.get(k.source),ze=ye.nodeLookup.get(k.target);if(!_e||!ze)return bA;const fe=ple({id:e,sourceNode:_e,targetNode:ze,sourceHandle:k.sourceHandle||null,targetHandle:k.targetHandle||null,connectionMode:ye.connectionMode,onError:v}),Se=ale({selected:k.selected,zIndex:k.zIndex,sourceNode:_e,targetNode:ze,elevateOnSelect:ye.elevateEdgesOnSelect,zIndexMode:ye.zIndexMode});return{...fe||bA,zIndex:Se}},[k.source,k.target,k.sourceHandle,k.targetHandle,k.selected,k.zIndex]),En),$=C.useMemo(()=>k.markerStart?`url('#${Sv(k.markerStart,x)}')`:void 0,[k.markerStart,x]),ae=C.useMemo(()=>k.markerEnd?`url('#${Sv(k.markerEnd,x)}')`:void 0,[k.markerEnd,x]);if(k.hidden||G===null||X===null||K===null||B===null)return null;const xe=ye=>{var Se;const{addSelectedEdges:_e,unselectNodesAndEdges:ze,multiSelectionActive:fe}=R.getState();I&&(R.setState({nodesSelectionActive:!1}),k.selected&&fe?(ze({nodes:[],edges:[k]}),(Se=P.current)==null||Se.blur()):_e([e])),s&&s(ye,k)},le=a?ye=>{a(ye,{...k})}:void 0,Ne=o?ye=>{o(ye,{...k})}:void 0,re=c?ye=>{c(ye,{...k})}:void 0,me=u?ye=>{u(ye,{...k})}:void 0,se=f?ye=>{f(ye,{...k})}:void 0,Q=ye=>{var _e;if(!_&&EI.includes(ye.key)&&I){const{unselectNodesAndEdges:ze,addSelectedEdges:fe}=R.getState();ye.key==="Escape"?((_e=P.current)==null||_e.blur(),ze({edges:[k]})):fe([e])}};return d.jsx("svg",{style:{zIndex:z},children:d.jsxs("g",{className:Wn(["react-flow__edge",`react-flow__edge-${A}`,k.className,E,{selected:k.selected,animated:k.animated,inactive:!I&&!s,updating:U,selectable:I}]),onClick:xe,onDoubleClick:le,onContextMenu:Ne,onMouseEnter:re,onMouseMove:me,onMouseLeave:se,onKeyDown:M?Q:void 0,tabIndex:M?0:void 0,role:k.ariaRole??(M?"group":"img"),"aria-roledescription":"edge","data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":k.ariaLabel===null?void 0:k.ariaLabel||`Edge from ${k.source} to ${k.target}`,"aria-describedby":M?`${nP}-${x}`:void 0,ref:P,...k.domAttributes,children:[!V&&d.jsx(j,{id:e,source:k.source,target:k.target,type:k.type,selected:k.selected,animated:k.animated,selectable:I,deletable:k.deletable??!0,label:k.label,labelStyle:k.labelStyle,labelShowBg:k.labelShowBg,labelBgStyle:k.labelBgStyle,labelBgPadding:k.labelBgPadding,labelBgBorderRadius:k.labelBgBorderRadius,sourceX:G,sourceY:X,targetX:K,targetY:B,sourcePosition:F,targetPosition:W,data:k.data,style:k.style,sourceHandleId:k.sourceHandle,targetHandleId:k.targetHandle,markerStart:$,markerEnd:ae,pathOptions:"pathOptions"in k?k.pathOptions:void 0,interactionWidth:k.interactionWidth}),D&&d.jsx(Nue,{edge:k,isReconnectable:D,reconnectRadius:m,onReconnect:p,onReconnectStart:y,onReconnectEnd:b,sourceX:G,sourceY:X,targetX:K,targetY:B,sourcePosition:F,targetPosition:W,setUpdateHover:q,setReconnecting:O})]})})}var Cue=C.memo(_ue);const Tue=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function MP({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:i,noPanClassName:s,onReconnect:a,onEdgeContextMenu:o,onEdgeMouseEnter:c,onEdgeMouseMove:u,onEdgeMouseLeave:f,onEdgeClick:m,reconnectRadius:p,onEdgeDoubleClick:y,onReconnectStart:b,onReconnectEnd:x,disableKeyboardA11y:w}){const{edgesFocusable:E,edgesReconnectable:v,elementsSelectable:_,onError:k}=Ft(Tue,En),T=fue(t);return d.jsxs("div",{className:"react-flow__edges",children:[d.jsx(yue,{defaultColor:e,rfId:n}),T.map(A=>d.jsx(Cue,{id:A,edgesFocusable:E,edgesReconnectable:v,elementsSelectable:_,noPanClassName:s,onReconnect:a,onContextMenu:o,onMouseEnter:c,onMouseMove:u,onMouseLeave:f,onClick:m,reconnectRadius:p,onDoubleClick:y,onReconnectStart:b,onReconnectEnd:x,rfId:n,onError:k,edgeTypes:i,disableKeyboardA11y:w},A))]})}MP.displayName="EdgeRenderer";const Aue=C.memo(MP),jue=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function Mue({children:e}){const t=Ft(jue);return d.jsx("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:t},children:e})}function Rue(e){const t=gg(),n=C.useRef(!1);C.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const Due=e=>{var t;return(t=e.panZoom)==null?void 0:t.syncViewport};function Oue(e){const t=Ft(Due),n=Sn();return C.useEffect(()=>{e&&(t==null||t(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function Lue(e){return e.connection.inProgress?{...e.connection,to:_f(e.connection.to,e.transform)}:{...e.connection}}function Iue(e){return Lue}function Pue(e){const t=Iue();return Ft(t,En)}const zue=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function Bue({containerStyle:e,style:t,type:n,component:i}){const{nodesConnectable:s,width:a,height:o,isValid:c,inProgress:u}=Ft(zue,En);return!(a&&s&&u)?null:d.jsx("svg",{style:e,width:a,height:o,className:"react-flow__connectionline react-flow__container",children:d.jsx("g",{className:Wn(["react-flow__connection",NI(c)]),children:d.jsx(RP,{style:t,type:n,CustomComponent:i,isValid:c})})})}const RP=({style:e,type:t=Fa.Bezier,CustomComponent:n,isValid:i})=>{const{inProgress:s,from:a,fromNode:o,fromHandle:c,fromPosition:u,to:f,toNode:m,toHandle:p,toPosition:y,pointer:b}=Pue();if(!s)return;if(n)return d.jsx(n,{connectionLineType:t,connectionLineStyle:e,fromNode:o,fromHandle:c,fromX:a.x,fromY:a.y,toX:f.x,toY:f.y,fromPosition:u,toPosition:y,connectionStatus:NI(i),toNode:m,toHandle:p,pointer:b});let x="";const w={sourceX:a.x,sourceY:a.y,sourcePosition:u,targetX:f.x,targetY:f.y,targetPosition:y};switch(t){case Fa.Bezier:[x]=zI(w);break;case Fa.SimpleBezier:[x]=xP(w);break;case Fa.Step:[x]=Ev({...w,borderRadius:0});break;case Fa.SmoothStep:[x]=Ev(w);break;default:[x]=FI(w)}return d.jsx("path",{d:x,fill:"none",className:"react-flow__connection-path",style:e})};RP.displayName="ConnectionLine";const Uue={};function wA(e=Uue){C.useRef(e),Sn(),C.useEffect(()=>{},[e])}function Fue(){Sn(),C.useRef(!1),C.useEffect(()=>{},[])}function DP({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:i,onEdgeClick:s,onNodeDoubleClick:a,onEdgeDoubleClick:o,onNodeMouseEnter:c,onNodeMouseMove:u,onNodeMouseLeave:f,onNodeContextMenu:m,onSelectionContextMenu:p,onSelectionStart:y,onSelectionEnd:b,connectionLineType:x,connectionLineStyle:w,connectionLineComponent:E,connectionLineContainerStyle:v,selectionKeyCode:_,selectionOnDrag:k,selectionMode:T,multiSelectionKeyCode:A,panActivationKeyCode:j,zoomActivationKeyCode:M,deleteKeyCode:D,onlyRenderVisibleElements:I,elementsSelectable:P,defaultViewport:U,translateExtent:q,minZoom:V,maxZoom:O,preventScrolling:R,defaultMarkerColor:z,zoomOnScroll:G,zoomOnPinch:X,panOnScroll:K,panOnScrollSpeed:B,panOnScrollMode:F,zoomOnDoubleClick:W,panOnDrag:$,autoPanOnSelection:ae,onPaneClick:xe,onPaneMouseEnter:le,onPaneMouseMove:Ne,onPaneMouseLeave:re,onPaneScroll:me,onPaneContextMenu:se,paneClickDistance:Q,nodeClickDistance:ye,onEdgeContextMenu:_e,onEdgeMouseEnter:ze,onEdgeMouseMove:fe,onEdgeMouseLeave:Se,reconnectRadius:Re,onReconnect:Qe,onReconnectStart:ht,onReconnectEnd:it,noDragClassName:Bt,noWheelClassName:mt,noPanClassName:wt,disableKeyboardA11y:Te,nodeExtent:ct,rfId:ne,viewport:we,onViewportChange:he}){return wA(e),wA(t),Fue(),Rue(n),Oue(we),d.jsx(nue,{onPaneClick:xe,onPaneMouseEnter:le,onPaneMouseMove:Ne,onPaneMouseLeave:re,onPaneContextMenu:se,onPaneScroll:me,paneClickDistance:Q,deleteKeyCode:D,selectionKeyCode:_,selectionOnDrag:k,selectionMode:T,onSelectionStart:y,onSelectionEnd:b,multiSelectionKeyCode:A,panActivationKeyCode:j,zoomActivationKeyCode:M,elementsSelectable:P,zoomOnScroll:G,zoomOnPinch:X,zoomOnDoubleClick:W,panOnScroll:K,panOnScrollSpeed:B,panOnScrollMode:F,panOnDrag:$,autoPanOnSelection:ae,defaultViewport:U,translateExtent:q,minZoom:V,maxZoom:O,onSelectionContextMenu:p,preventScrolling:R,noDragClassName:Bt,noWheelClassName:mt,noPanClassName:wt,disableKeyboardA11y:Te,onViewportChange:he,isControlledViewport:!!we,children:d.jsxs(Mue,{children:[d.jsx(Aue,{edgeTypes:t,onEdgeClick:s,onEdgeDoubleClick:o,onReconnect:Qe,onReconnectStart:ht,onReconnectEnd:it,onlyRenderVisibleElements:I,onEdgeContextMenu:_e,onEdgeMouseEnter:ze,onEdgeMouseMove:fe,onEdgeMouseLeave:Se,reconnectRadius:Re,defaultMarkerColor:z,noPanClassName:wt,disableKeyboardA11y:Te,rfId:ne}),d.jsx(Bue,{style:w,type:x,component:E,containerStyle:v}),d.jsx("div",{className:"react-flow__edgelabel-renderer"}),d.jsx(due,{nodeTypes:e,onNodeClick:i,onNodeDoubleClick:a,onNodeMouseEnter:c,onNodeMouseMove:u,onNodeMouseLeave:f,onNodeContextMenu:m,nodeClickDistance:ye,onlyRenderVisibleElements:I,noPanClassName:wt,noDragClassName:Bt,disableKeyboardA11y:Te,nodeExtent:ct,rfId:ne}),d.jsx("div",{className:"react-flow__viewport-portal"})]})})}DP.displayName="GraphView";const $ue=C.memo(DP),que=MI(),EA=({nodes:e,edges:t,defaultNodes:n,defaultEdges:i,width:s,height:a,fitView:o,fitViewOptions:c,minZoom:u=.5,maxZoom:f=2,nodeOrigin:m,nodeExtent:p,zIndexMode:y="basic"}={})=>{const b=new Map,x=new Map,w=new Map,E=new Map,v=i??t??[],_=n??e??[],k=m??[0,0],T=p??Kd;HI(w,E,v);const{nodesInitialized:A}=kv(_,b,x,{nodeOrigin:k,nodeExtent:T,zIndexMode:y});let j=[0,0,1];if(o&&s&&a){const M=kf(b,{filter:U=>!!((U.width||U.initialWidth)&&(U.height||U.initialHeight))}),{x:D,y:I,zoom:P}=Sw(M,s,a,u,f,(c==null?void 0:c.padding)??.1);j=[D,I,P]}return{rfId:"1",width:s??0,height:a??0,transform:j,nodes:_,nodesInitialized:A,nodeLookup:b,parentLookup:x,edges:v,edgeLookup:E,connectionLookup:w,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:i!==void 0,panZoom:null,minZoom:u,maxZoom:f,translateExtent:Kd,nodeExtent:T,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:Uc.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:k,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:{...kI},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:que,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:SI,zIndexMode:y,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},Hue=({nodes:e,edges:t,defaultNodes:n,defaultEdges:i,width:s,height:a,fitView:o,fitViewOptions:c,minZoom:u,maxZoom:f,nodeOrigin:m,nodeExtent:p,zIndexMode:y})=>ice((b,x)=>{async function w(){const{nodeLookup:E,panZoom:v,fitViewOptions:_,fitViewResolver:k,width:T,height:A,minZoom:j,maxZoom:M}=x();v&&(await Joe({nodes:E,width:T,height:A,panZoom:v,minZoom:j,maxZoom:M},_),k==null||k.resolve(!0),b({fitViewResolver:null}))}return{...EA({nodes:e,edges:t,width:s,height:a,fitView:o,fitViewOptions:c,minZoom:u,maxZoom:f,nodeOrigin:m,nodeExtent:p,defaultNodes:n,defaultEdges:i,zIndexMode:y}),setNodes:E=>{const{nodeLookup:v,parentLookup:_,nodeOrigin:k,elevateNodesOnSelect:T,fitViewQueued:A,zIndexMode:j,nodesSelectionActive:M}=x(),{nodesInitialized:D,hasSelectedNodes:I}=kv(E,v,_,{nodeOrigin:k,nodeExtent:p,elevateNodesOnSelect:T,checkEquality:!0,zIndexMode:j}),P=M&&I;A&&D?(w(),b({nodes:E,nodesInitialized:D,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:P})):b({nodes:E,nodesInitialized:D,nodesSelectionActive:P})},setEdges:E=>{const{connectionLookup:v,edgeLookup:_}=x();HI(v,_,E),b({edges:E})},setDefaultNodesAndEdges:(E,v)=>{if(E){const{setNodes:_}=x();_(E),b({hasDefaultNodes:!0})}if(v){const{setEdges:_}=x();_(v),b({hasDefaultEdges:!0})}},updateNodeInternals:E=>{const{triggerNodeChanges:v,nodeLookup:_,parentLookup:k,domNode:T,nodeOrigin:A,nodeExtent:j,debug:M,fitViewQueued:D,zIndexMode:I}=x(),{changes:P,updatedInternals:U}=Ele(E,_,k,T,A,j,I);U&&(ble(_,k,{nodeOrigin:A,nodeExtent:j,zIndexMode:I}),D?(w(),b({fitViewQueued:!1,fitViewOptions:void 0})):b({}),(P==null?void 0:P.length)>0&&(M&&console.log("React Flow: trigger node changes",P),v==null||v(P)))},updateNodePositions:(E,v=!1)=>{const _=[];let k=[];const{nodeLookup:T,triggerNodeChanges:A,connection:j,updateConnection:M,onNodesChangeMiddlewareMap:D}=x();for(const[I,P]of E){const U=T.get(I),q=!!(U!=null&&U.expandParent&&(U!=null&&U.parentId)&&(P!=null&&P.position)),V={id:I,type:"position",position:q?{x:Math.max(0,P.position.x),y:Math.max(0,P.position.y)}:P.position,dragging:v};if(U&&j.inProgress&&j.fromNode.id===U.id){const O=dl(U,j.fromHandle,Je.Left,!0);M({...j,from:O})}q&&U.parentId&&_.push({id:I,parentId:U.parentId,rect:{...P.internals.positionAbsolute,width:P.measured.width??0,height:P.measured.height??0}}),k.push(V)}if(_.length>0){const{parentLookup:I,nodeOrigin:P}=x(),U=Aw(_,T,I,P);k.push(...U)}for(const I of D.values())k=I(k);A(k)},triggerNodeChanges:E=>{const{onNodesChange:v,setNodes:_,nodes:k,hasDefaultNodes:T,debug:A}=x();if(E!=null&&E.length){if(T){const j=rP(E,k);_(j)}A&&console.log("React Flow: trigger node changes",E),v==null||v(E)}},triggerEdgeChanges:E=>{const{onEdgesChange:v,setEdges:_,edges:k,hasDefaultEdges:T,debug:A}=x();if(E!=null&&E.length){if(T){const j=aP(E,k);_(j)}A&&console.log("React Flow: trigger edge changes",E),v==null||v(E)}},addSelectedNodes:E=>{const{multiSelectionActive:v,edgeLookup:_,nodeLookup:k,triggerNodeChanges:T,triggerEdgeChanges:A}=x();if(v){const j=E.map(M=>Do(M,!0));T(j);return}T(dc(k,new Set([...E]),!0)),A(dc(_))},addSelectedEdges:E=>{const{multiSelectionActive:v,edgeLookup:_,nodeLookup:k,triggerNodeChanges:T,triggerEdgeChanges:A}=x();if(v){const j=E.map(M=>Do(M,!0));A(j);return}A(dc(_,new Set([...E]))),T(dc(k,new Set,!0))},unselectNodesAndEdges:({nodes:E,edges:v}={})=>{const{edges:_,nodes:k,nodeLookup:T,triggerNodeChanges:A,triggerEdgeChanges:j}=x(),M=E||k,D=v||_,I=[];for(const U of M){if(!U.selected)continue;const q=T.get(U.id);q&&(q.selected=!1),I.push(Do(U.id,!1))}const P=[];for(const U of D)U.selected&&P.push(Do(U.id,!1));A(I),j(P)},setMinZoom:E=>{const{panZoom:v,maxZoom:_}=x();v==null||v.setScaleExtent([E,_]),b({minZoom:E})},setMaxZoom:E=>{const{panZoom:v,minZoom:_}=x();v==null||v.setScaleExtent([_,E]),b({maxZoom:E})},setTranslateExtent:E=>{var v;(v=x().panZoom)==null||v.setTranslateExtent(E),b({translateExtent:E})},resetSelectedElements:()=>{const{edges:E,nodes:v,triggerNodeChanges:_,triggerEdgeChanges:k,elementsSelectable:T}=x();if(!T)return;const A=v.reduce((M,D)=>D.selected?[...M,Do(D.id,!1)]:M,[]),j=E.reduce((M,D)=>D.selected?[...M,Do(D.id,!1)]:M,[]);_(A),k(j)},setNodeExtent:E=>{const{nodes:v,nodeLookup:_,parentLookup:k,nodeOrigin:T,elevateNodesOnSelect:A,nodeExtent:j,zIndexMode:M}=x();E[0][0]===j[0][0]&&E[0][1]===j[0][1]&&E[1][0]===j[1][0]&&E[1][1]===j[1][1]||(kv(v,_,k,{nodeOrigin:T,nodeExtent:E,elevateNodesOnSelect:A,checkEquality:!1,zIndexMode:M}),b({nodeExtent:E}))},panBy:E=>{const{transform:v,width:_,height:k,panZoom:T,translateExtent:A}=x();return Sle({delta:E,panZoom:T,transform:v,translateExtent:A,width:_,height:k})},setCenter:async(E,v,_)=>{const{width:k,height:T,maxZoom:A,panZoom:j}=x();if(!j)return!1;const M=typeof(_==null?void 0:_.zoom)<"u"?_.zoom:A;return await j.setViewport({x:k/2-E*M,y:T/2-v*M,zoom:M},{duration:_==null?void 0:_.duration,ease:_==null?void 0:_.ease,interpolate:_==null?void 0:_.interpolate}),!0},cancelConnection:()=>{b({connection:{...kI}})},updateConnection:E=>{b({connection:E})},reset:()=>b({...EA()})}},Object.is);function OP({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:i,initialWidth:s,initialHeight:a,initialMinZoom:o,initialMaxZoom:c,initialFitViewOptions:u,fitView:f,nodeOrigin:m,nodeExtent:p,zIndexMode:y,children:b}){const[x]=C.useState(()=>Hue({nodes:e,edges:t,defaultNodes:n,defaultEdges:i,width:s,height:a,fitView:f,minZoom:o,maxZoom:c,fitViewOptions:u,nodeOrigin:m,nodeExtent:p,zIndexMode:y}));return d.jsx(sce,{value:x,children:d.jsx(Tce,{children:d.jsx(qce,{children:b})})})}function Vue({children:e,nodes:t,edges:n,defaultNodes:i,defaultEdges:s,width:a,height:o,fitView:c,fitViewOptions:u,minZoom:f,maxZoom:m,nodeOrigin:p,nodeExtent:y,zIndexMode:b}){return C.useContext(pg)?d.jsx(d.Fragment,{children:e}):d.jsx(OP,{initialNodes:t,initialEdges:n,defaultNodes:i,defaultEdges:s,initialWidth:a,initialHeight:o,fitView:c,initialFitViewOptions:u,initialMinZoom:f,initialMaxZoom:m,nodeOrigin:p,nodeExtent:y,zIndexMode:b,children:e})}const Kue={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function Gue({nodes:e,edges:t,defaultNodes:n,defaultEdges:i,className:s,nodeTypes:a,edgeTypes:o,onNodeClick:c,onEdgeClick:u,onInit:f,onMove:m,onMoveStart:p,onMoveEnd:y,onConnect:b,onConnectStart:x,onConnectEnd:w,onClickConnectStart:E,onClickConnectEnd:v,onNodeMouseEnter:_,onNodeMouseMove:k,onNodeMouseLeave:T,onNodeContextMenu:A,onNodeDoubleClick:j,onNodeDragStart:M,onNodeDrag:D,onNodeDragStop:I,onNodesDelete:P,onEdgesDelete:U,onDelete:q,onSelectionChange:V,onSelectionDragStart:O,onSelectionDrag:R,onSelectionDragStop:z,onSelectionContextMenu:G,onSelectionStart:X,onSelectionEnd:K,onBeforeDelete:B,connectionMode:F,connectionLineType:W=Fa.Bezier,connectionLineStyle:$,connectionLineComponent:ae,connectionLineContainerStyle:xe,deleteKeyCode:le="Backspace",selectionKeyCode:Ne="Shift",selectionOnDrag:re=!1,selectionMode:me=Gd.Full,panActivationKeyCode:se="Space",multiSelectionKeyCode:Q=Yd()?"Meta":"Control",zoomActivationKeyCode:ye=Yd()?"Meta":"Control",snapToGrid:_e,snapGrid:ze,onlyRenderVisibleElements:fe=!1,selectNodesOnDrag:Se,nodesDraggable:Re,autoPanOnNodeFocus:Qe,nodesConnectable:ht,nodesFocusable:it,nodeOrigin:Bt=iP,edgesFocusable:mt,edgesReconnectable:wt,elementsSelectable:Te=!0,defaultViewport:ct=yce,minZoom:ne=.5,maxZoom:we=2,translateExtent:he=Kd,preventScrolling:Ve=!0,nodeExtent:Ze,defaultMarkerColor:Ct="#b1b1b7",zoomOnScroll:Gt=!0,zoomOnPinch:ce=!0,panOnScroll:pe=!1,panOnScrollSpeed:Ce=.5,panOnScrollMode:je=Jo.Free,zoomOnDoubleClick:qe=!0,panOnDrag:st=!0,onPaneClick:Fe,onPaneMouseEnter:et,onPaneMouseMove:Qt,onPaneMouseLeave:Yn,onPaneScroll:Wt,onPaneContextMenu:Z,paneClickDistance:be=1,nodeClickDistance:Ie=0,children:ut,onReconnect:Yt,onReconnectStart:Tt,onReconnectEnd:$e,onEdgeContextMenu:Ue,onEdgeDoubleClick:ot,onEdgeMouseEnter:hn,onEdgeMouseMove:Zt,onEdgeMouseLeave:Vi,reconnectRadius:Ys=10,onNodesChange:Jn,onEdgesChange:kn,noDragClassName:mn="nodrag",noWheelClassName:An="nowheel",noPanClassName:Ti="nopan",fitView:Xs,fitViewOptions:wr,connectOnClick:Qs,attributionPosition:sa,proOptions:_s,defaultEdgeOptions:Zs,elevateNodesOnSelect:Bn=!0,elevateEdgesOnSelect:Ai=!1,disableKeyboardA11y:In=!1,autoPanOnConnect:ri,autoPanOnNodeDrag:bn,autoPanOnSelection:ra=!0,autoPanSpeed:xi,connectionRadius:hi,isValidConnection:Me,onError:Ge,style:xt,id:Rt,nodeDragThreshold:on,connectionDragThreshold:Un,viewport:ei,onViewportChange:ti,width:Vt,height:ai,colorMode:aa="light",debug:Cs,onScroll:os,ariaLabelConfig:Ts,zIndexMode:Er="basic",...Y},Ae){const Oe=Rt||"1",gt=wce(aa),pt=C.useCallback(ji=>{ji.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),os==null||os(ji)},[os]);return d.jsx("div",{"data-testid":"rf__wrapper",...Y,onScroll:pt,style:{...xt,...Kue},ref:Ae,className:Wn(["react-flow",s,gt]),id:Rt,role:"application",children:d.jsxs(Vue,{nodes:e,edges:t,width:Vt,height:ai,fitView:Xs,fitViewOptions:wr,minZoom:ne,maxZoom:we,nodeOrigin:Bt,nodeExtent:Ze,zIndexMode:Er,children:[d.jsx(vce,{nodes:e,edges:t,defaultNodes:n,defaultEdges:i,onConnect:b,onConnectStart:x,onConnectEnd:w,onClickConnectStart:E,onClickConnectEnd:v,nodesDraggable:Re,autoPanOnNodeFocus:Qe,nodesConnectable:ht,nodesFocusable:it,edgesFocusable:mt,edgesReconnectable:wt,elementsSelectable:Te,elevateNodesOnSelect:Bn,elevateEdgesOnSelect:Ai,minZoom:ne,maxZoom:we,nodeExtent:Ze,onNodesChange:Jn,onEdgesChange:kn,snapToGrid:_e,snapGrid:ze,connectionMode:F,translateExtent:he,connectOnClick:Qs,defaultEdgeOptions:Zs,fitView:Xs,fitViewOptions:wr,onNodesDelete:P,onEdgesDelete:U,onDelete:q,onNodeDragStart:M,onNodeDrag:D,onNodeDragStop:I,onSelectionDrag:R,onSelectionDragStart:O,onSelectionDragStop:z,onMove:m,onMoveStart:p,onMoveEnd:y,noPanClassName:Ti,nodeOrigin:Bt,rfId:Oe,autoPanOnConnect:ri,autoPanOnNodeDrag:bn,autoPanSpeed:xi,onError:Ge,connectionRadius:hi,isValidConnection:Me,selectNodesOnDrag:Se,nodeDragThreshold:on,connectionDragThreshold:Un,onBeforeDelete:B,debug:Cs,ariaLabelConfig:Ts,zIndexMode:Er}),d.jsx($ue,{onInit:f,onNodeClick:c,onEdgeClick:u,onNodeMouseEnter:_,onNodeMouseMove:k,onNodeMouseLeave:T,onNodeContextMenu:A,onNodeDoubleClick:j,nodeTypes:a,edgeTypes:o,connectionLineType:W,connectionLineStyle:$,connectionLineComponent:ae,connectionLineContainerStyle:xe,selectionKeyCode:Ne,selectionOnDrag:re,selectionMode:me,deleteKeyCode:le,multiSelectionKeyCode:Q,panActivationKeyCode:se,zoomActivationKeyCode:ye,onlyRenderVisibleElements:fe,defaultViewport:ct,translateExtent:he,minZoom:ne,maxZoom:we,preventScrolling:Ve,zoomOnScroll:Gt,zoomOnPinch:ce,zoomOnDoubleClick:qe,panOnScroll:pe,panOnScrollSpeed:Ce,panOnScrollMode:je,panOnDrag:st,autoPanOnSelection:ra,onPaneClick:Fe,onPaneMouseEnter:et,onPaneMouseMove:Qt,onPaneMouseLeave:Yn,onPaneScroll:Wt,onPaneContextMenu:Z,paneClickDistance:be,nodeClickDistance:Ie,onSelectionContextMenu:G,onSelectionStart:X,onSelectionEnd:K,onReconnect:Yt,onReconnectStart:Tt,onReconnectEnd:$e,onEdgeContextMenu:Ue,onEdgeDoubleClick:ot,onEdgeMouseEnter:hn,onEdgeMouseMove:Zt,onEdgeMouseLeave:Vi,reconnectRadius:Ys,defaultMarkerColor:Ct,noDragClassName:mn,noWheelClassName:An,noPanClassName:Ti,rfId:Oe,disableKeyboardA11y:In,nodeExtent:Ze,viewport:ei,onViewportChange:ti}),d.jsx(gce,{onSelectionChange:V}),ut,d.jsx(dce,{proOptions:_s,position:sa}),d.jsx(uce,{rfId:Oe,disableKeyboardA11y:In})]})})}var Wue=cP(Gue);function Yue(e){const[t,n]=C.useState(e),i=C.useCallback(s=>n(a=>rP(s,a)),[]);return[t,n,i]}function Xue(e){const[t,n]=C.useState(e),i=C.useCallback(s=>n(a=>aP(s,a)),[]);return[t,n,i]}function Que({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 Zue({radius:e,className:t}){return d.jsx("circle",{cx:e,cy:e,r:e,className:Wn(["react-flow__background-pattern","dots",t])})}var Qr;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(Qr||(Qr={}));const Jue={[Qr.Dots]:1,[Qr.Lines]:1,[Qr.Cross]:6},ede=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function LP({id:e,variant:t=Qr.Dots,gap:n=20,size:i,lineWidth:s=1,offset:a=0,color:o,bgColor:c,style:u,className:f,patternClassName:m}){const p=C.useRef(null),{transform:y,patternId:b}=Ft(ede,En),x=i||Jue[t],w=t===Qr.Dots,E=t===Qr.Cross,v=Array.isArray(n)?n:[n,n],_=[v[0]*y[2]||1,v[1]*y[2]||1],k=x*y[2],T=Array.isArray(a)?a:[a,a],A=E?[k,k]:_,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,...yg,"--xy-background-color-props":c,"--xy-background-pattern-color-props":o},ref:p,"data-testid":"rf__background",children:[d.jsx("pattern",{id:M,x:y[0]%_[0],y:y[1]%_[1],width:_[0],height:_[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${j[0]},-${j[1]})`,children:w?d.jsx(Zue,{radius:k/2,className:m}):d.jsx(Que,{dimensions:A,lineWidth:s,variant:t,className:m})}),d.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${M})`})]})}LP.displayName="Background";const tde=C.memo(LP);function nde(){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 ide(){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 sde(){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 rde(){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 ade(){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 md({children:e,className:t,...n}){return d.jsx("button",{type:"button",className:Wn(["react-flow__controls-button",t]),...n,children:e})}const ode=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function IP({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:i=!0,fitViewOptions:s,onZoomIn:a,onZoomOut:o,onFitView:c,onInteractiveChange:u,className:f,children:m,position:p="bottom-left",orientation:y="vertical","aria-label":b}){const x=Sn(),{isInteractive:w,minZoomReached:E,maxZoomReached:v,ariaLabelConfig:_}=Ft(ode,En),{zoomIn:k,zoomOut:T,fitView:A}=gg(),j=()=>{k(),a==null||a()},M=()=>{T(),o==null||o()},D=()=>{A(s),c==null||c()},I=()=>{x.setState({nodesDraggable:!w,nodesConnectable:!w,elementsSelectable:!w}),u==null||u(!w)},P=y==="horizontal"?"horizontal":"vertical";return d.jsxs(mg,{className:Wn(["react-flow__controls",P,f]),position:p,style:e,"data-testid":"rf__controls","aria-label":b??_["controls.ariaLabel"],children:[t&&d.jsxs(d.Fragment,{children:[d.jsx(md,{onClick:j,className:"react-flow__controls-zoomin",title:_["controls.zoomIn.ariaLabel"],"aria-label":_["controls.zoomIn.ariaLabel"],disabled:v,children:d.jsx(nde,{})}),d.jsx(md,{onClick:M,className:"react-flow__controls-zoomout",title:_["controls.zoomOut.ariaLabel"],"aria-label":_["controls.zoomOut.ariaLabel"],disabled:E,children:d.jsx(ide,{})})]}),n&&d.jsx(md,{className:"react-flow__controls-fitview",onClick:D,title:_["controls.fitView.ariaLabel"],"aria-label":_["controls.fitView.ariaLabel"],children:d.jsx(sde,{})}),i&&d.jsx(md,{className:"react-flow__controls-interactive",onClick:I,title:_["controls.interactive.ariaLabel"],"aria-label":_["controls.interactive.ariaLabel"],children:w?d.jsx(ade,{}):d.jsx(rde,{})}),m]})}IP.displayName="Controls";const lde=C.memo(IP);function cde({id:e,x:t,y:n,width:i,height:s,style:a,color:o,strokeColor:c,strokeWidth:u,className:f,borderRadius:m,shapeRendering:p,selected:y,onClick:b}){const{background:x,backgroundColor:w}=a||{},E=o||x||w;return d.jsx("rect",{className:Wn(["react-flow__minimap-node",{selected:y},f]),x:t,y:n,rx:m,ry:m,width:i,height:s,style:{fill:E,stroke:c,strokeWidth:u},shapeRendering:p,onClick:b?v=>b(v,e):void 0})}const ude=C.memo(cde),dde=e=>e.nodes.map(t=>t.id),Vx=e=>e instanceof Function?e:()=>e;function fde({nodeStrokeColor:e,nodeColor:t,nodeClassName:n="",nodeBorderRadius:i=5,nodeStrokeWidth:s,nodeComponent:a=ude,onClick:o}){const c=Ft(dde,En),u=Vx(t),f=Vx(e),m=Vx(n),p=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return d.jsx(d.Fragment,{children:c.map(y=>d.jsx(pde,{id:y,nodeColorFunc:u,nodeStrokeColorFunc:f,nodeClassNameFunc:m,nodeBorderRadius:i,nodeStrokeWidth:s,NodeComponent:a,onClick:o,shapeRendering:p},y))})}function hde({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:i,nodeBorderRadius:s,nodeStrokeWidth:a,shapeRendering:o,NodeComponent:c,onClick:u}){const{node:f,x:m,y:p,width:y,height:b}=Ft(x=>{const w=x.nodeLookup.get(e);if(!w)return{node:void 0,x:0,y:0,width:0,height:0};const E=w.internals.userNode,{x:v,y:_}=w.internals.positionAbsolute,{width:k,height:T}=ia(E);return{node:E,x:v,y:_,width:k,height:T}},En);return!f||f.hidden||!RI(f)?null:d.jsx(c,{x:m,y:p,width:y,height:b,style:f.style,selected:!!f.selected,className:i(f),color:t(f),borderRadius:s,strokeColor:n(f),strokeWidth:a,shapeRendering:o,onClick:u,id:f.id})}const pde=C.memo(hde);var mde=C.memo(fde);const gde=200,yde=150,bde=e=>!e.hidden,xde=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?AI(kf(e.nodeLookup,{filter:bde}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},vde="react-flow__minimap-desc";function PP({style:e,className:t,nodeStrokeColor:n,nodeColor:i,nodeClassName:s="",nodeBorderRadius:a=5,nodeStrokeWidth:o,nodeComponent:c,bgColor:u,maskColor:f,maskStrokeColor:m,maskStrokeWidth:p,position:y="bottom-right",onClick:b,onNodeClick:x,pannable:w=!1,zoomable:E=!1,ariaLabel:v,inversePan:_,zoomStep:k=1,offsetScale:T=5}){const A=Sn(),j=C.useRef(null),{boundingRect:M,viewBB:D,rfId:I,panZoom:P,translateExtent:U,flowWidth:q,flowHeight:V,ariaLabelConfig:O}=Ft(xde,En),R=(e==null?void 0:e.width)??gde,z=(e==null?void 0:e.height)??yde,G=M.width/R,X=M.height/z,K=Math.max(G,X),B=K*R,F=K*z,W=T*K,$=M.x-(B-M.width)/2-W,ae=M.y-(F-M.height)/2-W,xe=B+W*2,le=F+W*2,Ne=`${vde}-${I}`,re=C.useRef(0),me=C.useRef();re.current=K,C.useEffect(()=>{if(j.current&&P)return me.current=Rle({domNode:j.current,panZoom:P,getTransform:()=>A.getState().transform,getViewScale:()=>re.current}),()=>{var _e;(_e=me.current)==null||_e.destroy()}},[P]),C.useEffect(()=>{var _e;(_e=me.current)==null||_e.update({translateExtent:U,width:q,height:V,inversePan:_,pannable:w,zoomStep:k,zoomable:E})},[w,E,_,k,U,q,V]);const se=b?_e=>{var Se;const[ze,fe]=((Se=me.current)==null?void 0:Se.pointer(_e))||[0,0];b(_e,{x:ze,y:fe})}:void 0,Q=x?C.useCallback((_e,ze)=>{const fe=A.getState().nodeLookup.get(ze).internals.userNode;x(_e,fe)},[]):void 0,ye=v??O["minimap.ariaLabel"];return d.jsx(mg,{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 m=="string"?m:void 0,"--xy-minimap-mask-stroke-width-props":typeof p=="number"?p*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:R,height:z,viewBox:`${$} ${ae} ${xe} ${le}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":Ne,ref:j,onClick:se,children:[ye&&d.jsx("title",{id:Ne,children:ye}),d.jsx(mde,{onClick:Q,nodeColor:i,nodeStrokeColor:n,nodeBorderRadius:a,nodeClassName:s,nodeStrokeWidth:o,nodeComponent:c}),d.jsx("path",{className:"react-flow__minimap-mask",d:`M${$-W},${ae-W}h${xe+W*2}v${le+W*2}h${-xe-W*2}z
853
853
  M${D.x},${D.y}h${D.width}v${D.height}h${-D.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}PP.displayName="MiniMap";C.memo(PP);const wde=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,Ede={[qc.Line]:"right",[qc.Handle]:"bottom-right"};function Sde({nodeId:e,position:t,variant:n=qc.Handle,className:i,style:s=void 0,children:a,color:o,minWidth:c=10,minHeight:u=10,maxWidth:f=Number.MAX_VALUE,maxHeight:m=Number.MAX_VALUE,keepAspectRatio:p=!1,resizeDirection:y,autoScale:b=!0,shouldResize:x,onResizeStart:w,onResize:E,onResizeEnd:v}){const _=hP(),k=typeof e=="string"?e:_,T=Sn(),A=C.useRef(null),j=n===qc.Handle,M=Ft(C.useCallback(wde(j&&b),[j,b]),En),D=C.useRef(null),I=t??Ede[n];C.useEffect(()=>{if(!(!A.current||!k))return D.current||(D.current=Vle({domNode:A.current,nodeId:k,getStoreItems:()=>{const{nodeLookup:U,transform:q,snapGrid:V,snapToGrid:O,nodeOrigin:R,domNode:z}=T.getState();return{nodeLookup:U,transform:q,snapGrid:V,snapToGrid:O,nodeOrigin:R,paneDomNode:z}},onChange:(U,q)=>{const{triggerNodeChanges:V,nodeLookup:O,parentLookup:R,nodeOrigin:z}=T.getState(),G=[],X={x:U.x,y:U.y},K=O.get(k);if(K&&K.expandParent&&K.parentId){const B=K.origin??z,F=U.width??K.measured.width??0,W=U.height??K.measured.height??0,$={id:K.id,parentId:K.parentId,rect:{width:F,height:W,...DI({x:U.x??K.position.x,y:U.y??K.position.y},{width:F,height:W},K.parentId,O,B)}},ae=Aw([$],O,R,z);G.push(...ae),X.x=U.x?Math.max(B[0]*F,U.x):void 0,X.y=U.y?Math.max(B[1]*W,U.y):void 0}if(X.x!==void 0&&X.y!==void 0){const B={id:k,type:"position",position:{...X}};G.push(B)}if(U.width!==void 0&&U.height!==void 0){const F={id:k,type:"dimensions",resizing:!0,setAttributes:y?y==="horizontal"?"width":"height":!0,dimensions:{width:U.width,height:U.height}};G.push(F)}for(const B of q){const F={...B,type:"position"};G.push(F)}V(G)},onEnd:({width:U,height:q})=>{const V={id:k,type:"dimensions",resizing:!1,dimensions:{width:U,height:q}};T.getState().triggerNodeChanges([V])}})),D.current.update({controlPosition:I,boundaries:{minWidth:c,minHeight:u,maxWidth:f,maxHeight:m},keepAspectRatio:p,resizeDirection:y,onResizeStart:w,onResize:E,onResizeEnd:v,shouldResize:x}),()=>{var U;(U=D.current)==null||U.destroy()}},[I,c,u,f,m,p,w,E,v,x]);const P=I.split("-");return d.jsx("div",{className:Wn(["react-flow__resize-control","nodrag",...P,n,i]),ref:A,style:{...s,scale:M,...o&&{[j?"backgroundColor":"borderColor"]:o}},children:a})}C.memo(Sde);function kde(e){return _t(`/api/projects/${encodeURIComponent(e)}/flow`)}function Nde(e,t){return Rm(`/api/projects/${encodeURIComponent(e)}/flow`,t)}const Cv={done:"var(--color-running)",doing:"var(--color-running)",todo:"var(--color-text-subtle)",stuck:"var(--color-crashed)"},SA=["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 _de(e){let t=0;for(let n=0;n<e.length;n+=1)t=t*31+e.charCodeAt(n)>>>0;return SA[t%SA.length]}const yp={width:9,height:9,background:"var(--color-bg)",border:"1px solid var(--color-border-light)"},Cde=C.memo(function({id:t,data:n,selected:i}){const s=n,a=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(Za,{id:"l",type:"target",position:Je.Left,style:yp}),d.jsx(Za,{id:"t",type:"target",position:Je.Top,style:yp}),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:_de(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:Cv.doing}}),d.jsx("span",{className:"relative w-2.5 h-2.5 rounded-full",style:{background:Cv[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||"任务"}),a.length>0&&d.jsx("div",{className:"flex flex-wrap gap-1 mt-2 max-h-[46px] overflow-hidden",children:a.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(Za,{id:"r",type:"source",position:Je.Right,style:yp}),d.jsx(Za,{id:"b",type:"source",position:Je.Bottom,style:yp})]})});function Tde(e){if(!e)return"";const t=e.split(`
854
854
  `),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(`
855
- `).trim()}function Ade(e,t){return t.includes("NEEDS-FIX")?"stuck":e==="Done"?"done":e==="Inprogress"?"doing":"todo"}function jde({project:e,seq:t,onClose:n,onChanged:i,onDelete:s}){var V;const a=Xe(),[o,c]=C.useState(!0),[u,f]=C.useState(!1),[m,p]=C.useState(""),[y,b]=C.useState(""),[x,w]=C.useState(new Set),[E,v]=C.useState(""),[_,k]=C.useState("todo"),[T,A]=C.useState(null),[j,M]=C.useState(""),D=at({queryKey:["skills-all",e],queryFn:()=>ig(e)}),I=((V=D.data)==null?void 0:V.data)??[];C.useEffect(()=>{const O=R=>{R.key==="Escape"&&n()};return window.addEventListener("keydown",O),()=>window.removeEventListener("keydown",O)},[n]),C.useEffect(()=>{let O=!1;return c(!0),RL(e,t).then(R=>{O||(p(R.title),w(new Set(R.skills??[])),b(Tde(R.body)),v(R.state),k(Ade(R.state,R.labels??[])),A(typeof R.order=="number"?R.order:null))}).catch(()=>{}).finally(()=>{O||c(!1)}),()=>{O=!0}},[e,t]);const P=O=>{w(R=>{const z=new Set(R);return z.has(O)?z.delete(O):z.add(O),z})},U=async()=>{M(""),f(!0);try{await gm(e,t,{title:m.trim()||a("flow.node.default"),description:y,skills:[...x]}),i(),n()}catch(O){M(O instanceof Error?O.message:String(O)),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:O=>O.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]}),E&&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:Cv[_]??"gray"}}),E]}),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:a("flow.lane.orderTip"),children:a("flow.lane.wave",{n:T})})]}),d.jsx("button",{onClick:n,className:"nb-btn nb-btn-mint p-2 flex-shrink-0","aria-label":a("flow.node.close"),type:"button",children:d.jsx(vn,{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(lt,{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:a("flow.node.title")}),d.jsx("input",{className:"nb-input w-full text-base font-semibold",value:m,onChange:O=>p(O.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:a("flow.node.desc")}),d.jsx("textarea",{className:"nb-input w-full flex-1 min-h-0",style:{minHeight:200,resize:"vertical"},value:y,onChange:O=>b(O.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:a("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(lt,{size:14,className:"animate-spin text-[var(--color-text-muted)]"}),I.length>0&&d.jsx("div",{className:"flex flex-wrap gap-2",children:I.map(O=>{const R=x.has(O.name);return d.jsx("button",{type:"button",onClick:()=>P(O.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",R?"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":R,children:O.name},O.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(qi,{size:14,strokeWidth:2.4})," ",a("flow.node.delete")]}),d.jsxs("button",{type:"button",className:"nb-btn nb-btn-cta",onClick:()=>void U(),disabled:u,children:[u?d.jsx(lt,{size:14,className:"animate-spin"}):null,a("flow.node.save")]})]})]})]})})}const Mde=C.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 Rde(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 Dde={task:Cde,waveBox:Mde},kA="sps.flow.lastProject",NA="sps.flow.mode";function _A(e){return(e.labels??[]).includes("NEEDS-FIX")?"stuck":e.state==="Done"?"done":e.state==="Inprogress"?"doing":"todo"}function Ode(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 el=260,tl=158,Tm=28,bp=el+120,Kx=tl+28,CA=16,TA=44,xp=60,Gx=100,AA=["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 od(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 Lde(e,t){return Math.abs(e.x-t.x)<el+Tm&&Math.abs(e.y-t.y)<tl+Tm}function Ide(e){for(let t=0;t<80;t+=1)for(let n=0;n<8;n+=1){const i={x:60+n*(el+Tm),y:60+t*(tl+Tm)};if(!e.some(s=>Lde(i,s)))return i}return{x:60,y:60}}function jA(e){return{x:e.position.x+el/2,y:e.position.y+tl/2}}function Pde(e,t,n){const i=n.x-t.x,s=n.y-t.y,a=i*i+s*s;if(a===0)return Math.hypot(e.x-t.x,e.y-t.y);let o=((e.x-t.x)*i+(e.y-t.y)*s)/a;return o=Math.max(0,Math.min(1,o)),Math.hypot(e.x-(t.x+o*i),e.y-(t.y+o*s))}function zde(){var Ve,Ze,Ct,Gt;const e=Xe(),t=tn(),n=fl(),{confirm:i}=Ln(),{screenToFlowPosition:s,fitView:a}=gg(),o=C.useRef([]),[c,u]=C.useState(()=>localStorage.getItem(kA)??""),[f,m]=C.useState(()=>localStorage.getItem(NA)==="lanes"?"lanes":"free"),[p,y]=C.useState(!1),[b,x,w]=Yue([]),[E,v,_]=Xue([]),[k,T]=C.useState(null),[A,j]=C.useState(null),[M,D]=C.useState(!1),[I,P]=C.useState(""),[U,q]=C.useState(null),[V,O]=C.useState(null),[R,z]=C.useState(0),G=C.useRef({}),X=C.useRef(E);X.current=E;const K=C.useRef(b);K.current=b;const B=C.useRef(null),F=C.useRef(null),W=C.useRef(new Set),$=C.useRef(""),ae=C.useRef(null);LL(c||null);const xe=at({queryKey:["cards",c],queryFn:()=>ML(c),enabled:!!c,refetchInterval:3e3}),le=((Ve=xe.data)==null?void 0:Ve.data)??[],re=((Gt=(Ct=(Ze=at({queryKey:["projects"],queryFn:ro,refetchInterval:3e3}).data)==null?void 0:Ze.data)==null?void 0:Ct.find(ce=>ce.name===c))==null?void 0:Gt.pipelineStatus)==="running",me=C.useMemo(()=>{const ce={};for(const pe of le)ce[String(pe.seq)]=_A(pe);return ce},[le]),se=C.useMemo(()=>{if(f!=="lanes")return[];const ce=od(le),pe=[];for(let Ce=1;Ce<ce.length;Ce+=1)for(const je of ce[Ce-1]??[])for(const qe of ce[Ce]??[])pe.push({id:`w${je.seq}-${qe.seq}`,source:String(je.seq),target:String(qe.seq),sourceHandle:"r",targetHandle:"l",animated:!1,selectable:!1,deletable:!1});return pe},[f,le]),Q=C.useMemo(()=>(f==="lanes"?se:E).map(ce=>{const pe=Ode(me[ce.target]);return ce.selected?{...ce,...pe,style:{...pe.style,strokeWidth:6}}:{...ce,...pe}}),[f,se,E,me]),ye=C.useCallback(()=>{t.invalidateQueries({queryKey:["cards",c]})},[t,c]),_e=C.useCallback(()=>{!c||B.current!==c||(ae.current&&clearTimeout(ae.current),ae.current=setTimeout(()=>{Nde(c,{positions:G.current,edges:X.current.map(ce=>({id:ce.id,source:ce.source,target:ce.target,sourceHandle:ce.sourceHandle??null,targetHandle:ce.targetHandle??null}))}).catch(()=>{})},600))},[c]);C.useEffect(()=>{if(B.current=null,T(null),O(null),G.current={},W.current=new Set,$.current="",x([]),v([]),!c)return;localStorage.setItem(kA,c);let ce=!1;return kde(c).then(pe=>{ce||(G.current=pe.positions??{},v((pe.edges??[]).map(Ce=>({id:Ce.id,source:Ce.source,target:Ce.target,sourceHandle:Ce.sourceHandle??void 0,targetHandle:Ce.targetHandle??void 0,animated:!1}))))}).catch(()=>{}).finally(()=>{ce||(B.current=c,z(pe=>pe+1))}),()=>{ce=!0}},[c,x,v]),C.useEffect(()=>{if(!c||B.current!==c)return;const ce=`${f}|`+le.map(Fe=>`${Fe.seq}:${Fe.title}:${Fe.state}:${Fe.order}:${(Fe.skills??[]).join("|")}`).join(",");if(ce===$.current)return;$.current=ce;const pe=Fe=>({seq:String(Fe.seq),title:Fe.title,skills:(Fe.skills??[]).join(", "),status:_A(Fe),label:Fe.title,desc:""});if(f==="lanes"){const Fe=od(le),et=Fe.map((Yn,Wt)=>({id:`wave-${Wt}`,type:"waveBox",position:{x:xp+Wt*bp-CA,y:Gx-TA},data:{label:e("flow.lane.wave",{n:Wt+1}),sub:Yn.length>1?e("flow.lane.parallel",{n:Yn.length}):"",color:AA[Wt%AA.length]},style:{width:el+CA*2,height:TA+(Yn.length-1)*Kx+tl+14},draggable:!1,selectable:!1,zIndex:0})),Qt=Fe.flatMap((Yn,Wt)=>Yn.map((Z,be)=>({id:String(Z.seq),type:"task",position:{x:xp+Wt*bp,y:Gx+be*Kx},deletable:!1,zIndex:1,data:pe(Z)})));x([...et,...Qt]);return}const Ce=new Map(K.current.map(Fe=>[Fe.id,Fe.position])),je=[];for(const Fe of le){const et=Ce.get(String(Fe.seq))??G.current[String(Fe.seq)];et&&je.push(et)}let qe=!1;const st=le.map(Fe=>{const et=String(Fe.seq);let Qt=Ce.get(et)??G.current[et];return Qt||(Qt=Ide(je),je.push(Qt),qe=!0),G.current[et]=Qt,{id:et,type:"task",position:Qt,deletable:!1,data:pe(Fe)}});x(st),qe&&_e()},[le,c,f,R,x,_e,e]),C.useEffect(()=>{if(B.current!==c)return;const ce=new Set(le.map(pe=>String(pe.seq)));v(pe=>{const Ce=pe.filter(je=>ce.has(je.source)&&ce.has(je.target));return Ce.length!==pe.length&&_e(),Ce.length===pe.length?pe:Ce})},[le,c,v,_e]),C.useEffect(()=>{if(!c||B.current!==c||f!=="free"||le.length<2)return;const ce=od(le),pe=[];for(let qe=1;qe<ce.length;qe+=1)for(const st of ce[qe-1]??[])for(const Fe of ce[qe]??[])pe.push({id:`seed-${st.seq}-${Fe.seq}`,source:String(st.seq),target:String(Fe.seq),sourceHandle:"r",targetHandle:"l",animated:!1});const Ce=X.current,je=F.current!==c;if(F.current=c,je&&Ce.length===0)pe.length>0&&(v(pe),_e());else{const qe=new Set;for(const et of Ce)qe.add(et.source),qe.add(et.target);const st=new Set(Ce.map(et=>`${et.source}->${et.target}`)),Fe=new Set(le.map(et=>String(et.seq)).filter(et=>!W.current.has(et)&&!qe.has(et)));if(Fe.size>0){const et=pe.filter(Qt=>(Fe.has(Qt.source)||Fe.has(Qt.target))&&!st.has(`${Qt.source}->${Qt.target}`));et.length>0&&(v([...Ce,...et]),_e())}}W.current=new Set(le.map(qe=>String(qe.seq)))},[le,c,f,R,v,_e]);const ze=C.useCallback(ce=>{if(w(ce),f!=="free")return;let pe=!1;for(const Ce of ce)Ce.type==="position"&&Ce.position&&(G.current[Ce.id]=Ce.position,pe=!0);pe&&_e()},[w,_e,f]),fe=C.useCallback(ce=>{f==="free"&&(v(pe=>lP({...ce,animated:!1},pe)),_e())},[v,_e,f]),Se=C.useCallback(()=>{if(f!=="free"||le.length===0)return;const ce=od(le),pe={},Ce=[];ce.forEach((je,qe)=>{if(je.forEach((st,Fe)=>{pe[String(st.seq)]={x:xp+qe*bp,y:Gx+Fe*Kx}}),qe>0)for(const st of ce[qe-1]??[])for(const Fe of je)Ce.push({id:`seed-${st.seq}-${Fe.seq}`,source:String(st.seq),target:String(Fe.seq),sourceHandle:"r",targetHandle:"l",animated:!1})}),G.current={...G.current,...pe},x(je=>je.map(qe=>pe[qe.id]?{...qe,position:pe[qe.id]}:qe)),v(Ce),_e(),setTimeout(()=>a({padding:.2,duration:300}),60)},[f,le,x,v,_e,a]),Re=C.useCallback(async ce=>{if(!await i({title:e("flow.confirm.deleteTitle"),body:e("flow.confirm.deleteBody",{seq:ce}),danger:!0,confirm:e("flow.node.delete")}))return;P("");const Ce=X.current.filter(je=>je.source===String(ce)||je.target===String(ce)).map(je=>({...je}));try{await DL(c,ce),o.current.push({seq:ce,edges:Ce})}catch(je){P(je instanceof Error?je.message:String(je))}finally{T(je=>je===ce?null:je),j(je=>je===ce?null:je),$.current="",z(je=>je+1),ye()}},[c,i,e,ye]),Qe=C.useCallback(async()=>{const ce=o.current.pop();if(ce){P("");try{await Ane(c,ce.seq),v(pe=>{const Ce=new Set(pe.map(je=>je.id));return[...pe,...ce.edges.filter(je=>!Ce.has(je.id))]}),_e(),ye()}catch(pe){P(pe instanceof Error?pe.message:String(pe))}}},[c,v,_e,ye]),ht=C.useCallback((ce,pe)=>{var st;if(f!=="free"||pe.isValid)return;const Ce=pe.fromNode;if(!Ce||!c)return;const je="changedTouches"in ce?ce.changedTouches[0]:ce;if(!je)return;const qe=s({x:je.clientX,y:je.clientY});q({fromId:Ce.id,fromHandle:((st=pe.fromHandle)==null?void 0:st.id)??null,clientX:je.clientX,clientY:je.clientY,flowX:qe.x,flowY:qe.y})},[f,c,s]),it=C.useCallback(async()=>{const ce=U;if(q(null),!(!ce||!c))try{const pe=await cv(c,{title:`${e("flow.node.default")} ${le.length+1}`,initialState:"Planning"}),Ce=Rde(pe);if(Ce==null)return;const je=String(Ce);G.current[je]={x:ce.flowX-el/2,y:ce.flowY-tl/2},v(qe=>[...qe,{id:`e-${ce.fromId}-${je}-drop`,source:ce.fromId,target:je,sourceHandle:ce.fromHandle??void 0,animated:!1}]),_e(),ye()}catch(pe){P(pe instanceof Error?pe.message:String(pe))}},[U,c,le.length,v,_e,e,ye]);C.useEffect(()=>{if(!U)return;const ce=pe=>{pe.key==="Escape"&&q(null)};return window.addEventListener("keydown",ce),()=>window.removeEventListener("keydown",ce)},[U]);const Bt=C.useCallback((ce,pe)=>{f==="free"&&(v(Ce=>kce(ce,pe,Ce)),_e())},[f,v,_e]);C.useEffect(()=>{const ce=pe=>{if(pe.key!=="Delete"&&pe.key!=="Backspace"||A!=null)return;const Ce=pe.target;Ce&&(Ce.tagName==="INPUT"||Ce.tagName==="TEXTAREA"||Ce.isContentEditable)||k!=null&&(pe.preventDefault(),Re(k))};return window.addEventListener("keydown",ce),()=>window.removeEventListener("keydown",ce)},[k,A,Re]),C.useEffect(()=>{const ce=pe=>{if(!(pe.metaKey||pe.ctrlKey)||pe.key!=="z"&&pe.key!=="Z"||A!=null)return;const Ce=pe.target;Ce&&(Ce.tagName==="INPUT"||Ce.tagName==="TEXTAREA"||Ce.isContentEditable)||(pe.preventDefault(),Qe())};return window.addEventListener("keydown",ce),()=>window.removeEventListener("keydown",ce)},[A,Qe]);const mt=C.useCallback(async ce=>{if(c){y(!0),P("");try{const pe=new Map(le.map(Ce=>[Ce.seq,Ce.order]));for(let Ce=0;Ce<ce.length;Ce+=1)for(const je of ce[Ce]??[])pe.get(je)!==Ce+1&&await gm(c,je,{order:Ce+1});ye()}catch(pe){P(pe instanceof Error?pe.message:String(pe))}finally{y(!1)}}},[c,le,ye]),wt=C.useCallback(ce=>{const pe=Number(ce.id);if(!Number.isInteger(pe))return;const Ce=od(le).map(Fe=>Fe.map(et=>et.seq)),je=(ce.position.x-xp)/bp,qe=Math.round(je),st=Ce.map(Fe=>Fe.filter(et=>et!==pe));if(qe>=0&&qe<Ce.length&&Math.abs(je-qe)<=.35)st[qe].push(pe);else{const Fe=Math.max(0,Math.min(st.length,Math.ceil(je)));st.splice(Fe,0,[pe])}mt(st.filter(Fe=>Fe.length>0)).finally(()=>{$.current="",z(Fe=>Fe+1)})},[le,mt]),Te=C.useCallback((ce,pe)=>{if(f==="lanes"){wt(pe);return}const Ce=new Map(K.current.map(et=>[et.id,et])),je={x:pe.position.x+el/2,y:pe.position.y+tl/2};let qe=null,st=40;for(const et of X.current){if(et.source===pe.id||et.target===pe.id)continue;const Qt=Ce.get(et.source),Yn=Ce.get(et.target);if(!Qt||!Yn)continue;const Wt=Pde(je,jA(Qt),jA(Yn));Wt<st&&(st=Wt,qe=et)}if(!qe)return;const Fe=qe;v(et=>[...et.filter(Qt=>Qt.id!==Fe.id),{id:`e-${Fe.source}-${pe.id}-${Fe.id}`,source:Fe.source,target:pe.id,animated:!1},{id:`e-${pe.id}-${Fe.target}-${Fe.id}`,source:pe.id,target:Fe.target,animated:!1}]),_e()},[f,wt,v,_e]),ct=C.useCallback(ce=>{m(ce),localStorage.setItem(NA,ce)},[]);C.useEffect(()=>{const ce=setTimeout(()=>{a({padding:.2,duration:300})},80);return()=>clearTimeout(ce)},[f,a]);const ne=async()=>{if(c){P("");try{await cv(c,{title:`${e("flow.node.default")} ${le.length+1}`,initialState:"Planning"}),ye()}catch(ce){P(ce instanceof Error?ce.message:String(ce))}}},we=async()=>{if(P(""),O(null),!c)return P(e("flow.err.noProject"));if(le.length===0)return P(e("flow.err.noNodes"));D(!0);try{const ce=le.filter(je=>je.state==="Planning"),pe=ce.length;let Ce=0;O({phase:"creating",made:Ce,total:pe});for(const je of ce)await gm(c,je.seq,{state:"Backlog",labels:Array.from(new Set([...je.labels??[],"AI-PIPELINE"]))}),Ce+=1,O({phase:"creating",made:Ce,total:pe});O({phase:"starting",made:Ce,total:pe}),await OL(c),ye(),O({phase:"done",made:Ce,total:pe})}catch(ce){P(ce instanceof Error?ce.message:String(ce))}finally{D(!1)}},he=xe.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(UN,{size:18,strokeWidth:2.4}),e("nav.arrange")]}),d.jsx(zL,{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:()=>ct("free"),children:[d.jsx(UN,{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:()=>ct("lanes"),children:[d.jsx(WB,{size:14,strokeWidth:2.4})," ",e("flow.mode.lanes")]})]}),he&&d.jsx(lt,{size:15,className:"animate-spin text-[var(--color-text-muted)]"}),d.jsxs("button",{type:"button",className:"nb-btn",onClick:()=>void ne(),disabled:!c||he,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 we(),disabled:M||re||he||!c,title:re?e("flow.pipelineRunning"):void 0,children:[M||re?d.jsx(lt,{size:15,className:"animate-spin"}):d.jsx(Mm,{size:15,strokeWidth:2.4}),e(M?"flow.running":re?"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")}),I&&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:I}),V&&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:[V.phase==="creating"&&d.jsxs("span",{children:[e("flow.status.creating")," ",V.made,"/",V.total,"…"]}),V.phase==="starting"&&d.jsx("span",{children:e("flow.status.starting")}),V.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(V.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(Wue,{nodes:b,edges:Q,nodeTypes:Dde,connectionRadius:160,nodesConnectable:f==="free",edgesReconnectable:f==="free",deleteKeyCode:A!=null?null:["Delete","Backspace"],onNodesChange:ze,onEdgesChange:ce=>{f==="free"&&(_(ce),_e())},onConnect:fe,onConnectEnd:ht,onReconnect:Bt,onNodeClick:(ce,pe)=>{const Ce=Number(pe.id);Number.isInteger(Ce)&&j(Ce)},onNodeDragStop:Te,onSelectionChange:({nodes:ce})=>{const pe=ce[0]?Number(ce[0].id):null;T(pe!=null&&Number.isInteger(pe)?pe:null)},fitView:!0,children:[d.jsx(tde,{variant:Qr.Dots,gap:18,size:1}),d.jsx(lde,{children:f==="free"&&d.jsx(md,{onClick:Se,title:e("flow.tidy"),"aria-label":e("flow.tidy"),children:d.jsx(Dj,{size:14,strokeWidth:2.4})})})]})}),U&&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:U.clientX,top:U.clientY},onClick:ce=>{ce.stopPropagation(),it()},children:[d.jsx(Gn,{size:14,strokeWidth:2.4})," ",e("flow.pending.create")]})}),p&&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(lt,{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(jde,{project:c,seq:A,onClose:()=>j(null),onChanged:ye,onDelete:ce=>void Re(ce)})]})}function Bde(){return d.jsx(OP,{children:d.jsx(zde,{})})}function Ude(){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(Mc,{to:"/",className:"nb-btn nb-btn-mint inline-flex",children:e("notFound.home")})]})}const Fde=C.lazy(()=>yB(()=>import("./ShowcasePage-lGZ30wQv.js"),__vite__mapDeps([0,1])));function $de(){return d.jsx(gF,{children:d.jsxs(L5,{children:[d.jsx(ii,{path:"/showcase",element:d.jsx(C.Suspense,{fallback:null,children:d.jsx(Fde,{})})}),d.jsxs(ii,{element:d.jsx(HN,{contentMode:"workspace"}),children:[d.jsx(ii,{index:!0,element:d.jsx(bx,{})}),d.jsx(ii,{path:"/projects",element:d.jsx(aT,{})}),d.jsx(ii,{path:"/projects/:name",element:d.jsx(aT,{})}),d.jsx(ii,{path:"/board",element:d.jsx(Xne,{})}),d.jsx(ii,{path:"/prompts",element:d.jsx(uie,{})}),d.jsx(ii,{path:"/chat",element:d.jsx(bx,{})}),d.jsx(ii,{path:"/chat/:sessionId",element:d.jsx(bx,{})}),d.jsx(ii,{path:"/arrange",element:d.jsx(Bde,{})})]}),d.jsxs(ii,{element:d.jsx(HN,{contentMode:"document"}),children:[d.jsx(ii,{path:"/projects/new",element:d.jsx(jL,{})}),d.jsx(ii,{path:"/skills",element:d.jsx(iie,{})}),d.jsx(ii,{path:"/system",element:d.jsx(Tie,{})}),d.jsx(ii,{path:"/memory",element:d.jsx(Uie,{})}),d.jsx(ii,{path:"/plugins",element:d.jsx(ise,{})}),d.jsx(ii,{path:"*",element:d.jsx(Ude,{})})]})]})})}mF();$6();const qde=new S4({defaultOptions:{queries:{staleTime:3e4,refetchOnWindowFocus:!1}}}),zP=document.getElementById("root");if(!zP)throw new Error("#root not found");Zz.createRoot(zP).render(d.jsx(C.StrictMode,{children:d.jsx(R6,{children:d.jsx(k4,{client:qde,children:d.jsx(aB,{children:d.jsx(zW,{children:d.jsx($de,{})})})})})}));export{kj as A,VB as C,Aj as E,Mc as L,Hv as P,f0 as S,_B as a,Pe as c,d as j,C as r,qj as u};
855
+ `).trim()}function Ade(e,t){return t.includes("NEEDS-FIX")?"stuck":e==="Done"?"done":e==="Inprogress"?"doing":"todo"}function jde({project:e,seq:t,onClose:n,onChanged:i,onDelete:s}){var V;const a=Xe(),[o,c]=C.useState(!0),[u,f]=C.useState(!1),[m,p]=C.useState(""),[y,b]=C.useState(""),[x,w]=C.useState(new Set),[E,v]=C.useState(""),[_,k]=C.useState("todo"),[T,A]=C.useState(null),[j,M]=C.useState(""),D=at({queryKey:["skills-all",e],queryFn:()=>ig(e)}),I=((V=D.data)==null?void 0:V.data)??[];C.useEffect(()=>{const O=R=>{R.key==="Escape"&&n()};return window.addEventListener("keydown",O),()=>window.removeEventListener("keydown",O)},[n]),C.useEffect(()=>{let O=!1;return c(!0),RL(e,t).then(R=>{O||(p(R.title),w(new Set(R.skills??[])),b(Tde(R.body)),v(R.state),k(Ade(R.state,R.labels??[])),A(typeof R.order=="number"?R.order:null))}).catch(()=>{}).finally(()=>{O||c(!1)}),()=>{O=!0}},[e,t]);const P=O=>{w(R=>{const z=new Set(R);return z.has(O)?z.delete(O):z.add(O),z})},U=async()=>{M(""),f(!0);try{await gm(e,t,{title:m.trim()||a("flow.node.default"),description:y,skills:[...x]}),i(),n()}catch(O){M(O instanceof Error?O.message:String(O)),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:O=>O.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]}),E&&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:Cv[_]??"gray"}}),E]}),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:a("flow.lane.orderTip"),children:a("flow.lane.wave",{n:T})})]}),d.jsx("button",{onClick:n,className:"nb-btn nb-btn-mint p-2 flex-shrink-0","aria-label":a("flow.node.close"),type:"button",children:d.jsx(vn,{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(lt,{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:a("flow.node.title")}),d.jsx("input",{className:"nb-input w-full text-base font-semibold",value:m,onChange:O=>p(O.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:a("flow.node.desc")}),d.jsx("textarea",{className:"nb-input w-full flex-1 min-h-0",style:{minHeight:200,resize:"vertical"},value:y,onChange:O=>b(O.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:a("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(lt,{size:14,className:"animate-spin text-[var(--color-text-muted)]"}),I.length>0&&d.jsx("div",{className:"flex flex-wrap gap-2",children:I.map(O=>{const R=x.has(O.name);return d.jsx("button",{type:"button",onClick:()=>P(O.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",R?"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":R,children:O.name},O.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(qi,{size:14,strokeWidth:2.4})," ",a("flow.node.delete")]}),d.jsxs("button",{type:"button",className:"nb-btn nb-btn-cta",onClick:()=>void U(),disabled:u,children:[u?d.jsx(lt,{size:14,className:"animate-spin"}):null,a("flow.node.save")]})]})]})]})})}const Mde=C.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 Rde(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 Dde={task:Cde,waveBox:Mde},kA="sps.flow.lastProject",NA="sps.flow.mode";function _A(e){return(e.labels??[]).includes("NEEDS-FIX")?"stuck":e.state==="Done"?"done":e.state==="Inprogress"?"doing":"todo"}function Ode(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 el=260,tl=158,Tm=28,bp=el+120,Kx=tl+28,CA=16,TA=44,xp=60,Gx=100,AA=["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 od(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 Lde(e,t){return Math.abs(e.x-t.x)<el+Tm&&Math.abs(e.y-t.y)<tl+Tm}function Ide(e){for(let t=0;t<80;t+=1)for(let n=0;n<8;n+=1){const i={x:60+n*(el+Tm),y:60+t*(tl+Tm)};if(!e.some(s=>Lde(i,s)))return i}return{x:60,y:60}}function jA(e){return{x:e.position.x+el/2,y:e.position.y+tl/2}}function Pde(e,t,n){const i=n.x-t.x,s=n.y-t.y,a=i*i+s*s;if(a===0)return Math.hypot(e.x-t.x,e.y-t.y);let o=((e.x-t.x)*i+(e.y-t.y)*s)/a;return o=Math.max(0,Math.min(1,o)),Math.hypot(e.x-(t.x+o*i),e.y-(t.y+o*s))}function zde(){var Ve,Ze,Ct,Gt;const e=Xe(),t=tn(),n=fl(),{confirm:i}=Ln(),{screenToFlowPosition:s,fitView:a}=gg(),o=C.useRef([]),[c,u]=C.useState(()=>localStorage.getItem(kA)??""),[f,m]=C.useState(()=>localStorage.getItem(NA)==="lanes"?"lanes":"free"),[p,y]=C.useState(!1),[b,x,w]=Yue([]),[E,v,_]=Xue([]),[k,T]=C.useState(null),[A,j]=C.useState(null),[M,D]=C.useState(!1),[I,P]=C.useState(""),[U,q]=C.useState(null),[V,O]=C.useState(null),[R,z]=C.useState(0),G=C.useRef({}),X=C.useRef(E);X.current=E;const K=C.useRef(b);K.current=b;const B=C.useRef(null),F=C.useRef(null),W=C.useRef(new Set),$=C.useRef(""),ae=C.useRef(null);LL(c||null);const xe=at({queryKey:["cards",c],queryFn:()=>ML(c),enabled:!!c,refetchInterval:3e3}),le=((Ve=xe.data)==null?void 0:Ve.data)??[],re=((Gt=(Ct=(Ze=at({queryKey:["projects"],queryFn:ro,refetchInterval:3e3}).data)==null?void 0:Ze.data)==null?void 0:Ct.find(ce=>ce.name===c))==null?void 0:Gt.pipelineStatus)==="running",me=C.useMemo(()=>{const ce={};for(const pe of le)ce[String(pe.seq)]=_A(pe);return ce},[le]),se=C.useMemo(()=>{if(f!=="lanes")return[];const ce=od(le),pe=[];for(let Ce=1;Ce<ce.length;Ce+=1)for(const je of ce[Ce-1]??[])for(const qe of ce[Ce]??[])pe.push({id:`w${je.seq}-${qe.seq}`,source:String(je.seq),target:String(qe.seq),sourceHandle:"r",targetHandle:"l",animated:!1,selectable:!1,deletable:!1});return pe},[f,le]),Q=C.useMemo(()=>(f==="lanes"?se:E).map(ce=>{const pe=Ode(me[ce.target]);return ce.selected?{...ce,...pe,style:{...pe.style,strokeWidth:6}}:{...ce,...pe}}),[f,se,E,me]),ye=C.useCallback(()=>{t.invalidateQueries({queryKey:["cards",c]})},[t,c]),_e=C.useCallback(()=>{!c||B.current!==c||(ae.current&&clearTimeout(ae.current),ae.current=setTimeout(()=>{Nde(c,{positions:G.current,edges:X.current.map(ce=>({id:ce.id,source:ce.source,target:ce.target,sourceHandle:ce.sourceHandle??null,targetHandle:ce.targetHandle??null}))}).catch(()=>{})},600))},[c]);C.useEffect(()=>{if(B.current=null,T(null),O(null),G.current={},W.current=new Set,$.current="",x([]),v([]),!c)return;localStorage.setItem(kA,c);let ce=!1;return kde(c).then(pe=>{ce||(G.current=pe.positions??{},v((pe.edges??[]).map(Ce=>({id:Ce.id,source:Ce.source,target:Ce.target,sourceHandle:Ce.sourceHandle??void 0,targetHandle:Ce.targetHandle??void 0,animated:!1}))))}).catch(()=>{}).finally(()=>{ce||(B.current=c,z(pe=>pe+1))}),()=>{ce=!0}},[c,x,v]),C.useEffect(()=>{if(!c||B.current!==c)return;const ce=`${f}|`+le.map(Fe=>`${Fe.seq}:${Fe.title}:${Fe.state}:${Fe.order}:${(Fe.skills??[]).join("|")}`).join(",");if(ce===$.current)return;$.current=ce;const pe=Fe=>({seq:String(Fe.seq),title:Fe.title,skills:(Fe.skills??[]).join(", "),status:_A(Fe),label:Fe.title,desc:""});if(f==="lanes"){const Fe=od(le),et=Fe.map((Yn,Wt)=>({id:`wave-${Wt}`,type:"waveBox",position:{x:xp+Wt*bp-CA,y:Gx-TA},data:{label:e("flow.lane.wave",{n:Wt+1}),sub:Yn.length>1?e("flow.lane.parallel",{n:Yn.length}):"",color:AA[Wt%AA.length]},style:{width:el+CA*2,height:TA+(Yn.length-1)*Kx+tl+14},draggable:!1,selectable:!1,zIndex:0})),Qt=Fe.flatMap((Yn,Wt)=>Yn.map((Z,be)=>({id:String(Z.seq),type:"task",position:{x:xp+Wt*bp,y:Gx+be*Kx},deletable:!1,zIndex:1,data:pe(Z)})));x([...et,...Qt]);return}const Ce=new Map(K.current.map(Fe=>[Fe.id,Fe.position])),je=[];for(const Fe of le){const et=Ce.get(String(Fe.seq))??G.current[String(Fe.seq)];et&&je.push(et)}let qe=!1;const st=le.map(Fe=>{const et=String(Fe.seq);let Qt=Ce.get(et)??G.current[et];return Qt||(Qt=Ide(je),je.push(Qt),qe=!0),G.current[et]=Qt,{id:et,type:"task",position:Qt,deletable:!1,data:pe(Fe)}});x(st),qe&&_e()},[le,c,f,R,x,_e,e]),C.useEffect(()=>{if(B.current!==c)return;const ce=new Set(le.map(pe=>String(pe.seq)));v(pe=>{const Ce=pe.filter(je=>ce.has(je.source)&&ce.has(je.target));return Ce.length!==pe.length&&_e(),Ce.length===pe.length?pe:Ce})},[le,c,v,_e]),C.useEffect(()=>{if(!c||B.current!==c||f!=="free"||le.length<2)return;const ce=od(le),pe=[];for(let qe=1;qe<ce.length;qe+=1)for(const st of ce[qe-1]??[])for(const Fe of ce[qe]??[])pe.push({id:`seed-${st.seq}-${Fe.seq}`,source:String(st.seq),target:String(Fe.seq),sourceHandle:"r",targetHandle:"l",animated:!1});const Ce=X.current,je=F.current!==c;if(F.current=c,je&&Ce.length===0)pe.length>0&&(v(pe),_e());else{const qe=new Set;for(const et of Ce)qe.add(et.source),qe.add(et.target);const st=new Set(Ce.map(et=>`${et.source}->${et.target}`)),Fe=new Set(le.map(et=>String(et.seq)).filter(et=>!W.current.has(et)&&!qe.has(et)));if(Fe.size>0){const et=pe.filter(Qt=>(Fe.has(Qt.source)||Fe.has(Qt.target))&&!st.has(`${Qt.source}->${Qt.target}`));et.length>0&&(v([...Ce,...et]),_e())}}W.current=new Set(le.map(qe=>String(qe.seq)))},[le,c,f,R,v,_e]);const ze=C.useCallback(ce=>{if(w(ce),f!=="free")return;let pe=!1;for(const Ce of ce)Ce.type==="position"&&Ce.position&&(G.current[Ce.id]=Ce.position,pe=!0);pe&&_e()},[w,_e,f]),fe=C.useCallback(ce=>{f==="free"&&(v(pe=>lP({...ce,animated:!1},pe)),_e())},[v,_e,f]),Se=C.useCallback(()=>{if(f!=="free"||le.length===0)return;const ce=od(le),pe={},Ce=[];ce.forEach((je,qe)=>{if(je.forEach((st,Fe)=>{pe[String(st.seq)]={x:xp+qe*bp,y:Gx+Fe*Kx}}),qe>0)for(const st of ce[qe-1]??[])for(const Fe of je)Ce.push({id:`seed-${st.seq}-${Fe.seq}`,source:String(st.seq),target:String(Fe.seq),sourceHandle:"r",targetHandle:"l",animated:!1})}),G.current={...G.current,...pe},x(je=>je.map(qe=>pe[qe.id]?{...qe,position:pe[qe.id]}:qe)),v(Ce),_e(),setTimeout(()=>a({padding:.2,duration:300}),60)},[f,le,x,v,_e,a]),Re=C.useCallback(async ce=>{if(!await i({title:e("flow.confirm.deleteTitle"),body:e("flow.confirm.deleteBody",{seq:ce}),danger:!0,confirm:e("flow.node.delete")}))return;P("");const Ce=X.current.filter(je=>je.source===String(ce)||je.target===String(ce)).map(je=>({...je}));try{await DL(c,ce),o.current.push({seq:ce,edges:Ce})}catch(je){P(je instanceof Error?je.message:String(je))}finally{T(je=>je===ce?null:je),j(je=>je===ce?null:je),$.current="",z(je=>je+1),ye()}},[c,i,e,ye]),Qe=C.useCallback(async()=>{const ce=o.current.pop();if(ce){P("");try{await Ane(c,ce.seq),v(pe=>{const Ce=new Set(pe.map(je=>je.id));return[...pe,...ce.edges.filter(je=>!Ce.has(je.id))]}),_e(),ye()}catch(pe){P(pe instanceof Error?pe.message:String(pe))}}},[c,v,_e,ye]),ht=C.useCallback((ce,pe)=>{var st;if(f!=="free"||pe.isValid)return;const Ce=pe.fromNode;if(!Ce||!c)return;const je="changedTouches"in ce?ce.changedTouches[0]:ce;if(!je)return;const qe=s({x:je.clientX,y:je.clientY});q({fromId:Ce.id,fromHandle:((st=pe.fromHandle)==null?void 0:st.id)??null,clientX:je.clientX,clientY:je.clientY,flowX:qe.x,flowY:qe.y})},[f,c,s]),it=C.useCallback(async()=>{const ce=U;if(q(null),!(!ce||!c))try{const pe=await cv(c,{title:`${e("flow.node.default")} ${le.length+1}`,initialState:"Planning"}),Ce=Rde(pe);if(Ce==null)return;const je=String(Ce);G.current[je]={x:ce.flowX-el/2,y:ce.flowY-tl/2},v(qe=>[...qe,{id:`e-${ce.fromId}-${je}-drop`,source:ce.fromId,target:je,sourceHandle:ce.fromHandle??void 0,animated:!1}]),_e(),ye()}catch(pe){P(pe instanceof Error?pe.message:String(pe))}},[U,c,le.length,v,_e,e,ye]);C.useEffect(()=>{if(!U)return;const ce=pe=>{pe.key==="Escape"&&q(null)};return window.addEventListener("keydown",ce),()=>window.removeEventListener("keydown",ce)},[U]);const Bt=C.useCallback((ce,pe)=>{f==="free"&&(v(Ce=>kce(ce,pe,Ce)),_e())},[f,v,_e]);C.useEffect(()=>{const ce=pe=>{if(pe.key!=="Delete"&&pe.key!=="Backspace"||A!=null)return;const Ce=pe.target;Ce&&(Ce.tagName==="INPUT"||Ce.tagName==="TEXTAREA"||Ce.isContentEditable)||k!=null&&(pe.preventDefault(),Re(k))};return window.addEventListener("keydown",ce),()=>window.removeEventListener("keydown",ce)},[k,A,Re]),C.useEffect(()=>{const ce=pe=>{if(!(pe.metaKey||pe.ctrlKey)||pe.key!=="z"&&pe.key!=="Z"||A!=null)return;const Ce=pe.target;Ce&&(Ce.tagName==="INPUT"||Ce.tagName==="TEXTAREA"||Ce.isContentEditable)||(pe.preventDefault(),Qe())};return window.addEventListener("keydown",ce),()=>window.removeEventListener("keydown",ce)},[A,Qe]);const mt=C.useCallback(async ce=>{if(c){y(!0),P("");try{const pe=new Map(le.map(Ce=>[Ce.seq,Ce.order]));for(let Ce=0;Ce<ce.length;Ce+=1)for(const je of ce[Ce]??[])pe.get(je)!==Ce+1&&await gm(c,je,{order:Ce+1});ye()}catch(pe){P(pe instanceof Error?pe.message:String(pe))}finally{y(!1)}}},[c,le,ye]),wt=C.useCallback(ce=>{const pe=Number(ce.id);if(!Number.isInteger(pe))return;const Ce=od(le).map(Fe=>Fe.map(et=>et.seq)),je=(ce.position.x-xp)/bp,qe=Math.round(je),st=Ce.map(Fe=>Fe.filter(et=>et!==pe));if(qe>=0&&qe<Ce.length&&Math.abs(je-qe)<=.35)st[qe].push(pe);else{const Fe=Math.max(0,Math.min(st.length,Math.ceil(je)));st.splice(Fe,0,[pe])}mt(st.filter(Fe=>Fe.length>0)).finally(()=>{$.current="",z(Fe=>Fe+1)})},[le,mt]),Te=C.useCallback((ce,pe)=>{if(f==="lanes"){wt(pe);return}const Ce=new Map(K.current.map(et=>[et.id,et])),je={x:pe.position.x+el/2,y:pe.position.y+tl/2};let qe=null,st=40;for(const et of X.current){if(et.source===pe.id||et.target===pe.id)continue;const Qt=Ce.get(et.source),Yn=Ce.get(et.target);if(!Qt||!Yn)continue;const Wt=Pde(je,jA(Qt),jA(Yn));Wt<st&&(st=Wt,qe=et)}if(!qe)return;const Fe=qe;v(et=>[...et.filter(Qt=>Qt.id!==Fe.id),{id:`e-${Fe.source}-${pe.id}-${Fe.id}`,source:Fe.source,target:pe.id,animated:!1},{id:`e-${pe.id}-${Fe.target}-${Fe.id}`,source:pe.id,target:Fe.target,animated:!1}]),_e()},[f,wt,v,_e]),ct=C.useCallback(ce=>{m(ce),localStorage.setItem(NA,ce)},[]);C.useEffect(()=>{const ce=setTimeout(()=>{a({padding:.2,duration:300})},80);return()=>clearTimeout(ce)},[f,a]);const ne=async()=>{if(c){P("");try{await cv(c,{title:`${e("flow.node.default")} ${le.length+1}`,initialState:"Planning"}),ye()}catch(ce){P(ce instanceof Error?ce.message:String(ce))}}},we=async()=>{if(P(""),O(null),!c)return P(e("flow.err.noProject"));if(le.length===0)return P(e("flow.err.noNodes"));D(!0);try{const ce=le.filter(je=>je.state==="Planning"),pe=ce.length;let Ce=0;O({phase:"creating",made:Ce,total:pe});for(const je of ce)await gm(c,je.seq,{state:"Backlog",labels:Array.from(new Set([...je.labels??[],"AI-PIPELINE"]))}),Ce+=1,O({phase:"creating",made:Ce,total:pe});O({phase:"starting",made:Ce,total:pe}),await OL(c),ye(),O({phase:"done",made:Ce,total:pe})}catch(ce){P(ce instanceof Error?ce.message:String(ce))}finally{D(!1)}},he=xe.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(UN,{size:18,strokeWidth:2.4}),e("nav.arrange")]}),d.jsx(zL,{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:()=>ct("free"),children:[d.jsx(UN,{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:()=>ct("lanes"),children:[d.jsx(WB,{size:14,strokeWidth:2.4})," ",e("flow.mode.lanes")]})]}),he&&d.jsx(lt,{size:15,className:"animate-spin text-[var(--color-text-muted)]"}),d.jsxs("button",{type:"button",className:"nb-btn",onClick:()=>void ne(),disabled:!c||he,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 we(),disabled:M||re||he||!c,title:re?e("flow.pipelineRunning"):void 0,children:[M||re?d.jsx(lt,{size:15,className:"animate-spin"}):d.jsx(Mm,{size:15,strokeWidth:2.4}),e(M?"flow.running":re?"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")}),I&&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:I}),V&&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:[V.phase==="creating"&&d.jsxs("span",{children:[e("flow.status.creating")," ",V.made,"/",V.total,"…"]}),V.phase==="starting"&&d.jsx("span",{children:e("flow.status.starting")}),V.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(V.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(Wue,{nodes:b,edges:Q,nodeTypes:Dde,connectionRadius:160,nodesConnectable:f==="free",edgesReconnectable:f==="free",deleteKeyCode:A!=null?null:["Delete","Backspace"],onNodesChange:ze,onEdgesChange:ce=>{f==="free"&&(_(ce),_e())},onConnect:fe,onConnectEnd:ht,onReconnect:Bt,onNodeClick:(ce,pe)=>{const Ce=Number(pe.id);Number.isInteger(Ce)&&j(Ce)},onNodeDragStop:Te,onSelectionChange:({nodes:ce})=>{const pe=ce[0]?Number(ce[0].id):null;T(pe!=null&&Number.isInteger(pe)?pe:null)},fitView:!0,children:[d.jsx(tde,{variant:Qr.Dots,gap:18,size:1}),d.jsx(lde,{children:f==="free"&&d.jsx(md,{onClick:Se,title:e("flow.tidy"),"aria-label":e("flow.tidy"),children:d.jsx(Dj,{size:14,strokeWidth:2.4})})})]})}),U&&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:U.clientX,top:U.clientY},onClick:ce=>{ce.stopPropagation(),it()},children:[d.jsx(Gn,{size:14,strokeWidth:2.4})," ",e("flow.pending.create")]})}),p&&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(lt,{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(jde,{project:c,seq:A,onClose:()=>j(null),onChanged:ye,onDelete:ce=>void Re(ce)})]})}function Bde(){return d.jsx(OP,{children:d.jsx(zde,{})})}function Ude(){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(Mc,{to:"/",className:"nb-btn nb-btn-mint inline-flex",children:e("notFound.home")})]})}const Fde=C.lazy(()=>yB(()=>import("./ShowcasePage-BAs5NC0m.js"),__vite__mapDeps([0,1])));function $de(){return d.jsx(gF,{children:d.jsxs(L5,{children:[d.jsx(ii,{path:"/showcase",element:d.jsx(C.Suspense,{fallback:null,children:d.jsx(Fde,{})})}),d.jsxs(ii,{element:d.jsx(HN,{contentMode:"workspace"}),children:[d.jsx(ii,{index:!0,element:d.jsx(bx,{})}),d.jsx(ii,{path:"/projects",element:d.jsx(aT,{})}),d.jsx(ii,{path:"/projects/:name",element:d.jsx(aT,{})}),d.jsx(ii,{path:"/board",element:d.jsx(Xne,{})}),d.jsx(ii,{path:"/prompts",element:d.jsx(uie,{})}),d.jsx(ii,{path:"/chat",element:d.jsx(bx,{})}),d.jsx(ii,{path:"/chat/:sessionId",element:d.jsx(bx,{})}),d.jsx(ii,{path:"/arrange",element:d.jsx(Bde,{})})]}),d.jsxs(ii,{element:d.jsx(HN,{contentMode:"document"}),children:[d.jsx(ii,{path:"/projects/new",element:d.jsx(jL,{})}),d.jsx(ii,{path:"/skills",element:d.jsx(iie,{})}),d.jsx(ii,{path:"/system",element:d.jsx(Tie,{})}),d.jsx(ii,{path:"/memory",element:d.jsx(Uie,{})}),d.jsx(ii,{path:"/plugins",element:d.jsx(ise,{})}),d.jsx(ii,{path:"*",element:d.jsx(Ude,{})})]})]})})}mF();$6();const qde=new S4({defaultOptions:{queries:{staleTime:3e4,refetchOnWindowFocus:!1}}}),zP=document.getElementById("root");if(!zP)throw new Error("#root not found");Zz.createRoot(zP).render(d.jsx(C.StrictMode,{children:d.jsx(R6,{children:d.jsx(k4,{client:qde,children:d.jsx(aB,{children:d.jsx(zW,{children:d.jsx($de,{})})})})})}));export{kj as A,VB as C,Aj as E,Mc as L,Hv as P,f0 as S,_B as a,Pe as c,d as j,C as r,qj as u};