'use strict';const dotclear={msg:{},};dotclear.DOMready=(fn)=>{document.addEventListener('DOMContentLoaded',()=>{fn();});};dotclear.ready=(fn)=>{if(document.readyState==='complete'){fn();}else{globalThis.addEventListener('load',fn);}};dotclear.storeLocalData=(id,value=null)=>{localStorage.setItem(id,JSON.stringify(value));};dotclear.dropLocalData=(id)=>{localStorage.removeItem(id);};dotclear.readLocalData=(id)=>{const info=localStorage.getItem(id);if(info!==null){return JSON.parse(info);}
return info;};dotclear.getData=(id,clear=true,remove=true)=>{let data={};const element=document.getElementById(`${id}-data`);if(element){try{data=JSON.parse(element.textContent||'');if(clear&&remove){element.remove();}else if(clear){element.innerHTML='';}}catch{}}
return data;};dotclear.isObject=(item)=>item&&typeof item==='object'&&!Array.isArray(item);dotclear.isEmptyObject=(item)=>dotclear.isObject(item)&&Object.keys(item).length===0;dotclear.mergeDeep=(target,...sources)=>{if(!sources.length)return target;const source=sources.shift();if(dotclear.isObject(target)&&dotclear.isObject(source)){for(const key in source){if(dotclear.isObject(source[key])){if(!target[key])
Object.assign(target,{[key]:{},});dotclear.mergeDeep(target[key],source[key]);}else{Object.assign(target,{[key]:source[key],});}}}
return dotclear.mergeDeep(target,...sources);};dotclear.trimHtml=(html,options={})=>{const limit=options.limit||100;const preserveTags=options.preserveTags===undefined?true:options.preserveTags;const wordBreak=options.wordBreak===undefined?false:options.wordBreak;const suffix=options.suffix||'...';const moreLink=options.moreLink||'';const arr=html.replaceAll('<','\n<').replaceAll('>','>\n').replaceAll('\n\n','\n').replaceAll(/^\n/g,'').replaceAll(/\n$/g,'').split('\n');let sum=0;let row;let cut;let add;let tagMatch;let tagName;const tagStack=[];let more=false;let rowCut;for(let i=0;i<arr.length;i++){row=arr[i];rowCut=row.replaceAll(/ +/g,' ');if(!row.length){continue;}
if(!row.startsWith('<')){if(sum>=limit){row='';}else if(sum+rowCut.length>=limit){cut=limit-sum;if(row[cut-1]===' '){while(cut){cut-=1;if(row[cut-1]!==' '){break;}}}else{add=row.substring(cut).split('').indexOf(' ');if(!wordBreak){if(add===-1){cut=row.length;}else{cut+=add;}}}
row=row.substring(0,cut)+suffix;if(moreLink){row+=`<a href="${moreLink}" style="display:inline">»</a>`;}
sum=limit;more=true;}else{sum+=rowCut.length;}}else if(!preserveTags){row='';}else if(sum>=limit){tagMatch=new RegExp(/[a-zA-Z]+/).exec(row);tagName=tagMatch?tagMatch[0]:'';if(tagName){if(row.startsWith('</')){while(tagStack.at(-1)!==tagName&&tagStack.length){tagStack.pop();}
if(tagStack.length){row='';}
tagStack.pop();}else{tagStack.push(tagName);row='';}}else{row='';}}
arr[i]=row;}
return{html:arr.join('\n').replaceAll('\n',''),more,};};