require(["jquery","xwiki-meta"],function(a,b){a(document).ready(function(){var h=a("form#create");var d=h.find("input.location-name-field");var i=h.find("input.location-parent-field");var c=h.find('input[name="tocreate"]');var g=function(){var k=new XWiki.DocumentReference();if(i.length>0){var m=i.val();if(m==""){if(c.prop("checked")){return false}k=new XWiki.DocumentReference(b.wiki,d.val(),"WebHome")}else{var j=XWiki.Model.resolve(m,XWiki.EntityType.SPACE);if(c.prop("checked")){k=new XWiki.EntityReference(d.val(),XWiki.EntityType.DOCUMENT,j)}else{var l=new XWiki.EntityReference(d.val(),XWiki.EntityType.SPACE,j);k=new XWiki.EntityReference("WebHome",XWiki.EntityType.DOCUMENT,l)}}}else{if(a(".modal-popup").length>0){var j=XWiki.Model.resolve(a("#spaceReference").val(),XWiki.EntityType.SPACE);k=new XWiki.EntityReference(a("#name").val(),XWiki.EntityType.DOCUMENT,j)}else{if(c.prop("checked")){k=b.documentReference.parent}else{k=b.documentReference}}}return XWiki.Model.serialize(k.relativeTo(new XWiki.WikiReference(b.wiki)))};var f=function(k){var j=a("#templateprovider");if(j.length==0){j=a('<input type="hidden" name="templateprovider" id="templateprovider"/>').appendTo(h)}j.attr("value",k)};h.submit(function(){var m=a('input[name="type"]:checked');var l=m.attr("data-type");if(l=="blank"){f("");return true}if(l=="template"){var j=m.val();f(j);return true}if(l=="office"){if(d.length>0&&d.val().trim().length==0){return false}var k=g();if(k!=false){window.location=new XWiki.Document(new XWiki.DocumentReference(b.wiki,["XWiki"],"OfficeImporter")).getURL("view","page="+encodeURIComponent(k))}return false}});var e=function(j){var k=j.attr("data-terminal");var l=false;if(k){l=a.parseJSON(j.attr("data-terminal"))}c.prop("checked",l)};h.find(".xwiki-select").on("xwiki:select:updated",function(k){var j=a('input[name="type"]:checked');e(j)})})});