/** * Public API bridge. * * Initializes the shared event emitter and internal helpers used by the * documented runtime API before the editor lifecycle modules run. * * Exposes: * SFE.PublicApi * SFE.PublicApiBridge */ (function() { 'use strict'; window.MWP = window.MWP || {}; window.MWP.SFE = window.MWP.SFE || {}; const SFE = window.MWP.SFE; const PublicApi = SFE.PublicApi || {}; const eventListeners = new Map(); const stagedBlockStates = new Map(); /** * Create a plain-data clone for event payloads and snapshots. * * @param {*} value Source value. * @returns {*} Cloned value when possible. */ function clonePlainData(value) { if (value === null || typeof value === 'undefined') { return value; } try { return JSON.parse(JSON.stringify(value)); } catch (error) { if (Array.isArray(value)) { return value.slice(); } if (typeof value === 'object') { return Object.assign({}, value); } return value; } } /** * Resolve the current editor snapshot builder when available. * * @param {Object|null} editorState Active editor state. * @returns {Object|null} Stable editor snapshot. */ function buildEditorSnapshot(editorState) { if (typeof PublicApi._buildEditorSnapshot === 'function') { return PublicApi._buildEditorSnapshot(editorState); } return null; } /** * Invoke one event handler safely. * * @param {Function} handler Registered listener. * @param {Object} payload Event payload. * @returns {void} */ function callHandler(handler, payload) { try { handler(payload); } catch (error) { console.error('FrontEdit: PublicApi event handler failed', error); } } /** * Emit one public runtime event. * * @param {string} eventName Event name. * @param {Object} payload Event payload. * @returns {void} */ function emitEvent(eventName, payload) { const listeners = eventListeners.get(eventName); if (!listeners || !listeners.size) { return; } const snapshot = clonePlainData(payload); listeners.forEach(handler => callHandler(handler, snapshot)); } /** * Register one runtime event listener. * * @param {string} eventName Event name. * @param {Function} handler Event handler. * @returns {Function} Unsubscribe callback. */ function on(eventName, handler) { const normalizedEventName = String(eventName || '').trim(); if (!normalizedEventName || typeof handler !== 'function') { return function noop() {}; } if (!eventListeners.has(normalizedEventName)) { eventListeners.set(normalizedEventName, new Set()); } eventListeners.get(normalizedEventName).add(handler); return function unsubscribe() { off(normalizedEventName, handler); }; } /** * Remove one runtime event listener. * * @param {string} eventName Event name. * @param {Function} handler Event handler. * @returns {void} */ function off(eventName, handler) { const normalizedEventName = String(eventName || '').trim(); if (!normalizedEventName || typeof handler !== 'function') { return; } const listeners = eventListeners.get(normalizedEventName); if (!listeners) { return; } listeners.delete(handler); if (!listeners.size) { eventListeners.delete(normalizedEventName); } } /** * Emit one editor lifecycle event using the current snapshot builder. * * @param {string} eventName Event name. * @param {Object|null} editorState Editor session state. * @param {Object} metadata Additional event metadata. * @returns {void} */ function emitEditorEvent(eventName, editorState, metadata = {}) { const editor = buildEditorSnapshot(editorState); if (!editor) { return; } emitEvent(eventName, Object.assign({}, metadata, { editor })); } /** * Emit one save lifecycle event using the current snapshot builder. * * @param {string} eventName Event name. * @param {Object|null} editorState Editor session state. * @param {Object} metadata Additional event metadata. * @returns {void} */ function emitSaveEvent(eventName, editorState, metadata = {}) { const editor = buildEditorSnapshot(editorState); if (!editor) { return; } emitEvent(eventName, Object.assign({}, metadata, { editor })); } PublicApi.on = on; PublicApi.off = off; SFE.PublicApi = PublicApi; SFE.PublicApiBridge = { clonePlainData, emitEvent, emitEditorEvent, emitSaveEvent, stagedBlockStates, }; })(); .wc-block-components-validation-error { @include font-size(smaller); color: $error-red; max-width: 100%; position: absolute; top: calc(100% - 1px); white-space: normal; > p { align-items: center; display: flex; line-height: 12px; // This allows two lines in a 24px bottom margin. margin: 0; min-height: 24px; padding: 0; } } .wc-block-components-select + .wc-block-components-validation-error { margin-bottom: $gap-large; } (()=>{"use strict";var e,o,t,r={2590:(e,o,t)=>{const r=window.wp.blocks,n=window.wp.blockEditor;var i=t(4530),s=t(2216),a=t(790);const c=JSON.parse('{"name":"woocommerce/order-confirmation-shipping-wrapper","version":"1.0.0","title":"Shipping Address Section","description":"Display the order confirmation shipping section.","category":"woocommerce","keywords":["WooCommerce"],"attributes":{"heading":{"type":"string","default":"Shipping"}},"supports":{"multiple":false,"align":["wide","full"],"html":false,"spacing":{"padding":true,"margin":true,"__experimentalDefaultControls":{"margin":false,"padding":false}}},"textdomain":"woocommerce","apiVersion":3,"$schema":"https://schemas.wp.org/trunk/block.json"}'),p={heading:{type:"string",default:(0,t(7723).__)("Shipping address","woocommerce")}};(0,r.registerBlockType)(c,{icon:{src:(0,a.jsx)(i.A,{icon:s.A,className:"wc-block-editor-components-block-icon"})},edit:({attributes:e,setAttributes:o})=>{const t=(0,n.useBlockProps)();return(0,a.jsx)("div",{...t,children:(0,a.jsx)(n.InnerBlocks,{allowedBlocks:["core/heading"],template:[["core/heading",{level:2,style:{typography:{fontSize:"24px"}},content:e.heading||"",onChangeContent:e=>o({heading:e})}],["woocommerce/order-confirmation-shipping-address",{lock:{remove:!0}}]]})})},save:()=>(0,a.jsx)(n.InnerBlocks.Content,{}),attributes:p})},1609:e=>{e.exports=window.React},790:e=>{e.exports=window.ReactJSXRuntime},6087:e=>{e.exports=window.wp.element},7723:e=>{e.exports=window.wp.i18n},5573:e=>{e.exports=window.wp.primitives}},n={};function i(e){var o=n[e];if(void 0!==o)return o.exports;var t=n[e]={exports:{}};return r[e](t,t.exports,i),t.exports}i.m=r,e=[],i.O=(o,t,r,n)=>{if(!t){var s=1/0;for(l=0;l=n)&&Object.keys(i.O).every((e=>i.O[e](t[c])))?t.splice(c--,1):(a=!1,n0&&e[l-1][2]>n;l--)e[l]=e[l-1];e[l]=[t,r,n]},i.n=e=>{var o=e&&e.__esModule?()=>e.default:()=>e;return i.d(o,{a:o}),o},t=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,i.t=function(e,r){if(1&r&&(e=this(e)),8&r)return e;if("object"==typeof e&&e){if(4&r&&e.__esModule)return e;if(16&r&&"function"==typeof e.then)return e}var n=Object.create(null);i.r(n);var s={};o=o||[null,t({}),t([]),t(t)];for(var a=2&r&&e;"object"==typeof a&&!~o.indexOf(a);a=t(a))Object.getOwnPropertyNames(a).forEach((o=>s[o]=()=>e[o]));return s.default=()=>e,i.d(n,s),n},i.d=(e,o)=>{for(var t in o)i.o(o,t)&&!i.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:o[t]})},i.o=(e,o)=>Object.prototype.hasOwnProperty.call(e,o),i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.j=3806,(()=>{var e={3806:0};i.O.j=o=>0===e[o];var o=(o,t)=>{var r,n,[s,a,c]=t,p=0;if(s.some((o=>0!==e[o]))){for(r in a)i.o(a,r)&&(i.m[r]=a[r]);if(c)var l=c(i)}for(o&&o(t);pi(2590)));s=i.O(s),((this.wc=this.wc||{}).blocks=this.wc.blocks||{})["order-confirmation-shipping-wrapper"]=s})();