(self.webpackChunkplex_web_client=self.webpackChunkplex_web_client||[]).push([[370],{25370:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>B});var o=n(37703),a=n(22222),r=n(99051),l=n(67294),s=n(69605),c=n(53790),i=n(39571),d=n(66102),u=n(50362),p=n(14699),m=n(10470),y=n(58368),b=n(58858),S=n(18676),f=n(75774),g=n(45610),M=n(83564),w=n(84388),O=n(12986),E=n(46565),v=n(5562),C=n(58300),Z=n(40691),h=n(13202),D=Object.prototype.hasOwnProperty,P=Object.getOwnPropertySymbols,j=Object.prototype.propertyIsEnumerable,k=Object.assign;const A=function(e){const{errorMessage:t,isMediaSubscriptionSaving:n,prefGroups:o,className:a,onModalClose:r,onSubmit:s}=e,c=((e,t)=>{var n={};for(var o in e)D.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&P)for(var o of P(e))t.indexOf(o)<0&&j.call(e,o)&&(n[o]=e[o]);return n})(e,["errorMessage","isMediaSubscriptionSaving","prefGroups","className","onModalClose","onSubmit"]),i=(0,O.Z)(n)&&!n;return(0,l.useEffect)((()=>{i&&!t&&r()}),[t,i,r]),l.createElement(S.ZP,{className:a,onSubmit:s},l.createElement(w.Z,null,(0,v.Z)("Download Options")),t?l.createElement(Z.Z,{errorMessage:t}):null,l.createElement(f.Z,null,l.createElement("div",{key:"advanced"},l.createElement(h.Z,k(k({},c),{prefs:o.advanced})))),l.createElement(g.Z,null,l.createElement(M.Z,null,l.createElement(b.Z,{kind:E.TP,onPress:r},(0,v.Z)("Cancel")),l.createElement(C.Z,{type:"submit",isSpinning:n,kind:E._8},(0,v.Z)("Save")))))};var x=Object.prototype.hasOwnProperty,I=Object.getOwnPropertySymbols,K=Object.prototype.propertyIsEnumerable,N=Object.assign,_=(e,t)=>{var n={};for(var o in e)x.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&I)for(var o of I(e))t.indexOf(o)<0&&K.call(e,o)&&(n[o]=e[o]);return n};const G=new Set(["autoDeletionItemPolicyUnwatchedLibrary","autoDeletionItemPolicyWatchedLibrary"]),T={dispatchSyncDownloadModalChangeTemplateMode:r.Jl,dispatchSyncDownloadSaveSubscription:r.Y1},L=(0,o.$j)((function(){return(0,a.P1)(((e,{modal:t})=>t),(0,p.Z)(),(0,a.P1)((e=>e.downloads.states),((e,{modal:t})=>t),((e,t)=>{const{sourceAttr:n,ratingKey:o}=t;return e.some((e=>e.ratingKey===o&&e.sourceAttr===n&&e.state===m.SAVING))})),u.Z,((e,t,n,o)=>{const{hint:a}=t,r=t.target&&o[t.target.metadata],l=(0,y.Z)(t.prefs,G);return{errorMessage:e.error,hint:a,isMediaSubscriptionSaving:n,prefGroups:l,target:r}}))}),T)((function(e){const{dispatchSyncDownloadModalChangeTemplateMode:t,dispatchSyncDownloadSaveSubscription:n,modal:o}=e,a=_(e,["dispatchSyncDownloadModalChangeTemplateMode","dispatchSyncDownloadSaveSubscription","modal"]),{ratingKey:r,sourceAttr:s}=o,c=(0,l.useCallback)((e=>{const{mode:t}=e,o=_(e,["mode"]);n({prefs:o,ratingKey:r,sourceAttr:s})}),[r,s,n]);return l.createElement(A,N(N({},a),{onSubmit:c}))})),U=function(e){const{isOpen:t,modal:n,onSyncDownloadModalClose:o}=e,{error:a,mediaSubscription:r,ratingKey:u,sourceAttr:p}=n,m=(0,l.useCallback)((()=>{o({ratingKey:u,sourceAttr:p})}),[u,p,o]);return l.createElement(c.Z,{isOpen:t,metricsPage:s.B8,onModalClose:m},a&&!r?l.createElement(d.Z,{message:a,onModalClose:m}):l.createElement(i.Z,{onModalClose:m},l.createElement(L,{className:"SyncDownloadModal-formContent-2qUtoR ModalContent-modalContent-rkHSzL",modal:n,mediaSubscriptionEntityID:r,onModalClose:m})))};var $=Object.assign;const q=(0,a.P1)((function(e){return e.ui.syncDownloadModals}),(e=>({modal:e.find((e=>e.isOpen))}))),z={onSyncDownloadModalClose:r.yr},B=(0,o.$j)(q,z)((function(e){return e.modal?l.createElement(U,$($({},e),{isOpen:!0})):null}))}}]);