import n from"@babel/runtime/helpers/slicedToArray";import{jsx as i}from"react/jsx-runtime";import{createContext as o,useContext as e,useState as t,useCallback as r,useMemo as p}from"react";import{useAppCommonsInternal as a}from"../AppCommonsProvider/AppCommonsContext.js";var l="CorvaUI.internal.SettingsPinned",s=o({isPinned:!1,isPopoverOpen:!1,open:function(){},close:function(){},onPinClick:function(){},animatePopover:!0,showPinButton:!0}),c=function(){return e(s)},d=function(o){var e=o.children,c=o.initiallyPinned,d=void 0!==c&&c,u=o.pinningEnabled,m=void 0!==u&&u,P=o.additionalControls,f=a(),v=f.appSettings,C=f.onSettingChange,g=f.appSettingsComponent,h=f.isInsideNewMobileApp,b=d&&v&&!(l in v)||!(null==v||!v[l]),A=t(!1),S=n(A,2),w=S[0],x=S[1],y=t(!1),j=n(y,2),k=j[0],B=j[1],I=t(b&&!!g),O=n(I,2),E=O[0],M=O[1],N=E&&!h,T=r((function(){B(!1),x(N),M(!N),C(l,!N)}),[C,N]),U=r((function(){N||(B(!0),x(!0))}),[N]),q=r((function(n){B(!0),M(!1),n&&C(l,!1),x(!1)}),[C]),z=!h&&m,D=p((function(){return{isPinned:N,isPopoverOpen:w,open:U,close:q,onPinClick:T,animatePopover:k,showPinButton:z,initiallyPinned:d,additionalControls:P}}),[N,w,U,q,T,k,z,d,P]);return i(s.Provider,{value:D,children:e})};export{l as AppSettingsPinnedKey,d as AppSettingsPinningProvider,c as useAppSettingPinning};
//# sourceMappingURL=AppSettingsPinningContext.js.map
