File: /home/desetmhw/abusedacbuyertrading.site/wp-content/plugins/call-now-button/build/index.js
(()=>{"use strict";var e={n:t=>{var n=t&&t.__esModule?()=>t.default:()=>t;return e.d(n,{a:n}),n},d:(t,n)=>{for(var a in n)e.o(n,a)&&!e.o(t,a)&&Object.defineProperty(t,a,{enumerable:!0,get:n[a]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)};const t=window.React,n=window.wp.domReady;var a=e.n(n);const l=window.wp.element,o=window.wp.url,i=({template:e,handleSelect:n,types:a,displayModes:l})=>(0,t.createElement)("article",{onClick:()=>n(e),className:"cnb-template-container","data-template-id":e.id},(0,t.createElement)("section",null,(0,t.createElement)("header",{className:"cnb-relative",style:{backgroundImage:"url("+e.image+")"}},e.categories.includes("pro")&&(0,t.createElement)("span",{className:"cnb-pro-badge"},"Pro",(0,t.createElement)("br",null),"Required"),l&&e.button.options.displayMode&&(0,t.createElement)("span",{className:"cnb-feature-label"},l[e.button.options.displayMode])),(0,t.createElement)("div",{className:"text-block"},(0,t.createElement)("h3",null,e.name),(0,t.createElement)("p",null,e.description),(0,t.createElement)("p",null,e.button.actions.map((e=>(0,t.createElement)("span",{key:e.id,className:"cnb-feature-label"},((e,t)=>{const n=String(e);return t&&n in t?t[n].name:n})(e.actionType,a)))))))),r=e=>e?Object.fromEntries(Object.entries(e).filter((([e,t])=>null!=t)).map((([e,t])=>[e,t===Object(t)?r(t):t]))):e,c=({template:e,setTemplate:n,nonce:a,ajaxUrl:o,types:c,displayModes:s,domain:d,upgradeLink:m})=>{const u=(0,l.useRef)(),[p,b]=(0,l.useState)(void 0),[E,y]=(0,l.useState)(void 0),[w,g]=(0,l.useState)(!1),[v,h]=(0,l.useState)(void 0),f=e.categories.includes("pro")&&"PRO"!==d?.type,S=e.metadata.map((a=>{const o=(a=>a.fields.map((l=>{const o=e.button.actions.find((e=>e.id===a.id)),i=o[l.name],r=a.id+"-"+l.name;return(0,t.createElement)("tr",{key:r},(0,t.createElement)("th",null,l.line),(0,t.createElement)("td",null,(0,t.createElement)("input",{onChange:t=>((t,a,l)=>{l[a.name]=t.target.value,n({...e})})(t,l,o),type:"editable"===l.type?"text":"",name:l.name,value:i,required:l.required}),(0,t.createElement)("p",{className:"description"},l.description)))})))(a);return(0,t.createElement)(l.Fragment,{key:a.id},a.title&&(0,t.createElement)("tr",null,(0,t.createElement)("th",{colSpan:2},(0,t.createElement)("h3",null,a.title))),o)})),N=e.button.actions.length>1?"Generate buttons":"Generate button";return(0,t.createElement)("div",null,!w&&!v&&(0,t.createElement)("button",{className:"button button-secondary",onClick:()=>n(void 0)},"Back to the templates"),(0,t.createElement)("h2",{ref:u},"Configure template ",(0,t.createElement)("code",null,e.name)),(0,t.createElement)(i,{template:e,types:c,displayModes:s,handleSelect:()=>{}}),f&&(0,t.createElement)("div",{className:"notice notice-inline notice-warning"},(0,t.createElement)("h4",null,"This template uses ",(0,t.createElement)("span",{className:"cnb-pro-badge"},"Pro")," features."),e.proFeatures&&(0,t.createElement)("p",null,e.proFeatures),m&&(0,t.createElement)("p",null,"Start your ",(0,t.createElement)("strong",null,"14 day free trial")," to see this in action! ",(0,t.createElement)("a",{className:"button button-primary button-small",href:m},"Upgrade now"))),(0,t.createElement)("form",{onSubmit:t=>{t.preventDefault();const n={action:"cnb_create_button",_wpnonce_button:a,button:r({...e.button,id:void 0,actions:void 0,conditions:void 0}),actions:r(e.button.actions.map((e=>({...e,id:void 0})))),conditions:r(e.button.conditions?.map((e=>({...e,id:null}))))};return t.target.checkValidity()?(jQuery.post(o,n).done((e=>{y("success"),b("Redirecting to your button..."),h(e.redirect_link),g(!1),setTimeout((()=>window.location=e.redirect_link),1e3)})).fail((e=>{y("error"),b("Something went wrong: "+e),g(!1)})),y("info"),b("Your button is being created..."),g(!0),!1):(y("warning"),b("Please fill out all the fields..."),g(!1),!1)}},(0,t.createElement)("table",{className:"form-table form-table-gallery"},S),!w&&!v&&(0,t.createElement)("button",{type:"submit",className:"button button-primary"},N),w&&(0,t.createElement)("button",{className:"button button-primary components-button is-busy"},"Generating your button..."),v&&(0,t.createElement)("a",{className:"button button-primary",href:v},"Go to your new Button"),p&&(0,t.createElement)("div",{className:"notice notice-inline notice-"+E},(0,t.createElement)("p",null,p))))},s=({templates:e,setTemplate:n,types:a,displayModes:l})=>(0,t.createElement)("section",{className:"cnb-grid cnb-grid-4columns"},e.map((e=>(0,t.createElement)(i,{key:e.id,template:e,types:a,displayModes:l,handleSelect:e=>n(e)})))),d=()=>{window.cnb_templates_init()},m=()=>{const[e,n]=(0,l.useState)(void 0),[a,o]=(0,l.useState)(void 0),[i,r]=(0,l.useState)(void 0),[m,u]=(0,l.useState)(void 0),[p,b]=(0,l.useState)(void 0),[E,y]=(0,l.useState)(void 0),[w,g]=(0,l.useState)(void 0),[v,h]=(0,l.useState)(void 0),f=t=>{n(t.detail.templates),r(t.detail.nonce),u(t.detail.ajaxUrl),b(t.detail.actionTypes),y(t.detail.displayModes),g(t.detail.currentDomain),h(t.detail.upgradeLink);const a=window.location.hash.replace("#t=",""),l=e?.find((e=>e&&e.id===a));l&&o(l)},S=e=>{if(!e||!e?.id)return window.location.hash="",void o(void 0);window.location.hash="#t="+e.id,o(e)};return(0,l.useEffect)((()=>{window.addEventListener("cnb-templates-init",f,{once:!0});const e=setTimeout((()=>{d()}),200);return()=>{clearTimeout(e),window.removeEventListener("cnb-templates-init",f)}}),[]),e?(0,t.createElement)("div",{className:"cnb-templates"},a?(0,t.createElement)(c,{template:a,types:p,displayModes:E,setTemplate:S,nonce:i,ajaxUrl:m,domain:w,upgradeLink:v}):(0,t.createElement)(s,{templates:e,types:p,displayModes:E,setTemplate:S})):(0,t.createElement)("div",null,"Loading the Templates...",(0,t.createElement)("a",{onClick:d},"If nothing happens for a while, click here"))},u=()=>{const e=window.location.search;return(0,o.getQueryArg)(e,"page"),(0,t.createElement)(m,null)};a()((()=>{(0,l.createRoot)(document.getElementById("call-now-button-app")).render((0,t.createElement)(u,null))}))})();