/**
 * @since Last modified: 2024/06/12 16:57:50
 * @function getBulletinsTpl
 * @description Determine whether the two nodes contain or equal relationships.
 * @param  {object[]} data - List data.
 * @param  {object} [global={}] - Global paramsters.
 * @returns {boolean} Return template string.
 * @see {@link https://codepen.io/axui/pen/bGzQOYP|demo @ codepen}
 * @example
 * ax.getBulletinsTpl([{cube,label,tips,...}...],{paddingless,multiline,hoverable});
 * <!--return template string-->
 */
'use strict';
import prefix from "../global/prefix";
const getBulletinsTpl = (global = {}) => {
    let grid = '';
    if (global.cols > 0) {
        grid = global.fence ? `${prefix}grid ${prefix}fence` : `${prefix}grid`;
    }
    return `
    <ul class="${prefix}reset ${grid}">
        {{for(let k of this){
            let check = k.checked && (!['checkboxes','radios'].includes('${global.type}') && !['checkbox','radio'].includes(k.type)) ?'checked':'',
                value = k.value?'value="+ k.value +"':'',
                selected=k.selected?'selected':'',
                active=k.active?'active':'',
                disabled=k.disabled?'disabled':''; 
        /}}
            <li>
                <div class="${prefix}bulletin" ${global.paddingless ? 'paddingless' : ''} ${global.hoverable ? 'hoverable' : ''}  ${global.multiline ? 'multiline' : ''}  {{selected}} {{active}} {{check}}  {{disabled}}>
                {{k.disk?'<span role="disk"><img src="'+k.disk+'"></span>':''}}
                {{k.cube?'<span role="cube"><img src="'+k.cube+'"></span>':''}}
                <div class="${prefix}bulletin-body">
                    {{if('${global.type}' ==='checkboxes' || k.type ==='checkbox'){/}}
                        <ax-checkbox name="{{k.name}}" {{k.checked?'check="ed"':''}} {{value}}>{{k.label}}</ax-checkbox>
                    {{}else if ('${global.type}' ==='radios' || k.type==='radio'){/}}
                        <ax-radio name="{{k.name}}" {{k.checked?'check="ed"':''}} {{value}}>{{k.label}}</ax-radio>
                    {{}else if(k.href){/}}
                        <a role="caption" href="{{k.href}}" {{k.target?'target="+ k.target +"':''}} {{k.rel?'rel="+ k.rel +"':''}}  {{value}}>{{k.label}}</a>
                    {{}else{/}}
                        <span role="caption" {{value}}>{{k.label}}</span>
                    {{}/}}
                </div>
                {{k.badge?'<ax-badge>'+k.badge+'</ax-badge>':''}}
                {{k.tips?'<i role="tips"><img src="'+k.tips+'"></i>':''}}
                {{k.arrow?'<i class="'+k.arrow+'" role="arrow"></i>':''}}
                </div>
                ${global.divisible ? '<hr>' : ''}
            </li>
        {{}/}}
    </ul>`;
};
export default getBulletinsTpl;
