import{R as n,j as e,bE as O,aq as $,aP as M,l as q,b as G,o as D,a4 as V,F as P,b7 as A,aQ as H}from"./app-BgLa5dit.js";import{D as J}from"./DyaZIIgl.chunk.js";import{P as Q}from"./D79orKL9.chunk.js";import{C as j}from"./q-IBKcuF.chunk.js";import"./DFA8aJel.chunk.js";import"./DUpYPoLs.chunk.js";import"./EZim8aq-.chunk.js";import"./BD9MrUJP.chunk.js";import"./s6cGcwlA.chunk.js";import"./Zwjmkasg.chunk.js";import"./4qGb1BIY.chunk.js";import"./DnXDEnAR.chunk.js";import"./DpUpv6rY.chunk.js";import"./CG7zbly5.chunk.js";import"./m4aqaK_l.chunk.js";import"./MEkA24R1.chunk.js";import"./C53kfXmd.chunk.js";const W="_icon_fls63_1",X={icon:W};function T(s){const[i,c]=n.useState(s.enabled);function l(){return!(!$.isFunction(s.onToggle)||!s.canToggle)}return n.useEffect(()=>{l()&&(c(s.enabled),s.removeError())},[s.updateError]),e.jsxs("div",{className:"border rounded",children:[e.jsx("div",{className:"d-flex align-items-center justify-content-center py-3 rounded-top",children:e.jsx("img",{src:s.imageUrl,className:X.icon})}),e.jsx("div",{className:"border-top p-2",children:e.jsxs("div",{className:"d-flex align-items-center justify-content-between",children:[e.jsx("span",{className:"me-2",children:s.name}),e.jsx(O,{on:i,onClick:()=>{l()&&(s.onToggle(!i),c(!i))},disabled:!l(),showStateWhenDisabled:!0,tooltipText:s.tooltipText})]})})]})}const Y="_toggleContainer_cji3j_1",u={toggleContainer:Y},g="settings.productSetting",b=P.encloseNamespace(g),r={id:"manage",name:"Library Editor",imageUrl:"https://img.clickviewapp.com/v2/logos/JpKm92"},o={id:"exchange_tv",name:"TV",imageUrl:"https://img.clickviewapp.com/v2/logos/914KGA"},z=4;function xe(s){var y,F,I;const i=M(),c=q(),{hasPermissions:l}=G(),[E,h]=n.useState(),v=D(j.customerFormationTemplate(s.customerId)),d=D(j.getCustomerProducts(s.customerId)),[C,f]=n.useState(!1);if(!(!!d.data&&!!v.data))return e.jsx(Q,{className:`d-inline-block p-2 ${u.toggleContainer}`,quantity:z});const k=d.data.some(t=>t.id===r.id),N=d.data.some(t=>t.id===o.id),p=(I=(F=(y=v.data)==null?void 0:y.data)==null?void 0:F.features)==null?void 0:I.exchange,_=l(V.ExchangeTvProductManage),S=!p||p.optional!==!1||p.optional===!1&&N;function U(t,a,R){f(!0);let m=[];d.data.map(x=>m.push(x.id)),a&&m.push(t),a||(m=m.filter(x=>x!==t));const w=a?"enableProductSuccess":"disableProductSuccess",L=a?"enableProductError":"disableProductError";function B(){f(!1),c.success(P.getPhrase(g,w,{product:R}))}function K(){f(!1),h(!0),c.error(P.getPhrase(g,L,{product:R}))}H(i,j.updateCustomerProducts(s.customerId,m,B,K))}return e.jsxs(e.Fragment,{children:[e.jsx("h1",{className:"h4 px-2",children:b("customerProducts")}),e.jsx("div",{className:"px-2",children:e.jsxs(J,{localStorageKey:"productsInfoDismissed",children:[e.jsx("p",{children:e.jsx(A,{namespace:g,phrase:"firstParagraph"})}),e.jsx("p",{className:"mb-0",children:e.jsx(A,{namespace:g,phrase:"lastParagraph"})})]})}),e.jsxs(e.Fragment,{children:[d.data.map((t,a)=>t.id===r.id?e.jsx(n.Fragment,{},a):t.id===o.id?e.jsx(n.Fragment,{},a):e.jsx("div",{className:`d-inline-block p-2 ${u.toggleContainer}`,children:e.jsx(T,{name:t.name,imageUrl:t.imageUrl,enabled:!0,tooltipText:b("cannotBeModified")})},a)),e.jsx("div",{className:`d-inline-block p-2 ${u.toggleContainer}`,children:e.jsx(T,{name:r.name,imageUrl:r.imageUrl,onToggle:t=>{U(r.id,t,r.name)},enabled:k,canToggle:!C,updateError:E,removeError:()=>h(!1)})}),e.jsx("div",{className:`d-inline-block p-2 ${u.toggleContainer}`,children:e.jsx(T,{name:o.name,imageUrl:o.imageUrl,onToggle:t=>{U(o.id,t,o.name)},enabled:N,canToggle:!C&&_&&S,updateError:E,removeError:()=>h(!1),tooltipText:(!_||!S)&&b("cannotBeModified")})})]})]})}export{xe as ProductSettingView};
//# sourceMappingURL=KyGWfYN3.chunk.js.map
