(function(){"use strict";const{useCallback:h}=wp.element;function S({breakpoint:a,isDefault:e,onUpdate:o,onRemove:u,onFocus:s}){const{key:r,name:c,min:p,max:f,isRecent:m}=a,i=h(E=>{o(r,"name",E.target.value)},[r,o]),R=h(E=>{o(r,"max",Number(E.target.value))},[r,o]),j=h(()=>{s(r)},[r,s]),v=h(()=>{u(r)},[r,u]),k=`breakpoint-row ${m?"jltma_cbp-is-recent":""}`;return React.createElement("ul",{className:k,"data-key":r},React.createElement("li",{className:"bp-name","data-label":c},e?React.createElement("input",{type:"text",name:c,value:c,disabled:!0}):React.createElement("input",{type:"text",name:c,value:c,onChange:i,onFocus:j})),React.createElement("li",{className:"bp-min-width"},React.createElement("input",{type:"number",value:p||0,disabled:!0})),React.createElement("li",{className:"bp-max-width"},e?r==="desktop"?React.createElement("input",{type:"number",disabled:!0}):React.createElement("input",{type:"number",value:f||"",disabled:!0}):React.createElement("input",{className:"jlma-mcb-model jlma-mcb-model--max",type:"number",value:f||"",onChange:R,onFocus:j})),React.createElement("li",{className:"bp-actions"},!e&&React.createElement("div",{className:"button button-primary jltma-cbp-remove",onClick:v},React.createElement("span",{className:"dashicons dashicons-trash",style:{marginLeft:"2px"}}))))}function C(){var e;const a=(e=window.jltma_custom_bp_data)==null?void 0:e.upgrade_url;return React.createElement("div",{id:"jltma-mcb-message"},React.createElement("a",{href:a},"Upgrade to Pro")," for Unlimited Options."," ",React.createElement("a",{href:a},"Upgrade Now"))}const _=(a,e="success",o=3e3)=>{const u=document.body;let s=u.querySelector(".jltma-toaster-container");s||(s=document.createElement("div"),s.className="jltma-toaster-container",s.style.zIndex="999999999",u.appendChild(s));const r=document.createElement("div");r.className=`jltma-toaster ${e}`,r.style.cssText=`
            background: ${e==="error"?"linear-gradient(135deg, #f85032 0%, #e73827 100%)":e==="success"?"linear-gradient(135deg, #00b09b 0%, #96c93d 100%)":e==="warning"?"linear-gradient(135deg, #f7971e 0%, #ffd200 100%)":"linear-gradient(135deg, #667eea 0%, #764ba2 100%)"} !important;
            color: #fff !important;
            padding: 16px 24px !important;
            border-radius: 8px !important;
            box-shadow: 0 10px 40px ${e==="error"?"rgba(248, 80, 50, 0.4)":e==="success"?"rgba(0, 176, 155, 0.4)":e==="warning"?"rgba(247, 151, 30, 0.4)":"rgba(102, 126, 234, 0.4)"} !important;
            font-size: 14px !important;
            font-weight: 500 !important;
            min-width: 300px !important;
            max-width: 500px !important;
            text-align: center !important;
            pointer-events: auto !important;
            animation: jltma-toaster-slide-up 0.3s ease-out !important;
            position: relative !important;
            overflow: hidden !important;
            display: flex !important;
            align-items: center !important;
            gap: 10px !important;
            visibility: visible !important;
            opacity: 1 !important;
        `,r.innerHTML=`
            <span style="text-align: left;" class="jltma-toaster-content">${a}</span>
            <button class="jltma-toaster-close"></button>
            <div class="jltma-toaster-progress" style="animation-duration: ${o}ms;"></div>
        `;const c=document.createElement("style");c.textContent=".jltma-toaster::before { display: none !important; }",document.querySelector("style[data-toaster-fix]")||(c.setAttribute("data-toaster-fix","true"),document.head.appendChild(c)),s.appendChild(r),r.offsetHeight,r.querySelector(".jltma-toaster-close").addEventListener("click",()=>{w(r)}),setTimeout(()=>{w(r)},o)},w=a=>{a.classList.add("jltma-toaster-exit"),setTimeout(()=>{a.remove()},300)},B=({ajaxUrl:a})=>{const e=window.jltma_custom_bp_data.reset_nonce,o=u=>{u.preventDefault(),jQuery.ajax({url:a,method:"POST",dataType:"json",data:{security:e,action:"jltma_mcb_reset_settings"},success:()=>{_("Reset Settings"),window.location.reload()},error:s=>{console.error("Save failed:",s)},complete:()=>{}})};return React.createElement("button",{onClick:o,className:"jltma_cbp_button jltma_cbp_button_outline"},"Reset Settings")},I=()=>{const a=e=>{e.preventDefault(),window.open("admin-post.php?action=jltma_mcb_export_settings")};return React.createElement("div",{className:"jltma_cbp_settings_export"},React.createElement("h3",null,"Export"),React.createElement("p",null,"Click the below button to export the breakpoints settings."),React.createElement("button",{className:"jltma_cbp_button",onClick:a},React.createElement("span",{className:"dashicons dashicons-download"}),React.createElement("span",null,"Export")))},{useRef:T,useState:D}=wp.element,M=()=>{const a=T(null),[e,o]=D(!1),u=s=>{s.preventDefault();const r=window.jltma_custom_bp_data.ajaxurl||window.ajaxurl,c=window.jltma_custom_bp_data.import_nonce||"",p=a.current;if(!p||!p.files||!p.files[0]){_("Please select a file to import","error");return}const f=p.files[0];if(!f.name.endsWith(".json")){_("Please upload a valid .json file","error");return}o(!0);const m=new FormData;m.append("action","jltma_cbp_import_elementor_settings"),m.append("security",c),m.append("jltma_mcb",f),jQuery.ajax({url:r,method:"POST",dataType:"json",data:m,processData:!1,contentType:!1,success:i=>{i==="ok"||i.success?(_("Import Successfully"),p.value="",setTimeout(()=>{window.location.reload()},1500)):_("Import failed","error")},error:i=>{console.error("Import failed:",i),_("Import failed. Please try again.","error")},complete:()=>{o(!1)}})};return React.createElement("div",{className:"jltma_cbp_settings_import"},React.createElement("h3",null,"Import"),React.createElement("p",null,"Upload a file to import breakpoints settings."),React.createElement("input",{type:"file",accept:".json",ref:a}),React.createElement("button",{className:"jltma_cbp_button jltma_cbp_button_secondary",style:{marginTop:"12px"},onClick:u,disabled:e},React.createElement("span",{className:"dashicons dashicons-upload"}),React.createElement("span",null,e?"Importing...":"Import")))},P=({isPro:a})=>React.createElement("div",{className:"jltma_cbp_settings"},a?null:React.createElement("div",{className:"jltma_cbp_pro_settings"},React.createElement("a",{href:jltma_custom_bp_data==null?void 0:jltma_custom_bp_data.upgrade_url},React.createElement("span",null,React.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{width:"24px",height:"24px",pointerEvents:"none",marginRight:"2px"}},React.createElement("path",{d:"M11.562 3.266a.5.5 0 0 1 .876 0L15.39 8.87a1 1 0 0 0 1.516.294L21.183 5.5a.5.5 0 0 1 .798.519l-2.834 10.246a1 1 0 0 1-.956.734H5.81a1 1 0 0 1-.957-.734L2.02 6.02a.5.5 0 0 1 .798-.519l4.276 3.664a1 1 0 0 0 1.516-.294z"}),React.createElement("path",{d:"M5 21h14"})),"Upgrade Pro"))),React.createElement(I,null),React.createElement("hr",{style:{marginTop:"16px"}}),React.createElement(M,null)),{useState:x,useMemo:y,useCallback:g}=wp.element,L=["widescreen","desktop","laptop","tablet_extra","tablet","mobile_extra","mobile"];function $({initialData:a}){const[e,o]=x(()=>(a.breakpoints||[]).map(t=>({...t,isRecent:!1}))),[u,s]=x(!1),[r,c]=x(!1),[p,f]=x(!1),m=a.is_pro,i=a.default_devices||L,R=a.ajaxurl||window.ajaxurl,j=y(()=>{let t=e.map(n=>({...n,max:Number(n.max)||0}));return t=t.sort((n,l)=>l.key==="desktop"?-1:n.key==="desktop"?1:n.max<l.max?-1:1),t=t.map((n,l)=>{const d=t[l-1];return n.min=d?d.max+1:0,n.max>0&&n.max<=n.min&&(n.max=n.min+1),n}),t},[e]),v=y(()=>e.filter(t=>!i.includes(t.key)).length,[e,i]);g(()=>m?(s(!1),c(!1),!1):v>0?(s(!0),c(!0),!0):(s(!1),c(!1),!1),[m,v]);const k=g(()=>{if(!m&&e.filter(l=>!i.includes(l.key)).length>0){s(!0),c(!0);return}const t={key:Math.random().toString(36).substr(2,9),name:"New Breakpoint",min:0,max:0,isDraft:!0,isRecent:!0};o(n=>[...n.map(l=>({...l,isRecent:!1})),t])},[m,e,i]),E=g(t=>{o(n=>{const l=n.filter(b=>b.key!==t),d=l.filter(b=>!i.includes(b.key)).length;return!m&&d===0&&(s(!1),c(!1)),l})},[m,i]),A=g((t,n,l)=>{o(d=>d.map(b=>b.key===t?{...b,[n]:l,isRecent:!0}:{...b,isRecent:!1}))},[]),U=g(t=>{o(n=>n.map(l=>({...l,isRecent:l.key===t})))},[]),N=g(()=>e.filter(t=>!i.includes(t.key)).map(t=>({label:t.name,default_value:t.max,direction:"max"})),[e,i]),O=g(t=>{var d;t.preventDefault(),f(!0);const n=N(),l=((d=document.getElementById("breakpoints_form"))==null?void 0:d.value)||"";jQuery.ajax({url:R,method:"POST",data:{form_fields:n,security:l,action:"jltma_mcb_save_settings"},success:()=>{_("Saved Breakpoint Successfully")},error:b=>{console.error("Save failed:",b)},complete:()=>{f(!1)}})},[N,R]);return React.createElement(React.Fragment,null,React.createElement("h2",null,"Elementor Breakpoints Extender"),React.createElement("p",null,React.createElement("em",null,'Set max-width for automatic sorting Breakpoint positions. Make sure click "Save Settings"')),React.createElement("div",{className:"jltma_cbp_wrapper"},React.createElement("div",{className:"jltma_cbp_breakpoints"},React.createElement("div",{id:"master_cbp_table",className:"jltma_cbp_table"},React.createElement("ul",null,React.createElement("li",null,"Device Name"),React.createElement("li",null,"Min-Width"),React.createElement("li",null,"Max-Width"),React.createElement("li",null,"Actions")),j.map(t=>React.createElement(S,{key:t.key,breakpoint:t,isDefault:i.includes(t.key),onUpdate:A,onRemove:E,onFocus:U}))),u&&React.createElement(C,null),React.createElement("div",{className:"jltma_cbp_submit-wrapper"},React.createElement(B,{ajaxUrl:R}),React.createElement("div",{className:"jltma_cbp_right_buttons"},React.createElement("div",{className:`jltma_cbp_button jltma-cbp-add ${r?"jltma-disabled":""}`,onClick:k},"Add Breakpoint"),React.createElement("input",{type:"submit",name:"submit",id:"submit",className:"jltma_cbp_button jltma_cbp_button_secondary jltma-cbp-save",value:p?"Saving...":"Save Breakpoints",onClick:O,disabled:p})))),React.createElement("div",null,React.createElement(P,{isPro:!!m}))))}const{createRoot:F}=wp.element;document.addEventListener("DOMContentLoaded",()=>{const a=document.getElementById("custom_breakpoints_page");a&&window.jltma_custom_bp_data&&F(a).render(React.createElement($,{initialData:window.jltma_custom_bp_data}))})})();
