Module 599941

3,408 characters · in f3ae048a0e902d0f.js, 2ea8faf2c9f4d1a9.js
Dependencies
Source Raw
function(t,e,i){i.d(e,{KE:()=>h,Tq:()=>C,XE:()=>D,Yc:()=>f,cY:()=>A,dB:()=>E,dL:()=>P,eb:()=>L,et:()=>g,hc:()=>R,uP:()=>p,uk:()=>I}),i(321073);var n=i(64700),l=i(17928),s=i(724442),u=i(608461),r=i(587626);i(403362);var a=i(300233),S=i(579908),o=i(636194),_=i(624456);let c=[],d=function(t){let{refetchOnMount:e=!1,includeSoftDeleted:i=!0,countryCode:u,dontFetchWhileTrue:a}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},_=(0,l.bG)([r.A],()=>r.A.isConnected()),c=(0,l.bG)([o.A],()=>null!=t?o.A.getSubscriptionGroupListingsForGuildFetchState(t):o.e.FETCHED),d=n.useRef(e);n.useEffect(()=>{if(null==t||!_||!0===a)return;let n=o.A.getSubscriptionGroupListingsForGuildFetchState(t);(e||n===o.e.NOT_FETCHED)&&(d.current=!1,S.WA(t,{includeSoftDeleted:i,countryCode:u}))},[_,t,i,e,u,a]);let A=(0,s.A)(d);return{listingsLoaded:c===o.e.FETCHED&&!0!==A}},A=function(t){let{includeSoftDeleted:e=!1,includeUnpublished:i=!0}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return(0,l.yK)([o.A],()=>{if(null==t)return[];let n=o.A.getSubscriptionGroupListing(t);if(null==n)return[];let l=[];for(let t of n.subscription_listings_ids){let n=o.A.getSubscriptionListing(t);null!=n&&(!n.soft_deleted||e)&&(n.published||i)&&l.push(n)}return l},[t,e,i])},E=t=>(0,l.bG)([o.A],()=>null!=t?o.A.getSubscriptionListing(t):null),I=t=>{let e=(0,a.X)("useGroupListingsForGuild");return(0,l.bG)([o.A],()=>null!=t&&e?o.A.getSubscriptionGroupListingsForGuild(t):c)},p=function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{includeSoftDeleted:!1,sortDeletedListingsLast:!1};return d(t),(0,l.yK)([o.A],()=>{let i=null!=t?o.A.getSubscriptionGroupListingsForGuild(t):c,n=[];for(let t of i)for(let i of t.subscription_listings_ids){let t=o.A.getSubscriptionListing(i);null!=t&&(e.includeSoftDeleted||!t.soft_deleted)&&n.push(t)}return e.includeSoftDeleted&&e.sortDeletedListingsLast?[...n.filter(t=>!t.soft_deleted),...n.filter(t=>t.soft_deleted)]:n})},L=t=>{let[e,i]=n.useState(!1),s=n.useMemo(()=>t.map(_.M),[t]),u=(0,l.yK)([o.A],()=>s.filter(t=>!o.A.getDidFetchListingForSubscriptionPlanId(t)),[s]);return n.useEffect(()=>{!e&&u.length>0&&(i(!0),Promise.all(u.map(t=>S._R(t))).catch(()=>{}).then(()=>{i(!1)}))},[e,u]),{loading:e}},g=()=>{let[t,e]=n.useState(!1),[i,l]=n.useState(null);return{error:i,submitting:t,deleteSubscriptionListing:async(t,i,n)=>{try{return e(!0),l(null),await S.H7(t,i,n),!0}catch(t){l(t)}finally{e(!1)}}}},R=()=>{let[t,e]=(0,u.A)(S.mK),{loading:i,error:n}=e;return{error:n,submitting:i,archiveSubscriptionListing:t}},f=()=>{let[t,e]=n.useState(!1),[i,l]=n.useState(null);return{error:i,submitting:t,publishSubscriptionListing:async t=>{let{guildId:i,groupListingId:n,listingId:s}=t;try{return e(!0),l(null),await S.vW({guildId:i,groupListingId:n,listingId:s,data:{published:!0}}),!0}catch(t){l(t)}finally{e(!1)}},clearError:()=>l(null)}},C=t=>(0,l.bG)([o.A],()=>null!=t?o.A.getSubscriptionSettings(t):void 0),h=()=>{let[t,e]=n.useState(!1),[i,l]=n.useState(null);return{loading:t,updateSubscriptionsSettings:n.useCallback(async(t,i)=>{e(!0),l(null);try{await S.DO(t,i)}catch(t){l(t)}finally{e(!1)}},[]),error:i}},D=()=>{let[t,e]=n.useState(!1),[i,l]=n.useState(null);return{loading:t,fetchSubscriptionsSettings:n.useCallback(async t=>{e(!0),l(null);try{await S.W5(t)}catch(t){l(t)}finally{e(!1)}},[]),error:i}},P=t=>(0,l.bG)([o.A],()=>null!=t?o.A.getSubscriptionTrial(t):null)}