define(["jquery","core/ajax","core/templates","core/notification","core/str","core/config","core/url","core/form-autocomplete","core/pending"],function(a,b,c,d,e,f,g,h,i){return a("body").on("click keypress","[data-inplaceeditable] [data-inplaceeditablelink]",function(j){if("keypress"!==j.type||13===j.keyCode){var k=new i("autocomplete-start-editing");j.stopImmediatePropagation(),j.preventDefault();var l=a(this),m=l.closest("[data-inplaceeditable]"),n=function(b){b.addClass("updating");var c=b.find("img.spinner");c.length?c.show():(c=a("").attr("src",g.imageUrl("i/loading_small")).addClass("spinner").addClass("smallicon"),b.append(c))},o=function(a){a.removeClass("updating"),a.find("img.spinner").hide()},p=function(e,f){var g=[e.attr("data-itemid"),e.attr("data-component"),e.attr("data-itemtype")].join("-"),h=new i(g);n(e),b.call([{methodname:"core_update_inplace_editable",args:{itemid:e.attr("data-itemid"),component:e.attr("data-component"),itemtype:e.attr("data-itemtype"),value:f}}])[0].then(function(b){return c.render("core/inplace_editable",b).then(function(d,f){var g=e.attr("data-value"),h=a(d);c.replaceNode(e,h,f),h.find("[data-inplaceeditablelink]").focus(),h.trigger({type:"updated",ajaxreturn:b,oldvalue:g})})}).then(function(){return h.resolve()}).fail(function(b){var c=a.Event("updatefailed",{exception:b,newvalue:f});o(e),M.util.js_complete(g),e.trigger(c),c.isDefaultPrevented()||d.exception(b)})},q=function(a){a.find("input").off(),a.find("select").off(),a.html(a.attr("data-oldcontent")),a.removeAttr("data-oldcontent"),a.removeClass("inplaceeditingon"),a.find("[data-inplaceeditablelink]").focus()},r=function(){a("span.inplaceeditable.inplaceeditingon").each(function(){q(a(this))})},s=function(b,c){var d,e=b;for(d=0;d'+c+"").attr("id",s("id_editinstructions_",20)),e=a('').attr("id",s("id_inplacevalue_",20)).attr("value",b.attr("data-value")).attr("aria-describedby",d.attr("id")).addClass("ignoredirty").addClass("form-control"),g=a('").attr("for",e.attr("id"));b.html("").append(d).append(g).append(e),e.focus(),e.select(),e.on("keyup keypress focusout",function(a){if(!f.behatsiterunning||"focusout"!==a.type){if("keypress"===a.type&&13===a.keyCode){var c=e.val();q(b),p(b,c)}("keyup"===a.type&&27===a.keyCode||"focusout"===a.type)&&q(b)}})})},u=function(a,b){q(a),p(a,b)},v=function(b,c){var d,e=a("").attr("id",s("id_inplacevalue_",20)).addClass("custom-select"),g=a('").attr("for",e.attr("id"));for(d in c)e.append(a("