1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[46550],{69723:function(e,t,n){(window.__NEXT_P=window.__NEXT_P||[]).push(["/admin/sponsor/tierConfiguration",function(){return n(85092)}])},29093:function(e,t,n){"use strict";var i=n(9669),r=n.n(i),s=n(65885);let a=new s.Z,o=r().create({baseURL:"https://backend-v2.tradewing.com",timeout:3e4});o.interceptors.request.use(e=>{e.headers["x-api-key"]="aHR0cHM6Ly93d3cueW91dHViZS5jb20vd2F0Y2g/dj1kUXc0dzlXZ1hjUQ",e.headers["x-user-id"]="hardik";let t=a.get("accounts%3AaccessToken"),n=a.get("accounts%3ArefreshToken");return t&&(e.headers.Authorization="Bearer ".concat(t)),n&&(e.headers["x-refresh-token"]=n),e},e=>Promise.reject(e)),o.interceptors.response.use(e=>e,e=>{var t;return null===(t=e.response)||void 0===t||t.status,Promise.reject(e)}),t.Z=o},5209:function(e,t,n){"use strict";n.d(t,{BK:function(){return editAccountClass},XC:function(){return createAccountClass},YO:function(){return updateAccountClassStatus},eC:function(){return fetchAccountClass},xG:function(){return bulkCreateAccountClass}});var i=n(29093);async function fetchAccountClass(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{tenantId:t,search:n,limit:r,offset:s,status:a}=e,o=await i.Z.get("/api/v1/financial-settings/account-classes",{headers:{"x-tenant-id":t},params:{search:n,sort:"asc",limit:r,offset:s,status:a}});return o.data}async function createAccountClass(e,t){let n=await i.Z.post("/api/v1/financial-settings/account-classes",t,{headers:{"x-tenant-id":e}});return n.data}async function editAccountClass(e,t,n){let r=await i.Z.patch("/api/v1/financial-settings/account-classes/".concat(e),n,{headers:{"x-tenant-id":t}});return r.data}async function updateAccountClassStatus(e,t,n,r){let s=await i.Z.patch("/api/v1/financial-settings/account-classes/updateStatus/".concat(e),{status:n,updatedByUserId:r},{headers:{"x-tenant-id":t}});return s.data}async function bulkCreateAccountClass(e,t){let n=await i.Z.post("/api/v1/financial-settings/account-classes/bulkCreate",t,{headers:{"x-tenant-id":e}});return n.data}},67126:function(e,t,n){"use strict";n.d(t,{CO:function(){return fetchChartOfAccounts},Kx:function(){return editChartOfAccount},Ym:function(){return bulkCreateChartOfAccount},ZM:function(){return updateCOAStatus},jk:function(){return createChartOfAccount}});var i=n(29093);async function fetchChartOfAccounts(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{tenantId:t,search:n,limit:r,offset:s,status:a}=e,o=await i.Z.get("/api/v1/financial-settings/chart-of-account",{headers:{"x-tenant-id":t},params:{search:n,sort:"asc",limit:r,offset:s,status:a}});return o.data}async function createChartOfAccount(e,t){let n=await i.Z.post("/api/v1/financial-settings/chart-of-account",t,{headers:{"x-tenant-id":e}});return n.data}async function editChartOfAccount(e,t,n){let r=await i.Z.patch("/api/v1/financial-settings/chart-of-account/".concat(e),n,{headers:{"x-tenant-id":t}});return r.data}async function updateCOAStatus(e,t,n,r){let s=await i.Z.patch("/api/v1/financial-settings/chart-of-account/updateStatus/".concat(e),{status:n,updatedByUserId:r},{headers:{"x-tenant-id":t}});return s.data}async function bulkCreateChartOfAccount(e,t){let n=await i.Z.post("/api/v1/financial-settings/chart-of-account/bulkCreate",t,{headers:{"x-tenant-id":e}});return n.data}},29173:function(e,t,n){"use strict";n.d(t,{Hr:function(){return reorderSponsorTiers},J2:function(){return fetchSponsorTiersByName},Uq:function(){return fetchSponsorTierNameByIds},V9:function(){return fetchActiveBenefitCatalogsByTenant},al:function(){return updateBenefitCatalogVisibility},bZ:function(){return updateSponsorTierVisibility},fF:function(){return createSponsorTier},iE:function(){return fetchSponsorTiers},ik:function(){return fetchBenefitCatalogs},qs:function(){return updateSponsorTier}});var i=n(29093);async function fetchSponsorTiers(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{tenantId:t,search:n,limit:r,offset:s,userId:a}=e,o=await i.Z.get("/api/v1/sponsor/sponsor-tiers",{headers:{"x-tenant-id":t,...a?{"x-user-id":a}:{}},params:{search:n,sort:"asc",limit:r,offset:s}});return o.data}async function fetchSponsorTiersByName(e){let{tenantId:t,name:n}=e,r=await i.Z.get("/api/v1/sponsor/sponsor-tiers-by-name",{headers:{"x-tenant-id":t},params:{names:n}});return r.data}async function fetchSponsorTierNameByIds(e){let{tenantId:t,ids:n}=e,r=await i.Z.get("/api/v1/sponsor/sponsor-tiers-by-ids",{headers:{"x-tenant-id":t},params:{ids:n}});return r.data}async function fetchBenefitCatalogs(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{tenantId:t,search:n,userId:r}=e,s=await i.Z.get("/api/v1/sponsor/benefit-catelog-by-tenant",{headers:{"x-tenant-id":t,...r?{"x-user-id":r}:{}},params:{search:n}});return s.data}async function fetchActiveBenefitCatalogsByTenant(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{tenantId:t,userId:n}=e,r=await i.Z.get("/api/v1/sponsor/active-benefit-catelog-by-tenant",{headers:{"x-tenant-id":t,...n?{"x-user-id":n}:{}}});return r.data}async function updateSponsorTierVisibility(e){let t=await i.Z.put("/api/v1/sponsor/update-tier-visibility",{id:e.id,visibility:e.visibility},{headers:{"x-tenant-id":e.tenantId,...e.userId?{"x-user-id":e.userId}:{}}});return t.data}async function updateBenefitCatalogVisibility(e){let t=await i.Z.put("/api/v1/sponsor/update-benefit-catalog-visibility",{id:e.id,visibility:e.visibility},{headers:{"x-tenant-id":e.tenantId,...e.userId?{"x-user-id":e.userId}:{}}});return t.data}async function createSponsorTier(e){let t=await i.Z.post("/api/v1/sponsor/create",{...e},{headers:{"x-tenant-id":e.tenantId,...e.userId?{"x-user-id":e.userId}:{}}});return t.data}async function updateSponsorTier(e){let t=await i.Z.put("/api/v1/sponsor/update",{...e},{headers:{"x-tenant-id":e.tenantId,...e.userId?{"x-user-id":e.userId}:{}}});return t.data}async function reorderSponsorTiers(e){let t=await i.Z.post("/api/v1/sponsor/reorder-sponsor-tiers",e.tiers,{headers:{"x-tenant-id":e.tenantId,...e.userId?{"x-user-id":e.userId}:{}}});return t.data}},85200:function(e,t,n){"use strict";n.d(t,{DY:function(){return AdminPage},hb:function(){return a},lm:function(){return AdminPageHeading},yG:function(){return AdminPageHeader}});var i=n(85893),r=n(48641),s=n(38655);n(67294);let AdminPage=e=>{let{children:t,...n}=e;return(0,i.jsx)(r.xu,{...n,children:t})},AdminPageHeader=e=>{let{children:t,...n}=e;return(0,i.jsx)(r.Kq,{direction:"row",spacing:"4",alignItems:"flex-start",...n,children:t})},AdminPageHeading=e=>{let{children:t,...n}=e;return(0,i.jsx)(r.X6,{size:"md",...n,children:t})},a=(0,s.Gp)((e,t)=>{let{children:n,...s}=e;return(0,i.jsx)(r.xu,{marginY:"5",...s,ref:t,children:n})})},32156:function(e,t,n){"use strict";n.d(t,{LH:function(){return h},i_:function(){return CurrencyDisplay},mA:function(){return currencyDisplay}});var i=n(85893),r=n(48641),s=n(20979),a=n(50371),o=n(2487),l=n(79747),d=n(99829),c=n(67294),u=n(42956);let dineroFromFloat=e=>{let{amount:t,currency:n,scale:i}=e;return(0,a.h)({amount:Math.round(t*(n.base**n.exponent||i)),currency:n,scale:i})},currencyDisplay=(e,t)=>(0,o.h)(e,e=>{let{amount:n,currency:i}=e;return new Intl.NumberFormat(void 0,{style:"currency",currency:i.co
1de,...t}).format(n)}),CurrencyDisplay=e=>{let{value:t,options:n,newView:s=!1,...a}=e;return(0,i.jsx)(r.xv,{fontSize:s?"12px":"13px",as:"span",...a,color:"textPrimary.500",children:currencyDisplay(t,n)})},h=c.forwardRef((e,t)=>{let{value:n,onChange:r=()=>{},...a}=e,{currency:o}=(0,u.Z)(),[h,x]=c.useState(n?(0,l.n)(n).toFixed(2):""),m=dineroFromFloat({amount:Number(h),currency:o,scale:2});return c.useEffect(()=>{n||x("")},[n]),c.useEffect(()=>{n&&!(0,d.D)(m,n)&&x((0,l.n)(n).toFixed(2))},[m,n]),(0,i.jsxs)(s.BZ,{children:[(0,i.jsx)(s.Ui,{children:function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"en-US";return 0..toLocaleString(t,{style:"currency",currency:e,minimumFractionDigits:0,maximumFractionDigits:0}).replace(/\d/g,"").trim()}(o.code)}),(0,i.jsx)(s.II,{ref:t,...a,value:h,type:"number",onWheel:e=>e.currentTarget.blur(),onChange:e=>{let t=dineroFromFloat({amount:Number(e.target.value),currency:o,scale:2});r(t),x(e.target.value)}})]})});h.displayName="CurrencyInput"},76837:function(e,t,n){"use strict";n.d(t,{LH:function(){return i.LH},i_:function(){return i.i_},mA:function(){return i.mA}});var i=n(32156)},39174:function(e,t,n){"use strict";n.d(t,{A:function(){return NoMatchPage}});var i=n(85893),r=n(48641),s=n(23887),a=n(47741),o=n(11163);n(67294);let NoMatchPage=()=>{let e=(0,o.useRouter)();return(0,i.jsxs)(r.gC,{p:"12",spacing:"4",textAlign:"center",children:[(0,i.jsx)(s.Ee,{src:"https://tradewing-public.s3.us-east-2.amazonaws.com/tradewing-logo.png",alt:"Tradewing",width:"50px",height:"50px"}),(0,i.jsx)(r.xv,{textStyle:"xlBodyStrong",children:"Page Not Found"}),(0,i.jsx)(r.xv,{children:"Please check that you have the correct URL and try again. If you need help finding and accessing your community, please contact [email protected]."}),(0,i.jsx)(a.zx,{onClick:()=>e.push("/"),children:"Return to Site"})]})}},13086:function(e,t,n){"use strict";n.d(t,{j:function(){return ReorderingIcon}});var i=n(85893),r=n(48641);let ReorderingIcon=()=>(0,i.jsxs)(r.Kq,{spacing:"1",children:[(0,i.jsxs)(r.Kq,{direction:"row",spacing:"1",children:[(0,i.jsx)(r.Cd,{size:"2px",bg:"gray.500"}),(0,i.jsx)(r.Cd,{size:"2px",bg:"gray.500"})]}),(0,i.jsxs)(r.Kq,{direction:"row",spacing:"1",children:[(0,i.jsx)(r.Cd,{size:"2px",bg:"gray.500"}),(0,i.jsx)(r.Cd,{size:"2px",bg:"gray.500"})]}),(0,i.jsxs)(r.Kq,{direction:"row",spacing:"1",children:[(0,i.jsx)(r.Cd,{size:"2px",bg:"gray.500"}),(0,i.jsx)(r.Cd,{size:"2px",bg:"gray.500"})]})]})},82475:function(e,t,n){"use strict";n.d(t,{U:function(){return d}});var i=n(85893),r=n(83234),s=n(47741),a=n(38655),o=n(67294),l=n(6491);let d=o.forwardRef((e,t)=>{let{children:n,...o}=e,d=(0,r.NJ)(),c=(null==d?void 0:d.isDisabled)||o.isDisabled;return(0,i.jsx)(s.zx,{variant:"outline",colorScheme:"gray",backgroundColor:"white",fontWeight:"normal",rightIcon:(0,i.jsx)(l.v4q,{}),justifyContent:"space-between",borderColor:(null==d?void 0:d.isInvalid)?"red.500":void 0,border:(null==d?void 0:d.isInvalid)?"2px":void 0,_hover:{backgroundColor:"white"},w:"full",isDisabled:c,_expanded:{bg:"gray.200"},...o,ref:t,whiteSpace:"normal",textAlign:"left",children:(0,i.jsx)(a.m$.span,{noOfLines:1,wordBreak:"break-all",flex:"1",children:n})})});d.displayName="SelectMenuButton"},32683:function(e,t,n){"use strict";n.d(t,{MH:function(){return TableNone},Uc:function(){return l},fQ:function(){return TableEmpty}});var i=n(85893),r=n(48641),s=n(36696),a=n(36158),o=n(67294);let TableNone=e=>{let{children:t,...n}=e;return(0,i.jsx)(r.M5,{p:"10",h:"xs",...n,children:(0,i.jsx)(r.xu,{children:t})})},l=(0,o.memo)(e=>{let{columns:t,rows:n=5}=e;return(0,i.jsx)(s.p3,{children:[...Array(n)].map((e,n)=>(0,i.jsx)(s.Tr,{children:[...Array(t)].map((e,t)=>(0,i.jsx)(s.Td,{children:(0,i.jsx)(a.Od,{h:"4",borderRadius:"lg"})},t))},n))})});l.displayName="TableLoading";let TableEmpty=e=>(0,i.jsx)(s.p3,{children:(0,i.jsx)(s.Tr,{children:(0,i.jsx)(s.Td,{colSpan:100,children:(0,i.jsx)(TableNone,{children:e.children})})})})},91143:function(e,t,n){"use strict";n.d(t,{c:function(){return s}});var i=n(82729),r=n(50456);function _templateObject(){let e=(0,i._)(["\n fragment RawDraftContentStateFragment on DraftJS_ContentState {\n blocks {\n key\n text\n type\n depth\n inlineStyleRanges {\n offset\n length\n style\n __typename\n }\n entityRanges {\n offset\n length\n key\n __typename\n }\n }\n entityMap {\n type\n mutability\n data {\n ... on DraftJS_ContentState_Entity_Data_LinkData {\n explicit\n url\n targetOption\n hideLinkPreview\n __typename\n }\n ... on DraftJS_ContentState_Entity_Data_MentionData {\n mention {\n userId\n user {\n displayName\n __typename\n }\n userCanView\n __typename\n }\n __typename\n }\n ... on DraftJS_ContentState_Entity_Data_ImageData {\n src\n alt\n height\n width\n alignment\n __typename\n }\n __typename\n }\n __typename\n }\n __typename\n }\n"]);
1return _templateObject=function(){return e},e}let s=(0,r.Ps)(_templateObject())},5146:function(e,t,n){"use strict";var i=n(9669),r=n.n(i),s=n(67294);t.Z=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,[n,i]=(0,s.useState)(null),[a,o]=(0,s.useState)(!1),[l,d]=(0,s.useState)(null),c=(0,s.useCallback)(async function(){let n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:t;o(!0),d(null);try{let t=r().CancelToken.source(),s=await e(n,{cancelToken:t.token});return i(s),o(!1),s}catch(e){throw r().isCancel(e)?console.log("Request canceled",e.message):d(e),o(!1),e}},[e,t]);return{data:n,loading:a,error:l,execute:c}}},42956:function(e,t,n){"use strict";n.d(t,{Z:function(){return useDefaultCurrency}});var i=n(82729),r=n(50456),s=n(37887),a=n(25793),o=n(3723);function _templateObject(){let e=(0,i._)(["\n query useDefaultCurrency_Query {\n tenant {\n result {\n _id\n paymentDefaultCurrencyV2\n }\n }\n }\n"]);return _templateObject=function(){return e},e}let l=(0,r.Ps)(_templateObject()),useDefaultCurrency=()=>{var e,t;let n=(0,s.a)(l),i=null===(t=n.data)||void 0===t?void 0:null===(e=t.tenant.result)||void 0===e?void 0:e.paymentDefaultCurrencyV2;return{isLoading:n.loading,currency:i?(0,o.o)(i):a.q}}},12176:function(e,t,n){"use strict";n.d(t,{f:function(){return useHandleDragEndGeneric}});var i=n(67294);function useHandleDragEndGeneric(e){let{items:t,setItems:n,identifyKey:r,schemaKey:s,positionKey:a,systemLength:o,limit:l,offset:d,triggerReorder:c}=e;return(0,i.useCallback)(e=>{let i;if(!e.destination)return;let o=Array.from(t),[u]=o.splice(e.source.index,1);o.splice(e.destination.index,0,u);let h=Math.min(e.source.index,e.destination.index),x=Math.max(e.source.index,e.destination.index);if(o.slice(h,x+1).some(e=>null==e[a]))for(let e=h;e<=x;e++)o[e]={...o[e],[a]:e};else for(let e=0;e<o.length;e++)o[e]={...o[e],[a]:e+1+d*l};if(n([...o]),e.source.index!==e.destination.index){let e=[];for(let n=0;n<o.length;n++){var m,p;((null===(m=t[n])||void 0===m?void 0:m[r])!==o[n][r]||(null===(p=t[n])||void 0===p?void 0:p[a])!==o[n][a])&&e.push({[s]:o[n][r],[a]:o[n][a]})}i=e}else i=o.map(e=>({[s]:e[r],[a]:e[a]}));c(i)},[t,n,r,s,a,o,l,d,c])}},19598:function(e,t,n){"use strict";n.d(t,{Z:function(){return r}});var i=n(38655);let r=(0,i.m$)("div",{baseStyle:{borderRadius:"8px",backgroundColor:"white",shadow:"base"}})},52670:function(e,t,n){"use strict";n.d(t,{Z:function(){return i.Z}});var i=n(19598)},27588:function(e,t,n){"use strict";n.d(t,{Z:function(){return useEntityFetchByIds}});var i=n(82729),r=n(50456),s=n(73359),a=n(67294),o=n(91143);function _templateObject(){let e=(0,i._)(['\n query useEntityFetchByIds_query(\n $postIds: PostsByIdsInput!\n $userIds: UsersByIdsInput!\n $commentIds: CommentsByIdsInput!\n ) {\n usersByIds(input: $userIds) {\n results {\n displayName\n _id\n proxyProfilePictureUrl(\n input: { w: 140, h: 140, fit: "facearea", facepad: 10.0 }\n )\n }\n }\n postsByIds(input: $postIds) {\n results {\n _id\n group {\n _id\n }\n title\n bodyPlainText\n poll {\n _id\n title\n descriptionContentState {\n ...RawDraftContentStateFragment\n }\n }\n blog {\n _id\n title\n }\n question {\n _id\n title\n body\n }\n answer {\n _id\n body\n questionId\n }\n eventAlertId\n }\n }\n commentsByIds(input: $commentIds) {\n results {\n _id\n bodyPlainText\n post {\n _id\n group {\n _id\n }\n poll {\n _id\n }\n blog {\n _id\n }\n question {\n _id\n }\n answer {\n _id\n questionId\n }\n eventAlertId\n }\n }\n }\n }\n ',"\n"]);return _templateObject=function(){return e},e}
1let l=(0,r.Ps)(_templateObject(),o.c),d={posts:{},users:{},comments:{}};function useEntityFetchByIds(){let[e,t]=a.useState(d),[n,{data:i,loading:r}]=(0,s.t)(l);a.useEffect(()=>{if(!i)return;let e=i.postsByIds.results.filter(e=>!!e).reduce((e,t)=>({...e,[t._id]:t}),{}),n=i.usersByIds.results.filter(e=>!!e).reduce((e,t)=>({...e,[t._id]:t}),{}),r=i.commentsByIds.results.filter(e=>!!e).reduce((e,t)=>({...e,[t._id]:t}),{});t(t=>({posts:{...t.posts,...e},users:{...t.users,...n},comments:{...t.comments,...r}}))},[i]);let o=a.useCallback(t=>{let i=t.variables.userIds.userIds.filter(t=>!e.users[t]),r=t.variables.postIds.postIds.filter(t=>!e.posts[t]),s=t.variables.commentIds.commentIds.filter(t=>!e.comments[t]);(i.length>0||r.length>0||s.length>0)&&n({variables:{userIds:{userIds:i},postIds:{postIds:r},commentIds:{commentIds:s}}})},[e.comments,e.posts,e.users,n]),c=a.useCallback(()=>{t(d)},[]);return{entityIdsToEntities:e,fetchNewEntities:o,clearEntities:c,loading:r}}},85092:function(e,t,n){"use strict";n.r(t),n.d(t,{default:function(){return Q}});var i,r,s=n(85893),a=n(80419),o=n(90195),l=n(48641),d=n(18034),c=n(20979),u=n(47741),h=n(36696),x=n(68185),m=n(35610),p=n(97026),f=n(50371),v=n(79747),g=n(67294),y=n(15948),b=n(29173),j=n(85200),C=n(76837),S=n(13086),I=n(32683),_=n(47503),T=n(5146),w=n(45893),A=n(42956),E=n(12176),k=n(96317),B=n(52670),z=n(6491),P=n(27588);let O=_.Lo.Lite.toString(),L="Promotional Community Posts",D=new Set([O,_.Lo.Pro.toString(),_.Lo.Plus.toString(),_.Lo.Premium.toString()]);var N=n(2821),M=n(42588),R=n(83234),q=n(99052),Z=n(74373),F=n(82475);let CreateSponsorTierModal=e=>{let{isOpen:t,onClose:n,createTierStep:i,setCreateTierStep:r,isEditMode:a,isEditingLockedTier:o,baseTemplates:d,selectedTemplate:h,templateSelectionError:p,selectTemplate:f,tierName:v,tierNameError:y,handleTierNameChange:b,tierDescription:j,setTierDescription:S,tierVisibility:I,setTierVisibility:_,tierLocked:T,setTierLocked:w,tierPrice:A,handleTierPriceChange:E,activeBenefitCatalogsLoading:k,modalBenefits:B,benefitSelectionError:P,communityListeningEnabled:O,handleModalBenefitToggle:D,handleModalBenefitQuantityChange:U,enabledBenefits:W,accountClasses:H,selectedAccountClass:V,setSelectedAccountClass:Q,handleStep1Next:G,handleStep2Next:Y,handlePublishTier:K,handleLockedTierDismiss:X,isPublishLoading:$,isTemplateLocked:J,chartOfAccounts:ee,selectedChartOfAccounts:et,setselectedChartOfAccounts:en}=e,ei=g.useMemo(()=>{let e=H.filter(e=>"active"===e.status),t=H.find(e=>e.id===V);return t&&"inactive"===t.status&&e.push(t),e},[H,V]),er=g.useMemo(()=>{let e=ee.filter(e=>"active"===e.status),t=ee.find(e=>e.id===et);return t&&"inactive"===t.status&&e.push(t),e},[ee,et]),es=g.useMemo(()=>{let e=er.find(e=>e.id===et);return e?"".concat(e.code," - ").concat(e.description).concat("inactive"===e.status?" (Inactive)":""):"-- Select --"},[er,et]),ea=g.useMemo(()=>{let e=ei.find(e=>e.id===V);return e?"".concat(e.code," - ").concat(e.description).concat("inactive"===e.status?" (Inactive)":""):"-- Select --"},[ei,V]);return(0,s.jsxs)(N.u_,{isOpen:t,onClose:n,size:"5xl",scrollBehavior:"inside",closeOnOverlayClick:!1,closeOnEsc:!1,children:[(0,s.jsx)(N.ZA,{}),(0,s.jsxs)(N.hz,{children:[(0,s.jsx)(N.xB,{fontSize:"xl",fontWeight:"semibold",borderBottom:"1px solid",borderColor:"strokePrimary.500",children:a?"Edit Tier":"Create a New Tier"}),(0,s.jsx)(N.ol,{}),(0,s.jsxs)(N.fe,{pb:"6",pt:"4",children:[(0,s.jsx)(l.kC,{w:"full",align:"center",justify:"center",mb:"6",children:["Choose Template","Benefits","Review"].map((e,t)=>{let n=t===i,a=t<i;return(0,s.jsxs)(l.kC,{align:"center",flex:t<2?1:"none",children:[(0,s.jsx)(u.zx,{px:"4",py:"2",borderRadius:"full",fontSize:"sm",fontWeight:"medium",color:n||a?"white":"gray.600",bg:n||a?"blue.500":"transparent",border:"1px solid",borderColor:"blue.500",_hover:{bg:n||a?"blue.600":"blue.50"},onClick:()=>r(t),children:"".concat(t+1,". ").concat(e)}),t<2&&(0,s.jsx)(l.xu,{flex:"1",height:"2px",bg:a?"blue.500":"gray.300"})]},e)})}),0===i&&(0,s.jsxs)(l.xu,{w:"100%",display:{base:"block",md:"flex"},gap:"6",children:[(0,s.jsx)(l.xu,{border:"1px solid",borderColor:"strokePrimary.500",borderRadius:"lg",p:"6",mb:{base:"4",md:"0"},w:{base:"100%",md:"40%"},children:(0,s.jsxs)(l.xu,{w:"100%",children:[(0,s.jsx)(l.xv,{fontWeight:"semibold",color:"textPrimary.500",mb:"1",children:"Select Base Template"}),(0,s.jsx)(l.xv,{fontSize:"sm",color:"textSecondary.500",mb:"4",children:"Locked Templates cannot be changed they only seed your custom tier"}),p&&(0,s.jsx)(l.xv,{color:"red.500",fontSize:"sm",mt:"2",children:p}),(0,s.jsx)(M.Ee,{value:h,onChange:e=>{o||f(e)},children:(0,s.jsx)(l.gC,{align:"stretch",spacing:"3",children:d.map(e=>(0,s.jsx)(l.xu,{p:"4",border:"1px solid",borderColor:h===e.id?"primary.500":"strokePrimary.500",bg:h===e.id?"secondary.500":"white",borderRadius:"md",cursor:o?"not-allowed":"pointer",onClick:()=>{o||f(e.id)},_hover:{borderColor:"blue.300"},children:(0,s.jsxs)(l.Ug,{justify:"space-between",children:[(0,s.jsxs)(l.gC,{align:"start",spacing:"0",children:[(0,s.jsx)(l.xv,{fontWeight:"medium",children:e.name}),(0,s.jsx)(l.xv,{fontSize:"sm",color:"gray.500",children:e.description})]}),(0,s.jsx)(M.Y8,{value:e.id,colorScheme:"blue",isDisabled:o})]})},e.id))})})]})}),(0,s.jsx)(l.xu,{border:"1px solid",borderColor:"strokePrimary.500",borderRadius:"lg",p:"6",w:{base:"100%",md:"60%"},children:(0,s.jsxs)(l.xu,{children:[(0,s.jsxs)(l.Ug,{mb:"1",w:"100%",children:[(0,s.jsx)(l.xv,{fontWeight:"semibold",children:"Basics"}),J&&(0,s.jsx)(l.Ct,{colorScheme:"gray",fontSize:"xs",px:"2",py:"1",borderRadius:"full",children:(0,s.jsxs)(l.Ug,{spacing:"1",children:[(0,s.jsx)(z.mBM,{boxSize:"3"}),(0,s.jsx)(l.xv,{as:"span",size:"sm",children:"locked"})]})})]}),(0,s.jsx)(l.xv,{fontSize:"sm",color:"textSecondary.500",mb:"4",children:"Name, Description and Visibility"}),(0,s.jsxs)(l.gC,{spacing:"4",align:"stretch",children:[(0,s.jsxs)(R.NI,{isInvalid:!!y,children:[(0,s.jsx)(R.lX,{fontSize:"sm",children:"Tier Name"}
1),(0,s.jsx)(c.II,{value:v,onChange:e=>b(e.target.value),isDisabled:o,placeholder:"Enter tier name"}),(0,s.jsx)(R.J1,{children:y})]}),(0,s.jsxs)(R.NI,{children:[(0,s.jsx)(R.lX,{fontSize:"sm",children:"Description"}),(0,s.jsx)(c.II,{value:j,onChange:e=>S(e.target.value),isDisabled:o,placeholder:"Enter description"})]}),(0,s.jsx)(l.Ug,{justify:"space-between",children:(0,s.jsxs)(l.gC,{align:"start",spacing:"0",children:[(0,s.jsxs)(l.xv,{fontSize:"sm",fontWeight:"medium",children:["Visibility"," ",(0,s.jsx)(x.r,{isChecked:I,onChange:e=>_(e.target.checked),isDisabled:o,colorScheme:"blue",ml:"2"})]}),(0,s.jsx)(l.xv,{fontSize:"xs",color:"textSecondary.500",children:"Hidden tiers are not selectable by sponsors until you publish."})]})}),(0,s.jsx)(l.Ug,{justify:"space-between",children:(0,s.jsxs)(l.gC,{align:"start",spacing:"0",children:[(0,s.jsxs)(l.xv,{fontSize:"sm",fontWeight:"medium",children:["Lock Tier"," ",(0,s.jsx)(x.r,{isChecked:T,onChange:e=>w(e.target.checked),isDisabled:o,colorScheme:"blue",ml:"2"})]}),(0,s.jsx)(l.xv,{fontSize:"xs",color:"textSecondary.500",children:"Lock tiers are not editable"})]})}),(0,s.jsxs)(R.NI,{children:[(0,s.jsx)(R.lX,{fontSize:"sm",children:"Price"}),(0,s.jsx)(C.LH,{value:A,onChange:e=>E(e),placeholder:"0.00",isDisabled:o})]}),(0,s.jsxs)(R.NI,{children:[(0,s.jsx)(R.lX,{fontSize:"sm",children:"Chart Of Account"}),(0,s.jsxs)(q.v2,{matchWidth:!0,isLazy:!0,placement:"top-start",children:[(0,s.jsx)(q.j2,{as:F.U,isDisabled:o,size:"md",children:es}),(0,s.jsxs)(q.qy,{maxH:"min(320px, 40vh)",overflowY:"auto",zIndex:"popover",children:[(0,s.jsx)(q.sN,{onClick:()=>en(""),children:"-- Select --"}),er.map(e=>(0,s.jsxs)(q.sN,{onClick:()=>en(e.id),children:[e.code," - ",e.description,"inactive"===e.status?" (Inactive)":""]},e.id))]})]})]}),(0,s.jsxs)(R.NI,{children:[(0,s.jsx)(R.lX,{fontSize:"sm",children:"Account Class"}),(0,s.jsxs)(q.v2,{matchWidth:!0,isLazy:!0,placement:"top-start",children:[(0,s.jsx)(q.j2,{as:F.U,isDisabled:o,size:"md",children:ea}),(0,s.jsxs)(q.qy,{maxH:"min(320px, 40vh)",overflowY:"auto",zIndex:"popover",children:[(0,s.jsx)(q.sN,{onClick:()=>Q(""),children:"-- Select --"}),ei.map(e=>(0,s.jsxs)(q.sN,{onClick:()=>Q(e.id),children:[e.code," - ",e.description,"inactive"===e.status?" (Inactive)":""]},e.id))]})]})]})]})]})})]}),1===i&&(0,s.jsx)(l.xu,{border:"1px solid",borderColor:"strokePrimary.500",borderRadius:"lg",p:"6",children:(0,s.jsxs)(l.xu,{children:[(0,s.jsx)(l.xv,{fontWeight:"semibold",mb:"1",children:"Benefits"}),(0,s.jsx)(l.xv,{fontSize:"sm",color:"textSecondary.500",mb:"4",children:"Choose from the fixed catalog; set quotas for quota-based items."}),(0,s.jsx)(l.iz,{mb:"4"}),P&&(0,s.jsx)(l.xv,{color:"red.500",fontSize:"sm",mb:"4",children:P}),k?(0,s.jsx)(l.kC,{justify:"center",align:"center",py:"8",children:(0,s.jsx)(m.$,{size:"lg"})}):0===B.length?(0,s.jsx)(l.kC,{justify:"center",align:"center",py:"8",children:(0,s.jsx)(l.xv,{color:"textSecondary.500",children:"No benefits available"})}):(0,s.jsx)(l.MI,{columns:{base:1,md:2},spacing:"4",children:B.map(e=>{var t;let n=e.name===L,i=n&&!O;return(0,s.jsx)(l.xu,{p:"4",border:"1px solid",borderColor:"strokePrimary.500",borderRadius:"md",alignItems:"center",children:(0,s.jsxs)(l.Ug,{justify:"space-between",alignItems:"center",h:"full",children:[(0,s.jsx)(l.xv,{fontSize:"sm",fontWeight:"medium",color:"textPrimary.500",children:e.name}),e.hasQuantity?(0,s.jsxs)(c.BZ,{size:"sm",maxW:"120px",alignItems:"center",children:[(0,s.jsx)(c.II,{type:"number",value:null!==(t=e.quantity)&&void 0!==t?t:0,onChange:t=>U(e.id,parseInt(t.target.value,10)),textAlign:"right",min:0,isDisabled:o||e.isLiteTierBenefit||i}),(0,s.jsxs)(l.xv,{fontSize:"sm",fontWeight:"medium",color:"textSecondary.500",ml:"2",children:["/",e.quantityLabel]})]}):(0,s.jsx)(x.r,{isChecked:e.enabled,onChange:()=>D(e.id),colorScheme:"blue",isDisabled:o||e.isLiteTierBenefit||i})]})},e.id)})})]})}),2===i&&(0,s.jsx)(l.xu,{border:"1px solid",borderColor:"strokePrimary.500",borderRadius:"lg",p:"6",children:(0,s.jsxs)(l.xu,{children:[(0,s.jsx)(l.xv,{fontWeight:"semibold",mb:"1",color:"textPrimary.500",children:"Review"}),(0,s.jsx)(l.xv,{fontSize:"sm",color:"textSecondary.500",mb:"4",children:"Confirm selections before publishing"}),(0,s.jsx)(l.iz,{mb:"4"}),(0,s.jsxs)(l.MI,{columns:2,spacing:"4",mb:"6",children:[(0,s.jsxs)(l.xu,{children:[(0,s.jsx)(l.xv,{fontSize:"medium",color:"textSecondary.500",mb:"1",children:"Tier Name:"}),(0,s.jsxs)(l.Ug,{children:[(0,s.jsx)(l.xv,{fontWeight:"medium",children:v||"-"}),I&&(0,s.jsx)(l.Ct,{colorScheme:"green",fontSize:"xs",borderRadius:"full",px:"2",children:"Visible"}),T&&(0,s.jsx)(l.Ct,{colorScheme:"gray",fontSize:"xs",borderRadius:"full",px:"2",children:(0,s.jsxs)(l.Ug,{spacing:"1",children:[(0,s.jsx)(z.mBM,{boxSize:"3"}),(0,s.jsx)(l.xv,{as:"span",size:"sm",children:"Locked"})]})})]})]}),(0,s.jsxs)(l.xu,{children:[(0,s.jsx)(l.xv,{fontSize:"medium",color:"textSecondary.500",mb:"1",children:"Description:"}),(0,s.jsx)(l.xv,{fontWeight:"medium",children:j||"-"})]}),(0,s.jsxs)(l.xu,{children:[(0,s.jsx)(l.xv,{fontSize:"medium",color:"textSecondary.500",mb:"1",children:"Visibility:"}),(0,s.jsx)(l.xv,{fontWeight:"medium",children:I?"Visible":"Hidden"})]}),(0,s.jsxs)(l.xu,{children:[(0,s.jsx)(l.xv,{fontSize:"medium",color:"textSecondary.500",mb:"1",children:"Lock Tier:"}),(0,s.jsx)(l.xv,{fontWeight:"medium",children:T?"Locked":"Unlocked"})]}),(0,s.jsxs)(l.xu,{children:[(0,s.jsx)(l.xv,{fontSize:"medium",color:"textSecondary.500",mb:"1",children:"Chart of account:"}),(0,s.jsx)(l.xv,{fontWeight:"medium",children:et?es:"-"})]}),(0,s.jsxs)(l.xu,{children:[(0,s.jsx)(l.xv,{fontSize:"medium",color:"textSecondary.500",mb:"1",children:"Account class:"}),(0,s.jsx)(l.xv,{fontWeight:"medium",children:V?ea:"-"})]}),(0,s.jsxs)(l.xu,{children:[(0,s.jsx)(l.xv,{fontSize:"medium",color:"textSecondary.500",mb:"1",children:"Price:"}),(0,s.jsx)(l.xv,{fontWeight:"medium",children:A?(0,s.jsx)(C.i_,{value:A}):"-"})]})]}),(0,s.jsxs)(l.xu,{children:[(0,s.jsx)(l.xv,{fontWeight:"semibold",mb:"3",children:"Benefits included:"}),0===W.length?(0,s.jsx)(l.xv,{color:"gray.500",fontSize:"sm",children:"No benefits selected"}):(0,s.jsx)(l.Eq,{spacing:"2",children:W.map(e=>(0,s.jsx)(l.Uc,{children:(0,s.jsxs)(Z.Vp,{size:"md",variant:"outline",colorScheme:"blue",borderRadius:"full",px:"3",py:"1",children:[e.name,e.hasQuantity&&null!==e.quantity&&(0,s.jsxs)(l.xv,{as:"span",ml:"1",fontSize:"sm",color:"primary.500",children:["(",e.quantity,"/",e.quantityLabel||"year",")"]})]})},e.id))})]})]})})]}),(0,s.jsx)(N.mz,{children:(0,s.jsxs)(l.Ug,{spacing:"3",children:[0===i&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(u.zx,{variant:"outline",onClick:n,children:"Cancel"}),(0,s.jsx)(u.zx,{colorScheme:"blue",onClick:G,children:"Next"})]}),1===i&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(u.zx,{variant:"outline",onClick:()=>r(0),children:"Previous"}),(0,s.jsx)(u.zx,{colorScheme:"blue",onClick:Y,children:"Next"})]}),2===i&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(u.zx,{variant:"outline",onClick:()=>r(1),children:"Previous"}),(0,s.jsx)(u.zx,{colorScheme:"blue",onClick:o?X:K,isLoading:!o&&$,children:o?"Dismiss":a?"Update":"Publish"})]})]})})]})]})};var U=n(5209),W=n(67126),H=n(49517);
1let useFinancialSettingsState=()=>{var e;let t=(0,w.x)(),n=null==t?void 0:null===(e=t.tenant)||void 0===e?void 0:e._id,[i,r]=g.useState([]),[s,a]=g.useState([]),[o,l]=g.useState([]),[d,c]=g.useState([]),[u,h]=g.useState(!1),[x,m]=g.useState(!1),p=g.useCallback(async()=>{if(!n){r([]),l([]);return}h(!0);try{let e=await (0,W.CO)({tenantId:n});l(e.data.data);let t=e.data.data.filter(e=>"active"===e.status);r(t)}catch(e){(0,H.H)(e),r([]),l([])}finally{h(!1)}},[n]),f=g.useCallback(async()=>{if(!n){a([]),c([]);return}m(!0);try{let e=await (0,U.eC)({tenantId:n});c(e.data.data);let t=e.data.data.filter(e=>"active"===e.status);a(t)}catch(e){(0,H.H)(e),a([]),c([])}finally{m(!1)}},[n]);return g.useEffect(()=>{p(),f()},[p,f]),{chartOfAccounts:i,accountClasses:s,allChartOfAccounts:o,allAccountClasses:d,loadingAccountClasses:x,loadingChartOfAccounts:u,refreshAccountClasses:f,refreshChartOfAccounts:p}};(i=r||(r={}))[i.Tiers=0]="Tiers",i[i.BenefitCatalogs=1]="BenefitCatalogs";let isCommunityListeningBenefit=e=>"Community Listening"===e.name,isCommunityListeningBenefitEnabled=e=>{if(!isCommunityListeningBenefit(e))return!1;if(e.hasQuantity){var t;return(null!==(t=e.quantity)&&void 0!==t?t:0)>0}return e.enabled},hasCommunityListeningAccess=e=>e.some(e=>isCommunityListeningBenefitEnabled(e)),dineroFromFloat=function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:2;return(0,f.h)({amount:Math.round(e*(t.base**t.exponent||n)),currency:t,scale:n})};var V=n(93064),Q=(0,n(52609).z)(()=>{var e,t,n;let i=(0,w.x)(),r=(0,a.pm)(),O=null!==(n=null==i?void 0:null===(e=i.tenant)||void 0===e?void 0:e._id)&&void 0!==n?n:"",N=null==i?void 0:null===(t=i.user)||void 0===t?void 0:t._id,{currency:M}=(0,A.Z)(),{chartOfAccounts:R,accountClasses:q,allChartOfAccounts:Z,allAccountClasses:F,loadingAccountClasses:U,loadingChartOfAccounts:W,refreshAccountClasses:H,refreshChartOfAccounts:V}=useFinancialSettingsState(),[Q,G]=g.useState(""),[Y,K]=g.useState(""),X=g.useCallback(()=>{G(""),K("")},[]),{data:$,loading:J,execute:ee}=(0,T.Z)(b.iE),{data:et,loading:en,execute:ei}=(0,T.Z)(b.ik),{execute:er}=(0,T.Z)(b.bZ),{loading:es,execute:ea}=(0,T.Z)(b.al),{data:eo,loading:el,execute:ed}=(0,T.Z)(b.V9),{data:ec,loading:eu,execute:eh}=(0,T.Z)(b.fF),{loading:ex,execute:em}=(0,T.Z)(b.qs),{execute:ep}=(0,T.Z)(b.Hr),[ef,ev]=g.useState(0),[eg,ey]=g.useState(!1),[eb,ej]=g.useState(null),[eC,eS]=g.useState(""),[eI,e_]=g.useState([]),[eT,ew]=g.useState([]),eA=g.useMemo(()=>eI.filter(e=>D.has(e.name)).sort((e,t)=>{var n,i;return(null!==(n=e.priority)&&void 0!==n?n:0)-(null!==(i=t.priority)&&void 0!==i?i:0)}),[eI]),{entityIdsToEntities:eE,fetchNewEntities:ek}=(0,P.Z)();g.useEffect(()=>{O&&(ee({tenantId:O,userId:N}),ei({tenantId:O,userId:N}))},[O,N,ee,ei]),g.useEffect(()=>{if(!(null==$?void 0:$.data)){e_([]);return}let e=$.data.map(e=>e.createdBy).filter(e=>!!e),t=[...new Set(e)];t.length&&ek({variables:{userIds:{userIds:t},postIds:{postIds:[]},commentIds:{commentIds:[]}}});let n=$.data.map((e,t)=>{var n,i,r,s;let a;e.price&&(a=dineroFromFloat(e.price,M));let o=e.createdBy&&eE.users[e.createdBy],l=o&&"object"==typeof o&&"displayName"in o&&null!==(i=o.displayName)&&void 0!==i?i:"-";return{id:e.id,name:e.name,subtitle:e.description||"",description:e.description||"",visibility:e.visibility,isLocked:null!==(r=e.isLocked)&&void 0!==r&&r,benefits:(null===(n=e.sponsorBenefits)||void 0===n?void 0:n.length)||0,createdBy:l,priority:null!==(s=e.priority)&&void 0!==s?s:t,price:a}}).sort((e,t)=>e.priority-t.priority);e_(n)},[$,M,eE.users,ek]);let eB=g.useRef(!1),ez=g.useRef(!1),eP=g.useRef(!1);g.useEffect(()=>{if((null==et?void 0:et.data)&&!ez.current){let e=et.data.map(e=>{var t,n;return{id:e.id,name:(null===(t=e.sponsorBenefit)||void 0===t?void 0:t.name)||"",tooltip:(null===(n=e.sponsorBenefit)||void 0===n?void 0:n.description)||"",enabled:e.isActive}});ew(e)}},[et]);let{isOpen:eO,onOpen:eL,onClose:eD}=(0,o.qY)(),[eN,eM]=g.useState(0),[eR,eq]=g.useState(""),[eZ,eF]=g.useState(""),[eU,eW]=g.useState(""),[eH,eV]=g.useState(""),[eQ,eG]=g.useState(""),[eY,eK]=g.useState(!0),[eX,e$]=g.useState(!1),[eJ,e0]=g.useState(void 0),[e1,e5]=g.useState(""),selectTemplate=e=>{eq(e),eF("")},closeCreateTierModal=()=>{ey(!1),ej(null),eF(""),X(),eD()},[e2,e3]=g.useState(null),[e4,e6]=g.useState(null),[e9,e8]=g.useState([]),e7=g.useMemo(()=>hasCommunityListeningAccess(e9),[e9]);g.useEffect(()=>{e7||e8(e=>{let t=!1,n=e.map(e=>{var n;if(e.name!==L)return e;let i=e.hasQuantity,r=(null!==(n=e.quantity)&&void 0!==n?n:0)===0;return e.enabled||i&&!r?(t=!0,{...e,enabled:!1,quantity:i?0:e.quantity}):e});return t?n:e})},[e7]);let te=g.useMemo(()=>eR&&(null==$?void 0:$.data)&&$.data.find(e=>e.id===eR)||null,[eR,$]);g.useEffect(()=>{if(te){var e,t;eW(te.name||""),eV(""),eG(te.description||""),eK(null===(e=te.visibility)||void 0===e||e),eg&&e$(null!==(t=te.isLocked)&&void 0!==t&&t),void 0!==te.price&&null!==te.price?e0(dineroFromFloat(te.price,M)):e0(void 0)}},[te,M,eg]);let tt=g.useMemo(()=>eb&&(null==$?void 0:$.data)&&$.data.find(e=>e.id===eb)||null,[eb,$]),tn=null!=te?te:tt,ti=!!(null==te?void 0:te.isLocked),tr=g.useMemo(()=>{var e,t;return!te||eg?[]:null!==(t=null===(e=te.sponsorBenefits)||void 0===e?void 0:e.map(e=>e.id).filter(e=>!!e))&&void 0!==t?t:[]},[te,eg]),ts=!!(eg&&(null==tt?void 0:tt.isLocked)),ta=g.useMemo(()=>{var e,t;if(!(null==$?void 0:$.data))return[];let n=$.data.find(e=>e.name===_.Lo.Lite.toString());return null!==(t=null==n?void 0:null===(e=n.sponsorBenefits)||void 0===e?void 0:e.map(e=>e.id).filter(e=>!!e))&&void 0!==t?t:[]},[$]);g.useEffect(()=>{if(null==eo?void 0:eo.data){let e=(null==tn?void 0:tn.sponsorBenefits)||[],t=eo.data.map(t=>{var n,i,r,s,a,o,l;let d=(null===(n=t.sponsorBenefit)||void 0===n?void 0:n.id)||"",c=e.find(e=>e.id===d),u=tr.includes(d),h=ta.includes(d),x=null==c?void 0:c.SponsorTierBenefits,m=null;return(null==c?void 0:c.hasQuantity)&&((null==x?void 0:x.quantityValue)!==void 0?m=Number(x.quantityValue):(null==c?void 0:c.quantityValue)!==void 0&&(m=Number(null==c?void 0:c.quantityValue))),{id:(null===(i=t.sponsorBenefit)||void 0===i?void 0:i.id)||"",name:(null===(r=t.sponsorBenefit)||void 0===r?void 0:r.name)||"",description:(null===(s=t.sponsorBenefit)||void 0===s?void 0:s.description)||"",hasQuantity:(null===(a=t.sponsorBenefit)||void 0===a?void 0:a.hasQuantity)||!1,quantityLabel:(null===(o=t.sponsorBenefit)||void 0===o?void 0:o.quantityLabel)||"",enabled:u||!!c,quantity:m,unit:(null==x?void 0:x.unit)||(null==c?void 0:c.unit)||((null===(l=t.sponsorBenefit)||void 0===l?void 0:l.hasQuantity)?"year":null),isBaseTemplateBenefit:u,isLiteTierBenefit:h}});e8(t)}
1},[eo,tn,tr,ta]);let to=0===ef?J:en,tl=g.useMemo(()=>eC?eI.filter(e=>e.name.toLowerCase().includes(eC.toLowerCase())||e.description.toLowerCase().includes(eC.toLowerCase())):eI,[eC,eI]),triggerReorder=async e=>{let t=e.map(e=>({tierId:e.tierId,priority:e.priority}));try{let e=await ep({tenantId:O,tiers:t,userId:N});e.status||r({title:(null==e?void 0:e.message)||"Failed to reorder tiers",status:"error",duration:2e3,isClosable:!0})}catch(e){r({title:"Failed to reorder tiers",status:"error",duration:2e3,isClosable:!0})}},td=(0,E.f)({items:eI,setItems:e_,identifyKey:"id",schemaKey:"tierId",positionKey:"priority",systemLength:0,limit:1e3,offset:0,triggerReorder}),handleVisibilityToggle=async(e,t)=>{let n=!t;try{eB.current=!0,e3(e);let t=await er({tenantId:O,id:e,visibility:n,userId:N});t.status?(e_(t=>t.map(t=>t.id===e?{...t,visibility:n}:t)),r({title:(null==t?void 0:t.message)||"Visibility updated",status:"success",duration:3e3,isClosable:!0})):r({title:null==t?void 0:t.message,status:"error",duration:2e3,isClosable:!0})}catch(e){r({title:"Failed to update visibility",status:"error",duration:3e3,isClosable:!0})}finally{e3(null),eB.current=!1}},handleBenefitCatalogsToggle=async(e,t)=>{let n=!t;try{ez.current=!0,e6(e);let t=await ea({tenantId:O,id:e,visibility:n,userId:N});if(!t.status){r({title:null==t?void 0:t.message,status:"error",duration:2e3,isClosable:!0});return}ew(t=>t.map(t=>t.id===e?{...t,enabled:n}:t)),r({title:(null==t?void 0:t.message)||"Visibility updated",status:"success",duration:3e3,isClosable:!0})}catch(e){r({title:"Failed to update visibility",status:"error",duration:3e3,isClosable:!0})}finally{e6(null),ez.current=!1}},getEnabledBenefits=()=>e9.filter(e=>{var t;return e.enabled||e.hasQuantity&&(null!==(t=e.quantity)&&void 0!==t?t:0)>0}),tc=getEnabledBenefits(),tu=g.useMemo(()=>{if(!eg||!Y||R.some(e=>e.id===Y))return R;let e=Z.find(e=>e.id===Y);return e?[...R,e]:R},[eg,Y,R,Z]),th=g.useMemo(()=>{if(!eg||!Q||q.some(e=>e.id===Q))return q;let e=F.find(e=>e.id===Q);return e?[...q,e]:q},[eg,Q,q,F]),tx=g.useCallback(()=>{H(),V()},[H,V]),tm=tc.length;g.useEffect(()=>{e1&&tm>0&&e5("")},[e1,tm]);let handlePublishTier=async()=>{let e=e9.filter(e=>{var t;return e.enabled||e.hasQuantity&&(null!==(t=e.quantity)&&void 0!==t?t:0)>0}).map(e=>({id:e.id,hasQuantity:e.hasQuantity,quantity:e.hasQuantity?e.quantity:null,quantityLabel:e.hasQuantity?e.unit:null})),t=eU.trim();if(!t){eV("Tier name is required"),eM(0);return}if(!eP.current){eP.current=!0;try{var n;let s;let a=eg?void 0:null==te?void 0:te.name,o={name:t,description:eQ,visibility:eY,isLocked:eX,tenantId:O,sponsorBenefits:e,price:eJ?(0,v.n)(eJ):0,userId:null==i?void 0:null===(n=i.user)||void 0===n?void 0:n._id,chartOfAccountId:Y||null,accountClassId:Q||null,...a?{baseTier:a}:{}};if(eg&&eb){let e={...o,id:eb};s=await em(e)}else s=await eh(o);if(!s.status){r({title:null==s?void 0:s.message,status:"error",duration:2e3,isClosable:!0});return}r({title:null==s?void 0:s.message,status:"success",duration:2e3,isClosable:!0}),closeCreateTierModal(),O&&ee({tenantId:O,userId:N})}finally{eP.current=!1}}},handleEditTier=e=>{var t,n,i,r,s;let a=null==$?void 0:null===(t=$.data)||void 0===t?void 0:t.find(t=>t.id===e);a&&(ey(!0),ej(e),X(),eM(0),selectTemplate(e),eW(a.name||""),eV(""),eG(a.description||""),eK(null===(n=a.visibility)||void 0===n||n),e$(null!==(i=a.isLocked)&&void 0!==i&&i),G(null!==(r=a.accountClassId)&&void 0!==r?r:""),K(null!==(s=a.chartOfAccountId)&&void 0!==s?s:""),void 0!==a.price&&null!==a.price?e0(dineroFromFloat(a.price,M)):e0(void 0),tx(),O&&ed({tenantId:O,userId:N}),eL())};return(0,s.jsx)(k.C,{children:(0,s.jsxs)(j.DY,{maxWidth:"full",mx:"auto",children:[(0,s.jsx)(j.yG,{mb:"4",children:(0,s.jsx)(l.Ug,{w:"full",justifyContent:"space-between",alignItems:"center",children:(0,s.jsxs)(l.gC,{align:"start",spacing:"0",children:[(0,s.jsx)(j.lm,{size:"md",children:"Sponsor Program"}),(0,s.jsx)(l.xv,{color:"gray.textSecondary.500",fontSize:"md",mt:"2",children:"Manage sponsor tiers, benefits, and program settings."})]})})}),(0,s.jsxs)(l.gC,{spacing:"4",children:[(0,s.jsxs)(l.Ug,{w:"full",justifyContent:"space-between",alignItems:"center",children:[(0,s.jsx)(d.mQ,{index:ef,onChange:e=>ev(e),children:(0,s.jsxs)(d.td,{borderBottom:"none",children:[(0,s.jsx)(d.OK,{_selected:{color:"blue.500",borderBottomColor:"blue.500",fontWeight:"semibold"},children:"Tiers"}),(0,s.jsx)(d.OK,{_selected:{color:"blue.500",borderBottomColor:"blue.500",fontWeight:"semibold"},children:"Benefit Catalogs"})]})}),(0,s.jsxs)(l.Ug,{spacing:"3",children:[0===ef&&(0,s.jsxs)(c.BZ,{maxW:"400px",
1width:"400px",children:[(0,s.jsx)(c.Z8,{pointerEvents:"none",children:(0,s.jsx)(z.W1M,{color:"primary.500"})}),(0,s.jsx)(c.II,{variant:"outline",borderRadius:"6px",placeholder:"Search...",value:eC,onChange:e=>eS(e.target.value)})]}),(0,s.jsx)(u.zx,{colorScheme:"blue",leftIcon:(0,s.jsx)(z.pOD,{width:"16px",height:"16px"}),onClick:()=>{ey(!1),ej(null),X(),eM(0),selectTemplate(""),eW(""),eV(""),eG(""),eK(!0),e$(!1),e0(void 0),e8([]),tx(),O&&ed({tenantId:O,userId:N}),eL()},flexShrink:0,whiteSpace:"nowrap",children:"Create Tier"})]})]}),0===ef&&(0,s.jsx)(B.Z,{overflow:"hidden",w:"full",children:(0,s.jsx)(y.Z5,{onDragEnd:td,children:(0,s.jsx)(h.xJ,{children:(0,s.jsxs)(h.iA,{children:[(0,s.jsx)(h.hr,{children:(0,s.jsxs)(h.Tr,{children:[(0,s.jsx)(h.Th,{w:"40px",px:"2"}),(0,s.jsx)(h.Th,{children:"Tier Name"}),(0,s.jsx)(h.Th,{children:"Description"}),(0,s.jsx)(h.Th,{children:"Price"}),(0,s.jsx)(h.Th,{children:"Visibility"}),(0,s.jsx)(h.Th,{children:"Benefits"}),(0,s.jsx)(h.Th,{children:"Created By"}),(0,s.jsx)(h.Th,{width:"80px",children:"Actions"})]})}),(0,s.jsx)(y.bK,{droppableId:"tier-table",children:e=>(0,s.jsxs)(h.p3,{ref:e.innerRef,...e.droppableProps,children:[tl.map((e,t)=>(0,s.jsx)(y._l,{draggableId:e.id,index:t,children:t=>(0,s.jsxs)(h.Tr,{ref:t.innerRef,...t.draggableProps,bg:"white",_hover:{bg:"gray.50"},children:[(0,s.jsx)(h.Td,{px:"2",children:(0,s.jsx)(l.M5,{...t.dragHandleProps,cursor:"grab",_active:{cursor:"grabbing"},p:"1",children:(0,s.jsx)(S.j,{})})}),(0,s.jsx)(h.Td,{children:(0,s.jsx)(l.gC,{align:"start",spacing:"0",children:(0,s.jsx)(l.xv,{as:"span",fontWeight:"medium",fontSize:"16px",color:"textPrimary.500",children:e.name})})}),(0,s.jsx)(h.Td,{children:(0,s.jsx)(l.xv,{as:"span",fontWeight:"medium",fontSize:"16px",color:"textPrimary.500",children:e.description})}),(0,s.jsx)(h.Td,{children:(0,s.jsx)(l.xv,{as:"span",fontWeight:"medium",fontSize:"16px",color:"textPrimary.500",children:e.price?(0,s.jsx)(C.i_,{value:e.price}):(0,s.jsx)(C.i_,{value:(0,f.h)({amount:0,currency:M})})})}),(0,s.jsx)(h.Td,{children:(0,s.jsx)(x.r,{isChecked:e.visibility,isDisabled:e2===e.id,onChange:()=>handleVisibilityToggle(e.id,e.visibility),colorScheme:"blue"})}),(0,s.jsx)(h.Td,{children:(0,s.jsx)(l.xv,{as:"span",fontWeight:"medium",fontSize:"16px",color:"textPrimary.500",children:e.benefits})}),(0,s.jsx)(h.Td,{children:(0,s.jsx)(l.xv,{as:"span",fontWeight:"medium",fontSize:"16px",color:"textPrimary.500",children:e.createdBy})}),(0,s.jsx)(h.Td,{children:(0,s.jsx)(u.hU,{p:"0",style:{padding:"0",height:"40px",width:"20px"},"aria-label":"Edit tier",icon:(0,s.jsx)(z.dY8,{color:"blue.500",p:"0"}),size:"lg",variant:"ghost",_hover:{bg:"transparent"},onClick:()=>handleEditTier(e.id)})})]})},e.id)),e.placeholder]})}),to&&(0,s.jsx)(I.fQ,{children:(0,s.jsx)(m.$,{size:"lg"})}),!to&&0===tl.length&&(0,s.jsx)(I.fQ,{children:"No tiers found"})]})})})}),1===ef&&(0,s.jsx)(B.Z,{w:"full",bg:"transparent",p:"0",border:"0",shadow:"none",children:(0,s.jsx)(l.MI,{columns:2,spacing:"4",children:eT.map(e=>(0,s.jsx)(l.xu,{borderRadius:"md",border:"1px solid",borderColor:"strokePrimary.500",p:"4",bg:"white",children:(0,s.jsxs)(l.Ug,{justify:"space-between",children:[(0,s.jsxs)(l.Ug,{spacing:"2",children:[(0,s.jsx)(l.xv,{fontWeight:"medium",color:"textPrimary.500",children:e.name}),(0,s.jsx)(p.u,{label:e.tooltip,placement:"top",children:(0,s.jsx)(l.xu,{as:"span",color:"textSecondary.500",cursor:"help",children:(0,s.jsx)(z.szr,{boxSize:"5"})})})]}),(0,s.jsx)(x.r,{isChecked:e.enabled,isDisabled:e4===e.id,onChange:()=>handleBenefitCatalogsToggle(e.id,e.enabled),colorScheme:"blue"})]})},e.id))})})]}),(0,s.jsx)(CreateSponsorTierModal,{isOpen:eO,onClose:closeCreateTierModal,createTierStep:eN,setCreateTierStep:eM,isEditMode:eg,isEditingLockedTier:ts,baseTemplates:eA,selectedTemplate:eR,templateSelectionError:eZ,selectTemplate:selectTemplate,tierName:eU,tierNameError:eH,handleTierNameChange:e=>{eW(e),eH&&e.trim()&&eV("")},tierDescription:eQ,setTierDescription:eG,tierVisibility:eY,setTierVisibility:eK,tierLocked:eX,setTierLocked:e$,tierPrice:eJ,handleTierPriceChange:e=>{e0(e)},accountClasses:th,selectedAccountClass:Q,setSelectedAccountClass:G,chartOfAccounts:tu,selectedChartOfAccounts:Y,setselectedChartOfAccounts:K,activeBenefitCatalogsLoading:el,modalBenefits:e9,benefitSelectionError:e1,communityListeningEnabled:e7,handleModalBe
1nefitToggle:e=>{ts||e8(t=>t.map(t=>t.id!==e||t.isLiteTierBenefit?t:{...t,enabled:!t.enabled}))},handleModalBenefitQuantityChange:(e,t)=>{ts||e8(n=>n.map(n=>n.id!==e||n.isLiteTierBenefit?n:{...n,quantity:t,enabled:t>0}))},enabledBenefits:tc,handleStep1Next:()=>{if(!eR&&!eg){eF("Select a base template to continue");return}eF("");let e=eU.trim();if(!e){eV("Tier name is required");return}eV(""),eM(1)},handleStep2Next:()=>{let e=getEnabledBenefits();if(0===e.length){e5("Select at least one benefit to continue");return}e5(""),eM(2)},handlePublishTier:handlePublishTier,handleLockedTierDismiss:()=>{closeCreateTierModal()},isPublishLoading:eu||ex,isTemplateLocked:ti})]})})},{requiresEvery:[V.lj.ADMIN_ROLE]})},3723:function(e,t,n){"use strict";n.d(t,{o:function(){return getCurrencyFromCurrencyCode}});var i=n(26251),r=n(25793),s=n(49517);let getCurrency=e=>i[e.toUpperCase()],getCurrencyFromCurrencyCode=e=>{var t;return null!==(t=getCurrency(e))&&void 0!==t?t:((0,s.H)(Error("Unsupported currency code: ".concat(e))),r.q)}},52609:function(e,t,n){"use strict";n.d(t,{z:function(){return restrictedRoute}});var i=n(85893),r=n(11163),s=n(67294),a=n(39174),o=n(63205),l=n(62893),d=n(69171),c=n(47503),u=n(45893),h=n(93064);let x=new Map([[h.lj.AUTHENTICATION,e=>{var t;return!!(null===(t=e.user)||void 0===t?void 0:t._id)}],[h.lj.ADMIN_ROLE,e=>{var t,n;return(null===(t=e.user)||void 0===t?void 0:t.role)===c.uA.ADMIN||(null===(n=e.user)||void 0===n?void 0:n.role)===c.uA.MORGOTH}],[h.lj.MORGOTH_ROLE,e=>{var t;return(null===(t=e.user)||void 0===t?void 0:t.role)===c.uA.MORGOTH}],[h.lj.COMMUNITY_ACCESS,e=>{var t;return(null==e?void 0:null===(t=e.tenant)||void 0===t?void 0:t.communityAccessConfig)===c.iX.PUBLIC?!e.user||e.user.canAccessCommunity:!!e.user&&e.user.canAccessCommunity}],[h.lj.COMMUNITY_READ_ONLY_ACCESS,e=>{var t;return!!(null===(t=e.user)||void 0===t?void 0:t.canAccessCommunityReadOnly)}],[h.lj.SPONSOR_DASHBOARD_ACCESS,e=>{var t,n;return!!(null===(n=e.user)||void 0===n?void 0:null===(t=n.rosterOrganization)||void 0===t?void 0:t.currentUserOrganizationPermission.canManageOrganizationSponsorship)}],[h.lj.SPONSOR_DIRECTORY_ACCESS,e=>{var t,n,i;switch(null===(t=e.tenant)||void 0===t?void 0:t.sponsorDirectoryAccessConfig){case c.pZ.PUBLIC:return!0;case c.pZ.LOGGED_IN_USERS:return!!(null===(n=e.user)||void 0===n?void 0:n._id);case c.pZ.HIDDEN:return!1;default:throw Error("unknown sponsorDirectoryAccessConfig: ".concat(null===(i=e.tenant)||void 0===i?void 0:i.sponsorDirectoryAccessConfig))}}],[h.lj.MEMBER_DIRECTORY_ACCESS,e=>{var t;return!!(null===(t=e.tenant)||void 0===t?void 0:t.currentUserPermissions.canAccessMemberDirectory)}],[h.lj.EVENTS_FEED_ACCESS,e=>{var t;return!!(null===(t=e.tenant)||void 0===t?void 0:t.currentUserPermissions.canAccessEventsFeed)}],[h.lj.ORGANIZATION_DASHBOARD_ACCESS,e=>{var t,n;return!!(null===(n=e.user)||void 0===n?void 0:null===(t=n.rosterOrganization)||void 0===t?void 0:t.currentUserOrganizationPermission.canManageOrganizationProfile)}],[h.lj.DM_PAGE_ACCESS,e=>{var t;return!!(null===(t=e.user)||void 0===t?void 0:t.canAccessDMPage)}],[h.lj.ORGANIZATION_MEMBERSHIP_ACCESS,e=>{var t,n;return!!(null===(n=e.user)||void 0===n?void 0:null===(t=n.rosterOrganization)||void 0===t?void 0:t.currentUserOrganizationPermission.canManageOrganizationMembership)}],[h.lj.FEATURE_FLAG_CMS,e=>{var t,n;return!!(null===(n=e.tenant)||void 0===n?void 0:null===(t=n.featureFlags)||void 0===t?void 0:t.cms)}],[h.lj.FEATURE_FLAG_CONFERENCES,e=>{var t,n;return!!(null===(n=e.tenant)||void 0===n?void 0:null===(t=n.featureFlags)||void 0===t?void 0:t.conferences)}],[h.lj.FEATURE_FLAG_WEBFLOW,e=>{var t,n;return!!(null===(n=e.tenant)||void 0===n?void 0:null===(t=n.featureFlags)||void 0===t?void 0:t.webflow)}],[h.lj.PAID_MODULE_WEBSITE_BUILDER,e=>{var t,n;return!!(null===(n=e.tenant)||void 0===n?void 0:null===(t=n.paidModules)||void 0===t?void 0:t.websiteBuilder)}]]),useRequiredPermission=e=>{let t=(0,u.x)();if(!e.requiresEvery&&!e.requiresSome)return{hasPermission:!0,loading:!1};if(t.loading)return{hasPermission:!1,loading:!0};let n=null==e||!e.requiresEvery||(null==e?void 0:e.requiresEvery.map(e=>x.get(e)).every(e=>!e||e(t))),i=null==e||!e.requiresSome||(null==e?void 0:e.requiresSome.map(e=>x.get(e)).some(e=>!!e&&e(t)));return{hasPermission:n&&i,loading:!1}}
1,restrictedRoute=(e,t,n)=>c=>{let u=(0,r.useRouter)(),h=useRequiredPermission(t),x=(0,l.T)(),m=(0,o.U)(),p=h.loading||x.isLoading||m.loading,f=!!n&&!!n.requiresMemberManagement&&!m.isActive;return(s.useEffect(()=>{p||h.hasPermission&&!f||x.isAuthenticated||!u.isReady||u.replace({pathname:"/login",query:{redirect:u.asPath}})},[p,u,f,x.isAuthenticated,h.hasPermission]),p)?(0,i.jsx)(d.g,{}):!h.hasPermission||f?x.isAuthenticated?(0,i.jsx)(a.A,{}):(0,i.jsx)(d.g,{}):(0,i.jsx)(e,{...c})}}},function(e){e.O(0,[40630,9669,27313,38568,29411,64986,96317,49774,92888,40179],function(){return e(e.s=69723)}),_N_E=e.O()}]); 2//# sourceMappingURL=tierConfiguration-a167c930b4d3d02e.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.