define("attachment-validation-mimetype-messages",{prefix:"attachment.validation.mimetype.",keys:["errorMessage","allowedMimetypes","blockerMimetypes"]});
require(["jquery","xwiki-l10n!attachment-validation-mimetype-messages","xwiki-events-bridge"],(e,f)=>{function k(g,b){return g.some(a=>{const c=a.indexOf("*");if(-1===c)return a===b;const d=a.substring(0,c);a=a.substring(c+1,a.length);return b.startsWith(d)&&b.endsWith(a)})}const h={};e(document).on("xwiki:actions:beforeUpload",function(g,b){if(b.documentReference){h[b.documentReference]||e.ajax({url:(new XWiki.Document(XWiki.Model.resolve("XWiki.Attachment.Validation.Code.MimetypeValidation",XWiki.EntityType.DOCUMENT))).getURL("get",
e.param({outputSyntax:"plain",documentReference:b.documentReference})),async:!1,method:"GET",success:function(n){h[b.documentReference]=n}});var a=h[b.documentReference]}else a=document.getElementById("attachment-validation-mimetypes-configuration").textContent;var c=JSON.parse(a),d=b.file.type.toLowerCase();a=c.allowedMimetypes;c=c.blockerMimetypes;const l=0<a.length,m=0<c.length;if(l&&!k(a,d)||m&&k(c,d))d=f.get("errorMessage",b.file.name,d),l&&(d+="\x3cbr/\x3e"+f.get("allowedMimetypes",a)),m&&(d+=
"\x3cbr/\x3e"+f.get("blockerMimetypes",c)),new XWiki.widgets.Notification(d,"error"),g.preventDefault()})});