YUI.add("moodle-atto_managefiles-usedfiles",function(d,e){var o="has-missing-files",f="has-unused-files",r=".fitem",u="#atto_managefiles_manageform",m=".missing-files";M.atto_managefiles=M.atto_managefiles||{},M.atto_managefiles.usedfiles=M.atto_managefiles.usedfiles||{_usercontext:null,_itemid:null,_elementid:null,init:function(e){var i,n,t,s,l,a;if(this._usercontext=e.usercontext,this._itemid=e.itemid,this._elementid=e.elementid,e=e.files,(i=d.one(u))&&window.parent)if(n=this._getUsedFiles(),t=this.findUnusedFiles(e,n),s=this.findMissingFiles(e,n),0<t.length?(i.all('input[type=checkbox][name^="deletefile"]').each(function(e){-1===d.Array.indexOf(t,e.getData("filename"))&&e.ancestor(r).remove()}),i.addClass(f)):i.removeClass(f),0<s.length){for(l="<ul>",a=0;a<s.length;a++)l+="<li>"+d.Escape.html(s[a])+"</li>";l+="</ul>",i.one(m).setHTML("").append(l),i.addClass(o)}else i.removeClass(o)},_getUsedFiles:function(){for(var e,i=d.one(window.parent.document.getElementById(this._elementid+"editable")),n=M.cfg.wwwroot+"/draftfile.php/"+this._usercontext+"/user/draft/"+this._itemid+"/",t=new RegExp("[\"']"+n.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")+"(.+?)[\\?\"']","gm"),s={};null!==(e=t.exec(i.get("innerHTML")));)s[decodeURIComponent(e[1])]=!0;return s},findUnusedFiles:function(e,i){var n,t=[];for(n in e)i[n]||t.push(n);return t},findMissingFiles:function(e,i){var n,t=[];for(n in i)e[n]||t.push(n);return t}}},"@VERSION@",{requires:["node","escape"]});