"use strict";(()=>{var C={prod:"https://api.dontchurn.io",dev:"https://dev.api.dontchurn.io",localhost:"http://localhost:3001"},Q={prod:"https://dist.dontchurn.io",dev:"https://dev.dist.dontchurn.io",localhost:"http://localhost:3001/static"};var m=(t,e,n)=>{console.error("\u274C [DontChurn] Please contact us if the problem persists.");let{handleError:r}=e;try{if(t){let o=t.querySelector("#dc-error");if(o){let a=typeof n=="string"?n:n.message;o.textContent=`An unexpected error occurred while cancelling your subscription: ${a}`,o.style.display="block",console.log("[TEST] [DontChurn] Displayed error in modal:",o.textContent)}else console.warn("\u26A0\uFE0F [DontChurn] Could not find #dc-error element to display error message")}else console.warn("\u26A0\uFE0F [DontChurn] Root is null, cannot display error message in modal")}catch(o){console.error("\u274C [DontChurn] Error displaying modal error:",o)}finally{throw r&&(console.log("[TEST] [DontChurn] Calling handleError callback with error:",n),r(n)),n}},y=(t,e)=>{throw console.error("\u274C [DontChurn] "+t,e),Error(t)};var S=async(t,e,n,r,o,a=!1)=>{try{let s=await fetch(n,o),i=await s.json();if(!s.ok){let c=i?.error||r;throw Error(c)}return i}catch(s){if(console.error("\u274C [DontChurn] An error occurred while calling the DontChurn API:",s),a)throw s;return m(t,e,s)}},G=async t=>{let{appId:e,subscriptionId:n,hash:r,flowId:o,apiLocation:a}=t,s=C[a];try{let i=await S(null,t,`${s}/start-flow`,"Could not start flow",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({appId:e,subscriptionId:n,hash:r,flowId:o})});if(!i.html)throw Error("No html returned from API");if(!i.headerFont||!i.paragraphFont||!i.primaryColor)throw Error("No styling data returned from API");if(!i.language)throw Error("No language returned from API");let{html:c,headerFont:u,paragraphFont:l,primaryColor:d,language:p}=i;return{html:c,headerFont:u,paragraphFont:l,primaryColor:d,language:p}}catch(i){return console.error("\u274C [DontChurn] Error starting flow:",i),null}},z=async(t,e)=>{let{apiLocation:n}=t,r=C[n];try{let o={previewFlowId:e},a=new URLSearchParams(o).toString(),s=await S(null,t,`${r}/start-preview-flow?${a}`,"Could not start preview flow",{method:"GET",headers:{"Content-Type":"application/json"}});if(!s.html)throw Error("No html returned from API");if(!s.headerFont||!s.paragraphFont||!s.primaryColor)throw Error("No styling data returned from API");if(!s.language)throw Error("No language returned from API");let{html:i,headerFont:c,paragraphFont:u,primaryColor:l,language:d}=s;return{html:i,headerFont:c,paragraphFont:u,primaryColor:l,language:d}}catch(o){return console.error("\u274C [DontChurn] Error starting preview flow:",o),null}},K=async(t,e)=>{let{appId:n,subscriptionId:r,hash:o,apiLocation:a,isPreview:s}=e;if(s)return!0;let i=C[a];try{let c=await S(t,e,`${i}/submit-cancellation`,"Could not submit cancellation",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({appId:n,subscriptionId:r,hash:o})});return console.log("\u2714\uFE0F [DontChurn] Cancellation submitted successfully:",c),!0}catch(c){return console.error("\u274C [DontChurn] Error submitting cancellation:",c),m(t,e,c),!1}},Z=async(t,e,n)=>{let{appId:r,subscriptionId:o,hash:a,apiLocation:s,isPreview:i}=e;if(i)return!0;let c=C[s];try{let u=await S(t,e,`${c}/pause-subscription`,"Could not pause subscription",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({appId:r,subscriptionId:o,hash:a,durationMonths:n})});return console.log("\u2714\uFE0F [DontChurn] Subscription paused successfully:",u),!0}catch(u){return console.error("\u274C [DontChurn] Error pausing subscription:",u),m(t,e,u),!1}},ee=async(t,e)=>{let{appId:n,subscriptionId:r,hash:o,apiLocation:a,isPreview:s}=e;if(s)return!0;let i=C[a];try{let c=await S(t,e,`${i}/unpause-subscription`,"Could not unpause subscription",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({appId:n,subscriptionId:r,hash:o})});return console.log("\u2714\uFE0F [DontChurn] Subscription unpaused successfully:",c),!0}catch(c){return console.error("\u274C [DontChurn] Error unpausing subscription:",c),m(t,e,c),!1}},te=async(t,e,n)=>{let{appId:r,subscriptionId:o,hash:a,apiLocation:s,isPreview:i}=e;if(i)return!0;let c=C[s];try{let u=await S(t,e,`${c}/switch-plan`,"Could not switch plan",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({appId:r,subscriptionId:o,hash:a,newPriceId:n})});return console.log("\u2714\uFE0F [DontChurn] Plan switched successfully:",u),!0}catch(u){return console.error("\u274C [DontChurn] Error switching plan:",u),m(t,e,u),!1}},re=async(t,e)=>{let{appId:n,subscriptionId:r,hash:o,apiLocation:a,isPreview:s}=e;if(s)return!0;let i=C[a];try{let c=await S(t,e,`${i}/reactivate-subscription`,"Could not reactivate subscription",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({appId:n,subscriptionId:r,hash:o})});return console.log("\u2714\uFE0F [DontChurn] Subscription reactivated successfully:",c),!0}catch(c){return console.error("\u274C [DontChurn] Error reactivating subscription:",c),m(t,e,c),!1}},ne=async(t,e,n,r)=>{let{appId:o,subscriptionId:a,hash:s,apiLocation:i,isPreview:c}=e;if(c)return!0;let u=C[i];try{let l=await S(t,e,`${u}/apply-discount`,"Could not apply discount",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({appId:o,subscriptionId:a,hash:s,hashedStepId:n,discountId:r})});return console.log("\u2714\uFE0F [DontChurn] Discount applied successfully:",l),!0}catch(l){return console.error("\u274C [DontChurn] Error applying discount:",l),m(t,e,l),!1}},oe=async(t,e,n)=>{let{appId:r,subscriptionId:o,hash:a,apiLocation:s,isPreview:i}=e;if(i)return!0;let c=C[s];try{let u=await S(t,e,`${c}/extend-trial`,"Could not extend trial",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({appId:r,subscriptionId:o,hash:a,hashedId:n})});return console.log("\u2714\uFE0F [DontChurn] Trial extended successfully:",u),!0}catch(u){return console.error("\u274C [DontChurn] Error extending trial:",u),m(t,e,u),!1}},ae=async(t,e,n,r)=>{let{appId:o,subscriptionId:a,hash:s,apiLocation:i,isPreview:c}=e;if(c)return!0;let u=C[i];try{let l=await S(t,e,`${u}/store-survey-choice`,"Could not store survey choice",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({appId:o,subscriptionId:a,hash:s,surveyChoice:n,surveyText:r??void 0})},!0);return console.log("\u2714\uFE0F [DontChurn] Survey choice stored successfully:",l),!0}catch(l){return console.warn("\u26A0\uFE0F [DontChurn] Warning: storing survey choice did not work. This is not fatal and will not abort the flow. Error:",l),!1}},se=async(t,e,n)=>{let{appId:r,subscriptionId:o,hash:a,apiLocation:s,isPreview:i}=e;if(i)return!0;let c=C[s];try{let u=await S(t,e,`${c}/store-feedback`,"Could not store feedback",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({appId:r,subscriptionId:o,hash:a,feedback:n})},!0);return console.log("\u2714\uFE0F [DontChurn] Feedback stored successfully:",u),!0}catch(u){return console.warn("\u26A0\uFE0F [DontChurn] Warning: storing feedback did not work. This is not fatal and will not abort the flow. Error:",u),!1}},ie=async(t,e,n)=>{let{appId:r,subscriptionId:o,hash:a,apiLocation:s,isPreview:i}=e;if(i)return!0;if(n&&n!=="CONTACTED"&&n!=="SENT_TO_CUSTOM_PAGE"&&n!=="SENT_TO_FEEDBACK_CALL")return console.log("[TEST] [abortFlow] Not aborting flow because outcome is not in AbortFlowOutcome:",n),!0;let c=C[s];try{let u=await S(t,e,`${c}/abort-flow`,"Could not abort flow",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({appId:r,subscriptionId:o,hash:a,outcome:n??void 0})},!0);return console.log("\u2714\uFE0F [DontChurn] Flow aborted successfully:",u),!0}catch(u){return console.error("\u274C [DontChurn] Error aborting flow:",u),!1}};var j=()=>{let t=window.dontchurn;if(!t)return console.warn('\u26A0\uFE0F [DontChurn] "window.dontchurn" object not found'),null;let e=t.config;if(!e)return console.warn('\u26A0\uFE0F [DontChurn] "window.dontchurn.config" object not found'),null;let{appId:n}=e;return n?e:(console.warn('\u26A0\uFE0F [DontChurn] "appId" is missing in "config" object'),null)};var at=Math.pow(10,8)*24*60*60*1e3,Rr=-at,R=6048e5,ce=864e5;var st=3600;var ue=st*24,Nr=ue*7,it=ue*365.2425,ct=it/12,qr=ct*3,U=Symbol.for("constructDateFrom");function w(t,e){return typeof t=="function"?t(e):t&&typeof t=="object"&&U in t?t[U](e):t instanceof Date?new t.constructor(e):new Date(e)}function h(t,e){return w(e||t,t)}function le(t,e,n){let r=h(t,n?.in);if(isNaN(e))return w(n?.in||t,NaN);if(!e)return r;let o=r.getDate(),a=w(n?.in||t,r.getTime());a.setMonth(r.getMonth()+e+1,0);let s=a.getDate();return o>=s?a:(r.setFullYear(a.getFullYear(),a.getMonth(),o),r)}var ut={};function P(){return ut}function M(t,e){let n=P(),r=e?.weekStartsOn??e?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,o=h(t,e?.in),a=o.getDay(),s=(a<r?7:0)+a-r;return o.setDate(o.getDate()-s),o.setHours(0,0,0,0),o}function O(t,e){return M(t,{...e,weekStartsOn:1})}function N(t,e){let n=h(t,e?.in),r=n.getFullYear(),o=w(n,0);o.setFullYear(r+1,0,4),o.setHours(0,0,0,0);let a=O(o),s=w(n,0);s.setFullYear(r,0,4),s.setHours(0,0,0,0);let i=O(s);return n.getTime()>=a.getTime()?r+1:n.getTime()>=i.getTime()?r:r-1}function _(t){let e=h(t),n=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()));return n.setUTCFullYear(e.getFullYear()),+t-+n}function de(t,...e){let n=w.bind(null,t||e.find(r=>typeof r=="object"));return e.map(n)}function $(t,e){let n=h(t,e?.in);return n.setHours(0,0,0,0),n}function me(t,e,n){let[r,o]=de(n?.in,t,e),a=$(r),s=$(o),i=+a-_(a),c=+s-_(s);return Math.round((i-c)/ce)}function fe(t,e){let n=N(t,e),r=w(e?.in||t,0);return r.setFullYear(n,0,4),r.setHours(0,0,0,0),O(r)}function pe(t){return t instanceof Date||typeof t=="object"&&Object.prototype.toString.call(t)==="[object Date]"}function he(t){return!(!pe(t)&&typeof t!="number"||isNaN(+h(t)))}function ge(t,e){let n=h(t,e?.in);return n.setFullYear(n.getFullYear(),0,1),n.setHours(0,0,0,0),n}var lt={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},we=(t,e,n)=>{let r,o=lt[t];return typeof o=="string"?r=o:e===1?r=o.one:r=o.other.replace("{{count}}",e.toString()),n?.addSuffix?n.comparison&&n.comparison>0?"in "+r:r+" ago":r};function L(t){return(e={})=>{let n=e.width?String(e.width):t.defaultWidth;return t.formats[n]||t.formats[t.defaultWidth]}}var dt={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},mt={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},ft={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},ye={date:L({formats:dt,defaultWidth:"full"}),time:L({formats:mt,defaultWidth:"full"}),dateTime:L({formats:ft,defaultWidth:"full"})};var pt={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},be=(t,e,n,r)=>pt[t];function v(t){return(e,n)=>{let r=n?.context?String(n.context):"standalone",o;if(r==="formatting"&&t.formattingValues){let s=t.defaultFormattingWidth||t.defaultWidth,i=n?.width?String(n.width):s;o=t.formattingValues[i]||t.formattingValues[s]}else{let s=t.defaultWidth,i=n?.width?String(n.width):t.defaultWidth;o=t.values[i]||t.values[s]}let a=t.argumentCallback?t.argumentCallback(e):e;return o[a]}}var ht={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},gt={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},wt={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},yt={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},bt={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},Ct={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},St=(t,e)=>{let n=Number(t),r=n%100;if(r>20||r<10)switch(r%10){case 1:return n+"st";case 2:return n+"nd";case 3:return n+"rd"}return n+"th"},Ce={ordinalNumber:St,era:v({values:ht,defaultWidth:"wide"}),quarter:v({values:gt,defaultWidth:"wide",argumentCallback:t=>t-1}),month:v({values:wt,defaultWidth:"wide"}),day:v({values:yt,defaultWidth:"wide"}),dayPeriod:v({values:bt,defaultWidth:"wide",formattingValues:Ct,defaultFormattingWidth:"wide"})};function D(t){return(e,n={})=>{let r=n.width,o=r&&t.matchPatterns[r]||t.matchPatterns[t.defaultMatchWidth],a=e.match(o);if(!a)return null;let s=a[0],i=r&&t.parsePatterns[r]||t.parsePatterns[t.defaultParseWidth],c=Array.isArray(i)?Dt(i,d=>d.test(s)):vt(i,d=>d.test(s)),u;u=t.valueCallback?t.valueCallback(c):c,u=n.valueCallback?n.valueCallback(u):u;let l=e.slice(s.length);return{value:u,rest:l}}}function vt(t,e){for(let n in t)if(Object.prototype.hasOwnProperty.call(t,n)&&e(t[n]))return n}function Dt(t,e){for(let n=0;n<t.length;n++)if(e(t[n]))return n}function q(t){return(e,n={})=>{let r=e.match(t.matchPattern);if(!r)return null;let o=r[0],a=e.match(t.parsePattern);if(!a)return null;let s=t.valueCallback?t.valueCallback(a[0]):a[0];s=n.valueCallback?n.valueCallback(s):s;let i=e.slice(o.length);return{value:s,rest:i}}}var Mt=/^(\d+)(th|st|nd|rd)?/i,xt=/\d+/i,Et={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},Tt={any:[/^b/i,/^(a|c)/i]},Pt={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},Lt={any:[/1/i,/2/i,/3/i,/4/i]},kt={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},Ot={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},Ft={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},At={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},It={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},Wt={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},Se={ordinalNumber:q({matchPattern:Mt,parsePattern:xt,valueCallback:t=>parseInt(t,10)}),era:D({matchPatterns:Et,defaultMatchWidth:"wide",parsePatterns:Tt,defaultParseWidth:"any"}),quarter:D({matchPatterns:Pt,defaultMatchWidth:"wide",parsePatterns:Lt,defaultParseWidth:"any",valueCallback:t=>t+1}),month:D({matchPatterns:kt,defaultMatchWidth:"wide",parsePatterns:Ot,defaultParseWidth:"any"}),day:D({matchPatterns:Ft,defaultMatchWidth:"wide",parsePatterns:At,defaultParseWidth:"any"}),dayPeriod:D({matchPatterns:It,defaultMatchWidth:"any",parsePatterns:Wt,defaultParseWidth:"any"})};var H={code:"en-US",formatDistance:we,formatLong:ye,formatRelative:be,localize:Ce,match:Se,options:{weekStartsOn:0,firstWeekContainsDate:1}};function ve(t,e){let n=h(t,e?.in);return me(n,ge(n))+1}function De(t,e){let n=h(t,e?.in),r=+O(n)-+fe(n);return Math.round(r/R)+1}function Y(t,e){let n=h(t,e?.in),r=n.getFullYear(),o=P(),a=e?.firstWeekContainsDate??e?.locale?.options?.firstWeekContainsDate??o.firstWeekContainsDate??o.locale?.options?.firstWeekContainsDate??1,s=w(e?.in||t,0);s.setFullYear(r+1,0,a),s.setHours(0,0,0,0);let i=M(s,e),c=w(e?.in||t,0);c.setFullYear(r,0,a),c.setHours(0,0,0,0);let u=M(c,e);return+n>=+i?r+1:+n>=+u?r:r-1}function Me(t,e){let n=P(),r=e?.firstWeekContainsDate??e?.locale?.options?.firstWeekContainsDate??n.firstWeekContainsDate??n.locale?.options?.firstWeekContainsDate??1,o=Y(t,e),a=w(e?.in||t,0);return a.setFullYear(o,0,r),a.setHours(0,0,0,0),M(a,e)}function xe(t,e){let n=h(t,e?.in),r=+M(n,e)-+Me(n,e);return Math.round(r/R)+1}function f(t,e){let n=t<0?"-":"",r=Math.abs(t).toString().padStart(e,"0");return n+r}var x={y(t,e){let n=t.getFullYear(),r=n>0?n:1-n;return f(e==="yy"?r%100:r,e.length)},M(t,e){let n=t.getMonth();return e==="M"?String(n+1):f(n+1,2)},d(t,e){return f(t.getDate(),e.length)},a(t,e){let n=t.getHours()/12>=1?"pm":"am";switch(e){case"a":case"aa":return n.toUpperCase();case"aaa":return n;case"aaaaa":return n[0];case"aaaa":default:return n==="am"?"a.m.":"p.m."}},h(t,e){return f(t.getHours()%12||12,e.length)},H(t,e){return f(t.getHours(),e.length)},m(t,e){return f(t.getMinutes(),e.length)},s(t,e){return f(t.getSeconds(),e.length)},S(t,e){let n=e.length,r=t.getMilliseconds(),o=Math.trunc(r*Math.pow(10,n-3));return f(o,e.length)}};var A={am:"am",pm:"pm",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},J={G:function(t,e,n){let r=t.getFullYear()>0?1:0;switch(e){case"G":case"GG":case"GGG":return n.era(r,{width:"abbreviated"});case"GGGGG":return n.era(r,{width:"narrow"});case"GGGG":default:return n.era(r,{width:"wide"})}},y:function(t,e,n){if(e==="yo"){let r=t.getFullYear(),o=r>0?r:1-r;return n.ordinalNumber(o,{unit:"year"})}return x.y(t,e)},Y:function(t,e,n,r){let o=Y(t,r),a=o>0?o:1-o;if(e==="YY"){let s=a%100;return f(s,2)}return e==="Yo"?n.ordinalNumber(a,{unit:"year"}):f(a,e.length)},R:function(t,e){let n=N(t);return f(n,e.length)},u:function(t,e){let n=t.getFullYear();return f(n,e.length)},Q:function(t,e,n){let r=Math.ceil((t.getMonth()+1)/3);switch(e){case"Q":return String(r);case"QQ":return f(r,2);case"Qo":return n.ordinalNumber(r,{unit:"quarter"});case"QQQ":return n.quarter(r,{width:"abbreviated",context:"formatting"});case"QQQQQ":return n.quarter(r,{width:"narrow",context:"formatting"});case"QQQQ":default:return n.quarter(r,{width:"wide",context:"formatting"})}},q:function(t,e,n){let r=Math.ceil((t.getMonth()+1)/3);switch(e){case"q":return String(r);case"qq":return f(r,2);case"qo":return n.ordinalNumber(r,{unit:"quarter"});case"qqq":return n.quarter(r,{width:"abbreviated",context:"standalone"});case"qqqqq":return n.quarter(r,{width:"narrow",context:"standalone"});case"qqqq":default:return n.quarter(r,{width:"wide",context:"standalone"})}},M:function(t,e,n){let r=t.getMonth();switch(e){case"M":case"MM":return x.M(t,e);case"Mo":return n.ordinalNumber(r+1,{unit:"month"});case"MMM":return n.month(r,{width:"abbreviated",context:"formatting"});case"MMMMM":return n.month(r,{width:"narrow",context:"formatting"});case"MMMM":default:return n.month(r,{width:"wide",context:"formatting"})}},L:function(t,e,n){let r=t.getMonth();switch(e){case"L":return String(r+1);case"LL":return f(r+1,2);case"Lo":return n.ordinalNumber(r+1,{unit:"month"});case"LLL":return n.month(r,{width:"abbreviated",context:"standalone"});case"LLLLL":return n.month(r,{width:"narrow",context:"standalone"});case"LLLL":default:return n.month(r,{width:"wide",context:"standalone"})}},w:function(t,e,n,r){let o=xe(t,r);return e==="wo"?n.ordinalNumber(o,{unit:"week"}):f(o,e.length)},I:function(t,e,n){let r=De(t);return e==="Io"?n.ordinalNumber(r,{unit:"week"}):f(r,e.length)},d:function(t,e,n){return e==="do"?n.ordinalNumber(t.getDate(),{unit:"date"}):x.d(t,e)},D:function(t,e,n){let r=ve(t);return e==="Do"?n.ordinalNumber(r,{unit:"dayOfYear"}):f(r,e.length)},E:function(t,e,n){let r=t.getDay();switch(e){case"E":case"EE":case"EEE":return n.day(r,{width:"abbreviated",context:"formatting"});case"EEEEE":return n.day(r,{width:"narrow",context:"formatting"});case"EEEEEE":return n.day(r,{width:"short",context:"formatting"});case"EEEE":default:return n.day(r,{width:"wide",context:"formatting"})}},e:function(t,e,n,r){let o=t.getDay(),a=(o-r.weekStartsOn+8)%7||7;switch(e){case"e":return String(a);case"ee":return f(a,2);case"eo":return n.ordinalNumber(a,{unit:"day"});case"eee":return n.day(o,{width:"abbreviated",context:"formatting"});case"eeeee":return n.day(o,{width:"narrow",context:"formatting"});case"eeeeee":return n.day(o,{width:"short",context:"formatting"});case"eeee":default:return n.day(o,{width:"wide",context:"formatting"})}},c:function(t,e,n,r){let o=t.getDay(),a=(o-r.weekStartsOn+8)%7||7;switch(e){case"c":return String(a);case"cc":return f(a,e.length);case"co":return n.ordinalNumber(a,{unit:"day"});case"ccc":return n.day(o,{width:"abbreviated",context:"standalone"});case"ccccc":return n.day(o,{width:"narrow",context:"standalone"});case"cccccc":return n.day(o,{width:"short",context:"standalone"});case"cccc":default:return n.day(o,{width:"wide",context:"standalone"})}},i:function(t,e,n){let r=t.getDay(),o=r===0?7:r;switch(e){case"i":return String(o);case"ii":return f(o,e.length);case"io":return n.ordinalNumber(o,{unit:"day"});case"iii":return n.day(r,{width:"abbreviated",context:"formatting"});case"iiiii":return n.day(r,{width:"narrow",context:"formatting"});case"iiiiii":return n.day(r,{width:"short",context:"formatting"});case"iiii":default:return n.day(r,{width:"wide",context:"formatting"})}},a:function(t,e,n){let o=t.getHours()/12>=1?"pm":"am";switch(e){case"a":case"aa":return n.dayPeriod(o,{width:"abbreviated",context:"formatting"});case"aaa":return n.dayPeriod(o,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return n.dayPeriod(o,{width:"narrow",context:"formatting"});case"aaaa":default:return n.dayPeriod(o,{width:"wide",context:"formatting"})}},b:function(t,e,n){let r=t.getHours(),o;switch(r===12?o=A.noon:r===0?o=A.midnight:o=r/12>=1?"pm":"am",e){case"b":case"bb":return n.dayPeriod(o,{width:"abbreviated",context:"formatting"});case"bbb":return n.dayPeriod(o,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return n.dayPeriod(o,{width:"narrow",context:"formatting"});case"bbbb":default:return n.dayPeriod(o,{width:"wide",context:"formatting"})}},B:function(t,e,n){let r=t.getHours(),o;switch(r>=17?o=A.evening:r>=12?o=A.afternoon:r>=4?o=A.morning:o=A.night,e){case"B":case"BB":case"BBB":return n.dayPeriod(o,{width:"abbreviated",context:"formatting"});case"BBBBB":return n.dayPeriod(o,{width:"narrow",context:"formatting"});case"BBBB":default:return n.dayPeriod(o,{width:"wide",context:"formatting"})}},h:function(t,e,n){if(e==="ho"){let r=t.getHours()%12;return r===0&&(r=12),n.ordinalNumber(r,{unit:"hour"})}return x.h(t,e)},H:function(t,e,n){return e==="Ho"?n.ordinalNumber(t.getHours(),{unit:"hour"}):x.H(t,e)},K:function(t,e,n){let r=t.getHours()%12;return e==="Ko"?n.ordinalNumber(r,{unit:"hour"}):f(r,e.length)},k:function(t,e,n){let r=t.getHours();return r===0&&(r=24),e==="ko"?n.ordinalNumber(r,{unit:"hour"}):f(r,e.length)},m:function(t,e,n){return e==="mo"?n.ordinalNumber(t.getMinutes(),{unit:"minute"}):x.m(t,e)},s:function(t,e,n){return e==="so"?n.ordinalNumber(t.getSeconds(),{unit:"second"}):x.s(t,e)},S:function(t,e){return x.S(t,e)},X:function(t,e,n){let r=t.getTimezoneOffset();if(r===0)return"Z";switch(e){case"X":return Te(r);case"XXXX":case"XX":return F(r);case"XXXXX":case"XXX":default:return F(r,":")}},x:function(t,e,n){let r=t.getTimezoneOffset();switch(e){case"x":return Te(r);case"xxxx":case"xx":return F(r);case"xxxxx":case"xxx":default:return F(r,":")}},O:function(t,e,n){let r=t.getTimezoneOffset();switch(e){case"O":case"OO":case"OOO":return"GMT"+Ee(r,":");case"OOOO":default:return"GMT"+F(r,":")}},z:function(t,e,n){let r=t.getTimezoneOffset();switch(e){case"z":case"zz":case"zzz":return"GMT"+Ee(r,":");case"zzzz":default:return"GMT"+F(r,":")}},t:function(t,e,n){let r=Math.trunc(+t/1e3);return f(r,e.length)},T:function(t,e,n){return f(+t,e.length)}};function Ee(t,e=""){let n=t>0?"-":"+",r=Math.abs(t),o=Math.trunc(r/60),a=r%60;return a===0?n+String(o):n+String(o)+e+f(a,2)}function Te(t,e){return t%60===0?(t>0?"-":"+")+f(Math.abs(t)/60,2):F(t,e)}function F(t,e=""){let n=t>0?"-":"+",r=Math.abs(t),o=f(Math.trunc(r/60),2),a=f(r%60,2);return n+o+e+a}var Pe=(t,e)=>{switch(t){case"P":return e.date({width:"short"});case"PP":return e.date({width:"medium"});case"PPP":return e.date({width:"long"});case"PPPP":default:return e.date({width:"full"})}},Le=(t,e)=>{switch(t){case"p":return e.time({width:"short"});case"pp":return e.time({width:"medium"});case"ppp":return e.time({width:"long"});case"pppp":default:return e.time({width:"full"})}},Ht=(t,e)=>{let n=t.match(/(P+)(p+)?/)||[],r=n[1],o=n[2];if(!o)return Pe(t,e);let a;switch(r){case"P":a=e.dateTime({width:"short"});break;case"PP":a=e.dateTime({width:"medium"});break;case"PPP":a=e.dateTime({width:"long"});break;case"PPPP":default:a=e.dateTime({width:"full"});break}return a.replace("{{date}}",Pe(r,e)).replace("{{time}}",Le(o,e))},ke={p:Le,P:Ht};var Rt=/^D+$/,Nt=/^Y+$/,qt=["D","DD","YY","YYYY"];function Oe(t){return Rt.test(t)}function Fe(t){return Nt.test(t)}function Ae(t,e,n){let r=Yt(t,e,n);if(console.warn(r),qt.includes(t))throw new RangeError(r)}function Yt(t,e,n){let r=t[0]==="Y"?"years":"days of the month";return`Use \`${t.toLowerCase()}\` instead of \`${t}\` (in \`${e}\`) for formatting ${r} to the input \`${n}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}var Bt=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,jt=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,Ut=/^'([^]*?)'?$/,_t=/''/g,$t=/[a-zA-Z]/;function Ie(t,e,n){let r=P(),o=n?.locale??r.locale??H,a=n?.firstWeekContainsDate??n?.locale?.options?.firstWeekContainsDate??r.firstWeekContainsDate??r.locale?.options?.firstWeekContainsDate??1,s=n?.weekStartsOn??n?.locale?.options?.weekStartsOn??r.weekStartsOn??r.locale?.options?.weekStartsOn??0,i=h(t,n?.in);if(!he(i))throw new RangeError("Invalid time value");let c=e.match(jt).map(l=>{let d=l[0];if(d==="p"||d==="P"){let p=ke[d];return p(l,o.formatLong)}return l}).join("").match(Bt).map(l=>{if(l==="''")return{isToken:!1,value:"'"};let d=l[0];if(d==="'")return{isToken:!1,value:Jt(l)};if(J[d])return{isToken:!0,value:l};if(d.match($t))throw new RangeError("Format string contains an unescaped latin alphabet character `"+d+"`");return{isToken:!1,value:l}});o.localize.preprocessor&&(c=o.localize.preprocessor(i,c));let u={firstWeekContainsDate:a,weekStartsOn:s,locale:o};return c.map(l=>{if(!l.isToken)return l.value;let d=l.value;(!n?.useAdditionalWeekYearTokens&&Fe(d)||!n?.useAdditionalDayOfYearTokens&&Oe(d))&&Ae(d,e,String(t));let p=J[d[0]];return p(i,d,o.localize,u)}).join("")}function Jt(t){let e=t.match(Ut);return e?e[1].replace(_t,"'"):t}var Xt={lessThanXSeconds:{one:"moins d\u2019une seconde",other:"moins de {{count}} secondes"},xSeconds:{one:"1 seconde",other:"{{count}} secondes"},halfAMinute:"30 secondes",lessThanXMinutes:{one:"moins d\u2019une minute",other:"moins de {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"environ 1 heure",other:"environ {{count}} heures"},xHours:{one:"1 heure",other:"{{count}} heures"},xDays:{one:"1 jour",other:"{{count}} jours"},aboutXWeeks:{one:"environ 1 semaine",other:"environ {{count}} semaines"},xWeeks:{one:"1 semaine",other:"{{count}} semaines"},aboutXMonths:{one:"environ 1 mois",other:"environ {{count}} mois"},xMonths:{one:"1 mois",other:"{{count}} mois"},aboutXYears:{one:"environ 1 an",other:"environ {{count}} ans"},xYears:{one:"1 an",other:"{{count}} ans"},overXYears:{one:"plus d\u2019un an",other:"plus de {{count}} ans"},almostXYears:{one:"presqu\u2019un an",other:"presque {{count}} ans"}},We=(t,e,n)=>{let r,o=Xt[t];return typeof o=="string"?r=o:e===1?r=o.one:r=o.other.replace("{{count}}",String(e)),n?.addSuffix?n.comparison&&n.comparison>0?"dans "+r:"il y a "+r:r};var Vt={full:"EEEE d MMMM y",long:"d MMMM y",medium:"d MMM y",short:"dd/MM/y"},Qt={full:"HH:mm:ss zzzz",long:"HH:mm:ss z",medium:"HH:mm:ss",short:"HH:mm"},Gt={full:"{{date}} '\xE0' {{time}}",long:"{{date}} '\xE0' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},He={date:L({formats:Vt,defaultWidth:"full"}),time:L({formats:Qt,defaultWidth:"full"}),dateTime:L({formats:Gt,defaultWidth:"full"})};var zt={lastWeek:"eeee 'dernier \xE0' p",yesterday:"'hier \xE0' p",today:"'aujourd\u2019hui \xE0' p",tomorrow:"'demain \xE0' p'",nextWeek:"eeee 'prochain \xE0' p",other:"P"},Re=(t,e,n,r)=>zt[t];var Kt={narrow:["av. J.-C","ap. J.-C"],abbreviated:["av. J.-C","ap. J.-C"],wide:["avant J\xE9sus-Christ","apr\xE8s J\xE9sus-Christ"]},Zt={narrow:["T1","T2","T3","T4"],abbreviated:["1er trim.","2\xE8me trim.","3\xE8me trim.","4\xE8me trim."],wide:["1er trimestre","2\xE8me trimestre","3\xE8me trimestre","4\xE8me trimestre"]},er={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["janv.","f\xE9vr.","mars","avr.","mai","juin","juil.","ao\xFBt","sept.","oct.","nov.","d\xE9c."],wide:["janvier","f\xE9vrier","mars","avril","mai","juin","juillet","ao\xFBt","septembre","octobre","novembre","d\xE9cembre"]},tr={narrow:["D","L","M","M","J","V","S"],short:["di","lu","ma","me","je","ve","sa"],abbreviated:["dim.","lun.","mar.","mer.","jeu.","ven.","sam."],wide:["dimanche","lundi","mardi","mercredi","jeudi","vendredi","samedi"]},rr={narrow:{am:"AM",pm:"PM",midnight:"minuit",noon:"midi",morning:"mat.",afternoon:"ap.m.",evening:"soir",night:"mat."},abbreviated:{am:"AM",pm:"PM",midnight:"minuit",noon:"midi",morning:"matin",afternoon:"apr\xE8s-midi",evening:"soir",night:"matin"},wide:{am:"AM",pm:"PM",midnight:"minuit",noon:"midi",morning:"du matin",afternoon:"de l\u2019apr\xE8s-midi",evening:"du soir",night:"du matin"}},nr=(t,e)=>{let n=Number(t),r=e?.unit;if(n===0)return"0";let o=["year","week","hour","minute","second"],a;return n===1?a=r&&o.includes(r)?"\xE8re":"er":a="\xE8me",n+a},or=["MMM","MMMM"],Ne={preprocessor:(t,e)=>t.getDate()===1||!e.some(r=>r.isToken&&or.includes(r.value))?e:e.map(r=>r.isToken&&r.value==="do"?{isToken:!0,value:"d"}:r),ordinalNumber:nr,era:v({values:Kt,defaultWidth:"wide"}),quarter:v({values:Zt,defaultWidth:"wide",argumentCallback:t=>t-1}),month:v({values:er,defaultWidth:"wide"}),day:v({values:tr,defaultWidth:"wide"}),dayPeriod:v({values:rr,defaultWidth:"wide"})};var ar=/^(\d+)(ième|ère|ème|er|e)?/i,sr=/\d+/i,ir={narrow:/^(av\.J\.C|ap\.J\.C|ap\.J\.-C)/i,abbreviated:/^(av\.J\.-C|av\.J-C|apr\.J\.-C|apr\.J-C|ap\.J-C)/i,wide:/^(avant Jésus-Christ|après Jésus-Christ)/i},cr={any:[/^av/i,/^ap/i]},ur={narrow:/^T?[1234]/i,abbreviated:/^[1234](er|ème|e)? trim\.?/i,wide:/^[1234](er|ème|e)? trimestre/i},lr={any:[/1/i,/2/i,/3/i,/4/i]},dr={narrow:/^[jfmasond]/i,abbreviated:/^(janv|févr|mars|avr|mai|juin|juill|juil|août|sept|oct|nov|déc)\.?/i,wide:/^(janvier|février|mars|avril|mai|juin|juillet|août|septembre|octobre|novembre|décembre)/i},mr={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^av/i,/^ma/i,/^juin/i,/^juil/i,/^ao/i,/^s/i,/^o/i,/^n/i,/^d/i]},fr={narrow:/^[lmjvsd]/i,short:/^(di|lu|ma|me|je|ve|sa)/i,abbreviated:/^(dim|lun|mar|mer|jeu|ven|sam)\.?/i,wide:/^(dimanche|lundi|mardi|mercredi|jeudi|vendredi|samedi)/i},pr={narrow:[/^d/i,/^l/i,/^m/i,/^m/i,/^j/i,/^v/i,/^s/i],any:[/^di/i,/^lu/i,/^ma/i,/^me/i,/^je/i,/^ve/i,/^sa/i]},hr={narrow:/^(a|p|minuit|midi|mat\.?|ap\.?m\.?|soir|nuit)/i,any:/^([ap]\.?\s?m\.?|du matin|de l'après[-\s]midi|du soir|de la nuit)/i},gr={any:{am:/^a/i,pm:/^p/i,midnight:/^min/i,noon:/^mid/i,morning:/mat/i,afternoon:/ap/i,evening:/soir/i,night:/nuit/i}},qe={ordinalNumber:q({matchPattern:ar,parsePattern:sr,valueCallback:t=>parseInt(t)}),era:D({matchPatterns:ir,defaultMatchWidth:"wide",parsePatterns:cr,defaultParseWidth:"any"}),quarter:D({matchPatterns:ur,defaultMatchWidth:"wide",parsePatterns:lr,defaultParseWidth:"any",valueCallback:t=>t+1}),month:D({matchPatterns:dr,defaultMatchWidth:"wide",parsePatterns:mr,defaultParseWidth:"any"}),day:D({matchPatterns:fr,defaultMatchWidth:"wide",parsePatterns:pr,defaultParseWidth:"any"}),dayPeriod:D({matchPatterns:hr,defaultMatchWidth:"any",parsePatterns:gr,defaultParseWidth:"any"})};var Ye={code:"fr",formatDistance:We,formatLong:He,formatRelative:Re,localize:Ne,match:qe,options:{weekStartsOn:1,firstWeekContainsDate:4}};var Be={en:"MMM dd, yyyy",fr:"dd MMM yyyy"},je={en:H,fr:Ye};var Ue=(t,e)=>Ie(t,Be[e],{locale:je[e]});var Je=(t,e,n)=>{try{return t.querySelectorAll(".dc-pause-step").forEach(o=>{let a=o.querySelector(".dc-dropdown-container");if(a&&(!wr(a,t,e)||!yr(a,t,e)||(a.addEventListener("change",()=>{if(!_e(t,e,o,n)||!$e(t,e,o))return!1}),!_e(t,e,o,n))||!$e(t,e,o)))return!1}),!0}catch(r){return console.error("\u274C [DontChurn] Error setting up pause steps:",r),m(t,e,r),!1}},wr=(t,e,n)=>{try{let r=t.querySelector(".dc-dropdown-options");if(!r)return console.error("\u274C [DontChurn] Missing dropdown options container"),!1;let o=`dropdown-${Math.random().toString(36).substring(2,9)}`;t.setAttribute("data-dropdown-id",o),r.setAttribute("data-dropdown-parent",o);let a=r.cloneNode(!0);return a.classList.add("dc-dropdown-portal"),a.setAttribute("data-dropdown-parent",o),a.style.position="fixed",a.style.display="none",a.style.zIndex="1000",e.appendChild(a),r.style.display="none",window.addEventListener("resize",()=>{t.classList.contains("open")&&Xe(t,a)}),!0}catch(r){return console.error("\u274C [DontChurn] Error creating dropdown portal:",r),m(e,n,r),!1}},Xe=(t,e)=>{let n=t.querySelector(".dc-dropdown-trigger");if(!n)return;let r=n.getBoundingClientRect();e.style.top=`${r.bottom+window.scrollY}px`,e.style.left=`${r.left+window.scrollX}px`,e.style.width=`${r.width}px`,e.style.zIndex="20000"},yr=(t,e,n)=>{try{let r=t.querySelector(".dc-dropdown-trigger"),o=t.getAttribute("data-dropdown-id"),a=t.querySelectorAll(".dc-dropdown-option"),s=e.querySelector(`.dc-dropdown-portal[data-dropdown-parent="${o}"]`),i=s?.querySelectorAll(".dc-dropdown-option"),c=t.querySelector(".dc-dropdown-value");if(!r||!a.length||!s||!i.length||!c)return console.error("\u274C [DontChurn] Missing dropdown elements"),!1;r.addEventListener("click",l=>{l.stopPropagation(),t.classList.toggle("open")?(Xe(t,s),s.style.display="block",r.classList.add("selected")):(s.style.display="none",r.classList.remove("selected"))}),i.forEach((l,d)=>{l.addEventListener("click",()=>{let p=l.getAttribute("data-value"),b=l.getAttribute("data-text");t.setAttribute("data-selected-value",p||"1"),c.textContent=b||"1 month",a.forEach(g=>g.classList.remove("selected")),i.forEach(g=>g.classList.remove("selected")),a[d]&&a[d].classList.add("selected"),l.classList.add("selected"),t.classList.remove("open"),s.style.display="none",r.classList.remove("selected");let T=new CustomEvent("change",{bubbles:!0,detail:{value:p,text:b}});t.dispatchEvent(T)})}),e.addEventListener("mousedown",l=>{if(!t.classList.contains("open"))return;let d=l.target;!t.contains(d)&&!s.contains(d)&&(t.classList.remove("open"),s.style.display="none",r.classList.remove("selected"))},!0);let u=a[0];return u&&(t.setAttribute("data-selected-value",u.getAttribute("data-value")||"1"),u.classList.add("selected"),i[0]?.classList.add("selected")),!0}catch(r){return console.error("\u274C [DontChurn] Error setting up custom dropdown:",r),m(e,n,r),!1}},_e=(t,e,n,r)=>{try{let o=n.querySelector(".dc-dropdown-container"),a=n.querySelectorAll("span#pause-end-date-marker");if(!o||a.length===0)return!0;let s=parseInt(o.getAttribute("data-selected-value")||"1"),i=le(new Date,s),c=Ue(i,r);return a.forEach(u=>u.textContent=c),!0}catch(o){return console.error("\u274C [DontChurn] Error updating pause end date:",o),m(t,e,o),!1}},$e=(t,e,n)=>{try{let r=n.querySelector(".dc-dropdown-container"),o=r.querySelector(".dc-dropdown-value"),a=n.querySelectorAll("span#pause-duration-marker");if(!r||!o||a.length===0)return!0;let s=o.textContent||"1 month";return a.forEach(i=>i.textContent=s),!0}catch(r){return console.error("\u274C [DontChurn] Error updating pause duration markers:",r),m(t,e,r),!1}};var Ve=(t,e)=>{try{return t.querySelectorAll(".dc-feedback-step").forEach(r=>{if(!br(t,e,r))return!1}),!0}catch(n){return console.error("\u274C [DontChurn] Error setting up feedback steps:",n),m(t,e,n),!1}},br=(t,e,n)=>{try{let r=n.getAttribute("data-minimum-feedback-length");if(!r)return console.error("\u274C [DontChurn] Minimum feedback length is missing"),!1;let o=parseInt(r);if(isNaN(o)||o<0)return console.error("\u274C [DontChurn] Minimum feedback length is invalid"),!1;if(o===0)return!0;let a=n.querySelector(".dc-feedback-textarea"),s=n.querySelector(".dc-full-feedback-counter"),i=n.querySelector(".dc-feedback-counter");if(!a)return console.error("\u274C [DontChurn] Feedback textarea is missing"),!1;if(!s)return console.error("\u274C [DontChurn] Full feedback counter is missing"),!1;if(!i)return console.error("\u274C [DontChurn] Feedback counter is missing"),!1;let c=0;return a.addEventListener("input",()=>{let u=a.value.length;i.textContent=u.toString();let l=c>=o,d=u>=o;if(console.log("[TEST] Feedback input event listener fired with:",{previousLength:c,length:u,wasAboveMinimum:l,isAboveMinimum:d,minimumFeedbackLength:o}),l&&!d){s.style.color="#ed3535",a.classList.add("error");let p=n.querySelector(".dc-next-button");p&&p.setAttribute("disabled","true")}else if(!l&&d){s.style.color="#1b2035",a.classList.remove("error");let p=n.querySelector(".dc-next-button");p&&p.removeAttribute("disabled")}c=u}),!0}catch(r){return console.error("\u274C [DontChurn] Error handling feedback counter:",r),m(t,e,r),!1}},Qe=t=>{try{let e=t.closest(".dc-step");if(!e)return console.error("\u274C [DontChurn] Could not find current step"),null;let n=e.getAttribute("data-minimum-feedback-length");if(!n)return console.error("\u274C [DontChurn] Minimum feedback length is missing"),null;let r=parseInt(n);if(isNaN(r)||r<0)return console.error("\u274C [DontChurn] Minimum feedback length is invalid"),null;let o=e.querySelector(".dc-feedback-textarea");if(!o)return console.error("\u274C [DontChurn] Feedback textarea is missing"),null;if(r>0){let a=e.querySelector(".dc-full-feedback-counter"),s=e.querySelector(".dc-feedback-counter");if(!a)return console.error("\u274C [DontChurn] Full feedback counter is missing"),null;if(!s)return console.error("\u274C [DontChurn] Feedback counter is missing"),null;if(o.value.length<r)return a.style.color="#ed3535",o.classList.add("error"),t.setAttribute("disabled","true"),!1}return o.value.trim()}catch(e){return console.error("\u274C [DontChurn] Error reading feedback:",e),null}};var Ge=(t,e)=>{try{return t.querySelectorAll(".dc-survey-step").forEach(r=>{let o=r.querySelector(".dc-survey-options"),a=r.querySelector(".dc-survey-textarea");o.addEventListener("change",()=>{let i=o.querySelector('input[type="radio"]:checked');if(!i)return;let c=o.querySelectorAll(".dc-survey-option-label"),u=o.querySelectorAll(".dc-survey-option-title");c.forEach(b=>b.classList.remove("selected")),u.forEach(b=>b.classList.remove("selected"));let l=i.closest(".dc-survey-option-label"),d=l.querySelector(".dc-survey-option-title");l&&l.classList.add("selected"),d&&d.classList.add("selected");let p=r.querySelector(".dc-next-button");if(p){let b=i.getAttribute("data-next-hashed-id");b?p.setAttribute("data-next-hashed-id",b):p.removeAttribute("data-next-hashed-id"),p.removeAttribute("disabled");let T=i.hasAttribute("data-show-textarea");if(a){a.value="",a.style.display=T?"block":"none";let g=i.getAttribute("data-placeholder");g&&a.setAttribute("placeholder",g)}}});let s=r.querySelector(".dc-next-button");s&&s.setAttribute("disabled","true")}),!0}catch(n){return console.error("\u274C [DontChurn] Error setting up survey steps:",n),m(t,e,n),!1}};var ze=(t,e)=>{try{return t.querySelectorAll(".dc-warning-step").forEach(r=>{let o=r.querySelector(".dc-next-button");if(!o)throw Error("Next button is missing");let a=r.querySelector(".dc-warning-checkbox-label");if(!a)return o.removeAttribute("disabled");let s=r.querySelector(".dc-warning-checkbox-text");if(s&&s.textContent==="")return a.style.display="none",o.removeAttribute("disabled");let i=r.querySelector(".dc-warning-checkbox-unchecked"),c=r.querySelector(".dc-warning-checkbox-checked");if(!i)throw Error("Unchecked SVG is missing");if(!c)throw Error("Checked SVG is missing");o.setAttribute("disabled","true");let u=!1,l=()=>{u=!u,u?(i.style.display="none",c.style.display="block",o.removeAttribute("disabled")):(i.style.display="block",c.style.display="none",o.setAttribute("disabled","true"))};a.addEventListener("click",l)}),!0}catch(n){return console.error("\u274C [DontChurn] Error setting up warning steps:",n),m(t,e,n),!1}};var Ke=(t,e)=>{try{return!0}catch(n){return console.error("\u274C [DontChurn] Error setting up switch plan steps:",n),m(t,e,n),!1}};var Ze=(t,e,n)=>{try{return!(!Je(t,e,n)||!Ve(t,e)||!Ge(t,e)||!ze(t,e)||!Ke(t,e))}catch(r){return console.error("\u274C [DontChurn] Error setting up steps:",r),m(t,e,r),!1}},E=async(t,e,n,r,o,a)=>{try{if(o==="data-hashed-id"&&!n)return console.error("\u274C [DontChurn] Target hashed ID is null but attribute is data-hashed-id"),!1;let s=o==="data-step"?e:n,i=parseInt(e),c=t.querySelector("#dc-modal");if(!c)return console.error("\u274C [DontChurn] dc-modal element not found in shadow root"),!1;let u=o==="data-step"?i:i-1;if(!et(t,u,r))return console.error("\u274C [DontChurn] Error updating progress bar"),!1;let d=c.querySelector(`[${o}="${s}"]`);if(!d)return console.error("\u274C [DontChurn] Step element not found. Attribute:",o,"target order:",e,"target hashed ID:",n,"target:",s),!1;if(d.getAttribute("data-step-disabled")==="true"){let k=(o==="data-hashed-id"?i:i+1).toString();return await E(t,k,null,r,"data-step",a)}if(i===r){let g=d.getAttribute("data-should-cancel-subscription");if(!g)return console.error("\u274C [DontChurn] Should cancel subscription attribute not found on last step element"),!1;if(g==="true"){if(!await Cr(t,a))return!1;a.outcome="CANCELLED"}}return c.querySelectorAll(".dc-step").forEach(g=>{let k=g;k.style.display=k.getAttribute(o)===s?"flex":"none"}),!0}catch(s){return console.error("\u274C [DontChurn] Error showing step:",s),m(t,a,s),!1}},Cr=async(t,e)=>await K(t,e),et=(t,e,n)=>{try{let r=n==0?100:e/n*100,o=Math.min(Math.max(r,0),100),a=t.querySelector(".dc-progress-fill");return a?(a.style.width=`${o}%`,!0):(console.error("\u274C [DontChurn] Progress fill element not found"),!1)}catch(r){return console.error("\u274C [DontChurn] Error updating progress bar:",r),!1}},tt=t=>et(t,0,0);var rt=(t,e,n,r)=>{try{let{handleContact:o}=r;return e.querySelectorAll("[data-action]").forEach(s=>{s.addEventListener("click",async()=>{let i=s.getAttribute("data-action");if(i)if(i==="next"){let c=s.getAttribute("data-next-step");c&&await E(e,c,null,n,"data-step",r)}else if(i==="nextSurvey"){let c=xr(s),u=s.getAttribute("data-next-hashed-id"),l=s.getAttribute("data-next-step");if(console.log("[TEST] [DontChurn] Using hashedId:",u,"and nextStep:",l),!l){console.error("\u274C [DontChurn] No next step found for survey choice");return}if(r.userInput.surveyChoice=c?.surveyChoice,r.userInput.surveyText=c?.surveyText??void 0,c){let{surveyChoice:d,surveyText:p}=c;await ae(e,r,d,p)}else console.warn("\u26A0\uFE0F [DontChurn] Warning: could not find survey choice in the current step. This is not fatal and will not abort the flow.");u?await E(e,l,u,n,"data-hashed-id",r):await E(e,l,null,n,"data-step",r)}else if(i==="nextFeedback"){let c=Qe(s);if(c===!1)return;if(c===null){console.error("\u274C [DontChurn] Error getting feedback value");return}r.userInput.feedback=c,c?await se(e,r,c):console.warn("\u26A0\uFE0F [DontChurn] Warning: could not find feedback in the current step. This is not fatal and will not abort the flow.");let u=s.getAttribute("data-next-step");u&&await E(e,u,null,n,"data-step",r)}else if(i==="selectOption"){let c=s.getAttribute("data-hashed-id");c&&await E(e,c,null,n,"data-hashed-id",r)}else if(i==="pauseSubscription"){let c=Sr(e,r,s);if(!c||(r.outcome="PAUSED",!await Z(e,r,c)))return;console.log("\u2705 [DontChurn] User accepted pause"),I(e,r,s,i)}else if(i==="unpauseSubscription"){if(!await ee(e,r))return;r.outcome="UNPAUSED",console.log("\u2705 [DontChurn] User unpaused subscription"),I(e,r,s,i)}else if(i==="switchPlan"){let c=vr(e,r,s);if(!c||!await te(e,r,c))return;r.outcome="SWITCHED_PLAN",console.log("\u2705 [DontChurn] User switched plan"),I(e,r,s,i)}else if(i==="extendTrial"){let c=Mr(e,r,s);if(!c||!await oe(e,r,c))return;r.outcome="EXTENDED_TRIAL",console.log("\u2705 [DontChurn] User extended trial"),I(e,r,s,i)}else if(i==="applyDiscount"){let c=Dr(e,r,s);if(!c)return;let{hashedStepId:u,discountId:l}=c;if(!await ne(e,r,u,l))return;r.outcome="ACCEPTED_DISCOUNT",console.log("\u2705 [DontChurn] User applied discount"),I(e,r,s,i)}else if(i==="reactivateSubscription"){if(!await re(e,r))return;r.outcome="REACTIVATED",console.log("\u2705 [DontChurn] User reactivated subscription"),I(e,r,s,i)}else if(i==="contact")r.outcome="CONTACTED",await W(e,t,r),o?await o():console.error("\u274C [DontChurn] No contact handler provided in context. Please provide a handleContact function in order to use contact steps.");else if(i==="redirectCP"||i==="redirectCC"){let c=s.getAttribute("data-redirect-url");if(!c){console.error("\u274C [DontChurn] No redirect URL provided");return}let u=i==="redirectCP"?"SENT_TO_CUSTOM_PAGE":"SENT_TO_FEEDBACK_CALL";r.outcome=u,await W(e,t,r),window.open(c,"_blank")}else i==="close"?await W(e,t,r):console.warn("[DontChurn] Unknown action:",i)})}),!0}catch(o){return console.error("\u274C [DontChurn] Error setting up action buttons:",o),m(e,r,o),!1}},I=(t,e,n,r)=>{try{let o=n.closest(".dc-step");if(!o)return console.error(`\u274C [DontChurn] Could not find step container for ${r} action`),!1;let a=o.querySelector(".dc-default-view");a?a.style.display="none":console.error(`\u274C [DontChurn] Could not find default view for ${r} action`);let s=o.querySelector(".dc-success-view");return s?s.style.display="flex":console.error(`\u274C [DontChurn] Could not find success view for ${r} action`),tt(t)?!0:(console.error(`\u274C [DontChurn] Could not fill progress bar for ${r} action`),!1)}catch(o){return console.error(`\u274C [DontChurn] Error showing success view for ${r}:`,o),m(t,e,o),!1}},Sr=(t,e,n)=>{try{let r=n.closest(".dc-step");if(!r)return console.error("\u274C [DontChurn] Could not find step container for pause action"),null;let o=r.querySelector(".dc-dropdown-container");if(!o)return console.error("\u274C [DontChurn] Could not find dropdown container"),null;let a=o.getAttribute("data-selected-value");if(!a)return console.error("\u274C [DontChurn] Could not find selected duration value"),null;let s=parseInt(a);return isNaN(s)?(console.error("\u274C [DontChurn] Invalid duration value:",a),null):s}catch(r){return console.error("\u274C [DontChurn] Error reading pause duration:",r),m(t,e,r),null}},vr=(t,e,n)=>{try{let r=n.closest(".dc-step");if(!r)return console.error("\u274C [DontChurn] Could not find step container for pause action"),null;let o=r.getAttribute("data-new-price-id");return o||(console.error("\u274C [DontChurn] New price ID not found in step container"),null)}catch(r){return console.error("\u274C [DontChurn] Error reading new price ID:",r),m(t,e,r),null}},Dr=(t,e,n)=>{try{let r=n.closest(".dc-step");if(!r)return console.error("\u274C [DontChurn] Could not find step container for pause action"),null;let o=r.getAttribute("data-hashed-id");if(!o)return console.error("\u274C [DontChurn] Hashed step ID not found in step container"),null;let a=r.getAttribute("data-discount-coupon-id");return a?{hashedStepId:o,discountId:a}:(console.error("\u274C [DontChurn] Discount ID not found in step container"),null)}catch(r){return console.error("\u274C [DontChurn] Error reading new price ID:",r),m(t,e,r),null}},Mr=(t,e,n)=>{try{let r=n.closest(".dc-step");if(!r)return console.error("\u274C [DontChurn] Could not find step container for pause action"),null;let o=r.getAttribute("data-hashed-id");return o||(console.error("\u274C [DontChurn] Hashed ID not found in step container"),null)}catch(r){return console.error("\u274C [DontChurn] Error reading new price ID:",r),m(t,e,r),null}},xr=t=>{try{let e=t.closest(".dc-step");if(!e)return console.error("\u274C [DontChurn] Could not find current step"),null;let n=e.querySelector('input[type="radio"]:checked');if(!n)return console.warn("\u26A0\uFE0F [DontChurn] No survey option selected. This is not fatal and will not abort the flow."),null;let r=n.value,o=null;if(n.hasAttribute("data-show-textarea")){let a=e.querySelector(".dc-survey-textarea");if(!a)return console.error("\u274C [DontChurn] Could not find textarea for survey choice"),null;o=a.value.trim(),console.log("[TEST] [DontChurn] Found survey text:",o)}return{surveyChoice:r,surveyText:o}}catch(e){return console.error("\u274C [DontChurn] Error reading survey choice:",e),null}};var nt=async(t,e,n,r)=>{try{let{apiLocation:o}=t,s=`${Q[o]}/dontchurn.css`,i=await fetch(s);if(!i.ok)throw Error(`Failed to fetch CSS: ${i.status}`);let c=await i.text(),u=`'${n}', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif`,l=`'${e}', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif`;c=c.replace(/--dc-font-family:[\s\S]*?;/,`--dc-font-family: ${u};`),c=c.replace(/--dc-header-font-family:[\s\S]*?;/,`--dc-header-font-family: ${l};`);let d=Er(r),p=d?`${d.r}, ${d.g}, ${d.b}`:"120, 78, 255";return c=c.replace(/--dc-color-primary: #[0-9a-fA-F]{6};/,`--dc-color-primary: ${r};`),c=c.replace(/--dc-color-primary-rgb: [0-9, ]+;/,`--dc-color-primary-rgb: ${p};`),c}catch(o){return console.error("\u274C [DontChurn] Error loading CSS:",o),null}},Er=t=>{let e=t.startsWith("#")?t.slice(1):t,n=parseInt(e,16);if(isNaN(n))return null;let r=n>>16&255,o=n>>8&255,a=n&255;return{r,g:o,b:a}},ot=(t,e)=>{if(document.getElementById("dontchurn-font-preloader"))return;let n=document.createElement("div");n.id="dontchurn-font-preloader",n.style.fontFamily=`'${e}', '${t}', sans-serif`,n.style.position="absolute",n.style.visibility="hidden",n.style.width="0",n.style.height="0",n.style.overflow="hidden",n.textContent="Font Preloader";let r=encodeURIComponent(e),o=encodeURIComponent(t),a=`link[href*="fonts.googleapis.com/css2?family=${r}"]`,s=`link[href*="fonts.googleapis.com/css2?family=${o}"]`;if(!document.querySelector(a)){let i=document.createElement("link");i.rel="stylesheet",i.href=`https://fonts.googleapis.com/css2?family=${r}:wght@400;500;600;700&display=swap`,document.head.appendChild(i)}if(t!==e&&!document.querySelector(s)){let i=document.createElement("link");i.rel="stylesheet",i.href=`https://fonts.googleapis.com/css2?family=${o}:wght@400;500;600;700&display=swap`,document.head.appendChild(i)}document.body.appendChild(n)};var X=t=>t.style.display="flex",W=async(t,e,n)=>{try{let{handleClose:r,outcome:o}=n;e.parentNode?e.parentNode.removeChild(e):document.body.removeChild(e),await ie(t,n,o)?console.log("\u2705 [DontChurn] Flow run aborted successfully"):console.warn("\u26A0\uFE0F [DontChurn] Warning: could not abort flow run. This is not fatal."),r&&(console.log("[TEST] [closeModal] Calling handleClose with data:",{...n.userInput,outcome:o}),r({...n.userInput,outcome:o??void 0}))}catch(r){console.error("\u274C [DontChurn] Error closing modal:",r)}},V=async(t,e,n,r,o,a)=>{try{ot(n,r);let s=await nt(e,n,r,o);if(!s)return null;let i=await Pr(t,s,e);if(!i)return null;let{overlay:c,root:u}=i,l=Tr(u,e);return l===null||!rt(c,u,l,e)||!Ze(u,e,a)||!await E(u,"0",null,l,"data-step",e)?null:c}catch(s){return console.error("\u274C [DontChurn] Error creating modal element:",s),null}},Tr=(t,e)=>{try{if(t.querySelector(".dc-unpause-step"))return 0;let r=t.querySelector(".dc-cancellation-confirmation-step");if(!r)return console.error("\u274C [DontChurn] Could not find last step order"),null;let o=r.getAttribute("data-step");return o?parseInt(o):(console.error("\u274C [DontChurn] Last step order is missing"),null)}catch(n){return console.error("\u274C [DontChurn] Error getting last step order:",n),m(t,e,n),null}},Pr=async(t,e,n)=>{try{let r=document.createElement("div");r.id="dc-modal-container";let o=r.attachShadow({mode:"open"}),a=document.createElement("style");a.textContent=e,o.appendChild(a);let s=document.createElement("div");s.id="dc-modal",s.className="dc-modal",s.style.display="flex";let i=document.createElement("div");i.className="dc-dialog";let c=document.createElement("button");c.className="dc-close",c.setAttribute("aria-label","Close"),c.innerHTML=`
      <svg xmlns="http://www.w3.org/2000/svg" width="24" height="25" viewBox="0 0 24 25" fill="currentColor">
        <path d="M6.4 19.5L5 18.1L10.6 12.5L5 6.9L6.4 5.5L12 11.1L17.6 5.5L19 6.9L13.4 12.5L19 18.1L17.6 19.5L12 13.9L6.4 19.5Z" />
      </svg>
    `,i.appendChild(c);let u=document.createElement("div");u.className="dc-progress-bar";let l=document.createElement("div");return l.className="dc-progress-fill",l.style.width="0%",u.appendChild(l),i.appendChild(u),i.insertAdjacentHTML("beforeend",t),s.appendChild(i),o.appendChild(s),c.addEventListener("click",async()=>await W(o,r,n)),s.addEventListener("click",async d=>{d.target===s&&await W(o,r,n)}),i.addEventListener("click",d=>d.stopPropagation()),{overlay:r,root:o}}catch(r){return console.error("\u274C [DontChurn] Error setting up core modal elements:",r),null}};var Lr=async t=>{try{let e=j();if(!e)return;let{appId:n}=e;if(!n)return y("appId is missing");if(!t)return y("options are missing");let{subscriptionId:r,hash:o,flowId:a,handleContact:s,handleError:i,handleClose:c,apiLocation:u}=t;if(!r)return y("subscriptionId is missing");if(!o)return y("hash is missing");if(u&&!["prod","dev","localhost"].includes(u))return y('apiLocation is invalid. Use "prod", "dev" or "localhost". Got:',u);let l={appId:n,subscriptionId:r,hash:o,flowId:a,apiLocation:u??"prod",isPreview:!1,userInput:{},outcome:null,handleContact:s,handleError:i,handleClose:c},d=await G(l);if(!d)return y("Failed to fetch modal content");let{html:p,headerFont:b,paragraphFont:T,primaryColor:g,language:k}=d,B=await V(p,l,b,T,g,k);if(!B)return y("Failed to create modal element");document.body.appendChild(B),X(B)}catch(e){y("An error occurred while starting the cancellation process:",e)}},kr=async t=>{let e=j();if(!e)return;let{appId:n}=e;if(!n)return y("appId is missing");if(!t)return y("options are missing");let{previewFlowId:r,apiLocation:o,handleContact:a,handleError:s,handleClose:i}=t;if(!r)return y("previewFlowId is missing");if(o&&!["prod","dev","localhost"].includes(o))return y('apiLocation is invalid. Use "prod", "staging" or "dev". Got:',o);let c={appId:n,subscriptionId:"",hash:"",apiLocation:o??"prod",isPreview:!0,userInput:{},outcome:null,handleContact:a,handleError:s,handleClose:i},u=await z(c,r);if(!u)return y("Failed to fetch modal content");let{html:l,headerFont:d,paragraphFont:p,primaryColor:b,language:T}=u,g=await V(l,c,d,p,b,T);if(!g)return y("Failed to create modal element");document.body.appendChild(g),X(g)};window.dontchurn||(window.dontchurn={});window.dontchurn.start=Lr;window.dontchurn.startPreview=kr;})();
