const scsUtils=(function (){
'use strict';
const __=(key, data={})=> {
let translation=(typeof scsTranslations!=='undefined'&&scsTranslations[key])
? scsTranslations[key]
: key;
if(data&&typeof data==='object'){
Object.keys(data).forEach(varName=> {
const regex=new RegExp(`{${varName}}`, 'g');
translation=translation.replace(regex, data[varName]);
});
}
return translation;
};
const ICON_PATHS={
'chat-dots': '<path d="M5 8a1 1 0 1 1-2 0 1 1 0 0 1 2 0zm4 0a1 1 0 1 1-2 0 1 1 0 0 1 2 0zm3 1a1 1 0 1 0 0-2 1 1 0 0 0 0 2z"/><path d="m2.165 15.803.02-.004c1.83-.363 2.948-.842 3.468-1.105A9.06 9.06 0 0 0 8 15c4.418 0 8-3.134 8-7s-3.582-7-8-7-8 3.134-8 7c0 1.76.743 3.37 1.97 4.6a10.437 10.437 0 0 1-.524 2.318l-.003.011a10.722 10.722 0 0 1-.244.637c-.079.186.074.394.273.362a21.673 21.673 0 0 0 .693-.125zm.8-3.108a1 1 0 0 0-.287-.801C1.618 10.83 1 9.468 1 8c0-3.192 3.004-6 7-6s7 2.808 7 6c0 3.193-3.004 6-7 6a8.06 8.06 0 0 1-2.088-.272 1 1 0 0 0-.711.074c-.387.196-1.24.57-2.634.893a10.97 10.97 0 0 0 .398-2z"/>',
'chat-left-dots': '<path d="M14 1a1 1 0 0 1 1 1v8a1 1 0 0 1-1 1H4.414A2 2 0 0 0 3 11.586l-2 2V2a1 1 0 0 1 1-1h12zM2 0a2 2 0 0 0-2 2v12.793a.5.5 0 0 0 .854.353l2.853-2.853A1 1 0 0 1 4.414 12H14a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2H2z"/><path d="M5 6a1 1 0 1 1-2 0 1 1 0 0 1 2 0zm4 0a1 1 0 1 1-2 0 1 1 0 0 1 2 0zm4 0a1 1 0 1 1-2 0 1 1 0 0 1 2 0z"/>',
'chat-square-dots': '<path d="M14 1a1 1 0 0 1 1 1v8a1 1 0 0 1-1 1h-2.5a2 2 0 0 0-1.6.8L8 14.333 6.1 11.8a2 2 0 0 0-1.6-.8H2a1 1 0 0 1-1-1V2a1 1 0 0 1 1-1h12zM2 0a2 2 0 0 0-2 2v8a2 2 0 0 0 2 2h2.5a1 1 0 0 1 .8.4l1.9 2.533a1 1 0 0 0 1.6 0l1.9-2.533a1 1 0 0 1 .8-.4H14a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2H2z"/><path d="M5 6a1 1 0 1 1-2 0 1 1 0 0 1 2 0zm4 0a1 1 0 1 1-2 0 1 1 0 0 1 2 0zm4 0a1 1 0 1 1-2 0 1 1 0 0 1 2 0z"/>',
'chat-text': '<path d="M2.678 11.894a1 1 0 0 1 .287.801 10.97 10.97 0 0 1-.398 2c1.395-.323 2.247-.697 2.634-.893a1 1 0 0 1 .71-.074A8.06 8.06 0 0 0 8 14c3.996 0 7-2.807 7-6 0-3.192-3.004-6-7-6S1 4.808 1 8c0 1.468.617 2.83 1.678 3.894zm-.493 3.905a21.682 21.682 0 0 1-.713.129c-.2.032-.352-.176-.273-.362a9.68 9.68 0 0 0 .244-.637l.003-.01c.248-.72.45-1.548.524-2.319C.743 11.37 0 9.76 0 8c0-3.866 3.582-7 8-7s8 3.134 8 7-3.582 7-8 7a9.06 9.06 0 0 1-2.347-.306c-.52.263-1.639.742-3.468 1.105z"/><path d="M4 5.5a.5.5 0 0 1 .5-.5h7a.5.5 0 0 1 0 1h-7a.5.5 0 0 1-.5-.5zM4 8a.5.5 0 0 1 .5-.5h7a.5.5 0 0 1 0 1h-7A.5.5 0 0 1 4 8zm0 2.5a.5.5 0 0 1 .5-.5h4a.5.5 0 0 1 0 1h-4a.5.5 0 0 1-.5-.5z"/>',
'question-circle': '<path d="M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14zm0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16z"/><path d="M5.255 5.786a.237.237 0 0 0 .241.247h.825c.138 0 .248-.113.266-.25.09-.656.54-1.134 1.342-1.134.686 0 1.314.343 1.314 1.168 0 .635-.374.927-.965 1.371-.673.489-1.206 1.06-1.168 1.987l.003.217a.25.25 0 0 0 .25.246h.811a.25.25 0 0 0 .25-.25v-.105c0-.718.273-.927 1.01-1.486.609-.463 1.244-.977 1.244-2.056 0-1.511-1.276-2.241-2.673-2.241-1.267 0-2.655.59-2.75 2.286zm1.557 5.763c0 .533.425.927 1.01.927.609 0 1.028-.394 1.028-.927 0-.552-.42-.94-1.029-.94-.584 0-1.009.388-1.009.94z"/>',
'headset': '<path d="M8 1a5 5 0 0 0-5 5v1h1a1 1 0 0 1 1 1v3a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V6a6 6 0 1 1 12 0v6a2.5 2.5 0 0 1-2.5 2.5H9.366a1 1 0 0 1-.866.5h-1a1 1 0 1 1 0-2h1a1 1 0 0 1 .866.5H11.5A1.5 1.5 0 0 0 13 12h-1a1 1 0 0 1-1-1V8a1 1 0 0 1 1-1h1V6a5 5 0 0 0-5-5z"/>',
'person-circle': '<path d="M11 6a3 3 0 1 1-6 0 3 3 0 0 1 6 0z"/><path fill-rule="evenodd" d="M0 8a8 8 0 1 1 16 0A8 8 0 0 1 0 8zm8-7a7 7 0 0 0-5.468 11.37C3.242 11.226 4.805 10 8 10s4.757 1.225 5.468 2.37A7 7 0 0 0 8 1z"/>',
'info-circle': '<path d="M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14zm0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16z"/><path d="m8.93 6.588-2.29.287-.082.38.45.083c.294.07.352.176.288.469l-.738 3.468c-.194.897.105 1.319.808 1.319.545 0 1.178-.252 1.465-.598l.088-.416c-.2.176-.492.246-.686.246-.275 0-.375-.193-.304-.533L8.93 6.588zM9 4.5a1 1 0 1 1-2 0 1 1 0 0 1 2 0z"/>',
'send-fill': '<path d="M15.964.686a.5.5 0 0 0-.65-.65L.767 5.855H.766l-.452.18a.5.5 0 0 0-.082.887l.41.26.001.002 4.995 3.178 3.178 4.995.002.002.26.41a.5.5 0 0 0 .886-.083l6-15Zm-1.833 1.89L6.637 10.07l-.215-.338a.5.5 0 0 0-.154-.154l-.338-.215 7.494-7.494 1.178-.471-.47 1.178Z"/>',
'send': '<path d="M15.854.146a.5.5 0 0 1 .11.54l-5.819 14.547a.75.75 0 0 1-1.329.124l-3.178-4.995L.643 7.184a.75.75 0 0 1 .124-1.33L15.314.037a.5.5 0 0 1 .54.11ZM6.636 10.07l2.761 4.338L14.13 2.576 6.636 10.07Zm6.787-8.201L1.591 6.602l4.339 2.76 7.494-7.493Z"/>',
'arrow-right-circle': '<path fill-rule="evenodd" d="M1 8a7 7 0 1 0 14 0A7 7 0 0 0 1 8zm15 0A8 8 0 1 1 0 8a8 8 0 0 1 16 0zM4.5 7.5a.5.5 0 0 0 0 1h5.793l-2.147 2.146a.5.5 0 0 0 .708.708l3-3a.5.5 0 0 0 0-.708l-3-3a.5.5 0 1 0-.708.708L10.293 7.5H4.5z"/>',
'arrow-right-circle-fill': '<path d="M8 0a8 8 0 1 1 0 16A8 8 0 0 1 8 0zM4.5 7.5a.5.5 0 0 0 0 1h5.793l-2.147 2.146a.5.5 0 0 0 .708.708l3-3a.5.5 0 0 0 0-.708l-3-3a.5.5 0 1 0-.708.708L10.293 7.5H4.5z"/>',
'arrow-up-circle': '<path fill-rule="evenodd" d="M1 8a7 7 0 1 0 14 0A7 7 0 0 0 1 8zm15 0A8 8 0 1 1 0 8a8 8 0 0 1 16 0zm-7.5 3.5a.5.5 0 0 1-1 0V5.707L5.354 7.854a.5.5 0 1 1-.708-.708l3-3a.5.5 0 0 1 .708 0l3 3a.5.5 0 0 1-.708.708L8.5 5.707V11.5z"/>',
'chevron-right': '<path fill-rule="evenodd" d="M4.646 1.646a.5.5 0 0 1 .708 0l6 6a.5.5 0 0 1 0 .708l-6 6a.5.5 0 0 1-.708-.708L10.293 8 4.646 2.354a.5.5 0 0 1 0-.708z"/>',
'play-circle': '<path d="M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14zm0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16z"/><path d="M6.271 5.055a.5.5 0 0 1 .52.038l3.5 2.5a.5.5 0 0 1 0 .814l-3.5 2.5A.5.5 0 0 1 6 10.5v-5a.5.5 0 0 1 .271-.445z"/>',
'play-circle-fill': '<path d="M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0zM6.79 5.093A.5.5 0 0 0 6 5.5v5a.5.5 0 0 0 .79.407l3.5-2.5a.5.5 0 0 0 0-.814l-3.5-2.5z"/>'
};
function sanitizeInput(str){
if(!str) return '';
return str.replace(/&/g, '&amp;')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/"/g, '&quot;')
.replace(/'/g, '&#39;');
}
function containsHtmlTags(str){
return /<[a-z/][\s\S]*?>/i.test(str.trim());
}
function parseMarkdown(text){
if(!text) return '';
let html=text;
html=html.replace(/^# (.*?)$/gm, '<h1>$1</h1>');
html=html.replace(/^## (.*?)$/gm, '<h2>$1</h2>');
html=html.replace(/^### (.*?)$/gm, '<h3>$1</h3>');
html=html.replace(/^#### (.*?)$/gm, '<h4>$1</h4>');
html=html.replace(/\[([^\]]+)\]\((https?:\/\/[^\s\)]+)\)/g, function (match, label, url){
const mode=(typeof scsConfig!=='undefined') ? scsConfig.linkMode||'new':'new';
const target=mode==='same' ? '_self':'_blank';
const extraClass=mode==='button' ? ' class="scs-link-button"':'';
const linkText=mode==='button' ? scsConfig.linkButtonLabel:label;
return '<a href="' + url + '" target="' + target + '"' + extraClass + ' rel="noopener noreferrer">' + linkText + '</a>';
});
html=html.replace(/\*\*(.*?)\*\*/g, '<strong>$1</strong>');
html=html.replace(/^\s*[\*\-]\s+(.*?)$/gm, '<li>$1</li>');
html=html.replace(/(<li>.*?<\/li>)/gs, '<ul>$1</ul>');
html=html.replace(/<\/ul>\s*<ul>/g, '');
return html;
}
function linkify(text){
if(!text) return '';
if(typeof scsConfig==='undefined') return text;
const mode=scsConfig.linkMode||'new';
if(mode==='text') return text;
const regex=/<a\s+[^>]*>.*?<\/a>|(((https?:\/\/)|(www\.))[^\s\*\)\(\[\]]+)/gi;
return text.replace(regex, function (match){
if(match.toLowerCase().startsWith('<a')) return match;
let hyperlink=match;
if(!hyperlink.match(/^https?:\/\//i)){
hyperlink='http://' + hyperlink;
}
const target=mode==='same' ? '_self':'_blank';
const extraClass=mode==='button' ? ' class="scs-link-button"':'';
const linkText=mode==='button' ? scsConfig.linkButtonLabel:match;
return '<a href="' + hyperlink + '" target="' + target + '"' + extraClass + ' rel="noopener noreferrer">' + linkText + '</a>';
});
}
function sanitizeHtml(html){
if(!html) return '';
const temp=document.createElement('div');
temp.innerHTML=html;
const allowedTags=[
'p', 'br', 'span', 'div', 'strong', 'b', 'em', 'i', 'u', 's', 'strike',
'h1', 'h2', 'h3', 'h4', 'h5', 'h6',
'ul', 'ol', 'li',
'a', 'img',
'table', 'thead', 'tbody', 'tr', 'th', 'td',
'blockquote', 'pre', 'code',
'hr'
];
const allowedAttributes={
'a': ['href', 'title', 'target', 'class', 'rel'],
'img': ['src', 'alt', 'title', 'width', 'height', 'class'],
'td': ['colspan', 'rowspan'],
'th': ['colspan', 'rowspan']
};
function cleanNode(node){
if(node.nodeType===3) return node.cloneNode();
if(node.nodeType!==1) return null;
const tagName=node.tagName.toLowerCase();
if(!allowedTags.includes(tagName)) return document.createTextNode(node.textContent||'');
const cleanElement=document.createElement(tagName);
if(allowedAttributes[tagName]){
allowedAttributes[tagName].forEach(attr=> {
if(node.hasAttribute(attr)){
let value=node.getAttribute(attr);
if(attr==='href'&&!/^(https?:\/\/|mailto:)/i.test(value)) return;
if(attr==='src'&&!/^(https?:\/\/|data:image\/)/i.test(value)) return;
cleanElement.setAttribute(attr, value);
}});
}
if(tagName==='a'){
cleanElement.setAttribute('target', '_blank');
cleanElement.setAttribute('rel', 'noopener noreferrer');
}
Array.from(node.childNodes).forEach(child=> {
const cleanChild=cleanNode(child);
if(cleanChild) cleanElement.appendChild(cleanChild);
});
return cleanElement;
}
const cleanDiv=document.createElement('div');
Array.from(temp.childNodes).forEach(child=> {
const cleanChild=cleanNode(child);
if(cleanChild) cleanDiv.appendChild(cleanChild);
});
return cleanDiv.innerHTML;
}
function formatTimestamp(isoString){
const date=new Date(isoString);
const day=String(date.getDate()).padStart(2, '0');
const month=String(date.getMonth() + 1).padStart(2, '0');
const year=String(date.getFullYear()).slice(-2);
const hours=String(date.getHours()).padStart(2, '0');
const minutes=String(date.getMinutes()).padStart(2, '0');
return `${day}/${month}/${year} ${hours}:${minutes}`;
}
function getUtmParams(){
const params=new URLSearchParams(window.location.search);
const utms={};
['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content'].forEach(key=> {
if(params.has(key)){
utms[key]=params.get(key);
}});
return utms;
}
function getReferrer(){
return document.referrer||'';
}
function isMobile(){
return window.matchMedia("(max-width: 768px)").matches;
}
return {
__: __,
ICON_PATHS: ICON_PATHS,
sanitizeInput: sanitizeInput,
containsHtmlTags: containsHtmlTags,
linkify: linkify,
parseMarkdown: parseMarkdown,
sanitizeHtml: sanitizeHtml,
formatTimestamp: formatTimestamp,
getUtmParams: getUtmParams,
getReferrer: getReferrer,
isMobile: isMobile
};})();