@1interface/chat-shell 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/PaymentProviderHost-CBfoeBts.js +1 -0
- package/dist/PaymentProviderHost-VjMUCJgN.cjs +1 -0
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +4 -4
- package/dist/ExportResult-eb4TcH7k.cjs +0 -1
- package/dist/ExportResult-vKWGlZZX.js +0 -1
- package/dist/NoopLogger-B-ce52_l.cjs +0 -1
- package/dist/NoopLogger-aeNt0r6v.js +0 -1
- package/dist/PaymentProviderHost-BeHcCUZx.js +0 -1
- package/dist/PaymentProviderHost-Dph4wPYb.cjs +0 -1
- package/dist/ResourceImpl-DPkc_ob9.js +0 -1
- package/dist/ResourceImpl-yQJWLZDn.cjs +0 -1
- package/dist/diag-api-BepQpXrk.js +0 -1
- package/dist/diag-api-DsVI4ljU.cjs +0 -1
- package/dist/index-32QtQw41.cjs +0 -1
- package/dist/index-65-Yxkqs.cjs +0 -1
- package/dist/index-AAKj44J6.cjs +0 -1
- package/dist/index-AVWXcG-i.js +0 -1
- package/dist/index-BQf9Yax1.js +0 -1
- package/dist/index-Bs9yNhX-.js +0 -1
- package/dist/index-CS2Ktaql.cjs +0 -1
- package/dist/index-CwetZEW6.js +0 -1
- package/dist/index-_NPuwCXg.js +0 -1
- package/dist/index-iR-pnjyZ.cjs +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{jsx as e,jsxs as t,Fragment as n}from"react/jsx-runtime";import r,{forwardRef as o,createElement as a,useState as i,useRef as s,useCallback as c,useMemo as l,createContext as u,useContext as d,useEffect as p,useLayoutEffect as f}from"react";import{d as m,m as y,h,D as g,p as v,y as b,Z as w,b as x}from"./index-CwetZEW6.js";const S=e=>{const t=(e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,n)=>n?n.toUpperCase():t.toLowerCase()))(e);return t.charAt(0).toUpperCase()+t.slice(1)},E=(...e)=>e.filter((e,t,n)=>Boolean(e)&&""!==e.trim()&&n.indexOf(e)===t).join(" ").trim(),C=e=>{for(const t in e)if(t.startsWith("aria-")||"role"===t||"title"===t)return!0};var k={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"};const P=o(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:o="",children:i,iconNode:s,...c},l)=>a("svg",{ref:l,...k,width:t,height:t,stroke:e,strokeWidth:r?24*Number(n)/Number(t):n,className:E("lucide",o),...!i&&!C(c)&&{"aria-hidden":"true"},...c},[...s.map(([e,t])=>a(e,t)),...Array.isArray(i)?i:[i]])),O=((e,t)=>{const n=o(({className:n,...r},o)=>{return a(P,{ref:o,iconNode:t,className:E(`lucide-${i=S(e),i.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}`,`lucide-${e}`,n),...r});var i});return n.displayName=S(e),n})("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);function j(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var _,A,N,I,T,M,R,$,F,V,D,B,L,z,U,q,W={exports:{}},Y={exports:{}},H={},J={};function K(){return N||(N=1,Y.exports="production"===process.env.NODE_ENV?function(){if(_)return H;_=1;var e="function"==typeof Symbol&&Symbol.for,t=e?Symbol.for("react.element"):60103,n=e?Symbol.for("react.portal"):60106,r=e?Symbol.for("react.fragment"):60107,o=e?Symbol.for("react.strict_mode"):60108,a=e?Symbol.for("react.profiler"):60114,i=e?Symbol.for("react.provider"):60109,s=e?Symbol.for("react.context"):60110,c=e?Symbol.for("react.async_mode"):60111,l=e?Symbol.for("react.concurrent_mode"):60111,u=e?Symbol.for("react.forward_ref"):60112,d=e?Symbol.for("react.suspense"):60113,p=e?Symbol.for("react.suspense_list"):60120,f=e?Symbol.for("react.memo"):60115,m=e?Symbol.for("react.lazy"):60116,y=e?Symbol.for("react.block"):60121,h=e?Symbol.for("react.fundamental"):60117,g=e?Symbol.for("react.responder"):60118,v=e?Symbol.for("react.scope"):60119;function b(e){if("object"==typeof e&&null!==e){var p=e.$$typeof;switch(p){case t:switch(e=e.type){case c:case l:case r:case a:case o:case d:return e;default:switch(e=e&&e.$$typeof){case s:case u:case m:case f:case i:return e;default:return p}}case n:return p}}}function w(e){return b(e)===l}return H.AsyncMode=c,H.ConcurrentMode=l,H.ContextConsumer=s,H.ContextProvider=i,H.Element=t,H.ForwardRef=u,H.Fragment=r,H.Lazy=m,H.Memo=f,H.Portal=n,H.Profiler=a,H.StrictMode=o,H.Suspense=d,H.isAsyncMode=function(e){return w(e)||b(e)===c},H.isConcurrentMode=w,H.isContextConsumer=function(e){return b(e)===s},H.isContextProvider=function(e){return b(e)===i},H.isElement=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===t},H.isForwardRef=function(e){return b(e)===u},H.isFragment=function(e){return b(e)===r},H.isLazy=function(e){return b(e)===m},H.isMemo=function(e){return b(e)===f},H.isPortal=function(e){return b(e)===n},H.isProfiler=function(e){return b(e)===a},H.isStrictMode=function(e){return b(e)===o},H.isSuspense=function(e){return b(e)===d},H.isValidElementType=function(e){return"string"==typeof e||"function"==typeof e||e===r||e===l||e===a||e===o||e===d||e===p||"object"==typeof e&&null!==e&&(e.$$typeof===m||e.$$typeof===f||e.$$typeof===i||e.$$typeof===s||e.$$typeof===u||e.$$typeof===h||e.$$typeof===g||e.$$typeof===v||e.$$typeof===y)},H.typeOf=b,H}():(A||(A=1,"production"!==process.env.NODE_ENV&&function(){var e="function"==typeof Symbol&&Symbol.for,t=e?Symbol.for("react.element"):60103,n=e?Symbol.for("react.portal"):60106,r=e?Symbol.for("react.fragment"):60107,o=e?Symbol.for("react.strict_mode"):60108,a=e?Symbol.for("react.profiler"):60114,i=e?Symbol.for("react.provider"):60109,s=e?Symbol.for("react.context"):60110,c=e?Symbol.for("react.async_mode"):60111,l=e?Symbol.for("react.concurrent_mode"):60111,u=e?Symbol.for("react.forward_ref"):60112,d=e?Symbol.for("react.suspense"):60113,p=e?Symbol.for("react.suspense_list"):60120,f=e?Symbol.for("react.memo"):60115,m=e?Symbol.for("react.lazy"):60116,y=e?Symbol.for("react.block"):60121,h=e?Symbol.for("react.fundamental"):60117,g=e?Symbol.for("react.responder"):60118,v=e?Symbol.for("react.scope"):60119;function b(e){if("object"==typeof e&&null!==e){var p=e.$$typeof;switch(p){case t:var y=e.type;switch(y){case c:case l:case r:case a:case o:case d:return y;default:var h=y&&y.$$typeof;switch(h){case s:case u:case m:case f:case i:return h;default:return p}}case n:return p}}}var w=l,x=s,S=i,E=t,C=u,k=r,P=m,O=f,j=n,_=a,A=o,N=d,I=!1;function T(e){return b(e)===l}J.AsyncMode=c,J.ConcurrentMode=w,J.ContextConsumer=x,J.ContextProvider=S,J.Element=E,J.ForwardRef=C,J.Fragment=k,J.Lazy=P,J.Memo=O,J.Portal=j,J.Profiler=_,J.StrictMode=A,J.Suspense=N,J.isAsyncMode=function(e){return I||(I=!0,console.warn("The ReactIs.isAsyncMode() alias has been deprecated, and will be removed in React 17+. Update your code to use ReactIs.isConcurrentMode() instead. It has the exact same API.")),T(e)||b(e)===c},J.isConcurrentMode=T,J.isContextConsumer=function(e){return b(e)===s},J.isContextProvider=function(e){return b(e)===i},J.isElement=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===t},J.isForwardRef=function(e){return b(e)===u},J.isFragment=function(e){return b(e)===r},J.isLazy=function(e){return b(e)===m},J.isMemo=function(e){return b(e)===f},J.isPortal=function(e){return b(e)===n},J.isProfiler=function(e){return b(e)===a},J.isStrictMode=function(e){return b(e)===o},J.isSuspense=function(e){return b(e)===d},J.isValidElementType=function(e){return"string"==typeof e||"function"==typeof e||e===r||e===l||e===a||e===o||e===d||e===p||"object"==typeof e&&null!==e&&(e.$$typeof===m||e.$$typeof===f||e.$$typeof===i||e.$$typeof===s||e.$$typeof===u||e.$$typeof===h||e.$$typeof===g||e.$$typeof===v||e.$$typeof===y)},J.typeOf=b}()),J)),Y.exports}function X(){return R?M:(R=1,M="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}function Z(){return F?$:(F=1,$=Function.call.bind(Object.prototype.hasOwnProperty))}function G(){if(D)return V;D=1;var e=function(){};if("production"!==process.env.NODE_ENV){var t=X(),n={},r=Z();e=function(e){var t="Warning: "+e;"undefined"!=typeof console&&console.error(t);try{throw new Error(t)}catch(e){}}}function o(o,a,i,s,c){if("production"!==process.env.NODE_ENV)for(var l in o)if(r(o,l)){var u;try{if("function"!=typeof o[l]){var d=Error((s||"React class")+": "+i+" type `"+l+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof o[l]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw d.name="Invariant Violation",d}u=o[l](a,l,s,i,null,t)}catch(e){u=e}if(!u||u instanceof Error||e((s||"React class")+": type specification of "+i+" `"+l+"` is invalid; the type checker function must return `null` or an `Error` but returned a "+typeof u+". You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument)."),u instanceof Error&&!(u.message in n)){n[u.message]=!0;var p=c?c():"";e("Failed "+i+" type: "+u.message+(null!=p?p:""))}}}return o.resetWarningCache=function(){"production"!==process.env.NODE_ENV&&(n={})},V=o}function Q(){if(L)return B;L=1;var e=K(),t=function(){if(T)return I;T=1;var e=Object.getOwnPropertySymbols,t=Object.prototype.hasOwnProperty,n=Object.prototype.propertyIsEnumerable;return I=function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},n=0;n<10;n++)t["_"+String.fromCharCode(n)]=n;if("0123456789"!==Object.getOwnPropertyNames(t).map(function(e){return t[e]}).join(""))return!1;var r={};return"abcdefghijklmnopqrst".split("").forEach(function(e){r[e]=e}),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},r)).join("")}catch(e){return!1}}()?Object.assign:function(r,o){for(var a,i,s=function(e){if(null==e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}(r),c=1;c<arguments.length;c++){for(var l in a=Object(arguments[c]))t.call(a,l)&&(s[l]=a[l]);if(e){i=e(a);for(var u=0;u<i.length;u++)n.call(a,i[u])&&(s[i[u]]=a[i[u]])}}return s},I}(),n=X(),r=Z(),o=G(),a=function(){};function i(){return null}return"production"!==process.env.NODE_ENV&&(a=function(e){var t="Warning: "+e;"undefined"!=typeof console&&console.error(t);try{throw new Error(t)}catch(e){}}),B=function(s,c){var l="function"==typeof Symbol&&Symbol.iterator,u="<<anonymous>>",d={array:y("array"),bigint:y("bigint"),bool:y("boolean"),func:y("function"),number:y("number"),object:y("object"),string:y("string"),symbol:y("symbol"),any:m(i),arrayOf:function(e){return m(function(t,r,o,a,i){if("function"!=typeof e)return new f("Property `"+i+"` of component `"+o+"` has invalid PropType notation inside arrayOf.");var s=t[r];if(!Array.isArray(s))return new f("Invalid "+a+" `"+i+"` of type `"+v(s)+"` supplied to `"+o+"`, expected an array.");for(var c=0;c<s.length;c++){var l=e(s,c,o,a,i+"["+c+"]",n);if(l instanceof Error)return l}return null})},element:m(function(e,t,n,r,o){var a=e[t];return s(a)?null:new f("Invalid "+r+" `"+o+"` of type `"+v(a)+"` supplied to `"+n+"`, expected a single ReactElement.")}),elementType:m(function(t,n,r,o,a){var i=t[n];return e.isValidElementType(i)?null:new f("Invalid "+o+" `"+a+"` of type `"+v(i)+"` supplied to `"+r+"`, expected a single ReactElement type.")}),instanceOf:function(e){return m(function(t,n,r,o,a){return t[n]instanceof e?null:new f("Invalid "+o+" `"+a+"` of type `"+((i=t[n]).constructor&&i.constructor.name?i.constructor.name:u)+"` supplied to `"+r+"`, expected instance of `"+(e.name||u)+"`.");var i})},node:m(function(e,t,n,r,o){return g(e[t])?null:new f("Invalid "+r+" `"+o+"` supplied to `"+n+"`, expected a ReactNode.")}),objectOf:function(e){return m(function(t,o,a,i,s){if("function"!=typeof e)return new f("Property `"+s+"` of component `"+a+"` has invalid PropType notation inside objectOf.");var c=t[o],l=v(c);if("object"!==l)return new f("Invalid "+i+" `"+s+"` of type `"+l+"` supplied to `"+a+"`, expected an object.");for(var u in c)if(r(c,u)){var d=e(c,u,a,i,s+"."+u,n);if(d instanceof Error)return d}return null})},oneOf:function(e){return Array.isArray(e)?m(function(t,n,r,o,a){for(var i=t[n],s=0;s<e.length;s++)if(p(i,e[s]))return null;var c=JSON.stringify(e,function(e,t){return"symbol"===b(t)?String(t):t});return new f("Invalid "+o+" `"+a+"` of value `"+String(i)+"` supplied to `"+r+"`, expected one of "+c+".")}):("production"!==process.env.NODE_ENV&&a(arguments.length>1?"Invalid arguments supplied to oneOf, expected an array, got "+arguments.length+" arguments. A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z]).":"Invalid argument supplied to oneOf, expected an array."),i)},oneOfType:function(e){if(!Array.isArray(e))return"production"!==process.env.NODE_ENV&&a("Invalid argument supplied to oneOfType, expected an instance of array."),i;for(var t=0;t<e.length;t++){var o=e[t];if("function"!=typeof o)return a("Invalid argument supplied to oneOfType. Expected an array of check functions, but received "+w(o)+" at index "+t+"."),i}return m(function(t,o,a,i,s){for(var c=[],l=0;l<e.length;l++){var u=(0,e[l])(t,o,a,i,s,n);if(null==u)return null;u.data&&r(u.data,"expectedType")&&c.push(u.data.expectedType)}return new f("Invalid "+i+" `"+s+"` supplied to `"+a+"`"+(c.length>0?", expected one of type ["+c.join(", ")+"]":"")+".")})},shape:function(e){return m(function(t,r,o,a,i){var s=t[r],c=v(s);if("object"!==c)return new f("Invalid "+a+" `"+i+"` of type `"+c+"` supplied to `"+o+"`, expected `object`.");for(var l in e){var u=e[l];if("function"!=typeof u)return h(o,a,i,l,b(u));var d=u(s,l,o,a,i+"."+l,n);if(d)return d}return null})},exact:function(e){return m(function(o,a,i,s,c){var l=o[a],u=v(l);if("object"!==u)return new f("Invalid "+s+" `"+c+"` of type `"+u+"` supplied to `"+i+"`, expected `object`.");var d=t({},o[a],e);for(var p in d){var m=e[p];if(r(e,p)&&"function"!=typeof m)return h(i,s,c,p,b(m));if(!m)return new f("Invalid "+s+" `"+c+"` key `"+p+"` supplied to `"+i+"`.\nBad object: "+JSON.stringify(o[a],null," ")+"\nValid keys: "+JSON.stringify(Object.keys(e),null," "));var y=m(l,p,i,s,c+"."+p,n);if(y)return y}return null})}};function p(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}function f(e,t){this.message=e,this.data=t&&"object"==typeof t?t:{},this.stack=""}function m(e){if("production"!==process.env.NODE_ENV)var t={},r=0;function o(o,i,s,l,d,p,m){if(l=l||u,p=p||s,m!==n){if(c){var y=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use `PropTypes.checkPropTypes()` to call them. Read more at http://fb.me/use-check-prop-types");throw y.name="Invariant Violation",y}if("production"!==process.env.NODE_ENV&&"undefined"!=typeof console){var h=l+":"+s;!t[h]&&r<3&&(a("You are manually calling a React.PropTypes validation function for the `"+p+"` prop on `"+l+"`. This is deprecated and will throw in the standalone `prop-types` package. You may be seeing this warning due to a third-party PropTypes library. See https://fb.me/react-warning-dont-call-proptypes for details."),t[h]=!0,r++)}}return null==i[s]?o?new f(null===i[s]?"The "+d+" `"+p+"` is marked as required in `"+l+"`, but its value is `null`.":"The "+d+" `"+p+"` is marked as required in `"+l+"`, but its value is `undefined`."):null:e(i,s,l,d,p)}var i=o.bind(null,!1);return i.isRequired=o.bind(null,!0),i}function y(e){return m(function(t,n,r,o,a,i){var s=t[n];return v(s)!==e?new f("Invalid "+o+" `"+a+"` of type `"+b(s)+"` supplied to `"+r+"`, expected `"+e+"`.",{expectedType:e}):null})}function h(e,t,n,r,o){return new f((e||"React class")+": "+t+" type `"+n+"."+r+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+o+"`.")}function g(e){switch(typeof e){case"number":case"string":case"undefined":return!0;case"boolean":return!e;case"object":if(Array.isArray(e))return e.every(g);if(null===e||s(e))return!0;var t=function(e){var t=e&&(l&&e[l]||e["@@iterator"]);if("function"==typeof t)return t}(e);if(!t)return!1;var n,r=t.call(e);if(t!==e.entries){for(;!(n=r.next()).done;)if(!g(n.value))return!1}else for(;!(n=r.next()).done;){var o=n.value;if(o&&!g(o[1]))return!1}return!0;default:return!1}}function v(e){var t=typeof e;return Array.isArray(e)?"array":e instanceof RegExp?"object":function(e,t){return"symbol"===e||!!t&&("Symbol"===t["@@toStringTag"]||"function"==typeof Symbol&&t instanceof Symbol)}(t,e)?"symbol":t}function b(e){if(null==e)return""+e;var t=v(e);if("object"===t){if(e instanceof Date)return"date";if(e instanceof RegExp)return"regexp"}return t}function w(e){var t=b(e);switch(t){case"array":case"object":return"an "+t;case"boolean":case"date":case"regexp":return"a "+t;default:return t}}return f.prototype=Error.prototype,d.checkPropTypes=o,d.resetWarningCache=o.resetWarningCache,d.PropTypes=d,d},B}function ee(){if(U)return z;U=1;var e=X();function t(){}function n(){}return n.resetWarningCache=t,z=function(){function r(t,n,r,o,a,i){if(i!==e){var s=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw s.name="Invariant Violation",s}}function o(){return r}r.isRequired=r;var a={array:r,bigint:r,bool:r,func:r,number:r,object:r,string:r,symbol:r,any:r,arrayOf:o,element:r,elementType:r,instanceOf:o,node:r,objectOf:o,oneOf:o,oneOfType:o,shape:o,exact:o,checkPropTypes:n,resetWarningCache:t};return a.PropTypes=a,a}}function te(){if(q)return W.exports;if(q=1,"production"!==process.env.NODE_ENV){var e=K();W.exports=Q()(e.isElement,!0)}else W.exports=ee()();return W.exports}const ne=j(te());function re(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function oe(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?re(Object(n),!0).forEach(function(t){ie(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):re(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function ae(e){return(ae="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function ie(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function se(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=e&&("undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"]);if(null!=n){var r,o,a=[],i=!0,s=!1;try{for(n=n.call(e);!(i=(r=n.next()).done)&&(a.push(r.value),!t||a.length!==t);i=!0);}catch(e){s=!0,o=e}finally{try{i||null==n.return||n.return()}finally{if(s)throw o}}return a}}(e,t)||function(e,t){if(e){if("string"==typeof e)return ce(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?ce(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function ce(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var le=function(e,t,n){var o=!!n,a=r.useRef(n);r.useEffect(function(){a.current=n},[n]),r.useEffect(function(){if(!o||!e)return function(){};var n=function(){a.current&&a.current.apply(a,arguments)};return e.on(t,n),function(){e.off(t,n)}},[o,t,e,a])},ue=function(e){var t=r.useRef(e);return r.useEffect(function(){t.current=e},[e]),t.current},de=function(e){return null!==e&&"object"===ae(e)},pe="[object Object]",fe=function e(t,n){if(!de(t)||!de(n))return t===n;var r=Array.isArray(t);if(r!==Array.isArray(n))return!1;var o=Object.prototype.toString.call(t)===pe;if(o!==(Object.prototype.toString.call(n)===pe))return!1;if(!o&&!r)return t===n;var a=Object.keys(t),i=Object.keys(n);if(a.length!==i.length)return!1;for(var s={},c=0;c<a.length;c+=1)s[a[c]]=!0;for(var l=0;l<i.length;l+=1)s[i[l]]=!0;var u=Object.keys(s);if(u.length!==a.length)return!1;var d=t,p=n;return u.every(function(t){return e(d[t],p[t])})},me=function(e,t,n){return de(e)?Object.keys(e).reduce(function(r,o){var a=!de(t)||!fe(e[o],t[o]);return n.includes(o)?(a&&console.warn("Unsupported prop change: options.".concat(o," is not a mutable property.")),r):a?oe(oe({},r||{}),{},ie({},o,e[o])):r},null):null},ye="Invalid prop `stripe` supplied to `Elements`. We recommend using the `loadStripe` utility from `@stripe/stripe-js`. See https://stripe.com/docs/stripe-js/react#elements-props-stripe for details.",he=function(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:ye;if(null===e||de(t=e)&&"function"==typeof t.elements&&"function"==typeof t.createToken&&"function"==typeof t.createPaymentMethod&&"function"==typeof t.confirmCardPayment)return e;throw new Error(n)},ge=r.createContext(null);ge.displayName="ElementsContext";var ve=function(e,t){if(!e)throw new Error("Could not find Elements context; You need to wrap the part of your app that ".concat(t," in an <Elements> provider."));return e},be=function(e){var t=e.stripe,n=e.options,o=e.children,a=r.useMemo(function(){return function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:ye;if(function(e){return de(e)&&"function"==typeof e.then}(e))return{tag:"async",stripePromise:Promise.resolve(e).then(function(e){return he(e,t)})};var n=he(e,t);return null===n?{tag:"empty"}:{tag:"sync",stripe:n}}(t)},[t]),i=se(r.useState(function(){return{stripe:"sync"===a.tag?a.stripe:null,elements:"sync"===a.tag?a.stripe.elements(n):null}}),2),s=i[0],c=i[1];r.useEffect(function(){var e=!0,t=function(e){c(function(t){return t.stripe?t:{stripe:e,elements:e.elements(n)}})};return"async"!==a.tag||s.stripe?"sync"!==a.tag||s.stripe||t(a.stripe):a.stripePromise.then(function(n){n&&e&&t(n)}),function(){e=!1}},[a,s,n]);var l=ue(t);r.useEffect(function(){null!==l&&l!==t&&console.warn("Unsupported prop change on Elements: You cannot change the `stripe` prop after setting it.")},[l,t]);var u=ue(n);return r.useEffect(function(){if(s.elements){var e=me(n,u,["clientSecret","fonts"]);e&&s.elements.update(e)}},[n,u,s.elements]),r.useEffect(function(){var e;(e=s.stripe)&&e._registerWrapper&&e.registerAppInfo&&(e._registerWrapper({name:"react-stripe-js",version:"3.10.0"}),e.registerAppInfo({name:"react-stripe-js",version:"3.10.0",url:"https://stripe.com/docs/stripe-js/react"}))},[s.stripe]),r.createElement(ge.Provider,{value:s},o)};be.propTypes={stripe:ne.any,options:ne.object};var we=r.createContext(null);we.displayName="CheckoutSdkContext",r.createContext(null).displayName="CheckoutContext",ne.shape({fetchClientSecret:ne.func.isRequired,elementsOptions:ne.object});var xe=function(e){var t=r.useContext(we),n=r.useContext(ge);if(t&&n)throw new Error("You cannot wrap the part of your app that ".concat(e," in both <CheckoutProvider> and <Elements> providers."));return t?function(e,t){if(!e)throw new Error("Could not find CheckoutProvider context; You need to wrap the part of your app that ".concat(t," in an <CheckoutProvider> provider."));return e}(t,e):ve(n,e)},Se=["mode"],Ee=function(e,t){var n,o="".concat((n=e).charAt(0).toUpperCase()+n.slice(1),"Element"),a=t?function(e){return xe("mounts <".concat(o,">")),r.createElement("div",{id:e.id,className:e.className})}:function(t){var n,a=t.id,i=t.className,s=t.options,c=void 0===s?{}:s,l=t.onBlur,u=t.onFocus,d=t.onReady,p=t.onChange,f=t.onEscape,m=t.onClick,y=t.onLoadError,h=t.onLoaderStart,g=t.onNetworksChange,v=t.onConfirm,b=t.onCancel,w=t.onShippingAddressChange,x=t.onShippingRateChange,S=t.onSavedPaymentMethodRemove,E=t.onSavedPaymentMethodUpdate,C=xe("mounts <".concat(o,">")),k="elements"in C?C.elements:null,P="checkoutSdk"in C?C.checkoutSdk:null,O=se(r.useState(null),2),j=O[0],_=O[1],A=r.useRef(null),N=r.useRef(null);le(j,"blur",l),le(j,"focus",u),le(j,"escape",f),le(j,"click",m),le(j,"loaderror",y),le(j,"loaderstart",h),le(j,"networkschange",g),le(j,"confirm",v),le(j,"cancel",b),le(j,"shippingaddresschange",w),le(j,"shippingratechange",x),le(j,"savedpaymentmethodremove",S),le(j,"savedpaymentmethodupdate",E),le(j,"change",p),d&&(n="expressCheckout"===e?d:function(){d(j)}),le(j,"ready",n),r.useLayoutEffect(function(){if(null===A.current&&null!==N.current&&(k||P)){var t=null;if(P)switch(e){case"payment":t=P.createPaymentElement(c);break;case"address":if(!("mode"in c))throw new Error("You must supply options.mode. mode must be 'billing' or 'shipping'.");var n=c.mode,r=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)t.indexOf(n=a[r])>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)t.indexOf(n=a[r])>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(c,Se);if("shipping"===n)t=P.createShippingAddressElement(r);else{if("billing"!==n)throw new Error("Invalid options.mode. mode must be 'billing' or 'shipping'.");t=P.createBillingAddressElement(r)}break;case"expressCheckout":t=P.createExpressCheckoutElement(c);break;case"currencySelector":t=P.createCurrencySelectorElement();break;case"taxId":t=P.createTaxIdElement(c);break;default:throw new Error("Invalid Element type ".concat(o,". You must use either the <PaymentElement />, <AddressElement options={{mode: 'shipping'}} />, <AddressElement options={{mode: 'billing'}} />, or <ExpressCheckoutElement />."))}else k&&(t=k.create(e,c));A.current=t,_(t),t&&t.mount(N.current)}},[k,P,c]);var I=ue(c);return r.useEffect(function(){if(A.current){var e=me(c,I,["paymentRequest"]);e&&"update"in A.current&&A.current.update(e)}},[c,I]),r.useLayoutEffect(function(){return function(){if(A.current&&"function"==typeof A.current.destroy)try{A.current.destroy(),A.current=null}catch(e){}}},[]),r.createElement("div",{id:a,className:i,ref:N})};return a.propTypes={id:ne.string,className:ne.string,onChange:ne.func,onBlur:ne.func,onFocus:ne.func,onReady:ne.func,onEscape:ne.func,onClick:ne.func,onLoadError:ne.func,onLoaderStart:ne.func,onNetworksChange:ne.func,onConfirm:ne.func,onCancel:ne.func,onShippingAddressChange:ne.func,onShippingRateChange:ne.func,onSavedPaymentMethodRemove:ne.func,onSavedPaymentMethodUpdate:ne.func,options:ne.object},a.displayName=o,a.__elementType=e,a},Ce="undefined"==typeof window;r.createContext(null).displayName="EmbeddedCheckoutProviderContext",Ee("auBankAccount",Ce),Ee("card",Ce),Ee("cardNumber",Ce),Ee("cardExpiry",Ce),Ee("cardCvc",Ce),Ee("fpxBank",Ce),Ee("iban",Ce),Ee("idealBank",Ce),Ee("p24Bank",Ce),Ee("epsBank",Ce);var ke=Ee("payment",Ce);Ee("expressCheckout",Ce),Ee("currencySelector",Ce),Ee("paymentRequestButton",Ce),Ee("linkAuthentication",Ce),Ee("address",Ce),Ee("shippingAddress",Ce),Ee("paymentMethodMessaging",Ce),Ee("affirmMessage",Ce),Ee("afterpayClearpayMessage",Ce),Ee("taxId",Ce);const Pe=u(null),Oe=({onResult:t,children:n})=>{const[r,o]=i(null),[a,u]=i(null),d=s(t);d.current=t;const p=c(e=>{d.current(e)},[]),f=c(e=>{o(e)},[]),m=c(e=>{u(e)},[]),y=l(()=>({emitResult:p,registerConfirm:f,confirmHandle:r,reportSummary:m,summary:a}),[p,f,r,m,a]);return e(Pe.Provider,{value:y,children:n})},je=()=>{const e=d(Pe);if(!e)throw new Error("Payment result channel hooks must be used inside PaymentResultChannelProvider");return e},_e=()=>je().emitResult,Ae=()=>je().registerConfirm,Ne=()=>je().reportSummary;var Ie,Te="https://js.stripe.com/v3",Me=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/,Re=function(e){var t=document.createElement("script");t.src="".concat(Te).concat("");var n=document.head||document.body;if(!n)throw new Error("Expected document.body not to be null. Stripe.js requires a <body> element.");return n.appendChild(t),t},$e=null,Fe=null,Ve=null,De=!1,Be=function(){return Ie||(Ie=(null!==$e?$e:($e=new Promise(function(e,t){if("undefined"!=typeof window&&"undefined"!=typeof document)if(window.Stripe)e(window.Stripe);else try{var n=function(){for(var e=document.querySelectorAll('script[src^="'.concat(Te,'"]')),t=0;t<e.length;t++){var n=e[t];if(Me.test(n.src))return n}return null}();if(n){if(n&&null!==Ve&&null!==Fe){var r;n.removeEventListener("load",Ve),n.removeEventListener("error",Fe),null===(r=n.parentNode)||void 0===r||r.removeChild(n),n=Re()}}else n=Re();Ve=function(e,t){return function(){window.Stripe?e(window.Stripe):t(new Error("Stripe.js not available"))}}(e,t),Fe=function(e){return function(){e(new Error("Failed to load Stripe.js"))}}(t),n.addEventListener("load",Ve),n.addEventListener("error",Fe)}catch(e){return void t(e)}else e(null)})).catch(function(e){return $e=null,Promise.reject(e)})).catch(function(e){return Ie=null,Promise.reject(e)}))};Promise.resolve().then(function(){return Be()}).catch(function(e){De||console.warn(e)});const Le=u(null),ze=({onReady:t})=>{const n=xe("calls useStripe()").stripe,o=(y=r.useContext(ge),ve(y,"calls useElements()")).elements,{paymentInit:a}=hn(),s=_e(),l=Ae(),u=Ne(),[d,f]=i(!1),m="stripe"===a?.provider?a.config.client_secret:null;var y;p(()=>{if(!n||!m)return;let e=!1;return n.retrievePaymentIntent(m).then(t=>{if(e)return;const n=t.paymentIntent;n&&"number"==typeof n.amount&&n.currency&&u({amount:n.amount,currency:n.currency})}),()=>{e=!0}},[n,m,u]);const h=c(async()=>{if(!n||!o||!m)return;f(!0);const{error:e}=await o.submit();if(e)return void f(!1);const{error:t,paymentIntent:r}=await n.confirmPayment({elements:o,clientSecret:m,confirmParams:{return_url:window.location.href},redirect:"if_required"});f(!1),t||!r||"succeeded"!==r.status&&"requires_capture"!==r.status||s({status:"success",provider:"stripe",paymentId:r.id,amount:r.amount,currency:r.currency})},[n,o,m,s]);return p(()=>(l({confirm:h,isConfirming:d}),()=>l(null)),[h,d,l]),e(ke,{options:{layout:"tabs",wallets:{applePay:"auto",googlePay:"auto"}},onReady:t})},Ue={type:"stripe",label:"Stripe",ProviderWrapper:({children:t})=>{const{paymentInit:n}=hn(),[r,o]=i(null),a="stripe"===n?.provider?n.config.publishable_key:null;p(()=>{a&&a.startsWith("pk_")&&o(function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];De=!0;var r=Date.now();return Be().then(function(e){return function(e,t,n){if(null===e)return null;var r=e.apply(void 0,t);return function(e,t){e&&e._registerWrapper&&e._registerWrapper({name:"stripe-js",version:"4.6.0",startTime:t})}(r,n),r}(e,t,r)})}(a))},[a]);const s=l(()=>({stripePromise:r}),[r]);return e(Le.Provider,{value:s,children:t})},FormComponent:({onReady:t})=>{const{themeStyles:n,theme:r}=m(),{stripePromise:o}=(()=>{const e=d(Le);if(!e)throw new Error("Stripe adapter components must be used inside StripeProviderWrapper");return e})(),{paymentInit:a}=hn(),i=l(()=>y(n,r),[n,r]),s=l(()=>function(e,t,n){return{theme:"dark"===t?"night":"stripe",variables:{colorPrimary:e.statusDiscovery.solid,colorBackground:n.cardBg,colorText:n.text,colorDanger:"#df1b41",fontFamily:n.fontFamily,borderRadius:`${n.radius}px`,spacingUnit:"3px",fontSizeBase:"16px"}}}(n,r,i),[n,r,i]),c="stripe"===a?.provider?a.config.client_secret:null,u=l(()=>c?{clientSecret:c,appearance:s}:null,[c,s]);return o&&u?e(be,{stripe:o,options:u,children:e(ze,{onReady:t})},c):null}};function qe(e){const t={};if(e.config.metadata)for(const[n,r]of Object.entries(e.config.metadata))null!=r&&(t[n]=String(r));if(e.config.customer){const{name:n,email:r,phone:o,reference_id:a}=e.config.customer;n&&(t.customer_name=n),r&&(t.customer_email=r),o&&(t.customer_phone=o),a&&(t.customer_reference_id=a)}return t}class We extends Error{constructor(e,t,n){super(e),this.status=t,this.body=n,this.name="MoyasarApiError"}}async function Ye(e){const t=await He("https://api.moyasar.com/v1/payments",e);if(!t.ok)throw new We(Je(t.body)??`Payment creation failed (${t.status})`,t.status,t.body);const n=t.body;if(!n||"string"!=typeof n.id||"string"!=typeof n.status)throw new We("Payment creation returned no id/status",t.status,n);return n}async function He(e,t){const n=new AbortController,r=setTimeout(()=>n.abort(new DOMException("Request timed out","TimeoutError")),3e4);let o;try{o=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t),signal:n.signal})}catch(e){const t=e instanceof DOMException&&"TimeoutError"===e.name?"Payment request timed out — please try again.":e instanceof Error?e.message:"Network request failed";throw new We(t)}finally{clearTimeout(r)}let a=null;try{a=await o.json()}catch{a=null}return{ok:o.ok,status:o.status,body:a}}function Je(e){if(!e||"object"!=typeof e)return null;if("string"==typeof e.message&&e.message.length>0)return e.message;if(e.errors&&"object"==typeof e.errors){const t=e.errors;for(const[e,n]of Object.entries(t)){if(Array.isArray(n)&&"string"==typeof n[0])return`${Ke(e)}: ${n[0]}`;if("string"==typeof n)return`${Ke(e)}: ${n}`}}return null}function Ke(e){return e.replace(/_/g," ")}const Xe=({url:n,onResult:r,skin:o})=>{const a=s(r);a.current=r;const l=s(!1),[u,d]=i(!1),f=s(!1),m=c(e=>{l.current||(l.current=!0,a.current({status:"failure",provider:"moyasar",message:e}))},[]);return p(()=>{const e=window.location.origin,t=t=>{if(t.origin!==e)return;if(l.current)return;if(!(n=t.data)||"object"!=typeof n||"moyasar-iframe-callback"!==n.type||"string"!=typeof n.search)return;var n;const r=h(t.data.search);r&&(l.current=!0,a.current(r.result))};return window.addEventListener("message",t),()=>window.removeEventListener("message",t)},[]),p(()=>{const e=setTimeout(()=>{f.current||m("3D Secure challenge failed to load")},6e4);return()=>clearTimeout(e)},[m]),t("div",{className:"absolute inset-0 z-[105]",style:{background:o.cardBg},role:"dialog","aria-label":"3D Secure authentication",children:[!u&&e("div",{className:"absolute inset-0 flex items-center justify-center text-sm",style:{color:o.muted,fontFamily:o.fontFamily},children:"Loading…"}),e("iframe",{src:n,title:"3D Secure",className:"w-full h-full",style:{border:0,background:"white"},onLoad:()=>{f.current=!0,d(!0)},onError:()=>{m("3D Secure challenge failed to load")},allow:"payment *",sandbox:"allow-scripts allow-forms allow-same-origin allow-popups allow-top-navigation-by-user-activation",referrerPolicy:"no-referrer"})]})},Ze=["mada","visa","masterCard"],Ge="data-aiatcore-apple-pay",Qe=({skin:r})=>{const{paymentInit:o}=hn(),a=o&&"moyasar"===o.provider?o:null,l=_e(),[u,d]=i(null),f=s(l);f.current=l,p(()=>{!function(){if("undefined"==typeof document)return;if(document.querySelector(`style[${Ge}]`))return;const e=document.createElement("style");e.setAttribute(Ge,"true"),e.textContent="\n .aiatcore-apple-pay-button {\n -webkit-appearance: -apple-pay-button;\n -apple-pay-button-type: pay;\n -apple-pay-button-style: black;\n width: 100%;\n cursor: pointer;\n border: none;\n padding: 0;\n margin: 0;\n }\n ",document.head.appendChild(e)}()},[]);const m=c(()=>{if(!a)return;const e=window.ApplePaySession;if(!e)return void g("Apple Pay is not available on this device.");const t=a.config.apple_pay?.label??a.config.description??"Payment",n=a.config.apple_pay?.country??"SA",r=a.config.currency.toUpperCase(),o=(a.config.amount/100).toFixed(2),i={countryCode:n,currencyCode:r,supportedNetworks:Ze,merchantCapabilities:["supports3DS","supportsDebit","supportsCredit"],total:{label:t,amount:o}};let s;try{s=new e(5,i)}catch(e){return void g(e instanceof Error?e.message:"Failed to start Apple Pay")}s.onvalidatemerchant=async e=>{try{const n=await async function(e){const t={validation_url:e.validationUrl,display_name:e.displayName,domain_name:e.domainName??window.location.hostname,publishable_api_key:e.publishableApiKey},n=new AbortController,r=setTimeout(()=>n.abort(new DOMException("Request timed out","TimeoutError")),3e4);let o;try{o=await fetch("https://api.moyasar.com/v1/applepay/initiate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t),signal:n.signal})}catch(e){const t=e instanceof DOMException&&"TimeoutError"===e.name?"Apple Pay merchant validation timed out — please try again.":e instanceof Error?e.message:"Network request failed";throw new We(t)}finally{clearTimeout(r)}let a=null;try{a=await o.json()}catch{a=null}if(!o.ok)throw new We(function(e){return e&&"object"==typeof e&&"string"==typeof e.message&&e.message.length>0?e.message:null}(a)??`Apple Pay merchant validation failed (${o.status})`,o.status,a);return a}({validationUrl:e.validationURL,displayName:t,publishableApiKey:a.config.publishable_key});s.completeMerchantValidation(n)}catch(e){const t=e instanceof Error?e.message:"Merchant validation failed";s.abort(),l({status:"failure",provider:"moyasar",message:t,paymentId:a.config.given_id})}},s.onpaymentauthorized=async t=>{try{const n=qe(a),o=await Ye({publishable_api_key:a.config.publishable_key,given_id:a.config.given_id,amount:a.config.amount,currency:r,description:a.config.description,callback_url:v(a.config.given_id),source:{type:"applepay",token:t.payment.token},...Object.keys(n).length>0?{metadata:n}:{}}),i=o.source?.transaction_url??o.transaction_url;if(i)return s.completePayment({status:e.STATUS_SUCCESS}),void d(i);const c=o.status;if("paid"===c||"authorized"===c||"captured"===c)s.completePayment({status:e.STATUS_SUCCESS}),l({status:"success",provider:"moyasar",paymentId:o.id,amount:o.amount,currency:o.currency});else if("failed"===c){const t=o.source?.message??"Payment failed";s.completePayment({status:e.STATUS_FAILURE}),l({status:"failure",provider:"moyasar",code:"failed",message:t,paymentId:o.id})}else{const t=`Unexpected payment status: ${c}`;s.completePayment({status:e.STATUS_FAILURE}),l({status:"failure",provider:"moyasar",code:c,message:t,paymentId:o.id})}}catch(t){const n=t instanceof We||t instanceof Error?t.message:"Payment failed";s.completePayment({status:e.STATUS_FAILURE}),l({status:"failure",provider:"moyasar",message:n,paymentId:a.config.given_id})}},s.oncancel=()=>{};try{s.begin()}catch(e){g(e instanceof Error?e.message:"Failed to start Apple Pay")}},[a,l]);return a?t(n,{children:[e("button",{type:"button",onClick:m,className:"aiatcore-apple-pay-button",style:{borderRadius:r.radius,height:44},"aria-label":"Pay with Apple Pay"}),u&&e(Xe,{url:u,skin:r,onResult:e=>{d(null),f.current(e)}})]}):null};var et,tt,nt,rt={},ot={};function at(){return nt||(nt=1,Object.defineProperty(ot,"__esModule",{value:!0}),ot.clone=function(e){return e?JSON.parse(JSON.stringify(e)):null}),ot}var it,st,ct,lt,ut,dt,pt={},ft={},mt={};function yt(){if(dt)return ut;dt=1;var e=ut&&ut.__assign||function(){return e=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},e.apply(this,arguments)},t=tt?et:(tt=1,et={visa:{niceType:"Visa",type:"visa",patterns:[4],gaps:[4,8,12],lengths:[16,18,19],code:{name:"CVV",size:3}},mastercard:{niceType:"Mastercard",type:"mastercard",patterns:[[51,55],[2221,2229],[223,229],[23,26],[270,271],2720],gaps:[4,8,12],lengths:[16],code:{name:"CVC",size:3}},"american-express":{niceType:"American Express",type:"american-express",patterns:[34,37],gaps:[4,10],lengths:[15],code:{name:"CID",size:4}},"diners-club":{niceType:"Diners Club",type:"diners-club",patterns:[[300,305],36,38,39],gaps:[4,10],lengths:[14,16,19],code:{name:"CVV",size:3}},discover:{niceType:"Discover",type:"discover",patterns:[6011,[644,649],65],gaps:[4,8,12],lengths:[16,19],code:{name:"CID",size:3}},jcb:{niceType:"JCB",type:"jcb",patterns:[2131,1800,[3528,3589]],gaps:[4,8,12],lengths:[16,17,18,19],code:{name:"CVV",size:3}},unionpay:{niceType:"UnionPay",type:"unionpay",patterns:[620,[62100,62182],[62184,62187],[62185,62197],[62200,62205],[622010,622999],622018,[62207,62209],[623,626],6270,6272,6276,[627700,627779],[627781,627799],[6282,6289],6291,6292,810,[8110,8131],[8132,8151],[8152,8163],[8164,8171]],gaps:[4,8,12],lengths:[14,15,16,17,18,19],code:{name:"CVN",size:3}},maestro:{niceType:"Maestro",type:"maestro",patterns:[493698,[5e5,504174],[504176,506698],[506779,508999],[56,59],63,67,6],gaps:[4,8,12],lengths:[12,13,14,15,16,17,18,19],code:{name:"CVC",size:3}},elo:{niceType:"Elo",type:"elo",patterns:[401178,401179,438935,457631,457632,431274,451416,457393,504175,[506699,506778],[509e3,509999],627780,636297,636368,[650031,650033],[650035,650051],[650405,650439],[650485,650538],[650541,650598],[650700,650718],[650720,650727],[650901,650978],[651652,651679],[655e3,655019],[655021,655058]],gaps:[4,8,12],lengths:[16],code:{name:"CVE",size:3}},mir:{niceType:"Mir",type:"mir",patterns:[[2200,2204]],gaps:[4,8,12],lengths:[16,17,18,19],code:{name:"CVP2",size:3}},hiper:{niceType:"Hiper",type:"hiper",patterns:[637095,63737423,63743358,637568,637599,637609,637612],gaps:[4,8,12],lengths:[16],code:{name:"CVC",size:3}},hipercard:{niceType:"Hipercard",type:"hipercard",patterns:[606282],gaps:[4,8,12],lengths:[16],code:{name:"CVC",size:3}},verve:{niceType:"Verve",type:"verve",patterns:[[506099,506127],506129,[506133,506150],[506158,506163],506166,506168,506170,506173,[506176,506180],506184,[506187,506188],506191,506195,506197,507865,507866,[507868,507877],[507880,507888],507900,507941],gaps:[4,8,12],lengths:[16,18,19],code:{name:"CVV",size:3}}}),n=function(){if(st)return rt;st=1,Object.defineProperty(rt,"__esModule",{value:!0}),rt.addMatchingCardsToResults=function(n,r,o){var a,i;for(a=0;a<r.patterns.length;a++){var s=r.patterns[a];if((0,t.matches)(n,s)){var c=(0,e.clone)(r);i=Array.isArray(s)?String(s[0]).length:String(s).length,n.length>=i&&(c.matchStrength=i),o.push(c);break}}};var e=at(),t=(it||(it=1,Object.defineProperty(pt,"__esModule",{value:!0}),pt.matches=function(e,t){return Array.isArray(t)?function(e,t,n){var r=String(t).length,o=e.substr(0,r),a=parseInt(o,10);return t=parseInt(String(t).substr(0,o.length),10),n=parseInt(String(n).substr(0,o.length),10),a>=t&&a<=n}(e,t[0],t[1]):function(e,t){return(t=String(t)).substring(0,e.length)===e.substring(0,t.length)}(e,t)}),pt);return rt}(),r=(ct||(ct=1,Object.defineProperty(ft,"__esModule",{value:!0}),ft.isValidInputType=function(e){return"string"==typeof e||e instanceof String}),ft),o=(lt||(lt=1,Object.defineProperty(mt,"__esModule",{value:!0}),mt.findBestMatch=function(e){return function(e){var t=e.filter(function(e){return e.matchStrength}).length;return t>0&&t===e.length}(e)?e.reduce(function(e,t){return e?Number(e.matchStrength)<Number(t.matchStrength)?t:e:t}):null}),mt),a=at(),i={},s={VISA:"visa",MASTERCARD:"mastercard",AMERICAN_EXPRESS:"american-express",DINERS_CLUB:"diners-club",DISCOVER:"discover",JCB:"jcb",UNIONPAY:"unionpay",VERVE:"verve",MAESTRO:"maestro",ELO:"elo",MIR:"mir",HIPER:"hiper",HIPERCARD:"hipercard"},c=[s.VISA,s.MASTERCARD,s.AMERICAN_EXPRESS,s.DINERS_CLUB,s.DISCOVER,s.JCB,s.UNIONPAY,s.VERVE,s.MAESTRO,s.ELO,s.MIR,s.HIPER,s.HIPERCARD],l=(0,a.clone)(c);function u(e){return i[e]||t[e]}function d(e,t){void 0===t&&(t=!1);var n=l.indexOf(e);if(!t&&-1===n)throw new Error('"'+e+'" is not a supported card type.');return n}function p(e){var t=[];if(!(0,r.isValidInputType)(e))return t;if(0===e.length)return l.map(function(e){return(0,a.clone)(u(e))});l.forEach(function(r){var o=u(r);(0,n.addMatchingCardsToResults)(e,o,t)});var i=(0,o.findBestMatch)(t);return i?[i]:t}return p.getTypeInfo=function(e){return(0,a.clone)(u(e))},p.removeCard=function(e){var t=d(e);l.splice(t,1)},p.addCard=function(e){var t=d(e.type,!0);i[e.type]=e,-1===t&&l.push(e.type)},p.updateCard=function(n,r){var o=i[n]||t[n];if(!o)throw new Error('"'.concat(n,"\" is not a recognized type. Use `addCard` instead.'"));if(r.type&&o.type!==r.type)throw new Error("Cannot overwrite type parameter.");var s=(0,a.clone)(o);s=e(e({},s),r),i[s.type]=s},p.changeOrder=function(e,t){var n=d(e);l.splice(n,1),l.splice(t,0,e)},p.resetModifications=function(){l=(0,a.clone)(c),i={}},p.types=s,ut=p}var ht,gt,vt,bt,wt,xt={},St={},Et={},Ct={},kt={};function Pt(){if(wt)return kt;wt=1,Object.defineProperty(kt,"__esModule",{value:!0}),kt.expirationYear=function(n,r){var o;if(void 0===r&&(r=e),"string"!=typeof n)return t(!1,!1);if(""===n.replace(/\s/g,""))return t(!1,!0);if(!/^\d*$/.test(n))return t(!1,!1);var a=n.length;if(a<2)return t(!1,!0);var i=(new Date).getFullYear();if(3===a)return t(!1,n.slice(0,2)===String(i).slice(0,2));if(a>4)return t(!1,!1);var s=parseInt(n,10),c=Number(String(i).substr(2,2)),l=!1;if(2===a){if(String(i).substr(0,2)===n)return t(!1,!0);o=c===s,l=s>=c&&s<=c+r}else 4===a&&(o=i===s,l=s>=i&&s<=i+r);return t(l,l,o)};var e=19;function t(e,t,n){return{isValid:e,isPotentiallyValid:t,isCurrentYear:n||!1}}return kt}var Ot,jt,_t,At,Nt={},It={};function Tt(){if(_t)return It;function e(e,t,n){return{isValid:e,isPotentiallyValid:t,isValidForThisYear:n||!1}}return _t=1,Object.defineProperty(It,"__esModule",{value:!0}),It.expirationMonth=function(t){var n=(new Date).getMonth()+1;if("string"!=typeof t)return e(!1,!1);if(""===t.replace(/\s/g,"")||"0"===t)return e(!1,!0);if(!/^\d*$/.test(t))return e(!1,!1);var r=parseInt(t,10);if(isNaN(Number(t)))return e(!1,!1);var o=r>0&&r<13;return e(o,o,o&&r>=n)},It}var Mt,Rt,$t,Ft,Vt={},Dt={};const Bt=j(function(){if(Ft)return $t;Ft=1;var e=$t&&$t.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),t=$t&&$t.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=($t&&$t.__importStar||function(){var n=function(e){return(n=Object.getOwnPropertyNames||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[t.length]=n);return t})(e)};return function(r){if(r&&r.__esModule)return r;var o={};if(null!=r)for(var a=n(r),i=0;i<a.length;i++)"default"!==a[i]&&e(o,r,a[i]);return t(o,r),o}}())(yt()),r=function(){if(ht)return xt;ht=1,Object.defineProperty(xt,"__esModule",{value:!0}),xt.cardholderName=function(r){return"string"!=typeof r?n(!1,!1):0===r.length?n(!1,!0):r.length>t?n(!1,!1):e.test(r)?n(!1,!0):n(!0,!0)};var e=/^[\d\s-]*$/,t=255;function n(e,t){return{isValid:e,isPotentiallyValid:t}}return xt}(),o=function(){if(bt)return St;bt=1,Object.defineProperty(St,"__esModule",{value:!0}),St.cardNumber=function(r,o){var a,i;if(void 0===o&&(o={}),"string"!=typeof r&&"number"!=typeof r)return n(null,!1,!1);var s=String(r).replace(/-|\s/g,"");if(!/^\d*$/.test(s))return n(null,!1,!1);var c=t(s);if(0===c.length)return n(null,!1,!1);if(1!==c.length)return n(null,!0,!1);var l=c[0];if(o.maxLength&&s.length>o.maxLength)return n(l,!1,!1);a=!0===o.skipLuhnValidation||l.type===t.types.UNIONPAY&&!0!==o.luhnValidateUnionPay||e(s),i=Math.max.apply(null,l.lengths),o.maxLength&&(i=Math.min(o.maxLength,i));for(var u=0;u<l.lengths.length;u++)if(l.lengths[u]===s.length)return n(l,s.length<i||a,a);return n(l,s.length<i,!1)};var e=vt?gt:(vt=1,gt=function(e){for(var t,n=0,r=!1,o=e.length-1;o>=0;)t=parseInt(e.charAt(o),10),r&&(t*=2)>9&&(t=t%10+1),r=!r,n+=t,o--;return n%10==0}),t=yt();function n(e,t,n){return{card:e,isPotentiallyValid:t,isValid:n}}return St}(),a=function(){if(At)return Et;At=1;var e=Et&&Et.__assign||function(){return e=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},e.apply(this,arguments)};Object.defineProperty(Et,"__esModule",{value:!0}),Et.expirationDate=function(a,i){var s;if("string"==typeof a)a=a.replace(/^(\d\d) (\d\d(\d\d)?)$/,"$1/$2"),s=(0,t.parseDate)(String(a));else{if(null===a||"object"!=typeof a)return o(!1,!1,null,null);var c=e({},a);s={month:String(c.month),year:String(c.year)}}var l=(0,n.expirationMonth)(s.month),u=(0,r.expirationYear)(s.year,i);if(l.isValid){if(u.isCurrentYear){var d=l.isValidForThisYear;return o(d,d,s.month,s.year)}if(u.isValid)return o(!0,!0,s.month,s.year)}return o(!1,!(!l.isPotentiallyValid||!u.isPotentiallyValid),null,null)};var t=function(){if(jt)return Ct;jt=1,Object.defineProperty(Ct,"__esModule",{value:!0}),Ct.parseDate=function(n){var r;if(/^\d{4}-\d{1,2}$/.test(n)?r=n.split("-").reverse():/\//.test(n)?r=n.split(/\s*\/\s*/g):/\s/.test(n)&&(r=n.split(/ +/g)),(0,t.isArray)(r))return{month:r[0]||"",year:r.slice(1).join()};var o,a,i,s=(o=n,0===(i=Number(o[0]))?2:i>1||1===i&&Number(o[1])>2?1:1===i?(a=o.substr(1),(0,e.expirationYear)(a).isPotentiallyValid?1:2):5===o.length?1:o.length>5?2:1),c=n.substr(0,s);return{month:c,year:n.substr(c.length)}};var e=Pt(),t=(Ot||(Ot=1,Object.defineProperty(Nt,"__esModule",{value:!0}),Nt.isArray=void 0,Nt.isArray=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)}),Nt);return Ct}(),n=Tt(),r=Pt();function o(e,t,n,r){return{isValid:e,isPotentiallyValid:t,month:n,year:r}}return Et}(),i=Tt(),s=Pt(),c=function(){if(Mt)return Vt;Mt=1,Object.defineProperty(Vt,"__esModule",{value:!0}),Vt.cvv=function(n,r){return void 0===r&&(r=e),r=r instanceof Array?r:[r],"string"!=typeof n?t(!1,!1):/^\d*$/.test(n)?function(e,t){for(var n=0;n<e.length;n++)if(t===e[n])return!0;return!1}(r,n.length)?t(!0,!0):n.length<Math.min.apply(null,r)?t(!1,!0):n.length>function(t){for(var n=e,r=0;r<t.length;r++)n=t[r]>n?t[r]:n;return n}(r)?t(!1,!1):t(!0,!0):t(!1,!1)};var e=3;function t(e,t){return{isValid:e,isPotentiallyValid:t}}return Vt}(),l=function(){if(Rt)return Dt;Rt=1,Object.defineProperty(Dt,"__esModule",{value:!0}),Dt.postalCode=function(r,o){void 0===o&&(o={});var a=o.minLength||e;return"string"!=typeof r?n(!1,!1):r.length<a?n(!1,!0):t.test(r.trim().slice(0,a))?n(!0,!0):n(!1,!0)};var e=2,t=new RegExp(/^[a-z0-9]+$/i);function n(e,t){return{isValid:e,isPotentiallyValid:t}}return Dt}();return $t={creditCardType:n,cardholderName:r.cardholderName,number:o.cardNumber,expirationDate:a.expirationDate,expirationMonth:i.expirationMonth,expirationYear:s.expirationYear,cvv:c.cvv,postalCode:l.postalCode}}()),Lt=j(yt());let zt=!1;zt||(zt=!0,Lt.addCard({niceType:"Mada",type:"mada",patterns:[440647,440795,446404,446672,419593,428331,428671,432328,440533,446393,457865,458456,462220,484783,484800,493428,504300,521076,529415,535825,536023,537767,543357,557606,558848,588845,589206],gaps:[4,8,12],lengths:[16,18,19],code:{name:"CVV",size:3}}));const Ut=({brand:t,fallbackColor:n,height:r=22})=>{if(!t)return null;switch(t){case"Visa":return e(qt,{height:r});case"Mastercard":return e(Wt,{height:r});case"American Express":return e(Yt,{height:r});case"Mada":return e(Ht,{height:r});case"Discover":return e(Jt,{height:r});case"JCB":return e(Kt,{height:r});default:return e("span",{className:"text-xs font-medium",style:{color:n},"aria-label":`Card brand: ${t}`,children:t})}},qt=({height:n})=>t("svg",{role:"img","aria-label":"Visa",viewBox:"0 0 48 16",height:n,width:48*n/16,style:{display:"block"},children:[e("rect",{width:"48",height:"16",rx:"2",fill:"#1A1F71"}),e("text",{x:"24",y:"12",textAnchor:"middle",fontFamily:"Helvetica, Arial, sans-serif",fontWeight:"900",fontSize:"11",fill:"#FFFFFF",letterSpacing:"1.4",children:"VISA"})]}),Wt=({height:n})=>t("svg",{role:"img","aria-label":"Mastercard",viewBox:"0 0 32 20",height:n,width:32*n/20,style:{display:"block"},children:[e("circle",{cx:"12",cy:"10",r:"7",fill:"#EB001B"}),e("circle",{cx:"20",cy:"10",r:"7",fill:"#F79E1B"}),e("path",{d:"M16 4.5a7 7 0 0 1 0 11 7 7 0 0 1 0-11Z",fill:"#FF5F00","aria-hidden":"true"})]}),Yt=({height:n})=>t("svg",{role:"img","aria-label":"American Express",viewBox:"0 0 48 16",height:n,width:48*n/16,style:{display:"block"},children:[e("rect",{width:"48",height:"16",rx:"2",fill:"#2E77BB"}),e("text",{x:"24",y:"11.5",textAnchor:"middle",fontFamily:"Helvetica, Arial, sans-serif",fontWeight:"700",fontSize:"9",fill:"#FFFFFF",letterSpacing:"0.4",children:"AMEX"})]}),Ht=({height:n})=>t("svg",{role:"img","aria-label":"Mada",viewBox:"0 0 48 16",height:n,width:48*n/16,style:{display:"block"},children:[e("rect",{width:"48",height:"16",rx:"2",fill:"#84B740"}),e("text",{x:"24",y:"11.5",textAnchor:"middle",fontFamily:"Helvetica, Arial, sans-serif",fontWeight:"700",fontSize:"9",fill:"#FFFFFF",letterSpacing:"0.6",children:"mada"})]}),Jt=({height:n})=>t("svg",{role:"img","aria-label":"Discover",viewBox:"0 0 56 16",height:n,width:56*n/16,style:{display:"block"},children:[e("rect",{width:"56",height:"16",rx:"2",fill:"#FFFFFF",stroke:"#E5E7EB"}),e("text",{x:"20",y:"11.5",textAnchor:"middle",fontFamily:"Helvetica, Arial, sans-serif",fontWeight:"700",fontSize:"8",fill:"#231F20",letterSpacing:"0.2",children:"DISCOVER"}),e("circle",{cx:"44",cy:"8",r:"4",fill:"#FF6000"})]}),Kt=({height:n})=>t("svg",{role:"img","aria-label":"JCB",viewBox:"0 0 32 16",height:n,width:32*n/16,style:{display:"block"},children:[e("rect",{x:"0",y:"0",width:"10.66",height:"16",rx:"2",fill:"#0E4C96"}),e("rect",{x:"10.66",y:"0",width:"10.66",height:"16",fill:"#B41E25"}),e("rect",{x:"21.33",y:"0",width:"10.66",height:"16",rx:"2",fill:"#1B8A3A"}),e("text",{x:"16",y:"11",textAnchor:"middle",fontFamily:"Helvetica, Arial, sans-serif",fontWeight:"900",fontSize:"9",fill:"#FFFFFF",children:"JCB"})]}),Xt=({skin:r})=>{const{paymentInit:o}=hn(),a=o&&"moyasar"===o.provider?o:null,u=_e(),d=Ae(),f=Ne(),[m,y]=i(""),[h,g]=i(""),[b,w]=i(""),[x,S]=i(""),[E,C]=i(!1),[k,P]=i({}),[O,j]=i(null),_=s({number:m,expiry:h,cvc:b,name:x});_.current={number:m,expiry:h,cvc:b,name:x};const A=s(u);A.current=u,p(()=>{a&&f({amount:a.config.amount,currency:a.config.currency.toUpperCase()})},[a,f]);const N=c(async()=>{if(!a)return;const e=function(e,t=new Date){const n=[],r=Bt.number(e.number),o=e.number.replace(/\D/g,"");o?r.isValid||n.push({field:"number",message:"Invalid card number"}):n.push({field:"number",message:"Card number is required"});const a=Bt.expirationDate(e.expiry);let i=null,s=null;const c=e.expiry.trim();if(c)if(a.isValid){i=Number.parseInt(a.month??"",10);const e=Number.parseInt(a.year??"",10);s=2===(a.year??"").length?e+2e3:e}else{const e=function(e){let t="",n="";if(e.includes("/")){const[r,o]=e.split("/");t=(r??"").replace(/\D/g,""),n=(o??"").replace(/\D/g,"")}else{const r=e.replace(/\D/g,"");t=r.slice(0,2),n=r.slice(2)}const r=Number.parseInt(t,10),o=Number.parseInt(n,10);return Number.isNaN(r)||Number.isNaN(o)?null:{month:r,year:2===n.length?o+2e3:o}}(c);e&&function(e,t,n){const r=n.getFullYear(),o=n.getMonth()+1;return t<r||t===r&&e<o}(e.month,e.year,t)?n.push({field:"expiry",message:"Card expired"}):n.push({field:"expiry",message:"Invalid expiry"})}else n.push({field:"expiry",message:"Expiry is required"});const l=Bt.cvv(e.cvc,r.card?.code.size??[3,4]),u=e.cvc.replace(/\D/g,"");u?l.isValid||n.push({field:"cvc",message:"Invalid CVC"}):n.push({field:"cvc",message:"CVC is required"});const d=Bt.cardholderName(e.name),p=e.name.trim();return p?d.isValid||n.push({field:"name",message:"Invalid cardholder name"}):n.push({field:"name",message:"Cardholder name is required"}),n.length>0||null==i||null==s?{ok:!1,errors:n}:{ok:!0,card:{number:o,month:String(i).padStart(2,"0"),year:String(s),cvc:u,name:p}}}(_.current);if(!1===e.ok){const t={};for(const n of e.errors)t[n.field]||(t[n.field]=n.message);return void P(t)}P({}),C(!0);try{const t=await async function(e){const t=await He("https://api.moyasar.com/v1/tokens",{...e,save_only:!0});if(!t.ok)throw new We(Je(t.body)??`Tokenization failed (${t.status})`,t.status,t.body);const n=t.body;if(!n||"string"!=typeof n.id)throw new We("Tokenization returned no token id",t.status,n);return{id:n.id}}({publishable_api_key:a.config.publishable_key,name:e.card.name,number:e.card.number,month:e.card.month,year:e.card.year,cvc:e.card.cvc}),n=qe(a),r=await Ye({publishable_api_key:a.config.publishable_key,given_id:a.config.given_id,amount:a.config.amount,currency:a.config.currency.toUpperCase(),description:a.config.description,callback_url:v(a.config.given_id),source:{type:"token",token:t.id},...Object.keys(n).length>0?{metadata:n}:{}}),o=r.source?.transaction_url??r.transaction_url;if(o)return void j(o);const i=r.status;A.current("paid"===i||"authorized"===i||"captured"===i?{status:"success",provider:"moyasar",paymentId:r.id,amount:r.amount,currency:r.currency}:"failed"===i?{status:"failure",provider:"moyasar",code:"failed",message:r.source?.message??"Payment failed",paymentId:r.id}:{status:"failure",provider:"moyasar",code:i,message:`Unexpected payment status: ${i}`,paymentId:r.id})}catch(e){const t=e instanceof We||e instanceof Error?e.message:"Payment failed";A.current({status:"failure",provider:"moyasar",message:t,paymentId:a.config.given_id})}finally{C(!1)}},[a]);p(()=>(d({confirm:N,isConfirming:E}),()=>d(null)),[N,E,d]);const I=l(()=>Math.max(r.radius-4,4),[r.radius]),T=l(()=>function(e){const t=e.replace(/\D/g,"");if(t.length<2)return null;const n=Lt(t);return n[0]?.niceType??null}(m),[m]);return a?t(n,{children:[t("div",{className:"space-y-3",style:{fontFamily:r.fontFamily},children:[e(Gt,{label:"Card number",value:m,onChange:e=>y(e.replace(/\D/g,"").slice(0,19).replace(/(\d{4})(?=\d)/g,"$1 ")),autoComplete:"cc-number",inputMode:"numeric",placeholder:"1234 5678 9012 3456",error:k.number,skin:r,radius:I,endAdornment:T?e(Ut,{brand:T,fallbackColor:r.muted}):null}),t("div",{className:"grid grid-cols-2 gap-3",children:[e(Gt,{label:"Expiry",value:h,onChange:e=>g(function(e){const t=e.replace(/\D/g,"").slice(0,4);return t.length<=2?t:`${t.slice(0,2)}/${t.slice(2)}`}(e)),autoComplete:"cc-exp",inputMode:"numeric",placeholder:"MM / YY",error:k.expiry,skin:r,radius:I}),e(Gt,{label:"CVC",value:b,onChange:e=>w(e.replace(/\D/g,"").slice(0,4)),autoComplete:"cc-csc",inputMode:"numeric",placeholder:"123",error:k.cvc,skin:r,radius:I})]}),e(Gt,{label:"Name on card",value:x,onChange:S,autoComplete:"cc-name",inputMode:"text",placeholder:"Full name",error:k.name,skin:r,radius:I})]}),O&&e(Xe,{url:O,skin:r,onResult:e=>{j(null),A.current(e)}})]}):null};function Zt(e){let t=0;for(let n=0;n<e.length;n++){const r=e.charCodeAt(n);r>=48&&r<=57&&t++}return t}const Gt=({label:n,value:r,onChange:o,placeholder:a,autoComplete:i,inputMode:c,error:l,skin:u,radius:d,endAdornment:p})=>{const m=l?"#dc2626":u.divider,y=s(null),h=s(null),g="numeric"===c;return f(()=>{const e=h.current;if(null===e||!y.current)return;h.current=null;const t=y.current.value;let n=0,r=0;for(;r<t.length&&!(n>=e);)/\d/.test(t[r])&&n++,r++;y.current.setSelectionRange(r,r)},[r]),t("label",{className:"block",children:[e("span",{className:"block text-xs mb-1",style:{color:u.muted},children:n}),t("div",{className:"relative",children:[e("input",{ref:y,type:"text",value:r,onChange:e=>{g&&(h.current=Zt(e.target.value.slice(0,e.target.selectionStart??e.target.value.length))),o(e.target.value)},onKeyDown:e=>{if(!g||"Backspace"!==e.key)return;const t=e.currentTarget,n=t.selectionStart??0;if(n!==(t.selectionEnd??0)||n<2)return;const r=t.value[n-1];if(!r||/\d/.test(r))return;e.preventDefault();const a=t.value.slice(0,n-2)+t.value.slice(n);h.current=Zt(a.slice(0,n-2)),o(a)},placeholder:a,autoComplete:i,inputMode:c,spellCheck:!1,className:"w-full py-2.5 px-3 outline-none text-sm transition-colors",style:{background:u.pillBg,color:u.text,border:`1px solid ${m}`,borderRadius:d,paddingRight:p?96:void 0}}),p&&e("span",{className:"absolute right-3 top-1/2 -translate-y-1/2 text-xs font-medium pointer-events-none",style:{color:u.muted},"aria-label":"Card brand",children:p})]}),l&&e("span",{className:"block mt-1 text-xs",style:{color:"#dc2626"},children:l})]})},Qt=["creditcard","applepay"],en=({skin:n})=>t("div",{className:"relative",children:[e("div",{className:"absolute inset-x-0 top-1/2",style:{borderTop:`1px solid ${n.divider}`}}),e("div",{className:"relative flex justify-center",children:e("span",{className:"px-2 text-xs uppercase tracking-wide",style:{background:n.cardBg,color:n.muted,fontFamily:n.fontFamily},children:"or"})})]}),tn={type:"moyasar",label:"Moyasar",FormComponent:({skin:n,onReady:r})=>{const{paymentInit:o}=hn(),a=o&&"moyasar"===o.provider?o:null,c=function(){const[e,t]=i(!1);return p(()=>{if("undefined"==typeof window)return;const e=window.ApplePaySession;if(e&&"function"==typeof e.canMakePayments)try{t(!0===e.canMakePayments())}catch{t(!1)}},[]),e}(),l=s(r);if(l.current=r,p(()=>{l.current?.()},[]),!a)return null;const u=a.config.methods??Qt,d=u.includes("creditcard"),f=u.includes("applepay")&&c;return t("div",{className:"space-y-4",children:[d&&e(Xt,{skin:n}),d&&f&&e(en,{skin:n}),f&&e(Qe,{skin:n})]})}},nn="5vh",rn="5vw",on="aiatcore-chargebee-modal-style",an="aiatcore-chargebee-close-button",sn="aiatcore-chargebee-loader",cn="aiatcore-cb-spin",ln='#cb-container, .cb-container, [id^="cb-modal"], [class*="cb-modal"], [class*="cb-checkout"], div[class*="cb-"][class*="overlay"]',un="aiatcore-chargebee-open";function dn(){document.getElementById(an)?.remove()}function pn(){document.getElementById(sn)?.remove()}const fn={type:"chargebee",label:"Chargebee",FormComponent:({amount:e,currency:t,onReady:n})=>{const{paymentInit:r}=hn(),o=_e(),a=Ne(),i=Ae(),c=s(!1);return p(()=>(i(null),()=>i(null)),[i]),p(()=>{if("chargebee"!==r?.provider)return;const{site:i,hosted_page_url:s,amount:l,currency:u,expires_at:d}=r.config,p=l??e,f=u??t;null!=p&&f&&a({amount:p,currency:f}),c.current=!1;let m=!1,y=null,h=null;const g=e=>{c.current||(c.current=!0,o(e))};return n?.(),null!=d&&Date.now()>=1e3*d?(g({status:"failure",provider:"chargebee",message:"Payment link has expired. Please request a new one."}),()=>{m=!0}):(function(){const e=document.getElementById(on)??document.createElement("style");e.id=on,e.textContent=`\n /* Prevent horizontal page scroll only while Chargebee's overlay is mounted */\n html.${un}, body.${un} {\n overflow-x: hidden !important;\n }\n\n /* Outer Chargebee overlay container — broad selector net so we catch\n whatever wrapper Chargebee actually uses */\n #cb-container,\n .cb-container,\n [id^="cb-modal"],\n [class*="cb-modal"],\n [class*="cb-checkout"],\n div[class*="cb-"][class*="overlay"] {\n position: fixed !important;\n inset: ${nn} max(${rn}, calc((100vw - 1500px) / 2)) !important;\n width: auto !important;\n height: auto !important;\n max-width: none !important;\n max-height: none !important;\n margin: 0 !important;\n border-radius: 12px !important;\n box-shadow: 0 20px 60px rgba(0,0,0,0.35) !important;\n overflow: hidden !important;\n z-index: 2147483646 !important;\n pointer-events: all !important;\n }\n\n /* Inner iframe — fill the container fully and ensure it receives clicks */\n [id^="cb-frame"] {\n width: 100% !important;\n height: 100% !important;\n border: none !important;\n display: block !important;\n z-index: 2147483646 !important;\n pointer-events: all !important;\n outline: none !important;\n box-shadow: none !important;\n }\n\n @keyframes ${cn} {\n to { transform: rotate(360deg); }\n }\n `,e.parentElement||document.head.appendChild(e),document.documentElement.classList.add(un),document.body.classList.add(un)}(),function(e){if(window.Chargebee)return Promise.resolve();const t=document.querySelector('script[src*="js.chargebee.com"]');return t?"1"===t.dataset.cbLoaded?Promise.resolve():new Promise((e,n)=>{t.addEventListener("load",()=>e()),t.addEventListener("error",()=>n(new Error("Chargebee.js failed to load")))}):new Promise((t,n)=>{const r=document.createElement("script");r.src="https://js.chargebee.com/v2/chargebee.js",r.setAttribute("data-cb-site",e),r.onload=()=>{r.dataset.cbLoaded="1",t()},r.onerror=()=>n(new Error("Chargebee.js failed to load")),document.head.appendChild(r)})}(i).then(()=>{if(m)return;let e;try{e=window.Chargebee.getInstance()??window.Chargebee.init({site:i})}catch{e=window.Chargebee.init({site:i})}e.openCheckout({hostedPage:()=>Promise.resolve({id:r.payment_id,url:s,type:"checkout_one_time",state:"created"}),success:e=>{dn(),pn(),g({status:"success",provider:"chargebee",paymentId:e,amount:p??void 0,currency:f??void 0})},close:()=>{dn(),pn(),g({status:"cancel",provider:"chargebee"})},error:e=>{dn(),pn(),g({status:"failure",provider:"chargebee",message:e?.message??"Payment failed"})}}),h=function(){let e=0,t=0,n=0,r=null,o=null;const a=Date.now()+5e3,i=()=>{if(m||c.current)return;const t=document.querySelector(ln);if(t instanceof HTMLElement){const e=t.getBoundingClientRect();if(e.width>0&&e.height>0){!function(){pn();const e=document.createElement("div");e.id=sn,e.setAttribute("aria-live","polite"),e.setAttribute("aria-busy","true"),e.style.cssText=`\n position: fixed;\n inset: ${nn} max(${rn}, calc((100vw - 1500px) / 2));\n z-index: 2147483646;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n gap: 14px;\n background: #f8f8f8;\n border-radius: 12px;\n color: #6b7280;\n font: 500 14px/1.4 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;\n pointer-events: none;\n `;const t=document.createElement("div");t.style.cssText=`\n width: 32px;\n height: 32px;\n border: 2.5px solid rgba(17, 24, 39, 0.08);\n border-top-color: #6366f1;\n border-radius: 50%;\n animation: ${cn} 0.8s linear infinite;\n `;const n=document.createElement("p");n.textContent="Loading payment…",n.style.cssText="margin: 0;",e.appendChild(t),e.appendChild(n),document.body.appendChild(e)}();const e=document.querySelector('[id^="cb-frame"]');return void(e instanceof HTMLIFrameElement&&(r=e,o=()=>{n=window.setTimeout(pn,400)},r.addEventListener("load",o)))}}Date.now()>=a||(e=window.requestAnimationFrame(i))};return t=window.setTimeout(i,100),()=>{window.clearTimeout(t),window.clearTimeout(n),e&&window.cancelAnimationFrame(e),r&&o&&r.removeEventListener("load",o),pn()}}(),y=function(e){let t=0,n=0;const r=Date.now()+5e3,o=()=>{if(m||c.current)return;const n=document.querySelector(ln);if(n instanceof HTMLElement){const t=n.getBoundingClientRect();if(t.width>0&&t.height>0)return void function(e){dn();const t=document.createElement("button");t.id=an,t.type="button",t.setAttribute("aria-label","Close payment"),t.textContent="×",t.style.cssText=`\n position: fixed;\n top: calc(${nn} + 12px);\n right: calc(max(${rn}, calc((100vw - 1500px) / 2)) + 12px);\n z-index: 2147483647;\n width: 32px;\n height: 32px;\n border: 0;\n border-radius: 9999px;\n background: rgba(17, 24, 39, 0.72);\n color: #ffffff;\n font: 600 16px/1 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;\n cursor: pointer;\n pointer-events: auto;\n display: flex;\n align-items: center;\n justify-content: center;\n box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);\n `,t.addEventListener("click",e),document.body.appendChild(t)}(e)}Date.now()>=r||(t=window.requestAnimationFrame(o))};return n=window.setTimeout(o,100),()=>{window.clearTimeout(n),t&&window.cancelAnimationFrame(t)}}(()=>{dn(),pn(),document.querySelectorAll(ln).forEach(e=>{e instanceof HTMLElement&&(e.style.display="none")}),g({status:"cancel",provider:"chargebee"});try{e.closeAll()}catch{}})}).catch(e=>{g({status:"failure",provider:"chargebee",message:e?.message??"Failed to load payment form"})}),()=>{m=!0,y?.(),h?.(),dn(),pn(),document.documentElement.classList.remove(un),document.body.classList.remove(un),document.getElementById(on)?.remove();try{window.Chargebee?.getInstance?.()?.closeAll?.()}catch{}})},[r,e,t,a,n,o]),null},hideShellSubmit:!0},mn=u(void 0),yn=({children:t,paymentProvider:n,paymentInit:r=null,conversationId:o=null})=>{const a=r?.provider||n||b,i=l(()=>function(e){switch(e){case"stripe":return Ue;case"moyasar":return tn;case"chargebee":return fn;default:throw new Error(`Unknown payment provider: "${e}". Supported providers: stripe, moyasar, chargebee`)}}(a),[a]),s=l(()=>({adapter:i,paymentProvider:a,paymentInit:r,conversationId:o}),[i,a,r,o]),c=i.ProviderWrapper;return e(mn.Provider,{value:s,children:c?e(c,{children:t}):t})},hn=()=>{const e=d(mn);if(!e)throw new Error("usePaymentAdapter must be used within a PaymentProvider");return e},gn=({provider:t,paymentInit:n=null,onResult:r,conversationId:o=null})=>e(yn,{paymentInit:n,conversationId:o,paymentProvider:w(),children:e(Oe,{onResult:e=>{r?.(e)},children:e(vn,{provider:t,paymentInit:n})})},n?.provider??"default"),vn=({provider:n,paymentInit:r})=>{const{themeStyles:o,theme:a}=m(),{adapter:s}=hn(),u=je().summary,[d,p]=i(!1),f=c(()=>p(!0),[]),h=l(()=>y(o,a),[o,a]),g="moyasar"===r?.provider?r.config:null,v="chargebee"===r?.provider?r.config:null,b=u?.amount??g?.amount??v?.amount??0,w=u?.currency??g?.currency??v?.currency??"usd",S=null!=u?.amount||null!=g?.amount||null!=v?.amount,E=((e,t)=>x(e,t)??"")(b,w),C=n??s.label,k=s.FormComponent;return t("div",{className:"w-full flex-1 min-h-0 overflow-y-auto [&::-webkit-scrollbar]:hidden [scrollbar-width:none] relative",style:{background:h.pageBg,color:h.text,fontFamily:h.fontFamily,colorScheme:h.colorScheme},children:[!d&&e(bn,{skin:h}),e("div",{className:"min-h-full flex items-center justify-center p-4",style:{visibility:d?"visible":"hidden"},children:t("div",{className:"w-full max-w-sm p-5",style:{background:h.cardBg,borderRadius:h.radius,boxShadow:h.cardShadow,color:h.text},children:[e("h1",{className:"text-base font-semibold text-center mb-3.5",style:{color:h.heading},children:"Payment Options"}),e("div",{className:"mb-3.5",children:e(k,{amount:b,currency:w,skin:h,onReady:f})}),!s.hideShellSubmit&&S&&e(wn,{label:`Pay ${E}`,background:o.statusDiscovery.solid,color:o.statusDiscovery.text,radius:h.radius}),!s.hideShellFooter&&t("p",{className:"text-xs text-center mt-2.5",style:{color:h.muted},children:["Powered by ",C]})]})})]})},bn=({skin:n})=>t("div",{className:"absolute inset-0 z-10 flex flex-col items-center justify-center gap-3",style:{background:n.pageBg,color:n.text},"aria-live":"polite","aria-busy":"true",children:[e(O,{className:"h-8 w-8 animate-spin",style:{color:n.accent}}),e("p",{className:"text-sm",style:{color:n.muted},children:"Loading payment…"})]}),wn=({label:t,background:n,color:r,radius:o})=>{const a=je().confirmHandle;return e("button",{type:"button",onClick:()=>a?.confirm(),disabled:!a||a.isConfirming,className:"w-full p-2.5 text-sm font-semibold border-0 cursor-pointer disabled:cursor-not-allowed disabled:opacity-70",style:{background:n,color:r,borderRadius:o},children:a?.isConfirming?"Processing…":t})};export{gn as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("react"),n=require("./index-AAKj44J6.cjs"),r=e=>{const t=(e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,n)=>n?n.toUpperCase():t.toLowerCase()))(e);return t.charAt(0).toUpperCase()+t.slice(1)},o=(...e)=>e.filter((e,t,n)=>Boolean(e)&&""!==e.trim()&&n.indexOf(e)===t).join(" ").trim(),a=e=>{for(const t in e)if(t.startsWith("aria-")||"role"===t||"title"===t)return!0};var i={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"};const s=t.forwardRef(({color:e="currentColor",size:n=24,strokeWidth:r=2,absoluteStrokeWidth:s,className:c="",children:l,iconNode:u,...d},p)=>t.createElement("svg",{ref:p,...i,width:n,height:n,stroke:e,strokeWidth:s?24*Number(r)/Number(n):r,className:o("lucide",c),...!l&&!a(d)&&{"aria-hidden":"true"},...d},[...u.map(([e,n])=>t.createElement(e,n)),...Array.isArray(l)?l:[l]])),c=((e,n)=>{const a=t.forwardRef(({className:a,...i},c)=>{return t.createElement(s,{ref:c,iconNode:n,className:o(`lucide-${l=r(e),l.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}`,`lucide-${e}`,a),...i});var l});return a.displayName=r(e),a})("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);function l(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var u,d,p,f,m,y,h,g,v,b,x,w,S,E,j,C,k={exports:{}},P={exports:{}},O={},_={};function A(){return p||(p=1,P.exports="production"===process.env.NODE_ENV?function(){if(u)return O;u=1;var e="function"==typeof Symbol&&Symbol.for,t=e?Symbol.for("react.element"):60103,n=e?Symbol.for("react.portal"):60106,r=e?Symbol.for("react.fragment"):60107,o=e?Symbol.for("react.strict_mode"):60108,a=e?Symbol.for("react.profiler"):60114,i=e?Symbol.for("react.provider"):60109,s=e?Symbol.for("react.context"):60110,c=e?Symbol.for("react.async_mode"):60111,l=e?Symbol.for("react.concurrent_mode"):60111,d=e?Symbol.for("react.forward_ref"):60112,p=e?Symbol.for("react.suspense"):60113,f=e?Symbol.for("react.suspense_list"):60120,m=e?Symbol.for("react.memo"):60115,y=e?Symbol.for("react.lazy"):60116,h=e?Symbol.for("react.block"):60121,g=e?Symbol.for("react.fundamental"):60117,v=e?Symbol.for("react.responder"):60118,b=e?Symbol.for("react.scope"):60119;function x(e){if("object"==typeof e&&null!==e){var u=e.$$typeof;switch(u){case t:switch(e=e.type){case c:case l:case r:case a:case o:case p:return e;default:switch(e=e&&e.$$typeof){case s:case d:case y:case m:case i:return e;default:return u}}case n:return u}}}function w(e){return x(e)===l}return O.AsyncMode=c,O.ConcurrentMode=l,O.ContextConsumer=s,O.ContextProvider=i,O.Element=t,O.ForwardRef=d,O.Fragment=r,O.Lazy=y,O.Memo=m,O.Portal=n,O.Profiler=a,O.StrictMode=o,O.Suspense=p,O.isAsyncMode=function(e){return w(e)||x(e)===c},O.isConcurrentMode=w,O.isContextConsumer=function(e){return x(e)===s},O.isContextProvider=function(e){return x(e)===i},O.isElement=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===t},O.isForwardRef=function(e){return x(e)===d},O.isFragment=function(e){return x(e)===r},O.isLazy=function(e){return x(e)===y},O.isMemo=function(e){return x(e)===m},O.isPortal=function(e){return x(e)===n},O.isProfiler=function(e){return x(e)===a},O.isStrictMode=function(e){return x(e)===o},O.isSuspense=function(e){return x(e)===p},O.isValidElementType=function(e){return"string"==typeof e||"function"==typeof e||e===r||e===l||e===a||e===o||e===p||e===f||"object"==typeof e&&null!==e&&(e.$$typeof===y||e.$$typeof===m||e.$$typeof===i||e.$$typeof===s||e.$$typeof===d||e.$$typeof===g||e.$$typeof===v||e.$$typeof===b||e.$$typeof===h)},O.typeOf=x,O}():(d||(d=1,"production"!==process.env.NODE_ENV&&function(){var e="function"==typeof Symbol&&Symbol.for,t=e?Symbol.for("react.element"):60103,n=e?Symbol.for("react.portal"):60106,r=e?Symbol.for("react.fragment"):60107,o=e?Symbol.for("react.strict_mode"):60108,a=e?Symbol.for("react.profiler"):60114,i=e?Symbol.for("react.provider"):60109,s=e?Symbol.for("react.context"):60110,c=e?Symbol.for("react.async_mode"):60111,l=e?Symbol.for("react.concurrent_mode"):60111,u=e?Symbol.for("react.forward_ref"):60112,d=e?Symbol.for("react.suspense"):60113,p=e?Symbol.for("react.suspense_list"):60120,f=e?Symbol.for("react.memo"):60115,m=e?Symbol.for("react.lazy"):60116,y=e?Symbol.for("react.block"):60121,h=e?Symbol.for("react.fundamental"):60117,g=e?Symbol.for("react.responder"):60118,v=e?Symbol.for("react.scope"):60119;function b(e){if("object"==typeof e&&null!==e){var p=e.$$typeof;switch(p){case t:var y=e.type;switch(y){case c:case l:case r:case a:case o:case d:return y;default:var h=y&&y.$$typeof;switch(h){case s:case u:case m:case f:case i:return h;default:return p}}case n:return p}}}var x=l,w=s,S=i,E=t,j=u,C=r,k=m,P=f,O=n,A=a,N=o,I=d,T=!1;function M(e){return b(e)===l}_.AsyncMode=c,_.ConcurrentMode=x,_.ContextConsumer=w,_.ContextProvider=S,_.Element=E,_.ForwardRef=j,_.Fragment=C,_.Lazy=k,_.Memo=P,_.Portal=O,_.Profiler=A,_.StrictMode=N,_.Suspense=I,_.isAsyncMode=function(e){return T||(T=!0,console.warn("The ReactIs.isAsyncMode() alias has been deprecated, and will be removed in React 17+. Update your code to use ReactIs.isConcurrentMode() instead. It has the exact same API.")),M(e)||b(e)===c},_.isConcurrentMode=M,_.isContextConsumer=function(e){return b(e)===s},_.isContextProvider=function(e){return b(e)===i},_.isElement=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===t},_.isForwardRef=function(e){return b(e)===u},_.isFragment=function(e){return b(e)===r},_.isLazy=function(e){return b(e)===m},_.isMemo=function(e){return b(e)===f},_.isPortal=function(e){return b(e)===n},_.isProfiler=function(e){return b(e)===a},_.isStrictMode=function(e){return b(e)===o},_.isSuspense=function(e){return b(e)===d},_.isValidElementType=function(e){return"string"==typeof e||"function"==typeof e||e===r||e===l||e===a||e===o||e===d||e===p||"object"==typeof e&&null!==e&&(e.$$typeof===m||e.$$typeof===f||e.$$typeof===i||e.$$typeof===s||e.$$typeof===u||e.$$typeof===h||e.$$typeof===g||e.$$typeof===v||e.$$typeof===y)},_.typeOf=b}()),_)),P.exports}function N(){return h?y:(h=1,y="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}function I(){return v?g:(v=1,g=Function.call.bind(Object.prototype.hasOwnProperty))}function T(){if(x)return b;x=1;var e=function(){};if("production"!==process.env.NODE_ENV){var t=N(),n={},r=I();e=function(e){var t="Warning: "+e;"undefined"!=typeof console&&console.error(t);try{throw new Error(t)}catch(e){}}}function o(o,a,i,s,c){if("production"!==process.env.NODE_ENV)for(var l in o)if(r(o,l)){var u;try{if("function"!=typeof o[l]){var d=Error((s||"React class")+": "+i+" type `"+l+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof o[l]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw d.name="Invariant Violation",d}u=o[l](a,l,s,i,null,t)}catch(e){u=e}if(!u||u instanceof Error||e((s||"React class")+": type specification of "+i+" `"+l+"` is invalid; the type checker function must return `null` or an `Error` but returned a "+typeof u+". You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument)."),u instanceof Error&&!(u.message in n)){n[u.message]=!0;var p=c?c():"";e("Failed "+i+" type: "+u.message+(null!=p?p:""))}}}return o.resetWarningCache=function(){"production"!==process.env.NODE_ENV&&(n={})},b=o}function M(){if(S)return w;S=1;var e=A(),t=function(){if(m)return f;m=1;var e=Object.getOwnPropertySymbols,t=Object.prototype.hasOwnProperty,n=Object.prototype.propertyIsEnumerable;return f=function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},n=0;n<10;n++)t["_"+String.fromCharCode(n)]=n;if("0123456789"!==Object.getOwnPropertyNames(t).map(function(e){return t[e]}).join(""))return!1;var r={};return"abcdefghijklmnopqrst".split("").forEach(function(e){r[e]=e}),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},r)).join("")}catch(e){return!1}}()?Object.assign:function(r,o){for(var a,i,s=function(e){if(null==e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}(r),c=1;c<arguments.length;c++){for(var l in a=Object(arguments[c]))t.call(a,l)&&(s[l]=a[l]);if(e){i=e(a);for(var u=0;u<i.length;u++)n.call(a,i[u])&&(s[i[u]]=a[i[u]])}}return s},f}(),n=N(),r=I(),o=T(),a=function(){};function i(){return null}return"production"!==process.env.NODE_ENV&&(a=function(e){var t="Warning: "+e;"undefined"!=typeof console&&console.error(t);try{throw new Error(t)}catch(e){}}),w=function(s,c){var l="function"==typeof Symbol&&Symbol.iterator,u="<<anonymous>>",d={array:y("array"),bigint:y("bigint"),bool:y("boolean"),func:y("function"),number:y("number"),object:y("object"),string:y("string"),symbol:y("symbol"),any:m(i),arrayOf:function(e){return m(function(t,r,o,a,i){if("function"!=typeof e)return new f("Property `"+i+"` of component `"+o+"` has invalid PropType notation inside arrayOf.");var s=t[r];if(!Array.isArray(s))return new f("Invalid "+a+" `"+i+"` of type `"+v(s)+"` supplied to `"+o+"`, expected an array.");for(var c=0;c<s.length;c++){var l=e(s,c,o,a,i+"["+c+"]",n);if(l instanceof Error)return l}return null})},element:m(function(e,t,n,r,o){var a=e[t];return s(a)?null:new f("Invalid "+r+" `"+o+"` of type `"+v(a)+"` supplied to `"+n+"`, expected a single ReactElement.")}),elementType:m(function(t,n,r,o,a){var i=t[n];return e.isValidElementType(i)?null:new f("Invalid "+o+" `"+a+"` of type `"+v(i)+"` supplied to `"+r+"`, expected a single ReactElement type.")}),instanceOf:function(e){return m(function(t,n,r,o,a){return t[n]instanceof e?null:new f("Invalid "+o+" `"+a+"` of type `"+((i=t[n]).constructor&&i.constructor.name?i.constructor.name:u)+"` supplied to `"+r+"`, expected instance of `"+(e.name||u)+"`.");var i})},node:m(function(e,t,n,r,o){return g(e[t])?null:new f("Invalid "+r+" `"+o+"` supplied to `"+n+"`, expected a ReactNode.")}),objectOf:function(e){return m(function(t,o,a,i,s){if("function"!=typeof e)return new f("Property `"+s+"` of component `"+a+"` has invalid PropType notation inside objectOf.");var c=t[o],l=v(c);if("object"!==l)return new f("Invalid "+i+" `"+s+"` of type `"+l+"` supplied to `"+a+"`, expected an object.");for(var u in c)if(r(c,u)){var d=e(c,u,a,i,s+"."+u,n);if(d instanceof Error)return d}return null})},oneOf:function(e){return Array.isArray(e)?m(function(t,n,r,o,a){for(var i=t[n],s=0;s<e.length;s++)if(p(i,e[s]))return null;var c=JSON.stringify(e,function(e,t){return"symbol"===b(t)?String(t):t});return new f("Invalid "+o+" `"+a+"` of value `"+String(i)+"` supplied to `"+r+"`, expected one of "+c+".")}):("production"!==process.env.NODE_ENV&&a(arguments.length>1?"Invalid arguments supplied to oneOf, expected an array, got "+arguments.length+" arguments. A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z]).":"Invalid argument supplied to oneOf, expected an array."),i)},oneOfType:function(e){if(!Array.isArray(e))return"production"!==process.env.NODE_ENV&&a("Invalid argument supplied to oneOfType, expected an instance of array."),i;for(var t=0;t<e.length;t++){var o=e[t];if("function"!=typeof o)return a("Invalid argument supplied to oneOfType. Expected an array of check functions, but received "+x(o)+" at index "+t+"."),i}return m(function(t,o,a,i,s){for(var c=[],l=0;l<e.length;l++){var u=(0,e[l])(t,o,a,i,s,n);if(null==u)return null;u.data&&r(u.data,"expectedType")&&c.push(u.data.expectedType)}return new f("Invalid "+i+" `"+s+"` supplied to `"+a+"`"+(c.length>0?", expected one of type ["+c.join(", ")+"]":"")+".")})},shape:function(e){return m(function(t,r,o,a,i){var s=t[r],c=v(s);if("object"!==c)return new f("Invalid "+a+" `"+i+"` of type `"+c+"` supplied to `"+o+"`, expected `object`.");for(var l in e){var u=e[l];if("function"!=typeof u)return h(o,a,i,l,b(u));var d=u(s,l,o,a,i+"."+l,n);if(d)return d}return null})},exact:function(e){return m(function(o,a,i,s,c){var l=o[a],u=v(l);if("object"!==u)return new f("Invalid "+s+" `"+c+"` of type `"+u+"` supplied to `"+i+"`, expected `object`.");var d=t({},o[a],e);for(var p in d){var m=e[p];if(r(e,p)&&"function"!=typeof m)return h(i,s,c,p,b(m));if(!m)return new f("Invalid "+s+" `"+c+"` key `"+p+"` supplied to `"+i+"`.\nBad object: "+JSON.stringify(o[a],null," ")+"\nValid keys: "+JSON.stringify(Object.keys(e),null," "));var y=m(l,p,i,s,c+"."+p,n);if(y)return y}return null})}};function p(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}function f(e,t){this.message=e,this.data=t&&"object"==typeof t?t:{},this.stack=""}function m(e){if("production"!==process.env.NODE_ENV)var t={},r=0;function o(o,i,s,l,d,p,m){if(l=l||u,p=p||s,m!==n){if(c){var y=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use `PropTypes.checkPropTypes()` to call them. Read more at http://fb.me/use-check-prop-types");throw y.name="Invariant Violation",y}if("production"!==process.env.NODE_ENV&&"undefined"!=typeof console){var h=l+":"+s;!t[h]&&r<3&&(a("You are manually calling a React.PropTypes validation function for the `"+p+"` prop on `"+l+"`. This is deprecated and will throw in the standalone `prop-types` package. You may be seeing this warning due to a third-party PropTypes library. See https://fb.me/react-warning-dont-call-proptypes for details."),t[h]=!0,r++)}}return null==i[s]?o?new f(null===i[s]?"The "+d+" `"+p+"` is marked as required in `"+l+"`, but its value is `null`.":"The "+d+" `"+p+"` is marked as required in `"+l+"`, but its value is `undefined`."):null:e(i,s,l,d,p)}var i=o.bind(null,!1);return i.isRequired=o.bind(null,!0),i}function y(e){return m(function(t,n,r,o,a,i){var s=t[n];return v(s)!==e?new f("Invalid "+o+" `"+a+"` of type `"+b(s)+"` supplied to `"+r+"`, expected `"+e+"`.",{expectedType:e}):null})}function h(e,t,n,r,o){return new f((e||"React class")+": "+t+" type `"+n+"."+r+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+o+"`.")}function g(e){switch(typeof e){case"number":case"string":case"undefined":return!0;case"boolean":return!e;case"object":if(Array.isArray(e))return e.every(g);if(null===e||s(e))return!0;var t=function(e){var t=e&&(l&&e[l]||e["@@iterator"]);if("function"==typeof t)return t}(e);if(!t)return!1;var n,r=t.call(e);if(t!==e.entries){for(;!(n=r.next()).done;)if(!g(n.value))return!1}else for(;!(n=r.next()).done;){var o=n.value;if(o&&!g(o[1]))return!1}return!0;default:return!1}}function v(e){var t=typeof e;return Array.isArray(e)?"array":e instanceof RegExp?"object":function(e,t){return"symbol"===e||!!t&&("Symbol"===t["@@toStringTag"]||"function"==typeof Symbol&&t instanceof Symbol)}(t,e)?"symbol":t}function b(e){if(null==e)return""+e;var t=v(e);if("object"===t){if(e instanceof Date)return"date";if(e instanceof RegExp)return"regexp"}return t}function x(e){var t=b(e);switch(t){case"array":case"object":return"an "+t;case"boolean":case"date":case"regexp":return"a "+t;default:return t}}return f.prototype=Error.prototype,d.checkPropTypes=o,d.resetWarningCache=o.resetWarningCache,d.PropTypes=d,d},w}function R(){if(j)return E;j=1;var e=N();function t(){}function n(){}return n.resetWarningCache=t,E=function(){function r(t,n,r,o,a,i){if(i!==e){var s=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw s.name="Invariant Violation",s}}function o(){return r}r.isRequired=r;var a={array:r,bigint:r,bool:r,func:r,number:r,object:r,string:r,symbol:r,any:r,arrayOf:o,element:r,elementType:r,instanceOf:o,node:r,objectOf:o,oneOf:o,oneOfType:o,shape:o,exact:o,checkPropTypes:n,resetWarningCache:t};return a.PropTypes=a,a}}function F(){if(C)return k.exports;if(C=1,"production"!==process.env.NODE_ENV){var e=A();k.exports=M()(e.isElement,!0)}else k.exports=R()();return k.exports}const $=l(F());function V(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function D(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?V(Object(n),!0).forEach(function(t){L(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):V(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function B(e){return(B="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function L(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function z(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=e&&("undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"]);if(null!=n){var r,o,a=[],i=!0,s=!1;try{for(n=n.call(e);!(i=(r=n.next()).done)&&(a.push(r.value),!t||a.length!==t);i=!0);}catch(e){s=!0,o=e}finally{try{i||null==n.return||n.return()}finally{if(s)throw o}}return a}}(e,t)||function(e,t){if(e){if("string"==typeof e)return U(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?U(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function U(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var q=function(e,n,r){var o=!!r,a=t.useRef(r);t.useEffect(function(){a.current=r},[r]),t.useEffect(function(){if(!o||!e)return function(){};var t=function(){a.current&&a.current.apply(a,arguments)};return e.on(n,t),function(){e.off(n,t)}},[o,n,e,a])},W=function(e){var n=t.useRef(e);return t.useEffect(function(){n.current=e},[e]),n.current},Y=function(e){return null!==e&&"object"===B(e)},H="[object Object]",J=function e(t,n){if(!Y(t)||!Y(n))return t===n;var r=Array.isArray(t);if(r!==Array.isArray(n))return!1;var o=Object.prototype.toString.call(t)===H;if(o!==(Object.prototype.toString.call(n)===H))return!1;if(!o&&!r)return t===n;var a=Object.keys(t),i=Object.keys(n);if(a.length!==i.length)return!1;for(var s={},c=0;c<a.length;c+=1)s[a[c]]=!0;for(var l=0;l<i.length;l+=1)s[i[l]]=!0;var u=Object.keys(s);if(u.length!==a.length)return!1;var d=t,p=n;return u.every(function(t){return e(d[t],p[t])})},Z=function(e,t,n){return Y(e)?Object.keys(e).reduce(function(r,o){var a=!Y(t)||!J(e[o],t[o]);return n.includes(o)?(a&&console.warn("Unsupported prop change: options.".concat(o," is not a mutable property.")),r):a?D(D({},r||{}),{},L({},o,e[o])):r},null):null},K="Invalid prop `stripe` supplied to `Elements`. We recommend using the `loadStripe` utility from `@stripe/stripe-js`. See https://stripe.com/docs/stripe-js/react#elements-props-stripe for details.",X=function(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:K;if(null===e||Y(t=e)&&"function"==typeof t.elements&&"function"==typeof t.createToken&&"function"==typeof t.createPaymentMethod&&"function"==typeof t.confirmCardPayment)return e;throw new Error(n)},G=t.createContext(null);G.displayName="ElementsContext";var Q=function(e,t){if(!e)throw new Error("Could not find Elements context; You need to wrap the part of your app that ".concat(t," in an <Elements> provider."));return e},ee=function(e){var n=e.stripe,r=e.options,o=e.children,a=t.useMemo(function(){return function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:K;if(function(e){return Y(e)&&"function"==typeof e.then}(e))return{tag:"async",stripePromise:Promise.resolve(e).then(function(e){return X(e,t)})};var n=X(e,t);return null===n?{tag:"empty"}:{tag:"sync",stripe:n}}(n)},[n]),i=z(t.useState(function(){return{stripe:"sync"===a.tag?a.stripe:null,elements:"sync"===a.tag?a.stripe.elements(r):null}}),2),s=i[0],c=i[1];t.useEffect(function(){var e=!0,t=function(e){c(function(t){return t.stripe?t:{stripe:e,elements:e.elements(r)}})};return"async"!==a.tag||s.stripe?"sync"!==a.tag||s.stripe||t(a.stripe):a.stripePromise.then(function(n){n&&e&&t(n)}),function(){e=!1}},[a,s,r]);var l=W(n);t.useEffect(function(){null!==l&&l!==n&&console.warn("Unsupported prop change on Elements: You cannot change the `stripe` prop after setting it.")},[l,n]);var u=W(r);return t.useEffect(function(){if(s.elements){var e=Z(r,u,["clientSecret","fonts"]);e&&s.elements.update(e)}},[r,u,s.elements]),t.useEffect(function(){var e;(e=s.stripe)&&e._registerWrapper&&e.registerAppInfo&&(e._registerWrapper({name:"react-stripe-js",version:"3.10.0"}),e.registerAppInfo({name:"react-stripe-js",version:"3.10.0",url:"https://stripe.com/docs/stripe-js/react"}))},[s.stripe]),t.createElement(G.Provider,{value:s},o)};ee.propTypes={stripe:$.any,options:$.object};var te=t.createContext(null);te.displayName="CheckoutSdkContext",t.createContext(null).displayName="CheckoutContext",$.shape({fetchClientSecret:$.func.isRequired,elementsOptions:$.object});var ne=function(e){var n=t.useContext(te),r=t.useContext(G);if(n&&r)throw new Error("You cannot wrap the part of your app that ".concat(e," in both <CheckoutProvider> and <Elements> providers."));return n?function(e,t){if(!e)throw new Error("Could not find CheckoutProvider context; You need to wrap the part of your app that ".concat(t," in an <CheckoutProvider> provider."));return e}(n,e):Q(r,e)},re=["mode"],oe=function(e,n){var r,o="".concat((r=e).charAt(0).toUpperCase()+r.slice(1),"Element"),a=n?function(e){return ne("mounts <".concat(o,">")),t.createElement("div",{id:e.id,className:e.className})}:function(n){var r,a=n.id,i=n.className,s=n.options,c=void 0===s?{}:s,l=n.onBlur,u=n.onFocus,d=n.onReady,p=n.onChange,f=n.onEscape,m=n.onClick,y=n.onLoadError,h=n.onLoaderStart,g=n.onNetworksChange,v=n.onConfirm,b=n.onCancel,x=n.onShippingAddressChange,w=n.onShippingRateChange,S=n.onSavedPaymentMethodRemove,E=n.onSavedPaymentMethodUpdate,j=ne("mounts <".concat(o,">")),C="elements"in j?j.elements:null,k="checkoutSdk"in j?j.checkoutSdk:null,P=z(t.useState(null),2),O=P[0],_=P[1],A=t.useRef(null),N=t.useRef(null);q(O,"blur",l),q(O,"focus",u),q(O,"escape",f),q(O,"click",m),q(O,"loaderror",y),q(O,"loaderstart",h),q(O,"networkschange",g),q(O,"confirm",v),q(O,"cancel",b),q(O,"shippingaddresschange",x),q(O,"shippingratechange",w),q(O,"savedpaymentmethodremove",S),q(O,"savedpaymentmethodupdate",E),q(O,"change",p),d&&(r="expressCheckout"===e?d:function(){d(O)}),q(O,"ready",r),t.useLayoutEffect(function(){if(null===A.current&&null!==N.current&&(C||k)){var t=null;if(k)switch(e){case"payment":t=k.createPaymentElement(c);break;case"address":if(!("mode"in c))throw new Error("You must supply options.mode. mode must be 'billing' or 'shipping'.");var n=c.mode,r=function(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)t.indexOf(n=a[r])>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)t.indexOf(n=a[r])>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}(c,re);if("shipping"===n)t=k.createShippingAddressElement(r);else{if("billing"!==n)throw new Error("Invalid options.mode. mode must be 'billing' or 'shipping'.");t=k.createBillingAddressElement(r)}break;case"expressCheckout":t=k.createExpressCheckoutElement(c);break;case"currencySelector":t=k.createCurrencySelectorElement();break;case"taxId":t=k.createTaxIdElement(c);break;default:throw new Error("Invalid Element type ".concat(o,". You must use either the <PaymentElement />, <AddressElement options={{mode: 'shipping'}} />, <AddressElement options={{mode: 'billing'}} />, or <ExpressCheckoutElement />."))}else C&&(t=C.create(e,c));A.current=t,_(t),t&&t.mount(N.current)}},[C,k,c]);var I=W(c);return t.useEffect(function(){if(A.current){var e=Z(c,I,["paymentRequest"]);e&&"update"in A.current&&A.current.update(e)}},[c,I]),t.useLayoutEffect(function(){return function(){if(A.current&&"function"==typeof A.current.destroy)try{A.current.destroy(),A.current=null}catch(e){}}},[]),t.createElement("div",{id:a,className:i,ref:N})};return a.propTypes={id:$.string,className:$.string,onChange:$.func,onBlur:$.func,onFocus:$.func,onReady:$.func,onEscape:$.func,onClick:$.func,onLoadError:$.func,onLoaderStart:$.func,onNetworksChange:$.func,onConfirm:$.func,onCancel:$.func,onShippingAddressChange:$.func,onShippingRateChange:$.func,onSavedPaymentMethodRemove:$.func,onSavedPaymentMethodUpdate:$.func,options:$.object},a.displayName=o,a.__elementType=e,a},ae="undefined"==typeof window;t.createContext(null).displayName="EmbeddedCheckoutProviderContext",oe("auBankAccount",ae),oe("card",ae),oe("cardNumber",ae),oe("cardExpiry",ae),oe("cardCvc",ae),oe("fpxBank",ae),oe("iban",ae),oe("idealBank",ae),oe("p24Bank",ae),oe("epsBank",ae);var ie=oe("payment",ae);oe("expressCheckout",ae),oe("currencySelector",ae),oe("paymentRequestButton",ae),oe("linkAuthentication",ae),oe("address",ae),oe("shippingAddress",ae),oe("paymentMethodMessaging",ae),oe("affirmMessage",ae),oe("afterpayClearpayMessage",ae),oe("taxId",ae);const se=t.createContext(null),ce=({onResult:n,children:r})=>{const[o,a]=t.useState(null),[i,s]=t.useState(null),c=t.useRef(n);c.current=n;const l=t.useCallback(e=>{c.current(e)},[]),u=t.useCallback(e=>{a(e)},[]),d=t.useCallback(e=>{s(e)},[]),p=t.useMemo(()=>({emitResult:l,registerConfirm:u,confirmHandle:o,reportSummary:d,summary:i}),[l,u,o,d,i]);return e.jsx(se.Provider,{value:p,children:r})},le=()=>{const e=t.useContext(se);if(!e)throw new Error("Payment result channel hooks must be used inside PaymentResultChannelProvider");return e},ue=()=>le().emitResult,de=()=>le().registerConfirm,pe=()=>le().reportSummary;var fe,me="https://js.stripe.com/v3",ye=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/,he=function(e){var t=document.createElement("script");t.src="".concat(me).concat("");var n=document.head||document.body;if(!n)throw new Error("Expected document.body not to be null. Stripe.js requires a <body> element.");return n.appendChild(t),t},ge=null,ve=null,be=null,xe=!1,we=function(){return fe||(fe=(null!==ge?ge:(ge=new Promise(function(e,t){if("undefined"!=typeof window&&"undefined"!=typeof document)if(window.Stripe)e(window.Stripe);else try{var n=function(){for(var e=document.querySelectorAll('script[src^="'.concat(me,'"]')),t=0;t<e.length;t++){var n=e[t];if(ye.test(n.src))return n}return null}();if(n){if(n&&null!==be&&null!==ve){var r;n.removeEventListener("load",be),n.removeEventListener("error",ve),null===(r=n.parentNode)||void 0===r||r.removeChild(n),n=he()}}else n=he();be=function(e,t){return function(){window.Stripe?e(window.Stripe):t(new Error("Stripe.js not available"))}}(e,t),ve=function(e){return function(){e(new Error("Failed to load Stripe.js"))}}(t),n.addEventListener("load",be),n.addEventListener("error",ve)}catch(e){return void t(e)}else e(null)})).catch(function(e){return ge=null,Promise.reject(e)})).catch(function(e){return fe=null,Promise.reject(e)}))};Promise.resolve().then(function(){return we()}).catch(function(e){xe||console.warn(e)});const Se=t.createContext(null),Ee=({onReady:n})=>{const r=ne("calls useStripe()").stripe,o=(p=t.useContext(G),Q(p,"calls useElements()")).elements,{paymentInit:a}=Kt(),i=ue(),s=de(),c=pe(),[l,u]=t.useState(!1),d="stripe"===a?.provider?a.config.client_secret:null;var p;t.useEffect(()=>{if(!r||!d)return;let e=!1;return r.retrievePaymentIntent(d).then(t=>{if(e)return;const n=t.paymentIntent;n&&"number"==typeof n.amount&&n.currency&&c({amount:n.amount,currency:n.currency})}),()=>{e=!0}},[r,d,c]);const f=t.useCallback(async()=>{if(!r||!o||!d)return;u(!0);const{error:e}=await o.submit();if(e)return void u(!1);const{error:t,paymentIntent:n}=await r.confirmPayment({elements:o,clientSecret:d,confirmParams:{return_url:window.location.href},redirect:"if_required"});u(!1),t||!n||"succeeded"!==n.status&&"requires_capture"!==n.status||i({status:"success",provider:"stripe",paymentId:n.id,amount:n.amount,currency:n.currency})},[r,o,d,i]);return t.useEffect(()=>(s({confirm:f,isConfirming:l}),()=>s(null)),[f,l,s]),e.jsx(ie,{options:{layout:"tabs",wallets:{applePay:"auto",googlePay:"auto"}},onReady:n})},je={type:"stripe",label:"Stripe",ProviderWrapper:({children:n})=>{const{paymentInit:r}=Kt(),[o,a]=t.useState(null),i="stripe"===r?.provider?r.config.publishable_key:null;t.useEffect(()=>{i&&i.startsWith("pk_")&&a(function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];xe=!0;var r=Date.now();return we().then(function(e){return function(e,t,n){if(null===e)return null;var r=e.apply(void 0,t);return function(e,t){e&&e._registerWrapper&&e._registerWrapper({name:"stripe-js",version:"4.6.0",startTime:t})}(r,n),r}(e,t,r)})}(i))},[i]);const s=t.useMemo(()=>({stripePromise:o}),[o]);return e.jsx(Se.Provider,{value:s,children:n})},FormComponent:({onReady:r})=>{const{themeStyles:o,theme:a}=n.dt(),{stripePromise:i}=(()=>{const e=t.useContext(Se);if(!e)throw new Error("Stripe adapter components must be used inside StripeProviderWrapper");return e})(),{paymentInit:s}=Kt(),c=t.useMemo(()=>n.mo(o,a),[o,a]),l=t.useMemo(()=>function(e,t,n){return{theme:"dark"===t?"night":"stripe",variables:{colorPrimary:e.statusDiscovery.solid,colorBackground:n.cardBg,colorText:n.text,colorDanger:"#df1b41",fontFamily:n.fontFamily,borderRadius:`${n.radius}px`,spacingUnit:"3px",fontSizeBase:"16px"}}}(o,a,c),[o,a,c]),u="stripe"===s?.provider?s.config.client_secret:null,d=t.useMemo(()=>u?{clientSecret:u,appearance:l}:null,[u,l]);return i&&d?e.jsx(ee,{stripe:i,options:d,children:e.jsx(Ee,{onReady:r})},u):null}};function Ce(e){const t={};if(e.config.metadata)for(const[n,r]of Object.entries(e.config.metadata))null!=r&&(t[n]=String(r));if(e.config.customer){const{name:n,email:r,phone:o,reference_id:a}=e.config.customer;n&&(t.customer_name=n),r&&(t.customer_email=r),o&&(t.customer_phone=o),a&&(t.customer_reference_id=a)}return t}class ke extends Error{constructor(e,t,n){super(e),this.status=t,this.body=n,this.name="MoyasarApiError"}}async function Pe(e){const t=await Oe("https://api.moyasar.com/v1/payments",e);if(!t.ok)throw new ke(_e(t.body)??`Payment creation failed (${t.status})`,t.status,t.body);const n=t.body;if(!n||"string"!=typeof n.id||"string"!=typeof n.status)throw new ke("Payment creation returned no id/status",t.status,n);return n}async function Oe(e,t){const n=new AbortController,r=setTimeout(()=>n.abort(new DOMException("Request timed out","TimeoutError")),3e4);let o;try{o=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t),signal:n.signal})}catch(e){const t=e instanceof DOMException&&"TimeoutError"===e.name?"Payment request timed out — please try again.":e instanceof Error?e.message:"Network request failed";throw new ke(t)}finally{clearTimeout(r)}let a=null;try{a=await o.json()}catch{a=null}return{ok:o.ok,status:o.status,body:a}}function _e(e){if(!e||"object"!=typeof e)return null;if("string"==typeof e.message&&e.message.length>0)return e.message;if(e.errors&&"object"==typeof e.errors){const t=e.errors;for(const[e,n]of Object.entries(t)){if(Array.isArray(n)&&"string"==typeof n[0])return`${Ae(e)}: ${n[0]}`;if("string"==typeof n)return`${Ae(e)}: ${n}`}}return null}function Ae(e){return e.replace(/_/g," ")}const Ne=({url:r,onResult:o,skin:a})=>{const i=t.useRef(o);i.current=o;const s=t.useRef(!1),[c,l]=t.useState(!1),u=t.useRef(!1),d=t.useCallback(e=>{s.current||(s.current=!0,i.current({status:"failure",provider:"moyasar",message:e}))},[]);return t.useEffect(()=>{const e=window.location.origin,t=t=>{if(t.origin!==e)return;if(s.current)return;if(!(r=t.data)||"object"!=typeof r||"moyasar-iframe-callback"!==r.type||"string"!=typeof r.search)return;var r;const o=n.ho(t.data.search);o&&(s.current=!0,i.current(o.result))};return window.addEventListener("message",t),()=>window.removeEventListener("message",t)},[]),t.useEffect(()=>{const e=setTimeout(()=>{u.current||d("3D Secure challenge failed to load")},6e4);return()=>clearTimeout(e)},[d]),e.jsxs("div",{className:"absolute inset-0 z-[105]",style:{background:a.cardBg},role:"dialog","aria-label":"3D Secure authentication",children:[!c&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center text-sm",style:{color:a.muted,fontFamily:a.fontFamily},children:"Loading…"}),e.jsx("iframe",{src:r,title:"3D Secure",className:"w-full h-full",style:{border:0,background:"white"},onLoad:()=>{u.current=!0,l(!0)},onError:()=>{d("3D Secure challenge failed to load")},allow:"payment *",sandbox:"allow-scripts allow-forms allow-same-origin allow-popups allow-top-navigation-by-user-activation",referrerPolicy:"no-referrer"})]})},Ie=["mada","visa","masterCard"],Te="data-aiatcore-apple-pay",Me=({skin:r})=>{const{paymentInit:o}=Kt(),a=o&&"moyasar"===o.provider?o:null,i=ue(),[s,c]=t.useState(null),l=t.useRef(i);l.current=i,t.useEffect(()=>{!function(){if("undefined"==typeof document)return;if(document.querySelector(`style[${Te}]`))return;const e=document.createElement("style");e.setAttribute(Te,"true"),e.textContent="\n .aiatcore-apple-pay-button {\n -webkit-appearance: -apple-pay-button;\n -apple-pay-button-type: pay;\n -apple-pay-button-style: black;\n width: 100%;\n cursor: pointer;\n border: none;\n padding: 0;\n margin: 0;\n }\n ",document.head.appendChild(e)}()},[]);const u=t.useCallback(()=>{if(!a)return;const e=window.ApplePaySession;if(!e)return void n.De("Apple Pay is not available on this device.");const t=a.config.apple_pay?.label??a.config.description??"Payment",r=a.config.apple_pay?.country??"SA",o=a.config.currency.toUpperCase(),s=(a.config.amount/100).toFixed(2),l={countryCode:r,currencyCode:o,supportedNetworks:Ie,merchantCapabilities:["supports3DS","supportsDebit","supportsCredit"],total:{label:t,amount:s}};let u;try{u=new e(5,l)}catch(e){return void n.De(e instanceof Error?e.message:"Failed to start Apple Pay")}u.onvalidatemerchant=async e=>{try{const n=await async function(e){const t={validation_url:e.validationUrl,display_name:e.displayName,domain_name:e.domainName??window.location.hostname,publishable_api_key:e.publishableApiKey},n=new AbortController,r=setTimeout(()=>n.abort(new DOMException("Request timed out","TimeoutError")),3e4);let o;try{o=await fetch("https://api.moyasar.com/v1/applepay/initiate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t),signal:n.signal})}catch(e){const t=e instanceof DOMException&&"TimeoutError"===e.name?"Apple Pay merchant validation timed out — please try again.":e instanceof Error?e.message:"Network request failed";throw new ke(t)}finally{clearTimeout(r)}let a=null;try{a=await o.json()}catch{a=null}if(!o.ok)throw new ke(function(e){return e&&"object"==typeof e&&"string"==typeof e.message&&e.message.length>0?e.message:null}(a)??`Apple Pay merchant validation failed (${o.status})`,o.status,a);return a}({validationUrl:e.validationURL,displayName:t,publishableApiKey:a.config.publishable_key});u.completeMerchantValidation(n)}catch(e){const t=e instanceof Error?e.message:"Merchant validation failed";u.abort(),i({status:"failure",provider:"moyasar",message:t,paymentId:a.config.given_id})}},u.onpaymentauthorized=async t=>{try{const r=Ce(a),s=await Pe({publishable_api_key:a.config.publishable_key,given_id:a.config.given_id,amount:a.config.amount,currency:o,description:a.config.description,callback_url:n.po(a.config.given_id),source:{type:"applepay",token:t.payment.token},...Object.keys(r).length>0?{metadata:r}:{}}),l=s.source?.transaction_url??s.transaction_url;if(l)return u.completePayment({status:e.STATUS_SUCCESS}),void c(l);const d=s.status;if("paid"===d||"authorized"===d||"captured"===d)u.completePayment({status:e.STATUS_SUCCESS}),i({status:"success",provider:"moyasar",paymentId:s.id,amount:s.amount,currency:s.currency});else if("failed"===d){const t=s.source?.message??"Payment failed";u.completePayment({status:e.STATUS_FAILURE}),i({status:"failure",provider:"moyasar",code:"failed",message:t,paymentId:s.id})}else{const t=`Unexpected payment status: ${d}`;u.completePayment({status:e.STATUS_FAILURE}),i({status:"failure",provider:"moyasar",code:d,message:t,paymentId:s.id})}}catch(t){const n=t instanceof ke||t instanceof Error?t.message:"Payment failed";u.completePayment({status:e.STATUS_FAILURE}),i({status:"failure",provider:"moyasar",message:n,paymentId:a.config.given_id})}},u.oncancel=()=>{};try{u.begin()}catch(e){n.De(e instanceof Error?e.message:"Failed to start Apple Pay")}},[a,i]);return a?e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:u,className:"aiatcore-apple-pay-button",style:{borderRadius:r.radius,height:44},"aria-label":"Pay with Apple Pay"}),s&&e.jsx(Ne,{url:s,skin:r,onResult:e=>{c(null),l.current(e)}})]}):null};var Re,Fe,$e,Ve={},De={};function Be(){return $e||($e=1,Object.defineProperty(De,"__esModule",{value:!0}),De.clone=function(e){return e?JSON.parse(JSON.stringify(e)):null}),De}var Le,ze,Ue,qe,We,Ye,He={},Je={},Ze={};function Ke(){if(Ye)return We;Ye=1;var e=We&&We.__assign||function(){return e=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},e.apply(this,arguments)},t=Fe?Re:(Fe=1,Re={visa:{niceType:"Visa",type:"visa",patterns:[4],gaps:[4,8,12],lengths:[16,18,19],code:{name:"CVV",size:3}},mastercard:{niceType:"Mastercard",type:"mastercard",patterns:[[51,55],[2221,2229],[223,229],[23,26],[270,271],2720],gaps:[4,8,12],lengths:[16],code:{name:"CVC",size:3}},"american-express":{niceType:"American Express",type:"american-express",patterns:[34,37],gaps:[4,10],lengths:[15],code:{name:"CID",size:4}},"diners-club":{niceType:"Diners Club",type:"diners-club",patterns:[[300,305],36,38,39],gaps:[4,10],lengths:[14,16,19],code:{name:"CVV",size:3}},discover:{niceType:"Discover",type:"discover",patterns:[6011,[644,649],65],gaps:[4,8,12],lengths:[16,19],code:{name:"CID",size:3}},jcb:{niceType:"JCB",type:"jcb",patterns:[2131,1800,[3528,3589]],gaps:[4,8,12],lengths:[16,17,18,19],code:{name:"CVV",size:3}},unionpay:{niceType:"UnionPay",type:"unionpay",patterns:[620,[62100,62182],[62184,62187],[62185,62197],[62200,62205],[622010,622999],622018,[62207,62209],[623,626],6270,6272,6276,[627700,627779],[627781,627799],[6282,6289],6291,6292,810,[8110,8131],[8132,8151],[8152,8163],[8164,8171]],gaps:[4,8,12],lengths:[14,15,16,17,18,19],code:{name:"CVN",size:3}},maestro:{niceType:"Maestro",type:"maestro",patterns:[493698,[5e5,504174],[504176,506698],[506779,508999],[56,59],63,67,6],gaps:[4,8,12],lengths:[12,13,14,15,16,17,18,19],code:{name:"CVC",size:3}},elo:{niceType:"Elo",type:"elo",patterns:[401178,401179,438935,457631,457632,431274,451416,457393,504175,[506699,506778],[509e3,509999],627780,636297,636368,[650031,650033],[650035,650051],[650405,650439],[650485,650538],[650541,650598],[650700,650718],[650720,650727],[650901,650978],[651652,651679],[655e3,655019],[655021,655058]],gaps:[4,8,12],lengths:[16],code:{name:"CVE",size:3}},mir:{niceType:"Mir",type:"mir",patterns:[[2200,2204]],gaps:[4,8,12],lengths:[16,17,18,19],code:{name:"CVP2",size:3}},hiper:{niceType:"Hiper",type:"hiper",patterns:[637095,63737423,63743358,637568,637599,637609,637612],gaps:[4,8,12],lengths:[16],code:{name:"CVC",size:3}},hipercard:{niceType:"Hipercard",type:"hipercard",patterns:[606282],gaps:[4,8,12],lengths:[16],code:{name:"CVC",size:3}},verve:{niceType:"Verve",type:"verve",patterns:[[506099,506127],506129,[506133,506150],[506158,506163],506166,506168,506170,506173,[506176,506180],506184,[506187,506188],506191,506195,506197,507865,507866,[507868,507877],[507880,507888],507900,507941],gaps:[4,8,12],lengths:[16,18,19],code:{name:"CVV",size:3}}}),n=function(){if(ze)return Ve;ze=1,Object.defineProperty(Ve,"__esModule",{value:!0}),Ve.addMatchingCardsToResults=function(n,r,o){var a,i;for(a=0;a<r.patterns.length;a++){var s=r.patterns[a];if((0,t.matches)(n,s)){var c=(0,e.clone)(r);i=Array.isArray(s)?String(s[0]).length:String(s).length,n.length>=i&&(c.matchStrength=i),o.push(c);break}}};var e=Be(),t=(Le||(Le=1,Object.defineProperty(He,"__esModule",{value:!0}),He.matches=function(e,t){return Array.isArray(t)?function(e,t,n){var r=String(t).length,o=e.substr(0,r),a=parseInt(o,10);return t=parseInt(String(t).substr(0,o.length),10),n=parseInt(String(n).substr(0,o.length),10),a>=t&&a<=n}(e,t[0],t[1]):function(e,t){return(t=String(t)).substring(0,e.length)===e.substring(0,t.length)}(e,t)}),He);return Ve}(),r=(Ue||(Ue=1,Object.defineProperty(Je,"__esModule",{value:!0}),Je.isValidInputType=function(e){return"string"==typeof e||e instanceof String}),Je),o=(qe||(qe=1,Object.defineProperty(Ze,"__esModule",{value:!0}),Ze.findBestMatch=function(e){return function(e){var t=e.filter(function(e){return e.matchStrength}).length;return t>0&&t===e.length}(e)?e.reduce(function(e,t){return e?Number(e.matchStrength)<Number(t.matchStrength)?t:e:t}):null}),Ze),a=Be(),i={},s={VISA:"visa",MASTERCARD:"mastercard",AMERICAN_EXPRESS:"american-express",DINERS_CLUB:"diners-club",DISCOVER:"discover",JCB:"jcb",UNIONPAY:"unionpay",VERVE:"verve",MAESTRO:"maestro",ELO:"elo",MIR:"mir",HIPER:"hiper",HIPERCARD:"hipercard"},c=[s.VISA,s.MASTERCARD,s.AMERICAN_EXPRESS,s.DINERS_CLUB,s.DISCOVER,s.JCB,s.UNIONPAY,s.VERVE,s.MAESTRO,s.ELO,s.MIR,s.HIPER,s.HIPERCARD],l=(0,a.clone)(c);function u(e){return i[e]||t[e]}function d(e,t){void 0===t&&(t=!1);var n=l.indexOf(e);if(!t&&-1===n)throw new Error('"'+e+'" is not a supported card type.');return n}function p(e){var t=[];if(!(0,r.isValidInputType)(e))return t;if(0===e.length)return l.map(function(e){return(0,a.clone)(u(e))});l.forEach(function(r){var o=u(r);(0,n.addMatchingCardsToResults)(e,o,t)});var i=(0,o.findBestMatch)(t);return i?[i]:t}return p.getTypeInfo=function(e){return(0,a.clone)(u(e))},p.removeCard=function(e){var t=d(e);l.splice(t,1)},p.addCard=function(e){var t=d(e.type,!0);i[e.type]=e,-1===t&&l.push(e.type)},p.updateCard=function(n,r){var o=i[n]||t[n];if(!o)throw new Error('"'.concat(n,"\" is not a recognized type. Use `addCard` instead.'"));if(r.type&&o.type!==r.type)throw new Error("Cannot overwrite type parameter.");var s=(0,a.clone)(o);s=e(e({},s),r),i[s.type]=s},p.changeOrder=function(e,t){var n=d(e);l.splice(n,1),l.splice(t,0,e)},p.resetModifications=function(){l=(0,a.clone)(c),i={}},p.types=s,We=p}var Xe,Ge,Qe,et,tt,nt={},rt={},ot={},at={},it={};function st(){if(tt)return it;tt=1,Object.defineProperty(it,"__esModule",{value:!0}),it.expirationYear=function(n,r){var o;if(void 0===r&&(r=e),"string"!=typeof n)return t(!1,!1);if(""===n.replace(/\s/g,""))return t(!1,!0);if(!/^\d*$/.test(n))return t(!1,!1);var a=n.length;if(a<2)return t(!1,!0);var i=(new Date).getFullYear();if(3===a)return t(!1,n.slice(0,2)===String(i).slice(0,2));if(a>4)return t(!1,!1);var s=parseInt(n,10),c=Number(String(i).substr(2,2)),l=!1;if(2===a){if(String(i).substr(0,2)===n)return t(!1,!0);o=c===s,l=s>=c&&s<=c+r}else 4===a&&(o=i===s,l=s>=i&&s<=i+r);return t(l,l,o)};var e=19;function t(e,t,n){return{isValid:e,isPotentiallyValid:t,isCurrentYear:n||!1}}return it}var ct,lt,ut,dt,pt={},ft={};function mt(){if(ut)return ft;function e(e,t,n){return{isValid:e,isPotentiallyValid:t,isValidForThisYear:n||!1}}return ut=1,Object.defineProperty(ft,"__esModule",{value:!0}),ft.expirationMonth=function(t){var n=(new Date).getMonth()+1;if("string"!=typeof t)return e(!1,!1);if(""===t.replace(/\s/g,"")||"0"===t)return e(!1,!0);if(!/^\d*$/.test(t))return e(!1,!1);var r=parseInt(t,10);if(isNaN(Number(t)))return e(!1,!1);var o=r>0&&r<13;return e(o,o,o&&r>=n)},ft}var yt,ht,gt,vt,bt={},xt={};const wt=l(function(){if(vt)return gt;vt=1;var e=gt&>.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),t=gt&>.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),n=(gt&>.__importStar||function(){var n=function(e){return(n=Object.getOwnPropertyNames||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[t.length]=n);return t})(e)};return function(r){if(r&&r.__esModule)return r;var o={};if(null!=r)for(var a=n(r),i=0;i<a.length;i++)"default"!==a[i]&&e(o,r,a[i]);return t(o,r),o}}())(Ke()),r=function(){if(Xe)return nt;Xe=1,Object.defineProperty(nt,"__esModule",{value:!0}),nt.cardholderName=function(r){return"string"!=typeof r?n(!1,!1):0===r.length?n(!1,!0):r.length>t?n(!1,!1):e.test(r)?n(!1,!0):n(!0,!0)};var e=/^[\d\s-]*$/,t=255;function n(e,t){return{isValid:e,isPotentiallyValid:t}}return nt}(),o=function(){if(et)return rt;et=1,Object.defineProperty(rt,"__esModule",{value:!0}),rt.cardNumber=function(r,o){var a,i;if(void 0===o&&(o={}),"string"!=typeof r&&"number"!=typeof r)return n(null,!1,!1);var s=String(r).replace(/-|\s/g,"");if(!/^\d*$/.test(s))return n(null,!1,!1);var c=t(s);if(0===c.length)return n(null,!1,!1);if(1!==c.length)return n(null,!0,!1);var l=c[0];if(o.maxLength&&s.length>o.maxLength)return n(l,!1,!1);a=!0===o.skipLuhnValidation||l.type===t.types.UNIONPAY&&!0!==o.luhnValidateUnionPay||e(s),i=Math.max.apply(null,l.lengths),o.maxLength&&(i=Math.min(o.maxLength,i));for(var u=0;u<l.lengths.length;u++)if(l.lengths[u]===s.length)return n(l,s.length<i||a,a);return n(l,s.length<i,!1)};var e=Qe?Ge:(Qe=1,Ge=function(e){for(var t,n=0,r=!1,o=e.length-1;o>=0;)t=parseInt(e.charAt(o),10),r&&(t*=2)>9&&(t=t%10+1),r=!r,n+=t,o--;return n%10==0}),t=Ke();function n(e,t,n){return{card:e,isPotentiallyValid:t,isValid:n}}return rt}(),a=function(){if(dt)return ot;dt=1;var e=ot&&ot.__assign||function(){return e=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},e.apply(this,arguments)};Object.defineProperty(ot,"__esModule",{value:!0}),ot.expirationDate=function(a,i){var s;if("string"==typeof a)a=a.replace(/^(\d\d) (\d\d(\d\d)?)$/,"$1/$2"),s=(0,t.parseDate)(String(a));else{if(null===a||"object"!=typeof a)return o(!1,!1,null,null);var c=e({},a);s={month:String(c.month),year:String(c.year)}}var l=(0,n.expirationMonth)(s.month),u=(0,r.expirationYear)(s.year,i);if(l.isValid){if(u.isCurrentYear){var d=l.isValidForThisYear;return o(d,d,s.month,s.year)}if(u.isValid)return o(!0,!0,s.month,s.year)}return o(!1,!(!l.isPotentiallyValid||!u.isPotentiallyValid),null,null)};var t=function(){if(lt)return at;lt=1,Object.defineProperty(at,"__esModule",{value:!0}),at.parseDate=function(n){var r;if(/^\d{4}-\d{1,2}$/.test(n)?r=n.split("-").reverse():/\//.test(n)?r=n.split(/\s*\/\s*/g):/\s/.test(n)&&(r=n.split(/ +/g)),(0,t.isArray)(r))return{month:r[0]||"",year:r.slice(1).join()};var o,a,i,s=(o=n,0===(i=Number(o[0]))?2:i>1||1===i&&Number(o[1])>2?1:1===i?(a=o.substr(1),(0,e.expirationYear)(a).isPotentiallyValid?1:2):5===o.length?1:o.length>5?2:1),c=n.substr(0,s);return{month:c,year:n.substr(c.length)}};var e=st(),t=(ct||(ct=1,Object.defineProperty(pt,"__esModule",{value:!0}),pt.isArray=void 0,pt.isArray=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)}),pt);return at}(),n=mt(),r=st();function o(e,t,n,r){return{isValid:e,isPotentiallyValid:t,month:n,year:r}}return ot}(),i=mt(),s=st(),c=function(){if(yt)return bt;yt=1,Object.defineProperty(bt,"__esModule",{value:!0}),bt.cvv=function(n,r){return void 0===r&&(r=e),r=r instanceof Array?r:[r],"string"!=typeof n?t(!1,!1):/^\d*$/.test(n)?function(e,t){for(var n=0;n<e.length;n++)if(t===e[n])return!0;return!1}(r,n.length)?t(!0,!0):n.length<Math.min.apply(null,r)?t(!1,!0):n.length>function(t){for(var n=e,r=0;r<t.length;r++)n=t[r]>n?t[r]:n;return n}(r)?t(!1,!1):t(!0,!0):t(!1,!1)};var e=3;function t(e,t){return{isValid:e,isPotentiallyValid:t}}return bt}(),l=function(){if(ht)return xt;ht=1,Object.defineProperty(xt,"__esModule",{value:!0}),xt.postalCode=function(r,o){void 0===o&&(o={});var a=o.minLength||e;return"string"!=typeof r?n(!1,!1):r.length<a?n(!1,!0):t.test(r.trim().slice(0,a))?n(!0,!0):n(!1,!0)};var e=2,t=new RegExp(/^[a-z0-9]+$/i);function n(e,t){return{isValid:e,isPotentiallyValid:t}}return xt}();return gt={creditCardType:n,cardholderName:r.cardholderName,number:o.cardNumber,expirationDate:a.expirationDate,expirationMonth:i.expirationMonth,expirationYear:s.expirationYear,cvv:c.cvv,postalCode:l.postalCode}}()),St=l(Ke());let Et=!1;Et||(Et=!0,St.addCard({niceType:"Mada",type:"mada",patterns:[440647,440795,446404,446672,419593,428331,428671,432328,440533,446393,457865,458456,462220,484783,484800,493428,504300,521076,529415,535825,536023,537767,543357,557606,558848,588845,589206],gaps:[4,8,12],lengths:[16,18,19],code:{name:"CVV",size:3}}));const jt=({brand:t,fallbackColor:n,height:r=22})=>{if(!t)return null;switch(t){case"Visa":return e.jsx(Ct,{height:r});case"Mastercard":return e.jsx(kt,{height:r});case"American Express":return e.jsx(Pt,{height:r});case"Mada":return e.jsx(Ot,{height:r});case"Discover":return e.jsx(_t,{height:r});case"JCB":return e.jsx(At,{height:r});default:return e.jsx("span",{className:"text-xs font-medium",style:{color:n},"aria-label":`Card brand: ${t}`,children:t})}},Ct=({height:t})=>e.jsxs("svg",{role:"img","aria-label":"Visa",viewBox:"0 0 48 16",height:t,width:48*t/16,style:{display:"block"},children:[e.jsx("rect",{width:"48",height:"16",rx:"2",fill:"#1A1F71"}),e.jsx("text",{x:"24",y:"12",textAnchor:"middle",fontFamily:"Helvetica, Arial, sans-serif",fontWeight:"900",fontSize:"11",fill:"#FFFFFF",letterSpacing:"1.4",children:"VISA"})]}),kt=({height:t})=>e.jsxs("svg",{role:"img","aria-label":"Mastercard",viewBox:"0 0 32 20",height:t,width:32*t/20,style:{display:"block"},children:[e.jsx("circle",{cx:"12",cy:"10",r:"7",fill:"#EB001B"}),e.jsx("circle",{cx:"20",cy:"10",r:"7",fill:"#F79E1B"}),e.jsx("path",{d:"M16 4.5a7 7 0 0 1 0 11 7 7 0 0 1 0-11Z",fill:"#FF5F00","aria-hidden":"true"})]}),Pt=({height:t})=>e.jsxs("svg",{role:"img","aria-label":"American Express",viewBox:"0 0 48 16",height:t,width:48*t/16,style:{display:"block"},children:[e.jsx("rect",{width:"48",height:"16",rx:"2",fill:"#2E77BB"}),e.jsx("text",{x:"24",y:"11.5",textAnchor:"middle",fontFamily:"Helvetica, Arial, sans-serif",fontWeight:"700",fontSize:"9",fill:"#FFFFFF",letterSpacing:"0.4",children:"AMEX"})]}),Ot=({height:t})=>e.jsxs("svg",{role:"img","aria-label":"Mada",viewBox:"0 0 48 16",height:t,width:48*t/16,style:{display:"block"},children:[e.jsx("rect",{width:"48",height:"16",rx:"2",fill:"#84B740"}),e.jsx("text",{x:"24",y:"11.5",textAnchor:"middle",fontFamily:"Helvetica, Arial, sans-serif",fontWeight:"700",fontSize:"9",fill:"#FFFFFF",letterSpacing:"0.6",children:"mada"})]}),_t=({height:t})=>e.jsxs("svg",{role:"img","aria-label":"Discover",viewBox:"0 0 56 16",height:t,width:56*t/16,style:{display:"block"},children:[e.jsx("rect",{width:"56",height:"16",rx:"2",fill:"#FFFFFF",stroke:"#E5E7EB"}),e.jsx("text",{x:"20",y:"11.5",textAnchor:"middle",fontFamily:"Helvetica, Arial, sans-serif",fontWeight:"700",fontSize:"8",fill:"#231F20",letterSpacing:"0.2",children:"DISCOVER"}),e.jsx("circle",{cx:"44",cy:"8",r:"4",fill:"#FF6000"})]}),At=({height:t})=>e.jsxs("svg",{role:"img","aria-label":"JCB",viewBox:"0 0 32 16",height:t,width:32*t/16,style:{display:"block"},children:[e.jsx("rect",{x:"0",y:"0",width:"10.66",height:"16",rx:"2",fill:"#0E4C96"}),e.jsx("rect",{x:"10.66",y:"0",width:"10.66",height:"16",fill:"#B41E25"}),e.jsx("rect",{x:"21.33",y:"0",width:"10.66",height:"16",rx:"2",fill:"#1B8A3A"}),e.jsx("text",{x:"16",y:"11",textAnchor:"middle",fontFamily:"Helvetica, Arial, sans-serif",fontWeight:"900",fontSize:"9",fill:"#FFFFFF",children:"JCB"})]}),Nt=({skin:r})=>{const{paymentInit:o}=Kt(),a=o&&"moyasar"===o.provider?o:null,i=ue(),s=de(),c=pe(),[l,u]=t.useState(""),[d,p]=t.useState(""),[f,m]=t.useState(""),[y,h]=t.useState(""),[g,v]=t.useState(!1),[b,x]=t.useState({}),[w,S]=t.useState(null),E=t.useRef({number:l,expiry:d,cvc:f,name:y});E.current={number:l,expiry:d,cvc:f,name:y};const j=t.useRef(i);j.current=i,t.useEffect(()=>{a&&c({amount:a.config.amount,currency:a.config.currency.toUpperCase()})},[a,c]);const C=t.useCallback(async()=>{if(!a)return;const e=function(e,t=new Date){const n=[],r=wt.number(e.number),o=e.number.replace(/\D/g,"");o?r.isValid||n.push({field:"number",message:"Invalid card number"}):n.push({field:"number",message:"Card number is required"});const a=wt.expirationDate(e.expiry);let i=null,s=null;const c=e.expiry.trim();if(c)if(a.isValid){i=Number.parseInt(a.month??"",10);const e=Number.parseInt(a.year??"",10);s=2===(a.year??"").length?e+2e3:e}else{const e=function(e){let t="",n="";if(e.includes("/")){const[r,o]=e.split("/");t=(r??"").replace(/\D/g,""),n=(o??"").replace(/\D/g,"")}else{const r=e.replace(/\D/g,"");t=r.slice(0,2),n=r.slice(2)}const r=Number.parseInt(t,10),o=Number.parseInt(n,10);return Number.isNaN(r)||Number.isNaN(o)?null:{month:r,year:2===n.length?o+2e3:o}}(c);e&&function(e,t,n){const r=n.getFullYear(),o=n.getMonth()+1;return t<r||t===r&&e<o}(e.month,e.year,t)?n.push({field:"expiry",message:"Card expired"}):n.push({field:"expiry",message:"Invalid expiry"})}else n.push({field:"expiry",message:"Expiry is required"});const l=wt.cvv(e.cvc,r.card?.code.size??[3,4]),u=e.cvc.replace(/\D/g,"");u?l.isValid||n.push({field:"cvc",message:"Invalid CVC"}):n.push({field:"cvc",message:"CVC is required"});const d=wt.cardholderName(e.name),p=e.name.trim();return p?d.isValid||n.push({field:"name",message:"Invalid cardholder name"}):n.push({field:"name",message:"Cardholder name is required"}),n.length>0||null==i||null==s?{ok:!1,errors:n}:{ok:!0,card:{number:o,month:String(i).padStart(2,"0"),year:String(s),cvc:u,name:p}}}(E.current);if(!1===e.ok){const t={};for(const n of e.errors)t[n.field]||(t[n.field]=n.message);return void x(t)}x({}),v(!0);try{const t=await async function(e){const t=await Oe("https://api.moyasar.com/v1/tokens",{...e,save_only:!0});if(!t.ok)throw new ke(_e(t.body)??`Tokenization failed (${t.status})`,t.status,t.body);const n=t.body;if(!n||"string"!=typeof n.id)throw new ke("Tokenization returned no token id",t.status,n);return{id:n.id}}({publishable_api_key:a.config.publishable_key,name:e.card.name,number:e.card.number,month:e.card.month,year:e.card.year,cvc:e.card.cvc}),r=Ce(a),o=await Pe({publishable_api_key:a.config.publishable_key,given_id:a.config.given_id,amount:a.config.amount,currency:a.config.currency.toUpperCase(),description:a.config.description,callback_url:n.po(a.config.given_id),source:{type:"token",token:t.id},...Object.keys(r).length>0?{metadata:r}:{}}),i=o.source?.transaction_url??o.transaction_url;if(i)return void S(i);const s=o.status;j.current("paid"===s||"authorized"===s||"captured"===s?{status:"success",provider:"moyasar",paymentId:o.id,amount:o.amount,currency:o.currency}:"failed"===s?{status:"failure",provider:"moyasar",code:"failed",message:o.source?.message??"Payment failed",paymentId:o.id}:{status:"failure",provider:"moyasar",code:s,message:`Unexpected payment status: ${s}`,paymentId:o.id})}catch(e){const t=e instanceof ke||e instanceof Error?e.message:"Payment failed";j.current({status:"failure",provider:"moyasar",message:t,paymentId:a.config.given_id})}finally{v(!1)}},[a]);t.useEffect(()=>(s({confirm:C,isConfirming:g}),()=>s(null)),[C,g,s]);const k=t.useMemo(()=>Math.max(r.radius-4,4),[r.radius]),P=t.useMemo(()=>function(e){const t=e.replace(/\D/g,"");if(t.length<2)return null;const n=St(t);return n[0]?.niceType??null}(l),[l]);return a?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-3",style:{fontFamily:r.fontFamily},children:[e.jsx(Tt,{label:"Card number",value:l,onChange:e=>u(e.replace(/\D/g,"").slice(0,19).replace(/(\d{4})(?=\d)/g,"$1 ")),autoComplete:"cc-number",inputMode:"numeric",placeholder:"1234 5678 9012 3456",error:b.number,skin:r,radius:k,endAdornment:P?e.jsx(jt,{brand:P,fallbackColor:r.muted}):null}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(Tt,{label:"Expiry",value:d,onChange:e=>p(function(e){const t=e.replace(/\D/g,"").slice(0,4);return t.length<=2?t:`${t.slice(0,2)}/${t.slice(2)}`}(e)),autoComplete:"cc-exp",inputMode:"numeric",placeholder:"MM / YY",error:b.expiry,skin:r,radius:k}),e.jsx(Tt,{label:"CVC",value:f,onChange:e=>m(e.replace(/\D/g,"").slice(0,4)),autoComplete:"cc-csc",inputMode:"numeric",placeholder:"123",error:b.cvc,skin:r,radius:k})]}),e.jsx(Tt,{label:"Name on card",value:y,onChange:h,autoComplete:"cc-name",inputMode:"text",placeholder:"Full name",error:b.name,skin:r,radius:k})]}),w&&e.jsx(Ne,{url:w,skin:r,onResult:e=>{S(null),j.current(e)}})]}):null};function It(e){let t=0;for(let n=0;n<e.length;n++){const r=e.charCodeAt(n);r>=48&&r<=57&&t++}return t}const Tt=({label:n,value:r,onChange:o,placeholder:a,autoComplete:i,inputMode:s,error:c,skin:l,radius:u,endAdornment:d})=>{const p=c?"#dc2626":l.divider,f=t.useRef(null),m=t.useRef(null),y="numeric"===s;return t.useLayoutEffect(()=>{const e=m.current;if(null===e||!f.current)return;m.current=null;const t=f.current.value;let n=0,r=0;for(;r<t.length&&!(n>=e);)/\d/.test(t[r])&&n++,r++;f.current.setSelectionRange(r,r)},[r]),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-xs mb-1",style:{color:l.muted},children:n}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{ref:f,type:"text",value:r,onChange:e=>{y&&(m.current=It(e.target.value.slice(0,e.target.selectionStart??e.target.value.length))),o(e.target.value)},onKeyDown:e=>{if(!y||"Backspace"!==e.key)return;const t=e.currentTarget,n=t.selectionStart??0;if(n!==(t.selectionEnd??0)||n<2)return;const r=t.value[n-1];if(!r||/\d/.test(r))return;e.preventDefault();const a=t.value.slice(0,n-2)+t.value.slice(n);m.current=It(a.slice(0,n-2)),o(a)},placeholder:a,autoComplete:i,inputMode:s,spellCheck:!1,className:"w-full py-2.5 px-3 outline-none text-sm transition-colors",style:{background:l.pillBg,color:l.text,border:`1px solid ${p}`,borderRadius:u,paddingRight:d?96:void 0}}),d&&e.jsx("span",{className:"absolute right-3 top-1/2 -translate-y-1/2 text-xs font-medium pointer-events-none",style:{color:l.muted},"aria-label":"Card brand",children:d})]}),c&&e.jsx("span",{className:"block mt-1 text-xs",style:{color:"#dc2626"},children:c})]})},Mt=["creditcard","applepay"],Rt=({skin:t})=>e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-x-0 top-1/2",style:{borderTop:`1px solid ${t.divider}`}}),e.jsx("div",{className:"relative flex justify-center",children:e.jsx("span",{className:"px-2 text-xs uppercase tracking-wide",style:{background:t.cardBg,color:t.muted,fontFamily:t.fontFamily},children:"or"})})]}),Ft={type:"moyasar",label:"Moyasar",FormComponent:({skin:n,onReady:r})=>{const{paymentInit:o}=Kt(),a=o&&"moyasar"===o.provider?o:null,i=function(){const[e,n]=t.useState(!1);return t.useEffect(()=>{if("undefined"==typeof window)return;const e=window.ApplePaySession;if(e&&"function"==typeof e.canMakePayments)try{n(!0===e.canMakePayments())}catch{n(!1)}},[]),e}(),s=t.useRef(r);if(s.current=r,t.useEffect(()=>{s.current?.()},[]),!a)return null;const c=a.config.methods??Mt,l=c.includes("creditcard"),u=c.includes("applepay")&&i;return e.jsxs("div",{className:"space-y-4",children:[l&&e.jsx(Nt,{skin:n}),l&&u&&e.jsx(Rt,{skin:n}),u&&e.jsx(Me,{skin:n})]})}},$t="5vh",Vt="5vw",Dt="aiatcore-chargebee-modal-style",Bt="aiatcore-chargebee-close-button",Lt="aiatcore-chargebee-loader",zt="aiatcore-cb-spin",Ut='#cb-container, .cb-container, [id^="cb-modal"], [class*="cb-modal"], [class*="cb-checkout"], div[class*="cb-"][class*="overlay"]',qt="aiatcore-chargebee-open";function Wt(){document.getElementById(Bt)?.remove()}function Yt(){document.getElementById(Lt)?.remove()}const Ht={type:"chargebee",label:"Chargebee",FormComponent:({amount:e,currency:n,onReady:r})=>{const{paymentInit:o}=Kt(),a=ue(),i=pe(),s=de(),c=t.useRef(!1);return t.useEffect(()=>(s(null),()=>s(null)),[s]),t.useEffect(()=>{if("chargebee"!==o?.provider)return;const{site:t,hosted_page_url:s,amount:l,currency:u,expires_at:d}=o.config,p=l??e,f=u??n;null!=p&&f&&i({amount:p,currency:f}),c.current=!1;let m=!1,y=null,h=null;const g=e=>{c.current||(c.current=!0,a(e))};return r?.(),null!=d&&Date.now()>=1e3*d?(g({status:"failure",provider:"chargebee",message:"Payment link has expired. Please request a new one."}),()=>{m=!0}):(function(){const e=document.getElementById(Dt)??document.createElement("style");e.id=Dt,e.textContent=`\n /* Prevent horizontal page scroll only while Chargebee's overlay is mounted */\n html.${qt}, body.${qt} {\n overflow-x: hidden !important;\n }\n\n /* Outer Chargebee overlay container — broad selector net so we catch\n whatever wrapper Chargebee actually uses */\n #cb-container,\n .cb-container,\n [id^="cb-modal"],\n [class*="cb-modal"],\n [class*="cb-checkout"],\n div[class*="cb-"][class*="overlay"] {\n position: fixed !important;\n inset: ${$t} max(${Vt}, calc((100vw - 1500px) / 2)) !important;\n width: auto !important;\n height: auto !important;\n max-width: none !important;\n max-height: none !important;\n margin: 0 !important;\n border-radius: 12px !important;\n box-shadow: 0 20px 60px rgba(0,0,0,0.35) !important;\n overflow: hidden !important;\n z-index: 2147483646 !important;\n pointer-events: all !important;\n }\n\n /* Inner iframe — fill the container fully and ensure it receives clicks */\n [id^="cb-frame"] {\n width: 100% !important;\n height: 100% !important;\n border: none !important;\n display: block !important;\n z-index: 2147483646 !important;\n pointer-events: all !important;\n outline: none !important;\n box-shadow: none !important;\n }\n\n @keyframes ${zt} {\n to { transform: rotate(360deg); }\n }\n `,e.parentElement||document.head.appendChild(e),document.documentElement.classList.add(qt),document.body.classList.add(qt)}(),function(e){if(window.Chargebee)return Promise.resolve();const t=document.querySelector('script[src*="js.chargebee.com"]');return t?"1"===t.dataset.cbLoaded?Promise.resolve():new Promise((e,n)=>{t.addEventListener("load",()=>e()),t.addEventListener("error",()=>n(new Error("Chargebee.js failed to load")))}):new Promise((t,n)=>{const r=document.createElement("script");r.src="https://js.chargebee.com/v2/chargebee.js",r.setAttribute("data-cb-site",e),r.onload=()=>{r.dataset.cbLoaded="1",t()},r.onerror=()=>n(new Error("Chargebee.js failed to load")),document.head.appendChild(r)})}(t).then(()=>{if(m)return;let e;try{e=window.Chargebee.getInstance()??window.Chargebee.init({site:t})}catch{e=window.Chargebee.init({site:t})}e.openCheckout({hostedPage:()=>Promise.resolve({id:o.payment_id,url:s,type:"checkout_one_time",state:"created"}),success:e=>{Wt(),Yt(),g({status:"success",provider:"chargebee",paymentId:e,amount:p??void 0,currency:f??void 0})},close:()=>{Wt(),Yt(),g({status:"cancel",provider:"chargebee"})},error:e=>{Wt(),Yt(),g({status:"failure",provider:"chargebee",message:e?.message??"Payment failed"})}}),h=function(){let e=0,t=0,n=0,r=null,o=null;const a=Date.now()+5e3,i=()=>{if(m||c.current)return;const t=document.querySelector(Ut);if(t instanceof HTMLElement){const e=t.getBoundingClientRect();if(e.width>0&&e.height>0){!function(){Yt();const e=document.createElement("div");e.id=Lt,e.setAttribute("aria-live","polite"),e.setAttribute("aria-busy","true"),e.style.cssText=`\n position: fixed;\n inset: ${$t} max(${Vt}, calc((100vw - 1500px) / 2));\n z-index: 2147483646;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n gap: 14px;\n background: #f8f8f8;\n border-radius: 12px;\n color: #6b7280;\n font: 500 14px/1.4 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;\n pointer-events: none;\n `;const t=document.createElement("div");t.style.cssText=`\n width: 32px;\n height: 32px;\n border: 2.5px solid rgba(17, 24, 39, 0.08);\n border-top-color: #6366f1;\n border-radius: 50%;\n animation: ${zt} 0.8s linear infinite;\n `;const n=document.createElement("p");n.textContent="Loading payment…",n.style.cssText="margin: 0;",e.appendChild(t),e.appendChild(n),document.body.appendChild(e)}();const e=document.querySelector('[id^="cb-frame"]');return void(e instanceof HTMLIFrameElement&&(r=e,o=()=>{n=window.setTimeout(Yt,400)},r.addEventListener("load",o)))}}Date.now()>=a||(e=window.requestAnimationFrame(i))};return t=window.setTimeout(i,100),()=>{window.clearTimeout(t),window.clearTimeout(n),e&&window.cancelAnimationFrame(e),r&&o&&r.removeEventListener("load",o),Yt()}}(),y=function(e){let t=0,n=0;const r=Date.now()+5e3,o=()=>{if(m||c.current)return;const n=document.querySelector(Ut);if(n instanceof HTMLElement){const t=n.getBoundingClientRect();if(t.width>0&&t.height>0)return void function(e){Wt();const t=document.createElement("button");t.id=Bt,t.type="button",t.setAttribute("aria-label","Close payment"),t.textContent="×",t.style.cssText=`\n position: fixed;\n top: calc(${$t} + 12px);\n right: calc(max(${Vt}, calc((100vw - 1500px) / 2)) + 12px);\n z-index: 2147483647;\n width: 32px;\n height: 32px;\n border: 0;\n border-radius: 9999px;\n background: rgba(17, 24, 39, 0.72);\n color: #ffffff;\n font: 600 16px/1 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;\n cursor: pointer;\n pointer-events: auto;\n display: flex;\n align-items: center;\n justify-content: center;\n box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);\n `,t.addEventListener("click",e),document.body.appendChild(t)}(e)}Date.now()>=r||(t=window.requestAnimationFrame(o))};return n=window.setTimeout(o,100),()=>{window.clearTimeout(n),t&&window.cancelAnimationFrame(t)}}(()=>{Wt(),Yt(),document.querySelectorAll(Ut).forEach(e=>{e instanceof HTMLElement&&(e.style.display="none")}),g({status:"cancel",provider:"chargebee"});try{e.closeAll()}catch{}})}).catch(e=>{g({status:"failure",provider:"chargebee",message:e?.message??"Failed to load payment form"})}),()=>{m=!0,y?.(),h?.(),Wt(),Yt(),document.documentElement.classList.remove(qt),document.body.classList.remove(qt),document.getElementById(Dt)?.remove();try{window.Chargebee?.getInstance?.()?.closeAll?.()}catch{}})},[o,e,n,i,r,a]),null},hideShellSubmit:!0},Jt=t.createContext(void 0),Zt=({children:r,paymentProvider:o,paymentInit:a=null,conversationId:i=null})=>{const s=a?.provider||o||n.yo,c=t.useMemo(()=>function(e){switch(e){case"stripe":return je;case"moyasar":return Ft;case"chargebee":return Ht;default:throw new Error(`Unknown payment provider: "${e}". Supported providers: stripe, moyasar, chargebee`)}}(s),[s]),l=t.useMemo(()=>({adapter:c,paymentProvider:s,paymentInit:a,conversationId:i}),[c,s,a,i]),u=c.ProviderWrapper;return e.jsx(Jt.Provider,{value:l,children:u?e.jsx(u,{children:r}):r})},Kt=()=>{const e=t.useContext(Jt);if(!e)throw new Error("usePaymentAdapter must be used within a PaymentProvider");return e},Xt=({provider:r,paymentInit:o})=>{const{themeStyles:a,theme:i}=n.dt(),{adapter:s}=Kt(),c=le().summary,[l,u]=t.useState(!1),d=t.useCallback(()=>u(!0),[]),p=t.useMemo(()=>n.mo(a,i),[a,i]),f="moyasar"===o?.provider?o.config:null,m="chargebee"===o?.provider?o.config:null,y=c?.amount??f?.amount??m?.amount??0,h=c?.currency??f?.currency??m?.currency??"usd",g=null!=c?.amount||null!=f?.amount||null!=m?.amount,v=((e,t)=>n.bs(e,t)??"")(y,h),b=r??s.label,x=s.FormComponent;return e.jsxs("div",{className:"w-full flex-1 min-h-0 overflow-y-auto [&::-webkit-scrollbar]:hidden [scrollbar-width:none] relative",style:{background:p.pageBg,color:p.text,fontFamily:p.fontFamily,colorScheme:p.colorScheme},children:[!l&&e.jsx(Gt,{skin:p}),e.jsx("div",{className:"min-h-full flex items-center justify-center p-4",style:{visibility:l?"visible":"hidden"},children:e.jsxs("div",{className:"w-full max-w-sm p-5",style:{background:p.cardBg,borderRadius:p.radius,boxShadow:p.cardShadow,color:p.text},children:[e.jsx("h1",{className:"text-base font-semibold text-center mb-3.5",style:{color:p.heading},children:"Payment Options"}),e.jsx("div",{className:"mb-3.5",children:e.jsx(x,{amount:y,currency:h,skin:p,onReady:d})}),!s.hideShellSubmit&&g&&e.jsx(Qt,{label:`Pay ${v}`,background:a.statusDiscovery.solid,color:a.statusDiscovery.text,radius:p.radius}),!s.hideShellFooter&&e.jsxs("p",{className:"text-xs text-center mt-2.5",style:{color:p.muted},children:["Powered by ",b]})]})})]})},Gt=({skin:t})=>e.jsxs("div",{className:"absolute inset-0 z-10 flex flex-col items-center justify-center gap-3",style:{background:t.pageBg,color:t.text},"aria-live":"polite","aria-busy":"true",children:[e.jsx(c,{className:"h-8 w-8 animate-spin",style:{color:t.accent}}),e.jsx("p",{className:"text-sm",style:{color:t.muted},children:"Loading payment…"})]}),Qt=({label:t,background:n,color:r,radius:o})=>{const a=le().confirmHandle;return e.jsx("button",{type:"button",onClick:()=>a?.confirm(),disabled:!a||a.isConfirming,className:"w-full p-2.5 text-sm font-semibold border-0 cursor-pointer disabled:cursor-not-allowed disabled:opacity-70",style:{background:n,color:r,borderRadius:o},children:a?.isConfirming?"Processing…":t})};exports.default=({provider:t,paymentInit:r=null,onResult:o,conversationId:a=null})=>e.jsx(Zt,{paymentInit:r,conversationId:a,paymentProvider:n.Z(),children:e.jsx(ce,{onResult:e=>{o?.(e)},children:e.jsx(Xt,{provider:t,paymentInit:r})})},r?.provider??"default");
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{d as t}from"./diag-api-BepQpXrk.js";const e="exception.message",r="exception.stacktrace",s="exception.type",i="service.name",n="telemetry.sdk.language",u="telemetry.sdk.name",a="telemetry.sdk.version",c="process.runtime.name",o={[u]:"opentelemetry",[c]:"browser",[n]:"webjs",[a]:"2.7.1"};let b;function h(){if(void 0===b)try{const t=globalThis.process.argv0;b=t?`unknown_service:${t}`:"unknown_service"}catch{b="unknown_service"}return b}const m=t=>null!==t&&"object"==typeof t&&"function"==typeof t.then;class d{_rawAttributes;_asyncAttributesPending=!1;_schemaUrl;_memoizedAttributes;static FromAttributeList(t,e){const r=new d({},e);return r._rawAttributes=w(t),r._asyncAttributesPending=t.filter(([t,e])=>m(e)).length>0,r}constructor(e,r){this._rawAttributes=Object.entries(e.attributes??{}).map(([t,e])=>(m(e)&&(this._asyncAttributesPending=!0),[t,e])),this._rawAttributes=w(this._rawAttributes),this._schemaUrl=function(e){if("string"==typeof e||void 0===e)return e;t.warn("Schema URL must be string or undefined, got %s. Schema URL will be ignored.",e)}(r?.schemaUrl)}get asyncAttributesPending(){return this._asyncAttributesPending}async waitForAsyncAttributes(){if(this.asyncAttributesPending){for(let t=0;t<this._rawAttributes.length;t++){const[e,r]=this._rawAttributes[t];this._rawAttributes[t]=[e,m(r)?await r:r]}this._asyncAttributesPending=!1}}get attributes(){if(this.asyncAttributesPending&&t.error("Accessing resource attributes before async attributes settled"),this._memoizedAttributes)return this._memoizedAttributes;const e={};for(const[r,s]of this._rawAttributes)m(s)?t.debug(`Unsettled resource attribute ${r} skipped`):null!=s&&(e[r]??=s);return this._asyncAttributesPending||(this._memoizedAttributes=e),e}getRawAttributes(){return this._rawAttributes}get schemaUrl(){return this._schemaUrl}merge(e){if(null==e)return this;const r=function(e,r){const s=e?.schemaUrl,i=r?.schemaUrl;return void 0===s||""===s?i:void 0===i||""===i||s===i?s:void t.warn('Schema URL merge conflict: old resource has "%s", updating resource has "%s". Resulting resource will have undefined Schema URL.',s,i)}(this,e),s=r?{schemaUrl:r}:void 0;return d.FromAttributeList([...e.getRawAttributes(),...this.getRawAttributes()],s)}}function l(t,e){return d.FromAttributeList(Object.entries(t),e)}function g(t,e){return new d(t,e)}function A(){return l({})}function f(){return l({[i]:h(),[n]:o[n],[u]:o[u],[a]:o[a]})}function w(e){return e.map(([e,r])=>m(r)?[e,r.catch(r=>{t.debug("promise rejection for resource attribute: %s - %s",e,r)})]:[e,r])}export{e as A,s as a,r as b,h as c,f as d,A as e,l as f,g as r};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const t=require("./diag-api-DsVI4ljU.cjs"),e="service.name",r="telemetry.sdk.language",s="telemetry.sdk.name",i="telemetry.sdk.version",n="process.runtime.name",u={[s]:"opentelemetry",[n]:"browser",[r]:"webjs",[i]:"2.7.1"};let c;function o(){if(void 0===c)try{const t=globalThis.process.argv0;c=t?`unknown_service:${t}`:"unknown_service"}catch{c="unknown_service"}return c}const a=t=>null!==t&&"object"==typeof t&&"function"==typeof t.then;class b{_rawAttributes;_asyncAttributesPending=!1;_schemaUrl;_memoizedAttributes;static FromAttributeList(t,e){const r=new b({},e);return r._rawAttributes=h(t),r._asyncAttributesPending=t.filter(([t,e])=>a(e)).length>0,r}constructor(e,r){this._rawAttributes=Object.entries(e.attributes??{}).map(([t,e])=>(a(e)&&(this._asyncAttributesPending=!0),[t,e])),this._rawAttributes=h(this._rawAttributes),this._schemaUrl=function(e){if("string"==typeof e||void 0===e)return e;t.diag.warn("Schema URL must be string or undefined, got %s. Schema URL will be ignored.",e)}(r?.schemaUrl)}get asyncAttributesPending(){return this._asyncAttributesPending}async waitForAsyncAttributes(){if(this.asyncAttributesPending){for(let t=0;t<this._rawAttributes.length;t++){const[e,r]=this._rawAttributes[t];this._rawAttributes[t]=[e,a(r)?await r:r]}this._asyncAttributesPending=!1}}get attributes(){if(this.asyncAttributesPending&&t.diag.error("Accessing resource attributes before async attributes settled"),this._memoizedAttributes)return this._memoizedAttributes;const e={};for(const[r,s]of this._rawAttributes)a(s)?t.diag.debug(`Unsettled resource attribute ${r} skipped`):null!=s&&(e[r]??=s);return this._asyncAttributesPending||(this._memoizedAttributes=e),e}getRawAttributes(){return this._rawAttributes}get schemaUrl(){return this._schemaUrl}merge(e){if(null==e)return this;const r=function(e,r){const s=e?.schemaUrl,i=r?.schemaUrl;return void 0===s||""===s?i:void 0===i||""===i||s===i?s:void t.diag.warn('Schema URL merge conflict: old resource has "%s", updating resource has "%s". Resulting resource will have undefined Schema URL.',s,i)}(this,e),s=r?{schemaUrl:r}:void 0;return b.FromAttributeList([...e.getRawAttributes(),...this.getRawAttributes()],s)}}function d(t,e){return b.FromAttributeList(Object.entries(t),e)}function h(e){return e.map(([e,r])=>a(r)?[e,r.catch(r=>{t.diag.debug("promise rejection for resource attribute: %s - %s",e,r)})]:[e,r])}exports.ATTR_EXCEPTION_MESSAGE="exception.message",exports.ATTR_EXCEPTION_STACKTRACE="exception.stacktrace",exports.ATTR_EXCEPTION_TYPE="exception.type",exports.defaultResource=function(){return d({[e]:o(),[r]:u[r],[s]:u[s],[i]:u[i]})},exports.defaultServiceName=o,exports.emptyResource=function(){return d({})},exports.resourceFromAttributes=d,exports.resourceFromDetectedResource=function(t,e){return new b(t,e)};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const e="1.9.1",r=/^(\d+)\.(\d+)\.(\d+)(-(.+))?$/,n=function(e){const n=new Set([e]),t=new Set,o=e.match(r);if(!o)return()=>!1;const i=+o[1],s=+o[2],a=+o[3];if(null!=o[4])return function(r){return r===e};function u(e){return t.add(e),!1}function c(e){return n.add(e),!0}return function(e){if(n.has(e))return!0;if(t.has(e))return!1;const o=e.match(r);if(!o)return u(e);const l=+o[2],g=+o[3];return null!=o[4]||i!==+o[1]?u(e):0===i?s===l&&a<=g?c(e):u(e):s<=l?c(e):u(e)}}(e),t=e.split(".")[0],o=Symbol.for(`opentelemetry.js.api.${t}`),i="object"==typeof globalThis?globalThis:"object"==typeof self?self:"object"==typeof window?window:"object"==typeof global?global:{};function s(r,n,t,s=!1){var a;const u=i[o]=null!==(a=i[o])&&void 0!==a?a:{version:e};if(!s&&u[r]){const e=new Error(`@opentelemetry/api: Attempted duplicate registration of API: ${r}`);return t.error(e.stack||e.message),!1}if(u.version!==e){const n=new Error(`@opentelemetry/api: Registration of version v${u.version} for ${r} does not match previously registered API v${e}`);return t.error(n.stack||n.message),!1}return u[r]=n,t.debug(`@opentelemetry/api: Registered a global for ${r} v${e}.`),!0}function a(e){var r,t;const s=null===(r=i[o])||void 0===r?void 0:r.version;if(s&&n(s))return null===(t=i[o])||void 0===t?void 0:t[e]}function u(r,n){n.debug(`@opentelemetry/api: Unregistering a global for ${r} v${e}.`);const t=i[o];t&&delete t[r]}class c{constructor(e){this._namespace=e.namespace||"DiagComponentLogger"}debug(...e){return l("debug",this._namespace,e)}error(...e){return l("error",this._namespace,e)}info(...e){return l("info",this._namespace,e)}warn(...e){return l("warn",this._namespace,e)}verbose(...e){return l("verbose",this._namespace,e)}}function l(e,r,n){const t=a("diag");if(t)return t[e](r,...n)}var g,f;(f=g||(g={}))[f.NONE=0]="NONE",f[f.ERROR=30]="ERROR",f[f.WARN=50]="WARN",f[f.INFO=60]="INFO",f[f.DEBUG=70]="DEBUG",f[f.VERBOSE=80]="VERBOSE",f[f.ALL=9999]="ALL";class d{static instance(){return this._instance||(this._instance=new d),this._instance}constructor(){function e(e){return function(...r){const n=a("diag");if(n)return n[e](...r)}}const r=this;r.setLogger=(e,n={logLevel:g.INFO})=>{var t,o,i;if(e===r){const e=new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");return r.error(null!==(t=e.stack)&&void 0!==t?t:e.message),!1}"number"==typeof n&&(n={logLevel:n});const u=a("diag"),c=function(e,r){function n(n,t){const o=r[n];return"function"==typeof o&&e>=t?o.bind(r):function(){}}return e<g.NONE?e=g.NONE:e>g.ALL&&(e=g.ALL),r=r||{},{error:n("error",g.ERROR),warn:n("warn",g.WARN),info:n("info",g.INFO),debug:n("debug",g.DEBUG),verbose:n("verbose",g.VERBOSE)}}(null!==(o=n.logLevel)&&void 0!==o?o:g.INFO,e);if(u&&!n.suppressOverrideMessage){const e=null!==(i=(new Error).stack)&&void 0!==i?i:"<failed to generate stacktrace>";u.warn(`Current logger will be overwritten from ${e}`),c.warn(`Current logger will overwrite one already registered from ${e}`)}return s("diag",c,r,!0)},r.disable=()=>{u("diag",r)},r.createComponentLogger=e=>new c(e),r.verbose=e("verbose"),r.debug=e("debug"),r.info=e("info"),r.warn=e("warn"),r.error=e("error")}}const p=d.instance();export{d as D,p as d,a as g,s as r,u};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const e="1.9.1",r=/^(\d+)\.(\d+)\.(\d+)(-(.+))?$/,n=function(e){const n=new Set([e]),t=new Set,o=e.match(r);if(!o)return()=>!1;const i=+o[1],s=+o[2],a=+o[3];if(null!=o[4])return function(r){return r===e};function u(e){return t.add(e),!1}function l(e){return n.add(e),!0}return function(e){if(n.has(e))return!0;if(t.has(e))return!1;const o=e.match(r);if(!o)return u(e);const c=+o[2],g=+o[3];return null!=o[4]||i!==+o[1]?u(e):0===i?s===c&&a<=g?l(e):u(e):s<=c?l(e):u(e)}}(e),t=e.split(".")[0],o=Symbol.for(`opentelemetry.js.api.${t}`),i="object"==typeof globalThis?globalThis:"object"==typeof self?self:"object"==typeof window?window:"object"==typeof global?global:{};function s(r,n,t,s=!1){var a;const u=i[o]=null!==(a=i[o])&&void 0!==a?a:{version:e};if(!s&&u[r]){const e=new Error(`@opentelemetry/api: Attempted duplicate registration of API: ${r}`);return t.error(e.stack||e.message),!1}if(u.version!==e){const n=new Error(`@opentelemetry/api: Registration of version v${u.version} for ${r} does not match previously registered API v${e}`);return t.error(n.stack||n.message),!1}return u[r]=n,t.debug(`@opentelemetry/api: Registered a global for ${r} v${e}.`),!0}function a(e){var r,t;const s=null===(r=i[o])||void 0===r?void 0:r.version;if(s&&n(s))return null===(t=i[o])||void 0===t?void 0:t[e]}function u(r,n){n.debug(`@opentelemetry/api: Unregistering a global for ${r} v${e}.`);const t=i[o];t&&delete t[r]}class l{constructor(e){this._namespace=e.namespace||"DiagComponentLogger"}debug(...e){return c("debug",this._namespace,e)}error(...e){return c("error",this._namespace,e)}info(...e){return c("info",this._namespace,e)}warn(...e){return c("warn",this._namespace,e)}verbose(...e){return c("verbose",this._namespace,e)}}function c(e,r,n){const t=a("diag");if(t)return t[e](r,...n)}var g,f;(f=g||(g={}))[f.NONE=0]="NONE",f[f.ERROR=30]="ERROR",f[f.WARN=50]="WARN",f[f.INFO=60]="INFO",f[f.DEBUG=70]="DEBUG",f[f.VERBOSE=80]="VERBOSE",f[f.ALL=9999]="ALL";class d{static instance(){return this._instance||(this._instance=new d),this._instance}constructor(){function e(e){return function(...r){const n=a("diag");if(n)return n[e](...r)}}const r=this;r.setLogger=(e,n={logLevel:g.INFO})=>{var t,o,i;if(e===r){const e=new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");return r.error(null!==(t=e.stack)&&void 0!==t?t:e.message),!1}"number"==typeof n&&(n={logLevel:n});const u=a("diag"),l=function(e,r){function n(n,t){const o=r[n];return"function"==typeof o&&e>=t?o.bind(r):function(){}}return e<g.NONE?e=g.NONE:e>g.ALL&&(e=g.ALL),r=r||{},{error:n("error",g.ERROR),warn:n("warn",g.WARN),info:n("info",g.INFO),debug:n("debug",g.DEBUG),verbose:n("verbose",g.VERBOSE)}}(null!==(o=n.logLevel)&&void 0!==o?o:g.INFO,e);if(u&&!n.suppressOverrideMessage){const e=null!==(i=(new Error).stack)&&void 0!==i?i:"<failed to generate stacktrace>";u.warn(`Current logger will be overwritten from ${e}`),l.warn(`Current logger will overwrite one already registered from ${e}`)}return s("diag",l,r,!0)},r.disable=()=>{u("diag",r)},r.createComponentLogger=e=>new l(e),r.verbose=e("verbose"),r.debug=e("debug"),r.info=e("info"),r.warn=e("warn"),r.error=e("error")}}const p=d.instance();exports.DiagAPI=d,exports.diag=p,exports.getGlobal=a,exports.registerGlobal=s,exports.unregisterGlobal=u;
|
package/dist/index-32QtQw41.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./diag-api-DsVI4ljU.cjs"),t=require("./ExportResult-eb4TcH7k.cjs"),r=require("./ResourceImpl-yQJWLZDn.cjs"),s=require("./NoopLogger-B-ce52_l.cjs");function i(e){return Symbol.for(e)}class o{constructor(e){const t=this;t._currentContext=e?new Map(e):new Map,t.getValue=e=>t._currentContext.get(e),t.setValue=(e,r)=>{const s=new o(t._currentContext);return s._currentContext.set(e,r),s},t.deleteValue=e=>{const r=new o(t._currentContext);return r._currentContext.delete(e),r}}}const n=new o;class a{}class c{addCallback(e){}removeCallback(e){}}const u=new class{constructor(){}createGauge(e,t){return l}createHistogram(e,t){return d}createCounter(e,t){return h}createUpDownCounter(e,t){return g}createObservableGauge(e,t){return p}createObservableCounter(e,t){return _}createObservableUpDownCounter(e,t){return m}addBatchObservableCallback(e,t){}removeBatchObservableCallback(e){}},h=new class extends a{add(e,t){}},l=new class extends a{record(e,t){}},d=new class extends a{record(e,t){}},g=new class extends a{add(e,t){}},_=new class extends c{},p=new class extends c{},m=new class extends c{},f="context",x=new class{active(){return n}with(e,t,r,...s){return t.call(r,...s)}bind(e,t){return t}enable(){return this}disable(){return this}};class b{constructor(){}static getInstance(){return this._instance||(this._instance=new b),this._instance}setGlobalContextManager(t){return e.registerGlobal(f,t,e.DiagAPI.instance())}active(){return this._getContextManager().active()}with(e,t,r,...s){return this._getContextManager().with(e,t,r,...s)}bind(e,t){return this._getContextManager().bind(e,t)}_getContextManager(){return e.getGlobal(f)||x}disable(){this._getContextManager().disable(),e.unregisterGlobal(f,e.DiagAPI.instance())}}var v,y;(y=v||(v={}))[y.NONE=0]="NONE",y[y.SAMPLED=1]="SAMPLED";const w="0000000000000000",S="00000000000000000000000000000000",C={traceId:S,spanId:w,traceFlags:v.NONE};class T{constructor(e=C){this._spanContext=e}spanContext(){return this._spanContext}setAttribute(e,t){return this}setAttributes(e){return this}addEvent(e,t){return this}addLink(e){return this}addLinks(e){return this}setStatus(e){return this}updateName(e){return this}end(e){}isRecording(){return!1}recordException(e,t){}}const E=i("OpenTelemetry Context Key SPAN");function L(e){return e.getValue(E)||void 0}function R(){return L(b.getInstance().active())}function P(e,t){return e.setValue(E,t)}function A(e){return e.deleteValue(E)}function O(e,t){return P(e,new T(t))}function N(e){var t;return null===(t=L(e))||void 0===t?void 0:t.spanContext()}const I=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1]);function M(e,t){if("string"!=typeof e||e.length!==t)return!1;let r=0;for(let t=0;t<e.length;t+=4)r+=(0|I[e.charCodeAt(t)])+(0|I[e.charCodeAt(t+1)])+(0|I[e.charCodeAt(t+2)])+(0|I[e.charCodeAt(t+3)]);return r===t}function F(e){return M(r=e.traceId,32)&&r!==S&&M(t=e.spanId,16)&&t!==w;var t,r}function B(e){return new T(e)}const j=b.getInstance();class D{startSpan(e,t,r=j.active()){if(Boolean(null==t?void 0:t.root))return new T;const s=r&&N(r);return null!==(i=s)&&"object"==typeof i&&"spanId"in i&&"string"==typeof i.spanId&&"traceId"in i&&"string"==typeof i.traceId&&"traceFlags"in i&&"number"==typeof i.traceFlags&&F(s)?new T(s):new T;var i}startActiveSpan(e,t,r,s){let i,o,n;if(arguments.length<2)return;2===arguments.length?n=t:3===arguments.length?(i=t,n=r):(i=t,o=r,n=s);const a=null!=o?o:j.active(),c=this.startSpan(e,i,a),u=P(a,c);return j.with(u,n,void 0,c)}}const z=new D;class k{constructor(e,t,r,s){this._provider=e,this.name=t,this.version=r,this.options=s}startSpan(e,t,r){return this._getTracer().startSpan(e,t,r)}startActiveSpan(e,t,r,s){const i=this._getTracer();return Reflect.apply(i.startActiveSpan,i,arguments)}_getTracer(){if(this._delegate)return this._delegate;const e=this._provider.getDelegateTracer(this.name,this.version,this.options);return e?(this._delegate=e,this._delegate):z}}const U=new class{getTracer(e,t,r){return new D}};class G{getTracer(e,t,r){var s;return null!==(s=this.getDelegateTracer(e,t,r))&&void 0!==s?s:new k(this,e,t,r)}getDelegate(){var e;return null!==(e=this._delegate)&&void 0!==e?e:U}setDelegate(e){this._delegate=e}getDelegateTracer(e,t,r){var s;return null===(s=this._delegate)||void 0===s?void 0:s.getTracer(e,t,r)}}const $=b.getInstance(),V="trace";class X{constructor(){this._proxyTracerProvider=new G,this.wrapSpanContext=B,this.isSpanContextValid=F,this.deleteSpan=A,this.getSpan=L,this.getActiveSpan=R,this.getSpanContext=N,this.setSpan=P,this.setSpanContext=O}static getInstance(){return this._instance||(this._instance=new X),this._instance}setGlobalTracerProvider(t){const r=e.registerGlobal(V,this._proxyTracerProvider,e.DiagAPI.instance());return r&&this._proxyTracerProvider.setDelegate(t),r}getTracerProvider(){return e.getGlobal(V)||this._proxyTracerProvider}getTracer(e,t){return this.getTracerProvider().getTracer(e,t)}disable(){e.unregisterGlobal(V,e.DiagAPI.instance()),this._proxyTracerProvider=new G}}const H=X.getInstance(),Q=i("OpenTelemetry SDK Context Key SUPPRESS_TRACING");function q(e){return e.setValue(Q,!0)}function K(t){try{(t=>{e.diag.error(function(e){return"string"==typeof e?e:JSON.stringify(function(e){const t={};let r=e;for(;null!==r;)Object.getOwnPropertyNames(r).forEach(e=>{if(t[e])return;const s=r[e];s&&(t[e]=String(s))}),r=Object.getPrototypeOf(r);return t}(e))}(t))})(t)}catch{}}class Y extends Error{constructor(e){super(e),Object.setPrototypeOf(this,Y.prototype)}}class W{_promise;_resolve;_reject;constructor(){this._promise=new Promise((e,t)=>{this._resolve=e,this._reject=t})}get promise(){return this._promise}resolve(e){this._resolve(e)}reject(e){this._reject(e)}}class J{_isCalled=!1;_deferred=new W;_callback;_that;constructor(e,t){this._callback=e,this._that=t}get isCalled(){return this._isCalled}get promise(){return this._deferred.promise}call(...e){if(!this._isCalled){this._isCalled=!0;try{Promise.resolve(this._callback.call(this._that,...e)).then(e=>this._deferred.resolve(e),e=>this._deferred.reject(e))}catch(e){this._deferred.reject(e)}}return this._deferred.promise}}function Z(e){return ee(e,new WeakSet)}function ee(e,t){return null==e||"string"==typeof e||"number"==typeof e||"boolean"==typeof e||e instanceof Uint8Array||"object"==typeof e&&!t.has(e)&&(t.add(e),Array.isArray(e)?e.every(e=>ee(e,t)):(e.constructor===Object||void 0===e.constructor)&&Object.values(e).every(e=>ee(e,t)))}class te{hrTime;hrTimeObserved;spanContext;resource;instrumentationScope;attributes={};_severityText;_severityNumber;_body;_eventName;_attributesCount=0;_droppedAttributesCount=0;_isReadonly=!1;_logRecordLimits;set severityText(e){this._isLogRecordReadonly()||(this._severityText=e)}get severityText(){return this._severityText}set severityNumber(e){this._isLogRecordReadonly()||(this._severityNumber=e)}get severityNumber(){return this._severityNumber}set body(e){this._isLogRecordReadonly()||(this._body=e)}get body(){return this._body}get eventName(){return this._eventName}set eventName(e){this._isLogRecordReadonly()||(this._eventName=e)}get droppedAttributesCount(){return this._droppedAttributesCount}constructor(e,r,s){const{timestamp:i,observedTimestamp:o,eventName:n,severityNumber:a,severityText:c,body:u,attributes:h={},exception:l,context:d}=s,g=Date.now();if(this.hrTime=t.timeInputToHrTime(i??g),this.hrTimeObserved=t.timeInputToHrTime(o??g),d){const e=H.getSpanContext(d);e&&F(e)&&(this.spanContext=e)}this.severityNumber=a,this.severityText=c,this.body=u,this.resource=e.resource,this.instrumentationScope=r,this._logRecordLimits=e.logRecordLimits,this._eventName=n,this.setAttributes(h),null!=l&&this._setException(l)}setAttribute(t,r){if(this._isLogRecordReadonly())return this;if(0===t.length)return e.diag.warn(`Invalid attribute key: ${t}`),this;if(!Z(r))return e.diag.warn(`Invalid attribute value set for key: ${t}`),this;const s=!Object.prototype.hasOwnProperty.call(this.attributes,t);return s&&this._attributesCount>=this._logRecordLimits.attributeCountLimit?(this._droppedAttributesCount++,1===this._droppedAttributesCount&&e.diag.warn("Dropping extra attributes."),this):(this.attributes[t]=this._truncateToSize(r),s&&this._attributesCount++,this)}setAttributes(e){for(const[t,r]of Object.entries(e))this.setAttribute(t,r);return this}setBody(e){return this.body=e,this}setEventName(e){return this.eventName=e,this}setSeverityNumber(e){return this.severityNumber=e,this}setSeverityText(e){return this.severityText=e,this}_makeReadonly(){this._isReadonly=!0}_truncateToSize(t){const r=this._logRecordLimits.attributeValueLengthLimit;if(r<=0)return e.diag.warn(`Attribute value limit must be positive, got ${r}`),t;if(null==t)return t;if("string"==typeof t)return this._truncateToLimitUtil(t,r);if(t instanceof Uint8Array)return t;if(Array.isArray(t))return t.map(e=>this._truncateToSize(e));if("object"==typeof t){const e={};for(const[r,s]of Object.entries(t))e[r]=this._truncateToSize(s);return e}return t}_setException(t){let s=!1;if("string"==typeof t||"number"==typeof t)Object.hasOwn(this.attributes,r.ATTR_EXCEPTION_MESSAGE)||this.setAttribute(r.ATTR_EXCEPTION_MESSAGE,String(t)),s=!0;else if(t&&"object"==typeof t){const e=t;e.code?(Object.hasOwn(this.attributes,r.ATTR_EXCEPTION_TYPE)||this.setAttribute(r.ATTR_EXCEPTION_TYPE,e.code.toString()),s=!0):e.name&&(Object.hasOwn(this.attributes,r.ATTR_EXCEPTION_TYPE)||this.setAttribute(r.ATTR_EXCEPTION_TYPE,e.name),s=!0),e.message&&(Object.hasOwn(this.attributes,r.ATTR_EXCEPTION_MESSAGE)||this.setAttribute(r.ATTR_EXCEPTION_MESSAGE,e.message),s=!0),e.stack&&(Object.hasOwn(this.attributes,r.ATTR_EXCEPTION_STACKTRACE)||this.setAttribute(r.ATTR_EXCEPTION_STACKTRACE,e.stack),s=!0)}s||e.diag.warn(`Failed to record an exception ${t}`)}_truncateToLimitUtil(e,t){return e.length<=t?e:e.substring(0,t)}_isLogRecordReadonly(){return this._isReadonly&&e.diag.warn("Can not execute the operation on emitted log record"),this._isReadonly}}class re{instrumentationScope;_sharedState;_loggerConfig;constructor(e,t){this.instrumentationScope=e,this._sharedState=t,this._loggerConfig=this._sharedState.getLoggerConfig(this.instrumentationScope)}emit(e){const t=e.context||$.active();if(!this.enabled(e))return;const r=new te(this._sharedState,this.instrumentationScope,{context:t,...e});this._sharedState.loggerMetrics.emitLog(),this._sharedState.activeProcessor.onEmit(r,t),r._makeReadonly()}enabled(e){const t=this._loggerConfig;if(t.disabled)return!1;const r=e?.severityNumber;if("number"==typeof r&&r!==s.SeverityNumber.UNSPECIFIED&&r<t.minimumSeverity)return!1;const i=e?.context||$.active();if(t.traceBased){const e=H.getSpanContext(i);if(e&&F(e)&&(e.traceFlags&v.SAMPLED)!==v.SAMPLED)return!1}const o={context:i,instrumentationScope:this.instrumentationScope,severityNumber:e?.severityNumber,eventName:e?.eventName};for(const e of this._sharedState.processors)if(!e.enabled||e.enabled(o))return!0;return!1}}class se{forceFlush(){return Promise.resolve()}onEmit(e,t){}shutdown(){return Promise.resolve()}enabled(e){return!1}}class ie{processors;forceFlushTimeoutMillis;constructor(e,t){this.processors=e,this.forceFlushTimeoutMillis=t}async forceFlush(){const e=this.forceFlushTimeoutMillis;await Promise.all(this.processors.map(t=>function(e,t){let r;const s=new Promise(function(e,s){r=setTimeout(function(){s(new Y("Operation timed out."))},t)});return Promise.race([e,s]).then(e=>(clearTimeout(r),e),e=>{throw clearTimeout(r),e})}(t.forceFlush(),e)))}onEmit(e,t){this.processors.forEach(r=>r.onEmit(e,t))}async shutdown(){await Promise.all(this.processors.map(e=>e.shutdown()))}enabled(e){for(const t of this.processors)if(!t.enabled||t.enabled(e))return!0;return!1}}class oe{createdLogs;constructor(e){this.createdLogs=e.createCounter("otel.sdk.log.created",{unit:"{log_record}",description:"The number of logs submitted to enabled SDK Loggers."})}emitLog(){this.createdLogs.add(1)}}const ne={disabled:!1,minimumSeverity:s.SeverityNumber.UNSPECIFIED,traceBased:!1},ae=()=>({...ne});class ce{loggers=new Map;activeProcessor;registeredLogRecordProcessors=[];resource;forceFlushTimeoutMillis;logRecordLimits;processors;loggerMetrics;_loggerConfigurator;_loggerConfigs=new Map;constructor(e,t,r,s,i,o){this.resource=e,this.forceFlushTimeoutMillis=t,this.logRecordLimits=r,this.processors=s,s.length>0?(this.registeredLogRecordProcessors=s,this.activeProcessor=new ie(this.registeredLogRecordProcessors,this.forceFlushTimeoutMillis)):this.activeProcessor=new se,this._loggerConfigurator=i??ae;const n=o?o.getMeter("@opentelemetry/sdk-logs","0.218.0"):u;this.loggerMetrics=new oe(n)}getLoggerConfig(e){const t=`${(r=e).name}@${r.version||""}:${r.schemaUrl||""}`;var r;let s=this._loggerConfigs.get(t);return s||(s=this._loggerConfigurator(e),this._loggerConfigs.set(t,s),s)}}class ue{_exportCompleted;_exportScheduledPromise;_exportScheduledResolve;constructor(e,t,r){this._exportScheduledPromise=new Promise(e=>{this._exportScheduledResolve=e}),this._exportCompleted=this._executeExport(e,t,r)}get exportCompleted(){return this._exportCompleted}get exportScheduled(){return this._exportScheduledPromise}async _executeExport(e,t,r){try{await async function(e){const t=[];for(let r=0,s=e.length;r<s;r++){const s=e[r];s.resource.asyncAttributesPending&&s.resource.waitForAsyncAttributes&&t.push(s.resource.waitForAsyncAttributes())}null!=t&&t.length>0&&await Promise.all(t)}(t),await $.with(q($.active()),async()=>this._exportWithTimeout(e,t,r))}catch(e){K(e),this._exportScheduledResolve()}}async _exportWithTimeout(e,r,s){return new Promise((i,o)=>{const n=setTimeout(()=>{o(new Error("Timeout"))},s);e.export(r,e=>{clearTimeout(n),e.code===t.ExportResultCode.SUCCESS?i():o(e.error??new Error("BatchLogRecordProcessor: log record export failed"))}),this._exportScheduledResolve()})}}class he{_maxExportBatchSize;_maxQueueSize;_scheduledDelayMillis;_exportTimeoutMillis;_exporter;_currentExport=null;_finishedLogRecords=[];_timer;_shutdownOnce;_flushing=!1;constructor(t,r){this._exporter=t,this._maxExportBatchSize=r?.maxExportBatchSize??512,this._maxQueueSize=r?.maxQueueSize??2048,this._scheduledDelayMillis=r?.scheduledDelayMillis??5e3,this._exportTimeoutMillis=r?.exportTimeoutMillis??3e4,this._shutdownOnce=new J(this._shutdown,this),this._maxExportBatchSize>this._maxQueueSize&&(e.diag.warn("BatchLogRecordProcessor: maxExportBatchSize must be smaller or equal to maxQueueSize, setting maxExportBatchSize to match maxQueueSize"),this._maxExportBatchSize=this._maxQueueSize)}onEmit(e){this._shutdownOnce.isCalled||this._addToBuffer(e)}forceFlush(){return this._shutdownOnce.isCalled?this._shutdownOnce.promise:this._flushAll()}_addToBuffer(e){this._finishedLogRecords.length>=this._maxQueueSize||(this._finishedLogRecords.push(e),this._maybeStartTimer())}shutdown(){return this._shutdownOnce.call()}async _shutdown(){this.onShutdown(),await this._flushAll(),await this._exporter.shutdown()}async _flushAll(){if(this._flushing)return;this._flushing=!0;let e=this._finishedLogRecords;for(this._finishedLogRecords=[],this._clearTimer(),null!==this._currentExport&&(await this._exporter.forceFlush(),await this._currentExport.exportCompleted,this._currentExport=null);e.length>0;){let t;e.length<=this._maxExportBatchSize?(t=e,e=[]):t=e.splice(0,this._maxExportBatchSize);const r=new ue(this._exporter,t,this._exportTimeoutMillis);this._currentExport=r;try{await r.exportScheduled,await this._exporter.forceFlush(),await r.exportCompleted}catch(e){K(e)}finally{this._currentExport=null}}this._flushing=!1,this._maybeStartTimer()}_extractBatch(){if(0===this._finishedLogRecords.length)return null;if(this._finishedLogRecords.length<=this._maxExportBatchSize){const e=this._finishedLogRecords;return this._finishedLogRecords=[],e}return this._finishedLogRecords.splice(0,this._maxExportBatchSize)}_exportOneBatch(){this._clearTimer();const e=this._extractBatch();if(null===e)return;const t=new ue(this._exporter,e,this._exportTimeoutMillis);this._currentExport=t,t.exportCompleted.then(()=>{this._currentExport=null,this._maybeStartTimer()}).catch(e=>{this._currentExport=null,K(e),this._maybeStartTimer()})}_maybeStartTimer(){this._shutdownOnce.isCalled||this._flushing||0!==this._finishedLogRecords.length&&null===this._currentExport&&(this._finishedLogRecords.length>=this._maxExportBatchSize?this._exportOneBatch():void 0===this._timer&&(this._timer=setTimeout(()=>{this._timer=void 0,this._exportOneBatch()},this._scheduledDelayMillis),"number"!=typeof this._timer&&this._timer.unref()))}_clearTimer(){void 0!==this._timer&&(clearTimeout(this._timer),this._timer=void 0)}}const le={disabled:!1,minimumSeverity:s.SeverityNumber.UNSPECIFIED,traceBased:!1};function de(e,t){if(t===e)return!0;if(t.includes("*")){const r=t.split("*").map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join(".*");return new RegExp(`^${r}$`).test(e)}return!1}exports.BatchLogRecordProcessor=class extends he{_visibilityChangeListener;_pageHideListener;constructor(e,t){super(e,t),this._onInit(t)}onShutdown(){"undefined"!=typeof document&&(this._visibilityChangeListener&&document.removeEventListener("visibilitychange",this._visibilityChangeListener),this._pageHideListener&&document.removeEventListener("pagehide",this._pageHideListener))}_onInit(e){!0!==e?.disableAutoFlushOnDocumentHide&&"undefined"!=typeof document&&(this._visibilityChangeListener=()=>{"hidden"===document.visibilityState&&this.forceFlush()},this._pageHideListener=()=>{this.forceFlush()},document.addEventListener("visibilitychange",this._visibilityChangeListener),document.addEventListener("pagehide",this._pageHideListener))}},exports.ConsoleLogRecordExporter=class{export(e,t){this._sendLogRecords(e,t)}async forceFlush(){}async shutdown(){}_exportInfo(e){return{resource:{attributes:e.resource.attributes},instrumentationScope:e.instrumentationScope,timestamp:t.hrTimeToMicroseconds(e.hrTime),traceId:e.spanContext?.traceId,spanId:e.spanContext?.spanId,traceFlags:e.spanContext?.traceFlags,severityText:e.severityText,severityNumber:e.severityNumber,eventName:e.eventName,body:e.body,attributes:e.attributes}}_sendLogRecords(e,r){for(const t of e)console.dir(this._exportInfo(t),{depth:3});r?.({code:t.ExportResultCode.SUCCESS})}},exports.InMemoryLogRecordExporter=class{_finishedLogRecords=[];_stopped=!1;export(e,r){if(this._stopped)return r({code:t.ExportResultCode.FAILED,error:new Error("Exporter has been stopped")});this._finishedLogRecords.push(...e),r({code:t.ExportResultCode.SUCCESS})}async shutdown(){this._stopped=!0,this.reset()}async forceFlush(){}getFinishedLogRecords(){return this._finishedLogRecords}reset(){this._finishedLogRecords=[]}},exports.LoggerProvider=class{_shutdownOnce;_sharedState;constructor(e={}){const t={resource:e.resource??r.defaultResource(),forceFlushTimeoutMillis:e.forceFlushTimeoutMillis??3e4,logRecordLimits:{attributeCountLimit:e.logRecordLimits?.attributeCountLimit??128,attributeValueLengthLimit:e.logRecordLimits?.attributeValueLengthLimit??1/0},loggerConfigurator:e.loggerConfigurator??ae,processors:e.processors??[],meterProvider:e.meterProvider};this._sharedState=new ce(t.resource,t.forceFlushTimeoutMillis,t.logRecordLimits,t.processors,t.loggerConfigurator,t.meterProvider),this._shutdownOnce=new J(this._shutdown,this)}getLogger(t,r,i){if(this._shutdownOnce.isCalled)return e.diag.warn("A shutdown LoggerProvider cannot provide a Logger"),s.NOOP_LOGGER;t||e.diag.warn("Logger requested without instrumentation scope name.");const o=t||"unknown",n=`${o}@${r||""}:${i?.schemaUrl||""}`;return this._sharedState.loggers.has(n)||this._sharedState.loggers.set(n,new re({name:o,version:r,schemaUrl:i?.schemaUrl},this._sharedState)),this._sharedState.loggers.get(n)}forceFlush(){return this._shutdownOnce.isCalled?(e.diag.warn("invalid attempt to force flush after LoggerProvider shutdown"),this._shutdownOnce.promise):this._sharedState.activeProcessor.forceFlush()}shutdown(){return this._shutdownOnce.isCalled?(e.diag.warn("shutdown may only be called once per LoggerProvider"),this._shutdownOnce.promise):this._shutdownOnce.call()}_shutdown(){return this._sharedState.activeProcessor.shutdown()}},exports.SimpleLogRecordProcessor=class{_exporter;_shutdownOnce;_unresolvedExports;constructor(e){this._exporter=e,this._shutdownOnce=new J(this._shutdown,this),this._unresolvedExports=new Set}onEmit(e,r){if(this._shutdownOnce.isCalled)return;const s=()=>{return(r=this._exporter,s=[e],new Promise(e=>{$.with(q($.active()),()=>{r.export(s,e)})})).then(e=>{e.code!==t.ExportResultCode.SUCCESS&&K(e.error??new Error(`SimpleLogRecordProcessor: log record export failed (status ${e})`))}).catch(K);var r,s};if(e.resource.asyncAttributesPending){const t=e.resource.waitForAsyncAttributes?.().then(()=>(this._unresolvedExports.delete(t),s()),K);null!=t&&this._unresolvedExports.add(t)}else s()}async forceFlush(){await Promise.all(Array.from(this._unresolvedExports))}shutdown(){return this._shutdownOnce.call()}_shutdown(){return this._exporter.shutdown()}},exports.createLoggerConfigurator=function(e){return t=>{const r=t.name;for(const{pattern:t,config:s}of e)if(de(r,t))return{disabled:s.disabled??le.disabled,minimumSeverity:s.minimumSeverity??le.minimumSeverity,traceBased:s.traceBased??le.traceBased};return{...le}}};
|
package/dist/index-65-Yxkqs.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./diag-api-DsVI4ljU.cjs"),t=require("./ResourceImpl-yQJWLZDn.cjs"),r=new class{_MAX_LENGTH=255;_COMMA_SEPARATOR=",";_LABEL_KEY_VALUE_SPLITTER="=";detect(e){return{attributes:{}}}_parseResourceAttributes(e){if(!e)return{};const t={},r=e.split(this._COMMA_SEPARATOR).filter(e=>""!==e.trim());for(const e of r){const r=e.split(this._LABEL_KEY_VALUE_SPLITTER);if(2!==r.length)throw new Error(`Invalid format for OTEL_RESOURCE_ATTRIBUTES: "${e}". Expected format: key=value. The ',' and '=' characters must be percent-encoded in keys and values.`);const[o,s]=r,c=o.trim(),n=s.trim();if(0===c.length)throw new Error(`Invalid OTEL_RESOURCE_ATTRIBUTES: empty attribute key in "${e}".`);let u,a;try{u=decodeURIComponent(c),a=decodeURIComponent(n)}catch(t){throw new Error(`Failed to percent-decode OTEL_RESOURCE_ATTRIBUTES entry "${e}": ${t instanceof Error?t.message:t}`)}if(u.length>this._MAX_LENGTH)throw new Error(`Attribute key exceeds the maximum length of ${this._MAX_LENGTH} characters: "${u}".`);if(a.length>this._MAX_LENGTH)throw new Error(`Attribute value exceeds the maximum length of ${this._MAX_LENGTH} characters for key "${u}".`);t[u]=a}return t}},o=new class{detect(){return{attributes:{}}}},s=o,c=o,n=o,u=o;exports.defaultResource=t.defaultResource,exports.defaultServiceName=t.defaultServiceName,exports.emptyResource=t.emptyResource,exports.resourceFromAttributes=t.resourceFromAttributes,exports.detectResources=(r={})=>(r.detectors||[]).map(o=>{try{const s=t.resourceFromDetectedResource(o.detect(r));return e.diag.debug(`${o.constructor.name} found resource.`,s),s}catch(r){return e.diag.debug(`${o.constructor.name} failed: ${r.message}`),t.emptyResource()}}).reduce((e,t)=>e.merge(t),t.emptyResource()),exports.envDetector=r,exports.hostDetector=s,exports.osDetector=c,exports.processDetector=n,exports.serviceInstanceIdDetector=u;
|