// Code generated by templ - DO NOT EDIT.

// templ: version: v0.2.778
package templates

//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"
	"portfolio-tracker/internal/model"
	"portfolio-tracker/internal/web/templates/components"
)

func StockDetailsContent(stock string, data model.YahooChartResponse, portfolios []model.Portfolio) 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_Err = templ_7745c5c3_Buffer.WriteString("<div class=\"page-header d-print-none\" aria-label=\"Page header\"><div class=\"container-fluid\"><div class=\"row g-2 align-items-center\"><div class=\"col\"><div class=\"page-pretitle\">")
		if templ_7745c5c3_Err != nil {
			return templ_7745c5c3_Err
		}
		var templ_7745c5c3_Var2 string
		templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(data.Chart.Result[0].Meta.Symbol)
		if templ_7745c5c3_Err != nil {
			return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/templates/stock-details.templ`, Line: 14, Col: 66}
		}
		_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2))
		if templ_7745c5c3_Err != nil {
			return templ_7745c5c3_Err
		}
		_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</div><h2 class=\"page-title\">")
		if templ_7745c5c3_Err != nil {
			return templ_7745c5c3_Err
		}
		var templ_7745c5c3_Var3 string
		templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(data.Chart.Result[0].Meta.LongName)
		if templ_7745c5c3_Err != nil {
			return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/templates/stock-details.templ`, Line: 15, Col: 64}
		}
		_, 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("</h2></div><div class=\"col-auto ms-auto d-print-none\"><div class=\"btn-list\"><span class=\"d-none d-sm-inline\"><a href=\"/portfolio\" class=\"btn btn-outline-primary\">Zum Portfolio</a></span> <button type=\"button\" class=\"btn btn-primary btn-5 d-none d-sm-inline-block\" data-bs-toggle=\"modal\" data-bs-target=\"#addToPortfolioModal\"><svg xmlns=\"http://www.w3.org/2000/svg\" class=\"icon\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" stroke-width=\"2\" stroke=\"currentColor\" fill=\"none\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path stroke=\"none\" d=\"M0 0h24v24H0z\" fill=\"none\"></path> <path d=\"M12 5l0 14\"></path> <path d=\"M5 12l14 0\"></path></svg> Zu Portfolio hinzufügen</button> <button type=\"button\" class=\"btn btn-primary btn-6 d-sm-none btn-icon\" data-bs-toggle=\"modal\" data-bs-target=\"#addToPortfolioModal\" aria-label=\"Zu Portfolio hinzufügen\"><svg xmlns=\"http://www.w3.org/2000/svg\" class=\"icon\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" stroke-width=\"2\" stroke=\"currentColor\" fill=\"none\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path stroke=\"none\" d=\"M0 0h24v24H0z\" fill=\"none\"></path> <path d=\"M12 5l0 14\"></path> <path d=\"M5 12l14 0\"></path></svg></button></div></div></div></div></div><div class=\"container-fluid mt-4\"><div class=\"row\"><!-- Linke Spalte: Charts --><div class=\"col-md-8 col-12\"><div class=\"card mb-4\"><div class=\"card-header\"><h1 class=\"card-title\">Kursentwicklung</h1></div><div class=\"card-body\"><div id=\"chart\"></div></div></div><div class=\"card\"><div class=\"card-header\"><h1 class=\"card-title\">Dividenden</h1></div><div class=\"card-body\"><div id=\"chart2\"></div></div></div></div><!-- Rechte Spalte: Details --><div class=\"col-md-4 col-12\"><div class=\"card\"><div class=\"card-header\"><h2 class=\"card-title\">Details</h2></div><div class=\"card-body\"><ul class=\"list-unstyled\"><li><strong>Name:</strong> ")
		if templ_7745c5c3_Err != nil {
			return templ_7745c5c3_Err
		}
		var templ_7745c5c3_Var4 string
		templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(data.Chart.Result[0].Meta.LongName)
		if templ_7745c5c3_Err != nil {
			return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/templates/stock-details.templ`, Line: 71, Col: 70}
		}
		_, 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("</li><li><strong>Symbol:</strong> ")
		if templ_7745c5c3_Err != nil {
			return templ_7745c5c3_Err
		}
		var templ_7745c5c3_Var5 string
		templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(data.Chart.Result[0].Meta.Symbol)
		if templ_7745c5c3_Err != nil {
			return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/templates/stock-details.templ`, Line: 72, Col: 70}
		}
		_, 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("</li><li><strong>Währung:</strong> ")
		if templ_7745c5c3_Err != nil {
			return templ_7745c5c3_Err
		}
		var templ_7745c5c3_Var6 string
		templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(data.Chart.Result[0].Meta.Currency)
		if templ_7745c5c3_Err != nil {
			return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/templates/stock-details.templ`, Line: 73, Col: 74}
		}
		_, 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("</li><li><strong>Börse:</strong> ")
		if templ_7745c5c3_Err != nil {
			return templ_7745c5c3_Err
		}
		var templ_7745c5c3_Var7 string
		templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(data.Chart.Result[0].Meta.Exchange)
		if templ_7745c5c3_Err != nil {
			return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/templates/stock-details.templ`, Line: 74, Col: 72}
		}
		_, 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("</li><li><strong>Zeitzone:</strong> ")
		if templ_7745c5c3_Err != nil {
			return templ_7745c5c3_Err
		}
		var templ_7745c5c3_Var8 string
		templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(data.Chart.Result[0].Meta.Timezone)
		if templ_7745c5c3_Err != nil {
			return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/templates/stock-details.templ`, Line: 75, Col: 74}
		}
		_, 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("</li><li><strong>Aktueller Preis:</strong> ")
		if templ_7745c5c3_Err != nil {
			return templ_7745c5c3_Err
		}
		var templ_7745c5c3_Var9 string
		templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinStringErrs(data.Chart.Result[0].Meta.RegularMarketPrice)
		if templ_7745c5c3_Err != nil {
			return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/templates/stock-details.templ`, Line: 76, Col: 91}
		}
		_, 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("</li><li><strong>Instrumenttyp:</strong> ")
		if templ_7745c5c3_Err != nil {
			return templ_7745c5c3_Err
		}
		var templ_7745c5c3_Var10 string
		templ_7745c5c3_Var10, templ_7745c5c3_Err = templ.JoinStringErrs(data.Chart.Result[0].Meta.Instrument)
		if templ_7745c5c3_Err != nil {
			return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/templates/stock-details.templ`, Line: 77, Col: 81}
		}
		_, 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("</li></ul></div></div></div></div></div><!-- Add to Portfolio Modal --><div class=\"modal modal-blur fade\" id=\"addToPortfolioModal\" tabindex=\"-1\" aria-labelledby=\"addToPortfolioModalLabel\" aria-hidden=\"true\"><div class=\"modal-dialog\"><div class=\"modal-content\"><div class=\"modal-header\"><h5 class=\"modal-title\" id=\"addToPortfolioModalLabel\">")
		if templ_7745c5c3_Err != nil {
			return templ_7745c5c3_Err
		}
		var templ_7745c5c3_Var11 string
		templ_7745c5c3_Var11, templ_7745c5c3_Err = templ.JoinStringErrs(data.Chart.Result[0].Meta.Symbol)
		if templ_7745c5c3_Err != nil {
			return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/templates/stock-details.templ`, Line: 89, Col: 93}
		}
		_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var11))
		if templ_7745c5c3_Err != nil {
			return templ_7745c5c3_Err
		}
		_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(" zu Portfolio hinzufügen</h5><button type=\"button\" class=\"btn-close\" data-bs-dismiss=\"modal\" aria-label=\"Schließen\"></button></div><form method=\"post\" action=\"/portfolio/transaction\"><div class=\"modal-body\"><div class=\"mb-3\"><label for=\"portfolio-select\" class=\"form-label\">Portfolio</label> <select class=\"form-select\" id=\"portfolio-select\" name=\"portfolio_id\" required><option value=\"\">Wählen Sie ein Portfolio</option> ")
		if templ_7745c5c3_Err != nil {
			return templ_7745c5c3_Err
		}
		for _, portfolio := range portfolios {
			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("<option value=\"")
			if templ_7745c5c3_Err != nil {
				return templ_7745c5c3_Err
			}
			var templ_7745c5c3_Var12 string
			templ_7745c5c3_Var12, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("%d", portfolio.ID))
			if templ_7745c5c3_Err != nil {
				return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/templates/stock-details.templ`, Line: 99, Col: 56}
			}
			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var12))
			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_Var13 string
			templ_7745c5c3_Var13, templ_7745c5c3_Err = templ.JoinStringErrs(portfolio.Name)
			if templ_7745c5c3_Err != nil {
				return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/templates/stock-details.templ`, Line: 100, Col: 26}
			}
			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var13))
			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_Var14 string
			templ_7745c5c3_Var14, templ_7745c5c3_Err = templ.JoinStringErrs(portfolio.BaseCurrency)
			if templ_7745c5c3_Err != nil {
				return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/templates/stock-details.templ`, Line: 100, Col: 54}
			}
			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var14))
			if templ_7745c5c3_Err != nil {
				return templ_7745c5c3_Err
			}
			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(")</option>")
			if templ_7745c5c3_Err != nil {
				return templ_7745c5c3_Err
			}
		}
		_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</select></div><div class=\"mb-3\"><label for=\"transaction-type\" class=\"form-label\">Transaktionstyp</label> <select class=\"form-select\" id=\"transaction-type\" name=\"type\" required><option value=\"\">Wählen Sie einen Typ</option> <option value=\"BUY\">Kauf</option> <option value=\"SELL\">Verkauf</option> <option value=\"DIVIDEND\">Dividende</option></select></div><div class=\"mb-3\"><label for=\"transaction-stock\" class=\"form-label\">Wertpapier</label> <input type=\"text\" class=\"form-control\" id=\"transaction-stock\" name=\"stock\" value=\"")
		if templ_7745c5c3_Err != nil {
			return templ_7745c5c3_Err
		}
		var templ_7745c5c3_Var15 string
		templ_7745c5c3_Var15, templ_7745c5c3_Err = templ.JoinStringErrs(data.Chart.Result[0].Meta.Symbol)
		if templ_7745c5c3_Err != nil {
			return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/templates/stock-details.templ`, Line: 116, Col: 123}
		}
		_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var15))
		if templ_7745c5c3_Err != nil {
			return templ_7745c5c3_Err
		}
		_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\" readonly><div class=\"form-text\">")
		if templ_7745c5c3_Err != nil {
			return templ_7745c5c3_Err
		}
		var templ_7745c5c3_Var16 string
		templ_7745c5c3_Var16, templ_7745c5c3_Err = templ.JoinStringErrs(data.Chart.Result[0].Meta.LongName)
		if templ_7745c5c3_Err != nil {
			return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/templates/stock-details.templ`, Line: 117, Col: 66}
		}
		_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var16))
		if templ_7745c5c3_Err != nil {
			return templ_7745c5c3_Err
		}
		_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</div></div><div class=\"mb-3\"><label for=\"transaction-amount\" class=\"form-label\">Anzahl</label> <input type=\"number\" class=\"form-control\" id=\"transaction-amount\" name=\"amount\" step=\"0.001\" min=\"0\" required></div><div class=\"mb-3\"><label for=\"transaction-price\" class=\"form-label\">Preis pro Aktie</label><div class=\"input-group\"><input type=\"number\" class=\"form-control\" id=\"transaction-price\" name=\"price\" step=\"0.01\" min=\"0\" value=\"")
		if templ_7745c5c3_Err != nil {
			return templ_7745c5c3_Err
		}
		var templ_7745c5c3_Var17 string
		templ_7745c5c3_Var17, templ_7745c5c3_Err = templ.JoinStringErrs(data.Chart.Result[0].Meta.RegularMarketPrice)
		if templ_7745c5c3_Err != nil {
			return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/templates/stock-details.templ`, Line: 126, Col: 158}
		}
		_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var17))
		if templ_7745c5c3_Err != nil {
			return templ_7745c5c3_Err
		}
		_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\" required> <span class=\"input-group-text\">")
		if templ_7745c5c3_Err != nil {
			return templ_7745c5c3_Err
		}
		var templ_7745c5c3_Var18 string
		templ_7745c5c3_Var18, templ_7745c5c3_Err = templ.JoinStringErrs(data.Chart.Result[0].Meta.Currency)
		if templ_7745c5c3_Err != nil {
			return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/templates/stock-details.templ`, Line: 127, Col: 75}
		}
		_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var18))
		if templ_7745c5c3_Err != nil {
			return templ_7745c5c3_Err
		}
		_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("</span></div></div><div class=\"mb-3\"><label for=\"transaction-date\" class=\"form-label\">Datum</label> <input type=\"date\" class=\"form-control\" id=\"transaction-date\" name=\"date\" required></div><div class=\"mb-3\"><label for=\"transaction-note\" class=\"form-label\">Notiz (optional)</label> <textarea class=\"form-control\" id=\"transaction-note\" name=\"note\" rows=\"2\" placeholder=\"z.B. Grund für Kauf/Verkauf\"></textarea></div></div><div class=\"modal-footer\"><button type=\"button\" class=\"btn btn-secondary\" data-bs-dismiss=\"modal\">Abbrechen</button> <button type=\"submit\" class=\"btn btn-primary\">Zu Portfolio hinzufügen</button></div></form></div></div></div><!-- Inline Scripts for Charts --><script>\n\t\t// Stock symbol for API calls\n\t\tconst stockSymbol = {{ data.Chart.Result[0].Meta.Symbol }};\n\n\t\t// Set today's date as default\n\t\tdocument.addEventListener('DOMContentLoaded', function() {\n\t\t\tconst today = new Date().toISOString().split('T')[0];\n\t\t\tdocument.getElementById('transaction-date').value = today;\n\n\t\t\t// First Chart: Stock Price\n\t\t\tfetch('/api/yahoo?stock=' + encodeURIComponent(stockSymbol))\n\t\t\t\t.then(response => response.json())\n\t\t\t\t.then(data => {\n\t\t\t\t\tconsole.log('Stock data received:', data);\n\t\t\t\t\tif (data.chart && data.chart.result && data.chart.result.length > 0) {\n\t\t\t\t\t\tconst result = data.chart.result[0];\n\t\t\t\t\t\tconst timestamps = result.timestamp.map(ts =>\n\t\t\t\t\t\t\tnew Date(ts * 1000).toISOString().slice(0, 10)\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconst closes = result.indicators.quote[0].close.map(v =>\n\t\t\t\t\t\t\tv !== null ? Math.round(v * 10000) / 10000 : null\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tconst options = {\n\t\t\t\t\t\t\tchart: {\n\t\t\t\t\t\t\t\ttype: 'area',\n\t\t\t\t\t\t\t\theight: 350,\n\t\t\t\t\t\t\t\ttoolbar: {\n\t\t\t\t\t\t\t\t\tshow: true\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tdataLabels: {\n\t\t\t\t\t\t\t\tenabled: false\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tseries: [{\n\t\t\t\t\t\t\t\tname: 'Kurs',\n\t\t\t\t\t\t\t\tdata: closes\n\t\t\t\t\t\t\t}],\n\t\t\t\t\t\t\txaxis: {\n\t\t\t\t\t\t\t\tcategories: timestamps,\n\t\t\t\t\t\t\t\ttype: 'datetime'\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tyaxis: {\n\t\t\t\t\t\t\t\tlabels: {\n\t\t\t\t\t\t\t\t\tformatter: function(value) {\n\t\t\t\t\t\t\t\t\t\treturn value ? value.toFixed(2) : '';\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\ttooltip: {\n\t\t\t\t\t\t\t\tx: {\n\t\t\t\t\t\t\t\t\tformat: 'dd MMM yyyy'\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\ty: {\n\t\t\t\t\t\t\t\t\tformatter: function(value) {\n\t\t\t\t\t\t\t\t\t\treturn value ? value.toFixed(2) : '';\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tconst chart = new ApexCharts(document.querySelector(\"#chart\"), options);\n\t\t\t\t\t\tchart.render();\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t\t.catch(error => {\n\t\t\t\t\tconsole.error('Error fetching stock data:', error);\n\t\t\t\t\tdocument.querySelector(\"#chart\").innerHTML = '<p>Fehler beim Laden der Kursdaten.</p>';\n\t\t\t\t});\n\n\t\t\t// Second Chart: Dividends\n\t\t\tfetch('/api/yahoomaxdividends?stock=' + encodeURIComponent(stockSymbol))\n\t\t\t\t.then(response => response.json())\n\t\t\t\t.then(data => {\n\t\t\t\t\tconsole.log('Dividend data received:', data);\n\t\t\t\t\tconsole.log('Data type:', typeof data);\n\t\t\t\t\tconsole.log('Data length:', data ? data.length : 'no length');\n\n\t\t\t\t\tif (data && Array.isArray(data) && data.length > 0) {\n\t\t\t\t\t\tconsole.log('First dividend entry:', data[0]);\n\n\t\t\t\t\t\t// Convert the data to the format ApexCharts expects\n\t\t\t\t\t\tconst dividendData = data.map(item => ({\n\t\t\t\t\t\t\tx: new Date(item[0]),\n\t\t\t\t\t\t\ty: item[1]\n\t\t\t\t\t\t}));\n\n\t\t\t\t\t\tconsole.log('Processed dividend data:', dividendData);\n\n\t\t\t\t\t\tconst options2 = {\n\t\t\t\t\t\t\tchart: {\n\t\t\t\t\t\t\t\ttype: 'bar',\n\t\t\t\t\t\t\t\theight: 350,\n\t\t\t\t\t\t\t\ttoolbar: {\n\t\t\t\t\t\t\t\t\tshow: true\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tdataLabels: {\n\t\t\t\t\t\t\t\tenabled: false,\n\t\t\t\t\t\t\t\tformatter: function(val) {\n\t\t\t\t\t\t\t\t\treturn val.toFixed(2);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tseries: [{\n\t\t\t\t\t\t\t\tname: 'Dividende',\n\t\t\t\t\t\t\t\tdata: dividendData\n\t\t\t\t\t\t\t}],\n\t\t\t\t\t\t\txaxis: {\n\t\t\t\t\t\t\t\ttype: 'datetime',\n\t\t\t\t\t\t\t\ttitle: {\n\t\t\t\t\t\t\t\t\ttext: 'Datum'\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tyaxis: {\n\t\t\t\t\t\t\t\ttitle: {\n\t\t\t\t\t\t\t\t\ttext: 'Dividende'\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tlabels: {\n\t\t\t\t\t\t\t\t\tformatter: function(value) {\n\t\t\t\t\t\t\t\t\t\treturn value ? value.toFixed(2) : '';\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\ttooltip: {\n\t\t\t\t\t\t\t\tx: {\n\t\t\t\t\t\t\t\t\tformat: 'dd MMM yyyy'\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\ty: {\n\t\t\t\t\t\t\t\t\tformatter: function(value) {\n\t\t\t\t\t\t\t\t\t\treturn value ? value.toFixed(2) : '';\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tconst chart2 = new ApexCharts(document.querySelector(\"#chart2\"), options2);\n\t\t\t\t\t\tchart2.render();\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconsole.log('No dividend data available or data is empty');\n\t\t\t\t\t\tdocument.querySelector(\"#chart2\").innerHTML = '<p>Keine Dividendendaten verfügbar für dieses Wertpapier.</p>';\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t\t.catch(error => {\n\t\t\t\t\tconsole.error('Error fetching dividend data:', error);\n\t\t\t\t\tdocument.querySelector(\"#chart2\").innerHTML = '<p>Fehler beim Laden der Dividendendaten.</p>';\n\t\t\t\t});\n\t\t});\n\t</script>")
		if templ_7745c5c3_Err != nil {
			return templ_7745c5c3_Err
		}
		return templ_7745c5c3_Err
	})
}

func StockDetails(authenticated bool, username string, stock string, data model.YahooChartResponse, portfolios []model.Portfolio) 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_Var19 := templ.GetChildren(ctx)
		if templ_7745c5c3_Var19 == nil {
			templ_7745c5c3_Var19 = templ.NopComponent
		}
		ctx = templ.ClearChildren(ctx)
		templ_7745c5c3_Err = components.PageLayout(authenticated, username, data.Chart.Result[0].Meta.LongName, StockDetailsContent(stock, data, portfolios), portfolios).Render(ctx, templ_7745c5c3_Buffer)
		if templ_7745c5c3_Err != nil {
			return templ_7745c5c3_Err
		}
		return templ_7745c5c3_Err
	})
}

var _ = templruntime.GeneratedTemplate
