// Code generated by templ - DO NOT EDIT.

// templ: version: v0.2.778
package views

//lint:file-ignore SA4006 This context is only used if a nested component is present.

import "github.com/a-h/templ"
import templruntime "github.com/a-h/templ/runtime"

import (
	"fmt"
	"whereismymoney/internal/models"
)

func Settings(userName string, user models.User, categories []models.Category, bankAccounts []models.BankAccount) templ.Component {
	return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
		templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
		if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
			return templ_7745c5c3_CtxErr
		}
		templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
		if !templ_7745c5c3_IsBuffer {
			defer func() {
				templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
				if templ_7745c5c3_Err == nil {
					templ_7745c5c3_Err = templ_7745c5c3_BufErr
				}
			}()
		}
		ctx = templ.InitializeContext(ctx)
		templ_7745c5c3_Var1 := templ.GetChildren(ctx)
		if templ_7745c5c3_Var1 == nil {
			templ_7745c5c3_Var1 = templ.NopComponent
		}
		ctx = templ.ClearChildren(ctx)
		templ_7745c5c3_Var2 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
			templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
			templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
			if !templ_7745c5c3_IsBuffer {
				defer func() {
					templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
					if templ_7745c5c3_Err == nil {
						templ_7745c5c3_Err = templ_7745c5c3_BufErr
					}
				}()
			}
			ctx = templ.InitializeContext(ctx)
			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<div class=\"min-h-screen bg-gray-50\">")
			if templ_7745c5c3_Err != nil {
				return templ_7745c5c3_Err
			}
			templ_7745c5c3_Err = Navigation(userName).Render(ctx, templ_7745c5c3_Buffer)
			if templ_7745c5c3_Err != nil {
				return templ_7745c5c3_Err
			}
			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<div class=\"max-w-7xl mx-auto py-6 sm:px-6 lg:px-8\"><div class=\"px-4 py-6 sm:px-0\"><div class=\"mb-8\"><h1 class=\"text-3xl font-bold text-gray-900\">Einstellungen</h1><p class=\"mt-2 text-gray-600\">Verwalte deine Kontoinformationen und App-Einstellungen</p></div><div class=\"grid grid-cols-1 lg:grid-cols-3 gap-6\"><!-- Benutzereinstellungen --><div class=\"lg:col-span-2\"><div class=\"bg-white shadow rounded-lg\"><div class=\"px-6 py-4 border-b border-gray-200\"><h2 class=\"text-lg font-medium text-gray-900\">Benutzereinstellungen</h2></div><div class=\"px-6 py-4\"><form id=\"userSettingsForm\" class=\"space-y-4\"><div><label for=\"username\" class=\"block text-sm font-medium text-gray-700\">Benutzername</label> <input type=\"text\" id=\"username\" name=\"username\" value=\"")
			if templ_7745c5c3_Err != nil {
				return templ_7745c5c3_Err
			}
			var templ_7745c5c3_Var3 string
			templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(user.Name)
			if templ_7745c5c3_Err != nil {
				return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/views/settings.templ`, Line: 31, Col: 77}
			}
			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3))
			if templ_7745c5c3_Err != nil {
				return templ_7745c5c3_Err
			}
			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\" class=\"mt-1 w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-blue-500 focus:border-blue-500\"></div><div><label for=\"email\" class=\"block text-sm font-medium text-gray-700\">E-Mail</label> <input type=\"email\" id=\"email\" name=\"email\" value=\"")
			if templ_7745c5c3_Err != nil {
				return templ_7745c5c3_Err
			}
			var templ_7745c5c3_Var4 string
			templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(user.Email)
			if templ_7745c5c3_Err != nil {
				return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/views/settings.templ`, Line: 35, Col: 73}
			}
			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4))
			if templ_7745c5c3_Err != nil {
				return templ_7745c5c3_Err
			}
			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\" readonly class=\"mt-1 w-full px-3 py-2 border border-gray-300 rounded-md bg-gray-50 text-gray-500 cursor-not-allowed\" title=\"E-Mail-Adresse kann nicht geändert werden\"><p class=\"mt-1 text-xs text-gray-500\">Die E-Mail-Adresse dient als eindeutige Benutzer-ID und kann nicht geändert werden.</p></div><div class=\"pt-4\"><button type=\"submit\" class=\"px-4 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500\">Speichern</button></div></form></div></div><!-- Passwort ändern --><div class=\"bg-white shadow rounded-lg mt-6\"><div class=\"px-6 py-4 border-b border-gray-200\"><h2 class=\"text-lg font-medium text-gray-900\">Passwort ändern</h2></div><div class=\"px-6 py-4\"><form id=\"passwordForm\" class=\"space-y-4\"><div><label for=\"current_password\" class=\"block text-sm font-medium text-gray-700\">Aktuelles Passwort</label> <input type=\"password\" id=\"current_password\" name=\"current_password\" class=\"mt-1 w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-blue-500 focus:border-blue-500\"></div><div><label for=\"new_password\" class=\"block text-sm font-medium text-gray-700\">Neues Passwort</label> <input type=\"password\" id=\"new_password\" name=\"new_password\" class=\"mt-1 w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-blue-500 focus:border-blue-500\"></div><div><label for=\"confirm_password\" class=\"block text-sm font-medium text-gray-700\">Passwort bestätigen</label> <input type=\"password\" id=\"confirm_password\" name=\"confirm_password\" class=\"mt-1 w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-blue-500 focus:border-blue-500\"></div><div class=\"pt-4\"><button type=\"submit\" class=\"px-4 py-2 bg-red-600 text-white rounded-md hover:bg-red-700 focus:outline-none focus:ring-2 focus:ring-red-500\">Passwort ändern</button></div></form></div></div></div><!-- Seitenleiste --><div class=\"space-y-6\"><!-- Kategorien verwalten --><div class=\"bg-white shadow rounded-lg\"><div class=\"px-6 py-4 border-b border-gray-200\"><h3 class=\"text-lg font-medium text-gray-900\">Kategorien</h3></div><div class=\"px-6 py-4\"><div class=\"space-y-2 max-h-48 overflow-y-auto\">")
			if templ_7745c5c3_Err != nil {
				return templ_7745c5c3_Err
			}
			for _, category := range categories {
				_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<div class=\"flex items-center justify-between p-2 hover:bg-gray-50 rounded\"><span class=\"text-sm\">")
				if templ_7745c5c3_Err != nil {
					return templ_7745c5c3_Err
				}
				var templ_7745c5c3_Var5 string
				templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(category.Icon)
				if templ_7745c5c3_Err != nil {
					return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/views/settings.templ`, Line: 87, Col: 49}
				}
				_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5))
				if templ_7745c5c3_Err != nil {
					return templ_7745c5c3_Err
				}
				_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(" ")
				if templ_7745c5c3_Err != nil {
					return templ_7745c5c3_Err
				}
				var templ_7745c5c3_Var6 string
				templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(category.Name)
				if templ_7745c5c3_Err != nil {
					return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/views/settings.templ`, Line: 87, Col: 67}
				}
				_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var6))
				if templ_7745c5c3_Err != nil {
					return templ_7745c5c3_Err
				}
				_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</span> <button class=\"delete-category text-red-600 hover:text-red-800 text-sm\" data-category-id=\"")
				if templ_7745c5c3_Err != nil {
					return templ_7745c5c3_Err
				}
				var templ_7745c5c3_Var7 string
				templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("%d", category.ID))
				if templ_7745c5c3_Err != nil {
					return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/views/settings.templ`, Line: 88, Col: 133}
				}
				_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7))
				if templ_7745c5c3_Err != nil {
					return templ_7745c5c3_Err
				}
				_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\">🗑️</button></div>")
				if templ_7745c5c3_Err != nil {
					return templ_7745c5c3_Err
				}
			}
			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</div><button onclick=\"showModal(&#39;categoryModal&#39;)\" class=\"mt-4 w-full px-3 py-2 bg-gray-100 text-gray-700 rounded-md hover:bg-gray-200 text-sm\">+ Neue Kategorie</button></div></div><!-- Konten verwalten --><div class=\"bg-white shadow rounded-lg\"><div class=\"px-6 py-4 border-b border-gray-200\"><h3 class=\"text-lg font-medium text-gray-900\">Bankkonten</h3></div><div class=\"px-6 py-4\"><div class=\"space-y-2 max-h-48 overflow-y-auto\">")
			if templ_7745c5c3_Err != nil {
				return templ_7745c5c3_Err
			}
			for _, account := range bankAccounts {
				_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<div class=\"flex items-center justify-between p-2 hover:bg-gray-50 rounded\"><div class=\"text-sm\"><div class=\"font-medium\">")
				if templ_7745c5c3_Err != nil {
					return templ_7745c5c3_Err
				}
				var templ_7745c5c3_Var8 string
				templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(account.Name)
				if templ_7745c5c3_Err != nil {
					return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/views/settings.templ`, Line: 110, Col: 52}
				}
				_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var8))
				if templ_7745c5c3_Err != nil {
					return templ_7745c5c3_Err
				}
				_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</div><div class=\"text-gray-500\">")
				if templ_7745c5c3_Err != nil {
					return templ_7745c5c3_Err
				}
				var templ_7745c5c3_Var9 string
				templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinStringErrs(account.Bank)
				if templ_7745c5c3_Err != nil {
					return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/views/settings.templ`, Line: 111, Col: 54}
				}
				_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var9))
				if templ_7745c5c3_Err != nil {
					return templ_7745c5c3_Err
				}
				_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</div></div><button class=\"delete-account text-red-600 hover:text-red-800 text-sm\" data-account-id=\"")
				if templ_7745c5c3_Err != nil {
					return templ_7745c5c3_Err
				}
				var templ_7745c5c3_Var10 string
				templ_7745c5c3_Var10, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("%d", account.ID))
				if templ_7745c5c3_Err != nil {
					return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/views/settings.templ`, Line: 113, Col: 130}
				}
				_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var10))
				if templ_7745c5c3_Err != nil {
					return templ_7745c5c3_Err
				}
				_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\">🗑️</button></div>")
				if templ_7745c5c3_Err != nil {
					return templ_7745c5c3_Err
				}
			}
			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</div><a href=\"/accounts\" class=\"mt-4 w-full block px-3 py-2 bg-gray-100 text-gray-700 rounded-md hover:bg-gray-200 text-sm text-center\">Konten verwalten</a></div></div><!-- App-Informationen --><div class=\"bg-white shadow rounded-lg\"><div class=\"px-6 py-4 border-b border-gray-200\"><h3 class=\"text-lg font-medium text-gray-900\">App-Informationen</h3></div><div class=\"px-6 py-4 space-y-2 text-sm text-gray-600\"><div>Version: 1.0.0</div><div>Erstellt mit Go & Templ</div><div>© 2025 WhereIsMyMoney</div></div></div></div></div></div></div></div><!-- Kategorie Modal --> <div id=\"categoryModal\" class=\"fixed inset-0 bg-gray-600 bg-opacity-50 hidden z-50\"><div class=\"flex items-center justify-center min-h-screen px-4\"><div class=\"bg-white rounded-lg shadow-xl max-w-md w-full\"><form id=\"categoryForm\" method=\"POST\" action=\"/settings/categories\"><div class=\"px-6 py-4 border-b border-gray-200\"><h3 class=\"text-lg font-medium text-gray-900\">Neue Kategorie erstellen</h3></div><div class=\"px-6 py-4 space-y-4\"><div><label for=\"category_name\" class=\"block text-sm font-medium text-gray-700\">Name</label> <input type=\"text\" id=\"category_name\" name=\"name\" required class=\"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-blue-500 focus:border-blue-500\" placeholder=\"z.B. Lebensmittel\"></div><div><label for=\"category_icon\" class=\"block text-sm font-medium text-gray-700\">Icon (Emoji)</label> <input type=\"text\" id=\"category_icon\" name=\"icon\" required class=\"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-blue-500 focus:border-blue-500\" placeholder=\"🛒\" maxlength=\"2\"></div><div><label for=\"category_color\" class=\"block text-sm font-medium text-gray-700\">Farbe</label> <input type=\"color\" id=\"category_color\" name=\"color\" value=\"#3B82F6\" class=\"w-full h-10 border border-gray-300 rounded-md focus:outline-none focus:ring-blue-500 focus:border-blue-500\"></div></div><div class=\"px-6 py-4 border-t border-gray-200 flex justify-end space-x-3\"><button type=\"button\" onclick=\"hideModal(&#39;categoryModal&#39;)\" class=\"px-4 py-2 text-sm font-medium text-gray-700 bg-gray-100 rounded-md hover:bg-gray-200\">Abbrechen</button> <button type=\"submit\" class=\"px-4 py-2 text-sm font-medium text-white bg-blue-600 rounded-md hover:bg-blue-700\">Erstellen</button></div></form></div></div></div><script>\n\t\t\tfunction showModal(modalId) {\n\t\t\t\tdocument.getElementById(modalId).classList.remove('hidden');\n\t\t\t}\n\n\t\t\tfunction hideModal(modalId) {\n\t\t\t\tdocument.getElementById(modalId).classList.add('hidden');\n\t\t\t}\n\n\t\t\t// Event Listeners für Delete-Buttons\n\t\t\tdocument.addEventListener('DOMContentLoaded', function() {\n\t\t\t\t// Delete Category Buttons\n\t\t\t\tdocument.querySelectorAll('.delete-category').forEach(button => {\n\t\t\t\t\tbutton.addEventListener('click', function() {\n\t\t\t\t\t\tconst categoryId = this.getAttribute('data-category-id');\n\t\t\t\t\t\tdeleteCategory(categoryId);\n\t\t\t\t\t});\n\t\t\t\t});\n\n\t\t\t\t// Delete Account Buttons\n\t\t\t\tdocument.querySelectorAll('.delete-account').forEach(button => {\n\t\t\t\t\tbutton.addEventListener('click', function() {\n\t\t\t\t\t\tconst accountId = this.getAttribute('data-account-id');\n\t\t\t\t\t\tdeleteAccount(accountId);\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t});\n\n\t\t\tfunction deleteCategory(categoryId) {\n\t\t\t\tif (!confirm('Möchten Sie diese Kategorie wirklich löschen?')) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tfetch(`/settings/categories/${categoryId}`, {\n\t\t\t\t\tmethod: 'DELETE'\n\t\t\t\t}).then(response => {\n\t\t\t\t\tif (response.ok) {\n\t\t\t\t\t\tlocation.reload();\n\t\t\t\t\t} else {\n\t\t\t\t\t\talert('Fehler beim Löschen der Kategorie');\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tfunction deleteAccount(accountId) {\n\t\t\t\tif (!confirm('Möchten Sie dieses Konto wirklich löschen?')) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tfetch(`/settings/accounts/${accountId}`, {\n\t\t\t\t\tmethod: 'DELETE'\n\t\t\t\t}).then(response => {\n\t\t\t\t\tif (response.ok) {\n\t\t\t\t\t\tlocation.reload();\n\t\t\t\t\t} else {\n\t\t\t\t\t\talert('Fehler beim Löschen des Kontos');\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\n\t\t\t// Benutzereinstellungen speichern\n\t\t\tdocument.getElementById('userSettingsForm').addEventListener('submit', async function(e) {\n\t\t\t\te.preventDefault();\n\t\t\t\t\n\t\t\t\t// Nur den Benutzernamen senden, E-Mail wird ignoriert\n\t\t\t\tconst formObject = {\n\t\t\t\t\tusername: document.getElementById('username').value\n\t\t\t\t};\n\t\t\t\t\n\t\t\t\ttry {\n\t\t\t\t\tconst response = await fetch('/settings/user', {\n\t\t\t\t\t\tmethod: 'PUT',\n\t\t\t\t\t\theaders: {\n\t\t\t\t\t\t\t'Content-Type': 'application/json',\n\t\t\t\t\t\t},\n\t\t\t\t\t\tbody: JSON.stringify(formObject)\n\t\t\t\t\t});\n\t\t\t\t\t\n\t\t\t\t\tif (response.ok) {\n\t\t\t\t\t\talert('Einstellungen gespeichert!');\n\t\t\t\t\t} else {\n\t\t\t\t\t\talert('Fehler beim Speichern der Einstellungen');\n\t\t\t\t\t}\n\t\t\t\t} catch (error) {\n\t\t\t\t\talert('Fehler beim Speichern der Einstellungen');\n\t\t\t\t}\n\t\t\t});\n\n\t\t\t// Passwort ändern\n\t\t\tdocument.getElementById('passwordForm').addEventListener('submit', async function(e) {\n\t\t\t\te.preventDefault();\n\t\t\t\t\n\t\t\t\tconst newPassword = document.getElementById('new_password').value;\n\t\t\t\tconst confirmPassword = document.getElementById('confirm_password').value;\n\t\t\t\t\n\t\t\t\tif (newPassword !== confirmPassword) {\n\t\t\t\t\talert('Die Passwörter stimmen nicht überein!');\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tconst formData = new FormData(this);\n\t\t\t\tconst formObject = {};\n\t\t\t\tfor (let [key, value] of formData.entries()) {\n\t\t\t\t\tformObject[key] = value;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\ttry {\n\t\t\t\t\tconst response = await fetch('/settings/password', {\n\t\t\t\t\t\tmethod: 'PUT',\n\t\t\t\t\t\theaders: {\n\t\t\t\t\t\t\t'Content-Type': 'application/json',\n\t\t\t\t\t\t},\n\t\t\t\t\t\tbody: JSON.stringify(formObject)\n\t\t\t\t\t});\n\t\t\t\t\t\n\t\t\t\t\tif (response.ok) {\n\t\t\t\t\t\talert('Passwort erfolgreich geändert!');\n\t\t\t\t\t\tthis.reset();\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconst error = await response.text();\n\t\t\t\t\t\talert('Fehler: ' + error);\n\t\t\t\t\t}\n\t\t\t\t} catch (error) {\n\t\t\t\t\talert('Fehler beim Ändern des Passworts');\n\t\t\t\t}\n\t\t\t});\n\n\t\t\t// Modal schließen beim Klick außerhalb\n\t\t\tdocument.addEventListener('click', function(event) {\n\t\t\t\tif (event.target.classList.contains('bg-opacity-50')) {\n\t\t\t\t\tevent.target.classList.add('hidden');\n\t\t\t\t}\n\t\t\t});\n\t\t</script>")
			if templ_7745c5c3_Err != nil {
				return templ_7745c5c3_Err
			}
			return templ_7745c5c3_Err
		})
		templ_7745c5c3_Err = Layout("Einstellungen - WhereIsMyMoney").Render(templ.WithChildren(ctx, templ_7745c5c3_Var2), templ_7745c5c3_Buffer)
		if templ_7745c5c3_Err != nil {
			return templ_7745c5c3_Err
		}
		return templ_7745c5c3_Err
	})
}

var _ = templruntime.GeneratedTemplate
