{"version":3,"file":"first-time-setup.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/components/first-time-setup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAgC,MAAM,wBAAwB,CAAC;AAEjF,OAAO,EAAE,KAAK,aAAa,EAAS,MAAM,mBAAmB,CAAC;AAI9D,MAAM,WAAW,oBAAoB;IACpC,KAAK,EAAE,aAAa,CAAC;IACrB,cAAc,EAAE,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,qBAAqB;IACrC,aAAa,EAAE,aAAa,CAAC;IAC7B,cAAc,EAAE,CAAC,SAAS,EAAE,aAAa,KAAK,IAAI,CAAC;IACnD,QAAQ,EAAE,CAAC,MAAM,EAAE,oBAAoB,KAAK,IAAI,CAAC;IACjD,QAAQ,EAAE,MAAM,IAAI,CAAC;CACrB;AAcD,kEAAkE;AAClE,qBAAa,uBAAwB,SAAQ,SAAS;IACrD,OAAO,CAAC,IAAI,CAAkC;IAC9C,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,cAAc,CAAK;IAC3B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAwB;IAEhD,YAAY,OAAO,EAAE,qBAAqB,EAQzC;IAGD,OAAO,CAAC,MAAM;IAsDd,OAAO,CAAC,aAAa;IASrB,OAAO,CAAC,aAAa;IAarB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAmBjC;CACD","sourcesContent":["import { Container, getKeybindings, Spacer, Text } from \"@earendil-works/pi-tui\";\nimport { APP_NAME } from \"../../../config.ts\";\nimport { type TerminalTheme, theme } from \"../theme/theme.ts\";\nimport { DynamicBorder } from \"./dynamic-border.ts\";\nimport { keyHint, rawKeyHint } from \"./keybinding-hints.ts\";\n\nexport interface FirstTimeSetupResult {\n\ttheme: TerminalTheme;\n\tshareAnalytics: boolean;\n}\n\nexport interface FirstTimeSetupOptions {\n\tdetectedTheme: TerminalTheme;\n\tonThemePreview: (themeName: TerminalTheme) => void;\n\tonSubmit: (result: FirstTimeSetupResult) => void;\n\tonCancel: () => void;\n}\n\nconst THEME_OPTIONS: Array<{ value: TerminalTheme; label: string }> = [\n\t{ value: \"dark\", label: \"Dark\" },\n\t{ value: \"light\", label: \"Light\" },\n];\n\nconst ANALYTICS_OPTIONS: Array<{ value: boolean; label: string }> = [\n\t{ value: true, label: \"Share anonymous usage data\" },\n\t{ value: false, label: \"Don't share\" },\n];\n\nconst SETUP_LOGO_LINES = [\"██████\", \"██  ██\", \"████  ██\", \"██    ██\"];\n\n/** First-time setup dialog: theme choice and analytics opt-in. */\nexport class FirstTimeSetupComponent extends Container {\n\tprivate step: \"theme\" | \"analytics\" = \"theme\";\n\tprivate themeIndex: number;\n\tprivate analyticsIndex = 0;\n\tprivate readonly options: FirstTimeSetupOptions;\n\n\tconstructor(options: FirstTimeSetupOptions) {\n\t\tsuper();\n\t\tthis.options = options;\n\t\tthis.themeIndex = Math.max(\n\t\t\t0,\n\t\t\tTHEME_OPTIONS.findIndex((option) => option.value === options.detectedTheme),\n\t\t);\n\t\tthis.update();\n\t}\n\n\t// Rebuild the whole dialog on every change so theme previews recolor all text.\n\tprivate update(): void {\n\t\tthis.clear();\n\t\tthis.addChild(new DynamicBorder());\n\t\tthis.addChild(new Spacer(1));\n\t\tthis.addChild(new Text(theme.fg(\"accent\", SETUP_LOGO_LINES.join(\"\\n\")), 1, 0));\n\t\tthis.addChild(new Spacer(1));\n\t\tthis.addChild(\n\t\t\tnew Text(theme.fg(\"accent\", theme.bold(`Welcome to ${APP_NAME}, the minimal coding agent.`)), 1, 0),\n\t\t);\n\t\tthis.addChild(new Spacer(1));\n\n\t\tif (this.step === \"theme\") {\n\t\t\tthis.addChild(new Text(theme.fg(\"text\", \"Pick a theme.\"), 1, 0));\n\t\t\tthis.addChild(new Text(theme.fg(\"muted\", `Detected system appearance: ${this.options.detectedTheme}`), 1, 0));\n\t\t\tthis.addChild(new Spacer(1));\n\t\t\tthis.addOptionList(\n\t\t\t\tTHEME_OPTIONS.map((option) => option.label),\n\t\t\t\tthis.themeIndex,\n\t\t\t);\n\t\t} else {\n\t\t\tthis.addChild(new Text(theme.fg(\"text\", \"Opt-in to anonymous usage data sharing?\"), 1, 0));\n\t\t\tthis.addChild(\n\t\t\t\tnew Text(\n\t\t\t\t\ttheme.fg(\n\t\t\t\t\t\t\"muted\",\n\t\t\t\t\t\t\"Opting in stores a tracking identifier in settings.json and enables anonymous\\nusage analytics. This helps us to better debug, reproduce, and resolve issues\\nand bugs within Pi. You can observe what is shared using /privacy and make\\nchanges anytime in settings.json.\",\n\t\t\t\t\t),\n\t\t\t\t\t1,\n\t\t\t\t\t0,\n\t\t\t\t),\n\t\t\t);\n\t\t\tthis.addChild(new Spacer(1));\n\t\t\tthis.addOptionList(\n\t\t\t\tANALYTICS_OPTIONS.map((option) => option.label),\n\t\t\t\tthis.analyticsIndex,\n\t\t\t);\n\t\t}\n\n\t\tthis.addChild(new Spacer(1));\n\t\tthis.addChild(\n\t\t\tnew Text(\n\t\t\t\trawKeyHint(\"↑↓\", \"navigate\") +\n\t\t\t\t\t\"  \" +\n\t\t\t\t\tkeyHint(\"tui.select.confirm\", this.step === \"theme\" ? \"continue\" : \"finish\") +\n\t\t\t\t\t\"  \" +\n\t\t\t\t\tkeyHint(\"tui.select.cancel\", \"skip setup\"),\n\t\t\t\t1,\n\t\t\t\t0,\n\t\t\t),\n\t\t);\n\t\tthis.addChild(new Spacer(1));\n\t\tthis.addChild(new DynamicBorder());\n\t}\n\n\tprivate addOptionList(labels: string[], selectedIndex: number): void {\n\t\tfor (let i = 0; i < labels.length; i++) {\n\t\t\tconst isSelected = i === selectedIndex;\n\t\t\tconst prefix = isSelected ? theme.fg(\"accent\", \"→ \") : \"  \";\n\t\t\tconst label = isSelected ? theme.fg(\"accent\", labels[i]) : theme.fg(\"text\", labels[i]);\n\t\t\tthis.addChild(new Text(`${prefix}${label}`, 1, 0));\n\t\t}\n\t}\n\n\tprivate moveSelection(delta: number): void {\n\t\tif (this.step === \"theme\") {\n\t\t\tconst next = Math.max(0, Math.min(THEME_OPTIONS.length - 1, this.themeIndex + delta));\n\t\t\tif (next !== this.themeIndex) {\n\t\t\t\tthis.themeIndex = next;\n\t\t\t\tthis.options.onThemePreview(THEME_OPTIONS[this.themeIndex].value);\n\t\t\t}\n\t\t} else {\n\t\t\tthis.analyticsIndex = Math.max(0, Math.min(ANALYTICS_OPTIONS.length - 1, this.analyticsIndex + delta));\n\t\t}\n\t\tthis.update();\n\t}\n\n\thandleInput(keyData: string): void {\n\t\tconst kb = getKeybindings();\n\t\tif (kb.matches(keyData, \"tui.select.up\") || keyData === \"k\") {\n\t\t\tthis.moveSelection(-1);\n\t\t} else if (kb.matches(keyData, \"tui.select.down\") || keyData === \"j\") {\n\t\t\tthis.moveSelection(1);\n\t\t} else if (kb.matches(keyData, \"tui.select.confirm\") || keyData === \"\\n\") {\n\t\t\tif (this.step === \"theme\") {\n\t\t\t\tthis.step = \"analytics\";\n\t\t\t\tthis.update();\n\t\t\t} else {\n\t\t\t\tthis.options.onSubmit({\n\t\t\t\t\ttheme: THEME_OPTIONS[this.themeIndex].value,\n\t\t\t\t\tshareAnalytics: ANALYTICS_OPTIONS[this.analyticsIndex].value,\n\t\t\t\t});\n\t\t\t}\n\t\t} else if (kb.matches(keyData, \"tui.select.cancel\")) {\n\t\t\tthis.options.onCancel();\n\t\t}\n\t}\n}\n"]}