<?php

namespace Give\Campaigns\Actions;

/**
 * @since 4.0.0
 */
class CreateDefaultLayoutForCampaignPage
{
    /**
     * @since 4.0.0
     */
    public function getBlocks(): string
    {
        return '<!-- wp:columns {"style":{"spacing":{"padding":{"top":"0","bottom":"0"}}}} -->
<div class="wp-block-columns" style="padding-top:0;padding-bottom:0"><!-- wp:column {"verticalAlignment":"stretch","width":"60%"} -->
<div class="wp-block-column is-vertically-aligned-stretch" style="flex-basis:60%"><!-- wp:post-featured-image {"aspectRatio":"16/9","width":"100%","height":"100%","style":{"border":{"radius":"8px"}}} /--></div>
<!-- /wp:column -->

<!-- wp:column {"verticalAlignment":"stretch"} -->
<div class="wp-block-column is-vertically-aligned-stretch"><!-- wp:group {"style":{"dimensions":{"minHeight":"100%"}},"layout":{"type":"flex","orientation":"vertical","verticalAlignment":"space-between","justifyContent":"stretch"}} -->
<div class="wp-block-group" style="min-height:100%"><!-- wp:givewp/campaign-goal {"campaignId":%campaignId%} /-->

<!-- wp:group {"style":{"layout":{"selfStretch":"fill","flexSize":null}},"layout":{"type":"flex","orientation":"vertical"}} -->
<div class="wp-block-group"><!-- wp:givewp/campaign-stats-block {"campaignId":%campaignId%,"style":{"layout":{"selfStretch":"fit","flexSize":null}}} /-->

<!-- wp:givewp/campaign-stats-block {"campaignId":%campaignId%,"statistic":"average-donation","style":{"layout":{"selfStretch":"fit","flexSize":null}}} /--></div>
<!-- /wp:group -->

<!-- wp:givewp/campaign-donate-button {"campaignId":%campaignId%} /--></div>
<!-- /wp:group --></div>
<!-- /wp:column --></div>
<!-- /wp:columns -->

<!-- wp:paragraph -->
<p>%description%</p>
<!-- /wp:paragraph -->

<!-- wp:givewp/campaign-donations {"campaignId":%campaignId%} /-->

<!-- wp:givewp/campaign-donors {"campaignId":%campaignId%} /-->
';
    }

    /**
     * @since 4.0.0
     */
    public function __invoke(int $campaignId, string $shortDescription): string
    {
        return str_replace(
            ['%campaignId%', '%description%'],
            [$campaignId, $shortDescription],
            $this->getBlocks()
        );
    }
}
