<commit_before>import { DIV, BR } from 'sdi/components/elements';
import tr from 'sdi/locale';

import { context } from '../context';
import { actionChange, actionInfo } from '../action';
import { disclaimerLink, homegradeContactLink, beContactLink } from '../footer-infos';
import { summary as summaryPv } from '../summary/summary-pv';
import { summary as summaryThermal } from '../summary/summary-thermal';
import { getMaxPower, getSystem } from '../../queries/simulation';
import { navigateDetail } from '../../events/route';
import { getCapakey } from '../../queries/app';
import { buildingAdress, toggleWithInfo } from '../item-factory';
import { setSystem } from '../../events/simulation';


import { renderPDF } from '../summary/print';


const actionStepAdjust =
    () => DIV({
        className: 'action-step',
        onClick: () => getCapakey().map(navigateDetail),
    },
        DIV({ className: 'step-number' }, '1'),
        DIV({ className: 'step-label' },
            tr('solAdjustStr1'),
            BR({}),
            tr('solAdjustStr2')));

const actionStepPrint =
    () => DIV({
        className: 'action-step',
        onClick: () => renderPDF(),
    },
        DIV({ className: 'step-number' }, '2'),
        DIV({ className: 'step-label' }, tr('solPrintStr1'), BR({}), tr('solPrintStr2')));

const actionStepContact =
    () => DIV({ className: 'action-step' },
        DIV({ className: 'step-number' }, '3'),
        DIV({ className: 'step-label' },
            tr('solContactStr1'), BR({}), tr('solContactStr2')));



const toggleSystem = toggleWithInfo(
    () => getSystem() === 'photovoltaic',
    v => v ? setSystem('photovoltaic') : setSystem('thermal'));

const action =
    () =>
        DIV({ className: 'actions' },
            actionStepAdjust(),
            actionStepPrint(),
            actionStepContact(),
        );


const summary =
    () => {
        switch (getSystem()) {
            case 'photovoltaic': return summaryPv();
            case 'thermal': return summaryThermal();
        }
    };


const sidebar =
    () =>
        DIV({ className: 'sidebar' },
            summary(),
            toggleSystem('solPhotovoltaic', 'solSolarWaterHeater', 'solTogglePV', 'solToggleThermal'),
            DIV({ className: 'sidebar-action-wrapper' },
                actionChange(),
                actionInfo(),
            ));

const sidebarNoPreview =
    () =>
        DIV({ className: 'sidebar' },
            DIV({ className: 'sol-no-sol' },
                buildingAdress(),
                DIV({ className: 'sol-no-sol-msg' }, tr('solNoSol'))),
        );

const footerInfos =
    () =>
        DIV({ className: 'footer-infos' },
            homegradeContactLink(),
            beContactLink(),
            disclaimerLink());




const content =
    () =>
        DIV({ className: 'content' },
            context(),
            sidebar(),
            action(),
            footerInfos());

const contentNoPreview =
    () =>
        DIV({ className: 'content' },
            context(),
            sidebarNoPreview(),
            footerInfos());


const renderPreview =
    () =>
        DIV({ className: 'solar-main-and-right-sidebar' },
            content(),
        );


const renderNoPreview =
    () =>
        DIV({ className: 'solar-main-and-right-sidebar' },
            contentNoPreview(),
        );


const render =
    () => {
        if (getMaxPower() >= 1) {
            return renderPreview();
        }
        return renderNoPreview();
    };


export default render;<commit_msg>[solar] some factorisation<commit_after>import { DIV, BR } from 'sdi/components/elements';
import tr from 'sdi/locale';

import { context } from '../context';
import { actionChange, actionInfo } from '../action';
import { disclaimerLink, homegradeContactLink, beContactLink } from '../footer-infos';
import { summary as summaryPv } from '../summary/summary-pv';
import { summary as summaryThermal } from '../summary/summary-thermal';
import { getMaxPower, getSystem } from '../../queries/simulation';
import { navigateDetail } from '../../events/route';
import { getCapakey } from '../../queries/app';
import { buildingAdress, toggleWithInfo } from '../item-factory';
import { setSystem } from '../../events/simulation';


import { renderPDF } from '../summary/print';


const actionStepAdjust =
    () => DIV({
        className: 'action-step',
        onClick: () => getCapakey().map(navigateDetail),
    },
        DIV({ className: 'step-number' }, '1'),
        DIV({ className: 'step-label' },
            tr('solAdjustStr1'),
            BR({}),
            tr('solAdjustStr2')));

const actionStepPrint =
    () => DIV({
        className: 'action-step',
        onClick: () => renderPDF(),
    },
        DIV({ className: 'step-number' }, '2'),
        DIV({ className: 'step-label' }, tr('solPrintStr1'), BR({}), tr('solPrintStr2')));

const actionStepContact =
    () => DIV({ className: 'action-step' },
        DIV({ className: 'step-number' }, '3'),
        DIV({ className: 'step-label' },
            tr('solContactStr1'), BR({}), tr('solContactStr2')));



const toggleSystem = toggleWithInfo(
    () => getSystem() === 'photovoltaic',
    v => v ? setSystem('photovoltaic') : setSystem('thermal'));

const action =
    () =>
        DIV({ className: 'actions' },
            actionStepAdjust(),
            actionStepPrint(),
            actionStepContact(),
        );


const summary =
    () => {
        switch (getSystem()) {
            case 'photovoltaic': return summaryPv();
            case 'thermal': return summaryThermal();
        }
    };


const sidebar =
    () =>
        DIV({ className: 'sidebar' },
            summary(),
            toggleSystem('solPhotovoltaic', 'solSolarWaterHeater', 'solTogglePV', 'solToggleThermal'),
            DIV({ className: 'sidebar-action-wrapper' },
                actionChange(),
                actionInfo(),
            ));

const sidebarNoPreview =
    () =>
        DIV({ className: 'sidebar' },
            DIV({ className: 'sol-no-sol' },
                buildingAdress(),
                DIV({ className: 'sol-no-sol-msg' }, tr('solNoSol'))),
        );

const footerInfos =
    () =>
        DIV({ className: 'footer-infos' },
            homegradeContactLink(),
            beContactLink(),
            disclaimerLink());




const content =
    () =>
        DIV({ className: 'content' },
            context(),
            sidebar(),
            action(),
            footerInfos());

const contentNoPreview =
    () =>
        DIV({ className: 'content' },
            context(),
            sidebarNoPreview(),
            footerInfos());



            
const render =
    () => DIV({ className: 'solar-main-and-right-sidebar' },
        getMaxPower() >= 1 ?
            content() :
            contentNoPreview(),
    );



export default render;
{'fraction_non_alphanumeric': 0.17071044602644195, 'fraction_numerical': 0.002905709719599012, 'mean_word_length': 2.1899907321594068, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 37, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2255790', 'n_tokens_mistral': 1981, 'n_tokens_neox': 1868, 'n_words': 423}