import { titleField, slugField, excerptField, richContentField, featuredImageField, tagsField, publishedDateField, authorField, quoteField, ctaField, seoFields, locationFields, geoFields, priceFields, relatedDocsField, } from '../fields/presets.js';
function mergeCollection(defaults, overrides) {
    if (!overrides)
        return defaults;
    const { extraFields, fields, admin, seo, labels, ...rest } = overrides;
    const merged = {
        ...defaults,
        ...rest,
        labels: labels ?? defaults.labels,
        fields: { ...defaults.fields, ...extraFields, ...fields },
        admin: { ...defaults.admin, ...admin },
        seo: { ...defaults.seo, ...seo },
    };
    return merged;
}
// ─── Blog Post ─────────────────────────────────────────────────────────────
/** Long-form blog post collection. Renders as `/blog/:slug`, Schema.org BlogPosting. */
export function blogPostCollection(overrides) {
    const defaults = {
        slug: 'posts',
        labels: { singular: 'Post', plural: 'Posts' },
        urlPrefix: 'blog',
        type: 'post',
        timestamps: true,
        softDelete: true,
        versions: { maxPerDoc: 20 },
        defaultSort: '-publishedDate',
        seo: {
            defaultSchemaType: 'BlogPosting',
            sitemapPriority: 0.7,
            sitemapChangeFreq: 'weekly',
            archivePath: '/blog',
        },
        admin: {
            useAsTitle: 'title',
            defaultColumns: ['title', 'authorName', 'publishedDate', 'status'],
            group: 'Content',
            description: 'Long-form articles. Suggested template: blog-post.',
            icon: 'pencil',
        },
        fields: {
            ...titleField({ required: true }),
            ...slugField(),
            ...excerptField({ label: 'Excerpt', maxLength: 280 }),
            ...featuredImageField(),
            ...authorField(),
            ...publishedDateField(),
            ...tagsField(),
            ...richContentField({ name: 'body', label: 'Body', required: true }),
            // Self-reference: editors can hand-pick related posts for the "you
            // might also like" rail. Resolved depth-1 via `?populate=relatedPosts`.
            ...relatedDocsField('relatedPosts', {
                relationTo: 'posts',
                label: 'Related posts',
                description: 'Hand-picked recommendations shown at the end of this post.',
            }),
            ...seoFields(),
        },
    };
    return mergeCollection(defaults, overrides);
}
// ─── Case Study ────────────────────────────────────────────────────────────
/** Customer / project case study collection. Renders as `/case-studies/:slug`. */
export function caseStudyCollection(overrides) {
    const defaults = {
        slug: 'case-studies',
        labels: { singular: 'Case study', plural: 'Case studies' },
        urlPrefix: 'case-studies',
        type: 'post',
        timestamps: true,
        softDelete: true,
        versions: { maxPerDoc: 10 },
        defaultSort: '-publishedDate',
        seo: {
            defaultSchemaType: 'Article',
            sitemapPriority: 0.7,
            sitemapChangeFreq: 'monthly',
            archivePath: '/case-studies',
        },
        admin: {
            useAsTitle: 'title',
            defaultColumns: ['title', 'clientName', 'industry', 'publishedDate', 'status'],
            group: 'Content',
            description: 'Customer success stories. Suggested template: case-study.',
            icon: 'badge-check',
        },
        fields: {
            ...titleField({ label: 'Case study title' }),
            ...slugField(),
            clientName: { type: 'text', label: 'Client name', required: true, maxLength: 120 },
            industry: { type: 'text', label: 'Industry', maxLength: 80 },
            ...excerptField({ label: 'Summary', maxLength: 320 }),
            ...featuredImageField({ label: 'Hero image' }),
            challenge: {
                type: 'richText',
                label: 'Challenge',
                admin: { description: 'The business or technical problem the client faced.' },
                features: ['bold', 'italic', 'link', 'list'],
            },
            solution: {
                type: 'richText',
                label: 'Solution',
                admin: { description: 'How the work addressed the challenge.' },
                features: ['bold', 'italic', 'link', 'list', 'image'],
            },
            results: {
                type: 'richText',
                label: 'Results',
                admin: { description: 'Outcomes and measurable wins.' },
                features: ['bold', 'italic', 'link', 'list'],
            },
            keyMetrics: {
                type: 'array',
                label: 'Key metrics',
                maxRows: 6,
                fields: {
                    value: { type: 'text', label: 'Value', required: true, maxLength: 32 },
                    label: { type: 'text', label: 'Label', required: true, maxLength: 80 },
                },
            },
            ...quoteField({ label: 'Featured quote' }),
            quoteAuthor: { type: 'text', label: 'Quote attribution', maxLength: 120 },
            ...publishedDateField(),
            ...ctaField({ name: 'cta', label: 'CTA' }),
            ...tagsField({ label: 'Services involved' }),
            // Cross-doc reference: which service(s) the case study showcases.
            // Lets the `/services/:slug` page render a "Recent customers" rail
            // by reverse-querying case studies that mention it. Resolved via
            // `?populate=services` on this collection's reads.
            ...relatedDocsField('services', {
                relationTo: 'services',
                label: 'Services featured',
                description: 'Service pages this case study demonstrates.',
            }),
            ...seoFields(),
        },
    };
    return mergeCollection(defaults, overrides);
}
// ─── Portfolio ─────────────────────────────────────────────────────────────
/** Portfolio / project gallery collection. Renders as `/work/:slug`. */
export function portfolioCollection(overrides) {
    const defaults = {
        slug: 'portfolio',
        labels: { singular: 'Project', plural: 'Projects' },
        urlPrefix: 'work',
        type: 'post',
        timestamps: true,
        softDelete: true,
        versions: { maxPerDoc: 10 },
        defaultSort: '-completedDate',
        seo: {
            defaultSchemaType: 'CreativeWork',
            sitemapPriority: 0.6,
            sitemapChangeFreq: 'monthly',
            archivePath: '/work',
        },
        admin: {
            useAsTitle: 'title',
            defaultColumns: ['title', 'clientName', 'category', 'completedDate', 'status'],
            group: 'Content',
            description: 'Project showcase. Suggested template: portfolio.',
            icon: 'image',
        },
        fields: {
            ...titleField({ label: 'Project title' }),
            ...slugField(),
            clientName: { type: 'text', label: 'Client', maxLength: 120 },
            category: {
                type: 'select',
                label: 'Category',
                options: [
                    { label: 'Web', value: 'web' },
                    { label: 'Mobile', value: 'mobile' },
                    { label: 'Branding', value: 'branding' },
                    { label: 'Print', value: 'print' },
                    { label: 'Photography', value: 'photography' },
                    { label: 'Other', value: 'other' },
                ],
            },
            ...excerptField({ label: 'Project summary' }),
            ...featuredImageField({ label: 'Cover image' }),
            gallery: {
                type: 'array',
                label: 'Gallery',
                fields: {
                    image: { type: 'media', label: 'Image', required: true, accept: ['image/*'] },
                    caption: { type: 'text', label: 'Caption', maxLength: 200 },
                },
            },
            description: {
                ...richContentField({ name: 'description', label: 'Description' }).description,
            },
            role: { type: 'text', label: 'Your role', maxLength: 120 },
            stack: {
                type: 'array',
                label: 'Tech / tools',
                fields: { item: { type: 'text', label: 'Item', required: true, maxLength: 60 } },
            },
            projectUrl: {
                type: 'url',
                label: 'Live project URL',
                admin: { description: 'Public URL of the live project, if available.' },
            },
            completedDate: { type: 'date', label: 'Completed', includeTime: false },
            ...tagsField(),
            ...seoFields(),
        },
    };
    return mergeCollection(defaults, overrides);
}
// ─── Service ───────────────────────────────────────────────────────────────
/** Service offering collection. Renders as `/services/:slug`, Schema.org Service. */
export function serviceCollection(overrides) {
    const defaults = {
        slug: 'services',
        labels: { singular: 'Service', plural: 'Services' },
        urlPrefix: 'services',
        type: 'page',
        timestamps: true,
        softDelete: true,
        versions: { maxPerDoc: 10 },
        defaultSort: 'order',
        seo: {
            defaultSchemaType: 'Service',
            sitemapPriority: 0.8,
            sitemapChangeFreq: 'monthly',
        },
        admin: {
            useAsTitle: 'title',
            defaultColumns: ['title', 'category', 'order', 'status'],
            group: 'Content',
            description: 'Services offered. Suggested template: service.',
            icon: 'wrench',
        },
        fields: {
            ...titleField({ label: 'Service name' }),
            ...slugField(),
            category: { type: 'text', label: 'Category', maxLength: 80 },
            order: {
                type: 'number',
                label: 'Display order',
                admin: { description: 'Lower values sort first in service lists.' },
                defaultValue: 100,
            },
            icon: {
                type: 'text',
                label: 'Icon',
                admin: { description: 'Lucide / Heroicons icon name shown next to the service.' },
                maxLength: 40,
            },
            ...excerptField({ label: 'Short description', maxLength: 200 }),
            ...featuredImageField({ label: 'Service image' }),
            ...richContentField({ name: 'description', label: 'Full description' }),
            benefits: {
                type: 'array',
                label: 'Benefits',
                fields: {
                    title: { type: 'text', label: 'Benefit', required: true, maxLength: 120 },
                    description: { type: 'text', label: 'Description', maxLength: 280 },
                },
            },
            ...priceFields(),
            pricingNote: {
                type: 'text',
                label: 'Pricing note',
                maxLength: 200,
                admin: { description: 'e.g. "Starting at", "Per visit", "Custom quote".' },
            },
            ...ctaField({ name: 'cta', label: 'CTA' }),
            ...seoFields(),
        },
    };
    return mergeCollection(defaults, overrides);
}
// ─── Location ──────────────────────────────────────────────────────────────
/** Physical location / service-area collection. Schema.org LocalBusiness. */
export function locationCollection(overrides) {
    const defaults = {
        slug: 'locations',
        labels: { singular: 'Location', plural: 'Locations' },
        urlPrefix: 'locations',
        type: 'page',
        timestamps: true,
        softDelete: true,
        versions: { maxPerDoc: 10 },
        defaultSort: 'title',
        seo: {
            defaultSchemaType: 'LocalBusiness',
            sitemapPriority: 0.9,
            sitemapChangeFreq: 'weekly',
        },
        admin: {
            useAsTitle: 'title',
            defaultColumns: ['title', 'phone', 'serviceArea', 'status'],
            group: 'Content',
            description: 'Service areas / physical locations. Suggested template: location.',
            icon: 'map-pin',
        },
        fields: {
            ...titleField({ label: 'Location name' }),
            ...slugField(),
            serviceArea: { type: 'text', label: 'Service area', maxLength: 120 },
            ...excerptField({ label: 'Short description', maxLength: 200 }),
            ...featuredImageField({ label: 'Location photo' }),
            ...locationFields(),
            ...geoFields(),
            ...richContentField({ name: 'description', label: 'Description' }),
            servicesOffered: {
                type: 'relationship',
                label: 'Services offered',
                relationTo: 'services',
                hasMany: true,
                admin: { description: 'Pick which services are available at this location.' },
            },
            ...ctaField({ name: 'cta', label: 'Booking CTA' }),
            ...seoFields(),
        },
    };
    return mergeCollection(defaults, overrides);
}
// ─── Team member ───────────────────────────────────────────────────────────
/** Team member / author profile collection. Schema.org Person. */
export function teamMemberCollection(overrides) {
    const defaults = {
        slug: 'team',
        labels: { singular: 'Team member', plural: 'Team' },
        urlPrefix: 'team',
        type: 'page',
        timestamps: true,
        softDelete: true,
        versions: { maxPerDoc: 5 },
        defaultSort: 'order',
        seo: {
            defaultSchemaType: 'Person',
            sitemapPriority: 0.5,
            sitemapChangeFreq: 'monthly',
        },
        admin: {
            useAsTitle: 'title',
            defaultColumns: ['title', 'role', 'order', 'status'],
            group: 'Content',
            description: 'Team / author profiles. Suggested template: team-member.',
            icon: 'user',
        },
        fields: {
            ...titleField({ label: 'Full name' }),
            ...slugField(),
            role: { type: 'text', label: 'Role / title', required: true, maxLength: 120 },
            order: {
                type: 'number',
                label: 'Display order',
                defaultValue: 100,
                admin: { description: 'Lower values sort first on team pages.' },
            },
            photo: {
                type: 'media',
                label: 'Photo',
                accept: ['image/jpeg', 'image/png', 'image/webp'],
            },
            ...excerptField({ label: 'Short bio', maxLength: 200 }),
            bio: { ...richContentField({ name: 'bio', label: 'Full bio' }).bio },
            email: { type: 'email', label: 'Email' },
            phone: { type: 'text', label: 'Phone', maxLength: 40 },
            socialLinks: {
                type: 'array',
                label: 'Social links',
                fields: {
                    platform: {
                        type: 'select',
                        label: 'Platform',
                        options: [
                            { label: 'LinkedIn', value: 'linkedin' },
                            { label: 'X / Twitter', value: 'twitter' },
                            { label: 'GitHub', value: 'github' },
                            { label: 'Instagram', value: 'instagram' },
                            { label: 'Facebook', value: 'facebook' },
                            { label: 'Website', value: 'website' },
                        ],
                    },
                    url: { type: 'url', label: 'URL', required: true },
                },
            },
            ...seoFields(),
        },
    };
    return mergeCollection(defaults, overrides);
}
// ─── FAQ ────────────────────────────────────────────────────────────────────
/** Frequently asked question entries — composed into FAQPage schema. */
export function faqCollection(overrides) {
    const defaults = {
        slug: 'faqs',
        labels: { singular: 'FAQ', plural: 'FAQs' },
        urlPrefix: 'faqs',
        type: 'page',
        timestamps: true,
        softDelete: true,
        defaultSort: 'order',
        seo: {
            defaultSchemaType: 'FAQPage',
            sitemapPriority: 0.4,
            sitemapChangeFreq: 'monthly',
            excludeFromSitemap: true,
        },
        admin: {
            useAsTitle: 'question',
            defaultColumns: ['question', 'category', 'order', 'status'],
            group: 'Content',
            description: 'Frequently asked questions. Grouped by category.',
            icon: 'help-circle',
        },
        fields: {
            question: { type: 'text', label: 'Question', required: true, maxLength: 280 },
            ...slugField({ from: 'question' }),
            category: { type: 'text', label: 'Category', maxLength: 80 },
            order: { type: 'number', label: 'Order', defaultValue: 100 },
            answer: {
                type: 'richText',
                label: 'Answer',
                required: true,
                features: ['bold', 'italic', 'link', 'list'],
            },
        },
    };
    return mergeCollection(defaults, overrides);
}
// ─── Testimonial ───────────────────────────────────────────────────────────
/** Customer testimonial / review collection. Schema.org Review. */
export function testimonialCollection(overrides) {
    const defaults = {
        slug: 'testimonials',
        labels: { singular: 'Testimonial', plural: 'Testimonials' },
        urlPrefix: 'testimonials',
        type: 'page',
        timestamps: true,
        softDelete: true,
        defaultSort: '-publishedDate',
        seo: {
            defaultSchemaType: 'Review',
            sitemapPriority: 0.3,
            sitemapChangeFreq: 'monthly',
            excludeFromSitemap: true,
        },
        admin: {
            useAsTitle: 'authorName',
            defaultColumns: ['authorName', 'rating', 'publishedDate', 'status'],
            group: 'Content',
            description: 'Customer testimonials and reviews.',
            icon: 'star',
        },
        fields: {
            ...quoteField({ name: 'quote', label: 'Testimonial' }),
            authorName: { type: 'text', label: 'Author name', required: true, maxLength: 120 },
            authorRole: { type: 'text', label: 'Author role / company', maxLength: 200 },
            photo: { type: 'media', label: 'Author photo', accept: ['image/*'] },
            rating: {
                type: 'number',
                label: 'Rating (1–5)',
                min: 1,
                max: 5,
                step: 1,
                defaultValue: 5,
            },
            ...publishedDateField(),
            featured: {
                type: 'boolean',
                label: 'Featured',
                admin: { description: 'Pin to the top of testimonial lists.' },
            },
        },
    };
    return mergeCollection(defaults, overrides);
}
// ─── Template suggestion lookup ────────────────────────────────────────────
/**
 * Maps a collection slug → the suggested built-in page-builder template ID
 * (registered in `@actuate-media/cms-core` `BUILT_IN_TEMPLATES`).
 *
 * The admin "Create new" picker can call this to suggest a starter template
 * matching the post type without forcing users to choose blindly. Returns
 * `null` when no template is appropriate (e.g. testimonials, FAQs — these are
 * rendered as fragments, not standalone pages).
 */
export function getTemplatesForCollection(collectionSlug) {
    const slug = collectionSlug.toLowerCase();
    // Aliases handle the common variants we see in the wild.
    const map = {
        posts: { primary: 'blog-post' },
        post: { primary: 'blog-post' },
        blog: { primary: 'blog-post' },
        articles: { primary: 'blog-post' },
        'blog-posts': { primary: 'blog-post' },
        'case-studies': { primary: 'case-study', alternates: ['blog-post'] },
        'case-study': { primary: 'case-study', alternates: ['blog-post'] },
        portfolio: { primary: 'portfolio', alternates: ['about'] },
        portfolios: { primary: 'portfolio', alternates: ['about'] },
        work: { primary: 'portfolio', alternates: ['about'] },
        projects: { primary: 'portfolio', alternates: ['about'] },
        services: { primary: 'service', alternates: ['landing'] },
        service: { primary: 'service', alternates: ['landing'] },
        locations: { primary: 'location', alternates: ['contact'] },
        location: { primary: 'location', alternates: ['contact'] },
        team: { primary: 'team-member', alternates: ['about'] },
        'team-members': { primary: 'team-member', alternates: ['about'] },
        pages: { primary: 'blank', alternates: ['landing', 'about', 'contact'] },
        page: { primary: 'blank', alternates: ['landing', 'about', 'contact'] },
    };
    const entry = map[slug];
    if (entry)
        return { primary: entry.primary, alternates: entry.alternates ?? [] };
    // Soft match — `blog-news` → blog-post, etc.
    for (const [key, value] of Object.entries(map)) {
        if (slug.includes(key) || key.includes(slug)) {
            return { primary: value.primary, alternates: value.alternates ?? [] };
        }
    }
    return { primary: null, alternates: [] };
}
//# sourceMappingURL=presets.js.map