1"use strict";(self.webpackChunkplg_crm=self.webpackChunkplg_crm||[]).push([[594,6587,8968],{10637(e,t,n){n.d(t,{A:()=>o});var a=n(49555),r=n(44914),s=n(96452);function o(e){var t=e.mode,n=e.heading,o=e.description,l=e.icon,i=void 0===l?"alertCircle":l,c=e.initialUpvotes,m=void 0===c?127:c,u=e.statusLabel,d=void 0===u?"Coming soon":u,p=e.requestLabel,g=void 0===p?"Request custom feature":p,f=e.customEmailSubject,b=(0,r.useState)(m),y=(0,a.A)(b,2),v=y[0],x=y[1],h=(0,r.useState)(!1),E=(0,a.A)(h,2),N=E[0],w=E[1],C=n.endsWith(" ð")?n:"".concat(n," ð"),S=n.replace(/[^\w\s]/g,"").replace(/\b(coming soon|features?)\b/gi,"").replace(/!+/g,"").trim().split(/\s+/).slice(0,2).join(" ").toLowerCase(),k="Requesting ".concat(S," for Customer Analytics"),A=encodeURIComponent(f||k),I={bell:s.Bell,dollarSign:s.DollarSign,alertCircle:s.AlertCircle,lock:s.Lock}[i]||s.AlertCircle;return r.createElement("div",{className:"relative overflow-hidden bg-gradient-to-r from-purple-600 to-indigo-600 rounded-lg shadow-lg"},r.createElement("div",{className:"absolute inset-0 bg-white/10 backdrop-blur-sm"}),r.createElement("div",{className:"relative p-6 flex items-start gap-4"},r.createElement("div",{className:"flex-shrink-0 bg-white/20 p-3 rounded-full"},r.createElement(I,{className:"w-6 h-6 text-white"})),r.createElement("div",{className:"flex-1"},r.createElement("h3",{className:"text-lg font-semibold text-white mb-1"},C),r.createElement("p",{className:"text-purple-50 mb-4"},o),r.createElement("div",{className:"flex items-center gap-4"},r.createElement("span",{className:"inline-flex items-center text-sm text-purple-50 bg-white/10 px-3 py-1 rounded-full"},r.createElement(s.Lock,{className:"w-4 h-4 mr-1"}),d),"upvote"===t?r.createElement("button",{onClick:function(){N||(x(function(e){return e+1}),w(!0))},disabled:N,className:"inline-flex items-center gap-2 px-4 py-2 rounded-md text-sm font-medium transition-all\n ".concat(N?"bg-white/20 text-white cursor-not-allowed":"bg-white text-purple-600 hover:bg-purple-50 active:scale-95")},r.createElement(s.ThumbsUp,{className:"w-4 h-4"}),N?"Upvoted":"Upvote"," (",v,")"):r.createElement("a",{href:"mailto:[email protected]?subject=".concat(A),className:"inline-flex items-center text-sm text-purple-50 hover:text-white transition-colors"},r.createElement(s.Mail,{className:"w-4 h-4 mr-1"}),g)))),r.createElement("div",{className:"absolute top-0 right-0 w-32 h-32 bg-white/10 rounded-full -translate-y-1/2 translate-x-1/2"}))}},24188(e,t,n){n.d(t,{p:()=>m});var a=n(74652),r=n(49555),s=n(44914),o=n(96452),l=n(13622),i=n(18330),c=n(60749);function m(e){var t=e.icon,n=e.title,m=e.description,u=e.teams,d=e.setupTime,p=e.totalSteps,g=e.completedSteps,f=e.onInviteTeam,b=e.headerAction,y=e.metaAction,v=(0,s.useState)({}),x=(0,r.A)(v,2),h=x[0],E=x[1],N=(0,i.useSelector)(function(e){return e.teams.teamMap}),w=(0,l.t)(),C=(0,r.A)(w,1)[0],S=(0,s.useRef)(null);return(0,s.useEffect)(function(){if(u&&0!==u.length){var e=(0,a.A)(u).sort().join(",");S.current!==e&&(S.current=e,C({variables:{input:{productId:(0,c.J1)()}},onCompleted:function(e){var t;if(null!=e&&null!==(t=e.getTeamUsers)&&void 0!==t&&t.teams){var n={};e.getTeamUsers.teams.forEach(function(e){u.includes(e.teamId)&&(n[e.teamId]=e.users.map(function(e){return{email:e.email,name:e.name,avatar:e.image||"https://via.placeholder.com/40"}}))}),E(n)}},onError:function(){}}))}},[u,C]),s.createElement("div",null,s.createElement("div",{className:"flex gap-4 mb-4 w-full"},s.createElement("div",{className:"w-full"},s.createElement("div",{className:"flex items-start space-x-4"},s.createElement("div",{className:"p-3 bg-indigo-50 rounded-lg"},t),s.createElement("div",{className:"flex flex-col gap-3 w-full"},s.createElement("div",{className:"flex w-full justify-between items-start gap-4"},s.createElement("div",{className:"flex flex-col gap-1 min-w-0"},s.createElement("div",{className:"flex flex-row gap-2 items-center"},s.createElement("h1",{className:"text-[24px] font-bold text-gray-900"},n),s.createElement("div",{className:"relative group"},s.createElement(o.HelpCircle,{className:"w-5 h-5 text-gray-400 hover:text-gray-600 cursor-help"}),s.createElement("div",{className:"absolute left-0 bottom-full mb-2 w-64 p-3 bg-gray-800 text-white text-sm rounded-lg shadow-lg op
1acity-0 invisible group-hover:opacity-100 group-hover:visible transition-all duration-200 z-10"},s.createElement("div",{className:"absolute bottom-0 left-4 transform translate-y-full"},s.createElement("div",{className:"border-4 border-transparent border-t-gray-800"})),"Collaborate with your teams members"))),s.createElement("div",{className:"flex items-center justify-between gap-4"},s.createElement("p",{className:"text-gray-600"},m),y&&s.createElement("div",{className:"flex-shrink-0"},y))),b&&s.createElement("div",{className:"flex-shrink-0"},b)),s.createElement("div",{className:"flex justify-between"},s.createElement("div",{className:"flex justify-between gap-6 items-center"},s.createElement("div",{className:"flex items-center gap-3 bg-light-gray rounded-md"},s.createElement("div",{className:"flex items-center px-3 py-1 rounded-full text-sm font-medium bg-white shadow-sm border border-gray-200 text-gray-700"},s.createElement(o.Clock,{className:"w-3 h-3 mr-1"}),s.createElement("span",null,"~",d," mins setup"),s.createElement("span",{className:"mx-2"},"â¢"),s.createElement("div",{className:"flex items-center space-x-2"},s.createElement("div",{className:"w-16 h-1.5 bg-gray-100 rounded-full overflow-hidden"},s.createElement("div",{className:"h-full bg-[#0525f5] rounded-full transition-all duration-300",style:{width:"".concat(g/p*100,"%")}})),s.createElement("span",{className:"text-xs"},g,"/",p)))),s.createElement("div",{className:"flex items-center gap-2 rounded-lg"},u&&u.length>0&&s.createElement("div",{className:"flex items-center gap-3"},u.map(function(e,t){var n=h[e]||[],a=N[e]||e.replace("_"," ");return s.createElement(s.Fragment,{key:e},s.createElement("div",{className:"relative group"},s.createElement("button",{onClick:function(t){t.stopPropagation(),f&&f(e)},className:"inline-flex items-center gap-2 px-3 py-1.5 rounded-lg text-sm font-medium bg-primaryExtremeLightColor text-[#1556D0] hover:bg-primaryLightColor hover:text-[#1556D0] transition-colors cursor-pointer"},s.createElement("span",{className:"font-medium"},a),n.length>0?s.createElement("div",{className:"relative group flex items-center"},s.createElement("div",{className:"flex items-center"},n.slice(0,3).map(function(e,t){return s.createElement("div",{key:t,className:"w-6 h-6 rounded-full bg-white flex items-center justify-center text-[10px] text-gray-800 font-semibold border border-gray-200 ".concat(0!==t?"-ml-2":"")},e.avatar.includes("placeholder.com")?e.name.charAt(0).toUpperCase():s.createElement("img",{src:e.avatar,alt:e.name,className:"w-full h-full rounded-full object-cover"}))}),n.length>3&&s.createElement("div",{className:"-ml-2 w-6 h-6 rounded-full bg-gray-300 flex items-center justify-center text-[10px] font-semibold border border-gray-200"},"+",n.length-3)),s.createElement("div",{className:"absolute left-0 top-full mt-2 w-36 px-2 py-1.5 bg-gray-700 text-white text-xs rounded shadow-lg hidden group-hover:block z-40"},s.createElement("div",{className:"absolute bottom-full left-4 mb-0"},s.createElement("div",{className:"border-4 border-transparent border-b-gray-700"})),s.createElement("ul",{className:"space-y-0.5"},n.slice(0,5).map(function(e,t){return s.createElement("li",{key:t,className:"truncate"},e.name)}),n.length>5&&s.createElement("li",null,"+",n.length-5," more")))):s.createElement(o.UserPlus,{className:"w-3 h-3 mr-1"})),s.createElement("div",{className:"absolute left-1/2 transform -translate-x-1/2 bottom-full mb-2 w-48 p-2 bg-gray-800 text-white text-xs rounded-lg shadow-lg opacity-0 invisible group-hover:opacity-100 group-hover:visible transition-all duration-200 z-50 pointer-events-none whitespace-normal"},s.createElement("div",{className:"absolute top-full left-1/2 transform -translate-x-1/2 -mt-1"},s.createElement("div",{className:"border-4 border-transparent border-t-gray-800"})),"Collaborate with your teams members")),t<u.length-1&&s.createElement("div",{className:"border-l border-gray-300 h-6"}))}))))))))))}},34864(e,t,n){n.d(t,{R:()=>o});var a=n(44914),r=n(96452),s=n(93343),o=function(e){var t=e.onClose,n=e.variant,o="embedded"===(void 0===n?"default":n);return a.createElement("div",{className:"border-0 shadow-none"},a.createElement("div",{className:o?"pb-4":"pb-6 border-b border-gray-200"},a.createElement("div",{className:"flex items-start justify-between gap-3"},a.createElement("div",{className:"flex items-start gap-3"},a.createElement("div",{className:"shrink-0 p-2 rounded-lg bg-green-50 ".concat(o?"mt-0.5":"")},a.createElement(s._pZ,{className:o?"h-5 w-5 text-[#2CA01C]":"h-6 w-6 text-[#2CA01C]"})),a.createElement("div",null,a.createElement("p",{className:"text-xs font-semibold uppercase tracking-wider text-gray-400 mb-0.5"},"Setup Guide"),a.createElement("h2",{className:o?"text-lg font-bold text-gray-900 leading-tight":"text-2xl font-bold text-gray-900 leading-tight"},"QuickBooks Integration"),a.createElement("p",{className:"text-gray-500 mt-1 ".concat(o?"text-xs":"text-sm")}
1,"Follow these steps to connect and sync your QuickBooks Online account."))),t&&a.createElement("button",{type:"button",onClick:t,className:"p-1.5 rounded-md text-gray-500 hover:text-gray-700 hover:bg-gray-100 transition-colors flex-shrink-0 mt-1","aria-label":"Close setup guide"},a.createElement(r.X,{className:"w-5 h-5"})))),a.createElement("div",{className:o?"px-1 pb-1 pt-2 space-y-6":"p-6 space-y-8"},a.createElement("div",null,a.createElement("div",{className:"mb-3"},a.createElement("p",{className:"text-xs font-semibold uppercase tracking-wider text-gray-400 mb-0.5"},"Before you begin"),a.createElement("h3",{className:"font-bold text-gray-900 ".concat(o?"text-sm":"text-base")},"Prerequisites")),a.createElement("div",{className:"space-y-2 ml-7"},a.createElement("div",{className:"flex items-center gap-2"},a.createElement("span",{className:"inline-flex items-center px-2 py-1 rounded text-xs font-medium border border-gray-300 text-gray-700"},"Required"),a.createElement("span",{className:"text-sm"},"Admin access to your QuickBooks Online account")),a.createElement("div",{className:"flex items-center gap-2"},a.createElement("span",{className:"inline-flex items-center px-2 py-1 rounded text-xs font-medium border border-gray-300 text-gray-700"},"Required"),a.createElement("a",{href:"https://developer.intuit.com/app/developer/qbo/docs/develop/authentication-and-authorization/oauth-2.0",target:"_blank",rel:"noopener noreferrer",className:"text-sm text-blue-600 hover:text-blue-800 underline flex items-center gap-1"},"OAuth 2.0 credentials (Client ID, Client Secret, Access Token, Refresh Token)",a.createElement(r.ExternalLink,{className:"h-3 w-3"}))),a.createElement("div",{className:"flex items-center gap-2"},a.createElement("span",{className:"inline-flex items-center px-2 py-1 rounded text-xs font-medium border border-gray-300 text-gray-700"},"Required"),a.createElement("a",{href:"https://developer.intuit.com/app/developer/dashboard",target:"_blank",rel:"noopener noreferrer",className:"text-sm text-blue-600 hover:text-blue-800 underline flex items-center gap-1"},"Intuit Developer account with an app created",a.createElement(r.ExternalLink,{className:"h-3 w-3"}))))),a.createElement("hr",{className:"border-gray-200"}),a.createElement("div",null,a.createElement("div",{className:"flex items-center gap-2 mb-4"},a.createElement("div",{className:"flex items-center justify-center w-6 h-6 bg-gray-900 text-white rounded-full text-sm font-bold"},"1"),a.createElement("h3",{className:"text-lg font-semibold"},"Set up the QuickBooks connector")),a.createElement("div",{className:"ml-8 space-y-3"},[{title:"Map Environments",description:"Map your QuickBooks environment (Production or Sandbox) to your ThriveStack application environment."},{title:"Connect QuickBooks",description:"Click 'Connect with QuickBooks' to authorize ThriveStack via OAuth. You will be redirected to QuickBooks to approve access â no credentials to enter manually."},{title:"Start Date",description:"Select the date from which ThriveStack will begin syncing your QuickBooks data (e.g., 2023-01-01). Earlier dates include more historical revenue."},{title:"Test Connection",description:"Verify the QuickBooks connection before starting data ingestion."},{title:"Start Ingestion",description:"Trigger the data sync from your QuickBooks Online account to ThriveStack."}].map(function(e,t){return a.createElement("div",{key:t,className:"flex items-start gap-3"},a.createElement("div",{className:"flex items-center justify-center w-5 h-5 bg-gray-100 text-gray-600 rounded-full text-xs font-medium mt-0.5 flex-shrink-0"},t+1),a.createElement("div",null,a.createElement("p",{className:"text-sm font-medium"},e.title),a.createElement("p",{className:"text-xs text-gray-600 mt-1"},e.description)))}))),a.createElement("hr",{className:"border-gray-200"}),a.createElement("div",null,a.createElement("div",{className:"flex items-center gap-2 mb-3"},a.createElement("div",{className:"flex items-center justify-center w-6 h-6 bg-gray-900 text-white rounded-full text-sm font-bold"},"2"),a.createElement("h3",{className:"text-lg font-semibold"},"Sandbox vs Production")),a.createElement("div",{className:"ml-8"},a.createElement("div",{className:"p-3 bg-amber-50 border border-amber-200 rounded-md space-y-2"},a.createElement("p",{className:"text-xs font-semibold text-amber-900"},"Choosing the right environment"),a.createElement("ul",{className:"text-xs text-amber-800 space-y-1 list-disc list-inside"},a.createElement("li",null,a.createElement("span",{className:"font-semibold"},"Sandbox")," â use for testing. Credentials come from the Intuit Developer Portal sandbox keys."),a.createElement("li",null,a.createElement("span",{className:"font-semibold"},"Production")," â use for live data. Ensure your app is approved for production access in Intuit.")),a.createElement("p",{className:"text-xs text-amber-700"},"ThriveStack automatically suggests the correct environment based on your app environment. You can override this in the Map Environments step."))))))}},40594(e,t,n){n.r(t),n.d(t,{default:()=>Kt,useEmailManager:()=>Mt});var a=n(58160),r=n(60875),s=n(32816),o=n(36129),l=n(74652),i=n(67136),c=n(49555),m=n(92207),u=n.n(m),d=n(44914),p=n(96728),g=n(9514),f=n(9705),b=n.n(f),y=n(96452);function v(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,a)}return n}function x(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};
1t%2?v(Object(n),!0).forEach(function(t){(0,i.A)(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 h(){var e=(0,d.useState)(null),t=(0,c.A)(e,2),n=t[0],a=t[1],r=(0,d.useState)(null),o=(0,c.A)(r,2),m=o[0],p=o[1],g=(0,d.useState)({}),f=(0,c.A)(g,2),b=f[0],v=f[1],h=(0,d.useState)([{id:"mrr_change",metric:"mrr",condition:"below",threshold:5e3,timeframe:"24h",channels:[{type:"slack",target:"#revenue-alerts"}]},{id:"churn_spike",metric:"churn_rate",condition:"above",threshold:2,timeframe:"24h",channels:[{type:"email",target:"[email protected]"}]}]),E=(0,c.A)(h,2),N=E[0],w=E[1],C=function(){var e=(0,s.A)(u().mark(function e(t){var n;return u().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return p(t.id),v(function(e){return x(x({},e),{},(0,i.A)({},t.id,{success:!1}))}),e.prev=1,e.next=2,new Promise(function(e){return setTimeout(e,1500)});case 2:if(!(Math.random()>.5)){e.next=3;break}throw new Error("Failed to deliver to some channels");case 3:v(function(e){return x(x({},e),{},(0,i.A)({},t.id,{success:!0}))}),e.next=5;break;case 4:e.prev=4,n=e.catch(1),v(function(e){return x(x({},e),{},(0,i.A)({},t.id,{success:!1,error:n instanceof Error?n.message:"Unknown error occurred"}))});case 5:return e.prev=5,p(null),e.finish(5);case 6:case"end":return e.stop()}},e,null,[[1,4,5,6]])}));return function(t){return e.apply(this,arguments)}}();return d.createElement("div",{className:"space-y-6"},d.createElement("div",{className:"flex items-start space-x-3"},d.createElement("div",{className:"p-2 bg-indigo-100 rounded-lg"},d.createElement(y.AlertTriangle,{className:"w-6 h-6 text-indigo-600"})),d.createElement("div",{className:"flex-1"},d.createElement("h2",{className:"text-xl font-semibold text-gray-900"},"Configure Revenue Alerts"),d.createElement("p",{className:"text-gray-600"},"Set up alerts to monitor key revenue metrics and get notified of important changes."))),d.createElement("div",{className:"space-y-4 ml-11"},d.createElement("div",{className:"grid grid-cols-2 gap-6 mb-8"},d.createElement("div",{className:"space-y-2"},d.createElement("div",{className:"flex items-center space-x-2 text-gray-900"},d.createElement(y.Bell,{className:"w-4 h-4 text-indigo-600"}),d.createElement("span",{className:"font-medium"},"Revenue Alerts")),d.createElement("ul",{className:"space-y-2 text-sm text-gray-600"},d.createElement("li",{className:"flex items-center"},d.createElement("div",{className:"w-1.5 h-1.5 rounded-full bg-indigo-600 mr-2"}),"MRR changes"),d.createElement("li",{className:"flex items-center"},d.createElement("div",{className:"w-1.5 h-1.5 rounded-full bg-indigo-600 mr-2"}),"Churn spikes"),d.createElement("li",{className:"flex items-center"},d.createElement("div",{className:"w-1.5 h-1.5 rounded-full bg-indigo-600 mr-2"}),"Payment failures"))),d.createElement("div",{className:"space-y-2"},d.createElement("div",{className:"flex items-center space-x-2 text-gray-900"},d.createElement(y.Bell,{className:"w-4 h-4 text-indigo-600"}),d.createElement("span",{className:"font-medium"},"Billing Alerts")),d.createElement("ul",{className:"space-y-2 text-sm text-gray-600"},d.createElement("li",{className:"flex items-center"},d.createElement("div",{className:"w-1.5 h-1.5 rounded-full bg-indigo-600 mr-2"}),"Failed charges"),d.createElement("li",{className:"flex items-center"},d.createElement("div",{className:"w-1.5 h-1.5 rounded-full bg-indigo-600 mr-2"}),"Subscription changes"),d.createElement("li",{className:"flex items-center"},d.createElement("div",{className:"w-1.5 h-1.5 rounded-full bg-indigo-600 mr-2"}),"Dunning events")))),d.createElement("div",{className:"bg-white rounded-xl p-6 border border-gray-200 space-y-6"},d.createElement("h3",{className:"font-medium text-gray-900 mb-4"},"Revenue Alert Rules"),d.createElement("div",{className:"space-y-4"},N.map(function(e){var t,r;return d.createElement("div",{key:e.id,className:"border border-gray-200 rounded-lg overflow-hidden"},d.createElement("div",{onClick:function(){return t=e.id,void a(n===t?null:t);var t},className:"\n flex items-center justify-between p-4 cursor-pointer\n ".concat(n===e.id?"bg-indigo-50":"bg-gray-50","\n transition-colors duration-200\n ")},d.createElement("div",{className:"flex items-center space-x-3"},d.createElement(y.Bell,{className:"w-5 h-5 text-indigo-600"}),d.createElement("span",{className:"font-medium text-gray-900"},"Alert when"," ",d.createElement("span",null,"mrr"===e.metric?"Monthly Recurring Revenue":"Churn Rate")," ","is"," ",d.createElement("span",null,e.condition)," ",d.createElement("span",{className:"text-lg font-bold text-indigo-600"},e.threshold,d.createElement("span",{className:"text-sm ml-0.5"},"mrr"===e.metric?"$":"%")))),d.createElement("div",{className:"flex items-center space-x-4"}
1,d.createElement("div",{className:"flex -space-x-2"},e.channels.map(function(e,t){return d.createElement("div",{key:t,className:"w-8 h-8 rounded-full bg-white border-2 border-gray-200 flex items-center justify-center shadow-sm",title:e.target},"slack"===e.type&&d.createElement(y.Slack,{className:"w-4 h-4 text-[#4A154B]"}),"teams"===e.type&&d.createElement(y.MessageSquare,{className:"w-4 h-4 text-[#6264A7]"}),"email"===e.type&&d.createElement(y.Mail,{className:"w-4 h-4 text-gray-600"}))})),n===e.id?d.createElement(y.ChevronUp,{className:"w-5 h-5 text-gray-400"}):d.createElement(y.ChevronDown,{className:"w-5 h-5 text-gray-400"}))),n===e.id&&d.createElement("div",{className:"p-4 border-t border-gray-200 space-y-4"},d.createElement("div",{className:"grid grid-cols-3 gap-4"},d.createElement("div",null,d.createElement("label",{className:"block text-sm font-medium text-gray-700 mb-1"},"Metric"),d.createElement("select",{value:e.metric,onChange:function(t){var n=N.map(function(n){return n.id===e.id?x(x({},n),{},{metric:t.target.value}):n});w(n)},className:"w-full px-3 py-2 border border-gray-300 rounded-lg"},d.createElement("option",{value:"mrr"},"Monthly Recurring Revenue"),d.createElement("option",{value:"churn_rate"},"Churn Rate"),d.createElement("option",{value:"payment_failure"},"Payment Failure Rate"))),d.createElement("div",null,d.createElement("label",{className:"block text-sm font-medium text-gray-700 mb-1"},"Condition"),d.createElement("select",{value:e.condition,onChange:function(t){var n=N.map(function(n){return n.id===e.id?x(x({},n),{},{condition:t.target.value}):n});w(n)},className:"w-full px-3 py-2 border border-gray-300 rounded-lg"},d.createElement("option",{value:"above"},"Above"),d.createElement("option",{value:"below"},"Below"))),d.createElement("div",null,d.createElement("label",{className:"block text-sm font-medium text-gray-700 mb-1"},"Threshold"),d.createElement("input",{type:"number",value:e.threshold,onChange:function(t){var n=N.map(function(n){return n.id===e.id?x(x({},n),{},{threshold:Number(t.target.value)}):n});w(n)},className:"w-full px-3 py-2 border border-gray-300 rounded-lg"}))),d.createElement("div",null,d.createElement("label",{className:"block text-sm font-medium text-gray-700 mb-1"},"Timeframe"),d.createElement("select",{value:e.timeframe,onChange:function(t){var n=N.map(function(n){return n.id===e.id?x(x({},n),{},{timeframe:t.target.value}):n});w(n)},className:"w-full px-3 py-2 border border-gray-300 rounded-lg"},d.createElement("option",{value:"1h"},"1 hour"),d.createElement("option",{value:"6h"},"6 hours"),d.createElement("option",{value:"24h"},"24 hours"),d.createElement("option",{value:"7d"},"7 days"))),d.createElement("div",null,d.createElement("label",{className:"block text-sm font-medium text-gray-700 mb-2"},"Notification Channels"),d.createElement("div",{className:"space-y-3"},e.channels.map(function(t,n){return d.createElement("div",{key:n,className:"flex items-center space-x-3"},d.createElement("select",{value:t.type,onChange:function(t){var a=N.map(function(a){return a.id===e.id?x(x({},a),{},{channels:a.channels.map(function(e,a){return a===n?x(x({},e),{},{type:t.target.value}):e})}):a});w(a)},className:"w-32 px-3 py-2 border border-gray-300 rounded-lg"},d.createElement("option",{value:"slack"},"Slack"),d.createElement("option",{value:"teams"},"Teams"),d.createElement("option",{value:"email"},"Email")),d.createElement("input",{type:"text",value:t.target,onChange:function(t){var a=N.map(function(a){return a.id===e.id?x(x({},a),{},{channels:a.channels.map(function(e,a){return a===n?x(x({},e),{},{target:t.target.value}):e})}):a});w(a)},placeholder:"slack"===t.type||"teams"===t.type?"#channel":"[email protected]",className:"flex-1 px-3 py-2 border border-gray-300 rounded-lg"}),d.createElement("button",{onClick:function(){var t=N.map(function(t){return t.id===e.id?x(x({},t),{},{channels:t.channels.filter(function(e,t){return t!==n})}):t});w(t)},className:"p-2 text-gray-400 hover:text-gray-600"},d.createElement(y.X,{className:"w-5 h-5"})))})),d.createElement("button",{onClick:function(){var t=N.map(function(t){return t.id===e.id?x(x({},t),{},{channels:[].concat((0,l.A)(t.channels),[{type:"slack",target:""}])}):t});w(t)},className:"mt-2 inline-flex items-center text-sm text-indigo-600 hover:text-indigo-700"},d.createElement(y.Plus,{className:"w-4 h-4 mr-1"}),"Add Channel")),d.createElement("div",{className:"mt-6 pt-6 border-t border-gray-200"},d.createElement("div",{className:"flex items-center justify-between mb-4"},d.createElement("div",null,d.createElement("h4",{className:"text-sm font-medium text-gray-900 mb-1"},"Test Alert"),d.createElement("p",{className:"text-sm text-gray-600"},"Send a test notification to verify your alert configuration")),d.createElement("button",{onClick:function(){return C(e)},disabled:null!==m,className:"\n inline-flex items-center px-4 py-2 rounded-lg font-medium\n ".concat(m===e.id?"bg-gray-100 text-gray-400 cursor-wait":"bg-indigo-600 text-white hover:bg-indigo-700","\n ")},m===e.id?d.createElement(d.Fragment,null,d.createElement(y.Loader2,{className:"w-4 h-4 mr-2 animate-spin"}),"Sending..."):d.createElement(d.Fragment,null,d.createElement(y.Send,{className:"w-4 h-4 mr-2"}),"Send Test Alert"))),(null===(t=b[e.id])||void 0===t?void 0:t.success)&&d.createElement("div",{className:"flex items-center bg-green-50 text-green-700 p-4 rounded-lg border border-green-200 animate-fade-in"},d.createElement(y.Check,{className:"w-5 h-5 mr-3"}),d.createElement("div",null,d.createElement("h5",{className:"font-medium mb-1"},"Test Alert Sent Successfully!"),d.createElement("p",{className:"text-sm"},"Check your configured notification channels to verify the alert was received."))),(null===(r=b[e.id])||void 0===r?void 0:r.error)&&d.createElement("div",{className:"flex items-center bg-red-50 text-red-700 p-4 rounded-lg border border-red-200 animate-fade-in"},d.createElement(y.AlertTriangle,{className:"w-5 h-5 mr-3"}),d.createElement("div",null,d.createElement("h5",{className:"font-medium mb-1"},"Test Alert Failed"),d.createElement("p",{className:"text-sm"}
1,b[e.id].error,". Please verify your channel configuration and try again."))))))}),d.createElement("button",{onClick:function(){var e={id:"rule_".concat(Date.now()),metric:"mrr",condition:"below",threshold:5e3,timeframe:"24h",channels:[{type:"email",target:""}]};w([].concat((0,l.A)(N),[e])),a(e.id)},className:"w-full py-3 border-2 border-dashed border-gray-300 rounded-lg text-gray-600 hover:border-indigo-300 hover:text-indigo-600 transition-colors"},d.createElement("div",{className:"flex items-center justify-center"},d.createElement(y.Plus,{className:"w-5 h-5 mr-2"}),"Add Alert Rule"))))))}var E=n(24188),N=n(93343),w=n(29651);function C(e){var t,n,a,r=e.connections,s=e.onAddNew,o=e.onEdit,l=e.onDelete,i=e.canAddNew,m=void 0===i||i,u=e.addNewError,p=void 0===u?null:u,g=e.canDelete,f=void 0===g?function(){return!0}:g,b=(e.onOpenSetupHealthStatus,e.onOpenStepForIssue),v=e.leftContent,x=(0,d.useState)(null),h=(0,c.A)(x,2),E=h[0],C=h[1],S=E?r.find(function(e){return e.id===E}):null;return d.createElement("div",{className:"space-y-6"},d.createElement("div",{className:"flex items-start justify-between gap-4 flex-wrap"},null!=v?d.createElement("div",{className:"ml-2 flex flex-row items-center gap-2"},d.createElement("label",{className:"font-medium text-gray-600"},"Select Environment:"),v):null,d.createElement("div",{className:"flex flex-col items-end gap-2 ml-auto"},p&&d.createElement("div",{className:"text-sm text-red-600 bg-red-50 border border-red-200 rounded-lg px-3 py-2"},p),d.createElement("button",{onClick:s,disabled:!m,className:"inline-flex items-center space-x-2 px-4 py-2 rounded-lg font-medium transition-colors shadow-sm ".concat(m?"bg-primaryColor text-white hover:bg-primaryDarkColor hover:shadow-md":"bg-gray-300 text-gray-500 cursor-not-allowed")},d.createElement(y.Plus,{className:"w-4 h-4"}),d.createElement("span",null,"Connect New Source")))),0===r.length?d.createElement("div",{className:"bg-white rounded-xl border-2 border-dashed border-gray-300 p-12 text-center"},d.createElement(y.Database,{className:"w-12 h-12 text-gray-400 mx-auto mb-4"}),d.createElement("h3",{className:"text-lg font-semibold text-gray-900 mb-2"},"No connections yet"),d.createElement("p",{className:"text-gray-600 mb-6"},"Connect your first data source to start analyzing your revenue metrics in real-time."),d.createElement("button",{onClick:s,className:"inline-flex items-center gap-2 px-6 py-3 bg-primaryColor text-white rounded-lg font-medium hover:bg-primaryDarkColor transition-colors"},d.createElement(y.Plus,{className:"w-5 h-5"}),d.createElement("span",null,"Get Started"))):d.createElement("div",{className:"bg-white rounded-lg shadow-sm border border-gray-200 overflow-hidden"},d.createElement("div",{className:"overflow-x-auto"},d.createElement("table",{className:"w-full"},d.createElement("thead",{className:"border-b border-gray-200"},d.createElement("tr",null,d.createElement("th",{className:"px-6 py-3 text-left text-xs font-semibold text-gray-700 uppercase tracking-wider"},"Source"),d.createElement("th",{className:"px-6 py-3 text-left text-xs font-semibold text-gray-700 uppercase tracking-wider"},"Category"),d.createElement("th",{className:"px-6 py-3 text-left text-xs font-semibold text-gray-700 uppercase tracking-wider"},"Status"),d.createElement("th",{className:"px-6 py-3 text-left text-xs font-semibold text-gray-700 uppercase tracking-wider"},"Environment"),d.createElement("th",{className:"px-6 py-3 text-left text-xs font-semibold text-gray-700 uppercase tracking-wider"},"Account ID"),d.createElement("th",{className:"px-6 py-3 text-left text-xs font-semibold text-gray-700 uppercase tracking-wider"},"Last Sync"),d.createElement("th",{className:"px-6 py-3 text-left text-xs font-semibold text-gray-700 uppercase tracking-wider"},"Error"),d.createElement("th",{className:"px-6 py-3 text-right text-xs font-semibold text-gray-700 uppercase tracking-wider"},"Actions"))),d.createElement("tbody",null,r.map(function(e){var t,n;return d.createElement("tr",{key:e.id,className:"hover:bg-gray-50 transition-colors border-b border-gray-100 last:border-b-0"},d.createElement("td",{className:"px-6 py-3 whitespace-nowrap"},d.createElement("div",{className:"flex items-center gap-3"},d.createElement("div",{className:"flex-shrink-0"},function(e){switch(e){case"stripe":return d.createElement(N.kDV,{className:"w-5 h-5",style:{color:"#635BFF"}});case"chargebee":return d.createElement("img",{src:w,alt:"",className:"w-5 h-5 object-contain"});case"quickbooks":return d.createElement(N._pZ,{className:"w-5 h-5 text-[#2CA01C]"});default:return d.createElement(y.Database,{className:"w-5 h-5 text-blue-600"})}}(e.type)),d.createElement("div",{className:"text-sm font-medium text-gray-900 capitalize"},e.name||e.type))),d.createElement("td",{className:"px-6 py-3 whitespace-nowrap"},"â"===(n=function(e,t){switch(t||function(){switch(e){case"stripe":case"chargebee":return"subscription";case"api":case"csv":case"salesforce":return"transactions";default:return""}}()){case"subscription":return{label:"Subscription",style:"bg-blue-50 text-blue-700"};case"transactions":return{label:"Transactions & invoices",style:"bg-purple-50 text-purple-700"};default:return{label:"â",style:"text-gray-500"}}}(e.type,e.sourceCategory)).label?d.createElement("span",{className:"text-sm text-gray-400"},"â"):d.createElement("span",{className:"inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium ".concat(n.style)},n.label)),d.createElement("td",{className:"px-6 py-3 whitespace-nowrap"},d.createElement("div",{className:"flex items-center space-x-2"},!1!==e.isComplete?d.createElement(d.Fragment,null,d.createElement(y.CheckCircle2,{className:"w-4 h-4 text-green-600"}),d.createElement("span",{className:"inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium text-green-600 bg-green-50"},"Active")):d.createElement(d.Fragment,null,d.createElement(y.AlertCircle,{className:"w-4 h-4 text-amber-600"}),d.createElement("span",{className:"inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium text-amber-700 bg-amber-50"},"Incomplete")))),d.createElement("td",{className:"px-6 py-3 whitespace-nowrap text-sm text-gray-700"},function(e){var t,n,a;if("stripe"!==e.type&&"chargebee"!==e.type&&"quickbooks"!==e.type)return"â";var r,s=e.sourceConfig||{},o=null!==(t=e.sourceEnvironment)&&void 0!==t?t:"stripe"===e.type?s.stripeEnvironment:"chargebee"===e.type?null!==(n=s.chargebeeEnvironment)&&void 0!==n?n:"Production":null!==(a=s.quickbooksEnvironment)&&void 0!==a?a:"";return(r=String(o||"â"))?r.charAt(0).toUpperCase()+r.slice(1).toLowerCase():"â"}(e)),d.createElement("td",{className:"px-6 py-3 whitespace-nowrap text-sm text-gray-700"},function(e){var t;if("stripe"!==e.type&&"chargebee"!==e.type&&"quickbooks"!==e.type)return"â";var n=e.sourceConfig||{};return(null!==(t=e.accountIdValue)&&void 0!==t?t:"stripe"===e.type?n.accountId:"chargebee"===e.type?n.subdomain:"quickbooks"===e.type?n.realmId:"")||"â"}(e)),d.createElement("td",{className:"px-6 py-3 whitespace-nowrap text-sm text-gray-600"},function(e){if(!e||"string"!=typeof e)return"â";var t=new Date(e);if(Number.isNaN(t.getTime()))return"â";var n=t.getDate(),a=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][t.getMonth()],r=t.getFullYear(),s=t.getHours().toString().padStart(2,"0"),o=t.getMinutes().toString().padStart(2,"0");return"".concat(n," ").concat(a," ").concat(r,", ").concat(s,":").concat(o)}(e.lastSync)),d.createElement("td",{className:"px-6 py-3 whitespace-nowrap text-sm"},(null!==(t=e.issueCount)&&void 0!==t?t:0)>0?d.createElement("button",{type:"button",onClick:function(){return C(e.id)},className:"flex items-center gap-1.5 text-amber-700 hover:text-amber-800 focus:outline-none underline"},d.createElement(y.AlertCircle,{className:"w-4 h-4 flex-shrink-0"}),d.createElement("span",null,e.issueCount," ",1===e.issueCount?"issue":"issues"," found")):d.createElement("span",{className:"text-gray-500"},"â")),d.createElement("td",{className:"px-6 py-3 whitespace-nowrap text-right"},d.createElement("div",{className:"flex items-center justify-end gap-2"},d.createElement("button",{type:"button",onClick:function(){return o(e)},className:"p-2 text-gray-500 hover:text-primaryColor hover:bg-blue-50 rounded-lg transition-colors",title:"Configure"},d.createElement(y.Edit,{className:"w-4 h-4"})),f(e)&&d.createElement("button",{type:"button",onClick:function(){return l(e)},className:"p-2 text-gray-400 hover:text-red-600 hover:bg-red-50 rounded-lg transition-colors",title:"Delete"},d.createElement(y.Trash2,{className:"w-4 h-4"})))))}
1))))),S&&S.issues&&S.issues.length>0&&(t=[2,3,4,5],n=S.issues.filter(function(e){return t.includes(e.stepId)}),a=S.issues.filter(function(e){return 7===e.stepId}),d.createElement("div",{className:"fixed inset-0 z-[100] flex items-center justify-center p-4 bg-black/40 backdrop-blur-sm"},d.createElement("div",{className:"bg-white rounded-2xl shadow-xl w-full max-w-md overflow-hidden"},d.createElement("div",{className:"flex items-center justify-between px-6 py-4 border-b border-gray-200"},d.createElement("h3",{className:"text-lg font-semibold text-gray-900"},"Issues for ",S.name),d.createElement("button",{type:"button",onClick:function(){return C(null)},className:"p-2 text-gray-500 hover:text-gray-700 hover:bg-gray-100 rounded-lg transition-colors","aria-label":"Close"},d.createElement(y.X,{className:"w-5 h-5"}))),d.createElement("div",{className:"px-6 py-4 max-h-[60vh] overflow-y-auto space-y-6"},n.length>0&&d.createElement("div",null,d.createElement("h4",{className:"text-sm font-semibold text-gray-700 tracking-wider mb-2"},"Incomplete setup steps"),d.createElement("ul",{className:"space-y-2"},n.map(function(e){return d.createElement("li",{key:e.id},d.createElement("button",{type:"button",onClick:function(){null==b||b(S,e),C(null)},className:"w-full flex items-center gap-3 text-left px-3 py-2 rounded-lg text-sm text-amber-800 bg-amber-50 hover:bg-amber-100 transition-colors underline"},d.createElement(y.AlertTriangle,{className:"w-4 h-4 flex-shrink-0 text-amber-600"}),d.createElement("span",{className:"font-medium"},e.label)))}))),a.length>0&&d.createElement("div",null,d.createElement("h4",{className:"text-sm font-semibold text-gray-700 tracking-wider mb-2"},"Health issues"),d.createElement("ul",{className:"space-y-2"},a.map(function(e){return d.createElement("li",{key:e.id},d.createElement("button",{type:"button",onClick:function(){null==b||b(S,e),C(null)},className:"w-full flex items-center gap-3 text-left px-3 py-2 rounded-lg text-sm text-amber-800 bg-amber-50 hover:bg-amber-100 transition-colors underline"},d.createElement(y.AlertTriangle,{className:"w-4 h-4 flex-shrink-0 text-amber-600"}),d.createElement("span",{className:"font-medium"},e.label)))})))),d.createElement("div",{className:"px-6 py-4 border-t border-gray-200 bg-gray-50"},d.createElement("p",{className:"ml-4 text-xs text-gray-600"},"Click an issue to resolve it in ",S.name," setup."))))))}var S=n(64598),k=n(99334),A=n(10637);const I=function(e){var t=e.entities,n=e.relationships,a=e.isFullscreen,r=void 0!==a&&a,s=e.onFullscreen,o=e.onExitFullscreen,l=(0,d.useState)(1),i=(0,c.A)(l,2),m=i[0],u=i[1],p=(0,d.useState)({x:0,y:0}),g=(0,c.A)(p,2),f=g[0],b=g[1],v=(0,d.useState)(!1),x=(0,c.A)(v,2),h=x[0],E=x[1],N=(0,d.useState)({x:0,y:0}),w=(0,c.A)(N,2),C=w[0],S=w[1],k=(0,d.useState)(null),A=(0,c.A)(k,2),I=A[0],T=A[1],D=(0,d.useState)({x:0,y:0}),R=(0,c.A)(D,2),_=R[0],P=R[1],O=(0,d.useState)(!1),M=(0,c.A)(O,2),F=M[0],K=M[1],j=(0,d.useState)(!1),q=(0,c.A)(j,2),L=(q[0],q[1]),U=(0,d.useRef)(null),V=(0,d.useRef)(null),B=(0,d.useRef)(null);(0,d.useEffect)(function(){return function(){U.current&&clearTimeout(U.current)}},[]);var z,W=function(){E(!1)},H=function(e){return{x:e.x+f.x,y:e.y+f.y}};return d.createElement("div",{ref:B,className:"relative bg-gray-50 border border-gray-200 rounded-lg overflow-hidden ".concat(r?"fixed inset-0 z-20":"h-full"),style:{userSelect:"none"}},d.createElement("div",{className:"absolute top-4 right-4 z-10 flex space-x-2"},d.createElement("button",{onClick:function(){u(function(e){return Math.max(e-.2,.3)})},className:"p-2 bg-white border border-gray-300 rounded-lg shadow-sm hover:bg-gray-50 transition-colors",disabled:m<=.3},d.createElement(y.ZoomOut,{className:"w-4 h-4 text-gray-600"})),d.createElement("button",{onClick:function(){u(function(e){return Math.min(e+.2,3)})},className:"p-2 bg-white border border-gray-300 rounded-lg shadow-sm hover:bg-gray-50 transition-colors",disabled:m>=3},d.createElement(y.ZoomIn,{className:"w-4 h-4 text-gray-600"})),d.createElement("button",{onClick:function(){u(1),b({x:0,y:0})},className:"p-2 bg-white border border-gray-300 rounded-lg shadow-sm hover:bg-gray-50 transition-colors"},d.createElement(y.RotateCcw,{className:"w-4 h-4 text-gray-600"})),s&&d.createElement("button",{onClick:r?o:s,className:"p-2 bg-white border border-gray-300 rounded-lg shadow-sm hover:bg-gray-50 transition-colors"},d.createElement(y.Maximize,{className:"w-4 h-4 text-gray-600"}))),d.createElement("div",{className:"absolute top-4 left-4 z-10"},d.createElement("div",{className:"px-3 py-1 bg-white border border-gray-300 rounded-lg shadow-sm"},d.createElement("span",{className:"text-sm text-gray-600"},Math.round(100*m),"%"))),d.createElement("div",{className:"w-full h-full overflow-hidden"},d.createElement("svg",{ref:V,className:"cursor-grab active:cursor-grabbing",onMouseDown:function(e){E(!0),S({x:e.clientX-f.x,y:e.clientY-f.y})},onMouseMove:function(e){h&&b({x:e.clientX-C.x,y:e.clientY-C.y})},onMouseUp:W,onMouseLeave:W,style:{minWidth:"1000px",minHeight:"800px",width:"100%",height:"100%",userSelect:"none",WebkitUserSelect:"none",MozUserSelect:"none"}},d.createElement("defs",null,d.createElement("marker",{id:"arrowhead",markerWidth:"10",markerHeight:"7",refX:"9",refY:"3.5",orient:"auto"},d.createElement("polygon",{points:"0 0, 10 3.5, 0 7",fill:"#6b7280"}))),n.map(function(e){var n=function(e){var n=t.find(function(t){return t.id===e.from}),a=t.find(function(t){return t.id===e.to});if(!n||!a)return"";var r=H(n),s=H(a),o=r.x+140,l=r.y+16,i=s.x+140,c=s.y+16;return"M ".concat(o," ").concat(l," L ").concat(i," ").concat(c)}(e);!function(e){var n=t.find(function(t){return t.id===e.from}),a=t.find(function(t){return t.id===e.to});if(!n||!a)return{x:0,y:0};var r=H(n),s=H(a);r.x,s.x,r.y,s.y}(e);return d.createElement("g",{key:"".concat(e.from,"-").concat(e.to)},d.createElement("path",{d:n,stroke:"#6b7280",strokeWidth:"1.5",fill:"none",strokeDasharray:"5,5",markerEnd:"url(#arrowhead)"}))}),t.map(function(e){e.icon;var t=H(e);Math.max(120,20*e.fields.length+60);return d.createElement("g",{key:e.id,transform:"scale(".concat(m,")")},d.createElement("rect",{x:t.x/m,y:t.y/m,width:280,height:Math.max(120,20*e.fields.length+60),rx:"6",fill:"white",stroke:"#e5e7eb",strokeWidth:"1",className:"drop-shadow-sm"}),d.createElement("rect",{x:t.x/m,y:t.y/m,width:280,height:32,rx:"6",fill:"#f8fafc"}),d.createElement("foreignObject",{x:t.x/m+12,y:t.y/m+8,width:240,height:20,style:{userSelect:"none"}},d.createElement("div",{className:"flex items-center justify-between"},d.createElement("span",{className:"font-semibold text-gray-900 text-sm"},e.name),d.createElement("div",{className:"flex items-center space-x-1"},d.createElement("button",{className:"text-gray-400 hover:text-gray-600 p-1 rounded hover:bg-gray-100",onMouseEnter:function(t){return function(e,t){var n;U.current&&clearTimeout(U.current),T(e);var a=null===(n=B.current)||void 0===n?void 0:n.getBoundingClientRect();if(a){var r=t.clientX-a.left,s=t.clientY-a.top,o=r+10,l=s-10;o+320>
1a.width&&(o=r-320-10),l+200>a.height&&(l=s-200-10),l<0&&(l=10),o<0&&(o=10),P({x:o,y:l}),U.current=setTimeout(function(){K(!0)},300)}}(e.id,t)}},d.createElement(y.MoreVertical,{className:"w-4 h-4"})),d.createElement("button",{className:"text-gray-400 hover:text-gray-600 p-1 rounded hover:bg-gray-100"},d.createElement("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},d.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})))))),d.createElement("foreignObject",{x:t.x/m+12,y:t.y/m+40,width:256,height:20*e.fields.length,style:{userSelect:"none"}},d.createElement("div",{className:"space-y-1"},e.fields.map(function(e,t){return d.createElement("div",{key:t,className:"flex items-center justify-between text-xs py-1"},d.createElement("div",{className:"flex items-center space-x-2"},e.isPrimary&&d.createElement("svg",{className:"w-3 h-3 text-yellow-500",fill:"currentColor",viewBox:"0 0 20 20"},d.createElement("path",{d:"M9.049 2.927c.3-.921 1.603-.921 1.902 0l1.07 3.292a1 1 0 00.95.69h3.462c.969 0 1.371 1.24.588 1.81l-2.8 2.034a1 1 0 00-.364 1.118l1.07 3.292c.3.921-.755 1.688-1.54 1.118l-2.8-2.034a1 1 0 00-1.175 0l-2.8 2.034c-.784.57-1.838-.197-1.539-1.118l1.07-3.292a1 1 0 00-.364-1.118L2.98 8.72c-.783-.57-.38-1.81.588-1.81h3.461a1 1 0 00.951-.69l1.07-3.292z"})),e.isForeign&&d.createElement("div",{className:"w-2 h-2 bg-blue-500 rounded-full"}),!e.isPrimary&&!e.isForeign&&d.createElement("svg",{className:"w-3 h-3 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},d.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})),d.createElement("span",{className:"font-medium text-gray-700"},e.name)),d.createElement("span",{className:"text-gray-500 font-mono text-xs"},e.type))}))))})),I&&F&&d.createElement("div",{className:"absolute z-50 bg-white border border-gray-200 rounded-lg shadow-xl p-4 max-w-sm animate-in fade-in-0 zoom-in-95 duration-200",style:{left:"".concat(_.x,"px"),top:"".concat(_.y,"px"),pointerEvents:"auto"},onMouseEnter:function(){U.current&&clearTimeout(U.current),L(!0)},onMouseLeave:function(){L(!1),T(null),K(!1)}},(z=t.find(function(e){return e.id===I}))?d.createElement("div",null,d.createElement("h3",{className:"font-semibold text-gray-900 mb-3 text-sm"},z.name," - All Fields"),d.createElement("div",{className:"space-y-2 max-h-64 overflow-y-auto scrollbar-hide"},z.fields.map(function(e,t){return d.createElement("div",{key:t,className:"flex items-center justify-between text-xs py-1 border-b border-gray-100 last:border-b-0"},d.createElement("div",{className:"flex items-center space-x-2"},e.isPrimary&&d.createElement("svg",{className:"w-3 h-3 text-yellow-500",fill:"currentColor",viewBox:"0 0 20 20"},d.createElement("path",{d:"M9.049 2.927c.3-.921 1.603-.921 1.902 0l1.07 3.292a1 1 0 00.95.69h3.462c.969 0 1.371 1.24.588 1.81l-2.8 2.034a1 1 0 00-.364 1.118l1.07 3.292c.3.921-.755 1.688-1.54 1.118l-2.8-2.034a1 1 0 00-1.175 0l-2.8 2.034c-.784.57-1.838-.197-1.539-1.118l1.07-3.292a1 1 0 00-.364-1.118L2.98 8.72c-.783-.57-.38-1.81.588-1.81h3.461a1 1 0 00.951-.69l1.07-3.292z"})),e.isForeign&&d.createElement("div",{className:"w-2 h-2 bg-blue-500 rounded-full"}),!e.isPrimary&&!e.isForeign&&d.createElement("svg",{className:"w-3 h-3 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},d.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})),d.createElement("span",{className:"font-medium text-gray-700"},e.name)),d.createElement("span",{className:"text-gray-500 font-mono text-xs"},e.type))}))):null)))};var T="invoice_transaction",D="hierarchical",R="plan_subscription";const _=function(e){var t=e.isOpen,n=e.onClose,a=e.onOpenSchemaModal,r=(0,d.useState)(T),s=(0,c.A)(r,2),o=s[0],l=s[1],i=(0,d.useState)(!1),m=(0,c.A)(i,2),u=m[0],p=m[1];if(!t)return null;var g={entities:[{id:"transactions",name:"transactions",icon:y.CreditCard,color:"bg-emerald-50 border-emerald-200",iconColor:"text-emerald-600",x:50,y:50,fields:[{name:"transaction_id",type:"VARCHAR(50)",isPrimary:!0,required:!0},{name:"customer_id",type:"VARCHAR(50)",isForeign:!0,references:"CUSTOMER.id",required:!0},{name:"group_id",type:"VARCHAR(50)",required:!0},{name:"customer_name",type:"VARCHAR(255)",required:!0},{name:"transaction_amount",type:"Float",required:!0},{name:"transaction_type",type:"ENUM",required:!0},{name:"transaction_currency",type:"VARCHAR(3)",required:!0},{name:"transaction_status",type:"VARCHAR(50)",required:!0},{name:"line_item_type",type:"ENUM",required:!0},{name:"date",type:"TIMESTAMP",required:!0},{name:"invoice_id",type:"VARCHAR(50)",isForeign:!0,references:"INVOICES.id",required:!1}]},{id:"invoices",name:"invoices",icon:y.FileText,color:"bg-indigo-50 border-indigo-200",iconColor:"text-indigo-600",x:450,y:50,fields:[{name:"id",type:"VARCHAR(50)",isPrimary:!0,required:!0},{name:"customer_id",type:"VARCHAR(50)",isForeign:!0,references:"CUSTOMER.id",required:!0},{name:"group_id",type:"VARCHAR(50)",required:!0},{name:"issue_date",type:"DATE",required:!0},{name:"invoice_amount",type:"Float",required:!0},{name:"currency",type:"VARCHAR(3)",required:!0},{name:"due_date",type:"DATE",required:!1}]},{id:"invoice_payments",name:"invoice_payments",icon:y.Receipt,color:"bg-pink-50 border-pink-200",iconColor:"text-pink-600",x:50,y:350,fields:[{name:"id",type:"VARCHAR(50)",isPrimary:!0,required:!0},{name:"invoice_id",type:"VARCHAR(50)",isForeign:!0,references:"invoices.id",required:!0},{name:"amount",type:"Float",required:!0},{name:"status",type:"VARCHAR(50)",required:!0},{name:"created_at",type:"TIMESTAMP",required:!0}]}],relationships:[{from:"invoices",to:"transactions",label:"paid_by",cardinality:"1:many"},{from:"invoices",to:"invoice_payments",label:"has",cardinality:"1:many"}]},f={entities:[{id:"plans",name:"plans",icon:y.Calendar,color:"bg-blue-50 border-blue-200",iconColor:"text-blue-600",x:50,y:50,fields:[{name:"plan_id",type:"VARCHAR(50)",isPrimary:!0,required:!0},{name:"plan_name",type:"VARCHAR(255)",required:!0},{name:"billing_scheme",type:"VARCHAR(50)",required:!0},{name:"amount",type:"Float",required:!0},{name:"currency",type:"VARCHAR(3)",required:!0},{name:"interval_of_billing",type:"VARCHAR(20)",required:!0},{name:"interval_count",type:"INT",required:!0},{name:"trial_period_days",type:"INT",required:!1}]},{id:"subscriptions",name:"subscriptions",icon:y.Database,color:"bg-purple-50 border-purple-200",iconColor:"text-purple-600",x:400,y:50,fields:[{name:"id",type:"VARCHAR(50)",isPrimary:!0,required:!0},{name:"customer_id",type:"VARCHAR(50)",isForeign:!0,references:"CUSTOMER.id",required:!0},{name:"plan_id",type:"VARCHAR(50)",isForeign:!0,references:"PLANS.plan_id",required:!0},{name:"billing_type",type:"VARCHAR(50)",required:!0},{name:"status",type:"VARCHAR(50)",required:!0},{name:"currency",type:"VARCHAR(3)",required:!0},{name:"start_date",type:"TIMESTAMP",required:!0},{name:"end_date",type:"TIMESTAMP",required:!1},{name:"trial_start_date",type:"TIMESTAMP",required:!1},{name:"trial_end_date",type:"TIMESTAMP",required:!1}]}],relationships:[{from:"plans",to:"subscriptions",label:"defines",cardinality:"1:many"}]},b={entities:[{id:"plan",name:"plan",icon:y.Calendar,color:"bg-blue-50 border-blue-200",iconColor:"text-blue-600",x:50,y:50,fields:[{name:"id",type:"int",isPrimary:!0,required:!0},{name:"name",type:"string",required:!0},{name:"interval_count",type:"int",required:!0},{name:"interval_unit",type:"string",required:!0},{name:"plan_id",type:"string",required:!0},{name:"created_at",type:"timestamp",required:!0},{name:"currency",type:"VARCHAR(3)",required:!1},{name:"trial_period_days",type:"int",required:!1},{name:"amount",type:"bigint",required:!1}]},{id:"customer",name:"customer",icon:y.Users,color:"bg-green-50 border-green-200",iconColor:"text-green-600",x:50,y:300,fields:[{name:"id",type:"int",isPrimary:!0,required:!0},{name:"name",type:"string",required:!0},{name:"email",type:"string",required:!1},{name:"company",type:"string",required:!0},{name:"country",type:"string",required:!0},{name:"state",type:"string",required:!1},{name:"city",type:"string",required:!1},{name:"zip",type:"string",required:!1},{name:"created_at",type:"timestamp",required:!1},{name:"trail_start_date",type:"timestamp",required:!1},{name:"balance",type:"bigint",required:!1},{name:"currency",type:"bigint",required:!1},{name:"delinquent",type:"boolean",required:!0}]},{id:"subscription",name:"subscription",icon:y.Database,color:"bg-purple-50 border-purple-200",iconColor:"text-purple-600",x:400,y:175,fields:[{name:"id",type:"int",isPrimary:!0,required:!0},{name:"customer_id",type:"int",isForeign:!0,references:"CUSTOMER.id",required:!0},{name:"plan_id",type:"int",isForeign:!0,references:"PLAN.id",required:!0},{name:"event_type",type:"string",required:!0},{name:"currency",type:"VARCHAR(3)",required:!0},{name:"amount",type:"bigint",required:!0},{name:"quantity",type:"int",required:!0},{name:"start_at",type:"timestamp",required:!0},{name:"status",type:"string",required:!0},{name:"current_term_end",type:"timestamp",required:!0},{name:"current_term_start",type:"timestamp",required:!0},{name:"trial_start",type:"timestamp",required:!1},{name:"trial_end",type:"timestamp",required:!1},{name:"latest_invoice_id",type:"VARCHAR(50)",required:!1}]},{id:"subscription_events",name:"subscription_events",icon:y.TrendingUp,color:"bg-orange-50 border-orange-200",iconColor:"text-orange-600",x:700,y:100,fields:[{name:"event_id",type:"int",isPrimary:!0,required:!0},{name:"subscription_id",type:"int",isForeign:!0,references:"SUBSCRIPTION.id",required:!0},{name:"customer_id",type:"int",isForeign:!0,references:"CUSTOMER.id",required:!0},{name:"event_type",type:"string",required:!0},{name:"subscription_status",type:"string",required:!0},{name:"date",type:"timestamp",required:!0},{name:"effective_date",type:"timestamp",required:!0},{name:"plan_id",type:"int",isForeign:!0,references:"PLAN.id",required:!0},{name:"currency",type:"VARCHAR(3)",required:!0},{name:"amount",type:"bigint",required:!0},{name:"quantity",type:"int",required:!0}]},{id:"invoice_line_items",name:"invoice_line_items",icon:y.Receipt,color:"bg-pink-50 border-pink-200",iconColor:"text-pink-600",x:50,y:650,fields:[{name:"id",type:"int",isPrimary:!0,required:!0},{name:"invoice_id",type:"int",isForeign:!0,references:"INVOICES.id",required:!0},{name:"subscription_id",type:"int",isForeign:!0,references:"SUBSCRIPTION.id",required:!0},{name:"type",type:"string",required:!0},{name:"amount",type:"bigint",required:!0},{name:"plan_id",type:"int",isForeign:!0,references:"PLAN.id",required:!0},{name:"period_start",type:"timestamp",required:!0},{name:"period_end",type:"timestamp",required:!0},{name:"quantity",type:"int",required:!0},{name:"proration",type:"boolean",required:!0},{name:"proration_type",type:"string",required:!1},{name:"discount_amount",type:"bigint",required:!1},{name:"tax_amount",type:"bigint",required:!1},{name:"description",type:"string",required:!1},{name:"transaction_fees",type:"bigint",required:!1},{name:"transaction_fees_currency",type:"VARCHAR(3)",required:!1},{name:"balance_transfer",type:"boolean",required:!1},{name:"currency",type:"VARCHAr(3)",required:!1}]},{id:"invoices",name:"invoices",icon:y.FileText,color:"bg-indigo-50 border-indigo-200",iconColor:"text-indigo-600",x:400,y:600,fields:[{name:"id",type:"int",isPrimary:!0,required:!0},{name:"customer_id",type:"int",isForeign:!0,references:"CUSTOMER.id",required:!0},{name:"amount",type:"bigint",required:!0},{name:"issue_date",type:"date",required:!0},{name:"due_date",type:"date",required:!0},{name:"currency",type:"VARCHAR(3)",required:!0},{name:"status",type:"VARCHAR(10)",required:!0}]},{id:"transactions",name:"transactions",icon:y.CreditCard,color:"bg-emerald-50 border-emerald-200",iconColor:"text-emerald-600",x:700,y:500,fields:[{name:"id",type:"int",isPrimary:!0,required:!0},{name:"invoice_id",type:"int",isForeign:!0,references:"INVOICES.id",required:!0},{name:"type",type:"string",required:!0},{name:"result",type:"string",required:!0},{name:"date",type:"timestamp",required:!0}]}],relationships:[{from:"plan",to:"subscription",label:"defines",cardinality:"1:many"},{from:"customer",to:"subscription",label:"has",cardinality:"1:many"},{from:"customer",to:"invoices",label:"receives",cardinality:"1:many"},{from:"subscription",to:"subscription_events",label:"generates",cardinality:"1:many"},{from:"subscription_events",to:"plan",label:"references",cardinality:"many:1"},{from:"subscription",to:"invoice_line_items",label:"bills_for",cardinality:"1:many"},{from:"invoices",to:"invoice_line_items",label:"contains",cardinality:"1:many"},{from:"invoices",to:"transactions",label:"paid_by",cardinality:"1:many"}]},v=[{id:T,label:"Transactions + Invoices",description:"Transaction and invoices data",schema:g},{id:D,label:"Complete Revenue Data",description:"Complete entity relationships",schema:b},{id:R,label:"Plan + Subscription",description:"Subscription plans and customer subscriptions",schema:f}],x=v.find(function(e){return e.id===o}),h=function(){p(!1)};return u?d.createElement("div",{className:"fixed inset-0 z-20 top-9 right-0 bg-white flex flex-col"},d.createElement("div",{className:"flex items-center justify-between p-4 border-b border-gray-200 bg-gray-50 flex-shrink-0"},d.createElement("div",{className:"flex items-center space-x-3"},d.createElement("div",{className:"p-2 bg-blue-100 rounded-lg"},d.createElement(y.Database,{className:"w-6 h-6 text-blue-600"})),d.createElement("div",{className:"ms-4"},d.createElement("h2",{className:"ms-4 text-xl font-semibold text-gray-900"},null==x?void 0:x.label," - ER Diagram"),d.createElement("p",{className:"ms-4 text-sm text-gray-600"},null==x?void 0:x.description))),d.createElement("button",{onClick:h,className:"p-2 hover:bg-gray-200 rounded-lg transition-colors"},d.createElement(y.X,{className:"w-5 h-5 text-gray-500"}))),d.createElement("div",{className:"flex-1 overflow-auto p-8 scrollbar-hide"},d.createElement("div",{className:"flex justify-center items-start min-h-full"},d.createElement("div",{className:"w-full max-w-6xl"},x&&d.createElement(I,{entities:x.schema.entities,relationships:x.schema.relationships,isFullscreen:!0,onExitFullscreen:h}))))):d.createElement("div",{className:"fixed inset-0 z-20 overflow-hidden mt-6"},d.createElement("div",{className:"absolute inset-0 bg-black bg-opacity-50 mt-6",onClick:n}),d.createElement("div",{className:"absolute right-0 top-0 h-full w-full max-w-7xl bg-white shadow-xl mt-6"},d.createElement("div",{className:"flex items-center p-6 border-b border-gray-200 bg-gray-50"},d.createElement("div",{className:"flex items-center"},d.createElement("div",{className:"p-2 bg-blue-100 rounded-lg me-4"},d.createElement(y.Database,{className:"w-6 h-6 text-blue-600"})),d.createElement("div",null,d.createElement("h2",{className:"text-xl font-semibold text-gray-900"},"Entity Relationship Diagram"),d.createElement("p",{className:"text-sm text-gray-600"},"Choose your data structure and view the ER diagram"))),d.createElement("button",{className:"ml-auto text-blue-600 hover:text-blue-800 underline hover:underline-offset-2 bg-transparent px-0 py-0 text-sm font-medium transition-colors flex items-center gap-1",onClick:a},"Dev Guide: Data Model Schema"),d.createElement("button",{onClick:n,className:"p-2 hover:bg-gray-200 rounded-lg transition-colors"},d.createElement(y.X,{className:"w-5 h-5 text-gray-500"}))),d.createElement("div",{className:"border-b border-gray-200"},d.createElement("nav",{className:"flex space-x-8 px-6"},v.map(function(e){return d.createElement("button",{key:e.id,onClick:function(){return l(e.id)},className:"py-4 px-1 border-b-2 font-medium text-sm transition-colors ".concat(o===e.id?"border-blue-500 text-blue-600":"border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300")},e.label)}))),d.createElement("div",{className:"flex-1 overflow-auto"},x&&d.createElement("div",{className:"h-full min-h-[800px]"},d.createElement("div",{className:"p-4 pl-7 bg-blue-50 border-b border-blue-200"},d.createElement("h3",{className:"font-medium text-blue-900 mb-1"},x.label),d.createElement("p",{className:"text-sm text-blue-800"},x.description)),d.createElement("div",{className:"h-[calc(100vh-200px)] min-h-[600px] p-4 ms-5"},d.createElement(I,{entities:x.schema.entities,relati
1onships:x.schema.relationships,isFullscreen:!1,onFullscreen:function(){p(!0)}}))))))};var P=n(18330),O=n(4235),M=n(44170),F=n(69540),K=[{id:"chargebee",label:"Chargebee",icon:d.createElement("img",{src:w,alt:"Chargebee",className:"w-3.5 h-3.5 object-contain"})},{id:"stripe-billing",label:"Stripe billing",icon:d.createElement(N.kDV,{className:"w-3.5 h-3.5 text-[#635BFF]"})}],j=[{id:"stripe",label:"Stripe",icon:d.createElement(N.kDV,{className:"w-3.5 h-3.5 text-[#635BFF]"})},{id:"quickbooks",label:"QuickBooks",icon:d.createElement(N._pZ,{className:"w-3.5 h-3.5 text-[#2CA01C]"})},{id:"api",label:"API",icon:d.createElement(y.Code2,{className:"w-3.5 h-3.5 text-gray-500"})},{id:"csv",label:"CSV upload",icon:d.createElement(y.FileUp,{className:"w-3.5 h-3.5 text-gray-500"})}],q=[{id:"subscription",icon:y.CreditCard,iconBg:"bg-blue-50",iconColor:"text-blue-600",title:"Subscription management",description:"Your primary billing platform. Tracks customers, plans, billing cycles and subscription events.",tags:K},{id:"transactions",icon:y.Receipt,iconBg:"bg-purple-50",iconColor:"text-purple-600",title:"Transactions & Invoices",description:"Direct payments, marketplace charges, or revenue that flows outside your subscription system.",tags:j}],L=[{id:"chargebee",name:"Chargebee",description:"Subscription and billing management platform",features:["Auto-sync subscriptions","Customer data","Invoice tracking","Real-time updates"],logoType:"chargebee"},{id:"stripe",name:"Stripe",description:"Recurring billing via Stripe's subscription product",features:["Auto-sync payments","Customer data","Subscription tracking","Real-time updates"],logoType:"stripe"}],U=[{id:"stripe",name:"Stripe",description:"Marketplace or direct charges outside subscription billing",features:["Real-time sync","Webhook support","Direct charges","Marketplace support"],iconType:"stripe",comingSoon:!1,beta:!1,needsDataModel:!1},{id:"quickbooks",name:"QuickBooks",description:"Sync invoices and transactions from QuickBooks Online",features:["Invoice sync","Transaction import","OAuth 2.0","Sandbox support"],iconType:"quickbooks",comingSoon:!1,beta:!0,needsDataModel:!1,needsSetup:!1,demoOnly:!1},{id:"api",name:"API integration",description:"REST API push â real-time or bulk",features:["Real-time sync","Bulk operations","Webhook support","Authentication"],icon:y.Code2,iconType:"lucide",iconColor:"text-blue-600",comingSoon:!1,beta:!1,needsDataModel:!1,needsSetup:!1},{id:"csv",name:"Manual CSV upload",description:"One-time or historical import",features:["One-time import","Historical data","Bulk processing","Data validation"],icon:y.FileUp,iconType:"lucide",iconColor:"text-green-600",comingSoon:!1,beta:!0,needsDataModel:!1,needsSetup:!1},{id:"salesforce",name:"Salesforce",description:"Import from your Salesforce CRM",features:["CRM integration","Lead tracking","Opportunity sync","Custom fields"],icon:y.Building2,iconType:"lucide",iconColor:"text-gray-400",comingSoon:!0,beta:!1,needsDataModel:!1,needsSetup:!1,demoOnly:!1}],V=[{value:M.ko.INVOICE_TRANSACTION,label:"Transactions + Invoices",description:"Individual payment records without the need for linked subscription IDs or subscription-level details.",entities:["transactions","invoices"],icon:y.FileText,iconColor:"text-blue-600",disabled:!1},{value:M.ko.HIERARCHICAL,label:"Complete Revenue Data",description:"Complete entity relationships â customers, invoices, transactions, plans, and subscriptions.",entities:["customers","invoices","transactions","plans","subscriptions"],icon:y.Database,iconColor:"text-purple-600",disabled:!0},{value:M.ko.PLAN_SUBSCRIPTION,label:"Plan + Subscription",description:"Subscription plans and customer subscriptions.",entities:["plans","subscriptions"],icon:y.LayoutList,iconColor:"text-green-600",disabled:!0}],B=function(){return d.createElement("div",{className:"absolute top-4 right-4 w-5 h-5 bg-primaryColor rounded-full flex items-center justify-center"},d.createElement("svg",{className:"w-3 h-3 text-white",fill:"currentColor",viewBox:"0 0 20 20"},d.createElement("path",{fillRule:"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z",clipRule:"evenodd"})))};function z(e){var t,n,a=e.alreadyConfiguredSourceIds,r=void 0===a?[]:a,s=e.forceReset,o=void 0!==s&&s,i=(0,P.useDispatch)(),m=(0,F._K)(),u=m.isDemoMode,p=m.toggleDemoMode,g=(0,P.useSelector)(function(e){var t;return null!==(t=e.revenueAnalytics.selectedSources)&&void 0!==t?t:[]}),f=(0,P.useSelector)(function(e){var t;return null!==(t=e.revenueAnalytics.sourceConfigurations)&&void 0!==t?t:{}}),b=(0,P.useSelector)(function(e){return e.revenueAnalytics.selectedDataType}),v=(0,P.useSelector)(function(e){return e.revenueAnalytics.activeSourceTab}),x=!o&&v&&g.includes(v)?v:o?void 0:g[0],h=(0,d.useState)(function(){var e,t;return o||!x?null:null!==(e=null===(t=f[x])||void 0===t?void 0:t.sourceCategory)&&void 0!==e?e:null}),E=(0,c.A)(h,2),C=E[0],S=E[1],k=(0,d.useState)(function(){var e,t;if(o||!x)return null;var n=x,a=null!==(e=null===(t=f[n])||void 0===t?void 0:t.sourceCategory)&&void 0!==e?e:null;if(!a)return null;
1var r=[].concat(L,U).find(function(e){return e.id===n});return r?{id:r.id,name:r.name,category:a}:null}),A=(0,c.A)(k,2),I=A[0],T=A[1],D=(0,d.useState)(function(){return o?M.ko.INVOICE_TRANSACTION:b||M.ko.INVOICE_TRANSACTION}),R=(0,c.A)(D,2),_=R[0],K=R[1],j=(0,d.useState)(function(){var e,t,n;if(o||!x)return 1;var a=x;if(!(null===(e=f[a])||void 0===e?void 0:e.sourceCategory))return 1;var r=[].concat(L,U).find(function(e){return e.id===a}),s=null!==(t=null===(n=U.find(function(e){return e.id===a}))||void 0===n?void 0:n.needsDataModel)&&void 0!==t&&t;return r&&s&&b?3:r?2:1}),z=(0,c.A)(j,2),W=z[0],H=z[1],G=["chargebee","stripe"].some(function(e){return r.includes(e)}),J="subscription"===C?L:U.filter(function(e){return!e.demoOnly||u}),Z=I?U.find(function(e){return e.id===I.id}):null,Y=null!==(t=null==Z?void 0:Z.needsDataModel)&&void 0!==t&&t,X=null!==(n=null==Z?void 0:Z.needsSetup)&&void 0!==n&&n,Q=Y||X,$=(0,d.useCallback)(function(e,t){var n=Array.from(new Set([].concat((0,l.A)(g),[e.id])));i((0,O.x)({key:"selectedSources",value:n})),i((0,O.x)({key:"selectedDataType",value:t})),i((0,O.x)({key:"activeSourceTab",value:e.id})),"chargebee"===e.id&&i((0,O.x)({key:"selectedProvider",value:"chargebee"})),"stripe"===e.id&&i((0,O.x)({key:"selectedProvider",value:"stripe"})),i((0,O.Th)({sourceId:e.id,config:{sourceCategory:e.category}}))},[i,g]),ee=function(){C&&H(2)},te=function(){I&&Q&&H(3)},ne=function(){return d.createElement("div",{className:"space-y-4"},d.createElement("div",{className:"grid grid-cols-2 gap-3"},q.map(function(e){var t=e.icon,n=C===e.id;return d.createElement("button",{key:e.id,onClick:function(){return function(e){C!==e&&(T(null),K(M.ko.INVOICE_TRANSACTION)),S(e)}(e.id)},className:"relative p-4 border-2 rounded-xl text-left transition-all ".concat(n?"border-primaryColor bg-primaryExtremeLightColor":"border-gray-200 bg-white hover:border-gray-300")},n&&d.createElement(B,null),d.createElement("div",{className:"flex items-start gap-3"},d.createElement("div",{className:"p-2 rounded-lg shrink-0 ".concat(n?"bg-blue-100":e.iconBg)},d.createElement(t,{className:"w-5 h-5 ".concat(e.iconColor)})),d.createElement("div",{className:"flex-1"},d.createElement("h4",{className:"font-semibold text-gray-900 text-sm mb-1"},e.title),d.createElement("p",{className:"text-xs text-gray-500 leading-relaxed mb-2"},e.description),d.createElement("div",{className:"flex flex-wrap gap-1"},e.tags.map(function(e){return d.createElement("span",{key:e.id,title:e.label,className:"relative group inline-flex items-center justify-center w-6 h-6 rounded bg-gray-100 cursor-default"},e.icon,d.createElement("span",{className:"pointer-events-none absolute bottom-full left-1/2 -translate-x-1/2 mb-1.5 whitespace-nowrap rounded px-1.5 py-0.5 text-xs font-medium bg-gray-800 text-white opacity-0 group-hover:opacity-100 transition-opacity z-10"},e.label))})))))})),"transactions"===C&&G&&d.createElement("div",{className:"flex items-start gap-2"},d.createElement(y.Info,{className:"w-4 h-4 text-gray-400 mt-0.5 shrink-0"}),d.createElement("p",{className:"text-sm text-gray-600"},"This will only enable ",d.createElement("span",{className:"font-semibold"},"transaction and invoice tracking"),". Subscription-level metrics from your existing integration will remain unaffected.")),"transactions"===C&&!G&&d.createElement("div",{className:"flex items-start gap-2"},d.createElement(y.AlertTriangle,{className:"w-4 h-4 text-amber-500 mt-0.5 shrink-0"}),d.createElement("div",null,d.createElement("p",{className:"text-sm font-semibold text-gray-800"},"No subscription management source connected"),d.createElement("p",{className:"text-sm text-gray-600 mt-0.5"},"Without a subscription source (Chargebee or Stripe Billing), you will miss out on subscription-level metrics such as MRR, churn, and plan-level breakdowns."))),d.createElement("div",{className:"flex items-center justify-between pt-1"},u?d.createElement("span",null):d.createElement("button",{onClick:function(){return p("/analyze/dashboard")},className:"text-xs text-gray-400 hover:text-gray-600 transition-colors"},"Skip setup, try demo mode â"),d.createElement("button",{onClick:ee,disabled:!C,className:"px-4 py-2 rounded-lg text-sm font-semibold transition-colors ".concat(C?"bg-primaryColor text-white hover:bg-primaryDarkColor":"bg-gray-100 text-gray-400 cursor-not-allowed")},"transactions"!==C||G?"Next":"Proceed anyway")))},ae=function(){var e=J;return d.createElement("div",{className:"space-y-4"},d.createElement("div",{className:"grid grid-cols-2 gap-3"},e.map(function(e){var t=r.includes(e.id),n=e.comingSoon||t,a=(null==I?void 0:I.id)===e.id;return d.createElement("button",{key:e.id,disabled:n,onClick:function(){return!n&&function(e){T(e);var t=U.find(function(t){return t.id===e.id});null!=t&&t.needsDataModel||null!=t&&t.needsSetup||$(e,M.ko.INVOICE_TRANSACTION)}({id:e.id,name:e.name,category:C})},className:"relative p-4 border-2 rounded-xl text-left transition-all ".concat(a?"border-primaryColor bg-primaryExtremeLightColor":n?"border-gray-200 bg-gray-50 cursor-not-allowed opacity-60":"border-gray-200 bg-white hover:border-gray-300")},a&&d.createElement(B,null),e.comingSoon&&d.createElement("span",{className:"absolute top-3 right-3 inline-flex items-center gap-1 text-xs font-medium bg-yellow-50 text-yellow-700 px-2 py-0.5 rounded"},d.createElement(y.Clock,{className:"w-3 h-3"}),"Coming soon"),e.beta&&!e.comingSoon&&d.createElement("span",{className:"absolute top-3 right-3 text-xs font-medium bg-amber-50 text-amber-700 px-2 py-0.5 rounded"},"Beta"),t&&!e.comingSoon&&d.createElement("span",{className:"absolute top-3 right-3 text-xs font-medium text-amber-700 bg-amber-50 px-2 py-0.5 rounded"},"Configured"),d.createElement("div",{className:"flex items-start gap-3"},d.createElement("div",{className:"p-2 rounded-lg shrink-0 ".concat(a?"bg-blue-100":n?"bg-gray-100":"bg-white shadow-sm")},"chargebee"===e.logoType?d.createElement("img",{src:w,alt:"Chargebee",className:"w-5 h-5 object-contain"}):"stripe"===e.logoType||"stripe"===e.iconType?d.createElement(N.kDV,{className:"w-5 h-5 ".concat(e.comingSoon?"text-gray-300":"text-[#635BFF]")}):"quickbooks"===e.iconType?d.createElement(N._pZ,{className:"w-5 h-5 ".concat(e.comingSoon?"text-gray-300":"text-[#2CA01C]")}):d.createElement(e.icon,{className:"w-5 h-5 ".concat(e.comingSoon?"text-gray-300":e.iconColor)})),d.createElement("div",{className:"flex-1"},d.createElement("h3",{className:"font-semibold text-sm mb-1 ".concat(e.comingSoon?"text-gray-400":"text-gray-900")},e.name),d.createElement("p",{className:"text-xs mb-1.5 ".concat(e.comingSoon?"text-gray-400":"text-gray-500")},e.description),d.createElement("div",{className:"space-y-0.5"},e.features.map(function(t){return d.createElement("div",{key:t,className:"flex items-center gap-1.5"},d.createElement("span",{className:"w-1.5 h-1.5 rounded-full shrink-0 ".concat(e.comingSoon?"bg-gray-300":"bg-blue-500")}),d.createElement("span",{className:"text-xs ".concat(e.comingSoon?"text-gray-400":"text-gray-500")},t))})))))})),Y&&d.createElement("div",{className:"flex justify-end pt-1"},d.createElement("button",{onClick:te,disabled:!I,className:"px-4 py-2 rounded-lg text-sm font-semibold transition-colors ".concat(I?"bg-primaryColor text-white hover:bg-primaryDarkColor":"bg-gray-100 text-gray-400 cursor-not-allowed")},"Next")))},re=function(e){return 1===e?ne():2===e?ae():3===e?d.createElement("div",{className:"space-y-4"},d.createElement("div",{className:"space-y-2"},V.map(function(e){var t=e.icon,n=_===e.value;return d.createElement("button",{key:e.value,disabled:e.disabled,onClick:function(){!e.disabled&&I&&(K(e.value),$(I,e.value))},className:"relative w-full p-4 border-2 rounded-xl text-left transition-all ".concat(n?"border-primaryColor bg-primaryExtremeLightColor":e.disabled?"border-gray-200 bg-gray-50 cursor-not-allowed opacity-50":"border-gray-200 bg-white hover:border-gray-300")},e.disabled&&d.createElement("span",{className:"absolute top-3 right-3 text-xs font-medium bg-gray-100 text-gray-500 px-2 py-0.5 rounded"},"Coming soon"),n&&d.createElement(B,null),d.createElement("div",{className:"flex items-start gap-3"},d.createElement("div",{className:"p-2 rounded-lg shrink-0 ".concat(n?"bg-blue-100":e.disabled?"bg-gray-100":"bg-white shadow-sm")},d.createElement(t,{className:"w-5 h-5 ".concat(e.disabled?"text-gray-400":e.iconColor)})),d.createElement("div",{className:"flex-1"},d.createElement("p",{className:"font-semibold text-sm ".concat(e.disabled?"text-gray-400":"text-gray-900")},e.label),d.createElement("p",{className:"text-xs mt-0.5 ".concat(e.disabled?"text-gray-400":"text-gray-500")},e.description),d.createElement("div",{className:"flex flex-wrap gap-1 mt-1.5"},e.entities.map(function(t){return d.createElement("span",{key:t,className:"text-xs px-1.5 py-0.5 rounded font-mono ".concat(e.disabled?"bg-gray-100 text-gray-400":n?"bg-blue-100 text-blue-700":"bg-gray-100 text-gray-600")},t)}
1)))))}))):null},se=Y||W>=3?[1,2,3]:[1,2];return d.createElement("div",{className:"space-y-0 relative"},d.createElement("div",{className:"absolute left-[18px] top-8 bottom-8 w-px bg-gray-200 z-0"}),se.map(function(e){var t=function(e){return 1===e?null!==C&&W>1:2===e&&null!==I&&W>2}(e),n=function(e){return e>W}(e),a=W===e;return d.createElement("div",{key:e,className:"relative z-10"},d.createElement("div",{className:"flex items-center gap-3 px-1 py-3 cursor-pointer select-none ".concat(n?"opacity-40 cursor-not-allowed":""),onClick:function(){n||t&&H(e)}},d.createElement("div",{className:"w-9 h-9 rounded-full flex items-center justify-center shrink-0 border-2 text-sm font-bold z-10 ".concat(t?"bg-green-500 border-green-500 text-white":a?"bg-primaryColor border-primaryColor text-white":"bg-white border-gray-300 text-gray-400")},t?d.createElement(y.CheckCircle,{className:"w-4 h-4"}):e),d.createElement("div",{className:"flex-1 flex items-center justify-between"},d.createElement("div",null,d.createElement("p",{className:"text-sm font-bold ".concat(n?"text-gray-400":"text-gray-900")},function(e){return 1===e?"Source type":2===e?"Source":3===e?X?"Configure":"Data model":""}(e)),t?d.createElement("p",{className:"text-xs text-green-700 font-medium mt-0.5"},function(e){var t,n,a,r;return 1===e&&C?null!==(t=null===(n=q.find(function(e){return e.id===C}))||void 0===n?void 0:n.title)&&void 0!==t?t:"":2===e&&I?I.name:3===e&&null!==(a=null===(r=V.find(function(e){return e.value===_}))||void 0===r?void 0:r.label)&&void 0!==a?a:""}(e)):d.createElement("p",{className:"text-xs mt-0.5 ".concat(n?"text-gray-300":"text-gray-500")},function(e){return 1===e?"Choose between subscription management or transaction-based billing":2===e?"subscription"===C?"Select your billing platform to connect":"Select how your transaction data will be ingested":3===e?X?"Enter your credentials to connect":"Choose the data structure that matches your revenue setup":""}(e))),t&&d.createElement("button",{onClick:function(t){t.stopPropagation(),H(e),T(null)},className:"p-1 text-gray-400 hover:text-gray-600 transition-colors"},d.createElement(y.Pencil,{className:"w-3.5 h-3.5"})),!t&&d.createElement(y.ChevronDown,{className:"w-4 h-4 text-gray-400 transition-transform ".concat(a?"rotate-180":"")}))),a&&d.createElement("div",{className:"ml-12 pb-4"},re(e)))}))}const W=(0,d.forwardRef)(function(e,t){var n=e.loading,a=void 0!==n&&n,r=e.isSchemaDrawerOpen,s=e.openSchemaModal,o=e.openSchemaDrawer,l=e.closeAllModals,i=e.alreadyConfiguredSourceIds,c=void 0===i?[]:i,m=e.forceReset,u=void 0!==m&&m,p=e.connectionDraftKey,g=void 0===p?0:p;return d.createElement("div",{className:"space-y-6"},d.createElement("div",{className:"flex items-start justify-between gap-4"},d.createElement("div",{className:"flex items-start gap-3"},d.createElement("div",{className:"shrink-0 p-2 rounded-lg bg-primaryExtremeLightColor mt-0.5"},d.createElement(y.DatabaseZap,{className:"w-6 h-6 text-primaryColor"})),d.createElement("div",null,d.createElement("p",{className:"text-xs font-semibold uppercase tracking-wider text-gray-400 mb-0.5"},"Step 1"),d.createElement("h2",{className:"text-xl font-bold text-gray-900 leading-tight"},"Data Collection Method"),d.createElement("p",{className:"text-sm text-gray-500 mt-1"},"Connect a revenue data source to power your intelligence dashboard."))),d.createElement("button",{onClick:o,className:"shrink-0 text-blue-600 hover:text-blue-800 underline hover:underline-offset-2 bg-transparent px-0 py-0 text-sm font-medium transition-colors flex items-center gap-1 mt-1"},d.createElement(y.Database,{className:"w-4 h-4"}),d.createElement("span",null,"Dev Guide: ER Diagram"))),a?d.createElement("div",{className:"flex items-center justify-center h-64"},d.createElement("div",{className:"text-gray-500"},"Loading...")):d.createElement("div",{className:"p-6"},d.createElement(z,{key:g,alreadyConfiguredSourceIds:c,forceReset:u})),d.createElement(_,{isOpen:r,onClose:l,onOpenSchemaModal:s}))});var H=n(60749),G=n(45737),J=n(54361),Z=n(74381),Y=function(e){var t=e.isOpen,n=e.onClose,a=e.onConfirm,r=e.onEdit,s=e.subStep,o=e.fieldMapping,l=e.isRetry;if(!t||!s)return null;var i=s.fields.required||[],c=s.fields.optional||[],m=i.filter(function(e){return o[e.fieldName]}),u=c.filter(function(e){return o[e.fieldName]});return d.createElement("div",{className:"fixed inset-0 z-50 overflow-y-auto"},d.createElement("div",{className:"flex min-h-screen items-center justify-center p-4"},d.createElement("div",{className:"fixed inset-0 bg-black bg-opacity-50 transition-opacity",onClick:n}),d.createElement("div",{className:"relative bg-white rounded-lg shadow-xl w-full max-w-6xl max-h-[90vh] overflow-hidden"},d.createElement("div",{className:"flex items-center justify-between p-6 border-b border-gray-200 bg-gray-50"},d.createElement("div",null,d.createElement("h2",{className:"text-xl font-semibold text-gray-900"},l?"Retry Import - ":"Confirm Import - ",s.title),d.createElement("p",{className:"text-sm text-gray-600 mt-1"},"Review your field mappings before ",l?"retrying":"starting"," the import")),d.createElement("button",{onClick:n,className:"text-gray-400 hover:text-gray-600 transition-colors"},d.createElement(y.X,{size:24}))),d.createElement("div",{className:"px-6 py-4 bg-white border-b border-gray-100"},d.createElement("div",{className:"flex items-center justify-between"},d.createElement("div",{className:"flex items-center gap-6 text-sm"},d.createElement("div",{className:"flex items-center gap-2"},d.createElement("div",{className:"w-3 h-3 bg-red-200 rounded-full"}),d.createElement("span",{className:"font-medium text-gray-900"},"Required:"),d.createElement("span",{className:"font-semibold"},m.length,"/",i.length)),d.createElement("div",{className:"flex items-center gap-2"},d.createElement("div",{className:"w-3 h-3 bg-yellow-200 rounded-full"}),d.createElement("span",{className:"font-medium text-gray-900"},"Optional:"),d.createElement("span",{className:"font-semibold text-gray-600"},u.length,"/",c.length)),d.createElement("div",{className:"flex items-center gap-2"},d.createElement("span",{className:"font-medium text-gray-900"},"Total Mapped:"),d.createElement("span",{className:"font-semibold"},m.length+u.length))),m.length<i.length&&d.createElement("div",{className:"flex items-center gap-2 text-red-600"},d.createElement(y.AlertTriangle,{className:"w-4 h-4"}),d.createElement("span",{className:"text-sm font-medium"},"Missing required fields")))),d.createElement("div",{className:"p-6 overflow-y-auto max-h-[calc(90vh-240px)]"},d.createElement("div",{className:"overflow-hidden rounded-lg border border-gray-200"},d.createElement("table",{className:"w-full"},d.createElement("thead",{className:"bg-gray-50"},d.createElement("tr",null,d.createElement("th",{className:"px-4 py-3 text-left text-xs font-semibold text-gray-900 uppercase tracking-wider"},"Field Name"),d.createElement("th",{className:"px-4 py-3 text-left text-xs font-semibold text-gray-900 uppercase tracking-wider"},"Type"),d.createElement("th",{className:"px-4 py-3 text-left text-xs font-semibold text-gray-900 uppercase tracking-wider"},"CSV Column"),d.createElement("th",{className:"px-4 py-3 text-left text-xs font-semibold text-gray-900 uppercase tracking-wider"},"Status"))),d.createElement("tbody",{className:"bg-white divide-y divide-gray-200"},i.map(function(e){var t=o[e.fieldName],n=!!t;return d.createElement("tr",{key:e.fieldName,className:n?"":"bg-red-50"},d.createElement("td",{className:"px-4 py-3"},d.createElement("div",{className:"flex items-center gap-2"},d.createElement("div",{className:"w-2 h-2 bg-red-200 rounded-full"}),d.createElement("div",null,d.createElement("div",{className:"font-medium text-gray-900 text-sm"},e.fieldName),d.createElement("div",{className:"text-xs text-gray-500 truncate max-w-xs",title:e.description},e.description)))),d.createElement("td",{className:"px-4 py-3"},d.createElement("span",{className:"inline-flex items-center px-2 py-1 rounded-full text-xs font-medium"},"Required")),d.createElement("td",{className:"px-4 py-3"},n?d.createElement("span",{className:"font-medium text-gray-900 bg-white px-2 py-1 rounded border text-sm"},t):d.createElement("span",{className:"text-gray-400 italic text-sm"},"Not mapped")),d.createElement("td",{className:"px-4 py-3"},n?d.createElement("div",{className:"flex items-center gap-1 text-green-600"},d.createElement(y.CheckCircle,{className:"w-4 h-4"}),d.createElement("span",{className:"text-sm font-medium"},"Mapped")):d.createElement("div",{className:"flex items-center gap-1 text-red-600"},d.createElement(y.AlertTriangle,{className:"w-4 h-4"}),d.createElement("span",{className:"text-sm font-medium"},"Missing"))))}),c.map(function(e){var t=o[e.fieldName],n=!!t;return d.createElement("tr",{key:e.fieldName},d.createElement("td",{className:"px-4 py-3"},d.createElement("div",{className:"flex items-center gap-2"},d.createElement("div",{className:"w-2 h-2 bg-yellow-200 rounded-full"}),d.createElement("div",null,d.createElement("div",{className:"font-medium text-gray-900 text-sm"},e.fieldName),d.createElement("div",{className:"text-xs text-gray-500 truncate max-w-xs",title:e.description},e.description)))),d.createElement("td",{className:"px-4 py-3"},d.createElement("span",{className:"inline-flex items-center px-2 py-1 rounded-full text-xs font-medium bg-gray-100 text-gray-600"},"Optional")),d.createElement("td",{className:"px-4 py-3"},n?d.createElement("span",{className:"font-medium text-gray-900 bg-white px-2 py-1 rounded border text-sm"},t):d.createElement("span",{className:"text-gray-400 italic text-sm"},"Skipped")),d.createElement("td",{className:"px-4 py-3"},n?d.createElement("div",{className:"flex items-center gap-1 text-green-600"},d.createElement(y.CheckCircle,{className:"w-4 h-4"}),d.createElement("span",{className:"text-sm font-medium"},"Mapped")):d.createElement("div",{className:"flex items-center gap-1 text-gray-400"},d.createElement("span",{className:"w-4 h-4 rounded-full border border-gray-300"}),d.createElement("span",{className:"text-sm"},"Skipped"))))})))),m.length<i.length&&d.createElement("div",{className:"mt-6 bg-red-50 border border-red-200 rounded-lg p-4"},d.createElement("div",{className:"flex items-center gap-2"},d.createElement(y.AlertTriangle,{className:"w-5 h-5 text-red-600"}),d.createElement("span",{className:"font-medium text-red-800"},"Action Required")),d.createElement("p",{className:"text-red-700 text-sm mt-1"},i.length-m.length," required field",i.length-m.length>
11?"s":""," must be mapped before importing."))),d.createElement("div",{className:"flex justify-between items-center gap-3 p-6 border-t border-gray-200 bg-gray-50"},d.createElement("div",{className:"text-sm text-gray-600"},m.length+u.length," of ",i.length+c.length," fields mapped"),d.createElement("div",{className:"flex gap-3"},d.createElement("button",{onClick:r,className:"px-4 py-2 text-gray-700 bg-white border border-gray-300 rounded-md hover:bg-gray-50 transition-colors"},"Edit Mapping"),d.createElement("button",{onClick:a,disabled:m.length<i.length,className:"px-6 py-2 rounded-md font-medium transition-colors ".concat(m.length<i.length?"bg-gray-300 text-gray-500 cursor-not-allowed":"bg-blue-600 text-white hover:bg-blue-700")},l?"Retry Import":"Confirm & Import"))))))},X=n(92098),Q=n(64483);const $={hljs:{display:"block",background:"white",padding:"0.5em",color:"#333333",overflowX:"auto"},"hljs-comment":{color:"#969896"},"hljs-meta":{color:"#969896"},"hljs-variable":{color:"#df5000"},"hljs-template-variable":{color:"#df5000"},"hljs-strong":{color:"#df5000"},"hljs-emphasis":{color:"#df5000"},"hljs-quote":{color:"#df5000"},"hljs-keyword":{color:"#d73a49"},"hljs-selector-tag":{color:"#d73a49"},"hljs-type":{color:"#d73a49"},"hljs-literal":{color:"#0086b3"},"hljs-symbol":{color:"#0086b3"},"hljs-bullet":{color:"#0086b3"},"hljs-attribute":{color:"#0086b3"},"hljs-section":{color:"#63a35c"},"hljs-name":{color:"#63a35c"},"hljs-tag":{color:"#333333"},"hljs-title":{color:"#6f42c1"},"hljs-attr":{color:"#6f42c1"},"hljs-selector-id":{color:"#6f42c1"},"hljs-selector-class":{color:"#6f42c1"},"hljs-selector-attr":{color:"#6f42c1"},"hljs-selector-pseudo":{color:"#6f42c1"},"hljs-addition":{color:"#55a532",backgroundColor:"#eaffea"},"hljs-deletion":{color:"#bd2c00",backgroundColor:"#ffecec"},"hljs-link":{textDecoration:"underline"},"hljs-number":{color:"#005cc5"},"hljs-string":{color:"#032f62"}};var ee=n(59835),te=n(47793),ne=function(e){var t=e.open,n=e.onOpenChange,a=e.onProceed;return t?d.createElement("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50"},d.createElement("div",{className:"bg-white rounded-lg shadow-xl max-w-md w-full mx-4"},d.createElement("div",{className:"flex items-center justify-between p-6 border-b border-gray-200"},d.createElement("h3",{className:"text-lg font-semibold text-gray-900"},"Mapping Status Check"),d.createElement("button",{onClick:function(){return n(!1)},className:"text-gray-400 hover:text-gray-600 transition-colors"},d.createElement(y.X,{className:"w-5 h-5"}))),d.createElement("div",{className:"p-6"},d.createElement("div",{className:"border border-yellow-200 bg-yellow-50 rounded-lg p-4"},d.createElement("div",{className:"flex items-start space-x-2"},d.createElement(y.AlertTriangle,{className:"h-4 w-4 text-yellow-600 mt-0.5 flex-shrink-0"}),d.createElement("div",{className:"space-y-2 flex-1"},d.createElement("p",{className:"font-medium text-yellow-800"},"Group Id Mapping missing."),d.createElement("p",{className:"text-sm text-yellow-700"},"Do you still want to proceed? We will alert you about missing groups and customer IDs. You can ingest missing data here."),d.createElement("div",{className:"flex gap-2 mt-3"},d.createElement("button",{className:"px-3 py-1 text-sm bg-white border border-gray-300 rounded-md hover:bg-gray-50 transition-colors",onClick:function(){a(),n(!1)}},"Proceed Anyway"),d.createElement("button",{className:"px-3 py-1 text-sm text-yellow-700 hover:bg-yellow-100 rounded-md transition-colors",onClick:function(){return n(!1)}},"Cancel")))))))):null},ae=n(13113),re=n(24095),se=n(81185),oe={SUCCESS:{customers:[],groupIdFound:!0,missingEntities:[],customerMetaDataKeys:["group_id","account_id","organization_id","tenant_id"],__typename:"TestStripeConnectionResponse"},MISSING_ENTITIES:{customers:[{id:"cus_demo_1",metadata:'{"group_id":"demo_account_1","organization_id":"org_1"}'},{id:"cus_demo_2",metadata:'{"group_id":"demo_account_2","account_id":"acct_2"}'}],groupIdFound:!0,missingEntities:["products","subscriptions","subscription_items","balance_transactions","transactions","charges","disputes"],customerMetaDataKeys:["group_id","account_id","organization_id"],__typename:"TestStripeConnectionResponse"},MISSING_GROUP_ID:{customers:[],groupIdFound:!1,missingEntities:[],customerMetaDataKeys:["account_id","organization_id","tenant_id","company_id"],__typename:"TestStripeConnectionResponse"},NO_METADATA_KEYS:{customers:[],groupIdFound:!1,missingEntities:[],customerMetaDataKeys:[],__typename:"TestStripeConnectionResponse"}},le=function(){var e=(0,s.A)(u().mark(function e(t){return u().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=1,new Promise(function(e){return setTimeout(e,500)});case 1:return e.abrupt("return",oe[t]);case 2:case"end":return e.stop()}},e)}));return function(t){return e.apply(this,arguments)}}(),ie=function(){var e=(0,s.A)(u().mark(function e(t){return u().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=1,new Promise(function(e){return setTimeout(e,3e3)});case 1:return e.abrupt("return",{sourceId:"demo_source_".concat(Date.now()),connectionId:"demo_conn_".concat(Date.now()),syncStartedAt:(new Date).toISOString(),syncStatus:"succeeded",jobId:Math.floor(1e4*Math.random())});case 2:case"end":return e.stop()}},e)}));return function(t){return e.apply(this,arguments)}}(),ce="demo_env_development",me="Development",ue="development",de="NON_PRODUCTION",pe={customers:{label:"Customers",affectedReports:["MRR & ARR account level","MRR movements","Revenue â product correlation","Customer revenue lists"],explanation:"Customers are the foundation for tying payments to accounts. If customer data is missing, revenue cannot be matched to accounts in your CRM or product analytics. Metrics like account-level MRR, customer counts in movement reports, and cross-team revenue attribution will be incomplete or blank."},invoices:{label:"Invoices",affectedReports:["Monthly recurring revenue (MRR)","Total revenue","Non-recurring revenue","Account billing history"],explanation:"Invoices record what was billed and to whom. Without invoices, payments cannot be tied to billing periods or line items. MRR, total revenue, and one-time revenue figures will be understated for any business that bills through Stripe invoices."},invoice_items:{label:"Invoice_items",affectedReports:["One-time / Non-Recurring revenue"],explanation:"Invoice items capture ad-hoc charges, credits, and adjustments added outside a standard subscription invoice. If this data is missing, one-off charges and invoice-level adjustments may not appear in revenue reports, causing total revenue and non-recurring revenue to look lower than reality."},invoice_line_items:{label:"Invoice_line_items",affectedReports:["MRR","New, Expansion & Contraction MRR","N
1on-recurring revenue"],explanation:"Invoice line items show what customers are actually paying for on each bill â plan, amount, and billing period. Without them, the system cannot split subscription vs one-time revenue or calculate new and expansion MRR from invoice-based billing. Core MRR and movement metrics will be missing or wrong."},plans:{label:"Plans",affectedReports:["Plan level MRR","Plan performance trends","MRR movement drill-down"],explanation:"Plans define how offerings are priced and billed (e.g. monthly vs annual). If plan data is missing, MRR can still total at a company level in some setups, but you will not see which plans drive revenue. Plan-level trends, movement labels, and pricing-tier analysis will be unavailable."},prices:{label:"Prices",affectedReports:["MRR","New MRR","ARR","Revenue by price point"],explanation:"Prices define the billing amount and cadence for each product. Without prices, recurring amounts cannot be normalized to a monthly figure. New MRR, MRR growth, and ARR will be understated or omitted for customers billed through Stripe Prices."},products:{label:"Products",affectedReports:["Revenue","MRR movement details"],explanation:"Missing product data does not always block top-line MRR, but product names in reports and breakdowns by product line will be empty. You cannot see which products contribute most to revenue or churn."},subscriptions:{label:"Subscriptions",affectedReports:["MRR & ARR","Total revenue","Churn & contraction MRR","Reactivation MRR","Active subscriber metrics"],explanation:"In subscription management, if subscription data is missing, metrics like monthly recurring revenue, annual recurring revenue, and total revenue will not be calculated correctly. Churn, downgrades, reactivations, and active subscriber counts also depend on knowing subscription status and lifecycle."},subscription_items:{label:"Subscription_items",affectedReports:["MRR per subscription line","Expansion & contraction by quantity","Multi-product MRR"],explanation:"Subscription items represent each product or seat on a customerâs subscription. Without them, quantity-based expansion and contraction are invisible, and MRR for customers on multi-item subscriptions may be calculated incorrectly or shown as a single undifferentiated amount."},subscriptions_items:{label:"Subscriptions_items",affectedReports:["MRR per subscription item","Expansion & contraction by quantity","Multi-product MRR"],explanation:"Subscription items represent each product or seat on a customerâs subscription. Without them, quantity-based expansion and contraction are invisible, and MRR for customers on multi-item subscriptions may be calculated incorrectly or shown as a single undifferentiated amount."},balance_transactions:{label:"Balance_transactions",affectedReports:["Net revenue after fees","MRR & total revenue (fee-adjusted)","Payout reconciliation"],explanation:"Balance transactions record what actually lands in your Stripe balance after processing fees. If this data is missing and you exclude fees from revenue, reported MRR and total revenue may be overstated because payment processing costs cannot be deducted."},transactions:{label:"Transactions",affectedReports:["MRR (transaction-based setups)","Total & non-recurring revenue","Payment history","New MRR from first payments"],explanation:"Transactions are individual payment events. For integrations that rely on payment transactions rather than invoices alone, missing transaction data means no payment history, no new MRR from first-time payers, and incomplete total revenue for charge-based billing."},charges:{label:"Charges",affectedReports:["Total revenue","Non-recurring revenue","Payment success & failure tracking","New MRR (charge-based billing)"],explanation:"Charges are successful (or attempted) card payments. Without charge data, cash collected through Stripe will not flow into revenue reports. Total revenue, one-time purchases, and transaction-based MRR will appear zero or incomplete even if subscriptions exist."},disputes:{label:"Disputes",affectedReports:["Net revenue accuracy","Revenue health & risk","Collected vs disputed revenue"],explanation:"Disputes are chargebacks â revenue customers contest with their bank. If dispute data is missing, collected revenue may look higher than what you actually keep. Risk and reconciliation views will not reflect lost or at-risk revenue from disputes."},refunds:{label:"Refunds",affectedReports:["Net revenue","Total revenue","Contraction & downgrade impact","Gross vs net retention"],explanation:"Refunds return money to customers and reduce realized revenue. Without refund data, total and net revenue stay inflated after cancellations or downgrades with refunds. Retention and contraction metrics may overstate revenue you actually retained."},payment_intent:{label:"Payment_intent",affectedReports:["Payment status visibility","Failed payment analysis","Dispute & refund linkage"],explanation:"Payment intents represent the full payment attempt lifecycle (succeeded, failed, requires action). Missing access limits visibility into failed payments and incomplete checkouts. Disputes and refunds may be harder to tie back to the original payment in revenue diagnostics."}},ge={subscriptions_items:"subscription_items"};var fe=function(e){var t=e.isOpen,n=e.onClose,a=e.onConnect;return t?d.createElement("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50"},d.createElement("div",{className:"bg-white rounded-lg shadow-xl max-w-2xl w-full mx-4"},d.createElement("div",{className:"p-6 border-b border-gray-200"},d.createElement("div",{className:"flex items-center space-x-3"},d.createElement("div",{className:"w-10 h-10 bg-purple-100 rounded-full flex items-center justify-center"},d.createElement("span",{className:"text-purple-600 font-bold text-lg"},"TS")),d.createElement("h2",{className:"text-xl font-semibold text-gray-900"},"ThriveStack Corporation"))),d.createElement("div",{className:"p-6"},d.createElement("h3",{className:"text-2xl font-bold text-gray-900 mb-4"},"ThriveStack Corporation partners with Stripe for secure payments."),d.createElement("div",{className:"bg-blue-50 border border-blue-200 rounded-lg p-4 mb-4"},d.createElement("p",{className:"text-sm text-blue-800"},"â¹ï¸ You're using a test account with test data.")),d.createElement("h4",{className:"text-xl font-semibold text-gray-900 mb-4"},"Get started with Stripe"),d.createElement("p",{className:"text-gray-600 mb-6"},"If you're completing this form on behalf of a business, it must be completed by the business owner or someone with significant management responsibility of that business.")),d.createElement("div",{className:"p-6 border-t border-gray-200 flex justify-end space-x-3"},d.createElement("button",{onClick:n,className:"px-4 py-2 text-sm font-medium text-gray-700 bg-white border border-gray-300 rounded-md hover:bg-gray-50 transition-colors"},"Cancel"),d.createElement("button",{onClick:a,className:"px-6 py-2 text-sm font-medium text-white bg-blue-600 rounded-md hover:bg-blue-700 transition-colors flex items-center space-x-2"},d.createElement("span",null,"Connect Account"),d.createElement(y.ArrowRight,{className:"w-4 h-4"}))))):null},be=n(68063);function ye(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,a)}return n}function ve(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};
1t%2?ye(Object(n),!0).forEach(function(t){(0,i.A)(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ye(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function xe(e){if(null==e||!e.length)return null;var t=e.filter(function(e){return"STRIPE"===(e.dataSource||"").toString().toUpperCase()});if(0===t.length)return null;var n=function(e){var t=(e||"").toLowerCase();return"running"===t||"pending"===t?0:"failed"===t?1:"succeeded"===t?2:"cancelled"===t?3:4},a=function(e){var t=e.startTime?new Date(e.startTime).getTime():0,n=e.lastUpdatedAt?new Date(e.lastUpdatedAt).getTime():0;return Math.max(t,n)};return(0,l.A)(t).sort(function(e,t){var r=n(e.status),s=n(t.status);return r!==s?r-s:a(t)-a(e)})[0]}var he=function(){var e=new Date;return e.setMonth(e.getMonth()-12),e},Ee={available:["customers","subscriptions","subscription_items","subscription_schedules","subscription_schedule_phases","invoices","invoice_items","invoice_line_items","credit_notes","payments","payment_intents","setup_intents","setup_attempts","charges","refunds","balance_transactions","transfers","payouts","application_fees","application_fee_refunds","disputes","coupon","promotion_codes","tax_rates","usage_records","usage_record_summaries","mandates","payment_methods","payment_method_details","sources","source_metadata","events","files","file_links","customer_tax_ids","customer_balance_transactions","discounts","account","account_links","capabilities","external_accounts","persons","topups","transfer_reversals","country_specs","reviews","value_lists","value_list_items","issuing_authorizations","issuing_cardholders","issuing_disputes","issuing_transactions","locations"],willSync:["customers","invoices","invoice_items","invoice_line_items","plans","prices","products","subscriptions","subscriptions_items","balance_transactions","transactions","charges","disputes","refunds","payment_intent"]},Ne=function(e){return e.toLowerCase().replace(/[_\s-]/g,"")},we=function(e){var t=Ne("group_id");return e.find(function(e){return Ne(e)===t})||null},Ce=function(e,t){if(!e.length)return null!=t?t:"group_id";var n=we(e);return n||(t&&e.includes(t)?t:e[0])},Se=[{id:"group_id_found",label:"Has group_id"},{id:"no_group_id",label:"No group_id"},{id:"no_metadata_keys",label:"No metadata keys"}],ke={group_id_found:["group_id","organization_id","workspace_id"],no_group_id:["organization_id","workspace_id","tenant_id"],no_metadata_keys:[]},Ae="group_id",Ie=function(e){var t,n,a,r,o,m,f,b,v,x,h,E,w,C,S,A=e.sourceConfigurations,I=e.updateSourceConfiguration,T=(e.onComplete,e.loadedStripeData),D=e.selectedSources,R=e.config,_=e.setConfig,P=(e.onStepComplete,e.emailManager),O=e.onAutoSave,M=e.cleanOAuthParams,K=e.openSetupGuideRef,j=e.onOpenIntegrationsList,q=e.onTrackCompletion,L=(0,d.useState)({sourceName:"Stripe",accountId:"",accountIdEntryMode:void 0,secretKey:"",dataRetentionLocation:"",syncStartDate:he(),groupIdMapping:!1,environmentId:"",environmentName:"",stripeEnvironment:""}),U=(0,c.A)(L,2),V=U[0],B=U[1],z=(0,F._K)(),W=z.isDemoMode,G=(0,d.useState)(!1),Y=(0,c.A)(G,2),X=Y[0],Q=Y[1],$=(0,d.useState)(!1),ee=(0,c.A)($,2),te=ee[0],oe=ee[1],ue=(0,d.useState)(!1),de=(0,c.A)(ue,2),ye=de[0],Ne=de[1],Ie=(0,d.useState)(null),Te=(0,c.A)(Ie,2),De=(Te[0],Te[1]),Re=(0,d.useState)(!1),_e=(0,c.A)(Re,2),Pe=_e[0],Oe=_e[1],Me=(0,d.useState)({}),Fe=(0,c.A)(Me,2),Ke=Fe[0],je=Fe[1],qe=(0,d.useState)("environment"),Le=(0,c.A)(qe,2),Ue=Le[0],Ve=Le[1],Be=(0,d.useState)(!1),ze=(0,c.A)(Be,2),We=ze[0],He=ze[1],Ge=(0,d.useState)(!1),Je=(0,c.A)(Ge,2),Ze=(Je[0],Je[1],(0,d.useState)(!1)),Ye=(0,c.A)(Ze,2),Xe=Ye[0],Qe=Ye[1],$e=(0,d.useState)(!1),et=(0,c.A)($e,2),tt=et[0],nt=et[1],at=(0,d.useState)({displayName:"",environmentType:J.OX.NonProduction}),rt=(0,c.A)(at,2),st=rt[0],ot=rt[1],lt=(0,d.useState)(!1),it=(0,c.A)(lt,2),ct=it[0],mt=it[1],ut=(0,d.useRef)(null),dt=(0,d.useRef)(null),pt=(0,d.useState)("group_id"),gt=(0,c.A)(pt,2),ft=gt[0],bt=gt[1],yt=(0,d.useState)(!1),vt=(0,c.A)(yt,2),xt=vt[0],ht=vt[1],Et=(0,d.useState)([]),Nt=(0,c.A)(Et,2),wt=Nt[0],Ct=Nt[1],St=(0,d.useState)(!1),kt=(0,
1c.A)(St,2),At=kt[0],It=kt[1],Tt=(0,d.useState)("group_id_found"),Dt=(0,c.A)(Tt,2),Rt=Dt[0],_t=Dt[1],Pt=(0,d.useState)(!1),Ot=(0,c.A)(Pt,2),Mt=Ot[0],Ft=Ot[1],Kt=(0,d.useState)(!1),jt=(0,c.A)(Kt,2),qt=jt[0],Lt=jt[1],Ut=(0,d.useState)(!1),Vt=(0,c.A)(Ut,2),Bt=Vt[0],zt=Vt[1],Wt=(0,d.useState)(!0),Ht=(0,c.A)(Wt,2),Gt=Ht[0],Jt=Ht[1],Zt=(0,d.useState)([{id:"connection",title:"Connection",loadingText:"Establishing Connection",successText:"Connected",errorText:"Connection Error",status:"pending"},{id:"data",title:"Data Retrieval",loadingText:"Retrieving Data Tables",successText:"Data Retrieved",errorText:"Unable to Retrieve Data",status:"pending"},{id:"schema",title:"Schema Verification",loadingText:"Verifying Schema",successText:"Schema Verified",errorText:"Schema Error Detected",status:"pending"}]),Yt=(0,c.A)(Zt,2),Xt=Yt[0],Qt=Yt[1],$t=[{id:"create-source",title:"Creating Source",loadingText:"Creating Source...",successText:"Source Created",errorText:"Failed to Create Source",status:"pending"},{id:"make-connection",title:"Making Connection",loadingText:"Making Connection...",successText:"Connection Established",errorText:"Connection Error",status:"pending"},{id:"sync-data",title:"Syncing Data",loadingText:"Starting Data Sync...",successText:"Data Sync Started",errorText:"Sync Error",status:"pending"}],en=(0,d.useState)(!1),tn=(0,c.A)(en,2),nn=tn[0],an=tn[1],rn=(0,d.useState)(1),sn=(0,c.A)(rn,2),on=sn[0],ln=sn[1],cn=(0,d.useState)(!1),mn=(0,c.A)(cn,2),un=mn[0],dn=mn[1],pn=((0,p.Yx)(),(0,g.useLocation)(),(0,g.useSearchParams)()),gn=(0,c.A)(pn,2),fn=gn[0],bn=gn[1],yn=(0,d.useState)(),vn=(0,c.A)(yn,2),xn=vn[0],hn=vn[1],En=(0,d.useState)(!1),Nn=(0,c.A)(En,2),wn=Nn[0],Cn=Nn[1],Sn=(0,d.useState)(!1),kn=(0,c.A)(Sn,2),An=kn[0],In=kn[1],Tn=(0,d.useState)(!1),Dn=(0,c.A)(Tn,2),Rn=Dn[0],_n=Dn[1],Pn=(0,d.useState)(null),On=(0,c.A)(Pn,2),Mn=On[0],Fn=On[1],Kn=(0,d.useState)(null),jn=(0,c.A)(Kn,2),qn=jn[0],Ln=jn[1],Un=(0,d.useRef)(null),Vn=(0,d.useRef)(null),Bn=(0,d.useRef)(null),zn=(0,d.useRef)(null),Wn=(0,d.useRef)(null),Hn=(0,d.useRef)(null),Gn=(0,d.useRef)(null),Jn=(0,d.useRef)(null),Zn=(0,d.useRef)(null),Yn=(0,d.useRef)(null),Xn=(0,d.useRef)(null),Qn=(0,d.useRef)(null),$n=(0,d.useRef)(!1),ea=(0,d.useRef)(!1),ta=(0,d.useState)(!(null==T||!T.step3Completed)||!(null===(t=A.stripe)||void 0===t||!t.step3Completed)),na=(0,c.A)(ta,2),aa=na[0],ra=na[1],sa=(0,d.useState)(!(null==T||!T.step4Completed)||!(null===(n=A.stripe)||void 0===n||!n.step4Completed)),oa=(0,c.A)(sa,2),la=oa[0],ia=oa[1],ca=(0,d.useState)(!!(null!=T&&T.step4WasEverCompleted||null!==(a=A.stripe)&&void 0!==a&&a.step4WasEverCompleted||null!=T&&T.step4CompletedAt||null!==(r=A.stripe)&&void 0!==r&&r.step4CompletedAt)),ma=(0,c.A)(ca,2),ua=ma[0],da=ma[1],pa=(0,d.useState)(!1),ga=(0,c.A)(pa,2),fa=ga[0],ba=ga[1],ya=(0,d.useState)($t),va=(0,c.A)(ya,2),xa=va[0],ha=va[1],Ea=(0,d.useState)(0),Na=(0,c.A)(Ea,2),wa=Na[0],Ca=Na[1],Sa=(0,d.useState)(!1),ka=(0,c.A)(Sa,2),Aa=ka[0],Ia=ka[1],Ta=(0,d.useState)("pending"),Da=(0,c.A)(Ta,2),Ra=Da[0],_a=Da[1],Pa=(0,d.useState)(!1),Oa=(0,c.A)(Pa,2),Ma=Oa[0],Fa=Oa[1],Ka=(0,d.useState)(null),ja=(0,c.A)(Ka,2),qa=ja[0],La=ja[1],Ua=(0,d.useState)(!1),Va=(0,c.A)(Ua,2),Ba=Va[0],za=Va[1],Wa=(0,d.useState)(!1),Ha=(0,c.A)(Wa,2),Ga=Ha[0],Ja=Ha[1],Za=(0,d.useState)(!1),Ya=(0,c.A)(Za,2),Xa=Ya[0],Qa=Ya[1],$a=(0,d.useState)(!1),er=(0,c.A)($a,2),tr=er[0],nr=er[1],ar=(0,d.useState)(!1),rr=(0,c.A)(ar,2),sr=rr[0],or=rr[1],lr=(0,d.useState)(!1),ir=(0,c.A)(lr,2),cr=ir[0],mr=ir[1],ur=!(null===(o=A.stripe)||void 0===o||null===(o=o.ingestionResult)||void 0===o||!o.sourceId||null===(m=A.stripe)||void 0===m||null===(m=m.ingestionResult)||void 0===m||!m.connectionId),dr=ur,pr=!(null===(f=A.stripe)||void 0===f||!f.step2Completed)||cr,gr=(0,d.useState)(""),fr=(0,c.A)(gr,2),br=fr[0],yr=fr[1],vr=(0,d.useState)(""),xr=(0,c.A)(vr,2),hr=xr[0],Er=xr[1],Nr=(0,d.useState)(null),wr=(0,c.A)(Nr,2),Cr=wr[0],Sr=wr[1],kr=(0,d.useState)(!1),Ar=(0,c.A)(kr,2),Ir=Ar[0],Tr=Ar[1],Dr=(0,d.useState)("none"),Rr=(0,c.A)(Dr,2),_r
1=Rr[0],Pr=Rr[1],Or=(0,d.useState)(!(null===(b=A.stripe)||void 0===b||!b.pendingSecretKeyChange)||!(null==T||!T.pendingSecretKeyChange)),Mr=(0,c.A)(Or,2),Fr=Mr[0],Kr=Mr[1],jr=(0,d.useState)(!(null===(v=A.stripe)||void 0===v||!v.pendingSyncDateChange)||!(null==T||!T.pendingSyncDateChange)),qr=(0,c.A)(jr,2),Lr=qr[0],Ur=qr[1],Vr=(0,d.useState)(!1),Br=(0,c.A)(Vr,2),zr=Br[0],Wr=Br[1],Hr=(0,d.useState)(!1),Gr=(0,c.A)(Hr,2),Jr=Gr[0],Zr=Gr[1],Yr=(0,d.useState)(null),Xr=(0,c.A)(Yr,2),Qr=Xr[0],$r=Xr[1],es=(0,d.useState)(!1),ts=(0,c.A)(es,2),ns=ts[0],as=ts[1],rs=(0,J.wi)({client:Z.RB,fetchPolicy:"no-cache"}),ss=(0,c.A)(rs,2),os=ss[0],ls=ss[1],is=ls.data,cs=(ls.loading,(0,J.WX)({client:Z.RB,fetchPolicy:"no-cache"})),ms=(0,c.A)(cs,2),us=ms[0],ds=ms[1].loading,ps=(0,se.TBv)({client:Z.Ju,fetchPolicy:"no-cache"}),gs=(0,c.A)(ps,1)[0],fs=(0,se.Ske)({client:Z.Ju,fetchPolicy:"no-cache"}),bs=(0,c.A)(fs,1)[0],ys=(0,se.B3y)({client:Z.k3,fetchPolicy:"no-cache"}),vs=(0,c.A)(ys,2),xs=vs[0],hs=vs[1].loading,Es=(0,se.PMB)({client:Z.k3,fetchPolicy:"no-cache"}),Ns=(0,c.A)(Es,2),ws=Ns[0],Cs=Ns[1].loading,Ss=(0,se.Mpy)({client:Z.k3,fetchPolicy:"no-cache"}),ks=(0,c.A)(Ss,2),As=ks[0],Is=ks[1].loading,Ts=(0,se.F3z)({client:Z.k3,fetchPolicy:"no-cache"}),Ds=(0,c.A)(Ts,2),Rs=Ds[0],_s=Ds[1].loading,Ps=(0,se.JET)({client:Z.k3,fetchPolicy:"no-cache"}),Os=(0,c.A)(Ps,1)[0],Ms=function(){oe(!0),setTimeout(function(){ut.current&&ut.current.scrollIntoView({behavior:"smooth",block:"start"})},100)},Fs=function(){oe(!0),setTimeout(function(){dt.current&&dt.current.scrollIntoView({behavior:"smooth",block:"start"})},100)},Ks=function(){var e=(0,s.A)(u().mark(function e(){var t;return u().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=1,os({variables:{input:{productId:(0,H.J1)()}}});case 1:e.next=3;break;case 2:e.prev=2,t=e.catch(0),console.error("Failed to fetch environments:",t);case 3:case"end":return e.stop()}},e,null,[[0,2]])}));return function(){return e.apply(this,arguments)}}(),js=function(){var e="acct_demo_".concat(Math.random().toString(36).substring(2,15));B(function(t){return ve(ve({},t),{},{accountId:e})}),Ja(!1)},qs=function(){return Xt.every(function(e){return"success"===e.status})},Ls=function(){var e=(0,s.A)(u().mark(function e(){return u().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:ra(!0),In(!1),mr(!0),mo(!1),Xn.current="pause-fix",Ve("pause-fix"),O(),setTimeout(function(){var e;null===(e=zn.current)||void 0===e||e.scrollIntoView({behavior:"smooth",block:"center"})},100);case 1:case"end":return e.stop()}},e)}));return function(){return e.apply(this,arguments)}}(),Us=function(){var e=(0,s.A)(u().mark(function e(){return u().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:In(!0),ra(!0),B(function(e){return ve(ve({},e),{},{groupIdMapping:!0})}),mr(!0),mo(!0,{selectedIdentifierKey:Ae,groupIdMapping:!0}),hn(k.V.REVOPS_TEAMS),Cn(!0),Xn.current="pause-fix",Ve("pause-fix"),O(),setTimeout(function(){var e;null===(e=zn.current)||void 0===e||e.scrollIntoView({behavior:"smooth",block:"center"})},100);case 1:case"end":return e.stop()}},e)}));return function(){return e.apply(this,arguments)}}(),Vs=function(){Xn.current="basic-config",Ve("basic-config"),setTimeout(function(){var e;null===(e=Hn.current)||void 0===e||e.scrollIntoView({behavior:"smooth",block:"start"})},100)},Bs=function(){zt(!0),Jt(!1),In(!0),mo(!0,{missingEntitiesAcknowledged:!0}),O()},zs=function(){var e=(0,s.A)(u().mark(function e(){return u().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:In(!0),ra(!0),B(function(e){return ve(ve({},e),{},{groupIdMapping:!0})}),mr(!0),mo(!0,{selectedIdentifierKey:Ae,groupIdMapping:!0}),Xn.current="pause-fix",Ve("pause-fix"),O(),setTimeout(function(){var e;null===(e=zn.current)||void 0===e||e.scrollIntoView({behavior:"smooth",block:"center"})},100);case 1:case"end":return e.stop()}},e)}));return function(){return e.apply(this,arguments)}}(),Ws=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:2e3,t=(0,d.useState)({}),n=(0,c.A)(t,2),a=n[0],r=n[1],o=function(){var t=(0,s.A)(u().mark(function t(n,a){return u().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=1,navigator.clipboard.writeText(n);case 1:r(function(e){return ve(ve({},e),{},(0,i.A)({},a,!0))}),setTimeout(function(){r(function(e){return ve(ve({},e),{},(0,i.A)({},a,!1))})},e);case 2:case"end":return t.stop()}},t)}));return function(e,n){return t.apply(this,arguments)}}();return{copiedStates:a,copy:o}}(),Hs=(Ws.copiedStates,Ws.copy,function(){var e=(0,s.A)(u().mark(function e(){var t,n,a,r,s,o,l,i,c,m,d,p,g,f,b=arguments;return u().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(t=b.length>0&&void 0!==b[0]?b[0]:"SUCCESS",!W){e.next=2;break}return e.next=1,le(t);case 1:return a=e.sent,r=null!==(n=a.customerMetaDataKeys)&&void 0!==n?n:[],s=Ce(r,ft),o=!!we(r),Ct(r),It(o),Ft(o),r.length>0&&bt(s),e.abrupt("return",a);case 2:return e.prev=2,e.next=3,gs({variables:{input:{environmentId:V.environmentId,str
1ipeKey:V.secretKey}}});case 3:return c=e.sent,m=null===(l=c.data)||void 0===l?void 0:l.testStripeConnection,d=null!==(i=null==m?void 0:m.customerMetaDataKeys)&&void 0!==i?i:[],p=Ce(d,ft),g=!!we(d),Ct(d),d.length>0&&bt(p),It(g),Ft(g),e.abrupt("return",m);case 4:throw e.prev=4,f=e.catch(2),console.error("Test connection error:",f),f;case 5:case"end":return e.stop()}},e,null,[[2,4]])}));return function(){return e.apply(this,arguments)}}()),Gs=(0,d.useMemo)(function(){return Fr||Lr?Fr&&Lr?"both":Lr?"syncDateOnly":"apiKeyOnly":_r},[Fr,Lr,_r]),Js=[{id:"environment",number:1,title:"Map Environments",description:"Select the Stripe environment that will map with current App environment and will be used when establishing an connection.",subtitle:"Select the Stripe environment to connect with Current App environment",isCompleted:!(!V.environmentId||!V.stripeEnvironment),isActive:"environment"===Ue,required:!0},{id:"basic-config",number:2,title:"Basic Configuration",description:"Configure your Stripe connection details",isCompleted:!!(V.sourceName&&V.accountId&&V.secretKey&&V.syncStartDate),isActive:"basic-config"===Ue,required:!0},{id:"revenue-correlation",number:3,title:"Test Your Stripe Connection",description:"Test your Stripe credentials before starting Data Ingestion",isCompleted:aa||qs(),isActive:"revenue-correlation"===Ue,required:!0},{id:"pause-fix",number:4,title:"apiKeyOnly"!==Gs&&"both"!==Gs&&"syncDateOnly"!==Gs||!ua?"Start Ingestion":"Resync Stripe data",description:"apiKeyOnly"!==Gs&&"both"!==Gs&&"syncDateOnly"!==Gs||!ua?"Finalize your Str
1ipe integration":"Start a new sync with modified configurations",isCompleted:la||!1,isActive:"pause-fix"===Ue,required:!0}],Zs=function(){var e,t={notificationEmails:{userEmail:null===(e=(0,H.wz)())||void 0===e?void 0:e.email,additionalEmails:P.state.emails}};I("stripe",t),_(function(e){return ve(ve({},e),t)}),P.resetUpdateButton()};(0,d.useEffect)(function(){return K&&(K.current=function(){return oe(!0)}),function(){K&&(K.current=null)}},[K]),Qn.current=null!==(x=A.stripe)&&void 0!==x?x:null,(0,d.useEffect)(function(){var e,t,n=null==A?void 0:A.stripe;if(n&&0!==Object.keys(n).length){var a=JSON.stringify({accountId:n.accountId,accountIdEntryMode:n.accountIdEntryMode,secretKey:null===(e=n.secretKey)||void 0===e?void 0:e.substring(0,10),syncStartDate:n.syncStartDate,step2Completed:n.step2Completed,step3Completed:n.step3Completed,step4Completed:n.step4Completed,ingestionResult:null===(t=n.ingestionResult)||void 0===t?void 0:t.sourceId});if($n.current!==a){if($n.current=a,B(function(e){var t,a,r,s,o,l,i,c,m,u;return ve(ve({},e),{},{sourceName:null!==(t=n.sourceName)&&void 0!==t?t:e.sourceName,accountId:null!==(a=n.accountId)&&void 0!==a?a:e.accountId,accountIdEntryMode:null!==(r=n.accountIdEntryMode)&&void 0!==r?r:e.accountIdEntryMode,stripeAccountName:null!==(s=n.stripeAccountName)&&void 0!==s?s:e.stripeAccountName,secretKey:null!==(o=n.secretKey)&&void 0!==o?o:e.secretKey,dataRetentionLocation:null!==(l=n.dataRetentionLocation)&&void 0!==l?l:e.dataRetentionLocation,syncStartDate:n.syncStartDate?new Date(n.syncStartDate):e.syncStartDate,groupIdMapping:null!==(i=n.groupIdMapping)&&void 0!==i?i:e.groupIdMapping,environmentId:null!==(c=n.environmentId)&&void 0!==c?c:e.environmentId,environmentName:null!==(m=n.environmentName)&&void 0!==m?m:e.environmentName,stripeEnvironment:null!==(u=n.stripeEnvironment)&&void 0!==u?u:e.stripeEnvironment})}),Qa(!1),nr(!1),or(!1),yr(""),Er(""),Sr(null),Array.isArray(n.testingSteps)&&Qt(n.testingSteps),Array.isArray(n.customerMetaDataKeys)&&Ct(n.customerMetaDataKeys),"boolean"==typeof n.groupIdFound&&It(n.groupIdFound),"boolean"==typeof n.testCompleted&&an(n.testCompleted),"boolean"==typeof n.isStep3Incomplete&&In(n.isStep3Incomplete),"boolean"==typeof n.missingEntitiesAcknowledged){var r=n.missingEntitiesAcknowledged;zt(r),Jt(!r)}if("boolean"==typeof n.step3Completed&&ra(n.step3Completed),"boolean"==typeof n.step4Completed&&ia(function(e){return!0===n.step4Completed||(!(!1!==n.step4Completed||"apiKeyOnly"!==_r||!zr||!e)||n.step4Completed)}),n.ingestionResult){Fn(n.ingestionResult);var s=n.ingestionResult.syncStatus||n.syncStatus;s&&(_a(s),"running"!==s&&"pending"!==s||Fa(!0))}else n.syncStatus&&(_a(n.syncStatus),"running"!==n.syncStatus&&"pending"!==n.syncStatus||Fa(!0));if("boolean"==typeof n.isSetupIncomplete&&Tr(n.isSetupIncomplete),!0===n.pendingSecretKeyChange&&Kr(!0),!0===n.pendingSyncDateChange&&Ur(!0),n.pendingSecretKeyChange||n.pendingSyncDateChange){var o=n.pendingSecretKeyChange&&n.pendingSyncDateChange?"both":n.pendingSyncDateChange?"syncDateOnly":n.pendingSecretKeyChange?"apiKeyOnly":"none";Pr(o)}We||(n.step4Completed?Ve("pause-fix"):n.step3Completed?Ve("revenue-correlation"):n.isSetupIncomplete?Ve("basic-config"):n.step2Completed?Ve("revenue-correlation"):n.step1Completed&&Ve("basic-config"))}}},[A,We,_r,zr]),(0,d.useEffect)(function(){var e,t=("apiKeyOnly"===Gs||"both"===Gs||"syncDateOnly"===Gs)&&(null===(e=A.stripe)||void 0===e?void 0:e.step4Completed);if("pause-fix"===Ue&&!!V.environmentId&&!!Mn&&(!t||zr)){var n=setTimeout(function(){var e=function(){var e=(0,s.A)(u().mark(function e(){var t,n,a,r,s,o;return u().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=1,Os({variables:{input:{environmentId:V.environmentId,dataSource:[se.qSh.Stripe]}}});case 1:n=e.sent,(a=xe(null===(t=n.data)||void 0===t||null===(t=t.getSyncStatus)||void 0===t?void 0:t.syncStatus))&&(r=a.status,_a(r),(s=a.lastUpdatedAt||a.startTime)?La(s):Mn.syncStartedAt&&!qa&&La(Mn.syncStartedAt),"running"!==r&&"pending"!==r||Fa(!0)),e.next=3;break;case 2:e.prev=2,o=e.catch(0),console.error("Error loading sync status:",o);case 3:case"end":return e.stop()}},e,null,[[0,2]])}));return function(){return e.apply(this,arguments)}}();e()},100);return function(){return clearTimeout(n)}}},[Ue,Mn,V.environmentId,Os,_r,zr]),(0,d.useEffect)(function(){var e;!(("apiKeyOnly"===Gs||"both"===Gs||"syncDateOnly"===Gs)&&(null===(e=A.stripe)||void 0===e?void 0:e.step4Completed))||zr||Is||_s||(Wr(!1),Fa(!1),_a("pending"),La(null))},[Gs,null===(h=A.stripe)||void 0===h?void 0:h.step4Completed,zr,Is,_s]),(0,d.useEffect)(function(){var e;Zr(("apiKeyOnly"===Gs||"both"===Gs||"syncDateOnly"===Gs)&&(null===(e=A.stripe)||void 0===e?void 0:e.step4Completed))},[Gs,null===(E=A.stripe)||void 0===E?void 0:E.step4Completed]),(0,d.useEffect)(function(){var e;if(Ma&&V.environmentId&&(!(("apiKeyOnly"===_r||"both"===_r||"syncDateOnly"===_r)&&(null===(e=A.stripe)||void 0===e?void 0:e.step4Completed))||zr)){var t,n=0,a=function(){var e=(0,s.A)(u().mark(function e(){var a,r,s,o,l,i,c,m;return u().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,!(++n>40)){e.next=1;break}return _a("failed"),Fa(!1),clearInterval(t),e.abrupt("return");case 1:return e.next=2,Os({variables:{input:{environmentId:V.environmentId,dataSource:[se.qSh.Stripe]}}});case 2:r=e.sent,(s=xe(null===(a=r.data)||void 0===a||null===(a=a.getSyncStatus)||void 0===a?void 0:a.syncStatus))&&(o=s.status,_a(o),(l=s.lastUpdatedAt||s.startTime)&&La(l),Fn(function(e){return e?ve(ve({},e),{},{syncStatus:o||e.syncStatus}):null}),i=Qn.current||{},c=i.ingestionResult||{},I("stripe",ve(ve({},i),{},{ingestionResult:ve(ve({},c),{},{syncStatus:o})})),"succeeded"!==o&&"failed"!==o||(Fa(!1),clearInterval(t))),e.next=4;break;case 3:e.prev=3,m=e.catch(0),console.error("Error polling sync status:",m),_a("failed"),Fa(!1),clearInterval(t);case 4:case"end":return e.stop()}},e,null,[[0,3]])}
1));return function(){return e.apply(this,arguments)}}();return a(),t=setInterval(a,3e4),function(){clearInterval(t)}}},[Ma,V.environmentId,Os,_r,zr,I]),(0,d.useEffect)(function(){if(fa)if(qn)ha(function(e){return e.map(function(e){return ve(ve({},e),{},{status:"error"})})});else{if(wa<xa.length-1){ha(function(e){return e.map(function(e,t){return t===wa?ve(ve({},e),{},{status:"loading"}):e})});var e=setTimeout(function(){ha(function(e){return e.map(function(e,t){return t===wa?ve(ve({},e),{},{status:"success"}):e})}),Ca(function(e){return e+1})},3e3);return function(){return clearTimeout(e)}}wa===xa.length-1&&ha(function(e){return e.map(function(e,t){return t===wa?ve(ve({},e),{},{status:hs?"loading":"success"}):e})})}},[fa,wa,hs,xa.length,qn]),(0,d.useEffect)(function(){var e,t,n,a,r=new URLSearchParams(window.location.search),o=r.get("code"),l=r.get("state"),i=r.get("substep"),c=r.get("step"),m=r.get("openSetupGuide");if(l)try{var d=JSON.parse(decodeURIComponent(l));if("number"==typeof d.step)n=d.step;else if("string"==typeof d.step){var p=parseInt(d.step,10);Number.isNaN(p)||(n=p)}if("number"==typeof d.substep)a=d.substep;else if("string"==typeof d.substep){var g=parseInt(d.substep,10);Number.isNaN(g)||(a=g)}}catch(e){console.error("Invalid state param:",e)}var f,b,y=c?parseInt(c,10):NaN,v=Number.isNaN(y)?void 0:y,x=null!=n?n:v,h=i?parseInt(i,10):NaN,E=Number.isNaN(h)?void 0:h,N=null!=a?a:E;if(2!==x||1!==N&&2!==N&&3!==N&&4!==N||(Yn.current=N,1===N?Ve("environment"):2===N?(Ve("basic-config"),setTimeout(function(){var e;null===(e=Zn.current)||void 0===e||e.scrollIntoView({behavior:"smooth",block:"start"})},300)):3===N?Ve("revenue-correlation"):4===N&&Ve("pause-fix"),2===N&&"1"===m&&Ms(),f=new URLSearchParams(fn.toString()),b=!1,f.has("substep")&&(f.delete("substep"),b=!0),f.has("openSetupGuide")&&(f.delete("openSetupGuide"),b=!0),b&&bn(f,{replace:!0})),""!==V.accountId||(null==T||null===(e=T.formData)||void 0===e?void 0:e.accountId)||(null==R?void 0:R.accountId)||(null===(t=A.stripe)||void 0===t?void 0:t.accountId))o&&M();else if(2===n&&o){var w=function(){var e=(0,s.A)(u().mark(function e(){var t,n,a,r,s,l;return u().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(t=(0,H.Qb)())try{n=JSON.parse(t),B(function(e){return ve(ve({},e),{},{sourceName:n.sourceName||e.sourceName,secretKey:n.secretKey||e.secretKey,dataRetentionLocation:n.dataRetentionLocation||e.dataRetentionLocation,groupIdMapping:n.groupIdMapping||e.groupIdMapping,environmentId:n.environmentId||e.environmentId,environmentName:n.environmentName||e.environmentName,stripeEnvironment:n.stripeEnvironment||e.stripeEnvironment,syncStartDate:n.syncStartDate?new Date(n.syncStartDate):e.syncStartDate,accountId:""})})}catch(e){console.error("Error parsing saved form data:",e)}return e.prev=1,console.log("OAuth code received:",o),za(!0),e.next=2,bs({variables:{input:{accessCode:o}}});case 2:r=e.sent,s=null===(a=r.data)||void 0===a||null===(a=a.getStripeAccountDetails)||void 0===a?void 0:a.accountId,B(function(e){return ve(ve({},e),{},{accountId:s,accountIdEntryMode:s?"oauth":e.accountIdEntryMode})}),za(!1),M(),e.next=4;break;case 3:e.prev=3,l=e.catch(1),za(!1),console.error("Error processing OAuth code:",l),M(),alert("Failed to connect Stripe account. Please try again.");case 4:case"end":return e.stop()}},e,null,[[1,3]])}));return function(){return e.apply(this,arguments)}}();w()}},[T,R]);var Ys=R&&(null!=R.accountId||R.step4Completed||null!=R.ingestionResult||null!=(null===(w=R.formData)||void 0===w?void 0:w.accountId));(0,d.useEffect)(function(){if(Ys){if(B(function(e){var t,n,a,r,s,o,l,i,c,m,u,d,p,g,f,b,y,v,x,h,E,N,w,C,S,k,A,I,T,D,_,P,O;return ve(ve({},e),{},{sourceName:null!==(t=null!==(n=R.sourceName)&&void 0!==n?n:null===(a=R.formData)||void 0===a?void 0:a.sourceName)&&void 0!==t?t:"Stripe",accountId:null!==(r=null!==(s=R.accountId)&&void 0!==s?s:null===(o=R.formData)||void 0===o?void 0:o.accountId)&&void 0!==r?r:"",accountIdEntryMode:null!==(l=null!==(i=R.accountIdEntryMode)&&void 0!==i?i:null===(c=R.formData)||void 0===c?void 0:c.accountIdEntryMode)&&void 0!==l?l:e.accountIdEntryMode,stripeAccountName:null!==(m=null!==(u=R.str
1ipeAccountName)&&void 0!==u?u:null===(d=R.formData)||void 0===d?void 0:d.stripeAccountName)&&void 0!==m?m:e.stripeAccountName,secretKey:null!==(p=null!==(g=R.secretKey)&&void 0!==g?g:null===(f=R.formData)||void 0===f?void 0:f.secretKey)&&void 0!==p?p:"",dataRetentionLocation:null!==(b=null!==(y=R.dataRetentionLocation)&&void 0!==y?y:null===(v=R.formData)||void 0===v?void 0:v.dataRetentionLocation)&&void 0!==b?b:"",syncStartDate:(null!==(x=R.syncStartDate)&&void 0!==x?x:null===(h=R.formData)||void 0===h?void 0:h.syncStartDate)?new Date(null!==(E=R.syncStartDate)&&void 0!==E?E:R.formData.syncStartDate):he(),groupIdMapping:null!==(N=null!==(w=R.groupIdMapping)&&void 0!==w?w:null===(C=R.formData)||void 0===C?void 0:C.groupIdMapping)&&void 0!==N&&N,environmentId:null!==(S=null!==(k=R.environmentId)&&void 0!==k?k:null===(A=R.formData)||void 0===A?void 0:A.environmentId)&&void 0!==S?S:"",environmentName:null!==(I=null!==(T=R.environmentName)&&void 0!==T?T:null===(D=R.formData)||void 0===D?void 0:D.environmentName)&&void 0!==I?I:"",stripeEnvironment:null!==(_=null!==(P=R.stripeEnvironment)&&void 0!==P?P:null===(O=R.formData)||void 0===O?void 0:O.stripeEnvironment)&&void 0!==_?_:""})}),null!=R&&R.testingSteps&&R.testingSteps.length>0){var e;Qt(R.testingSteps);var t=R.testingSteps.find(function(e){return"schema"===e.id});null!=t&&null!==(e=t.customerMetaDataKeys)&&void 0!==e&&e.length&&(Ct(t.customerMetaDataKeys),Ft(!!we(t.customerMetaDataKeys)),t.selectedIdentifierKey&&t.customerMetaDataKeys.includes(t.selectedIdentifierKey)?bt(t.selectedIdentifierKey):bt(Ce(t.customerMetaDataKeys)))}if(void 0!==R.groupIdFound&&(It(R.groupIdFound),Ft(R.groupIdFound)),R.ingestionResult){Fn(R.ingestionResult);var n=R.ingestionResult.syncStatus;"pending"!==n&&"running"!==n&&"succeeded"!==n&&"failed"!==n||_a(n)}if(void 0!==R.testCompleted&&an(R.testCompleted),void 0!==R.isStep3Incomplete&&In(R.isStep3Incomplete),"boolean"==typeof R.isSetupIncomplete&&Tr(R.isSetupIncomplete),void 0!==R.step3Completed&&ra(R.step3Completed),void 0!==R.step4Completed&&ia(function(e){return!0===R.step4Completed||(!(!1!==R.step4Completed||"apiKeyOnly"!==_r||!zr||!e)||R.step4Completed)}),Yn.current||(Xn.current?(Ve(Xn.current),Xn.current=null):R.step4Completed?Ve("pause-fix"):R.step3Completed?Ve("revenue-correlation"):R.isSetupIncomplete?Ve("basic-config"):R.step2Completed?Ve("revenue-correlation"):R.step1Completed&&Ve("basic-config")),R.notificationEmails){var a=Object.entries(R.notificationEmails).filter(function(e){return"userEmail"!==(0,c.A)(e,1)[0]}).map(function(e){var t=(0,c.A)(e,2);t[0];return t[1]});P.setEmails(a)}Yn.current=null}else{var r=(null==A?void 0:A.stripe)&&Object.keys(A.stripe).length>0;if((!$n.current||!r||Xn.current)&&T){var s,o=new URLSearchParams(window.location.search).get("code"),l=(0,H.Qb)(),i=null===(s=T.formData)||void 0===s?void 0:s.accountId,m=r?A.stripe:T.formData;if(l&&o&&!i)try{var u=JSON.parse(l);B(function(e){return ve(ve({},e),{},{sourceName:u.sourceName||(null==m?void 0:m.sourceName)||"Stripe",accountId:u.accountId||(null==m?void 0:m.accountId)||"",secretKey:u.secretKey||(null==m?void 0:m.secretKey)||"",syncStartDate:u.syncStartDate?new Date(u.syncStartDate):null!=m&&m.syncStartDate?new Date(m.syncStartDate):he(),groupIdMapping:(null==m?void 0:m.groupIdMapping)||!1,environmentId:(null==m?void 0:m.environmentId)||"",environmentName:(null==m?void 0:m.environmentName)||"",stripeEnvironment:(null==m?void 0:m.stripeEnvironment)||""})})}catch(e){console.error("Error parsing localStorage:",e)}else m&&B(function(e){var t;return ve(ve({},e),{},{sourceName:m.sourceName||"Stripe",accountId:m.accountId||"",stripeAccountName:null!==(t=m.stripeAccountName)&&void 0!==t?t:e.stripeAccountName,secretKey:m.secretKey||e.secretKey,dataRetentionLocation:m.dataRetentionLocation||"",syncStartDate:m.syncStartDate?new Date(m.syncStartDate):he(),groupIdMapping:m.groupIdMapping||!1,environmentId:m.environmentId||"",environmentName:m.environmentName||"",stripeEnvironment:m.stripeEnvironment||""})});if(T.testingSteps&&T.testingSteps.length>0){Qt(T.testingSteps);var d=T.testingSteps.find(function(e){return"schema"===e.id});d&&d.customerMetaDataKeys&&d.customerMetaDataKeys.length>0&&(Ct(d.customerMetaDataKeys),Ft(!!we(d.customerMetaDataKeys)),d.selectedIdentifierKey&&d.customerMetaDataKeys.includes(d.selectedIdentifierKey)?bt(d.selectedIdentifierKey):bt(Ce(d.customerMetaDataKeys)))}if(T.testingSteps){var p=T.testingSteps.find(function(e){return"schema"===e.id});if(null!=p&&p.customerMetaDataKeys&&p.customerMetaDataKeys.length>0){var g=we(p.customerMetaDataKeys);Ft(!!g),g&&!p.selectedIdentifierKey&&bt(g)}}if(void 0!==T.groupIdFound&&(It(T.groupIdFound),Ft(T.groupIdFound)),null!=T&&T.testingSteps&&T.testingSteps.length>0&&Qt(T.testingSteps),T.ingestionResult){Fn(T.ingestionResult);var f=T.ingestionResult.syncStatus;"pending"!==f&&"running"!==f&&"succeeded"!==f&&"failed"!==f||_a(f)}if(void 0!==T.testCompleted&&an(T.testCompleted),void 0!==T.isStep3Incomplete&&In(T.isStep3Incomplete),"boolean"==typeof T.missingEntitiesAcknowledged){var b=T.missingEntitiesAcknowledged;zt(b),Jt(!b)}"boolean"==typeof T.isSetupIncomplete&&Tr(T.isSetupIncomplete),void 0!==T.step3Completed&&ra(T.step3Completed);var y=r&&"boolean"==typeof A.stripe.step4Completed?A.stripe.step4Completed:T.step4Completed;if("boolean"==typeof y&&ia(function(e){return!0===y||(!(!1!==y||"apiKeyOnly"!==_r||!zr||!e)||y)}),!Yn.current)if(Xn.current)Ve(Xn.current),Xn.current=null;else{var v=r?A.stripe:T;v.step4Completed?Ve("pause-fix"):v.step3Completed?Ve("revenue-correlation"):v.isSetupIncomplete?Ve("basic-config"):v.step2Completed?Ve("revenue-correlation"):v.step1Completed&&Ve("basic-config")}if(T.notificationEmails){var x=Object.entries(T.notificationEmails).filter(function(e){return"userEmail"!==(0,c.A)(e,1)[0]}).map(function(e){var t=(0,c.A)(e,2);t[0];return t[1]});P.setEmails(x)}}}},[T,R,A,_r,zr]),(0,d.useEffect)(function(){if(P.state.emails.length>0&&(T||R)){var e,t={userEmail:null===(e=(0,H.wz)())||void 0===e?void 0:e.email,additionalEmails:P.state.emails};I("stripe",{notificationEmails:t}),_(function(e){return ve(ve({},e),{},{notificationEmails:t})})}},[P.state.emails]),(0,d.useEffect)(function(){if(ct){var e=setInterval(function(){ln(function(e){return e>=3?1:e+1}
1)},500);return function(){return clearInterval(e)}}},[ct]),(0,d.useEffect)(function(){Ks()},[]),(0,d.useEffect)(function(){la&&!ua&&da(!0)},[la,ua]),(0,d.useEffect)(function(){var e,t;((null===(e=A.stripe)||void 0===e?void 0:e.step4WasEverCompleted)||(null==T?void 0:T.step4WasEverCompleted)||(null===(t=A.stripe)||void 0===t?void 0:t.step4CompletedAt)||(null==T?void 0:T.step4CompletedAt))&&!ua&&da(!0)},[null===(C=A.stripe)||void 0===C?void 0:C.step4WasEverCompleted,null==T?void 0:T.step4WasEverCompleted,null===(S=A.stripe)||void 0===S?void 0:S.step4CompletedAt,null==T?void 0:T.step4CompletedAt,ua]),(0,d.useEffect)(function(){B(W?function(e){return ve(ve({},e),{},{environmentId:ce,environmentName:me})}:function(e){var t,n;return ve(ve({},e),{},{environmentId:"".concat(null==is||null===(t=is.getEnvironmentsForProduct.environments.find(function(e){return(null==e?void 0:e.displayName)===(0,H.bb)()}))||void 0===t?void 0:t.id),environmentName:"".concat(null==is||null===(n=is.getEnvironmentsForProduct.environments.find(function(e){return(null==e?void 0:e.displayName)===(0,H.bb)()}))||void 0===n?void 0:n.displayName)})})},[is,W]);var Xs=function(e,t){B(function(n){return ve(ve({},n),{},(0,i.A)({},e,t))}),Ke[e]&&je(function(t){return ve(ve({},t),{},(0,i.A)({},e,void 0))})},Qs=function(){var e=(0,s.A)(u().mark(function e(){var t,n,a;return u().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(st.displayName){e.next=1;break}return e.abrupt("return");case 1:return e.prev=1,e.next=2,us({variables:{input:{name:st.displayName.toLowerCase().replace(/\s+/g,"-"),displayName:st.displayName,environmentType:st.environmentType}}});case 2:if(n=e.sent,null===(t=n.data)||void 0===t||null===(t=t.createEnvironmentCA)||void 0===t||!t.isSuccess){e.next=4;break}return ot({displayName:"",environmentType:J.OX.NonProduction}),nt(!1),e.next=3,Ks();case 3:e.next=5;break;case 4:console.error("Failed to create environment");case 5:e.next=7;break;case 6:e.prev=6,a=e.catch(1),console.error("Error creating environment:",a);case 7:case"end":return e.stop()}},e,null,[[1,6]])}));return function(){return e.apply(this,arguments)}}(),$s=function(){nt(!1),ot({displayName:"",environmentType:J.OX.NonProduction})},eo=function(e){var t=!(null==e||!e.keepIngestionResult);ra(!1),ia(!1),an(!1),Qt([{id:"connection",title:"Connection",loadingText:"Establishing Connection",successText:"Connected",errorText:"Connection Error",status:"pending"},{id:"data",title:"Data Retrieval",loadingText:"Retrieving Data Tables",successText:"Data Retrieved",errorText:"Unable to Retrieve Data",status:"pending"},{id:"schema",title:"Schema Verification",loadingText:"Verifying Schema",successText:"Schema Verified",errorText:"Schema Error Detected",status:"pending"}]),Ct([]),bt("group_id"),It(!1),t||Fn(null),Ln(null),ba(!1),_a("pending"),Fa(!1),La(null),Tr(!0)},to=function(){yr(V.sourceName),Qa(!0)},no=function(){Xs("sourceName",br),Qa(!1),yr("")},ao=function(){Qa(!1),yr("");var e=ve(ve({},V),{},{step1Completed:!(!V.environmentId||!V.stripeEnvironment),step2Completed:!!(V.sourceName&&V.accountId&&V.secretKey&&V.syncStartDate)});I("stripe",e),_(e),O()},ro=function(){Er(V.secretKey),nr(!0)},so=function(){Xs("secretKey",hr),nr(!1),Er(""),Kr(!1)},oo=function(){var e,t,n,a=!1;V.secretKey!==hr&&(eo({keepIngestionResult:!0}),a=!0),nr(!1),Er(""),a&&dr&&Kr(!0);var r=(null===(e=A.stripe)||void 0===e?void 0:e.ingestionResult)||Mn||null,s=!(!V.environmentId||!V.stripeEnvironment),o=!!(V.sourceName&&V.accountId&&V.secretKey&&V.syncStartDate),l=!a&&aa,i=!a&&la,c=ve(ve({},V),{},{step1Completed:s,step2Completed:o,step3Completed:l,step4Completed:i,step4WasEverCompleted:ua,isStep3Incomplete:!a&&An,customerMetaDataKeys:a?[]:wt,selectedIdentifierKey:a?Ae:ft,groupIdFound:!a&&At,groupIdMapping:!a&&V.groupIdMapping,testingSteps:a?[{id:"connection",title:"Connection",loadingText:"Establishing Connection",successText:"Connected",errorText:"Connection Error",status:"pending"},{id:"data",title:"Data Retrieval",loadingText:"Retrieving Data Tables",successText:"Data Retrieved",errorText:"Unable to Retrieve Data",status:"pending"},{id:"schema",title:"Schema Verification",loadingText:"Verifying Schema",successText:"Schema Verified",errorText:"Schema Error Detected",status:"pending"}]:Xt,testCompleted:!a&&nn,schemaVerified:(null===(t=A.stripe)||void 0===t?void 0:t.schemaVerified)||!1,status:(null===(n=A.stripe)||void 0===n?void 0:n.status)||"pending",completed:s&&o&&l&&i,isSetupIncomplete:a,ingestionResult:r});I("stripe",c),_(c),O()},lo=function(){Sr(V.syncStartDate instanceof Date?new Date(V.syncStartDate):null),or(!0)},io=function(){Cr&&Xs("syncStartDate",Cr),or(!1),Sr(null),Ne(!1),Ur(!1)},co=function(){var e,t,n,a=!1;Cr&&V.syncStartDate instanceof Date&&(a=V.syncStartDate.toISOString()!==Cr.toISOString());var r=!(!a||!dr);r&&(eo({keepIngestionResult:!0}),Ur(!0),mr(!1)),or(!1),Sr(null),Ne(!1);var s=!!(V.sourceName&&V.accountId&&V.secretKey&&V.syncStartDate),o=(null===(e=A.stripe)||void 0===e?void 0:e.ingestionResult)||Mn||null,l=ve(ve({},V),{},{step1Completed:!(!V.environmentId||!V.stripeEnvironment),step2Completed:(!r||!dr)&&s,step3Completed:!r&&aa,step4Completed:!r&&la,step4WasEverCompleted:ua,isStep3Incomplete:!r&&An,customerMetaDataKeys:r?[]:wt,selectedIdentifierKey:r?Ae:ft,groupIdFound:!r&&At,groupIdMapping:!r&&V.groupIdMapping,testingSteps:r?[{id:"connection",title:"Connection",loadingText:"Establishing Connection",successText:"Connected",errorText:"Connection
1Error",status:"pending"},{id:"data",title:"Data Retrieval",loadingText:"Retrieving Data Tables",successText:"Data Retrieved",errorText:"Unable to Retrieve Data",status:"pending"},{id:"schema",title:"Schema Verification",loadingText:"Verifying Schema",successText:"Schema Verified",errorText:"Schema Error Detected",status:"pending"}]:Xt,testCompleted:!r&&nn,schemaVerified:(null===(t=A.stripe)||void 0===t?void 0:t.schemaVerified)||!1,status:(null===(n=A.stripe)||void 0===n?void 0:n.status)||"pending",completed:!r&&(!(!V.environmentId||!V.stripeEnvironment)&&s&&aa&&la),isSetupIncomplete:r,ingestionResult:o});I("stripe",l),_(l),O()},mo=function(e,t){var n,a,r,s,o,l,i,c,m,u=null!==(n=null==t?void 0:t.testingSteps)&&void 0!==n?n:Xt,d=null!==(a=null==t?void 0:t.testCompleted)&&void 0!==a?a:nn,p=null!==(r=null==t?void 0:t.selectedIdentifierKey)&&void 0!==r?r:ft,g=null!==(s=null==t?void 0:t.customerMetaDataKeys)&&void 0!==s?s:wt,f=null!==(o=null==t?void 0:t.groupIdFound)&&void 0!==o?o:At,b=null!==(l=null==t?void 0:t.groupIdMapping)&&void 0!==l?l:!!p||V.groupIdMapping,y=null!==(i=null==t?void 0:t.missingEntitiesAcknowledged)&&void 0!==i?i:Bt,v=null!==(c=null==A?void 0:A.stripe)&&void 0!==c?c:{},x=null!==(m=null!=Mn?Mn:v.ingestionResult)&&void 0!==m?m:null,h=!0===v.step2Completed||!!(V.sourceName&&V.accountId&&V.secretKey&&V.syncStartDate),E=ve(ve({},V),{},{groupIdMapping:b,step1Completed:!(!V.environmentId||!V.stripeEnvironment),step2Completed:h,step3Completed:!0,step3CompletedAt:(new Date).toISOString(),isStep3Incomplete:e,step4Completed:la,step4CompletedAt:la?v.step4CompletedAt||(new Date).toISOString():void 0,ingestionResult:x,testingSteps:u.map(function(e){return ve(ve({},e),"schema"===e.id?{selectedIdentifierKey:p,customerMetaDataKeys:g}:{})}),testCompleted:d,schemaVerified:!0,selectedIdentifierKey:p,customerMetaDataKeys:g,groupIdFound:f,missingEntitiesAcknowledged:y,status:v.status||"pending",completed:!(!V.environmentId||!V.stripeEnvironment)&&h&&la,isSetupIncomplete:!1});I("stripe",E),_(E)},uo=function(){var e,t,n,a=!0===(null!==(e=null==A?void 0:A.stripe)&&void 0!==e?e:{}).step2Completed||!!(V.sourceName&&V.accountId&&V.secretKey&&V.syncStartDate),r=ve(ve({},V),{},{step1Completed:!(!V.environmentId||!V.stripeEnvironment),step2Completed:a,step3Completed:aa,step4Completed:la,isStep3Incomplete:An,testingSteps:Xt,testCompleted:nn,schemaVerified:(null===(t=A.stripe)||void 0===t?void 0:t.schemaVerified)||!1,status:(null===(n=A.stripe)||void 0===n?void 0:n.status)||"pending",completed:!(!V.environmentId||!V.stripeEnvironment)&&a&&aa&&la,isSetupIncomplete:Ir});I("stripe",r),_(r),r.step2Completed&&(0,H.wi)()},po=(Js.filter(function(e){return e.isCompleted}).length,Js.length,(0,d.useState)(V.syncStartDate instanceof Date?V.syncStartDate.getMonth():(new Date).getMonth())),go=(0,c.A)(po,2),fo=go[0],bo=go[1],yo=(0,d.useState)(V.syncStartDate instanceof Date?V.syncStartDate.getFullYear():(new Date).getFullYear()),vo=(0,c.A)(yo,2),xo=vo[0],ho=vo[1],Eo=(0,H.VG)()||"",No=function(e){if(!e||""===e.trim())return"";var t=e.trim().split(/\s+/);return 1===t.length?t[0].substring(0,2).toUpperCase():(t[0][0]+t[1][0]).toUpperCase()}(Eo),wo=function(){(0,H.mq)(JSON.stringify(V)),ea.current=!0;var e=window.location.origin+window.location.pathname;window.location.href="https://connect.stripe.com/oauth/v2/authorize?response_type=code"+"&client_id=".concat("ca_T8xPjuTQvqKSkwJ3adbiTXAFqTC7PxXi")+"&scope=read_write"+"&redirect_uri=".concat(encodeURIComponent(e))+"&state=".concat(encodeURIComponent(JSON.stringify({step:2,substep:2})))},Co=function(){var e,t,n,a,r,s,o,l,i,c,m=!!(V.sourceName&&V.accountId&&V.secretKey&&V.syncStartDate),u=dr&&!!V.accountId,p="manual"===V.accountIdEntryMode,g="oauth"===V.accountIdEntryMode,f=p||u&&!g;return d.createElement("div",{className:"space-y-8"},d.createElement("div",null,d.createElement("div",{className:"flex items-center gap-2 mb-2"},d.createElement("h3",{className:"text-lg font-semibold text-gray-900"},"2.1 Source Name"),V.sourceName&&d.createElement(y.CheckCircle,{className:"w-5 h-5 text-green-600"})),d.createElement("div",{className:"ml-7"},d.createElement("p",{className:"text-sm text-gray-600 mb-4"},"Give this data source a memorable name to easily identify it in your dashboard."),d.createElement("div",{className:"flex items-center gap-2"},d.createElement("input",{type:"text",placeholder:"Enter source name",value:V.sourceName,onChange:function(e){return Xs("sourceName",e.target.value)},readOnly:dr&&!(null===(e=A.stripe)||void 0===e||!e.sourceName)&&!Xa,className:"w-96 px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent ".concat(dr&&!Xa&&null!==(t=A.stripe)&&void 0!==t&&t.sourceName?"bg-gray-50 cursor-not-allowed":"")}),dr&&(null===(n=A.stripe)||void 0===n?void 0:n.sourceName)&&!Xa&&d.createElement("button",{type:"button",onClick:to,className:"p-2 text-blue-600 hover:text-blue-800 hover:bg-blue-50 rounded-md transition-colors",title:"Edit"},d.createElement(y.Pencil,{className:"w-4 h-4"})),Xa&&d.createElement("div",{className:"flex gap-2"},d.createElement("button",{type:"button",onClick:ao,className:"px-3 py-2 text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 rounded-md transition-colors whitespace-nowrap"},"Save"),d.createElement("button",{type:"button",onClick:no,className:"px-3 py-2 text-sm font-medium text-gray-700 hover:text-gray-900 border border-gray-300 rounded-md hover:bg-gray-50 transition-colors whitespace-nowrap"},"Cancel"))),Ke.sourceName&&d.createElement("p",{className:"text-red-600 text-sm mt-1"},Ke.sourceName))),d.createElement("div",{ref:Zn},d.createElement("div",{className:"flex items-center gap-2 mb-2"},d.createElement("h3",{className:"text-lg font-semibold text-gray-900"}
1,"2.2 Select Stripe Account"),V.accountId&&d.createElement(y.CheckCircle,{className:"w-5 h-5 text-green-600"})),d.createElement("div",{className:"ml-7"},d.createElement("p",{className:"text-sm text-gray-600 mb-4"},"Connect to the Stripe account you want to sync payment data from."),Ba&&d.createElement(y.Loader2,{className:"w-4 h-4 text-blue-600 animate-spin"}),!Ba&&(f?d.createElement("div",{className:"space-y-3"},d.createElement("div",{className:"relative flex items-center gap-2"},d.createElement("div",{className:"flex items-center max-w-md"},u?d.createElement("div",{className:"w-64 px-3 py-2 border border-gray-300 rounded-md bg-gray-50 cursor-not-allowed select-none text-gray-900 font-semibold",onCopy:function(e){return e.preventDefault()},onCut:function(e){return e.preventDefault()},onDragStart:function(e){return e.preventDefault()},onMouseDown:function(e){return e.preventDefault()}},V.accountId||"â"):d.createElement("input",{type:"text",placeholder:"Enter Stripe account ID",value:V.accountId||"",onChange:function(e){return Xs("accountId",e.target.value)},className:"w-64 px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent"})),u?d.createElement("div",{className:"flex items-center gap-2"},d.createElement("div",{className:"relative group"},d.createElement(y.Lock,{className:"w-4 h-4 text-gray-500"}),d.createElement("div",{className:"absolute bottom-full left-1/2 transform -translate-x-1/2 mb-2 px-3 py-2 bg-gray-900 text-white text-xs rounded-lg opacity-0 group-hover:opacity-100 transition-opacity duration-200 pointer-events-none whitespace-nowrap z-10"},"Stripe account ID is locked after you complete Basic Configuration.",d.createElement("div",{className:"absolute top-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-l-4 border-r-4 border-t-4 border-transparent border-t-gray-900"}))),d.createElement("div",{className:"relative group"},d.createElement(y.Info,{className:"w-4 h-4 text-gray-500 cursor-help"}),d.createElement("div",{className:"absolute bottom-full left-1/2 transform -translate-x-1/2 mb-2 px-3 py-2 bg-gray-900 text-white text-xs rounded-lg opacity-0 group-hover:opacity-100 transition-opacity duration-200 z-10 w-80"},"To use a different Stripe account ID, ",d.createElement("a",{href:"#",onClick:function(e){e.preventDefault(),j()},className:"font-semibold underline"},"go to Integrations list"),", delete this connection, and create a new one.",d.createElement("div",{className:"absolute top-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-l-4 border-r-4 border-t-4 border-transparent border-t-gray-900"})))):d.createElement("div",{className:"flex items-center gap-4"},d.createElement("div",{className:"relative group"},d.createElement(y.Info,{className:"w-4 h-4 text-blue-500 cursor-help",onClick:Fs}),d.createElement("div",{className:"absolute bottom-full left-1/2 transform -translate-x-1/2 mb-2 px-3 py-2 bg-gray-900 text-white text-xs rounded-lg opacity-0 group-hover:opacity-100 transition-opacity duration-200 pointer-events-none whitespace-nowrap z-10"},"Click to see how to find your Account ID",d.createElement("div",{className:"absolute top-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-l-4 border-r-4 border-t-4 border-transparent border-t-gray-900"}))),d.createElement("button",{type:"button",onClick:function(){B(function(e){return ve(ve({},e),{},{accountId:"",accountIdEntryMode:void 0,stripeAccountName:void 0})})},className:"text-sm text-blue-600 hover:text-blue-800 underline whitespace-nowrap"},"Use OAuth instead")))):V.accountId?d.createElement("div",{className:"space-y-3"},d.createElement("button",{type:"button",className:"px-4 py-2 bg-green-50 border border-green-200 text-green-700 rounded-md flex items-center gap-2",disabled:!0},d.createElement(y.CheckCircle,{className:"h-4 w-4"}),"Account Selected"),d.createElement("div",{className:"bg-gray-50 border border-gray-200 rounded-md p-4"},d.createElement("div",{className:"text-sm text-gray-700"},d.createElement("div",{className:"font-medium"},V.stripeAccountName||"Stripe Account"),d.createElement("div",{className:"mt-1 flex flex-wrap items-center gap-2"},d.createElement("span",null,"Account ID: ",V.accountId),u?d.createElement("div",{className:"flex items-center gap-2"},d.createElement("div",{className:"relative group"},d.createElement(y.Lock,{className:"w-4 h-4 text-gray-500"}),d.createElement("div",{className:"absolute bottom-full left-1/2 transform -translate-x-1/2 mb-2 px-3 py-2 bg-gray-900 text-white text-xs rounded-lg opacity-0 group-hover:opacity-100 transition-opacity duration-200 pointer-events-none whitespace-nowrap z-10"},"Stripe account is locked after you complete Basic Configuration.",d.createElement("div",{className:"absolute top-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-l-4 border-r-4 border-t-4 border-transparent border-t-gray-900"}))),d.createElement("div",{className:"relative group"},d.createElement(y.Info,{className:"w-4 h-4 text-gray-500 cursor-help"}),d.createElement("div",{className:"absolute bottom-full left-1/2 transform -translate-x-1/2 mb-2 px-3 py-2 bg-gray-900 text-white text-xs rounded-lg opacity-0 group-hover:opacity-100 transition-opacity duration-200 z-10 w-80"},"To use a different Stripe account, ",d.createElement("a",{href:"#",onClick:function(e){e.preventDefault(),j()},className:"font-semibold underline"},"go to Integrations list"),", delete this connection, and create a new one.",d.createElement("div",{className:"absolute top-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-l-4 border-r-4 border-t-4 border-transparent border-t-gray-900"})))):d.createElement(d.Fragment,null,d.createElement("button",{onClick:function(){W?Ja(!0):wo()},type:"button",className:"text-blue-600 underline hover:text-blue-800"},"Reconnect"),d.createElement("button",{type:"button",disabled:!0,className:"text-gray-400 cursor-not-allowed"},"Enter account ID manually")))))):d.createElement("div",{className:"flex items-center gap-3 flex-wrap"},d.createElement("button",{onClick:function(){W?Ja(!0):wo()},disabled:!W&&(!V.sourceName||Ba),className:"flex items-center justify-center space-x-2 px-4 py-2.5 bg-blue-600 text-white rounded-md hover:bg-blue-700 disabled:bg-gray-300 disabled:cursor-not-allowed transition-colors"},Ba?d.createElement(d.Fragment,null,d.createElement(y.Loader2,{className:"w-4 h-4 animate-spin"}),d.createElement("span",null,"Connecting...")):d.createElement(d.Fragment,null,d.createElement(N.kDV,{className:"w-4 h-4"}),d.createElement("span",null,"Select Account"))),d.createElement("button",{type:"button",onClick:function(){B(function(e){return ve(ve({},e),{},{accountIdEntryMode:"manual",stripeAccountName:void 0})})},disabled:g,className:"text-sm underline ".concat(g?"text-gray-400 cursor-not-allowed":"text-blue-600 hover:text-blue-800")},"Enter account ID manually"))))),d.createElement("div",{ref:Hn},d.createElement("div",{className:"flex items-center gap-2 mb-2"},d.createElement("h3",{className:"text-lg font-semibold text-gray-900"},"2.3 Secret Key"),V.secretKey&&d.createElement(y.CheckCircle,{className:"w-5 h-5 text-green-600"}),d.createElement("div",{className:"relative group"},d.createElement(y.Info,{className:"h-4 w-4 text-gray-400 cursor-help"}),d.createElement("div",{className:"absolute bottom-full left-1/2 transform -translate-x-1/2 mb-2 px-3 py-2 bg-gray-800 text-white text-sm rounded-lg opacity-0 group-hover:opacity-100 transition-opacity duration-200 pointer-events-none whitespace-nowrap z-10"},"Get your secret key from Stripe dashboard and paste it here for API access",d.createElement("div",{className:"absolute top-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-l-4 border-r-4 border-t-4 border-transparent border-t-gray-800"}
1)))),d.createElement("div",{className:"ml-7"},d.createElement("div",{className:"flex items-center gap-2 mb-4"},d.createElement("p",{className:"text-sm text-gray-600"},"Your Stripe secret key allows ThriveStack to securely access your payment data via the Stripe API."),d.createElement("a",{href:"#",onClick:function(e){e.preventDefault(),Ms()},className:"text-blue-600 underline text-sm cursor-pointer whitespace-nowrap"},"Show Documentation")),d.createElement("div",{className:"space-y-3 mb-4"},d.createElement("div",{className:"flex items-center gap-2"},d.createElement("span",{className:"text-sm text-gray-700"},"1. Get your key from Stripe"),d.createElement("a",{href:V.accountId?"https://dashboard.stripe.com/".concat(V.accountId,"/").concat("test"===V.stripeEnvironment?"test/":"","apikeys"):"https://dashboard.stripe.com/apikeys",target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 underline text-sm flex items-center gap-1"},"Get your key from Stripe",d.createElement(y.ExternalLink,{className:"h-3 w-3"}))),d.createElement("div",{className:"text-sm text-gray-700"},"2. Paste it below")),d.createElement("div",{className:"flex items-center gap-2 flex-wrap"},d.createElement("div",{className:"relative w-full max-w-md"},d.createElement("input",{type:X?"text":"password",placeholder:"sk_test_xxâ¢â¢â¢â¢XXX",value:V.secretKey,onChange:function(e){return Xs("secretKey",e.target.value)},readOnly:dr&&!(null===(a=A.stripe)||void 0===a||!a.secretKey)&&!tr,className:"w-full px-3 py-2 pr-10 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent ".concat(dr&&!tr&&null!==(r=A.stripe)&&void 0!==r&&r.secretKey?"bg-gray-50 cursor-not-allowed":"")}),d.createElement("button",{type:"button",className:"absolute right-3 top-1/2 transform -translate-y-1/2 text-gray-400 hover:text-gray-600",onClick:function(){return Q(!X)}},X?d.createElement(y.EyeOff,{className:"h-4 w-4"}):d.createElement(y.Eye,{className:"h-4 w-4"}))),dr&&(null===(s=A.stripe)||void 0===s?void 0:s.secretKey)&&!tr&&d.createElement("button",{type:"button",onClick:ro,className:"p-2 text-blue-600 hover:text-blue-800 hover:bg-blue-50 rounded-md transition-colors",title:"Edit"},d.createElement(y.Pencil,{className:"w-4 h-4"})),tr&&d.createElement("div",{className:"flex gap-2"},d.createElement("button",{type:"button",onClick:oo,className:"px-3 py-2 text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 rounded-md transition-colors whitespace-nowrap"},"Save"),d.createElement("button",{type:"button",onClick:so,className:"px-3 py-2 text-sm font-medium text-gray-700 hover:text-gray-900 border border-gray-300 rounded-md hover:bg-gray-50 transition-colors whitespace-nowrap"},"Cancel"))),tr&&d.createElement("div",{className:"mt-2 p-3 bg-yellow-50 border border-yellow-200 rounded-md"},d.createElement("p",{className:"text-sm text-yellow-800"},d.createElement("strong",null,"Warning:")," Changing the secret key will reset the setup and you need to run connection test and ingestion again with the updated credentials.")),Ke.secretKey&&d.createElement("p",{className:"text-red-600 text-sm mt-1"},Ke.secretKey))),d.createElement("div",null,d.createElement("div",{className:"flex items-center gap-2 mb-2"},d.createElement("h3",{className:"text-lg font-semibold text-gray-900"},"2.4 Sync Start Date"),V.syncStartDate&&d.createElement(y.CheckCircle,{className:"w-5 h-5 text-green-600"})),d.createElement("div",{className:"ml-7"},d.createElement("p",{className:"text-sm text-gray-600 mb-4"},"Choose the date from which you want to start syncing historical payment data."),d.createElement("div",{className:"flex items-center gap-2 flex-wrap"},d.createElement("div",{className:"relative max-w-md flex-1 min-w-[200px]"},d.createElement("button",{type:"button",onClick:function(){var e;dr&&!sr&&null!==(e=A.stripe)&&void 0!==e&&e.syncStartDate||Ne(!ye)},disabled:dr&&!(null===(o=A.stripe)||void 0===o||!o.syncStartDate)&&!sr,className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent text-left flex items-center justify-between ".concat(dr&&!sr&&null!==(l=A.stripe)&&void 0!==l&&l.syncStartDate?"bg-gray-50 cursor-not-allowed":"")},d.createElement("span",{className:V.syncStartDate?"text-gray-900":"text-gray-500"},V.syncStartDate instanceof Date?V.syncStartDate.toLocaleDateString("en-US",{weekday:"long",year:"numeric",month:"long",day:"numeric"}):"Pick a date"),d.createElement(y.CalendarIcon,{className:"h-4 w-4 text-gray-400"})),ye&&function(){for(var e=new Date,t=new Date(xo,fo,1),n=new Date(xo,fo+1,0),a=t.getDay(),r=n.getDate(),s=[],o=0;o<a;o++)s.push(d.createElement("div",{key:"empty-".concat(o),className:"p-2"}));for(var l=function(){var t=new Date(xo,fo,i),n=V.syncStartDate instanceof Date&&V.syncStartDate.toDateString()===t.toDateString(),a=t>e||t<new Date("2020-01-01");s.push(d.createElement("button",{key:i,type:"button",onClick:function(){a||(Xs("syncStartDate",t),Ne(!1))},disabled:a,className:"p-2 text-sm rounded hover:bg-gray-100 ".concat(n?"bg-blue-600 text-white hover:bg-blue-700":""," ").concat(a?"text-gray-400 cursor-not-allowed":"cursor-pointer")}
1,i))},i=1;i<=r;i++)l();for(var c=[],m=2020;m<=e.getFullYear();m++)c.push(m);return d.createElement("div",{className:"absolute z-10 mb-2 bottom-full bg-white border border-gray-300 rounded-md shadow-lg p-4 w-80"},d.createElement("div",{className:"flex items-center justify-between mb-4 gap-2"},d.createElement("button",{type:"button",onClick:function(){0===fo?(bo(11),ho(xo-1)):bo(fo-1)},className:"p-1 hover:bg-gray-100 rounded"},d.createElement("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},d.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"}))),d.createElement("div",{className:"flex gap-2"},d.createElement("select",{value:fo,onChange:function(e){return bo(parseInt(e.target.value))},className:"text-sm border border-gray-300 rounded px-2 py-1 focus:outline-none focus:ring-2 focus:ring-blue-500"},["January","February","March","April","May","June","July","August","September","October","November","December"].map(function(e,t){return d.createElement("option",{key:e,value:t},e)})),d.createElement("select",{value:xo,onChange:function(e){return ho(parseInt(e.target.value))},className:"text-sm border border-gray-300 rounded px-2 py-1 focus:outline-none focus:ring-2 focus:ring-blue-500"},c.map(function(e){return d.createElement("option",{key:e,value:e},e)}))),d.createElement("button",{type:"button",onClick:function(){11===fo?(bo(0),ho(xo+1)):bo(fo+1)},className:"p-1 hover:bg-gray-100 rounded"},d.createElement("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},d.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})))),d.createElement("div",{className:"grid grid-cols-7 gap-1 text-xs mb-2"},["Su","Mo","Tu","We","Th","Fr","Sa"].map(function(e){return d.createElement("div",{key:e,className:"p-2 text-center font-medium text-gray-500"},e)})),d.createElement("div",{className:"grid grid-cols-7 gap-1"},s))}()),dr&&(null===(i=A.stripe)||void 0===i?void 0:i.syncStartDate)&&!sr&&d.createElement("button",{type:"button",onClick:lo,className:"p-2 text-blue-600 hover:text-blue-800 hover:bg-blue-50 rounded-md transition-colors",title:"Edit"},d.createElement(y.Pencil,{className:"w-4 h-4"})),sr&&d.createElement("div",{className:"flex gap-2"},d.createElement("button",{type:"button",onClick:co,className:"px-3 py-2 text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 rounded-md transition-colors whitespace-nowrap"},"Save"),d.createElement("button",{type:"button",onClick:io,className:"px-3 py-2 text-sm font-medium text-gray-700 hover:text-gray-900 border border-gray-300 rounded-md hover:bg-gray-50 transition-colors whitespace-nowrap"},"Cancel"))),sr&&d.createElement("div",{className:"mt-2 p-3 bg-yellow-50 border border-yellow-200 rounded-md"},d.createElement("p",{className:"text-sm text-yellow-800"},d.createElement("strong",null,"Warning:")," Changing the sync start date will reset the setup and you need to run connection test and ingestion again with the updated settings.")),Ke.syncStartDate&&d.createElement("p",{className:"text-red-600 text-sm mt-1"},Ke.syncStartDate.toString()))),d.createElement("div",{className:"flex justify-end pt-4 border-t border-gray-200"},(c=!m||Xa||tr||sr,d.createElement("button",{type:"button",onClick:function(){if(mr(!0),Tr(!1),He(!0),Xn.current="revenue-correlation",Fr||Lr){Pr(Fr&&Lr?"both":Lr?"syncDateOnly":Fr?"apiKeyOnly":"none");var e=ve(ve({},V),{},{pendingSecretKeyChange:Fr,pendingSyncDateChange:Lr,step1Completed:!(!V.environmentId||!V.stripeEnvironment),step2Completed:!!(V.sourceName&&V.accountId&&V.secretKey&&V.syncStartDate)});I("stripe",e),_(e)}else uo();(0,H.wi)(),O(),Ve("revenue-correlation"),setTimeout(function(){var e;null===(e=Gn.current)||void 0===e||e.scrollIntoView({behavior:"smooth",block:"start"})},100)},disabled:c,className:"px-6 py-2 rounded-md font-medium transition-colors ".concat(c?"bg-gray-300 text-gray-500 cursor-not-allowed":"bg-blue-600 text-white hover:bg-blue-700")},"Save"))),d.createElement(fe,{isOpen:Ga,onClose:function(){return Ja(!1)},onConnect:js}
1))},So=function(){var e=(0,s.A)(u().mark(function e(){var t,n,a,r,s,o,l,i,c,m,d,p,g,f,b,y,v,x,h=arguments;return u().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return t=h.length>0&&void 0!==h[0]?h[0]:"SUCCESS",mt(!0),an(!1),De(null),dn(!1),In(!1),Lt(!1),zt(!1),Jt(!0),n=Xt.map(function(e){return ve(ve({},e),{},{status:"pending",missingEntities:[]})}),Qt(n),a=n.map(function(e){return ve({},e)}),e.prev=1,Qt(function(e){return e.map(function(e,t){return 0===t?ve(ve({},e),{},{status:"loading"}):e})}),a[0]=ve(ve({},a[0]),{},{status:"loading"}),e.next=2,new Promise(function(e){return setTimeout(e,500)});case 2:return e.next=3,Hs(t);case 3:return l=e.sent,Qt(function(e){return e.map(function(e,t){return 0===t?ve(ve({},e),{},{status:"success"}):e})}),a[0]=ve(ve({},a[0]),{},{status:"success"}),e.next=4,new Promise(function(e){return setTimeout(e,800)});case 4:return Qt(function(e){return e.map(function(e,t){return 1===t?ve(ve({},e),{},{status:"loading"}):e})}),a[1]=ve(ve({},a[1]),{},{status:"loading"}),setTimeout(function(){return dn(!0)},300),e.next=5,new Promise(function(e){return setTimeout(e,1e3)});case 5:if(i=(null==l?void 0:l.missingEntities)&&l.missingEntities.length>0,c=null!==(r=null==l?void 0:l.customers)&&void 0!==r?r:[],m=null==l||null===(s=l.missingEntities)||void 0===s?void 0:s.includes("customers"),d=m||0===c.length,Qt(function(e){return e.map(function(e,t){return 1===t?ve(ve({},e),{},{status:d||i?"error":"success",missingEntities:(null==l?void 0:l.missingEntities)||[]}):e})}),a[1]=ve(ve({},a[1]),{},{status:d||i?"error":"success",missingEntities:(null==l?void 0:l.missingEntities)||[]}),!d){e.next=6;break}return Lt(!0),setTimeout(function(){return dn(!1)},1200),mt(!1),an(!0),mo(!0,{testingSteps:a,testCompleted:!0}),e.abrupt("return");case 6:return setTimeout(function(){return dn(!1)},1200),e.next=7,new Promise(function(e){return setTimeout(e,800)});case 7:return Qt(function(e){return e.map(function(e,t){return 2===t?ve(ve({},e),{},{status:"loading"}):e})}),a[2]=ve(ve({},a[2]),{},{status:"loading"}),e.next=8,new Promise(function(e){return setTimeout(e,500)});case 8:return p=null!==(o=null==l?void 0:l.customerMetaDataKeys)&&void 0!==o?o:[],g=p.length>0,f=Ce(p,ft),b=!!we(p),y=g?"success":"error",Qt(function(e){return e.map(function(e,t){return 2===t?ve(ve({},e),{},{status:y,selectedIdentifierKey:f}):e})}),a[2]=ve(ve({},a[2]),{},{status:y,selectedIdentifierKey:f,customerMetaDataKeys:p}),e.next=9,new Promise(function(e){return setTimeout(e,800)});case 9:p.length>0&&bt(f),It(b),Ft(b),ra(!0),v=i||!b||!!ua&&An,ua?i&&In(!0):In(i||!b),mo(ua?v:i||!b,{testingSteps:a,testCompleted:!0,selectedIdentifierKey:f,customerMetaDataKeys:p,groupIdFound:b}),e.next=11;break;case 10:e.prev=10,x=e.catch(1),console.error("Test failed:",x),a=a.map(function(e){return"loading"===e.status?ve(ve({},e),{},{status:"error"}):e}),Qt(function(e){return e.map(function(e){return"loading"===e.status?ve(ve({},e),{},{status:"error"}):e})}),an(!0),mo(!0,{testingSteps:a,testCompleted:!0});case 11:mt(!1),an(!0);case 12:case"end":return e.stop()}},e,null,[[1,10]])}));return function(){return e.apply(this,arguments)}}(),ko=function(){var e,t,n=Xt.find(function(e){return"data"===e.id}),a="pending"===(null==n?void 0:n.status)||"loading"===(null==n?void 0:n.status),r="error"===(null==n?void 0:n.status)&&!qt&&(null!==(e=null===(t=n.missingEntities)||void 0===t?void 0:t.length)&&void 0!==e?e:0)>0,o=!qt&&(Bt||!r&&!(ct&&a));return d.createElement("div",{className:"mt-4 space-y-3 border border-gray-200 p-4 rounded-lg"},Xt.map(function(e){var t,n,a,r;if("schema"===e.id&&!o)return null;var i,c=W&&"schema"===e.id&&"success"===e.status,m=c?ke[Rt]:wt,p=Ce(m,ft),g=c?!!we(m):At,f=!g&&m.length>0,b=f&&!Mt;return d.createElement("div",{key:e.id,className:"flex items-start space-x-3"},d.createElement("div",{className:"flex-shrink-0 mt-1 text-lg"},"loading"===e.status&&d.createElement(y.Loader2,{className:"w-4 h-4 text-blue-600 animate-spin"}),"success"===e.status&&d.createElement(y.CheckCircle,{className:"w-4 h-4 text-green-600"}),"error"===e.status&&d.createElement(y.AlertTriangle,{className:"w-4 h-4 text-red-600"}),"pending"===e.status&&d.createElement("div",{className:"w-4 h-4 rounded-full border-2 border-gray-300"})),d.createElement("div",{className:"flex-1"},d.createElement("div",{className:"font-medium text-gray-900 text-lg flex items-center justify-between gap-3 flex-wrap"},d.createElement("span",null,"loading"===e.status&&e.loadingText,"success"===e.status&&e.successText,"error"===e.status&&("data"===e.id?"Failed to Retrieve Data":e.errorText),"pending"===e.status&&e.loadingText),c&&d.createElement("div",{className:"flex items-center gap-2"},Se.map(function(e){return d.createElement("button",{key:e.id,type:"button",onClick:function(){_t(e.id),Ft("no_group_id"!==e.id),ht(!1)},className:"px-2 py-1 text-xs rounded-md border transition-colors ".concat(Rt===e.id?"bg-blue-600 text-white border-blue-600":"bg-white text-blue-600 border-blue-600 hover:bg-blue-50")},e.label)}))),"data"===e.id&&"pending"!==e.status&&d.createElement("div",{className:"mt-2"},d.createElement("button",{type:"button",onClick:function(){return dn(!un)},className:"flex items-center space-x-2 text-blue-600 hover:text-blue-800 text-sm font-medium mb-2"},d.createElement(y.ChevronDown,{className:"w-4 h-4 transition-transform ".concat(un?"":"-rotate-90")}),d.createElement("span",null,"List of Entities Syncing")),un&&d.createElement("div",{className:"border-l-2 border-gray-200 pl-4 ml-6 transition-all duration-500 ease-in-out transform"},d.createElement("div",{className:"space-y-2"},d.createElement("div",{className:"text-sm text-gray-600"},"Total tables in Stripe: ",d.createElement("span",{className:"font-medium text-gray-900"},Ee.available.length)),d.createElement("div",{className:"text-sm text-gray-600"}
1,"Tables to be synced to TS: ",d.createElement("span",{className:"font-medium text-gray-900"},Ee.willSync.length),d.createElement("ul",{className:"flex flex-col ml-1 mt-2 space-y-1"},Ee.willSync.map(function(t){var n,a=null===(n=e.missingEntities)||void 0===n?void 0:n.includes(t);return d.createElement("li",{key:t,className:"flex items-center space-x-2 text-sm"},a?d.createElement(y.X,{className:"w-4 h-4 text-red-600 flex-shrink-0"}):d.createElement(y.Check,{className:"w-4 h-4 text-green-600 flex-shrink-0"}),d.createElement("span",{className:a?"text-red-700 font-medium":"text-gray-700"},t))})))))),"data"===e.id&&"error"===e.status&&qt&&d.createElement("div",{className:"space-y-4 mt-3"},d.createElement("div",{className:"p-4 bg-red-50 rounded-md"},d.createElement("div",{className:"space-y-3"},d.createElement("h4",{className:"font-semibold text-gray-900 text-base"},"No customer data found â ",d.createElement("span",{className:"font-normal"},"No customers was found for this secret key.")),d.createElement("div",{className:"flex items-center gap-3 flex-wrap"},d.createElement("button",{type:"button",className:"px-4 py-2 bg-white border border-gray-300 hover:bg-gray-50 text-gray-700 rounded-md font-medium text-sm transition-colors",onClick:function(){return So("SUCCESS")}},"Retry Test"),d.createElement("button",{type:"button",className:"px-4 py-2 bg-white border border-gray-300 hover:bg-gray-50 text-gray-700 rounded-md font-medium text-sm transition-colors",onClick:Vs},"Change Credentials"))))),"data"===e.id&&"error"===e.status&&!qt&&e.missingEntities&&e.missingEntities.length>0&&d.createElement("div",{className:"space-y-4 mt-3"},d.createElement("div",{className:"p-4 bg-red-50 rounded-md"},Bt&&d.createElement("button",{type:"button",onClick:function(){return Jt(!Gt)},className:"w-full flex items-start gap-2 text-left"},d.createElement(y.ChevronDown,{className:"w-4 h-4 text-red-600 flex-shrink-0 mt-1 transition-transform ".concat(Gt?"":"-rotate-90")}),d.createElement("h4",{className:"font-semibold text-gray-900 text-base"},"Unable to retrieve some entities â ",d.createElement("span",{className:"font-normal"},"Your secret key doesn't have access to ",(null===(t=e.missingEntities)||void 0===t?void 0:t.length)||0," / ",Ee.willSync.length," required Stripe ",1===(null===(n=e.missingEntities)||void 0===n?void 0:n.length)?"table":"tables","."))),(!Bt||Gt)&&d.createElement("div",{className:"space-y-3 ".concat(Bt?"mt-3 pl-6":"")},!Bt&&d.createElement("h4",{className:"font-semibold text-gray-900 text-base"},"Unable to retrieve some entities â ",d.createElement("span",{className:"font-normal"},"Your secret key doesn't have access to ",(null===(a=e.missingEntities)||void 0===a?void 0:a.length)||0," / ",Ee.willSync.length," required Stripe ",1===(null===(r=e.missingEntities)||void 0===r?void 0:r.length)?"table":"tables",".")),d.createElement("h4",{className:"font-semibold text-gray-900 text-base"},"To resolve this, you need to"," ",d.createElement("button",{type:"button",onClick:function(){oe(!0),setTimeout(function(){var e=document.querySelector('[data-section="setup-stripe"]');e&&e.scrollIntoView({behavior:"smooth",block:"start"})},100)},className:"text-blue-600 hover:text-blue-800 underline font-medium"},"configure your secret key's permissions"),"."),d.createElement("div",{className:"bg-white p-3 rounded space-y-4"},d.createElement("div",{className:"text-sm font-medium text-gray-900"},"Missing entities and revenue impact:"),d.createElement("ul",{className:"space-y-4"},(i=e.missingEntities,i.includes("subscriptions")?["subscriptions"].concat((0,l.A)(i.filter(function(e){return"subscriptions"!==e}))):i).map(function(e){var t,n=function(e){var t,n,a=null!==(t=ge[e])&&void 0!==t?t:e;return null!==(n=pe[a])&&void 0!==n?n:pe[e]}(e),a="subscriptions"===e;return d.createElement("li",{key:e,className:"border-b border-gray-100 pb-3 last:border-b-0 last:pb-0"},d.createElement("div",{className:"flex items-start gap-2"},d.createElement(y.X,{className:"w-4 h-4 text-red-600 flex-shrink-0 mt-0.5"}),d.createElement("div",{className:"space-y-1.5 flex-1 min-w-0"},d.createElement("span",{className:"text-base font-semibold text-red-700"},null!==(t=null==n?void 0:n.label)&&void 0!==t?t:e),(null==n?void 0:n.affectedReports)&&n.affectedReports.length>0&&d.createElement("p",{className:"text-xs text-gray-600"},d.createElement("span",{className:"font-medium text-gray-700"},"Affected Metrics: "),n.affectedReports.join(", ")),(null==n?void 0:n.explanation)&&d.createElement("p",{className:"text-sm text-gray-700 leading-relaxed"},n.explanation),a&&d.createElement("div",{className:"mt-3 bg-amber-50 text-amber-700 rounded-xl px-5 py-4"},d.createElement("div",{className:"flex items-start gap-2"},d.createElement(y.AlertTriangle,{className:"w-4 h-4 mt-0.5 flex-shrink-0"}),d.createElement("div",{className:"text-sm space-y-2"},d.createElement("p",null,"If you are not using Stripe Billing for subscriptions or used only as a payment gateway, switch to a transaction-based connection:"),d.createElement("ol",{className:"list-decimal pl-5 space-y-1.5"},d.createElement("li",null,d.createElement("a",{href:"#",onClick:function(e){e.preventDefault(),j()},className:"font-semibold underline"},"Go to Integrations")," ","and delete this Stripe connection."),d.createElement("li",null,"In ",d.createElement("span",{className:"font-medium"},"Data Source")," (Step 1 of revenue setup), choose ",d.createElement("span",{className:"font-medium"},"Transactions & Invoices"),"."),d.createElement("li",null,"Choose ",d.createElement("span",{className:"font-medium"},"Stripe")," and set up the connection again."))))))))}))),d.createElement("div",{className:"flex items-center gap-3 flex-wrap"},d.createElement("button",{type:"button",className:"px-4 py-2 bg-white border border-gray-300 hover:bg-gray-50 text-gray-700 rounded-md font-medium text-sm transition-colors",onClick:function(){return So("SUCCESS")}},"Retry Test"),d.createElement("button",{type:"button",className:"px-4 py-2 bg-white border border-gray-300 hover:bg-gray-50 text-gray-700 rounded-md font-medium text-sm transition-colors",onClick:Vs},"Change Credentials"),!Bt&&d.createElement("button",{type:"button",className:"px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-md font-medium text-sm transition-colors",onClick:Bs},"Proceed Anyway"))))),"schema"===e.id&&"pending"!==e.status&&(!m||0===m.length)&&d.createElement("div",{className:"space-y-3 mt-3"},d.createElement("p",{className:"text-sm text-gray-700"},"Account identifier key is missing in Stripe customer metadata. Fix it to enable correlation across product, marketing and revenue data."),d.createElement(be.i,{source:"stripe",accountIdentifierKey:Ae}),d.createElement("div",{className:"flex items-center gap-3"},d.createElement("button",{type:"button",className:"px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-md font-medium text-sm transition-colors inline-flex items-center gap-2",onClick:(0,s.A)(u().mark(function e(){var t;return u().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!Fr&&!Lr){e.next=5;break}return as(!0),$r(null),e.prev=1,e.next=2,ws({variables:{input:{environmentId:V.environmentId,sourceType:se.pqc.Stripe,startDate:V.syncStartDate instanceof Date?V.syncStartDate.toISOString().split(".")[0]+"Z":(new Date).toISOString().split(".")[0]+"Z",apiKey:V.secretKey,shouldReset:!1}}});case 2:e.next=4;break;case 3:return e.prev=3,t=e.catch(1),console.error("Failed to update Stripe source:",t),$r("Something went wrong, try again"),as(!1),e.abrupt("return");case 4:as(!1);case 5:hn(k.V.REVOPS_TEAMS),Cn(!0),In(!0),ra(!0),mo(!0,{selectedIdentifierKey:Ae,groupIdMapping:!0}),Xn.current="pause-fix",Ve("pause-fix"),O();case 6:case"end":return e.stop()}},e,null,[[1,3]])}
1)),disabled:ns},ns&&d.createElement(y.Loader2,{className:"w-4 h-4 animate-spin"}),ns?"Saving...":Qr?"Retry Invite and Proceed":"Invite and Proceed"),d.createElement("button",{type:"button",className:"px-4 py-2 bg-white border border-gray-300 hover:bg-gray-50 text-gray-700 rounded-md font-medium text-sm transition-colors",onClick:zs,disabled:ns},"Proceed Anyway")),Qr&&d.createElement("span",{className:"text-red-600 text-sm font-medium ml-3"},Qr)),"schema"===e.id&&m&&m.length>0&&d.createElement(d.Fragment,null,d.createElement("div",{className:"space-y-4 mt-3"},d.createElement("div",{className:"p-4 bg-gray-50 rounded-lg"},d.createElement("div",{className:"space-y-3"},d.createElement("div",null,d.createElement("p",{className:"text-sm text-gray-900 mb-3"},"To uniquely identify the account information and to correlate it with revenue data, we look at the following key. This key enables seamless correlation across revenue, marketing, and product data.")),d.createElement("div",null,d.createElement("label",{className:"block text-sm font-medium text-gray-700 mb-2"},"Account Identifier Key"),d.createElement("div",{className:"relative"},d.createElement("button",{type:"button",onClick:function(){var e=!xt;ht(e),e&&f&&Ft(!0)},className:"w-64 px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent bg-white text-left flex items-center justify-between"},d.createElement("span",{className:"flex items-center gap-1 text-gray-900 font-medium"},b&&d.createElement(y.AlertTriangle,{className:"w-4 h-4 text-amber-600"}),d.createElement("span",null,p)),d.createElement(y.ChevronDown,{className:"w-4 h-4 text-gray-400 transition-transform ".concat(xt?"rotate-180":"")})),xt&&d.createElement("div",{className:"absolute z-10 w-64 mt-1 bg-white border border-gray-300 rounded-md shadow-lg max-h-60 overflow-auto"},d.createElement("div",{className:"py-1"},m.map(function(e){return d.createElement("button",{key:e,type:"button",onClick:function(){bt(e),ht(!1),Qt(function(t){return t.map(function(t){return"schema"===t.id?ve(ve({},t),{},{selectedIdentifierKey:e,customerMetaDataKeys:m}):t})})},className:"w-full px-3 py-2 text-left text-sm hover:bg-blue-50 hover:text-blue-900 flex items-center justify-between"},d.createElement("span",null,e),p===e&&d.createElement(y.Check,{className:"w-4 h-4 text-blue-600"}))}))),g&&d.createElement(d.Fragment,null,d.createElement("p",{className:"flex items-center gap-x-1 text-sm bg-amber-50 text-amber-700 rounded-xl px-5 py-4 mb-3 mt-2"},d.createElement(y.AlertTriangle,{className:"w-4 h-4 flex-shrink-0"}),d.createElement("span",null,"Group ID is set as the default account identifier. Please select an alternative key from the dropdown menu if this is incorrect."))),!g&&d.createElement("div",{className:"mt-3"},d.createElement("div",{className:"bg-amber-50 text-amber-700 rounded-xl px-5 py-4"},d.createElement("div",{className:"flex items-start gap-2"},d.createElement(y.AlertTriangle,{className:"w-4 h-4 mt-0.5 flex-shrink-0"}),d.createElement("div",{className:"text-sm"},d.createElement("p",{className:"mb-1"},"group_id was not found in the customer metadata from Stripe."),d.createElement("ul",{className:"pl-5 space-y-2"},d.createElement("li",{className:"list-disc"},d.createElement("span",{className:"font-medium"},"Option 1:")," Select the correct account identifier from the dropdown above."),d.createElement("li",{className:"list-none text-center text-xs font-semibold uppercase tracking-wide text-amber-700"},"OR"),d.createElement("li",{className:"list-disc"},d.createElement("span",{className:"font-medium"},"Option 2:")," Resolve this by using the AI-assisted or manual steps below to add the missing key in customer metadata of Stripe.")))))),d.createElement("p",{className:"flex items-center text-sm text-gray-700 mx-2 mb-2"},"If your product telemetry's account identifier key is missing from the dropdown, use the tabs below to resolve this.",d.createElement("button",{type:"button",onClick:function(){return _n(!0)},className:"text-blue-600 underline hover:text-blue-800 ml-1"},"See the guide"),"."),d.createElement(be.i,{source:"stripe",accountIdentifierKey:Ae}))),d.createElement("div",{className:"flex items-center gap-3 pt-2"},d.createElement("button",{type:"button",onClick:Us,disabled:ns,className:"px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-md font-medium text-sm transition-colors inline-flex items-center gap-2 ".concat(ns?"opacity-70 cursor-not-allowed":"")},ns&&d.createElement(y.Loader2,{className:"w-4 h-4 animate-spin"}),ns?"Saving...":Qr?"Retry Invite and Proceed":"Invite and Proceed"),d.createElement("button",{type:"button",onClick:Ls,disabled:ns,className:"px-4 py-2 bg-white border border-blue-600 hover:bg-blue-50 text-blue-600 rounded-md font-medium text-sm transition-colors inline-flex items-center gap-2 ".concat(ns?"opacity-70 cursor-not-allowed":"")},ns&&d.createElement(y.Loader2,{className:"w-4 h-4 animate-spin"}),ns?"Saving...":Qr?"Retry Save and Proceed":"Save and Proceed"),Qr&&d.createElement("span",{className:"text-red-600 text-sm font-medium"},Qr))))))))}))},Ao=function(){var e,t=("apiKeyOnly"===Gs||"both"===Gs||"syncDateOnly"===Gs)&&ua,n=!la,a=function(){var e=(0,s.A)(u().mark(function e(){var t,n,a,r,s,o,l,i,c,m,d,p,g,f,b,y,v,x,h,E,N,w,C,S,k,T,D,R,P,M,F,K,j,L,U,B;return u().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,Ln(null),n="apiKeyOnly"===(t=Fr&&Lr?"both":Lr?"syncDateOnly":Fr?"apiKeyOnly":"none")||"both"===t||"syncDateOnly"===t,!Fr&&!Lr||!ur||!n){e.next=5;break}return as(!0),$r(null),e.prev=1,e.next=2,ws({variables:{input:{environmentId:V.environmentId,sourceType:se.pqc.Stripe,startDate:V.syncStartDate instanceof Date?V.syncStartDate.toISOString().split(".")[0]+"Z":(new Date).toISOString().split(".")[0]+"Z",apiKey:V.secretKey,shouldReset:!1}}});case 2:e.next=4;break;case 3:return e.prev=3,U=e.catch(1),console.error("Failed to update Stripe source:",U),$r("Failed to update source configuration"),as(!1),Ln("Failed to update source configuration. Please try again."),e.abrupt("return");case 4:as(!1);case 5:if(n||(ba(!0),Ca(0),ha($t),Fn(null)),"apiKeyOnly"!==t){e.next=7;break}return e.next=6,As({variables:{input:{environmentId:V.environmentId,dataSource:se.qSh.Stripe}}});case 6:return s=e.sent,null!==(r=s.data)&&void 0!==r&&null!==(r=r.triggerSync)&&void 0!==r&&r.isSuccess?(m=(new Date).toISOString(),ia(!0),_a("running"),Fa(!0),Tr(!1),Wr(!0),d=(null===(o=A.stripe)||void 0===o?void 0:o.ingestionResult)||Mn,p=d?ve(ve({},d),{},{syncStatus:"running",syncStartedAt:m}):null,Fn(p),Kr(!1),Ur(!1),g=!0===(null===(l=A.stripe)||void 0===l?void 0:l.step2Completed)||!!(V.sourceName&&V.accountId&&V.secretKey&&V.syncStartDate),f=ve(ve({},V),{},{status:"configured",completed:!0,completedAt:m,step1Completed:!(!V.environmentId||!V.stripeEnvironment),step2Completed:g,step3Completed:aa,step3CompletedAt:(null===(i=A.stripe)||void 0===i?void 0:i.step3CompletedAt)||m,step4Completed:!0,step4WasEverCompleted:!0,step4CompletedAt:m,isStep3Incomplete:An,testingSteps:Xt,testCompleted:nn,schemaVerified:(null===(c=A.stripe)||void 0===c?void 0:c.schemaVerified)||!1,selectedIdentifierKey:ft,customerMetaDataKeys:wt,groupIdFound:At,ingestionResult:p,isSetupIncomplete:!1,pendingSecretKeyChange:!1,pendingSyncDateChange:!1}),I("stripe",f),_(f),O()):Ln("Failed to trigger resync"),e.abrupt("return");case 7:if("syncDateOnly"!==t&&"both"!==t){e.next=9;break}return e.next=8,Rs({variables:{input:{environmentId:V.environmentId,sourceType:se.pqc.Stripe}}});case 8:return y=e.sent,null!==(b=y.data)&&void 0!==b&&null!==(b=b.resetAndResyncAirbyteData)&&void 0!==b&&b.isSuccess?(N=(new Date).toISOString(),ia(!0),_a("running"),Fa(!0),Tr(!1),Wr(!0),w=(null===(v=A.stripe)||void 0===v?void 0:v.ingestionResult)||Mn,C=w?ve(ve({},w),{},{syncStatus:"running",syncStartedAt:N}):null,Fn(C),Kr(!1),Ur(!1),S=!0===(null===(x=A.stripe)||void 0===x?void 0:x.step2Completed)||!!(V.sourceName&&V.accountId&&V.secretKey&&V.syncStartDate),k=ve(ve({},V),{},{status:"configured",completed:!0,completedAt:N,step1Completed:!(!V.environmentId||!V.stripeEnvironment),step2Completed:S,step3Completed:aa,step3CompletedAt:(null===(h=A.stripe)||void 0===h?void 0:h.step3CompletedAt)||N,step4Completed:!0,step4WasEverCompleted:!0,step4CompletedAt:N,isStep3Incomplete:An,testingSteps:Xt,testCompleted:nn,schemaVerified:(null===(E=A.stripe)||void 0===E?void 0:E.schemaVerified)||!1,selectedIdentifierKey:ft,customerMetaDataKeys:wt,groupIdFound:At,ingestionResult:C,isSetupIncomplete:!1,pendingSecretKeyChange:!1,pendingSyncDateChange:!1}),I("stripe",k),_(k),O()):Ln((null===(T=y.data)||void 0===T||null===(T=T.resetAndResyncAirbyteData)||void 0===T?void 0:T.message)||"Failed to reset and resync"),e.abrupt("return");case 9:if(!W){e.next=11;break}
1return e.next=10,ie({environmentId:V.environmentId,stripeEnvironmentType:V.stripeEnvironment,stripeAccountId:V.accountId,stripeSecretKey:V.secretKey,syncStartTime:V.syncStartDate instanceof Date?V.syncStartDate.toISOString():(new Date).toISOString()});case 10:a=e.sent,e.next=13;break;case 11:return R="live"===V.stripeEnvironment?se.bTM.Live:se.bTM.Test,e.next=12,xs({variables:{input:{environmentId:V.environmentId,integrationType:se.pqc.Stripe,syncStartTime:V.syncStartDate instanceof Date?V.syncStartDate.toISOString().split(".")[0]+"Z":(new Date).toISOString().split(".")[0]+"Z",stripeConfig:{environmentType:R,accountId:V.accountId||"",secretKey:V.secretKey}}}});case 12:P=e.sent,null!==(D=P.data)&&void 0!==D&&D.createAirbyteIntegration&&(a=P.data.createAirbyteIntegration);case 13:if(!a){e.next=14;break}return j=!0===(null===(M=A.stripe)||void 0===M?void 0:M.step2Completed)||!!(V.sourceName&&V.accountId&&V.secretKey&&V.syncStartDate),L=ve(ve({},V),{},{status:"configured",completed:!0,completedAt:(new Date).toISOString(),step1Completed:!(!V.environmentId||!V.stripeEnvironment),step2Completed:j,step3Completed:aa,step3CompletedAt:aa&&(null===(F=A.stripe)||void 0===F?void 0:F.step3CompletedAt)||(new Date).toISOString(),step4Completed:!0,step4WasEverCompleted:!0,step4CompletedAt:(new Date).toISOString(),isStep3Incomplete:An,testingSteps:Xt,testCompleted:nn,schemaVerified:(null===(K=A.stripe)||void 0===K?void 0:K.schemaVerified)||!1,selectedIdentifierKey:ft,customerMetaDataKeys:wt,groupIdFound:At,ingestionResult:{sourceId:a.sourceId,connectionId:a.connectionId,syncStartedAt:a.syncStartedAt,syncStatus:a.syncStatus,jobId:a.jobId},isSetupIncomplete:!1}),I("stripe",L),_(L),ia(!0),null==q||q(),Fn({sourceId:a.sourceId,connectionId:a.connectionId,syncStartedAt:a.syncStartedAt,syncStatus:a.syncStatus,jobId:a.jobId}),_a("running"),Fa(!0),Tr(!1),a.syncStartedAt&&La(a.syncStartedAt),O(),e.abrupt("return",a.syncStatus);case 14:e.next=16;break;case 15:e.prev=15,B=e.catch(0),console.error("Failed to start Stripe ingestion:",B),Ln(B instanceof Error?B.message:"Unknown error occurred");case 16:case"end":return e.stop()}},e,null,[[0,15],[1,3]])}));return function(){return e.apply(this,arguments)}}(),r=la&&!!Mn||la&&zr&&("running"===Ra||"pending"===Ra)||t&&(Is||_s),o=n&&!Is&&!_s;return d.createElement("div",{className:"space-y-6"},r&&d.createElement("div",{className:"rounded-lg p-4 ".concat("succeeded"===Ra?"bg-green-50":"failed"===Ra?"bg-red-50":"bg-blue-50")},d.createElement("div",{className:"flex items-start space-x-3"},"running"===Ra&&d.createElement(y.Loader2,{className:"w-5 h-5 text-blue-600 mt-0.5 flex-shrink-0 animate-spin"}),"succeeded"===Ra&&d.createElement(y.CheckCircle,{className:"w-5 h-5 text-green-600 mt-0.5 flex-shrink-0"}),"failed"===Ra&&d.createElement(y.AlertTriangle,{className:"w-5 h-5 text-red-600 mt-0.5 flex-shrink-0"}),"pending"===Ra&&d.createElement(y.Loader2,{className:"w-5 h-5 text-blue-600 mt-0.5 flex-shrink-0 animate-spin"}),d.createElement("div",{className:"flex-1"},d.createElement("h4",{className:"font-semibold text-xl mb-1 ".concat("succeeded"===Ra?"text-green-900":"failed"===Ra?"text-red-900":"text-blue-900")},"running"===Ra||"pending"===Ra?"Processing Ingestion":"succeeded"===Ra?"Ingestion Completed Successfully":"failed"===Ra?"Ingestion Failed":"Processing Ingestion"),d.createElement("p",{className:"text-sm mb-2 ".concat("succeeded"===Ra?"text-green-800":"failed"===Ra?"text-red-800":"text-blue-800")},"running"===Ra||"pending"===Ra?"We're currently syncing your Stripe data. This process may take a 5-7 minutes. You'll receive an email notification once complete.":"succeeded"===Ra?"Your Stripe data has been successfully synced and is ready for analysis.":"failed"===Ra?"There was an error syncing your Stripe data. Please try again or contact support.":"We're currently syncing your Stripe data. This process may take a 5-7 minutes. You'll receive an email notification once complete."),d.createElement("div",{className:"text-xs ".concat("succeeded"===Ra?"text-green-700":"failed"===Ra?"text-red-700":"text-blue-700")},qa&&d.createElement("div",{className:"flex items-center gap-2 mb-1"},d.createElement("span",{className:"font-medium"},"Last synced:"),d.createElement("span",null,new Date(qa).toLocaleStr
1ing("en-US",{weekday:"short",year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"})),Ma&&d.createElement("div",{className:"w-1.5 h-1.5 bg-blue-500 rounded-full animate-pulse",title:"Checking status every 30 seconds"})),!qa&&(null==Mn?void 0:Mn.syncStartedAt)&&d.createElement("div",{className:"flex items-center gap-2 mb-1"},d.createElement("span",{className:"font-medium"},"Sync started at:"),d.createElement("span",null,new Date(Mn.syncStartedAt).toLocaleString("en-US",{weekday:"short",year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"})),Ma&&d.createElement("div",{className:"w-1.5 h-1.5 bg-blue-500 rounded-full animate-pulse",title:"Checking status every 30 seconds"})),d.createElement("div",{className:"mt-1"},d.createElement("span",{className:"font-medium"},"Status:")," ",d.createElement("span",{className:"font-semibold ".concat("succeeded"===Ra?"text-green-600":"failed"===Ra?"text-red-600":"running"===Ra||"pending"===Ra?"text-blue-600":"text-gray-600")},"succeeded"===Ra?"Completed":"failed"===Ra?"Failed":"running"===Ra||"pending"===Ra?"In Progress":"Pending")),"failed"===Ra&&d.createElement("div",{className:"mt-1"},d.createElement("span",{className:"font-medium"},"Status:")," ",d.createElement("span",{className:"text-red-600 font-semibold"},"Failed"))),d.createElement("div",{className:"mt-6"},d.createElement("p",{className:"text-sm text-blue-800 mb-3"},"Notification will be sent to: ",d.createElement("p",{className:"font-semibold"},"".concat(null===(e=(0,H.wz)())||void 0===e?void 0:e.email))),P.state.showInput?d.createElement("div",{className:"space-y-2"},d.createElement("label",{className:"block text-sm text-blue-900"},"Add additional email addresses where youâd like to receive notifications."),d.createElement("div",{className:"relative"},d.createElement("input",{type:"text",value:P.state.inputValue,onChange:function(e){return P.handleInputChange(e.target.value)},onKeyDown:P.handleKeyDown,placeholder:"Enter email and press Enter or comma",className:"w-full px-3 py-2 border rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 text-sm ".concat(P.state.error?"border-red-500":"border-gray-300")}),P.state.error&&d.createElement("p",{className:"text-red-600 text-xs mt-1"},P.state.error)),P.state.emails.length>0&&d.createElement("div",{className:"flex flex-wrap gap-2 mb-2"},P.state.emails.map(function(e,t){return d.createElement("div",{key:t,className:"flex items-center gap-1 px-3 py-1 bg-gray-200 rounded-full text-sm"},d.createElement("span",null,e),d.createElement("button",{type:"button",onClick:function(){return P.removeEmail(e)},className:"hover:bg-blue-200 rounded-full p-0.5 transition-colors"},d.createElement(y.X,{className:"w-3 h-3"})))})),P.state.showUpdateButton&&d.createElement("button",{type:"button",onClick:Zs,className:"px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-md text-sm font-medium transition-colors"},"Update Notification Emails")):d.createElement("button",{type:"button",onClick:P.toggleInput,className:"flex items-center gap-2 px-4 py-2 text-sm font-medium text-blue-600 bg-white border border-blue-600 rounded-md hover:bg-blue-50 transition-colors"},d.createElement(y.UserPlus,{className:"w-4 h-4"}),"Add Additional Emails"))))),o&&d.createElement(d.Fragment,null,d.createElement("p",null,"syncDateOnly"===Gs||"apiKeyOnly"===Gs||"both"===Gs?"Start a new sync with modified configurations.":"Start ingestion of your data from Stripe by starting the data sync. First time syncing of all data will take a while to populate the revenue analytics dashboard."),d.createElement("button",{type:"button",onClick:a,disabled:"apiKeyOnly"===Gs?!aa||Is||Cs:"syncDateOnly"===Gs||"both"===Gs?!aa||_s||Cs:!nn||hs,className:"px-6 py-3 rounded-md bg-blue-600 hover:bg-blue-700 text-white font-medium transition-colors disabled:opacity-50 disabled:cursor-not-allowed flex items-center space-x-2"},(hs||Is||_s)&&d.createElement(y.Loader2,{className:"w-4 h-4 animate-spin"}),d.createElement("span",null,"apiKeyOnly"===Gs||"both"===Gs?Is?"Starting Resync...":"Resync Stripe data":"syncDateOnly"===Gs?_s?"Starting Resync...":"Resync Stripe data":hs?"Starting Ingestion...":"Start Ingestion")),An&&d.createElement("p",null,d.createElement("strong",null,"Note:")," You can start Data Ingestion now and see revenue analytics data and fix the schema for data correlation later. ")),qn&&d.createElement("div",{className:"bg-red-50 rounded-lg p-4"},d.createElement("div",{className:"flex items-start space-x-3"},d.createElement(y.AlertTriangle,{className:"w-5 h-5 text-red-600 mt-0.5 flex-shrink-0"}),d.createElement("div",{className:"flex-1"},d.createElement("h4",{className:"text-sm font-semibold text-red-900 mb-1"},"Failed to Start Ingestion"),d.createElement("p",{className:"text-sm text-red-800"},"Something went wrong, Please try again.")))),!t&&d.createElement("div",null,fa?d.createElement("div",{className:"mt-4 space-y-3 border border-gray-200 p-4 rounded-lg"},xa.map(function(e,t){return d.createElement("div",{key:e.id,className:"flex items-start space-x-3"},d.createElement("div",{className:"flex-shrink-0 mt-1 text-lg"},"loading"===e.status&&d.createElement(y.Loader2,{className:"w-4 h-4 text-blue-600 animate-spin"}),"success"===e.status&&d.createElement(y.CheckCircle,{className:"w-4 h-4 text-green-600"}),"error"===e.status&&d.createElement(y.AlertTriangle,{className:"w-4 h-4 text-red-600"}),"pending"===e.status&&d.createElement("div",{className:"w-4 h-4 rounded-full border-2 border-gray-300"})),d.createElement("div",{className:"flex-1"},d.createElement("div",{className:"font-medium text-gray-900 text-lg"},"loading"===e.status&&e.loadingText,"success"===e.status&&e.successText,"error"===e.status&&e.errorText,"pending"===e.status&&e.loadingText)))})):null),r&&d.createElement("div",{className:"mt-4 ml-6 space-y-4"},d.createElement("div",null,"You can continue to ",d.createElement("strong",null,"Core Revenue Calculation")," to set up currency and other fee-related configurations while the sync completes in background.")))},Io=function(e){switch(e.id){case"environment":return d.createElement("div",{className:"space-y-6"},d.createElement("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6"},d.createElement("div",null,d.createElement("label",{className:"block text-sm font-medium text-gray-700 mb-2"},"Stripe Environment"),d.createElement("div",{className:"relative","data-dropdown":"stripe-environment"},d.createElement("button",{type:"button",onClick:function(){return Qe(!Xe)},className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent bg-white text-left flex items-center justify-between"},d.createElement("span",{className:V.stripeEnvironment?"text-gray-900 font-semibold":"text-gray-500"},"live"===V.stripeEnvironment?"Live":"test"===V.stripeEnvironment?"Test":"Select Stripe Environment"),d.createElement(y.ChevronDown,{className:"w-4 h-4 text-gray-400 transition-transform ".concat(Xe?"rotate-180":"")})),Xe&&d.createElement("div",{className:"absolute z-10 w-full mt-1 bg-white border border-gray-300 rounded-md shadow-lg"},d.createElement("div",{className:"py-1"},d.createElement("button",{type:"button",onClick:function(){Xs("stripeEnvironment","live"),Qe(!1)},className:"w-full px-3 py-2 text-left text-sm hover:bg-blue-50 hover:text-blue-900 flex items-center justify-between"},d.createElement("span",null,"Live"),"live"===V.stripeEnvironment&&d.createElement(y.CheckCircle,{className:"w-4 h-4 text-blue-600"})),d.createElement("button",{type:"button",onClick:function(){Xs("stripeEnvironment","test"),Qe(!1)},className:"w-full px-3 py-2 text-left text-sm hover:bg-blue-50 hover:text-blue-900 flex items-center justify-between"},d.createElement("span",null,"Test"),"test"===V.stripeEnvironment&&d.createElement(y.CheckCircle,{className:"w-4 h-4 text-blue-600"})))))),d.createElement("div",null,d.createElement("label",{className:"block text-sm font-medium text-gray-700 mb-2"},"ThriveStack Environment"),d.createElement("div",{className:"w-full px-3 py-2 border border-gray-300 rounded-md bg-gray-100 text-left flex items-center justify-between cursor-not-allowed"},d.createElement("span",{className:"text-gray-900 font-semibold"},V.environmentName?V.environmentName.charAt(0).toUpperCase()+V.environmentName.slice(1).toLowerCase():"Development"),d.createElement(y.ChevronDown,{className:"w-4 h-4 text-gray-400"})),d.createElement("p",{className:"text-xs text-gray-500 mt-1"},"To change this, change the environment from the navigation bar"))),d.createElement("div",{className:"flex justify-end pt-4 border-t border-gray-200"},d.createElement("button",{type:"button",onClick:function(){uo(),Xn.current="basic-config",Ve("basic-config"),setTimeout(function(){var e;null===(e=Wn.current)||void 0===e||e.scrollIntoView({behavior:"smooth",block:"start"})},100),O()}
1,disabled:!(V.environmentId&&V.stripeEnvironment),className:"px-6 py-2 rounded-md font-medium transition-colors ".concat(V.environmentId&&V.stripeEnvironment?"bg-blue-600 text-white hover:bg-blue-700":"bg-gray-300 text-gray-500 cursor-not-allowed")},"Next")));case"basic-config":return Co();case"revenue-correlation":return d.createElement("div",{className:"space-y-6"},d.createElement("div",null,d.createElement("p",{className:"text-gray-700 leading-relaxed text-sm"},"We will use the credentials from ",d.createElement("span",{className:"font-medium text-gray-900"},"Basic Configuration")," (step 2) to test the connection with Stripe and sync sample data of 200 Transactions."),d.createElement("div",{className:"flex items-center gap-3 mt-2 flex-wrap"},d.createElement("button",{type:"button",className:"px-4 py-2 rounded-md font-medium transition-all duration-200 flex items-center space-x-2 min-w-[120px] justify-center ".concat(ct?"bg-blue-600 text-white cursor-default":"bg-blue-600 hover:bg-blue-700 active:bg-blue-800 text-white shadow-sm hover:shadow-md"),onClick:function(){return So("SUCCESS")},disabled:ct},ct?d.createElement(d.Fragment,null,d.createElement(y.Database,{className:"w-4 h-4"}),d.createElement("span",null,"Testing",".".repeat(on))):nn?d.createElement(d.Fragment,null,d.createElement(y.Database,{className:"w-4 h-4"}),d.createElement("span",null,"Retry")):d.createElement(d.Fragment,null,d.createElement(y.Database,{className:"w-4 h-4"}),d.createElement("span",null,"Test Data Sync"))),W&&!ct&&d.createElement(d.Fragment,null,d.createElement("button",{type:"button",className:"px-4 py-2 rounded-md font-medium transition-all duration-200 flex items-center space-x-2 border border-blue-600 bg-white text-blue-600 hover:bg-blue-50",onClick:function(){return So("MISSING_ENTITIES")}},d.createElement(y.Database,{className:"w-4 h-4"}),d.createElement("span",null,"Simulate Missing Entities")),d.createElement("button",{type:"button",className:"px-4 py-2 rounded-md font-medium transition-all duration-200 flex items-center space-x-2 border border-blue-600 bg-white text-blue-600 hover:bg-blue-50",onClick:function(){return So("MISSING_GROUP_ID")}},d.createElement(y.Database,{className:"w-4 h-4"}),d.createElement("span",null,"Simulate Schema Error"))),nn&&qs()&&d.createElement(d.Fragment,null,d.createElement("div",{className:"flex items-center space-x-3"},d.createElement("div",{className:"flex items-center space-x-2 text-green-600"},d.createElement(y.CheckCircle,{className:"w-4 h-4"}),d.createElement("span",{className:"text-sm font-medium"},"Test Completed - Schema Verified"))))),ko(),nn&&qs()&&(!wt||0===wt.length)&&d.createElement("button",{type:"button",onClick:function(){mo(!1),Xn.current="pause-fix",Ve("pause-fix"),ra(!0)},className:"flex px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-md text-sm font-medium mt-4 ml-auto"},"Proceed to Next Step")));case"pause-fix":return Ao();default:return null}};return d.createElement("div",{className:"bg-white"},d.createElement("div",{className:"container mt-8"},d.createElement("div",{className:""},d.createElement("div",{className:"mx-auto w-full bg-white rounded-lg"},d.createElement("form",{onSubmit:function(e){e.preventDefault()},className:"space-y-8"},d.createElement("div",{className:"relative"},d.createElement("div",{className:"absolute left-5 w-0.5 bg-gray-300",style:function(){if(Wn.current&&Gn.current&&Jn.current){var e=Wn.current.getBoundingClientRect().height,t=Gn.current.getBoundingClientRect().height,n=Jn.current.getBoundingClientRect().height;if("pause-fix"===Ue)return{top:"4rem",bottom:"".concat(n-10,"px")};if("revenue-correlation"===Ue)return{top:"4rem",bottom:"".concat(t-10,"px")};if("basic-config"===Ue)return{top:"4rem",bottom:"".concat(e-10,"px")}}return{top:"4rem",bottom:"4rem"}}()}),d.createElement("div",{className:"bg-white rounded-lg shadow-sm border border-gray-200 relative z-10 ml-10"},Js.map(function(e,t){return d.createElement("div",{key:e.id,ref:"basic-config"===e.id?Wn:"revenue-correlation"===e.id?Gn:"pause-fix"===e.id?Jn:null,className:"border-b border-gray-200 last:border-b-0 transition-all duration-300 ease-in-out ".concat(e.isActive?"bg-blue-50":"")},(a=aa,r=(Fr||Lr)&&!pr,s=("revenue-correlation"===e.id||"pause-fix"===e.id)&&(!pr||r),o=Jr&&"pause-fix"===e.id&&!a,l=s||o,d.createElement("div",{className:"relative ".concat(l?"group":"")},d.createElement("button",{type:"button",onClick:function(){if(!l){He(!0);var t=e.isActive?"":e.id;t&&(Xn.current=t),Ve(t)}},"aria-disabled":l,className:"w-full flex items-center justify-between p-4 text-left transition-colors ".concat(l?"cursor-not-allowed opacity-70":"hover:bg-gray-50")},d.createElement("div",{className:"flex items-center gap-4 flex-1"},d.createElement("div",{ref:"environment"===e.id?Un:"basic-config"===e.id?Vn:"revenue-correlation"===e.id?Bn:zn,className:"absolute -left-10 w-8 h-8 flex items-center justify-center rounded-full font-semibold text-sm z-10 border-2 transition-all duration-300 ".concat(e.isCompleted?"border-green-500":e.isActive?"bg-blue-500 text-white border-blue-500":"bg-gray-100 text-gray-600 border-gray-300"),style:e.isCompleted?{backgroundColor:"rgb(34, 197, 94)",color:"rgb(255, 255, 255)"}:{}},e.number),d.createElement("div",{className:"flex-1"},d.createElement("div",{className:"flex items-center justify-between gap-4"},d.createElement("div",{className:"flex items-center gap-2"},d.createElement("div",{className:"font-semibold text-gray-900 text-lg"},e.title),e.required&&!An&&d.createElement("span",{className:"text-red-800 text-lg"},"*")),"environment"===e.id&&e.isCompleted&&d.createElement("div",{className:"flex items-center"}
1,(n=nn,V.environmentId&&V.stripeEnvironment?d.createElement("div",{className:"flex items-center justify-center space-x-3 py-3"},d.createElement("div",{className:"flex flex-col items-center space-y-1 group relative"},d.createElement("div",{className:"text-[10px] font-semibold text-gray-400 uppercase tracking-wide"},"Your Stripe"),d.createElement("div",{className:"flex items-center space-x-2 cursor-help"},d.createElement("div",{className:"w-6 h-6 rounded-full border-2 border-blue-600 flex items-center justify-center bg-white"},d.createElement("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none"},d.createElement("path",{d:"M13.976 9.15c-2.172-.806-3.356-1.426-3.356-2.409 0-.831.683-1.305 1.901-1.305 2.227 0 4.515.858 6.09 1.631l.89-5.494C18.252.975 15.697 0 12.165 0 9.667 0 7.589.654 6.104 1.872 4.56 3.147 3.757 4.992 3.757 7.218c0 4.039 2.467 5.76 6.476 7.219 2.585.92 3.445 1.574 3.445 2.583 0 .98-.84 1.545-2.354 1.545-2.808 0-5.671-1.226-7.59-2.335l-.928 5.494C4.926 22.41 8.03 24 11.89 24c2.606 0 4.655-.587 6.148-1.688 1.572-1.165 2.369-2.874 2.369-5.083 0-4.359-2.64-6.165-6.431-7.374z",fill:"#635BFF"}))),d.createElement("div",{className:"text-xs font-semibold text-gray-700"},V.stripeEnvironment.charAt(0).toUpperCase()+V.stripeEnvironment.slice(1).toLowerCase())),d.createElement("div",{className:"absolute bottom-full mb-2 left-1/2 -translate-x-1/2 px-3 py-1.5 bg-gray-900 text-white text-xs rounded shadow-lg whitespace-nowrap opacity-0 group-hover:opacity-100 transition-opacity pointer-events-none z-10"},"Your Stripe environment: ",V.stripeEnvironment.charAt(0).toUpperCase()+V.stripeEnvironment.slice(1).toLowerCase(),d.createElement("div",{className:"absolute top-full left-1/2 -translate-x-1/2 border-4 border-transparent border-t-gray-900"}))),d.createElement("div",{className:"flex items-center space-x-1 pt-4"},d.createElement("div",{className:"w-6 h-0.5 bg-blue-600"}),d.createElement("div",{className:"w-6 h-6 bg-transparent rounded-full flex items-center justify-center border-2",style:{borderColor:n?"#16a34a":"#eab308"}},n?d.createElement("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"#16a34a",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round"},d.createElement("polyline",{points:"20 6 9 17 4 12"})):d.createElement("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"#eab308",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round"},d.createElement("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),d.createElement("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"}))),d.createElement("svg",{className:"w-8 h-3",viewBox:"0 0 32 12",fill:"none"},d.createElement("path",{d:"M0 6 L26 6",stroke:"#2563eb",strokeWidth:"2"}),d.createElement("path",{d:"M22 2 L30 6 L22 10",stroke:"#2563eb",strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"}))),d.createElement("div",{className:"flex flex-col items-center space-y-1 group relative"},d.createElement("div",{className:"text-[10px] font-semibold text-gray-400 uppercase tracking-wide"},Eo||"Product"),d.createElement("div",{className:"flex items-center space-x-2 cursor-help"},d.createElement("div",{className:"w-6 h-6 rounded-full flex items-center justify-center border-2 border-blue-600 bg-white"},d.createElement("span",{className:"text-blue-600 text-[9px] font-bold"},No)),d.createElement("div",{className:"text-xs font-semibold text-gray-700 max-w-20 truncate"},V.environmentName.charAt(0).toUpperCase()+V.environmentName.slice(1).toLowerCase())),d.createElement("div",{className:"absolute bottom-full mb-2 left-1/2 -translate-x-1/2 px-3 py-1.5 bg-gray-900 text-white text-xs rounded shadow-lg whitespace-nowrap opacity-0 group-hover:opacity-100 transition-opacity pointer-events-none z-10"},"Your Stripe data is syncing to your ",V.environmentName.charAt(0).toUpperCase()+V.environmentName.slice(1).toLowerCase()," ",d.createElement("br",null),' environment within ThriveStack for "',Eo,'". Status: ',n?"Successful":"Pending",d.createElement("div",{className:"absolute top-full left-1/2 -translate-x-1/2 border-4 border-transparent border-t-gray-900"})))):null)),d.createElement("div",{className:"flex items-center gap-4"},e.isCompleted&&d.createElement("div",{className:"px-3 py-1 rounded-full text-xs font-medium bg-green-50 text-green-800"},"Completed"),"revenue-correlation"===e.id&&An&&d.createElement("div",{className:"inline-flex items-center gap-1 px-2 py-1 rounded-full text-xs font-medium bg-red-500 text-red-100 h-5"},d.createElement(y.AlertTriangle,{className:"w-3 h-3"}),d.createElement("span",null,"Action Required")))),"environment"===e.id?d.createElement("div",{className:"text-sm text-gray-500"},e.subtitle):d.createElement("div",{className:"text-sm text-gray-500"},e.description))),d.createElement(y.ChevronDown,{className:"w-4 h-4 text-gray-400 transition-transform duration-300 ml-2 ".concat(e.isActive?"rotate-180":"")})),l&&d.createElement("div",{className:"absolute bottom-full left-1/2 -translate-x-1/2 mb-2 px-3 py-2 bg-gray-900 text-white text-xs rounded-lg opacity-0 group-hover:opacity-100 transition-opacity duration-200 pointer-events-none whitespace-nowrap z-20"},o?"Complete Step 3 to proceed.":"Complete Basic Configurations Step.",d.createElement("div",{className:"absolute top-full left-1/2 -translate-x-1/2 w-0 h-0 border-l-4 border-r-4 border-t-4 border-transparent border-t-gray-900"})))),e.isActive&&d.createElement("div",{className:"border-t border-gray-200 p-6 bg-white transition-all duration-300 ease-in-out"},Io(e)));var n,a,r,s,o,l}))))))),te&&d.createElement("div",{className:"fixed inset-0 z-50 overflow-hidden"},d.createElement("div",{className:"absolute inset-0 bg-black bg-opacity-50",onClick:function(){return oe(!1)}}),d.createElement("div",{className:"absolute right-0 top-0 h-full w-[600px] bg-white shadow-xl overflow-y-auto"},d.createElement("div",{className:"p-4 border-b border-gray-200"},d.createElement("div",{className:"flex items-center justify-between"},d.createElement("h2",{className:"text-xl font-semibold"},"Setup Guide: Stripe"),d.createElement("button",{onClick:function(){return oe(!1)},className:"text-gray-400 hover:text-gray-600 transition-colors"},d.createElement(y.X,{className:"w-5 h-5"})))),d.createElement("div",{className:"p-6"},d.createElement(ae.e,{step3Ref:ut,accountIdRef:dt,setExpanded:Ia,expanded:Aa})))),d.createElement(ne,{open:Pe,onOpenChange:Oe,onProceed:function(){De("proceed"),ra(!0),In(!0),Xn.current="pause-fix",Ve("pause-fix")}}),wn&&d.createElement(re.O,{isOpen:wn,onClose:function(){return Cn(!1)},team:xn,onInvite:function(){},source:"stripe"===D?D:void 0}),d.createElement(be.S,{isOpen:Rn,onClose:function(){return _n(!1)},onInviteTeam:function(e){hn(e),Cn(!0),In(!0),ra(!0),mo(!0),Xn.current="pause-fix",Ve("pause-fix"),O()},accountIdentifierKey:Ae}),tt&&d.createElement("div",{className:"fixed inset-0 bg-gray-600 bg-opacity-50 flex items-center justify-center z-20"},d.createElement("div",{className:"bg-white rounded-lg shadow-xl max-w-md w-full mx-4"},d.createElement("div",{className:"flex items-center justify-between p-6 border-b border-gray-200"},d.createElement("h3",{className:"text-lg font-semibold text-gray-900"},"Create New Environment"),d.createElement("button",{onClick:$s,className:"text-gray-400 hover:text-gray-600 transition-colors"},d.createElement(y.X,{className:"w-5 h-5"}))),d.createElement("div",{className:"p-6 space-y-4"},d.createElement("div",null,d.createElement("label",{className:"block text-sm font-medium text-gray-700 mb-1"},"Environment Name ",d.createElement("span",{className:"text-red-500"},"*")),d.createElement("input",{type:"text",value:st.displayName,onChange:function(e){return ot(function(t){return ve(ve({},t),{},{displayName:e.target.value})})},className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent",placeholder:"Enter environment name"})),d.createElement("div",null,d.createElement("label",{className:"block text-sm font-medium text-gray-700 mb-1"},"Environment Type ",d.createElement("span",{className:"text-red-500"}
1,"*")),d.createElement("select",{value:st.environmentType,onChange:function(e){return ot(function(t){return ve(ve({},t),{},{environmentType:e.target.value})})},className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent"},d.createElement("option",{value:J.OX.Production},"Production"),d.createElement("option",{value:J.OX.NonProduction},"NonProduction")))),d.createElement("div",{className:"flex items-center justify-end space-x-3 p-6 border-t border-gray-200"},d.createElement("button",{onClick:$s,className:"px-4 py-2 text-sm font-medium text-blue-600 bg-white border border-blue-600 rounded-md hover:bg-blue-50 transition-colors"},"Cancel"),d.createElement("button",{onClick:Qs,disabled:!st.displayName||ds,className:"px-4 py-2 text-sm font-medium text-white bg-blue-600 rounded-md hover:bg-blue-700 disabled:bg-gray-300 disabled:cursor-not-allowed transition-colors flex items-center space-x-2"},ds&&d.createElement("div",{className:"w-4 h-4 border-2 border-white border-t-transparent rounded-full animate-spin"}),d.createElement("span",null,ds?"Creating...":"Create Environment"))))))},Te=n(48944),De=n(31214);function Re(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,a)}return n}function _e(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){(0,i.A)(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 Pe(e){if(null==e||!e.length)return null;var t=e.filter(function(e){var t=(e.dataSource||"").toString().toUpperCase(),n=(e.syncType||"").toLowerCase();return"CHARGEBEE"===t&&"sync"===n});return 0===t.length?null:(0,l.A)(t).sort(function(e,t){var n=e.startTime?new Date(e.startTime).getTime():0;return(t.startTime?new Date(t.startTime).getTime():0)-n})[0]}var Oe=function(){var e=new Date;return e.setMonth(e.getMonth()-12),e},Me={available:["addon","customer","subscription","invoice","item_price","plan","item","transaction","event","credit_note","payment_source","subscription_entitlement","item_entitlement","coupon","promotional_credit","unbilled_charge","order","gift","quote","attached_item","differential_price","virtual_bank_account"],willSync:["addon","customer","subscription","invoice","item_price","plan","item","transaction","event"]},Fe=function(e){return e.toLowerCase().replace(/[_\s-]/g,"")},Ke=function(e){var t=Fe("group_id");return e.find(function(e){return Fe(e)===t})||null},je=function(e){var t,n,a,r,o,l,m,f,b,v,x=e.sourceConfigurations,h=e.updateSourceConfiguration,E=(e.onComplete,e.loadedChargebeeData),N=e.selectedSources,C=e.config,S=e.setConfig,A=(e.onStepComplete,e.emailManager),I=e.onAutoSave,T=e.cleanOAuthParams,D=e.openSetupGuideRef,R=e.onOpenIntegrationsList,_=e.onTrackCompletion,P=(0,d.useState)({sourceName:"Chargebee",subdomain:"",apiKey:"",secretKey:"",productCatalog:"2.0",dataRetentionLocation:"",syncStartDate:Oe(),groupIdMapping:!1,environmentId:"",environmentName:"",chargebeeEnvironment:"",chargebeeFeePerTransaction:0,paymentGatewayFees:0,accountId:""}),O=(0,c.A)(P,2),M=O[0],K=O[1],j=(0,F._K)(),q=j.isDemoMode,L=(0,d.useState)(!1),U=(0,c.A)(L,2),V=U[0],B=U[1],z=(0,d.useState)(!1),W=(0,c.A)(z,2),G=W[0],Y=W[1],X=(0,d.useState)(!1),Q=(0,c.A)(X,2),$=Q[0],ee=Q[1],te=(0,d.useState)(null),ae=(0,c.A)(te,2),oe=(ae[0],ae[1]),ue=(0,d.useState)(!1),de=(0,c.A)(ue,2),pe=de[0],ge=de[1],ye=(0,d.useState)({}),ve=(0,c.A)(ye,2),xe=ve[0],he=ve[1],Ee=(0,d.useState)("environment"),Ne=(0,c.A)(Ee,2),we=Ne[0],Ce=Ne[1],Se=(0,d.useState)(!1),ke=(0,c.A)(Se,2),Ae=ke[0],Ie=ke[1],Re=(0,d.useState)(!1),Fe=(0,c.A)(Re,2),je=(Fe[0],Fe[1],(0,d.useState)(!1)),qe=(0,c.A)(je,2),Le=qe[0],Ue=qe[1],Ve=(0,d.useState)(!1),Be=(0,c.A)(Ve,2),ze=Be[0],We=Be[1],He=(0,d.useState)(!1),Ge=(0,c.A)(He,2),Je=Ge[0],Ze=Ge[1],Ye=(0,d.useState)({dis
1playName:"",environmentType:J.OX.NonProduction}),Xe=(0,c.A)(Ye,2),Qe=Xe[0],$e=Xe[1],et=(0,d.useState)(!1),tt=(0,c.A)(et,2),nt=tt[0],at=tt[1],rt=(0,d.useRef)(null),st=(0,d.useState)("group_id"),ot=(0,c.A)(st,2),lt=ot[0],it=ot[1],ct=(0,d.useState)(!1),mt=(0,c.A)(ct,2),ut=mt[0],dt=mt[1],pt=(0,d.useState)([]),gt=(0,c.A)(pt,2),ft=gt[0],bt=gt[1],yt=(0,d.useState)(!1),vt=(0,c.A)(yt,2),xt=vt[0],ht=vt[1],Et=(0,d.useState)([{id:"connection",title:"Connection",loadingText:"Establishing Connection",successText:"Connected",errorText:"Connection Error",status:"pending"},{id:"data",title:"Data Retrieval",loadingText:"Retrieving Data Tables",successText:"Data Retrieved",errorText:"Unable to Retrieve Data",status:"pending"},{id:"schema",title:"Schema Verification",loadingText:"Verifying Schema",successText:"Schema Verified",errorText:"Schema Error Detected",status:"pending"}]),Nt=(0,c.A)(Et,2),wt=Nt[0],Ct=Nt[1],St=[{id:"create-source",title:"Creating Source",loadingText:"Creating Source...",successText:"Source Created",errorText:"Failed to Create Source",status:"pending"},{id:"make-connection",title:"Making Connection",loadingText:"Making Connection...",successText:"Connection Established",errorText:"Connection Error",status:"pending"},{id:"sync-data",title:"Syncing Data",loadingText:"Starting Data Sync...",successText:"Data Sync Started",errorText:"Sync Error",status:"pending"}],kt=(0,d.useState)(!1),At=(0,c.A)(kt,2),It=At[0],Tt=At[1],Dt=(0,d.useState)(1),Rt=(0,c.A)(Dt,2),_t=Rt[0],Pt=Rt[1],Ot=(0,d.useState)(!1),Mt=(0,c.A)(Ot,2),Ft=Mt[0],Kt=Mt[1],jt=(0,d.useState)(null),qt=(0,c.A)(jt,2),Lt=(qt[0],qt[1]),Ut=(0,d.useState)(null),Vt=(0,c.A)(Ut,2),Bt=Vt[0],zt=Vt[1],Wt=((0,p.Yx)(),(0,g.useLocation)(),(0,d.useState)()),Ht=(0,c.A)(Wt,2),Gt=Ht[0],Jt=Ht[1],Zt=(0,d.useState)(!1),Yt=(0,c.A)(Zt,2),Xt=Yt[0],Qt=Yt[1],$t=(0,d.useState)(!1),en=(0,c.A)($t,2),tn=en[0],nn=en[1],an=(0,d.useState)(!1),rn=(0,c.A)(an,2),sn=rn[0],on=rn[1],ln=(0,d.useState)(null),cn=(0,c.A)(ln,2),mn=cn[0],un=cn[1],dn=(0,d.useState)(null),pn=(0,c.A)(dn,2),gn=pn[0],fn=pn[1],bn=(0,d.useRef)(null),yn=(0,d.useRef)(null),vn=(0,d.useRef)(null),xn=(0,d.useRef)(null),hn=(0,d.useRef)(null),En=(0,d.useRef)(null),Nn=(0,d.useRef)(null),wn=(0,d.useRef)(null),Cn=(0,d.useRef)(null),Sn=(0,d.useRef)(null),kn=((0,d.useRef)(!1),(0,d.useRef)(!1)),An=(0,d.useState)(!(null===(t=x.chargebee)||void 0===t||!t.step3Completed)),In=(0,c.A)(An,2),Tn=In[0],Dn=In[1],Rn=(0,d.useState)(!(null===(n=x.chargebee)||void 0===n||!n.step4Completed)),_n=(0,c.A)(Rn,2),Pn=_n[0],On=_n[1],Mn=(0,d.useState)(!!(null!==(a=x.chargebee)&&void 0!==a&&a.step4WasEverCompleted||null!=E&&E.step4WasEverCompleted||null!==(r=x.chargebee)&&void 0!==r&&r.step4CompletedAt||null!=E&&E.step4CompletedAt)),Fn=(0,c.A)(Mn,2),Kn=Fn[0],jn=Fn[1],qn=(0,d.useState)(!1),Ln=(0,c.A)(qn,2),Un=Ln[0],Vn=Ln[1],Bn=(0,d.useState)(St),zn=(0,c.A)(Bn,2),Wn=zn[0],Hn=zn[1],Gn=(0,d.useState)(0),Jn=(0,c.A)(Gn,2),Zn=Jn[0],Yn=Jn[1],Xn=(0,d.useState)(!1),Qn=(0,c.A)(Xn,2),$n=Qn[0],ea=Qn[1],ta=(0,d.useState)("pending"),na=(0,c.A)(ta,2),aa=na[0],ra=na[1],sa=(0,d.useState)(!1),oa=(0,c.A)(sa,2),la=oa[0],ia=oa[1],ca=(0,d.useState)(!1),ma=(0,c.A)(ca,2),ua=(ma[0],ma[1]),da=(0,d.useState)(!1),pa=(0,c.A)(da,2),ga=pa[0],fa=pa[1],ba=(0,d.useState)(!1),ya=(0,c.A)(ba,2),va=ya[0],xa=ya[1],ha=(0,d.useState)(!1),Ea=(0,c.A)(ha,2),Na=Ea[0],wa=Ea[1],Ca=(0,d.useState)(!1),Sa=(0,c.A)(Ca,2),ka=Sa[0],Aa=Sa[1],Ia=(0,d.useState)(!1),Ta=(0,c.A)(Ia,2),Da=Ta[0],Ra=Ta[1],_a=(0,d.useState)(!1),Pa=(0,c.A)(_a,2),Oa=Pa[0],Ma=Pa[1],Fa=!(null===(o=x.chargebee)||void 0===o||!o.step2Completed)||Oa,Ka=(0,d.useState)(!1),ja=(0,c.A)(Ka,2),qa=ja[0],La=ja[1],Ua=(0,d.useState)(null),Va=(0,c.A)(Ua,2),Ba=Va[0],za=Va[1],Wa=(0,d.useState)(""),Ha=(0,c.A)(Wa,2),Ga=Ha[0],Ja=Ha[1],Za=(0,d.useState)(""),Ya=(0,c.A)(Za,2),Xa=Ya[0],Qa=Ya[1],$a=(0,d.useState)(""),er=(0,c.A)($a,2),tr=er[0],nr=er[1],ar=(0,d.useState)(""),rr=(0,c.A)(ar,2),sr=rr[0],or=rr[1],lr=(0,d.useState)(null),ir=(0,c.A)(lr,2),cr=ir[0],mr=ir[1],ur=(0,d.useState)(!1),dr=(0,
1c.A)(ur,2),pr=dr[0],gr=dr[1],fr=(0,d.useState)("none"),br=(0,c.A)(fr,2),yr=br[0],vr=br[1],xr=(0,d.useState)(!1),hr=(0,c.A)(xr,2),Er=hr[0],Nr=hr[1],wr=(0,d.useState)(!(null===(l=x.chargebee)||void 0===l||!l.pendingApiKeyChange)||!(null==E||!E.pendingApiKeyChange)),Cr=(0,c.A)(wr,2),Sr=Cr[0],kr=Cr[1],Ar=(0,d.useState)(!(null===(m=x.chargebee)||void 0===m||!m.pendingSyncDateChange)||!(null==E||!E.pendingSyncDateChange)),Ir=(0,c.A)(Ar,2),Tr=Ir[0],Dr=Ir[1],Rr=(0,d.useState)(!1),_r=(0,c.A)(Rr,2),Pr=_r[0],Or=_r[1],Mr=(0,d.useState)(!1),Fr=(0,c.A)(Mr,2),Kr=Fr[0],jr=Fr[1],qr=(0,d.useState)(null),Lr=(0,c.A)(qr,2),Ur=Lr[0],Vr=Lr[1],Br=(0,d.useState)(!1),zr=(0,c.A)(Br,2),Wr=zr[0],Hr=zr[1],Gr=(0,J.wi)({client:Z.RB,fetchPolicy:"no-cache"}),Jr=(0,c.A)(Gr,2),Zr=Jr[0],Yr=Jr[1],Xr=Yr.data,Qr=(Yr.loading,(0,J.WX)({client:Z.RB,fetchPolicy:"no-cache"})),$r=(0,c.A)(Qr,2),es=$r[0],ts=$r[1].loading,ns=(0,De.Uc)({client:Z.Ju,fetchPolicy:"no-cache"}),as=(0,c.A)(ns,1)[0],rs=(0,se.Ske)({client:Z.Ju,fetchPolicy:"no-cache"}),ss=(0,c.A)(rs,1)[0],os=(0,se.B3y)({client:Z.k3,fetchPolicy:"no-cache"}),ls=(0,c.A)(os,2),is=ls[0],cs=ls[1].loading,ms=(0,se.PMB)({client:Z.k3,fetchPolicy:"no-cache"}),us=(0,c.A)(ms,2),ds=us[0],ps=us[1].loading,gs=(0,se.Mpy)({client:Z.k3,fetchPolicy:"no-cache"}),fs=(0,c.A)(gs,2),bs=fs[0],ys=fs[1].loading,vs=(0,se.F3z)({client:Z.k3,fetchPolicy:"no-cache"}),xs=(0,c.A)(vs,2),hs=xs[0],Es=xs[1].loading,Ns=(0,se.JET)({client:Z.k3,fetchPolicy:"no-cache"}),ws=(0,c.A)(Ns,1)[0];(0,d.useEffect)(function(){var e,t,n=null==x?void 0:x.chargebee;if(n&&0!==Object.keys(n).length){var a=JSON.stringify({subdomain:n.subdomain,apiKey:null===(e=n.apiKey)||void 0===e?void 0:e.substring(0,10),syncStartDate:n.syncStartDate,step2Completed:n.step2Completed,step3Completed:n.step3Completed,step4Completed:n.step4Completed,ingestionResult:null===(t=n.ingestionResult)||void 0===t?void 0:t.sourceId});if(kn.current!==a){if(kn.current=a,K(function(e){var t,a,r,s,o,l,i,c,m,u,d,p,g;return _e(_e({},e),{},{sourceName:null!==(t=n.sourceName)&&void 0!==t?t:e.sourceName,subdomain:null!==(a=n.subdomain)&&void 0!==a?a:e.subdomain,apiKey:null!==(r=n.apiKey)&&void 0!==r?r:e.apiKey,secretKey:null!==(s=n.secretKey)&&void 0!==s?s:e.secretKey,productCatalog:null!==(o=n.productCatalog)&&void 0!==o?o:e.productCatalog,dataRetentionLocation:null!==(l=n.dataRetentionLocation)&&void 0!==l?l:e.dataRetentionLocation,syncStartDate:n.syncStartDate?new Date(n.syncStartDate):e.syncStartDate,groupIdMapping:null!==(i=n.groupIdMapping)&&void 0!==i?i:e.groupIdMapping,environmentId:null!==(c=n.environmentId)&&void 0!==c?c:e.environmentId,environmentName:null!==(m=n.environmentName)&&void 0!==m?m:e.environmentName,chargebeeEnvironment:null!==(u=n.chargebeeEnvironment)&&void 0!==u?u:e.chargebeeEnvironment,chargebeeFeePerTransaction:null!==(d=n.chargebeeFeePerTransaction)&&void 0!==d?d:e.chargebeeFeePerTransaction,paymentGatewayFees:null!==(p=n.paymentGatewayFees)&&void 0!==p?p:e.paymentGatewayFees,accountId:null!==(g=n.accountId)&&void 0!==g?g:e.accountId})}),fa(!1),xa(!1),wa(!1),Aa(!1),Ra(!1),Ja(""),Qa(""),nr(""),or(""),mr(null),Array.isArray(n.testingSteps)&&Ct(n.testingSteps),Array.isArray(n.customerMetaDataKeys)&&bt(n.customerMetaDataKeys),"boolean"==typeof n.groupIdFound&&ht(n.groupIdFound),"boolean"==typeof n.testCompleted&&Tt(n.testCompleted),"boolean"==typeof n.isStep3Incomplete&&nn(n.isStep3Incomplete),"boolean"==typeof n.step3Completed&&Dn(n.step3Completed),"boolean"==typeof n.step4Completed&&On(function(e){return!0===n.step4Completed||(!(!1!==n.step4Completed||"apiKeyOnly"!==yr||!Pr||!e)||n.step4Completed)}),"boolean"==typeof n.step4WasEverCompleted&&jn(n.step4WasEverCompleted),n.ingestionResult){un(n.ingestionResult),n.ingestionResult.syncStartedAt&&Vr(n.ingestionResult.syncStartedAt);var r=n.ingestionResult.syncStatus||n.syncStatus;r&&(ra(r),"running"!==r&&"pending"!==r||ia(!0))}else n.syncStatus&&(ra(n.syncStatus),"running"!==n.syncStatus&&"pending"!==n.syncStatus||ia(!0));if("boolean"==typeof n.isSetupIncomplete&&gr(n.isSetupIncomplete),!0===n.pendingApiKeyChange&&kr(!0),!0===n.pendingSyncDateChange&&Dr(!0),n.pendingApiKeyChange||n.pe
1ndingSyncDateChange){var s=n.pendingApiKeyChange&&n.pendingSyncDateChange?"both":n.pendingSyncDateChange?"syncDateOnly":n.pendingApiKeyChange?"apiKeyOnly":"none";vr(s)}"string"==typeof n.selectedIdentifierKey&&n.selectedIdentifierKey?it(n.selectedIdentifierKey):Array.isArray(n.customerMetaDataKeys)&&n.customerMetaDataKeys.length>0&&it(n.customerMetaDataKeys[0]),Ae||(n.isStep3Incomplete?Ce("revenue-correlation"):n.step4Completed?Ce("pause-fix"):n.step3Completed?Ce("revenue-correlation"):n.isSetupIncomplete?Ce("basic-config"):n.step2Completed?Ce("revenue-correlation"):n.step1Completed&&Ce("basic-config"))}}},[x,Ae,yr,Pr]),(0,d.useEffect)(function(){Pn&&!Kn&&jn(!0)},[Pn,Kn]),(0,d.useEffect)(function(){var e,t;((null===(e=x.chargebee)||void 0===e?void 0:e.step4WasEverCompleted)||(null==E?void 0:E.step4WasEverCompleted)||(null===(t=x.chargebee)||void 0===t?void 0:t.step4CompletedAt)||(null==E?void 0:E.step4CompletedAt))&&!Kn&&jn(!0)},[null===(f=x.chargebee)||void 0===f?void 0:f.step4WasEverCompleted,null==E?void 0:E.step4WasEverCompleted,null===(b=x.chargebee)||void 0===b?void 0:b.step4CompletedAt,null==E?void 0:E.step4CompletedAt,Kn]);var Cs=function(){var e=(0,s.A)(u().mark(function e(){var t;return u().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=1,Zr({variables:{input:{productId:(0,H.J1)()}}});case 1:e.next=3;break;case 2:e.prev=2,t=e.catch(0),console.error("Failed to fetch environments:",t);case 3:case"end":return e.stop()}},e,null,[[0,2]])}));return function(){return e.apply(this,arguments)}}(),Ss=function(){var e="acct_demo_".concat(Math.random().toString(36).substring(2,15));K(function(t){return _e(_e({},t),{},{accountId:e})}),Hr(!1)},ks=function(){return wt.every(function(e){return"success"===e.status})},As=function(){var e=(0,s.A)(u().mark(function e(){var t;return u().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!(Er||Sr||Tr)){e.next=5;break}return La(!0),za(null),e.prev=1,e.next=2,ds({variables:{input:{environmentId:M.environmentId,sourceType:se.pqc.Chargebee,startDate:M.syncStartDate instanceof Date?M.syncStartDate.toISOString().split(".")[0]+"Z":(new Date).toISOString().split(".")[0]+"Z",apiKey:M.apiKey,shouldReset:!1}}});case 2:Nr(!1),e.next=4;break;case 3:return e.prev=3,t=e.catch(1),console.error("Failed to update Chargebee source:",t),za("Something went wrong, try again"),La(!1),e.abrupt("return");case 4:La(!1);case 5:Dn(!0),nn(!1),Ma(!0),Sn.current="pause-fix",Ce("pause-fix"),Fs(!1),I(),setTimeout(function(){var e;null===(e=xn.current)||void 0===e||e.scrollIntoView({behavior:"smooth",block:"center"})},100);case 6:case"end":return e.stop()}},e,null,[[1,3]])}));return function(){return e.apply(this,arguments)}}(),Is=function(){var e=(0,s.A)(u().mark(function e(){var t;return u().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!(Er||Sr||Tr)){e.next=5;break}return La(!0),za(null),e.prev=1,e.next=2,ds({variables:{input:{environmentId:M.environmentId,sourceType:se.pqc.Chargebee,startDate:M.syncStartDate instanceof Date?M.syncStartDate.toISOString().split(".")[0]+"Z":(new Date).toISOString().split(".")[0]+"Z",apiKey:M.apiKey,shouldReset:!1}}});case 2:Nr(!1),e.next=4;break;case 3:return e.prev=3,t=e.catch(1),console.error("Failed to update Chargebee source:",t),za("Something went wrong, try again"),La(!1),e.abrupt("return");case 4:La(!1);case 5:nn(!0),Dn(!0),Ma(!0),Sn.current="pause-fix",Ce("pause-fix"),Fs(!0),Jt(k.V.REVOPS_TEAMS),Qt(!0),I(),setTimeout(function(){var e;null===(e=xn.current)||void 0===e||e.scrollIntoView({behavior:"smooth",block:"center"})},100);case 6:case"end":return e.stop()}},e,null,[[1,3]])}));return function(){return e.apply(this,arguments)}}(),Ts=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:2e3,t=(0,d.useState)({}),n=(0,c.A)(t,2),a=n[0],r=n[1],o=function(){var t=(0,s.A)(u().mark(function t(n,a){return u().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=1,navigator.clipboard.writeText(n);case 1:r(function(e){return _e(_e({},e),{},(0,i.A)({},a,!0))}),setTimeout(function(){r(function(e){return _e(_e({},e),{},(0,i.A)({},a,!1))})},e);case 2:case"end":return t.stop()}},t)}));return function(e,n){return t.apply(this,arguments)}}();return{copiedStates:a,copy:o}}(),Ds=(Ts.copiedStates,Ts.copy,function(){var e=(0,s.A)(u().mark(function e(){var t,n,a,r,s,o,l,i,c=arguments;return u().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(t=c.length>0&&void 0!==c[0]?c[0]:"SUCCESS",!q){e.next=2;break}return e.next=1,le(t);case 1:return(n=e.sent).customerMetaDataKeys?bt(n.customerMetaDataKeys):bt([]),ht(n.groupIdFound),n.customerMetaDataKeys&&n.customerMetaDataKeys.includes("group_id")?it("group_id"):n.customerMetaDataKeys&&n.customerMetaDataKeys.length>0&&it(n.customerMetaDataKeys[0]),e.abrupt("return",n);case 2:return e.prev=2,e.next=3,as({variables:{input:{siteType:M.chargebeeEnvironment||"test",siteName:M.subdomain||"",apiKey:M.apiKey||"",productCatalogVersion:M.productCatalog||"2.0"}}});case 3:if(r=e.sent,s=null===(a=r.data)||void 0===a?void 0:a.testChargebeeConnection){e.next=4;break}throw new Error("CHARGEBEE_TEST_CONNECTION_NO_RESPONSE");case 4:return o={},null!=s&&s.validSiteTypeMessage&&(o.siteType=s.validSiteTypeMessage),null!=s&&s.validSiteNameMessage&&(o.siteName=s.validSiteNameMessage),null!=s&&s.validProductCatalogMessage&&(o.productCatalog=s.validProductCatalogMessage),null!=s&&s.credentialsMessage&&(o.credentials=s.credentialsMessage),Object.keys(o).length>0?Lt(o):Lt(null),null!=s&&s.credentialsValid&&null!=s&&s.validSiteType&&null!=s&&s.validSiteNameMatchesType&&null!=s&&s.validProductCatalogVersion?(null!=s&&s.customerMetaDataKeys?bt(s.customerMetaDataKeys):bt([]),null!=s&&s.customerMetaDataKeys&&s.customerMetaDataKeys.length>0?(l=Ke(s.customerMetaDataKeys))?(it(l),ht(!0)):(it(s.customerMetaDataKeys[0]),ht(!1)):ht(!1)):(bt([]),ht(!1)),e.abrupt("return",s);case 5:throw e.prev=5,i=e.catch(2),console.error("Test connection error:",i),i;case 6:case"end":return e.stop()}},e,null,[[2,5]])}));return function(){return e.apply(this,arguments)}}()),Rs=[{id:"environment",number:1,title:"Map Environments",description:"Select the Chargebee site that will map with current App environment and will be used when establishing an connection.",subtitle:"Select the Chargebee site to connect with Current App environment",isCompleted:!(!M.environmentId||!M.chargebeeEnvironment),isActive:"environment"===we,required:!0},{id:"basic-config",number:2,title:"Basic Configuration",description:"Configure your Chargebee connection details",isCompleted:!!(M.sourceName&&M.subdomain&&M.apiKey&&M.syncStartDate),isActive:"basic-config"===we,required:!0},{id:"revenue-correlation",number:3,title:"Test Your Chargebee Connection",description:"Test your Chargebee credentials before starting Data Ingestion",isCompleted:Tn||ks(),isActive:"revenue-correlation"===we,required:!0},{id:"pause-fix",number:4,title:"apiKeyOnly"!==yr&&"both"!==yr&&"syncDateOnly"!==yr||!Kn?"Start Ingestion":"Resync Chargebee data",description:"apiKeyOnly"!==yr&&"both"!==yr&&"syncDateOnly"!==yr||!Kn?"Finalize your Chargebee integration":"Start a new sync with modified configurations",isCompleted:Pn||!1,isActive:"pause-fix"===we,required:!0}],_s=function(){var e,t={notificationEmails:{userEmail:null===(e=(0,H.wz)())||void 0===e?void 0:e.email,additionalEmails:A.state.emails}};h("chargebee",t),S(function(e){return _e(_e({},e),t)}),A.resetUpdateButton()};(0,d.useEffect)(function(){return D&&(D.current=function(){return Y(!0)}),function(){D&&(D.current=null)}},[D]),(0,d.useEffect)(function(){var e,t=("apiKeyOnly"===yr||"both"===yr||"syncDateOnly"===yr)&&(null===(e=x.chargebee)||void 0===e?void 0:e.step4Completed);
1if("pause-fix"===we&&!!M.environmentId&&!!mn&&(!t||Pr)){var n=setTimeout(function(){var e=function(){var e=(0,s.A)(u().mark(function e(){var t,n,a,r,s;return u().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=1,ws({variables:{input:{environmentId:M.environmentId,dataSource:[se.qSh.Chargebee]}}});case 1:n=e.sent,(a=Pe(null===(t=n.data)||void 0===t||null===(t=t.getSyncStatus)||void 0===t?void 0:t.syncStatus))&&(r=a.status,ra(r),a.lastUpdatedAt?Vr(a.lastUpdatedAt):mn.syncStartedAt&&!Ur&&Vr(mn.syncStartedAt),"running"!==r&&"pending"!==r||ia(!0)),e.next=3;break;case 2:e.prev=2,s=e.catch(0),console.error("Error loading sync status:",s);case 3:case"end":return e.stop()}},e,null,[[0,2]])}));return function(){return e.apply(this,arguments)}}();e()},100);return function(){return clearTimeout(n)}}},[we,mn,M.environmentId,ws,yr,Pr]),(0,d.useEffect)(function(){var e;!(("apiKeyOnly"===yr||"both"===yr||"syncDateOnly"===yr)&&(null===(e=x.chargebee)||void 0===e?void 0:e.step4Completed))||Pr||ys||Es||(Or(!1),ia(!1),ra("pending"),Vr(null))},[yr,null===(v=x.chargebee)||void 0===v?void 0:v.step4Completed,Pr,ys,Es]),(0,d.useEffect)(function(){jr("apiKeyOnly"===yr||"both"===yr||"syncDateOnly"===yr)},[yr]),(0,d.useEffect)(function(){var e;if(la&&M.environmentId&&(!(("apiKeyOnly"===yr||"both"===yr||"syncDateOnly"===yr)&&(null===(e=x.chargebee)||void 0===e?void 0:e.step4Completed))||Pr)){var t,n=0,a=function(){var e=(0,s.A)(u().mark(function e(){var a,r,s,o,l;return u().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,!(++n>40)){e.next=1;break}return ra("failed"),ia(!1),clearInterval(t),e.abrupt("return");case 1:return e.next=2,ws({variables:{input:{environmentId:M.environmentId,dataSource:[se.qSh.Chargebee]}}});case 2:r=e.sent,(s=Pe(null===(a=r.data)||void 0===a||null===(a=a.getSyncStatus)||void 0===a?void 0:a.syncStatus))&&(o=s.status,ra(o),s.lastUpdatedAt&&Vr(s.lastUpdatedAt),"succeeded"!==o&&"failed"!==o||(ia(!1),clearInterval(t))),e.next=4;break;case 3:e.prev=3,l=e.catch(0),console.error("Error polling sync status:",l),ra("failed"),ia(!1),clearInterval(t);case 4:case"end":return e.stop()}},e,null,[[0,3]])}));return function(){return e.apply(this,arguments)}}();return a(),t=setInterval(a,3e4),function(){clearInterval(t)}}},[la,M.environmentId,ws,yr,Pr]),(0,d.useEffect)(function(){if(Un)if(gn)Hn(function(e){return e.map(function(e){return _e(_e({},e),{},{status:"error"})})});else{if(Zn<Wn.length-1){Hn(function(e){return e.map(function(e,t){return t===Zn?_e(_e({},e),{},{status:"loading"}):e})});var e=setTimeout(function(){Hn(function(e){return e.map(function(e,t){return t===Zn?_e(_e({},e),{},{status:"success"}):e})}),Yn(function(e){return e+1})},3e3);return function(){return clearTimeout(e)}}Zn===Wn.length-1&&Hn(function(e){return e.map(function(e,t){return t===Zn?_e(_e({},e),{},{status:cs?"loading":"success"}):e})})}},[Un,Zn,cs,Wn.length,gn]),(0,d.useEffect)(function(){var e,t,n=new URLSearchParams(window.location.search),a=n.get("code"),r=n.get("state");if(!(""!==M.accountId||(null==E||null===(e=E.formData)||void 0===e?void 0:e.accountId)||(null==C?void 0:C.accountId)||(null===(t=x.chargebee)||void 0===t?void 0:t.accountId))){var o,l;if(r)try{var i=JSON.parse(decodeURIComponent(r));o=i.step,l=i.substep}catch(e){console.error("Invalid state param:",e)}if(2===o&&a){var c=function(){var e=(0,s.A)(u().mark(function e(){var t,n,r,s,o,i;return u().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(l&&(Cn.current=l),2===l&&(Ce("basic-config"),setTimeout(function(){var e;null===(e=wn.current)||void 0===e||e.scrollIntoView({behavior:"smooth",block:"start"})},300)),t=(0,H.f2)())try{n=JSON.parse(t),K(function(e){return _e(_e({},e),{},{sourceName:n.sourceName||e.sourceName,secretKey:n.secretKey||e.secretKey,dataRetentionLocation:n.dataRetentionLocation||e.dataRetentionLocation,groupIdMapping:n.groupIdMapping||e.groupIdMapping,environmentId:n.environmentId||e.environmentId,environmentName:n.environmentName||e.environmentName,chargebeeEnvironment:n.chargebeeEnvironment||e.chargebeeEnvironment,syncStartDate:n.syncStartDate?new Date(n.syncStartDate):e.syncStartDate,accountId:""})})}catch(e){console.error("Error parsing saved form data:",e)}return e.prev=1,console.log("OAuth code received:",a),ua(!0),e.next=2,ss({variables:{input:{accessCode:a}}});case 2:s=e.sent,o=null===(r=s.data)||void 0===r||null===(r=r.getChargebeeAccountDetails)||void 0===r?void 0:r.accountId,K(function(e){return _e(_e({},e),{},{accountId:o})}),ua(!1),T(),e.next=4;break;case 3:e.prev=3,i=e.catch(1),ua(!1),console.error("Error processing OAuth code:",i),T(),alert("Failed to connect Chargebee account. Please try again.");case 4:case"end":return e.stop()}},e,null,[[1,3]])}
1));return function(){return e.apply(this,arguments)}}();c()}return function(){if(window.location.search.includes("code=")){var e="".concat(window.location.pathname,"?step=2");window.history.replaceState(null,"",e)}}}a&&T()},[E,C]),(0,d.useEffect)(function(){var e=(null==x?void 0:x.chargebee)&&Object.keys(x.chargebee).length>0;if(!kn.current||!e||Sn.current)if(E){var t,n,a,r=new URLSearchParams(window.location.search).get("code"),s=(0,H.f2)(),o=null===(t=E.formData)||void 0===t?void 0:t.accountId,l=e?x.chargebee:E.formData;if(s&&r&&!o)try{var i=JSON.parse(s);K(function(e){return _e(_e({},e),{},{sourceName:i.sourceName||(null==l?void 0:l.sourceName)||"Chargebee",accountId:i.accountId||(null==l?void 0:l.accountId)||"",secretKey:i.secretKey||(null==l?void 0:l.secretKey)||"",syncStartDate:i.syncStartDate?new Date(i.syncStartDate):null!=l&&l.syncStartDate?new Date(l.syncStartDate):Oe(),groupIdMapping:(null==l?void 0:l.groupIdMapping)||!1,environmentId:(null==l?void 0:l.environmentId)||"",environmentName:(null==l?void 0:l.environmentName)||"",chargebeeEnvironment:(null==l?void 0:l.chargebeeEnvironment)||""})})}catch(e){console.error("Error parsing localStorage:",e)}else l&&(K(function(e){return _e(_e({},e),{},{sourceName:l.sourceName||"Chargebee",subdomain:l.subdomain||e.subdomain,apiKey:l.apiKey||e.apiKey,accountId:l.accountId||"",secretKey:l.secretKey||"",productCatalog:l.productCatalog||e.productCatalog,dataRetentionLocation:l.dataRetentionLocation||"",syncStartDate:l.syncStartDate?new Date(l.syncStartDate):Oe(),groupIdMapping:l.groupIdMapping||!1,environmentId:l.environmentId||"",environmentName:l.environmentName||"",chargebeeEnvironment:l.chargebeeEnvironment||""})}),r&&T());var m=e&&x.chargebee.testingSteps?x.chargebee.testingSteps:E.testingSteps,u=e&&x.chargebee.customerMetaDataKeys?x.chargebee.customerMetaDataKeys:null===(n=E.testingSteps)||void 0===n||null===(n=n.find(function(e){return"schema"===e.id}))||void 0===n?void 0:n.customerMetaDataKeys,d=e&&x.chargebee.selectedIdentifierKey?x.chargebee.selectedIdentifierKey:null===(a=E.testingSteps)||void 0===a||null===(a=a.find(function(e){return"schema"===e.id}))||void 0===a?void 0:a.selectedIdentifierKey,p=e&&"boolean"==typeof x.chargebee.groupIdFound?x.chargebee.groupIdFound:E.groupIdFound,g=e&&x.chargebee.ingestionResult?x.chargebee.ingestionResult:E.ingestionResult;if(m&&m.length>0)Ct(m),m.find(function(e){return"schema"===e.id})&&(d&&it(d),u&&u.length>0&&bt(u));if(m){var f=m.find(function(e){return"schema"===e.id});if(null!=f&&f.customerMetaDataKeys&&f.customerMetaDataKeys.length>0){var b=Ke(f.customerMetaDataKeys);b&&!d&&it(b)}}"boolean"==typeof p&&ht(p),g&&(un(g),g.syncStartedAt&&Vr(g.syncStartedAt),g.syncStatus&&(ra(g.syncStatus),"running"!==g.syncStatus&&"pending"!==g.syncStatus||ia(!0)));var y=e&&"boolean"==typeof x.chargebee.testCompleted?x.chargebee.testCompleted:E.testCompleted;"boolean"==typeof y&&Tt(y);var v=e&&"boolean"==typeof x.chargebee.isSetupIncomplete?x.chargebee.isSetupIncomplete:E.isSetupIncomplete;"boolean"==typeof v&&gr(v);var h=e&&"boolean"==typeof x.chargebee.isStep3Incomplete?x.chargebee.isStep3Incomplete:E.isStep3Incomplete;
1"boolean"==typeof h&&nn(h);var N=e&&"boolean"==typeof x.chargebee.step3Completed?x.chargebee.step3Completed:E.step3Completed;"boolean"==typeof N&&Dn(N);var w=e&&"boolean"==typeof x.chargebee.step4Completed?x.chargebee.step4Completed:E.step4Completed;"boolean"==typeof w&&On(function(e){return!0===w||(!(!1!==w||"apiKeyOnly"!==yr||!Pr||!e)||w)});var S=e&&"boolean"==typeof x.chargebee.step4WasEverCompleted?x.chargebee.step4WasEverCompleted:E.step4WasEverCompleted;if("boolean"==typeof S&&jn(S),!Cn.current)if(Sn.current)Ce(Sn.current),Sn.current=null;else{var k=e?x.chargebee:E;k.isStep3Incomplete?Ce("revenue-correlation"):k.step4Completed?Ce("pause-fix"):k.step3Completed?Ce("revenue-correlation"):k.isSetupIncomplete?Ce("basic-config"):k.step2Completed?Ce("revenue-correlation"):k.step1Completed&&Ce("basic-config")}var I=e&&x.chargebee.notificationEmails?x.chargebee.notificationEmails:E.notificationEmails;if(I){var D=Object.entries(I).filter(function(e){return"userEmail"!==(0,c.A)(e,1)[0]}).map(function(e){var t=(0,c.A)(e,2);t[0];return t[1]});A.setEmails(D)}}else if(C){if(K(function(e){return _e(_e({},e),{},{sourceName:C.sourceName||"Chargebee",accountId:C.accountId||"",secretKey:C.secretKey||"",dataRetentionLocation:C.dataRetentionLocation||"",syncStartDate:C.syncStartDate?new Date(C.syncStartDate):Oe(),groupIdMapping:C.groupIdMapping||!1,environmentId:C.environmentId||"",environmentName:C.environmentName||"",chargebeeEnvironment:C.chargebeeEnvironment||""})}),null!=C&&C.testingSteps&&C.testingSteps.length>0&&Ct(C.testingSteps),C.ingestionResult&&un(C.ingestionResult),C.testCompleted&&Tt(C.testCompleted),"boolean"==typeof C.isSetupIncomplete&&gr(C.isSetupIncomplete),C.isStep3Incomplete&&nn(C.isStep3Incomplete),C.step3Completed&&Dn(C.step3Completed),C.step4Completed&&On(C.step4Completed),"boolean"==typeof C.step4WasEverCompleted&&jn(C.step4WasEverCompleted),Cn.current||(Sn.current?(Ce(Sn.current),Sn.current=null):C.isStep3Incomplete?Ce("revenue-correlation"):C.step4Completed?Ce("pause-fix"):C.step3Completed?Ce("revenue-correlation"):C.isSetupIncomplete?Ce("basic-config"):C.step2Completed?Ce("revenue-correlation"):C.step1Completed&&Ce("basic-config")),C.notificationEmails){var R=Object.entries(C.notificationEmails).filter(function(e){return"userEmail"!==(0,c.A)(e,1)[0]}).map(function(e){var t=(0,c.A)(e,2);t[0];return t[1]});A.setEmails(R)}Cn.current=null}},[E,x,yr,Pr]),(0,d.useEffect)(function(){if(A.state.emails.length>0&&(E||C)){var e,t={userEmail:null===(e=(0,H.wz)())||void 0===e?void 0:e.email,additionalEmails:A.state.emails};h("chargebee",{notificationEmails:t}),S(function(e){return _e(_e({},e),{},{notificationEmails:t})})}},[A.state.emails]),(0,d.useEffect)(function(){if(nt){var e=setInterval(function(){Pt(function(e){return e>=3?1:e+1})},500);return function(){return clearInterval(e)}}},[nt]),(0,d.useEffect)(function(){Cs()},[]),(0,d.useEffect)(function(){if(q)K(function(e){return _e(_e({},e),{},{environmentId:ce,environmentName:me,chargebeeEnvironment:e.chargebeeEnvironment||"test"})});else{var e=null==Xr?void 0:Xr.getEnvironmentsForProduct.environments.find(function(e){return(null==e?void 0:e.displayName)===(0,H.bb)()}),t="";(null==e?void 0:e.environmentType)===J.OX.Production?t="live":(null==e?void 0:e.environmentType)===J.OX.NonProduction&&(t="test"),K(function(n){return _e(_e({},n),{},{environmentId:"".concat((null==e?void 0:e.id)||""),environmentName:"".concat((null==e?void 0:e.displayName)||""),chargebeeEnvironment:n.chargebeeEnvironment||t})})}},[Xr,q]);var Ps=function(e,t){K(function(n){return _e(_e({},n),{},(0,i.A)({},e,t))}),xe[e]&&he(function(t){return _e(_e({},t),{},(0,i.A)({},e,void 0))})},Os=function(){var e=(0,s.A)(u().mark(function e(){var t,n,a;return u().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(Qe.displayName){e.next=1;break}return e.abrupt("return");case 1:return e.prev=1,e.next=2,es({variables:{input:{name:Qe.displayName.toLowerCase().replace(/\s+/g,"-"),displayName:Qe.displayName,environmentType:Qe.environmentType}}});case 2:if(n=e.sent,null===(t=n.data)||void 0===t||null===(t=t.createEnvironmentCA)||void 0===t||!t.isSuccess){e.next=4;break}return $e({displayName:"",environmentType:J.OX.NonProduction}),Ze(!1),e.next=3,Cs();case 3:e.next=5;break;case 4:console.error("Failed to create environment");case 5:e.next=7;break;case 6:e.prev=6,a=e.catch(1),console.error("Error creating environment:",a);case 7:case"end":return e.stop()}},e,null,[[1,6]])}));return function(){return e.apply(this,arguments)}}(),Ms=function(){Ze(!1),$e({displayName:"",environmentType:J.OX.NonProduction})},Fs=function(e){var t,n=!0===(null!==(t=null==x?void 0:x.chargebee)&&void 0!==t?t:{}).step2Completed||!!(M.sourceName&&M.subdomain&&M.apiKey&&M.syncStartDate),a=_e(_e({},M),{},{step1Completed:!(!M.environmentId||!M.chargebeeEnvironment),step2Completed:n,step3Completed:!0,step3CompletedAt:(new Date).toISOString(),isStep3Incomplete:e,testingSteps:wt.map(function(e){return _e(_e({},e),"schema"===e.id?{selectedIdentifierKey:lt,customerMetaDataKeys:ft}:{})}),testCompleted:It,schemaVerified:!0,selectedIdentifierKey:lt,customerMetaDataKeys:ft,groupIdFound:xt,isSetupIncomplete:!1});h("chargebee",a),S(a)},Ks=function(e){var t=!(null==e||!e.keepIngestionResult);Dn(!1),On(!1),Tt(!1),Ct([{id:"connection",title:"Connection",loadingText:"Establishing Connection",successText:"Connected",errorText:"Connection
1Error",status:"pending"},{id:"data",title:"Data Retrieval",loadingText:"Retrieving Data Tables",successText:"Data Retrieved",errorText:"Unable to Retrieve Data",status:"pending"},{id:"schema",title:"Schema Verification",loadingText:"Verifying Schema",successText:"Schema Verified",errorText:"Schema Error Detected",status:"pending"}]),bt([]),it("group_id"),ht(!1),t||un(null),fn(null),Vn(!1),ra("pending"),ia(!1),Vr(null),gr(!0)},js=function(){Ps("subdomain",Xa),xa(!1),Qa("")},qs=function(){var e,t,n;zt(null);var a=!1;M.subdomain!==Xa&&(Ks(),a=!0),xa(!1),Qa("");var r=_e(_e({},M),{},{step1Completed:!(!M.environmentId||!M.chargebeeEnvironment),step2Completed:!!(M.sourceName&&M.subdomain&&M.apiKey&&M.syncStartDate),step3Completed:!a&&Tn,step4Completed:!a&&Pn,step4WasEverCompleted:Kn,isStep3Incomplete:!a&&tn,testingSteps:a?[{id:"connection",title:"Connection",loadingText:"Establishing Connection",successText:"Connected",errorText:"Connection Error",status:"pending"},{id:"data",title:"Data Retrieval",loadingText:"Retrieving Data Tables",successText:"Data Retrieved",errorText:"Unable to Retrieve Data",status:"pending"},{id:"schema",title:"Schema Verification",loadingText:"Verifying Schema",successText:"Schema Verified",errorText:"Schema Error Detected",status:"pending"}]:wt,testCompleted:!a&&It,schemaVerified:(null===(e=x.chargebee)||void 0===e?void 0:e.schemaVerified)||!1,status:(null===(t=x.chargebee)||void 0===t?void 0:t.status)||"pending",completed:!(!M.environmentId||!M.chargebeeEnvironment)&&!!(M.sourceName&&M.subdomain&&M.apiKey&&M.syncStartDate)&&!a&&Tn&&!a&&Pn,isSetupIncomplete:a,ingestionResult:a?null:(null===(n=x.chargebee)||void 0===n?void 0:n.ingestionResult)||null});h("chargebee",r),S(r),I()},Ls=function(){nr(M.apiKey),wa(!0)},Us=function(){Ps("apiKey",tr),wa(!1),nr(""),kr(!1)},Vs=function(){Ja(M.sourceName),fa(!0)},Bs=function(){Ps("sourceName",Ga),fa(!1),Ja("")},zs=function(){fa(!1),Ja("");var e=_e(_e({},M),{},{step1Completed:!(!M.environmentId||!M.chargebeeEnvironment),step2Completed:!!(M.sourceName&&M.subdomain&&M.apiKey&&M.syncStartDate)});h("chargebee",e),S(e),I()},Ws=function(){Ps("productCatalog",sr),Aa(!1),or(""),We(!1)},Hs=function(){Aa(!1),or(""),We(!1);var e=_e(_e({},M),{},{step1Completed:!(!M.environmentId||!M.chargebeeEnvironment),step2Completed:!!(M.sourceName&&M.subdomain&&M.apiKey&&M.syncStartDate)});h("chargebee",e),S(e),I()},Gs=function(){mr(M.syncStartDate instanceof Date?new Date(M.syncStartDate):null),Ra(!0)},Js=function(){cr&&Ps("syncStartDate",cr),Ra(!1),mr(null),ee(!1),Dr(!1)},Zs=function(){var e=(0,s.A)(u().mark(function e(){var t,n,a,r,s,o,l;return u().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:zt(null),r=!1,cr&&M.syncStartDate instanceof Date&&(r=M.syncStartDate.toISOString()!==cr.toISOString()),(s=!(!r||!Fa))&&(Ks({keepIngestionResult:!0}),Nr(!0),Dr(!0)),Ra(!1),mr(null),ee(!1),o=(null===(t=x.chargebee)||void 0===t?void 0:t.ingestionResult)||mn||null,l=_e(_e({},M),{},{step1Completed:!(!M.environmentId||!M.chargebeeEnvironment),step2Completed:!!(M.sourceName&&M.subdomain&&M.apiKey&&M.syncStartDate),step3Completed:!s&&Tn,step4Completed:!s&&Pn,step4WasEverCompleted:Kn,isStep3Incomplete:!s&&tn,testingSteps:s?[{id:"connection",title:"Connection",loadingText:"Establishing Connection",successText:"Connected",errorText:"Connection Error",status:"pending"},{id:"data",title:"Data Retrieval",loadingText:"Retrieving Data Tables",successText:"Data Retrieved",errorText:"Unable to Retrieve Data",status:"pending"},{id:"schema",title:"Schema Verification",loadingText:"Verifying Schema",successText:"Schema Verified",errorText:"Schema Error Detected",status:"pending"}]:wt,testCompleted:!s&&It,schemaVerified:(null===(n=x.chargebee)||void 0===n?void 0:n.schemaVerified)||!1,status:(null===(a=x.chargebee)||void 0===a?void 0:a.status)||"pending",completed:!(!M.environmentId||!M.chargebeeEnvironment)&&!!(M.sourceName&&M.subdomain&&M.apiKey&&M.syncStartDate)&&!s&&Tn&&!s&&Pn,isSetupIncomplete:s,ingestionResult:o}),h("chargebee",l),S(l),I();case 1:case"end":return e.stop()}},e)}));return function(){return e.apply(this,arguments)}}(),Ys=function(){var e=(0,s.A)(u().mark(function e(){var t,n,a,r,s,o;return u().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:zt(null),r=!1,M.apiKey!==tr&&(Ks({keepIngestionResult:!0}),r=!0),wa(!1),nr(""),r&&Fa&&(Nr(!0),kr(!0)),s=(null===(t=x.chargebee)||void 0===t?void 0:t.ingestionResult)||mn||null,o=_e(_e({},M),{},{step1Completed:!(!M.environmentId||!M.chargebeeEnvironment),step2Completed:!!(M.sourceName&&M.subdomain&&M.apiKey&&M.syncStartDate),step3Completed:!r&&Tn,step4Completed:!r&&Pn,step4WasEverCompleted:Kn,isStep3Incomplete:!r&&tn,testingSteps:r?[{id:"connection",title:"Connection",loadingText:"Establishing Connection",successText:"Connected",errorText:"Connection
1Error",status:"pending"},{id:"data",title:"Data Retrieval",loadingText:"Retrieving Data Tables",successText:"Data Retrieved",errorText:"Unable to Retrieve Data",status:"pending"},{id:"schema",title:"Schema Verification",loadingText:"Verifying Schema",successText:"Schema Verified",errorText:"Schema Error Detected",status:"pending"}]:wt,testCompleted:!r&&It,schemaVerified:(null===(n=x.chargebee)||void 0===n?void 0:n.schemaVerified)||!1,status:(null===(a=x.chargebee)||void 0===a?void 0:a.status)||"pending",completed:!(!M.environmentId||!M.chargebeeEnvironment)&&!!(M.sourceName&&M.subdomain&&M.apiKey&&M.syncStartDate)&&!r&&Tn&&!r&&Pn,isSetupIncomplete:r,ingestionResult:s}),h("chargebee",o),S(o),I();case 1:case"end":return e.stop()}},e)}));return function(){return e.apply(this,arguments)}}(),Xs=function(){var e,t,n,a=!0===(null!==(e=null==x?void 0:x.chargebee)&&void 0!==e?e:{}).step2Completed||!!(M.sourceName&&M.subdomain&&M.apiKey&&M.syncStartDate),r=_e(_e({},M),{},{step1Completed:!(!M.environmentId||!M.chargebeeEnvironment),step2Completed:a,step3Completed:Tn,step4Completed:Pn,step4WasEverCompleted:Kn,isStep3Incomplete:tn,testingSteps:wt,testCompleted:It,schemaVerified:(null===(t=x.chargebee)||void 0===t?void 0:t.schemaVerified)||!1,status:(null===(n=x.chargebee)||void 0===n?void 0:n.status)||"pending",completed:!(!M.environmentId||!M.chargebeeEnvironment)&&a&&Tn&&Pn,isSetupIncomplete:pr});h("chargebee",r),S(r),r.step2Completed&&(0,H.fX)()},Qs=function(e){Jt(e),Qt(!0),nn(!0),Dn(!0),Ma(!0),Fs(!0),Ce("pause-fix")},$s=(Rs.filter(function(e){return e.isCompleted}).length,Rs.length,(0,d.useState)(M.syncStartDate instanceof Date?M.syncStartDate.getMonth():(new Date).getMonth())),eo=(0,c.A)($s,2),to=eo[0],no=eo[1],ao=(0,d.useState)(M.syncStartDate instanceof Date?M.syncStartDate.getFullYear():(new Date).getFullYear()),ro=(0,c.A)(ao,2),so=ro[0],oo=ro[1],lo=(0,H.VG)()||"",io=function(e){if(!e||""===e.trim())return"";var t=e.trim().split(/\s+/);return 1===t.length?t[0].substring(0,2).toUpperCase():(t[0][0]+t[1][0]).toUpperCase()}(lo),co=function(){var e,t,n,a,r,s,o,l,i,c,m,u=!!(M.sourceName&&M.subdomain&&M.apiKey&&M.syncStartDate),p=Fa&&!!M.subdomain,g=Fa&&It;return d.createElement("div",{className:"space-y-8"},d.createElement("div",null,d.createElement("div",{className:"flex items-center gap-2 mb-2"},d.createElement("h3",{className:"text-lg font-semibold text-gray-900"},"2.1 Source Name"),M.sourceName&&d.createElement(y.CheckCircle,{className:"w-5 h-5 text-green-600"})),d.createElement("div",{className:"ml-7"},d.createElement("p",{className:"text-sm text-gray-600 mb-4"},"Give this data source a memorable name to easily identify it in your dashboard."),d.createElement("div",{className:"flex items-center gap-2"},d.createElement("input",{type:"text",placeholder:"Enter source name",value:M.sourceName,onChange:function(e){return Ps("sourceName",e.target.value)},readOnly:Fa&&!(null===(e=x.chargebee)||void 0===e||!e.sourceName)&&!ga,className:"w-96 px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent ".concat(Fa&&!ga&&null!==(t=x.chargebee)&&void 0!==t&&t.sourceName?"bg-gray-50 cursor-not-allowed":"")}),Fa&&(null===(n=x.chargebee)||void 0===n?void 0:n.sourceName)&&!ga&&d.createElement("button",{type:"button",onClick:Vs,className:"p-2 text-blue-600 hover:text-blue-800 hover:bg-blue-50 rounded-md transition-colors",title:"Edit"},d.createElement(y.Pencil,{className:"w-4 h-4"})),ga&&d.createElement("div",{className:"flex gap-2"},d.createElement("button",{type:"button",onClick:zs,className:"px-3 py-2 text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 rounded-md transition-colors whitespace-nowrap"},"Save"),d.createElement("button",{type:"button",onClick:Bs,className:"px-3 py-2 text-sm font-medium text-gray-700 hover:text-gray-900 border border-gray-300 rounded-md hover:bg-gray-50 transition-colors whitespace-nowrap"},"Cancel"))),xe.sourceName&&d.createElement("p",{className:"text-red-600 text-sm mt-1"},xe.sourceName))),d.createElement("div",{ref:wn},d.createElement("div",{className:"flex items-center gap-2 mb-2"},d.createElement("h3",{className:"text-lg font-semibold text-gray-900"},"2.2 Site Name (Subdomain)"),M.subdomain&&d.createElement(y.CheckCircle,{className:"w-5 h-5 text-green-600"}),d.createElement("div",{className:"relative group"},d.createElement(y.Info,{className:"h-4 w-4 text-gray-400 cursor-help"}),d.createElement("div",{className:"absolute bottom-full left-1/2 transform -translate-x-1/2 mb-2 px-3 py-2 bg-gray-800 text-white text-sm rounded-lg opacity-0 group-hover:opacity-100 transition-opacity duration-200 pointer-events-none whitespace-nowrap z-10"},"Your site name appears in your Chargebee URL: ","{sitename}",".chargebee.com",d.createElement("div",{className:"absolute top-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-l-4 border-r-4 border-t-4 border-transparent border-t-gray-800"}
1)))),d.createElement("div",{className:"ml-7"},d.createElement("p",{className:"text-sm text-gray-600 mb-4"},"Enter your Chargebee site name (subdomain). For example, if your Chargebee URL is ",d.createElement("span",{className:"font-mono bg-gray-100 px-1 rounded"},"mycompany.chargebee.com"),", enter ",d.createElement("span",{className:"font-mono bg-gray-100 px-1 rounded"},"mycompany"),"."),d.createElement("div",{className:"relative flex items-center gap-2"},d.createElement("div",{className:"flex items-center max-w-md"},p?d.createElement("div",{className:"w-64 px-3 py-2 border border-gray-300 rounded-l-md bg-gray-50 cursor-not-allowed select-none text-gray-900 font-semibold",onCopy:function(e){return e.preventDefault()},onCut:function(e){return e.preventDefault()},onDragStart:function(e){return e.preventDefault()},onMouseDown:function(e){return e.preventDefault()}},M.subdomain||"â"):d.createElement("input",{type:"text",placeholder:"mycompany",value:M.subdomain,onChange:function(e){return Ps("subdomain",e.target.value)},className:"w-64 px-3 py-2 border border-gray-300 rounded-l-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent"}),d.createElement("span",{className:"px-3 py-2 bg-gray-100 border border-l-0 border-gray-300 rounded-r-md text-gray-600 select-none"},".chargebee.com")),p&&d.createElement("div",{className:"flex items-center gap-2"},d.createElement("div",{className:"relative group"},d.createElement(y.Lock,{className:"w-4 h-4 text-gray-500"})),d.createElement("div",{className:"relative group"},d.createElement(y.Info,{className:"w-4 h-4 text-gray-500 cursor-help"}),d.createElement("div",{className:"absolute bottom-full left-1/2 transform -translate-x-1/2 mb-2 px-3 py-2 bg-gray-900 text-white text-xs rounded-lg opacity-0 group-hover:opacity-100 transition-opacity duration-200 z-10 w-80"},"To use a different Chargebee subdomain, ",d.createElement("a",{href:"#",onClick:function(e){e.preventDefault(),R()},className:"font-semibold underline"},"go to Integrations list"),", delete this connection, and create a new one.",d.createElement("div",{className:"absolute top-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-l-4 border-r-4 border-t-4 border-transparent border-t-gray-900"})))),!p&&Bt&&d.createElement("span",{className:"flex items-center gap-1.5 text-sm text-red-600"},d.createElement(y.AlertTriangle,{className:"w-4 h-4 flex-shrink-0"}),"Invalid credentials"),va&&d.createElement("div",{className:"flex gap-2"},d.createElement("button",{type:"button",onClick:qs,className:"px-3 py-2 text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 rounded-md transition-colors whitespace-nowrap"},"Save"),d.createElement("button",{type:"button",onClick:js,className:"px-3 py-2 text-sm font-medium text-gray-700 hover:text-gray-900 border border-gray-300 rounded-md hover:bg-gray-50 transition-colors whitespace-nowrap"},"Cancel"))),va&&d.createElement("div",{className:"mt-2 p-3 bg-yellow-50 border border-yellow-200 rounded-md"},d.createElement("p",{className:"text-sm text-yellow-800"},d.createElement("strong",null,"Warning:")," Changing the site name will reset the setup and you need to run connection test and ingestion again with the updated credentials.")),xe.subdomain&&d.createElement("p",{className:"text-red-600 text-sm mt-1"},xe.subdomain))),d.createElement("div",null,d.createElement("div",{className:"flex items-center gap-2 mb-2"},d.createElement("h3",{className:"text-lg font-semibold text-gray-900"},"2.3 API Key"),M.apiKey&&d.createElement(y.CheckCircle,{className:"w-5 h-5 text-green-600"}),d.createElement("div",{className:"relative group"},d.createElement(y.Info,{className:"h-4 w-4 text-gray-400 cursor-help"}),d.createElement("div",{className:"absolute bottom-full left-1/2 transform -translate-x-1/2 mb-2 px-3 py-2 bg-gray-800 text-white text-sm rounded-lg opacity-0 group-hover:opacity-100 transition-opacity duration-200 pointer-events-none whitespace-nowrap z-10"},"Get your secret key from Chargebee dashboard and paste it here for API access",d.createElement("div",{className:"absolute top-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-l-4 border-r-4 border-t-4 border-transparent border-t-gray-800"}
1)))),d.createElement("div",{className:"ml-7"},d.createElement("div",{className:"flex items-start mb-4"},d.createElement("p",{className:"text-sm text-gray-600"},"Your Chargebee API key helps ThriveStack to pull data from your Chargebee account."),d.createElement("button",{onClick:function(){Y(!0),setTimeout(function(){var e;null===(e=rt.current)||void 0===e||e.scrollIntoView({behavior:"smooth",block:"start"})},100)},className:"text-blue-600 hover:text-blue-800 underline text-sm font-medium whitespace-nowrap ml-4"},"Show Documentation")),d.createElement("div",{className:"mb-4"},d.createElement("p",{className:"text-sm text-gray-700 mb-2"},"1. Get your API key from Chargebee"," ",d.createElement("a",{href:M.subdomain?"https://".concat(M.subdomain,".chargebee.com/apikeys_and_webhooks/api"):"https://www.chargebee.com/docs/2.0/api_keys.html",target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 hover:text-blue-800 underline inline-flex items-center gap-1"},"Get your API key from Chargebee",d.createElement(y.ExternalLink,{className:"h-3 w-3"}))),d.createElement("p",{className:"text-sm text-gray-700"},"2. Paste it below")),d.createElement("div",{className:"flex items-center gap-2"},d.createElement("div",{className:"relative max-w-md"},d.createElement("input",{type:V?"text":"password",placeholder:"live_â¢â¢â¢â¢â¢â¢â¢â¢â¢â¢â¢â¢â¢â¢â¢â¢",value:M.apiKey,onChange:function(e){return Ps("apiKey",e.target.value)},readOnly:Fa&&!(null===(a=x.chargebee)||void 0===a||!a.apiKey)&&!Na,className:"w-96 px-3 py-2 pr-10 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent ".concat(Fa&&!Na&&null!==(r=x.chargebee)&&void 0!==r&&r.apiKey?"bg-gray-50 cursor-not-allowed":"")}),(!Na||!(null!==(s=x.chargebee)&&void 0!==s&&s.apiKey))&&d.createElement("button",{type:"button",className:"absolute right-3 top-1/2 transform -translate-y-1/2 text-gray-400 hover:text-gray-600",onClick:function(){return B(!V)}},V?d.createElement(y.EyeOff,{className:"h-4 w-4"}):d.createElement(y.Eye,{className:"h-4 w-4"}))),Fa&&(null===(o=x.chargebee)||void 0===o?void 0:o.apiKey)&&!Na&&d.createElement(d.Fragment,null,d.createElement("button",{type:"button",onClick:Ls,className:"p-2 text-blue-600 hover:text-blue-800 hover:bg-blue-50 rounded-md transition-colors",title:"Edit"},d.createElement(y.Pencil,{className:"w-4 h-4"})),Bt&&d.createElement("span",{className:"flex items-center gap-1.5 text-sm text-red-600"},d.createElement(y.AlertTriangle,{className:"w-4 h-4 flex-shrink-0"}),"Invalid credentials")),Na&&d.createElement("div",{className:"flex gap-2"},d.createElement("button",{type:"button",onClick:Ys,className:"px-3 py-2 text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 rounded-md transition-colors whitespace-nowrap"},"Save"),d.createElement("button",{type:"button",onClick:Us,className:"px-3 py-2 text-sm font-medium text-gray-700 hover:text-gray-900 border border-gray-300 rounded-md hover:bg-gray-50 transition-colors whitespace-nowrap"},"Cancel"))),Na&&d.createElement("div",{className:"mt-2 p-3 bg-yellow-50 border border-yellow-200 rounded-md"},d.createElement("p",{className:"text-sm text-yellow-800"},d.createElement("strong",null,"Warning:")," Changing the API key will reset the setup and you need to run connection test and ingestion again with the updated credentials.")),xe.apiKey&&d.createElement("p",{className:"text-red-600 text-sm mt-1"},xe.apiKey))),d.createElement("div",null,d.createElement("div",{className:"flex items-center gap-2 mb-2"},d.createElement("h3",{className:"text-lg font-semibold text-gray-900"},"2.4 Product Catalog Version"),M.productCatalog&&d.createElement(y.CheckCircle,{className:"w-5 h-5 text-green-600"}),d.createElement("div",{className:"relative group"},d.createElement(y.Info,{className:"h-4 w-4 text-gray-400 cursor-help"}),d.createElement("div",{className:"absolute bottom-full left-1/2 transform -translate-x-1/2 mb-2 px-3 py-2 bg-gray-800 text-white text-sm rounded-lg opacity-0 group-hover:opacity-100 transition-opacity duration-200 pointer-events-none whitespace-nowrap z-10"},"Select your Chargebee Product Catalog version",d.createElement("div",{className:"absolute top-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-l-4 border-r-4 border-t-4 border-transparent border-t-gray-800"}
1)))),d.createElement("div",{className:"ml-7"},d.createElement("p",{className:"text-sm text-gray-600 mb-4"},"Select the Product Catalog version used in your Chargebee account."," ",d.createElement("a",{href:"#",onClick:function(e){e.preventDefault(),Y(!0),setTimeout(function(){var e;return null===(e=rt.current)||void 0===e?void 0:e.scrollIntoView({behavior:"smooth",block:"start"})},100)},className:"text-blue-600 hover:text-blue-800 underline text-sm font-medium whitespace-nowrap ml-4"},"Show documentation")),d.createElement("div",{className:"flex items-center gap-2"},d.createElement("div",{className:"relative max-w-md","data-dropdown":"product-catalog"},g?d.createElement("div",{className:"w-96 px-3 py-2 border border-gray-300 rounded-md bg-gray-50 cursor-not-allowed select-none flex items-center justify-between",onCopy:function(e){return e.preventDefault()},onCut:function(e){return e.preventDefault()},onDragStart:function(e){return e.preventDefault()},onMouseDown:function(e){return e.preventDefault()}},d.createElement("span",{className:"text-gray-900 font-semibold"},"2.0"===M.productCatalog?"Product Catalog 2.0":"1.0"===M.productCatalog?"Product Catalog 1.0":"â"),d.createElement(y.Lock,{className:"w-4 h-4 text-gray-500"})):d.createElement("button",{type:"button",onClick:function(){return We(!ze)},className:"w-96 px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent text-left flex items-center justify-between bg-white"},d.createElement("span",{className:M.productCatalog?"text-gray-900 font-semibold":"text-gray-500"},"2.0"===M.productCatalog?"Product Catalog 2.0":"1.0"===M.productCatalog?"Product Catalog 1.0":"Select Product Catalog"),d.createElement(y.ChevronDown,{className:"w-4 h-4 text-gray-400 transition-transform ".concat(ze?"rotate-180":"")})),ze&&d.createElement("div",{className:"absolute z-10 w-full mt-1 bg-white border border-gray-300 rounded-md shadow-lg"},d.createElement("div",{className:"py-1"},d.createElement("button",{type:"button",onClick:function(){Ps("productCatalog","2.0"),We(!1)},className:"w-full px-3 py-2 text-left text-sm hover:bg-blue-50 hover:text-blue-900 flex items-center justify-between"},d.createElement("span",null,"Product Catalog 2.0"),"2.0"===M.productCatalog&&d.createElement(y.CheckCircle,{className:"w-4 h-4 text-blue-600"})),d.createElement("button",{type:"button",onClick:function(){ka||(Ps("productCatalog","1.0"),We(!1))},className:"w-full px-3 py-2 text-left text-sm text-gray-900 hover:bg-gray-100 transition-colors flex items-center justify-between border-t border-gray-200"},d.createElement("span",null,"Product Catalog 1.0"),"1.0"===M.productCatalog&&d.createElement(y.CheckCircle,{className:"w-4 h-4 text-blue-600"}))))),g&&d.createElement("div",{className:"relative group"},d.createElement(y.Info,{className:"w-4 h-4 text-gray-500 cursor-help"}),d.createElement("div",{className:"absolute bottom-full left-1/2 transform -translate-x-1/2 mb-2 px-3 py-2 bg-gray-900 text-white text-xs rounded-lg opacity-0 group-hover:opacity-100 transition-opacity duration-200 z-10 w-80"},"To use a different Product Catalog version, ",d.createElement("a",{href:"#",onClick:function(e){e.preventDefault(),R()},className:"font-semibold underline"},"go to Integrations list"),", delete this connection, and create a new one.",d.createElement("div",{className:"absolute top-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-l-4 border-r-4 border-t-4 border-transparent border-t-gray-900"}))),ka&&d.createElement("div",{className:"flex gap-2"},d.createElement("button",{type:"button",onClick:Hs,className:"px-3 py-2 text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 rounded-md transition-colors whitespace-nowrap"},"Save"),d.createElement("button",{type:"button",onClick:Ws,className:"px-3 py-2 text-sm font-medium text-gray-700 hover:text-gray-900 border border-gray-300 rounded-md hover:bg-gray-50 transition-colors whitespace-nowrap"},"Cancel"))))),d.createElement("div",null,d.createElement("div",{className:"flex items-center gap-2 mb-2"},d.createElement("h3",{className:"text-lg font-semibold text-gray-900"},"2.5 Sync Start Date"),M.syncStartDate&&d.createElement(y.CheckCircle,{className:"w-5 h-5 text-green-600"})),d.createElement("div",{className:"ml-7"},d.createElement("p",{className:"text-sm text-gray-600 mb-4"},"Choose the date from which you want to start syncing historical payment data."),d.createElement("div",{className:"flex items-center gap-2"},d.createElement("div",{className:"relative max-w-md"},d.createElement("button",{type:"button",onClick:function(){var e;Fa&&!Da&&null!==(e=x.chargebee)&&void 0!==e&&e.syncStartDate||ee(!$)},disabled:Fa&&!(null===(l=x.chargebee)||void 0===l||!l.syncStartDate)&&!Da,className:"w-96 px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent text-left flex items-center justify-between ".concat(Fa&&!Da&&null!==(i=x.chargebee)&&void 0!==i&&i.syncStartDate?"bg-gray-50 cursor-not-allowed":"")},d.createElement("span",{className:M.syncStartDate?"text-gray-900":"text-gray-500"},M.syncStartDate instanceof Date?M.syncStartDate.toLocaleDateString("en-US",{weekday:"long",year:"numeric",month:"long",day:"numeric"}):"Pick a date"),d.createElement(y.CalendarIcon,{className:"h-4 w-4 text-gray-400"})),$&&function(){for(var e=new Date,t=new Date(so,to,1),n=new Date(so,to+1,0),a=t.getDay(),r=n.getDate(),s=[],o=0;o<a;o++)s.push(d.createElement("div",{key:"empty-".concat(o),className:"p-2"}));for(var l=function(){var t=new Date(so,to,i),n=M.syncStartDate instanceof Date&&M.syncStartDate.toDateString()===t.toDateString(),a=t>e||t<new Date("2020-01-01");s.push(d.createElement("button",{key:i,type:"button",onClick:function(){a||(Ps("syncStartDate",t),ee(!1))},disabled:a,className:"p-2 text-sm rounded hover:bg-gray-100 ".concat(n?"bg-blue-600 text-white hover:bg-blue-700":""," ").concat(a?"text-gray-400 cursor-not-allowed":"cursor-pointer")}
1,i))},i=1;i<=r;i++)l();for(var c=[],m=2020;m<=e.getFullYear();m++)c.push(m);return d.createElement("div",{className:"absolute z-10 mb-2 bottom-full bg-white border border-gray-300 rounded-md shadow-lg p-4 w-96"},d.createElement("div",{className:"flex items-center justify-between mb-4 gap-2"},d.createElement("button",{type:"button",onClick:function(){0===to?(no(11),oo(so-1)):no(to-1)},className:"p-1 hover:bg-gray-100 rounded"},d.createElement("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},d.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"}))),d.createElement("div",{className:"flex gap-2"},d.createElement("select",{value:to,onChange:function(e){return no(parseInt(e.target.value))},className:"text-sm border border-gray-300 rounded px-2 py-1 focus:outline-none focus:ring-2 focus:ring-blue-500"},["January","February","March","April","May","June","July","August","September","October","November","December"].map(function(e,t){return d.createElement("option",{key:e,value:t},e)})),d.createElement("select",{value:so,onChange:function(e){return oo(parseInt(e.target.value))},className:"text-sm border border-gray-300 rounded px-2 py-1 focus:outline-none focus:ring-2 focus:ring-blue-500"},c.map(function(e){return d.createElement("option",{key:e,value:e},e)}))),d.createElement("button",{type:"button",onClick:function(){11===to?(no(0),oo(so+1)):no(to+1)},className:"p-1 hover:bg-gray-100 rounded"},d.createElement("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},d.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})))),d.createElement("div",{className:"grid grid-cols-7 gap-1 text-xs mb-2"},["Su","Mo","Tu","We","Th","Fr","Sa"].map(function(e){return d.createElement("div",{key:e,className:"p-2 text-center font-medium text-gray-500"},e)})),d.createElement("div",{className:"grid grid-cols-7 gap-1"},s))}()),Fa&&(null===(c=x.chargebee)||void 0===c?void 0:c.syncStartDate)&&!Da&&d.createElement("button",{type:"button",onClick:Gs,className:"p-2 text-blue-600 hover:text-blue-800 hover:bg-blue-50 rounded-md transition-colors",title:"Edit"},d.createElement(y.Pencil,{className:"w-4 h-4"})),Da&&d.createElement("div",{className:"flex gap-2"},d.createElement("button",{type:"button",onClick:Zs,className:"px-3 py-2 text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 rounded-md transition-colors whitespace-nowrap"},"Save"),d.createElement("button",{type:"button",onClick:Js,className:"px-3 py-2 text-sm font-medium text-gray-700 hover:text-gray-900 border border-gray-300 rounded-md hover:bg-gray-50 transition-colors whitespace-nowrap"},"Cancel"))),Da&&d.createElement("div",{className:"mt-2 p-3 bg-yellow-50 border border-yellow-200 rounded-md"},d.createElement("p",{className:"text-sm text-yellow-800"},d.createElement("strong",null,"Warning:")," Changing the sync start date will reset the setup and you need to run connection test and ingestion again with the updated settings.")),xe.syncStartDate&&d.createElement("p",{className:"text-red-600 text-sm mt-1"},xe.syncStartDate.toString()))),d.createElement("div",{className:"flex justify-end pt-4 border-t border-gray-200"},(m=!u||ga||va||Na||ka||Da,d.createElement("button",{type:"button",onClick:function(){if(Ma(!0),gr(!1),Ie(!0),Sn.current="revenue-correlation",Er){vr(Sr&&Tr?"both":Tr?"syncDateOnly":Sr?"apiKeyOnly":"none"),Nr(!1);var e=_e(_e({},M),{},{pendingApiKeyChange:Sr,pendingSyncDateChange:Tr,step1Completed:!(!M.environmentId||!M.chargebeeEnvironment),step2Completed:!!(M.sourceName&&M.subdomain&&M.apiKey&&M.productCatalog&&M.syncStartDate)});h("chargebee",e),S(e)}else Xs();(0,H.fX)(),I(),Ce("revenue-correlation"),setTimeout(function(){var e;null===(e=En.current)||void 0===e||e.scrollIntoView({behavior:"smooth",block:"start"})},100)},disabled:m,className:"px-6 py-2 rounded-md font-medium transition-colors ".concat(m?"bg-gray-300 text-gray-500 cursor-not-allowed":"bg-blue-600 text-white hover:bg-blue-700")},"Save"))),d.createElement(fe,{isOpen:Wr,onClose:function(){return Hr(!1)},onConnect:Ss}))},mo=function(){var e=(0,s.A)(u().mark(function e(){var t,n,a,r,s,o,l,i,c,m,d=arguments;return u().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return t=d.length>0&&void 0!==d[0]?d[0]:"SUCCESS",at(!0),Tt(!1),oe(null),Kt(!1),nn(!1),Lt(null),zt(null),Ct(function(e){return e.map(function(e){return _e(_e({},e),{},{status:"pending",missingEntities:[]})})}),e.prev=1,Ct(function(e){return e.map(function(e,t){return 0===t?_e(_e({},e),{},{status:"loading"}):e})}),e.next=2,new Promise(function(e){return setTimeout(e,500)});case 2:return e.next=3,Ds(t);case 3:if(a=e.sent){e.next=4;break}throw new Error("CHARGEBEE_TEST_CONNECTION_NO_RESPONSE");case 4:if(r={},null!=a&&a.validSiteTypeMessage&&(r.siteType=a.validSiteTypeMessage),null!=a&&a.validSiteNameMessage&&(r.siteName=a.validSiteNameMessage),null!=a&&a.validProductCatalogMessage&&(r.productCatalog=a.validProductCatalogMessage),null!=a&&a.credentialsMessage&&(r.credentials=a.credentialsMessage,a.credentialsMessage.toLowerCase().includes("site_not_found")?zt("Invalid Site Name and or API key"):zt("Invalid credentials"),setTimeout(function(){Sn.current="basic-config",Ce("basic-config"),setTimeout(function(){var e;null===(e=hn.current)||void 0===e||e.scrollIntoView({behavior:"smooth",block:"start"})},100)},1500)),null!=a&&a.entitySyncResults&&(s=a.entitySyncResults.filter(function(e){return!e.success}).map(function(e){return{entityName:e.entityName,errorMessage:e.errorMessage}})).length>0&&(r.entitySync=s),!(Object.keys(r).length>0)){e.next=5;break}return Lt(r),Ct(function(e){return e.map(function(e,t){return 0===t?_e(_e({},e),{},{status:"error"}):e})}),at(!1),Tt(!0),e.abrupt("return");case 5:return Ct(function(e){return e.map(function(e,t){return 0===t?_e(_e({},e),{},{status:"success"}):e})}),e.next=6,new Promise(function(e){return setTimeout(e,800)});case 6:return Ct(function(e){return e.map(function(e,t){return 1===t?_e(_e({},e),{},{status:"loading"}):e})}),setTimeout(function(){return Kt(!0)},300),e.next=7,new Promise(function(e){return setTimeout(e,1e3)});case 7:if(o=(null==a||null===(n=a.entitySyncResults)||void 0===n?void 0:n.filter(function(e){return!e.success}).map(function(e){return e.entityName}))||[],l=o.length>0,Ct(function(e){return e.map(function(e,t){return 1===t?_e(_e({},e),{},{status:l?"error":"success",missingEntities:o}):e})}),!l){e.next=8;break}return setTimeout(function(){return Kt(!1)},1200),at(!1),Tt(!0),Dn(!0),nn(!0),e.abrupt("return");case 8:return setTimeout(function(){return Kt(!1)},1200),e.next=9,new Promise(function(e){return setTimeout(e,800)});case 9:return Ct(function(e){return e.map(function(e,t){return 2===t?_e(_e({},e),{},{status:"loading"}):e})}),e.next=10,new Promise(function(e){return setTimeout(e,500)});case 10:return i=(null==a?void 0:a.customerMetaDataKeys)&&a.customerMetaDataKeys.length>0,c=i?"success":"error",Ct(function(e){return e.map(function(e,t){return 2===t?_e(_e({},e),{},{status:c,selectedIdentifierKey:lt}):e})}),e.next=11,new Promise(function(e){return setTimeout(e,800)});case 11:Dn(!0),Kn||nn(!xt),e.next=13;break;case 12:e.prev=12,m=e.catch(1),console.error("Test failed:",m),Ct(function(e){return e.map(function(e,t){return _e(_e({},e),{},0===t?{status:"error",missingEntities:[]}:{status:"pending",missingEntities:[]})})}),Tt(!0);case 13:at(!1),Tt(!0);case 14:case"end":return e.stop()}},e,null,[[1,12]])}));return function(){return e.apply(this,arguments)}}(),uo=function(){return d.createElement("div",{className:"space-y-6"},d.createElement("div",null,d.createElement("p",{className:"text-gray-700 leading-relaxed text-sm"},"We will use the credentials from ",d.createElement("span",{className:"font-medium text-gray-900"},"Basic Configuration")," (step 2) to test the connection with Chargebee and sync sample data of 200 Transactions."),d.createElement("div",{className:"flex items-center gap-3 mt-2 flex-wrap"},d.createElement("button",{type:"button",className:"px-4 py-2 rounded-md font-medium transition-all duration-200 flex items-center space-x-2 min-w-[120px] justify-center ".concat(nt?"bg-blue-600 text-white cursor-default":"bg-blue-600 hover:bg-blue-700 active:bg-blue-800 text-white shadow-sm hover:shadow-md"),onClick:function(){return mo("SUCCESS")},disabled:nt},nt?d.createElement(d.Fragment,null,d.createElement(y.Database,{className:"w-4 h-4"}),d.createElement("span",null,"Testing",".".repeat(_t))):It?d.createElement(d.Fragment,null,d.createElement(y.Database,{className:"w-4 h-4"}),d.createElement("span",null,"Retry")):d.createElement(d.Fragment,null,d.createElement(y.Database,{className:"w-4 h-4"}),d.createElement("span",null,"Test Data Sync"))),q&&!nt&&d.createElement(d.Fragment,null,d.createElement("button",{type:"button",className:"px-4 py-2 rounded-md font-medium transition-all duration-200 flex items-center space-x-2 border border-blue-600 bg-white text-blue-600 hover:bg-blue-50",onClick:function(){return mo("MISSING_ENTITIES")}},d.createElement(y.Database,{className:"w-4 h-4"}),d.createElement("span",null,"Simulate Missing Entities")),d.createElement("button",{type:"button",className:"px-4 py-2 rounded-md font-medium transition-all duration-200 flex items-center space-x-2 border border-blue-600 bg-white text-blue-600 hover:bg-blue-50",onClick:function(){return mo("MISSING_GROUP_ID")}},d.createElement(y.Database,{className:"w-4 h-4"}),d.createElement("span",null,"Simulate Schema Error"))),It&&ks()&&d.createElement(d.Fragment,null,d.createElement("div",{className:"flex items-center space-x-3"},d.createElement("div",{className:"flex items-center space-x-2 text-green-600"},d.createElement(y.CheckCircle,{className:"w-4 h-4"}),d.createElement("span",{className:"text-sm font-medium"},"Test Completed - Schema Verified"))))),d.createElement("div",{className:"mt-4 space-y-3 border border-gray-200 p-4 rounded-lg"},wt.map(function(e,t){var n,a;return d.createElement("div",{key:e.id,className:"flex items-start space-x-3"},d.createElement("div",{className:"flex-shrink-0 mt-1 text-lg"},"loading"===e.status&&d.createElement(y.Loader2,{className:"w-4 h-4 text-blue-600 animate-spin"}),"success"===e.status&&d.createElement(y.CheckCircle,{className:"w-4 h-4 text-green-600"}),"error"===e.status&&d.createElement(y.AlertTriangle,{className:"w-4 h-4 text-red-600"}),"pending"===e.status&&d.createElement("div",{className:"w-4 h-4 rounded-full border-2 border-gray-300"})),d.createElement("div",{className:"flex-1"},d.createElement("div",{className:"font-medium text-gray-900 text-lg"},"loading"===e.status&&e.loadingText,"success"===e.status&&e.successText,"error"===e.status&&("data"===e.id?"Failed to Retrieve Data":"connection"===e.id&&Bt?d.createElement("span",{className:"flex items-center gap-2 flex-wrap"},e.errorText,d.createElement("span",{className:"text-red-600 font-normal text-base"}," - ",Bt)):e.errorText),"pending"===e.status&&e.loadingText),"data"===e.id&&"pending"!==e.status&&d.createElement("div",{className:"mt-2"},d.createElement("button",{type:"button",onClick:function(){return Kt(!Ft)},className:"flex items-center space-x-2 text-blue-600 hover:text-blue-800 text-sm font-medium mb-2"},d.createElement(y.ChevronDown,{className:"w-4 h-4 transition-transform ".concat(Ft?"":"-rotate-90")}),d.createElement("span",null,"List of Entities Syncing")),Ft&&d.createElement("div",{className:"border-l-2 border-gray-200 pl-4 ml-6 transition-all duration-500 ease-in-out transform"},d.createElement("div",{className:"space-y-2"},d.createElement("div",{className:"text-sm text-gray-600"},"Total tables in Chargebee: ",d.createElement("span",{className:"font-medium text-gray-900"},Me.available.length)),d.createElement("div",{className:"text-sm text-gray-600"}
1,"Tables to be synced to TS: ",d.createElement("span",{className:"font-medium text-gray-900"},Me.willSync.length),d.createElement("ul",{className:"flex flex-col ml-1 mt-2 space-y-1"},Me.willSync.map(function(t){var n,a=null===(n=e.missingEntities)||void 0===n?void 0:n.includes(t);return d.createElement("li",{key:t,className:"flex items-center space-x-2 text-sm"},a?d.createElement(y.X,{className:"w-4 h-4 text-red-600 flex-shrink-0"}):d.createElement(y.Check,{className:"w-4 h-4 text-green-600 flex-shrink-0"}),d.createElement("span",{className:a?"text-red-700 font-medium":"text-gray-700"},t))})))))),"data"===e.id&&"error"===e.status&&e.missingEntities&&e.missingEntities.length>0&&d.createElement("div",{className:"space-y-4 mt-3"},d.createElement("div",{className:"p-4 bg-red-50 rounded-md"},d.createElement("div",{className:"space-y-3"},d.createElement("h4",{className:"font-semibold text-gray-900 text-base"},"Unable to retrieve some entities â ",d.createElement("span",{className:"font-normal"},"Your secret key doesn't have access to ",(null===(n=e.missingEntities)||void 0===n?void 0:n.length)||0," / ",Me.willSync.length," required Chargebee ",1===(null===(a=e.missingEntities)||void 0===a?void 0:a.length)?"table":"tables",".")),d.createElement("h4",{className:"font-semibold text-gray-900 text-base"},"To resolve this, you need to"," ",d.createElement("button",{type:"button",onClick:function(){Y(!0),setTimeout(function(){var e=document.querySelector('[data-section="setup-chargebee"]');e&&e.scrollIntoView({behavior:"smooth",block:"start"})},100)},className:"text-blue-600 hover:text-blue-800 underline font-medium"},"configure your secret key's permissions"),"."),d.createElement("div",{className:"bg-white p-3 rounded"},d.createElement("div",{className:"text-sm font-medium text-gray-900 mb-2"},"All tables to be synced:"),d.createElement("ul",{className:"space-y-1"},Me.willSync.map(function(t){var n,a=null===(n=e.missingEntities)||void 0===n?void 0:n.includes(t);return d.createElement("li",{key:t,className:"flex items-center space-x-2 text-sm"},a?d.createElement(y.X,{className:"w-4 h-4 text-red-600 flex-shrink-0"}):d.createElement(y.CheckCircle,{className:"w-4 h-4 text-green-600 flex-shrink-0"}),d.createElement("span",{className:a?"text-red-700 font-medium":"text-gray-700"},t))}))),d.createElement("div",{className:"flex items-center gap-3"},d.createElement("button",{type:"button",className:"px-4 py-2 bg-white border border-gray-300 hover:bg-gray-50 text-gray-700 rounded-md font-medium text-sm transition-colors",onClick:function(){return mo("SUCCESS")}},"Retry Test"))))),"error"===e.status&&"schema"===e.id&&(!ft||0===ft.length)&&d.createElement("div",{className:"space-y-3 mt-3"},d.createElement("p",{className:"text-sm text-gray-700"},"Account identifier key is missing in Chargebee customer metadata. Fix it to enable correlation across product, marketing and revenue data."),d.createElement(be.i,{source:"chargebee",accountIdentifierKey:lt}),d.createElement("button",{type:"button",className:"px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-md font-medium text-sm transition-colors",onClick:function(){Qs(k.V.REVOPS_TEAMS),Fs(!0),Ce("pause-fix"),Dn(!0)}},"Invite and Proceed")),"schema"===e.id&&"success"===e.status&&ft&&ft.length>0&&d.createElement(d.Fragment,null,d.createElement("div",{className:"space-y-4 mt-3"},d.createElement("div",{className:"p-4 bg-gray-50 rounded-lg"},d.createElement("div",{className:"space-y-3"},d.createElement("div",null,d.createElement("p",{className:"text-sm text-gray-900 mb-3"},"To uniquely identify the account information and to correlate it with revenue data, we look at the following key. This key enables seamless correlation across revenue, marketing, and product data.")),d.createElement("div",null,d.createElement("label",{className:"block text-sm font-medium text-gray-700 mb-2"},"Account Identifier Key"),d.createElement("div",{className:"relative"},d.createElement("button",{type:"button",onClick:function(){return dt(!ut)},className:"w-64 px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent bg-white text-left flex items-center justify-between"},d.createElement("span",{className:"text-gray-900 font-medium"},lt),d.createElement(y.ChevronDown,{className:"w-4 h-4 text-gray-400 transition-transform ".concat(ut?"rotate-180":"")})),ut&&d.createElement("div",{className:"absolute z-10 w-64 mt-1 bg-white border border-gray-300 rounded-md shadow-lg max-h-60 overflow-auto"},d.createElement("div",{className:"py-1"},ft.map(function(e){return d.createElement("button",{key:e,type:"button",onClick:function(){it(e),dt(!1),Ct(function(t){return t.map(function(t){return"schema"===t.id?_e(_e({},t),{},{selectedIdentifierKey:e,customerMetaDataKeys:ft}):t})})},className:"w-full px-3 py-2 text-left text-sm hover:bg-blue-50 hover:text-blue-900 flex items-center justify-between"},d.createElement("span",null,e),lt===e&&d.createElement(y.Check,{className:"w-4 h-4 text-blue-600"}))}))),xt&&d.createElement(d.Fragment,null,d.createElement("p",{className:"flex items-center gap-x-1 text-sm bg-amber-50 text-amber-700 rounded-xl px-5 py-4 mb-3 mt-2"},d.createElement(y.AlertTriangle,{className:"w-4 h-4 flex-shrink-0"}),d.createElement("span",null,"Group ID is set as the default account identifier. Please select an alternative key from the dropdown menu if this is incorrect."))),!xt&&d.createElement("div",{className:"mt-3"},d.createElement("div",{className:"bg-amber-50 text-amber-700 rounded-xl px-5 py-4"},d.createElement("div",{className:"flex items-start gap-2"},d.createElement(y.AlertTriangle,{className:"w-4 h-4 mt-0.5 flex-shrink-0"}),d.createElement("div",{className:"text-sm"},d.createElement("p",{className:"mb-1"},"group_id was not found in the customer metadata from Chargebee."),d.createElement("ul",{className:"pl-5 space-y-2"},d.createElement("li",{className:"list-disc"},d.createElement("span",{className:"font-medium"},"Option 1:")," Select the correct account identifier from the dropdown above."),d.createElement("li",{className:"list-none text-center text-xs font-semibold uppercase tracking-wide text-amber-700"},"OR"),d.createElement("li",{className:"list-disc"},d.createElement("span",{className:"font-medium"},"Option 2:")," Resolve this by using the AI-assisted or manual steps below to add the missing key in customer metadata of Chargebee.")))))),d.createElement("p",{className:"flex items-center text-sm text-gray-700 mx-2 mb-2"},"If your product telemetry's account identifier key is missing from the dropdown, use the tabs below to resolve this.",d.createElement("button",{type:"button",onClick:function(){return on(!0)},className:"text-blue-600 underline hover:text-blue-800 ml-1"},"See the guide"),"."),d.createElement(be.i,{source:"chargebee",accountIdentifierKey:lt,defaultCollapsed:xt}))),d.createElement("div",{className:"flex items-center gap-3 pt-2"},d.createElement("button",{type:"button",onClick:Is,disabled:qa,className:"px-4 py-2 rounded-md font-medium text-sm transition-colors ".concat(qa?"bg-gray-300 text-gray-500 cursor-not-allowed":"bg-blue-600 hover:bg-blue-700 text-white")},qa?d.createElement("span",{className:"inline-flex items-center gap-2"},d.createElement(y.Loader2,{className:"w-4 h-4 animate-spin"}),"Saving..."):Ba?"Retry Invite and Proceed":"Invite and Proceed"),d.createElement("button",{type:"button",onClick:As,disabled:qa,className:"px-4 py-2 rounded-md font-medium text-sm transition-colors ".concat(qa?"bg-gray-100 text-gray-400 cursor-not-allowed border border-gray-300":"bg-white border border-blue-600 hover:bg-blue-50 text-blue-600")},Ba?"Retry Save and Proceed":"Save and Proceed"),Ba&&d.createElement("p",{className:"text-red-600 text-sm"},Ba))))))))})),It&&ks()&&(!ft||0===ft.length)&&d.createElement("button",{type:"button",onClick:function(){Ce("pause-fix"),setTimeout(function(){var e;null===(e=xn.current)||void 0===e||e.scrollIntoView({behavior:"smooth",block:"center"})},100)},className:"flex px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-md text-sm font-medium mt
1-4 ml-auto"},"Proceed to Next Step")))},po=function(){var e,t=("apiKeyOnly"===yr||"both"===yr||"syncDateOnly"===yr)&&Kn,n=!Pn,a=function(){var e=(0,s.A)(u().mark(function e(){var n,a,r,s,o,l,i,c,m,d,p,g,f,b,y,v,E,N,w,C,k,A,T,D,R,P,O,F,K,j;return u().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,fn(null),t||(Vn(!0),Yn(0),Hn(St),un(null)),"apiKeyOnly"!==yr){e.next=2;break}return e.next=1,bs({variables:{input:{environmentId:M.environmentId,dataSource:se.qSh.Chargebee}}});case 1:return r=e.sent,null!==(a=r.data)&&void 0!==a&&null!==(a=a.triggerSync)&&void 0!==a&&a.isSuccess?(c=(new Date).toISOString(),On(!0),ra("running"),ia(!0),gr(!1),Or(!0),m=(null==x||null===(s=x.chargebee)||void 0===s?void 0:s.ingestionResult)||mn,d=m?_e(_e({},m),{},{syncStatus:"running",syncStartedAt:c}):null,un(d),p=!0===(null===(o=x.chargebee)||void 0===o?void 0:o.step2Completed)||!!(M.sourceName&&M.subdomain&&M.apiKey&&M.syncStartDate),g=_e(_e({},M),{},{step1Completed:!(!M.environmentId||!M.chargebeeEnvironment),step2Completed:p,step3Completed:Tn,step3CompletedAt:(null===(l=x.chargebee)||void 0===l?void 0:l.step3CompletedAt)||c,step4Completed:!0,step4WasEverCompleted:!0,step4CompletedAt:c,isStep3Incomplete:tn,testingSteps:wt,testCompleted:It,schemaVerified:(null===(i=x.chargebee)||void 0===i?void 0:i.schemaVerified)||!1,selectedIdentifierKey:lt,customerMetaDataKeys:ft,groupIdFound:xt,ingestionResult:d,isSetupIncomplete:!1,pendingApiKeyChange:!1,pendingSyncDateChange:!1}),h("chargebee",g),S(g),I()):fn("Failed to trigger resync"),e.abrupt("return");case 2:if("syncDateOnly"!==yr&&"both"!==yr){e.next=4;break}return e.next=3,hs({variables:{input:{environmentId:M.environmentId,sourceType:se.pqc.Chargebee}}});case 3:return b=e.sent,null!==(f=b.data)&&void 0!==f&&null!==(f=f.resetAndResyncAirbyteData)&&void 0!==f&&f.isSuccess?(w=(new Date).toISOString(),On(!0),ra("running"),ia(!0),gr(!1),Or(!0),C=(null==x||null===(y=x.chargebee)||void 0===y?void 0:y.ingestionResult)||mn,k=C?_e(_e({},C),{},{syncStatus:"running",syncStartedAt:w}):null,un(k),A=!0===(null===(v=x.chargebee)||void 0===v?void 0:v.step2Completed)||!!(M.sourceName&&M.subdomain&&M.apiKey&&M.syncStartDate),T=_e(_e({},M),{},{step1Completed:!(!M.environmentId||!M.chargebeeEnvironment),step2Completed:A,step3Completed:Tn,step3CompletedAt:(null===(E=x.chargebee)||void 0===E?void 0:E.step3CompletedAt)||w,step4Completed:!0,step4WasEverCompleted:!0,step4CompletedAt:w,isStep3Incomplete:tn,testingSteps:wt,testCompleted:It,schemaVerified:(null===(N=x.chargebee)||void 0===N?void 0:N.schemaVerified)||!1,selectedIdentifierKey:lt,customerMetaDataKeys:ft,groupIdFound:xt,ingestionResult:k,isSetupIncomplete:!1,pendingApiKeyChange:!1,pendingSyncDateChange:!1}),h("chargebee",T),S(T),I()):fn((null===(D=b.data)||void 0===D||null===(D=D.resetAndResyncAirbyteData)||void 0===D?void 0:D.message)||"Failed to reset and resync"),e.abrupt("return");case 4:if(!q){e.next=6;break}return e.next=5,ie({environmentId:M.environmentId,chargebeeEnvironmentType:M.chargebeeEnvironment,chargebeeSubdomain:M.subdomain,chargebeeApiKey:M.apiKey,syncStartTime:M.syncStartDate instanceof Date?M.syncStartDate.toISOString():(new Date).toISOString()});case 5:n=e.sent,e.next=8;break;case 6:return"live"===M.chargebeeEnvironment?se.bTM.Live:se.bTM.Test,e.next=7,is({variables:{input:{environmentId:M.environmentId,integrationType:se.pqc.Chargebee,syncStartTime:M.syncStartDate instanceof Date?M.syncStartDate.toISOString().split(".")[0]+"Z":(new Date).toISOString().split(".")[0]+"Z",chargebeeConfig:{siteName:M.subdomain||"",apiKey:M.apiKey,productCatalog:M.productCatalog}}}});case 7:P=e.sent,null!==(R=P.data)&&void 0!==R&&R.createAirbyteIntegration&&(n=P.data.createAirbyteIntegration);case 8:if(!n){e.next=9;break}return K=_e(_e({},M),{},{status:"configured",completed:!0,completedAt:(new Date).toISOString(),step3Completed:Tn,step3CompletedAt:Tn&&(null===(O=x.chargebee)||void 0===O?void 0:O.step3CompletedAt)||(new Date).toISOString(),step4Completed:!0,step4WasEverCompleted:!0,step4CompletedAt:(new Date).toISOString(),isStep3Incomplete:tn,testingSteps:wt,testCompleted:It,schemaVerified:(null===(F=x.chargebee)||void 0===F?void 0:F.schemaVerified)||!1,selectedIdentifierKey:lt,customerMetaDataKeys:ft,groupIdFound:xt,ingestionResult:{sourceId:n.sourceId,connectionId:n.connectionId,syncStartedAt:n.syncStartedAt,syncStatus:n.syncStatus,jobId:n.jobId}}),h("chargebee",K),On(!0),null==_||_(),un({sourceId:n.sourceId,connectionId:n.connectionId,syncStartedAt:n.syncStartedAt,syncStatus:n.syncStatus,jobId:n.jobId}),ra("running"),ia(!0),gr(!1),n.syncStartedAt&&Vr(n.syncStartedAt),I(),e.abrupt("return",n.syncStatus);case 9:e.next=11;break;case 10:e.prev=10,j=e.catch(0),console.error("Failed to start Chargebee ingestion:",j),fn(j instanceof Error?j.message:"Unknown error occurred");case 11:case"end":return e.stop()}},e,null,[[0,10]])}));return function(){return e.apply(this,arguments)}}
1(),r=Pn&&!!mn||Pn&&Pr&&("running"===aa||"pending"===aa)||t&&(ys||Es),o=n&&!ys&&!Es;return d.createElement("div",{className:"space-y-6"},r&&d.createElement("div",{className:"rounded-lg p-4 ".concat("succeeded"===aa?"bg-green-50":"failed"===aa?"bg-red-50":"bg-blue-50")},d.createElement("div",{className:"flex items-start space-x-3"},"running"===aa&&d.createElement(y.Loader2,{className:"w-5 h-5 text-blue-600 mt-0.5 flex-shrink-0 animate-spin"}),"succeeded"===aa&&d.createElement(y.CheckCircle,{className:"w-5 h-5 text-green-600 mt-0.5 flex-shrink-0"}),"failed"===aa&&d.createElement(y.AlertTriangle,{className:"w-5 h-5 text-red-600 mt-0.5 flex-shrink-0"}),"pending"===aa&&d.createElement(y.Loader2,{className:"w-5 h-5 text-blue-600 mt-0.5 flex-shrink-0 animate-spin"}),d.createElement("div",{className:"flex-1"},d.createElement("h4",{className:"font-semibold text-xl mb-1 ".concat("succeeded"===aa?"text-green-900":"failed"===aa?"text-red-900":"text-blue-900")},"running"===aa||"pending"===aa?"Processing Ingestion":"succeeded"===aa?"Ingestion Completed Successfully":"failed"===aa?"Ingestion Failed":"Processing Ingestion"),d.createElement("p",{className:"text-sm mb-2 ".concat("succeeded"===aa?"text-green-800":"failed"===aa?"text-red-800":"text-blue-800")},"running"===aa||"pending"===aa?"We're currently syncing your Chargebee data. This process may take a 5-7 minutes. You'll receive an email notification once complete.":"succeeded"===aa?"Your Chargebee data has been successfully synced and is ready for analysis.":"failed"===aa?"There was an error syncing your Chargebee data. Please try again or contact support.":"We're currently syncing your Chargebee data. This process may take a 5-7 minutes. You'll receive an email notification once complete."),d.createElement("div",{className:"text-xs ".concat("succeeded"===aa?"text-green-700":"failed"===aa?"text-red-700":"text-blue-700")},Ur&&d.createElement("div",{className:"flex items-center gap-2 mb-1"},d.createElement("span",{className:"font-medium"},"Last synced:"),d.createElement("span",null,new Date(Ur).toLocaleString("en-US",{weekday:"short",year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"})),la&&d.createElement("div",{className:"w-1.5 h-1.5 bg-blue-500 rounded-full animate-pulse",title:"Checking status every 30 seconds"})),!Ur&&(null==mn?void 0:mn.syncStartedAt)&&d.createElement("div",{className:"flex items-center gap-2 mb-1"},d.createElement("span",{className:"font-medium"},"Sync started at:"),d.createElement("span",null,new Date(mn.syncStartedAt).toLocaleString("en-US",{weekday:"short",year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"})),la&&d.createElement("div",{className:"w-1.5 h-1.5 bg-blue-500 rounded-full animate-pulse",title:"Checking status every 30 seconds"})),d.createElement("div",{className:"mt-1"},d.createElement("span",{className:"font-medium"},"Status:")," ",d.createElement("span",{className:"font-semibold ".concat("succeeded"===aa?"text-green-600":"failed"===aa?"text-red-600":"running"===aa||"pending"===aa?"text-blue-600":"text-gray-600")},"succeeded"===aa?"Completed":"failed"===aa?"Failed":"running"===aa||"pending"===aa?"In Progress":"Pending")),"failed"===aa&&d.createElement("div",{className:"mt-1"},d.createElement("span",{className:"font-medium"},"Status:")," ",d.createElement("span",{className:"text-red-600 font-semibold"},"Failed"))),d.createElement("div",{className:"mt-6"},d.createElement("p",{className:"text-sm text-blue-800 mb-3"},"Notification will be sent to: ",d.createElement("p",{className:"font-semibold"},"".concat(null===(e=(0,H.wz)())||void 0===e?void 0:e.email))),A.state.showInput?d.createElement("div",{className:"space-y-2"},d.createElement("label",{className:"block text-sm text-blue-900"},"Add additional email addresses where youâd like to receive notifications."),d.createElement("div",{className:"relative"},d.createElement("input",{type:"text",value:A.state.inputValue,onChange:function(e){return A.handleInputChange(e.target.value)},onKeyDown:A.handleKeyDown,placeholder:"Enter email and press Enter or comma",className:"w-full px-3 py-2 border rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 text-sm ".concat(A.state.error?"border-red-500":"border-gray-300")}),A.state.error&&d.createElement("p",{className:"text-red-600 text-xs mt-1"},A.state.error)),A.state.emails.length>0&&d.createElement("div",{className:"flex flex-wrap gap-2 mb-2"},A.state.emails.map(function(e,t){return d.createElement("div",{key:t,className:"flex items-center gap-1 px-3 py-1 bg-gray-200 rounded-full text-sm"},d.createElement("span",null,e),d.createElement("button",{type:"button",onClick:function(){return A.removeEmail(e)},className:"hover:bg-blue-200 rounded-full p-0.5 transition-colors"},d.createElement(y.X,{className:"w-3 h-3"})))})),A.state.showUpdateButton&&d.createElement("button",{type:"button",onClick:_s,className:"px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-md text-sm font-medium transition-colors"}
1,"Update Notification Emails")):d.createElement("button",{type:"button",onClick:A.toggleInput,className:"flex items-center gap-2 px-4 py-2 text-sm font-medium text-blue-600 bg-white border border-blue-600 rounded-md hover:bg-blue-50 transition-colors"},d.createElement(y.UserPlus,{className:"w-4 h-4"}),"Add Additional Emails"))))),o&&d.createElement(d.Fragment,null,d.createElement("p",null,"syncDateOnly"===yr||"apiKeyOnly"===yr||"both"===yr?"Start a new sync with modified configurations.":"Start ingestion of your data from Chargebee by starting the data sync. First time syncing of all data will take a while to populate the revenue analytics dashboard."),d.createElement("button",{type:"button",onClick:a,disabled:"apiKeyOnly"===yr?!Tn||ys||ps:"syncDateOnly"===yr||"both"===yr?!Tn||Es||ps:!It||cs,className:"px-6 py-3 rounded-md bg-blue-600 hover:bg-blue-700 text-white font-medium transition-colors disabled:opacity-50 disabled:cursor-not-allowed flex items-center space-x-2"},(cs||ys||Es)&&d.createElement(y.Loader2,{className:"w-4 h-4 animate-spin"}),d.createElement("span",null,!t||"apiKeyOnly"!==yr&&"both"!==yr?t&&"syncDateOnly"===yr?Es?"Starting Resync...":"Resync Chargebee data":cs?"Starting Ingestion...":"Start Ingestion":ys?"Starting Resync...":"Resync Chargebee data")),tn&&d.createElement("p",null,d.createElement("strong",null,"Note:")," You can start Data Ingestion now and see revenue analytics data and fix the schema for data correlation later. ")),gn&&d.createElement("div",{className:"bg-red-50 rounded-lg p-4"},d.createElement("div",{className:"flex items-start space-x-3"},d.createElement(y.AlertTriangle,{className:"w-5 h-5 text-red-600 mt-0.5 flex-shrink-0"}),d.createElement("div",{className:"flex-1"},d.createElement("h4",{className:"text-sm font-semibold text-red-900 mb-1"},"Failed to Start Ingestion"),d.createElement("p",{className:"text-sm text-red-800"},"Something went wrong, Please try again.")))),!t&&d.createElement("div",null,Un?d.createElement("div",{className:"mt-4 space-y-3 border border-gray-200 p-4 rounded-lg"},Wn.map(function(e,t){return d.createElement("div",{key:e.id,className:"flex items-start space-x-3"},d.createElement("div",{className:"flex-shrink-0 mt-1 text-lg"},"loading"===e.status&&d.createElement(y.Loader2,{className:"w-4 h-4 text-blue-600 animate-spin"}),"success"===e.status&&d.createElement(y.CheckCircle,{className:"w-4 h-4 text-green-600"}),"error"===e.status&&d.createElement(y.AlertTriangle,{className:"w-4 h-4 text-red-600"}),"pending"===e.status&&d.createElement("div",{className:"w-4 h-4 rounded-full border-2 border-gray-300"})),d.createElement("div",{className:"flex-1"},d.createElement("div",{className:"font-medium text-gray-900 text-lg"},"loading"===e.status&&e.loadingText,"success"===e.status&&e.successText,"error"===e.status&&e.errorText,"pending"===e.status&&e.loadingText)))})):null),r&&d.createElement("div",{className:"mt-4 ml-6 space-y-4"},d.createElement("div",null,"You can continue to ",d.createElement("strong",null,"Core Revenue Calculation")," to set up currency and other fee-related configurations while the sync completes in background.")))},go=function(e){switch(e.id){case"environment":return d.createElement("div",{className:"space-y-6"},d.createElement("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6"},d.createElement("div",null,d.createElement("label",{className:"block text-sm font-medium text-gray-700 mb-2"},"Chargebee Site"),d.createElement("div",{className:"relative","data-dropdown":"chargebee-environment"},d.createElement("button",{type:"button",onClick:function(){return Ue(!Le)},className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent bg-white text-left flex items-center justify-between"},d.createElement("span",{className:M.chargebeeEnvironment?"text-gray-900 font-semibold":"text-gray-500"},"live"===M.chargebeeEnvironment?"Live":"test"===M.chargebeeEnvironment?"Test":"Select Chargebee Site"),d.createElement(y.ChevronDown,{className:"w-4 h-4 text-gray-400 transition-transform ".concat(Le?"rotate-180":"")})),Le&&d.createElement("div",{className:"absolute z-10 w-full mt-1 bg-white border border-gray-300 rounded-md shadow-lg"},d.createElement("div",{className:"py-1"},d.createElement("button",{type:"button",onClick:function(){Ps("chargebeeEnvironment","live"),Ue(!1)},className:"w-full px-3 py-2 text-left text-sm hover:bg-blue-50 hover:text-blue-900 flex items-center justify-between"},d.createElement("span",null,"Live"),"live"===M.chargebeeEnvironment&&d.createElement(y.CheckCircle,{className:"w-4 h-4 text-blue-600"})),d.createElement("button",{type:"button",onClick:function(){Ps("chargebeeEnvironment","test"),Ue(!1)},className:"w-full px-3 py-2 text-left text-sm hover:bg-blue-50 hover:text-blue-900 flex items-center justify-between"},d.createElement("span",null,"Test"),"test"===M.chargebeeEnvironment&&d.createElement(y.CheckCircle,{className:"w-4 h-4 text-blue-600"})))))),d.createElement("div",null,d.createElement("label",{className:"block text-sm font-medium text-gray-700 mb-2"},"ThriveStack Environment"),d.createElement("div",{className:"w-full px-3 py-2 border border-gray-300 rounded-md bg-gray-100 text-left flex items-center justify-between cursor-not-allowed"},d.createElement("span",{className:"text-gray-900 font-semibold"},M.environmentName?M.environmentName.charAt(0).toUpperCase()+M.environmentName.slice(1).toLowerCase():"Development"),d.createElement(y.ChevronDown,{className:"w-4 h-4 text-gray-400"})),d.createElement("p",{className:"text-xs text-gray-500 mt-1"},"To change this, change the environment from the navigation bar"))),d.createElement("div",{className:"flex justify-end pt-4 border-t border-gray-200"},d.createElement("button",{type:"button",onClick:function(){Xs(),Ce("basic-config"),setTimeout(function(){var e;null===(e=hn.current)||void 0===e||e.scrollIntoView({behavior:"smooth",block:"start"})},100),I()},disabled:!(M.environmentId&&M.chargebeeEnvironment),className:"px-6 py-2 rounded-md font-medium transition-colors ".concat(M.environmentId&&M.chargebeeEnvironment?"bg-blue-600 text-white hover:bg-blue-700":"bg-gray-300 text-gray-500 cursor-not-allowed")},"Next")));case"basic-config":return co();case"revenue-correlation":return uo();case"pause-fix":return po();default:return null}};return d.createElement("div",{className:"bg-white"},d.createElement("div",{className:"container mt-8"},d.createElement("div",{className:""},d.createElement("div",{className:"mx-auto w-full bg-white rounded-lg"},d.createElement("form",{onSubmit:function(e){e.preventDefault()},className:"space-y-8"},d.createElement("div",{className:"relative"},d.createElement("div",{className:"absolute left-5 w-0.5 bg-gray-300",style:function(){if(hn.current&&En.current&&Nn.current){var e=hn.current.getBoundingClientRect().height,t=En.current.getBoundingClientRect().height,n=Nn.current.getBoundingClientRect().height;if("pause-fix"===we)return{top:"4rem",bottom:"".concat(n-10,"px")};if("revenue-correlation"===we)return{top:"4rem",bottom:"".concat(t-10,"px")};if("basic-config"===we)return{top:"4rem",bottom:"".concat(e-10,"px")}}return{top:"4rem",bottom:"4rem"}}()}),d.createElement("div",{className:"bg-white rounded-lg shadow-sm border border-gray-200 relative z-10 ml-10"},Rs.map(function(e,t){return d.createElement("div",{key:e.id,ref:"basic-config"===e.id?hn:"revenue-correlation"===e.id?En:"pause
1-fix"===e.id?Nn:null,className:"border-b border-gray-200 last:border-b-0 transition-all duration-300 ease-in-out ".concat(e.isActive?"bg-blue-50":"")},(a=Tn,r=("revenue-correlation"===e.id||"pause-fix"===e.id)&&(!Fa||Er),s=Kr&&"pause-fix"===e.id&&!a,o=r||s,d.createElement("div",{className:"relative ".concat(o?"group":"")},d.createElement("button",{type:"button",onClick:function(){if(!o){Ie(!0);var t=e.isActive?"":e.id;t&&(Sn.current=t),Ce(t)}},"aria-disabled":o,className:"w-full flex items-center justify-between p-4 text-left transition-colors ".concat(o?"cursor-not-allowed opacity-70":"hover:bg-gray-50")},d.createElement("div",{className:"flex items-center gap-4 flex-1"},d.createElement("div",{ref:"environment"===e.id?bn:"basic-config"===e.id?yn:"revenue-correlation"===e.id?vn:xn,className:"absolute -left-10 w-8 h-8 flex items-center justify-center rounded-full font-semibold text-sm z-10 border-2 transition-all duration-300 ".concat(e.isCompleted?"border-green-500":e.isActive?"bg-blue-500 text-white border-blue-500":"bg-gray-100 text-gray-600 border-gray-300"),style:e.isCompleted?{backgroundColor:"rgb(34, 197, 94)",color:"rgb(255, 255, 255)"}:{}},e.number),d.createElement("div",{className:"flex-1"},d.createElement("div",{className:"flex items-center justify-between gap-4"},d.createElement("div",{className:"flex items-center gap-2"},d.createElement("div",{className:"font-semibold text-gray-900 text-lg"},e.title),e.required&&!tn&&d.createElement("span",{className:"text-red-800 text-lg"},"*")),"environment"===e.id&&e.isCompleted&&d.createElement("div",{className:"flex items-center ml-10"},(n=It,M.environmentId&&M.chargebeeEnvironment?d.createElement("div",{className:"flex items-center justify-center space-x-3 py-3"},d.createElement("div",{className:"flex flex-col items-center space-y-1 group relative"},d.createElement("div",{className:"text-[10px] font-semibold text-gray-400 uppercase tracking-wide"},"Your Chargebee"),d.createElement("div",{className:"flex items-center space-x-2 cursor-help"},d.createElement("div",{className:"w-6 h-6 rounded-full border-2 border-blue-600 flex items-center justify-center bg-white"},d.createElement("img",{src:w,alt:"Chargebee",className:"w-3 h-3",style:{objectFit:"contain"}})),d.createElement("div",{className:"text-xs font-semibold text-gray-700"},M.chargebeeEnvironment.charAt(0).toUpperCase()+M.chargebeeEnvironment.slice(1).toLowerCase())),d.createElement("div",{className:"absolute bottom-full mb-2 left-1/2 -translate-x-1/2 px-3 py-1.5 bg-gray-900 text-white text-xs rounded shadow-lg whitespace-nowrap opacity-0 group-hover:opacity-100 transition-opacity pointer-events-none z-10"},"Your Chargebee Site: ",M.chargebeeEnvironment.charAt(0).toUpperCase()+M.chargebeeEnvironment.slice(1).toLowerCase(),d.createElement("div",{className:"absolute top-full left-1/2 -translate-x-1/2 border-4 border-transparent border-t-gray-900"}))),d.createElement("div",{className:"flex items-center space-x-1 pt-4"},d.createElement("div",{className:"w-6 h-0.5 bg-blue-600"}),d.createElement("div",{className:"w-6 h-6 bg-transparent rounded-full flex items-center justify-center border-2",style:{borderColor:n?"#16a34a":"#eab308"}},n?d.createElement("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"#16a34a",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round"},d.createElement("polyline",{points:"20 6 9 17 4 12"})):d.createElement("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"#eab308",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round"},d.createElement("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),d.createElement("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"}))),d.createElement("svg",{className:"w-8 h-3",viewBox:"0 0 32 12",fill:"none"},d.createElement("path",{d:"M0 6 L26 6",stroke:"#2563eb",strokeWidth:"2"}),d.createElement("path",{d:"M22 2 L30 6 L22 10",stroke:"#2563eb",strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"}))),d.createElement("div",{className:"flex flex-col items-center space-y-1 group relative"},d.createElement("div",{className:"text-[10px] font-semibold text-gray-400 uppercase tracking-wide"},lo||"Product"),d.createElement("div",{className:"flex items-center space-x-2 cursor-help"},d.createElement("div",{className:"w-6 h-6 rounded-full flex items-center justify-center border-2 border-blue-600 bg-white"},d.createElement("span",{className:"text-blue-600 text-[9px] font-bold"},io)),d.createElement("div",{className:"text-xs font-semibold text-gray-700 max-w-20 truncate"},M.environmentName.charAt(0).toUpperCase()+M.environmentName.slice(1).toLowerCase())),d.createElement("div",{className:"absolute bottom-full mb-2 left-1/2 -translate-x-1/2 px-3 py-1.5 bg-gray-900 text-white text-xs rounded shadow-lg whitespace-nowrap opacity-0 group-hover:opacity-100 transition-opacity pointer-events-none z-10"},"Your Chargebee data is syncing to your ",M.environmentName.charAt(0).toUpperCase()+M.environmentName.slice(1).toLowerCase()," ",d.createElement("br",null),' environment within ThriveStack for "',lo,'". Status: ',n?"Successful":"Pending",d.createElement("div",{className:"absolute top-full left-1/2 -translate-x-1/2 border-4 border-transparent border-t-gray-900"})))):null)),d.createElement("div",{className:"flex items-center gap-4"},e.isCompleted&&d.createElement("div",{className:"px-3 py-1 rounded-full text-xs font-medium bg-green-100 text-green-700"},"Completed"),"revenue-correlation"===e.id&&tn&&d.createElement("div",{className:"inline-flex items-center gap-1 px-2 py-1 rounded-full text-xs font-medium bg-red-100 text-red-700 h-5"},d.createElement(y.AlertTriangle,{className:"w-3 h-3"}),d.createElement("span",null,"Action Required")))),d.createElement("div",{className:"text-sm text-gray-500"},"environment"===e.id?e.subtitle:e.description))),d.createElement(y.ChevronDown,{className:"w-4 h-4 text-gray-400 transition-transform duration-300 ml-2 ".concat(e.isActive?"rotate-180":"")})),o&&d.createElement("div",{className:"absolute bottom-full left-1/2 -translate-x-1/2 mb-2 px-3 py-2 bg-gray-900 text-white text-xs rounded-lg opacity-0 group-hover:opacity-100 transition-opacity duration-200 pointer-events-none whitespace-nowrap z-20"},s?"Complete Step 3 to proceed.":"Complete Basic Configurations Step.",d.createElement("div",{className:"absolute top-full left-1/2 -translate-x-1/2 w-0 h-0 border-l-4 border-r-4 border-t-4 border-transparent border-t-gray-900"})))),e.isActive&&d.createElement("div",{className:"border-t border-gray-200 p-6 bg-white transition-all duration-300 ease-in-out"},go(e)));var n,a,r,s,o}))))))),G&&d.createElement("div",{className:"fixed inset-0 z-50 overflow-hidden"},d.createElement("div",{className:"absolute inset-0 bg-black bg-opacity-50",onClick:function(){return Y(!1)}}),d.createElement("div",{className:"absolute right-0 top-0 h-full w-[600px] bg-white shadow-xl overflow-y-auto"},d.createElement("div",{className:"p-4 border-b border-gray-200"},d.createElement("div",{className:"flex items-center justify-between"},d.createElement("h2",{className:"text-xl font-semibold"},"Setup Guide: Chargebee"),d.createElement("button",{onClick:function(){return Y(!1)},className:"text-gray-400 hover:text-gray-600 transition-colors"},d.createElement(y.X,{className:"w-5 h-5"})))),d.createElement("div",{className:"p-6"},d.createElement(Te.O,{step3Ref:rt,setExpanded:ea,expanded:$n})))),d.createElement(ne,{open:pe,onOpenChange:ge,onProceed:function(){oe("proceed"),Dn(!0),nn(!0),Ce("pause-fix")}}),Xt&&d.createElement(re.O,{isOpen:Xt,onClose:function(){return Qt(!1)},team:Gt,onInvite:function(){},source:"chargebee"===N?N:void 0}),d.createElement(be.S,{isOpen:sn,onClose:function(){return on(!1)},onInviteTeam:Qs,source:"chargebee",accountIdentifierKey:lt}),Je&&d.createElement("div",{className:"fixed inset-0 bg-gray-600 bg-opacity-50 flex items-center justify-center z-20"},d.createElement("div",{className:"bg-white rounded-lg shadow-xl max-w-md w-full mx-4"},d.createElement("div",{className:"flex items-center justify-between p-6 border-b border-gray-200"},d.createElement("h3",{className:"text-lg font-semibold text-gray-900"},"Create New Environment"),d.createElement("button",{onClick:Ms,className:"text-gray-400 hover:text-gray-600 transition-colors"},d.createElement(y.X,{className:"w-5 h-5"}))),d.createElement("div",{className:"p-6 space-y-4"},d.createElement("div",null,d.createElement("label",{className:"block text-sm font-medium text-gray-700 mb-1"},"Environment Name ",d.createElement("span",{className:"text-red-500"},"*")),d.createElement("input",{type:"text",value:Qe.displayName,onChange:function(e){return $e(function(t){return _e(_e({},t),{},{displayName:e.target.value})})},className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent",placeholder:"Enter environment name"})),d.createElement("div",null,d.createElement("label",{className:"block text-sm font-medium text-gray-700 mb-1"},"Environment Type ",d.createElement("span",{className:"text-red-500"}
1,"*")),d.createElement("select",{value:Qe.environmentType,onChange:function(e){return $e(function(t){return _e(_e({},t),{},{environmentType:e.target.value})})},className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent"},d.createElement("option",{value:J.OX.Production},"Production"),d.createElement("option",{value:J.OX.NonProduction},"NonProduction")))),d.createElement("div",{className:"flex items-center justify-end space-x-3 p-6 border-t border-gray-200"},d.createElement("button",{onClick:Ms,className:"px-4 py-2 text-sm font-medium text-blue-600 bg-white border border-blue-600 rounded-md hover:bg-blue-50 transition-colors"},"Cancel"),d.createElement("button",{onClick:Os,disabled:!Qe.displayName||ts,className:"px-4 py-2 text-sm font-medium text-white bg-blue-600 rounded-md hover:bg-blue-700 disabled:bg-gray-300 disabled:cursor-not-allowed transition-colors flex items-center space-x-2"},ts&&d.createElement("div",{className:"w-4 h-4 border-2 border-white border-t-transparent rounded-full animate-spin"}),d.createElement("span",null,ts?"Creating...":"Create Environment"))))))},qe=n(34864);function Le(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,a)}return n}function Ue(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Le(Object(n),!0).forEach(function(t){(0,i.A)(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Le(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var Ve={day:[1,7,14,21],week:[1,2,4],month:[1,3,6],year:[1]},Be="QB_OAUTH_CALLBACK",ze=function(){var e=new Date;return e.setMonth(e.getMonth()-12),e.toISOString().slice(0,10)},We={"1m":"1 Month","3m":"3 Months","6m":"6 Months","12m":"12 Months"},He={sourceName:"QuickBooks",startDate:ze(),realmId:"",companyName:""},Ge=function(e){var t=e.text;return d.createElement("div",{className:"flex items-center gap-1 mb-1.5"},d.createElement("span",{className:"text-sm font-medium text-gray-700"},t),d.createElement(y.Info,{className:"w-3.5 h-3.5 text-gray-400"}))},Je=[{id:"environment",num:1,title:"Map Environments",description:"Select the QuickBooks environment to connect with your App environment"},{id:"basic",num:2,title:"Connect QuickBooks",description:"Authorize ThriveStack to access your QuickBooks data via OAuth"},{id:"test",num:3,title:"Test Connection",description:"Verify your QuickBooks connection before starting data ingestion"},{id:"ingestion",num:4,title:"Start Ingestion",description:"Trigger the data sync from your QuickBooks account to ThriveStack"}],Ze=[{name:"Implementation Services",type:"Service",price:"$150"},{name:"Technical Support",type:"Service",price:"$100"},{name:"Onboarding & Training",type:"Service",price:"$120"},{name:"Professional Plan License",type:"NonInventory",price:"$49"},{name:"Enterprise Plan License",type:"NonInventory",price:"$199"},{name:"API Access Add-on",type:"NonInventory",price:"$29"}],Ye=function(e){var t,n,a,r,o,m,p,g,f,b,v,x,h,E,w=e.sourceConfigurations,C=e.updateSourceConfiguration,S=e.onStepComplete,A=e.emailManager,I=e.onAutoSave,T=e.cleanOAuthParams,D=e.openSetupGuideRef,R=e.onTrackCompletion,_=(0,F._K)().isDemoMode,P=(null==w?void 0:w.quickbooks)||{},O=(0,d.useRef)(!1),M=(0,d.useState)(!1),K=(0,c.A)(M,2),j=K[0],q=K[1];(0,d.useEffect)(function(){if(D)return D.current=function(){return q(!0)},function(){D&&(D.current=null)}},[D]);var L=null!==(t=null===(n=(0,H.wz)())||void 0===n?void 0:n.email)&&void 0!==t?t:"",U=function(){var e=A.state.emails.filter(function(e){return e!==L});return L?[L].concat((0,l.A)(e)):e},V=(null!==(a=P.notificationEmails)&&void 0!==a?a:[]).filter(function(e){return e!==L}),B=(0,d.useRef)(V),z=(0,d.useRef)(!1);(0,d.useEffect)(function(){V.length&&A.setEmails(V),z.current=!0},[]),(0,d.useEffect)(function(){if(z.current){var e=A.state.emails,t=B.current;e.length===t.length&&e.every(function(e,n){return e===t[n]})||(B.current=e,Oa({notificationEmails:U()}))}},[A.state.emails]);var W=_?ce:null!==(r=(0,H.nN)())&&void 0!==r?r:"",G=_?me:null!==(o=(0,H.bb)())&&void 0!==o?o:"Production",J=(_?"PRODUCTION"===de||"production"===(null===(m=ue)||void 0===m?void 0:m.toLowerCase()):G.toLowerCase().includes("prod"))?"Production":"Sandbox",Y=(0,d.useState)(!!P.step1Completed),X=(0,c.A)(Y,2),Q=X[0],$=X[1],ee=(0,d.useState)(!!P.step2Completed),te=(0,
1c.A)(ee,2),ne=te[0],ae=te[1],oe=(0,d.useState)(!!P.step3Completed),le=(0,c.A)(oe,2),pe=le[0],ge=le[1],fe=(0,d.useState)(!!P.pauseFixCompleted),ye=(0,c.A)(fe,2),ve=ye[0],xe=ye[1],he=(0,d.useState)(!1),Ee=(0,c.A)(he,2),Ne=Ee[0],we=Ee[1],Ce=(0,d.useState)(!1),Se=(0,c.A)(Ce,2),ke=Se[0],Ae=Se[1],Ie=(0,d.useState)(!!P.itemsStepCompleted),Te=(0,c.A)(Ie,2),Re=Te[0],_e=Te[1],Pe=(0,d.useState)(!!P.plansStepCompleted),Oe=(0,c.A)(Pe,2),Me=Oe[0],Fe=Oe[1],Ke=(0,d.useState)(!!P.professionalStepCompleted),je=(0,c.A)(Ke,2),Le=je[0],Ye=je[1],Xe=(0,d.useState)(!!P.cancellationsStepCompleted),Qe=(0,c.A)(Xe,2),$e=Qe[0],et=Qe[1],tt=(0,d.useState)(P.cancellationPolicy||"auto"),nt=(0,c.A)(tt,2),at=nt[0],rt=nt[1],st=(0,d.useState)(null!==(p=P.unpaidInvoiceDays)&&void 0!==p?p:45),ot=(0,c.A)(st,2),lt=ot[0],it=ot[1],ct=(0,d.useState)(null!==(g=P.noRenewalDays)&&void 0!==g?g:45),mt=(0,c.A)(ct,2),ut=mt[0],dt=mt[1],pt=(0,d.useState)(P.mrrItemsTerm?Ue({},P.mrrItemsTerm):{}),gt=(0,c.A)(pt,2),ft=gt[0],bt=gt[1],yt=(0,d.useState)(!!P.step4Completed),vt=(0,c.A)(yt,2),xt=vt[0],ht=vt[1],Et=(0,d.useState)(new Set(P.mrrItems||[])),Nt=(0,c.A)(Et,2),wt=Nt[0],Ct=Nt[1],St=(0,d.useState)(""),kt=(0,c.A)(St,2),At=kt[0],It=kt[1],Tt=(0,d.useState)(new Set(P.oneTimeItems||[])),Dt=(0,c.A)(Tt,2),Rt=Dt[0],_t=Dt[1],Pt=(0,d.useState)(""),Ot=(0,c.A)(Pt,2),Mt=Ot[0],Ft=Ot[1],Kt=(0,d.useState)(P.datePeriod||""),jt=(0,c.A)(Kt,2),qt=jt[0],Lt=jt[1],Ut=(0,De.t5)({client:Z.Ju,variables:{input:{accessToken:P.accessToken||"",realmId:P.realmId||"",sandbox:P.sandbox||!1}},skip:_||!P.accessToken||!P.realmId}),Vt=Ut.data,Bt=Ut.loading,zt=Ut.error,Wt=[].concat((0,l.A)(Je.slice(0,3)),[{id:"pause-fix",num:4,title:"Fix Schema Issue",description:"Add the group_id custom field to your QuickBooks customers to enable account-level correlation"},{id:"recurring",num:5,title:"Select products that contribute to Recurring Revenue",description:"Products/services tied to subscriptions. These will power metrics like MRR, ARR, ACV, Contraction, Expansion etc."},{id:"plans",num:6,title:"Define Billing Terms",description:"Set the billing term and frequency for each product that contributes to your recurring revenue."},{id:"professional",num:7,title:"Select Services that Contribute to Non-Recurring Revenue",description:"Products/Services that are one-time, project-based, professional services, onboarding or ad-hoc services that generate revenue outside subscriptions"},{id:"cancellations",num:8,title:"Subscription Cancellations",description:"Define how QuickBooks subscriptions should be cancelled when invoices go unpaid or renewals stop"},{id:"ingestion",num:9,title:"Start Ingestion",description:"Trigger the data sync from your QuickBooks account to ThriveStack"}]),Ht=(0,d.useState)(P.step4Completed||P.cancellationsStepCompleted?"ingestion":P.professionalStepCompleted?"cancellations":P.plansStepCompleted?"professional":P.itemsStepCompleted?"plans":P.pauseFixCompleted?"recurring":P.step3Completed?"pause-fix":P.step2Completed?"test":P.step1Completed?"basic":"environment"),Gt=(0,c.A)(Ht,2),Jt=Gt[0],Zt=Gt[1],Yt=(0,d.useState)(P.quickbooksEnvironment||J),Xt=(0,c.A)(Yt,2),Qt=Xt[0],$t=Xt[1],en=(0,d.useState)(!1),tn=(0,c.A)(en,2),nn=tn[0],an=tn[1],rn=(0,d.useState)(Ue(Ue({},He),{},{sourceName:P.sourceName||He.sourceName,startDate:P.startDate||He.startDate,realmId:P.realmId||"",companyName:P.companyName||""})),sn=(0,c.A)(rn,2),on=sn[0],ln=sn[1],cn=(0,d.useState)(!1),mn=(0,c.A)(cn,2),un=mn[0],dn=mn[1],pn=(0,d.useState)(null),gn=(0,c.A)(pn,2),fn=gn[0],bn=gn[1],yn=(0,d.useState)(!1),vn=(0,c.A)(yn,2),xn=vn[0],hn=vn[1],En=(0,d.useState)({clientId:"",clientSecret:"",accessToken:"",refreshToken:"",realmId:"",companyName:""}),Nn=(0,c.A)(En,2),wn=Nn[0],Cn=Nn[1],Sn=(0,d.useState)(!1),kn=(0,c.A)(Sn,2),An=kn[0],In=kn[1],Tn=(0,d.useState)(0),Dn=(0,c.A)(Tn,2),Rn=Dn[0],_n=Dn[1],Pn=(0,d.useState)(0),On=(0,c.A)(Pn,2),Mn=On[0],Fn=On[1],Kn=(0,d.useRef)(null),jn=(0,d.useState)(P.ingestionResult||null),qn=(0,c.A)(jn,2),Ln=qn[0],Un=qn[1],Vn=(0,d.useState)([{id:"connection",title:"Connection",loadingText:"Establishing Connection",successText:"Connected",errorText:"Connection Failed",status:"pending"},{id:"data",title:"Data Retrieval",loadingText:"Retrieving Data",successText:"Data Retrieved",errorText:"Failed to Retrieve Data",status:"pending"},{id:"schema",title:"Schema Verification",loadingText:"Verifying Schema",successText:"Schema Verified",errorText:"Schema Error Detected",status:"pending"}]),Bn=(0,c.A)(Vn,2),zn=Bn[0],Wn=Bn[1],Hn=(0,d.useState)(!1),Gn=(0,c.A)(Hn,2),Jn=Gn[0],Zn=Gn[1],Yn=(0,d.useState)(!!P.testCompleted),Xn=(0,c.A)(Yn,2),Qn=Xn[0],$n=Xn[1],ea=(0,d.useState)(null!==(f=P.groupIdFound)&&void 0!==f&&f),ta=(0,c.A)(ea,2),na=ta[0],aa=ta[1],ra=(0,d.useState)(P.customerMetaDataKeys||[]),sa=(0,c.A)(ra,2),oa=sa[0],la=sa[1],ia=(0,d.useState)(!1),ca=(0,c.A)(ia,2),ma=ca[0],ua=ca[1],da=!(null===(b=P.fieldMapping)||void 0===b||!b.confirmed),pa=(0,d.useState)(da&&null!==(v=null===(x=P.fieldMapping)||void 0===x?void 0:x.productField)&&void 0!==v?v:null),ga=(0,c.A)(pa,2),fa=ga[0],ba=ga[1],ya=(0,d.useState)(da&&null!==(h=null===(E=P.fieldMapping)||void 0===E?void 0:E.qbField)&&void 0!==h?h:null),va=(0,c.A)(ya,2),xa=va[0],ha=va[1],Ea=(0,d.useState)(da),Na=(0,c.A)(Ea,2),wa=Na[0],Ca=Na[1],Sa=(0,se.B3y)({client:Z.k3,fetchPolicy:"no-cache"}),ka=(0,c.A)(Sa,2),Aa=ka[0],Ia=ka[1].loading,Ta=(0,De.vS)({client:Z.Ju,fetchPolicy:"no-cache"}),Da=(0,c.A)(Ta,1)[0],Ra=(0,De.LG)({client:Z.Ju,fetchPolicy:"no-cache"}),_a=(0,c.A)(Ra,1)[0],Pa=function(e,t){return ln(function(n){return Ue(Ue({},n),{},(0,i.A)({},e,t))})},Oa=function(e){C("quickbooks",e),I()},Ma="w-full px-3 py-2.5 border border-gray-300 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent bg-white",Fa="qb_oauth_session",Ka=function(){var e=(0,s.A)(u().mark(function e(t,n,a){var r,s,o,l,i,c,m,d,p,g;return u().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(r=(0,H.MW)(),s={},r){try{s=JSON.parse(r)}catch(e){}(0,H.WW)()}if(o=a.environment||"Production",$t(o),ln(function(e){return Ue(Ue(Ue({},e),s),{},{realmId:n||e.realmId})}),l={oauthCode:t},_){e.next=5;break}return e.prev=1,e.next=2,_a({variables:{input:{realmId:n||"",code:t,sandbox:"Sandbox"===o}}});case 2:if(c=e.sent,m=null===(i=c.data)||void 0===i?void 0:i.getQuickbooksCredentials){e.next=3;break}return bn("Cannot make connection, Please try again."),dn(!1),e.abrupt("return");case 3:d=new Date(1e3*m.tokenExpiry).toISOString().split(".")[0]+"Z",l=Ue(Ue({},l),{},{clientId:m.clientId,clientSecret:m.clientSecret,accessToken:m.accessToken,refreshToken:m.refreshToken,tokenExpiryDate:d}),e.next=5;break;case 4:return e.prev=4,g=e.catch(1),console.error("Failed to fetch QuickBooks credentials",g),bn("Cannot make connection, Please try again."),dn(!1),e.abrupt("return");case 5:p=Ue({step2Completed:!0,realmId:n||"",companyName:s.companyName||"",sourceName:s.sourceName||"QuickBooks",startDate:s.startDate||ze(),quickbooksEnvironment:o,sandbox:"Sandbox"===o},l),ae(!0),Oa(p),sessionStorage.setItem(Fa,"1"),dn(!1),Zt("test");case 6:case"end":return e.stop()}},e,null,[[1,4]])}));return function(t,n,a){return e.apply(this,arguments)}}();(0,d.useEffect)(function(){if(!O.current){var e=new URLSearchParams(window.location.search),t=e.get("code"),n=e.get("state"),a=e.get("realmId");if(t){var r={};try{r=n?JSON.parse(decodeURIComponent(n)):{}}catch(e){}if("quickbooks"===r.source){if(O.current=!0,window.opener)return window.opener.postMessage({type:Be,code:t,realmId:a||"",state:r},window.location.origin),void window.close();dn(!0),Ka(t,a||"",r),T()}}}},[]),(0,d.useEffect)(function(){var e=function(e){var t;e.origin===window.location.origin&&(null===(t=e.data)||void 0===t?void 0:t.type)===Be&&(O.current||(O.current=!0,dn(!0),Ka(e.data.code,e.data.realmId,e.data.state||{})))};return window.addEventListener("message",e),function(){return window.removeEventListener("message",e)}},[]),(0,d.useEffect)(function(){_||P.step2Completed&&P.accessToken&&!sessionStorage.getItem(Fa)&&(C("quickbooks",{step2Completed:!1,accessToken:"",refreshToken:"",clientId:"",clientSecret:"",tokenExpiryDate:"",oauthCode:""}),ae(!1),ln(function(e){return Ue(Ue({},e),{},{realmId:""})}),Zt("basic"))},[]);var ja=function(){var e=(0,s.A)(u().mark(function e(){var t,n;return u().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return dn(!0),bn(null),e.next=1,new Promise(function(e){return setTimeout(e,1500)});case 1:t="1234567890",ln(function(e){return Ue(Ue({},e),{},{realmId:t,companyName:"Acme Corp (Demo)"})}),n={step2Completed:!0,realmId:t,companyName:"Acme Corp (Demo)",sourceName:on.sourceName,startDate:on.startDate,datePeriod:qt,quickbooksEnvironment:Qt,sandbox:"Sandbox"===Qt},ae(!0),Oa(n),dn(!1),Zt("test");case 2:case"end":return e.stop()}},e)}));return function(){return e.apply(this,arguments)}}(),qa=function(){var e={step1Completed:!0,environmentId:W,quickbooksEnvironment:Qt,sandbox:"Sandbox"===Qt};$(!0),Oa(e),Zt("basic")},La=function(){(0,H.Us)(JSON.stringify(on));var e=window.location.origin+window.location.pathname,t={step:2,substep:2,source:"quickbooks",environment:Qt},n=new URLSearchParams({response_type:"code",client_id:"Production"===Qt?"AB8ulyB33fW5klZAPBUZxX94nJYl69qgeWzSFQoPbkXeY78TfE":"ABS2XjVdQ99IvuGx7SIF0iQ6lAmKLi2okjZjcqU9V1JClCL8Li",scope:"com.intuit.quickbooks.accounting",redirect_uri:e,state:JSON.stringify(t)});window.open("".concat("https://appcenter.intuit.com/connect/oauth2","?").concat(n.toString()),"_blank","noopener")}
1,Ua=function(){var e=wn.clientId,t=wn.clientSecret,n=wn.accessToken,a=wn.refreshToken,r=wn.realmId,s=wn.companyName;if(n&&r){var o={step2Completed:!0,realmId:r,companyName:s,sourceName:on.sourceName,startDate:on.startDate,datePeriod:qt,quickbooksEnvironment:Qt,sandbox:"Sandbox"===Qt,clientId:e,clientSecret:t,accessToken:n,refreshToken:a,tokenExpiryDate:"",oauthCode:""};ln(function(e){return Ue(Ue({},e),{},{realmId:r,companyName:s})}),ae(!0),Oa(o),sessionStorage.setItem(Fa,"1"),Zt("test")}},Va=function(){ae(!1),ln(function(e){return Ue(Ue({},e),{},{realmId:"",companyName:""})}),Oa({step2Completed:!1,realmId:"",companyName:""})},Ba=function(){var e=(0,s.A)(u().mark(function e(){var t,n,a,r,s,o,i,c,m,d,p,g,f,b,y,v,x,h,E,N,w;return u().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return Zn(!0),$n(!1),t=zn.map(function(e){return Ue(Ue({},e),{},{status:"pending",errorMessage:void 0})}),Wn(t),n=t.map(function(e){return Ue({},e)}),e.prev=1,n[0]=Ue(Ue({},n[0]),{},{status:"loading"}),Wn((0,l.A)(n)),e.next=2,new Promise(function(e){return setTimeout(e,400)});case 2:if(s=null,!_){e.next=4;break}return e.next=3,new Promise(function(e){return setTimeout(e,800)});case 3:s={connectionValid:!0,groupIdFound:!0,customerMetaDataKeys:["account_id","company_id"],details:JSON.stringify({accessibleEntities:["customers","invoices","payments","items","credit_memos"],missingEntities:[]}),errorMessage:null},e.next=6;break;case 4:return e.next=5,Da({variables:{input:{integrationType:"QUICKBOOKS",properties:{accessToken:P.accessToken||"",refreshToken:P.refreshToken||"",clientId:P.clientId||"",clientSecret:P.clientSecret||"",realmId:P.realmId||"",tokenExpiryDate:P.tokenExpiryDate||"",sandbox:null!==(o=P.sandbox)&&void 0!==o&&o,environmentId:W}}}});case 5:m=e.sent,s=null!==(i=null===(c=m.data)||void 0===c?void 0:c.testBillingConnection)&&void 0!==i?i:null;case 6:if(null!==(a=s)&&void 0!==a&&a.connectionValid){e.next=7;break}return n[0]=Ue(Ue({},n[0]),{},{status:"error",errorMessage:(null===(d=s)||void 0===d?void 0:d.errorMessage)||"Could not establish connection.",details:(null===(p=s)||void 0===p?void 0:p.details)||void 0}),Wn((0,l.A)(n)),Zn(!1),$n(!0),Oa({testCompleted:!0,step3Completed:!1}),e.abrupt("return");case 7:return n[0]=Ue(Ue({},n[0]),{},{status:"success"}),Wn((0,l.A)(n)),e.next=8,new Promise(function(e){return setTimeout(e,500)});case 8:return n[1]=Ue(Ue({},n[1]),{},{status:"loading"}),Wn((0,l.A)(n)),setTimeout(function(){return ua(!0)},300),e.next=9,new Promise(function(e){return setTimeout(e,700)});case 9:g=[],f=[];try{v=JSON.parse(s.details||"{}"),g=null!==(b=v.accessibleEntities)&&void 0!==b?b:[],f=null!==(y=v.missingEntities)&&void 0!==y?y:[]}catch(e){}return x=f.length>0,n[1]=Ue(Ue({},n[1]),{},{status:x?"error":"success",accessibleEntities:g,missingEntities:f}),Wn((0,l.A)(n)),e.next=10,new Promise(function(e){return setTimeout(e,500)});case 10:return x&&setTimeout(function(){return ua(!1)},1200),n[2]=Ue(Ue({},n[2]),{},{status:"loading"}),Wn((0,l.A)(n)),e.next=11,new Promise(function(e){return setTimeout(e,600)});case 11:h=null!==(r=s.customerMetaDataKeys)&&void 0!==r?r:[],E=h.length>0,N=E?"success":"error",n[2]=Ue(Ue({},n[2]),{},{status:N}),Wn((0,l.A)(n)),aa(s.groupIdFound),la(h),ge(!0),$n(!0),E&&s.groupIdFound?(xe(!0),Oa({step3Completed:!0,testCompleted:!0,groupIdFound:s.groupIdFound,customerMetaDataKeys:h,pauseFixCompleted:!0}),Zt("recurring")):(Oa({step3Completed:!0,testCompleted:!0,groupIdFound:s.groupIdFound,customerMetaDataKeys:h,pauseFixCompleted:!1}),Zt("pause-fix")),e.next=13;break;case 12:e.prev=12,w=e.catch(1),console.error("QuickBooks test failed",w),n=n.map(function(e){return"loading"===e.status?Ue(Ue({},e),{},{status:"error"}):e}),Wn((0,l.A)(n)),$n(!0),Oa({testCompleted:!0,step3Completed:!1});case 13:return e.prev=13,Zn(!1),e.finish(13);case 14:case"end":return e.stop()}},e,null,[[1,12,13,14]])}));return function(){return e.apply(this,arguments)}}(),za=function(){var e=(0,s.A)(u().mark(function e(){var t,n,a,r,s,o,l,i,c,m;return u().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(In(!0),e.prev=1,t=null,!_){e.next=3;break}return e.next=2,ie({});case 2:a=e.sent,t={syncStartedAt:null!==(n=null==a?void 0:a.syncStartedAt)&&void 0!==n?n:(new Date).toISOString()},e.next=5;break;case 3:return e.next=4,Aa({variables:{input:{environmentId:W,integrationType:"QUICKBOOKS",syncStartTime:P.startDate?new Date(P.startDate).toISOString().split(".")[0]+"Z":(new Date).toISOString().split(".")[0]+"Z",quickbooksConfig:{realmId:P.realmId||"",clientId:P.clientId||"",clientSecret:P.clientSecret||"",accessToken:P.accessToken||"",refreshToken:P.refreshToken||"",tokenExpiryDate:P.tokenExpiryDate||(new Date).toISOString().split(".")[0]+"Z",sandbox:null!==(r=P.sandbox)&&void 0!==r&&r}}}});case 4:o=e.sent,null!==(s=o.data)&&void 0!==s&&s.createAirbyteIntegration&&(i=o.data.createAirbyteIntegration,t={syncStartedAt:null!==(l=i.syncStartedAt)&&void 0!==l?l:(new Date).toISOString()});case 5:t&&(Un(t),ht(!0),c=(new Date).toISOString(),Oa({step4Completed:!0,ingestionResult:t,completedAt:c,status:"configured",completed:!0,notificationEmails:U()}),null==R||R(),S(!0)),e.next=7;break;case 6:e.prev=6,m=e.catch(1),console.error("QuickBooks sync failed",m);case 7:return e.prev=7,In(!1),e.finish(7);case 8:case"end":return e.stop()}},e,null,[[1,6,7,8]])}
1));return function(){return e.apply(this,arguments)}}();(0,d.useEffect)(function(){xt&&I()},[xt]),(0,d.useEffect)(function(){if(An){_n(0),Fn(0);var e=Date.now();Kn.current=setInterval(function(){var t=(Date.now()-e)/1e3;Fn(t),_n(t<5?t/5*35:t<15?35+(t-5)/10*45:function(e){return Math.min(93,e+.05)})},100)}else Kn.current&&clearInterval(Kn.current),xt&&_n(100);return function(){Kn.current&&clearInterval(Kn.current)}},[An]);var Wa=function(){return d.createElement("div",{className:"pb-2 space-y-4"},!ne&&d.createElement(d.Fragment,null,d.createElement("div",null,d.createElement(Ge,{text:"Source name"}),d.createElement("input",{type:"text",value:on.sourceName,onChange:function(e){return Pa("sourceName",e.target.value)},className:Ma})),d.createElement("div",null,d.createElement(Ge,{text:"Start Date"}),d.createElement("div",{className:"flex flex-wrap gap-2"},["1m","3m","6m","12m"].map(function(e){return d.createElement("button",{key:e,type:"button",onClick:function(){var t=function(e){var t=new Date,n="1m"===e?1:"3m"===e?3:"6m"===e?6:12;return t.setMonth(t.getMonth()-n),t.toISOString().slice(0,10)}(e);Lt(e),Pa("startDate",t),Oa({datePeriod:e,startDate:t})},className:"px-3 py-1.5 rounded-lg border text-sm font-medium transition-colors ".concat(qt===e?"border-primaryColor bg-primaryExtremeLightColor text-primaryColor":"border-gray-200 bg-white text-gray-700 hover:border-gray-300")},We[e])}),d.createElement("button",{type:"button",onClick:function(){return Lt("custom")},className:"px-3 py-1.5 rounded-lg border text-sm font-medium transition-colors ".concat("custom"===qt?"border-primaryColor bg-primaryExtremeLightColor text-primaryColor":"border-gray-200 bg-white text-gray-700 hover:border-gray-300")},"Custom")),"custom"===qt&&d.createElement("div",{className:"relative mt-2"},d.createElement("input",{type:"date",value:on.startDate,onChange:function(e){Pa("startDate",e.target.value),Oa({datePeriod:"custom",startDate:e.target.value})},className:"".concat(Ma," pr-10")}),d.createElement(y.Calendar,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400 pointer-events-none"})))),ne&&on.realmId?d.createElement("div",{className:"rounded-lg border border-green-200 bg-green-50 px-4 py-3"},d.createElement("div",{className:"flex items-start justify-between gap-3"},d.createElement("div",{className:"flex items-center gap-3"},d.createElement(y.CheckCircle,{className:"w-5 h-5 text-green-600 shrink-0 mt-0.5"}),d.createElement("div",null,d.createElement("p",{className:"text-sm font-semibold text-green-800"},"Connected to QuickBooks"),on.companyName&&d.createElement("p",{className:"text-xs text-green-700 mt-0.5"},on.companyName),d.createElement("p",{className:"text-xs text-green-600 mt-0.5 font-mono"},"Realm ID: ",on.realmId))),d.createElement("button",{type:"button",onClick:Va,className:"flex items-center gap-1 text-xs text-green-700 hover:text-green-900 font-medium shrink-0 mt-0.5"},d.createElement(y.RefreshCw,{className:"w-3.5 h-3.5"}),"Reconnect"))):xn?d.createElement("div",{className:"rounded-lg border border-gray-200 bg-gray-50 px-4 py-4 space-y-3"},d.createElement("div",{className:"flex items-center justify-between mb-1"},d.createElement("p",{className:"text-sm font-semibold text-gray-800"},"Enter Credentials Manually"),d.createElement("button",{type:"button",onClick:function(){return hn(!1)},className:"text-xs text-primaryColor hover:underline font-medium"},"â Use OAuth instead")),[{key:"clientId",label:"Client ID",placeholder:"Your QuickBooks app Client ID"},{key:"clientSecret",label:"Client Secret",placeholder:"Your QuickBooks app Client Secret"},{key:"accessToken",label:"Access Token",placeholder:"Bearer access token"},{key:"refreshToken",label:"Refresh Token",placeholder:"Refresh token"},{key:"realmId",label:"Realm ID",placeholder:"QuickBooks company Realm ID"},{key:"companyName",label:"Company Name",placeholder:"Your QuickBooks company name (optional)"}].map(function(e){var t=e.key,n=e.label,a=e.placeholder;return d.createElement("div",{key:t},d.createElement("label",{className:"block text-xs font-medium text-gray-600 mb-1"},n),d.createElement("input",{type:"clientSecret"===t||"accessToken"===t||"refreshToken"===t?"password":"text",value:wn[t],onChange:function(e){return Cn(function(n){return Ue(Ue({},n),{},(0,i.A)({},t,e.target.value))})},placeholder:a,className:Ma}))}),d.createElement("div",{className:"flex justify-end pt-1"},d.createElement("button",{type:"button",onClick:Ua,disabled:!wn.accessToken||!wn.realmId,className:"px-4 py-2 rounded-lg text-sm font-semibold transition-colors ".concat(wn.accessToken&&wn.realmId?"bg-primaryColor text-white hover:bg-primaryDarkColor":"bg-gray-100 text-gray-400 cursor-not-allowed")},"Connect"))):d.createElement("div",{className:"rounded-lg border border-gray-200 bg-gray-50 px-4 py-5 flex flex-col items-center gap-3 text-center"},d.createElement("div",{className:"flex items-center justify-center w-12 h-12 rounded-full bg-white border border-gray-200 shadow-sm"},d.createElement(N._pZ,{className:"w-6 h-6 text-[#2CA01C]"})),d.createElement("div",null,d.createElement("p",{className:"text-sm font-semibold text-gray-800"},"Authorize with QuickBooks"),d.createElement("p",{className:"text-xs text-gray-500 mt-1"},"You'll be redirected to Intuit to grant ThriveStack read access to your"," ",d.createElement("span",{className:"font-medium"},Qt)," QuickBooks data.")),d.createElement("button",{type:"button",onClick:_?ja:La,disabled:un,className:"flex items-center gap-2 px-5 py-2.5 rounded-lg text-sm font-semibold transition-colors ".concat(un?"bg-gray-100 text-gray-400 cursor-not-allowed":"bg-[#2CA01C] text-white hover:bg-[#238016]")},un?d.createElement(d.Fragment,null,d.createElement(y.Loader2,{className:"w-4 h-4 animate-spin"}),"Connectingâ¦"):d.createElement(d.Fragment,null,d.createElement(N._pZ,{className:"w-4 h-4"}),"Connect with QuickBooks")),fn&&d.createElement("p",{className:"text-xs text-red-600"},fn),!_&&d.createElement("button",{type:"button",onClick:function(){return hn(!0)},className:"text-xs text-gray-400 hover:text-gray-600 transition-colors"},"Enter Credentials manually")),ne&&on.realmId&&d.createElement("div",{className:"flex justify-end pt-1"},d.createElement("button",{onClick:function(){return Zt("test")},className:"px-4 py-2 rounded-lg text-sm font-semibold bg-primaryColor text-white hover:bg-primaryDarkColor transition-colors"},"Continue to Test")))},Ha=[15,30,45,60,90],Ga=function(e,t,n,a,r){var s=a.toLowerCase(),o=e.filter(function(e){return e.name.toLowerCase().includes(s)||e.type.toLowerCase().includes(s)}),l=o.map(function(e){return e.id}),i=l.length>0&&l.every(function(e){return t.has(e)}),c=l.some(function(e){return t.has(e)});return d.createElement("div",{className:"space-y-3"},d.createElement("div",{className:"relative"},d.createElement(y.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400 pointer-events-none"}),d.createElement("input",{type:"text",placeholder:"Search itemsâ¦",value:a,onChange:function(e){return r(e.target.value)},className:"w-full pl-9 pr-3 py-2 border border-gray-300 rounded-lg text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent bg-white"}),a&&d.createElement("button",{type:"button",onClick:function(){return r("")},className:"absolute right-3 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600"},d.createElement(y.X,{className:"w-3.5 h-3.5"}))),d.createElement("div",{className:"border border-gray-200 rounded-lg overflow-hidden"},d.createElement("table",{className:"w-full text-sm"},d.createElement("thead",null,d.createElement("tr",{className:"bg-gray-50 border-b border-gray-200"},d.createElement("th",{className:"px-4 py-2.5 w-10"},d.createElement("input",{type:"checkbox",checked:i,ref:function(e){e&&(e.indeterminate=!i&&c)},onChange:function(){return n(function(e){var t=new Set(e);return i?l.forEach(function(e){return t.delete(e)}):l.forEach(function(e){return t.add(e)}),t})}
1,className:"w-4 h-4 accent-primaryColor rounded cursor-pointer"})),d.createElement("th",{className:"text-left px-4 py-2.5 font-medium text-gray-600"},"Name"),d.createElement("th",{className:"text-left px-4 py-2.5 font-medium text-gray-600"},"Type"),d.createElement("th",{className:"text-left px-4 py-2.5 font-medium text-gray-600"},"Price"))),d.createElement("tbody",null,0===o.length?d.createElement("tr",null,d.createElement("td",{colSpan:4,className:"px-4 py-6 text-center text-sm text-gray-400"},"No items match your search.")):o.map(function(e){var a=t.has(e.id);return d.createElement("tr",{key:e.id,onClick:function(){return t=e.id,n(function(e){var n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n});var t},className:"border-b border-gray-100 last:border-0 cursor-pointer transition-colors ".concat(a?"bg-blue-50":"hover:bg-gray-50")},d.createElement("td",{className:"px-4 py-3 text-center"},d.createElement("input",{type:"checkbox",readOnly:!0,checked:a,className:"w-4 h-4 accent-primaryColor rounded cursor-pointer"})),d.createElement("td",{className:"px-4 py-3 font-medium text-gray-900"},e.name),d.createElement("td",{className:"px-4 py-3 text-gray-500"},e.type),d.createElement("td",{className:"px-4 py-3 text-gray-900"},e.price))})))))},Ja=function(){var e,t,n=null!==(e=null==Vt||null===(t=Vt.getQuickbooksItems)||void 0===t?void 0:t.items)&&void 0!==e?e:[],a=!_&&Bt,r=!_&&!!zt,s=!_&&n.length>0;return{isLoadingReal:a,hasError:r,hasRealItems:s,showTable:_||s,allItems:_?Ze.map(function(e){return{id:e.name,name:e.name,type:e.type,price:e.price}}):n.map(function(e){var t;return{id:e.id,name:e.name,type:e.type,price:"$".concat((null!==(t=e.unitPrice)&&void 0!==t?t:0).toFixed(2))}})}},Za=function(e,t){return e?d.createElement("div",{className:"border border-dashed border-gray-200 rounded-lg px-6 py-8 flex flex-col items-center gap-2 text-center bg-gray-50"},d.createElement(y.Loader2,{className:"w-6 h-6 text-gray-400 animate-spin"}),d.createElement("p",{className:"text-sm font-medium text-gray-600"},"Fetching items from QuickBooksâ¦")):t?d.createElement("div",{className:"border border-dashed border-red-200 rounded-lg px-6 py-6 flex flex-col items-center gap-2 text-center bg-red-50"},d.createElement("p",{className:"text-sm font-medium text-red-600"},"Failed to load items"),d.createElement("p",{className:"text-xs text-red-400"},null==zt?void 0:zt.message)):d.createElement("div",{className:"border border-dashed border-gray-200 rounded-lg px-6 py-6 flex flex-col items-center gap-2 text-center bg-gray-50"},d.createElement("p",{className:"text-sm font-medium text-gray-600"},"No items found in your QuickBooks account."),d.createElement("p",{className:"text-xs text-gray-400"},"You can continue and update this selection later."))},Ya=function(e){return"environment"===e?d.createElement("div",{className:"pb-2"},d.createElement("div",{className:"grid grid-cols-2 gap-4 mb-4"},d.createElement("div",null,d.createElement("label",{className:"block text-xs font-semibold text-gray-500 uppercase tracking-wider mb-2"},"Your QuickBooks"),d.createElement("div",{className:"relative"},d.createElement("button",{type:"button",onClick:function(){return an(function(e){return!e})},className:"w-full flex items-center gap-2 px-3 py-2.5 border border-gray-300 rounded-lg bg-white text-sm text-gray-700 hover:border-gray-400 focus:outline-none focus:ring-2 focus:ring-blue-500"},d.createElement(N._pZ,{className:"w-4 h-4 text-[#2CA01C] shrink-0"}),d.createElement("span",{className:"flex-1 text-left"},Qt),Qt===J&&d.createElement("span",{className:"text-xs text-green-600 font-medium bg-green-50 px-1.5 py-0.5 rounded"},"Auto-mapped"),d.createElement(y.ChevronDown,{className:"w-4 h-4 text-gray-400 transition-transform ".concat(nn?"rotate-180":"")})),nn&&d.createElement("div",{className:"absolute z-10 mt-1 w-full bg-white border border-gray-200 rounded-lg shadow-lg"},["Production","Sandbox"].map(function(e){var t=Qt===e,n=e===J,a=t?void 0:"Switch to ".concat(e," â recommended for ").concat("Production"===e?"production":"non-production"," environments");return d.createElement("div",{key:e,className:"relative group"},d.createElement("button",{type:"button",onClick:function(){$t(e),an(!1)},className:"w-full flex items-center gap-2 px-3 py-2.5 text-sm text-left hover:bg-gray-50 first:rounded-t-lg last:rounded-b-lg ".concat(t?"font-semibold text-primaryColor bg-blue-50":"text-gray-700")},d.createElement(N._pZ,{className:"w-4 h-4 text-[#2CA01C] shrink-0"}),d.createElement("span",{className:"flex-1"},e),n&&d.createElement("span",{className:"text-xs text-green-600 font-medium"},"Recommended")),a&&d.createElement("div",{className:"absolute left-full top-1/2 -translate-y-1/2 ml-2 px-2.5 py-1.5 bg-gray-900 text-white text-xs rounded-lg shadow-lg whitespace-nowrap opacity-0 group-hover:opacity-100 transition-opacity pointer-events-none z-20"},a,d.createElement("div",{className:"absolute right-full top-1/2 -translate-y-1/2 border-4 border-transparent border-r-gray-900"})))})))),d.createElement("div",null,d.createElement("label",{className:"block text-xs font-semibold text-gray-500 uppercase tracking-wider mb-2"},"ThriveStack Environment"),d.createElement("div",{className:"flex items-center gap-2 px-3 py-2.5 border border-gray-200 rounded-lg bg-gray-50"},d.createElement("span",{className:"text-sm text-gray-700"},G)))),d.createElement("div",{className:"flex justify-end"},d.createElement("button",{onClick:qa,className:"px-4 py-2 rounded-lg text-sm font-semibold bg-primaryColor text-white hover:bg-primaryDarkColor transition-colors"},"Next"))):"basic"===e?Wa():"test"===e?(t=Qn&&zn.some(function(e){return"error"===e.status}),n=Qn&&zn.every(function(e){return"success"===e.status}),a=n&&!na,d.createElement("div",{className:"pb-2 space-y-3"},d.createElement("div",{className:"space-y-2"},zn.map(function(e){var t,n,a,r,s,o,l,i;return d.createElement("div",{key:e.id},d.createElement("div",{className:"flex items-center gap-3 px-3 py-2.5 rounded-lg border ".concat("success"===e.status?"border-green-200 bg-green-50":"error"===e.status?"border-red-200 bg-red-50":"loading"===e.status?"border-blue-200 bg-blue-50":"border-gray-200 bg-gray-50")},"loading"===e.status?d.createElement(y.Loader2,{className:"w-4 h-4 text-blue-500 animate-spin shrink-0"}):"success"===e.status?d.createElement(y.CheckCircle,{className:"w-4 h-4 text-green-500 shrink-0"}):"error"===e.status?d.createElement(y.X,{className:"w-4 h-4 text-red-500 shrink-0"}):d.createElement("div",{className:"w-4 h-4 rounded-full border-2 border-gray-300 shrink-0"}),d.createElement("span",{className:"text-sm font-medium ".concat("success"===e.status?"text-green-700":"error"===e.status?"text-red-700":"loading"===e.status?"text-blue-700":"text-gray-500")},"loading"===e.status?e.loadingText:"success"===e.status?e.successText:"error"===e.status?e.errorText:e.title)),"connection"===e.id&&"error"===e.status&&e.errorMessage&&d.createElement("div",{className:"mt-2 mx-1 px-4 py-3 rounded-lg border border-red-200 bg-red-50 space-y-1"},d.createElement("p",{className:"text-sm font-semibold text-red-800"},e.errorMessage),e.details&&d.createElement("p",{className:"text-xs text-red-700 leading-relaxed"},e.details),d.createElement("p",{className:"text-xs text-red-600 mt-1"},"Please verify your ",d.createElement("span",{className:"font-medium"},"Client ID"),","," ",d.createElement("span",{className:"font-medium"},"Client Secret"),","," ",d.createElement("span",{className:"font-medium"},"Access Token"),", and"," ",d.createElement("span",{className:"font-medium"},"Refresh Token")," in the previous step and retry.")),"schema"===e.id&&"error"===e.status&&d.createElement("div",{className:"mt-3 px-3 py-3 rounded-lg border border-red-100 bg-red-50 flex items-start justify-between gap-3"},d.createElement("p",{className:"text-xs text-red-700"},"We were not able to fetch the custom fields from your QuickBooks customers. Proceed to map your account fields."),d.createElement("button",{type:"button",onClick:function(){return Zt("pause-fix")},className:"shrink-0 px-3 py-1.5 rounded-lg text-xs font-semibold bg-primaryColor text-white hover:bg-primaryDarkColor transition-colors"},"Fix Now")),"data"===e.id&&"pending"!==e.status&&(null!==(t=null===(n=e.accessibleEntities)||void 0===n?void 0:n.length)&&void 0!==t?t:0)+(null!==(a=null===(r=e.missingEntities)||void 0===r?void 0:r.length)&&void 0!==a?a:0)>0&&d.createElement("div",{className:"mt-2 ml-1"},d.createElement("button",{type:"button",onClick:function(){return ua(function(e){return!e})},className:"flex items-center gap-1.5 text-blue-600 hover:text-blue-800 text-sm font-medium mb-2"},d.createElement(y.ChevronDown,{className:"w-4 h-4 transition-transform ".concat(ma?""
1:"-rotate-90")}),"List of Entities Syncing"),ma&&d.createElement("div",{className:"border-l-2 border-gray-200 pl-4 ml-2 space-y-3"},(null!==(s=null===(o=e.accessibleEntities)||void 0===o?void 0:o.length)&&void 0!==s?s:0)>0&&d.createElement("div",null,d.createElement("p",{className:"text-xs text-gray-500 mb-1"},"Accessible: ",d.createElement("span",{className:"font-medium text-gray-700"},e.accessibleEntities.length)),d.createElement("ul",{className:"space-y-1"},e.accessibleEntities.map(function(e){return d.createElement("li",{key:e,className:"flex items-center gap-2 text-sm"},d.createElement(y.Check,{className:"w-4 h-4 text-green-600 shrink-0"}),d.createElement("span",{className:"text-gray-700"},e))}))),(null!==(l=null===(i=e.missingEntities)||void 0===i?void 0:i.length)&&void 0!==l?l:0)>0&&d.createElement("div",null,d.createElement("p",{className:"text-xs text-red-500 mb-1"},"Missing: ",d.createElement("span",{className:"font-medium"},e.missingEntities.length)),d.createElement("ul",{className:"space-y-1"},e.missingEntities.map(function(e){return d.createElement("li",{key:e,className:"flex items-center gap-2 text-sm"},d.createElement(y.X,{className:"w-4 h-4 text-red-500 shrink-0"}),d.createElement("span",{className:"text-red-700 font-medium"},e))}))))))})),a&&d.createElement("div",{className:"space-y-3"},d.createElement("div",{className:"flex items-start gap-2 px-3 py-2.5 rounded-lg border border-yellow-200 bg-yellow-50"},d.createElement(y.Info,{className:"w-4 h-4 text-yellow-600 shrink-0 mt-0.5"}),d.createElement("div",null,d.createElement("p",{className:"text-sm font-medium text-yellow-800"},"Group ID field not found"),d.createElement("p",{className:"text-xs text-yellow-700 mt-0.5"},"The ",d.createElement("span",{className:"font-semibold"},"group_id")," custom field was not found on your QuickBooks customers. Add it and populate it with the account/group identifier so account-level attribution works correctly."))),d.createElement(be.i,{source:"quickbooks",accountIdentifierKey:"group_id"}),d.createElement("button",{type:"button",className:"px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-md font-medium text-sm transition-colors",onClick:function(){return we(!0)}},"Invite and Proceed")),n&&oa.length>0&&d.createElement("div",{className:"px-3 py-2.5 rounded-lg border border-gray-200 bg-gray-50"},d.createElement("p",{className:"text-xs font-medium text-gray-600 mb-1.5"},"Customer metadata keys found:"),d.createElement("div",{className:"flex flex-wrap gap-1.5"},oa.map(function(e){return d.createElement("span",{key:e,className:"inline-block px-2 py-0.5 bg-white border border-gray-300 rounded text-xs text-gray-700 font-mono"},e)}))),!Jn&&d.createElement("div",{className:"flex items-center gap-3 pt-1"},d.createElement("button",{onClick:Ba,className:"flex items-center gap-2 px-4 py-2 rounded-lg text-sm font-semibold bg-primaryColor text-white hover:bg-primaryDarkColor transition-colors"},Qn?"Re-test Connection":"Test Connection"),t&&d.createElement("p",{className:"text-xs text-red-600"},"Fix the issue above and retry.")),Jn&&d.createElement("div",{className:"flex items-center gap-2 text-sm text-blue-600"},d.createElement(y.Loader2,{className:"w-4 h-4 animate-spin"}),"Testing connectionâ¦"))):"pause-fix"===e?d.createElement("div",{className:"pb-2 space-y-4"},d.createElement("p",{className:"text-sm text-gray-700"},"We were not able to fetch the custom fields from your QuickBooks customers."," ",d.createElement("button",{type:"button",onClick:function(){return Ae(!0)},className:"text-blue-600 hover:text-blue-800 underline text-sm font-medium"},"Learn more")),wa?d.createElement("div",{className:"flex items-center gap-3 px-3 py-2.5 rounded-lg border border-green-200 bg-green-50"},d.createElement(y.CheckCircle,{className:"w-4 h-4 text-green-500 shrink-0"}),d.createElement("p",{className:"text-sm text-green-800"},"Mapped ",d.createElement("span",{className:"font-mono font-medium"},fa)," â ",d.createElement("span",{className:"font-mono font-medium"},"customerId"===xa?"Id":"customer name"),". ThriveStack will fetch account correlation from product telemetry."),d.createElement("button",{type:"button",onClick:function(){return Ca(!1)},className:"ml-auto text-xs text-gray-400 hover:text-gray-600 underline shrink-0"},"Change")):d.createElement(d.Fragment,null,d.createElement("p",{className:"text-sm font-medium text-gray-800"},"How do you map your accounts in product to your QuickBooks customers?"),d.createElement("div",{className:"border border-gray-200 rounded-xl overflow-hidden"},d.createElement("div",{className:"grid grid-cols-[1fr_24px_1fr] px-4 py-2 bg-gray-50 border-b border-gray-200"},d.createElement("span",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wider"},"Product"),d.createElement("span",null),d.createElement("span",{className:"text-xs font-semibold text-gray-500 uppercase tracking-wider"},"QuickBooks")),d.createElement("div",{className:"divide-y divide-gray-100"},[{productField:"accountId",qbField:"customerId",qbLabel:"Id"},{productField:"useremail",qbField:"customerName",qbLabel:"customer name"}].map(function(e){var t=e.productField,n=e.qbField,a=e.qbLabel,r=fa===t&&xa===n;return d.createElement("button",{key:t,type:"button",onClick:function(){ba(t),ha(n)},className:"w-full grid grid-cols-[1fr_24px_1fr] items-center px-4 py-3 text-left transition-colors ".concat(r?"bg-blue-50":"hover:bg-gray-50")},d.createElement("span",{className:"flex items-center gap-2 font-mono text-xs ".concat(r?"text-blue-700 font-semibold":"text-gray-700")},d.createElement("div",{className:"w-3.5 h-3.5 rounded-full border-2 shrink-0 ".concat(r?"border-blue-500 bg-blue-500":"border-gray-300")}),t),d.createElement("span",{className:"text-center text-sm font-bold ".concat(r?"text-blue-500":"text-gray-300")},"â"),d.createElement("span",{className:"font-mono text-xs ".concat(r?"text-blue-700 font-semibold":"text-gray-700")},a))}))),d.createElement("div",{className:"flex items-center gap-3 pt-1"},d.createElement("button",{type:"button",disabled:!fa||!xa,onClick:function(){Ca(!0),xe(!0),Oa({pauseFixCompleted:!0,fieldMapping:{productField:fa,qbField:xa,confirmed:!0}}),Zt("recurring")},className:"px-4 py-2 rounded-lg text-sm font-semibold bg-primaryColor text-white hover:bg-primaryDarkColor transition-colors disabled:opacity-40 disabled:cursor-not-allowed"},"Confirm Mapping"),d.createElement("button",{type:"button",onClick:function(){return we(!0)},className:"px-4 py-2 rounded-lg text-sm font-semibold border border-gray-300 text-gray-700 hover:bg-gray-50 transition-colors"},"Invite and Proceed"),d.createElement("button",{type:"button",onClick:function(){xe(!0),Oa({pauseFixCompleted:!0}),Zt("recurring")},className:"px-4 py-2 rounded-lg text-sm font-semibold text-gray-500 hover:text-gray-700 transition-colors"},"Proceed Anyway")))):"recurring"===e?(r=Ja(),s=r.isLoadingReal,o=r.hasError,l=r.hasRealItems,c=r.showTable,m=r.allItems,u=_?wt.size>0:!l||wt.size>0,d.createElement("div",{className:"pb-2 space-y-4"},c?Ga(m,wt,Ct,At,It):Za(s,o),d.createElement("div",{className:"flex items-center justify-between pt-1"},d.createElement("span",{className:"text-xs text-gray-500"}
1,wt.size>0?"".concat(wt.size," item").concat(1!==wt.size?"s":""," selected"):_||l?"Select at least one item to continue":"You can update your selection later."),d.createElement("button",{onClick:function(){Oa({itemsStepCompleted:!0,mrrItems:Array.from(wt)}),_e(!0),Zt("plans")},disabled:!u,className:"px-4 py-2 rounded-lg text-sm font-semibold transition-colors ".concat(u?"bg-primaryColor text-white hover:bg-primaryDarkColor":"bg-gray-100 text-gray-400 cursor-not-allowed")},"Continue")))):"plans"===e?(p=Ja().allItems.filter(function(e){return wt.has(e.id)}),g=p.length>0&&p.every(function(e){var t,n;return(null===(t=ft[e.id])||void 0===t?void 0:t.term)&&(null===(n=ft[e.id])||void 0===n?void 0:n.frequency)}),f=function(e,t){bt(function(n){var a=n[e]||{term:"month",frequency:1},r=Ue(Ue({},a),t);return t.term&&t.term!==a.term&&(r.frequency=Ve[t.term][0]),Ue(Ue({},n),{},(0,i.A)({},e,r))})},b="border border-gray-300 rounded-lg text-sm bg-white focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent px-3 py-2 pr-8 appearance-none cursor-pointer",d.createElement("div",{className:"pb-2 space-y-4"},d.createElement("div",{className:"border border-gray-200 rounded-lg overflow-hidden"},d.createElement("table",{className:"w-full text-sm"},d.createElement("thead",null,d.createElement("tr",{className:"bg-gray-50 border-b border-gray-200"},d.createElement("th",{className:"text-left px-4 py-2.5 font-medium text-gray-600"},"Product"),d.createElement("th",{className:"text-left px-4 py-2.5 font-medium text-gray-600"},"Type"),d.createElement("th",{className:"text-left px-4 py-2.5 font-medium text-gray-600 w-36"},"Term"),d.createElement("th",{className:"text-left px-4 py-2.5 font-medium text-gray-600 w-44"},"Frequency"))),d.createElement("tbody",null,0===p.length?d.createElement("tr",null,d.createElement("td",{colSpan:4,className:"px-4 py-6 text-center text-sm text-gray-400"},"No recurring items selected. Go back and select items first.")):p.map(function(e){var t,n,a=ft[e.id],r=null!==(t=null==a?void 0:a.term)&&void 0!==t?t:"",s=r?Ve[r]:[];return d.createElement("tr",{key:e.id,className:"border-b border-gray-100 last:border-0"},d.createElement("td",{className:"px-4 py-3 font-medium text-gray-900"},e.name),d.createElement("td",{className:"px-4 py-3 text-gray-500"},e.type),d.createElement("td",{className:"px-4 py-3"},d.createElement("div",{className:"relative"},d.createElement("select",{value:r,onChange:function(t){return f(e.id,{term:t.target.value})},className:b},d.createElement("option",{value:"",disabled:!0},"Select term"),d.createElement("option",{value:"day"},"Day"),d.createElement("option",{value:"week"},"Week"),d.createElement("option",{value:"month"},"Month"),d.createElement("option",{value:"year"},"Year")),d.createElement(y.ChevronDown,{className:"absolute right-2 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-gray-400 pointer-events-none"}))),d.createElement("td",{className:"px-4 py-3"},d.createElement("div",{className:"relative"},d.createElement("select",{value:null!==(n=null==a?void 0:a.frequency)&&void 0!==n?n:"",onChange:function(t){return f(e.id,{frequency:Number(t.target.value)})},disabled:!r,className:"".concat(b," ").concat(r?"":"opacity-40 cursor-not-allowed")},d.createElement("option",{value:"",disabled:!0},"Select frequency"),s.map(function(e){return d.createElement("option",{key:e,value:e},function(e,t){var n="day"===e?"day":"week"===e?"week":"month"===e?"month":"year";return 1===t?"Every ".concat(n):"Every ".concat(t," ").concat(n,"s")}(r,e))})),d.createElement(y.ChevronDown,{className:"absolute right-2 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-gray-400 pointer-events-none"}))))})))),d.createElement("div",{className:"flex items-center justify-between pt-1"},d.createElement("span",{className:"text-xs text-gray-500"},g?"All products configured":"Set term and frequency for every product to continue"),d.createElement("button",{onClick:function(){Oa({plansStepCompleted:!0,mrrItemsTerm:Ue({},ft),planTerms:null}),Fe(!0),Zt("professional")},disabled:!g,className:"px-4 py-2 rounded-lg text-sm font-semibold transition-colors ".concat(g?"bg-primaryColor text-white hover:bg-primaryDarkColor":"bg-gray-100 text-gray-400 cursor-not-allowed")},"Continue")))):"professional"===e?function(){var e=Ja(),t=e.isLoadingReal,n=e.hasError,a=e.showTable,r=e.allItems.filter(function(e){return!wt.has(e.id)});return d.createElement("div",{className:"pb-2 space-y-4"},d.createElement("p",{className:"text-sm text-gray-600"},"Select the products and services that contribute to your revenue outside of recurring revenue â e.g. one-time fees, implementation, consulting, or training."),a?Ga(r,Rt,_t,Mt,Ft):Za(t,n),d.createElement("div",{className:"flex items-center justify-between pt-1"},d.createElement("span",{className:"text-xs text-gray-500"},Rt.size>0?"".concat(Rt.size," item").concat(1!==Rt.size?"s":""," selected"):"Optional â you can update this later."),d.createElement("button",{onClick:function(){Oa({professionalStepCompleted:!0,oneTimeItems:Array.from(Rt),otherRevenueItems:null}),Ye(!0),Zt("cancellations")},className:"px-4 py-2 rounded-lg text-sm font-semibold transition-colors bg-primaryColor text-white hover:bg-primaryDarkColor"},"Continue")))}():"cancellations"===e?d.createElement("div",{className:"pb-2 space-y-4"},d.createElement("p",{className:"text-sm font-semibold text-gray-800"},"Cancellations"),d.createElement("div",{className:"rounded-xl border-2 transition-all ".concat("auto"===at?"border-primaryColor bg-primaryExtremeLightColor":"border-gray-200 bg-white")},d.createElement("button",{type:"button",onClick:function(){return rt("auto")},className:"w-full flex items-center gap-3 px-4 py-3 text-left"},d.createElement("div",{className:"w-4 h-4 rounded-full border-2 flex items-center justify-center shrink-0 ".concat("auto"===at?"border-primaryColor":"border-gray-400")},"auto"===at&&d.createElement("div",{className:"w-2 h-2 rounded-full bg-primaryColor"})),d.createElement("span",{className:"text-sm font-medium text-gray-800 flex-1"},"Automatically mark cancel subscriptions")),"auto"===at&&d.createElement("div",{className:"px-4 pb-4 space-y-3 border-t border-primaryColor/20 mt-1 pt-3"},d.createElement("div",{className:"flex items-center justify-between gap-4"},d.createElement("div",{className:"flex items-center gap-1.5"},d.createElement("span",{className:"text-sm text-gray-700"},"When an invoice is unpaid"),d.createElement(y.Info,{className:"w-3.5 h-3.5 text-gray-400"})),d.createElement("div",{className:"relative"},d.createElement("select",{value:lt,onChange:function(e){return it(Number(e.target.value))},className:"appearance-none pl-3 pr-8 py-1.5 border border-gray-300 rounded-lg text-sm bg-white focus:outline-none focus:ring-2 focus:ring-blue-500 cursor-pointer"},Ha.map(function(e){return d.createElement("option",{key:e,value:e},"Cancel after ",e," Days")})),d.createElement(y.ChevronDown,{className:"pointer-events-none absolute right-2 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-gray-400"}))),d.createElement("div",{className:"flex items-center justify-between gap-4"},d.createElement("div",{className:"flex items-center gap-1.5"},d.createElement("span",{className:"text-sm text-gray-700"},"When there is no renewal invoice"),d.createElement(y.Info,{className:"w-3.5 h-3.5 text-gray-400"})),d.createElement("div",{className:"relative"},d.createElement("select",{value:ut,onChange:function(e){return dt(Number(e.target.value))},className:"appearance-none pl-3 pr-8 py-1.5 border border-gray-300 rounded-lg text-sm bg-white focus:outline-none focus:ring-2 focus:ring-blue-500 cursor-pointer"},Ha.map(function(e){return d.createElement("option",{key:e,value:e},"Cancel after ",e," Days")})),d.createElement(y.ChevronDown,{className:"pointer-events-none absolute right-2 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-gray-400"}))))),d.createElement("button",{type:"button",onClick:function(){return rt("manual")},className:"w-full flex items-center gap-3 px-4 py-3 rounded-xl border-2 text-left transition-all ".concat("manual"===at?"border-primaryColor bg-primaryExtremeLightColor":"border-gray-200 bg-white hover:border-gray-300")},d.createElement("div",{className:"w-4 h-4 rounded-full border-2 flex items-center justify-center shrink-0 ".concat("manual"===at?"border-primaryColor":"border-gray-400")},"manual"===at&&d.createElement("div",{className:"w-2 h-2 rounded-full bg-primaryColor"})),d.createElement("span",{className:"text-sm font-medium text-gray-800"},"Leave subscriptions as is until I explicitly mark them for cancellation")),d.createElement("div",{className:"flex justify-end pt-1"},d.createElement("button",{type:"button",onClick:function(){et(!0),Oa({cancellationsStepCompleted:!0,cancellationPolicy:at,unpaidInvoiceDays:"auto"===at?lt:null,no
1RenewalDays:"auto"===at?ut:null}),Zt("ingestion")},className:"px-4 py-2 rounded-lg text-sm font-semibold bg-primaryColor text-white hover:bg-primaryDarkColor transition-colors"},"Continue to Ingestion"))):"ingestion"===e?d.createElement("div",{className:"pb-2 space-y-4"},xt&&Ln?d.createElement(d.Fragment,null,d.createElement("div",{className:"flex items-start gap-3 px-4 py-3 rounded-lg border border-green-200 bg-green-50"},d.createElement(y.CheckCircle,{className:"w-5 h-5 text-green-600 shrink-0 mt-0.5"}),d.createElement("div",null,d.createElement("p",{className:"text-sm font-semibold text-green-800"},"Sync started successfully"),Ln.syncStartedAt&&d.createElement("p",{className:"text-xs text-green-600 mt-0.5"},"Started at ",new Date(Ln.syncStartedAt).toLocaleString("en-US",{weekday:"short",year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"})),d.createElement("p",{className:"text-xs text-green-700 mt-1"},"We're syncing your QuickBooks data. This may take 5â7 minutes. You'll receive an email notification once complete."))),d.createElement("div",{className:"text-sm text-gray-700"},"You can continue to ",d.createElement("strong",null,"Core Revenue Calculation")," to set up currency and other fee-related configurations while the sync completes in the background.")):d.createElement(d.Fragment,null,d.createElement("p",{className:"text-sm text-gray-600 mb-4"},"Your QuickBooks connection is configured and tested. Click below to start syncing your data to ThriveStack."),d.createElement("div",{className:"mb-4"},d.createElement("p",{className:"text-sm text-gray-700 mb-3"},"Notification will be sent to: ",d.createElement("span",{className:"font-semibold"},null===(v=(0,H.wz)())||void 0===v?void 0:v.email)),A.state.showInput?d.createElement("div",{className:"space-y-2"},d.createElement("label",{className:"block text-sm text-gray-700"},"Add additional email addresses where you'd like to receive notifications."),d.createElement("div",{className:"relative"},d.createElement("input",{type:"text",value:A.state.inputValue,onChange:function(e){return A.handleInputChange(e.target.value)},onKeyDown:A.handleKeyDown,placeholder:"Enter email and press Enter or comma",className:"w-full px-3 py-2 border rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 text-sm ".concat(A.state.error?"border-red-500":"border-gray-300")}),A.state.error&&d.createElement("p",{className:"text-red-600 text-xs mt-1"},A.state.error)),A.state.emails.length>0&&d.createElement("div",{className:"flex flex-wrap gap-2 mb-2"},A.state.emails.map(function(e,t){return d.createElement("div",{key:t,className:"flex items-center gap-1 px-3 py-1 bg-gray-200 rounded-full text-sm"},d.createElement("span",null,e),d.createElement("button",{type:"button",onClick:function(){return A.removeEmail(e)},className:"hover:bg-blue-200 rounded-full p-0.5 transition-colors"},d.createElement(y.X,{className:"w-3 h-3"})))}))):d.createElement("button",{type:"button",onClick:A.toggleInput,className:"flex items-center gap-2 px-4 py-2 text-sm font-medium text-blue-600 hover:text-blue-800 transition-colors"},d.createElement(y.UserPlus,{className:"w-4 h-4"}),"Add Additional Emails")),An||Ia?d.createElement("div",{className:"space-y-2"},d.createElement("div",{className:"flex items-center justify-between mb-1"},d.createElement("span",{className:"text-sm font-medium text-gray-700"},Mn<5?"Creating Sourceâ¦":Mn<15?"Creating Connectionâ¦":"Starting Ingestionâ¦"),d.createElement("span",{className:"text-xs text-gray-400"},Math.round(Rn),"%")),d.createElement("div",{className:"w-full h-1.5 bg-gray-100 rounded-full overflow-hidden"},d.createElement("div",{className:"h-full bg-blue-500 rounded-full transition-all duration-300 ease-out",style:{width:"".concat(Rn,"%")}}))):d.createElement("button",{onClick:za,className:"flex items-center gap-2 px-4 py-2 rounded-lg text-sm font-semibold bg-primaryColor text-white hover:bg-primaryDarkColor transition-colors"},"Start Ingestion"))):null;var t,n,a,r,s,o,l,c,m,u,p,g,f,b,v};return d.createElement("div",{className:"relative"}
1,d.createElement("div",{className:"absolute left-3.5 top-8 bottom-8 w-px bg-gray-200 z-0"}),d.createElement("div",{className:"space-y-0"},Wt.map(function(e){var t,n="environment"===(t=e.id)?Q:"basic"===t?ne:"test"===t?pe:"pause-fix"===t?ve:"recurring"===t?Re:"plans"===t?Me:"professional"===t?Le:"cancellations"===t?$e:"ingestion"===t&&xt,a=function(e){return"basic"===e?!Q:"test"===e?!ne:"pause-fix"===e?!pe:"recurring"===e?!ve:"plans"===e?!Re:"professional"===e?!Me:"cancellations"===e?!Le:"ingestion"===e&&!$e}(e.id),r=Jt===e.id;return d.createElement("div",{key:e.id,className:"relative z-10"},d.createElement("div",{className:"flex items-start gap-4 py-3 ".concat(a?"opacity-50 cursor-not-allowed":"cursor-pointer"),onClick:function(){a||Zt(e.id)}},d.createElement("div",{className:"w-8 h-8 rounded-full flex items-center justify-center shrink-0 border-2 text-sm font-bold z-10 mt-0.5 ".concat(n?"bg-green-500 border-green-500 text-white":r?"bg-primaryColor border-primaryColor text-white":"bg-white border-gray-300 text-gray-400")},n?d.createElement(y.Check,{className:"w-4 h-4"}):e.num),d.createElement("div",{className:"flex-1 min-w-0"},d.createElement("div",{className:"flex items-center justify-between gap-2"},d.createElement("div",{className:"flex items-center gap-2"},d.createElement("span",{className:"font-semibold text-sm ".concat(r?"text-primaryColor":a?"text-gray-400":"text-gray-900")},e.title),n&&d.createElement("span",{className:"text-xs font-medium text-green-700 bg-green-50 px-2 py-0.5 rounded-full"},"Completed")),!a&&d.createElement(y.ChevronDown,{className:"w-4 h-4 text-gray-400 shrink-0 transition-transform ".concat(r?"rotate-180":"")})),d.createElement("p",{className:"text-xs mt-0.5 ".concat(a?"text-gray-300":"text-gray-500")},e.description))),r&&d.createElement("div",{className:"ml-12 pb-4"},Ya(e.id)))})),Ne&&d.createElement(re.O,{isOpen:Ne,onClose:function(){return we(!1)},team:k.V.REVOPS_TEAMS,onInvite:function(){xe(!0),Oa({pauseFixCompleted:!0}),Zt("recurring")},source:"quickbooks"}),ke&&d.createElement("div",{className:"fixed inset-0 z-50 flex justify-end"},d.createElement("div",{className:"absolute inset-0 bg-black bg-opacity-50",onClick:function(){return Ae(!1)}}),d.createElement("div",{className:"relative bg-white w-full max-w-lg h-full overflow-y-auto shadow-xl"},d.createElement("div",{className:"sticky top-0 bg-white z-10 flex items-center justify-between px-6 py-4 border-b border-gray-200"},d.createElement("span",{className:"text-sm font-semibold text-gray-700"},"Fix Schema Issue"),d.createElement("button",{type:"button",onClick:function(){return Ae(!1)},className:"p-1.5 rounded-md text-gray-500 hover:text-gray-700 hover:bg-gray-100 transition-colors"},d.createElement(y.X,{className:"w-5 h-5"}))),d.createElement("div",{className:"px-6 py-4 space-y-3"},d.createElement("p",{className:"text-sm text-gray-700"},"The ",d.createElement("span",{className:"font-semibold font-mono"},"group_id")," custom field is missing from your QuickBooks customers. Follow the instructions below to create it and populate it on every customer record."),d.createElement(be.i,{source:"quickbooks",accountIdentifierKey:"group_id"})))),j&&d.createElement("div",{className:"fixed inset-0 z-50 flex justify-end"},d.createElement("div",{className:"absolute inset-0 bg-black bg-opacity-50",onClick:function(){return q(!1)}}),d.createElement("div",{className:"relative bg-white w-full max-w-lg h-full overflow-y-auto shadow-xl"},d.createElement("div",{className:"sticky top-0 bg-white z-10 flex items-center justify-between px-6 py-4 border-b border-gray-200"},d.createElement("span",{className:"text-sm font-semibold text-gray-700"},"Setup Guide"),d.createElement("button",{type:"button",onClick:function(){return q(!1)},className:"p-1.5 rounded-md text-gray-500 hover:text-gray-700 hover:bg-gray-100 transition-colors"},d.createElement(y.X,{className:"w-5 h-5"}))),d.createElement("div",{className:"px-6 py-4"},d.createElement(qe.R,{onClose:function(){return q(!1)}})))))};function Xe(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,a)}return n}function Qe(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};
1t%2?Xe(Object(n),!0).forEach(function(t){(0,i.A)(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Xe(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}y.Database,y.Globe,N.kDV,y.CreditCard,y.Building2;const $e=function(e){var t,n,a,o,m,p=e.step2Configs,g=e.step2UploadedFiles,f=e.mapFieldsRefs,b=e.nextButtonRefs,v=e.handleStep2FileUpload,x=e.handleStep2FieldMappingChange,h=e.processStep2Import,E=e.fileInputRef,N=e.getStepStatus,w=e.renderImportResults,C=e.getStatusDisplay,S=e.getImportButtonText,k=e.retryStep2Import,A=e.onStepComplete,I=e.onAutoSave,T=e.onApiKeyDataChange,D=e.initialApiKeyData,R=e.emailManager,_=e.cleanOAuthParams,F=e.openSetupGuideRef,K=e.onOpenIntegrationsList,j=e.onTrackCompletion,q=(0,P.useDispatch)(),L=(0,P.useSelector)(function(e){return e.revenueAnalytics.selectedSources}),U=(0,P.useSelector)(function(e){return e.revenueAnalytics.selectedDataType}),V=(0,P.useSelector)(function(e){return e.revenueAnalytics.activeSourceTab}),B=(0,P.useSelector)(function(e){return e.revenueAnalytics.sourceConfigurations}),z=(0,P.useSelector)(function(e){return e.revenueAnalytics.expandedStep2SubStep}),W=(0,P.useSelector)(function(e){return e.revenueAnalytics.step2ImportResults}),ne=(0,P.useSelector)(function(e){return e.revenueAnalytics.step2CsvHeaders}),ae=(0,P.useSelector)(function(e){return e.revenueAnalytics.step2FieldMappings}),re=(0,P.useSelector)(function(e){return e.revenueAnalytics.step2IsProcessing}),se=(0,P.useSelector)(function(e){return e.revenueAnalytics.healthCheckCompletedStates}),oe=(0,P.useSelector)(function(e){return e.revenueAnalytics.loadedStripeData}),le=(0,d.useCallback)(function(e){q((0,O.x)({key:"activeSourceTab",value:e}))},[q]),ie=(0,d.useCallback)(function(e,t){q((0,O.Th)({sourceId:e,config:(0,O.xv)(t)}))},[q]),ce=(0,d.useCallback)(function(e){q((0,O.x)({key:"expandedStep2SubStep",value:e}))},[q]),me=(0,d.useCallback)(function(e){q((0,O.x)({key:"healthCheckCompletedStates",value:e}))},[q]),ue=(0,d.useRef)(se);(0,d.useEffect)(function(){ue.current=se},[se]);var de=(null==B?void 0:B.stripe)||{},pe=(null==B?void 0:B.chargebee)||{},ge=(0,d.useCallback)(function(e){return q((0,O.Th)({sourceId:"stripe",config:(0,O.xv)(e)}))},[q]),fe=(0,d.useCallback)(function(e){return q((0,O.Th)({sourceId:"chargebee",config:(0,O.xv)(e)}))},[q]),be=(0,d.useRef)([]),ye=(0,d.useState)(!1),ve=(0,c.A)(ye,2),xe=ve[0],he=ve[1],Ee=(0,d.useState)(null),Ne=(0,c.A)(Ee,2),we=Ne[0],Ce=Ne[1],Se=(0,d.useState)(!1),ke=(0,c.A)(Se,2),Ae=ke[0],Te=ke[1],De=(0,d.useState)(""),Re=(0,c.A)(De,2),_e=(Re[0],Re[1]),Pe=(0,d.useState)("bearer"),Oe=(0,c.A)(Pe,2),Me=(Oe[0],Oe[1]),Fe=(0,d.useState)({}),Ke=(0,c.A)(Fe,2),qe=(Ke[0],Ke[1]),Le=(0,d.useState)({}),Ue=(0,c.A)(Le,2),Ve=(Ue[0],Ue[1]),Be=(0,d.useState)(""),ze=(0,c.A)(Be,2),We=(ze[0],ze[1],(0,d.useState)("")),He=(0,c.A)(We,2),Ge=(He[0],He[1],(0,d.useState)(!1)),Je=(0,c.A)(Ge,2),Ze=(Je[0],Je[1],(0,d.useState)("")),Xe=(0,c.A)(Ze,2),$e=Xe[0],et=Xe[1],tt=(0,d.useState)(""),nt=(0,c.A)(tt,2),at=nt[0],rt=nt[1],st=(0,d.useState)(""),ot=(0,c.A)(st,2),lt=ot[0],it=ot[1],ct=(0,d.useState)(""),mt=(0,c.A)(ct,2),ut=mt[0],dt=mt[1],pt=(0,d.useState)(!1),gt=(0,c.A)(pt,2),ft=gt[0],bt=gt[1],yt=(0,d.useState)(!1),vt=(0,c.A)(yt,2),xt=vt[0],ht=vt[1],Et=(0,d.useState)(0),Nt=(0,c.A)(Et,2),wt=Nt[0],Ct=Nt[1],St=(0,d.useState)(null),kt=(0,c.A)(St,2),At=kt[0],It=kt[1],Tt=(0,d.useState)(null),Dt=(0,c.A)(Tt,2),Rt=Dt[0],_t=Dt[1],Pt=(0,d.useState)(null),Ot=(0,c.A)(Pt,2),Mt=Ot[0],Ft=Ot[1],Kt=(0,d.useState)(!1),jt=(0,c.A)(Kt,2),qt=jt[0],Lt=jt[1],Ut=(0,d.useState)(!1),Vt=(0,c.A)(Ut,2),Bt=Vt[0],zt=Vt[1],Wt=(0,d.useState)(!1),Ht=(0,c.A)(Wt,2),Gt=Ht[0],Jt=Ht[1],Zt=(0,d.useState)(!1),Yt=(0,c.A)(Zt,2),Xt=Yt[0],Qt=Yt[1],$t=(0,d.useState)({name:"",expirationDate:"",scope:"revenue_apis",environment:"Development",environmentId:"",environmentName:""}),en=(0,c.A)($t,2),tn=en[0],nn=en[1],an=(0,d.useState)({name:"",displayName:"",environmentType:J.OX.NonProduction}),rn=(0,c.A)(an,2),sn=rn[0],on=rn[1],ln=(0,d.useState)("POST"),cn=(0,c.A)(ln,2),mn=cn[0],un=cn[1],dn=(0,d.useState)(!1),pn=(0,c.A)(dn,2),gn=pn[0],fn=pn[1],bn=(0,d.useState)(!1),yn=(0,c.A)(bn,2),vn=yn[0],xn=yn[1],hn=(0,d.useState)(null),En=(0,c.A)(hn,2),Nn=En[0],wn=En[1],Cn=(0,d.useState)(null),Sn=(0,c.A)(Cn,2),kn=(Sn[0],Sn[1]),An=(0,d.useState)(!1),In=(0,c.A)(An,2),Tn=In[0],Dn=In[1],Rn=(0,d.useState)([]),_n=(0,c.A)(Rn,2),Pn=(_n[0],_n[1]),On=(0,d.useState)(!1),Mn=(0,c.A)(On,2),Fn=(Mn[0],Mn[1]),Kn=(0,d.useState)({transactions:[],invoices:[],subscriptions:[],"subscription-items":[]}),jn=(0,c.A)(Kn,2),qn=jn[0],Ln=jn[1],Un=(0,d.useState)("transactions"),Vn=(0,c.A)(Un,2),Bn=Vn[0],zn=Vn[1],Wn=(0,d.useState)("transactions"),Hn=(0,c.A)(Wn,2),Gn=Hn[0],Jn=Hn[1],Zn=(0,d.useState)(null),Yn=(0,c.A)(Zn,2),Xn=Yn[0],Qn=Yn[1],$n=(0,d.useState)(!1),ea=(0,c.A)($n,2),ta=ea[0],na=ea[1],aa=(0,d.useState)(!1),ra=(0,c.A)(aa,2),sa=ra[0],oa=ra[1],la=(0,d.useRef)(""),ia=(0,d.useRef)(null),ca=(0,d.useRef)(0),ma=(0,d.useRef)(V),ua=(0,d.useRef)(T);ua.current=T;var da=(0,d.useRef)(null),pa=(0,d.useState)(null),ga=(0,c.A)(pa,2),fa=ga[0],ba=ga[1],ya=(0,d.useRef)(null),va=(0,d.useState)(null),xa=(0,c.A)(va,2),ha=xa[0],Ea=xa[1],Na=(0,G.Ew)({client:Z.AX,fetchPolicy:"no-cache"}),wa=(0,c.A)(Na,2),Ca=wa[0],Sa=wa[1],ka=Sa.data,Aa=Sa.loading,Ia=Sa.error,Ta=(0,G.Qv)({client:Z.AX,fetchPolicy:"no-cache"}),Da=(0,c.A)(Ta,2),Ra=Da[0],_a=Da[1].loading,Pa=(0,J.wi)({client:Z.RB,fetchPolicy:"no-cache"}),Oa=(0,c.A)(Pa,2),Ma=Oa[0],Fa=Oa[1],Ka=Fa.data,ja=Fa.loading,qa=(0,J.WX)({client:Z.RB,fetchPolicy:"no-cache"}),La=(0,c.A)(qa,2),Ua=La[0],Va=La[1].loading,Ba="undefined"!=typeof window&&null!==(t=(0,H.nN)())&&void 0!==t?t:"",za=d.useMemo(function(){if(null==ka||!ka.listKeysV2)return[];var e=ka.listKeysV2.filter(function(e){return Boolean(e&&e.isActive)});return Ba?e.filter(function(e){return e.envId===Ba}):e},[null==ka?void 0:ka.listKeysV2,Ba]),Wa=d.useMemo(function(){if(!za.length)return{};var e={};return za.forEach(function(t){t&&t.isActive&&(e[t.envName.toLowerCase()]=t.key)}),e},[za]),Ha=function(e){return new Date(e).toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!0})};(0,d.useLayoutEffect)(function(){ma.current=V},[V]);var Ga=(0,d.useCallback)(function(){var e="".concat(Bn,"-").concat(mn),t=e,n=++ca.current;if(la.current===e){if(!L.includes("api")||"api"!==V)return console.log("API not selected or not active tab, skipping WebSocket connection"),void(la.current="");ia.current&&Za();var a=function(){var e,t,n=(0,H.J1)(),a=Mt?null==ka||null===(e=ka.listKeysV2)||void 0===e||null===(e=e.find(function(e){return(null==e?void 0:e.id)===Mt}))||void 0===e?void 0:e.envId:null;if(!n||!a)return console.error("Missing productId or environmentId for health check"),null;var r=null===(t="https://api.app.thrivestack.ai")?void 0:t.replace("https://","wss://"),s="invoices"===Bn?"INVOICE":"subscriptions"===Bn?"SUBSCRIPTION":"subscription-items"===Bn?"SUBSCRIPTION_ITEM":"TRANSACTION",o="PUT"===mn?"UPDATE":"DELETE"===mn?"DELETE":"CREATE";return"".concat(r,"/ws/revenueApiSetupEvents?productId=").concat(n,"&environmentId=").concat(a,"&recordType=").concat(s,"&operationType=").concat(o)}();if(!a)return console.error("Could not construct WebSocket URL"),void(la.current="");console.log("Creating WebSocket connection for ".concat(e,":"),a),ia.current=ne
1w WebSocket(a),ia.current.onopen=function(){console.log("WebSocket opened for ".concat(e)),Dn(!0),kn(ia.current)},ia.current.onmessage=function(e){ca.current===n&&Ja(e.data,t)},ia.current.onerror=function(t){console.error("WebSocket error for ".concat(e,":"),t),Dn(!1)},ia.current.onclose=function(t){console.log("WebSocket closed for ".concat(e,":"),t.code,t.reason),Dn(!1),kn(null),ia.current=null,la.current===e&&(la.current="")}}else console.log("Connection key mismatch, skipping connection for ".concat(e))},[L,V,Mt,ka,Bn,mn]),Ja=function(){var e=(0,s.A)(u().mark(function e(t,n){var a,r,s,o,c,m;return u().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,a=JSON.parse(t),console.log("WebSocket message:",a),a&&a.revenue_events&&Array.isArray(a.revenue_events)){e.next=1;break}return console.log("No revenue_events found in message"),e.abrupt("return");case 1:a.revenue_events.length>0&&(r=function(e){switch(e){case"TRANSACTION":return"transactions";case"INVOICE":return"invoices";case"SUBSCRIPTION":return"subscriptions";case"SUBSCRIPTION_ITEM":return"subscription-items";default:return null}},s={},a.revenue_events.forEach(function(e){var t=r(null==e?void 0:e.record_type);if(t){var n=Qe(Qe({},e),{},{type:e.record_type||"UNKNOWN",name:e.operation_type||"",timestamp:e.timestamp||(new Date).toISOString(),id:e.id||Math.random().toString(36).substr(2,9),originalData:function(){try{var t=e.data||e.payload||e;if("string"==typeof t&&t.startsWith("{")){var n=JSON.parse(t);return JSON.stringify(n,null,2)}return JSON.stringify(t,null,2)}catch(t){return JSON.stringify(e,null,2)}}()});s[t]||(s[t]=[]),s[t].push(n)}}),Ln(function(e){var t=Qe({},e);return Object.keys(s).forEach(function(n){var a,r=null!==(a=s[n])&&void 0!==a?a:[];t[n]=[].concat((0,l.A)(r),(0,l.A)(e[n])).slice(0,5)}),t}),Pn(function(e){return[].concat((0,l.A)(e),(0,l.A)(a.revenue_events))}),a.revenue_events.some(function(e){return"COMPLETED"===e.processing_status})&&(o=ue.current,c=Qe(Qe({},o),{},(0,i.A)({},n,!0)),ue.current=c,c["transactions-POST"]&&c["invoices-POST"]&&c["subscriptions-POST"]&&c["subscription-items-POST"]&&Rt&&Mt&&ie("api",Qe(Qe({},B.api),{},{status:"configured",completed:!0,completedAt:(new Date).toISOString()})),me(c),Fn(!0),Za())),e.next=3;break;case 2:e.prev=2,m=e.catch(0),console.error("Error parsing WebSocket message:",m);case 3:case"end":return e.stop()}},e,null,[[0,2]])}));return function(t,n){return e.apply(this,arguments)}}();(0,d.useEffect)(function(){Ln(function(e){return Qe(Qe({},e),{},(0,i.A)({},Bn,[]))})},[Bn]),(0,d.useLayoutEffect)(function(){if(da.current){var e=da.current.getBoundingClientRect().height;ba(e)}},[z]),(0,d.useLayoutEffect)(function(){if(ya.current){var e=ya.current.getBoundingClientRect().height;Ea(e)}},[Bn]);var Za=(0,d.useCallback)(function(){console.log("closeSocketConnection called, socketRef.current:",ia.current),ia.current?(console.log("Closing WebSocket connection, readyState:",ia.current.readyState),ia.current.readyState!==WebSocket.OPEN&&ia.current.readyState!==WebSocket.CONNECTING||ia.current.close(),ia.current=null,ca.current+=1,Dn(!1),kn(null),la.current="",console.log("WebSocket connection closed and state updated")):console.log("No socket to close")},[]);(0,d.useEffect)(function(){var e="".concat(Bn,"-").concat(mn);if(la.current!==e||!Tn){if(L.includes("api")&&"api"===V&&Mt&&(null==ka?void 0:ka.listKeysV2)){console.log("Starting WebSocket for ".concat(e)),ia.current&&Za(),la.current=e;var t=setTimeout(function(){Ga()},1e3);return function(){clearTimeout(t)}}"api"!==V&&Tn&&(console.log("Switched away from API tab - stopping WebSocket"),Za(),la.current="")}},[L,V,Mt,ka,Bn,mn,Ga,Za]),(0,d.useEffect)(function(){var e=function(){Za()},t=function(){"hidden"===document.visibilityState&&Za()};return window.addEventListener("beforeunload",e),document.addEventListener("visibilitychange",t),function(){window.removeEventListener("beforeunload",e),document.removeEventListener("visibilitychange",t),Za()}},[Za]);var Ya=null!==(n=null==D?void 0:D.selectedApiKeyId)&&void 0!==n?n:null,Xa=null!==(a=null==D?void 0:D.selectedApiKey)&&void 0!==a?a:null;(0,d.useEffect)(function(){var e=za;if(e.length){var t=function(e){e.selectedApiKeyId===Ya&&e.selectedApiKey===Xa||ua.current(e)};if(Rt){e.some(function(e){return e&&e.key===Rt}
1)||(_t(null),Ft(null),t({selectedApiKeyId:null,selectedApiKey:null}))}else{if(Ya){var n=e.find(function(e){return e&&e.id===Ya});if(n)return _t(n.key),Ft(n.id),void t({selectedApiKeyId:n.id,selectedApiKey:n.key})}1===e.length&&e[0]&&(_t(e[0].key),Ft(e[0].id),t({selectedApiKeyId:e[0].id,selectedApiKey:e[0].key}))}}},[za,Rt,Ya,Xa]),(0,d.useEffect)(function(){tr()},[]),(0,d.useEffect)(function(){return function(){Za()}},[Za]);var Qa="object"===(0,r.A)(null==B?void 0:B.api)?JSON.stringify({baseUrl:B.api.baseUrl,authType:B.api.authType,credentials:B.api.credentials,endpoints:B.api.endpoints}):"";(0,d.useEffect)(function(){if(null!=B&&B.api){var e=B.api;_e(e.baseUrl||""),Me(e.authType||"bearer"),qe(e.credentials||{}),Ve(e.endpoints||{})}},[Qa]);var $a="object"===(0,r.A)(null==B?void 0:B.salesforce)?JSON.stringify({instanceUrl:B.salesforce.instanceUrl,username:B.salesforce.username,password:B.salesforce.password,securityToken:B.salesforce.securityToken}):"";(0,d.useEffect)(function(){if(null!=B&&B.salesforce){var e=B.salesforce;et(e.instanceUrl||""),rt(e.username||""),it(e.password||""),dt(e.securityToken||"")}},[$a]),(0,d.useEffect)(function(){be.current=be.current.slice(0,p.length)},[p.length]);var er=(null!==(o=null==L?void 0:L.length)&&void 0!==o?o:0)>0?(L||[]).slice().sort().join(","):"";(0,d.useEffect)(function(){L.length>0&&!V&&le(L[0]),V&&!L.includes(V)&&le(L[0]||"")},[er,V,le]),(0,d.useEffect)(function(){if(W.some(function(e){return null!=e})&&I){var e=W.filter(function(e){return null!=e});e.filter(function(e){return e.success}).length,e.filter(function(e){return!e.success}).length,e.filter(function(e){return e.success&&e.errorRows>0}).length;I()}},[W]),(0,d.useEffect)(function(){Ya&&null!=ka&&ka.listKeysV2&&!Nn&&(wn(Ya),xn(!1))},[Ya,null==ka?void 0:ka.listKeysV2,Nn]),(0,d.useEffect)(function(){var e,t,n;if(z>=0&&re[z]){Ct(0);var a=80/3500*50;e=setInterval(function(){Ct(function(n){var r=n+a;return r>=80?(clearInterval(e),t=setInterval(function(){Ct(function(e){var t=e+.1;return Math.min(t,99)})},50),80):r})},50)}else wt>0&&wt<100&&z>=0&&!re[z]&&(t&&clearInterval(t),n=setTimeout(function(){Ct(100),setTimeout(function(){Ct(0)},2e3)},300));return function(){e&&clearInterval(e),t&&clearInterval(t),n&&clearTimeout(n)}},[z,re]);var tr=function(){var e=(0,s.A)(u().mark(function e(){var t;return u().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=1,Ca({variables:{input:{productId:(0,H.J1)(),scope:"revenue_apis",status:"active"}}
1});case 1:e.next=3;break;case 2:e.prev=2,t=e.catch(0),console.error("Failed to fetch API keys:",t);case 3:case"end":return e.stop()}},e,null,[[0,2]])}));return function(){return e.apply(this,arguments)}}(),nr=function(){var e=(0,s.A)(u().mark(function e(t){var n,a;return u().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,!(n=Wa[t])){e.next=2;break}return e.next=1,navigator.clipboard.writeText(n);case 1:It(t),setTimeout(function(){return It(null)},2e3);case 2:e.next=4;break;case 3:e.prev=3,a=e.catch(0),console.error("Failed to copy API key:",a);case 4:case"end":return e.stop()}},e,null,[[0,3]])}));return function(t){return e.apply(this,arguments)}}(),ar=function(){var e=(0,s.A)(u().mark(function e(){var t;return u().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=1,Ma({variables:{input:{productId:(0,H.J1)()}}});case 1:e.next=3;break;case 2:e.prev=2,t=e.catch(0),console.error("Failed to fetch environments:",t);case 3:zt(!0);case 4:case"end":return e.stop()}},e,null,[[0,2]])}));return function(){return e.apply(this,arguments)}}(),rr=function(){var e=(0,s.A)(u().mark(function e(){var t,n,a,r,s;return u().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(tn.name&&tn.expirationDate&&tn.environmentId){e.next=1;break}return e.abrupt("return");case 1:return e.prev=1,n=new Date(tn.expirationDate).getTime()/1e3,e.next=2,Ra({variables:{input:{productId:(0,H.J1)(),name:tn.name,scopes:["revenue_apis"],validTill:Math.floor(n),envId:tn.environmentId,envName:tn.environmentName,sbId:(0,H.NK)()}}});case 2:if(a=e.sent,null===(t=a.data)||void 0===t||!t.createAPIKeyV2){e.next=4;break}return e.next=3,tr();case 3:(r=a.data.createAPIKeyV2)&&(_t(r.key),Ft(r.id),xn(!0),T({selectedApiKeyId:r.id,selectedApiKey:r.key})),zt(!1),nn({name:"",expirationDate:"",scope:"revenue_apis",environment:"Development",environmentId:"",environmentName:""}),e.next=5;break;case 4:console.error("Failed to create API key");case 5:e.next=7;break;case 6:e.prev=6,s=e.catch(1),console.error("Error creating API key:",s);case 7:case"end":return e.stop()}},e,null,[[1,6]])}));return function(){return e.apply(this,arguments)}}(),sr=function(){zt(!1),Jt(!1),Qt(!1),nn({name:"",expirationDate:"",scope:"revenue_apis",environment:"Development",environmentId:"",environmentName:""}),on({name:"",displayName:"",environmentType:J.OX.NonProduction})},or=function(){var e=(0,s.A)(u().mark(function e(){var t,n,a;return u().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(sn.displayName){e.next=1;break}return e.abrupt("return");case 1:return e.prev=1,e.next=2,Ua({variables:{input:{name:sn.displayName.toLowerCase().replace(/\s+/g,"-"),displayName:sn.displayName,environmentType:sn.environmentType}}});case 2:if(n=e.sent,null===(t=n.data)||void 0===t||null===(t=t.createEnvironmentCA)||void 0===t||!t.isSuccess){e.next=4;break}return on({name:"",displayName:"",environmentType:J.OX.NonProduction}),Qt(!1),e.next=3,Ma({variables:{input:{productId:(0,H.J1)()}}});case 3:e.next=5;break;case 4:console.error("Failed to create environment");case 5:e.next=7;break;case 6:e.prev=6,a=e.catch(1),console.error("Error creating environment:",a);case 7:case"end":return e.stop()}},e,null,[[1,6]])}));return function(){return e.apply(this,arguments)}}(),lr=function(){Qt(!1),on({name:"",displayName:"",environmentType:J.OX.NonProduction})};(0,d.useEffect)(function(){var e=function(e){var t=e.target;Gt&&!t.closest('[data-dropdown="environment"]')&&Jt(!1),qt&&!t.closest('[data-dropdown="api-key"]')&&Lt(!1)};return document.addEventListener("mousedown",e),function(){document.removeEventListener("mousedown",e)}},[Gt,qt]);var ir=function(){L.includes("salesforce")&&ie("salesforce",{status:$e&&at&<&&ut?"configured":"in_progress",instanceUrl:$e,username:at,password:lt,securityToken:ut})};if(0===L.length)return d.createElement("div",{className:"text-center py-12"},d.createElement("div",{className:"text-gray-500"},"No data sources selected. Please go back to select your data sources."));var cr=(0,M.rk)(U,p),mr=(0,M.Hu)(U,p),ur=function(){null===(e=B.api)||void 0===e||e.completed;var e,t,n,a,r,o=(r=Rt||"<Your API Key with Revenue APIs Scope>",{transactions:{GET:"curl -X GET ".concat(X.S.REVENUE,'/transactions \\\n -H "x-api-key: ').concat(r,'" \\\n -H "Content-Type: application/json"'),POST:"curl -X POST ".concat(X.S.REVENUE,'/transactions \\\n -H "x-api-key: ').concat(r,'" \\\n -H "Content-Type: application/json" \\\n -d \'{\n "transaction_id": "txn_123",\n "customer_id": "cust_123", //customer id in your billing system (can be same as group_id)\n "group_id": "group_456", //group_id in product telemetry\n "customer_name": "John Doe",\n "invoice_id": "inv_123",\n "type": "payment", // payment, refund\n "status": "paid", // paid, cancelled, failed, refund, charged_back\n "transaction_date": "2024-01-15T14:30:00Z",\n "amount": 99.99,\n "currency": "USD", // USD, EUR, GBP | Default: USD\n "payment_method": "credit_card", // credit_card, paypal, stripe\n "transaction_fee": 2.99,\n "tax_amount": 5.00,\n "discount_amount": 10.00,\n "term_frequency": 1,\n "term_unit": "month", // day, week, month, year | Default: month\n "period_start_date": "2024-01-01T00:00:00Z",\n "period_end_date": "2024-01-31T23:59:59Z",\n "line_item_type": "subscription" // Must be "subscription" for recurring revenue or "one_time" for setup or any professional charges\n }\''),PUT:"curl -X PUT ".concat(X.S.REVENUE,'/transactions \\\n -H "x-api-key: ').concat(r,'" \\\n -H "Content-Type: application/json" \\\n -d \'{\n "transaction_id": "txn_123",\n "status": "paid", // paid, cancelled, failed, refund, charged_back\n "type": "payment", // payment, refund\n "date": "2024-01-20T10:30:00Z",\n "amount": 149.99,\n "currency": "USD", // USD, EUR, GBP | Default: USD\n "payment_method": "credit_card", // credit_card, paypal, stripe\n "transaction_fee": 3.50,\n "tax_amount": 7.50,\n "discount_amount": 15.00,\n "term_frequency": 1, // Default: 1\n "term_unit": "month", // day, week, month, year | Default: month\n "period_start_date": "2024-01-01T00:00:00Z",\n "period_end_date": "2024-01-31T23:59:59Z",\n "line_item_type": "subscription" // Must be "subscription" for recurring revenue or "one_time" for setup or any professional charges\n }\''),DELETE:"curl -X DELETE ".concat(X.S.REVENUE,"/transactions \\\n -H 'x-api-key: ").concat(r,"' \\\n -H 'Content-Type: application/json' \\\n -d '{\n \"transaction_id\": \"txn_123\"\n }'")},invoices:{GET:"curl -X GET ".concat(X.S.REVENUE,'/invoices \\\n -H "x-api-key: ').concat(r,'" \\\n -H "Content-Type: application/json"'),POST:"curl -X POST ".concat(X.S.REVENUE,'/invoices \\\n -H "x-api-key: ').concat(r,'" \\\n -H "Content-Type: application/json" \\\n -d \'{\n "invoice_id": "inv_123",\n "customer_id": "cust_123", //customer id in your billing system\n "group_id": "group_123", //group_id in product telemetry\n "issue_date": "2024-01-15T00:00:00Z",\n "amount": 299.99,\n "currency": "USD", // USD, EUR, GBP | Default: USD\n "due_date": "2024-02-15T00:00:00Z" //optional\n }\''),PUT:"curl -X PUT ".concat(X.S.REVENUE,'/invoices \\\n -H "x-api-key: ').concat(r,'" \\\n -H "Content-Type: application/json" \\\n -d \'{\n "invoice_id": "inv_123",\n "issue_date": "2024-01-15T00:00:00Z",\n "amount": 349.99,\n "currency": "USD", // USD, EUR, GBP | Default: USD\n "due_date": "2024-02-15T00:00:00Z"\n }\''),DELETE:"curl -X DELETE ".concat(X.S.REVENUE,"/invoices \\\n -H 'x-api-key: ").concat(r,"' \\\n -H 'Content-Type: application/json' \\\n -d '{\n \"invoice_id\": \"inv_123\"\n }'")},subscriptions:{POST:"curl -X POST ".concat(X.S.REVENUE,'/subscriptions \\\n -H "x-api-key: ').concat(r,'" \\\n -H "Content-Type: application/json" \\\n -d \'{\n "subscription_id": "sub_123",\n "customer_id": "cust_123",\n "group_id": "group_456",\n "status": "active",\n "currency": "USD",\n "start_date": "2024-01-15T00:00:00Z",\n "ended_at": "2025-01-15T00:00:00Z",\n "trial_start_date": "2024-01-01T00:00:00Z",\n "trial_end_date": "2024-01-14T23:59:59Z",\n "current_period_start": "2024-01-15T00:00:00Z",\n "current_period_end": "2024-02-14T23:59:59Z",\n "cancelled_at": null,\n "cancellation_comment": "",\n "create_date": "2024-01-15T00:00:00Z",\n "updated_date": "2024-01-15T00:00:00Z"\n }\''),PUT:"curl -X PUT ".concat(X.S.REVENUE,'/subscriptions \\\n -H "x-api-key: ').concat(r,'" \\\n -H "Content-Type: application/json" \\\n -d \'{\n "subscription_id": "sub_123",\n "status": "cancelled",\n "currency": "USD",\n "current_period_start": "2024-01-15T00:00:00Z",\n "current_period_end": "2024-02-14T23:59:59Z",\n "cancelled_at": "2024-02-01T12:00:00Z",\n "ended_at": "2024-02-01T12:00:00Z",\n "cancellation_comment": "Customer requested cancellation",\n "updated_date": "2024-02-01T12:00:00Z"\n }\''),DELETE:"curl -X DELETE ".concat(X.S.REVENUE,'/subscriptions \\\n -H "x-api-key: ').concat(r,'" \\\n -H "Content-Type: application/json" \\\n -d \'{\n "subscription_id": "sub_123"\n }\'')},"subscription-items":{POST:"curl -X POST ".concat(X.S.REVENUE,'/subscription-items \\\n -H "x-api-key: ').concat(r,'" \\\n -H "Content-Type: application/json" \\\n -d \'{\n "subscription_item_id": "si_123",\n "subscription_id": "sub_123",\n "customer_id": "cust_123",\n "plan_id": "plan_pro_monthly",\n "price_id": "price_123",\n "term_unit": "month",\n "term_frequency": "1",\n "start_date": "2024-01-15T00:00:00Z",\n "status": "active",\n "created_date": "2024-01-15T00:00:00Z",\n "ended_at": "2025-01-15T00:00:00Z",\n "quantity": 1,\n "trial_start_date": "2024-01-01T00:00:00Z",\n "trial_end_date": "2024-01-14T23:59:59Z",\n "cancelled_at": null,\n "current_period_start": "2024-01-15T00:00:00Z",\n "current_period_end": "2024-02-14T23:59:59Z",\n "updated_date": "2024-01-15T00:00:00Z"\n }\''),PUT:"curl -X PUT ".concat(X.S.REVENUE,'/subscription-items \\\n -H "x-api-key: ').concat(r,'" \\\n -H "Content-Type: application/json" \\\n -d \'{\n "subscription_item_id": "si_123",\n "subscription_id": "sub_123",\n "plan_id": "plan_pro_monthly",\n "price_id": "price_456",\n "term_unit": "month",\n "term_frequency": "1",\n "start_date": "2024-01-15T00:00:00Z",\n "status": "active",\n "quantity": 2,\n "current_period_start": "2024-01-15T00:00:00Z",\n "current_period_end": "2024-02-14T23:59:59Z",\n "updated_date": "2024-02-01T00:00:00Z"\n }\''),DELETE:"curl -X DELETE ".concat(X.S.REVENUE,'/subscription-items \\\n -H "x-api-key: ').concat(r,'" \\\n -H "Content-Type: application/json" \\\n -d \'{\n "subscription_item_id": "si_123"\n }\'')}}
1),l=o[Bn][mn],i=function(){var e=(0,s.A)(u().mark(function e(){var t;return u().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=1,navigator.clipboard.writeText(l);case 1:fn(!0),setTimeout(function(){return fn(!1)},2e3),e.next=3;break;case 2:e.prev=2,t=e.catch(0),console.error("Failed to copy:",t);case 3:case"end":return e.stop()}},e,null,[[0,2]])}));return function(){return e.apply(this,arguments)}}();return Aa?d.createElement("div",{className:"space-y-6"},d.createElement("div",{className:"bg-white border border-gray-200 rounded-lg p-6"},d.createElement("div",{className:"flex items-center justify-center py-12"},d.createElement("div",{className:"flex flex-col items-center space-y-4"},d.createElement(y.Loader2,{className:"w-8 h-8 text-blue-600 animate-spin"}),d.createElement("p",{className:"text-gray-600"},"Loading API configuration..."))))):d.createElement("div",{className:"space-y-6"},d.createElement("div",{className:"space-y-6"},d.createElement("div",{className:"border border-gray-200 rounded-lg p-6"},d.createElement("div",{className:"bg-white rounded-lg"},d.createElement("div",{className:"flex items-center justify-between mb-6"},d.createElement("h3",{className:"text-lg font-semibold text-gray-900"},"API Keys"),d.createElement("div",{className:"flex items-center space-x-3"},d.createElement("button",{onClick:function(){return Qt(!0)},className:"text-blue-600 hover:text-blue-700 font-medium text-sm"},"+ Add Environment"),d.createElement("button",{onClick:ar,className:"text-blue-600 hover:text-blue-700 font-medium text-sm"},"+ Create API Key"))),d.createElement("div",{className:"flex flex-col ms-6"},!Aa&&!Ia&&0===za.length&&d.createElement("div",{className:"text-center py-6"},d.createElement("div",{className:"bg-gray-50 border border-gray-200 rounded-lg p-6"},d.createElement("div",{className:"w-12 h-12 bg-gray-100 rounded-full flex items-center justify-center mx-auto mb-3"},d.createElement(y.Database,{className:"w-6 h-6 text-gray-400"})),d.createElement("h4",{className:"text-md font-medium text-gray-900 mb-2"},"No API Keys Found"),d.createElement("p",{className:"text-gray-600 text-sm"},"No API keys found for the current environment with scope ",d.createElement("span",{className:"font-mono bg-gray-100 px-2 py-1 rounded text-xs"},"Revenue APIs")),d.createElement("button",{onClick:ar,className:"text-blue-600 hover:text-blue-700 font-medium text-sm mt-6"},"+ Create API Key"))),!Aa&&!Ia&&za.length>0&&d.createElement("div",null,d.createElement("label",{className:"block text-sm font-medium text-gray-700 mb-2"},"Select API Key"),d.createElement("div",{className:"relative mb-6","data-dropdown":"api-key"},d.createElement("button",{type:"button",onClick:function(){return Lt(!qt)},className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent bg-white text-left flex items-center justify-between"},d.createElement("div",{className:"flex items-center space-x-3 flex-1 min-w-0"},d.createElement("div",{className:"flex-1 min-w-0"},d.createElement("div",{className:"text-sm font-medium text-gray-900 truncate"},Rt&&(null===(t=za.find(function(e){return(null==e?void 0:e.key)===Rt}))||void 0===t?void 0:t.name)||"Select API Key"),d.createElement("div",{className:"text-xs text-gray-500 font-mono truncate"},Rt?"".concat(Rt.substring(0,8),"...").concat(Rt.substring(Rt.length-8)):"No API key selected")),d.createElement("button",{type:"button",onClick:function(e){if(e.stopPropagation(),e.preventDefault(),Rt){var t,n,a=null!==(t=null===(n=za.find(function(e){return e&&e.key===Rt}))||void 0===n||null===(n=n.envName)||void 0===n?void 0:n.toLowerCase())&&void 0!==t?t:"";nr(a)}},className:"text-gray-400 hover:text-gray-600 transition-colors p-1",disabled:!Rt},At===(null===(n=za.find(function(e){return e&&e.key===Rt}))||void 0===n||null===(n=n.envName)||void 0===n?void 0:n.toLowerCase())?d.createElement(y.CheckCircle,{className:"w-4 h-4 text-green-600"}):d.createElement(y.Copy,{className:"w-4 h-4"}))),d.createElement("div",{className:"flex items-center space-x-2 ml-2"},Rt&&d.createElement("span",{className:"inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium bg-blue-100 text-blue-800"},null===(a=za.find(function(e){return e&&e.key===Rt}))||void 0===a?void 0:a.envName),d.createElement(y.ChevronDown,{className:"w-4 h-4 text-gray-400 transition-transform ".concat(qt?"rotate-180":"")}))),qt&&d.createElement("div",{className:"absolute z-20 w-full mt-1 bg-white border border-gray-300 rounded-md shadow-lg"},d.createElement("div",{className:"py-1"},za.map(function(e){if(!e)return null;var t=Rt===e.key;return d.createElement("button",{key:e.id,type:"button",onClick:function(){_t(e.key),Ft(e.id),Lt(!1);var t=e.id!==Nn;xn(t),T({selectedApiKeyId:e.id,selectedApiKey:e.key})},className:"w-full px-3 py-2 text-left hover:bg-blue-50 hover:text-blue-900 flex items-center justify-between ".concat(t?"bg-blue-50 text-blue-900":"")},d.createElement("div",{className:"flex items-center space-x-3 flex-1 min-w-0"},d.createElement("div",{className:"flex-1 min-w-0"},d.createElement("div",{className:"text-sm font-medium truncate"},e.name),d.createElement("div",{className:"text-xs text-gray-500 font-mono truncate"},e.key?"".concat(e.key.substring(0,8),"...").concat(e.key.substring(e.key.length-8)):"No key available")),d.createElement("button",{onClick:function(t){t.stopPropagation(),nr(e.envName.toLowerCase())},className:"text-gray-400 hover:text-gray-600 transition-colors p-1"}
1,At===e.envName.toLowerCase()?d.createElement(y.CheckCircle,{className:"w-4 h-4 text-green-600"}):d.createElement(y.Copy,{className:"w-4 h-4"}))),d.createElement("div",{className:"flex items-center space-x-2 ml-2"},d.createElement("span",{className:"inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium bg-gray-100 text-gray-800"},e.envName),t&&d.createElement(y.CheckCircle,{className:"w-4 h-4 text-blue-600"})))}),d.createElement("div",{className:"border-t border-gray-200"},d.createElement("button",{type:"button",onClick:function(){Lt(!1),ar()},className:"w-full px-3 py-2 text-left text-sm text-blue-600 hover:bg-blue-50 hover:text-blue-700 flex items-center space-x-2"},d.createElement("span",{className:"text-lg"},"+"),d.createElement("span",null,"Create API Key"))))))),vn&&d.createElement("div",{className:"my-4 p-3 bg-yellow-50 border rounded-lg"},d.createElement("div",{className:"flex items-center space-x-2"},d.createElement(y.AlertTriangle,{className:"w-4 h-4 text-yellow-600"}),d.createElement("span",{className:"text-yellow-800 text-sm font-medium"},'API key has been changed. Click "Confirm Changes" after completing steps to save the new selection.'))),Ia&&d.createElement("div",{className:"mt-4 p-3 bg-red-50 border border-red-200 rounded-lg"},d.createElement("p",{className:"text-red-700 text-sm"},"Failed to load API keys. Please try again or contact support."),d.createElement("button",{onClick:tr,className:"mt-2 text-red-600 hover:text-red-800 text-sm font-medium"},"Retry")),d.createElement(ee.Y,{title:"Know more about API Key",content:d.createElement("ul",{className:"space-y-2"},d.createElement("li",{key:1,className:"text-sm text-amber-800 flex items-start"},d.createElement("span",{className:"mr-2"},"â¢"),d.createElement("span",null,"Your selected API key for the Revenue Analytics is included in the script below.")),d.createElement("li",{key:2,className:"text-sm text-amber-800 flex items-start"},d.createElement("span",{className:"mr-2"},"â¢"),d.createElement("span",null,"Store it in a configuration file to easily switch keys between different environments.")),d.createElement("li",{key:3,className:"text-sm text-amber-800 flex items-start"},d.createElement("span",{className:"mr-2"},"â¢"),d.createElement("span",null,"You can generate separate API keys for production and other environments above.")))}))),d.createElement("div",{className:"mt-8"},d.createElement("div",{className:"relative"},d.createElement("div",{className:"absolute left-5 w-0.5 bg-gray-300",style:{to
1p:"4rem",bottom:ha?"".concat(ha,"px"):"2rem"}}),d.createElement("div",{className:"space-y-4 relative z-10 ml-10"},d.createElement("div",{className:"border border-gray-200 rounded-lg ".concat("transactions"===Gn?"bg-blue-50":"bg-white")},d.createElement("button",{type:"button",onClick:function(){var e="transactions"===Gn?null:"transactions";Jn(e),"transactions"===e&&zn("transactions")},className:"w-full flex items-center justify-between p-4 text-left hover:bg-gray-50 transition-colors"},d.createElement("div",{className:"flex items-center gap-4"},d.createElement("div",{className:"absolute -left-10 w-8 h-8 bg-blue-500 font-semibold border-2 text-white flex-shrink-0 flex items-center justify-center rounded-full text-sm z-10"},"1"),d.createElement("div",null,d.createElement("div",{className:"font-semibold text-gray-900"},"Transaction"),d.createElement("div",{className:"text-sm text-gray-500"},"API endpoint for sending Transaction data"))),d.createElement("div",{className:"flex items-center gap-2"},d.createElement("span",{className:"px-3 py-1 rounded-full text-xs font-medium ".concat(se["transactions-POST"]?"bg-green-50 text-green-800":"bg-gray-100 text-gray-600")},se["transactions-POST"]?"Complete":"Pending"),d.createElement(y.ChevronDown,{className:"w-4 h-4 text-gray-400 transition-transform ".concat("transactions"===Gn?"rotate-180":"")}))),"transactions"===Gn&&d.createElement("div",{className:"border-t border-gray-200 p-6 bg-white"},d.createElement("div",{className:"bg-gray-50 rounded-lg p-4 relative overflow-x-auto"},d.createElement("div",{className:"flex items-center justify-between mb-4"},d.createElement("div",{className:"flex space-x-1"},[{method:"POST",label:"CREATE"},{method:"PUT",label:"UPDATE"},{method:"DELETE",label:"DELETE"}].map(function(e){var t=e.method,n=e.label;return d.createElement("button",{key:t,onClick:function(){return un(t)},className:"px-3 py-1 text-sm font-medium rounded transition-colors ".concat(mn===t?"bg-primaryColor text-white":"bg-gray-100 text-gray-700 hover:bg-gray-200")},n)})),d.createElement("button",{onClick:i,className:"flex items-center space-x-1 px-2 py-1 text-xs text-gray-600 hover:text-gray-900 transition-colors",title:"Copy to clipboard"},gn?d.createElement(d.Fragment,null,d.createElement(y.CheckCircle,{className:"w-3 h-3 text-green-600"}),d.createElement("span",{className:"text-green-600"},"Copied!")):d.createElement(d.Fragment,null,d.createElement(y.Copy,{className:"w-3 h-3"}),d.createElement("span",null,"Copy")))),d.createElement(Q.Prism,{language:"javascript",style:$,customStyle:{fontSize:"0.875rem",background:"#f9fafb",borderRadius:".5rem",padding:"1rem",maxWidth:"100%",overflowX:"auto"},codeTagProps:{style:{fontFamily:"Menlo, monospace"}}},o.transactions[mn])),d.createElement("div",{className:"bg-amber-50 border rounded-lg p-3 mt-4"},d.createElement("p",{className:"text-amber-900 text-sm"},"Use the above create cURL commands to send events to complete the Step.")),d.createElement("div",{className:"mt-4 p-4 border rounded-lg bg-blue-50"},d.createElement("div",{className:"flex items-center space-x-2 mb-2"},d.createElement("span",{className:"flex items-center justify-center w-6 h-6"},se["transactions-POST"]?d.createElement(y.CheckCircle,{className:"w-6 h-6 text-green-600 font-bold"}):d.createElement(y.Loader2,{className:"w-6 h-6 text-blue-500 animate-spin font-bold",strokeWidth:4})),d.createElement("span",{className:"font-medium ".concat(se["transactions-POST"]?"text-green-700":"text-blue-700")},se["transactions-POST"]?"Transaction events detected successfully":"Waiting for events...")),"transactions"===Gn&&qn.transactions.length>0&&d.createElement("div",{className:"mt-4 transition-all duration-500 ease-out opacity-100 transform translate-y-0"},d.createElement("div",{className:"bg-white rounded-lg border border-blue-200 p-4 ms-8"},d.createElement("div",{className:"flex items-center space-x-2 mb-4"},d.createElement(y.Activity,{className:"w-5 h-5 text-blue-600"}),d.createElement("h4",{className:"font-medium text-blue-800"},"Recent Transaction Events")),d.createElement("div",{className:"overflow-x-auto"},d.createElement("table",{className:"w-full"},d.createElement("thead",null,d.createElement("tr",{className:"bg-gray-50 text-left"},d.createElement("th",{className:"px-4 py-2 text-sm font-medium text-gray-600"},"Event Type"),d.createElement("th",{className:"px-4 py-2 text-sm font-medium text-gray-600"},"Operation"),d.createElement("th",{className:"px-4 py-2 text-sm font-medium text-gray-600"},"Status"),d.createElement("th",{className:"px-4 py-2 text-sm font-medium text-gray-600"},"Timestamp"),d.createElement("th",{className:"px-4 py-2 text-sm font-medium text-gray-600"},"Data"))),d.createElement("tbody",null,qn.transactions.map(function(e,t){return d.createElement("tr",{key:"".concat(e.id,"-").concat(t),style:{opacity:0,transform:"translateY(20px)",animation:"fade-in-up 0.5s ease-out ".concat(.1*t,"s forwards")}},d.createElement("td",{className:"px-4 py-3"},d.createElement("div",{className:"flex items-center space-x-2"},d.createElement(y.Activity,{className:"w-4 h-4 text-blue-600"}),d.createElement("span",{className:"font-medium text-gray-900"},e.record_type))),d.createElement("td",{className:"px-4 py-3"},d.createElement("span",{className:"font-medium text-gray-900"},e.operation_type||"-")),d.createElement("td",{className:"px-4 py-3"},d.createElement("span",{className:"px-2 py-1 rounded-full text-xs font-medium ".concat("COMPLETED"===e.processing_status?"bg-green-50 text-green-800":"FAILED"===e.processing_status?"bg-red-500 text-red-800":"bg-yellow-100 text-yellow-800")},e.processing_status||"PENDING")),d.createElement("td",{className:"px-4 py-3 text-gray-600"},Ha(e.timestamp)),d.createElement("td",{className:"px-4 py-3"},d.createElement("button",{onClick:function(){Qn(e.originalData),na(!0)},className:"text-blue-600 hover:text-blue-800 font-mono text-sm px-2 py-1 hover:bg-blue-50 transition-colors",title:"View original JSON data"},"...")))}))))))))),d.createElement("div",{className:"border border-gray-200 rounded-lg ".concat("invoices"===Gn?"bg-blue-50":"bg-white"),ref:"invoices"===Bn?ya:null},d.createElement("button",{type:"button",onClick:function(){var e="invoices"===Gn?null:"invoices";Jn(e),"invoices"===e&&zn("invoices")},className:"w-full flex items-center justify-between p-4 text-left hover:bg-gray-50 transition-colors"},d.createElement("div",{className:"flex items-center gap-4"},d.createElement("div",{className:"absolute -left-10 w-8 h-8 bg-blue-500 font-semibold border-2 text-white flex-shrink-0 flex items-center justify-center rounded-full text-sm z-10"},"2"),d.createElement("div",null,d.createElement("div",{className:"font-semibold text-gray-900"},"Invoice"),d.createElement("div",{className:"text-sm text-gray-500"},"API endpoint for sending Invoice data"))),d.createElement("div",{className:"flex items-center gap-2"},d.createElement("span",{className:"px-3 py-1 rounded-full text-xs font-medium ".concat(se["invoices-POST"]?"bg-green-50 text-green-800":"bg-gray-100 text-gray-600")},se["invoices-POST"]?"Complete":"Pending"),d.createElement(y.ChevronDown,{className:"w-4 h-4 text-gray-400 transition-transform ".concat("invoices"===Gn?"rotate-180":"")}))),"invoices"===Gn&&d.createElement("div",{className:"border-t border-gray-200 p-6 bg-white"},d.createElement("div",{className:"bg-gray-50 rounded-lg p-4 relative overflow-x-auto"},d.createElement("div",{className:"flex items-center justify-between mb-4"},d.createElement("div",{className:"flex space-x-1"},[{method:"POST",label:"CREATE"},{method:"PUT",label:"UPDATE"},{method:"DELETE",label:"DELETE"}].map(function(e){var t=e.method,n=e.label;return d.createElement("button",{key:t,onClick:function(){return un(t)},className:"px-3 py-1 text-sm font-medium rounded transition-colors ".concat(mn===t?"bg-primaryColor text-white":"bg-gray-100 text-gray-700 hover:bg-gray-200")},n)})),d.createElement("button",{onClick:i,className:"flex items-center space-x-1 px-2 py-1 text-xs text-gray-600 hover:text-gray-900 transition-colors",title:"Copy to clipboard"}
1,gn?d.createElement(d.Fragment,null,d.createElement(y.CheckCircle,{className:"w-3 h-3 text-green-600"}),d.createElement("span",{className:"text-green-600"},"Copied!")):d.createElement(d.Fragment,null,d.createElement(y.Copy,{className:"w-3 h-3"}),d.createElement("span",null,"Copy")))),d.createElement(Q.Prism,{language:"javascript",style:$,customStyle:{fontSize:"0.875rem",background:"#f9fafb",borderRadius:".5rem",padding:"1rem",maxWidth:"100%",overflowX:"auto"},codeTagProps:{style:{fontFamily:"Menlo, monospace"}}},o.invoices[mn])),d.createElement("div",{className:"bg-amber-50 border rounded-lg p-3 mt-4"},d.createElement("p",{className:"text-amber-900 text-sm"},"Use the above create cURL commands to send events to complete the Step.")),d.createElement("div",{className:"mt-4 p-4 border rounded-lg bg-blue-50"},d.createElement("div",{className:"flex items-center space-x-2 mb-2"},d.createElement("span",{className:"flex items-center justify-center w-6 h-6"},se["invoices-POST"]?d.createElement(y.CheckCircle,{className:"w-6 h-6 text-green-600 font-bold"}):d.createElement(y.Loader2,{className:"w-6 h-6 text-blue-500 animate-spin font-bold",strokeWidth:4})),d.createElement("span",{className:" font-medium ".concat(se["invoices-POST"]?"text-green-700":"text-blue-700")},se["invoices-POST"]?"Invoice events detected successfully":"Waiting for events...")),"invoices"===Gn&&qn.invoices.length>0&&d.createElement("div",{className:"mt-4 transition-all duration-500 ease-out opacity-100 transform translate-y-0"},d.createElement("div",{className:"bg-white rounded-lg border border-blue-200 p-4 ms-8"},d.createElement("div",{className:"flex items-center space-x-2 mb-4"},d.createElement(y.Activity,{className:"w-5 h-5 text-blue-600"}),d.createElement("h4",{className:"font-medium text-blue-800"},"Recent Invoice Events")),d.createElement("div",{className:"overflow-x-auto"},d.createElement("table",{className:"w-full"},d.createElement("thead",null,d.createElement("tr",{className:"bg-gray-50 text-left"},d.createElement("th",{className:"px-4 py-2 text-sm font-medium text-gray-600"},"Event Type"),d.createElement("th",{className:"px-4 py-2 text-sm font-medium text-gray-600"},"Operation"),d.createElement("th",{className:"px-4 py-2 text-sm font-medium text-gray-600"},"Status"),d.createElement("th",{className:"px-4 py-2 text-sm font-medium text-gray-600"},"Timestamp"),d.createElement("th",{className:"px-4 py-2 text-sm font-medium text-gray-600"},"Data"))),d.createElement("tbody",null,qn.invoices.map(function(e,t){return d.createElement("tr",{key:"".concat(e.id,"-").concat(t),style:{opacity:0,transform:"translateY(20px)",animation:"fade-in-up 0.5s ease-out ".concat(.1*t,"s forwards")}},d.createElement("td",{className:"px-4 py-3"},d.createElement("div",{className:"flex items-center space-x-2"},d.createElement(y.Activity,{className:"w-4 h-4 text-blue-600"}),d.createElement("span",{className:"font-medium text-gray-900"},e.record_type))),d.createElement("td",{className:"px-4 py-3"},d.createElement("span",{className:"font-medium text-gray-900"},e.operation_type||"-")),d.createElement("td",{className:"px-4 py-3"},d.createElement("span",{className:"px-2 py-1 rounded-full text-xs font-medium ".concat("COMPLETED"===e.processing_status?"bg-green-50 text-green-800":"FAILED"===e.processing_status?"bg-red-500 text-red-800":"bg-yellow-100 text-yellow-800")},e.processing_status||"PENDING")),d.createElement("td",{className:"px-4 py-3 text-gray-600"},Ha(e.timestamp)),d.createElement("td",{className:"px-4 py-3"},d.createElement("button",{onClick:function(){Qn(e.originalData),na(!0)},className:"text-blue-600 hover:text-blue-800 font-mono text-sm px-2 py-1 hover:bg-blue-50 transition-colors",title:"View original JSON data"},"...")))}))))))))),d.createElement("div",{className:"border border-gray-200 rounded-lg ".concat("subscriptions"===Gn?"bg-blue-50":"bg-white"),ref:"subscriptions"===Bn?ya:null},d.createElement("button",{type:"button",onClick:function(){var e="subscriptions"===Gn?null:"subscriptions";Jn(e),"subscriptions"===e&&zn("subscriptions")},className:"w-full flex items-center justify-between p-4 text-left hover:bg-gray-50 transition-colors"},d.createElement("div",{className:"flex items-center gap-4"},d.createElement("div",{className:"absolute -left-10 w-8 h-8 bg-blue-500 font-semibold border-2 text-white flex-shrink-0 flex items-center justify-center rounded-full text-sm z-10"},"3"),d.createElement("div",null,d.createElement("div",{className:"font-semibold text-gray-900"},"Subscription"),d.createElement("div",{className:"text-sm text-gray-500"},"API endpoint for sending Subscription data"))),d.createElement("div",{className:"flex items-center gap-2"},d.createElement("span",{className:"px-3 py-1 rounded-full text-xs font-medium ".concat(se["subscriptions-POST"]?"bg-green-50 text-green-800":"bg-gray-100 text-gray-600")},se["subscriptions-POST"]?"Complete":"Pending"),d.createElement(y.ChevronDown,{className:"w-4 h-4 text-gray-400 transition-transform ".concat("subscriptions"===Gn?"rotate-180":"")}))),"subscriptions"===Gn&&d.createElement("div",{className:"border-t border-gray-200 p-6 bg-white"},d.createElement("div",{className:"bg-gray-50 rounded-lg p-4 relative overflow-x-auto"},d.createElement("div",{className:"flex items-center justify-between mb-4"},d.createElement("div",{className:"flex space-x-1"},[{method:"POST",label:"CREATE"},{method:"PUT",label:"UPDATE"},{method:"DELETE",label:"DELETE"}].map(function(e){var t=e.method,n=e.label;return d.createElement("button",{key:t,onClick:function(){return un(t)},className:"px-3 py-1 text-sm font-medium rounded transition-colors ".concat(mn===t?"bg-primaryColor text-white":"bg-gray-100 text-gray-700 hover:bg-gray-200")},n)})),d.createElement("button",{onClick:i,className:"flex items-center space-x-1 px-2 py-1 text-xs text-gray-600 hover:text-gray-900 transition-colors",title:"Copy to clipboard"}
1,gn?d.createElement(d.Fragment,null,d.createElement(y.CheckCircle,{className:"w-3 h-3 text-green-600"}),d.createElement("span",{className:"text-green-600"},"Copied!")):d.createElement(d.Fragment,null,d.createElement(y.Copy,{className:"w-3 h-3"}),d.createElement("span",null,"Copy")))),d.createElement(Q.Prism,{language:"javascript",style:$,customStyle:{fontSize:"0.875rem",background:"#f9fafb",borderRadius:".5rem",padding:"1rem",maxWidth:"100%",overflowX:"auto"},codeTagProps:{style:{fontFamily:"Menlo, monospace"}}},o.subscriptions[mn])),d.createElement("div",{className:"bg-amber-50 border rounded-lg p-3 mt-4"},d.createElement("p",{className:"text-amber-900 text-sm"},"Use the above create cURL commands to send events to complete the Step.")),d.createElement("div",{className:"mt-4 p-4 border rounded-lg bg-blue-50"},d.createElement("div",{className:"flex items-center space-x-2 mb-2"},d.createElement("span",{className:"flex items-center justify-center w-6 h-6"},se["subscriptions-POST"]?d.createElement(y.CheckCircle,{className:"w-6 h-6 text-green-600 font-bold"}):d.createElement(y.Loader2,{className:"w-6 h-6 text-blue-500 animate-spin font-bold",strokeWidth:4})),d.createElement("span",{className:" font-medium ".concat(se["subscriptions-POST"]?"text-green-700":"text-blue-700")},se["subscriptions-POST"]?"Subscription events detected successfully":"Waiting for events...")),"subscriptions"===Gn&&qn.subscriptions.length>0&&d.createElement("div",{className:"mt-4 transition-all duration-500 ease-out opacity-100 transform translate-y-0"},d.createElement("div",{className:"bg-white rounded-lg border border-blue-200 p-4 ms-8"},d.createElement("div",{className:"flex items-center space-x-2 mb-4"},d.createElement(y.Activity,{className:"w-5 h-5 text-blue-600"}),d.createElement("h4",{className:"font-medium text-blue-800"},"Recent Subscription Events")),d.createElement("div",{className:"overflow-x-auto"},d.createElement("table",{className:"w-full"},d.createElement("thead",null,d.createElement("tr",{className:"bg-gray-50 text-left"},d.createElement("th",{className:"px-4 py-2 text-sm font-medium text-gray-600"},"Event Type"),d.createElement("th",{className:"px-4 py-2 text-sm font-medium text-gray-600"},"Operation"),d.createElement("th",{className:"px-4 py-2 text-sm font-medium text-gray-600"},"Status"),d.createElement("th",{className:"px-4 py-2 text-sm font-medium text-gray-600"},"Timestamp"),d.createElement("th",{className:"px-4 py-2 text-sm font-medium text-gray-600"},"Data"))),d.createElement("tbody",null,qn.subscriptions.map(function(e,t){return d.createElement("tr",{key:"".concat(e.id,"-").concat(t),style:{opacity:0,transform:"translateY(20px)",animation:"fade-in-up 0.5s ease-out ".concat(.1*t,"s forwards")}},d.createElement("td",{className:"px-4 py-3"},d.createElement("div",{className:"flex items-center space-x-2"},d.createElement(y.Activity,{className:"w-4 h-4 text-blue-600"}),d.createElement("span",{className:"font-medium text-gray-900"},e.record_type))),d.createElement("td",{className:"px-4 py-3"},d.createElement("span",{className:"font-medium text-gray-900"},e.operation_type||"-")),d.createElement("td",{className:"px-4 py-3"},d.createElement("span",{className:"px-2 py-1 rounded-full text-xs font-medium ".concat("COMPLETED"===e.processing_status?"bg-green-50 text-green-800":"FAILED"===e.processing_status?"bg-red-500 text-red-800":"bg-yellow-100 text-yellow-800")},e.processing_status||"PENDING")),d.createElement("td",{className:"px-4 py-3 text-gray-600"},Ha(e.timestamp)),d.createElement("td",{className:"px-4 py-3"},d.createElement("button",{onClick:function(){Qn(e.originalData),na(!0)},className:"text-blue-600 hover:text-blue-800 font-mono text-sm px-2 py-1 hover:bg-blue-50 transition-colors",title:"View original JSON data"},"...")))}))))))))),d.createElement("div",{className:"border border-gray-200 rounded-lg ".concat("subscription-items"===Gn?"bg-blue-50":"bg-white"),ref:"subscription-items"===Bn?ya:null},d.createElement("button",{type:"button",onClick:function(){var e="subscription-items"===Gn?null:"subscription-items";Jn(e),"subscription-items"===e&&zn("subscription-items")},className:"w-full flex items-center justify-between p-4 text-left hover:bg-gray-50 transition-colors"},d.createElement("div",{className:"flex items-center gap-4"},d.createElement("div",{className:"absolute -left-10 w-8 h-8 bg-blue-500 font-semibold border-2 text-white flex-shrink-0 flex items-center justify-center rounded-full text-sm z-10"},"4"),d.createElement("div",null,d.createElement("div",{className:"font-semibold text-gray-900"},"Subscription Items"),d.createElement("div",{className:"text-sm text-gray-500"},"API endpoint for sending Subscription Items data"))),d.createElement("div",{className:"flex items-center gap-2"},d.createElement("span",{className:"px-3 py-1 rounded-full text-xs font-medium ".concat(se["subscription-items-POST"]?"bg-green-50 text-green-800":"bg-gray-100 text-gray-600")},se["subscription-items-POST"]?"Complete":"Pending"),d.createElement(y.ChevronDown,{className:"w-4 h-4 text-gray-400 transition-transform ".concat("subscription-items"===Gn?"rotate-180":"")}))),"subscription-items"===Gn&&d.createElement("div",{className:"border-t border-gray-200 p-6 bg-white"},d.createElement("div",{className:"bg-gray-50 rounded-lg p-4 relative overflow-x-auto"},d.createElement("div",{className:"flex items-center justify-between mb-4"},d.createElement("div",{className:"flex space-x-1"},[{method:"POST",label:"CREATE"},{method:"PUT",label:"UPDATE"},{method:"DELETE",label:"DELETE"}].map(function(e){var t=e.method,n=e.label;return d.createElement("button",{key:t,onClick:function(){return un(t)},className:"px-3 py-1 text-sm font-medium rounded transition-colors ".concat(mn===t?"bg-primaryColor text-white":"bg-gray-100 text-gray-700 hover:bg-gray-200")},n)})),d.createElement("button",{onClick:i,className:"flex items-center space-x-1 px-2 py-1 text-xs text-gray-600 hover:text-gray-900 transition-colors",title:"Copy to clipboard"}
1,gn?d.createElement(d.Fragment,null,d.createElement(y.CheckCircle,{className:"w-3 h-3 text-green-600"}),d.createElement("span",{className:"text-green-600"},"Copied!")):d.createElement(d.Fragment,null,d.createElement(y.Copy,{className:"w-3 h-3"}),d.createElement("span",null,"Copy")))),d.createElement(Q.Prism,{language:"javascript",style:$,customStyle:{fontSize:"0.875rem",background:"#f9fafb",borderRadius:".5rem",padding:"1rem",maxWidth:"100%",overflowX:"auto"},codeTagProps:{style:{fontFamily:"Menlo, monospace"}}},o["subscription-items"][mn])),d.createElement("div",{className:"bg-amber-50 border rounded-lg p-3 mt-4"},d.createElement("p",{className:"text-amber-900 text-sm"},"Use the above create cURL commands to send events to complete the Step.")),d.createElement("div",{className:"mt-4 p-4 border rounded-lg bg-blue-50"},d.createElement("div",{className:"flex items-center space-x-2 mb-2"},d.createElement("span",{className:"flex items-center justify-center w-6 h-6"},se["subscription-items-POST"]?d.createElement(y.CheckCircle,{className:"w-6 h-6 text-green-600 font-bold"}):d.createElement(y.Loader2,{className:"w-6 h-6 text-blue-500 animate-spin font-bold",strokeWidth:4})),d.createElement("span",{className:" font-medium ".concat(se["subscription-items-POST"]?"text-green-700":"text-blue-700")},se["subscription-items-POST"]?"Subscription Item events detected successfully":"Waiting for events...")),"subscription-items"===Gn&&qn["subscription-items"].length>0&&d.createElement("div",{className:"mt-4 transition-all duration-500 ease-out opacity-100 transform translate-y-0"},d.createElement("div",{className:"bg-white rounded-lg border border-blue-200 p-4 ms-8"},d.createElement("div",{className:"flex items-center space-x-2 mb-4"},d.createElement(y.Activity,{className:"w-5 h-5 text-blue-600"}),d.createElement("h4",{className:"font-medium text-blue-800"},"Recent Subscription Item Events")),d.createElement("div",{className:"overflow-x-auto"},d.createElement("table",{className:"w-full"},d.createElement("thead",null,d.createElement("tr",{className:"bg-gray-50 text-left"},d.createElement("th",{className:"px-4 py-2 text-sm font-medium text-gray-600"},"Event Type"),d.createElement("th",{className:"px-4 py-2 text-sm font-medium text-gray-600"},"Operation"),d.createElement("th",{className:"px-4 py-2 text-sm font-medium text-gray-600"},"Status"),d.createElement("th",{className:"px-4 py-2 text-sm font-medium text-gray-600"},"Timestamp"),d.createElement("th",{className:"px-4 py-2 text-sm font-medium text-gray-600"},"Data"))),d.createElement("tbody",null,qn["subscription-items"].map(function(e,t){return d.createElement("tr",{key:"".concat(e.id,"-").concat(t),style:{opacity:0,transform:"translateY(20px)",animation:"fade-in-up 0.5s ease-out ".concat(.1*t,"s forwards")}},d.createElement("td",{className:"px-4 py-3"},d.createElement("div",{className:"flex items-center space-x-2"},d.createElement(y.Activity,{className:"w-4 h-4 text-blue-600"}),d.createElement("span",{className:"font-medium text-gray-900"},e.record_type))),d.createElement("td",{className:"px-4 py-3"},d.createElement("span",{className:"font-medium text-gray-900"},e.operation_type||"-")),d.createElement("td",{className:"px-4 py-3"},d.createElement("span",{className:"px-2 py-1 rounded-full text-xs font-medium ".concat("COMPLETED"===e.processing_status?"bg-green-50 text-green-800":"FAILED"===e.processing_status?"bg-red-500 text-red-800":"bg-yellow-100 text-yellow-800")},e.processing_status||"PENDING")),d.createElement("td",{className:"px-4 py-3 text-gray-600"},Ha(e.timestamp)),d.createElement("td",{className:"px-4 py-3"},d.createElement("button",{onClick:function(){Qn(e.originalData),na(!0)},className:"text-blue-600 hover:text-blue-800 font-mono text-sm px-2 py-1 hover:bg-blue-50 transition-colors",title:"View original JSON data"},"...")))})))))))))),d.createElement("style",null,"\n @keyframes fade-in-up {\n from {\n opacity: 0;\n transform: translateY(20px);\n }\n to {\n opacity: 1;\n transform: translateY(0);\n }\n }\n "))))))},dr=function(e){var t=p[e],n=g[e],a=ne[e],r=ae[e],s=W[e],o=re[e],l=t.fields.required,i=t.fields.optional,c=N(e),m=l.every(function(e){return r[e.fieldName]});return d.createElement("div",{className:"space-y-6"},d.createElement("div",{className:"rounded-lg p-3 bg-amber-50 text-amber-900"},d.createElement("div",{className:"flex items-start space-x-3"}
1,d.createElement(y.Download,{className:"w-5 h-4 mt-1 text-amber-900"}),d.createElement("div",{className:"flex"},d.createElement("h3",{className:"font-medium"},"Need a sample file?"),d.createElement("button",{onClick:function(){return(0,te.VQ)(t.sampleFileName,U)},className:"ml-1 font-medium text-sm underline",style:{color:"#2563eb"},onMouseOver:function(e){return e.currentTarget.style.color="#1d4ed8"},onMouseOut:function(e){return e.currentTarget.style.color="#2563eb"}},"Download Sample Data")))),d.createElement("div",{className:"border-2 border-dashed border-gray-300 rounded-lg p-8 text-center hover:border-gray-400 transition-colors"},d.createElement("input",{ref:E,type:"file",accept:".csv",onChange:function(t){return v(e,t)},className:"hidden"}),d.createElement(y.Upload,{className:"w-12 h-12 text-gray-400 mx-auto mb-4"}),d.createElement("p",{className:"text-gray-600 mb-4"},"Drop your CSV file here or click to browse"),d.createElement("button",{onClick:function(){var e;return null===(e=E.current)||void 0===e?void 0:e.click()},style:{background:"#2563eb",color:"#ffffff"},className:"px-6 py-2 rounded-lg transition-colors",onMouseOver:function(e){return e.currentTarget.style.background="#1d4ed8"},onMouseOut:function(e){return e.currentTarget.style.background="#2563eb"}},"Choose File")),n&&d.createElement("div",{className:"border rounded-lg p-4"},d.createElement("div",{className:"flex items-center space-x-2"},"error"===c?d.createElement(y.AlertTriangle,{className:"w-5 h-5 text-red-600"}):d.createElement(y.CheckCircle,{className:"w-5 h-5 text-green-600"}),d.createElement("span",{className:"font-medium ms-6 ".concat("error"===c?"text-red-600":"text-green-800")},"error"===c?"File uploaded with errors":"File uploaded successfully")),d.createElement("p",{className:"text-sm mt-1 ms-[26px] border border-gray-50 ".concat("error"===c?"text-red-600":"text-green-700")},n.name," (",(n.size/1024).toFixed(1)," KB)")),n&&a.length>0&&d.createElement("div",{ref:function(t){f.current&&(f.current[e]=t)},className:"space-y-6"},d.createElement("div",{className:"text-center"},d.createElement("h3",{className:"text-lg font-semibold text-gray-900 mb-2"},"Map Your Fields"),d.createElement("p",{className:"text-gray-600"},"Map your CSV columns to the required and optional fields")),l.length>0&&d.createElement("div",{className:"space-y-4"},d.createElement("h4",{className:"font-medium text-gray-900 text-sm flex items-center"},d.createElement("span",{className:"mr-1"},"*"),"Required Fields"),l.map(function(t){return d.createElement("div",{key:t.fieldName,className:"border rounded-lg p-4"},d.createElement("div",{className:"flex items-start justify-between"},d.createElement("div",{className:"flex-1"},d.createElement("h3",{className:"font-medium text-gray-900"},t.fieldName," ",d.createElement("span",{className:"text-lg mr-1"},"*")),d.createElement("p",{className:"text-sm text-gray-600 mt-1"},t.description)),d.createElement("div",{className:"ml-4"},d.createElement("select",{value:r[t.fieldName]||"",onChange:function(n){return x(e,t.fieldName,n.target.value)},className:"block w-48 px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500"},d.createElement("option",{value:""},"Select a field..."),a.map(function(e){return d.createElement("option",{key:e,value:e},e)})))))})),i.length>0&&d.createElement("div",{className:"space-y-4"},d.createElement("h4",{className:"font-medium text-gray-900 text-sm flex items-center"},d.createElement("span",{className:"inline-block w-2 h-2 rounded-full mr-2"}),"Optional Fields"),i.map(function(t){return d.createElement("div",{key:t.fieldName,className:"border border-gray-200 rounded-lg p-4"},d.createElement("div",{className:"flex items-start justify-between"},d.createElement("div",{className:"flex-1"},d.createElement("h3",{className:"font-medium text-gray-900"},t.fieldName),d.createElement("p",{className:"text-sm text-gray-600 mt-1"},t.description)),d.createElement("div",{className:"ml-4"},d.createElement("select",{value:r[t.fieldName]||"",onChange:function(n){return x(e,t.fieldName,n.target.value)},className:"block w-48 px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500"},d.createElement("option",{value:""},"Select a field (optional)..."),a.map(function(e){return d.createElement("option",{key:e,value:e},e)})))))})),d.createElement("div",{className:"bg-amber-50 border text-amber-900 rounded-lg p-4"},d.createElement("h4",{className:"font-medium mb-2"},"Mapping Summary"),d.createElement("div",{className:"text-sm space-y-1"},d.createElement("div",null,"Required fields mapped: ",l.filter(function(e){return r[e.fieldName]}).length," / ",l.length),d.createElement("div",null,"Optional fields mapped: ",i.filter(function(e){return r[e.fieldName]}).length," / ",i.length))),d.createElement("div",{className:"flex gap-4 justify-end"},o&&d.createElement("div",{className:"bg-blue-50 border border-blue-200 rounded-lg p-3"},d.createElement("div",{className:"flex items-center space-x-2"},d.createElement("div",{className:"w-4 h-4 rounded-full bg-blue-500 flex items-center justify-center"},d.createElement("span",{className:"text-white text-xs"},"â¹")),d.createElement("div",{className:"flex-1"},d.createElement("div",{className:"mb-3"},d.createElement("div",{className:"flex justify-between items-center mb-1"},d.createElement("span",{className:"text-xs text-blue-700 font-medium"},"Processing..."),d.createElement("span",{className:"text-xs text-blue-700"},Math.round(wt),"%")),d.createElement("div",{className:"w-full bg-blue-200 rounded-full h-2"},d.createElement("div",{className:"bg-blue-600 h-2 rounded-full transition-all duration-200 ease-out",style:{width:"".concat(wt,"%")}}))),d.createElement("span",{className:"text-blue-800 text-sm font-medium"},"You can proceed to upload other data while this processes.")))),d.createElement("button",{ref:function(t){b.current&&(b.current[e]=t)},onClick:function(){return function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];Ce(e),Te(t),he(!0)}(e,"error"===c)},disabled:o||!m,className:"flex items-center space-x-2 px-6 py-2 rounded-lg font-medium transition-colors ".concat(o||!m?"cursor-not-allowed":""),style:{background:o||!m?"#d1d5db":"error"===c?"#dc2626":"#2563eb",color:o||!m?"#6b7280":"#ffffff"},onMouseOver:function(e){!o&&m&&(e.currentTarget.style.background="error"===c?"#b91c1c":"#1d4ed8")},onMouseOut:function(e){!o&&m&&(e.currentTarget.style.background="error"===c?"#dc2626":"#2563eb")}},S(c,o),!o&&d.createElement(y.ArrowRight,{className:"w-4 h-4"})))),w(s,e))};return d.createElement("div",{className:"space-y-6 ms-10"},d.createElement(Y,{isOpen:xe,onClose:function(){return he(!1)},onConfirm:function(){null!==we&&(Ae?k(we):h(we)),he(!1),Ce(null),Te(!1)},onEdit:function(){he(!1),Ce(null),Te(!1)},subStep:null!==we?p[we]:null,fieldMapping:null!==we?ae[we]:{},isRetry:Ae}),function(){switch(V){case"csv":return d.createElement("div",{className:"space-y-6 overflow-y-auto"},d.createElement("div",{className:"relative"},cr.length>1&&d.createElement("div",{className:"absolute left-5 w-0.5 bg-gray-300",style:{to
1p:"4.3rem",bottom:fa?"".concat(fa-10,"px"):"4rem"}}),d.createElement("div",{className:"bg-white rounded-lg shadow-sm border border-gray-200 relative z-10 ml-10"},cr.map(function(e,t){var n=p.findIndex(function(t){return t.key===e.key}),a=z===n,r=N(n),s=C(r),o=mr.includes(e.key);return d.createElement("div",{key:e.key,ref:t===cr.length-1?da:null,className:"border-b border-gray-200 last:border-b-0 ".concat(a?"bg-blue-50":"")},d.createElement("button",{type:"button",ref:function(e){be.current[n]=e},onClick:function(){ce(a?-1:n)},className:"w-full flex items-center justify-between p-4 text-left hover:bg-gray-50 transition-colors"},d.createElement("div",{className:"flex items-center gap-4"},d.createElement("div",{className:"absolute -left-10 w-8 h-8 bg-blue-500 font-semibold border-2 text-white flex-shrink-0 flex items-center justify-center rounded-full text-sm z-10"},t+1),d.createElement("div",null,d.createElement("div",{className:"flex items-center gap-2 mb-2"},d.createElement("div",{className:"font-semibold text-gray-900"},e.title),o?d.createElement("span",{className:"inline-flex items-center px-2 py-1 rounded-full text-xs font-medium bg-red-50 text-red-800 h-5"},"Required"):d.createElement("span",{className:"inline-flex items-center px-2 py-1 rounded-full text-xs font-medium bg-gray-100 text-gray-600"},"Optional")),d.createElement("div",{className:"text-sm text-gray-500 me-2"},e.description))),d.createElement("div",{className:"flex items-center gap-2"},d.createElement("span",{className:"px-3 py-1 rounded-full text-xs font-medium ".concat(s.color)},s.label),d.createElement(y.ChevronDown,{className:"w-4 h-4 text-gray-400 transition-transform ".concat(a?"rotate-180":"")}))),a&&d.createElement("div",{className:"border-t border-gray-200 p-6 bg-white"},dr(n)))}))));case"api":return ur();case"stripe":return d.createElement(Ie,{sourceConfigurations:B,updateSourceConfiguration:ie,loadedStripeData:oe,selectedSources:L[0],config:de,setConfig:ge,onStepComplete:A,emailManager:R,onAutoSave:I,cleanOAuthParams:_,openSetupGuideRef:F,onOpenIntegrationsList:K,onTrackCompletion:j});case"chargebee":return d.createElement(je,{sourceConfigurations:B,updateSourceConfiguration:ie,loadedChargebeeData:null==B?void 0:B.chargebee,selectedSources:L[0],config:pe,setConfig:fe,onStepComplete:A,emailManager:R,onAutoSave:I,cleanOAuthParams:_,openSetupGuideRef:F,onOpenIntegrationsList:K,onTrackCompletion:j});case"salesforce":return d.createElement("div",{className:"space-y-6"},d.createElement("div",{className:"bg-orange-50 border border-orange-200 rounded-lg p-4"},d.createElement("div",{className:"flex items-start gap-3"},d.createElement(y.Building2,{className:"w-5 h-5 text-orange-600 mt-1"}),d.createElement("div",{className:"flex-1"},d.createElement("h3",{className:"font-medium text-orange-900 mb-2"},"Salesforce Integration"),d.createElement("p",{className:"text-orange-700 text-sm mb-3"},"Connect your Salesforce CRM to import customer and sales data. This integration will provide access to:"),d.createElement("ul",{className:"text-sm text-orange-700 space-y-1"},d.createElement("li",{className:"flex items-center gap-2"},d.createElement("div",{className:"w-1.5 h-1.5 rounded-full bg-orange-600"}),"Account and contact information"),d.createElement("li",{className:"flex items-center gap-2"},d.createElement("div",{className:"w-1.5 h-1.5 rounded-full bg-orange-600"}),"Opportunity and lead data"),d.createElement("li",{className:"flex items-center gap-2"},d.createElement("div",{className:"w-1.5 h-1.5 rounded-full bg-orange-600"}),"Sales pipeline metrics"),d.createElement("li",{className:"flex items-center gap-2"},d.createElement("div",{className:"w-1.5 h-1.5 rounded-full bg-orange-600"}),"Custom objects and fields"))))),d.createElement("div",{className:"bg-white border border-gray-200 rounded-lg p-6"},d.createElement("h3",{className:"font-semibold text-gray-900 mb-4"},"Connection Settings"),d.createElement("div",{className:"space-y-4"},d.createElement("div",{className:"space-y-2"},d.createElement("label",{className:"block text-sm font-medium text-gray-700"},"Instance URL"),d.createElement("input",{type:"text",placeholder:"https://your-org.my.salesforce.com",value:$e,onChange:function(e){return et(e.target.value)},onBlur:ir,className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500"}),d.createElement("p",{className:"text-xs text-gray-500"},"Your Salesforce instance URL (found in your Salesforce setup)")),d.createElement("div",{className:"space-y-2"},d.createElement("label",{className:"block text-sm font-medium text-gray-700"},"Username"),d.createElement("input",{type:"email",placeholder:"[email protected]",value:at,onChange:function(e){return rt(e.target.value)},onBlur:ir,className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500"})),d.createElement("div",{className:"space-y-2"},d.createElement("label",{className:"block text-sm font-medium text-gray-700"},"Password"),d.createElement("div",{className:"relative"},d.createElement("input",{type:ft?"text":"password",placeholder:"Your Salesforce password",value:lt,onChange:function(e){return it(e.target.value)},onBlur:ir,className:"w-full px-3 py-2 pr-10 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500"}),d.createElement("button",{type:"button",className:"absolute right-3 top-1/2 -translate-y-1/2",onClick:function(){return bt(!ft)}},ft?d.createElement(y.EyeOff,{className:"w-4 h-4 text-gray-400"}):d.createElement(y.Eye,{className:"w-4 h-4 text-gray-400"})))),d.createElement("div",{className:"space-y-2"},d.createElement("label",{className:"block text-sm font-medium text-gray-700"},"Security Token"),d.createElement("div",{className:"relative"},d.createElement("input",{type:xt?"text":"password",placeholder:"Your security token",value:ut,onChange:function(e){return dt(e.target.value)},onBlur:ir,className:"w-full px-3 py-2 pr-10 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500"}),d.createElement("button",{type:"button",className:"absolute right-3 top-1/2 -translate-y-1/2",onClick:function(){return ht(!xt)}},xt?d.createElement(y.EyeOff,{className:"w-4 h-4 text-gray-400"}):d.createElement(y.Eye,{className:"w-4 h-4 text-gray-400"}))),d.createElement("p",{className:"text-xs text-gray-500"},"Get your security token from"," ",d.createElement("a",{href:"https://help.salesforce.com/s/articleView?id=sf.user_security_token.htm",target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 hover:underline inline-flex items-center gap-1"},"Salesforce Settings",d.createElement(y.ExternalLink,{className:"w-3 h-3"})))))),d.createElement("div",{className:"bg-white border border-gray-200 rounded-lg p-6"},d.createElement("h3",{className:"font-semibold text-gray-900 mb-4"},"API Access Requirements"),d.createElement("div",{className:"space-y-3 text-sm text-gray-600"},d.createElement("p",null,"To use this integration, ensure your Salesforce org has:"),d.createElement("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-2"},["API access enabled","User has API permissions","Required object permissions","IP address allowlisted (if restricted)"].map(function(e){return d.createElement("div",{key:e,className:"flex items-center gap-2"},d.createElement("div",{className:"w-1.5 h-1.5 rounded-full bg-blue-600"}),d.createElement("span",null,e))})))),d.createElement("div",{className:"bg-white border border-gray-200 rounded-lg p-6"},d.createElement("h3",{className:"font-semibold text-gray-900 mb-4"},"Available Data Objects"),d.createElement("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-2"},["Accounts","Contacts","Opportunities","Leads","Cases","Products","Quotes","Contracts","Campaigns"].map(function(e){return d.createElement("span",{key:e,className:"px-3 py-2 bg-gray-100 text-gray-700 text-sm rounded text-center"},e)}))),d.createElement("div",{className:"bg-white border border-gray-200 rounded-lg p-6"},d.createElement("button",{disabled:!($e&&at&<&&ut),onClick:function(){return console.log("Test Salesforce connection")},className:"px-4 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700 disabled:bg-gray-300 disabled:cursor-not-allowed"},"Test Connection"),d.createElement("p",{className:"text-xs text-gray-500 mt-2"},"Verify your Salesforce credentials and API access")));case"quickbooks":return d.createElement(Ye,{sourceConfigurations:B,updateSourceConfiguration:ie,onStepComplete:A,emailManager:R,onAutoSave:I,cleanOAuthParams:_,openSetupGuideRef:F,onTrackCompletion:j});default:return d.createElement("div",null,"Unknown configuration type")}}(),Bt&&d.createElement("div",{className:"fixed inset-0 bg-gray-600 bg-opacity-50 flex items-center justify-center z-20"},d.createElement("div",{className:"bg-white rounded-lg shadow-xl max-w-md w-full mx-4"},d.createElement("div",{className:"flex items-center justify-between p-6 border-b border-gray-200"},d.createElement("h3",{className:"text-lg font-semibold text-gray-900"},"Create API Key"),d.createElement("button",{onClick:sr,className:"text-gray-400 hover:text-gray-600 transition-colors"},d.createElement(y.X,{className:"w-5 h-5"}))),d.createElement("div",{className:"p-6 space-y-4"},d.createElement("div",null,d.createElement("label",{className:"block text-sm font-medium text-gray-700 mb-1"},"Name ",d.createElement("span",{className:"text-red-500"},"*")),d.createElement("input",{type:"text",value:tn.name,onChange:function(e){return nn(function(t){return Qe(Qe({},t),{},{name:e.target.value})})},className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent",placeholder:"Enter API key name"})),d.createElement("div",null,d.createElement("label",{className:"block text-sm font-medium text-gray-700 mb-1"},"Expiration Date ",d.createElement("span",{className:"text-red-500"},"*")),d.createElement("div",{className:"relative"},d.createElement("input",{type:"date",value:tn.expirationDate,onChange:function(e){return nn(function(t){return Qe(Qe({},t),{},{expirationDate:e.target.value})})},className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent"}),d.createElement(y.Calendar,{className:"absolute right-3 top-2.5 w-4 h-4 text-gray-400 pointer-events-none"}))),d.createElement("div",null,d.createElement("label",{className:"block text-sm font-medium text-gray-700 mb-1"},"Scope of the API Key ",d.createElement("span",{className:"text-red-500"},"*")),d.createElement("div",{className:"relative"},d.createElement("select",{value:tn.scope,disabled:!0,className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent appearance-none bg-gray-100 cursor-not-allowed"},d.createElement("option",{value:"revenue_apis"},"Revenue APIs")),d.createElement(y.ChevronDown,{className:"absolute right-3 top-2.5 w-4 h-4 text-gray-400 pointer-events-none"})),d.createElement("p",{className:"text-xs text-gray-500 mt-1"},"Scope is automatically set to Revenue APIs for this setup")),d.createElement("div",null,d.createElement("label",{className:"block text-sm font-medium text-gray-700 mb-1"},"Environment ",d.createElement("span",{className:"text-red-500"},"*")),d.createElement("div",{className:"relative","data-dropdown":"environment"},d.createElement("button",{type:"button",onClick:function(){return Jt(!Gt)},disabled:ja,className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent bg-white disabled:bg-gray-100 text-left flex items-center justify-between"},d.createElement("span",{className:tn.environmentName?"text-gray-900":"text-gray-500"},tn.environmentName||"Select Environment"),d.createElement(y.ChevronDown,{className:"w-4 h-4 text-gray-400 transition-transform ".concat(Gt?"rotate-180":"")})),Gt&&d.createElement("div",{className:"absolute z-10 w-full mt-1 bg-white border border-gray-300 rounded-md shadow-lg"},d.createElement("div",{className:"py-1"},ja?d.createElement("div",{className:"px-3 py-2 text-sm text-gray-500"},"Loading environments..."):d.createElement(d.Fragment,null,null==Ka||null===(m=Ka.getEnvironmentsForProduct)||void 0===m||null===(m=m.environments)||void 0===m?void 0:m.map(function(e){return d.createElement("button",{key:null==e?void 0:e.id,type:"button",onClick:function(){return function(e){nn(function(t){return Qe(Qe({},t),{},{environmentId:e.id,environmentName:e.displayName,environment:e.displayName})}),Jt(!1)}(e)},className:"w-full px-3 py-2 text-left text-sm hover:bg-blue-50 hover:text-blue-900 flex items-center justify-between"},d.createElement("span",null,null==e?void 0:e.displayName),tn.environmentId===(null==e?void 0:e.id)&&d.createElement(y.CheckCircle,{className:"w-4 h-4 text-blue-600"}))}),d.createElement("div",{className:"border-t border-gray-200"},d.createElement("button",{type:"button",onClick:function(){Jt(!1),Qt(!0)},className:"w-full px-3 py-2 text-left text-sm text-blue-600 hover:bg-blue-50 hover:text-blue-700 flex items-center space-x-2"},d.createElement("span",{className:"text-lg"},"+"),d.createElement("span",null,"New Environment"))))))))),d.createElement("div",{className:"flex items-center justify-end space-x-3 p-6 border-t border-gray-200"},d.createElement("button",{onClick:sr,className:"px-4 py-2 text-sm font-medium text-blue-600 bg-white border border-blue-600 rounded-md hover:bg-blue-50 transition-colors"},"Cancel"),d.createElement("button",{onClick:rr,disabled:!tn.name||!tn.expirationDate||!tn.environmentId||_a,className:"px-4 py-2 text-sm font-medium text-white bg-blue-600 rounded-md hover:bg-blue-700 disabled:bg-gray-300 disabled:cursor-not-allowed transition-colors flex items-center space-x-2"},_a&&d.createElement(y.Loader2,{className:"w-4 h-4 animate-spin"}),d.createElement("span",null,_a?"Creating...":"Create"))))),Xt&&d.createElement("div",{className:"fixed inset-0 bg-gray-600 bg-opacity-50 flex items-center justify-center z-20"},d.createElement("div",{className:"bg-white rounded-lg shadow-xl max-w-md w-full mx-4"},d.createElement("div",{className:"flex items-center justify-between p-6 border-b border-gray-200"},d.createElement("h3",{className:"text-lg font-semibold text-gray-900"},"Create New Environment"),d.createElement("button",{onClick:lr,className:"text-gray-400 hover:text-gray-600 transition-colors"},d.createElement(y.X,{className:"w-5 h-5"}))),d.createElement("div",{className:"p-6 space-y-4"},d.createElement("div",null,d.createElement("label",{className:"block text-sm font-medium text-gray-700 mb-1"},"Environment Name ",d.createElement("span",{className:"text-red-500"},"*")),d.createElement("input",{type:"text",value:sn.displayName,onChange:function(e){return on(function(t){return Qe(Qe({},t),{},{displayName:e.target.value})})},className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent",placeholder:"Enter environment name"})),d.createElement("div",null,d.createElement("label",{className:"block text-sm font-medium text-gray-700 mb-1"},"Environment Type ",d.createElement("span",{className:"text-red-500"},"*")),d.createElement("div",{className:"relative"}
1,d.createElement("select",{value:sn.environmentType,onChange:function(e){return on(function(t){return Qe(Qe({},t),{},{environmentType:e.target.value})})},className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent appearance-none bg-white"},d.createElement("option",{value:J.OX.Production},"Production"),d.createElement("option",{value:J.OX.NonProduction},"NonProduction")),d.createElement(y.ChevronDown,{className:"absolute right-3 top-2.5 w-4 h-4 text-gray-400 pointer-events-none"})))),d.createElement("div",{className:"flex items-center justify-end space-x-3 p-6 border-t border-gray-200"},d.createElement("button",{onClick:lr,className:"px-4 py-2 text-sm font-medium text-blue-600 bg-white border border-blue-600 rounded-md hover:bg-blue-50 transition-colors"},"Cancel"),d.createElement("button",{onClick:or,disabled:!sn.displayName||Va,className:"px-4 py-2 text-sm font-medium text-white bg-blue-600 rounded-md hover:bg-blue-700 disabled:bg-gray-300 disabled:cursor-not-allowed transition-colors flex items-center space-x-2"},Va&&d.createElement(y.Loader2,{className:"w-4 h-4 animate-spin"}),d.createElement("span",null,Va?"Creating...":"Create Environment"))))),ta&&Xn&&d.createElement("div",{className:"fixed inset-0 bg-gray-600 bg-opacity-50 flex items-center justify-center z-30"},d.createElement("div",{className:"bg-white rounded-lg shadow-xl max-w-4xl w-full mx-4 max-h-[80vh] flex flex-col"},d.createElement("div",{className:"flex items-center justify-between p-6 border-b border-gray-200"},d.createElement("h3",{className:"text-lg font-semibold text-gray-900"},"Event JSON Data"),d.createElement("button",{onClick:function(){na(!1),Qn(null),oa(!1)},className:"text-gray-400 hover:text-gray-600 transition-colors"},d.createElement(y.X,{className:"w-5 h-5"}))),d.createElement("div",{className:"flex-1 p-6 overflow-auto"},d.createElement("div",{className:"bg-gray-50 rounded-lg p-4 overflow-auto"},d.createElement("div",{className:"flex items-center justify-between mb-4"},d.createElement("h4",{className:"text-sm font-medium text-gray-700"},"Raw JSON Data"),d.createElement("button",{onClick:(0,s.A)(u().mark(function e(){var t;return u().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=1,navigator.clipboard.writeText(Xn);case 1:oa(!0),setTimeout(function(){return oa(!1)},2e3),e.next=3;break;case 2:e.prev=2,t=e.catch(0),console.error("Failed to copy:",t);case 3:case"end":return e.stop()}},e,null,[[0,2]])})),className:"flex items-center space-x-1 px-2 py-1 text-xs transition-colors border rounded ".concat(sa?"text-green-600 border-green-300 bg-green-50":"text-gray-600 hover:text-gray-900 border-gray-300 hover:bg-gray-100"),title:"Copy to clipboard"},sa?d.createElement(d.Fragment,null,d.createElement(y.CheckCircle,{className:"w-3 h-3 text-green-600"}),d.createElement("span",null,"Copied!")):d.createElement(d.Fragment,null,d.createElement(y.Copy,{className:"w-3 h-3"}),d.createElement("span",null,"Copy")))),d.createElement(Q.Prism,{language:"json",style:$,customStyle:{fontSize:"0.875rem",background:"#f9fafb",borderRadius:".5rem",padding:"1rem",maxHeight:"400px",overflow:"auto"},codeTagProps:{style:{fontFamily:"Menlo, monospace"}}},Xn))),d.createElement("div",{className:"flex items-center justify-end space-x-3 p-6 border-t border-gray-200"},d.createElement("button",{onClick:function(){na(!1),Qn(null),oa(!1)},className:"px-4 py-2 text-sm font-medium text-gray-600 bg-white border border-gray-300 rounded-md hover:bg-gray-50 transition-colors"},"Close")))))};var et=n(85868),tt=n(68431);function nt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,a)}return n}function at(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?nt(Object(n),!0).forEach(function(t){(0,i.A)(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):nt(Object(n)).forEac
1h(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var rt=function(e){return e.Checkbox="checkbox",e.Dropdown="dropdown",e.Radio="radio",e.SingleCheckbox="single-checkbox",e}(rt||{}),st={USD:"$",EUR:"â¬",GBP:"£",CAD:"$",AUD:"$",JPY:"Â¥",CHF:"â£",CNY:"Â¥",INR:"â¹",BRL:"R$",KRW:"â©",SGD:"$",HKD:"$",NZD:"$",SEK:"kr",NOK:"kr",DKK:"kr",PLN:"zÅ",CZK:"KÄ",HUF:"Ft"};const ot=function(e){e.step2UploadedFiles,e.step2CsvHeaders,e.step2SampleRows;var t=e.onComplete,n=e.loadedMrrPlans,a=e.loadedMrrStatuses,r=e.loadedPastDueHandling,s=(e.onGoToDataSetup,e.statusOptions),o=(e.dataSetupIsComplete,e.selectedDataType),i=e.setIsMrrCompleted,m=e.setCsvDetectedStatuses,u=e.includeTax,p=e.onStepComplete,g=e.loadedBaseCurrency,f=e.includeTransactionFees,b=e.setIncludeTransactionFees,v=(e.selectedSources,e.chargebeeFeePerTransaction),x=void 0===v?0:v,h=e.setChargebeeFeePerTransaction,E=e.paymentGatewayFees,N=void 0===E?0:E,C=e.setPaymentGatewayFees,S=(e.paymentGatewayType,e.setPaymentGatewayType,e.selectedPaymentGateway,e.setSelectedPaymentGateway,e.chargebeeChargesPerTxnFee),k=e.setChargebeeChargesPerTxnFee,A=e.activeSourceTab,I=(0,d.useState)([]),T=(0,c.A)(I,2),D=T[0],R=T[1],_=(0,d.useState)([]),O=(0,c.A)(_,2),K=O[0],j=O[1],q=(0,d.useState)("mrr"),L=(0,c.A)(q,2),U=L[0],V=L[1],B=(0,d.useState)(new Set),z=(0,c.A)(B,2),W=z[0],G=z[1],J=(0,d.useState)(!0),Y=(0,c.A)(J,2),X=Y[0],Q=Y[1],$=(0,d.useState)("USD"),te=(0,c.A)($,2),ne=te[0],ae=te[1],re=(0,d.useState)([]),oe=(0,c.A)(re,2),le=oe[0],ie=oe[1],ce=(0,d.useState)([]),me=(0,c.A)(ce,2),ue=me[0],de=me[1],pe=(0,d.useState)(!0),ge=(0,c.A)(pe,2),fe=ge[0],be=ge[1],ye=(0,d.useState)(!1),ve=(0,c.A)(ye,2),xe=(ve[0],ve[1]),he=(0,d.useState)(!1),Ee=(0,c.A)(he,2),Ne=Ee[0],we=Ee[1],Ce=(0,d.useState)(!1),Se=(0,c.A)(Ce,2),ke=Se[0],Ae=Se[1],Ie=(0,tt.w)().isReady,Te=(0,d.useState)(x>0),De=(0,c.A)(Te,2),Re=De[0],_e=De[1],Pe=null!=S?S:Re,Oe=null!=k?k:_e,Me=(0,d.useState)(!1),Fe=(0,c.A)(Me,2),Ke=Fe[0],je=Fe[1],qe=(0,F._K)().isDemoMode,Le=(0,d.useRef)(!1),Ue=["USD","EUR","GBP","CAD","AUD","JPY","CHF","CNY","INR","BRL","KRW","SGD","HKD","NZD","SEK","NOK","DKK","PLN","CZK","HUF"],Ve=(0,se.H2_)({client:Z.k3,fetchPolicy:"no-cache"}),Be=(0,c.A)(Ve,1)[0],ze=(0,se.qAD)({client:Z.k3,fetchPolicy:"no-cache"}),We=(0,c.A)(ze,1)[0],He=(0,P.useSelector)(function(e){if(!Ie)return null;var t=e.modules.find(function(e){return"revenue_analytics"===e.moduleId}),n=null==t?void 0:t.stepDetails.find(function(e){return"data_setup"===e.stepId});if(null==n||!n.value)return null;try{var a,r,s,o,l=null===(a=JSON.parse(n.value).subStepsData)||void 0===a?void 0:a.find(function(e){return"transactions"===e.key});return l?{fieldMapping:l.fieldMapping,taxAmountMapping:(null===(r=l.fieldMapping)||void 0===r?void 0:r["Tax Amount"])||null,currecy:(null===(s=l.fieldMapping)||void 0===s?void 0:s["Transaction Fee"])||null,transactionFees:(null===(o=l.fieldMapping)||void 0===o?void 0:o.Currency)||null,transactionsData:l,hasTransactionData:!!l}:null}catch(e){return console.error("Error parsing data_setup value:",e),null}});(0,d.useEffect)(function(){if(qe)return be(!1),xe(!1),ie(["Basic","Pro","Enterprise"]),void de(["paid","success","pending","failed"]);if(Ie){var e,t,n,a;be(!0),xe(!1),We({variables:{input:{productId:null!==(e=(0,H.J1)())&&void 0!==e?e:"",environmentId:null!==(t=(0,H.nN)())&&void 0!==t?t:""}},onCompleted:function(e){m(e.getTransactionStatus.status)}}),Be({variables:{input:{productId:null!==(n=(0,H.J1)())&&void 0!==n?n:"",environmentId:null!==(a=(0,H.nN)())&&void 0!==a?a:""}},onCompleted:function(e){var t=null==e?void 0:e.getPlanData;if(!t||!t.data||0===t.data.length)return xe(!0),void be(!1);var n=t.data.map(function(e){return e.planName}).filter(Boolean);ie(n),be(!1)},onError:function(e){console.error("Error loading plan data:",e),xe(!0),be(!1)}})}},[Ie,qe]),(0,d.useEffect)(function(){if(!(K.length>0||a&&a.length>0)){var e=s&&s.length>0?s:ue;if(e.length>0){var t=["paid","success"].filter(function(t){return e.includes(t)});t.length>0&&j(t)}}},[s,ue,K,a]),(0,d.useEffect)(function(){W.has("mrr")&&(t(D,K,X,Ne,ne,f),p(!1,{selectedMrrPlans:D,selectedMrrStatuses:K,selectedPastDueHandling:X,includeTax:Ne,baseCurrency:ne,includeTransactionFees:f}))},[W]),(0,d.useEffect)(function(){Le.current||(n&&(null==n?void 0:n.length)>0&&R(n),a&&(null==a?void 0:a.length)>0&&j(a),void 0!==r&&Q(r),void 0!==u&&we(u),g&&ae(g),null!=f&&b(f),Le.current=!0)},[n,a,r,u,g]);var Ge=d.useMemo(function(){var e=[{id:M.lb.PLANS,number:1,title:"Plans to Include in MRR",description:"Choose which subscription plans should be included in MRR calculations",type:rt.Checkbox,options:[],gridCols:3,required:!0}
1,{id:M.lb.BASE_CURRECY,number:2,title:"Select Base Currency",description:"All monetary values in the data will be converted to the base currency. We will convert based on the exchange rate applicable on that date.",type:rt.Dropdown,options:Ue,defaultValue:"USD",required:!0},{id:M.lb.INCLUDE_TAX,number:3,title:"Exclude Tax in MRR Calculations?",description:"We detected that you have mapped a tax column (".concat(null==He?void 0:He.taxAmountMapping,"), which is why we are excluding it by default. Please check this option if you want to exclude tax amounts from your calculations."),checkboxLabel:"Exclude tax amounts from the monthly recurring revenue calculation",type:rt.SingleCheckbox,options:[],defaultValue:!0},{id:M.lb.TRANSACTION_FEES,number:4,title:"Exclude Transaction Fees in MRR Calculations?",description:"chargebee"===A?"Check this option if you want to exclude transaction fees (Chargebee fees + payment gateway fees) from your MRR calculations. You will be able to configure the fee percentages in the next step.":"We detected that you have mapped a transaction fee column (".concat(null==He?void 0:He.transactionFees,"), which is why we are excluding it by default. Please check this option if you want to exclude transaction fees from your calculations."),checkboxLabel:"Exclude transaction fees from the monthly recurring revenue calculation",type:rt.SingleCheckbox,options:[],defaultValue:!0},{id:M.lb.PAST_DUE_HANDLING,number:5,title:"Handling Past-due Subscriptions",description:"Configure how past-due subscriptions should be handled",checkboxLabel:"Past-due subscriptions count towards MRR until cancelled",type:rt.SingleCheckbox,options:[],defaultValue:!0}];M.lb.CHARGEBEE_FEES,rt.Checkbox;return"chargebee"===A||"quickbooks"===A?e.map(function(e,t){return at(at({},e),{},{number:t+1})}):"stripe"!==A?[{id:M.lb.PAYMENT_STATUS,number:1,title:"Payment Status for Revenue Recognition",description:"Select which payment statuses should be considered for revenue calculation",type:rt.Checkbox,options:[],gridCols:2,defaultText:'Default: Only "paid" or "success" status is included'}].concat((0,l.A)(e.map(function(e,t){return at(at({},e),{},{number:t+2})}))):e},[A,He,f]),Je=[{id:"mrr",label:"MRR",labelBgColor:"#dbeafe",labelTextColor:"#1e40af",title:"MRR Configuration",description:"Configure MRR calculation settings",isCompleted:K.length>0,isActive:"mrr"===U,questions:Ge,tip:{title:"What is Monthly Recurring Revenue?",content:d.createElement("div",{className:"text-sm text-amber-800 flex flex-col gap-2"},d.createElement("div",{className:"bg-amber-50 p-3 text-amber-900"},d.createElement("span",{className:"font-medium"})," MRR is the amount of revenue you get from your active customers on a monthly basis. It represents predictable, recurring income from subscriptions or contracts."),d.createElement("div",{className:"ml-4"},d.createElement("strong",null,"Includes:")," Recurring fees only",d.createElement("br",null),d.createElement("strong",null,"Excludes:")," Refunds, one-time charges, setup fees, and taxes"),d.createElement("div",{className:"mt-2 ml-4"},d.createElement("strong",null,"Formula:"),d.createElement("br",null),d.createElement("span",{className:"bg-white border border-amber-200 rounded px-2 py-1 inline-block mt-1"},"MRR = Sum of all active subscription fees for the month")),d.createElement("div",{className:"mt-2 ml-4"},d.createElement("strong",null,"Why it matters:"),d.createElement("br",null),"MRR helps you track predictable revenue, forecast growth, and measure financial health month-over-month.")),icon:d.createElement(y.CheckCircle,{className:"w-4 h-4 text-amber-600 mr-2"}),type:"info",timeout:2e3}}],Ze=function(e){var t="hierarchical"!==o?e.questions.filter(function(e){return e.id===M.lb.PAYMENT_STATUS||e.id===M.lb.INCLUDE_TAX||e.id===M.lb.BASE_CURRECY||e.id===M.lb.TRANSACTION_FEES}):e.questions;return d.createElement("div",{className:"space-y-6"},e.tip&&d.createElement("div",{className:"mb-4"},d.createElement(ee.Y,{title:e.tip.title,content:e.tip.content,icon:e.tip.icon,type:e.tip.type,timeout:e.tip.timeout})),t.map(function(e,t){var n=at(at({},e),{},{number:t+1});return d.createElement("div",{key:e.id},function(e){var t=function(){switch(e.id){case M.lb.PLANS:return le;case M.lb.PAYMENT_STATUS:return s&&s.length>0?s:ue;default:return e.options}},n=function(){switch(e.id){case M.lb.PLANS:return D;case M.lb.PAYMENT_STATUS:return K;case M.lb.BASE_CURRECY:return ne;case M.lb.PAST_DUE_HANDLING:return X;case M.lb.INCLUDE_TAX:return!Ne;case M.lb.TRANSACTION_FEES:return!f;default:return e.defaultValue||[]}},a=function(t){switch(e.id){case M.lb.PLANS:R(Array.isArray(t)?t:[t]);break;case M.lb.PAYMENT_STATUS:j(Array.isArray(t)?t:[t]);break;case M.lb.BASE_CURRECY:ae(t);break;case M.lb.PAST_DUE_HANDLING:Q(t);break;case M.lb.INCLUDE_TAX:we(!Boolean(t));break;case M.lb.TRANSACTION_FEES:b(!Boolean(t))}};return d.createElement("div",{className:"mb-8"},d.createElement("div",{className:"font-semibold text-gray-900 mb-2"},e.number,". ",e.title),d.createElement("p",{className:"text-sm text-gray-600 mb-4 ml-5"},e.description),"checkbox"===e.type&&d.createElement("div",{className:"ml-5 grid grid-cols-1 md:grid-cols-".concat(e.gridCols||3," gap-3")},t().map(function(e){return d.createElement("label",{key:e,className:"flex items-center gap-3 p-3 hover:bg-gray-50 cursor-pointer rounded-lg"},d.createElement("input",{type:"checkbox",checked:!!Array.isArray(n())&&n().includes(e),onChange:function(t){var r=n(),s=Array.isArray(r)?r:[],o=t.target.checked?[].concat((0,l.A)(s),[e]):s.filter(function(t){return t!==e});a(o)},className:"w-4 h-4 text-blue-600 border-gray-300 rounded focus:ring-blue-500"}),d.createElement("span",{className:"text-sm font-medium text-gray-700"},e))})),"dropdown"===e.type&&d.createElement("div",{className:"relative ms-4"},d.createElement("select",{value:n(),onChange:function(e){return a(e.target.value)},className:"w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 appearance-none bg-white"},t().map(function(e){return d.createElement("option",{key:e,value:e},st[e]?st[e]+" - ":"",e)})),d.createElement("div",{className:"absolute inset-y-0 right-0 flex items-center pr-3 pointer-events-none"},d.createElement(y.ChevronDown,{className:"w-4 h-4 text-gray-400"}))),"single-checkbox"===e.type&&d.createElement(d.Fragment,null,d.createElement("div",{className:"space-y-3 ml-5"},d.createElement("label",{className:"flex items-start gap-3 p-3 hover:bg-gray-50 cursor-pointer rounded-lg"},d.createElement("input",{type:"checkbox",checked:Boolean(n()),onChange:function(e){return a(e.target.checked)},className:"w-4 h-4 text-blue-600 border-gray-300 rounded focus:ring-blue-500"}),d.createElement("span",{className:"text-sm text-gray-700"},e.checkboxLabel?e.checkboxLabel:"")))),e.defaultText&&d.createElement("p",{className:"text-xs text-gray-500 mt-3 ms-4"},e.defaultText),e.id===M.lb.INCLUDE_TAX&&d.createElement("div",{className:"mt-3 ml-5 p-3 bg-gray-50 rounded-lg"},d.createElement("p",{className:"text-sm text-gray-600"},d.createElement("strong",null,"Example:")," If payment amount is $100 and tax is $10 â"," ",Boolean(n())?d.createElement(d.Fragment,null,d.createElement("strong",null,"MRR = $90 "),"(tax excluded)"):d.createElement(d.Fragment,null,d.createElement("strong",null,"MRR = $100 "),"(tax included)"))),e.id===M.lb.TRANSACTION_FEES&&d.createElement(d.Fragment,null,"chargebee"===A&&Boolean(n())&&d.createElement("div",{className:"mt-4 ml-16"},d.createElement("div",{className:"bg-gray-50 p-4 rounded-xl space-y-4"},d.createElement("div",{className:"mb-8"},d.createElement("div",{className:"flex items-center gap-2"},d.createElement("label",{className:"font-medium text-gray-900"},"Does Chargebee charge you any fees for each transaction?"),d.createElement("button",{type:"button",onClick:function(){return je(!0)},className:"text-blue-600 hover:text-blue-800 text-sm font-medium flex items-center gap-1"},d.createElement(y.HelpCircle,{className:"w-4 h-4"}),"Learn more")),d.createElement("div",{className:"mt-2 ml-1 flex items-center gap-6"},d.createElement("label",{className:"inline-flex items-center gap-2 cursor-pointer select-none"},d.createElement("input",{type:"radio",name:"chargebeeChargesPerTxnFee",checked:!0===Pe,onChange:function(){return Oe(!0)},className:"w-4 h-4 text-blue-600 border-gray-300 focus:ring-blue-500"}),d.createElement("span",{className:"text-sm font-medium text-gray-700"},"Yes")),d.createElement("label",{className:"inline-flex items-center gap-2 cursor-pointer select-none"},d.createElement("input",{type:"radio",name:"chargebeeChargesPerTxnFee",checked:!1===Pe,onChange:function(){return Oe(!1)},className:"w-4 h-4 text-blue-600 border-gray-300 focus:ring-blue-500"}),d.createElement("span",{className:"text-sm font-medium text-gray-700"},"No")))),Pe&&d.createElement("div",{className:"ml-6 space-y-2"},d.createElement("label",{className:"block text-sm font-medium text-gray-700 mb-2"},"Fees by Chargebee for per transaction (%)"),d.createElement("div",{className:"relative w-32"},d.createElement("input",{type:"number",min:"0",max:"100",step:"0.01",value:x,onChange:function(e){return null==h?void 0:h(parseFloat(e.target.value)||0)},className:"w-full px-3 py-2 pr-8 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent",placeholder:"0.00"}),d.createElement("span",{className:"absolute right-3 top-2.5 text-gray-500"},"%"))),d.createElement("div",{className:"ml-6 space-y-2"},d.createElement("label",{className:"block text-sm font-medium text-gray-700 mb-2"},"Payment Gateway Fee Per Transaction (%)"),d.createElement("div",{className:"relative w-32"},d.createElement("input",{type:"number",min:"0",max:"100",step:"0.01",value:N,onChange:function(e){return null==C?void 0:C(parseFloat(e.target.value)||0)},className:"w-full px-3 py-2 pr-8 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent",placeholder:"0.00"}),d.createElement("span",{className:"absolute right-3 top-2.5 text-gray-500"},"%")),d.createElement("p",{className:"mt-1 text-xs text-gray-500"},"Enter the percentage fee charged by your payment gateway")),d.createElement("div",{className:"mt-8 ml-6 bg-gray-50 rounded-lg"},d.createElement("p",{className:"text-sm text-gray-700"},d.createElement("strong",null,"Example:")," If payment amount is $100, Chargebee fee is ",Pe?x:0,"%, and Payment Gateway fee is ",N,"% â
1"," ",d.createElement("strong",null,"MRR = $",(100-100*((Pe?x:0)+N)/100).toFixed(2))," (fees excluded)")))),"chargebee"!==A&&d.createElement("div",{className:"mt-3 ml-5 p-3 bg-gray-50 rounded-lg"},d.createElement("p",{className:"text-sm text-gray-600"},d.createElement("strong",null,"Example:")," If payment amount is $100 and transaction fee is $2 â"," ",Boolean(n())?d.createElement(d.Fragment,null,d.createElement("strong",null,"MRR = $98 "),"(tax excluded)"):d.createElement(d.Fragment,null,d.createElement("strong",null,"MRR = $100 "),"(tax included)")))),e.id===M.lb.CHARGEBEE_FEES&&d.createElement("div",{className:"ml-5 mt-4"},d.createElement("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4"},d.createElement("div",null,d.createElement("label",{className:"block text-sm font-medium text-gray-700 mb-2"},"Chargebee Fee Per Transaction (%)"),d.createElement("div",{className:"relative"},d.createElement("input",{type:"number",min:"0",max:"100",step:"0.01",value:x,onChange:function(e){return null==h?void 0:h(parseFloat(e.target.value)||0)},className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent",placeholder:"0.00"}),d.createElement("span",{className:"absolute right-3 top-2 text-gray-500"},"%")),d.createElement("p",{className:"mt-1 text-xs text-gray-500"},"Enter the percentage fee charged by Chargebee per transaction")),d.createElement("div",null,d.createElement("label",{className:"block text-sm font-medium text-gray-700 mb-2"},"Payment Gateway Fees (%)"),d.createElement("div",{className:"relative"},d.createElement("input",{type:"number",min:"0",max:"100",step:"0.01",value:N,onChange:function(e){return null==C?void 0:C(parseFloat(e.target.value)||0)},className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent",placeholder:"0.00"}),d.createElement("span",{className:"absolute right-3 top-2 text-gray-500"},"%")),d.createElement("p",{className:"mt-1 text-xs text-gray-500"},"Enter the percentage fee charged by your payment gateway"))),d.createElement("div",{className:"mt-4 p-3 bg-gray-50 rounded-lg"},d.createElement("p",{className:"text-sm text-gray-700"},d.createElement("strong",null,"Example:")," If payment amount is $100, Chargebee fee is ",x,"%, and Payment Gateway fee is ",N,"% â
1"," ",d.createElement("strong",null,"MRR = $",(100-100*(x+N)/100).toFixed(2))," (fees excluded)"))))}(n))}),d.createElement("div",{className:"flex justify-end"},d.createElement("button",{onClick:function(){G(function(t){return new Set([].concat((0,l.A)(Array.from(t)),[e.id]))}),i(!0),Ae(!0)},className:"flex items-center space-x-2 px-6 py-3 rounded-lg font-medium transition-colors bg-blue-600 text-white hover:bg-blue-700"},d.createElement("span",null,"Save Changes"),d.createElement(y.ArrowRight,{className:"w-4 h-4"}))))};return qe||!fe&&Ie?d.createElement("div",{className:"w-full mt-5"},d.createElement("div",{className:"bg-white rounded-lg shadow-sm border border-gray-200 ms-9"},Je.map(function(e,t){return d.createElement("div",{key:e.id,className:"border-b border-gray-200 last:border-b-0 ".concat(e.isActive?"bg-blue-50":"")},d.createElement("button",{type:"button",onClick:function(){return V(e.isActive?"":e.id)},className:"w-full flex items-center justify-between p-4 text-left hover:bg-gray-50 transition-colors"},d.createElement("div",{className:"flex items-center gap-4"},d.createElement("div",{className:"flex items-center gap-3"},d.createElement("div",{className:"w-8 h-8 flex-shrink-0 flex items-center justify-center rounded-full border-2 bg-blue-500 text-white font-semibold text-sm"},t+1)),d.createElement("div",null,d.createElement("div",{className:"font-semibold text-gray-900"},e.title),d.createElement("div",{className:"text-sm text-gray-500"},e.description))),d.createElement("div",{className:"flex items-center gap-2"},e.isCompleted&&d.createElement(y.CheckCircle,{className:"w-5 h-5 text-green-600"}),d.createElement(y.ChevronDown,{className:"w-4 h-4 text-gray-400 transition-transform ".concat(e.isActive?"rotate-180":"")}))),e.isActive&&d.createElement("div",{className:"border-t border-gray-200 p-6 bg-white"},Ze(e)))})),d.createElement("div",{className:"mt-6 ms-9"},ke&&d.createElement(et.F,{description:"Great job! You have completed the Revenue Analytics Setup. You've unlocked the following features: ",events:[],features:[{id:"revenue_analytics_report",name:"Revenue Intelligence Report",description:"Unlock detailed insights into your Revenue trends and growth.",icon:d.createElement(y.TrendingUp,{className:"w-5 h-5 text-blue-600"}),unlocked:!0,url:"/revenue-analytics/dashboard"}],completed:!0,hideRecentEvents:!0,title:"Excellent! You've completed basic setup for Revenue Intelligence. We are now analyzing your revenue data and calculating your Revenue metrics."})),Ke&&d.createElement("div",{className:"fixed inset-0 z-50 overflow-hidden"},d.createElement("div",{className:"absolute inset-0 bg-black bg-opacity-50",onClick:function(){return je(!1)}}),d.createElement("div",{className:"absolute right-0 top-0 h-full w-full max-w-md bg-white shadow-xl overflow-y-auto"},d.createElement("div",{className:"flex items-center justify-between p-4 border-b border-gray-200 sticky top-0 bg-white"},d.createElement("div",{className:"flex items-center gap-3"},d.createElement("img",{src:w,alt:"Chargebee",className:"h-6 w-6",style:{objectFit:"contain"}}),d.createElement("h2",{className:"text-lg font-semibold text-gray-900"},"Transaction Fees")),d.createElement("button",{onClick:function(){return je(!1)},className:"p-1.5 hover:bg-gray-100 rounded-lg transition-colors"},d.createElement(y.X,{className:"w-5 h-5 text-gray-500"}))),d.createElement("div",{className:"p-4 border-b border-gray-200"},d.createElement("h3",{className:"font-semibold text-gray-900 mb-3"},"How fees impact your revenue"),d.createElement("div",{className:"mb-4"},d.createElement("p",{className:"text-xs text-gray-500 mb-2"},"With Chargebee fee:"),d.createElement("div",{className:"flex items-center justify-between text-center"},d.createElement("div",{className:"flex-1"},d.createElement("div",{className:"w-10 h-10 mx-auto bg-white rounded-full flex items-center justify-center border border-gray-200"},d.createElement("span",{className:"text-sm font-bold text-gray-700"},"$100")),d.createElement("p",{className:"text-xs font-medium text-gray-700 mt-1"},"Gross")),d.createElement("div",{className:"text-gray-400 text-xs"},"â"),d.createElement("div",{className:"flex-1"},d.createElement("div",{className:"w-10 h-10 mx-auto bg-white rounded-full flex items-center justify-center border border-gray-200"},d.createElement("img",{src:w,alt:"Chargebee",className:"w-5 h-5",style:{objectFit:"contain"}})),d.createElement("p",{className:"text-xs font-medium text-gray-700 mt-1"},"Chargebee"),d.createElement("p",{className:"text-xs text-gray-500"},"-0.75%")),d.createElement("div",{className:"text-gray-400 text-xs"},"â"),d.createElement("div",{className:"flex-1"},d.createElement("div",{className:"w-10 h-10 mx-auto bg-white rounded-full flex items-center justify-center border border-gray-200"},d.createElement("img",{src:"https://upload.wikimedia.org/wikipedia/commons/b/ba/Stripe_Logo%2C_revised_2016.svg",alt:"Stripe",className:"w-5 h-5",style:{objectFit:"contain"}})),d.createElement("p",{className:"text-xs font-medium text-gray-700 mt-1"},"Gateway"),d.createElement("p",{className:"text-xs text-gray-500"},"-2.9%")),d.createElement("div",{className:"text-gray-400 text-xs"},"â"),d.createElement("div",{className:"flex-1"},d.createElement("div",{className:"w-10 h-10 mx-auto bg-white rounded-full flex items-center justify-center border border-gray-200"},d.createElement("span",{className:"text-xs font-bold text-gray-700"},"$96")),d.createElement("p",{className:"text-xs font-medium text-gray-700 mt-1"},"Net MRR")))),d.createElement("div",null,d.createElement("p",{className:"text-xs text-gray-500 mb-2"},"Without Chargebee fee:"),d.createElement("div",{className:"flex items-center justify-between text-center"},d.createElement("div",{className:"flex-1"},d.createElement("div",{className:"w-10 h-10 mx-auto bg-white rounded-full flex items-center justify-center border border-gray-200"},d.createElement("span",{className:"text-sm font-bold text-gray-700"},"$100")),d.createElement("p",{className:"text-xs font-medium text-gray-700 mt-1"},"Gross")),d.createElement("div",{className:"text-gray-400 text-xs"},"â"),d.createElement("div",{className:"flex-1"},d.createElement("div",{className:"w-10 h-10 mx-auto bg-white rounded-full flex items-center justify-center border border-gray-200"},d.createElement("img",{src:"https://upload.wikimedia.org/wikipedia/commons/b/ba/Stripe_Logo%2C_revised_2016.svg",alt:"Stripe",className:"w-5 h-5",style:{objectFit:"contain"}})),d.createElement("p",{className:"text-xs font-medium text-gray-700 mt-1"},"Gateway"),d.createElement("p",{className:"text-xs text-gray-500"},"-2.9%")),d.createElement("div",{className:"text-gray-400 text-xs"},"â"),d.createElement("div",{className:"flex-1"},d.createElement("div",{className:"w-10 h-10 mx-auto bg-white rounded-full flex items-center justify-center border border-gray-200"},d.createElement("span",{className:"text-xs font-bold text-gray-700"},"$96.80")),d.createElement("p",{className:"text-xs font-medium text-gray-700 mt-1"},"Net MRR"))))),d.createElement("div",{className:"p-4 space-y-4 text-sm text-gray-700"},d.createElement("section",null,d.createElement("h3",{className:"font-semibold text-gray-900 mb-2"},"Why does this matter?"),d.createElement("p",{className:"text-xs text-gray-600"},"Transaction fees reduce your actual revenue. Excluding them from MRR calculations gives you a more accurate view of what you actually retain â helping you make better financial decisions and forecasts.")),d.createElement("hr",{className:"border-gray-200"}),d.createElement("section",null,d.createElement("div",{className:"flex items-center justify-between mb-2"},d.createElement("h3",{className:"font-semibold text-gray-900"},"Chargebee Fee"),d.createElement("a",{href:"https://www.chargebee.com/pricing/",target:"_blank",rel:"noopener noreferrer",className:"text-xs text-blue-600 hover:text-blue-800 flex items-center gap-1"},"Pricing ",d.createElement(y.ExternalLink,{className:"w-3 h-3"}))),d.createElement("p",{className:"text-xs text-gray-600 mb-2"},"Revenue-based pricing, not per-transaction."),d.createElement("div",{className:"grid grid-cols-3 gap-2 text-xs"},d.createElement("div",{className:"bg-gray-50 rounded p-2 text-center"},d.createElement("p",{className:"font-medium"},"Starter"),d.createElement("p",{className:"text-gray-500"},"Free to $250K")),d.createElement("div",{className:"bg-gray-50 rounded p-2 text-center"},d.createElement("p",{className:"font-medium"},"Performance"),d.createElement("p",{className:"text-gray-500"},"$599/mo")),d.createElement("div",{className:"bg-gray-50 rounded p-2 text-center"},d.createElement("p",{className:"font-medium"},"Enterprise"),d.createElement("p",{className:"text-gray-500"},"Custom"))),d.createElement("p",{className:"text-xs text-gray-500 mt-2"},"Overage: 0.75% beyond plan limits")),d.createElement("hr",{className:"border-gray-200"}),d.createElement("section",null,d.createElement("h3",{className:"font-semibold text-gray-900 mb-2"},"Payment Gateway Fee"),d.createElement("p",{className:"text-xs text-gray-600 mb-2"},"Per-transaction fees charged by payment processors."),d.createElement("table",{className:"w-full text-xs"},d.createElement("thead",null,d.createElement("tr",{className:"border-b border-gray-200"},d.createElement("th",{className:"text-left py-1.5 font-medium"},"Gateway"),d.createElement("th",{className:"text-left py-1.5 font-medium"},"Card"),d.createElement("th",{className:"text-left py-1.5 font-medium"},"ACH"),d.createElement("th",{className:"py-1.5"}))),d.createElement("tbody",{className:"text-gray-600"},d.createElement("tr",{className:"border-b border-gray-100"},d.createElement("td",{className:"py-1.5"},"Stripe"),d.createElement("td",{className:"py-1.5"},"2.9% + $0.30"),d.createElement("td",{className:"py-1.5"},"0.8%"),d.createElement("td",{className:"py-1.5"},d.createElement("a",{href:"https://stripe.com/pricing",target:"_blank",rel:"noopener noreferrer",className:"text-blue-600"},d.createElement(y.ExternalLink,{className:"w-3 h-3"})))),d.createElement("tr",{className:"border-b border-gray-100"},d.createElement("td",{className:"py-1.5"},"Braintree"),d.createElement("td",{className:"py-1.5"},"2.9% + $0.30"),d.createElement("td",{className:"py-1.5"},"0.75%"),d.createElement("td",{className:"py-1.5"},d.createElement("a",{href:"https://www.braintreepayments.com/learn/credit-card-processing-fees",target:"_blank",rel:"noopener noreferrer",className:"text-blue-600"},d.createElement(y.ExternalLink,{className:"w-3 h-3"})))),d.createElement("tr",null,d.createElement("td",{className:"py-1.5"},"PayPal"),d.createElement("td",{className:"py-1.5"},"2.9% + $0.30"),d.createElement("td",{className:"py-1.5"},"Varies"),d.createElement("td",{className:"py-1.5"},d.createElement("a",{href:"https://www.paypal.com/us/webapps/mpp/merchant-fees",target:"_blank",rel:"noopener noreferrer",className:"text-blue-600"},d.createElement(y.ExternalLink,{className:"w-3 h-3"})))))),d.createElement("p",{className:"text-xs text-gray-500 mt-2"},"+1% for international transactions, +1% for currency conversion"),d.createElement("p",{className:"text-xs text-gray-500 mt-1 italic"},"* For reference only. Please check your account for actual fees.")),d.createElement("hr",{className:"border-gray-200"}),d.createElement("section",null,d.createElement("h3",{className:"font-semibold text-gray-900 mb-2"},"Why Exclude Fees from MRR?"),d.createElement("p",{className:"text-xs text-gray-600 mb-3"}
1,"Excluding fees gives a more accurate view of net revenue you actually retain."),d.createElement("div",{className:"bg-gray-50 rounded p-3 text-xs font-mono"},d.createElement("div",{className:"space-y-1 text-gray-600"},d.createElement("div",{className:"flex justify-between"},d.createElement("span",null,"Gross Payment"),d.createElement("span",null,"$100.00")),d.createElement("div",{className:"flex justify-between"},d.createElement("span",null,"â Chargebee (0.75%)"),d.createElement("span",{className:"text-red-600"},"-$0.75")),d.createElement("div",{className:"flex justify-between"},d.createElement("span",null,"â Stripe (2.9% + $0.30)"),d.createElement("span",{className:"text-red-600"},"-$3.20")),d.createElement("div",{className:"flex justify-between border-t border-gray-300 pt-1 mt-1 font-semibold text-gray-900"},d.createElement("span",null,"MRR"),d.createElement("span",{className:"text-green-600"},"$96.05"))))))))):d.createElement("div",{className:"w-full mt-5"},d.createElement("div",{className:"bg-white rounded-lg shadow-sm border border-gray-200 p-8"},d.createElement("div",{className:"flex items-center justify-center"},d.createElement("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-blue-600"}),d.createElement("span",{className:"ml-3 text-gray-600"},"Loading configuration options..."))))};var lt="Last month MRR * 12",it="january",ct=["subscription_cancelled"];const mt=function(e){var t=e.onComplete,n=e.loadedRevenueOption,a=e.loadedArrMethod,r=e.loadedChurnOptions,s=(0,d.useState)(lt),o=(0,c.A)(s,2),i=o[0],m=o[
11],u=(0,d.useState)(it),p=(0,c.A)(u,2),g=p[0],f=p[1],b=(0,d.useState)(ct),v=(0,c.A)(b,2),x=v[0],h=v[1],E=(0,d.useState)("total_revenue"),N=(0,c.A)(E,2),w=N[0],C=N[1],S=(0,d.useState)(new Set),k=(0,c.A)(S,2),A=k[0],I=k[1],T=d.useRef(!1),D=d.useRef(!1),R=d.useRef(!1);function _(e,t){if(!e||!t)return!1;if(e.length!==t.length)return!1;var n=(0,l.A)(e).sort(),a=(0,l.A)(t).sort();return n.every(function(e,t){return e===a[t]})}(0,d.useEffect)(function(){M.map(function(e){return e.id}).every(function(e){return A.has(e)})&&t([g,i],x)},[g,i,x,A]),(0,d.useEffect)(function(){try{var e=new URLSearchParams(window.location.search),t=e.get("step"),n=e.get("substep"),a=t?parseInt(t,10):NaN,r=n?parseInt(n,10):NaN;if(4!==a||Number.isNaN(r))return;1===r?C("total_revenue"):2===r?C("arr"):3===r&&C("churn")}catch(e){}},[]),(0,d.useEffect)(function(){T.current||void 0===n||n===g||(f(n),T.current=!0),D.current||void 0===a||a===i||(m(a),D.current=!0),R.current||!r||_(r,x)||(h(r),R.current=!0)},[n,a,r]);var P=""!==i,O=""!==g,M=(x.length,[{id:"total_revenue",label:"Total Revenue",labelBgColor:"#dbeafe",labelTextColor:"#1e40af",title:"Total Revenue Setup",description:"Easily configure how your revenue is tracked and recognized",isCompleted:O,isActive:"total_revenue"===w,questions:[{id:"total_revenue",number:1,title:"When does your fiscal year start?",description:"Set up your fiscal year start to enable precise total revenue calculations, aligned with your financial reporting cycle.",type:"dropdown",options:[{id:"january",value:"January"},{id:"february",value:"February"},{id:"march",value:"March"},{id:"april",value:"April"},{id:"may",value:"May"},{id:"june",value:"June"},{id:"july",value:"July"},{id:"august",value:"August"},{id:"september",value:"September"},{id:"october",value:"October"},{id:"november",value:"November"},{id:"december",value:"December"}],gridCols:3}],tip:{title:"What is Total Revenue?",content:d.createElement("div",{className:"text-sm text-amber-800 flex flex-col gap-2"},d.createElement("div",{className:"bg-amber-50 p-3 text-amber-900"},d.createElement("span",{className:"font-medium"})," Total Revenue represents all income generated by your business, including both recurring and one-time revenue streams."),d.createElement("div",{className:"ml-4"},d.createElement("strong",null,"Includes:"),d.createElement("br",null),"⢠Recurring subscription fees",d.createElement("br",null),"⢠One-time purchases",d.createElement("br",null),"⢠Setup fees and onboarding charges",d.createElement("br",null),"⢠Professional services revenue",d.createElement("br",null),"⢠Add-on products and upgrades"),d.createElement("div",{className:"mt-2 ml-4"},d.createElement("strong",null,"Fiscal Year Start:"),d.createElement("br",null),"Choose which month marks the beginning of your fiscal year. This affects how revenue is calculated and reported for tax and accounting purposes."),d.createElement("div",{className:"mt-2 ml-4"},d.createElement("strong",null,"Why it matters:"),d.createElement("br",null),"Total Revenue gives you a complete picture of your business performance, helping with financial planning, investor reporting, and growth analysis.")),icon:d.createElement(y.CheckCircle,{className:"w-4 h-4 text-amber-600 mr-2"}),type:"info",timeout:2e3}},{id:"arr",label:"ARR",labelBgColor:"#dbeafe",labelTextColor:"#1e40af",title:"ARR Configuration",description:"Configure your ARR calculation",isCompleted:P,isActive:"arr"===w,questions:[{id:"arr_method",number:1,title:"Select ARR Calculation Formula",description:"Choose how you want to calculate your Annual Recurring Revenue (ARR).",type:"dropdown",options:["Last month MRR * 12","Average MRR for fiscal year * 12"].map(function(e,t){return{id:e,value:e}}),defaultValue:"Last month ARR * 12",required:!0}],tip:{title:"What is Annual Recurring Revenue (ARR)?",content:d.createElement("div",{className:"text-sm text-amber-800 flex flex-col gap-2"},d.createElement("div",{className:"bg-amber-50 p-3 text-amber-900"},d.createElement("span",{className:"font-medium"})," ARR is the annualized version of your Monthly Recurring Revenue (MRR). It represents the predictable, recurring revenue you can expect from your customers over a 12-month period."),d.createElement("div",{className:"ml-4"},d.createElement("strong",null,"Formula:"),d.createElement("br",null),d.createElement("span",{className:"bg-white border border-amber-200 rounded px-2 py-1 inline-block mt-1"},"ARR = MRR à 12")),d.createElement("div",{className:"mt-2 ml-4"},d.createElement("strong",null,"Why ARR matters:"),d.createElement("br",null),"ARR helps you forecast annual revenue, plan budgets, and communicate with investors. It's a key metric for SaaS businesses and subscription models."),d.createElement("div",{className:"mt-2 ml-4"},d.createElement("strong",null,"Calculation Methods:"),d.createElement("br",null),"⢠",d.createElement("strong",null,"Last month MRR à 12:")," Uses your most recent MRR",d.createElement("br",null),"⢠",d.createElement("strong",null,"Fiscal Monthly Average MRR à 12:")," Uses average MRR over time",d.createElement("br",null))),icon:d.createElement(y.CheckCircle,{className:"w-4 h-4 text-amber-600 mr-2"}),type:"info",timeout:2e3}}]),F=function(e){return d.createElement("div",{className:"space-y-6"},e.tip&&d.createElement("div",{className:"mb-4"},d.createElement(ee.Y,{title:e.tip.title,content:e.tip.content,icon:e.tip.icon,type:e.tip.type,timeout:e.tip.timeout})),e.questions.map(function(e){return d.createElement("div",{key:e.id},function(e){var t=function(){return e.options},n=function(){switch(e.id){case"arr_method":return i;case"total_revenue":return g;case"churn_config":return x;default:return e.defaultValue||[]}},a=function(t){switch(e.id){case"arr_method":m("string"==typeof t?t:t[0]||"");break;case"total_revenue":f("string"==typeof t?t:t[0]||"");break;case"churn_config":h(Array.isArray(t)?t:[t])}};return d.createElement("div",{className:"bg-white rounded-lg shadow-sm border border-gray-200 p-6 overflow-y-auto"},d.createElement("h3",{className:"font-semibold text-gray-900 mb-2"},e.number,". ",e.title),d.createElement("p",{className:"text-sm text-gray-600 mb-4 ml-4"},e.description),"checkbox"===e.type&&d.createElement("div",{className:"grid grid-cols-1 md:grid-cols-".concat(e.gridCols||3," gap-3")},t().map(function(e){return d.createElement("label",{key:e.id,className:"flex items-center gap-3 p-3 hover:bg-gray-50 cursor-pointer rounded-lg"},d.createElement("input",{type:"checkbox",checked:!!Array.isArray(n())&&n().includes(e.id),onChange:function(t){var r=n(),s=Array.isArray(r)?r:[],o=t.target.checked?[].concat((0,l.A)(s),[e.id]):s.filter(function(t){return t!==e.id});a(o)},className:"w-4 h-4 text-blue-600 border-gray-300 rounded focus:ring-blue-500"}),d.createElement("span",{className:"text-sm font-medium text-gray-700"},e.value))})),"dropdown"===e.type&&d.createElement("div",{className:"relative"},d.createElement("select",{value:n(),onChange:function(e){return a(e.target.value)},className:"w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 appearance-none bg-white"},t().map(function(e){return d.createElement("option",{key:e.id,value:e.id},e.value)})),d.createElement("div",{className:"absolute inset-y-0 right-0 flex items-center pr-3 pointer-events-none"},d.createElement(y.ChevronDown,{className:"w-4 h-4 text-gray-400"}))),e.defaultText&&d.createElement("p",{className:"text-xs text-gray-500 mt-3"},e.defaultText))}(e))}),d.createElement("div",{className:"flex justify-end"},d.createElement("button",{onClick:function(){if(e.isCompleted){I(function(t){var n=new Set;return t.forEach(function(e){return n.add(e)}),n.add(e.id),n});var t=M.findIndex(function(t){return t.id===e.id});-1!==t&&t+1<M.length?C(M[t+1].id):C("")}},disabled:!e.isCompleted,className:"flex items-center space-x-2 px-6 py-3 rounded-lg font-medium transition-colors ".concat(e.isCompleted?"bg-blue-600 text-white hover:bg-blue-700":"bg-gray-400 cursor-not-allowed opacity-60")},d.createElement("span",null,"Continue"),d.createElement(y.ArrowRight,{className:"w-4 h-4"}))))};return d.createElement("div",{className:"ms-9 mt-5"},d.createElement("div",{className:"bg-white rounded-lg shadow-sm border border-gray-200"},M.map(function(e,t){return d.createElement("div",{key:e.id,className:"border-b border-gray-200 last:border-b-0 ".concat(e.isActive?"bg-blue-50":"")},d.createElement("button",{type:"button",onClick:function(){return C(e.isActive?"":e.id)},className:"w-full flex items-center justify-between p-4 text-left hover:bg-gray-50 transition-colors"},d.createElement("div",{className:"flex items-center gap-4"},d.createElement("div",{className:"w-8 h-8 flex-shrink-0 flex items-center justify-center rounded-full border-2 bg-blue-500 text-white font-semibold text-sm"},t+1),d.createElement("div",null,d.createElement("div",{className:"font-semibold text-gray-900"},e.title),d.createElement("div",{className:"text-sm text-gray-500"},e.description))),d.createElement("div",{className:"flex items-center gap-2"},"arr"===e.id?i===lt?d.createElement("span",{className:"px-2 py-1 text-xs font-medium bg-gray-100 text-gray-600 rounded"},"Default"):d.createElement(y.CheckCircle,{className:"w-5 h-5 text-green-600"}):"total_revenue"===e.id?g===it?d.createElement("span",{className:"px-2 py-1 text-xs font-medium bg-gray-100 text-gray-600 rounded"},"Default"):d.createElement(y.CheckCircle,{className:"w-5 h-5 text-green-600"}):"churn"===e.id?_(x,ct)?d.createElement("span",{className:"px-2 py-1 text-xs font-medium bg-gray-100 text-gray-600 rounded"},"Default"):d.createElement(y.CheckCircle,{className:"w-5 h-5 text-green-600"}):null,d.createElement(y.ChevronDown,{className:"w-4 h-4 text-gray-400 transition-transform ".concat(e.isActive?"rotate-180":"")}))),e.isActive&&d.createElement("div",{className:"border-t border-gray-200 p-6 bg-white"},F(e)))})))};var ut=n(7787),dt=n(10472),pt=n(23387),gt=n(6209),ft=n(58968),bt=n(74348),yt=n(99034),vt=n(95922),xt=[{name:"transaction_id",dataType:"VARCHAR(50)",fieldType:"Required",examples:"txn_123456789"},{name:"customer_id",dataType:"VARCHAR(50)",fieldType:"Required",examples:"cust_987654321"},{name:"group_id",dataType:"VARCHAR(50)",fieldType:"Required",examples:"This is the group_id in product telemetry"},{name:"customer_name",dataType:"VARCHAR(255)",fieldType:"Required",examples:"John Doe"},{name:"transaction_amount",dataType:"Float",fieldType:"Required",examples:"99.99"},{name:"transaction_type",dataType:"ENUM",fieldType:"Required",examples:"payment/refund"},{name:"transaction_currency",dataType:"VARCHAR(3)",fieldType:"Required",examples:"USD, EUR, GBP | Default: USD"},{name:"transaction_status",dataType:"VARCHAR(50)",fieldType:"Required",examples:"paid, cancelled, failed, refund, charged_back"},{name:"line_item_type",dataType:"ENUM",fieldType:"Required",examples:"subscription/one_time"},{name:"date",dataType:"TIMESTAMP",fieldType:"Required",examples:"2025-01-15T14:30:00Z"},{name:"transaction_period_start_date",dataType:"DATE",fieldType:"Required",examples:"2025-01-15T14:30:00Z"},{name:"transaction_period_end_date",dataType:"DATE",fieldType:"Required",examples:"2025-02-15T14:30:00Z"},{name:"invoice_id",dataType:"VARCHAR(50)",fieldType:"Optional",examples:"inv_112233445"},{name:"payment_method",dataType:"VARCHAR(50)",fieldType:"Optional",examples:"credit_card, paypal, stripe"},{name:"tax_amount",dataType:"BIGINT",fieldType:"Optional",examples:"Default: 0"},{name:"discount_amount",dataType:"BIGINT",fieldType:"Optional",examples:"Default: 0"},{name:"transaction_fee",dataType:"BIGINT",fieldType:"Optional",examples:"Default: 0"},{name:"term_unit",dataType:"ENUM",fieldType:"Optional",examples:"day, week, month, year | Default: month"},{name:"term_frequency",dataType:"INT",fieldType:"Optional",examples:"Default: 1"}],ht=[{name:"id",dataType:"VARCHAR(50)",fieldType:"Required",examples:"inv_123456789"},{name:"customer_id",dataType:"VARCHAR(50)",fieldType:"Required",examples:"cust_987654321"},{name:"group_id",dataType:"VARCHAR(50)",fieldType:"Required",examples:"group_001"},{name:"issue_date",dataType:"DATE",fieldType:"Required",examples:"2025-01-15T14:30:00Z"},{name:"invoice_amount",dataType:"Float",fieldType:"Required",examples:"299.99"},{name:"currency",dataType:"VARCHAR(3)",fieldType:"Required",examples:"USD, EUR, GBP | Default: USD"},{name:"due_date",dataType:"DATE",fieldType:"Optional",examples:"2025-02-15T14:30:00Z",comments:"If this data is not provided, the system will be unable to determine the applicable payment terms."}],Et=[{name:"subscription_id",dataType:"VARCHAR(50)",fieldType:"Required",examples:"sub_123",comments:"Unique subscription identifier in your billing system."},{name:"customer_id",dataType:"VARCHAR(50)",fieldType:"Required",examples:"cust_123",comments:"Customer identifier in your billing system (can be same as group_id)."},{name:"group_id",dataType:"VARCHAR(50)",fieldType:"Required",examples:"group_456",comments:"Must map to the group_id in product telemetry."},{name:"status",dataType:"VARCHAR(50)",fieldType:"Required",examples:"active | cancelled",comments:"Subscription lifecycle status."},{name:"currency",dataType:"VARCHAR(3)",fieldType:"Required",examples:"USD, EUR, GBP",comments:"3-letter currency code."},{name:"start_date",dataType:"TIMESTAMP",fieldType:"Optional",examples:"2024-01-15T00:00:00Z",comments:"Subscription start timestamp (ISO 8601)."},{name:"ended_at",dataType:"TIMESTAMP",fieldType:"Optional",examples:"2025-01-15T00:00:00Z",comments:"When the subscription ended. Use null if active."},{name:"trial_start_date",dataType:"TIMESTAMP",fieldType:"Optional",examples:"2024-01-01T00:00:00Z",comments:"Trial start timestamp (ISO 8601)."},{name:"trial_end_date",dataType:"TIMESTAMP",fieldType:"Optional",examples:"2024-01-14T23:59:59Z",comments:"Trial end timestamp (ISO 8601)."},{name:"current_period_start",dataType:"TIMESTAMP",fieldType:"Required",examples:"2024-01-15T00:00:00Z",comments:"Current billing period start (required)."},{name:"current_period_end",dataType:"TIMESTAMP",fieldType:"Required",examples:"2024-02-14T23:59:59Z",comments:"Current billing period end (required)."},{name:"cancelled_at",dataType:"TIMESTAMP",fieldType:"Optional",examples:"null | 2024-02-01T12:00:00Z",comments:"When the customer cancelled. Use null if not cancelled."},{name:"cancellation_comment",dataType:"VARCHAR(255)",fieldType:"Optional",examples:"Customer requested cancellation",comments:"Reason/comment for cancellation."},{name:"create_date",dataType:"TIMESTAMP",fieldType:"Optional",examples:"2024-01-15T00:00:00Z",comments:"When the subscription record was created in your system."},{name:"updated_date",dataType:"TIMESTAMP",fieldType:"Optional",examples:"2024-02-01T12:00:00Z",comments:"When the subscription record was last updated in your system."}],Nt=[{name:"subscription_item_id",dataType:"VARCHAR(50)",fieldType:"Required",examples:"si_123",comments:"Unique subscription item identifier in your billing system."},{name:"subscription_id",dataType:"VARCHAR(50)",fieldType:"Required",examples:"sub_123",comments:"Parent subscription identifier."},{name:"customer_id",dataType:"VARCHAR(50)",fieldType:"Required",examples:"cust_123",comments:"Customer identifier in your billing system."},{name:"plan_id",dataType:"VARCHAR(50)",fieldType:"Optional",examples:"plan_pro_monthly",comments:"Plan identifier (if applicable)."},{name:"price_id",dataType:"VARCHAR(50)",fieldType:"Optional",examples:"price_123",comments:"Price identifier (if applicable)."},{name:"term_unit",dataType:"VARCHAR(20)",fieldType:"Required",examples:"month | year",comments:"Billing term unit."},{name:"term_frequency",dataType:"VARCHAR(10)",fieldType:"Required",examples:"1",comments:"Billing term frequency (string as sent by API payload)."},{name:"start_date",dataType:"TIMESTAMP",fieldType:"Optional",examples:"2024-01-15T00:00:00Z",comments:"Subscription item start timestamp."},{name:"status",dataType:"VARCHAR(50)",fieldType:"Required",examples:"active",comments:"Subscription item status."},{name:"created_date",dataType:"TIMESTAMP",fieldType:"Optional",examples:"2024-01-15T00:00:00Z",comments:"When the subscription item record was created in your system."},{name:"ended_at",dataType:"TIMESTAMP",fieldType:"Optional",examples:"2025-01-15T00:00:00Z",comments:"When the subscription item ended. Use null if
1active."},{name:"quantity",dataType:"INT",fieldType:"Required",examples:"1",comments:"Quantity purchased (required)."},{name:"trial_start_date",dataType:"TIMESTAMP",fieldType:"Optional",examples:"2024-01-01T00:00:00Z",comments:"Trial start timestamp."},{name:"trial_end_date",dataType:"TIMESTAMP",fieldType:"Optional",examples:"2024-01-14T23:59:59Z",comments:"Trial end timestamp."},{name:"cancelled_at",dataType:"TIMESTAMP",fieldType:"Optional",examples:"null | 2024-02-01T12:00:00Z",comments:"When the item was cancelled. Use null if not cancelled."},{name:"current_period_start",dataType:"TIMESTAMP",fieldType:"Required",examples:"2024-01-15T00:00:00Z",comments:"Current billing period start (required)."},{name:"current_period_end",dataType:"TIMESTAMP",fieldType:"Required",examples:"2024-02-14T23:59:59Z",comments:"Current billing period end (required)."},{name:"updated_date",dataType:"TIMESTAMP",fieldType:"Optional",examples:"2024-02-01T00:00:00Z",comments:"When the subscription item record was last updated in your system."}];const wt=function(e){var t=e.isOpen,n=e.onClose,a=e.onOpenSchemaDrawer,r=(0,d.useState)("transactions"),s=(0,c.A)(r,2),o=s[0],l=s[1],i=function(){return("transactions"===o?xt:"invoices"===o?ht:"subscriptions"===o?Et:Nt).some(function(e){return Boolean(e.comments&&e.comments.trim().length>0)})},m=function(e,t){return d.createElement("div",{className:"mb-8 ms-6"},d.createElement("h3",{className:"text-lg font-semibold text-gray-900 mb-4 flex items-center"},d.createElement(y.Database,{className:"w-5 h-5 mr-2 text-blue-600"}),t),d.createElement("div",{className:"overflow-hidden rounded-lg border border-gray-200"},d.createElement("table",{className:"min-w-full divide-y divide-gray-200"},d.createElement("thead",{className:"bg-gray-50"},d.createElement("tr",null,d.createElement("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider"},"Field Name"),d.createElement("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider"},"Data Type"),d.createElement("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider"},"Field Type"),d.createElement("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider"},"Value"),i()&&d.createElement("th",{className:"px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider"},"Comments"))),d.createElement("tbody",{className:"bg-white divide-y divide-gray-200"},e.map(function(e,t){var n;return d.createElement("tr",{key:e.name,className:t%2==0?"bg-white":"bg-gray-50"},d.createElement("td",{className:"px-4 py-3 text-sm font-medium text-gray-900"},d.createElement("code",{className:"bg-blue-50 text-blue-700 px-2 py-1 rounded text-xs"},e.name)),d.createElement("td",{className:"px-4 py-3 text-sm text-gray-600"},d.createElement("span",{className:"px-2 py-1 rounded text-xs"},e.dataType)),d.createElement("td",{className:"px-4 py-3 text-sm text-gray-600"},d.createElement("span",{className:e.fieldType.includes("Required")?"text-red-600 font-medium":"text-gray-600"},e.fieldType)),d.createElement("td",{className:"px-4 py-3 text-sm text-gray-500"},e.examples),i()&&d.createElement("td",{className:"px-4 py-3 text-sm text-gray-500"},null!==(n=e.comments)&&void 0!==n?n:"-"))})))))};return t?d.createElement(d.Fragment,null,d.createElement("div",{className:"fixed inset-0 mt-4 bg-black bg-opacity-50 z-20 flex items-center justify-center p-4",onClick:n}),d.createElement("div",{className:"fixed right-0 top-6 bottom-6 w-full h-full max-w-4xl bg-white rounded-xl shadow-xl z-20 transform transition-transform duration-300 flex flex-col ".concat(t?"translate-x-0":"-translate-x-full")},d.createElement("div",{className:"flex items-center p-6 border-b border-gray-200 bg-white sticky top-0"},d.createElement("div",{className:"flex items-center"},d.createElement(y.Database,{className:"w-6 h-6 text-blue-600 mr-3"}),d.createElement("h2",{className:"text-xl font-semibold text-gray-900"},"DataModel Schema")),d.createElement("div",{className:"flex ml-auto items-center"},a&&d.createElement("button",{onClick:a,className:"ml-auto text-blue-600 hover:text-blue-800 underline hover:underline-offset-2 bg-transparent px-0 py-0 text-sm font-medium transition-colors flex items-center gap-1"},d.createElement(y.Database,{className:"w-4 h-4"}),d.createElement("span",null,"Dev Guide: ER Diagram"))),d.createElement("button",{onClick:n,className:"p-2 hover:bg-gray-100 rounded-lg transition-colors"},d.createElement(y.X,{className:"w-5 h-5 text-gray-500"}))),d.createElement("div",{className:"p-6 overflow-y-auto flex-1 pb-20"},d.createElement("div",{className:"mb-6"},d.createElement("p",{className:"text-gray-600"},"Below are the schema definitions for the dataset tables. These schemas define the structure and data types expected for each field.")),d.createElement("div",{className:"flex border-b border-gray-200 mb-6"},d.createElement("button",{onClick:function(){return l("transactions")},className:"px-4 py-2 text-sm font-medium border-b-2 transition-colors ".concat("transactions"===o?"border-blue-500 text-blue-600":"border-transparent text-gray-500 hover:text-gray-700")},"Transaction Schema"),d.createElement("button",{onClick:function(){return l("invoices")},className:"px-4 py-2 text-sm font-medium border-b-2 transition-colors ".concat("invoices"===o?"border-blue-500 text-blue-600":"border-transparent text-gray-500 hover:text-gray-700")},"Invoices Schema"),d.createElement("button",{onClick:function(){return l("subscriptions")},className:"px-4 py-2 text-sm font-medium border-b-2 transition-colors ".concat("subscriptions"===o?"border-blue-500 text-blue-600":"border-transparent text-gray-500 hover:text-gray-700")},"Subscriptions Schema"),d.createElement("button",{onClick:function(){return l("subscription-items")},className:"px-4 py-2 text-sm font-medium border-b-2 transition-colors ".concat("subscription-items"===o?"border-blue-500 text-blue-600":"border-transparent text-gray-500 hover:text-gray-700")},"Subscription Items Schema")),"transactions"===o&&m(xt,"Transaction Schema"),"invoices"===o&&m(ht,"Invoices Schema"),"subscriptions"===o&&m(Et,"Subscriptions Schema"),"subscription-items"===o&&m(Nt,"Subscription Items Schema")))):null};var Ct=n(25342),St=n(51250),kt=n(52312),At=n(41830),It=n(23930),Tt=n(1606),Dt=n(76566),Rt=["selectedMrrPlans","selectedMrrStatuses","selectedPastDueHandling","includeTax","baseCurrency","includeTransactionFees","chargebeeFeePerTransaction","paymentGatewayFees","chargebeeChargesPerTxnFee"];function _t(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,a)}return n}function Pt(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};
1t%2?_t(Object(n),!0).forEach(function(t){(0,i.A)(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):_t(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var Ot=vt.default.get("system_token"),Mt=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=(0,d.useState)({emails:e,inputValue:"",error:"",showInput:e.length>0,showUpdateButton:!1}),n=(0,c.A)(t,2),a=n[0],r=n[1];return{state:a,handleKeyDown:function(e){if(","===e.key||"Enter"===e.key){e.preventDefault();var t=a.inputValue.trim();if(!t)return;if(!function(e){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e.trim())}(t))return void r(function(e){return Pt(Pt({},e),{},{error:"Please enter a valid email address"})});if(a.emails.includes(t))return void r(function(e){return Pt(Pt({},e),{},{error:"This email has already been added"})});r(function(e){return Pt(Pt({},e),{},{emails:[].concat((0,l.A)(e.emails),[t]),inputValue:"",error:"",showUpdateButton:!0})})}},handleInputChange:function(e){r(function(t){return Pt(Pt({},t),{},{inputValue:e,error:t.error?"":t.error})})},removeEmail:function(e){r(function(t){return Pt(Pt({},t),{},{emails:t.emails.filter(function(t){return t!==e}),showUpdateButton:t.emails.length>1})})},toggleInput:function(){r(function(e){return Pt(Pt({},e),{},{showInput:!e.showInput})})},resetUpdateButton:function(){r(function(e){return Pt(Pt({},e),{},{showUpdateButton:!1})})},setEmails:function(e){r(function(t){return Pt(Pt({},t),{},{emails:e,showInput:e.length>0})})}}},Ft=function(e){var t=(0,P.useDispatch)(),n=(0,P.useSelector)(function(t){return t.revenueAnalytics[e]}),a=(0,d.useCallback)(function(a){var r="function"==typeof a?a(n):a;t((0,O.x)({key:e,value:r}))},[t,e,n]);return[n,a]};const Kt=function(){var e,t,n,m;document.title="Revenue Intelligence Setup";var f=(0,St.N2)(),v=(0,p.Yx)(),x=(0,P.useDispatch)(),I=(0,P.useStore)(),T=(0,g.useSearchParams)(),D=(0,c.A)(T,2),R=D[0],K=D[1],j=(0,P.useSelector)(function(e){return e.modules}),q=Ft("currentStep"),L=(0,c.A)(q,2),U=L[0],V=L[1],B=Ft("successSteps"),z=(0,c.A)(B,2),G=z[0],J=z[1],Y=Ft("demoModeSuccessSteps"),Q=(0,c.A)(Y,2),$=Q[0],ee=Q[1],te=Ft("selectedSources"),ne=(0,c.A)(te,2),oe=ne[0],le=ne[1],ie=Ft("selectedDataType"),ce=(0,c.A)(ie,2),me=ce[0],ue=ce[1],de=Ft("activeSourceTab"),pe=(0,c.A)(de,2),ge=pe[0],fe=pe[1],be=Ft("sourceConfigurations"),ye=(0,c.A)(be,2),ve=ye[0],xe=ye[1],he=Ft("processing"),Ee=(0,c.A)(he,2),Ne=Ee[0],we=Ee[1],Ce=Ft("saveError"),Se=(0,c.A)(Ce,2),ke=Se[0],Ae=Se[1],Ie=(0,F._K)(),De=Ie.toggleDemoMode,Re=Ie.isDemoMode,_e=(0,d.useState)(!1),Pe=(0,c.A)(_e,2),Oe=Pe[0],Me=Pe[1],Fe=(0,d.useState)(!1),Ke=(0,c.A)(Fe,2),je=Ke[0],qe=Ke[1],Le=(0,d.useState)("none"),Ue=(0,c.A)(Le,2),Ve=(Ue[0],Ue[1]),Be=Ft("originalApiKeyData"),ze=(0,c.A)(Be,2),We=ze[0];ze[1],(0,o.A)((0,tt.w)());var He=Ft("healthCheckCompletedStates"),Ge=(0,c.A)(He,2),Je=Ge[0],Ze=(Ge[1],(0,d.useState)(!1)),Ye=(0,c.A)(Ze,2)[1],Xe="revenue_analytics_demo_connections",Qe=(0,d.useState)("setup"),et=(0,c.A)(Qe,2),nt=et[0],at=et[1],rt=(0,d.useState)(!1),st=(0,c.A)(rt,2),lt=st[0],it=st[1],ct=(0,d.useState)(0),vt=(0,c.A)(ct,2),xt=vt[0],ht=vt[1],Et=(0,d.useState)([]),Nt=(0,c.A)(Et,2),_t=Nt[0],Kt=Nt[1],jt=(0,d.useState)(null),qt=(0,c.A)(jt,2),Lt=(qt[0],qt[1]),Ut=(0,d.useState)(null),Vt=(0,c.A)(Ut,2),Bt=Vt[0],zt=Vt[1],Wt=(0,d.useState)(!1),Ht=(0,c.A)(Wt,2),Gt=Ht[0],Jt=Ht[1],Zt=(0,d.useState)(null),Yt=(0,c.A)(Zt,2),Xt=Yt[0],Qt=Yt[1],$t=(0,d.useState)(!1),en=(0,c.A)($t,2),tn=en[0],nn=en[1],an=(0,d.useRef)(null),rn=(0,d.useCallback)(function(e){try{localStorage.setItem(Xe,JSON.stringify(e))}catch(e){}},[]),sn=((0,d.useCallback)(function(){try{var e=localStorage.getItem(Xe);if(e){var t=JSON.parse(e);Array.isArray(t)&&Kt(t)}}catch(e){}},[]),function(){je?(Ve("drawer-to-modal"),qe(!1),setTimeout(function(){Me(!0),Ve("none")},150)):Me(!0)}),on=function(){Oe?(Ve("modal-to-drawer"),Me(!1),setTimeout(function(){qe(!0),Ve("none")},150)):qe(!0)},ln=function(){Me(!1),qe(!1),Ve("none")},cn=(0,d.useRef)(null),mn=(0,d.useState)({newSubscriberTrigger:"fully_paid",existingSubscriberTrigger:"issued",preventInvoiceConditions:{writtenOff:!0,voided:!0,fullyRefunded:!1},pastDueHandling:"remain_past_due",autoCancelDays:14}),un=(0,c.A)(mn,2),dn=(un[0],un[1],(0,d.useState)(null)),pn=(0,c.A)(dn,2),gn=pn[0],fn=pn[1],bn=(0,d.useState)(null),yn=(0,c.A)(bn,2),vn=yn[0],xn=yn[1],hn=(0,d.useState)(null),En=(0,c.A)(hn,2),Nn=En[0],wn=En[1],Cn=(0,d.useState)(null),Sn=(0,c.A)(Cn,2),kn=Sn[0],An=Sn[1],In=(0,d.useState)(!1),Tn=(0,c.A)(In,2),Dn=Tn[0],Rn=Tn[1],_n=(0,d.useState)("group_id"),Pn=(0,c.A)(_n,2),On=Pn[0],Mn=Pn[1],Fn=(0,d.useState)(!1),Kn=(0,c.A)(Fn,2),jn=Kn[0],qn=Kn[1],Ln=(0,d.useState)(null),Un=(0,c.A)(Ln,2),Vn=Un[0],Bn=Un[1],zn=(0,d.useState)(!1),Wn=(0,c.A)(zn,2),Hn=Wn[0],Gn=Wn[1],Jn=(0,d.useRef)(null),Zn=(0,d.useRef)(null),Yn=(0,d.useState)(!1),Xn=(0,c.A)(Yn,2),Qn=Xn[0],$n=Xn[1],ea=(0,It.pI_)({client:Z.fT,fetchPolicy:"no-cache"}),ta=(0,c.A)(ea,1)[0],na=(0,se.jES)({client:Z.k3,fetchPolicy:"no-cache"}),aa=(0,c.A)(na,1)[0],ra=(0,It.xnT)({client:Z.fT,fetchPolicy:"no-cache"}),sa=((0,c.A)(ra,1)[0],(0,d.useCallback)(function(){if(Re){Math.max(542,0);return{idMissingAccountsCount:20,missingRevenueDataCount:Math.max(666,0),unidentifiedAccountsCount:378,unidentifiedFromRevenueCount:50,unidentifiedFromProductCount:328}}var e=(null==gn?void 0:gn.totalGroups)||0,t=(null==gn?void 0:gn.untrackedGroups)||0,n=(null==vn?void 0:vn.totalAccountIdentifiers)||0,a=(null==vn?void 0:vn.customerWithMissingIdentifier)||0,r=(null==vn?void 0:vn.untrackedAccountIdentifiers)||0,s=(Math.max(n-r,0),e-t),o=n-r;return{idMissingAccountsCount:a,missingRevenueDataCount:Math.max(s-o,0),unidentifiedAccountsCount:r+t,unidentifiedFromRevenueCount:r,unidentifiedFromProductCount:t}},[Re,gn,vn])()),oa=sa.idMissingAccountsCount,la=sa.missingRevenueDataCount,ia=sa.unidentifiedAccountsCount,ca=sa.unidentifiedFromRevenueCount,ma=sa.unidentifiedFromProductCount,ua=null!==(e=null==vn?void 0:vn.transactionsWithoutInvoice)&&void 0!==e?e:0;(0,d.useEffect)(function(){var e;null!==(e=ve.stripe)&&void 0!==e&&e.selectedIdentifierKey?Mn(ve.stripe.selectedIdentifierKey):Mn("group_id")},[null===(t=ve.stripe)||void 0===t?void 0:t.selectedIdentifierKey]),(0,d.useEffect)(function(){7!==U||Re||(Ye(!0),ta({variables:{input:{environmentId:(0,H.nN)()||""}},onCompleted:function(e){fn(null==e?void 0:e.getUserAndGroupTrackingStats)},onError:function(e){console.error("Error fetching user and group tracking stats:",e)}}),aa({variables:{input:{environmentId:(0,H.nN)()||""}},onCompleted:function(e){null!=e&&e.getRevenueCustomerAndAccountStats&&xn({totalCustomers:e.getRevenueCustomerAndAccountStats.totalCustomers,customerWithMissingIdentifier:e.getRevenueCustomerAndAccountStats.customerWithMissingIdentifier,totalAccountIdentifiers:e.getRevenueCustomerAndAccountStats.totalAccountIdentifiers,untrackedAccountIdentifiers:e.getRevenueCustomerAndAccountStats.untrackedAccountIdentifiers,totalGroups:e.getRevenueCustomerAndAccountStats.totalGroups,transactionsWithoutInvoice:e.getRevenueCustomerAndAccountStats.transactionsWithoutInvoice}),Ye(!1)},onError:function(e){console.error("Error fetching revenue stats:",e),Ye(!1)}}))},[U,Re,ta,aa]);var da=oe.some(function(e){return"csv"===e||"api"===e});(0,d.useEffect)(function(){(0,H.lO)("true"),window.dispatchEvent(new CustomEvent("environmentSelectorVisibilityChange",{detail:{hidden:!0}}));var e=function(){(0,H.lO)("false")};return window.addEventListener("beforeunload",e),window.addEventListener("pagehide",e),function(){(0,H.lO)("false"),window.dispatchEvent(new CustomEvent("environmentSelectorVisibilityChange",{detail:{hidden:!1}})),window.removeEventListener("beforeunload",e),window.removeEventListener("pagehide",e)}},[]),(0,d.useEffect)(function(){if(oe.length>0){var e=setTimeout(function(){!function(){var e=document.querySelector(".flex-1.overflow-auto"),t=null;if((t=cn.current?cn.current:document.getElementById("select-data-model-section"))&&e){var n=e.getBoundingClientRect(),a=t.getBoundingClientRect().top-n.top,r=e.scrollTop+a-80;e.scrollTo({top:Math.max(0,r),behavior:"smooth"})}}()},300);return function(){return clearTimeout(e)}}},[oe,da]);
1var pa=[{id:"stripe",title:"Stripe Integration",description:"Automatically sync payment data from your Stripe account",icon:N.kDV,color:"blue",status:"available",features:["Auto-sync payments","Customer data","Subscription tracking","Real-time updates"]},{id:"chargebee",title:"Chargebee Integration",description:"Automatically sync subscription and billing data from Chargebee",icon:w,color:"orange",status:"available",features:["Auto-sync subscriptions","Customer data","Invoice tracking","Real-time updates"]},{id:"api",title:"API Integration",description:"Send single or bulk records via our REST API for real-time sync",icon:y.Zap,color:"blue",status:"available",features:["Real-time sync","Bulk operations","Webhook support","Authentication"]},{id:"csv",title:"Manual CSV Upload",description:"Upload your revenue data in CSV format for one-time import",icon:y.Upload,color:"blue",status:"available",badge:"beta",features:["One-time import","Historical data","Bulk processing","Data validation"]},{id:"salesforce",title:"Salesforce Integration",description:"Import sales data directly from your Salesforce CRM",icon:y.Building2,color:"orange",status:"coming-soon",features:["CRM integration","Lead tracking","Opportunity sync","Custom fields"]}],ga=function(e){if(0===e)return"0 Bytes";var t=Math.floor(Math.log(e)/Math.log(1024));return parseFloat((e/Math.pow(1024,t)).toFixed(2))+" "+["Bytes","KB","MB","GB"][t]},fa=Ft("expandedStep2SubStep"),ba=(0,c.A)(fa,2),ya=(ba[0],ba[1],Ft("step2ImportResults")),va=(0,c.A)(ya,2),xa=va[0],ha=va[1],Ea=(0,d.useState)(Array.from({length:M.ab.length},function(){return null})),Na=(0,c.A)(Ea,2),wa=Na[0],Ca=Na[1],Sa=Ft("step2FieldMappings"),ka=(0,c.A)(Sa,2),Aa=ka[0],Ia=ka[1],Ta=Ft("step2CsvHeaders"),Da=(0,c.A)(Ta,2),Ra=Da[0],_a=Da[1],Pa=Ft("step2IsProcessing"),Oa=(0,c.A)(Pa,2),Ma=Oa[0],Fa=Oa[1],Ka=Ft("step2SubStepStatuses"),ja=(0,c.A)(Ka,2),qa=ja[0],La=ja[1],Ua=(0,d.useRef)([]),Va=(0,d.useRef)([]),Ba=(0,d.useRef)(null),za=Ft("selectedMrrPlans"),Wa=(0,c.A)(za,2),Ha=Wa[0],Ga=Wa[1],Ja=Ft("selectedMrrStatuses"),Za=(0,c.A)(Ja,2),Ya=Za[0],Xa=Za[1],Qa=Ft("selectedRevenueOptions"),$a=(0,c.A)(Qa,2),er=$a[0],tr=$a[1],nr=Ft("selectedChurnOptions"),ar=(0,c.A)(nr,2),rr=ar[0],sr=ar[1],or=(0,d.useState)(!1),lr=(0,c.A)(or,2),ir=lr[0],cr=lr[1],mr=(0,d.useState)(null),ur=(0,c.A)(mr,2),dr=ur[0],pr=ur[1],gr=(0,d.useState)(!1),fr=(0,c.A)(gr,2),br=fr[0],yr=fr[1],vr=Ft("selectedPastDueHandling"),xr=(0,c.A)(vr,2),hr=xr[0],Er=xr[1],Nr=Ft("csvDetectedStatuses"),wr=(0,c.A)(Nr,2),Cr=wr[0],Sr=wr[1],kr=Ft("isMrrCompleted"),Ar=(0,c.A)(kr,2),Ir=Ar[0],Tr=Ar[1],Dr=Ft("includeTax"),Rr=(0,c.A)(Dr,2),_r
1=Rr[0],Pr=Rr[1],Or=Ft("baseCurrency"),Mr=(0,c.A)(Or,2),Fr=Mr[0],Kr=Mr[1],jr=Ft("includeTransactionFees"),qr=(0,c.A)(jr,2),Lr=qr[0],Ur=qr[1],Vr=Ft("chargebeeFeePerTransaction"),Br=(0,c.A)(Vr,2),zr=Br[0],Wr=Br[1],Hr=Ft("paymentGatewayFees"),Gr=(0,c.A)(Hr,2),Jr=Gr[0],Zr=Gr[1],Yr=Ft("paymentGatewayType"),Xr=(0,c.A)(Yr,2),Qr=Xr[0],$r=Xr[1],es=Ft("chargebeeChargesPerTxnFee"),ts=(0,c.A)(es,2),ns=ts[0],as=ts[1],rs=Ft("selectedPaymentGateway"),ss=(0,c.A)(rs,2),os=ss[0],ls=ss[1],is=Mt(),cs=Ft("selectedApiKeyData"),ms=(0,c.A)(cs,2),us=ms[0],ds=ms[1],ps=Ft("apiKeyChanged"),gs=(0,c.A)(ps,2),fs=gs[0],bs=gs[1],ys=Ft("apiKeyMarkedComplete"),vs=(0,c.A)(ys,2),xs=(vs[0],vs[1]),hs=Ft("goals"),Es=(0,c.A)(hs,2),Ns=Es[0],ws=Es[1],Cs=(0,d.useState)(null),Ss=(0,c.A)(Cs,2),ks=Ss[0],As=Ss[1],Is=(0,d.useState)(!1),Ts=(0,c.A)(Is,2),Ds=Ts[0],Rs=Ts[1],_s=[{id:1,title:"Data Source",icon:d.createElement(y.DatabaseZap,{className:"size-5"})},{id:2,title:"Data Setup",icon:d.createElement(y.Upload,{className:"size-5"})},{id:3,title:"Core Revenue Calculation",icon:d.createElement(y.TrendingUp,{className:"size-5"})},{id:4,title:"Advance Revenue Calculation",icon:d.createElement(y.Target,{className:"size-5"})},{id:5,title:"Set Goals",icon:d.createElement(y.Goal,{className:"size-5"})},{id:6,title:"Revenue Alerts",icon:d.createElement(y.Bell,{className:"size-5"}),comingSoon:!0},{id:7,title:"Setup Health Status",icon:d.createElement(y.Gauge,{className:"size-5"})}],Ps=(0,d.useCallback)(function(){var e=R.get("step"),t=R.get("state"),n=null;if(t)try{var a=JSON.parse(decodeURIComponent(t));a.step&&(n=parseInt(a.step,10))}catch(e){console.error("Invalid state param:",e)}if(!n&&e){var r=parseInt(e,10);isNaN(r)||(n=r)}return!n||n<1||n>_s.length?null:n},[R,_s.length]),Os=(0,d.useCallback)(function(e){var t=new URLSearchParams(R);t.delete("code"),t.delete("state"),t.set("step",e.toString()),K(t,{replace:!0})},[R,K]),Ms=(0,d.useCallback)(function(){var e=new URLSearchParams(R.toString());e.delete("code"),e.delete("state"),K(e,{replace:!0})},[R,K]),Fs=(0,d.useCallback)(function(){var e=new URLSearchParams(R);e.delete("step"),K(e,{replace:!0})},[R,K]),Ks=(0,d.useCallback)(function(){var e=new URLSearchParams(R);e.delete("step"),e.delete("substep"),K(e,{replace:!0})},[R,K]),js=(0,d.useCallback)(function(e,t){if(1===e)return!0;for(var n=1;n<e;n++)if(!t.includes(n))return!1;return!0},[]),qs=(0,gt.Bd)({client:Z.Lq,fetchPolicy:"no-cache"}),Ls=(0,c.A)(qs,1)[0],Us=(0,gt.lD)({client:Z.Lq,fetchPolicy:"no-cache"}),Vs=(0,c.A)(Us,1)[0],Bs=(0,se.iOX)({client:Z.k3,fetchPolicy:"no-cache"}),zs=(0,c.A)(Bs,2),Ws=zs[0],Hs=zs[1].loading,Gs=(0,se.p7p)({client:Z.k3,fetchPolicy:"no-cache"}),Js=(0,c.A)(Gs,1)[0],Zs=(0,d.useCallback)(function(e){As(e)},[]),Ys=(0,d.useCallback)(function(){var e=(0,s.A)(u().mark(function e(t){var n,a,r,s,o;return u().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!Re){e.next=1;break}return e.abrupt("return");case 1:return s=(0,dt.MV)(t),e.next=2,Vs({variables:{input:{environmentId:null!==(n=(0,H.nN)())&&void 0!==n?n:"",productId:null!==(a=(0,H.J1)())&&void 0!==a?a:"",moduleId:"revenue_analytics",stepId:"set_goals",isCompleted:s,data:JSON.stringify({goals:t})}}});case 2:if(o=e.sent,null!==(r=o.data)&&void 0!==r&&null!==(r=r.storeCustomerAnalyticsOnboardingDetails)&&void 0!==r&&r.isSuccess){e.next=3;break}throw new Error("Failed to save onboarding step");case 3:x((0,pt.CI)({path:"revenue_analytics.set_goals",value:JSON.stringify({goals:t}),isCompleted:s})),s&&J(function(e){return e.includes(5)?e:[].concat((0,l.A)(e),[5])}),ws(t);case 4:case"end":return e.stop()}},e)}));return function(t){return e.apply(this,arguments)}}(),[Re,Vs,x,J,ws]),Xs=(0,d.useCallback)(function(){var e=(0,s.A)(u().mark(function e(t){var n,a,r,s,o,l;return u().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!Re){e.next=1;break}return e.abrupt("return");case 1:return e.next=2,Js({variables:{input:{goals:(0,dt.yN)(t),environmentId:null!==(n=(0,H.nN)())&&void 0!==n?n:"",productId:null!==(a=(0,H.J1)())&&void 0!==a?a:""}}});case 2:if(s=e.sent,null===(r=s.errors)||void 0===r||!r.length){e.next=3;break}throw new Error(null!==(o=null===(l=s.errors[0])||void 0===l?void 0:l.message)&&void 0!==o?o:"Failed to save goals");case 3:return e.next=4,Ys(t);case 4:case"end":return e.stop()}},e)}));return function(t){return e.apply(this,arguments)}}(),[Re,Js,Ys]),Qs=(0,d.useCallback)((0,s.A)(u().mark(function e(){var t;return u().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!Re){e.next=1;break}return at("list"),e.abrupt("return");case 1:if((t=ks)&&(0,dt.pP)(t)){e.next=2;break}return at("list"),e.abrupt("return");case 2:if((0,dt.MV)(t)){e.next=3;break}return e.abrupt("return");case 3:return Rs(!0),Ae(null),e.prev=4,e.next=5,Xs(t);case 5:at("list"),e.next=7;break;case 6:e.prev=6,e.catch(4),Ae("Something went wrong. Try again later.");case 7:return e.prev=7,Rs(!1),e.finish(7);case 8:case"end":return e.stop()}},e,null,[[4,6,7,8]])}
1)),[Re,ks,Xs,Ae]),$s=(0,d.useCallback)((0,s.A)(u().mark(function e(){var t;return u().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!Re){e.next=1;break}return v("/revenue-analytics/dashboard"),e.abrupt("return");case 1:if((t=ks)&&(0,dt.pP)(t)){e.next=2;break}return v("/revenue-analytics/dashboard"),e.abrupt("return");case 2:if((0,dt.MV)(t)){e.next=3;break}return e.abrupt("return");case 3:return Rs(!0),Ae(null),e.prev=4,e.next=5,Xs(t);case 5:v("/revenue-analytics/dashboard"),e.next=7;break;case 6:e.prev=6,e.catch(4),Ae("Something went wrong. Try again later.");case 7:return e.prev=7,Rs(!1),e.finish(7);case 8:case"end":return e.stop()}},e,null,[[4,6,7,8]])})),[Re,ks,Xs,v,Ae]),eo=(0,d.useCallback)(function(e,t){xe(function(n){return Pt(Pt({},n),{},(0,i.A)({},e,Pt(Pt({},n[e]),t)))})},[]),to=function(e){pr(e),yr(!0)},no=function(e){return e?e.replace(/[_\s]/g,"").toLowerCase():""},ao=function(){var e=(0,s.A)(u().mark(function e(t,n){var a,r,s,o,i,c,m;return u().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(r=null===(a=n.target.files)||void 0===a?void 0:a[0]){e.next=1;break}return e.abrupt("return");case 1:if("text/csv"===r.type||r.name.endsWith(".csv")){e.next=2;break}return alert("Invalid file type. Please upload a CSV file."),e.abrupt("return");case 2:if(!(r.size>10485760)){e.next=3;break}return alert("File too large (".concat(ga(r.size),"). Please upload a file smaller than 10MB.")),e.abrupt("return");case 3:return Ca(function(e){return e.map(function(e,n){return n===t?r:e})}),x((0,O.pJ)({index:t,fileName:r.name,fileSize:r.size})),La(function(e){return e.map(function(e,n){return n===t?"uploaded":e})}),e.prev=4,e.next=5,(0,yt.Mz)(r);case 5:s=e.sent,_a(function(e){return e.map(function(e,n){return n===t?s:e})}),o={},i=Eo[t],M.if[i.key]&&[].concat((0,l.A)(i.fields.required),(0,l.A)(i.fields.optional)).forEach(function(e){var t=e.fieldName,n=no(t),a=s.find(function(e){return no(e)===n});a&&(o[t]=a)}),Ia(function(e){return e.map(function(e,n){return n===t?o:e})}),e.next=7;break;case 6:e.prev=6,m=e.catch(4),console.error("Error extracting CSV headers:",m),c=m instanceof Error?m.message:"Unknown error occurred",alert("Error reading CSV headers: ".concat(c)),Ca(function(e){return e.map(function(e,n){return n===t?null:e})}),La(function(e){return e.map(function(e,n){return n===t?"pending":e})});case 7:case"end":return e.stop()}},e,null,[[4,6]])}));return function(t,n){return e.apply(this,arguments)}}(),ro=function(){var e=(0,s.A)(u().mark(function e(t){var n,a,r,s,o,l,i,m,d,p,g,f,b,y,v,x,h,E;return u().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(n=wa[t],a=Aa[t],n){e.next=1;break}return e.abrupt("return");case 1:if(Fa(function(e){return e.map(function(e,n){return n===t||e})}),La(function(e){return e.map(function(e,n){return n===t?"processing":e})}),e.prev=2,o=M.ab[t],M.if[o.key]){e.next=3;break}throw new Error("No field mapping found for substep: ".concat(o.key));case 3:return l=me===M.ko.INVOICE_TRANSACTION,i={},Object.entries(a).forEach(function(e){var t,n,a,r=(0,c.A)(e,2),s=r[0],m=r[1];l&&"transactions"===o.key?t=M.LP[s]:t=null===(n=M.if[o.key])||void 0===n?void 0:n[s];l&&"invoices"===o.key?t=M.gk[s]:t=null===(a=M.if[o.key])||void 0===a?void 0:a[s];t&&m&&(i[t]=m)}),"transactions"===o.key&&me===M.ko.INVOICE_TRANSACTION&&(Object.keys(i).forEac
1h(function(e){return delete i[e]}),Object.entries(a).forEach(function(e){var t=(0,c.A)(e,2),n=t[0],a=t[1],r=M.LP[n];r&&a&&(i[r]=a)})),m=new FormData,d={query:"\n mutation UploadCsv($input: CsvUploadInput!) {\n uploadCsv(input: $input) {\n success\n message\n batchId\n totalRows\n processedRows\n skippedRows\n duplicateRows\n errorRows\n errors {\n rowNumber\n tempId\n error\n rowData\n }\n processingTimeMs\n }\n }\n ",variables:{input:{productId:null!==(r=(0,H.J1)())&&void 0!==r?r:"",environmentId:null!==(s=(0,H.nN)())&&void 0!==s?s:"",file:null,entityType:(0,M.$P)(o.key),dataSource:se.qSh.Manual,fieldMappings:JSON.stringify(i),skipDuplicateCheck:!1,dataModelType:se.sYE.TransactionOnly}}},p={0:["variables.input.file"]},m.append("operations",JSON.stringify(d)),m.append("map",JSON.stringify(p)),m.append("0",n),e.next=4,fetch("".concat(X.S.REVENUE),{method:"POST",headers:{Authorization:"Bearer ".concat(Ot)},body:m});case 4:if((g=e.sent).ok){e.next=6;break}return e.next=5,g.text();case 5:throw f=e.sent,new Error("HTTP ".concat(g.status,": ").concat(g.statusText," - ").concat(f));case 6:return e.next=7,g.json();case 7:if(!((b=e.sent).errors&&b.errors.length>0)){e.next=8;break}throw new Error(b.errors[0].message);case 8:if(b.data&&b.data.uploadCsv){e.next=9;break}throw new Error("Invalid response format from upload API");case 9:y=b.data.uploadCsv,v={totalRows:y.totalRows,processedRows:y.processedRows,skippedRows:y.skippedRows,duplicateRows:y.duplicateRows,errorRows:y.errorRows,errors:y.errors||[],batchId:y.batchId,success:y.success,message:y.message,processingTimeMs:y.processingTimeMs,csvFileName:n.name,originalFileSize:n.size,savedAt:(new Date).toISOString(),isRestored:!1},ha(function(e){return e.map(function(e,n){return n===t?v:e})}),x=y.success&&0===y.errorRows?"completed":y.success&&y.errorRows>0?"completed_with_errors":"error",La(function(e){return e.map(function(e,n){return n===t?x:e})}),fo(),e.next=11;break;case 10:e.prev=10,E=e.catch(2),console.error("GraphQL upload failed:",E),La(function(e){return e.map(function(e,n){return n===t?"error":e})}),h={totalRows:0,processedRows:0,skippedRows:0,duplicateRows:0,errorRows:0,errors:[{rowNumber:0,tempId:"",error:E.message||"Upload failed",rowData:{}}],batchId:"",success:!1,message:E.message||"Upload failed - check console for details",processingTimeMs:0,csvFileName:n.name,originalFileSize:n.size,savedAt:(new Date).toISOString(),isRestored:!1},ha(function(e){return e.map(function(e,n){return n===t?h:e})});case 11:return e.prev=11,Fa(function(e){return e.map(function(e,n){return n!==t&&e})}),e.finish(11);case 12:case"end":return e.stop()}},e,null,[[2,10,11,12]])}));return function(t){return e.apply(this,arguments)}}(),so=function(e){if(Re)return!!$.includes(e)||(1===e?oe.length>0:2===e?mo():3===e?G.includes(e)||Ir:4===e?G.includes(e)||er.length>0:5===e&&Object.values(Ns).some(function(e){return!(null==e||!e.enabled)}));if(1===e)return yo(1);if(2===e)return co();if(3===e)return G.includes(e)||Ir;if(4===e)return G.includes(e)||er.length>0;if(5===e)return Object.values(Ns).some(function(e){return!(null==e||!e.enabled)});if(G.includes(e))return!0;if(2===e||3===e||4===e)return!1;var t=j.find(function(e){return"revenue_analytics"===e.moduleId});if(!t)return!1;var n=M.EW[e];if(!n)return!1;var a=t.stepDetails.find(function(e){return e.stepId===n});return!!a&&a.isCompleted},oo=(0,d.useCallback)(function(e,t,n){if("csv"===e){var a=(0,M.Hu)(me,M.ab);return a.length>0&&a.every(function(e){var t,n=M.ab.findIndex(function(t){return t.key===e});return-1!==n&&(null===(t=xa[n])||void 0===t?void 0:t.success)})}var r=null==t?void 0:t[e];if(!r)return!1;switch(e){case"api":return"configured"===r.status&&!0===r.completed&&!0===(null==n?void 0:n["transactions-POST"])&&!0===(null==n?void 0:n["invoices-POST"]);case"stripe":case"chargebee":return"configured"===r.status&&!0===r.completed||!!(r.step1Completed&&r.step2Completed&&r.step3Completed&&r.step4Completed);case"quickbooks":return!!r.step4Completed;case"salesforce":return"configured"===r.status&&!0===r.completed;default:return!("configured"!==r.status||!0!==r.completed)}},[me,M.ab,xa]),lo=(0,d.useCallback)(function(e,t,n){if("csv"===e)return(null!=xa?xa:[]).some(function(e){return null==e?void 0:e.success}
1)||oo("csv",t,n);var a=null==t?void 0:t[e];if(!a)return!1;switch(e){case"api":case"salesforce":default:return"configured"===a.status;case"stripe":case"chargebee":case"quickbooks":return!!(a.step1Completed||a.step2Completed||a.step3Completed||a.step4Completed)||"configured"===a.status&&!0===a.completed}},[oo,xa]),io=function(e){var t,n,a,r,s,o,l,i,c,m,u,d,p,g,f,b,y;switch(e){case"csv":return(0,M.Hu)(me,M.ab).every(function(e){var t,n=M.ab.findIndex(function(t){return t.key===e});return-1!==n&&(null===(t=xa[n])||void 0===t?void 0:t.success)});case"api":return"configured"===(null===(t=ve.api)||void 0===t?void 0:t.status)&&!0===(null===(n=ve.api)||void 0===n?void 0:n.completed)&&!0===Je["transactions-POST"]&&!0===Je["invoices-POST"];case"stripe":return"configured"===(null===(a=ve.stripe)||void 0===a?void 0:a.status)&&!0===(null===(r=ve.stripe)||void 0===r?void 0:r.completed)||(null===(s=ve.stripe)||void 0===s?void 0:s.step1Completed)&&(null===(o=ve.stripe)||void 0===o?void 0:o.step2Completed)&&(null===(l=ve.stripe)||void 0===l?void 0:l.step3Completed)&&(null===(i=ve.stripe)||void 0===i?void 0:i.step4Completed);case"chargebee":return"configured"===(null===(c=ve.chargebee)||void 0===c?void 0:c.status)&&!0===(null===(m=ve.chargebee)||void 0===m?void 0:m.completed)||(null===(u=ve.chargebee)||void 0===u?void 0:u.step1Completed)&&(null===(d=ve.chargebee)||void 0===d?void 0:d.step2Completed)&&(null===(p=ve.chargebee)||void 0===p?void 0:p.step3Completed)&&(null===(g=ve.chargebee)||void 0===g?void 0:g.step4Completed);case"quickbooks":return!(null===(f=ve.quickbooks)||void 0===f||!f.step4Completed);case"salesforce":return"configured"===(null===(b=ve.salesforce)||void 0===b?void 0:b.status)&&!0===(null===(y=ve.salesforce)||void 0===y?void 0:y.completed);default:return!1}},co=function(){return 0!==oe.length&&(ge&&oe.includes(ge)?io(ge):!!(Re?$.includes(2):G.includes(2))||oe.some(function(e){return io(e)}))},mo=function(){return 0!==oe.length&&(!!(Re?$.includes(2):G.includes(2))||oe.some(function(e){var t,n,a,r,s,o,l,i,c,m,u,d,p,g,f,b,y;switch(e){case"csv":return(0,M.Hu)(me,M.ab).some(function(e){var t,n=M.ab.findIndex(function(t){return t.key===e});return-1!==n&&(null===(t=xa[n])||void 0===t?void 0:t.success)});case"api":return"configured"===(null===(t=ve.api)||void 0===t?void 0:t.status)&&!0===(null===(n=ve.api)||void 0===n?void 0:n.completed)&&!0===Je["transactions-POST"]&&!0===Je["invoices-POST"];case"stripe":return"configured"===(null===(a=ve.stripe)||void 0===a?void 0:a.status)&&!0===(null===(r=ve.stripe)||void 0===r?void 0:r.completed)||(null===(s=ve.stripe)||void 0===s?void 0:s.step1Completed)&&(null===(o=ve.stripe)||void 0===o?void 0:o.step2Completed)&&(null===(l=ve.stripe)||void 0===l?void 0:l.step3Completed)&&(null===(i=ve.stripe)||void 0===i?void 0:i.step4Completed);case"chargebee":return"configured"===(null===(c=ve.chargebee)||void 0===c?void 0:c.status)&&!0===(null===(m=ve.chargebee)||void 0===m?void 0:m.completed)||(null===(u=ve.chargebee)||void 0===u?void 0:u.step1Completed)&&(null===(d=ve.chargebee)||void 0===d?void 0:d.step2Completed)&&(null===(p=ve.chargebee)||void 0===p?void 0:p.step3Completed)&&(null===(g=ve.chargebee)||void 0===g?void 0:g.step4Completed);case"quickbooks":return!(null===(f=ve.quickbooks)||void 0===f||!f.step4Completed);case"salesforce":return"configured"===(null===(b=ve.salesforce)||void 0===b?void 0:b.status)&&!0===(null===(y=ve.salesforce)||void 0===y?void 0:y.completed);default:return!1}}))},uo=function(){var e,t;Re?cr(!0):Ls({variables:{input:{productId:null!==(e=(0,H.J1)())&&void 0!==e?e:"",environmentId:null!==(t=(0,H.nN)())&&void 0!==t?t:"",moduleId:"revenue_analytics"}},onCompleted:function(e){var t,n,a=(null==e||null===(t=e.getCAOnboardingStepDetails)||void 0===t?void 0:t.moduleDetails)||[];po(a),cr(!0);var r=I.getState().revenueAnalytics,s=null!==(n=r.successSteps)&&void 0!==n?n:[],o=function(e){for(var t=1;t<=go;t++)if(!e.includes(t))return t;return go}(s),l=r.sourceConfigurations||{},i=r.healthCheckCompletedStates||{},c=Object.keys(l).some(function(e){return lo(e,l,i)}),m=new URLSearchParams(window.location.search),u=m.get("code"),d=m.get("state"),p="str
1ipe",g=!!(u&&d&&function(){try{var e=JSON.parse(decodeURIComponent(d));return!(!e||"number"!=typeof e.step||2!==e.step)&&(e.source&&(p=e.source),!0)}catch(e){return!1}}());if(c&&!g?at("list"):g&&(at("setup"),V(2),fe(p),Os(2)),!g){var f=Ps();f&&js(f,s)?V(f):(V(o),f||Os(o))}},onError:function(e){console.error("Error loading onboarding data:",e),cr(!0),V(1)}})},po=function(e){if(e&&0!==e.length){var t=e.find(function(e){return"revenue_analytics"===e.moduleId});if(t){var n="";t.stepDetails.forEach(function(e){try{var t=JSON.parse(e.value||"{}");!t.activeSourceTab||"data_source"!==e.stepId&&"data_setup"!==e.stepId||(n=t.activeSourceTab)}catch(e){}});var a={sourceConfigurations:{}},r=function(e,t){t&&Object.keys(t).forEach(function(n){e[n]=Pt(Pt({},e[n]),t[n])})};t.stepDetails.forEach(function(e){try{var s=JSON.parse(e.value||"{}");switch(e.stepId){case"data_source":s.selectedSources&&(a.selectedSources=s.selectedSources),s.selectedDataType&&(a.selectedDataType=s.selectedDataType),s.activeSourceTab&&(a.activeSourceTab=s.activeSourceTab),s.sourceConfigurations&&Object.entries(s.sourceConfigurations).forEach(function(e){var t=(0,c.A)(e,2),n=t[0],r=t[1];null!=r&&r.sourceCategory&&(a.sourceConfigurations[n]=Pt(Pt({},a.sourceConfigurations[n]),{},{sourceCategory:r.sourceCategory}))});break;case"data_setup":if(s.selectedSources&&(a.selectedSources=s.selectedSources),s.selectedDataType&&(a.selectedDataType=s.selectedDataType),s.activeSourceTab&&(a.activeSourceTab=s.activeSourceTab),s.stripeStepDetails){var o,l,m,u,d,p,g,f,b=s.stripeStepDetails,y=b.step1Completed||!1,v=b.step2Completed||!1,x=b.step3Completed||!1,h=b.step4Completed||!1,E=(null===(o=s.sourceConfigurations)||void 0===o?void 0:o.stripe)||{},N=(b.testingSteps||[]).find(function(e){return"schema"===(null==e?void 0:e.id)});a.loadedStripeData=s.stripeStepDetails,a.sourceConfigurations.stripe=Pt(Pt(Pt({},a.sourceConfigurations.stripe),b.formData),{},{step1Completed:y,step2Completed:v,step3Completed:x,isStep3Incomplete:b.isStep3Incomplete||!1,testingSteps:b.testingSteps||[],testCompleted:b.testCompleted||!1,step4Completed:h,ingestionResult:b.ingestionResult||null,schemaVerified:b.schemaVerified||!1,completedAt:b.completedAt||null,selectedIdentifierKey:null!==(l=null!==(m=b.selectedIdentifierKey)&&void 0!==m?m:E.selectedIdentifierKey)&&void 0!==l?l:null==N?void 0:N.selectedIdentifierKey,customerMetaDataKeys:null!==(u=null!==(d=null!==(p=b.customerMetaDataKeys)&&void 0!==p?p:E.customerMetaDataKeys)&&void 0!==d?d:null==N?void 0:N.customerMetaDataKeys)&&void 0!==u?u:[],groupIdFound:null!==(g=null!==(f=b.groupIdFound)&&void 0!==f?f:E.groupIdFound)&&void 0!==g&&g,status:"configured",completed:y&&v&&x&&h,notificationEmails:b.notificationEmails||null,pendingSecretKeyChange:E.pendingSecretKeyChange||!1,pendingSyncDateChange:E.pendingSyncDateChange||!1,step4WasEverCompleted:E.step4WasEverCompleted||b.step4CompletedAt||!1,step3CompletedAt:E.step3CompletedAt||null,step4CompletedAt:E.step4CompletedAt||null})}if(s.chargebeeStepDetails){var w,C=s.chargebeeStepDetails,S=C.step1Completed||!1,k=C.step2Completed||!1,A=C.step3Completed||!1,I=C.step4Completed||!1,T=(null===(w=s.sourceConfigurations)||void 0===w?void 0:w.chargebee)||{};a.sourceConfigurations.chargebee=Pt(Pt(Pt({},a.sourceConfigurations.chargebee),C.formData),{},{step1Completed:S,step2Completed:k,step3Completed:A,step4Completed:I,isStep3Incomplete:C.isStep3Incomplete||!1,testingSteps:C.testingSteps||[],testCompleted:C.testCompleted||!1,ingestionResult:C.ingestionResult||null,schemaVerified:C.schemaVerified||!1,completedAt:C.completedAt||null,selectedIdentifierKey:C.selectedIdentifierKey||"group_id",customerMetaDataKeys:C.customerMetaDataKeys||[],groupIdFound:C.groupIdFound||!1,status:"configured",completed:S&&k&&A&&I,notificationEmails:C.notificationEmails||null,pendingApiKeyChange:T.pendingApiKeyChange||!1,pendingSyncDateChange:T.pendingSyncDateChange||!1,step4WasEverCompleted:T.step4WasEverCompleted||C.step4CompletedAt||!1,step3CompletedAt:T.step3CompletedAt||null,step4CompletedAt:T.step4CompletedAt||null})}if(s.quickbooksStepDetails){var D=s.quickbooksStepDetails;a.sourceConfigurations.quickbooks=Pt(Pt(Pt({},a.sourceConfigurations.quickbooks),D.formData),{},{step1Completed:D.step1Completed||!1,step2Completed:D.step2Completed||!1,step3Completed:D.step3Completed||!1,step4Completed:D.step4Completed||!1,testCompleted:D.testCompleted||!1,itemsStepCompleted:D.itemsStepCompleted||!1,mrrItems:D.mrrItems||[],ingestionResult:D.ingestionResult||null,completedAt:D.completedAt||null,notificationEmails:D.notificationEmails||null})}var R=t.stepDetails.find(function(e){return"data_setup"===e.stepId});if(R&&R.isCompleted&&s.sourceConfigurations&&Object.keys(s.sourceConfigurations).forEac
1h(function(e){var t=s.sourceConfigurations[e];t&&!t.step2Completed&&((!0===t.completed||"configured"===t.status||t.step1Completed&&t.step2Completed&&t.step3Completed&&t.step4Completed)&&(a.sourceConfigurations[e]=Pt(Pt(Pt({},a.sourceConfigurations[e]),t),{},{step2Completed:!0})))}),s.subStepsData){var _,P,O,F,K,j=null!==(_=a.step2ImportResults)&&void 0!==_?_:Array.from({length:M.ab.length},function(){return null}),q=null!==(P=a.step2FieldMappings)&&void 0!==P?P:Array.from({length:M.ab.length},function(){return{}}),L=null!==(O=a.step2CsvHeaders)&&void 0!==O?O:Array.from({length:M.ab.length},function(){return[]}),U=null!==(F=a.step2SubStepStatuses)&&void 0!==F?F:Array.from({length:M.ab.length},function(){return"pending"});s.subStepsData.forEach(function(e,t){var n,a;(e.status&&(U[t]=e.status),e.importResult)&&(j[t]=Pt(Pt({},e.importResult),{},{isRestored:!0,csvFileName:e.importResult.csvFileName||(null===(n=e.fileInfo)||void 0===n?void 0:n.fileName)||"Unknown file",originalFileSize:e.importResult.originalFileSize||(null===(a=e.fileInfo)||void 0===a?void 0:a.fileSize)||0}));e.csvHeaders&&(L[t]=e.csvHeaders),e.fieldMapping&&(q[t]=e.fieldMapping)}),a.step2ImportResults=j,a.step2FieldMappings=q,a.step2CsvHeaders=L,a.step2SubStepStatuses=U,null!==(K=s.subStepsData[4])&&void 0!==K&&K.csvStatuses&&(a.csvDetectedStatuses=s.subStepsData[4].csvStatuses)}if(s.sourceConfigurations&&Object.keys(s.sourceConfigurations).forEach(function(e){"stripe"!==e&&"chargebee"!==e?r(a.sourceConfigurations,(0,i.A)({},e,s.sourceConfigurations[e])):"chargebee"!==e||s.chargebeeStepDetails?"stripe"!==e||s.stripeStepDetails||r(a.sourceConfigurations,{stripe:s.sourceConfigurations.stripe}):r(a.sourceConfigurations,{chargebee:s.sourceConfigurations.chargebee})}),Object.keys(a.sourceConfigurations).forEach(function(e){var t=a.sourceConfigurations[e];t&&!t.step2Completed&&((!0===t.completed||"configured"===t.status||t.step1Completed&&t.step2Completed&&t.step3Completed&&t.step4Completed)&&(a.sourceConfigurations[e]=Pt(Pt({},t),{},{step2Completed:!0})))}),s.apiKeyInfo){var V={selectedApiKeyId:s.apiKeyInfo.selectedApiKeyId||null,selectedApiKey:s.apiKeyInfo.selectedApiKey||null};a.selectedApiKeyData=V,a.originalApiKeyData=V,a.apiKeyChanged=!1,a.apiKeyMarkedComplete=!0,s.apiKeyInfo.selectedApiKeyId&&(a.sourceConfigurations.api=Pt(Pt({},a.sourceConfigurations.api),{},{status:"configured",completed:!0}))}s.healthCheckStates&&(a.healthCheckCompletedStates=s.healthCheckStates);break;case"core_revenue_calculation":var B=void 0!==s.selectedMrrPlans||void 0!==s.selectedMrrStatuses||void 0!==s.baseCurrency,z=!B&&s.sourceConfigurations&&Object.keys(s.sourceConfigurations).some(function(e){return void 0!==s.sourceConfigurations[e].step3Completed||void 0!==s.sourceConfigurations[e].selectedMrrPlans}),W=a.activeSourceTab||n;if(B){s.selectedMrrPlans&&(a.selectedMrrPlans=s.selectedMrrPlans),s.selectedMrrStatuses&&(a.selectedMrrStatuses=s.selectedMrrStatuses),void 0!==s.selectedPastDueHandling&&(a.selectedPastDueHandling=s.selectedPastDueHandling),void 0!==s.includeTax&&(a.includeTax=s.includeTax),s.baseCurrency&&(a.baseCurrency=s.baseCurrency),void 0!==s.includeTransactionFees&&(a.includeTransactionFees=s.includeTransactionFees),"number"==typeof s.chargebeeFeePerTransaction&&(a.chargebeeFeePerTransaction=s.chargebeeFeePerTransaction),"number"==typeof s.paymentGatewayFees&&(a.paymentGatewayFees=s.paymentGatewayFees),"boolean"==typeof s.chargebeeChargesPerTxnFee?a.chargebeeChargesPerTxnFee=s.chargebeeChargesPerTxnFee:"number"==typeof s.chargebeeFeePerTransaction&&(a.chargebeeChargesPerTxnFee=s.chargebeeFeePerTransaction>0);var H=t.stepDetails.find(function(e){return"core_revenue_calculation"===e.stepId});H&&H.isCompleted&&s.sourceConfigurations&&Object.keys(s.sourceConfigurations).forEach(function(e){a.sourceConfigurations[e]=Pt(Pt({},a.sourceConfigurations[e]),{},{step3Completed:!0})})}else if(z&&W&&s.sourceConfigurations[W]){var G=s.sourceConfigurations[W];G.selectedMrrPlans&&(a.selectedMrrPlans=G.selectedMrrPlans),G.selectedMrrStatuses&&(a.selectedMrrStatuses=G.selectedMrrStatuses),void 0!==G.selectedPastDueHandling&&(a.selectedPastDueHandling=G.selectedPastDueHandling),void 0!==G.includeTax&&(a.includeTax=G.includeTax),G.baseCurrency&&(a.baseCurrency=G.baseCurrency),void 0!==G.includeTransactionFees&&(a.includeTransactionFees=G.includeTransactionFees),"number"==typeof G.chargebeeFeePerTransaction&&(a.chargebeeFeePerTransaction=G.chargebeeFeePerTransaction),"number"==typeof G.paymentGatewayFees&&(a.paymentGatewayFees=G.paymentGatewayFees),"boolean"==typeof G.chargebeeChargesPerTxnFee&&(a.chargebeeChargesPerTxnFee=G.chargebeeChargesPerTxnFee),void 0!==G.step3Completed&&(a.sourceConfigurations[W]=Pt(Pt(Pt({},a.sourceConfigurations[W]),G),{},{step3Completed:G.step3Completed}))}break;case"advance_revenue_calculation":var J=s.sourceConfigurations&&Object.keys(s.sourceConfigurations).some(function(e){return void 0!==s.sourceConfigurations[e].step4Completed||void 0!==s.sourceConfigurations[e].selectedRevenueOptions}),Z=a.activeSourceTab||n;if(J&&Z&&s.sourceConfigurations[Z]){var Y=s.sourceConfigurations[Z];Y.selectedRevenueOptions&&(a.selectedRevenueOptions=Y.selectedRevenueOptions),Y.selectedChurnOptions&&(a.selectedChurnOptions=Y.selectedChurnOptions),void 0!==Y.step4Completed&&(a.sourceConfigurations[Z]=Pt(Pt(Pt({},a.sourceConfigurations[Z]),Y),{},{step4Completed:Y.step4Completed}))}else{var X=(0,M.Xc)(s);a.selectedRevenueOptions=X.selectedRevenueOptions,a.selectedChurnOptions=X.selectedChurnOptions;var Q=t.stepDetails.find(function(e){return"advance_revenue_calculation"===e.stepId});Q&&Q.isCompleted&&s.sourceConfigurations&&Object.keys(s.sourceConfigurations).forEac
1h(function(e){a.sourceConfigurations[e]=Pt(Pt({},a.sourceConfigurations[e]),{},{step4Completed:!0})})}break;case"set_goals":s.goals&&(a.goals=s.goals)}}catch(e){console.error("Error parsing step data:",e)}});var s=[];t.stepDetails.forEach(function(e){if(e.isCompleted){var t=Object.keys(M.EW).find(function(t){return M.EW[parseInt(t)]===e.stepId});t&&s.push(parseInt(t))}}),a.successSteps=s,x((0,O.zW)(a))}}},go=6,fo=function(){if(2===U){var e,t=I.getState().revenueAnalytics,n=Pt({},t.sourceConfigurations||{});t.originalApiKeyData&&(t.originalApiKeyData.selectedApiKeyId||t.originalApiKeyData.selectedApiKey)?e=t.originalApiKeyData:t.selectedApiKeyData&&(t.selectedApiKeyData.selectedApiKeyId||t.selectedApiKeyData.selectedApiKey)&&(e=t.selectedApiKeyData);var a=Pt(Pt({selectedSources:t.selectedSources,selectedDataType:t.selectedDataType,sourceConfigurations:n,activeSourceTab:t.activeSourceTab},e&&{apiKeyInfo:e}),{},{healthCheckStates:t.healthCheckCompletedStates});n.stripe&&Object.keys(n.stripe).length>0?a.stripeStepDetails={step1Completed:!(!n.stripe.environmentId||!n.stripe.stripeEnvironment),step2Completed:!!(n.stripe.sourceName&&n.stripe.accountId&&n.stripe.secretKey&&n.stripe.syncStartDate),step3Completed:n.stripe.step3Completed||!1,step4Completed:n.stripe.step4Completed||!1,testCompleted:n.stripe.testCompleted||!1,isStep3Incomplete:n.stripe.isStep3Incomplete||!1,testingSteps:n.stripe.testingSteps||[],selectedIdentifierKey:n.stripe.selectedIdentifierKey||"group_id",customerMetaDataKeys:n.stripe.customerMetaDataKeys||[],groupIdFound:n.stripe.groupIdFound||!1,formData:{sourceName:n.stripe.sourceName||"Stripe",accountId:n.stripe.accountId||"",secretKey:n.stripe.secretKey||"",dataRetentionLocation:n.stripe.dataRetentionLocation||"",syncStartDate:n.stripe.syncStartDate||"",groupIdMapping:n.stripe.groupIdMapping||!1,environmentId:n.stripe.environmentId||"",environmentName:n.stripe.environmentName||"",stripeEnvironment:n.stripe.stripeEnvironment||""},ingestionResult:n.stripe.ingestionResult||null,schemaVerified:n.stripe.schemaVerified||!1,completedAt:n.stripe.completedAt||null,notificationEmails:n.stripe.notificationEmails||null}:t.loadedStripeData&&Object.keys(t.loadedStripeData).length>0&&(a.stripeStepDetails=t.loadedStripeData),n.chargebee&&Object.keys(n.chargebee).length>0&&(a.chargebeeStepDetails={step1Completed:!(!n.chargebee.environmentId||!n.chargebee.chargebeeEnvironment),step2Completed:!!(n.chargebee.sourceName&&n.chargebee.subdomain&&n.chargebee.apiKey&&n.chargebee.syncStartDate),step3Completed:n.chargebee.step3Completed||!1,step4Completed:n.chargebee.step4Completed||!1,testCompleted:n.chargebee.testCompleted||!1,isStep3Incomplete:n.chargebee.isStep3Incomplete||!1,testingSteps:n.chargebee.testingSteps||[],selectedIdentifierKey:n.chargebee.selectedIdentifierKey||"group_id",customerMetaDataKeys:n.chargebee.customerMetaDataKeys||[],groupIdFound:n.chargebee.groupIdFound||!1,formData:{sourceName:n.chargebee.sourceName||"Chargebee",subdomain:n.chargebee.subdomain||"",apiKey:n.chargebee.apiKey||"",secretKey:n.chargebee.secretKey||"",productCatalog:n.chargebee.productCatalog||"2.0",dataRetentionLocation:n.chargebee.dataRetentionLocation||"",syncStartDate:n.chargebee.syncStartDate||"",groupIdMapping:n.chargebee.groupIdMapping||!1,environmentId:n.chargebee.environmentId||"",environmentName:n.chargebee.environmentName||"",chargebeeEnvironment:n.chargebee.chargebeeEnvironment||""},ingestionResult:n.chargebee.ingestionResult||null,schemaVerified:n.chargebee.schemaVerified||!1,completedAt:n.chargebee.completedAt||null,notificationEmails:n.chargebee.notificationEmails||null}),n.quickbooks&&Object.keys(n.quickbooks).length>0&&(a.quickbooksStepDetails={step1Completed:n.quickbooks.step1Completed||!1,step2Completed:n.quickbooks.step2Completed||!1,step3Completed:n.quickbooks.step3Completed||!1,step4Completed:n.quickbooks.step4Completed||!1,testCompleted:n.quickbooks.testCompleted||!1,itemsStepCompleted:n.quickbooks.itemsStepCompleted||!1,mrrItems:n.quickbooks.mrrItems||[],formData:{sourceName:n.quickbooks.sourceName||"QuickBooks",startDate:n.quickbooks.startDate||"",realmId:n.quickbooks.realmId||"",companyName:n.quickbooks.companyName||"",environmentId:n.quickbooks.environmentId||"",quickbooksEnvironment:n.quickbooks.quickbooksEnvironment||"",sandbox:n.quickbooks.sandbox||!1},ingestionResult:n.quickbooks.ingestionResult||null,completedAt:n.quickbooks.completedAt||null,notificationEmails:n.quickbooks.notificationEmails||null}),a.subStepsData=M.ab.map(function(e,n){var a=t.step2ImportResults[n],r=wa[n],s=t.step2FileInfos[n],o=t.step2FieldMappings[n],l=t.step2CsvHeaders[n],i=6===n?t.csvDetectedStatuses:[],c=r?{fileName:r.name,fileSize:r.size,uploadedAt:(new Date).toISOString()}:null!=s&&s.fileName?{fileName:s.fileName,fileSize:s.fileSize,uploadedAt:(new Date).toISOString()}:null;return{key:e.key,title:e.title,status:t.step2SubStepStatuses[n],fileInfo:c,csvHeaders:l||[],csvStatuses:i||[],fieldMapping:o||{},importResult:a?{totalRows:a.totalRows||0,processedRows:a.processedRows||0,skippedRows:a.skippedRows||0,duplicateRows:a.duplicateRows||0,errorRows:a.errorRows||0,hasErrors:!!(a.errors&&a.errors.length>0),errorCount:a.errors?a.errors.length:0,firstFewErrors:a.errors?a.errors.slice(0,3):[],batchId:a.batchId||"",success:a.success||!1,message:a.message||"",processingTimeMs:a.processingTimeMs||0,savedAt:(new Date).toISOString(),csvFileName:(null==r?void 0:r.name)||a.csvFileName||"Unknown file",originalFileSize:(null==r?void 0:r.size)||a.originalFileSize||0}:null}}
1),Object.keys(n).forEach(function(e){var t=n[e];if(t){var a=io(e);n[e]=Pt(Pt({},t),{},{step2Completed:a})}}),a.completionSummary={totalSubSteps:t.selectedSources.length,completedSubSteps:t.selectedSources.filter(function(e){var a,r,s,o,l,i;switch(e){case"csv":return(0,M.Hu)(t.selectedDataType,M.ab).some(function(e){var n=M.ab.findIndex(function(t){return t.key===e});return-1!==n&&null!==t.step2ImportResults[n]});case"api":return"configured"===(null===(a=n.api)||void 0===a?void 0:a.status)&&!0===(null===(r=n.api)||void 0===r?void 0:r.completed)&&!0===t.healthCheckCompletedStates["transactions-POST"]&&!0===t.healthCheckCompletedStates["invoices-POST"];case"stripe":return"configured"===(null===(s=n.stripe)||void 0===s?void 0:s.status)&&!0===(null===(o=n.stripe)||void 0===o?void 0:o.completed);case"salesforce":return"configured"===(null===(l=n.salesforce)||void 0===l?void 0:l.status)&&!0===(null===(i=n.salesforce)||void 0===i?void 0:i.completed);default:return!1}}).length,isFullyCompleted:co(),autoSavedAt:(new Date).toISOString(),hasAnyImportAttempts:t.step2ImportResults.some(function(e){return null!==e})},bo(a,!0),x((0,O.x)({key:"sourceConfigurations",value:n}));var r=Re?t.demoModeSuccessSteps.includes(2):t.successSteps.includes(2);if(co()&&!r)t.selectedSources.every(function(e){var a,r,s,o,l,i;switch(e){case"csv":return(0,M.Hu)(t.selectedDataType,M.ab).every(function(e){var n,a=M.ab.findIndex(function(t){return t.key===e});return-1!==a&&(null===(n=t.step2ImportResults[a])||void 0===n?void 0:n.success)});case"api":return"configured"===(null===(a=n.api)||void 0===a?void 0:a.status)&&!0===(null===(r=n.api)||void 0===r?void 0:r.completed)&&!0===t.healthCheckCompletedStates["transactions-POST"]&&!0===t.healthCheckCompletedStates["invoices-POST"];case"stripe":return"configured"===(null===(s=n.stripe)||void 0===s?void 0:s.status)&&!0===(null===(o=n.stripe)||void 0===o?void 0:o.completed);case"salesforce":return"configured"===(null===(l=n.salesforce)||void 0===l?void 0:l.status)&&!0===(null===(i=n.salesforce)||void 0===i?void 0:i.completed);default:return!1}})&&x(Re?(0,O.x)({key:"demoModeSuccessSteps",value:[].concat((0,l.A)(t.demoModeSuccessSteps),[2])}):(0,O.x)({key:"successSteps",value:[].concat((0,l.A)(t.successSteps),[2])}))}},bo=function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(Re)we(!1);else try{var n,a,r=yo(U);Vs({variables:{input:{environmentId:null!==(n=(0,H.nN)())&&void 0!==n?n:"",productId:null!==(a=(0,H.J1)())&&void 0!==a?a:"",isCompleted:!0===r,moduleId:"revenue_analytics",stepId:M.EW[U],data:JSON.stringify(e)}},onCompleted:function(n){var a=M.EW[U];a&&(t||2===U||vo(U,e),x(2!==U&&3!==U&&4!==U?(0,pt.CI)({path:"revenue_analytics.".concat(a),value:JSON.stringify(e),isCompleted:yo(U)}):(0,pt.CI)({path:"revenue_analytics.".concat(a),value:JSON.stringify(e),isCompleted:!1})))},onError:function(e){Ae("Something went wrong. Try again later.")}})}catch(e){Ae("Something went wrong. Try again later.")}finally{we(!1)}},yo=function(e){switch(e){case 1:return oe.length>0&&(!["csv","api"].some(function(e){return oe.includes(e)})||me.length>0);case 2:return co();case 3:return G.includes(3)||Ir;case 4:return G.includes(4)||er.length>0;case 5:return(0,dt.MV)(Ns);case 6:return!1;default:return!0}};function vo(e,t){var n,a;if(!Re){var s=M.Bh[e],o=M.EW[e],l=null===(n=(0,H.wz)())||void 0===n?void 0:n.id,i=s?[{event_name:s}]:[];if(1===e&&t&&"object"===(0,r.A)(t)){var c,m=Array.isArray(t.selectedSources)?t.selectedSources:[],u=t.sourceConfigurations&&"object"===(0,r.A)(t.sourceConfigurations)?t.sourceConfigurations:{},d=m.map(function(e){return String(null!=e?e:"").toLowerCase().trim()}).filter(function(e){return e.length>0}),p=String(null!==(c=t.activeSourceTab)&&void 0!==c?c:"").toLowerCase().trim(),g=d.includes(p)?p:d[0];if(g){var f,b,y={subscription:"subscription",transactions:"transaction"}[(null!==(f=null===(b=u[g])||void 0===b?void 0:b.sourceCategory)&&void 0!==f?f:"").toLowerCase().trim()];y&&i.push({event_name:"ro_data_source_".concat(y,"_").concat(g)})}}if(2===e&&t&&"object"===(0,r.A)(t)){var v,x=t.sourceConfigurations&&"object"===(0,r.A)(t.sourceConfigurations)?t.s
1ourceConfigurations:{},h=String(null!==(v=t.activeSourceTab)&&void 0!==v?v:"").toLowerCase().trim(),E=h&&x[h]||{};if(!E.completed)return;if(h){var N,w=(null!==(N=E.sourceCategory)&&void 0!==N?N:"").toLowerCase().trim();w&&i.push({event_name:"ro_data_setup_".concat(w,"_").concat(h)})}}var C=i.map(function(e){var n;return{event_name:e.event_name,properties:{step_id:o,module_id:"revenue_analytics",completion_status:"completed",data:JSON.stringify(t)},user_id:l,timestamp:(new Date).toISOString(),context:{group_id:null!==(n=(0,H.PU)())&&void 0!==n?n:"unknown"}}}),S="".concat(o,"|").concat(JSON.stringify({eventNames:i.map(function(e){return e.event_name}),properties:{step_id:o,module_id:"revenue_analytics",completion_status:"completed",data:JSON.stringify(t)},user_id:l,context:{group_id:null!==(a=(0,H.PU)())&&void 0!==a?a:"unknown"}})),k=Date.now();if(!(an.current&&an.current.signature===S&&k-an.current.timestamp<3e3)&&(an.current={signature:S,timestamp:k},window.thriveStack&&"function"==typeof window.thriveStack.track))try{window.thriveStack.track(C)}catch(e){console.error("Analytics tracking failed:",e)}}}var xo=function(){var e=new(b()),t=(0,bt.$s)(42),n=function(e,t){var n=new bt.AU(Date.now()),a=[].concat((0,l.A)(t.fields.required),(0,l.A)(t.fields.optional)),r=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:90,t=new Date;return new Date(t.getTime()-n.next()*e*24*60*60*1e3)},s=function(e){if(arguments.length>1&&void 0!==arguments[1]&&arguments[1])return e.toISOString();var t=e.getFullYear(),n=String(e.getMonth()+1).padStart(2,"0"),a=String(e.getDate()).padStart(2,"0");return"".concat(t,"-").concat(n,"-").concat(a)};return e.map(function(e){var t=null,o=null,l=null,i=null,c=null,m=a.some(function(e){return e.fieldName===Ct.F2.PERIOD_START_DATE}),u=a.some(function(e){return e.fieldName===Ct.F2.DATE}),d=a.some(function(e){return e.fieldName===Ct.F2.PERIOD_END_DATE});if(m||u||d){var p=r(90);(t=new Date(p)).setDate(t.getDate()-n.nextInt(15,30)),(o=new Date(t)).setDate(o.getDate()+n.nextInt(5,10)),(l=new Date(o)).setDate(l.getDate()+n.nextInt(15,25))}var g=a.some(function(e){return e.fieldName===Ct.o9.INVOICE_ISSUE_DATE}),f=a.some(function(e){return e.fieldName===Ct.o9.INVOICE_DUE_DATE});return(g||f)&&(i=r(90),(c=new Date(i)).setDate(c.getDate()+n.nextInt(15,45))),e.map(function(e,n){if(n>=a.length)return e;var m=a[n].fieldName;if(m===Ct.F2.PERIOD_START_DATE&&t)return s(t);if(m===Ct.F2.DATE&&o)return s(o,!0);if(m===Ct.F2.PERIOD_END_DATE&&l)return s(l);if(m===Ct.o9.INVOICE_ISSUE_DATE&&i)return s(i);if(m===Ct.o9.INVOICE_DUE_DATE&&c)return s(c);if(e&&"string"==typeof e&&e.includes("T")&&e.includes("Z")){var u=r(90);return s(u,!0)}return e})})};me===M.ko.INVOICE_TRANSACTION?[M.JW,M.QP].forEach(function(a){var r=t[a.key];if(r){var s=n(r,a),o=[].concat((0,l.A)(a.fields.required),(0,l.A)(a.fields.optional)).map(function(e){return e.fieldName}).join(",")+"\n";o+=s.map(function(e){return e.join(",")}).join("\n")+"\n",e.file(a.sampleFileName,o)}}):M.ab.forEach(function(a,r){var s=t[a.key];if(s){var o=n(s,a),i=[].concat((0,l.A)(a.fields.required),(0,l.A)(a.fields.optional)).map(function(e){return e.fieldName}).join(",")+"\n";i+=o.map(function(e){return e.join(",")}).join("\n")+"\n",e.file(a.sampleFileName,i)}});e.generateAsync({type:"blob"}).then(function(e){var t=URL.createObjectURL(e),n=document.createElement("a");n.href=t,n.download="revenue_intelligence_sample_files.zip",document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(t)})},ho=function(e){var t=xa[e];if(t&&t.errors&&0!==t.errors.length){var n="Row,Temp ID,Error,Data\n"+t.errors.map(function(e){return{row:e.rowNumber,tempId:e.tempId||"",error:e.error,data:JSON.stringify(e.rowData||{})}}).map(function(e){return"".concat(e.row,',"').concat(e.tempId,'","').concat(e.error,'","').concat(e.data,'"')}).join("\n"),a=new Blob([n],{type:"text/csv"}),r=URL.createObjectURL(a),s=document.createElement("a");s.href=r,s.download="".concat(M.ab[e].key,"_failed_records.csv"),document.body.appendChild(s),s.click(),document.body.removeChild(s),URL.revokeObjectURL(r)}},Eo=M.ab.map(function(e){return me===M.ko.INVOICE_TRANSACTION&&"transactions"===e.key?Pt(Pt({},e),{},{fields:{required:M.JW.fields.required,optional:M.JW.fields.optional}}):me===M.ko.INVOICE_TRANSACTION&&"invoices"===e.key?Pt(Pt({},e),{},{fields:{required:M.QP.fields.required,optional:M.QP.fields.optional}}):e}),No=function(){return 2===U?mo():yo(U)},wo=function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],t=arguments.length>1?arguments[1]:void 0,n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(t||No()||n){var r;if(t&&2===U&&fs&&xs(!0),Ae(null),1===U){var s=Object.fromEntries(oe.filter(function(e){var t;return null===(t=ve[e])||void 0===t?void 0:t.sourceCategory}).map(function(e){return[e,{sourceCategory:ve[e].sourceCategory}]}));r=Pt({selectedSources:oe,selectedDataType:me,activeSourceTab:ge},Object.keys(s).length>0&&{sourceConfigurations:s})}else if(2===U){var o;t?o=t:We&&(We.selectedApiKeyId||We.selectedApiKey)?o=We:us&&(us.selectedApiKeyId||us.selectedApiKey)&&(o=us);var i=ve||{};if(r=Pt(Pt({selectedSources:oe,selectedDataType:me,sourceConfigurations:i,activeSourceTab:ge},o&&{apiKeyInfo:o}),{},{healthCheckStates:(null==t?void 0:t.healthCheckStates)||Je}),i.stripe&&Object.keys(i.stripe).length>0){var c=i.stripe;r.stripeStepDetails={step1Completed:!(!c.environmentId||!c.stripeEnvironment),step2Completed:!!(c.sourceName&&c.accountId&&c.secretKey&&c.syncStartDate),step3Completed:c.step3Completed||!1,testCompleted:c.testCompleted||!1,step4Completed:c.step4Completed||!1,isStep3Incomplete:c.isStep3Incomplete||!1,testingSteps:c.testingSteps||[],selectedIdentifierKey:c.selectedIdentifierKey||"group_id",customerMetaDataKeys:c.customerMetaDataKeys||[],groupIdFound:c.groupIdFound||!1,formData:{sourceName:c.sourceName||"Stripe",accountId:c.accountId||"",secretKey:c.secretKey||"",dataRetentionLocation:c.dataRetentionLocation||"",syncStartDate:c.syncStartDate||"",groupIdMapping:c.groupIdMapping||!1,environmentId:c.environmentId||"",environmentName:c.environmentName||"",stripeEnvironment:c.stripeEnvironment||""},ingestionResult:c.ingestionResult||null,schemaVerified:c.schemaVerified||!1,completedAt:c.completedAt||null,notificationEmails:c.notificationEmails||null}}if(i.chargebee&&Object.keys(i.chargebee).length>0){var m=i.chargebee;r.chargebeeStepDetails={step1Completed:!(!m.environmentId||!m.chargebeeEnvironment),step2Completed:!!(m.sourceName&&m.subdomain&&m.apiKey&&m.syncStartDate),step3Completed:m.step3Completed||!1,testCompleted:m.testCompleted||!1,step4Completed:m.step4Completed||!1,isStep3Incomplete:m.isStep3Incomplete||!1,testingSteps:m.testingSteps||[],selectedIdentifierKey:m.selectedIdentifierKey||"group_id",customerMetaDataKeys:m.customerMetaDataKeys||[],groupIdFound:m.groupIdFound||!1,formData:{sourceName:m.sourceName||"Chargebee",subdomain:m.subdomain||"",apiKey:m.apiKey||"",secretKey:m.secretKey||"",productCatalog:m.productCatalog||"2.0",dataRetentionLocation:m.dataRetentionLocation||"",syncStartDate:m.syncStartDate||"",groupIdMapping:m.groupIdMapping||!1,environmentId:m.environmentId||"",environmentName:m.environmentName||"",chargebeeEnvironment:m.chargebeeEnvironment||""},ingestionResult:m.ingestionResult||null,schemaVerified:m.schemaVerified||!1,completedAt:m.completedAt||null,notificationEmails:m.notificationEmails||null}}if(i.quickbooks&&Object.keys(i.quickbooks).length>0){var u=i.quickbooks;r.quickbooksStepDetails={step1Completed:u.step1Completed||!1,step2Completed:u.step2Completed||!1,step3Completed:u.step3Completed||!1,step4Completed:u.step4Completed||!1,testCompleted:u.testCompleted||!1,itemsStepCompleted:u.itemsStepCompleted||!1,mrrItems:u.mrrItems||[],formData:{sourceName:u.sourceName||"QuickBooks",startDate:u.startDate||"",realmId:u.realmId||"",companyName:u.companyName||"",environmentId:u.environmentId||"",quickbooksEnvironment:u.quickbooksEnvironment||"",sandbox:u.sandbox||!1},ingestionResult:u.ingestionResult||null,completedAt:u.completedAt||null,notificationEmails:u.notificationEmails||null}}r.subStepsData=M.ab.map(function(e,t){var n=xa[t],a=wa[t],r=Aa[t],s=Ra[t],o=6===t?Cr:[];return{key:e.key,title:e.title,status:qa[t],fileInfo:a?{fileName:a.name,fileSize:a.size,uploadedAt:(new Date).toISOString()}:null,csvHeaders:s||[],csvStatuses:o||[],fieldMapping:r||{},importResult:n?{totalRows:n.totalRows||0,processedRows:n.processedRows||0,skippedRows:n.skippedRows||0,duplicateRows:n.duplicateRows||0,errorRows:n.errorRows||0,hasErrors:!!(n.errors&&n.errors.length>0),errorCount:n.errors?n.errors.length:0,firstFewErrors:n.errors?n.errors.slice(0,3):[],batchId:n.batchId||"",success:n.success||!1,message:n.message||"",processingTimeMs:n.processingTimeMs||0,savedAt:(new Date).toISOString(),csvFileName:(null==a?void 0:a.name)||n.csvFileName||"Unknown file",originalFileSize:(null==a?void 0:a.size)||n.originalFileSize||0}:null}}),r.completionSummary={totalSubSteps:oe.length,completedSubSteps:oe.filter(function(e){var t,n,a,r,s,o;switch(e){case"csv":return(0,M.Hu)(me,M.ab).some(function(e){var t=M.ab.findIndex(function(t){return t.key===e});return-1!==t&&null!==xa[t]});case"api":return"configured"===(null===(t=ve.api)||void 0===t?void 0:t.status)&&!0===(null===(n=ve.api)||void 0===n?void 0:n.completed);case"stripe":return"configured"===(null===(a=ve.stripe)||void 0===a?void 0:a.status)&&!0===(null===(r=ve.stripe)||void 0===r?void 0:r.completed);case"salesforce":return"configured"===(null===(s=ve.salesforce)||void 0===s?void 0:s.status)&&!0===(null===(o=ve.salesforce)||void 0===o?void 0:o.completed);default:return!1}}).length,isFullyCompleted:co(),autoSavedAt:(new Date).toISOString(),hasA
1nyImportAttempts:xa.some(function(e){return null!==e})}}else if(3===U){var d=Pt({},ve);if(t){var p,g;if(ge&&d[ge]){var f=d[ge],b=(f.selectedMrrPlans,f.selectedMrrStatuses,f.selectedPastDueHandling,f.includeTax,f.baseCurrency,f.includeTransactionFees,f.chargebeeFeePerTransaction,f.paymentGatewayFees,f.chargebeeChargesPerTxnFee,(0,a.A)(f,Rt));d[ge]=Pt(Pt({},b),{},{step3Completed:!0,step3CompletedAt:(new Date).toISOString()})}r={selectedMrrPlans:t.selectedMrrPlans,selectedMrrStatuses:t.selectedMrrStatuses,selectedPastDueHandling:t.selectedPastDueHandling,includeTax:t.includeTax,baseCurrency:t.baseCurrency,includeTransactionFees:t.includeTransactionFees,chargebeeFeePerTransaction:t.chargebeeFeePerTransaction||zr,paymentGatewayFees:t.paymentGatewayFees||Jr,chargebeeChargesPerTxnFee:t.chargebeeChargesPerTxnFee||ns,user_email:null===(p=(0,H.wz)())||void 0===p?void 0:p.email,user_name:null===(g=(0,H.wz)())||void 0===g?void 0:g.name}}else{var y,x;r={selectedMrrPlans:Ha,selectedMrrStatuses:Ya,selectedPastDueHandling:hr,includeTax:_r,baseCurrency:Fr,includeTransactionFees:Lr,chargebeeFeePerTransaction:zr,paymentGatewayFees:Jr,chargebeeChargesPerTxnFee:ns,user_email:null===(y=(0,H.wz)())||void 0===y?void 0:y.email,user_name:null===(x=(0,H.wz)())||void 0===x?void 0:x.name}}ge&&d[ge]&&(d[ge]=Pt(Pt({},d[ge]),{},{step3Completed:!0,step3CompletedAt:(new Date).toISOString()})),xe(d)}else if(4===U){var h=Pt({},ve);if(ge&&h[ge]){var E=(0,M.fu)(er,rr);h[ge]=Pt(Pt(Pt({},h[ge]),E),{},{selectedRevenueOptions:er,selectedChurnOptions:rr,step4Completed:!0,step4CompletedAt:(new Date).toISOString()}),r={sourceConfigurations:h}}else r=(0,M.fu)(er,rr);xe(h)}else 5===U?r={goals:Ns}:(6===U||7===U)&&(r={completed:!0});if(U===_s.length)return we(!0),Fs(),void v("/revenue-analytics/dashboard");if(Re?$.includes(U)||ee(function(e){return[].concat((0,l.A)(e),[U])}):G.includes(U)||J(function(e){return[].concat((0,l.A)(e),[U])}),bo(r),e){var N=Math.min(U+1,_s.length);if(Re&&4===U&&ge){var w=ve[ge]||{},C=w.sourceName||("stripe"===ge?"Stripe":"chargebee"===ge?"Chargebee":ge),S=hr?"Past Due: Remain Active":"Past Due: Exclude",k=null!=er&&er[1]?"ARR: ".concat(er[1]):"ARR: MRR Ã 12",A="stripe"===ge?w.stripeEnvironment||"":"chargebee"===ge?w.chargebeeEnvironment||"Production":"",I=w.environmentName||"",T="stripe"===ge?"Stripe account ID":"chargebee"===ge?"Chargebee subdomain":"Account ID",D="stripe"===ge?w.accountId||"":w.subdomain||"",R={id:"demo-".concat(Date.now()),type:ge,name:"string"==typeof C?C:"Connection",lastSync:"Just now",coreSummary:S,advancedSummary:k,sourceEnvironment:A,targetEnvironment:I,accountIdLabel:T,accountIdValue:D,syncStartDate:w.syncStartDate||"",accountIdentifierKey:On||"group_id",sourceCategory:w.sourceCategory||void 0,sourceConfig:Pt({selectedMrrPlans:Ha,selectedMrrStatuses:Ya,selectedPastDueHandling:hr,selectedRevenueOptions:er,selectedChurnOptions:rr},w)};Kt(function(e){var t=e.filter(function(e){return e.type!==ge});return t.push(R),rn(t),t})}V(N),Os(N)}}};(0,d.useEffect)(function(){uo()},[]),(0,d.useEffect)(function(){if(Re)try{var e=localStorage.getItem(Xe);if(e){var t=JSON.parse(e);if(Array.isArray(t)&&t.length>0)return Kt(t),void at("list")}Kt([])}catch(e){}},[Re]);var Co=(0,d.useRef)(Fs);Co.current=Fs;var So=(0,d.useRef)(!1);(0,d.useEffect)(function(){return function(){Co.current()}},[]),(0,d.useEffect)(function(){1!==U&&it(!1)},[U]),(0,d.useEffect)(function(){if(3===U&&ge&&ve[ge]){var e=ve[ge];e.selectedMrrPlans&&Ga(e.selectedMrrPlans),e.selectedMrrStatuses&&Xa(e.selectedMrrStatuses),void 0!==e.selectedPastDueHandling&&Er(e.selectedPastDueHandling),void 0!==e.includeTax&&Pr(e.includeTax),e.baseCurrency&&Kr(e.baseCurrency),void 0!==e.includeTransactionFees&&Ur(e.includeTransactionFees),"number"==typeof e.chargebeeFeePerTransaction&&Wr(e.chargebeeFeePerTransaction),"number"==typeof e.paymentGatewayFees&&Zr(e.paymentGatewayFees),"boolean"==typeof e.chargebeeChargesPerTxnFee&&as(e.chargebeeChargesPerTxnFee)}},[ge,U,ve]),(0,d.useEffect)(function(){if(4===U&&ge&&ve[ge]){var e=ve[ge];e.selectedRevenueOptions&&tr(e.selectedRevenueOptions),e.selectedChurnOptions&&sr(e.selectedChurnOptions)}},[ge,U,ve]),(0,d.useEffect)(function(){2===U&&mo()&&((Re?$.includes(2):G.includes(2))||(Re?ee(function(e){return[].concat((0,l.A)(e),[2])}):J(function(e){return[].concat((0,l.A)(e),[2])}),fo()));if(2===U&&"stripe"===ge){var e=ve.stripe;(null==e?void 0:e.step4Completed)?So.current||(So.current=!0,wo(!1,void 0,!0)):So.current=!1}else So.current=!1},[ve,xa,Je,U,ge]);var ko,Ao,Io,To,Do,Ro,_o,Po,Oo,Mo,Fo,Ko,jo,qo,Lo=(0,d.useCallback)(function(e,t){at("setup"),le([e.type]),fe(e.type),V(t.stepId),Os(t.stepId)},[V,le,fe,Os]),Uo=(0,d.useCallback)(function(e,t){var n,a,s,o,l,i,c,m,u,d,p,g,f,b=I.getState().revenueAnalytics,y=null!=t?t:(delete(f=Pt({},b.sourceConfigurations))[e],f),v=(b.selectedSources||[]).filter(function(t){return t!==e}),x=b.activeSourceTab===e?v[0]||"":b.activeSourceTab,h=function(e){switch(e){case"csv":return(0,M.Hu)(b.selectedDataType,M.ab).some(function(e){var t,n,a=M.ab.findIndex(function(t){return t.key===e});return-1!==a&&(null===(t=(null!==(n=b.step2ImportResults)&&void 0!==n?n:[])[a])||void 0===t?void 0:t.success)});case"api":var t=y.api,n=b.healthCheckCompletedStates||{};return"configured"===(null==t?void 0:t.status)&&!0===(null==t?void 0:t.completed)&&!0===n["transactions-POST"]&&!0===n["invoices-POST"];case"stripe":var a=y.stripe;return"configured"===(null==a?void 0:a.status)&&!0===(null==a?void 0:a.completed)||!!(null!=a&&a.step1Completed&&null!=a&&a.step2Completed&&null!=a&&a.step3Completed&&null!=a&&a.step4Completed);case"chargebee":var r=y.chargebee;return"configured"===(null==r?void 0:r.status)&&!0===(null==r?void 0:r.completed)||!!(null!=r&&r.step1Completed&&null!=r&&r.step2Completed&&null!=r&&r.step3Completed&&null!=r&&r.step4Completed);case"salesforce":var s=y.salesforce;return"configured"===(null==s?void 0:s.status)&&!0===(null==s?void 0:s.completed);default:return!1}},E=v.length>0&&v.some(h),N={selectedSources:v,selectedDataType:b.selectedDataType,activeSourceTab:x};Vs({variables:{input:{environmentId:null!==(n=(0,H.nN)())&&void 0!==n?n:"",productId:null!==(a=(0,H.J1)())&&void 0!==a?a:"",moduleId:"revenue_analytics",stepId:"data_source",isCompleted:v.length>0,data:JSON.stringify(N)}}});
1var w=null!==(s=b.originalApiKeyData)&&void 0!==s&&s.selectedApiKeyId||null!==(o=b.originalApiKeyData)&&void 0!==o&&o.selectedApiKey?b.originalApiKeyData:null!==(l=b.selectedApiKeyData)&&void 0!==l&&l.selectedApiKeyId||null!==(i=b.selectedApiKeyData)&&void 0!==i&&i.selectedApiKey?b.selectedApiKeyData:void 0,C=Pt(Pt({selectedSources:v,selectedDataType:b.selectedDataType,sourceConfigurations:y,activeSourceTab:x},w&&{apiKeyInfo:w}),{},{healthCheckStates:b.healthCheckCompletedStates||{}});if(y.stripe&&Object.keys(y.stripe).length>0){var S,k,A,T,D,R,_,P,O,F,K,j,q,L=y.stripe;C.stripeStepDetails={step1Completed:!(!L.environmentId||!L.stripeEnvironment),step2Completed:!!(L.sourceName&&L.accountId&&L.secretKey&&L.syncStartDate),step3Completed:null!==(S=L.step3Completed)&&void 0!==S&&S,step4Completed:null!==(k=L.step4Completed)&&void 0!==k&&k,testCompleted:null!==(A=L.testCompleted)&&void 0!==A&&A,isStep3Incomplete:null!==(T=L.isStep3Incomplete)&&void 0!==T&&T,testingSteps:null!==(D=L.testingSteps)&&void 0!==D?D:[],selectedIdentifierKey:null!==(R=L.selectedIdentifierKey)&&void 0!==R?R:"group_id",customerMetaDataKeys:null!==(_=L.customerMetaDataKeys)&&void 0!==_?_:[],groupIdFound:null!==(P=L.groupIdFound)&&void 0!==P&&P,formData:{sourceName:L.sourceName||"Stripe",accountId:L.accountId||"",secretKey:L.secretKey||"",dataRetentionLocation:L.dataRetentionLocation||"",syncStartDate:L.syncStartDate||"",groupIdMapping:null!==(O=L.groupIdMapping)&&void 0!==O&&O,environmentId:L.environmentId||"",environmentName:L.environmentName||"",stripeEnvironment:L.stripeEnvironment||""},ingestionResult:null!==(F=L.ingestionResult)&&void 0!==F?F:null,schemaVerified:null!==(K=L.schemaVerified)&&void 0!==K&&K,completedAt:null!==(j=L.completedAt)&&void 0!==j?j:null,notificationEmails:null!==(q=L.notificationEmails)&&void 0!==q?q:null}}if(y.chargebee&&Object.keys(y.chargebee).length>0){var U,V,B,z,W,G,J,Z,Y,X,Q,$,ee,te=y.chargebee;C.chargebeeStepDetails={step1Completed:!(!te.environmentId||!te.chargebeeEnvironment),step2Completed:!!(te.sourceName&&te.subdomain&&te.apiKey&&te.syncStartDate),step3Completed:null!==(U=te.step3Completed)&&void 0!==U&&U,step4Completed:null!==(V=te.step4Completed)&&void 0!==V&&V,testCompleted:null!==(B=te.testCompleted)&&void 0!==B&&B,isStep3Incomplete:null!==(z=te.isStep3Incomplete)&&void 0!==z&&z,testingSteps:null!==(W=te.testingSteps)&&void 0!==W?W:[],selectedIdentifierKey:null!==(G=te.selectedIdentifierKey)&&void 0!==G?G:"group_id",customerMetaDataKeys:null!==(J=te.customerMetaDataKeys)&&void 0!==J?J:[],groupIdFound:null!==(Z=te.groupIdFound)&&void 0!==Z&&Z,formData:{sourceName:te.sourceName||"Chargebee",subdomain:te.subdomain||"",apiKey:te.apiKey||"",secretKey:te.secretKey||"",productCatalog:te.productCatalog||"2.0",dataRetentionLocation:te.dataRetentionLocation||"",syncStartDate:te.syncStartDate||"",groupIdMapping:null!==(Y=te.groupIdMapping)&&void 0!==Y&&Y,environmentId:te.environmentId||"",environmentName:te.environmentName||"",chargebeeEnvironment:te.chargebeeEnvironment||""},ingestionResult:null!==(X=te.ingestionResult)&&void 0!==X?X:null,schemaVerified:null!==(Q=te.schemaVerified)&&void 0!==Q&&Q,completedAt:null!==($=te.completedAt)&&void 0!==$?$:null,notificationEmails:null!==(ee=te.notificationEmails)&&void 0!==ee?ee:null}}C.subStepsData=(null!==(c=b.step2ImportResults)&&void 0!==c?c:[]).map(function(e,t){var n,a,r,s,o,l,i=M.ab[t],c=(null!==(n=b.step2ImportResults)&&void 0!==n?n:[])[t],m=(null!==(a=b.step2FileInfos)&&void 0!==a?a:[])[t];return{key:null==i?void 0:i.key,title:null==i?void 0:i.title,status:(null!==(r=b.step2SubStepStatuses)&&void 0!==r?r:[])[t],fileInfo:null!=m&&m.fileName?{fileName:m.fileName,fileSize:m.fileSize,uploadedAt:(new Date).toISOString()}:null,csvHeaders:(null!==(s=b.step2CsvHeaders)&&void 0!==s?s:[])[t]||[],csvStatuses:6===t&&null!==(o=b.csvDetectedStatuses)&&void 0!==o?o:[],fieldMapping:(null!==(l=b.step2FieldMappings)&&void 0!==l?l:[])[t]||{},importResult:c?{totalRows:c.totalRows||0,processedRows:c.processedRows||0,skippedRows:c.skippedRows||0,duplicateRows:c.duplicateRows||0,errorRows:c.errorRows||0,hasErrors:!!(c.errors&&c.errors.length>0),errorCount:c.errors?c.errors.length:0,firstFewErrors:(c.errors||[]).slice(0,3),batchId:c.batchId||"",success:c.success||!1,message:c.message||"",processingTimeMs:c.processingTimeMs||0,savedAt:(new Date).toISOString(),csvFileName:c.csvFileName||"Unknown file",originalFileSize:c.originalFileSize||0}:null}}),C.completionSummary={totalSubSteps:v.length,completedSubSteps:v.filter(h).length,isFullyCompleted:E,autoSavedAt:(new Date).toISOString(),hasA
1nyImportAttempts:(null!==(m=b.step2ImportResults)&&void 0!==m?m:[]).some(function(e){return null!==e})},Vs({variables:{input:{environmentId:null!==(u=(0,H.nN)())&&void 0!==u?u:"",productId:null!==(d=(0,H.J1)())&&void 0!==d?d:"",moduleId:"revenue_analytics",stepId:"data_setup",isCompleted:E,data:JSON.stringify(C)}}});var ne={sourceConfigurations:y},ae=Object.values(y).some(function(e){return!(!e||"object"!==(0,r.A)(e))&&(!0===e.step4Completed||Array.isArray(e.selectedRevenueOptions)&&e.selectedRevenueOptions.length>0||Array.isArray(e.selectedChurnOptions)&&e.selectedChurnOptions.length>0||null!=e.advanced_revenue_calculations)});Vs({variables:{input:{environmentId:null!==(p=(0,H.nN)())&&void 0!==p?p:"",productId:null!==(g=(0,H.J1)())&&void 0!==g?g:"",moduleId:"revenue_analytics",stepId:"advance_revenue_calculation",isCompleted:ae,data:JSON.stringify(ne)}}})},[Vs]),Vo=(0,d.useCallback)(function(){var e,t=Bt;if(t){if(Re)return n=t.id,Kt(function(e){var t=e.filter(function(e){return e.id!==n});return rn(t),t}),zt(null),void Qt(null);var n,a=(null===(e=t.sourceConfig)||void 0===e?void 0:e.environmentId)||
1(0,H.nN)()||"";a?(Jt(!0),Qt(null),Ws({variables:{input:{environmentId:a,integrationType:"stripe"===t.type?se.pqc.Stripe:"quickbooks"===t.type?se.pqc.Quickbooks:se.pqc.Chargebee}},onCompleted:function(e){var n=null==e?void 0:e.deleteAirbyteIntegration;if(null!=n&&n.isSuccess){var a=Pt({},I.getState().revenueAnalytics.sourceConfigurations);delete a[t.type],I.dispatch((0,O.x)({key:"sourceConfigurations",value:a})),"stripe"===t.type&&I.dispatch((0,O.x)({key:"loadedStripeData",value:null})),le(function(e){return e.filter(function(e){return e!==t.type})}),fe(function(e){return e===t.type?"":e}),Uo(t.type,a),nn(!0),Jt(!1),setTimeout(function(){zt(null),nn(!1)},1500)}else Qt((null==n?void 0:n.message)||"Delete failed."),Jt(!1)},onError:function(e){var t,n=e.message||(null===(t=e.graphQLErrors)||void 0===t||null===(t=t[0])||void 0===t?void 0:t.message)||"Failed to delete connection.";Qt(n),Jt(!1)}})):Qt("Environment not found.")}},[Bt,Re,Ws,Uo]),Bo=(0,d.useMemo)(function(){if(Re)return[];var e=ve||{},t=Je||{},n=Object.keys(e),a=oe||[],r=(null!=xa?xa:[]).some(function(e){return null!=e});return Array.from(new Set([].concat(n,(0,l.A)(a),(0,l.A)(r?["csv"]:[])))).filter(function(n){return"csv"===n?r:e[n]?lo(n,e,t):a.includes(n)}).map(function(t){var n,a,r,s,o=e[t]||{},l=o.sourceName||("stripe"===t?"Stripe":"chargebee"===t?"Chargebee":"api"===t?"API":"csv"===t?"Manual CSV Upload":t),i="stripe"===t?o.stripeEnvironment:"chargebee"===t?null!==(n=o.chargebeeEnvironment)&&void 0!==n?n:"Production":"quickbooks"===t&&null!==(a=o.quickbooksEnvironment)&&void 0!==a?a:"",c=o.environmentName||"",m="stripe"===t?"Stripe account ID":"chargebee"===t?"Chargebee subdomain":"quickbooks"===t?"Realm ID":"Account ID",u="stripe"===t?o.accountId:"chargebee"===t?o.subdomain:"quickbooks"===t?o.realmId:"",d=null===(r=o.ingestionResult)||void 0===r?void 0:r.syncStartedAt,p=o.completedAt;return{id:t,type:t,name:l,lastSync:null!==(s=null!=d?d:p)&&void 0!==s?s:"",sourceEnvironment:i,targetEnvironment:c,accountIdLabel:m,accountIdValue:u,syncStartDate:o.syncStartDate||"",accountIdentifierKey:o.selectedIdentifierKey||"group_id",sourceConfig:o,sourceCategory:o.sourceCategory||void 0}})},[Re,ve,Je,lo,oe,xa]),zo=Re?_t:Bo,Wo=(0,d.useMemo)(function(){var e=ve||{},t=Je||{};return zo.map(function(n){var a=oo(n.type,e,t),r=a?"active":"incomplete",s=[];if(!io(n.type)&&s.push({id:"data-setup-".concat(n.id),label:"Data setup incomplete",stepId:2,sourceType:n.type}),G.includes(3)||s.push({id:"core-revenue-".concat(n.id),label:"Core revenue calculation incomplete",stepId:3}),G.includes(4)||s.push({id:"advance-revenue-".concat(n.id),label:"Advanced revenue calculation incomplete",stepId:4}),G.includes(5)||s.push({id:"set-goals-".concat(n.id),label:"Set goals incomplete",stepId:5}),"stripe"===n.type||"chargebee"===n.type){var o,l="stripe"===n.type?"Stripe":"Chargebee";!(null===(o=n.sourceConfig)||void 0===o||!o.selectedIdentifierKey)||s.push({id:"".concat(Dt.W0.MISSING_ACCOUNT_IDENTIFIER,"-").concat(n.id),label:(0,Dt.FF)(l),stepId:7}),oa>0&&s.push({id:"id-missing-accounts-".concat(n.id),label:Dt.Dx[Dt.W0.ID_MISSING_ACCOUNTS],stepId:7})}(la>0&&s.push({id:"missing-revenue-data-".concat(n.id),label:Dt.Dx[Dt.W0.MISSING_REVENUE_DATA],stepId:7}),ua>0&&s.push({id:"transactions-without-invoices-".concat(n.id),label:Dt.Dx[Dt.W0.TRANSACTIONS_WITHOUT_INVOICES],stepId:7}),"api"===n.type)&&(Object.keys(t).some(function(e){return!0!==t[e]})&&s.push({id:"api-health-".concat(n.id),label:Dt.Dx[Dt.W0.API_HEALTH],stepId:7}));var i=s.length,c=i>0;return Pt(Pt({},n),{},{status:r,hasError:c,isComplete:a,issueCount:i,issues:s})})},[zo,G,ve,Je,oa,la,ua,oo,io]),Ho="list"===nt,Go=!Ho&&zo.length>0&&1===oe.length&&zo.some(function(e){return e.type===oe[0]}),Jo=(0,d.useRef)(!1);return(0,d.useEffect)(function(){if(!Jo.current&&Ho){var e=R.get("step"),t=R.get("substep");if(e&&t){var n=parseInt(e,10),a=parseInt(t,10);if(!Number.isNaN(n)&&!Number.isNaN(a)){var r=Wo.find(function(e){return"active"===e.status});if(r){Jo.current=!0,at("setup"),le([r.type]),fe(r.type),V(n),Os(n);var s=window.setTimeout(function(){Ks()},800);return function(){return window.clearTimeout(s)}}}}}},[Ho,R,Wo,le,fe,V,at,Os,Ks]),Ho?d.createElement("div",{className:"min-h-screen bg-primaryExtremeLightColor w-screen"},d.createElement("div",{className:"relative min-h-screen bg-gray-50 w-[70%] mx-auto overflow-hidden"},d.createElement("div",{className:"flex flex-col px-8 py-4 gap-4"},d.createElement("div",{className:"flex"},d.createElement("button",{onClick:function(){return v("/onboarding")},className:"w-fit p-0 min-w-0 text-gray-600 hover:text-gray-900"},d.createElement(y.ArrowLeft,{className:"w-5 h-5"}))),d.createElement(E.p,{icon:d.createElement(y.DollarSign,{className:"w-8 h-8 text-primaryColor"}),title:"Setup Revenue Intelligence",description:"Track and analyze your revenue metrics to optimize monetization and drive growth.",team
1s:[k.V.SALES_TEAMS,k.V.REVOPS_TEAMS],setupTime:20,totalSteps:_s.length,completedSteps:Re?$.length:G.length,onInviteTeam:to,headerAction:d.createElement("button",{onClick:f.open,className:"flex items-center gap-2 px-3 py-1.5 text-sm text-gray-700 border border-gray-200 rounded-md hover:bg-gray-50 transition-colors"},d.createElement(y.Bell,{className:"w-4 h-4"}),"Notifications")})),d.createElement("div",{className:"flex gap-8 ms-3 py-4 px-8 h-[calc(100vh-200px)] overflow-y-auto"},d.createElement("div",{className:"flex-1"},d.createElement("div",{className:"bg-white rounded-xl shadow-sm border border-gray-200 p-6"},d.createElement(C,{connections:Wo,onAddNew:function(){Lt(null),ue(""),V(1),Os(1),at("setup"),it(!0),ht(function(e){return e+1})},onEdit:function(e){it(!1),le([e.type]),fe(e.type),Re&&(Lt(e.id),e.sourceConfig&&e.type&&xe(function(t){return Pt(Pt({},t),{},(0,i.A)({},e.type,Pt(Pt({},t[e.type]),e.sourceConfig)))})),V(2),Os(2),at("setup")},onDelete:function(e){zt(e),Qt(null),nn(!1)},canAddNew:!0,canDelete:function(e){return Re||"stripe"===e.type||"chargebee"===e.type||"quickbooks"===e.type},onOpenSetupHealthStatus:function(){at("setup"),V(7),Os(7)},onOpenStepForIssue:Lo,leftContent:d.createElement(S.r,null)})))),Bt&&d.createElement("div",{className:"fixed inset-0 z-[100] flex items-center justify-center p-4 bg-black/40 backdrop-blur-sm"},d.createElement("div",{className:"bg-white rounded-2xl shadow-xl w-full max-w-md overflow-hidden"},d.createElement("div",{className:"p-6"},d.createElement("div",{className:"flex gap-4"},d.createElement("div",{className:"flex-shrink-0 w-10 h-10 rounded-lg bg-red-50 flex items-center justify-center"},d.createElement(y.AlertTriangle,{className:"w-5 h-5 text-red-600"})),d.createElement("div",{className:"flex-1 min-w-0"},d.createElement("h3",{className:"text-lg font-bold text-gray-900"},"Delete Connection?"),d.createElement("p",{className:"mt-2 text-sm text-gray-600"},"Are you sure you want to delete ",d.createElement("strong",null,Bt.name),"? This action ",d.createElement("strong",{className:"text-red-600 underline"},"cannot be undone")," and will permanently delete the connection and ",d.createElement("strong",null,"all synced revenue data.")))),(Xt||tn||Gt||Hs)&&d.createElement("div",{className:"flex gap-4 mt-4"},d.createElement("div",{className:"flex-shrink-0 w-10","aria-hidden":!0}),d.createElement("div",{className:"flex-1 min-w-0 space-y-0"},Xt&&d.createElement("div",{className:"p-3 rounded-lg bg-gray-50 text-sm text-red-700"},Xt),tn&&d.createElement("div",{className:"p-3 rounded-lg bg-gray-50 text-sm text-green-700 font-medium"},"Complete"),(Gt||Hs)&&!tn&&d.createElement("div",{className:"p-3 rounded-lg bg-gray-50 text-sm text-blue-700 flex items-center gap-2"},d.createElement(y.Loader2,{className:"w-4 h-4 flex-shrink-0 animate-spin text-blue-600","aria-hidden":!0}),"Deleting connection and Dataâ¦"))),d.createElement("div",{className:"mt-6 flex justify-end gap-3"},d.createElement("button",{type:"button",onClick:function(){zt(null),Qt(null),nn(!1)},disabled:Gt||Hs,className:"px-4 py-2 rounded-lg font-medium text-gray-700 bg-gray-100 hover:bg-gray-200 transition-colors disabled:opacity-50 disabled:cursor-not-allowed"},"Cancel"),d.createElement("button",{type:"button",onClick:Vo,disabled:Gt||Hs,className:"px-4 py-2 rounded-lg font-medium text-white bg-red-600 hover:bg-red-700 transition-colors disabled:opacity-50 disabled:cursor-not-allowed"},"Confirm & Delete"))))),dr&&br&&d.createElement(re.O,{isOpen:br,onClose:function(){return yr(!1)},team:null!=dr?dr:void 0,onInvite:function(){}}))):d.createElement("div",{className:"flex flex-col justify-center items-center w-screen overflow-y-auto bg-gradient-to-br bg-primaryExtremeLightColor dark:from-gray-900 dark:to-primaryDarkColor transition-colors duration-200"},d.createElement("div",{className:"min-h-screen bg-gray-50 w-[85%] mx-auto px-8 pt-8 relative"},d.createElement("div",{className:"flex py-4"},d.createElement("button",{onClick:function(){"setup"===nt&&so(1)?at("list"):v("/onboarding")},className:"w-fit p-0 min-w-0 text-gray-600 hover:text-gray-900 flex items-center gap-2"},d.createElement(y.ArrowLeft,{className:"w-5 h-5"}),"setup"===nt&&so(1)?"Back to Integrations":null)),d.createElement("div",null,d.createElement("div",{className:"flex gap-6 overflow-y-auto max-h-[calc(100vh-140px)]"},d.createElement("div",{className:"w-72 flex-shrink-0"},d.createElement("div",{className:"sticky bg-gray-50 px-4 pb-4"},d.createElement("div",{className:"mb-6 pb-4 border-b border-gray-200"},d.createElement("div",{className:"flex flex-col gap-1 w-full"},d.createElement("label",{className:"font-medium text-gray-600"},"Select Environment"),d.createElement(S.r,null))),d.createElement("div",{className:"mb-6"},d.createElement("h3",{className:"text-xs font-bold text-gray-500 uppercase tracking-wider mb-4 px-2"},"Basic Setup"),d.createElement("div",{className:"space-y-0"},_s.slice(0,3).map(function(e,t){var n=so(e.id),a=e.id===U,r=1===e.id&&Go;return d.createElement("div",{key:e.id,className:"relative ".concat(r?"opacity-60":"")},d.createElement("div",{className:"flex items-center space-x-3 px-3 py-3 rounded-lg transition-all duration-200\n ".concat(r?"curs
1or-not-allowed":"cursor-pointer","\n ").concat(a?"bg-blue-100":"hover:bg-blue-50"),onClick:function(){r||(V(e.id),Os(e.id))},role:r?"button":void 0,"aria-disabled":r},d.createElement("div",{className:"relative flex flex-col items-center"},d.createElement("div",{className:"z-10 flex items-center justify-center rounded-full transition-all duration-200 p-2\n ".concat(n?"bg-[#22c55e] text-white":a?"bg-primaryColor text-white":"bg-gray-100 text-gray-400")},n?d.createElement(y.CheckCircle2,{className:"w-5 h-5"}):e.icon)),d.createElement("div",{className:"flex items-center flex-1"},d.createElement("span",{className:"text-sm font-medium ".concat(a?"text-primaryColor":"text-gray-700")},e.title),(null==e?void 0:e.comingSoon)&&d.createElement(ft.A,null))),t<_s.slice(0,3).length-1&&d.createElement("div",{className:"flex justify-start ml-4"},d.createElement("div",{className:"w-[2px] h-6 bg-gray-200 ml-3"})))}))),d.createElement("div",{className:"pt-4 border-t border-gray-200"},d.createElement("h3",{className:"text-xs font-bold text-gray-500 uppercase tracking-wider mb-4 px-2"},"Advanced Setup"),d.createElement("div",{className:"space-y-0"},_s.slice(3).filter(function(e){return 7!==e.id}).map(function(e,t){var n=so(e.id),a=e.id===U;return d.createElement("div",{key:e.id,className:"relative"},d.createElement("div",{className:"flex items-center space-x-3 px-3 py-3 rounded-lg cursor-pointer transition-all duration-200\n ".concat(a?"bg-gray-200":"hover:bg-gray-50"),onClick:function(){V(e.id),Os(e.id)}},d.createElement("div",{className:"relative flex flex-col items-center"},d.createElement("div",{className:"z-10 flex items-center justify-center rounded-full transition-all duration-200 p-2\n ".concat(n?"bg-[#22c55e] text-white":a?"bg-primaryColor text-white":"bg-gray-100 text-gray-400")},n?d.createElement(y.CheckCircle2,{className:"w-5 h-5"}):e.icon)),d.createElement("div",{className:"flex items-center flex-1"},d.createElement("span",{className:"text-sm font-medium ".concat(a?"text-primaryColor":"text-gray-700")},e.title),(null==e?void 0:e.comingSoon)&&d.createElement(ft.A,null))),t<_s.slice(3).length-1&&d.createElement("div",{className:"flex justify-start ml-4"},d.createElement("div",{className:"w-[2px] h-6 bg-gray-200 ml-3"})))}))),d.createElement("div",{className:"pt-4 border-t border-gray-200"},d.createElement("h3",{className:"text-xs font-bold text-gray-500 uppercase tracking-wider mb-4 px-2"},"Diagnostics"),d.createElement("div",{className:"space-y-0"},_s.slice(6).map(function(e,t){var n=so(e.id),a=e.id===U;return d.createElement("div",{key:e.id,className:"relative"},d.createElement("div",{className:"flex items-center space-x-3 px-3 py-3 rounded-lg cursor-pointer transition-all duration-200\n ".concat(a?"bg-gray-200":"hover:bg-gray-50"),onClick:function(){V(e.id),Os(e.id)}},d.createElement("div",{className:"relative flex flex-col items-center"},d.createElement("div",{className:"z-10 flex items-center justify-center rounded-full transition-all duration-200 p-2\n ".concat(n?"bg-[#22c55e] text-white":a?"bg-primaryColor text-white":"bg-gray-100 text-gray-400")},n?d.createElement(y.CheckCircle2,{className:"w-5 h-5"}):e.icon)),d.createElement("div",{className:"flex items-center flex-1"},d.createElement("span",{className:"text-sm font-medium ".concat(a?"text-primaryColor":"text-gray-700")},e.title),(null==e?void 0:e.comingSoon)&&d.createElement(ft.A,null))),t<_s.slice(6).length-1&&d.createElement("div",{className:"flex justify-start ml-4"},d.createElement("div",{className:"w-[2px] h-6 bg-gray-200 ml-3"})))}))))),d.createElement("div",{className:"flex-1 overflow-auto scrollbar-hide"},d.createElement("div",{className:"mb-6"},d.createElement(E.p,{icon:d.createElement(y.DollarSign,{className:"w-8 h-8 text-primaryColor"}),title:"Setup Revenue Intelligence",description:"Track and analyze your revenue metrics to optimize monetization and drive growth.",teams:[k.V.SALES_TEAMS,k.V.REVOPS_TEAMS],setupTime:20,totalSteps:_s.length,completedSteps:Re?$.length:G.length,onInviteTeam:to,headerAction:d.createElement("button",{onClick:f.open,className:"flex items-center gap-2 px-3 py-1.5 text-sm text-gray-700 border border-gray-200 rounded-md hover:bg-gray-50 transition-colors"},d.createElement(y.Bell,{className:"w-4 h-4"}),"Notifications")})),d.createElement("div",{className:"bg-white rounded-xl shadow-sm border border-gray-200 p-6 pb-32 w-full"},d.createElement("div",{className:"space-y-6"},1===U&&d.createElement(W,{ref:cn,dataCollectionOptions:pa,getColorClasses:function(e){var t={blue:"border-blue-200 hover:border-blue-300",green:"border-green-200 hover:border-green-300",purple:"border-purple-200 hover:border-purple-300",orange:"border-orange-200 hover:border-orange-300"};return t[e]||t.blue},getIconColor:function(e){if(arguments.length>1&&void 0!==arguments[1]&&arguments[1])return"text-gray-400";var t={blue:"text-blue-600",green:"text-green-600",purple:"text-purple-600",orange:"text-orange-600"};return t[e]||t.blue},loading:!ir,isSchemaDrawerOpen:je,openSchemaModal:sn,openSchemaDrawer:on,closeAllModals:ln,forceReset:lt,connectionDraft
1Key:xt,alreadyConfiguredSourceIds:Array.from(new Set(Wo.filter(function(e){return e.isComplete}).map(function(e){return e.type})))}),2===U&&d.createElement("div",{className:"w-full"},d.createElement("div",{className:"flex items-start space-x-3 mb-5"},d.createElement("div",{className:"p-2 bg-primaryExtremeLightColor rounded-lg mt-2"},1===oe.length&&"stripe"===oe[0]?d.createElement(N.kDV,{className:"w-6 h-6 text-primaryColor"}):1===oe.length&&"chargebee"===oe[0]?d.createElement("img",{src:w,alt:"Chargebee",className:"w-6 h-6",style:{objectFit:"contain"}}):1===oe.length&&"quickbooks"===oe[0]?d.createElement(N._pZ,{className:"w-6 h-6 text-[#2CA01C]"}):d.createElement(y.Upload,{className:"w-6 h-6 text-primaryColor"})),d.createElement("div",{className:"flex items-center w-full mb-2"},d.createElement("div",{className:"flex flex-col justify-between flex-1"},d.createElement("h2",{className:"text-2xl font-bold text-gray-900 mb-1"},1===oe.length?"Configure ".concat(oe[0].charAt(0).toUpperCase()+oe[0].slice(1)):"Configure Data Sources"),1!==oe.length||"stripe"!==oe[0]&&"chargebee"!==oe[0]&&"quickbooks"!==oe[0]?d.createElement("div",{className:"mt-2 flex items-center gap-2"},d.createElement("span",{className:"text-sm text-gray-500"},oe.filter(function(e){var t,n,a,r,s,o,l,i,c;switch(e){case"csv":return(0,M.Hu)(me,M.ab).some(function(e){var t,n=M.ab.findIndex(function(t){return t.key===e});return-1!==n&&(null===(t=xa[n])||void 0===t?void 0:t.success)});case"api":return"configured"===(null===(t=ve.api)||void 0===t?void 0:t.status)&&!0===(null===(n=ve.api)||void 0===n?void 0:n.completed)&&!0===Je["transactions-POST"]&&!0===Je["invoices-POST"];case"stripe":return"configured"===(null===(a=ve.stripe)||void 0===a?void 0:a.status)&&!0===(null===(r=ve.stripe)||void 0===r?void 0:r.completed);case"chargebee":return"configured"===(null===(s=ve.chargebee)||void 0===s?void 0:s.status)&&!0===(null===(o=ve.chargebee)||void 0===o?void 0:o.completed);case"quickbooks":return!(null===(l=ve.quickbooks)||void 0===l||!l.step4Completed);case"salesforce":return"configured"===(null===(i=ve.salesforce)||void 0===i?void 0:i.status)&&!0===(null===(c=ve.salesforce)||void 0===c?void 0:c.completed);default:return!1}}).length," of ",oe.length," source",1!==oe.length?"s":""," completed"),mo()&&d.createElement("span",{className:"text-xs bg-green-50 text-green-800 px-2 py-1 rounded-full font-medium"},"Ready to proceed")):d.createElement("p",{className:"text-gray-600"},"Configure your ",oe[0].charAt(0).toUpperCase()+oe[0].slice(1)," data source connection")),d.createElement("div",{className:"flex ml-auto gap-6 items-center"},1===oe.length&&("stripe"===oe[0]||"chargebee"===oe[0]||"quickbooks"===oe[0])&&function(){var e=oe[0],t=ve[e],n=0;t&&("stripe"===e||"chargebee"===e?((t.step1Completed||t.environmentId&&t["stripe"===e?"stripeEnvironment":"chargebeeEnvironment"])&&n++,(t.step2Completed||t.sourceName&&t.apiKey)&&n++,t.step3Completed&&n++,t.step4Completed&&n++):"quickbooks"===e&&(t.step1Completed&&n++,t.step2Completed&&n++,t.step3Completed&&n++,t.step4Completed&&n++));var a=n/4*100;return d.createElement("div",{className:"flex items-center space-x-3"},d.createElement("div",{className:"w-48 h-2 bg-gray-200 rounded-full overflow-hidden"},d.createElement("div",{className:"h-full bg-gradient-to-r from-blue-500 to-blue-600 rounded-full transition-all duration-500 ease-out",style:{width:"".concat(a,"%")}})),d.createElement("div",{className:"text-sm font-medium text-gray-700"},n,"/",4," completed (",Math.round(a),"%)"))}(),1===oe.length&&("stripe"===oe[0]||"chargebee"===oe[0]||"quickbooks"===oe[0])&&d.createElement("button",{className:"flex items-center gap-2 px-4 py-2 border border-gray-300 rounded-md hover:bg-gray-50 transition-colors",onClick:function(){Zn.current&&Zn.current()}},d.createElement(y.BookOpen,{className:"h-4 w-4"}),"Setup Guide"),!(1===oe.length&&("stripe"===oe[0]||"chargebee"===oe[0]||"quickbooks"===oe[0]))&&d.createElement("button",{onClick:sn,className:"text-blue-600 hover:text-blue-800 underline hover:underline-offset-2 bg-transparent px-0 py-0 text-sm font-medium transition-colors flex items-center gap-1"},d.createElement(y.Database,{className:"w-4 h-4"}),d.createElement("span",null,"Dev Guide: Data Model Schema")),oe.includes("csv")&&d.createElement("button",{onClick:xo,className:"flex items-center space-x-2 h-10 px-4 py-2 bg-gray-100 text-gray-700 rounded-lg hover:bg-gray-200 transition-colors"},d.createElement(y.Download,{className:"w-4 h-4"}),d.createElement("span",null,"Download All Sample Files"))))),d.createElement($e,{step2Configs:Eo,step2UploadedFiles:wa,mapFieldsRefs:Ua,nextButtonRefs:Va,handleStep2FileUpload:ao,handleStep2FieldMappingChange:function(e,t,n){Ia(function(a){return a.map(function(a,r){return r===e?Pt(Pt({},a),{},(0,i.A)({},t,n)):a})})},processStep2Import:ro,handleDownloadAllSamples:xo,downloadFailedRecords:ho,fileInputRef:Ba,getStepStatus:function(e){return qa[e]},renderImportResults:function(e,t){if(!e)return null;var n=Ma[t],a=wa[t],r=e.isRestored||!1,s=r?"Previous Import Results":"Current Import Results",o=e.csvFileName||(null==a?void 0:a.name)||"Unknown file",l=e.originalFileSize||(null==a?void 0:a.size)||0,i=e.savedAt||e.uploadedAt||(new Date).toISOString(),c=new Date(i).toLocaleStr
1ing();return d.createElement("div",{className:"space-y-4"},d.createElement("div",{className:"bg-gray-50 border border-gray-200 rounded-lg p-4"},d.createElement("div",{className:"bg-white border rounded-lg p-4"},e.success&&!n&&0===e.errorRows&&d.createElement("div",{className:"space-y-3"},d.createElement("div",{className:"flex items-center space-x-2"},d.createElement(y.CheckCircle,{className:"w-5 h-5 text-green-600"}),d.createElement("span",{className:"text-green-800 font-medium"},"Upload completed successfully")),d.createElement("p",{className:"text-green-700 text-sm ms-[26px]"},e.message||"Your data has been processed and is ready for the next step")),e.success&&!n&&e.errorRows>0&&d.createElement(d.Fragment,null,d.createElement("div",{className:"flex items-center justify-between mb-3"},d.createElement("div",{className:"flex items-center space-x-2"},d.createElement(y.CheckCircle,{className:"w-5 h-5 text-orange-600"}),d.createElement("span",{className:"text-orange-800 font-medium"},"Upload completed with errors")),d.createElement("button",{onClick:function(){return ho(t)},className:"inline-flex items-center text-sm font-medium text-orange-600 hover:text-orange-800 underline"},d.createElement(y.Download,{className:"w-4 h-4 mr-1"}),"Download Failed Records")),d.createElement("p",{className:"text-orange-700 text-sm mb-4"},e.message||"".concat(e.processedRows," records processed successfully, ").concat(e.errorRows," records failed")),e.errors&&e.errors.length>0&&d.createElement("div",{className:"space-y-3"},d.createElement("h4",{className:"font-medium text-orange-800 text-sm"},"Processing Issues:"),d.createElement("ul",{className:"space-y-1 text-sm text-orange-700"},e.errors.slice(0,5).map(function(e,t){return d.createElement("li",{key:t,className:"flex items-start space-x-2"},d.createElement("span",{className:"text-orange-500 mt-1"},"â¢"),d.createElement("span",null,d.createElement("span",{className:"font-medium"},"Row ",e.rowNumber,":")," ",e.error))}),e.errors.length>5&&d.createElement("li",{className:"flex items-start space-x-2 text-orange-600"},d.createElement("span",{className:"text-orange-500 mt-1"},"â¢"),d.createElement("span",{className:"italic"},"+",e.errors.length-5," more errors"))))),!e.success&&e.message&&!n&&d.createElement(d.Fragment,null,d.createElement("div",{className:"flex items-center justify-between mb-3"},d.createElement("div",{className:"flex items-center space-x-2"},d.createElement(y.AlertTriangle,{className:"w-5 h-5 text-red-600"}),d.createElement("span",{className:"text-red-800 font-medium"},"Upload failed")),e.errors&&e.errors.some(function(e){return e.rowData&&Object.keys(e.rowData).length>0})&&d.createElement("button",{onClick:function(){return ho(t)},className:"inline-flex items-center text-sm font-medium text-red-600 hover:text-red-800 underline"},d.createElement(y.Download,{className:"w-4 h-4 mr-1"}),"Download Failed Records")),d.createElement("p",{className:"text-red-700 text-sm mb-4"},e.message),e.errors&&e.errors.length>0&&d.createElement("div",{className:"space-y-2"},d.createElement("h4",{className:"font-medium text-red-800 text-sm"},"Error Details:"),d.createElement("ul",{className:"space-y-1 text-sm text-red-700"},e.errors.slice(0,3).map(function(e,t){return d.createElement("li",{key:t,className:"flex items-start space-x-2"},d.createElement("span",{className:"text-red-500 mt-1"},"â¢"),d.createElement("span",null,e.error))})))),n&&d.createElement("div",{className:"space-y-3"},d.createElement("div",{className:"flex items-center space-x-2"},d.createElement("div",{className:"w-5 h-5 border-2 border-blue-600 border-t-transparent rounded-full animate-spin"}),d.createElement("span",{className:"text-blue-800 font-medium"},"Processing import...")),d.createElement("p",{className:"text-blue-700 text-sm"},"Please wait while we process your data. This may take a few moments."))),d.createElement("div",{className:"flex items-center justify-between mt-4 ml-2"},d.createElement("div",null,d.createElement("h3",{className:"font-semibold text-gray-900 text-lg"},s),d.createElement("div",{className:"text-sm text-gray-600 mt-1 space-y-1 mb-4 ms-2"},d.createElement("div",null,d.createElement("span",{className:"font-medium"},"File:")," ",o,l>0&&d.createElement("span",{className:"ml-2 text-gray-500"},"(",function(e){if(0===e)return"0 Bytes";var t=Math.floor(Math.log(e)/Math.log(1024));return parseFloat((e/Math.pow(1024,t)).toFixed(2))+" "+["Bytes","KB","MB","GB"][t]}(l),")")),d.createElement("div",null,d.createElement("span",{className:"font-medium"},"Date:")," ",c))),d.createElement("div",{className:"flex flex-col items-end space-y-1"},r&&d.createElement("div",{className:"text-xs bg-blue-100 text-blue-800 px-2 py-1 rounded-full"},"Restored"))),d.createElement("div",{className:"ms-2 grid grid-cols-2 md:grid-cols-5 ga
1p-4"},d.createElement("div",{className:"bg-white border border-gray-200 rounded-lg p-4"},d.createElement("h4",{className:"font-medium text-gray-900"},"Total Rows"),d.createElement("p",{className:"text-2xl font-bold text-gray-800"},e.totalRows)),d.createElement("div",{className:"bg-white border border-gray-200 rounded-lg p-4"},d.createElement("h4",{className:"font-medium text-gray-900"},"Processed"),d.createElement("p",{className:"text-2xl font-bold text-green-600"},e.processedRows)),d.createElement("div",{className:"bg-white border border-gray-200 rounded-lg p-4"},d.createElement("h4",{className:"font-medium text-gray-900"},"Skipped"),d.createElement("p",{className:"text-2xl font-bold text-yellow-600"},e.skippedRows)),d.createElement("div",{className:"bg-white border border-gray-200 rounded-lg p-4"},d.createElement("h4",{className:"font-medium text-gray-900"},"Duplicates"),d.createElement("p",{className:"text-2xl font-bold text-purple-600"},e.duplicateRows)),d.createElement("div",{className:"bg-white border border-gray-200 rounded-lg p-4"},d.createElement("h4",{className:"font-medium text-gray-900"},"Errors"),d.createElement("p",{className:"text-2xl font-bold text-red-600"},e.errorRows)))),d.createElement("div",{className:"text-sm text-gray-600"},"You can check the status of all files in the "," ",d.createElement("a",{href:"/analyze/developer-tool?devTab=Revenue",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center text-blue-600 hover:text-blue-800 underline"},"Revenue Source Data",d.createElement(y.ExternalLink,{className:"w-3 h-3 ml-1"}))))},getStatusDisplay:function(e){var t={pending:{color:"bg-gray-100 text-gray-600",label:"Pending"},uploaded:{color:"bg-yellow-50 text-yellow-800",label:"Uploaded"},processing:{color:"bg-blue-50 text-blue-800",label:"Processing..."},completed:{color:"bg-green-50 text-green-800",label:"Completed"},completed_with_errors:{color:"bg-orange-10 text-orange-800",label:"Completed (Errors)"},error:{color:"bg-red-50 text-red-800",label:"Error"}};return t[e]||t.pending},getImportButtonText:function(e,t){return t?"Processing...":"error"===e?"Retry Import":"completed"===e||"completed_with_errors"===e?"Re-import":"Proceed to Import"},retryStep2Import:function(e){ha(function(t){return t.map(function(t,n){return n===e?null:t})}),La(function(t){return t.map(function(t,n){return n===e?"uploaded":t})}),ro(e)},onStepComplete:wo,openSetupGuideRef:Zn,onAutoSave:fo,onTrackCompletion:function(){var e=I.getState().revenueAnalytics;vo(2,{activeSourceTab:e.activeSourceTab,sourceConfigurations:e.sourceConfigurations,selectedSources:e.selectedSources})},onApiKeyDataChange:function(e){ds(e),bs(!0),xs(!1)},initialApiKeyData:us,emailManager:is,cleanOAuthParams:Ms,onOpenIntegrationsList:function(){return at("list")}}),d.createElement(_,{isOpen:je,onClose:ln,onOpenSchemaModal:sn})),d.createElement(wt,{isOpen:Oe,onClose:ln,onOpenSchemaDrawer:on}),3===U&&d.createElement("div",{className:"w-full"},d.createElement("div",{className:"flex items-start space-x-3 mb-5"},d.createElement("div",{className:"p-2 bg-primaryExtremeLightColor rounded-lg"},d.createElement(y.TrendingUp,{className:"w-6 h-6 text-primaryColor"})),d.createElement("div",null,d.createElement("h2",{className:"text-xl font-semibold text-gray-900 mb-1"},"Core Revenue Calculation"),d.createElement("p",{className:"text-gray-600"},"Setup the core revenue calculation for your business."))),d.createElement(ot,{includeTransactionFees:Lr,setIncludeTransactionFees:Ur,step2UploadedFiles:wa,step2CsvHeaders:Ra,step2SampleRows:bt.CI,onComplete:function(e,t,n,a,r,s){Ga(e),Xa(t),Er(n),Pr(a),Kr(r),Ur(s)},loadedMrrPlans:Ha,loadedMrrStatuses:Ya,loadedPastDueHandling:hr,onGoToDataSetup:function(){V(2),Os(2)},statusOptions:Cr,setCsvDetectedStatuses:Sr,dataSetupIsComplete:co(),selectedDataType:me,setIsMrrCompleted:Tr,isMrrCompleted:Ir,includeTax:_r,onStepComplete:wo,selectedSources:oe[0],chargebeeFeePerTransaction:zr,setChargebeeFeePerTransaction:Wr,paymentGatewayFees:Jr,setPaymentGatewayFees:Zr,paymentGatewayType:Qr,setPaymentGatewayType:$r,selectedPaymentGateway:os,setSelectedPaymentGateway:ls,chargebeeChargesPerTxnFee:ns,setChargebeeChargesPerTxnFee:as,activeSourceTab:ge})),4===U&&d.createElement("div",{className:"w-full"},d.createElement("div",{className:"flex items-start space-x-3 mb-5"},d.createElement("div",{className:"p-2 bg-primaryExtremeLightColor roun
1ded-lg"},d.createElement(y.TrendingUp,{className:"w-6 h-6 text-primaryColor"})),d.createElement("div",null,d.createElement("h2",{className:"text-xl font-semibold text-gray-900 mb-1"},"Advance Revenue Calculation"),d.createElement("p",{className:"text-gray-600"},"Setup the advance revenue calculation for your business."))),d.createElement(mt,{onComplete:function(e,t){tr(e),sr(t)},loadedRevenueOption:er[0],loadedArrMethod:er[1],loadedChurnOptions:rr})),5===U&&d.createElement("div",{className:"w-full"},d.createElement("div",{className:"flex items-start mb-5 gap-3"},d.createElement("div",{className:"p-2 bg-primaryExtremeLightColor rounded-lg"},d.createElement(y.Goal,{className:"w-6 h-6 text-primaryColor"})),d.createElement("div",null,d.createElement("h2",{className:"text-xl font-semibold text-gray-900 mb-1"},"Set Goals"),d.createElement("p",{className:"text-gray-600"},"Configure revenue goals and targets to track your business progress."))),d.createElement("div",{className:"pb-20 ms-9"},d.createElement(ut.q,{currentGoals:Ns,onSave:function(e){ws(e)},currency:Fr,asModal:!1,isDemoMode:Re,onGoalsChange:Zs,onPersistOnboardingStep:Ys}))),6===U&&d.createElement("div",{className:"space-y-6"},d.createElement(A.A,{mode:"email",heading:"Revenue Alerts Features Coming Soon! ð",description:"We're building a revenue alert system to help you track your revenue and take action when needed.",icon:"lock",customEmailSubject:"Requesting Revenue Alerts",requestLabel:"Request Revenue Alerts"}),d.createElement(h,null)),7===U&&d.createElement("div",{className:"space-y-6 flex-1 overflow-x-hidden"},d.createElement("div",{className:"flex items-start space-x-3"},d.createElement("div",{className:"p-2 bg-primaryExtremeLightColor rounded-lg"},d.createElement(y.Gauge,{className:"w-6 h-6 text-primaryColor"})),d.createElement("div",{className:"flex-1"},d.createElement("div",{className:"flex items-center gap-4 mb-2"},d.createElement("h2",{className:"text-xl font-semibold text-gray-910 mb-1"},"Setup Health Status"),d.createElement("button",{onClick:function(){return $n(!0)},className:"flex ml-auto items-center gap-2 px-3 py-1.5 text-sm font-medium text-gray-700 bg-white border border-gray-200 rounded-lg hover:bg-gray-50 transition-colors"},d.createElement(y.BookOpen,{className:"w-4 h-4"}),"Guide")),d.createElement("p",{className:"text-gray-600"},"Monitor and resolve data quality issues to ensure accurate analytics and reporting."))),d.createElement("div",{className:"space-y-3"},(Po=oe.includes("stripe")||oe.includes("chargebee"),Oo="stripe"!==ge&&"chargebee"!==ge||!oe.includes(ge)?oe.includes("stripe")?"stripe":"chargebee":ge,Mo="chargebee"===Oo?ve.chargebee:ve.stripe,Fo="chargebee"===Oo?"Chargebee":"Stripe",Ko=!(null==Mo||!Mo.selectedIdentifierKey),jo=null!==(Ro=null==Mo?void 0:Mo.customerMetaDataKeys)&&void 0!==Ro?Ro:[],qo=!Re&&0===jo.length,Po?d.createElement("div",{id:"stripe"===Oo?"missing-account-identifier-stripe":"missing-account-identifier-chargebee",className:"border border-gray-200 rounded-lg bg-white shadow-sm"},d.createElement("button",{onClick:function(){return Rn(!Dn)},className:"w-full flex items-center p-5 hover:bg-gray-50 transition-colors relative"},d.createElement("div",{className:"flex items-center gap-3 flex-1"},d.createElement("div",{className:"flex items-center justify-center w-8 h-8 rounded-full text-white font-semibold flex-shrink-0 bg-gray-700"},d.createElement("span",{className:"text-sm"},"1")),d.createElement("div",{className:"text-left"},d.createElement("div",{className:"text-lg font-semibold text-gray-900"},(0,Dt.FF)(Fo)),d.createElement("div",{className:"text-sm text-gray-600"},"Account identifier is the unique key in your product telemetry for customers that link them to a Account. Choose a key from your ",Fo," customer metadata to link account records."))),d.createElement("div",{className:"flex items-center gap-3"},Ko?d.createElement("span",{className:"text-sm font-semibold text-green-600"},"Configured"):d.createElement("span",{className:"text-sm font-semibold text-red-600"},"Not configured"),Dn?d.createElement(y.ChevronDown,{className:"w-5 h-5 text-gray-400"}):d.createElement(y.ChevronRight,{className:"w-5 h-5 text-gray-400"}))),Dn&&d.createElement("div",{className:"px-5 pb-5 border-t border-gray-200 pt-5 bg-gray-50 pl-12"},qo?d.createElement(d.Fragment,null,d.createElement("p",{className:"text-sm text-gray-600"},d.createElement("span",{className:"text-base font-bold text-gray-800"},"Error: "),"No account identifier key is found in the customer data sent by ",Fo,"."),d.createElement("div",{className:"space-y-2"},d.createElement("div",null,d.createElement("span",{className:"font-bold text-gray-800"},"Impact: "),d.createElement("span",{className:"text-sm text-gray-600"},"Essential for accurately linking records across revenue, marketing, and productâensuring every account's activities, transactions, and campaigns are unified under one identifier.")),d.createElement("div",{className:"flex items-center"},d.createElement("span",{className:"font-bold text-gray-800"},"Resolution: "),d.createElement("span",{className:"text-sm text-gray-600"},"Include an Account identifier key in ",Fo,"'s metadata."),d.createElement("button",{onClick:function(){Bn(Oo),qn(!0),setTimeout(function(){Jn.current&&Jn.current.scrollIntoView({behavior:"smooth",block:"start"})},100)},className:"text-sm text-blue-600 hover:underline ms-1"},"See how to fix this")))):d.createElement(d.Fragment,null,d.createElement("div",null,d.createElement("div",{className:"flex items-center gap-4"},d.createElement("label",{className:"block font-bold text-gray-800"},"Current selected Account Identifier:"),d.createElement("select",{value:"stripe"===Oo?On:null!==(_o=null==Mo?void 0:Mo.selectedIdentifierKey)&&void 0!==_o?_o:"group_id",onChange:function(e){var t=e.target.value;"stripe"===Oo?(Mn(t),ve.stripe&&eo("stripe",Pt(Pt({},ve.stripe),{},{selectedIdentifierKey:t}
1))):ve.chargebee&&eo("chargebee",Pt(Pt({},ve.chargebee),{},{selectedIdentifierKey:t}))},className:"px-3 py-2 border border-gray-300 rounded-md text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent"},Re?d.createElement("option",{value:"group_id"},"group_id"):(jo.length?jo:["group_id"]).map(function(e){return d.createElement("option",{key:e,value:e},e)})))),d.createElement("div",{className:"space-y-2 mt-4"},d.createElement("div",null,d.createElement("span",{className:"font-bold text-gray-800"},"Impact: "),d.createElement("span",{className:"text-sm text-gray-600"},"Customers without this key are excluded from account-level linking â This breaks the correlation between marketing, sales and revenue.")),d.createElement("div",{className:"flex items-center"},d.createElement("span",{className:"font-bold text-gray-800"},"Resolution: "),d.createElement("span",{className:"text-sm text-gray-600 ms-1"},"If account identifier key used in your product telemetry is not present in the list â"," ",d.createElement("button",{onClick:function(){Bn(Oo),qn(!0),setTimeout(function(){Jn.current&&Jn.current.scrollIntoView({behavior:"smooth",block:"start"})},100)},className:"text-blue-600 hover:underline"},"see how to fix this"))))))):null),d.createElement(kt.A,{expandedIssueId:Nn,onToggleIssue:wn,idMissingAccountsCount:oa,missingRevenueDataCount:la,unidentifiedAccountsCount:ia,unidentifiedFromRevenueCount:ca,unidentifiedFromProductCount:ma,selectedSource:oe[0]||null,accountIdentifier:"group_id",filteredIssueIds:["id-missing-accounts"],hideExportImport:!0,showRedirectLink:!0,redirectLink:"/analyze/diagnostics-report/revenue-product-correlation?subIssueId=id-missing-accounts",redirectLinkText:"View detailed resolution steps",displayIndex:oe.includes("stripe")||oe.includes("chargebee")?2:1}),d.createElement(kt.A,{expandedIssueId:Nn,onToggleIssue:wn,idMissingAccountsCount:oa,missingRevenueDataCount:la,unidentifiedAccountsCount:ia,unidentifiedFromRevenueCount:ca,unidentifiedFromProductCount:ma,selectedSource:oe[0]||null,accountIdentifier:"group_id",filteredIssueIds:["missing-revenue-data"],hideExportImport:!0,showRedirectLink:!0,redirectLink:"/analyze/diagnostics-report/revenue-product-correlation?subIssueId=missing-revenue-data",redirectLinkText:"View detailed resolution steps",displayIndex:oe.includes("stripe")||oe.includes("chargebee")?3:2}),d.createElement(At.A,{expandedIssueId:kn,onToggleIssue:An,transactionsWithoutInvoiceCount:ua,filteredIssueIds:["transactions-without-invoices"],hideExportImport:!0,showRedirectLink:!0,redirectLink:"/analyze/diagnostics-report/revenue-missing-data?subIssueId=transactions-without-invoices",redirectLinkText:"View detailed resolution steps",displayIndex:oe.includes("stripe")||oe.includes("chargebee")?4:3}))))))))),d.createElement("div",{className:"bg-white w-[84%] mx-auto fixed bottom-0 flex justify-end items-center py-4 px-8 z-10"},d.createElement("div",{className:"flex space-x-4"},ke&&d.createElement("span",{className:"text-red-600 mr-4"},ke),!Re&&d.createElement("button",{id:"detect_demo_active",className:"px-3 py-3 rounded-lg font-medium transition-transform duration-200 text-blue-800 hover:bg-white text-sm hover:scale-[1.02] underline underline-offset-4",onClick:function(){return Fs(),void De("/analyze/revenue-analytics/dashboard")}},d.createElement("span",{className:"flex items-center space-x-2"},"Skip setup, try demo mode ",d.createElement(y.ArrowRight,{className:"w-5 h-5 mr-1"}))),5===U?(Io=!!(Ao=ks)&&(0,dt.pP)(Ao),To=!!Ao&&(0,dt.MV)(Ao),Do=Ds||Io&&!To,d.createElement(d.Fragment,null,d.createElement("button",{type:"button",onClick:function(){Qs()},disabled:Do,className:"inline-flex items-center space-x-2 px-6 py-3 rounded-lg font-semibold bg-white border-2 border-primaryColor text-primaryColor transition-colors ".concat(Do?"opacity-50 cursor-not-allowed":"hover:bg-gray-50")},d.createElement("span",null,Ds?"Savingâ¦":Io?"Save goals & go to Integrations":"Go to Integrations"),d.createElement(y.ArrowRight,{className:"w-5 h-5"})),d.createElement("button",{type:"button",onClick:function(){$s()},disabled:Do,className:"inline-flex items-center space-x-2 px-6 py-3 rounded-lg font-semibold text-white transition-colors shadow-lg hover:shadow-xl ".concat(Do?"bg-gray-400 cursor-not-allowed":"bg-primaryColor hover:bg-primaryColor")},d.createElement("span",null,Ds?"Savingâ¦":Io?"Save goals & go to Dashboard":"Go to Dashboard"),d.createElement(y.ArrowRight,{className:"w-5 h-5"})))):d.createElement("button",{onClick:function(){return wo()},disabled:!No()||Ne||2===U&&"chargebee"===ge&&(null===(n=ve.chargebee)||void 0===n?void 0:n.isSetupIncomplete),className:"inline-flex items-center space-x-2 px-6 py-3 rounded-lg font-semibold text-white transition-colors shadow-lg hover:shadow-xl ".concat(!No()||Ne||2===U&&"chargebee"===ge&&null!==(m=ve.chargebee)&&void 0!==m&&m.isSetupIncomplete?"bg-gray-400 cursor-not-allowed opacity-60":"bg-primaryColor hover:bg-primaryColor")},d.createElement("span",null,Ne?"Processing...":U===_s.length?"Go to Dashboard":2!==U||mo()?"Next Step":"Complete Source Setup"),d.createElement(y.ArrowRight,{className:"w-5 h-5"})))),d.createElement(St.Ny,{isOpen:f.isOpen,onClose:f.close,featureName:"Revenue Intelligence",notifications:[{key:"rule_revenue_setup_telemetry"}]}),dr&&br&&d.createElement(re.O,{isOpen:br,onClose:function(){return yr(!1)},team:null!=dr?dr:void 0,onInvite:function(){}}),jn&&(ko=null!=Vn?Vn:null!=oe&&oe.includes("chargebee")?"chargebee":"stripe",d.createElement("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex justify-end z-50",onClick:function(){qn(!1),Bn(null)},role:"presentation","aria-hidden":"false"},d.createElement("div",{className:"mt-10 h-[calc(100%-2.5rem)] w-[600px] bg-white shadow-xl overflow-y-auto flex flex-col",onClick:function(e){return e.stopPropagation()},role:"dialog","aria-modal":"true","aria-label":"Setup guide"},d.createElement("div",{className:"p-6 flex-1 overflow-y-auto"},"chargebee"===ko?d.createElement(Te.O,{step3Ref:Jn,setExpanded:Gn,expanded:Hn,onClose:function(){qn(!1),Bn(null)}}):d.createElement(ae.e,{step3Ref:Jn,setExpanded:Gn,expanded:Hn,onClose:function(){qn(!1),Bn(null)}}))))),d.createElement(Tt.A,{isOpen:Qn,onClose:function(){return $n(!1)},setupContext:"revenue-analytics",selectedSource:oe[0]||null,onNavigateToConfigureStep:function(){Rn(!0),setTimeout(function(){var e="chargebee"===oe[0]?"missing-account-identifier-chargebee":"missing-account-identifier-stripe",t=document.getElementById(e);t&&t.scrollIntoView({behavior:"smooth",block:"center"})},100)}
1,onNavigateToIssueCard:function(e){"id-missing-accounts"===e?wn("id-missing-accounts"):"missing-revenue-data"===e&&wn("missing-revenue-data"),setTimeout(function(){var t=document.getElementById("issue-card-".concat(e));t&&t.scrollIntoView({behavior:"smooth",block:"center"})},100)}}))}},58968(e,t,n){n.d(t,{A:()=>s});var a=n(44914),r=n(96452);const s=function(){return a.createElement("div",{className:"ml-3 inline-flex items-center px-2 py-1 rounded-full text-xs font-medium bg-purple-50 text-purple-700"},a.createElement(r.Rocket,{className:"w-3.5 h-3.5 mr-1"}),"Planned")}},99034(e,t,n){n.d(t,{Mz:()=>c,je:()=>d});var a=n(32816),r=n(92207),s=n.n(r),o=n(73977);function l(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return i(e,t);var n={}.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)?i(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var a=0,r=function(){};return{s:r,n:function(){return a>=e.length?{done:!0}:{done:!1,value:e[a++]}},e:function(e){throw e},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,o=!0,l=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){l=!0,s=e},f:function(){try{o||null==n.return||n.return()}finally{if(l)throw s}}}}function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,a=Array(t);n<t;n++)a[n]=e[n];return a}var c=function(){var e=(0,a.A)(s().mark(function e(t){return s().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Promise(function(e,n){var a=new FileReader,r=1024,s=0,o="",l=!1,i=function(){if(s>=t.size)n(new Error("No headers found in file - file appears to be empty or contains no text"));else{var e=t.slice(s,s+r);a.readAsText(e)}};a.onload=function(a){var c,u,d=null===(c=a.target)||void 0===c?void 0:c.result;for(o+=d;-1!==(u=o.search(/\r?\n/))&&!l;){var p=o.substring(0,u);o=o.substring(u+("\r"===o[u]?2:1));var g=p.trim();if(g&&/[a-zA-Z0-9]/.test(g))try{var f=m(g);return l=!0,void e(f)}catch(e){return void n(new Error("Error parsing header line: ".concat(e.message)))}}if(!l&&s+r<t.size)s+=r,i();else if(!l){var b=o.trim();if(b&&/[a-zA-Z0-9]/.test(b))try{var y=m(b);return void e(y)}catch(e){return void n(new Error("Error parsing header line: ".concat(e.message)))}n(new Error("No headers found in file - file appears to be empty or contains no text"))}},a.onerror=function(){n(new Error("Error reading file"))},i()}));case 1:case"end":return e.stop()}},e)}));return function(t){return e.apply(this,arguments)}}(),m=function(e){var t=u(e,","),n=u(e,";");if(n.length>t.length&&n.length>=2)return n;if(t.length>=2)return t;if(n.length>=1)return n;if(t.length>=1)return t;throw new Error("Unable to parse header line - no valid delimiter found")},u=function(e,t){var n,a=[],r=l(e.split(t));try{for(r.s();!(n=r.n()).done;){var s=n.value.trim().replace(/^["']|["']$/g,"");a.push(s)}}catch(e){r.e(e)}finally{r.f()}return a.filter(function(e){return e.length>0})},d=function(){var e=(0,a.A)(s().mark(function e(t,n,a){return s().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Promise(function(e,r){var s=new FileReader;s.onload=function(t){try{var s,l=(null===(s=t.target)||void 0===s?void 0:s.result).split("\n").filter(function(e){return e.trim()});if(0===l.length)return void r(new Error("Empty file"));for(var i="",c=0,d=0;d<l.length;d++){var p=l[d].trim();if(p&&/[a-zA-Z0-9]/.test(p)){i=p,c=d+1;break}}if(!i)return void r(new Error("No headers found in file"));var g=m(i),f=l.slice(c);if(f.length>1e4)return void r(new Error("File too large. Maximum 10,000 records allowed."));var b=[],y=new Map,v=[],x=a||["customer_id","plan_id","product_id","amount","currency","billing_date","payment_status","payment_method"],h=x.filter(function(e){return!n[e]});if(h.length>0)return void r(new Error("Missing required field mappings: ".concat(h.join(", "))));var E=f[0]||i,N=E.split(";").length>E.split(",").length?";":",";f.forEach(function(e,t){var a=c+t+1,r=u(e,N);if(r.length===g.length){var s={};if(g.forEach(function(e,t){s[e]=r[t]||""}),x.forEach(function(e){s[n[e]]||b.push({row:a,field:e,value:"",message:"".concat(e," is required")})}),["customer_id","plan_id","product_id","amount","currency","billing_date","payment_status","payment_method"].every(function(e){return x.includes(e)})&&0===b.filter(function(e){return e.row===a}).length){var l=s[n.customer_id],i=s[n.plan_id],m=s[n.product_id],d=s[n.amount],p=s[n.currency],f=s[n.billing_date],h=s[n.payment_status],E=s[n.payment_method],w=parseFloat(d),C=new Date(f);y.has(l)||y.set(l,{id:l,name:"Customer ".concat(l),email:"customer".concat(l,"@example.com"),status:"active",createdAt:new Date,totalRevenue:0,currency:p,mrr:0,arr:0,ltv:0});var S={id:(0,o.v4)(),customerId:l,productId:m,amount:w,currency:p,billingDate:C,paymentStatus:h,paymentMethod:E,description:"Payment for ".concat(m," (").concat(i,")")};v.push(S);var k=y.get(l);"successful"===h&&(k.totalRevenue+=w,k.mrr=w,k.arr=12*k.mrr,k.ltv=1.5*k.totalRevenue,k.lastPaymentDate=C)}}else b.push({row:a,field:"row",value:e,message:"Column count mismatch"})});var w={totalRecords:f.length,successfulRecords:f.length-b.length,failedRecords:b.length,errors:b,customers:Array.from(y.values()),transactions:v};e(w)}catch(e){r(e)}},s.onerror=function(){r(new Error("Error reading file"))},s.readAsText(t)}));case 1:case"end":return e.stop()}},e)}));return function(t,n,a){return e.apply(this,arguments)}}()}}]); 2//# sourceMappingURL=594.c0be99639df631bbbb01.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.