(function(p){const C=p.paths,w=p.l10n;require.config({paths:C.js});define("xwiki-document-api",["jquery","xwiki-meta"],function(b,t){class v{constructor(){this.documentReference=t.documentReference;this.language=t.locale;this.version=t.version;this.isNew=t.isNew;this.renderedTitle=b("#document-title h1").html();this.renderedContent=b("#xwikicontent").html();if(!this.language){const d=new URLSearchParams(XWiki.docvariant);this.translations=this.translations||{};this.translations["default"]=d.get("language")}}getPlainTitle(){return b("\x3cdiv/\x3e").html(this.renderedTitle||
this.title).text()}getRealLocale(){var d=this.language;if("string"!==typeof d||""===d)d=this.getDefaultLocale();return d}getDefaultLocale(){return this.translations&&"string"===typeof this.translations["default"]?this.translations["default"]:b("html").attr("lang")}getURL(d,h,n){h&&"object"===typeof h&&(h=b.param(h,!0));var g=this.documentReference&&new XWiki.Document(this.documentReference)||XWiki.currentDocument;return g.getURL.call(g,d,h,n)}getRestURL(d){var h=this.documentReference&&new XWiki.Document(this.documentReference)||
XWiki.currentDocument;d&&"object"===typeof d&&(d=b.param(d,!0));var n=this.language&&"translations/"+encodeURIComponent(this.language);return h.getRestURL(n,d)}render({outputSyntax:d,transformations:h}={}){const n={xpage:"get",outputTitle:!0,language:this.isNew?"":this.getRealLocale(),timestamp:(new Date).getTime()};d&&(n.outputSyntax=d.type,n.outputSyntaxVersion=d.version);h&&(n.transformations=h);return Promise.resolve(b.get(this.getURL("view"),b.param(n,!0))).then(g=>{g=b("\x3cdiv/\x3e").html(g);
const q=g.find("#xwikicontent"),k=!d||d.type.includes("html");return b.extend(this,{renderedTitle:g.find("#document-title h1").html(),renderedContent:k?q.html():q.text()})}).catch(()=>{new XWiki.widgets.Notification(w["edit.inplace.page.renderFailed"],"error");return Promise.reject(this)})}reload(){return Promise.resolve(b.getJSON(this.getRestURL(),{timestamp:(new Date).getTime()})).then(d=>{this.documentReference=XWiki.Model.resolve(d.id,XWiki.EntityType.DOCUMENT);this.isNew=!1;return b.extend(this,
d)}).catch(d=>{if(404===d.status){if(""===this.language)return this.markAsNew(),this;const h=this.language;this.language="";return this.reload().then(()=>{this.isNew||this.translate(h);return this})}return Promise.reject(this)})}markAsNew(){this.isNew=!0;delete this.version;delete this.majorVersion;delete this.minorVersion}lock(d,h){d=d||"edit";return Promise.resolve(b.getJSON(this.getURL("get"),{sheet:"XWiki.InplaceEditing",action:"lock",lockAction:d,force:h,language:this.getRealLocale(),timestamp:(new Date).getTime()})).then(()=>
{this.locked=d;return this}).catch(n=>{delete this.locked;var g=n.responseJSON;423===n.status&&g&&(this.lockConfirmation=g);return Promise.reject(this)})}unlock(d){this.locked=!1;d=this.getURL("cancel",b.param({ajax:1,action:d||"edit",language:this.getRealLocale()}));navigator.sendBeacon?navigator.sendBeacon(d):b.ajax({type:"GET",url:d,async:!1})}translate(d){const h=this.getRealLocale();d=d||b("html").attr("lang");h&&h!==d&&(this.backup("defaultTranslation"),this.language=d,this.translations=this.translations||
{},this.translations["default"]=h,this.markAsNew())}backup(d){d=d||"originalDocument";delete this[d];this[d]=b.extend(!0,new v,this)}}return v});define("editInPlace",["jquery","xwiki-meta","xwiki-document-api","bootstrap","xwiki-events-bridge"],function(b,t,v){function d(){k||=new v;return k}function h(a){k=a;return Promise.resolve(a)}async function n(a,c){a.isNew&&a.language&&a.defaultTranslation&&(a=a.defaultTranslation);const f=b("#xwikicontent"),l=[];f.trigger("xwiki:actions:view",{document:a,
promises:l});g("We encountered some errors while restoring the view mode: ",await Promise.allSettled(l));b("#document-title h1").html(a.renderedTitle);f.html(a.renderedContent);XWiki.editor="";c||(f.children(":header").children(".edit_section").removeClass("hidden"),b(document).trigger("xwiki:dom:updated",{elements:f.toArray()}));f.closest(".form").removeClass("form");"#edit"!==window.location.hash&&"#translate"!==window.location.hash||history.replaceState(null,null,"#");return a}function g(a,c){c=
c.filter(f=>"rejected"===f.status).map(f=>f.reason);c.length&&console.warn(a,c)}var q=function(a){b("\x3clink/\x3e").attr({type:"text/css",rel:"stylesheet",href:a}).appendTo("head")};let k;b(document).on("xwiki:document:changeVersion",(a,c)=>{c.documentReference.equals(k?.documentReference)&&(k.version=c.version)});var e=function(){const a=document.getElementById("document-title-input");a.focus();a.setSelectionRange(0,0)},m=function(a){a=b.extend({afterEdit:function(){},lockFailed:function(){}},a);
b("#xwikicontent").addClass("loading");return r(d()).then(z,c=>{a.lockFailed(c);return Promise.reject(c)}).then(I).then(c=>{a.afterEdit(c);return c}).finally(()=>{b("#xwikicontent").removeClass("loading")}).then(A).then(B,B).then(n,n).then(h,h)},r=function(a){return a.lock().catch(function(c){if(c.lockConfirmation){var f=c.lockConfirmation;delete c.lockConfirmation;return D(f).then(c.lock.bind(c,"edit",!0),function(){return Promise.reject(c)})}new XWiki.widgets.Notification(w["edit.inplace.page.lockFailed"],
"error");return Promise.reject(c)})},D=function(a){var c,f=new Promise((u,x)=>{c={resolve:u,reject:x}});f.catch(()=>{}).finally(()=>{c.settled=!0});var l=b(".force-edit-lock-modal");l.length||(l=y());l.data("deferred",c);l.find(".modal-title").text(a.title);l.find(".modal-body").html(a.message);l.find(".modal-footer .btn-default").text(a.reject);a.confirm?l.find(".modal-footer .btn-warning").show().text(a.confirm):l.find(".modal-footer .btn-warning").hide();l.modal("show");return f},y=function(){var a=
b('\x3cdiv class\x3d"modal fade force-edit-lock-modal" tabindex\x3d"-1" role\x3d"dialog"\x3e\x3cdiv class\x3d"modal-dialog" role\x3d"document"\x3e\x3cdiv class\x3d"modal-content"\x3e\x3cdiv class\x3d"modal-header"\x3e\x3cbutton type\x3d"button" class\x3d"close" data-dismiss\x3d"modal"\x3e\x3cspan aria-hidden\x3d"true"\x3e\x26times;\x3c/span\x3e\x3c/button\x3e\x3ch4 class\x3d"modal-title"\x3e\x3c/h4\x3e\x3c/div\x3e\x3cdiv class\x3d"modal-body"\x3e\x3c/div\x3e\x3cdiv class\x3d"modal-footer"\x3e\x3cbutton type\x3d"button" class\x3d"btn btn-default" data-dismiss\x3d"modal"\x3e\x3c/button\x3e\x3cbutton type\x3d"button" class\x3d"btn btn-warning"\x3e\x3c/button\x3e\x3c/div\x3e\x3c/div\x3e\x3c/div\x3e\x3c/div\x3e');
a.find(".close").attr("aria-label",w["edit.inplace.close"]);a.find(".modal-footer .btn-warning").on("click",function(){a.data("deferred").resolve();a.modal("hide")});a.on("hide.bs.modal",function(){var c=a.data("deferred");c.settled||c.reject()});return a.appendTo("body").modal()},z=function(a){return a.reload().then(c=>{c.backup();return c}).catch(c=>{new XWiki.widgets.Notification(w["edit.inplace.page.loadFailed"],"error");return Promise.reject(c)}).then(E.bind(null,F.contentEditor.getRenderingConfig()))},
E=function(a,c){return c.render(a)},A=function(a){return J(a).then(c=>{switch(c.name){case "save":return K({document:c.document,"continue":c.data&&c.data["continue"]});case "reload":return G(c.document);default:return c.document.originalDocument}})},J=function(a){return new Promise((c,f)=>{const l=b(".inplace-editing-buttons").prop("disabled",!1);b(document).one("xwiki:actions:save xwiki:actions:reload xwiki:actions:cancel",".xcontent.form",function(u,x){l.prop("disabled",!0);c({name:u.type.substring(14),
document:a,data:x})})})},K=function(a){return L(a.document).then(c=>M(c).then(G,N.bind(null,a["continue"])),A)},L=function(a){return new Promise((c,f)=>{b(document).one("xwiki:document:saved",".xcontent.form",c.bind(null,a));b(document).one("xwiki:document:saveFailed",".xcontent.form",f.bind(null,a))})},N=function(a,c){var f=function(l,u){return a?(l&&u.backup(),A(u)):u};return c.reload().then(E.bind(null,{})).then(f.bind(null,!0),f.bind(null,!1))},B=function(a){a.locked&&0<b("#document-title-input").length&&
a.unlock();return a};b(window).on("unload pagehide",()=>{B(d())});var M=function(a){var c=!1;b(document).one("xwiki:actions:reload.maybe",".xcontent.form",function(){c=!0});return new Promise((f,l)=>{setTimeout(function(){b(document).off("xwiki:actions:reload.maybe");c?f(a):l(a)},0)})},G=function(a){return n(a,!0).then(m)},I=function(a){b("#xwikicontent").closest(".xcontent").addClass("form");XWiki.editor=p.editMode;return H(a).then(O).then(P)},H=function(a){a&&Q(a);var c=b("#xwikicontent");let f=
c.nextAll("form#inplace-editing");if(f.length)return a&&(f.show().children(".sticky-buttons").data("xwikiDocument",a).trigger("xwiki:dom:refresh").prop("disabled",!1),f.children("fieldset").nextAll().remove()),Promise.resolve(a);f=b('\n        \x3cform id\x3d"inplace-editing" class\x3d"col-xs-12"\x3e\n          \x3cdiv hidden\x3e\n            \x3cinput type\x3d"hidden" name\x3d"form_token" /\x3e\n            \x3cinput type\x3d"hidden" name\x3d"async" value\x3d"true" /\x3e\n            \x3cinput type\x3d"hidden" name\x3d"language" /\x3e\n          \x3c/div\x3e\n          \x3cfieldset id\x3d"xwikieditcontent" class\x3d"xform inplace-editing-buttons sticky-buttons"\x3e\x3c/fieldset\x3e\n        \x3c/form\x3e\n      ').attr("action",
XWiki.currentDocument.getURL("save")).insertAfter(c).toggle(!!a);f.find('input[name\x3d"form_token"]').val(t.form_token);a=f.children(".sticky-buttons").data("xwikiDocument",a);return R(a)},S=function(a){e();b("#document-title-input").popover({content:w["edit.inplace.page.translate.messageAfter"],placement:"bottom",trigger:"manual"}).popover("show").one("blur",function(){b(this).popover("hide")})},Q=function(a){const c=b(p.translateButtonSelector).filter('[data-toggle\x3d"popover"]').filter(":visible");
c.attr({"data-content-view":c.attr("data-content"),"data-content":w["edit.inplace.page.translate.messageBefore"]}).popover("show").closest("html").one("click",function(){c.popover("hide")})},R=function(a){a.on("xwiki:actions:beforeSave xwiki:actions:beforePreview",c=>{b(document).one(c.type,T)});a.on("xwiki:actions:cancel",function(c){c.preventDefault()});b(document).on("xwiki:actions:view",".xcontent.form",function(c,f){a.find(":input").blur().end().prop("disabled",!0).parent().hide();c=f.document.getRealLocale();
f=b("html").attr("lang");c&&c!==f&&(c=b(p.translateButtonSelector).filter('[data-toggle\x3d"popover"]'),c.attr("data-content",c.attr("data-content-view")||c.attr("data-content")).parent().removeClass("hidden"))});return Promise.resolve(b.get(XWiki.currentDocument.getURL("get"),{xpage:"editactions"})).then(c=>{a.html(c);a.find(".btn-primary").first().attr("name","action_save");b(document).trigger("xwiki:dom:updated",{elements:a.toArray()});return new Promise((f,l)=>{require(["xwiki-actionButtons",
"xwiki-diff","xwiki-autoSave"],function(){U();var u=a.data("xwikiDocument");a.prop("disabled",!u);f(u)})})}).catch(()=>{new XWiki.widgets.Notification(w["edit.inplace.actionButtons.loadFailed"],"error")})},T=function(){const a=b("form#inplace-editing"),c=a.children(".sticky-buttons").data("xwikiDocument");a.find('input[name\x3d"language"]').val(c.getRealLocale());a.find('input[name\x3d"isNew"]').val(c.isNew);!c.isNew&&c.version&&(a.find('input[name\x3d"previousVersion"]').val(c.version),a.find('input[name\x3d"editingVersionDate"]').val((new Date(c.modified)).getTime()))},
U=function(){var a=b.extend({},XWiki.actionButtons.AjaxSaveAndContinue.prototype);b.extend(XWiki.actionButtons.AjaxSaveAndContinue.prototype,{reloadEditor:function(){if(XWiki.editor===p.editMode)setTimeout(function(){b(".inplace-editing-buttons").trigger("xwiki:actions:reload")},0);else return a.reloadEditor.apply(this,arguments)},maybeRedirect:function(c){return XWiki.editor===p.editMode?!c:a.maybeRedirect.apply(this,arguments)}})},O=function(a){var c=b('\x3clabel for\x3d"document-title-input" class\x3d"sr-only"/\x3e').text(w["core.editors.content.titleField.label"]),
f=b('\x3cinput type\x3d"text" id\x3d"document-title-input" name\x3d"title" form\x3d"inplace-editing" /\x3e').val(a.rawTitle);if(p.titleIsMandatory)f.attr({required:"","data-validation-value-missing":w["core.validation.required.message"]});else{var l=a.documentReference.name;"WebHome"===l&&(l=a.documentReference.parent.name);f.attr("placeholder",l)}b("#document-title h1").addClass("editable").empty().append([c,f]);b(document).on("xwiki:actions:beforeSave.titleEditor xwiki:actions:beforePreview.titleEditor",
".xcontent.form",()=>a.rawTitle=f.val());b(document).one("xwiki:actions:view",".xcontent.form",function(u,x){b(document).off("xwiki:actions:beforeSave.titleEditor xwiki:actions:beforePreview.titleEditor");b("#document-title h1").removeClass("editable").text(a.rawTitle)});return a},P=function(a){var c=b("#xwikicontent"),f=document.activeElement&&document.activeElement===c[0],l=c.clone().insertAfter(c);c.hide().empty();f&&l.focus();f=b.extend({},p,{editorName:"content",document:a,startupFocus:f,formId:"inplace-editing",
deferred:b.Deferred()});c.trigger("xwiki:actions:edit",f);return f.deferred.promise().then(()=>{c.show();l.remove();return a})};let F={contentEditor:void 0,preload:function(){C.css.forEach(q);return H()},editPage:function(){return m({afterEdit:e})},editSection:function(a){return m({lockFailed:function(){b("#xwikicontent").children(":header").children(".edit_section").removeClass("hidden")},afterEdit:function(){a&&b("#xwikicontent \x3e #"+b.escapeSelector(a)).each(function(){if(window.getSelection){var c=
window.getSelection(),f=document.createRange();f.selectNodeContents(this);c.removeAllRanges();c.addRange(f)}})}})},translatePage:function(){d().translate();return m({afterEdit:S})}};return F});require(["jquery"],function(b){function t(k){k?(g.removeClass("disabled"),g.removeAttr("aria-disabled"),g.removeAttr("role"),g.attr("href",g.attr("data-saved-href")),g.removeAttr("data-saved-href")):(g.add(q).addClass("disabled"),g.attr("aria-disabled","true"),g.each(function(){b(this).attr("data-saved-href",
b(this).attr("href"))}),g.removeAttr("href"),g.attr("role","link"),b("#xwikicontent").children(":header").children(".edit_section").addClass("hidden"))}if(b("#xwikicontent").length){var v=function(){require(["editInPlace",p.contentEditor],function(k,e){k.contentEditor=e;k.preload()},n)};if("complete"===document.readyState)setTimeout(v,0);else b(window).on("load",function(){setTimeout(v,0)});var d,h=function(k){k.preventDefault();t(!1);if(d)d.finally(()=>{h(k)}),b(".xcontent.form").trigger("xwiki:actions:cancel");
else{var e=k.data,m=e.beforeEdit?.(k);d=(new Promise((r,D)=>{require(["editInPlace",p.contentEditor],(y,z)=>{y.contentEditor=z;q.removeClass("disabled");e.edit(y,m).finally(()=>{t(!0);r()})},n.bind(k.target))})).finally(()=>{d=!1})}},n=function(){g.add(q).off("click.inPlaceEditing").removeClass("disabled");b("#xwikicontent").off("click.inPlaceEditing").removeAttr("tabindex").children(":header").children(".edit_section").removeClass("hidden");b(this).click()},g=b(p.editButtonSelector);g.on("click.inPlaceEditing",
{beforeEdit:function(){history.replaceState(null,null,"#edit")},edit:function(k){return k.editPage()}},h).attr("data-editor","inplace");var q=b(p.translateButtonSelector);q.on("click.inPlaceEditing",{beforeEdit:function(){history.replaceState(null,null,"#translate");q.parent().addClass("hidden")},edit:function(k){return k.translatePage()}},h);b("#xwikicontent").on("click.inPlaceEditing","\x3e :header \x3e a.edit_section:not(.disabled)",{beforeEdit:function(k){b("#xwikicontent").attr("tabindex","0").focus();
return b(k.target).closest(":header").attr("id")},edit:async function(k,e){try{return await k.editSection(e)}finally{b("#xwikicontent").removeAttr("tabindex")}}},h);"#edit"===window.location.hash?g.click():"#translate"===window.location.hash&&q.click()}});require(["jquery","xwiki-meta"],function(b,t){function v(e){b("html").attr({"data-xwiki-isnew":e.isNew,"data-xwiki-version":e.version||"","data-xwiki-modified":e.modified,"data-xwiki-locale":e.language,"data-xwiki-rest-url":e.getRestURL()}).data({"xwiki-isnew":e.isNew,
"xwiki-version":e.version||"","xwiki-modified":e.modified,"xwiki-locale":e.language,"xwiki-rest-url":e.getRestURL()});t.init();t.modified=e.modified}var d;b("#xwikicontent").on("xwiki:actions:edit",function(e,m){e=m.document;v(e);d=e.getPlainTitle()});b(document).on("xwiki:actions:view",function(e,m){e=m.document;v(e);h(e);b("#docextrapanes").children().addClass("empty").empty();m=b("#docExtraTabs .active[data-template]");if(m.length){var r=m.attr("id");r=r.substring(0,r.length-3);XWiki.displayDocExtra(r,
m.data("template"),!1)}q(e);k(e);e.getPlainTitle()!==d&&(n(e),g(e))});var h=function(e){e=e.getURL("get",b.param({xpage:"contentheader",language:b("html").attr("lang")}))+" .xdocLastModification";b(".xdocLastModification").load(e,function(){b(this).children().unwrap()})},n=function(e){var m=e.getPlainTitle();b(".jstree-xwiki").each(function(){b(this).jstree?.(!0)?.set_text?.("document:"+e.id,m)})},g=function(e){var m=e.getURL();e=e.getPlainTitle();b("a").not("#xwikicontent a").not(":has(*)").filter(function(){return b(this).attr("href")?.split(/[?#]/,
1)[0]===m&&b(this).text()===d}).text(e)},q=function(e){var m=b("#tmLanguages_menu"),r=e.getRealLocale();m.length&&!m.find('a[href*\x3d"language\x3d'+r+'\x26"], a[href$\x3d"language\x3d'+r+'"]').length&&b("\x3cdiv/\x3e").load(e.getURL("get",b.param({xpage:"xpart",vm:"drawer.vm",useLayoutVars:!0}))+"\x26"+location.search.substring(1)+" #tmLanguages_menu",function(){b(this).find("a").each(function(){b(this).attr("href",b(this).attr("href").replace(/&?(xpage=xpart|vm=drawer\.vm|useLayoutVars=true)/g,
"").replace("?\x26","?"))});m.replaceWith(b(this).children())})},k=function(e){var m=e.getRealLocale();e=e.getDefaultLocale();if(m!=e){var r=new RegExp("(\\blanguage\x3d)"+e+"($|\x26|#)");b('#contentmenu a[href*\x3d"language\x3d'+e+'"]').each(function(){b(this).attr("href",b(this).attr("href").replace(r,"$1"+m+"$2"))})}}})})(JSON.parse(document.querySelector("[data-inplace-editing-config]")?.getAttribute("data-inplace-editing-config"))||{});