(()=>{var t;(t=jQuery)(document).ready((function(){let a=t(".document-library-table");const e=t("#wpadminbar"),o=["doc_categories"],i=data_table_params.language||{};i.processing||(i.processing='<div class="dots-loader"><div class="dot"></div><div class="dot"></div><div class="dot"></div></div>'),a.each((function(){let a=t(this);this.id=a.attr("id");const l="document_library_params_"+this.id.replace(/[^a-zA-Z0-9]/g,"_"),r=window[l];if(!r)return void console.error("Document library params not found for table: "+this.id);let n=r.columns||[];"object"!=typeof n||Array.isArray(n)||(n=Object.values(n));let s=[];n.forEach((t=>{s.push({className:"col-"+t.trimStart(),data:t.trimStart()})}));const d=r.sort_by||"title",c=r.sort_order||"asc";let h=s.findIndex((t=>t.data===d)),u={responsive:!0,processing:!0,serverSide:r.lazy_load,language:i};r.lazy_load?u.order=-1!==h?[[h,c]]:[[0,"asc"]]:u.order=-1!==h?[[h,c]]:[],r.lazy_load&&(u.ajax={url:r.ajax_url,type:"POST",data:{table_id:r.table_id,action:r.ajax_action,category:t(".category-search-"+r.table_id).val(),_ajax_nonce:r.ajax_nonce}}),u.columns=s;let g=a.DataTable(u);a.on("page.dt",(function(){if(!1!==t(this).data("scroll-offset")){let a=t(this).parent().offset().top-t(this).data("scroll-offset");if(e.length){a-=e.outerHeight()||32}t("html,body").animate({scrollTop:a},300)}})),a.on("processing.dt",(function(t,e,o){o?a.find("tbody").addClass("loading"):a.find("tbody").removeClass("loading")})),g.on("preXhr.dt",(function(a,e,o){o.category=t(".category-search-"+r.table_id).val()})),a.data("click-filter")&&a.on("click","a",(function(){if(t(this).hasClass("dlw-lightbox"))return;let a,e=t(this);if(g.cell(e.closest("td").get(0)).index()&&(a=g.cell(e.closest("td").get(0)).index().column),e.closest("td").hasClass("child")){let o=e.closest("li").attr("class").split(" ")[0];a=g.cell(t("td."+o)).index().column}let i=g.column(a).header(),l=t(i).data("name");return-1===o.indexOf(l)||(r.lazy_load?(t(".category-search-"+r.table_id).val(e.text()),g.draw()):g.search(e.text()).draw(),!1)}))})),t(document).on("click",".document-library-table a.dlw-lightbox",(function(a){a.preventDefault(),a.stopPropagation();const e=t(".pswp")[0],o=t(this).find("img");if(o.length<1)return;const i=[{src:o.attr("data-large_image"),w:o.attr("data-large_image_width"),h:o.attr("data-large_image_height"),title:o.attr("data-caption")&&o.attr("data-caption").length?o.attr("data-caption"):o.attr("title")}];return new PhotoSwipe(e,PhotoSwipeUI_Default,i,{index:0,shareEl:!1,closeOnScroll:!1,history:!1,hideAnimationDuration:0,showAnimationDuration:0}).init(),!1}))}))})();