import{h as t,F as e,r as a}from"./p-083180bf.js";import{i as n}from"./p-f8a09b0f.js";import{n as o,k as s}from"./p-a7fc1e02.js";import{F as r,i,d as l,H as c,J as d,B as u,w as p,$ as m}from"./p-d0993bb9.js";import{c as g}from"./p-c1086930.js";import{g as f}from"./p-9ec99ced.js";import{c as h}from"./p-cef45012.js";import{R as v,a as x,S as b,u as y}from"./p-bab4929e.js";import"./p-49b20dae.js";import{C}from"./p-d276468c.js";const T=h({Container:{display:"flex",justifyContent:"flex-end",alignItems:"center",gap:"var(--sl-spacing-small)",width:"100%"},TextContainer:{display:"flex",gap:"var(--sl-spacing-xx-small)"}}),P=T.toString();function j(a){const{states:n,callbacks:o,text:s,buttonType:r}=a,{onNext:i,onPrev:l}=o,{currentPage:c,totalPages:d,loading:u}=n;return 1===d?t(e,null):t("span",{class:T.classes.Container,part:"sqm-base"},t("style",{type:"text/css"},P),!u&&t(e,null,t("sl-button",{exportparts:`base: ${r}button-base`,onClick:l,part:"sqm-pagination-button",circle:!0,disabled:1===c},t("sl-icon",{name:"chevron-left",label:"Previous Page"})),t("div",{class:T.classes.TextContainer},s.paginationText)),t("sl-button",{exportparts:`base: ${r}button-base`,onClick:i,part:"sqm-pagination-button",circle:!0,disabled:c===d},t("sl-icon",{name:"chevron-right",label:"Previous Page"})))}const k=class{constructor(t){a(this,t),this.ignored=!0,this.paginationText="{currentPage} of {totalPages}",this.buttonType="secondary",o(this)}disconnectedCallback(){}render(){const e=i()?function(t){const[e,a]=s(1);return g({states:{currentPage:e,totalPages:5,loading:!1},buttonType:t.buttonType,callbacks:{onNext:()=>a(e+1),onPrev:()=>a(e-1)},text:{paginationText:n.formatMessage({id:"paginationText",defaultMessage:t.paginationText||"{currentPage} of {totalPages}"},{currentPage:e,totalPages:5})}},t.demoData||{},{arrayMerge:(t,e)=>e})}(f(this)):function(t){var e;const a=r(v),o=a.states.currentPage+1,s=null===(e=a.states)||void 0===e?void 0:e.pageCount;return{states:{currentPage:o,totalPages:s,loading:a.states.loading},callbacks:{onNext:()=>{var t,e;return null===(t=a.callbacks)||void 0===t?void 0:t.setCurrentPage((null===(e=a.states)||void 0===e?void 0:e.currentPage)+1)},onPrev:()=>{var t,e;return null===(t=a.callbacks)||void 0===t?void 0:t.setCurrentPage((null===(e=a.states)||void 0===e?void 0:e.currentPage)-1)}},text:{paginationText:n.formatMessage({id:"paginationText",defaultMessage:t.paginationText},{currentPage:o,totalPages:s})}}}(f(this));return t(j,Object.assign({},e))}},E=l.gql`
  query getReferralCode($programId: ID) {
    user: viewer {
      ... on User {
        referralCode(programId: $programId)
      }
    }
  }
`,I=l.gql`
  mutation loadEvent($eventMeta: UserAnalyticsEvent!) {
    createUserAnalyticsEvent(eventMeta: $eventMeta)
  }
`,w=class{constructor(t){a(this,t),this.tooltiptext="Copied to Clipboard",this.showNotificationText=!1,this.notificationText="You've copied this code before",this.tooltiplifespan=1e3,this.textAlign="left",this.copyButtonLabel="Copy Code",this.buttonStyle="icon",this.buttonType="primary",o(this)}disconnectedCallback(){}render(){const e=f(this),a=i()?function(t){const[e,a]=s(!1),n="REFERRALCODE001";return g({copyString:n,tooltiptext:t.tooltiptext,textAlign:t.textAlign,copyButtonLabel:t.copyButtonLabel,buttonStyle:t.buttonStyle,notificationText:t.notificationText,showNotificationText:t.showNotificationText,isCopied:t.showNotificationText,borderColor:t.borderColor,backgroundColor:t.backgroundColor,textColor:t.textColor,borderRadius:t.borderRadius,buttonType:t.buttonType,isUsed:!1,rewardStatus:"AVAILABLE",open:e,onClick:()=>{navigator.clipboard.writeText(n),a(!0),setTimeout((()=>a(!1)),t.tooltiplifespan)}},t.demoData||{},{arrayMerge:(t,e)=>e})}(e):function(t){var e,a;const{programId:n=c()}=t,o=d(),i=u(),l=r(x),{data:g}=p(E,{programId:n},!(null==o?void 0:o.jwt)||void 0!==(null==l?void 0:l.referralCode)),[f]=m(I),[h]=m(b),v=null!==(a=(null==l?void 0:l.referralCode)||(null===(e=null==g?void 0:g.user)||void 0===e?void 0:e.referralCode))&&void 0!==a?a:"...",[y,C]=s(!1);return{...t,onClick:async function(){l&&(await h({referralCode:l.referralCode}),l.refresh()),navigator.clipboard.writeText(v),C(!0),setTimeout((()=>C(!1)),t.tooltiplifespan),f({eventMeta:{programId:n,id:null==o?void 0:o.id,accountId:null==o?void 0:o.accountId,type:"USER_REFERRAL_PROGRAM_ENGAGEMENT_EVENT",meta:{engagementMedium:i,shareMedium:"DIRECT"}}})},open:y,copyString:v,isCopied:null==l?void 0:l.isCopied,showNotificationText:t.showNotificationText&&!!(null==l?void 0:l.singleUse)}}(e);return t(C,Object.assign({},a))}};function q(e){const{slots:a,titleText:n,states:o,textColor:s="var(--sqm-text-subdued)"}=e,r=h({Wrapper:{width:"100%",display:"flex",alignItems:"flex-start",justifyContent:"center",flexDirection:"column",gap:"var(--sl-spacing-large)",color:s},HeaderContainer:{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%"},ShareCodeContainer:{width:"100%",display:"flex",alignItems:"flex-start",justifyContent:"center",flexDirection:"column"},ShareButtonContainer:{width:"100%",display:"flex",alignItems:"flex-start",justifyContent:"center",flexDirection:"column"},TitleText:{fontSize:"var(--sl-font-size-large)",margin:"0"}}),i=r.toString();return t("div",{class:r.classes.Wrapper,part:"sqm-base"},t("style",{type:"text/css"},"\n    :host {\n      display: block;\n    }\n    :host([hidden]): {\n      display: none;\n    }\n  ",i),t("div",{class:r.classes.HeaderContainer},t("h2",{class:r.classes.TitleText},n),!o.noCodes&&!o.loading&&a.pagination),(e=>e.noCodes?a.empty:e.loading?a.loading:t("div",{class:r.classes.Wrapper},t("div",{class:r.classes.ShareCodeContainer},a.shareCodes),t("div",{class:r.classes.ShareButtonContainer},a.shareButtons)))(o))}const M=class{constructor(t){a(this,t),this.titleText="Start sharing",this.emptyStateHeaderText="Your new codes and links aren’t ready yet",this.emptyStateDescriptionText="Please contact our program support team to let them know you’re out of codes.",this.emptyStateImageUrl="https://res.cloudinary.com/saasquatch/image/upload/v1644360953/squatch-assets/empty_leaderboard2.png",o(this)}disconnectedCallback(){}render(){const e=f(this),a=i()?function(t){return g({titleText:t.titleText,textColor:t.textColor,states:{noCodes:!1,loading:!1}},t.demoData||{},{arrayMerge:(t,e)=>e})}(e):y(e),n={slots:{shareButtons:t("slot",{name:"shareButtons"}),shareCodes:t("slot",{name:"shareCodes"}),pagination:t("slot",{name:"pagination"}),empty:t(R,{headerText:this.emptyStateHeaderText,descriptionText:this.emptyStateDescriptionText,imageUrl:this.emptyStateImageUrl}),loading:t(S,null)},...a,loading:a.states.loading,noCodes:a.states.noCodes};return t(q,Object.assign({},n))}};function R({headerText:e,descriptionText:a,imageUrl:n}){return t("slot",{name:"empty"},t("sqm-empty",{emptyStateHeader:e,emptyStateText:a,emptyStateImage:n}))}function S(){return t("slot",{name:"loading"},t(A,null),t(A,null),t(A,null),t(A,null))}function A(){return t("sqm-skeleton",null)}export{k as sqm_pagination,w as sqm_referral_code,M as sqm_referral_codes}