function escapeRegExp(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")}jQuery(document).ready(function(e){e("button.pspbutton").each(function(a,s){var t="#"+e(this).data("id"),i="%"+e(this).data("added")+"%";t=escapeRegExp(t);var p=e(t).val();"%sep%"===i&&e(this).attr("id","pspsep"),-1!=p.indexOf(i)&&e(this).toggleClass("active")}),e("button.pspbutton").click(function(){var a="%"+e(this).data("added")+"%",s="#"+e(this).data("id");s=escapeRegExp(s);var t=a,i=e(s).val();i&&"%sep%"!==a&&(a=i.trim().endsWith("%sep%")?" "+a:" %sep% "+a),-1!=i.indexOf(a)?(i=i.replace(a,""),e(this).removeClass("active")):-1!=i.indexOf(t)?(i=(i=i.replace(t+" %sep% ","")).replace(t,""),e(this).removeClass("active")):("%sep%"!==a&&(i+=a),"%sep%"==a&&(i=i+" "+a),e(this).addClass("active")),-1!=i.indexOf("%sep%")?e("#pspsep").addClass("active"):e("#pspsep").removeClass("active"),e(s).val(i.trim()).trigger("change")})});