@gigscom/embeds-js
Version:
prebuilt embeddable UI components on top of the Gigs API for the Web
2 lines (1 loc) • 44.1 kB
JavaScript
(function(Z,ee){typeof exports=="object"&&typeof module<"u"?ee(exports):typeof define=="function"&&define.amd?define(["exports"],ee):(Z=typeof globalThis<"u"?globalThis:Z||self,ee(Z.GigsEmbeds={}))})(this,function(Z){"use strict";function ee(e){return{all:e=e||new Map,on:function(t,i){var n=e.get(t);n?n.push(i):e.set(t,[i])},off:function(t,i){var n=e.get(t);n&&(i?n.splice(n.indexOf(i)>>>0,1):e.set(t,[]))},emit:function(t,i){var n=e.get(t);n&&n.slice().map(function(r){r(i)}),(n=e.get("*"))&&n.slice().map(function(r){r(t,i)})}}}var ae,g,Ye,Ze,B,Ke,Qe,Pe,$e,xe,we,Xe,te={},et=[],Mt=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,Ae=Array.isArray;function L(e,t){for(var i in t)e[i]=t[i];return e}function tt(e){var t=e.parentNode;t&&t.removeChild(e)}function Vt(e,t,i){var n,r,o,u={};for(o in t)o=="key"?n=t[o]:o=="ref"?r=t[o]:u[o]=t[o];if(arguments.length>2&&(u.children=arguments.length>3?ae.call(arguments,2):i),typeof e=="function"&&e.defaultProps!=null)for(o in e.defaultProps)u[o]===void 0&&(u[o]=e.defaultProps[o]);return le(e,u,n,r,null)}function le(e,t,i,n,r){var o={type:e,props:t,key:i,ref:n,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,constructor:void 0,__v:r??++Ye,__i:-1,__u:0};return r==null&&g.vnode!=null&&g.vnode(o),o}function K(e){return e.children}function ie(e,t){this.props=e,this.context=t}function J(e,t){if(t==null)return e.__?J(e.__,e.__i+1):null;for(var i;t<e.__k.length;t++)if((i=e.__k[t])!=null&&i.__e!=null)return i.__e;return typeof e.type=="function"?J(e):null}function it(e){var t,i;if((e=e.__)!=null&&e.__c!=null){for(e.__e=e.__c.base=null,t=0;t<e.__k.length;t++)if((i=e.__k[t])!=null&&i.__e!=null){e.__e=e.__c.base=i.__e;break}return it(e)}}function Fe(e){(!e.__d&&(e.__d=!0)&&B.push(e)&&!ce.__r++||Ke!==g.debounceRendering)&&((Ke=g.debounceRendering)||Qe)(ce)}function ce(){var e,t,i,n,r,o,u,a;for(B.sort(Pe);e=B.shift();)e.__d&&(t=B.length,n=void 0,o=(r=(i=e).__v).__e,u=[],a=[],i.__P&&((n=L({},r)).__v=r.__v+1,g.vnode&&g.vnode(n),Ce(i.__P,n,r,i.__n,i.__P.namespaceURI,32&r.__u?[o]:null,u,o??J(r),!!(32&r.__u),a),n.__v=r.__v,n.__.__k[n.__i]=n,ut(u,n,a),n.__e!=o&&it(n)),B.length>t&&B.sort(Pe));ce.__r=0}function nt(e,t,i,n,r,o,u,a,f,l,c){var s,h,_,p,y,v=n&&n.__k||et,m=t.length;for(i.__d=f,Rt(i,t,v),f=i.__d,s=0;s<m;s++)(_=i.__k[s])!=null&&typeof _!="boolean"&&typeof _!="function"&&(h=_.__i===-1?te:v[_.__i]||te,_.__i=s,Ce(e,_,h,r,o,u,a,f,l,c),p=_.__e,_.ref&&h.ref!=_.ref&&(h.ref&&De(h.ref,null,_),c.push(_.ref,_.__c||p,_)),y==null&&p!=null&&(y=p),65536&_.__u||h.__k===_.__k?(f&&!f.isConnected&&(f=J(h)),f=rt(_,f,e)):typeof _.type=="function"&&_.__d!==void 0?f=_.__d:p&&(f=p.nextSibling),_.__d=void 0,_.__u&=-196609);i.__d=f,i.__e=y}function Rt(e,t,i){var n,r,o,u,a,f=t.length,l=i.length,c=l,s=0;for(e.__k=[],n=0;n<f;n++)u=n+s,(r=e.__k[n]=(r=t[n])==null||typeof r=="boolean"||typeof r=="function"?null:typeof r=="string"||typeof r=="number"||typeof r=="bigint"||r.constructor==String?le(null,r,null,null,null):Ae(r)?le(K,{children:r},null,null,null):r.constructor===void 0&&r.__b>0?le(r.type,r.props,r.key,r.ref?r.ref:null,r.__v):r)!=null?(r.__=e,r.__b=e.__b+1,a=Wt(r,i,u,c),r.__i=a,o=null,a!==-1&&(c--,(o=i[a])&&(o.__u|=131072)),o==null||o.__v===null?(a==-1&&s--,typeof r.type!="function"&&(r.__u|=65536)):a!==u&&(a===u+1?s++:a>u?c>f-u?s+=a-u:s--:a<u?a==u-1&&(s=a-u):s=0,a!==n+s&&(r.__u|=65536))):(o=i[u])&&o.key==null&&o.__e&&!(131072&o.__u)&&(o.__e==e.__d&&(e.__d=J(o)),qe(o,o,!1),i[u]=null,c--);if(c)for(n=0;n<l;n++)(o=i[n])!=null&&!(131072&o.__u)&&(o.__e==e.__d&&(e.__d=J(o)),qe(o,o))}function rt(e,t,i){var n,r;if(typeof e.type=="function"){for(n=e.__k,r=0;n&&r<n.length;r++)n[r]&&(n[r].__=e,t=rt(n[r],t,i));return t}e.__e!=t&&(i.insertBefore(e.__e,t||null),t=e.__e);do t=t&&t.nextSibling;while(t!=null&&t.nodeType===8);return t}function Wt(e,t,i,n){var r=e.key,o=e.type,u=i-1,a=i+1,f=t[i];if(f===null||f&&r==f.key&&o===f.type&&!(131072&f.__u))return i;if(n>(f!=null&&!(131072&f.__u)?1:0))for(;u>=0||a<t.length;){if(u>=0){if((f=t[u])&&!(131072&f.__u)&&r==f.key&&o===f.type)return u;u--}if(a<t.length){if((f=t[a])&&!(131072&f.__u)&&r==f.key&&o===f.type)return a;a++}}return-1}function ot(e,t,i){t[0]==="-"?e.setProperty(t,i??""):e[t]=i==null?"":typeof i!="number"||Mt.test(t)?i:i+"px"}function fe(e,t,i,n,r){var o;e:if(t==="style")if(typeof i=="string")e.style.cssText=i;else{if(typeof n=="string"&&(e.style.cssText=n=""),n)for(t in n)i&&t in i||ot(e.style,t,"");if(i)for(t in i)n&&i[t]===n[t]||ot(e.style,t,i[t])}else if(t[0]==="o"&&t[1]==="n")o=t!==(t=t.replace(/(PointerCapture)$|Capture$/i,"$1")),t=t.toLowerCase()in e||t==="onFocusOut"||t==="onFocusIn"?t.toLowerCase().slice(2):t.slice(2),e.l||(e.l={}),e.l[t+o]=i,i?n?i.u=n.u:(i.u=$e,e.addEventListener(t,o?we:xe,o)):e.removeEventListener(t,o?we:xe,o);else{if(r=="http://www.w3.org/2000/svg")t=t.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(t!="width"&&t!="height"&&t!="href"&&t!="list"&&t!="form"&&t!="tabIndex"&&t!="download"&&t!="rowSpan"&&t!="colSpan"&&t!="role"&&t in e)try{e[t]=i??"";break e}catch{}typeof i=="function"||(i==null||i===!1&&t[4]!=="-"?e.removeAttribute(t):e.setAttribute(t,i))}}function st(e){return function(t){if(this.l){var i=this.l[t.type+e];if(t.t==null)t.t=$e++;else if(t.t<i.u)return;return i(g.event?g.event(t):t)}}}function Ce(e,t,i,n,r,o,u,a,f,l){var c,s,h,_,p,y,v,m,E,I,H,N,W,j,Je,D=t.type;if(t.constructor!==void 0)return null;128&i.__u&&(f=!!(32&i.__u),o=[a=t.__e=i.__e]),(c=g.__b)&&c(t);e:if(typeof D=="function")try{if(m=t.props,E=(c=D.contextType)&&n[c.__c],I=c?E?E.props.value:c.__:n,i.__c?v=(s=t.__c=i.__c).__=s.__E:("prototype"in D&&D.prototype.render?t.__c=s=new D(m,I):(t.__c=s=new ie(m,I),s.constructor=D,s.render=Jt),E&&E.sub(s),s.props=m,s.state||(s.state={}),s.context=I,s.__n=n,h=s.__d=!0,s.__h=[],s._sb=[]),s.__s==null&&(s.__s=s.state),D.getDerivedStateFromProps!=null&&(s.__s==s.state&&(s.__s=L({},s.__s)),L(s.__s,D.getDerivedStateFromProps(m,s.__s))),_=s.props,p=s.state,s.__v=t,h)D.getDerivedStateFromProps==null&&s.componentWillMount!=null&&s.componentWillMount(),s.componentDidMount!=null&&s.__h.push(s.componentDidMount);else{if(D.getDerivedStateFromProps==null&&m!==_&&s.componentWillReceiveProps!=null&&s.componentWillReceiveProps(m,I),!s.__e&&(s.shouldComponentUpdate!=null&&s.shouldComponentUpdate(m,s.__s,I)===!1||t.__v===i.__v)){for(t.__v!==i.__v&&(s.props=m,s.state=s.__s,s.__d=!1),t.__e=i.__e,t.__k=i.__k,t.__k.forEach(function(Ee){Ee&&(Ee.__=t)}),H=0;H<s._sb.length;H++)s.__h.push(s._sb[H]);s._sb=[],s.__h.length&&u.push(s);break e}s.componentWillUpdate!=null&&s.componentWillUpdate(m,s.__s,I),s.componentDidUpdate!=null&&s.__h.push(function(){s.componentDidUpdate(_,p,y)})}if(s.context=I,s.props=m,s.__P=e,s.__e=!1,N=g.__r,W=0,"prototype"in D&&D.prototype.render){for(s.state=s.__s,s.__d=!1,N&&N(t),c=s.render(s.props,s.state,s.context),j=0;j<s._sb.length;j++)s.__h.push(s._sb[j]);s._sb=[]}else do s.__d=!1,N&&N(t),c=s.render(s.props,s.state,s.context),s.state=s.__s;while(s.__d&&++W<25);s.state=s.__s,s.getChildContext!=null&&(n=L(L({},n),s.getChildContext())),h||s.getSnapshotBeforeUpdate==null||(y=s.getSnapshotBeforeUpdate(_,p)),nt(e,Ae(Je=c!=null&&c.type===K&&c.key==null?c.props.children:c)?Je:[Je],t,i,n,r,o,u,a,f,l),s.base=t.__e,t.__u&=-161,s.__h.length&&u.push(s),v&&(s.__E=s.__=null)}catch(Ee){t.__v=null,f||o!=null?(t.__e=a,t.__u|=f?160:32,o[o.indexOf(a)]=null):(t.__e=i.__e,t.__k=i.__k),g.__e(Ee,t,i)}else o==null&&t.__v===i.__v?(t.__k=i.__k,t.__e=i.__e):t.__e=Bt(i.__e,t,i,n,r,o,u,f,l);(c=g.diffed)&&c(t)}function ut(e,t,i){t.__d=void 0;for(var n=0;n<i.length;n++)De(i[n],i[++n],i[++n]);g.__c&&g.__c(t,e),e.some(function(r){try{e=r.__h,r.__h=[],e.some(function(o){o.call(r)})}catch(o){g.__e(o,r.__v)}})}function Bt(e,t,i,n,r,o,u,a,f){var l,c,s,h,_,p,y,v=i.props,m=t.props,E=t.type;if(E==="svg"?r="http://www.w3.org/2000/svg":E==="math"?r="http://www.w3.org/1998/Math/MathML":r||(r="http://www.w3.org/1999/xhtml"),o!=null){for(l=0;l<o.length;l++)if((_=o[l])&&"setAttribute"in _==!!E&&(E?_.localName===E:_.nodeType===3)){e=_,o[l]=null;break}}if(e==null){if(E===null)return document.createTextNode(m);e=document.createElementNS(r,E,m.is&&m),o=null,a=!1}if(E===null)v===m||a&&e.data===m||(e.data=m);else{if(o=o&&ae.call(e.childNodes),v=i.props||te,!a&&o!=null)for(v={},l=0;l<e.attributes.length;l++)v[(_=e.attributes[l]).name]=_.value;for(l in v)if(_=v[l],l!="children"){if(l=="dangerouslySetInnerHTML")s=_;else if(l!=="key"&&!(l in m)){if(l=="value"&&"defaultValue"in m||l=="checked"&&"defaultChecked"in m)continue;fe(e,l,null,_,r)}}for(l in m)_=m[l],l=="children"?h=_:l=="dangerouslySetInnerHTML"?c=_:l=="value"?p=_:l=="checked"?y=_:l==="key"||a&&typeof _!="function"||v[l]===_||fe(e,l,_,v[l],r);if(c)a||s&&(c.__html===s.__html||c.__html===e.innerHTML)||(e.innerHTML=c.__html),t.__k=[];else if(s&&(e.innerHTML=""),nt(e,Ae(h)?h:[h],t,i,n,E==="foreignObject"?"http://www.w3.org/1999/xhtml":r,o,u,o?o[0]:i.__k&&J(i,0),a,f),o!=null)for(l=o.length;l--;)o[l]!=null&&tt(o[l]);a||(l="value",p!==void 0&&(p!==e[l]||E==="progress"&&!p||E==="option"&&p!==v[l])&&fe(e,l,p,v[l],r),l="checked",y!==void 0&&y!==e[l]&&fe(e,l,y,v[l],r))}return e}function De(e,t,i){try{typeof e=="function"?e(t):e.current=t}catch(n){g.__e(n,i)}}function qe(e,t,i){var n,r;if(g.unmount&&g.unmount(e),(n=e.ref)&&(n.current&&n.current!==e.__e||De(n,null,t)),(n=e.__c)!=null){if(n.componentWillUnmount)try{n.componentWillUnmount()}catch(o){g.__e(o,t)}n.base=n.__P=null}if(n=e.__k)for(r=0;r<n.length;r++)n[r]&&qe(n[r],t,i||typeof e.type!="function");i||e.__e==null||tt(e.__e),e.__c=e.__=e.__e=e.__d=void 0}function Jt(e,t,i){return this.constructor(e,i)}function at(e,t,i){var n,r,o,u;g.__&&g.__(e,t),r=(n=typeof i=="function")?null:i&&i.__k||t.__k,o=[],u=[],Ce(t,e=(!n&&i||t).__k=Vt(K,null,[e]),r||te,te,t.namespaceURI,!n&&i?[i]:r?null:t.firstChild?ae.call(t.childNodes):null,o,!n&&i?i:r?r.__e:t.firstChild,n,u),ut(o,e,u)}function Yt(e,t){var i={__c:t="__cC"+Xe++,__:e,Consumer:function(n,r){return n.children(r)},Provider:function(n){var r,o;return this.getChildContext||(r=[],(o={})[t]=this,this.getChildContext=function(){return o},this.shouldComponentUpdate=function(u){this.props.value!==u.value&&r.some(function(a){a.__e=!0,Fe(a)})},this.sub=function(u){r.push(u);var a=u.componentWillUnmount;u.componentWillUnmount=function(){r.splice(r.indexOf(u),1),a&&a.call(u)}}),n.children}};return i.Provider.__=i.Consumer.contextType=i}ae=et.slice,g={__e:function(e,t,i,n){for(var r,o,u;t=t.__;)if((r=t.__c)&&!r.__)try{if((o=r.constructor)&&o.getDerivedStateFromError!=null&&(r.setState(o.getDerivedStateFromError(e)),u=r.__d),r.componentDidCatch!=null&&(r.componentDidCatch(e,n||{}),u=r.__d),u)return r.__E=r}catch(a){e=a}throw e}},Ye=0,Ze=function(e){return e!=null&&e.constructor==null},ie.prototype.setState=function(e,t){var i;i=this.__s!=null&&this.__s!==this.state?this.__s:this.__s=L({},this.state),typeof e=="function"&&(e=e(L({},i),this.props)),e&&L(i,e),e!=null&&this.__v&&(t&&this._sb.push(t),Fe(this))},ie.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),Fe(this))},ie.prototype.render=K,B=[],Qe=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,Pe=function(e,t){return e.__v.__b-t.__v.__b},ce.__r=0,$e=0,xe=st(!1),we=st(!0),Xe=0;function P(e,t,i){if(!e)throw new Error(t,{cause:i})}async function Zt(e,t,i){const n=await fetch(`https://api.gigs.com/projects/${i.project}/portings/${e}`,{method:"PATCH",headers:{authorization:`Bearer ${i.token}`,"content-type":"application/json",accept:"application/json"},body:JSON.stringify(t)}),r=await n.json().catch(()=>n.text());return P(n.status!==404,"PRT_NOT_FOUND: Porting could not be found."),P(n.ok,`FETCH_FAILED: ${(r==null?void 0:r.message)||(r==null?void 0:r.toString())}`),r}async function Kt(e,t){const i=await fetch(`https://api.gigs.com/projects/${t.project}/subscriptions/${e}`,{headers:{authorization:`Bearer ${t.token}`}}),n=await i.json().catch(()=>i.text());return P(i.status!==404,"SUB_NOT_FOUND: Subscription could not be fetched."),P(i.ok,`FETCH_FAILED: ${(n==null?void 0:n.message)||(n==null?void 0:n.toString())}`),n}async function Qt(e,t){var u;const{connectSession:i,token:n}=Xt(e,t),r=await fetch("https://connect.gigs.com/api/embeds/auth",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({secret:n})}),o=await r.json().catch(async()=>({error:await r.text()}));return P(r.status!==422,"INVALID_SESSION: Session is expired."),P(r.ok,`FETCH_FAILED: ${o.error}`),P((u=o.token)==null?void 0:u.access_token,"Expected user token to be returned in response of token exchange, but was not found."),{connectSession:i,token:o.token.access_token}}function Xt(e,t){P(e&&typeof e=="object"&&"object"in e&&"intent"in e&&"url"in e&&e.object==="connectSession","INVALID_SESSION: The object you passed in is not a ConnectSession resoure. Make sure to pass in the complete resource.");const i=e;P(i.intent.type===t,`INVALID_SESSION: PortingEmbed must be initialized with the "${t}" intent, but got "${i.intent.type}" instead.`),P(i.url,"INVALID_SESSION: Session has no URL. Did you pass in the created session?");const r=new URL(i.url).searchParams.get("token");return P(r,"INVALID_SESSION: Session has no token. Is it an authenticated session?"),{connectSession:i,token:r}}var ne,x,Ie,lt,Oe=0,ct=[],de=[],S=g,ft=S.__b,dt=S.__r,_t=S.diffed,vt=S.__c,pt=S.unmount,ht=S.__;function Te(e,t){S.__h&&S.__h(x,e,Oe||t),Oe=0;var i=x.__H||(x.__H={__:[],__h:[]});return e>=i.__.length&&i.__.push({__V:de}),i.__[e]}function Ue(e,t){var i=Te(ne++,3);!S.__s&&bt(i.__H,t)&&(i.__=e,i.i=t,x.__H.__h.push(i))}function mt(e){return Oe=5,q(function(){return{current:e}},[])}function q(e,t){var i=Te(ne++,7);return bt(i.__H,t)?(i.__V=e(),i.i=t,i.__h=e,i.__V):i.__}function ei(e){var t=x.context[e.__c],i=Te(ne++,9);return i.c=e,t?(i.__==null&&(i.__=!0,t.sub(x)),t.props.value):e.__}function ti(){for(var e;e=ct.shift();)if(e.__P&&e.__H)try{e.__H.__h.forEach(_e),e.__H.__h.forEach(Ge),e.__H.__h=[]}catch(t){e.__H.__h=[],S.__e(t,e.__v)}}S.__b=function(e){x=null,ft&&ft(e)},S.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),ht&&ht(e,t)},S.__r=function(e){dt&&dt(e),ne=0;var t=(x=e.__c).__H;t&&(Ie===x?(t.__h=[],x.__h=[],t.__.forEach(function(i){i.__N&&(i.__=i.__N),i.__V=de,i.__N=i.i=void 0})):(t.__h.forEach(_e),t.__h.forEach(Ge),t.__h=[],ne=0)),Ie=x},S.diffed=function(e){_t&&_t(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(ct.push(t)!==1&<===S.requestAnimationFrame||((lt=S.requestAnimationFrame)||ii)(ti)),t.__H.__.forEach(function(i){i.i&&(i.__H=i.i),i.__V!==de&&(i.__=i.__V),i.i=void 0,i.__V=de})),Ie=x=null},S.__c=function(e,t){t.some(function(i){try{i.__h.forEach(_e),i.__h=i.__h.filter(function(n){return!n.__||Ge(n)})}catch(n){t.some(function(r){r.__h&&(r.__h=[])}),t=[],S.__e(n,i.__v)}}),vt&&vt(e,t)},S.unmount=function(e){pt&&pt(e);var t,i=e.__c;i&&i.__H&&(i.__H.__.forEach(function(n){try{_e(n)}catch(r){t=r}}),i.__H=void 0,t&&S.__e(t,i.__v))};var yt=typeof requestAnimationFrame=="function";function ii(e){var t,i=function(){clearTimeout(n),yt&&cancelAnimationFrame(t),setTimeout(e)},n=setTimeout(i,100);yt&&(t=requestAnimationFrame(i))}function _e(e){var t=x,i=e.__c;typeof i=="function"&&(e.__c=void 0,i()),x=t}function Ge(e){var t=x;e.__c=e.__(),x=t}function bt(e,t){return!e||e.length!==t.length||t.some(function(i,n){return i!==e[n]})}const ve="gigsPortingEmbedForm",ni={"field.accountNumber.label":"Account Number","field.accountNumber.error.required":"The account number is required","field.accountPin.label":"Account PIN","field.accountPin.error.required":"The account pin is required","field.accountPin.error.cleared":"The new account pin is empty. If you do not want to change the account pin, clear the input.","field.firstName.label":"First Name","field.firstName.error.required":"Your first name is required","field.lastName.label":"Last Name","field.lastName.error.required":"Your last name is required","field.birthday.label":"Birthday","field.birthday.error.required":"Your birthday is required","field.line1.label":"Line 1","field.line1.error.required":"Line 1 is required","field.line2.label":"Line 2","field.city.label":"City","field.city.error.required":"City is required","field.postalCode.label":"Postal Code","field.postalCode.error.required":"Postal Code is required","field.state.label":"State (ISO code)","field.state.error.format":"Must be an ISO state code","field.country.label":"Country (2 letter code)","field.country.error.required":"Country is required","field.country.error.format":"Must be an ISO country code","field.donorProviderApproval.label":"I have notified my current provider of the number porting and got the approval that the number can be ported","field.donorProviderApproval.error.required":"You must get the approval of your current provider"},gt=Yt({});function z(){const e=ei(gt);return{...e,text:{...ni,...e.text}}}var ri=Symbol.for("preact-signals");function pe(){if(M>1)M--;else{for(var e,t=!1;re!==void 0;){var i=re;for(re=void 0,He++;i!==void 0;){var n=i.o;if(i.o=void 0,i.f&=-3,!(8&i.f)&&Nt(i))try{i.c()}catch(r){t||(e=r,t=!0)}i=n}}if(He=0,M--,t)throw e}}function O(e){if(M>0)return e();M++;try{return e()}finally{pe()}}var k=void 0,re=void 0,M=0,He=0,he=0;function kt(e){if(k!==void 0){var t=e.n;if(t===void 0||t.t!==k)return t={i:0,S:e,p:k.s,n:void 0,t:k,e:void 0,x:void 0,r:t},k.s!==void 0&&(k.s.n=t),k.s=t,e.n=t,32&k.f&&e.S(t),t;if(t.i===-1)return t.i=0,t.n!==void 0&&(t.n.p=t.p,t.p!==void 0&&(t.p.n=t.n),t.p=k.s,t.n=void 0,k.s.n=t,k.s=t),t}}function $(e){this.v=e,this.i=0,this.n=void 0,this.t=void 0}$.prototype.brand=ri,$.prototype.h=function(){return!0},$.prototype.S=function(e){this.t!==e&&e.e===void 0&&(e.x=this.t,this.t!==void 0&&(this.t.e=e),this.t=e)},$.prototype.U=function(e){if(this.t!==void 0){var t=e.e,i=e.x;t!==void 0&&(t.x=i,e.e=void 0),i!==void 0&&(i.e=t,e.x=void 0),e===this.t&&(this.t=i)}},$.prototype.subscribe=function(e){var t=this;return se(function(){var i=t.value,n=k;k=void 0;try{e(i)}finally{k=n}})},$.prototype.valueOf=function(){return this.value},$.prototype.toString=function(){return this.value+""},$.prototype.toJSON=function(){return this.value},$.prototype.peek=function(){var e=k;k=void 0;try{return this.value}finally{k=e}},Object.defineProperty($.prototype,"value",{get:function(){var e=kt(this);return e!==void 0&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(He>100)throw new Error("Cycle detected");this.v=e,this.i++,he++,M++;try{for(var t=this.t;t!==void 0;t=t.x)t.t.N()}finally{pe()}}}});function b(e){return new $(e)}function Nt(e){for(var t=e.s;t!==void 0;t=t.n)if(t.S.i!==t.i||!t.S.h()||t.S.i!==t.i)return!0;return!1}function St(e){for(var t=e.s;t!==void 0;t=t.n){var i=t.S.n;if(i!==void 0&&(t.r=i),t.S.n=t,t.i=-1,t.n===void 0){e.s=t;break}}}function Et(e){for(var t=e.s,i=void 0;t!==void 0;){var n=t.p;t.i===-1?(t.S.U(t),n!==void 0&&(n.n=t.n),t.n!==void 0&&(t.n.p=n)):i=t,t.S.n=t.r,t.r!==void 0&&(t.r=void 0),t=n}e.s=i}function Q(e){$.call(this,void 0),this.x=e,this.s=void 0,this.g=he-1,this.f=4}(Q.prototype=new $).h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===he))return!0;if(this.g=he,this.f|=1,this.i>0&&!Nt(this))return this.f&=-2,!0;var e=k;try{St(this),k=this;var t=this.x();(16&this.f||this.v!==t||this.i===0)&&(this.v=t,this.f&=-17,this.i++)}catch(i){this.v=i,this.f|=16,this.i++}return k=e,Et(this),this.f&=-2,!0},Q.prototype.S=function(e){if(this.t===void 0){this.f|=36;for(var t=this.s;t!==void 0;t=t.n)t.S.S(t)}$.prototype.S.call(this,e)},Q.prototype.U=function(e){if(this.t!==void 0&&($.prototype.U.call(this,e),this.t===void 0)){this.f&=-33;for(var t=this.s;t!==void 0;t=t.n)t.S.U(t)}},Q.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var e=this.t;e!==void 0;e=e.x)e.t.N()}},Object.defineProperty(Q.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var e=kt(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v}});function Pt(e){return new Q(e)}function $t(e){var t=e.u;if(e.u=void 0,typeof t=="function"){M++;var i=k;k=void 0;try{t()}catch(n){throw e.f&=-2,e.f|=8,je(e),n}finally{k=i,pe()}}}function je(e){for(var t=e.s;t!==void 0;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,$t(e)}function oi(e){if(k!==this)throw new Error("Out-of-order effect");Et(this),k=e,this.f&=-2,8&this.f&&je(this),pe()}function oe(e){this.x=e,this.u=void 0,this.s=void 0,this.o=void 0,this.f=32}oe.prototype.c=function(){var e=this.S();try{if(8&this.f||this.x===void 0)return;var t=this.x();typeof t=="function"&&(this.u=t)}finally{e()}},oe.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,$t(this),St(this),M++;var e=k;return k=this,oi.bind(this,e)},oe.prototype.N=function(){2&this.f||(this.f|=2,this.o=re,re=this)},oe.prototype.d=function(){this.f|=8,1&this.f||je(this)};function se(e){var t=new oe(e);try{t.c()}catch(i){throw t.d(),i}return t.d.bind(t)}var me,Le;function X(e,t){g[e]=t.bind(null,g[e]||function(){})}function ye(e){Le&&Le(),Le=e&&e.S()}function xt(e){var t=this,i=e.data,n=wt(i);n.value=i;var r=q(function(){for(var o=t.__v;o=o.__;)if(o.__c){o.__c.__$f|=4;break}return t.__$u.c=function(){var u;!Ze(r.peek())&&((u=t.base)==null?void 0:u.nodeType)===3?t.base.data=r.peek():(t.__$f|=1,t.setState({}))},Pt(function(){var u=n.value.value;return u===0?0:u===!0?"":u||""})},[]);return r.value}xt.displayName="_st",Object.defineProperties($.prototype,{constructor:{configurable:!0,value:void 0},type:{configurable:!0,value:xt},props:{configurable:!0,get:function(){return{data:this}}},__b:{configurable:!0,value:1}}),X("__b",function(e,t){if(typeof t.type=="string"){var i,n=t.props;for(var r in n)if(r!=="children"){var o=n[r];o instanceof $&&(i||(t.__np=i={}),i[r]=o,n[r]=o.peek())}}e(t)}),X("__r",function(e,t){ye();var i,n=t.__c;n&&(n.__$f&=-2,(i=n.__$u)===void 0&&(n.__$u=i=function(r){var o;return se(function(){o=this}),o.c=function(){n.__$f|=1,n.setState({})},o}())),me=n,ye(i),e(t)}),X("__e",function(e,t,i,n){ye(),me=void 0,e(t,i,n)}),X("diffed",function(e,t){ye(),me=void 0;var i;if(typeof t.type=="string"&&(i=t.__e)){var n=t.__np,r=t.props;if(n){var o=i.U;if(o)for(var u in o){var a=o[u];a!==void 0&&!(u in n)&&(a.d(),o[u]=void 0)}else i.U=o={};for(var f in n){var l=o[f],c=n[f];l===void 0?(l=si(i,f,c,r),o[f]=l):l.o(c,r)}}}e(t)});function si(e,t,i,n){var r=t in e&&e.ownerSVGElement===void 0,o=b(i);return{o:function(u,a){o.value=u,n=a},d:se(function(){var u=o.value.value;n[t]!==u&&(n[t]=u,r?e[t]=u:u?e.setAttribute(t,u):e.removeAttribute(t))})}}X("unmount",function(e,t){if(typeof t.type=="string"){var i=t.__e;if(i){var n=i.U;if(n){i.U=void 0;for(var r in n){var o=n[r];o&&o.d()}}}}else{var u=t.__c;if(u){var a=u.__$u;a&&(u.__$u=void 0,a.d())}}e(t)}),X("__h",function(e,t,i,n){(n<3||n===9)&&(t.__$f|=2),e(t,i,n)}),ie.prototype.shouldComponentUpdate=function(e,t){var i=this.__$u;if(!(i&&i.s!==void 0||4&this.__$f)||3&this.__$f)return!0;for(var n in t)return!0;for(var r in e)if(r!=="__source"&&e[r]!==this.props[r])return!0;for(var o in this.props)if(!(o in e))return!0;return!1};function wt(e){return q(function(){return b(e)},[])}function ui(e){var t=mt(e);return t.current=e,me.__$f|=4,q(function(){return Pt(function(){return t.current()})},[])}function be(e){var t=mt(e);t.current=e,Ue(function(){return se(function(){return t.current()})},[])}var ai=0;function d(e,t,i,n,r,o){t||(t={});var u,a,f=t;if("ref"in f)for(a in f={},t)a=="ref"?u=t[a]:f[a]=t[a];var l={type:e,props:f,key:i,ref:u,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,constructor:void 0,__v:--ai,__i:-1,__u:0,__source:r,__self:o};if(typeof e=="function"&&(u=e.defaultProps))for(a in u)f[a]===void 0&&(f[a]=u[a]);return g.vnode&&g.vnode(l),l}var li=Object.defineProperty,ci=(e,t,i)=>t in e?li(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,At=(e,t,i)=>(ci(e,typeof t!="symbol"?t+"":t,i),i);function fi({initialValues:e={},validateOn:t="submit",revalidateOn:i="input",validate:n}={}){return q(()=>({internal:{initialValues:e,validate:n,validateOn:t,revalidateOn:i,fieldNames:b([]),fieldArrayNames:b([]),fields:{},fieldArrays:{},validators:new Set},element:b(null),submitCount:b(0),submitting:b(!1),submitted:b(!1),validating:b(!1),touched:b(!1),dirty:b(!1),invalid:b(!1),response:b({})}),[])}function ge(e){const t=fi(e);return q(()=>[t,{Form:i=>$i({...i,of:t}),Field:i=>Ei({...i,of:t}),FieldArray:i=>Pi({...i,of:t})}],[t])}function Ft(e,t,i){const{checked:n,files:r,options:o,value:u,valueAsDate:a,valueAsNumber:f}=e;return!i||i==="string"?u:i==="string[]"?o?[...o].filter(l=>l.selected&&!l.disabled).map(l=>l.value):n?[...t.value.peek()||[],u]:(t.value.peek()||[]).filter(l=>l!==u):i==="number"?f:i==="boolean"?n:i==="File"&&r?r[0]:i==="File[]"&&r?[...r]:i==="Date"&&a?a:t.value.peek()}function ze(e){return[...Object.values(e.internal.fields),...Object.values(e.internal.fieldArrays)]}function V(e,t){return e.internal.fieldArrays[t]}function di(e,t){return+t.replace(`${e}.`,"").split(".")[0]}function Ct(e,t){Dt(e,!1).forEach(i=>{const n=V(e,i).items.peek().length-1;t.filter(r=>r.startsWith(`${i}.`)&&di(i,r)>n).forEach(r=>{t.splice(t.indexOf(r),1)})})}function Dt(e,t=!0){const i=[...e.internal.fieldArrayNames.peek()];return t&&Ct(e,i),i}function _i(e,t=!0){const i=[...e.internal.fieldNames.peek()];return t&&Ct(e,i),i}function R(e,t){return e.internal.fields[t]}function Me(e,t,i){const n=_i(e,i),r=Dt(e,i);return typeof t=="string"||Array.isArray(t)?(typeof t=="string"?[t]:t).reduce((o,u)=>{const[a,f]=o;return r.includes(u)?(r.forEach(l=>{l.startsWith(u)&&f.add(l)}),n.forEach(l=>{l.startsWith(u)&&a.add(l)})):a.add(u),o},[new Set,new Set]).map(o=>[...o]):[n,r]}function Ve(e,t){return(typeof e!="string"&&!Array.isArray(e)?e:t)||{}}function ke(e,t){return e.split(".").reduce((i,n)=>i==null?void 0:i[n],t)}let vi=0;function Ne(){return vi++}function pi(e,t){const i=n=>n instanceof Blob?n.size:n;return Array.isArray(e)&&Array.isArray(t)?e.map(i).join()!==t.map(i).join():e instanceof Date&&t instanceof Date?e.getTime()!==t.getTime():Number.isNaN(e)&&Number.isNaN(t)?!1:e!==t}function hi(e,t){e.dirty.value=t||ze(e).some(i=>i.active.peek()&&i.dirty.peek())}function mi(e,t){const i=pi(t.startValue.peek(),t.value.peek());i!==t.dirty.peek()&&O(()=>{t.dirty.value=i,hi(e,i)})}function yi(e,t,i,{on:n,shouldFocus:r=!1}){n.includes((e.internal.validateOn==="submit"?e.submitted.peek():t.error.peek())?e.internal.revalidateOn:e.internal.validateOn)&&Ut(e,i,{shouldFocus:r})}function Re(e,t,i,n,r,o){O(()=>{t.value.value=t.transform.reduce((u,a)=>a(u,n),o??t.value.value),t.touched.value=!0,e.touched.value=!0,mi(e,t),yi(e,t,i,{on:r})})}function bi(e,t){var i;if(!V(e,t)){const n=((i=ke(t,e.internal.initialValues))==null?void 0:i.map(()=>Ne()))||[];e.internal.fieldArrays[t]={initialItems:b(n),startItems:b(n),items:b(n),error:b(""),active:b(!1),touched:b(!1),dirty:b(!1),validate:[],consumers:new Set},e.internal.fieldArrayNames.value=[...e.internal.fieldArrayNames.peek(),t]}return V(e,t)}function gi(e,t){if(!R(e,t)){const i=ke(t,e.internal.initialValues);e.internal.fields[t]={elements:b([]),initialValue:b(i),startValue:b(i),value:b(i),error:b(""),active:b(!1),touched:b(!1),dirty:b(!1),validate:[],transform:[],consumers:new Set},e.internal.fieldNames.value=[...e.internal.fieldNames.peek(),t]}return R(e,t)}function ue(e,t){return t?e.peek():e.value}function ki(e,t,{shouldActive:i=!0}){const n=Object.entries(t).reduce((r,[o,u])=>([R(e,o),V(e,o)].every(a=>!a||i&&!a.active.peek())&&r.push(u),r),[]).join(" ");n&&(e.response.value={status:"error",message:n})}function qt(e,t){e.invalid.value=t||ze(e).some(i=>i.active.peek()&&i.error.peek())}function We(e){let t=!1,i=!1,n=!1;for(const r of ze(e))if(r.active.peek()&&(r.touched.peek()&&(t=!0),r.dirty.peek()&&(i=!0),r.error.peek()&&(n=!0)),t&&i&&n)break;O(()=>{e.touched.value=t,e.dirty.value=i,e.invalid.value=n})}function It(e,t){var i,n;(n=(i=R(e,t))==null?void 0:i.elements.peek()[0])==null||n.focus()}function Ot(e,t,i,{shouldActive:n=!0,shouldTouched:r=!1,shouldDirty:o=!1,shouldFocus:u=!!i}={}){O(()=>{for(const a of[R(e,t),V(e,t)])a&&(!n||a.active.peek())&&(!r||a.touched.peek())&&(!o||a.dirty.peek())&&(a.error.value=i,i&&"value"in a&&u&&It(e,t));qt(e,!!i)})}function Tt(e,t,i){const[n,r]=Me(e,t),{shouldActive:o=!0,shouldTouched:u=!1,shouldDirty:a=!1,shouldValid:f=!1,peek:l=!1}=Ve(t,i);return l||(typeof t!="string"&&!Array.isArray(t)?e.internal.fieldNames.value:r.forEach(c=>V(e,c).items.value)),n.reduce((c,s)=>{const h=R(e,s);return(!o||ue(h.active,l))&&(!u||ue(h.touched,l))&&(!a||ue(h.dirty,l))&&(!f||!ue(h.error,l))&&(typeof t=="string"?s.replace(`${t}.`,""):s).split(".").reduce((_,p,y,v)=>_[p]=y===v.length-1?ue(h.value,l):typeof _[p]=="object"&&_[p]||(isNaN(+v[y+1])?{}:[]),c),c},typeof t=="string"?[]:{})}function Ni(e,t,i){const[n,r]=Me(e,t,!1),o=typeof t=="string"&&n.length===1,u=!o&&!Array.isArray(t),a=Ve(t,i),{initialValue:f,initialValues:l,keepResponse:c=!1,keepSubmitCount:s=!1,keepSubmitted:h=!1,keepValues:_=!1,keepDirtyValues:p=!1,keepItems:y=!1,keepDirtyItems:v=!1,keepErrors:m=!1,keepTouched:E=!1,keepDirty:I=!1}=a;O(()=>{n.forEach(H=>{const N=R(e,H);(o?"initialValue"in a:l)&&(N.initialValue.value=o?f:ke(H,l));const W=p&&N.dirty.peek();!_&&!W&&(N.startValue.value=N.initialValue.peek(),N.value.value=N.initialValue.peek(),N.elements.peek().forEach(j=>{j.type==="file"&&(j.value="")})),E||(N.touched.value=!1),!I&&!_&&!W&&(N.dirty.value=!1),m||(N.error.value="")}),r.forEach(H=>{var j;const N=V(e,H),W=v&&N.dirty.peek();!y&&!W&&(l&&(N.initialItems.value=((j=ke(H,l))==null?void 0:j.map(()=>Ne()))||[]),N.startItems.value=[...N.initialItems.peek()],N.items.value=[...N.initialItems.peek()]),E||(N.touched.value=!1),!I&&!y&&!W&&(N.dirty.value=!1),m||(N.error.value="")}),u&&(c||(e.response.value={}),s||(e.submitCount.value=0),h||(e.submitted.value=!1)),We(e)})}function Si(e,t,{duration:i}={}){e.response.value=t,i&&setTimeout(()=>{e.response.peek()===t&&(e.response.value={})},i)}async function Ut(e,t,i){const[n,r]=Me(e,t),{shouldActive:o=!0,shouldFocus:u=!0}=Ve(t,i),a=Ne();e.internal.validators.add(a),e.validating.value=!0;const f=e.internal.validate?await e.internal.validate(Tt(e,{shouldActive:o,peek:!0})):{};let l=typeof t!="string"&&!Array.isArray(t)?!Object.keys(f).length:!0;const[c]=await Promise.all([Promise.all(n.map(async s=>{const h=R(e,s);if(!o||h.active.peek()){let _;for(const y of h.validate)if(_=await y(h.value.peek()),_)break;const p=_||f[s]||"";return p&&(l=!1),h.error.value=p,p?s:null}})),Promise.all(r.map(async s=>{const h=V(e,s);if(!o||h.active.peek()){let _="";for(const y of h.validate)if(_=await y(h.items.peek()),_)break;const p=_||f[s]||"";p&&(l=!1),h.error.value=p}}))]);return O(()=>{if(ki(e,f,{shouldActive:o}),u){const s=c.find(h=>h);s&&It(e,s)}qt(e,!l),e.internal.validators.delete(a),e.internal.validators.size||(e.validating.value=!1)}),l}function Gt({of:e,name:t,store:i,validate:n,transform:r,keepActive:o=!1,keepState:u=!0}){Ue(()=>{i.validate=n?Array.isArray(n)?n:[n]:[],"transform"in i&&(i.transform=r?Array.isArray(r)?r:[r]:[])},[i,r,n]),Ue(()=>{const a=Ne();return i.consumers.add(a),i.active.peek()||O(()=>{i.active.value=!0,We(e)}),()=>{setTimeout(()=>{i.consumers.delete(a),O(()=>{!o&&!i.consumers.size&&(i.active.value=!1,u?We(e):Ni(e,t))}),"elements"in i&&(i.elements.value=i.elements.peek().filter(f=>f.isConnected))})}},[e,t,i,o,u])}function T(e){const t=wt(e);return t.peek()!==e&&(t.value=e),ui(()=>t.value.value)}function Ei({children:e,type:t,...i}){const{of:n,name:r}=i,o=q(()=>gi(n,r),[n,r]);Gt({...i,store:o});const u=T(o.value),a=T(o.error),f=T(o.active),l=T(o.touched),c=T(o.dirty);return d(K,{children:e(q(()=>({name:r,value:u,error:a,active:f,touched:l,dirty:c}),[r]),q(()=>({name:r,ref(s){s&&(o.elements.value=[...o.elements.value,s],se(()=>{if(s.type!=="radio"&&o.startValue.value===void 0&&o.value.peek()===void 0){const h=Ft(s,o,t);o.startValue.value=h,o.value.value=h}}))},onInput(s){Re(n,o,r,s,["touched","input"],Ft(s.currentTarget,o,t))},onChange(s){Re(n,o,r,s,["change"])},onBlur(s){Re(n,o,r,s,["touched","blur"])}}),[o,n,r,t]))})}function Pi({children:e,...t}){const{of:i,name:n}=t,r=q(()=>bi(i,n),[i,n]);Gt({...t,store:r});const o=T(r.items),u=T(r.error),a=T(r.active),f=T(r.touched),l=T(r.dirty);return d(K,{children:e(q(()=>({name:n,items:o,error:u,active:a,touched:f,dirty:l}),[n]))})}class Ht extends Error{constructor(t,i){super(typeof t=="string"?t:""),At(this,"name","FormError"),At(this,"errors"),this.errors=typeof t=="string"?i||{}:t}}function $i({of:e,onSubmit:t,responseDuration:i,keepResponse:n,shouldActive:r,shouldTouched:o,shouldDirty:u,shouldFocus:a,...f}){return d("form",{noValidate:!0,...f,ref:l=>e.element.value=l,onSubmit:async l=>{l.preventDefault(),O(()=>{n||(e.response.value={}),e.submitCount.value++,e.submitted.value=!0,e.submitting.value=!0});const c={duration:i,shouldActive:r,shouldTouched:o,shouldDirty:u,shouldFocus:a};try{await Ut(e,c)&&await t(Tt(e,c),l)}catch(s){O(()=>{s instanceof Ht&&Object.entries(s.errors).forEach(([h,_])=>{_&&Ot(e,h,_,{...c,shouldFocus:!1})}),(!(s instanceof Ht)||s.message)&&Si(e,{status:"error",message:(s==null?void 0:s.message)||"An unknown error has occurred."},c)})}finally{e.submitting.value=!1}}})}function jt(e,{on:t}){return(i,n)=>n.type===t?e(i,n):i}function U(e){return jt(t=>t&&t.trim(),e)}function Lt(e){return jt(t=>t&&t.toUpperCase(),e)}function zt(e,t){return i=>i&&!e.test(i)?t:""}function G(e){return t=>!t&&t!==0||Array.isArray(t)&&!t.length?e:""}function w({children:e,of:t}){var r,o;const n=((o=(r=z().className)==null?void 0:r.field)==null?void 0:o.call(r,{name:t.name,touched:t.touched.value,dirty:t.dirty.value,valid:!t.error.value}))||"";return d("div",{className:`GigsEmbeds GigsPortingEmbed GigsEmbeds-field ${n}`,children:e})}function A({of:e}){var r,o;const i=((o=(r=z().className)==null?void 0:r.error)==null?void 0:o.call(r,{name:e.name,touched:e.touched.value,dirty:e.dirty.value}))||"",n=e.error.value;return n?d("div",{className:`GigsEmbeds GigsPortingEmbed GigsEmbeds-error ${i}`,children:n}):null}function F({of:e,...t}){var o,u;const n=((u=(o=z().className)==null?void 0:o.input)==null?void 0:u.call(o,{name:e.name,touched:e.touched.value,dirty:e.dirty.value,valid:!e.error.value}))||"",r=`__ge_${e.name}`;return d("input",{className:`GigsEmbeds GigsPortingEmbed GigsEmbeds-input ${n}`,id:r,...t})}function C({of:e,...t}){var o,u;const n=((u=(o=z().className)==null?void 0:o.label)==null?void 0:u.call(o,{name:e.name,touched:e.touched.value,dirty:e.dirty.value,valid:!e.error.value}))||"",r=`__ge_${e.name}`;return d("label",{htmlFor:r,className:`GigsEmbeds GigsPortingEmbed GigsEmbeds-label ${n}`,...t})}function xi({porting:e,onValidationChange:t,onSubmit:i}){var f,l,c,s,h,_,p,y;const n=z(),[r,{Form:o,Field:u}]=ge({initialValues:{line1:((f=e.address)==null?void 0:f.line1)??"",line2:((l=e.address)==null?void 0:l.line2)??null,city:((c=e.address)==null?void 0:c.city)??"",postalCode:((s=e.address)==null?void 0:s.postalCode)??"",state:(h=e.address)==null?void 0:h.state,country:((_=e.address)==null?void 0:_.country)??""},validateOn:"blur"}),a=((y=(p=n.className)==null?void 0:p.form)==null?void 0:y.call(p,{name:"address",dirty:r.dirty.value,valid:!r.invalid.value,submitting:r.submitting.value,touched:r.touched.value}))||"";return be(()=>{const v=!r.invalid.value;t==null||t({isValid:v})}),d(o,{id:n.formId||ve,role:"form",className:`GigsEmbeds GigsPortingEmbed GigsEmbeds-form ${a}`,onSubmit:v=>{const m={...v,line2:v.line2||null,state:v.state||null};return i(m)},children:[d(u,{name:"line1",validate:[G(n.text["field.line1.error.required"])],transform:U({on:"input"}),children:(v,m)=>d(w,{of:v,children:[d(C,{of:v,children:n.text["field.line1.label"]}),d(F,{...m,of:v,type:"text",value:v.value,required:!0}),d(A,{of:v})]})}),d(u,{name:"line2",transform:U({on:"input"}),children:(v,m)=>d(w,{of:v,children:[d(C,{of:v,children:n.text["field.line2.label"]}),d(F,{...m,of:v,type:"text",value:v.value.value||""}),d(A,{of:v})]})}),d(u,{name:"city",validate:[G(n.text["field.city.error.required"])],transform:U({on:"input"}),children:(v,m)=>d(w,{of:v,children:[d(C,{of:v,children:n.text["field.city.label"]}),d(F,{...m,of:v,type:"text",value:v.value,required:!0}),d(A,{of:v})]})}),d(u,{name:"postalCode",validate:[G(n.text["field.postalCode.error.required"])],transform:U({on:"input"}),children:(v,m)=>d(w,{of:v,children:[d(C,{of:v,children:n.text["field.postalCode.label"]}),d(F,{...m,of:v,type:"text",value:v.value,required:!0}),d(A,{of:v})]})}),d(u,{name:"state",validate:zt(/^[A-Z]{1,3}(-[A-Z0-9]{1,3})?$/,n.text["field.state.error.format"]),transform:[U({on:"input"}),Lt({on:"input"})],children:(v,m)=>d(w,{of:v,children:[d(C,{of:v,children:n.text["field.state.label"]}),d(F,{...m,of:v,type:"text",value:v.value.value||"",required:!0}),d(A,{of:v})]})}),d(u,{name:"country",validate:[G(n.text["field.country.error.required"]),zt(/^[A-Z]{2}$/,n.text["field.country.error.format"])],transform:[U({on:"input"}),Lt({on:"input"})],children:(v,m)=>d(w,{of:v,children:[d(C,{of:v,children:n.text["field.country.label"]}),d(F,{...m,of:v,type:"text",value:v.value.value||"",required:!0}),d(A,{of:v})]})})]})}function Be(e){return Object.fromEntries(Object.entries(e).filter(([i,n])=>n!==""&&n!==null&&n!==void 0))}const wi=(e,t)=>e&&(t==="Verizon"?e.replaceAll("-","").trim():e.trim());function Ai({porting:e,onValidationChange:t,onSubmit:i}){var f,l;const n=z(),[r,{Form:o,Field:u}]=ge({initialValues:{accountNumber:e.accountNumber??""},validateOn:"blur"}),a=((l=(f=n.className)==null?void 0:f.form)==null?void 0:l.call(f,{name:"carrierDetails",dirty:r.dirty.value,valid:!r.invalid.value,submitting:r.submitting.value,touched:r.touched.value}))||"";return be(()=>{const c=!r.invalid.value;t==null||t({isValid:c})}),d(o,{id:n.formId||ve,role:"form",className:`GigsEmbeds GigsPortingEmbed GigsEmbeds-form ${a}`,shouldDirty:!0,onSubmit:c=>{var _,p;const s=c.accountPin&&e.accountPinExists;if(s&&c.accountPin===""&&(c.accountPin=void 0),s&&c.accountPin!==""&&((_=c.accountPin)==null?void 0:_.trim())===""){Ot(r,"accountPin",n.text["field.accountPin.error.cleared"]);return}c.accountPin=wi(c.accountPin,(p=e.donorProvider)==null?void 0:p.name);const h=Be(c);return i(h)},children:[e.required.includes("accountNumber")&&d(u,{name:"accountNumber",validate:[G(n.text["field.accountNumber.error.required"])],transform:U({on:"input"}),children:(c,s)=>d(w,{of:c,children:[d(C,{of:c,children:n.text["field.accountNumber.label"]}),d(F,{...s,of:c,type:"text",value:c.value,required:!0}),d(A,{of:c})]})}),e.required.includes("accountPin")&&d(u,{name:"accountPin",validate:e.accountPinExists?[]:[G(n.text["field.accountPin.error.required"])],children:(c,s)=>d(w,{of:c,children:[d(C,{of:c,children:n.text["field.accountPin.label"]}),d(F,{...s,of:c,type:"text",placeholder:e.accountPinExists?"••••":void 0,value:c.value}),d(A,{of:c})]})})]})}function Fi({porting:e,onValidationChange:t,onSubmit:i}){var f,l;const n=z(),[r,{Form:o,Field:u}]=ge({initialValues:{donorProviderApproval:e.donorProviderApproval??!1},validateOn:"change"});be(()=>{const c=!r.invalid.value;t==null||t({isValid:c})});const a=((l=(f=n.className)==null?void 0:f.form)==null?void 0:l.call(f,{name:"donorProviderApproval",dirty:r.dirty.value,valid:!r.invalid.value,submitting:r.submitting.value,touched:r.touched.value}))||"";return d(o,{id:n.formId||ve,role:"form",className:`GigsEmbeds GigsPortingEmbed GigsEmbeds-form ${a}`,shouldActive:!1,onSubmit:async c=>{const s=Be(c);return i(s)},children:d(u,{name:"donorProviderApproval",type:"boolean",validate:[G(n.text["field.donorProviderApproval.error.required"])],children:(c,s)=>d(w,{of:c,children:[d("div",{className:"GigsEmbeds GigsPortingEmbed GigsEmbeds-checkbox",children:[d(F,{...s,of:c,type:"checkbox",checked:c.value}),d(C,{of:c,children:n.text["field.donorProviderApproval.label"]})]}),d(A,{of:c})]})})})}function Ci({porting:e,onValidationChange:t,onSubmit:i}){var f,l;const n=z(),[r,{Form:o,Field:u}]=ge({initialValues:{firstName:e.firstName??"",lastName:e.lastName??"",birthday:e.birthday??""},validateOn:"blur"});be(()=>{const c=!r.invalid.value;t==null||t({isValid:c})});const a=((l=(f=n.className)==null?void 0:f.form)==null?void 0:l.call(f,{name:"holderDetails",dirty:r.dirty.value,valid:!r.invalid.value,submitting:r.submitting.value,touched:r.touched.value}))||"";return d(o,{id:n.formId||ve,role:"form",className:`GigsEmbeds GigsPortingEmbed GigsEmbeds-form ${a}`,shouldDirty:!0,onSubmit:c=>{const s=Be(c);return i(s)},children:[e.required.includes("firstName")&&d(u,{name:"firstName",validate:[G(n.text["field.firstName.error.required"])],transform:U({on:"input"}),children:(c,s)=>d(w,{of:c,children:[d(C,{of:c,children:n.text["field.firstName.label"]}),d(F,{...s,of:c,type:"text",value:c.value,required:!0}),d(A,{of:c})]})}),e.required.includes("lastName")&&d(u,{name:"lastName",validate:[G(n.text["field.lastName.error.required"])],transform:U({on:"input"}),children:(c,s)=>d(w,{of:c,children:[d(C,{of:c,children:n.text["field.lastName.label"]}),d(F,{...s,of:c,type:"text",value:c.value,required:!0}),d(A,{of:c})]})}),e.required.includes("birthday")&&d(u,{name:"birthday",validate:[G(n.text["field.birthday.error.required"])],transform:U({on:"input"}),children:(c,s)=>d(w,{of:c,children:[d(C,{of:c,children:n.text["field.birthday.label"]}),d(F,{...s,of:c,value:c.value,required:!0,type:"date"}),d(A,{of:c})]})})]})}function Se(e){return Di(e)?"carrierDetails":qi(e)?"holderDetails":Ii(e)?"address":Oi(e)?"donorProviderApproval":null}function Di(e){return!!(Y(e,"accountPin")&&!e.accountPinExists||Y(e,"accountNumber")&&!e.accountNumber)}function qi(e){return!!(Y(e,"firstName")&&!e.firstName||Y(e,"lastName")&&!e.lastName||Y(e,"birthday")&&!e.birthday)}function Ii(e){return Y(e,"address")&&!e.address}function Oi(e){return Y(e,"donorProviderApproval")&&!e.donorProviderApproval}function Y(e,t){return e.required.includes(t)}function Ti({porting:e,onValidationChange:t,onSubmit:i}){const n=Se(e);return n==="carrierDetails"?d(Ai,{porting:e,onValidationChange:t,onSubmit:r=>i(r)}):n==="holderDetails"?d(Ci,{porting:e,onValidationChange:t,onSubmit:r=>i(r)}):n==="address"?d(xi,{porting:e,onValidationChange:t,onSubmit:r=>i({address:r})}):n==="donorProviderApproval"?d(Fi,{porting:e,onValidationChange:t,onSubmit:r=>i(r)}):null}function Ui({porting:e,onPortingUpdate:t,onValidationChange:i,options:n}){return d(gt.Provider,{value:n||{},children:d("div",{className:"__ge_portingRoot GigsEmbeds-root",children:d(Ti,{porting:e,onValidationChange:i,onSubmit:async r=>{await(t==null?void 0:t(r))}})})})}async function Gi(e,{options:t,project:i}){P(i,"NO_PROJECT: Cannot initialize PortingEmbed without a project.");const{connectSession:n,token:r}=await Qt(e,"completePorting");let o=null,u=t;const a=ee(),f=await Kt(n.intent.completePorting.subscription,{project:i,token:r});P(f.porting,"NOT_FOUND: The given subscription has no porting.");let l=f.porting;P(["informationRequired"].includes(l.status),`UNSUPPORTED: Porting status "${l.status}" is not supported by the embed.`);const s=p=>{a.emit("validationChange",p)},h=async p=>{a.emit("submitStatus",{status:"loading"});try{const y=await Zt(l.id,p,{token:r,project:i});a.emit("submitStatus",{status:"success",porting:l});const v=Se(y),m=Se(l);a.emit("stepChange",{nextStep:v,prevStep:m}),v===null&&a.emit("completed",{porting:y}),l=y}catch(y){a.emit("submitStatus",{status:"error",error:y})}finally{_()}},_=()=>{P(o,"No element present to render embed into."),at(d(Ui,{options:u,porting:l,onValidationChange:s,onPortingUpdate:h}),o)};return{mount(p){P(p,"Cannot call mount() without specifying a container."),o=typeof p=="string"?document.querySelector(p):p,P(o,"Element to mount to could not be found."),_()},update(p){P(o,"Cannot call update() on an unmounted embed."),u=p,_()},unmount(){P(o,"Cannot call unmount() on an unmounted embed."),at(null,o),o=null},on:a.on.bind(a),off:a.off.bind(a),currentStep(){return Se(l)}}}Z.PortingEmbed=Gi,Object.defineProperty(Z,Symbol.toStringTag,{value:"Module"})});