((e,l,c)=>{"use strict";const t={modal:null,wrap:null,active:!1,url:!1,fr:!1,init(e){this.loader("show"),this.url=("A"===e.tagName?e:e.tfTag("A")[0]).href;const t=l.createElement("div"),a=l.createElement("div"),s=l.createElement("div"),o=l.createElement("div"),i=l.createElement("div"),n=l.createElement("div");return t.id="tf_page_options_modal",t.className="tf_scrollbar",a.className="tf_w tf_h tf_rel",s.className="tf_page_options_toolbar",o.className="tf_page_options_title",o.innerText=c.pg_opt_t,n.className="tf_page_options_save",n.tfOn("click",this.save.bind(this),{passive:!0}).innerText=c.pg_opt_updt,i.tfOn("click",this.close,{once:!0,passive:!0}).className="tf_page_options_close tf_close",s.append(o,n,i),a.appendChild(s),t.appendChild(a),this.wrap=a,this.modal=t,l.body.appendChild(t),this.loadIframe()},loadIframe(){return new Promise((a,e)=>{if(this.active)a();else{const s=l.createElement("iframe");s.className="tf_w tf_h",s.tfOn("load",()=>{this.loader("hide"),this.modal.classList.remove("updating");const e=s.contentDocument,t=e.getElementById("post");t.action="post.php?tf-meta-opts=update",e.body.appendChild(t),e.getElementById("wpwrap").remove(),l.body.className+=" tf_page_options_active",s.contentWindow.document.documentElement.className+=" tf_scrollbar",this.active=!0,a()},{passive:!0,once:!0}).tfOn("error",e,{passive:!0,once:!0}).src=this.url,this.fr=s,this.wrap.appendChild(s)}})},close(){window.location.reload()},save(){this.modal.className+=" updating",this.loader("show"),this.fr.contentDocument.querySelector("#post").submit()},loader(e){if("show"===e){const t=l.createElement("div");t.id="tb_alert",t.className="tb_busy",l.body.appendChild(t)}else{const a=l.tfId("tb_alert");a&&a.remove()}}};e.on("tf_page_options_init",e=>t.init(e),!0)})(Themify,document,themify_vars);