Files
formipay/build/admin.js
dwindown ab69d03f78 fix: React admin icon imports and mount point rendering
- Fix all @wordpress/icons imports - use build/ paths and call as functions
- Update all admin pages to render React mount points
- Components fixed: VariationPricingTable, NotificationLog, GlobalSettings,
  FormFieldOptions, OrderDetail, OrderListItem, OrderList, FormCanvas,
  AnalyticsDashboard, FormField, Products
- Admin pages updated: Order.php, Customer.php, Coupon.php, License.php,
  Product.php, Access.php, Form.php

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-18 13:28:57 +07:00

1 line
42 KiB
JavaScript

(()=>{"use strict";var e={n:t=>{var a=t&&t.__esModule?()=>t.default:()=>t;return e.d(a,{a}),a},d:(t,a)=>{for(var l in a)e.o(a,l)&&!e.o(t,l)&&Object.defineProperty(t,l,{enumerable:!0,get:a[l]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)};const t=window.React,a=window.wp.element,l=window.wp.i18n,n=window.wp.components,r=(0,a.forwardRef)(function({icon:e,size:t=24,...l},n){return(0,a.cloneElement)(e,{width:t,height:t,...l,ref:n})}),i=window.wp["icons/build/list"];var o=e.n(i);const c=window.formipayAdmin?.ajaxUrl||"/wp-admin/admin-ajax.php",s=window.formipayAdmin?.nonce||"";async function m(e,t={}){const a=new FormData;a.append("action",e),a.append("_wpnonce",s),Object.keys(t).forEach(e=>{"object"==typeof t[e]?a.append(e,JSON.stringify(t[e])):a.append(e,t[e])});try{const e=await fetch(c,{method:"POST",credentials:"same-origin",body:a}),t=await e.json();if(!e.ok||!1===t.success)throw new Error(t.message||"Request failed");return t}catch(t){throw console.error(`AJAX error [${e}]:`,t),t}}window.formipayAdmin;const d=window.wp["icons/build/visible"];var p=e.n(d);const u={"on-hold":"#f0ad4e","payment-confirm":"#17a2b8","in-progress":"#17a2b8",shipping:"#6c757d",completed:"#28a745",failed:"#dc3545",refunded:"#6c757d",cancelled:"#dc3545"},f={"on-hold":(0,l.__)("On Hold","formipay"),"payment-confirm":(0,l.__)("Payment Confirmed","formipay"),"in-progress":(0,l.__)("In Progress","formipay"),shipping:(0,l.__)("Shipping","formipay"),completed:(0,l.__)("Completed","formipay"),failed:(0,l.__)("Failed","formipay"),refunded:(0,l.__)("Refunded","formipay"),cancelled:(0,l.__)("Cancelled","formipay")};function y({order:e,onSelect:a}){const n=u[e.status]||"#6c757d",i=f[e.status]||e.status,o=(e=>{if(e.form_data){const t=Object.values(e.form_data).find(e=>e.name&&e.name.includes("name"));return t?.value||"-"}return"-"})(e);return(0,t.createElement)("tr",{className:"formipay-order-item"},(0,t.createElement)("td",null,(0,t.createElement)("strong",null,"#",e.id)),(0,t.createElement)("td",null,(c=e.created_date)?new Date(c).toLocaleDateString():"-"),(0,t.createElement)("td",null,"-"!==o?o:(0,t.createElement)("em",null,"Unknown")),(0,t.createElement)("td",null,(0,t.createElement)("strong",null,e.total_formatted||e.total)),(0,t.createElement)("td",null,(0,t.createElement)("span",{className:"status-badge",style:{backgroundColor:n}},i)),(0,t.createElement)("td",null,(0,t.createElement)("button",{type:"button",className:"button button-small",onClick:a},(0,t.createElement)(r,{icon:p()(),size:16}),(0,l.__)("View","formipay"))));var c}function _({onSelectOrder:e}){const[i,c]=(0,a.useState)([]),[s,d]=(0,a.useState)(!0),[p,u]=(0,a.useState)(0),[f,_]=(0,a.useState)({keyword:"",status:"",date_from:"",date_to:""}),[E,v]=(0,a.useState)({limit:20,offset:0}),b=(0,a.useCallback)(()=>{d(!0),((e={})=>m("formipay_tabledata_orders",e))({keyword:f.keyword,status:f.status,date_from:f.date_from,date_to:f.date_to,limit:E.limit,offset:E.offset}).then(e=>{e.data&&(c(e.data.results||[]),u(e.data.total||0))}).catch(e=>{console.error("Load orders error:",e)}).finally(()=>{d(!1)})},[f,E]);(0,a.useEffect)(()=>{b()},[b]);const g=(e,t)=>{_({...f,[e]:t}),v({...E,offset:0})},h=e=>{v({...E,offset:e})},N={"":(0,l.__)("All Statuses","formipay"),"on-hold":(0,l.__)("On Hold","formipay"),"payment-confirm":(0,l.__)("Payment Confirmed","formipay"),"in-progress":(0,l.__)("In Progress","formipay"),shipping:(0,l.__)("Shipping","formipay"),completed:(0,l.__)("Completed","formipay"),failed:(0,l.__)("Failed","formipay"),refunded:(0,l.__)("Refunded","formipay"),cancelled:(0,l.__)("Cancelled","formipay")},w=Math.ceil(p/E.limit),C=Math.floor(E.offset/E.limit)+1;return(0,t.createElement)("div",{className:"formipay-order-list"},(0,t.createElement)("div",{className:"formipay-orders-header"},(0,t.createElement)("h2",null,(0,t.createElement)(r,{icon:o()()}),(0,l.__)("Orders","formipay")),(0,t.createElement)("span",{className:"order-count"},p," ",(0,l.__)("orders","formipay"))),(0,t.createElement)("div",{className:"formipay-orders-filters"},(0,t.createElement)(n.SearchControl,{value:f.keyword,onChange:e=>{g("keyword",e)},placeholder:(0,l.__)("Search by order ID, customer name, email...","formipay")}),(0,t.createElement)(n.SelectControl,{value:f.status,options:Object.entries(N).map(([e,t])=>({value:e,label:t})),onChange:e=>g("status",e),label:(0,l.__)("Status","formipay")}),(0,t.createElement)("input",{type:"date",value:f.date_from,onChange:e=>g("date_from",e.target.value),className:"formipay-date-input"}),(0,t.createElement)("input",{type:"date",value:f.date_to,onChange:e=>g("date_to",e.target.value),className:"formipay-date-input"}),(f.keyword||f.status||f.date_from||f.date_to)&&(0,t.createElement)(n.Button,{variant:"secondary",onClick:()=>{_({keyword:"",status:"",date_from:"",date_to:""}),v({limit:20,offset:0})}},(0,l.__)("Clear Filters","formipay"))),(0,t.createElement)("div",{className:"formipay-orders-table-wrapper"},s?(0,t.createElement)("div",{className:"formipay-loading"},(0,t.createElement)("span",{className:"spinner is-active"})):0===i.length?(0,t.createElement)("div",{className:"formipay-no-results"},(0,t.createElement)("p",null,(0,l.__)("No orders found","formipay"))):(0,t.createElement)(t.Fragment,null,(0,t.createElement)("table",{className:"formipay-orders-table wp-list-table widefat fixed striped"},(0,t.createElement)("thead",null,(0,t.createElement)("tr",null,(0,t.createElement)("th",null,(0,l.__)("ID","formipay")),(0,t.createElement)("th",null,(0,l.__)("Date","formipay")),(0,t.createElement)("th",null,(0,l.__)("Customer","formipay")),(0,t.createElement)("th",null,(0,l.__)("Total","formipay")),(0,t.createElement)("th",null,(0,l.__)("Status","formipay")),(0,t.createElement)("th",null,(0,l.__)("Actions","formipay")))),(0,t.createElement)("tbody",null,i.map(a=>(0,t.createElement)(y,{key:a.id,order:a,onSelect:()=>e?.(a.id)})))),w>1&&(0,t.createElement)("div",{className:"formipay-pagination"},(0,t.createElement)(n.Button,{variant:"secondary",disabled:1===C,onClick:()=>h(E.offset-E.limit)},(0,l.__)("Previous","formipay")),(0,t.createElement)("span",{className:"pagination-info"},(0,l.__)("Page","formipay")," ",C," ",(0,l.__)("of","formipay")," ",w),(0,t.createElement)(n.Button,{variant:"secondary",disabled:C===w,onClick:()=>h(E.offset+E.limit)},(0,l.__)("Next","formipay"))))))}const E=window.wp["icons/build/arrowLeft"];var v=e.n(E);const b=window.wp["icons/build/trash"];var g=e.n(b);const h=["on-hold","payment-confirm","in-progress","shipping","completed"],N={"on-hold":(0,l.__)("On Hold","formipay"),"payment-confirm":(0,l.__)("Payment Confirmed","formipay"),"in-progress":(0,l.__)("In Progress","formipay"),shipping:(0,l.__)("Shipping","formipay"),completed:(0,l.__)("Completed","formipay"),failed:(0,l.__)("Failed","formipay"),refunded:(0,l.__)("Refunded","formipay"),cancelled:(0,l.__)("Cancelled","formipay")};function w({orderId:e}){const[n,r]=(0,a.useState)([]);return(0,a.useEffect)(()=>{const e=[{status:"on-hold",date:(new Date).toISOString(),note:(0,l.__)("Order placed","formipay")}];r(e)},[e]),(0,t.createElement)("div",{className:"formipay-order-timeline"},(0,t.createElement)("h3",null,(0,l.__)("Order Timeline","formipay")),(0,t.createElement)("div",{className:"timeline-progress"},h.map((e,a)=>(0,t.createElement)("div",{key:e,className:`timeline-step ${0===a?"first":""} ${a===h.length-1?"last":""}`},(0,t.createElement)("div",{className:"timeline-dot"}),a<h.length-1&&(0,t.createElement)("div",{className:"timeline-line"}),(0,t.createElement)("span",{className:"timeline-label"},N[e])))),(0,t.createElement)("div",{className:"timeline-events"},0===n.length?(0,t.createElement)("p",{className:"no-events"},(0,l.__)("No timeline events yet","formipay")):(0,t.createElement)("ul",null,n.map((e,a)=>(0,t.createElement)("li",{key:a},(0,t.createElement)("span",{className:"event-status"},N[e.status]||e.status),(0,t.createElement)("span",{className:"event-date"},new Date(e.date).toLocaleString()),e.note&&(0,t.createElement)("span",{className:"event-note"},e.note))))))}const C=window.wp["icons/build/bell"];var k=e.n(C);const S=window.wp["icons/build/message"];var D=e.n(S);function x(){const e=[{id:1,type:"email",recipient:"customer@example.com",subject:"Order Confirmation",status:"sent",date:(new Date).toISOString()}],a=e=>{switch(e){case"email":default:return k()();case"sms":case"whatsapp":return D()()}};return(0,t.createElement)("div",{className:"formipay-notification-log"},(0,t.createElement)("h3",null,(0,t.createElement)(r,{icon:k()(),size:18}),(0,l.__)("Notification Log","formipay")),0===e.length?(0,t.createElement)("p",{className:"no-logs"},(0,l.__)("No notifications sent yet","formipay")):(0,t.createElement)("ul",{className:"notification-list"},e.map(e=>(0,t.createElement)("li",{key:e.id,className:`notification-item ${e.status}`},(0,t.createElement)("div",{className:"notification-icon"},(0,t.createElement)(r,{icon:a(e.type),size:20})),(0,t.createElement)("div",{className:"notification-content"},(0,t.createElement)("div",{className:"notification-header"},(0,t.createElement)("span",{className:"notification-type"},e.type.toUpperCase()),(0,t.createElement)("span",{className:"notification-status"},e.status)),(0,t.createElement)("div",{className:"notification-details"},(0,t.createElement)("strong",null,e.subject||e.type),(0,t.createElement)("span",{className:"notification-recipient"},(0,l.__)("To:","formipay")," ",e.recipient)),(0,t.createElement)("div",{className:"notification-date"},new Date(e.date).toLocaleString()))))))}const O=[{value:"on-hold",label:(0,l.__)("On Hold","formipay")},{value:"payment-confirm",label:(0,l.__)("Payment Confirmed","formipay")},{value:"in-progress",label:(0,l.__)("In Progress","formipay")},{value:"shipping",label:(0,l.__)("Shipping","formipay")},{value:"completed",label:(0,l.__)("Completed","formipay")},{value:"failed",label:(0,l.__)("Failed","formipay")},{value:"refunded",label:(0,l.__)("Refunded","formipay")},{value:"cancelled",label:(0,l.__)("Cancelled","formipay")}];function P({orderId:e,onBack:i}){const[o,c]=(0,a.useState)(null),[s,d]=(0,a.useState)(!0),[p,u]=(0,a.useState)(!1),[f,y]=(0,a.useState)(""),_=(0,a.useCallback)(()=>{d(!0),(e=>m("formipay_get_order",{order_id:e}))(e).then(e=>{e.data&&(c(e.data),y(e.data.status))}).catch(e=>{console.error("Load order error:",e)}).finally(()=>{d(!1)})},[e]);return(0,a.useEffect)(()=>{_()},[_]),s?(0,t.createElement)("div",{className:"formipay-order-detail"},(0,t.createElement)("div",{className:"formipay-loading"},(0,t.createElement)("span",{className:"spinner is-active"}))):o?(0,t.createElement)("div",{className:"formipay-order-detail"},(0,t.createElement)("div",{className:"formipay-detail-header"},(0,t.createElement)(n.Button,{variant:"secondary",onClick:i},(0,t.createElement)(r,{icon:v()(),size:16}),(0,l.__)("Back","formipay")),(0,t.createElement)("h1",null,(0,l.__)("Order","formipay")," #",o.id),(0,t.createElement)("div",{className:"header-actions"},(0,t.createElement)(n.Button,{variant:"secondary",isDestructive:!0,onClick:()=>{var t;confirm((0,l.__)("Are you sure you want to delete this order?","formipay"))&&(t=[e],m("formipay_bulk_delete_order",{ids:t})).then(e=>{e.success&&i?.()}).catch(e=>{console.error("Delete order error:",e)})}},(0,t.createElement)(r,{icon:g()(),size:16}),(0,l.__)("Delete","formipay")))),(0,t.createElement)("div",{className:"formipay-detail-content"},(0,t.createElement)("div",{className:"formipay-detail-main"},(0,t.createElement)("div",{className:"formipay-detail-card"},(0,t.createElement)("h3",null,(0,l.__)("Order Details","formipay")),(0,t.createElement)("dl",{className:"detail-list"},(0,t.createElement)("div",null,(0,t.createElement)("dt",null,(0,l.__)("Status","formipay")),(0,t.createElement)("dd",null,(0,t.createElement)(n.SelectControl,{value:f,options:O,onChange:y,disabled:p}),f!==o.status&&(0,t.createElement)(n.Button,{variant:"primary",size:"small",onClick:()=>{f&&f!==o.status&&(u(!0),((e,t)=>m("formipay_update_order_status",{order_id:e,status:t}))(e,f).then(e=>{(e.success||e.data?.valid)&&_()}).catch(e=>{console.error("Update status error:",e)}).finally(()=>{u(!1)}))},disabled:p,isBusy:p},p?(0,l.__)("Updating...","formipay"):(0,l.__)("Update Status","formipay")))),(0,t.createElement)("div",null,(0,t.createElement)("dt",null,(0,l.__)("Date Created","formipay")),(0,t.createElement)("dd",null,(E=o.created_date)?new Date(E).toLocaleString():"-")),(0,t.createElement)("div",null,(0,t.createElement)("dt",null,(0,l.__)("Form ID","formipay")),(0,t.createElement)("dd",null,o.form_id)),(0,t.createElement)("div",null,(0,t.createElement)("dt",null,(0,l.__)("Payment Gateway","formipay")),(0,t.createElement)("dd",null,o.payment_gateway||"-")))),(0,t.createElement)("div",{className:"formipay-detail-card"},(0,t.createElement)("h3",null,(0,l.__)("Items","formipay")),(0,t.createElement)("table",{className:"items-table"},(0,t.createElement)("thead",null,(0,t.createElement)("tr",null,(0,t.createElement)("th",null,(0,l.__)("Item","formipay")),(0,t.createElement)("th",null,(0,l.__)("Qty","formipay")),(0,t.createElement)("th",null,(0,l.__)("Subtotal","formipay")))),(0,t.createElement)("tbody",null,o.items?.map((e,a)=>(0,t.createElement)("tr",{key:a},(0,t.createElement)("td",null,(0,t.createElement)("strong",null,e.item),e.description&&(0,t.createElement)("small",null,e.description)),(0,t.createElement)("td",null,e.qty||1),(0,t.createElement)("td",null,e.subtotal_formatted||e.subtotal)))||(0,t.createElement)("tr",null,(0,t.createElement)("td",{colSpan:"3",className:"text-center"},(0,l.__)("No items","formipay")))),(0,t.createElement)("tfoot",null,(0,t.createElement)("tr",null,(0,t.createElement)("td",{colSpan:"2"},(0,t.createElement)("strong",null,(0,l.__)("Total","formipay"))),(0,t.createElement)("td",null,(0,t.createElement)("strong",null,o.total_formatted||o.total))))))),(0,t.createElement)("div",{className:"formipay-detail-sidebar"},(0,t.createElement)("div",{className:"formipay-detail-card"},(0,t.createElement)("h3",null,(0,l.__)("Customer Information","formipay")),o.form_data?(0,t.createElement)("dl",{className:"customer-info"},Object.entries(o.form_data).map(([e,a])=>["payment","payment_gateway","coupon_code","qty"].includes(e)?null:(0,t.createElement)("div",{key:e},(0,t.createElement)("dt",null,e.replace(/_/g," ")),(0,t.createElement)("dd",null,a?.value||a||"-")))):(0,t.createElement)("p",{className:"no-data"},(0,l.__)("No customer data available","formipay"))),(0,t.createElement)(w,{orderId:e}),(0,t.createElement)(x,null)))):(0,t.createElement)("div",{className:"formipay-order-detail"},(0,t.createElement)("div",{className:"formipay-error"},(0,t.createElement)("p",null,(0,l.__)("Order not found","formipay")),(0,t.createElement)(n.Button,{variant:"secondary",onClick:i},(0,t.createElement)(r,{icon:v()(),size:16}),(0,l.__)("Back to Orders","formipay"))));var E}const F=window.wp["icons/build/plus"];var A=e.n(F);const I=window.wp["icons/build/minus"];var U=e.n(I);const T=window.wp["icons/build/eyeClosed"];var j=e.n(T);const L=window.wp["icons/build/eyeOpened"];var q=e.n(L);function z({productId:e,productDetails:n}){const[r,i]=(0,a.useState)([]),[o,c]=(0,a.useState)([]),[s,m]=(0,a.useState)(!0),d=(0,a.useRef)(null),p=(0,a.useRef)(null),u=(0,a.useRef)(null),f=(0,a.useCallback)(()=>String(n?.default_currency||"").split(":::")[0]||n?.default_currency_code||"USD",[n]),y=(0,a.useCallback)(e=>{const t=n?.global_currencies||[],a=String(e).split(":::")[0],l=t.find(e=>String(e.currency).split(":::")[0]===a);return parseInt(l?.decimal_digits,10)||2},[n]),_=(0,a.useCallback)(()=>{const e=n?.global_selected_currencies||{};let t=Object.keys(e);if(!t.length){const e=n?.default_currency||"";e&&(t=[e])}return t.map(e=>{const t=String(e).split(":::")[0];return{currency:e,regular_price:"",sale_price:"",currency_decimal_digits:y(t)}})},[n,y]),E=(0,a.useCallback)(e=>{const t={...e};void 0===t.expanded&&(t.expanded=!1);const a=_(),l=e=>String(e).split(":::")[0];if(Array.isArray(t.prices)){const e=new Set(a.map(e=>l(e.currency)));t.prices=t.prices.filter(t=>t&&e.has(l(t.currency))),a.forEach(e=>{const a=l(e.currency);t.prices.some(e=>l(e.currency)===a)||t.prices.push(JSON.parse(JSON.stringify(e)))})}else t.prices=JSON.parse(JSON.stringify(a));Array.isArray(t.prices)&&0!==t.prices.length||(t.prices=JSON.parse(JSON.stringify(a))),t.prices.forEach(e=>{const t=l(e.currency);e.currency_decimal_digits=y(t),void 0!==e.regular_price&&null!==e.regular_price||(e.regular_price=""),void 0!==e.sale_price&&null!==e.sale_price||(e.sale_price="")});const n=f();return t.prices.sort((e,t)=>l(e.currency)===n?-1:l(t.currency)===n?1:0),delete t.price,delete t.sale,t},[_,y,f]),v=(0,a.useCallback)(()=>new Promise(e=>{let t=0;const a=setInterval(()=>{const l=document.querySelector('input[name="product_variation_attributes"]');if(l&&l.value)try{const t=JSON.parse(l.value);clearInterval(a),e(Array.isArray(t)?t:[])}catch(t){clearInterval(a),e([])}else++t>=100&&(clearInterval(a),e([]))},50)}),[]),b=(0,a.useCallback)(e=>{const t=e.map(e=>(e.attribute_variations||[]).map(e=>({label:e.variation_label}))).filter(e=>e.length>0);return t.length?t.reduce((e,t)=>e.flatMap(e=>t.map(t=>[].concat(e,t)))).map(e=>{const t=Array.isArray(e)?e.map(e=>e.label):[e.label];return{key:t.join("||"),label:t.join(" - ")}}):[]},[]),g=(0,a.useCallback)(async()=>{try{const e=await v();if(!e.length)return i([]),void h([]);const t=b(e).filter(e=>!o.includes(e.key)).map(e=>{const t=r.find(t=>t.key===e.key);return t?Object.assign(E(t),{name:e.label}):E({key:e.key,name:e.label,stock:"",weight:0,active:!0})});i(t),h(t)}catch(e){console.warn("Attributes not available; initializing empty variations."),i([]),h([])}},[v,b,o,r,E]),h=(0,a.useCallback)(e=>{d.current&&(d.current.value=JSON.stringify(e||[]))},[]),N=(0,a.useCallback)(async()=>{if(e)try{const t=new FormData;t.append("action","get_product_variables"),t.append("post_id",e),t.append("_wpnonce",window.formipayAdmin?.nonce||"");const a=await fetch(window.formipayAdmin?.ajaxUrl||"/wp-admin/admin-ajax.php",{method:"POST",credentials:"same-origin",body:t}),l=await a.json();if(l.success&&Array.isArray(l.data)&&l.data.length){const e=l.data.map(e=>E(e));i(e),c([]),h(e)}else await g()}catch{await g()}else await g()},[e,E,g,h]),w=(0,a.useCallback)(()=>{const e=()=>{setTimeout(()=>{g()},200)},t=document.querySelector('input[name="product_variation_attributes"]');if(t){t.addEventListener("input",e),t.addEventListener("change",e);const a=new MutationObserver(e);a.observe(t,{attributes:!0,attributeFilter:["value"]}),u.current=a,p.current=setInterval(()=>{const t=document.querySelector('input[name="product_variation_attributes"]');t&&t.value!==d.current?.value&&e()},300)}return()=>{u.current&&u.current.disconnect(),p.current&&clearInterval(p.current)}},[g]);(0,a.useEffect)(()=>{const e=n?.multicurrency,t=n?.global_selected_currencies||{},a=Object.keys(t).length;return m(!e||a<=1),N(),w()},[n,N,w]);const C=(0,a.useCallback)((e,t,a,l)=>{const n=[...r];n[e].prices[t][a]=l,i(n),h(n)},[r,h]),k=(0,a.useCallback)(e=>{const t=[...r];t[e].expanded=!t[e].expanded,i(t)},[r]),S=(0,a.useCallback)((e,t,a)=>{const l=[...r];l[e][t]=a,i(l),h(l)},[r,h]),D=(0,a.useCallback)(e=>{const t=r[e],a=[...o,t.key];c(a);const l=r.filter((t,a)=>a!==e);i(l),h(l)},[r,o,h]),x=(0,a.useCallback)(()=>{const e=f();for(const t of r){const a=t.prices?.find(t=>String(t.currency).split(":::")[0]===e);if(!a||!a.regular_price)return{currencyCode:e,rowLabel:t.name}}return null},[r,f]);return(0,a.useEffect)(()=>{const e=document.getElementById("post");if(!e)return;const t=e=>{const t=x();if(t){e.preventDefault(),e.stopImmediatePropagation();const a=(n?.variation_table?.error_missing_default_price||'Please fill Regular Price for default currency (%1$s) in variation "%2$s".').replace("%1$s",t.currencyCode).replace("%2$s",t.rowLabel);return alert(a),!1}};return e.addEventListener("submit",t,!0),()=>e.removeEventListener("submit",t,!0)},[x,n]),(0,t.createElement)(t.Fragment,null,(0,t.createElement)("input",{ref:d,type:"hidden",name:"product_variation_variables",value:JSON.stringify(r)}),(0,t.createElement)("table",{className:"formipay-variation-table",id:"product-variables-table"},(0,t.createElement)("thead",null,(0,t.createElement)("tr",null,(0,t.createElement)("th",null,(0,l.__)("Variation","formipay")),s?(0,t.createElement)(t.Fragment,null,(0,t.createElement)("th",null,(0,l.__)("Price","formipay")),(0,t.createElement)("th",null,(0,l.__)("Sale Price","formipay"))):null,(0,t.createElement)("th",null,(0,l.__)("Stock","formipay")),(0,t.createElement)("th",null,(0,l.__)("Weight","formipay")),(0,t.createElement)("th",null,(0,l.__)("Actions","formipay")))),(0,t.createElement)("tbody",null,r.map((e,a)=>(0,t.createElement)(B,{key:e.key,row:e,rowIndex:a,showFlatPricing:s,defaultCurrencyCode:f(),onToggleExpanded:()=>k(a),onUpdatePrice:(e,t,l)=>C(a,e,t,l),onUpdateField:(e,t)=>S(a,e,t),onDelete:()=>D(a)})))))}function B({row:e,rowIndex:a,showFlatPricing:i,defaultCurrencyCode:o,onToggleExpanded:c,onUpdatePrice:s,onUpdateField:m,onDelete:d}){return(0,t.createElement)(t.Fragment,null,(0,t.createElement)("tr",{className:"variation-row"},(0,t.createElement)("td",{className:"variation-name"},(0,t.createElement)("button",{type:"button",className:"toggle-expand",onClick:c},(0,t.createElement)(r,{icon:e.expanded?q():j(),size:16})),(0,t.createElement)("strong",null,e.name)),i?(0,t.createElement)(t.Fragment,null,(0,t.createElement)(M,{price:e.prices[0],field:"regular_price",onChange:(e,t)=>s(0,e,t)}),(0,t.createElement)(M,{price:e.prices[0],field:"sale_price",onChange:(e,t)=>s(0,e,t)})):null,(0,t.createElement)("td",{className:"variation-stock"},(0,t.createElement)(n.TextControl,{type:"number",value:e.stock,onChange:e=>m("stock",e),placeholder:"Unlimited"})),(0,t.createElement)("td",{className:"variation-weight"},(0,t.createElement)(n.TextControl,{type:"number",value:e.weight,onChange:e=>m("weight",e),step:"0.01"})),(0,t.createElement)("td",{className:"variation-actions"},(0,t.createElement)(n.Button,{variant:"secondary",size:"small",isDestructive:!0,onClick:d,icon:U()()},(0,l.__)("Delete","formipay")))),!i&&e.expanded&&(0,t.createElement)("tr",{className:"variation-details-row"},(0,t.createElement)("td",{colSpan:"5"},(0,t.createElement)("table",{className:"inner-table"},(0,t.createElement)("tbody",null,e.prices.map((e,a)=>{const l=String(e.currency).split(":::")[0]===o,n=e.currency_decimal_digits?1/Math.pow(10,e.currency_decimal_digits):.01;return(0,t.createElement)("tr",{key:a},(0,t.createElement)("td",{className:"currency-name"},e.currency,l&&(0,t.createElement)("span",{className:"required"},"*")),(0,t.createElement)("td",null,(0,t.createElement)("input",{type:"number",value:e.regular_price,onChange:e=>s(a,"regular_price",e.target.value),step:n,placeholder:"Regular Price",required:l})),(0,t.createElement)("td",null,(0,t.createElement)("input",{type:"number",value:e.sale_price,onChange:e=>s(a,"sale_price",e.target.value),step:n,placeholder:"Sale Price"})))}))))))}function M({price:e,field:a,onChange:l}){const n=e.currency_decimal_digits?1/Math.pow(10,e.currency_decimal_digits):.01;return(0,t.createElement)("td",{className:"price-cell"},(0,t.createElement)("input",{type:"number",value:e[a],onChange:e=>l(a,e.target.value),step:n,placeholder:"Auto"}))}const R={text:{label:"Text",icon:"text",category:"input"},url:{label:"URL",icon:"link",category:"input"},email:{label:"Email",icon:"email",category:"input"},tel:{label:"Telephone",icon:"phone",category:"input"},number:{label:"Number",icon:"number",category:"input"},date:{label:"Date",icon:"calendar",category:"input"},datetime:{label:"Date & Time",icon:"calendar-alt",category:"input"},color:{label:"Color",icon:"art",category:"input"},select:{label:"Select Dropdown",icon:"list-view",category:"choice"},checkbox:{label:"Checkbox",icon:"checkbox",category:"choice"},radio:{label:"Radio",icon:"radio",category:"choice"},hidden:{label:"Hidden",icon:"hidden",category:"advanced"},textarea:{label:"Textarea",icon:"document",category:"input"},divider:{label:"Divider",icon:"minus",category:"layout"},page_break:{label:"Page Break",icon:"page-break",category:"layout"},country_list:{label:"Preset: Country List",icon:"globe",category:"preset"}},$={input:{label:"Input Fields",order:1},choice:{label:"Choice Fields",order:2},layout:{label:"Layout",order:3},preset:{label:"Presets",order:4},advanced:{label:"Advanced",order:5}},J={field_type:"text",label:"",field_id:"",placeholder:"",default_value:"",description:"",is_required:!1,field_options:[],option_grid_columns:1},H=window.wp["icons/build/chevronUp"];var V=e.n(H);const G=window.wp["icons/build/chevronDown"];var Q=e.n(G);function W({field:e,index:a,isSelected:n,onSelect:i,onUpdate:o,onMoveUp:c,onMoveDown:s,onDelete:m,onDragStart:d,onDragOver:p,onDrop:u}){const f=R[e.field_type]||R.text,y=["select","checkbox","radio"].includes(e.field_type);return(0,t.createElement)("div",{className:"formipay-field-item "+(n?"is-selected":""),draggable:!0,onDragStart:d,onDragOver:p,onDrop:u,onClick:i},(0,t.createElement)("div",{className:"formipay-field-header"},(0,t.createElement)("div",{className:"formipay-field-info"},(0,t.createElement)("span",{className:"field-type-badge"},f.label),(0,t.createElement)("span",{className:"field-id"},"#",e.field_id||a)),(0,t.createElement)("div",{className:"formipay-field-actions"},(0,t.createElement)("button",{type:"button",className:"button-icon",onClick:e=>{e.stopPropagation(),c?.()},disabled:!c,title:(0,l.__)("Move Up","formipay")},(0,t.createElement)(r,{icon:V()(),size:16})),(0,t.createElement)("button",{type:"button",className:"button-icon",onClick:e=>{e.stopPropagation(),s?.()},disabled:!s,title:(0,l.__)("Move Down","formipay")},(0,t.createElement)(r,{icon:Q()(),size:16})),(0,t.createElement)("button",{type:"button",className:"button-icon button-danger",onClick:e=>{e.stopPropagation(),m?.()},title:(0,l.__)("Delete","formipay")},(0,t.createElement)(r,{icon:g()(),size:16})))),(0,t.createElement)("div",{className:"formipay-field-content"},(0,t.createElement)("div",{className:"field-label-row"},(0,t.createElement)("strong",null,e.label||(0,t.createElement)("em",null,"Untitled")),e.is_required&&(0,t.createElement)("span",{className:"required-badge"},(0,l.__)("Required","formipay"))),e.description&&(0,t.createElement)("p",{className:"field-description"},e.description),y&&e.field_options&&e.field_options.length>0&&(0,t.createElement)("div",{className:"field-options-preview"},(0,t.createElement)("small",null,e.field_options.length," ",(0,l.__)("options","formipay"))),(0,t.createElement)("div",{className:"field-meta"},e.placeholder&&(0,t.createElement)("span",{className:"meta-item"},'Placeholder: "',e.placeholder,'"'),e.default_value&&(0,t.createElement)("span",{className:"meta-item"},'Default: "',e.default_value,'"'))))}function X({fields:e=[],selectedFieldId:a,onDrop:n,onSelectField:i,onUpdateField:o,onMoveField:c,onDeleteField:s}){const m=(t,a)=>{const l=[...e],[n]=l.splice(t,1);l.splice(a,0,n),c?.(l)};return(0,t.createElement)("div",{className:"formipay-form-canvas"},(0,t.createElement)("div",{className:"formipay-canvas-header"},(0,t.createElement)("h3",null,(0,l.__)("Form Fields","formipay")),(0,t.createElement)("span",{className:"field-count"},e.length," ",(0,l.__)("fields","formipay"))),(0,t.createElement)("div",{className:"formipay-canvas-area "+(0===e.length?"is-empty":""),onDragOver:e=>{e.preventDefault(),e.dataTransfer.dropEffect="copy"},onDrop:e=>{e.preventDefault();const t=e.dataTransfer.getData("formipay-field-type");if(!t)return;const a={...J,field_type:t,field_id:(l=t.replace("_"," "),`${l.toLowerCase().replace(/[^a-z0-9]/g,"_")}_${Date.now().toString(36)}`),label:t.replace("_"," ").replace(/\b\w/g,e=>e.toUpperCase())};var l;n?.(a)}},0===e.length?(0,t.createElement)("div",{className:"formipay-empty-state"},(0,t.createElement)(r,{icon:A()(),size:48}),(0,t.createElement)("p",null,(0,l.__)("Drag fields from the palette to build your form","formipay"))):(0,t.createElement)("div",{className:"formipay-fields-list"},e.map((l,n)=>(0,t.createElement)(W,{key:l.field_id,field:l,index:n,isSelected:a===l.field_id,onSelect:()=>i?.(l.field_id),onUpdate:e=>o?.(l.field_id,e),onMoveUp:n>0?()=>m(n,n-1):null,onMoveDown:n<e.length-1?()=>m(n,n+1):null,onDelete:()=>s?.(l.field_id),onDragStart:e=>{e.dataTransfer.effectAllowed="move",e.dataTransfer.setData("formipay-field-index",n.toString())},onDragOver:e=>{e.preventDefault(),e.dataTransfer.dropEffect="move"},onDrop:e=>{e.preventDefault();const t=parseInt(e.dataTransfer.getData("formipay-field-index"));isNaN(t)||t===n||m(t,n)}})))))}function K({onDragStart:e}){const a=function(){const e={};return Object.entries(R).forEach(([t,a])=>{e[a.category]||(e[a.category]=[]),e[a.category].push({type:t,...a})}),e}(),n=Object.values($).sort((e,t)=>e.order-t.order);return(0,t.createElement)("div",{className:"formipay-field-palette"},(0,t.createElement)("h3",null,(0,l.__)("Add Field","formipay")),n.map(l=>{const n=a[l.label]||[];return 0===n.length?null:(0,t.createElement)("div",{key:l.label,className:"formipay-palette-category"},(0,t.createElement)("h4",null,l.label),(0,t.createElement)("div",{className:"formipay-palette-items"},n.map(a=>(0,t.createElement)("div",{key:a.type,className:"formipay-palette-item",draggable:!0,onDragStart:t=>{return l=t,n=a.type,l.dataTransfer.effectAllowed="copy",l.dataTransfer.setData("formipay-field-type",n),void e?.(n);var l,n},title:a.label},(0,t.createElement)(r,{icon:a.icon}),(0,t.createElement)("span",null,a.label)))))}))}function Y({options:e=[],onChange:a,fieldType:i}){const o=(t,l)=>{const n=[...e];n[t]={...n[t],...l},a(n)},c="checkbox"===i;return(0,t.createElement)("div",{className:"formipay-field-options"},(0,t.createElement)("div",{className:"formipay-options-header"},(0,t.createElement)("label",null,c?(0,l.__)("Checkbox Options","formipay"):"radio"===i?(0,l.__)("Radio Options","formipay"):(0,l.__)("Select Options","formipay")),(0,t.createElement)(n.Button,{variant:"secondary",size:"compact",onClick:()=>{a([...e,{label:"",value:"",amount:"",weight:"",quantity:!1}])},icon:(0,t.createElement)(r,{icon:A()(),size:16})},(0,l.__)("Add Option","formipay"))),(0,t.createElement)("div",{className:"formipay-options-list"},e.map((i,c)=>(0,t.createElement)("div",{key:c,className:"formipay-option-item"},(0,t.createElement)("div",{className:"formipay-option-fields"},(0,t.createElement)(n.TextControl,{label:(0,l.__)("Label","formipay"),value:i.label||"",onChange:e=>o(c,{label:e}),placeholder:(0,l.__)("Option label","formipay")}),(0,t.createElement)(n.TextControl,{label:(0,l.__)("Value","formipay"),value:i.value||"",onChange:e=>o(c,{value:e}),placeholder:(0,l.__)("Optional custom value","formipay")}),(0,t.createElement)(n.TextControl,{label:(0,l.__)("Amount","formipay"),type:"number",value:i.amount||"",onChange:e=>o(c,{amount:e}),placeholder:(0,l.__)("0","formipay"),step:"0.01"})),(0,t.createElement)("div",{className:"formipay-option-actions"},(0,t.createElement)(n.Button,{variant:"tertiary",size:"compact",onClick:()=>(t=>{const l=e.filter((e,a)=>a!==t);a(l)})(c),icon:(0,t.createElement)(r,{icon:g()(),size:16}),label:(0,l.__)("Delete Option","formipay")})))),0===e.length&&(0,t.createElement)("div",{className:"formipay-no-options"},(0,t.createElement)("p",null,(0,l.__)('No options added yet. Click "Add Option" to create one.',"formipay")))))}function Z({field:e,open:a,onClose:r,onUpdate:i}){if(!a||!e)return null;const o=R[e.field_type]||R.text,c=["select","checkbox","radio"].includes(e.field_type),s=["text","url","email","tel","number","date","datetime","color","select","checkbox","radio","hidden","textarea","country_list"].includes(e.field_type),m=["text","url","email","tel","number","date","datetime","color","select","checkbox","radio","hidden","textarea"].includes(e.field_type),d=!["hidden"].includes(e.field_type),p=!["divider","page_break","hidden"].includes(e.field_type),u=["radio","checkbox"].includes(e.field_type),f=(t,a)=>{i?.({...e,[t]:a})};return(0,t.createElement)("div",{className:"formipay-field-settings-panel"},(0,t.createElement)("div",{className:"formipay-settings-header"},(0,t.createElement)("h3",null,(0,t.createElement)("span",{className:"field-type-badge"},o.label),(0,l.__)("Field Settings","formipay")),(0,t.createElement)("button",{type:"button",className:"button-link",onClick:r},(0,l.__)("Close","formipay"))),(0,t.createElement)("div",{className:"formipay-settings-content"},(0,t.createElement)(n.TextControl,{label:(0,l.__)("Label","formipay"),value:e.label||"",onChange:e=>f("label",e),help:(0,l.__)("The display label for this field","formipay")}),(0,t.createElement)(n.TextControl,{label:(0,l.__)("Field ID","formipay"),value:e.field_id||"",onChange:e=>f("field_id",e),help:(0,l.__)("Unique identifier for this field (used in form data)","formipay")}),s&&(0,t.createElement)(n.TextControl,{label:(0,l.__)("Placeholder","formipay"),value:e.placeholder||"",onChange:e=>f("placeholder",e)}),m&&(0,t.createElement)(n.TextControl,{label:(0,l.__)("Default Value","formipay"),value:e.default_value||"",onChange:e=>f("default_value",e)}),d&&(0,t.createElement)(n.TextareaControl,{label:(0,l.__)("Description","formipay"),value:e.description||"",onChange:e=>f("description",e),help:(0,l.__)("Optional help text displayed below the field","formipay"),rows:3}),c&&(0,t.createElement)(Y,{options:e.field_options||[],onChange:e=>f("field_options",e),fieldType:e.field_type}),u&&(0,t.createElement)(n.SelectControl,{label:(0,l.__)("Option Grid Columns","formipay"),value:e.option_grid_columns||1,options:[{label:(0,l.__)("1 Column","formipay"),value:1},{label:(0,l.__)("2 Columns","formipay"),value:2},{label:(0,l.__)("3 Columns","formipay"),value:3},{label:(0,l.__)("4 Columns","formipay"),value:4}],onChange:e=>f("option_grid_columns",parseInt(e))}),p&&(0,t.createElement)(n.CheckboxControl,{label:(0,l.__)("Required Field","formipay"),checked:e.is_required||!1,onChange:e=>f("is_required",e),help:(0,l.__)("User must fill this field before submitting","formipay")})))}function ee({field:e}){const a=e.field_type||"text",n=e.label||"",r=e.placeholder||"",i=e.default_value||"",o=e.description||"",c=e.is_required||!1,s=e.field_id||`field_${Math.random().toString(36).slice(2,11)}`,m=["divider","page_break"].includes(a);return(0,t.createElement)("div",{className:`formipay-field-preview formipay-field-preview--${a}`},!m&&n&&(0,t.createElement)("label",{htmlFor:s,className:"formipay-field-label"},n,c&&(0,t.createElement)("span",{className:"required"},"*")),(()=>{const n={id:s,name:s,placeholder:r,defaultValue:i,required:c,disabled:!0};switch(a){case"text":case"url":case"email":case"tel":case"number":case"date":case"datetime":case"color":return(0,t.createElement)("input",{type:a,className:"formipay-input",...n});case"textarea":return(0,t.createElement)("textarea",{className:"formipay-textarea",rows:4,...n});case"select":return(0,t.createElement)("select",{className:"formipay-select",...n},(0,t.createElement)("option",{value:""},(0,l.__)("Select an option","formipay")),e.field_options?.map((e,a)=>(0,t.createElement)("option",{key:a,value:e.value||e.label},e.label)));case"radio":return(0,t.createElement)("div",{className:"formipay-radio-group"},e.field_options?.map((e,a)=>(0,t.createElement)("label",{key:a,className:"formipay-radio-label"},(0,t.createElement)("input",{type:"radio",name:s,value:e.value||e.label,disabled:!0}),(0,t.createElement)("span",null,e.label))));case"checkbox":return(0,t.createElement)("div",{className:"formipay-checkbox-group"},e.field_options?.map((e,a)=>(0,t.createElement)("label",{key:a,className:"formipay-checkbox-label"},(0,t.createElement)("input",{type:"checkbox",name:`${s}_${a}`,value:e.value||e.label,disabled:!0}),(0,t.createElement)("span",null,e.label))));case"divider":return(0,t.createElement)("hr",{className:"formipay-divider"});case"page_break":return(0,t.createElement)("div",{className:"formipay-page-break"},(0,l.__)("Page Break","formipay"));case"country_list":return(0,t.createElement)("select",{className:"formipay-select",...n},(0,t.createElement)("option",{value:""},(0,l.__)("Select country","formipay")),(0,t.createElement)("option",{value:"United States"},"United States"),(0,t.createElement)("option",{value:"Indonesia"},"Indonesia"));default:return(0,t.createElement)("input",{type:"text",className:"formipay-input",...n})}})(),o&&!m&&(0,t.createElement)("p",{className:"formipay-field-description"},o))}function te({fields:e}){return e&&0!==e.length?(0,t.createElement)("div",{className:"formipay-form-preview"},(0,t.createElement)("div",{className:"formipay-preview-header"},(0,t.createElement)("h4",null,(0,l.__)("Live Preview","formipay"))),(0,t.createElement)("div",{className:"formipay-preview-content"},(0,t.createElement)("form",{className:"formipay-preview-form"},e.map((e,a)=>(0,t.createElement)(ee,{key:e.field_id||a,field:e}))))):(0,t.createElement)("div",{className:"formipay-form-preview"},(0,t.createElement)("div",{className:"formipay-preview-header"},(0,t.createElement)("h4",null,(0,l.__)("Live Preview","formipay"))),(0,t.createElement)("div",{className:"formipay-preview-content is-empty"},(0,t.createElement)("p",null,(0,l.__)("Add fields to see the preview","formipay"))))}function ae({formId:e,initialData:n={}}){const[r,i]=(0,a.useState)(n.fields||[]),[o,c]=(0,a.useState)(null),[s,m]=(0,a.useState)(null),d=r.find(e=>e.field_id===o)||null;(0,a.useEffect)(()=>{e&&!n.fields&&p()},[e]);const p=(0,a.useCallback)(()=>{const t=new URLSearchParams({action:"formipay_load_form_fields",post_id:e,_wpnonce:window.formipayAdmin?.nonce||""});fetch(`${window.formipayAdmin?.ajaxUrl||"/wp-admin/admin-ajax.php"}?${t}`).then(e=>e.json()).then(e=>{e.success&&e.data.fields&&i(e.data.fields)}).catch(e=>{console.error("Load error:",e)})},[e]),u=(0,a.useCallback)(e=>{i([...r,e]),c(e.field_id)},[r]),f=(0,a.useCallback)(e=>{c(e)},[]),y=(0,a.useCallback)((e,t)=>{i(r.map(a=>a.field_id===e?{...a,...t}:a))},[r]),_=(0,a.useCallback)(e=>{i(e)},[]),E=(0,a.useCallback)(e=>{const t=r.filter(t=>t.field_id!==e);i(t),o===e&&c(null)},[r,o]),v=(0,a.useCallback)(()=>{m("saving");const t=new FormData;t.append("action","formipay_save_form_fields"),t.append("post_id",e),t.append("fields",JSON.stringify(r)),t.append("_wpnonce",window.formipayAdmin?.nonce||""),fetch(window.formipayAdmin?.ajaxUrl||"/wp-admin/admin-ajax.php",{method:"POST",credentials:"same-origin",body:t}).then(e=>e.json()).then(e=>{e.success?(m("saved"),setTimeout(()=>m(null),2e3)):(m("error"),console.error("Failed to save form:",e.message))}).catch(e=>{m("error"),console.error("Save error:",e)})},[r,e]);return(0,t.createElement)("div",{className:"formipay-form-builder"},(0,t.createElement)("div",{className:"formipay-builder-toolbar"},(0,t.createElement)("h2",null,(0,l.__)("Form Builder","formipay")),(0,t.createElement)("div",{className:"formipay-builder-actions"},(0,t.createElement)("button",{type:"button",className:"button button-secondary",onClick:()=>i([])},(0,l.__)("Clear All","formipay")),(0,t.createElement)("button",{type:"button",className:"button button-primary "+("saving"===s?"is-busy":""),onClick:v,disabled:"saving"===s},"saved"===s?(0,l.__)("Saved!","formipay"):"error"===s?(0,l.__)("Failed","formipay"):"saving"===s?(0,l.__)("Saving...","formipay"):(0,l.__)("Save Form","formipay")))),(0,t.createElement)("div",{className:"formipay-builder-content"},(0,t.createElement)(K,{onDragStart:()=>{}}),(0,t.createElement)(X,{fields:r,selectedFieldId:o,onDrop:u,onSelectField:f,onUpdateField:y,onMoveField:_,onDeleteField:E}),(0,t.createElement)(te,{fields:r}),(0,t.createElement)(Z,{field:d,open:!!d,onClose:()=>c(null),onUpdate:y})))}const le={orders:function({initialData:e}){const[l,n]=(0,a.useState)(null);return l?(0,t.createElement)(P,{orderId:l,onBack:()=>n(null)}):(0,t.createElement)(_,{onSelectOrder:e=>n(e)})},customers:function({initialData:e}){return(0,t.createElement)("div",{className:"formipay-page-formipay-page"},(0,t.createElement)("h1",null,(0,l.__)("Customers","formipay")),(0,t.createElement)("p",null,(0,l.__)("Page content coming soon...","formipay")))},products:function({initialData:e}){const[n,i]=(0,a.useState)(!1),[o,c]=(0,a.useState)(null),s=e?.productDetails||{};return n&&o?(0,t.createElement)("div",{className:"formipay-page-products"},(0,t.createElement)("div",{className:"formipay-products-header"},(0,t.createElement)("button",{type:"button",className:"button button-secondary",onClick:()=>i(!1)},"← ",(0,l.__)("Back to Products","formipay")),(0,t.createElement)("h1",null,(0,l.__)("Edit Product","formipay"))),(0,t.createElement)("div",{className:"formipay-product-editor"},(0,t.createElement)(z,{productId:o,productDetails:s}))):(0,t.createElement)("div",{className:"formipay-page-products"},(0,t.createElement)("div",{className:"formipay-products-list-header"},(0,t.createElement)("h1",null,(0,l.__)("Products","formipay")),(0,t.createElement)("button",{type:"button",className:"button button-primary",onClick:()=>{c(null),i(!0)}},(0,t.createElement)(r,{icon:A()(),size:16}),(0,l.__)("Add New Product","formipay"))),(0,t.createElement)("p",{className:"formipay-coming-soon"},(0,l.__)("Products list coming soon. Use the classic editor for now.","formipay")))},forms:function({initialData:e}){const[n,r]=(0,a.useState)(!1),[i,o]=(0,a.useState)(null);return n?(0,t.createElement)("div",{className:"formipay-page-forms"},(0,t.createElement)(ae,{formId:i,initialData:e})):(0,t.createElement)("div",{className:"formipay-page-forms"},(0,t.createElement)("div",{className:"formipay-forms-list"},(0,t.createElement)("h1",null,(0,l.__)("Forms","formipay")),(0,t.createElement)("p",null,(0,l.__)("Forms list coming soon. Use the classic editor for now.","formipay"))))},coupons:function({initialData:e}){return(0,t.createElement)("div",{className:"formipay-page-coupons"},(0,t.createElement)("h1",null,(0,l.__)("Coupons","formipay")),(0,t.createElement)("p",null,(0,l.__)("Coupon management coming soon. Use the classic editor for now.","formipay")))},access:function({initialData:e}){return(0,t.createElement)("div",{className:"formipay-page-access"},(0,t.createElement)("h1",null,(0,l.__)("Access Items","formipay")),(0,t.createElement)("p",null,(0,l.__)("Access items management coming soon. Use the classic editor for now.","formipay")))},licenses:function({initialData:e}){return(0,t.createElement)("div",{className:"formipay-page-licenses"},(0,t.createElement)("h1",null,(0,l.__)("Licenses","formipay")),(0,t.createElement)("p",null,(0,l.__)("License management coming soon. Use the classic editor for now.","formipay")))}};function ne({page:e,initialData:a}){const l=le[e];return l?(0,t.createElement)("div",{className:"formipay-admin-wrap"},(0,t.createElement)(l,{initialData:a})):(0,t.createElement)("div",{className:"formipay-error"},(0,t.createElement)("p",null,"Unknown page: ",e))}const re=()=>{document.querySelectorAll("[data-formipay-mount]").forEach(e=>{const l=e.dataset.formipayMount,n=window.formipayAdmin?.[l]||{};(0,a.render)((0,t.createElement)(ne,{page:l,initialData:n}),e)})};"loading"===document.readyState?document.addEventListener("DOMContentLoaded",re):re()})();