var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.findInternal=function(a,f,e){a instanceof String&&(a=String(a));for(var g=a.length,b=0;b<g;b++){var k=a[b];if(f.call(e,k,b,a))return{i:b,v:k}}return{i:-1,v:void 0}};$jscomp.ASSUME_ES5=!1;$jscomp.ASSUME_NO_NATIVE_MAP=!1;$jscomp.ASSUME_NO_NATIVE_SET=!1;$jscomp.SIMPLE_FROUND_POLYFILL=!1;
$jscomp.defineProperty=$jscomp.ASSUME_ES5||"function"==typeof Object.defineProperties?Object.defineProperty:function(a,f,e){a!=Array.prototype&&a!=Object.prototype&&(a[f]=e.value)};$jscomp.getGlobal=function(a){return"undefined"!=typeof window&&window===a?a:"undefined"!=typeof global&&null!=global?global:a};$jscomp.global=$jscomp.getGlobal(this);
$jscomp.polyfill=function(a,f,e,g){if(f){e=$jscomp.global;a=a.split(".");for(g=0;g<a.length-1;g++){var b=a[g];b in e||(e[b]={});e=e[b]}a=a[a.length-1];g=e[a];f=f(g);f!=g&&null!=f&&$jscomp.defineProperty(e,a,{configurable:!0,writable:!0,value:f})}};$jscomp.polyfill("Array.prototype.find",function(a){return a?a:function(a,e){return $jscomp.findInternal(this,a,e).v}},"es6","es3");$jscomp.polyfill("Object.is",function(a){return a?a:function(a,e){return a===e?0!==a||1/a===1/e:a!==a&&e!==e}},"es6","es3");
$jscomp.polyfill("Array.prototype.includes",function(a){return a?a:function(a,e){var f=this;f instanceof String&&(f=String(f));var b=f.length;e=e||0;for(0>e&&(e=Math.max(e+b,0));e<b;e++){var k=f[e];if(k===a||Object.is(k,a))return!0}return!1}},"es7","es3");
$jscomp.checkStringArgs=function(a,f,e){if(null==a)throw new TypeError("The 'this' value for String.prototype."+e+" must not be null or undefined");if(f instanceof RegExp)throw new TypeError("First argument to String.prototype."+e+" must not be a regular expression");return a+""};$jscomp.polyfill("String.prototype.includes",function(a){return a?a:function(a,e){return-1!==$jscomp.checkStringArgs(this,a,"includes").indexOf(a,e||0)}},"es6","es3");
(function(a){a.fn.NetopesHierarchicalTexts=function(f){function e(c,d){b=d;a(c).data("_NetopesHierarchicalTextsConfig",b);a(c).find(".hTextsActions .hTextsActionButton").on("click",function(){m(c,this)});a(c).find(".hTextsData button.hTextsEditButton").on("click",function(){n(c,this)});a(c).find(".hTextsData button.hTextsDeleteButton").on("click",function(){p(c,this)});a(c).find(".hTextsEditActions button.hTextsSaveButton").on("click",function(){m(c,this)});a(c).find(".hTextsEditActions button.hTextsCancelButton").on("click",
function(){a(c).find(".hTextsInput #"+b.tagId+"_hId").first().val("");k(c,"");a(this).parents(".hTextsEditActions").hide()});b.sortableTexts&&a(c).find(".hTextsData ul.hSections ul.hTexts").sortable({revert:!0,placeholder:"ui-state-highlight"});b.sortableSections&&a(c).find(".hTextsData ul.hSections").sortable({revert:!0,placeholder:"ui-state-highlight"})}var g={tagId:null,tagName:null,textEditorType:"textarea",showEmptySections:!1,sortableSections:!1,sortableTexts:!1,fieldErrorClass:"",editButtonClass:"btn btn-primary",
deleteButtonClass:"btn btn-danger",deleteConfirmText:"Are you sure you want to delete item?",deleteConfirmTitle:"Action confirm",deleteConfirmOkLabel:"OK",deleteConfirmCancelLabel:"Cancel",requiredSectionClass:"",requiredSectionMarker:""},b=!1,k=function(c,d){"ckeditor"===b.textEditorType?SetCkEditorData(b.tagId+"_hValue",d):a(c).find(".hTextsInput #"+b.tagId+"_hValue").first().val(d.replaceAll("<br>","\n"))},w=function(c,d,e,f,g,k){a(c).find(".hTextsData ul.hSections li.hItemSection.empty").remove();
var h='<li class="hItemSection'+(b.sortableSections?" sortable":"")+'" data-id="'+d+'" data-required="'+g+'" data-position="'+k+'">';h="1"===g.toString()?h+('<span class="hItemTitle '+b.requiredSectionClass+'">'+e+b.requiredSectionMarker+"</span>"):h+('<span class="hItemTitle">'+e+"</span>");h+='<input type="hidden" class="postable" name="'+b.tagName+"["+d+'][id]" value="'+d+'"><input type="hidden" class="postable" name="'+b.tagName+"["+d+'][name]" value="'+e+'"><input type="hidden" class="postable" name="'+
b.tagName+"["+d+'][code]" value="'+f+'"><input type="hidden" class="postable" name="'+b.tagName+"["+d+'][required]" value="'+g+'"><input type="hidden" class="postable" name="'+b.tagName+"["+d+'][position]" value="'+k+'"><ul class="hTexts"></ul></li>';var l=a(h);if(isNaN(parseInt(k)))a(c).find(".hTextsData ul.hSections").append(l);else{var u=!1,v=0;a(c).find(".hTextsData ul.hSections li.hItemSection").each(function(){if(isNaN(parseInt(a(this).data("position")))||parseInt(k)<parseInt(a(this).data("position")))return a(this).before(l),
u=!0,!1;v++});u||(0<v?a(c).find(".hTextsData ul.hSections").append(l):a(c).find(".hTextsData ul.hSections").prepend(l))}b.sortableTexts&&a(l).find("ul.hTexts").sortable({revert:!0,placeholder:"ui-state-highlight"});return l},x=function(c,d,e){d=a('<li class="hItem'+(b.sortableTexts?" sortable":"")+'" data-id="'+d+'"><div class="hItemData postable" name="'+b.tagName+"["+d+'][data][]">'+e+'</div><div class="hItemEditActions"></div><div class="hItemDeleteActions"></div></li>');a(d).find(".hItemEditActions").append(a('<button class="'+
b.editButtonClass+' hTextsEditButton"><i class="fa fa-pencil-square-o" aria-hidden="true"></i></button>').on("click",function(){n(c,this)}));a(d).find(".hItemDeleteActions").append(a('<button class="'+b.deleteButtonClass+' hTextsDeleteButton"><i class="fa fa-trash" aria-hidden="true"></i></button>').on("click",function(){p(c,this)}));return d},n=function(c,d){d=a(d).parents("li.hItem");var e=a(d).find(".hItemData").first().html();a(c).find(".hTextsInput #"+b.tagId+"_hId").first().val(a(d).data("id")+
"|"+a(d).index());k(c,e);a(c).find(".hTextsEditActions").show()},p=function(c,d){ShowConfirmDialog(b.deleteConfirmText,function(){var c=a(d).parents("li.hItemSection");a(d).parents("li.hItem").remove();"1"===a(c).data("required").toString()||b.showEmptySections||0!==a(c).find("ul.hTexts > li.hItem").length||a(c).remove()},!1,{title:b.deleteConfirmTitle,ok:b.deleteConfirmOkLabel,cancel:b.deleteConfirmCancelLabel})},m=function(c,d){var e="ckeditor"===b.textEditorType?GetCkEditorData(b.tagId+"_hValue"):
a(c).find(".hTextsInput #"+b.tagId+"_hValue").first().val().replace(/(?:\r\n|\r|\n)/g,"<br>");a(c).find(".hTextsInput #"+b.tagId+"_hValue").removeClass(b.fieldErrorClass);if(""===e.trim())a(c).find(".hTextsInput #"+b.tagId+"_hValue").addClass(b.fieldErrorClass);else{var h=a(c).find(".hTextsInput #"+b.tagId+"_hId").first().val();if(0<h.length&&h.includes("|")){var f=h.split("|")[0];h=parseInt(h.split("|")[1]);if(isNaN(h)){console.log("Invalid text item index!");return}h+=1;a(c).find('.hTextsData ul.hSections li.hItemSection[data-id="'+
f+'"] ul.hTexts li.hItem:nth-child('+h+") .hItemData").html(e)}else{f=a(d).data("id");if(!f){console.log("Invalid save action!");return}h=a(c).find('.hTextsData ul.hSections li.hItemSection[data-id="'+f+'"]').first();if(0===h.length){h=a(d).text();var g=a(d).data("code")||"";h=w(c,f,h,g,a(d).data("required"),a(d).data("position"))}h.find("ul.hTexts").append(x(c,f,e))}a(c).find(".hTextsInput #"+b.tagId+"_hId").val("");k(c,"");a(d).parents(".hTextsEditActions").hide();a(c).find(".hTextsActions .hTextsActionButton").prop("disabled",
!1)}},q={setValueForSection:function(c,b,e){k(c,b);a(c).find(".hTextsActions .hTextsActionButton").each(function(){a(this).data("id")!==e?a(this).prop("disabled","disabled"):a(this).prop("disabled",!1)})},setValue:function(c,b){"string"===typeof b&&(b=JSON.parse(b));for(var e in b){var d=b[e],f;for(f in d.data){var g=d.data[f];if(g){var k=c,r=d.id,m=d.name,n=d.code,p=d.required,q=d.position,t=a(k).find('.hTextsData ul.hSections li.hItemSection[data-id="'+r+'"]').first();0===t.length&&(t=w(k,r,m,n,
p,q));t.find("ul.hTexts").append(x(k,r,g))}}}},setDisabled:function(c,d){!0===d||"true"===d||1===d||"1"===d?(a(c).attr("data-disabled","disabled"),a(c).find(".hTextsActions .hTextsActionButton").prop("disabled","disabled"),a(c).find(".hTextsData button.hTextsEditButton").prop("disabled","disabled"),a(c).find(".hTextsData button.hTextsDeleteButton").prop("disabled","disabled"),"ckeditor"===b.textEditorType?SetCkEditorReadonly(b.tagId+"_hValue",!0):a(c).find(".hTextsInput #"+b.tagId+"_hValue").prop("disabled",
"disabled"),b.sortableTexts&&a(c).find(".hTextsData ul.hSections ul.hTexts").sortable("option","disabled",!0),b.sortableSections&&a(c).find(".hTextsData ul.hSections").sortable("option","disabled",!0)):!1===d||"false"===d||0===d||"0"===d?(a(c).attr("data-disabled",""),a(c).find(".hTextsActions .hTextsActionButton").prop("disabled",!1),a(c).find(".hTextsData button.hTextsEditButton").prop("disabled",!1),a(c).find(".hTextsData button.hTextsDeleteButton").prop("disabled",!1),"ckeditor"===b.textEditorType?
SetCkEditorReadonly(b.tagId+"_hValue",!1):a(c).find(".hTextsInput #"+b.tagId+"_hValue").prop("disabled",!1),b.sortableTexts&&a(c).find(".hTextsData ul.hSections ul.hTexts").sortable("option","disabled",!1),b.sortableSections&&a(c).find(".hTextsData ul.hSections").sortable("option","disabled",!1)):console.log("Invalid setDisabled value ["+d+"]!")}};if("string"===typeof f)if(q[f]){g=Array.prototype.slice.call(arguments,1);g.unshift(this);if(b=a(this).data("_NetopesHierarchicalTextsConfig"))return q[f].apply(this,
g);console.log("Invalid NetopesHierarchicalTexts instance for element ["+a(this).attr("id")+"]!")}else console.log("Invalid or inaccessible method: ["+f+"]!");else{var y="object"===typeof f?a.extend(g,f):g;return this.each(function(){e(this,y)})}}})(jQuery);
