package docx

import "mgit.msbls.de/m/paliad/pkg/docforge"

// Exporter is the .docx implementation of docforge.Exporter — it renders a
// neutral Document to OOXML body markup (t-paliad-349 slice 8). The
// stylemap (block kind → Word paragraph style) and the optional hyperlink
// allocator are baked in at construction, so RenderBody matches the
// interface's format-neutral signature.
//
// This is the seam a future PDF/HTML exporter slots into: implement
// docforge.Exporter, no engine change. The submission composer can render
// section content through this exporter instead of calling
// RenderDocumentToOOXML directly once a second format exists.
type Exporter struct {
	Stylemap map[string]string
	Links    HyperlinkAllocator
}

// compile-time conformance.
var _ docforge.Exporter = Exporter{}

// NewExporter builds a .docx exporter with the given stylemap + allocator.
func NewExporter(stylemap map[string]string, links HyperlinkAllocator) Exporter {
	return Exporter{Stylemap: stylemap, Links: links}
}

// Format returns the format id.
func (Exporter) Format() string { return "docx" }

// MIMEType returns the .docx container MIME type.
func (Exporter) MIMEType() string {
	return "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
}

// RenderBody renders the Document to OOXML paragraph markup.
func (e Exporter) RenderBody(doc docforge.Document) ([]byte, error) {
	return []byte(RenderDocumentToOOXML(doc, e.Stylemap, e.Links)), nil
}
