1(()=>{"use strict";const e=window.wc.wcBlocksRegistry,t=window.wc.wcSettings,n=window.wp.data,o=window.wp.htmlEntities,r=window.wp.element,i=window.wp.i18n,c="https://secure.helcim.app/helcim-pay/services/start.js",a="helcim_verification_unconfirmed";let s="",d="",l=null;function m(){document.body.style.overflow=s,document.body.style.paddingRight=d}function u(){return window.appendHelcimPayIframe?Promise.resolve():l||(l=new Promise((e,t)=>{const n=document.querySelector(`script[src^="${c}"]`),o=n??document.createElement("script"),r=setTimeout(()=>{l=null,t(new Error("HelcimPay.js script load timeout"))},15e3),i=e=>{clearTimeout(r),o.remove(),l=null,t(new Error(e))};o.addEventListener("load",()=>{window.appendHelcimPayIframe?(clearTimeout(r),e()):i("HelcimPay.js loaded without appendHelcimPayIframe")},{once:!0}),o.addEventListener("error",()=>{i("Failed to load HelcimPay.js script")},{once:!0}),n||(o.src=c,o.async=!0,document.head.appendChild(o))}),l)}function p(){window.removeHelcimPayIframe&&(m(),window.removeHelcimPayIframe())}function h(e){return e>=500||408===e||429===e}function w(e){const t=[e],n=function(e){const t=e.search(/\{\s*"success"/);if(t<0)return null;let n=0,o=!1,r=!1;for(let i=t;i<e.length;i++){const c=e[i];if(r)r=!1;else if(o)"\\"===c?r=!0:'"'===c&&(o=!1);else if('"'===c)o=!0;else if("{"===c)n++;else if("}"===c&&(n--,0===n))return e.slice(t,i+1)}return null}(e);null!==n&&t.push(n);for(const e of t)try{const t=JSON.parse(e);if(t&&"object"==typeof t&&"success"in t)return t}catch{}return null}function y(e,t,n,o,r,i){if(!i)return;const c=new FormData;c.append("order_id",n),c.append("nonce",o),c.append("order_key",r),c.append("code",e),c.append("message",t),fetch(i,{method:"POST",credentials:"same-origin",body:c,keepalive:!0}).catch(()=>{})}function f(e){return a===e?.message?(0,i.__)("Your payment went through, but we could not finish confirming your order. Please do not pay again â contact us and we will complete it for you.","helcim-commerce-for-woocommerce"):"helcim_modal_unresponsive"===e?.message?(0,i.__)("The payment provider is not responding right now. Please wait a moment and try again.","helcim-commerce-for-woocommerce"):(0,i.__)("Payment could not be completed. Please try again or use a different payment method.","helcim-commerce-for-woocommerce")}const g=window.ReactJSXRuntime,_=(0,t.getSetting)("helcimjs_data",{}),v="Credit Card (Helcim)",E=()=>(0,g.jsxs)(g.Fragment,{children:[(0,o.decodeEntities)(_.title||v),_.icon&&(0,g.jsx)("img",{src:_.icon,alt:(0,o.decodeEntities)(_.title||v),style:{marginLeft:"8px",maxHeight:"24px"}})]}),P=({eventRegistration:e,emitResponse:t})=>{const{onPaymentSetup:c,onCheckoutSuccess:l}=e,{responseTypes:v}=t;return(0,r.useEffect)(()=>{u().catch(()=>{})},[]),(0,r.useEffect)(()=>c(()=>({type:v.SUCCESS,meta:{paymentMethodData:{}}})),[c,v.SUCCESS]),(0,r.useEffect)(()=>l(async e=>{const t=e.paymentResult??e.processingResponse,o=function(e){if(!e)return;const t=Array.isArray(e)?e.reduce((e,{key:t,value:n})=>(e[t]=n,e),{}):e;return{helcimOrderId:t.helcimOrderId,helcimCheckoutToken:t.helcimCheckoutToken,helcimNonce:t.helcimNonce,helcimOrderKey:t.helcimOrderKey}}(t?.paymentDetails),r=_.ajaxUrl;if(!o?.helcimCheckoutToken||!r)return{type:v.ERROR,message:(0,i.__)("Payment could not be initialized. Please try again.","helcim-commerce-for-woocommerce"),messageContext:"wc/checkout",retry:!0};try{const e=await function(e,t){const n=()=>{window.location.hash.startsWith("#helcim-pay")&&(window.removeEventListener("hashchange",n),history.replaceState(null,"",window.location.pathname+window.location.search))};return window.addEventListener("hashchange",n),new Promise((n,o)=>{const r="helcim-pay-js-"+e;let i,c=!1;const a=()=>{void 0!==i&&(clearTimeout(i),i=void 0)},l=()=>{window.removeEventListener("message",p),a()},p=e=>{const i=e.data;if(i.eventName===r)switch(i.eventStatus){case"SUCCESS":l();try{const e=JSON.parse(i.eventMessage);n(e)}catch{o(new Error("Failed to parse Helcim response"))}break;case"ABORTED":console.warn("[helcim] payment declined:",i.eventMessage),a(),c||(c=!0,t?.(i.eventMessage));break;case"HIDE":l(),m(),o(new Error("modal_closed"))}};window.addEventListener("message",p),u().then(()=>
1{if(!window.appendHelcimPayIframe)return l(),void o(new Error("HelcimPay.js not available after script load"));let t;try{t=window.appendHelcimPayIframe(e)}catch{return l(),void o(new Error("helcim_modal_unavailable"))}if(t=t??document.querySelector("iframe#helcimPayIframe")??void 0,!t)return l(),void o(new Error("helcim_modal_unavailable"));!function(){s=document.body.style.overflow,d=document.body.style.paddingRight;const e=window.innerWidth-document.documentElement.clientWidth;document.body.style.overflow="hidden",document.body.style.paddingRight=`${e}px`}(),i=setTimeout(()=>{l(),m(),o(new Error("helcim_modal_unresponsive"))},2e4),t.addEventListener("load",a,{once:!0})}).catch(e=>{l(),o(e)})})}(o.helcimCheckoutToken,e=>{!function(e,t,n,o){if(!o)return;const r=new FormData;r.append("order_id",e),r.append("nonce",t),r.append("order_key",n),fetch(o,{method:"POST",credentials:"same-origin",body:r,keepalive:!0}).catch(()=>{console.warn("[helcim] could not record the payment attempt")})}(o.helcimOrderId,o.helcimNonce,o.helcimOrderKey,_.attemptUrl),y("payment_declined",e??"",o.helcimOrderId,o.helcimNonce,o.helcimOrderKey,_.logUrl)}),t=await async function(e,t,n,o,r){if(!r)throw new Error("Missing payment verification endpoint");const i=()=>{const r=new FormData;return r.append("order_id",t),r.append("nonce",n),r.append("order_key",o),r.append("transaction_response",JSON.stringify(e)),r};let c="";for(let e=0;e<2;e++){let t,n;e>0&&await new Promise(e=>setTimeout(e,2e3));try{t=await fetch(r,{method:"POST",credentials:"same-origin",body:i()})}catch(e){c=`network error: ${e?.message??"unknown"}`;continue}if(!t.ok){if(!h(t.status))throw new Error(`Verification request failed: ${t.status}`);c=`HTTP ${t.status}`;continue}try{n=await t.text()}catch(e){c=`body read failed: ${e?.message??"unknown"}`;continue}const o=w(n);if(o){if(o.success)return o;if(o.data?.redirect)return o;throw new Error(o.data?.message??"Payment verification failed")}c=`unreadable response: ${n.slice(0,100)}`}const s=new Error(a);throw s.detail=c,s}(e,o.helcimOrderId,o.helcimNonce,o.helcimOrderKey,r);return p(),window.location.href=t.data.redirect,{type:v.SUCCESS}}catch(e){if("modal_closed"===e.message){const e=(0,n.dispatch)("wc/store/checkout"),t=(0,n.dispatch)("wc/store/payment");return"function"!=typeof e.__internalSetIdle||"function"!=typeof t.__internalSetPaymentIdle?{type:v.ERROR,message:(0,i.__)("Payment was cancelled.","helcim-commerce-for-woocommerce"),messageContext:"wc/checkout"}:(setTimeout(()=>{e.__internalSetIdle(),t.__internalSetPaymentIdle()},0),{type:v.SUCCESS})}return p(),y(function(e){switch(e?.message){case"helcim_modal_unresponsive":return"modal_unresponsive";case"helcim_modal_unavailable":return"modal_unavailable";case a:return"verification_unconfirmed";case"HelcimPay.js script load timeout":case"Failed to load HelcimPay.js script":case"HelcimPay.js loaded without appendHelcimPayIframe":return"script_load_failed";default:return"client_error"}}(e),function(e){const t=e?.message??"";return e?.detail?`${t}: ${e.detail}`:t}(e),o.helcimOrderId,o.helcimNonce,o.helcimOrderKey,_.logUrl),{type:v.ERROR,message:f(e),messageContext:"wc/checkout",retry:!0}}}),[l,v.SUCCESS,v.ERROR]),(0,g.jsx)("div",{children:(0,o.decodeEntities)(_.description||"")})};(0,e.registerPaymentMethod)({name:"helcimjs",label:(0,g.jsx)(E,{}),content:(0,g.jsx)(P,{}),edit:(0,g.jsx)(P,{}),canMakePayment:({cartTotals:e})=>{const{supportedCurrencies:t}=_;return!t||t.includes(e.currency_code)},ariaLabel:(0,o.decodeEntities)(_.title||v),supports:{features:_?.supports??["products"]}})})();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.