"use strict";(self.webpackChunksubstack=self.webpackChunksubstack||[]).push([["3686"],{22777:function(e,t,i){i.d(t,{Z:()=>n});let n={verticalMenu:"verticalMenu-iEWUZS",customThumbnailInput:"customThumbnailInput-XO3HWP",placeholder:"placeholder-VDJ0cC",loadingPlaceholder:"loadingPlaceholder-PycMQg",videoPlaceholder:"videoPlaceholder-z7fCRh",thumbnailPicture:"thumbnailPicture-sSZ1qk",videoEditorMenu:"videoEditorMenu-PM9LlQ",verticalMenuLabel:"verticalMenuLabel-lDnMVg",clipIcon:"clipIcon-bRPUgg"}},96085:function(e,t,i){i.d(t,{Z:()=>n});let n={videoEditorEmbed:"videoEditorEmbed-YEDZay",videoUploaderEmbed:"videoUploaderEmbed-nDin41",videoUploaderProgressEmbed:"videoUploaderProgressEmbed-WeUy9l",videoUploaderProgressHero:"videoUploaderProgressHero-GSgd0q",videoPortal:"videoPortal-J4jgUG",contextMenu:"contextMenu-YJ0GMi",uploadThumbnailButton:"uploadThumbnailButton-mlBfUX",updatingThumbnailLoader:"updatingThumbnailLoader-TIJ3Re",resumingVideoUploadAlert:"resumingVideoUploadAlert-WC3zea",topLabels:"topLabels-Od3jRz",topLabel:"topLabel-x6LVGU"}},98866:function(e,t,i){i.d(t,{Z:()=>n});let n={alert:"alert-qpA4WP",title:"title-wp_J1f",description:"description-qi_X6V",icon:"icon-wk6sn4",dismissIcon:"dismissIcon-V3WVWl",theme_default:"theme_default-HMCu2W",themeDefault:"theme_default-HMCu2W",priority_primary:"priority_primary-JtnDV3",priorityPrimary:"priority_primary-JtnDV3",theme_accent:"theme_accent-Bs0wZ8",themeAccent:"theme_accent-Bs0wZ8",theme_error:"theme_error-d_EgBh",themeError:"theme_error-d_EgBh",theme_success:"theme_success-ar7Bep",themeSuccess:"theme_success-ar7Bep",theme_warn:"theme_warn-TZXJyb",themeWarn:"theme_warn-TZXJyb",theme_paid:"theme_paid-JMfzbm",themePaid:"theme_paid-JMfzbm",theme_substack:"theme_substack-uNNOIg",themeSubstack:"theme_substack-uNNOIg",theme_select:"theme_select-BVDVyP",themeSelect:"theme_select-BVDVyP",priority_secondary:"priority_secondary-RbRp5G",prioritySecondary:"priority_secondary-RbRp5G",priority_tertiary:"priority_tertiary-PawRzr",priorityTertiary:"priority_tertiary-PawRzr"}},70075:function(e,t,i){i.d(t,{c:()=>Z});var n=i(16584),r=i(98661),a=i(30396),o=i(94874),l=i(15771),s=i(19081),d=i(98248),c=i(10510),u=i(58175),h=i(71460),m=i(55533),p=i(60308);let g={items:"items-SZnmh_",item:"item-VxynEz",isSelected:"isSelected-Yq6O15",showMore:"showMore-rDQFwq",badge:"badge-cOMigQ"},v=e=>{let{items:t,selectItem:i,selectedItem:r,setSelectedItem:a,selectedItemRef:o,query:l}=e;return(0,n.tZ)(n.HY,{children:t.map(e=>(0,n.tZ)(f,{isSelected:r&&e.id===r.id&&e.type===r.type,onClick:()=>i(e),onMouseEnter:()=>a(e),elemRef:r&&e.id===r.id&&e.type===r.type?o:void 0,isDisabled:!!e.disabledReason,children:(0,n.BX)(s.gq,{flex:"grow",alignItems:"center",gap:12,padding:8,children:["user"===e.type&&(0,n.tZ)(y,{item:e,query:l}),"pub"===e.type&&(0,n.BX)(n.HY,{children:[(0,n.tZ)(c.wk,{className:g.profileImg,logoUrl:e.photo_url||(0,p.I4e)(e.id),size:32,publicationName:e.name}),(0,n.BX)(s.tu,{style:{maxWidth:"260px"},children:[(0,n.tZ)(u.xv.B4,{weight:"semibold",color:"primary",ellipsis:!0,as:"div",children:e.name}),e.author_name&&e.author_name.length>0?(0,n.BX)(u.xv.B5,{color:"secondary",ellipsis:!0,translated:!0,children:["by ",I18N.p(e.author_name)]}):null]})]})]})},e.id+e.type))})};function y(e){let{item:t}=e,i=null;return t.publications&&t.publications.length>0&&(i=t.primary_publication_id&&t.publications.find(e=>{let{id:i}=e;return i===t.primary_publication_id})||t.publications[0]),(0,n.BX)(n.HY,{children:[(0,n.tZ)(o.qE,{className:g.avatar,photoUrl:(0,p.zF4)(t.photo_url||(0,p.I4e)(t.id),80),size:36}),(0,n.BX)(s.tu,{maxWidth:220,children:[(0,n.BX)(s.gq,{gap:4,minWidth:0,children:[(0,n.tZ)(u.xv.B4,{color:t.disabledReason?"secondary":"primary",weight:"semibold",ellipsis:!0,children:t.name}),0!==t.bestseller_tier&&(0,n.tZ)(h.UserBadge,{className:g.badge,tier:t.bestseller_tier,size:"sm",userId:t.id})]}),"unmentionable"===t.disabledReason?(0,n.tZ)(u.xv.B5,{color:"secondary",children:"\uD83D\uDD12 Mentions disabled"}):i&&t.handle?(0,n.tZ)(u.xv.B4,{color:"secondary",ellipsis:!0,children:i.name}):(0,n.BX)(n.HY,{children:[i?(0,n.tZ)(u.xv.B5,{color:"secondary",ellipsis:!0,children:i.name}):null,t.handle?(0,n.tZ)(u.xv.B4,{color:"secondary",ellipsis:!0,children:t.handle}):null]})]})]})}let f=e=>{let{children:t,isSelected:i,onClick:r,onMouseEnter:a,elemRef:o,className:l,isDisabled:s}=e;return(0,n.tZ)("button",{className:"".concat(g.item," ").concat(i?g.isSelected:""," ").concat(null!=l?l:""),onClick:r,onMouseEnter:a,onMouseDown:e=>{e.preventDefault();let{target:t}=e;t&&void 0!==t.focus&&t.focus()},ref:o,tabIndex:-1,disabled:s,children:t})},Z=(0,r.forwardRef)((e,t)=>{var i;let{items:r,selectItem:o,query:c,isLoading:u,placeholderText:h,noResultsText:p,minQueryLength:v=0,language:y}=e,{iString:Z}=I18N.i(y),[w,_]=(0,a.eJ)(0),[T,C]=(0,a.eJ)(!1),E=r.size>1,L=Array.from(r.values()).some(e=>e.length>(E?3:6))&&!T,S=Array.from(r.values()).map(e=>T?e:e.slice(0,E?3:6)).flat(),x=(0,a.sO)(),D=null!==(i=S[w])&&void 0!==i?i:null,I=S.length+ +!!L,M=!!L&&w===I-1,P=(0,a.sO)(null);(0,a.d4)(()=>{w>=0&&x.current&&x.current.scrollIntoView({behavior:"smooth",block:"nearest"})},[w,x]);let B=()=>{_((w+I-1)%I)},k=()=>{_((w+1)%I)},N=()=>{D&&o(D),M&&C(!0)};(0,a.d4)(()=>{_(0),C(!1)},[r]);let R=e=>{let t=S.findIndex(t=>t.id===e.id);-1!==t?_(t):_(0)};return((0,a.aP)(t,()=>({getElement:()=>P.current,onKeyDown:e=>{let{event:t}=e;return"ArrowUp"===t.key?(B(),!0):"ArrowDown"===t.key?(k(),!0):"Enter"===t.key&&(N(),!0)}})),h&&(!c||c.length{let[t,i]=e;return(0,n.tZ)(b,{title:E?Z(t):void 0,maxItemsToDisplay:T?void 0:E?3:6,items:i,selectItem:o,selectedItem:D,setSelectedItem:R,selectedItemRef:x,query:c})}),u&&(0,n.tZ)(s.tu,{padding:8,alignItems:"center",children:(0,n.tZ)(d.$j,{})}),!u&&0===I&&(0,n.tZ)(s.gq,{padding:8,children:(0,n.tZ)(m.vJ,{title:p,body:Z("Try another search...")})}),L&&(0,n.tZ)(s.tu,{padding:8,children:(0,n.tZ)(f,{isSelected:M,onMouseEnter:()=>_(I-1),onClick:()=>C(!0),elemRef:M?x:void 0,className:g.showMore,children:(0,n.tZ)(l.zx,{priority:"secondary",flex:"grow",children:Z("Load more...")})})})]})}),b=e=>{let{title:t,maxItemsToDisplay:i,items:r,selectItem:a,selectedItem:o,setSelectedItem:l,selectedItemRef:d,query:c}=e,h=i?r.slice(0,i):r;return(0,n.BX)(n.HY,{children:[t&&(0,n.tZ)(s.tu,{padding:8,children:(0,n.tZ)(u.xv.Meta,{color:"secondary",weight:"semibold",children:t})}),(0,n.tZ)(v,{items:h,selectItem:a,selectedItem:o,setSelectedItem:l,selectedItemRef:d,query:c})]})}},88452:function(e,t,i){i.d(t,{Z:()=>l});var n=i(27412),r=i(6400),a=i(68833),o=i(98914);class l extends r.Component{componentWillUnmount(){this.state.uploading&&this.cancelUpload()}acceptsFile(e){return(this.props.accepts||this.accepts||"*").split(",").map(e=>new RegExp(e.trim().replace(/\./g,"\\.").replace(/\*/g,".*"))).reduce((t,i)=>t||i.test(e.type),!1)}uploadFile(e,t){let{urls:i=null,method:n="POST",rehost:r=!1,fileUrl:a=null,path:o=null,withCredentials:l=!0,useFormData:s=!0,mediaUpload:d=null}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};var c,u=this;if(this.state.uploading)return;if(!window.FormData||!window.XMLHttpRequest){alert("Your browser does not support uploading files!");return}if(e&&!this.acceptsFile(e)){alert("Please select a valid file");return}let h=i||this.props.urls||this.urls,m=[];if(!s&&this.chunkSize>0)for(let t=0;t1&&void 0!==arguments[1]?arguments[1]:0,r=new XMLHttpRequest;if(r.upload&&r.upload.addEventListener("progress",e=>u.onProgress(e),!1),r.addEventListener("load",t=>{d&&u.onPartUploadCompleted(d,r,e),u.uploadNextFile(t)},!1),r.addEventListener("error",t=>{console.error("failed to upload",t),i<10?(console.warn("retrying attempt=".concat(i+1),t),setTimeout(()=>{let t=g(e,i+1);u.setState({uploading:t,uploadingXhrs:[...u.state.uploadingXhrs.slice(0,-1),t]})},1e3*Math.pow(2,i))):u.onError(t)},!1),r.addEventListener("abort",e=>u.onAbort(e),!1),r.withCredentials=l,d&&u.onPartUploadStarted(d,r,e),r.open(n,h[e],!0),s){let i=new FormData;if(m[e]&&i.append(u.fileName||"file",m[e]),t)for(let e of Object.keys(t))i.append(e,t[e]);r.send(i)}else if(m[e]){var a,o;(null===(a=m[e])||void 0===a?void 0:a.type)&&r.setRequestHeader("Content-Type",null===(o=m[e])||void 0===o?void 0:o.type),r.send(m[e])}return r};for(let e=0;et.part_number===e+1);if(null==t?void 0:t.etag){console.warn("already uploaded part ".concat(e+1));continue}}p.push(()=>g(e))}if(p.length)return this.resetUpload(p,r,a,o,d),p;this.onComplete()}uploadNextFile(e){let{uploadingXhrs:t,uploadingXhrGenerators:i}=this.state;if(t&&i&&t.length0&&void 0!==arguments[0]?arguments[0]:null,t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;arguments.length>4&&arguments[4];let r=null,a=null==e?void 0:e[0];a?r=a():e=null,clearInterval(this.state.percentCompleteInterval),this.setState({uploading:r,uploadingXhrs:r?[r]:null,uploadingXhrGenerators:e,startedAt:new Date().getTime(),percentComplete:null,percentCompleteInterval:null,estimatedTimeLeft:null,estimatedTimeLeftAt:null,rehost:t,fileUrl:i,path:n})}startPercentCompleteInterval(){this.setState({uploadedAt:new Date().getTime(),percentCompleteInterval:window.setInterval(()=>this.onPercentCompleteInterval(),100)})}onPercentCompleteInterval(){if(!this.state.uploading)return;let e=this.state.uploadedAt-this.state.startedAt,t=e*(1/this.fudgeFactor-1),i=e+t,n=Date.now()-this.state.startedAt;n=5e3&&e&&e<1){let n=Date.now()-this.state.startedAt,r=n/e-n;r>=6e4&&(this.state.estimatedTimeLeft&&this.state.estimatedTimeLeft=1&&this.startPercentCompleteInterval()}}async onComplete(e){var t,i;let n;let r=this.state.uploading&&this.state.uploading.status;if(!r||r<200||r>=400){this.onError();return}let a=null!==(i=null===(t=this.state.uploading)||void 0===t?void 0:t.responseText)&&void 0!==i?i:"";try{n=JSON.parse(a)}catch(e){console.error("Failed to parse response:",e)}this.resetUpload(),this.props.onUpload&&this.props.onUpload(n,a)}onError(e,t){let i=t||(0,o.zm)(this.state.uploading);alert(i),this.resetUpload(),this.props.onError&&this.props.onError(Error(i))}onAbort(e){this.resetUpload(),this.props.onAbort&&this.props.onAbort()}render(e,t){return console.error("should be implemented by subclass"),null}constructor(e,t){super(e,t),(0,n._)(this,"fudgeFactor",.8),(0,n._)(this,"accepts",null),(0,n._)(this,"chunkSize",null),(0,n._)(this,"fileName",""),(0,n._)(this,"urls",[]),(0,n._)(this,"onPartUploadStarted",async(e,t,i)=>{(0,a.j)(a.FP.MEDIA_UPLOAD_PART_STARTED,{media_upload_id:e.id,post_id:e.post_id,part_number:i})}),(0,n._)(this,"onPartUploadCompleted",async(e,t,i)=>{(0,a.j)(a.FP.MEDIA_UPLOAD_PART_COMPLETED,{media_upload_id:e.id,post_id:e.post_id,part_number:i})}),this.state={uploading:null,uploadingXhrGenerators:[],uploadingXhrs:[],existingEtags:[],startedAt:null,uploadedAt:null,percentComplete:null,percentCompleteInterval:null,estimatedTimeLeft:null,estimatedTimeLeftAt:null,rehost:null,fileUrl:null,path:null}}}},82016:function(e,t,i){i.d(t,{Z:()=>l});var n=i(7409),r=i(99282),a=i(16584),o=i(64515);let l=e=>(0,a.tZ)(o.l,(0,r._)((0,n._)({},e),{name:"PlayIcon",svgParams:{height:43,width:35},children:(0,a.tZ)("path",{d:"M34.428 20.819C34.8483 21.0821 34.8483 21.7121 34.428 21.9752L1.74924 42.4349C1.3132 42.7079 0.755859 42.3835 0.755859 41.8568V0.937387C0.755859 0.410635 1.3132 0.0862969 1.74925 0.359298L34.428 20.819Z"})}))},95741:function(e,t,i){i.d(t,{Z:()=>s});var n=i(7409),r=i(99282),a=i(98848),o=i(16584),l=i(64515);let s=e=>{var{stroke:t="#666666"}=e,i=(0,a._)(e,["stroke"]);return(0,o.BX)(l.l,(0,r._)((0,n._)({stroke:t},i),{name:"UploadIcon",svgParams:{width:20,height:20,viewBox:"0 0 20 20"},children:[(0,o.tZ)("path",{d:"M17.5 12.5V15.8333C17.5 16.2754 17.3244 16.6993 17.0118 17.0118C16.6993 17.3244 16.2754 17.5 15.8333 17.5H4.16667C3.72464 17.5 3.30072 17.3244 2.98816 17.0118C2.67559 16.6993 2.5 16.2754 2.5 15.8333V12.5",strokeWidth:"1.5",fill:"none",strokeLinecap:"round",strokeLinejoin:"round"}),(0,o.tZ)("path",{d:"M14.1667 6.66667L10 2.5L5.83337 6.66667",strokeWidth:"1.5",strokeLinecap:"round",fill:"none",strokeLinejoin:"round"}),(0,o.tZ)("path",{d:"M10 2.5V12.5",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})]}))}},31098:function(e,t,i){i.d(t,{Z:()=>w});var n=i(7409),r=i(99282),a=i(16584),o=i(80569),l=i.n(o),s=i(58865),d=i(30396),c=i(48083),u=i(95441),h=i(15771),m=i(19081),p=i(98248),g=i(58175),v=i(51776),y=i(93370);function f(){let e=(0,s._)(["time format must be 0:00.0"]);return f=function(){return e},e}function Z(e){let{videoPlayerRef:t,onCancel:i,onSubmit:n,onSubmitLabel:r,initialTime:o}=e,[l,s]=(0,d.eJ)(null!=o?o:0),[Z,b]=(0,d.eJ)((0,y.DL)(l)),[w,_]=(0,d.eJ)(),[T,C]=(0,d.eJ)(!1),E=(0,y.Jk)(Z),{iString:L,iTemplate:S}=(0,u.M1)(),x=(0,c.Z)(t);(0,d.d4)(()=>{t&&setTimeout(()=>{t.currentTime=null!=o?o:0},0)},[]),(0,d.d4)(()=>{(0,y.ZD)(Z)!==l&&b((0,y.DL)(l,!0)),_(void 0)},[l]),(0,d.d4)(()=>{s(x)},[x]);let D=e=>(0,y.Jk)(e)?(s((0,y.ZD)(e)),!0):(_(S(f())),!1),I=e=>(b(e),D(e)),M=(0,d.I4)(e=>{(0,y.fI)(e)&&I(e)&&t&&(t.currentTime=(0,y.ZD)(e))},[Z]),P=async()=>{C(!0),await n({time:l}),C(!1)};if(!t)return null;let B=!!w;return(0,a.BX)(m.tu,{border:"detail",className:"container-dENihb",flex:"grow",gap:16,paddingY:12,paddingX:12,radius:"sm",children:[(0,a.BX)(m.gq,{gap:8,justifyContent:"space-between",alignItems:"center",children:[T?(0,a.tZ)(m.gq,{justifyContent:"center",alignItems:"center",children:(0,a.BX)(m.gq,{justifyContent:"center",alignItems:"center",gap:8,children:[(0,a.tZ)(p.$j,{}),(0,a.tZ)(g.xv.B4,{weight:"medium",color:"secondary",translated:!0,children:"Saving..."})]})}):(0,a.tZ)(m.gq,{gap:16,alignItems:"center",children:(0,a.tZ)(v.oi,{error:!E,value:Z,onChange:e=>M(e.currentTarget.value)})}),(0,a.BX)(m.gq,{gap:8,children:[!T&&(0,a.tZ)(h.zx,{priority:"secondary",onClick:i,children:L("Cancel")}),(0,a.tZ)(h.zx,{priority:"primary",onClick:P,disabled:B,loading:T,children:r})]})]}),w&&(0,a.tZ)(m.tu,{children:(0,a.tZ)(m.gq,{children:(0,a.tZ)(g.xv.B4,{weight:"medium",color:"error",children:w})})})]})}var b=i(70379);let w=e=>{var t;let{videoPlayerRef:i,videoUpload:o,active:s,onCancel:d,onUpdate:c}=e,h=(0,b.pm)(),{iString:m}=(0,u.M1)(),p=async e=>{i&&setTimeout(()=>i.pause(),100);try{let t={thumbnail_time:e.time},i=await l().put("/api/v1/video/upload/".concat(o.id,"/thumbnail_time")).send(t);return c(i.body),h.popToast(e=>(0,a.tZ)(b.FN,(0,r._)((0,n._)({},e),{text:m("Thumbnail successfully updated")}))),e}catch(e){console.error(e),h.popToast(e=>(0,a.tZ)(b.FN,(0,r._)((0,n._)({},e),{text:m("Error setting thumbnail")})))}},g=(null!==(t=o.thumbnail_id)&&void 0!==t?t:0)/100;return s?(0,a.tZ)(Z,{videoPlayerRef:i,onCancel:d,onSubmit:p,onSubmitLabel:m("Set thumbnail"),initialTime:g}):null}},71825:function(e,t,i){i.d(t,{Z:()=>F});var n=i(7409),r=i(99282),a=i(98848),o=i(16584),l=i(80569),s=i.n(l),d=i(58865),c=i(6400),u=i(30396),h=i(94184),m=i.n(h),p=i(74691),g=i.n(p),v=i(53716),y=i(82424),f=i(19081),Z=i(98248),b=i(93370);let w={timeline:"timeline-iu4Txf",rail:"rail-_MZqyY",draggable:"draggable-u5Drtn",draggableLeft:"draggableLeft-NsfL_N",draggableRight:"draggableRight-jMJGYz",tooltip:"tooltip-ayX1gr",visible:"visible-vSmpLP",hidden:"hidden-caz2wY",playback:"playback-UzRGYP",nonSelectable:"nonSelectable-ulLSw9",tick:"tick-qjhJIN",lgTick:"lgTick-FIEDu9",smTick:"smTick-UVmBu9",selection:"selection-ioxpLQ",handle:"handle-DL5V5h",storyboard:"storyboard-L12jPn",ticks:"ticks-y4vav6",shadow:"shadow-vjbh9o",shadowContainer:"shadowContainer-Q4Wx96"},_=e=>{let{videoElement:t,start:i,setStart:n,end:r,setEnd:a,onDurationChange:l,storyboard:s,maxDuration:d,minDuration:c,maxTimelineDuration:h,minTimelineDuration:m,looping:p=!1}=e,[g,v]=(0,u.eJ)(0),[y,b]=(0,u.eJ)(0),[_,T]=(0,u.eJ)(0),[E,L]=(0,u.eJ)(0),S=(0,u.sO)(0),[x,D]=(0,u.eJ)(!1);return(0,u.d4)(()=>{let e=()=>{if(t){v(t.duration);let e=[120,t.duration];h&&e.push(h),T(Math.min(...e)),l&&l(t.duration)}};return t&&t.addEventListener("loadedmetadata",e),(null==t?void 0:t.duration)&&e(),()=>{t&&t.removeEventListener("loadedmetadata",e)}},[t]),(0,u.d4)(()=>{t&&(t.currentTime=i)},[i]),(0,u.d4)(()=>{let e=()=>{t&&L(t.currentTime)};if(t)return t.addEventListener("timeupdate",e),()=>{t.removeEventListener("timeupdate",e)}},[t]),(0,u.d4)(()=>{let e=Math.abs(E-S.current);if(S.current=E,e<1){p&&t&&!x&&(E>r||E_||E{e.preventDefault();let t=e.currentTarget.getBoundingClientRect(),i=(e.clientX-t.left)/t.width,n=_-y,r=(e.deltaY>0?-1:1)*n/4,a=n-r,o=y+i*n,l=o-i*a,s=o+(1-i)*a;(!h||!(s-l>h))&&(!m||!(s-l0?(0,o.tZ)(C,{startTimeline:y,setStartTimeline:b,endTimeline:_,setEndTimeline:T,startPosition:i,setStartPosition:e=>{if(c&&e+c>=r){n(r-c);return}if(d&&e+d<=r){n(r-d);return}n(e)},endPosition:r,setEndPosition:e=>{if(c&&e-c<=i){a(i+c);return}if(d&&e-d>=i){a(i+d);return}a(e)},setPosition:(e,t)=>{n(e),a(t)},playerPosition:E,duration:g,onDragging:e=>{D(e)},storyboard:s}):(0,o.tZ)(f.gq,{alignItems:"center",justifyContent:"center",children:(0,o.tZ)(Z.$j,{})})})},T=e=>{let{storyboard:t,imageUrl:i,x:n,y:r,displayWidth:a,displayHeight:l,className:s}=e,d=(n?n/t.tile_width:0)*a,c=(r?r/t.tile_height:0)*l,u={width:"".concat(a,"px"),height:"".concat(l,"px"),backgroundImage:"url(".concat(i,")"),backgroundPosition:"-".concat(d,"px -").concat(c,"px"),backgroundSize:"500%"};return(0,o.tZ)("div",{className:s,style:u})},C=e=>{let{startTimeline:t,setStartTimeline:i,endTimeline:n,setEndTimeline:r,startPosition:a,setStartPosition:l,endPosition:s,setEndPosition:d,setPosition:c,playerPosition:h,duration:p,storyboard:v,onDragging:y}=e,Z=(0,u.sO)(null),_=(0,u.sO)(null),C=(0,u.sO)(s-a),E=(0,u.sO)(null),[L,S]=(0,u.eJ)(!1),M=n-t,P=a-t,B=s-t,k=h-t,N=(0,u.Ye)(()=>P/M*100,[M,P]),R=(0,u.Ye)(()=>B/M*100,[B,M]),A=(0,u.Ye)(()=>k/M*100,[k,M]),X="linear-gradient(to right, \n rgba(0,0,0,0.5) 0%, rgba(0,0,0,0.5) calc(".concat(N,"% + 6px), \n rgba(0,0,0,0) calc(").concat(N,"% + 6px), rgba(0,0,0,0) calc(").concat(R,"% - 6px), \n rgba(0,0,0,0.5) calc(").concat(R,"% - 6px), rgba(0,0,0,0.5) 100%)"),U=(0,u.I4)(e=>{l(Math.max(0,e/100*M+t))},[M,l,t]),z=(0,u.I4)(e=>{d(Math.min(p,e/100*M+t))},[p,M,d,t]);(0,u.d4)(()=>{y(L)},[L]);let O=()=>{document.addEventListener("selectstart",J)},q=()=>{document.removeEventListener("selectstart",J)},J=e=>{e.preventDefault(),e.stopPropagation()},j=()=>{setTimeout(()=>{S(!1)},0),_.current=null,E.current=null,q(),document.removeEventListener("mousemove",F),document.removeEventListener("mouseup",j),document.removeEventListener("pointerup",j)},F=e=>{if(null===_.current)return;let o=e.clientX-_.current;if(o>5&&S(!0),!Z.current)return;let l=o/Z.current.getBoundingClientRect().width*M,s=a+l,d=s+C.current;E.current?s<0?c(0,C.current):d>p?c(p-C.current,p):c(s,d):t-l>0&&n-l<=p&&(i(Math.max(0,t-l)),r(Math.min(p,n-l)))};return(0,o.BX)("div",{className:w.rail,ref:Z,onMouseDown:e=>{if(!Z.current)return;O(),S(!1),_.current=e.clientX,C.current=s-a;let t=Z.current.getBoundingClientRect().left,i=(e.clientX-t)/Z.current.getBoundingClientRect().width*100,n=i>=N&&i<=R;E.current=n,document.addEventListener("mousemove",F),document.addEventListener("mouseup",j),document.addEventListener("pointerup",j)},onClick:e=>{if(e.stopPropagation(),e.preventDefault(),L||!Z.current)return;_.current=e.clientX,C.current=s-a;let i=Z.current.getBoundingClientRect().left,n=(e.clientX-i)/Z.current.getBoundingClientRect().width*100;if(!(n>=N&&n<=R)){let e=t+n/100*M,i=g()(e,0,p-C.current),r=i+C.current;c(i,r)}},children:[(()=>{var e,i;if(!v)return null;let r=null!==(i=null==Z?void 0:null===(e=Z.current)||void 0===e?void 0:e.getBoundingClientRect().width)&&void 0!==i?i:0;if(0===r)return null;let a=(function(e,t,i){let n=[],r=Math.floor(e/i)*i,a=Math.ceil(t/i)*i;for(let e=r;e<=a;e+=i)n.push(e);return n})(t,n,M/r*(60*(v.tile_width/v.tile_height))).map(e=>({time:e,tile:v.tiles.reduce((t,i)=>Math.abs(i.start-e){let{time:n,tile:r}=e,a=(n-t)/M*100;return(0,o.tZ)("div",{style:{position:"absolute",left:"calc(".concat(a,"% + 6px)")},children:(0,o.tZ)(T,{storyboard:v,imageUrl:v.url,displayHeight:60,displayWidth:v.tile_width/v.tile_height*60,x:r.x,y:r.y},"".concat(r.x,"-").concat(r.y,"-").concat(i))})})})})(),(0,o.tZ)("div",{className:w.nonSelectable,style:{background:X,position:"absolute",top:0,bottom:0,left:0,right:0}}),(0,o.tZ)("div",{className:w.ticks,children:(0,o.tZ)(x,{railDuration:M,startTimeline:t})}),(0,o.tZ)("div",{className:m()(w.ticks,w.nonSelectable),children:(0,o.tZ)("div",{className:w.selection,style:{left:"calc(".concat(N,"% + 6px)"),width:"calc(".concat(R-N,"% - 12px)")}})}),(0,o.tZ)(I,{divRef:Z,startTimeline:t,railDuration:n-t,active:!L}),(0,o.BX)("div",{className:w.ticks,children:[(0,o.tZ)(D,{className:"".concat(w.draggable," ").concat(w.draggableLeft),railRef:Z,label:(0,b.DL)(a,!0),position:N,maxPosition:R,setPosition:U,isDragging:L,setIsDragging:S}),(0,o.tZ)(D,{className:"".concat(w.draggable," ").concat(w.draggableRight),railRef:Z,label:(0,b.DL)(s,!0),position:R,minPosition:N,setPosition:z,isDragging:L,setIsDragging:S}),(0,o.tZ)(D,{className:w.playback,railRef:Z,label:(0,b.DL)(h,!0),position:A,isDragging:L,setIsDragging:S,disabled:!0})]})]})},E=[{id:"lg",interval:60,tickClassName:w.lgTick,displayOnZoomLevels:["lg","md"],displayLabelsOnZoomLevels:["lg"]},{id:"md",interval:30,tickClassName:w.lgTick,displayOnZoomLevels:["lg","md"],displayLabelsOnZoomLevels:["md"]},{id:"sm",interval:5,tickClassName:w.smTick,displayOnZoomLevels:["md","sm"],displayLabelsOnZoomLevels:["sm"]},{id:"xs",interval:1,tickClassName:w.smTick,displayOnZoomLevels:["sm","xs"],displayLabelsOnZoomLevels:["xs"]}],L=e=>e>120?"lg":e>30?"md":e>5?"sm":"xs",S=(e,t,i)=>{let n=Math.floor(e/i)*i;return Array.from({length:Math.ceil(t/i)+1}).map((t,r)=>({label:(0,b.DL)(n+i*r),time:n+i*r-e}))},x=e=>{let{railDuration:t,startTimeline:i}=e,a=L(t),l=E.map(e=>(0,r._)((0,n._)({},e),{values:S(i,t,e.interval)}));return(0,o.tZ)(c.Fragment,{children:l.map(e=>e.displayOnZoomLevels.includes(a)&&e.values.map((i,n)=>(0,o.tZ)("div",{className:m()(w.tick,e.tickClassName,w.nonSelectable),style:{left:"".concat(i.time/t*100,"%")},children:e.displayLabelsOnZoomLevels.includes(a)&&(0,o.tZ)("span",{children:i.label})},n)))})},D=e=>{let{railRef:t,position:i,disabled:n,setPosition:r,label:a,maxPosition:l,minPosition:s,className:d,onDragStart:c,onDragEnd:h,showIcon:m=!0,setIsDragging:p}=e,g=(0,u.sO)(null),[v,y]=(0,u.eJ)(!1),f=()=>{document.addEventListener("selectstart",b)},Z=()=>{document.removeEventListener("selectstart",b)},b=e=>{e.preventDefault(),e.stopPropagation()},_=()=>{setTimeout(()=>{p(!1)},0),y(!1),Z(),document.removeEventListener("mousemove",T),document.removeEventListener("mouseup",_),document.removeEventListener("pointerup",_),h&&h()},T=e=>{if(p(!0),!t.current||!g.current)return;let i=t.current.getBoundingClientRect().left,n=t.current.getBoundingClientRect().width,a=(e.clientX-i)/n*100;r&&(void 0!==l&&void 0!==s?r(Math.min(l,Math.max(s,a))):void 0!==l?r(Math.min(l,a)):void 0!==s?r(Math.max(s,a)):r(a))};return(0,o.BX)("div",{className:d,ref:g,style:{left:"".concat(i,"%")},onMouseDown:e=>{!n&&(p(!1),e.stopPropagation(),y(!0),f(),document.addEventListener("mousemove",T),document.addEventListener("mouseup",_),document.addEventListener("pointerup",_),c&&c())},children:[m&&(0,o.tZ)("div",{className:w.handle}),(0,o.tZ)("div",{className:"".concat(w.tooltip," ").concat(v?w.visible:w.hidden," ").concat(w.nonSelectable),children:a})]})},I=e=>{let{divRef:t,startTimeline:i,railDuration:n,active:r}=e,[a,l]=(0,u.eJ)(null),[s,d]=(0,u.eJ)(!1),c=e=>{if(t.current){let r=t.current.getBoundingClientRect(),{left:a,width:o}=r,s=e.clientX-a;l({x:e.clientX-r.left,time:i+s/o*100/100*n})}},h=()=>d(!0),p=()=>d(!1);return((0,u.d4)(()=>(t.current&&(t.current.addEventListener("mousemove",c),t.current.addEventListener("mouseenter",h),t.current.addEventListener("mouseleave",p)),()=>{t.current&&(t.current.removeEventListener("mousemove",c),t.current.removeEventListener("mouseenter",h),t.current.removeEventListener("mouseleave",p))}),[i,n]),r&&a&&s)?(0,o.BX)("div",{className:m()(w.shadowContainer,w.nonSelectable),style:{left:a.x},children:[(0,o.tZ)("div",{className:w.shadow}),(0,o.tZ)("div",{className:w.tooltip,children:(0,b.DL)(a.time,!0)})]}):null};var M=i(347),P=i(95441),B=i(68833),k=i(15771),N=i(58175),R=i(51776),A=i(87077),X=i(24791),U=i(82021);function z(){let e=(0,d._)(["Start time format must be 0:00.0"]);return z=function(){return e},e}function O(){let e=(0,d._)(["End time format must be 0:00.01"]);return O=function(){return e},e}function q(e){var t;let{videoPlayerRef:i,videoUpload:n,post:r,onCancel:a,onSubmit:l,onSubmitLabel:d,minClipDuration:h=1,maxClipDuration:p=Number.MAX_VALUE,minTimelineDuration:w=0,maxTimelineDuration:T=Number.MAX_VALUE,initialStart:C,initialEnd:E,showCaptionsButton:L=!0,elevated:S}=e,[x,D]=(0,u.eJ)(null!=C?C:0),[I,q]=(0,u.eJ)(null!=E?E:Math.min(6,null!==(t=null==n?void 0:n.duration)&&void 0!==t?t:6)),[J,j]=(0,u.eJ)((0,b.DL)(x,!0)),[F,H]=(0,u.eJ)((0,b.DL)(I,!0)),[V,Y]=(0,u.eJ)(!1),[W,G]=(0,u.eJ)(),[K,Q]=(0,u.eJ)(),[$,ee]=(0,u.eJ)(),[et,ei]=(0,u.eJ)(),[en,er]=(0,u.eJ)(!1),[ea,eo]=(0,u.eJ)(!0),el=(0,X.xH)(r),es=(0,b.Jk)(J),ed=(0,b.Jk)(F),{iString:ec,iTemplate:eu}=(0,P.M1)();(0,u.d4)(()=>{let e=async e=>{let{body:{src:t}}=await s().get("/api/v1/video/upload/".concat(e,"/storyboard"));G((await s().get(t)).body)};(null==n?void 0:n.id)&&e(n.id)},[n]),(0,u.d4)(()=>{(0,b.ZD)(J)!==x&&j((0,b.DL)(x,!0)),Q(void 0)},[x]),(0,u.d4)(()=>{(0,b.ZD)(F)!==I&&H((0,b.DL)(I,!0)),ee(void 0)},[I]);let eh=e=>{let t=!1;return e<0?(ei(ec("Start time must be prior to end time")),t=!0):e>p?(ei(ec("Clip can't be greater than 60 seconds")),t=!0):e1&&void 0!==arguments[1]?arguments[1]:"start",i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=(0,b.Jk)(e);if(i||("start"===t?j(e):H(e)),!n)return("start"===t?Q:ee)("start"===t?eu(z()):eu(O())),!1;let r=(0,b.ZD)(e),a="start"===t?(0,b.ZD)(F)-r:r-(0,b.ZD)(J),o=!1;return a<=0?o=!0:("start"===t?Q:ee)(void 0),(o=eh(a)||o)||i||("start"===t?(D(r),q((0,b.ZD)(F))):(D((0,b.ZD)(J)),q(r))),!o},ep=function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return em(e,"start",t)},eg=function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return em(e,"end",t)},ev=(0,u.I4)((e,t)=>{(0,b.fI)(t)&&("start"===e?ep(t):eg(t))},[J,F]),ey=async()=>{er(!0),await (null==l?void 0:l({start:x,duration:I-x,render_transcript_as:V?"subtitles":void 0})),er(!1)};if(!i)return null;let ef=!!K||!!$||!!et;return(0,o.tZ)(M.h,{children:(0,o.tZ)(f.hs,{bg:"primary",className:m()(S?U.Z.containerElevated:U.Z.containerInline),children:(0,o.BX)(f.tu,{gap:16,paddingX:4,flex:"grow",children:[(0,o.tZ)(f.gq,{className:U.Z.videoTrimmerWrapper,children:(0,o.tZ)(_,{videoElement:i,start:x,setStart:D,end:I,setEnd:q,minDuration:h,maxDuration:p,maxTimelineDuration:T,minTimelineDuration:w,looping:ea,onDurationChange:e=>{!C&&!E&&q(g()(e/4,h,30))},storyboard:W})}),(0,o.BX)(c.Fragment,{children:[(0,o.BX)(f.gq,{justifyContent:"space-between",alignItems:"center",opacity:en?50:100,children:[en?(0,o.tZ)(f.gq,{justifyContent:"center",alignItems:"center",children:(0,o.BX)(f.gq,{justifyContent:"center",alignItems:"center",gap:8,children:[(0,o.tZ)(Z.$j,{}),(0,o.tZ)(N.xv.B4,{weight:"medium",translated:!0,color:"secondary",children:"Saving..."})]})}):(0,o.BX)(f.gq,{gap:16,children:[(0,o.BX)(f.gq,{gap:4,alignItems:"center",onClick:()=>el&&Y(!V),className:"".concat(el?U.Z.captionsAvailable:U.Z.captionsNotAvailable),children:[(0,o.tZ)(A.u,{text:ec("Loop video"),children:(0,o.tZ)(k.hU,{onClick:()=>{var e;(0,B.j)(B.FP.VIDEO_CLIP_LOOP_BUTTON_CLICKED,{post_id:null==r?void 0:r.id,media_upload_id:null==r?void 0:null===(e=r.videoUpload)||void 0===e?void 0:e.id,looping:!ea}),eo(!ea)},children:(0,o.tZ)(v.Z,{})})}),L&&(0,o.tZ)(A.u,{text:ec("Include subtitles"),children:(0,o.tZ)(k.hU,{disabled:!el||en,children:(0,o.tZ)(y.Z,{})})})]}),(0,o.BX)(f.gq,{gap:8,children:[(0,o.tZ)(R.oi,{error:!es,value:J,onChange:e=>ev("start",e.currentTarget.value)}),(0,o.tZ)(R.oi,{error:!ed,value:F,onChange:e=>ev("end",e.currentTarget.value)})]}),(0,o.tZ)(f.gq,{gap:4,alignItems:"center",justifyContent:"space-between",className:U.Z.durationContainer,children:(0,o.tZ)(N.xv.B3,{weight:"medium",color:"secondary",children:(0,b.DL)(I-x,!0)})})]}),(0,o.BX)(f.gq,{gap:8,children:[(0,o.tZ)(k.zx,{priority:"secondary",onClick:a,children:ec("Cancel")}),(0,o.tZ)(k.zx,{onClick:ey,disabled:ef||en,children:d})]})]}),ef&&(0,o.BX)(f.tu,{children:[K&&(0,o.tZ)(f.gq,{children:(0,o.tZ)(N.xv.B4,{weight:"medium",color:"error",children:K})}),$&&(0,o.tZ)(f.gq,{children:(0,o.tZ)(N.xv.B4,{weight:"medium",color:"error",children:$})}),et&&(0,o.tZ)(f.gq,{children:(0,o.tZ)(N.xv.B4,{weight:"medium",color:"error",children:et})})]})]})]})})})}var J=i(61649),j=i(70379);let F=e=>{var t;let{videoPlayerRef:i,videoUpload:l,post:d,active:c,onCancel:u,onUpdate:h,audioPreviewMediaUpload:m,onAudioExtractPreviewMediaUpload:p}=e,g=(0,j.pm)(),{iString:v}=(0,P.M1)(),y=async e=>{i&&setTimeout(()=>i.pause(),100);try{let t={preview_start:e.start,preview_duration:e.duration},i=(await s().put("/api/v1/video/upload/".concat(l.id,"/preview")).send(t)).body,{audioExtractPreviewMediaUpload:d}=i,c=(0,a._)(i,["audioExtractPreviewMediaUpload"]),u=!m,y=m&&!!(null==m?void 0:m.src_media_upload_id);return d&&(u||y)&&p({mediaUpload:d}),h(c),g.popToast(e=>(0,o.tZ)(j.FN,(0,r._)((0,n._)({},e),{text:v("Free preview successfully updated")}))),e}catch(e){console.error(e),g.popToast(e=>(0,o.tZ)(j.FN,(0,r._)((0,n._)({},e),{text:v("Error setting free preview")})))}},{preview_start:f,preview_duration:Z}=l,b=f||0,w=Z?b+Z:b+Math.max(30,(null!==(t=l.duration)&&void 0!==t?t:60)/2);return c?(0,o.tZ)(q,{videoPlayerRef:i,videoUpload:l,post:d,onCancel:u,onSubmit:y,onSubmitLabel:v("Set free preview"),minClipDuration:J.AT,minTimelineDuration:J.Zl,maxTimelineDuration:J.eD,initialStart:b,initialEnd:w,showCaptionsButton:!1}):null}},5786:function(e,t,i){i.d(t,{H:()=>u,o:()=>c});var n=i(16584),r=i(98661),a=i(30396),o=i(15771),l=i(19081),s=i(58175);let d={verticalMenuLabel:"verticalMenuLabel-vDULBF"},c=(0,r.forwardRef)((e,t)=>{let{onClick:i,children:r,disabled:a=!1,size:l="md"}=e;return(0,n.tZ)(o.GI,{ref:t,rounded:!0,onClick:i,disabled:a,size:l,children:r})}),u=e=>{let{label:t,children:i}=e,[r,o]=(0,a.eJ)(!1);return(0,n.BX)(l.gq,{gap:8,justifyContent:"center",alignItems:"center",children:[t&&(0,n.tZ)(l.gq,{bg:"glass-inverted-medium",justifyContent:"center",alignItems:"center",radius:"sm",paddingY:6,paddingX:8,className:d.verticalMenuLabel,style:{opacity:+!!r},children:(0,n.tZ)(s.xv.B4,{color:"white",children:t})}),(0,n.tZ)("div",{onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),children:i})]})}},40158:function(e,t,i){i.d(t,{y:()=>u}),i(27412);var n=i(7409),r=i(98848),a=i(16584),o=i(6400),l=i(94184),s=(i(82424),i(13304),i(82016),i(36181),i(51214),i(99282)),d=i(64515);i(95741);var c=i(49995);function u(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};var{timeout:i=5e3}=t,a=(0,r._)(t,["timeout"]);(0,c.ZP)(e,(0,n._)({timeout:i},a),document.querySelector(".bottom-bar"))}i(98914),i(19081),i(98248),i(96085),o.Component},29719:function(e,t,i){i.d(t,{Z:()=>j});var n=i(7409),r=i(99282),a=i(16584),o=i(6400),l=i(30396),s=i(94184),d=i.n(s),c=i(40423),u=i(5281),h=i(84488),m=i(65445),p=i(85200),g=i(71212),v=i(47976),y=i(27194),f=i(74945),Z=i(80569),b=i.n(Z),w=i(29032),_=i(20888),T=i(12281),C=i(95441),E=i(61381),L=i(89871),S=i(5786),x=i(53030),D=i(68833),I=i(49762),M=i(98914),P=i(70717),B=i(15771),k=i(61254),N=i(19081),R=i(44424),A=i(98248),X=i(58175),U=i(70379),z=i(18618),O=i(60308),q=i(9799),J=i(22777);let j=e=>{var t,i;let{videoPlayer:s,pub:Z,postId:j,mediaUpload:F,onOpenThumbnail:H,onThumbnailUpdated:V,onOpenFreePreview:Y,onRemoveFreePreview:W,onOpenSettings:G,onRemoveMedia:K,active:Q,onSelected:$,onDownloadStarted:ee,onDownloadFinished:et,onOpenVideoSettings:ei}=e,[en,er]=(0,l.eJ)(),[ea,eo]=(0,l.eJ)(!1),el=(0,l.sO)(null),{iString:es}=(0,C.M1)(),{setIsPodcastDrawerOpen:ed,isPodcastDrawerOpen:ec,setInitialTab:eu}=(0,E.y)(),eh=(0,M.K1)(),em=(0,U.pm)(),ep=(0,q.M)(F),eg=(0,x.md)(s),{postMediaComposition:ev}=(0,L.z)();(0,l.d4)(()=>{null==$||$(en)},[en]),(0,l.d4)(()=>{100===ep.downloadPercentage&&(null==et||et())},[ep.downloadPercentage]);let ey=()=>{if(null==s?void 0:s.player){let e=s.player;e.pause(),e.currentTime=0;let t=e.src;e.src="",e.load(),e.src=t}},ef=async()=>{var e,t;if((0,D.j)(D.FP.EDITOR_MEDIA_SET_THUMBNAIL_UPLOAD_IMAGE_CLICKED,{media_upload_id:F.id,post_id:F.post_id}),!(null==el?void 0:null===(t=el.current)||void 0===t?void 0:null===(e=t.files)||void 0===e?void 0:e.length))return;let i=el.current.files[0];eo(!0),await eZ(i),eo(!1)},eZ=async e=>{let t=Math.round(new Date().getTime()/1e3);try{await b().put("/api/v1/video/upload/".concat(F.id,"/thumbnail_id")).send({thumbnail_id:t,custom_thumbnail:!0});let i=await b().post("/api/v1/video/upload/".concat(F.id,"/thumbnail_upload_url")).query({fileType:e.type,fileSize:e.size,thumbnail_id:t}),a=i.body.thumbnail_upload_url;await b().put(a).set("content-type",e.type).send(e),(0,M.pt)((0,O.ow1)(i.body.mediaUpload)),V((0,r._)((0,n._)({},i.body.mediaUpload),{updated_at:new Date})),ey()}catch(e){console.error(e);return}},eb=async()=>{try{let{body:e}=await b().put("/api/v1/video/upload/".concat(F.id,"/thumbnail_id")).send({ai_thumbnail:!0});em.popToast(t=>(0,a.tZ)(U.FN,(0,r._)((0,n._)({},t),{text:"Workflow started with id ".concat(e.workflowId)})))}catch(e){console.error(e);return}},ew=(0,O.kOB)(F);return Q?(0,a.BX)(w.C,{children:[(0,a.tZ)("div",{className:J.Z.verticalMenu,children:(0,a.BX)(N.tu,{gap:8,alignItems:"end",children:[!en&&G&&(0,a.tZ)(S.H,{label:es("Clips"),children:(0,a.tZ)(S.o,{onClick:()=>{ed({isOpen:!ec}),ec||(eu("clips"),null==G||G({tab:"clips"}))},children:(0,a.BX)(a.HY,{children:[(0,a.tZ)(_.e,{src:(0,O.kOB)(F),maxWidth:40,radius:"full",imageProps:{height:40,smartCrop:!0},style:{border:"2px solid white"},className:J.Z.clipIcon}),(0,a.tZ)(N.hs,{position:"absolute",children:(0,a.tZ)(c.Z,{size:16,stroke:"white"})})]})})},"".concat(F.id,"_clips")),(!en||"settings"===en)&&G&&(0,a.tZ)(S.H,{label:es("Open Settings"),children:(0,a.tZ)(S.o,{onClick:()=>{ed({isOpen:!ec}),ec||G()},children:(0,a.tZ)(u.Z,{size:16})})},"".concat(F.id,"_settings")),(!en||"preview"===en)&&Y&&W&&(0,a.tZ)(S.H,{label:es("Free preview"),children:F.preview_duration?(0,a.tZ)(R.v2,{layerOptions:{placement:"bottom-end"},onClose:()=>er(void 0),onOpen:()=>er("preview"),trigger:(0,a.tZ)(S.o,{children:(0,a.tZ)(h.Z,{size:16})}),children:(0,a.BX)(N.tu,{gap:8,padding:8,justifyContent:"center",children:[(0,a.tZ)(N.gq,{className:J.Z.videoPlaceholder,justifyContent:"center",alignItems:"center",children:(0,a.BX)("div",{className:d()("video-editor-menu",J.Z.videoEditorMenu),children:[(0,a.tZ)(T.Z,{mediaUpload:F,pub:Z,autoPlay:!1,usePreview:!0,surface:"editor",contentType:"post",videoType:"post",entityKey:String(null!=j?j:null==F?void 0:F.post_id),entityType:"post",renderPlayButton:()=>(0,a.tZ)(z.f,{isPlaying:!1,size:eh?40:56})}),(0,a.tZ)(P.w,{duration:F.preview_duration})]})}),(0,a.BX)(o.Fragment,{children:[(0,a.tZ)(B.zx,{priority:"secondary",onClick:()=>{Y(),er(void 0)},children:es("Edit preview")}),(0,a.tZ)(B.zx,{priority:"destructive",disabled:!F.preview_duration,onClick:()=>{W(),er(void 0)},children:es("Remove preview")})]})]})}):(0,a.tZ)(S.o,{onClick:Y,children:(0,a.tZ)(h.Z,{size:16})})},"".concat(F.id,"_preview")),(!en||"thumbnail"===en)&&(0,a.tZ)(S.H,{label:es("Edit thumbnail"),children:(0,a.tZ)(R.v2,{layerOptions:{placement:"bottom-end"},onClose:()=>er(void 0),onOpen:()=>er("thumbnail"),trigger:(0,a.tZ)(S.o,{children:(0,a.tZ)(m.Z,{size:16})}),children:(0,a.BX)(N.tu,{gap:8,padding:8,justifyContent:"center",children:[ea?(0,a.tZ)(N.gq,{className:J.Z.loadingPlaceholder,justifyContent:"center",alignItems:"center",children:(0,a.tZ)(A.$j,{})}):(0,a.tZ)("img",{className:J.Z.thumbnailPicture,src:ew}),(0,a.BX)(o.Fragment,{children:[(0,a.BX)(B.zx,{priority:"secondary",disabled:ea,children:[es("Upload image"),(0,a.tZ)("input",{type:"file",accept:"image/*",className:J.Z.customThumbnailInput,onChange:()=>ef(),ref:el})]}),(0,a.tZ)(B.zx,{priority:"secondary",disabled:ea,onClick:()=>{(0,D.j)(D.FP.EDITOR_MEDIA_SET_THUMBNAIL_FROM_TIMELINE_CLICKED,{media_upload_id:F.id,post_id:F.post_id}),H(),er(void 0)},children:es("Select from timeline")}),(0,a.tZ)(I.SiteConfigGate,{configKey:"use_livestream_post_media_composition",value:!0,children:(0,a.tZ)(B.zx,{priority:"secondary",onClick:async()=>{await eb(),er(void 0)},children:es("Select with AI")})})]})]})})},"".concat(F.id,"_thumbnail")),(0,a.tZ)(S.H,{label:es("More"),children:(0,a.BX)(R.v2,{layerOptions:{placement:"bottom-end"},onOpen:()=>er("more"),onClose:()=>er(void 0),trigger:(0,a.tZ)(S.o,{disabled:ep.downloadPercentage>0,children:ep.downloadPercentage>0?(0,a.BX)(N.hs,{position:"relative",justifyContent:"center",alignItems:"center",children:[(0,a.tZ)(N.hs,{position:"absolute",justifyContent:"center",alignItems:"center",children:(0,a.BX)(X.xv.Digit,{color:"white",children:[ep.downloadPercentage.toFixed(0),"%"]})}),(0,a.tZ)(N.hs,{position:"absolute",justifyContent:"center",alignItems:"center",children:(0,a.tZ)(A.$j,{size:32})})]}):(0,a.tZ)(p.Z,{size:16})}),children:[(0,a.tZ)(R.sN,{leading:(0,a.tZ)(g.Z,{}),onClick:()=>{ep.startDownload(),null==ee||ee()},children:es("Download video")}),(0,a.tZ)(I.SiteConfigGate,{configKey:"use_livestream_post_media_composition",value:!0,children:ev&&ei&&(0,a.tZ)(R.sN,{leading:(0,a.tZ)(v.Z,{size:16}),onClick:()=>{null==ei||ei()},children:es("Edit video")})}),ev&&ei&&(0,a.tZ)(k.iz,{paddingY:4}),K&&(0,a.tZ)(R.sN,{leading:(0,a.tZ)(y.Z,{}),priority:"destructive",onClick:()=>{(0,D.j)(D.FP.EDITOR_MEDIA_REMOVE_CLICKED,{media_upload_id:F.id,post_id:F.post_id}),K()},children:es("Delete video")})]})},"".concat(F.id,"_more"))]})}),!eg&&(0,a.tZ)(P.w,{duration:null!==(t=F.duration)&&void 0!==t?t:0,icon:F.preview_duration?(0,a.tZ)(h.Z,{color:"white",size:12}):null,previewDuration:null!==(i=F.preview_duration)&&void 0!==i?i:null},"".concat(F.id,"_duration")),(0,a.tZ)(I.SiteConfigGate,{configKey:"use_livestream_post_media_composition",value:!0,children:ev&&ei&&(0,a.tZ)(N.hs,{position:"absolute",style:{left:16,top:16},children:(0,a.tZ)(B.zx,{size:"sm",priority:"secondary",leading:(0,a.tZ)(f.Z,{size:16}),onClick:()=>{null==ei||ei()},children:es("Edit AI enhancements")})})})]},"".concat(F.id,"_container")):null}},41688:function(e,t,i){i.d(t,{F:()=>d});var n=i(16584),r=i(94184),a=i.n(r),o=i(71375),l=i(15771),s=i(58175);let d=e=>{let{percentComplete:t=0,onCancel:i}=e;return(0,n.BX)("div",{className:"mediaUploader-QyeCya",children:[(0,n.tZ)("div",{className:a()("mediaUploaderProgressBar-UH1KZ3","tw-mt-0 tw-h-1 tw-w-full"),children:(0,n.tZ)("div",{className:a()("mediaUploaderProgressBarFilled-jRbeeL","tw-bg-pub-accent"),style:"width: ".concat(Math.max(5,100*t),"%;")})}),(0,n.tZ)("div",{className:"tw-w-12 tw-text-right tw-text-sm",children:(0,n.tZ)(s.xv,{color:"secondary",children:"".concat(Math.max(1,100*t).toFixed(0),"%")})}),(0,n.tZ)(l.hU,{size:"sm",priority:"quaternary","aria-label":"Cancel",onClick:i,children:(0,n.tZ)(o.Z,{size:16,"aria-hidden":!0})})]})}},21680:function(e,t,i){i.d(t,{O:()=>d});var n=i(16584),r=i(71375),a=i(95441),o=i(19081),l=i(98248),s=i(58175);let d=e=>{let{onCancel:t}=e,{iString:i}=(0,a.M1)();return(0,n.BX)(o.gq,{gap:16,flex:"grow",children:[(0,n.tZ)(o.hs,{radius:"xs",height:40,width:40,alignItems:"center",justifyContent:"center",children:(0,n.tZ)(l.$j,{})}),(0,n.BX)(o.tu,{flex:"grow",gap:4,children:[(0,n.tZ)(o.gq,{justifyContent:"space-between",alignItems:"center",children:(0,n.tZ)(s.xv.B3,{color:"primary",weight:"semibold",children:i("Processing media...")})}),(0,n.tZ)(o.gq,{flex:"grow",alignItems:"center",gap:32,children:(0,n.tZ)(s.xv,{translated:!0,size:12,color:"secondary",children:"This could take up to several minutes depending on the format and length of your media."})})]}),(0,n.tZ)(o.gq,{cursor:"pointer",onClick:t,children:(0,n.tZ)(r.Z,{size:20,color:"var(--color-fg-secondary)"})})]})}},88788:function(e,t,i){i.d(t,{Z:()=>a});var n=i(27412),r=i(98914);class a{static get STATE(){return{STOPPED:"stopped",STARTING:"starting",STARTED:"started",STOPPING:"stopping"}}static isSupported(){var e,t;return!("undefined"==typeof window||!(null===(t=window.navigator)||void 0===t?void 0:null===(e=t.mediaDevices)||void 0===e?void 0:e.getUserMedia)||!window.AudioContext&&!window.webkitAudioContext||!window.MediaRecorder||!window.Float32Array||!window.Blob||!window.URL||!window.Worker||(0,r.K1)()||(0,r.L)())}get duration(){return this.startedAt?((this.endedAt||Date.now())-this.startedAt)/1e3:null}get volume(){if(this.state!==a.STATE.STARTED||!this.analyser)return 0;let e=new Uint8Array(this.analyser.frequencyBinCount);return this.analyser.getByteFrequencyData(e),Math.max(...e)/255}async startCapture(){let{iString:e}=this.i18n;if(!a.isSupported())return alert(e("Recording is not supported on this device.")),!1;if(this.stream)try{return await this.stream,!0}catch(e){return!1}try{this.stream=navigator.mediaDevices.getUserMedia({audio:!0,video:{width:{ideal:1920},height:{ideal:1080},aspectRatio:this.aspectRatio?{ideal:this.aspectRatio}:{ideal:16/9}}}),this.stream=await this.stream,this.stream.getTracks().forEach(e=>{e.addEventListener("ended",()=>{this.state===a.STATE.STARTED&&this.stop()})})}catch(e){console.error(e),this.stream=null}return!!this.stream||(alert(e("Unable to access the camera or microphone! Please check your browser settings.")),!1)}async stopCapture(){if(this.stream){if(this.stream instanceof Promise)try{await this.stream}catch(e){return}if(this.state===a.STATE.STARTED){await this.stop();return}if(this.stream instanceof MediaStream){var e,t;this.stream.getTracks().forEach(e=>e.stop()),null===(e=(t=this.stream).stop)||void 0===e||e.call(t),this.stream=null}}}async start(){var e,t;let{startAt:i=null}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{iString:n}=this.i18n;if(!a.isSupported())throw Error("Recording is not supported on this device");if(this.state===a.STATE.STOPPING)throw Error("Currently stopping last recording");if(["starting","started"].includes(this.state))return;if(this.startingTimeout&&clearTimeout(this.startingTimeout),this.state=a.STATE.STARTING,!await this.startCapture()){this.state=a.STATE.STOPPED,null===(e=this.onStopped)||void 0===e||e.call(this);return}let o=window.AudioContext||window.webkitAudioContext;try{let e;if(this.audioContext=(0,r.vU)()?new o:new o({sampleRate:this.sampleRate}),this.analyser=this.audioContext.createAnalyser(),this.analyser.smoothingTimeConstant=.2,this.analyser.fftSize=1024,this.audioContext.createScriptProcessor)this.audioNode=this.audioContext.createScriptProcessor(this.bufferSize,1,1);else throw Error("Unable to construct audio node");if(this.stream instanceof MediaStream&&(this.audioInput=this.audioContext.createMediaStreamSource(this.stream),this.audioInput.connect(this.analyser),this.analyser.connect(this.audioNode),this.audioNode.connect(this.audioContext.destination)),"function"==typeof MediaRecorder.isTypeSupported&&(MediaRecorder.isTypeSupported('video/mp4;codecs="avc1.42E01E, mp4a.40.2"')?e={mimeType:'video/mp4;codecs="avc1.42E01E, mp4a.40.2"'}:MediaRecorder.isTypeSupported("video/webm;codecs=h264")?e={mimeType:"video/webm;codecs=h264"}:MediaRecorder.isTypeSupported("video/webm;codecs=vp9")?e={mimeType:"video/webm;codecs=vp9"}:MediaRecorder.isTypeSupported("video/webm")?e={mimeType:"video/webm"}:MediaRecorder.isTypeSupported("video/mp4")&&(e={mimeType:"video/mp4"})),this.recordedChunks=[],!this.stream){console.error("this.stream is not set, cannot record");return}if(this.stream instanceof Promise){console.error("this.stream has not been awaited, cannot record");return}this.mediaRecorder=new MediaRecorder(this.stream,e),this.startingTimeout=window.setTimeout(()=>{var e,t;this.mediaRecorder||console.error("mediaRecorder is null in timeout"),null===(e=this.mediaRecorder)||void 0===e||e.start(),this.state=a.STATE.STARTED,this.startedAt=Date.now(),this.endedAt=null,null===(t=this.onStarted)||void 0===t||t.call(this)},i?Math.max(Math.max(Date.now(),+i)-Date.now(),0):2e3)}catch(e){this.state=a.STATE.STOPPED,null===(t=this.onStopped)||void 0===t||t.call(this),console.error("Unable to access the camera or microphone!",e),alert(n("Unable to setup camera or microphone!"))}}async stop(){let{dropRecording:e=!1,stopCapture:t=!0}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};var i,n,r=this;if(!a.isSupported())throw Error("Recording is not supported on this device");if(["stopping","stopped"].includes(this.state))return;if(this.state===a.STATE.STARTING)throw Error("Currently starting new recording");this.startingTimeout&&clearTimeout(this.startingTimeout),this.state=a.STATE.STOPPING,null===(i=this.onStopping)||void 0===i||i.call(this);let o=async function(){var e,i,n,o,l;let s=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;null===(e=r.audioInput)||void 0===e||e.disconnect(),null===(i=r.analyser)||void 0===i||i.disconnect(),null===(n=r.audioNode)||void 0===n||n.disconnect(),null===(o=r.audioContext)||void 0===o||o.close(),r.audioContext=null,r.analyser=null,r.audioNode=null,r.audioInput=null,r.mediaRecorder=null,t&&await r.stopCapture(),r.state=a.STATE.STOPPED,r.endedAt=Date.now(),null===(l=r.onStopped)||void 0===l||l.call(r,null!=s?s:void 0)};(null===(n=this.mediaRecorder)||void 0===n?void 0:n.state)!=="recording"||e?await o():(this.mediaRecorder.ondataavailable=async e=>{e.data&&e.data.size>0?await o(e.data):await o()},this.mediaRecorder.stop())}constructor(e){(0,n._)(this,"bufferSize",void 0),(0,n._)(this,"sampleRate",void 0),(0,n._)(this,"startedAt",null),(0,n._)(this,"endedAt",null),(0,n._)(this,"audioContext",null),(0,n._)(this,"analyser",null),(0,n._)(this,"createJavaScriptNode",null),(0,n._)(this,"audioNode",null),(0,n._)(this,"aspectRatio",null),(0,n._)(this,"startingTimeout",null),(0,n._)(this,"onStarting",void 0),(0,n._)(this,"onStopping",void 0),(0,n._)(this,"audioInput",null),(0,n._)(this,"recordedChunks",null),(0,n._)(this,"mediaRecorder",null),(0,n._)(this,"onStarted",void 0),(0,n._)(this,"onStopped",void 0),(0,n._)(this,"stream",null),(0,n._)(this,"state",void 0),(0,n._)(this,"i18n",void 0),this.bufferSize=4096,this.sampleRate=44100,this.state=a.STATE.STOPPED,this.aspectRatio=e.aspectRatio,this.onStarting=e.onStarting,this.onStarted=e.onStarted,this.onStopping=e.onStopping,this.onStopped=e.onStopped,this.i18n=I18N.i(e.language),Object.assign(this,e)}}},70717:function(e,t,i){i.d(t,{w:()=>l});var n=i(16584),r=i(19081),a=i(58175),o=i(84864);let l=e=>{let{duration:t,icon:i,position:l="bottom-left",previewDuration:s}=e;return(0,n.BX)(r.gq,{alignItems:"center",bg:"glass-inverted-medium",gap:6,paddingX:8,paddingY:2,position:"absolute",radius:"sm",style:"bottom-left"===l?{left:8,bottom:8}:{right:8,bottom:8},children:[i,(0,n.tZ)(a.xv.Meta,{color:"white",lineHeight:20,children:s?"".concat((0,o.secondsToHHMMSS)(s)," / ").concat((0,o.secondsToHHMMSS)(null!=t?t:0)):(0,o.secondsToHHMMSS)(null!=t?t:0)})]})}},69791:function(e,t,i){i.d(t,{b:()=>h});var n=i(16584),r=i(94184),a=i.n(r),o=i(71375),l=i(71068),s=i(15771),d=i(19081),c=i(58175),u=i(98866);let h=e=>{let{title:t,description:i,Icon:r,onDismiss:a,theme:o="default",priority:l="tertiary",showClose:s=!0,flex:d="grow"}=e;return(0,n.BX)(f,{theme:o,priority:l,flex:d,children:[r&&(0,n.tZ)(m,{Icon:r}),(0,n.BX)(Z,{children:[(0,n.tZ)(p,{children:t}),i&&(0,n.tZ)(g,{children:i})]}),s&&(0,n.tZ)(v,{onClose:a,priority:l})]})},m=e=>{let{Icon:t}=e;return(0,n.tZ)(y,{children:(0,n.tZ)(t,{size:18,className:u.Z.icon})})},p=e=>{let{children:t}=e;return(0,n.tZ)(c.xv.B4,{weight:"medium",color:"primary",className:u.Z.title,children:t})},g=e=>{let{children:t}=e;return(0,n.tZ)(c.xv.B4,{weight:"regular",color:"secondary",className:u.Z.description,children:t})},v=e=>{let{onClose:t,priority:i}=e;return(0,n.tZ)(y,{children:(0,n.tZ)(s.hU,{priority:"quaternary",onClick:t,size:"xs",children:(0,n.tZ)(o.Z,{size:18,className:a()(u.Z.dismissIcon,u.Z["priority_".concat(i)])})})})},y=(0,l.zo)({display:"flex",alignItems:"center",justifyContent:"center",width:20,height:20}),f=e=>{let{theme:t,priority:i,children:r,flex:o}=e;return(0,n.tZ)(d.X2,{flex:o,gap:12,paddingX:16,paddingY:12,radius:"sm",className:a()(u.Z.alert,u.Z["theme_".concat(t)],u.Z["priority_".concat(i)]),children:r})},Z=(0,l.zo)({display:"flex",direction:"column",flex:"grow",alignItems:"start"})},74134:function(e,t,i){i.d(t,{a:()=>p,i:()=>m});var n=i(7409),r=i(99282),a=i(98848),o=i(16584),l=i(6400),s=i(61254),d=i(19081),c=i(58175),u=i(60308);let h={tableData:"tableData-Yoy3uq",tableRow:"tableRow-p2pp0v",rowLogo:"rowLogo-C959OF",rowInfo:"rowInfo-DS3vUN",rowLink:"rowLink-p8OUuc",podcastDescription:"podcastDescription-a0BlLC",rowHeader:"rowHeader-xKXiQq",rowText:"rowText-V02KAu",editButton:"editButton-rcOodp"},m=e=>{var{children:t,addItem:i}=e,c=(0,a._)(e,["children","addItem"]);let u=(0,l.toChildArray)(t);return(0,o.BX)(d.tu,(0,r._)((0,n._)({gap:16,flex:"fill"},c),{children:[u.map((e,t)=>(0,o.BX)(o.HY,{children:[e,t{let{imgSrc:t,icon:i,href:n,title:r,subtitle:a,action:l}=e;return(0,o.BX)(d.gq,{alignItems:"center",gap:16,children:[t?(0,o.tZ)("img",{className:h.rowLogo,src:(0,u.zF4)(t,144),alt:"".concat(r," logo")}):i?(0,o.tZ)(d.hs,{justifyContent:"center",alignItems:"center",className:h.rowLogo,bg:"secondary",radius:"sm",children:i}):null,(0,o.BX)(d.gq,{alignItems:"center",flex:"grow",gap:12,children:[(0,o.BX)(d.tu,{className:h.rowInfo,justifyContent:"center",children:[(0,o.tZ)(c.xv.B4,{weight:"bold",className:h.rowTitle,children:(0,o.tZ)("a",{className:h.rowLink,href:n,native:!0,children:r})}),(0,o.tZ)(d.gq,{gap:8,alignItems:"center",children:(0,o.tZ)(c.xv.B4,{children:a})})]}),l]})]})}}}]);