"use strict";(self.webpackChunkplex_web_client=self.webpackChunkplex_web_client||[]).push([[5786],{71284:(e,t,r)=>{r.d(t,{A:()=>a});var n=r(1081),o=r(17469);function a(){return(0,n.Mz)((e,{mediaSubscriptionEntityID:t})=>t,o.A,(e,t)=>t[e])}},5786:(e,t,r)=>{r.r(t),r.d(t,{default:()=>te});var n=r(71468),o=r(1081),a=r(9374),l=r(96540),i=r(84593),c=r(49809),s=r(88896),d=r(87020),p=r(84074),u=r(71284),m=r(25715),b=r(46772),f=r(37423),y=r(8282),O=r(48511),g=r(32467),S=r(84358),v=r(22935),w=r(7672),M=r(94507),A=r(96140),E=r(2346),h=r(25799),j=Object.defineProperty,C=Object.defineProperties,D=Object.getOwnPropertyDescriptors,P=Object.getOwnPropertySymbols,k=Object.prototype.hasOwnProperty,I=Object.prototype.propertyIsEnumerable,K=(e,t,r)=>t in e?j(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;const N=function(e){const t=e,{errorMessage:r,isMediaSubscriptionSaving:n,prefGroups:o,className:a,onModalClose:i,onSubmit:c}=t,s=((e,t)=>{var r={};for(var n in e)k.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&P)for(var n of P(e))t.indexOf(n)<0&&I.call(e,n)&&(r[n]=e[n]);return r})(t,["errorMessage","isMediaSubscriptionSaving","prefGroups","className","onModalClose","onSubmit"]),d=(0,w.A)(n)&&!n;return(0,l.useEffect)(()=>{d&&!r&&i()},[r,d,i]),l.createElement(y.Ay,{className:a,onSubmit:c},l.createElement(v.A,null,(0,b.A)("Download Options")),r?l.createElement(E.A,{errorMessage:r}):null,l.createElement(O.A,null,l.createElement("div",{key:"advanced"},l.createElement(h.A,(p=((e,t)=>{for(var r in t||(t={}))k.call(t,r)&&K(e,r,t[r]);if(P)for(var r of P(t))I.call(t,r)&&K(e,r,t[r]);return e})({},s),u={prefs:o.advanced},C(p,D(u)))))),l.createElement(g.A,null,l.createElement(S.A,null,l.createElement(f.A,{kind:M.qN,onPress:i},(0,b.A)("Cancel")),l.createElement(A.A,{isSpinning:n,kind:M.jd,type:"submit"},(0,b.A)("Save")))));var p,u};var x=Object.defineProperty,T=Object.defineProperties,_=Object.getOwnPropertyDescriptors,z=Object.getOwnPropertySymbols,G=Object.prototype.hasOwnProperty,L=Object.prototype.propertyIsEnumerable,q=(e,t,r)=>t in e?x(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,B=(e,t)=>{var r={};for(var n in e)G.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&z)for(var n of z(e))t.indexOf(n)<0&&L.call(e,n)&&(r[n]=e[n]);return r};const F=new Set(["autoDeletionItemPolicyUnwatchedLibrary","autoDeletionItemPolicyWatchedLibrary"]),Q={dispatchSyncDownloadModalChangeTemplateMode:a.iT,dispatchSyncDownloadSaveSubscription:a.nc},U=(0,n.Ng)(function(){return(0,o.Mz)((e,{modal:t})=>t,(0,u.A)(),(0,o.Mz)(e=>e.downloads.states,(e,{modal:t})=>t,(e,t)=>{const{sourceAttr:r,ratingKey:n}=t;return e.some(e=>e.ratingKey===n&&e.sourceAttr===r&&"saving"===e.state)}),p.A,(e,t,r,n)=>{const{hint:o}=t,a=t.target&&n[t.target.metadata],l=(0,m.A)(t.prefs,F);return{errorMessage:e.error,hint:o,isMediaSubscriptionSaving:r,prefGroups:l,target:a}})},Q)(function(e){const t=e,{dispatchSyncDownloadModalChangeTemplateMode:r,dispatchSyncDownloadSaveSubscription:n,modal:o}=t,a=B(t,["dispatchSyncDownloadModalChangeTemplateMode","dispatchSyncDownloadSaveSubscription","modal"]),{ratingKey:i,sourceAttr:c}=o,s=(0,l.useCallback)(e=>{const t=e,{mode:r}=t,o=B(t,["mode"]);n({prefs:o,ratingKey:i,sourceAttr:c})},[i,c,n]);return l.createElement(N,(d=((e,t)=>{for(var r in t||(t={}))G.call(t,r)&&q(e,r,t[r]);if(z)for(var r of z(t))L.call(t,r)&&q(e,r,t[r]);return e})({},a),T(d,_({onSubmit:s}))));var d}),W=function(e){const{isOpen:t,modal:r,onSyncDownloadModalClose:n}=e,{error:o,mediaSubscription:a,ratingKey:p,sourceAttr:u}=r,m=(0,l.useCallback)(()=>{n({ratingKey:p,sourceAttr:u})},[p,u,n]);return l.createElement(c.A,{isOpen:t,metricsPage:i.g_,onModalClose:m},o&&!a?l.createElement(d.A,{message:o,onModalClose:m}):l.createElement(s.A,{onModalClose:m},l.createElement(U,{className:"SyncDownloadModal-formContent-iDFo2i ModalContent-modalContent-_BsQSK",mediaSubscriptionEntityID:a,modal:r,onModalClose:m})))};var H=Object.defineProperty,J=Object.defineProperties,R=Object.getOwnPropertyDescriptors,V=Object.getOwnPropertySymbols,X=Object.prototype.hasOwnProperty,Y=Object.prototype.propertyIsEnumerable,Z=(e,t,r)=>t in e?H(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;const $=(0,o.Mz)(function(e){return e.ui.syncDownloadModals},e=>({modal:e.find(e=>e.isOpen)})),ee={onSyncDownloadModalClose:a.TT},te=(0,n.Ng)($,ee)(function(e){return e.modal?l.createElement(W,(t=((e,t)=>{for(var r in t||(t={}))X.call(t,r)&&Z(e,r,t[r]);if(V)for(var r of V(t))Y.call(t,r)&&Z(e,r,t[r]);return e})({},e),J(t,R({isOpen:!0})))):null;var t})}}]);