var TB_Link_Lightbox;((t,i,e,s,o,a,c,_,l)=>{"use strict";var n,r,b;(TB_Link_Lightbox={init(){(i.isFrontend?window.top:window).document.tfOn("click",(async t=>{t.target.classList.contains("tb_add_link")&&(b=t.target.closest('[data-type="url"]'),this.showLightbox())}))},async load(t=1,e=""){i.Spinner.showLoader();try{return await i.LocalFetch({action:"tb_get_pages",page:t,s:e},"html")}catch(t){throw i.Spinner.showLoader("error"),t}},async showLightbox(){const t=i.isFrontend?window.top:window;if(n=t.document.tfClass("tb_link_lightbox")[0])r.classList.remove("tf_hide"),n.classList.remove("tf_hide");else{t.Themify.loadCss(e.builder_url+"css/editor/components/import"),r=s("div",{class:"tb_lightbox_overlay"}),n=s("div",{class:"tb_import_post_lightbox tb_link_lightbox"});const o=s("div",{class:"tb_lightbox_top_bar"}),a=s("div",{class:"tb_lightbox_container tf_scrollbar"}),c=s("div",{class:"tb_import_result"}),_=s("div",{class:"tb_import_search_wrap"}),h=s("input",{placeholder:l.search}),d=s("div",{class:"tb_close_lightbox tf_close"}),p=s("span"),g=async(t=1,e="")=>{i.Spinner.showLoader();const s=await this.load(t,e);a.tfClass("tb_import_result")[0].replaceWith(s),i.Spinner.showLoader("done")};p.textContent=l.cancel,d.appendChild(p),o.appendChild(d),_.appendChild(h),a.append(_,c),n.append(o,a),t.document.body.append(r,n),g(),d.tfOn("click",(()=>{this.close()})),h.tfOn("keyup",(t=>{g(1,h.value)}),{passive:!0}),n.tfOn("click",(t=>{const i=t.target;if(t.preventDefault(),i?.dataset.permalink){const t=b.querySelector('input[type="url"]');t.value=i.dataset.permalink,t.dispatchEvent(new Event("change")),this.close()}else"A"===i?.tagName&&i.classList.contains("page-numbers")&&g(i.textContent,h.value)}))}return n},close(){n.classList.add("tf_hide"),r.classList.add("tf_hide")}}).init()})(document,tb_app,Themify,tb_createElement,tb_createDocumentFragment,themifyBuilder,0,0,themifyBuilder.i18n.label);