import{a as v}from"../../chunk-WPZOBLPA.js";import{a as S}from"../../chunk-3BEB5PEG.js";import"../../chunk-EY555SK2.js";import{a as D}from"../../chunk-XH2OJDAW.js";import{b as y}from"../../chunk-7DBUQ2CV.js";import{b as d}from"../../chunk-KC6VWGIB.js";import"../../chunk-3XIZD54N.js";import{C as c,t as C}from"../../chunk-IRFDE6LX.js";import"../../chunk-FW4363Y4.js";import{lazy as E,Suspense as P,useContext as T,useEffect as m}from"react";import{jsx as N}from"react/jsx-runtime";var R=()=>import("../../Roller-YEZ5W7XM.js").then(({Roller:s})=>({default:s})),h=E(R),k=({visible:s,...I})=>{let{user:e,nodeEnv:u,env:f}=T(D),{getIsShared3dDiceSettingEnabled:i,setIsShared3dDiceSettingEnabled:b}=v(),{getDiceRollPrivacy:a,setHasSeenDiceContainer:p,setRollToPrivacy:r}=y(),l=!isNaN(Number(e?.id)),{setUserDiceData:g}=d(),t=d(o=>o.getUserDiceData(Number(e?.id)));return m(()=>{l&&i(Number(e?.id))===void 0&&b(Number(e?.id))},[i,l,b,e?.id]),m(()=>{(async()=>{if(t&&!t.settings.visibility){let o={...t,settings:{...t.settings,visibility:i(Number(e?.id))===!1?c.Disabled:c.Shared}};g(Number(e?.id),o),await S(o.settings,u,f)}})()},[f,i,u,g,e?.id,t]),m(()=>{let o=JSON.parse(localStorage.getItem("diceContainerConfig")||"{}"),n=o[Number(e?.id)];n&&(n.hasSeenDiceContainer&&p(Number(e?.id)),n.rollTo&&r(Number(e?.id),n.rollTo),delete o[Number(e?.id)],Object.keys(o).length?localStorage.setItem("diceContainerConfig",JSON.stringify(o)):localStorage.removeItem("diceContainerConfig")),l&&(a(Number(e?.id))?a(Number(e?.id))?.rollTo==="All"&&r(Number(e?.id),C.Everyone):r(Number(e?.id)))},[a,l,p,r,e]),s?N(P,{children:N(h,{...I})}):null};export{k as CustomDiceRoller,R as rollerImport};
//# sourceMappingURL=index.js.map
