import { ITrigger } from './types/interface';
import { s4 } from '@janda-com/front';



export type TTrigger = {
	_id: string;
	event: string;
	enable: boolean;
	new?: boolean;
};

export const DEFAULT_TRIGGER: TTrigger = {
	_id: s4(),
	event: '',
	enable: true,
	new: true
};

//여기서 추가용을 추가해줌
export const triggerMap = (triggers: ITrigger[]): TTrigger[] => {
	const sss = triggers.map(tg => ({
		_id: tg._id,
		event: tg.event,
		enable: tg.isEnabled
	}));

	return [...sss, DEFAULT_TRIGGER];
};

export const removeBigWrap = (str: string) => str.replace('[', '').replace(']', '');



export const getByteLength = (s: string = ""): number => {
	let i;
	let b;
	let c;
	for (b = i = 0; (c = s.charCodeAt(i++)); b += c >> 11 ? 2 : c >> 7 ? 2 : 1);
	return b;
};
