import{f as e}from"./p-a7fc1e02.js";import{d as i,J as a,B as s,H as l,Q as d,R as r,I as o}from"./p-d0993bb9.js";const n=i.gql`
  query getCodes(
    $engagementMedium: UserEngagementMedium!
    $limit: Int!
    $offset: Int!
    $filter: ReferralCodeFilterInput
  ) {
    viewer {
      ... on User {
        referralCodeList(limit: $limit, offset: $offset, filter: $filter) {
          data {
            code
            dateUsed
            dateCopied
            singleUse
            shareLinkCodes(limit: $limit) {
              data {
                linkCode
                shareLink: shortUrl(
                  shareMedium: DIRECT
                  engagementMedium: EMBED
                )
                email: shortUrl(
                  shareMedium: EMAIL
                  engagementMedium: $engagementMedium
                )
                whatsApp: shortUrl(
                  shareMedium: WHATSAPP
                  engagementMedium: $engagementMedium
                )
                fbMessenger: shortUrl(
                  shareMedium: FBMESSENGER
                  engagementMedium: $engagementMedium
                )
              }
            }
          }
          count
          totalCount
        }
      }
    }
  }
`,t="sq:referral-codes",m="sq:referral-codes-pagination",u=i.gql`
  mutation markReferralCodeCopied($referralCode: String!) {
    markReferralCodeCopied(referralCode: $referralCode) {
      referralCode {
        dateCopied
      }
    }
  }
`;function v(i){const t=a(),m=s(),u=i.programId||l(),{refresh:v}=d(),{envelope:f,states:g,callbacks:p}=r(n,(e=>{var i;return null===(i=null==e?void 0:e.viewer)||void 0===i?void 0:i.referralCodeList}),{limit:1,offset:0},{engagementMedium:m,programId:u,filter:{fuelTank_eq:!0,programId_eq:u,dateUsed_exists:!1}},!(null==t?void 0:t.jwt)),[C,c]=o({namespace:"sq:referral-codes-pagination",initialValue:{states:g,callbacks:p}}),[h,k]=o({namespace:"sq:referral-codes",initialValue:{refresh:v,loading:!0,referralCode:"",shareLink:"",isCopied:!1,isUsed:!1,singleUse:!1,email:{messageLink:""},fbmessenger:{messageLink:"",shareLink:""},whatsapp:{messageLink:""}}});return e((()=>{var e,i,a,s,l,d,r,o,n,t,m,u,C,h,M,L;if(null===(e=null==f?void 0:f.data)||void 0===e?void 0:e.length){const e=f.data[0];k({refresh:v,referralCode:e.code,isCopied:!!e.dateCopied,isUsed:!!e.dateUsed,singleUse:!!e.singleUse,shareLink:null===(s=null===(a=null===(i=e.shareLinkCodes)||void 0===i?void 0:i.data)||void 0===a?void 0:a[0])||void 0===s?void 0:s.direct,email:{messageLink:null===(r=null===(d=null===(l=e.shareLinkCodes)||void 0===l?void 0:l.data)||void 0===d?void 0:d[0])||void 0===r?void 0:r.email},fbmessenger:{messageLink:null===(t=null===(n=null===(o=e.shareLinkCodes)||void 0===o?void 0:o.data)||void 0===n?void 0:n[0])||void 0===t?void 0:t.fbMessenger,shareLink:null===(C=null===(u=null===(m=e.shareLinkCodes)||void 0===m?void 0:m.data)||void 0===u?void 0:u[0])||void 0===C?void 0:C.fbMessenger},whatsapp:{messageLink:null===(L=null===(M=null===(h=e.shareLinkCodes)||void 0===h?void 0:h.data)||void 0===M?void 0:M[0])||void 0===L?void 0:L.whatsApp}}),c({states:g,callbacks:p})}}),[f]),{states:{...g,noCodes:0===(null==f?void 0:f.totalCount)},data:h,callbacks:{}}}export{m as R,u as S,t as a,v as u}