@agi-cli/web-ui 0.1.151 → 0.1.152
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@import"https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600;700&display=swap";*,:before,:after{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }*,:before,:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:#e5e7eb}:before,:after{--tw-content: ""}html,:host{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:IBM Plex Mono,monospace;font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:IBM Plex Mono,monospace;font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;letter-spacing:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}fieldset{margin:0;padding:0}legend{padding:0}ol,ul,menu{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}button,[role=button]{cursor:pointer}:disabled{cursor:default}img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]:where(:not([hidden=until-found])){display:none}:root{--background: 220 25% 95%;--foreground: 220 10% 15%;--card: 220 25% 98%;--card-foreground: 220 10% 15%;--popover: 220 25% 98%;--popover-foreground: 220 10% 15%;--primary: 222.2 47.4% 11.2%;--primary-foreground: 210 40% 98%;--secondary: 220 18% 88%;--secondary-foreground: 222.2 35% 25%;--muted: 220 18% 88%;--muted-foreground: 220 15% 40%;--accent: 220 20% 86%;--accent-foreground: 222.2 35% 25%;--destructive: 0 90% 65%;--destructive-foreground: 210 40% 98%;--border: 220 15% 89%;--input: 220 15% 89%;--ring: 222.2 84% 4.9%;--chart-1: 222.2 47.4% 41.2%;--chart-2: 173 58% 39%;--chart-3: 197 37% 24%;--chart-4: 43 74% 66%;--chart-5: 27 87% 67%;--radius: .5rem;--sidebar-background: 220 25% 91%;--sidebar-foreground: 220 10% 15%;--sidebar-primary: 222.2 47.4% 11.2%;--sidebar-primary-foreground: 210 40% 98%;--sidebar-accent: 220 20% 86%;--sidebar-accent-foreground: 222.2 35% 25%;--sidebar-border: 220 15% 89%;--sidebar-ring: 222.2 84% 4.9%;--code-background: hsl(220 25% 93%);--code-foreground: hsl(220 10% 10%);--code-keyword: hsl(300 85% 42%);--code-class: hsl(120 60% 35%);--code-function: hsl(220 95% 45%);--code-string: hsl(120 60% 35%);--code-comment: hsl(220 15% 35%);--code-operator: hsl(180 85% 30%);--code-punctuation: hsl(220 15% 20%);color-scheme:light}.dark{--background: 240 10% 8%;--foreground: 0 0% 98%;--card: 240 10% 10%;--card-foreground: 0 0% 98%;--popover: 240 10% 10%;--popover-foreground: 0 0% 98%;--primary: 0 0% 98%;--primary-foreground: 240 5.9% 10%;--secondary: 240 3.7% 15.9%;--secondary-foreground: 0 0% 98%;--muted: 240 3.7% 15.9%;--muted-foreground: 240 5% 64.9%;--accent: 240 3.7% 15.9%;--accent-foreground: 0 0% 98%;--destructive: 0 75% 45%;--destructive-foreground: 0 0% 98%;--border: 240 3.7% 15.9%;--input: 240 3.7% 15.9%;--ring: 240 4.9% 83.9%;--chart-1: 220 70% 50%;--chart-2: 160 60% 45%;--chart-3: 30 80% 55%;--chart-4: 280 65% 60%;--chart-5: 340 75% 55%;--radius: .5rem;--sidebar-background: 240 10% 10%;--sidebar-foreground: 0 0% 98%;--sidebar-primary: 217.2 91.2% 59.8%;--sidebar-primary-foreground: 240 5.9% 10%;--sidebar-accent: 240 3.7% 15.9%;--sidebar-accent-foreground: 0 0% 98%;--sidebar-border: 240 3.7% 15.9%;--sidebar-ring: 217.2 91.2% 59.8%;--code-background: hsl(240 10% 10%);--code-foreground: hsl(0 0% 98%);--code-keyword: #c678dd;--code-class: #98c379;--code-function: #61afef;--code-string: #98c379;--code-comment: hsl(240 5% 64.9%);--code-operator: #56b6c2;--code-punctuation: hsl(240 5% 64.9%);color-scheme:dark}.\!container{width:100%!important}.container{width:100%}@media(min-width:640px){.\!container{max-width:640px!important}.container{max-width:640px}}@media(min-width:768px){.\!container{max-width:768px!important}.container{max-width:768px}}@media(min-width:1024px){.\!container{max-width:1024px!important}.container{max-width:1024px}}@media(min-width:1280px){.\!container{max-width:1280px!important}.container{max-width:1280px}}@media(min-width:1536px){.\!container{max-width:1536px!important}.container{max-width:1536px}}.pointer-events-none{pointer-events:none}.pointer-events-auto{pointer-events:auto}.visible{visibility:visible}.collapse{visibility:collapse}.fixed{position:fixed}.absolute{position:absolute}.relative{position:relative}.sticky{position:sticky}.inset-0{inset:0}.inset-x-0{left:0;right:0}.-bottom-1{bottom:-.25rem}.-top-1{top:-.25rem}.-top-6{top:-1.5rem}.bottom-0{bottom:0}.bottom-24{bottom:6rem}.bottom-36{bottom:9rem}.bottom-4{bottom:1rem}.bottom-full{bottom:100%}.left-0{left:0}.left-1\/2{left:50%}.left-3{left:.75rem}.left-4{left:1rem}.right-0{right:0}.right-1{right:.25rem}.right-2{right:.5rem}.right-4{right:1rem}.top-0{top:0}.top-1{top:.25rem}.top-1\/2{top:50%}.top-2{top:.5rem}.top-4{top:1rem}.top-full{top:100%}.z-0{z-index:0}.z-10{z-index:10}.z-20{z-index:20}.z-40{z-index:40}.z-50{z-index:50}.z-\[9999\]{z-index:9999}.mx-4{margin-left:1rem;margin-right:1rem}.mx-6{margin-left:1.5rem;margin-right:1.5rem}.mx-auto{margin-left:auto;margin-right:auto}.my-2{margin-top:.5rem;margin-bottom:.5rem}.my-3{margin-top:.75rem;margin-bottom:.75rem}.-mt-0\.5{margin-top:-.125rem}.mb-1{margin-bottom:.25rem}.mb-1\.5{margin-bottom:.375rem}.mb-10{margin-bottom:2.5rem}.mb-2{margin-bottom:.5rem}.mb-3{margin-bottom:.75rem}.mb-4{margin-bottom:1rem}.mb-6{margin-bottom:1.5rem}.ml-1{margin-left:.25rem}.ml-2{margin-left:.5rem}.ml-3{margin-left:.75rem}.ml-4{margin-left:1rem}.ml-5{margin-left:1.25rem}.ml-6{margin-left:1.5rem}.ml-7{margin-left:1.75rem}.ml-auto{margin-left:auto}.mr-1{margin-right:.25rem}.mr-2{margin-right:.5rem}.mt-0\.5{margin-top:.125rem}.mt-1{margin-top:.25rem}.mt-2{margin-top:.5rem}.mt-3{margin-top:.75rem}.mt-4{margin-top:1rem}.line-clamp-2{overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2}.block{display:block}.inline-block{display:inline-block}.inline{display:inline}.flex{display:flex}.inline-flex{display:inline-flex}.grid{display:grid}.hidden{display:none}.h-10{height:2.5rem}.h-11{height:2.75rem}.h-12{height:3rem}.h-14{height:3.5rem}.h-16{height:4rem}.h-2{height:.5rem}.h-2\.5{height:.625rem}.h-3{height:.75rem}.h-3\.5{height:.875rem}.h-4{height:1rem}.h-5{height:1.25rem}.h-6{height:1.5rem}.h-7{height:1.75rem}.h-8{height:2rem}.h-9{height:2.25rem}.h-auto{height:auto}.h-full{height:100%}.h-px{height:1px}.h-screen{height:100vh}.max-h-24{max-height:6rem}.max-h-48{max-height:12rem}.max-h-60{max-height:15rem}.max-h-80{max-height:20rem}.max-h-96{max-height:24rem}.max-h-\[120px\]{max-height:120px}.max-h-\[200px\]{max-height:200px}.max-h-\[300px\]{max-height:300px}.max-h-\[30rem\]{max-height:30rem}.max-h-\[70vh\]{max-height:70vh}.max-h-full{max-height:100%}.min-h-10{min-height:2.5rem}.min-h-screen{min-height:100vh}.w-10{width:2.5rem}.w-11{width:2.75rem}.w-12{width:3rem}.w-14{width:3.5rem}.w-16{width:4rem}.w-2{width:.5rem}.w-2\.5{width:.625rem}.w-20{width:5rem}.w-3{width:.75rem}.w-3\.5{width:.875rem}.w-4{width:1rem}.w-5{width:1.25rem}.w-6{width:1.5rem}.w-7{width:1.75rem}.w-8{width:2rem}.w-80{width:20rem}.w-9{width:2.25rem}.w-96{width:24rem}.w-\[2px\]{width:2px}.w-full{width:100%}.min-w-0{min-width:0px}.min-w-\[100px\]{min-width:100px}.min-w-\[160px\]{min-width:160px}.min-w-\[60px\]{min-width:60px}.min-w-max{min-width:-moz-max-content;min-width:max-content}.max-w-2xl{max-width:42rem}.max-w-32{max-width:8rem}.max-w-3xl{max-width:48rem}.max-w-40{max-width:10rem}.max-w-48{max-width:12rem}.max-w-7xl{max-width:80rem}.max-w-\[120px\]{max-width:120px}.max-w-\[150px\]{max-width:150px}.max-w-\[200px\]{max-width:200px}.max-w-\[calc\(100\%-3rem\)\]{max-width:calc(100% - 3rem)}.max-w-full{max-width:100%}.max-w-lg{max-width:32rem}.max-w-md{max-width:28rem}.max-w-sm{max-width:24rem}.max-w-xl{max-width:36rem}.max-w-xs{max-width:20rem}.flex-1{flex:1 1 0%}.flex-shrink{flex-shrink:1}.flex-shrink-0,.shrink-0{flex-shrink:0}.-translate-x-1\/2{--tw-translate-x: -50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.-translate-y-1\/2{--tw-translate-y: -50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.-translate-y-full{--tw-translate-y: -100%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.translate-x-1{--tw-translate-x: .25rem;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.translate-x-6{--tw-translate-x: 1.5rem;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.translate-y-0{--tw-translate-y: 0px;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.translate-y-2{--tw-translate-y: .5rem;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rotate-180{--tw-rotate: 180deg;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rotate-90{--tw-rotate: 90deg;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}@keyframes pulse{50%{opacity:.5}}.animate-pulse{animation:pulse 2s cubic-bezier(.4,0,.6,1) infinite}@keyframes spin{to{transform:rotate(360deg)}}.animate-spin{animation:spin 1s linear infinite}.cursor-default{cursor:default}.cursor-pointer{cursor:pointer}.select-none{-webkit-user-select:none;-moz-user-select:none;user-select:none}.resize-none{resize:none}.resize{resize:both}.appearance-none{-webkit-appearance:none;-moz-appearance:none;appearance:none}.grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.grid-rows-\[0fr\]{grid-template-rows:0fr}.grid-rows-\[1fr\]{grid-template-rows:1fr}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.items-start{align-items:flex-start}.items-end{align-items:flex-end}.items-center{align-items:center}.justify-start{justify-content:flex-start}.justify-end{justify-content:flex-end}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.gap-0\.5{gap:.125rem}.gap-1{gap:.25rem}.gap-1\.5{gap:.375rem}.gap-2{gap:.5rem}.gap-3{gap:.75rem}.gap-4{gap:1rem}.gap-5{gap:1.25rem}.gap-6{gap:1.5rem}.gap-x-1\.5{-moz-column-gap:.375rem;column-gap:.375rem}.gap-x-2{-moz-column-gap:.5rem;column-gap:.5rem}.gap-x-5{-moz-column-gap:1.25rem;column-gap:1.25rem}.gap-y-1{row-gap:.25rem}.gap-y-2{row-gap:.5rem}.space-y-0\.5>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.125rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.125rem * var(--tw-space-y-reverse))}.space-y-1>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.25rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.25rem * var(--tw-space-y-reverse))}.space-y-1\.5>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.375rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.375rem * var(--tw-space-y-reverse))}.space-y-2>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.5rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.5rem * var(--tw-space-y-reverse))}.space-y-3>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.75rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.75rem * var(--tw-space-y-reverse))}.space-y-4>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(1rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1rem * var(--tw-space-y-reverse))}.space-y-6>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(1.5rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1.5rem * var(--tw-space-y-reverse))}.divide-y>:not([hidden])~:not([hidden]){--tw-divide-y-reverse: 0;border-top-width:calc(1px * calc(1 - var(--tw-divide-y-reverse)));border-bottom-width:calc(1px * var(--tw-divide-y-reverse))}.divide-border>:not([hidden])~:not([hidden]){border-color:hsl(var(--border))}.divide-border\/50>:not([hidden])~:not([hidden]){border-color:hsl(var(--border) / .5)}.justify-self-start{justify-self:start}.justify-self-end{justify-self:end}.justify-self-center{justify-self:center}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.overflow-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.text-ellipsis{text-overflow:ellipsis}.whitespace-nowrap{white-space:nowrap}.whitespace-pre-wrap{white-space:pre-wrap}.break-words{overflow-wrap:break-word}.break-all{word-break:break-all}.rounded{border-radius:.25rem}.rounded-2xl{border-radius:1rem}.rounded-3xl{border-radius:1.5rem}.rounded-full{border-radius:9999px}.rounded-lg{border-radius:var(--radius)}.rounded-md{border-radius:calc(var(--radius) - 2px)}.rounded-xl{border-radius:.75rem}.rounded-bl-md{border-bottom-left-radius:calc(var(--radius) - 2px)}.border{border-width:1px}.border-0{border-width:0px}.border-2{border-width:2px}.border-b{border-bottom-width:1px}.border-l{border-left-width:1px}.border-r{border-right-width:1px}.border-r-2{border-right-width:2px}.border-t{border-top-width:1px}.border-dashed{border-style:dashed}.border-\[hsl\(var\(--border\)\)\]{border-color:hsl(var(--border))}.border-amber-200{--tw-border-opacity: 1;border-color:rgb(253 230 138 / var(--tw-border-opacity, 1))}.border-blue-500\/30{border-color:#3b82f64d}.border-border{border-color:hsl(var(--border))}.border-border\/50{border-color:hsl(var(--border) / .5)}.border-destructive\/30{border-color:hsl(var(--destructive) / .3)}.border-emerald-500\/20{border-color:#10b98133}.border-emerald-500\/30{border-color:#10b9814d}.border-emerald-500\/50{border-color:#10b98180}.border-foreground{border-color:hsl(var(--foreground))}.border-green-500\/20{border-color:#22c55e33}.border-primary{border-color:hsl(var(--primary))}.border-primary\/50{border-color:hsl(var(--primary) / .5)}.border-red-200{--tw-border-opacity: 1;border-color:rgb(254 202 202 / var(--tw-border-opacity, 1))}.border-red-500\/20{border-color:#ef444433}.border-red-500\/30{border-color:#ef44444d}.border-red-500\/50{border-color:#ef444480}.border-ring{border-color:hsl(var(--ring))}.border-slate-300{--tw-border-opacity: 1;border-color:rgb(203 213 225 / var(--tw-border-opacity, 1))}.border-teal-500\/30{border-color:#14b8a64d}.border-violet-500{--tw-border-opacity: 1;border-color:rgb(139 92 246 / var(--tw-border-opacity, 1))}.border-violet-500\/30{border-color:#8b5cf64d}.border-violet-500\/50{border-color:#8b5cf680}.bg-\[hsl\(var\(--accent\)\)\]{background-color:hsl(var(--accent))}.bg-\[hsl\(var\(--muted\)\)\]{background-color:hsl(var(--muted))}.bg-\[hsl\(var\(--popover\)\)\]{background-color:hsl(var(--popover))}.bg-\[hsl\(var\(--secondary\)\)\]{background-color:hsl(var(--secondary))}.bg-accent{background-color:hsl(var(--accent))}.bg-accent\/50{background-color:hsl(var(--accent) / .5)}.bg-amber-50{--tw-bg-opacity: 1;background-color:rgb(255 251 235 / var(--tw-bg-opacity, 1))}.bg-amber-500\/90{background-color:#f59e0be6}.bg-amber-600{--tw-bg-opacity: 1;background-color:rgb(217 119 6 / var(--tw-bg-opacity, 1))}.bg-background{background-color:hsl(var(--background))}.bg-background\/50{background-color:hsl(var(--background) / .5)}.bg-background\/80{background-color:hsl(var(--background) / .8)}.bg-background\/95{background-color:hsl(var(--background) / .95)}.bg-black\/50{background-color:#00000080}.bg-black\/60{background-color:#0009}.bg-black\/80{background-color:#000c}.bg-blue-500{--tw-bg-opacity: 1;background-color:rgb(59 130 246 / var(--tw-bg-opacity, 1))}.bg-blue-500\/10{background-color:#3b82f61a}.bg-border{background-color:hsl(var(--border))}.bg-card{background-color:hsl(var(--card))}.bg-card\/60{background-color:hsl(var(--card) / .6)}.bg-destructive{background-color:hsl(var(--destructive))}.bg-destructive\/10{background-color:hsl(var(--destructive) / .1)}.bg-emerald-500\/10{background-color:#10b9811a}.bg-emerald-500\/20{background-color:#10b98133}.bg-emerald-500\/5{background-color:#10b9810d}.bg-foreground{background-color:hsl(var(--foreground))}.bg-green-500{--tw-bg-opacity: 1;background-color:rgb(34 197 94 / var(--tw-bg-opacity, 1))}.bg-green-500\/10{background-color:#22c55e1a}.bg-green-500\/90{background-color:#22c55ee6}.bg-green-600\/20{background-color:#16a34a33}.bg-muted{background-color:hsl(var(--muted))}.bg-muted\/10{background-color:hsl(var(--muted) / .1)}.bg-muted\/20{background-color:hsl(var(--muted) / .2)}.bg-muted\/30{background-color:hsl(var(--muted) / .3)}.bg-muted\/40{background-color:hsl(var(--muted) / .4)}.bg-muted\/50{background-color:hsl(var(--muted) / .5)}.bg-muted\/60{background-color:hsl(var(--muted) / .6)}.bg-orange-50{--tw-bg-opacity: 1;background-color:rgb(255 247 237 / var(--tw-bg-opacity, 1))}.bg-popover{background-color:hsl(var(--popover))}.bg-primary{background-color:hsl(var(--primary))}.bg-primary-foreground{background-color:hsl(var(--primary-foreground))}.bg-primary\/10{background-color:hsl(var(--primary) / .1)}.bg-purple-600\/20{background-color:#9333ea33}.bg-red-100\/50{background-color:#fee2e280}.bg-red-50{--tw-bg-opacity: 1;background-color:rgb(254 242 242 / var(--tw-bg-opacity, 1))}.bg-red-500\/10{background-color:#ef44441a}.bg-slate-100{--tw-bg-opacity: 1;background-color:rgb(241 245 249 / var(--tw-bg-opacity, 1))}.bg-teal-500{--tw-bg-opacity: 1;background-color:rgb(20 184 166 / var(--tw-bg-opacity, 1))}.bg-teal-500\/10{background-color:#14b8a61a}.bg-teal-500\/5{background-color:#14b8a60d}.bg-transparent{background-color:transparent}.bg-violet-500\/10{background-color:#8b5cf61a}.bg-violet-500\/20{background-color:#8b5cf633}.bg-violet-600{--tw-bg-opacity: 1;background-color:rgb(124 58 237 / var(--tw-bg-opacity, 1))}.bg-white{--tw-bg-opacity: 1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1))}.bg-white\/10{background-color:#ffffff1a}.bg-gradient-to-t{background-image:linear-gradient(to top,var(--tw-gradient-stops))}.from-background{--tw-gradient-from: hsl(var(--background)) var(--tw-gradient-from-position);--tw-gradient-to: hsl(var(--background) / 0) var(--tw-gradient-to-position);--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to)}.via-background{--tw-gradient-to: hsl(var(--background) / 0) var(--tw-gradient-to-position);--tw-gradient-stops: var(--tw-gradient-from), hsl(var(--background)) var(--tw-gradient-via-position), var(--tw-gradient-to)}.to-transparent{--tw-gradient-to: transparent var(--tw-gradient-to-position)}.object-contain{-o-object-fit:contain;object-fit:contain}.object-cover{-o-object-fit:cover;object-fit:cover}.p-0{padding:0}.p-0\.5{padding:.125rem}.p-1{padding:.25rem}.p-1\.5{padding:.375rem}.p-2{padding:.5rem}.p-3{padding:.75rem}.p-4{padding:1rem}.p-5{padding:1.25rem}.p-6{padding:1.5rem}.p-8{padding:2rem}.px-1{padding-left:.25rem;padding-right:.25rem}.px-1\.5{padding-left:.375rem;padding-right:.375rem}.px-2{padding-left:.5rem;padding-right:.5rem}.px-2\.5{padding-left:.625rem;padding-right:.625rem}.px-3{padding-left:.75rem;padding-right:.75rem}.px-4{padding-left:1rem;padding-right:1rem}.px-6{padding-left:1.5rem;padding-right:1.5rem}.py-0\.5{padding-top:.125rem;padding-bottom:.125rem}.py-1{padding-top:.25rem;padding-bottom:.25rem}.py-1\.5{padding-top:.375rem;padding-bottom:.375rem}.py-16{padding-top:4rem;padding-bottom:4rem}.py-2{padding-top:.5rem;padding-bottom:.5rem}.py-2\.5{padding-top:.625rem;padding-bottom:.625rem}.py-3{padding-top:.75rem;padding-bottom:.75rem}.py-4{padding-top:1rem;padding-bottom:1rem}.py-6{padding-top:1.5rem;padding-bottom:1.5rem}.py-8{padding-top:2rem;padding-bottom:2rem}.pb-1{padding-bottom:.25rem}.pb-2{padding-bottom:.5rem}.pb-3{padding-bottom:.75rem}.pb-32{padding-bottom:8rem}.pb-6{padding-bottom:1.5rem}.pb-64{padding-bottom:16rem}.pb-8{padding-bottom:2rem}.pl-1{padding-left:.25rem}.pl-2{padding-left:.5rem}.pl-3{padding-left:.75rem}.pl-8{padding-left:2rem}.pl-9{padding-left:2.25rem}.pr-1{padding-right:.25rem}.pr-2{padding-right:.5rem}.pr-3{padding-right:.75rem}.pr-4{padding-right:1rem}.pt-0{padding-top:0}.pt-0\.5{padding-top:.125rem}.pt-1{padding-top:.25rem}.pt-16{padding-top:4rem}.pt-2{padding-top:.5rem}.pt-3{padding-top:.75rem}.pt-4{padding-top:1rem}.pt-6{padding-top:1.5rem}.text-left{text-align:left}.text-center{text-align:center}.text-right{text-align:right}.font-mono{font-family:IBM Plex Mono,monospace}.text-2xl{font-size:1.5rem;line-height:2rem}.text-3xl{font-size:1.875rem;line-height:2.25rem}.text-\[0\.65rem\]{font-size:.65rem}.text-\[10px\]{font-size:10px}.text-\[11px\]{font-size:11px}.text-\[13px\]{font-size:13px}.text-base{font-size:1rem;line-height:1.5rem}.text-lg{font-size:1.125rem;line-height:1.75rem}.text-sm{font-size:.875rem;line-height:1.25rem}.text-xl{font-size:1.25rem;line-height:1.75rem}.text-xs{font-size:.75rem;line-height:1rem}.font-medium{font-weight:500}.font-semibold{font-weight:600}.uppercase{text-transform:uppercase}.capitalize{text-transform:capitalize}.italic{font-style:italic}.leading-normal{line-height:1.5}.leading-relaxed{line-height:1.625}.leading-tight{line-height:1.25}.tracking-wider{letter-spacing:.05em}.text-\[hsl\(var\(--accent-foreground\)\)\]{color:hsl(var(--accent-foreground))}.text-\[hsl\(var\(--foreground\)\)\]{color:hsl(var(--foreground))}.text-\[hsl\(var\(--muted-foreground\)\)\]{color:hsl(var(--muted-foreground))}.text-\[hsl\(var\(--muted-foreground\)\)\]\/50{color:hsl(var(--muted-foreground) / .5)}.text-amber-500{--tw-text-opacity: 1;color:rgb(245 158 11 / var(--tw-text-opacity, 1))}.text-amber-600{--tw-text-opacity: 1;color:rgb(217 119 6 / var(--tw-text-opacity, 1))}.text-amber-700{--tw-text-opacity: 1;color:rgb(180 83 9 / var(--tw-text-opacity, 1))}.text-amber-800{--tw-text-opacity: 1;color:rgb(146 64 14 / var(--tw-text-opacity, 1))}.text-background{color:hsl(var(--background))}.text-blue-500{--tw-text-opacity: 1;color:rgb(59 130 246 / var(--tw-text-opacity, 1))}.text-blue-600{--tw-text-opacity: 1;color:rgb(37 99 235 / var(--tw-text-opacity, 1))}.text-blue-700{--tw-text-opacity: 1;color:rgb(29 78 216 / var(--tw-text-opacity, 1))}.text-card-foreground{color:hsl(var(--card-foreground))}.text-cyan-600{--tw-text-opacity: 1;color:rgb(8 145 178 / var(--tw-text-opacity, 1))}.text-cyan-700{--tw-text-opacity: 1;color:rgb(14 116 144 / var(--tw-text-opacity, 1))}.text-destructive{color:hsl(var(--destructive))}.text-destructive-foreground{color:hsl(var(--destructive-foreground))}.text-destructive\/80{color:hsl(var(--destructive) / .8)}.text-emerald-500{--tw-text-opacity: 1;color:rgb(16 185 129 / var(--tw-text-opacity, 1))}.text-emerald-600{--tw-text-opacity: 1;color:rgb(5 150 105 / var(--tw-text-opacity, 1))}.text-emerald-700{--tw-text-opacity: 1;color:rgb(4 120 87 / var(--tw-text-opacity, 1))}.text-foreground{color:hsl(var(--foreground))}.text-foreground\/60{color:hsl(var(--foreground) / .6)}.text-foreground\/70{color:hsl(var(--foreground) / .7)}.text-foreground\/80{color:hsl(var(--foreground) / .8)}.text-foreground\/85{color:hsl(var(--foreground) / .85)}.text-foreground\/90{color:hsl(var(--foreground) / .9)}.text-green-400{--tw-text-opacity: 1;color:rgb(74 222 128 / var(--tw-text-opacity, 1))}.text-green-500{--tw-text-opacity: 1;color:rgb(34 197 94 / var(--tw-text-opacity, 1))}.text-green-600{--tw-text-opacity: 1;color:rgb(22 163 74 / var(--tw-text-opacity, 1))}.text-green-600\/40{color:#16a34a66}.text-green-600\/60{color:#16a34a99}.text-green-700{--tw-text-opacity: 1;color:rgb(21 128 61 / var(--tw-text-opacity, 1))}.text-indigo-600{--tw-text-opacity: 1;color:rgb(79 70 229 / var(--tw-text-opacity, 1))}.text-muted-foreground{color:hsl(var(--muted-foreground))}.text-muted-foreground\/40{color:hsl(var(--muted-foreground) / .4)}.text-muted-foreground\/50{color:hsl(var(--muted-foreground) / .5)}.text-muted-foreground\/60{color:hsl(var(--muted-foreground) / .6)}.text-muted-foreground\/65{color:hsl(var(--muted-foreground) / .65)}.text-muted-foreground\/70{color:hsl(var(--muted-foreground) / .7)}.text-muted-foreground\/75{color:hsl(var(--muted-foreground) / .75)}.text-muted-foreground\/80{color:hsl(var(--muted-foreground) / .8)}.text-orange-500{--tw-text-opacity: 1;color:rgb(249 115 22 / var(--tw-text-opacity, 1))}.text-orange-600{--tw-text-opacity: 1;color:rgb(234 88 12 / var(--tw-text-opacity, 1))}.text-primary{color:hsl(var(--primary))}.text-primary-foreground{color:hsl(var(--primary-foreground))}.text-purple-400{--tw-text-opacity: 1;color:rgb(192 132 252 / var(--tw-text-opacity, 1))}.text-purple-500{--tw-text-opacity: 1;color:rgb(168 85 247 / var(--tw-text-opacity, 1))}.text-purple-600{--tw-text-opacity: 1;color:rgb(147 51 234 / var(--tw-text-opacity, 1))}.text-purple-700{--tw-text-opacity: 1;color:rgb(126 34 206 / var(--tw-text-opacity, 1))}.text-red-500{--tw-text-opacity: 1;color:rgb(239 68 68 / var(--tw-text-opacity, 1))}.text-red-600{--tw-text-opacity: 1;color:rgb(220 38 38 / var(--tw-text-opacity, 1))}.text-red-700{--tw-text-opacity: 1;color:rgb(185 28 28 / var(--tw-text-opacity, 1))}.text-red-800{--tw-text-opacity: 1;color:rgb(153 27 27 / var(--tw-text-opacity, 1))}.text-red-900{--tw-text-opacity: 1;color:rgb(127 29 29 / var(--tw-text-opacity, 1))}.text-teal-500{--tw-text-opacity: 1;color:rgb(20 184 166 / var(--tw-text-opacity, 1))}.text-teal-600{--tw-text-opacity: 1;color:rgb(13 148 136 / var(--tw-text-opacity, 1))}.text-violet-500{--tw-text-opacity: 1;color:rgb(139 92 246 / var(--tw-text-opacity, 1))}.text-violet-600{--tw-text-opacity: 1;color:rgb(124 58 237 / var(--tw-text-opacity, 1))}.text-violet-700{--tw-text-opacity: 1;color:rgb(109 40 217 / var(--tw-text-opacity, 1))}.text-white{--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity, 1))}.text-yellow-500{--tw-text-opacity: 1;color:rgb(234 179 8 / var(--tw-text-opacity, 1))}.line-through{text-decoration-line:line-through}.placeholder-\[hsl\(var\(--muted-foreground\)\)\]::-moz-placeholder{color:hsl(var(--muted-foreground))}.placeholder-\[hsl\(var\(--muted-foreground\)\)\]::placeholder{color:hsl(var(--muted-foreground))}.placeholder-muted-foreground::-moz-placeholder{color:hsl(var(--muted-foreground))}.placeholder-muted-foreground::placeholder{color:hsl(var(--muted-foreground))}.caret-\[6px\]{caret-color:6px}.opacity-0{opacity:0}.opacity-100{opacity:1}.opacity-40{opacity:.4}.opacity-50{opacity:.5}.opacity-60{opacity:.6}.opacity-70{opacity:.7}.shadow-2xl{--tw-shadow: 0 25px 50px -12px rgb(0 0 0 / .25);--tw-shadow-colored: 0 25px 50px -12px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-lg{--tw-shadow: 0 10px 15px -3px rgb(0 0 0 / .1), 0 4px 6px -4px rgb(0 0 0 / .1);--tw-shadow-colored: 0 10px 15px -3px var(--tw-shadow-color), 0 4px 6px -4px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-sm{--tw-shadow: 0 1px 2px 0 rgb(0 0 0 / .05);--tw-shadow-colored: 0 1px 2px 0 var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.outline-none{outline:2px solid transparent;outline-offset:2px}.ring-1{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.ring-inset{--tw-ring-inset: inset}.ring-primary\/40{--tw-ring-color: hsl(var(--primary) / .4)}.blur{--tw-blur: blur(8px);filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.backdrop-blur-sm{--tw-backdrop-blur: blur(4px);-webkit-backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia);backdrop-filter:var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia)}.transition-\[grid-template-rows\]{transition-property:grid-template-rows;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-all{transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-colors{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-opacity{transition-property:opacity;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-transform{transition-property:transform;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.duration-150{transition-duration:.15s}.duration-200{transition-duration:.2s}.duration-300{transition-duration:.3s}.ease-in-out{transition-timing-function:cubic-bezier(.4,0,.2,1)}.ease-out{transition-timing-function:cubic-bezier(0,0,.2,1)}.touch-manipulation{touch-action:manipulation}.safe-area-inset-bottom{padding-bottom:env(safe-area-inset-bottom)}.\[word-break\:break-word\]{word-break:break-word}@keyframes shimmer{0%{background-position:-200% 0}to{background-position:200% 0}}.animate-shimmer{animation:shimmer 2s ease-in-out infinite}body{margin:0;font-family:IBM Plex Mono,monospace;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;background-color:hsl(var(--background));color:hsl(var(--foreground));overflow:hidden;position:fixed;width:100%;height:100%;-webkit-overflow-scrolling:touch}html{overflow:hidden;position:fixed;width:100%;height:100%}code{font-family:IBM Plex Mono,monospace;color:var(--code-foreground)}button:focus,button:focus-visible{outline:none;box-shadow:none}.scrollbar-hide{-ms-overflow-style:none;scrollbar-width:none}.scrollbar-hide::-webkit-scrollbar{display:none}.markdown-content{max-width:100%;overflow-wrap:break-word;word-wrap:break-word;word-break:break-word}.markdown-content h1{font-size:1.875rem;font-weight:700;margin-top:1.5rem;margin-bottom:1rem;line-height:1.2}.markdown-content h2{font-size:1.5rem;font-weight:600;margin-top:1.5rem;margin-bottom:.75rem;line-height:1.3}.markdown-content h3{font-size:1.25rem;font-weight:600;margin-top:1.25rem;margin-bottom:.5rem;line-height:1.4}.markdown-content h4{font-size:1.125rem;font-weight:600;margin-top:1rem;margin-bottom:.5rem;line-height:1.4}.markdown-content p{margin-top:.75rem;margin-bottom:.75rem}.markdown-content ul,.markdown-content ol{margin-top:.75rem;margin-bottom:.75rem;padding-left:1.5rem}.markdown-content li{margin-top:.25rem;margin-bottom:.25rem}.markdown-content pre{background-color:var(--code-background);border:1px solid hsl(var(--border));border-radius:.5rem;padding:1rem;margin-top:.75rem;margin-bottom:.75rem;overflow-x:auto;color:var(--code-foreground);max-width:100%}.markdown-content code{background-color:var(--code-background);border:1px solid hsl(var(--border));border-radius:.25rem;padding:.125rem .375rem;font-size:.875rem;color:var(--code-foreground);word-break:break-all}.markdown-content pre code{background-color:transparent;border:none;padding:0;font-size:.875rem;color:inherit;word-break:normal;overflow-wrap:normal}.markdown-content blockquote{border-left:4px solid hsl(var(--border));padding-left:1rem;margin-top:.75rem;margin-bottom:.75rem;color:hsl(var(--muted-foreground));font-style:italic}.markdown-content a{color:hsl(var(--primary));text-decoration:underline;word-break:break-word}.markdown-content a:hover{color:hsl(var(--primary) / .85)}.markdown-content strong,.markdown-content b{font-weight:600}.markdown-content em,.markdown-content i{font-style:italic}.markdown-content hr{border:none;border-top:1px solid hsl(var(--border));margin-top:1.5rem;margin-bottom:1.5rem}.markdown-content table{width:100%;max-width:100%;border-collapse:collapse;margin-top:.75rem;margin-bottom:.75rem;overflow-x:auto;display:block}.markdown-content th,.markdown-content td{border:1px solid hsl(var(--border));padding:.5rem;text-align:left;word-break:break-word}.markdown-content th{background-color:hsl(var(--muted));font-weight:600}.markdown-content>*:first-child{margin-top:0}.markdown-content>*:last-child{margin-bottom:0}.markdown-content>p:first-child,.markdown-content>ul:first-child,.markdown-content>ol:first-child,.markdown-content>pre:first-child,.markdown-content>blockquote:first-child{margin-top:0}.markdown-content>p:last-child,.markdown-content>ul:last-child,.markdown-content>ol:last-child,.markdown-content>pre:last-child,.markdown-content>blockquote:last-child{margin-bottom:0}.research-messages .markdown-content{font-size:.8125rem;line-height:1.5}.research-messages .markdown-content h1{font-size:1.25rem;margin-top:1rem;margin-bottom:.5rem}.research-messages .markdown-content h2{font-size:1.125rem;margin-top:.875rem;margin-bottom:.375rem}.research-messages .markdown-content h3{font-size:1rem;margin-top:.75rem;margin-bottom:.25rem}.research-messages .markdown-content pre{padding:.625rem;font-size:.75rem}.research-messages .markdown-content code{font-size:.75rem;padding:.0625rem .25rem}.placeholder\:text-muted-foreground::-moz-placeholder{color:hsl(var(--muted-foreground))}.placeholder\:text-muted-foreground::placeholder{color:hsl(var(--muted-foreground))}.last\:border-0:last-child{border-width:0px}.focus-within\:border-primary\/60:focus-within{border-color:hsl(var(--primary) / .6)}.focus-within\:border-slate-400:focus-within{--tw-border-opacity: 1;border-color:rgb(148 163 184 / var(--tw-border-opacity, 1))}.focus-within\:border-teal-500\/60:focus-within{border-color:#14b8a699}.focus-within\:ring-1:focus-within{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.focus-within\:ring-primary\/40:focus-within{--tw-ring-color: hsl(var(--primary) / .4)}.focus-within\:ring-slate-300:focus-within{--tw-ring-opacity: 1;--tw-ring-color: rgb(203 213 225 / var(--tw-ring-opacity, 1))}.focus-within\:ring-teal-500\/40:focus-within{--tw-ring-color: rgb(20 184 166 / .4)}.hover\:scale-110:hover{--tw-scale-x: 1.1;--tw-scale-y: 1.1;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.hover\:border-border\/80:hover{border-color:hsl(var(--border) / .8)}.hover\:border-foreground\/40:hover{border-color:hsl(var(--foreground) / .4)}.hover\:bg-\[hsl\(var\(--accent\)\)\]:hover,.hover\:bg-accent:hover{background-color:hsl(var(--accent))}.hover\:bg-accent\/50:hover{background-color:hsl(var(--accent) / .5)}.hover\:bg-amber-700:hover{--tw-bg-opacity: 1;background-color:rgb(180 83 9 / var(--tw-bg-opacity, 1))}.hover\:bg-background\/50:hover{background-color:hsl(var(--background) / .5)}.hover\:bg-destructive\/10:hover{background-color:hsl(var(--destructive) / .1)}.hover\:bg-destructive\/20:hover{background-color:hsl(var(--destructive) / .2)}.hover\:bg-destructive\/90:hover{background-color:hsl(var(--destructive) / .9)}.hover\:bg-emerald-500\/20:hover{background-color:#10b98133}.hover\:bg-foreground\/90:hover{background-color:hsl(var(--foreground) / .9)}.hover\:bg-muted:hover{background-color:hsl(var(--muted))}.hover\:bg-muted\/20:hover{background-color:hsl(var(--muted) / .2)}.hover\:bg-muted\/50:hover{background-color:hsl(var(--muted) / .5)}.hover\:bg-muted\/80:hover{background-color:hsl(var(--muted) / .8)}.hover\:bg-primary\/90:hover{background-color:hsl(var(--primary) / .9)}.hover\:bg-teal-500\/10:hover{background-color:#14b8a61a}.hover\:bg-teal-600:hover{--tw-bg-opacity: 1;background-color:rgb(13 148 136 / var(--tw-bg-opacity, 1))}.hover\:bg-violet-500\/10:hover{background-color:#8b5cf61a}.hover\:bg-violet-700:hover{--tw-bg-opacity: 1;background-color:rgb(109 40 217 / var(--tw-bg-opacity, 1))}.hover\:bg-white\/20:hover{background-color:#fff3}.hover\:text-amber-600:hover{--tw-text-opacity: 1;color:rgb(217 119 6 / var(--tw-text-opacity, 1))}.hover\:text-blue-600:hover{--tw-text-opacity: 1;color:rgb(37 99 235 / var(--tw-text-opacity, 1))}.hover\:text-cyan-600:hover{--tw-text-opacity: 1;color:rgb(8 145 178 / var(--tw-text-opacity, 1))}.hover\:text-destructive:hover{color:hsl(var(--destructive))}.hover\:text-destructive\/80:hover{color:hsl(var(--destructive) / .8)}.hover\:text-emerald-600:hover{--tw-text-opacity: 1;color:rgb(5 150 105 / var(--tw-text-opacity, 1))}.hover\:text-foreground:hover{color:hsl(var(--foreground))}.hover\:text-foreground\/80:hover{color:hsl(var(--foreground) / .8)}.hover\:text-green-600\/80:hover{color:#16a34acc}.hover\:text-primary:hover{color:hsl(var(--primary))}.hover\:text-purple-600:hover{--tw-text-opacity: 1;color:rgb(147 51 234 / var(--tw-text-opacity, 1))}.hover\:text-red-500:hover{--tw-text-opacity: 1;color:rgb(239 68 68 / var(--tw-text-opacity, 1))}.hover\:text-red-600:hover{--tw-text-opacity: 1;color:rgb(220 38 38 / var(--tw-text-opacity, 1))}.hover\:text-teal-500:hover{--tw-text-opacity: 1;color:rgb(20 184 166 / var(--tw-text-opacity, 1))}.hover\:underline:hover{text-decoration-line:underline}.hover\:ring-2:hover{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.hover\:ring-primary\/50:hover{--tw-ring-color: hsl(var(--primary) / .5)}.focus\:border-foreground\/30:focus{border-color:hsl(var(--foreground) / .3)}.focus\:border-foreground\/40:focus{border-color:hsl(var(--foreground) / .4)}.focus\:border-ring:focus{border-color:hsl(var(--ring))}.focus\:outline-none:focus{outline:2px solid transparent;outline-offset:2px}.focus\:ring-0:focus{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(0px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.focus\:ring-2:focus{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.focus\:ring-\[hsl\(var\(--ring\)\)\]:focus{--tw-ring-color: hsl(var(--ring))}.focus\:ring-primary:focus{--tw-ring-color: hsl(var(--primary))}.focus\:ring-primary\/50:focus{--tw-ring-color: hsl(var(--primary) / .5)}.focus\:ring-offset-2:focus{--tw-ring-offset-width: 2px}.focus-visible\:outline-none:focus-visible{outline:2px solid transparent;outline-offset:2px}.active\:bg-background\/70:active{background-color:hsl(var(--background) / .7)}.active\:bg-primary\/80:active{background-color:hsl(var(--primary) / .8)}.disabled\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\:opacity-50:disabled{opacity:.5}.group\/code:hover .group-hover\/code\:opacity-100,.group:hover .group-hover\:opacity-100{opacity:1}.dark\:border-amber-800:is(.dark *){--tw-border-opacity: 1;border-color:rgb(146 64 14 / var(--tw-border-opacity, 1))}.dark\:border-blue-500\/20:is(.dark *){border-color:#3b82f633}.dark\:border-red-800:is(.dark *){--tw-border-opacity: 1;border-color:rgb(153 27 27 / var(--tw-border-opacity, 1))}.dark\:border-slate-700:is(.dark *){--tw-border-opacity: 1;border-color:rgb(51 65 85 / var(--tw-border-opacity, 1))}.dark\:border-violet-500\/20:is(.dark *){border-color:#8b5cf633}.dark\:bg-amber-950\/30:is(.dark *){background-color:#451a034d}.dark\:bg-background:is(.dark *){background-color:hsl(var(--background))}.dark\:bg-blue-500\/5:is(.dark *){background-color:#3b82f60d}.dark\:bg-emerald-500\/10:is(.dark *){background-color:#10b9811a}.dark\:bg-orange-950\/20:is(.dark *){background-color:#43140733}.dark\:bg-red-900\/20:is(.dark *){background-color:#7f1d1d33}.dark\:bg-red-950\/20:is(.dark *){background-color:#450a0a33}.dark\:bg-slate-900\/40:is(.dark *){background-color:#0f172a66}.dark\:bg-violet-500\/10:is(.dark *){background-color:#8b5cf61a}.dark\:bg-violet-500\/5:is(.dark *){background-color:#8b5cf60d}.dark\:text-amber-200:is(.dark *){--tw-text-opacity: 1;color:rgb(253 230 138 / var(--tw-text-opacity, 1))}.dark\:text-amber-300:is(.dark *){--tw-text-opacity: 1;color:rgb(252 211 77 / var(--tw-text-opacity, 1))}.dark\:text-amber-400:is(.dark *){--tw-text-opacity: 1;color:rgb(251 191 36 / var(--tw-text-opacity, 1))}.dark\:text-blue-300:is(.dark *){--tw-text-opacity: 1;color:rgb(147 197 253 / var(--tw-text-opacity, 1))}.dark\:text-blue-400:is(.dark *){--tw-text-opacity: 1;color:rgb(96 165 250 / var(--tw-text-opacity, 1))}.dark\:text-cyan-300:is(.dark *){--tw-text-opacity: 1;color:rgb(103 232 249 / var(--tw-text-opacity, 1))}.dark\:text-emerald-300:is(.dark *){--tw-text-opacity: 1;color:rgb(110 231 183 / var(--tw-text-opacity, 1))}.dark\:text-emerald-400:is(.dark *){--tw-text-opacity: 1;color:rgb(52 211 153 / var(--tw-text-opacity, 1))}.dark\:text-foreground\/80:is(.dark *){color:hsl(var(--foreground) / .8)}.dark\:text-green-400:is(.dark *){--tw-text-opacity: 1;color:rgb(74 222 128 / var(--tw-text-opacity, 1))}.dark\:text-green-500:is(.dark *){--tw-text-opacity: 1;color:rgb(34 197 94 / var(--tw-text-opacity, 1))}.dark\:text-green-500\/40:is(.dark *){color:#22c55e66}.dark\:text-green-500\/60:is(.dark *){color:#22c55e99}.dark\:text-indigo-300:is(.dark *){--tw-text-opacity: 1;color:rgb(165 180 252 / var(--tw-text-opacity, 1))}.dark\:text-purple-300:is(.dark *){--tw-text-opacity: 1;color:rgb(216 180 254 / var(--tw-text-opacity, 1))}.dark\:text-red-200:is(.dark *){--tw-text-opacity: 1;color:rgb(254 202 202 / var(--tw-text-opacity, 1))}.dark\:text-red-300:is(.dark *){--tw-text-opacity: 1;color:rgb(252 165 165 / var(--tw-text-opacity, 1))}.dark\:text-red-400:is(.dark *){--tw-text-opacity: 1;color:rgb(248 113 113 / var(--tw-text-opacity, 1))}.dark\:text-red-500:is(.dark *){--tw-text-opacity: 1;color:rgb(239 68 68 / var(--tw-text-opacity, 1))}.dark\:text-teal-300:is(.dark *){--tw-text-opacity: 1;color:rgb(94 234 212 / var(--tw-text-opacity, 1))}.dark\:text-teal-400:is(.dark *){--tw-text-opacity: 1;color:rgb(45 212 191 / var(--tw-text-opacity, 1))}.dark\:text-violet-300:is(.dark *){--tw-text-opacity: 1;color:rgb(196 181 253 / var(--tw-text-opacity, 1))}.dark\:text-violet-400:is(.dark *){--tw-text-opacity: 1;color:rgb(167 139 250 / var(--tw-text-opacity, 1))}.dark\:focus-within\:border-slate-600:focus-within:is(.dark *){--tw-border-opacity: 1;border-color:rgb(71 85 105 / var(--tw-border-opacity, 1))}.dark\:focus-within\:ring-slate-700:focus-within:is(.dark *){--tw-ring-opacity: 1;--tw-ring-color: rgb(51 65 85 / var(--tw-ring-opacity, 1))}.dark\:hover\:text-amber-200:hover:is(.dark *){--tw-text-opacity: 1;color:rgb(253 230 138 / var(--tw-text-opacity, 1))}.dark\:hover\:text-blue-200:hover:is(.dark *){--tw-text-opacity: 1;color:rgb(191 219 254 / var(--tw-text-opacity, 1))}.dark\:hover\:text-cyan-200:hover:is(.dark *){--tw-text-opacity: 1;color:rgb(165 243 252 / var(--tw-text-opacity, 1))}.dark\:hover\:text-emerald-200:hover:is(.dark *){--tw-text-opacity: 1;color:rgb(167 243 208 / var(--tw-text-opacity, 1))}.dark\:hover\:text-green-500\/80:hover:is(.dark *){color:#22c55ecc}.dark\:hover\:text-purple-200:hover:is(.dark *){--tw-text-opacity: 1;color:rgb(233 213 255 / var(--tw-text-opacity, 1))}.dark\:hover\:text-red-200:hover:is(.dark *){--tw-text-opacity: 1;color:rgb(254 202 202 / var(--tw-text-opacity, 1))}@media(min-width:640px){.sm\:block{display:block}.sm\:inline{display:inline}.sm\:flex{display:flex}.sm\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.sm\:px-6{padding-left:1.5rem;padding-right:1.5rem}.sm\:pt-8{padding-top:2rem}.sm\:text-3xl{font-size:1.875rem;line-height:2.25rem}.sm\:text-sm{font-size:.875rem;line-height:1.25rem}}@media(min-width:768px){.md\:relative{position:relative}.md\:col-span-1{grid-column:span 1 / span 1}.md\:col-span-2{grid-column:span 2 / span 2}.md\:mb-0{margin-bottom:0}.md\:inline{display:inline}.md\:flex{display:flex}.md\:hidden{display:none}.md\:h-auto{height:auto}.md\:w-12{width:3rem}.md\:w-64{width:16rem}.md\:w-auto{width:auto}.md\:max-w-2xl{max-width:42rem}.md\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.md\:gap-4{gap:1rem}.md\:gap-x-2{-moz-column-gap:.5rem;column-gap:.5rem}.md\:px-4{padding-left:1rem;padding-right:1rem}.md\:pb-8{padding-bottom:2rem}.md\:pl-3{padding-left:.75rem}.md\:pr-4{padding-right:1rem}.md\:text-sm{font-size:.875rem;line-height:1.25rem}}@media(min-width:1024px){.lg\:px-12{padding-left:3rem;padding-right:3rem}.lg\:pt-12{padding-top:3rem}.lg\:text-4xl{font-size:2.25rem;line-height:2.5rem}}@media(min-width:1280px){.xl\:col-span-2{grid-column:span 2 / span 2}.xl\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.xl\:gap-8{gap:2rem}}.\[\&\>\*\:first-child\]\:mt-0>*:first-child{margin-top:0}.\[\&\>\*\:last-child\]\:mb-0>*:last-child{margin-bottom:0}.\[\&_\*\]\:\[word-break\:break-word\] *{word-break:break-word}.xterm{cursor:text;position:relative;-moz-user-select:none;user-select:none;-ms-user-select:none;-webkit-user-select:none}.xterm.focus,.xterm:focus{outline:none}.xterm .xterm-helpers{position:absolute;top:0;z-index:5}.xterm .xterm-helper-textarea{padding:0;border:0;margin:0;position:absolute;opacity:0;left:-9999em;top:0;width:0;height:0;z-index:-5;white-space:nowrap;overflow:hidden;resize:none}.xterm .composition-view{background:#000;color:#fff;display:none;position:absolute;white-space:nowrap;z-index:1}.xterm .composition-view.active{display:block}.xterm .xterm-viewport{background-color:#000;overflow-y:scroll;cursor:default;position:absolute;inset:0}.xterm .xterm-screen{position:relative}.xterm .xterm-screen canvas{position:absolute;left:0;top:0}.xterm .xterm-scroll-area{visibility:hidden}.xterm-char-measure-element{display:inline-block;visibility:hidden;position:absolute;top:0;left:-9999em;line-height:normal}.xterm.enable-mouse-events{cursor:default}.xterm.xterm-cursor-pointer,.xterm .xterm-cursor-pointer{cursor:pointer}.xterm.column-select.focus{cursor:crosshair}.xterm .xterm-accessibility:not(.debug),.xterm .xterm-message{position:absolute;inset:0;z-index:10;color:transparent;pointer-events:none}.xterm .xterm-accessibility-tree:not(.debug) *::-moz-selection{color:transparent}.xterm .xterm-accessibility-tree:not(.debug) *::selection{color:transparent}.xterm .xterm-accessibility-tree{-webkit-user-select:text;-moz-user-select:text;user-select:text;white-space:pre}.xterm .live-region{position:absolute;left:-9999px;width:1px;height:1px;overflow:hidden}.xterm-dim{opacity:1!important}.xterm-underline-1{text-decoration:underline}.xterm-underline-2{-webkit-text-decoration:double underline;text-decoration:double underline}.xterm-underline-3{-webkit-text-decoration:wavy underline;text-decoration:wavy underline}.xterm-underline-4{-webkit-text-decoration:dotted underline;text-decoration:dotted underline}.xterm-underline-5{-webkit-text-decoration:dashed underline;text-decoration:dashed underline}.xterm-overline{text-decoration:overline}.xterm-overline.xterm-underline-1{text-decoration:overline underline}.xterm-overline.xterm-underline-2{-webkit-text-decoration:overline double underline;text-decoration:overline double underline}.xterm-overline.xterm-underline-3{-webkit-text-decoration:overline wavy underline;text-decoration:overline wavy underline}.xterm-overline.xterm-underline-4{-webkit-text-decoration:overline dotted underline;text-decoration:overline dotted underline}.xterm-overline.xterm-underline-5{-webkit-text-decoration:overline dashed underline;text-decoration:overline dashed underline}.xterm-strikethrough{text-decoration:line-through}.xterm-screen .xterm-decoration-container .xterm-decoration{z-index:6;position:absolute}.xterm-screen .xterm-decoration-container .xterm-decoration.xterm-decoration-top-layer{z-index:7}.xterm-decoration-overview-ruler{z-index:8;position:absolute;top:0;right:0;pointer-events:none}.xterm-decoration-top{z-index:2;position:relative}
|
|
@@ -143,4 +143,4 @@ ${u?.absPath||""}`,children:n}),i&&m.jsx("span",{className:"text-xs px-2 py-0.5
|
|
|
143
143
|
`),n=[];let i=0,s=0,l=!1,c="";for(const o of t){if(o.startsWith("+++")||o.startsWith("*** Update File:")){const d=o.match(/\+\+\+ b\/(.+)/)||o.match(/\*\*\* Update File: (.+)/);d&&(c=d[1])}if(o.startsWith("*** Add File:")){const d=o.match(/\*\*\* Add File: (.+)/);d&&(c=d[1])}const u=o.match(/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/);if(u){i=Number.parseInt(u[1],10),s=Number.parseInt(u[2],10),l=!0,n.push({content:o,codeContent:o,type:"header"});continue}if(o.startsWith("***")||o.startsWith("diff ")||o.startsWith("index ")||o.startsWith("---")||o.startsWith("+++")||o.startsWith("@@")&&!l){n.push({content:o,codeContent:o,type:"meta"});continue}l?o.startsWith("+")?n.push({content:o,codeContent:o.slice(1),type:"add",newLineNum:s++}):o.startsWith("-")?n.push({content:o,codeContent:o.slice(1),type:"remove",oldLineNum:i++}):o.startsWith(" ")||o===""?n.push({content:o,codeContent:o.startsWith(" ")?o.slice(1):o,type:"context",oldLineNum:i++,newLineNum:s++}):n.push({content:o,codeContent:o,type:"context",oldLineNum:i++,newLineNum:s++}):n.push({content:o,codeContent:o,type:"meta"})}return{lines:n,filePath:c}}function Vee({patch:e}){const{lines:t,filePath:n}=Wee(e),i=Gee(n),s=document?.documentElement.classList.contains("dark")?si:Ir;return m.jsx("div",{className:"bg-card/60 border border-border rounded-lg overflow-hidden h-full",children:m.jsx("div",{className:"overflow-x-auto overflow-y-auto h-full text-xs font-mono",children:t.map((l,c)=>{const o=`line-${c}-${l.content.slice(0,20)}`;if(l.type==="meta"||l.type==="header")return m.jsx("div",{className:`px-3 py-0.5 whitespace-pre-wrap break-all ${l.type==="header"?"text-muted-foreground/80 bg-muted/20":"text-muted-foreground/80"}`,children:l.content},o);let u="",d="";switch(l.type){case"add":u="text-emerald-700 dark:text-emerald-300",d="bg-emerald-500/10";break;case"remove":u="text-red-600 dark:text-red-300",d="bg-red-500/10";break;default:u="text-foreground/80"}let p=l.content;return l.codeContent.trim()&&i!=="text"&&(p=m.jsx(Rn,{language:i,style:s,customStyle:{margin:0,padding:0,background:"transparent",display:"inline",fontSize:"inherit",lineHeight:"inherit"},codeTagProps:{style:{fontFamily:"inherit",background:"transparent"}},PreTag:"span",children:l.codeContent}),l.type==="add"?p=m.jsxs(m.Fragment,{children:[m.jsx("span",{className:"select-none",children:"+"}),p]}):l.type==="remove"?p=m.jsxs(m.Fragment,{children:[m.jsx("span",{className:"select-none",children:"-"}),p]}):l.type==="context"&&(p=m.jsxs(m.Fragment,{children:[m.jsx("span",{className:"select-none",children:" "}),p]}))),m.jsxs("div",{className:`flex ${d}`,children:[m.jsx("div",{className:"px-2 py-0.5 text-right text-muted-foreground/40 select-none w-12 flex-shrink-0",children:l.oldLineNum||""}),m.jsx("div",{className:"px-2 py-0.5 text-right text-muted-foreground/40 select-none w-12 flex-shrink-0 border-r border-border/50",children:l.newLineNum||""}),m.jsx("div",{className:`px-3 py-0.5 flex-1 min-w-0 whitespace-pre-wrap break-all ${u}`,children:p})]},o)})})})}function Kee(e){return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}const Yee=z.memo(function(){const t=Xt(v=>v.isDiffOpen),n=Xt(v=>v.selectedFile),i=Xt(v=>v.allOperations),s=Xt(v=>v.selectedOperationIndex),l=Xt(v=>v.selectOperation),c=Xt(v=>v.closeDiff),o=Ca(v=>v.setCollapsed),u=z.useRef(null),d=z.useRef(!1),p=i[s],f=z.useMemo(()=>{if(!p||!n)return null;let v=null;if(p.artifact?.patch)v=p.artifact.patch;else if(p.patch)v=p.patch;else if(p.content){const E=p.content.split(`
|
|
144
144
|
`);v=`*** Add File: ${n}
|
|
145
145
|
${E.map(y=>`+${y}`).join(`
|
|
146
|
-
`)}`}return v?/@@ -\d+(?:,\d+)? \+\d+(?:,\d+)? @@/.test(v)?v:$ee(v):null},[p,n]);if(z.useEffect(()=>{if(t&&!d.current){const{isCollapsed:v}=Ca.getState();u.current=v,o(!0)}else!t&&d.current&&u.current!==null&&(o(u.current),u.current=null);d.current=t},[t,o]),z.useEffect(()=>{const v=w=>{const E=w.target,y=E.tagName==="INPUT"||E.tagName==="TEXTAREA"||E.isContentEditable;(w.key==="Escape"||w.key==="q"&&!y)&&t&&c(),!y&&t&&i.length>1&&(w.key==="ArrowLeft"||w.key==="["?(w.preventDefault(),l(Math.max(0,s-1))):(w.key==="ArrowRight"||w.key==="]")&&(w.preventDefault(),l(Math.min(i.length-1,s+1))))};return document.addEventListener("keydown",v),()=>document.removeEventListener("keydown",v)},[t,c,i.length,s,l]),!t||!n||!p)return null;const g=i.length>1;return m.jsxs("div",{className:"absolute inset-0 bg-background z-50 flex flex-col animate-in slide-in-from-left duration-300",children:[m.jsxs("div",{className:"h-14 border-b border-border px-4 flex items-center gap-3 shrink-0",children:[m.jsx(st,{variant:"ghost",size:"icon",onClick:c,title:"Close diff viewer (ESC)",children:m.jsx(cn,{className:"w-4 h-4"})}),m.jsxs("div",{className:"flex-1 flex items-center gap-2 min-w-0",children:[m.jsx("span",{className:"text-sm font-medium text-foreground font-mono truncate",title:n,children:n}),m.jsx("span",{className:"text-xs px-2 py-0.5 rounded bg-primary/10 text-primary flex-shrink-0 capitalize",children:p.operation}),p.artifact?.summary&&m.jsxs("div",{className:"flex items-center gap-1 text-xs flex-shrink-0",children:[m.jsxs("span",{className:"text-green-500",children:["+",p.artifact.summary.additions]}),m.jsxs("span",{className:"text-red-500",children:["-",p.artifact.summary.deletions]})]})]}),g&&m.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[m.jsx(st,{variant:"ghost",size:"icon",onClick:()=>l(Math.max(0,s-1)),disabled:s===0,title:"Previous operation (←)",children:m.jsx(oj,{className:"w-4 h-4"})}),m.jsxs("span",{className:"text-xs text-muted-foreground min-w-[60px] text-center",children:[s+1," / ",i.length]}),m.jsx(st,{variant:"ghost",size:"icon",onClick:()=>l(Math.min(i.length-1,s+1)),disabled:s===i.length-1,title:"Next operation (→)",children:m.jsx(an,{className:"w-4 h-4"})})]})]}),g&&m.jsx("div",{className:"border-b border-border px-4 py-2 flex gap-2 overflow-x-auto shrink-0",children:i.map((v,w)=>m.jsxs("button",{type:"button",onClick:()=>l(w),className:`px-3 py-1.5 text-xs rounded-md flex items-center gap-2 shrink-0 transition-colors ${w===s?"bg-primary text-primary-foreground":"bg-muted hover:bg-muted/80 text-muted-foreground"}`,children:[m.jsx("span",{className:"capitalize",children:v.operation}),m.jsx("span",{className:"opacity-70",children:Kee(v.timestamp)}),v.artifact?.summary&&m.jsxs("span",{className:"opacity-70",children:["+",v.artifact.summary.additions,"/-",v.artifact.summary.deletions]})]},v.toolCallId))}),m.jsx("div",{className:"flex-1 overflow-hidden p-4",children:f?m.jsx(Vee,{patch:f}):m.jsx("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:"No diff content available"})})]})}),Xee={};class Zee{get baseUrl(){const t=window;if(t.AGI_SERVER_URL)return t.AGI_SERVER_URL;if(!Xee?.VITE_API_BASE_URL)return Hc}async listResearchSessions(t){const n=await fetch(`${this.baseUrl}/v1/sessions/${t}/research`,{method:"GET",headers:{"Content-Type":"application/json"}});if(!n.ok){const i=await n.json().catch(()=>({error:"Failed to fetch research sessions"}));throw new Error(i.error||"Failed to fetch research sessions")}return n.json()}async createResearchSession(t,n){const i=await fetch(`${this.baseUrl}/v1/sessions/${t}/research`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!i.ok){const s=await i.json().catch(()=>({error:"Failed to create research session"}));throw new Error(s.error||"Failed to create research session")}return i.json()}async deleteResearchSession(t){const n=await fetch(`${this.baseUrl}/v1/research/${t}`,{method:"DELETE",headers:{"Content-Type":"application/json"}});if(!n.ok){const i=await n.json().catch(()=>({error:"Failed to delete research session"}));throw new Error(i.error||"Failed to delete research session")}return n.json()}async injectContext(t,n,i){const s=await fetch(`${this.baseUrl}/v1/sessions/${t}/inject`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({researchSessionId:n,label:i})});if(!s.ok){const l=await s.json().catch(()=>({error:"Failed to inject context"}));throw new Error(l.error||"Failed to inject context")}return s.json()}async exportToNewSession(t,n){const i=await fetch(`${this.baseUrl}/v1/research/${t}/export`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n??{})});if(!i.ok){const s=await i.json().catch(()=>({error:"Failed to export to session"}));throw new Error(s.error||"Failed to export to session")}return i.json()}}const rd=new Zee;function N5(e){return Vn({queryKey:["research","sessions",e],queryFn:()=>rd.listResearchSessions(e),enabled:!!e,staleTime:3e4})}function Qee(){const e=Ot();return Zt({mutationFn:({parentSessionId:t,data:n})=>rd.createResearchSession(t,n??{}),onSuccess:(t,{parentSessionId:n})=>{e.invalidateQueries({queryKey:["research","sessions",n]})}})}function Jee(){const e=nc(t=>t.addContext);return Zt({mutationFn:({parentSessionId:t,researchSessionId:n,label:i})=>rd.injectContext(t,n,i),onSuccess:(t,{parentSessionId:n})=>{e(n,{id:t.sessionId,sessionId:t.sessionId,label:t.label,content:t.content})}})}function ete(){const e=Ot();return Zt({mutationFn:({researchId:t,data:n})=>rd.exportToNewSession(t,n),onSuccess:()=>{e.invalidateQueries({queryKey:["sessions"]})}})}const tte=z.memo(function({parentSessionId:t,onNavigateToSession:n}){const i=zn(q=>q.isExpanded),s=zn(q=>q.collapseSidebar),l=zn(q=>q.activeResearchSessionId),c=zn(q=>q.selectResearchSession),[o,u]=z.useState(!1),[d,p]=z.useState(""),[f,g]=z.useState(!1),[v,w]=z.useState("idle"),E=z.useRef(null),y=z.useRef(null),{data:S,isLoading:x,refetch:_}=N5(t),C=Qee(),O=Jee(),T=ete(),{data:N}=$c(),{data:A}=_c(l??void 0),{data:D}=_c(t??void 0);A5(l??void 0);const L=zD(l??""),I=Ot(),j=Zt({mutationFn:async({sessionId:q,content:te})=>Te.sendMessage(q,{content:te}),onSuccess:(q,{sessionId:te})=>{I.invalidateQueries({queryKey:["messages",te]})}});z.useEffect(()=>{t&&zn.getState().setParentSessionId(t)},[t]),z.useEffect(()=>{S?.sessions?.length?S.sessions.some(te=>te.id===l)||c(S.sessions[0].id):S?.sessions?.length===0&&c(null)},[S,l,c]),z.useEffect(()=>{y.current?.scrollIntoView({behavior:"smooth"})},[]);const F=z.useCallback(()=>{const q=E.current;q&&(q.style.height="auto",q.style.height=`${Math.min(q.scrollHeight,120)}px`)},[]);z.useEffect(()=>{F()},[F]);const V=z.useCallback(async()=>{if(t)try{const q=await C.mutateAsync({parentSessionId:t,data:{}});await _(),c(q.session.id),u(!1)}catch(q){console.error("Failed to create research session:",q)}},[t,C,c,_]),Y=z.useCallback(q=>{c(q.id),u(!1)},[c]),W=z.useCallback(async()=>{if(!t||!l)return;if(D?.some(be=>be.role==="system"&&be.parts?.some(Ee=>typeof Ee.content=="string"&&Ee.content.includes(`from="${l}"`)))){w("error"),setTimeout(()=>w("idle"),3e3);return}const se=`Research ${new Date().toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}`;try{await O.mutateAsync({parentSessionId:t,researchSessionId:l,label:se}),w("success"),setTimeout(()=>w("idle"),5e3),I.invalidateQueries({queryKey:["messages",t]})}catch(be){console.error("Failed to inject context:",be),w("error"),setTimeout(()=>w("idle"),3e3)}},[t,l,O,D,I]),K=z.useCallback(async()=>{if(l)try{const q=await T.mutateAsync({researchId:l});n&&q.newSession?.id&&n(q.newSession.id)}catch(q){console.error("Failed to export to session:",q)}},[l,T,n]),X=z.useCallback(async()=>{if(!(!d.trim()||!t))try{let q=l;q||(q=(await C.mutateAsync({parentSessionId:t,data:{}})).session.id,c(q)),await j.mutateAsync({sessionId:q,content:d}),p(""),E.current&&(E.current.style.height="auto")}catch(q){console.error("Failed to send message:",q)}},[d,t,l,C,c,j]),B=z.useCallback(q=>{q.key==="Enter"&&!q.shiftKey&&(q.preventDefault(),X())},[X]),M=z.useMemo(()=>A?.some(q=>q.role==="assistant"&&q.status==="pending")??!1,[A]),U=z.useMemo(()=>!l||!D?!1:D.some(q=>q.role==="system"&&q.parts?.some(te=>typeof te.content=="string"&&te.content.includes(`from="${l}"`))),[l,D]),$=z.useCallback(async(q,te)=>{if(l)try{await L.mutateAsync({provider:q,model:te}),g(!1)}catch(he){console.error("Failed to update research session model:",he)}},[l,L]);if(!i)return null;const H=S?.sessions??[],J=H.find(q=>q.id===l),oe=A??[],de=N?.[J?.provider??""]?.label??J?.provider,Z=N?.[J?.provider??""]?.models.find(q=>q.id===J?.model)?.label??J?.model;return m.jsxs("div",{className:"w-96 border-l border-border bg-background flex flex-col h-full",children:[m.jsxs("div",{className:"h-14 border-b border-border px-3 flex items-center justify-between",children:[m.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[m.jsx(el,{className:"w-4 h-4 text-teal-500"}),m.jsx("span",{className:"font-medium text-foreground text-sm",children:"Research"})]}),m.jsxs("div",{className:"flex items-center gap-0.5",children:[m.jsx(st,{variant:"ghost",size:"icon",onClick:()=>u(!o),title:"Research history",className:"h-8 w-8",children:m.jsx(nB,{className:"w-4 h-4"})}),m.jsx(st,{variant:"ghost",size:"icon",onClick:V,disabled:!t||C.isPending,title:"New research session",className:"h-8 w-8",children:C.isPending?m.jsx(rn,{className:"w-4 h-4 animate-spin"}):m.jsx(Ts,{className:"w-4 h-4"})}),m.jsx(st,{variant:"ghost",size:"icon",onClick:s,title:"Close sidebar",className:"h-8 w-8",children:m.jsx(an,{className:"w-4 h-4"})})]})]}),o?m.jsxs("div",{className:"flex-1 overflow-y-auto",children:[m.jsx("div",{className:"p-2 border-b border-border",children:m.jsx("div",{className:"text-xs font-medium text-muted-foreground px-2 py-1",children:"Research Sessions"})}),x?m.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:"Loading..."}):H.length===0?m.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:"No research sessions yet"}):m.jsx("div",{className:"p-2 space-y-1",children:H.map(q=>m.jsxs("button",{type:"button",onClick:()=>Y(q),className:`w-full text-left p-2 rounded-md text-sm transition-colors ${q.id===l?"bg-teal-500/10 border border-teal-500/30 text-foreground":"hover:bg-muted"}`,children:[m.jsx("div",{className:"font-medium truncate",children:q.title||"Untitled"}),m.jsxs("div",{className:"text-xs text-muted-foreground",children:[q.messageCount," messages •"," ",nte(q.lastActiveAt??q.createdAt)]})]},q.id))})]}):m.jsxs(m.Fragment,{children:[m.jsx("div",{className:"flex-1 overflow-y-auto px-3 py-3 research-messages text-[13px]",children:l?oe.length===0?m.jsx("div",{className:"text-xs text-muted-foreground text-center py-8",children:m.jsx("p",{children:"Ask a question to start researching."})}):m.jsxs("div",{className:"space-y-1.5",children:[oe.map((q,te)=>{if(q.role==="user"){const he=oe[te+1];return m.jsx(w5,{sessionId:l,message:q,isFirst:te===0,nextAssistantMessageId:he?.role==="assistant"?he.id:void 0},q.id)}if(q.role==="assistant"){const he=te>0?oe[te-1]:null,se=oe[te+1],be=he?.role!=="assistant",Ee=se?.role==="assistant";return m.jsx(E5,{sessionId:l,message:q,showHeader:be,hasNextAssistantMessage:Ee,isLastMessage:te===oe.length-1,compact:!0,onNavigateToSession:n},q.id)}return null}),m.jsx("div",{ref:y})]}):m.jsxs("div",{className:"text-xs text-muted-foreground text-center py-8",children:[m.jsx(el,{className:"w-8 h-8 mx-auto mb-2 text-muted-foreground/50"}),m.jsx("p",{children:"Start researching by asking a question below."})]})}),m.jsxs("div",{className:"p-3 border-t border-border",children:[m.jsx("div",{className:"relative flex flex-col rounded-3xl bg-card border border-border focus-within:border-teal-500/60 focus-within:ring-1 focus-within:ring-teal-500/40 p-1",children:m.jsxs("div",{className:"flex items-end gap-1",children:[m.jsx(zc,{ref:E,value:d,onChange:q=>p(q.target.value),onKeyDown:B,placeholder:"Ask anything...",disabled:!t||j.isPending||C.isPending,rows:1,className:"flex-1 border-0 bg-transparent pl-2 pr-1 py-2 max-h-[120px] overflow-y-auto leading-normal resize-none scrollbar-hide text-sm focus:ring-0 focus:outline-none",style:{height:"2.25rem"}}),m.jsx("button",{type:"button",onClick:X,disabled:!d.trim()||!t||j.isPending||C.isPending||M,className:`flex items-center justify-center w-9 h-9 rounded-full transition-colors flex-shrink-0 ${d.trim()&&t&&!M?"bg-teal-500 hover:bg-teal-600 text-white":"bg-transparent text-muted-foreground"}`,children:j.isPending||C.isPending?m.jsx(rn,{className:"w-4 h-4 animate-spin"}):m.jsx(PO,{className:"w-4 h-4"})})]})}),v==="success"&&m.jsxs("div",{className:"flex items-center gap-2 mt-2 px-2 py-1.5 text-xs rounded-lg bg-teal-500/10 border border-teal-500/30 text-teal-600 dark:text-teal-400",children:[m.jsx(ti,{className:"w-3 h-3 flex-shrink-0"}),m.jsx("span",{className:"flex-1",children:"Context injected — will be used on next request"}),m.jsx("button",{type:"button",onClick:()=>w("idle"),className:"hover:text-teal-500",children:m.jsx(cn,{className:"w-3 h-3"})})]}),v==="error"&&m.jsxs("div",{className:"flex items-center gap-2 mt-2 px-2 py-1.5 text-xs rounded-lg bg-red-500/10 border border-red-500/30 text-red-600 dark:text-red-400",children:[m.jsx(cn,{className:"w-3 h-3 flex-shrink-0"}),m.jsx("span",{className:"flex-1",children:"Failed to inject context"}),m.jsx("button",{type:"button",onClick:()=>w("idle"),className:"hover:text-red-500",children:m.jsx(cn,{className:"w-3 h-3"})})]}),m.jsxs("div",{className:"flex gap-2 mt-2",children:[m.jsxs("button",{type:"button",onClick:W,disabled:!l||O.isPending||M||U,className:`flex-1 flex items-center justify-center gap-1.5 px-2 py-1.5 text-xs rounded-lg transition-colors disabled:opacity-50 disabled:cursor-not-allowed ${U?"bg-teal-500/10 text-teal-600 dark:text-teal-400 border border-teal-500/30":"bg-muted hover:bg-muted/80 text-muted-foreground hover:text-foreground"}`,title:U?"Already injected into main session":"Inject findings into main session",children:[O.isPending?m.jsx(rn,{className:"w-3 h-3 animate-spin"}):U?m.jsx(ti,{className:"w-3 h-3"}):m.jsx($6,{className:"w-3 h-3"}),U?"Injected":"Inject"]}),m.jsxs("button",{type:"button",onClick:K,disabled:!l||T.isPending||M,className:"flex-1 flex items-center justify-center gap-1.5 px-2 py-1.5 text-xs rounded-lg bg-muted hover:bg-muted/80 text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50 disabled:cursor-not-allowed",title:"Export to new main session",children:[T.isPending?m.jsx(rn,{className:"w-3 h-3 animate-spin"}):m.jsx(Gn,{className:"w-3 h-3"}),"Export"]})]})]})]}),m.jsxs("div",{className:"h-12 px-3 border-t border-border text-xs text-muted-foreground flex items-center justify-between",children:[m.jsxs("span",{className:"text-[10px]",children:[H.length," research session",H.length!==1?"s":""]}),J&&m.jsxs("button",{type:"button",onClick:()=>g(!0),className:"flex items-center gap-1 text-[10px] hover:text-foreground transition-colors",children:[m.jsx("span",{className:"opacity-60",children:de}),m.jsx("span",{className:"opacity-40",children:"/"}),m.jsx("span",{children:Z}),m.jsx(mr,{className:"w-3 h-3 opacity-40"})]})]}),m.jsx(Ea,{isOpen:f,onClose:()=>g(!1),title:"Select Model for Research",maxWidth:"md",children:J&&m.jsx(YD,{provider:J.provider,model:J.model,onChange:$})})]})});function nte(e){const t=Date.now()-e,n=Math.floor(t/6e4);if(n<1)return"just now";if(n<60)return`${n}m ago`;const i=Math.floor(n/60);return i<24?`${i}h ago`:`${Math.floor(i/24)}d ago`}const rte=z.memo(function({parentSessionId:t}){const n=zn(c=>c.isExpanded),i=zn(c=>c.toggleSidebar),{data:s}=N5(t??null),l=s?.sessions?.length??0;return m.jsxs("button",{type:"button",onClick:i,className:`relative h-14 w-full transition-colors touch-manipulation flex items-center justify-center ${n?"bg-muted border-r-2 border-primary":"hover:bg-muted/50"}`,title:"Research (⌘⇧R)",children:[m.jsx(el,{className:"w-5 h-5 text-muted-foreground mx-auto"}),l>0&&m.jsx("span",{className:"absolute top-1 right-1 w-5 h-5 bg-primary text-primary-foreground text-xs rounded-full flex items-center justify-center font-semibold",children:l>9?"9+":l})]})});var ite=Object.defineProperty,Tc=Object.getOwnPropertySymbols,O5=Object.prototype.hasOwnProperty,D5=Object.prototype.propertyIsEnumerable,ZN=(e,t,n)=>t in e?ite(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Dv=(e,t)=>{for(var n in t||(t={}))O5.call(t,n)&&ZN(e,n,t[n]);if(Tc)for(var n of Tc(t))D5.call(t,n)&&ZN(e,n,t[n]);return e},Iv=(e,t)=>{var n={};for(var i in e)O5.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(e!=null&&Tc)for(var i of Tc(e))t.indexOf(i)<0&&D5.call(e,i)&&(n[i]=e[i]);return n};var ka;(e=>{const t=class Ye{constructor(u,d,p,f){if(this.version=u,this.errorCorrectionLevel=d,this.modules=[],this.isFunction=[],u<Ye.MIN_VERSION||u>Ye.MAX_VERSION)throw new RangeError("Version value out of range");if(f<-1||f>7)throw new RangeError("Mask value out of range");this.size=u*4+17;let g=[];for(let w=0;w<this.size;w++)g.push(!1);for(let w=0;w<this.size;w++)this.modules.push(g.slice()),this.isFunction.push(g.slice());this.drawFunctionPatterns();const v=this.addEccAndInterleave(p);if(this.drawCodewords(v),f==-1){let w=1e9;for(let E=0;E<8;E++){this.applyMask(E),this.drawFormatBits(E);const y=this.getPenaltyScore();y<w&&(f=E,w=y),this.applyMask(E)}}s(0<=f&&f<=7),this.mask=f,this.applyMask(f),this.drawFormatBits(f),this.isFunction=[]}static encodeText(u,d){const p=e.QrSegment.makeSegments(u);return Ye.encodeSegments(p,d)}static encodeBinary(u,d){const p=e.QrSegment.makeBytes(u);return Ye.encodeSegments([p],d)}static encodeSegments(u,d,p=1,f=40,g=-1,v=!0){if(!(Ye.MIN_VERSION<=p&&p<=f&&f<=Ye.MAX_VERSION)||g<-1||g>7)throw new RangeError("Invalid value");let w,E;for(w=p;;w++){const _=Ye.getNumDataCodewords(w,d)*8,C=c.getTotalBits(u,w);if(C<=_){E=C;break}if(w>=f)throw new RangeError("Data too long")}for(const _ of[Ye.Ecc.MEDIUM,Ye.Ecc.QUARTILE,Ye.Ecc.HIGH])v&&E<=Ye.getNumDataCodewords(w,_)*8&&(d=_);let y=[];for(const _ of u){n(_.mode.modeBits,4,y),n(_.numChars,_.mode.numCharCountBits(w),y);for(const C of _.getData())y.push(C)}s(y.length==E);const S=Ye.getNumDataCodewords(w,d)*8;s(y.length<=S),n(0,Math.min(4,S-y.length),y),n(0,(8-y.length%8)%8,y),s(y.length%8==0);for(let _=236;y.length<S;_^=253)n(_,8,y);let x=[];for(;x.length*8<y.length;)x.push(0);return y.forEach((_,C)=>x[C>>>3]|=_<<7-(C&7)),new Ye(w,d,x,g)}getModule(u,d){return 0<=u&&u<this.size&&0<=d&&d<this.size&&this.modules[d][u]}getModules(){return this.modules}drawFunctionPatterns(){for(let p=0;p<this.size;p++)this.setFunctionModule(6,p,p%2==0),this.setFunctionModule(p,6,p%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);const u=this.getAlignmentPatternPositions(),d=u.length;for(let p=0;p<d;p++)for(let f=0;f<d;f++)p==0&&f==0||p==0&&f==d-1||p==d-1&&f==0||this.drawAlignmentPattern(u[p],u[f]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(u){const d=this.errorCorrectionLevel.formatBits<<3|u;let p=d;for(let g=0;g<10;g++)p=p<<1^(p>>>9)*1335;const f=(d<<10|p)^21522;s(f>>>15==0);for(let g=0;g<=5;g++)this.setFunctionModule(8,g,i(f,g));this.setFunctionModule(8,7,i(f,6)),this.setFunctionModule(8,8,i(f,7)),this.setFunctionModule(7,8,i(f,8));for(let g=9;g<15;g++)this.setFunctionModule(14-g,8,i(f,g));for(let g=0;g<8;g++)this.setFunctionModule(this.size-1-g,8,i(f,g));for(let g=8;g<15;g++)this.setFunctionModule(8,this.size-15+g,i(f,g));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let u=this.version;for(let p=0;p<12;p++)u=u<<1^(u>>>11)*7973;const d=this.version<<12|u;s(d>>>18==0);for(let p=0;p<18;p++){const f=i(d,p),g=this.size-11+p%3,v=Math.floor(p/3);this.setFunctionModule(g,v,f),this.setFunctionModule(v,g,f)}}drawFinderPattern(u,d){for(let p=-4;p<=4;p++)for(let f=-4;f<=4;f++){const g=Math.max(Math.abs(f),Math.abs(p)),v=u+f,w=d+p;0<=v&&v<this.size&&0<=w&&w<this.size&&this.setFunctionModule(v,w,g!=2&&g!=4)}}drawAlignmentPattern(u,d){for(let p=-2;p<=2;p++)for(let f=-2;f<=2;f++)this.setFunctionModule(u+f,d+p,Math.max(Math.abs(f),Math.abs(p))!=1)}setFunctionModule(u,d,p){this.modules[d][u]=p,this.isFunction[d][u]=!0}addEccAndInterleave(u){const d=this.version,p=this.errorCorrectionLevel;if(u.length!=Ye.getNumDataCodewords(d,p))throw new RangeError("Invalid argument");const f=Ye.NUM_ERROR_CORRECTION_BLOCKS[p.ordinal][d],g=Ye.ECC_CODEWORDS_PER_BLOCK[p.ordinal][d],v=Math.floor(Ye.getNumRawDataModules(d)/8),w=f-v%f,E=Math.floor(v/f);let y=[];const S=Ye.reedSolomonComputeDivisor(g);for(let _=0,C=0;_<f;_++){let O=u.slice(C,C+E-g+(_<w?0:1));C+=O.length;const T=Ye.reedSolomonComputeRemainder(O,S);_<w&&O.push(0),y.push(O.concat(T))}let x=[];for(let _=0;_<y[0].length;_++)y.forEach((C,O)=>{(_!=E-g||O>=w)&&x.push(C[_])});return s(x.length==v),x}drawCodewords(u){if(u.length!=Math.floor(Ye.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let d=0;for(let p=this.size-1;p>=1;p-=2){p==6&&(p=5);for(let f=0;f<this.size;f++)for(let g=0;g<2;g++){const v=p-g,E=(p+1&2)==0?this.size-1-f:f;!this.isFunction[E][v]&&d<u.length*8&&(this.modules[E][v]=i(u[d>>>3],7-(d&7)),d++)}}s(d==u.length*8)}applyMask(u){if(u<0||u>7)throw new RangeError("Mask value out of range");for(let d=0;d<this.size;d++)for(let p=0;p<this.size;p++){let f;switch(u){case 0:f=(p+d)%2==0;break;case 1:f=d%2==0;break;case 2:f=p%3==0;break;case 3:f=(p+d)%3==0;break;case 4:f=(Math.floor(p/3)+Math.floor(d/2))%2==0;break;case 5:f=p*d%2+p*d%3==0;break;case 6:f=(p*d%2+p*d%3)%2==0;break;case 7:f=((p+d)%2+p*d%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[d][p]&&f&&(this.modules[d][p]=!this.modules[d][p])}}getPenaltyScore(){let u=0;for(let g=0;g<this.size;g++){let v=!1,w=0,E=[0,0,0,0,0,0,0];for(let y=0;y<this.size;y++)this.modules[g][y]==v?(w++,w==5?u+=Ye.PENALTY_N1:w>5&&u++):(this.finderPenaltyAddHistory(w,E),v||(u+=this.finderPenaltyCountPatterns(E)*Ye.PENALTY_N3),v=this.modules[g][y],w=1);u+=this.finderPenaltyTerminateAndCount(v,w,E)*Ye.PENALTY_N3}for(let g=0;g<this.size;g++){let v=!1,w=0,E=[0,0,0,0,0,0,0];for(let y=0;y<this.size;y++)this.modules[y][g]==v?(w++,w==5?u+=Ye.PENALTY_N1:w>5&&u++):(this.finderPenaltyAddHistory(w,E),v||(u+=this.finderPenaltyCountPatterns(E)*Ye.PENALTY_N3),v=this.modules[y][g],w=1);u+=this.finderPenaltyTerminateAndCount(v,w,E)*Ye.PENALTY_N3}for(let g=0;g<this.size-1;g++)for(let v=0;v<this.size-1;v++){const w=this.modules[g][v];w==this.modules[g][v+1]&&w==this.modules[g+1][v]&&w==this.modules[g+1][v+1]&&(u+=Ye.PENALTY_N2)}let d=0;for(const g of this.modules)d=g.reduce((v,w)=>v+(w?1:0),d);const p=this.size*this.size,f=Math.ceil(Math.abs(d*20-p*10)/p)-1;return s(0<=f&&f<=9),u+=f*Ye.PENALTY_N4,s(0<=u&&u<=2568888),u}getAlignmentPatternPositions(){if(this.version==1)return[];{const u=Math.floor(this.version/7)+2,d=this.version==32?26:Math.ceil((this.version*4+4)/(u*2-2))*2;let p=[6];for(let f=this.size-7;p.length<u;f-=d)p.splice(1,0,f);return p}}static getNumRawDataModules(u){if(u<Ye.MIN_VERSION||u>Ye.MAX_VERSION)throw new RangeError("Version number out of range");let d=(16*u+128)*u+64;if(u>=2){const p=Math.floor(u/7)+2;d-=(25*p-10)*p-55,u>=7&&(d-=36)}return s(208<=d&&d<=29648),d}static getNumDataCodewords(u,d){return Math.floor(Ye.getNumRawDataModules(u)/8)-Ye.ECC_CODEWORDS_PER_BLOCK[d.ordinal][u]*Ye.NUM_ERROR_CORRECTION_BLOCKS[d.ordinal][u]}static reedSolomonComputeDivisor(u){if(u<1||u>255)throw new RangeError("Degree out of range");let d=[];for(let f=0;f<u-1;f++)d.push(0);d.push(1);let p=1;for(let f=0;f<u;f++){for(let g=0;g<d.length;g++)d[g]=Ye.reedSolomonMultiply(d[g],p),g+1<d.length&&(d[g]^=d[g+1]);p=Ye.reedSolomonMultiply(p,2)}return d}static reedSolomonComputeRemainder(u,d){let p=d.map(f=>0);for(const f of u){const g=f^p.shift();p.push(0),d.forEach((v,w)=>p[w]^=Ye.reedSolomonMultiply(v,g))}return p}static reedSolomonMultiply(u,d){if(u>>>8||d>>>8)throw new RangeError("Byte out of range");let p=0;for(let f=7;f>=0;f--)p=p<<1^(p>>>7)*285,p^=(d>>>f&1)*u;return s(p>>>8==0),p}finderPenaltyCountPatterns(u){const d=u[1];s(d<=this.size*3);const p=d>0&&u[2]==d&&u[3]==d*3&&u[4]==d&&u[5]==d;return(p&&u[0]>=d*4&&u[6]>=d?1:0)+(p&&u[6]>=d*4&&u[0]>=d?1:0)}finderPenaltyTerminateAndCount(u,d,p){return u&&(this.finderPenaltyAddHistory(d,p),d=0),d+=this.size,this.finderPenaltyAddHistory(d,p),this.finderPenaltyCountPatterns(p)}finderPenaltyAddHistory(u,d){d[0]==0&&(u+=this.size),d.pop(),d.unshift(u)}};t.MIN_VERSION=1,t.MAX_VERSION=40,t.PENALTY_N1=3,t.PENALTY_N2=3,t.PENALTY_N3=40,t.PENALTY_N4=10,t.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],t.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],e.QrCode=t;function n(o,u,d){if(u<0||u>31||o>>>u)throw new RangeError("Value out of range");for(let p=u-1;p>=0;p--)d.push(o>>>p&1)}function i(o,u){return(o>>>u&1)!=0}function s(o){if(!o)throw new Error("Assertion error")}const l=class Mt{constructor(u,d,p){if(this.mode=u,this.numChars=d,this.bitData=p,d<0)throw new RangeError("Invalid argument");this.bitData=p.slice()}static makeBytes(u){let d=[];for(const p of u)n(p,8,d);return new Mt(Mt.Mode.BYTE,u.length,d)}static makeNumeric(u){if(!Mt.isNumeric(u))throw new RangeError("String contains non-numeric characters");let d=[];for(let p=0;p<u.length;){const f=Math.min(u.length-p,3);n(parseInt(u.substring(p,p+f),10),f*3+1,d),p+=f}return new Mt(Mt.Mode.NUMERIC,u.length,d)}static makeAlphanumeric(u){if(!Mt.isAlphanumeric(u))throw new RangeError("String contains unencodable characters in alphanumeric mode");let d=[],p;for(p=0;p+2<=u.length;p+=2){let f=Mt.ALPHANUMERIC_CHARSET.indexOf(u.charAt(p))*45;f+=Mt.ALPHANUMERIC_CHARSET.indexOf(u.charAt(p+1)),n(f,11,d)}return p<u.length&&n(Mt.ALPHANUMERIC_CHARSET.indexOf(u.charAt(p)),6,d),new Mt(Mt.Mode.ALPHANUMERIC,u.length,d)}static makeSegments(u){return u==""?[]:Mt.isNumeric(u)?[Mt.makeNumeric(u)]:Mt.isAlphanumeric(u)?[Mt.makeAlphanumeric(u)]:[Mt.makeBytes(Mt.toUtf8ByteArray(u))]}static makeEci(u){let d=[];if(u<0)throw new RangeError("ECI assignment value out of range");if(u<128)n(u,8,d);else if(u<16384)n(2,2,d),n(u,14,d);else if(u<1e6)n(6,3,d),n(u,21,d);else throw new RangeError("ECI assignment value out of range");return new Mt(Mt.Mode.ECI,0,d)}static isNumeric(u){return Mt.NUMERIC_REGEX.test(u)}static isAlphanumeric(u){return Mt.ALPHANUMERIC_REGEX.test(u)}getData(){return this.bitData.slice()}static getTotalBits(u,d){let p=0;for(const f of u){const g=f.mode.numCharCountBits(d);if(f.numChars>=1<<g)return 1/0;p+=4+g+f.bitData.length}return p}static toUtf8ByteArray(u){u=encodeURI(u);let d=[];for(let p=0;p<u.length;p++)u.charAt(p)!="%"?d.push(u.charCodeAt(p)):(d.push(parseInt(u.substring(p+1,p+3),16)),p+=2);return d}};l.NUMERIC_REGEX=/^[0-9]*$/,l.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,l.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";let c=l;e.QrSegment=l})(ka||(ka={}));(e=>{(t=>{const n=class{constructor(s,l){this.ordinal=s,this.formatBits=l}};n.LOW=new n(0,1),n.MEDIUM=new n(1,0),n.QUARTILE=new n(2,3),n.HIGH=new n(3,2),t.Ecc=n})(e.QrCode||(e.QrCode={}))})(ka||(ka={}));(e=>{(t=>{const n=class{constructor(s,l){this.modeBits=s,this.numBitsCharCount=l}numCharCountBits(s){return this.numBitsCharCount[Math.floor((s+7)/17)]}};n.NUMERIC=new n(1,[10,12,14]),n.ALPHANUMERIC=new n(2,[9,11,13]),n.BYTE=new n(4,[8,16,16]),n.KANJI=new n(8,[8,10,12]),n.ECI=new n(7,[0,0,0]),t.Mode=n})(e.QrSegment||(e.QrSegment={}))})(ka||(ka={}));var xs=ka;var ate={L:xs.QrCode.Ecc.LOW,M:xs.QrCode.Ecc.MEDIUM,Q:xs.QrCode.Ecc.QUARTILE,H:xs.QrCode.Ecc.HIGH},I5=128,L5="L",M5="#FFFFFF",j5="#000000",B5=!1,F5=1,ste=4,ote=0,lte=.1;function P5(e,t=0){const n=[];return e.forEach(function(i,s){let l=null;i.forEach(function(c,o){if(!c&&l!==null){n.push(`M${l+t} ${s+t}h${o-l}v1H${l+t}z`),l=null;return}if(o===i.length-1){if(!c)return;l===null?n.push(`M${o+t},${s+t} h1v1H${o+t}z`):n.push(`M${l+t},${s+t} h${o+1-l}v1H${l+t}z`);return}c&&l===null&&(l=o)})}),n.join("")}function U5(e,t){return e.slice().map((n,i)=>i<t.y||i>=t.y+t.h?n:n.map((s,l)=>l<t.x||l>=t.x+t.w?s:!1))}function ute(e,t,n,i){if(i==null)return null;const s=e.length+n*2,l=Math.floor(t*lte),c=s/t,o=(i.width||l)*c,u=(i.height||l)*c,d=i.x==null?e.length/2-o/2:i.x*c,p=i.y==null?e.length/2-u/2:i.y*c,f=i.opacity==null?1:i.opacity;let g=null;if(i.excavate){let w=Math.floor(d),E=Math.floor(p),y=Math.ceil(o+d-w),S=Math.ceil(u+p-E);g={x:w,y:E,w:y,h:S}}const v=i.crossOrigin;return{x:d,y:p,h:u,w:o,excavation:g,opacity:f,crossOrigin:v}}function cte(e,t){return t!=null?Math.max(Math.floor(t),0):e?ste:ote}function H5({value:e,level:t,minVersion:n,includeMargin:i,marginSize:s,imageSettings:l,size:c,boostLevel:o}){let u=Je.useMemo(()=>{const w=(Array.isArray(e)?e:[e]).reduce((E,y)=>(E.push(...xs.QrSegment.makeSegments(y)),E),[]);return xs.QrCode.encodeSegments(w,ate[t],n,void 0,void 0,o)},[e,t,n,o]);const{cells:d,margin:p,numCells:f,calculatedImageSettings:g}=Je.useMemo(()=>{let v=u.getModules();const w=cte(i,s),E=v.length+w*2,y=ute(v,c,w,l);return{cells:v,margin:w,numCells:E,calculatedImageSettings:y}},[u,c,l,i,s]);return{qrcode:u,margin:p,cells:d,numCells:f,calculatedImageSettings:g}}var dte=(function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0})(),hte=Je.forwardRef(function(t,n){const i=t,{value:s,size:l=I5,level:c=L5,bgColor:o=M5,fgColor:u=j5,includeMargin:d=B5,minVersion:p=F5,boostLevel:f,marginSize:g,imageSettings:v}=i,E=Iv(i,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:y}=E,S=Iv(E,["style"]),x=v?.src,_=Je.useRef(null),C=Je.useRef(null),O=Je.useCallback(V=>{_.current=V,typeof n=="function"?n(V):n&&(n.current=V)},[n]),[T,N]=Je.useState(!1),{margin:A,cells:D,numCells:L,calculatedImageSettings:I}=H5({value:s,level:c,minVersion:p,boostLevel:f,includeMargin:d,marginSize:g,imageSettings:v,size:l});Je.useEffect(()=>{if(_.current!=null){const V=_.current,Y=V.getContext("2d");if(!Y)return;let W=D;const K=C.current,X=I!=null&&K!==null&&K.complete&&K.naturalHeight!==0&&K.naturalWidth!==0;X&&I.excavation!=null&&(W=U5(D,I.excavation));const B=window.devicePixelRatio||1;V.height=V.width=l*B;const M=l/L*B;Y.scale(M,M),Y.fillStyle=o,Y.fillRect(0,0,L,L),Y.fillStyle=u,dte?Y.fill(new Path2D(P5(W,A))):D.forEach(function(U,$){U.forEach(function(H,J){H&&Y.fillRect(J+A,$+A,1,1)})}),I&&(Y.globalAlpha=I.opacity),X&&Y.drawImage(K,I.x+A,I.y+A,I.w,I.h)}}),Je.useEffect(()=>{N(!1)},[x]);const j=Dv({height:l,width:l},y);let F=null;return x!=null&&(F=Je.createElement("img",{src:x,key:x,style:{display:"none"},onLoad:()=>{N(!0)},ref:C,crossOrigin:I?.crossOrigin})),Je.createElement(Je.Fragment,null,Je.createElement("canvas",Dv({style:j,height:l,width:l,ref:O,role:"img"},S)),F)});hte.displayName="QRCodeCanvas";var $1=Je.forwardRef(function(t,n){const i=t,{value:s,size:l=I5,level:c=L5,bgColor:o=M5,fgColor:u=j5,includeMargin:d=B5,minVersion:p=F5,boostLevel:f,title:g,marginSize:v,imageSettings:w}=i,E=Iv(i,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:y,cells:S,numCells:x,calculatedImageSettings:_}=H5({value:s,level:c,minVersion:p,boostLevel:f,includeMargin:d,marginSize:v,imageSettings:w,size:l});let C=S,O=null;w!=null&&_!=null&&(_.excavation!=null&&(C=U5(S,_.excavation)),O=Je.createElement("image",{href:w.src,height:_.h,width:_.w,x:_.x+y,y:_.y+y,preserveAspectRatio:"none",opacity:_.opacity,crossOrigin:_.crossOrigin}));const T=P5(C,y);return Je.createElement("svg",Dv({height:l,width:l,viewBox:`0 0 ${x} ${x}`,ref:n,role:"img"},E),!!g&&Je.createElement("title",null,g),Je.createElement("path",{fill:o,d:`M0,0 h${x}v${x}H0z`,shapeRendering:"crispEdges"}),Je.createElement("path",{fill:u,d:T,shapeRendering:"crispEdges"}),O)});$1.displayName="QRCodeSVG";const qo=["wallet","defaults"],on=gn((e,t)=>({isOpen:!1,currentStep:"wallet",manageMode:!1,isLoading:!1,error:null,authStatus:null,setOpen:n=>e({isOpen:n}),setStep:n=>e({currentStep:n}),setManageMode:n=>e({manageMode:n}),setLoading:n=>e({isLoading:n}),setError:n=>e({error:n}),setAuthStatus:n=>e({authStatus:n}),nextStep:()=>{const{currentStep:n}=t(),i=qo.indexOf(n);i<qo.length-1&&e({currentStep:qo[i+1]})},prevStep:()=>{const{currentStep:n}=t(),i=qo.indexOf(n);i>0&&e({currentStep:qo[i-1]})},reset:()=>e({isOpen:!1,currentStep:"wallet",manageMode:!1,isLoading:!1,error:null})}));function G1(){const e=on(x=>x.setAuthStatus),t=on(x=>x.setOpen),n=on(x=>x.setLoading),i=on(x=>x.setError),s=on(x=>x.authStatus),l=on(x=>x.isOpen),[c,o]=z.useState(!1),u=z.useCallback(async()=>{n(!0),i(null);try{const x=await Te.getAuthStatus();return e(x),x}catch(x){const _=x instanceof Error?x.message:"Failed to load";return i(_),null}finally{n(!1)}},[e,n,i]),d=z.useCallback(async()=>{const x=await u();if(x){const _=Object.values(x.providers).some(O=>O.configured);(!x.onboardingComplete||!_||!x.setu.configured)&&t(!0)}o(!0)},[u,t]),p=z.useCallback(async()=>{n(!0),i(null);try{const x=await Te.setupSetuWallet();return await u(),x}catch(x){const _=x instanceof Error?x.message:"Setup failed";throw i(_),x}finally{n(!1)}},[u,n,i]),f=z.useCallback(async x=>{n(!0),i(null);try{const _=await Te.importSetuWallet(x);return await u(),_}catch(_){const C=_ instanceof Error?_.message:"Import failed";throw i(C),_}finally{n(!1)}},[u,n,i]),g=z.useCallback(async(x,_)=>{n(!0),i(null);try{const C=await Te.addProvider(x,_);return await u(),C}catch(C){const O=C instanceof Error?C.message:"Failed to add provider";throw i(O),C}finally{n(!1)}},[u,n,i]),v=z.useCallback(async x=>{n(!0),i(null);try{const _=await Te.removeProvider(x);return await u(),_}catch(_){const C=_ instanceof Error?_.message:"Failed to remove provider";throw i(C),_}finally{n(!1)}},[u,n,i]),w=z.useCallback(async()=>{n(!0),i(null);try{await Te.completeOnboarding(),await u(),t(!1)}catch(x){const _=x instanceof Error?x.message:"Failed to complete onboarding";throw i(_),x}finally{n(!1)}},[u,n,i,t]),E=z.useCallback((x,_)=>{const C=Te.getOAuthStartUrl(x,_),O=600,T=700,N=window.screenX+(window.outerWidth-O)/2,A=window.screenY+(window.outerHeight-T)/2;return window.open(C,"oauth_popup",`width=${O},height=${T},left=${N},top=${A},toolbar=no,menubar=no`)},[]),y=z.useCallback(async(x,_)=>{const T=window.screenX+(window.outerWidth-600)/2,N=window.screenY+(window.outerHeight-700)/2,A=window.open("about:blank","oauth_popup",`width=600,height=700,left=${T},top=${N},toolbar=no,menubar=no`),{url:D,sessionId:L}=await Te.getOAuthUrl(x,_);return A&&(A.location.href=D),{popup:A,sessionId:L}},[]),S=z.useCallback(async(x,_,C)=>{n(!0),i(null);try{return await Te.exchangeOAuthCode(x,_,C),await u(),!0}catch(O){const T=O instanceof Error?O.message:"Failed to exchange code";throw i(T),O}finally{n(!1)}},[u,n,i]);return z.useEffect(()=>{const x=_=>{_.data?.type==="oauth-success"&&u()};return window.addEventListener("message",x),()=>window.removeEventListener("message",x)},[u]),{authStatus:s,isOpen:l,initialized:c,fetchAuthStatus:u,checkOnboarding:d,setupWallet:p,importWallet:f,addProvider:g,removeProvider:v,completeOnboarding:w,startOAuth:E,startOAuthManual:y,exchangeOAuthCode:S}}const $u="pendingPolarCheckout";function pte(){const e=z.useRef(!1),t=z.useRef(null),n=kt(s=>s.setBalance),i=br(s=>s.removeToast);z.useEffect(()=>{if(e.current)return;const l=new URLSearchParams(window.location.search).get("topup"),c=localStorage.getItem($u);if(l==="pending"||c){e.current=!0;const o=new URL(window.location.href);if(o.searchParams.delete("topup"),window.history.replaceState({},"",o.toString()),!c){at.info("Checking payment status...");return}t.current=at.loading("Verifying payment...");let u=0;const d=10,p=2e3,f=()=>{t.current&&(i(t.current),t.current=null)},g=async()=>{u++;try{const v=await Te.getPolarTopupStatus(c);if(v?.confirmed){localStorage.removeItem($u),f();const w=await Te.getSetuBalance();w?.balance!==void 0&&n(w.balance),at.success(`Payment confirmed! +$${v.amountUsd?.toFixed(2)} credited`);return}u<d?setTimeout(g,p):(localStorage.removeItem($u),f(),at.info("Payment processing. Balance will update automatically."))}catch{u<d?setTimeout(g,p):(localStorage.removeItem($u),f(),at.error("Could not verify payment. Please check your balance."))}};setTimeout(g,1500)}},[n,i])}const Gu=z.memo(function({title:t,icon:n,children:i,action:s}){return m.jsxs("div",{className:"border-b border-border",children:[m.jsxs("div",{className:"px-4 py-3 flex items-center gap-2 bg-muted/30",children:[n,m.jsx("span",{className:"text-sm font-medium flex-1",children:t}),s]}),m.jsx("div",{className:"px-4 py-3 space-y-3",children:i})]})}),Wy=z.memo(function({label:t,value:n}){return m.jsxs("div",{className:"flex items-center justify-between text-sm",children:[m.jsx("span",{className:"text-muted-foreground",children:t}),m.jsx("span",{className:"font-mono text-foreground",children:n})]})}),QN=z.memo(function({label:t,checked:n,onChange:i}){return m.jsxs("div",{className:"flex items-center justify-between text-sm",children:[m.jsx("span",{className:"text-muted-foreground",children:t}),m.jsx("button",{type:"button",role:"switch","aria-checked":n,onClick:()=>i(!n),className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-2 ${n?"bg-primary":"bg-muted"}`,children:m.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full transition-transform ${n?"translate-x-6":"translate-x-1"} ${n?"bg-primary-foreground":"bg-foreground"}`})})]})}),Wu=z.memo(function({label:t,value:n,options:i,onChange:s,disabled:l}){const[c,o]=z.useState(!1),u=i.find(d=>d.id===n);return m.jsxs("div",{className:"flex items-center justify-between text-sm",children:[m.jsx("span",{className:"text-muted-foreground",children:t}),m.jsxs("div",{className:"relative",children:[m.jsxs("button",{type:"button",onClick:()=>!l&&o(!c),disabled:l,className:"flex items-center gap-1 px-2 py-1 text-xs font-mono bg-muted hover:bg-muted/80 rounded border border-border disabled:opacity-50",children:[m.jsx("span",{className:"max-w-[120px] truncate",children:u?.label||n||"Select..."}),m.jsx(mr,{className:"w-3 h-3"})]}),c&&m.jsxs(m.Fragment,{children:[m.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>o(!1),role:"presentation"}),m.jsx("div",{className:"absolute right-0 top-full mt-1 z-50 min-w-[160px] max-h-[200px] overflow-y-auto bg-popover border border-border rounded-md shadow-lg",children:i.map(d=>m.jsx("button",{type:"button",onClick:()=>{s(d.id),o(!1)},className:`w-full px-3 py-2 text-left text-xs font-mono hover:bg-muted truncate ${d.id===n?"bg-muted/50":""}`,children:d.label},d.id))})]})]})]})}),fte=z.memo(function(){const t=Nr(j=>j.isExpanded),n=Nr(j=>j.collapseSidebar),{data:i}=c1(),{data:s}=$c(),{preferences:l,updatePreferences:c}=dl(),o=KU(),u=kt(j=>j.balance),d=kt(j=>j.walletAddress),p=kt(j=>j.usdcBalance),f=kt(j=>j.isLoading),g=kt(j=>j.openTopupModal);pte();const v=i?.providers?.includes("setu"),{fetchBalance:w}=Vc(v?"setu":void 0),E=on(j=>j.setOpen),y=on(j=>j.setStep),S=on(j=>j.setManageMode),{fetchAuthStatus:x}=G1(),_=z.useMemo(()=>!i?.providers||!s?[]:i.providers.filter(j=>s[j]).map(j=>({id:j,label:s[j]?.label||j})),[i?.providers,s]),C=z.useMemo(()=>{const j=i?.defaults?.provider;return!j||!s?.[j]?[]:s[j].models.map(F=>({id:F.id,label:F.label}))},[i?.defaults?.provider,s]),O=z.useMemo(()=>i?.agents?i.agents.map(j=>({id:j,label:j})):[],[i?.agents]);if(!t)return null;const T=j=>{const F=s?.[j]?.models?.[0]?.id;o.mutate({provider:j,model:F||i?.defaults?.model})},N=j=>{o.mutate({model:j})},A=j=>{o.mutate({agent:j})},D=j=>j?`${j.slice(0,4)}...${j.slice(-4)}`:"Not configured",L=j=>j===null?"—":`$${j.toFixed(4)}`,I=j=>j===null?"—":`${j.toFixed(2)} USDC`;return m.jsxs("div",{className:"w-80 border-l border-border bg-background flex flex-col h-full",children:[m.jsxs("div",{className:"h-14 border-b border-border px-4 flex items-center justify-between shrink-0",children:[m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsx(QO,{className:"w-4 h-4"}),m.jsx("span",{className:"font-medium",children:"Settings"})]}),m.jsx(st,{variant:"ghost",size:"icon",onClick:n,children:m.jsx(an,{className:"w-4 h-4"})})]}),m.jsxs("div",{className:"flex-1 overflow-y-auto",children:[m.jsxs(Gu,{title:"Default Model",icon:m.jsx(wj,{className:"w-4 h-4 text-muted-foreground"}),children:[m.jsx(Wu,{label:"Provider",value:i?.defaults?.provider??"",options:_,onChange:T,disabled:o.isPending}),m.jsx(Wu,{label:"Model",value:i?.defaults?.model??"",options:C,onChange:N,disabled:o.isPending}),m.jsx(Wu,{label:"Agent",value:i?.defaults?.agent??"",options:O,onChange:A,disabled:o.isPending})]}),m.jsxs(Gu,{title:"Preferences",icon:m.jsx(Jv,{className:"w-4 h-4 text-muted-foreground"}),children:[m.jsx(QN,{label:"Vim Mode",checked:l.vimMode,onChange:j=>c({vimMode:j})}),m.jsx(QN,{label:"Show Reasoning",checked:l.reasoningEnabled,onChange:j=>c({reasoningEnabled:j})}),m.jsx(Wu,{label:"Tool Approval",value:i?.defaults?.toolApproval??"auto",options:[{id:"auto",label:"Auto (no approval)"},{id:"dangerous",label:"Dangerous only"},{id:"all",label:"All tools"}],onChange:j=>o.mutate({toolApproval:j}),disabled:o.isPending})]}),i?.providers?.includes("setu")&&m.jsxs(Gu,{title:"Setu Wallet",icon:m.jsx(e1,{className:"w-4 h-4 text-muted-foreground"}),action:m.jsx("button",{type:"button",onClick:w,disabled:f,className:"p-1 hover:bg-muted rounded transition-colors disabled:opacity-50",title:"Refresh balances",children:m.jsx(ni,{className:`w-3.5 h-3.5 text-muted-foreground ${f?"animate-spin":""}`})}),children:[d&&m.jsx("div",{className:"flex justify-center pb-3",children:m.jsx("div",{className:"p-2 bg-white rounded-lg",children:m.jsx($1,{value:d,size:120,level:"M",includeMargin:!1})})}),m.jsx(Wy,{label:"Address",value:D(d)}),m.jsx(Wy,{label:"Balance",value:L(u)}),m.jsx(Wy,{label:"USDC",value:I(p)}),m.jsxs(st,{variant:"secondary",size:"sm",onClick:g,className:"w-full mt-2 gap-2",children:[m.jsx(Ts,{className:"w-4 h-4"}),"Top Up Balance"]})]}),m.jsx(z1,{}),m.jsx(Gu,{title:"Providers",icon:m.jsx(HB,{className:"w-4 h-4 text-muted-foreground"}),action:m.jsx("button",{type:"button",onClick:()=>{x().then(()=>{y("wallet"),S(!0),E(!0)})},className:"p-1 hover:bg-muted rounded transition-colors",title:"Manage providers",children:m.jsx(nv,{className:"w-3.5 h-3.5 text-muted-foreground"})}),children:m.jsx("div",{className:"flex flex-wrap gap-2",children:i?.providers?.map(j=>m.jsx("span",{className:"px-2 py-1 text-xs bg-muted rounded-md font-mono",children:j},j))??m.jsx("span",{className:"text-muted-foreground text-sm",children:"None"})})})]})]})}),mte=z.memo(function(){const t=Nr(i=>i.isExpanded),n=Nr(i=>i.toggleSidebar);return m.jsx("button",{type:"button",onClick:n,className:`relative h-14 w-full transition-colors touch-manipulation flex items-center justify-center ${t?"bg-muted border-r-2 border-primary":"hover:bg-muted/50"}`,title:"Settings",children:m.jsx(QO,{className:"w-5 h-5 text-muted-foreground mx-auto"})})}),gte=z.memo(function({authStatus:t,onSetupWallet:n,onAddProvider:i,onRemoveProvider:s,onStartOAuth:l,onStartOAuthManual:c,onExchangeOAuthCode:o,onOpenTopup:u,onNext:d,manageMode:p=!1,onClose:f}){const[g,v]=z.useState(!1),[w,E]=z.useState(!1),[y,S]=z.useState(null),[x,_]=z.useState(""),[C,O]=z.useState(null),[T,N]=z.useState(null),[A,D]=z.useState(null),[L,I]=z.useState(""),[j,F]=z.useState(!1),[V,Y]=z.useState(!1),W=kt(se=>se.balance),K=kt(se=>se.usdcBalance),X=z.useRef(null),B=z.useRef(null);Vc("setu"),z.useEffect(()=>{!t.setu.configured&&!w&&(E(!0),n().finally(()=>E(!1)))},[t.setu.configured,n,w]),z.useEffect(()=>{y&&X.current&&X.current.focus()},[y]),z.useEffect(()=>{A&&B.current&&B.current.focus()},[A]);const M=async()=>{t.setu.publicKey&&(await navigator.clipboard.writeText(t.setu.publicKey),v(!0),setTimeout(()=>v(!1),2e3))},U=se=>`${se.slice(0,8)}...${se.slice(-6)}`,$=async se=>{if(x.trim())try{await i(se,x.trim()),S(null),_("")}catch{}},H=async se=>{if(T===se){O(se);try{await s(se)}finally{O(null),N(null)}}else N(se)},J=()=>{N(null)},oe=async(se,be)=>{se==="anthropic"?D({provider:se,sessionId:null,mode:be}):l(se,be)},de=async()=>{if(A){Y(!0);try{const{sessionId:se}=await c(A.provider,A.mode);D({...A,sessionId:se})}catch(se){console.error("Failed to start OAuth:",se)}Y(!1)}},Z=async()=>{if(!(!A||!A.sessionId||!L.trim())){F(!0);try{await o(A.provider,L.trim(),A.sessionId),D(null),I("")}catch{}F(!1)}},q=()=>{D(null),I("")},te=Object.entries(t.providers).filter(([se,be])=>be.configured&&se!=="setu"),he=Object.entries(t.providers).filter(([se,be])=>!be.configured&&se!=="setu");return m.jsxs("div",{className:"min-h-screen flex flex-col",children:[m.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-border",children:[m.jsxs("div",{className:"flex items-center gap-3",children:[m.jsx(fr,{provider:"setu",size:24}),m.jsx("span",{className:"font-semibold text-foreground",children:"AGI"})]}),!p&&m.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[m.jsx("span",{className:"w-2 h-2 rounded-full bg-green-500"}),"Step 1 of 2"]})]}),m.jsx("div",{className:"flex-1 px-6 py-8 lg:px-12 lg:py-12",children:m.jsxs("div",{className:"max-w-7xl mx-auto",children:[m.jsxs("div",{className:"mb-10",children:[m.jsx("h1",{className:"text-3xl lg:text-4xl font-semibold text-foreground mb-3",children:p?"Manage Providers":"Welcome to AGI"}),m.jsx("p",{className:"text-lg text-muted-foreground max-w-2xl",children:p?"Add or remove AI providers. Your changes are saved automatically.":"Setu is your default AI provider, powered by your wallet. Add more providers below if you'd like."})]}),m.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-3 gap-8",children:[m.jsx("div",{className:"xl:col-span-1",children:m.jsx("div",{className:"bg-card rounded-2xl border border-border p-5 h-full",children:t.setu.configured&&t.setu.publicKey?m.jsxs("div",{className:"flex flex-col h-full",children:[m.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 bg-green-500/10 border border-green-500/20 rounded-lg",children:[m.jsx(fr,{provider:"setu",size:16}),m.jsx("span",{className:"text-sm font-medium text-green-600 dark:text-green-400",children:"Setu"}),m.jsx("span",{className:"text-xs text-green-600/60 dark:text-green-500/60 ml-auto",children:"Default Provider"})]}),m.jsx("div",{className:"flex justify-center py-4 mt-4",children:m.jsx("div",{className:"bg-white p-2 rounded-lg",children:m.jsx($1,{value:t.setu.publicKey,size:140,level:"M"})})}),m.jsxs("div",{className:"space-y-2 mt-4",children:[m.jsxs("button",{type:"button",onClick:M,className:"w-full flex items-center justify-center gap-2 px-3 py-2 bg-muted hover:bg-muted/80 rounded-lg text-xs font-mono text-muted-foreground transition-colors",children:[U(t.setu.publicKey),g?m.jsx(ti,{className:"w-3.5 h-3.5 text-green-500"}):m.jsx(Ic,{className:"w-3.5 h-3.5 text-muted-foreground"})]}),m.jsxs("div",{className:"flex items-center justify-between px-3 py-2 bg-muted/50 rounded-lg",children:[m.jsx("span",{className:"text-xs text-muted-foreground",children:"Balance"}),m.jsxs("span",{className:"font-mono text-sm text-foreground",children:["$",((W??0)+(K??0)).toFixed(4)]})]})]}),m.jsxs("div",{className:"flex items-center gap-4 py-4",children:[m.jsx("div",{className:"flex-1 h-px bg-border"}),m.jsx("span",{className:"text-xs text-muted-foreground font-medium",children:"OR"}),m.jsx("div",{className:"flex-1 h-px bg-border"})]}),m.jsxs("button",{type:"button",onClick:u,className:"w-full flex items-center justify-center gap-2 px-4 py-2.5 bg-primary text-primary-foreground rounded-lg text-sm font-medium hover:bg-primary/90 transition-colors",children:[m.jsx(ks,{className:"w-4 h-4"}),"Pay via Card"]})]}):m.jsx("div",{className:"flex items-center justify-center py-16",children:m.jsx(rn,{className:"w-8 h-8 animate-spin text-muted-foreground"})})})}),m.jsxs("div",{className:"xl:col-span-2 space-y-6",children:[m.jsxs("div",{children:[m.jsxs("div",{className:"flex items-center justify-between mb-4",children:[m.jsx("h2",{className:"font-semibold text-foreground",children:"Connected Providers"}),te.length>0&&m.jsxs("span",{className:"text-sm text-muted-foreground",children:[te.length," active"]})]}),te.length===0?m.jsx("div",{className:"text-sm text-muted-foreground py-4",children:"No providers connected yet. Add one below."}):m.jsx("div",{className:"flex flex-wrap gap-2",children:te.map(([se,be])=>m.jsxs("div",{className:`flex items-center gap-2 pl-3 pr-2 py-2 rounded-full transition-all duration-200 ${T===se?"bg-destructive/10 border border-destructive/30":"group bg-green-500/10 border border-green-500/20"}`,children:[m.jsx(fr,{provider:se,size:16}),m.jsx("span",{className:`text-sm font-medium transition-colors ${T===se?"text-destructive":"text-green-600 dark:text-green-400"}`,children:be.label}),T!==se&&m.jsx("span",{className:"text-xs text-green-600/60 dark:text-green-500/60",children:be.type==="oauth"?"OAuth":"API"}),T===se?m.jsxs("div",{className:"flex items-center gap-1 ml-1",children:[m.jsx("span",{className:"text-xs text-destructive/80 mr-1",children:"Remove?"}),m.jsx("button",{type:"button",onClick:()=>H(se),disabled:C===se,className:"px-2 py-0.5 text-xs bg-destructive text-destructive-foreground rounded hover:bg-destructive/90 transition-colors disabled:opacity-50",children:C===se?m.jsx(rn,{className:"w-3 h-3 animate-spin"}):"Yes"}),m.jsx("button",{type:"button",onClick:J,className:"px-2 py-0.5 text-xs bg-muted text-muted-foreground rounded hover:bg-muted/80 transition-colors",children:"No"})]}):se!=="setu"&&m.jsx("button",{type:"button",onClick:()=>H(se),className:"ml-1 p-1 text-green-600/40 dark:text-green-500/40 hover:text-green-600/80 dark:hover:text-green-500/80 opacity-0 group-hover:opacity-100 transition-opacity",children:m.jsx(cn,{className:"w-3 h-3"})})]},se))})]}),m.jsxs("div",{children:[m.jsx("h2",{className:"font-semibold text-foreground mb-4",children:"Add Providers"}),m.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:he.map(([se,be])=>m.jsx("div",{children:y===se?m.jsxs("div",{className:"flex items-center gap-2 p-3 bg-card border border-ring rounded-xl",children:[m.jsx(fr,{provider:se,size:18}),m.jsx("input",{ref:X,type:"password",value:x,onChange:Ee=>_(Ee.target.value),placeholder:`${be.label} API key...`,className:"flex-1 bg-transparent text-sm outline-none placeholder:text-muted-foreground text-foreground",onKeyDown:Ee=>{Ee.key==="Enter"&&$(se),Ee.key==="Escape"&&(S(null),_(""))}}),m.jsx("button",{type:"button",onClick:()=>$(se),disabled:!x.trim(),className:"px-3 py-1.5 bg-primary text-primary-foreground text-sm font-medium rounded-lg disabled:opacity-50",children:"Add"}),m.jsx("button",{type:"button",onClick:()=>{S(null),_("")},className:"p-1.5 text-muted-foreground hover:text-foreground",children:m.jsx(cn,{className:"w-4 h-4"})})]}):m.jsxs("div",{className:"flex items-center justify-between p-3 bg-card border border-border hover:border-border/80 rounded-xl transition-colors",children:[m.jsxs("div",{className:"flex items-center gap-3",children:[m.jsx(fr,{provider:se,size:20}),m.jsxs("div",{children:[m.jsx("div",{className:"font-medium text-foreground",children:be.label}),m.jsxs("div",{className:"text-xs text-muted-foreground",children:[be.modelCount," models"]})]})]}),m.jsxs("div",{className:"flex items-center gap-1",children:[m.jsxs("button",{type:"button",onClick:()=>S(se),className:"flex items-center gap-1.5 px-3 py-1.5 text-sm text-muted-foreground hover:text-foreground hover:bg-muted rounded-lg transition-colors",children:[m.jsx(aB,{className:"w-3.5 h-3.5"}),"API"]}),be.supportsOAuth&&m.jsxs("button",{type:"button",onClick:()=>oe(se,se==="anthropic"?"max":void 0),className:"flex items-center gap-1.5 px-3 py-1.5 text-sm text-muted-foreground hover:text-foreground hover:bg-muted rounded-lg transition-colors",children:[m.jsx(Gn,{className:"w-3.5 h-3.5"}),se==="anthropic"?"Max":"OAuth"]})]})]})},se))})]})]})]})]})}),m.jsx("div",{className:"px-6 py-4 border-t border-border",children:m.jsxs("div",{className:"max-w-7xl mx-auto flex items-center justify-between",children:[!p&&m.jsx("div",{className:"text-sm text-muted-foreground",children:"You can add more providers later in settings"}),p?m.jsx("button",{type:"button",onClick:f,className:"flex items-center gap-2 px-6 py-3 bg-primary text-primary-foreground rounded-lg font-medium hover:bg-primary/90 transition-colors ml-auto",children:"Done"}):m.jsxs("button",{type:"button",onClick:d,className:"flex items-center gap-2 px-6 py-3 bg-primary text-primary-foreground rounded-lg font-medium hover:bg-primary/90 transition-colors",children:["Continue",m.jsx(BO,{className:"w-4 h-4"})]})]})}),A&&m.jsx("div",{className:"fixed inset-0 z-[9999] flex items-center justify-center bg-black/60 backdrop-blur-sm",children:m.jsxs("div",{className:"bg-background border border-border rounded-xl w-full max-w-lg mx-6 shadow-2xl",children:[m.jsxs("div",{className:"flex items-center gap-3 p-6 border-b border-border",children:[m.jsx(fr,{provider:A.provider,size:24}),m.jsxs("h3",{className:"text-lg font-semibold",children:["Connect"," ",t.providers[A.provider]?.label||A.provider]})]}),A.sessionId?m.jsxs("div",{className:"p-6",children:[m.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Paste the authorization code:"}),m.jsx("input",{type:"text",ref:B,value:L,onChange:se=>I(se.target.value),placeholder:"Paste code here...",className:"w-full h-11 px-4 bg-muted/50 border border-border rounded-lg text-foreground placeholder:text-muted-foreground outline-none focus:border-foreground/30 transition-colors mb-4 font-mono text-sm",onKeyDown:se=>{se.key==="Enter"&&Z(),se.key==="Escape"&&q()}}),m.jsxs("div",{className:"flex gap-3",children:[m.jsx("button",{type:"button",onClick:q,className:"flex-1 h-11 px-4 bg-transparent border border-border text-foreground rounded-lg font-medium hover:bg-muted/50 transition-colors",children:"Cancel"}),m.jsx("button",{type:"button",onClick:Z,disabled:!L.trim()||j,className:"flex-1 h-11 px-4 bg-foreground text-background rounded-lg font-medium hover:bg-foreground/90 transition-colors disabled:opacity-50 flex items-center justify-center gap-2",children:j?m.jsx(rn,{className:"w-4 h-4 animate-spin"}):"Connect"})]})]}):m.jsxs("div",{className:"p-6",children:[m.jsxs("p",{className:"text-sm text-muted-foreground mb-6",children:["You'll be redirected to"," ",t.providers[A.provider]?.label||A.provider," ","to authorize access. After authorizing, copy the code and return here."]}),m.jsxs("div",{className:"flex gap-3",children:[m.jsx("button",{type:"button",onClick:q,className:"flex-1 h-11 px-4 bg-transparent border border-border text-foreground rounded-lg font-medium hover:bg-muted/50 transition-colors",children:"Cancel"}),m.jsx("button",{type:"button",onClick:de,disabled:V,className:"flex-1 h-11 px-4 bg-foreground text-background rounded-lg font-medium hover:bg-foreground/90 transition-colors disabled:opacity-50 flex items-center justify-center gap-2",children:V?m.jsx(rn,{className:"w-4 h-4 animate-spin"}):m.jsxs(m.Fragment,{children:["Continue",m.jsx(Gn,{className:"w-4 h-4"})]})})]})]})]})})]})}),bte=z.memo(function({authStatus:t,onComplete:n,onBack:i}){const[s,l]=z.useState(null),[c,o]=z.useState(null),[u,d]=z.useState(!0),[p,f]=z.useState(!1),[g,v]=z.useState("setu"),[w,E]=z.useState("kimi-k2.5"),[y,S]=z.useState(t.defaults.agent),[x,_]=z.useState(t.defaults.toolApproval||"auto"),C=z.useRef(!1),O=z.useId(),T=z.useId(),N=z.useId(),A=z.useId();z.useEffect(()=>{(async()=>{try{const[F,V]=await Promise.all([Te.getConfig(),Te.getAllModels()]);l(F),o(V)}catch{}finally{d(!1)}})()},[]),z.useEffect(()=>{if(c?.[g]&&C.current){const j=c[g];j.models.some(F=>F.id===w)||E(j.models[0]?.id||"")}},[g,c,w]);const D=async()=>{f(!0);try{await Te.updateDefaults({provider:g,model:w,agent:y,toolApproval:x,scope:"global"}),await n()}catch{}finally{f(!1)}};if(u)return m.jsx("div",{className:"min-h-screen flex items-center justify-center",children:m.jsx(rn,{className:"w-8 h-8 animate-spin text-muted-foreground"})});const L=s?.providers.filter(j=>(t.providers[j]?.configured||j==="setu")&&c?.[j]?.models?.length>0)||["setu"],I=c?.[g]?.models||[];return m.jsxs("div",{className:"min-h-screen flex flex-col",children:[m.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-border",children:[m.jsxs("div",{className:"flex items-center gap-3",children:[m.jsx(fr,{provider:"setu",size:24}),m.jsx("span",{className:"font-semibold text-foreground",children:"AGI"})]}),m.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[m.jsx("span",{className:"w-2 h-2 rounded-full bg-blue-500"}),"Step 2 of 2"]})]}),m.jsx("div",{className:"flex-1 px-6 py-8 lg:px-12 lg:py-12",children:m.jsxs("div",{className:"max-w-7xl mx-auto",children:[m.jsxs("div",{className:"mb-10",children:[m.jsx("h1",{className:"text-3xl lg:text-4xl font-semibold text-foreground mb-3",children:"Configure Defaults"}),m.jsx("p",{className:"text-lg text-muted-foreground",children:"Set your preferences. You can change these anytime in settings."})]}),m.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[m.jsxs("div",{className:"md:col-span-2",children:[m.jsx("label",{htmlFor:O,className:"block text-sm font-medium text-muted-foreground mb-2",children:"Default Provider"}),m.jsxs("div",{className:"relative",children:[m.jsx("select",{id:O,value:g,onChange:j=>{C.current=!0,v(j.target.value)},className:"w-full px-4 py-3 bg-card border border-border rounded-xl text-foreground appearance-none cursor-pointer focus:outline-none focus:border-ring transition-colors",children:L.map(j=>m.jsx("option",{value:j,children:t.providers[j]?.label||j},j))}),m.jsx(mr,{className:"absolute right-4 top-1/2 -translate-y-1/2 w-5 h-5 text-muted-foreground pointer-events-none"})]})]}),m.jsxs("div",{className:"md:col-span-2",children:[m.jsx("label",{htmlFor:T,className:"block text-sm font-medium text-muted-foreground mb-2",children:"Default Model"}),m.jsxs("div",{className:"relative",children:[m.jsx("select",{id:T,value:w,onChange:j=>E(j.target.value),className:"w-full px-4 py-3 bg-card border border-border rounded-xl text-foreground appearance-none cursor-pointer focus:outline-none focus:border-ring transition-colors",children:I.map(j=>m.jsx("option",{value:j.id,children:j.label||j.id},j.id))}),m.jsx(mr,{className:"absolute right-4 top-1/2 -translate-y-1/2 w-5 h-5 text-muted-foreground pointer-events-none"})]})]}),m.jsxs("div",{children:[m.jsx("label",{htmlFor:N,className:"block text-sm font-medium text-muted-foreground mb-2",children:"Default Agent"}),m.jsxs("div",{className:"relative",children:[m.jsx("select",{id:N,value:y,onChange:j=>S(j.target.value),className:"w-full px-4 py-3 bg-card border border-border rounded-xl text-foreground appearance-none cursor-pointer focus:outline-none focus:border-ring transition-colors",children:(s?.agents||["build"]).map(j=>m.jsx("option",{value:j,children:j},j))}),m.jsx(mr,{className:"absolute right-4 top-1/2 -translate-y-1/2 w-5 h-5 text-muted-foreground pointer-events-none"})]})]}),m.jsxs("div",{children:[m.jsx("label",{htmlFor:A,className:"block text-sm font-medium text-muted-foreground mb-2",children:"Tool Approval"}),m.jsxs("div",{className:"relative",children:[m.jsxs("select",{id:A,value:x,onChange:j=>_(j.target.value),className:"w-full px-4 py-3 bg-card border border-border rounded-xl text-foreground appearance-none cursor-pointer focus:outline-none focus:border-ring transition-colors",children:[m.jsx("option",{value:"auto",children:"Auto - run without asking"}),m.jsx("option",{value:"dangerous",children:"Dangerous - approve writes only"}),m.jsx("option",{value:"all",children:"All - approve every tool"})]}),m.jsx(mr,{className:"absolute right-4 top-1/2 -translate-y-1/2 w-5 h-5 text-muted-foreground pointer-events-none"})]}),m.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"Controls when tool executions need approval"})]})]})]})}),m.jsx("div",{className:"px-6 py-4 border-t border-border",children:m.jsxs("div",{className:"max-w-7xl mx-auto flex items-center justify-between",children:[m.jsxs("button",{type:"button",onClick:i,className:"flex items-center gap-2 px-4 py-3 text-muted-foreground hover:text-foreground transition-colors",children:[m.jsx(Yv,{className:"w-4 h-4"}),"Back"]}),m.jsx("button",{type:"button",onClick:D,disabled:p,className:"flex items-center gap-2 px-6 py-3 bg-primary text-primary-foreground rounded-lg font-medium hover:bg-primary/90 transition-colors disabled:opacity-50",children:p?m.jsxs(m.Fragment,{children:[m.jsx(rn,{className:"w-4 h-4 animate-spin"}),"Setting up..."]}):m.jsxs(m.Fragment,{children:["Start Using AGI",m.jsx(As,{className:"w-4 h-4"})]})})]})})]})}),yte=z.memo(function(){const t=on(y=>y.isOpen),n=on(y=>y.currentStep),i=on(y=>y.manageMode),s=on(y=>y.authStatus),l=on(y=>y.nextStep),c=on(y=>y.prevStep),o=on(y=>y.reset),u=kt(y=>y.openTopupModal),{setupWallet:d,addProvider:p,removeProvider:f,completeOnboarding:g,startOAuth:v,startOAuthManual:w,exchangeOAuthCode:E}=G1();return!t||!s?null:m.jsxs("div",{className:"fixed inset-0 z-[9999] bg-background text-foreground overflow-y-auto",children:[n==="wallet"&&m.jsx(gte,{authStatus:s,onSetupWallet:d,onAddProvider:p,onRemoveProvider:f,onStartOAuth:v,onStartOAuthManual:w,onExchangeOAuthCode:E,onOpenTopup:u,onNext:l,manageMode:i,onClose:o}),n==="defaults"&&m.jsx(bte,{authStatus:s,onComplete:g,onBack:c})]})}),z5="agi-theme",JN="dark";function vte(){if(typeof window>"u")return JN;const e=window.localStorage.getItem(z5);return e==="light"||e==="dark"?e:JN}function xte(){const[e,t]=z.useState(()=>vte());z.useEffect(()=>{if(typeof document>"u")return;const i=document.documentElement;e==="dark"?i.classList.add("dark"):i.classList.remove("dark");try{window.localStorage.setItem(z5,e)}catch(s){console.warn("Failed to persist theme preference",s)}},[e]);const n=z.useCallback(()=>{t(i=>i==="dark"?"light":"dark")},[]);return z.useMemo(()=>({theme:e,setTheme:t,toggleTheme:n}),[e,n])}function _te(){const[e,t]=z.useState(null);return z.useEffect(()=>{(async()=>{try{const l=`${window.AGI_SERVER_URL||Hc}/v1/config/cwd`;console.log("[useWorkingDirectory] Fetching from:",l);const c=await fetch(l);if(!c.ok)throw console.error("[useWorkingDirectory] Failed:",c.status,c.statusText),new Error(`Failed to fetch working directory: ${c.status}`);const o=await c.json();console.log("[useWorkingDirectory] Success:",o),o.dirName&&(console.log("[useWorkingDirectory] Setting title to:",o.dirName),t(o.dirName),document.title=o.dirName)}catch(i){console.error("[useWorkingDirectory] Error:",i),document.title="AGI"}})()},[]),e}function Ste({sessionIds:e,activeSessionId:t,gitFiles:n,onSelectSession:i,onNewSession:s,onStageFile:l,onUnstageFile:c,onRestoreFile:o,onDeleteFile:u,onStageAll:d,onUnstageAll:p,onOpenCommitModal:f,onViewDiff:g,onReturnToInput:v}){const{currentFocus:w,sessionIndex:E,gitFileIndex:y,setFocus:S,setSessionIndex:x,setGitFileIndex:_,resetGitFileIndex:C}=q1(),{setCollapsed:O,toggleCollapse:T}=Ca(),{isExpanded:N,toggleSidebar:A}=Tt(),D=Tt(F=>F.closeDiff),L=zn(F=>F.toggleSidebar),I=e.indexOf(t||""),j=z.useCallback(F=>{const V=F.target,Y=V.tagName==="INPUT"||V.tagName==="TEXTAREA"||V.isContentEditable;if((F.ctrlKey||F.metaKey)&&F.key==="h"){F.preventDefault(),w==="sessions"?(document.activeElement?.blur(),S("input"),O(!0),setTimeout(()=>v?.(),50)):w==="git"?(document.activeElement?.blur(),S("input"),A(),D(),setTimeout(()=>v?.(),50)):(document.activeElement?.blur(),S("sessions"),O(!1),I>=0&&x(I));return}if((F.ctrlKey||F.metaKey)&&F.key==="l"){F.preventDefault(),w==="git"?(document.activeElement?.blur(),S("input"),A(),D(),setTimeout(()=>v?.(),50)):w==="sessions"?(document.activeElement?.blur(),S("input"),O(!0),setTimeout(()=>v?.(),50)):(document.activeElement?.blur(),N||A(),S("git"),C());return}if((F.ctrlKey||F.metaKey)&&F.key==="/"){F.preventDefault(),T();return}if((F.ctrlKey||F.metaKey)&&F.key==="\\"){F.preventDefault(),A();return}if((F.ctrlKey||F.metaKey)&&F.shiftKey&&F.key==="r"){F.preventDefault(),L();return}if((F.ctrlKey||F.metaKey)&&F.key==="n"){F.preventDefault(),s();return}if(F.key==="Escape"||F.key==="q"&&!Y&&(w==="sessions"||w==="git")){F.preventDefault(),w==="sessions"?O(!0):w==="git"&&(A(),D()),S("input"),v?.();return}if(w==="sessions"&&!Y){if(F.key==="j"&&e.length>0){F.preventDefault();const W=Math.min(E+1,e.length-1);x(W);return}if(F.key==="k"&&e.length>0){F.preventDefault();const W=Math.max(E-1,0);x(W);return}if(F.key==="Enter"&&e[E]){F.preventDefault(),i(e[E]),S("input");return}}if(w==="git"&&!Y){if(F.key==="j"&&n.length>0){F.preventDefault();const W=Math.min(y+1,n.length-1);_(W);return}if(F.key==="k"&&n.length>0){F.preventDefault();const W=Math.max(y-1,0);_(W);return}if(F.key===" "&&n[y]){F.preventDefault();const W=n[y];W.staged?c?.(W.path):l?.(W.path);return}if(F.key==="a"){F.preventDefault(),d?.();return}if(F.key==="u"){F.preventDefault(),p?.();return}if(F.key==="R"&&n[y]){F.preventDefault();const W=n[y];!W.staged&&W.status!=="untracked"&&W.status!=="added"&&o?.(W.path);return}if(F.shiftKey&&F.key==="D"||F.key==="Backspace"){F.preventDefault();const W=n[y];W&&!W.staged&&W.status==="untracked"&&u?.(W.path);return}if(F.key==="c"){F.preventDefault(),f?.();return}if(F.key==="Enter"&&n[y]){F.preventDefault();const W=n[y];g?.(W.path,W.staged);return}}},[w,E,y,e,n,I,N,S,x,_,C,O,A,L,T,i,s,l,c,o,u,d,p,f,g,v,D]);return z.useEffect(()=>(window.addEventListener("keydown",j),()=>window.removeEventListener("keydown",j)),[j]),{currentFocus:w,sessionIndex:E,gitFileIndex:y}}function Ete(e){const t=z.useRef(null),n=z.useRef(null),i=kt(d=>d.setBalance),s=kt(d=>d.setPaymentPending),l=br(d=>d.removeToast),c=br(d=>d.updateToast),o=kc(d=>d.setPendingTopup),u=kc(d=>d.clearPendingTopup);z.useEffect(()=>{if(!e)return;const d=new T5;t.current=d;const p=Te.getStreamUrl(e);d.connect(p);const f=d.on("*",g=>{const v=g.payload;switch(g.type){case"setu.topup.required":{const w=typeof v?.amountUsd=="number"?v.amountUsd:0,E=typeof v?.currentBalance=="number"?v.currentBalance:0,y=typeof v?.minTopupUsd=="number"?v.minTopupUsd:5,S=typeof v?.suggestedTopupUsd=="number"?v.suggestedTopupUsd:10,x=typeof v?.messageId=="string"?v.messageId:"";o({sessionId:e,messageId:x,amountUsd:w,currentBalance:E,minTopupUsd:y,suggestedTopupUsd:S});break}case"setu.topup.method_selected":{v?.method==="crypto"&&(s(!0),n.current=at.loading("💳 Processing crypto payment..."));break}case"setu.topup.cancelled":{u();const w=typeof v?.reason=="string"?v.reason:"Request cancelled";at(`⚠️ ${w}`);break}case"setu.payment.required":{const w=typeof v?.amountUsd=="number"?v.amountUsd:0;s(!0),n.current||(n.current=at.loading(`💳 Payment required: $${w.toFixed(2)}`));break}case"setu.payment.signing":{n.current?c(n.current,{message:"✍️ Signing transaction..."}):n.current=at.loading("✍️ Signing transaction...");break}case"setu.payment.complete":{u();const w=v?.amountUsd,E=v?.newBalance,y=typeof v?.transactionId=="string"?v.transactionId:void 0,S=typeof w=="number"?w:typeof w=="string"?parseFloat(w):0,x=typeof E=="number"?E:typeof E=="string"?parseFloat(E):0;i(x),s(!1),n.current&&(l(n.current),n.current=null);const _=`✅ Paid $${S.toFixed(2)}`;y?at.successWithAction(_,{label:"View Tx",href:`https://orbmarkets.io/tx/${y}`}):at.success(_);break}case"setu.fiat.checkout_created":{u(),s(!1),n.current&&(l(n.current),n.current=null),at.success("💳 Complete payment, then retry your message");break}case"setu.payment.error":{u();const w=typeof v?.error=="string"?v.error:"Payment failed";s(!1),n.current&&(l(n.current),n.current=null),at.error(`❌ ${w}`);break}}});return()=>{f(),d.disconnect()}},[e,i,s,l,c,o,u])}const id=k6({component:wte});function wte(){const{checkOnboarding:e}=G1();return z.useEffect(()=>{e()},[e]),m.jsxs(m.Fragment,{children:[m.jsx(MO,{}),m.jsx(yte,{}),m.jsx(z1,{}),null]})}const Cte=Jo("/")({beforeLoad:()=>{throw xO({to:"/sessions"})},component:()=>null});const kte=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Tte=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,i)=>i?i.toUpperCase():n.toLowerCase()),eO=e=>{const t=Tte(e);return t.charAt(0).toUpperCase()+t.slice(1)},q5=(...e)=>e.filter((t,n,i)=>!!t&&t.trim()!==""&&i.indexOf(t)===n).join(" ").trim(),Ate=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0};var Rte={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const Nte=z.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:i,className:s="",children:l,iconNode:c,...o},u)=>z.createElement("svg",{ref:u,...Rte,width:t,height:t,stroke:e,strokeWidth:i?Number(n)*24/Number(t):n,className:q5("lucide",s),...!l&&!Ate(o)&&{"aria-hidden":"true"},...o},[...c.map(([d,p])=>z.createElement(d,p)),...Array.isArray(l)?l:[l]]));const bl=(e,t)=>{const n=z.forwardRef(({className:i,...s},l)=>z.createElement(Nte,{ref:l,iconNode:t,className:q5(`lucide-${kte(eO(e))}`,`lucide-${e}`,i),...s}));return n.displayName=eO(e),n};const Ote=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Dte=bl("chevron-right",Ote);const Ite=[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]],Lte=bl("moon",Ite);const Mte=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],tO=bl("plus",Mte);const jte=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]],Bte=bl("sun",jte);const Fte=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Pte=bl("x",Fte),Ute=z.memo(function({children:t,onNewSession:n}){const i=Tt(c=>c.isDiffOpen),s=Ca(c=>c.isCollapsed),l=Ca(c=>c.toggleCollapse);return z.useEffect(()=>(s?document.body.style.overflow="":document.body.style.overflow="hidden",()=>{document.body.style.overflow=""}),[s]),s?m.jsxs("aside",{className:"w-12 md:w-12 border-r border-border bg-background flex flex-col transition-all duration-300 ease-in-out hidden md:flex",children:[m.jsx("div",{className:"h-14 border-b border-border flex items-center justify-center",children:m.jsx(st,{variant:"ghost",size:"icon",onClick:n,title:"New session",className:"rounded-full touch-manipulation",children:m.jsx(tO,{className:"w-4 h-4"})})}),m.jsx("button",{type:"button",className:"flex-1 cursor-pointer hover:bg-muted/50 transition-colors touch-manipulation",onClick:i?void 0:l,title:i?void 0:"Expand sidebar","aria-label":"Expand sidebar"}),m.jsx("div",{className:"h-12 border-t border-border flex items-center justify-center",children:m.jsx(st,{variant:"ghost",size:"icon",onClick:l,title:"Expand sidebar",disabled:i,className:"transition-transform duration-200 hover:scale-110 touch-manipulation",children:m.jsx(Dte,{className:"w-4 h-4"})})})]}):m.jsxs(m.Fragment,{children:[!s&&m.jsx("div",{className:"fixed inset-0 bg-black/50 z-40 md:hidden",onClick:l,"aria-hidden":"true"}),m.jsxs("aside",{className:"w-full md:w-64 border-r border-border bg-background flex flex-col transition-all duration-300 ease-in-out fixed md:relative top-0 left-0 z-50 h-screen md:h-auto",children:[m.jsxs("div",{className:"h-14 border-b border-border px-4 flex items-center gap-2 md:hidden bg-background",children:[m.jsx(st,{variant:"ghost",size:"icon",onClick:l,title:"Close menu",className:"touch-manipulation flex-shrink-0","aria-label":"Close menu",children:m.jsx(Pte,{className:"w-5 h-5"})}),m.jsx("h1",{className:"text-lg font-semibold text-foreground flex-1",children:"AGI"})]}),m.jsx("div",{className:"h-14 border-b border-border px-4 flex items-center gap-2",children:m.jsxs(st,{variant:"primary",size:"sm",onClick:n,className:"flex-1 touch-manipulation",children:[m.jsx(tO,{className:"w-4 h-4 mr-2"}),"New Session"]})}),m.jsx("div",{className:"flex-1 overflow-y-auto scrollbar-hide",children:t}),m.jsx("div",{className:"h-12 border-t border-border px-2 flex items-center justify-end",children:m.jsx(st,{variant:"ghost",size:"icon",onClick:l,title:"Collapse sidebar",disabled:i,className:"transition-transform duration-200 hover:scale-110 touch-manipulation",children:m.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"transition-transform duration-300",role:"img","aria-label":"Collapse sidebar",children:[m.jsx("title",{children:"Collapse sidebar"}),m.jsx("path",{d:"M15 18l-6-6 6-6"})]})})})]})]})}),Hte=z.memo(function({sidebar:t,children:n,onNewSession:i,theme:s,onToggleTheme:l,sessionId:c,onNavigateToSession:o}){return m.jsxs("div",{className:"h-screen flex bg-background touch-manipulation border-t border-border/50",children:[m.jsx(Ute,{onNewSession:i,children:t}),m.jsxs("main",{className:"flex-1 flex flex-col overflow-hidden relative w-full md:w-auto",children:[m.jsx(jee,{}),m.jsx(Yee,{}),n]}),m.jsxs("div",{className:"hidden md:flex",children:[m.jsx(Oee,{}),m.jsx(zee,{sessionId:c}),m.jsx(mP,{}),m.jsx(tte,{parentSessionId:c??null,onNavigateToSession:o}),m.jsx(fte,{}),m.jsxs("div",{className:"flex flex-col w-12 border-l border-border bg-background",children:[m.jsx(Dee,{}),m.jsx(qee,{sessionId:c}),m.jsx(gP,{}),m.jsx(rte,{parentSessionId:c}),m.jsx("div",{className:"flex-1"}),m.jsx(mte,{}),m.jsx("div",{className:"h-12 border-t border-border flex items-center justify-center",children:m.jsx(st,{variant:"ghost",size:"icon",onClick:l,title:`Switch to ${s==="dark"?"light":"dark"} mode`,"aria-label":`Switch to ${s==="dark"?"light":"dark"} mode`,className:"touch-manipulation",children:s==="dark"?m.jsx(Bte,{className:"w-4 h-4"}):m.jsx(Lte,{className:"w-4 h-4"})})})]})]}),m.jsx(Bee,{}),m.jsx(vP,{})]})});function $5({sessionId:e}){const t=z.useRef(null),n=WU(),{data:i}=c1(),{theme:s,toggleTheme:l}=xte(),{openCommitModal:c,openDiff:o}=Tt(),u=Dc(),{data:d=[]}=qc(),{data:p}=Gc(),f=Wc(),g=d1(),v=qD(),w=$D(),E=s1(N=>N.openConfirmation);_te(),Ete(e),Vc(i?.defaults?.provider);const y=z.useCallback(()=>{setTimeout(()=>{t.current?.focus()},100)},[]),S=z.useCallback(async()=>{try{const N=await n.mutateAsync({agent:i?.defaults.agent||"general",provider:i?.defaults.provider,model:i?.defaults.model});u({to:"/sessions/$sessionId",params:{sessionId:N.id},replace:!1}),y()}catch(N){console.error("Failed to create session:",N)}},[n,i,u,y]),x=z.useCallback(()=>{u({to:"/sessions"})},[u]),_=z.useCallback(N=>{u({to:"/sessions/$sessionId",params:{sessionId:N}}),y()},[u,y]),C=z.useMemo(()=>p?[...(p.conflicted??[]).map(N=>({path:N.path,staged:!1,status:N.status})),...p.staged.map(N=>({path:N.path,staged:!0,status:N.status})),...p.unstaged.map(N=>({path:N.path,staged:!1,status:N.status})),...p.untracked.map(N=>({path:N.path,staged:!1,status:N.status}))]:[],[p]),O=z.useMemo(()=>d.map(N=>N.id),[d]);Ste({sessionIds:O,activeSessionId:e,gitFiles:C,onSelectSession:_,onNewSession:S,onStageFile:N=>f.mutate([N]),onUnstageFile:N=>g.mutate([N]),onRestoreFile:N=>v.mutate([N]),onDeleteFile:N=>{E({title:"Delete File",message:`Delete ${N}? This will permanently remove the untracked file.`,confirmLabel:"Delete",variant:"destructive",onConfirm:async()=>{await w.mutateAsync([N])}})},onStageAll:()=>{const N=C.filter(A=>!A.staged).map(A=>A.path);N.length>0&&f.mutate(N)},onUnstageAll:()=>{const N=C.filter(A=>A.staged).map(A=>A.path);N.length>0&&g.mutate(N)},onOpenCommitModal:c,onViewDiff:o,onReturnToInput:y}),z.useEffect(()=>{e&&y()},[e,y]);const T=z.useMemo(()=>e?m.jsxs(m.Fragment,{children:[m.jsx(See,{sessionId:e,onSelectSession:_}),m.jsx(c7,{ref:t,sessionId:e,onNewSession:S,onDeleteSession:x})]}):m.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:"Select a session or create a new one to start"}),[e,S,_,x]);return m.jsxs(m.Fragment,{children:[m.jsx(Hte,{onNewSession:S,theme:s,onToggleTheme:l,sessionId:e,onNavigateToSession:_,sidebar:m.jsx(wee,{activeSessionId:e,onSelectSession:_}),children:T}),m.jsx(EP,{})]})}const zte=Jo("/sessions/")({component:qte});function qte(){return m.jsx($5,{})}const G5=Jo("/sessions/$sessionId")({component:$te});function $te(){const{sessionId:e}=G5.useParams();return m.jsx($5,{sessionId:e})}const Gte=Cte.update({id:"/",path:"/",getParentRoute:()=>id}),Wte=zte.update({id:"/sessions/",path:"/sessions/",getParentRoute:()=>id}),Vte=G5.update({id:"/sessions/$sessionId",path:"/sessions/$sessionId",getParentRoute:()=>id}),Kte={IndexRoute:Gte,SessionsSessionIdRoute:Vte,SessionsIndexRoute:Wte},Yte=id._addFileChildren(Kte)._addFileTypes(),Xte=()=>{const n=(typeof globalThis<"u"?globalThis.AGI_ROUTER_BASEPATH:void 0)??"/"??"/";if(!n||n==="/")return"/";const i=n.replace(/\/+$/,"")||"/";return i.startsWith("/")?i:`/${i}`},Zte=L6({routeTree:Yte,basepath:Xte()}),Qte=new B4({defaultOptions:{queries:{refetchOnWindowFocus:!1,retry:1,structuralSharing:!0}}});function Jte(){return m.jsx(F4,{client:Qte,children:m.jsx(B6,{router:Zte})})}const W5=document.getElementById("root");if(!W5)throw new Error("Root element not found");p4.createRoot(W5).render(m.jsx(z.StrictMode,{children:m.jsx(Jte,{})}));
|
|
146
|
+
`)}`}return v?/@@ -\d+(?:,\d+)? \+\d+(?:,\d+)? @@/.test(v)?v:$ee(v):null},[p,n]);if(z.useEffect(()=>{if(t&&!d.current){const{isCollapsed:v}=Ca.getState();u.current=v,o(!0)}else!t&&d.current&&u.current!==null&&(o(u.current),u.current=null);d.current=t},[t,o]),z.useEffect(()=>{const v=w=>{const E=w.target,y=E.tagName==="INPUT"||E.tagName==="TEXTAREA"||E.isContentEditable;(w.key==="Escape"||w.key==="q"&&!y)&&t&&c(),!y&&t&&i.length>1&&(w.key==="ArrowLeft"||w.key==="["?(w.preventDefault(),l(Math.max(0,s-1))):(w.key==="ArrowRight"||w.key==="]")&&(w.preventDefault(),l(Math.min(i.length-1,s+1))))};return document.addEventListener("keydown",v),()=>document.removeEventListener("keydown",v)},[t,c,i.length,s,l]),!t||!n||!p)return null;const g=i.length>1;return m.jsxs("div",{className:"absolute inset-0 bg-background z-50 flex flex-col animate-in slide-in-from-left duration-300",children:[m.jsxs("div",{className:"h-14 border-b border-border px-4 flex items-center gap-3 shrink-0",children:[m.jsx(st,{variant:"ghost",size:"icon",onClick:c,title:"Close diff viewer (ESC)",children:m.jsx(cn,{className:"w-4 h-4"})}),m.jsxs("div",{className:"flex-1 flex items-center gap-2 min-w-0",children:[m.jsx("span",{className:"text-sm font-medium text-foreground font-mono truncate",title:n,children:n}),m.jsx("span",{className:"text-xs px-2 py-0.5 rounded bg-primary/10 text-primary flex-shrink-0 capitalize",children:p.operation}),p.artifact?.summary&&m.jsxs("div",{className:"flex items-center gap-1 text-xs flex-shrink-0",children:[m.jsxs("span",{className:"text-green-500",children:["+",p.artifact.summary.additions]}),m.jsxs("span",{className:"text-red-500",children:["-",p.artifact.summary.deletions]})]})]}),g&&m.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[m.jsx(st,{variant:"ghost",size:"icon",onClick:()=>l(Math.max(0,s-1)),disabled:s===0,title:"Previous operation (←)",children:m.jsx(oj,{className:"w-4 h-4"})}),m.jsxs("span",{className:"text-xs text-muted-foreground min-w-[60px] text-center",children:[s+1," / ",i.length]}),m.jsx(st,{variant:"ghost",size:"icon",onClick:()=>l(Math.min(i.length-1,s+1)),disabled:s===i.length-1,title:"Next operation (→)",children:m.jsx(an,{className:"w-4 h-4"})})]})]}),g&&m.jsx("div",{className:"border-b border-border px-4 py-2 flex gap-2 overflow-x-auto shrink-0",children:i.map((v,w)=>m.jsxs("button",{type:"button",onClick:()=>l(w),className:`px-3 py-1.5 text-xs rounded-md flex items-center gap-2 shrink-0 transition-colors ${w===s?"bg-primary text-primary-foreground":"bg-muted hover:bg-muted/80 text-muted-foreground"}`,children:[m.jsx("span",{className:"capitalize",children:v.operation}),m.jsx("span",{className:"opacity-70",children:Kee(v.timestamp)}),v.artifact?.summary&&m.jsxs("span",{className:"opacity-70",children:["+",v.artifact.summary.additions,"/-",v.artifact.summary.deletions]})]},v.toolCallId))}),m.jsx("div",{className:"flex-1 overflow-hidden p-4",children:f?m.jsx(Vee,{patch:f}):m.jsx("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:"No diff content available"})})]})}),Xee={};class Zee{get baseUrl(){const t=window;if(t.AGI_SERVER_URL)return t.AGI_SERVER_URL;if(!Xee?.VITE_API_BASE_URL)return Hc}async listResearchSessions(t){const n=await fetch(`${this.baseUrl}/v1/sessions/${t}/research`,{method:"GET",headers:{"Content-Type":"application/json"}});if(!n.ok){const i=await n.json().catch(()=>({error:"Failed to fetch research sessions"}));throw new Error(i.error||"Failed to fetch research sessions")}return n.json()}async createResearchSession(t,n){const i=await fetch(`${this.baseUrl}/v1/sessions/${t}/research`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!i.ok){const s=await i.json().catch(()=>({error:"Failed to create research session"}));throw new Error(s.error||"Failed to create research session")}return i.json()}async deleteResearchSession(t){const n=await fetch(`${this.baseUrl}/v1/research/${t}`,{method:"DELETE",headers:{"Content-Type":"application/json"}});if(!n.ok){const i=await n.json().catch(()=>({error:"Failed to delete research session"}));throw new Error(i.error||"Failed to delete research session")}return n.json()}async injectContext(t,n,i){const s=await fetch(`${this.baseUrl}/v1/sessions/${t}/inject`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({researchSessionId:n,label:i})});if(!s.ok){const l=await s.json().catch(()=>({error:"Failed to inject context"}));throw new Error(l.error||"Failed to inject context")}return s.json()}async exportToNewSession(t,n){const i=await fetch(`${this.baseUrl}/v1/research/${t}/export`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n??{})});if(!i.ok){const s=await i.json().catch(()=>({error:"Failed to export to session"}));throw new Error(s.error||"Failed to export to session")}return i.json()}}const rd=new Zee;function N5(e){return Vn({queryKey:["research","sessions",e],queryFn:()=>rd.listResearchSessions(e),enabled:!!e,staleTime:3e4})}function Qee(){const e=Ot();return Zt({mutationFn:({parentSessionId:t,data:n})=>rd.createResearchSession(t,n??{}),onSuccess:(t,{parentSessionId:n})=>{e.invalidateQueries({queryKey:["research","sessions",n]})}})}function Jee(){const e=nc(t=>t.addContext);return Zt({mutationFn:({parentSessionId:t,researchSessionId:n,label:i})=>rd.injectContext(t,n,i),onSuccess:(t,{parentSessionId:n})=>{e(n,{id:t.sessionId,sessionId:t.sessionId,label:t.label,content:t.content})}})}function ete(){const e=Ot();return Zt({mutationFn:({researchId:t,data:n})=>rd.exportToNewSession(t,n),onSuccess:()=>{e.invalidateQueries({queryKey:["sessions"]})}})}const tte=z.memo(function({parentSessionId:t,onNavigateToSession:n}){const i=zn(q=>q.isExpanded),s=zn(q=>q.collapseSidebar),l=zn(q=>q.activeResearchSessionId),c=zn(q=>q.selectResearchSession),[o,u]=z.useState(!1),[d,p]=z.useState(""),[f,g]=z.useState(!1),[v,w]=z.useState("idle"),E=z.useRef(null),y=z.useRef(null),{data:S,isLoading:x,refetch:_}=N5(t),C=Qee(),O=Jee(),T=ete(),{data:N}=$c(),{data:A}=_c(l??void 0),{data:D}=_c(t??void 0);A5(l??void 0);const L=zD(l??""),I=Ot(),j=Zt({mutationFn:async({sessionId:q,content:te})=>Te.sendMessage(q,{content:te}),onSuccess:(q,{sessionId:te})=>{I.invalidateQueries({queryKey:["messages",te]})}});z.useEffect(()=>{t&&zn.getState().setParentSessionId(t)},[t]),z.useEffect(()=>{S?.sessions?.length?S.sessions.some(te=>te.id===l)||c(S.sessions[0].id):S?.sessions?.length===0&&c(null)},[S,l,c]),z.useEffect(()=>{y.current?.scrollIntoView({behavior:"smooth"})},[]);const F=z.useCallback(()=>{const q=E.current;q&&(q.style.height="auto",q.style.height=`${Math.min(q.scrollHeight,120)}px`)},[]);z.useEffect(()=>{F()},[F]);const V=z.useCallback(async()=>{if(t)try{const q=await C.mutateAsync({parentSessionId:t,data:{}});await _(),c(q.session.id),u(!1)}catch(q){console.error("Failed to create research session:",q)}},[t,C,c,_]),Y=z.useCallback(q=>{c(q.id),u(!1)},[c]),W=z.useCallback(async()=>{if(!t||!l)return;if(D?.some(be=>be.role==="system"&&be.parts?.some(Ee=>typeof Ee.content=="string"&&Ee.content.includes(`from="${l}"`)))){w("error"),setTimeout(()=>w("idle"),3e3);return}const se=`Research ${new Date().toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}`;try{await O.mutateAsync({parentSessionId:t,researchSessionId:l,label:se}),w("success"),setTimeout(()=>w("idle"),5e3),I.invalidateQueries({queryKey:["messages",t]})}catch(be){console.error("Failed to inject context:",be),w("error"),setTimeout(()=>w("idle"),3e3)}},[t,l,O,D,I]),K=z.useCallback(async()=>{if(l)try{const q=await T.mutateAsync({researchId:l});n&&q.newSession?.id&&n(q.newSession.id)}catch(q){console.error("Failed to export to session:",q)}},[l,T,n]),X=z.useCallback(async()=>{if(!(!d.trim()||!t))try{let q=l;q||(q=(await C.mutateAsync({parentSessionId:t,data:{}})).session.id,c(q)),await j.mutateAsync({sessionId:q,content:d}),p(""),E.current&&(E.current.style.height="auto")}catch(q){console.error("Failed to send message:",q)}},[d,t,l,C,c,j]),B=z.useCallback(q=>{q.key==="Enter"&&!q.shiftKey&&(q.preventDefault(),X())},[X]),M=z.useMemo(()=>A?.some(q=>q.role==="assistant"&&q.status==="pending")??!1,[A]),U=z.useMemo(()=>!l||!D?!1:D.some(q=>q.role==="system"&&q.parts?.some(te=>typeof te.content=="string"&&te.content.includes(`from="${l}"`))),[l,D]),$=z.useCallback(async(q,te)=>{if(l)try{await L.mutateAsync({provider:q,model:te}),g(!1)}catch(he){console.error("Failed to update research session model:",he)}},[l,L]);if(!i)return null;const H=S?.sessions??[],J=H.find(q=>q.id===l),oe=A??[],de=N?.[J?.provider??""]?.label??J?.provider,Z=N?.[J?.provider??""]?.models.find(q=>q.id===J?.model)?.label??J?.model;return m.jsxs("div",{className:"w-96 border-l border-border bg-background flex flex-col h-full",children:[m.jsxs("div",{className:"h-14 border-b border-border px-3 flex items-center justify-between",children:[m.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[m.jsx(el,{className:"w-4 h-4 text-teal-500"}),m.jsx("span",{className:"font-medium text-foreground text-sm",children:"Research"})]}),m.jsxs("div",{className:"flex items-center gap-0.5",children:[m.jsx(st,{variant:"ghost",size:"icon",onClick:()=>u(!o),title:"Research history",className:"h-8 w-8",children:m.jsx(nB,{className:"w-4 h-4"})}),m.jsx(st,{variant:"ghost",size:"icon",onClick:V,disabled:!t||C.isPending,title:"New research session",className:"h-8 w-8",children:C.isPending?m.jsx(rn,{className:"w-4 h-4 animate-spin"}):m.jsx(Ts,{className:"w-4 h-4"})}),m.jsx(st,{variant:"ghost",size:"icon",onClick:s,title:"Close sidebar",className:"h-8 w-8",children:m.jsx(an,{className:"w-4 h-4"})})]})]}),o?m.jsxs("div",{className:"flex-1 overflow-y-auto",children:[m.jsx("div",{className:"p-2 border-b border-border",children:m.jsx("div",{className:"text-xs font-medium text-muted-foreground px-2 py-1",children:"Research Sessions"})}),x?m.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:"Loading..."}):H.length===0?m.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:"No research sessions yet"}):m.jsx("div",{className:"p-2 space-y-1",children:H.map(q=>m.jsxs("button",{type:"button",onClick:()=>Y(q),className:`w-full text-left p-2 rounded-md text-sm transition-colors ${q.id===l?"bg-teal-500/10 border border-teal-500/30 text-foreground":"hover:bg-muted"}`,children:[m.jsx("div",{className:"font-medium truncate",children:q.title||"Untitled"}),m.jsxs("div",{className:"text-xs text-muted-foreground",children:[q.messageCount," messages •"," ",nte(q.lastActiveAt??q.createdAt)]})]},q.id))})]}):m.jsxs(m.Fragment,{children:[m.jsx("div",{className:"flex-1 overflow-y-auto px-3 py-3 research-messages text-[13px]",children:l?oe.length===0?m.jsx("div",{className:"text-xs text-muted-foreground text-center py-8",children:m.jsx("p",{children:"Ask a question to start researching."})}):m.jsxs("div",{className:"space-y-1.5",children:[oe.map((q,te)=>{if(q.role==="user"){const he=oe[te+1];return m.jsx(w5,{sessionId:l,message:q,isFirst:te===0,nextAssistantMessageId:he?.role==="assistant"?he.id:void 0},q.id)}if(q.role==="assistant"){const he=te>0?oe[te-1]:null,se=oe[te+1],be=he?.role!=="assistant",Ee=se?.role==="assistant";return m.jsx(E5,{sessionId:l,message:q,showHeader:be,hasNextAssistantMessage:Ee,isLastMessage:te===oe.length-1,compact:!0,onNavigateToSession:n},q.id)}return null}),m.jsx("div",{ref:y})]}):m.jsxs("div",{className:"text-xs text-muted-foreground text-center py-8",children:[m.jsx(el,{className:"w-8 h-8 mx-auto mb-2 text-muted-foreground/50"}),m.jsx("p",{children:"Start researching by asking a question below."})]})}),m.jsxs("div",{className:"p-3 border-t border-border",children:[m.jsx("div",{className:"relative flex flex-col rounded-3xl bg-card border border-border focus-within:border-teal-500/60 focus-within:ring-1 focus-within:ring-teal-500/40 p-1",children:m.jsxs("div",{className:"flex items-end gap-1",children:[m.jsx(zc,{ref:E,value:d,onChange:q=>p(q.target.value),onKeyDown:B,placeholder:"Ask anything...",disabled:!t||j.isPending||C.isPending,rows:1,className:"flex-1 border-0 bg-transparent pl-2 pr-1 py-2 max-h-[120px] overflow-y-auto leading-normal resize-none scrollbar-hide text-sm focus:ring-0 focus:outline-none",style:{height:"2.25rem"}}),m.jsx("button",{type:"button",onClick:X,disabled:!d.trim()||!t||j.isPending||C.isPending||M,className:`flex items-center justify-center w-9 h-9 rounded-full transition-colors flex-shrink-0 ${d.trim()&&t&&!M?"bg-teal-500 hover:bg-teal-600 text-white":"bg-transparent text-muted-foreground"}`,children:j.isPending||C.isPending?m.jsx(rn,{className:"w-4 h-4 animate-spin"}):m.jsx(PO,{className:"w-4 h-4"})})]})}),v==="success"&&m.jsxs("div",{className:"flex items-center gap-2 mt-2 px-2 py-1.5 text-xs rounded-lg bg-teal-500/10 border border-teal-500/30 text-teal-600 dark:text-teal-400",children:[m.jsx(ti,{className:"w-3 h-3 flex-shrink-0"}),m.jsx("span",{className:"flex-1",children:"Context injected — will be used on next request"}),m.jsx("button",{type:"button",onClick:()=>w("idle"),className:"hover:text-teal-500",children:m.jsx(cn,{className:"w-3 h-3"})})]}),v==="error"&&m.jsxs("div",{className:"flex items-center gap-2 mt-2 px-2 py-1.5 text-xs rounded-lg bg-red-500/10 border border-red-500/30 text-red-600 dark:text-red-400",children:[m.jsx(cn,{className:"w-3 h-3 flex-shrink-0"}),m.jsx("span",{className:"flex-1",children:"Failed to inject context"}),m.jsx("button",{type:"button",onClick:()=>w("idle"),className:"hover:text-red-500",children:m.jsx(cn,{className:"w-3 h-3"})})]}),m.jsxs("div",{className:"flex gap-2 mt-2",children:[m.jsxs("button",{type:"button",onClick:W,disabled:!l||O.isPending||M||U,className:`flex-1 flex items-center justify-center gap-1.5 px-2 py-1.5 text-xs rounded-lg transition-colors disabled:opacity-50 disabled:cursor-not-allowed ${U?"bg-teal-500/10 text-teal-600 dark:text-teal-400 border border-teal-500/30":"bg-muted hover:bg-muted/80 text-muted-foreground hover:text-foreground"}`,title:U?"Already injected into main session":"Inject findings into main session",children:[O.isPending?m.jsx(rn,{className:"w-3 h-3 animate-spin"}):U?m.jsx(ti,{className:"w-3 h-3"}):m.jsx($6,{className:"w-3 h-3"}),U?"Injected":"Inject"]}),m.jsxs("button",{type:"button",onClick:K,disabled:!l||T.isPending||M,className:"flex-1 flex items-center justify-center gap-1.5 px-2 py-1.5 text-xs rounded-lg bg-muted hover:bg-muted/80 text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50 disabled:cursor-not-allowed",title:"Export to new main session",children:[T.isPending?m.jsx(rn,{className:"w-3 h-3 animate-spin"}):m.jsx(Gn,{className:"w-3 h-3"}),"Export"]})]})]})]}),m.jsxs("div",{className:"h-12 px-3 border-t border-border text-xs text-muted-foreground flex items-center justify-between",children:[m.jsxs("span",{className:"text-[10px]",children:[H.length," research session",H.length!==1?"s":""]}),J&&m.jsxs("button",{type:"button",onClick:()=>g(!0),className:"flex items-center gap-1 text-[10px] hover:text-foreground transition-colors",children:[m.jsx("span",{className:"opacity-60",children:de}),m.jsx("span",{className:"opacity-40",children:"/"}),m.jsx("span",{children:Z}),m.jsx(mr,{className:"w-3 h-3 opacity-40"})]})]}),m.jsx(Ea,{isOpen:f,onClose:()=>g(!1),title:"Select Model for Research",maxWidth:"md",children:J&&m.jsx(YD,{provider:J.provider,model:J.model,onChange:$})})]})});function nte(e){const t=Date.now()-e,n=Math.floor(t/6e4);if(n<1)return"just now";if(n<60)return`${n}m ago`;const i=Math.floor(n/60);return i<24?`${i}h ago`:`${Math.floor(i/24)}d ago`}const rte=z.memo(function({parentSessionId:t}){const n=zn(c=>c.isExpanded),i=zn(c=>c.toggleSidebar),{data:s}=N5(t??null),l=s?.sessions?.length??0;return m.jsxs("button",{type:"button",onClick:i,className:`relative h-14 w-full transition-colors touch-manipulation flex items-center justify-center ${n?"bg-muted border-r-2 border-primary":"hover:bg-muted/50"}`,title:"Research (⌘⇧R)",children:[m.jsx(el,{className:"w-5 h-5 text-muted-foreground mx-auto"}),l>0&&m.jsx("span",{className:"absolute top-1 right-1 w-5 h-5 bg-primary text-primary-foreground text-xs rounded-full flex items-center justify-center font-semibold",children:l>9?"9+":l})]})});var ite=Object.defineProperty,Tc=Object.getOwnPropertySymbols,O5=Object.prototype.hasOwnProperty,D5=Object.prototype.propertyIsEnumerable,ZN=(e,t,n)=>t in e?ite(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Dv=(e,t)=>{for(var n in t||(t={}))O5.call(t,n)&&ZN(e,n,t[n]);if(Tc)for(var n of Tc(t))D5.call(t,n)&&ZN(e,n,t[n]);return e},Iv=(e,t)=>{var n={};for(var i in e)O5.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(e!=null&&Tc)for(var i of Tc(e))t.indexOf(i)<0&&D5.call(e,i)&&(n[i]=e[i]);return n};var ka;(e=>{const t=class Ye{constructor(u,d,p,f){if(this.version=u,this.errorCorrectionLevel=d,this.modules=[],this.isFunction=[],u<Ye.MIN_VERSION||u>Ye.MAX_VERSION)throw new RangeError("Version value out of range");if(f<-1||f>7)throw new RangeError("Mask value out of range");this.size=u*4+17;let g=[];for(let w=0;w<this.size;w++)g.push(!1);for(let w=0;w<this.size;w++)this.modules.push(g.slice()),this.isFunction.push(g.slice());this.drawFunctionPatterns();const v=this.addEccAndInterleave(p);if(this.drawCodewords(v),f==-1){let w=1e9;for(let E=0;E<8;E++){this.applyMask(E),this.drawFormatBits(E);const y=this.getPenaltyScore();y<w&&(f=E,w=y),this.applyMask(E)}}s(0<=f&&f<=7),this.mask=f,this.applyMask(f),this.drawFormatBits(f),this.isFunction=[]}static encodeText(u,d){const p=e.QrSegment.makeSegments(u);return Ye.encodeSegments(p,d)}static encodeBinary(u,d){const p=e.QrSegment.makeBytes(u);return Ye.encodeSegments([p],d)}static encodeSegments(u,d,p=1,f=40,g=-1,v=!0){if(!(Ye.MIN_VERSION<=p&&p<=f&&f<=Ye.MAX_VERSION)||g<-1||g>7)throw new RangeError("Invalid value");let w,E;for(w=p;;w++){const _=Ye.getNumDataCodewords(w,d)*8,C=c.getTotalBits(u,w);if(C<=_){E=C;break}if(w>=f)throw new RangeError("Data too long")}for(const _ of[Ye.Ecc.MEDIUM,Ye.Ecc.QUARTILE,Ye.Ecc.HIGH])v&&E<=Ye.getNumDataCodewords(w,_)*8&&(d=_);let y=[];for(const _ of u){n(_.mode.modeBits,4,y),n(_.numChars,_.mode.numCharCountBits(w),y);for(const C of _.getData())y.push(C)}s(y.length==E);const S=Ye.getNumDataCodewords(w,d)*8;s(y.length<=S),n(0,Math.min(4,S-y.length),y),n(0,(8-y.length%8)%8,y),s(y.length%8==0);for(let _=236;y.length<S;_^=253)n(_,8,y);let x=[];for(;x.length*8<y.length;)x.push(0);return y.forEach((_,C)=>x[C>>>3]|=_<<7-(C&7)),new Ye(w,d,x,g)}getModule(u,d){return 0<=u&&u<this.size&&0<=d&&d<this.size&&this.modules[d][u]}getModules(){return this.modules}drawFunctionPatterns(){for(let p=0;p<this.size;p++)this.setFunctionModule(6,p,p%2==0),this.setFunctionModule(p,6,p%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);const u=this.getAlignmentPatternPositions(),d=u.length;for(let p=0;p<d;p++)for(let f=0;f<d;f++)p==0&&f==0||p==0&&f==d-1||p==d-1&&f==0||this.drawAlignmentPattern(u[p],u[f]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(u){const d=this.errorCorrectionLevel.formatBits<<3|u;let p=d;for(let g=0;g<10;g++)p=p<<1^(p>>>9)*1335;const f=(d<<10|p)^21522;s(f>>>15==0);for(let g=0;g<=5;g++)this.setFunctionModule(8,g,i(f,g));this.setFunctionModule(8,7,i(f,6)),this.setFunctionModule(8,8,i(f,7)),this.setFunctionModule(7,8,i(f,8));for(let g=9;g<15;g++)this.setFunctionModule(14-g,8,i(f,g));for(let g=0;g<8;g++)this.setFunctionModule(this.size-1-g,8,i(f,g));for(let g=8;g<15;g++)this.setFunctionModule(8,this.size-15+g,i(f,g));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let u=this.version;for(let p=0;p<12;p++)u=u<<1^(u>>>11)*7973;const d=this.version<<12|u;s(d>>>18==0);for(let p=0;p<18;p++){const f=i(d,p),g=this.size-11+p%3,v=Math.floor(p/3);this.setFunctionModule(g,v,f),this.setFunctionModule(v,g,f)}}drawFinderPattern(u,d){for(let p=-4;p<=4;p++)for(let f=-4;f<=4;f++){const g=Math.max(Math.abs(f),Math.abs(p)),v=u+f,w=d+p;0<=v&&v<this.size&&0<=w&&w<this.size&&this.setFunctionModule(v,w,g!=2&&g!=4)}}drawAlignmentPattern(u,d){for(let p=-2;p<=2;p++)for(let f=-2;f<=2;f++)this.setFunctionModule(u+f,d+p,Math.max(Math.abs(f),Math.abs(p))!=1)}setFunctionModule(u,d,p){this.modules[d][u]=p,this.isFunction[d][u]=!0}addEccAndInterleave(u){const d=this.version,p=this.errorCorrectionLevel;if(u.length!=Ye.getNumDataCodewords(d,p))throw new RangeError("Invalid argument");const f=Ye.NUM_ERROR_CORRECTION_BLOCKS[p.ordinal][d],g=Ye.ECC_CODEWORDS_PER_BLOCK[p.ordinal][d],v=Math.floor(Ye.getNumRawDataModules(d)/8),w=f-v%f,E=Math.floor(v/f);let y=[];const S=Ye.reedSolomonComputeDivisor(g);for(let _=0,C=0;_<f;_++){let O=u.slice(C,C+E-g+(_<w?0:1));C+=O.length;const T=Ye.reedSolomonComputeRemainder(O,S);_<w&&O.push(0),y.push(O.concat(T))}let x=[];for(let _=0;_<y[0].length;_++)y.forEach((C,O)=>{(_!=E-g||O>=w)&&x.push(C[_])});return s(x.length==v),x}drawCodewords(u){if(u.length!=Math.floor(Ye.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let d=0;for(let p=this.size-1;p>=1;p-=2){p==6&&(p=5);for(let f=0;f<this.size;f++)for(let g=0;g<2;g++){const v=p-g,E=(p+1&2)==0?this.size-1-f:f;!this.isFunction[E][v]&&d<u.length*8&&(this.modules[E][v]=i(u[d>>>3],7-(d&7)),d++)}}s(d==u.length*8)}applyMask(u){if(u<0||u>7)throw new RangeError("Mask value out of range");for(let d=0;d<this.size;d++)for(let p=0;p<this.size;p++){let f;switch(u){case 0:f=(p+d)%2==0;break;case 1:f=d%2==0;break;case 2:f=p%3==0;break;case 3:f=(p+d)%3==0;break;case 4:f=(Math.floor(p/3)+Math.floor(d/2))%2==0;break;case 5:f=p*d%2+p*d%3==0;break;case 6:f=(p*d%2+p*d%3)%2==0;break;case 7:f=((p+d)%2+p*d%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[d][p]&&f&&(this.modules[d][p]=!this.modules[d][p])}}getPenaltyScore(){let u=0;for(let g=0;g<this.size;g++){let v=!1,w=0,E=[0,0,0,0,0,0,0];for(let y=0;y<this.size;y++)this.modules[g][y]==v?(w++,w==5?u+=Ye.PENALTY_N1:w>5&&u++):(this.finderPenaltyAddHistory(w,E),v||(u+=this.finderPenaltyCountPatterns(E)*Ye.PENALTY_N3),v=this.modules[g][y],w=1);u+=this.finderPenaltyTerminateAndCount(v,w,E)*Ye.PENALTY_N3}for(let g=0;g<this.size;g++){let v=!1,w=0,E=[0,0,0,0,0,0,0];for(let y=0;y<this.size;y++)this.modules[y][g]==v?(w++,w==5?u+=Ye.PENALTY_N1:w>5&&u++):(this.finderPenaltyAddHistory(w,E),v||(u+=this.finderPenaltyCountPatterns(E)*Ye.PENALTY_N3),v=this.modules[y][g],w=1);u+=this.finderPenaltyTerminateAndCount(v,w,E)*Ye.PENALTY_N3}for(let g=0;g<this.size-1;g++)for(let v=0;v<this.size-1;v++){const w=this.modules[g][v];w==this.modules[g][v+1]&&w==this.modules[g+1][v]&&w==this.modules[g+1][v+1]&&(u+=Ye.PENALTY_N2)}let d=0;for(const g of this.modules)d=g.reduce((v,w)=>v+(w?1:0),d);const p=this.size*this.size,f=Math.ceil(Math.abs(d*20-p*10)/p)-1;return s(0<=f&&f<=9),u+=f*Ye.PENALTY_N4,s(0<=u&&u<=2568888),u}getAlignmentPatternPositions(){if(this.version==1)return[];{const u=Math.floor(this.version/7)+2,d=this.version==32?26:Math.ceil((this.version*4+4)/(u*2-2))*2;let p=[6];for(let f=this.size-7;p.length<u;f-=d)p.splice(1,0,f);return p}}static getNumRawDataModules(u){if(u<Ye.MIN_VERSION||u>Ye.MAX_VERSION)throw new RangeError("Version number out of range");let d=(16*u+128)*u+64;if(u>=2){const p=Math.floor(u/7)+2;d-=(25*p-10)*p-55,u>=7&&(d-=36)}return s(208<=d&&d<=29648),d}static getNumDataCodewords(u,d){return Math.floor(Ye.getNumRawDataModules(u)/8)-Ye.ECC_CODEWORDS_PER_BLOCK[d.ordinal][u]*Ye.NUM_ERROR_CORRECTION_BLOCKS[d.ordinal][u]}static reedSolomonComputeDivisor(u){if(u<1||u>255)throw new RangeError("Degree out of range");let d=[];for(let f=0;f<u-1;f++)d.push(0);d.push(1);let p=1;for(let f=0;f<u;f++){for(let g=0;g<d.length;g++)d[g]=Ye.reedSolomonMultiply(d[g],p),g+1<d.length&&(d[g]^=d[g+1]);p=Ye.reedSolomonMultiply(p,2)}return d}static reedSolomonComputeRemainder(u,d){let p=d.map(f=>0);for(const f of u){const g=f^p.shift();p.push(0),d.forEach((v,w)=>p[w]^=Ye.reedSolomonMultiply(v,g))}return p}static reedSolomonMultiply(u,d){if(u>>>8||d>>>8)throw new RangeError("Byte out of range");let p=0;for(let f=7;f>=0;f--)p=p<<1^(p>>>7)*285,p^=(d>>>f&1)*u;return s(p>>>8==0),p}finderPenaltyCountPatterns(u){const d=u[1];s(d<=this.size*3);const p=d>0&&u[2]==d&&u[3]==d*3&&u[4]==d&&u[5]==d;return(p&&u[0]>=d*4&&u[6]>=d?1:0)+(p&&u[6]>=d*4&&u[0]>=d?1:0)}finderPenaltyTerminateAndCount(u,d,p){return u&&(this.finderPenaltyAddHistory(d,p),d=0),d+=this.size,this.finderPenaltyAddHistory(d,p),this.finderPenaltyCountPatterns(p)}finderPenaltyAddHistory(u,d){d[0]==0&&(u+=this.size),d.pop(),d.unshift(u)}};t.MIN_VERSION=1,t.MAX_VERSION=40,t.PENALTY_N1=3,t.PENALTY_N2=3,t.PENALTY_N3=40,t.PENALTY_N4=10,t.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],t.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],e.QrCode=t;function n(o,u,d){if(u<0||u>31||o>>>u)throw new RangeError("Value out of range");for(let p=u-1;p>=0;p--)d.push(o>>>p&1)}function i(o,u){return(o>>>u&1)!=0}function s(o){if(!o)throw new Error("Assertion error")}const l=class Mt{constructor(u,d,p){if(this.mode=u,this.numChars=d,this.bitData=p,d<0)throw new RangeError("Invalid argument");this.bitData=p.slice()}static makeBytes(u){let d=[];for(const p of u)n(p,8,d);return new Mt(Mt.Mode.BYTE,u.length,d)}static makeNumeric(u){if(!Mt.isNumeric(u))throw new RangeError("String contains non-numeric characters");let d=[];for(let p=0;p<u.length;){const f=Math.min(u.length-p,3);n(parseInt(u.substring(p,p+f),10),f*3+1,d),p+=f}return new Mt(Mt.Mode.NUMERIC,u.length,d)}static makeAlphanumeric(u){if(!Mt.isAlphanumeric(u))throw new RangeError("String contains unencodable characters in alphanumeric mode");let d=[],p;for(p=0;p+2<=u.length;p+=2){let f=Mt.ALPHANUMERIC_CHARSET.indexOf(u.charAt(p))*45;f+=Mt.ALPHANUMERIC_CHARSET.indexOf(u.charAt(p+1)),n(f,11,d)}return p<u.length&&n(Mt.ALPHANUMERIC_CHARSET.indexOf(u.charAt(p)),6,d),new Mt(Mt.Mode.ALPHANUMERIC,u.length,d)}static makeSegments(u){return u==""?[]:Mt.isNumeric(u)?[Mt.makeNumeric(u)]:Mt.isAlphanumeric(u)?[Mt.makeAlphanumeric(u)]:[Mt.makeBytes(Mt.toUtf8ByteArray(u))]}static makeEci(u){let d=[];if(u<0)throw new RangeError("ECI assignment value out of range");if(u<128)n(u,8,d);else if(u<16384)n(2,2,d),n(u,14,d);else if(u<1e6)n(6,3,d),n(u,21,d);else throw new RangeError("ECI assignment value out of range");return new Mt(Mt.Mode.ECI,0,d)}static isNumeric(u){return Mt.NUMERIC_REGEX.test(u)}static isAlphanumeric(u){return Mt.ALPHANUMERIC_REGEX.test(u)}getData(){return this.bitData.slice()}static getTotalBits(u,d){let p=0;for(const f of u){const g=f.mode.numCharCountBits(d);if(f.numChars>=1<<g)return 1/0;p+=4+g+f.bitData.length}return p}static toUtf8ByteArray(u){u=encodeURI(u);let d=[];for(let p=0;p<u.length;p++)u.charAt(p)!="%"?d.push(u.charCodeAt(p)):(d.push(parseInt(u.substring(p+1,p+3),16)),p+=2);return d}};l.NUMERIC_REGEX=/^[0-9]*$/,l.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,l.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";let c=l;e.QrSegment=l})(ka||(ka={}));(e=>{(t=>{const n=class{constructor(s,l){this.ordinal=s,this.formatBits=l}};n.LOW=new n(0,1),n.MEDIUM=new n(1,0),n.QUARTILE=new n(2,3),n.HIGH=new n(3,2),t.Ecc=n})(e.QrCode||(e.QrCode={}))})(ka||(ka={}));(e=>{(t=>{const n=class{constructor(s,l){this.modeBits=s,this.numBitsCharCount=l}numCharCountBits(s){return this.numBitsCharCount[Math.floor((s+7)/17)]}};n.NUMERIC=new n(1,[10,12,14]),n.ALPHANUMERIC=new n(2,[9,11,13]),n.BYTE=new n(4,[8,16,16]),n.KANJI=new n(8,[8,10,12]),n.ECI=new n(7,[0,0,0]),t.Mode=n})(e.QrSegment||(e.QrSegment={}))})(ka||(ka={}));var xs=ka;var ate={L:xs.QrCode.Ecc.LOW,M:xs.QrCode.Ecc.MEDIUM,Q:xs.QrCode.Ecc.QUARTILE,H:xs.QrCode.Ecc.HIGH},I5=128,L5="L",M5="#FFFFFF",j5="#000000",B5=!1,F5=1,ste=4,ote=0,lte=.1;function P5(e,t=0){const n=[];return e.forEach(function(i,s){let l=null;i.forEach(function(c,o){if(!c&&l!==null){n.push(`M${l+t} ${s+t}h${o-l}v1H${l+t}z`),l=null;return}if(o===i.length-1){if(!c)return;l===null?n.push(`M${o+t},${s+t} h1v1H${o+t}z`):n.push(`M${l+t},${s+t} h${o+1-l}v1H${l+t}z`);return}c&&l===null&&(l=o)})}),n.join("")}function U5(e,t){return e.slice().map((n,i)=>i<t.y||i>=t.y+t.h?n:n.map((s,l)=>l<t.x||l>=t.x+t.w?s:!1))}function ute(e,t,n,i){if(i==null)return null;const s=e.length+n*2,l=Math.floor(t*lte),c=s/t,o=(i.width||l)*c,u=(i.height||l)*c,d=i.x==null?e.length/2-o/2:i.x*c,p=i.y==null?e.length/2-u/2:i.y*c,f=i.opacity==null?1:i.opacity;let g=null;if(i.excavate){let w=Math.floor(d),E=Math.floor(p),y=Math.ceil(o+d-w),S=Math.ceil(u+p-E);g={x:w,y:E,w:y,h:S}}const v=i.crossOrigin;return{x:d,y:p,h:u,w:o,excavation:g,opacity:f,crossOrigin:v}}function cte(e,t){return t!=null?Math.max(Math.floor(t),0):e?ste:ote}function H5({value:e,level:t,minVersion:n,includeMargin:i,marginSize:s,imageSettings:l,size:c,boostLevel:o}){let u=Je.useMemo(()=>{const w=(Array.isArray(e)?e:[e]).reduce((E,y)=>(E.push(...xs.QrSegment.makeSegments(y)),E),[]);return xs.QrCode.encodeSegments(w,ate[t],n,void 0,void 0,o)},[e,t,n,o]);const{cells:d,margin:p,numCells:f,calculatedImageSettings:g}=Je.useMemo(()=>{let v=u.getModules();const w=cte(i,s),E=v.length+w*2,y=ute(v,c,w,l);return{cells:v,margin:w,numCells:E,calculatedImageSettings:y}},[u,c,l,i,s]);return{qrcode:u,margin:p,cells:d,numCells:f,calculatedImageSettings:g}}var dte=(function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0})(),hte=Je.forwardRef(function(t,n){const i=t,{value:s,size:l=I5,level:c=L5,bgColor:o=M5,fgColor:u=j5,includeMargin:d=B5,minVersion:p=F5,boostLevel:f,marginSize:g,imageSettings:v}=i,E=Iv(i,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:y}=E,S=Iv(E,["style"]),x=v?.src,_=Je.useRef(null),C=Je.useRef(null),O=Je.useCallback(V=>{_.current=V,typeof n=="function"?n(V):n&&(n.current=V)},[n]),[T,N]=Je.useState(!1),{margin:A,cells:D,numCells:L,calculatedImageSettings:I}=H5({value:s,level:c,minVersion:p,boostLevel:f,includeMargin:d,marginSize:g,imageSettings:v,size:l});Je.useEffect(()=>{if(_.current!=null){const V=_.current,Y=V.getContext("2d");if(!Y)return;let W=D;const K=C.current,X=I!=null&&K!==null&&K.complete&&K.naturalHeight!==0&&K.naturalWidth!==0;X&&I.excavation!=null&&(W=U5(D,I.excavation));const B=window.devicePixelRatio||1;V.height=V.width=l*B;const M=l/L*B;Y.scale(M,M),Y.fillStyle=o,Y.fillRect(0,0,L,L),Y.fillStyle=u,dte?Y.fill(new Path2D(P5(W,A))):D.forEach(function(U,$){U.forEach(function(H,J){H&&Y.fillRect(J+A,$+A,1,1)})}),I&&(Y.globalAlpha=I.opacity),X&&Y.drawImage(K,I.x+A,I.y+A,I.w,I.h)}}),Je.useEffect(()=>{N(!1)},[x]);const j=Dv({height:l,width:l},y);let F=null;return x!=null&&(F=Je.createElement("img",{src:x,key:x,style:{display:"none"},onLoad:()=>{N(!0)},ref:C,crossOrigin:I?.crossOrigin})),Je.createElement(Je.Fragment,null,Je.createElement("canvas",Dv({style:j,height:l,width:l,ref:O,role:"img"},S)),F)});hte.displayName="QRCodeCanvas";var $1=Je.forwardRef(function(t,n){const i=t,{value:s,size:l=I5,level:c=L5,bgColor:o=M5,fgColor:u=j5,includeMargin:d=B5,minVersion:p=F5,boostLevel:f,title:g,marginSize:v,imageSettings:w}=i,E=Iv(i,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:y,cells:S,numCells:x,calculatedImageSettings:_}=H5({value:s,level:c,minVersion:p,boostLevel:f,includeMargin:d,marginSize:v,imageSettings:w,size:l});let C=S,O=null;w!=null&&_!=null&&(_.excavation!=null&&(C=U5(S,_.excavation)),O=Je.createElement("image",{href:w.src,height:_.h,width:_.w,x:_.x+y,y:_.y+y,preserveAspectRatio:"none",opacity:_.opacity,crossOrigin:_.crossOrigin}));const T=P5(C,y);return Je.createElement("svg",Dv({height:l,width:l,viewBox:`0 0 ${x} ${x}`,ref:n,role:"img"},E),!!g&&Je.createElement("title",null,g),Je.createElement("path",{fill:o,d:`M0,0 h${x}v${x}H0z`,shapeRendering:"crispEdges"}),Je.createElement("path",{fill:u,d:T,shapeRendering:"crispEdges"}),O)});$1.displayName="QRCodeSVG";const qo=["wallet","defaults"],on=gn((e,t)=>({isOpen:!1,currentStep:"wallet",manageMode:!1,isLoading:!1,error:null,authStatus:null,setOpen:n=>e({isOpen:n}),setStep:n=>e({currentStep:n}),setManageMode:n=>e({manageMode:n}),setLoading:n=>e({isLoading:n}),setError:n=>e({error:n}),setAuthStatus:n=>e({authStatus:n}),nextStep:()=>{const{currentStep:n}=t(),i=qo.indexOf(n);i<qo.length-1&&e({currentStep:qo[i+1]})},prevStep:()=>{const{currentStep:n}=t(),i=qo.indexOf(n);i>0&&e({currentStep:qo[i-1]})},reset:()=>e({isOpen:!1,currentStep:"wallet",manageMode:!1,isLoading:!1,error:null})}));function G1(){const e=on(x=>x.setAuthStatus),t=on(x=>x.setOpen),n=on(x=>x.setLoading),i=on(x=>x.setError),s=on(x=>x.authStatus),l=on(x=>x.isOpen),[c,o]=z.useState(!1),u=z.useCallback(async()=>{n(!0),i(null);try{const x=await Te.getAuthStatus();return e(x),x}catch(x){const _=x instanceof Error?x.message:"Failed to load";return i(_),null}finally{n(!1)}},[e,n,i]),d=z.useCallback(async()=>{const x=await u();if(x){const _=Object.values(x.providers).some(O=>O.configured);(!x.onboardingComplete||!_||!x.setu.configured)&&t(!0)}o(!0)},[u,t]),p=z.useCallback(async()=>{n(!0),i(null);try{const x=await Te.setupSetuWallet();return await u(),x}catch(x){const _=x instanceof Error?x.message:"Setup failed";throw i(_),x}finally{n(!1)}},[u,n,i]),f=z.useCallback(async x=>{n(!0),i(null);try{const _=await Te.importSetuWallet(x);return await u(),_}catch(_){const C=_ instanceof Error?_.message:"Import failed";throw i(C),_}finally{n(!1)}},[u,n,i]),g=z.useCallback(async(x,_)=>{n(!0),i(null);try{const C=await Te.addProvider(x,_);return await u(),C}catch(C){const O=C instanceof Error?C.message:"Failed to add provider";throw i(O),C}finally{n(!1)}},[u,n,i]),v=z.useCallback(async x=>{n(!0),i(null);try{const _=await Te.removeProvider(x);return await u(),_}catch(_){const C=_ instanceof Error?_.message:"Failed to remove provider";throw i(C),_}finally{n(!1)}},[u,n,i]),w=z.useCallback(async()=>{n(!0),i(null);try{await Te.completeOnboarding(),await u(),t(!1)}catch(x){const _=x instanceof Error?x.message:"Failed to complete onboarding";throw i(_),x}finally{n(!1)}},[u,n,i,t]),E=z.useCallback((x,_)=>{const C=Te.getOAuthStartUrl(x,_),O=600,T=700,N=window.screenX+(window.outerWidth-O)/2,A=window.screenY+(window.outerHeight-T)/2;return window.open(C,"oauth_popup",`width=${O},height=${T},left=${N},top=${A},toolbar=no,menubar=no`)},[]),y=z.useCallback(async(x,_)=>{const T=window.screenX+(window.outerWidth-600)/2,N=window.screenY+(window.outerHeight-700)/2,A=window.open("about:blank","oauth_popup",`width=600,height=700,left=${T},top=${N},toolbar=no,menubar=no`),{url:D,sessionId:L}=await Te.getOAuthUrl(x,_);return A&&(A.location.href=D),{popup:A,sessionId:L}},[]),S=z.useCallback(async(x,_,C)=>{n(!0),i(null);try{return await Te.exchangeOAuthCode(x,_,C),await u(),!0}catch(O){const T=O instanceof Error?O.message:"Failed to exchange code";throw i(T),O}finally{n(!1)}},[u,n,i]);return z.useEffect(()=>{const x=_=>{_.data?.type==="oauth-success"&&u()};return window.addEventListener("message",x),()=>window.removeEventListener("message",x)},[u]),{authStatus:s,isOpen:l,initialized:c,fetchAuthStatus:u,checkOnboarding:d,setupWallet:p,importWallet:f,addProvider:g,removeProvider:v,completeOnboarding:w,startOAuth:E,startOAuthManual:y,exchangeOAuthCode:S}}const $u="pendingPolarCheckout";function pte(){const e=z.useRef(!1),t=z.useRef(null),n=kt(s=>s.setBalance),i=br(s=>s.removeToast);z.useEffect(()=>{if(e.current)return;const l=new URLSearchParams(window.location.search).get("topup"),c=localStorage.getItem($u);if(l==="pending"||c){e.current=!0;const o=new URL(window.location.href);if(o.searchParams.delete("topup"),window.history.replaceState({},"",o.toString()),!c){at.info("Checking payment status...");return}t.current=at.loading("Verifying payment...");let u=0;const d=10,p=2e3,f=()=>{t.current&&(i(t.current),t.current=null)},g=async()=>{u++;try{const v=await Te.getPolarTopupStatus(c);if(v?.confirmed){localStorage.removeItem($u),f();const w=await Te.getSetuBalance();w?.balance!==void 0&&n(w.balance),at.success(`Payment confirmed! +$${v.amountUsd?.toFixed(2)} credited`);return}u<d?setTimeout(g,p):(localStorage.removeItem($u),f(),at.info("Payment processing. Balance will update automatically."))}catch{u<d?setTimeout(g,p):(localStorage.removeItem($u),f(),at.error("Could not verify payment. Please check your balance."))}};setTimeout(g,1500)}},[n,i])}const Gu=z.memo(function({title:t,icon:n,children:i,action:s}){return m.jsxs("div",{className:"border-b border-border",children:[m.jsxs("div",{className:"px-4 py-3 flex items-center gap-2 bg-muted/30",children:[n,m.jsx("span",{className:"text-sm font-medium flex-1",children:t}),s]}),m.jsx("div",{className:"px-4 py-3 space-y-3",children:i})]})}),Wy=z.memo(function({label:t,value:n}){return m.jsxs("div",{className:"flex items-center justify-between text-sm",children:[m.jsx("span",{className:"text-muted-foreground",children:t}),m.jsx("span",{className:"font-mono text-foreground",children:n})]})}),QN=z.memo(function({label:t,checked:n,onChange:i}){return m.jsxs("div",{className:"flex items-center justify-between text-sm",children:[m.jsx("span",{className:"text-muted-foreground",children:t}),m.jsx("button",{type:"button",role:"switch","aria-checked":n,onClick:()=>i(!n),className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-2 ${n?"bg-primary":"bg-muted"}`,children:m.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full transition-transform ${n?"translate-x-6":"translate-x-1"} ${n?"bg-primary-foreground":"bg-foreground"}`})})]})}),Wu=z.memo(function({label:t,value:n,options:i,onChange:s,disabled:l}){const[c,o]=z.useState(!1),u=i.find(d=>d.id===n);return m.jsxs("div",{className:"flex items-center justify-between text-sm",children:[m.jsx("span",{className:"text-muted-foreground",children:t}),m.jsxs("div",{className:"relative",children:[m.jsxs("button",{type:"button",onClick:()=>!l&&o(!c),disabled:l,className:"flex items-center gap-1 px-2 py-1 text-xs font-mono bg-muted hover:bg-muted/80 rounded border border-border disabled:opacity-50",children:[m.jsx("span",{className:"max-w-[120px] truncate",children:u?.label||n||"Select..."}),m.jsx(mr,{className:"w-3 h-3"})]}),c&&m.jsxs(m.Fragment,{children:[m.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>o(!1),role:"presentation"}),m.jsx("div",{className:"absolute right-0 top-full mt-1 z-50 min-w-[160px] max-h-[200px] overflow-y-auto bg-popover border border-border rounded-md shadow-lg",children:i.map(d=>m.jsx("button",{type:"button",onClick:()=>{s(d.id),o(!1)},className:`w-full px-3 py-2 text-left text-xs font-mono hover:bg-muted truncate ${d.id===n?"bg-muted/50":""}`,children:d.label},d.id))})]})]})]})}),fte=z.memo(function(){const t=Nr(j=>j.isExpanded),n=Nr(j=>j.collapseSidebar),{data:i}=c1(),{data:s}=$c(),{preferences:l,updatePreferences:c}=dl(),o=KU(),u=kt(j=>j.balance),d=kt(j=>j.walletAddress),p=kt(j=>j.usdcBalance),f=kt(j=>j.isLoading),g=kt(j=>j.openTopupModal);pte();const v=i?.providers?.includes("setu"),{fetchBalance:w}=Vc(v?"setu":void 0),E=on(j=>j.setOpen),y=on(j=>j.setStep),S=on(j=>j.setManageMode),{fetchAuthStatus:x}=G1(),_=z.useMemo(()=>!i?.providers||!s?[]:i.providers.filter(j=>s[j]).map(j=>({id:j,label:s[j]?.label||j})),[i?.providers,s]),C=z.useMemo(()=>{const j=i?.defaults?.provider;return!j||!s?.[j]?[]:s[j].models.map(F=>({id:F.id,label:F.label}))},[i?.defaults?.provider,s]),O=z.useMemo(()=>i?.agents?i.agents.map(j=>({id:j,label:j})):[],[i?.agents]);if(!t)return null;const T=j=>{const F=s?.[j]?.models?.[0]?.id;o.mutate({provider:j,model:F||i?.defaults?.model})},N=j=>{o.mutate({model:j})},A=j=>{o.mutate({agent:j})},D=j=>j?`${j.slice(0,4)}...${j.slice(-4)}`:"Not configured",L=j=>j===null?"—":`$${j.toFixed(4)}`,I=j=>j===null?"—":`${j.toFixed(2)} USDC`;return m.jsxs("div",{className:"w-80 border-l border-border bg-background flex flex-col h-full",children:[m.jsxs("div",{className:"h-14 border-b border-border px-4 flex items-center justify-between shrink-0",children:[m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsx(QO,{className:"w-4 h-4"}),m.jsx("span",{className:"font-medium",children:"Settings"})]}),m.jsx(st,{variant:"ghost",size:"icon",onClick:n,children:m.jsx(an,{className:"w-4 h-4"})})]}),m.jsxs("div",{className:"flex-1 overflow-y-auto",children:[m.jsxs(Gu,{title:"Default Model",icon:m.jsx(wj,{className:"w-4 h-4 text-muted-foreground"}),children:[m.jsx(Wu,{label:"Provider",value:i?.defaults?.provider??"",options:_,onChange:T,disabled:o.isPending}),m.jsx(Wu,{label:"Model",value:i?.defaults?.model??"",options:C,onChange:N,disabled:o.isPending}),m.jsx(Wu,{label:"Agent",value:i?.defaults?.agent??"",options:O,onChange:A,disabled:o.isPending})]}),m.jsxs(Gu,{title:"Preferences",icon:m.jsx(Jv,{className:"w-4 h-4 text-muted-foreground"}),children:[m.jsx(QN,{label:"Vim Mode",checked:l.vimMode,onChange:j=>c({vimMode:j})}),m.jsx(QN,{label:"Show Reasoning",checked:l.reasoningEnabled,onChange:j=>c({reasoningEnabled:j})}),m.jsx(Wu,{label:"Tool Approval",value:i?.defaults?.toolApproval??"auto",options:[{id:"auto",label:"Auto (no approval)"},{id:"dangerous",label:"Dangerous only"},{id:"all",label:"All tools"}],onChange:j=>o.mutate({toolApproval:j}),disabled:o.isPending})]}),i?.providers?.includes("setu")&&m.jsxs(Gu,{title:"Setu Wallet",icon:m.jsx(e1,{className:"w-4 h-4 text-muted-foreground"}),action:m.jsx("button",{type:"button",onClick:w,disabled:f,className:"p-1 hover:bg-muted rounded transition-colors disabled:opacity-50",title:"Refresh balances",children:m.jsx(ni,{className:`w-3.5 h-3.5 text-muted-foreground ${f?"animate-spin":""}`})}),children:[d&&m.jsx("div",{className:"flex justify-center pb-3",children:m.jsx("div",{className:"p-2 bg-white rounded-lg",children:m.jsx($1,{value:d,size:120,level:"M",includeMargin:!1})})}),m.jsx(Wy,{label:"Address",value:D(d)}),m.jsx(Wy,{label:"Balance",value:L(u)}),m.jsx(Wy,{label:"USDC",value:I(p)}),m.jsxs(st,{variant:"secondary",size:"sm",onClick:g,className:"w-full mt-2 gap-2",children:[m.jsx(Ts,{className:"w-4 h-4"}),"Top Up Balance"]})]}),m.jsx(z1,{}),m.jsx(Gu,{title:"Providers",icon:m.jsx(HB,{className:"w-4 h-4 text-muted-foreground"}),action:m.jsx("button",{type:"button",onClick:()=>{x().then(()=>{y("wallet"),S(!0),E(!0)})},className:"p-1 hover:bg-muted rounded transition-colors",title:"Manage providers",children:m.jsx(nv,{className:"w-3.5 h-3.5 text-muted-foreground"})}),children:m.jsx("div",{className:"flex flex-wrap gap-2",children:i?.providers?.map(j=>m.jsx("span",{className:"px-2 py-1 text-xs bg-muted rounded-md font-mono",children:j},j))??m.jsx("span",{className:"text-muted-foreground text-sm",children:"None"})})})]})]})}),mte=z.memo(function(){const t=Nr(i=>i.isExpanded),n=Nr(i=>i.toggleSidebar);return m.jsx("button",{type:"button",onClick:n,className:`relative h-14 w-full transition-colors touch-manipulation flex items-center justify-center ${t?"bg-muted border-r-2 border-primary":"hover:bg-muted/50"}`,title:"Settings",children:m.jsx(QO,{className:"w-5 h-5 text-muted-foreground mx-auto"})})}),gte=z.memo(function({authStatus:t,onSetupWallet:n,onAddProvider:i,onRemoveProvider:s,onStartOAuth:l,onStartOAuthManual:c,onExchangeOAuthCode:o,onOpenTopup:u,onNext:d,manageMode:p=!1,onClose:f}){const[g,v]=z.useState(!1),[w,E]=z.useState(!1),[y,S]=z.useState(null),[x,_]=z.useState(""),[C,O]=z.useState(null),[T,N]=z.useState(null),[A,D]=z.useState(null),[L,I]=z.useState(""),[j,F]=z.useState(!1),[V,Y]=z.useState(!1),W=kt(se=>se.balance),K=kt(se=>se.usdcBalance),X=z.useRef(null),B=z.useRef(null);Vc("setu"),z.useEffect(()=>{!t.setu.configured&&!w&&(E(!0),n().finally(()=>E(!1)))},[t.setu.configured,n,w]),z.useEffect(()=>{y&&X.current&&X.current.focus()},[y]),z.useEffect(()=>{A&&B.current&&B.current.focus()},[A]);const M=async()=>{t.setu.publicKey&&(await navigator.clipboard.writeText(t.setu.publicKey),v(!0),setTimeout(()=>v(!1),2e3))},U=se=>`${se.slice(0,8)}...${se.slice(-6)}`,$=async se=>{if(x.trim())try{await i(se,x.trim()),S(null),_("")}catch{}},H=async se=>{if(T===se){O(se);try{await s(se)}finally{O(null),N(null)}}else N(se)},J=()=>{N(null)},oe=async(se,be)=>{se==="anthropic"?D({provider:se,sessionId:null,mode:be}):l(se,be)},de=async()=>{if(A){Y(!0);try{const{sessionId:se}=await c(A.provider,A.mode);D({...A,sessionId:se})}catch(se){console.error("Failed to start OAuth:",se)}Y(!1)}},Z=async()=>{if(!(!A||!A.sessionId||!L.trim())){F(!0);try{await o(A.provider,L.trim(),A.sessionId),D(null),I("")}catch{}F(!1)}},q=()=>{D(null),I("")},te=Object.entries(t.providers).filter(([se,be])=>be.configured&&se!=="setu"),he=Object.entries(t.providers).filter(([se,be])=>!be.configured&&se!=="setu");return m.jsxs("div",{className:"min-h-screen flex flex-col",children:[m.jsxs("div",{className:"flex items-center justify-between px-4 sm:px-6 py-4 border-b border-border",children:[m.jsxs("div",{className:"flex items-center gap-3",children:[m.jsx(fr,{provider:"setu",size:24}),m.jsx("span",{className:"font-semibold text-foreground",children:"AGI"})]}),!p&&m.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[m.jsx("span",{className:"w-2 h-2 rounded-full bg-green-500"}),"Step 1 of 2"]})]}),m.jsx("div",{className:"flex-1 px-4 pt-6 sm:px-6 sm:pt-8 lg:px-12 lg:pt-12 pb-32",children:m.jsxs("div",{className:"max-w-7xl mx-auto",children:[m.jsxs("div",{className:"mb-10",children:[m.jsx("h1",{className:"text-2xl sm:text-3xl lg:text-4xl font-semibold text-foreground mb-3",children:p?"Manage Providers":"Welcome to AGI"}),m.jsx("p",{className:"text-lg text-muted-foreground max-w-2xl",children:p?"Add or remove AI providers. Your changes are saved automatically.":"Setu is your default AI provider, powered by your wallet. Add more providers below if you'd like."})]}),m.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-6 xl:gap-8",children:[m.jsx("div",{className:"md:col-span-1",children:m.jsx("div",{className:"bg-card rounded-2xl border border-border p-5",children:t.setu.configured&&t.setu.publicKey?m.jsxs("div",{className:"flex flex-col h-full",children:[m.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 bg-green-500/10 border border-green-500/20 rounded-lg",children:[m.jsx(fr,{provider:"setu",size:16}),m.jsx("span",{className:"text-sm font-medium text-green-600 dark:text-green-400",children:"Setu"}),m.jsx("span",{className:"text-xs text-green-600/60 dark:text-green-500/60 ml-auto",children:"Default Provider"})]}),m.jsx("div",{className:"flex justify-center py-4 mt-4",children:m.jsx("div",{className:"bg-white p-2 rounded-lg",children:m.jsx($1,{value:t.setu.publicKey,size:140,level:"M"})})}),m.jsxs("div",{className:"space-y-2 mt-4",children:[m.jsxs("button",{type:"button",onClick:M,className:"w-full flex items-center justify-center gap-2 px-3 py-2 bg-muted hover:bg-muted/80 rounded-lg text-xs font-mono text-muted-foreground transition-colors",children:[U(t.setu.publicKey),g?m.jsx(ti,{className:"w-3.5 h-3.5 text-green-500"}):m.jsx(Ic,{className:"w-3.5 h-3.5 text-muted-foreground"})]}),m.jsxs("div",{className:"flex items-center justify-between px-3 py-2 bg-muted/50 rounded-lg",children:[m.jsx("span",{className:"text-xs text-muted-foreground",children:"Balance"}),m.jsxs("span",{className:"font-mono text-sm text-foreground",children:["$",((W??0)+(K??0)).toFixed(4)]})]})]}),m.jsxs("div",{className:"flex items-center gap-4 py-4",children:[m.jsx("div",{className:"flex-1 h-px bg-border"}),m.jsx("span",{className:"text-xs text-muted-foreground font-medium",children:"OR"}),m.jsx("div",{className:"flex-1 h-px bg-border"})]}),m.jsxs("button",{type:"button",onClick:u,className:"w-full flex items-center justify-center gap-2 px-4 py-2.5 bg-primary text-primary-foreground rounded-lg text-sm font-medium hover:bg-primary/90 transition-colors",children:[m.jsx(ks,{className:"w-4 h-4"}),"Pay via Card"]})]}):m.jsx("div",{className:"flex items-center justify-center py-16",children:m.jsx(rn,{className:"w-8 h-8 animate-spin text-muted-foreground"})})})}),m.jsxs("div",{className:"md:col-span-1 xl:col-span-2 space-y-6",children:[m.jsxs("div",{children:[m.jsxs("div",{className:"flex items-center justify-between mb-4",children:[m.jsx("h2",{className:"font-semibold text-foreground",children:"Connected Providers"}),te.length>0&&m.jsxs("span",{className:"text-sm text-muted-foreground",children:[te.length," active"]})]}),te.length===0?m.jsx("div",{className:"text-sm text-muted-foreground py-4",children:"No providers connected yet. Add one below."}):m.jsx("div",{className:"flex flex-wrap gap-2",children:te.map(([se,be])=>m.jsxs("div",{className:`flex items-center gap-2 pl-3 pr-2 py-2 rounded-full transition-all duration-200 ${T===se?"bg-destructive/10 border border-destructive/30":"group bg-green-500/10 border border-green-500/20"}`,children:[m.jsx(fr,{provider:se,size:16}),m.jsx("span",{className:`text-sm font-medium transition-colors ${T===se?"text-destructive":"text-green-600 dark:text-green-400"}`,children:be.label}),T!==se&&m.jsx("span",{className:"text-xs text-green-600/60 dark:text-green-500/60",children:be.type==="oauth"?"OAuth":"API"}),T===se?m.jsxs("div",{className:"flex items-center gap-1 ml-1",children:[m.jsx("span",{className:"text-xs text-destructive/80 mr-1",children:"Remove?"}),m.jsx("button",{type:"button",onClick:()=>H(se),disabled:C===se,className:"px-2 py-0.5 text-xs bg-destructive text-destructive-foreground rounded hover:bg-destructive/90 transition-colors disabled:opacity-50",children:C===se?m.jsx(rn,{className:"w-3 h-3 animate-spin"}):"Yes"}),m.jsx("button",{type:"button",onClick:J,className:"px-2 py-0.5 text-xs bg-muted text-muted-foreground rounded hover:bg-muted/80 transition-colors",children:"No"})]}):se!=="setu"&&m.jsx("button",{type:"button",onClick:()=>H(se),className:"ml-1 p-1 text-green-600/40 dark:text-green-500/40 hover:text-green-600/80 dark:hover:text-green-500/80 opacity-0 group-hover:opacity-100 transition-opacity",children:m.jsx(cn,{className:"w-3 h-3"})})]},se))})]}),m.jsxs("div",{children:[m.jsx("h2",{className:"font-semibold text-foreground mb-4",children:"Add Providers"}),m.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3 items-start",children:he.map(([se,be])=>m.jsx("div",{children:y===se?m.jsxs("div",{className:"flex items-center gap-2 p-3 bg-card border border-ring rounded-xl overflow-hidden",children:[m.jsx("div",{className:"shrink-0",children:m.jsx(fr,{provider:se,size:18})}),m.jsx("input",{ref:X,type:"password",value:x,onChange:Ee=>_(Ee.target.value),placeholder:`${be.label} API key...`,className:"flex-1 min-w-0 bg-transparent text-sm outline-none placeholder:text-muted-foreground text-foreground",onKeyDown:Ee=>{Ee.key==="Enter"&&$(se),Ee.key==="Escape"&&(S(null),_(""))}}),m.jsx("button",{type:"button",onClick:()=>$(se),disabled:!x.trim(),className:"shrink-0 px-3 py-1.5 bg-primary text-primary-foreground text-sm font-medium rounded-lg disabled:opacity-50",children:"Add"}),m.jsx("button",{type:"button",onClick:()=>{S(null),_("")},className:"shrink-0 p-1.5 text-muted-foreground hover:text-foreground",children:m.jsx(cn,{className:"w-4 h-4"})})]}):m.jsxs("div",{className:"flex items-center justify-between p-3 bg-card border border-border hover:border-border/80 rounded-xl transition-colors gap-2",children:[m.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[m.jsx(fr,{provider:se,size:20}),m.jsxs("div",{className:"min-w-0",children:[m.jsx("div",{className:"font-medium text-foreground truncate",children:be.label}),m.jsxs("div",{className:"text-xs text-muted-foreground",children:[be.modelCount," models"]})]})]}),m.jsxs("div",{className:"flex items-center gap-1",children:[m.jsxs("button",{type:"button",onClick:()=>S(se),className:"flex items-center gap-1.5 px-3 py-1.5 text-sm text-muted-foreground hover:text-foreground hover:bg-muted rounded-lg transition-colors",children:[m.jsx(aB,{className:"w-3.5 h-3.5"}),"API"]}),be.supportsOAuth&&m.jsxs("button",{type:"button",onClick:()=>oe(se,se==="anthropic"?"max":void 0),className:"flex items-center gap-1.5 px-3 py-1.5 text-sm text-muted-foreground hover:text-foreground hover:bg-muted rounded-lg transition-colors",children:[m.jsx(Gn,{className:"w-3.5 h-3.5"}),se==="anthropic"?"Max":"OAuth"]})]})]})},se))})]})]})]})]})}),m.jsx("div",{className:"fixed bottom-0 left-0 right-0 px-4 sm:px-6 py-4 border-t border-border bg-background",children:m.jsxs("div",{className:"max-w-7xl mx-auto flex items-center justify-between",children:[!p&&m.jsx("div",{className:"text-xs sm:text-sm text-muted-foreground hidden sm:block",children:"You can add more providers later in settings"}),p?m.jsx("button",{type:"button",onClick:f,className:"flex items-center gap-2 px-6 py-3 bg-primary text-primary-foreground rounded-lg font-medium hover:bg-primary/90 transition-colors ml-auto",children:"Done"}):m.jsxs("button",{type:"button",onClick:d,className:"flex items-center gap-2 px-6 py-3 bg-primary text-primary-foreground rounded-lg font-medium hover:bg-primary/90 transition-colors",children:["Continue",m.jsx(BO,{className:"w-4 h-4"})]})]})}),A&&m.jsx("div",{className:"fixed inset-0 z-[9999] flex items-center justify-center bg-black/60 backdrop-blur-sm",children:m.jsxs("div",{className:"bg-background border border-border rounded-xl w-full max-w-lg mx-6 shadow-2xl",children:[m.jsxs("div",{className:"flex items-center gap-3 p-6 border-b border-border",children:[m.jsx(fr,{provider:A.provider,size:24}),m.jsxs("h3",{className:"text-lg font-semibold",children:["Connect"," ",t.providers[A.provider]?.label||A.provider]})]}),A.sessionId?m.jsxs("div",{className:"p-6",children:[m.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Paste the authorization code:"}),m.jsx("input",{type:"text",ref:B,value:L,onChange:se=>I(se.target.value),placeholder:"Paste code here...",className:"w-full h-11 px-4 bg-muted/50 border border-border rounded-lg text-foreground placeholder:text-muted-foreground outline-none focus:border-foreground/30 transition-colors mb-4 font-mono text-sm",onKeyDown:se=>{se.key==="Enter"&&Z(),se.key==="Escape"&&q()}}),m.jsxs("div",{className:"flex gap-3",children:[m.jsx("button",{type:"button",onClick:q,className:"flex-1 h-11 px-4 bg-transparent border border-border text-foreground rounded-lg font-medium hover:bg-muted/50 transition-colors",children:"Cancel"}),m.jsx("button",{type:"button",onClick:Z,disabled:!L.trim()||j,className:"flex-1 h-11 px-4 bg-foreground text-background rounded-lg font-medium hover:bg-foreground/90 transition-colors disabled:opacity-50 flex items-center justify-center gap-2",children:j?m.jsx(rn,{className:"w-4 h-4 animate-spin"}):"Connect"})]})]}):m.jsxs("div",{className:"p-6",children:[m.jsxs("p",{className:"text-sm text-muted-foreground mb-6",children:["You'll be redirected to"," ",t.providers[A.provider]?.label||A.provider," ","to authorize access. After authorizing, copy the code and return here."]}),m.jsxs("div",{className:"flex gap-3",children:[m.jsx("button",{type:"button",onClick:q,className:"flex-1 h-11 px-4 bg-transparent border border-border text-foreground rounded-lg font-medium hover:bg-muted/50 transition-colors",children:"Cancel"}),m.jsx("button",{type:"button",onClick:de,disabled:V,className:"flex-1 h-11 px-4 bg-foreground text-background rounded-lg font-medium hover:bg-foreground/90 transition-colors disabled:opacity-50 flex items-center justify-center gap-2",children:V?m.jsx(rn,{className:"w-4 h-4 animate-spin"}):m.jsxs(m.Fragment,{children:["Continue",m.jsx(Gn,{className:"w-4 h-4"})]})})]})]})]})})]})}),bte=z.memo(function({authStatus:t,onComplete:n,onBack:i}){const[s,l]=z.useState(null),[c,o]=z.useState(null),[u,d]=z.useState(!0),[p,f]=z.useState(!1),[g,v]=z.useState("setu"),[w,E]=z.useState("kimi-k2.5"),[y,S]=z.useState(t.defaults.agent),[x,_]=z.useState(t.defaults.toolApproval||"auto"),C=z.useRef(!1),O=z.useId(),T=z.useId(),N=z.useId(),A=z.useId();z.useEffect(()=>{(async()=>{try{const[F,V]=await Promise.all([Te.getConfig(),Te.getAllModels()]);l(F),o(V)}catch{}finally{d(!1)}})()},[]),z.useEffect(()=>{if(c?.[g]&&C.current){const j=c[g];j.models.some(F=>F.id===w)||E(j.models[0]?.id||"")}},[g,c,w]);const D=async()=>{f(!0);try{await Te.updateDefaults({provider:g,model:w,agent:y,toolApproval:x,scope:"global"}),await n()}catch{}finally{f(!1)}};if(u)return m.jsx("div",{className:"min-h-screen flex items-center justify-center",children:m.jsx(rn,{className:"w-8 h-8 animate-spin text-muted-foreground"})});const L=s?.providers.filter(j=>(t.providers[j]?.configured||j==="setu")&&c?.[j]?.models?.length>0)||["setu"],I=c?.[g]?.models||[];return m.jsxs("div",{className:"min-h-screen flex flex-col",children:[m.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-border",children:[m.jsxs("div",{className:"flex items-center gap-3",children:[m.jsx(fr,{provider:"setu",size:24}),m.jsx("span",{className:"font-semibold text-foreground",children:"AGI"})]}),m.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[m.jsx("span",{className:"w-2 h-2 rounded-full bg-blue-500"}),"Step 2 of 2"]})]}),m.jsx("div",{className:"flex-1 px-4 pt-6 sm:px-6 sm:pt-8 lg:px-12 lg:pt-12 pb-32",children:m.jsxs("div",{className:"max-w-7xl mx-auto",children:[m.jsxs("div",{className:"mb-10",children:[m.jsx("h1",{className:"text-3xl lg:text-4xl font-semibold text-foreground mb-3",children:"Configure Defaults"}),m.jsx("p",{className:"text-lg text-muted-foreground",children:"Set your preferences. You can change these anytime in settings."})]}),m.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[m.jsxs("div",{className:"md:col-span-2",children:[m.jsx("label",{htmlFor:O,className:"block text-sm font-medium text-muted-foreground mb-2",children:"Default Provider"}),m.jsxs("div",{className:"relative",children:[m.jsx("select",{id:O,value:g,onChange:j=>{C.current=!0,v(j.target.value)},className:"w-full px-4 py-3 bg-card border border-border rounded-xl text-foreground appearance-none cursor-pointer focus:outline-none focus:border-ring transition-colors",children:L.map(j=>m.jsx("option",{value:j,children:t.providers[j]?.label||j},j))}),m.jsx(mr,{className:"absolute right-4 top-1/2 -translate-y-1/2 w-5 h-5 text-muted-foreground pointer-events-none"})]})]}),m.jsxs("div",{className:"md:col-span-2",children:[m.jsx("label",{htmlFor:T,className:"block text-sm font-medium text-muted-foreground mb-2",children:"Default Model"}),m.jsxs("div",{className:"relative",children:[m.jsx("select",{id:T,value:w,onChange:j=>E(j.target.value),className:"w-full px-4 py-3 bg-card border border-border rounded-xl text-foreground appearance-none cursor-pointer focus:outline-none focus:border-ring transition-colors",children:I.map(j=>m.jsx("option",{value:j.id,children:j.label||j.id},j.id))}),m.jsx(mr,{className:"absolute right-4 top-1/2 -translate-y-1/2 w-5 h-5 text-muted-foreground pointer-events-none"})]})]}),m.jsxs("div",{children:[m.jsx("label",{htmlFor:N,className:"block text-sm font-medium text-muted-foreground mb-2",children:"Default Agent"}),m.jsxs("div",{className:"relative",children:[m.jsx("select",{id:N,value:y,onChange:j=>S(j.target.value),className:"w-full px-4 py-3 bg-card border border-border rounded-xl text-foreground appearance-none cursor-pointer focus:outline-none focus:border-ring transition-colors",children:(s?.agents||["build"]).map(j=>m.jsx("option",{value:j,children:j},j))}),m.jsx(mr,{className:"absolute right-4 top-1/2 -translate-y-1/2 w-5 h-5 text-muted-foreground pointer-events-none"})]})]}),m.jsxs("div",{children:[m.jsx("label",{htmlFor:A,className:"block text-sm font-medium text-muted-foreground mb-2",children:"Tool Approval"}),m.jsxs("div",{className:"relative",children:[m.jsxs("select",{id:A,value:x,onChange:j=>_(j.target.value),className:"w-full px-4 py-3 bg-card border border-border rounded-xl text-foreground appearance-none cursor-pointer focus:outline-none focus:border-ring transition-colors",children:[m.jsx("option",{value:"auto",children:"Auto - run without asking"}),m.jsx("option",{value:"dangerous",children:"Dangerous - approve writes only"}),m.jsx("option",{value:"all",children:"All - approve every tool"})]}),m.jsx(mr,{className:"absolute right-4 top-1/2 -translate-y-1/2 w-5 h-5 text-muted-foreground pointer-events-none"})]}),m.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"Controls when tool executions need approval"})]})]})]})}),m.jsx("div",{className:"fixed bottom-0 left-0 right-0 px-4 sm:px-6 py-4 border-t border-border bg-background",children:m.jsxs("div",{className:"max-w-7xl mx-auto flex items-center justify-between",children:[m.jsxs("button",{type:"button",onClick:i,className:"flex items-center gap-2 px-4 py-3 text-muted-foreground hover:text-foreground transition-colors",children:[m.jsx(Yv,{className:"w-4 h-4"}),"Back"]}),m.jsx("button",{type:"button",onClick:D,disabled:p,className:"flex items-center gap-2 px-6 py-3 bg-primary text-primary-foreground rounded-lg font-medium hover:bg-primary/90 transition-colors disabled:opacity-50",children:p?m.jsxs(m.Fragment,{children:[m.jsx(rn,{className:"w-4 h-4 animate-spin"}),"Setting up..."]}):m.jsxs(m.Fragment,{children:["Start Using AGI",m.jsx(As,{className:"w-4 h-4"})]})})]})})]})}),yte=z.memo(function(){const t=on(y=>y.isOpen),n=on(y=>y.currentStep),i=on(y=>y.manageMode),s=on(y=>y.authStatus),l=on(y=>y.nextStep),c=on(y=>y.prevStep),o=on(y=>y.reset),u=kt(y=>y.openTopupModal),{setupWallet:d,addProvider:p,removeProvider:f,completeOnboarding:g,startOAuth:v,startOAuthManual:w,exchangeOAuthCode:E}=G1();return!t||!s?null:m.jsxs("div",{className:"fixed inset-0 z-[9999] bg-background text-foreground overflow-y-auto",children:[n==="wallet"&&m.jsx(gte,{authStatus:s,onSetupWallet:d,onAddProvider:p,onRemoveProvider:f,onStartOAuth:v,onStartOAuthManual:w,onExchangeOAuthCode:E,onOpenTopup:u,onNext:l,manageMode:i,onClose:o}),n==="defaults"&&m.jsx(bte,{authStatus:s,onComplete:g,onBack:c})]})}),z5="agi-theme",JN="dark";function vte(){if(typeof window>"u")return JN;const e=window.localStorage.getItem(z5);return e==="light"||e==="dark"?e:JN}function xte(){const[e,t]=z.useState(()=>vte());z.useEffect(()=>{if(typeof document>"u")return;const i=document.documentElement;e==="dark"?i.classList.add("dark"):i.classList.remove("dark");try{window.localStorage.setItem(z5,e)}catch(s){console.warn("Failed to persist theme preference",s)}},[e]);const n=z.useCallback(()=>{t(i=>i==="dark"?"light":"dark")},[]);return z.useMemo(()=>({theme:e,setTheme:t,toggleTheme:n}),[e,n])}function _te(){const[e,t]=z.useState(null);return z.useEffect(()=>{(async()=>{try{const l=`${window.AGI_SERVER_URL||Hc}/v1/config/cwd`;console.log("[useWorkingDirectory] Fetching from:",l);const c=await fetch(l);if(!c.ok)throw console.error("[useWorkingDirectory] Failed:",c.status,c.statusText),new Error(`Failed to fetch working directory: ${c.status}`);const o=await c.json();console.log("[useWorkingDirectory] Success:",o),o.dirName&&(console.log("[useWorkingDirectory] Setting title to:",o.dirName),t(o.dirName),document.title=o.dirName)}catch(i){console.error("[useWorkingDirectory] Error:",i),document.title="AGI"}})()},[]),e}function Ste({sessionIds:e,activeSessionId:t,gitFiles:n,onSelectSession:i,onNewSession:s,onStageFile:l,onUnstageFile:c,onRestoreFile:o,onDeleteFile:u,onStageAll:d,onUnstageAll:p,onOpenCommitModal:f,onViewDiff:g,onReturnToInput:v}){const{currentFocus:w,sessionIndex:E,gitFileIndex:y,setFocus:S,setSessionIndex:x,setGitFileIndex:_,resetGitFileIndex:C}=q1(),{setCollapsed:O,toggleCollapse:T}=Ca(),{isExpanded:N,toggleSidebar:A}=Tt(),D=Tt(F=>F.closeDiff),L=zn(F=>F.toggleSidebar),I=e.indexOf(t||""),j=z.useCallback(F=>{const V=F.target,Y=V.tagName==="INPUT"||V.tagName==="TEXTAREA"||V.isContentEditable;if((F.ctrlKey||F.metaKey)&&F.key==="h"){F.preventDefault(),w==="sessions"?(document.activeElement?.blur(),S("input"),O(!0),setTimeout(()=>v?.(),50)):w==="git"?(document.activeElement?.blur(),S("input"),A(),D(),setTimeout(()=>v?.(),50)):(document.activeElement?.blur(),S("sessions"),O(!1),I>=0&&x(I));return}if((F.ctrlKey||F.metaKey)&&F.key==="l"){F.preventDefault(),w==="git"?(document.activeElement?.blur(),S("input"),A(),D(),setTimeout(()=>v?.(),50)):w==="sessions"?(document.activeElement?.blur(),S("input"),O(!0),setTimeout(()=>v?.(),50)):(document.activeElement?.blur(),N||A(),S("git"),C());return}if((F.ctrlKey||F.metaKey)&&F.key==="/"){F.preventDefault(),T();return}if((F.ctrlKey||F.metaKey)&&F.key==="\\"){F.preventDefault(),A();return}if((F.ctrlKey||F.metaKey)&&F.shiftKey&&F.key==="r"){F.preventDefault(),L();return}if((F.ctrlKey||F.metaKey)&&F.key==="n"){F.preventDefault(),s();return}if(F.key==="Escape"||F.key==="q"&&!Y&&(w==="sessions"||w==="git")){F.preventDefault(),w==="sessions"?O(!0):w==="git"&&(A(),D()),S("input"),v?.();return}if(w==="sessions"&&!Y){if(F.key==="j"&&e.length>0){F.preventDefault();const W=Math.min(E+1,e.length-1);x(W);return}if(F.key==="k"&&e.length>0){F.preventDefault();const W=Math.max(E-1,0);x(W);return}if(F.key==="Enter"&&e[E]){F.preventDefault(),i(e[E]),S("input");return}}if(w==="git"&&!Y){if(F.key==="j"&&n.length>0){F.preventDefault();const W=Math.min(y+1,n.length-1);_(W);return}if(F.key==="k"&&n.length>0){F.preventDefault();const W=Math.max(y-1,0);_(W);return}if(F.key===" "&&n[y]){F.preventDefault();const W=n[y];W.staged?c?.(W.path):l?.(W.path);return}if(F.key==="a"){F.preventDefault(),d?.();return}if(F.key==="u"){F.preventDefault(),p?.();return}if(F.key==="R"&&n[y]){F.preventDefault();const W=n[y];!W.staged&&W.status!=="untracked"&&W.status!=="added"&&o?.(W.path);return}if(F.shiftKey&&F.key==="D"||F.key==="Backspace"){F.preventDefault();const W=n[y];W&&!W.staged&&W.status==="untracked"&&u?.(W.path);return}if(F.key==="c"){F.preventDefault(),f?.();return}if(F.key==="Enter"&&n[y]){F.preventDefault();const W=n[y];g?.(W.path,W.staged);return}}},[w,E,y,e,n,I,N,S,x,_,C,O,A,L,T,i,s,l,c,o,u,d,p,f,g,v,D]);return z.useEffect(()=>(window.addEventListener("keydown",j),()=>window.removeEventListener("keydown",j)),[j]),{currentFocus:w,sessionIndex:E,gitFileIndex:y}}function Ete(e){const t=z.useRef(null),n=z.useRef(null),i=kt(d=>d.setBalance),s=kt(d=>d.setPaymentPending),l=br(d=>d.removeToast),c=br(d=>d.updateToast),o=kc(d=>d.setPendingTopup),u=kc(d=>d.clearPendingTopup);z.useEffect(()=>{if(!e)return;const d=new T5;t.current=d;const p=Te.getStreamUrl(e);d.connect(p);const f=d.on("*",g=>{const v=g.payload;switch(g.type){case"setu.topup.required":{const w=typeof v?.amountUsd=="number"?v.amountUsd:0,E=typeof v?.currentBalance=="number"?v.currentBalance:0,y=typeof v?.minTopupUsd=="number"?v.minTopupUsd:5,S=typeof v?.suggestedTopupUsd=="number"?v.suggestedTopupUsd:10,x=typeof v?.messageId=="string"?v.messageId:"";o({sessionId:e,messageId:x,amountUsd:w,currentBalance:E,minTopupUsd:y,suggestedTopupUsd:S});break}case"setu.topup.method_selected":{v?.method==="crypto"&&(s(!0),n.current=at.loading("💳 Processing crypto payment..."));break}case"setu.topup.cancelled":{u();const w=typeof v?.reason=="string"?v.reason:"Request cancelled";at(`⚠️ ${w}`);break}case"setu.payment.required":{const w=typeof v?.amountUsd=="number"?v.amountUsd:0;s(!0),n.current||(n.current=at.loading(`💳 Payment required: $${w.toFixed(2)}`));break}case"setu.payment.signing":{n.current?c(n.current,{message:"✍️ Signing transaction..."}):n.current=at.loading("✍️ Signing transaction...");break}case"setu.payment.complete":{u();const w=v?.amountUsd,E=v?.newBalance,y=typeof v?.transactionId=="string"?v.transactionId:void 0,S=typeof w=="number"?w:typeof w=="string"?parseFloat(w):0,x=typeof E=="number"?E:typeof E=="string"?parseFloat(E):0;i(x),s(!1),n.current&&(l(n.current),n.current=null);const _=`✅ Paid $${S.toFixed(2)}`;y?at.successWithAction(_,{label:"View Tx",href:`https://orbmarkets.io/tx/${y}`}):at.success(_);break}case"setu.fiat.checkout_created":{u(),s(!1),n.current&&(l(n.current),n.current=null),at.success("💳 Complete payment, then retry your message");break}case"setu.payment.error":{u();const w=typeof v?.error=="string"?v.error:"Payment failed";s(!1),n.current&&(l(n.current),n.current=null),at.error(`❌ ${w}`);break}}});return()=>{f(),d.disconnect()}},[e,i,s,l,c,o,u])}const id=k6({component:wte});function wte(){const{checkOnboarding:e}=G1();return z.useEffect(()=>{e()},[e]),m.jsxs(m.Fragment,{children:[m.jsx(MO,{}),m.jsx(yte,{}),m.jsx(z1,{}),null]})}const Cte=Jo("/")({beforeLoad:()=>{throw xO({to:"/sessions"})},component:()=>null});const kte=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Tte=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,i)=>i?i.toUpperCase():n.toLowerCase()),eO=e=>{const t=Tte(e);return t.charAt(0).toUpperCase()+t.slice(1)},q5=(...e)=>e.filter((t,n,i)=>!!t&&t.trim()!==""&&i.indexOf(t)===n).join(" ").trim(),Ate=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0};var Rte={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const Nte=z.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:i,className:s="",children:l,iconNode:c,...o},u)=>z.createElement("svg",{ref:u,...Rte,width:t,height:t,stroke:e,strokeWidth:i?Number(n)*24/Number(t):n,className:q5("lucide",s),...!l&&!Ate(o)&&{"aria-hidden":"true"},...o},[...c.map(([d,p])=>z.createElement(d,p)),...Array.isArray(l)?l:[l]]));const bl=(e,t)=>{const n=z.forwardRef(({className:i,...s},l)=>z.createElement(Nte,{ref:l,iconNode:t,className:q5(`lucide-${kte(eO(e))}`,`lucide-${e}`,i),...s}));return n.displayName=eO(e),n};const Ote=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Dte=bl("chevron-right",Ote);const Ite=[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]],Lte=bl("moon",Ite);const Mte=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],tO=bl("plus",Mte);const jte=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]],Bte=bl("sun",jte);const Fte=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Pte=bl("x",Fte),Ute=z.memo(function({children:t,onNewSession:n}){const i=Tt(c=>c.isDiffOpen),s=Ca(c=>c.isCollapsed),l=Ca(c=>c.toggleCollapse);return z.useEffect(()=>(s?document.body.style.overflow="":document.body.style.overflow="hidden",()=>{document.body.style.overflow=""}),[s]),s?m.jsxs("aside",{className:"w-12 md:w-12 border-r border-border bg-background flex flex-col transition-all duration-300 ease-in-out hidden md:flex",children:[m.jsx("div",{className:"h-14 border-b border-border flex items-center justify-center",children:m.jsx(st,{variant:"ghost",size:"icon",onClick:n,title:"New session",className:"rounded-full touch-manipulation",children:m.jsx(tO,{className:"w-4 h-4"})})}),m.jsx("button",{type:"button",className:"flex-1 cursor-pointer hover:bg-muted/50 transition-colors touch-manipulation",onClick:i?void 0:l,title:i?void 0:"Expand sidebar","aria-label":"Expand sidebar"}),m.jsx("div",{className:"h-12 border-t border-border flex items-center justify-center",children:m.jsx(st,{variant:"ghost",size:"icon",onClick:l,title:"Expand sidebar",disabled:i,className:"transition-transform duration-200 hover:scale-110 touch-manipulation",children:m.jsx(Dte,{className:"w-4 h-4"})})})]}):m.jsxs(m.Fragment,{children:[!s&&m.jsx("div",{className:"fixed inset-0 bg-black/50 z-40 md:hidden",onClick:l,"aria-hidden":"true"}),m.jsxs("aside",{className:"w-full md:w-64 border-r border-border bg-background flex flex-col transition-all duration-300 ease-in-out fixed md:relative top-0 left-0 z-50 h-screen md:h-auto",children:[m.jsxs("div",{className:"h-14 border-b border-border px-4 flex items-center gap-2 md:hidden bg-background",children:[m.jsx(st,{variant:"ghost",size:"icon",onClick:l,title:"Close menu",className:"touch-manipulation flex-shrink-0","aria-label":"Close menu",children:m.jsx(Pte,{className:"w-5 h-5"})}),m.jsx("h1",{className:"text-lg font-semibold text-foreground flex-1",children:"AGI"})]}),m.jsx("div",{className:"h-14 border-b border-border px-4 flex items-center gap-2",children:m.jsxs(st,{variant:"primary",size:"sm",onClick:n,className:"flex-1 touch-manipulation",children:[m.jsx(tO,{className:"w-4 h-4 mr-2"}),"New Session"]})}),m.jsx("div",{className:"flex-1 overflow-y-auto scrollbar-hide",children:t}),m.jsx("div",{className:"h-12 border-t border-border px-2 flex items-center justify-end",children:m.jsx(st,{variant:"ghost",size:"icon",onClick:l,title:"Collapse sidebar",disabled:i,className:"transition-transform duration-200 hover:scale-110 touch-manipulation",children:m.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"transition-transform duration-300",role:"img","aria-label":"Collapse sidebar",children:[m.jsx("title",{children:"Collapse sidebar"}),m.jsx("path",{d:"M15 18l-6-6 6-6"})]})})})]})]})}),Hte=z.memo(function({sidebar:t,children:n,onNewSession:i,theme:s,onToggleTheme:l,sessionId:c,onNavigateToSession:o}){return m.jsxs("div",{className:"h-screen flex bg-background touch-manipulation border-t border-border/50",children:[m.jsx(Ute,{onNewSession:i,children:t}),m.jsxs("main",{className:"flex-1 flex flex-col overflow-hidden relative w-full md:w-auto",children:[m.jsx(jee,{}),m.jsx(Yee,{}),n]}),m.jsxs("div",{className:"hidden md:flex",children:[m.jsx(Oee,{}),m.jsx(zee,{sessionId:c}),m.jsx(mP,{}),m.jsx(tte,{parentSessionId:c??null,onNavigateToSession:o}),m.jsx(fte,{}),m.jsxs("div",{className:"flex flex-col w-12 border-l border-border bg-background",children:[m.jsx(Dee,{}),m.jsx(qee,{sessionId:c}),m.jsx(gP,{}),m.jsx(rte,{parentSessionId:c}),m.jsx("div",{className:"flex-1"}),m.jsx(mte,{}),m.jsx("div",{className:"h-12 border-t border-border flex items-center justify-center",children:m.jsx(st,{variant:"ghost",size:"icon",onClick:l,title:`Switch to ${s==="dark"?"light":"dark"} mode`,"aria-label":`Switch to ${s==="dark"?"light":"dark"} mode`,className:"touch-manipulation",children:s==="dark"?m.jsx(Bte,{className:"w-4 h-4"}):m.jsx(Lte,{className:"w-4 h-4"})})})]})]}),m.jsx(Bee,{}),m.jsx(vP,{})]})});function $5({sessionId:e}){const t=z.useRef(null),n=WU(),{data:i}=c1(),{theme:s,toggleTheme:l}=xte(),{openCommitModal:c,openDiff:o}=Tt(),u=Dc(),{data:d=[]}=qc(),{data:p}=Gc(),f=Wc(),g=d1(),v=qD(),w=$D(),E=s1(N=>N.openConfirmation);_te(),Ete(e),Vc(i?.defaults?.provider);const y=z.useCallback(()=>{setTimeout(()=>{t.current?.focus()},100)},[]),S=z.useCallback(async()=>{try{const N=await n.mutateAsync({agent:i?.defaults.agent||"general",provider:i?.defaults.provider,model:i?.defaults.model});u({to:"/sessions/$sessionId",params:{sessionId:N.id},replace:!1}),y()}catch(N){console.error("Failed to create session:",N)}},[n,i,u,y]),x=z.useCallback(()=>{u({to:"/sessions"})},[u]),_=z.useCallback(N=>{u({to:"/sessions/$sessionId",params:{sessionId:N}}),y()},[u,y]),C=z.useMemo(()=>p?[...(p.conflicted??[]).map(N=>({path:N.path,staged:!1,status:N.status})),...p.staged.map(N=>({path:N.path,staged:!0,status:N.status})),...p.unstaged.map(N=>({path:N.path,staged:!1,status:N.status})),...p.untracked.map(N=>({path:N.path,staged:!1,status:N.status}))]:[],[p]),O=z.useMemo(()=>d.map(N=>N.id),[d]);Ste({sessionIds:O,activeSessionId:e,gitFiles:C,onSelectSession:_,onNewSession:S,onStageFile:N=>f.mutate([N]),onUnstageFile:N=>g.mutate([N]),onRestoreFile:N=>v.mutate([N]),onDeleteFile:N=>{E({title:"Delete File",message:`Delete ${N}? This will permanently remove the untracked file.`,confirmLabel:"Delete",variant:"destructive",onConfirm:async()=>{await w.mutateAsync([N])}})},onStageAll:()=>{const N=C.filter(A=>!A.staged).map(A=>A.path);N.length>0&&f.mutate(N)},onUnstageAll:()=>{const N=C.filter(A=>A.staged).map(A=>A.path);N.length>0&&g.mutate(N)},onOpenCommitModal:c,onViewDiff:o,onReturnToInput:y}),z.useEffect(()=>{e&&y()},[e,y]);const T=z.useMemo(()=>e?m.jsxs(m.Fragment,{children:[m.jsx(See,{sessionId:e,onSelectSession:_}),m.jsx(c7,{ref:t,sessionId:e,onNewSession:S,onDeleteSession:x})]}):m.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:"Select a session or create a new one to start"}),[e,S,_,x]);return m.jsxs(m.Fragment,{children:[m.jsx(Hte,{onNewSession:S,theme:s,onToggleTheme:l,sessionId:e,onNavigateToSession:_,sidebar:m.jsx(wee,{activeSessionId:e,onSelectSession:_}),children:T}),m.jsx(EP,{})]})}const zte=Jo("/sessions/")({component:qte});function qte(){return m.jsx($5,{})}const G5=Jo("/sessions/$sessionId")({component:$te});function $te(){const{sessionId:e}=G5.useParams();return m.jsx($5,{sessionId:e})}const Gte=Cte.update({id:"/",path:"/",getParentRoute:()=>id}),Wte=zte.update({id:"/sessions/",path:"/sessions/",getParentRoute:()=>id}),Vte=G5.update({id:"/sessions/$sessionId",path:"/sessions/$sessionId",getParentRoute:()=>id}),Kte={IndexRoute:Gte,SessionsSessionIdRoute:Vte,SessionsIndexRoute:Wte},Yte=id._addFileChildren(Kte)._addFileTypes(),Xte=()=>{const n=(typeof globalThis<"u"?globalThis.AGI_ROUTER_BASEPATH:void 0)??"/"??"/";if(!n||n==="/")return"/";const i=n.replace(/\/+$/,"")||"/";return i.startsWith("/")?i:`/${i}`},Zte=L6({routeTree:Yte,basepath:Xte()}),Qte=new B4({defaultOptions:{queries:{refetchOnWindowFocus:!1,retry:1,structuralSharing:!0}}});function Jte(){return m.jsx(F4,{client:Qte,children:m.jsx(B6,{router:Zte})})}const W5=document.getElementById("root");if(!W5)throw new Error("Root element not found");p4.createRoot(W5).render(m.jsx(z.StrictMode,{children:m.jsx(Jte,{})}));
|
|
@@ -8,8 +8,15 @@
|
|
|
8
8
|
<meta name="apple-mobile-web-app-capable" content="yes" />
|
|
9
9
|
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
|
|
10
10
|
<title>Loading...</title>
|
|
11
|
-
<
|
|
12
|
-
|
|
11
|
+
<style>
|
|
12
|
+
html, body, #root {
|
|
13
|
+
background-color: hsl(240, 10%, 8%);
|
|
14
|
+
margin: 0;
|
|
15
|
+
padding: 0;
|
|
16
|
+
}
|
|
17
|
+
</style>
|
|
18
|
+
<script type="module" crossorigin src="/assets/index-D4GGcLJQ.js"></script>
|
|
19
|
+
<link rel="stylesheet" crossorigin href="/assets/index-CRGJCOt4.css">
|
|
13
20
|
</head>
|
|
14
21
|
<body>
|
|
15
22
|
<div id="root"></div>
|