(function(){function i(b){return b.forEach(function(b){b.id=elementorCommon.helpers.getUniqueId(),0<b.elements.length&&i(b.elements)}),b}function b(j,k){var h=k,a=k.model.get("elType"),b=j.tpelecode.elType,c=j.tpelecode,d=JSON.stringify(c),e=/\.(jpg|png|jpeg|gif|svg)/gi.test(d),f={elType:b,settings:c.settings},g=null,o={index:0};"section"===b||"container"===b?(f.elements=i(c.elements),g=elementor.getPreviewContainer()):"column"===b?(f.elements=i(c.elements),"section"===a||"container"===a?g=h.getContainer():"column"===a?(g=h.getContainer().parent,o.index=h.getOption("_index")+1):"widget"===a?(g=h.getContainer().parent.parent,o.index=h.getContainer().parent.view.getOption("_index")+1):void 0):"widget"===b?(f.widgetType=j.tpeletype,g=h.getContainer(),"section"===a||"container"===a?g=h.children.findByIndex(0).getContainer():"column"===a?g=h.getContainer():"widget"===a?(g=h.getContainer().parent,a.index=h.getOption("_index")+1,o.index=h.getOption("_index")+1):void 0):void 0;var m=$e.run("document/elements/create",{model:f,container:g,options:o});e&&jQuery.ajax({url:theplus_cross_cp.ajax_url,method:"POST",data:{nonce:theplus_cross_cp.nonce,action:"plus_cross_cp_import",copy_content:d}}).done(function(c){if(c.success){var a=c.data[0];f.elType=a.elType,f.settings=a.settings,"widget"===f.elType?f.widgetType=a.widgetType:f.elements=a.elements,$e.run("document/elements/delete",{container:m}),$e.run("document/elements/create",{model:f,container:g,options:o})}})}function c(a){try{return JSON.parse(a),!0}catch(a){return!1}}xdLocalStorage.init({iframeUrl:"https://posimyththemes.com/tpcp/",initCallback:function(){}});var d=["section","column","widget","container"],f=[];elementor.on("preview:loaded",function(){d.forEach(function(a,g){elementor.hooks.addFilter("elements/"+d[g]+"/contextMenuGroups",function(a,e){return f.push(e),a.push({name:"plus_"+d[g],actions:[{name:"tp_plus_copy",title:"Plus Copy",icon:"eicon-copy",callback:function(){var a={};a.tpeletype="widget"==d[g]?e.model.get("widgetType"):null,a.tpelecode=e.model.toJSON(),xdLocalStorage.setItem("theplus-c-p-element",JSON.stringify(a)),console.log(a);var b=document.createElement("textarea");b.value=JSON.stringify(a),document.body.appendChild(b),b.select(),document.execCommand("copy"),document.body.removeChild(b)}},{name:"tp_plus_paste",title:"Plus Paste",icon:"eicon-import-kit",callback:function(){if(!navigator.clipboard){var a=document.getElementById("tpae-paste-area-dialog");a&&a.parentNode.removeChild(a);var d=document.querySelector("#tpae-paste-area-input");if(!d){var f=document.createElement("div"),g=document.createElement("p");g.innerHTML="Please grant clipboard permission for smoother copying and pasting.";var h=document.createElement("input");h.id="tpae-paste-area-input",h.type="text",h.setAttribute("autocomplete","off"),h.setAttribute("autofocus","autofocus"),h.focus(),f.appendChild(g),f.appendChild(h),h.addEventListener("paste",async function(a){a.preventDefault();var d=a.clipboardData.getData("text");if(c(d)){var f=JSON.parse(d);d&&"object"==typeof f&&f.tpelecode&&xdLocalStorage.setItem("theplus-c-p-element",d)}xdLocalStorage.getItem("theplus-c-p-element",function(a){if(a&&a.value!==void 0&&a.value&&c(a.value)){var d=JSON.parse(a.value);"object"==typeof d&&d.tpelecode&&b(d,e)}});var g=document.getElementById("tpae-paste-area-dialog");g&&g.parentNode.removeChild(g)});let a="";a=-1==navigator.userAgent.indexOf("Mac OS X")?"Ctrl":"Command";var i=elementorCommon.dialogsManager.createWidget("lightbox",{id:"tpae-paste-area-dialog",headerMessage:`${a} + V`,message:f,position:{my:"center center",at:"center center"},onShow:function(){h.focus(),i.getElements("widgetContent").on("click",function(){h.focus()})},closeButton:!0,closeButtonOptions:{iconClass:"eicon-close"}});i.show()}}else navigator.clipboard.readText().then(function(a){if(c(a)){var d=JSON.parse(a);a&&"object"==typeof d&&d.tpelecode&&xdLocalStorage.setItem("theplus-c-p-element",a)}xdLocalStorage.getItem("theplus-c-p-element",function(a){if(a&&null!=a.value&&a.value&&c(a.value)){var d=JSON.parse(a.value);"object"==typeof d&&d.tpelecode&&b(d,e)}})}).catch(function(a){console.error("Error clipboard data: "+a)})}}]}),a})})})})(jQuery);