',a+='
',a+=oA(A),a+=D("a",p.close,{className:"close-field"}).outerHTML,a+="
",a+="
";var u=D("li",a,{class:r+"-field form-field",type:r,id:y.lastID}),f=$(u);f.data("fieldData",{attrs:A}),void 0===C.stopIndex?Y.append(f):$("> li",M.stage).eq(C.stopIndex).before(f),$(".sortable-options",f).sortable({update:function(){return C.updatePreview(f)}}),C.updatePreview(f),e.typeUserEvents[r]&&e.typeUserEvents[r].onadd&&e.typeUserEvents[r].onadd(u),e.editOnAdd&&t&&(C.closeAllEdit(),C.toggleEdit(y.lastID,!1)),y.lastID=C.incrementId(y.lastID)},gA=function(A,e,t){var r={selected:t?"checkbox":"radio"},o=["value","label","selected"],n=[];e=Object.assign({selected:!1,label:"",value:""},e);for(var i,s=o.length-1;0<=s;s--)if(i=o[s],e.hasOwnProperty(i)){var a={type:r[i]||"text",className:"option-"+i,value:e[i],name:A+"-option"};a.placeholder=p["placeholder."+i]||"","selected"===i&&!0===e.selected&&(a.checked=e.selected),n.push(D("input",null,a))}var l={className:"remove btn",title:p.removeMessage};return n.push(g.default.markup("a",p.remove,l)),g.default.markup("li",n).outerHTML},fA=function(A){var t=A.attr("id"),r=A.attr("type"),o=(new Date).getTime(),n=r+"-"+o,i=A.clone();return $(".fld-name",i).val(n),i.find("[id]").each(function(A,e){e.id=e.id.replace(t,y.lastID)}),i.find("[for]").each(function(A,e){var r=e.getAttribute("for"),o=r.replace(t,y.lastID);e.setAttribute("for",o)}),i.attr("id",y.lastID),i.attr("name",n),i.addClass("cloned"),$(".sortable-options",i).sortable(),e.typeUserEvents[r]&&e.typeUserEvents[r].onclone&&e.typeUserEvents[r].onclone(i[0]),y.lastID=C.incrementId(y.lastID),i};if(Y.on("click touchstart",".remove",function(A){var t=$(A.target).parents(".form-field:eq(0)"),r=t[0],o=r.getAttribute("type"),n=$(A.target.parentElement);A.preventDefault(),2>=r.querySelector(".sortable-options").childNodes.length&&!o.includes("checkbox")?e.notify.error("Error: "+p.minOptionMessage):n.slideUp("250",function(){n.remove(),C.updatePreview(t),C.save.call(C)})}),Y.on("touchstart","input",function(A){var e=$(u);if(!0===A.handled)return!1;if("checkbox"===e.attr("type"))e.trigger("click");else{e.focus();var t=e.val();e.val(t)}}),Y.on("click touchstart",".toggle-form, .close-field",function(A){if(A.stopPropagation(),A.preventDefault(),!0===A.handled)return!1;var e=$(A.target).parents(".form-field:eq(0)").attr("id");C.toggleEdit(e),A.handled=!0}),Y.on("dblclick","li.form-field, .field-label",function(A){if(A.stopPropagation(),A.preventDefault(),!0!==A.handled){var e="li"==A.target.tagName?$(A.target).attr("id"):$(A.target).closest("li.form-field").attr("id");C.toggleEdit(e),A.handled=!0}}),Y.on("change",'[name="subtype"]',function(A){var e=$(A.target).closest("li.form-field");$(".value-wrap",e).toggle("quill"!==A.target.value)}),Y.on("change",[".prev-holder input",".prev-holder select",".prev-holder textarea"].join(", "),function(A){var e;if(!A.target.classList.contains("other-option")){var t=g.default.closest(A.target,".form-field");if(g.default.inArray(t.type,["select","checkbox-group","radio-group"])){var r=t.getElementsByClassName("option-value");"select"===t.type?g.default.forEach(r,function(e){r[e].parentElement.childNodes[0].checked=A.target.value===r[e].value}):(e=document.getElementsByName(A.target.name),g.default.forEach(e,function(A){r[A].parentElement.childNodes[0].checked=e[A].checked}))}else{var o=document.getElementById("value-"+t.id);o&&(o.value=A.target.value)}C.save.call(C)}}),g.default.addEventListeners(M.stage,"keyup change",function(A){if(A.target.classList.contains("fld-label")){var e=A.target.value||A.target.innerHTML;g.default.closest(A.target,".form-field").querySelector(".field-label").innerHTML=g.default.parsedHtml(e)}}),Y.on("keyup","input.error",function(A){$(A.target).removeClass("error")}),Y.on("keyup",'input[name="description"]',function(A){var e=$(A.target).parents(".form-field:eq(0)"),t=$(".tooltip-element",e),r=$(A.target).val();""===r?t.length&&t.css("display","none"):t.length?t.attr("tooltip",r).css("display","inline-block"):$(".field-label",e).after('