@gentbajko/slopify 3.0.1 → 3.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -46,7 +46,7 @@ Error generating stack: `+e.message+`
46
46
  `},Ep=function(){var e=parseInt(document.body.getAttribute(`data-scroll-locked`)||`0`,10);return isFinite(e)?e:0},Dp=function(){m.useEffect(function(){return document.body.setAttribute(wp,(Ep()+1).toString()),function(){var e=Ep()-1;e<=0?document.body.removeAttribute(wp):document.body.setAttribute(wp,e.toString())}},[])},Op=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,i=r===void 0?`margin`:r;Dp();var a=m.useMemo(function(){return Sp(i)},[i]);return m.createElement(Cp,{styles:Tp(a,!t,i,n?``:`!important`)})},kp=!1;if(typeof window<`u`)try{var Ap=Object.defineProperty({},"passive",{get:function(){return kp=!0,!0}});window.addEventListener(`test`,Ap,Ap),window.removeEventListener(`test`,Ap,Ap)}catch{kp=!1}var jp=kp?{passive:!1}:!1,Mp=function(e){return e.tagName===`TEXTAREA`},Np=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!==`hidden`&&!(n.overflowY===n.overflowX&&!Mp(e)&&n[t]===`visible`)},Pp=function(e){return Np(e,`overflowY`)},Fp=function(e){return Np(e,`overflowX`)},Ip=function(e,t){var n=t.ownerDocument,r=t;do{if(typeof ShadowRoot<`u`&&r instanceof ShadowRoot&&(r=r.host),zp(e,r)){var i=Bp(e,r);if(i[1]>i[2])return!0}r=r.parentNode}while(r&&r!==n.body);return!1},Lp=function(e){return[e.scrollTop,e.scrollHeight,e.clientHeight]},Rp=function(e){return[e.scrollLeft,e.scrollWidth,e.clientWidth]},zp=function(e,t){return e===`v`?Pp(t):Fp(t)},Bp=function(e,t){return e===`v`?Lp(t):Rp(t)},Vp=function(e,t){return e===`h`&&t===`rtl`?-1:1},Hp=function(e,t,n,r,i){var a=Vp(e,window.getComputedStyle(t).direction),o=a*r,s=n.target,c=t.contains(s),l=!1,u=o>0,d=0,f=0;do{if(!s)break;var p=Bp(e,s),m=p[0],h=p[1]-p[2]-a*m;(m||h)&&zp(e,s)&&(d+=h,f+=m);var g=s.parentNode;s=g&&g.nodeType===Node.DOCUMENT_FRAGMENT_NODE?g.host:g}while(!c&&s!==document.body||c&&(t.contains(s)||t===s));return(u&&(i&&Math.abs(d)<1||!i&&o>d)||!u&&(i&&Math.abs(f)<1||!i&&-o>f))&&(l=!0),l},Up=function(e){return`changedTouches`in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Wp=function(e){return[e.deltaX,e.deltaY]},Gp=function(e){return e&&`current`in e?e.current:e},Kp=function(e,t){return e[0]===t[0]&&e[1]===t[1]},qp=function(e){return`
47
47
  .block-interactivity-${e} {pointer-events: none;}
48
48
  .allow-interactivity-${e} {pointer-events: all;}
49
- `},Jp=0,Yp=[];function Xp(e){var t=m.useRef([]),n=m.useRef([0,0]),r=m.useRef(),i=m.useState(Jp++)[0],a=m.useState(vp)[0],o=m.useRef(e);m.useEffect(function(){o.current=e},[e]),m.useEffect(function(){if(e.inert){document.body.classList.add(`block-interactivity-${i}`);var t=Jf([e.lockRef.current],(e.shards||[]).map(Gp),!0).filter(Boolean);return t.forEach(function(e){return e.classList.add(`allow-interactivity-${i}`)}),function(){document.body.classList.remove(`block-interactivity-${i}`),t.forEach(function(e){return e.classList.remove(`allow-interactivity-${i}`)})}}},[e.inert,e.lockRef.current,e.shards]);var s=m.useCallback(function(e,t){if(`touches`in e&&e.touches.length===2||e.type===`wheel`&&e.ctrlKey)return!o.current.allowPinchZoom;var i=Up(e),a=n.current,s=`deltaX`in e?e.deltaX:a[0]-i[0],c=`deltaY`in e?e.deltaY:a[1]-i[1],l,u=e.target,d=Math.abs(s)>Math.abs(c)?`h`:`v`;if(`touches`in e&&d===`h`&&u.type===`range`)return!1;var f=window.getSelection(),p=f&&f.anchorNode;if(p&&(p===u||p.contains(u)))return!1;var m=Ip(d,u);if(!m)return!0;if(m?l=d:(l=d===`v`?`h`:`v`,m=Ip(d,u)),!m)return!1;if(!r.current&&`changedTouches`in e&&(s||c)&&(r.current=l),!l)return!0;var h=r.current||l;return Hp(h,t,e,h===`h`?s:c,!0)},[]),c=m.useCallback(function(e){var n=e;if(Yp.length&&Yp[Yp.length-1]===a){var r=`deltaY`in n?Wp(n):Up(n),i=t.current.filter(function(e){return e.name===n.type&&(e.target===n.target||n.target===e.shadowParent)&&Kp(e.delta,r)})[0];if(i&&i.should){n.cancelable&&n.preventDefault();return}if(!i){var c=(o.current.shards||[]).map(Gp).filter(Boolean).filter(function(e){return e.contains(n.target)});(c.length>0?s(n,c[0]):!o.current.noIsolation)&&n.cancelable&&n.preventDefault()}}},[]),l=m.useCallback(function(e,n,r,i){var a={name:e,delta:n,target:r,should:i,shadowParent:Zp(r)};t.current.push(a),setTimeout(function(){t.current=t.current.filter(function(e){return e!==a})},1)},[]),u=m.useCallback(function(e){n.current=Up(e),r.current=void 0},[]),d=m.useCallback(function(t){l(t.type,Wp(t),t.target,s(t,e.lockRef.current))},[]),f=m.useCallback(function(t){l(t.type,Up(t),t.target,s(t,e.lockRef.current))},[]);m.useEffect(function(){return Yp.push(a),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener(`wheel`,c,jp),document.addEventListener(`touchmove`,c,jp),document.addEventListener(`touchstart`,u,jp),function(){Yp=Yp.filter(function(e){return e!==a}),document.removeEventListener(`wheel`,c,jp),document.removeEventListener(`touchmove`,c,jp),document.removeEventListener(`touchstart`,u,jp)}},[]);var p=e.removeScrollBar,h=e.inert;return m.createElement(m.Fragment,null,h?m.createElement(a,{styles:qp(i)}):null,p?m.createElement(Op,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function Zp(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}var Qp=cp(lp,Xp),$p=m.forwardRef(function(e,t){return m.createElement(dp,Kf({},e,{ref:t,sideCar:Qp}))});$p.classNames=dp.classNames;var em=function(e){return typeof document>`u`?null:(Array.isArray(e)?e[0]:e).ownerDocument.body},tm=new WeakMap,nm=new WeakMap,rm={},im=0,am=function(e){return e&&(e.host||am(e.parentNode))},om=function(e,t){return t.map(function(t){if(e.contains(t))return t;var n=am(t);return n&&e.contains(n)?n:(console.error(`aria-hidden`,t,`in not contained inside`,e,`. Doing nothing`),null)}).filter(function(e){return!!e})},sm=function(e,t,n,r){var i=om(t,Array.isArray(e)?e:[e]);rm[n]||(rm[n]=new WeakMap);var a=rm[n],o=[],s=new Set,c=new Set(i),l=function(e){e&&!s.has(e)&&(s.add(e),l(e.parentNode))};i.forEach(l);var u=function(e){e&&!c.has(e)&&Array.prototype.forEach.call(e.children,function(e){if(s.has(e))u(e);else try{var t=e.getAttribute(r),i=t!==null&&t!==`false`,c=(tm.get(e)||0)+1,l=(a.get(e)||0)+1;tm.set(e,c),a.set(e,l),o.push(e),c===1&&i&&nm.set(e,!0),l===1&&e.setAttribute(n,`true`),i||e.setAttribute(r,`true`)}catch(t){console.error(`aria-hidden: cannot operate on `,e,t)}})};return u(t),s.clear(),im++,function(){o.forEach(function(e){var t=tm.get(e)-1,i=a.get(e)-1;tm.set(e,t),a.set(e,i),t||(nm.has(e)||e.removeAttribute(r),nm.delete(e)),i||e.removeAttribute(n)}),im--,im||(tm=new WeakMap,tm=new WeakMap,nm=new WeakMap,rm={})}},cm=function(e,t,n){n===void 0&&(n=`data-aria-hidden`);var r=Array.from(Array.isArray(e)?e:[e]),i=t||em(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll(`[aria-live], script`))),sm(r,i,n,`aria-hidden`)):function(){return null}},lm=Object.defineProperty,um=(e,t)=>lm(e,`name`,{value:t,configurable:!0}),dm=`Dialog`,[fm,tee]=td(dm),[pm,mm]=fm(dm),hm=um(e=>{let{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!0}=e,s=m.useRef(null),c=m.useRef(null),[l,u]=Nd({prop:r,defaultProp:i??!1,onChange:a,caller:dm}),[d,f]=m.useState(0),[p,g]=m.useState(0);return(0,h.jsx)(pm,{scope:t,triggerRef:s,contentRef:c,contentId:Zd(),titleId:Zd(),descriptionId:Zd(),titlePresent:d>0,descriptionPresent:p>0,setTitleCount:f,setDescriptionCount:g,open:l,onOpenChange:u,onOpenToggle:m.useCallback(()=>u(e=>!e),[u]),modal:o,children:n})},`Dialog`),gm=`DialogPortal`,[nee,_m]=fm(gm,{forceMount:void 0}),vm=um(e=>{let{__scopeDialog:t,forceMount:n,children:r,container:i}=e,a=mm(gm,t);return(0,h.jsx)(nee,{scope:t,forceMount:n,children:m.Children.map(r,e=>(0,h.jsx)(Vd,{present:n||a.open,children:(0,h.jsx)(Rf,{asChild:!0,container:i,children:e})}))})},`DialogPortal`),ym=`DialogOverlay`,bm=m.forwardRef(um(function(e,t){let n=_m(ym,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=mm(ym,e.__scopeDialog);return a.modal?(0,h.jsx)(Vd,{present:r||a.open,children:(0,h.jsx)(Sm,{...i,ref:t})}):null},`DialogOverlay`)),xm=Nu(`DialogOverlay.RemoveScroll`),Sm=m.forwardRef(um(function(e,t){let{__scopeDialog:n,...r}=e,i=mm(ym,n),a=Au(t,mf());return(0,h.jsx)($p,{as:xm,allowPinchZoom:!0,shards:[i.contentRef],children:(0,h.jsx)(Xu.div,{"data-state":km(i.open),...r,ref:a,style:{pointerEvents:`auto`,...r.style}})})},`DialogOverlayImpl`)),Cm=`DialogContent`,wm=m.forwardRef(um(function(e,t){let n=_m(Cm,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=mm(Cm,e.__scopeDialog);return(0,h.jsx)(Vd,{present:r||a.open,children:a.modal?(0,h.jsx)(ree,{...i,ref:t}):(0,h.jsx)(iee,{...i,ref:t})})},`DialogContent`)),ree=m.forwardRef(um(function(e,t){let n=mm(Cm,e.__scopeDialog),r=m.useRef(null),i=Au(t,n.contentRef,r);return m.useEffect(()=>{let e=r.current;if(e)return cm(e)},[]),(0,h.jsx)(Tm,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,onCloseAutoFocus:yd(e.onCloseAutoFocus,e=>{e.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:yd(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;(t.button===2||n)&&e.preventDefault()}),onFocusOutside:yd(e.onFocusOutside,e=>e.preventDefault())})},`DialogContentModal`)),iee=m.forwardRef(um(function(e,t){let n=mm(Cm,e.__scopeDialog),r=m.useRef(!1),i=m.useRef(!1);return(0,h.jsx)(Tm,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})},`DialogContentNonModal`)),Tm=m.forwardRef(um(function(e,t){let{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,...o}=e,s=mm(Cm,n);return Wf(),(0,h.jsx)(h.Fragment,{children:(0,h.jsx)(Tf,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,h.jsx)(pf,{role:`dialog`,id:s.contentId,"aria-describedby":s.descriptionPresent?s.descriptionId:void 0,"aria-labelledby":s.titlePresent?s.titleId:void 0,"data-state":km(s.open),...o,ref:t,deferPointerDownOutside:!0,onDismiss:()=>s.onOpenChange(!1)})})})},`DialogContentImpl`)),aee=`DialogTitle`,Em=m.forwardRef(um(function(e,t){let{__scopeDialog:n,...r}=e,i=mm(aee,n),{setTitleCount:a}=i;return wd(()=>(a(e=>e+1),()=>a(e=>e-1)),[a]),(0,h.jsx)(Xu.h2,{id:i.titleId,...r,ref:t})},`DialogTitle`)),oee=`DialogDescription`,see=m.forwardRef(um(function(e,t){let{__scopeDialog:n,...r}=e,i=mm(oee,n),{setDescriptionCount:a}=i;return wd(()=>(a(e=>e+1),()=>a(e=>e-1)),[a]),(0,h.jsx)(Xu.p,{id:i.descriptionId,...r,ref:t})},`DialogDescription`)),Dm=`DialogClose`,Om=m.forwardRef(um(function(e,t){let{__scopeDialog:n,...r}=e,i=mm(Dm,n);return(0,h.jsx)(Xu.button,{type:`button`,...r,ref:t,onClick:yd(e.onClick,()=>i.onOpenChange(!1))})},`DialogClose`));function km(e){return e?`open`:`closed`}um(km,`getState`);var Am=Object.defineProperty,jm=(e,t)=>Am(e,`name`,{value:t,configurable:!0});function Mm(e){let[t,n]=m.useState(void 0);return wd(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});let t=new ResizeObserver(t=>{if(!Array.isArray(t)||!t.length)return;let r=t[0],i,a;if(`borderBoxSize`in r){let e=r.borderBoxSize,t=Array.isArray(e)?e[0]:e;i=t.inlineSize,a=t.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return t.observe(e,{box:`border-box`}),()=>t.unobserve(e)}n(void 0)},[e]),t}jm(Mm,`useSize`);var Nm=[`top`,`right`,`bottom`,`left`],Pm=Math.min,Fm=Math.max,Im=Math.round,Lm=Math.floor,Rm=e=>({x:e,y:e}),cee={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function zm(e,t,n){return Fm(e,Pm(t,n))}function Bm(e,t){return typeof e==`function`?e(t):e}function Vm(e){return e.split(`-`)[0]}function Hm(e){return e.split(`-`)[1]}function Um(e){return e===`x`?`y`:`x`}function Wm(e){return e===`y`?`height`:`width`}function Gm(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function Km(e){return Um(Gm(e))}function qm(e,t,n){n===void 0&&(n=!1);let r=Hm(e),i=Km(e),a=Wm(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=nh(o)),[o,nh(o)]}function Jm(e){let t=nh(e);return[Ym(e),t,Ym(t)]}function Ym(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var Xm=[`left`,`right`],Zm=[`right`,`left`],Qm=[`top`,`bottom`],$m=[`bottom`,`top`];function eh(e,t,n){switch(e){case`top`:case`bottom`:return n?t?Zm:Xm:t?Xm:Zm;case`left`:case`right`:return t?Qm:$m;default:return[]}}function th(e,t,n,r){let i=Hm(e),a=eh(Vm(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(Ym)))),a}function nh(e){let t=Vm(e);return cee[t]+e.slice(t.length)}function rh(e){return{top:e.top??0,right:e.right??0,bottom:e.bottom??0,left:e.left??0}}function ih(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:rh(e)}function ah(e){let{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function oh(e,t,n){let{reference:r,floating:i}=e,a=Gm(t),o=Km(t),s=Wm(o),c=Vm(t),l=a===`y`,u=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=r[s]/2-i[s]/2,p;switch(c){case`top`:p={x:u,y:r.y-i.height};break;case`bottom`:p={x:u,y:r.y+r.height};break;case`right`:p={x:r.x+r.width,y:d};break;case`left`:p={x:r.x-i.width,y:d};break;default:p={x:r.x,y:r.y}}let m=Hm(t);return m&&(p[o]+=f*(m===`end`?1:-1)*(n&&l?-1:1)),p}async function sh(e,t){t===void 0&&(t={});let{x:n,y:r,platform:i,rects:a,elements:o,strategy:s}=e,{boundary:c=`clippingAncestors`,rootBoundary:l=`viewport`,elementContext:u=`floating`,altBoundary:d=!1,padding:f=0}=Bm(t,e),p=ih(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=ah(await i.getClippingRect({element:await(i.isElement==null?void 0:i.isElement(m))??!0?m:m.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(o.floating)),boundary:c,rootBoundary:l,strategy:s})),g=u===`floating`?{x:n,y:r,width:a.floating.width,height:a.floating.height}:a.reference,_=await(i.getOffsetParent==null?void 0:i.getOffsetParent(o.floating)),v=await(i.isElement==null?void 0:i.isElement(_))&&await(i.getScale==null?void 0:i.getScale(_))||{x:1,y:1},y=ah(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:g,offsetParent:_,strategy:s}):g);return{top:(h.top-y.top+p.top)/v.y,bottom:(y.bottom-h.bottom+p.bottom)/v.y,left:(h.left-y.left+p.left)/v.x,right:(y.right-h.right+p.right)/v.x}}var ch=50,lh=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:sh},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=oh(l,r,c),f=r,p=0,m={};for(let n=0;n<a.length;n++){let h=a[n];if(!h)continue;let{name:g,fn:_}=h,{x:v,y,data:b,reset:x}=await _({x:u,y:d,initialPlacement:r,placement:f,strategy:i,middlewareData:m,rects:l,platform:s,elements:{reference:e,floating:t}});u=v??u,d=y??d,m[g]={...m[g],...b},x&&p<ch&&(p++,typeof x==`object`&&(x.placement&&(f=x.placement),x.rects&&(l=x.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):x.rects),{x:u,y:d}=oh(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},uh=e=>({name:`arrow`,options:e,async fn(t){let{x:n,y:r,placement:i,rects:a,platform:o,elements:s,middlewareData:c}=t,{element:l,padding:u=0}=Bm(e,t)||{};if(l==null)return{};let d=ih(u),f={x:n,y:r},p=Km(i),m=Wm(p),h=await o.getDimensions(l),g=p===`y`,_=g?`top`:`left`,v=g?`bottom`:`right`,y=g?`clientHeight`:`clientWidth`,b=a.reference[m]+a.reference[p]-f[p]-a.floating[m],x=f[p]-a.reference[p],S=await(o.getOffsetParent==null?void 0:o.getOffsetParent(l)),C=S?S[y]:0;(!C||!await(o.isElement==null?void 0:o.isElement(S)))&&(C=s.floating[y]||a.floating[m]);let w=b/2-x/2,T=C/2-h[m]/2-1,E=Pm(d[_],T),D=Pm(d[v],T),O=C-h[m]-D,k=C/2-h[m]/2+w,ee=zm(E,k,O),te=!c.arrow&&Hm(i)!=null&&k!==ee&&a.reference[m]/2-(k<E?E:D)-h[m]/2<0,ne=te?k<E?k-E:k-O:0;return{[p]:f[p]+ne,data:{[p]:ee,centerOffset:k-ee-ne,...te&&{alignmentOffset:ne}},reset:te}}}),dh=function(e){return e===void 0&&(e={}),{name:`flip`,options:e,async fn(t){var n;let{placement:r,middlewareData:i,rects:a,initialPlacement:o,platform:s,elements:c}=t,{mainAxis:l=!0,crossAxis:u=!0,fallbackPlacements:d,fallbackStrategy:f=`bestFit`,fallbackAxisSideDirection:p=`none`,flipAlignment:m=!0,...h}=Bm(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=Vm(r),_=Gm(o),v=Vm(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[nh(o)]:Jm(o)),x=p!==`none`;!d&&x&&b.push(...th(o,m,p,y));let S=[o,...b],C=await s.detectOverflow(t,h),w=[],T=i.flip?.overflows||[];if(l&&w.push(C[g]),u){let e=qm(r,a,y);w.push(C[e[0]],C[e[1]])}if(T=[...T,{placement:r,overflows:w}],!w.every(e=>e<=0)){let e=(i.flip?.index||0)+1,t=S[e];if(t&&(u!==`alignment`||_===Gm(t)||T.every(e=>Gm(e.placement)!==_||e.overflows[0]>0)))return{data:{index:e,overflows:T},reset:{placement:t}};let n=T.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0]?.placement;if(!n)switch(f){case`bestFit`:{let e=T.filter(e=>{if(x){let t=Gm(e.placement);return t===_||t===`y`}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0]?.[0];e&&(n=e);break}case`initialPlacement`:n=o}if(r!==n)return{reset:{placement:n}}}return{}}}};function fh(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function ph(e){return Nm.some(t=>e[t]>=0)}var mh=function(e){return e===void 0&&(e={}),{name:`hide`,options:e,async fn(t){let{rects:n,platform:r}=t,{strategy:i=`referenceHidden`,...a}=Bm(e,t);switch(i){case`referenceHidden`:{let e=fh(await r.detectOverflow(t,{...a,elementContext:`reference`}),n.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:ph(e)}}}case`escaped`:{let e=fh(await r.detectOverflow(t,{...a,altBoundary:!0}),n.floating);return{data:{escapedOffsets:e,escaped:ph(e)}}}default:return{}}}}},hh=new Set([`left`,`top`]);async function gh(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=Vm(n),s=Hm(n),c=Gm(n)===`y`,l=hh.has(o)?-1:1,u=a&&c?-1:1,d=Bm(t,e),{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d==`number`?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof m==`number`&&(p=s===`end`?m*-1:m),c?{x:p*u,y:f*l}:{x:f*l,y:p*u}}var _h=function(e){return e===void 0&&(e=0),{name:`offset`,options:e,async fn(t){var n;let{x:r,y:i,placement:a,middlewareData:o}=t,s=await gh(t,e);return a===o.offset?.placement&&(n=o.arrow)!=null&&n.alignmentOffset?{}:{x:r+s.x,y:i+s.y,data:{...s,placement:a}}}}},vh=function(e){return e===void 0&&(e={}),{name:`shift`,options:e,async fn(t){let{x:n,y:r,placement:i,platform:a}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:c={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...l}=Bm(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=Gm(i),p=Um(f),m=u[p],h=u[f],g=(e,t)=>zm(t+d[e===`y`?`top`:`left`],t,t-d[e===`y`?`bottom`:`right`]);o&&(m=g(p,m)),s&&(h=g(f,h));let _=c.fn({...t,[p]:m,[f]:h});return{..._,data:{x:_.x-n,y:_.y-r,enabled:{[p]:o,[f]:s}}}}}},yh=function(e){return e===void 0&&(e={}),{options:e,fn(t){let{x:n,y:r,placement:i,rects:a,middlewareData:o}=t,{offset:s=0,mainAxis:c=!0,crossAxis:l=!0}=Bm(e,t),u={x:n,y:r},d=Gm(i),f=Um(d),p=u[f],m=u[d],h=Bm(s,t),g=typeof h==`number`?{mainAxis:h,crossAxis:0}:{mainAxis:h.mainAxis??0,crossAxis:h.crossAxis??0};if(c){let e=f===`y`?`height`:`width`,t=a.reference[f]-a.floating[e]+g.mainAxis,n=a.reference[f]+a.reference[e]-g.mainAxis;p<t?p=t:p>n&&(p=n)}if(l){let e=f===`y`?`width`:`height`,t=hh.has(Vm(i)),n=a.reference[d]-a.floating[e]+(t&&o.offset?.[d]||0)+(t?0:g.crossAxis),r=a.reference[d]+a.reference[e]+(t?0:o.offset?.[d]||0)-(t?g.crossAxis:0);m<n?m=n:m>r&&(m=r)}return{[f]:p,[d]:m}}}},bh=function(e){return e===void 0&&(e={}),{name:`size`,options:e,async fn(t){let{placement:n,rects:r,platform:i,elements:a}=t,{apply:o=()=>{},...s}=Bm(e,t),c=await i.detectOverflow(t,s),l=Vm(n),u=Hm(n),d=Gm(n)===`y`,{width:f,height:p}=r.floating,m,h;l===`top`||l===`bottom`?(m=l,h=u===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?`start`:`end`)?`left`:`right`):(h=l,m=u===`end`?`top`:`bottom`);let g=p-c.top-c.bottom,_=f-c.left-c.right,v=Pm(p-c[m],g),y=Pm(f-c[h],_),b=t.middlewareData.shift,x=!b,S=v,C=y;b!=null&&b.enabled.x&&(C=_),b!=null&&b.enabled.y&&(S=g),x&&!u&&(d?C=f-2*Fm(c.left,c.right):S=p-2*Fm(c.top,c.bottom)),await o({...t,availableWidth:C,availableHeight:S});let w=await i.getDimensions(a.floating);return f!==w.width||p!==w.height?{reset:{rects:!0}}:{}}}};function xh(){return typeof window<`u`}function Sh(e){return Th(e)?(e.nodeName||``).toLowerCase():`#document`}function Ch(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function wh(e){return((Th(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function Th(e){return xh()?e instanceof Node||e instanceof Ch(e).Node:!1}function Eh(e){return xh()?e instanceof Element||e instanceof Ch(e).Element:!1}function Dh(e){return xh()?e instanceof HTMLElement||e instanceof Ch(e).HTMLElement:!1}function Oh(e){return!xh()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof Ch(e).ShadowRoot}function kh(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=zh(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function lee(e){return/^(table|td|th)$/.test(Sh(e))}function Ah(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var jh=/transform|translate|scale|rotate|perspective|filter/,Mh=/paint|layout|strict|content/,Nh=e=>!!e&&e!==`none`,Ph;function Fh(e){let t=Eh(e)?zh(e):e;return Nh(t.transform)||Nh(t.translate)||Nh(t.scale)||Nh(t.rotate)||Nh(t.perspective)||!Lh()&&(Nh(t.backdropFilter)||Nh(t.filter))||jh.test(t.willChange||``)||Mh.test(t.contain||``)}function Ih(e){let t=Vh(e);for(;Dh(t)&&!Rh(t);){if(Fh(t))return t;if(Ah(t))return null;t=Vh(t)}return null}function Lh(){return Ph??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),Ph}function Rh(e){return/^(html|body|#document)$/.test(Sh(e))}function zh(e){return Ch(e).getComputedStyle(e)}function Bh(e){return Eh(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Vh(e){if(Sh(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||Oh(e)&&e.host||wh(e);return Oh(t)?t.host:t}function Hh(e){let t=Vh(e);return Rh(t)?(e.ownerDocument||e).body:Dh(t)&&kh(t)?t:Hh(t)}function Uh(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=Hh(e),i=r===e.ownerDocument?.body,a=Ch(r);if(i){let e=Wh(a);return t.concat(a,a.visualViewport||[],kh(r)?r:[],e&&n?Uh(e):[])}return t.concat(r,Uh(r,[],n))}function Wh(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Gh(e){let t=zh(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=Dh(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=Im(n)!==a||Im(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function Kh(e){return Eh(e)?e:e.contextElement}function qh(e){let t=Kh(e);if(!Dh(t))return Rm(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=Gh(t),o=(a?Im(n.width):n.width)/r,s=(a?Im(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!s||!Number.isFinite(s))&&(s=1),{x:o,y:s}}var Jh=Rm(0);function Yh(e){let t=Ch(e);return!Lh()||!t.visualViewport?Jh:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Xh(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===Ch(e)}function Zh(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=Kh(e),o=Rm(1);t&&(r?Eh(r)&&(o=qh(r)):o=qh(e));let s=Xh(a,n,r)?Yh(a):Rm(0),c=(i.left+s.x)/o.x,l=(i.top+s.y)/o.y,u=i.width/o.x,d=i.height/o.y;if(a&&r){let e=Ch(a),t=Eh(r)?Ch(r):r,n=e,i=Wh(n);for(;i&&t!==n;){let e=qh(i),t=i.getBoundingClientRect(),r=zh(i),a=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,o=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;c*=e.x,l*=e.y,u*=e.x,d*=e.y,c+=a,l+=o,n=Ch(i),i=Wh(n)}}return ah({width:u,height:d,x:c,y:l})}function Qh(e,t){let n=Bh(e).scrollLeft;return t?t.left+n:Zh(wh(e)).left+n}function $h(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-Qh(e,n),y:n.top+t.scrollTop}}function eg(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=wh(r),s=t?Ah(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=Rm(1),u=Rm(0),d=Dh(r);if((d||!a)&&((Sh(r)!==`body`||kh(o))&&(c=Bh(r)),d)){let e=Zh(r);l=qh(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?$h(o,c):Rm(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x+f.x,y:n.y*l.y-c.scrollTop*l.y+u.y+f.y}}function tg(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function ng(e){let t=Bh(e),n=e.ownerDocument.body,r=Fm(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),i=Fm(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight),a=-t.scrollLeft+Qh(e),o=-t.scrollTop;return zh(n).direction===`rtl`&&(a+=Fm(e.clientWidth,n.clientWidth)-r),{width:r,height:i,x:a,y:o}}var rg=25;function ig(e,t,n){n===void 0&&(n=`viewport`);let r=n===`layoutViewport`,i=Ch(e),a=wh(e),o=i.visualViewport,s=a.clientWidth,c=a.clientHeight,l=0,u=0;if(o){let e=!Lh()||t===`fixed`;r?e||(l=-o.offsetLeft,u=-o.offsetTop):(s=o.width,c=o.height,e&&(l=o.offsetLeft,u=o.offsetTop))}if(Qh(a)<=0){let e=a.ownerDocument,t=e.body,n=getComputedStyle(t),r=e.compatMode===`CSS1Compat`&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,i=Math.abs(a.clientWidth-t.clientWidth-r),o=getComputedStyle(a).scrollbarGutter===`stable both-edges`?i/2:i;o<=rg&&(s-=o)}return{width:s,height:c,x:l,y:u}}function ag(e,t){let n=Zh(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=qh(e);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function og(e,t,n){let r;if(t===`viewport`||t===`layoutViewport`)r=ig(e,n,t);else if(t===`document`)r=ng(wh(e));else if(Eh(t))r=ag(t,n);else{let n=Yh(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return ah(r)}function sg(e,t){let n=t.get(e);if(n)return n;let r=Uh(e,[],!1).filter(e=>Eh(e)&&Sh(e)!==`body`),i=null,a=zh(e).position===`fixed`,o=a?Vh(e):e;for(;Eh(o)&&!Rh(o);){let e=zh(o),t=Fh(o),n=i?i.position:a?`fixed`:``;!t&&(n===`fixed`||n===`absolute`&&e.position===`static`)?r=r.filter(e=>e!==o):i=e,o=Vh(o)}return t.set(e,r),r}function cg(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?Ah(t)?[]:sg(t,this._c):[].concat(n),r],o=og(t,a[0],i),s=o.top,c=o.right,l=o.bottom,u=o.left;for(let e=1;e<a.length;e++){let n=og(t,a[e],i);s=Fm(n.top,s),c=Pm(n.right,c),l=Pm(n.bottom,l),u=Fm(n.left,u)}return{width:c-u,height:l-s,x:u,y:s}}function lg(e){let{width:t,height:n}=Gh(e);return{width:t,height:n}}function ug(e,t,n){let r=Dh(t),i=wh(t),a=n===`fixed`,o=Zh(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=Rm(0);if((r||!a)&&((Sh(t)!==`body`||kh(i))&&(s=Bh(t)),r)){let e=Zh(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}!r&&i&&(c.x=Qh(i));let l=i&&!r&&!a?$h(i,s):Rm(0);return{x:o.left+s.scrollLeft-c.x-l.x,y:o.top+s.scrollTop-c.y-l.y,width:o.width,height:o.height}}function dg(e){return zh(e).position===`static`}function fg(e,t){if(!Dh(e)||zh(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return wh(e)===n&&(n=n.ownerDocument.body),n}function pg(e,t){let n=Ch(e);if(Ah(e))return n;if(!Dh(e)){let t=Vh(e);for(;t&&!Rh(t);){if(Eh(t)&&!dg(t))return t;t=Vh(t)}return n}let r=fg(e,t);for(;r&&lee(r)&&dg(r);)r=fg(r,t);return r&&Rh(r)&&dg(r)&&!Fh(r)?n:r||Ih(e)||n}var mg=async function(e){let t=this.getOffsetParent||pg,n=this.getDimensions,r=await n(e.floating);return{reference:ug(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function hg(e){return zh(e).direction===`rtl`}var gg={convertOffsetParentRelativeRectToViewportRelativeRect:eg,getDocumentElement:wh,getClippingRect:cg,getOffsetParent:pg,getElementRects:mg,getClientRects:tg,getDimensions:lg,getScale:qh,isElement:Eh,isRTL:hg};function _g(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function vg(e,t,n){let r=null,i,a=wh(e);function o(){var e;clearTimeout(i),(e=r)==null||e.disconnect(),r=null}function s(n,c){n===void 0&&(n=!1),c===void 0&&(c=1),o();let l=e.getBoundingClientRect(),{left:u,top:d,width:f,height:p}=l;if(n||t(),!f||!p)return;let m=Lm(d),h=Lm(a.clientWidth-(u+f)),g=Lm(a.clientHeight-(d+p)),_=Lm(u),v={rootMargin:-m+`px `+-h+`px `+-g+`px `+-_+`px`,threshold:Fm(0,Pm(1,c))||1},y=!0;function b(t){let n=t[0].intersectionRatio;if(!_g(l,e.getBoundingClientRect()))return s();if(n!==c){if(!y)return s();n?s(!1,n):i=setTimeout(()=>{s(!1,1e-7)},1e3)}y=!1}try{r=new IntersectionObserver(b,{...v,root:a.ownerDocument})}catch{r=new IntersectionObserver(b,v)}r.observe(e)}let c=Ch(e),l=()=>s(n);return c.addEventListener(`resize`,l),s(!0),()=>{c.removeEventListener(`resize`,l),o()}}function yg(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver==`function`,layoutShift:s=typeof IntersectionObserver==`function`,animationFrame:c=!1}=r,l=Kh(e),u=i||a?[...l?Uh(l):[],...t?Uh(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n),a&&e.addEventListener(`resize`,n)});let d=l&&s?vg(l,n,a):null,f=-1,p=null;o&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===l&&p&&t&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;(e=p)==null||e.observe(t)})),n()}),l&&!c&&p.observe(l),t&&p.observe(t));let m,h=c?Zh(e):null;c&&g();function g(){let t=Zh(e);h&&!_g(h,t)&&n(),h=t,m=requestAnimationFrame(g)}return n(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener(`scroll`,n),a&&e.removeEventListener(`resize`,n)}),d?.(),(e=p)==null||e.disconnect(),p=null,c&&cancelAnimationFrame(m)}}var bg=_h,xg=vh,Sg=dh,Cg=bh,wg=mh,Tg=uh,Eg=yh,Dg=(e,t,n)=>{let r=new Map,i=n??{},a={...gg,...i.platform,_c:r};return lh(e,t,{...i,platform:a})},Og=typeof document<`u`?m.useLayoutEffect:function(){};function kg(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e==`function`&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e==`object`){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!kg(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){let n=i[r];if(!(n===`_owner`&&e.$$typeof)&&!kg(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function Ag(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function jg(e,t){let n=Ag(e);return Math.round(t*n)/n}function Mg(e){let t=m.useRef(e);return Og(()=>{t.current=e}),t}function uee(e){e===void 0&&(e={});let{placement:t=`bottom`,strategy:n=`absolute`,middleware:r=[],platform:i,elements:{reference:a,floating:o}={},transform:s=!0,whileElementsMounted:c,open:l}=e,[u,d]=m.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,p]=m.useState(r);kg(f,r)||p(r);let[h,g]=m.useState(null),[_,v]=m.useState(null),y=m.useCallback(e=>{e!==C.current&&(C.current=e,g(e))},[]),b=m.useCallback(e=>{e!==w.current&&(w.current=e,v(e))},[]),x=a||h,S=o||_,C=m.useRef(null),w=m.useRef(null),T=m.useRef(u),E=c!=null,D=Mg(c),O=Mg(i),k=Mg(l),ee=m.useCallback(()=>{if(!C.current||!w.current)return;let e={placement:t,strategy:n,middleware:f};O.current&&(e.platform=O.current),Dg(C.current,w.current,e).then(e=>{let t={...e,isPositioned:k.current!==!1};te.current&&!kg(T.current,t)&&(T.current=t,qu.flushSync(()=>{d(t)}))})},[f,t,n,O,k]);Og(()=>{l===!1&&T.current.isPositioned&&(T.current.isPositioned=!1,d(e=>({...e,isPositioned:!1})))},[l]);let te=m.useRef(!1);Og(()=>(te.current=!0,()=>{te.current=!1}),[]),Og(()=>{if(x&&(C.current=x),S&&(w.current=S),x&&S){if(D.current)return D.current(x,S,ee);ee()}},[x,S,ee,D,E]);let ne=m.useMemo(()=>({reference:C,floating:w,setReference:y,setFloating:b}),[y,b]),re=m.useMemo(()=>({reference:x,floating:S}),[x,S]),A=m.useMemo(()=>{let e={position:n,left:0,top:0};if(!re.floating)return e;let t=jg(re.floating,u.x),r=jg(re.floating,u.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...Ag(re.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,s,re.floating,u.x,u.y]);return m.useMemo(()=>({...u,update:ee,refs:ne,elements:re,floatingStyles:A}),[u,ee,ne,re,A])}var dee=e=>{function t(e){return{}.hasOwnProperty.call(e,`current`)}return{name:`arrow`,options:e,fn(n){let{element:r,padding:i}=typeof e==`function`?e(n):e;return r&&t(r)?r.current==null?{}:Tg({element:r.current,padding:i}).fn(n):r?Tg({element:r,padding:i}).fn(n):{}}}},fee=(e,t)=>{let n=bg(e);return{name:n.name,fn:n.fn,options:[e,t]}},pee=(e,t)=>{let n=xg(e);return{name:n.name,fn:n.fn,options:[e,t]}},mee=(e,t)=>({fn:Eg(e).fn,options:[e,t]}),hee=(e,t)=>{let n=Sg(e);return{name:n.name,fn:n.fn,options:[e,t]}},gee=(e,t)=>{let n=Cg(e);return{name:n.name,fn:n.fn,options:[e,t]}},_ee=(e,t)=>{let n=wg(e);return{name:n.name,fn:n.fn,options:[e,t]}},vee=(e,t)=>{let n=dee(e);return{name:n.name,fn:n.fn,options:[e,t]}},yee=Object.defineProperty,Ng=(e,t)=>yee(e,`name`,{value:t,configurable:!0}),Pg=`Popper`,[Fg,Ig]=td(Pg),[bee,Lg]=Fg(Pg),xee=Ng(e=>{let{__scopePopper:t,children:n}=e,[r,i]=m.useState(null),[a,o]=m.useState(void 0);return(0,h.jsx)(bee,{scope:t,anchor:r,onAnchorChange:i,placementState:a,setPlacementState:o,children:n})},`Popper`),See=`PopperAnchor`,Cee=m.forwardRef(Ng(function(e,t){let{__scopePopper:n,virtualRef:r,...i}=e,a=Lg(See,n),o=m.useRef(null),s=a.onAnchorChange,c=Au(t,m.useCallback(e=>{o.current=e,e&&s(e)},[s])),l=m.useRef(null);m.useEffect(()=>{if(!r)return;let e=l.current;l.current=r.current,e!==l.current&&s(l.current)});let u=a.placementState&&Bg(a.placementState),d=u?.[0],f=u?.[1];return r?null:(0,h.jsx)(Xu.div,{"data-radix-popper-side":d,"data-radix-popper-align":f,...i,ref:c})},`PopperAnchor`)),Rg=`PopperContent`,[wee,Tee]=Fg(Rg),Eee=m.forwardRef(Ng(function(e,t){let{__scopePopper:n,side:r=`bottom`,sideOffset:i=0,align:a=`center`,alignOffset:o=0,arrowPadding:s=0,avoidCollisions:c=!0,collisionBoundary:l=[],collisionPadding:u=0,sticky:d=`partial`,hideWhenDetached:f=!1,updatePositionStrategy:p=`optimized`,onPlaced:g,..._}=e,v=Lg(Rg,n),[y,b]=m.useState(null),x=Au(t,b),[S,C]=m.useState(null),w=Mm(S),T=w?.width??0,E=w?.height??0,D=r+(a===`center`?``:`-`+a),O=typeof u==`number`?u:{top:0,right:0,bottom:0,left:0,...u},k=Array.isArray(l)?l:[l],ee=k.length>0,te={padding:O,boundary:k.filter(zg),altBoundary:ee},{refs:ne,floatingStyles:re,placement:A,isPositioned:ie,middlewareData:j}=uee({strategy:`fixed`,placement:D,whileElementsMounted:Ng((...e)=>yg(...e,{animationFrame:p===`always`}),`whileElementsMounted`),elements:{reference:v.anchor},middleware:[fee({mainAxis:i+E,alignmentAxis:o}),c&&pee({mainAxis:!0,crossAxis:!1,limiter:d===`partial`?mee():void 0,...te}),c&&hee({...te}),gee({...te,apply:Ng(({elements:e,rects:t,availableWidth:n,availableHeight:r})=>{let{width:i,height:a}=t.reference,o=e.floating.style;o.setProperty(`--radix-popper-available-width`,`${n}px`),o.setProperty(`--radix-popper-available-height`,`${r}px`),o.setProperty(`--radix-popper-anchor-width`,`${i}px`),o.setProperty(`--radix-popper-anchor-height`,`${a}px`)},`apply`)}),S&&vee({element:S,padding:s}),Dee({arrowWidth:T,arrowHeight:E}),f&&_ee({strategy:`referenceHidden`,...te,boundary:ee?te.boundary:void 0})]}),ae=v.setPlacementState;wd(()=>(ae(A),()=>{ae(void 0)}),[A,ae]);let[oe,se]=Bg(A),ce=af(g);wd(()=>{ie&&ce?.()},[ie,ce]);let le=j.arrow?.x,ue=j.arrow?.y,de=j.arrow?.centerOffset!==0,[fe,pe]=m.useState();return wd(()=>{y&&pe(window.getComputedStyle(y).zIndex)},[y]),(0,h.jsx)(`div`,{ref:ne.setFloating,"data-radix-popper-content-wrapper":``,style:{...re,transform:ie?re.transform:`translate(0, -200%)`,minWidth:`max-content`,zIndex:fe,"--radix-popper-transform-origin":[j.transformOrigin?.x,j.transformOrigin?.y].join(` `),...j.hide?.referenceHidden&&{visibility:`hidden`,pointerEvents:`none`}},dir:e.dir,children:(0,h.jsx)(wee,{scope:n,placedSide:oe,placedAlign:se,onArrowChange:C,arrowX:le,arrowY:ue,shouldHideArrow:de,children:(0,h.jsx)(Xu.div,{"data-side":oe,"data-align":se,..._,ref:x,style:{..._.style,animation:ie?_.style?.animation:`none`}})})})},`PopperContent`));function zg(e){return e!==null}Ng(zg,`isNotNull`);var Dee=Ng(e=>({name:`transformOrigin`,options:e,fn(t){let{placement:n,rects:r,middlewareData:i}=t,a=i.arrow?.centerOffset!==0,o=a?0:e.arrowWidth,s=a?0:e.arrowHeight,[c,l]=Bg(n),u={start:`0%`,center:`50%`,end:`100%`}[l],d=(i.arrow?.x??0)+o/2,f=(i.arrow?.y??0)+s/2,p=``,m=``;return c===`bottom`?(p=a?u:`${d}px`,m=`${-s}px`):c===`top`?(p=a?u:`${d}px`,m=`${r.floating.height+s}px`):c===`right`?(p=`${-s}px`,m=a?u:`${f}px`):c===`left`&&(p=`${r.floating.width+s}px`,m=a?u:`${f}px`),{data:{x:p,y:m}}}}),`transformOrigin`);function Bg(e){let[t,n=`center`]=e.split(`-`);return[t,n]}Ng(Bg,`getSideAndAlignFromPlacement`);var Vg=xee,Hg=Cee,Ug=Eee,Wg=Object.defineProperty,Gg=(e,t)=>Wg(e,`name`,{value:t,configurable:!0}),Kg=!1;function qg(){let[e,t]=m.useState(Kg);return m.useEffect(()=>{Kg||(Kg=!0,t(!0))},[]),e}Gg(qg,`useIsHydrated`);var Jg=m.useSyncExternalStore;function Yg(){return()=>{}}Gg(Yg,`subscribe`);function Xg(){return Jg(Yg,()=>!0,()=>!1)}Gg(Xg,`useIsHydratedModern`);var Zg=typeof Jg==`function`?Xg:qg,Qg=Object.defineProperty,$g=(e,t)=>Qg(e,`name`,{value:t,configurable:!0}),e_=`rovingFocusGroup.onEntryFocus`,t_={bubbles:!1,cancelable:!0},n_=`RovingFocusGroup`,[r_,i_,a_]=ad(n_),[o_,s_]=td(n_,[a_]),[c_,l_]=o_(n_),u_=m.forwardRef($g(function(e,t){return(0,h.jsx)(r_.Provider,{scope:e.__scopeRovingFocusGroup,children:(0,h.jsx)(r_.Slot,{scope:e.__scopeRovingFocusGroup,children:(0,h.jsx)(d_,{...e,ref:t})})})},`RovingFocusGroup`)),d_=m.forwardRef($g(function(e,t){let{__scopeRovingFocusGroup:n,orientation:r,loop:i=!1,dir:a,currentTabStopId:o,defaultCurrentTabStopId:s,onCurrentTabStopIdChange:c,onEntryFocus:l,preventScrollOnEntryFocus:u=!1,...d}=e,f=m.useRef(null),p=Au(t,f),g=tf(a),[_,v]=Nd({prop:o,defaultProp:s??null,onChange:c,caller:n_}),[y,b]=m.useState(!1),x=af(l),S=i_(n),C=m.useRef(!1),[w,T]=m.useState(0);return m.useEffect(()=>{let e=f.current;if(e)return e.addEventListener(e_,x),()=>e.removeEventListener(e_,x)},[x]),(0,h.jsx)(c_,{scope:n,orientation:r,dir:g,loop:i,currentTabStopId:_,onItemFocus:m.useCallback(e=>v(e),[v]),onItemShiftTab:m.useCallback(()=>b(!0),[]),onFocusableItemAdd:m.useCallback(()=>T(e=>e+1),[]),onFocusableItemRemove:m.useCallback(()=>T(e=>e-1),[]),children:(0,h.jsx)(Xu.div,{tabIndex:y||w===0?-1:0,"data-orientation":r,...d,ref:p,style:{outline:`none`,...e.style},onMouseDown:yd(e.onMouseDown,()=>{C.current=!0}),onFocus:yd(e.onFocus,e=>{let t=!C.current;if(e.target===e.currentTarget&&t&&!y){let t=new CustomEvent(e_,t_);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){let e=S().filter(e=>e.focusable);__([e.find(e=>e.active),e.find(e=>e.id===_),...e].filter(Boolean).map(e=>e.ref.current),u)}}C.current=!1}),onBlur:yd(e.onBlur,()=>b(!1))})})},`RovingFocusGroupImpl`)),f_=`RovingFocusGroupItem`,p_=m.forwardRef($g(function(e,t){let{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:a,children:o,...s}=e,c=Zd(),l=a||c,u=l_(f_,n),d=u.currentTabStopId===l,f=i_(n),{onFocusableItemAdd:p,onFocusableItemRemove:g,currentTabStopId:_}=u,v=Zg();return wd(()=>{if(v&&r)return p(),()=>g()},[v,r,p,g]),m.useEffect(()=>{if(!v&&r)return p(),()=>g()},[v,r,p,g]),(0,h.jsx)(r_.ItemSlot,{scope:n,id:l,focusable:r,active:i,children:(0,h.jsx)(Xu.span,{tabIndex:d?0:-1,"data-orientation":u.orientation,...s,ref:t,onMouseDown:yd(e.onMouseDown,e=>{r?u.onItemFocus(l):e.preventDefault()}),onFocus:yd(e.onFocus,()=>u.onItemFocus(l)),onKeyDown:yd(e.onKeyDown,e=>{if(e.key===`Tab`&&e.shiftKey){u.onItemShiftTab();return}if(e.target!==e.currentTarget)return;let t=g_(e,u.orientation,u.dir);if(t!==void 0){if(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault();let n=f().filter(e=>e.focusable).map(e=>e.ref.current);if(t===`last`)n.reverse();else if(t===`prev`||t===`next`){t===`prev`&&n.reverse();let r=n.indexOf(e.currentTarget);n=u.loop?v_(n,r+1):n.slice(r+1)}setTimeout(()=>__(n))}}),children:typeof o==`function`?o({isCurrentTabStop:d,hasTabStop:_!=null}):o})})},`RovingFocusGroupItem`)),m_={ArrowLeft:`prev`,ArrowUp:`prev`,ArrowRight:`next`,ArrowDown:`next`,PageUp:`first`,Home:`first`,PageDown:`last`,End:`last`};function h_(e,t){return t===`rtl`?e===`ArrowLeft`?`ArrowRight`:e===`ArrowRight`?`ArrowLeft`:e:e}$g(h_,`getDirectionAwareKey`);function g_(e,t,n){let r=h_(e.key,n);if(!(t===`vertical`&&[`ArrowLeft`,`ArrowRight`].includes(r))&&!(t===`horizontal`&&[`ArrowUp`,`ArrowDown`].includes(r)))return m_[r]}$g(g_,`getFocusIntent`);function __(e,t=!1){let n=document.activeElement;for(let r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}$g(__,`focusFirst`);function v_(e,t){return e.map((n,r)=>e[(t+r)%e.length])}$g(v_,`wrapArray`);var y_=u_,b_=p_,x_=Object.defineProperty,S_=(e,t)=>x_(e,`name`,{value:t,configurable:!0}),C_=[`Enter`,` `],w_=[`ArrowDown`,`PageUp`,`Home`],T_=[`ArrowUp`,`PageDown`,`End`],E_=[...w_,...T_];[...C_],[...C_];var D_=`Menu`,[O_,k_,A_]=ad(D_),[j_,M_]=td(D_,[A_,Ig,s_]),N_=Ig(),P_=s_(),[F_,I_]=j_(D_),[L_,R_]=j_(D_),z_=S_(e=>{let{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:a,modal:o=!0}=e,s=N_(t),[c,l]=m.useState(null),u=m.useRef(!1),d=af(a),f=tf(i);return m.useEffect(()=>{let e=S_(()=>{u.current=!0,document.addEventListener(`pointerdown`,t,{capture:!0,once:!0}),document.addEventListener(`pointermove`,t,{capture:!0,once:!0})},`handleKeyDown`),t=S_(()=>u.current=!1,`handlePointer`);return document.addEventListener(`keydown`,e,{capture:!0}),()=>{document.removeEventListener(`keydown`,e,{capture:!0}),document.removeEventListener(`pointerdown`,t,{capture:!0}),document.removeEventListener(`pointermove`,t,{capture:!0})}},[]),m.useEffect(()=>{if(!n)return;let e=S_(()=>d(!1),`handleBlur`);return window.addEventListener(`blur`,e),()=>window.removeEventListener(`blur`,e)},[n,d]),(0,h.jsx)(Vg,{...s,children:(0,h.jsx)(F_,{scope:t,open:n,onOpenChange:d,content:c,onContentChange:l,children:(0,h.jsx)(L_,{scope:t,onClose:m.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:f,modal:o,children:r})})})},`Menu`),B_=m.forwardRef(S_(function(e,t){let{__scopeMenu:n,...r}=e,i=N_(n);return(0,h.jsx)(Hg,{...i,...r,ref:t})},`MenuAnchor`)),V_=`MenuPortal`,[H_,U_]=j_(V_,{forceMount:void 0}),W_=S_(e=>{let{__scopeMenu:t,forceMount:n,children:r,container:i}=e,a=I_(V_,t);return(0,h.jsx)(H_,{scope:t,forceMount:n,children:(0,h.jsx)(Vd,{present:n||a.open,children:(0,h.jsx)(Rf,{asChild:!0,container:i,children:r})})})},`MenuPortal`),G_=`MenuContent`,[K_,q_]=j_(G_),J_=m.forwardRef(S_(function(e,t){let n=U_(G_,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=I_(G_,e.__scopeMenu),o=R_(G_,e.__scopeMenu);return(0,h.jsx)(O_.Provider,{scope:e.__scopeMenu,children:(0,h.jsx)(Vd,{present:r||a.open,children:(0,h.jsx)(O_.Slot,{scope:e.__scopeMenu,children:o.modal?(0,h.jsx)(Y_,{...i,ref:t}):(0,h.jsx)(X_,{...i,ref:t})})})})},`MenuContent`)),Y_=m.forwardRef(S_(function(e,t){let n=I_(G_,e.__scopeMenu),r=m.useRef(null),i=Au(t,r);return m.useEffect(()=>{let e=r.current;if(e)return cm(e)},[]),(0,h.jsx)(Q_,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:yd(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})},`MenuRootContentModal`)),X_=m.forwardRef(S_(function(e,t){let n=I_(G_,e.__scopeMenu);return(0,h.jsx)(Q_,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})},`MenuRootContentNonModal`)),Z_=Nu(`MenuContent.ScrollLock`),Q_=m.forwardRef(S_(function(e,t){let{__scopeMenu:n,loop:r=!1,trapFocus:i,onOpenAutoFocus:a,onCloseAutoFocus:o,disableOutsidePointerEvents:s,onEntryFocus:c,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,disableOutsideScroll:g,..._}=e,v=I_(G_,n),y=R_(G_,n),b=N_(n),x=P_(n),S=k_(n),[C,w]=m.useState(null),T=m.useRef(null),E=Au(t,T,v.onContentChange),D=m.useRef(0),O=m.useRef(``),k=m.useRef(0),ee=m.useRef(null),te=m.useRef(`right`),ne=m.useRef(0),re=g?$p:m.Fragment,A=g?{as:Z_,allowPinchZoom:!0}:void 0,ie=S_(e=>{let t=O.current+e,n=S().filter(e=>!e.disabled),r=document.activeElement,i=n.find(e=>e.ref.current===r)?.textValue,a=lv(n.map(e=>e.textValue),t,i),o=n.find(e=>e.textValue===a)?.ref.current;S_((function e(t){O.current=t,window.clearTimeout(D.current),t!==``&&(D.current=window.setTimeout(()=>e(``),1e3))}),`updateSearch`)(t),o&&setTimeout(()=>o.focus())},`handleTypeaheadSearch`);m.useEffect(()=>()=>window.clearTimeout(D.current),[]),Wf();let j=m.useCallback(e=>te.current===ee.current?.side&&dv(e,ee.current?.area),[]);return(0,h.jsx)(K_,{scope:n,searchRef:O,onItemEnter:m.useCallback(e=>{j(e)&&e.preventDefault()},[j]),onItemLeave:m.useCallback(e=>{j(e)||(T.current?.focus(),w(null))},[j]),onTriggerLeave:m.useCallback(e=>{j(e)&&e.preventDefault()},[j]),pointerGraceTimerRef:k,onPointerGraceIntentChange:m.useCallback(e=>{ee.current=e},[]),children:(0,h.jsx)(re,{...A,children:(0,h.jsx)(Tf,{asChild:!0,trapped:i,onMountAutoFocus:yd(a,e=>{e.preventDefault(),T.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:(0,h.jsx)(pf,{asChild:!0,disableOutsidePointerEvents:s,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,children:(0,h.jsx)(y_,{asChild:!0,...x,dir:y.dir,orientation:`vertical`,loop:r,currentTabStopId:C,onCurrentTabStopIdChange:w,onEntryFocus:yd(c,e=>{y.isUsingKeyboardRef.current||e.preventDefault()}),preventScrollOnEntryFocus:!0,children:(0,h.jsx)(Ug,{role:`menu`,"aria-orientation":`vertical`,"data-state":iv(v.open),"data-radix-menu-content":``,dir:y.dir,...b,..._,ref:E,style:{outline:`none`,..._.style},onKeyDown:yd(_.onKeyDown,e=>{let t=e.target.closest(`[data-radix-menu-content]`)===e.currentTarget,n=e.ctrlKey||e.altKey||e.metaKey,r=e.key.length===1;t&&(e.key===`Tab`&&e.preventDefault(),!n&&r&&ie(e.key));let i=T.current;if(e.target!==i||!E_.includes(e.key))return;e.preventDefault();let a=S().filter(e=>!e.disabled).map(e=>e.ref.current);T_.includes(e.key)&&a.reverse(),sv(a)}),onBlur:yd(e.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(D.current),O.current=``)}),onPointerMove:yd(e.onPointerMove,fv(e=>{let t=e.target,n=ne.current!==e.clientX;if(e.currentTarget.contains(t)&&n){let t=e.clientX>ne.current?`right`:`left`;te.current=t,ne.current=e.clientX}}))})})})})})})},`MenuContentImpl`)),$_=`MenuItem`,ev=`menu.itemSelect`,tv=m.forwardRef(S_(function(e,t){let{disabled:n=!1,onSelect:r,...i}=e,a=m.useRef(null),o=R_($_,e.__scopeMenu),s=q_($_,e.__scopeMenu),c=Au(t,a),l=m.useRef(!1),u=S_(()=>{let e=a.current;if(!n&&e){let t=new CustomEvent(ev,{bubbles:!0,cancelable:!0});e.addEventListener(ev,e=>r?.(e),{once:!0}),Zu(e,t),t.defaultPrevented?l.current=!1:o.onClose()}},`handleSelect`);return(0,h.jsx)(nv,{...i,ref:c,disabled:n,onClick:yd(e.onClick,u),onPointerDown:t=>{e.onPointerDown?.(t),l.current=!0},onPointerUp:yd(e.onPointerUp,e=>{l.current||e.currentTarget?.click()}),onKeyDown:yd(e.onKeyDown,e=>{n||e.target!==e.currentTarget||(s.searchRef.current===``||e.key!==` `)&&C_.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})})},`MenuItem`)),nv=m.forwardRef(S_(function(e,t){let{__scopeMenu:n,disabled:r=!1,textValue:i,...a}=e,o=q_($_,n),s=P_(n),c=m.useRef(null),l=Au(t,c),[u,d]=m.useState(!1),[f,p]=m.useState(``);return m.useEffect(()=>{let e=c.current;e&&p((e.textContent??``).trim())},[a.children]),(0,h.jsx)(O_.ItemSlot,{scope:n,disabled:r,textValue:i??f,children:(0,h.jsx)(b_,{asChild:!0,...s,focusable:!r,children:(0,h.jsx)(Xu.div,{role:`menuitem`,"data-highlighted":u?``:void 0,"aria-disabled":r||void 0,"data-disabled":r?``:void 0,...a,ref:l,onPointerMove:yd(e.onPointerMove,fv(e=>{r?o.onItemLeave(e):(o.onItemEnter(e),e.defaultPrevented||e.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:yd(e.onPointerLeave,fv(e=>o.onItemLeave(e))),onFocus:yd(e.onFocus,()=>d(!0)),onBlur:yd(e.onBlur,()=>d(!1))})})})},`MenuItemImpl`)),[Oee,kee]=j_(`MenuRadioGroup`,{value:void 0,onValueChange:S_(()=>{},`onValueChange`)}),[Aee,jee]=j_(`MenuItemIndicator`,{checked:!1}),rv=m.forwardRef(S_(function(e,t){let{__scopeMenu:n,...r}=e;return(0,h.jsx)(Xu.div,{role:`separator`,"aria-orientation":`horizontal`,...r,ref:t})},`MenuSeparator`)),[Mee,Nee]=j_(`MenuSub`);function iv(e){return e?`open`:`closed`}S_(iv,`getOpenState`);function av(e){return e===`indeterminate`}S_(av,`isIndeterminate`);function ov(e){return av(e)?`indeterminate`:e?`checked`:`unchecked`}S_(ov,`getCheckedState`);function sv(e){let t=document.activeElement;for(let n of e)if(n===t||(n.focus(),document.activeElement!==t))return}S_(sv,`focusFirst`);function cv(e,t){return e.map((n,r)=>e[(t+r)%e.length])}S_(cv,`wrapArray`);function lv(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=cv(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}S_(lv,`getNextMatch`);function uv(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}S_(uv,`isPointInPolygon`);function dv(e,t){return t?uv({x:e.clientX,y:e.clientY},t):!1}S_(dv,`isPointerInGraceArea`);function fv(e){return t=>t.pointerType===`mouse`?e(t):void 0}S_(fv,`whenMouse`);var pv=z_,mv=B_,hv=W_,gv=J_,_v=tv,vv=rv,yv=Object.defineProperty,bv=(e,t)=>yv(e,`name`,{value:t,configurable:!0}),xv=`DropdownMenu`,[Sv,Pee]=td(xv,[M_]),Cv=M_(),[wv,Tv]=Sv(xv),Ev=bv(e=>{let{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:a,onOpenChange:o,modal:s=!0}=e,c=Cv(t),l=m.useRef(null),[u,d]=Nd({prop:i,defaultProp:a??!1,onChange:o,caller:xv});return(0,h.jsx)(wv,{scope:t,triggerId:Zd(),triggerRef:l,contentId:Zd(),open:u,onOpenChange:d,onOpenToggle:m.useCallback(()=>d(e=>!e),[d]),modal:s,children:(0,h.jsx)(pv,{...c,open:u,onOpenChange:d,dir:r,modal:s,children:n})})},`DropdownMenu`),Dv=`DropdownMenuTrigger`,Ov=m.forwardRef(bv(function(e,t){let{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,a=Tv(Dv,n),o=Cv(n),s=Au(t,a.triggerRef);return(0,h.jsx)(mv,{asChild:!0,...o,children:(0,h.jsx)(Xu.button,{type:`button`,id:a.triggerId,"aria-haspopup":`menu`,"aria-expanded":a.open,"aria-controls":a.open?a.contentId:void 0,"data-state":a.open?`open`:`closed`,"data-disabled":r?``:void 0,disabled:r,...i,ref:s,onPointerDown:yd(e.onPointerDown,e=>{!r&&e.button===0&&e.ctrlKey===!1&&(a.onOpenToggle(),a.open||e.preventDefault())}),onKeyDown:yd(e.onKeyDown,e=>{r||([`Enter`,` `].includes(e.key)&&a.onOpenToggle(),e.key===`ArrowDown`&&a.onOpenChange(!0),[`Enter`,` `,`ArrowDown`].includes(e.key)&&e.preventDefault())})})})},`DropdownMenuTrigger`)),kv=bv(e=>{let{__scopeDropdownMenu:t,...n}=e,r=Cv(t);return(0,h.jsx)(hv,{...r,...n})},`DropdownMenuPortal`),Av=`DropdownMenuContent`,jv=m.forwardRef(bv(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=Tv(Av,n),a=Cv(n),o=m.useRef(!1);return(0,h.jsx)(gv,{id:i.contentId,"aria-labelledby":i.triggerId,...a,...r,ref:t,onCloseAutoFocus:yd(e.onCloseAutoFocus,e=>{o.current||i.triggerRef.current?.focus(),o.current=!1,e.preventDefault()}),onInteractOutside:yd(e.onInteractOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;(!i.modal||r)&&(o.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})},`DropdownMenuContent`)),Mv=m.forwardRef(bv(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=Cv(n);return(0,h.jsx)(_v,{...i,...r,ref:t})},`DropdownMenuItem`)),Nv=m.forwardRef(bv(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=Cv(n);return(0,h.jsx)(vv,{...i,...r,ref:t})},`DropdownMenuSeparator`)),Pv=Ev,Fv=Ov,Iv=kv,Lv=jv,Rv=Mv,zv=Nv,Bv=Object.defineProperty,Vv=m.forwardRef(((e,t)=>Bv(e,`name`,{value:t,configurable:!0}))(function(e,t){return(0,h.jsx)(Xu.label,{...e,ref:t,onMouseDown:t=>{t.target.closest(`button, input, select, textarea`)||(e.onMouseDown?.(t),!t.defaultPrevented&&t.detail>1&&t.preventDefault())}})},`Label`)),Hv=Object.defineProperty,Uv=(e,t)=>Hv(e,`name`,{value:t,configurable:!0}),Wv=`Popover`,[Gv,Fee]=td(Wv,[Ig]),Kv=Ig(),[qv,Jv]=Gv(Wv),Yv=Uv(e=>{let{__scopePopover:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!1}=e,s=Kv(t),c=m.useRef(null),[l,u]=m.useState(!1),[d,f]=Nd({prop:r,defaultProp:i??!1,onChange:a,caller:Wv});return(0,h.jsx)(Vg,{...s,children:(0,h.jsx)(qv,{scope:t,contentId:Zd(),triggerRef:c,open:d,onOpenChange:f,onOpenToggle:m.useCallback(()=>f(e=>!e),[f]),hasCustomAnchor:l,onCustomAnchorAdd:m.useCallback(()=>u(!0),[]),onCustomAnchorRemove:m.useCallback(()=>u(!1),[]),modal:o,children:n})})},`Popover`),Xv=`PopoverAnchor`,Zv=m.forwardRef(Uv(function(e,t){let{__scopePopover:n,...r}=e,i=Jv(Xv,n),a=Kv(n),{onCustomAnchorAdd:o,onCustomAnchorRemove:s}=i;return m.useEffect(()=>(o(),()=>s()),[o,s]),(0,h.jsx)(Hg,{...a,...r,ref:t})},`PopoverAnchor`)),Qv=`PopoverTrigger`,$v=m.forwardRef(Uv(function(e,t){let{__scopePopover:n,...r}=e,i=Jv(Qv,n),a=Kv(n),o=Au(t,i.triggerRef),s=(0,h.jsx)(Xu.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":fy(i.open),...r,ref:o,onClick:yd(e.onClick,i.onOpenToggle)});return i.hasCustomAnchor?s:(0,h.jsx)(Hg,{asChild:!0,...a,children:s})},`PopoverTrigger`)),ey=`PopoverPortal`,[ty,ny]=Gv(ey,{forceMount:void 0}),ry=Uv(e=>{let{__scopePopover:t,forceMount:n,children:r,container:i}=e,a=Jv(ey,t);return(0,h.jsx)(ty,{scope:t,forceMount:n,children:(0,h.jsx)(Vd,{present:n||a.open,children:(0,h.jsx)(Rf,{asChild:!0,container:i,children:r})})})},`PopoverPortal`),iy=`PopoverContent`,ay=m.forwardRef(Uv(function(e,t){let n=ny(iy,e.__scopePopover),{forceMount:r=n.forceMount,...i}=e,a=Jv(iy,e.__scopePopover);return(0,h.jsx)(Vd,{present:r||a.open,children:a.modal?(0,h.jsx)(sy,{...i,ref:t}):(0,h.jsx)(cy,{...i,ref:t})})},`PopoverContent`)),oy=Nu(`PopoverContent.RemoveScroll`),sy=m.forwardRef(Uv(function(e,t){let n=Jv(iy,e.__scopePopover),r=m.useRef(null),i=Au(t,r),a=m.useRef(!1);return m.useEffect(()=>{let e=r.current;if(e)return cm(e)},[]),(0,h.jsx)($p,{as:oy,allowPinchZoom:!0,children:(0,h.jsx)(ly,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:yd(e.onCloseAutoFocus,e=>{e.preventDefault(),a.current||n.triggerRef.current?.focus()}),onPointerDownOutside:yd(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;a.current=r},{checkForDefaultPrevented:!1}),onFocusOutside:yd(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1})})})},`PopoverContentModal`)),cy=m.forwardRef(Uv(function(e,t){let n=Jv(iy,e.__scopePopover),r=m.useRef(!1),i=m.useRef(!1);return(0,h.jsx)(ly,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})},`PopoverContentNonModal`)),ly=m.forwardRef(Uv(function(e,t){let{__scopePopover:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,disableOutsidePointerEvents:o,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onInteractOutside:u,...d}=e,f=Jv(iy,n),p=Kv(n);return Wf(),(0,h.jsx)(Tf,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,h.jsx)(pf,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:u,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onDismiss:()=>f.onOpenChange(!1),deferPointerDownOutside:!0,children:(0,h.jsx)(Ug,{"data-state":fy(f.open),role:`dialog`,id:f.contentId,...p,...d,ref:t,style:{...d.style,"--radix-popover-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-popover-content-available-width":`var(--radix-popper-available-width)`,"--radix-popover-content-available-height":`var(--radix-popper-available-height)`,"--radix-popover-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-popover-trigger-height":`var(--radix-popper-anchor-height)`}})})})},`PopoverContentImpl`)),uy=`PopoverClose`,dy=m.forwardRef(Uv(function(e,t){let{__scopePopover:n,...r}=e,i=Jv(uy,n);return(0,h.jsx)(Xu.button,{type:`button`,...r,ref:t,onClick:yd(e.onClick,()=>i.onOpenChange(!1))})},`PopoverClose`));function fy(e){return e?`open`:`closed`}Uv(fy,`getState`);var Iee=Yv,Lee=Zv,Ree=$v,zee=ry,Bee=ay,Vee=dy,Hee=Object.defineProperty,Uee=(e,t)=>Hee(e,`name`,{value:t,configurable:!0}),Wee=`Toggle`,Gee=m.forwardRef(Uee(function(e,t){let{pressed:n,defaultPressed:r,onPressedChange:i,...a}=e,[o,s]=Nd({prop:n,onChange:i,defaultProp:r??!1,caller:Wee});return(0,h.jsx)(Xu.button,{type:`button`,"aria-pressed":o,"data-state":o?`on`:`off`,"data-disabled":e.disabled?``:void 0,...a,ref:t,onClick:yd(e.onClick,()=>{e.disabled||s(!o)})})},`Toggle`)),Kee=Object.defineProperty,py=(e,t)=>Kee(e,`name`,{value:t,configurable:!0}),my=`ToggleGroup`,[hy,qee]=td(my,[s_]),gy=s_(),Jee=m.forwardRef(py(function(e,t){let{type:n,...r}=e;if(n===`single`)return(0,h.jsx)(Yee,{role:`radiogroup`,...r,ref:t});if(n===`multiple`)return(0,h.jsx)(Xee,{role:`toolbar`,...r,ref:t});throw Error(`Missing prop \`type\` expected on \`${my}\``)},`ToggleGroup`)),[_y,vy]=hy(my),Yee=m.forwardRef(py(function(e,t){let{value:n,defaultValue:r,onValueChange:i=py(()=>{},`onValueChange`),...a}=e,[o,s]=Nd({prop:n,defaultProp:r??``,onChange:i,caller:my});return(0,h.jsx)(_y,{scope:e.__scopeToggleGroup,type:`single`,value:m.useMemo(()=>o?[o]:[],[o]),onItemActivate:s,onItemDeactivate:m.useCallback(()=>s(``),[s]),children:(0,h.jsx)(yy,{...a,ref:t})})},`ToggleGroupImplSingle`)),Xee=m.forwardRef(py(function(e,t){let{value:n,defaultValue:r,onValueChange:i=py(()=>{},`onValueChange`),...a}=e,[o,s]=Nd({prop:n,defaultProp:r??[],onChange:i,caller:my}),c=m.useCallback(e=>s((t=[])=>[...t,e]),[s]),l=m.useCallback(e=>s((t=[])=>t.filter(t=>t!==e)),[s]);return(0,h.jsx)(_y,{scope:e.__scopeToggleGroup,type:`multiple`,value:o,onItemActivate:c,onItemDeactivate:l,children:(0,h.jsx)(yy,{...a,ref:t})})},`ToggleGroupImplMultiple`)),[Zee,Qee]=hy(my),yy=m.forwardRef(py(function(e,t){let{__scopeToggleGroup:n,disabled:r=!1,rovingFocus:i=!0,orientation:a,dir:o,loop:s=!0,...c}=e,l=gy(n),u=tf(o),d={dir:u,...c};return(0,h.jsx)(Zee,{scope:n,rovingFocus:i,disabled:r,children:i?(0,h.jsx)(y_,{asChild:!0,...l,orientation:a,dir:u,loop:s,children:(0,h.jsx)(Xu.div,{...d,ref:t})}):(0,h.jsx)(Xu.div,{...d,ref:t})})},`ToggleGroupImpl`)),by=`ToggleGroupItem`,$ee=m.forwardRef(py(function(e,t){let n=vy(by,e.__scopeToggleGroup),r=Qee(by,e.__scopeToggleGroup),i=gy(e.__scopeToggleGroup),a=n.value.includes(e.value),o=r.disabled||e.disabled,s={...e,pressed:a,disabled:o},c=m.useRef(null);return r.rovingFocus?(0,h.jsx)(b_,{asChild:!0,...i,focusable:!o,active:a,ref:c,children:(0,h.jsx)(xy,{...s,ref:t})}):(0,h.jsx)(xy,{...s,ref:t})},`ToggleGroupItem`)),xy=m.forwardRef(py(function(e,t){let{__scopeToggleGroup:n,value:r,...i}=e,a=vy(by,n),o={role:`radio`,"aria-checked":e.pressed,"aria-pressed":void 0},s=a.type===`single`?o:void 0;return(0,h.jsx)(Gee,{...s,...i,ref:t,onPressedChange:e=>{e?a.onItemActivate(r):a.onItemDeactivate(r)}})},`ToggleGroupItemImpl`));function Sy({variant:e=`secondary`,size:t=`default`}={}){return I(`sl-btn`,`sl-btn--${e}`,t===`small`&&`sl-btn--small`)}function L({variant:e=`secondary`,size:t=`default`,disabledReason:n,className:r,type:i,title:a,...o}){return(0,h.jsx)(`button`,{"data-slot":`button`,"data-variant":e,type:i??`button`,title:o.disabled&&n!==void 0?n:a,className:I(Sy({variant:e,size:t}),r),...o})}function Cy({label:e,tip:t,title:n,children:r,...i}){let a=t===void 0||t===!1?void 0:t===!0?e:t;return(0,h.jsx)(L,{variant:`icon`,"aria-label":e,...a===void 0?{title:n??e}:{"data-tip":a},...i,children:r})}function wy({className:e,asChild:t=!1,type:n,...r}){let i=t?Pu:`button`;return(0,h.jsx)(i,{"data-slot":`play-key`,...t?{}:{type:n??`button`},className:I(`sl-key`,e),...r})}function Ty({className:e,...t}){return(0,h.jsx)(`div`,{className:I(`sl-btn-row`,e),...t})}var ete=4e3,tte=8e3,Ey=(0,m.createContext)(void 0);function nte({children:e}){let[t,n]=(0,m.useState)([]),r=(0,m.useRef)(0),i=(0,m.useRef)(new Map),a=(0,m.useCallback)(e=>{n(t=>t.filter(t=>t.id!==e));let t=i.current.get(e);t!==void 0&&clearTimeout(t),i.current.delete(e)},[]),o=(0,m.useCallback)((e,t=`info`,o)=>{r.current+=1;let s=r.current;n(n=>[...n.filter(t=>t.message!==e).slice(-2),{id:s,message:e,tone:t,action:o}]),i.current.set(s,setTimeout(()=>a(s),o===void 0?ete:tte))},[a]);(0,m.useEffect)(()=>{let e=i.current;return()=>{for(let t of e.values())clearTimeout(t)}},[]);let s=(0,m.useMemo)(()=>o,[o]);return(0,h.jsxs)(Ey.Provider,{value:s,children:[e,(0,h.jsx)(`section`,{"aria-label":`Notifications`,className:`sl-toasts`,children:t.map(e=>(0,h.jsxs)(`div`,{role:e.tone===`error`?`alert`:`status`,"data-tone":e.tone,className:I(`sl-toast sl-enter`,e.tone===`error`&&`sl-toast--failed`,e.tone===`success`&&`sl-toast--done`),children:[e.tone===`error`?(0,h.jsx)(Lc,{"aria-hidden":`true`,strokeWidth:1.75}):e.tone===`success`?(0,h.jsx)(ac,{"aria-hidden":`true`,strokeWidth:1.75}):(0,h.jsx)(yc,{"aria-hidden":`true`,strokeWidth:1.75,className:`text-ink-2`}),(0,h.jsx)(`p`,{className:`sl-toast__text m-0 min-w-0 break-words`,children:e.message}),e.action===void 0?null:(0,h.jsx)(L,{variant:`quiet`,size:`small`,onClick:()=>{a(e.id),e.action?.run()},children:e.action.label}),(0,h.jsx)(`button`,{type:`button`,"aria-label":`Dismiss notification`,onClick:()=>a(e.id),className:`sl-btn sl-btn--icon sl-btn--small -mr-1 w-[30px]`,children:(0,h.jsx)(Vc,{"aria-hidden":`true`,strokeWidth:1.75})})]},e.id))})]})}function Dy(){return(0,m.useContext)(Ey)??rte}function rte(){}var Oy=(0,m.createContext)(void 0);function ite({deps:e,children:t}){return(0,h.jsx)(Oy.Provider,{value:e,children:(0,h.jsx)(nte,{children:t})})}function R(){let e=(0,m.useContext)(Oy);if(e===void 0)throw Error(`useApp was called outside AppProvider`);return e}var ate=hm,ote=vm;function ste({className:e,...t}){return(0,h.jsx)(bm,{"data-slot":`dialog-overlay`,className:I(`fixed inset-0 z-40 bg-scrim`,e),...t})}function cte({className:e,children:t,...n}){return(0,h.jsxs)(ote,{children:[(0,h.jsx)(ste,{}),(0,h.jsx)(wm,{"data-slot":`dialog-content`,className:I(`sl-dialog fixed top-1/2 left-1/2 z-50 max-h-[calc(100vh-2rem)] -translate-x-1/2 -translate-y-1/2 overflow-y-auto`,`data-[state=open]:animate-dialog-in motion-reduce:animate-none`,e),...n,children:t})]})}function lte({className:e,...t}){return(0,h.jsx)(Em,{"data-slot":`dialog-title`,className:I(`sl-dialog__title text-ink`,e),...t})}function ute({className:e,...t}){return(0,h.jsx)(see,{"data-slot":`dialog-description`,className:I(`m-0 text-body text-ink-2`,e),...t})}function ky({open:e,onOpenChange:t,title:n,description:r,footer:i,children:a,className:o,dismissible:s=!0}){return(0,h.jsx)(ate,{open:e,...t===void 0?{}:{onOpenChange:t},children:(0,h.jsxs)(cte,{className:o,...s?{}:{onEscapeKeyDown:e=>e.preventDefault(),onInteractOutside:e=>e.preventDefault()},...r===void 0?{"aria-describedby":void 0}:{},children:[(0,h.jsx)(lte,{children:n}),r===void 0?null:(0,h.jsx)(ute,{children:r}),a,i===void 0?null:(0,h.jsx)(`div`,{className:`sl-dialog__foot`,children:i})]})})}function Ay({open:e,title:t,consequence:n,confirmLabel:r,cancelLabel:i=`Cancel`,tone:a=`destructive`,pending:o=!1,onConfirm:s,onCancel:c}){return(0,h.jsx)(ky,{open:e,onOpenChange:e=>{e||c()},title:t,description:n,footer:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(L,{variant:`secondary`,autoFocus:!0,onClick:c,children:i}),(0,h.jsx)(L,{variant:a,disabled:o,disabledReason:`Working on it`,onClick:s,children:r})]})})}var jy=[`onboarding`],My=[`onboarding`,`sample`],Ny=(e,t)=>[`narration-peaks`,e,t],Py=(e,t,n)=>e.fetch(`${e.origin}/api/onboarding${t}`,{method:`POST`,...n===void 0?{}:{headers:{"content-type":`application/json`},body:JSON.stringify(n)}});async function Fy(e){return P(await e.fetch(`${e.origin}/api/onboarding`))}async function Iy(e){await P(await Py(e,`/dismiss`))}async function Ly(e,t){return P(await Py(e,`/packs/${encodeURIComponent(t)}`))}async function Ry(e,t){return P(await Py(e,`/short`,t))}async function zy(e,t){return P(await Py(e,`/full-video`,t))}async function By(e){return P(await e.fetch(`${e.origin}/api/onboarding/sample`))}function Vy(e,t){return e!==void 0&&Object.values(e.samples).includes(t)}async function Hy(e){return P(await Py(e,`/sample/restore`))}async function Uy(e,t=Wy()){return P(await Py(e,`/sample/copy`,t===void 0?void 0:{projectId:t}))}function Wy(){if(typeof window>`u`)return;let e=/\/projects\/([^/?#]+)/.exec(window.location.pathname);return e?.[1]===void 0?void 0:decodeURIComponent(e[1])}async function Gy(e,t){return P(await e.fetch(`${e.origin}/api/projects/${encodeURIComponent(t)}/narration/peaks`))}var z={projects:[`projects`],revisions:e=>[`project`,e,`revisions`],revision:(e,t)=>[`project`,e,`revision`,t],revisionFile:(e,t,n)=>[`revision-file`,e,t,n],project:e=>[`project`,e],runCost:e=>[`project`,e,`run-cost`],article:(e,t=null)=>[`project`,e,`article`,t],audioPreview:(e,t)=>[`audio-preview`,e,t],file:(e,t)=>[`file`,e,t],staging:[`staging`],notice:[`notice`],usage:[`usage`],providers:[`providers`],voices:[`voices`],prompts:[`prompts`],entries:[`entries`],documentThemes:[`document-themes`],narrationAliases:[`narration-aliases`],settings:[`settings`],youtubeEdits:e=>[`project`,e,`youtube-edits`],channelLinks:[`channel-links`],projectChannelLinks:e=>[`channel-links`,`project`,e]};function Ky(e){return lt({queryKey:z.projects,queryFn:()=>Do(e)})}function qy(e,t){return lt({queryKey:z.project(t),queryFn:()=>Oo(e,t)})}function Jy(e,t){return lt({queryKey:z.runCost(t),queryFn:()=>ko(e,t)})}function Yy(e){return lt({queryKey:z.notice,queryFn:()=>Vo(e)})}function Xy(e){return lt({queryKey:z.usage,queryFn:()=>Bo(e)})}function Zy(e){return lt({queryKey:z.providers,queryFn:()=>Wo(e)})}function Qy(e){return lt({queryKey:z.voices,queryFn:()=>ls(e)})}function $y(e){return lt({queryKey:z.prompts,queryFn:()=>gs(e)})}function eb(e){return lt({queryKey:z.entries,queryFn:()=>Os(e)})}function tb(e){return lt({queryKey:z.documentThemes,queryFn:()=>As(e)})}function nb(e){return lt({queryKey:z.narrationAliases,queryFn:()=>Fs(e)})}function rb(e){return lt({queryKey:z.settings,queryFn:()=>Jo(e)})}var ib={"library.prompt.kind":{title:`Prompt kind`,body:`What the prompt is for, which decides where Play offers it. Article writes the video's text, Image and Thumbnail describe pictures, Narration Preparation adds delivery cues, YouTube Description writes the description, Shorts picks the short clips, Review checks a finished stage, Script writes speaker turns for several voices.`,tutorial:{page:`Prompts`,anchor:`prompt-kinds`}},"library.prompt.name":{title:`Prompt name`,body:`What Play and Edit project list this prompt by. Up to 200 characters, and unique within its kind. Templates remember a prompt by name, so after a rename they use the copy saved with them until you pick it again.`,tutorial:{page:`Prompts`,anchor:`write-a-new-prompt`}},"library.prompt.body.article":{title:`Article prompt`,body:`The instruction the text model gets to write the video's article, which becomes the narration. Each {{keyword}} becomes a field on Play. One call on the project's LLM, plus up to 3 more when the answer runs out of room; research notes go first when research ran. The answer's sources and pronunciation sections are never narrated.`,tutorial:{page:`Prompts`,anchor:`write-a-new-prompt`}},"library.prompt.body.image":{title:`Image prompt`,body:`Sent as written to the image model, with the keywords filled in; no text model rewrites it. Play sets how many pictures each prompt makes (1 to 20, at most 60 a run), and each picture is one image call. Pictures show for 15 s each by default and repeat until the video ends.`,tutorial:{page:`Prompts`,anchor:`write-a-new-prompt`}},"library.prompt.body.thumbnail":{title:`Thumbnail prompt`,body:`Sent to the image model to draw the thumbnail. With Thumbnail set to Prompt by LLM, the text model first turns it into a picture prompt using the title and article, one extra call. 1 thumbnail by default, or 3: the second a close-up, the third a wider shot, each one image call.`,tutorial:{page:`Prompts`,anchor:`write-a-new-prompt`}},"library.prompt.body.narration":{title:`Narration Preparation prompt`,body:`Tells the text model how the narration should be delivered. It only adds cues, such as a short speaking direction or a laugh or sigh, and never rewrites the words. One call each for the body, the intro and the outro. Works only with the Inworld TTS-2 voice model. With several speakers, each speaker on TTS-2 gets cues suited to their role.`,tutorial:{page:`Play-Narration`,anchor:`narration-preparation`}},"library.prompt.body.description":{title:`YouTube Description prompt`,body:`Tells the text model how to write the video's YouTube description, chapters, hashtags and tags from the timestamped transcript. One call per video. Each {{keyword}} becomes a field on Play. A project that picks none uses the Built-in wording.`,tutorial:{page:`Prompts`,anchor:`write-a-new-prompt`}},"library.prompt.body.shorts":{title:`Shorts prompt`,body:`Tells the text model which moments of the video to cut into vertical shorts (3 of 60 to 120 s by default). One call picks them, then one call per short writes its picture prompts, and each picture is one image call. A project that picks none uses the Built-in wording.`,tutorial:{page:`Prompts`,anchor:`write-a-new-prompt`}},"library.prompt.body.review":{title:`Review prompt`,body:`Tells the reviewer what to check in a finished article, set of images, narration, thumbnail or shorts, and when to flag or redo it. One reviewer call per item checked; pictures can only be judged by the Claude Code and Codex reviewers. A stage with none picked uses its own built-in wording.`,tutorial:{page:`Prompts`,anchor:`write-a-new-prompt`}},"library.prompt.body.script":{title:`Script prompt`,body:`Used in place of an Article prompt when a run has several voices and writes a script. The text model answers with # section headings and Name: words turns, one speaker per paragraph; text in [square brackets] is not spoken. One call on the project's LLM.`,tutorial:{page:`Prompts`,anchor:`write-a-new-prompt`}},"library.prompt.starter":{title:`Starter text`,body:`Fills the body with ready-made text to start from: the documentary delivery cues for Narration Preparation, or the Built-in wording YouTube Description and Shorts use when no prompt is picked. When the body already has text you confirm first. Nothing is saved until you choose Save.`,tutorial:{page:`Prompts`,anchor:`start-from-ready-made-text`}},"library.prompt.photorealistic":{title:`Draws photorealistic pictures`,body:`Turn on when this prompt's style looks like real photos or film. Prepare upload then answers Yes to YouTube's AI use question (a realistic-looking scene that didn't happen) for videos and shorts drawn with it. Leave off for painterly or illustrated styles. Applies at once, apart from Save; a channel's Always Yes or Always No wins. Default: off.`,tutorial:{page:`Prompts`,anchor:`mark-an-image-prompt-as-photorealistic`}},"library.slots":{title:`Detected slots`,body:`Every {{keyword}} in the body, listed as you type. Each becomes one field on Play, typed once and filled into every prompt that names it. Names are case-sensitive, so {{Topic}} and {{topic}} are two fields. A keyword the project title also names is typed per video and saved empty in templates.`,tutorial:{page:`Prompts`,anchor:`keywords-slots`}},"library.used-by":{title:`Used by`,body:`The templates, schedules and projects that name this item, matched by name within its kind. For a project it says how many of its revisions used it and whether the current one does. Projects keep their own text, so editing here changes only runs started later.`,tutorial:{page:`Prompts`,anchor:`used-by`}},"library.history":{title:`History`,body:`Every save that changes the name or text adds a version, and every version is kept. Here you see the latest change with the changed words marked. Compare versions opens them all side by side, with Restore for an older one.`,tutorial:{page:`Prompts`,anchor:`history-and-versions`}},"library.history.compare":{title:`Compare versions`,body:`Pick any two saved versions to see them side by side, with the words that changed marked. Older and Newer can be any versions; a rename between them is said above the text.`,tutorial:{page:`Prompts`,anchor:`history-and-versions`}},"library.history.versions":{title:`Versions`,body:`Every saved version, newest first. Restore saves an older version again as a new version, so nothing after it is lost and History notes where it came from. Projects already made keep their text.`,tutorial:{page:`Prompts`,anchor:`history-and-versions`}},"library.entry.category":{title:`Intro or outro`,body:`An intro is narrated before the body of the video, an outro after it, in the same voice. Play offers each in its own picker. A name only needs to be unique within its category.`,tutorial:{page:`Intros-and-Outros`,anchor:`text-or-llm`}},"library.inline-rename":{title:`Rename in the list`,body:`Changes only the name, right in the list; the text stays as it is. Enter saves, Escape keeps the old name, and Undo on the notice renames it back. A prompt or intro/outro keeps the rename in History; templates that picked the old name use the copy saved with them until you pick it again. A template saves a new version; schedules keep the version they were made from.`,tutorial:{page:`Library-Overview`,anchor:`rename-in-the-row`}},"library.entry.name":{title:`Entry name`,body:`What Play and Edit project list this intro or outro by. Up to 200 characters, and unique within its category.`,tutorial:{page:`Intros-and-Outros`,anchor:`write-an-intro-or-outro`}},"library.entry.mode":{title:`Mode`,body:`Text is narrated as written, with the keywords filled in and no extra call. LLM sends the body as an instruction to the project's text model, with the title, keyword values and article, and narrates the answer: one call per entry, and the run then needs an LLM. Default: Text.`,tutorial:{page:`Intros-and-Outros`,anchor:`text-or-llm`}},"library.entry.body":{title:`Entry body`,body:`In Text mode, the words the narrator says; in LLM mode, the instruction whose answer is said. Each {{keyword}} becomes a field on Play. It is narrated as its own audio file with the run's voice, one voice request each.`,tutorial:{page:`Intros-and-Outros`,anchor:`write-an-intro-or-outro`}},"library.aliases":{title:`Narration aliases`,body:`Words the narrator says differently from how they are written, such as Dr. as Doctor. Only what the voice and Narration Preparation receive changes; the article and captions keep the written words. A project copies this list when it starts and uses it while Use narration aliases is on. Up to 1000 aliases, saved as a whole.`,tutorial:{page:`Narration-Aliases-and-Glossary`,anchor:`narration-aliases`}},"library.aliases.written":{title:`Written`,body:`The word or phrase as it appears in the article, up to 200 characters. Spaces inside it match any spacing. Two aliases can't share a written form; where two overlap, the one starting first wins, then the longer.`,tutorial:{page:`Narration-Aliases-and-Glossary`,anchor:`rules`}},"library.aliases.spoken":{title:`Say it as`,body:`What the narrator says instead, spelled the way it sounds, up to 500 characters. Only the audio changes. An alias wins over a Pronunciation Glossary entry for the same words.`,tutorial:{page:`Narration-Aliases-and-Glossary`,anchor:`rules`}},"library.aliases.whole-word":{title:`Whole word`,body:`On: matches only where the written form stands as a word of its own, so it never fires inside a longer word. Off: matches inside other words too. Default: on.`,tutorial:{page:`Narration-Aliases-and-Glossary`,anchor:`rules`}},"library.aliases.match-case":{title:`Match case`,body:`On: matches only with the same capital letters, so US is not us. Off: capitals are ignored. Default: off.`,tutorial:{page:`Narration-Aliases-and-Glossary`,anchor:`rules`}},"templates.show-channel":{title:`Show templates of`,body:`Shows only the templates of one channel, or of all. A template's channel is the one a draft made from it runs in. Choosing here changes nothing about the templates.`,tutorial:{page:`Templates`,anchor:`filter-by-channel`}},"templates.apply":{title:`Use in Play`,body:`Makes a new Play draft from the template and opens it in Play for you to review; nothing starts. Keywords the project title names start empty for this video's topic, and uploaded files keep their names but must be attached again. The template itself is unchanged.`,tutorial:{page:`Templates`,anchor:`use-a-template`}},"templates.save":{title:`Save a setup`,body:`Keeps a saved Play draft as a reusable template: every setting and checkpoint choice, plus a copy of each picked prompt and intro or outro. Keywords the project title names, like {{Topic}}, are saved empty; other keywords keep their values. Queued extra videos and uploaded fonts are left out.`,tutorial:{page:`Templates`,anchor:`save-a-template-from-library--templates`}},"templates.save.draft":{title:`Saved Play draft`,body:`The Play draft whose setup the template keeps. Only drafts saved in Play are listed; open Play to prepare one first. The draft itself stays as it is.`,tutorial:{page:`Templates`,anchor:`save-a-template-from-library--templates`}},"templates.save.name":{title:`Template name`,body:`What the template is called in this list and wherever you pick a template, such as a schedule. Up to 120 characters.`,tutorial:{page:`Templates`,anchor:`save-a-template-from-library--templates`}},"templates.edit":{title:`Edit a template`,body:`Shows the keywords the template fills and what each feeds. The pencil beside its name renames it; every save adds a version that History keeps. To change its settings, use it in Play, change the draft, then Save a setup.`,tutorial:{page:`Templates`,anchor:`see-a-templates-keywords`}},"templates.history":{title:`Template versions`,body:`Every saved version of the template, newest first. Pick one to compare its setup with the current one. Restore saves the older setup again as a new version, so nothing is lost. Drafts and projects made from it keep their setup.`,tutorial:{page:`Templates`,anchor:`history`}},"templates.save.channel":{title:`Template channel`,body:`The channel the template belongs to, and the one a draft made from it runs in. Default: the draft's own channel, or its template's channel when it has none.`,tutorial:{page:`Templates`,anchor:`save-a-template-from-library--templates`}},"library.themes.yours":{title:`Your themes`,body:`Themes you made or copied from a built-in. Pick one on the Document row in Play or in Edit project. A project keeps its own copy of the settings, so editing or deleting a theme here never changes a PDF already made or queued.`,tutorial:{page:`Document-Themes`,anchor:`built-in-and-your-own-themes`}},"library.themes.built-in":{title:`Built-in themes`,body:`Looks that ship with Slopify and can't be changed. Plain is an unbranded flat page and what a new project gets. Copy one to make a theme of your own you can edit.`,tutorial:{page:`Document-Themes`,anchor:`built-in-and-your-own-themes`}},"library.theme.name":{title:`Theme name`,body:`What the theme is called on the Document row in Play and in Edit project. Up to 80 characters.`,tutorial:{page:`Document-Themes`,anchor:`make-a-theme`}},"library.theme.preview":{title:`Preview`,body:`A sample article laid out with this theme by the same renderer that makes a project's PDF, redrawn about half a second after you stop typing. It runs on your computer and costs nothing. Your projects use their own text and thumbnail.`,tutorial:{page:`Document-Themes`,anchor:`make-a-theme`}},"library.theme.page.format":{title:`Paper size`,body:`The page size of the PDF. A4 (210 × 297 mm) is used in most of the world; US Letter (216 × 279 mm) in the US and Canada. Pick the one your readers print on. Default: A4.`,tutorial:{page:`Document-Themes`,anchor:`page`}},"library.theme.page.margin":{title:`Margins`,body:`Blank space kept on every edge of each page, in millimetres. Wider margins mean shorter lines and more pages. From 5 to 60 mm. Default: 22 mm.`,tutorial:{page:`Document-Themes`,anchor:`page`}},"library.theme.page.content-top":{title:`Text starts at`,body:`How far from the top of the page the text begins on pages that carry the running header, in millimetres. Raise it when text crowds the header. From 5 to 80 mm. Default: 32 mm.`,tutorial:{page:`Document-Themes`,anchor:`page`}},"library.theme.background.image":{title:`Background`,body:`Parchment texture stretches an aged-paper picture over every page. Flat colour fills each page with the Page colour, drawn slightly darker at the edges. Default: Flat colour.`,tutorial:{page:`Document-Themes`,anchor:`page`}},"library.theme.background.color":{title:`Page colour`,body:`The colour of every page when Background is Flat colour; ignored with the parchment texture. Type a hex code like #fdfaf3 or use the picker. Default: #fdfaf3, a warm off-white.`,tutorial:{page:`Document-Themes`,anchor:`page`}},"library.theme.colors.heading":{title:`Heading colour`,body:`The colour of headings, drop caps, the brand name and links. Type a hex code like #1f3a5f or use the picker. Default: #1f3a5f, a dark blue.`,tutorial:{page:`Document-Themes`,anchor:`colours`}},"library.theme.colors.text":{title:`Body text colour`,body:`The colour of paragraphs, lists and bold or italic text. Keep it dark against the page colour so it reads and prints well. Default: #1a1a1a, near black.`,tutorial:{page:`Document-Themes`,anchor:`colours`}},"library.theme.colors.muted":{title:`Muted colour`,body:`The colour of dates, bullets, quotes and the dotted lines on the contents page. Default: #555555, a mid grey.`,tutorial:{page:`Document-Themes`,anchor:`colours`}},"library.theme.colors.faint":{title:`Faint colour`,body:`The colour of the running header and the page numbers, kept light so they stay out of the way. Default: #888888, a light grey.`,tutorial:{page:`Document-Themes`,anchor:`colours`}},"library.theme.fonts.body":{title:`Body font`,body:`The font of paragraphs and lists. The first box picks the family, the second its weight or italic, the number adds space between letters in millimetres (-0.5 to 2). Cinzel is bundled and has no italics; Times, Helvetica and Courier are built into every PDF reader. Default: Cinzel Regular, 0.01 mm.`,tutorial:{page:`Document-Themes`,anchor:`fonts`}},"library.theme.fonts.strong":{title:`Bold text font`,body:`The font of bold words inside paragraphs. Family, style and letter spacing in millimetres, as for Body. Default: Cinzel Bold, 0.02 mm.`,tutorial:{page:`Document-Themes`,anchor:`fonts`}},"library.theme.fonts.emphasis":{title:`Italic text font`,body:`The font of italic words inside paragraphs. Cinzel has no italics, so the default borrows Times. Family, style and letter spacing in millimetres, as for Body. Default: Times Italic, 0 mm.`,tutorial:{page:`Document-Themes`,anchor:`fonts`}},"library.theme.fonts.heading":{title:`Heading font`,body:`The font of the article's headings and of the contents, sources and closing page titles. Family, style and letter spacing in millimetres, as for Body. Default: Cinzel Bold, 0.02 mm.`,tutorial:{page:`Document-Themes`,anchor:`fonts`}},"library.theme.fonts.dramatic":{title:`Chapter numbers and brand font`,body:`The font of the big number in a heading like "Chapter 3:" and of the brand name on the title page. Family, style and letter spacing in millimetres, as for Body. Default: Cinzel Black, 0.03 mm.`,tutorial:{page:`Document-Themes`,anchor:`fonts`}},"library.theme.fonts.decorative":{title:`Tagline and link font`,body:`The font of the tagline and the linked line on the title page, and of the link and closing line on the closing page. Default: Cinzel Medium, 0.015 mm.`,tutorial:{page:`Document-Themes`,anchor:`fonts`}},"library.theme.fonts.drop-cap":{title:`Drop cap font`,body:`The font of the large first letter that starts a paragraph after a heading, when drop caps are on. Family, style and letter spacing in millimetres, as for Body. Default: Cinzel Black, 0 mm.`,tutorial:{page:`Document-Themes`,anchor:`fonts`}},"library.theme.fonts.footer":{title:`Header and page number font`,body:`The font of the running header and the page numbers. Family, style and letter spacing in millimetres, as for Body. Default: Times Regular, 0 mm.`,tutorial:{page:`Document-Themes`,anchor:`fonts`}},"library.theme.sizes.title":{title:`Title size`,body:`The size of the article's title on the title page, in points (1 pt is about 0.35 mm). From 6 to 72 pt. Default: 22 pt.`,tutorial:{page:`Document-Themes`,anchor:`text-sizes`}},"library.theme.sizes.brand":{title:`Brand size`,body:`The size of the brand name on the title page, in points. Shown only when Branding has a brand name. From 6 to 72 pt. Default: 31 pt.`,tutorial:{page:`Document-Themes`,anchor:`text-sizes`}},"library.theme.sizes.section":{title:`Top-level heading size`,body:`The size of top-level headings and of the contents, sources and closing page titles, in points. From 6 to 72 pt. Default: 19 pt.`,tutorial:{page:`Document-Themes`,anchor:`text-sizes`}},"library.theme.sizes.heading":{title:`Second-level heading size`,body:`The size of second-level headings, the ones inside a top-level section, in points. From 6 to 72 pt. Default: 17 pt.`,tutorial:{page:`Document-Themes`,anchor:`text-sizes`}},"library.theme.sizes.subheading":{title:`Third-level heading size`,body:`The size of third-level and deeper headings, in points. From 6 to 72 pt. Default: 13 pt.`,tutorial:{page:`Document-Themes`,anchor:`text-sizes`}},"library.theme.sizes.body":{title:`Body size`,body:`The size of paragraphs, lists and the closing page text, in points. Bigger text means more pages. From 6 to 24 pt. Default: 10.5 pt.`,tutorial:{page:`Document-Themes`,anchor:`text-sizes`}},"library.theme.sizes.meta":{title:`Date and word count size`,body:`The size of the date, word count and link lines under the title on the title page, in points. From 5 to 24 pt. Default: 10 pt.`,tutorial:{page:`Document-Themes`,anchor:`text-sizes`}},"library.theme.sizes.footer":{title:`Header and page number size`,body:`The size of the running header and the page numbers, in points. From 5 to 24 pt. Default: 9 pt.`,tutorial:{page:`Document-Themes`,anchor:`text-sizes`}},"library.theme.spacing.body-line":{title:`Body line height`,body:`The distance from one line of body text to the next, in millimetres. Raise it for airier pages, lower it to fit more on each page. From 3 to 20 mm. Default: 8 mm.`,tutorial:{page:`Document-Themes`,anchor:`spacing`}},"library.theme.spacing.heading-line":{title:`Heading line height`,body:`The distance between the lines of a top- or second-level heading that wraps, in millimetres. From 3 to 30 mm. Default: 11 mm.`,tutorial:{page:`Document-Themes`,anchor:`spacing`}},"library.theme.spacing.subheading-line":{title:`Subheading line height`,body:`The distance between the lines of a third-level heading that wraps, in millimetres. From 3 to 30 mm. Default: 9 mm.`,tutorial:{page:`Document-Themes`,anchor:`spacing`}},"library.theme.spacing.paragraph-gap":{title:`After a paragraph`,body:`Extra space after each paragraph, as a share of a body line: 0.5 is half a line. From 0 to 3. Default: 0.5.`,tutorial:{page:`Document-Themes`,anchor:`spacing`}},"library.theme.spacing.heading-gap":{title:`Before a heading`,body:`Extra space above each heading, as a share of a body line: 1 is one full line. From 0 to 5. Default: 1.`,tutorial:{page:`Document-Themes`,anchor:`spacing`}},"library.theme.spacing.item-gap":{title:`After a list item`,body:`Extra space after each bulleted or numbered item, as a share of a body line. From 0 to 3. Default: 0.2.`,tutorial:{page:`Document-Themes`,anchor:`spacing`}},"library.theme.spacing.list-indent":{title:`List indent`,body:`How far bulleted and numbered lists are pushed in from the left margin, in millimetres. From 0 to 30 mm. Default: 6 mm.`,tutorial:{page:`Document-Themes`,anchor:`spacing`}},"library.theme.spacing.quote-indent":{title:`Quote indent`,body:`How far quotes are pushed in from the left margin, in millimetres. From 0 to 40 mm. Default: 8 mm.`,tutorial:{page:`Document-Themes`,anchor:`spacing`}},"library.theme.spacing.rule-width":{title:`Divider width`,body:`The width of the short centred line a --- in the article becomes, in millimetres. From 0 to 150 mm. Default: 30 mm.`,tutorial:{page:`Document-Themes`,anchor:`spacing`}},"library.theme.drop-cap.enabled":{title:`Drop caps`,body:`Starts the first paragraph after each heading with a large first letter that spans several lines, as in printed books. Turn it off for a plainer page. Default: on.`,tutorial:{page:`Document-Themes`,anchor:`drop-caps`}},"library.theme.drop-cap.lines":{title:`Drop cap lines tall`,body:`How many lines of body text the large first letter spans. Default: 3 lines.`,tutorial:{page:`Document-Themes`,anchor:`drop-caps`}},"library.theme.drop-cap.scale":{title:`Drop cap letter size`,body:`The size of the large first letter, as a multiple of the height of the lines it spans. From 1 to 5. Default: 3.`,tutorial:{page:`Document-Themes`,anchor:`drop-caps`}},"library.theme.drop-cap.gap":{title:`Gap beside the drop cap`,body:`The space between the large first letter and the text beside it, in millimetres. From 0 to 20 mm. Default: 4 mm.`,tutorial:{page:`Document-Themes`,anchor:`drop-caps`}},"library.theme.drop-cap.min-length":{title:`Shortest paragraph`,body:`A paragraph shorter than this many characters starts plainly, so a one-line paragraph never gets a huge letter. From 0 to 2000. Default: 50.`,tutorial:{page:`Document-Themes`,anchor:`drop-caps`}},"library.theme.drop-cap.min-room":{title:`Room needed`,body:`With less than this share of the page left, a paragraph that starts with a drop cap moves to the next page. 0.25 is a quarter of the page. From 0 to 1. Default: 0.25.`,tutorial:{page:`Document-Themes`,anchor:`drop-caps`}},"library.theme.title-page.brand-y":{title:`Brand from top`,body:`Where the brand name sits on the title page, measured from the top edge of the page in millimetres. From 10 to 200 mm. Default: 60 mm.`,tutorial:{page:`Document-Themes`,anchor:`title-page`}},"library.theme.title-page.tagline-offset":{title:`Tagline below brand`,body:`The distance from the brand name down to the tagline, in millimetres. From 0 to 60 mm. Default: 10 mm.`,tutorial:{page:`Document-Themes`,anchor:`title-page`}},"library.theme.title-page.title-y":{title:`Title from top`,body:`Where the article's title sits on the title page, measured from the top edge of the page in millimetres. From 10 to 250 mm. Default: 80 mm.`,tutorial:{page:`Document-Themes`,anchor:`title-page`}},"library.theme.title-page.title-line":{title:`Title line height`,body:`The distance between the lines of a title that wraps, in millimetres. From 3 to 40 mm. Default: 10 mm.`,tutorial:{page:`Document-Themes`,anchor:`title-page`}},"library.theme.title-page.meta-offset":{title:`Details below title`,body:`The distance from the title down to the date and word count, in millimetres, when there is no cover picture. From 0 to 100 mm. Default: 20 mm.`,tutorial:{page:`Document-Themes`,anchor:`title-page`}},"library.theme.title-page.meta-line":{title:`Details line height`,body:`The distance between the date, word count and link lines on the title page, in millimetres. From 3 to 30 mm. Default: 10 mm.`,tutorial:{page:`Document-Themes`,anchor:`title-page`}},"library.theme.title-page.show-date":{title:`Show the date`,body:`Prints "Written on" and the date the PDF was made under the title on the title page. Default: on.`,tutorial:{page:`Document-Themes`,anchor:`title-page`}},"library.theme.title-page.show-word-count":{title:`Show the word count`,body:`Prints the article's word count under the title on the title page. Default: on.`,tutorial:{page:`Document-Themes`,anchor:`title-page`}},"library.theme.title-page.cover":{title:`Thumbnail as cover`,body:`Puts the project's thumbnail on the title page, between the title and the date, when the project has one. Without a thumbnail the page is laid out as if this were off. Default: on.`,tutorial:{page:`Document-Themes`,anchor:`title-page`}},"library.theme.title-page.cover-gap":{title:`Space around cover`,body:`The space above and below the cover picture on the title page, in millimetres. From 0 to 40 mm. Default: 6 mm.`,tutorial:{page:`Document-Themes`,anchor:`title-page`}},"library.theme.title-page.cover-height":{title:`Cover height at most`,body:`The tallest the cover picture may be, in millimetres. It keeps its shape and shrinks further when the page has less room. From 20 to 200 mm. Default: 110 mm.`,tutorial:{page:`Document-Themes`,anchor:`title-page`}},"library.theme.brand.name":{title:`Brand name`,body:`Your channel or brand, printed large at the top of the title page and before the title in the running header ("Brand | Title"). Leave it empty to show no brand. Default: empty.`,tutorial:{page:`Document-Themes`,anchor:`branding`}},"library.theme.brand.tagline":{title:`Tagline`,body:`A short line under the brand name on the title page. Leave it empty to hide it. Default: empty.`,tutorial:{page:`Document-Themes`,anchor:`branding`}},"library.theme.brand.url":{title:`Website`,body:`The web address the brand name and the title-page link open when clicked in the PDF. Leave it empty for no link. Default: empty.`,tutorial:{page:`Document-Themes`,anchor:`branding`}},"library.theme.brand.link-label":{title:`Link text`,body:`The words of a linked line under the word count on the title page; it opens Website. Leave it empty to hide the line. Default: empty.`,tutorial:{page:`Document-Themes`,anchor:`branding`}},"library.theme.contents.enabled":{title:`Contents page`,body:`Adds a table of contents after the title page, listing the article's headings with their page numbers. Each entry is a link to its page. Default: on.`,tutorial:{page:`Document-Themes`,anchor:`contents-page`}},"library.theme.contents.title":{title:`Contents page title`,body:`The heading at the top of the contents page. Up to 300 characters. Default: Table of Contents.`,tutorial:{page:`Document-Themes`,anchor:`contents-page`}},"library.theme.contents.depth":{title:`Lists headings down to`,body:`Which headings the contents page lists: only top-level ones, down to second-level, or down to third-level. Deeper lists take more room and can add a page. Default: Second level.`,tutorial:{page:`Document-Themes`,anchor:`contents-page`}},"library.theme.contents.title-offset":{title:`Contents title position`,body:`The distance from the top margin down to the contents page title, in millimetres. From 0 to 100 mm. Default: 20 mm.`,tutorial:{page:`Document-Themes`,anchor:`contents-page`}},"library.theme.contents.first-entry-offset":{title:`First entry position`,body:`The distance from the top margin down to the first entry of the contents, in millimetres. From 0 to 150 mm. Default: 40 mm.`,tutorial:{page:`Document-Themes`,anchor:`contents-page`}},"library.theme.contents.line":{title:`Contents line height`,body:`The distance from one contents entry to the next, in millimetres. From 3 to 30 mm. Default: 8 mm.`,tutorial:{page:`Document-Themes`,anchor:`contents-page`}},"library.theme.contents.indent":{title:`Indent per level`,body:`How much further in each deeper heading level is listed on the contents page, in millimetres. From 0 to 30 mm. Default: 5 mm.`,tutorial:{page:`Document-Themes`,anchor:`contents-page`}},"library.theme.header.enabled":{title:`Running header`,body:`Prints the brand and the article title ("Brand | Title") at the top of every page after the title page. Default: on.`,tutorial:{page:`Document-Themes`,anchor:`header-and-footer`}},"library.theme.header.top":{title:`Header from top`,body:`The distance from the top edge of the page to the running header, in millimetres. From 3 to 60 mm. Default: 15 mm.`,tutorial:{page:`Document-Themes`,anchor:`header-and-footer`}},"library.theme.header.max-title":{title:`Header title at most`,body:`A title longer than this many characters is cut short in the running header so it fits on one line. From 5 to 200. Default: 35.`,tutorial:{page:`Document-Themes`,anchor:`header-and-footer`}},"library.theme.footer.enabled":{title:`Page numbers`,body:`Prints a page number at the bottom of every page after the title page. Default: on.`,tutorial:{page:`Document-Themes`,anchor:`header-and-footer`}},"library.theme.footer.text":{title:`Page number text`,body:`The words around the page number; {page} becomes the number, so "Page {page}" prints "Page 4". Default: Page {page}.`,tutorial:{page:`Document-Themes`,anchor:`header-and-footer`}},"library.theme.footer.bottom":{title:`Page number from the bottom`,body:`The distance from the bottom edge of the page to the page number, in millimetres. From 3 to 60 mm. Default: 10 mm.`,tutorial:{page:`Document-Themes`,anchor:`header-and-footer`}},"library.theme.footer.reserve":{title:`Space kept above page number`,body:`Space kept free above the page number, so body text always stops short of it, in millimetres. From 0 to 60 mm. Default: 15 mm.`,tutorial:{page:`Document-Themes`,anchor:`header-and-footer`}},"library.theme.sources.enabled":{title:`Sources page`,body:`Adds a page listing the web links the article and its research used, each one clickable. Default: on.`,tutorial:{page:`Document-Themes`,anchor:`sources-page`}},"library.theme.sources.title":{title:`Sources page title`,body:`The heading at the top of the sources page. Up to 300 characters. Default: Sources Consulted.`,tutorial:{page:`Document-Themes`,anchor:`sources-page`}},"library.theme.sources.title-offset":{title:`Sources title position`,body:`The distance from the top margin down to the sources page title, in millimetres. From 0 to 100 mm. Default: 20 mm.`,tutorial:{page:`Document-Themes`,anchor:`sources-page`}},"library.theme.sources.body-offset":{title:`Sources list position`,body:`The distance from the top margin down to the first source, in millimetres. From 0 to 150 mm. Default: 40 mm.`,tutorial:{page:`Document-Themes`,anchor:`sources-page`}},"library.theme.sources.line":{title:`Sources line height`,body:`The distance between the lines of one source, in millimetres. From 3 to 30 mm. Default: 8 mm.`,tutorial:{page:`Document-Themes`,anchor:`sources-page`}},"library.theme.sources.gap":{title:`Gap between sources`,body:`Extra space between one source and the next, in millimetres. From 0 to 20 mm. Default: 2 mm.`,tutorial:{page:`Document-Themes`,anchor:`sources-page`}},"library.theme.end-page.enabled":{title:`Closing page`,body:`Adds a last page with your own text, such as an about section, a thank-you or a link to your site. Default: off.`,tutorial:{page:`Document-Themes`,anchor:`closing-page`}},"library.theme.end-page.title":{title:`Closing page title`,body:`The heading at the top of the closing page. Up to 300 characters. Default: About.`,tutorial:{page:`Document-Themes`,anchor:`closing-page`}},"library.theme.end-page.lines":{title:`Closing page text`,body:`The closing page text, one line per row, up to 60 lines of 300 characters. A line starting with "•" becomes a muted bullet, one ending with ":" a bold label, an empty line a gap. Default: empty.`,tutorial:{page:`Document-Themes`,anchor:`closing-page`}},"library.theme.end-page.details":{title:`Add date, word and page counts`,body:`Adds a Document Details list under your text: the date written, the total words and the total pages. Default: on.`,tutorial:{page:`Document-Themes`,anchor:`closing-page`}},"library.theme.end-page.link":{title:`Closing page link`,body:`Adds a clickable line after your text: the words to show and the web address it opens. Leave the address empty to show the words without a link. Default: off.`,tutorial:{page:`Document-Themes`,anchor:`closing-page`}},"library.theme.end-page.closing":{title:`Closing line`,body:`A last line after the text and the link, such as a sign-off, in the decorative font. Leave it empty to leave it out. Default: empty.`,tutorial:{page:`Document-Themes`,anchor:`closing-page`}},"library.theme.end-page.title-offset":{title:`Closing title position`,body:`The distance from the top margin down to the closing page title, in millimetres. From 0 to 100 mm. Default: 20 mm.`,tutorial:{page:`Document-Themes`,anchor:`closing-page`}},"library.theme.end-page.body-offset":{title:`Closing text position`,body:`The distance from the top margin down to the first line of the closing text, in millimetres. From 0 to 150 mm. Default: 40 mm.`,tutorial:{page:`Document-Themes`,anchor:`closing-page`}},"library.theme.metadata.author":{title:`PDF author`,body:`The author a PDF reader shows in the document properties; it is not printed on the pages. {title} becomes the article title. Default: empty.`,tutorial:{page:`Document-Themes`,anchor:`pdf-details`}},"library.theme.metadata.subject":{title:`PDF subject`,body:`The subject a PDF reader shows in the document properties. {title} becomes the article title. Default: {title}.`,tutorial:{page:`Document-Themes`,anchor:`pdf-details`}},"library.theme.metadata.keywords":{title:`PDF keywords`,body:`Search words a PDF reader shows in the document properties, usually separated by commas. Up to 1000 characters. Default: empty.`,tutorial:{page:`Document-Themes`,anchor:`pdf-details`}},"library.theme.metadata.creator":{title:`PDF creator`,body:`The app or person a PDF reader shows as the creator in the document properties. Default: empty.`,tutorial:{page:`Document-Themes`,anchor:`pdf-details`}}},ab={"planning.schedules":{title:`Schedules`,body:`A schedule starts a new project from a saved template at a local time, while Slopify is open on this machine. Each run makes a fresh project, so changing the template later never rewrites an old run. It uses the template version you picked and never includes uploaded media. Each run costs what that template's project costs.`,tutorial:{page:`Schedules`}},"planning.schedule.name":{title:`Schedule name`,body:`A name to tell this schedule apart in the list, on the calendar and on the channel page. It never appears in the videos. Up to 200 characters.`,tutorial:{page:`Schedules`,anchor:`create-a-schedule`}},"planning.schedule.template":{title:`Template`,body:`The saved template each run starts from, with its version. The schedule keeps this version when you save the template again; pick the template again here to use the newer one. The template decides the providers, and so what each run costs. Save templates from Play; they are listed in Library → Templates.`,tutorial:{page:`Schedules`,anchor:`create-a-schedule`}},"planning.schedule.cadence":{title:`Cadence`,body:`How often the schedule runs. Every day runs once a day at the local time. Selected weekdays runs on the days you tick. One time runs once at a date and time, then completes. Each run starts one project. Default: Every day at 09:00.`,tutorial:{page:`Schedules`,anchor:`when-it-runs`}},"planning.schedule.time":{title:`Local time`,body:`The clock time each run starts, read in the timezone below. Default: 09:00. A run only starts while Slopify is open; Missed run decides what happens when it was closed.`,tutorial:{page:`Schedules`,anchor:`when-it-runs`}},"planning.schedule.once-at":{title:`Run at`,body:`The date and time of the single run, read in the timezone below. After that run starts, the schedule shows as completed.`,tutorial:{page:`Schedules`,anchor:`when-it-runs`}},"planning.schedule.weekdays":{title:`Weekdays`,body:`The days a Selected weekdays schedule runs, each at the local time. Tick at least one; each ticked day is one project a week. Default: Mon, Wed and Fri.`,tutorial:{page:`Schedules`,anchor:`when-it-runs`}},"planning.schedule.timezone":{title:`Timezone`,body:`The IANA zone the run time is read in, such as Europe/Tirane or America/New_York. Default: this computer's zone. When clocks go back, a repeated time uses the earlier one; a time skipped when clocks go forward moves forward by the gap.`,tutorial:{page:`Schedules`,anchor:`when-it-runs`}},"planning.schedule.timezone-once":{title:`Timezone`,body:`The IANA zone the one-off date and time are read in, such as Europe/Tirane or America/New_York. Default: this computer's zone. When clocks go back, a repeated time uses the earlier one; nonexistent spring-forward times are refused, so pick another.`,tutorial:{page:`Schedules`,anchor:`when-it-runs`}},"planning.schedule.missed":{title:`Missed run`,body:`What happens to a run that came due while Slopify was closed or asleep. Skip drops it when it is more than 1 minute late and waits for the next time. Run once when Slopify reopens starts one catch-up run, however many were missed. Default: Skip.`,tutorial:{page:`Schedules`,anchor:`when-it-runs`}},"planning.schedule.spend":{title:`Spend ceiling`,body:`The most one run may cost, in US cents: 500 is $5.00. Before each run Slopify estimates the project's cost; when the high estimate is over this, or a cost can't be estimated, the run fails instead of starting. Leave it empty for no ceiling. Default: empty.`,tutorial:{page:`Schedules`,anchor:`when-it-runs`}},"planning.schedule.topics":{title:`Topics`,body:`Each run takes the first topic, starts one project with it and removes it from the list. The schedule completes when the list is empty, unless topic generation is on. With no topics and generation off, every run uses the template as saved. Up to 500 topics.`,tutorial:{page:`Schedules`,anchor:`topics`}},"planning.schedule.inline-topics":{title:`Queued topics`,body:`Change the queue right here: type a topic and press Enter to add it, edit one in its field and press Enter to rename it, use the arrows to move it and the cross to remove it. Each change saves at once and changes only the queue; Undo on the notice puts it back. For a topic's own keyword values, press Edit.`,tutorial:{page:`Schedules`,anchor:`edit-the-queued-topics-in-place`}},"planning.schedule.topic-format":{title:`How to write the topics`,body:`Three ways to write the same list; switching keeps everything. One per line fills only the topic keyword. Table adds a column for each keyword a topic sets itself, such as its word count. YAML / JSON holds the same as text, for pasting or keeping in a file.`,tutorial:{page:`Schedules`,anchor:`three-ways-to-write-the-list`}},"planning.schedule.topic-lines":{title:`Topics, one per line`,body:`Type or paste one topic per line; blank lines are skipped. Each topic fills the keyword under Each topic fills, and the first line is the next run. Every other keyword uses its every-run value.`,tutorial:{page:`Schedules`,anchor:`three-ways-to-write-the-list`}},"planning.schedule.topic-yaml":{title:`Topics as YAML or JSON`,body:`A list such as "- Cleopatra", or one map per topic such as "- Topic: Cleopatra" with a line for each keyword it sets, like "Min. Word Count: 12000". A JSON array works too. A keyword a topic leaves out uses its every-run value. The schedule saves only once the list reads.`,tutorial:{page:`Schedules`,anchor:`three-ways-to-write-the-list`}},"planning.schedule.topic-table":{title:`Topic table`,body:`One row per run, in order. The first column fills the topic keyword; each extra column sets that keyword for that topic's run only, and a blank cell uses the every-run value. Set a keyword per topic adds a column; the x in a column's header drops it. Project title shows the result.`,tutorial:{page:`Schedules`,anchor:`three-ways-to-write-the-list`}},"planning.schedule.topic-keyword":{title:`Each topic fills`,body:`The template keyword, such as {{Topic}}, that each queued topic replaces. Default: the keyword the template's project title uses, else the first one. When the title doesn't use it, every project gets the same title.`,tutorial:{page:`Schedules`,anchor:`which-keyword-a-topic-fills`}},"planning.schedule.every-run":{title:`Every-run value`,body:`The value this keyword gets on every run, such as a word count. Default: the template's own value. A topic that sets the keyword itself, in Table or YAML / JSON, overrides it for that one run.`,tutorial:{page:`Schedules`,anchor:`which-keyword-a-topic-fills`}},"planning.schedule.generation":{title:`Topic generation`,body:`When the queue holds fewer topics than you ask for, Slopify asks an LLM for more: one call for what is missing plus 5 spare, at most 50. It sends the series brief and every title this schedule, your projects and the channel's existing videos already have, and drops near duplicates.`,tutorial:{page:`Schedules`,anchor:`topics-that-find-themselves`}},"planning.schedule.brief":{title:`Series brief`,body:`What the series covers, its style and what makes a topic worth a video. Only topic generation reads it. Leave it empty to use the channel's series brief from the channel's Brand tab. Up to 4,000 characters.`,tutorial:{page:`Schedules`,anchor:`topics-that-find-themselves`}},"planning.schedule.new-topics":{title:`New topics`,body:`Off: you add every topic yourself. Generate and queue directly: new topics join the end of the list. Generate and hold for approval: they wait under Topics waiting, and beside the calendar, until you approve them. Each generation is one LLM call. Default: Off.`,tutorial:{page:`Schedules`,anchor:`topics-that-find-themselves`}},"planning.schedule.keep-count":{title:`Keep at least this many queued`,body:`Slopify asks for new topics whenever the queue, plus the topics waiting for approval when holding, drops below this number. A higher number keeps more topics lined up ahead of the runs, for you to review. From 1 to 100. Default: 10.`,tutorial:{page:`Schedules`,anchor:`topics-that-find-themselves`}},"planning.schedule.generation-llm":{title:`Topic generation LLM`,body:`The text model that suggests topics. Ticked, it uses the provider and model the template writes with. Untick to pick another, such as a cheaper model. Either way each generation is one call on that provider. Default: the template's LLM.`,tutorial:{page:`Schedules`,anchor:`topics-that-find-themselves`}},"planning.schedule.generate-now":{title:`Generate topics now`,body:`Asks the LLM for new topics right away, at least 5, even when the queue is full and even during the 5 minutes Slopify waits after a failed try. One LLM call. When holding for approval they wait for you; otherwise they join the queue.`,tutorial:{page:`Schedules`,anchor:`generate-topics-now`}},"planning.schedule.held-keywords":{title:`Keywords of a waiting topic`,body:`The template's other keywords, set for this one topic's run, the same as a column in the queue's table. Leave one empty to use the schedule's every-run value (shown greyed). They go with the topic into the queue when you approve it.`,tutorial:{page:`Schedules`,anchor:`approve-held-topics`}},"planning.schedule.held":{title:`Topics waiting`,body:`Topics the LLM suggested, waiting for you. Approve adds one to the end of the queue; Edit changes its words first; Reject drops it for good, so it is never suggested again. Approve all queues every one in order. Waiting topics count toward Keep at least.`,tutorial:{page:`Schedules`,anchor:`approve-held-topics`}},"planning.calendar.view":{title:`Calendar view`,body:`Weeks shows the coming 4 weeks as a grid: drag a topic to another day or onto another schedule's run, or focus it and press Alt+arrow keys. List shows the same runs day by day, with buttons to move each topic. This browser remembers your choice.`,tutorial:{page:`Calendar`,anchor:`switch-between-weeks-and-a-list`}},"planning.calendar.move":{title:`Moving topics`,body:`Earlier and later swap a topic with its neighbour in the same schedule's queue, so it takes the other's run. Move to puts it at the end of another schedule's queue, so it takes that schedule's next free run. No schedule runs outside its own times.`,tutorial:{page:`Calendar`,anchor:`move-a-topic-to-another-day`}},"planning.calendar.add-schedule":{title:`Schedule`,body:`The schedule the topics join. They go to the end of its queue, after the topics already there (the count beside each name), so they take its next free runs. Only active and paused schedules are listed.`,tutorial:{page:`Calendar`,anchor:`add-topics`}},"planning.calendar.add-topics":{title:`Topics, one per line`,body:`Each line becomes one topic, in order; blank lines are skipped. A topic fills the schedule's topic keyword, and every other keyword keeps its every-run value. To give topics their own values, edit the schedule's topics as a table under Schedules.`,tutorial:{page:`Calendar`,anchor:`add-topics`}},"planning.channels":{title:`Channels`,body:`A channel is one series: its brand kit, series brief, cast, templates and schedules. Every template belongs to one channel, and each run from it uses that channel's look and cast. The default channel holds everything made before channels and can't be deleted.`,tutorial:{page:`Channels`,anchor:`the-channels-page`}},"planning.channel.current":{title:`Current channel`,body:`Home, Projects and the calendar show only this channel's work. All channels shows everything. It only filters what you see; every project and schedule keeps its own channel. This browser remembers your choice.`,tutorial:{page:`Channels`,anchor:`show-one-channels-work`}},"planning.channel.name":{title:`Channel name`,body:`The name you see in the channel picker, on Play and on the calendar. It stays inside Slopify and doesn't have to match your YouTube channel. Up to 200 characters.`,tutorial:{page:`Channels`,anchor:`create-a-channel`}},"planning.channel.brief":{title:`Series brief`,body:`What the channel covers, its style and what makes a topic worth a video. Topic generation reads it for every schedule of this channel that has no brief of its own. It doesn't change how videos are written. Up to 10,000 characters.`,tutorial:{page:`Channels`,anchor:`brand`}},"planning.channel.ai-disclosure":{title:`YouTube AI disclosure`,body:`Studio's AI use answer for this channel's videos and Shorts, given by Prepare upload and the Studio extension. Automatic says Yes only for YouTube's three cases: a voice marked as imitating a real person, real footage altered, or photorealistic AI pictures from a marked Image prompt. Saves as you pick. Default: Automatic.`,tutorial:{page:`Publishing-to-YouTube`,anchor:`override-per-channel`}},"planning.channel.language":{title:`Language of new projects`,body:`The language this channel's new projects are written and narrated in when Play or the template picks none. It applies with the brand kit off too, since it is not styling. Pick voices that speak it. Not set means English. Projects already made keep their language.`,tutorial:{page:`Other-Languages`,anchor:`set-a-channels-language`}},"planning.channel.brand-kit":{title:`Brand kit`,body:`The look every template of this channel gets unless it sets its own: fonts, colours, end screen, intro, outro, document theme and ambient sound. It fills only what a template leaves at its default, and a blank field adds nothing. Turn it off for one video on Play or in Edit project.`,tutorial:{page:`Channels`,anchor:`brand`}},"planning.channel.brand.caption-font":{title:`Caption font`,body:`The subtitle font for this channel's videos whose template leaves the font at Default. Not set leaves the template's font alone. Fonts you upload in the subtitle font picker on Play appear here.`,tutorial:{page:`Channels`,anchor:`brand`}},"planning.channel.brand.caption-colour":{title:`Caption colour`,body:`The subtitle text colour, as # and six hex digits such as #FFFFFF, for videos whose template sets no colour of its own. Blank leaves the template's colour alone.`,tutorial:{page:`Channels`,anchor:`brand`}},"planning.channel.brand.caption-outline":{title:`Caption outline`,body:`The colour of the line around each subtitle letter, as # and six hex digits such as #000000, for videos whose template sets none. A dark outline keeps light captions readable on bright pictures. Blank leaves the template's outline alone.`,tutorial:{page:`Channels`,anchor:`brand`}},"planning.channel.brand.font":{title:`Title font`,body:`The font of chapter cards and the end screen for videos whose template sets no title style. Not set leaves the template's font alone. Fonts you upload in the subtitle font picker on Play appear here.`,tutorial:{page:`Channels`,anchor:`brand`}},"planning.channel.brand.title-colour":{title:`Title colour`,body:`The text colour of chapter cards and the end screen, as # and six hex digits such as #FFD700, for videos whose template sets no title style. Blank leaves the template's colour alone.`,tutorial:{page:`Channels`,anchor:`brand`}},"planning.channel.brand.end-screen":{title:`End screen text`,body:`A line shown over the last 5 seconds of every video of this channel whose template sets no end screen, such as Subscribe for more. Up to 200 characters. Blank shows no end screen text.`,tutorial:{page:`Channels`,anchor:`brand`}},"planning.channel.brand.intro":{title:`Intro`,body:`An entry from Library → Intros & Outros, narrated before every video of this channel whose template has no intro. Not set adds none. It adds its own length to each video and costs one voice request, since it is narrated.`,tutorial:{page:`Channels`,anchor:`brand`}},"planning.channel.brand.outro":{title:`Outro`,body:`An entry from Library → Intros & Outros, narrated after every video of this channel whose template has no outro. Not set adds none. It adds its own length to each video and costs one voice request, since it is narrated.`,tutorial:{page:`Channels`,anchor:`brand`}},"planning.channel.brand.document-theme":{title:`Document theme`,body:`The look of the PDF document for videos of this channel whose template picks no theme: a built-in theme or one you saved. Not set leaves the template's choice alone. A saved theme that was deleted is skipped.`,tutorial:{page:`Channels`,anchor:`brand`}},"planning.channel.template-move":{title:`Move a template`,body:`Moves a template, and every schedule that runs it, to another channel. Their next runs use that channel's brand kit, cast and series brief. Projects already made keep what they were made with.`,tutorial:{page:`Channels`,anchor:`templates`}},"planning.channel.episode-memory":{title:`Episode memory`,body:`When a video of this channel finishes, one short call to its text model writes a summary of up to 150 words. A new episode about the same cast or title words gets up to 5 related summaries in its writing prompt, so it agrees with them. Videos already made never change. Default: on for new channels.`,tutorial:{page:`Channels`,anchor:`episodes-episode-memory`}},"planning.channel.episode-summary":{title:`Episode summary`,body:`What the text model wrote this episode covered. Related new episodes read it before they are written. Edit it to correct a fact; your text is kept even if the video finishes again.`,tutorial:{page:`Channels`,anchor:`episodes-episode-memory`}},"planning.channel.videos-paste":{title:`Existing video titles`,body:`Titles of videos this channel made before Slopify, one per line. Topic generation and its duplicate checks skip them, as they skip the videos made here. Titles already listed are skipped, whatever their case.`,tutorial:{page:`Channels`,anchor:`existing-videos`}},"planning.channel.videos-csv":{title:`Import a YouTube Studio CSV`,body:`In YouTube Studio open Analytics → Content → Advanced mode and export the table as a CSV. Slopify reads its titles on this machine and lists them with ticks first, so you keep only this channel's videos.`,tutorial:{page:`Channels`,anchor:`existing-videos`}},"planning.channel.videos-filter":{title:`Keep only titles containing`,body:`Ticks only the titles containing this text, in any case, such as "Egypt" or "History at Bedtime"; empty ticks them all. Use it when one Studio export holds several series. Remembered for this channel's next import.`,tutorial:{page:`Channels`,anchor:`existing-videos`}},"planning.channel.videos-ticks":{title:`Titles in the CSV`,body:`Only ticked titles are added when you press Add. Untick videos of other series in the same export, or type in Keep only titles containing to tick by text.`,tutorial:{page:`Channels`,anchor:`existing-videos`}},"planning.cast.kind":{title:`Kind`,body:`Character, creature, place or object. A generated reference picture of a character or creature is portrait (9:16), of a place or object landscape (16:9), and its starting prompt asks for the whole figure, place or object in view. It doesn't change how the member is matched.`,tutorial:{page:`Cast-Library`,anchor:`fields`}},"planning.cast.name":{title:`Name`,body:`The name matched against video titles and image briefs, as whole words, ignoring case. When it is found, this member's pictures go with that image as references. Add other spellings and plurals as aliases. Up to 200 characters.`,tutorial:{page:`Cast-Library`,anchor:`fields`}},"planning.cast.aliases":{title:`Aliases`,body:`Other names that count as this member, matched as whole words, ignoring case: Cleopatra is found in Cleopatra's palace but not in Cleopatraic. Add plurals and titles such as the Last Pharaoh. Up to 20.`,tutorial:{page:`Cast-Library`,anchor:`how-names-are-matched`}},"planning.cast.description":{title:`Description for the image model`,body:`What the member looks like, in a sentence. It goes to the image model with the member's reference pictures for every image that names it, and starts the prompt of a generated picture. Up to 2,000 characters.`,tutorial:{page:`Cast-Library`,anchor:`fields`}},"planning.cast.voice":{title:`Cast voice`,body:`How this member speaks in multi-voice runs: pick them under Speakers on Play and they read with this voice, model and pace in every episode. The list shows voices that speak the channel's language. Leave the provider empty for no voice. A run keeps the voice it started with.`,tutorial:{page:`Cast-Library`,anchor:`give-a-cast-member-a-voice`}},"planning.cast.host":{title:`Channel host`,body:`A recurring voice of this channel. When you pick Podcast or Interview on Play, the draft starts with the channel's hosts that have a voice as its hosts, so you don't add them every episode. You can still remove or add speakers on the draft. Projects already made are unchanged.`,tutorial:{page:`Cast-Library`,anchor:`make-a-member-one-of-the-channels-hosts`}},"planning.cast.pictures":{title:`Reference pictures`,body:`Up to 4 pictures per member, sent with every image whose brief, or the video's title, names it, so it looks the same each time. Upload a PNG or JPEG up to 10 MB, or generate one below. Videos already made keep the pictures they started with.`,tutorial:{page:`Cast-Library`,anchor:`add-reference-pictures`}},"planning.cast.generate":{title:`Make a reference picture`,body:`Pick an image provider and model, describe the picture, then press Generate a picture. Each press is one image call on that provider, billed at its price for one image. A plain background with the whole figure in view makes the best reference.`,tutorial:{page:`Cast-Library`,anchor:`generate-a-picture`}},"planning.cast.picture-prompt":{title:`Picture to make`,body:`The prompt for the generated reference picture. It starts from the name, the description and a request for a plain background; edit it as you like. Up to 4,000 characters.`,tutorial:{page:`Cast-Library`,anchor:`generate-a-picture`}},"planning.links.named":{title:`Named links`,body:`Write {{Name}} in a YouTube description, or ask for it in a Description prompt, and it becomes the link of that name when the description is shown, copied or downloaded, such as {{Patreon}} or {{Discord}}. Each channel keeps its own list on its Brand tab, so a project fills from its channel's links; its own {{Previous video}} wins over the channel's. A name with no link stays as typed. Save channel keeps the list.`,tutorial:{page:`YouTube-Description`,anchor:`links-in-the-description`}}},ob={"play.template":{title:`Template`,body:`Starts this video from a saved setup: prompts, voice, images, style, outputs and reviews. Picking one opens a fresh draft made from it and carries the topic you typed. No template starts from the default setup. Save a setup you like with Save as template in the right rail.`,tutorial:{page:`Play-Overview`,anchor:`template`}},"play.title":{title:`Title`,body:`The video's name, shown on the project and in Projects. Write a keyword in double braces, like {{Topic}}, and the title becomes a pattern: you type the topic per video, and Add topic queues more videos from the same setup. Up to 200 characters.`,tutorial:{page:`Play-Overview`,anchor:`title-title-pattern-and-topic`}},"play.title-pattern":{title:`Title pattern`,body:`The title with its keywords in double braces, like History: {{Topic}}. Each keyword in it is a topic you type at the top of Play, once per video, and templates save it empty. Change the pattern here; the topic values stay at the top.`,tutorial:{page:`Play-Overview`,anchor:`title-title-pattern-and-topic`}},"play.topic":{title:`Topic`,body:`What this video is about. The title names this keyword, so its value fills the title and every prompt that names it. Each video from this setup gets its own value, and a template leaves it empty. Up to 200 characters.`,tutorial:{page:`Play-Overview`,anchor:`title-title-pattern-and-topic`}},"play.keyword":{title:`Keyword`,body:`A value a picked prompt or the title asks for with {{name}}. You type it once and it fills every place that names it; the line under it lists where. Up to 200 characters. A keyword the title does not name is saved with a template.`,tutorial:{page:`Play-Overview`,anchor:`keywords`}},"play.more-videos":{title:`More videos from the same setup`,body:`Add topic queues another video with everything else the same: only its title and keywords differ. Press a chip to change that video's keywords. Start queues all of them, and they run one at a time. One Start queues at most 50 videos.`,tutorial:{page:`Play-Overview`,anchor:`more-videos-from-the-same-setup`}},"play.drafts":{title:`Drafts`,body:`Play saves every change to this draft on its own; nothing starts until you press the Play key. Drafts lists your saved setups to open again or discard. New draft starts an empty one and keeps this one in the list.`,tutorial:{page:`Play-Overview`,anchor:`drafts`}},"play.draft-conflict":{title:`Changed elsewhere`,body:`This draft was saved from another tab or window since you opened it. Reload saved draft shows that version and drops your unsaved change. Save as a new draft keeps your version as a separate draft and leaves the other one alone.`,tutorial:{page:`Play-Overview`,anchor:`when-a-draft-was-changed-elsewhere`}},"play.source.research":{title:`Research source`,body:`Generate has the text model plan chapters, research each one on the web and combine the notes before the article is written: one call to plan, one per chapter and one to combine. Provide uses notes you paste. Off, the default, writes from the prompt alone.`,tutorial:{page:`Play-Title-and-Article`,anchor:`research`}},"play.source.article":{title:`Article source`,body:`Generate has the text model write the article from the article prompt, one call. Provide narrates text you paste, word for word, with no text-model cost. The article is what the narration reads and the PDF lays out. Default: Generate.`,tutorial:{page:`Play-Title-and-Article`,anchor:`choose-where-the-article-comes-from`}},"play.source.audio":{title:`Narration source`,body:`Generate reads the article aloud with a text-to-speech voice, charged by the provider per character. Provide uses an audio file you upload, as it is. Off makes a silent video with no captions, YouTube description or shorts. Default: Generate.`,tutorial:{page:`Play-Narration`,anchor:`choose-where-the-narration-comes-from`}},"play.source.images":{title:`Images source`,body:`Generate draws images from the ticked image prompts, one image-model call each. Provide uses your own PNG, JPEG or WebP files in the order you pick them. Off turns off the video too. Default: Generate.`,tutorial:{page:`Play-Images`,anchor:`choose-where-the-images-come-from`}},"play.source.thumbnail":{title:`Thumbnail source`,body:`From prompt draws the thumbnail straight from the thumbnail prompt, one image call. Prompt by LLM first has the text model write the image prompt from yours, the title and the article, then draws it. Provide uses your own image. Default: Off.`,tutorial:{page:`Play-Outputs`,anchor:`thumbnail`}},"play.source.video":{title:`Video source`,body:`Generate renders the slideshow video on this computer from the images and narration; it costs no provider money, only time. Off leaves each finished stage to download on its own. It needs images, so it is Off while Images is Off. Default: Generate.`,tutorial:{page:`Play-Video-and-Style`,anchor:`choose-whether-to-render-a-video`}},"play.source.document":{title:`Document source`,body:`Generate lays out a PDF of the article and title on this computer, in the theme you pick. It needs no provider and costs nothing. Default: Off.`,tutorial:{page:`PDF-Documents`,anchor:`make-a-pdf`}},"play.article-prompt":{title:`Article prompt`,body:`The Library prompt the text model is sent to write the article, with its keywords filled in. A Script prompt, used when several speakers read, asks for speaker turns instead. Write or change prompts on Prompts; View prompt shows the text.`,tutorial:{page:`Play-Title-and-Article`,anchor:`generate-an-article-from-a-prompt`}},"play.provided.article":{title:`Article text`,body:`The article you paste is narrated word for word, and no text model writes one. Include everything that should be read, headings too. The count under it helps you judge the length: about 150 words is one minute of narration.`,tutorial:{page:`Play-Title-and-Article`,anchor:`paste-your-own-article`}},"play.provided.research":{title:`Research notes`,body:`Notes you paste are given to the text model with the article prompt, in place of web research. Paste facts, sources and quotes the article should draw on. Nothing is looked up.`,tutorial:{page:`Play-Title-and-Article`,anchor:`give-your-own-research-notes`}},"play.text-generation":{title:`Text generation`,body:`One text model writes everything this run needs in words: the article, research, the thumbnail's image prompt, entries set to LLM, Narration Preparation, the YouTube description and picking shorts. Each is a separate call, counted in usage. Set the default under Settings.`,tutorial:{page:`Play-Title-and-Article`,anchor:`text-generation`}},"play.llm.provider":{title:`LLM`,body:`Who runs the text model: a command-line tool you are signed in to, such as Claude Code or Codex, or a keyed service such as OpenRouter, billed per token. A greyed provider says why it cannot be used; fix it under Settings.`,tutorial:{page:`Play-Title-and-Article`,anchor:`text-generation`}},"play.llm.model":{title:`Text model`,body:`The model the provider runs for every text step. Bigger models write better and cost more per token. Refresh asks the provider for its current list; Custom ID lets you type a model the list does not show.`,tutorial:{page:`Play-Title-and-Article`,anchor:`text-generation`}},"play.llm.thinking":{title:`Thinking`,body:`How long the model reasons before it answers, for models that offer it. Higher levels can write more carefully but take longer and use more tokens. Model default leaves it to the provider.`,tutorial:{page:`Play-Title-and-Article`,anchor:`text-generation`}},"play.tts.provider":{title:`TTS`,body:`The text-to-speech service that reads the narration, charged by the provider per character of text. A greyed provider says why it cannot be used; add its key under Settings. Changing it clears the model and voice.`,tutorial:{page:`Play-Narration`,anchor:`pick-a-voice`}},"play.tts.model":{title:`TTS model`,body:`The provider's speech model. Models differ in quality, languages, speed and price per character. Some features need a particular model: Narration Preparation needs Inworld TTS-2. Refresh asks the provider for its current list.`,tutorial:{page:`Play-Narration`,anchor:`pick-a-voice`}},"play.voice":{title:`Voice`,body:`Who reads the narration. The list holds the voices you added under Settings → Voices for this provider, filtered to the project's language. With several speakers, this voice reads the intro and outro.`,tutorial:{page:`Play-Narration`,anchor:`pick-a-voice`}},"play.show-all-voices":{title:`Show all voices`,body:`The voice list hides voices listed for other languages than the project's. Tick this to pick one anyway, for example a multilingual voice whose languages are listed wrong. A voice with unknown languages is always shown.`,tutorial:{page:`Play-Narration`,anchor:`pick-a-voice`}},"play.intro":{title:`Intro`,body:`A Library entry read before the article. A text entry is read as written; an LLM entry is written by the text model for each video, one extra call. Off reads no intro. Write entries in Library → Intros & Outros.`,tutorial:{page:`Play-Narration`,anchor:`intro-and-outro`}},"play.outro":{title:`Outro`,body:`A Library entry read after the article, such as a sign-off. A text entry is read as written; an LLM entry is written by the text model for each video, one extra call. Off reads no outro.`,tutorial:{page:`Play-Narration`,anchor:`intro-and-outro`}},"play.chunking":{title:`Chunking`,body:`How the narration is split into text-to-speech requests. Whole sends it in one request; Paragraph sends one per paragraph; Every N words or characters ends each at a sentence end. Split when a provider refuses long text. Default: Whole. It changes the number of requests, not the characters charged.`,tutorial:{page:`Play-Narration`,anchor:`chunking`}},"play.chunking.count":{title:`Chunk size`,body:`How long each text-to-speech request may be. Each request ends at the last whole sentence that fits, so a single longer sentence stays whole. Defaults: 500 words or 3000 characters, spaces included.`,tutorial:{page:`Play-Narration`,anchor:`chunking`}},"play.narration-preparation":{title:`Narration Preparation`,body:`Has the text model add delivery directions and sounds, such as a sigh or a laugh, following the Library narration prompt you pick. One text-model call per narration chunk and per entry. Needs Inworld TTS-2. The article and captions stay unchanged. Default: Off.`,tutorial:{page:`Play-Narration`,anchor:`narration-preparation`}},"play.pronunciation-glossary":{title:`Pronunciation Glossary`,body:`Reads names with the IPA in the article's Pronunciation Glossary, such as Arda: /ˈɑɹdə/, with no extra text-model call. In your article prompt, ask for a glossary in slash-delimited standard-English IPA (Term: /IPA/), with an English approximation for foreign names; a line with sounds English lacks is read as plain text. Works with Inworld TTS-2 and TTS-2 Flash. The written text stays unchanged. Default: on.`,tutorial:{page:`Narration-Aliases-and-Glossary`,anchor:`the-pronunciation-glossary`}},"play.share-glossary":{title:`Pronunciations from other projects`,body:`Adds every term from your other projects' glossaries, copied when this project starts. This project's own glossary wins where they differ. Turn it off to use only this article's glossary. Default: on.`,tutorial:{page:`Narration-Aliases-and-Glossary`,anchor:`the-pronunciation-glossary`}},"play.describe-figures":{title:`Describe tables and figures`,body:`Instead of skipping tables, pictures, equations and code or reading them cell by cell, the text model writes a short spoken passage for each (a table's pattern, what a figure or equation means, what code does) and the narration says it in its place. One extra text-model call per block, in the estimate, kept for reuse. The article and PDF keep the real table; captions show what is said. Needs a text model. Default: on.`,tutorial:{page:`Play-Narration`,anchor:`tables-figures-and-code`}},"play.show-figures":{title:`Show tables and figures on screen`,body:`Each table, figure, equation and code block the narration describes is also shown in the video while it is described: the article's own picture for a figure, a card drawn in your brand kit's title font and colour for the rest. The images take turns around them, and Shorts that include one show it upright. Drawn on this computer at no cost. Needs Describe tables and figures. Default: on.`,tutorial:{page:`Play-Outputs`,anchor:`show-tables-and-figures-on-screen`}},"play.skip-code":{title:`Leave code out`,body:`Drops code blocks from the narration instead of summarising each in a sentence or two. Tables, figures and equations are still described. Default: off.`,tutorial:{page:`Play-Narration`,anchor:`tables-figures-and-code`}},"play.narration-aliases":{title:`Narration aliases`,body:`Says the words listed in Library → Aliases the way they are written there, such as Dr. as Doctor, with any generated voice. They are copied when the project starts. The article and captions keep the written words. Default: on.`,tutorial:{page:`Narration-Aliases-and-Glossary`,anchor:`use-aliases-in-a-video`}},"play.speakers.format":{title:`Speakers format`,body:`Narration uses one voice. Audiobook, Podcast, Radio drama and Interview give lines to several speakers, each with a voice. Several speakers need the text model to write or split the script. A new Podcast or Interview starts with the channel's hosts (cast members marked as hosts, with a voice).`,tutorial:{page:`Multiple-Voices`,anchor:`formats`}},"play.speakers.script":{title:`Script`,body:`Write a script has the text model write speaker turns from a Script prompt, one Name: words paragraph each. Split the article keeps the article as written and has the text model hand its narration and dialogue to the speakers, one extra call.`,tutorial:{page:`Multiple-Voices`,anchor:`the-script`}},"play.speakers.add-from-cast":{title:`Add from the cast`,body:`Adds a member of this channel's cast as a speaker, with their name and voice. Only members with a voice are listed. Edit the cast on the channel's page.`,tutorial:{page:`Multiple-Voices`,anchor:`speakers-from-a-channels-cast`}},"play.speakers.book":{title:`A chapter of a book`,body:`Makes this audiobook one chapter of a book. The MP3 and M4B are tagged with the book as their album and the chapter as their track, so a player keeps the chapters together and in order. When the chapter is done, Make the next chapter on its project page starts the next one with the same speakers and settings.`,tutorial:{page:`Multiple-Voices`,anchor:`audiobooks-in-chapters`}},"play.speakers.book-title":{title:`Book title`,body:`The book this chapter belongs to, the same for every chapter. It becomes the album of the MP3 and M4B files.`,tutorial:{page:`Multiple-Voices`,anchor:`audiobooks-in-chapters`}},"play.speakers.book-chapter":{title:`Chapter`,body:`This chapter's number in the book, from 1 to 9999. It becomes the track number of the MP3 and M4B files.`,tutorial:{page:`Multiple-Voices`,anchor:`audiobooks-in-chapters`}},"play.speakers.turn-gap":{title:`Gap between turns`,body:`The pause between one speaker's turn and the next, from 0 to 1.2 seconds. Longer feels calmer; shorter feels like a lively talk. Default: 0.35 s.`,tutorial:{page:`Multiple-Voices`,anchor:`run-wide-options`}},"play.speakers.name-tags":{title:`Speaker names on captions`,body:`Puts the speaker's name before their captions, like Ada: and their words, so viewers know who is talking. On by default for a podcast or interview.`,tutorial:{page:`Multiple-Voices`,anchor:`run-wide-options`}},"play.speakers.native-dialogue":{title:`One request for consecutive turns`,body:`Sends back-to-back turns as one multi-speaker request where the provider has one (ElevenLabs v3 with up to 10 voices, Gemini TTS with 2), so the voices react to each other. Fewer requests, same characters charged. Other providers read each turn on its own.`,tutorial:{page:`Multiple-Voices`,anchor:`run-wide-options`}},"play.speakers.audio-files":{title:`MP3 and M4B files`,body:`Also saves the narration as an MP3 and an M4B audiobook file with a chapter marker at each chapter, beside the video. Made on this computer at no provider cost.`,tutorial:{page:`Multiple-Voices`,anchor:`run-wide-options`}},"play.speaker.name":{title:`Speaker name`,body:`The name the script uses for this speaker's turns (Name: words) and the one captions and the speaker panel show. Up to 40 characters.`,tutorial:{page:`Multiple-Voices`,anchor:`speaker-options`}},"play.speaker.role":{title:`Role`,body:`What this speaker does in the format: narrator, host, guest or character. The text model is told each speaker's role when it writes or splits the script.`,tutorial:{page:`Multiple-Voices`,anchor:`speaker-options`}},"play.speaker.provider":{title:`Voice provider`,body:`The text-to-speech service for this speaker, charged per character of their lines. Speakers may use different providers. Changing it clears the model and voice.`,tutorial:{page:`Multiple-Voices`,anchor:`speaker-options`}},"play.speaker.model":{title:`Voice model`,body:`The provider's speech model for this speaker. Models differ in quality, languages and price per character. Pronunciations need an Inworld TTS-2 model.`,tutorial:{page:`Multiple-Voices`,anchor:`speaker-options`}},"play.speaker.voice":{title:`Speaker voice`,body:`This speaker's voice, from the voices you added under Settings → Voices for their provider, filtered to the project's language. Press Audition to hear it read their first line.`,tutorial:{page:`Multiple-Voices`,anchor:`speaker-options`}},"play.speaker.pace":{title:`Pace`,body:`How fast this speaker talks, from 0.8× to 1.2× of the voice's own speed. Default: Normal.`,tutorial:{page:`Multiple-Voices`,anchor:`speaker-options`}},"play.speaker.pronunciations":{title:`Speaker pronunciations`,body:`One Term: /IPA/ per line, like the article's Pronunciation Glossary, for this speaker only. Used on Inworld TTS-2 voices, ahead of the glossary. A line with sounds the language does not use is skipped and read as ordinary text.`,tutorial:{page:`Multiple-Voices`,anchor:`speaker-options`}},"play.speaker.audition":{title:`Audition`,body:`Speaks this speaker's first line in their voice so you can hear it before the run. It is one real text-to-speech request, charged by the provider at about the price shown on the button.`,tutorial:{page:`Multiple-Voices`,anchor:`speaker-options`}},"play.images.provider":{title:`Image provider`,body:`Who draws the images, the thumbnail and the shorts' pictures: a keyed service such as fal.ai, billed per image, or a command-line tool you are signed in to. A greyed provider says why it cannot be used; fix it under Settings.`,tutorial:{page:`Play-Images`,anchor:`pick-the-image-provider-and-model`}},"play.images.model":{title:`Image model`,body:`The provider's image model. Models differ in quality, speed and price per image; the estimate in the right rail shows what this run costs. Refresh asks the provider for its current list.`,tutorial:{page:`Play-Images`,anchor:`pick-the-image-provider-and-model`}},"play.images.effort":{title:`Effort`,body:`How long an image agent, such as the Codex CLI, reasons before it draws. Higher effort can follow the prompt more closely but takes longer and uses more tokens. Model default leaves it to the provider.`,tutorial:{page:`Play-Images`,anchor:`drawing-with-the-codex-cli`}},"play.image-prompts":{title:`Image prompts`,body:`Tick the Library prompts that draw the video's images, and give each a number: how many images it makes, 1 to 20. A run makes at most 60 this way. Each image is one image-model call. The images play in the order you ticked the prompts.`,tutorial:{page:`Play-Images`,anchor:`pick-the-image-prompts`}},"play.reference":{title:`Establishing image`,body:`Made first and never shown in the video. Every other image, the shorts' and, if ticked, the thumbnail is drawn with it as a reference, so characters, style and palette stay the same. From a prompt costs one more image; Upload uses yours. Changing it marks those images outdated. Default: Off.`,tutorial:{page:`Play-Images`,anchor:`establishing-image`}},"play.reference.prompt":{title:`Establishing prompt`,body:`The Library image prompt that draws the establishing image, its keywords filled like the others. Describe the characters, setting and style every other image should share.`,tutorial:{page:`Play-Images`,anchor:`establishing-image`}},"play.reference.thumbnail":{title:`Thumbnail from the establishing image`,body:`Draws the thumbnail with the establishing image as a reference too, so it matches the video. Untick it for a thumbnail drawn on its own. Default: on.`,tutorial:{page:`Play-Images`,anchor:`establishing-image`}},"play.image-scale":{title:`More images for long videos`,body:`Adds images as the narration gets longer, planned from the expected length when the run starts. The extra images are shared among the ticked prompts in order, up to 240 in all; each is one more image call. The line under it shows the count. Turning it on switches Motion from Zoom to Mix of both.`,tutorial:{page:`Play-Images`,anchor:`more-images-for-long-videos`}},"play.image-scale.rate":{title:`Image rate`,body:`Give the rate as one image every N minutes of narration (0.25 to 60) or as N images per hour (1 to 240); switching keeps the same rate. Narration runs about 150 words a minute. Starts at one image every 2 minutes.`,tutorial:{page:`Play-Images`,anchor:`more-images-for-long-videos`}},"play.image-seconds":{title:`Seconds per image`,body:`How long each image stays on screen, 1 to 600 seconds. When cuts follow the narration, it is the target and a cut waits for a sentence end. When images run out they start again. Default: 15.`,tutorial:{page:`Play-Video-and-Style`,anchor:`timing-and-motion`}},"play.zoom":{title:`Zoom`,body:`How far each image zooms in or out over its time on screen, 0 to 50 percent. 0 keeps images still. Default: 22.5 percent.`,tutorial:{page:`Play-Video-and-Style`,anchor:`timing-and-motion`}},"play.motion":{title:`Motion`,body:`How each image moves while on screen: Zoom in and out, Pan across, a Mix of both by turns, or Still. A mix keeps a long video watchable. Default: Zoom in and out.`,tutorial:{page:`Play-Video-and-Style`,anchor:`timing-and-motion`}},"play.edge-silence":{title:`Silence at start and end`,body:`Quiet time before the narration starts and after it ends, 0 to 30 seconds. Default: 2.`,tutorial:{page:`Play-Video-and-Style`,anchor:`timing-and-motion`}},"play.silence-gap":{title:`Silence between segments`,body:`Seconds of quiet between the intro and the narration, and between the narration and the outro, 0 to 30. It only matters when an intro or outro is set. Leave it empty to use the gap set in Settings, 3 seconds unless you changed it.`,tutorial:{page:`Play-Narration`,anchor:`silence-at-the-edges-and-between-segments`}},"play.format":{title:`Frame format`,body:`16:9 is a landscape video for YouTube and screens. 9:16 is a portrait video for phones. Images are drawn in this shape and captions are placed for it. Default: 16:9.`,tutorial:{page:`Play-Video-and-Style`,anchor:`frame-format`}},"play.preview-text":{title:`Preview text`,body:`The sample sentence the style preview shows in your caption font, size and position. It is only for the preview and never reaches the video; real captions come from the narration.`,tutorial:{page:`Play-Video-and-Style`,anchor:`style-preview`}},"play.thumbnail-prompt":{title:`Thumbnail prompt`,body:`The Library thumbnail prompt, keywords filled in. From prompt sends it to the image model as it is; Prompt by LLM gives it to the text model with the title and article to write the image prompt. Write prompts on Prompts.`,tutorial:{page:`Play-Outputs`,anchor:`thumbnail`}},"play.thumbnail-count":{title:`Thumbnails`,body:`Three makes two more thumbnails from the same prompt with different compositions, for YouTube's Test & compare. Each costs one more image, so 3 thumbnails are 3 image calls. You can remake each on its own on the project page. Default: 1.`,tutorial:{page:`Play-Outputs`,anchor:`make-three-thumbnails-for-test--compare`}},"play.youtube-description":{title:`YouTube description`,body:`After subtitle timing, the text model writes a description with chapters at the narration's real times, hashtags at the end, and a separate list of tags, ready to copy. One text-model call. It runs beside the render. Needs narration. Default: off.`,tutorial:{page:`YouTube-Description`,anchor:`turn-it-on`}},"play.description-prompt":{title:`Description prompt`,body:`The Library prompt the description is written from. Built-in asks for a short summary, 5 to 12 chapters, 3 to 5 hashtags and 15 to 25 tags. Write your own description prompt on Prompts to change the tone or add links.`,tutorial:{page:`YouTube-Description`,anchor:`turn-it-on`}},"play.shorts":{title:`Shorts`,body:`After subtitle timing, the text model picks the best self-contained moments of the narration. Each becomes a vertical 1080×1920 clip with new images, big word-by-word captions and its own title, description and hashtags. It runs beside the render; its images are charged like any other. Needs narration. Default: off.`,tutorial:{page:`Shorts`,anchor:`turn-on-shorts`}},"play.shorts.count":{title:`How many shorts`,body:`How many shorts to cut from this video, 1 to 10. Each needs its own new images, so more shorts cost more image calls and render time. Default: 3.`,tutorial:{page:`Shorts`,anchor:`options`}},"play.shorts.length":{title:`Short length`,body:`The shortest and longest a short may run, in seconds, between 15 and 180. The text model picks moments within these bounds. Default: 60 to 120.`,tutorial:{page:`Shorts`,anchor:`options`}},"play.shorts.prompt":{title:`Shorts prompt`,body:`The Library prompt the text model follows to pick the moments and write each short's title, description and hashtags. Built-in picks moments that make sense alone and open on a hook.`,tutorial:{page:`Shorts`,anchor:`options`}},"play.shorts.image-style":{title:`Image style`,body:`The Library image prompt the shorts' new vertical images are drawn from. Built-in draws cinematic, uncluttered images with the subject centred. Pick one of your image prompts to match the long video.`,tutorial:{page:`Shorts`,anchor:`options`}},"play.shorts.title-on-screen":{title:`Title on screen`,body:`Keeps the short's title at the top for the whole clip, large and bold in the caption font, below where the apps draw their own buttons. Default: on.`,tutorial:{page:`Shorts`,anchor:`options`}},"play.shorts.preview":{title:`Shorts preview`,body:`A few seconds of the sample project's narration and images as a short: vertical, through the same renderer your shorts use, with the big word-by-word captions in your caption font, the title on screen when it is on, and the speed you chose. It renders again by itself a moment after you change a setting, costs no API calls, and Render again forces a fresh one.`,tutorial:{page:`Shorts`,anchor:`shorts-preview`}},"play.shorts.speed":{title:`Speed`,body:`Plays each short faster than the narration, 1.00× to 1.25× in steps of 0.05, with the pitch kept. A little faster suits short-form viewers. Default: 1.00×.`,tutorial:{page:`Shorts`,anchor:`options`}},"play.shorts.music-volume":{title:`Music volume`,body:`How loud the background music plays under every short, 0 to 100 percent; it dips while the narrator speaks. Only used when you add a music file below. Default: 15.`,tutorial:{page:`Shorts`,anchor:`add-background-music`}},"play.shorts.full-video-link":{title:`Full video link`,body:`Each short's description ends with a line pointing to the full video. Paste the video's link here; without it the line says [PASTE THE FULL VIDEO LINK HERE] for you to fill in.`,tutorial:{page:`Shorts`,anchor:`options`}},"play.document-theme":{title:`Theme`,body:`How the PDF looks: a built-in theme or one of yours from Library → Documents. A theme of yours is copied into the project, so editing it later leaves this project alone until you pick it again. Edit themes opens the list.`,tutorial:{page:`PDF-Documents`,anchor:`options`}},"play.checkpoints":{title:`Review checkpoints`,body:`Holds the run before a step so you can check and edit what came before it. Steps that do not depend on it carry on. Approve each checkpoint on the project page to continue. A step must be generated to have a checkpoint.`,tutorial:{page:`Reviews-and-Checkpoints`,anchor:`add-a-checkpoint-on-play`}},"play.reviews":{title:`Automatic reviews`,body:`A reviewer model checks each finished item and saves its verdict and reasons on the project page. Flag only marks a failed item; Flag and redo makes it again, up to the redos per item, then keeps and flags it. Each review is a text-model call, counted in usage. Default: Off.`,tutorial:{page:`Reviews-and-Checkpoints`,anchor:`set-up-automatic-reviews`}},"play.reviews.provider":{title:`Reviewer`,body:`Who runs the review model. Picture reviews, for images, the thumbnail and shorts, need Claude Code or Codex, which can look at images; other providers review text only.`,tutorial:{page:`Reviews-and-Checkpoints`,anchor:`set-up-automatic-reviews`}},"play.reviews.model":{title:`Reviewer model`,body:`The model that judges each item. A stronger model catches more but costs more per review. It can differ from the model that wrote the text.`,tutorial:{page:`Reviews-and-Checkpoints`,anchor:`set-up-automatic-reviews`}},"play.reviews.retries":{title:`Redos per item`,body:`How many times Flag and redo makes a failed item again before it keeps the last one and flags it, 0 to 5. Each redo costs the item again plus one more review. Default: 2.`,tutorial:{page:`Reviews-and-Checkpoints`,anchor:`set-up-automatic-reviews`}},"play.channel":{title:`Channel`,body:`The channel this video belongs to. Its brand kit fills what this setup leaves at its default, and its cast of characters goes with the images. A draft that picks none runs in its template's channel, or the default one.`,tutorial:{page:`Play-Overview`,anchor:`channel-row`}},"play.brand-kit":{title:`Channel's brand kit`,body:`Fills what this setup leaves at its default from the channel: the caption font, intro, outro, document theme and ambient sound. What you set here wins. Turn it off to take none of it; the cast and language still apply. Default: on.`,tutorial:{page:`Play-Overview`,anchor:`channel-row`}},"play.language":{title:`Language`,body:`The language the article, narration, YouTube description and shorts titles are written in. Pick a voice that speaks it. Outside English, captions are timed with a free 248 MB model, downloaded once, where one exists. On Play, blank uses the channel's language.`,tutorial:{page:`Other-Languages`,anchor:`pick-a-language-for-one-video`}},"play.estimate":{title:`Estimated cost`,body:`What the providers are likely to charge for this run, in US dollars, from their published prices. Actual usage can differ, and the estimate does not cap spending.`,tutorial:{page:`Play-Overview`,anchor:`estimated-cost`}},"play.expected-words":{title:`Expected article words`,body:`How long you expect each generated article to be. It drives the cost estimate and how many images More images for long videos adds; the article's real length is used once it is written. About 150 words is one minute. Default: 1500.`,tutorial:{page:`Play-Overview`,anchor:`expected-article-words-per-video`}},"play.refresh-review":{title:`Refresh review`,body:`Asks the server to check the setup again and recalculate the estimate now, instead of waiting for you to pause typing. Use it after changing a prompt in the Library.`,tutorial:{page:`Play-Overview`,anchor:`review-the-whole-setup`}},"play.template-name":{title:`Template name`,body:`The name the template is listed under on Play and Templates. The template keeps this setup's settings; the topic you typed and any extra videos are left out, as the list below says.`,tutorial:{page:`Play-Overview`,anchor:`save-as-template`}},"play.queue":{title:`Video queue`,body:`Videos started together run one at a time, in this order. Pausing a project holds the queue; when one fails or is cancelled, the next one starts.`,tutorial:{page:`Play-Overview`,anchor:`the-video-queue`}},"play.voices.name":{title:`Voice name`,body:`The name you pick this voice by on Play and in Edit project. Only you see it.`,tutorial:{page:`Providers-and-Keys`,anchor:`add-a-voice`}},"play.voices.provider":{title:`Voice provider`,body:`The text-to-speech service the voice ID belongs to. Only providers set up under Settings are listed.`,tutorial:{page:`Providers-and-Keys`,anchor:`add-a-voice`}},"play.voices.voice-id":{title:`Voice ID`,body:`The provider's own id for the voice, copied from its voice library. It is not checked now; a wrong id fails when a run's narration uses it. For Google Gemini, pick one of its 30 prebuilt voices instead.`,tutorial:{page:`Providers-and-Keys`,anchor:`add-a-voice`}},"play.voices.languages":{title:`Voice languages`,body:`The languages the voice speaks, as codes such as es, de. Play lists the voice only for projects in these languages. Blank asks the provider when it can say; a voice with unknown languages is offered for every language.`,tutorial:{page:`Providers-and-Keys`,anchor:`add-a-voice`}},"play.voices.real-person":{title:`Real person`,body:`Turn this on for a voice cloned from, or made to sound like, a real person. Prepare upload then answers Yes to YouTube's AI use question for videos it narrates. An AI voice that imitates no one stays off.`,tutorial:{page:`Providers-and-Keys`,anchor:`add-a-voice`}}},sb={"project.next-chapter":{title:`Make the next chapter`,body:`Opens a new draft on Play for this book's next chapter: the same speakers and voices, channel and cast, prompts and settings, with the chapter number one higher. Write or paste the new chapter's text there, then start it. The MP3 and M4B carry the book as their album and the chapter as their track. An audiobook that is not a book yet becomes one, named after it, starting at chapter 2.`,tutorial:{page:`Multiple-Voices`,anchor:`make-the-next-chapter`}},"project.video.cuts":{title:`Cuts`,body:`Every N seconds holds each image for Seconds per image. Follow the narration cuts in the pause after a sentence, as close to that length as the sentences allow (never under 40% of it), and starts a new image at every chapter. It needs word timing, so it works in English and the languages that have it. New projects default to Follow the narration.`,tutorial:{page:`Video-Editing`,anchor:`cuts`}},"project.video.transition":{title:`Transition`,body:`How one image hands over to the next: Cut, Crossfade, Fade through black, Slide or Wipe. The change is centred on the cut and takes the length you pick (0.2 to 2 s), so the video stays exactly as long as its narration. Default: Cut, 0.6 s.`,tutorial:{page:`Video-Editing`,anchor:`cuts`}},"project.video.grade":{title:`Colour grade`,body:`A colour treatment over the whole video: Warm fantasy, Cold, Desaturated or Sepia. It is applied while the video renders, so it costs no API calls, only render time. Default: None.`,tutorial:{page:`Video-Editing`,anchor:`the-look`}},"project.video.vignette":{title:`Vignette`,body:`Darkens the corners of the picture to draw the eye to the middle. Subtle or Strong. Applied while the video renders, with no API cost. Default: Off.`,tutorial:{page:`Video-Editing`,anchor:`the-look`}},"project.video.grain":{title:`Film grain`,body:`Adds moving film grain over the whole picture for an older, filmic feel. Subtle or Strong. Applied while the video renders, with no API cost. Default: Off.`,tutorial:{page:`Video-Editing`,anchor:`the-look`}},"project.video.atmosphere":{title:`Atmosphere`,body:`An overlay Slopify draws itself: rising embers, drifting dust, or low fog along the bottom of the frame. No footage is downloaded and no API is called; it only adds render time. Default: None.`,tutorial:{page:`Video-Editing`,anchor:`the-look`}},"project.video.chapter-cards":{title:`Chapter cards`,body:`Shows each chapter's title in the middle of the picture for 2.5 seconds as the chapter starts, in the caption font. Chapters come from the YouTube description when that step runs, otherwise from the article's headings. Needs narration. Default: off.`,tutorial:{page:`Video-Editing`,anchor:`the-look`}},"project.video.animate":{title:`Animate images`,body:`Turns some images into 5-second moving clips with an image-to-video model on your image provider (fal.ai or Replicate). Chapter openers animates the first image of each chapter; Every Nth image animates every 2nd to 10th. Each clip is one paid call, shown in the estimate. An image that cannot be animated stays still. Default: Off.`,tutorial:{page:`Video-Editing`,anchor:`the-look`}},"project.pause.sentence":{title:`Pause between sentences`,body:`The least quiet after each sentence, in seconds. Some voices barely breathe between sentences; this adds silence where the pause is shorter, never shortening one or cutting a word, and the captions follow. About 0.25 s is brisk, 0.35 to 0.45 natural or documentary, 0.5 to 0.8 an audiobook's relaxed pace, 0.8 and up sleep content. Default: 0.4; 0 keeps the voice's own.`,tutorial:{page:`Editing-a-Project`,anchor:`pauses-and-volume`}},"project.pause.paragraph":{title:`Pause between paragraphs`,body:`The least quiet at the end of a paragraph, in seconds, when you want more than between sentences. Usually the narration prompt and the voice pace paragraphs well already, so it is 0 by default: paragraphs get the sentence pause. Try 0.8 to 1.2 for a slower read. A speaker's turn gap is set under Speakers instead. Runs on this computer.`,tutorial:{page:`Editing-a-Project`,anchor:`pauses-and-volume`}},"project.loudness":{title:`Level the volume`,body:`Brings every narration piece (each chunk, and each speaker's turn) to one loudness before they are joined, so the voice stops jumping between quiet and loud. Then the video, the shorts and the audio files are each set to a finished loudness. Runs on this computer, no API calls; turning it on remakes the levelled narration and the exports, never the speech. Default: on for new runs.`,tutorial:{page:`Editing-a-Project`,anchor:`pauses-and-volume`}},"project.loudness.video":{title:`Video volume`,body:`How loud the finished video and shorts are, in dB from the recommended level. LUFS is how loud a file sounds on average (the scale YouTube and Spotify use); YouTube and Spotify play everything at about -14 LUFS, so 0 dB here is -14 LUFS. -6 dB is about half as loud (50%), +4 dB about 158%. Peaks always stay under -1.5 dBTP.`,tutorial:{page:`Editing-a-Project`,anchor:`pauses-and-volume`}},"project.loudness.audio-files":{title:`Audio files volume`,body:`How loud the audio-only WAV and an audiobook's MP3 and M4B are, in dB from -18 LUFS, the level audiobook shops such as ACX ask for (-18 to -23 LUFS). LUFS is how loud a file sounds on average. Type dB or a percentage of the recommended level; peaks always stay under -3 dBTP, which those shops require.`,tutorial:{page:`Editing-a-Project`,anchor:`pauses-and-volume`}},"project.ambient.source":{title:`Ambient sound`,body:`Rain, a fireplace or wind made on this computer, or your own audio file, played quietly under the whole narration of the long video. It dips while the narrator speaks. Costs no API calls. Shorts never get it. Changing it remakes only the video. Default: None, or the channel's bed.`,tutorial:{page:`Video-Editing`,anchor:`ambient-sound`}},"project.ambient.level":{title:`Ambient level`,body:`How loud the ambient sound plays under the voice, in decibels from -40 (barely there) to -6 (close to the voice). Whole numbers only. Default: -18 dB.`,tutorial:{page:`Video-Editing`,anchor:`ambient-sound`}},"project.ambient.fade-in":{title:`Ambient fade in`,body:`How many seconds the ambient sound takes to rise from silence at the start of the video, 0 to 30 in half-second steps. Default: 3 seconds.`,tutorial:{page:`Video-Editing`,anchor:`ambient-sound`}},"project.ambient.tail":{title:`Ambient tail`,body:`How long the ambient sound keeps playing, fading out, after the narration ends: 0 to 30 seconds in half-second steps. A tail longer than the silence at the end makes the video that much longer. Default: 6 seconds.`,tutorial:{page:`Video-Editing`,anchor:`ambient-sound`}},"project.subtitles.mode":{title:`Subtitles`,body:`Off makes none. Subtitle files gives you .srt and .vtt files to upload beside the video. Burn into video draws the captions into the picture and also makes the files; it needs Video on. Captions are timed from your narration on this computer, with no paid API; the first use downloads a speech model of about 95 MB. Default: Off.`,tutorial:{page:`Video-Editing`,anchor:`subtitles`}},"project.subtitles.font":{title:`Subtitle font`,body:`The typeface of burned-in captions and chapter cards. Pick a bundled font or one you uploaded (.ttf or .otf); uploaded fonts stay available to every project. Subtitle files carry no font, since players style them. Changing it remakes only the video. Default: the bundled font.`,tutorial:{page:`Video-Editing`,anchor:`subtitles`}},"project.subtitles.size":{title:`Subtitle font size`,body:`How big burned-in captions are, from 16 to 120. Larger is easier to read on phones but covers more of the picture. Default: 48.`,tutorial:{page:`Video-Editing`,anchor:`subtitles`}},"project.subtitles.position":{title:`Subtitle position`,body:`Where burned-in captions sit on the frame: Top, Upper-middle, Center, Lower-middle or Bottom. Move them up when the pictures have important detail near the bottom. Subtitle files ignore it. Default: Bottom.`,tutorial:{page:`Video-Editing`,anchor:`subtitles`}},"project.video.style-preview":{title:`Style preview`,body:`Six seconds of the sample project's narration and images, rendered on this computer by the real video renderer with your captions, Look and motion, on the establishing image or a cast picture when there is one. The captions follow the narration word by word. It renders again by itself a moment after you change a setting. It costs no API calls, only a few seconds of your computer's time. Render again forces a fresh one.`,tutorial:{page:`Video-Editing`,anchor:`style-preview`}},"project.edit.article-text":{title:`Article text`,body:`The script the narrator reads, in Markdown. Your edits are kept when other settings change and are saved as a new revision; the narration, images and video made from the old text turn outdated and are remade when you choose. Headings become chapters.`,tutorial:{page:`Editing-a-Project`,anchor:`change-the-article-text`}},"project.edit.regenerate-article":{title:`Regenerate article after review`,body:`Marks the article to be written again by the text model, which is one or more paid text calls. Nothing runs yet: the rebuild review lists it with the narration, images and video it outdates, and you start it there. It replaces any edits you made to the article.`,tutorial:{page:`Editing-a-Project`,anchor:`regenerate-the-article`}},"project.saved-revision":{title:`Saved revision`,body:`Every save of Edit project is a revision: a snapshot of the settings and content. Continuing a run always uses the current one. Saving never starts work; outputs the change affects turn outdated and keep their old version until remade. Remaking is offered as the next action, and History lets you go back.`,tutorial:{page:`Editing-a-Project`,anchor:`history-and-saved-revisions`}},"project.choose-remake":{title:`Choose what to remake`,body:`Opens the rebuild review for every outdated or failed output: what will be made again, kept or skipped, what it costs, and which inputs changed. Nothing runs until you press Remake there, and Keep things as they are closes it with nothing spent.`,tutorial:{page:`Editing-a-Project`,anchor:`choose-what-to-remake`}},"project.prompts.template":{title:`Use saved template`,body:`Copies a prompt from your Library into this project, replacing the raw prompt below. The project keeps its own copy, so later Library edits reach it only when you pick it again or press Use the Library version. Outputs made from the old wording turn outdated; nothing is remade until you choose.`,tutorial:{page:`Editing-a-Project`,anchor:`prompts`}},"project.prompts.raw":{title:`Raw prompt`,body:`This project's own copy of the prompt, with keywords still in double braces such as {{Topic}}. Edit it to change what the model is asked for this project only; the Library prompt is untouched. Saving fills the keywords in again, and what was made from the old wording turns outdated.`,tutorial:{page:`Editing-a-Project`,anchor:`prompts`}},"project.edit.rewrite-description":{title:`Write the description again`,body:`Marks the YouTube description to be written again by the text model, one paid text call. Nothing runs yet: save, and it is remade when you continue the run or start the rebuild review. The description you have now is replaced.`,tutorial:{page:`YouTube-Description`,anchor:`write-it-again-or-turn-it-on-later`}},"project.shorts.clips":{title:`Picked clips`,body:`The moments the text model picked for your shorts, each shown by its first and last sentence. Earlier and Later move a clip's start or end by one sentence; Use my own range picks both from lists. Moving a clip costs no calls and keeps its images where the sentences stay the same. Changes apply when you save and continue the run.`,tutorial:{page:`Shorts`,anchor:`change-the-picked-moments`}},"project.shorts.range":{title:`Clip range`,body:`The first and last sentence of this short, from the narration's timed sentences. The clip must stay between the shortest and longest length you set for shorts and must not overlap another clip; the line under the clip says what to change. Back to the AI's choice restores its pick.`,tutorial:{page:`Shorts`,anchor:`change-the-picked-moments`}},"project.shorts.pick-again":{title:`Pick different moments`,body:`Asks the text model to pick new moments when you save and continue the run, one text call. Ranges you set by hand are dropped. A new clip on the same sentences as an old one keeps its images; any other clip gets new images, one image call each, and is rendered again.`,tutorial:{page:`Shorts`,anchor:`pick-new-moments-or-remake-one-short`}},"project.shorts.remake":{title:`Make this short again`,body:`Makes this one short again when you save and continue the run: its image prompts are written again, its images are drawn again (one image call each) and it is rendered again. Its moment, title and the other shorts stay as they are.`,tutorial:{page:`Shorts`,anchor:`pick-new-moments-or-remake-one-short`}},"project.images.editor":{title:`Edit images`,body:`Every image of the video in the order it is shown. You can edit a drawn image's prompt, replace any image with your own file, move it earlier or later, delete it, or add a drawn image, your own picture or a video clip. A clip plays muted in an image's place, trimmed, slowed or looped to fit. Changes apply after you save.`,tutorial:{page:`Editing-a-Project`,anchor:`edit-images`}},"project.images.prompt":{title:`Image prompt`,body:`The words this one image is drawn from, with keywords in double braces filled in from the project. Editing it outdates only this image and the video; it is drawn again, one image call, when you remake outdated outputs. Use saved wording as template copies the prompt as sent so you can edit it.`,tutorial:{page:`Editing-a-Project`,anchor:`edit-images`}},"project.images.regenerate":{title:`Regenerate image after review`,body:`Marks this image to be drawn again from its prompt, one paid image call, with a new result. Nothing runs yet: save, and the rebuild review lists it with the video it outdates. The current image stays until the new one is made.`,tutorial:{page:`Editing-a-Project`,anchor:`edit-images`}},"project.narration.editor":{title:`Edit narration`,body:`The narration split into the chunks it was spoken in. Edit a chunk's text, replace its audio with your own file, or have it spoken again. Only the chunks you touch are made again, paid per character, and the video is rendered again with them. Changes apply after you save.`,tutorial:{page:`Editing-a-Project`,anchor:`edit-narration`}},"project.narration.chunk-text":{title:`Narration chunk text`,body:`What the narrator says in this chunk. Editing it has this chunk spoken again by your voice provider, paid per character of the chunk, when you remake outdated outputs; the other chunks keep their audio. Captions and the video follow. It does not change the article.`,tutorial:{page:`Editing-a-Project`,anchor:`edit-narration`}},"project.narration.regenerate":{title:`Regenerate narration chunk after review`,body:`Marks this chunk to be spoken again with the same text and voice, paid per character of the chunk, for a new take when a word came out wrong. Nothing runs yet: save, and it is made again when you continue the run. The current audio stays until then.`,tutorial:{page:`Editing-a-Project`,anchor:`edit-narration`}},"project.captions.editor":{title:`Caption text and timing`,body:`Each caption's words and when it shows, in seconds from the start of the narration. Fix a misheard word or move a caption a little earlier or later; captions must not overlap and must end after they start. Edits cost nothing and only the subtitle files and the video are made again. The narration is not changed.`,tutorial:{page:`Editing-a-Project`,anchor:`edit-captions`}},"project.captions.apply":{title:`Apply caption edits to draft`,body:`Checks every caption (text present, times in order, inside the narration) and puts your edits into the project draft. Nothing is saved until you press Save changes, and the video is rendered again only when you remake outdated outputs.`,tutorial:{page:`Editing-a-Project`,anchor:`edit-captions`}},"project.youtube.summary":{title:`Summary`,body:`The opening of the YouTube description, written by the text model from the article. Edit changes it in place and keeps your text as yours: when the description is written again, your summary stays and the new one waits beside it with Use it, Keep mine and View diff. Use generated goes back to the model's text.`,tutorial:{page:`YouTube-Description`,anchor:`edit-a-part`}},"project.youtube.chapters":{title:`Chapters`,body:`Timestamped chapter lines at the narration's real times, which YouTube turns into chapters. YouTube needs the first at 0:00, at least three, each at least 10 seconds long. Edit changes them in place and your edit survives the next rewrite; Use generated goes back.`,tutorial:{page:`YouTube-Description`,anchor:`chapters-follow-youtubes-rules`}},"project.youtube.hashtags":{title:`Hashtags`,body:`The hashtags at the end of the description; YouTube shows the first three above the title. Edit changes them in place and your edit survives the next rewrite, with the new ones offered beside it. Use generated goes back to the model's.`,tutorial:{page:`YouTube-Description`,anchor:`edit-a-part`}},"project.youtube.tags":{title:`Tags`,body:`Search tags for YouTube's Tags field, which allows 500 characters in all, commas included. They are not shown to viewers. Edit changes them in place and your edit survives the next rewrite; Copy gives them comma-separated, ready to paste.`,tutorial:{page:`YouTube-Description`,anchor:`edit-a-part`}},"project.youtube.previous-video":{title:`Previous video for this project`,body:`The link that {{Previous video}} fills in this project's description, ahead of the one on its channel's Brand tab. Paste the video this one follows on from. It changes only what is shown and copied, with no text call. Save links keeps it.`,tutorial:{page:`YouTube-Description`,anchor:`previous-video`}},"project.live.writing":{title:`Live writing`,body:`The text model's words as they arrive, so you can see the article or research taking shape. When a stage makes several calls, the list picks which one to watch. Follow output keeps the newest text in view; untick it to read back. Watching costs nothing extra; the full text is saved when the stage finishes.`,tutorial:{page:`Project-Page`,anchor:`live`}},"project.checkpoints.choices":{title:`Checkpoint choices`,body:`A checkpoint holds the run before a step so you can check and edit what came before it. Tick a step that has not started to add one; untick to remove it, and work already admitted for that step carries on when ready. Pausing the project still applies. Only generated steps can have one. Save checkpoints applies the change.`,tutorial:{page:`Project-Page`,anchor:`checkpoints`}},"project.rebuild.keep-provided":{title:`Keep the provided content`,body:`This output uses a file or text you supplied, and something it depends on, such as the narration, has changed since. Tick to confirm it still fits and keep it as it is. To use something else, cancel and replace the file in Edit project first. Remake stays off until you tick it.`,tutorial:{page:`Editing-a-Project`,anchor:`choose-what-to-remake`}},"project.rebuild.unknown-costs":{title:`Unknown cost estimates`,body:`Some steps use a model with no published price, so their cost cannot be estimated and is left out of the total shown. Tick to start anyway; the real cost is recorded under Cost once they run. Remake stays off until you tick it.`,tutorial:{page:`Editing-a-Project`,anchor:`choose-what-to-remake`}},"project.cost.by-stage":{title:`Cost by stage`,body:`What each stage of this project has cost so far, from every provider call it made, retries and remakes included, priced from the model catalogue when each call finished. Failed calls are not charged here, and taxes and included credits are not counted. Stage time is how long the stage ran.`,tutorial:{page:`Costs-and-Run-Cost`,anchor:`after-a-run-the-run-cost-tab`}},"project.cost.by-model":{title:`Cost by model`,body:`The same spending split by provider and model. Cost is what you paid the provider. Calls through a signed-in command-line tool such as Claude Code or Codex cost $0 on your plan; Via API shows what the same work would cost through the provider's API, for comparison only.`,tutorial:{page:`Costs-and-Run-Cost`,anchor:`after-a-run-the-run-cost-tab`}},"project.upload.item":{title:`What to upload`,body:`Switches the list between the long video and each short, since each is uploaded to YouTube on its own with its own title, description and tags. The ticks and the Fill in YouTube Studio button follow the one you pick.`,tutorial:{page:`Publishing-to-YouTube`,anchor:`upload-a-video`}},"project.upload.real-footage":{title:`Real footage`,body:`Turn this on when the video clips you uploaded are filmed footage, not made by AI. The AI use answer then checks them: laying a Look atmosphere such as fog over real footage makes it Yes, while colour, vignette or grain count as minor edits and keep it No. It is saved with the project and changes nothing in the video.`,tutorial:{page:`Publishing-to-YouTube`,anchor:`ai-use-disclosure`}},"project.upload.steps":{title:`Upload steps`,body:`Everything YouTube Studio asks for, in the order it asks: file, title, description, thumbnail, playlist, audience, AI use and tags. Copy puts each value on the clipboard. The tick box beside each step is only a note to yourself, remembered in this browser; it changes nothing in the project.`,tutorial:{page:`Publishing-to-YouTube`,anchor:`upload-a-video`}},"project.upload.fill-studio":{title:`Fill in YouTube Studio`,body:`Opens Studio's upload page and adds this item to what waits for the Slopify Studio extension, which must be installed and paired (Settings, YouTube Studio). Each upload dialog you start is filled with the first waiting item. If Studio's dialog lacks a field, nothing is filled and the whole pack is copied instead. You check it and press Publish; Slopify never uploads or publishes.`,tutorial:{page:`Studio-Extension`,anchor:`fill-in-an-upload`}},"project.upload.queue":{title:`Waiting for Studio`,body:`The videos and shorts Fill in YouTube Studio added, oldest first, from every project. Each new upload dialog in Studio is filled with the first, which then leaves the list. It survives restarting Slopify; an item waits up to 24 hours, and a new pairing token clears the list. Remove takes an item out without filling it.`,tutorial:{page:`Studio-Extension`,anchor:`upload-several-one-after-another`}},"project.free-space":{title:`Free space`,body:`Once a project has finished, it can drop the working files it was made from (images, narration parts, subtitle timing, render settings) and keep what gets published: the video, shorts, thumbnail, article, description, document and anything you uploaded. The button says how much space that frees. Changing the project later makes those files again first, which takes time and provider credits. Settings → Storage offers the same for every project.`,tutorial:{page:`Project-Page`,anchor:`free-space`}},"project.mark-uploaded":{title:`Mark uploaded`,body:`Records that you uploaded this finished video to YouTube yourself, so it leaves the ready-to-upload lists on Home and here and shows an Uploaded badge. Slopify does not upload anything or check YouTube. Undo takes the mark off.`,tutorial:{page:`Publishing-to-YouTube`,anchor:`mark-a-video-uploaded`}},"project.edit.update-glossary":{title:`Update from other projects`,body:`Copies your other projects' Pronunciation Glossary terms into this project again, picking up any added since the last copy. The project keeps its own copy, so nothing changes until you press this. After you save, only the narration chunks whose words those terms change are spoken again, paid per character.`,tutorial:{page:`Narration-Aliases-and-Glossary`,anchor:`the-pronunciation-glossary`}},"project.edit.show-figures":{title:`Show tables and figures on screen`,body:`Shows each described table, figure, equation and code block in the video while its description is spoken, as the article's picture or a card drawn on this computer at no cost. Turning it on or off renders the video again, and any Shorts that include a card; the narration is kept. The cards appear under Images, From the article, and can be made again there.`,tutorial:{page:`Play-Outputs`,anchor:`show-tables-and-figures-on-screen`}},"project.edit.describe-figures":{title:`Describe tables and figures`,body:`The text model writes a short spoken passage for each table, figure, equation and code block, said in its place. Turning it on costs one text-model call per block, and after you save, the narration chunks that contain a block are spoken again, paid per character (the whole narration when Chunking is the whole article). Other chunks keep their audio; captions and timing are redone to match.`,tutorial:{page:`Play-Narration`,anchor:`tables-figures-and-code`}},"project.edit.update-aliases":{title:`Update from Library`,body:`Copies Library, Aliases into this project again, picking up aliases added or changed since the last copy. The project keeps its own copy, so a Library edit reaches it only when you press this. After you save, only the narration chunks the changed aliases touch are spoken again, paid per character.`,tutorial:{page:`Narration-Aliases-and-Glossary`,anchor:`use-aliases-in-a-video`}}},cb={"settings.diagnostics":{title:`Download diagnostics`,body:`Saves slopify-diagnostics.json: the Slopify version, your system and Node version, which providers are set up or found, the project count and the model catalogue's state. It never holds your keys, prompts or project content. Attach it to a bug report so the problem can be found faster.`,tutorial:{page:`Troubleshooting`,anchor:`download-diagnostics`}},"settings.autostart":{title:`Start Slopify when you log in`,body:`Slopify starts in the background when you log in to this computer, without opening a browser tab; open it from your bookmark. It uses your account's own start-up list, so no administrator password is needed, and turning it off removes exactly what it added. Default: off. In Docker, Slopify starts whenever Docker does, so this only shows Docker's own setting.`,tutorial:{page:`Start-at-Login`,anchor:`turn-it-on`}},"settings.providers.api-key":{title:`API key`,body:`The key that lets Slopify call this provider on your account; the provider bills you for what it makes. It is stored on this computer only, sent only to that provider, and never put in a backup or export. Paste a new key and Save to replace the old one.`,tutorial:{page:`Providers-and-Keys`,anchor:`add-a-key`}},"settings.providers.test-key":{title:`Test`,body:`Asks the provider whether the key works, with the cheapest harmless call it allows. A key pasted in the field is tested before you save it; with the field empty, the saved key is. Nothing is generated, billed or stored. When it fails, the answer says why: a rejected key, missing permission, no credit, or the provider being down.`,tutorial:{page:`Providers-and-Keys`,anchor:`test-a-key`}},"settings.provider.openrouter":{title:`OpenRouter`,body:`Writes the text (research, script, article, titles, descriptions) with hundreds of models from many companies through one key. Each call is charged per token from the credit you buy on OpenRouter; prices follow the model catalogue. Choose it when you want a model the command-line tools do not offer.`,tutorial:{page:`Providers-and-Keys`,anchor:`openrouter`}},"settings.provider.claude-code":{title:`Claude Code CLI`,body:`Writes the text with the Claude Code command-line tool on this computer, using your own Claude sign-in, so no API key is needed and calls count toward your Claude plan's limits instead of costing per call. Sign in first by running claude auth login in a terminal. Slopify runs up to 3 calls at once.`,tutorial:{page:`AI-CLIs`,anchor:`set-up-a-cli`}},"settings.provider.codex":{title:`Codex CLI`,body:`Writes the text with the Codex command-line tool on this computer, using your own ChatGPT sign-in, so no API key is needed and calls count toward your plan's limits instead of costing per call. Sign in first by running codex login in a terminal. Slopify runs up to 3 calls at once.`,tutorial:{page:`AI-CLIs`,anchor:`set-up-a-cli`}},"settings.provider.gemini":{title:`Gemini CLI`,body:`Writes the text with the Gemini command-line tool on this computer, using your own Google sign-in, so no API key is needed. Sign in first by running gemini in a terminal and following its login steps. Slopify runs up to 3 calls at once.`,tutorial:{page:`AI-CLIs`,anchor:`set-up-a-cli`}},"settings.provider.codex-image":{title:`Codex CLI images`,body:`Draws the images with the Codex command-line tool, using your ChatGPT sign-in instead of an API key, so images count toward your plan's limits rather than costing per image. It shares its executable path and sign-in with Codex text. Slopify draws up to 4 images at once.`,tutorial:{page:`AI-CLIs`,anchor:`codex-images`}},"settings.provider.elevenlabs":{title:`ElevenLabs`,body:`Narrates the script with ElevenLabs voices, including voices you added to your ElevenLabs account. It is billed in characters of narration from your ElevenLabs plan. A restricted key needs Text to Speech and Models read access.`,tutorial:{page:`Providers-and-Keys`,anchor:`elevenlabs`}},"settings.provider.openai-tts":{title:`OpenAI speech`,body:`Narrates the script with OpenAI's text-to-speech voices. It is billed per character or per audio minute, depending on the model, from prepaid credit on your OpenAI platform account; new accounts need at least $5 of credit before any call works.`,tutorial:{page:`Providers-and-Keys`,anchor:`openai-speech`}},"settings.provider.cartesia":{title:`Cartesia`,body:`Narrates the script with Cartesia voices, billed in characters from your Cartesia plan. The free plan needs no card, so it is an easy way to try narration.`,tutorial:{page:`Providers-and-Keys`,anchor:`cartesia`}},"settings.provider.inworld":{title:`Inworld`,body:`Narrates the script with Inworld voices, billed per character from your Inworld account. Paste the Base64 credentials of a Standard key exactly as shown; Realtime-only keys do not work.`,tutorial:{page:`Providers-and-Keys`,anchor:`inworld`}},"settings.provider.system-voice":{title:`System voice`,body:`Narrates with the speech your computer already has: macOS voices, Windows voices, or on Linux Piper, SVOX Pico or eSpeak NG. No key, no account and no charge, but it sounds robotic next to ElevenLabs or OpenAI. On Linux, install espeak-ng if nothing is found. Its models are the speech programs Slopify found; add one of their voices in Settings → Voices.`,tutorial:{page:`Providers-and-Keys`,anchor:`the-system-voice`}},"settings.provider.google-tts":{title:`Google Gemini voices`,body:`Narrates with Gemini's 30 prebuilt voices, billed to your Gemini API key per text and audio token. It uses the key saved for Google images unless you save one here. Two speakers' consecutive turns can go in one request (see Speakers on Play).`,tutorial:{page:`Providers-and-Keys`,anchor:`google-gemini-speech`}},"settings.provider.fal":{title:`fal.ai`,body:`Draws the images and thumbnails with the image models fal.ai hosts, charged per image from prepaid credit. fal.ai locks the account when the balance runs out, so a run stops at the images step until you add credit.`,tutorial:{page:`Providers-and-Keys`,anchor:`falai`}},"settings.provider.replicate":{title:`Replicate`,body:`Draws the images and thumbnails with the image models Replicate hosts, charged per image or per second of compute from credit you buy up front.`,tutorial:{page:`Providers-and-Keys`,anchor:`replicate`}},"settings.provider.openai-image":{title:`OpenAI images`,body:`Draws the images and thumbnails with OpenAI's GPT Image models, charged per image from prepaid credit on your OpenAI platform account. GPT Image may also need Verify Organization on the OpenAI platform before it works.`,tutorial:{page:`Providers-and-Keys`,anchor:`openai-images`}},"settings.provider.google-image":{title:`Google images`,body:`Draws the images and thumbnails with Google's Gemini image models, charged per image. Use a key made in Google AI Studio on a project with billing set up; Gemini image models are not on the free tier.`,tutorial:{page:`Providers-and-Keys`,anchor:`google`}},"settings.cli.path":{title:`Executable path`,body:`Where the command-line tool is on this computer. Leave it blank and Slopify finds it on PATH, the list of folders your terminal searches. Set an absolute path, without quotes or arguments, when the tool is installed somewhere else or you have more than one copy. Save checks the tool answers.`,tutorial:{page:`AI-CLIs`,anchor:`set-the-executable-path`}},"settings.cli.managed-on-host":{title:`Managed on host`,body:`Slopify runs in Docker, so this tool runs on your computer outside the container, with the sign-in it already has there. Its path cannot be changed here. After you install, update or remove a command-line tool, run the Docker launcher again so Slopify sees the change.`,tutorial:{page:`AI-CLIs`,anchor:`in-docker-the-host-helper`}},"settings.health":{title:`Health check`,body:`Asks each command-line tool whether it is signed in, makes the cheapest harmless call each saved key allows (nothing is generated or billed), and checks that the models your templates, schedules, drafts and projects use are still offered and answer for your key. Run it after changing a key or when a run stops at a provider; Check again on a provider's row checks that one alone.`,tutorial:{page:`Providers-and-Keys`,anchor:`check-all-providers`}},"settings.models.catalogue":{title:`Model catalogue`,body:`The list of models, prices and retirements the pickers and cost estimates use. Slopify checks the published catalogue and OpenRouter's live list when it starts and once a day; Check now does it at once. New models appear and prices update; nothing you made changes. Your own edits to the local file are kept.`,tutorial:{page:`Models`,anchor:`what-the-catalogue-covers`}},"settings.models.replace":{title:`Replace with published file`,body:`Overwrites the local catalogue file with the published one, dropping any edits you made to it. The previous file is saved beside it first, so you can copy your edits back. Use it when the local file is broken or you want the published list exactly.`,tutorial:{page:`Models`,anchor:`replace-the-local-file-with-the-published-one`}},"settings.models.retired":{title:`Retired models in use`,body:`Templates, schedules, drafts and projects with steps still to run that pick a model the provider no longer offers. A run that reaches one stops and says so. Switch replaces only that one model choice with the suggestion shown; Switch all does every one that has a suggestion.`,tutorial:{page:`Models`,anchor:`switch-away-from-a-retired-model`}},"settings.playback.silence-gap":{title:`Silence between segments`,body:`Seconds of quiet between the intro and the narration, and between the narration and the outro, in every new video, unless Play sets a different gap for one video. It only matters when an intro or outro is set; 0 runs them together. Default: 3 seconds, from 0 to 30. Videos already started keep their own gap.`,tutorial:{page:`Settings-Reference`,anchor:`silence-between-segments`}},"settings.loudness":{title:`Level the volume for new runs`,body:`Whether a new run on Play (and a template or quick short) starts with Level the volume on, and at which volumes. On evens out every narration piece and sets the video to about -14 LUFS, the loudness YouTube plays at, and the audio files to -18 LUFS. A project keeps what it started with; change it there in Edit project. Default: on.`,tutorial:{page:`Settings-Reference`,anchor:`level-the-volume-for-new-runs`}},"settings.appearance":{title:`Appearance`,body:`Light or dark colours for Slopify on this computer. System follows your operating system's setting and changes with it. Default: System. It changes at once and does not affect your videos.`,tutorial:{page:`Settings-Reference`,anchor:`appearance`}},"settings.notifications":{title:`Notifications`,body:`Slopify tells you when a run finishes, fails, or stops to wait for your review, and when an automatic review kept an item flagged and needs your decision. The message holds the project title, what happened and a link to the project, never your keys. Browser notifications need a Slopify tab open; a Notification URL works with none open.`,tutorial:{page:`Notifications`,anchor:`when-slopify-notifies-you`}},"settings.notifications.browser":{title:`Browser notifications`,body:`Shows a notification from this browser while any Slopify tab is open, even in the background. Turning it on asks the browser's permission. It applies to this browser only, so turn it on in each browser you use. Default: off.`,tutorial:{page:`Notifications`,anchor:`turn-on-browser-notifications`}},"settings.notifications.url":{title:`Notification URL`,body:`An address Slopify POSTs a short plain-text message to, with no tab open. For your phone, install the ntfy app, subscribe to a topic with a long random name, and paste https://ntfy.sh/that-topic. Any address that accepts a POST works. Each message is sent once, with a 5 second timeout. Leave it empty to turn it off.`,tutorial:{page:`Notifications`,anchor:`get-notifications-on-your-phone-notification-url`}},"settings.studio.extension":{title:`Upload pack and extension`,body:`Slopify never uploads or publishes. A finished project's Prepare upload lists everything Studio asks for, with Copy buttons. The optional Slopify Studio browser extension fills Studio's upload dialog from that pack; you still press Publish. Install it from Install the Studio extension below: Download, three steps, then pair it with the token.`,tutorial:{page:`Studio-Extension`,anchor:`get-the-extension`}},"settings.studio.playlist":{title:`Playlist`,body:`The YouTube playlist an upload pack names, so the extension ticks it in Studio's dialog. Pick Every channel for the default, or a channel to give it its own; a channel without its own uses the default. Type it exactly as it is called in Studio, up to 150 characters. Empty means no playlist (for a channel: the default). Default: empty.`,tutorial:{page:`Studio-Extension`,anchor:`settings--youtube-studio`}},"settings.studio.install":{title:`Install the Studio extension`,body:`The extension comes with Slopify: Download saves it for the browser picked, nothing is fetched from a store. Chrome, Edge and Brave load the unzipped folder with Load unpacked (Developer mode); Firefox 128 or newer loads the zip as a temporary add-on, which it forgets on restart. Then pair it with the token above. A new Slopify may bring a new extension: download and load it again after updating.`,tutorial:{page:`Studio-Extension`,anchor:`get-the-extension`}},"settings.studio.pairing":{title:`Extension pairing token`,body:`A secret the Slopify Studio extension needs before it may read your upload packs, so no other page can. Copy it into the extension's options and press Pair. New pairing token makes a fresh one and unpairs the extension until you paste the new token.`,tutorial:{page:`Studio-Extension`,anchor:`pair-it-with-slopify`}},"settings.storage.export":{title:`Export and import`,body:`Export everything saves every project with its files and history, your library, templates, schedules, Play drafts, fonts, settings and usage in one .tar file; never provider keys. Import adds to this install and replaces nothing: projects already here are skipped, taken names arrive as “(imported)” and schedules arrive paused. Running projects must finish or pause first.`,tutorial:{page:`Where-Your-Files-Live`,anchor:`export-and-import`}},"settings.storage.clean":{title:`Clean orphan files`,body:`Deletes files in the projects folder that no project records any more, and uploaded files that no draft, template or project uses. Your projects, outputs and library are never touched. Slopify also does this each time it starts; use it after a crash or to free space now.`,tutorial:{page:`Where-Your-Files-Live`,anchor:`clean-orphan-files`}},"settings.storage.disk":{title:`Disk space`,body:`What Slopify stores on this computer: project files (outputs plus the working files they were made from), staged uploads, and deleted projects still in the trash. Deleted projects free their space when the trash removes them after 30 days, or when you choose Delete now.`,tutorial:{page:`Where-Your-Files-Live`,anchor:`disk-space`}},"settings.storage.keep-outputs":{title:`Keep outputs only`,body:`On a finished project, deletes the working files it was made from (images, narration parts, subtitle timing, render settings) and keeps the video, shorts, thumbnail, article, description, document and your uploads. Changing the project later makes those files again first, which takes time and provider credits.`,tutorial:{page:`Where-Your-Files-Live`,anchor:`keep-outputs-only`}},"settings.sample.restore":{title:`Sample projects`,body:`The finished examples that come with Slopify: a narrated video, an audiobook and a podcast, which you can look through without spending anything. Restore samples adds back any that were deleted and replaces the others with the originals. Your own copies of them are not touched.`,tutorial:{page:`Where-Your-Files-Live`,anchor:`sample-projects`}},"settings.files":{title:`Your files`,body:`Your projects, automatic backups and exports live here; new installs use Documents/Slopify. The database, settings, keys and logs stay in Slopify's hidden data folder. Moving copies every file, checks each copy by size and checksum, then switches, and keeps the old folder until you delete it. It takes as long as copying your projects and cannot start while a project is being made.`,tutorial:{page:`Where-Your-Files-Live`,anchor:`see-your-files`}},"settings.files.docker":{title:`Your files`,body:`Your projects and backups are in the folders Docker shares with this computer. The container cannot move its own folders, so run the command shown on the computer running Docker: the installer waits for running work, copies your projects, checks the copy and remounts the new folder.`,tutorial:{page:`Where-Your-Files-Live`,anchor:`see-your-files`}},"settings.files.new-folder":{title:`New folder`,body:`The full path of the folder your files move to, on another disk or a synced folder for example. Slopify makes Projects and Backups inside it. It must be empty or not exist yet. The move needs as much free space there as your projects take now.`,tutorial:{page:`Where-Your-Files-Live`,anchor:`move-your-files-to-another-folder`}},"settings.backups":{title:`Daily backup`,body:`Once a day Slopify writes the file Export everything makes into the backup folder and deletes its own oldest backups beyond the number you keep. Nothing else there is touched. A backup waits while projects are being made; if Slopify was off at the time, it backs up a couple of minutes after it starts. Each backup can be many gigabytes.`,tutorial:{page:`Backups`,anchor:`turn-on-daily-backups`}},"settings.backups.auto":{title:`Back up automatically`,body:`Turns the daily backup on or off. Default: off, because each backup holds every project's video and can fill a disk. Back up now works either way. Press Save after changing it.`,tutorial:{page:`Backups`,anchor:`turn-on-daily-backups`}},"settings.backups.time":{title:`Time of day`,body:`When the daily backup runs, in this browser's time zone. Pick a time the computer is usually on and idle; a backup waits for running projects. Default: 03:00.`,tutorial:{page:`Backups`,anchor:`when-the-daily-backup-runs`}},"settings.backups.keep":{title:`Keep last`,body:`How many of Slopify's own backups stay in the folder; after a new one is written, the oldest beyond this number are deleted. Each holds everything, so disk use grows with this number. Default: 5, from 1 to 30.`,tutorial:{page:`Backups`,anchor:`turn-on-daily-backups`}},"settings.backups.folder":{title:`Backup folder`,body:`Where backups are written. Leave it empty to use the Backups folder beside your projects (Documents/Slopify/Backups on a new install), which moves with them. Point it at another disk or a synced folder to keep copies away from this disk. Slopify only ever deletes its own backup files there.`,tutorial:{page:`Backups`,anchor:`where-the-files-go-and-what-they-are-called`}},"settings.trash":{title:`Trash`,body:`Deleted projects, prompts, intros and outros, templates and schedules stay here for 30 days, then are removed for good along with a project's files. Restore puts one back; if its name was taken meanwhile it comes back renamed, and a schedule comes back paused. Delete now frees the space at once.`,tutorial:{page:`Trash`}},"settings.patch-notes":{title:`Patch notes`,body:`What changed in each version of Slopify. The newest notes are open here; older versions are folded under Earlier versions, and each opens when you pick it. They ship with the app, so they work offline. After an update, the new version's notes open by themselves once; a fresh install skips that. On a major update the What's new tour shows instead and links here.`,tutorial:{page:`Updating-and-Patch-Notes`,anchor:`read-the-patch-notes`}},"settings.whats-new":{title:`What's new in this version`,body:`Opens the patch notes for the version you are running, in Settings, Patch notes. When this version has no notes of its own, it opens the newest ones instead.`,tutorial:{page:`Updating-and-Patch-Notes`,anchor:`whats-new-tour-on-a-major-update`}},"settings.updates":{title:`Updates`,body:`The circular-arrows button at the foot of the sidebar (at the top on a phone) checks for a newer Slopify and installs it. A dot on it means an update is ready. If a video is being made, the update waits until it finishes, and you can cancel it meanwhile. Slopify restarts itself and this page reconnects.`,tutorial:{page:`Updating-and-Patch-Notes`,anchor:`update-from-the-app`}},"home.channel":{title:`Channel`,body:`Shows Home and the other screens for one channel, or for all of them. It only filters what you see: projects, schedules and costs of other channels keep running. Slopify remembers the choice in this browser.`,tutorial:{page:`Channels`,anchor:`show-one-channels-work`}},"home.needs-you":{title:`Needs you`,body:`Runs held at a review before a step, topics a schedule suggested for you to accept or reject, and runs that failed with the fix to try. Nothing here moves on until you act; approving a review from here lets that run continue.`,tutorial:{page:`Home-and-Projects`,anchor:`needs-you`}},"home.running":{title:`Running now`,body:`Videos being made or paused, with the step each is on and how long it has taken. Up to 3 show here; Projects lists them all. Open one to follow it live, pause it or cancel it.`,tutorial:{page:`Home-and-Projects`,anchor:`running-now`}},"home.coming-up":{title:`Coming up`,body:`The schedule runs due in the next 7 days, with the template and topic each will use. Paused schedules show too. Plan or move runs on the calendar.`,tutorial:{page:`Home-and-Projects`,anchor:`coming-up`}},"home.ready":{title:`Ready to upload`,body:`Finished videos you have not marked uploaded. Prepare upload lists everything YouTube Studio asks for, with Copy buttons; Slopify never uploads for you. Mark uploaded takes the video off this list; Projects still has it.`,tutorial:{page:`Home-and-Projects`,anchor:`ready-to-upload`}},"home.this-week":{title:`This week`,body:`Videos made since Monday and what their provider calls cost. Calls billed to a command-line plan cost nothing per call, so the API figure says what they would have cost with API keys. The bars show how much of each plan's weekly limit is used, from the tool's last reading.`,tutorial:{page:`Home-and-Projects`,anchor:`this-week`}},"welcome.samples":{title:`Samples`,body:`Finished projects that come with Slopify: a narrated video, an audiobook and a podcast. They are read-only, so nothing you try on them costs anything; Make my own copy on a sample's page gives you one to edit.`,tutorial:{page:`First-Launch-and-Welcome`,anchor:`explore-the-samples`}},"welcome.found":{title:`Found on this computer`,body:`Claude Code, Codex and Gemini CLI write the text with your own sign-in, so no API key is needed for it, and Codex also draws the images. The narration uses a voice key (OpenAI, ElevenLabs, Cartesia or Inworld) when one is saved in Settings → Providers, and otherwise your computer's built-in voice, so no key is needed to start.`,tutorial:{page:`First-Launch-and-Welcome`,anchor:`found-on-this-computer`}},"welcome.voice":{title:`Narration voice`,body:`Who reads the script aloud. With a voice key saved (OpenAI, ElevenLabs, Cartesia or Inworld), that provider narrates. Without one, your computer's own speech does it for free: macOS or Windows voices, or eSpeak NG on Linux. It sounds robotic, so add a key in Settings → Providers when you want a better voice.`,tutorial:{page:`First-Launch-and-Welcome`,anchor:`narration-voice`}},"welcome.short":{title:`Make a 60-second short`,body:`Slopify writes a script of about 150 words, narrates it, draws four vertical images and renders a captioned 9:16 short, usually in about five minutes with the command-line tools. The narration uses your voice provider's credit, or nothing with the built-in voice; text and images through a command-line tool count toward its plan.`,tutorial:{page:`First-Launch-and-Welcome`,anchor:`step-3-make-a-60-second-short`}},"welcome.topic":{title:`Topic`,body:`What the short is about, in a few words or a question, up to 200 characters. Slopify writes the script from it without a research step, to keep the first short quick, so a specific topic gives a sharper short than a broad one.`,tutorial:{page:`First-Launch-and-Welcome`,anchor:`step-3-make-a-60-second-short`}},"welcome.pack":{title:`Style`,body:`The starter pack whose prompts, voice and art direction the short uses. General is a neutral explainer style. Making the short with a pack adds its prompts and suggested voice to your library; Add to library also adds its template for Play.`,tutorial:{page:`First-Launch-and-Welcome`,anchor:`step-2-pick-a-style`}},"welcome.packs":{title:`Starter packs`,body:`Each pack adds prompts, a suggested voice and a Play template for one kind of channel, so you can pick the template on Play, type a topic and go. Adding a pack twice changes nothing, and it never replaces a prompt or template of yours with the same name.`,tutorial:{page:`First-Launch-and-Welcome`,anchor:`starter-packs`}}},lb={...ob,...sb,...ib,...ab,...cb};function ub(e,t){let n=lb[e];if(t===void 0)return n;let r=e=>e.replace(/\{(\w+)\}/g,(e,n)=>t[n]??e);return{...n,title:r(n.title),body:r(n.body)}}function db(e){return e.replace(/!?\[([^\]]*)\]\([^)]*\)/g,`$1`).replace(/`([^`]*)`/g,`$1`).replace(/(\*\*|__)(.+?)\1/g,`$2`).replace(/(^|[^\p{L}\p{N}])[*_]([^*_]+)[*_](?![\p{L}\p{N}])/gu,`$1$2`).replace(/<[^>]+>/g,``).trim()}function fb(e){return e.toLowerCase().replace(/[^\p{L}\p{N}\p{M} _-]/gu,``).replace(/ /g,`-`)}var pb=`/help/tutorials`;function mb(e,t){return`${pb}/${encodeURIComponent(e)}${t?`#${t}`:``}`}function hb(e,t,n){return e.replace(/\]\(([A-Za-z0-9][A-Za-z0-9-]*)?(?:#([^)\s]*))?\)/g,(e,r,i)=>{if(r===void 0&&i===void 0)return e;let a=r??n;return t.has(a)?`](${mb(a,i)})`:e})}function gb(e){let t=/^\s*#\s+(.+?)\s*#*\s*(?:\n|$)/.exec(e);return t===null?{title:void 0,body:e}:{title:t[1],body:e.slice(t[0].length)}}function _b(e){let t=/^\/help\/tutorials\/([^/#?]+)(?:#(.*))?$/.exec(e);if(t===null)return;let n=t[2];return{page:decodeURIComponent(t[1]??``),anchor:n===void 0||n===``?void 0:decodeURIComponent(n)}}function vb(e,t,n=[]){let r=new Map;for(let e of n){let t=fb(db(e));r.set(t,(r.get(t)??0)+1)}for(let n of e.querySelectorAll(`h1, h2, h3, h4, h5, h6`)){let e=fb((n.textContent??``).trim()),i=r.get(e)??0;if(r.set(e,i+1),(i===0?e:`${e}-${String(i)}`)===t)return n}}var yb=Iee,bb=Ree,xb=Lee,Sb=Vee;function Cb({className:e,align:t=`start`,sideOffset:n=6,...r}){return(0,h.jsx)(zee,{children:(0,h.jsx)(Bee,{"data-slot":`popover-content`,align:t,sideOffset:n,collisionPadding:12,className:I(`z-50 w-[min(340px,calc(100vw-24px))] rounded-control border border-line bg-raised p-3 text-small text-ink-2`,`shadow-[var(--shadow-pop)] outline-hidden`,e),...r})})}function B({id:e,label:t,vars:n,className:r}){let i=ub(e,n);return(0,h.jsxs)(yb,{children:[(0,h.jsx)(bb,{type:`button`,"aria-label":`About ${t??i.title}`,"data-help-id":e,className:I(`inline-flex size-6 shrink-0 items-center justify-center rounded-full text-ink-3 hover:bg-raised hover:text-ink`,r),children:(0,h.jsx)(yc,{"aria-hidden":`true`,className:`size-[15px]`})}),(0,h.jsxs)(Cb,{className:`space-y-2 leading-[1.45]`,children:[(0,h.jsx)(`p`,{className:`m-0 font-semibold text-ink`,children:i.title}),i.body.split(`
49
+ `},Jp=0,Yp=[];function Xp(e){var t=m.useRef([]),n=m.useRef([0,0]),r=m.useRef(),i=m.useState(Jp++)[0],a=m.useState(vp)[0],o=m.useRef(e);m.useEffect(function(){o.current=e},[e]),m.useEffect(function(){if(e.inert){document.body.classList.add(`block-interactivity-${i}`);var t=Jf([e.lockRef.current],(e.shards||[]).map(Gp),!0).filter(Boolean);return t.forEach(function(e){return e.classList.add(`allow-interactivity-${i}`)}),function(){document.body.classList.remove(`block-interactivity-${i}`),t.forEach(function(e){return e.classList.remove(`allow-interactivity-${i}`)})}}},[e.inert,e.lockRef.current,e.shards]);var s=m.useCallback(function(e,t){if(`touches`in e&&e.touches.length===2||e.type===`wheel`&&e.ctrlKey)return!o.current.allowPinchZoom;var i=Up(e),a=n.current,s=`deltaX`in e?e.deltaX:a[0]-i[0],c=`deltaY`in e?e.deltaY:a[1]-i[1],l,u=e.target,d=Math.abs(s)>Math.abs(c)?`h`:`v`;if(`touches`in e&&d===`h`&&u.type===`range`)return!1;var f=window.getSelection(),p=f&&f.anchorNode;if(p&&(p===u||p.contains(u)))return!1;var m=Ip(d,u);if(!m)return!0;if(m?l=d:(l=d===`v`?`h`:`v`,m=Ip(d,u)),!m)return!1;if(!r.current&&`changedTouches`in e&&(s||c)&&(r.current=l),!l)return!0;var h=r.current||l;return Hp(h,t,e,h===`h`?s:c,!0)},[]),c=m.useCallback(function(e){var n=e;if(Yp.length&&Yp[Yp.length-1]===a){var r=`deltaY`in n?Wp(n):Up(n),i=t.current.filter(function(e){return e.name===n.type&&(e.target===n.target||n.target===e.shadowParent)&&Kp(e.delta,r)})[0];if(i&&i.should){n.cancelable&&n.preventDefault();return}if(!i){var c=(o.current.shards||[]).map(Gp).filter(Boolean).filter(function(e){return e.contains(n.target)});(c.length>0?s(n,c[0]):!o.current.noIsolation)&&n.cancelable&&n.preventDefault()}}},[]),l=m.useCallback(function(e,n,r,i){var a={name:e,delta:n,target:r,should:i,shadowParent:Zp(r)};t.current.push(a),setTimeout(function(){t.current=t.current.filter(function(e){return e!==a})},1)},[]),u=m.useCallback(function(e){n.current=Up(e),r.current=void 0},[]),d=m.useCallback(function(t){l(t.type,Wp(t),t.target,s(t,e.lockRef.current))},[]),f=m.useCallback(function(t){l(t.type,Up(t),t.target,s(t,e.lockRef.current))},[]);m.useEffect(function(){return Yp.push(a),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener(`wheel`,c,jp),document.addEventListener(`touchmove`,c,jp),document.addEventListener(`touchstart`,u,jp),function(){Yp=Yp.filter(function(e){return e!==a}),document.removeEventListener(`wheel`,c,jp),document.removeEventListener(`touchmove`,c,jp),document.removeEventListener(`touchstart`,u,jp)}},[]);var p=e.removeScrollBar,h=e.inert;return m.createElement(m.Fragment,null,h?m.createElement(a,{styles:qp(i)}):null,p?m.createElement(Op,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function Zp(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}var Qp=cp(lp,Xp),$p=m.forwardRef(function(e,t){return m.createElement(dp,Kf({},e,{ref:t,sideCar:Qp}))});$p.classNames=dp.classNames;var em=function(e){return typeof document>`u`?null:(Array.isArray(e)?e[0]:e).ownerDocument.body},tm=new WeakMap,nm=new WeakMap,rm={},im=0,am=function(e){return e&&(e.host||am(e.parentNode))},om=function(e,t){return t.map(function(t){if(e.contains(t))return t;var n=am(t);return n&&e.contains(n)?n:(console.error(`aria-hidden`,t,`in not contained inside`,e,`. Doing nothing`),null)}).filter(function(e){return!!e})},sm=function(e,t,n,r){var i=om(t,Array.isArray(e)?e:[e]);rm[n]||(rm[n]=new WeakMap);var a=rm[n],o=[],s=new Set,c=new Set(i),l=function(e){e&&!s.has(e)&&(s.add(e),l(e.parentNode))};i.forEach(l);var u=function(e){e&&!c.has(e)&&Array.prototype.forEach.call(e.children,function(e){if(s.has(e))u(e);else try{var t=e.getAttribute(r),i=t!==null&&t!==`false`,c=(tm.get(e)||0)+1,l=(a.get(e)||0)+1;tm.set(e,c),a.set(e,l),o.push(e),c===1&&i&&nm.set(e,!0),l===1&&e.setAttribute(n,`true`),i||e.setAttribute(r,`true`)}catch(t){console.error(`aria-hidden: cannot operate on `,e,t)}})};return u(t),s.clear(),im++,function(){o.forEach(function(e){var t=tm.get(e)-1,i=a.get(e)-1;tm.set(e,t),a.set(e,i),t||(nm.has(e)||e.removeAttribute(r),nm.delete(e)),i||e.removeAttribute(n)}),im--,im||(tm=new WeakMap,tm=new WeakMap,nm=new WeakMap,rm={})}},cm=function(e,t,n){n===void 0&&(n=`data-aria-hidden`);var r=Array.from(Array.isArray(e)?e:[e]),i=t||em(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll(`[aria-live], script`))),sm(r,i,n,`aria-hidden`)):function(){return null}},lm=Object.defineProperty,um=(e,t)=>lm(e,`name`,{value:t,configurable:!0}),dm=`Dialog`,[fm,tee]=td(dm),[pm,mm]=fm(dm),hm=um(e=>{let{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!0}=e,s=m.useRef(null),c=m.useRef(null),[l,u]=Nd({prop:r,defaultProp:i??!1,onChange:a,caller:dm}),[d,f]=m.useState(0),[p,g]=m.useState(0);return(0,h.jsx)(pm,{scope:t,triggerRef:s,contentRef:c,contentId:Zd(),titleId:Zd(),descriptionId:Zd(),titlePresent:d>0,descriptionPresent:p>0,setTitleCount:f,setDescriptionCount:g,open:l,onOpenChange:u,onOpenToggle:m.useCallback(()=>u(e=>!e),[u]),modal:o,children:n})},`Dialog`),gm=`DialogPortal`,[nee,_m]=fm(gm,{forceMount:void 0}),vm=um(e=>{let{__scopeDialog:t,forceMount:n,children:r,container:i}=e,a=mm(gm,t);return(0,h.jsx)(nee,{scope:t,forceMount:n,children:m.Children.map(r,e=>(0,h.jsx)(Vd,{present:n||a.open,children:(0,h.jsx)(Rf,{asChild:!0,container:i,children:e})}))})},`DialogPortal`),ym=`DialogOverlay`,bm=m.forwardRef(um(function(e,t){let n=_m(ym,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=mm(ym,e.__scopeDialog);return a.modal?(0,h.jsx)(Vd,{present:r||a.open,children:(0,h.jsx)(Sm,{...i,ref:t})}):null},`DialogOverlay`)),xm=Nu(`DialogOverlay.RemoveScroll`),Sm=m.forwardRef(um(function(e,t){let{__scopeDialog:n,...r}=e,i=mm(ym,n),a=Au(t,mf());return(0,h.jsx)($p,{as:xm,allowPinchZoom:!0,shards:[i.contentRef],children:(0,h.jsx)(Xu.div,{"data-state":km(i.open),...r,ref:a,style:{pointerEvents:`auto`,...r.style}})})},`DialogOverlayImpl`)),Cm=`DialogContent`,wm=m.forwardRef(um(function(e,t){let n=_m(Cm,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=mm(Cm,e.__scopeDialog);return(0,h.jsx)(Vd,{present:r||a.open,children:a.modal?(0,h.jsx)(ree,{...i,ref:t}):(0,h.jsx)(iee,{...i,ref:t})})},`DialogContent`)),ree=m.forwardRef(um(function(e,t){let n=mm(Cm,e.__scopeDialog),r=m.useRef(null),i=Au(t,n.contentRef,r);return m.useEffect(()=>{let e=r.current;if(e)return cm(e)},[]),(0,h.jsx)(Tm,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,onCloseAutoFocus:yd(e.onCloseAutoFocus,e=>{e.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:yd(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;(t.button===2||n)&&e.preventDefault()}),onFocusOutside:yd(e.onFocusOutside,e=>e.preventDefault())})},`DialogContentModal`)),iee=m.forwardRef(um(function(e,t){let n=mm(Cm,e.__scopeDialog),r=m.useRef(!1),i=m.useRef(!1);return(0,h.jsx)(Tm,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})},`DialogContentNonModal`)),Tm=m.forwardRef(um(function(e,t){let{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,...o}=e,s=mm(Cm,n);return Wf(),(0,h.jsx)(h.Fragment,{children:(0,h.jsx)(Tf,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,h.jsx)(pf,{role:`dialog`,id:s.contentId,"aria-describedby":s.descriptionPresent?s.descriptionId:void 0,"aria-labelledby":s.titlePresent?s.titleId:void 0,"data-state":km(s.open),...o,ref:t,deferPointerDownOutside:!0,onDismiss:()=>s.onOpenChange(!1)})})})},`DialogContentImpl`)),aee=`DialogTitle`,Em=m.forwardRef(um(function(e,t){let{__scopeDialog:n,...r}=e,i=mm(aee,n),{setTitleCount:a}=i;return wd(()=>(a(e=>e+1),()=>a(e=>e-1)),[a]),(0,h.jsx)(Xu.h2,{id:i.titleId,...r,ref:t})},`DialogTitle`)),oee=`DialogDescription`,see=m.forwardRef(um(function(e,t){let{__scopeDialog:n,...r}=e,i=mm(oee,n),{setDescriptionCount:a}=i;return wd(()=>(a(e=>e+1),()=>a(e=>e-1)),[a]),(0,h.jsx)(Xu.p,{id:i.descriptionId,...r,ref:t})},`DialogDescription`)),Dm=`DialogClose`,Om=m.forwardRef(um(function(e,t){let{__scopeDialog:n,...r}=e,i=mm(Dm,n);return(0,h.jsx)(Xu.button,{type:`button`,...r,ref:t,onClick:yd(e.onClick,()=>i.onOpenChange(!1))})},`DialogClose`));function km(e){return e?`open`:`closed`}um(km,`getState`);var Am=Object.defineProperty,jm=(e,t)=>Am(e,`name`,{value:t,configurable:!0});function Mm(e){let[t,n]=m.useState(void 0);return wd(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});let t=new ResizeObserver(t=>{if(!Array.isArray(t)||!t.length)return;let r=t[0],i,a;if(`borderBoxSize`in r){let e=r.borderBoxSize,t=Array.isArray(e)?e[0]:e;i=t.inlineSize,a=t.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return t.observe(e,{box:`border-box`}),()=>t.unobserve(e)}n(void 0)},[e]),t}jm(Mm,`useSize`);var Nm=[`top`,`right`,`bottom`,`left`],Pm=Math.min,Fm=Math.max,Im=Math.round,Lm=Math.floor,Rm=e=>({x:e,y:e}),cee={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function zm(e,t,n){return Fm(e,Pm(t,n))}function Bm(e,t){return typeof e==`function`?e(t):e}function Vm(e){return e.split(`-`)[0]}function Hm(e){return e.split(`-`)[1]}function Um(e){return e===`x`?`y`:`x`}function Wm(e){return e===`y`?`height`:`width`}function Gm(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function Km(e){return Um(Gm(e))}function qm(e,t,n){n===void 0&&(n=!1);let r=Hm(e),i=Km(e),a=Wm(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=nh(o)),[o,nh(o)]}function Jm(e){let t=nh(e);return[Ym(e),t,Ym(t)]}function Ym(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var Xm=[`left`,`right`],Zm=[`right`,`left`],Qm=[`top`,`bottom`],$m=[`bottom`,`top`];function eh(e,t,n){switch(e){case`top`:case`bottom`:return n?t?Zm:Xm:t?Xm:Zm;case`left`:case`right`:return t?Qm:$m;default:return[]}}function th(e,t,n,r){let i=Hm(e),a=eh(Vm(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(Ym)))),a}function nh(e){let t=Vm(e);return cee[t]+e.slice(t.length)}function rh(e){return{top:e.top??0,right:e.right??0,bottom:e.bottom??0,left:e.left??0}}function ih(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:rh(e)}function ah(e){let{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function oh(e,t,n){let{reference:r,floating:i}=e,a=Gm(t),o=Km(t),s=Wm(o),c=Vm(t),l=a===`y`,u=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=r[s]/2-i[s]/2,p;switch(c){case`top`:p={x:u,y:r.y-i.height};break;case`bottom`:p={x:u,y:r.y+r.height};break;case`right`:p={x:r.x+r.width,y:d};break;case`left`:p={x:r.x-i.width,y:d};break;default:p={x:r.x,y:r.y}}let m=Hm(t);return m&&(p[o]+=f*(m===`end`?1:-1)*(n&&l?-1:1)),p}async function sh(e,t){t===void 0&&(t={});let{x:n,y:r,platform:i,rects:a,elements:o,strategy:s}=e,{boundary:c=`clippingAncestors`,rootBoundary:l=`viewport`,elementContext:u=`floating`,altBoundary:d=!1,padding:f=0}=Bm(t,e),p=ih(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=ah(await i.getClippingRect({element:await(i.isElement==null?void 0:i.isElement(m))??!0?m:m.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(o.floating)),boundary:c,rootBoundary:l,strategy:s})),g=u===`floating`?{x:n,y:r,width:a.floating.width,height:a.floating.height}:a.reference,_=await(i.getOffsetParent==null?void 0:i.getOffsetParent(o.floating)),v=await(i.isElement==null?void 0:i.isElement(_))&&await(i.getScale==null?void 0:i.getScale(_))||{x:1,y:1},y=ah(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:g,offsetParent:_,strategy:s}):g);return{top:(h.top-y.top+p.top)/v.y,bottom:(y.bottom-h.bottom+p.bottom)/v.y,left:(h.left-y.left+p.left)/v.x,right:(y.right-h.right+p.right)/v.x}}var ch=50,lh=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:sh},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=oh(l,r,c),f=r,p=0,m={};for(let n=0;n<a.length;n++){let h=a[n];if(!h)continue;let{name:g,fn:_}=h,{x:v,y,data:b,reset:x}=await _({x:u,y:d,initialPlacement:r,placement:f,strategy:i,middlewareData:m,rects:l,platform:s,elements:{reference:e,floating:t}});u=v??u,d=y??d,m[g]={...m[g],...b},x&&p<ch&&(p++,typeof x==`object`&&(x.placement&&(f=x.placement),x.rects&&(l=x.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):x.rects),{x:u,y:d}=oh(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},uh=e=>({name:`arrow`,options:e,async fn(t){let{x:n,y:r,placement:i,rects:a,platform:o,elements:s,middlewareData:c}=t,{element:l,padding:u=0}=Bm(e,t)||{};if(l==null)return{};let d=ih(u),f={x:n,y:r},p=Km(i),m=Wm(p),h=await o.getDimensions(l),g=p===`y`,_=g?`top`:`left`,v=g?`bottom`:`right`,y=g?`clientHeight`:`clientWidth`,b=a.reference[m]+a.reference[p]-f[p]-a.floating[m],x=f[p]-a.reference[p],S=await(o.getOffsetParent==null?void 0:o.getOffsetParent(l)),C=S?S[y]:0;(!C||!await(o.isElement==null?void 0:o.isElement(S)))&&(C=s.floating[y]||a.floating[m]);let w=b/2-x/2,T=C/2-h[m]/2-1,E=Pm(d[_],T),D=Pm(d[v],T),O=C-h[m]-D,k=C/2-h[m]/2+w,ee=zm(E,k,O),te=!c.arrow&&Hm(i)!=null&&k!==ee&&a.reference[m]/2-(k<E?E:D)-h[m]/2<0,ne=te?k<E?k-E:k-O:0;return{[p]:f[p]+ne,data:{[p]:ee,centerOffset:k-ee-ne,...te&&{alignmentOffset:ne}},reset:te}}}),dh=function(e){return e===void 0&&(e={}),{name:`flip`,options:e,async fn(t){var n;let{placement:r,middlewareData:i,rects:a,initialPlacement:o,platform:s,elements:c}=t,{mainAxis:l=!0,crossAxis:u=!0,fallbackPlacements:d,fallbackStrategy:f=`bestFit`,fallbackAxisSideDirection:p=`none`,flipAlignment:m=!0,...h}=Bm(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=Vm(r),_=Gm(o),v=Vm(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[nh(o)]:Jm(o)),x=p!==`none`;!d&&x&&b.push(...th(o,m,p,y));let S=[o,...b],C=await s.detectOverflow(t,h),w=[],T=i.flip?.overflows||[];if(l&&w.push(C[g]),u){let e=qm(r,a,y);w.push(C[e[0]],C[e[1]])}if(T=[...T,{placement:r,overflows:w}],!w.every(e=>e<=0)){let e=(i.flip?.index||0)+1,t=S[e];if(t&&(u!==`alignment`||_===Gm(t)||T.every(e=>Gm(e.placement)!==_||e.overflows[0]>0)))return{data:{index:e,overflows:T},reset:{placement:t}};let n=T.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0]?.placement;if(!n)switch(f){case`bestFit`:{let e=T.filter(e=>{if(x){let t=Gm(e.placement);return t===_||t===`y`}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0]?.[0];e&&(n=e);break}case`initialPlacement`:n=o}if(r!==n)return{reset:{placement:n}}}return{}}}};function fh(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function ph(e){return Nm.some(t=>e[t]>=0)}var mh=function(e){return e===void 0&&(e={}),{name:`hide`,options:e,async fn(t){let{rects:n,platform:r}=t,{strategy:i=`referenceHidden`,...a}=Bm(e,t);switch(i){case`referenceHidden`:{let e=fh(await r.detectOverflow(t,{...a,elementContext:`reference`}),n.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:ph(e)}}}case`escaped`:{let e=fh(await r.detectOverflow(t,{...a,altBoundary:!0}),n.floating);return{data:{escapedOffsets:e,escaped:ph(e)}}}default:return{}}}}},hh=new Set([`left`,`top`]);async function gh(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=Vm(n),s=Hm(n),c=Gm(n)===`y`,l=hh.has(o)?-1:1,u=a&&c?-1:1,d=Bm(t,e),{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d==`number`?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof m==`number`&&(p=s===`end`?m*-1:m),c?{x:p*u,y:f*l}:{x:f*l,y:p*u}}var _h=function(e){return e===void 0&&(e=0),{name:`offset`,options:e,async fn(t){var n;let{x:r,y:i,placement:a,middlewareData:o}=t,s=await gh(t,e);return a===o.offset?.placement&&(n=o.arrow)!=null&&n.alignmentOffset?{}:{x:r+s.x,y:i+s.y,data:{...s,placement:a}}}}},vh=function(e){return e===void 0&&(e={}),{name:`shift`,options:e,async fn(t){let{x:n,y:r,placement:i,platform:a}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:c={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...l}=Bm(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=Gm(i),p=Um(f),m=u[p],h=u[f],g=(e,t)=>zm(t+d[e===`y`?`top`:`left`],t,t-d[e===`y`?`bottom`:`right`]);o&&(m=g(p,m)),s&&(h=g(f,h));let _=c.fn({...t,[p]:m,[f]:h});return{..._,data:{x:_.x-n,y:_.y-r,enabled:{[p]:o,[f]:s}}}}}},yh=function(e){return e===void 0&&(e={}),{options:e,fn(t){let{x:n,y:r,placement:i,rects:a,middlewareData:o}=t,{offset:s=0,mainAxis:c=!0,crossAxis:l=!0}=Bm(e,t),u={x:n,y:r},d=Gm(i),f=Um(d),p=u[f],m=u[d],h=Bm(s,t),g=typeof h==`number`?{mainAxis:h,crossAxis:0}:{mainAxis:h.mainAxis??0,crossAxis:h.crossAxis??0};if(c){let e=f===`y`?`height`:`width`,t=a.reference[f]-a.floating[e]+g.mainAxis,n=a.reference[f]+a.reference[e]-g.mainAxis;p<t?p=t:p>n&&(p=n)}if(l){let e=f===`y`?`width`:`height`,t=hh.has(Vm(i)),n=a.reference[d]-a.floating[e]+(t&&o.offset?.[d]||0)+(t?0:g.crossAxis),r=a.reference[d]+a.reference[e]+(t?0:o.offset?.[d]||0)-(t?g.crossAxis:0);m<n?m=n:m>r&&(m=r)}return{[f]:p,[d]:m}}}},bh=function(e){return e===void 0&&(e={}),{name:`size`,options:e,async fn(t){let{placement:n,rects:r,platform:i,elements:a}=t,{apply:o=()=>{},...s}=Bm(e,t),c=await i.detectOverflow(t,s),l=Vm(n),u=Hm(n),d=Gm(n)===`y`,{width:f,height:p}=r.floating,m,h;l===`top`||l===`bottom`?(m=l,h=u===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?`start`:`end`)?`left`:`right`):(h=l,m=u===`end`?`top`:`bottom`);let g=p-c.top-c.bottom,_=f-c.left-c.right,v=Pm(p-c[m],g),y=Pm(f-c[h],_),b=t.middlewareData.shift,x=!b,S=v,C=y;b!=null&&b.enabled.x&&(C=_),b!=null&&b.enabled.y&&(S=g),x&&!u&&(d?C=f-2*Fm(c.left,c.right):S=p-2*Fm(c.top,c.bottom)),await o({...t,availableWidth:C,availableHeight:S});let w=await i.getDimensions(a.floating);return f!==w.width||p!==w.height?{reset:{rects:!0}}:{}}}};function xh(){return typeof window<`u`}function Sh(e){return Th(e)?(e.nodeName||``).toLowerCase():`#document`}function Ch(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function wh(e){return((Th(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function Th(e){return xh()?e instanceof Node||e instanceof Ch(e).Node:!1}function Eh(e){return xh()?e instanceof Element||e instanceof Ch(e).Element:!1}function Dh(e){return xh()?e instanceof HTMLElement||e instanceof Ch(e).HTMLElement:!1}function Oh(e){return!xh()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof Ch(e).ShadowRoot}function kh(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=zh(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function lee(e){return/^(table|td|th)$/.test(Sh(e))}function Ah(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var jh=/transform|translate|scale|rotate|perspective|filter/,Mh=/paint|layout|strict|content/,Nh=e=>!!e&&e!==`none`,Ph;function Fh(e){let t=Eh(e)?zh(e):e;return Nh(t.transform)||Nh(t.translate)||Nh(t.scale)||Nh(t.rotate)||Nh(t.perspective)||!Lh()&&(Nh(t.backdropFilter)||Nh(t.filter))||jh.test(t.willChange||``)||Mh.test(t.contain||``)}function Ih(e){let t=Vh(e);for(;Dh(t)&&!Rh(t);){if(Fh(t))return t;if(Ah(t))return null;t=Vh(t)}return null}function Lh(){return Ph??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),Ph}function Rh(e){return/^(html|body|#document)$/.test(Sh(e))}function zh(e){return Ch(e).getComputedStyle(e)}function Bh(e){return Eh(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Vh(e){if(Sh(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||Oh(e)&&e.host||wh(e);return Oh(t)?t.host:t}function Hh(e){let t=Vh(e);return Rh(t)?(e.ownerDocument||e).body:Dh(t)&&kh(t)?t:Hh(t)}function Uh(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=Hh(e),i=r===e.ownerDocument?.body,a=Ch(r);if(i){let e=Wh(a);return t.concat(a,a.visualViewport||[],kh(r)?r:[],e&&n?Uh(e):[])}return t.concat(r,Uh(r,[],n))}function Wh(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Gh(e){let t=zh(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=Dh(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=Im(n)!==a||Im(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function Kh(e){return Eh(e)?e:e.contextElement}function qh(e){let t=Kh(e);if(!Dh(t))return Rm(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=Gh(t),o=(a?Im(n.width):n.width)/r,s=(a?Im(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!s||!Number.isFinite(s))&&(s=1),{x:o,y:s}}var Jh=Rm(0);function Yh(e){let t=Ch(e);return!Lh()||!t.visualViewport?Jh:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Xh(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===Ch(e)}function Zh(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=Kh(e),o=Rm(1);t&&(r?Eh(r)&&(o=qh(r)):o=qh(e));let s=Xh(a,n,r)?Yh(a):Rm(0),c=(i.left+s.x)/o.x,l=(i.top+s.y)/o.y,u=i.width/o.x,d=i.height/o.y;if(a&&r){let e=Ch(a),t=Eh(r)?Ch(r):r,n=e,i=Wh(n);for(;i&&t!==n;){let e=qh(i),t=i.getBoundingClientRect(),r=zh(i),a=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,o=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;c*=e.x,l*=e.y,u*=e.x,d*=e.y,c+=a,l+=o,n=Ch(i),i=Wh(n)}}return ah({width:u,height:d,x:c,y:l})}function Qh(e,t){let n=Bh(e).scrollLeft;return t?t.left+n:Zh(wh(e)).left+n}function $h(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-Qh(e,n),y:n.top+t.scrollTop}}function eg(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=wh(r),s=t?Ah(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=Rm(1),u=Rm(0),d=Dh(r);if((d||!a)&&((Sh(r)!==`body`||kh(o))&&(c=Bh(r)),d)){let e=Zh(r);l=qh(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?$h(o,c):Rm(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x+f.x,y:n.y*l.y-c.scrollTop*l.y+u.y+f.y}}function tg(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function ng(e){let t=Bh(e),n=e.ownerDocument.body,r=Fm(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),i=Fm(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight),a=-t.scrollLeft+Qh(e),o=-t.scrollTop;return zh(n).direction===`rtl`&&(a+=Fm(e.clientWidth,n.clientWidth)-r),{width:r,height:i,x:a,y:o}}var rg=25;function ig(e,t,n){n===void 0&&(n=`viewport`);let r=n===`layoutViewport`,i=Ch(e),a=wh(e),o=i.visualViewport,s=a.clientWidth,c=a.clientHeight,l=0,u=0;if(o){let e=!Lh()||t===`fixed`;r?e||(l=-o.offsetLeft,u=-o.offsetTop):(s=o.width,c=o.height,e&&(l=o.offsetLeft,u=o.offsetTop))}if(Qh(a)<=0){let e=a.ownerDocument,t=e.body,n=getComputedStyle(t),r=e.compatMode===`CSS1Compat`&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,i=Math.abs(a.clientWidth-t.clientWidth-r),o=getComputedStyle(a).scrollbarGutter===`stable both-edges`?i/2:i;o<=rg&&(s-=o)}return{width:s,height:c,x:l,y:u}}function ag(e,t){let n=Zh(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=qh(e);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function og(e,t,n){let r;if(t===`viewport`||t===`layoutViewport`)r=ig(e,n,t);else if(t===`document`)r=ng(wh(e));else if(Eh(t))r=ag(t,n);else{let n=Yh(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return ah(r)}function sg(e,t){let n=t.get(e);if(n)return n;let r=Uh(e,[],!1).filter(e=>Eh(e)&&Sh(e)!==`body`),i=null,a=zh(e).position===`fixed`,o=a?Vh(e):e;for(;Eh(o)&&!Rh(o);){let e=zh(o),t=Fh(o),n=i?i.position:a?`fixed`:``;!t&&(n===`fixed`||n===`absolute`&&e.position===`static`)?r=r.filter(e=>e!==o):i=e,o=Vh(o)}return t.set(e,r),r}function cg(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?Ah(t)?[]:sg(t,this._c):[].concat(n),r],o=og(t,a[0],i),s=o.top,c=o.right,l=o.bottom,u=o.left;for(let e=1;e<a.length;e++){let n=og(t,a[e],i);s=Fm(n.top,s),c=Pm(n.right,c),l=Pm(n.bottom,l),u=Fm(n.left,u)}return{width:c-u,height:l-s,x:u,y:s}}function lg(e){let{width:t,height:n}=Gh(e);return{width:t,height:n}}function ug(e,t,n){let r=Dh(t),i=wh(t),a=n===`fixed`,o=Zh(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=Rm(0);if((r||!a)&&((Sh(t)!==`body`||kh(i))&&(s=Bh(t)),r)){let e=Zh(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}!r&&i&&(c.x=Qh(i));let l=i&&!r&&!a?$h(i,s):Rm(0);return{x:o.left+s.scrollLeft-c.x-l.x,y:o.top+s.scrollTop-c.y-l.y,width:o.width,height:o.height}}function dg(e){return zh(e).position===`static`}function fg(e,t){if(!Dh(e)||zh(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return wh(e)===n&&(n=n.ownerDocument.body),n}function pg(e,t){let n=Ch(e);if(Ah(e))return n;if(!Dh(e)){let t=Vh(e);for(;t&&!Rh(t);){if(Eh(t)&&!dg(t))return t;t=Vh(t)}return n}let r=fg(e,t);for(;r&&lee(r)&&dg(r);)r=fg(r,t);return r&&Rh(r)&&dg(r)&&!Fh(r)?n:r||Ih(e)||n}var mg=async function(e){let t=this.getOffsetParent||pg,n=this.getDimensions,r=await n(e.floating);return{reference:ug(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function hg(e){return zh(e).direction===`rtl`}var gg={convertOffsetParentRelativeRectToViewportRelativeRect:eg,getDocumentElement:wh,getClippingRect:cg,getOffsetParent:pg,getElementRects:mg,getClientRects:tg,getDimensions:lg,getScale:qh,isElement:Eh,isRTL:hg};function _g(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function vg(e,t,n){let r=null,i,a=wh(e);function o(){var e;clearTimeout(i),(e=r)==null||e.disconnect(),r=null}function s(n,c){n===void 0&&(n=!1),c===void 0&&(c=1),o();let l=e.getBoundingClientRect(),{left:u,top:d,width:f,height:p}=l;if(n||t(),!f||!p)return;let m=Lm(d),h=Lm(a.clientWidth-(u+f)),g=Lm(a.clientHeight-(d+p)),_=Lm(u),v={rootMargin:-m+`px `+-h+`px `+-g+`px `+-_+`px`,threshold:Fm(0,Pm(1,c))||1},y=!0;function b(t){let n=t[0].intersectionRatio;if(!_g(l,e.getBoundingClientRect()))return s();if(n!==c){if(!y)return s();n?s(!1,n):i=setTimeout(()=>{s(!1,1e-7)},1e3)}y=!1}try{r=new IntersectionObserver(b,{...v,root:a.ownerDocument})}catch{r=new IntersectionObserver(b,v)}r.observe(e)}let c=Ch(e),l=()=>s(n);return c.addEventListener(`resize`,l),s(!0),()=>{c.removeEventListener(`resize`,l),o()}}function yg(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver==`function`,layoutShift:s=typeof IntersectionObserver==`function`,animationFrame:c=!1}=r,l=Kh(e),u=i||a?[...l?Uh(l):[],...t?Uh(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n),a&&e.addEventListener(`resize`,n)});let d=l&&s?vg(l,n,a):null,f=-1,p=null;o&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===l&&p&&t&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;(e=p)==null||e.observe(t)})),n()}),l&&!c&&p.observe(l),t&&p.observe(t));let m,h=c?Zh(e):null;c&&g();function g(){let t=Zh(e);h&&!_g(h,t)&&n(),h=t,m=requestAnimationFrame(g)}return n(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener(`scroll`,n),a&&e.removeEventListener(`resize`,n)}),d?.(),(e=p)==null||e.disconnect(),p=null,c&&cancelAnimationFrame(m)}}var bg=_h,xg=vh,Sg=dh,Cg=bh,wg=mh,Tg=uh,Eg=yh,Dg=(e,t,n)=>{let r=new Map,i=n??{},a={...gg,...i.platform,_c:r};return lh(e,t,{...i,platform:a})},Og=typeof document<`u`?m.useLayoutEffect:function(){};function kg(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e==`function`&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e==`object`){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!kg(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){let n=i[r];if(!(n===`_owner`&&e.$$typeof)&&!kg(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function Ag(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function jg(e,t){let n=Ag(e);return Math.round(t*n)/n}function Mg(e){let t=m.useRef(e);return Og(()=>{t.current=e}),t}function uee(e){e===void 0&&(e={});let{placement:t=`bottom`,strategy:n=`absolute`,middleware:r=[],platform:i,elements:{reference:a,floating:o}={},transform:s=!0,whileElementsMounted:c,open:l}=e,[u,d]=m.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,p]=m.useState(r);kg(f,r)||p(r);let[h,g]=m.useState(null),[_,v]=m.useState(null),y=m.useCallback(e=>{e!==C.current&&(C.current=e,g(e))},[]),b=m.useCallback(e=>{e!==w.current&&(w.current=e,v(e))},[]),x=a||h,S=o||_,C=m.useRef(null),w=m.useRef(null),T=m.useRef(u),E=c!=null,D=Mg(c),O=Mg(i),k=Mg(l),ee=m.useCallback(()=>{if(!C.current||!w.current)return;let e={placement:t,strategy:n,middleware:f};O.current&&(e.platform=O.current),Dg(C.current,w.current,e).then(e=>{let t={...e,isPositioned:k.current!==!1};te.current&&!kg(T.current,t)&&(T.current=t,qu.flushSync(()=>{d(t)}))})},[f,t,n,O,k]);Og(()=>{l===!1&&T.current.isPositioned&&(T.current.isPositioned=!1,d(e=>({...e,isPositioned:!1})))},[l]);let te=m.useRef(!1);Og(()=>(te.current=!0,()=>{te.current=!1}),[]),Og(()=>{if(x&&(C.current=x),S&&(w.current=S),x&&S){if(D.current)return D.current(x,S,ee);ee()}},[x,S,ee,D,E]);let ne=m.useMemo(()=>({reference:C,floating:w,setReference:y,setFloating:b}),[y,b]),re=m.useMemo(()=>({reference:x,floating:S}),[x,S]),A=m.useMemo(()=>{let e={position:n,left:0,top:0};if(!re.floating)return e;let t=jg(re.floating,u.x),r=jg(re.floating,u.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...Ag(re.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,s,re.floating,u.x,u.y]);return m.useMemo(()=>({...u,update:ee,refs:ne,elements:re,floatingStyles:A}),[u,ee,ne,re,A])}var dee=e=>{function t(e){return{}.hasOwnProperty.call(e,`current`)}return{name:`arrow`,options:e,fn(n){let{element:r,padding:i}=typeof e==`function`?e(n):e;return r&&t(r)?r.current==null?{}:Tg({element:r.current,padding:i}).fn(n):r?Tg({element:r,padding:i}).fn(n):{}}}},fee=(e,t)=>{let n=bg(e);return{name:n.name,fn:n.fn,options:[e,t]}},pee=(e,t)=>{let n=xg(e);return{name:n.name,fn:n.fn,options:[e,t]}},mee=(e,t)=>({fn:Eg(e).fn,options:[e,t]}),hee=(e,t)=>{let n=Sg(e);return{name:n.name,fn:n.fn,options:[e,t]}},gee=(e,t)=>{let n=Cg(e);return{name:n.name,fn:n.fn,options:[e,t]}},_ee=(e,t)=>{let n=wg(e);return{name:n.name,fn:n.fn,options:[e,t]}},vee=(e,t)=>{let n=dee(e);return{name:n.name,fn:n.fn,options:[e,t]}},yee=Object.defineProperty,Ng=(e,t)=>yee(e,`name`,{value:t,configurable:!0}),Pg=`Popper`,[Fg,Ig]=td(Pg),[bee,Lg]=Fg(Pg),xee=Ng(e=>{let{__scopePopper:t,children:n}=e,[r,i]=m.useState(null),[a,o]=m.useState(void 0);return(0,h.jsx)(bee,{scope:t,anchor:r,onAnchorChange:i,placementState:a,setPlacementState:o,children:n})},`Popper`),See=`PopperAnchor`,Cee=m.forwardRef(Ng(function(e,t){let{__scopePopper:n,virtualRef:r,...i}=e,a=Lg(See,n),o=m.useRef(null),s=a.onAnchorChange,c=Au(t,m.useCallback(e=>{o.current=e,e&&s(e)},[s])),l=m.useRef(null);m.useEffect(()=>{if(!r)return;let e=l.current;l.current=r.current,e!==l.current&&s(l.current)});let u=a.placementState&&Bg(a.placementState),d=u?.[0],f=u?.[1];return r?null:(0,h.jsx)(Xu.div,{"data-radix-popper-side":d,"data-radix-popper-align":f,...i,ref:c})},`PopperAnchor`)),Rg=`PopperContent`,[wee,Tee]=Fg(Rg),Eee=m.forwardRef(Ng(function(e,t){let{__scopePopper:n,side:r=`bottom`,sideOffset:i=0,align:a=`center`,alignOffset:o=0,arrowPadding:s=0,avoidCollisions:c=!0,collisionBoundary:l=[],collisionPadding:u=0,sticky:d=`partial`,hideWhenDetached:f=!1,updatePositionStrategy:p=`optimized`,onPlaced:g,..._}=e,v=Lg(Rg,n),[y,b]=m.useState(null),x=Au(t,b),[S,C]=m.useState(null),w=Mm(S),T=w?.width??0,E=w?.height??0,D=r+(a===`center`?``:`-`+a),O=typeof u==`number`?u:{top:0,right:0,bottom:0,left:0,...u},k=Array.isArray(l)?l:[l],ee=k.length>0,te={padding:O,boundary:k.filter(zg),altBoundary:ee},{refs:ne,floatingStyles:re,placement:A,isPositioned:ie,middlewareData:j}=uee({strategy:`fixed`,placement:D,whileElementsMounted:Ng((...e)=>yg(...e,{animationFrame:p===`always`}),`whileElementsMounted`),elements:{reference:v.anchor},middleware:[fee({mainAxis:i+E,alignmentAxis:o}),c&&pee({mainAxis:!0,crossAxis:!1,limiter:d===`partial`?mee():void 0,...te}),c&&hee({...te}),gee({...te,apply:Ng(({elements:e,rects:t,availableWidth:n,availableHeight:r})=>{let{width:i,height:a}=t.reference,o=e.floating.style;o.setProperty(`--radix-popper-available-width`,`${n}px`),o.setProperty(`--radix-popper-available-height`,`${r}px`),o.setProperty(`--radix-popper-anchor-width`,`${i}px`),o.setProperty(`--radix-popper-anchor-height`,`${a}px`)},`apply`)}),S&&vee({element:S,padding:s}),Dee({arrowWidth:T,arrowHeight:E}),f&&_ee({strategy:`referenceHidden`,...te,boundary:ee?te.boundary:void 0})]}),ae=v.setPlacementState;wd(()=>(ae(A),()=>{ae(void 0)}),[A,ae]);let[oe,se]=Bg(A),ce=af(g);wd(()=>{ie&&ce?.()},[ie,ce]);let le=j.arrow?.x,ue=j.arrow?.y,de=j.arrow?.centerOffset!==0,[fe,pe]=m.useState();return wd(()=>{y&&pe(window.getComputedStyle(y).zIndex)},[y]),(0,h.jsx)(`div`,{ref:ne.setFloating,"data-radix-popper-content-wrapper":``,style:{...re,transform:ie?re.transform:`translate(0, -200%)`,minWidth:`max-content`,zIndex:fe,"--radix-popper-transform-origin":[j.transformOrigin?.x,j.transformOrigin?.y].join(` `),...j.hide?.referenceHidden&&{visibility:`hidden`,pointerEvents:`none`}},dir:e.dir,children:(0,h.jsx)(wee,{scope:n,placedSide:oe,placedAlign:se,onArrowChange:C,arrowX:le,arrowY:ue,shouldHideArrow:de,children:(0,h.jsx)(Xu.div,{"data-side":oe,"data-align":se,..._,ref:x,style:{..._.style,animation:ie?_.style?.animation:`none`}})})})},`PopperContent`));function zg(e){return e!==null}Ng(zg,`isNotNull`);var Dee=Ng(e=>({name:`transformOrigin`,options:e,fn(t){let{placement:n,rects:r,middlewareData:i}=t,a=i.arrow?.centerOffset!==0,o=a?0:e.arrowWidth,s=a?0:e.arrowHeight,[c,l]=Bg(n),u={start:`0%`,center:`50%`,end:`100%`}[l],d=(i.arrow?.x??0)+o/2,f=(i.arrow?.y??0)+s/2,p=``,m=``;return c===`bottom`?(p=a?u:`${d}px`,m=`${-s}px`):c===`top`?(p=a?u:`${d}px`,m=`${r.floating.height+s}px`):c===`right`?(p=`${-s}px`,m=a?u:`${f}px`):c===`left`&&(p=`${r.floating.width+s}px`,m=a?u:`${f}px`),{data:{x:p,y:m}}}}),`transformOrigin`);function Bg(e){let[t,n=`center`]=e.split(`-`);return[t,n]}Ng(Bg,`getSideAndAlignFromPlacement`);var Vg=xee,Hg=Cee,Ug=Eee,Wg=Object.defineProperty,Gg=(e,t)=>Wg(e,`name`,{value:t,configurable:!0}),Kg=!1;function qg(){let[e,t]=m.useState(Kg);return m.useEffect(()=>{Kg||(Kg=!0,t(!0))},[]),e}Gg(qg,`useIsHydrated`);var Jg=m.useSyncExternalStore;function Yg(){return()=>{}}Gg(Yg,`subscribe`);function Xg(){return Jg(Yg,()=>!0,()=>!1)}Gg(Xg,`useIsHydratedModern`);var Zg=typeof Jg==`function`?Xg:qg,Qg=Object.defineProperty,$g=(e,t)=>Qg(e,`name`,{value:t,configurable:!0}),e_=`rovingFocusGroup.onEntryFocus`,t_={bubbles:!1,cancelable:!0},n_=`RovingFocusGroup`,[r_,i_,a_]=ad(n_),[o_,s_]=td(n_,[a_]),[c_,l_]=o_(n_),u_=m.forwardRef($g(function(e,t){return(0,h.jsx)(r_.Provider,{scope:e.__scopeRovingFocusGroup,children:(0,h.jsx)(r_.Slot,{scope:e.__scopeRovingFocusGroup,children:(0,h.jsx)(d_,{...e,ref:t})})})},`RovingFocusGroup`)),d_=m.forwardRef($g(function(e,t){let{__scopeRovingFocusGroup:n,orientation:r,loop:i=!1,dir:a,currentTabStopId:o,defaultCurrentTabStopId:s,onCurrentTabStopIdChange:c,onEntryFocus:l,preventScrollOnEntryFocus:u=!1,...d}=e,f=m.useRef(null),p=Au(t,f),g=tf(a),[_,v]=Nd({prop:o,defaultProp:s??null,onChange:c,caller:n_}),[y,b]=m.useState(!1),x=af(l),S=i_(n),C=m.useRef(!1),[w,T]=m.useState(0);return m.useEffect(()=>{let e=f.current;if(e)return e.addEventListener(e_,x),()=>e.removeEventListener(e_,x)},[x]),(0,h.jsx)(c_,{scope:n,orientation:r,dir:g,loop:i,currentTabStopId:_,onItemFocus:m.useCallback(e=>v(e),[v]),onItemShiftTab:m.useCallback(()=>b(!0),[]),onFocusableItemAdd:m.useCallback(()=>T(e=>e+1),[]),onFocusableItemRemove:m.useCallback(()=>T(e=>e-1),[]),children:(0,h.jsx)(Xu.div,{tabIndex:y||w===0?-1:0,"data-orientation":r,...d,ref:p,style:{outline:`none`,...e.style},onMouseDown:yd(e.onMouseDown,()=>{C.current=!0}),onFocus:yd(e.onFocus,e=>{let t=!C.current;if(e.target===e.currentTarget&&t&&!y){let t=new CustomEvent(e_,t_);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){let e=S().filter(e=>e.focusable);__([e.find(e=>e.active),e.find(e=>e.id===_),...e].filter(Boolean).map(e=>e.ref.current),u)}}C.current=!1}),onBlur:yd(e.onBlur,()=>b(!1))})})},`RovingFocusGroupImpl`)),f_=`RovingFocusGroupItem`,p_=m.forwardRef($g(function(e,t){let{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:a,children:o,...s}=e,c=Zd(),l=a||c,u=l_(f_,n),d=u.currentTabStopId===l,f=i_(n),{onFocusableItemAdd:p,onFocusableItemRemove:g,currentTabStopId:_}=u,v=Zg();return wd(()=>{if(v&&r)return p(),()=>g()},[v,r,p,g]),m.useEffect(()=>{if(!v&&r)return p(),()=>g()},[v,r,p,g]),(0,h.jsx)(r_.ItemSlot,{scope:n,id:l,focusable:r,active:i,children:(0,h.jsx)(Xu.span,{tabIndex:d?0:-1,"data-orientation":u.orientation,...s,ref:t,onMouseDown:yd(e.onMouseDown,e=>{r?u.onItemFocus(l):e.preventDefault()}),onFocus:yd(e.onFocus,()=>u.onItemFocus(l)),onKeyDown:yd(e.onKeyDown,e=>{if(e.key===`Tab`&&e.shiftKey){u.onItemShiftTab();return}if(e.target!==e.currentTarget)return;let t=g_(e,u.orientation,u.dir);if(t!==void 0){if(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault();let n=f().filter(e=>e.focusable).map(e=>e.ref.current);if(t===`last`)n.reverse();else if(t===`prev`||t===`next`){t===`prev`&&n.reverse();let r=n.indexOf(e.currentTarget);n=u.loop?v_(n,r+1):n.slice(r+1)}setTimeout(()=>__(n))}}),children:typeof o==`function`?o({isCurrentTabStop:d,hasTabStop:_!=null}):o})})},`RovingFocusGroupItem`)),m_={ArrowLeft:`prev`,ArrowUp:`prev`,ArrowRight:`next`,ArrowDown:`next`,PageUp:`first`,Home:`first`,PageDown:`last`,End:`last`};function h_(e,t){return t===`rtl`?e===`ArrowLeft`?`ArrowRight`:e===`ArrowRight`?`ArrowLeft`:e:e}$g(h_,`getDirectionAwareKey`);function g_(e,t,n){let r=h_(e.key,n);if(!(t===`vertical`&&[`ArrowLeft`,`ArrowRight`].includes(r))&&!(t===`horizontal`&&[`ArrowUp`,`ArrowDown`].includes(r)))return m_[r]}$g(g_,`getFocusIntent`);function __(e,t=!1){let n=document.activeElement;for(let r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}$g(__,`focusFirst`);function v_(e,t){return e.map((n,r)=>e[(t+r)%e.length])}$g(v_,`wrapArray`);var y_=u_,b_=p_,x_=Object.defineProperty,S_=(e,t)=>x_(e,`name`,{value:t,configurable:!0}),C_=[`Enter`,` `],w_=[`ArrowDown`,`PageUp`,`Home`],T_=[`ArrowUp`,`PageDown`,`End`],E_=[...w_,...T_];[...C_],[...C_];var D_=`Menu`,[O_,k_,A_]=ad(D_),[j_,M_]=td(D_,[A_,Ig,s_]),N_=Ig(),P_=s_(),[F_,I_]=j_(D_),[L_,R_]=j_(D_),z_=S_(e=>{let{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:a,modal:o=!0}=e,s=N_(t),[c,l]=m.useState(null),u=m.useRef(!1),d=af(a),f=tf(i);return m.useEffect(()=>{let e=S_(()=>{u.current=!0,document.addEventListener(`pointerdown`,t,{capture:!0,once:!0}),document.addEventListener(`pointermove`,t,{capture:!0,once:!0})},`handleKeyDown`),t=S_(()=>u.current=!1,`handlePointer`);return document.addEventListener(`keydown`,e,{capture:!0}),()=>{document.removeEventListener(`keydown`,e,{capture:!0}),document.removeEventListener(`pointerdown`,t,{capture:!0}),document.removeEventListener(`pointermove`,t,{capture:!0})}},[]),m.useEffect(()=>{if(!n)return;let e=S_(()=>d(!1),`handleBlur`);return window.addEventListener(`blur`,e),()=>window.removeEventListener(`blur`,e)},[n,d]),(0,h.jsx)(Vg,{...s,children:(0,h.jsx)(F_,{scope:t,open:n,onOpenChange:d,content:c,onContentChange:l,children:(0,h.jsx)(L_,{scope:t,onClose:m.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:f,modal:o,children:r})})})},`Menu`),B_=m.forwardRef(S_(function(e,t){let{__scopeMenu:n,...r}=e,i=N_(n);return(0,h.jsx)(Hg,{...i,...r,ref:t})},`MenuAnchor`)),V_=`MenuPortal`,[H_,U_]=j_(V_,{forceMount:void 0}),W_=S_(e=>{let{__scopeMenu:t,forceMount:n,children:r,container:i}=e,a=I_(V_,t);return(0,h.jsx)(H_,{scope:t,forceMount:n,children:(0,h.jsx)(Vd,{present:n||a.open,children:(0,h.jsx)(Rf,{asChild:!0,container:i,children:r})})})},`MenuPortal`),G_=`MenuContent`,[K_,q_]=j_(G_),J_=m.forwardRef(S_(function(e,t){let n=U_(G_,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=I_(G_,e.__scopeMenu),o=R_(G_,e.__scopeMenu);return(0,h.jsx)(O_.Provider,{scope:e.__scopeMenu,children:(0,h.jsx)(Vd,{present:r||a.open,children:(0,h.jsx)(O_.Slot,{scope:e.__scopeMenu,children:o.modal?(0,h.jsx)(Y_,{...i,ref:t}):(0,h.jsx)(X_,{...i,ref:t})})})})},`MenuContent`)),Y_=m.forwardRef(S_(function(e,t){let n=I_(G_,e.__scopeMenu),r=m.useRef(null),i=Au(t,r);return m.useEffect(()=>{let e=r.current;if(e)return cm(e)},[]),(0,h.jsx)(Q_,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:yd(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})},`MenuRootContentModal`)),X_=m.forwardRef(S_(function(e,t){let n=I_(G_,e.__scopeMenu);return(0,h.jsx)(Q_,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})},`MenuRootContentNonModal`)),Z_=Nu(`MenuContent.ScrollLock`),Q_=m.forwardRef(S_(function(e,t){let{__scopeMenu:n,loop:r=!1,trapFocus:i,onOpenAutoFocus:a,onCloseAutoFocus:o,disableOutsidePointerEvents:s,onEntryFocus:c,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,disableOutsideScroll:g,..._}=e,v=I_(G_,n),y=R_(G_,n),b=N_(n),x=P_(n),S=k_(n),[C,w]=m.useState(null),T=m.useRef(null),E=Au(t,T,v.onContentChange),D=m.useRef(0),O=m.useRef(``),k=m.useRef(0),ee=m.useRef(null),te=m.useRef(`right`),ne=m.useRef(0),re=g?$p:m.Fragment,A=g?{as:Z_,allowPinchZoom:!0}:void 0,ie=S_(e=>{let t=O.current+e,n=S().filter(e=>!e.disabled),r=document.activeElement,i=n.find(e=>e.ref.current===r)?.textValue,a=lv(n.map(e=>e.textValue),t,i),o=n.find(e=>e.textValue===a)?.ref.current;S_((function e(t){O.current=t,window.clearTimeout(D.current),t!==``&&(D.current=window.setTimeout(()=>e(``),1e3))}),`updateSearch`)(t),o&&setTimeout(()=>o.focus())},`handleTypeaheadSearch`);m.useEffect(()=>()=>window.clearTimeout(D.current),[]),Wf();let j=m.useCallback(e=>te.current===ee.current?.side&&dv(e,ee.current?.area),[]);return(0,h.jsx)(K_,{scope:n,searchRef:O,onItemEnter:m.useCallback(e=>{j(e)&&e.preventDefault()},[j]),onItemLeave:m.useCallback(e=>{j(e)||(T.current?.focus(),w(null))},[j]),onTriggerLeave:m.useCallback(e=>{j(e)&&e.preventDefault()},[j]),pointerGraceTimerRef:k,onPointerGraceIntentChange:m.useCallback(e=>{ee.current=e},[]),children:(0,h.jsx)(re,{...A,children:(0,h.jsx)(Tf,{asChild:!0,trapped:i,onMountAutoFocus:yd(a,e=>{e.preventDefault(),T.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:(0,h.jsx)(pf,{asChild:!0,disableOutsidePointerEvents:s,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,children:(0,h.jsx)(y_,{asChild:!0,...x,dir:y.dir,orientation:`vertical`,loop:r,currentTabStopId:C,onCurrentTabStopIdChange:w,onEntryFocus:yd(c,e=>{y.isUsingKeyboardRef.current||e.preventDefault()}),preventScrollOnEntryFocus:!0,children:(0,h.jsx)(Ug,{role:`menu`,"aria-orientation":`vertical`,"data-state":iv(v.open),"data-radix-menu-content":``,dir:y.dir,...b,..._,ref:E,style:{outline:`none`,..._.style},onKeyDown:yd(_.onKeyDown,e=>{let t=e.target.closest(`[data-radix-menu-content]`)===e.currentTarget,n=e.ctrlKey||e.altKey||e.metaKey,r=e.key.length===1;t&&(e.key===`Tab`&&e.preventDefault(),!n&&r&&ie(e.key));let i=T.current;if(e.target!==i||!E_.includes(e.key))return;e.preventDefault();let a=S().filter(e=>!e.disabled).map(e=>e.ref.current);T_.includes(e.key)&&a.reverse(),sv(a)}),onBlur:yd(e.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(D.current),O.current=``)}),onPointerMove:yd(e.onPointerMove,fv(e=>{let t=e.target,n=ne.current!==e.clientX;if(e.currentTarget.contains(t)&&n){let t=e.clientX>ne.current?`right`:`left`;te.current=t,ne.current=e.clientX}}))})})})})})})},`MenuContentImpl`)),$_=`MenuItem`,ev=`menu.itemSelect`,tv=m.forwardRef(S_(function(e,t){let{disabled:n=!1,onSelect:r,...i}=e,a=m.useRef(null),o=R_($_,e.__scopeMenu),s=q_($_,e.__scopeMenu),c=Au(t,a),l=m.useRef(!1),u=S_(()=>{let e=a.current;if(!n&&e){let t=new CustomEvent(ev,{bubbles:!0,cancelable:!0});e.addEventListener(ev,e=>r?.(e),{once:!0}),Zu(e,t),t.defaultPrevented?l.current=!1:o.onClose()}},`handleSelect`);return(0,h.jsx)(nv,{...i,ref:c,disabled:n,onClick:yd(e.onClick,u),onPointerDown:t=>{e.onPointerDown?.(t),l.current=!0},onPointerUp:yd(e.onPointerUp,e=>{l.current||e.currentTarget?.click()}),onKeyDown:yd(e.onKeyDown,e=>{n||e.target!==e.currentTarget||(s.searchRef.current===``||e.key!==` `)&&C_.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})})},`MenuItem`)),nv=m.forwardRef(S_(function(e,t){let{__scopeMenu:n,disabled:r=!1,textValue:i,...a}=e,o=q_($_,n),s=P_(n),c=m.useRef(null),l=Au(t,c),[u,d]=m.useState(!1),[f,p]=m.useState(``);return m.useEffect(()=>{let e=c.current;e&&p((e.textContent??``).trim())},[a.children]),(0,h.jsx)(O_.ItemSlot,{scope:n,disabled:r,textValue:i??f,children:(0,h.jsx)(b_,{asChild:!0,...s,focusable:!r,children:(0,h.jsx)(Xu.div,{role:`menuitem`,"data-highlighted":u?``:void 0,"aria-disabled":r||void 0,"data-disabled":r?``:void 0,...a,ref:l,onPointerMove:yd(e.onPointerMove,fv(e=>{r?o.onItemLeave(e):(o.onItemEnter(e),e.defaultPrevented||e.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:yd(e.onPointerLeave,fv(e=>o.onItemLeave(e))),onFocus:yd(e.onFocus,()=>d(!0)),onBlur:yd(e.onBlur,()=>d(!1))})})})},`MenuItemImpl`)),[Oee,kee]=j_(`MenuRadioGroup`,{value:void 0,onValueChange:S_(()=>{},`onValueChange`)}),[Aee,jee]=j_(`MenuItemIndicator`,{checked:!1}),rv=m.forwardRef(S_(function(e,t){let{__scopeMenu:n,...r}=e;return(0,h.jsx)(Xu.div,{role:`separator`,"aria-orientation":`horizontal`,...r,ref:t})},`MenuSeparator`)),[Mee,Nee]=j_(`MenuSub`);function iv(e){return e?`open`:`closed`}S_(iv,`getOpenState`);function av(e){return e===`indeterminate`}S_(av,`isIndeterminate`);function ov(e){return av(e)?`indeterminate`:e?`checked`:`unchecked`}S_(ov,`getCheckedState`);function sv(e){let t=document.activeElement;for(let n of e)if(n===t||(n.focus(),document.activeElement!==t))return}S_(sv,`focusFirst`);function cv(e,t){return e.map((n,r)=>e[(t+r)%e.length])}S_(cv,`wrapArray`);function lv(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=cv(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}S_(lv,`getNextMatch`);function uv(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}S_(uv,`isPointInPolygon`);function dv(e,t){return t?uv({x:e.clientX,y:e.clientY},t):!1}S_(dv,`isPointerInGraceArea`);function fv(e){return t=>t.pointerType===`mouse`?e(t):void 0}S_(fv,`whenMouse`);var pv=z_,mv=B_,hv=W_,gv=J_,_v=tv,vv=rv,yv=Object.defineProperty,bv=(e,t)=>yv(e,`name`,{value:t,configurable:!0}),xv=`DropdownMenu`,[Sv,Pee]=td(xv,[M_]),Cv=M_(),[wv,Tv]=Sv(xv),Ev=bv(e=>{let{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:a,onOpenChange:o,modal:s=!0}=e,c=Cv(t),l=m.useRef(null),[u,d]=Nd({prop:i,defaultProp:a??!1,onChange:o,caller:xv});return(0,h.jsx)(wv,{scope:t,triggerId:Zd(),triggerRef:l,contentId:Zd(),open:u,onOpenChange:d,onOpenToggle:m.useCallback(()=>d(e=>!e),[d]),modal:s,children:(0,h.jsx)(pv,{...c,open:u,onOpenChange:d,dir:r,modal:s,children:n})})},`DropdownMenu`),Dv=`DropdownMenuTrigger`,Ov=m.forwardRef(bv(function(e,t){let{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,a=Tv(Dv,n),o=Cv(n),s=Au(t,a.triggerRef);return(0,h.jsx)(mv,{asChild:!0,...o,children:(0,h.jsx)(Xu.button,{type:`button`,id:a.triggerId,"aria-haspopup":`menu`,"aria-expanded":a.open,"aria-controls":a.open?a.contentId:void 0,"data-state":a.open?`open`:`closed`,"data-disabled":r?``:void 0,disabled:r,...i,ref:s,onPointerDown:yd(e.onPointerDown,e=>{!r&&e.button===0&&e.ctrlKey===!1&&(a.onOpenToggle(),a.open||e.preventDefault())}),onKeyDown:yd(e.onKeyDown,e=>{r||([`Enter`,` `].includes(e.key)&&a.onOpenToggle(),e.key===`ArrowDown`&&a.onOpenChange(!0),[`Enter`,` `,`ArrowDown`].includes(e.key)&&e.preventDefault())})})})},`DropdownMenuTrigger`)),kv=bv(e=>{let{__scopeDropdownMenu:t,...n}=e,r=Cv(t);return(0,h.jsx)(hv,{...r,...n})},`DropdownMenuPortal`),Av=`DropdownMenuContent`,jv=m.forwardRef(bv(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=Tv(Av,n),a=Cv(n),o=m.useRef(!1);return(0,h.jsx)(gv,{id:i.contentId,"aria-labelledby":i.triggerId,...a,...r,ref:t,onCloseAutoFocus:yd(e.onCloseAutoFocus,e=>{o.current||i.triggerRef.current?.focus(),o.current=!1,e.preventDefault()}),onInteractOutside:yd(e.onInteractOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;(!i.modal||r)&&(o.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})},`DropdownMenuContent`)),Mv=m.forwardRef(bv(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=Cv(n);return(0,h.jsx)(_v,{...i,...r,ref:t})},`DropdownMenuItem`)),Nv=m.forwardRef(bv(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=Cv(n);return(0,h.jsx)(vv,{...i,...r,ref:t})},`DropdownMenuSeparator`)),Pv=Ev,Fv=Ov,Iv=kv,Lv=jv,Rv=Mv,zv=Nv,Bv=Object.defineProperty,Vv=m.forwardRef(((e,t)=>Bv(e,`name`,{value:t,configurable:!0}))(function(e,t){return(0,h.jsx)(Xu.label,{...e,ref:t,onMouseDown:t=>{t.target.closest(`button, input, select, textarea`)||(e.onMouseDown?.(t),!t.defaultPrevented&&t.detail>1&&t.preventDefault())}})},`Label`)),Hv=Object.defineProperty,Uv=(e,t)=>Hv(e,`name`,{value:t,configurable:!0}),Wv=`Popover`,[Gv,Fee]=td(Wv,[Ig]),Kv=Ig(),[qv,Jv]=Gv(Wv),Yv=Uv(e=>{let{__scopePopover:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!1}=e,s=Kv(t),c=m.useRef(null),[l,u]=m.useState(!1),[d,f]=Nd({prop:r,defaultProp:i??!1,onChange:a,caller:Wv});return(0,h.jsx)(Vg,{...s,children:(0,h.jsx)(qv,{scope:t,contentId:Zd(),triggerRef:c,open:d,onOpenChange:f,onOpenToggle:m.useCallback(()=>f(e=>!e),[f]),hasCustomAnchor:l,onCustomAnchorAdd:m.useCallback(()=>u(!0),[]),onCustomAnchorRemove:m.useCallback(()=>u(!1),[]),modal:o,children:n})})},`Popover`),Xv=`PopoverAnchor`,Zv=m.forwardRef(Uv(function(e,t){let{__scopePopover:n,...r}=e,i=Jv(Xv,n),a=Kv(n),{onCustomAnchorAdd:o,onCustomAnchorRemove:s}=i;return m.useEffect(()=>(o(),()=>s()),[o,s]),(0,h.jsx)(Hg,{...a,...r,ref:t})},`PopoverAnchor`)),Qv=`PopoverTrigger`,$v=m.forwardRef(Uv(function(e,t){let{__scopePopover:n,...r}=e,i=Jv(Qv,n),a=Kv(n),o=Au(t,i.triggerRef),s=(0,h.jsx)(Xu.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":fy(i.open),...r,ref:o,onClick:yd(e.onClick,i.onOpenToggle)});return i.hasCustomAnchor?s:(0,h.jsx)(Hg,{asChild:!0,...a,children:s})},`PopoverTrigger`)),ey=`PopoverPortal`,[ty,ny]=Gv(ey,{forceMount:void 0}),ry=Uv(e=>{let{__scopePopover:t,forceMount:n,children:r,container:i}=e,a=Jv(ey,t);return(0,h.jsx)(ty,{scope:t,forceMount:n,children:(0,h.jsx)(Vd,{present:n||a.open,children:(0,h.jsx)(Rf,{asChild:!0,container:i,children:r})})})},`PopoverPortal`),iy=`PopoverContent`,ay=m.forwardRef(Uv(function(e,t){let n=ny(iy,e.__scopePopover),{forceMount:r=n.forceMount,...i}=e,a=Jv(iy,e.__scopePopover);return(0,h.jsx)(Vd,{present:r||a.open,children:a.modal?(0,h.jsx)(sy,{...i,ref:t}):(0,h.jsx)(cy,{...i,ref:t})})},`PopoverContent`)),oy=Nu(`PopoverContent.RemoveScroll`),sy=m.forwardRef(Uv(function(e,t){let n=Jv(iy,e.__scopePopover),r=m.useRef(null),i=Au(t,r),a=m.useRef(!1);return m.useEffect(()=>{let e=r.current;if(e)return cm(e)},[]),(0,h.jsx)($p,{as:oy,allowPinchZoom:!0,children:(0,h.jsx)(ly,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:yd(e.onCloseAutoFocus,e=>{e.preventDefault(),a.current||n.triggerRef.current?.focus()}),onPointerDownOutside:yd(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;a.current=r},{checkForDefaultPrevented:!1}),onFocusOutside:yd(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1})})})},`PopoverContentModal`)),cy=m.forwardRef(Uv(function(e,t){let n=Jv(iy,e.__scopePopover),r=m.useRef(!1),i=m.useRef(!1);return(0,h.jsx)(ly,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})},`PopoverContentNonModal`)),ly=m.forwardRef(Uv(function(e,t){let{__scopePopover:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,disableOutsidePointerEvents:o,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onInteractOutside:u,...d}=e,f=Jv(iy,n),p=Kv(n);return Wf(),(0,h.jsx)(Tf,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,h.jsx)(pf,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:u,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onDismiss:()=>f.onOpenChange(!1),deferPointerDownOutside:!0,children:(0,h.jsx)(Ug,{"data-state":fy(f.open),role:`dialog`,id:f.contentId,...p,...d,ref:t,style:{...d.style,"--radix-popover-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-popover-content-available-width":`var(--radix-popper-available-width)`,"--radix-popover-content-available-height":`var(--radix-popper-available-height)`,"--radix-popover-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-popover-trigger-height":`var(--radix-popper-anchor-height)`}})})})},`PopoverContentImpl`)),uy=`PopoverClose`,dy=m.forwardRef(Uv(function(e,t){let{__scopePopover:n,...r}=e,i=Jv(uy,n);return(0,h.jsx)(Xu.button,{type:`button`,...r,ref:t,onClick:yd(e.onClick,()=>i.onOpenChange(!1))})},`PopoverClose`));function fy(e){return e?`open`:`closed`}Uv(fy,`getState`);var Iee=Yv,Lee=Zv,Ree=$v,zee=ry,Bee=ay,Vee=dy,Hee=Object.defineProperty,Uee=(e,t)=>Hee(e,`name`,{value:t,configurable:!0}),Wee=`Toggle`,Gee=m.forwardRef(Uee(function(e,t){let{pressed:n,defaultPressed:r,onPressedChange:i,...a}=e,[o,s]=Nd({prop:n,onChange:i,defaultProp:r??!1,caller:Wee});return(0,h.jsx)(Xu.button,{type:`button`,"aria-pressed":o,"data-state":o?`on`:`off`,"data-disabled":e.disabled?``:void 0,...a,ref:t,onClick:yd(e.onClick,()=>{e.disabled||s(!o)})})},`Toggle`)),Kee=Object.defineProperty,py=(e,t)=>Kee(e,`name`,{value:t,configurable:!0}),my=`ToggleGroup`,[hy,qee]=td(my,[s_]),gy=s_(),Jee=m.forwardRef(py(function(e,t){let{type:n,...r}=e;if(n===`single`)return(0,h.jsx)(Yee,{role:`radiogroup`,...r,ref:t});if(n===`multiple`)return(0,h.jsx)(Xee,{role:`toolbar`,...r,ref:t});throw Error(`Missing prop \`type\` expected on \`${my}\``)},`ToggleGroup`)),[_y,vy]=hy(my),Yee=m.forwardRef(py(function(e,t){let{value:n,defaultValue:r,onValueChange:i=py(()=>{},`onValueChange`),...a}=e,[o,s]=Nd({prop:n,defaultProp:r??``,onChange:i,caller:my});return(0,h.jsx)(_y,{scope:e.__scopeToggleGroup,type:`single`,value:m.useMemo(()=>o?[o]:[],[o]),onItemActivate:s,onItemDeactivate:m.useCallback(()=>s(``),[s]),children:(0,h.jsx)(yy,{...a,ref:t})})},`ToggleGroupImplSingle`)),Xee=m.forwardRef(py(function(e,t){let{value:n,defaultValue:r,onValueChange:i=py(()=>{},`onValueChange`),...a}=e,[o,s]=Nd({prop:n,defaultProp:r??[],onChange:i,caller:my}),c=m.useCallback(e=>s((t=[])=>[...t,e]),[s]),l=m.useCallback(e=>s((t=[])=>t.filter(t=>t!==e)),[s]);return(0,h.jsx)(_y,{scope:e.__scopeToggleGroup,type:`multiple`,value:o,onItemActivate:c,onItemDeactivate:l,children:(0,h.jsx)(yy,{...a,ref:t})})},`ToggleGroupImplMultiple`)),[Zee,Qee]=hy(my),yy=m.forwardRef(py(function(e,t){let{__scopeToggleGroup:n,disabled:r=!1,rovingFocus:i=!0,orientation:a,dir:o,loop:s=!0,...c}=e,l=gy(n),u=tf(o),d={dir:u,...c};return(0,h.jsx)(Zee,{scope:n,rovingFocus:i,disabled:r,children:i?(0,h.jsx)(y_,{asChild:!0,...l,orientation:a,dir:u,loop:s,children:(0,h.jsx)(Xu.div,{...d,ref:t})}):(0,h.jsx)(Xu.div,{...d,ref:t})})},`ToggleGroupImpl`)),by=`ToggleGroupItem`,$ee=m.forwardRef(py(function(e,t){let n=vy(by,e.__scopeToggleGroup),r=Qee(by,e.__scopeToggleGroup),i=gy(e.__scopeToggleGroup),a=n.value.includes(e.value),o=r.disabled||e.disabled,s={...e,pressed:a,disabled:o},c=m.useRef(null);return r.rovingFocus?(0,h.jsx)(b_,{asChild:!0,...i,focusable:!o,active:a,ref:c,children:(0,h.jsx)(xy,{...s,ref:t})}):(0,h.jsx)(xy,{...s,ref:t})},`ToggleGroupItem`)),xy=m.forwardRef(py(function(e,t){let{__scopeToggleGroup:n,value:r,...i}=e,a=vy(by,n),o={role:`radio`,"aria-checked":e.pressed,"aria-pressed":void 0},s=a.type===`single`?o:void 0;return(0,h.jsx)(Gee,{...s,...i,ref:t,onPressedChange:e=>{e?a.onItemActivate(r):a.onItemDeactivate(r)}})},`ToggleGroupItemImpl`));function Sy({variant:e=`secondary`,size:t=`default`}={}){return I(`sl-btn`,`sl-btn--${e}`,t===`small`&&`sl-btn--small`)}function L({variant:e=`secondary`,size:t=`default`,disabledReason:n,className:r,type:i,title:a,...o}){return(0,h.jsx)(`button`,{"data-slot":`button`,"data-variant":e,type:i??`button`,title:o.disabled&&n!==void 0?n:a,className:I(Sy({variant:e,size:t}),r),...o})}function Cy({label:e,tip:t,title:n,children:r,...i}){let a=t===void 0||t===!1?void 0:t===!0?e:t;return(0,h.jsx)(L,{variant:`icon`,"aria-label":e,...a===void 0?{title:n??e}:{"data-tip":a},...i,children:r})}function wy({className:e,asChild:t=!1,type:n,...r}){let i=t?Pu:`button`;return(0,h.jsx)(i,{"data-slot":`play-key`,...t?{}:{type:n??`button`},className:I(`sl-key`,e),...r})}function Ty({className:e,...t}){return(0,h.jsx)(`div`,{className:I(`sl-btn-row`,e),...t})}var ete=4e3,tte=8e3,Ey=(0,m.createContext)(void 0);function nte({children:e}){let[t,n]=(0,m.useState)([]),r=(0,m.useRef)(0),i=(0,m.useRef)(new Map),a=(0,m.useCallback)(e=>{n(t=>t.filter(t=>t.id!==e));let t=i.current.get(e);t!==void 0&&clearTimeout(t),i.current.delete(e)},[]),o=(0,m.useCallback)((e,t=`info`,o)=>{r.current+=1;let s=r.current;n(n=>[...n.filter(t=>t.message!==e).slice(-2),{id:s,message:e,tone:t,action:o}]),i.current.set(s,setTimeout(()=>a(s),o===void 0?ete:tte))},[a]);(0,m.useEffect)(()=>{let e=i.current;return()=>{for(let t of e.values())clearTimeout(t)}},[]);let s=(0,m.useMemo)(()=>o,[o]);return(0,h.jsxs)(Ey.Provider,{value:s,children:[e,(0,h.jsx)(`section`,{"aria-label":`Notifications`,className:`sl-toasts`,children:t.map(e=>(0,h.jsxs)(`div`,{role:e.tone===`error`?`alert`:`status`,"data-tone":e.tone,className:I(`sl-toast sl-enter`,e.tone===`error`&&`sl-toast--failed`,e.tone===`success`&&`sl-toast--done`),children:[e.tone===`error`?(0,h.jsx)(Lc,{"aria-hidden":`true`,strokeWidth:1.75}):e.tone===`success`?(0,h.jsx)(ac,{"aria-hidden":`true`,strokeWidth:1.75}):(0,h.jsx)(yc,{"aria-hidden":`true`,strokeWidth:1.75,className:`text-ink-2`}),(0,h.jsx)(`p`,{className:`sl-toast__text m-0 min-w-0 break-words`,children:e.message}),e.action===void 0?null:(0,h.jsx)(L,{variant:`quiet`,size:`small`,onClick:()=>{a(e.id),e.action?.run()},children:e.action.label}),(0,h.jsx)(`button`,{type:`button`,"aria-label":`Dismiss notification`,onClick:()=>a(e.id),className:`sl-btn sl-btn--icon sl-btn--small -mr-1 w-[30px]`,children:(0,h.jsx)(Vc,{"aria-hidden":`true`,strokeWidth:1.75})})]},e.id))})]})}function Dy(){return(0,m.useContext)(Ey)??rte}function rte(){}var Oy=(0,m.createContext)(void 0);function ite({deps:e,children:t}){return(0,h.jsx)(Oy.Provider,{value:e,children:(0,h.jsx)(nte,{children:t})})}function R(){let e=(0,m.useContext)(Oy);if(e===void 0)throw Error(`useApp was called outside AppProvider`);return e}var ate=hm,ote=vm;function ste({className:e,...t}){return(0,h.jsx)(bm,{"data-slot":`dialog-overlay`,className:I(`fixed inset-0 z-40 bg-scrim`,e),...t})}function cte({className:e,children:t,...n}){return(0,h.jsxs)(ote,{children:[(0,h.jsx)(ste,{}),(0,h.jsx)(wm,{"data-slot":`dialog-content`,className:I(`sl-dialog fixed top-1/2 left-1/2 z-50 max-h-[calc(100vh-2rem)] -translate-x-1/2 -translate-y-1/2 overflow-y-auto`,`data-[state=open]:animate-dialog-in motion-reduce:animate-none`,e),...n,children:t})]})}function lte({className:e,...t}){return(0,h.jsx)(Em,{"data-slot":`dialog-title`,className:I(`sl-dialog__title text-ink`,e),...t})}function ute({className:e,...t}){return(0,h.jsx)(see,{"data-slot":`dialog-description`,className:I(`m-0 text-body text-ink-2`,e),...t})}function ky({open:e,onOpenChange:t,title:n,description:r,footer:i,children:a,className:o,dismissible:s=!0}){return(0,h.jsx)(ate,{open:e,...t===void 0?{}:{onOpenChange:t},children:(0,h.jsxs)(cte,{className:o,...s?{}:{onEscapeKeyDown:e=>e.preventDefault(),onInteractOutside:e=>e.preventDefault()},...r===void 0?{"aria-describedby":void 0}:{},children:[(0,h.jsx)(lte,{children:n}),r===void 0?null:(0,h.jsx)(ute,{children:r}),a,i===void 0?null:(0,h.jsx)(`div`,{className:`sl-dialog__foot`,children:i})]})})}function Ay({open:e,title:t,consequence:n,confirmLabel:r,cancelLabel:i=`Cancel`,tone:a=`destructive`,pending:o=!1,onConfirm:s,onCancel:c}){return(0,h.jsx)(ky,{open:e,onOpenChange:e=>{e||c()},title:t,description:n,footer:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(L,{variant:`secondary`,autoFocus:!0,onClick:c,children:i}),(0,h.jsx)(L,{variant:a,disabled:o,disabledReason:`Working on it`,onClick:s,children:r})]})})}var jy=[`onboarding`],My=[`onboarding`,`sample`],Ny=(e,t)=>[`narration-peaks`,e,t],Py=(e,t,n)=>e.fetch(`${e.origin}/api/onboarding${t}`,{method:`POST`,...n===void 0?{}:{headers:{"content-type":`application/json`},body:JSON.stringify(n)}});async function Fy(e){return P(await e.fetch(`${e.origin}/api/onboarding`))}async function Iy(e){await P(await Py(e,`/dismiss`))}async function Ly(e,t){return P(await Py(e,`/packs/${encodeURIComponent(t)}`))}async function Ry(e,t){return P(await Py(e,`/short`,t))}async function zy(e,t){return P(await Py(e,`/full-video`,t))}async function By(e){return P(await e.fetch(`${e.origin}/api/onboarding/sample`))}function Vy(e,t){return e!==void 0&&Object.values(e.samples).includes(t)}async function Hy(e){return P(await Py(e,`/sample/restore`))}async function Uy(e,t=Wy()){return P(await Py(e,`/sample/copy`,t===void 0?void 0:{projectId:t}))}function Wy(){if(typeof window>`u`)return;let e=/\/projects\/([^/?#]+)/.exec(window.location.pathname);return e?.[1]===void 0?void 0:decodeURIComponent(e[1])}async function Gy(e,t){return P(await e.fetch(`${e.origin}/api/projects/${encodeURIComponent(t)}/narration/peaks`))}var z={projects:[`projects`],revisions:e=>[`project`,e,`revisions`],revision:(e,t)=>[`project`,e,`revision`,t],revisionFile:(e,t,n)=>[`revision-file`,e,t,n],project:e=>[`project`,e],runCost:e=>[`project`,e,`run-cost`],article:(e,t=null)=>[`project`,e,`article`,t],audioPreview:(e,t)=>[`audio-preview`,e,t],file:(e,t)=>[`file`,e,t],staging:[`staging`],notice:[`notice`],usage:[`usage`],providers:[`providers`],voices:[`voices`],prompts:[`prompts`],entries:[`entries`],documentThemes:[`document-themes`],narrationAliases:[`narration-aliases`],settings:[`settings`],youtubeEdits:e=>[`project`,e,`youtube-edits`],channelLinks:[`channel-links`],projectChannelLinks:e=>[`channel-links`,`project`,e]};function Ky(e){return lt({queryKey:z.projects,queryFn:()=>Do(e)})}function qy(e,t){return lt({queryKey:z.project(t),queryFn:()=>Oo(e,t)})}function Jy(e,t){return lt({queryKey:z.runCost(t),queryFn:()=>ko(e,t)})}function Yy(e){return lt({queryKey:z.notice,queryFn:()=>Vo(e)})}function Xy(e){return lt({queryKey:z.usage,queryFn:()=>Bo(e)})}function Zy(e){return lt({queryKey:z.providers,queryFn:()=>Wo(e)})}function Qy(e){return lt({queryKey:z.voices,queryFn:()=>ls(e)})}function $y(e){return lt({queryKey:z.prompts,queryFn:()=>gs(e)})}function eb(e){return lt({queryKey:z.entries,queryFn:()=>Os(e)})}function tb(e){return lt({queryKey:z.documentThemes,queryFn:()=>As(e)})}function nb(e){return lt({queryKey:z.narrationAliases,queryFn:()=>Fs(e)})}function rb(e){return lt({queryKey:z.settings,queryFn:()=>Jo(e)})}var ib={"library.prompt.kind":{title:`Prompt kind`,body:`What the prompt is for, which decides where Play offers it. Article writes the video's text, Image and Thumbnail describe pictures, Narration Preparation adds delivery cues, YouTube Description writes the description, Shorts picks the short clips, Review checks a finished stage, Script writes speaker turns for several voices.`,tutorial:{page:`Prompts`,anchor:`prompt-kinds`}},"library.prompt.name":{title:`Prompt name`,body:`What Play and Edit project list this prompt by. Up to 200 characters, and unique within its kind. Templates remember a prompt by name, so after a rename they use the copy saved with them until you pick it again.`,tutorial:{page:`Prompts`,anchor:`write-a-new-prompt`}},"library.prompt.body.article":{title:`Article prompt`,body:`The instruction the text model gets to write the video's article, which becomes the narration. Each {{keyword}} becomes a field on Play. One call on the project's LLM, plus up to 3 more when the answer runs out of room; research notes go first when research ran. The answer's sources and pronunciation sections are never narrated.`,tutorial:{page:`Prompts`,anchor:`write-a-new-prompt`}},"library.prompt.body.image":{title:`Image prompt`,body:`Sent as written to the image model, with the keywords filled in; no text model rewrites it. Play sets how many pictures each prompt makes (1 to 20, at most 60 a run), and each picture is one image call. Pictures show for 15 s each by default and repeat until the video ends.`,tutorial:{page:`Prompts`,anchor:`write-a-new-prompt`}},"library.prompt.body.thumbnail":{title:`Thumbnail prompt`,body:`Sent to the image model to draw the thumbnail. With Thumbnail set to Prompt by LLM, the text model first turns it into a picture prompt using the title and article, one extra call. 1 thumbnail by default, or 3: the second a close-up, the third a wider shot, each one image call.`,tutorial:{page:`Prompts`,anchor:`write-a-new-prompt`}},"library.prompt.body.narration":{title:`Narration Preparation prompt`,body:`Tells the text model how the narration should be delivered. It only adds cues, such as a short speaking direction or a laugh or sigh, and never rewrites the words. One call each for the body, the intro and the outro. Works only with the Inworld TTS-2 voice model. With several speakers, each speaker on TTS-2 gets cues suited to their role.`,tutorial:{page:`Play-Narration`,anchor:`narration-preparation`}},"library.prompt.body.description":{title:`YouTube Description prompt`,body:`Tells the text model how to write the video's YouTube description, chapters, hashtags and tags from the timestamped transcript. One call per video. Each {{keyword}} becomes a field on Play. A project that picks none uses the Built-in wording.`,tutorial:{page:`Prompts`,anchor:`write-a-new-prompt`}},"library.prompt.body.shorts":{title:`Shorts prompt`,body:`Tells the text model which moments of the video to cut into vertical shorts (3 of 60 to 120 s by default). One call picks them, then one call per short writes its picture prompts, and each picture is one image call. A project that picks none uses the Built-in wording.`,tutorial:{page:`Prompts`,anchor:`write-a-new-prompt`}},"library.prompt.body.review":{title:`Review prompt`,body:`Tells the reviewer what to check in a finished article, set of images, narration, thumbnail or shorts, and when to flag or redo it. One reviewer call per item checked; pictures can only be judged by the Claude Code and Codex reviewers. A stage with none picked uses its own built-in wording.`,tutorial:{page:`Prompts`,anchor:`write-a-new-prompt`}},"library.prompt.body.script":{title:`Script prompt`,body:`Used in place of an Article prompt when a run has several voices and writes a script. The text model answers with # section headings and Name: words turns, one speaker per paragraph; text in [square brackets] is not spoken. One call on the project's LLM.`,tutorial:{page:`Prompts`,anchor:`write-a-new-prompt`}},"library.prompt.starter":{title:`Starter text`,body:`Fills the body with ready-made text to start from: the documentary delivery cues for Narration Preparation, or the Built-in wording YouTube Description and Shorts use when no prompt is picked. When the body already has text you confirm first. Nothing is saved until you choose Save.`,tutorial:{page:`Prompts`,anchor:`start-from-ready-made-text`}},"library.prompt.photorealistic":{title:`Draws photorealistic pictures`,body:`Turn on when this prompt's style looks like real photos or film. Prepare upload then answers Yes to YouTube's AI use question (a realistic-looking scene that didn't happen) for videos and shorts drawn with it. Leave off for painterly or illustrated styles. Applies at once, apart from Save; a channel's Always Yes or Always No wins. Default: off.`,tutorial:{page:`Prompts`,anchor:`mark-an-image-prompt-as-photorealistic`}},"library.slots":{title:`Detected slots`,body:`Every {{keyword}} in the body, listed as you type. Each becomes one field on Play, typed once and filled into every prompt that names it. Names are case-sensitive, so {{Topic}} and {{topic}} are two fields. A keyword the project title also names is typed per video and saved empty in templates.`,tutorial:{page:`Prompts`,anchor:`keywords-slots`}},"library.used-by":{title:`Used by`,body:`The templates, schedules and projects that name this item, matched by name within its kind. For a project it says how many of its revisions used it and whether the current one does. Projects keep their own text, so editing here changes only runs started later.`,tutorial:{page:`Prompts`,anchor:`used-by`}},"library.history":{title:`History`,body:`Every save that changes the name or text adds a version, and every version is kept. Here you see the latest change with the changed words marked. Compare versions opens them all side by side, with Restore for an older one.`,tutorial:{page:`Prompts`,anchor:`history-and-versions`}},"library.history.compare":{title:`Compare versions`,body:`Pick any two saved versions to see them side by side, with the words that changed marked. Older and Newer can be any versions; a rename between them is said above the text.`,tutorial:{page:`Prompts`,anchor:`history-and-versions`}},"library.history.versions":{title:`Versions`,body:`Every saved version, newest first. Restore saves an older version again as a new version, so nothing after it is lost and History notes where it came from. Projects already made keep their text.`,tutorial:{page:`Prompts`,anchor:`history-and-versions`}},"library.entry.category":{title:`Intro or outro`,body:`An intro is narrated before the body of the video, an outro after it, in the same voice. Play offers each in its own picker. A name only needs to be unique within its category.`,tutorial:{page:`Intros-and-Outros`,anchor:`text-or-llm`}},"library.inline-rename":{title:`Rename in the list`,body:`Changes only the name, right in the list; the text stays as it is. Enter saves, Escape keeps the old name, and Undo on the notice renames it back. A prompt or intro/outro keeps the rename in History; templates that picked the old name use the copy saved with them until you pick it again. A template saves a new version; schedules keep the version they were made from.`,tutorial:{page:`Library-Overview`,anchor:`rename-in-the-row`}},"library.entry.name":{title:`Entry name`,body:`What Play and Edit project list this intro or outro by. Up to 200 characters, and unique within its category.`,tutorial:{page:`Intros-and-Outros`,anchor:`write-an-intro-or-outro`}},"library.entry.mode":{title:`Mode`,body:`Text is narrated as written, with the keywords filled in and no extra call. LLM sends the body as an instruction to the project's text model, with the title, keyword values and article, and narrates the answer: one call per entry, and the run then needs an LLM. Default: Text.`,tutorial:{page:`Intros-and-Outros`,anchor:`text-or-llm`}},"library.entry.body":{title:`Entry body`,body:`In Text mode, the words the narrator says; in LLM mode, the instruction whose answer is said. Each {{keyword}} becomes a field on Play. It is narrated as its own audio file with the run's voice, one voice request each.`,tutorial:{page:`Intros-and-Outros`,anchor:`write-an-intro-or-outro`}},"library.aliases":{title:`Narration aliases`,body:`Words the narrator says differently from how they are written, such as Dr. as Doctor. Only what the voice and Narration Preparation receive changes; the article and captions keep the written words. A project copies this list when it starts and uses it while Use narration aliases is on. Up to 1000 aliases, saved as a whole.`,tutorial:{page:`Narration-Aliases-and-Glossary`,anchor:`narration-aliases`}},"library.aliases.written":{title:`Written`,body:`The word or phrase as it appears in the article, up to 200 characters. Spaces inside it match any spacing. Two aliases can't share a written form; where two overlap, the one starting first wins, then the longer.`,tutorial:{page:`Narration-Aliases-and-Glossary`,anchor:`rules`}},"library.aliases.spoken":{title:`Say it as`,body:`What the narrator says instead, spelled the way it sounds, up to 500 characters. Only the audio changes. An alias wins over a Pronunciation Glossary entry for the same words.`,tutorial:{page:`Narration-Aliases-and-Glossary`,anchor:`rules`}},"library.aliases.whole-word":{title:`Whole word`,body:`On: matches only where the written form stands as a word of its own, so it never fires inside a longer word. Off: matches inside other words too. Default: on.`,tutorial:{page:`Narration-Aliases-and-Glossary`,anchor:`rules`}},"library.aliases.match-case":{title:`Match case`,body:`On: matches only with the same capital letters, so US is not us. Off: capitals are ignored. Default: off.`,tutorial:{page:`Narration-Aliases-and-Glossary`,anchor:`rules`}},"templates.show-channel":{title:`Show templates of`,body:`Shows only the templates of one channel, or of all. A template's channel is the one a draft made from it runs in. Choosing here changes nothing about the templates.`,tutorial:{page:`Templates`,anchor:`filter-by-channel`}},"templates.apply":{title:`Use in Play`,body:`Makes a new Play draft from the template and opens it in Play for you to review; nothing starts. Keywords the project title names start empty for this video's topic, and uploaded files keep their names but must be attached again. The template itself is unchanged.`,tutorial:{page:`Templates`,anchor:`use-a-template`}},"templates.save":{title:`Save a setup`,body:`Keeps a saved Play draft as a reusable template: every setting and checkpoint choice, plus a copy of each picked prompt and intro or outro. Keywords the project title names, like {{Topic}}, are saved empty; other keywords keep their values. Queued extra videos and uploaded fonts are left out.`,tutorial:{page:`Templates`,anchor:`save-a-template-from-library--templates`}},"templates.save.draft":{title:`Saved Play draft`,body:`The Play draft whose setup the template keeps. Only drafts saved in Play are listed; open Play to prepare one first. The draft itself stays as it is.`,tutorial:{page:`Templates`,anchor:`save-a-template-from-library--templates`}},"templates.save.name":{title:`Template name`,body:`What the template is called in this list and wherever you pick a template, such as a schedule. Up to 120 characters.`,tutorial:{page:`Templates`,anchor:`save-a-template-from-library--templates`}},"templates.edit":{title:`Edit a template`,body:`Shows the keywords the template fills and what each feeds. The pencil beside its name renames it; every save adds a version that History keeps. To change its settings, use it in Play, change the draft, then Save a setup.`,tutorial:{page:`Templates`,anchor:`see-a-templates-keywords`}},"templates.history":{title:`Template versions`,body:`Every saved version of the template, newest first. Pick one to compare its setup with the current one. Restore saves the older setup again as a new version, so nothing is lost. Drafts and projects made from it keep their setup.`,tutorial:{page:`Templates`,anchor:`history`}},"templates.save.channel":{title:`Template channel`,body:`The channel the template belongs to, and the one a draft made from it runs in. Default: the draft's own channel, or its template's channel when it has none.`,tutorial:{page:`Templates`,anchor:`save-a-template-from-library--templates`}},"library.themes.yours":{title:`Your themes`,body:`Themes you made or copied from a built-in. Pick one on the Document row in Play or in Edit project. A project keeps its own copy of the settings, so editing or deleting a theme here never changes a PDF already made or queued.`,tutorial:{page:`Document-Themes`,anchor:`built-in-and-your-own-themes`}},"library.themes.built-in":{title:`Built-in themes`,body:`Looks that ship with Slopify and can't be changed. Plain is an unbranded flat page and what a new project gets. Copy one to make a theme of your own you can edit.`,tutorial:{page:`Document-Themes`,anchor:`built-in-and-your-own-themes`}},"library.theme.name":{title:`Theme name`,body:`What the theme is called on the Document row in Play and in Edit project. Up to 80 characters.`,tutorial:{page:`Document-Themes`,anchor:`make-a-theme`}},"library.theme.preview":{title:`Preview`,body:`A sample article laid out with this theme by the same renderer that makes a project's PDF, redrawn about half a second after you stop typing. It runs on your computer and costs nothing. Your projects use their own text and thumbnail.`,tutorial:{page:`Document-Themes`,anchor:`make-a-theme`}},"library.theme.page.format":{title:`Paper size`,body:`The page size of the PDF. A4 (210 × 297 mm) is used in most of the world; US Letter (216 × 279 mm) in the US and Canada. Pick the one your readers print on. Default: A4.`,tutorial:{page:`Document-Themes`,anchor:`page`}},"library.theme.page.margin":{title:`Margins`,body:`Blank space kept on every edge of each page, in millimetres. Wider margins mean shorter lines and more pages. From 5 to 60 mm. Default: 22 mm.`,tutorial:{page:`Document-Themes`,anchor:`page`}},"library.theme.page.content-top":{title:`Text starts at`,body:`How far from the top of the page the text begins on pages that carry the running header, in millimetres. Raise it when text crowds the header. From 5 to 80 mm. Default: 32 mm.`,tutorial:{page:`Document-Themes`,anchor:`page`}},"library.theme.background.image":{title:`Background`,body:`Parchment texture stretches an aged-paper picture over every page. Flat colour fills each page with the Page colour, drawn slightly darker at the edges. Default: Flat colour.`,tutorial:{page:`Document-Themes`,anchor:`page`}},"library.theme.background.color":{title:`Page colour`,body:`The colour of every page when Background is Flat colour; ignored with the parchment texture. Type a hex code like #fdfaf3 or use the picker. Default: #fdfaf3, a warm off-white.`,tutorial:{page:`Document-Themes`,anchor:`page`}},"library.theme.colors.heading":{title:`Heading colour`,body:`The colour of headings, drop caps, the brand name and links. Type a hex code like #1f3a5f or use the picker. Default: #1f3a5f, a dark blue.`,tutorial:{page:`Document-Themes`,anchor:`colours`}},"library.theme.colors.text":{title:`Body text colour`,body:`The colour of paragraphs, lists and bold or italic text. Keep it dark against the page colour so it reads and prints well. Default: #1a1a1a, near black.`,tutorial:{page:`Document-Themes`,anchor:`colours`}},"library.theme.colors.muted":{title:`Muted colour`,body:`The colour of dates, bullets, quotes and the dotted lines on the contents page. Default: #555555, a mid grey.`,tutorial:{page:`Document-Themes`,anchor:`colours`}},"library.theme.colors.faint":{title:`Faint colour`,body:`The colour of the running header and the page numbers, kept light so they stay out of the way. Default: #888888, a light grey.`,tutorial:{page:`Document-Themes`,anchor:`colours`}},"library.theme.fonts.body":{title:`Body font`,body:`The font of paragraphs and lists. The first box picks the family, the second its weight or italic, the number adds space between letters in millimetres (-0.5 to 2). Cinzel is bundled and has no italics; Times, Helvetica and Courier are built into every PDF reader. Default: Cinzel Regular, 0.01 mm.`,tutorial:{page:`Document-Themes`,anchor:`fonts`}},"library.theme.fonts.strong":{title:`Bold text font`,body:`The font of bold words inside paragraphs. Family, style and letter spacing in millimetres, as for Body. Default: Cinzel Bold, 0.02 mm.`,tutorial:{page:`Document-Themes`,anchor:`fonts`}},"library.theme.fonts.emphasis":{title:`Italic text font`,body:`The font of italic words inside paragraphs. Cinzel has no italics, so the default borrows Times. Family, style and letter spacing in millimetres, as for Body. Default: Times Italic, 0 mm.`,tutorial:{page:`Document-Themes`,anchor:`fonts`}},"library.theme.fonts.heading":{title:`Heading font`,body:`The font of the article's headings and of the contents, sources and closing page titles. Family, style and letter spacing in millimetres, as for Body. Default: Cinzel Bold, 0.02 mm.`,tutorial:{page:`Document-Themes`,anchor:`fonts`}},"library.theme.fonts.dramatic":{title:`Chapter numbers and brand font`,body:`The font of the big number in a heading like "Chapter 3:" and of the brand name on the title page. Family, style and letter spacing in millimetres, as for Body. Default: Cinzel Black, 0.03 mm.`,tutorial:{page:`Document-Themes`,anchor:`fonts`}},"library.theme.fonts.decorative":{title:`Tagline and link font`,body:`The font of the tagline and the linked line on the title page, and of the link and closing line on the closing page. Default: Cinzel Medium, 0.015 mm.`,tutorial:{page:`Document-Themes`,anchor:`fonts`}},"library.theme.fonts.drop-cap":{title:`Drop cap font`,body:`The font of the large first letter that starts a paragraph after a heading, when drop caps are on. Family, style and letter spacing in millimetres, as for Body. Default: Cinzel Black, 0 mm.`,tutorial:{page:`Document-Themes`,anchor:`fonts`}},"library.theme.fonts.footer":{title:`Header and page number font`,body:`The font of the running header and the page numbers. Family, style and letter spacing in millimetres, as for Body. Default: Times Regular, 0 mm.`,tutorial:{page:`Document-Themes`,anchor:`fonts`}},"library.theme.sizes.title":{title:`Title size`,body:`The size of the article's title on the title page, in points (1 pt is about 0.35 mm). From 6 to 72 pt. Default: 22 pt.`,tutorial:{page:`Document-Themes`,anchor:`text-sizes`}},"library.theme.sizes.brand":{title:`Brand size`,body:`The size of the brand name on the title page, in points. Shown only when Branding has a brand name. From 6 to 72 pt. Default: 31 pt.`,tutorial:{page:`Document-Themes`,anchor:`text-sizes`}},"library.theme.sizes.section":{title:`Top-level heading size`,body:`The size of top-level headings and of the contents, sources and closing page titles, in points. From 6 to 72 pt. Default: 19 pt.`,tutorial:{page:`Document-Themes`,anchor:`text-sizes`}},"library.theme.sizes.heading":{title:`Second-level heading size`,body:`The size of second-level headings, the ones inside a top-level section, in points. From 6 to 72 pt. Default: 17 pt.`,tutorial:{page:`Document-Themes`,anchor:`text-sizes`}},"library.theme.sizes.subheading":{title:`Third-level heading size`,body:`The size of third-level and deeper headings, in points. From 6 to 72 pt. Default: 13 pt.`,tutorial:{page:`Document-Themes`,anchor:`text-sizes`}},"library.theme.sizes.body":{title:`Body size`,body:`The size of paragraphs, lists and the closing page text, in points. Bigger text means more pages. From 6 to 24 pt. Default: 10.5 pt.`,tutorial:{page:`Document-Themes`,anchor:`text-sizes`}},"library.theme.sizes.meta":{title:`Date and word count size`,body:`The size of the date, word count and link lines under the title on the title page, in points. From 5 to 24 pt. Default: 10 pt.`,tutorial:{page:`Document-Themes`,anchor:`text-sizes`}},"library.theme.sizes.footer":{title:`Header and page number size`,body:`The size of the running header and the page numbers, in points. From 5 to 24 pt. Default: 9 pt.`,tutorial:{page:`Document-Themes`,anchor:`text-sizes`}},"library.theme.spacing.body-line":{title:`Body line height`,body:`The distance from one line of body text to the next, in millimetres. Raise it for airier pages, lower it to fit more on each page. From 3 to 20 mm. Default: 8 mm.`,tutorial:{page:`Document-Themes`,anchor:`spacing`}},"library.theme.spacing.heading-line":{title:`Heading line height`,body:`The distance between the lines of a top- or second-level heading that wraps, in millimetres. From 3 to 30 mm. Default: 11 mm.`,tutorial:{page:`Document-Themes`,anchor:`spacing`}},"library.theme.spacing.subheading-line":{title:`Subheading line height`,body:`The distance between the lines of a third-level heading that wraps, in millimetres. From 3 to 30 mm. Default: 9 mm.`,tutorial:{page:`Document-Themes`,anchor:`spacing`}},"library.theme.spacing.paragraph-gap":{title:`After a paragraph`,body:`Extra space after each paragraph, as a share of a body line: 0.5 is half a line. From 0 to 3. Default: 0.5.`,tutorial:{page:`Document-Themes`,anchor:`spacing`}},"library.theme.spacing.heading-gap":{title:`Before a heading`,body:`Extra space above each heading, as a share of a body line: 1 is one full line. From 0 to 5. Default: 1.`,tutorial:{page:`Document-Themes`,anchor:`spacing`}},"library.theme.spacing.item-gap":{title:`After a list item`,body:`Extra space after each bulleted or numbered item, as a share of a body line. From 0 to 3. Default: 0.2.`,tutorial:{page:`Document-Themes`,anchor:`spacing`}},"library.theme.spacing.list-indent":{title:`List indent`,body:`How far bulleted and numbered lists are pushed in from the left margin, in millimetres. From 0 to 30 mm. Default: 6 mm.`,tutorial:{page:`Document-Themes`,anchor:`spacing`}},"library.theme.spacing.quote-indent":{title:`Quote indent`,body:`How far quotes are pushed in from the left margin, in millimetres. From 0 to 40 mm. Default: 8 mm.`,tutorial:{page:`Document-Themes`,anchor:`spacing`}},"library.theme.spacing.rule-width":{title:`Divider width`,body:`The width of the short centred line a --- in the article becomes, in millimetres. From 0 to 150 mm. Default: 30 mm.`,tutorial:{page:`Document-Themes`,anchor:`spacing`}},"library.theme.drop-cap.enabled":{title:`Drop caps`,body:`Starts the first paragraph after each heading with a large first letter that spans several lines, as in printed books. Turn it off for a plainer page. Default: on.`,tutorial:{page:`Document-Themes`,anchor:`drop-caps`}},"library.theme.drop-cap.lines":{title:`Drop cap lines tall`,body:`How many lines of body text the large first letter spans. Default: 3 lines.`,tutorial:{page:`Document-Themes`,anchor:`drop-caps`}},"library.theme.drop-cap.scale":{title:`Drop cap letter size`,body:`The size of the large first letter, as a multiple of the height of the lines it spans. From 1 to 5. Default: 3.`,tutorial:{page:`Document-Themes`,anchor:`drop-caps`}},"library.theme.drop-cap.gap":{title:`Gap beside the drop cap`,body:`The space between the large first letter and the text beside it, in millimetres. From 0 to 20 mm. Default: 4 mm.`,tutorial:{page:`Document-Themes`,anchor:`drop-caps`}},"library.theme.drop-cap.min-length":{title:`Shortest paragraph`,body:`A paragraph shorter than this many characters starts plainly, so a one-line paragraph never gets a huge letter. From 0 to 2000. Default: 50.`,tutorial:{page:`Document-Themes`,anchor:`drop-caps`}},"library.theme.drop-cap.min-room":{title:`Room needed`,body:`With less than this share of the page left, a paragraph that starts with a drop cap moves to the next page. 0.25 is a quarter of the page. From 0 to 1. Default: 0.25.`,tutorial:{page:`Document-Themes`,anchor:`drop-caps`}},"library.theme.title-page.brand-y":{title:`Brand from top`,body:`Where the brand name sits on the title page, measured from the top edge of the page in millimetres. From 10 to 200 mm. Default: 60 mm.`,tutorial:{page:`Document-Themes`,anchor:`title-page`}},"library.theme.title-page.tagline-offset":{title:`Tagline below brand`,body:`The distance from the brand name down to the tagline, in millimetres. From 0 to 60 mm. Default: 10 mm.`,tutorial:{page:`Document-Themes`,anchor:`title-page`}},"library.theme.title-page.title-y":{title:`Title from top`,body:`Where the article's title sits on the title page, measured from the top edge of the page in millimetres. From 10 to 250 mm. Default: 80 mm.`,tutorial:{page:`Document-Themes`,anchor:`title-page`}},"library.theme.title-page.title-line":{title:`Title line height`,body:`The distance between the lines of a title that wraps, in millimetres. From 3 to 40 mm. Default: 10 mm.`,tutorial:{page:`Document-Themes`,anchor:`title-page`}},"library.theme.title-page.meta-offset":{title:`Details below title`,body:`The distance from the title down to the date and word count, in millimetres, when there is no cover picture. From 0 to 100 mm. Default: 20 mm.`,tutorial:{page:`Document-Themes`,anchor:`title-page`}},"library.theme.title-page.meta-line":{title:`Details line height`,body:`The distance between the date, word count and link lines on the title page, in millimetres. From 3 to 30 mm. Default: 10 mm.`,tutorial:{page:`Document-Themes`,anchor:`title-page`}},"library.theme.title-page.show-date":{title:`Show the date`,body:`Prints "Written on" and the date the PDF was made under the title on the title page. Default: on.`,tutorial:{page:`Document-Themes`,anchor:`title-page`}},"library.theme.title-page.show-word-count":{title:`Show the word count`,body:`Prints the article's word count under the title on the title page. Default: on.`,tutorial:{page:`Document-Themes`,anchor:`title-page`}},"library.theme.title-page.cover":{title:`Thumbnail as cover`,body:`Puts the project's thumbnail on the title page, between the title and the date, when the project has one. Without a thumbnail the page is laid out as if this were off. Default: on.`,tutorial:{page:`Document-Themes`,anchor:`title-page`}},"library.theme.title-page.cover-gap":{title:`Space around cover`,body:`The space above and below the cover picture on the title page, in millimetres. From 0 to 40 mm. Default: 6 mm.`,tutorial:{page:`Document-Themes`,anchor:`title-page`}},"library.theme.title-page.cover-height":{title:`Cover height at most`,body:`The tallest the cover picture may be, in millimetres. It keeps its shape and shrinks further when the page has less room. From 20 to 200 mm. Default: 110 mm.`,tutorial:{page:`Document-Themes`,anchor:`title-page`}},"library.theme.brand.name":{title:`Brand name`,body:`Your channel or brand, printed large at the top of the title page and before the title in the running header ("Brand | Title"). Leave it empty to show no brand. Default: empty.`,tutorial:{page:`Document-Themes`,anchor:`branding`}},"library.theme.brand.tagline":{title:`Tagline`,body:`A short line under the brand name on the title page. Leave it empty to hide it. Default: empty.`,tutorial:{page:`Document-Themes`,anchor:`branding`}},"library.theme.brand.url":{title:`Website`,body:`The web address the brand name and the title-page link open when clicked in the PDF. Leave it empty for no link. Default: empty.`,tutorial:{page:`Document-Themes`,anchor:`branding`}},"library.theme.brand.link-label":{title:`Link text`,body:`The words of a linked line under the word count on the title page; it opens Website. Leave it empty to hide the line. Default: empty.`,tutorial:{page:`Document-Themes`,anchor:`branding`}},"library.theme.contents.enabled":{title:`Contents page`,body:`Adds a table of contents after the title page, listing the article's headings with their page numbers. Each entry is a link to its page. Default: on.`,tutorial:{page:`Document-Themes`,anchor:`contents-page`}},"library.theme.contents.title":{title:`Contents page title`,body:`The heading at the top of the contents page. Up to 300 characters. Default: Table of Contents.`,tutorial:{page:`Document-Themes`,anchor:`contents-page`}},"library.theme.contents.depth":{title:`Lists headings down to`,body:`Which headings the contents page lists: only top-level ones, down to second-level, or down to third-level. Deeper lists take more room and can add a page. Default: Second level.`,tutorial:{page:`Document-Themes`,anchor:`contents-page`}},"library.theme.contents.title-offset":{title:`Contents title position`,body:`The distance from the top margin down to the contents page title, in millimetres. From 0 to 100 mm. Default: 20 mm.`,tutorial:{page:`Document-Themes`,anchor:`contents-page`}},"library.theme.contents.first-entry-offset":{title:`First entry position`,body:`The distance from the top margin down to the first entry of the contents, in millimetres. From 0 to 150 mm. Default: 40 mm.`,tutorial:{page:`Document-Themes`,anchor:`contents-page`}},"library.theme.contents.line":{title:`Contents line height`,body:`The distance from one contents entry to the next, in millimetres. From 3 to 30 mm. Default: 8 mm.`,tutorial:{page:`Document-Themes`,anchor:`contents-page`}},"library.theme.contents.indent":{title:`Indent per level`,body:`How much further in each deeper heading level is listed on the contents page, in millimetres. From 0 to 30 mm. Default: 5 mm.`,tutorial:{page:`Document-Themes`,anchor:`contents-page`}},"library.theme.header.enabled":{title:`Running header`,body:`Prints the brand and the article title ("Brand | Title") at the top of every page after the title page. Default: on.`,tutorial:{page:`Document-Themes`,anchor:`header-and-footer`}},"library.theme.header.top":{title:`Header from top`,body:`The distance from the top edge of the page to the running header, in millimetres. From 3 to 60 mm. Default: 15 mm.`,tutorial:{page:`Document-Themes`,anchor:`header-and-footer`}},"library.theme.header.max-title":{title:`Header title at most`,body:`A title longer than this many characters is cut short in the running header so it fits on one line. From 5 to 200. Default: 35.`,tutorial:{page:`Document-Themes`,anchor:`header-and-footer`}},"library.theme.footer.enabled":{title:`Page numbers`,body:`Prints a page number at the bottom of every page after the title page. Default: on.`,tutorial:{page:`Document-Themes`,anchor:`header-and-footer`}},"library.theme.footer.text":{title:`Page number text`,body:`The words around the page number; {page} becomes the number, so "Page {page}" prints "Page 4". Default: Page {page}.`,tutorial:{page:`Document-Themes`,anchor:`header-and-footer`}},"library.theme.footer.bottom":{title:`Page number from the bottom`,body:`The distance from the bottom edge of the page to the page number, in millimetres. From 3 to 60 mm. Default: 10 mm.`,tutorial:{page:`Document-Themes`,anchor:`header-and-footer`}},"library.theme.footer.reserve":{title:`Space kept above page number`,body:`Space kept free above the page number, so body text always stops short of it, in millimetres. From 0 to 60 mm. Default: 15 mm.`,tutorial:{page:`Document-Themes`,anchor:`header-and-footer`}},"library.theme.sources.enabled":{title:`Sources page`,body:`Adds a page listing the web links the article and its research used, each one clickable. Default: on.`,tutorial:{page:`Document-Themes`,anchor:`sources-page`}},"library.theme.sources.title":{title:`Sources page title`,body:`The heading at the top of the sources page. Up to 300 characters. Default: Sources Consulted.`,tutorial:{page:`Document-Themes`,anchor:`sources-page`}},"library.theme.sources.title-offset":{title:`Sources title position`,body:`The distance from the top margin down to the sources page title, in millimetres. From 0 to 100 mm. Default: 20 mm.`,tutorial:{page:`Document-Themes`,anchor:`sources-page`}},"library.theme.sources.body-offset":{title:`Sources list position`,body:`The distance from the top margin down to the first source, in millimetres. From 0 to 150 mm. Default: 40 mm.`,tutorial:{page:`Document-Themes`,anchor:`sources-page`}},"library.theme.sources.line":{title:`Sources line height`,body:`The distance between the lines of one source, in millimetres. From 3 to 30 mm. Default: 8 mm.`,tutorial:{page:`Document-Themes`,anchor:`sources-page`}},"library.theme.sources.gap":{title:`Gap between sources`,body:`Extra space between one source and the next, in millimetres. From 0 to 20 mm. Default: 2 mm.`,tutorial:{page:`Document-Themes`,anchor:`sources-page`}},"library.theme.end-page.enabled":{title:`Closing page`,body:`Adds a last page with your own text, such as an about section, a thank-you or a link to your site. Default: off.`,tutorial:{page:`Document-Themes`,anchor:`closing-page`}},"library.theme.end-page.title":{title:`Closing page title`,body:`The heading at the top of the closing page. Up to 300 characters. Default: About.`,tutorial:{page:`Document-Themes`,anchor:`closing-page`}},"library.theme.end-page.lines":{title:`Closing page text`,body:`The closing page text, one line per row, up to 60 lines of 300 characters. A line starting with "•" becomes a muted bullet, one ending with ":" a bold label, an empty line a gap. Default: empty.`,tutorial:{page:`Document-Themes`,anchor:`closing-page`}},"library.theme.end-page.details":{title:`Add date, word and page counts`,body:`Adds a Document Details list under your text: the date written, the total words and the total pages. Default: on.`,tutorial:{page:`Document-Themes`,anchor:`closing-page`}},"library.theme.end-page.link":{title:`Closing page link`,body:`Adds a clickable line after your text: the words to show and the web address it opens. Leave the address empty to show the words without a link. Default: off.`,tutorial:{page:`Document-Themes`,anchor:`closing-page`}},"library.theme.end-page.closing":{title:`Closing line`,body:`A last line after the text and the link, such as a sign-off, in the decorative font. Leave it empty to leave it out. Default: empty.`,tutorial:{page:`Document-Themes`,anchor:`closing-page`}},"library.theme.end-page.title-offset":{title:`Closing title position`,body:`The distance from the top margin down to the closing page title, in millimetres. From 0 to 100 mm. Default: 20 mm.`,tutorial:{page:`Document-Themes`,anchor:`closing-page`}},"library.theme.end-page.body-offset":{title:`Closing text position`,body:`The distance from the top margin down to the first line of the closing text, in millimetres. From 0 to 150 mm. Default: 40 mm.`,tutorial:{page:`Document-Themes`,anchor:`closing-page`}},"library.theme.metadata.author":{title:`PDF author`,body:`The author a PDF reader shows in the document properties; it is not printed on the pages. {title} becomes the article title. Default: empty.`,tutorial:{page:`Document-Themes`,anchor:`pdf-details`}},"library.theme.metadata.subject":{title:`PDF subject`,body:`The subject a PDF reader shows in the document properties. {title} becomes the article title. Default: {title}.`,tutorial:{page:`Document-Themes`,anchor:`pdf-details`}},"library.theme.metadata.keywords":{title:`PDF keywords`,body:`Search words a PDF reader shows in the document properties, usually separated by commas. Up to 1000 characters. Default: empty.`,tutorial:{page:`Document-Themes`,anchor:`pdf-details`}},"library.theme.metadata.creator":{title:`PDF creator`,body:`The app or person a PDF reader shows as the creator in the document properties. Default: empty.`,tutorial:{page:`Document-Themes`,anchor:`pdf-details`}}},ab={"planning.schedules":{title:`Schedules`,body:`A schedule starts a new project from a saved template at a local time, while Slopify is open on this machine. Each run makes a fresh project, so changing the template later never rewrites an old run. It uses the template version you picked and never includes uploaded media. Each run costs what that template's project costs.`,tutorial:{page:`Schedules`}},"planning.schedule.name":{title:`Schedule name`,body:`A name to tell this schedule apart in the list, on the calendar and on the channel page. It never appears in the videos. Up to 200 characters.`,tutorial:{page:`Schedules`,anchor:`create-a-schedule`}},"planning.schedule.template":{title:`Template`,body:`The saved template each run starts from, with its version. The schedule keeps this version when you save the template again; pick the template again here to use the newer one. The template decides the providers, and so what each run costs. Save templates from Play; they are listed in Library → Templates.`,tutorial:{page:`Schedules`,anchor:`create-a-schedule`}},"planning.schedule.cadence":{title:`Cadence`,body:`How often the schedule runs. Every day runs once a day at the local time. Selected weekdays runs on the days you tick. One time runs once at a date and time, then completes. Each run starts one project. Default: Every day at 09:00.`,tutorial:{page:`Schedules`,anchor:`when-it-runs`}},"planning.schedule.time":{title:`Local time`,body:`The clock time each run starts, read in the timezone below. Default: 09:00. A run only starts while Slopify is open; Missed run decides what happens when it was closed.`,tutorial:{page:`Schedules`,anchor:`when-it-runs`}},"planning.schedule.once-at":{title:`Run at`,body:`The date and time of the single run, read in the timezone below. After that run starts, the schedule shows as completed.`,tutorial:{page:`Schedules`,anchor:`when-it-runs`}},"planning.schedule.weekdays":{title:`Weekdays`,body:`The days a Selected weekdays schedule runs, each at the local time. Tick at least one; each ticked day is one project a week. Default: Mon, Wed and Fri.`,tutorial:{page:`Schedules`,anchor:`when-it-runs`}},"planning.schedule.timezone":{title:`Timezone`,body:`The IANA zone the run time is read in, such as Europe/Tirane or America/New_York. Default: this computer's zone. When clocks go back, a repeated time uses the earlier one; a time skipped when clocks go forward moves forward by the gap.`,tutorial:{page:`Schedules`,anchor:`when-it-runs`}},"planning.schedule.timezone-once":{title:`Timezone`,body:`The IANA zone the one-off date and time are read in, such as Europe/Tirane or America/New_York. Default: this computer's zone. When clocks go back, a repeated time uses the earlier one; nonexistent spring-forward times are refused, so pick another.`,tutorial:{page:`Schedules`,anchor:`when-it-runs`}},"planning.schedule.missed":{title:`Missed run`,body:`What happens to a run that came due while Slopify was closed or asleep. Skip drops it when it is more than 1 minute late and waits for the next time. Run once when Slopify reopens starts one catch-up run, however many were missed. Default: Skip.`,tutorial:{page:`Schedules`,anchor:`when-it-runs`}},"planning.schedule.spend":{title:`Spend ceiling`,body:`The most one run may cost, in US cents: 500 is $5.00. Before each run Slopify estimates the project's cost; when the high estimate is over this, or a cost can't be estimated, the run fails instead of starting. Leave it empty for no ceiling. Default: empty.`,tutorial:{page:`Schedules`,anchor:`when-it-runs`}},"planning.schedule.topics":{title:`Topics`,body:`Each run takes the first topic, starts one project with it and removes it from the list. The schedule completes when the list is empty, unless topic generation is on. With no topics and generation off, every run uses the template as saved. Up to 500 topics.`,tutorial:{page:`Schedules`,anchor:`topics`}},"planning.schedule.inline-topics":{title:`Queued topics`,body:`Change the queue right here: type a topic and press Enter to add it, edit one in its field and press Enter to rename it, use the arrows to move it and the cross to remove it. Each change saves at once and changes only the queue; Undo on the notice puts it back. For a topic's own keyword values, press Edit.`,tutorial:{page:`Schedules`,anchor:`edit-the-queued-topics-in-place`}},"planning.schedule.topic-format":{title:`How to write the topics`,body:`Three ways to write the same list; switching keeps everything. One per line fills only the topic keyword. Table adds a column for each keyword a topic sets itself, such as its word count. YAML / JSON holds the same as text, for pasting or keeping in a file.`,tutorial:{page:`Schedules`,anchor:`three-ways-to-write-the-list`}},"planning.schedule.topic-lines":{title:`Topics, one per line`,body:`Type or paste one topic per line; blank lines are skipped. Each topic fills the keyword under Each topic fills, and the first line is the next run. Every other keyword uses its every-run value.`,tutorial:{page:`Schedules`,anchor:`three-ways-to-write-the-list`}},"planning.schedule.topic-yaml":{title:`Topics as YAML or JSON`,body:`A list such as "- Cleopatra", or one map per topic such as "- Topic: Cleopatra" with a line for each keyword it sets, like "Min. Word Count: 12000". A JSON array works too. A keyword a topic leaves out uses its every-run value. The schedule saves only once the list reads.`,tutorial:{page:`Schedules`,anchor:`three-ways-to-write-the-list`}},"planning.schedule.topic-table":{title:`Topic table`,body:`One row per run, in order. The first column fills the topic keyword; each extra column sets that keyword for that topic's run only, and a blank cell uses the every-run value. Set a keyword per topic adds a column; the x in a column's header drops it. Project title shows the result.`,tutorial:{page:`Schedules`,anchor:`three-ways-to-write-the-list`}},"planning.schedule.topic-keyword":{title:`Each topic fills`,body:`The template keyword, such as {{Topic}}, that each queued topic replaces. Default: the keyword the template's project title uses, else the first one. When the title doesn't use it, every project gets the same title.`,tutorial:{page:`Schedules`,anchor:`which-keyword-a-topic-fills`}},"planning.schedule.every-run":{title:`Every-run value`,body:`The value this keyword gets on every run, such as a word count. Default: the template's own value. A topic that sets the keyword itself, in Table or YAML / JSON, overrides it for that one run.`,tutorial:{page:`Schedules`,anchor:`which-keyword-a-topic-fills`}},"planning.schedule.generation":{title:`Topic generation`,body:`When the queue holds fewer topics than you ask for, Slopify asks an LLM for more: one call for what is missing plus 5 spare, at most 50. It sends the series brief and every title this schedule, your projects and the channel's existing videos already have, and drops near duplicates.`,tutorial:{page:`Schedules`,anchor:`topics-that-find-themselves`}},"planning.schedule.brief":{title:`Series brief`,body:`What the series covers, its style and what makes a topic worth a video. Only topic generation reads it. Leave it empty to use the channel's series brief from the channel's Brand tab. Up to 4,000 characters.`,tutorial:{page:`Schedules`,anchor:`topics-that-find-themselves`}},"planning.schedule.new-topics":{title:`New topics`,body:`Off: you add every topic yourself. Generate and queue directly: new topics join the end of the list. Generate and hold for approval: they wait under Topics waiting, and beside the calendar, until you approve them. Each generation is one LLM call. Default: Off.`,tutorial:{page:`Schedules`,anchor:`topics-that-find-themselves`}},"planning.schedule.keep-count":{title:`Keep at least this many queued`,body:`Slopify asks for new topics whenever the queue, plus the topics waiting for approval when holding, drops below this number. A higher number keeps more topics lined up ahead of the runs, for you to review. From 1 to 100. Default: 10.`,tutorial:{page:`Schedules`,anchor:`topics-that-find-themselves`}},"planning.schedule.generation-llm":{title:`Topic generation LLM`,body:`The text model that suggests topics. Ticked, it uses the provider and model the template writes with. Untick to pick another, such as a cheaper model. Either way each generation is one call on that provider. Default: the template's LLM.`,tutorial:{page:`Schedules`,anchor:`topics-that-find-themselves`}},"planning.schedule.generate-now":{title:`Generate topics now`,body:`Asks the LLM for new topics right away, at least 5, even when the queue is full and even during the 5 minutes Slopify waits after a failed try. One LLM call. When holding for approval they wait for you; otherwise they join the queue.`,tutorial:{page:`Schedules`,anchor:`generate-topics-now`}},"planning.schedule.held-keywords":{title:`Keywords of a waiting topic`,body:`The template's other keywords, set for this one topic's run, the same as a column in the queue's table. Leave one empty to use the schedule's every-run value (shown greyed). They go with the topic into the queue when you approve it.`,tutorial:{page:`Schedules`,anchor:`approve-held-topics`}},"planning.schedule.held":{title:`Topics waiting`,body:`Topics the LLM suggested, waiting for you. Approve adds one to the end of the queue; Edit changes its words first; Reject drops it for good, so it is never suggested again. Approve all queues every one in order. Waiting topics count toward Keep at least.`,tutorial:{page:`Schedules`,anchor:`approve-held-topics`}},"planning.calendar.view":{title:`Calendar view`,body:`Weeks shows the coming 4 weeks as a grid: drag a topic to another day or onto another schedule's run, or focus it and press Alt+arrow keys. List shows the same runs day by day, with buttons to move each topic. This browser remembers your choice.`,tutorial:{page:`Calendar`,anchor:`switch-between-weeks-and-a-list`}},"planning.calendar.move":{title:`Moving topics`,body:`Earlier and later swap a topic with its neighbour in the same schedule's queue, so it takes the other's run. Move to puts it at the end of another schedule's queue, so it takes that schedule's next free run. No schedule runs outside its own times.`,tutorial:{page:`Calendar`,anchor:`move-a-topic-to-another-day`}},"planning.calendar.add-schedule":{title:`Schedule`,body:`The schedule the topics join. They go to the end of its queue, after the topics already there (the count beside each name), so they take its next free runs. Only active and paused schedules are listed.`,tutorial:{page:`Calendar`,anchor:`add-topics`}},"planning.calendar.add-topics":{title:`Topics, one per line`,body:`Each line becomes one topic, in order; blank lines are skipped. A topic fills the schedule's topic keyword, and every other keyword keeps its every-run value. To give topics their own values, edit the schedule's topics as a table under Schedules.`,tutorial:{page:`Calendar`,anchor:`add-topics`}},"planning.channels":{title:`Channels`,body:`A channel is one series: its brand kit, series brief, cast, templates and schedules. Every template belongs to one channel, and each run from it uses that channel's look and cast. The default channel holds everything made before channels and can't be deleted.`,tutorial:{page:`Channels`,anchor:`the-channels-page`}},"planning.channel.current":{title:`Current channel`,body:`Home, Projects and the calendar show only this channel's work. All channels shows everything. It only filters what you see; every project and schedule keeps its own channel. This browser remembers your choice.`,tutorial:{page:`Channels`,anchor:`show-one-channels-work`}},"planning.channel.name":{title:`Channel name`,body:`The name you see in the channel picker, on Play and on the calendar. It stays inside Slopify and doesn't have to match your YouTube channel. Up to 200 characters.`,tutorial:{page:`Channels`,anchor:`create-a-channel`}},"planning.channel.brief":{title:`Series brief`,body:`What the channel covers, its style and what makes a topic worth a video. Topic generation reads it for every schedule of this channel that has no brief of its own. It doesn't change how videos are written. Up to 10,000 characters.`,tutorial:{page:`Channels`,anchor:`brand`}},"planning.channel.ai-disclosure":{title:`YouTube AI disclosure`,body:`Studio's AI use answer for this channel's videos and Shorts, given by Prepare upload and the Studio extension. Automatic says Yes only for YouTube's three cases: a voice marked as imitating a real person, real footage altered, or photorealistic AI pictures from a marked Image prompt. Saves as you pick. Default: Automatic.`,tutorial:{page:`Publishing-to-YouTube`,anchor:`override-per-channel`}},"planning.channel.language":{title:`Language of new projects`,body:`The language this channel's new projects are written and narrated in when Play or the template picks none. It applies with the brand kit off too, since it is not styling. Pick voices that speak it. Not set means English. Projects already made keep their language.`,tutorial:{page:`Other-Languages`,anchor:`set-a-channels-language`}},"planning.channel.brand-kit":{title:`Brand kit`,body:`The look every template of this channel gets unless it sets its own: fonts, colours, end screen, intro, outro, document theme and ambient sound. It fills only what a template leaves at its default, and a blank field adds nothing. Turn it off for one video on Play or in Edit project.`,tutorial:{page:`Channels`,anchor:`brand`}},"planning.channel.brand.caption-font":{title:`Caption font`,body:`The subtitle font for this channel's videos whose template leaves the font at Default. Not set leaves the template's font alone. Fonts you upload in the subtitle font picker on Play appear here.`,tutorial:{page:`Channels`,anchor:`brand`}},"planning.channel.brand.caption-colour":{title:`Caption colour`,body:`The subtitle text colour, as # and six hex digits such as #FFFFFF, for videos whose template sets no colour of its own. Blank leaves the template's colour alone.`,tutorial:{page:`Channels`,anchor:`brand`}},"planning.channel.brand.caption-outline":{title:`Caption outline`,body:`The colour of the line around each subtitle letter, as # and six hex digits such as #000000, for videos whose template sets none. A dark outline keeps light captions readable on bright pictures. Blank leaves the template's outline alone.`,tutorial:{page:`Channels`,anchor:`brand`}},"planning.channel.brand.font":{title:`Title font`,body:`The font of chapter cards and the end screen for videos whose template sets no title style. Not set leaves the template's font alone. Fonts you upload in the subtitle font picker on Play appear here.`,tutorial:{page:`Channels`,anchor:`brand`}},"planning.channel.brand.title-colour":{title:`Title colour`,body:`The text colour of chapter cards and the end screen, as # and six hex digits such as #FFD700, for videos whose template sets no title style. Blank leaves the template's colour alone.`,tutorial:{page:`Channels`,anchor:`brand`}},"planning.channel.brand.end-screen":{title:`End screen text`,body:`A line shown over the last 5 seconds of every video of this channel whose template sets no end screen, such as Subscribe for more. Up to 200 characters. Blank shows no end screen text.`,tutorial:{page:`Channels`,anchor:`brand`}},"planning.channel.brand.intro":{title:`Intro`,body:`An entry from Library → Intros & Outros, narrated before every video of this channel whose template has no intro. Not set adds none. It adds its own length to each video and costs one voice request, since it is narrated.`,tutorial:{page:`Channels`,anchor:`brand`}},"planning.channel.brand.outro":{title:`Outro`,body:`An entry from Library → Intros & Outros, narrated after every video of this channel whose template has no outro. Not set adds none. It adds its own length to each video and costs one voice request, since it is narrated.`,tutorial:{page:`Channels`,anchor:`brand`}},"planning.channel.brand.document-theme":{title:`Document theme`,body:`The look of the PDF document for videos of this channel whose template picks no theme: a built-in theme or one you saved. Not set leaves the template's choice alone. A saved theme that was deleted is skipped.`,tutorial:{page:`Channels`,anchor:`brand`}},"planning.channel.template-move":{title:`Move a template`,body:`Moves a template, and every schedule that runs it, to another channel. Their next runs use that channel's brand kit, cast and series brief. Projects already made keep what they were made with.`,tutorial:{page:`Channels`,anchor:`templates`}},"planning.channel.episode-memory":{title:`Episode memory`,body:`When a video of this channel finishes, one short call to its text model writes a summary of up to 150 words. A new episode about the same cast or title words gets up to 5 related summaries in its writing prompt, so it agrees with them. Videos already made never change. Default: on for new channels.`,tutorial:{page:`Channels`,anchor:`episodes-episode-memory`}},"planning.channel.episode-summary":{title:`Episode summary`,body:`What the text model wrote this episode covered. Related new episodes read it before they are written. Edit it to correct a fact; your text is kept even if the video finishes again.`,tutorial:{page:`Channels`,anchor:`episodes-episode-memory`}},"planning.channel.videos-paste":{title:`Existing video titles`,body:`Titles of videos this channel made before Slopify, one per line. Topic generation and its duplicate checks skip them, as they skip the videos made here. Titles already listed are skipped, whatever their case.`,tutorial:{page:`Channels`,anchor:`existing-videos`}},"planning.channel.videos-csv":{title:`Import a YouTube Studio CSV`,body:`In YouTube Studio open Analytics → Content → Advanced mode and export the table as a CSV. Slopify reads its titles on this machine and lists them with ticks first, so you keep only this channel's videos.`,tutorial:{page:`Channels`,anchor:`existing-videos`}},"planning.channel.videos-filter":{title:`Keep only titles containing`,body:`Ticks only the titles containing this text, in any case, such as "Egypt" or "History at Bedtime"; empty ticks them all. Use it when one Studio export holds several series. Remembered for this channel's next import.`,tutorial:{page:`Channels`,anchor:`existing-videos`}},"planning.channel.videos-ticks":{title:`Titles in the CSV`,body:`Only ticked titles are added when you press Add. Untick videos of other series in the same export, or type in Keep only titles containing to tick by text.`,tutorial:{page:`Channels`,anchor:`existing-videos`}},"planning.cast.kind":{title:`Kind`,body:`Character, creature, place or object. A generated reference picture of a character or creature is portrait (9:16), of a place or object landscape (16:9), and its starting prompt asks for the whole figure, place or object in view. It doesn't change how the member is matched.`,tutorial:{page:`Cast-Library`,anchor:`fields`}},"planning.cast.name":{title:`Name`,body:`The name matched against video titles and image briefs, as whole words, ignoring case. When it is found, this member's pictures go with that image as references. Add other spellings and plurals as aliases. Up to 200 characters.`,tutorial:{page:`Cast-Library`,anchor:`fields`}},"planning.cast.aliases":{title:`Aliases`,body:`Other names that count as this member, matched as whole words, ignoring case: Cleopatra is found in Cleopatra's palace but not in Cleopatraic. Add plurals and titles such as the Last Pharaoh. Up to 20.`,tutorial:{page:`Cast-Library`,anchor:`how-names-are-matched`}},"planning.cast.description":{title:`Description for the image model`,body:`What the member looks like, in a sentence. It goes to the image model with the member's reference pictures for every image that names it, and starts the prompt of a generated picture. Up to 2,000 characters.`,tutorial:{page:`Cast-Library`,anchor:`fields`}},"planning.cast.voice":{title:`Cast voice`,body:`How this member speaks in multi-voice runs: pick them under Speakers on Play and they read with this voice, model and pace in every episode. The list shows voices that speak the channel's language. Leave the provider empty for no voice. A run keeps the voice it started with.`,tutorial:{page:`Cast-Library`,anchor:`give-a-cast-member-a-voice`}},"planning.cast.host":{title:`Channel host`,body:`A recurring voice of this channel. When you pick Podcast or Interview on Play, the draft starts with the channel's hosts that have a voice as its hosts, so you don't add them every episode. You can still remove or add speakers on the draft. Projects already made are unchanged.`,tutorial:{page:`Cast-Library`,anchor:`make-a-member-one-of-the-channels-hosts`}},"planning.cast.pictures":{title:`Reference pictures`,body:`Up to 4 pictures per member, sent with every image whose brief, or the video's title, names it, so it looks the same each time. Upload a PNG or JPEG up to 10 MB, or generate one below. Videos already made keep the pictures they started with.`,tutorial:{page:`Cast-Library`,anchor:`add-reference-pictures`}},"planning.cast.generate":{title:`Make a reference picture`,body:`Pick an image provider and model, describe the picture, then press Generate a picture. Each press is one image call on that provider, billed at its price for one image. A plain background with the whole figure in view makes the best reference.`,tutorial:{page:`Cast-Library`,anchor:`generate-a-picture`}},"planning.cast.picture-prompt":{title:`Picture to make`,body:`The prompt for the generated reference picture. It starts from the name, the description and a request for a plain background; edit it as you like. Up to 4,000 characters.`,tutorial:{page:`Cast-Library`,anchor:`generate-a-picture`}},"planning.links.named":{title:`Named links`,body:`Write {{Name}} in a YouTube description, or ask for it in a Description prompt, and it becomes the link of that name when the description is shown, copied or downloaded, such as {{Patreon}} or {{Discord}}. Each channel keeps its own list on its Brand tab, so a project fills from its channel's links; its own {{Previous video}} wins over the channel's. A name with no link stays as typed. Save channel keeps the list.`,tutorial:{page:`YouTube-Description`,anchor:`links-in-the-description`}}},ob={"play.template":{title:`Template`,body:`Starts this video from a saved setup: prompts, voice, images, style, outputs and reviews. Picking one opens a fresh draft made from it and carries the topic you typed. No template starts from the default setup. Save a setup you like with Save as template in the right rail.`,tutorial:{page:`Play-Overview`,anchor:`template`}},"play.title":{title:`Title`,body:`The video's name, shown on the project and in Projects. Write a keyword in double braces, like {{Topic}}, and the title becomes a pattern: you type the topic per video, and Add topic queues more videos from the same setup. Up to 200 characters.`,tutorial:{page:`Play-Overview`,anchor:`title-title-pattern-and-topic`}},"play.title-pattern":{title:`Title pattern`,body:`The title with its keywords in double braces, like History: {{Topic}}. Each keyword in it is a topic you type at the top of Play, once per video, and templates save it empty. Change the pattern here; the topic values stay at the top.`,tutorial:{page:`Play-Overview`,anchor:`title-title-pattern-and-topic`}},"play.topic":{title:`Topic`,body:`What this video is about. The title names this keyword, so its value fills the title and every prompt that names it. Each video from this setup gets its own value, and a template leaves it empty. Up to 200 characters.`,tutorial:{page:`Play-Overview`,anchor:`title-title-pattern-and-topic`}},"play.keyword":{title:`Keyword`,body:`A value a picked prompt or the title asks for with {{name}}. You type it once and it fills every place that names it; the line under it lists where. Up to 200 characters. A keyword the title does not name is saved with a template.`,tutorial:{page:`Play-Overview`,anchor:`keywords`}},"play.more-videos":{title:`More videos from the same setup`,body:`Add topic queues another video with everything else the same: only its title and keywords differ. Press a chip to change that video's keywords. Start queues all of them, and they run one at a time. One Start queues at most 50 videos.`,tutorial:{page:`Play-Overview`,anchor:`more-videos-from-the-same-setup`}},"play.drafts":{title:`Drafts`,body:`Play saves every change to this draft on its own; nothing starts until you press the Play key. Drafts lists your saved setups to open again or discard. New draft starts an empty one and keeps this one in the list.`,tutorial:{page:`Play-Overview`,anchor:`drafts`}},"play.draft-conflict":{title:`Changed elsewhere`,body:`This draft was saved from another tab or window since you opened it. Reload saved draft shows that version and drops your unsaved change. Save as a new draft keeps your version as a separate draft and leaves the other one alone.`,tutorial:{page:`Play-Overview`,anchor:`when-a-draft-was-changed-elsewhere`}},"play.source.research":{title:`Research source`,body:`Generate has the text model plan chapters, research each one on the web and combine the notes before the article is written: one call to plan, one per chapter and one to combine. Provide uses notes you paste. Off, the default, writes from the prompt alone.`,tutorial:{page:`Play-Title-and-Article`,anchor:`research`}},"play.source.article":{title:`Article source`,body:`Generate has the text model write the article from the article prompt, one call. Provide narrates text you paste, word for word, with no text-model cost. The article is what the narration reads and the PDF lays out. Default: Generate.`,tutorial:{page:`Play-Title-and-Article`,anchor:`choose-where-the-article-comes-from`}},"play.source.audio":{title:`Narration source`,body:`Generate reads the article aloud with a text-to-speech voice, charged by the provider per character. Provide uses an audio file you upload, as it is. Off makes a silent video with no captions, YouTube description or shorts. Default: Generate.`,tutorial:{page:`Play-Narration`,anchor:`choose-where-the-narration-comes-from`}},"play.source.images":{title:`Images source`,body:`Generate draws images from the ticked image prompts, one image-model call each. Provide uses your own PNG, JPEG or WebP files in the order you pick them. Off turns off the video too. Default: Generate.`,tutorial:{page:`Play-Images`,anchor:`choose-where-the-images-come-from`}},"play.source.thumbnail":{title:`Thumbnail source`,body:`From prompt draws the thumbnail straight from the thumbnail prompt, one image call. Prompt by LLM first has the text model write the image prompt from yours, the title and the article, then draws it. Provide uses your own image. Default: Off.`,tutorial:{page:`Play-Outputs`,anchor:`thumbnail`}},"play.source.video":{title:`Video source`,body:`Generate renders the slideshow video on this computer from the images and narration; it costs no provider money, only time. Off leaves each finished stage to download on its own. It needs images, so it is Off while Images is Off. Default: Generate.`,tutorial:{page:`Play-Video-and-Style`,anchor:`choose-whether-to-render-a-video`}},"play.source.document":{title:`Document source`,body:`Generate lays out a PDF of the article and title on this computer, in the theme you pick. It needs no provider and costs nothing. Default: Off.`,tutorial:{page:`PDF-Documents`,anchor:`make-a-pdf`}},"play.article-prompt":{title:`Article prompt`,body:`The Library prompt the text model is sent to write the article, with its keywords filled in. A Script prompt, used when several speakers read, asks for speaker turns instead. Write or change prompts on Prompts; View prompt shows the text.`,tutorial:{page:`Play-Title-and-Article`,anchor:`generate-an-article-from-a-prompt`}},"play.provided.article":{title:`Article text`,body:`The article you paste is narrated word for word, and no text model writes one. Include everything that should be read, headings too. The count under it helps you judge the length: about 150 words is one minute of narration.`,tutorial:{page:`Play-Title-and-Article`,anchor:`paste-your-own-article`}},"play.provided.research":{title:`Research notes`,body:`Notes you paste are given to the text model with the article prompt, in place of web research. Paste facts, sources and quotes the article should draw on. Nothing is looked up.`,tutorial:{page:`Play-Title-and-Article`,anchor:`give-your-own-research-notes`}},"play.text-generation":{title:`Text generation`,body:`One text model writes everything this run needs in words: the article, research, the thumbnail's image prompt, entries set to LLM, Narration Preparation, the YouTube description and picking shorts. Each is a separate call, counted in usage. Set the default under Settings.`,tutorial:{page:`Play-Title-and-Article`,anchor:`text-generation`}},"play.llm.provider":{title:`LLM`,body:`Who runs the text model: a command-line tool you are signed in to, such as Claude Code or Codex, or a keyed service such as OpenRouter, billed per token. A greyed provider says why it cannot be used; fix it under Settings.`,tutorial:{page:`Play-Title-and-Article`,anchor:`text-generation`}},"play.llm.model":{title:`Text model`,body:`The model the provider runs for every text step. Bigger models write better and cost more per token. Refresh asks the provider for its current list; Custom ID lets you type a model the list does not show.`,tutorial:{page:`Play-Title-and-Article`,anchor:`text-generation`}},"play.llm.thinking":{title:`Thinking`,body:`How long the model reasons before it answers, for models that offer it. Higher levels can write more carefully but take longer and use more tokens. Model default leaves it to the provider.`,tutorial:{page:`Play-Title-and-Article`,anchor:`text-generation`}},"play.tts.provider":{title:`TTS`,body:`The text-to-speech service that reads the narration, charged by the provider per character of text. A greyed provider says why it cannot be used; add its key under Settings. Changing it clears the model and voice.`,tutorial:{page:`Play-Narration`,anchor:`pick-a-voice`}},"play.tts.model":{title:`TTS model`,body:`The provider's speech model. Models differ in quality, languages, speed and price per character. Some features need a particular model: Narration Preparation needs Inworld TTS-2. Refresh asks the provider for its current list.`,tutorial:{page:`Play-Narration`,anchor:`pick-a-voice`}},"play.voice":{title:`Voice`,body:`Who reads the narration. The list holds the voices you added under Settings → Voices for this provider, filtered to the project's language. With several speakers, this voice reads the intro and outro.`,tutorial:{page:`Play-Narration`,anchor:`pick-a-voice`}},"play.show-all-voices":{title:`Show all voices`,body:`The voice list hides voices listed for other languages than the project's. Tick this to pick one anyway, for example a multilingual voice whose languages are listed wrong. A voice with unknown languages is always shown.`,tutorial:{page:`Play-Narration`,anchor:`pick-a-voice`}},"play.intro":{title:`Intro`,body:`A Library entry read before the article. A text entry is read as written; an LLM entry is written by the text model for each video, one extra call. Off reads no intro. Write entries in Library → Intros & Outros.`,tutorial:{page:`Play-Narration`,anchor:`intro-and-outro`}},"play.outro":{title:`Outro`,body:`A Library entry read after the article, such as a sign-off. A text entry is read as written; an LLM entry is written by the text model for each video, one extra call. Off reads no outro.`,tutorial:{page:`Play-Narration`,anchor:`intro-and-outro`}},"play.chunking":{title:`Chunking`,body:`How the narration is split into text-to-speech requests. Whole sends it in one request; Paragraph sends one per paragraph; Every N words or characters ends each at a sentence end. Split when a provider refuses long text. Default: Whole. It changes the number of requests, not the characters charged.`,tutorial:{page:`Play-Narration`,anchor:`chunking`}},"play.chunking.count":{title:`Chunk size`,body:`How long each text-to-speech request may be. Each request ends at the last whole sentence that fits, so a single longer sentence stays whole. Defaults: 500 words or 3000 characters, spaces included.`,tutorial:{page:`Play-Narration`,anchor:`chunking`}},"play.narration-preparation":{title:`Narration Preparation`,body:`Has the text model add delivery directions and sounds, such as a sigh or a laugh, following the Library narration prompt you pick. One text-model call per narration chunk and per entry. Needs Inworld TTS-2. The article and captions stay unchanged. Default: Off.`,tutorial:{page:`Play-Narration`,anchor:`narration-preparation`}},"play.pronunciation-glossary":{title:`Pronunciation Glossary`,body:`Reads names with the IPA in the article's Pronunciation Glossary, such as Arda: /ˈɑɹdə/, with no extra text-model call. In your article prompt, ask for a glossary in slash-delimited standard-English IPA (Term: /IPA/), with an English approximation for foreign names; a line with sounds English lacks is read as plain text. Works with Inworld TTS-2 and TTS-2 Flash. The written text stays unchanged. Default: on.`,tutorial:{page:`Narration-Aliases-and-Glossary`,anchor:`the-pronunciation-glossary`}},"play.share-glossary":{title:`Pronunciations from other projects`,body:`Adds every term from your other projects' glossaries, copied when this project starts. This project's own glossary wins where they differ. Turn it off to use only this article's glossary. Default: on.`,tutorial:{page:`Narration-Aliases-and-Glossary`,anchor:`the-pronunciation-glossary`}},"play.describe-figures":{title:`Describe tables and figures`,body:`Instead of skipping tables, pictures, equations and code or reading them cell by cell, the text model writes a short spoken passage for each (a table's pattern, what a figure or equation means, what code does) and the narration says it in its place. One extra text-model call per block, in the estimate, kept for reuse. The article and PDF keep the real table; captions show what is said. Needs a text model. Default: on.`,tutorial:{page:`Play-Narration`,anchor:`tables-figures-and-code`}},"play.show-figures":{title:`Show tables and figures on screen`,body:`Each table, figure, equation and code block the narration describes is also shown in the video while it is described: the article's own picture for a figure, a card drawn in your brand kit's title font and colour for the rest. The images take turns around them, and Shorts that include one show it upright. Drawn on this computer at no cost. Needs Describe tables and figures. Default: on.`,tutorial:{page:`Play-Outputs`,anchor:`show-tables-and-figures-on-screen`}},"play.skip-code":{title:`Leave code out`,body:`Drops code blocks from the narration instead of summarising each in a sentence or two. Tables, figures and equations are still described. Default: off.`,tutorial:{page:`Play-Narration`,anchor:`tables-figures-and-code`}},"play.narration-aliases":{title:`Narration aliases`,body:`Says the words listed in Library → Aliases the way they are written there, such as Dr. as Doctor, with any generated voice. They are copied when the project starts. The article and captions keep the written words. Default: on.`,tutorial:{page:`Narration-Aliases-and-Glossary`,anchor:`use-aliases-in-a-video`}},"play.speakers.format":{title:`Speakers format`,body:`Narration uses one voice. Audiobook, Podcast, Radio drama and Interview give lines to several speakers, each with a voice. Several speakers need the text model to write or split the script. A new Podcast or Interview starts with the channel's hosts (cast members marked as hosts, with a voice).`,tutorial:{page:`Multiple-Voices`,anchor:`formats`}},"play.speakers.script":{title:`Script`,body:`Write a script has the text model write speaker turns from a Script prompt, one Name: words paragraph each. Split the article keeps the article as written and has the text model hand its narration and dialogue to the speakers, one extra call.`,tutorial:{page:`Multiple-Voices`,anchor:`the-script`}},"play.speakers.add-from-cast":{title:`Add from the cast`,body:`Adds a member of this channel's cast as a speaker, with their name and voice. Only members with a voice are listed. Edit the cast on the channel's page.`,tutorial:{page:`Multiple-Voices`,anchor:`speakers-from-a-channels-cast`}},"play.speakers.book":{title:`A chapter of a book`,body:`Makes this audiobook one chapter of a book. The MP3 and M4B are tagged with the book as their album and the chapter as their track, so a player keeps the chapters together and in order. When the chapter is done, Make the next chapter on its project page starts the next one with the same speakers and settings.`,tutorial:{page:`Multiple-Voices`,anchor:`audiobooks-in-chapters`}},"play.speakers.book-title":{title:`Book title`,body:`The book this chapter belongs to, the same for every chapter. It becomes the album of the MP3 and M4B files.`,tutorial:{page:`Multiple-Voices`,anchor:`audiobooks-in-chapters`}},"play.speakers.book-chapter":{title:`Chapter`,body:`This chapter's number in the book, from 1 to 9999. It becomes the track number of the MP3 and M4B files.`,tutorial:{page:`Multiple-Voices`,anchor:`audiobooks-in-chapters`}},"play.speakers.turn-gap":{title:`Gap between turns`,body:`The pause between one speaker's turn and the next, from 0 to 1.2 seconds. Longer feels calmer; shorter feels like a lively talk. Default: 0.35 s.`,tutorial:{page:`Multiple-Voices`,anchor:`run-wide-options`}},"play.speakers.name-tags":{title:`Speaker names on captions`,body:`Puts the speaker's name before their captions, like Ada: and their words, so viewers know who is talking. On by default for a podcast or interview.`,tutorial:{page:`Multiple-Voices`,anchor:`run-wide-options`}},"play.speakers.native-dialogue":{title:`One request for consecutive turns`,body:`Sends back-to-back turns as one multi-speaker request where the provider has one (ElevenLabs v3 with up to 10 voices, Gemini TTS with 2), so the voices react to each other. Fewer requests, same characters charged. Other providers read each turn on its own.`,tutorial:{page:`Multiple-Voices`,anchor:`run-wide-options`}},"play.speakers.audio-files":{title:`MP3 and M4B files`,body:`Also saves the narration as an MP3 and an M4B audiobook file with a chapter marker at each chapter, beside the video. Made on this computer at no provider cost.`,tutorial:{page:`Multiple-Voices`,anchor:`run-wide-options`}},"play.speaker.name":{title:`Speaker name`,body:`The name the script uses for this speaker's turns (Name: words) and the one captions and the speaker panel show. Up to 40 characters.`,tutorial:{page:`Multiple-Voices`,anchor:`speaker-options`}},"play.speaker.role":{title:`Role`,body:`What this speaker does in the format: narrator, host, guest or character. The text model is told each speaker's role when it writes or splits the script.`,tutorial:{page:`Multiple-Voices`,anchor:`speaker-options`}},"play.speaker.provider":{title:`Voice provider`,body:`The text-to-speech service for this speaker, charged per character of their lines. Speakers may use different providers. Changing it clears the model and voice.`,tutorial:{page:`Multiple-Voices`,anchor:`speaker-options`}},"play.speaker.model":{title:`Voice model`,body:`The provider's speech model for this speaker. Models differ in quality, languages and price per character. Pronunciations need an Inworld TTS-2 model.`,tutorial:{page:`Multiple-Voices`,anchor:`speaker-options`}},"play.speaker.voice":{title:`Speaker voice`,body:`This speaker's voice, from the voices you added under Settings → Voices for their provider, filtered to the project's language. Press Audition to hear it read their first line.`,tutorial:{page:`Multiple-Voices`,anchor:`speaker-options`}},"play.speaker.pace":{title:`Pace`,body:`How fast this speaker talks, from 0.8× to 1.2× of the voice's own speed. Default: Normal.`,tutorial:{page:`Multiple-Voices`,anchor:`speaker-options`}},"play.speaker.pronunciations":{title:`Speaker pronunciations`,body:`One Term: /IPA/ per line, like the article's Pronunciation Glossary, for this speaker only. Used on Inworld TTS-2 voices, ahead of the glossary. A line with sounds the language does not use is skipped and read as ordinary text.`,tutorial:{page:`Multiple-Voices`,anchor:`speaker-options`}},"play.speaker.audition":{title:`Audition`,body:`Speaks this speaker's first line in their voice so you can hear it before the run. It is one real text-to-speech request, charged by the provider at about the price shown on the button.`,tutorial:{page:`Multiple-Voices`,anchor:`speaker-options`}},"play.images.provider":{title:`Image provider`,body:`Who draws the images, the thumbnail and the shorts' pictures: a keyed service such as fal.ai, billed per image, or a command-line tool you are signed in to. A greyed provider says why it cannot be used; fix it under Settings.`,tutorial:{page:`Play-Images`,anchor:`pick-the-image-provider-and-model`}},"play.images.model":{title:`Image model`,body:`The provider's image model. Models differ in quality, speed and price per image; the estimate in the right rail shows what this run costs. Refresh asks the provider for its current list.`,tutorial:{page:`Play-Images`,anchor:`pick-the-image-provider-and-model`}},"play.images.effort":{title:`Effort`,body:`How long an image agent, such as the Codex CLI, reasons before it draws. Higher effort can follow the prompt more closely but takes longer and uses more tokens. Model default leaves it to the provider.`,tutorial:{page:`Play-Images`,anchor:`drawing-with-the-codex-cli`}},"play.image-prompts":{title:`Image prompts`,body:`Tick the Library prompts that draw the video's images, and give each a number: how many images it makes, 1 to 20. A run makes at most 60 this way. Each image is one image-model call. The images play in the order you ticked the prompts.`,tutorial:{page:`Play-Images`,anchor:`pick-the-image-prompts`}},"play.reference":{title:`Establishing image`,body:`Made first and never shown in the video. Every other image, the shorts' and, if ticked, the thumbnail is drawn with it as a reference, so characters, style and palette stay the same. From a prompt costs one more image; Upload uses yours. Changing it marks those images outdated. Default: Off.`,tutorial:{page:`Play-Images`,anchor:`establishing-image`}},"play.reference.prompt":{title:`Establishing prompt`,body:`The Library image prompt that draws the establishing image, its keywords filled like the others. Describe the characters, setting and style every other image should share.`,tutorial:{page:`Play-Images`,anchor:`establishing-image`}},"play.reference.thumbnail":{title:`Thumbnail from the establishing image`,body:`Draws the thumbnail with the establishing image as a reference too, so it matches the video. Untick it for a thumbnail drawn on its own. Default: on.`,tutorial:{page:`Play-Images`,anchor:`establishing-image`}},"play.image-scale":{title:`More images for long videos`,body:`Adds images as the narration gets longer, planned from the expected length when the run starts. The extra images are shared among the ticked prompts in order, up to 240 in all; each is one more image call. The line under it shows the count. Turning it on switches Motion from Zoom to Mix of both.`,tutorial:{page:`Play-Images`,anchor:`more-images-for-long-videos`}},"play.image-scale.rate":{title:`Image rate`,body:`Give the rate as one image every N minutes of narration (0.25 to 60) or as N images per hour (1 to 240); switching keeps the same rate. Narration runs about 150 words a minute. Starts at one image every 2 minutes.`,tutorial:{page:`Play-Images`,anchor:`more-images-for-long-videos`}},"play.image-seconds":{title:`Seconds per image`,body:`How long each image stays on screen, 1 to 600 seconds. When cuts follow the narration, it is the target and a cut waits for a sentence end. When images run out they start again. Default: 15.`,tutorial:{page:`Play-Video-and-Style`,anchor:`timing-and-motion`}},"play.zoom":{title:`Zoom`,body:`How far each image zooms in or out over its time on screen, 0 to 50 percent. 0 keeps images still. Default: 22.5 percent.`,tutorial:{page:`Play-Video-and-Style`,anchor:`timing-and-motion`}},"play.motion":{title:`Motion`,body:`How each image moves while on screen: Zoom in and out, Pan across, a Mix of both by turns, or Still. A mix keeps a long video watchable. Default: Zoom in and out.`,tutorial:{page:`Play-Video-and-Style`,anchor:`timing-and-motion`}},"play.edge-silence":{title:`Silence at start and end`,body:`Quiet time before the narration starts and after it ends, 0 to 30 seconds. Default: 2.`,tutorial:{page:`Play-Video-and-Style`,anchor:`timing-and-motion`}},"play.silence-gap":{title:`Silence between segments`,body:`Seconds of quiet between the intro and the narration, and between the narration and the outro, 0 to 30. It only matters when an intro or outro is set. Leave it empty to use the gap set in Settings, 3 seconds unless you changed it.`,tutorial:{page:`Play-Narration`,anchor:`silence-at-the-edges-and-between-segments`}},"play.format":{title:`Frame format`,body:`16:9 is a landscape video for YouTube and screens. 9:16 is a portrait video for phones. Images are drawn in this shape and captions are placed for it. Default: 16:9.`,tutorial:{page:`Play-Video-and-Style`,anchor:`frame-format`}},"play.preview-text":{title:`Preview text`,body:`The sample sentence the style preview shows in your caption font, size and position. It is only for the preview and never reaches the video; real captions come from the narration.`,tutorial:{page:`Play-Video-and-Style`,anchor:`style-preview`}},"play.thumbnail-prompt":{title:`Thumbnail prompt`,body:`The Library thumbnail prompt, keywords filled in. From prompt sends it to the image model as it is; Prompt by LLM gives it to the text model with the title and article to write the image prompt. Write prompts on Prompts.`,tutorial:{page:`Play-Outputs`,anchor:`thumbnail`}},"play.thumbnail-count":{title:`Thumbnails`,body:`Three makes two more thumbnails from the same prompt with different compositions, for YouTube's Test & compare. Each costs one more image, so 3 thumbnails are 3 image calls. You can remake each on its own on the project page. Default: 1.`,tutorial:{page:`Play-Outputs`,anchor:`make-three-thumbnails-for-test--compare`}},"play.youtube-description":{title:`YouTube description`,body:`After subtitle timing, the text model writes a description with chapters at the narration's real times, hashtags at the end, and a separate list of tags, ready to copy. One text-model call. It runs beside the render. Needs narration. Default: off.`,tutorial:{page:`YouTube-Description`,anchor:`turn-it-on`}},"play.description-prompt":{title:`Description prompt`,body:`The Library prompt the description is written from. Built-in asks for a short summary, 5 to 12 chapters, 3 to 5 hashtags and 15 to 25 tags. Write your own description prompt on Prompts to change the tone or add links.`,tutorial:{page:`YouTube-Description`,anchor:`turn-it-on`}},"play.shorts":{title:`Shorts`,body:`After subtitle timing, the text model picks the best self-contained moments of the narration. Each becomes a vertical 1080×1920 clip with new images, big word-by-word captions and its own title, description and hashtags. It runs beside the render; its images are charged like any other. Needs narration. Default: off.`,tutorial:{page:`Shorts`,anchor:`turn-on-shorts`}},"play.shorts.count":{title:`How many shorts`,body:`How many shorts to cut from this video, 1 to 10. Each needs its own new images, so more shorts cost more image calls and render time. Default: 3.`,tutorial:{page:`Shorts`,anchor:`options`}},"play.shorts.length":{title:`Short length`,body:`The shortest and longest a short may run, in seconds, between 15 and 180. The text model picks moments within these bounds. Default: 60 to 120.`,tutorial:{page:`Shorts`,anchor:`options`}},"play.shorts.prompt":{title:`Shorts prompt`,body:`The Library prompt the text model follows to pick the moments and write each short's title, description and hashtags. Built-in picks moments that make sense alone and open on a hook.`,tutorial:{page:`Shorts`,anchor:`options`}},"play.shorts.image-style":{title:`Image style`,body:`The Library image prompt the shorts' new vertical images are drawn from. Built-in draws cinematic, uncluttered images with the subject centred. Pick one of your image prompts to match the long video.`,tutorial:{page:`Shorts`,anchor:`options`}},"play.shorts.title-on-screen":{title:`Title on screen`,body:`Keeps the short's title at the top for the whole clip, large and bold in the caption font, below where the apps draw their own buttons. Default: on.`,tutorial:{page:`Shorts`,anchor:`options`}},"play.shorts.preview":{title:`Shorts preview`,body:`A few seconds of the sample project's narration and images as a short: vertical, through the same renderer your shorts use, with the big word-by-word captions in your caption font, the title on screen when it is on, and the speed you chose. It renders again by itself a moment after you change a setting, costs no API calls, and Render again forces a fresh one.`,tutorial:{page:`Shorts`,anchor:`shorts-preview`}},"play.shorts.speed":{title:`Speed`,body:`Plays each short faster than the narration, 1.00× to 1.25× in steps of 0.05, with the pitch kept. A little faster suits short-form viewers. Default: 1.00×.`,tutorial:{page:`Shorts`,anchor:`options`}},"play.shorts.music-volume":{title:`Music volume`,body:`How loud the background music plays under every short, 0 to 100 percent; it dips while the narrator speaks. Only used when you add a music file below. Default: 15.`,tutorial:{page:`Shorts`,anchor:`add-background-music`}},"play.shorts.full-video-link":{title:`Full video link`,body:`Each short's description ends with a line pointing to the full video. Paste the video's link here; without it the line says [PASTE THE FULL VIDEO LINK HERE] for you to fill in.`,tutorial:{page:`Shorts`,anchor:`options`}},"play.document-theme":{title:`Theme`,body:`How the PDF looks: a built-in theme or one of yours from Library → Documents. A theme of yours is copied into the project, so editing it later leaves this project alone until you pick it again. Edit themes opens the list.`,tutorial:{page:`PDF-Documents`,anchor:`options`}},"play.checkpoints":{title:`Review checkpoints`,body:`Holds the run before a step so you can check and edit what came before it. Steps that do not depend on it carry on. Approve each checkpoint on the project page to continue. A step must be generated to have a checkpoint.`,tutorial:{page:`Reviews-and-Checkpoints`,anchor:`add-a-checkpoint-on-play`}},"play.reviews":{title:`Automatic reviews`,body:`A reviewer model checks each finished item and saves its verdict and reasons on the project page. Flag only marks a failed item; Flag and redo makes it again, up to the redos per item, then keeps and flags it. Each review is a text-model call, counted in usage. Default: Off.`,tutorial:{page:`Reviews-and-Checkpoints`,anchor:`set-up-automatic-reviews`}},"play.reviews.provider":{title:`Reviewer`,body:`Who runs the review model. Picture reviews, for images, the thumbnail and shorts, need Claude Code or Codex, which can look at images; other providers review text only.`,tutorial:{page:`Reviews-and-Checkpoints`,anchor:`set-up-automatic-reviews`}},"play.reviews.model":{title:`Reviewer model`,body:`The model that judges each item. A stronger model catches more but costs more per review. It can differ from the model that wrote the text.`,tutorial:{page:`Reviews-and-Checkpoints`,anchor:`set-up-automatic-reviews`}},"play.reviews.retries":{title:`Redos per item`,body:`How many times Flag and redo makes a failed item again before it keeps the last one and flags it, 0 to 5. Each redo costs the item again plus one more review. Default: 2.`,tutorial:{page:`Reviews-and-Checkpoints`,anchor:`set-up-automatic-reviews`}},"play.channel":{title:`Channel`,body:`The channel this video belongs to. Its brand kit fills what this setup leaves at its default, and its cast of characters goes with the images. A draft that picks none runs in its template's channel, or the default one.`,tutorial:{page:`Play-Overview`,anchor:`channel-row`}},"play.brand-kit":{title:`Channel's brand kit`,body:`Fills what this setup leaves at its default from the channel: the caption font, intro, outro, document theme and ambient sound. What you set here wins. Turn it off to take none of it; the cast and language still apply. Default: on.`,tutorial:{page:`Play-Overview`,anchor:`channel-row`}},"play.language":{title:`Language`,body:`The language the article, narration, YouTube description and shorts titles are written in. Pick a voice that speaks it. Outside English, captions are timed with a free 248 MB model, downloaded once, where one exists. On Play, blank uses the channel's language.`,tutorial:{page:`Other-Languages`,anchor:`pick-a-language-for-one-video`}},"play.estimate":{title:`Estimated cost`,body:`What the providers are likely to charge for this run, in US dollars, from their published prices. Actual usage can differ, and the estimate does not cap spending.`,tutorial:{page:`Play-Overview`,anchor:`estimated-cost`}},"play.expected-words":{title:`Expected article words`,body:`How long you expect each generated article to be. It drives the cost estimate and how many images More images for long videos adds; the article's real length is used once it is written. About 150 words is one minute. Default: 1500.`,tutorial:{page:`Play-Overview`,anchor:`expected-article-words-per-video`}},"play.refresh-review":{title:`Refresh review`,body:`Asks the server to check the setup again and recalculate the estimate now, instead of waiting for you to pause typing. Use it after changing a prompt in the Library.`,tutorial:{page:`Play-Overview`,anchor:`review-the-whole-setup`}},"play.template-name":{title:`Template name`,body:`The name the template is listed under on Play and Templates. The template keeps this setup's settings; the topic you typed and any extra videos are left out, as the list below says.`,tutorial:{page:`Play-Overview`,anchor:`save-as-template`}},"play.queue":{title:`Video queue`,body:`Videos started together run one at a time, in this order. Pausing a project holds the queue; when one fails or is cancelled, the next one starts.`,tutorial:{page:`Play-Overview`,anchor:`the-video-queue`}},"play.voices.name":{title:`Voice name`,body:`The name you pick this voice by on Play and in Edit project. Only you see it.`,tutorial:{page:`Providers-and-Keys`,anchor:`add-a-voice`}},"play.voices.provider":{title:`Voice provider`,body:`The text-to-speech service the voice ID belongs to. Only providers set up under Settings are listed.`,tutorial:{page:`Providers-and-Keys`,anchor:`add-a-voice`}},"play.voices.voice-id":{title:`Voice ID`,body:`The provider's own id for the voice, copied from its voice library. It is not checked now; a wrong id fails when a run's narration uses it. For Google Gemini, pick one of its 30 prebuilt voices instead.`,tutorial:{page:`Providers-and-Keys`,anchor:`add-a-voice`}},"play.voices.languages":{title:`Voice languages`,body:`The languages the voice speaks, as codes such as es, de. Play lists the voice only for projects in these languages. Blank asks the provider when it can say; a voice with unknown languages is offered for every language.`,tutorial:{page:`Providers-and-Keys`,anchor:`add-a-voice`}},"play.voices.real-person":{title:`Real person`,body:`Turn this on for a voice cloned from, or made to sound like, a real person. Prepare upload then answers Yes to YouTube's AI use question for videos it narrates. An AI voice that imitates no one stays off.`,tutorial:{page:`Providers-and-Keys`,anchor:`add-a-voice`}}},sb={"project.next-chapter":{title:`Make the next chapter`,body:`Opens a new draft on Play for this book's next chapter: the same speakers and voices, channel and cast, prompts and settings, with the chapter number one higher. Write or paste the new chapter's text there, then start it. The MP3 and M4B carry the book as their album and the chapter as their track. An audiobook that is not a book yet becomes one, named after it, starting at chapter 2.`,tutorial:{page:`Multiple-Voices`,anchor:`make-the-next-chapter`}},"project.video.cuts":{title:`Cuts`,body:`Every N seconds holds each image for Seconds per image. Follow the narration cuts in the pause after a sentence, as close to that length as the sentences allow (never under 40% of it), and starts a new image at every chapter. It needs word timing, so it works in English and the languages that have it. New projects default to Follow the narration.`,tutorial:{page:`Video-Editing`,anchor:`cuts`}},"project.video.transition":{title:`Transition`,body:`How one image hands over to the next: Cut, Crossfade, Fade through black, Slide or Wipe. The change is centred on the cut and takes the length you pick (0.2 to 2 s), so the video stays exactly as long as its narration. Default: Cut, 0.6 s.`,tutorial:{page:`Video-Editing`,anchor:`cuts`}},"project.video.grade":{title:`Colour grade`,body:`A colour treatment over the whole video: Warm fantasy, Cold, Desaturated or Sepia. It is applied while the video renders, so it costs no API calls, only render time. Default: None.`,tutorial:{page:`Video-Editing`,anchor:`the-look`}},"project.video.vignette":{title:`Vignette`,body:`Darkens the corners of the picture to draw the eye to the middle. Subtle or Strong. Applied while the video renders, with no API cost. Default: Off.`,tutorial:{page:`Video-Editing`,anchor:`the-look`}},"project.video.grain":{title:`Film grain`,body:`Adds moving film grain over the whole picture for an older, filmic feel. Subtle or Strong. Applied while the video renders, with no API cost. Default: Off.`,tutorial:{page:`Video-Editing`,anchor:`the-look`}},"project.video.atmosphere":{title:`Atmosphere`,body:`An overlay Slopify draws itself: rising embers, drifting dust, or low fog along the bottom of the frame. No footage is downloaded and no API is called; it only adds render time. Default: None.`,tutorial:{page:`Video-Editing`,anchor:`the-look`}},"project.video.chapter-cards":{title:`Chapter cards`,body:`Shows each chapter's title in the middle of the picture for 2.5 seconds as the chapter starts, in the caption font. Chapters come from the YouTube description when that step runs, otherwise from the article's headings. Needs narration. Default: off.`,tutorial:{page:`Video-Editing`,anchor:`the-look`}},"project.video.animate":{title:`Animate images`,body:`Turns some images into 5-second moving clips with an image-to-video model on your image provider (fal.ai or Replicate). Chapter openers animates the first image of each chapter; Every Nth image animates every 2nd to 10th. Each clip is one paid call, shown in the estimate. An image that cannot be animated stays still. Default: Off.`,tutorial:{page:`Video-Editing`,anchor:`the-look`}},"project.pause.sentence":{title:`Pause between sentences`,body:`The least quiet after each sentence, in seconds. Some voices barely breathe between sentences; this adds silence where the pause is shorter, never shortening one or cutting a word, and the captions follow. About 0.25 s is brisk, 0.35 to 0.45 natural or documentary, 0.5 to 0.8 an audiobook's relaxed pace, 0.8 and up sleep content. Default: 0.4; 0 keeps the voice's own.`,tutorial:{page:`Editing-a-Project`,anchor:`pauses-and-volume`}},"project.pause.paragraph":{title:`Pause between paragraphs`,body:`The least quiet at the end of a paragraph, in seconds, when you want more than between sentences. Usually the narration prompt and the voice pace paragraphs well already, so it is 0 by default: paragraphs get the sentence pause. Try 0.8 to 1.2 for a slower read. A speaker's turn gap is set under Speakers instead. Runs on this computer.`,tutorial:{page:`Editing-a-Project`,anchor:`pauses-and-volume`}},"project.loudness":{title:`Level the volume`,body:`Brings every narration piece (each chunk, and each speaker's turn) to one loudness before they are joined, so the voice stops jumping between quiet and loud. Then the video, the shorts and the audio files are each set to a finished loudness. Runs on this computer, no API calls; turning it on remakes the levelled narration and the exports, never the speech. Default: on for new runs.`,tutorial:{page:`Editing-a-Project`,anchor:`pauses-and-volume`}},"project.loudness.video":{title:`Video volume`,body:`How loud the finished video and shorts are, in dB from the recommended level. LUFS is how loud a file sounds on average (the scale YouTube and Spotify use); YouTube and Spotify play everything at about -14 LUFS, so 0 dB here is -14 LUFS. -6 dB is about half as loud (50%), +4 dB about 158%. Peaks always stay under -1.5 dBTP.`,tutorial:{page:`Editing-a-Project`,anchor:`pauses-and-volume`}},"project.loudness.audio-files":{title:`Audio files volume`,body:`How loud the audio-only WAV and an audiobook's MP3 and M4B are, in dB from -18 LUFS, the level audiobook shops such as ACX ask for (-18 to -23 LUFS). LUFS is how loud a file sounds on average. Type dB or a percentage of the recommended level; peaks always stay under -3 dBTP, which those shops require.`,tutorial:{page:`Editing-a-Project`,anchor:`pauses-and-volume`}},"project.ambient.source":{title:`Ambient sound`,body:`Rain, a fireplace or wind made on this computer, or your own audio file, played quietly under the whole narration of the long video. It dips while the narrator speaks. Costs no API calls. Shorts never get it. Changing it remakes only the video. Default: None, or the channel's bed.`,tutorial:{page:`Video-Editing`,anchor:`ambient-sound`}},"project.ambient.level":{title:`Ambient level`,body:`How loud the ambient sound plays under the voice, in decibels from -40 (barely there) to -6 (close to the voice). Whole numbers only. Default: -18 dB.`,tutorial:{page:`Video-Editing`,anchor:`ambient-sound`}},"project.ambient.fade-in":{title:`Ambient fade in`,body:`How many seconds the ambient sound takes to rise from silence at the start of the video, 0 to 30 in half-second steps. Default: 3 seconds.`,tutorial:{page:`Video-Editing`,anchor:`ambient-sound`}},"project.ambient.tail":{title:`Ambient tail`,body:`How long the ambient sound keeps playing, fading out, after the narration ends: 0 to 30 seconds in half-second steps. A tail longer than the silence at the end makes the video that much longer. Default: 6 seconds.`,tutorial:{page:`Video-Editing`,anchor:`ambient-sound`}},"project.subtitles.mode":{title:`Subtitles`,body:`Off makes none. Subtitle files gives you .srt and .vtt files to upload beside the video. Burn into video draws the captions into the picture and also makes the files; it needs Video on. Captions are timed from your narration on this computer, with no paid API; the first use downloads a speech model of about 95 MB. Default: Off.`,tutorial:{page:`Video-Editing`,anchor:`subtitles`}},"project.subtitles.font":{title:`Subtitle font`,body:`The typeface of burned-in captions and chapter cards. Pick a bundled font or one you uploaded (.ttf or .otf); uploaded fonts stay available to every project. Subtitle files carry no font, since players style them. Changing it remakes only the video. Default: the bundled font.`,tutorial:{page:`Video-Editing`,anchor:`subtitles`}},"project.subtitles.size":{title:`Subtitle font size`,body:`How big burned-in captions are, from 16 to 120. Larger is easier to read on phones but covers more of the picture. Default: 48.`,tutorial:{page:`Video-Editing`,anchor:`subtitles`}},"project.subtitles.position":{title:`Subtitle position`,body:`Where burned-in captions sit on the frame: Top, Upper-middle, Center, Lower-middle or Bottom. Move them up when the pictures have important detail near the bottom. Subtitle files ignore it. Default: Bottom.`,tutorial:{page:`Video-Editing`,anchor:`subtitles`}},"project.video.style-preview":{title:`Style preview`,body:`Six seconds of the sample project's narration and images, rendered on this computer by the real video renderer with your captions, Look and motion, on the establishing image or a cast picture when there is one. The captions follow the narration word by word. It renders again by itself a moment after you change a setting. It costs no API calls, only a few seconds of your computer's time. Render again forces a fresh one.`,tutorial:{page:`Video-Editing`,anchor:`style-preview`}},"project.edit.article-text":{title:`Article text`,body:`The script the narrator reads, in Markdown. Your edits are kept when other settings change and are saved as a new revision; the narration, images and video made from the old text turn outdated and are remade when you choose. Headings become chapters.`,tutorial:{page:`Editing-a-Project`,anchor:`change-the-article-text`}},"project.edit.regenerate-article":{title:`Regenerate article after review`,body:`Marks the article to be written again by the text model, which is one or more paid text calls. Nothing runs yet: the rebuild review lists it with the narration, images and video it outdates, and you start it there. It replaces any edits you made to the article.`,tutorial:{page:`Editing-a-Project`,anchor:`regenerate-the-article`}},"project.saved-revision":{title:`Saved revision`,body:`Every save of Edit project is a revision: a snapshot of the settings and content. Continuing a run always uses the current one. Saving never starts work; outputs the change affects turn outdated and keep their old version until remade. Remaking is offered as the next action, and History lets you go back.`,tutorial:{page:`Editing-a-Project`,anchor:`history-and-saved-revisions`}},"project.choose-remake":{title:`Choose what to remake`,body:`Opens the rebuild review for every outdated or failed output: what will be made again, kept or skipped, what it costs, and which inputs changed. Nothing runs until you press Remake there, and Keep things as they are closes it with nothing spent.`,tutorial:{page:`Editing-a-Project`,anchor:`choose-what-to-remake`}},"project.prompts.template":{title:`Use saved template`,body:`Copies a prompt from your Library into this project, replacing the raw prompt below. The project keeps its own copy, so later Library edits reach it only when you pick it again or press Use the Library version. Outputs made from the old wording turn outdated; nothing is remade until you choose.`,tutorial:{page:`Editing-a-Project`,anchor:`prompts`}},"project.prompts.raw":{title:`Raw prompt`,body:`This project's own copy of the prompt, with keywords still in double braces such as {{Topic}}. Edit it to change what the model is asked for this project only; the Library prompt is untouched. Saving fills the keywords in again, and what was made from the old wording turns outdated.`,tutorial:{page:`Editing-a-Project`,anchor:`prompts`}},"project.edit.rewrite-description":{title:`Write the description again`,body:`Marks the YouTube description to be written again by the text model, one paid text call. Nothing runs yet: save, and it is remade when you continue the run or start the rebuild review. The description you have now is replaced.`,tutorial:{page:`YouTube-Description`,anchor:`write-it-again-or-turn-it-on-later`}},"project.shorts.clips":{title:`Picked clips`,body:`The moments the text model picked for your shorts, each shown by its first and last sentence. Earlier and Later move a clip's start or end by one sentence; Use my own range picks both from lists. Moving a clip costs no calls and keeps its images where the sentences stay the same. Changes apply when you save and continue the run.`,tutorial:{page:`Shorts`,anchor:`change-the-picked-moments`}},"project.shorts.range":{title:`Clip range`,body:`The first and last sentence of this short, from the narration's timed sentences. The clip must stay between the shortest and longest length you set for shorts and must not overlap another clip; the line under the clip says what to change. Back to the AI's choice restores its pick.`,tutorial:{page:`Shorts`,anchor:`change-the-picked-moments`}},"project.shorts.pick-again":{title:`Pick different moments`,body:`Asks the text model to pick new moments when you save and continue the run, one text call. Ranges you set by hand are dropped. A new clip on the same sentences as an old one keeps its images; any other clip gets new images, one image call each, and is rendered again.`,tutorial:{page:`Shorts`,anchor:`pick-new-moments-or-remake-one-short`}},"project.shorts.remake":{title:`Make this short again`,body:`Makes this one short again when you save and continue the run: its image prompts are written again, its images are drawn again (one image call each) and it is rendered again. Its moment, title and the other shorts stay as they are.`,tutorial:{page:`Shorts`,anchor:`pick-new-moments-or-remake-one-short`}},"project.images.editor":{title:`Edit images`,body:`Every image of the video in the order it is shown. You can edit a drawn image's prompt, replace any image with your own file, move it earlier or later, delete it, or add a drawn image, your own picture or a video clip. A clip plays muted in an image's place, trimmed, slowed or looped to fit. Changes apply after you save.`,tutorial:{page:`Editing-a-Project`,anchor:`edit-images`}},"project.images.prompt":{title:`Image prompt`,body:`The words this one image is drawn from, with keywords in double braces filled in from the project. Editing it outdates only this image and the video; it is drawn again, one image call, when you remake outdated outputs. Use saved wording as template copies the prompt as sent so you can edit it.`,tutorial:{page:`Editing-a-Project`,anchor:`edit-images`}},"project.images.regenerate":{title:`Regenerate image`,body:`Marks this image to be drawn again from its prompt, one paid image call, with a new result. Nothing runs yet: the image says it is marked, and Keep takes the mark off. Press Save changes, and the rebuild review lists it with the video it outdates. The current image stays until the new one is made.`,tutorial:{page:`Editing-a-Project`,anchor:`edit-images`}},"project.narration.editor":{title:`Edit narration`,body:`The narration split into the chunks it was spoken in. Edit a chunk's text, replace its audio with your own file, or have it spoken again. Only the chunks you touch are made again, paid per character, and the video is rendered again with them. Changes apply after you save.`,tutorial:{page:`Editing-a-Project`,anchor:`edit-narration`}},"project.narration.chunk-text":{title:`Narration chunk text`,body:`What the narrator says in this chunk. Editing it has this chunk spoken again by your voice provider, paid per character of the chunk, when you remake outdated outputs; the other chunks keep their audio. Captions and the video follow. It does not change the article.`,tutorial:{page:`Editing-a-Project`,anchor:`edit-narration`}},"project.narration.regenerate":{title:`Regenerate narration chunk after review`,body:`Marks this chunk to be spoken again with the same text and voice, paid per character of the chunk, for a new take when a word came out wrong. Nothing runs yet: save, and it is made again when you continue the run. The current audio stays until then.`,tutorial:{page:`Editing-a-Project`,anchor:`edit-narration`}},"project.captions.editor":{title:`Caption text and timing`,body:`Each caption's words and when it shows, in seconds from the start of the narration. Fix a misheard word or move a caption a little earlier or later; captions must not overlap and must end after they start. Edits cost nothing and only the subtitle files and the video are made again. The narration is not changed.`,tutorial:{page:`Editing-a-Project`,anchor:`edit-captions`}},"project.captions.apply":{title:`Apply caption edits to draft`,body:`Checks every caption (text present, times in order, inside the narration) and puts your edits into the project draft. Nothing is saved until you press Save changes, and the video is rendered again only when you remake outdated outputs.`,tutorial:{page:`Editing-a-Project`,anchor:`edit-captions`}},"project.youtube.summary":{title:`Summary`,body:`The opening of the YouTube description, written by the text model from the article. Edit changes it in place and keeps your text as yours: when the description is written again, your summary stays and the new one waits beside it with Use it, Keep mine and View diff. Use generated goes back to the model's text.`,tutorial:{page:`YouTube-Description`,anchor:`edit-a-part`}},"project.youtube.chapters":{title:`Chapters`,body:`Timestamped chapter lines at the narration's real times, which YouTube turns into chapters. YouTube needs the first at 0:00, at least three, each at least 10 seconds long. Edit changes them in place and your edit survives the next rewrite; Use generated goes back.`,tutorial:{page:`YouTube-Description`,anchor:`chapters-follow-youtubes-rules`}},"project.youtube.hashtags":{title:`Hashtags`,body:`The hashtags at the end of the description; YouTube shows the first three above the title. Edit changes them in place and your edit survives the next rewrite, with the new ones offered beside it. Use generated goes back to the model's.`,tutorial:{page:`YouTube-Description`,anchor:`edit-a-part`}},"project.youtube.tags":{title:`Tags`,body:`Search tags for YouTube's Tags field, which allows 500 characters in all, commas included. They are not shown to viewers. Edit changes them in place and your edit survives the next rewrite; Copy gives them comma-separated, ready to paste.`,tutorial:{page:`YouTube-Description`,anchor:`edit-a-part`}},"project.youtube.previous-video":{title:`Previous video for this project`,body:`The link that {{Previous video}} fills in this project's description, ahead of the one on its channel's Brand tab. Paste the video this one follows on from. It changes only what is shown and copied, with no text call. Save links keeps it.`,tutorial:{page:`YouTube-Description`,anchor:`previous-video`}},"project.live.writing":{title:`Live writing`,body:`The text model's words as they arrive, so you can see the article or research taking shape. When a stage makes several calls, the list picks which one to watch. Follow output keeps the newest text in view; untick it to read back. Watching costs nothing extra; the full text is saved when the stage finishes.`,tutorial:{page:`Project-Page`,anchor:`live`}},"project.checkpoints.choices":{title:`Checkpoint choices`,body:`A checkpoint holds the run before a step so you can check and edit what came before it. Tick a step that has not started to add one; untick to remove it, and work already admitted for that step carries on when ready. Pausing the project still applies. Only generated steps can have one. Save checkpoints applies the change.`,tutorial:{page:`Project-Page`,anchor:`checkpoints`}},"project.rebuild.keep-provided":{title:`Keep the provided content`,body:`This output uses a file or text you supplied, and something it depends on, such as the narration, has changed since. Tick to confirm it still fits and keep it as it is. To use something else, cancel and replace the file in Edit project first. Remake stays off until you tick it.`,tutorial:{page:`Editing-a-Project`,anchor:`choose-what-to-remake`}},"project.rebuild.unknown-costs":{title:`Unknown cost estimates`,body:`Some steps use a model with no published price, so their cost cannot be estimated and is left out of the total shown. Tick to start anyway; the real cost is recorded under Cost once they run. Remake stays off until you tick it.`,tutorial:{page:`Editing-a-Project`,anchor:`choose-what-to-remake`}},"project.cost.by-stage":{title:`Cost by stage`,body:`What each stage of this project has cost so far, from every provider call it made, retries and remakes included, priced from the model catalogue when each call finished. Failed calls are not charged here, and taxes and included credits are not counted. Stage time is how long the stage ran.`,tutorial:{page:`Costs-and-Run-Cost`,anchor:`after-a-run-the-run-cost-tab`}},"project.cost.by-model":{title:`Cost by model`,body:`The same spending split by provider and model. Cost is what you paid the provider. Calls through a signed-in command-line tool such as Claude Code or Codex cost $0 on your plan; Via API shows what the same work would cost through the provider's API, for comparison only.`,tutorial:{page:`Costs-and-Run-Cost`,anchor:`after-a-run-the-run-cost-tab`}},"project.upload.item":{title:`What to upload`,body:`Switches the list between the long video and each short, since each is uploaded to YouTube on its own with its own title, description and tags. The ticks and the Fill in YouTube Studio button follow the one you pick.`,tutorial:{page:`Publishing-to-YouTube`,anchor:`upload-a-video`}},"project.upload.real-footage":{title:`Real footage`,body:`Turn this on when the video clips you uploaded are filmed footage, not made by AI. The AI use answer then checks them: laying a Look atmosphere such as fog over real footage makes it Yes, while colour, vignette or grain count as minor edits and keep it No. It is saved with the project and changes nothing in the video.`,tutorial:{page:`Publishing-to-YouTube`,anchor:`ai-use-disclosure`}},"project.upload.steps":{title:`Upload steps`,body:`Everything YouTube Studio asks for, in the order it asks: file, title, description, thumbnail, playlist, audience, AI use and tags. Copy puts each value on the clipboard. The tick box beside each step is only a note to yourself, remembered in this browser; it changes nothing in the project.`,tutorial:{page:`Publishing-to-YouTube`,anchor:`upload-a-video`}},"project.upload.fill-studio":{title:`Fill in YouTube Studio`,body:`Opens Studio's upload page and adds this item to what waits for the Slopify Studio extension, which must be installed and paired (Settings, YouTube Studio). Each upload dialog you start is filled with the first waiting item. If Studio's dialog lacks a field, nothing is filled and the whole pack is copied instead. You check it and press Publish; Slopify never uploads or publishes.`,tutorial:{page:`Studio-Extension`,anchor:`fill-in-an-upload`}},"project.upload.queue":{title:`Waiting for Studio`,body:`The videos and shorts Fill in YouTube Studio added, oldest first, from every project. Each new upload dialog in Studio is filled with the first, which then leaves the list. It survives restarting Slopify; an item waits up to 24 hours, and a new pairing token clears the list. Remove takes an item out without filling it.`,tutorial:{page:`Studio-Extension`,anchor:`upload-several-one-after-another`}},"project.free-space":{title:`Free space`,body:`Once a project has finished, it can drop the working files it was made from (images, narration parts, subtitle timing, render settings) and keep what gets published: the video, shorts, thumbnail, article, description, document and anything you uploaded. The button says how much space that frees. Changing the project later makes those files again first, which takes time and provider credits. Settings → Storage offers the same for every project.`,tutorial:{page:`Project-Page`,anchor:`free-space`}},"project.mark-uploaded":{title:`Mark uploaded`,body:`Records that you uploaded this finished video to YouTube yourself, so it leaves the ready-to-upload lists on Home and here and shows an Uploaded badge. Slopify does not upload anything or check YouTube. Undo takes the mark off.`,tutorial:{page:`Publishing-to-YouTube`,anchor:`mark-a-video-uploaded`}},"project.edit.update-glossary":{title:`Update from other projects`,body:`Copies your other projects' Pronunciation Glossary terms into this project again, picking up any added since the last copy. The project keeps its own copy, so nothing changes until you press this. After you save, only the narration chunks whose words those terms change are spoken again, paid per character.`,tutorial:{page:`Narration-Aliases-and-Glossary`,anchor:`the-pronunciation-glossary`}},"project.edit.show-figures":{title:`Show tables and figures on screen`,body:`Shows each described table, figure, equation and code block in the video while its description is spoken, as the article's picture or a card drawn on this computer at no cost. Turning it on or off renders the video again, and any Shorts that include a card; the narration is kept. The cards appear under Images, From the article, and can be made again there.`,tutorial:{page:`Play-Outputs`,anchor:`show-tables-and-figures-on-screen`}},"project.edit.describe-figures":{title:`Describe tables and figures`,body:`The text model writes a short spoken passage for each table, figure, equation and code block, said in its place. Turning it on costs one text-model call per block, and after you save, the narration chunks that contain a block are spoken again, paid per character (the whole narration when Chunking is the whole article). Other chunks keep their audio; captions and timing are redone to match.`,tutorial:{page:`Play-Narration`,anchor:`tables-figures-and-code`}},"project.edit.update-aliases":{title:`Update from Library`,body:`Copies Library, Aliases into this project again, picking up aliases added or changed since the last copy. The project keeps its own copy, so a Library edit reaches it only when you press this. After you save, only the narration chunks the changed aliases touch are spoken again, paid per character.`,tutorial:{page:`Narration-Aliases-and-Glossary`,anchor:`use-aliases-in-a-video`}}},cb={"settings.diagnostics":{title:`Download diagnostics`,body:`Saves slopify-diagnostics.json: the Slopify version, your system and Node version, which providers are set up or found, the project count and the model catalogue's state. It never holds your keys, prompts or project content. Attach it to a bug report so the problem can be found faster.`,tutorial:{page:`Troubleshooting`,anchor:`download-diagnostics`}},"settings.autostart":{title:`Start Slopify when you log in`,body:`Slopify starts in the background when you log in to this computer, without opening a browser tab; open it from your bookmark. It uses your account's own start-up list, so no administrator password is needed, and turning it off removes exactly what it added. Default: off. In Docker, Slopify starts whenever Docker does, so this only shows Docker's own setting.`,tutorial:{page:`Start-at-Login`,anchor:`turn-it-on`}},"settings.providers.api-key":{title:`API key`,body:`The key that lets Slopify call this provider on your account; the provider bills you for what it makes. It is stored on this computer only, sent only to that provider, and never put in a backup or export. Paste a new key and Save to replace the old one.`,tutorial:{page:`Providers-and-Keys`,anchor:`add-a-key`}},"settings.providers.test-key":{title:`Test`,body:`Asks the provider whether the key works, with the cheapest harmless call it allows. A key pasted in the field is tested before you save it; with the field empty, the saved key is. Nothing is generated, billed or stored. When it fails, the answer says why: a rejected key, missing permission, no credit, or the provider being down.`,tutorial:{page:`Providers-and-Keys`,anchor:`test-a-key`}},"settings.provider.openrouter":{title:`OpenRouter`,body:`Writes the text (research, script, article, titles, descriptions) with hundreds of models from many companies through one key. Each call is charged per token from the credit you buy on OpenRouter; prices follow the model catalogue. Choose it when you want a model the command-line tools do not offer.`,tutorial:{page:`Providers-and-Keys`,anchor:`openrouter`}},"settings.provider.claude-code":{title:`Claude Code CLI`,body:`Writes the text with the Claude Code command-line tool on this computer, using your own Claude sign-in, so no API key is needed and calls count toward your Claude plan's limits instead of costing per call. Sign in first by running claude auth login in a terminal. Slopify runs up to 3 calls at once.`,tutorial:{page:`AI-CLIs`,anchor:`set-up-a-cli`}},"settings.provider.codex":{title:`Codex CLI`,body:`Writes the text with the Codex command-line tool on this computer, using your own ChatGPT sign-in, so no API key is needed and calls count toward your plan's limits instead of costing per call. Sign in first by running codex login in a terminal. Slopify runs up to 3 calls at once.`,tutorial:{page:`AI-CLIs`,anchor:`set-up-a-cli`}},"settings.provider.gemini":{title:`Gemini CLI`,body:`Writes the text with the Gemini command-line tool on this computer, using your own Google sign-in, so no API key is needed. Sign in first by running gemini in a terminal and following its login steps. Slopify runs up to 3 calls at once.`,tutorial:{page:`AI-CLIs`,anchor:`set-up-a-cli`}},"settings.provider.codex-image":{title:`Codex CLI images`,body:`Draws the images with the Codex command-line tool, using your ChatGPT sign-in instead of an API key, so images count toward your plan's limits rather than costing per image. It shares its executable path and sign-in with Codex text. Slopify draws up to 4 images at once.`,tutorial:{page:`AI-CLIs`,anchor:`codex-images`}},"settings.provider.elevenlabs":{title:`ElevenLabs`,body:`Narrates the script with ElevenLabs voices, including voices you added to your ElevenLabs account. It is billed in characters of narration from your ElevenLabs plan. A restricted key needs Text to Speech and Models read access.`,tutorial:{page:`Providers-and-Keys`,anchor:`elevenlabs`}},"settings.provider.openai-tts":{title:`OpenAI speech`,body:`Narrates the script with OpenAI's text-to-speech voices. It is billed per character or per audio minute, depending on the model, from prepaid credit on your OpenAI platform account; new accounts need at least $5 of credit before any call works.`,tutorial:{page:`Providers-and-Keys`,anchor:`openai-speech`}},"settings.provider.cartesia":{title:`Cartesia`,body:`Narrates the script with Cartesia voices, billed in characters from your Cartesia plan. The free plan needs no card, so it is an easy way to try narration.`,tutorial:{page:`Providers-and-Keys`,anchor:`cartesia`}},"settings.provider.inworld":{title:`Inworld`,body:`Narrates the script with Inworld voices, billed per character from your Inworld account. Paste the Base64 credentials of a Standard key exactly as shown; Realtime-only keys do not work.`,tutorial:{page:`Providers-and-Keys`,anchor:`inworld`}},"settings.provider.system-voice":{title:`System voice`,body:`Narrates with the speech your computer already has: macOS voices, Windows voices, or on Linux Piper, SVOX Pico or eSpeak NG. No key, no account and no charge, but it sounds robotic next to ElevenLabs or OpenAI. On Linux, install espeak-ng if nothing is found. Its models are the speech programs Slopify found; add one of their voices in Settings → Voices.`,tutorial:{page:`Providers-and-Keys`,anchor:`the-system-voice`}},"settings.provider.google-tts":{title:`Google Gemini voices`,body:`Narrates with Gemini's 30 prebuilt voices, billed to your Gemini API key per text and audio token. It uses the key saved for Google images unless you save one here. Two speakers' consecutive turns can go in one request (see Speakers on Play).`,tutorial:{page:`Providers-and-Keys`,anchor:`google-gemini-speech`}},"settings.provider.fal":{title:`fal.ai`,body:`Draws the images and thumbnails with the image models fal.ai hosts, charged per image from prepaid credit. fal.ai locks the account when the balance runs out, so a run stops at the images step until you add credit.`,tutorial:{page:`Providers-and-Keys`,anchor:`falai`}},"settings.provider.replicate":{title:`Replicate`,body:`Draws the images and thumbnails with the image models Replicate hosts, charged per image or per second of compute from credit you buy up front.`,tutorial:{page:`Providers-and-Keys`,anchor:`replicate`}},"settings.provider.openai-image":{title:`OpenAI images`,body:`Draws the images and thumbnails with OpenAI's GPT Image models, charged per image from prepaid credit on your OpenAI platform account. GPT Image may also need Verify Organization on the OpenAI platform before it works.`,tutorial:{page:`Providers-and-Keys`,anchor:`openai-images`}},"settings.provider.google-image":{title:`Google images`,body:`Draws the images and thumbnails with Google's Gemini image models, charged per image. Use a key made in Google AI Studio on a project with billing set up; Gemini image models are not on the free tier.`,tutorial:{page:`Providers-and-Keys`,anchor:`google`}},"settings.cli.path":{title:`Executable path`,body:`Where the command-line tool is on this computer. Leave it blank and Slopify finds it on PATH, the list of folders your terminal searches. Set an absolute path, without quotes or arguments, when the tool is installed somewhere else or you have more than one copy. Save checks the tool answers.`,tutorial:{page:`AI-CLIs`,anchor:`set-the-executable-path`}},"settings.cli.managed-on-host":{title:`Managed on host`,body:`Slopify runs in Docker, so this tool runs on your computer outside the container, with the sign-in it already has there. Its path cannot be changed here. After you install, update or remove a command-line tool, run the Docker launcher again so Slopify sees the change.`,tutorial:{page:`AI-CLIs`,anchor:`in-docker-the-host-helper`}},"settings.health":{title:`Health check`,body:`Asks each command-line tool whether it is signed in, makes the cheapest harmless call each saved key allows (nothing is generated or billed), and checks that the models your templates, schedules, drafts and projects use are still offered and answer for your key. Run it after changing a key or when a run stops at a provider; Check again on a provider's row checks that one alone.`,tutorial:{page:`Providers-and-Keys`,anchor:`check-all-providers`}},"settings.models.catalogue":{title:`Model catalogue`,body:`The list of models, prices and retirements the pickers and cost estimates use. Slopify checks the published catalogue and OpenRouter's live list when it starts and once a day; Check now does it at once. New models appear and prices update; nothing you made changes. Your own edits to the local file are kept.`,tutorial:{page:`Models`,anchor:`what-the-catalogue-covers`}},"settings.models.replace":{title:`Replace with published file`,body:`Overwrites the local catalogue file with the published one, dropping any edits you made to it. The previous file is saved beside it first, so you can copy your edits back. Use it when the local file is broken or you want the published list exactly.`,tutorial:{page:`Models`,anchor:`replace-the-local-file-with-the-published-one`}},"settings.models.retired":{title:`Retired models in use`,body:`Templates, schedules, drafts and projects with steps still to run that pick a model the provider no longer offers. A run that reaches one stops and says so. Switch replaces only that one model choice with the suggestion shown; Switch all does every one that has a suggestion.`,tutorial:{page:`Models`,anchor:`switch-away-from-a-retired-model`}},"settings.playback.silence-gap":{title:`Silence between segments`,body:`Seconds of quiet between the intro and the narration, and between the narration and the outro, in every new video, unless Play sets a different gap for one video. It only matters when an intro or outro is set; 0 runs them together. Default: 3 seconds, from 0 to 30. Videos already started keep their own gap.`,tutorial:{page:`Settings-Reference`,anchor:`silence-between-segments`}},"settings.loudness":{title:`Level the volume for new runs`,body:`Whether a new run on Play (and a template or quick short) starts with Level the volume on, and at which volumes. On evens out every narration piece and sets the video to about -14 LUFS, the loudness YouTube plays at, and the audio files to -18 LUFS. A project keeps what it started with; change it there in Edit project. Default: on.`,tutorial:{page:`Settings-Reference`,anchor:`level-the-volume-for-new-runs`}},"settings.appearance":{title:`Appearance`,body:`Light or dark colours for Slopify on this computer. System follows your operating system's setting and changes with it. Default: System. It changes at once and does not affect your videos.`,tutorial:{page:`Settings-Reference`,anchor:`appearance`}},"settings.notifications":{title:`Notifications`,body:`Slopify tells you when a run finishes, fails, or stops to wait for your review, and when an automatic review kept an item flagged and needs your decision. The message holds the project title, what happened and a link to the project, never your keys. Browser notifications need a Slopify tab open; a Notification URL works with none open.`,tutorial:{page:`Notifications`,anchor:`when-slopify-notifies-you`}},"settings.notifications.browser":{title:`Browser notifications`,body:`Shows a notification from this browser while any Slopify tab is open, even in the background. Turning it on asks the browser's permission. It applies to this browser only, so turn it on in each browser you use. Default: off.`,tutorial:{page:`Notifications`,anchor:`turn-on-browser-notifications`}},"settings.notifications.url":{title:`Notification URL`,body:`An address Slopify POSTs a short plain-text message to, with no tab open. For your phone, install the ntfy app, subscribe to a topic with a long random name, and paste https://ntfy.sh/that-topic. Any address that accepts a POST works. Each message is sent once, with a 5 second timeout. Leave it empty to turn it off.`,tutorial:{page:`Notifications`,anchor:`get-notifications-on-your-phone-notification-url`}},"settings.studio.extension":{title:`Upload pack and extension`,body:`Slopify never uploads or publishes. A finished project's Prepare upload lists everything Studio asks for, with Copy buttons. The optional Slopify Studio browser extension fills Studio's upload dialog from that pack; you still press Publish. Install it from Install the Studio extension below: Download, three steps, then pair it with the token.`,tutorial:{page:`Studio-Extension`,anchor:`get-the-extension`}},"settings.studio.playlist":{title:`Playlist`,body:`The YouTube playlist an upload pack names, so the extension ticks it in Studio's dialog. Pick Every channel for the default, or a channel to give it its own; a channel without its own uses the default. Type it exactly as it is called in Studio, up to 150 characters. Empty means no playlist (for a channel: the default). Default: empty.`,tutorial:{page:`Studio-Extension`,anchor:`settings--youtube-studio`}},"settings.studio.install":{title:`Install the Studio extension`,body:`The extension comes with Slopify: Download saves it for the browser picked, nothing is fetched from a store. Chrome, Edge and Brave load the unzipped folder with Load unpacked (Developer mode); Firefox 128 or newer loads the zip as a temporary add-on, which it forgets on restart. Then pair it with the token above. A new Slopify may bring a new extension: download and load it again after updating.`,tutorial:{page:`Studio-Extension`,anchor:`get-the-extension`}},"settings.studio.pairing":{title:`Extension pairing token`,body:`A secret the Slopify Studio extension needs before it may read your upload packs, so no other page can. Copy it into the extension's options and press Pair. New pairing token makes a fresh one and unpairs the extension until you paste the new token.`,tutorial:{page:`Studio-Extension`,anchor:`pair-it-with-slopify`}},"settings.storage.export":{title:`Export and import`,body:`Export everything saves every project with its files and history, your library, templates, schedules, Play drafts, fonts, settings and usage in one .tar file; never provider keys. Import adds to this install and replaces nothing: projects already here are skipped, taken names arrive as “(imported)” and schedules arrive paused. Running projects must finish or pause first.`,tutorial:{page:`Where-Your-Files-Live`,anchor:`export-and-import`}},"settings.storage.clean":{title:`Clean orphan files`,body:`Deletes files in the projects folder that no project records any more, and uploaded files that no draft, template or project uses. Your projects, outputs and library are never touched. Slopify also does this each time it starts; use it after a crash or to free space now.`,tutorial:{page:`Where-Your-Files-Live`,anchor:`clean-orphan-files`}},"settings.storage.disk":{title:`Disk space`,body:`What Slopify stores on this computer: project files (outputs plus the working files they were made from), staged uploads, and deleted projects still in the trash. Deleted projects free their space when the trash removes them after 30 days, or when you choose Delete now.`,tutorial:{page:`Where-Your-Files-Live`,anchor:`disk-space`}},"settings.storage.keep-outputs":{title:`Keep outputs only`,body:`On a finished project, deletes the working files it was made from (images, narration parts, subtitle timing, render settings) and keeps the video, shorts, thumbnail, article, description, document and your uploads. Changing the project later makes those files again first, which takes time and provider credits.`,tutorial:{page:`Where-Your-Files-Live`,anchor:`keep-outputs-only`}},"settings.sample.restore":{title:`Sample projects`,body:`The finished examples that come with Slopify: a narrated video, an audiobook and a podcast, which you can look through without spending anything. Restore samples adds back any that were deleted and replaces the others with the originals. Your own copies of them are not touched.`,tutorial:{page:`Where-Your-Files-Live`,anchor:`sample-projects`}},"settings.files":{title:`Your files`,body:`Your projects, automatic backups and exports live here; new installs use Documents/Slopify. The database, settings, keys and logs stay in Slopify's hidden data folder. Moving copies every file, checks each copy by size and checksum, then switches, and keeps the old folder until you delete it. It takes as long as copying your projects and cannot start while a project is being made.`,tutorial:{page:`Where-Your-Files-Live`,anchor:`see-your-files`}},"settings.files.docker":{title:`Your files`,body:`Your projects and backups are in the folders Docker shares with this computer. The container cannot move its own folders, so run the command shown on the computer running Docker: the installer waits for running work, copies your projects, checks the copy and remounts the new folder.`,tutorial:{page:`Where-Your-Files-Live`,anchor:`see-your-files`}},"settings.files.new-folder":{title:`New folder`,body:`The full path of the folder your files move to, on another disk or a synced folder for example. Slopify makes Projects and Backups inside it. It must be empty or not exist yet. The move needs as much free space there as your projects take now.`,tutorial:{page:`Where-Your-Files-Live`,anchor:`move-your-files-to-another-folder`}},"settings.backups":{title:`Daily backup`,body:`Once a day Slopify writes the file Export everything makes into the backup folder and deletes its own oldest backups beyond the number you keep. Nothing else there is touched. A backup waits while projects are being made; if Slopify was off at the time, it backs up a couple of minutes after it starts. Each backup can be many gigabytes.`,tutorial:{page:`Backups`,anchor:`turn-on-daily-backups`}},"settings.backups.auto":{title:`Back up automatically`,body:`Turns the daily backup on or off. Default: off, because each backup holds every project's video and can fill a disk. Back up now works either way. Press Save after changing it.`,tutorial:{page:`Backups`,anchor:`turn-on-daily-backups`}},"settings.backups.time":{title:`Time of day`,body:`When the daily backup runs, in this browser's time zone. Pick a time the computer is usually on and idle; a backup waits for running projects. Default: 03:00.`,tutorial:{page:`Backups`,anchor:`when-the-daily-backup-runs`}},"settings.backups.keep":{title:`Keep last`,body:`How many of Slopify's own backups stay in the folder; after a new one is written, the oldest beyond this number are deleted. Each holds everything, so disk use grows with this number. Default: 5, from 1 to 30.`,tutorial:{page:`Backups`,anchor:`turn-on-daily-backups`}},"settings.backups.folder":{title:`Backup folder`,body:`Where backups are written. Leave it empty to use the Backups folder beside your projects (Documents/Slopify/Backups on a new install), which moves with them. Point it at another disk or a synced folder to keep copies away from this disk. Slopify only ever deletes its own backup files there.`,tutorial:{page:`Backups`,anchor:`where-the-files-go-and-what-they-are-called`}},"settings.trash":{title:`Trash`,body:`Deleted projects, prompts, intros and outros, templates and schedules stay here for 30 days, then are removed for good along with a project's files. Restore puts one back; if its name was taken meanwhile it comes back renamed, and a schedule comes back paused. Delete now frees the space at once.`,tutorial:{page:`Trash`}},"settings.patch-notes":{title:`Patch notes`,body:`What changed in each version of Slopify. The newest notes are open here; older versions are folded under Earlier versions, and each opens when you pick it. They ship with the app, so they work offline. After an update, the new version's notes open by themselves once; a fresh install skips that. On a major update the What's new tour shows instead and links here.`,tutorial:{page:`Updating-and-Patch-Notes`,anchor:`read-the-patch-notes`}},"settings.whats-new":{title:`What's new in this version`,body:`Opens the patch notes for the version you are running, in Settings, Patch notes. When this version has no notes of its own, it opens the newest ones instead.`,tutorial:{page:`Updating-and-Patch-Notes`,anchor:`whats-new-tour-on-a-major-update`}},"settings.updates":{title:`Updates`,body:`The circular-arrows button at the foot of the sidebar (at the top on a phone) checks for a newer Slopify and installs it. A dot on it means an update is ready. If a video is being made, the update waits until it finishes, and you can cancel it meanwhile. Slopify restarts itself and this page reconnects.`,tutorial:{page:`Updating-and-Patch-Notes`,anchor:`update-from-the-app`}},"home.channel":{title:`Channel`,body:`Shows Home and the other screens for one channel, or for all of them. It only filters what you see: projects, schedules and costs of other channels keep running. Slopify remembers the choice in this browser.`,tutorial:{page:`Channels`,anchor:`show-one-channels-work`}},"home.needs-you":{title:`Needs you`,body:`Runs held at a review before a step, topics a schedule suggested for you to accept or reject, and runs that failed with the fix to try. Nothing here moves on until you act; approving a review from here lets that run continue.`,tutorial:{page:`Home-and-Projects`,anchor:`needs-you`}},"home.running":{title:`Running now`,body:`Videos being made or paused, with the step each is on and how long it has taken. Up to 3 show here; Projects lists them all. Open one to follow it live, pause it or cancel it.`,tutorial:{page:`Home-and-Projects`,anchor:`running-now`}},"home.coming-up":{title:`Coming up`,body:`The schedule runs due in the next 7 days, with the template and topic each will use. Paused schedules show too. Plan or move runs on the calendar.`,tutorial:{page:`Home-and-Projects`,anchor:`coming-up`}},"home.ready":{title:`Ready to upload`,body:`Finished videos you have not marked uploaded. Prepare upload lists everything YouTube Studio asks for, with Copy buttons; Slopify never uploads for you. Mark uploaded takes the video off this list; Projects still has it.`,tutorial:{page:`Home-and-Projects`,anchor:`ready-to-upload`}},"home.this-week":{title:`This week`,body:`Videos made since Monday and what their provider calls cost. Calls billed to a command-line plan cost nothing per call, so the API figure says what they would have cost with API keys. The bars show how much of each plan's weekly limit is used, from the tool's last reading.`,tutorial:{page:`Home-and-Projects`,anchor:`this-week`}},"welcome.samples":{title:`Samples`,body:`Finished projects that come with Slopify: a narrated video, an audiobook and a podcast. They are read-only, so nothing you try on them costs anything; Make my own copy on a sample's page gives you one to edit.`,tutorial:{page:`First-Launch-and-Welcome`,anchor:`explore-the-samples`}},"welcome.found":{title:`Found on this computer`,body:`Claude Code, Codex and Gemini CLI write the text with your own sign-in, so no API key is needed for it, and Codex also draws the images. The narration uses a voice key (OpenAI, ElevenLabs, Cartesia or Inworld) when one is saved in Settings → Providers, and otherwise your computer's built-in voice, so no key is needed to start.`,tutorial:{page:`First-Launch-and-Welcome`,anchor:`found-on-this-computer`}},"welcome.voice":{title:`Narration voice`,body:`Who reads the script aloud. With a voice key saved (OpenAI, ElevenLabs, Cartesia or Inworld), that provider narrates. Without one, your computer's own speech does it for free: macOS or Windows voices, or eSpeak NG on Linux. It sounds robotic, so add a key in Settings → Providers when you want a better voice.`,tutorial:{page:`First-Launch-and-Welcome`,anchor:`narration-voice`}},"welcome.short":{title:`Make a 60-second short`,body:`Slopify writes a script of about 150 words, narrates it, draws four vertical images and renders a captioned 9:16 short, usually in about five minutes with the command-line tools. The narration uses your voice provider's credit, or nothing with the built-in voice; text and images through a command-line tool count toward its plan.`,tutorial:{page:`First-Launch-and-Welcome`,anchor:`step-3-make-a-60-second-short`}},"welcome.topic":{title:`Topic`,body:`What the short is about, in a few words or a question, up to 200 characters. Slopify writes the script from it without a research step, to keep the first short quick, so a specific topic gives a sharper short than a broad one.`,tutorial:{page:`First-Launch-and-Welcome`,anchor:`step-3-make-a-60-second-short`}},"welcome.pack":{title:`Style`,body:`The starter pack whose prompts, voice and art direction the short uses. General is a neutral explainer style. Making the short with a pack adds its prompts and suggested voice to your library; Add to library also adds its template for Play.`,tutorial:{page:`First-Launch-and-Welcome`,anchor:`step-2-pick-a-style`}},"welcome.packs":{title:`Starter packs`,body:`Each pack adds prompts, a suggested voice and a Play template for one kind of channel, so you can pick the template on Play, type a topic and go. Adding a pack twice changes nothing, and it never replaces a prompt or template of yours with the same name.`,tutorial:{page:`First-Launch-and-Welcome`,anchor:`starter-packs`}}},lb={...ob,...sb,...ib,...ab,...cb};function ub(e,t){let n=lb[e];if(t===void 0)return n;let r=e=>e.replace(/\{(\w+)\}/g,(e,n)=>t[n]??e);return{...n,title:r(n.title),body:r(n.body)}}function db(e){return e.replace(/!?\[([^\]]*)\]\([^)]*\)/g,`$1`).replace(/`([^`]*)`/g,`$1`).replace(/(\*\*|__)(.+?)\1/g,`$2`).replace(/(^|[^\p{L}\p{N}])[*_]([^*_]+)[*_](?![\p{L}\p{N}])/gu,`$1$2`).replace(/<[^>]+>/g,``).trim()}function fb(e){return e.toLowerCase().replace(/[^\p{L}\p{N}\p{M} _-]/gu,``).replace(/ /g,`-`)}var pb=`/help/tutorials`;function mb(e,t){return`${pb}/${encodeURIComponent(e)}${t?`#${t}`:``}`}function hb(e,t,n){return e.replace(/\]\(([A-Za-z0-9][A-Za-z0-9-]*)?(?:#([^)\s]*))?\)/g,(e,r,i)=>{if(r===void 0&&i===void 0)return e;let a=r??n;return t.has(a)?`](${mb(a,i)})`:e})}function gb(e){let t=/^\s*#\s+(.+?)\s*#*\s*(?:\n|$)/.exec(e);return t===null?{title:void 0,body:e}:{title:t[1],body:e.slice(t[0].length)}}function _b(e){let t=/^\/help\/tutorials\/([^/#?]+)(?:#(.*))?$/.exec(e);if(t===null)return;let n=t[2];return{page:decodeURIComponent(t[1]??``),anchor:n===void 0||n===``?void 0:decodeURIComponent(n)}}function vb(e,t,n=[]){let r=new Map;for(let e of n){let t=fb(db(e));r.set(t,(r.get(t)??0)+1)}for(let n of e.querySelectorAll(`h1, h2, h3, h4, h5, h6`)){let e=fb((n.textContent??``).trim()),i=r.get(e)??0;if(r.set(e,i+1),(i===0?e:`${e}-${String(i)}`)===t)return n}}var yb=Iee,bb=Ree,xb=Lee,Sb=Vee;function Cb({className:e,align:t=`start`,sideOffset:n=6,...r}){return(0,h.jsx)(zee,{children:(0,h.jsx)(Bee,{"data-slot":`popover-content`,align:t,sideOffset:n,collisionPadding:12,className:I(`z-50 w-[min(340px,calc(100vw-24px))] rounded-control border border-line bg-raised p-3 text-small text-ink-2`,`shadow-[var(--shadow-pop)] outline-hidden`,e),...r})})}function B({id:e,label:t,vars:n,className:r}){let i=ub(e,n);return(0,h.jsxs)(yb,{children:[(0,h.jsx)(bb,{type:`button`,"aria-label":`About ${t??i.title}`,"data-help-id":e,className:I(`inline-flex size-6 shrink-0 items-center justify-center rounded-full text-ink-3 hover:bg-raised hover:text-ink`,r),children:(0,h.jsx)(yc,{"aria-hidden":`true`,className:`size-[15px]`})}),(0,h.jsxs)(Cb,{className:`space-y-2 leading-[1.45]`,children:[(0,h.jsx)(`p`,{className:`m-0 font-semibold text-ink`,children:i.title}),i.body.split(`
50
50
 
51
51
  `).map(e=>(0,h.jsx)(`p`,{className:`m-0`,children:e},e)),i.tutorial===void 0?null:(0,h.jsx)(wb,{tutorial:i.tutorial})]})]})}function wb({tutorial:e}){let t=hi({warn:!1}),n=`sl-link inline-flex items-center gap-1 text-small`,r=(0,h.jsxs)(h.Fragment,{children:[`Learn more`,(0,h.jsx)($s,{"aria-hidden":`true`,className:`size-[13px]`})]});return t?(0,h.jsx)(Sb,{asChild:!0,children:(0,h.jsx)(pa,{to:`/help/tutorials/$page`,params:{page:e.page},...e.anchor===void 0?{}:{hash:e.anchor},className:n,children:r})}):(0,h.jsx)(`a`,{href:mb(e.page,e.anchor),className:n,children:r})}var Tb={"data-help-scope":``};function V({title:e,kicker:t,meta:n,info:r,infoLabel:i=e,as:a=`h2`,size:o=a===`h3`?`small`:`default`,id:s,status:c,className:l,children:u}){return(0,h.jsxs)(`div`,{className:I(`sl-section-head`,l),"data-slot":`section-head`,children:[(0,h.jsxs)(`div`,{className:`min-w-0`,children:[t===void 0?null:(0,h.jsx)(`div`,{className:`sl-kicker`,children:t}),(0,h.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,h.jsx)(a,{id:s,className:I(`sl-section-head__title`,o===`small`&&`text-title-3`),children:e}),r===void 0?null:(0,h.jsx)(B,{id:r,label:i}),c]}),n===void 0?null:(0,h.jsx)(`p`,{className:`sl-section-head__meta`,children:n})]}),u===void 0?null:(0,h.jsx)(`div`,{className:`sl-btn-row min-w-0 shrink-0 justify-end max-md:shrink max-md:justify-start`,children:u})]})}function Eb({checked:e,onChange:t,label:n,disabled:r,className:i,describedBy:a,tip:o,tipLabel:s}){let c=(0,h.jsxs)(`button`,{type:`button`,role:`switch`,"aria-checked":e,"aria-describedby":a,disabled:r,onClick:()=>t(!e),className:I(`sl-switch`,i),children:[(0,h.jsx)(`span`,{className:`sl-switch__track`,"aria-hidden":`true`}),(0,h.jsx)(`span`,{children:n})]});return o===void 0?c:(0,h.jsxs)(`span`,{className:`inline-flex max-w-full items-center gap-1`,...Tb,children:[c,(0,h.jsx)(B,{id:o,label:s??(typeof n==`string`?n:void 0)})]})}function Db({value:e,options:t,onChange:n,label:r,className:i,tip:a}){let o=(0,m.useRef)(null),s=(0,h.jsx)(`div`,{ref:o,role:`group`,"aria-label":r,onKeyDown:r=>{if(r.key!==`ArrowRight`&&r.key!==`ArrowLeft`)return;let i=t.filter(e=>!e.disabled),a=i[(i.findIndex(t=>t.value===e)+(r.key===`ArrowRight`?1:-1)+i.length)%i.length];a!==void 0&&(r.preventDefault(),n(a.value),o.current?.querySelector(`[data-value="${CSS.escape(a.value)}"]`)?.focus())},className:I(`sl-seg`,i),children:t.map(t=>(0,h.jsx)(`button`,{type:`button`,"data-value":t.value,"aria-pressed":t.value===e,tabIndex:t.value===e?0:-1,disabled:t.disabled,onClick:()=>n(t.value),className:`sl-seg__opt`,children:t.label},t.value))});return a===void 0?s:(0,h.jsxs)(`span`,{className:`inline-flex max-w-full items-center gap-1`,...Tb,children:[s,(0,h.jsx)(B,{id:a,label:r})]})}var Ob=[`settings`,`autostart`],kb=(e,t=``)=>`${e.origin}/api/settings/autostart${t}`;async function Ab(e){return P(await e.fetch(kb(e)))}async function jb(e,t){return P(await e.fetch(kb(e),{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({enabled:t})}))}async function Mb(e){return P(await e.fetch(kb(e,`/answer`),{method:`POST`}))}var Nb=`Start Slopify when I log in`;function Pb(e){let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString()}function Fb(){let{api:e}=R(),t=_();return{view:M({queryKey:Ob,queryFn:()=>Ab(e)}),turn:N({mutationFn:t=>jb(e,t),onSuccess:e=>t.setQueryData(Ob,e)}),decline:N({mutationFn:()=>Mb(e),onSuccess:e=>t.setQueryData(Ob,e)})}}function Ib(){let{view:e,turn:t}=Fb(),n=e.data;return(0,h.jsxs)(`div`,{...Tb,children:[(0,h.jsx)(V,{title:Nb,info:`settings.autostart`}),e.error===null?null:(0,h.jsxs)(`p`,{role:`alert`,className:`m-0 mb-3 text-body text-danger`,children:[`Starting at login couldn't be checked: `,e.error.message]}),n===void 0?e.error===null?(0,h.jsx)(`p`,{role:`status`,className:`m-0 text-ink-2`,children:`Checking…`}):null:n.kind===`docker`?(0,h.jsx)(Lb,{view:n}):(0,h.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,h.jsx)(Eb,{label:Nb,checked:n.enabled===!0,disabled:!n.available||t.isPending,describedBy:`autostart-summary`,onChange:e=>t.mutate(e)}),(0,h.jsxs)(`p`,{id:`autostart-summary`,className:`m-0 text-small text-ink-2`,children:[n.summary,n.enabled===!0&&n.where!==null?` Login entry: ${n.where}`:``]}),t.error===null?null:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-small text-danger`,children:t.error.message})]})]})}function Lb({view:e}){return(0,h.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,h.jsx)(`p`,{className:`m-0 text-body`,children:(0,h.jsx)(`span`,{className:`font-semibold`,children:e.enabled===!0?`Starts with Docker: yes`:e.enabled===!1?`Starts with Docker: no`:`Starts with Docker: unknown`})}),(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:e.summary}),e.howTo===null?null:(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:e.howTo}),e.checkedAt===null?null:(0,h.jsxs)(`p`,{className:`m-0 text-small text-ink-2`,children:[`Checked by the installer on `,Pb(e.checkedAt),`.`]})]})}function Rb(){let{view:e,turn:t,decline:n}=Fb();if(t.isSuccess&&e.data?.enabled===!0)return(0,h.jsx)(`p`,{role:`status`,className:`m-0 text-small text-ink-2`,children:`Slopify now starts when you log in. Change it any time in Settings → General.`});if(e.data?.kind===`docker`)return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(V,{title:Nb,info:`settings.autostart`}),(0,h.jsx)(`div`,{className:`mb-6`,children:(0,h.jsx)(Lb,{view:e.data})})]});if(e.data?.offer!==!0)return null;let r=t.error??n.error;return(0,h.jsxs)(`section`,{children:[(0,h.jsx)(V,{title:Nb,info:`settings.autostart`}),(0,h.jsx)(`p`,{className:`m-0 mb-3 text-small text-ink-2`,children:`Have Slopify ready whenever you open your bookmark, without starting it from a terminal.`}),(0,h.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,h.jsx)(L,{variant:`primary`,disabled:t.isPending||n.isPending,onClick:()=>t.mutate(!0),children:`Start when I log in`}),(0,h.jsx)(L,{variant:`quiet`,disabled:t.isPending||n.isPending,onClick:()=>n.mutate(),children:`No thanks`})]}),r===null?null:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 mt-3 text-small text-danger`,children:r.message})]})}function zb(){let{api:e}=R(),t=za({select:e=>e.pathname}),{view:n,turn:r,decline:i}=Fb(),a=M(Yy(e)),o=M({queryKey:jy,queryFn:()=>Fy(e)}),s=n.data?.offer===!0&&a.data?.seen===!0&&o.data?.show===!1&&t!==`/welcome`,c=r.isPending||i.isPending,l=r.error??i.error;return(0,h.jsx)(ky,{open:s,onOpenChange:e=>{!e&&!c&&i.mutate()},title:`Start Slopify when you log in?`,description:`Have Slopify ready whenever you open your bookmark, without starting it from a terminal. Change it any time in Settings → General.`,footer:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(L,{variant:`secondary`,disabled:c,onClick:()=>i.mutate(),children:`No thanks`}),(0,h.jsx)(L,{variant:`primary`,autoFocus:!0,disabled:c,onClick:()=>r.mutate(!0),children:`Start when I log in`})]}),children:l===null?null:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-small text-danger`,children:l.message})})}function Bb(){let{api:e}=R(),t=M({queryKey:Ob,queryFn:()=>Ab(e),retry:!1,staleTime:1/0}).data?.kind;(0,m.useEffect)(()=>{t!==void 0&&po(t)},[t])}var Vb=`00000000-0000-4000-8000-000000000001`,Hb=[`character`,`creature`,`place`,`object`],Ub={character:`Character`,creature:`Creature`,place:`Place`,object:`Object`},Wb=[`channels`],Gb=e=>[`channels`,e],Kb=e=>`${e.origin}/api/channels`,qb=(e,t)=>({method:e,headers:{"content-type":`application/json`},body:JSON.stringify(t)});function Jb(e){return lt({queryKey:Wb,queryFn:async()=>(await P(await e.fetch(Kb(e)))).channels})}function Yb(e,t){return lt({queryKey:Gb(t),queryFn:async()=>P(await e.fetch(`${Kb(e)}/${t}`)),refetchInterval:e=>e.state.data?.cast.some(e=>e.images.some(e=>e.state===`generating`))?3e3:!1})}async function Xb(e,t,n){return P(await e.fetch(Kb(e),qb(`POST`,{id:t,name:n})))}async function Zb(e,t,n){return P(await e.fetch(`${Kb(e)}/${t}`,qb(`PUT`,n)))}async function Qb(e,t){let n=await e.fetch(`${Kb(e)}/${t}`,{method:`DELETE`});n.ok||await P(n)}async function $b(e,t,n,r){return P(await e.fetch(`${Kb(e)}/${t}/cast`,qb(`POST`,{id:n,...r})))}async function ex(e,t,n){return P(await e.fetch(`${Kb(e)}/cast/${t}`,qb(`PUT`,n)))}async function tx(e,t){let n=await e.fetch(`${Kb(e)}/cast/${t}`,{method:`DELETE`});n.ok||await P(n)}async function nx(e,t,n){return P(await e.fetch(`${Kb(e)}/cast/${t}/images`,{method:`POST`,headers:{"content-type":n.type||`application/octet-stream`},body:n}))}async function rx(e,t,n){return P(await e.fetch(`${Kb(e)}/cast/${t}/generate`,qb(`POST`,n)))}async function ix(e,t,n){let r=await e.fetch(`${Kb(e)}/cast/${t}/images/${n}`,{method:`DELETE`});r.ok||await P(r)}async function ax(e,t,n){await P(await e.fetch(`${Kb(e)}/templates/${t}`,qb(`PUT`,{channelId:n})))}async function ox(e,t,n){return P(await e.fetch(`${Kb(e)}/${t}/ai-disclosure`,qb(`PUT`,{aiDisclosure:n})))}function sx(e,t){return`${Kb(e)}/pictures/${t}`}var cx=`slopify.channel`,lx=(0,m.createContext)(void 0);function ux(){try{let e=window.localStorage.getItem(cx);return e===null||e===``?null:e}catch{return null}}function dx({children:e}){let{api:t}=R(),n=M(Jb(t)),[r,i]=(0,m.useState)(ux),a=n.data??[],o=r!==null&&n.data!==void 0&&!a.some(e=>e.id===r)?null:r,s=(0,m.useCallback)(e=>{i(e);try{e===null?window.localStorage.removeItem(cx):window.localStorage.setItem(cx,e)}catch{}},[]),c=(0,m.useMemo)(()=>({channelId:o,channel:a.find(e=>e.id===o),channels:a,setChannelId:s,includes:e=>o===null||e===o}),[o,a,s]);return(0,h.jsx)(lx,{value:c,children:e})}var fx={channelId:null,channel:void 0,channels:[],setChannelId:()=>{},includes:()=>!0};function px(){return(0,m.useContext)(lx)??fx}function mx({className:e}){let t=px(),n=(0,m.useId)();return(0,h.jsxs)(`div`,{className:I(`flex flex-col gap-1`,e),...Tb,children:[(0,h.jsxs)(`span`,{className:`flex items-center gap-1 px-2`,children:[(0,h.jsx)(`label`,{htmlFor:n,className:`sl-kicker`,children:`Channel`}),(0,h.jsx)(B,{id:`planning.channel.current`,className:`-my-1`})]}),(0,h.jsxs)(`select`,{id:n,className:`sl-select`,value:t.channelId??``,onChange:e=>t.setChannelId(e.target.value===``?null:e.target.value),children:[(0,h.jsx)(`option`,{value:``,children:`All channels`}),t.channels.map(e=>(0,h.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]})}var hx=class{commands=new Map;listeners=new Set;version=0;snapshot=[];register(e){return this.commands.set(e.id,e),this.changed(),()=>{this.commands.get(e.id)===e&&(this.commands.delete(e.id),this.changed())}}list(){return this.snapshot}subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)});getSnapshot=()=>this.version;changed(){this.version+=1,this.snapshot=[...this.commands.values()];for(let e of this.listeners)e()}},gx=(0,m.createContext)(void 0);function _x(e){let t=(0,m.useContext)(gx),n=(0,m.useRef)(e);n.current=e;let{id:r,title:i,group:a,context:o,searchOnly:s}=e,c=e.keywords?.join(`\0`),l=e.shortcut?.join(`\0`),u=e.numbered!==void 0,d=t?.registry;(0,m.useEffect)(()=>{if(d===void 0)return;let{icon:e}=n.current;return d.register({id:r,title:i,group:a,...o===void 0?{}:{context:o},...c===void 0?{}:{keywords:c.split(`\0`)},...e===void 0?{}:{icon:e},...l===void 0?{}:{shortcut:l.split(`\0`)},...u?{numbered:e=>n.current.numbered?.(e)??i}:{},...s===!0?{searchOnly:!0}:{},run:e=>n.current.run(e)})},[d,r,i,a,o,c,l,u,s])}function vx(e,t){let n=[`/`];return _x({id:`list.search`,title:`Search ${t}`,group:`This page`,keywords:[`find`,`filter`],shortcut:n,run:()=>{e.current?.focus(),e.current?.select()}}),n}function yx(){return(0,m.useContext)(gx)??{open:!1,setOpen:bx}}function bx(){}function xx(e,t){let n=e.trim().toLowerCase();if(n===``)return 0;let r=t.toLowerCase(),i=0,a=0,o=-2;for(let e of n){if(e===` `)continue;let t=r.indexOf(e,a);if(t===-1)return null;i+=1,t===o+1&&(i+=3),(t===0||/[\s\-_:/.]/.test(r[t-1]??``))&&(i+=4),i-=Math.min(t-a,5)*.1,o=t,a=t+1}return r.startsWith(n)||r.includes(` ${n}`)?i+=6:r.includes(n)&&(i+=3),i}function Sx(e){return[{text:e.title,bonus:2},...e.context===void 0?[]:[{text:e.context,bonus:1}],...(e.keywords??[]).map(e=>({text:e,bonus:0})),{text:e.group,bonus:0}]}function Cx(e,t,n){let r=null;for(let i of t){let t=xx(e,i.text);if(t===null)continue;let a=n&&i.text.toLowerCase().split(/[\s\-_:/.,&]+/).includes(e)?4:0,o=t+i.bonus+a;(r===null||o>r)&&(r=o)}return r}function wx(e,t){if(e.length===0)return 0;let n=Cx(e.join(` `),t,!1);if(e.length===1)return n;let r=0;for(let i of e){let e=Cx(i,t,!0);if(e===null)return n;r+=e}return n===null?r:Math.max(n,r)}function Tx(e,t){let n=t.trim()===``,r=t.trim().toLowerCase().split(/\s+/).filter(Boolean),i=r.find(e=>/^\d+$/.test(e)),a=[];return e.forEach((e,t)=>{if(n&&e.searchOnly===!0)return;let o=e.numbered;if(o!==void 0&&i!==void 0){let n=Number(i),s=r.indexOf(i),c=wx([...r.slice(0,s),...r.slice(s+1)],Sx(e));c!==null&&a.push({command:{...e,title:o(n),run:()=>e.run(n)},score:c,order:t});return}let s=wx(r,Sx(e));s!==null&&a.push({command:e,score:s,order:t})}),a.sort((e,t)=>{let r=Number(t.command.context!==void 0)-Number(e.command.context!==void 0);return n?r===0?e.order-t.order:r:t.score-e.score||r||e.order-t.order}),a.map(e=>e.command)}var Ex=new Set([`Ctrl`,`Alt`,`Shift`]);function Dx(e){return{mod:e.includes(`Ctrl`),alt:e.includes(`Alt`),shift:e.includes(`Shift`),keys:e.filter(e=>!Ex.has(e)).map(e=>e.toLowerCase())}}var Ox=e=>!e.mod&&!e.alt&&!e.shift&&e.keys.length>1;function kx(e){if(e===void 0)return;let t=Dx(e);if(Ox(t)||t.keys.length!==1)return;let n=e.at(-1)??``,r=[...t.alt?[`Alt`]:[],...t.shift?[`Shift`]:[],n].join(`+`);return t.mod?`Control+${r} Meta+${r}`:r}function Ax(e,t,n){return e.mod!==(n.ctrlKey||n.metaKey)||e.alt!==n.altKey||/^[a-z0-9]$/.test(t)&&e.shift!==n.shiftKey?!1:n.key.toLowerCase()===t}function jx(e){return e instanceof HTMLElement?e.isContentEditable||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement?!0:e instanceof HTMLInputElement&&![`checkbox`,`radio`,`button`,`submit`,`reset`,`range`,`color`,`file`].includes(e.type):!1}var Mx=()=>document.querySelector(`[role="dialog"][data-state="open"], [role="alertdialog"]`)!==null;function Nx(e){return e.map((e,t)=>({command:e,order:t})).filter(e=>e.command.shortcut!==void 0).sort((e,t)=>Number(t.command.context!==void 0)-Number(e.command.context!==void 0)||t.order-e.order).map(e=>e.command)}var Px=1500;function Fx({children:e,registry:t}){let[n]=(0,m.useState)(()=>t??new hx),[r,i]=(0,m.useState)(!1),[a,o]=(0,m.useState)(!1),s=(0,m.useRef)(!1);s.current=r,(0,m.useEffect)(()=>n.register({id:`help.shortcuts`,title:`Show keyboard shortcuts`,group:`Help`,keywords:[`keys`,`keyboard`,`hotkeys`,`help`],shortcut:[`?`],run:()=>o(!0)}),[n]),(0,m.useEffect)(()=>{let e,t=t=>{if((t.ctrlKey||t.metaKey)&&!t.altKey&&t.key.toLowerCase()===`k`){t.preventDefault(),i(e=>!e);return}if(t.defaultPrevented||t.isComposing||s.current||Mx())return;let r=jx(t.target),a=Nx(n.list()),o=t.key.toLowerCase(),c=!t.ctrlKey&&!t.metaKey&&!t.altKey,l=n=>{t.preventDefault(),e=void 0,n.run()};if(e!==void 0&&c&&!r&&t.timeStamp-e.at<Px){let t=e.key,n=a.find(e=>{let n=Dx(e.shortcut??[]);return Ox(n)&&n.keys[0]===t&&n.keys[1]===o});if(n!==void 0)return l(n)}e=void 0;let u=a.find(e=>{let n=Dx(e.shortcut??[]);return Ox(n)||n.keys.length!==1||r&&!n.mod?!1:Ax(n,n.keys[0]??``,t)});if(u!==void 0)return l(u);c&&!r&&!t.shiftKey&&a.some(e=>{let t=Dx(e.shortcut??[]);return Ox(t)&&t.keys[0]===o})&&(e={key:o,at:t.timeStamp})};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[n]);let c=(0,m.useMemo)(()=>({registry:n,open:r,setOpen:i}),[n,r]);return(0,h.jsxs)(gx.Provider,{value:c,children:[e,(0,h.jsx)(Rx,{}),(0,h.jsx)(Lx,{registry:n,open:a,onOpenChange:o})]})}function Ix({shortcut:e}){let t=Ox(Dx(e));return(0,h.jsx)(`span`,{className:`sl-kbd`,children:e.map((e,n)=>(0,h.jsxs)(m.Fragment,{children:[t&&n>0?(0,h.jsx)(`span`,{className:`text-caption text-ink-3`,children:`then`}):null,(0,h.jsx)(`kbd`,{children:e})]},e))})}function Lx({registry:e,open:t,onOpenChange:n}){(0,m.useSyncExternalStore)(e.subscribe,e.getSnapshot,e.getSnapshot);let r=new Set,i=Nx(e.list()).filter(e=>{let t=e.shortcut?.join(`+`)??``;return!r.has(t)&&(r.add(t),!0)}).toSorted((e,t)=>e.group.localeCompare(t.group)||e.title.localeCompare(t.title));return(0,h.jsx)(ky,{open:t,onOpenChange:n,title:`Keyboard shortcuts`,description:`Ctrl works as Cmd on a Mac. Keys without Ctrl wait while you type in a field. A screen's own shortcuts are listed while it is open.`,children:(0,h.jsx)(`dl`,{className:`m-0 grid grid-cols-[auto_1fr] items-center gap-x-4 gap-y-2 text-small`,children:[{keys:[`Ctrl`,`K`],title:`Search or run a command`},{keys:[`Esc`],title:`Close a dialog, a drawer or the palette`},...i.map(e=>({keys:e.shortcut??[],title:e.title}))].map(e=>(0,h.jsxs)(m.Fragment,{children:[(0,h.jsx)(`dt`,{children:(0,h.jsx)(Ix,{shortcut:e.keys})}),(0,h.jsx)(`dd`,{className:`m-0 min-w-0`,children:e.title})]},e.keys.join(`+`)))})})}function Rx(){let e=(0,m.useContext)(gx);return e===void 0?null:(0,h.jsx)(hm,{open:e.open,onOpenChange:e.setOpen,children:(0,h.jsxs)(vm,{children:[(0,h.jsx)(bm,{className:`sl-overlay`}),(0,h.jsxs)(wm,{className:`sl-overlay-content sl-palette sl-enter`,"aria-describedby":void 0,children:[(0,h.jsx)(Em,{className:`sr-only`,children:`Command palette`}),(0,h.jsx)(zx,{registry:e.registry,close:()=>e.setOpen(!1)})]})]})})}function zx({registry:e,close:t}){(0,m.useSyncExternalStore)(e.subscribe,e.getSnapshot,e.getSnapshot);let n=e.list(),[r,i]=(0,m.useState)(``),[a,o]=(0,m.useState)(0),s=(0,m.useId)(),c=(0,m.useMemo)(()=>Tx(n,r),[n,r]),l=Math.min(a,Math.max(0,c.length-1)),u=(0,m.useRef)(null),d=(0,m.useMemo)(()=>{let e=new Map;return c.forEach((t,n)=>{let r=e.get(t.group)??[];r.push({command:t,index:n}),e.set(t.group,r)}),[...e.entries()]},[c]),f=e=>`${s}-option-${String(e)}`;(0,m.useEffect)(()=>{u.current?.querySelector(`[data-index="${String(l)}"]`)?.scrollIntoView?.({block:`nearest`})},[l]);let p=(0,m.useCallback)(e=>{e!==void 0&&(t(),e.run())},[t]);return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`div`,{className:`sl-palette__input`,children:[(0,h.jsx)(Nc,{"aria-hidden":`true`,strokeWidth:1.75}),(0,h.jsx)(`input`,{autoFocus:!0,role:`combobox`,"aria-expanded":`true`,"aria-controls":s,"aria-autocomplete":`list`,"aria-activedescendant":c.length===0?void 0:f(l),"aria-label":`Search or run a command`,placeholder:`Search or run a command`,value:r,onChange:e=>{i(e.target.value),o(0)},onKeyDown:e=>{e.key===`ArrowDown`?(e.preventDefault(),o(c.length===0?0:(l+1)%c.length)):e.key===`ArrowUp`?(e.preventDefault(),o(c.length===0?0:(l-1+c.length)%c.length)):e.key===`Home`?(e.preventDefault(),o(0)):e.key===`End`?(e.preventDefault(),o(Math.max(0,c.length-1))):e.key===`Enter`&&(e.preventDefault(),p(c[l]))}}),(0,h.jsx)(`span`,{className:`sl-kbd`,"aria-hidden":`true`,children:(0,h.jsx)(`kbd`,{children:`Esc`})})]}),(0,h.jsx)(`div`,{ref:u,id:s,role:`listbox`,"aria-label":`Commands`,className:`sl-palette__list`,children:c.length===0?(0,h.jsx)(`p`,{className:`sl-palette__empty`,children:n.length===0?`No commands here yet.`:`Nothing matches "${r.trim()}". Try fewer letters or another word.`}):d.map(([e,t])=>(0,h.jsxs)(`div`,{role:`group`,"aria-label":e,className:`sl-palette__group`,children:[(0,h.jsx)(`div`,{className:`sl-kicker px-[10px] pb-1`,"aria-hidden":`true`,children:e}),t.map(({command:e,index:t})=>(0,h.jsxs)(`div`,{id:f(t),"data-index":t,role:`option`,tabIndex:-1,"aria-selected":t===l,className:`sl-palette__item`,onMouseMove:()=>{t!==l&&o(t)},onClick:()=>p(e),children:[e.icon,(0,h.jsx)(`span`,{className:`min-w-0 truncate`,children:e.title}),e.context===void 0?null:(0,h.jsx)(`span`,{className:`sl-palette__meta`,children:e.context}),e.shortcut===void 0?null:(0,h.jsx)(Ix,{shortcut:e.shortcut})]},e.id))]},e))})]})}var Bx=1e4,Vx={newSchedule:`schedules.new`,addToCalendar:`calendar.add`,showImages:e=>`project.${e}.show-images`,regenerateImage:e=>`project.${e}.regenerate-image`},Hx=new Map,Ux=new Set;function Wx(e,t){Hx.set(e,{value:t,at:Date.now()});for(let e of Ux)e()}function Gx(e){let t=Hx.get(e);return Hx.delete(e),t===void 0||Date.now()-t.at>Bx?void 0:t}function Kx(e,t,n=!0){let r=(0,m.useRef)(t);r.current=t,(0,m.useEffect)(()=>{if(!n)return;let t=()=>{if(!Hx.has(e))return;let t=Gx(e);t!==void 0&&r.current(t.value)};return t(),Ux.add(t),()=>{Ux.delete(t)}},[e,n])}function qx(){let{api:e}=R(),t=M(Ky(e)),n=za({select:e=>e.pathname}),r=za({select:e=>e.pathname===`/calendar`&&e.search.tab===`schedules`}),i=/^\/projects\/([^/]+)/.exec(n)?.[1];return(0,h.jsxs)(h.Fragment,{children:[r?null:(0,h.jsx)(Jx,{}),n===`/calendar`?null:(0,h.jsx)(Yx,{}),(t.data?.projects??[]).filter(e=>e.id!==i).map(e=>(0,h.jsx)(Xx,{project:e},e.id))]})}function Jx(){let e=Xi();return _x({id:`global.schedules.new`,title:`New schedule`,group:`Create`,keywords:[`schedule`,`recurring`,`calendar`,`plan`],searchOnly:!0,run:()=>{Wx(Vx.newSchedule),e({to:`/calendar`,search:{tab:`schedules`}})}}),null}function Yx(){let e=Xi();return _x({id:`global.calendar.add`,title:`Add to calendar`,group:`Create`,keywords:[`schedule`,`topics`,`batch`,`queue`,`plan`],searchOnly:!0,run:()=>{Wx(Vx.addToCalendar),e({to:`/calendar`})}}),null}function Xx({project:e}){let t=Xi(),n=()=>{t({to:`/projects/$projectId`,params:{projectId:e.id}})};return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(Zx,{project:e,open:n}),e.config.sources.images===`off`?null:(0,h.jsx)(Qx,{project:e,open:n})]})}function Zx({project:e,open:t}){return _x({id:`index.open.${e.id}`,title:`Open ${e.title}`,group:`Projects`,keywords:[`project`,`go`],searchOnly:!0,run:t}),null}function Qx({project:e,open:t}){return _x({id:`index.image.${e.id}`,title:`Regenerate an image in ${e.title}`,numbered:t=>`Regenerate image ${String(t)} in ${e.title}`,group:`Projects`,keywords:[`image`,`picture`,`redraw`,`remake`],searchOnly:!0,run:n=>{Wx(Vx.showImages(e.id)),n!==void 0&&Wx(Vx.regenerateImage(e.id),n),t()}}),null}var $x=`data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%20role='img'%20aria-label='Buy%20Me%20a%20Coffee'%3e%3cpath%20fill='currentColor'%20fill-rule='evenodd'%20d='M3.4%207.6h13.1v2.1a3.9%203.9%200%200%201%200%207.6v.2a3.6%203.6%200%200%201-3.6%203.6H7a3.6%203.6%200%200%201-3.6-3.6zm13.1%204.3v3.2a1.7%201.7%200%200%200%200-3.2zM6.2%202.1a.9.9%200%200%201%201.8%200v2.6a.9.9%200%200%201-1.8%200zm3.6%200a.9.9%200%200%201%201.8%200v2.6a.9.9%200%200%201-1.8%200zm3.6%200a.9.9%200%200%201%201.8%200v2.6a.9.9%200%200%201-1.8%200z'/%3e%3c/svg%3e`,eS=`data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%20fill='none'%20stroke='%23000'%20stroke-width='2'%20stroke-linecap='round'%20stroke-linejoin='round'%20role='img'%20aria-label='GitHub'%3e%3cpath%20d='M15%2022v-4a4.8%204.8%200%200%200-1-3.5c3%200%206-2%206-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35%200-3.5%200%200-1%200-3%201.5-2.64-.5-5.36-.5-8%200C6%202%205%202%205%202c-.3%201.15-.3%202.35%200%203.5A5.403%205.403%200%200%200%204%209c0%203.5%203%205.5%206%205.5-.39.49-.68%201.05-.85%201.65-.17.6-.22%201.23-.15%201.85v4'/%3e%3cpath%20d='M9%2018c-4.51%202-5-2-7-2'/%3e%3c/svg%3e`,tS=`data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%20role='img'%20aria-label='Patreon'%3e%3cpath%20fill='currentColor'%20d='M2.5%202.2h4.3v19.6H2.5z'/%3e%3ccircle%20fill='currentColor'%20cx='15.2'%20cy='9.4'%20r='6.9'/%3e%3c/svg%3e`,nS={research:`data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%20fill='none'%20stroke='currentColor'%20stroke-width='2'%20stroke-linecap='round'%20stroke-linejoin='round'%20role='img'%20aria-label='research'%3e%3ccircle%20cx='10.5'%20cy='10.5'%20r='6.5'/%3e%3cpath%20d='M15.5%2015.5%2021%2021'/%3e%3c/svg%3e`,article:`data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%20fill='none'%20stroke='currentColor'%20stroke-width='2'%20stroke-linecap='round'%20stroke-linejoin='round'%20role='img'%20aria-label='article'%3e%3cpath%20d='M6%203h8l4%204v14H6z'/%3e%3cpath%20d='M14%203v4h4'/%3e%3cpath%20d='M9%2011h6'/%3e%3cpath%20d='M9%2014h6'/%3e%3cpath%20d='M9%2017h4'/%3e%3c/svg%3e`,audio:`data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%20fill='none'%20stroke='currentColor'%20stroke-width='2'%20stroke-linecap='round'%20stroke-linejoin='round'%20role='img'%20aria-label='audio'%3e%3cpath%20d='M4%2010v4'/%3e%3cpath%20d='M8%207v10'/%3e%3cpath%20d='M12%204v16'/%3e%3cpath%20d='M16%208v8'/%3e%3cpath%20d='M20%2011v2'/%3e%3c/svg%3e`,images:`data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%20fill='none'%20stroke='currentColor'%20stroke-width='2'%20stroke-linecap='round'%20stroke-linejoin='round'%20role='img'%20aria-label='images'%3e%3crect%20x='3'%20y='4'%20width='18'%20height='16'%20rx='2'/%3e%3ccircle%20cx='8.5'%20cy='9'%20r='1.5'/%3e%3cpath%20d='M21%2016l-4.5-4.5L7%2020'/%3e%3c/svg%3e`,thumbnail:`data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%20fill='none'%20stroke='currentColor'%20stroke-width='2'%20stroke-linecap='round'%20stroke-linejoin='round'%20role='img'%20aria-label='thumbnail'%3e%3crect%20x='3'%20y='4'%20width='18'%20height='16'%20rx='2'/%3e%3cpath%20d='M10%209v6l5-3z'/%3e%3c/svg%3e`,video:`data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%20fill='none'%20stroke='currentColor'%20stroke-width='2'%20stroke-linecap='round'%20stroke-linejoin='round'%20role='img'%20aria-label='video'%3e%3crect%20x='3'%20y='5'%20width='18'%20height='14'%20rx='2'/%3e%3cpath%20d='M7%205v14'/%3e%3cpath%20d='M17%205v14'/%3e%3cpath%20d='M3%209.5h4M3%2014.5h4M17%209.5h4M17%2014.5h4'/%3e%3c/svg%3e`,document:`data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%20fill='none'%20stroke='currentColor'%20stroke-width='2'%20stroke-linecap='round'%20stroke-linejoin='round'%20role='img'%20aria-label='document'%3e%3cpath%20d='M8%203h7l4%204v11H8z'/%3e%3cpath%20d='M15%203v4h4'/%3e%3cpath%20d='M5%207v14h11'/%3e%3cpath%20d='M11%2012h5'/%3e%3cpath%20d='M11%2015h3'/%3e%3c/svg%3e`};function rS(e){return{maskImage:`url("${e}")`,maskSize:`contain`,maskRepeat:`no-repeat`,maskPosition:`center`}}function iS({kind:e,className:t}){return(0,h.jsx)(`span`,{"aria-hidden":`true`,"data-glyph":e,className:I(`block size-[22px] shrink-0 bg-current`,t),style:rS(nS[e])})}var aS={github:eS,patreon:tS,coffee:$x};function oS({name:e,className:t}){return(0,h.jsx)(`span`,{"aria-hidden":`true`,"data-glyph":e,className:I(`block size-[14px] shrink-0 bg-current`,t),style:rS(aS[e])})}function sS({variant:e=`secondary`,size:t=`default`,className:n,...r}){return(0,h.jsx)(`a`,{"data-slot":`button-link`,className:I(Sy({variant:e,size:t}),n),...r})}function cS({className:e,...t}){return(0,h.jsx)(`a`,{"data-slot":`text-link`,className:I(`sl-link`,e),...t})}var lS=fa(sS),uS=fa(cS);function dS({href:e,...t}){return(0,h.jsx)(sS,{href:e,...t})}function fS({href:e,label:t,tip:n,...r}){return(0,h.jsx)(sS,{href:e,variant:`icon`,"aria-label":t,"data-tip":n??t,...r})}function pS({tone:e,className:t}){return(0,h.jsx)(`span`,{"aria-hidden":`true`,"data-tone":e,className:I(`sl-lamp`,e!==`off`&&`sl-lamp--${e}`,t)})}function mS({tone:e,children:t,className:n}){let r=e===`done`?`running`:e;return(0,h.jsxs)(`span`,{"data-slot":`status`,className:I(`sl-status`,r!==`off`&&`sl-status--${r}`,n),children:[(0,h.jsx)(pS,{tone:e}),t]})}function hS({tone:e=`neutral`,className:t,...n}){return(0,h.jsx)(`span`,{"data-slot":`badge`,className:I(`sl-badge`,e!==`neutral`&&`sl-badge--${e}`,t),...n})}function gS({children:e,onRemove:t,removeLabel:n,className:r}){return(0,h.jsxs)(`span`,{"data-slot":`chip`,className:I(`sl-chip`,r),children:[e,t===void 0?null:(0,h.jsx)(`button`,{type:`button`,"aria-label":n??`Remove`,onClick:t,className:`-mr-1 inline-flex size-5 items-center justify-center rounded-control text-ink-2 hover:bg-raised hover:text-ink`,children:(0,h.jsx)(Vc,{"aria-hidden":`true`,className:`size-[14px]`,strokeWidth:1.75})})]})}function _S({className:e}){return(0,h.jsx)(`svg`,{viewBox:`0 0 256 256`,"aria-hidden":`true`,focusable:`false`,className:e,children:(0,h.jsx)(`path`,{fill:`currentColor`,fillRule:`evenodd`,d:`M 62 28 C 100 46, 118 60, 140 66 C 150 68, 152 80, 164 84 L 232 120 L 216 132 C 214.0 134.3, 208.3 141.7, 204.0 146.0 C 199.7 150.3, 194.0 154.7, 190.0 158.0 C 186.0 161.3, 182.3 162.3, 180.0 166.0 C 177.7 169.7, 176.3 175.0, 176.0 180.0 C 175.7 185.0, 179.0 191.0, 178.0 196.0 C 177.0 201.0, 174.0 207.3, 170.0 210.0 C 166.0 212.7, 158.0 213.7, 154.0 212.0 C 150.0 210.3, 147.3 204.3, 146.0 200.0 C 144.7 195.7, 147.0 189.7, 146.0 186.0 C 145.0 182.3, 143.0 178.7, 140.0 178.0 C 137.0 177.3, 131.3 179.0, 128.0 182.0 C 124.7 185.0, 121.3 190.7, 120.0 196.0 C 118.7 201.3, 121.3 208.0, 120.0 214.0 C 118.7 220.0, 115.7 228.3, 112.0 232.0 C 108.3 235.7, 102.3 237.0, 98.0 236.0 C 93.7 235.0, 88.3 230.7, 86.0 226.0 C 83.7 221.3, 84.0 213.3, 84.0 208.0 C 84.0 202.7, 86.7 197.3, 86.0 194.0 C 85.3 190.7, 82.7 187.7, 80.0 188.0 C 77.3 188.3, 72.7 193.3, 70.0 196.0 C 67.3 198.7, 65.3 202.3, 64.0 204.0 C 62.7 205.7, 62.3 205.7, 62.0 206.0 Q 56 118, 62 28 Z M 100 84 L 170 122 L 100 160 Z`})})}var vS=[`Tokens in and out per stage, with provider and model`,`Audio seconds per segment`,`Images made`,`Thumbnails made`,`Videos rendered`,`PDF documents made`,`YouTube descriptions written`,`Shorts made`,`Projects created`,`That this machine installed Slopify`,`The time each of those happened`],yS=[`API keys`,`Prompt bodies`,`Keyword values`,`Titles`,`Article or research text`,`Files and filenames`,`OS, locale, hardware`];function bS(){let{api:e}=R(),t=_(),n=M(Yy(e)),r=N({mutationFn:()=>Ho(e),onSuccess:e=>{t.setQueryData(z.notice,e)}}),i=n.data?.seen===!1,a=n.data?.appVersion;return(0,h.jsxs)(ky,{open:i,dismissible:!1,title:`Anonymous usage stats`,description:`These numbers power the live counters on slopify.stream.`,footer:(0,h.jsx)(L,{autoFocus:!0,variant:`primary`,disabled:r.isPending,onClick:()=>{r.mutate()},children:`Got it`}),children:[(0,h.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,h.jsx)(xS,{heading:`Tracked`,items:vS}),(0,h.jsx)(xS,{heading:`Never tracked`,items:yS})]}),(0,h.jsx)(`p`,{className:`text-small text-ink-2`,children:`Every event carries a random ID of its own and this machine's random ID, and nothing else. Nothing you write, upload, or paste ever leaves your machine.`}),a===void 0?null:(0,h.jsx)(`p`,{className:`engraved text-ink-3`,children:`Slopify ${a} · this version is included in each report`}),r.error===null?null:(0,h.jsx)(`p`,{role:`alert`,className:`text-small text-danger`,children:r.error.message})]})}function xS({heading:e,items:t}){let n=`notice-${e.replace(/\s+/g,`-`).toLowerCase()}`;return(0,h.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,h.jsx)(`p`,{id:n,className:`engraved border-b border-line pb-1 text-ink-3`,children:e}),(0,h.jsx)(`ul`,{"aria-labelledby":n,className:`m-0 flex list-none flex-col gap-2 p-0 text-small`,children:t.map(e=>(0,h.jsx)(`li`,{children:e},e))})]})}function SS(e,t){if(t===`system`){e.removeAttribute(`data-theme`);return}e.setAttribute(`data-theme`,t)}function CS(){let{api:e}=R(),t=M(rb(e)).data?.appearance??`system`;return(0,m.useEffect)(()=>{SS(document.documentElement,t)},[t]),null}function wS({reload:e}){let{version:t}=R(),n=(0,m.useSyncExternalStore)(t.subscribe,t.staleAt,t.staleAt);return(0,h.jsx)(ky,{open:n!==void 0,dismissible:!1,title:`Slopify was updated`,description:`This tab was loaded before the update. Version ${n??``} is running now; reload to catch up.`,footer:(0,h.jsx)(L,{autoFocus:!0,variant:`primary`,onClick:e,children:`Reload`})})}var TS=[`stage.state`,`stage.progress`,`article.delta`,`llm.preview`,`image.landed`,`narration.piece`,`project.state`,`project.updated`,`review.flagged`],ES=[`running.count`,`staging.progress`,`staging.failed`,`project.updated`,`project.state`,`schedule.topics`,`review.flagged`];function DS(e,t,n){return kS(e,t,TS,n.refetch,e=>{if(n.accept?.(e)!==!1){if(e.type===`llm.preview`){n.previewWriting?.(e);return}if(e.type===`narration.piece`){n.narrationPiece?.();return}if(e.type===`article.delta`){n.appendArticle(e.text);return}if(e.type===`image.landed`||e.type===`project.updated`||e.type===`review.flagged`){n.refetch();return}n.patch(e),e.type===`stage.state`&&n.refetch()}})}function OS(e,t,n){return kS(e,t,ES,n.refetch,e=>{if(e.type===`running.count`){n.tally(e.count);return}if(e.type===`project.updated`||e.type===`project.state`){e.type===`project.state`&&n.projectState?.(e),n.refetch(e.projectId);return}if(e.type===`schedule.topics`){n.scheduleTopics?.(e);return}if(e.type===`review.flagged`){n.reviewFlagged?.(e),n.refetch(e.projectId);return}n.stagingChanged()})}function kS(e,t,n,r,i){let a=e(t),o=!1;a.addEventListener(`open`,()=>{o&&r(),o=!0});for(let e of n)a.addEventListener(e,t=>{let n=AS(t.data);n.type===e&&i(n)});return()=>{a.close()}}function AS(e){return JSON.parse(e)}var jS=[`16:9`,`9:16`],MS=[`research`,`article`,`audio`,`images`,`thumbnail`,`video`,`document`],NS=[`running`,`paused`,`canceled`,`failed`,`partial`,`done`,`pending`],PS=[`generate`,`provide`,`off`,`from_prompt`,`prompt_by_llm`];function FS(e,t){return e[t]??`off`}var IS=[`zoom`,`pan`,`mixed`,`still`],LS=[`text`,`llm`];function RS(e){return e.thumbnailCount===3&&(e.sources.thumbnail===`from_prompt`||e.sources.thumbnail===`prompt_by_llm`)?3:1}var zS=[`prompt`,`provide`],BS=[`video`,`short`],VS=[`plain`],HS=`dicemaster`,US=[...VS,HS],WS={plain:`Plain`,dicemaster:`DiceMaster`};function GS(e){return e?.theme??`dicemaster`}function KS(e){return e?.theme??`plain`}function qS(e){return e?.custom?.name??WS[GS(e)]}function JS(e){let t=e.trim();return t===``?[{field:`name`,message:`Give the theme a name.`}]:t.length>80?[{field:`name`,message:`Keep the name under 80 characters.`}]:[]}function YS(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function XS(e,t=`|`){return e.map(e=>hC(e)).join(t)}function ZS(e,t){return typeof t==`bigint`?t.toString():t}function QS(e){return{get value(){{let t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function $S(e){return e==null}function eC(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function tC(e,t){let n=e/t,r=Math.round(n),i=4*2**-52*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?0:n-r}function nC(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function rC(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function iC(e){return JSON.stringify(e)}function aC(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}var oC=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function sC(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var cC=QS(()=>{if(ew.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function lC(e){if(sC(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return sC(n)!==!1&&Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)!==!1}function uC(e){return lC(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}var dC=new Set([`string`,`number`,`symbol`]);function fC(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function pC(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function mC(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function hC(e){return typeof e==`bigint`?e.toString()+`n`:typeof e==`string`?`"${e}"`:`${e}`}function gC(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout===`optional`)}var _C={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function vC(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);return pC(e,rC(e._zod.def,{get shape(){let e={};for(let r of Reflect.ownKeys(t)){if(!Object.prototype.hasOwnProperty.call(n.shape,r))throw Error(`Unrecognized key: "${String(r)}"`);t[r]&&nC(e,r,n.shape[r])}return nC(this,`shape`,e),e},checks:[]}))}function yC(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);return pC(e,rC(e._zod.def,{get shape(){let r={...e._zod.def.shape};for(let e of Reflect.ownKeys(t)){if(!Object.prototype.hasOwnProperty.call(n.shape,e))throw Error(`Unrecognized key: "${String(e)}"`);t[e]&&delete r[e]}return nC(this,`shape`,r),r},checks:[]}))}function bC(e,t){if(!lC(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=e._zod.def.shape;for(let e of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return pC(e,rC(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return nC(this,`shape`,n),n}}))}function xC(e,t){if(!lC(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return pC(e,rC(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return nC(this,`shape`,n),n}}))}function SC(e,t){if(!t?._zod?.def)throw Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw Error(`.merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.`);return pC(e,rC(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return nC(this,`shape`,n),n},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function CC(e,t,n,r=`partial`){let i=t._zod.def.checks;if(i&&i.length>0)throw Error(`.${r}() cannot be used on object schemas containing refinements`);return pC(t,rC(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t of Reflect.ownKeys(n)){if(!Object.prototype.hasOwnProperty.call(r,t))throw Error(`Unrecognized key: "${String(t)}"`);n[t]&&(i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t])}else for(let t of Reflect.ownKeys(r))i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t];return nC(this,`shape`,i),i},checks:[]}))}function wC(e,t,n){return pC(t,rC(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t of Reflect.ownKeys(n)){if(!Object.prototype.hasOwnProperty.call(i,t))throw Error(`Unrecognized key: "${String(t)}"`);n[t]&&(i[t]=new e({type:`nonoptional`,innerType:r[t]}))}else for(let t of Reflect.ownKeys(r))i[t]=new e({type:`nonoptional`,innerType:r[t]});return nC(this,`shape`,i),i}}))}function TC(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function EC(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function DC(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function OC(e){return typeof e==`string`?e:e?.message}function kC(e,t,n){var r;for(let i=t;i<e.length;i++)(r=e[i]).schema??(r.schema=n)}function AC(e,t,n){var r;let i=e.inst?._zod?.traits;i?.has(`$ZodType`)&&(i.has(`$ZodCheck`)?(r=e).schema??(r.schema=e.inst):e.schema=e.inst);let a=e.schema===e.inst?void 0:e.schema?._zod.def?.error,o=e.message?e.message:OC(e.inst?._zod.def?.error?.(e))??OC(a?.(e))??OC(t?.error?.(e))??OC(n.customError?.(e))??OC(n.localeError?.(e))??`Invalid input`,{inst:s,schema:c,continue:l,input:u,...d}=e;return d.path??=[],d.message=o,t?.reportInput&&(d.input=u),d}var jC=/[\uD800-\uDBFF]/;function MC(e){let t=e.length;if(!jC.test(e))return t;let n=t;for(let r=0;r<t-1;r++)(e.charCodeAt(r)&64512)==55296&&(e.charCodeAt(r+1)&64512)==56320&&(n--,r++);return n}function NC(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function PC(e){let t=typeof e;switch(t){case`number`:return Number.isNaN(e)?`nan`:`number`;case`object`:{if(e===null)return`null`;if(Array.isArray(e))return`array`;let t=e;if(t&&Object.getPrototypeOf(t)!==Object.prototype&&`constructor`in t&&t.constructor)return t.constructor.name}}return t}function FC(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}function IC(e,t){for(let n in t){let r=Object.getOwnPropertyDescriptor(t,n);r.get?Object.defineProperty(e,n,{...r,enumerable:!1}):zC(e,n,r.value)}}function LC(e,t,n,r=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:r,value:n}),n}function RC(e,t,n){return LC(e,t,n,!1)}function zC(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:LC(this,t,n.bind(this))},set(e){LC(this,t,e)}})}function BC(e,t){let n=Object.getPrototypeOf(e);return t in n?void 0:n}var VC,HC=!1,UC={configurable:!0,get(){HC=!0}};function WC(e,t,n){let r=Object.getPrototypeOf(e._zod);if(t in r&&VC!==e._zod){VC=void 0;return}VC=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,UC);let e=HC;HC=!1;try{let r=n(this);return HC?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:r}),HC||=e,r}catch(n){throw delete this[t],HC||=e,n}},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:e})}})}function GC(e,t,n,r){let i=BC(e,t);i&&Object.defineProperty(i,t,{configurable:!0,get(){let e={configurable:!0,writable:!0,enumerable:r,value:void 0};return Object.defineProperty(this,t,e),e.value=n(this),Object.defineProperty(this,t,e),e.value},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:r,value:e})}})}var KC=`~constantCatch`;function qC(e){let t=()=>e;return t[KC]=!0,t}var JC,YC={value:void 0,enumerable:!1},XC=`captureStackTrace`in Error?Error:null;function ZC(e){let t=XC;if(t){let n=t.stackTraceLimit;if(typeof n==`number`){try{t.stackTraceLimit=0}catch{return XC=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function H(e,t,n,r){let i={};function a(e){this.def=e,this.constr=d,this.traits=new Set}a.prototype=i;let o=n,s=o&&new WeakSet;function c(n,r){if(!n._zod){YC.value=new a(r);try{Object.defineProperty(n,"_zod",YC)}finally{YC.value=void 0}}if(n._zod.traits.has(e))return;if(n._zod.traits.add(e),t(n,r),s){let e=Object.getPrototypeOf(n),t=n._zod.constr.prototype,r=e;for(;r&&r!==t;)r=Object.getPrototypeOf(r);let i=r??e;s.has(i)||(s.add(i),IC(i,o))}let i=d.prototype;for(let e in i)Object.prototype.hasOwnProperty.call(i,e)&&(e in n||(n[e]=i[e].bind(n)))}let l=r?.Parent??Object;class u extends l{}Object.defineProperty(u,"name",{value:e});function d(e){let t=r?.Parent?ZC(u):this;c(t,e);let n=t._zod.deferred;if(n){for(let e of n)e();t._zod.deferred=void 0}let i=globalThis.__zod_globalConfig?.postProcessor;return i&&i(t),t}return Object.defineProperty(d,"init",{value:c}),Object.defineProperty(d,Symbol.hasInstance,{value:t=>r?.Parent&&t instanceof r.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(d,"name",{value:e}),d}var QC=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},$C=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};(JC=globalThis).__zod_globalConfig??(JC.__zod_globalConfig={});var ew=globalThis.__zod_globalConfig;function tw(e){return e&&Object.assign(ew,e),ew}function nw(){let e=this._zod;return e.message??=JSON.stringify(e.def,ZS,2),e.message}function rw(e){this._zod.message=e}var iw={get:nw,set:rw,enumerable:!0,configurable:!0},aw={value:void 0,enumerable:!1},ow={value:void 0,enumerable:!1},sw=new WeakSet([Object.prototype,Error.prototype]),cw=(e,t)=>{e.name=`$ZodError`,aw.value=e._zod,Object.defineProperty(e,"_zod",aw),ow.value=t,Object.defineProperty(e,"issues",ow),aw.value=void 0,ow.value=void 0,Object.defineProperty(e,"message",iw);let n=Object.getPrototypeOf(e);sw.has(n)||(sw.add(n),Object.defineProperty(n,"toString",{configurable:!0,enumerable:!1,get(){let e=()=>this.message;return Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0})}}))},lw=H(`$ZodError`,cw),uw=H(`$ZodError`,cw,void 0,{Parent:Error});function dw(e,t,n){return Object.prototype.hasOwnProperty.call(e,t)||(t===`__proto__`?Object.defineProperty(e,t,{value:n(),writable:!0,enumerable:!0,configurable:!0}):e[t]=n()),e[t]}function fw(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?dw(n,i.path[0],()=>[]).push(t(i)):r.push(t(i));return{formErrors:r,fieldErrors:n}}function pw(e,t=e=>e.message){let n={_errors:[]},r=(e,i=[])=>{for(let a of e.issues)if(a.code===`invalid_union`&&a.errors.length)a.errors.map(e=>r({issues:e},[...i,...a.path]));else if(a.code===`invalid_key`)r({issues:a.issues},[...i,...a.path]);else if(a.code===`invalid_element`)r({issues:a.issues},[...i,...a.path]);else{let e=[...i,...a.path];if(e.length===0)n._errors.push(t(a));else{let r=n,i=0;for(;i<e.length;){let n=e[i],o=i===e.length-1;if(n===`_errors`){o&&r._errors.push(t(a)),i++;continue}Object.prototype.hasOwnProperty.call(r,n)||Object.defineProperty(r,n,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let s=r[n];o&&s._errors.push(t(a)),r=s,i++}}}};return r(e),n}function mw(e,t){return{callee:t?.callee??e,Err:t?.Err}}var hw=e=>{let t=(n,r,i,a)=>{let o=i?{...i,async:!1}:{async:!1},s=n._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new QC;if(s.issues.length){let n=new((a?.Err)??e)(s.issues.map(e=>AC(e,o,tw())));throw oC(n,a?.callee??t),n}return s.value};return t},gw=e=>{let t=async(n,r,i,a)=>{let o=i?{...i,async:!0}:{async:!0},s=n._zod.run({value:r,issues:[]},o);if(s instanceof Promise&&(s=await s),s.issues.length){let n=new((a?.Err)??e)(s.issues.map(e=>AC(e,o,tw())));throw oC(n,a?.callee??t),n}return s.value};return t},_w=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new QC;return a.issues.length?{success:!1,error:new(e??lw)(a.issues.map(e=>AC(e,i,tw())))}:{success:!0,data:a.value}},vw=_w(uw),yw=e=>async(t,n,r)=>{let i=r?{...r,async:!0}:{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(e=>AC(e,i,tw())))}:{success:!0,data:a.value}},bw=yw(uw),xw=e=>{let t=hw(e),n=(e,r,i,a)=>{let o=i?{...i,direction:`backward`}:{direction:`backward`};return t(e,r,o,mw(n,a))};return n},Sw=e=>{let t=hw(e),n=(e,r,i,a)=>t(e,r,i,mw(n,a));return n},Cw=e=>{let t=gw(e),n=async(e,r,i,a)=>{let o=i?{...i,direction:`backward`}:{direction:`backward`};return await t(e,r,o,mw(n,a))};return n},ww=e=>{let t=gw(e),n=async(e,r,i,a)=>await t(e,r,i,mw(n,a));return n},Tw=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return _w(e)(t,n,i)},Ew=e=>(t,n,r)=>_w(e)(t,n,r),Dw=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return yw(e)(t,n,i)},Ow=e=>async(t,n,r)=>yw(e)(t,n,r),kw=/^[cC][0-9a-z]{6,}$/,Aw=/^[0-9a-z]+$/,jw=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,Mw=/^[0-9a-vA-V]{20}$/,Nw=/^[A-Za-z0-9]{27}$/,Pw=/^[a-zA-Z0-9_-]{21}$/;function Fw(e){return RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var Iw=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Lw=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Rw=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,zw=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Bw=`^[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$`;function Vw(){return new RegExp(Bw,`u`)}var Hw=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Uw=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,Ww=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,Gw=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Kw=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,qw=/^[A-Za-z0-9_-]*$/,Jw=/^https?$/,Yw=/^\+[1-9]\d{6,14}$/,Xw=`(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`;function Zw(e){return RegExp(`^${e}$`)}var Qw=Zw(Xw);function $w(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?`${t}:[0-5]\\d(?:\\.\\d+)?`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function eT(e){return RegExp(`^${$w(e)}$`)}function tT(e){let t=[`Z`];e.offset&&t.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let n=`${$w({precision:e.precision,seconds:!0})}(?:${t.join(`|`)})`,r=e.local?`${n}|${$w({precision:e.precision})}`:n;return RegExp(`^${Xw}T(?:${r})$`)}var dte=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},nT=/^-?\d+$/,rT=/^-?\d+(?:\.\d+)?$/,fte=/^(?:true|false)$/i,pte=/^null$/i,mte=/^[^A-Z]*$/,hte=/^[^a-z]*$/,iT=H(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),aT=e=>{let t=e.value;return!$S(t)&&t.length!==void 0},oT={number:`number`,bigint:`bigint`,object:`date`},sT=H(`$ZodCheckLessThan`,(e,t)=>{iT.init(e,t);let n=oT[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.maximum:n.exclusiveMaximum)??1/0;t.value<r&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:oT[typeof r.value]??n,code:`too_big`,maximum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),cT=H(`$ZodCheckGreaterThan`,(e,t)=>{iT.init(e,t);let n=oT[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.minimum:n.exclusiveMinimum)??-1/0;t.value>r&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:oT[typeof r.value]??n,code:`too_small`,minimum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),gte=H(`$ZodCheckMultipleOf`,(e,t)=>{iT.init(e,t),e._zod.onattach.push(e=>{var n;(n=e._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?t.value!==BigInt(0)&&n.value%t.value===BigInt(0):tC(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),_te=H(`$ZodCheckNumberFormat`,(e,t)=>{iT.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=_C[t.format];e._zod.onattach.push(e=>{let r=e._zod.bag;r.format=t.format,r.minimum=i,r.maximum=a,n&&(r.pattern=nT)}),e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),vte=H(`$ZodCheckMaxLength`,(e,t)=>{var n;iT.init(e,t),(n=e._zod.def).when??(n.when=aT),e._zod.onattach.push(e=>{let n=e._zod.bag.maximum??1/0;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>t.maximum?MC(r):i)<=t.maximum)return;let a=NC(r);n.issues.push({origin:a,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),yte=H(`$ZodCheckMinLength`,(e,t)=>{var n;iT.init(e,t),(n=e._zod.def).when??(n.when=aT),e._zod.onattach.push(e=>{let n=e._zod.bag.minimum??-1/0;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>=t.minimum&&i<t.minimum*2?MC(r):i)>=t.minimum)return;let a=NC(r);n.issues.push({origin:a,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),bte=H(`$ZodCheckLengthEquals`,(e,t)=>{var n;iT.init(e,t),(n=e._zod.def).when??(n.when=aT),e._zod.onattach.push(e=>{let n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=n=>{let r=n.value,i=r.length,a=typeof r==`string`&&i>=t.length&&i<=t.length*2?MC(r):i;if(a===t.length)return;let o=NC(r),s=a>t.length;n.issues.push({origin:o,...s?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),lT=H(`$ZodCheckStringFormat`,(e,t)=>{var n,r;iT.init(e,t),e._zod.onattach.push(e=>{let n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??=new Set,n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),xte=H(`$ZodCheckRegex`,(e,t)=>{lT.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Ste=H(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=mte,lT.init(e,t)}),Cte=H(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=hte,lT.init(e,t)}),wte=H(`$ZodCheckIncludes`,(e,t)=>{iT.init(e,t);let n=fC(t.includes),r=new RegExp(typeof t.position==`number`?`^.{${t.position},}${n}`:n);t.pattern=r,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(r)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),Tte=H(`$ZodCheckStartsWith`,(e,t)=>{iT.init(e,t);let n=RegExp(`^${fC(t.prefix)}.*`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),Ete=H(`$ZodCheckEndsWith`,(e,t)=>{iT.init(e,t);let n=RegExp(`.*${fC(t.suffix)}$`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),Dte=H(`$ZodCheckOverwrite`,(e,t)=>{iT.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}),Ote=class{constructor(e=[],t={}){this.content=[],this.indent=0,this.args=e,this.closed=t}indented(e){this.indent+=1,e(this),--this.indent}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
52
52
  `).filter(e=>e),n=Math.min(...t.map(e=>e.length-e.trimStart().length)),r=t.map(e=>e.slice(n)).map(e=>` `.repeat(this.indent*2)+e);for(let e of r)this.content.push(e)}compile(){let e=Function,t=this?.content??[``];return new e(...Object.keys(this.closed),`return function (${this.args.join(`, `)}) {\n${t.join(`
@@ -269,7 +269,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
269
269
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function _(e,t){if(t&&(typeof t==`object`||typeof t==`function`))return t;if(t!==void 0)throw TypeError(`Derived constructors may only return object or undefined`);return i(e)}function v(e,t){return v=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},v(e,t)}function y(e,t){return r(e)||h(e,t)||C(e,t)||g()}function b(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function x(e){var t=b(e,`string`);return typeof t==`symbol`?t:t+``}function S(e){"@babel/helpers - typeof";return S=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},S(e)}function C(e,t){if(e){if(typeof e==`string`)return n(e,t);var r={}.toString.call(e).slice(8,-1);return r===`Object`&&e.constructor&&(r=e.constructor.name),r===`Map`||r===`Set`?Array.from(e):r===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?n(e,t):void 0}}function w(e){var t=typeof Map==`function`?new Map:void 0;return w=function(e){function n(){return s(e,arguments,d(this).constructor)}if(e===null||!p(e))return e;if(typeof e!=`function`)throw TypeError(`Super expression must either be null or a function`);if(t!==void 0){if(t.has(e))return t.get(e);t.set(e,n)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),v(n,e)},w(e)}var T=function(e){var t=Math.abs,n=Math.max,r=Math.floor;function i(e,t){var n;if(o(this,i),n=a(this,i,[e]),n.sign=t,Object.setPrototypeOf(n,i.prototype),e>i.__kMaxLength)throw RangeError(`Maximum BigInt size exceeded`);return n}return f(i,e),l(i,[{key:`toDebugString`,value:function(){var e,t=[`BigInt[`],n=u(this);try{for(n.s();!(e=n.n()).done;){var r=e.value;t.push((r&&(r>>>0).toString(16))+`, `)}}catch(e){n.e(e)}finally{n.f()}return t.push(`]`),t.join(``)}},{key:`toString`,value:function(){var e=0<arguments.length&&arguments[0]!==void 0?arguments[0]:10;if(2>e||36<e)throw RangeError(`toString() radix argument must be between 2 and 36`);return this.length===0?`0`:e&e-1?i.__toStringGeneric(this,e,!1):i.__toStringBasePowerOfTwo(this,e)}},{key:`valueOf`,value:function(){throw Error("Convert JSBI instances to native numbers using `toNumber`.")}},{key:`__copy`,value:function(){for(var e=new i(this.length,this.sign),t=0;t<this.length;t++)e[t]=this[t];return e}},{key:`__trim`,value:function(){for(var e=this.length,t=this[e-1];t===0;)e--,t=this[e-1],this.pop();return e===0&&(this.sign=!1),this}},{key:`__initializeDigits`,value:function(){for(var e=0;e<this.length;e++)this[e]=0}},{key:`__clzmsd`,value:function(){return i.__clz30(this.__digit(this.length-1))}},{key:`__inplaceMultiplyAdd`,value:function(e,t,n){n>this.length&&(n=this.length);for(var r=32767&e,a=e>>>15,o=0,s=t,c=0;c<n;c++){var l=this.__digit(c),u=32767&l,d=l>>>15,f=i.__imul(u,r),p=i.__imul(u,a),m=i.__imul(d,r),h=i.__imul(d,a),g=s+f+o;o=g>>>30,g&=1073741823,g+=((32767&p)<<15)+((32767&m)<<15),o+=g>>>30,s=h+(p>>>15)+(m>>>15),this.__setDigit(c,1073741823&g)}if(o!==0||s!==0)throw Error(`implementation bug`)}},{key:`__inplaceAdd`,value:function(e,t,n){for(var r,i=0,a=0;a<n;a++)r=this.__halfDigit(t+a)+e.__halfDigit(a)+i,i=r>>>15,this.__setHalfDigit(t+a,32767&r);return i}},{key:`__inplaceSub`,value:function(e,t,n){var r=n-1>>>1,i=0;if(1&t){t>>=1;for(var a=this.__digit(t),o=32767&a,s=0;s<r;s++){var c=e.__digit(s),l=(a>>>15)-(32767&c)-i;i=1&l>>>15,this.__setDigit(t+s,(32767&l)<<15|32767&o),a=this.__digit(t+s+1),o=(32767&a)-(c>>>15)-i,i=1&o>>>15}var u=e.__digit(s),d=(a>>>15)-(32767&u)-i;i=1&d>>>15,this.__setDigit(t+s,(32767&d)<<15|32767&o);var f=u>>>15;if(t+s+1>=this.length)throw RangeError(`out of bounds`);!(1&n)&&(a=this.__digit(t+s+1),o=(32767&a)-f-i,i=1&o>>>15,this.__setDigit(t+e.length,1073709056&a|32767&o))}else{t>>=1;for(var p=0;p<e.length-1;p++){var m=this.__digit(t+p),h=e.__digit(p),g=(32767&m)-(32767&h)-i;i=1&g>>>15;var _=(m>>>15)-(h>>>15)-i;i=1&_>>>15,this.__setDigit(t+p,(32767&_)<<15|32767&g)}var v=this.__digit(t+p),y=e.__digit(p),b=(32767&v)-(32767&y)-i;i=1&b>>>15;var x=0;!(1&n)&&(x=(v>>>15)-(y>>>15)-i,i=1&x>>>15),this.__setDigit(t+p,(32767&x)<<15|32767&b)}return i}},{key:`__inplaceRightShift`,value:function(e){if(e!==0){for(var t,n=this.__digit(0)>>>e,r=this.length-1,i=0;i<r;i++)t=this.__digit(i+1),this.__setDigit(i,1073741823&t<<30-e|n),n=t>>>e;this.__setDigit(r,n)}}},{key:`__digit`,value:function(e){return this[e]}},{key:`__unsignedDigit`,value:function(e){return this[e]>>>0}},{key:`__setDigit`,value:function(e,t){this[e]=0|t}},{key:`__setDigitGrow`,value:function(e,t){this[e]=0|t}},{key:`__halfDigitLength`,value:function(){var e=this.length;return 32767>=this.__unsignedDigit(e-1)?2*e-1:2*e}},{key:`__halfDigit`,value:function(e){return 32767&this[e>>>1]>>>15*(1&e)}},{key:`__setHalfDigit`,value:function(e,t){var n=e>>>1,r=this.__digit(n),i=1&e?32767&r|t<<15:1073709056&r|32767&t;this.__setDigit(n,i)}}],[{key:`BigInt`,value:function(e){var t=Number.isFinite;if(typeof e==`number`){if(e===0)return i.__zero();if(i.__isOneDigitInt(e))return 0>e?i.__oneDigit(-e,!0):i.__oneDigit(e,!1);if(!t(e)||r(e)!==e)throw RangeError(`The number `+e+` cannot be converted to BigInt because it is not an integer`);return i.__fromDouble(e)}if(typeof e==`string`){var n=i.__fromString(e);if(n===null)throw SyntaxError(`Cannot convert `+e+` to a BigInt`);return n}if(typeof e==`boolean`)return!0===e?i.__oneDigit(1,!1):i.__zero();if(S(e)===`object`){if(e.constructor===i)return e;var a=i.__toPrimitive(e);return i.BigInt(a)}throw TypeError(`Cannot convert `+e+` to a BigInt`)}},{key:`toNumber`,value:function(e){var t=e.length;if(t===0)return 0;if(t===1){var n=e.__unsignedDigit(0);return e.sign?-n:n}var r=e.__digit(t-1),a=i.__clz30(r),o=30*t-a;if(1024<o)return e.sign?-1/0:1/0;var s=o-1,c=r,l=t-1,u=a+3,d=u===32?0:c<<u;d>>>=12;var f=u-12,p=12<=u?0:c<<20+u,m=20+u;for(0<f&&0<l&&(l--,c=e.__digit(l),d|=c>>>30-f,p=c<<f+2,m=f+2);0<m&&0<l;)l--,c=e.__digit(l),p|=30<=m?c<<m-30:c>>>30-m,m-=30;var h=i.__decideRounding(e,m,l,c);if((h===1||h===0&&(1&p)==1)&&(p=p+1>>>0,p===0&&(d++,d>>>20&&(d=0,s++,1023<s))))return e.sign?-1/0:1/0;var g=e.sign?-2147483648:0;return s=s+1023<<20,i.__kBitConversionInts[i.__kBitConversionIntHigh]=g|s|d,i.__kBitConversionInts[i.__kBitConversionIntLow]=p,i.__kBitConversionDouble[0]}},{key:`unaryMinus`,value:function(e){if(e.length===0)return e;var t=e.__copy();return t.sign=!e.sign,t}},{key:`bitwiseNot`,value:function(e){return e.sign?i.__absoluteSubOne(e).__trim():i.__absoluteAddOne(e,!0)}},{key:`exponentiate`,value:function(e,t){if(t.sign)throw RangeError(`Exponent must be positive`);if(t.length===0)return i.__oneDigit(1,!1);if(e.length===0)return e;if(e.length===1&&e.__digit(0)===1)return e.sign&&!(1&t.__digit(0))?i.unaryMinus(e):e;if(1<t.length)throw RangeError(`BigInt too big`);var n=t.__unsignedDigit(0);if(n===1)return e;if(n>=i.__kMaxLengthBits)throw RangeError(`BigInt too big`);if(e.length===1&&e.__digit(0)===2){var r=1+(0|n/30),a=new i(r,e.sign&&!!(1&n));a.__initializeDigits();var o=1<<n%30;return a.__setDigit(r-1,o),a}var s=null,c=e;for(1&n&&(s=e),n>>=1;n!==0;n>>=1)c=i.multiply(c,c),1&n&&(s=s===null?c:i.multiply(s,c));return s}},{key:`multiply`,value:function(e,t){if(e.length===0)return e;if(t.length===0)return t;var n=e.length+t.length;30<=e.__clzmsd()+t.__clzmsd()&&n--;var r=new i(n,e.sign!==t.sign);r.__initializeDigits();for(var a=0;a<e.length;a++)i.__multiplyAccumulate(t,e.__digit(a),r,a);return r.__trim()}},{key:`divide`,value:function(e,t){if(t.length===0)throw RangeError(`Division by zero`);if(0>i.__absoluteCompare(e,t))return i.__zero();var n,r=e.sign!==t.sign,a=t.__unsignedDigit(0);if(t.length===1&&32767>=a){if(a===1)return r===e.sign?e:i.unaryMinus(e);n=i.__absoluteDivSmall(e,a,null)}else n=i.__absoluteDivLarge(e,t,!0,!1);return n.sign=r,n.__trim()}},{key:`remainder`,value:function(e,t){if(t.length===0)throw RangeError(`Division by zero`);if(0>i.__absoluteCompare(e,t))return e;var n=t.__unsignedDigit(0);if(t.length===1&&32767>=n){if(n===1)return i.__zero();var r=i.__absoluteModSmall(e,n);return r===0?i.__zero():i.__oneDigit(r,e.sign)}var a=i.__absoluteDivLarge(e,t,!1,!0);return a.sign=e.sign,a.__trim()}},{key:`add`,value:function(e,t){var n=e.sign;return n===t.sign?i.__absoluteAdd(e,t,n):0<=i.__absoluteCompare(e,t)?i.__absoluteSub(e,t,n):i.__absoluteSub(t,e,!n)}},{key:`subtract`,value:function(e,t){var n=e.sign;return n===t.sign?0<=i.__absoluteCompare(e,t)?i.__absoluteSub(e,t,n):i.__absoluteSub(t,e,!n):i.__absoluteAdd(e,t,n)}},{key:`leftShift`,value:function(e,t){return t.length===0||e.length===0?e:t.sign?i.__rightShiftByAbsolute(e,t):i.__leftShiftByAbsolute(e,t)}},{key:`signedRightShift`,value:function(e,t){return t.length===0||e.length===0?e:t.sign?i.__leftShiftByAbsolute(e,t):i.__rightShiftByAbsolute(e,t)}},{key:`unsignedRightShift`,value:function(){throw TypeError(`BigInts have no unsigned right shift; use >> instead`)}},{key:`lessThan`,value:function(e,t){return 0>i.__compareToBigInt(e,t)}},{key:`lessThanOrEqual`,value:function(e,t){return 0>=i.__compareToBigInt(e,t)}},{key:`greaterThan`,value:function(e,t){return 0<i.__compareToBigInt(e,t)}},{key:`greaterThanOrEqual`,value:function(e,t){return 0<=i.__compareToBigInt(e,t)}},{key:`equal`,value:function(e,t){if(e.sign!==t.sign||e.length!==t.length)return!1;for(var n=0;n<e.length;n++)if(e.__digit(n)!==t.__digit(n))return!1;return!0}},{key:`notEqual`,value:function(e,t){return!i.equal(e,t)}},{key:`bitwiseAnd`,value:function(e,t){if(!e.sign&&!t.sign)return i.__absoluteAnd(e,t).__trim();if(e.sign&&t.sign){var r=n(e.length,t.length)+1,a=i.__absoluteSubOne(e,r),o=i.__absoluteSubOne(t);return a=i.__absoluteOr(a,o,a),i.__absoluteAddOne(a,!0,a).__trim()}if(e.sign){var s=[t,e];e=s[0],t=s[1]}return i.__absoluteAndNot(e,i.__absoluteSubOne(t)).__trim()}},{key:`bitwiseXor`,value:function(e,t){if(!e.sign&&!t.sign)return i.__absoluteXor(e,t).__trim();if(e.sign&&t.sign){var r=n(e.length,t.length),a=i.__absoluteSubOne(e,r),o=i.__absoluteSubOne(t);return i.__absoluteXor(a,o,a).__trim()}var s=n(e.length,t.length)+1;if(e.sign){var c=[t,e];e=c[0],t=c[1]}var l=i.__absoluteSubOne(t,s);return l=i.__absoluteXor(l,e,l),i.__absoluteAddOne(l,!0,l).__trim()}},{key:`bitwiseOr`,value:function(e,t){var r=n(e.length,t.length);if(!e.sign&&!t.sign)return i.__absoluteOr(e,t).__trim();if(e.sign&&t.sign){var a=i.__absoluteSubOne(e,r),o=i.__absoluteSubOne(t);return a=i.__absoluteAnd(a,o,a),i.__absoluteAddOne(a,!0,a).__trim()}if(e.sign){var s=[t,e];e=s[0],t=s[1]}var c=i.__absoluteSubOne(t,r);return c=i.__absoluteAndNot(c,e,c),i.__absoluteAddOne(c,!0,c).__trim()}},{key:`asIntN`,value:function(e,t){if(t.length===0)return t;if(e=r(e),0>e)throw RangeError(`Invalid value: not (convertible to) a safe integer`);if(e===0)return i.__zero();if(e>=i.__kMaxLengthBits)return t;var n=0|(e+29)/30;if(t.length<n)return t;var a=t.__unsignedDigit(n-1),o=1<<(e-1)%30;if(t.length===n&&a<o)return t;if((a&o)!==o)return i.__truncateToNBits(e,t);if(!t.sign)return i.__truncateAndSubFromPowerOfTwo(e,t,!0);if(!(a&o-1)){for(var s=n-2;0<=s;s--)if(t.__digit(s)!==0)return i.__truncateAndSubFromPowerOfTwo(e,t,!1);return t.length===n&&a===o?t:i.__truncateToNBits(e,t)}return i.__truncateAndSubFromPowerOfTwo(e,t,!1)}},{key:`asUintN`,value:function(e,t){if(t.length===0)return t;if(e=r(e),0>e)throw RangeError(`Invalid value: not (convertible to) a safe integer`);if(e===0)return i.__zero();if(t.sign){if(e>i.__kMaxLengthBits)throw RangeError(`BigInt too big`);return i.__truncateAndSubFromPowerOfTwo(e,t,!1)}if(e>=i.__kMaxLengthBits)return t;var n=0|(e+29)/30;if(t.length<n)return t;var a=e%30;return t.length==n&&(a===0||!(t.__digit(n-1)>>>a))?t:i.__truncateToNBits(e,t)}},{key:`ADD`,value:function(e,t){if(e=i.__toPrimitive(e),t=i.__toPrimitive(t),typeof e==`string`)return typeof t!=`string`&&(t=t.toString()),e+t;if(typeof t==`string`)return e.toString()+t;if(e=i.__toNumeric(e),t=i.__toNumeric(t),i.__isBigInt(e)&&i.__isBigInt(t))return i.add(e,t);if(typeof e==`number`&&typeof t==`number`)return e+t;throw TypeError(`Cannot mix BigInt and other types, use explicit conversions`)}},{key:`LT`,value:function(e,t){return i.__compare(e,t,0)}},{key:`LE`,value:function(e,t){return i.__compare(e,t,1)}},{key:`GT`,value:function(e,t){return i.__compare(e,t,2)}},{key:`GE`,value:function(e,t){return i.__compare(e,t,3)}},{key:`EQ`,value:function(e,t){for(;;){if(i.__isBigInt(e))return i.__isBigInt(t)?i.equal(e,t):i.EQ(t,e);if(typeof e==`number`){if(i.__isBigInt(t))return i.__equalToNumber(t,e);if(S(t)!==`object`)return e==t;t=i.__toPrimitive(t)}else if(typeof e==`string`){if(i.__isBigInt(t))return e=i.__fromString(e),e!==null&&i.equal(e,t);if(S(t)!==`object`)return e==t;t=i.__toPrimitive(t)}else if(typeof e==`boolean`){if(i.__isBigInt(t))return i.__equalToNumber(t,+e);if(S(t)!==`object`)return e==t;t=i.__toPrimitive(t)}else if(S(e)===`symbol`){if(i.__isBigInt(t))return!1;if(S(t)!==`object`)return e==t;t=i.__toPrimitive(t)}else if(S(e)===`object`){if(S(t)===`object`&&t.constructor!==i)return e==t;e=i.__toPrimitive(e)}else return e==t}}},{key:`NE`,value:function(e,t){return!i.EQ(e,t)}},{key:`DataViewGetBigInt64`,value:function(e,t){var n=2<arguments.length&&arguments[2]!==void 0&&arguments[2];return i.asIntN(64,i.DataViewGetBigUint64(e,t,n))}},{key:`DataViewGetBigUint64`,value:function(e,t){var n=2<arguments.length&&arguments[2]!==void 0&&arguments[2],r=y(n?[4,0]:[0,4],2),a=r[0],o=r[1],s=e.getUint32(t+a,n),c=e.getUint32(t+o,n),l=new i(3,!1);return l.__setDigit(0,1073741823&c),l.__setDigit(1,(268435455&s)<<2|c>>>30),l.__setDigit(2,s>>>28),l.__trim()}},{key:`DataViewSetBigInt64`,value:function(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0&&arguments[3];i.DataViewSetBigUint64(e,t,n,r)}},{key:`DataViewSetBigUint64`,value:function(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0&&arguments[3];n=i.asUintN(64,n);var a=0,o=0;if(0<n.length&&(o=n.__digit(0),1<n.length)){var s=n.__digit(1);o|=s<<30,a=s>>>2,2<n.length&&(a|=n.__digit(2)<<28)}var c=y(r?[4,0]:[0,4],2),l=c[0],u=c[1];e.setUint32(t+l,a,r),e.setUint32(t+u,o,r)}},{key:`__zero`,value:function(){return new i(0,!1)}},{key:`__oneDigit`,value:function(e,t){var n=new i(1,t);return n.__setDigit(0,e),n}},{key:`__decideRounding`,value:function(e,t,n,r){if(0<t)return-1;var i;if(0>t)i=-t-1;else{if(n===0)return-1;n--,r=e.__digit(n),i=29}var a=1<<i;if((r&a)==0)return-1;if(--a,(r&a)!=0)return 1;for(;0<n;)if(n--,e.__digit(n)!==0)return 1;return 0}},{key:`__fromDouble`,value:function(e){var t=0>e;i.__kBitConversionDouble[0]=e;var n,r=(2047&i.__kBitConversionInts[i.__kBitConversionIntHigh]>>>20)-1023,a=(0|r/30)+1,o=new i(a,t),s=1048575&i.__kBitConversionInts[i.__kBitConversionIntHigh]|1048576,c=i.__kBitConversionInts[i.__kBitConversionIntLow],l=20,u=r%30,d=0;if(u<l){var f=l-u;d=f+32,n=s>>>f,s=s<<32-f|c>>>f,c<<=32-f}else if(u===l)d=32,n=s,s=c,c=0;else{var p=u-l;d=32-p,n=s<<p|c>>>32-p,s=c<<p,c=0}o.__setDigit(a-1,n);for(var m=a-2;0<=m;m--)0<d?(d-=30,n=s>>>2,s=s<<30|c>>>2,c<<=30):n=0,o.__setDigit(m,n);return o.__trim()}},{key:`__isWhitespace`,value:function(e){return 13>=e&&9<=e||(159>=e?e==32:131071>=e?e==160||e==5760:196607>=e?(e&=131071,10>=e||e==40||e==41||e==47||e==95||e==4096):e==65279)}},{key:`__fromString`,value:function(e){var t=1<arguments.length&&arguments[1]!==void 0?arguments[1]:0,n=0,r=e.length,a=0;if(a===r)return i.__zero();for(var o=e.charCodeAt(a);i.__isWhitespace(o);){if(++a===r)return i.__zero();o=e.charCodeAt(a)}if(o===43){if(++a===r)return null;o=e.charCodeAt(a),n=1}else if(o===45){if(++a===r)return null;o=e.charCodeAt(a),n=-1}if(t===0){if(t=10,o===48){if(++a===r)return i.__zero();if(o=e.charCodeAt(a),o===88||o===120){if(t=16,++a===r)return null;o=e.charCodeAt(a)}else if(o===79||o===111){if(t=8,++a===r)return null;o=e.charCodeAt(a)}else if(o===66||o===98){if(t=2,++a===r)return null;o=e.charCodeAt(a)}}}else if(t===16&&o===48){if(++a===r)return i.__zero();if(o=e.charCodeAt(a),o===88||o===120){if(++a===r)return null;o=e.charCodeAt(a)}}if(n!==0&&t!==10)return null;for(;o===48;){if(++a===r)return i.__zero();o=e.charCodeAt(a)}var s=r-a,c=i.__kMaxBitsPerChar[t],l=i.__kBitsPerCharTableMultiplier-1;if(s>1073741824/c)return null;var u=new i(0|((c*s+l>>>i.__kBitsPerCharTableShift)+29)/30,!1),d=10>t?t:10,f=10<t?t-10:0;if(t&t-1){u.__initializeDigits();var p=!1,m=0;do{for(var h,g=0,_=1;;){if(h=void 0,o-48>>>0<d)h=o-48;else if((32|o)-97>>>0<f)h=(32|o)-87;else{p=!0;break}var v=_*t;if(1073741823<v)break;if(_=v,g=g*t+h,m++,++a===r){p=!0;break}o=e.charCodeAt(a)}l=30*i.__kBitsPerCharTableMultiplier-1;var y=0|(c*m+l>>>i.__kBitsPerCharTableShift)/30;u.__inplaceMultiplyAdd(_,g,y)}while(!p)}else{c>>=i.__kBitsPerCharTableShift;var b=[],x=[],S=!1;do{for(var C,w=0,T=0;;){if(C=void 0,o-48>>>0<d)C=o-48;else if((32|o)-97>>>0<f)C=(32|o)-87;else{S=!0;break}if(T+=c,w=w<<c|C,++a===r){S=!0;break}if(o=e.charCodeAt(a),30<T+c)break}b.push(w),x.push(T)}while(!S);i.__fillFromParts(u,b,x)}if(a!==r){if(!i.__isWhitespace(o))return null;for(a++;a<r;a++)if(o=e.charCodeAt(a),!i.__isWhitespace(o))return null}return u.sign=n===-1,u.__trim()}},{key:`__fillFromParts`,value:function(e,t,n){for(var r=0,i=0,a=0,o=t.length-1;0<=o;o--){var s=t[o],c=n[o];i|=s<<a,a+=c,a===30?(e.__setDigit(r++,i),a=0,i=0):30<a&&(e.__setDigit(r++,1073741823&i),a-=30,i=s>>>c-a)}if(i!==0){if(r>=e.length)throw Error(`implementation bug`);e.__setDigit(r++,i)}for(;r<e.length;r++)e.__setDigit(r,0)}},{key:`__toStringBasePowerOfTwo`,value:function(e,t){var n=e.length,r=t-1;r=(85&r>>>1)+(85&r),r=(51&r>>>2)+(51&r),r=(15&r>>>4)+(15&r);var a=r,o=t-1,s=e.__digit(n-1),c=i.__clz30(s),l=0|(30*n-c+a-1)/a;if(e.sign&&l++,268435456<l)throw Error(`string too long`);for(var u=Array(l),d=l-1,f=0,p=0,m=0;m<n-1;m++){var h=e.__digit(m),g=(f|h<<p)&o;u[d--]=i.__kConversionChars[g];var _=a-p;for(f=h>>>_,p=30-_;p>=a;)u[d--]=i.__kConversionChars[f&o],f>>>=a,p-=a}var v=(f|s<<p)&o;for(u[d--]=i.__kConversionChars[v],f=s>>>a-p;f!==0;)u[d--]=i.__kConversionChars[f&o],f>>>=a;if(e.sign&&(u[d--]=`-`),d!==-1)throw Error(`implementation bug`);return u.join(``)}},{key:`__toStringGeneric`,value:function(e,t,n){var r=e.length;if(r===0)return``;if(r===1){var a=e.__unsignedDigit(0).toString(t);return!1===n&&e.sign&&(a=`-`+a),a}var o=30*r-i.__clz30(e.__digit(r-1)),s=i.__kMaxBitsPerChar[t]-1,c=o*i.__kBitsPerCharTableMultiplier;c+=s-1,c=0|c/s;var l,u,d=c+1>>1,f=i.exponentiate(i.__oneDigit(t,!1),i.__oneDigit(d,!1)),p=f.__unsignedDigit(0);if(f.length===1&&32767>=p){l=new i(e.length,!1),l.__initializeDigits();for(var m,h=0,g=2*e.length-1;0<=g;g--)m=h<<15|e.__halfDigit(g),l.__setHalfDigit(g,0|m/p),h=0|m%p;u=h.toString(t)}else{var _=i.__absoluteDivLarge(e,f,!0,!0);l=_.quotient;var v=_.remainder.__trim();u=i.__toStringGeneric(v,t,!0)}l.__trim();for(var y=i.__toStringGeneric(l,t,!0);u.length<d;)u=`0`+u;return!1===n&&e.sign&&(y=`-`+y),y+u}},{key:`__unequalSign`,value:function(e){return e?-1:1}},{key:`__absoluteGreater`,value:function(e){return e?-1:1}},{key:`__absoluteLess`,value:function(e){return e?1:-1}},{key:`__compareToBigInt`,value:function(e,t){var n=e.sign;if(n!==t.sign)return i.__unequalSign(n);var r=i.__absoluteCompare(e,t);return 0<r?i.__absoluteGreater(n):0>r?i.__absoluteLess(n):0}},{key:`__compareToNumber`,value:function(e,n){if(i.__isOneDigitInt(n)){var r=e.sign,a=0>n;if(r!==a)return i.__unequalSign(r);if(e.length===0){if(a)throw Error(`implementation bug`);return n===0?0:-1}if(1<e.length)return i.__absoluteGreater(r);var o=t(n),s=e.__unsignedDigit(0);return s>o?i.__absoluteGreater(r):s<o?i.__absoluteLess(r):0}return i.__compareToDouble(e,n)}},{key:`__compareToDouble`,value:function(e,t){if(t!==t)return t;if(t===1/0)return-1;if(t===-1/0)return 1;var n=e.sign;if(n!==0>t)return i.__unequalSign(n);if(t===0)throw Error(`implementation bug: should be handled elsewhere`);if(e.length===0)return-1;i.__kBitConversionDouble[0]=t;var r=2047&i.__kBitConversionInts[i.__kBitConversionIntHigh]>>>20;if(r==2047)throw Error(`implementation bug: handled elsewhere`);var a=r-1023;if(0>a)return i.__absoluteGreater(n);var o=e.length,s=e.__digit(o-1),c=i.__clz30(s),l=30*o-c,u=a+1;if(l<u)return i.__absoluteLess(n);if(l>u)return i.__absoluteGreater(n);var d=1048576|1048575&i.__kBitConversionInts[i.__kBitConversionIntHigh],f=i.__kBitConversionInts[i.__kBitConversionIntLow],p=20,m=29-c;if(m!==(0|(l-1)%30))throw Error(`implementation bug`);var h,g=0;if(m<p){var _=p-m;g=_+32,h=d>>>_,d=d<<32-_|f>>>_,f<<=32-_}else if(m===p)g=32,h=d,d=f,f=0;else{var v=m-p;g=32-v,h=d<<v|f>>>32-v,d=f<<v,f=0}if(s>>>=0,h>>>=0,s>h)return i.__absoluteGreater(n);if(s<h)return i.__absoluteLess(n);for(var y=o-2;0<=y;y--){0<g?(g-=30,h=d>>>2,d=d<<30|f>>>2,f<<=30):h=0;var b=e.__unsignedDigit(y);if(b>h)return i.__absoluteGreater(n);if(b<h)return i.__absoluteLess(n)}if(d!==0||f!==0){if(g===0)throw Error(`implementation bug`);return i.__absoluteLess(n)}return 0}},{key:`__equalToNumber`,value:function(e,n){return i.__isOneDigitInt(n)?n===0?e.length===0:e.length===1&&e.sign===0>n&&e.__unsignedDigit(0)===t(n):i.__compareToDouble(e,n)===0}},{key:`__comparisonResultToBool`,value:function(e,t){return t===0?0>e:t===1?0>=e:t===2?0<e:t===3?0<=e:void 0}},{key:`__compare`,value:function(e,t,n){if(e=i.__toPrimitive(e),t=i.__toPrimitive(t),typeof e==`string`&&typeof t==`string`)switch(n){case 0:return e<t;case 1:return e<=t;case 2:return e>t;case 3:return e>=t}if(i.__isBigInt(e)&&typeof t==`string`)return t=i.__fromString(t),t!==null&&i.__comparisonResultToBool(i.__compareToBigInt(e,t),n);if(typeof e==`string`&&i.__isBigInt(t))return e=i.__fromString(e),e!==null&&i.__comparisonResultToBool(i.__compareToBigInt(e,t),n);if(e=i.__toNumeric(e),t=i.__toNumeric(t),i.__isBigInt(e)){if(i.__isBigInt(t))return i.__comparisonResultToBool(i.__compareToBigInt(e,t),n);if(typeof t!=`number`)throw Error(`implementation bug`);return i.__comparisonResultToBool(i.__compareToNumber(e,t),n)}if(typeof e!=`number`)throw Error(`implementation bug`);if(i.__isBigInt(t))return i.__comparisonResultToBool(i.__compareToNumber(t,e),2^n);if(typeof t!=`number`)throw Error(`implementation bug`);return n===0?e<t:n===1?e<=t:n===2?e>t:n===3?e>=t:void 0}},{key:`__absoluteAdd`,value:function(e,t,n){if(e.length<t.length)return i.__absoluteAdd(t,e,n);if(e.length===0)return e;if(t.length===0)return e.sign===n?e:i.unaryMinus(e);var r=e.length;(e.__clzmsd()===0||t.length===e.length&&t.__clzmsd()===0)&&r++;for(var a,o=new i(r,n),s=0,c=0;c<t.length;c++)a=e.__digit(c)+t.__digit(c)+s,s=a>>>30,o.__setDigit(c,1073741823&a);for(;c<e.length;c++){var l=e.__digit(c)+s;s=l>>>30,o.__setDigit(c,1073741823&l)}return c<o.length&&o.__setDigit(c,s),o.__trim()}},{key:`__absoluteSub`,value:function(e,t,n){if(e.length===0)return e;if(t.length===0)return e.sign===n?e:i.unaryMinus(e);for(var r,a=new i(e.length,n),o=0,s=0;s<t.length;s++)r=e.__digit(s)-t.__digit(s)-o,o=1&r>>>30,a.__setDigit(s,1073741823&r);for(;s<e.length;s++){var c=e.__digit(s)-o;o=1&c>>>30,a.__setDigit(s,1073741823&c)}return a.__trim()}},{key:`__absoluteAddOne`,value:function(e,t){var n=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null,r=e.length;n===null?n=new i(r,t):n.sign=t;for(var a,o=1,s=0;s<r;s++)a=e.__digit(s)+o,o=a>>>30,n.__setDigit(s,1073741823&a);return o!==0&&n.__setDigitGrow(r,1),n}},{key:`__absoluteSubOne`,value:function(e,t){var n=e.length;t||=n;for(var r,a=new i(t,!1),o=1,s=0;s<n;s++)r=e.__digit(s)-o,o=1&r>>>30,a.__setDigit(s,1073741823&r);if(o!==0)throw Error(`implementation bug`);for(var c=n;c<t;c++)a.__setDigit(c,0);return a}},{key:`__absoluteAnd`,value:function(e,t){var n=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null,r=e.length,a=t.length,o=a;if(r<a){o=r;var s=e,c=r;e=t,r=a,t=s,a=c}var l=o;n===null?n=new i(l,!1):l=n.length;for(var u=0;u<o;u++)n.__setDigit(u,e.__digit(u)&t.__digit(u));for(;u<l;u++)n.__setDigit(u,0);return n}},{key:`__absoluteAndNot`,value:function(e,t){var n=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null,r=e.length,a=t.length,o=a;r<a&&(o=r);var s=r;n===null?n=new i(s,!1):s=n.length;for(var c=0;c<o;c++)n.__setDigit(c,e.__digit(c)&~t.__digit(c));for(;c<r;c++)n.__setDigit(c,e.__digit(c));for(;c<s;c++)n.__setDigit(c,0);return n}},{key:`__absoluteOr`,value:function(e,t){var n=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null,r=e.length,a=t.length,o=a;if(r<a){o=r;var s=e,c=r;e=t,r=a,t=s,a=c}var l=r;n===null?n=new i(l,!1):l=n.length;for(var u=0;u<o;u++)n.__setDigit(u,e.__digit(u)|t.__digit(u));for(;u<r;u++)n.__setDigit(u,e.__digit(u));for(;u<l;u++)n.__setDigit(u,0);return n}},{key:`__absoluteXor`,value:function(e,t){var n=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null,r=e.length,a=t.length,o=a;if(r<a){o=r;var s=e,c=r;e=t,r=a,t=s,a=c}var l=r;n===null?n=new i(l,!1):l=n.length;for(var u=0;u<o;u++)n.__setDigit(u,e.__digit(u)^t.__digit(u));for(;u<r;u++)n.__setDigit(u,e.__digit(u));for(;u<l;u++)n.__setDigit(u,0);return n}},{key:`__absoluteCompare`,value:function(e,t){var n=e.length-t.length;if(n!=0)return n;for(var r=e.length-1;0<=r&&e.__digit(r)===t.__digit(r);)r--;return 0>r?0:e.__unsignedDigit(r)>t.__unsignedDigit(r)?1:-1}},{key:`__multiplyAccumulate`,value:function(e,t,n,r){if(t!==0){for(var a=32767&t,o=t>>>15,s=0,c=0,l=0;l<e.length;l++,r++){var u=n.__digit(r),d=e.__digit(l),f=32767&d,p=d>>>15,m=i.__imul(f,a),h=i.__imul(f,o),g=i.__imul(p,a),_=i.__imul(p,o);u+=c+m+s,s=u>>>30,u&=1073741823,u+=((32767&h)<<15)+((32767&g)<<15),s+=u>>>30,c=_+(h>>>15)+(g>>>15),n.__setDigit(r,1073741823&u)}for(;s!==0||c!==0;r++){var v=n.__digit(r);v+=s+c,c=0,s=v>>>30,n.__setDigit(r,1073741823&v)}}}},{key:`__internalMultiplyAdd`,value:function(e,t,n,r,a){for(var o=n,s=0,c=0;c<r;c++){var l=e.__digit(c),u=i.__imul(32767&l,t),d=i.__imul(l>>>15,t),f=u+((32767&d)<<15)+s+o;o=f>>>30,s=d>>>15,a.__setDigit(c,1073741823&f)}if(a.length>r)for(a.__setDigit(r++,o+s);r<a.length;)a.__setDigit(r++,0);else if(o+s!==0)throw Error(`implementation bug`)}},{key:`__absoluteDivSmall`,value:function(e,t){var n=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;n===null&&(n=new i(e.length,!1));for(var r=0,a=2*e.length-1;0<=a;a-=2){var o=(r<<15|e.__halfDigit(a))>>>0,s=0|o/t;r=0|o%t,o=(r<<15|e.__halfDigit(a-1))>>>0;var c=0|o/t;r=0|o%t,n.__setDigit(a>>>1,s<<15|c)}return n}},{key:`__absoluteModSmall`,value:function(e,t){for(var n,r=0,i=2*e.length-1;0<=i;i--)n=(r<<15|e.__halfDigit(i))>>>0,r=0|n%t;return r}},{key:`__absoluteDivLarge`,value:function(e,t,n,r){var a=t.__halfDigitLength(),o=t.length,s=e.__halfDigitLength()-a,c=null;n&&(c=new i(s+2>>>1,!1),c.__initializeDigits());var l=new i(a+2>>>1,!1);l.__initializeDigits();var u=i.__clz15(t.__halfDigit(a-1));0<u&&(t=i.__specialLeftShift(t,u,0));for(var d=i.__specialLeftShift(e,u,1),f=t.__halfDigit(a-1),p=0,m=s;0<=m;m--){var h=32767,g=d.__halfDigit(m+a);if(g!==f){var _=(g<<15|d.__halfDigit(m+a-1))>>>0;h=0|_/f;for(var v=0|_%f,y=t.__halfDigit(a-2),b=d.__halfDigit(m+a-2);i.__imul(h,y)>>>0>(v<<16|b)>>>0&&(h--,v+=f,!(32767<v)););}i.__internalMultiplyAdd(t,h,0,o,l);var x=d.__inplaceSub(l,m,a+1);x!==0&&(x=d.__inplaceAdd(t,m,a),d.__setHalfDigit(m+a,32767&d.__halfDigit(m+a)+x),h--),n&&(1&m?p=h<<15:c.__setDigit(m>>>1,p|h))}if(r)return d.__inplaceRightShift(u),n?{quotient:c,remainder:d}:d;if(n)return c;throw Error(`unreachable`)}},{key:`__clz15`,value:function(e){return i.__clz30(e)-15}},{key:`__specialLeftShift`,value:function(e,t,n){var r=e.length,a=new i(r+n,!1);if(t===0){for(var o=0;o<r;o++)a.__setDigit(o,e.__digit(o));return 0<n&&a.__setDigit(r,0),a}for(var s,c=0,l=0;l<r;l++)s=e.__digit(l),a.__setDigit(l,1073741823&s<<t|c),c=s>>>30-t;return 0<n&&a.__setDigit(r,c),a}},{key:`__leftShiftByAbsolute`,value:function(e,t){var n=i.__toShiftAmount(t);if(0>n)throw RangeError(`BigInt too big`);var r=0|n/30,a=n%30,o=e.length,s=a!==0&&!!(e.__digit(o-1)>>>30-a),c=o+r+ +!!s,l=new i(c,e.sign);if(a===0){for(var u=0;u<r;u++)l.__setDigit(u,0);for(;u<c;u++)l.__setDigit(u,e.__digit(u-r))}else{for(var d=0,f=0;f<r;f++)l.__setDigit(f,0);for(var p,m=0;m<o;m++)p=e.__digit(m),l.__setDigit(m+r,1073741823&p<<a|d),d=p>>>30-a;if(s)l.__setDigit(o+r,d);else if(d!==0)throw Error(`implementation bug`)}return l.__trim()}},{key:`__rightShiftByAbsolute`,value:function(e,t){var n=e.length,r=e.sign,a=i.__toShiftAmount(t);if(0>a)return i.__rightShiftByMaximum(r);var o=0|a/30,s=a%30,c=n-o;if(0>=c)return i.__rightShiftByMaximum(r);var l=!1;if(r){var u=(1<<s)-1;if((e.__digit(o)&u)!=0)l=!0;else for(var d=0;d<o;d++)if(e.__digit(d)!==0){l=!0;break}}l&&s===0&&~e.__digit(n-1)==0&&c++;var f=new i(c,r);if(s===0){f.__setDigit(c-1,0);for(var p=o;p<n;p++)f.__setDigit(p-o,e.__digit(p))}else{for(var m,h=e.__digit(o)>>>s,g=n-o-1,_=0;_<g;_++)m=e.__digit(_+o+1),f.__setDigit(_,1073741823&m<<30-s|h),h=m>>>s;f.__setDigit(g,h)}return l&&(f=i.__absoluteAddOne(f,!0,f)),f.__trim()}},{key:`__rightShiftByMaximum`,value:function(e){return e?i.__oneDigit(1,!0):i.__zero()}},{key:`__toShiftAmount`,value:function(e){if(1<e.length)return-1;var t=e.__unsignedDigit(0);return t>i.__kMaxLengthBits?-1:t}},{key:`__toPrimitive`,value:function(e){var t=1<arguments.length&&arguments[1]!==void 0?arguments[1]:`default`;if(S(e)!==`object`||e.constructor===i)return e;if(typeof Symbol<`u`&&S(Symbol.toPrimitive)===`symbol`&&e[Symbol.toPrimitive]){var n=e[Symbol.toPrimitive](t);if(S(n)!==`object`)return n;throw TypeError(`Cannot convert object to primitive value`)}var r=e.valueOf;if(r){var a=r.call(e);if(S(a)!==`object`)return a}var o=e.toString;if(o){var s=o.call(e);if(S(s)!==`object`)return s}throw TypeError(`Cannot convert object to primitive value`)}},{key:`__toNumeric`,value:function(e){return i.__isBigInt(e)?e:+e}},{key:`__isBigInt`,value:function(e){return S(e)===`object`&&e!==null&&e.constructor===i}},{key:`__truncateToNBits`,value:function(e,t){for(var n=0|(e+29)/30,r=new i(n,t.sign),a=n-1,o=0;o<a;o++)r.__setDigit(o,t.__digit(o));var s=t.__digit(a);if(e%30!=0){var c=32-e%30;s=s<<c>>>c}return r.__setDigit(a,s),r.__trim()}},{key:`__truncateAndSubFromPowerOfTwo`,value:function(e,t,n){for(var r=Math.min,a,o=0|(e+29)/30,s=new i(o,n),c=0,l=o-1,u=0,d=r(l,t.length);c<d;c++)a=0-t.__digit(c)-u,u=1&a>>>30,s.__setDigit(c,1073741823&a);for(;c<l;c++)s.__setDigit(c,0|1073741823&-u);var f,p=l<t.length?t.__digit(l):0,m=e%30;if(m===0)f=0-p-u,f&=1073741823;else{var h=32-m;p=p<<h>>>h;var g=1<<32-h;f=g-p-u,f&=g-1}return s.__setDigit(l,f),s.__trim()}},{key:`__digitPow`,value:function(e,t){for(var n=1;0<t;)1&t&&(n*=e),t>>>=1,e*=e;return n}},{key:`__detectBigEndian`,value:function(){return i.__kBitConversionDouble[0]=-0,i.__kBitConversionInts[0]!==0}},{key:`__isOneDigitInt`,value:function(e){return(1073741823&e)===e}}])}(w(Array));return T.__kMaxLength=33554432,T.__kMaxLengthBits=T.__kMaxLength<<5,T.__kMaxBitsPerChar=[0,0,32,51,64,75,83,90,96,102,107,111,115,119,122,126,128,131,134,136,139,141,143,145,147,149,151,153,154,156,158,159,160,162,163,165,166],T.__kBitsPerCharTableShift=5,T.__kBitsPerCharTableMultiplier=1<<T.__kBitsPerCharTableShift,T.__kConversionChars=`0123456789abcdefghijklmnopqrstuvwxyz`.split(``),T.__kBitConversionBuffer=new ArrayBuffer(8),T.__kBitConversionDouble=new Float64Array(T.__kBitConversionBuffer),T.__kBitConversionInts=new Int32Array(T.__kBitConversionBuffer),T.__kBitConversionIntHigh=+!T.__detectBigEndian(),T.__kBitConversionIntLow=+!!T.__detectBigEndian(),T.__clz30=t?function(e){return t(e)-2}:function(e){var t=Math.LN2,n=Math.log;return e===0?30:0|29-(0|n(e>>>0)/t)},T.__imul=e||function(e,t){return 0|e*t},T})}))(),1),Qq=X.default.BigInt(0),$q=X.default.BigInt(1),eJ=X.default.BigInt(2),tJ=X.default.BigInt(10),nJ=X.default.BigInt(24),rJ=X.default.BigInt(60),iJ=X.default.BigInt(1e3),aJ=X.default.BigInt(1e6),oJ=X.default.BigInt(1e9),sJ=X.default.multiply(X.default.BigInt(3600),oJ),cJ=X.default.multiply(rJ,oJ),lJ=X.default.multiply(sJ,nJ);function uJ(e){return typeof e==`bigint`?X.default.BigInt(e.toString(10)):e}function dJ(e){return X.default.equal(X.default.remainder(e,eJ),Qq)}function fJ(e){return X.default.lessThan(e,Qq)?X.default.unaryMinus(e):e}function pJ(e,t){return X.default.lessThan(e,t)?-1:+!!X.default.greaterThan(e,t)}function mJ(e,t){return{quotient:X.default.divide(e,t),remainder:X.default.remainder(e,t)}}var hJ,gJ,_J=`slot-epochNanoSeconds`,vJ=`slot-iso-date`,yJ=`slot-iso-date-time`,bJ=`slot-time`,Z=`slot-calendar`,xJ=`slot-date-brand`,SJ=`slot-year-month-brand`,CJ=`slot-month-day-brand`,wJ=`slot-time-zone`,TJ=`slot-years`,EJ=`slot-months`,DJ=`slot-weeks`,OJ=`slot-days`,kJ=`slot-hours`,AJ=`slot-minutes`,jJ=`slot-seconds`,MJ=`slot-milliseconds`,NJ=`slot-microseconds`,PJ=`slot-nanoseconds`,FJ=`date`,IJ=`ym`,LJ=`md`,RJ=`time`,zJ=`datetime`,BJ=`instant`,VJ=`original`,HJ=`timezone-canonical`,UJ=`timezone-original`,WJ=`calendar-id`,GJ=`locale`,KJ=`options`,qJ=new WeakMap,JJ=Symbol.for(`@@Temporal__GetSlots`);(hJ=globalThis)[JJ]||(hJ[JJ]=function(e){return qJ.get(e)});var YJ=globalThis[JJ],XJ=Symbol.for(`@@Temporal__CreateSlots`);(gJ=globalThis)[XJ]||(gJ[XJ]=function(e){qJ.set(e,Object.create(null))});var ZJ=globalThis[XJ];function QJ(e,...t){if(!e||typeof e!=`object`)return!1;let n=YJ(e);return!!n&&t.every((e=>e in n))}function Q(e,t){let n=YJ(e)?.[t];if(n===void 0)throw TypeError(`Missing internal slot ${t}`);return n}function $J(e,t,n){let r=YJ(e);if(r===void 0)throw TypeError(`Missing slots for the given container`);if(r[t])throw TypeError(`${t} already has set`);r[t]=n}var eY={};function tY(e,t){Object.defineProperty(e.prototype,Symbol.toStringTag,{value:t,writable:!1,enumerable:!1,configurable:!0});let n=Object.getOwnPropertyNames(e);for(let t=0;t<n.length;t++){let r=n[t],i=Object.getOwnPropertyDescriptor(e,r);i.configurable&&i.enumerable&&(i.enumerable=!1,Object.defineProperty(e,r,i))}let r=Object.getOwnPropertyNames(e.prototype);for(let t=0;t<r.length;t++){let n=r[t],i=Object.getOwnPropertyDescriptor(e.prototype,n);i.configurable&&i.enumerable&&(i.enumerable=!1,Object.defineProperty(e.prototype,n,i))}nY(t,e),nY(`${t}.prototype`,e.prototype)}function nY(e,t){let n=`%${e}%`;if(eY[n]!==void 0)throw Error(`intrinsic ${e} already exists`);eY[n]=t}function rY(e){return eY[e]}function iY(e,t){let n=e;if(n===0)return{div:n,mod:n};let r=Math.sign(n);n=Math.abs(n);let i=Math.trunc(1+Math.log10(n));if(t>=i)return{div:0*r,mod:r*n};if(t===0)return{div:r*n,mod:0*r};let a=n.toPrecision(i);return{div:r*Number.parseInt(a.slice(0,i-t),10),mod:r*Number.parseInt(a.slice(i-t),10)}}function aY(e,t,n){let r=e,i=n;if(r===0)return i;let a=Math.sign(r)||Math.sign(i);r=Math.abs(r),i=Math.abs(i);let o=r.toPrecision(Math.trunc(1+Math.log10(r)));if(i===0)return a*Number.parseInt(o+`0`.repeat(t),10);let s=o+i.toPrecision(Math.trunc(1+Math.log10(i))).padStart(t,`0`);return a*Number.parseInt(s,10)}function oY(e,t){let n=t===`negative`;switch(e){case`ceil`:return n?`zero`:`infinity`;case`floor`:return n?`infinity`:`zero`;case`expand`:return`infinity`;case`trunc`:return`zero`;case`halfCeil`:return n?`half-zero`:`half-infinity`;case`halfFloor`:return n?`half-infinity`:`half-zero`;case`halfExpand`:return`half-infinity`;case`halfTrunc`:return`half-zero`;case`halfEven`:return`half-even`}}function sY(e,t,n,r,i){return i===`zero`?e:i===`infinity`?t:n<0?e:n>0?t:i===`half-zero`?e:i===`half-infinity`?t:r?e:t}var cY=class e{constructor(e){this.totalNs=uJ(e),this.sec=X.default.toNumber(X.default.divide(this.totalNs,oJ)),this.subsec=X.default.toNumber(X.default.remainder(this.totalNs,oJ))}static validateNew(t,n){if(X.default.greaterThan(fJ(t),e.MAX))throw RangeError(`${n} of duration time units cannot exceed ${e.MAX} s`);return new e(t)}static fromEpochNsDiff(t,n){let r=X.default.subtract(uJ(t),uJ(n));return new e(r)}static fromComponents(t,n,r,i,a,o){let s=X.default.add(X.default.add(X.default.add(X.default.add(X.default.add(X.default.BigInt(o),X.default.multiply(X.default.BigInt(a),iJ)),X.default.multiply(X.default.BigInt(i),aJ)),X.default.multiply(X.default.BigInt(r),oJ)),X.default.multiply(X.default.BigInt(n),cJ)),X.default.multiply(X.default.BigInt(t),sJ));return e.validateNew(s,`total`)}abs(){return new e(fJ(this.totalNs))}add(t){return e.validateNew(X.default.add(this.totalNs,t.totalNs),`sum`)}add24HourDays(t){return e.validateNew(X.default.add(this.totalNs,X.default.multiply(X.default.BigInt(t),lJ)),`sum`)}addToEpochNs(e){return X.default.add(uJ(e),this.totalNs)}cmp(e){return pJ(this.totalNs,e.totalNs)}divmod(t){let{quotient:n,remainder:r}=mJ(this.totalNs,X.default.BigInt(t));return{quotient:X.default.toNumber(n),remainder:new e(r)}}fdiv(e){let t=uJ(e),n=X.default.BigInt(t),{quotient:r,remainder:i}=mJ(this.totalNs,n),a=[],o,s=(X.default.lessThan(this.totalNs,Qq)?-1:1)*Math.sign(X.default.toNumber(t));for(;!X.default.equal(i,Qq)&&a.length<50;)i=X.default.multiply(i,tJ),{quotient:o,remainder:i}=mJ(i,n),a.push(Math.abs(X.default.toNumber(o)));return s*Number(fJ(r).toString()+`.`+a.join(``))}isZero(){return X.default.equal(this.totalNs,Qq)}round(t,n){let r=uJ(t);if(X.default.equal(r,$q))return this;let{quotient:i,remainder:a}=mJ(this.totalNs,r),o=X.default.lessThan(this.totalNs,Qq)?`negative`:`positive`,s=X.default.multiply(fJ(i),r),c=X.default.add(s,r),l=pJ(fJ(X.default.multiply(a,eJ)),r),u=oY(n,o),d=X.default.equal(fJ(this.totalNs),s)?s:sY(s,c,l,dJ(i),u),f=o===`positive`?d:X.default.unaryMinus(d);return e.validateNew(f,`rounding`)}sign(){return this.cmp(new e(Qq))}subtract(t){return e.validateNew(X.default.subtract(this.totalNs,t.totalNs),`difference`)}};cY.MAX=X.default.BigInt(`9007199254740991999999999`),cY.ZERO=new cY(Qq);var lY=/[A-Za-z._][A-Za-z._0-9+-]*/,uY=RegExp(`(?:(?:[+-](?:[01][0-9]|2[0-3])(?::?[0-5][0-9])?)|(?:${lY.source})(?:\\/(?:${lY.source}))*)`),dY=/(?:[+-]\d{6}|\d{4})/,fY=/(?:0[1-9]|1[0-2])/,pY=/(?:0[1-9]|[12]\d|3[01])/,mY=RegExp(`(${dY.source})(?:-(${fY.source})-(${pY.source})|(${fY.source})(${pY.source}))`),hY=/(\d{2})(?::(\d{2})(?::(\d{2})(?:[.,](\d{1,9}))?)?|(\d{2})(?:(\d{2})(?:[.,](\d{1,9}))?)?)?/,gY=/((?:[+-])(?:[01][0-9]|2[0-3])(?::?(?:[0-5][0-9])(?::?(?:[0-5][0-9])(?:[.,](?:\d{1,9}))?)?)?)/,_Y=RegExp(`([zZ])|${gY.source}?`),vY=/\[(!)?([a-z_][a-z0-9_-]*)=([A-Za-z0-9]+(?:-[A-Za-z0-9]+)*)\]/g,yY=new RegExp([`^${mY.source}`,`(?:(?:[tT]|\\s+)${hY.source}(?:${_Y.source})?)?`,`(?:\\[!?(${uY.source})\\])?`,`((?:${vY.source})*)$`].join(``)),bY=new RegExp([`^[tT]?${hY.source}`,`(?:${_Y.source})?`,`(?:\\[!?${uY.source}\\])?`,`((?:${vY.source})*)$`].join(``)),xY=RegExp(`^(${dY.source})-?(${fY.source})(?:\\[!?${uY.source}\\])?((?:${vY.source})*)$`),SY=RegExp(`^(?:--)?(${fY.source})-?(${pY.source})(?:\\[!?${uY.source}\\])?((?:${vY.source})*)$`),CY=/(\d+)(?:[.,](\d{1,9}))?/,wY=RegExp(`(?:${CY.source}H)?(?:${CY.source}M)?(?:${CY.source}S)?`),TY=RegExp(`^([+-])?P(?:(\\d+)Y)?(?:(\\d+)M)?(?:(\\d+)W)?(?:(\\d+)D)?(?:T(?!$)${wY.source})?$`,`i`),EY=864e5,DY=1e6*EY,OY=6e10,kY=1e8*EY,AY=O$(kY),jY=X.default.unaryMinus(AY),MY=X.default.add(X.default.subtract(jY,lJ),$q),NY=X.default.subtract(X.default.add(AY,lJ),$q),PY=146097*EY,FY=-271821,IY=275760,LY=Date.UTC(1847,0,1),RY=[`iso8601`,`hebrew`,`islamic`,`islamic-umalqura`,`islamic-tbla`,`islamic-civil`,`islamic-rgsa`,`islamicc`,`persian`,`ethiopic`,`ethioaa`,`ethiopic-amete-alem`,`coptic`,`chinese`,`dangi`,`roc`,`indian`,`buddhist`,`japanese`,`gregory`],zY=new Set([`ACT`,`AET`,`AGT`,`ART`,`AST`,`BET`,`BST`,`CAT`,`CNT`,`CST`,`CTT`,`EAT`,`ECT`,`IET`,`IST`,`JST`,`MIT`,`NET`,`NST`,`PLT`,`PNT`,`PRT`,`PST`,`SST`,`VST`]);function BY(e){return typeof e==`object`&&!!e||typeof e==`function`}function VY(e){if(typeof e==`bigint`)throw TypeError(`Cannot convert BigInt to number`);return Number(e)}function HY(e){if(typeof e==`symbol`)throw TypeError(`Cannot convert a Symbol value to a String`);return String(e)}function UY(e){let t=VY(e);if(t===0)return 0;if(Number.isNaN(t)||t===1/0||t===-1/0)throw RangeError(`invalid number value`);let n=Math.trunc(t);return n===0?0:n}function WY(e,t){let n=UY(e);if(n<=0)throw RangeError(t===void 0?`Cannot convert a number less than one to a positive integer`:`property '${t}' cannot be a a number less than one`);return n}function GY(e){let t=VY(e);if(Number.isNaN(t))throw RangeError(`not a number`);if(t===1/0||t===-1/0)throw RangeError(`infinity is out of range`);if(!function(e){if(typeof e!=`number`||Number.isNaN(e)||e===1/0||e===-1/0)return!1;let t=Math.abs(e);return Math.floor(t)===t}(t))throw RangeError(`unsupported fractional value ${e}`);return t===0?0:t}function KY(e,t){return String(e).padStart(t,`0`)}function qY(e){if(typeof e!=`string`)throw TypeError(`expected a string, not ${String(e)}`);return e}function JY(e,t){if(BY(e)){let t=e?.toString();if(typeof t==`string`||typeof t==`number`)return t;throw TypeError(`Cannot convert object to primitive value`)}return e}var YY=[`era`,`eraYear`,`year`,`month`,`monthCode`,`day`,`hour`,`minute`,`second`,`millisecond`,`microsecond`,`nanosecond`,`offset`,`timeZone`],XY={era:HY,eraYear:UY,year:UY,month:WY,monthCode:function(e){let t=qY(JY(e));if(t.length<3||t.length>4||t[0]!==`M`||`0123456789`.indexOf(t[1])===-1||`0123456789`.indexOf(t[2])===-1||t[1]+t[2]===`00`&&t[3]!==`L`||t[3]!==`L`&&t[3]!==void 0)throw RangeError(`bad month code ${t}; must match M01-M99 or M00L-M99L`);return t},day:WY,hour:UY,minute:UY,second:UY,millisecond:UY,microsecond:UY,nanosecond:UY,offset:function(e){let t=qY(JY(e));return tQ(t),t},timeZone:NZ},ZY={hour:0,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0},QY=[[`years`,`year`,`date`],[`months`,`month`,`date`],[`weeks`,`week`,`date`],[`days`,`day`,`date`],[`hours`,`hour`,`time`],[`minutes`,`minute`,`time`],[`seconds`,`second`,`time`],[`milliseconds`,`millisecond`,`time`],[`microseconds`,`microsecond`,`time`],[`nanoseconds`,`nanosecond`,`time`]],$Y=Object.fromEntries(QY.map((e=>[e[0],e[1]]))),eX=Object.fromEntries(QY.map((([e,t])=>[t,e]))),tX=QY.map((([,e])=>e)),nX={day:DY,hour:36e11,minute:6e10,second:1e9,millisecond:1e6,microsecond:1e3,nanosecond:1},rX=[`days`,`hours`,`microseconds`,`milliseconds`,`minutes`,`months`,`nanoseconds`,`seconds`,`weeks`,`years`],iX=Intl.DateTimeFormat,aX=new Map;function oX(e){let t=L$(e),n=aX.get(t);return n===void 0&&(n=new iX(`en-us`,{timeZone:t,hour12:!1,era:`short`,year:`numeric`,month:`numeric`,day:`numeric`,hour:`numeric`,minute:`numeric`,second:`numeric`}),aX.set(t,n)),n}function sX(e){return QJ(e,_J)&&!QJ(e,wJ,Z)}function cX(e){return QJ(e,TJ,EJ,OJ,kJ,AJ,jJ,MJ,NJ,PJ)}function lX(e){return QJ(e,xJ)}function uX(e){return QJ(e,bJ)}function dX(e){return QJ(e,yJ)}function fX(e){return QJ(e,SJ)}function pX(e){return QJ(e,CJ)}function mX(e){return QJ(e,_J,wJ,Z)}function $(e,t){if(!t(e))throw TypeError(`invalid receiver: method called with the wrong type of this-object`)}function hX(e){if(QJ(e,Z)||QJ(e,wJ))throw TypeError(`with() does not support a calendar or timeZone property`);if(uX(e))throw TypeError(`with() does not accept Temporal.PlainTime, use withPlainTime() instead`);if(e.calendar!==void 0)throw TypeError(`with() does not support a calendar property`);if(e.timeZone!==void 0)throw TypeError(`with() does not support a timeZone property`)}function gX(e,t){return t===`never`||t===`auto`&&e===`iso8601`?``:`[${t===`critical`?`!`:``}u-ca=${e}]`}function _X(e){let t,n,r=!1;for(vY.lastIndex=0;n=vY.exec(e);){let{1:i,2:a,3:o}=n;if(a===`u-ca`){if(t===void 0)t=o,r=i===`!`;else if(i===`!`||r)throw RangeError(`Invalid annotations in ${e}: more than one u-ca present with critical flag`)}else if(i===`!`)throw RangeError(`Unrecognized annotation: !${a}=${o}`)}return t}function vX(e){let t=yY.exec(e);if(!t)throw RangeError(`invalid RFC 9557 string: ${e}`);let n=_X(t[16]),r=t[1];if(r===`-000000`)throw RangeError(`invalid RFC 9557 string: ${e}`);let i=+r,a=+(t[2]??t[4]??1),o=+(t[3]??t[5]??1),s=t[6]!==void 0,c=+(t[6]??0),l=+(t[7]??t[10]??0),u=+(t[8]??t[11]??0);u===60&&(u=59);let d=(t[9]??t[12]??``)+`000000000`,f=+d.slice(0,3),p=+d.slice(3,6),m=+d.slice(6,9),h,g=!1;t[13]?(h=void 0,g=!0):t[14]&&(h=t[14]);let _=t[15];return MQ(i,a,o,c,l,u,f,p,m),{year:i,month:a,day:o,time:s?{hour:c,minute:l,second:u,millisecond:f,microsecond:p,nanosecond:m}:`start-of-day`,tzAnnotation:_,offset:h,z:g,calendar:n}}function yX(e){let t=bY.exec(e),n,r,i,a,o,s,c;if(t){c=_X(t[10]),n=+(t[1]??0),r=+(t[2]??t[5]??0),i=+(t[3]??t[6]??0),i===60&&(i=59);let e=(t[4]??t[7]??``)+`000000000`;if(a=+e.slice(0,3),o=+e.slice(3,6),s=+e.slice(6,9),t[8])throw RangeError(`Z designator not supported for PlainTime`)}else{let t,l;if({time:t,z:l,calendar:c}=vX(e),t===`start-of-day`)throw RangeError(`time is missing in string: ${e}`);if(l)throw RangeError(`Z designator not supported for PlainTime`);({hour:n,minute:r,second:i,millisecond:a,microsecond:o,nanosecond:s}=t)}if(jQ(n,r,i,a,o,s),/[tT ][0-9][0-9]/.test(e))return{hour:n,minute:r,second:i,millisecond:a,microsecond:o,nanosecond:s,calendar:c};try{let{month:t,day:n}=xX(e);kQ(1972,t,n)}catch{try{let{year:t,month:n}=bX(e);kQ(t,n,1)}catch{return{hour:n,minute:r,second:i,millisecond:a,microsecond:o,nanosecond:s,calendar:c}}}throw RangeError(`invalid RFC 9557 time-only string ${e}; may need a T prefix`)}function bX(e){let t=xY.exec(e),n,r,i,a;if(t){i=_X(t[3]);let o=t[1];if(o===`-000000`)throw RangeError(`invalid RFC 9557 string: ${e}`);if(n=+o,r=+t[2],a=1,i!==void 0&&i!==`iso8601`)throw RangeError(`YYYY-MM format is only valid with iso8601 calendar`)}else{let t;if({year:n,month:r,calendar:i,day:a,z:t}=vX(e),t)throw RangeError(`Z designator not supported for PlainYearMonth`)}return{year:n,month:r,calendar:i,referenceISODay:a}}function xX(e){let t=SY.exec(e),n,r,i,a;if(t){if(i=_X(t[3]),n=+t[1],r=+t[2],i!==void 0&&i!==`iso8601`)throw RangeError(`MM-DD format is only valid with iso8601 calendar`)}else{let t;if({month:n,day:r,calendar:i,year:a,z:t}=vX(e),t)throw RangeError(`Z designator not supported for PlainMonthDay`)}return{month:n,day:r,calendar:i,referenceISOYear:a}}var SX=RegExp(`^${uY.source}$`,`i`),CX=RegExp(`^([+-])([01][0-9]|2[0-3])(?::?([0-5][0-9])?)?$`);function wX(e){let t=z$.test(e)?`Seconds not allowed in offset time zone`:`Invalid time zone`;throw RangeError(`${t}: ${e}`)}function TX(e){return SX.test(e)||wX(e),CX.test(e)?{offsetMinutes:tQ(e)/6e10}:{tzName:e}}function EX(e,t,n,r){let i=e,a=t,o=n;switch(r){case`reject`:kQ(i,a,o);break;case`constrain`:({year:i,month:a,day:o}=DQ(i,a,o))}return{year:i,month:a,day:o}}function DX(e,t,n,r,i,a,o){let s=e,c=t,l=n,u=r,d=i,f=a;switch(o){case`reject`:jQ(s,c,l,u,d,f);break;case`constrain`:s=EQ(s,0,23),c=EQ(c,0,59),l=EQ(l,0,59),u=EQ(u,0,999),d=EQ(d,0,999),f=EQ(f,0,999)}return{hour:s,minute:c,second:l,millisecond:u,microsecond:d,nanosecond:f}}function OX(e){if(!BY(e))throw TypeError(`invalid duration-like`);let t={years:void 0,months:void 0,weeks:void 0,days:void 0,hours:void 0,minutes:void 0,seconds:void 0,milliseconds:void 0,microseconds:void 0,nanoseconds:void 0},n=!1;for(let r=0;r<rX.length;r++){let i=rX[r],a=e[i];a!==void 0&&(n=!0,t[i]=GY(a))}if(!n)throw TypeError(`invalid duration-like`);return t}function kX({years:e,months:t,weeks:n,days:r},i,a,o){return{years:e,months:o??t,weeks:a??n,days:i??r}}function AX(e,t){return{isoDate:e,time:t}}function jX(e){return F$(e,`overflow`,[`constrain`,`reject`],`constrain`)}function MX(e){return F$(e,`disambiguation`,[`compatible`,`earlier`,`later`,`reject`],`compatible`)}function NX(e,t){return F$(e,`roundingMode`,[`ceil`,`floor`,`expand`,`trunc`,`halfCeil`,`halfFloor`,`halfExpand`,`halfTrunc`,`halfEven`],t)}function PX(e,t){return F$(e,`offset`,[`prefer`,`use`,`ignore`,`reject`],t)}function FX(e){return F$(e,`calendarName`,[`auto`,`always`,`never`,`critical`],`auto`)}function IX(e){let t=e.roundingIncrement;if(t===void 0)return 1;let n=UY(t);if(n<1||n>1e9)throw RangeError(`roundingIncrement must be at least 1 and at most 1e9, not ${t}`);return n}function LX(e,t,n){let r=n?t:t-1;if(e>r)throw RangeError(`roundingIncrement must be at least 1 and less than ${r}, not ${e}`);if(t%e!=0)throw RangeError(`Rounding increment must divide evenly into ${t}`)}function RX(e){let t=e.fractionalSecondDigits;if(t===void 0)return`auto`;if(typeof t!=`number`){if(HY(t)!==`auto`)throw RangeError(`fractionalSecondDigits must be 'auto' or 0 through 9, not ${t}`);return`auto`}let n=Math.floor(t);if(!Number.isFinite(n)||n<0||n>9)throw RangeError(`fractionalSecondDigits must be 'auto' or 0 through 9, not ${t}`);return n}function zX(e,t){switch(e){case`minute`:return{precision:`minute`,unit:`minute`,increment:1};case`second`:return{precision:0,unit:`second`,increment:1};case`millisecond`:return{precision:3,unit:`millisecond`,increment:1};case`microsecond`:return{precision:6,unit:`microsecond`,increment:1};case`nanosecond`:return{precision:9,unit:`nanosecond`,increment:1}}switch(t){case`auto`:return{precision:t,unit:`nanosecond`,increment:1};case 0:return{precision:t,unit:`second`,increment:1};case 1:case 2:case 3:return{precision:t,unit:`millisecond`,increment:10**(3-t)};case 4:case 5:case 6:return{precision:t,unit:`microsecond`,increment:10**(6-t)};case 7:case 8:case 9:return{precision:t,unit:`nanosecond`,increment:10**(9-t)};default:throw RangeError(`fractionalSecondDigits must be 'auto' or 0 through 9, not ${t}`)}}var BX=Symbol(`~required~`);function VX(e,t,n,r,i=[]){let a=[];for(let e=0;e<QY.length;e++){let t=QY[e],r=t[1],i=t[2];n!==`datetime`&&n!==i||a.push(r)}a=a.concat(i);let o=r;o===BX?o=void 0:o!==void 0&&a.push(o);let s=[];s=s.concat(a);for(let e=0;e<a.length;e++){let t=eX[a[e]];t!==void 0&&s.push(t)}let c=F$(e,t,s,o);if(c===void 0&&r===BX)throw RangeError(`${t} is required`);return c&&c in $Y?$Y[c]:c}function HX(e){let t=e.relativeTo;if(t===void 0)return{};let n,r,i,a,o,s=`option`,c=!1;if(BY(t)){if(mX(t))return{zonedRelativeTo:t};if(lX(t))return{plainRelativeTo:t};if(dX(t))return{plainRelativeTo:uZ(Q(t,yJ).isoDate,Q(t,Z))};i=OZ(t);let e=XX(i,t,[`year`,`month`,`monthCode`,`day`],[`hour`,`minute`,`second`,`millisecond`,`microsecond`,`nanosecond`,`offset`,`timeZone`],[]);({isoDate:n,time:r}=$X(i,e,`constrain`)),{offset:o,timeZone:a}=e,o===void 0&&(s=`wall`)}else{let e,l,u,d,f;if({year:u,month:d,day:f,time:r,calendar:i,tzAnnotation:e,offset:o,z:l}=vX(qY(t)),e)a=NZ(e),l?s=`exact`:o||(s=`wall`),c=!0;else if(l)throw RangeError(`Z designator not supported for PlainDate relativeTo; either remove the Z or add a bracketed time zone`);i||=`iso8601`,i=I$(i),n={year:u,month:d,day:f}}return a===void 0?{plainRelativeTo:uZ(n,i)}:{zonedRelativeTo:SZ(sZ(n,r,s,s===`option`?tQ(o):0,a,`compatible`,`reject`,c),a,i)}}function UX(e){return Q(e,TJ)===0?Q(e,EJ)===0?Q(e,DJ)===0?Q(e,OJ)===0?Q(e,kJ)===0?Q(e,AJ)===0?Q(e,jJ)===0?Q(e,MJ)===0?Q(e,NJ)===0?`nanosecond`:`microsecond`:`millisecond`:`second`:`minute`:`hour`:`day`:`week`:`month`:`year`}function WX(e,t){return tX.indexOf(e)>tX.indexOf(t)?t:e}function GX(e){return e===`year`||e===`month`||e===`week`}function KX(e){return GX(e)||e===`day`?`date`:`time`}function qX(e){return rY(`%calendarImpl%`)(e)}function JX(e){return rY(`%calendarImpl%`)(Q(e,Z))}function YX(e,t,n=`date`){let r=Object.create(null),i=qX(e).isoToDate(t,{year:!0,monthCode:!0,day:!0});return r.monthCode=i.monthCode,n!==`month-day`&&n!==`date`||(r.day=i.day),n!==`year-month`&&n!==`date`||(r.year=i.year),r}function XX(e,t,n,r,i){let a=qX(e).extraFields(n),o=n.concat(r,a),s=Object.create(null),c=!1;o.sort();for(let e=0;e<o.length;e++){let n=o[e],r=t[n];if(r!==void 0)c=!0,s[n]=(0,XY[n])(r);else if(i!==`partial`){if(i.includes(n))throw TypeError(`required property '${n}' missing or undefined`);s[n]=ZY[n]}}if(i===`partial`&&!c)throw TypeError(`no supported properties found`);return s}function ZX(e,t=`complete`){let n=[`hour`,`microsecond`,`millisecond`,`minute`,`nanosecond`,`second`],r=!1,i=Object.create(null);for(let a=0;a<n.length;a++){let o=n[a],s=e[o];s===void 0?t===`complete`&&(i[o]=0):(i[o]=UY(s),r=!0)}if(!r)throw TypeError(`invalid time-like`);return i}function QX(e,t){if(BY(e)){if(lX(e))return jX(N$(t)),uZ(Q(e,vJ),Q(e,Z));if(mX(e)){let n=LZ(Q(e,wJ),Q(e,_J));return jX(N$(t)),uZ(n.isoDate,Q(e,Z))}if(dX(e))return jX(N$(t)),uZ(Q(e,yJ).isoDate,Q(e,Z));let n=OZ(e);return uZ(AZ(n,XX(n,e,[`year`,`month`,`monthCode`,`day`],[],[]),jX(N$(t))),n)}let{year:n,month:r,day:i,calendar:a,z:o}=vX(qY(e));if(o)throw RangeError(`Z designator not supported for PlainDate`);return a||=`iso8601`,a=I$(a),jX(N$(t)),uZ({year:n,month:r,day:i},a)}function $X(e,t,n){return AX(AZ(e,t,n),DX(t.hour,t.minute,t.second,t.millisecond,t.microsecond,t.nanosecond,n))}function eZ(e,t){let n,r,i;if(BY(e)){if(dX(e))return jX(N$(t)),fZ(Q(e,yJ),Q(e,Z));if(mX(e)){let n=LZ(Q(e,wJ),Q(e,_J));return jX(N$(t)),fZ(n,Q(e,Z))}if(lX(e))return jX(N$(t)),fZ(AX(Q(e,vJ),{deltaDays:0,hour:0,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0}),Q(e,Z));i=OZ(e);let a=XX(i,e,[`year`,`month`,`monthCode`,`day`],[`hour`,`minute`,`second`,`millisecond`,`microsecond`,`nanosecond`],[]),o=jX(N$(t));({isoDate:n,time:r}=$X(i,a,o))}else{let a,o,s,c;if({year:o,month:s,day:c,time:r,calendar:i,z:a}=vX(qY(e)),a)throw RangeError(`Z designator not supported for PlainDateTime`);r===`start-of-day`&&(r={deltaDays:0,hour:0,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0}),MQ(o,s,c,r.hour,r.minute,r.second,r.millisecond,r.microsecond,r.nanosecond),i||=`iso8601`,i=I$(i),jX(N$(t)),n={year:o,month:s,day:c}}return fZ(AX(n,r),i)}function tZ(e){let t=rY(`%Temporal.Duration%`);if(cX(e))return new t(Q(e,TJ),Q(e,EJ),Q(e,DJ),Q(e,OJ),Q(e,kJ),Q(e,AJ),Q(e,jJ),Q(e,MJ),Q(e,NJ),Q(e,PJ));if(!BY(e))return function(e){let{years:t,months:n,weeks:r,days:i,hours:a,minutes:o,seconds:s,milliseconds:c,microseconds:l,nanoseconds:u}=function(e){let t=TY.exec(e);if(!t||t.every(((e,t)=>t<2||e===void 0)))throw RangeError(`invalid duration: ${e}`);let n=t[1]===`-`?-1:1,r=t[2]===void 0?0:UY(t[2])*n,i=t[3]===void 0?0:UY(t[3])*n,a=t[4]===void 0?0:UY(t[4])*n,o=t[5]===void 0?0:UY(t[5])*n,s=t[6]===void 0?0:UY(t[6])*n,c=t[7],l=t[8],u=t[9],d=t[10],f=t[11],p=0,m=0,h=0;if(c!==void 0){if(l??u??d??f)throw RangeError(`only the smallest unit can be fractional`);h=3600*UY((c+`000000000`).slice(0,9))*n}else if(p=l===void 0?0:UY(l)*n,u!==void 0){if(d??f)throw RangeError(`only the smallest unit can be fractional`);h=60*UY((u+`000000000`).slice(0,9))*n}else m=d===void 0?0:UY(d)*n,f!==void 0&&(h=UY((f+`000000000`).slice(0,9))*n);let g=h%1e3,_=Math.trunc(h/1e3)%1e3,v=Math.trunc(h/1e6)%1e3;return m+=Math.trunc(h/1e9)%60,p+=Math.trunc(h/6e10),LQ(r,i,a,o,s,p,m,v,_,g),{years:r,months:i,weeks:a,days:o,hours:s,minutes:p,seconds:m,milliseconds:v,microseconds:_,nanoseconds:g}}(e);return new(rY(`%Temporal.Duration%`))(t,n,r,i,a,o,s,c,l,u)}(qY(e));let n={years:0,months:0,weeks:0,days:0,hours:0,minutes:0,seconds:0,milliseconds:0,microseconds:0,nanoseconds:0},r=OX(e);for(let e=0;e<rX.length;e++){let t=rX[e],i=r[t];i!==void 0&&(n[t]=i)}return new t(n.years,n.months,n.weeks,n.days,n.hours,n.minutes,n.seconds,n.milliseconds,n.microseconds,n.nanoseconds)}function nZ(e){let t;if(BY(e)){if(sX(e)||mX(e))return bZ(Q(e,_J));t=JY(e)}else t=e;let{year:n,month:r,day:i,time:a,offset:o,z:s}=function(e){let t=vX(e);if(!t.z&&!t.offset)throw RangeError(`Temporal.Instant requires a time zone offset`);return t}(qY(t)),{hour:c=0,minute:l=0,second:u=0,millisecond:d=0,microsecond:f=0,nanosecond:p=0}=a===`start-of-day`?{}:a,m=SQ(n,r,i,c,l,u,d,f,p-(s?0:tQ(o)));return WQ(m.isoDate),bZ(uQ(m))}function rZ(e,t){if(BY(e)){if(pX(e))return jX(N$(t)),mZ(Q(e,vJ),Q(e,Z));let n;return QJ(e,Z)?n=Q(e,Z):(n=e.calendar,n===void 0&&(n=`iso8601`),n=DZ(n)),mZ(MZ(n,XX(n,e,[`year`,`month`,`monthCode`,`day`],[],[]),jX(N$(t))),n)}let{month:n,day:r,referenceISOYear:i,calendar:a}=xX(qY(e));if(a===void 0&&(a=`iso8601`),a=I$(a),jX(N$(t)),a===`iso8601`)return mZ({year:1972,month:n,day:r},a);let o={year:i,month:n,day:r};return AQ(o),o=MZ(a,YX(a,o,`month-day`),`constrain`),mZ(o,a)}function iZ(e,t){let n;if(BY(e)){if(uX(e))return jX(N$(t)),gZ(Q(e,bJ));if(dX(e))return jX(N$(t)),gZ(Q(e,yJ).time);if(mX(e)){let n=LZ(Q(e,wJ),Q(e,_J));return jX(N$(t)),gZ(n.time)}let{hour:r,minute:i,second:a,millisecond:o,microsecond:s,nanosecond:c}=ZX(e);n=DX(r,i,a,o,s,c,jX(N$(t)))}else n=yX(qY(e)),jX(N$(t));return gZ(n)}function aZ(e){return e===void 0?{deltaDays:0,hour:0,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0}:Q(iZ(e),bJ)}function oZ(e,t){if(BY(e)){if(fX(e))return jX(N$(t)),vZ(Q(e,vJ),Q(e,Z));let n=OZ(e);return vZ(jZ(n,XX(n,e,[`year`,`month`,`monthCode`],[],[]),jX(N$(t))),n)}let{year:n,month:r,referenceISODay:i,calendar:a}=bX(qY(e));a===void 0&&(a=`iso8601`),a=I$(a),jX(N$(t));let o={year:n,month:r,day:i};return IQ(o),o=jZ(a,YX(a,o,`year-month`),`constrain`),vZ(o,a)}function sZ(e,t,n,r,i,a,o,s){if(t===`start-of-day`)return VZ(i,e);let c=AX(e,t);if(n===`wall`||o===`ignore`)return RZ(i,c,a);if(n===`exact`||o===`use`){let n=SQ(e.year,e.month,e.day,t.hour,t.minute,t.second,t.millisecond,t.microsecond,t.nanosecond-r);WQ(n.isoDate);let i=uQ(n);return FQ(i),i}WQ(e);let l=uQ(c),u=BZ(i,c);for(let e=0;e<u.length;e++){let t=u[e],n=X.default.toNumber(X.default.subtract(l,t)),i=_$(n,6e10,`halfExpand`);if(n===r||s&&i===r)return t}if(o===`reject`){let e=IZ(r),t=XZ(c,`iso8601`,`auto`);throw RangeError(`Offset ${e} is invalid for ${t} in ${i}`)}return zZ(u,i,c,a)}function cZ(e,t){let n,r,i,a,o,s,c,l=!1,u=`option`;if(BY(e)){if(mX(e)){let n=N$(t);return MX(n),PX(n,`reject`),jX(n),SZ(Q(e,_J),Q(e,wJ),Q(e,Z))}o=OZ(e);let l=XX(o,e,[`year`,`month`,`monthCode`,`day`],[`hour`,`minute`,`second`,`millisecond`,`microsecond`,`nanosecond`,`offset`,`timeZone`],[`timeZone`]);({offset:a,timeZone:i}=l),a===void 0&&(u=`wall`);let d=N$(t);s=MX(d),c=PX(d,`reject`);let f=jX(d);({isoDate:n,time:r}=$X(o,l,f))}else{let d,f,p,m,h;({year:p,month:m,day:h,time:r,tzAnnotation:d,offset:a,z:f,calendar:o}=function(e){let t=vX(e);if(!t.tzAnnotation)throw RangeError(`Temporal.ZonedDateTime requires a time zone ID in brackets`);return t}(qY(e))),i=NZ(d),f?u=`exact`:a||(u=`wall`),o||=`iso8601`,o=I$(o),l=!0;let g=N$(t);s=MX(g),c=PX(g,`reject`),jX(g),n={year:p,month:m,day:h}}let d=0;return u===`option`&&(d=tQ(a)),SZ(sZ(n,r,u,d,i,s,c,l),i,o)}function lZ(e,t,n){AQ(t),ZJ(e),$J(e,vJ,t),$J(e,Z,n),$J(e,xJ,!0)}function uZ(e,t){let n=rY(`%Temporal.PlainDate%`),r=Object.create(n.prototype);return lZ(r,e,t),r}function dZ(e,t,n){NQ(t),ZJ(e),$J(e,yJ,t),$J(e,Z,n)}function fZ(e,t){let n=rY(`%Temporal.PlainDateTime%`),r=Object.create(n.prototype);return dZ(r,e,t),r}function pZ(e,t,n){AQ(t),ZJ(e),$J(e,vJ,t),$J(e,Z,n),$J(e,CJ,!0)}function mZ(e,t){let n=rY(`%Temporal.PlainMonthDay%`),r=Object.create(n.prototype);return pZ(r,e,t),r}function hZ(e,t){ZJ(e),$J(e,bJ,t)}function gZ(e){let t=rY(`%Temporal.PlainTime%`),n=Object.create(t.prototype);return hZ(n,e),n}function _Z(e,t,n){IQ(t),ZJ(e),$J(e,vJ,t),$J(e,Z,n),$J(e,SJ,!0)}function vZ(e,t){let n=rY(`%Temporal.PlainYearMonth%`),r=Object.create(n.prototype);return _Z(r,e,t),r}function yZ(e,t){FQ(t),ZJ(e),$J(e,_J,t)}function bZ(e){let t=rY(`%Temporal.Instant%`),n=Object.create(t.prototype);return yZ(n,e),n}function xZ(e,t,n,r){FQ(t),ZJ(e),$J(e,_J,t),$J(e,wJ,n),$J(e,Z,r)}function SZ(e,t,n=`iso8601`){let r=rY(`%Temporal.ZonedDateTime%`),i=Object.create(r.prototype);return xZ(i,e,t,n),i}function CZ(e){return YY.filter((t=>e[t]!==void 0))}function wZ(e,t,n){let r=CZ(n),i=qX(e).fieldKeysToIgnore(r),a=Object.create(null),o=CZ(t);for(let e=0;e<YY.length;e++){let s,c=YY[e];o.includes(c)&&!i.includes(c)&&(s=t[c]),r.includes(c)&&(s=n[c]),s!==void 0&&(a[c]=s)}return a}function TZ(e,t,n,r){let i=qX(e).dateAdd(t,n,r);return AQ(i),i}function EZ(e,t,n,r){return qX(e).dateUntil(t,n,r)}function DZ(e){if(BY(e)&&QJ(e,Z))return Q(e,Z);let t=qY(e);try{return I$(t)}catch{}let n;try{({calendar:n}=vX(t))}catch{try{({calendar:n}=yX(t))}catch{try{({calendar:n}=bX(t))}catch{({calendar:n}=xX(t))}}}return n||=`iso8601`,I$(n)}function OZ(e){if(QJ(e,Z))return Q(e,Z);let{calendar:t}=e;return t===void 0?`iso8601`:DZ(t)}function kZ(e,t){return I$(e)===I$(t)}function AZ(e,t,n){let r=qX(e);r.resolveFields(t,`date`);let i=r.dateToISO(t,n);return AQ(i),i}function jZ(e,t,n){let r=qX(e);r.resolveFields(t,`year-month`),t.day=1;let i=r.dateToISO(t,n);return IQ(i),i}function MZ(e,t,n){let r=qX(e);r.resolveFields(t,`month-day`);let i=r.monthDayToISOReferenceDate(t,n);return AQ(i),i}function NZ(e){if(BY(e)&&mX(e))return Q(e,wJ);let t=qY(e);if(t===`UTC`)return`UTC`;let{tzName:n,offsetMinutes:r}=function(e){let{tzAnnotation:t,offset:n,z:r}=function(e){if(SX.test(e))return{tzAnnotation:e,offset:void 0,z:!1};try{let{tzAnnotation:t,offset:n,z:r}=vX(e);if(r||t||n)return{tzAnnotation:t,offset:n,z:r}}catch{}wX(e)}(e);return t?TX(t):r?TX(`UTC`):n?TX(n):void 0}(t);if(r!==void 0)return sQ(r);let i=iQ(n);if(!i)throw RangeError(`Unrecognized time zone ${n}`);return i.identifier}function PZ(e,t){if(e===t)return!0;let n=TX(e).offsetMinutes,r=TX(t).offsetMinutes;if(n===void 0&&r===void 0){let n=iQ(t);if(!n)return!1;let r=iQ(e);return!!r&&r.primaryIdentifier===n.primaryIdentifier}return n===r}function FZ(e,t){let n=TX(e).offsetMinutes;return n===void 0?oQ(e,t):6e10*n}function IZ(e){let t=e<0?`-`:`+`,n=Math.abs(e),r=Math.floor(n/36e11),i=Math.floor(n/6e10)%60,a=Math.floor(n/1e9)%60,o=n%1e9;return`${t}${GZ(r,i,a,o,a===0&&o===0?`minute`:`auto`)}`}function LZ(e,t){let n=FZ(e,t),{isoDate:{year:r,month:i,day:a},time:{hour:o,minute:s,second:c,millisecond:l,microsecond:u,nanosecond:d}}=dQ(t);return SQ(r,i,a,o,s,c,l,u,d+n)}function RZ(e,t,n){return zZ(BZ(e,t),e,t,n)}function zZ(e,t,n,r){let i=e.length;if(i===1)return e[0];if(i)switch(r){case`compatible`:case`earlier`:return e[0];case`later`:return e[i-1];case`reject`:throw RangeError(`multiple instants found`)}if(r===`reject`)throw RangeError(`multiple instants found`);let a=uQ(n),o=X.default.subtract(a,lJ);FQ(o);let s=FZ(t,o),c=X.default.add(a,lJ);FQ(c);let l=FZ(t,c)-s;switch(r){case`earlier`:{let e=cY.fromComponents(0,0,0,0,0,-l),r=s$(n.time,e);return BZ(t,AX(xQ(n.isoDate.year,n.isoDate.month,n.isoDate.day+r.deltaDays),r))[0]}case`compatible`:case`later`:{let e=cY.fromComponents(0,0,0,0,0,l),r=s$(n.time,e),i=BZ(t,AX(xQ(n.isoDate.year,n.isoDate.month,n.isoDate.day+r.deltaDays),r));return i[i.length-1]}}}function BZ(e,t){if(e===`UTC`)return WQ(t.isoDate),[uQ(t)];let n=TX(e).offsetMinutes;if(n!==void 0){let e=SQ(t.isoDate.year,t.isoDate.month,t.isoDate.day,t.time.hour,t.time.minute-n,t.time.second,t.time.millisecond,t.time.microsecond,t.time.nanosecond);WQ(e.isoDate);let r=uQ(e);return FQ(r),[r]}return WQ(t.isoDate),function(e,t){let n=uQ(t),r=X.default.subtract(n,lJ);X.default.lessThan(r,jY)&&(r=n);let i=X.default.add(n,lJ);X.default.greaterThan(i,AY)&&(i=n);let a=oQ(e,r),o=oQ(e,i);return(a===o?[a]:[a,o]).map((r=>{let i=X.default.subtract(n,X.default.BigInt(r));if(T$(t,function(e,t){let{epochMilliseconds:n,time:{millisecond:r,microsecond:i,nanosecond:a}}=dQ(t),{year:o,month:s,day:c,hour:l,minute:u,second:d}=mQ(e,n);return SQ(o,s,c,l,u,d,r,i,a)}(e,i))===0)return FQ(i),i})).filter((e=>e!==void 0))}(e,t)}function VZ(e,t){let n=AX(t,{deltaDays:0,hour:0,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0}),r=BZ(e,n);if(r.length)return r[0];let i=uQ(n),a=X.default.subtract(i,lJ);return FQ(a),fQ(e,a)}function HZ(e){let t;return t=e<0||e>9999?(e<0?`-`:`+`)+KY(Math.abs(e),6):KY(e,4),t}function UZ(e){return KY(e,2)}function WZ(e,t){let n;if(t===`auto`){if(e===0)return``;n=KY(e,9).replace(/0+$/,``)}else{if(t===0)return``;n=KY(e,9).slice(0,t)}return`.${n}`}function GZ(e,t,n,r,i){let a=`${UZ(e)}:${UZ(t)}`;return i===`minute`||(a+=`:${UZ(n)}`,a+=WZ(r,i)),a}function KZ(e,t,n){let r=t;r===void 0&&(r=`UTC`);let i=Q(e,_J),a=XZ(LZ(r,i),`iso8601`,n,`never`),o=`Z`;return t!==void 0&&(o=cQ(FZ(r,i))),`${a}${o}`}function qZ(e,t){let n=Q(e,TJ),r=Q(e,EJ),i=Q(e,DJ),a=Q(e,OJ),o=Q(e,kJ),s=Q(e,AJ),c=_Q(e),l=``;n!==0&&(l+=`${Math.abs(n)}Y`),r!==0&&(l+=`${Math.abs(r)}M`),i!==0&&(l+=`${Math.abs(i)}W`),a!==0&&(l+=`${Math.abs(a)}D`);let u=``;o!==0&&(u+=`${Math.abs(o)}H`),s!==0&&(u+=`${Math.abs(s)}M`);let d=cY.fromComponents(0,0,Q(e,jJ),Q(e,MJ),Q(e,NJ),Q(e,PJ));d.isZero()&&![`second`,`millisecond`,`microsecond`,`nanosecond`].includes(UX(e))&&t===`auto`||(u+=`${Math.abs(d.sec)}${WZ(Math.abs(d.subsec),t)}S`);let f=`${c<0?`-`:``}P${l}`;return u&&(f=`${f}T${u}`),f}function JZ(e,t=`auto`){let{year:n,month:r,day:i}=Q(e,vJ);return`${HZ(n)}-${UZ(r)}-${UZ(i)}${gX(Q(e,Z),t)}`}function YZ({hour:e,minute:t,second:n,millisecond:r,microsecond:i,nanosecond:a},o){return GZ(e,t,n,1e6*r+1e3*i+a,o)}function XZ(e,t,n,r=`auto`){let{isoDate:{year:i,month:a,day:o},time:{hour:s,minute:c,second:l,millisecond:u,microsecond:d,nanosecond:f}}=e;return`${HZ(i)}-${UZ(a)}-${UZ(o)}T${GZ(s,c,l,1e6*u+1e3*d+f,n)}${gX(t,r)}`}function ZZ(e,t=`auto`){let{year:n,month:r,day:i}=Q(e,vJ),a=`${UZ(r)}-${UZ(i)}`,o=Q(e,Z);t!==`always`&&t!==`critical`&&o===`iso8601`||(a=`${HZ(n)}-${a}`);let s=gX(o,t);return s&&(a+=s),a}function QZ(e,t=`auto`){let{year:n,month:r,day:i}=Q(e,vJ),a=`${HZ(n)}-${UZ(r)}`,o=Q(e,Z);t!==`always`&&t!==`critical`&&o===`iso8601`||(a+=`-${UZ(i)}`);let s=gX(o,t);return s&&(a+=s),a}function $Z(e,t,n=`auto`,r=`auto`,i=`auto`,a=void 0){let o=Q(e,_J);if(a){let{unit:e,increment:t,roundingMode:n}=a;o=v$(o,t,e,n)}let s=Q(e,wJ),c=FZ(s,o),l=XZ(LZ(s,o),`iso8601`,t,`never`);return i!==`never`&&(l+=cQ(c)),r!==`never`&&(l+=`[${r===`critical`?`!`:``}${s}]`),l+=gX(Q(e,Z),n),l}function eQ(e){return CX.test(e)}function tQ(e){let t=B$.exec(e);if(!t)throw RangeError(`invalid time zone offset: ${e}; must match ±HH:MM[:SS.SSSSSSSSS]`);return(t[1]===`-`?-1:1)*(1e9*(60*(60*t[2]+ +(t[3]||0))+ +(t[4]||0))+ +((t[5]||0)+`000000000`).slice(0,9))}var nQ,rQ=Object.assign(Object.create(null),{"/":!0,"-":!0,_:!0});function iQ(e){if(nQ===void 0){let e=Intl.supportedValuesOf?.(`timeZone`);if(e){nQ=new Map;for(let t=0;t<e.length;t++){let n=e[t];nQ.set(L$(n),n)}}else nQ=null}let t=L$(e),n=nQ?.get(t);if(n)return{identifier:n,primaryIdentifier:n};try{n=oX(e).resolvedOptions().timeZone}catch{return}if(t===`antarctica/south_pole`&&(n=`Antarctica/McMurdo`),zY.has(e))throw RangeError(`${e} is a legacy time zone identifier from ICU. Use ${n} instead`);let r=[...t].map(((e,n)=>n===0||rQ[t[n-1]]?e.toUpperCase():e)).join(``).split(`/`);if(r.length===1)return t===`gb-eire`?{identifier:`GB-Eire`,primaryIdentifier:n}:{identifier:t.length<=3||/[-0-9]/.test(t)?t.toUpperCase():r[0],primaryIdentifier:n};if(r[0]===`Etc`)return{identifier:`Etc/${[`Zulu`,`Greenwich`,`Universal`].includes(r[1])?r[1]:r[1].toUpperCase()}`,primaryIdentifier:n};if(r[0]===`Us`)return{identifier:`US/${r[1]}`,primaryIdentifier:n};let i=new Map([[`Act`,`ACT`],[`Lhi`,`LHI`],[`Nsw`,`NSW`],[`Dar_Es_Salaam`,`Dar_es_Salaam`],[`Port_Of_Spain`,`Port_of_Spain`],[`Port-Au-Prince`,`Port-au-Prince`],[`Isle_Of_Man`,`Isle_of_Man`],[`Comodrivadavia`,`ComodRivadavia`],[`Knox_In`,`Knox_IN`],[`Dumontdurville`,`DumontDUrville`],[`Mcmurdo`,`McMurdo`],[`Denoronha`,`DeNoronha`],[`Easterisland`,`EasterIsland`],[`Bajanorte`,`BajaNorte`],[`Bajasur`,`BajaSur`]]);return r[1]=i.get(r[1])??r[1],r.length>2&&(r[2]=i.get(r[2])??r[2]),{identifier:r.join(`/`),primaryIdentifier:n}}function aQ(e,t){let{year:n,month:r,day:i,hour:a,minute:o,second:s}=mQ(e,t),c=t%1e3;return c<0&&(c+=1e3),1e6*(lQ({isoDate:{year:n,month:r,day:i},time:{hour:a,minute:o,second:s,millisecond:c}})-t)}function oQ(e,t){return aQ(e,D$(t,`floor`))}function sQ(e){let t=e<0?`-`:`+`,n=Math.abs(e);return`${t}${GZ(Math.floor(n/60),n%60,0,0,`minute`)}`}function cQ(e){return sQ(_$(e,OY,`halfExpand`)/6e10)}function lQ({isoDate:{year:e,month:t,day:n},time:{hour:r,minute:i,second:a,millisecond:o}}){let s=e%400,c=(e-s)/400,l=new Date;return l.setUTCHours(r,i,a,o),l.setUTCFullYear(s,t-1,n),l.getTime()+PY*c}function uQ(e){let t=lQ(e),n=1e3*e.time.microsecond+e.time.nanosecond;return X.default.add(O$(t),X.default.BigInt(n))}function dQ(e){let t=D$(e,`trunc`),n=X.default.toNumber(X.default.remainder(e,aJ));n<0&&(n+=1e6,--t);let r=Math.floor(n/1e3)%1e3,i=n%1e3,a=new Date(t);return{epochMilliseconds:t,isoDate:{year:a.getUTCFullYear(),month:a.getUTCMonth()+1,day:a.getUTCDate()},time:{hour:a.getUTCHours(),minute:a.getUTCMinutes(),second:a.getUTCSeconds(),millisecond:a.getUTCMilliseconds(),microsecond:r,nanosecond:i}}}function fQ(e,t){if(e===`UTC`)return null;let n=D$(t,`floor`);if(n<LY)return fQ(e,O$(LY));let r=Math.max(n,Date.now())+366*EY*3,i=n,a=aQ(e,i),o=i,s=a;for(;a===s&&i<r;){if(o=i+2*EY*7,o>kY)return null;s=aQ(e,o),a===s&&(i=o)}return a===s?null:O$(V$((t=>aQ(e,t)),i,o,a,s))}function pQ(e,t){if(e===`UTC`)return null;let n=D$(t,`ceil`),r=Date.now(),i=r+366*EY*3;if(n>i){let t=pQ(e,O$(i));if(t===null||X.default.lessThan(t,O$(r)))return t}if(e===`Africa/Casablanca`||e===`Africa/El_Aaiun`){let t=Date.UTC(2088,0,1);if(t<n)return pQ(e,O$(t))}let a=n-1;if(a<LY)return null;let o=aQ(e,a),s=a,c=o;for(;o===c&&a>LY;){if(s=a-2*EY*7,s<LY)return null;c=aQ(e,s),o===c&&(a=s)}return o===c?null:O$(V$((t=>aQ(e,t)),s,a,c,o))}function mQ(e,t){return function(e){let t=e.split(/[^\w]+/);if(t.length!==7)throw RangeError(`expected 7 parts in "${e}`);let n=+t[0],r=+t[1],i=+t[2],a=t[3];if(a[0]===`b`||a[0]===`B`)i=1-i;else if(a[0]!==`a`&&a[0]!==`A`)throw RangeError(`Unknown era ${a} in "${e}`);let o=t[4]===`24`?0:+t[4],s=+t[5],c=+t[6];if(!(Number.isFinite(i)&&Number.isFinite(n)&&Number.isFinite(r)&&Number.isFinite(o)&&Number.isFinite(s)&&Number.isFinite(c)))throw RangeError(`Invalid number in "${e}`);return{year:i,month:n,day:r,hour:o,minute:s,second:c}}(oX(e).format(t))}function hQ(e){return e!==void 0&&!(e%4!=0||e%100==0&&e%400!=0)}function gQ(e,t){return{standard:[31,28,31,30,31,30,31,31,30,31,30,31],leapyear:[31,29,31,30,31,30,31,31,30,31,30,31]}[hQ(e)?`leapyear`:`standard`][t-1]}function _Q(e){let t=[Q(e,TJ),Q(e,EJ),Q(e,DJ),Q(e,OJ),Q(e,kJ),Q(e,AJ),Q(e,jJ),Q(e,MJ),Q(e,NJ),Q(e,PJ)];for(let e=0;e<t.length;e++){let n=t[e];if(n!==0)return n<0?-1:1}return 0}function vQ(e){let t=[`years`,`months`,`weeks`,`days`];for(let n=0;n<t.length;n++){let r=e[t[n]];if(r!==0)return r<0?-1:1}return 0}function yQ(e){let t=vQ(e.date);return t===0?e.time.sign():t}function bQ(e,t){let n=e,r=t;if(!Number.isFinite(n)||!Number.isFinite(r))throw RangeError(`infinity is out of range`);return--r,n+=Math.floor(r/12),r%=12,r<0&&(r+=12),r+=1,{year:n,month:r}}function xQ(e,t,n){let r=e,i=t,a=n;if(!Number.isFinite(a))throw RangeError(`infinity is out of range`);({year:r,month:i}=bQ(r,i));let o=146097;if(Math.abs(a)>o){let e=Math.trunc(a/o);r+=400*e,a-=e*o}let s=0,c=i>2?r:r-1;for(;s=hQ(c)?366:365,a<-s;)--r,--c,a+=s;for(c+=1;s=hQ(c)?366:365,a>s;)r+=1,c+=1,a-=s;for(;a<1;)({year:r,month:i}=bQ(r,i-1)),a+=gQ(r,i);for(;a>gQ(r,i);)a-=gQ(r,i),{year:r,month:i}=bQ(r,i+1);return{year:r,month:i,day:a}}function SQ(e,t,n,r,i,a,o,s,c){let l=CQ(r,i,a,o,s,c);return AX(xQ(e,t,n+l.deltaDays),l)}function CQ(e,t,n,r,i,a){let o,s=e,c=t,l=n,u=r,d=i,f=a;({div:o,mod:f}=iY(f,3)),d+=o,f<0&&(--d,f+=1e3),{div:o,mod:d}=iY(d,3),u+=o,d<0&&(--u,d+=1e3),l+=Math.trunc(u/1e3),u%=1e3,u<0&&(--l,u+=1e3),c+=Math.trunc(l/60),l%=60,l<0&&(--c,l+=60),s+=Math.trunc(c/60),c%=60,c<0&&(--s,c+=60);let p=Math.trunc(s/24);return s%=24,s<0&&(--p,s+=24),p+=0,s+=0,c+=0,l+=0,u+=0,d+=0,f+=0,{deltaDays:p,hour:s,minute:c,second:l,millisecond:u,microsecond:d,nanosecond:f}}function wQ(e,t){let n=kX(e,0);if(vQ(n)===0)return e.days;let r=Q(t,vJ),i=TZ(Q(t,Z),r,n,`constrain`),a=UQ(r.year,r.month-1,r.day),o=UQ(i.year,i.month-1,i.day)-a;return e.days+o}function TQ(e){return new(rY(`%Temporal.Duration%`))(-Q(e,TJ),-Q(e,EJ),-Q(e,DJ),-Q(e,OJ),-Q(e,kJ),-Q(e,AJ),-Q(e,jJ),-Q(e,MJ),-Q(e,NJ),-Q(e,PJ))}function EQ(e,t,n){return Math.min(n,Math.max(t,e))}function DQ(e,t,n){let r=EQ(t,1,12);return{year:e,month:r,day:EQ(n,1,gQ(e,r))}}function OQ(e,t,n){if(e<t||e>n)throw RangeError(`value out of range: ${t} <= ${e} <= ${n}`)}function kQ(e,t,n){OQ(t,1,12),OQ(n,1,gQ(e,t))}function AQ(e){NQ(AX(e,{deltaDays:0,hour:12,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0}))}function jQ(e,t,n,r,i,a){OQ(e,0,23),OQ(t,0,59),OQ(n,0,59),OQ(r,0,999),OQ(i,0,999),OQ(a,0,999)}function MQ(e,t,n,r,i,a,o,s,c){kQ(e,t,n),jQ(r,i,a,o,s,c)}function NQ(e){let t=uQ(e);(X.default.lessThan(t,MY)||X.default.greaterThan(t,NY))&&FQ(t)}function PQ(e){uQ(e)}function FQ(e){if(X.default.lessThan(e,jY)||X.default.greaterThan(e,AY))throw RangeError(`date/time value is outside of supported range`)}function IQ({year:e,month:t}){OQ(e,FY,IY),e===FY?OQ(t,4,12):e===IY&&OQ(t,1,9)}function LQ(e,t,n,r,i,a,o,s,c,l){let u=0,d=[e,t,n,r,i,a,o,s,c,l];for(let e=0;e<d.length;e++){let t=d[e];if(t===1/0||t===-1/0)throw RangeError(`infinite values not allowed as duration fields`);if(t!==0){let e=t<0?-1:1;if(u!==0&&e!==u)throw RangeError(`mixed-sign values not allowed as duration fields`);u=e}}if(Math.abs(e)>=2**32||Math.abs(t)>=2**32||Math.abs(n)>=2**32)throw RangeError(`years, months, and weeks must be < 2³²`);let f=iY(s,3),p=iY(c,6),m=iY(l,9),h=iY(1e6*f.mod+1e3*p.mod+m.mod,9).div,g=86400*r+3600*i+60*a+o+f.div+p.div+m.div+h;if(!Number.isSafeInteger(g))throw RangeError(`total of duration time units cannot exceed 9007199254740991.999999999 s`)}function RQ(e){return{date:{years:Q(e,TJ),months:Q(e,EJ),weeks:Q(e,DJ),days:Q(e,OJ)},time:cY.fromComponents(Q(e,kJ),Q(e,AJ),Q(e,jJ),Q(e,MJ),Q(e,NJ),Q(e,PJ))}}function zQ(e){let t=cY.fromComponents(Q(e,kJ),Q(e,AJ),Q(e,jJ),Q(e,MJ),Q(e,NJ),Q(e,PJ)).add24HourDays(Q(e,OJ));return{date:{years:Q(e,TJ),months:Q(e,EJ),weeks:Q(e,DJ),days:0},time:t}}function BQ(e){let t=zQ(e),n=Math.trunc(t.time.sec/86400);return LQ(t.date.years,t.date.months,t.date.weeks,n,0,0,0,0,0,0),{...t.date,days:n}}function VQ(e,t){let n=e.time.sign(),r=e.time.abs().subsec,i=0,a=0,o=e.time.abs().sec,s=0,c=0,l=0;switch(t){case`year`:case`month`:case`week`:case`day`:i=Math.trunc(r/1e3),r%=1e3,a=Math.trunc(i/1e3),i%=1e3,o+=Math.trunc(a/1e3),a%=1e3,s=Math.trunc(o/60),o%=60,c=Math.trunc(s/60),s%=60,l=Math.trunc(c/24),c%=24;break;case`hour`:i=Math.trunc(r/1e3),r%=1e3,a=Math.trunc(i/1e3),i%=1e3,o+=Math.trunc(a/1e3),a%=1e3,s=Math.trunc(o/60),o%=60,c=Math.trunc(s/60),s%=60;break;case`minute`:i=Math.trunc(r/1e3),r%=1e3,a=Math.trunc(i/1e3),i%=1e3,o+=Math.trunc(a/1e3),a%=1e3,s=Math.trunc(o/60),o%=60;break;case`second`:i=Math.trunc(r/1e3),r%=1e3,a=Math.trunc(i/1e3),i%=1e3,o+=Math.trunc(a/1e3),a%=1e3;break;case`millisecond`:i=Math.trunc(r/1e3),r%=1e3,a=aY(o,3,Math.trunc(i/1e3)),i%=1e3,o=0;break;case`microsecond`:i=aY(o,6,Math.trunc(r/1e3)),r%=1e3,o=0;break;case`nanosecond`:r=aY(o,9,r),o=0}return new(rY(`%Temporal.Duration%`))(e.date.years,e.date.months,e.date.weeks,e.date.days+n*l,n*c,n*s,n*o,n*a,n*i,n*r)}function HQ(e,t){return vQ(e),t.sign(),{date:e,time:t}}function UQ(e,t,n){return lQ({isoDate:{year:e,month:t+1,day:n},time:{hour:0,minute:0,second:0,millisecond:0}})/EY}function WQ({year:e,month:t,day:n}){if(Math.abs(UQ(e,t-1,n))>1e8)throw RangeError(`date/time value is outside the supported range`)}function GQ(e,t){let n=t.hour-e.hour,r=t.minute-e.minute,i=t.second-e.second,a=t.millisecond-e.millisecond,o=t.microsecond-e.microsecond,s=t.nanosecond-e.nanosecond;return cY.fromComponents(n,r,i,a,o,s)}function KQ(e,t,n,r,i){let a=cY.fromEpochNsDiff(t,e);return a=x$(a,n,r,i),HQ({years:0,months:0,weeks:0,days:0},a)}function qQ(e,t,n,r){PQ(e),PQ(t);let i=GQ(e.time,t.time),a=i.sign(),o=C$(e.isoDate,t.isoDate),s=t.isoDate;o===a&&(s=xQ(s.year,s.month,s.day+a),i=i.add24HourDays(-a));let c=WX(`day`,r),l=EZ(n,e.isoDate,s,c);return r!==c&&(i=i.add24HourDays(l.days),l.days=0),HQ(l,i)}function JQ(e,t,n,r,i){let a=X.default.subtract(t,e);if(X.default.equal(a,Qq))return{date:{years:0,months:0,weeks:0,days:0},time:cY.ZERO};let o=X.default.lessThan(a,Qq)?-1:1,s=LZ(n,e),c=LZ(n,t),l,u=0,d=o===1?2:1,f=GQ(s.time,c.time);for(f.sign()===-o&&u++;u<=d;u++){l=AX(xQ(c.isoDate.year,c.isoDate.month,c.isoDate.day-u*o),s.time);let e=RZ(n,l,`compatible`);if(f=cY.fromEpochNsDiff(t,e),f.sign()!==-o)break}let p=WX(`day`,i);return HQ(EZ(r,s.isoDate,l.isoDate,p),f)}function YQ(e,t,n,r,i,a,o,s,c){let l,u,d,f,p=t;switch(s){case`year`:{let t=_$(p.date.years,o,`trunc`);l=t,u=t+o*e,d={years:l,months:0,weeks:0,days:0},f={...d,years:u};break}case`month`:{let t=_$(p.date.months,o,`trunc`);l=t,u=t+o*e,d=kX(p.date,0,0,l),f=kX(p.date,0,0,u);break}case`week`:{let t=kX(p.date,0,0),n=TZ(a,r.isoDate,t,`constrain`),i=EZ(a,n,xQ(n.year,n.month,n.day+p.date.days),`week`),s=_$(p.date.weeks+i.weeks,o,`trunc`);l=s,u=s+o*e,d=kX(p.date,0,l),f=kX(p.date,0,u);break}case`day`:{let t=_$(p.date.days,o,`trunc`);l=t,u=t+o*e,d=kX(p.date,l),f=kX(p.date,u);break}}let m=TZ(a,r.isoDate,d,`constrain`),h=TZ(a,r.isoDate,f,`constrain`),g,_,v=AX(m,r.time),y=AX(h,r.time);i?(g=RZ(i,v,`compatible`),_=RZ(i,y,`compatible`)):(g=uQ(v),_=uQ(y));let b=cY.fromEpochNsDiff(n,g),x=cY.fromEpochNsDiff(_,g),S=oY(c,e<0?`negative`:`positive`),C=b.add(b).abs().subtract(x.abs()).sign(),w=Math.abs(l)/o%2==0,T=b.isZero()?Math.abs(l):b.cmp(x)?sY(Math.abs(l),Math.abs(u),C,w,S):Math.abs(u),E=new cY(X.default.add(X.default.multiply(x.totalNs,X.default.BigInt(l)),X.default.multiply(b.totalNs,X.default.BigInt(o*e)))).fdiv(x.totalNs),D=T===Math.abs(u);return p={date:D?f:d,time:cY.ZERO},{nudgeResult:{duration:p,nudgedEpochNs:D?_:g,didExpandCalendarUnit:D},total:E}}function XQ(e,t,n,r,i,a,o,s,c){let l=e,u=GX(s)||r&&s===`day`,d=yQ(l)<0?-1:1,f;return u?{nudgeResult:f}=YQ(d,l,t,n,r,i,o,s,c):f=r?function(e,t,n,r,i,a,o,s){let c=t,l=TZ(i,n.isoDate,c.date,`constrain`),u=AX(l,n.time),d=AX(xQ(l.year,l.month,l.day+e),n.time),f=RZ(r,u,`compatible`),p=RZ(r,d,`compatible`),m=cY.fromEpochNsDiff(p,f);if(m.sign()!==e)throw RangeError(`time zone returned inconsistent Instants`);let h=X.default.BigInt(nX[o]*a),g=c.time.round(h,s),_=g.subtract(m),v=_.sign()!==-e,y,b;return v?(y=e,g=_.round(h,s),b=g.addToEpochNs(p)):(y=0,b=g.addToEpochNs(f)),{duration:HQ(kX(c.date,c.date.days+y),g),nudgedEpochNs:b,didExpandCalendarUnit:v}}(d,l,n,r,i,o,s,c):function(e,t,n,r,i,a){let o=e,s=o.time.add24HourDays(o.date.days),c=s.round(X.default.BigInt(r*nX[i]),a),l=c.subtract(s),{quotient:u}=s.divmod(DY),{quotient:d}=c.divmod(DY),f=Math.sign(d-u)===s.sign(),p=l.addToEpochNs(t),m=0,h=c;return KX(n)===`date`&&(m=d,h=c.add(cY.fromComponents(24*-d,0,0,0,0,0))),{duration:{date:kX(o.date,m),time:h},nudgedEpochNs:p,didExpandCalendarUnit:f}}(l,t,a,o,s,c),l=f.duration,f.didExpandCalendarUnit&&s!==`week`&&(l=function(e,t,n,r,i,a,o,s){let c=t;if(s===o)return c;let l=tX.indexOf(o);for(let t=tX.indexOf(s)-1;t>=l;t--){let s=tX[t];if(s===`week`&&o!==`week`)continue;let l;switch(s){case`year`:l={years:c.date.years+e,months:0,weeks:0,days:0};break;case`month`:{let t=c.date.months+e;l=kX(c.date,0,0,t);break}case`week`:{let t=c.date.weeks+e;l=kX(c.date,0,t);break}}let u=AX(TZ(a,r.isoDate,l,`constrain`),r.time),d;if(d=i?RZ(i,u,`compatible`):uQ(u),pJ(n,d)===-e)break;c={date:l,time:cY.ZERO}}return c}(d,l,f.nudgedEpochNs,n,r,i,a,WX(s,`day`))),l}function ZQ(e,t,n,r,i,a){return GX(a)||r&&a===`day`?YQ(yQ(e)<0?-1:1,e,t,n,r,i,1,a,`trunc`).total:S$(e.time.add24HourDays(e.date.days),a)}function QQ(e,t,n,r,i,a,o){if(T$(e,t)==0)return{date:{years:0,months:0,weeks:0,days:0},time:cY.ZERO};NQ(e),NQ(t);let s=qQ(e,t,n,r);return a===`nanosecond`&&i===1?s:XQ(s,uQ(t),e,null,n,r,i,a,o)}function $Q(e,t,n,r,i,a,o,s){if(KX(i)===`time`)return KQ(e,t,a,o,s);let c=JQ(e,t,n,r,i);return o===`nanosecond`&&a===1?c:XQ(c,t,LZ(n,e),n,r,i,a,o,s)}function e$(e,t,n,r,i,a){let o=QY.reduce(((e,t)=>{let i=t[0],a=t[1],o=t[2];return n!==`datetime`&&o!==n||r.includes(a)||e.push(a,i),e}),[]),s=VX(t,`largestUnit`,n,`auto`);if(r.includes(s))throw RangeError(`largestUnit must be one of ${o.join(`, `)}, not ${s}`);let c=IX(t),l=NX(t,`trunc`);e===`since`&&(l=function(e){switch(e){case`ceil`:return`floor`;case`floor`:return`ceil`;case`halfCeil`:return`halfFloor`;case`halfFloor`:return`halfCeil`;default:return e}}(l));let u=VX(t,`smallestUnit`,n,i);if(r.includes(u))throw RangeError(`smallestUnit must be one of ${o.join(`, `)}, not ${u}`);let d=WX(a,u);if(s===`auto`&&(s=d),WX(s,u)!==s)throw RangeError(`largestUnit ${s} cannot be smaller than smallestUnit ${u}`);let f={hour:24,minute:60,second:60,millisecond:1e3,microsecond:1e3,nanosecond:1e3}[u];return f!==void 0&&LX(c,f,!1),{largestUnit:s,roundingIncrement:c,roundingMode:l,smallestUnit:u}}function t$(e,t,n,r){let i=nZ(n),a=e$(e,N$(r),`time`,[],`nanosecond`,`second`),o=VQ(KQ(Q(t,_J),Q(i,_J),a.roundingIncrement,a.smallestUnit,a.roundingMode),a.largestUnit);return e===`since`&&(o=TQ(o)),o}function n$(e,t,n,r){let i=QX(n),a=Q(t,Z),o=Q(i,Z);if(!kZ(a,o))throw RangeError(`cannot compute difference between dates of ${a} and ${o} calendars`);let s=e$(e,N$(r),`date`,[],`day`,`day`),c=rY(`%Temporal.Duration%`),l=Q(t,vJ),u=Q(i,vJ);if(C$(l,u)===0)return new c;let d={date:EZ(a,l,u,s.largestUnit),time:cY.ZERO};if(s.smallestUnit!==`day`||s.roundingIncrement!==1){let e=AX(l,{deltaDays:0,hour:0,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0});d=XQ(d,uQ(AX(u,{deltaDays:0,hour:0,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0})),e,null,a,s.largestUnit,s.roundingIncrement,s.smallestUnit,s.roundingMode)}let f=VQ(d,`day`);return e===`since`&&(f=TQ(f)),f}function r$(e,t,n,r){let i=eZ(n),a=Q(t,Z),o=Q(i,Z);if(!kZ(a,o))throw RangeError(`cannot compute difference between dates of ${a} and ${o} calendars`);let s=e$(e,N$(r),`datetime`,[],`nanosecond`,`day`),c=rY(`%Temporal.Duration%`),l=Q(t,yJ),u=Q(i,yJ);if(T$(l,u)===0)return new c;let d=VQ(QQ(l,u,a,s.largestUnit,s.roundingIncrement,s.smallestUnit,s.roundingMode),s.largestUnit);return e===`since`&&(d=TQ(d)),d}function i$(e,t,n,r){let i=iZ(n),a=e$(e,N$(r),`time`,[],`nanosecond`,`hour`),o=GQ(Q(t,bJ),Q(i,bJ));o=x$(o,a.roundingIncrement,a.smallestUnit,a.roundingMode);let s=VQ(HQ({years:0,months:0,weeks:0,days:0},o),a.largestUnit);return e===`since`&&(s=TQ(s)),s}function a$(e,t,n,r){let i=oZ(n),a=Q(t,Z),o=Q(i,Z);if(!kZ(a,o))throw RangeError(`cannot compute difference between months of ${a} and ${o} calendars`);let s=e$(e,N$(r),`date`,[`week`,`day`],`month`,`year`),c=rY(`%Temporal.Duration%`);if(C$(Q(t,vJ),Q(i,vJ))==0)return new c;let l=YX(a,Q(t,vJ),`year-month`);l.day=1;let u=AZ(a,l,`constrain`),d=YX(a,Q(i,vJ),`year-month`);d.day=1;let f=AZ(a,d,`constrain`),p={date:kX(EZ(a,u,f,s.largestUnit),0,0),time:cY.ZERO};if(s.smallestUnit!==`month`||s.roundingIncrement!==1){let e=AX(u,{deltaDays:0,hour:0,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0});p=XQ(p,uQ(AX(f,{deltaDays:0,hour:0,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0})),e,null,a,s.largestUnit,s.roundingIncrement,s.smallestUnit,s.roundingMode)}let m=VQ(p,`day`);return e===`since`&&(m=TQ(m)),m}function o$(e,t,n,r){let i=cZ(n),a=Q(t,Z),o=Q(i,Z);if(!kZ(a,o))throw RangeError(`cannot compute difference between dates of ${a} and ${o} calendars`);let s=e$(e,N$(r),`datetime`,[],`nanosecond`,`hour`),c=Q(t,_J),l=Q(i,_J),u=rY(`%Temporal.Duration%`),d;if(KX(s.largestUnit)!==`date`)d=VQ(KQ(c,l,s.roundingIncrement,s.smallestUnit,s.roundingMode),s.largestUnit);else{let e=Q(t,wJ);if(!PZ(e,Q(i,wJ)))throw RangeError(`When calculating difference between time zones, largestUnit must be 'hours' or smaller because day lengths can vary between time zones due to DST or time zone offset changes.`);if(X.default.equal(c,l))return new u;d=VQ($Q(c,l,e,a,s.largestUnit,s.roundingIncrement,s.smallestUnit,s.roundingMode),`hour`)}return e===`since`&&(d=TQ(d)),d}function s$({hour:e,minute:t,second:n,millisecond:r,microsecond:i,nanosecond:a},o){let s=n,c=a;return s+=o.sec,c+=o.subsec,CQ(e,t,s,r,i,c)}function c$(e,t){let n=t.addToEpochNs(e);return FQ(n),n}function l$(e,t,n,r,i=`constrain`){if(vQ(r.date)===0)return c$(e,r.time);let a=LZ(t,e);return c$(RZ(t,AX(TZ(n,a.isoDate,r.date,i),a.time),`compatible`),r.time)}function u$(e,t,n){let r=tZ(n);e===`subtract`&&(r=TQ(r));let i=WX(UX(t),UX(r));if(GX(i))throw RangeError(`For years, months, or weeks arithmetic, use date arithmetic relative to a starting point`);let a=zQ(t),o=zQ(r);return VQ(HQ({years:0,months:0,weeks:0,days:0},a.time.add(o.time)),i)}function d$(e,t,n){let r=tZ(n);e===`subtract`&&(r=TQ(r));let i=UX(r);if(KX(i)===`date`)throw RangeError(`Duration field ${i} not supported by Temporal.Instant. Try Temporal.ZonedDateTime instead.`);let a=zQ(r);return bZ(c$(Q(t,_J),a.time))}function f$(e,t,n,r){let i=Q(t,Z),a=tZ(n);e===`subtract`&&(a=TQ(a));let o=BQ(a),s=jX(N$(r));return uZ(TZ(i,Q(t,vJ),o,s),i)}function p$(e,t,n,r){let i=tZ(n);e===`subtract`&&(i=TQ(i));let a=jX(N$(r)),o=Q(t,Z),s=zQ(i),c=Q(t,yJ),l=s$(c.time,s.time),u=kX(s.date,l.deltaDays);return LQ(u.years,u.months,u.weeks,u.days,0,0,0,0,0,0),fZ(AX(TZ(o,c.isoDate,u,a),l),o)}function m$(e,t,n){let r=tZ(n);e===`subtract`&&(r=TQ(r));let i=zQ(r),{hour:a,minute:o,second:s,millisecond:c,microsecond:l,nanosecond:u}=s$(Q(t,bJ),i.time);return gZ(DX(a,o,s,c,l,u,`reject`))}function h$(e,t,n,r){let i=tZ(n);e===`subtract`&&(i=TQ(i));let a=jX(N$(r)),o=_Q(i),s=Q(t,Z),c=YX(s,Q(t,vJ),`year-month`);c.day=1;let l=AZ(s,c,`constrain`);if(o<0){let e=TZ(s,l,{months:1},`constrain`);l=xQ(e.year,e.month,e.day-1)}let u=BQ(i);return AQ(l),vZ(jZ(s,YX(s,TZ(s,l,u,a),`year-month`),a),s)}function g$(e,t,n,r){let i=tZ(n);e===`subtract`&&(i=TQ(i));let a=jX(N$(r)),o=Q(t,wJ),s=Q(t,Z),c=RQ(i);return SZ(l$(Q(t,_J),o,s,c,a),o,s)}function _$(e,t,n){let r=Math.trunc(e/t),i=e%t,a=e<0?`negative`:`positive`,o=Math.abs(r),s=o+1,c=M$(Math.abs(2*i)-t),l=o%2==0,u=oY(n,a),d=i===0?o:sY(o,s,c,l,u);return t*(a===`positive`?d:-d)}function v$(e,t,n,r){let i=nX[n]*t;return function(e,t,n){let r=uJ(e),i=uJ(t),a=X.default.divide(r,i),o=X.default.remainder(r,i),s=oY(n,`positive`),c,l;X.default.lessThan(r,Qq)?(c=X.default.subtract(a,$q),l=a):(c=a,l=X.default.add(a,$q));let u=pJ(fJ(X.default.multiply(o,eJ)),i)*(X.default.lessThan(r,Qq)?-1:1)+0,d=X.default.equal(o,Qq)?a:sY(c,l,u,dJ(c),s);return X.default.multiply(d,i)}(e,X.default.BigInt(i),r)}function y$(e,t,n,r){PQ(e);let{year:i,month:a,day:o}=e.isoDate,s=b$(e.time,t,n,r);return AX(xQ(i,a,o+s.deltaDays),s)}function b$({hour:e,minute:t,second:n,millisecond:r,microsecond:i,nanosecond:a},o,s,c){let l;switch(s){case`day`:case`hour`:l=1e3*(1e3*(1e3*(60*(60*e+t)+n)+r)+i)+a;break;case`minute`:l=1e3*(1e3*(1e3*(60*t+n)+r)+i)+a;break;case`second`:l=1e3*(1e3*(1e3*n+r)+i)+a;break;case`millisecond`:l=1e3*(1e3*r+i)+a;break;case`microsecond`:l=1e3*i+a;break;case`nanosecond`:l=a}let u=nX[s],d=_$(l,u*o,c)/u;switch(s){case`day`:return{deltaDays:d,hour:0,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0};case`hour`:return CQ(d,0,0,0,0,0);case`minute`:return CQ(e,d,0,0,0,0);case`second`:return CQ(e,t,d,0,0,0);case`millisecond`:return CQ(e,t,n,d,0,0);case`microsecond`:return CQ(e,t,n,r,d,0);case`nanosecond`:return CQ(e,t,n,r,i,d);default:throw Error(`Invalid unit ${s}`)}}function x$(e,t,n,r){let i=nX[n];return e.round(X.default.BigInt(i*t),r)}function S$(e,t){let n=nX[t];return e.fdiv(X.default.BigInt(n))}function C$(e,t){return e.year===t.year?e.month===t.month?e.day===t.day?0:M$(e.day-t.day):M$(e.month-t.month):M$(e.year-t.year)}function w$(e,t){return e.hour===t.hour?e.minute===t.minute?e.second===t.second?e.millisecond===t.millisecond?e.microsecond===t.microsecond?e.nanosecond===t.nanosecond?0:M$(e.nanosecond-t.nanosecond):M$(e.microsecond-t.microsecond):M$(e.millisecond-t.millisecond):M$(e.second-t.second):M$(e.minute-t.minute):M$(e.hour-t.hour)}function T$(e,t){let n=C$(e.isoDate,t.isoDate);return n===0?w$(e.time,t.time):n}function E$(e){let t=k$(e);return globalThis.BigInt===void 0?t:globalThis.BigInt(t.toString(10))}function D$(e,t){let{quotient:n,remainder:r}=mJ(uJ(e),aJ),i=X.default.toNumber(n);return t===`floor`&&X.default.toNumber(r)<0&&--i,t===`ceil`&&X.default.toNumber(r)>0&&(i+=1),i}function O$(e){if(!Number.isInteger(e))throw RangeError(`epoch milliseconds must be an integer`);return X.default.multiply(X.default.BigInt(e),aJ)}function k$(e){let t=e;if(typeof e==`object`){let n=e[Symbol.toPrimitive];n&&typeof n==`function`&&(t=n.call(e,`number`))}if(typeof t==`number`)throw TypeError(`cannot convert number to bigint`);return typeof t==`bigint`?X.default.BigInt(t.toString(10)):X.default.BigInt(t)}var A$=(()=>{let e=X.default.BigInt(Date.now()%1e6);return()=>{let t=Date.now(),n=X.default.BigInt(t),r=X.default.add(O$(t),e);return e=X.default.remainder(n,aJ),X.default.greaterThan(r,AY)?AY:X.default.lessThan(r,jY)?jY:r}})();function j$(){return new Intl.DateTimeFormat().resolvedOptions().timeZone}function M$(e){return e<0?-1:e>0?1:e}function N$(e){if(e===void 0)return Object.create(null);if(BY(e)&&e!==null)return e;throw TypeError(`Options parameter must be an object, not `+(e===null?`null`:typeof e))}function P$(e,t){let n=Object.create(null);return n[e]=t,n}function F$(e,t,n,r){let i=e[t];if(i!==void 0){if(i=HY(i),!n.includes(i))throw RangeError(`${t} must be one of ${n.join(`, `)}, not ${i}`);return i}if(r===BX)throw RangeError(`${t} option is required`);return r}function I$(e){let t=L$(e);if(!RY.includes(L$(t)))throw RangeError(`invalid calendar identifier ${t}`);switch(t){case`ethiopic-amete-alem`:return`ethioaa`;case`islamicc`:return`islamic-civil`}return t}function L$(e){let t=``;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);t+=r>=65&&r<=90?String.fromCharCode(r+32):String.fromCharCode(r)}return t}function R$(e){throw TypeError(`Do not use built-in arithmetic operators with Temporal objects. When comparing, use ${e===`PlainMonthDay`?`Temporal.PlainDate.compare(obj1.toPlainDate(year), obj2.toPlainDate(year))`:`Temporal.${e}.compare(obj1, obj2)`}, not obj1 > obj2. When coercing to strings, use \`\${obj}\` or String(obj), not '' + obj. When coercing to numbers, use properties or methods of the object, not \`+obj\`. When concatenating with strings, use \`\${str}\${obj}\` or str.concat(obj), not str + obj. In React, coerce to a string before rendering a Temporal object.`)}var z$=RegExp(`^${gY.source}$`),B$=RegExp(`^([+-])([01][0-9]|2[0-3])(?::?([0-5][0-9])(?::?([0-5][0-9])(?:[.,](\\d{1,9}))?)?)?$`);function V$(e,t,n,r=e(t),i=e(n)){let a=t,o=n,s=r,c=i;for(;o-a>1;){let t=Math.trunc((a+o)/2),n=e(t);n===s?(a=t,s=n):n===c&&(o=t,c=n)}return o}function H$(e){return[...e]}function U$(e,t){if(e!==`gregory`&&e!==`iso8601`)return;let n=G$[e],r=t.year,{dayOfWeek:i,dayOfYear:a,daysInYear:o}=n.isoToDate(t,{dayOfWeek:!0,dayOfYear:!0,daysInYear:!0}),s=n.getFirstDayOfWeek(),c=n.getMinimalDaysInFirstWeek(),l=(i+7-s)%7,u=(i-a+7001-s)%7,d=Math.floor((a-1+u)/7);if(7-u>=c&&++d,d==0)d=function(e,t,n,r){let i=(r-e-n+1)%7;i<0&&(i+=7);let a=Math.floor((n+i-1)/7);return 7-i>=t&&++a,a}(s,c,a+n.isoToDate(n.dateAdd(t,{years:-1},`constrain`),{daysInYear:!0}).daysInYear,i),r--;else if(a>=o-5){let e=(l+o-a)%7;e<0&&(e+=7),6-e>=c&&a+7-l>o&&(d=1,r++)}return{week:d,year:r}}function W$(e,t,n,r,i){if(t!==i.year){if(e*(t-i.year)>0)return!0}else if(n!==i.month){if(e*(n-i.month)>0)return!0}else if(r!==i.day&&e*(r-i.day)>0)return!0;return!1}var G$={};function K$(e){if(!e.startsWith(`M`))throw RangeError(`Invalid month code: ${e}. Month codes must start with M.`);let t=+e.slice(1);if(Number.isNaN(t))throw RangeError(`Invalid month code: ${e}`);return t}function q$(e,t=!1){return`M${`${e}`.padStart(2,`0`)}${t?`L`:``}`}function J$(e,t=void 0,n=12){let{month:r,monthCode:i}=e;if(i===void 0){if(r===void 0)throw TypeError(`Either month or monthCode are required`);t===`reject`&&OQ(r,1,n),t===`constrain`&&(r=EQ(r,1,n)),i=q$(r)}else{let e=K$(i);if(i!==q$(e))throw RangeError(`Invalid month code: ${i}`);if(r!==void 0&&r!==e)throw RangeError(`monthCode ${i} and month ${r} must match if both are present`);if(r=e,r<1||r>n)throw RangeError(`Invalid monthCode: ${i}`)}return{...e,month:r,monthCode:i}}G$.iso8601={resolveFields(e,t){if((t===`date`||t===`year-month`)&&e.year===void 0)throw TypeError(`year is required`);if((t===`date`||t===`month-day`)&&e.day===void 0)throw TypeError(`day is required`);Object.assign(e,J$(e))},dateToISO:(e,t)=>EX(e.year,e.month,e.day,t),monthDayToISOReferenceDate(e,t){let{month:n,day:r}=EX(e.year??1972,e.month,e.day,t);return{month:n,day:r,year:1972}},extraFields:()=>[],fieldKeysToIgnore(e){let t=new Set;for(let n=0;n<e.length;n++){let r=e[n];t.add(r),r===`month`?t.add(`monthCode`):r===`monthCode`&&t.add(`month`)}return H$(t)},dateAdd(e,{years:t=0,months:n=0,weeks:r=0,days:i=0},a){let{year:o,month:s,day:c}=e;return o+=t,s+=n,{year:o,month:s}=bQ(o,s),{year:o,month:s,day:c}=EX(o,s,c,a),c+=i+7*r,xQ(o,s,c)},dateUntil(e,t,n){let r=-C$(e,t);if(r===0)return{years:0,months:0,weeks:0,days:0};let i,a=0,o=0;if(n===`year`||n===`month`){let s=t.year-e.year;for(s!==0&&(s-=r);!W$(r,e.year+s,e.month,e.day,t);)a=s,s+=r;let c=r;for(i=bQ(e.year+a,e.month+c);!W$(r,i.year,i.month,e.day,t);)o=c,c+=r,i=bQ(i.year,i.month+r);n===`month`&&(o+=12*a,a=0)}i=bQ(e.year+a,e.month+o);let s=DQ(i.year,i.month,e.day),c=0,l=UQ(t.year,t.month-1,t.day)-UQ(s.year,s.month-1,s.day);return n===`week`&&(c=Math.trunc(l/7),l%=7),{years:a,months:o,weeks:c,days:l}},isoToDate({year:e,month:t,day:n},r){let i={era:void 0,eraYear:void 0,year:e,month:t,day:n,daysInWeek:7,monthsInYear:12};if(r.monthCode&&(i.monthCode=q$(t)),r.dayOfWeek){let r=t+(t<3?10:-2),a=e-+(t<3),o=Math.floor(a/100),s=a-100*o,c=(n+Math.floor(2.6*r-.2)+(s+Math.floor(s/4))+(Math.floor(o/4)-2*o))%7;i.dayOfWeek=c+(c<=0?7:0)}if(r.dayOfYear){let r=n;for(let n=t-1;n>0;n--)r+=gQ(e,n);i.dayOfYear=r}return r.weekOfYear&&(i.weekOfYear=U$(`iso8601`,{year:e,month:t,day:n})),r.daysInMonth&&(i.daysInMonth=gQ(e,t)),(r.daysInYear||r.inLeapYear)&&(i.inLeapYear=hQ(e),i.daysInYear=i.inLeapYear?366:365),i},getFirstDayOfWeek:()=>1,getMinimalDaysInFirstWeek:()=>4};var Y$=class e{constructor(t){if(this.map=new Map,this.calls=0,this.hits=0,this.misses=0,t!==void 0){let n=0;for(let r of t.map.entries()){if(++n>e.MAX_CACHE_ENTRIES)break;this.map.set(...r)}}}get(e){let t=this.map.get(e);return t&&(this.hits++,this.report()),this.calls++,t}set(e,t){this.map.set(e,t),this.misses++,this.report()}report(){}setObject(t){if(e.objectMap.get(t))throw RangeError(`object already cached`);e.objectMap.set(t,this),this.report()}static getCacheForObject(t){let n=e.objectMap.get(t);return n||(n=new e,e.objectMap.set(t,n)),n}};function X$({isoYear:e,isoMonth:t,isoDay:n}){return`${HZ(e)}-${UZ(t)}-${UZ(n)}T00:00Z`}function Z$(e,t){return{years:e.year-t.year,months:e.month-t.month,days:e.day-t.day}}Y$.objectMap=new WeakMap,Y$.MAX_CACHE_ENTRIES=1e3;var Q$=class{constructor(){this.eras=[],this.hasEra=!1,this.erasBeginMidYear=!1}getFormatter(){return this.formatter===void 0&&(this.formatter=new Intl.DateTimeFormat(`en-US-u-ca-${this.id}`,{day:`numeric`,month:`numeric`,year:`numeric`,era:`short`,timeZone:`UTC`})),this.formatter}getCalendarParts(e){let t=this.getFormatter(),n=new Date(e);if(e===`-271821-04-19T00:00Z`){let e=t.resolvedOptions();t=new Intl.DateTimeFormat(e.locale,{...e,timeZone:`Etc/GMT+1`}),n=new Date(`-271821-04-20T00:00Z`)}try{return t.formatToParts(n)}catch{throw RangeError(`Invalid ISO date: ${e}`)}}isoToCalendarDate(e,t){let{year:n,month:r,day:i}=e,a=JSON.stringify({func:`isoToCalendarDate`,isoYear:n,isoMonth:r,isoDay:i,id:this.id}),o=t.get(a);if(o)return o;let s=X$({isoYear:n,isoMonth:r,isoDay:i}),c=this.getCalendarParts(s),l={};for(let e=0;e<c.length;e++){let{type:t,value:n}=c[e];if(t!==`year`&&t!==`relatedYear`||(this.hasEra?l.eraYear=+n:l.year=+n),t===`month`){let e=/^([0-9]*)(.*?)$/.exec(n);if(!e||e.length!=3||!e[1]&&!e[2])throw RangeError(`Unexpected month: ${n}`);if(l.month=e[1]?+e[1]:1,l.month<1)throw RangeError(`Invalid month ${n} from ${s}[u-ca-${this.id}] (probably due to https://bugs.chromium.org/p/v8/issues/detail?id=10527)`);if(l.month>13)throw RangeError(`Invalid month ${n} from ${s}[u-ca-${this.id}] (probably due to https://bugs.chromium.org/p/v8/issues/detail?id=10529)`);e[2]&&(l.monthExtra=e[2])}t===`day`&&(l.day=+n),this.hasEra&&t===`era`&&n!=null&&n!==``&&(l.era=n.split(` (`)[0].normalize(`NFD`).replace(/[^-0-9 \p{L}]/gu,``).replace(/ /g,`-`).toLowerCase())}if(this.hasEra&&l.eraYear===void 0)throw RangeError(`Intl.DateTimeFormat.formatToParts lacks relatedYear in ${this.id} calendar. Try Node 14+ or modern browsers.`);if(this.hasEra){let e=this.eras.find((e=>l.era===e.genericName));e&&(l.era=e.code)}if(this.reviseIntlEra){let{era:t,eraYear:n}=this.reviseIntlEra(l,e);l.era=t,l.eraYear=n}this.checkIcuBugs&&this.checkIcuBugs(e);let u=this.adjustCalendarDate(l,t,`constrain`,!0);if(u.year===void 0)throw RangeError(`Missing year converting ${JSON.stringify(e)}`);if(u.month===void 0)throw RangeError(`Missing month converting ${JSON.stringify(e)}`);if(u.day===void 0)throw RangeError(`Missing day converting ${JSON.stringify(e)}`);return t.set(a,u),[`constrain`,`reject`].forEach((n=>{let r=JSON.stringify({func:`calendarToIsoDate`,year:u.year,month:u.month,day:u.day,overflow:n,id:this.id});t.set(r,e)})),u}validateCalendarDate(e){let{month:t,year:n,day:r,eraYear:i,monthCode:a,monthExtra:o}=e;if(o!==void 0)throw RangeError("Unexpected `monthExtra` value");if(n===void 0&&i===void 0)throw TypeError(`year or eraYear is required`);if(t===void 0&&a===void 0)throw TypeError(`month or monthCode is required`);if(r===void 0)throw RangeError(`Missing day`);if(a!==void 0){if(typeof a!=`string`)throw RangeError(`monthCode must be a string, not `+typeof a);if(!/^M([01]?\d)(L?)$/.test(a))throw RangeError(`Invalid monthCode: ${a}`)}if(this.hasEra&&e.era===void 0!=(e.eraYear===void 0))throw TypeError(`properties era and eraYear must be provided together`)}adjustCalendarDate(e,t=void 0,n=`constrain`,r=!1){if(this.calendarType===`lunisolar`)throw RangeError(`Override required for lunisolar calendars`);let i=e;this.validateCalendarDate(i);let a=this.monthsInYear(i,t),{month:o,monthCode:s}=i;return{month:o,monthCode:s}=J$(i,n,a),{...i,month:o,monthCode:s}}regulateMonthDayNaive(e,t,n){let r=this.monthsInYear(e,n),{month:i,day:a}=e;return t===`reject`?(OQ(i,1,r),OQ(a,1,this.maximumMonthLength(e))):(i=EQ(i,1,r),a=EQ(a,1,this.maximumMonthLength({...e,month:i}))),{...e,month:i,day:a}}calendarToIsoDate(e,t=`constrain`,n){let r=e,i=this.adjustCalendarDate(e,n,t,!1);i=this.regulateMonthDayNaive(i,t,n);let{year:a,month:o,day:s}=i,c=JSON.stringify({func:`calendarToIsoDate`,year:a,month:o,day:s,overflow:t,id:this.id}),l,u=n.get(c);if(u||r.year!==void 0&&r.month!==void 0&&r.day!==void 0&&(r.year!==i.year||r.month!==i.month||r.day!==i.day)&&(l=JSON.stringify({func:`calendarToIsoDate`,year:r.year,month:r.month,day:r.day,overflow:t,id:this.id}),u=n.get(l),u))return u;let d=this.estimateIsoDate({year:a,month:o,day:s}),f=e=>{let r=this.addDaysIso(d,e);if(i.day>this.minimumMonthLength(i)){let e=this.isoToCalendarDate(r,n);for(;e.month!==o||e.year!==a;){if(t===`reject`)throw RangeError(`day ${s} does not exist in month ${o} of year ${a}`);r=this.addDaysIso(r,-1),e=this.isoToCalendarDate(r,n)}}return r},p=0,m=this.isoToCalendarDate(d,n),h=Z$(i,m);if(h.years!==0||h.months!==0||h.days!==0){let e=365*h.years+30*h.months+h.days;d=this.addDaysIso(d,e),m=this.isoToCalendarDate(d,n),h=Z$(i,m),h.years===0&&h.months===0?d=f(h.days):p=this.compareCalendarDates(i,m)}let g=8;for(;p;){d=this.addDaysIso(d,p*g);let e=m;m=this.isoToCalendarDate(d,n);let a=p;if(p=this.compareCalendarDates(i,m),p){if(h=Z$(i,m),h.years===0&&h.months===0)d=f(h.days),p=0;else if(a&&p!==a){if(g>1)g/=2;else{if(t===`reject`)throw RangeError(`Can't find ISO date from calendar date: ${JSON.stringify({...r})}`);this.compareCalendarDates(m,e)>0&&(d=this.addDaysIso(d,-1)),p=0}}}}if(n.set(c,d),l&&n.set(l,d),i.year===void 0||i.month===void 0||i.day===void 0||i.monthCode===void 0||this.hasEra&&(i.era===void 0||i.eraYear===void 0))throw RangeError(`Unexpected missing property`);return d}compareCalendarDates(e,t){return e.year===t.year?e.month===t.month?e.day===t.day?0:M$(e.day-t.day):M$(e.month-t.month):M$(e.year-t.year)}regulateDate(e,t=`constrain`,n){let r=this.calendarToIsoDate(e,t,n);return this.isoToCalendarDate(r,n)}addDaysIso(e,t){return xQ(e.year,e.month,e.day+t)}addDaysCalendar(e,t,n){let r=this.calendarToIsoDate(e,`constrain`,n),i=this.addDaysIso(r,t);return this.isoToCalendarDate(i,n)}addMonthsCalendar(e,t,n,r){let i=e,{day:a}=i;for(let e=0,n=Math.abs(t);e<n;e++){let{month:e}=i,n=i,o=t<0?-Math.max(a,this.daysInPreviousMonth(i,r)):this.daysInMonth(i,r),s=this.calendarToIsoDate(i,`constrain`,r),c=this.addDaysIso(s,o);if(i=this.isoToCalendarDate(c,r),t>0){let t=this.monthsInYear(n,r);for(;i.month-1!=e%t;)c=this.addDaysIso(c,-1),i=this.isoToCalendarDate(c,r)}i.day!==a&&(i=this.regulateDate({...i,day:a},`constrain`,r))}if(n===`reject`&&i.day!==a)throw RangeError(`Day ${a} does not exist in resulting calendar month`);return i}addCalendar(e,{years:t=0,months:n=0,weeks:r=0,days:i=0},a,o){let{year:s,day:c,monthCode:l}=e,u=this.adjustCalendarDate({year:s+t,monthCode:l,day:c},o),d=this.addMonthsCalendar(u,n,a,o),f=i+7*r;return this.addDaysCalendar(d,f,o)}untilCalendar(e,t,n,r){let i=0,a=0,o=0,s=0;switch(n){case`day`:i=this.calendarDaysUntil(e,t,r);break;case`week`:{let n=this.calendarDaysUntil(e,t,r);i=n%7,a=(n-i)/7;break}case`month`:case`year`:{let a=this.compareCalendarDates(t,e);if(!a)return{years:0,months:0,weeks:0,days:0};let c=t.year-e.year,l=t.day-e.day;if(n===`year`&&c){let n=0;t.monthCode>e.monthCode&&(n=1),t.monthCode<e.monthCode&&(n=-1),n||=Math.sign(l),s=n*a<0?c-a:c}let u,d=s?this.addCalendar(e,{years:s},`constrain`,r):e;do o+=a,u=d,d=this.addMonthsCalendar(u,a,`constrain`,r),d.day!==e.day&&(d=this.regulateDate({...d,day:e.day},`constrain`,r));while(this.compareCalendarDates(t,d)*a>=0);o-=a,i=this.calendarDaysUntil(u,t,r);break}}return{years:s,months:o,weeks:a,days:i}}daysInMonth(e,t){let{day:n}=e,r=this.maximumMonthLength(e),i=this.minimumMonthLength(e);if(i===r)return i;let a=n<=r-i?r:i,o=this.calendarToIsoDate(e,`constrain`,t),s=this.addDaysIso(o,a),c=this.isoToCalendarDate(s,t),l=this.addDaysIso(s,-c.day);return this.isoToCalendarDate(l,t).day}daysInPreviousMonth(e,t){let{day:n,month:r,year:i}=e,a={year:r>1?i:i-1,month:r,day:1},o=r>1?r-1:this.monthsInYear(a,t);a={...a,month:o};let s=this.minimumMonthLength(a),c=this.maximumMonthLength(a);if(s===c)return c;let l=this.calendarToIsoDate(e,`constrain`,t),u=this.addDaysIso(l,-n);return this.isoToCalendarDate(u,t).day}startOfCalendarYear(e){return{year:e.year,month:1,monthCode:`M01`,day:1}}startOfCalendarMonth(e){return{year:e.year,month:e.month,day:1}}calendarDaysUntil(e,t,n){let r=this.calendarToIsoDate(e,`constrain`,n),i=this.calendarToIsoDate(t,`constrain`,n);return UQ(i.year,i.month-1,i.day)-UQ(r.year,r.month-1,r.day)}monthDaySearchStartYear(e,t){return 1972}monthDayFromFields(e,t,n){let r,i,a,o,s,{era:c,eraYear:l,year:u,month:d,monthCode:f,day:p}=e;if(d!==void 0&&u===void 0&&(!this.hasEra||c===void 0||l===void 0))throw TypeError(`when month is present, year (or era and eraYear) are required`);(f===void 0||u!==void 0||this.hasEra&&l!==void 0)&&({monthCode:f,day:p}=this.isoToCalendarDate(this.calendarToIsoDate(e,t,n),n));let m={year:this.monthDaySearchStartYear(f,p),month:12,day:31},h=this.isoToCalendarDate(m,n),g=h.monthCode>f||h.monthCode===f&&h.day>=p?h.year:h.year-1;for(let e=0;e<20;e++){let c=this.adjustCalendarDate({day:p,monthCode:f,year:g-e},n),l=this.calendarToIsoDate(c,`constrain`,n),u=this.isoToCalendarDate(l,n);if({year:r,month:i,day:a}=l,u.monthCode===f&&u.day===p)return{month:i,day:a,year:r};if(t===`constrain`){let e=this.maxLengthOfMonthCodeInAnyYear(u.monthCode);if(u.monthCode===f&&u.day===e&&p>e)return{month:i,day:a,year:r};(o===void 0||u.monthCode===o.monthCode&&u.day>o.day)&&(o=u,s=l)}}if(t===`constrain`&&s!==void 0)return s;throw RangeError(`No recent ${this.id} year with monthCode ${f} and day ${p}`)}getFirstDayOfWeek(){}getMinimalDaysInFirstWeek(){}},$$=class extends Q${constructor(){super(...arguments),this.id=`hebrew`,this.calendarType=`lunisolar`,this.months={Tishri:{leap:1,regular:1,monthCode:`M01`,days:30},Heshvan:{leap:2,regular:2,monthCode:`M02`,days:{min:29,max:30}},Kislev:{leap:3,regular:3,monthCode:`M03`,days:{min:29,max:30}},Tevet:{leap:4,regular:4,monthCode:`M04`,days:29},Shevat:{leap:5,regular:5,monthCode:`M05`,days:30},Adar:{leap:void 0,regular:6,monthCode:`M06`,days:29},"Adar I":{leap:6,regular:void 0,monthCode:`M05L`,days:30},"Adar II":{leap:7,regular:void 0,monthCode:`M06`,days:29},Nisan:{leap:8,regular:7,monthCode:`M07`,days:30},Iyar:{leap:9,regular:8,monthCode:`M08`,days:29},Sivan:{leap:10,regular:9,monthCode:`M09`,days:30},Tamuz:{leap:11,regular:10,monthCode:`M10`,days:29},Av:{leap:12,regular:11,monthCode:`M11`,days:30},Elul:{leap:13,regular:12,monthCode:`M12`,days:29}}}inLeapYear(e){let{year:t}=e;return(7*t+1)%19<7}monthsInYear(e){return this.inLeapYear(e)?13:12}minimumMonthLength(e){return this.minMaxMonthLength(e,`min`)}maximumMonthLength(e){return this.minMaxMonthLength(e,`max`)}minMaxMonthLength(e,t){let{month:n,year:r}=e,i=this.getMonthCode(r,n),a=Object.entries(this.months).find((e=>e[1].monthCode===i));if(a===void 0)throw RangeError(`unmatched Hebrew month: ${n}`);let o=a[1].days;return typeof o==`number`?o:o[t]}maxLengthOfMonthCodeInAnyYear(e){return[`M04`,`M06`,`M08`,`M10`,`M12`].includes(e)?29:30}estimateIsoDate(e){let{year:t}=e;return{year:t-3760,month:1,day:1}}getMonthCode(e,t){return this.inLeapYear({year:e})?t===6?q$(5,!0):q$(t<6?t:t-1):q$(t)}adjustCalendarDate(e,t,n=`constrain`,r=!1){let{year:i,month:a,monthCode:o,day:s,monthExtra:c}=e;if(i===void 0)throw TypeError(`Missing property: year`);if(r){if(c){let e=this.months[c];if(!e)throw RangeError(`Unrecognized month from formatToParts: ${c}`);a=this.inLeapYear({year:i})?e.leap:e.regular}return o=this.getMonthCode(i,a),{year:i,month:a,day:s,monthCode:o}}if(this.validateCalendarDate(e),a===void 0){if(o.endsWith(`L`)){if(o!==`M05L`)throw RangeError(`Hebrew leap month must have monthCode M05L, not ${o}`);if(a=6,!this.inLeapYear({year:i})){if(n===`reject`)throw RangeError(`Hebrew monthCode M05L is invalid in year ${i} which is not a leap year`);a=6,o=`M06`}}else{a=K$(o),this.inLeapYear({year:i})&&a>=6&&a++;let e=this.monthsInYear({year:i});if(a<1||a>e)throw RangeError(`Invalid monthCode: ${o}`)}}else if(n===`reject`?(OQ(a,1,this.monthsInYear({year:i})),OQ(s,1,this.maximumMonthLength({year:i,month:a}))):(a=EQ(a,1,this.monthsInYear({year:i})),s=EQ(s,1,this.maximumMonthLength({year:i,month:a}))),o===void 0)o=this.getMonthCode(i,a);else if(this.getMonthCode(i,a)!==o)throw RangeError(`monthCode ${o} doesn't correspond to month ${a} in Hebrew year ${i}`);return{...e,day:s,month:a,monthCode:o,year:i}}},e1=class extends Q${constructor(){super(...arguments),this.calendarType=`lunar`,this.DAYS_PER_ISLAMIC_YEAR=354+11/30,this.DAYS_PER_ISO_YEAR=365.2425}inLeapYear(e,t){let n={year:e.year,month:1,monthCode:`M01`,day:1},r={year:e.year+1,month:1,monthCode:`M01`,day:1};return this.calendarDaysUntil(n,r,t)===355}monthsInYear(){return 12}minimumMonthLength(){return 29}maximumMonthLength(){return 30}maxLengthOfMonthCodeInAnyYear(){return 30}estimateIsoDate(e){let{year:t}=this.adjustCalendarDate(e);return{year:Math.floor(t*this.DAYS_PER_ISLAMIC_YEAR/this.DAYS_PER_ISO_YEAR)+622,month:1,day:1}}},t1=class extends e1{constructor(){super(...arguments),this.id=`islamic`}},n1=class extends e1{constructor(){super(...arguments),this.id=`islamic-umalqura`}},r1=class extends e1{constructor(){super(...arguments),this.id=`islamic-tbla`}},i1=class extends e1{constructor(){super(...arguments),this.id=`islamic-civil`}},a1=class extends e1{constructor(){super(...arguments),this.id=`islamic-rgsa`}},o1=class extends e1{constructor(){super(...arguments),this.id=`islamicc`}},s1=class extends Q${constructor(){super(...arguments),this.id=`persian`,this.calendarType=`solar`}inLeapYear(e,t){return this.daysInMonth({year:e.year,month:12,day:1},t)===30}monthsInYear(){return 12}minimumMonthLength(e){let{month:t}=e;return t===12?29:t<=6?31:30}maximumMonthLength(e){let{month:t}=e;return t===12?30:t<=6?31:30}maxLengthOfMonthCodeInAnyYear(e){return K$(e)<=6?31:30}estimateIsoDate(e){let{year:t}=this.adjustCalendarDate(e);return{year:t+621,month:1,day:1}}},c1=class extends Q${constructor(){super(...arguments),this.id=`indian`,this.calendarType=`solar`,this.months={1:{length:30,month:3,day:22,leap:{length:31,month:3,day:21}},2:{length:31,month:4,day:21},3:{length:31,month:5,day:22},4:{length:31,month:6,day:22},5:{length:31,month:7,day:23},6:{length:31,month:8,day:23},7:{length:30,month:9,day:23},8:{length:30,month:10,day:23},9:{length:30,month:11,day:22},10:{length:30,month:12,day:22},11:{length:30,month:1,nextYear:!0,day:21},12:{length:30,month:2,nextYear:!0,day:20}},this.vulnerableToBceBug=new Date(`0000-01-01T00:00Z`).toLocaleDateString(`en-US-u-ca-indian`,{timeZone:`UTC`})!==`10/11/-79 Saka`}inLeapYear(e){return l1(e.year+78)}monthsInYear(){return 12}minimumMonthLength(e){return this.getMonthInfo(e).length}maximumMonthLength(e){return this.getMonthInfo(e).length}maxLengthOfMonthCodeInAnyYear(e){let t=K$(e),n=this.months[t];return n=n.leap??n,n.length}getMonthInfo(e){let{month:t}=e,n=this.months[t];if(n===void 0)throw RangeError(`Invalid month: ${t}`);return this.inLeapYear(e)&&n.leap&&(n=n.leap),n}estimateIsoDate(e){let t=this.adjustCalendarDate(e),n=this.getMonthInfo(t);return xQ(t.year+78+ +!!n.nextYear,n.month,n.day+t.day-1)}checkIcuBugs(e){if(this.vulnerableToBceBug&&e.year<1)throw RangeError(`calendar '${this.id}' is broken for ISO dates before 0001-01-01 (see https://bugs.chromium.org/p/v8/issues/detail?id=10529)`)}};function l1(e){return e%4==0&&(e%100!=0||e%400==0)}var u1=class extends Q${constructor(e,t){super(),this.calendarType=`solar`,this.id=e,this.isoEpoch=t}inLeapYear(e){let{year:t}=this.estimateIsoDate({month:1,day:1,year:e.year});return l1(t)}monthsInYear(){return 12}minimumMonthLength(e){let{month:t}=e;return t===2?this.inLeapYear(e)?29:28:[4,6,9,11].indexOf(t)>=0?30:31}maximumMonthLength(e){return this.minimumMonthLength(e)}maxLengthOfMonthCodeInAnyYear(e){return[31,29,31,30,31,30,31,31,30,31,30,31][K$(e)-1]}estimateIsoDate(e){let t=this.adjustCalendarDate(e);return EX(t.year+this.isoEpoch.year,t.month+this.isoEpoch.month,t.day+this.isoEpoch.day,`constrain`)}},d1=class extends Q${constructor(e,t){super(),this.hasEra=!0,this.calendarType=`solar`,this.id=e;let{eras:n,anchorEra:r}=function(e){let t,n=e;if(n.length===0)throw RangeError(`Invalid era data: eras are required`);if(n.length===1&&n[0].reverseOf)throw RangeError(`Invalid era data: anchor era cannot count years backwards`);if(n.length===1&&!n[0].code)throw RangeError(`Invalid era data: at least one named era is required`);if(n.filter((e=>e.reverseOf!=null)).length>1)throw RangeError(`Invalid era data: only one era can count years backwards`);n.forEach((e=>{if(e.isAnchor||!e.anchorEpoch&&!e.reverseOf){if(t)throw RangeError(`Invalid era data: cannot have multiple anchor eras`);t=e,e.anchorEpoch={year:+!e.hasYearZero}}else if(!e.code)throw RangeError(`If era name is blank, it must be the anchor era`)})),n=n.filter((e=>e.code)),n.forEach((e=>{let{reverseOf:t}=e;if(t){let r=n.find((e=>e.code===t));if(r===void 0)throw RangeError(`Invalid era data: unmatched reverseOf era: ${t}`);e.reverseOf=r,e.anchorEpoch=r.anchorEpoch,e.isoEpoch=r.isoEpoch}e.anchorEpoch.month===void 0&&(e.anchorEpoch.month=1),e.anchorEpoch.day===void 0&&(e.anchorEpoch.day=1)})),n.sort(((e,t)=>{if(e.reverseOf)return 1;if(t.reverseOf)return-1;if(!e.isoEpoch||!t.isoEpoch)throw RangeError(`Invalid era data: missing ISO epoch`);return t.isoEpoch.year-e.isoEpoch.year}));let r=n[n.length-1].reverseOf;if(r&&r!==n[n.length-2])throw RangeError(`Invalid era data: invalid reverse-sign era`);return n.forEach(((e,t)=>{e.genericName=`era`+(n.length-1-t)})),{eras:n,anchorEra:t||n[0]}}(t);this.anchorEra=r,this.eras=n}inLeapYear(e){let{year:t}=this.estimateIsoDate({month:1,day:1,year:e.year});return l1(t)}monthsInYear(){return 12}minimumMonthLength(e){let{month:t}=e;return t===2?this.inLeapYear(e)?29:28:[4,6,9,11].indexOf(t)>=0?30:31}maximumMonthLength(e){return this.minimumMonthLength(e)}maxLengthOfMonthCodeInAnyYear(e){return[31,29,31,30,31,30,31,31,30,31,30,31][K$(e)-1]}completeEraYear(e){let t=(t,n,r)=>{let i=e[t];if(i!=null&&i!=n&&!(r||[]).includes(i)){let e=r?.[0];throw RangeError(`Input ${t} ${i} doesn't match calculated value ${e?`${n} (also called ${e})`:n}`)}},n=t=>{let n,r={...e,year:t},i=this.eras.find(((e,i)=>{if(i===this.eras.length-1){if(e.reverseOf){if(t>0)throw RangeError(`Signed year ${t} is invalid for era ${e.code}`);return n=e.anchorEpoch.year-t,!0}return n=t-e.anchorEpoch.year+ +!e.hasYearZero,!0}return this.compareCalendarDates(r,e.anchorEpoch)>=0&&(n=t-e.anchorEpoch.year+ +!e.hasYearZero,!0)}));if(!i)throw RangeError(`Year ${t} was not matched by any era`);return{eraYear:n,era:i.code,eraNames:i.names}},{year:r,eraYear:i,era:a}=e;if(r!=null){let e=n(r);({eraYear:i,era:a}=e),t(`era`,a,e?.eraNames),t(`eraYear`,i)}else{if(i==null)throw RangeError(`Either year or eraYear and era are required`);{if(a===void 0)throw RangeError(`era and eraYear must be provided together`);let e=this.eras.find((({code:e,names:t=[]})=>e===a||t.includes(a)));if(!e)throw RangeError(`Era ${a} (ISO year ${i}) was not matched by any era`);r=e.reverseOf?e.anchorEpoch.year-i:i+e.anchorEpoch.year-+!e.hasYearZero,t(`year`,r),{eraYear:i,era:a}=n(r)}}return{...e,year:r,eraYear:i,era:a}}adjustCalendarDate(e,t,n=`constrain`){let r=e,{month:i,monthCode:a}=r;return i===void 0&&(r={...r,month:K$(a)}),this.validateCalendarDate(r),r=this.completeEraYear(r),super.adjustCalendarDate(r,t,n)}estimateIsoDate(e){let{year:t,month:n,day:r}=this.adjustCalendarDate(e),{anchorEra:i}=this;return EX(t+i.isoEpoch.year-+!i.hasYearZero,n,r,`constrain`)}},f1=class extends d1{constructor(e,t){super(e,t)}isoToCalendarDate(e){let{year:t,month:n,day:r}=e,i=q$(n),a=t-this.anchorEra.isoEpoch.year+1;return this.completeEraYear({year:a,month:n,monthCode:i,day:r})}},p1={inLeapYear(e){let{year:t}=e;return(t+1)%4==0},monthsInYear:()=>13,minimumMonthLength(e){let{month:t}=e;return t===13?this.inLeapYear(e)?6:5:30},maximumMonthLength(e){return this.minimumMonthLength(e)},maxLengthOfMonthCodeInAnyYear:e=>e===`M13`?6:30},m1=class extends u1{constructor(e,t){super(e,t),this.inLeapYear=p1.inLeapYear,this.monthsInYear=p1.monthsInYear,this.minimumMonthLength=p1.minimumMonthLength,this.maximumMonthLength=p1.maximumMonthLength,this.maxLengthOfMonthCodeInAnyYear=p1.maxLengthOfMonthCodeInAnyYear}},h1=class extends d1{constructor(e,t){super(e,t),this.inLeapYear=p1.inLeapYear,this.monthsInYear=p1.monthsInYear,this.minimumMonthLength=p1.minimumMonthLength,this.maximumMonthLength=p1.maximumMonthLength,this.maxLengthOfMonthCodeInAnyYear=p1.maxLengthOfMonthCodeInAnyYear}},g1=class extends m1{constructor(){super(`ethioaa`,{year:-5492,month:7,day:17})}},_1=class extends h1{constructor(){super(`coptic`,[{code:`coptic`,isoEpoch:{year:284,month:8,day:29}},{code:`coptic-inverse`,reverseOf:`coptic`}])}},v1=class extends h1{constructor(){super(`ethiopic`,[{code:`ethioaa`,names:[`ethiopic-amete-alem`,`mundi`],isoEpoch:{year:-5492,month:7,day:17}},{code:`ethiopic`,names:[`incar`],isoEpoch:{year:8,month:8,day:27},anchorEpoch:{year:5501}}])}},y1=class extends f1{constructor(){super(`roc`,[{code:`roc`,names:[`minguo`],isoEpoch:{year:1912,month:1,day:1}},{code:`roc-inverse`,names:[`before-roc`],reverseOf:`roc`}])}},b1=class extends u1{constructor(){super(`buddhist`,{year:-543,month:1,day:1})}},x1=class extends f1{constructor(){super(`gregory`,[{code:`gregory`,names:[`ad`,`ce`],isoEpoch:{year:1,month:1,day:1}},{code:`gregory-inverse`,names:[`be`,`bce`],reverseOf:`gregory`}])}reviseIntlEra(e){let{era:t,eraYear:n}=e;return t===`b`&&(t=`gregory-inverse`),t===`a`&&(t=`gregory`),{era:t,eraYear:n}}getFirstDayOfWeek(){return 1}getMinimalDaysInFirstWeek(){return 1}},S1=class extends f1{constructor(){super(`japanese`,[{code:`reiwa`,isoEpoch:{year:2019,month:5,day:1},anchorEpoch:{year:2019,month:5,day:1}},{code:`heisei`,isoEpoch:{year:1989,month:1,day:8},anchorEpoch:{year:1989,month:1,day:8}},{code:`showa`,isoEpoch:{year:1926,month:12,day:25},anchorEpoch:{year:1926,month:12,day:25}},{code:`taisho`,isoEpoch:{year:1912,month:7,day:30},anchorEpoch:{year:1912,month:7,day:30}},{code:`meiji`,isoEpoch:{year:1868,month:9,day:8},anchorEpoch:{year:1868,month:9,day:8}},{code:`japanese`,names:[`japanese`,`gregory`,`ad`,`ce`],isoEpoch:{year:1,month:1,day:1}},{code:`japanese-inverse`,names:[`japanese-inverse`,`gregory-inverse`,`bc`,`bce`],reverseOf:`japanese`}]),this.erasBeginMidYear=!0}reviseIntlEra(e,t){let{era:n,eraYear:r}=e,{year:i}=t;return this.eras.find((e=>e.code===n))?{era:n,eraYear:r}:i<1?{era:`japanese-inverse`,eraYear:1-i}:{era:`japanese`,eraYear:i}}},C1=class extends Q${constructor(){super(...arguments),this.calendarType=`lunisolar`}inLeapYear(e,t){let n=this.getMonthList(e.year,t);return Object.entries(n).length===13}monthsInYear(e,t){return this.inLeapYear(e,t)?13:12}minimumMonthLength(){return 29}maximumMonthLength(){return 30}maxLengthOfMonthCodeInAnyYear(e){return[`M01L`,`M09L`,`M10L`,`M11L`,`M12L`].includes(e)?29:30}monthDaySearchStartYear(e,t){let n={M01L:[1651,1651],M02L:[1947,1765],M03L:[1966,1955],M04L:[1963,1944],M05L:[1971,1952],M06L:[1960,1941],M07L:[1968,1938],M08L:[1957,1718],M09L:[1832,1832],M10L:[1870,1870],M11L:[1814,1814],M12L:[1890,1890]}[e]??[1972,1972];return t<30?n[0]:n[1]}getMonthList(e,t){if(e===void 0)throw TypeError(`Missing year`);let n=JSON.stringify({func:`getMonthList`,calendarYear:e,id:this.id}),r=t.get(n);if(r)return r;let i=this.getFormatter(),a=(e,t)=>{let n=X$({isoYear:e,isoMonth:2,isoDay:1}),r=new Date(n);r.setUTCDate(t+1);let a=i.formatToParts(r),o=a.find((e=>e.type===`month`)).value,s=+a.find((e=>e.type===`day`)).value,c=a.find((e=>e.type===`relatedYear`)),l;if(c===void 0)throw RangeError(`Intl.DateTimeFormat.formatToParts lacks relatedYear in ${this.id} calendar. Try Node 14+ or modern browsers.`);return l=+c.value,{calendarMonthString:o,calendarDay:s,calendarYearToVerify:l}},o=17,{calendarMonthString:s,calendarDay:c,calendarYearToVerify:l}=a(e,o);s!==`1`&&(o+=29,{calendarMonthString:s,calendarDay:c}=a(e,o)),o-=c-5;let u={},d,f,p=1,m=!1;do({calendarMonthString:s,calendarDay:c,calendarYearToVerify:l}=a(e,o)),d&&(u[f].daysInMonth=d+30-c),l===e?(u[s]={monthIndex:p++},o+=30):m=!0,d=c,f=s;while(!m);return u[f].daysInMonth=d+30-c,t.set(n,u),u}estimateIsoDate(e){let{year:t,month:n}=e;return{year:t,month:n>=12?12:n+1,day:1}}adjustCalendarDate(e,t,n=`constrain`,r=!1){let{year:i,month:a,monthExtra:o,day:s,monthCode:c}=e;if(i===void 0)throw TypeError(`Missing property: year`);if(r){if(o&&o!==`bis`)throw RangeError(`Unexpected leap month suffix: ${o}`);let e=q$(a,o!==void 0),n=`${a}${o||``}`,r=this.getMonthList(i,t)[n];if(r===void 0)throw RangeError(`Unmatched month ${n} in Chinese year ${i}`);return a=r.monthIndex,{year:i,month:a,day:s,monthCode:e}}if(this.validateCalendarDate(e),a===void 0){let e=this.getMonthList(i,t),r=c.replace(/^M|L$/g,(e=>e===`L`?`bis`:``));r[0]===`0`&&(r=r.slice(1));let o=e[r];if(a=o&&o.monthIndex,a===void 0&&c.endsWith(`L`)&&c!=`M13L`&&n===`constrain`){let t=+c.replace(/^M0?|L$/g,``);o=e[t],o&&(a=o.monthIndex,c=q$(t))}if(a===void 0)throw RangeError(`Unmatched month ${c} in Chinese year ${i}`)}else if(c===void 0){let e=this.getMonthList(i,t),r=Object.entries(e),o=r.length;n===`reject`?(OQ(a,1,o),OQ(s,1,this.maximumMonthLength())):(a=EQ(a,1,o),s=EQ(s,1,this.maximumMonthLength()));let l=r.find((e=>e[1].monthIndex===a));if(l===void 0)throw RangeError(`Invalid month ${a} in Chinese year ${i}`);c=q$(+l[0].replace(`bis`,``),l[0].indexOf(`bis`)!==-1)}else{let e=this.getMonthList(i,t),n=c.replace(/^M|L$/g,(e=>e===`L`?`bis`:``));n[0]===`0`&&(n=n.slice(1));let r=e[n];if(!r)throw RangeError(`Unmatched monthCode ${c} in Chinese year ${i}`);if(a!==r.monthIndex)throw RangeError(`monthCode ${c} doesn't correspond to month ${a} in Chinese year ${i}`)}return{...e,year:i,month:a,monthCode:c,day:s}}},w1=class extends C1{constructor(){super(...arguments),this.id=`chinese`}},T1=class extends C1{constructor(){super(...arguments),this.id=`dangi`}},Rle=class{constructor(e){this.helper=e}extraFields(e){return this.helper.hasEra&&e.includes(`year`)?[`era`,`eraYear`]:[]}resolveFields(e){if(this.helper.calendarType!==`lunisolar`){let t=new Y$;J$(e,void 0,this.helper.monthsInYear({year:e.year??1972},t))}}dateToISO(e,t){let n=new Y$,r=this.helper.calendarToIsoDate(e,t,n);return n.setObject(r),r}monthDayToISOReferenceDate(e,t){let n=new Y$,r=this.helper.monthDayFromFields(e,t,n);return n.setObject(r),r}fieldKeysToIgnore(e){let t=new Set;for(let n=0;n<e.length;n++){let r=e[n];switch(t.add(r),r){case`era`:t.add(`eraYear`),t.add(`year`);break;case`eraYear`:t.add(`era`),t.add(`year`);break;case`year`:t.add(`era`),t.add(`eraYear`);break;case`month`:t.add(`monthCode`),this.helper.erasBeginMidYear&&(t.add(`era`),t.add(`eraYear`));break;case`monthCode`:t.add(`month`),this.helper.erasBeginMidYear&&(t.add(`era`),t.add(`eraYear`));break;case`day`:this.helper.erasBeginMidYear&&(t.add(`era`),t.add(`eraYear`))}}return H$(t)}dateAdd(e,{years:t,months:n,weeks:r,days:i},a){let o=Y$.getCacheForObject(e),s=this.helper.isoToCalendarDate(e,o),c=this.helper.addCalendar(s,{years:t,months:n,weeks:r,days:i},a,o),l=this.helper.calendarToIsoDate(c,`constrain`,o);return Y$.getCacheForObject(l)||new Y$(o).setObject(l),l}dateUntil(e,t,n){let r=Y$.getCacheForObject(e),i=Y$.getCacheForObject(t),a=this.helper.isoToCalendarDate(e,r),o=this.helper.isoToCalendarDate(t,i);return this.helper.untilCalendar(a,o,n,r)}isoToDate(e,t){let n=Y$.getCacheForObject(e),r=this.helper.isoToCalendarDate(e,n);if(t.dayOfWeek&&(r.dayOfWeek=G$.iso8601.isoToDate(e,{dayOfWeek:!0}).dayOfWeek),t.dayOfYear){let e=this.helper.startOfCalendarYear(r);r.dayOfYear=this.helper.calendarDaysUntil(e,r,n)+1}if(t.weekOfYear&&(r.weekOfYear=U$(this.helper.id,e)),r.daysInWeek=7,t.daysInMonth&&(r.daysInMonth=this.helper.daysInMonth(r,n)),t.daysInYear){let e=this.helper.startOfCalendarYear(r),t=this.helper.addCalendar(e,{years:1},`constrain`,n);r.daysInYear=this.helper.calendarDaysUntil(e,t,n)}return t.monthsInYear&&(r.monthsInYear=this.helper.monthsInYear(r,n)),t.inLeapYear&&(r.inLeapYear=this.helper.inLeapYear(r,n)),r}getFirstDayOfWeek(){return this.helper.getFirstDayOfWeek()}getMinimalDaysInFirstWeek(){return this.helper.getMinimalDaysInFirstWeek()}};for(let e of[$$,s1,v1,g1,_1,w1,T1,y1,c1,b1,x1,S1,t1,n1,r1,i1,a1,o1]){let t=new e;G$[t.id]=new Rle(t)}nY(`calendarImpl`,(function(e){return G$[e]}));var E1=Intl.DateTimeFormat;function D1(e,t){let n=Q(e,t);return typeof n==`function`&&(n=new E1(Q(e,GJ),n(Q(e,KJ))),function(e,t,n){let r=YJ(e);if(r===void 0)throw TypeError(`Missing slots for the given container`);if(r[t]===void 0)throw TypeError(`tried to reset ${t} which was not set`);r[t]=n}(e,t,n)),n}function O1(e){return QJ(e,VJ)}var k1=class{constructor(e=void 0,t=void 0){(function(e,t,n){let r=n!==void 0,i;if(r){let e=[`localeMatcher`,`calendar`,`numberingSystem`,`hour12`,`hourCycle`,`timeZone`,`weekday`,`era`,`year`,`month`,`day`,`dayPeriod`,`hour`,`minute`,`second`,`fractionalSecondDigits`,`timeZoneName`,`formatMatcher`,`dateStyle`,`timeStyle`];i=function(e){if(e==null)throw TypeError(`Expected object not ${e}`);return Object(e)}(n);let t=Object.create(null);for(let n=0;n<e.length;n++){let r=e[n];Object.prototype.hasOwnProperty.call(i,r)&&(t[r]=i[r])}i=t}else i=Object.create(null);let a=new E1(t,i),o=a.resolvedOptions();if(ZJ(e),r){let t=Object.assign(Object.create(null),o);for(let e in t)Object.prototype.hasOwnProperty.call(i,e)||delete t[e];t.hour12=i.hour12,t.hourCycle=i.hourCycle,$J(e,KJ,t)}else $J(e,KJ,i);$J(e,GJ,o.locale),$J(e,VJ,a),$J(e,HJ,o.timeZone),$J(e,WJ,o.calendar),$J(e,FJ,qle),$J(e,IJ,Gle),$J(e,LJ,Kle),$J(e,RJ,Wle),$J(e,zJ,Jle),$J(e,BJ,Yle);let s=r?i.timeZone:void 0;if(s===void 0)$J(e,UJ,o.timeZone);else{let t=HY(s);if(t.startsWith(`−`))throw RangeError(`Unicode minus (U+2212) is not supported in time zone offsets`);$J(e,UJ,NZ(t))}})(this,e,t)}get format(){$(this,O1);let e=Ble.bind(this);return Object.defineProperties(e,{length:{value:1,enumerable:!1,writable:!1,configurable:!0},name:{value:``,enumerable:!1,writable:!1,configurable:!0}}),e}formatRange(e,t){return $(this,O1),Hle.call(this,e,t)}formatToParts(e,...t){return $(this,O1),Vle.call(this,e,...t)}formatRangeToParts(e,t){return $(this,O1),Ule.call(this,e,t)}resolvedOptions(){return $(this,O1),zle.call(this)}};`formatToParts`in E1.prototype||delete k1.prototype.formatToParts,`formatRangeToParts`in E1.prototype||delete k1.prototype.formatRangeToParts;var A1=function(e=void 0,t=void 0){return new k1(e,t)};function zle(){let e=Q(this,VJ).resolvedOptions();return e.timeZone=Q(this,UJ),e}function Ble(e,...t){let n,r,i=R1(e,this);return i.formatter?(n=i.formatter,r=[D$(i.epochNs,`floor`)]):(n=Q(this,VJ),r=[e,...t]),n.format(...r)}function Vle(e,...t){let n,r,i=R1(e,this);return i.formatter?(n=i.formatter,r=[D$(i.epochNs,`floor`)]):(n=Q(this,VJ),r=[e,...t]),n.formatToParts(...r)}function Hle(e,t){if(e===void 0||t===void 0)throw TypeError(`Intl.DateTimeFormat.formatRange requires two values`);let n=I1(e),r=I1(t),i,a=[n,r];if(F1(n)!==F1(r))throw TypeError(`Intl.DateTimeFormat.formatRange accepts two values of the same type`);if(F1(n)){if(!L1(n,r))throw TypeError(`Intl.DateTimeFormat.formatRange accepts two values of the same type`);let{epochNs:e,formatter:t}=R1(n,this),{epochNs:o,formatter:s}=R1(r,this);t&&(i=t,a=[D$(e,`floor`),D$(o,`floor`)])}return i||=Q(this,VJ),i.formatRange(...a)}function Ule(e,t){if(e===void 0||t===void 0)throw TypeError(`Intl.DateTimeFormat.formatRange requires two values`);let n=I1(e),r=I1(t),i,a=[n,r];if(F1(n)!==F1(r))throw TypeError(`Intl.DateTimeFormat.formatRangeToParts accepts two values of the same type`);if(F1(n)){if(!L1(n,r))throw TypeError(`Intl.DateTimeFormat.formatRangeToParts accepts two values of the same type`);let{epochNs:e,formatter:t}=R1(n,this),{epochNs:o,formatter:s}=R1(r,this);t&&(i=t,a=[D$(e,`floor`),D$(o,`floor`)])}return i||=Q(this,VJ),i.formatRangeToParts(...a)}function j1(e={},t={}){let n=Object.assign({},e),r=[`year`,`month`,`day`,`hour`,`minute`,`second`,`weekday`,`dayPeriod`,`timeZoneName`,`dateStyle`,`timeStyle`];for(let e=0;e<r.length;e++){let i=r[e];n[i]=i in t?t[i]:n[i],!1!==n[i]&&n[i]!==void 0||delete n[i]}return n}function Wle(e){let t=j1(e,{year:!1,month:!1,day:!1,weekday:!1,timeZoneName:!1,dateStyle:!1});if(t.timeStyle!==`long`&&t.timeStyle!==`full`||(delete t.timeStyle,Object.assign(t,{hour:`numeric`,minute:`2-digit`,second:`2-digit`})),!N1(t)){if(P1(e))throw TypeError(`cannot format Temporal.PlainTime with options [${Object.keys(e)}]`);Object.assign(t,{hour:`numeric`,minute:`numeric`,second:`numeric`})}return t}function Gle(e){let t={short:{year:`2-digit`,month:`numeric`},medium:{year:`numeric`,month:`short`},long:{year:`numeric`,month:`long`},full:{year:`numeric`,month:`long`}},n=j1(e,{day:!1,hour:!1,minute:!1,second:!1,weekday:!1,dayPeriod:!1,timeZoneName:!1,timeStyle:!1});if(`dateStyle`in n&&n.dateStyle){let e=n.dateStyle;delete n.dateStyle,Object.assign(n,t[e])}if(!(`year`in n||`month`in n||`era`in n)){if(P1(e))throw TypeError(`cannot format PlainYearMonth with options [${Object.keys(e)}]`);Object.assign(n,{year:`numeric`,month:`numeric`})}return n}function Kle(e){let t={short:{month:`numeric`,day:`numeric`},medium:{month:`short`,day:`numeric`},long:{month:`long`,day:`numeric`},full:{month:`long`,day:`numeric`}},n=j1(e,{year:!1,hour:!1,minute:!1,second:!1,weekday:!1,dayPeriod:!1,timeZoneName:!1,timeStyle:!1});if(`dateStyle`in n&&n.dateStyle){let e=n.dateStyle;delete n.dateStyle,Object.assign(n,t[e])}if(!(`month`in n)&&!(`day`in n)){if(P1(e))throw TypeError(`cannot format PlainMonthDay with options [${Object.keys(e)}]`);Object.assign(n,{month:`numeric`,day:`numeric`})}return n}function qle(e){let t=j1(e,{hour:!1,minute:!1,second:!1,dayPeriod:!1,timeZoneName:!1,timeStyle:!1});if(!M1(t)){if(P1(e))throw TypeError(`cannot format PlainDate with options [${Object.keys(e)}]`);Object.assign(t,{year:`numeric`,month:`numeric`,day:`numeric`})}return t}function Jle(e){let t=j1(e,{timeZoneName:!1});if((t.timeStyle===`long`||t.timeStyle===`full`)&&(delete t.timeStyle,Object.assign(t,{hour:`numeric`,minute:`2-digit`,second:`2-digit`}),t.dateStyle)&&(Object.assign(t,{short:{year:`numeric`,month:`numeric`,day:`numeric`},medium:{year:`numeric`,month:`short`,day:`numeric`},long:{year:`numeric`,month:`long`,day:`numeric`},full:{year:`numeric`,month:`long`,day:`numeric`,weekday:`long`}}[t.dateStyle]),delete t.dateStyle),!N1(t)&&!M1(t)){if(P1(e))throw TypeError(`cannot format PlainDateTime with options [${Object.keys(e)}]`);Object.assign(t,{year:`numeric`,month:`numeric`,day:`numeric`,hour:`numeric`,minute:`numeric`,second:`numeric`})}return t}function Yle(e){let t=e;return N1(t)||M1(t)||(t=Object.assign({},t,{year:`numeric`,month:`numeric`,day:`numeric`,hour:`numeric`,minute:`numeric`,second:`numeric`})),t}function M1(e){return`year`in e||`month`in e||`day`in e||`weekday`in e||`dateStyle`in e||`era`in e}function N1(e){return`hour`in e||`minute`in e||`second`in e||`timeStyle`in e||`dayPeriod`in e||`fractionalSecondDigits`in e}function P1(e){return M1(e)||N1(e)||`dateStyle`in e||`timeStyle`in e||`timeZoneName`in e}function F1(e){return lX(e)||uX(e)||dX(e)||mX(e)||fX(e)||pX(e)||sX(e)}function I1(e){return F1(e)?e:VY(e)}function L1(e,t){return!(!F1(e)||!F1(t)||uX(e)&&!uX(t)||lX(e)&&!lX(t)||dX(e)&&!dX(t)||mX(e)&&!mX(t)||fX(e)&&!fX(t)||pX(e)&&!pX(t)||sX(e)&&!sX(t))}function R1(e,t){if(uX(e)){let n={isoDate:{year:1970,month:1,day:1},time:Q(e,bJ)};return{epochNs:RZ(Q(t,HJ),n,`compatible`),formatter:D1(t,RJ)}}if(fX(e)){let n=Q(e,Z),r=Q(t,WJ);if(n!==r)throw RangeError(`cannot format PlainYearMonth with calendar ${n} in locale with calendar ${r}`);let i=AX(Q(e,vJ),{deltaDays:0,hour:12,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0});return{epochNs:RZ(Q(t,HJ),i,`compatible`),formatter:D1(t,IJ)}}if(pX(e)){let n=Q(e,Z),r=Q(t,WJ);if(n!==r)throw RangeError(`cannot format PlainMonthDay with calendar ${n} in locale with calendar ${r}`);let i=AX(Q(e,vJ),{deltaDays:0,hour:12,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0});return{epochNs:RZ(Q(t,HJ),i,`compatible`),formatter:D1(t,LJ)}}if(lX(e)){let n=Q(e,Z),r=Q(t,WJ);if(n!==`iso8601`&&n!==r)throw RangeError(`cannot format PlainDate with calendar ${n} in locale with calendar ${r}`);let i=AX(Q(e,vJ),{deltaDays:0,hour:12,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0});return{epochNs:RZ(Q(t,HJ),i,`compatible`),formatter:D1(t,FJ)}}if(dX(e)){let n=Q(e,Z),r=Q(t,WJ);if(n!==`iso8601`&&n!==r)throw RangeError(`cannot format PlainDateTime with calendar ${n} in locale with calendar ${r}`);let i=Q(e,yJ);return{epochNs:RZ(Q(t,HJ),i,`compatible`),formatter:D1(t,zJ)}}if(mX(e))throw TypeError(`Temporal.ZonedDateTime not supported in DateTimeFormat methods. Use toLocaleString() instead.`);return sX(e)?{epochNs:Q(e,_J),formatter:D1(t,BJ)}:{}}function z1(e){let t=Object.create(null);return t.years=Q(e,TJ),t.months=Q(e,EJ),t.weeks=Q(e,DJ),t.days=Q(e,OJ),t.hours=Q(e,kJ),t.minutes=Q(e,AJ),t.seconds=Q(e,jJ),t.milliseconds=Q(e,MJ),t.microseconds=Q(e,NJ),t.nanoseconds=Q(e,PJ),t}k1.prototype.constructor=A1,Object.defineProperty(A1,"prototype",{value:k1.prototype,writable:!1,enumerable:!1,configurable:!1}),A1.supportedLocalesOf=E1.supportedLocalesOf,tY(A1,`Intl.DateTimeFormat`);var{format:Xle,formatToParts:Zle}=Intl.DurationFormat?.prototype??Object.create(null);function B1(e){Intl.DurationFormat.prototype.resolvedOptions.call(this);let t=z1(tZ(e));return Xle.call(this,t)}Intl.DurationFormat?.prototype&&(Intl.DurationFormat.prototype.format=B1,Intl.DurationFormat.prototype.formatToParts=function(e){Intl.DurationFormat.prototype.resolvedOptions.call(this);let t=z1(tZ(e));return Zle.call(this,t)}),Object.freeze({__proto__:null,DateTimeFormat:A1,ModifiedIntlDurationFormatPrototypeFormat:B1});var V1=class{constructor(e){if(arguments.length<1)throw TypeError(`missing argument: epochNanoseconds is required`);yZ(this,k$(e))}get epochMilliseconds(){return $(this,sX),D$(Q(this,_J),`floor`)}get epochNanoseconds(){return $(this,sX),E$(X.default.BigInt(Q(this,_J)))}add(e){return $(this,sX),d$(`add`,this,e)}subtract(e){return $(this,sX),d$(`subtract`,this,e)}until(e,t=void 0){return $(this,sX),t$(`until`,this,e,t)}since(e,t=void 0){return $(this,sX),t$(`since`,this,e,t)}round(e){if($(this,sX),e===void 0)throw TypeError(`options parameter is required`);let t=typeof e==`string`?P$(`smallestUnit`,e):N$(e),n=IX(t),r=NX(t,`halfExpand`),i=VX(t,`smallestUnit`,`time`,BX);return LX(n,{hour:24,minute:1440,second:86400,millisecond:864e5,microsecond:864e8,nanosecond:864e11}[i],!0),bZ(v$(Q(this,_J),n,i,r))}equals(e){$(this,sX);let t=nZ(e),n=Q(this,_J),r=Q(t,_J);return X.default.equal(X.default.BigInt(n),X.default.BigInt(r))}toString(e=void 0){$(this,sX);let t=N$(e),n=RX(t),r=NX(t,`trunc`),i=VX(t,`smallestUnit`,`time`,void 0);if(i===`hour`)throw RangeError(`smallestUnit must be a time unit other than "hour"`);let a=t.timeZone;a!==void 0&&(a=NZ(a));let{precision:o,unit:s,increment:c}=zX(i,n);return KZ(bZ(v$(Q(this,_J),c,s,r)),a,o)}toJSON(){return $(this,sX),KZ(this,void 0,`auto`)}toLocaleString(e=void 0,t=void 0){return $(this,sX),new A1(e,t).format(this)}valueOf(){R$(`Instant`)}toZonedDateTimeISO(e){$(this,sX);let t=NZ(e);return SZ(Q(this,_J),t,`iso8601`)}static fromEpochMilliseconds(e){return bZ(O$(VY(e)))}static fromEpochNanoseconds(e){return bZ(k$(e))}static from(e){return nZ(e)}static compare(e,t){let n=nZ(e),r=nZ(t),i=Q(n,_J),a=Q(r,_J);return X.default.lessThan(i,a)?-1:+!!X.default.greaterThan(i,a)}};tY(V1,`Temporal.Instant`);var H1=class{constructor(e,t,n,r=`iso8601`){let i=UY(e),a=UY(t),o=UY(n),s=I$(r===void 0?`iso8601`:qY(r));kQ(i,a,o),lZ(this,{year:i,month:a,day:o},s)}get calendarId(){return $(this,lX),Q(this,Z)}get era(){return U1(this,`era`)}get eraYear(){return U1(this,`eraYear`)}get year(){return U1(this,`year`)}get month(){return U1(this,`month`)}get monthCode(){return U1(this,`monthCode`)}get day(){return U1(this,`day`)}get dayOfWeek(){return U1(this,`dayOfWeek`)}get dayOfYear(){return U1(this,`dayOfYear`)}get weekOfYear(){return U1(this,`weekOfYear`)?.week}get yearOfWeek(){return U1(this,`weekOfYear`)?.year}get daysInWeek(){return U1(this,`daysInWeek`)}get daysInMonth(){return U1(this,`daysInMonth`)}get daysInYear(){return U1(this,`daysInYear`)}get monthsInYear(){return U1(this,`monthsInYear`)}get inLeapYear(){return U1(this,`inLeapYear`)}with(e,t=void 0){if($(this,lX),!BY(e))throw TypeError(`invalid argument`);hX(e);let n=Q(this,Z),r=YX(n,Q(this,vJ));return r=wZ(n,r,XX(n,e,[`year`,`month`,`monthCode`,`day`],[],`partial`)),uZ(AZ(n,r,jX(N$(t))),n)}withCalendar(e){$(this,lX);let t=DZ(e);return uZ(Q(this,vJ),t)}add(e,t=void 0){return $(this,lX),f$(`add`,this,e,t)}subtract(e,t=void 0){return $(this,lX),f$(`subtract`,this,e,t)}until(e,t=void 0){return $(this,lX),n$(`until`,this,e,t)}since(e,t=void 0){return $(this,lX),n$(`since`,this,e,t)}equals(e){$(this,lX);let t=QX(e);return C$(Q(this,vJ),Q(t,vJ))===0&&kZ(Q(this,Z),Q(t,Z))}toString(e=void 0){return $(this,lX),JZ(this,FX(N$(e)))}toJSON(){return $(this,lX),JZ(this)}toLocaleString(e=void 0,t=void 0){return $(this,lX),new A1(e,t).format(this)}valueOf(){R$(`PlainDate`)}toPlainDateTime(e=void 0){$(this,lX);let t=aZ(e);return fZ(AX(Q(this,vJ),t),Q(this,Z))}toZonedDateTime(e){let t,n;if($(this,lX),BY(e)){let r=e.timeZone;r===void 0?t=NZ(e):(t=NZ(r),n=e.plainTime)}else t=NZ(e);let r=Q(this,vJ),i;return n===void 0?i=VZ(t,r):(n=iZ(n),i=RZ(t,AX(r,Q(n,bJ)),`compatible`)),SZ(i,t,Q(this,Z))}toPlainYearMonth(){$(this,lX);let e=Q(this,Z);return vZ(jZ(e,YX(e,Q(this,vJ)),`constrain`),e)}toPlainMonthDay(){$(this,lX);let e=Q(this,Z);return mZ(MZ(e,YX(e,Q(this,vJ)),`constrain`),e)}static from(e,t=void 0){return QX(e,t)}static compare(e,t){let n=QX(e),r=QX(t);return C$(Q(n,vJ),Q(r,vJ))}};function U1(e,t){$(e,lX);let n=Q(e,vJ);return JX(e).isoToDate(n,{[t]:!0})[t]}tY(H1,`Temporal.PlainDate`);var W1=class{constructor(e,t,n,r=0,i=0,a=0,o=0,s=0,c=0,l=`iso8601`){let u=UY(e),d=UY(t),f=UY(n),p=r===void 0?0:UY(r),m=i===void 0?0:UY(i),h=a===void 0?0:UY(a),g=o===void 0?0:UY(o),_=s===void 0?0:UY(s),v=c===void 0?0:UY(c),y=I$(l===void 0?`iso8601`:qY(l));MQ(u,d,f,p,m,h,g,_,v),dZ(this,{isoDate:{year:u,month:d,day:f},time:{hour:p,minute:m,second:h,millisecond:g,microsecond:_,nanosecond:v}},y)}get calendarId(){return $(this,dX),Q(this,Z)}get year(){return G1(this,`year`)}get month(){return G1(this,`month`)}get monthCode(){return G1(this,`monthCode`)}get day(){return G1(this,`day`)}get hour(){return K1(this,`hour`)}get minute(){return K1(this,`minute`)}get second(){return K1(this,`second`)}get millisecond(){return K1(this,`millisecond`)}get microsecond(){return K1(this,`microsecond`)}get nanosecond(){return K1(this,`nanosecond`)}get era(){return G1(this,`era`)}get eraYear(){return G1(this,`eraYear`)}get dayOfWeek(){return G1(this,`dayOfWeek`)}get dayOfYear(){return G1(this,`dayOfYear`)}get weekOfYear(){return G1(this,`weekOfYear`)?.week}get yearOfWeek(){return G1(this,`weekOfYear`)?.year}get daysInWeek(){return G1(this,`daysInWeek`)}get daysInYear(){return G1(this,`daysInYear`)}get daysInMonth(){return G1(this,`daysInMonth`)}get monthsInYear(){return G1(this,`monthsInYear`)}get inLeapYear(){return G1(this,`inLeapYear`)}with(e,t=void 0){if($(this,dX),!BY(e))throw TypeError(`invalid argument`);hX(e);let n=Q(this,Z),r=Q(this,yJ),i={...YX(n,r.isoDate),...r.time};return i=wZ(n,i,XX(n,e,[`year`,`month`,`monthCode`,`day`],[`hour`,`minute`,`second`,`millisecond`,`microsecond`,`nanosecond`],`partial`)),fZ($X(n,i,jX(N$(t))),n)}withPlainTime(e=void 0){$(this,dX);let t=aZ(e);return fZ(AX(Q(this,yJ).isoDate,t),Q(this,Z))}withCalendar(e){$(this,dX);let t=DZ(e);return fZ(Q(this,yJ),t)}add(e,t=void 0){return $(this,dX),p$(`add`,this,e,t)}subtract(e,t=void 0){return $(this,dX),p$(`subtract`,this,e,t)}until(e,t=void 0){return $(this,dX),r$(`until`,this,e,t)}since(e,t=void 0){return $(this,dX),r$(`since`,this,e,t)}round(e){if($(this,dX),e===void 0)throw TypeError(`options parameter is required`);let t=typeof e==`string`?P$(`smallestUnit`,e):N$(e),n=IX(t),r=NX(t,`halfExpand`),i=VX(t,`smallestUnit`,`time`,BX,[`day`]),a={day:1,hour:24,minute:60,second:60,millisecond:1e3,microsecond:1e3,nanosecond:1e3}[i];LX(n,a,a===1);let o=Q(this,yJ);return fZ(n===1&&i===`nanosecond`?o:y$(o,n,i,r),Q(this,Z))}equals(e){$(this,dX);let t=eZ(e);return T$(Q(this,yJ),Q(t,yJ))===0&&kZ(Q(this,Z),Q(t,Z))}toString(e=void 0){$(this,dX);let t=N$(e),n=FX(t),r=RX(t),i=NX(t,`trunc`),a=VX(t,`smallestUnit`,`time`,void 0);if(a===`hour`)throw RangeError(`smallestUnit must be a time unit other than "hour"`);let{precision:o,unit:s,increment:c}=zX(a,r),l=y$(Q(this,yJ),c,s,i);return NQ(l),XZ(l,Q(this,Z),o,n)}toJSON(){return $(this,dX),XZ(Q(this,yJ),Q(this,Z),`auto`)}toLocaleString(e=void 0,t=void 0){return $(this,dX),new A1(e,t).format(this)}valueOf(){R$(`PlainDateTime`)}toZonedDateTime(e,t=void 0){$(this,dX);let n=NZ(e),r=MX(N$(t));return SZ(RZ(n,Q(this,yJ),r),n,Q(this,Z))}toPlainDate(){return $(this,dX),uZ(Q(this,yJ).isoDate,Q(this,Z))}toPlainTime(){return $(this,dX),gZ(Q(this,yJ).time)}static from(e,t=void 0){return eZ(e,t)}static compare(e,t){let n=eZ(e),r=eZ(t);return T$(Q(n,yJ),Q(r,yJ))}};function G1(e,t){$(e,dX);let n=Q(e,yJ).isoDate;return JX(e).isoToDate(n,{[t]:!0})[t]}function K1(e,t){return $(e,dX),Q(e,yJ).time[t]}tY(W1,`Temporal.PlainDateTime`);var q1=class e{constructor(e=0,t=0,n=0,r=0,i=0,a=0,o=0,s=0,c=0,l=0){let u=e===void 0?0:GY(e),d=t===void 0?0:GY(t),f=n===void 0?0:GY(n),p=r===void 0?0:GY(r),m=i===void 0?0:GY(i),h=a===void 0?0:GY(a),g=o===void 0?0:GY(o),_=s===void 0?0:GY(s),v=c===void 0?0:GY(c),y=l===void 0?0:GY(l);LQ(u,d,f,p,m,h,g,_,v,y),ZJ(this),$J(this,TJ,u),$J(this,EJ,d),$J(this,DJ,f),$J(this,OJ,p),$J(this,kJ,m),$J(this,AJ,h),$J(this,jJ,g),$J(this,MJ,_),$J(this,NJ,v),$J(this,PJ,y)}get years(){return $(this,cX),Q(this,TJ)}get months(){return $(this,cX),Q(this,EJ)}get weeks(){return $(this,cX),Q(this,DJ)}get days(){return $(this,cX),Q(this,OJ)}get hours(){return $(this,cX),Q(this,kJ)}get minutes(){return $(this,cX),Q(this,AJ)}get seconds(){return $(this,cX),Q(this,jJ)}get milliseconds(){return $(this,cX),Q(this,MJ)}get microseconds(){return $(this,cX),Q(this,NJ)}get nanoseconds(){return $(this,cX),Q(this,PJ)}get sign(){return $(this,cX),_Q(this)}get blank(){return $(this,cX),_Q(this)===0}with(t){$(this,cX);let{years:n=Q(this,TJ),months:r=Q(this,EJ),weeks:i=Q(this,DJ),days:a=Q(this,OJ),hours:o=Q(this,kJ),minutes:s=Q(this,AJ),seconds:c=Q(this,jJ),milliseconds:l=Q(this,MJ),microseconds:u=Q(this,NJ),nanoseconds:d=Q(this,PJ)}=OX(t);return new e(n,r,i,a,o,s,c,l,u,d)}negated(){return $(this,cX),TQ(this)}abs(){return $(this,cX),new e(Math.abs(Q(this,TJ)),Math.abs(Q(this,EJ)),Math.abs(Q(this,DJ)),Math.abs(Q(this,OJ)),Math.abs(Q(this,kJ)),Math.abs(Q(this,AJ)),Math.abs(Q(this,jJ)),Math.abs(Q(this,MJ)),Math.abs(Q(this,NJ)),Math.abs(Q(this,PJ)))}add(e){return $(this,cX),u$(`add`,this,e)}subtract(e){return $(this,cX),u$(`subtract`,this,e)}round(e){if($(this,cX),e===void 0)throw TypeError(`options parameter is required`);let t=UX(this),n=typeof e==`string`?P$(`smallestUnit`,e):N$(e),r=VX(n,`largestUnit`,`datetime`,void 0,[`auto`]),{plainRelativeTo:i,zonedRelativeTo:a}=HX(n),o=IX(n),s=NX(n,`halfExpand`),c=VX(n,`smallestUnit`,`datetime`,void 0),l=!0;c||=(l=!1,`nanosecond`);let u=WX(t,c),d=!0;if(r||=(d=!1,u),r===`auto`&&(r=u),!l&&!d)throw RangeError(`at least one of smallestUnit or largestUnit is required`);if(WX(r,c)!==r)throw RangeError(`largestUnit ${r} cannot be smaller than smallestUnit ${c}`);let f={hour:24,minute:60,second:60,millisecond:1e3,microsecond:1e3,nanosecond:1e3}[c];if(f!==void 0&&LX(o,f,!1),o>1&&KX(c)===`date`&&r!==c)throw RangeError(`For calendar units with roundingIncrement > 1, use largestUnit = smallestUnit`);if(a){let e=RQ(this),t=Q(a,wJ),n=Q(a,Z),i=Q(a,_J);return e=$Q(i,l$(i,t,n,e),t,n,r,o,c,s),KX(r)===`date`&&(r=`hour`),VQ(e,r)}if(i){let e=zQ(this),t=s$({deltaDays:0,hour:0,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0},e.time),n=Q(i,vJ),a=Q(i,Z),l=TZ(a,n,kX(e.date,t.deltaDays),`constrain`);return e=QQ(AX(n,{deltaDays:0,hour:0,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0}),AX(l,t),a,r,o,c,s),VQ(e,r)}if(GX(t))throw RangeError(`a starting point is required for ${t}s balancing`);if(GX(r))throw RangeError(`a starting point is required for ${r}s balancing`);let p=zQ(this);if(c===`day`){let{quotient:e,remainder:t}=p.time.divmod(DY),n=p.date.days+e+S$(t,`day`);n=_$(n,o,s),p=HQ({years:0,months:0,weeks:0,days:n},cY.ZERO)}else p=HQ({years:0,months:0,weeks:0,days:0},x$(p.time,o,c,s));return VQ(p,r)}total(e){if($(this,cX),e===void 0)throw TypeError(`options argument is required`);let t=typeof e==`string`?P$(`unit`,e):N$(e),{plainRelativeTo:n,zonedRelativeTo:r}=HX(t),i=VX(t,`unit`,`datetime`,BX);if(r){let e=RQ(this),t=Q(r,wJ),n=Q(r,Z),a=Q(r,_J);return function(e,t,n,r,i){return KX(i)===`time`?S$(cY.fromEpochNsDiff(t,e),i):ZQ(JQ(e,t,n,r,i),t,LZ(n,e),n,r,i)}(a,l$(a,t,n,e),t,n,i)}if(n){let e=zQ(this),t=s$({deltaDays:0,hour:0,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0},e.time),r=Q(n,vJ),a=Q(n,Z),o=TZ(a,r,kX(e.date,t.deltaDays),`constrain`);return function(e,t,n,r){if(T$(e,t)==0)return 0;NQ(e),NQ(t);let i=qQ(e,t,n,r);return r===`nanosecond`?X.default.toNumber(i.time.totalNs):ZQ(i,uQ(t),e,null,n,r)}(AX(r,{deltaDays:0,hour:0,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0}),AX(o,t),a,i)}let a=UX(this);if(GX(a))throw RangeError(`a starting point is required for ${a}s total`);if(GX(i))throw RangeError(`a starting point is required for ${i}s total`);return S$(zQ(this).time,i)}toString(e=void 0){$(this,cX);let t=N$(e),n=RX(t),r=NX(t,`trunc`),i=VX(t,`smallestUnit`,`time`,void 0);if(i===`hour`||i===`minute`)throw RangeError(`smallestUnit must be a time unit other than "hours" or "minutes"`);let{precision:a,unit:o,increment:s}=zX(i,n);if(o===`nanosecond`&&s===1)return qZ(this,a);let c=UX(this),l=RQ(this),u=x$(l.time,s,o,r);return l=HQ(l.date,u),qZ(VQ(l,WX(c,`second`)),a)}toJSON(){return $(this,cX),qZ(this,`auto`)}toLocaleString(e=void 0,t=void 0){if($(this,cX),typeof Intl.DurationFormat==`function`){let n=new Intl.DurationFormat(e,t);return B1.call(n,this)}return console.warn(`Temporal.Duration.prototype.toLocaleString() requires Intl.DurationFormat.`),qZ(this,`auto`)}valueOf(){R$(`Duration`)}static from(e){return tZ(e)}static compare(e,t,n=void 0){let r=tZ(e),i=tZ(t),{plainRelativeTo:a,zonedRelativeTo:o}=HX(N$(n));if(Q(r,TJ)===Q(i,TJ)&&Q(r,EJ)===Q(i,EJ)&&Q(r,DJ)===Q(i,DJ)&&Q(r,OJ)===Q(i,OJ)&&Q(r,kJ)===Q(i,kJ)&&Q(r,AJ)===Q(i,AJ)&&Q(r,jJ)===Q(i,jJ)&&Q(r,MJ)===Q(i,MJ)&&Q(r,NJ)===Q(i,NJ)&&Q(r,PJ)===Q(i,PJ))return 0;let s=UX(r),c=UX(i),l=RQ(r),u=RQ(i);if(o&&(KX(s)===`date`||KX(c)===`date`)){let e=Q(o,wJ),t=Q(o,Z),n=Q(o,_J),r=l$(n,e,t,l),i=l$(n,e,t,u);return M$(X.default.toNumber(X.default.subtract(r,i)))}let d=l.date.days,f=u.date.days;if(GX(s)||GX(c)){if(!a)throw RangeError(`A starting point is required for years, months, or weeks comparison`);d=wQ(l.date,a),f=wQ(u.date,a)}let p=l.time.add24HourDays(d),m=u.time.add24HourDays(f);return p.cmp(m)}};tY(q1,`Temporal.Duration`);var J1=class{constructor(e,t,n=`iso8601`,r=1972){let i=UY(e),a=UY(t),o=I$(n===void 0?`iso8601`:qY(n)),s=UY(r);kQ(s,i,a),pZ(this,{year:s,month:i,day:a},o)}get monthCode(){return Y1(this,`monthCode`)}get day(){return Y1(this,`day`)}get calendarId(){return $(this,pX),Q(this,Z)}with(e,t=void 0){if($(this,pX),!BY(e))throw TypeError(`invalid argument`);hX(e);let n=Q(this,Z),r=YX(n,Q(this,vJ),`month-day`);return r=wZ(n,r,XX(n,e,[`year`,`month`,`monthCode`,`day`],[],`partial`)),mZ(MZ(n,r,jX(N$(t))),n)}equals(e){$(this,pX);let t=rZ(e);return C$(Q(this,vJ),Q(t,vJ))===0&&kZ(Q(this,Z),Q(t,Z))}toString(e=void 0){return $(this,pX),ZZ(this,FX(N$(e)))}toJSON(){return $(this,pX),ZZ(this)}toLocaleString(e=void 0,t=void 0){return $(this,pX),new A1(e,t).format(this)}valueOf(){R$(`PlainMonthDay`)}toPlainDate(e){if($(this,pX),!BY(e))throw TypeError(`argument should be an object`);let t=Q(this,Z);return uZ(AZ(t,wZ(t,YX(t,Q(this,vJ),`month-day`),XX(t,e,[`year`],[],[])),`constrain`),t)}static from(e,t=void 0){return rZ(e,t)}};function Y1(e,t){$(e,pX);let n=Q(e,vJ);return JX(e).isoToDate(n,{[t]:!0})[t]}function X1(e){return LZ(e,A$())}tY(J1,`Temporal.PlainMonthDay`);var Z1={instant:()=>bZ(A$()),plainDateTimeISO:(e=j$())=>fZ(X1(NZ(e)),`iso8601`),plainDateISO:(e=j$())=>uZ(X1(NZ(e)).isoDate,`iso8601`),plainTimeISO:(e=j$())=>gZ(X1(NZ(e)).time),timeZoneId:()=>j$(),zonedDateTimeISO:(e=j$())=>{let t=NZ(e);return SZ(A$(),t,`iso8601`)},[Symbol.toStringTag]:`Temporal.Now`};Object.defineProperty(Z1,Symbol.toStringTag,{value:`Temporal.Now`,writable:!1,enumerable:!1,configurable:!0});var Q1=class e{constructor(e=0,t=0,n=0,r=0,i=0,a=0){let o=e===void 0?0:UY(e),s=t===void 0?0:UY(t),c=n===void 0?0:UY(n),l=r===void 0?0:UY(r),u=i===void 0?0:UY(i),d=a===void 0?0:UY(a);jQ(o,s,c,l,u,d),hZ(this,{hour:o,minute:s,second:c,millisecond:l,microsecond:u,nanosecond:d})}get hour(){return $(this,uX),Q(this,bJ).hour}get minute(){return $(this,uX),Q(this,bJ).minute}get second(){return $(this,uX),Q(this,bJ).second}get millisecond(){return $(this,uX),Q(this,bJ).millisecond}get microsecond(){return $(this,uX),Q(this,bJ).microsecond}get nanosecond(){return $(this,uX),Q(this,bJ).nanosecond}with(t,n=void 0){if($(this,uX),!BY(t))throw TypeError(`invalid argument`);hX(t);let r=ZX(t,`partial`),i=ZX(this),{hour:a,minute:o,second:s,millisecond:c,microsecond:l,nanosecond:u}=Object.assign(i,r),d=jX(N$(n));return{hour:a,minute:o,second:s,millisecond:c,microsecond:l,nanosecond:u}=DX(a,o,s,c,l,u,d),new e(a,o,s,c,l,u)}add(e){return $(this,uX),m$(`add`,this,e)}subtract(e){return $(this,uX),m$(`subtract`,this,e)}until(e,t=void 0){return $(this,uX),i$(`until`,this,e,t)}since(e,t=void 0){return $(this,uX),i$(`since`,this,e,t)}round(e){if($(this,uX),e===void 0)throw TypeError(`options parameter is required`);let t=typeof e==`string`?P$(`smallestUnit`,e):N$(e),n=IX(t),r=NX(t,`halfExpand`),i=VX(t,`smallestUnit`,`time`,BX);return LX(n,{hour:24,minute:60,second:60,millisecond:1e3,microsecond:1e3,nanosecond:1e3}[i],!1),gZ(b$(Q(this,bJ),n,i,r))}equals(e){$(this,uX);let t=iZ(e);return w$(Q(this,bJ),Q(t,bJ))===0}toString(e=void 0){$(this,uX);let t=N$(e),n=RX(t),r=NX(t,`trunc`),i=VX(t,`smallestUnit`,`time`,void 0);if(i===`hour`)throw RangeError(`smallestUnit must be a time unit other than "hour"`);let{precision:a,unit:o,increment:s}=zX(i,n);return YZ(b$(Q(this,bJ),s,o,r),a)}toJSON(){return $(this,uX),YZ(Q(this,bJ),`auto`)}toLocaleString(e=void 0,t=void 0){return $(this,uX),new A1(e,t).format(this)}valueOf(){R$(`PlainTime`)}static from(e,t=void 0){return iZ(e,t)}static compare(e,t){let n=iZ(e),r=iZ(t);return w$(Q(n,bJ),Q(r,bJ))}};tY(Q1,`Temporal.PlainTime`);var $1=class{constructor(e,t,n=`iso8601`,r=1){let i=UY(e),a=UY(t),o=I$(n===void 0?`iso8601`:qY(n)),s=UY(r);kQ(i,a,s),_Z(this,{year:i,month:a,day:s},o)}get year(){return e0(this,`year`)}get month(){return e0(this,`month`)}get monthCode(){return e0(this,`monthCode`)}get calendarId(){return $(this,fX),Q(this,Z)}get era(){return e0(this,`era`)}get eraYear(){return e0(this,`eraYear`)}get daysInMonth(){return e0(this,`daysInMonth`)}get daysInYear(){return e0(this,`daysInYear`)}get monthsInYear(){return e0(this,`monthsInYear`)}get inLeapYear(){return e0(this,`inLeapYear`)}with(e,t=void 0){if($(this,fX),!BY(e))throw TypeError(`invalid argument`);hX(e);let n=Q(this,Z),r=YX(n,Q(this,vJ),`year-month`);return r=wZ(n,r,XX(n,e,[`year`,`month`,`monthCode`],[],`partial`)),vZ(jZ(n,r,jX(N$(t))),n)}add(e,t=void 0){return $(this,fX),h$(`add`,this,e,t)}subtract(e,t=void 0){return $(this,fX),h$(`subtract`,this,e,t)}until(e,t=void 0){return $(this,fX),a$(`until`,this,e,t)}since(e,t=void 0){return $(this,fX),a$(`since`,this,e,t)}equals(e){$(this,fX);let t=oZ(e);return C$(Q(this,vJ),Q(t,vJ))===0&&kZ(Q(this,Z),Q(t,Z))}toString(e=void 0){return $(this,fX),QZ(this,FX(N$(e)))}toJSON(){return $(this,fX),QZ(this)}toLocaleString(e=void 0,t=void 0){return $(this,fX),new A1(e,t).format(this)}valueOf(){R$(`PlainYearMonth`)}toPlainDate(e){if($(this,fX),!BY(e))throw TypeError(`argument should be an object`);let t=Q(this,Z);return uZ(AZ(t,wZ(t,YX(t,Q(this,vJ),`year-month`),XX(t,e,[`day`],[],[])),`constrain`),t)}static from(e,t=void 0){return oZ(e,t)}static compare(e,t){let n=oZ(e),r=oZ(t);return C$(Q(n,vJ),Q(r,vJ))}};function e0(e,t){$(e,fX);let n=Q(e,vJ);return JX(e).isoToDate(n,{[t]:!0})[t]}tY($1,`Temporal.PlainYearMonth`);var Qle=A1.prototype.resolvedOptions,t0=class{constructor(e,t,n=`iso8601`){if(arguments.length<1)throw TypeError(`missing argument: epochNanoseconds is required`);let r=k$(e),i=qY(t),{tzName:a,offsetMinutes:o}=TX(i);if(o===void 0){let e=iQ(a);if(!e)throw RangeError(`unknown time zone ${a}`);i=e.identifier}else i=sQ(o);xZ(this,r,i,I$(n===void 0?`iso8601`:qY(n)))}get calendarId(){return $(this,mX),Q(this,Z)}get timeZoneId(){return $(this,mX),Q(this,wJ)}get year(){return r0(this,`year`)}get month(){return r0(this,`month`)}get monthCode(){return r0(this,`monthCode`)}get day(){return r0(this,`day`)}get hour(){return i0(this,`hour`)}get minute(){return i0(this,`minute`)}get second(){return i0(this,`second`)}get millisecond(){return i0(this,`millisecond`)}get microsecond(){return i0(this,`microsecond`)}get nanosecond(){return i0(this,`nanosecond`)}get era(){return r0(this,`era`)}get eraYear(){return r0(this,`eraYear`)}get epochMilliseconds(){return $(this,mX),D$(Q(this,_J),`floor`)}get epochNanoseconds(){return $(this,mX),E$(Q(this,_J))}get dayOfWeek(){return r0(this,`dayOfWeek`)}get dayOfYear(){return r0(this,`dayOfYear`)}get weekOfYear(){return r0(this,`weekOfYear`)?.week}get yearOfWeek(){return r0(this,`weekOfYear`)?.year}get hoursInDay(){$(this,mX);let e=Q(this,wJ),t=n0(this).isoDate,n=xQ(t.year,t.month,t.day+1),r=VZ(e,t),i=VZ(e,n);return S$(cY.fromEpochNsDiff(i,r),`hour`)}get daysInWeek(){return r0(this,`daysInWeek`)}get daysInMonth(){return r0(this,`daysInMonth`)}get daysInYear(){return r0(this,`daysInYear`)}get monthsInYear(){return r0(this,`monthsInYear`)}get inLeapYear(){return r0(this,`inLeapYear`)}get offset(){return $(this,mX),IZ(FZ(Q(this,wJ),Q(this,_J)))}get offsetNanoseconds(){return $(this,mX),FZ(Q(this,wJ),Q(this,_J))}with(e,t=void 0){if($(this,mX),!BY(e))throw TypeError(`invalid zoned-date-time-like`);hX(e);let n=Q(this,Z),r=Q(this,wJ),i=FZ(r,Q(this,_J)),a=n0(this),o={...YX(n,a.isoDate),...a.time,offset:IZ(i)};o=wZ(n,o,XX(n,e,[`year`,`month`,`monthCode`,`day`],[`hour`,`minute`,`second`,`millisecond`,`microsecond`,`nanosecond`,`offset`],`partial`));let s=N$(t),c=MX(s),l=PX(s,`prefer`),u=$X(n,o,jX(s)),d=tQ(o.offset);return SZ(sZ(u.isoDate,u.time,`option`,d,r,c,l,!1),r,n)}withPlainTime(e=void 0){$(this,mX);let t=Q(this,wJ),n=Q(this,Z),r=n0(this).isoDate,i;return i=e===void 0?VZ(t,r):RZ(t,AX(r,Q(iZ(e),bJ)),`compatible`),SZ(i,t,n)}withTimeZone(e){$(this,mX);let t=NZ(e);return SZ(Q(this,_J),t,Q(this,Z))}withCalendar(e){$(this,mX);let t=DZ(e);return SZ(Q(this,_J),Q(this,wJ),t)}add(e,t=void 0){return $(this,mX),g$(`add`,this,e,t)}subtract(e,t=void 0){return $(this,mX),g$(`subtract`,this,e,t)}until(e,t=void 0){return $(this,mX),o$(`until`,this,e,t)}since(e,t=void 0){return $(this,mX),o$(`since`,this,e,t)}round(e){if($(this,mX),e===void 0)throw TypeError(`options parameter is required`);let t=typeof e==`string`?P$(`smallestUnit`,e):N$(e),n=IX(t),r=NX(t,`halfExpand`),i=VX(t,`smallestUnit`,`time`,BX,[`day`]),a={day:1,hour:24,minute:60,second:60,millisecond:1e3,microsecond:1e3,nanosecond:1e3}[i];if(LX(n,a,a===1),i===`nanosecond`&&n===1)return SZ(Q(this,_J),Q(this,wJ),Q(this,Z));let o=Q(this,wJ),s=Q(this,_J),c=n0(this),l;if(i===`day`){let e=c.isoDate,t=xQ(e.year,e.month,e.day+1),n=VZ(o,e),i=VZ(o,t),a=X.default.subtract(i,n);l=cY.fromEpochNsDiff(s,n).round(a,r).addToEpochNs(n)}else{let e=y$(c,n,i,r),t=FZ(o,s);l=sZ(e.isoDate,e.time,`option`,t,o,`compatible`,`prefer`,!1)}return SZ(l,o,Q(this,Z))}equals(e){$(this,mX);let t=cZ(e),n=Q(this,_J),r=Q(t,_J);return!!X.default.equal(X.default.BigInt(n),X.default.BigInt(r))&&!!PZ(Q(this,wJ),Q(t,wJ))&&kZ(Q(this,Z),Q(t,Z))}toString(e=void 0){$(this,mX);let t=N$(e),n=FX(t),r=RX(t),i=function(e){return F$(e,`offset`,[`auto`,`never`],`auto`)}(t),a=NX(t,`trunc`),o=VX(t,`smallestUnit`,`time`,void 0);if(o===`hour`)throw RangeError(`smallestUnit must be a time unit other than "hour"`);let s=function(e){return F$(e,`timeZoneName`,[`auto`,`never`,`critical`],`auto`)}(t),{precision:c,unit:l,increment:u}=zX(o,r);return $Z(this,c,n,s,i,{unit:l,increment:u,roundingMode:a})}toLocaleString(e=void 0,t=void 0){$(this,mX);let n=N$(t),r=Object.create(null);if(function(e,t,n,r){if(t==null)return;let i=Reflect.ownKeys(t);for(let r=0;r<i.length;r++){let a=i[r];!n.some((e=>Object.is(e,a)))&&Object.prototype.propertyIsEnumerable.call(t,a)&&(e[a]=t[a])}}(r,n,[`timeZone`]),n.timeZone!==void 0)throw TypeError(`ZonedDateTime toLocaleString does not accept a timeZone option`);if(r.year===void 0&&r.month===void 0&&r.day===void 0&&r.era===void 0&&r.weekday===void 0&&r.dateStyle===void 0&&r.hour===void 0&&r.minute===void 0&&r.second===void 0&&r.fractionalSecondDigits===void 0&&r.timeStyle===void 0&&r.dayPeriod===void 0&&r.timeZoneName===void 0&&(r.timeZoneName=`short`),r.timeZone=Q(this,wJ),eQ(r.timeZone))throw RangeError(`toLocaleString does not currently support offset time zones`);let i=new A1(e,r),a=Qle.call(i).calendar,o=Q(this,Z);if(o!==`iso8601`&&a!==`iso8601`&&!kZ(a,o))throw RangeError(`cannot format ZonedDateTime with calendar ${o} in locale with calendar ${a}`);return i.format(bZ(Q(this,_J)))}toJSON(){return $(this,mX),$Z(this,`auto`)}valueOf(){R$(`ZonedDateTime`)}startOfDay(){$(this,mX);let e=Q(this,wJ);return SZ(VZ(e,n0(this).isoDate),e,Q(this,Z))}getTimeZoneTransition(e){$(this,mX);let t=Q(this,wJ);if(e===void 0)throw TypeError(`options parameter is required`);let n=F$(typeof e==`string`?P$(`direction`,e):N$(e),`direction`,[`next`,`previous`],BX);if(n===void 0)throw TypeError(`direction option is required`);if(eQ(t)||t===`UTC`)return null;let r=Q(this,_J),i=n===`next`?fQ(t,r):pQ(t,r);return i===null?null:SZ(i,t,Q(this,Z))}toInstant(){return $(this,mX),bZ(Q(this,_J))}toPlainDate(){return $(this,mX),uZ(n0(this).isoDate,Q(this,Z))}toPlainTime(){return $(this,mX),gZ(n0(this).time)}toPlainDateTime(){return $(this,mX),fZ(n0(this),Q(this,Z))}static from(e,t=void 0){return cZ(e,t)}static compare(e,t){let n=cZ(e),r=cZ(t),i=Q(n,_J),a=Q(r,_J);return X.default.lessThan(X.default.BigInt(i),X.default.BigInt(a))?-1:+!!X.default.greaterThan(X.default.BigInt(i),X.default.BigInt(a))}};function n0(e){return LZ(Q(e,wJ),Q(e,_J))}function r0(e,t){$(e,mX);let n=n0(e).isoDate;return JX(e).isoToDate(n,{[t]:!0})[t]}function i0(e,t){return $(e,mX),n0(e).time[t]}tY(t0,`Temporal.ZonedDateTime`);var $le=Object.freeze({__proto__:null,Duration:q1,Instant:V1,Now:Z1,PlainDate:H1,PlainDateTime:W1,PlainMonthDay:J1,PlainTime:Q1,PlainYearMonth:$1,ZonedDateTime:t0});(class{toTemporalInstant(){return bZ(O$(Date.prototype.valueOf.call(this)))}}).prototype.toTemporalInstant;var eue=[V1,H1,W1,q1,J1,Q1,$1,t0];for(let e of eue){let t=Object.getOwnPropertyDescriptor(e,`prototype`);(t.configurable||t.enumerable||t.writable)&&(t.configurable=!1,t.enumerable=!1,t.writable=!1,Object.defineProperty(e,"prototype",t))}function tue(e,t){let n=new Intl.DateTimeFormat(`en-CA`,{timeZone:t,year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,hourCycle:`h23`}).formatToParts(e),r=e=>{let t=n.find(t=>t.type===e);if(!t)throw Error(`This timezone isn't recognised. Enter a timezone name like Europe/Tirane.`);return t.value};return`${r(`year`)}-${r(`month`)}-${r(`day`)}T${r(`hour`)}:${r(`minute`)}`}function nue(e,t){return tue(new Date(e),t)}function rue(e,t){if(!/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}$/.test(e))throw Error(`Pick a date and time for the one-off run.`);let n=$le.PlainDateTime.from(e,{overflow:`reject`}),r=n.toZonedDateTime(t,{disambiguation:`compatible`});if(!n.equals(r.toPlainDateTime()))throw Error(`That time is skipped in this timezone (a clock change). Choose another time.`);return r.toInstant().toString({smallestUnit:`millisecond`})}function a0(e,t){return new Intl.DateTimeFormat(void 0,{timeZone:t,dateStyle:`medium`,timeStyle:`short`}).format(new Date(e))}var o0={"claude-code":{name:`Claude Code`,command:`claude auth login`},codex:{name:`Codex`,command:`codex login`},gemini:{name:`Gemini`,command:`gemini`}},iue=/not signed in|sign-in has expired|not logged in|run\s+"?(?:codex login|claude auth login)|authentication required/i,aue=/ENOSPC|no space left on device|disk (?:is )?full|not enough (?:free )?(?:disk )?space/i,oue=/refused to make|content (?:rules|policy|filter)|safety (?:system|filter)|flagged|moderation/i,sue=/\bunknown model\b|\bmodel\b[^\n]{0,80}?\b(?:not found|does not exist|retired|deprecated|decommissioned|no longer (?:available|supported)|is not available)/i,cue=/did not accept the API key|API key is saved|invalid api key|key may be wrong/i,lue=[`images`,`thumbnail`];function s0(e){let t=e.reason??``,n=uue(e.provider,t);if(n!==void 0&&(iue.test(t)||e.kind===`auth`))return{kind:`sign-in`,label:`Sign in to ${o0[n].name}`,cli:n,command:o0[n].command};if(aue.test(t))return{kind:`free-space`,label:`Free space`};if(e.kind===`refusal`||oue.test(t))return lue.includes(e.stage)?{kind:`refused`,label:`Soften and retry`,soften:!0}:{kind:`refused`,label:`Edit the prompt`,soften:!1};if(sue.test(t))return{kind:`switch-model`,label:`Switch model`};if(e.kind===`auth`||e.kind===`missing_key`||cue.test(t)){let t=due(e.provider);return{kind:`provider-settings`,label:t===void 0?`Open Settings → Providers`:`Open Settings → Providers → ${t}`,provider:e.provider??``}}}function uue(e,t){if(e===`claude-code`||e===`gemini`)return e;if(e===`codex`||e===`codex-image`||/Codex CLI/.test(t))return`codex`;if(/Claude Code CLI/.test(t))return`claude-code`;if(/Gemini CLI/.test(t))return`gemini`}function due(e){return MF.find(t=>t.id===e)?.displayName}function fue(e,t){switch(t){case`audio`:return e.audio?.provider;case`images`:case`thumbnail`:return e.images?.provider;case`research`:case`article`:return e.llm?.provider;default:return}}var c0={catalogue:[`catalogue`],retired:[`catalogue`,`retired`],firstRun:[`first-run`]},l0={method:`POST`};async function pue(e,t,n){return P(await e.fetch(`${e.origin}/api/providers/${t}/key/test`,n===void 0?l0:{...l0,headers:{"content-type":`application/json`},body:JSON.stringify({key:n})}))}async function u0(e,t){let n=t===void 0?``:`?provider=${encodeURIComponent(t)}`;return P(await e.fetch(`${e.origin}/api/providers/health${n}`,l0))}async function mue(e){return P(await e.fetch(`${e.origin}/api/providers/catalogue`))}async function hue(e){return P(await e.fetch(`${e.origin}/api/providers/catalogue/check`,l0))}async function gue(e){return P(await e.fetch(`${e.origin}/api/providers/catalogue/refresh`,l0))}async function d0(e){return(await P(await e.fetch(`${e.origin}/api/providers/catalogue/retired`))).usages}async function f0(e,t){await P(await e.fetch(`${e.origin}/api/providers/catalogue/retired/switch`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({kind:t.kind,id:t.id,slot:t.slot,from:{provider:t.provider,model:t.model},to:t.replacement?.id??``})}))}async function _ue(e){return P(await e.fetch(`${e.origin}/api/providers/catalogue/retired/switch-all`,l0))}async function vue(e){return P(await e.fetch(`${e.origin}/api/providers/first-run`))}async function yue(e){let t=await e.fetch(`${e.origin}/api/providers/first-run/dismiss`,l0);t.ok||await P(t)}function bue(e,t){let n=e.providers.find(e=>e.id===t.cli)?.checks.find(e=>e.label===`Signed in`);return n?.state===`ok`?`signed-in`:n?.state===`problem`?`signed-out`:`unknown`}function xue(e){return e.label.replace(/^Sign in to /,``)}async function p0(e){if(!navigator.clipboard)return!1;try{return await navigator.clipboard.writeText(e),!0}catch{return!1}}function m0({fix:e,retry:t,variant:n=`primary`,size:r=`default`}){let{api:i}=R(),a=Dy(),o=xue(e),s=N({mutationFn:async()=>bue(await u0(i,e.cli),e),onSuccess:n=>{if(n===`signed-out`){a(`${o} is still signed out. Run ${e.command} in a terminal on the computer running Slopify, sign in, then press Check again.`,`error`);return}if(t===void 0){a(n===`signed-in`?`${o} is signed in.`:`Slopify couldn't tell whether ${o} is signed in. If ${e.command} finished without an error, try the step again.`,n===`signed-in`?`success`:`info`);return}a(`${o} is signed in. Trying again.`,`success`),t.run()},onError:e=>a(`Slopify couldn't check ${o}'s sign-in: ${e.message} Press Check again in a moment, or use Check all in Settings → Providers.`,`error`)}),c=async()=>{let t=await p0(e.command);a(t?`Copied ${e.command}. Paste it in a terminal on the computer running Slopify and sign in, then press Check again.`:`Couldn't copy: the browser blocked the clipboard. Type ${e.command} in a terminal on the computer running Slopify, sign in, then press Check again.`,t?`success`:`error`)};return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(L,{variant:n,size:r,onClick:()=>void c(),children:`Copy sign-in command`}),(0,h.jsx)(L,{variant:`secondary`,size:r,disabled:s.isPending||t?.busy===!0,disabledReason:`Checking the sign-in…`,onClick:()=>s.mutate(),children:s.isPending?`Checking…`:`Check again`})]})}function h0({fix:e,retry:t,edit:n,variant:r=`primary`,size:i=`default`}){switch(e.kind){case`sign-in`:return(0,h.jsx)(m0,{fix:e,retry:t,variant:r,size:i});case`provider-settings`:return(0,h.jsx)(lS,{to:`/settings`,search:{section:`providers`},variant:r,size:i,children:e.label});case`free-space`:return(0,h.jsx)(lS,{to:`/settings`,search:{section:`storage`},variant:r,size:i,children:e.label});case`refused`:case`switch-model`:return n??null}}function Sue(e){let t=e.topics.error;if(t!==null)return s0({stage:`article`,reason:t,provider:e.topicGeneration.llm?.provider})}function g0({schedule:e,title:t,retry:n,className:r}){if(e.topics.error===null)return null;let i=Sue(e);return(0,h.jsx)(fI,{tone:`danger`,title:t,...r===void 0?{}:{className:r},...i===void 0?{}:{actions:(0,h.jsx)(h0,{fix:i,retry:n,variant:`secondary`,size:`small`})},children:e.topics.error})}function _0(e){let t=Object.entries(e);return t.length===0?void 0:t.map(([e,t])=>`${e}: ${t}`).join(` · `)}function Cue({schedule:e}){let{api:t}=R(),n=_(),[r,i]=(0,m.useState)(null),[a,o]=(0,m.useState)(null),s=e.deletedAt===null&&(e.status===`active`||e.status===`paused`),c=M({queryKey:[...IH(e.id),e.topics.held,e.topics.generatedAt],enabled:s&&e.topicGeneration.mode===`hold`,queryFn:async()=>{let n=await LH(t,e.id);if(!n.ok)throw Error(n.message);return n.value}}),l=M({queryKey:[`project-template`,e.templateId],enabled:s&&e.topicGeneration.mode===`hold`,queryFn:async()=>{let n=await Wq(t,e.templateId);if(!n.ok)throw Error(n.message);return n.value}}).data?.document.form,u=(l===void 0?[]:vq(l)).filter(t=>t!==e.topicKeyword),d=t=>e.values[t]??l?.values[t]??``,f=N({mutationFn:e=>e(),onSuccess:e=>{i(e.ok?null:e.message),e.ok&&o(null)},onError:e=>i(e.message),onSettled:async()=>{await Promise.all([n.invalidateQueries({queryKey:OH}),n.invalidateQueries({queryKey:IH(e.id)}),n.invalidateQueries({queryKey:qH})])}});if(!s||e.topicGeneration.mode===`off`)return null;let{topics:p}=e,g=f.isPending,v=c.data??[];return(0,h.jsxs)(`section`,{"aria-label":`Topic generation`,children:[(0,h.jsx)(Nq,{className:`my-6`}),(0,h.jsxs)(V,{as:`h3`,title:`Topic generation`,meta:`${p.generatingSince===null?p.generatedAt===null?`No topics generated yet.`:`Topics last generated ${a0(p.generatedAt,e.timezone)}.`:`Generating topics now…`} Keeps at least ${String(e.topicGeneration.keepAtLeast)} ${e.topicGeneration.mode===`hold`?`queued or waiting`:`queued`}.`,children:[(0,h.jsx)(B,{id:`planning.schedule.generate-now`}),(0,h.jsx)(L,{disabled:g||p.generatingSince!==null,disabledReason:`Topics are being generated now`,onClick:()=>f.mutate(()=>zH(t,e.id)),children:`Generate topics now`})]}),(0,h.jsx)(g0,{schedule:e,title:`The last topic generation failed.`,className:`mt-3`,retry:{run:()=>f.mutate(()=>zH(t,e.id)),busy:g||p.generatingSince!==null}}),r===null?null:(0,h.jsx)(fI,{tone:`danger`,title:`That didn't work.`,className:`mt-3`,children:r}),e.topicGeneration.mode===`hold`?(0,h.jsxs)(`div`,{className:`mt-4`,...Tb,children:[(0,h.jsx)(V,{as:`h3`,title:`Topics waiting · ${String(v.length)}`,info:`planning.schedule.held`,children:(0,h.jsx)(L,{variant:`primary`,disabled:g||v.length===0,disabledReason:`Nothing is waiting`,onClick:()=>f.mutate(()=>VH(t,e.id)),children:`Approve all`})}),c.error?(0,h.jsx)(`p`,{className:`m-0 mt-2 text-small text-danger`,children:`The waiting topics couldn't be loaded: ${c.error.message} Reload the page to try again.`}):v.length===0?(0,h.jsx)(`p`,{className:`m-0 mt-2 text-small text-ink-3`,children:`Nothing is waiting. New topics appear here for you to approve.`}):(0,h.jsx)(hU,{label:`Topics waiting`,className:`mt-2 [&_.sl-row__actions]:flex-wrap`,children:v.map(n=>(0,h.jsx)(gU,{title:a?.id===n.id?(0,h.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2`,children:[(0,h.jsx)(OV,{"aria-label":`Edit ${n.title}`,className:`w-full`,maxLength:200,value:a.title,onChange:e=>o({...a,title:e.target.value})}),u.length===0?null:(0,h.jsx)(`div`,{className:`grid grid-cols-1 gap-2 min-[600px]:grid-cols-2`,children:u.map(e=>(0,h.jsx)(Y,{label:e,tip:`planning.schedule.held-keywords`,children:(0,h.jsx)(OV,{maxLength:2e3,placeholder:d(e)||`Not set`,value:a.values[e]??``,onChange:t=>o({...a,values:{...a.values,[e]:t.target.value}})})},e))})]}):n.title,meta:a?.id===n.id?void 0:_0(n.values),actions:a?.id===n.id?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(L,{size:`small`,disabled:g||a.title.trim()===``,onClick:()=>f.mutate(()=>UH(t,e.id,n.id,a.title.trim(),Object.fromEntries(Object.entries(a.values).filter(([,e])=>e.trim()!==``)))),children:`Save`}),(0,h.jsx)(L,{variant:`quiet`,size:`small`,onClick:()=>o(null),children:`Cancel`})]}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(L,{size:`small`,disabled:g,onClick:()=>f.mutate(()=>BH(t,e.id,n.id)),children:`Approve`}),(0,h.jsx)(L,{variant:`quiet`,size:`small`,disabled:g,onClick:()=>o({id:n.id,title:n.title,values:n.values}),children:`Edit`}),(0,h.jsx)(L,{variant:`quiet`,size:`small`,disabled:g,onClick:()=>f.mutate(()=>HH(t,e.id,n.id)),children:`Reject`})]})},n.id))})]}):null]})}function wue({schedules:e}){let t=e.filter(e=>e.deletedAt===null&&e.topicGeneration.mode!==`off`&&(e.status===`active`||e.status===`paused`));return(0,h.jsx)(`div`,{className:`flex flex-col gap-6`,children:t.length===0?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(V,{title:`Suggested topics`}),(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:`No schedule suggests its own topics yet. Turn on topic generation in a schedule and its suggestions wait here for you.`}),(0,h.jsx)(`div`,{children:(0,h.jsx)(uS,{to:`/calendar`,search:{tab:`schedules`},children:`Open schedules`})})]}):t.map((e,t)=>(0,h.jsx)(Tue,{schedule:e,first:t===0},e.id))})}function Tue({schedule:e,first:t}){let{api:n}=R(),r=_(),i=Dy(),a=M({queryKey:[...IH(e.id),e.topics.held,e.version],queryFn:async()=>{let t=await LH(n,e.id);if(!t.ok)throw Error(t.message);return t.value},enabled:e.topics.held>0}),o=N({mutationFn:e=>e(),onSuccess:e=>{e.ok||i(e.message,`error`)},onError:e=>i(`The topics weren't changed: ${e.message} Try again in a moment.`,`error`),onSettled:async()=>{await Promise.all([r.invalidateQueries({queryKey:OH}),r.invalidateQueries({queryKey:qH}),r.invalidateQueries({queryKey:IH(e.id)})])}}),s=e.topics.held>0?a.data??[]:[],c=()=>o.mutate(()=>VH(n,e.id));_x({id:`calendar.approve-all.${e.id}`,title:`Queue all suggested topics`,group:`Calendar`,context:e.name,keywords:[`approve`,`suggestions`,`topics`],run:c});let l=e.topics.generatingSince!==null,u=e.topicGeneration.mode===`hold`;return(0,h.jsxs)(`section`,{"aria-label":`Suggested topics for ${e.name}`,className:`flex flex-col gap-3`,children:[(0,h.jsx)(V,{title:t?`Suggested topics`:e.name,kicker:t?e.name:void 0,meta:`From the series brief · not made or queued before`,info:`planning.schedule.held`,children:s.length>0?(0,h.jsx)(L,{size:`small`,variant:`secondary`,disabled:o.isPending,onClick:c,children:`Queue all ${String(s.length)}`}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(B,{id:`planning.schedule.generate-now`,label:`Suggest topics now`}),(0,h.jsx)(L,{size:`small`,variant:`quiet`,disabled:o.isPending||l,disabledReason:l?`Slopify is suggesting topics now.`:`Working…`,onClick:()=>o.mutate(()=>zH(n,e.id)),children:l?`Suggesting…`:`Suggest topics now`})]})}),(0,h.jsx)(g0,{schedule:e,title:`The last suggestion failed.`,retry:{run:()=>o.mutate(()=>zH(n,e.id)),busy:o.isPending||l}}),a.error===null?null:(0,h.jsx)(`p`,{className:`m-0 text-small text-danger`,children:`The suggestions didn't load: ${a.error.message} Reload the page to try again.`}),s.length===0?(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:l?`Slopify is asking for new topics. They appear here when it finishes.`:`No suggestions are waiting.`}):(0,h.jsx)(hU,{label:`Suggestions for ${e.name}`,children:s.map(t=>(0,h.jsx)(gU,{title:t.title,meta:_0(t.values),actions:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(L,{size:`small`,variant:`quiet`,disabled:o.isPending,onClick:()=>o.mutate(()=>BH(n,e.id,t.id)),"aria-label":`Queue ${t.title}`,children:`Queue`}),(0,h.jsx)(Cy,{size:`small`,label:`Reject ${t.title}`,disabled:o.isPending,onClick:()=>o.mutate(()=>HH(n,e.id,t.id)),children:(0,h.jsx)(Vc,{"aria-hidden":`true`,strokeWidth:1.75})})]})},t.id))}),(0,h.jsx)(fI,{title:`Keeps at least ${String(e.topicGeneration.keepAtLeast)} ${e.topicGeneration.keepAtLeast===1?`topic`:`topics`} queued.`,children:u?`New suggestions wait here for you. Change this under Schedules → Edit.`:`New suggestions join the queue straight away. Change this under Schedules → Edit.`})]})}var Eue={info:`text-ink-2`,error:`text-danger`,warning:`text-waiting`,success:`text-accent-ink`};function v0({children:e,tone:t=`info`,className:n,id:r}){let i=typeof e==`string`?e:void 0;return(0,h.jsx)(`div`,{id:r,"data-slot":`status-slot`,role:t===`error`?`alert`:`status`,title:i,className:I(`flex min-h-8 min-w-0 flex-1 items-center gap-2 overflow-hidden text-small`,Eue[t],n),children:e==null||e===!1?null:i===void 0?e:(0,h.jsx)(`span`,{className:`min-w-0 truncate`,children:i})})}function y0({status:e,children:t,className:n}){return(0,h.jsxs)(`div`,{"data-slot":`action-bar`,className:I(`sticky bottom-0 z-20 -mx-4 mt-6 flex min-h-14 flex-wrap items-center gap-x-3 gap-y-2 border-t border-line bg-surface px-4 py-2 pb-[max(8px,env(safe-area-inset-bottom))] max-md:bottom-[calc(48px+max(12px,env(safe-area-inset-bottom)))] md:-mx-10 md:px-10`,n),children:[(0,h.jsx)(`div`,{className:`flex w-full min-w-0 sm:w-auto sm:flex-1`,children:e??(0,h.jsx)(v0,{})}),(0,h.jsx)(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:t})]})}function b0({split:e=`main-side`,className:t,children:n}){return(0,h.jsx)(`div`,{"data-slot":`board`,className:I(`sl-board`,`sl-board--${e}`,t),children:n})}function x0({as:e=`div`,label:t,className:n,children:r}){let i=I(`sl-board__column`,n);return e===`aside`?(0,h.jsx)(`aside`,{"aria-label":t,className:i,children:r}):t===void 0?(0,h.jsx)(`div`,{className:i,children:r}):(0,h.jsx)(`section`,{"aria-label":t,className:i,children:r})}var S0=`sl-tab inline-flex items-center gap-[6px]`;function C0({items:e,value:t,onChange:n,label:r,idPrefix:i,trailing:a,className:o}){let s=(0,m.useRef)(null);return(0,h.jsxs)(`div`,{className:I(`flex min-w-0 items-end gap-3 border-b border-line`,o),"data-slot":`tabs`,children:[(0,h.jsx)(`div`,{ref:s,role:`tablist`,"aria-label":r,onKeyDown:r=>{let a=e.filter(e=>!e.disabled),o=a.findIndex(e=>e.id===t),c=r.key===`ArrowRight`?a[(o+1)%a.length]:r.key===`ArrowLeft`?a[(o-1+a.length)%a.length]:r.key===`Home`?a[0]:r.key===`End`?a[a.length-1]:void 0;c&&(r.preventDefault(),n(c.id),s.current?.querySelector(`#${i}-tab-${c.id}`)?.focus())},className:`sl-tabs min-w-0 flex-1 border-b-0`,children:e.map(e=>(0,h.jsxs)(`button`,{id:`${i}-tab-${e.id}`,type:`button`,role:`tab`,"aria-selected":e.id===t,"aria-controls":`${i}-panel-${e.id}`,tabIndex:e.id===t?0:-1,disabled:e.disabled,onClick:()=>n(e.id),className:S0,children:[e.label,e.badge===void 0?null:(0,h.jsx)(`span`,{className:`sl-tab__count ml-0`,children:e.badge})]},e.id))}),a?(0,h.jsx)(`div`,{className:`flex shrink-0 items-center gap-2 pb-1`,children:a}):null]})}function Due({items:e,label:t,className:n}){return(0,h.jsx)(`nav`,{"aria-label":t,className:I(`sl-tabs min-w-0`,n),children:e.map(e=>(0,h.jsx)(pa,{to:e.to,...e.search?{search:e.search}:{},activeOptions:{exact:!1,includeSearch:!1},className:S0,activeProps:{"aria-current":`page`},children:e.label},e.to))})}function w0({idPrefix:e,id:t,active:n,children:r,className:i}){return(0,h.jsx)(`div`,{id:`${e}-panel-${t}`,role:`tabpanel`,"aria-labelledby":`${e}-tab-${t}`,hidden:!n,className:i,children:r})}function T0({title:e,children:t,actions:n,className:r}){return(0,h.jsxs)(`div`,{className:I(`sl-empty`,r),"data-slot":`empty-state`,children:[(0,h.jsx)(`h2`,{className:`sl-section-head__title`,children:e}),t===void 0?null:(0,h.jsx)(`p`,{children:t}),n===void 0?null:(0,h.jsx)(`div`,{className:`sl-btn-row`,children:n})]})}function E0(e){return e.channelId??`00000000-0000-4000-8000-000000000001`}function Oue({channelId:e}){let{api:t}=R(),n=_(),r=M(Uq(t)),i=M(Jb(t)),a=N({mutationFn:e=>ax(t,e.templateId,e.channelId),onSettled:()=>Promise.all([n.invalidateQueries({queryKey:Rq}),n.invalidateQueries({queryKey:Wb})])}),o=(r.data??[]).filter(t=>E0(t)===e);return(0,h.jsxs)(`div`,{...Tb,children:[(0,h.jsxs)(`p`,{className:`m-0 mb-4 max-w-[68ch] text-small text-ink-2`,children:[`Runs from these templates use this channel's brand kit and cast. Save new ones from Play in`,` `,(0,h.jsx)(pa,{to:`/templates`,className:`underline`,children:`Library → Templates`}),`. Move to sends a template and its schedules to another channel.`,` `,(0,h.jsx)(B,{id:`planning.channel.template-move`,className:`-my-1 align-middle`})]}),(0,h.jsx)(v0,{tone:a.error||r.error?`error`:`info`,className:`mb-2`,children:a.error?.message??r.error?.message}),r.data&&o.length===0?(0,h.jsx)(T0,{title:`No templates in this channel`,children:`Pick this channel on Play, then save the setup as a template, or move one here from another channel.`}):null,o.length>0?(0,h.jsx)(hU,{label:`Channel templates`,className:`[&_.sl-row__actions]:flex-wrap`,children:o.map(t=>(0,h.jsx)(gU,{title:t.name,meta:`Version ${String(t.version)}`,actions:(0,h.jsxs)(`span`,{className:`flex items-center gap-2 text-small text-ink-2`,children:[`Move to`,(0,h.jsx)(AV,{"aria-label":`Channel of ${t.name}`,value:e,disabled:a.isPending,onChange:e=>a.mutate({templateId:t.id,channelId:e.target.value}),options:(i.data??[]).map(e=>({value:e.id,label:e.name}))})]})},t.id))}):null]})}var kue={active:`Active`,paused:`Paused`,completed:`Completed`,canceled:`Canceled`},Aue={active:`running`,paused:`waiting`,completed:`done`,canceled:`off`};function jue({channelId:e}){let{api:t}=R(),n=M(Uq(t)),r=M(kH(t)),i=new Set((n.data??[]).filter(t=>E0(t)===e).map(e=>e.id)),a=(r.data??[]).filter(e=>e.deletedAt===null&&i.has(e.templateId));return(0,h.jsxs)(`div`,{children:[(0,h.jsxs)(`p`,{className:`m-0 mb-4 max-w-[68ch] text-small text-ink-2`,children:[`A schedule belongs to the channel of the template it runs. Create and change schedules in`,` `,(0,h.jsx)(pa,{to:`/calendar`,search:{tab:`schedules`},className:`underline`,children:`Calendar → Schedules`}),`.`]}),(0,h.jsx)(v0,{tone:r.error?`error`:`info`,className:`mb-2`,children:r.error?.message}),r.data&&a.length===0?(0,h.jsx)(T0,{title:`No schedules run this channel's templates`,children:`Make one in Calendar → Schedules from one of this channel's templates.`}):null,a.length>0?(0,h.jsx)(hU,{label:`Channel schedules`,children:a.map(e=>(0,h.jsx)(gU,{title:e.name,meta:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(mS,{tone:Aue[e.status],children:kue[e.status]}),` · ${e.nextRunAt===null?`No next run`:`Next run ${a0(e.nextRunAt,e.timezone)}`} · ${String(e.items.length)} queued`]})},e.id))}):null]})}var D0={llm:`Text model`,audio:`Voice model`,images:`Image model`,animate:`Animation model`};function O0({kind:e,id:t,name:n}){let{api:r}=R(),i=_(),a=M({queryKey:c0.retired,queryFn:()=>d0(r)}),o=N({mutationFn:e=>f0(r,e),onSuccess:()=>Promise.all([i.invalidateQueries({queryKey:c0.retired}),i.invalidateQueries({queryKey:Rq}),i.invalidateQueries({queryKey:OH})])}),s=(a.data??[]).filter(n=>n.kind===e&&n.id===t);return s.length===0?null:(0,h.jsxs)(`li`,{"aria-label":`Retired models in ${n}`,className:`flex flex-col gap-2 px-3 pb-3`,children:[s.map(t=>(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-small`,children:[(0,h.jsxs)(`span`,{className:`text-waiting`,children:[`${D0[t.slot]} ${t.model} is ${t.why===`retired`?`retired`:`no longer listed`}.`,t.blocked===null?``:` ${t.blocked}`,t.replacement===null&&t.blocked===null?` No replacement is suggested: choose another model in Settings → Models, or edit the ${e}.`:``]}),t.replacement===null?null:(0,h.jsx)(L,{size:`small`,disabled:t.blocked!==null||o.isPending,disabledReason:t.blocked??`Switching…`,onClick:()=>o.mutate(t),children:`Switch to ${t.replacement.name}`})]},t.key)),o.error?(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-small text-danger`,children:`The model wasn't switched: ${o.error.message}`}):null]})}function k0(e){return QA(e)?`script`:`article`}function Mue(e){let{form:t}=e,n=[],r=[];if(P0(n,t.title),_j(t)&&P0(n,M0(e.prompts,`narration`,t.narrationPrompt??``)),t.sources.article===`generate`&&P0(n,M0(e.prompts,k0(t),t.articlePrompt)),t.sources.audio===`generate`&&(P0(n,N0(e.entries,`intro`,t.intro)),P0(n,N0(e.entries,`outro`,t.outro))),bj(t)&&P0(n,M0(e.prompts,`description`,t.descriptionPrompt??``)),LN(t)&&(P0(n,M0(e.prompts,`shorts`,t.shorts?.prompt??``)),P0(r,M0(e.prompts,`image`,t.shorts?.imagePrompt??``))),t.sources.images===`generate`){for(let n of t.imagePrompts)P0(r,M0(e.prompts,`image`,n.name));t.reference?.source===`prompt`&&P0(r,M0(e.prompts,`image`,t.reference.prompt))}return(t.sources.thumbnail===`from_prompt`||t.sources.thumbnail===`prompt_by_llm`)&&P0(r,M0(e.prompts,`thumbnail`,t.thumbnailPrompt)),mq(n,r)}function Nue(e){let t=Mue(e),n={form:e.form,entries:e.entries,slots:t.map(e=>e.name),silenceGapSeconds:e.silenceGapSeconds},r=GN(n),i=lj({draft:r,staged:WN(e.form.provided),requiredSlots:n.slots}),a=FN(r.subtitles??e.form.subtitles)?i:{ok:!1,fields:[...i.ok?[]:i.fields,{field:`subtitles.fontSize`,message:`Choose a whole subtitle font size from 16 to 120.`}]};return{fields:t,draft:r,result:a,blocker:Pue(e.form,a)}}var A0=`sources,provided.research,articlePrompt,provided.article,audio,provided.audio,voices,narrationPrompt,imagePrompts,images,provided.images,reference,provided.reference,thumbnailPrompt,provided.thumbnail,subtitles,title,intro,outro,llm,values,silenceGapSeconds,edgeSilenceSeconds,imageSeconds,zoomPercent,motionStyle,youtubeDescription,descriptionPrompt,shorts.enabled,shorts.count,shorts.minSeconds,shorts.maxSeconds,shorts.prompt,shorts.imagePrompt,shorts.speed,shorts.musicVolume,shorts.music,shorts.fullVideoLink,videoEdit.transitionSeconds,videoEdit.chapterCards,videoEdit.animate,videoEdit.animateEvery,videoEdit.animateModel,ambientBed,sentencePauseSeconds,paragraphPauseSeconds,loudness.videoLufs,loudness.audioFilesLufs`.split(`,`);function Pue(e,t){let n=Fue(e);if(n!==void 0)return n;if(t.ok)return;let r=[...t.fields].sort((e,t)=>j0(e.field)-j0(t.field))[0];return r===void 0?void 0:{field:r.field,hint:Iue(e,r)}}function Fue(e){let{sources:t,provided:n}=e,r=[];if(t.audio===`provide`&&n.audio!==void 0&&r.push(n.audio),t.images===`provide`&&r.push(...n.images),t.thumbnail===`provide`&&n.thumbnail!==void 0&&r.push(n.thumbnail),t.images===`generate`&&e.reference?.source===`provide`&&n.reference!==void 0&&r.push(n.reference),LN(e)&&n.shortsMusic!==void 0&&r.push(n.shortsMusic),RN(e)&&n.ambientBed!==void 0&&r.push(n.ambientBed),r.some(e=>e.error!==void 0))return{field:`provided`,hint:`Remove the upload that failed to play`};if(r.some(e=>e.file===void 0))return{field:`provided`,hint:`Wait for the uploads to finish to play`}}function j0(e){let t=A0.length;for(let[n,r]of A0.entries())(e===r||e.startsWith(`${r}.`))&&n<t&&(t=n);return t}function Iue(e,t){if(t.field.startsWith(`values.`))return`Fill ${t.field.slice(7)} to play`;if(t.field.startsWith(`imagePrompts.`))return t.field.endsWith(`.number`)?`Set a Number between 1 and 20 to play`:`Pick an image prompt to play`;switch(t.field){case`title`:return e.title.trim()===``?`Name the video to play`:`Shorten the title to 200 characters to play`;case`imagePrompts`:return e.imagePrompts.length===0?`Tick an image prompt to play`:`Lower the Numbers to play: a run makes at most 60 images`;case`llm`:return`Pick an LLM provider and model to play`;case`articlePrompt`:return k0(e)===`script`?`Pick a script prompt to play`:`Pick an article prompt to play`;case`audio`:return`Pick a narration provider to play`;case`audio.voice`:return`Pick a voice to play`;case`images`:return`Pick an image provider and model to play`;case`thumbnailPrompt`:return`Pick a thumbnail prompt to play`;case`youtubeDescription`:return`Turn narration on, or the YouTube description off, to play`;case`shorts.enabled`:return`Turn narration on, or Shorts off, to play`;case`shorts.count`:return`Set how many shorts to make to play`;case`shorts.minSeconds`:case`shorts.maxSeconds`:return`Set the shorts' length to play`;case`shorts.speed`:return`Choose the shorts' speed to play`;case`shorts.musicVolume`:return`Set the shorts' music volume to play`;case`shorts.music`:return`Attach the shorts' background music again, or remove it, to play`;case`shorts.fullVideoLink`:return`Fix the full video link to play`;case`provided.research`:return`Paste the research notes to play`;case`provided.article`:return`Paste the article to play`;case`provided.audio`:return`Attach the narration audio to play`;case`provided.images`:return e.provided.images.length>60?`Remove images to play: a run holds at most 60`:`Attach at least one image to play`;case`provided.thumbnail`:return`Attach the thumbnail image to play`;case`reference.prompt`:return`Pick the establishing image's prompt to play`;case`provided.reference`:return`Attach the establishing image to play`;default:return t.message}}function M0(e,t,n){if(n!==``)return e.find(e=>e.kind===t&&e.name===n)?.body}function N0(e,t,n){if(n!==``)return e.find(e=>e.category===t&&e.name===n)?.body}function P0(e,t){t!==void 0&&e.push(t)}function F0(e){let t=new Map,n=(e,n)=>{if(e)for(let r of pq(e).names){let e=t.get(r)??[];e.includes(n)||e.push(n),t.set(r,e)}},{form:r,prompts:i,entries:a}=e;if(n(r.title,`Project title`),_j(r)&&n(M0(i,`narration`,r.narrationPrompt??``),`Narration Preparation`),r.sources.article===`generate`&&n(M0(i,k0(r),r.articlePrompt),`Article`),r.sources.images===`generate`){for(let e of r.imagePrompts)n(M0(i,`image`,e.name),`Image: ${e.name}`);r.reference?.source===`prompt`&&n(M0(i,`image`,r.reference.prompt),`Establishing image`)}if((r.sources.thumbnail===`from_prompt`||r.sources.thumbnail===`prompt_by_llm`)&&n(M0(i,`thumbnail`,r.thumbnailPrompt),`Thumbnail`),r.sources.audio===`generate`)for(let e of[`intro`,`outro`])n(N0(a,e,r[e]),e===`intro`?`Intro`:`Outro`);return bj(r)&&n(M0(i,`description`,r.descriptionPrompt??``),`YouTube description`),LN(r)&&(n(M0(i,`shorts`,r.shorts?.prompt??``),`Shorts`),n(M0(i,`image`,r.shorts?.imagePrompt??``),`Shorts images`)),t}function I0(e){let t=[e.feeds.length===0?`Not used by any picked prompt`:`Feeds ${e.feeds.join(` · `)}`,...e.topic?[`left empty in templates`]:[]].join(` · `);return e.note===void 0?t:`${t}. ${e.note}`}function L0({keywords:e,onChange:t,problem:n,fieldPrefix:r=`values`,empty:i,label:a=e=>e,inputLabel:o,tip:s=`play.keyword`,maxLength:c=200}){if(e.length===0)return i===void 0?null:(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:i});let l=I0;return t===void 0?(0,h.jsx)(hU,{label:`Keywords`,children:e.map(e=>(0,h.jsx)(gU,{title:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`code`,{className:`sl-code`,children:`{{${e.name}}}`}),` `,e.value===``?(0,h.jsx)(`span`,{className:`text-ink-3`,children:e.topic?`the topic`:`empty`}):e.value]}),meta:l(e)},e.name))}):(0,h.jsx)(`div`,{"data-tour":`play-keywords`,className:`grid min-w-0 grid-cols-1 gap-4 min-[700px]:grid-cols-2`,children:e.map(e=>(0,h.jsx)(Y,{label:a(e.name),tip:s,help:l(e),error:n?.(`${r}.${e.name}`),children:(0,h.jsx)(OV,{"data-play-field":`${r}.${e.name}`,value:e.value,maxLength:c,...o===void 0?{}:{"aria-label":o(e.name)},spellCheck:!1,"aria-invalid":n?.(`${r}.${e.name}`)!==void 0,onChange:n=>t(e.name,n.target.value)})},e.name))})}var R0={lines:`One per line`,table:`Table`,yaml:`YAML / JSON`};function z0(e){return{mode:`lines`,rows:e,lines:Dq(e),base:e,yaml:``,columns:B0(e,[])}}function B0(e,t){return[...new Set([...t,...e.flatMap(e=>Object.keys(e.values))])]}function V0(e){return e.keywords.filter(t=>t!==e.topicKeyword&&(e.everyRun[t]??``).trim()===``)}function H0(e,t){if(t.form===void 0)return{rows:e.rows,problems:[]};if(e.mode===`yaml`){let n=Oq(e.yaml,{keywords:t.keywords,topicKeyword:t.topicKeyword,required:V0(t)});return n.ok?{rows:n.rows,problems:[]}:{rows:[],problems:n.problems}}let n=e.rows.map(e=>({title:e.title.trim(),values:Object.fromEntries(Object.entries(e.values).filter(([,e])=>e!==``))}));return{rows:n,problems:wq(n,{keywords:t.keywords,topicKeyword:t.topicKeyword,...e.mode===`table`?{required:V0(t)}:{},kept:t.kept})}}function Lue(e,t,n){if(t===e.mode)return{queue:e,problems:[]};let r=e.rows;if(e.mode===`yaml`){let t=Oq(e.yaml,{keywords:n.keywords.length===0?Object.keys(n.everyRun):n.keywords,topicKeyword:n.topicKeyword});if(!t.ok)return{queue:e,problems:t.problems};r=t.rows}return{queue:{...e,mode:t,rows:r,lines:t===`lines`?Dq(r):e.lines,base:t===`lines`?r:e.base,yaml:t===`yaml`?kq(r,n.topicKeyword):e.yaml,columns:B0(r,e.columns)},problems:[]}}function Rue({queue:e,onQueue:t,context:n,onKeyword:r,onValue:i,loading:a,exportName:o}){let[s,c]=(0,m.useState)([]),[l,u]=(0,m.useState)(null),{keywords:d,topicKeyword:f,form:p,everyRun:g}=n,_=e=>n.origins?.get(e)??[],v=H0(e,n),y=e.mode===`yaml`?v.rows:e.rows,b=e=>p===void 0?void 0:bq(p,{topicKeyword:f,values:g},e),x=y[0],S=x===void 0?void 0:b(x),C=f!==null&&p?.title.includes(`{{${f}}}`)===!0,w=()=>kq(H0(e,n).rows,f),T=()=>{let e=w();if(!navigator.clipboard){u(`Couldn't copy the list. Switch to YAML / JSON, select the text and copy it.`);return}navigator.clipboard.writeText(e).then(()=>u(`Copied ${String(y.length)} topics as YAML.`),()=>u(`Couldn't copy the list. Switch to YAML / JSON, select the text and copy it.`))},E=()=>{let e=URL.createObjectURL(new Blob([w()],{type:`application/yaml`})),t=document.createElement(`a`);t.href=e,t.download=`${(o.trim()||`schedule`).replace(/[^\w.-]+/g,`-`)}-topics.yaml`,t.click(),URL.revokeObjectURL(e),u(`Downloaded ${String(y.length)} topics as YAML.`)},D=(n,r)=>t({...e,rows:e.rows.map((e,t)=>t===n?r:e)}),O=d.filter(t=>t!==f&&!e.columns.includes(t)),k=[...s,...v.problems];return(0,h.jsxs)(`fieldset`,{className:`m-0 flex min-w-0 flex-col gap-3 border-0 border-t border-line p-0 pt-5 min-[700px]:col-span-2`,children:[(0,h.jsxs)(`legend`,{className:`float-left mb-1 flex w-full items-center gap-1 text-title-3 font-semibold`,children:[`Topics (optional)`,(0,h.jsx)(B,{id:`planning.schedule.topics`})]}),(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,h.jsx)(Db,{label:`How to write the topics`,tip:`planning.schedule.topic-format`,value:e.mode,options:Object.keys(R0).map(e=>({value:e,label:R0[e]})),onChange:r=>{let i=Lue(e,r,n);c(i.problems),t(i.queue)}}),(0,h.jsxs)(L,{variant:`quiet`,size:`small`,disabled:y.length===0||v.problems.length>0,disabledReason:`Add topics, and fix the problems below, first`,onClick:T,children:[(0,h.jsx)(fc,{"aria-hidden":`true`,className:`size-4`,strokeWidth:1.75}),`Copy as YAML`]}),(0,h.jsxs)(L,{variant:`quiet`,size:`small`,disabled:y.length===0||v.problems.length>0,disabledReason:`Add topics, and fix the problems below, first`,onClick:E,children:[(0,h.jsx)(pc,{"aria-hidden":`true`,className:`size-4`,strokeWidth:1.75}),`Export as YAML`]}),l===null?null:(0,h.jsx)(`span`,{role:`status`,className:`text-small text-ink-2`,children:l})]}),e.mode===`lines`?(0,h.jsx)(Y,{id:`schedule-topics`,tip:`planning.schedule.topic-lines`,tipLabel:`Topics, one per line`,label:y.length===0?`One per line`:`${String(y.length)} ${y.length===1?`topic`:`topics`} · next: ${x?.title??``}`,children:(0,h.jsx)(kV,{rows:6,value:e.lines,onChange:n=>t({...e,lines:n.target.value,rows:Eq(n.target.value,e.base)}),placeholder:`Pyramids
270
270
  Sphinxes
271
271
  Obelisks`})}):e.mode===`yaml`?(0,h.jsx)(Y,{id:`schedule-topics-yaml`,label:`Topics as YAML or JSON`,tip:`planning.schedule.topic-yaml`,children:(0,h.jsx)(kV,{rows:10,className:`font-mono`,spellCheck:!1,value:e.yaml,onChange:n=>t({...e,yaml:n.target.value}),placeholder:`- ${f??`Topic`}: Cleopatra\n ${d.find(e=>e!==f)??`Min. Word Count`}: 12000\n- Hypatia`})}):(0,h.jsx)(zue,{queue:e,onQueue:t,keyword:f,addable:O,setRow:D,titleOf:b}),k.length===0?null:(0,h.jsx)(fI,{tone:`danger`,title:`These topics can't be saved yet.`,children:(0,h.jsxs)(`ul`,{className:`m-0 flex list-none flex-col gap-1 p-0`,children:[k.slice(0,8).map(e=>(0,h.jsx)(`li`,{children:e},e)),k.length>8?(0,h.jsx)(`li`,{children:`And ${String(k.length-8)} more.`}):null]})}),e.mode===`yaml`&&v.rows.length>0?(0,h.jsxs)(`section`,{"aria-label":`Project titles`,children:[(0,h.jsx)(`p`,{className:`m-0 mb-1 text-small text-ink-2`,children:`Project titles, in order:`}),(0,h.jsxs)(`ol`,{className:`m-0 flex flex-col gap-1 pl-5 text-small`,children:[v.rows.slice(0,20).map((e,t)=>(0,h.jsx)(`li`,{children:b(e)},t)),v.rows.length>20?(0,h.jsx)(`li`,{className:`list-none text-ink-3`,children:`And ${String(v.rows.length-20)} more.`}):null]})]}):null,a?(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-3`,children:`Reading the template's keywords…`}):d.length===0?(0,h.jsxs)(`p`,{className:`m-0 text-small text-ink-3`,children:[`This template has no keywords such as `,`{{Topic}}`,`, so each topic becomes the project's title.`]}):(0,h.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,h.jsx)(`div`,{className:`grid gap-4 min-[700px]:grid-cols-2`,children:(0,h.jsx)(Y,{label:`Each topic fills`,id:`schedule-topic-keyword`,tip:`planning.schedule.topic-keyword`,...f===null?{}:{help:I0({feeds:_(f)})},children:(0,h.jsx)(AV,{value:f??``,onChange:e=>r(e.target.value),children:d.map(e=>(0,h.jsx)(`option`,{value:e,children:`{{${e}}}`},e))})})}),(0,h.jsx)(L0,{keywords:d.filter(e=>e!==f).map(t=>({name:t,value:g[t]??``,feeds:_(t),...e.columns.includes(t)?{note:`Unless a topic sets its own.`}:{}})),onChange:i,fieldPrefix:`everyRun`,label:e=>`${e} (every run)`,inputLabel:e=>`${e} for every run`,tip:`planning.schedule.every-run`,maxLength:1e4})]}),e.mode===`lines`&&S!==void 0&&x!==void 0?(0,h.jsxs)(`p`,{className:`m-0 text-small text-ink-2`,children:[`Next project: `,(0,h.jsx)(`span`,{className:`font-semibold text-ink`,children:S}),f===null||C?null:(0,h.jsxs)(`span`,{className:`block text-ink-3`,children:[`The template's project title does not use `,`{{${f}}}`,`, so every project gets this title. Edit the template's title to include it.`]})]}):null]})}function zue({queue:e,onQueue:t,keyword:n,addable:r,setRow:i,titleOf:a}){let o=n===null?`Title`:`{{${n}}}`;return(0,h.jsxs)(`div`,{className:`flex flex-col gap-3`,...Tb,children:[(0,h.jsx)(`div`,{className:`overflow-x-auto`,children:(0,h.jsxs)(`table`,{className:`sl-table`,"aria-label":`Topics`,children:[(0,h.jsx)(`thead`,{children:(0,h.jsxs)(`tr`,{children:[(0,h.jsx)(`th`,{scope:`col`,children:`#`}),(0,h.jsx)(`th`,{scope:`col`,children:(0,h.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[o,(0,h.jsx)(B,{id:`planning.schedule.topic-table`,className:`-my-1`})]})}),e.columns.map(n=>(0,h.jsx)(`th`,{scope:`col`,children:(0,h.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[`{{${n}}}`,(0,h.jsx)(Cy,{label:`Use the every-run ${n} for all topics`,size:`small`,onClick:()=>t({...e,columns:e.columns.filter(e=>e!==n),rows:e.rows.map(e=>({title:e.title,values:Object.fromEntries(Object.entries(e.values).filter(([e])=>e!==n))}))}),children:(0,h.jsx)(Vc,{"aria-hidden":`true`,strokeWidth:1.75})})]})},n)),(0,h.jsx)(`th`,{scope:`col`,children:`Project title`}),(0,h.jsx)(`th`,{scope:`col`,children:(0,h.jsx)(`span`,{className:`sr-only`,children:`Remove`})})]})}),(0,h.jsx)(`tbody`,{children:e.rows.map((n,r)=>(0,h.jsxs)(`tr`,{children:[(0,h.jsx)(`td`,{className:`num`,children:r+1}),(0,h.jsx)(`td`,{children:(0,h.jsx)(OV,{"aria-label":`Topic ${String(r+1)} ${o}`,maxLength:200,value:n.title,onChange:e=>i(r,{...n,title:e.target.value})})}),e.columns.map(e=>(0,h.jsx)(`td`,{children:(0,h.jsx)(OV,{"aria-label":`Topic ${String(r+1)} ${e}`,maxLength:_q,placeholder:`Every-run value`,value:n.values[e]??``,onChange:t=>i(r,{...n,values:{...n.values,[e]:t.target.value}})})},e)),(0,h.jsx)(`td`,{className:`min-w-[180px] text-small text-ink-2`,children:a(n)??`—`}),(0,h.jsx)(`td`,{children:(0,h.jsx)(Cy,{label:`Remove topic ${String(r+1)}`,size:`small`,onClick:()=>t({...e,rows:e.rows.filter((e,t)=>t!==r)}),children:(0,h.jsx)(Vc,{"aria-hidden":`true`,strokeWidth:1.75})})})]},r))})]})}),(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,h.jsxs)(L,{size:`small`,onClick:()=>t({...e,rows:[...e.rows,{title:``,values:{}}]}),children:[(0,h.jsx)(kc,{"aria-hidden":`true`,className:`size-4`,strokeWidth:1.75}),`Add topic`]}),r.length===0?null:(0,h.jsxs)(AV,{"aria-label":`Set a keyword per topic`,value:``,className:`w-auto`,onChange:n=>{let r=n.target.value;r!==``&&t({...e,columns:[...e.columns,r]})},children:[(0,h.jsx)(`option`,{value:``,children:`Set a keyword per topic…`}),r.map(e=>(0,h.jsx)(`option`,{value:e,children:e},e))]})]})]})}var Bue=[[1,`Mon`],[2,`Tue`],[3,`Wed`],[4,`Thu`],[5,`Fri`],[6,`Sat`],[0,`Sun`]];function Vue({templates:e,pending:t,onCreated:n,onError:r,editing:i,onCancel:a,error:o,onBusy:s}){let{api:c}=R(),[l,u]=(0,m.useState)(i?.name??``),[d,f]=(0,m.useState)(i?.templateId??``),[p,g]=(0,m.useState)(i?.cadence.kind??`daily`),[_,v]=(0,m.useState)(i?.cadence.kind===`once`?nue(i.cadence.at,i.timezone):``),[y,b]=(0,m.useState)(i&&i.cadence.kind!==`once`?i.cadence.time:`09:00`),[x,S]=(0,m.useState)(i?.cadence.kind===`weekly`?i.cadence.days:[1,3,5]),[C,w]=(0,m.useState)(()=>i?.timezone??(Intl.DateTimeFormat().resolvedOptions().timeZone||`UTC`)),[T,E]=(0,m.useState)(i?.missedPolicy??`skip`),[D,O]=(0,m.useState)(i?.spendLimitCents?.toString()??``),[k,ee]=(0,m.useState)(()=>z0(i?.items??[])),[te,ne]=(0,m.useState)(i?.topicKeyword??null),[re,A]=(0,m.useState)(i?.values??{}),[ie,j]=(0,m.useState)(i?.brief??``),[ae,oe]=(0,m.useState)(i?.topicGeneration??fH),[se,ce]=(0,m.useState)(!1),[le,ue]=(0,m.useState)(!1),de=(0,m.useRef)(!1),fe=(0,m.useRef)(null),pe=i&&!e.some(e=>e.id===i.templateId)?[...e,{id:i.templateId,version:i.templateVersion,name:`Saved template`}]:e.map(e=>i?.templateId===e.id?{...e,version:i.templateVersion}:e),me=pe.find(e=>e.id===d),he=M({queryKey:[`project-template`,d],enabled:d!==``,queryFn:async()=>{let e=await Wq(c,d);if(!e.ok)throw Error(e.message);return e.value}}),ge=he.data?.document.form,_e=ge===void 0?void 0:F0({form:ge,prompts:he.data?.document.librarySnapshot?.prompts??[],entries:he.data?.document.librarySnapshot?.entries??[]}),ve=ge===void 0?[]:vq(ge),ye=te!==null&&ve.includes(te)?te:ve.find(e=>ge?.title.includes(`{{${e}}}`))??ve[0]??null,be=Object.fromEntries(ve.filter(e=>e!==ye).map(e=>[e,re[e]??ge?.values[e]??``])),xe={keywords:ve,topicKeyword:ye,everyRun:be,form:ge,kept:i?.items??[],..._e===void 0?{}:{origins:_e}},Se=H0(k,xe);async function Ce(e){if(e.preventDefault(),!(de.current||t)){if(!me&&!fe.current){r(`Choose a template before saving the schedule.`);return}if(!fe.current&&Se.problems.length>0){r(`Fix the topics first. ${Se.problems.slice(0,3).join(` `)}`);return}if(Se.rows.length>500){r(`Keep the list to 500 topics or fewer.`);return}if(ie.trim().length>4e3){r(`Keep the series brief to ${String(uH)} characters or fewer.`);return}if(ae.llm!==null&&(ae.llm.provider===``||ae.llm.model===``)){r(`Pick both a provider and a model for topic generation, or choose Use the template's LLM.`);return}if(p===`weekly`&&x.length===0){r(`Choose at least one weekday for a weekly schedule.`);return}de.current=!0,ce(!0),s(!0);try{if(!fe.current){if(!me)throw Error(`Choose a template before saving the schedule.`);let e=C.trim();if(!nH(e))throw Error(`Enter a timezone name like Europe/Tirane or America/New_York.`);let t=p===`once`?{kind:p,at:rue(_,e)}:p===`weekly`?{kind:p,time:y,days:x}:{kind:p,time:y},n=D.trim()===``?null:Number(D);if(n!==null&&(!Number.isInteger(n)||n<0))throw Error(`Enter the spend limit as a whole number of cents, 0 or more (500 is $5.00), or leave it empty.`);let r={id:i?.id??crypto.randomUUID(),name:l.trim(),templateId:me.id,templateVersion:i?.templateId===d?i.templateVersion:me.version,cadence:t,timezone:e,missedPolicy:T,overlapPolicy:`skip`,spendLimitCents:n,items:Se.rows,topicKeyword:ye,values:be,brief:ie.trim()===``?null:ie.trim(),topicGeneration:ae};fe.current=i?{...r,baseVersion:i.version,mutationId:crypto.randomUUID()}:r}let e=fe.current,{id:t,...a}=e,o=`mutationId`in a?await MH(c,t,a):await jH(c,e);if(!o.ok){fe.current=null,ue(!1),r(o.reason===`conflict`?`${o.message} Your inputs are kept here. To load the latest saved version, cancel editing and press Edit again.`:o.message);return}fe.current=null,ue(!1),u(``),ee(z0([])),n()}catch(e){ue(fe.current!==null),r(e instanceof Error?e.message:`The schedule wasn't saved. Try again.`)}finally{de.current=!1,ce(!1),s(fe.current!==null)}}}return(0,h.jsxs)(`section`,{"aria-label":i?`Edit schedule`:`New schedule`,children:[o?(0,h.jsx)(fI,{tone:`danger`,title:`The schedule wasn't saved.`,className:`mb-4`,children:o}):null,(0,h.jsxs)(`form`,{onSubmit:e=>void Ce(e),children:[(0,h.jsxs)(`fieldset`,{disabled:se||le||t,className:`m-0 grid min-w-0 gap-4 border-0 p-0 min-[700px]:grid-cols-2`,children:[(0,h.jsx)(Y,{label:`Name`,id:`schedule-name`,tip:`planning.schedule.name`,children:(0,h.jsx)(OV,{required:!0,value:l,onChange:e=>u(e.target.value),placeholder:`Monday morning stories`})}),(0,h.jsx)(Y,{label:`Template`,id:`schedule-template`,tip:`planning.schedule.template`,children:(0,h.jsxs)(AV,{required:!0,value:d,onChange:e=>f(e.target.value),disabled:pe.length===0,children:[(0,h.jsx)(`option`,{value:``,children:`Choose a template`}),pe.map(e=>(0,h.jsxs)(`option`,{value:e.id,children:[e.name,` · v`,e.version]},e.id))]})}),(0,h.jsx)(Y,{label:`Cadence`,id:`schedule-cadence`,tip:`planning.schedule.cadence`,children:(0,h.jsxs)(AV,{value:p,onChange:e=>g(e.target.value===`once`?`once`:e.target.value===`weekly`?`weekly`:`daily`),children:[(0,h.jsx)(`option`,{value:`daily`,children:`Every day`}),(0,h.jsx)(`option`,{value:`weekly`,children:`Selected weekdays`}),(0,h.jsx)(`option`,{value:`once`,children:`One time`})]})}),p===`once`?(0,h.jsx)(Y,{label:`Run at`,id:`schedule-once`,tip:`planning.schedule.once-at`,children:(0,h.jsx)(OV,{required:!0,type:`datetime-local`,value:_,onChange:e=>v(e.target.value)})}):(0,h.jsx)(Y,{label:`Local time`,id:`schedule-time`,tip:`planning.schedule.time`,children:(0,h.jsx)(OV,{required:!0,type:`time`,value:y,onChange:e=>b(e.target.value)})}),p===`weekly`?(0,h.jsxs)(`fieldset`,{className:`m-0 min-w-0 border-0 p-0`,...Tb,children:[(0,h.jsxs)(`legend`,{className:`sl-field__label mb-2 flex items-center gap-1`,children:[`Weekdays`,(0,h.jsx)(B,{id:`planning.schedule.weekdays`,className:`-my-1`})]}),(0,h.jsx)(`div`,{className:`flex flex-wrap gap-3`,children:Bue.map(([e,t])=>(0,h.jsxs)(`label`,{className:`inline-flex items-center gap-1 text-small`,children:[(0,h.jsx)(`input`,{type:`checkbox`,checked:x.includes(e),onChange:t=>S(n=>t.target.checked?[...n,e]:n.filter(t=>t!==e))}),t]},e))})]}):(0,h.jsx)(`div`,{}),(0,h.jsx)(Y,{label:`Timezone`,id:`schedule-timezone`,tip:p===`once`?`planning.schedule.timezone-once`:`planning.schedule.timezone`,children:(0,h.jsx)(OV,{value:C,onChange:e=>w(e.target.value),placeholder:`Europe/Tirane`})}),(0,h.jsx)(Y,{label:`Missed run`,id:`schedule-missed`,tip:`planning.schedule.missed`,children:(0,h.jsxs)(AV,{value:T,onChange:e=>E(e.target.value===`run-once`?`run-once`:`skip`),children:[(0,h.jsx)(`option`,{value:`skip`,children:`Skip if Slopify was closed`}),(0,h.jsx)(`option`,{value:`run-once`,children:`Run once when Slopify reopens`})]})}),(0,h.jsx)(Y,{label:`Spend ceiling (cents, optional)`,id:`schedule-spend`,tip:`planning.schedule.spend`,tipLabel:`Spend ceiling`,children:(0,h.jsx)(OV,{inputMode:`numeric`,value:D,onChange:e=>O(e.target.value),placeholder:`1000`})}),(0,h.jsx)(Rue,{queue:k,onQueue:ee,context:xe,onKeyword:ne,onValue:(e,t)=>A(n=>({...n,[e]:t})),loading:d!==``&&he.isPending,exportName:l}),(0,h.jsx)(Hue,{brief:ie,onBrief:j,generation:ae,onGeneration:oe,templateLlm:ge?.llm})]}),(0,h.jsxs)(`div`,{className:`sticky bottom-0 z-10 mt-6 flex flex-wrap gap-2 border-t border-line bg-ground py-3 max-md:bottom-[68px]`,children:[(0,h.jsx)(L,{type:`submit`,variant:`primary`,disabled:t||se||pe.length===0&&!le,children:se?`Saving…`:le?`Retry save`:i?`Save changes`:`Save schedule`}),(0,h.jsx)(L,{variant:`quiet`,disabled:se||le,onClick:a,children:i?`Cancel editing`:`Cancel`})]})]})]})}function Hue({brief:e,onBrief:t,generation:n,onGeneration:r,templateLlm:i}){let{api:a}=R(),o=M({...Zy(a),enabled:n.mode!==`off`}),s=n.llm;return(0,h.jsxs)(`fieldset`,{className:`m-0 flex min-w-0 flex-col gap-3 border-0 border-t border-line p-0 pt-5 min-[700px]:col-span-2`,children:[(0,h.jsxs)(`legend`,{className:`float-left mb-1 flex w-full items-center gap-1 text-title-3 font-semibold`,children:[`Topic generation`,(0,h.jsx)(B,{id:`planning.schedule.generation`})]}),(0,h.jsx)(Y,{label:`Series brief (optional)`,id:`schedule-brief`,tip:`planning.schedule.brief`,tipLabel:`Series brief`,children:(0,h.jsx)(kV,{rows:3,maxLength:uH,value:e,onChange:e=>t(e.target.value),placeholder:`Ancient history, documentary style. Famous rulers and places first.`})}),(0,h.jsxs)(`div`,{className:`grid gap-4 min-[700px]:grid-cols-2`,children:[(0,h.jsx)(Y,{label:`New topics`,id:`schedule-generation`,tip:`planning.schedule.new-topics`,children:(0,h.jsxs)(AV,{value:n.mode,onChange:e=>{let t=e.target.value;r({...n,mode:t===`queue`||t===`hold`?t:`off`})},children:[(0,h.jsx)(`option`,{value:`off`,children:`Off: add topics yourself`}),(0,h.jsx)(`option`,{value:`queue`,children:`Generate and queue directly`}),(0,h.jsx)(`option`,{value:`hold`,children:`Generate and hold for approval`})]})}),n.mode===`off`?null:(0,h.jsx)(Y,{label:`Keep at least this many queued`,id:`schedule-keep`,tip:`planning.schedule.keep-count`,children:(0,h.jsx)(OV,{type:`number`,min:1,max:100,value:String(n.keepAtLeast),onChange:e=>{let t=Math.round(Number(e.target.value));r({...n,keepAtLeast:Number.isFinite(t)?Math.min(100,Math.max(1,t)):1})}})})]}),n.mode===`off`?null:(0,h.jsxs)(`div`,{className:`flex flex-col gap-3`,...Tb,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,h.jsxs)(`label`,{className:`inline-flex items-center gap-2 text-small`,children:[(0,h.jsx)(`input`,{type:`checkbox`,checked:s===null,onChange:e=>r({...n,llm:e.target.checked?null:{provider:i?.provider??``,model:i?.model??``}})}),`Use the template's LLM`,s===null&&i!==void 0&&i.provider!==``?` (${i.provider} · ${i.model})`:``]}),(0,h.jsx)(B,{id:`planning.schedule.generation-llm`,className:`-my-1`})]}),s===null?null:(0,h.jsxs)(`div`,{className:`grid gap-4 min-[700px]:grid-cols-2`,children:[(0,h.jsx)(HV,{label:`Provider`,family:`llm`,providers:o.data?.providers??[],value:s.provider,problem:o.error?.message,onPick:e=>r({...n,llm:{provider:e,model:``}})}),(0,h.jsx)(UV,{label:`Model`,provider:s.provider,value:s.model,problem:void 0,onPick:e=>r({...n,llm:{...s,model:e}})})]})]})]})}function Uue({schedule:e}){let{api:t}=R(),n=_(),r=Dy(),[i,a]=(0,m.useState)(null),[o,s]=(0,m.useState)(!1),c=(0,m.useRef)(!1),[l,u]=(0,m.useState)(``),d=(0,m.useRef)(e);e.version>d.current.version&&(d.current=e);let f=d.current.items,p=e.topicKeyword===null?`title`:`{{${e.topicKeyword}}}`,g=async(e,i,o)=>{if(c.current)return!1;c.current=!0;let l=d.current;s(!0),a(null);try{let s=await GH(t,l.id,{baseVersion:l.version,items:e});return s.ok?(d.current=s.value,n.setQueryData(OH,e=>e?.map(e=>e.id===s.value.id?s.value:e)),n.invalidateQueries({queryKey:qH}),r(i,`success`,o?{label:`Undo`,run:()=>void g(l.items,`Put the topics back as they were.`,!1)}:void 0),!0):(a(s.reason===`conflict`?`The topics weren't saved: this schedule changed since the page loaded, possibly because a run just took a topic. The list now shows the latest; make your change again.`:`The topics weren't saved: ${s.message}`),await n.invalidateQueries({queryKey:OH}),!1)}catch(e){return a(`The topics weren't saved: ${e instanceof Error?e.message:`Slopify didn't answer.`} Check that Slopify is running, then try again.`),!1}finally{c.current=!1,s(!1)}},v=async e=>{e.preventDefault();let t=l.trim();if(t===``){a(`Write the new topic's ${p} first, then press Add topic.`);return}await g([...f,{title:t,values:{}}],`Added “${t}”.`,!0)&&u(``)},y=(e,t)=>{let n=f[e];if(n!==void 0&&t.trim()!==n.title){if(t.trim()===``){a(`Topic ${String(e+1)} needs a ${p}. Write one, or press its Remove button.`);return}g(f.map((n,r)=>r===e?{...n,title:t.trim()}:n),`Renamed to “${t.trim()}”.`,!0)}},b=(e,t)=>{let n=f[e];if(n===void 0)return;let r=[...f];r.splice(e,1),r.splice(e+t,0,n),g(r,`Moved “${n.title}” ${t===-1?`up`:`down`}.`,!0)},x=e=>{let t=f[e];t!==void 0&&g(f.filter((t,n)=>n!==e),`Removed “${t.title}”.`,!0)};return(0,h.jsxs)(`section`,{"aria-label":`Queued topics`,className:`mt-6`,...Tb,children:[(0,h.jsx)(V,{as:`h3`,title:`Queued topics · ${String(f.length)}`,info:`planning.schedule.inline-topics`,meta:e.topicKeyword===null?`Each topic becomes the next project's title.`:`Each topic fills ${p}; the next run takes the first.`}),i===null?null:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 mt-2 text-small text-danger`,children:i}),f.length===0?null:(0,h.jsx)(hU,{label:`Topics of ${e.name}`,className:`mt-2`,children:f.map((e,t)=>(0,h.jsx)(Wue,{index:t,title:e.title,count:f.length,busy:o,onRename:e=>y(t,e),onMove:e=>b(t,e),onRemove:()=>x(t)},`${String(t)}:${e.title}`))}),(0,h.jsxs)(`form`,{className:`mt-3 flex flex-wrap items-center gap-2`,onSubmit:e=>void v(e),children:[(0,h.jsx)(OV,{"aria-label":`New topic`,placeholder:e.topicKeyword===null?`New topic`:`New ${p}`,maxLength:200,value:l,className:`min-w-0 flex-1`,onChange:e=>u(e.target.value)}),(0,h.jsxs)(L,{type:`submit`,size:`small`,disabled:o||f.length>=500,disabledReason:o?`Saving the last change`:`A queue holds at most 500 topics`,children:[(0,h.jsx)(kc,{"aria-hidden":`true`,className:`size-4`,strokeWidth:1.75}),`Add topic`]})]})]})}function Wue({index:e,title:t,count:n,busy:r,onRename:i,onMove:a,onRemove:o}){let[s,c]=(0,m.useState)(t);(0,m.useEffect)(()=>c(t),[t]);let l=`Topic ${String(e+1)}`;return(0,h.jsx)(gU,{lead:(0,h.jsx)(`span`,{className:`w-6 text-small text-ink-3 tabular-nums`,children:e+1}),title:(0,h.jsx)(OV,{"aria-label":l,maxLength:200,value:s,onChange:e=>c(e.target.value),onBlur:()=>i(s),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),i(s)):e.key===`Escape`&&c(t)}}),actions:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(Cy,{size:`small`,label:`Move ${t} up`,disabled:r||e===0,onClick:()=>a(-1),children:(0,h.jsx)(ec,{"aria-hidden":`true`,strokeWidth:1.75})}),(0,h.jsx)(Cy,{size:`small`,label:`Move ${t} down`,disabled:r||e===n-1,onClick:()=>a(1),children:(0,h.jsx)(Zs,{"aria-hidden":`true`,strokeWidth:1.75})}),(0,h.jsx)(Cy,{size:`small`,label:`Remove ${t}`,disabled:r,onClick:o,children:(0,h.jsx)(Vc,{"aria-hidden":`true`,strokeWidth:1.75})})]})})}function Gue({pickedId:e,onPick:t}={}){let{api:n}=R(),r=_(),i=M(kH(n)),a=M(Uq(n)),[o,s]=(0,m.useState)(null),c=Dy(),[l,u]=(0,m.useState)(null),[d,f]=(0,m.useState)(!1),[p,g]=(0,m.useState)(!1),[v,y]=(0,m.useState)(null),b=t===void 0?v:e??null,x=e=>{t===void 0?y(e):t(e)},[S,C]=(0,m.useState)(null),w=(0,m.useRef)(!1),T=M(Jb(n)),[E]=(0,m.useState)(()=>{let e=new Date;return{from:e.toISOString(),to:new Date(e.valueOf()+79488e5).toISOString()}}),D=M(JH(n,E.from,E.to)),O=new Map;for(let e of D.data?.runs??[])e.renderedTitle!==null&&!O.has(e.scheduleId)&&O.set(e.scheduleId,e.renderedTitle);let[k,ee]=(0,m.useState)(``),te=e=>{if(k===``)return!0;let t=a.data?.find(t=>t.id===e.templateId);return(t?E0(t):Vb)===k},ne=i.data?.filter(e=>e.deletedAt===null&&te(e))??[],re=i.data?.filter(e=>e.deletedAt!==null)??[],A=i.data?.find(e=>e.id===b)??ne[0]??null,ie=N({onError:e=>s(e.message),onSettled:async()=>{w.current=!1,await r.invalidateQueries({queryKey:OH})},mutationFn:async e=>e(),onSuccess:async e=>{if(!e.ok){s(e.message);return}s(null)}}),j=e=>{w.current||(w.current=!0,s(null),ie.mutate(e))},ae=d||l!==null,oe=()=>{u(null),f(!1),s(null)},se=a.data?.length===0,ce=()=>{ae||se||(u(null),f(!0),s(null))},le=e=>{f(!1),x(e.id),u(e),s(null)};_x({id:`schedules.new`,title:`New schedule`,group:`Schedules`,keywords:[`calendar`,`recurring`],run:ce}),Kx(Vx.newSchedule,()=>{se?c(`A schedule runs a project template, and there is none yet. Open a project, choose Save as template, then run New schedule again.`,`error`):ce()},a.data!==void 0);let ue=o?{tone:`error`,text:o}:i.error?{tone:`error`,text:`The schedules couldn't be loaded: ${i.error.message} Reload the page to try again.`}:a.error?{tone:`error`,text:`The templates couldn't be loaded: ${a.error.message} Reload the page to try again.`}:void 0,de=ie.isPending||p||ae;return(0,h.jsxs)(`div`,{children:[(0,h.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center justify-between gap-3`,children:[(0,h.jsx)(`p`,{className:`m-0 min-w-0 text-small text-ink-2`,children:se?(0,h.jsxs)(h.Fragment,{children:[`Save a template in`,` `,(0,h.jsx)(pa,{className:`underline`,to:`/templates`,children:`Library → Templates`}),` `,`before creating a schedule.`]}):(0,h.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[`Runs a saved template on this machine at a local time.`,(0,h.jsx)(B,{id:`planning.schedules`})]})}),(0,h.jsxs)(Ty,{children:[(0,h.jsxs)(AV,{"aria-label":`Filter schedules by channel`,value:k,className:`w-auto min-w-[160px]`,onChange:e=>ee(e.target.value),children:[(0,h.jsx)(`option`,{value:``,children:`All channels`}),(T.data??[]).map(e=>(0,h.jsx)(`option`,{value:e.id,children:e.name},e.id))]}),(0,h.jsxs)(L,{variant:`primary`,onClick:ce,disabled:ae||se,disabledReason:se?`Save a template in Library → Templates first`:`Finish or cancel the open form first`,children:[(0,h.jsx)(kc,{"aria-hidden":`true`,className:`size-4`,strokeWidth:1.75}),`New schedule`]})]})]}),(0,h.jsx)(v0,{tone:ae?`info`:ue?.tone??`info`,className:`mb-2`,children:ae?void 0:ue?.text}),(0,h.jsx)(Mq,{className:`min-[768px]:grid-cols-[minmax(320px,460px)_minmax(0,1fr)]`,list:(0,h.jsxs)(h.Fragment,{children:[i.data&&ne.length===0?(0,h.jsx)(T0,{title:k===``?re.length===0?`No schedules yet`:`No active schedules`:`No schedules run this channel's templates`,children:k===``?re.length===0?`Your first one can be a one-off run or a recurring series. Press New schedule.`:`Create one with New schedule, or review deleted history below.`:`Pick All channels to see the others, or make one from this channel's templates.`}):null,ne.length>0?(0,h.jsx)(hU,{label:`Saved schedules`,className:`[&_.sl-row__actions]:flex-wrap`,children:ne.map(e=>(0,h.jsxs)(m.Fragment,{children:[(0,h.jsx)(W0,{schedule:e,nextTitle:O.get(e.id),selected:!ae&&A?.id===e.id,pending:de,onSelect:()=>x(e.id),onEdit:()=>le(e),onAction:j,onConfirm:t=>C({kind:t,schedule:e})}),(0,h.jsx)(O0,{kind:`schedule`,id:e.id,name:e.name})]},e.id))}):null,re.length>0?(0,h.jsxs)(`details`,{className:`mt-6`,children:[(0,h.jsxs)(`summary`,{className:`cursor-pointer text-small font-semibold text-ink-2`,children:[`Deleted schedules · `,re.length]}),(0,h.jsx)(`p`,{className:`m-0 mt-2 mb-2 text-small text-ink-2`,children:`Deleted schedules stay in Settings → Trash for 30 days, where Restore brings one back paused. Pick one to see its run history.`}),(0,h.jsx)(hU,{label:`Deleted schedules`,children:re.map(e=>(0,h.jsx)(W0,{schedule:e,nextTitle:void 0,selected:!ae&&A?.id===e.id,pending:!1,onSelect:()=>x(e.id),onEdit:()=>void 0,onAction:j,onConfirm:()=>void 0},e.id))})]}):null]}),detail:ae?(0,h.jsxs)(`div`,{children:[(0,h.jsx)(V,{kicker:l?l.name:void 0,title:l?`Edit schedule`:`New schedule`,className:`mb-4`}),(0,h.jsx)(Vue,{onBusy:g,editing:l,onCancel:()=>{p||oe()},templates:a.data??[],pending:ie.isPending,error:o,onCreated:()=>{c(l?`Schedule updated.`:`Schedule saved. It will run automatically while Slopify is open.`,`success`),oe(),r.invalidateQueries({queryKey:OH})},onError:e=>{s(e),r.invalidateQueries({queryKey:OH})}},l?.id??`new`)]}):A?(0,h.jsx)(Yue,{schedule:A,pending:de,onAction:j,onConfirm:e=>C({kind:e,schedule:A})},A.id):null}),(0,h.jsx)(Ay,{open:S!==null,title:S?.kind===`delete`?`Delete schedule?`:`Cancel schedule?`,consequence:(S?.kind===`delete`?`Moves this schedule to the trash for 30 days (Settings → Trash). Its run history is kept.`:`Stops future scheduled runs. Existing projects and run history are kept.`)+(o?` ${o}`:``),confirmLabel:S?.kind===`delete`?`Delete schedule`:`Cancel schedule`,cancelLabel:`Keep schedule`,pending:ie.isPending,onCancel:()=>{ie.isPending||C(null)},onConfirm:()=>{if(!S)return;let{kind:e,schedule:t}=S;j(async()=>{let r=e===`delete`?await PH(n,t.id,t.version):await NH(n,t.id,`cancel`,t.version);return r.ok&&C(null),r})}})]})}function Kue(e){return e.cadence.kind===`once`?`One time`:e.cadence.kind===`daily`?`Daily at ${e.cadence.time}`:`Weekly at ${e.cadence.time}`}var que={active:`Active`,paused:`Paused`,completed:`Completed`,canceled:`Canceled`},Jue={active:`running`,paused:`waiting`,completed:`done`,canceled:`off`};function U0({schedule:e}){return e.deletedAt===null?(0,h.jsx)(mS,{tone:Jue[e.status],children:que[e.status]}):(0,h.jsx)(mS,{tone:`off`,children:`Deleted`})}function W0({schedule:e,nextTitle:t,selected:n,pending:r,onSelect:i,onEdit:a,onAction:o,onConfirm:s}){let{api:c}=R(),l=e.deletedAt===null,u=l&&(e.status===`active`||e.status===`paused`),d=e.status===`canceled`||e.status===`completed`;return(0,h.jsx)(gU,{selected:n,onSelect:i,title:e.name,meta:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(U0,{schedule:e}),` · ${Kue(e)} · ${e.deletedAt===null?e.nextRunAt===null?`No future run`:`Next: ${a0(e.nextRunAt,e.timezone)}${t===void 0?``:` · “${t}”`}`:`Deleted: ${a0(e.deletedAt,e.timezone)}`}${e.topics.held>0?` · ${String(e.topics.held)} waiting for you`:``}`]}),actions:l?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(L,{variant:`quiet`,size:`small`,"aria-label":`Edit ${e.name}`,disabled:r||!u,disabledReason:u?`Finish or cancel the open form first`:`Only a live schedule can change`,onClick:a,children:`Edit`}),e.status===`paused`?(0,h.jsx)(L,{variant:`quiet`,size:`small`,"aria-label":`Resume ${e.name}`,disabled:r,onClick:()=>o(()=>NH(c,e.id,`resume`,e.version)),children:`Resume`}):(0,h.jsx)(L,{variant:`quiet`,size:`small`,"aria-label":`Pause ${e.name}`,disabled:r||e.status!==`active`,disabledReason:`Only an active schedule can pause`,onClick:()=>o(()=>NH(c,e.id,`pause`,e.version)),children:`Pause`}),(0,h.jsx)(L,{variant:`quiet`,size:`small`,"aria-label":`Delete ${e.name}`,disabled:r||!d,disabledReason:`Cancel the schedule first; a completed or canceled one can be deleted`,onClick:()=>s(`delete`),children:`Delete`})]}):void 0})}function Yue({schedule:e,pending:t,onAction:n,onConfirm:r}){let{api:i}=R(),a=M({queryKey:[`schedule`,e.id],queryFn:async()=>{let t=await AH(i,e.id);if(!t.ok)throw Error(t.message);return t.value},refetchInterval:3e4}),o=e.deletedAt===null,s=o&&(e.status===`active`||e.status===`paused`),c=e.status===`paused`,l=[[`When`,e.cadence.kind===`once`?`Once, ${a0(e.cadence.at,e.timezone)}`:e.cadence.kind===`daily`?`Every day at ${e.cadence.time}`:`Selected weekdays at ${e.cadence.time}`],[`Timezone`,e.timezone],[`Next run`,e.deletedAt!==null||e.nextRunAt===null?`None`:a0(e.nextRunAt,e.timezone)],[`Topics`,e.items.length===0?e.topicGeneration.mode===`off`?`Template as saved`:`No topics queued`:`${String(e.items.length)} ${e.items.length===1?`topic`:`topics`} left`],[`Missed runs`,e.missedPolicy===`skip`?`Skip`:`Run once on reopening`],[`Overlap`,`Skip`],[`Spend ceiling`,e.spendLimitCents===null?`Not set`:`${String(e.spendLimitCents)} cents`]];return(0,h.jsxs)(`section`,{"aria-label":`${e.name} detail`,children:[o&&s?(0,h.jsx)(Xue,{schedule:e,paused:c,onAction:n}):null,(0,h.jsx)(V,{kicker:(0,h.jsx)(U0,{schedule:e}),title:e.name,meta:e.topics.held>0?`${String(e.topics.held)} topics waiting for you`:void 0,children:o?(0,h.jsx)(L,{variant:`quiet`,size:`small`,"aria-label":`Cancel ${e.name}`,disabled:t||!s,disabledReason:`Only an active or paused schedule can be canceled`,onClick:()=>r(`cancel`),children:`Cancel schedule`}):null}),(0,h.jsx)(`dl`,{className:`m-0 mt-4 grid grid-cols-1 gap-x-6 gap-y-3 text-small min-[600px]:grid-cols-2`,children:l.map(([e,t])=>(0,h.jsxs)(`div`,{className:`min-w-0`,children:[(0,h.jsx)(`dt`,{className:`sl-kicker`,children:e}),(0,h.jsx)(`dd`,{className:`m-0 break-words text-ink`,children:t})]},e))}),s?(0,h.jsx)(Uue,{schedule:e}):null,(0,h.jsx)(Cue,{schedule:e}),(0,h.jsx)(Nq,{className:`my-6`}),(0,h.jsx)(V,{as:`h3`,title:`Run history`}),(0,h.jsx)(`div`,{className:`mt-3`,children:a.isPending?(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-3`,children:`Loading history…`}):a.error?(0,h.jsx)(`p`,{className:`m-0 text-small text-danger`,children:`The run history couldn't be loaded: ${a.error.message} It tries again every 30 seconds.`}):a.data.runs.length===0?(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-3`,children:`No runs yet.`}):(0,h.jsx)(hU,{label:`Runs of ${e.name}`,children:a.data.runs.map(t=>(0,h.jsx)(gU,{title:(0,h.jsx)(`span`,{className:`capitalize`,children:`${t.status} · ${a0(t.scheduledFor,e.timezone)}`}),meta:t.error?t.error:t.projectIds.length>0?(0,h.jsx)(`span`,{className:`inline-flex flex-wrap gap-x-3`,children:t.projectIds.map((e,t)=>(0,h.jsxs)(pa,{className:`underline hover:text-ink`,to:`/projects/$projectId`,params:{projectId:e},children:[`Project `,t+1]},e))}):`No projects`},t.id))})})]})}function Xue({schedule:e,paused:t,onAction:n}){let{api:r}=R();return _x({id:`schedules.pause-resume`,title:t?`Resume schedule`:`Pause schedule`,group:`Schedules`,context:e.name,run:()=>n(()=>NH(r,e.id,t?`resume`:`pause`,e.version))}),null}var G0=`https://www.youtube.com/upload`,Zue=[`video`,`title`,`description`,`thumbnails`,`playlist`,`audience`,`altered`,`tags`];function Que(e){return e.join(`, `)}var $ue=[.75,1,1.25,1.5,1.75,2];function K0(e){let t=Number.isFinite(e)?Math.max(0,Math.floor(e)):0,n=Math.floor(t/3600),r=Math.floor(t%3600/60),i=String(t%60).padStart(2,`0`);return n>0?`${String(n)}:${String(r).padStart(2,`0`)}:${i}`:`${String(r)}:${i}`}function q0(e){return`${String(e)}×`}function ede(e,t){return e.filter(e=>e.start<=t).at(-1)}function J0(...e){return t=>{for(let n of e)typeof n==`function`?n(t):n!=null&&(n.current=t)}}var Y0=(e,t,n)=>Math.min(n,Math.max(t,e));function X0(){let e=(0,m.useRef)(null),t=(0,m.useId)(),[n,r]=(0,m.useState)(!1),[i,a]=(0,m.useState)(0),[o,s]=(0,m.useState)(0),[c,l]=(0,m.useState)(0),[u,d]=(0,m.useState)(1),[f,p]=(0,m.useState)(!1),[h,g]=(0,m.useState)(1),[_,v]=(0,m.useState)(!1),[y,b]=(0,m.useState)(null),[x,S]=(0,m.useState)(!1),C=Number.isFinite(o)&&o>0,w=()=>{let t=e.current;t!==null&&(t.paused||t.ended?t.play()?.catch(()=>void 0):t.pause())},T=t=>{let n=e.current;if(n===null||!C)return;let r=Y0(t,0,o);n.currentTime=r,a(r)},E=t=>T((e.current?.currentTime??i)+t),D=t=>{let n=e.current;if(n===null)return;let r=Y0(Math.round(t*100)/100,0,1);n.volume=r,n.muted=r===0,d(r),p(r===0)},O=()=>{let t=e.current;t!==null&&(t.muted=!t.muted,p(t.muted))};return{media:e,menuId:t,playing:n,current:i,duration:o,buffered:c,known:C,volume:u,muted:f,rate:h,menu:_,setMenu:v,hover:y,setHover:b,seeking:x,setSeeking:S,toggle:w,seekTo:T,jump:E,setLevel:D,toggleMute:O,pickRate:n=>{let r=e.current;r!==null&&(r.playbackRate=n),g(n),v(!1),document.getElementById(`${t}-button`)?.focus()},keyAction:e=>{let t=e.length===1?e.toLowerCase():e;if(t===` `||t===`k`)return w;if(t===`j`)return()=>E(-10);if(t===`l`)return()=>E(10);if(t===`ArrowLeft`)return()=>E(-5);if(t===`ArrowRight`)return()=>E(5);if(t===`m`)return O;if(/^[0-9]$/.test(t))return()=>T(Number(t)/10*o)},events:{onPlay:()=>r(!0),onPause:()=>r(!1),onEnded:()=>r(!1),onTimeUpdate:e=>{x||a(e.currentTarget.currentTime)},onDurationChange:e=>s(e.currentTarget.duration),onLoadedMetadata:e=>s(e.currentTarget.duration),onProgress:e=>{let t=e.currentTarget.buffered;l(t.length>0?t.end(t.length-1):0)},onVolumeChange:e=>{d(e.currentTarget.volume),p(e.currentTarget.muted)},onRateChange:e=>g(e.currentTarget.playbackRate)}}}function Z0(e,t){let n=e?.getBoundingClientRect();return n===void 0||n.width===0?0:Y0((t-n.left)/n.width,0,1)}function Q0(e,t){t!==void 0&&(e.preventDefault(),e.stopPropagation(),t())}function $0({controls:e,className:t}){return(0,h.jsx)(Cy,{size:`small`,label:e.playing?`Pause`:`Play`,className:t,onClick:e.toggle,children:e.playing?(0,h.jsx)(Tc,{"aria-hidden":`true`,strokeWidth:1.75}):(0,h.jsx)(Oc,{"aria-hidden":`true`,strokeWidth:1.75})})}function e2({controls:e}){return(0,h.jsxs)(`span`,{className:`sl-player__time`,children:[(0,h.jsx)(`span`,{className:`sl-player__now`,children:K0(e.current)}),(0,h.jsx)(`span`,{className:`sl-player__total`,children:` / ${e.known?K0(e.duration):`-:--`}`})]})}function t2({controls:e,chapters:t=[]}){let n=(0,m.useRef)(null),{known:r,duration:i,current:a,buffered:o,seeking:s,hover:c}=e,l=r?t.filter(e=>e.start>0&&e.start<i):[],u=t=>{r&&(t.currentTarget.setPointerCapture?.(t.pointerId),e.setSeeking(!0),e.seekTo(Z0(n.current,t.clientX)*i))},d=t=>{let r=Z0(n.current,t.clientX);e.setHover(r),s&&e.seekTo(r*i)},f=t=>{t.currentTarget.releasePointerCapture?.(t.pointerId),e.setSeeking(!1)},p=t=>{Q0(t,{ArrowLeft:()=>e.jump(-5),ArrowDown:()=>e.jump(-5),ArrowRight:()=>e.jump(5),ArrowUp:()=>e.jump(5),PageDown:()=>e.jump(-10),PageUp:()=>e.jump(10),Home:()=>e.seekTo(0),End:()=>e.seekTo(i)}[t.key])},g=r?a/i*100:0,_=r?o/i*100:0,v=c===null||!r?void 0:c*i,y=v===void 0?void 0:ede(t,v);return(0,h.jsxs)(`div`,{ref:n,role:`slider`,tabIndex:0,"aria-label":`Seek`,"aria-valuemin":0,"aria-valuemax":r?Math.floor(i):0,"aria-valuenow":Math.floor(a),"aria-valuetext":`${K0(a)} of ${r?K0(i):`unknown length`}`,"aria-disabled":!r,className:`sl-player__track`,onPointerDown:u,onPointerMove:d,onPointerUp:f,onPointerCancel:f,onPointerLeave:()=>e.setHover(null),onKeyDown:p,children:[(0,h.jsxs)(`span`,{className:`sl-player__rail`,children:[(0,h.jsx)(`span`,{className:`sl-player__buffered`,style:{width:`${String(_)}%`}}),(0,h.jsx)(`span`,{className:`sl-player__played`,style:{width:`${String(g)}%`}})]}),l.map(e=>(0,h.jsx)(`span`,{className:`sl-player__mark`,"data-chapter":e.title,title:e.title,style:{left:`${String(e.start/i*100)}%`}},`${String(e.start)}-${e.title}`)),(0,h.jsx)(`span`,{className:`sl-player__knob`,style:{left:`${String(g)}%`}}),v===void 0||c===null?null:(0,h.jsxs)(`span`,{className:`sl-player__tip`,"aria-hidden":`true`,style:{left:`${String(c*100)}%`},children:[y===void 0?null:(0,h.jsx)(`span`,{className:`sl-player__tip-title`,children:y.title}),K0(v)]})]})}function n2({controls:e}){let t=(0,m.useRef)(null),{muted:n,volume:r}=e,i=n?0:r;return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(Cy,{size:`small`,label:n?`Unmute`:`Mute`,"aria-pressed":n,className:`sl-player__mute`,onClick:e.toggleMute,children:n||r===0?(0,h.jsx)(Bc,{"aria-hidden":`true`,strokeWidth:1.75}):(0,h.jsx)(zc,{"aria-hidden":`true`,strokeWidth:1.75})}),(0,h.jsx)(`div`,{ref:t,role:`slider`,tabIndex:0,"aria-label":`Volume`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(i*100),"aria-valuetext":n?`Muted`:`${String(Math.round(i*100))}%`,className:`sl-player__volume`,onPointerDown:n=>{n.currentTarget.setPointerCapture?.(n.pointerId),e.setLevel(Z0(t.current,n.clientX))},onPointerMove:n=>{n.buttons===1&&e.setLevel(Z0(t.current,n.clientX))},onKeyDown:t=>{let n={ArrowLeft:i-.05,ArrowDown:i-.05,ArrowRight:i+.05,ArrowUp:i+.05,Home:0,End:1}[t.key];Q0(t,n===void 0?void 0:()=>e.setLevel(n))},children:(0,h.jsx)(`span`,{className:`sl-player__rail`,children:(0,h.jsx)(`span`,{className:`sl-player__played`,style:{width:`${String(i*100)}%`}})})})]})}function r2({controls:e}){let{menuId:t,menu:n,rate:r}=e;return(0,h.jsxs)(`span`,{className:`sl-player__speed`,children:[(0,h.jsx)(L,{id:`${t}-button`,variant:`quiet`,size:`small`,className:`sl-player__rate`,"aria-label":`Playback speed, ${q0(r)}`,"aria-haspopup":`menu`,"aria-expanded":n,"aria-controls":n?`${t}-menu`:void 0,onClick:()=>e.setMenu(e=>!e),children:q0(r)}),n?(0,h.jsx)(`div`,{id:`${t}-menu`,role:`menu`,"aria-label":`Playback speed`,className:`sl-player__menu`,onKeyDown:n=>{if(n.key===`Escape`){Q0(n,()=>{e.setMenu(!1),document.getElementById(`${t}-button`)?.focus()});return}if(n.key!==`ArrowDown`&&n.key!==`ArrowUp`)return;let r=[...n.currentTarget.querySelectorAll(`[role=menuitemradio]`)],i=r[(r.indexOf(document.activeElement)+(n.key===`ArrowDown`?1:-1)+r.length)%r.length];Q0(n,()=>i?.focus())},children:$ue.map(t=>(0,h.jsx)(L,{variant:`quiet`,size:`small`,role:`menuitemradio`,"aria-checked":t===r,className:I(`sl-player__option`),autoFocus:t===r,onClick:()=>e.pickRate(t),children:t===1?`Normal`:q0(t)},t))}):null]})}var tde=2500;function i2({src:e,poster:t,label:n,portrait:r=!1,captions:i,chapters:a=[],ref:o,className:s,children:c}){let l=X0(),u=l.media,d=(0,m.useRef)(null),f=(0,m.useRef)(void 0),[p,g]=(0,m.useState)(!1),[_,v]=(0,m.useState)(!1),[y,b]=(0,m.useState)(0),[x,S]=(0,m.useState)(!1),[C,w]=(0,m.useState)(!1),[T,E]=(0,m.useState)(!1),[D,O]=(0,m.useState)(!0),{playing:k,menu:ee,seeking:te,hover:ne,events:re}=l,A=i!==void 0||y>0,ie=typeof document<`u`&&`pictureInPictureEnabled`in document&&document.pictureInPictureEnabled===!0,j=(0,m.useCallback)(()=>{O(!0),clearTimeout(f.current),f.current=setTimeout(()=>O(!1),tde)},[]);(0,m.useEffect)(()=>()=>clearTimeout(f.current),[]);let ae=k&&!D&&!ee&&!T&&!te&&ne===null;(0,m.useEffect)(()=>{let e=()=>S(document.fullscreenElement===d.current);return document.addEventListener(`fullscreenchange`,e),()=>document.removeEventListener(`fullscreenchange`,e)},[]),(0,m.useEffect)(()=>{let e=u.current;if(e===null)return;let t=()=>w(!0),n=()=>w(!1);return e.addEventListener(`enterpictureinpicture`,t),e.addEventListener(`leavepictureinpicture`,n),()=>{e.removeEventListener(`enterpictureinpicture`,t),e.removeEventListener(`leavepictureinpicture`,n)}},[u]),(0,m.useEffect)(()=>{let e=u.current?.textTracks;if(e!==void 0)for(let t=0;t<e.length;t+=1){let n=e[t];n!==void 0&&(n.mode=_&&t===0?`showing`:`hidden`)}},[_,u]);let oe=()=>{let e=u.current;e!==null&&(e.paused||e.ended)&&g(!0),l.toggle()},se=()=>{let e=d.current;e!==null&&(document.fullscreenElement===e?document.exitFullscreen?.():e.requestFullscreen?.()?.catch(()=>void 0))},ce=()=>{let e=u.current;e!==null&&(document.pictureInPictureElement===e?document.exitPictureInPicture?.().catch(()=>void 0):e.requestPictureInPicture?.().catch(()=>void 0))};return(0,h.jsxs)(`div`,{ref:d,"data-slot":`player`,"data-state":k?`playing`:`paused`,className:I(`sl-player`,r&&`sl-player--portrait`,ae&&`sl-player--bare`,x&&`sl-player--full`,s),onKeyDown:e=>{if(e.metaKey||e.ctrlKey||e.altKey)return;let t=e.target.closest(`button`)!==null,n=e.key.length===1?e.key.toLowerCase():e.key,r=n===` `&&t?void 0:n===` `||n===`k`?oe:n===`f`?se:n===`c`?A?()=>v(e=>!e):void 0:l.keyAction(n);r!==void 0&&(e.preventDefault(),e.stopPropagation(),j(),r())},onPointerMove:j,onPointerDown:j,onFocus:()=>E(!0),onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||(E(!1),l.setMenu(!1))},children:[(0,h.jsxs)(`video`,{ref:J0(u,o),src:e,poster:t,preload:`metadata`,playsInline:!0,"aria-label":n,onClick:oe,...re,onPlay:e=>{re.onPlay(e),g(!0),j()},onPause:e=>{re.onPause(e),O(!0)},onEnded:e=>{re.onEnded(e),O(!0)},onLoadedMetadata:e=>{re.onLoadedMetadata(e),b(e.currentTarget.textTracks?.length??0)},children:[i===void 0?null:(0,h.jsx)(`track`,{kind:`captions`,src:i.src,srcLang:i.lang,label:i.label}),c]}),p?null:(0,h.jsx)(Cy,{label:`Play ${n}`,className:`sl-player__big`,onClick:oe,children:(0,h.jsx)(Oc,{"aria-hidden":`true`,strokeWidth:1.75})}),(0,h.jsxs)(`div`,{className:`sl-player__bar`,role:`group`,"aria-label":`${n} controls`,children:[(0,h.jsx)($0,{controls:{...l,toggle:oe}}),(0,h.jsx)(e2,{controls:l}),(0,h.jsx)(t2,{controls:l,chapters:a}),(0,h.jsx)(n2,{controls:l}),(0,h.jsx)(r2,{controls:l}),A?(0,h.jsx)(Cy,{size:`small`,label:`Captions`,"aria-pressed":_,onClick:()=>v(e=>!e),children:(0,h.jsx)(ic,{"aria-hidden":`true`,strokeWidth:1.75})}):null,ie?(0,h.jsx)(Cy,{size:`small`,label:`Picture in picture`,"aria-pressed":C,className:`sl-player__pip`,onClick:ce,children:(0,h.jsx)(Dc,{"aria-hidden":`true`,strokeWidth:1.75})}):null,(0,h.jsx)(Cy,{size:`small`,label:x?`Exit full screen`:`Full screen`,"aria-pressed":x,onClick:se,children:x?(0,h.jsx)(wc,{"aria-hidden":`true`,strokeWidth:1.75}):(0,h.jsx)(Cc,{"aria-hidden":`true`,strokeWidth:1.75})})]})]})}var nde={landscape:void 0,portrait:`sl-media__frame--portrait`,square:`sl-media__frame--square`};function a2({src:e,alt:t,kind:n=`image`,poster:r,aspect:i=`landscape`,title:a,meta:o,badge:s,actions:c,actionsShown:l=!1,generating:u,onOpen:d,openLabel:f,className:p}){let m=u==null||u===!1;return(0,h.jsxs)(`figure`,{className:I(`sl-media m-0`,p),"data-slot":`media-frame`,children:[(0,h.jsxs)(`div`,{className:I(`sl-media__frame`,nde[i]),children:[m&&e!==void 0?n===`video`?(0,h.jsx)(`video`,{src:e,poster:r,muted:!0,preload:`metadata`,"aria-label":t}):(0,h.jsx)(`img`,{src:e,alt:t,loading:`lazy`,decoding:`async`}):null,m?null:(0,h.jsxs)(`div`,{className:`sl-media__generating`,role:`status`,children:[(0,h.jsx)(pS,{tone:`running`}),(0,h.jsx)(`span`,{children:u})]}),s===void 0?null:(0,h.jsx)(`span`,{className:`sl-media__badge`,children:s}),c===void 0?null:(0,h.jsx)(`div`,{className:I(`sl-media__actions`,l&&`sl-media__actions--shown`),children:c})]}),d!==void 0&&m&&e!==void 0?(0,h.jsx)(`button`,{type:`button`,className:`sl-media__open`,"aria-label":f??`Open ${t} full size`,onClick:d}):null,a===void 0&&o===void 0?null:(0,h.jsxs)(`figcaption`,{className:`sl-media__caption`,children:[a===void 0?(0,h.jsx)(`span`,{}):(0,h.jsx)(`strong`,{className:`min-w-0 truncate`,children:a}),o===void 0?null:(0,h.jsx)(`span`,{className:`shrink-0`,children:o})]})]})}function o2({shorts:e=!1,density:t=`default`,list:n=!1,className:r,children:i,label:a}){let o=I(`sl-grid`,e&&`sl-grid--shorts`,t===`compact`&&`sl-grid--compact`,n&&`m-0 list-none p-0`,r);return n?(0,h.jsx)(`ul`,{"aria-label":a,className:o,"data-slot":`media-grid`,children:i}):(0,h.jsx)(`section`,{"aria-label":a,className:o,"data-slot":`media-grid`,children:i})}function s2({items:e,index:t,onIndex:n,onClose:r,actions:i}){let a=t===null?void 0:e[t],o=e.length,s=e=>{t!==null&&o!==0&&n((t+e+o)%o)};return(0,h.jsx)(hm,{open:a!==void 0,onOpenChange:e=>{e||r()},children:(0,h.jsx)(vm,{children:(0,h.jsx)(wm,{className:`sl-lightbox sl-enter`,onKeyDown:e=>{e.key===`ArrowRight`?(e.preventDefault(),s(1)):e.key===`ArrowLeft`&&(e.preventDefault(),s(-1))},"aria-describedby":void 0,children:a===void 0||t===null?null:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`div`,{className:`sl-lightbox__bar`,children:[(0,h.jsx)(Em,{className:`m-0 text-small font-semibold`,children:`${String(t+1)} of ${String(o)} · ${a.alt}`}),(0,h.jsxs)(`div`,{className:`sl-btn-row`,children:[i?.(a,t),(0,h.jsx)(Cy,{label:`Previous`,onClick:()=>s(-1),disabled:o<2,children:(0,h.jsx)(sc,{"aria-hidden":`true`,strokeWidth:1.75})}),(0,h.jsx)(Cy,{label:`Next`,onClick:()=>s(1),disabled:o<2,children:(0,h.jsx)(cc,{"aria-hidden":`true`,strokeWidth:1.75})}),(0,h.jsx)(Om,{asChild:!0,children:(0,h.jsx)(Cy,{label:`Close`,children:(0,h.jsx)(Vc,{"aria-hidden":`true`,strokeWidth:1.75})})})]})]}),(0,h.jsx)(`div`,{className:`sl-lightbox__stage`,children:a.kind===`video`?(0,h.jsx)(i2,{src:a.src,label:a.alt,className:`sl-lightbox__player`,...a.poster===void 0?{}:{poster:a.poster}},a.src):(0,h.jsx)(`img`,{src:a.src,alt:a.alt},a.src)}),a.caption===void 0?(0,h.jsx)(`span`,{}):(0,h.jsx)(`p`,{className:`sl-lightbox__caption`,children:a.caption})]})})})})}var c2={location:SO(`docker-host`),path:U().min(1)},l2=uO([K({opened:SO(!0)}).strict(),K({opened:SO(!0),...c2}).strict(),K({opened:SO(!1),...c2}).strict()]),u2=fO(`kind`,[K({kind:SO(`allAffected`)}).strict(),K({kind:SO(`selected`),workKeys:G(U().min(1).max(200)).min(1).max(1e4)}).strict()]),d2=U().min(1).max(64),rde=K({baseRevisionId:d2,request:u2}).strict(),ide=K({baseRevisionId:d2,idempotencyKey:ND(),previewId:U().min(1).max(64),acknowledgeUnknownCosts:eO(),confirmedProvidedWorkKeys:G(U().min(1).max(200)).max(1e4)}).strict(),ade=K({stage:U(),low:W().finite().nonnegative().nullable(),high:W().finite().nonnegative().nullable(),detail:U(),onPlan:eO().optional(),apiLow:W().finite().nonnegative().nullable().optional(),apiHigh:W().finite().nonnegative().nullable().optional()}),ode=K({currency:SO(`USD`),rows:G(ade),low:W().finite().nonnegative(),high:W().finite().nonnegative(),unknown:W().int().nonnegative(),apiLow:W().finite().nonnegative().optional(),apiHigh:W().finite().nonnegative().optional(),apiUnknown:W().int().nonnegative().optional(),expectedWords:W().finite().nonnegative(),catalogueDate:U().nullable(),assumptions:G(U())}),f2=K({revisionId:d2,admissionId:U().min(1).max(64),workIds:G(U().min(1).max(64)),replayed:eO()}),sde=K({id:U().min(1).max(64),projectId:U().min(1).max(64),baseRevisionId:d2,planFingerprint:U().min(1),selection:u2,changedInputs:G(K({path:U(),before:U().nullable(),after:U().nullable()})),work:G(K({key:U(),stage:q(MS),kind:q([`provider`,`local`,`provided`]),disposition:q([`reuse`,`generate`,`local`,`review`,`blocked`]),requestFingerprint:U(),fingerprint:U(),dependsOn:G(U()),reason:U(),inflight:eO(),pieceIds:G(U())})),retained:G(K({slot:U(),outputId:U(),assetId:U(),state:q([`ready`,`outdated`,`review`])})),providedReuseRequired:G(U()),costs:ode,wholeRequestNotice:U().nullable(),warnings:G(U()),review:K({inputChanges:G(K({label:U(),before:U().nullable(),after:U().nullable()})),requests:G(K({key:U(),label:U(),text:U().nullable(),settings:U().nullable()}))}).optional()}),p2=[`chapter`,`chunk`,`segment`,`image`,`prompt_written`,`article_written`],m2=[`pending`,`running`,`done`,`failed`];K({id:U(),stage_id:U(),kind:q(p2),idx:W(),state:q(m2),payload:U().nullable()});var cde=`notes.article_md.article_txt.narration_txt.tts_script.sources.glossary.audio_body.audio_intro.audio_outro.audio_export.image.thumbnail.video.render_params.subtitles_srt.subtitles_vtt.subtitle_words.subtitle_ass.subtitle_font.instructions.document_pdf.youtube_description.youtube_tags.shorts.short_image.short_video.animated_image.figure_card.reference.script_md.audio_mp3.audio_m4b.audio_levelled`.split(`.`),lde=[`copying`,`staged`],ude=K({segment:q([`body`,`intro`,`outro`]).optional(),subtitleOmissions:G(K({start:W().finite().nonnegative(),text:U()})).optional(),subtitlesMode:q([`off`,`files`,`burn-in`]).optional(),promptName:U().optional(),prompt:U().optional(),index:W().optional(),short:W().optional(),format:q([`16:9`,`9:16`]).optional(),sentences:gO([W(),W()]).optional(),warnings:G(U()).optional(),provider:U().optional(),model:U().optional(),voice:U().optional(),loudness:K({pieces:W(),skipped:W(),spreadBefore:W(),spreadAfter:W(),target:W()}).optional(),master:K({target:W(),integrated:W(),truePeak:W()}).optional()}),dde=K({id:U(),projectId:U(),stageKind:q(MS),role:q(cde),path:U(),originalFilename:U().nullable(),bytes:W().nonnegative(),durationMs:W().nonnegative().nullable(),meta:ude,createdAt:U()});K({id:U(),stageKind:q(MS),path:U(),originalFilename:U(),bytes:W().nonnegative(),state:q(lde),createdAt:U()});var h2=U().min(1).max(64).regex(/^[0-9A-Za-z_-]+$/),g2=U().min(1).max(256),fde=vO(g2,h2),pde=K({id:h2,text:U().trim().min(1).max(1e4),start:W().finite().nonnegative(),end:W().finite().positive(),speaker:U().min(1).max(60).regex(/^[a-z0-9-]+$/).optional()}).strict().refine(e=>e.end>e.start,{path:[`end`],message:`The end time must be after the start time.`}),_2=K({articleMarkdown:U().max(5e5).optional(),articleEdited:eO().default(!1),provided:K({research:h2.optional(),article:h2.optional(),audio:h2.optional(),thumbnail:h2.optional(),reference:h2.optional()}).strict(),imageOrder:G(h2).max(240),imageDefinitions:vO(h2,K({source:q([`generate`,`provide`]),assetId:h2.nullable(),prompt:U().max(5e5).nullable(),templateKey:U().min(1).max(256).nullable().optional()}).strict()),narrationOverrides:vO(g2,fO(`kind`,[K({kind:SO(`asset`),assetId:h2}).strict(),K({kind:SO(`text`),text:U().trim().min(1).max(5e5)}).strict()])),narrationSources:vO(g2,K({text:U().min(1).max(5e5),start:W().int().nonnegative().max(5e5),bodyFingerprint:U().regex(/^[0-9a-f]{64}$/u),chunkingFingerprint:U().regex(/^[0-9a-f]{64}$/u)}).strict()).refine(e=>Object.keys(e).length<=1e4&&Object.values(e).reduce((e,t)=>e+t.text.length,0)<=5e5,`Narration source bindings exceed the article limit.`).optional(),subtitleCues:K({audioFingerprint:U().min(1),cues:G(pde)}).strict().optional(),regenerationTokens:fde,promptTemplates:vO(U().min(1),U().max(5e5).nullable()),shortsMusic:h2.optional(),shortsRanges:vO(U().regex(/^[1-9]\d?$/u),K({first:W().int().positive(),last:W().int().positive(),pick:U().min(1).max(128)}).strict()).optional(),ambientBed:h2.optional()}).strict(),mde=K({baseRevisionId:h2,idempotencyKey:h2,edit:K({config:DM.strict(),content:_2,regenerate:G(g2).optional(),uploads:G(K({stagedFileId:h2,destination:fO(`kind`,[K({kind:SO(`provided`),stage:q([`audio`,`thumbnail`,`reference`])}).strict(),K({kind:SO(`image`),imageKey:h2}).strict(),K({kind:SO(`narration`),key:g2}).strict(),K({kind:SO(`shortsMusic`)}).strict()])}).strict()).max(1e4).optional()}).strict()}).strict(),hde=K({baseRevisionId:h2,idempotencyKey:h2,targetRevisionId:h2}).strict(),gde=K({id:h2,projectId:h2,parentId:h2.nullable(),restoredFromId:h2.nullable(),config:DM,content:_2,fingerprints:vO(g2,U()),createdAt:U()}),_de=K({id:h2,stageId:h2,kind:q(p2),idx:W().int(),state:q(m2),payload:U().nullable()}),vde=K({slot:U(),workKey:g2,assetId:h2,output:dde,fingerprint:U(),state:q([`ready`,`outdated`,`review`])}),yde=K({key:g2,stageKind:q(MS),piece:_de,assetId:h2.nullable(),fingerprint:U()}),v2={recordId:h2,publicationId:h2.nullable(),selected:eO(),available:eO()},y2=K({articleMarkdown:U().nullable(),revision:gde,outputs:G(vde.extend(v2)),pieces:G(yde.extend(v2)),current:eO()}),bde=K({id:h2,parentId:h2.nullable(),restoredFromId:h2.nullable(),title:U(),createdAt:U(),current:eO()}),b2=K({ok:SO(!0),view:y2,duplicate:eO()}),xde=K({ok:SO(!0),view:y2,created:eO()}),Sde=K({title:U(),status:W(),detail:U().optional(),reason:U().optional(),currentRevisionId:U().nullable().optional(),fields:G(K({field:U(),message:U()})).optional(),errors:G(K({path:U(),message:U()})).optional()});async function x2(e,t){let n;try{n=await e.json()}catch{throw lo(e,void 0)}if(e.ok)return{ok:!0,value:yo(t,n)};let r=Sde.safeParse(n);if(!r.success)throw lo(e,void 0);let i=r.data;if(![400,404,409].includes(e.status))throw lo(e,{title:i.title,status:i.status,...i.detail===void 0?{}:{detail:i.detail},...i.fields===void 0?{}:{fields:i.fields}});return{ok:!1,reason:i.reason??`invalid-request`,message:i.detail??i.title,currentRevisionId:i.currentRevisionId??null,fields:i.fields??i.errors?.map(e=>({field:e.path,message:e.message}))??[]}}async function S2(e,t,n,r,i){return x2(await e.fetch(`${e.origin}/api/projects/${encodeURIComponent(t)}${n}`,i===void 0?{method:`GET`}:{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(i)}),r)}function C2(e,t){return S2(e,t,`/revisions/prepare`,xde,{})}function Cde(e,t,n){return S2(e,t,`/revisions`,b2,mde.parse(n))}function wde(e,t,n){return S2(e,t,`/revisions/restore`,b2,hde.parse(n))}function Tde(e,t){return S2(e,t,`/revisions`,K({revisions:G(bde)}))}function w2(e,t,n){return S2(e,t,`/revisions/${encodeURIComponent(n)}`,K({view:y2}))}var T2=G(U()).readonly();function Ede(e,t,n){return S2(e,t,`/revisions/${encodeURIComponent(n)}/narration-chunks`,K({chunks:K({intro:T2.optional(),body:T2.optional(),outro:T2.optional()}).nullable()}))}function Dde(e,t,n){return S2(e,t,`/rebuild/preview`,K({ok:SO(!0),value:sde}),rde.parse(n))}function Ode(e,t,n){return S2(e,t,`/rebuild`,K({ok:SO(!0),value:f2}),ide.parse(n))}function E2(e,t,n,r){return`${e.origin}/files/${encodeURIComponent(t)}/revisions/${encodeURIComponent(n)}/${encodeURIComponent(r)}`}async function kde(e,t,n,r){let i=await x2(await e.fetch(`${e.origin}/api/projects/${encodeURIComponent(t)}/revisions/${encodeURIComponent(n)}/${encodeURIComponent(r)}/open-folder`,{method:`POST`}),l2);if(!i.ok)throw Error(i.message);return i.value}function Ade(e,t,n){return E2(e,t,n,`images.zip`)}async function D2(e,{projectId:t,asset:n,folder:r=null}){if(r)return kde(e,t,r.revisionId,r.recordId);let i=await e.client.projects[`:id`][`open-folder`].$post({param:{id:t},json:{asset:n}});if(!i.ok)throw lo(i,await uo(i));return l2.parse(await i.json())}var O2=`Slopify runs in Docker, which can't open windows on your desktop. Copy this path into your file manager. To have Open folder open it directly, run the Docker launcher again (npx @gentbajko/slopify@latest --docker) so it sets up the host helper.`;function k2(e){return(0,h.jsx)(jde,{...e},JSON.stringify([e.projectId,e.asset,e.folder?.revisionId,e.folder?.recordId]))}function jde(e){let{api:t}=R(),[n,r]=(0,m.useState)(!1),[i,a]=(0,m.useState)(),[o,s]=(0,m.useState)();async function c(){r(!0),a(void 0),s(void 0);try{let n=await D2(t,e);n.opened||s(n.path)}catch(e){a(e instanceof Error?e.message:`The folder couldn't be opened. Press Open folder to try again.`)}finally{r(!1)}}return(0,h.jsxs)(yb,{open:o!==void 0||i!==void 0,onOpenChange:e=>{e||(s(void 0),a(void 0))},children:[(0,h.jsx)(xb,{asChild:!0,children:(0,h.jsxs)(L,{variant:`secondary`,size:e.size??`default`,disabled:n,onClick:()=>void c(),title:`Locate the saved output folder on the machine running Slopify`,children:[(0,h.jsx)(_c,{"aria-hidden":`true`,strokeWidth:1.75}),n?`Locating…`:o?`Locate folder`:`Open folder`]})}),(0,h.jsxs)(Cb,{className:`flex flex-col gap-2`,children:[o===void 0?null:(0,h.jsxs)(`div`,{role:`status`,className:`flex min-w-0 flex-col gap-2 text-small text-ink-2`,children:[(0,h.jsx)(`p`,{className:`m-0`,children:O2}),(0,h.jsx)(`input`,{"aria-label":`Saved folder path`,readOnly:!0,value:o,onFocus:e=>e.currentTarget.select(),className:`sl-input w-full min-w-0 font-mono text-small`})]}),i===void 0?null:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-small text-danger`,children:i})]})]})}var Mde={chrome:`Chrome, Edge, Brave`,firefox:`Firefox`};function Nde(){return typeof navigator<`u`&&/firefox/i.test(navigator.userAgent)?`firefox`:`chrome`}function A2(){let{api:e}=R(),[t,n]=(0,m.useState)(Nde),r=`slopify-studio-${t}.zip`;return(0,h.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,h.jsx)(Db,{label:`Browser`,value:t,onChange:n,tip:`settings.studio.install`,options:[`chrome`,`firefox`].map(e=>({value:e,label:Mde[e]}))}),(0,h.jsxs)(dS,{href:ns(e,t),download:r,children:[(0,h.jsx)(pc,{"aria-hidden":`true`,className:`size-4 shrink-0`,strokeWidth:1.75}),`Download for ${t===`chrome`?`Chrome`:`Firefox`}`]})]}),(0,h.jsxs)(`ol`,{"aria-label":`Install steps`,className:`m-0 flex list-decimal flex-col gap-1 pl-5`,children:[t===`chrome`?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`li`,{children:[`Press Download for Chrome, then unzip `,(0,h.jsx)(jV,{children:r}),` into a folder you keep: the browser loads the extension from there.`]}),(0,h.jsxs)(`li`,{children:[`Open `,(0,h.jsx)(jV,{children:`chrome://extensions`}),` (Edge: `,(0,h.jsx)(jV,{children:`edge://extensions`}),`), turn on Developer mode, press Load unpacked and pick that folder.`]})]}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`li`,{children:`Press Download for Firefox. It needs Firefox 128 or newer; keep the zip, you pick it in the next step.`}),(0,h.jsxs)(`li`,{children:[`Open `,(0,h.jsx)(jV,{children:`about:debugging#/runtime/this-firefox`}),`, press Load Temporary Add-on and pick `,(0,h.jsx)(jV,{children:r}),`. Firefox removes it when it restarts; load it again then.`]})]}),(0,h.jsx)(`li`,{children:`Pair it: press Copy beside the pairing token in Settings → YouTube Studio, click the Slopify extension's toolbar button, paste the token and press Pair.`})]})]})}var j2=[`studio`,`settings`];function Pde(){return(0,h.jsxs)(`div`,{children:[(0,h.jsx)(V,{title:`Upload pack and extension`,info:`settings.studio.extension`}),(0,h.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[(0,h.jsx)(Fde,{}),(0,h.jsx)(Ide,{}),(0,h.jsxs)(`section`,{"aria-label":`Install the Studio extension`,children:[(0,h.jsx)(V,{as:`h3`,title:`Install the Studio extension`,className:`mb-3`}),(0,h.jsx)(A2,{})]})]})]})}var M2=``;function Fde(){let{api:e}=R(),t=_(),n=Dy(),r=(0,m.useId)(),i=M({queryKey:j2,queryFn:()=>es(e)}),a=M(Jb(e)),o=(0,m.useId)(),[s,c]=(0,m.useState)(M2),[l,u]=(0,m.useState)(void 0),d=i.data?.playlist??null,f=s===M2?d:i.data?.channelPlaylists[s]??null,p=l??f??``,g=p.trim().length>150?`The playlist name is longer than YouTube allows (150 characters). Shorten it.`:void 0,v=N({mutationFn:t=>ts(e,t,s===M2?void 0:s),onSuccess:()=>{u(void 0),t.invalidateQueries({queryKey:j2}),n(`Playlist saved.`,`success`)}}),y=g??v.error?.message,b=[{value:M2,label:`Every channel (default)`},...(a.data??[]).map(e=>({value:e.id,label:e.name}))];return(0,h.jsxs)(Y,{label:`Playlist`,tip:`settings.studio.playlist`,help:s===M2?`The playlist upload packs name, for every channel without its own.`:d===null?`This channel's own playlist. Empty: no playlist.`:`This channel's own playlist. Empty: the default, "${d}".`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,h.jsx)(AV,{id:o,"aria-label":`Channel`,value:s,options:b,onChange:e=>{v.reset(),u(void 0),c(e.currentTarget.value)},className:`max-w-[220px]`}),(0,h.jsx)(OV,{autoComplete:`off`,placeholder:s!==M2&&d!==null?`Default: ${d}`:`The playlist's name in Studio`,className:`min-w-0 flex-1 basis-[220px]`,value:p,disabled:i.data===void 0,"aria-invalid":g!==void 0,"aria-describedby":y===void 0?void 0:r,onChange:e=>{v.reset(),u(e.target.value)}}),(0,h.jsx)(L,{variant:`primary`,disabled:v.isPending||l===void 0||g!==void 0,onClick:()=>v.mutate(p),children:`Save`})]}),y===void 0?null:(0,h.jsx)(`p`,{id:r,role:`alert`,className:`m-0 text-small text-danger`,children:y})]})}function Ide(){let{api:e}=R(),t=_(),n=Dy(),r=M({queryKey:j2,queryFn:()=>es(e)}),i=N({mutationFn:()=>as(e),onSuccess:()=>{t.invalidateQueries({queryKey:j2}),n(`New pairing token made. Pair the extension again with it.`,`success`)}}),a=r.data?.pairing;return(0,h.jsxs)(`div`,{className:`sl-field`,children:[(0,h.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1`,children:[(0,h.jsx)(`span`,{className:`sl-field__label`,children:`Extension pairing token`}),(0,h.jsx)(B,{id:`settings.studio.pairing`,className:`-my-1`})]}),(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,h.jsx)(`code`,{className:`sl-code min-w-0 flex-1 basis-[220px] truncate py-2 select-all`,children:a?.token??`…`}),(0,h.jsxs)(L,{variant:`quiet`,disabled:a===void 0,onClick:()=>{if(a!==void 0){if(!navigator.clipboard){n(`Couldn't copy the token. Select it and copy it.`,`error`);return}navigator.clipboard.writeText(a.token).then(()=>n(`Pairing token copied. Paste it into the extension's options.`,`success`),()=>n(`Couldn't copy the token. Select it and copy it.`,`error`))}},children:[(0,h.jsx)(fc,{"aria-hidden":`true`,className:`size-[14px] shrink-0`}),`Copy`]}),(0,h.jsx)(L,{variant:`quiet`,disabled:i.isPending||a===void 0,onClick:()=>i.mutate(),children:`New pairing token`})]}),(0,h.jsx)(`p`,{className:`sl-field__help m-0`,children:a?.origin==null?`No extension is paired. Paste this token into the Slopify Studio extension's options and press Pair.`:`Paired with the extension at ${a.origin}. A new token unpairs it.`}),i.error===null?null:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-small text-danger`,children:i.error.message})]})}var N2=[`studio`,`queue`];function P2({projectId:e,ready:t,variant:n=`secondary`,size:r=`default`}){let[i,a]=(0,m.useState)(!1);return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(L,{variant:n,size:r,disabled:!t,disabledReason:`Available once the video has been made`,onClick:()=>a(!0),children:`Prepare upload`}),i?(0,h.jsx)(L2,{projectId:e,onClose:()=>a(!1)}):null]})}var F2={video:`Video file`,title:`Title`,description:`Description`,thumbnails:`Thumbnail`,playlist:`Playlist`,audience:`Audience`,altered:`AI use (under Show more)`,tags:`Tags (under Show more)`};function I2(e){return e.kind===`video`?`video`:`short-${String(e.short)}`}function L2({projectId:e,onClose:t}){let{api:n}=R(),r=_(),i=[`studio`,`pack`,e],a=M({queryKey:i,queryFn:()=>os(n,e)}),[o,s]=(0,m.useState)(`video`),[c,l]=(0,m.useState)(),u=a.data?.items??[],d=u.find(e=>I2(e)===o)??u[0],f=M({queryKey:j2,queryFn:()=>es(n)}),p=f.data===void 0?void 0:f.data.pairing.origin!==null,g=M({queryKey:N2,queryFn:()=>rs(n)}),v=N({mutationFn:t=>cs(n,e,t.short),onSuccess:e=>{r.setQueryData(N2,e),l({text:e.length>1?`Added; ${String(e.length)} uploads are waiting. Studio is opening: each upload you start there is filled with the next one, in the order under Waiting for Studio. Check everything and publish yourself.`:`Studio is opening. Drop the video file into its upload dialog; the Slopify Studio extension fills in the details. Check everything and publish yourself.`,tone:`success`})},onError:e=>l({text:`Couldn't hand this to the extension: ${e.message}`,tone:`error`})}),y=N({mutationFn:e=>is(n,e.projectId,e.short),onSuccess:e=>r.setQueryData(N2,e),onError:e=>l({text:`Couldn't remove it from Waiting for Studio: ${e.message} Press Remove again.`,tone:`error`})}),b=N({mutationFn:t=>ss(n,e,t),onSuccess:e=>{r.setQueryData(i,e),l({text:`Saved. The AI use answer is updated.`,tone:`success`})},onError:e=>l({text:`Couldn't save whether the clips are real footage: ${e.message} Press the switch again.`,tone:`error`})});return(0,h.jsxs)(HP,{open:!0,title:`Prepare upload`,onClose:t,footer:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(v0,{tone:c?.tone??`info`,children:c?.text}),p===!1?(0,h.jsx)(dS,{href:G0,target:`_blank`,rel:`noopener noreferrer`,variant:`secondary`,children:`Open YouTube Studio`}):null,(0,h.jsx)(L,{variant:`primary`,disabled:d===void 0||v.isPending||p!==!0,disabledReason:p===!1?`Install and pair the Slopify Studio extension first (steps above)`:f.error===null?`Wait for the upload pack to load`:`Couldn't check whether the extension is paired: ${f.error.message} Close Prepare upload and open it again.`,onClick:()=>{d!==void 0&&(window.open(G0,`_blank`,`noopener`),v.mutate(d))},children:`Fill in YouTube Studio`}),(0,h.jsx)(B,{id:`project.upload.fill-studio`})]}),children:[a.error===null?null:(0,h.jsx)(fI,{tone:`danger`,title:`The upload pack couldn't be read.`,children:`${a.error.message} Close Prepare upload and open it again.`}),a.data===void 0?null:(0,h.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[p===!1?(0,h.jsx)(fI,{tone:`waiting`,title:`The Slopify Studio extension isn't paired.`,children:(0,h.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,h.jsx)(`p`,{className:`m-0`,children:`Without it, the steps below are the upload pack: copy each into Studio's upload dialog. To have Studio filled in for you, install the extension:`}),(0,h.jsx)(A2,{})]})}):null,u.length>1?(0,h.jsx)(Db,{label:`What to upload`,value:d===void 0?``:I2(d),onChange:s,tip:`project.upload.item`,options:u.map(e=>({value:I2(e),label:e.kind===`video`?`Video`:`Short ${String(e.short)}`})),className:`self-start`}):null,a.data.missing.length===0?null:(0,h.jsx)(fI,{tone:`waiting`,title:`Some of it isn't made yet.`,children:(0,h.jsx)(`ul`,{className:`m-0 flex list-none flex-col gap-1 p-0`,children:a.data.missing.map(e=>(0,h.jsx)(`li`,{children:e},e))})}),d===void 0?null:(0,h.jsx)(Rde,{projectId:e,item:d,footageSwitch:d.kind===`video`&&a.data.footage!==void 0?(0,h.jsx)(Eb,{checked:b.isPending?b.variables:a.data.footage.real,disabled:b.isPending,onChange:e=>b.mutate(e),tip:`project.upload.real-footage`,label:`The ${a.data.footage.clips===1?`uploaded clip is`:`${String(a.data.footage.clips)} uploaded clips are`} real footage (filmed, not made by AI)`}):void 0,copy:(e,t)=>{if(!navigator.clipboard){l({text:`Couldn't copy the ${t}. Select the text and copy it.`,tone:`error`});return}navigator.clipboard.writeText(e).then(()=>l({text:`Copied the ${t}.`,tone:`success`}),()=>l({text:`Couldn't copy the ${t}. Select the text and copy it.`,tone:`error`}))},doneKey:`slopify.upload.${e}.${I2(d)}`},I2(d)),(g.data??[]).length===0?null:(0,h.jsxs)(`section`,{"aria-label":`Waiting for Studio`,children:[(0,h.jsxs)(`div`,{className:`mb-2 flex items-center gap-1`,children:[(0,h.jsx)(`div`,{className:`sl-kicker`,children:`Waiting for Studio`}),(0,h.jsx)(B,{id:`project.upload.queue`,className:`-my-1`})]}),(0,h.jsx)(hU,{label:`Waiting to be filled`,children:(g.data??[]).map((e,t)=>{let n=e.short===null?`Video`:`Short ${String(e.short)}`;return(0,h.jsx)(gU,{title:`${e.projectTitle} · ${n}`,meta:t===0?`Next: filled in the next upload dialog you open in Studio.`:`Filled after ${String(t)} more upload${t===1?``:`s`}.`,actions:(0,h.jsx)(L,{variant:`quiet`,size:`small`,disabled:y.isPending,"aria-label":`Remove ${e.projectTitle} ${n.toLowerCase()} from Waiting for Studio`,onClick:()=>y.mutate(e),children:`Remove`})},`${e.projectId}-${String(e.short)}`)})})]}),(0,h.jsx)(fI,{title:`Slopify never publishes.`,children:p===!1?`Copy each step into Studio's upload dialog (Open YouTube Studio), check it and press Publish yourself.`:`Fill in YouTube Studio hands this to the Slopify Studio extension after you drop the video in. You check it and press Publish.`})]})]})}function Lde(e){try{let t=JSON.parse(localStorage.getItem(e)??`[]`);return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch{return[]}}function R2({href:e,filename:t}){return(0,h.jsxs)(dS,{href:e,download:t,"aria-label":`Download ${t}`,variant:`secondary`,size:`small`,children:[(0,h.jsx)(pc,{"aria-hidden":`true`,className:`size-4 shrink-0`,strokeWidth:1.75}),`Download`]})}function Rde({projectId:e,item:t,footageSwitch:n,copy:r,doneKey:i}){let{api:a}=R(),[o,s]=(0,m.useState)(()=>Lde(i)),[c,l]=(0,m.useState)(null),u=(e,t)=>{let n=t?[...o,e]:o.filter(t=>t!==e);s(n);try{localStorage.setItem(i,JSON.stringify(n))}catch{}},d=Zue.filter(e=>e!==`thumbnails`||t.kind===`video`),f=e=>{let n=z2(t,e);return(0,h.jsxs)(L,{variant:`quiet`,size:`small`,disabled:n===``,disabledReason:`Nothing to copy yet`,"aria-label":`Copy ${F2[e].toLowerCase()}`,onClick:()=>r(n,F2[e].toLowerCase()),children:[(0,h.jsx)(fc,{"aria-hidden":`true`,className:`size-4 shrink-0`,strokeWidth:1.75}),`Copy`]})},p=r=>{switch(r){case`video`:return t.video===null?{value:(0,h.jsx)(`span`,{className:`text-ink-3`,children:`Not made yet.`})}:{value:t.video.filename,actions:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(R2,{href:`${a.origin}${t.video.url}`,filename:t.video.filename}),(0,h.jsx)(k2,{projectId:e,asset:t.video.asset,size:`small`})]})};case`thumbnails`:return t.thumbnails.length===0?{value:(0,h.jsx)(`span`,{className:`text-ink-3`,children:`None made.`})}:{value:t.thumbnails.length>1?`The first under Thumbnail; all ${String(t.thumbnails.length)} in A/B Testing (beside the title).`:t.thumbnails[0]?.filename??``,actions:(0,h.jsx)(k2,{projectId:e,asset:t.thumbnails[0]?.asset??`thumbnail`,size:`small`})};case`audience`:return{value:`No, it's not made for kids`};case`altered`:return{value:(0,h.jsxs)(`span`,{className:`flex flex-col gap-1`,children:[(0,h.jsx)(`span`,{className:`font-semibold`,children:t.alteredContent.altered?`Yes`:`No`}),(0,h.jsx)(`span`,{className:`text-ink-2`,children:t.alteredContent.why}),n]})};case`description`:return{value:t.chapterNotice===void 0?z2(t,r)||(0,h.jsx)(`span`,{className:`text-ink-3`,children:`Not written yet.`}):(0,h.jsxs)(`span`,{className:`flex flex-col gap-1`,children:[(0,h.jsx)(`span`,{children:t.description}),(0,h.jsx)(`span`,{className:`text-waiting`,children:t.chapterNotice})]}),actions:f(r)};case`playlist`:return{value:t.playlist??(0,h.jsx)(`span`,{className:`text-ink-3`,children:`None set (Settings → YouTube Studio).`}),actions:f(r)};default:return{value:z2(t,r)||(0,h.jsx)(`span`,{className:`text-ink-3`,children:`Not written yet.`}),actions:f(r)}}};return(0,h.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,h.jsxs)(`section`,{"aria-label":`In the order Studio asks`,children:[(0,h.jsxs)(`div`,{className:`mb-2 flex items-center gap-1`,children:[(0,h.jsx)(`div`,{className:`sl-kicker`,children:`In the order Studio asks`}),(0,h.jsx)(B,{id:`project.upload.steps`,className:`-my-1`})]}),(0,h.jsx)(hU,{label:`Upload steps`,className:`[&_.sl-row__actions]:flex-wrap`,children:d.map(e=>{let{value:t,actions:n}=p(e);return(0,h.jsx)(gU,{className:`items-start`,lead:(0,h.jsx)(`input`,{type:`checkbox`,checked:o.includes(e),onChange:t=>u(e,t.currentTarget.checked),className:`mt-1 size-4 shrink-0 self-start accent-[var(--color-accent)]`,"aria-label":`${F2[e]} done`}),title:F2[e],meta:(0,h.jsx)(`span`,{className:`line-clamp-4 whitespace-pre-wrap break-words text-ink`,children:t}),actions:n},e)})})]}),t.thumbnails.length===0?null:(0,h.jsxs)(`section`,{"aria-label":`Thumbnails`,children:[(0,h.jsx)(V,{as:`h3`,kicker:`Thumbnails · A/B Testing`,title:`${String(t.thumbnails.length)} ${t.thumbnails.length===1?`thumbnail`:`thumbnails`}`,className:`mb-3`}),(0,h.jsx)(o2,{label:`Thumbnails to upload`,density:`compact`,children:t.thumbnails.map((e,t)=>(0,h.jsx)(a2,{src:`${a.origin}${e.url}`,alt:`Thumbnail ${String.fromCharCode(65+t)}`,title:String.fromCharCode(65+t),meta:e.filename,onOpen:()=>l(t),openLabel:`Open thumbnail ${String.fromCharCode(65+t)} full size`,actionsShown:!0,actions:(0,h.jsx)(R2,{href:`${a.origin}${e.url}`,filename:e.filename})},e.asset))}),(0,h.jsx)(s2,{items:t.thumbnails.map((e,t)=>({src:`${a.origin}${e.url}`,alt:`Thumbnail ${String.fromCharCode(65+t)}`,caption:e.filename})),index:c,onIndex:l,onClose:()=>l(null),actions:(e,n)=>{let r=t.thumbnails[n];return r===void 0?null:(0,h.jsx)(R2,{href:`${a.origin}${r.url}`,filename:r.filename})}})]})]})}function z2(e,t){switch(t){case`title`:return e.title;case`description`:return e.description;case`tags`:return Que(e.tags);case`playlist`:return e.playlist??``;default:return``}}var B2=4;function zde(e){return e===`schedules`?`schedules`:`weeks`}var V2=new Intl.DateTimeFormat(void 0,{weekday:`short`,day:`numeric`}),H2=new Intl.DateTimeFormat(void 0,{dateStyle:`full`}),U2=new Intl.DateTimeFormat(void 0,{timeStyle:`short`}),W2=`slopify.calendar.view`;function Bde(){try{return window.localStorage.getItem(W2)===`list`?`list`:`weeks`}catch{return`weeks`}}function Vde({tab:e,schedule:t,onTab:n,onSchedule:r}={}){let{api:i}=R(),a=_(),o=px(),[s]=(0,m.useState)(()=>lU(new Date,B2)),[c,l]=(0,m.useState)(Bde),[u,d]=(0,m.useState)(e??`weeks`),f=n===void 0?u:e??`weeks`,p=e=>{n===void 0?d(e):n(e)},[g,v]=(0,m.useState)(!1),y=M(JH(i,s.from,s.to)),b=M(kH(i)),x=M(Uq(i)),S=M(Ky(i)),[C,w]=(0,m.useState)(null),[T,E]=(0,m.useState)(null),D=(0,m.useMemo)(()=>new Map((x.data??[]).map(e=>[e.id,e.channelId])),[x.data]),O=(0,m.useMemo)(()=>new Map((S.data?.projects??[]).map(e=>[e.id,e.channelId])),[S.data]),k=(b.data??[]).filter(e=>o.includes(D.get(e.templateId))),ee=y.data===void 0?void 0:{...y.data,runs:y.data.runs.filter(e=>o.includes(D.get(e.templateId))),projects:y.data.projects.filter(e=>o.includes(O.get(e.id)))},te=(0,m.useMemo)(()=>ee===void 0?new Map:cU(ee),[ee]),ne=ee?.runs??[],re=rU(ee?.projects??[]),A=N({mutationFn:e=>e(),onSuccess:e=>w(e.ok?{tone:`info`,text:`Moved.`}:{tone:`error`,text:e.message}),onError:e=>w({tone:`error`,text:`The topic wasn't moved: ${e.message} Reload the calendar and try again.`}),onSettled:async()=>{await Promise.all([a.invalidateQueries({queryKey:qH}),a.invalidateQueries({queryKey:OH})])}}),ie=e=>{if(e.kind!==`none`){if(e.kind===`refused`){w({tone:`error`,text:e.message});return}e.kind===`move`?A.mutate(()=>WH(i,e.scheduleId,{baseVersion:e.baseVersion,from:e.from,to:e.to})):A.mutate(()=>KH(i,e.scheduleId,{baseVersion:e.baseVersion,index:e.index,targetId:e.targetId,...e.position===void 0?{}:{position:e.position}}))}},j=(e,t)=>{let n=dU(ne,e,t);if(n===void 0){w({tone:`error`,text:t===-1?`${fU(e)} is already the next topic of ${e.scheduleName}.`:`${fU(e)} is the last topic on the calendar for ${e.scheduleName}.`});return}ie(uU(e,n,H2.format(new Date(n.at))))},ae=e=>{l(e),f!==`weeks`&&p(`weeks`);try{window.localStorage.setItem(W2,e)}catch{}};_x({id:`calendar.add`,title:`Add to calendar`,group:`Calendar`,keywords:[`topics`,`batch`,`queue`],run:()=>v(!0)}),_x({id:`calendar.schedules`,title:`Show the schedules`,group:`Calendar`,keywords:[`edit`,`recurring`,`pause`,`resume`],run:()=>p(`schedules`)}),Kx(Vx.addToCalendar,()=>v(!0)),_x({id:`calendar.weeks`,title:`Show the calendar as weeks`,group:`Calendar`,run:()=>ae(`weeks`)}),_x({id:`calendar.list`,title:`Show the calendar as a list`,group:`Calendar`,run:()=>ae(`list`)});let oe=k.reduce((e,t)=>e+(t.deletedAt===null?t.items.length:0),0),se=C?.text??y.error?.message??b.error?.message,ce=aU(new Date),le=(b.data??[]).filter(e=>e.deletedAt===null).length;return(0,h.jsxs)(`div`,{"data-tour":`calendar`,children:[(0,h.jsx)(Aq,{title:`Calendar`,meta:`${o.channel?.name??`Every channel`} · ${String(ne.length)} scheduled ${ne.length===1?`run`:`runs`} in the next ${String(B2)} weeks · ${String(oe)} ${oe===1?`topic`:`topics`} queued`,actions:f===`schedules`?void 0:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(Db,{label:`Calendar view`,tip:`planning.calendar.view`,value:c,onChange:ae,options:[{value:`weeks`,label:`Weeks`},{value:`list`,label:`List`}]}),(0,h.jsxs)(L,{variant:`primary`,onClick:()=>v(!0),children:[(0,h.jsx)(kc,{"aria-hidden":`true`,strokeWidth:1.75}),`Add to calendar`]})]})}),(0,h.jsx)(C0,{items:[{id:`weeks`,label:`Coming weeks`},{id:`schedules`,label:`Schedules`,...b.data===void 0?{}:{badge:String(le)}}],value:f,onChange:p,label:`Calendar sections`,idPrefix:`calendar`,className:`mb-6`}),(0,h.jsx)(w0,{idPrefix:`calendar`,id:`schedules`,active:f===`schedules`,children:f===`schedules`?(0,h.jsx)(Gue,{pickedId:t,onPick:r}):null}),(0,h.jsxs)(w0,{idPrefix:`calendar`,id:`weeks`,active:f===`weeks`,children:[(0,h.jsx)(v0,{tone:C?.tone===`info`?`info`:se?`error`:`info`,className:`mb-3`,children:se}),(0,h.jsxs)(b0,{split:`aside`,children:[(0,h.jsxs)(x0,{label:`Coming weeks`,children:[re.length===0?null:(0,h.jsxs)(`section`,{"aria-label":`Needs you`,children:[(0,h.jsx)(V,{title:`Needs you`,meta:nU(re)}),(0,h.jsx)(hU,{label:`Needs you`,children:re.map(e=>(0,h.jsx)(G2,{project:e},e.id))})]}),y.isPending?(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-3`,children:`Loading the calendar…`}):c===`weeks`?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:`Drag a topic to another day to change when it runs, or onto another schedule's run to move it there. With the keyboard: focus a topic and press Alt+← or Alt+→.`}),sU(new Date(s.from),B2).map(e=>(0,h.jsx)(`div`,{className:`sl-cal-week`,children:e.map(e=>{let t=aU(e),n=te.get(t);return(0,h.jsx)(Hde,{date:e,today:t===ce,day:n,dragging:T,busy:A.isPending,onDragStart:E,onDragEnd:()=>E(null),onDrop:t=>{T!==null&&(ie(uU(T,t,H2.format(e))),E(null))},onStep:j},t)})},aU(e[0]??new Date)))]}):(0,h.jsx)(Wde,{days:te,busy:A.isPending,onStep:j,schedules:k,onTransfer:(e,t)=>{e.index!==null&&ie({kind:`transfer`,scheduleId:e.scheduleId,baseVersion:e.scheduleVersion,index:e.index,targetId:t,position:void 0})}}),ee!==void 0&&ee.queued.length>0?(0,h.jsxs)(`section`,{"aria-label":`Batch queue`,children:[(0,h.jsx)(V,{title:`Batch queue`,meta:`${String(ee.queued.length)} waiting to start`,info:`play.queue`}),(0,h.jsx)(hU,{label:`Batch queue`,children:ee.queued.toSorted((e,t)=>e.position-t.position).map((e,t)=>{let n=ee.projects.find(t=>t.id===e.projectId)?.state===`paused`;return(0,h.jsx)(gU,{title:(0,h.jsx)(pa,{to:`/projects/$projectId`,params:{projectId:e.projectId},children:e.title}),meta:`${String(t+1)} in line`,actions:(0,h.jsx)(mS,{tone:n?`waiting`:e.state===`active`?`running`:`off`,children:n?`Paused`:e.state===`active`?`Running now`:`Waiting its turn`})},e.projectId)})})]}):null]}),(0,h.jsx)(x0,{as:`aside`,label:`Suggested topics`,children:(0,h.jsx)(wue,{schedules:k})})]})]}),(0,h.jsx)(XH,{open:g,onOpenChange:v,schedules:k})]})}function Hde({date:e,today:t,day:n,dragging:r,busy:i,onDragStart:a,onDragEnd:o,onDrop:s,onStep:c}){let[l,u]=(0,m.useState)(!1),d=n?.runs??[],f=()=>d.find(e=>e.scheduleId===r?.scheduleId)??d[0];return(0,h.jsxs)(`section`,{"aria-label":H2.format(e),className:I(`sl-cal-day`,t&&`sl-cal-day--today`,l&&`sl-cal-day--over`),onDragOver:e=>{r!==null&&(e.preventDefault(),e.dataTransfer.dropEffect=`move`,u(!0))},onDragLeave:()=>u(!1),onDrop:e=>{e.preventDefault(),u(!1),s(f())},children:[(0,h.jsx)(`div`,{className:`sl-kicker`,children:t?`Today · ${V2.format(e)}`:V2.format(e)}),d.map(e=>(0,h.jsx)(Ude,{run:e,busy:i,onDragStart:a,onDragEnd:o,onDrop:t=>{t.preventDefault(),t.stopPropagation(),u(!1),s(e)},onStep:c},`${e.scheduleId}-${e.at}`)),(n?.projects??[]).map(e=>{let t=tU(e);return(0,h.jsxs)(`div`,{className:`sl-cal-item sl-cal-item--project ${pU}`,children:[(0,h.jsx)(pa,{to:`/projects/$projectId`,params:{projectId:e.id},className:`text-small font-semibold ${mU}`,children:e.title}),(0,h.jsx)(mS,{tone:t.tone,children:t.word})]},e.id)})]})}function Ude({run:e,busy:t,onDragStart:n,onDragEnd:r,onDrop:i,onStep:a}){let o=e.index!==null&&!t,s=fU(e);return(0,h.jsxs)(`article`,{tabIndex:e.index===null?void 0:0,"aria-label":`${s}, ${U2.format(new Date(e.at))}, ${e.scheduleName}${e.index===null?``:`. Alt+arrow keys move it.`}`,draggable:o,onDragStart:t=>{t.dataTransfer.effectAllowed=`move`,t.dataTransfer.setData(`text/plain`,s),n(e)},onDragEnd:r,onDragOver:e=>e.preventDefault(),onDrop:i,onKeyDown:t=>{o&&t.altKey&&(t.key===`ArrowLeft`||t.key===`ArrowUp`?(t.preventDefault(),a(e,-1)):(t.key===`ArrowRight`||t.key===`ArrowDown`)&&(t.preventDefault(),a(e,1)))},className:I(`sl-cal-item`,o&&`sl-cal-item--movable`),children:[(0,h.jsx)(`span`,{className:`text-label text-ink-3 tabular-nums`,children:U2.format(new Date(e.at))}),(0,h.jsx)(`b`,{className:I(`text-small`,e.topic===null&&`font-normal text-ink-2`),children:s}),(0,h.jsx)(`span`,{className:`text-label text-ink-3`,children:e.scheduleName}),e.paused?(0,h.jsx)(mS,{tone:`waiting`,children:`Paused`}):e.topicSource===`held`?(0,h.jsx)(mS,{tone:`info`,children:`Needs a topic`}):(0,h.jsx)(mS,{tone:`off`,children:`Queued`})]})}function G2({project:e}){let t=tU(e);return(0,h.jsx)(gU,{title:(0,h.jsx)(pa,{to:`/projects/$projectId`,params:{projectId:e.id},children:e.title}),actions:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(mS,{tone:t.tone,children:t.word}),t.action===void 0?null:t.action.kind===`upload`?(0,h.jsx)(P2,{projectId:e.id,ready:!0}):(0,h.jsx)(lS,{to:`/projects/$projectId`,params:{projectId:e.id},size:`small`,variant:`secondary`,children:t.action.label})]})})}function Wde({days:e,busy:t,schedules:n,onStep:r,onTransfer:i}){let a=[...e.values()].sort((e,t)=>e.key.localeCompare(t.key));if(a.length===0)return(0,h.jsxs)(`p`,{className:`m-0 text-ink-2`,children:[`Nothing is planned for the next `,B2,` weeks. Add topics with Add to calendar, or create a schedule on the`,` `,(0,h.jsx)(pa,{to:`/calendar`,search:{tab:`schedules`},children:`Schedules`}),` `,`tab.`]});let o=n.filter(e=>e.deletedAt===null&&(e.status===`active`||e.status===`paused`));return(0,h.jsxs)(`div`,{className:`flex flex-col gap-6`,...Tb,children:[(0,h.jsxs)(`p`,{className:`m-0 flex items-center gap-1 text-small text-ink-2`,children:[`Move a topic earlier, later or to another schedule from its row.`,(0,h.jsx)(B,{id:`planning.calendar.move`,className:`-my-1`})]}),a.map(e=>(0,h.jsxs)(`section`,{"aria-label":H2.format(e.date),children:[(0,h.jsx)(V,{title:H2.format(e.date),as:`h3`}),(0,h.jsxs)(hU,{label:`Planned on ${H2.format(e.date)}`,children:[e.runs.map(e=>{let n=fU(e),a=o.filter(t=>t.id!==e.scheduleId);return(0,h.jsx)(gU,{title:n,meta:`${U2.format(new Date(e.at))} · ${e.scheduleName}${e.templateName===null?``:` · ${e.templateName}`}${e.paused?` · Paused`:``}`,actions:e.index===null?void 0:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(Cy,{size:`small`,label:`Move ${n} earlier`,disabled:t,onClick:()=>r(e,-1),children:(0,h.jsx)(ec,{"aria-hidden":`true`,strokeWidth:1.75})}),(0,h.jsx)(Cy,{size:`small`,label:`Move ${n} later`,disabled:t,onClick:()=>r(e,1),children:(0,h.jsx)(Zs,{"aria-hidden":`true`,strokeWidth:1.75})}),a.length===0?null:(0,h.jsxs)(`select`,{"aria-label":`Move ${n} to another schedule`,className:`sl-select h-8 w-auto text-small`,value:``,disabled:t,onChange:t=>{t.target.value!==``&&i(e,t.target.value)},children:[(0,h.jsx)(`option`,{value:``,children:`Move to…`}),a.map(e=>(0,h.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]})},`${e.scheduleId}-${e.at}`)}),e.projects.map(e=>(0,h.jsx)(G2,{project:e},e.id))]})]},e.key))]})}var Gde=Aj.map(e=>({value:e,label:jj[e]}));function Kde({channel:e}){let{api:t}=R(),n=_(),r=Dy(),i=N({mutationFn:n=>ox(t,e.id,n),onSuccess:async e=>{r(`YouTube AI disclosure set to ${jj[e.aiDisclosure]}.`,`success`),n.setQueryData(Gb(e.id),t=>typeof t==`object`&&t&&`channel`in t?{...t,channel:{...t.channel,aiDisclosure:e.aiDisclosure}}:t),await n.invalidateQueries({queryKey:Wb,exact:!0})}});return(0,h.jsxs)(`section`,{"aria-label":`YouTube AI disclosure`,className:`mb-6 max-w-3xl border-b border-line pb-5`,children:[(0,h.jsx)(Y,{label:`YouTube AI disclosure`,tip:`planning.channel.ai-disclosure`,help:`Mark voices in Settings → Voices and Image prompts in Library → Prompts.`,children:(0,h.jsx)(AV,{value:i.isPending?i.variables:e.aiDisclosure,options:Gde,disabled:i.isPending,onChange:e=>{let t=Aj.find(t=>t===e.currentTarget.value);t!==void 0&&i.mutate(t)},className:`max-w-[260px]`})}),(0,h.jsx)(v0,{tone:`error`,children:i.error?`Couldn't save the YouTube AI disclosure: ${i.error.message}`:void 0})]})}function K2({value:e,onChange:t,inherited:n,label:r=`Language`,error:i,disabled:a=!1,tip:o=`play.language`}){let s=e??n?.language;return(0,h.jsx)(Y,{label:r,tip:o,help:qde(s),error:i,children:(0,h.jsxs)(AV,{"data-play-field":`language`,value:e??(n===void 0?`en`:``),disabled:a,onChange:e=>t(e.target.value===``?void 0:JO.parse(e.target.value)),children:[n===void 0?null:(0,h.jsxs)(`option`,{value:``,children:[n.label,` (`,YO(n.language).name,`)`]}),qO.map(e=>(0,h.jsx)(`option`,{value:e.code,children:e.native===e.name?e.name:`${e.native} · ${e.name}`},e.code))]})})}function qde(e){let t=YO(e);if(t.code===`en`)return`Everything is written and timed in English.`;let n=`The article, narration, YouTube description and Shorts titles are written in ${t.name}; pick a voice that speaks it.`,r=XO(t.code);return r===void 0?`${n} Captions are timed word by word with a free 248 MB model, downloaded the first time a ${t.name} project makes captions.`:`${n} ${r}`}function Jde({rows:e,onChange:t}){let n=(n,r)=>t(e.map((e,t)=>t===n?{...e,...r}:e));return(0,h.jsxs)(`section`,{"aria-label":`Channel links`,...Tb,children:[(0,h.jsx)(V,{title:`Channel links`,meta:`Write a link's name in braces in a description, such as {{Patreon}}.`,info:`planning.links.named`}),e.length===0?(0,h.jsx)(`p`,{className:`m-0 border-y border-line py-4 text-ink-2`,children:`No channel links yet. Add one, then write its name in braces in a description.`}):(0,h.jsx)(`ul`,{"aria-label":`Channel links`,className:`sl-list m-0 list-none p-0`,children:e.map((r,i)=>(0,h.jsxs)(`li`,{className:`grid grid-cols-[minmax(0,1fr)] items-center gap-2 border-b border-line py-3 md:grid-cols-[220px_minmax(0,1fr)_auto]`,children:[(0,h.jsx)(OV,{"aria-label":`Name of link ${String(i+1)}`,placeholder:`Patreon`,value:r.name,onChange:e=>n(i,{name:e.currentTarget.value})}),(0,h.jsx)(OV,{"aria-label":`Address of link ${String(i+1)}`,type:`url`,placeholder:`https://`,value:r.url,onChange:e=>n(i,{url:e.currentTarget.value})}),(0,h.jsxs)(L,{variant:`quiet`,size:`small`,className:`justify-self-start`,"aria-label":`Remove link ${String(i+1)}`,onClick:()=>t(e.filter((e,t)=>t!==i)),children:[(0,h.jsx)(Ic,{"aria-hidden":`true`,className:`size-[14px]`}),`Remove`]})]},i))}),(0,h.jsx)(`div`,{className:`mt-3`,children:(0,h.jsxs)(L,{onClick:()=>t([...e,{name:``,url:``}]),children:[(0,h.jsx)(kc,{"aria-hidden":`true`,className:`size-[14px]`}),`Add link`]})})]})}function Yde(){return(0,h.jsxs)(`div`,{...Tb,children:[(0,h.jsx)(V,{title:`Named links`,info:`planning.links.named`}),(0,h.jsx)(`p`,{className:`m-0 max-w-[60ch] text-ink-2`,children:`Each channel keeps its own links now, on its Brand tab under Channel links. Links saved here before fill the default channel's descriptions until you save its Brand tab.`}),(0,h.jsx)(`div`,{className:`mt-3`,children:(0,h.jsx)(lS,{to:`/channels/$channelId`,params:{channelId:Vb},children:`Open the default channel's links`})})]})}function q2({value:e,inherit:t,sources:n,offerNone:r,problem:i,file:a,fieldPrefix:o=`ambientBed`,onChange:s}){let c=e!==void 0&&e.source!==`none`,l={level:e?.level??String(lA.levelDb),fadeIn:e?.fadeIn??String(lA.fadeInSeconds),tail:e?.tail??String(lA.tailSeconds)},u=e=>{if(e===``)s(void 0);else if(e===`none`)s({source:`none`,...l});else{let t=n.find(t=>t===e);t!==void 0&&s({source:t,...l})}},d=(t,n,r,a)=>e===void 0||!c?null:(0,h.jsx)(Y,{label:n,help:r,tip:a,error:i(t),children:(0,h.jsx)(OV,{"data-play-field":`${o}.${t}`,type:`text`,inputMode:`decimal`,className:`w-[90px] tabular-nums`,value:e[t],onChange:n=>s({...e,[t]:n.target.value})})});return(0,h.jsxs)(`div`,{className:`grid min-w-0 grid-cols-1 gap-3`,children:[(0,h.jsx)(Y,{label:`Ambient sound`,tip:`project.ambient.source`,error:i(`source`),children:(0,h.jsxs)(AV,{"data-play-field":`${o}.source`,className:`w-auto min-w-[180px]`,value:e?.source??``,onChange:e=>u(e.target.value),children:[(0,h.jsx)(`option`,{value:``,children:t}),r?(0,h.jsx)(`option`,{value:`none`,children:`None`}):null,n.map(e=>(0,h.jsx)(`option`,{value:e,children:cA[e]},e))]})}),e?.source===`upload`?a:null,c?(0,h.jsxs)(`div`,{className:`flex min-w-0 flex-wrap gap-4`,children:[d(`level`,`Level (dB)`,`-40 to -6; 0 is about as loud as the voice.`,`project.ambient.level`),d(`fadeIn`,`Fade in (seconds)`,`0 to 30.`,`project.ambient.fade-in`),d(`tail`,`Tail after the narration (seconds)`,`0 to 30, fading out.`,`project.ambient.tail`)]}):null]})}function Xde({value:e,onChange:t}){let n=mA(e),r=n===void 0?[]:dA(n);return(0,h.jsx)(q2,{value:e,inherit:`Not set`,sources:oA,offerNone:!1,fieldPrefix:`brand.ambientBed`,problem:e=>r.find(t=>t.field===e)?.message,onChange:t})}function Zde(e){return e.ambientBed===void 0?void 0:pA(e.ambientBed)}function Qde(e){let t=mA(e);return t===void 0||t.source===`upload`?{brand:{},blocked:!1}:{brand:{ambientBed:{...t,source:t.source}},blocked:dA(t).length>0}}var J2=[`captionFontId`,`captionColor`,`captionOutlineColor`,`titleFontId`,`titleColor`,`intro`,`outro`,`endScreenText`,`documentTheme`,`language`];function $de(e){return Object.fromEntries(J2.map(t=>[t,e[t]??``]))}function efe({channel:e}){let{api:t}=R(),n=_(),r=Dy(),i=M({queryKey:pN,queryFn:()=>mN(t)}),a=M(eb(t)),o=M(tb(t)),[s,c]=(0,m.useState)(e.name),[l,u]=(0,m.useState)(e.seriesBrief),[d,f]=(0,m.useState)($de(e.brand)),[p,g]=(0,m.useState)(Zde(e.brand)),v=Qde(p),y=M({queryKey:z.channelLinks,queryFn:()=>bs(t),enabled:e.isDefault&&e.brand.links===void 0}),[b,x]=(0,m.useState)(),S=b??e.brand.links??y.data??[],C=b!==void 0||e.brand.links!==void 0||(y.data?.length??0)>0,w=N({mutationFn:()=>Zb(t,e.id,{name:s,seriesBrief:l,brand:{...Object.fromEntries(J2.flatMap(e=>d[e].trim()===``?[]:[[e,d[e].trim()]])),...v.brand,...C?{links:S}:{}},baseVersion:e.version}),onSuccess:async e=>{r(`Channel saved.`,`success`),n.setQueryData(Gb(e.id),t=>typeof t==`object`&&t?{...t,channel:e}:t),await Promise.all([n.invalidateQueries({queryKey:Wb}),n.invalidateQueries({queryKey:z.channelLinks})])}}),T=e=>t=>f({...d,[e]:t}),E=(i.data?.fonts??[]).map(e=>({value:e.id,label:e.name})),D=e=>(a.data?.entries??[]).filter(t=>t.category===e).map(e=>({value:e.name,label:e.name})),O=[...(o.data?.builtIns??[]).map(e=>({value:e.name,label:e.label})),...(o.data?.themes??[]).map(e=>({value:e.id,label:e.name}))];return(0,h.jsxs)(`form`,{"aria-label":`Brand kit`,onSubmit:e=>{e.preventDefault(),w.mutate()},children:[(0,h.jsxs)(`div`,{className:`grid max-w-3xl grid-cols-1 gap-5`,children:[(0,h.jsx)(Y,{label:`Channel name`,tip:`planning.channel.name`,children:(0,h.jsx)(OV,{value:s,maxLength:200,required:!0,onChange:e=>c(e.target.value)})}),(0,h.jsx)(Y,{label:`Series brief`,tip:`planning.channel.brief`,help:`Topic generation reads it for this channel's schedules.`,children:(0,h.jsx)(kV,{rows:4,value:l,maxLength:1e4,onChange:e=>u(e.target.value)})}),(0,h.jsx)(V,{title:`Brand kit`,meta:`Fills what a template leaves at its default. Blank fields add nothing.`,info:`planning.channel.brand-kit`,className:`mt-2 border-t border-line pt-6`}),(0,h.jsx)(`section`,{"aria-label":`Language`,className:`max-w-md`,children:(0,h.jsx)(K2,{label:`Language of new projects`,tip:`planning.channel.language`,value:d.language===``?void 0:d.language,inherited:{label:`Not set`,language:void 0},onChange:e=>T(`language`)(e??``)})}),(0,h.jsxs)(`section`,{"aria-label":`Captions`,className:`grid grid-cols-1 gap-4 min-[700px]:grid-cols-3`,children:[(0,h.jsx)(Y2,{label:`Caption font`,tip:`planning.channel.brand.caption-font`,value:d.captionFontId,options:E,onPick:T(`captionFontId`)}),(0,h.jsx)(X2,{label:`Caption colour`,tip:`planning.channel.brand.caption-colour`,value:d.captionColor,onChange:T(`captionColor`)}),(0,h.jsx)(X2,{label:`Caption outline`,tip:`planning.channel.brand.caption-outline`,value:d.captionOutlineColor,onChange:T(`captionOutlineColor`)})]}),(0,h.jsxs)(`section`,{"aria-label":`Chapter cards and end screen`,className:`grid grid-cols-1 gap-4 min-[700px]:grid-cols-3`,children:[(0,h.jsx)(Y2,{label:`Title font`,tip:`planning.channel.brand.font`,value:d.titleFontId,options:E,onPick:T(`titleFontId`)}),(0,h.jsx)(X2,{label:`Title colour`,tip:`planning.channel.brand.title-colour`,value:d.titleColor,onChange:T(`titleColor`)}),(0,h.jsx)(Y,{label:`End screen text`,tip:`planning.channel.brand.end-screen`,help:`Shown over the last 5 seconds.`,children:(0,h.jsx)(OV,{value:d.endScreenText,maxLength:200,placeholder:`Subscribe for more`,onChange:e=>T(`endScreenText`)(e.target.value)})})]}),(0,h.jsxs)(`section`,{"aria-label":`Intro, outro and document`,className:`grid grid-cols-1 gap-4 min-[700px]:grid-cols-3`,children:[(0,h.jsx)(Y2,{label:`Intro`,tip:`planning.channel.brand.intro`,value:d.intro,options:D(`intro`),onPick:T(`intro`)}),(0,h.jsx)(Y2,{label:`Outro`,tip:`planning.channel.brand.outro`,value:d.outro,options:D(`outro`),onPick:T(`outro`)}),(0,h.jsx)(Y2,{label:`Document theme`,tip:`planning.channel.brand.document-theme`,value:d.documentTheme,options:O,onPick:T(`documentTheme`)})]}),(0,h.jsx)(Xde,{value:p,onChange:g}),(0,h.jsx)(`div`,{className:`border-t border-line pt-6`,children:(0,h.jsx)(Jde,{rows:S,onChange:x})})]}),(0,h.jsx)(y0,{status:(0,h.jsx)(v0,{tone:w.error?`error`:`info`,children:w.error?.message??(w.isPending?`Saving…`:void 0)}),children:(0,h.jsx)(L,{type:`submit`,variant:`primary`,disabled:w.isPending||s.trim()===``||v.blocked,disabledReason:s.trim()===``?`Give the channel a name`:`Fix the ambient sound settings above`,children:`Save channel`})})]})}function Y2({label:e,tip:t,value:n,options:r,onPick:i}){return(0,h.jsx)(Y,{label:e,tip:t,children:(0,h.jsxs)(AV,{value:n,onChange:e=>i(e.target.value),children:[(0,h.jsx)(`option`,{value:``,children:`Not set`}),n!==``&&!r.some(e=>e.value===n)?(0,h.jsxs)(`option`,{value:n,children:[n,` (no longer in the library)`]}):null,r.map(e=>(0,h.jsx)(`option`,{value:e.value,children:e.label},e.value))]})})}function X2({label:e,tip:t,value:n,onChange:r}){let i=/^#[0-9a-fA-F]{6}$/.test(n);return(0,h.jsx)(Y,{label:e,tip:t,...n!==``&&!i?{error:`Write the colour as # and six hex digits.`}:{},children:(0,h.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,h.jsx)(`span`,{"aria-hidden":`true`,className:`size-6 shrink-0 rounded-control border border-line-strong`,style:{background:i?n:`transparent`}}),(0,h.jsx)(OV,{value:n,placeholder:`#FFFFFF`,maxLength:7,onChange:e=>r(e.target.value)})]})})}function Z2(e,t){return e.languages===void 0||e.languages.includes(YO(t).code)}function tfe(e,t,n,r){return n?e:e.filter(e=>Z2(e,t)||e.voiceId===r)}function nfe(e,t){if(e===void 0||Z2(e,t))return;let n=YO(t).name,r=(e.languages??[]).map(e=>YO(e).code===e?YO(e).name:e);return`${e.name} is listed for ${r.join(`, `)}, not ${n}, so it may read the ${n} narration with the wrong accent. Pick a ${n} voice under Narration, or correct the voice's languages in Settings → Voices.`}function Q2(e,t,n){let[r,i]=(0,m.useState)(!1),a=tfe(e,t,r,n);return{listed:a,hidden:e.length-a.length,showAll:r,setShowAll:i}}function $2({language:e,voice:t,hidden:n,showAll:r,onShowAll:i}){let a=(0,m.useId)(),o=nfe(t,e);return n===0&&!r&&o===void 0?null:(0,h.jsxs)(`div`,{className:`col-span-full grid gap-1`,children:[n>0||r?(0,h.jsxs)(`span`,{className:`flex min-h-8 items-center gap-1`,...Tb,children:[(0,h.jsxs)(`label`,{htmlFor:a,className:`flex items-center gap-2 text-small`,children:[(0,h.jsx)(`input`,{id:a,type:`checkbox`,checked:r,onChange:e=>i(e.target.checked)}),`Show all voices`,r?``:` (${String(n)} listed for other languages than ${YO(e).name})`]}),(0,h.jsx)(B,{id:`play.show-all-voices`})]}):null,o===void 0?null:(0,h.jsx)(`p`,{role:`status`,className:`m-0 text-small text-ink-2`,children:o})]})}function rfe({channelId:e,member:t,open:n,onClose:r,onCreated:i}){let{api:a}=R(),o=_(),[s,c]=(0,m.useState)(t?.kind??`character`),[l,u]=(0,m.useState)(t?.name??``),[d,f]=(0,m.useState)(t?.aliases??[]),[p,g]=(0,m.useState)(``),[v,y]=(0,m.useState)(t?.description??``),[b,x]=(0,m.useState)(t?.voice),[S,C]=(0,m.useState)(t?.host===!0),w=()=>Promise.all([o.invalidateQueries({queryKey:Gb(e)}),o.invalidateQueries({queryKey:Wb})]),T=N({mutationFn:async()=>{let n={kind:s,name:l.trim(),aliases:d,description:v,voice:b!==void 0&&b.provider!==``&&b.model!==``&&b.voice!==``?b:null,host:S};return t===void 0?$b(a,e,crypto.randomUUID(),n):ex(a,t.id,{...n,baseVersion:t.version})},onSuccess:async e=>{await w(),t===void 0&&i(e.id)}}),E=()=>{let e=p.trim();e===``||d.some(t=>t.toLowerCase()===e.toLowerCase())||(f([...d,e]),g(``))};return n?(0,h.jsxs)(`section`,{"aria-label":t===void 0?`Add to cast`:`Edit ${t.name}`,children:[(0,h.jsx)(V,{kicker:t===void 0?`New cast member`:Ub[t.kind],title:t===void 0?`Add to cast`:t.name,meta:t===void 0?`Name it first, then give it reference pictures.`:`Used whenever a title or an image brief names it or one of its aliases.`,children:(0,h.jsx)(L,{variant:`quiet`,size:`small`,onClick:r,children:`Close`})}),t!==void 0&&!t.images.some(e=>e.state===`ready`)?(0,h.jsx)(`p`,{className:`m-0 mt-2 text-small text-waiting`,children:`No picture yet, so it is not sent with any image. Upload or generate one below.`}):null,(0,h.jsxs)(`form`,{id:`cast-member-form`,"aria-label":`Cast member`,className:`mt-4 flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),l.trim()!==``&&T.mutate()},children:[(0,h.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 min-[600px]:grid-cols-[160px_minmax(0,1fr)]`,children:[(0,h.jsx)(Y,{label:`Kind`,tip:`planning.cast.kind`,children:(0,h.jsx)(AV,{value:s,onChange:e=>c(Hb.find(t=>t===e.target.value)??`character`),options:Hb.map(e=>({value:e,label:Ub[e]}))})}),(0,h.jsx)(Y,{label:`Name`,tip:`planning.cast.name`,children:(0,h.jsx)(OV,{value:l,maxLength:200,required:!0,onChange:e=>u(e.target.value)})})]}),(0,h.jsx)(Y,{label:`Aliases`,tip:`planning.cast.aliases`,help:`Press Enter to add each one.`,children:(0,h.jsxs)(`div`,{className:`flex gap-2`,children:[(0,h.jsx)(OV,{value:p,maxLength:200,placeholder:`Another name, such as the Last Pharaoh`,onChange:e=>g(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),E())}}),(0,h.jsxs)(L,{onClick:E,disabled:p.trim()===``,children:[(0,h.jsx)(kc,{"aria-hidden":`true`,className:`size-4`,strokeWidth:1.75}),`Add alias`]})]})}),d.length>0?(0,h.jsx)(`ul`,{"aria-label":`Aliases added`,className:`m-0 flex list-none flex-wrap gap-2 p-0`,children:d.map(e=>(0,h.jsx)(`li`,{children:(0,h.jsx)(gS,{removeLabel:`Remove alias ${e}`,onRemove:()=>f(d.filter(t=>t!==e)),children:e})},e))}):null,(0,h.jsx)(Y,{label:`Description for the image model`,tip:`planning.cast.description`,children:(0,h.jsx)(kV,{rows:3,value:v,maxLength:2e3,placeholder:`What they look like, in a sentence.`,onChange:e=>y(e.target.value)})}),(0,h.jsx)(afe,{channelId:e,value:b,onChange:x}),(0,h.jsxs)(`div`,{className:`flex flex-col items-start gap-1`,children:[(0,h.jsx)(Eb,{label:`One of the channel's hosts`,tip:`planning.cast.host`,checked:S,onChange:C}),S&&(b===void 0||b.voice===``)?(0,h.jsx)(`p`,{className:`m-0 text-small text-waiting`,children:`A host joins new podcasts and interviews only with a voice. Pick one under Voice above.`}):null]}),(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,h.jsx)(v0,{tone:T.error?`error`:`info`,children:T.error?.message??(T.isPending?`Saving…`:T.isSuccess?`Saved.`:void 0)}),(0,h.jsx)(L,{type:`submit`,form:`cast-member-form`,variant:t===void 0?`primary`:`secondary`,disabled:T.isPending||l.trim()===``,children:t===void 0?`Add to cast`:`Save`})]})]}),t===void 0?null:(0,h.jsx)(ife,{channelId:e,member:t})]}):null}function ife({channelId:e,member:t}){let{api:n}=R(),r=_(),i=M(Zy(n)),a=(0,m.useRef)(null),o=(0,m.useRef)(null),[s,c]=(0,m.useState)(``),[l,u]=(0,m.useState)(``),[d,f]=(0,m.useState)(`${t.name}${t.description.trim()?`, ${t.description.trim()}`:``}. A clear reference picture on a plain background, the whole ${t.kind===`place`?`place`:t.kind===`object`?`object`:`figure`} in view.`),p=()=>Promise.all([r.invalidateQueries({queryKey:Gb(e)}),r.invalidateQueries({queryKey:Wb})]),g=N({mutationFn:e=>nx(n,t.id,e),onSettled:p}),v=N({mutationFn:()=>rx(n,t.id,{prompt:d,provider:s,model:l}),onSettled:p}),y=N({mutationFn:e=>ix(n,t.id,e),onSettled:p}),b=g.error??v.error??y.error,x=t.images.flatMap((e,t)=>e.state===`ready`&&e.sha256!==null?[{id:e.id,number:t+1,src:sx(n,e.sha256)}]:[]),[S,C]=(0,m.useState)(null);return(0,h.jsxs)(`section`,{"aria-label":`Reference pictures`,className:`mt-6`,children:[(0,h.jsx)(Nq,{className:`mb-6`}),(0,h.jsx)(V,{as:`h3`,title:`Reference pictures`,meta:`Sent with every image whose brief, or the video's title, names ${t.name}.`,info:`planning.cast.pictures`}),t.images.length>0?(0,h.jsx)(o2,{list:!0,density:`compact`,label:`Pictures of ${t.name}`,className:`mt-3`,children:t.images.map((e,r)=>(0,h.jsxs)(`li`,{className:`min-w-0`,children:[(0,h.jsx)(a2,{aspect:`square`,alt:`${t.name}, reference ${String(r+1)}`,...e.state===`ready`&&e.sha256!==null?{src:sx(n,e.sha256)}:{},...e.state===`generating`?{generating:`Making the picture…`}:{},onOpen:()=>C(x.findIndex(t=>t.id===e.id)),openLabel:`Open picture ${String(r+1)} of ${t.name} full size`,...e.state===`failed`?{badge:(0,h.jsx)(hS,{tone:`failed`,children:`Failed`})}:{},actionsShown:!0,actions:(0,h.jsx)(L,{variant:`secondary`,size:`small`,"aria-label":`Delete picture ${String(r+1)} of ${t.name}`,disabled:y.isPending||e.state===`generating`,disabledReason:`Wait until the picture is made`,onClick:()=>y.mutate(e.id),children:`Delete`})}),e.state===`failed`&&e.error?(0,h.jsx)(ofe,{error:e.error,retry:s===``||l===``||d.trim()===``?void 0:{run:()=>v.mutate(),busy:v.isPending},onReword:()=>o.current?.focus()}):null]},e.id))}):(0,h.jsx)(`p`,{className:`m-0 mt-3 text-small text-ink-3`,children:`No pictures yet.`}),(0,h.jsx)(s2,{items:x.map(e=>({src:e.src,alt:`${t.name}, reference ${String(e.number)}`})),index:S,onIndex:C,onClose:()=>C(null),actions:(e,n)=>{let r=x[n];return r===void 0?null:(0,h.jsx)(dS,{href:r.src,download:!0,size:`small`,"aria-label":`Download picture ${String(r.number)} of ${t.name}`,children:`Download`})}}),(0,h.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center gap-3`,children:[(0,h.jsx)(`input`,{ref:a,type:`file`,accept:`image/png,image/jpeg`,className:`sr-only`,tabIndex:-1,"aria-hidden":`true`,onChange:e=>{let t=e.target.files?.[0];e.target.value=``,t&&g.mutate(t)}}),(0,h.jsx)(L,{disabled:g.isPending,onClick:()=>a.current?.click(),children:`Upload a picture`}),(0,h.jsx)(`span`,{className:`text-small text-ink-3`,children:`PNG or JPEG, up to 10 MB.`})]}),(0,h.jsxs)(`div`,{className:`mt-4 flex flex-col gap-4`,children:[(0,h.jsxs)(`div`,{className:`flex flex-col gap-2`,...Tb,children:[(0,h.jsxs)(`p`,{className:`sl-kicker m-0 flex items-center gap-1`,children:[`Make a picture`,(0,h.jsx)(B,{id:`planning.cast.generate`,className:`-my-1`})]}),(0,h.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 min-[600px]:grid-cols-2`,children:[(0,h.jsx)(HV,{label:`Image provider`,family:`image`,providers:i.data?.providers??[],value:s,problem:void 0,onPick:e=>{c(e),u(``)}}),(0,h.jsx)(UV,{label:`Image model`,provider:s,value:l,problem:void 0,onPick:u})]})]}),(0,h.jsx)(Y,{label:`Picture to make`,tip:`planning.cast.picture-prompt`,children:(0,h.jsx)(kV,{ref:o,rows:3,value:d,maxLength:4e3,onChange:e=>f(e.target.value)})}),(0,h.jsx)(`div`,{children:(0,h.jsx)(L,{disabled:v.isPending||s===``||l===``||d.trim()===``,disabledReason:`Pick an image provider and model, and describe the picture`,onClick:()=>v.mutate(),children:`Generate a picture`})})]}),(0,h.jsx)(v0,{tone:b?`error`:`info`,className:`mt-2`,children:b?.message??(g.isPending?`Uploading…`:v.isSuccess?`The picture is being made; it appears here when it is ready.`:void 0)})]})}function afe({channelId:e,value:t,onChange:n}){let{api:r}=R(),i=M(Zy(r)),a=M(Qy(r)),o=M(Yb(r,e)).data?.channel.brand.language??`en`,s=t??{provider:``,model:``,voice:``},c=(a.data?.voices??[]).filter(e=>e.provider===s.provider),l=Q2(c,o,s.voice||void 0),u=l.listed;return(0,h.jsxs)(`fieldset`,{className:`m-0 flex flex-col gap-3 border-0 border-t border-line p-0 pt-4`,...Tb,children:[(0,h.jsxs)(`legend`,{className:`sl-kicker flex items-center gap-1`,children:[`Voice`,(0,h.jsx)(B,{id:`planning.cast.voice`,label:`Cast voice`,className:`-my-1`})]}),(0,h.jsx)(`p`,{className:`text-small text-ink-2`,children:`For multi-voice runs: pick this member under Speakers on Play.`}),(0,h.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 min-[600px]:grid-cols-2`,children:[(0,h.jsx)(HV,{label:`Voice provider`,family:`tts`,providers:i.data?.providers??[],value:s.provider,problem:void 0,onPick:e=>n(e===``?void 0:{provider:e,model:``,voice:``})}),(0,h.jsx)(UV,{label:`Voice model`,provider:s.provider,value:s.model,problem:void 0,onPick:e=>n({...s,model:e})}),(0,h.jsx)(zV,{label:`Voice`,value:s.voice,placeholder:u.length===0?`No voices. Add one in Settings.`:`Pick a voice`,options:u.map(e=>({value:e.voiceId,label:e.name})),problem:void 0,onPick:e=>n({...s,voice:e})}),(0,h.jsx)($2,{language:o,voice:c.find(e=>e.voiceId===s.voice),hidden:l.hidden,showAll:l.showAll,onShowAll:l.setShowAll}),(0,h.jsx)(zV,{label:`Pace`,value:String(s.pace??1),placeholder:`Pick a pace`,options:zA.map(e=>({value:String(e),label:e===1?`Normal`:`${String(e)}×`})),problem:void 0,onPick:e=>{let{pace:t,...r}=s;n(Number(e)===1?r:{...r,pace:Number(e)})}})]}),t===void 0?null:(0,h.jsx)(L,{variant:`quiet`,onClick:()=>n(void 0),children:`Remove the voice`})]})}function ofe({error:e,retry:t,onReword:n}){let r=s0({stage:`images`,reason:e});return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`p`,{className:`m-0 mt-1 text-small text-danger`,children:e}),r===void 0?null:(0,h.jsx)(Ty,{className:`mt-2`,children:(0,h.jsx)(h0,{fix:r,retry:t,variant:`secondary`,size:`small`,edit:r.kind===`refused`?(0,h.jsx)(L,{variant:`secondary`,size:`small`,onClick:n,children:`Reword the picture`}):void 0})})]})}function sfe({channelId:e,cast:t,selected:n,onSelect:r}){let{api:i}=R(),a=_(),[o,s]=(0,m.useState)(null),c=n===void 0?o:n,l=r??s,[u,d]=(0,m.useState)(null),f=N({mutationFn:e=>tx(i,e),onSuccess:async(t,n)=>{d(null),c===n&&l(null),await Promise.all([a.invalidateQueries({queryKey:Gb(e)}),a.invalidateQueries({queryKey:Wb})])}}),p=t.find(e=>e.id===c),g=t.flatMap(e=>{let t=e.images.find(e=>e.state===`ready`)?.sha256;return t?[{member:e,src:sx(i,t)}]:[]}),v=g.map(e=>({src:e.src,alt:e.member.name,caption:`${Ub[e.member.kind]} · ${e.member.description||`No description yet`}`})),[y,b]=(0,m.useState)(null),x=c===`new`||p!==void 0;return(0,h.jsxs)(`div`,{className:`grid grid-cols-1 items-start gap-8 min-[1024px]:grid-cols-[minmax(0,1fr)_440px]`,children:[(0,h.jsxs)(`div`,{className:`min-w-0`,children:[(0,h.jsx)(`p`,{className:`m-0 mb-4 max-w-[68ch] text-small text-ink-2`,children:`When a video's title or an image's brief names a member, its pictures go with that image as references, so it looks the same in every video.`}),t.length===0?(0,h.jsx)(T0,{title:`No cast yet`,actions:(0,h.jsx)(L,{variant:`secondary`,onClick:()=>l(`new`),children:`Add to cast`}),children:`Add the characters, creatures, places and objects this channel keeps coming back to.`}):(0,h.jsx)(o2,{label:`Cast`,children:t.map(e=>{let t=e.images.filter(e=>e.state===`ready`),n=t[0]?.sha256;return(0,h.jsx)(a2,{className:I(e.id===c&&`rounded-media outline-2 outline-accent outline-offset-4 outline-solid`),...n?{src:sx(i,n)}:{},alt:e.name,onOpen:()=>b(g.findIndex(t=>t.member.id===e.id)),openLabel:`Open ${e.name}'s picture full size`,title:e.name,meta:`${Ub[e.kind]}${e.host===!0?` · Host`:``} · ${String(t.length)} ${t.length===1?`picture`:`pictures`}`,...t.length===0?{badge:(0,h.jsx)(hS,{tone:`waiting`,children:`No picture`})}:{},actionsShown:!0,actions:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(L,{variant:`secondary`,size:`small`,"aria-label":`Edit ${e.name}`,"aria-pressed":e.id===c,onClick:()=>l(e.id),children:`Edit`}),(0,h.jsx)(L,{variant:`secondary`,size:`small`,"aria-label":`Delete ${e.name}`,onClick:()=>{f.reset(),d(e)},children:`Delete`})]})},e.id)})}),(0,h.jsx)(s2,{items:v,index:y,onIndex:b,onClose:()=>b(null),actions:(e,t)=>{let n=g[t];return n===void 0?null:(0,h.jsx)(L,{size:`small`,onClick:()=>{b(null),l(n.member.id)},children:`Edit ${n.member.name}`})}}),(0,h.jsx)(v0,{tone:`error`,className:`mt-2`,children:u?void 0:f.error?.message})]}),(0,h.jsx)(`aside`,{"aria-label":`Cast member editor`,className:`min-w-0`,children:x?(0,h.jsx)(rfe,{channelId:e,member:p,open:!0,onClose:()=>l(null),onCreated:e=>l(e)},c??`closed`):t.length===0?null:(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:`Pick a member's Edit to change its names, description and pictures here.`})}),(0,h.jsx)(Ay,{open:u!==null,title:`Delete ${u?.name??`this cast member`}?`,consequence:f.error?.message??`New videos stop using its pictures. Videos already made keep the pictures they were started with.`,confirmLabel:`Delete from cast`,cancelLabel:`Keep it`,pending:f.isPending,onConfirm:()=>{u&&f.mutate(u.id)},onCancel:()=>d(null)})]})}var e4=e=>[`channels`,e,`episodes`],t4=e=>[`channels`,e,`videos`],n4=(e,t)=>`${e.origin}/api/channels/${t}`,r4=(e,t)=>({method:e,headers:{"content-type":`application/json`},body:JSON.stringify(t)});function cfe(e,t){return lt({queryKey:e4(t),queryFn:async()=>P(await e.fetch(`${n4(e,t)}/episodes`))})}async function lfe(e,t,n){return P(await e.fetch(`${n4(e,t)}/episodes/setting`,r4(`PUT`,{enabled:n})))}async function ufe(e,t,n,r){return P(await e.fetch(`${n4(e,t)}/episodes/${encodeURIComponent(n)}`,r4(`PUT`,{summary:r})))}async function dfe(e,t,n){let r=await e.fetch(`${n4(e,t)}/episodes/${encodeURIComponent(n)}`,{method:`DELETE`});r.ok||await P(r)}function i4(e,t){return lt({queryKey:t4(t),queryFn:async()=>(await P(await e.fetch(`${n4(e,t)}/videos`))).videos})}async function ffe(e,t,n){return P(await e.fetch(`${n4(e,t)}/videos`,r4(`POST`,n)))}async function pfe(e,t,n){return P(await e.fetch(`${n4(e,t)}/videos/preview`,r4(`POST`,{format:`csv`,text:n})))}async function mfe(e,t,n){let r=await e.fetch(`${n4(e,t)}/videos/${n}`,{method:`DELETE`});r.ok||await P(r)}async function hfe(e,t){await P(await e.fetch(`${n4(e,t)}/videos`,{method:`DELETE`}))}var gfe=e=>e.length>160?`${e.slice(0,160)}…`:e;function _fe({channelId:e}){let{api:t}=R(),n=_(),r=M(cfe(t,e)),[i,a]=(0,m.useState)(null),[o,s]=(0,m.useState)(null),c=()=>n.invalidateQueries({queryKey:e4(e)}),l=N({mutationFn:n=>lfe(t,e,n),onSuccess:t=>n.setQueryData(e4(e),t)}),u=N({mutationFn:n=>dfe(t,e,n),onSuccess:async()=>{s(null),await c()}}),d=r.data?.enabled??!1,f=r.data?.memories??[];return(0,h.jsxs)(`div`,{children:[(0,h.jsx)(Eb,{checked:d,disabled:r.data===void 0||l.isPending,onChange:e=>l.mutate(e),label:`Episode memory`,tip:`planning.channel.episode-memory`,describedBy:`${e}-memory-help`}),(0,h.jsx)(`p`,{id:`${e}-memory-help`,className:`mt-1 mb-3 text-small text-ink-2`,children:`Finished episodes leave a short summary that new related episodes are written with.`}),(0,h.jsx)(v0,{tone:r.error||l.error||u.error?`error`:`info`,children:r.error?.message??l.error?.message??(o?void 0:u.error?.message)??(r.isPending?`Loading the episodes…`:void 0)}),r.data&&f.length===0?(0,h.jsx)(T0,{title:`No episodes remembered yet`,children:d?`When a video on this channel finishes, its summary appears here.`:`Turn on episode memory, and the next finished video's summary appears here.`}):null,f.length>0?(0,h.jsx)(hU,{label:`Episode summaries`,children:f.map(e=>(0,h.jsx)(gU,{title:e.title,meta:(0,h.jsxs)(h.Fragment,{children:[e.source===`edited`?`Edited · `:``,e.cast.length>0?`${e.cast.join(`, `)} · `:``,gfe(e.summary)]}),actions:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(L,{size:`small`,"aria-label":`Open the summary of ${e.title}`,onClick:()=>a(e),children:`Open`}),(0,h.jsx)(L,{size:`small`,variant:`quiet`,"aria-label":`Delete the summary of ${e.title}`,onClick:()=>{u.reset(),s(e)},children:`Delete`})]})},e.id))}):null,i?(0,h.jsx)(vfe,{channelId:e,memory:i,onClose:()=>a(null)},i.id):null,(0,h.jsx)(Ay,{open:o!==null,title:`Delete the summary of ${o?.title??`this episode`}?`,consequence:u.error?.message??`New episodes stop being reminded of it. The video itself is not changed.`,confirmLabel:`Delete summary`,pending:u.isPending,onConfirm:()=>{o&&u.mutate(o.id)},onCancel:()=>s(null)})]})}function vfe({channelId:e,memory:t,onClose:n}){let{api:r}=R(),i=_(),[a,o]=(0,m.useState)(t.summary),s=N({mutationFn:()=>ufe(r,e,t.id,a),onSuccess:async()=>{await i.invalidateQueries({queryKey:e4(e)}),n()}}),c=a.trim()!==t.summary.trim();return(0,h.jsx)(ky,{open:!0,onOpenChange:e=>{e||n()},title:t.title,description:t.source===`edited`?`You edited this summary; finishing the video again keeps your text.`:`Written by the text model when the video finished. An edit here is kept.`,footer:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(L,{onClick:n,children:`Close`}),(0,h.jsx)(L,{variant:`primary`,disabled:!c||s.isPending,onClick:()=>s.mutate(),children:`Save summary`})]}),children:(0,h.jsx)(Y,{label:`Summary`,error:s.error?.message,tip:`planning.channel.episode-summary`,children:(0,h.jsx)(kV,{rows:8,value:a,onChange:e=>o(e.target.value)})})})}var a4=(e,t,n)=>`${e.toLocaleString(`en`)} ${e===1?t:n}`;function o4(e,t){let n=t.trim().toLowerCase();return e.map(e=>n===``||e.toLowerCase().includes(n))}function yfe({channelId:e}){let{api:t}=R(),n=_(),r=M(i4(t,e)),[i,a]=(0,m.useState)(``),[o,s]=(0,m.useState)(!1),[c,l]=(0,m.useState)(void 0),u=(0,m.useRef)(null),d=()=>n.invalidateQueries({queryKey:t4(e)}),[f,p]=(0,m.useState)(void 0),[g,v]=(0,m.useState)(``),y=N({mutationFn:n=>ffe(t,e,{format:`lines`,...n}),onSuccess:async(e,t)=>{t.filter===void 0?a(``):p(void 0),l(`Added ${a4(e.added,`title`,`titles`)}${e.skipped>0?`; skipped ${e.skipped.toLocaleString(`en`)} already listed`:``}.`),await d()}}),b=N({mutationFn:n=>pfe(t,e,n),onSuccess:e=>{v(e.filter),p({titles:e.titles,ticked:o4(e.titles,e.filter)})}}),x=N({mutationFn:n=>mfe(t,e,n),onSuccess:d}),S=N({mutationFn:()=>hfe(t,e),onSuccess:async()=>{s(!1),await d()}}),C=r.data??[],w=y.isPending||b.isPending||x.isPending||S.isPending,T=r.error??b.error??y.error??x.error;return(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`p`,{className:`mb-3 text-small text-ink-2`,children:`Topic suggestions and duplicate checks skip these titles, as they skip the videos made here.`}),(0,h.jsx)(Y,{label:`Paste titles`,tip:`planning.channel.videos-paste`,help:`One title per line.`,children:(0,h.jsx)(kV,{rows:5,value:i,onChange:e=>a(e.target.value)})}),(0,h.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2`,children:[(0,h.jsx)(L,{variant:`primary`,disabled:w||i.trim()===``,onClick:()=>{l(void 0),y.mutate({text:i})},children:`Add titles`}),(0,h.jsx)(L,{disabled:w,onClick:()=>{u.current?.click()},children:`Import a YouTube Studio CSV…`}),(0,h.jsx)(B,{id:`planning.channel.videos-csv`}),(0,h.jsx)(`input`,{ref:u,type:`file`,accept:`.csv,text/csv`,className:`hidden`,"aria-label":`YouTube Studio CSV file`,onChange:async e=>{let t=e.target.files?.[0];e.target.value=``,t!==void 0&&(l(void 0),y.reset(),b.mutate(await t.text()))}}),(0,h.jsx)(L,{variant:`quiet`,disabled:w||C.length===0,onClick:()=>{S.reset(),s(!0)},children:`Remove all`})]}),(0,h.jsx)(v0,{tone:T?`error`:c?`success`:`info`,className:`mt-1`,children:T?.message??c??(r.isPending?`Loading the titles…`:b.isPending?`Reading the CSV…`:void 0)}),f===void 0?null:(0,h.jsx)(bfe,{preview:f,filter:g,busy:w,onFilter:e=>{v(e),p({...f,ticked:o4(f.titles,e)})},onTick:e=>p({...f,ticked:e}),onSave:()=>{l(void 0);let e=f.titles.filter((e,t)=>f.ticked[t]);y.mutate({text:e.join(`
272
- `),filter:g})},onCancel:()=>{y.reset(),p(void 0)}}),r.data&&C.length===0?(0,h.jsx)(T0,{title:`No existing videos listed`,children:`In YouTube Studio open Analytics → Content → Advanced mode, export the table as a CSV, and import it here; or paste the titles above.`}):null,C.length>0?(0,h.jsx)(hU,{label:`Existing videos`,children:C.map(e=>(0,h.jsx)(gU,{title:e.title,actions:(0,h.jsx)(L,{size:`small`,variant:`quiet`,disabled:w,"aria-label":`Remove ${e.title}`,onClick:()=>x.mutate(e.id),children:`Remove`})},e.id))}):null,(0,h.jsx)(Ay,{open:o,title:`Remove all ${a4(C.length,`title`,`titles`)}?`,consequence:S.error?.message??`Topic suggestions and duplicate checks stop skipping them. Your videos on YouTube are not touched.`,confirmLabel:`Remove all`,pending:S.isPending,onConfirm:()=>S.mutate(),onCancel:()=>s(!1)})]})}function bfe({preview:e,filter:t,busy:n,onFilter:r,onTick:i,onSave:a,onCancel:o}){let s=(0,m.useId)(),c=e.ticked.filter(Boolean).length;return(0,h.jsxs)(`section`,{"aria-label":`Titles in the CSV`,className:`mt-4`,...Tb,children:[(0,h.jsxs)(V,{as:`h3`,title:`Titles in the CSV`,info:`planning.channel.videos-ticks`,meta:`${c.toLocaleString(`en`)} of ${a4(e.titles.length,`title`,`titles`)} ticked`,children:[(0,h.jsxs)(L,{variant:`primary`,disabled:n||c===0,onClick:a,children:[`Add `,a4(c,`ticked title`,`ticked titles`)]}),(0,h.jsx)(L,{variant:`quiet`,disabled:n,onClick:o,children:`Cancel`})]}),(0,h.jsx)(Y,{label:`Keep only titles containing…`,tip:`planning.channel.videos-filter`,tipLabel:`Keep only titles containing`,children:(0,h.jsx)(OV,{value:t,maxLength:200,onChange:e=>r(e.target.value)})}),(0,h.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2`,children:[(0,h.jsx)(L,{size:`small`,disabled:n,onClick:()=>i(e.titles.map(()=>!0)),children:`Tick all`}),(0,h.jsx)(L,{size:`small`,disabled:n,onClick:()=>i(e.titles.map(()=>!1)),children:`Untick all`})]}),(0,h.jsx)(hU,{label:`Titles in the CSV`,className:`mt-2`,children:e.titles.map((t,r)=>(0,h.jsx)(gU,{lead:(0,h.jsx)(`input`,{id:`${s}-${r}`,type:`checkbox`,checked:e.ticked[r]===!0,disabled:n,className:`size-4 shrink-0 accent-accent`,onChange:t=>i(e.ticked.map((e,n)=>n===r?t.target.checked:e))}),title:(0,h.jsx)(`label`,{htmlFor:`${s}-${r}`,children:t})},r))})]})}var s4=[`brand`,`cast`,`templates`,`schedules`,`episodes`,`videos`],xfe={brand:`Brand`,cast:`Cast`,templates:`Templates`,schedules:`Schedules`,episodes:`Episodes`,videos:`Existing videos`};function Sfe(e){return s4.find(t=>t===e)??`brand`}function Cfe({channelId:e,tab:t,onTab:n}){let{api:r}=R(),i=_(),a=Xi(),o=M(Yb(r,e)),[s,c]=(0,m.useState)(!1),[l,u]=(0,m.useState)(null),d=N({mutationFn:()=>Qb(r,e),onSuccess:async()=>{c(!1),await i.invalidateQueries({queryKey:Wb}),await a({to:`/channels`})}}),f=o.data?.channel,p=o.data?.cast??[],g=()=>{n(`cast`),u(`new`)};return _x({id:`channel.add-to-cast`,title:`Add to cast`,group:`Channel`,...f===void 0?{}:{context:f.name},keywords:[`character`,`creature`,`place`,`object`],run:g}),(0,h.jsxs)(`div`,{children:[(0,h.jsx)(Aq,{crumb:(0,h.jsx)(pa,{to:`/channels`,children:`Channels`}),title:f?.name??`Channel`,meta:f?.isDefault?`Default channel`:void 0,actions:(0,h.jsxs)(h.Fragment,{children:[t===`cast`&&f?(0,h.jsxs)(L,{variant:`primary`,onClick:g,children:[(0,h.jsx)(kc,{"aria-hidden":`true`,className:`size-4`,strokeWidth:1.75}),`Add to cast`]}):null,f&&!f.isDefault?(0,h.jsx)(L,{variant:`quiet`,onClick:()=>{d.reset(),c(!0)},children:`Delete channel`}):null]})}),(0,h.jsx)(C0,{items:s4.map(e=>({id:e,label:xfe[e],...e===`cast`?{badge:String(p.length)}:{}})),value:t,onChange:n,label:`Channel sections`,idPrefix:`channel`,className:`mb-6`}),(0,h.jsx)(v0,{tone:o.error?`error`:`info`,className:`mb-2`,children:o.error?`The channel couldn't be loaded: ${o.error.message} Go back to Channels and open it again.`:o.isPending?`Loading the channel…`:void 0}),f?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(w0,{idPrefix:`channel`,id:`brand`,active:t===`brand`,children:[(0,h.jsx)(Kde,{channel:f}),(0,h.jsx)(efe,{channel:f},`${f.id}:${String(f.version)}`)]}),(0,h.jsx)(w0,{idPrefix:`channel`,id:`cast`,active:t===`cast`,children:(0,h.jsx)(sfe,{channelId:f.id,cast:p,selected:l,onSelect:u})}),(0,h.jsx)(w0,{idPrefix:`channel`,id:`templates`,active:t===`templates`,children:t===`templates`?(0,h.jsx)(Oue,{channelId:f.id}):null}),(0,h.jsx)(w0,{idPrefix:`channel`,id:`schedules`,active:t===`schedules`,children:t===`schedules`?(0,h.jsx)(jue,{channelId:f.id}):null}),(0,h.jsx)(w0,{idPrefix:`channel`,id:`episodes`,active:t===`episodes`,children:t===`episodes`?(0,h.jsx)(_fe,{channelId:f.id}):null}),(0,h.jsx)(w0,{idPrefix:`channel`,id:`videos`,active:t===`videos`,children:t===`videos`?(0,h.jsx)(yfe,{channelId:f.id}):null})]}):null,(0,h.jsx)(Ay,{open:s,title:`Delete ${f?.name??`this channel`}?`,consequence:d.error?.message??`Its cast goes with it. Its videos move to the default channel and keep what they were made with.`,confirmLabel:`Delete channel`,cancelLabel:`Keep it`,pending:d.isPending,onConfirm:()=>d.mutate(),onCancel:()=>c(!1)})]})}function c4({className:e,children:t}){return(0,h.jsx)(`dl`,{className:I(`sl-stats m-0`,e),children:t})}function l4({value:e,label:t,children:n}){return(0,h.jsxs)(`div`,{className:`sl-stat`,children:[(0,h.jsx)(`dt`,{className:`sl-stat__label order-2`,children:t}),(0,h.jsx)(`dd`,{className:`sl-stat__value order-1 m-0`,children:e}),n===void 0?null:(0,h.jsx)(`dd`,{className:`order-3 m-0 mt-1`,children:n})]})}function u4({value:e,label:t,valueText:n,tone:r=`accent`,className:i}){let a=Math.round(Math.min(1,Math.max(0,Number.isFinite(e)?e:0))*100);return(0,h.jsx)(`div`,{role:`meter`,"aria-label":t,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":a,"aria-valuetext":n??`${String(a)}%`,className:I(`sl-meter`,r===`waiting`&&`sl-meter--waiting`,i),children:(0,h.jsx)(`span`,{style:{width:`${String(a)}%`}})})}function d4({columns:e,rows:t,rowKey:n,caption:r,empty:i,className:a}){return(0,h.jsxs)(`table`,{className:I(`sl-table`,a),children:[(0,h.jsx)(`caption`,{className:`sr-only`,children:r}),(0,h.jsx)(`thead`,{children:(0,h.jsx)(`tr`,{children:e.map(e=>(0,h.jsx)(`th`,{scope:`col`,className:e.numeric?`num`:void 0,children:e.header},e.id))})}),(0,h.jsx)(`tbody`,{children:t.length===0&&i!==void 0?(0,h.jsx)(`tr`,{children:(0,h.jsx)(`td`,{colSpan:e.length,className:`text-ink-2`,children:i})}):t.map(t=>(0,h.jsx)(`tr`,{children:e.map(e=>(0,h.jsx)(`td`,{className:e.numeric?`num`:void 0,children:e.cell(t)},e.id))},n(t)))})]})}function wfe(){let{api:e}=R(),t=_(),n=Xi(),r=M(Jb(e)),[i,a]=(0,m.useState)(null),[o,s]=(0,m.useState)(null),[c,l]=(0,m.useState)(``),[u,d]=(0,m.useState)(null),f=r.data?.find(e=>e.id===u)??r.data?.[0],p=N({mutationFn:()=>Xb(e,crypto.randomUUID(),c.trim()),onSuccess:async e=>{await t.invalidateQueries({queryKey:Wb}),a(null),l(``),await n({to:`/channels/$channelId`,params:{channelId:e.id}})}}),g=N({mutationFn:t=>Zb(e,t.id,{name:c.trim(),brand:t.brand,seriesBrief:t.seriesBrief,baseVersion:t.version}),onSuccess:async()=>{await t.invalidateQueries({queryKey:Wb}),a(null)}}),v=N({mutationFn:t=>Qb(e,t.id),onSuccess:async()=>{s(null),await t.invalidateQueries({queryKey:Wb})}}),y=()=>{p.reset(),l(``),a(`new`)};_x({id:`channels.new`,title:`New channel`,group:`Channels`,run:y});let b=i===`new`?p:g,x=()=>{c.trim()!==``&&i!==null&&(i===`new`?p.mutate():g.mutate(i))};return(0,h.jsxs)(`div`,{"data-tour":`channels`,children:[(0,h.jsx)(Aq,{title:`Channels`,meta:(0,h.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[`A channel keeps its brand kit, cast, series brief, templates and schedules together.`,(0,h.jsx)(B,{id:`planning.channels`})]}),actions:(0,h.jsxs)(L,{variant:`primary`,"aria-expanded":i===`new`,onClick:y,children:[(0,h.jsx)(kc,{"aria-hidden":`true`,className:`size-4`,strokeWidth:1.75}),`New channel`]})}),(0,h.jsx)(v0,{tone:r.error||v.error?`error`:`info`,className:`mb-2`,children:r.error?`The channels couldn't be loaded: ${r.error.message} Reload the page to try again.`:o===null&&v.error?v.error.message:r.isPending?`Loading channels…`:void 0}),r.data?.length===0?(0,h.jsx)(T0,{title:`No channels yet`,actions:(0,h.jsx)(L,{variant:`primary`,onClick:y,children:`New channel`}),children:`Make one for each series you run; it keeps that series' look and cast.`}):null,r.data?.length?(0,h.jsx)(Mq,{list:(0,h.jsx)(hU,{label:`Channels`,className:`[&_.sl-row__actions]:flex-wrap`,children:r.data.map(e=>(0,h.jsx)(gU,{selected:e.id===f?.id,onSelect:()=>d(e.id),title:e.name,meta:`${e.isDefault?`Default · `:``}${String(e.templates)} ${e.templates===1?`template`:`templates`} · ${String(e.cast)} in the cast`,actions:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(uS,{to:`/channels/$channelId`,params:{channelId:e.id},"aria-label":`Open ${e.name}`,className:`px-2 text-small`,children:`Open`}),(0,h.jsx)(L,{variant:`quiet`,size:`small`,"aria-label":`Rename ${e.name}`,onClick:()=>{g.reset(),l(e.name),a(e)},children:`Rename`}),e.isDefault?null:(0,h.jsx)(L,{variant:`quiet`,size:`small`,"aria-label":`Delete ${e.name}`,onClick:()=>{v.reset(),s(e)},children:`Delete`})]})},e.id))}),detail:f===void 0?null:(0,h.jsx)(Tfe,{channel:f})}):null,(0,h.jsx)(ky,{open:i!==null,onOpenChange:e=>{!e&&!b.isPending&&a(null)},title:i===`new`||i===null?`New channel`:`Rename ${i.name}`,footer:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(v0,{tone:b.error?`error`:`info`,children:b.error?.message??(b.isPending?`Saving…`:void 0)}),(0,h.jsx)(L,{disabled:b.isPending,onClick:()=>a(null),children:`Cancel`}),(0,h.jsx)(L,{type:`submit`,form:`channel-name-form`,variant:`primary`,disabled:b.isPending||c.trim()===``,children:i===`new`?`Create channel`:`Rename channel`})]}),children:(0,h.jsx)(`form`,{id:`channel-name-form`,"aria-label":i===`new`?`New channel`:`Rename channel`,onSubmit:e=>{e.preventDefault(),x()},children:(0,h.jsx)(Y,{label:`Channel name`,tip:`planning.channel.name`,children:(0,h.jsx)(OV,{value:c,maxLength:200,required:!0,disabled:b.isPending,onChange:e=>l(e.target.value)})})})}),(0,h.jsx)(Ay,{open:o!==null,title:`Delete ${o?.name??`this channel`}?`,consequence:v.error?.message??`Its cast goes with it. Its videos move to the default channel and keep what they were made with.`,confirmLabel:`Delete channel`,cancelLabel:`Keep it`,pending:v.isPending,onConfirm:()=>{o&&v.mutate(o)},onCancel:()=>s(null)})]})}function Tfe({channel:e}){let t=e.brand,n=[[`Intro`,t.intro??`None`],[`Outro`,t.outro??`None`],[`Document theme`,t.documentTheme??`Default`],[`End screen text`,t.endScreenText??`None`]];return(0,h.jsxs)(`section`,{"aria-label":`About ${e.name}`,children:[(0,h.jsx)(V,{title:`About ${e.name}`,meta:e.isDefault?`The default channel`:void 0,children:(0,h.jsx)(lS,{to:`/channels/$channelId`,params:{channelId:e.id},children:`Open channel`})}),(0,h.jsxs)(c4,{className:`mb-6`,children:[(0,h.jsx)(l4,{value:String(e.templates),label:`Templates`}),(0,h.jsx)(l4,{value:String(e.cast),label:`In the cast`})]}),(0,h.jsx)(V,{as:`h3`,title:`Series brief`,className:`pb-2`}),(0,h.jsx)(`p`,{className:`m-0 mb-6 whitespace-pre-wrap text-body text-ink-2`,children:e.seriesBrief.trim()===``?`No series brief yet. Open the channel to say what it covers.`:e.seriesBrief}),(0,h.jsx)(V,{as:`h3`,title:`Brand kit`,className:`pb-2`}),(0,h.jsx)(`dl`,{className:`m-0 grid grid-cols-[auto_minmax(0,1fr)] gap-x-6 gap-y-2 text-small`,children:n.map(([e,t])=>(0,h.jsxs)(`div`,{className:`contents`,children:[(0,h.jsx)(`dt`,{className:`text-ink-2`,children:e}),(0,h.jsx)(`dd`,{className:`m-0 truncate`,children:t})]},e))})]})}var f4=2e3;function p4(e,t){let n=(0,m.useRef)(t);(0,m.useEffect)(()=>{n.current=t}),(0,m.useEffect)(()=>{if(!e)return;let t=setTimeout(()=>{n.current()},f4);return()=>{clearTimeout(t)}},[e])}function m4(){return(0,h.jsxs)(`span`,{className:`inline-flex animate-tick-in items-center gap-1 text-label text-accent-ink motion-reduce:animate-none`,children:[(0,h.jsx)(ac,{"aria-hidden":`true`,className:`size-[14px]`}),`Saved`]})}function h4({onDelete:e,blocked:t,blockedId:n,pending:r,saved:i,cancel:a,errors:o,onSave:s}){let c=t!==void 0||r||i,l=Dy();_x({id:`editor.save`,title:`Save`,group:`This editor`,keywords:[`save`,`keep`],shortcut:mP.save,run:()=>{c?t!==void 0&&l(`Not saved yet: ${t}`,`error`):s()}});let u=o.join(` `);return(0,h.jsxs)(`div`,{"data-slot":`editor-actions`,className:`sticky bottom-0 z-10 flex flex-wrap items-center gap-3 border-t border-line bg-ground py-3 max-md:bottom-[calc(48px+max(12px,env(safe-area-inset-bottom)))]`,children:[(0,h.jsx)(L,{variant:`destructive`,onClick:e,disabled:e===void 0,"aria-hidden":e===void 0||void 0,tabIndex:e===void 0?-1:void 0,style:e===void 0?{visibility:`hidden`}:void 0,children:`Delete`}),(0,h.jsx)(v0,{tone:u?`error`:`info`,id:u?void 0:n,children:u||(i?(0,h.jsx)(m4,{}):t)}),a,(0,h.jsx)(L,{variant:`primary`,"aria-disabled":c,"aria-describedby":t===void 0?void 0:n,"aria-keyshortcuts":kx(mP.save),onClick:()=>{c||s()},children:`Save`})]})}var Efe=`rounded-media border border-line bg-surface p-4`;function g4(){return(0,h.jsxs)(`div`,{className:`mx-auto grid max-w-[1440px] grid-cols-[minmax(0,1fr)] gap-6 lg:grid-cols-[minmax(0,1fr)_360px]`,children:[(0,h.jsxs)(`div`,{className:`${Efe} flex flex-col gap-4`,children:[(0,h.jsx)(`span`,{className:`h-8 w-64 rounded-control bg-sunken`}),(0,h.jsx)(`span`,{className:`h-[520px] rounded-control bg-sunken`})]}),(0,h.jsx)(`div`,{className:`flex flex-col gap-3 pt-1`,children:(0,h.jsx)(`span`,{className:`h-3 w-28 rounded-control bg-sunken`})})]})}var Dfe=`modulepreload`,Ofe=function(e){return`/`+e},_4={},v4=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?import.meta.resolve(e):new URL(e,import.meta.url).href}r=o(t.map(t=>{if(t=Ofe(t,n),t=s(t),t in _4)return;_4[t]=!0;let r=t.endsWith(`.css`);for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}let i=document.createElement(`link`);if(i.rel=r?`stylesheet`:Dfe,r||(i.as=`script`),i.crossOrigin=``,i.href=t,a&&i.setAttribute(`nonce`,a),document.head.appendChild(i),r)return new Promise((e,n)=>{i.addEventListener(`load`,e),i.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})};function kfe({data:e,label:t,onDrawn:n}){let r=(0,m.useRef)(null),[i,a]=(0,m.useState)(0);return(0,m.useEffect)(()=>{let e=r.current;if(e===null)return;let t=new ResizeObserver(([e])=>{a(Math.floor(e?.contentRect.width??0))});return t.observe(e),()=>{t.disconnect()}},[]),(0,m.useEffect)(()=>{let t=r.current;if(t===null||e===void 0||i===0)return;let a=!1;return Afe(e,i).then(e=>{a||(t.replaceChildren(...e),n?.(void 0))},e=>{a||n?.(e instanceof Error?e:Error(String(e)))}),()=>{a=!0}},[e,i,n]),(0,h.jsx)(`div`,{ref:r,role:`img`,"aria-label":t,className:`flex flex-col gap-3 [&>canvas]:w-full [&>canvas]:shadow-[var(--shadow-pop)]`})}async function Afe(e,t){let n=await v4(()=>import(`./pdf-B9OY1ioX.js`),[]),r=await v4(()=>import(`./pdf.worker.min-zC6nfbxG.js`),[]);n.GlobalWorkerOptions.workerSrc=r.default;let i=n.getDocument({data:e.slice()}),a=await i.promise;try{let e=window.devicePixelRatio||1,n=[];for(let r=1;r<=a.numPages;r+=1){let i=await a.getPage(r),o=i.getViewport({scale:t*e/i.getViewport({scale:1}).width}),s=window.document.createElement(`canvas`);s.width=Math.floor(o.width),s.height=Math.floor(o.height),await i.render({canvas:s,viewport:o}).promise,n.push(s)}return n}finally{await i.destroy()}}var y4=(e,t,n)=>({kind:`number`,path:e,label:t,unit:`mm`,step:1,...n===void 0?{}:{help:n}}),b4=(e,t,n)=>({kind:`number`,path:e,label:t,unit:`pt`,step:.5,...n===void 0?{}:{help:n}}),x4=(e,t,n,r)=>({kind:`number`,path:e,label:t,unit:n,step:.05,...r===void 0?{}:{help:r}}),S4=(e,t,n)=>({kind:`toggle`,path:e,label:t,...n===void 0?{}:{help:n}}),C4=(e,t,n)=>({kind:`text`,path:e,label:t,...n===void 0?{}:{help:n}}),w4=(e,t,n)=>({kind:`optional-text`,path:e,label:t,...n===void 0?{}:{help:n}}),T4=(e,t,n)=>({kind:`face`,path:[`fonts`,e],label:t,...n===void 0?{}:{help:n}}),jfe=[{title:`Page`,fields:[{kind:`choice`,path:[`page`,`format`],label:`Paper size`,options:[{value:`a4`,label:`A4`},{value:`letter`,label:`US Letter`}]},y4([`page`,`margin`],`Margins`),y4([`page`,`contentTop`],`Text starts at`,`From the top, on pages with the header.`),{kind:`choice`,path:[`background`,`image`],label:`Background`,options:[{value:`parchment`,label:`Parchment texture`},{value:null,label:`Flat colour`}]},{kind:`color`,path:[`background`,`color`],label:`Page colour`,help:`Used when the background is a flat colour.`}]},{title:`Colours`,fields:[{kind:`color`,path:[`colors`,`heading`],label:`Headings`,help:`Also drop caps, the brand name and links.`},{kind:`color`,path:[`colors`,`text`],label:`Body text`},{kind:`color`,path:[`colors`,`muted`],label:`Muted`,help:`Dates, bullets, quotes and the dots in the contents.`},{kind:`color`,path:[`colors`,`faint`],label:`Faint`,help:`Running header and page numbers.`}]},{title:`Fonts`,fields:[T4(`body`,`Body`),T4(`strong`,`Bold text`),T4(`emphasis`,`Italic text`),T4(`heading`,`Headings`),T4(`dramatic`,`Chapter numbers and brand`,`The big number of a "Chapter 3:" heading.`),T4(`decorative`,`Tagline and title-page link`),T4(`dropCap`,`Drop caps`),T4(`footer`,`Header and page numbers`)]},{title:`Text sizes`,fields:[b4([`sizes`,`title`],`Title`),b4([`sizes`,`brand`],`Brand`),b4([`sizes`,`section`],`Top-level headings`,`Also the titles of the contents, sources and closing pages.`),b4([`sizes`,`heading`],`Second-level headings`),b4([`sizes`,`subheading`],`Third-level headings`),b4([`sizes`,`body`],`Body`),b4([`sizes`,`meta`],`Date and word count`),b4([`sizes`,`footer`],`Header and page numbers`)]},{title:`Spacing`,fields:[y4([`spacing`,`bodyLine`],`Body line height`),y4([`spacing`,`headingLine`],`Heading line height`),y4([`spacing`,`subheadingLine`],`Subheading line height`),x4([`spacing`,`paragraphGap`],`After a paragraph`,`× line`),x4([`spacing`,`headingGap`],`Before a heading`,`× line`),x4([`spacing`,`itemGap`],`After a list item`,`× line`),y4([`spacing`,`listIndent`],`List indent`),y4([`spacing`,`quoteIndent`],`Quote indent`),y4([`spacing`,`ruleWidth`],`Divider width`,`The short centred line a --- becomes.`)]},{title:`Drop caps`,fields:[S4([`dropCap`,`enabled`],`Drop caps`,`A large first letter after each heading.`),{kind:`choice`,path:[`dropCap`,`lines`],label:`Lines tall`,options:[{value:2,label:`2 lines`},{value:3,label:`3 lines`},{value:4,label:`4 lines`}]},x4([`dropCap`,`scale`],`Letter size`,`× lines`),y4([`dropCap`,`gap`],`Gap beside it`),{kind:`number`,path:[`dropCap`,`minLength`],label:`Shortest paragraph`,unit:`chars`,step:10,help:`Shorter paragraphs start plainly.`},x4([`dropCap`,`minRoom`],`Room needed`,`of page`,`With less room left, the paragraph starts on the next page.`)]},{title:`Title page`,fields:[y4([`titlePage`,`brandY`],`Brand from top`),y4([`titlePage`,`taglineOffset`],`Tagline below brand`),y4([`titlePage`,`titleY`],`Title from top`),y4([`titlePage`,`titleLine`],`Title line height`),y4([`titlePage`,`metaOffset`],`Details below title`),y4([`titlePage`,`metaLine`],`Details line height`),S4([`titlePage`,`showDate`],`Show the date`),S4([`titlePage`,`showWordCount`],`Show the word count`),S4([`titlePage`,`cover`,`enabled`],`Thumbnail as cover`,`When the project has a thumbnail.`),y4([`titlePage`,`cover`,`gap`],`Space around cover`),y4([`titlePage`,`cover`,`maxHeight`],`Cover height at most`)]},{title:`Branding`,fields:[w4([`brand`,`name`],`Brand name`,`Leave empty to hide the brand.`),w4([`brand`,`tagline`],`Tagline`),w4([`brand`,`url`],`Website`,`Where the brand and its link go.`),w4([`brand`,`linkLabel`],`Link text`,`The linked line under the word count.`)]},{title:`Contents page`,fields:[S4([`contents`,`enabled`],`Contents page`),C4([`contents`,`title`],`Title`),{kind:`choice`,path:[`contents`,`depth`],label:`Lists headings down to`,options:[{value:1,label:`Top level`},{value:2,label:`Second level`},{value:3,label:`Third level`}]},y4([`contents`,`titleOffset`],`Title from top margin`),y4([`contents`,`firstEntryOffset`],`First entry from top margin`),y4([`contents`,`line`],`Line height`),y4([`contents`,`indent`],`Indent per level`)]},{title:`Header and footer`,fields:[S4([`header`,`enabled`],`Running header`,`The title at the top of each page.`),y4([`header`,`top`],`Header from top`),{kind:`number`,path:[`header`,`maxTitleCharacters`],label:`Header title at most`,unit:`chars`,step:1},S4([`footer`,`enabled`],`Page numbers`),C4([`footer`,`text`],`Page number text`,`{page} becomes the page number.`),y4([`footer`,`bottom`],`From the bottom`),y4([`footer`,`reserve`],`Space kept above it`)]},{title:`Sources page`,fields:[S4([`sources`,`enabled`],`Sources page`,`The links the article and research used.`),C4([`sources`,`title`],`Title`),y4([`sources`,`titleOffset`],`Title from top margin`),y4([`sources`,`bodyOffset`],`List from top margin`),y4([`sources`,`line`],`Line height`),y4([`sources`,`gap`],`Gap between sources`)]},{title:`Closing page`,fields:[S4([`endPage`,`enabled`],`Closing page`),C4([`endPage`,`title`],`Title`),{kind:`lines`,path:[`endPage`,`lines`],label:`Text`,help:`One line each. Start with "•" for a bullet, end with ":" for a bold label, leave a line empty for a gap.`},S4([`endPage`,`showDocumentDetails`],`Add date, word and page counts`),{kind:`link`,path:[`endPage`,`link`],label:`Link`},w4([`endPage`,`closing`],`Closing line`),y4([`endPage`,`titleOffset`],`Title from top margin`),y4([`endPage`,`bodyOffset`],`Text from top margin`)]},{title:`PDF details`,fields:[C4([`metadata`,`author`],`Author`,`Shown in a PDF reader's document properties. {title} becomes the title.`),C4([`metadata`,`subject`],`Subject`),C4([`metadata`,`keywords`],`Keywords`),C4([`metadata`,`creator`],`Creator`)]}],E4=aM.map(e=>({value:e,label:{Cinzel:`Cinzel`,times:`Times`,helvetica:`Helvetica`,courier:`Courier`}[e]}));function D4(e){let t={normal:`Regular`,medium:`Medium`,bold:`Bold`,black:`Black`,italic:`Italic`,bolditalic:`Bold italic`};return(e===`Cinzel`?[`normal`,`medium`,`bold`,`black`]:[`normal`,`bold`,`italic`,`bolditalic`]).map(e=>({value:e,label:t[e]}))}function Mfe(e,t){let n=e;for(let e of t)n=n?.[e];return n}function O4(e,t,n){let[r,...i]=t;if(r===void 0)return n;let a=e[r];return{...e,[r]:i.length===0?n:O4(a,i,n)}}function Nfe(e){let t=pM;for(let n of e)t=t?.shape?.[n];return{min:t?.minValue??0,max:t?.maxValue??1e3}}function k4(e){return`values.${e.join(`.`)}`}var A4=`pt-1`,j4=`flex min-w-0 flex-col gap-3 pt-1 lg:sticky lg:top-16`;function M4({children:e}){return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`span`,{children:`Library`}),(0,h.jsx)(cc,{"aria-hidden":`true`}),e]})}function N4({children:e,back:t}){return(0,h.jsxs)(`div`,{className:`mx-auto flex max-w-[1440px] flex-col gap-3`,children:[(0,h.jsx)(fI,{tone:`danger`,title:`This can't be opened.`,children:e}),(0,h.jsx)(`p`,{className:`m-0 text-small text-accent-ink underline underline-offset-[3px]`,children:t})]})}function P4({themeId:e,from:t,onLeave:n}){let{api:r}=R(),i=_(),a=M(tb(r)),o=(0,m.useId)(),[s,c]=(0,m.useState)(void 0),[l,u]=(0,m.useState)([]),[d,f]=(0,m.useState)(!1),[p,g]=(0,m.useState)(!1),v=a.data,y=e===void 0?void 0:v?.themes.find(t=>t.id===e),b=e===void 0?v?.themes.find(e=>e.id===t)??v?.builtIns.find(e=>e.name===(t??`plain`))??v?.builtIns[0]:y,x=b===void 0?void 0:{name:e===void 0?`${`label`in b?b.label:b.name} copy`:b.name,values:b.values},S=s??x,C=N({mutationFn:t=>js(r,t,e),onSuccess:async e=>{if(!e.ok){u(e.fields);return}f(!0),await i.invalidateQueries({queryKey:tb(r).queryKey})}}),w=N({mutationFn:e=>Ms(r,e),onSuccess:async()=>{g(!1),await i.invalidateQueries({queryKey:tb(r).queryKey}),n()}});p4(d,n);let T=(0,m.useMemo)(()=>S===void 0?void 0:pM.safeParse(S.values),[S]),E=[...S===void 0||S.name.trim()===``?[]:JS(S.name),...T===void 0||T.success?[]:T.error.issues.map(e=>({field:`values.${e.path.join(`.`)}`,message:e.message})),...l];if(a.error!==null)return(0,h.jsx)(L4,{children:a.error.message});if(v===void 0)return(0,h.jsx)(g4,{});if(S===void 0)return(0,h.jsx)(L4,{children:`That theme is gone. It may have been deleted in another tab.`});let D=(e,t)=>{c(e),u(e=>e.filter(e=>e.field!==t))},O=S.name.trim()===``?`Give the theme a name.`:E.length>0?`Fix the highlighted settings first.`:void 0,k=E.filter(e=>e.field===`name`);return(0,h.jsxs)(`div`,{children:[(0,h.jsx)(Aq,{crumb:(0,h.jsx)(M4,{children:(0,h.jsx)(pa,{to:`/document-themes`,children:`Documents`})}),title:e===void 0?`New document theme`:`Edit document theme`,meta:`How a project's PDF looks`}),(0,h.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)] items-start gap-6 lg:grid-cols-[minmax(0,1fr)_minmax(320px,440px)]`,children:[(0,h.jsxs)(`div`,{className:`${A4} flex min-w-0 flex-col gap-4`,children:[(0,h.jsx)(Y,{label:`Name`,tip:`library.theme.name`,...k.length===0?{}:{error:k.map(e=>e.message).join(` `)},children:(0,h.jsx)(OV,{value:S.name,onChange:e=>{D({...S,name:e.target.value},`name`)}})}),jfe.map((e,t)=>(0,h.jsxs)(`details`,{open:t<2||e.fields.some(e=>F4(E,e.path)),className:`group border-t border-line`,children:[(0,h.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 py-3 text-title-3 font-semibold`,onClick:e=>{let t=e.currentTarget.parentElement;requestAnimationFrame(()=>{t instanceof HTMLDetailsElement&&t.open&&t.scrollIntoView?.({block:`nearest`,behavior:`smooth`})})},children:[(0,h.jsx)(cc,{"aria-hidden":`true`,className:`size-[14px] text-ink-2 transition-transform group-open:rotate-90 motion-reduce:transition-none`}),e.title]}),(0,h.jsx)(`div`,{className:`grid grid-cols-[minmax(0,1fr)] gap-x-5 gap-y-4 pb-4 sm:grid-cols-2`,children:e.fields.map(e=>(0,h.jsx)(Ife,{field:e,theme:S.values,problem:F4(E,e.path),onChange:t=>{D({...S,values:t},k4(e.path))}},e.path.join(`.`)))})]},e.title)),(0,h.jsx)(h4,{onDelete:e===void 0?void 0:()=>{g(!0)},blocked:O,blockedId:o,pending:C.isPending,saved:d,cancel:(0,h.jsx)(lS,{to:`/document-themes`,variant:`secondary`,children:`Cancel`}),errors:[C.error,w.error].flatMap(e=>e===null?[]:[e.message]),onSave:()=>{C.mutate(S)}})]}),(0,h.jsx)(Ffe,{values:T?.success===!0?S.values:void 0})]}),(0,h.jsx)(Ay,{open:p,title:`Delete "${S.name}"?`,consequence:`Projects that used it keep their own copy of its settings.`,confirmLabel:`Delete theme`,pending:w.isPending,onConfirm:()=>{e!==void 0&&w.mutate(e)},onCancel:()=>{g(!1)}})]})}var Pfe={"values.page.format":`library.theme.page.format`,"values.page.margin":`library.theme.page.margin`,"values.page.contentTop":`library.theme.page.content-top`,"values.background.image":`library.theme.background.image`,"values.background.color":`library.theme.background.color`,"values.colors.heading":`library.theme.colors.heading`,"values.colors.text":`library.theme.colors.text`,"values.colors.muted":`library.theme.colors.muted`,"values.colors.faint":`library.theme.colors.faint`,"values.fonts.body":`library.theme.fonts.body`,"values.fonts.strong":`library.theme.fonts.strong`,"values.fonts.emphasis":`library.theme.fonts.emphasis`,"values.fonts.heading":`library.theme.fonts.heading`,"values.fonts.dramatic":`library.theme.fonts.dramatic`,"values.fonts.decorative":`library.theme.fonts.decorative`,"values.fonts.dropCap":`library.theme.fonts.drop-cap`,"values.fonts.footer":`library.theme.fonts.footer`,"values.sizes.title":`library.theme.sizes.title`,"values.sizes.brand":`library.theme.sizes.brand`,"values.sizes.section":`library.theme.sizes.section`,"values.sizes.heading":`library.theme.sizes.heading`,"values.sizes.subheading":`library.theme.sizes.subheading`,"values.sizes.body":`library.theme.sizes.body`,"values.sizes.meta":`library.theme.sizes.meta`,"values.sizes.footer":`library.theme.sizes.footer`,"values.spacing.bodyLine":`library.theme.spacing.body-line`,"values.spacing.headingLine":`library.theme.spacing.heading-line`,"values.spacing.subheadingLine":`library.theme.spacing.subheading-line`,"values.spacing.paragraphGap":`library.theme.spacing.paragraph-gap`,"values.spacing.headingGap":`library.theme.spacing.heading-gap`,"values.spacing.itemGap":`library.theme.spacing.item-gap`,"values.spacing.listIndent":`library.theme.spacing.list-indent`,"values.spacing.quoteIndent":`library.theme.spacing.quote-indent`,"values.spacing.ruleWidth":`library.theme.spacing.rule-width`,"values.dropCap.enabled":`library.theme.drop-cap.enabled`,"values.dropCap.lines":`library.theme.drop-cap.lines`,"values.dropCap.scale":`library.theme.drop-cap.scale`,"values.dropCap.gap":`library.theme.drop-cap.gap`,"values.dropCap.minLength":`library.theme.drop-cap.min-length`,"values.dropCap.minRoom":`library.theme.drop-cap.min-room`,"values.titlePage.brandY":`library.theme.title-page.brand-y`,"values.titlePage.taglineOffset":`library.theme.title-page.tagline-offset`,"values.titlePage.titleY":`library.theme.title-page.title-y`,"values.titlePage.titleLine":`library.theme.title-page.title-line`,"values.titlePage.metaOffset":`library.theme.title-page.meta-offset`,"values.titlePage.metaLine":`library.theme.title-page.meta-line`,"values.titlePage.showDate":`library.theme.title-page.show-date`,"values.titlePage.showWordCount":`library.theme.title-page.show-word-count`,"values.titlePage.cover.enabled":`library.theme.title-page.cover`,"values.titlePage.cover.gap":`library.theme.title-page.cover-gap`,"values.titlePage.cover.maxHeight":`library.theme.title-page.cover-height`,"values.brand.name":`library.theme.brand.name`,"values.brand.tagline":`library.theme.brand.tagline`,"values.brand.url":`library.theme.brand.url`,"values.brand.linkLabel":`library.theme.brand.link-label`,"values.contents.enabled":`library.theme.contents.enabled`,"values.contents.title":`library.theme.contents.title`,"values.contents.depth":`library.theme.contents.depth`,"values.contents.titleOffset":`library.theme.contents.title-offset`,"values.contents.firstEntryOffset":`library.theme.contents.first-entry-offset`,"values.contents.line":`library.theme.contents.line`,"values.contents.indent":`library.theme.contents.indent`,"values.header.enabled":`library.theme.header.enabled`,"values.header.top":`library.theme.header.top`,"values.header.maxTitleCharacters":`library.theme.header.max-title`,"values.footer.enabled":`library.theme.footer.enabled`,"values.footer.text":`library.theme.footer.text`,"values.footer.bottom":`library.theme.footer.bottom`,"values.footer.reserve":`library.theme.footer.reserve`,"values.sources.enabled":`library.theme.sources.enabled`,"values.sources.title":`library.theme.sources.title`,"values.sources.titleOffset":`library.theme.sources.title-offset`,"values.sources.bodyOffset":`library.theme.sources.body-offset`,"values.sources.line":`library.theme.sources.line`,"values.sources.gap":`library.theme.sources.gap`,"values.endPage.enabled":`library.theme.end-page.enabled`,"values.endPage.title":`library.theme.end-page.title`,"values.endPage.lines":`library.theme.end-page.lines`,"values.endPage.showDocumentDetails":`library.theme.end-page.details`,"values.endPage.link":`library.theme.end-page.link`,"values.endPage.closing":`library.theme.end-page.closing`,"values.endPage.titleOffset":`library.theme.end-page.title-offset`,"values.endPage.bodyOffset":`library.theme.end-page.body-offset`,"values.metadata.author":`library.theme.metadata.author`,"values.metadata.subject":`library.theme.metadata.subject`,"values.metadata.keywords":`library.theme.metadata.keywords`,"values.metadata.creator":`library.theme.metadata.creator`};function F4(e,t){let n=k4(t),r=e.filter(e=>e.field===n||e.field.startsWith(`${n}.`));return r.length===0?void 0:r.map(e=>e.message).join(` `)}function Ffe({values:e}){let{api:t}=R(),[n,r]=(0,m.useState)(),[i,a]=(0,m.useState)(`busy`),[o,s]=(0,m.useState)(void 0),c=e===void 0?void 0:JSON.stringify(e);(0,m.useEffect)(()=>{if(c===void 0)return;let e=new AbortController,n=window.setTimeout(()=>{a(`busy`),Ns(t,JSON.parse(c),e.signal).then(async e=>({bytes:new Uint8Array(await e.arrayBuffer()),blob:e})).then(({bytes:t,blob:n})=>{e.signal.aborted||r({bytes:t,url:URL.createObjectURL(n)})},t=>{e.signal.aborted||(s(t instanceof Error?t.message:String(t)),a(`failed`))})},450);return()=>{window.clearTimeout(n),e.abort()}},[t,c]),(0,m.useEffect)(()=>()=>{n!==void 0&&URL.revokeObjectURL(n.url)},[n]);let l=(0,m.useCallback)(e=>{if(e===void 0){a(`idle`);return}s(e.message),a(`failed`)},[]),u=e===void 0?`Paused until the highlighted settings are fixed.`:i===`busy`?`Updating…`:i===`failed`?`The preview couldn't be made: ${o??`unknown error`}`:`A sample article with this theme. Your projects use their own text and thumbnail.`;return(0,h.jsxs)(`div`,{className:j4,children:[(0,h.jsx)(V,{title:`Preview`,info:`library.theme.preview`,size:`small`,className:`pb-0`,children:n===void 0?null:(0,h.jsxs)(dS,{href:n.url,target:`_blank`,rel:`noreferrer`,variant:`secondary`,size:`small`,children:[(0,h.jsx)(hc,{"aria-hidden":`true`,strokeWidth:1.75}),`Open full size`]})}),(0,h.jsx)(`div`,{className:`max-h-[calc(100vh-220px)] min-h-[320px] overflow-y-auto rounded-media bg-sunken p-3`,children:(0,h.jsx)(kfe,{data:n?.bytes,label:`The sample article laid out with this theme`,onDrawn:l})}),(0,h.jsx)(`p`,{role:`status`,className:i===`failed`?`m-0 text-small text-danger`:`m-0 text-small text-ink-2`,children:u})]})}function Ife({field:e,theme:t,problem:n,onChange:r}){let i=(0,m.useId)(),a=Mfe(t,e.path),o=Pfe[k4(e.path)],s=o===void 0?null:(0,h.jsx)(B,{id:o,label:e.label,className:`-my-1`}),c=n=>{r(O4(t,e.path,n))},l=[e.help===void 0?``:`${i}-help`,n===void 0?``:`${i}-error`].filter(e=>e!==``).join(` `),u=(0,h.jsxs)(h.Fragment,{children:[e.help===void 0?null:(0,h.jsx)(`p`,{id:`${i}-help`,className:`sl-field__help m-0`,children:e.help}),n===void 0?null:(0,h.jsx)(`p`,{id:`${i}-error`,className:`sl-field__error m-0`,children:n})]}),d={id:i,"aria-invalid":n!==void 0,"aria-describedby":l===``?void 0:l};switch(e.kind){case`toggle`:return(0,h.jsxs)(`div`,{className:`flex flex-col gap-1 sm:col-span-2`,...Tb,children:[(0,h.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,h.jsxs)(`label`,{htmlFor:i,className:`flex min-h-8 items-center gap-3 text-small font-semibold`,children:[(0,h.jsx)(`input`,{...d,type:`checkbox`,checked:a===!0,className:`size-4 accent-accent`,onChange:e=>{c(e.currentTarget.checked)}}),e.label]}),s]}),u]});case`number`:{let{min:t,max:n}=Nfe(e.path);return(0,h.jsx)(I4,{id:i,label:e.label,notes:u,info:s,children:(0,h.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,h.jsx)(OV,{...d,type:`number`,inputMode:`decimal`,min:t,max:n,step:e.step,className:`w-28`,value:typeof a==`number`&&Number.isFinite(a)?a:``,onChange:e=>{c(e.target.value===``?NaN:Number(e.target.value))}}),(0,h.jsx)(`span`,{className:`text-small text-ink-2`,children:e.unit})]})})}case`color`:{let t=typeof a==`string`?a:``,n=/^#?[0-9a-f]{6}$/i.test(t)?`#${t.replace(`#`,``)}`:/^#?[0-9a-f]{3}$/i.test(t)?`#${[...t.replace(`#`,``)].map(e=>e+e).join(``)}`:`#000000`;return(0,h.jsx)(I4,{id:i,label:e.label,notes:u,info:s,children:(0,h.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,h.jsx)(`input`,{type:`color`,"aria-label":`${e.label} colour`,value:n,className:`h-8 w-10 cursor-pointer rounded-control border border-line-strong bg-transparent p-0.5`,onChange:e=>{c(e.target.value)}}),(0,h.jsx)(OV,{...d,className:`w-28 font-mono`,value:t,onChange:e=>{c(e.target.value)}})]})})}case`text`:return(0,h.jsx)(I4,{id:i,label:e.label,notes:u,info:s,children:(0,h.jsx)(OV,{...d,value:typeof a==`string`?a:``,onChange:e=>{c(e.target.value)}})});case`optional-text`:return(0,h.jsx)(I4,{id:i,label:e.label,notes:u,info:s,children:(0,h.jsx)(OV,{...d,value:typeof a==`string`?a:``,onChange:e=>{c(e.target.value===``?null:e.target.value)}})});case`choice`:{let t=e.options.findIndex(e=>e.value===a);return(0,h.jsx)(I4,{id:i,label:e.label,notes:u,info:s,children:(0,h.jsx)(AV,{...d,value:String(t),onChange:t=>{let n=e.options[Number(t.target.value)];n!==void 0&&c(n.value)},children:e.options.map((e,t)=>(0,h.jsx)(`option`,{value:String(t),children:e.label},e.label))})})}case`face`:{let t=a,n=D4(t.family);return(0,h.jsx)(I4,{id:i,label:e.label,notes:u,info:s,children:(0,h.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,h.jsx)(AV,{...d,"aria-label":`${e.label} font`,value:t.family,onChange:e=>{let n=E4.find(t=>t.value===e.target.value);if(n===void 0)return;let r=D4(n.value).some(e=>e.value===t.style);c({...t,family:n.value,style:r?t.style:`normal`})},children:E4.map(e=>(0,h.jsx)(`option`,{value:e.value,children:e.label},e.value))}),(0,h.jsx)(AV,{"aria-label":`${e.label} style`,value:t.style,onChange:e=>{c({...t,style:e.target.value})},children:n.map(e=>(0,h.jsx)(`option`,{value:e.value,children:e.label},e.value))}),(0,h.jsx)(OV,{type:`number`,"aria-label":`${e.label} letter spacing in millimetres`,title:`Letter spacing (mm)`,step:.01,className:`w-20`,value:Number.isFinite(t.letterSpacing)?t.letterSpacing:``,onChange:e=>{c({...t,letterSpacing:e.target.value===``?NaN:Number(e.target.value)})}})]})})}case`lines`:return(0,h.jsxs)(`div`,{className:`flex flex-col gap-1 sm:col-span-2`,...Tb,children:[(0,h.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,h.jsx)(`label`,{htmlFor:i,className:`sl-field__label`,children:e.label}),s]}),(0,h.jsx)(kV,{...d,rows:8,value:Array.isArray(a)?a.join(`
272
+ `),filter:g})},onCancel:()=>{y.reset(),p(void 0)}}),r.data&&C.length===0?(0,h.jsx)(T0,{title:`No existing videos listed`,children:`In YouTube Studio open Analytics → Content → Advanced mode, export the table as a CSV, and import it here; or paste the titles above.`}):null,C.length>0?(0,h.jsx)(hU,{label:`Existing videos`,children:C.map(e=>(0,h.jsx)(gU,{title:e.title,actions:(0,h.jsx)(L,{size:`small`,variant:`quiet`,disabled:w,"aria-label":`Remove ${e.title}`,onClick:()=>x.mutate(e.id),children:`Remove`})},e.id))}):null,(0,h.jsx)(Ay,{open:o,title:`Remove all ${a4(C.length,`title`,`titles`)}?`,consequence:S.error?.message??`Topic suggestions and duplicate checks stop skipping them. Your videos on YouTube are not touched.`,confirmLabel:`Remove all`,pending:S.isPending,onConfirm:()=>S.mutate(),onCancel:()=>s(!1)})]})}function bfe({preview:e,filter:t,busy:n,onFilter:r,onTick:i,onSave:a,onCancel:o}){let s=(0,m.useId)(),c=e.ticked.filter(Boolean).length;return(0,h.jsxs)(`section`,{"aria-label":`Titles in the CSV`,className:`mt-4`,...Tb,children:[(0,h.jsxs)(V,{as:`h3`,title:`Titles in the CSV`,info:`planning.channel.videos-ticks`,meta:`${c.toLocaleString(`en`)} of ${a4(e.titles.length,`title`,`titles`)} ticked`,children:[(0,h.jsxs)(L,{variant:`primary`,disabled:n||c===0,onClick:a,children:[`Add `,a4(c,`ticked title`,`ticked titles`)]}),(0,h.jsx)(L,{variant:`quiet`,disabled:n,onClick:o,children:`Cancel`})]}),(0,h.jsx)(Y,{label:`Keep only titles containing…`,tip:`planning.channel.videos-filter`,tipLabel:`Keep only titles containing`,children:(0,h.jsx)(OV,{value:t,maxLength:200,onChange:e=>r(e.target.value)})}),(0,h.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2`,children:[(0,h.jsx)(L,{size:`small`,disabled:n,onClick:()=>i(e.titles.map(()=>!0)),children:`Tick all`}),(0,h.jsx)(L,{size:`small`,disabled:n,onClick:()=>i(e.titles.map(()=>!1)),children:`Untick all`})]}),(0,h.jsx)(hU,{label:`Titles in the CSV`,className:`mt-2`,children:e.titles.map((t,r)=>(0,h.jsx)(gU,{lead:(0,h.jsx)(`input`,{id:`${s}-${r}`,type:`checkbox`,checked:e.ticked[r]===!0,disabled:n,className:`size-4 shrink-0 accent-accent`,onChange:t=>i(e.ticked.map((e,n)=>n===r?t.target.checked:e))}),title:(0,h.jsx)(`label`,{htmlFor:`${s}-${r}`,children:t})},r))})]})}var s4=[`brand`,`cast`,`templates`,`schedules`,`episodes`,`videos`],xfe={brand:`Brand`,cast:`Cast`,templates:`Templates`,schedules:`Schedules`,episodes:`Episodes`,videos:`Existing videos`};function Sfe(e){return s4.find(t=>t===e)??`brand`}function Cfe({channelId:e,tab:t,onTab:n}){let{api:r}=R(),i=_(),a=Xi(),o=M(Yb(r,e)),[s,c]=(0,m.useState)(!1),[l,u]=(0,m.useState)(null),d=N({mutationFn:()=>Qb(r,e),onSuccess:async()=>{c(!1),await i.invalidateQueries({queryKey:Wb}),await a({to:`/channels`})}}),f=o.data?.channel,p=o.data?.cast??[],g=()=>{n(`cast`),u(`new`)};return _x({id:`channel.add-to-cast`,title:`Add to cast`,group:`Channel`,...f===void 0?{}:{context:f.name},keywords:[`character`,`creature`,`place`,`object`],run:g}),(0,h.jsxs)(`div`,{children:[(0,h.jsx)(Aq,{crumb:(0,h.jsx)(pa,{to:`/channels`,children:`Channels`}),title:f?.name??`Channel`,meta:f?.isDefault?`Default channel`:void 0,actions:(0,h.jsxs)(h.Fragment,{children:[t===`cast`&&f?(0,h.jsxs)(L,{variant:`primary`,onClick:g,children:[(0,h.jsx)(kc,{"aria-hidden":`true`,className:`size-4`,strokeWidth:1.75}),`Add to cast`]}):null,f&&!f.isDefault?(0,h.jsx)(L,{variant:`quiet`,onClick:()=>{d.reset(),c(!0)},children:`Delete channel`}):null]})}),(0,h.jsx)(C0,{items:s4.map(e=>({id:e,label:xfe[e],...e===`cast`?{badge:String(p.length)}:{}})),value:t,onChange:n,label:`Channel sections`,idPrefix:`channel`,className:`mb-6`}),(0,h.jsx)(v0,{tone:o.error?`error`:`info`,className:`mb-2`,children:o.error?`The channel couldn't be loaded: ${o.error.message} Go back to Channels and open it again.`:o.isPending?`Loading the channel…`:void 0}),f?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(w0,{idPrefix:`channel`,id:`brand`,active:t===`brand`,children:[(0,h.jsx)(Kde,{channel:f}),(0,h.jsx)(efe,{channel:f},`${f.id}:${String(f.version)}`)]}),(0,h.jsx)(w0,{idPrefix:`channel`,id:`cast`,active:t===`cast`,children:(0,h.jsx)(sfe,{channelId:f.id,cast:p,selected:l,onSelect:u})}),(0,h.jsx)(w0,{idPrefix:`channel`,id:`templates`,active:t===`templates`,children:t===`templates`?(0,h.jsx)(Oue,{channelId:f.id}):null}),(0,h.jsx)(w0,{idPrefix:`channel`,id:`schedules`,active:t===`schedules`,children:t===`schedules`?(0,h.jsx)(jue,{channelId:f.id}):null}),(0,h.jsx)(w0,{idPrefix:`channel`,id:`episodes`,active:t===`episodes`,children:t===`episodes`?(0,h.jsx)(_fe,{channelId:f.id}):null}),(0,h.jsx)(w0,{idPrefix:`channel`,id:`videos`,active:t===`videos`,children:t===`videos`?(0,h.jsx)(yfe,{channelId:f.id}):null})]}):null,(0,h.jsx)(Ay,{open:s,title:`Delete ${f?.name??`this channel`}?`,consequence:d.error?.message??`Its cast goes with it. Its videos move to the default channel and keep what they were made with.`,confirmLabel:`Delete channel`,cancelLabel:`Keep it`,pending:d.isPending,onConfirm:()=>d.mutate(),onCancel:()=>c(!1)})]})}function c4({className:e,children:t}){return(0,h.jsx)(`dl`,{className:I(`sl-stats m-0`,e),children:t})}function l4({value:e,label:t,children:n}){return(0,h.jsxs)(`div`,{className:`sl-stat`,children:[(0,h.jsx)(`dt`,{className:`sl-stat__label order-2`,children:t}),(0,h.jsx)(`dd`,{className:`sl-stat__value order-1 m-0`,children:e}),n===void 0?null:(0,h.jsx)(`dd`,{className:`order-3 m-0 mt-1`,children:n})]})}function u4({value:e,label:t,valueText:n,tone:r=`accent`,className:i}){let a=Math.round(Math.min(1,Math.max(0,Number.isFinite(e)?e:0))*100);return(0,h.jsx)(`div`,{role:`meter`,"aria-label":t,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":a,"aria-valuetext":n??`${String(a)}%`,className:I(`sl-meter`,r===`waiting`&&`sl-meter--waiting`,i),children:(0,h.jsx)(`span`,{style:{width:`${String(a)}%`}})})}function d4({columns:e,rows:t,rowKey:n,caption:r,empty:i,className:a}){return(0,h.jsxs)(`table`,{className:I(`sl-table`,a),children:[(0,h.jsx)(`caption`,{className:`sr-only`,children:r}),(0,h.jsx)(`thead`,{children:(0,h.jsx)(`tr`,{children:e.map(e=>(0,h.jsx)(`th`,{scope:`col`,className:e.numeric?`num`:void 0,children:e.header},e.id))})}),(0,h.jsx)(`tbody`,{children:t.length===0&&i!==void 0?(0,h.jsx)(`tr`,{children:(0,h.jsx)(`td`,{colSpan:e.length,className:`text-ink-2`,children:i})}):t.map(t=>(0,h.jsx)(`tr`,{children:e.map(e=>(0,h.jsx)(`td`,{className:e.numeric?`num`:void 0,children:e.cell(t)},e.id))},n(t)))})]})}function wfe(){let{api:e}=R(),t=_(),n=Xi(),r=M(Jb(e)),[i,a]=(0,m.useState)(null),[o,s]=(0,m.useState)(null),[c,l]=(0,m.useState)(``),[u,d]=(0,m.useState)(null),f=r.data?.find(e=>e.id===u)??r.data?.[0],p=N({mutationFn:()=>Xb(e,crypto.randomUUID(),c.trim()),onSuccess:async e=>{await t.invalidateQueries({queryKey:Wb}),a(null),l(``),await n({to:`/channels/$channelId`,params:{channelId:e.id}})}}),g=N({mutationFn:t=>Zb(e,t.id,{name:c.trim(),brand:t.brand,seriesBrief:t.seriesBrief,baseVersion:t.version}),onSuccess:async()=>{await t.invalidateQueries({queryKey:Wb}),a(null)}}),v=N({mutationFn:t=>Qb(e,t.id),onSuccess:async()=>{s(null),await t.invalidateQueries({queryKey:Wb})}}),y=()=>{p.reset(),l(``),a(`new`)};_x({id:`channels.new`,title:`New channel`,group:`Channels`,run:y});let b=i===`new`?p:g,x=()=>{c.trim()!==``&&i!==null&&(i===`new`?p.mutate():g.mutate(i))};return(0,h.jsxs)(`div`,{"data-tour":`channels`,children:[(0,h.jsx)(Aq,{title:`Channels`,meta:(0,h.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[`A channel keeps its brand kit, cast, series brief, templates and schedules together.`,(0,h.jsx)(B,{id:`planning.channels`})]}),actions:(0,h.jsxs)(L,{variant:`primary`,"aria-expanded":i===`new`,onClick:y,children:[(0,h.jsx)(kc,{"aria-hidden":`true`,className:`size-4`,strokeWidth:1.75}),`New channel`]})}),(0,h.jsx)(v0,{tone:r.error||v.error?`error`:`info`,className:`mb-2`,children:r.error?`The channels couldn't be loaded: ${r.error.message} Reload the page to try again.`:o===null&&v.error?v.error.message:r.isPending?`Loading channels…`:void 0}),r.data?.length===0?(0,h.jsx)(T0,{title:`No channels yet`,actions:(0,h.jsx)(L,{variant:`primary`,onClick:y,children:`New channel`}),children:`Make one for each series you run; it keeps that series' look and cast.`}):null,r.data?.length?(0,h.jsx)(Mq,{list:(0,h.jsx)(hU,{label:`Channels`,className:`[&_.sl-row__actions]:flex-wrap`,children:r.data.map(e=>(0,h.jsx)(gU,{selected:e.id===f?.id,onSelect:()=>d(e.id),title:e.name,meta:`${e.isDefault?`Default · `:``}${String(e.templates)} ${e.templates===1?`template`:`templates`} · ${String(e.cast)} in the cast`,actions:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(uS,{to:`/channels/$channelId`,params:{channelId:e.id},"aria-label":`Open ${e.name}`,className:`px-2 text-small`,children:`Open`}),(0,h.jsx)(L,{variant:`quiet`,size:`small`,"aria-label":`Rename ${e.name}`,onClick:()=>{g.reset(),l(e.name),a(e)},children:`Rename`}),e.isDefault?null:(0,h.jsx)(L,{variant:`quiet`,size:`small`,"aria-label":`Delete ${e.name}`,onClick:()=>{v.reset(),s(e)},children:`Delete`})]})},e.id))}),detail:f===void 0?null:(0,h.jsx)(Tfe,{channel:f})}):null,(0,h.jsx)(ky,{open:i!==null,onOpenChange:e=>{!e&&!b.isPending&&a(null)},title:i===`new`||i===null?`New channel`:`Rename ${i.name}`,footer:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(v0,{tone:b.error?`error`:`info`,children:b.error?.message??(b.isPending?`Saving…`:void 0)}),(0,h.jsx)(L,{disabled:b.isPending,onClick:()=>a(null),children:`Cancel`}),(0,h.jsx)(L,{type:`submit`,form:`channel-name-form`,variant:`primary`,disabled:b.isPending||c.trim()===``,children:i===`new`?`Create channel`:`Rename channel`})]}),children:(0,h.jsx)(`form`,{id:`channel-name-form`,"aria-label":i===`new`?`New channel`:`Rename channel`,onSubmit:e=>{e.preventDefault(),x()},children:(0,h.jsx)(Y,{label:`Channel name`,tip:`planning.channel.name`,children:(0,h.jsx)(OV,{value:c,maxLength:200,required:!0,disabled:b.isPending,onChange:e=>l(e.target.value)})})})}),(0,h.jsx)(Ay,{open:o!==null,title:`Delete ${o?.name??`this channel`}?`,consequence:v.error?.message??`Its cast goes with it. Its videos move to the default channel and keep what they were made with.`,confirmLabel:`Delete channel`,cancelLabel:`Keep it`,pending:v.isPending,onConfirm:()=>{o&&v.mutate(o)},onCancel:()=>s(null)})]})}function Tfe({channel:e}){let t=e.brand,n=[[`Intro`,t.intro??`None`],[`Outro`,t.outro??`None`],[`Document theme`,t.documentTheme??`Default`],[`End screen text`,t.endScreenText??`None`]];return(0,h.jsxs)(`section`,{"aria-label":`About ${e.name}`,children:[(0,h.jsx)(V,{title:`About ${e.name}`,meta:e.isDefault?`The default channel`:void 0,children:(0,h.jsx)(lS,{to:`/channels/$channelId`,params:{channelId:e.id},children:`Open channel`})}),(0,h.jsxs)(c4,{className:`mb-6`,children:[(0,h.jsx)(l4,{value:String(e.templates),label:`Templates`}),(0,h.jsx)(l4,{value:String(e.cast),label:`In the cast`})]}),(0,h.jsx)(V,{as:`h3`,title:`Series brief`,className:`pb-2`}),(0,h.jsx)(`p`,{className:`m-0 mb-6 whitespace-pre-wrap text-body text-ink-2`,children:e.seriesBrief.trim()===``?`No series brief yet. Open the channel to say what it covers.`:e.seriesBrief}),(0,h.jsx)(V,{as:`h3`,title:`Brand kit`,className:`pb-2`}),(0,h.jsx)(`dl`,{className:`m-0 grid grid-cols-[auto_minmax(0,1fr)] gap-x-6 gap-y-2 text-small`,children:n.map(([e,t])=>(0,h.jsxs)(`div`,{className:`contents`,children:[(0,h.jsx)(`dt`,{className:`text-ink-2`,children:e}),(0,h.jsx)(`dd`,{className:`m-0 truncate`,children:t})]},e))})]})}var f4=2e3;function p4(e,t){let n=(0,m.useRef)(t);(0,m.useEffect)(()=>{n.current=t}),(0,m.useEffect)(()=>{if(!e)return;let t=setTimeout(()=>{n.current()},f4);return()=>{clearTimeout(t)}},[e])}function m4(){return(0,h.jsxs)(`span`,{className:`inline-flex animate-tick-in items-center gap-1 text-label text-accent-ink motion-reduce:animate-none`,children:[(0,h.jsx)(ac,{"aria-hidden":`true`,className:`size-[14px]`}),`Saved`]})}function h4({onDelete:e,blocked:t,blockedId:n,pending:r,saved:i,cancel:a,errors:o,onSave:s}){let c=t!==void 0||r||i,l=Dy();_x({id:`editor.save`,title:`Save`,group:`This editor`,keywords:[`save`,`keep`],shortcut:mP.save,run:()=>{c?t!==void 0&&l(`Not saved yet: ${t}`,`error`):s()}});let u=o.join(` `);return(0,h.jsxs)(`div`,{"data-slot":`editor-actions`,className:`sticky bottom-0 z-10 flex flex-wrap items-center gap-3 border-t border-line bg-ground py-3 max-md:bottom-[calc(48px+max(12px,env(safe-area-inset-bottom)))]`,children:[(0,h.jsx)(L,{variant:`destructive`,onClick:e,disabled:e===void 0,"aria-hidden":e===void 0||void 0,tabIndex:e===void 0?-1:void 0,style:e===void 0?{visibility:`hidden`}:void 0,children:`Delete`}),(0,h.jsx)(v0,{tone:u?`error`:`info`,id:u?void 0:n,children:u||(i?(0,h.jsx)(m4,{}):t)}),a,(0,h.jsx)(L,{variant:`primary`,"aria-disabled":c,"aria-describedby":t===void 0?void 0:n,"aria-keyshortcuts":kx(mP.save),onClick:()=>{c||s()},children:`Save`})]})}var Efe=`rounded-media border border-line bg-surface p-4`;function g4(){return(0,h.jsxs)(`div`,{className:`mx-auto grid max-w-[1440px] grid-cols-[minmax(0,1fr)] gap-6 lg:grid-cols-[minmax(0,1fr)_360px]`,children:[(0,h.jsxs)(`div`,{className:`${Efe} flex flex-col gap-4`,children:[(0,h.jsx)(`span`,{className:`h-8 w-64 rounded-control bg-sunken`}),(0,h.jsx)(`span`,{className:`h-[520px] rounded-control bg-sunken`})]}),(0,h.jsx)(`div`,{className:`flex flex-col gap-3 pt-1`,children:(0,h.jsx)(`span`,{className:`h-3 w-28 rounded-control bg-sunken`})})]})}var Dfe=`modulepreload`,Ofe=function(e){return`/`+e},_4={},v4=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?import.meta.resolve(e):new URL(e,import.meta.url).href}r=o(t.map(t=>{if(t=Ofe(t,n),t=s(t),t in _4)return;_4[t]=!0;let r=t.endsWith(`.css`);for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}let i=document.createElement(`link`);if(i.rel=r?`stylesheet`:Dfe,r||(i.as=`script`),i.crossOrigin=``,i.href=t,a&&i.setAttribute(`nonce`,a),document.head.appendChild(i),r)return new Promise((e,n)=>{i.addEventListener(`load`,e),i.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})};function kfe({data:e,label:t,onDrawn:n}){let r=(0,m.useRef)(null),[i,a]=(0,m.useState)(0);return(0,m.useEffect)(()=>{let e=r.current;if(e===null)return;let t=new ResizeObserver(([e])=>{a(Math.floor(e?.contentRect.width??0))});return t.observe(e),()=>{t.disconnect()}},[]),(0,m.useEffect)(()=>{let t=r.current;if(t===null||e===void 0||i===0)return;let a=!1;return Afe(e,i).then(e=>{a||(t.replaceChildren(...e),n?.(void 0))},e=>{a||n?.(e instanceof Error?e:Error(String(e)))}),()=>{a=!0}},[e,i,n]),(0,h.jsx)(`div`,{ref:r,role:`img`,"aria-label":t,className:`flex flex-col gap-3 [&>canvas]:w-full [&>canvas]:shadow-[var(--shadow-pop)]`})}async function Afe(e,t){let n=await v4(()=>import(`./pdf-COowcLcz.js`),[]),r=await v4(()=>import(`./pdf.worker.min-zC6nfbxG.js`),[]);n.GlobalWorkerOptions.workerSrc=r.default;let i=n.getDocument({data:e.slice()}),a=await i.promise;try{let e=window.devicePixelRatio||1,n=[];for(let r=1;r<=a.numPages;r+=1){let i=await a.getPage(r),o=i.getViewport({scale:t*e/i.getViewport({scale:1}).width}),s=window.document.createElement(`canvas`);s.width=Math.floor(o.width),s.height=Math.floor(o.height),await i.render({canvas:s,viewport:o}).promise,n.push(s)}return n}finally{await i.destroy()}}var y4=(e,t,n)=>({kind:`number`,path:e,label:t,unit:`mm`,step:1,...n===void 0?{}:{help:n}}),b4=(e,t,n)=>({kind:`number`,path:e,label:t,unit:`pt`,step:.5,...n===void 0?{}:{help:n}}),x4=(e,t,n,r)=>({kind:`number`,path:e,label:t,unit:n,step:.05,...r===void 0?{}:{help:r}}),S4=(e,t,n)=>({kind:`toggle`,path:e,label:t,...n===void 0?{}:{help:n}}),C4=(e,t,n)=>({kind:`text`,path:e,label:t,...n===void 0?{}:{help:n}}),w4=(e,t,n)=>({kind:`optional-text`,path:e,label:t,...n===void 0?{}:{help:n}}),T4=(e,t,n)=>({kind:`face`,path:[`fonts`,e],label:t,...n===void 0?{}:{help:n}}),jfe=[{title:`Page`,fields:[{kind:`choice`,path:[`page`,`format`],label:`Paper size`,options:[{value:`a4`,label:`A4`},{value:`letter`,label:`US Letter`}]},y4([`page`,`margin`],`Margins`),y4([`page`,`contentTop`],`Text starts at`,`From the top, on pages with the header.`),{kind:`choice`,path:[`background`,`image`],label:`Background`,options:[{value:`parchment`,label:`Parchment texture`},{value:null,label:`Flat colour`}]},{kind:`color`,path:[`background`,`color`],label:`Page colour`,help:`Used when the background is a flat colour.`}]},{title:`Colours`,fields:[{kind:`color`,path:[`colors`,`heading`],label:`Headings`,help:`Also drop caps, the brand name and links.`},{kind:`color`,path:[`colors`,`text`],label:`Body text`},{kind:`color`,path:[`colors`,`muted`],label:`Muted`,help:`Dates, bullets, quotes and the dots in the contents.`},{kind:`color`,path:[`colors`,`faint`],label:`Faint`,help:`Running header and page numbers.`}]},{title:`Fonts`,fields:[T4(`body`,`Body`),T4(`strong`,`Bold text`),T4(`emphasis`,`Italic text`),T4(`heading`,`Headings`),T4(`dramatic`,`Chapter numbers and brand`,`The big number of a "Chapter 3:" heading.`),T4(`decorative`,`Tagline and title-page link`),T4(`dropCap`,`Drop caps`),T4(`footer`,`Header and page numbers`)]},{title:`Text sizes`,fields:[b4([`sizes`,`title`],`Title`),b4([`sizes`,`brand`],`Brand`),b4([`sizes`,`section`],`Top-level headings`,`Also the titles of the contents, sources and closing pages.`),b4([`sizes`,`heading`],`Second-level headings`),b4([`sizes`,`subheading`],`Third-level headings`),b4([`sizes`,`body`],`Body`),b4([`sizes`,`meta`],`Date and word count`),b4([`sizes`,`footer`],`Header and page numbers`)]},{title:`Spacing`,fields:[y4([`spacing`,`bodyLine`],`Body line height`),y4([`spacing`,`headingLine`],`Heading line height`),y4([`spacing`,`subheadingLine`],`Subheading line height`),x4([`spacing`,`paragraphGap`],`After a paragraph`,`× line`),x4([`spacing`,`headingGap`],`Before a heading`,`× line`),x4([`spacing`,`itemGap`],`After a list item`,`× line`),y4([`spacing`,`listIndent`],`List indent`),y4([`spacing`,`quoteIndent`],`Quote indent`),y4([`spacing`,`ruleWidth`],`Divider width`,`The short centred line a --- becomes.`)]},{title:`Drop caps`,fields:[S4([`dropCap`,`enabled`],`Drop caps`,`A large first letter after each heading.`),{kind:`choice`,path:[`dropCap`,`lines`],label:`Lines tall`,options:[{value:2,label:`2 lines`},{value:3,label:`3 lines`},{value:4,label:`4 lines`}]},x4([`dropCap`,`scale`],`Letter size`,`× lines`),y4([`dropCap`,`gap`],`Gap beside it`),{kind:`number`,path:[`dropCap`,`minLength`],label:`Shortest paragraph`,unit:`chars`,step:10,help:`Shorter paragraphs start plainly.`},x4([`dropCap`,`minRoom`],`Room needed`,`of page`,`With less room left, the paragraph starts on the next page.`)]},{title:`Title page`,fields:[y4([`titlePage`,`brandY`],`Brand from top`),y4([`titlePage`,`taglineOffset`],`Tagline below brand`),y4([`titlePage`,`titleY`],`Title from top`),y4([`titlePage`,`titleLine`],`Title line height`),y4([`titlePage`,`metaOffset`],`Details below title`),y4([`titlePage`,`metaLine`],`Details line height`),S4([`titlePage`,`showDate`],`Show the date`),S4([`titlePage`,`showWordCount`],`Show the word count`),S4([`titlePage`,`cover`,`enabled`],`Thumbnail as cover`,`When the project has a thumbnail.`),y4([`titlePage`,`cover`,`gap`],`Space around cover`),y4([`titlePage`,`cover`,`maxHeight`],`Cover height at most`)]},{title:`Branding`,fields:[w4([`brand`,`name`],`Brand name`,`Leave empty to hide the brand.`),w4([`brand`,`tagline`],`Tagline`),w4([`brand`,`url`],`Website`,`Where the brand and its link go.`),w4([`brand`,`linkLabel`],`Link text`,`The linked line under the word count.`)]},{title:`Contents page`,fields:[S4([`contents`,`enabled`],`Contents page`),C4([`contents`,`title`],`Title`),{kind:`choice`,path:[`contents`,`depth`],label:`Lists headings down to`,options:[{value:1,label:`Top level`},{value:2,label:`Second level`},{value:3,label:`Third level`}]},y4([`contents`,`titleOffset`],`Title from top margin`),y4([`contents`,`firstEntryOffset`],`First entry from top margin`),y4([`contents`,`line`],`Line height`),y4([`contents`,`indent`],`Indent per level`)]},{title:`Header and footer`,fields:[S4([`header`,`enabled`],`Running header`,`The title at the top of each page.`),y4([`header`,`top`],`Header from top`),{kind:`number`,path:[`header`,`maxTitleCharacters`],label:`Header title at most`,unit:`chars`,step:1},S4([`footer`,`enabled`],`Page numbers`),C4([`footer`,`text`],`Page number text`,`{page} becomes the page number.`),y4([`footer`,`bottom`],`From the bottom`),y4([`footer`,`reserve`],`Space kept above it`)]},{title:`Sources page`,fields:[S4([`sources`,`enabled`],`Sources page`,`The links the article and research used.`),C4([`sources`,`title`],`Title`),y4([`sources`,`titleOffset`],`Title from top margin`),y4([`sources`,`bodyOffset`],`List from top margin`),y4([`sources`,`line`],`Line height`),y4([`sources`,`gap`],`Gap between sources`)]},{title:`Closing page`,fields:[S4([`endPage`,`enabled`],`Closing page`),C4([`endPage`,`title`],`Title`),{kind:`lines`,path:[`endPage`,`lines`],label:`Text`,help:`One line each. Start with "•" for a bullet, end with ":" for a bold label, leave a line empty for a gap.`},S4([`endPage`,`showDocumentDetails`],`Add date, word and page counts`),{kind:`link`,path:[`endPage`,`link`],label:`Link`},w4([`endPage`,`closing`],`Closing line`),y4([`endPage`,`titleOffset`],`Title from top margin`),y4([`endPage`,`bodyOffset`],`Text from top margin`)]},{title:`PDF details`,fields:[C4([`metadata`,`author`],`Author`,`Shown in a PDF reader's document properties. {title} becomes the title.`),C4([`metadata`,`subject`],`Subject`),C4([`metadata`,`keywords`],`Keywords`),C4([`metadata`,`creator`],`Creator`)]}],E4=aM.map(e=>({value:e,label:{Cinzel:`Cinzel`,times:`Times`,helvetica:`Helvetica`,courier:`Courier`}[e]}));function D4(e){let t={normal:`Regular`,medium:`Medium`,bold:`Bold`,black:`Black`,italic:`Italic`,bolditalic:`Bold italic`};return(e===`Cinzel`?[`normal`,`medium`,`bold`,`black`]:[`normal`,`bold`,`italic`,`bolditalic`]).map(e=>({value:e,label:t[e]}))}function Mfe(e,t){let n=e;for(let e of t)n=n?.[e];return n}function O4(e,t,n){let[r,...i]=t;if(r===void 0)return n;let a=e[r];return{...e,[r]:i.length===0?n:O4(a,i,n)}}function Nfe(e){let t=pM;for(let n of e)t=t?.shape?.[n];return{min:t?.minValue??0,max:t?.maxValue??1e3}}function k4(e){return`values.${e.join(`.`)}`}var A4=`pt-1`,j4=`flex min-w-0 flex-col gap-3 pt-1 lg:sticky lg:top-16`;function M4({children:e}){return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`span`,{children:`Library`}),(0,h.jsx)(cc,{"aria-hidden":`true`}),e]})}function N4({children:e,back:t}){return(0,h.jsxs)(`div`,{className:`mx-auto flex max-w-[1440px] flex-col gap-3`,children:[(0,h.jsx)(fI,{tone:`danger`,title:`This can't be opened.`,children:e}),(0,h.jsx)(`p`,{className:`m-0 text-small text-accent-ink underline underline-offset-[3px]`,children:t})]})}function P4({themeId:e,from:t,onLeave:n}){let{api:r}=R(),i=_(),a=M(tb(r)),o=(0,m.useId)(),[s,c]=(0,m.useState)(void 0),[l,u]=(0,m.useState)([]),[d,f]=(0,m.useState)(!1),[p,g]=(0,m.useState)(!1),v=a.data,y=e===void 0?void 0:v?.themes.find(t=>t.id===e),b=e===void 0?v?.themes.find(e=>e.id===t)??v?.builtIns.find(e=>e.name===(t??`plain`))??v?.builtIns[0]:y,x=b===void 0?void 0:{name:e===void 0?`${`label`in b?b.label:b.name} copy`:b.name,values:b.values},S=s??x,C=N({mutationFn:t=>js(r,t,e),onSuccess:async e=>{if(!e.ok){u(e.fields);return}f(!0),await i.invalidateQueries({queryKey:tb(r).queryKey})}}),w=N({mutationFn:e=>Ms(r,e),onSuccess:async()=>{g(!1),await i.invalidateQueries({queryKey:tb(r).queryKey}),n()}});p4(d,n);let T=(0,m.useMemo)(()=>S===void 0?void 0:pM.safeParse(S.values),[S]),E=[...S===void 0||S.name.trim()===``?[]:JS(S.name),...T===void 0||T.success?[]:T.error.issues.map(e=>({field:`values.${e.path.join(`.`)}`,message:e.message})),...l];if(a.error!==null)return(0,h.jsx)(L4,{children:a.error.message});if(v===void 0)return(0,h.jsx)(g4,{});if(S===void 0)return(0,h.jsx)(L4,{children:`That theme is gone. It may have been deleted in another tab.`});let D=(e,t)=>{c(e),u(e=>e.filter(e=>e.field!==t))},O=S.name.trim()===``?`Give the theme a name.`:E.length>0?`Fix the highlighted settings first.`:void 0,k=E.filter(e=>e.field===`name`);return(0,h.jsxs)(`div`,{children:[(0,h.jsx)(Aq,{crumb:(0,h.jsx)(M4,{children:(0,h.jsx)(pa,{to:`/document-themes`,children:`Documents`})}),title:e===void 0?`New document theme`:`Edit document theme`,meta:`How a project's PDF looks`}),(0,h.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)] items-start gap-6 lg:grid-cols-[minmax(0,1fr)_minmax(320px,440px)]`,children:[(0,h.jsxs)(`div`,{className:`${A4} flex min-w-0 flex-col gap-4`,children:[(0,h.jsx)(Y,{label:`Name`,tip:`library.theme.name`,...k.length===0?{}:{error:k.map(e=>e.message).join(` `)},children:(0,h.jsx)(OV,{value:S.name,onChange:e=>{D({...S,name:e.target.value},`name`)}})}),jfe.map((e,t)=>(0,h.jsxs)(`details`,{open:t<2||e.fields.some(e=>F4(E,e.path)),className:`group border-t border-line`,children:[(0,h.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 py-3 text-title-3 font-semibold`,onClick:e=>{let t=e.currentTarget.parentElement;requestAnimationFrame(()=>{t instanceof HTMLDetailsElement&&t.open&&t.scrollIntoView?.({block:`nearest`,behavior:`smooth`})})},children:[(0,h.jsx)(cc,{"aria-hidden":`true`,className:`size-[14px] text-ink-2 transition-transform group-open:rotate-90 motion-reduce:transition-none`}),e.title]}),(0,h.jsx)(`div`,{className:`grid grid-cols-[minmax(0,1fr)] gap-x-5 gap-y-4 pb-4 sm:grid-cols-2`,children:e.fields.map(e=>(0,h.jsx)(Ife,{field:e,theme:S.values,problem:F4(E,e.path),onChange:t=>{D({...S,values:t},k4(e.path))}},e.path.join(`.`)))})]},e.title)),(0,h.jsx)(h4,{onDelete:e===void 0?void 0:()=>{g(!0)},blocked:O,blockedId:o,pending:C.isPending,saved:d,cancel:(0,h.jsx)(lS,{to:`/document-themes`,variant:`secondary`,children:`Cancel`}),errors:[C.error,w.error].flatMap(e=>e===null?[]:[e.message]),onSave:()=>{C.mutate(S)}})]}),(0,h.jsx)(Ffe,{values:T?.success===!0?S.values:void 0})]}),(0,h.jsx)(Ay,{open:p,title:`Delete "${S.name}"?`,consequence:`Projects that used it keep their own copy of its settings.`,confirmLabel:`Delete theme`,pending:w.isPending,onConfirm:()=>{e!==void 0&&w.mutate(e)},onCancel:()=>{g(!1)}})]})}var Pfe={"values.page.format":`library.theme.page.format`,"values.page.margin":`library.theme.page.margin`,"values.page.contentTop":`library.theme.page.content-top`,"values.background.image":`library.theme.background.image`,"values.background.color":`library.theme.background.color`,"values.colors.heading":`library.theme.colors.heading`,"values.colors.text":`library.theme.colors.text`,"values.colors.muted":`library.theme.colors.muted`,"values.colors.faint":`library.theme.colors.faint`,"values.fonts.body":`library.theme.fonts.body`,"values.fonts.strong":`library.theme.fonts.strong`,"values.fonts.emphasis":`library.theme.fonts.emphasis`,"values.fonts.heading":`library.theme.fonts.heading`,"values.fonts.dramatic":`library.theme.fonts.dramatic`,"values.fonts.decorative":`library.theme.fonts.decorative`,"values.fonts.dropCap":`library.theme.fonts.drop-cap`,"values.fonts.footer":`library.theme.fonts.footer`,"values.sizes.title":`library.theme.sizes.title`,"values.sizes.brand":`library.theme.sizes.brand`,"values.sizes.section":`library.theme.sizes.section`,"values.sizes.heading":`library.theme.sizes.heading`,"values.sizes.subheading":`library.theme.sizes.subheading`,"values.sizes.body":`library.theme.sizes.body`,"values.sizes.meta":`library.theme.sizes.meta`,"values.sizes.footer":`library.theme.sizes.footer`,"values.spacing.bodyLine":`library.theme.spacing.body-line`,"values.spacing.headingLine":`library.theme.spacing.heading-line`,"values.spacing.subheadingLine":`library.theme.spacing.subheading-line`,"values.spacing.paragraphGap":`library.theme.spacing.paragraph-gap`,"values.spacing.headingGap":`library.theme.spacing.heading-gap`,"values.spacing.itemGap":`library.theme.spacing.item-gap`,"values.spacing.listIndent":`library.theme.spacing.list-indent`,"values.spacing.quoteIndent":`library.theme.spacing.quote-indent`,"values.spacing.ruleWidth":`library.theme.spacing.rule-width`,"values.dropCap.enabled":`library.theme.drop-cap.enabled`,"values.dropCap.lines":`library.theme.drop-cap.lines`,"values.dropCap.scale":`library.theme.drop-cap.scale`,"values.dropCap.gap":`library.theme.drop-cap.gap`,"values.dropCap.minLength":`library.theme.drop-cap.min-length`,"values.dropCap.minRoom":`library.theme.drop-cap.min-room`,"values.titlePage.brandY":`library.theme.title-page.brand-y`,"values.titlePage.taglineOffset":`library.theme.title-page.tagline-offset`,"values.titlePage.titleY":`library.theme.title-page.title-y`,"values.titlePage.titleLine":`library.theme.title-page.title-line`,"values.titlePage.metaOffset":`library.theme.title-page.meta-offset`,"values.titlePage.metaLine":`library.theme.title-page.meta-line`,"values.titlePage.showDate":`library.theme.title-page.show-date`,"values.titlePage.showWordCount":`library.theme.title-page.show-word-count`,"values.titlePage.cover.enabled":`library.theme.title-page.cover`,"values.titlePage.cover.gap":`library.theme.title-page.cover-gap`,"values.titlePage.cover.maxHeight":`library.theme.title-page.cover-height`,"values.brand.name":`library.theme.brand.name`,"values.brand.tagline":`library.theme.brand.tagline`,"values.brand.url":`library.theme.brand.url`,"values.brand.linkLabel":`library.theme.brand.link-label`,"values.contents.enabled":`library.theme.contents.enabled`,"values.contents.title":`library.theme.contents.title`,"values.contents.depth":`library.theme.contents.depth`,"values.contents.titleOffset":`library.theme.contents.title-offset`,"values.contents.firstEntryOffset":`library.theme.contents.first-entry-offset`,"values.contents.line":`library.theme.contents.line`,"values.contents.indent":`library.theme.contents.indent`,"values.header.enabled":`library.theme.header.enabled`,"values.header.top":`library.theme.header.top`,"values.header.maxTitleCharacters":`library.theme.header.max-title`,"values.footer.enabled":`library.theme.footer.enabled`,"values.footer.text":`library.theme.footer.text`,"values.footer.bottom":`library.theme.footer.bottom`,"values.footer.reserve":`library.theme.footer.reserve`,"values.sources.enabled":`library.theme.sources.enabled`,"values.sources.title":`library.theme.sources.title`,"values.sources.titleOffset":`library.theme.sources.title-offset`,"values.sources.bodyOffset":`library.theme.sources.body-offset`,"values.sources.line":`library.theme.sources.line`,"values.sources.gap":`library.theme.sources.gap`,"values.endPage.enabled":`library.theme.end-page.enabled`,"values.endPage.title":`library.theme.end-page.title`,"values.endPage.lines":`library.theme.end-page.lines`,"values.endPage.showDocumentDetails":`library.theme.end-page.details`,"values.endPage.link":`library.theme.end-page.link`,"values.endPage.closing":`library.theme.end-page.closing`,"values.endPage.titleOffset":`library.theme.end-page.title-offset`,"values.endPage.bodyOffset":`library.theme.end-page.body-offset`,"values.metadata.author":`library.theme.metadata.author`,"values.metadata.subject":`library.theme.metadata.subject`,"values.metadata.keywords":`library.theme.metadata.keywords`,"values.metadata.creator":`library.theme.metadata.creator`};function F4(e,t){let n=k4(t),r=e.filter(e=>e.field===n||e.field.startsWith(`${n}.`));return r.length===0?void 0:r.map(e=>e.message).join(` `)}function Ffe({values:e}){let{api:t}=R(),[n,r]=(0,m.useState)(),[i,a]=(0,m.useState)(`busy`),[o,s]=(0,m.useState)(void 0),c=e===void 0?void 0:JSON.stringify(e);(0,m.useEffect)(()=>{if(c===void 0)return;let e=new AbortController,n=window.setTimeout(()=>{a(`busy`),Ns(t,JSON.parse(c),e.signal).then(async e=>({bytes:new Uint8Array(await e.arrayBuffer()),blob:e})).then(({bytes:t,blob:n})=>{e.signal.aborted||r({bytes:t,url:URL.createObjectURL(n)})},t=>{e.signal.aborted||(s(t instanceof Error?t.message:String(t)),a(`failed`))})},450);return()=>{window.clearTimeout(n),e.abort()}},[t,c]),(0,m.useEffect)(()=>()=>{n!==void 0&&URL.revokeObjectURL(n.url)},[n]);let l=(0,m.useCallback)(e=>{if(e===void 0){a(`idle`);return}s(e.message),a(`failed`)},[]),u=e===void 0?`Paused until the highlighted settings are fixed.`:i===`busy`?`Updating…`:i===`failed`?`The preview couldn't be made: ${o??`unknown error`}`:`A sample article with this theme. Your projects use their own text and thumbnail.`;return(0,h.jsxs)(`div`,{className:j4,children:[(0,h.jsx)(V,{title:`Preview`,info:`library.theme.preview`,size:`small`,className:`pb-0`,children:n===void 0?null:(0,h.jsxs)(dS,{href:n.url,target:`_blank`,rel:`noreferrer`,variant:`secondary`,size:`small`,children:[(0,h.jsx)(hc,{"aria-hidden":`true`,strokeWidth:1.75}),`Open full size`]})}),(0,h.jsx)(`div`,{className:`max-h-[calc(100vh-220px)] min-h-[320px] overflow-y-auto rounded-media bg-sunken p-3`,children:(0,h.jsx)(kfe,{data:n?.bytes,label:`The sample article laid out with this theme`,onDrawn:l})}),(0,h.jsx)(`p`,{role:`status`,className:i===`failed`?`m-0 text-small text-danger`:`m-0 text-small text-ink-2`,children:u})]})}function Ife({field:e,theme:t,problem:n,onChange:r}){let i=(0,m.useId)(),a=Mfe(t,e.path),o=Pfe[k4(e.path)],s=o===void 0?null:(0,h.jsx)(B,{id:o,label:e.label,className:`-my-1`}),c=n=>{r(O4(t,e.path,n))},l=[e.help===void 0?``:`${i}-help`,n===void 0?``:`${i}-error`].filter(e=>e!==``).join(` `),u=(0,h.jsxs)(h.Fragment,{children:[e.help===void 0?null:(0,h.jsx)(`p`,{id:`${i}-help`,className:`sl-field__help m-0`,children:e.help}),n===void 0?null:(0,h.jsx)(`p`,{id:`${i}-error`,className:`sl-field__error m-0`,children:n})]}),d={id:i,"aria-invalid":n!==void 0,"aria-describedby":l===``?void 0:l};switch(e.kind){case`toggle`:return(0,h.jsxs)(`div`,{className:`flex flex-col gap-1 sm:col-span-2`,...Tb,children:[(0,h.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,h.jsxs)(`label`,{htmlFor:i,className:`flex min-h-8 items-center gap-3 text-small font-semibold`,children:[(0,h.jsx)(`input`,{...d,type:`checkbox`,checked:a===!0,className:`size-4 accent-accent`,onChange:e=>{c(e.currentTarget.checked)}}),e.label]}),s]}),u]});case`number`:{let{min:t,max:n}=Nfe(e.path);return(0,h.jsx)(I4,{id:i,label:e.label,notes:u,info:s,children:(0,h.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,h.jsx)(OV,{...d,type:`number`,inputMode:`decimal`,min:t,max:n,step:e.step,className:`w-28`,value:typeof a==`number`&&Number.isFinite(a)?a:``,onChange:e=>{c(e.target.value===``?NaN:Number(e.target.value))}}),(0,h.jsx)(`span`,{className:`text-small text-ink-2`,children:e.unit})]})})}case`color`:{let t=typeof a==`string`?a:``,n=/^#?[0-9a-f]{6}$/i.test(t)?`#${t.replace(`#`,``)}`:/^#?[0-9a-f]{3}$/i.test(t)?`#${[...t.replace(`#`,``)].map(e=>e+e).join(``)}`:`#000000`;return(0,h.jsx)(I4,{id:i,label:e.label,notes:u,info:s,children:(0,h.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,h.jsx)(`input`,{type:`color`,"aria-label":`${e.label} colour`,value:n,className:`h-8 w-10 cursor-pointer rounded-control border border-line-strong bg-transparent p-0.5`,onChange:e=>{c(e.target.value)}}),(0,h.jsx)(OV,{...d,className:`w-28 font-mono`,value:t,onChange:e=>{c(e.target.value)}})]})})}case`text`:return(0,h.jsx)(I4,{id:i,label:e.label,notes:u,info:s,children:(0,h.jsx)(OV,{...d,value:typeof a==`string`?a:``,onChange:e=>{c(e.target.value)}})});case`optional-text`:return(0,h.jsx)(I4,{id:i,label:e.label,notes:u,info:s,children:(0,h.jsx)(OV,{...d,value:typeof a==`string`?a:``,onChange:e=>{c(e.target.value===``?null:e.target.value)}})});case`choice`:{let t=e.options.findIndex(e=>e.value===a);return(0,h.jsx)(I4,{id:i,label:e.label,notes:u,info:s,children:(0,h.jsx)(AV,{...d,value:String(t),onChange:t=>{let n=e.options[Number(t.target.value)];n!==void 0&&c(n.value)},children:e.options.map((e,t)=>(0,h.jsx)(`option`,{value:String(t),children:e.label},e.label))})})}case`face`:{let t=a,n=D4(t.family);return(0,h.jsx)(I4,{id:i,label:e.label,notes:u,info:s,children:(0,h.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,h.jsx)(AV,{...d,"aria-label":`${e.label} font`,value:t.family,onChange:e=>{let n=E4.find(t=>t.value===e.target.value);if(n===void 0)return;let r=D4(n.value).some(e=>e.value===t.style);c({...t,family:n.value,style:r?t.style:`normal`})},children:E4.map(e=>(0,h.jsx)(`option`,{value:e.value,children:e.label},e.value))}),(0,h.jsx)(AV,{"aria-label":`${e.label} style`,value:t.style,onChange:e=>{c({...t,style:e.target.value})},children:n.map(e=>(0,h.jsx)(`option`,{value:e.value,children:e.label},e.value))}),(0,h.jsx)(OV,{type:`number`,"aria-label":`${e.label} letter spacing in millimetres`,title:`Letter spacing (mm)`,step:.01,className:`w-20`,value:Number.isFinite(t.letterSpacing)?t.letterSpacing:``,onChange:e=>{c({...t,letterSpacing:e.target.value===``?NaN:Number(e.target.value)})}})]})})}case`lines`:return(0,h.jsxs)(`div`,{className:`flex flex-col gap-1 sm:col-span-2`,...Tb,children:[(0,h.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,h.jsx)(`label`,{htmlFor:i,className:`sl-field__label`,children:e.label}),s]}),(0,h.jsx)(kV,{...d,rows:8,value:Array.isArray(a)?a.join(`
273
273
  `):``,onChange:e=>{c(e.target.value.split(`
274
274
  `))}}),u]});case`link`:{let t=a;return(0,h.jsxs)(`div`,{className:`flex flex-col gap-1 sm:col-span-2`,...Tb,children:[(0,h.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,h.jsxs)(`label`,{htmlFor:i,className:`flex min-h-8 items-center gap-3 text-small font-semibold`,children:[(0,h.jsx)(`input`,{id:i,type:`checkbox`,checked:t!==null,className:`size-4 accent-accent`,onChange:e=>{c(e.currentTarget.checked?{text:`Visit the website`,url:null}:null)}}),e.label]}),s]}),t===null?null:(0,h.jsxs)(`span`,{className:`grid grid-cols-[minmax(0,1fr)] gap-2 sm:grid-cols-2`,children:[(0,h.jsx)(OV,{"aria-label":`Link text`,placeholder:`Link text`,value:t.text,onChange:e=>{c({...t,text:e.target.value})}}),(0,h.jsx)(OV,{"aria-label":`Link address`,placeholder:`https://`,value:t.url??``,onChange:e=>{c({...t,url:e.target.value===``?null:e.target.value})}})]}),u]})}}}function I4({id:e,label:t,notes:n,info:r,children:i}){return(0,h.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,...Tb,children:[(0,h.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,h.jsx)(`label`,{htmlFor:e,className:`sl-field__label`,children:t}),r]}),i,n]})}function L4({children:e}){return(0,h.jsx)(N4,{back:(0,h.jsx)(pa,{to:`/document-themes`,children:`Back to Documents`}),children:e})}var Lfe=4e3;function R4(e){return e.match(/\s+|[^\s]+/gu)??[]}function Rfe(e,t){let n=R4(e),r=R4(t),i=0;for(;i<n.length&&i<r.length&&n[i]===r[i];)i+=1;let a=0;for(;a<n.length-i&&a<r.length-i&&n[n.length-1-a]===r[r.length-1-a];)a+=1;let o=[];B4(o,`same`,n.slice(0,i).join(``));let s=n.slice(i,n.length-a),c=r.slice(i,r.length-a);for(let e of Bfe(s,c))B4(o,e.op,e.text);return B4(o,`same`,n.slice(n.length-a).join(``)),o}function z4(e,t){let n=t===`before`?`added`:`removed`;return e.filter(e=>e.op!==n)}function zfe(e){let t=t=>e.filter(e=>e.op===t).reduce((e,t)=>e+R4(t.text).filter(e=>e.trim()!==``).length,0);return{added:t(`added`),removed:t(`removed`)}}function B4(e,t,n){if(n===``)return;let r=e.at(-1);r!==void 0&&r.op===t?e[e.length-1]={op:t,text:r.text+n}:e.push({op:t,text:n})}function Bfe(e,t){if(e.length===0&&t.length===0)return[];if(e.length===0)return[{op:`added`,text:t.join(``)}];if(t.length===0)return[{op:`removed`,text:e.join(``)}];let n=e.length,r=t.length,i=Math.min(n+r,Lfe),a=i+1,o=new Int32Array(2*i+3),s=[],c=!1;for(let l=0;l<=i&&!c;l+=1){s.push(o.slice());let i=o.slice();for(let s=-l;s<=l;s+=2){let u=s===-l||s!==l&&(o[a+s-1]??0)<(o[a+s+1]??0)?o[a+s+1]??0:(o[a+s-1]??0)+1,d=u-s;for(;u<n&&d<r&&e[u]===t[d];)u+=1,d+=1;if(i[a+s]=u,u>=n&&d>=r){c=!0;break}}o=i}if(!c)return[{op:`removed`,text:e.join(``)},{op:`added`,text:t.join(``)}];let l=[],u=n,d=r;for(let n=s.length-1;n>=0;--n){let r=s[n]??new Int32Array,i=u-d,o=i===-n||i!==n&&(r[a+i-1]??0)<(r[a+i+1]??0),c=o?i+1:i-1,f=r[a+c]??0,p=f-c;for(;u>f&&d>p;)l.push({op:`same`,text:e[u-1]??``}),--u,--d;n>0&&(o?l.push({op:`added`,text:t[d-1]??``}):l.push({op:`removed`,text:e[u-1]??``}),u=f,d=p)}let f=[];for(let e of l.reverse())B4(f,e.op,e.text);return f}function V4({before:e,after:t,beforeLabel:n,afterLabel:r}){let i=(0,m.useMemo)(()=>Rfe(e,t),[e,t]),a=zfe(i);return(0,h.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2`,children:[(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:a.added===0&&a.removed===0?`The two texts are the same.`:`${String(a.added)} ${a.added===1?`word`:`words`} added, ${String(a.removed)} removed.`}),(0,h.jsxs)(`div`,{className:`grid min-w-0 grid-cols-1 gap-4 md:grid-cols-2`,children:[(0,h.jsx)(H4,{label:n,parts:z4(i,`before`)}),(0,h.jsx)(H4,{label:r,parts:z4(i,`after`)})]})]})}function H4({label:e,parts:t}){return(0,h.jsxs)(`section`,{"aria-label":e,className:`flex min-w-0 flex-col gap-1`,children:[(0,h.jsx)(`h4`,{className:`sl-kicker m-0`,children:e}),(0,h.jsx)(`div`,{className:`min-w-0 whitespace-pre-wrap break-words border-l-2 border-line pl-3 text-small leading-relaxed text-ink`,children:Vfe(t).map(({key:e,part:t})=>t.op===`removed`?(0,h.jsx)(`del`,{className:`rounded-[2px] bg-danger-tint text-danger line-through`,children:t.text},e):t.op===`added`?(0,h.jsx)(`ins`,{className:`rounded-[2px] bg-accent-tint text-accent-ink no-underline`,children:t.text},e):(0,h.jsx)(`span`,{children:t.text},e))})]})}function Vfe(e){let t=0;return e.map(e=>{let n=`${e.op}-${String(t)}`;return t+=e.text.length,{key:n,part:e}})}var U4={versions:(e,t)=>[`library-history`,e,t],usedBy:(e,t)=>[`library-used-by`,e,t]};function W4(e,t){let{api:n}=R();return M({queryKey:U4.versions(e,t),queryFn:()=>Ts(n,e,t)})}function Hfe(e,t){let{api:n}=R();return M({queryKey:U4.usedBy(e,t),queryFn:()=>Es(n,e,t)})}function G4({item:e,id:t,name:n,onClose:r}){let{api:i}=R(),a=_(),o=W4(e,t),s=o.data?.versions??[],[c,l]=(0,m.useState)({}),u=c.after??s[0]?.version,d=c.before??s[1]?.version??u,f=s.find(e=>e.version===d),p=s.find(e=>e.version===u),[g,v]=(0,m.useState)(),y=N({mutationFn:n=>Ds(i,e,t,n),onSuccess:async(n,r)=>{v(`Restored version ${String(r)} as a new version.`),l({}),await Promise.all([a.invalidateQueries({queryKey:U4.versions(e,t)}),a.invalidateQueries({queryKey:e===`prompt`?z.prompts:z.entries})])},onError:()=>v(void 0)}),b=s[0]?.version;return(0,h.jsx)(HP,{open:!0,title:`History of ${n}`,onClose:r,className:`sm:w-[min(1080px,100vw)]`,children:(0,h.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[o.error===null?null:(0,h.jsx)(`p`,{className:`m-0 text-body text-danger`,children:`The history couldn't be read: ${o.error.message}`}),(0,h.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,h.jsx)(V,{title:`Compare`,as:`h3`}),(0,h.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 sm:grid-cols-2`,children:[(0,h.jsx)(Y,{label:`Older`,tip:`library.history.compare`,children:(0,h.jsx)(AV,{value:d===void 0?``:String(d),disabled:s.length===0,onChange:e=>l(t=>({...t,before:Number(e.currentTarget.value)})),children:s.map(e=>(0,h.jsx)(`option`,{value:e.version,children:q4(e,b)},e.version))})}),(0,h.jsx)(Y,{label:`Newer`,tip:`library.history.compare`,children:(0,h.jsx)(AV,{value:u===void 0?``:String(u),disabled:s.length===0,onChange:e=>l(t=>({...t,after:Number(e.currentTarget.value)})),children:s.map(e=>(0,h.jsx)(`option`,{value:e.version,children:q4(e,b)},e.version))})})]}),f===void 0||p===void 0?(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:o.isPending?`Loading the versions…`:`No versions to compare.`}):(0,h.jsxs)(h.Fragment,{children:[f.name===p.name?null:(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:`Renamed from "${f.name}" to "${p.name}".`}),(0,h.jsx)(V4,{before:f.body,after:p.body,beforeLabel:`Version ${String(f.version)}`,afterLabel:`Version ${String(p.version)}`})]})]}),(0,h.jsxs)(`section`,{className:`flex flex-col gap-2`,children:[(0,h.jsx)(V,{title:`Versions`,as:`h3`,info:`library.history.versions`}),(0,h.jsx)(hU,{label:`Versions of ${n}`,children:s.map(e=>(0,h.jsx)(gU,{title:`Version ${String(e.version)}`,meta:K4(e),actions:e.version===b?(0,h.jsx)(`span`,{className:`text-small text-ink-2`,children:`Current`}):(0,h.jsx)(L,{size:`small`,"aria-label":`Restore version ${String(e.version)}`,disabled:y.isPending,disabledReason:`Restoring a version`,onClick:()=>{v(void 0),y.mutate(e.version)},children:`Restore`})},e.version))}),(0,h.jsx)(v0,{tone:y.error===null?`success`:`error`,children:y.error?.message??g})]})]})})}function K4(e){return`${e.author} · ${J4(e.createdAt)}${e.restoredFrom===null?``:` · restored from version ${String(e.restoredFrom)}`}`}function q4(e,t){return`Version ${String(e.version)}${e.version===t?` (current)`:``} · ${J4(e.createdAt)}`}function J4(e){let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`})}function Y4({item:e,id:t,name:n,kicker:r,meta:i,body:a,slots:o,actions:s,onOpenHistory:c}){return(0,h.jsxs)(`section`,{"aria-label":`${n} details`,className:`flex min-w-0 flex-col gap-6`,children:[(0,h.jsx)(V,{title:n,kicker:r,meta:i,className:`pb-0`,children:s}),(0,h.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,h.jsx)(`div`,{className:`m-0 max-h-[420px] min-w-0 overflow-y-auto whitespace-pre-wrap break-words rounded-media bg-sunken p-4 font-mono text-small text-ink-2`,children:a}),o.length===0?(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:`No keywords. It runs as written.`}):(0,h.jsx)(`ul`,{"aria-label":`Keywords`,className:`m-0 flex list-none flex-wrap gap-2 p-0`,children:o.map(e=>(0,h.jsx)(`li`,{children:(0,h.jsx)(jV,{children:`{{${e}}}`})},e))})]}),(0,h.jsx)(Ufe,{item:e,id:t}),(0,h.jsx)(Wfe,{item:e,id:t,name:n,onOpenHistory:c})]})}function Ufe({item:e,id:t}){let n=Hfe(e,t),r=n.data;return(0,h.jsxs)(`section`,{className:`flex flex-col gap-2`,children:[(0,h.jsx)(V,{title:`Used by`,as:`h3`,className:`pb-0`,info:`library.used-by`,...r===void 0?{}:{meta:Gfe(r)}}),n.error===null?null:(0,h.jsx)(`p`,{className:`m-0 text-small text-danger`,children:`What uses it couldn't be read: ${n.error.message}`}),r===void 0?null:r.templates.length+r.schedules.length+r.projects.length===0?(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:`Nothing uses it yet.`}):(0,h.jsxs)(hU,{label:`Used by`,children:[r.templates.map(e=>(0,h.jsx)(gU,{title:(0,h.jsx)(pa,{to:`/templates`,children:e.name}),meta:`Template`},`t-${e.id}`)),r.schedules.map(e=>(0,h.jsx)(gU,{title:(0,h.jsx)(pa,{to:`/calendar`,search:{tab:`schedules`,schedule:e.id},children:e.name}),meta:e.status===`paused`?`Schedule · paused`:`Schedule`},`s-${e.id}`)),r.projects.map(e=>(0,h.jsx)(gU,{title:(0,h.jsx)(pa,{to:`/projects/$projectId`,params:{projectId:e.id},children:e.title}),meta:`Project${e.totalRevisions===0?``:` · ${String(e.revisions)} of ${String(e.totalRevisions)} ${e.totalRevisions===1?`revision`:`revisions`}${e.current?`, including the current one`:`, not the current one`}`}`},`p-${e.id}`))]})]})}function Wfe({item:e,id:t,name:n,onOpenHistory:r}){let i=W4(e,t),a=i.data?.versions??[],[o,s]=a;return(0,h.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,h.jsx)(V,{title:`History`,as:`h3`,className:`pb-0`,info:`library.history`,...o===void 0?{}:{meta:`${X4(a.length,`version`)} · latest ${K4(o)}`},children:(0,h.jsx)(L,{size:`small`,"aria-label":`Compare versions of ${n}`,onClick:r,children:`Compare versions`})}),i.error===null?null:(0,h.jsx)(`p`,{className:`m-0 text-small text-danger`,children:`The history couldn't be read: ${i.error.message}`}),o===void 0?null:s===void 0?(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:`Only one version so far.`}):(0,h.jsx)(V4,{before:s.body,after:o.body,beforeLabel:`Version ${String(s.version)}`,afterLabel:`Version ${String(o.version)}`})]})}function Gfe(e){return[X4(e.templates.length,`template`),X4(e.schedules.length,`schedule`),X4(e.projects.length,`project`)].join(`, `)}function X4(e,t){return`${String(e)} ${t}${e===1?``:`s`}`}function Z4(e){let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleDateString(void 0,{dateStyle:`medium`})}var Q4=`min-[1180px]:grid-cols-[minmax(0,1fr)_minmax(0,1fr)]`,$4=`grid-cols-1 2xl:grid-cols-[minmax(0,1fr)_auto]`;function e3({label:e}){return(0,h.jsx)(`ul`,{"aria-label":`${e}, loading`,"aria-busy":`true`,className:`sl-list m-0 list-none p-0`,children:[0,1,2].map(e=>(0,h.jsx)(`li`,{className:`sl-row`,"aria-hidden":`true`,children:(0,h.jsxs)(`span`,{className:`flex flex-col gap-2 py-0.5`,children:[(0,h.jsx)(`span`,{className:`h-3 w-40 rounded-control bg-sunken`}),(0,h.jsx)(`span`,{className:`h-3 w-56 rounded-control bg-sunken`})]})},e))})}function t3({what:e,message:t,onRetry:n}){return(0,h.jsx)(fI,{tone:`danger`,title:`The ${e} couldn't be loaded.`,actions:(0,h.jsx)(L,{size:`small`,onClick:n,children:`Try again`}),children:t})}function n3({name:e,edit:t,duplicate:n,play:r,onHistory:i,onDelete:a,className:o}){return(0,h.jsxs)(`div`,{role:`group`,"aria-label":`Actions for ${e}`,className:I(`flex flex-wrap items-center gap-0.5`,o),children:[t,n,r===void 0?null:(0,h.jsx)(L,{variant:`quiet`,size:`small`,"aria-label":`Use ${e} in Play`,title:r.blocked,disabled:r.run===void 0||r.blocked!==void 0,onClick:r.run,children:`Use in Play`}),i===void 0?null:(0,h.jsx)(Cy,{size:`small`,label:`History of ${e}`,onClick:i,children:(0,h.jsx)(Mc,{"aria-hidden":`true`})}),(0,h.jsx)(Cy,{size:`small`,label:`Delete ${e}`,onClick:a,children:(0,h.jsx)(Ic,{"aria-hidden":`true`})})]})}var Kfe=[{to:`/prompts`,label:`Prompts`},{to:`/entries`,label:`Intros & Outros`},{to:`/templates`,label:`Templates`},{to:`/document-themes`,label:`Documents`},{to:`/narration-aliases`,label:`Aliases`}];function qfe(){return(0,h.jsxs)(`div`,{children:[(0,h.jsx)(Aq,{title:`Library`,meta:`Prompts, intros and outros, templates, document themes and narration aliases`}),(0,h.jsx)(Due,{items:Kfe,label:`Library sections`,className:`mb-6`}),(0,h.jsx)(Jfe,{}),(0,h.jsx)(Oa,{})]})}function Jfe(){let e=Xi(),t=Ra({select:e=>e.location}),n=t.search,r=xV(t.pathname===`/prompts`?n.kind:void 0),i=vV(t.pathname===`/entries`?n.category:void 0);return _x({id:`library.new-prompt`,title:`New prompt`,group:`Library`,keywords:[`create`,`article`,`image`,`thumbnail`],run:()=>{e({to:`/prompts/new`,search:{kind:r}})}}),_x({id:`library.new-entry`,title:`New intro or outro`,group:`Library`,keywords:[`create`,`entry`],run:()=>{e({to:`/entries/new`,search:{category:i}})}}),_x({id:`library.new-document-theme`,title:`New document theme`,group:`Library`,keywords:[`create`,`pdf`,`theme`],run:()=>{e({to:`/document-themes/new`,search:{from:`plain`}})}}),_x({id:`library.open-prompts`,title:`Open prompts`,group:`Library`,run:()=>{e({to:`/prompts`,search:{kind:`article`}})}}),_x({id:`library.open-entries`,title:`Open intros and outros`,group:`Library`,keywords:[`entries`],run:()=>{e({to:`/entries`,search:{category:`intro`}})}}),_x({id:`library.open-templates`,title:`Open templates`,group:`Library`,keywords:[`setups`],run:()=>{e({to:`/templates`})}}),_x({id:`library.open-document-themes`,title:`Open document themes`,group:`Library`,keywords:[`pdf`,`documents`],run:()=>{e({to:`/document-themes`})}}),null}function r3({children:e,action:t,className:n}){return(0,h.jsxs)(`div`,{"data-slot":`library-toolbar`,className:I(`mb-5 flex min-h-9 flex-wrap items-center gap-x-4 gap-y-3`,n),children:[(0,h.jsx)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-center gap-3`,children:e}),t===void 0?null:(0,h.jsx)(Ty,{className:`ml-auto shrink-0`,children:t})]})}function Yfe(){let{api:e}=R(),t=_(),n=M(tb(e)),[r,i]=(0,m.useState)(void 0),[a,o]=(0,m.useState)(void 0),s=N({mutationFn:t=>Ms(e,t),onSettled:async()=>{o(void 0),await t.invalidateQueries({queryKey:z.documentThemes})}}),c=n.data,l=r!==void 0&&`saved`in r?c?.themes.find(e=>e.id===r.saved):void 0,u=r!==void 0&&`builtIn`in r?c?.builtIns.find(e=>e.name===r.builtIn):void 0,d=l===void 0&&u===void 0?c?.themes[0]:void 0,f=l??d,p=f===void 0?u??c?.builtIns[0]:void 0;return(0,h.jsxs)(`div`,{children:[(0,h.jsx)(r3,{action:(0,h.jsx)(lS,{to:`/document-themes/new`,search:{from:`plain`},variant:`primary`,children:`New theme`}),children:(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:`How a project's PDF looks. Pick one on the Document row in Play or in Edit project.`})}),n.error===null?null:(0,h.jsx)(t3,{what:`document themes`,message:n.error.message,onRetry:()=>void n.refetch()}),c===void 0?n.error===null?(0,h.jsx)(e3,{label:`Document themes`}):null:(0,h.jsx)(Mq,{className:Q4,list:(0,h.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[(0,h.jsxs)(`section`,{className:`flex flex-col gap-2`,children:[(0,h.jsx)(V,{title:`Your themes`,as:`h3`,className:`pb-0`,info:`library.themes.yours`}),c.themes.length===0?(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:`No themes of your own yet. Copy a built-in below to start one.`}):(0,h.jsx)(hU,{label:`Your themes`,children:c.themes.map(e=>(0,h.jsx)(gU,{className:$4,lead:(0,h.jsx)(l3,{colors:e.values.colors}),title:e.name,meta:`${i3(e.values)} · updated ${Z4(e.updatedAt)}`,selected:e.id===f?.id,onSelect:()=>i({saved:e.id}),actions:(0,h.jsx)(n3,{name:e.name,edit:(0,h.jsx)(lS,{to:`/document-themes/$themeId`,params:{themeId:e.id},"aria-label":`Edit ${e.name}`,variant:`quiet`,size:`small`,children:`Edit`}),duplicate:(0,h.jsx)(lS,{to:`/document-themes/new`,search:{from:e.id},"aria-label":`Duplicate ${e.name}`,variant:`quiet`,size:`small`,children:`Duplicate`}),onDelete:()=>o(e)})},e.id))})]}),(0,h.jsxs)(`section`,{className:`flex flex-col gap-2`,children:[(0,h.jsx)(V,{title:`Built in`,as:`h3`,className:`pb-0`,info:`library.themes.built-in`}),(0,h.jsx)(hU,{label:`Built-in themes`,children:c.builtIns.map(e=>(0,h.jsx)(gU,{className:$4,lead:(0,h.jsx)(l3,{colors:e.values.colors}),title:e.label,meta:i3(e.values),selected:e.name===p?.name,onSelect:()=>i({builtIn:e.name}),actions:(0,h.jsx)(lS,{to:`/document-themes/new`,search:{from:e.name},"aria-label":`Copy ${e.label}`,variant:`quiet`,size:`small`,children:`Copy`})},e.name))})]})]}),detail:f===void 0?p===void 0?null:(0,h.jsx)(s3,{name:p.label,kicker:`Built in`,meta:`Built-in themes can't be changed. Copy one to make it yours.`,values:p.values,action:(0,h.jsx)(lS,{to:`/document-themes/new`,search:{from:p.name},size:`small`,children:`Copy theme`})}):(0,h.jsx)(s3,{name:f.name,kicker:`Your theme`,meta:`Updated ${Z4(f.updatedAt)}`,values:f.values,action:(0,h.jsx)(lS,{to:`/document-themes/$themeId`,params:{themeId:f.id},size:`small`,children:`Edit theme`})})}),s.error===null?null:(0,h.jsx)(fI,{tone:`danger`,title:`The theme wasn't deleted.`,className:`mt-4`,children:s.error.message}),(0,h.jsx)(Ay,{open:a!==void 0,title:`Delete "${a?.name??``}"?`,consequence:`Projects that used it keep their own copy of its settings.`,confirmLabel:`Delete theme`,pending:s.isPending,onConfirm:()=>{a!==void 0&&s.mutate(a.id)},onCancel:()=>o(void 0)})]})}function i3(e){return`${e.page.format===`a4`?`A4`:`Letter`} · ${a3(e.fonts.body.family)} body`}function a3(e){return E4.find(t=>t.value===e)?.label??e}function o3(e){return e.startsWith(`#`)?e:`#${e}`}function s3({name:e,kicker:t,meta:n,values:r,action:i}){let a=[[`Headings`,r.colors.heading],[`Text`,r.colors.text],[`Muted`,r.colors.muted],[`Header and page numbers`,r.colors.faint]],o=[[`Body`,r.fonts.body],[`Headings`,r.fonts.heading],[`Drop cap`,r.fonts.dropCap]];return(0,h.jsxs)(`section`,{"aria-label":`${e} details`,className:`flex min-w-0 flex-col gap-6`,children:[(0,h.jsx)(V,{title:e,kicker:t,meta:n,className:`pb-0`,children:i}),(0,h.jsxs)(`dl`,{className:`m-0 grid grid-cols-1 gap-x-6 gap-y-3 sm:grid-cols-[max-content_minmax(0,1fr)]`,children:[a.map(([e,t])=>(0,h.jsx)(c3,{label:e,children:(0,h.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,h.jsx)(`span`,{"aria-hidden":`true`,className:`size-4 rounded-full border border-line`,style:{backgroundColor:o3(t)}}),(0,h.jsx)(`span`,{className:`font-mono text-small`,children:o3(t)})]})},e)),o.map(([e,t])=>(0,h.jsx)(c3,{label:`${e} font`,children:`${a3(t.family)}, ${t.style}`},`font-${e}`)),(0,h.jsx)(c3,{label:`Page`,children:`${r.page.format===`a4`?`A4`:`Letter`}, ${r.background.image===`parchment`?`parchment`:`flat ${o3(r.background.color)}`} background`})]})]})}function c3({label:e,children:t}){return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`dt`,{className:`text-small text-ink-2`,children:e}),(0,h.jsx)(`dd`,{className:`m-0 min-w-0 text-body text-ink`,children:t})]})}function l3({colors:e}){return(0,h.jsx)(`span`,{"aria-hidden":`true`,className:`flex shrink-0 gap-1`,children:[e.heading,e.text,e.muted].map((e,t)=>(0,h.jsx)(`span`,{className:`size-3 rounded-full border border-line`,style:{backgroundColor:o3(e)}},t))})}function u3(e){let t=e.map(e=>e.message).join(` `);return`The name wasn't saved. ${t===``?`Pick another name and press Save name again.`:t}`}function d3({name:e,onSelect:t,onRename:n,tip:r=`library.inline-rename`,maxLength:i=200}){let a=Dy(),[o,s]=(0,m.useState)(!1),[c,l]=(0,m.useState)(e),[u,d]=(0,m.useState)(null),[f,p]=(0,m.useState)(!1),g=(0,m.useRef)(!1),_=async e=>{try{return await n(e)}catch(e){return`The name wasn't saved: ${e instanceof Error?e.message:`Slopify didn't answer.`} Check that Slopify is running, then press Save name again.`}},v=async()=>{let t=c.trim();if(t===e){s(!1),d(null);return}if(t===``){d(`Write a name first, or press Cancel to keep the old one.`);return}if(g.current)return;g.current=!0,p(!0);let n=await _(t);if(g.current=!1,p(!1),n!==null){d(n);return}s(!1),d(null),a(`Renamed “${e}” to “${t}”.`,`success`,{label:`Undo`,run:()=>void _(e).then(t=>{t===null?a(`Renamed back to “${e}”.`,`success`):a(t,`error`)})})},y=()=>{s(!1),l(e),d(null)};return o?(0,h.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-1`,...Tb,children:[(0,h.jsxs)(`span`,{className:`flex min-w-0 flex-wrap items-center gap-1`,children:[(0,h.jsx)(OV,{autoFocus:!0,"aria-label":`New name for ${e}`,"aria-invalid":u!==null,maxLength:i,value:c,className:`min-w-0 flex-1`,onChange:e=>{l(e.target.value),d(null)},onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),v()):e.key===`Escape`&&(e.preventDefault(),y())}}),(0,h.jsx)(L,{size:`small`,variant:`primary`,disabled:f,onClick:()=>void v(),children:f?`Saving…`:`Save name`}),(0,h.jsx)(L,{size:`small`,variant:`quiet`,disabled:f,onClick:y,children:`Cancel`}),(0,h.jsx)(B,{id:r,label:`Rename`})]}),u===null?null:(0,h.jsx)(`span`,{role:`alert`,className:`text-small font-normal text-danger`,children:u})]}):(0,h.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-1`,children:[t===void 0?(0,h.jsx)(`span`,{className:`min-w-0 break-words`,children:e}):(0,h.jsx)(_U,{onSelect:t,className:`min-w-0`,children:e}),(0,h.jsx)(Cy,{size:`small`,label:`Rename ${e}`,onClick:()=>{l(e),s(!0)},children:(0,h.jsx)(Ec,{"aria-hidden":`true`,strokeWidth:1.75})})]})}function Xfe({category:e,onCategory:t,onUseInPlay:n,playBlocked:r}){let{api:i}=R(),a=_(),o=M(eb(i)),[s,c]=(0,m.useState)(``),l=(0,m.useRef)(null),u=vx(l,`intros and outros`),[d,f]=(0,m.useState)(void 0),[p,g]=(0,m.useState)(void 0),[v,y]=(0,m.useState)(void 0),b=N({mutationFn:e=>Ls(i,e),onSettled:async()=>{g(void 0),await a.invalidateQueries({queryKey:z.entries})}}),x=async(e,t)=>{let n=await ks(i,{category:e.category,mode:e.mode,name:t,body:e.body},e.id);return await a.invalidateQueries({queryKey:z.entries}),n.ok?null:u3(n.fields)},S=o.data?.entries.filter(t=>t.category===e),C=s.trim().toLowerCase(),w=C===``?S:S?.filter(e=>e.name.toLowerCase().includes(C)||e.body.toLowerCase().includes(C)),T=w?.find(e=>e.id===d)??w?.[0];return(0,h.jsxs)(`div`,{children:[(0,h.jsxs)(r3,{action:(0,h.jsx)(lS,{to:`/entries/new`,search:{category:e},variant:`primary`,children:`New intro or outro`}),children:[(0,h.jsx)(OV,{type:`search`,ref:l,"aria-label":`Search intros and outros`,"aria-keyshortcuts":kx(u),placeholder:`Search intros and outros`,value:s,className:`w-full min-w-0 sm:w-64`,onChange:e=>c(e.target.value)}),(0,h.jsx)(Db,{label:`Entry category`,value:e,options:fV.map(e=>({...e,label:`${e.label}s`})),onChange:t,tip:`library.entry.category`})]}),o.error===null?null:(0,h.jsx)(t3,{what:`intros and outros`,message:o.error.message,onRetry:()=>void o.refetch()}),w===void 0||S===void 0?o.error===null?(0,h.jsx)(e3,{label:`Intros and outros`}):null:S.length===0?(0,h.jsx)(Qfe,{category:e}):(0,h.jsx)(Mq,{className:Q4,list:w.length===0?(0,h.jsx)(`p`,{className:`m-0 py-3 text-small text-ink-2`,children:`No ${e}s match "${s.trim()}".`}):(0,h.jsx)(hU,{label:`${mV(e)}s`,children:w.map(e=>(0,h.jsx)(gU,{className:$4,title:(0,h.jsx)(d3,{name:e.name,onSelect:()=>f(e.id),onRename:t=>x(e,t)}),meta:Zfe(e),selected:e.id===T?.id,actions:(0,h.jsx)(n3,{name:e.name,edit:(0,h.jsx)(lS,{to:`/entries/$entryId`,params:{entryId:e.id},"aria-label":`Edit ${e.name}`,variant:`quiet`,size:`small`,children:`Edit`}),duplicate:(0,h.jsx)(lS,{to:`/entries/new`,search:{category:e.category,from:e.id},"aria-label":`Duplicate ${e.name}`,variant:`quiet`,size:`small`,children:`Duplicate`}),play:{run:n===void 0?void 0:()=>n(e),blocked:r},onHistory:()=>y(e),onDelete:()=>g(e)})},e.id))}),detail:T===void 0?null:(0,h.jsx)(Y4,{item:`entry`,id:T.id,name:T.name,kicker:`${mV(T.category)} · ${hV(T.mode)}`,meta:`Updated ${Z4(T.updatedAt)}`,body:T.body,slots:T.slots,actions:(0,h.jsx)(lS,{to:`/entries/$entryId`,params:{entryId:T.id},size:`small`,children:`Edit ${T.category}`}),onOpenHistory:()=>y(T)},T.id)}),b.error===null?null:(0,h.jsx)(fI,{tone:`danger`,title:`The ${e} wasn't deleted.`,className:`mt-4`,children:b.error.message}),v===void 0?null:(0,h.jsx)(G4,{item:`entry`,id:v.id,name:v.name,onClose:()=>y(void 0)},v.id),(0,h.jsx)(Ay,{open:p!==void 0,title:p===void 0?``:`Delete "${p.name}"?`,consequence:`Moves it to the trash for 30 days (Settings → Trash). Projects that used it keep their text.`,confirmLabel:`Delete ${p?.category??e}`,pending:b.isPending,onConfirm:()=>{p!==void 0&&b.mutate(p.id)},onCancel:()=>g(void 0)})]})}function Zfe(e){return`${hV(e.mode)} · ${X4(e.slots.length,`keyword`)} · updated ${Z4(e.updatedAt)}`}function Qfe({category:e}){let t=e===`intro`?`before`:`after`;return(0,h.jsx)(T0,{title:`No ${e}s yet`,children:`An ${e} is narrated ${t} the body in the run's voice.`})}function $fe({name:e,className:t}){return(0,h.jsx)(`span`,{"data-slot-chip":e,className:I(`animate-tick-in rounded-control border border-line-strong bg-sunken px-2 py-0.5 font-mono text-label text-ink-2 motion-reduce:animate-none`,t),children:e})}function f3({slots:e,body:t,lint:n,lintId:r,noSlots:i=`No slots. This prompt runs as written.`}){return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(V,{title:`Detected slots`,info:`library.slots`,size:`small`,className:`pb-0`}),e.length>0?(0,h.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:e.map(e=>(0,h.jsx)($fe,{name:e,className:`px-2 py-1`},e))}):t.trim()===``?(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-3`,children:`Slots appear here as you type {{name}}.`}):(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:i}),n.length===0?null:(0,h.jsxs)(`div`,{id:r,className:`flex flex-col gap-2 border-t border-line pt-3`,children:[(0,h.jsx)(`span`,{className:`sl-kicker text-danger`,children:n.length===1?`1 slot error`:`${String(n.length)} slot errors`}),n.map(e=>(0,h.jsx)(`span`,{className:`text-small text-danger`,children:e.message},e.message))]})]})}function p3({className:e,...t}){return(0,h.jsx)(Vv,{"data-slot":`label`,className:I(`engraved block select-none text-ink-3`,e),...t})}function m3({className:e,...t}){return(0,h.jsx)(Jee,{"data-slot":`toggle-group`,className:I(`inline-flex w-fit items-stretch overflow-hidden rounded-control border border-line-strong`,e),...t})}function h3({className:e,...t}){return(0,h.jsx)($ee,{"data-slot":`toggle-group-item`,className:I(`min-h-8 shrink-0 border-r border-line-strong px-3 py-1 text-label text-ink-2 last:border-r-0`,`transition-colors duration-150 ease-out motion-reduce:transition-none hover:bg-raised hover:text-ink`,`data-[state=on]:bg-raised data-[state=on]:text-ink data-[state=on]:shadow-[inset_0_-2px_0_var(--color-accent)]`,`disabled:cursor-not-allowed disabled:opacity-40`,e),...t})}function g3({label:e,value:t,options:n,describedBy:r,tip:i,onPick:a}){let o=(0,m.useId)();return(0,h.jsxs)(`div`,{...Tb,children:[(0,h.jsxs)(`div`,{className:`mb-1 flex items-center gap-1`,children:[(0,h.jsx)(p3,{id:o,children:e}),i===void 0?null:(0,h.jsx)(B,{id:i,label:e,className:`-my-1`})]}),(0,h.jsx)(m3,{type:`single`,value:t,"aria-labelledby":o,"aria-describedby":r,onValueChange:e=>{let t=n.find(t=>t.value===e);t!==void 0&&a(t.value)},children:n.map(e=>(0,h.jsx)(h3,{value:e.value,children:e.label},e.value))})]})}function epe(e){return _3(e.name,e.body)}function tpe(e){return _3(e.name,e.body)}function _3(e,t){let n=[],r=e.trim();if(r===``?n.push({field:`name`,message:`Enter a name.`}):r.length>200&&n.push({field:`name`,message:`Keep the name to 200 characters or fewer.`}),t.trim()===``)return n.push({field:`body`,message:`Enter the text.`}),n;if(t.length>1e5)return n.push({field:`body`,message:`The text is too long. Keep it to ${String(AM)} characters or fewer.`}),n;for(let e of pq(t).errors)n.push({field:`body`,message:npe(e,t)});return n}function npe(e,t){let n=rpe(t,e.at);switch(e.kind){case`unclosed`:return`The \`{{\` at ${n} is never closed. Add \`}}\` after the keyword name.`;case`empty`:return`The keyword at ${n} has no name. Write a name between \`{{\` and \`}}\`.`;case`nested`:return`The keyword at ${n} contains a brace. Keywords cannot be placed inside other keywords.`}}function rpe(e,t){let n=e.slice(0,t),r=n.lastIndexOf(`
275
275
  `),i=n.split(`
@@ -287,21 +287,21 @@ Obelisks`})}):e.mode===`yaml`?(0,h.jsx)(Y,{id:`schedule-topics-yaml`,label:`Topi
287
287
  `)}\n`,pronunciation:`${O}\n`},le={article:`article`,script:`script`,research:`research notes`,sources:`sources`,pronunciation:`pronunciation table`},ue=(0,m.useCallback)((e,t)=>{if(!navigator.clipboard){se({text:`Couldn't copy the ${t}. Select the text and copy it.`,tone:`error`});return}navigator.clipboard.writeText(e).then(()=>se({text:`Copied the ${t} as Markdown.`,tone:`success`}),()=>se({text:`Couldn't copy the ${t}. Select the text and copy it.`,tone:`error`}))},[]),de=e=>ue(ce[e],le[e]);return(0,h.jsxs)(P8,{children:[(0,h.jsx)(Y8,{review:G8(a,{itemKey:`article:body`}),projectId:n.id,busy:i}),(0,h.jsx)(`h3`,{className:`m-0 text-title-3 font-semibold text-ink`,children:(0,h.jsx)(rge,{markdown:T})}),(0,h.jsxs)(z8,{files:[...f===void 0?[]:[{output:f,label:`Article${U8(f)}`}],...p===void 0?[]:[{output:p,label:`Sources${U8(p)}`}],...g===void 0?[]:[{output:g,label:`Pronunciation glossary${U8(g)}`}],...u===void 0?[]:[{output:u,label:`Research notes${U8(u)}`}]],children:[(j===`research`?c?.state===`running`||d.data===void 0:C||S===``)?null:(0,h.jsxs)(L,{variant:`secondary`,onClick:()=>de(j),children:[(0,h.jsx)(fc,{"aria-hidden":`true`,strokeWidth:1.75}),`Copy `,le[j]]}),j===`research`&&c!==void 0?(0,h.jsx)(H8,{output:C8(l,`instructions`)}):(0,h.jsx)(H8,{output:C8(s,`instructions`)})]}),(0,h.jsx)(v0,{tone:oe?.tone??`info`,children:oe?.text}),y.error===null?null:(0,h.jsx)(`p`,{className:`m-0 text-body text-danger`,children:y.error.message}),te.length>1?(0,h.jsx)(C0,{items:te,value:j,onChange:e=>{A(e),se(void 0)},label:`Article parts`,idPrefix:ae}):null,(0,h.jsx)(w0,{idPrefix:ae,id:`article`,active:j===`article`,children:C?(0,h.jsx)(`section`,{"aria-label":`Article content`,tabIndex:0,className:`max-h-[min(58vh,640px)] min-h-48 overflow-auto pr-3`,children:b?(0,h.jsx)(q3,{projectId:n.id,stage:`article`,className:``}):(0,h.jsx)(I8,{markdown:E.body})}):(0,h.jsx)(EB,{markdown:E.body,label:`Article`,regionLabel:`Article content`,anchorPrefix:`article-`,what:`article`,onCopy:ue,copyAll:!1,children:Z8(e)&&f!==void 0&&y.data===void 0?(0,h.jsx)(`span`,{className:`block h-4 w-[40ch] max-w-full rounded-control bg-sunken`}):(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:Z8(e)?`No article was saved.`:c===void 0?`The article will be written when its inputs are ready.`:`The article is written once the research has finished.`})})}),_===void 0||ee.trim()===``?null:(0,h.jsx)(w0,{idPrefix:ae,id:`script`,active:j===`script`,children:(0,h.jsx)(`section`,{"aria-label":`Script by speaker`,tabIndex:0,className:`max-h-[min(58vh,640px)] min-h-48 overflow-auto pr-3`,children:(0,h.jsx)(Xhe,{script:ee,voices:_})})}),c===void 0?null:(0,h.jsx)(w0,{idPrefix:ae,id:`research`,active:j===`research`,children:(0,h.jsx)(dge,{projectId:n.id,stage:c,notes:u,onCopy:ue})}),D.length===0?null:(0,h.jsx)(w0,{idPrefix:ae,id:`sources`,active:j===`sources`,children:(0,h.jsx)(EB,{markdown:D.map((e,t)=>`${String(t+1)}. ${e}`).join(`
288
288
  `),label:`Sources`,regionLabel:`Sources`,anchorPrefix:`sources-`,what:`sources`,onCopy:ue,copyAll:!1})}),O===``?null:(0,h.jsxs)(w0,{idPrefix:ae,id:`pronunciation`,active:j===`pronunciation`,children:[k.length===0?null:(0,h.jsxs)(fI,{className:`mb-3`,title:`${k.length===1?`1 entry is`:`${k.length} entries are`} skipped by the narration and read as ordinary text`,children:[(0,h.jsx)(`ul`,{className:`m-0 flex flex-col gap-1 pl-5`,children:k.map(e=>(0,h.jsxs)(`li`,{children:[`Entry `,e.row,`: `,e.reason,`.`]},e.row))}),(0,h.jsx)(`p`,{className:`m-0 mt-1`,children:`The other entries are used. To fix these, edit the Pronunciation Glossary at the end of the article in Edit settings → Article.`})]}),(0,h.jsx)(`div`,{className:`max-h-[min(58vh,640px)] overflow-auto pr-3`,children:(0,h.jsx)(I8,{markdown:O})})]})]})}function Q8({src:e,label:t,marks:n=[],compact:r=!1,preload:i=`metadata`,onError:a,ref:o,className:s}){let c=X0(),l=c.media;return(0,h.jsxs)(`div`,{role:`group`,"aria-label":`${t} controls`,"data-slot":`audio-player`,"data-state":c.playing?`playing`:`paused`,className:I(`sl-audio`,r&&`sl-audio--compact`,s),onKeyDown:e=>{if(e.metaKey||e.ctrlKey||e.altKey||e.key===` `&&e.target.closest(`button`)!==null)return;let t=c.keyAction(e.key);t!==void 0&&(e.preventDefault(),e.stopPropagation(),t())},onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||c.setMenu(!1)},children:[(0,h.jsx)(`audio`,{ref:J0(l,o),src:e,preload:i,"aria-label":t,onError:a,...c.events}),(0,h.jsx)($0,{controls:c,className:`sl-audio__key`}),(0,h.jsx)(e2,{controls:c}),(0,h.jsx)(t2,{controls:c,chapters:n}),(0,h.jsx)(n2,{controls:c}),(0,h.jsx)(r2,{controls:c})]})}function $8({className:e,label:t,children:n}){return(0,h.jsx)(`dl`,{"aria-label":t,className:I(`m-0 grid grid-cols-1 gap-x-6 gap-y-1 sm:grid-cols-[max-content_minmax(0,1fr)] sm:gap-y-3`,e),children:n})}function e5({label:e,children:t}){return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`dt`,{className:`text-small text-ink-2 max-sm:mt-2 max-sm:first:mt-0`,children:e}),(0,h.jsx)(`dd`,{className:`m-0 min-w-0 text-body text-ink`,children:t})]})}function xge({projectId:e,revisionId:t}){let n=G3(e),r=t===void 0?n:t,{api:i}=R(),a=M({queryKey:z.audioPreview(e,r),queryFn:async()=>P(await i.client.projects[`:projectId`][`audio-preview`].$get({param:{projectId:e}})),refetchInterval:1e3,staleTime:0,gcTime:0,retry:!1}),o=(a.data?.revisionId??null)===r?a.data?.previews??[]:[];return(0,h.jsxs)(`section`,{"aria-label":`Live narration`,className:`grid gap-3 border-y border-line py-3`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-2`,children:[(0,h.jsx)(`span`,{className:`text-small font-semibold text-ink`,children:`Listen while it generates`}),(0,h.jsx)(`span`,{className:`text-small text-ink-2`,children:`Play any part. Each preview starts from its beginning.`})]}),a.error===null?null:(0,h.jsx)(`p`,{className:`text-small text-ink-2`,children:`Live preview is temporarily unavailable. Finished audio will still appear here.`}),o.length===0&&a.error===null?(0,h.jsx)(`p`,{className:`text-small text-ink-2`,children:`Waiting for the first audio bytes…`}):null,(0,h.jsx)(`div`,{className:`grid max-h-[420px] gap-3 overflow-y-auto`,children:o.map(t=>(0,h.jsx)(Sge,{preview:t,url:`${i.origin}/api/projects/${encodeURIComponent(e)}/audio-preview/${t.id}`},t.id))})]})}function Sge({preview:e,url:t}){let[n,r]=(0,m.useState)(!1),i=(e.state===`streaming`||e.state===`ready`)&&e.bytes>0,a=e.state===`ready`?`Ready`:e.state===`streaming`?`Generating`:`Preview stopped`;return(0,h.jsxs)(`div`,{className:`grid gap-2 text-small`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,h.jsx)(`span`,{className:`text-ink`,children:e.label}),(0,h.jsx)(`span`,{className:`text-ink-2`,children:a})]}),i&&!n?(0,h.jsx)(Cge,{label:e.label,url:t,onError:()=>r(!0)}):(0,h.jsx)(`p`,{className:`text-ink-2`,children:e.state===`streaming`&&!n?`Waiting for audio…`:`This preview has stopped. The finished narration will be available when generation completes.`})]})}function Cge({label:e,url:t,onError:n}){let r=(0,m.useRef)(null);return(0,m.useEffect)(()=>{let e=r.current;return()=>{e!==null&&(e.pause(),e.removeAttribute(`src`),e.load())}},[]),(0,h.jsx)(Q8,{ref:r,compact:!0,preload:`none`,label:`Live ${e} narration`,src:t,onError:n,className:`max-w-[620px]`})}function wge({outputs:e}){let t=(0,m.useId)(),n=t=>e.find(e=>e.role===`narration_txt`&&e.meta.segment===t),r=V8(n(`intro`)).data,i=V8(n(`body`)).data,a=V8(n(`outro`)).data,[o,s]=(0,m.useState)(),c=(0,m.useCallback)((e,t)=>{if(!navigator.clipboard){s({text:`Couldn't copy the ${t}. Select the text and copy it.`,tone:`error`});return}navigator.clipboard.writeText(e).then(()=>s({text:`Copied the ${t} as Markdown.`,tone:`success`}),()=>s({text:`Couldn't copy the ${t}. Select the text and copy it.`,tone:`error`}))},[]),l=[[`Intro`,r],[`Body`,i],[`Outro`,a]].filter(([,e])=>e!==void 0&&e.trim()!==``);if(!e.some(e=>e.role===`narration_txt`))return null;let u=l.length===1?(l[0]?.[1]??``).trim():l.map(([e,t])=>`## ${e}\n\n${(t??``).trim()}`).join(`
289
289
 
290
- `);return(0,h.jsxs)(`section`,{"aria-labelledby":`${t}-title`,className:`flex min-w-0 flex-col gap-2`,children:[(0,h.jsx)(`h3`,{id:`${t}-title`,className:`sl-kicker text-ink-3`,children:`Narration text`}),(0,h.jsx)(EB,{markdown:u,label:`Narration text`,regionLabel:`Narration text`,anchorPrefix:`narration-`,what:`narration text`,onCopy:c,children:(0,h.jsx)(`span`,{className:`block h-4 w-[40ch] max-w-full rounded-control bg-raised`})}),(0,h.jsx)(v0,{tone:o?.tone??`info`,children:o?.text})]})}var t5=[{role:`audio_intro`,segment:`intro`,name:`Intro`},{role:`audio_body`,segment:`body`,name:`Body`},{role:`audio_outro`,segment:`outro`,name:`Outro`}];function Tge({stage:e,project:t,outputs:n,busy:r}){let{api:i}=R(),a=M(Qy(i)),o=W8(t.id),s=S8(n,e),c=s.filter(e=>e.role===`audio_levelled`),l=t5.flatMap(e=>{let t=c.find(t=>t.meta.segment===e.segment)??C8(s,e.role);return t===void 0?[]:[{...e,output:t}]}),u=t5.flatMap(e=>{let t=c.find(t=>t.meta.segment===e.segment)?.meta.loudness;return t===void 0?[]:[{name:e.name,report:t}]}),d=l.find(e=>e.output.meta.voice!==void 0)?.output.meta,f=l.length>0?d?.voice:t.config.audio?.voice,p=l.length>0?d?.provider:t.config.audio?.provider,m=a.data?.voices.find(e=>e.voiceId===f&&e.provider===p)?.name??f;return(0,h.jsxs)(P8,{children:[e.state===`running`?(0,h.jsx)(xge,{projectId:t.id}):null,l.length===0?(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:`No narration has landed yet.`}):l.map(e=>(0,h.jsx)(Ege,{name:e.name,output:e.output},e.role)),(0,h.jsx)(z8,{files:mge(s,l)}),u.length===0?null:(0,h.jsx)(B8,{children:u.map(({name:e,report:t})=>u.length===1?Ck(t):`${e}: ${Ck(t)}`).join(` `)}),(0,h.jsxs)($8,{label:`How it was recorded`,children:[m===void 0?null:(0,h.jsx)(e5,{label:`Voice`,children:m}),(0,h.jsx)(e5,{label:`Chunking`,children:Dge(Oge(t.config.chunking))}),hge(s)?(0,h.jsx)(e5,{label:`Text files`,children:(0,h.jsx)(`span`,{className:`text-small text-ink-2`,children:`Clean narration is the spoken text used for captions. The TTS script adds delivery cues, with a blank line between requests. Uploaded audio has no TTS request.`})}):null]}),(0,h.jsx)(Y8,{review:G8(o,{itemKey:`narration`}),projectId:t.id,busy:r}),(0,h.jsx)(wge,{outputs:s})]})}function Ege({name:e,output:t}){let n=A8(t);return(0,h.jsxs)(`div`,{className:`grid grid-cols-[64px_minmax(0,1fr)] items-center gap-3 text-small`,children:[(0,h.jsx)(ege,{children:e}),(0,h.jsx)(Q8,{label:`${e} narration`,src:n?.url,className:`max-w-[640px]`})]})}function Dge(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Oge(e){return e===void 0||e.mode===`whole`?`the whole text as one request`:e.mode===`paragraph`?`one request per paragraph`:e.mode===`characters`?`every ${String(e.characters??3e3)} characters`:`every ${String(e.words??500)} words`}function kge({stage:e,project:t,outputs:n}){let r=C8(S8(n,e),`document_pdf`),i=A8(r),a=qS(t.config.document);return(0,h.jsxs)(P8,{children:[r===void 0?(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:e.state===`running`?`The PDF will be saved when rendering finishes.`:`No PDF has been saved yet.`}):(0,h.jsx)(z8,{files:[{output:r,label:`PDF`}],label:`Download PDF`,children:i?.folder?(0,h.jsxs)(dS,{href:`${i.url}?inline=1`,target:`_blank`,rel:`noopener`,variant:`secondary`,children:[(0,h.jsx)(hc,{"aria-hidden":`true`,strokeWidth:1.75}),`Open PDF`]}):null}),(0,h.jsx)($8,{label:`PDF details`,children:(0,h.jsx)(e5,{label:`Theme`,children:a})})]})}var Age={research:`Generates fresh research and affected article, narration, entries, thumbnail and exports; previous outputs stay in History.`,article:`Generates a fresh article and affected narration, entries, thumbnail and exports; previous outputs stay in History.`,audio:`Regenerates narration and affected exports, keeping compatible cue preparation; previous outputs stay in History.`,images:`Regenerates generated images and affected video, keeping supplied images and narration; previous outputs stay in History.`,thumbnail:`Regenerates the thumbnail without changing the main video; previous outputs stay in History.`,video:`Rebuilds local exports from saved media without regenerating narration or images; previous outputs stay in History.`,document:`Renders the PDF again from the saved article and title without regenerating anything else; previous outputs stay in History.`};function n5(e){switch(e.kind){case`cancel`:return{title:`Cancel this run?`,consequence:`Stops every running stage; finished outputs are kept.`,verb:`Cancel run`,dismiss:`Keep running`};case`rerun`:return{title:`Re-run this stage?`,consequence:Age[e.stage],verb:`Re-run`,dismiss:`Cancel`};case`delete-image`:return{title:`Delete this image?`,consequence:`Removes the image and re-renders video when enabled.`,verb:`Delete`,dismiss:`Cancel`};case`regenerate-image`:return{title:`Regenerate this image?`,consequence:`Replaces the image with a new one and re-renders video when enabled.`,verb:`Regenerate`,dismiss:`Cancel`};case`save-article`:return{title:`Save the edited article?`,consequence:`Replaces the article, then updates the enabled narration and final export.`,verb:`Save & update outputs`,dismiss:`Cancel`};case`discard-article`:return{title:`Discard these edits?`,consequence:`The article goes back to the text on disk.`,verb:`Discard`,dismiss:`Keep editing`}}}var r5=(0,m.createContext)(!1),i5=(0,m.createContext)(void 0);function jge(e){let t=k8();return e===void 0?!1:t?.outputs.some(t=>t.output.id===e.id&&t.state===`outdated`)??!1}function a5(e,t,n){let[r,i]=(0,m.useState)(),a=(0,m.use)(r5),o=(0,m.use)(i5),s=k8(),c=e===void 0?void 0:s?.outputs.find(t=>t.output.id===e.id)?.workKey,l=a&&c!==void 0;return{act:t=>{if(e===void 0)return;if(!l||c===void 0){i(t);return}let n=c.startsWith(`image:`)?c.slice(6):void 0;o?.({section:`images`,change:e=>t===`regenerate-image`||n===void 0?{...e,regenerate:[...new Set([...e.regenerate??[],c])]}:{...e,content:{...e.content,imageOrder:e.content.imageOrder.filter(e=>e!==n),imageDefinitions:Object.fromEntries(Object.entries(e.content.imageDefinitions).filter(([e])=>e!==n))},regenerate:(e.regenerate??[]).filter(e=>e!==c)}})},asking:r,confirm:()=>{let n=r;i(void 0),n!==void 0&&e!==void 0&&t.run({kind:n,outputId:e.id})},dismiss:()=>i(void 0),unavailable:e===void 0||n||t.pending||l&&o===void 0,viaEdit:l,ready:!a||s!==void 0}}function Mge(e,t){let{config:n,content:r,fingerprints:i}=e.revision;switch(t){case`research`:return n.sources.research===`generate`;case`article`:return n.sources.article===`generate`&&!r.articleEdited;case`audio`:return n.sources.audio===`generate`&&Object.keys(i).some(e=>!/^audio:(body:.+|intro|outro):[0-9]+$/.test(e)&&!/^audio:(body|intro|outro):future$/.test(e)?!1:!Object.entries(r.narrationOverrides).some(([t,n])=>n.kind===`asset`&&(e===t||e.startsWith(`${t}:`))));case`images`:return n.sources.images!==`off`&&r.imageOrder.some(e=>r.imageDefinitions[e]?.source===`generate`);case`thumbnail`:return n.sources.thumbnail===`from_prompt`||n.sources.thumbnail===`prompt_by_llm`;case`video`:return n.sources.video!==`off`||n.sources.audio!==`off`;case`document`:return FS(n.sources,`document`)===`generate`}}function o5(e){switch(e){case`research`:case`article`:return`article`;case`audio`:return`narration`;case`images`:case`thumbnail`:return`images`;case`video`:return`video`;case`document`:return`document`}}var s5={research:`Research`,article:`Article`,audio:`Narration`,images:`Images`,thumbnail:`Thumbnail`,video:`Video`,document:`PDF`},c5=e=>/^[A-Z]{2}/.test(e)?e:e.charAt(0).toLowerCase()+e.slice(1);function Nge(e){let{project:t,stages:n}=e,r=t.config,i=e=>e===`video`&&XP(r)===`audio`?`Audio export`:s5[e];if(e.sample)return{situation:`sample`,tone:`info`,status:`Sample project`,title:`This is the sample project, finished and free to explore.`,why:`It is read-only. Your own copy can be edited and made again.`,action:{label:`Make my own copy`,intent:{kind:`copy-sample`}}};if(t.status===`paused`)return{situation:`paused`,tone:`waiting`,status:`Paused`,title:`The run is paused.`,why:`Everything made so far is kept. Continuing picks up where it stopped.`,action:{label:`Continue the run`,intent:{kind:`resume`}}};let a=n.find(e=>e.state===`failed`&&e.retryAt===void 0);if(a!==void 0){let t=i(a.kind),n=e.fixOf(a),r={label:`Try ${c5(l5(t))} again`,intent:{kind:`retry`,stage:a.kind}},o={situation:`failed`,tone:`failed`,status:`Failed`,section:o5(a.kind),...a.failureReason===null?{}:{detail:a.failureReason}};switch(n?.kind){case`sign-in`:return{...o,title:`${n.label.replace(/^Sign in to /,``)} is signed out, so ${c5(l5(t))} stopped.`,why:`Copy the sign-in command (${n.command}), run it in a terminal on the computer running Slopify and sign in, then press Check again. Once ${n.label.replace(/^Sign in to /,``)} is signed in, Slopify tries ${c5(l5(t))} again.`,action:{label:`Copy sign-in command`,intent:{kind:`sign-in`,stage:a.kind,fix:n}}};case`refused`:return{...o,title:`A content filter refused a prompt, so ${c5(l5(t))} stopped.`,why:n.soften?`Softening rewrites each refused prompt without what the filter flagged, then draws it again.`:`Change the prompt in the project settings, then try again.`,action:n.soften?{label:n.label,intent:{kind:`soften`,stage:a.kind}}:{label:`Edit the prompt`,intent:{kind:`edit`}}};case`switch-model`:return{...o,title:`The model for ${c5(l5(t))} is no longer offered.`,why:`Pick another model in the project settings, then try again.`,action:{label:`Switch model`,intent:{kind:`edit`}}};case`provider-settings`:return{...o,title:`The provider did not accept its key, so ${c5(l5(t))} stopped.`,why:`Check the key in Settings, then try again.`,action:{label:n.label,intent:{kind:`open-settings`,section:`providers`}}};case`free-space`:return{...o,title:`The disk is full, so ${c5(l5(t))} stopped.`,why:`Storage in Settings shows what can go. Then try again.`,action:{label:n.label,intent:{kind:`open-settings`,section:`storage`}}};case void 0:return{...o,title:`${t} stopped with an error.`,why:`Trying again keeps everything already made.`,action:r}}}let o=e.held[0];if(o!==void 0){let e=i(o.stage);return{situation:`held`,tone:`waiting`,status:`Waiting for you`,title:`The ${c5(e)} ${Ige(e)} ready for your review.`,why:o.dependents.length===0?`Approving marks it reviewed.`:`Approving lets ${Lge(o.dependents.map(e=>c5(l5(i(e)))))} run. Nothing after it runs until you do.`,action:{label:Pge(o,i),intent:{kind:`approve`,gate:o}},section:o5(o.stage)}}let s=n.find(e=>e.state===`failed`&&e.retryAt!==void 0),c=e.waits[0];if(c!==void 0||s!==void 0){if(c!==void 0){let t=QH(e.waits);return{situation:`waiting`,tone:`waiting`,status:`Waiting for limits`,title:`${ZH(e.waits,e.clock)??``}.`,why:`Nothing to do: the run carries on by itself when they reset, and work that does not need ${t} keeps going.`,section:o5(c.stage)}}if(s!==void 0)return{situation:`waiting`,tone:`waiting`,status:`Waiting to try again`,title:`${i(s.kind)} will try again by itself at ${e.clock(s.retryAt??``)}.`,why:`Nothing to do: the run carries on when it does.`,section:o5(s.kind),...s.failureReason===null?{}:{detail:s.failureReason}}}let l=n.find(e=>e.state===`running`);if(t.status===`running`||l!==void 0)return{situation:`running`,tone:`running`,status:`Running`,title:l===void 0?`The run is starting.`:`Making the ${c5(i(l.kind))}${Fge(l)}.`,why:`Pausing lets the current call finish and keeps everything made so far.`,action:{label:`Pause`,intent:{kind:`pause`}},...l===void 0?{}:{section:o5(l.kind)}};if(e.resumable||t.status===`canceled`||t.status===`failed`&&a===void 0)return{situation:`stopped`,tone:`off`,status:t.status===`canceled`?`Canceled`:`Stopped`,title:`The run stopped before it finished.`,why:`Continuing makes only what is missing; everything made so far is kept.`,action:{label:`Continue the run`,intent:{kind:`resume`}}};if(t.status===`pending`)return{situation:`queued`,tone:`off`,status:`Queued`,title:`Waiting for its turn.`,why:`It starts by itself when the videos ahead of it are done.`};let u=Rge(e.outdated);if(u!==void 0)return{situation:`outdated`,tone:`info`,status:`Outdated`,title:u.count===1||u.singular?`The ${u.noun} ${u.noun.endsWith(`s`)?`are`:`is`} outdated after your edit.`:`${String(u.count)} ${u.plural} are outdated after your edit.`,why:`They keep their current version until you remake them. Nothing else is made again.`,action:{label:u.count===1||u.singular?`Remake the outdated ${u.noun}`:`Remake ${String(u.count)} outdated ${u.plural}`,intent:{kind:`remake`,workKeys:u.workKeys}},section:u.section};if(t.status===`done`&&r.mode===`short`)return{situation:`done`,tone:`done`,status:`Done`,title:`The short is ready.`,why:`Play opens set up for a long video on the same topic, with the same starter pack and providers. Nothing starts until you press Play.`,action:{label:`Make the full video on this topic`,intent:{kind:`full-video`}}};if((t.status===`done`||t.status===`partial`)&&e.uploadReady)return{situation:`done`,tone:`done`,status:`Done`,title:`The video is ready.`,why:`Prepare upload lays out the file, title, description, thumbnails and tags in the order YouTube Studio asks for them.`,action:{label:`Prepare upload`,intent:{kind:`prepare-upload`}},section:`youtube`}}function Pge(e,t){if(e.dependents.includes(`video`))return`Approve and render the video`;if(e.dependents.includes(`images`))return`Approve and make the images`;if(e.dependents.includes(`audio`))return`Approve and record the narration`;let n=e.dependents[0];return n===void 0?`Approve the ${c5(t(e.stage))}`:`Approve and make the ${c5(t(n))}`}function Fge(e){return e.progressTotal===null||e.progressTotal<=0?``:` · ${String(e.progressCurrent??0)} of ${String(e.progressTotal)}`}function l5(e){return/s$/i.test(e)?e:`the ${c5(e)}`}function Ige(e){return/s$/i.test(e)?`are`:`is`}function Lge(e){return e.length<=1?e[0]??``:`${e.slice(0,-1).join(`, `)} and ${e.at(-1)??``}`}var u5=[{id:`article`,noun:`article`,plural:`article files`,singular:!0,section:`article`,roles:[`notes`,`sources`,`article_md`,`article_txt`,`script_md`],counted:[`article_md`]},{id:`narration`,noun:`narration`,plural:`narration parts`,singular:!0,section:`narration`,roles:[`narration_txt`,`tts_script`,`glossary`,`audio_body`,`audio_intro`,`audio_outro`],counted:[`audio_body`]},{id:`reference`,noun:`establishing image`,plural:`establishing images`,singular:!0,section:`images`,roles:[`reference`],counted:[`reference`]},{id:`images`,noun:`image`,plural:`images`,singular:!1,section:`images`,roles:[`image`],counted:[`image`]},{id:`animated`,noun:`animated image`,plural:`animated images`,singular:!1,section:`images`,roles:[`animated_image`],counted:[`animated_image`]},{id:`thumbnails`,noun:`thumbnail`,plural:`thumbnails`,singular:!1,section:`images`,roles:[`thumbnail`],counted:[`thumbnail`]},{id:`video`,noun:`video`,plural:`video files`,singular:!0,section:`video`,roles:[`video`,`audio_export`,`audio_mp3`,`audio_m4b`,`render_params`,`subtitles_srt`,`subtitles_vtt`,`subtitle_words`,`subtitle_ass`,`subtitle_font`],counted:[`video`,`audio_export`]},{id:`shorts`,noun:`short`,plural:`shorts`,singular:!1,section:`shorts`,roles:[`shorts`,`short_image`,`short_video`],counted:[`short_video`]},{id:`youtube`,noun:`YouTube description`,plural:`YouTube descriptions`,singular:!0,section:`youtube`,roles:[`youtube_description`,`youtube_tags`],counted:[`youtube_description`]},{id:`document`,noun:`PDF`,plural:`PDFs`,singular:!0,section:`document`,roles:[`document_pdf`],counted:[`document_pdf`]}];function Rge(e){for(let t of u5){let n=e.filter(e=>t.roles.includes(e.role));if(n.length===0)continue;let r=n.filter(e=>t.counted.includes(e.role)).length;return{noun:t.noun,plural:t.plural,singular:t.singular,count:Math.max(1,r),workKeys:[...new Set(n.map(e=>e.workKey))],section:t.section}}}function zge(e){return u5.flatMap(t=>{let n=e.filter(e=>t.roles.includes(e.role));if(n.length===0)return[];let r=Math.max(1,n.filter(e=>t.counted.includes(e.role)).length);return[{label:r===1||t.singular?`Remake the outdated ${t.noun}`:`Remake ${String(r)} outdated ${t.plural}`,workKeys:[...new Set(n.map(e=>e.workKey))],section:t.section,count:r}]})}function Bge({tone:e,status:t,title:n,why:r,action:i,className:a}){return(0,h.jsxs)(`section`,{"aria-label":`Next action`,className:I(`sl-next`,a),children:[(0,h.jsx)(mS,{tone:e,children:t}),(0,h.jsx)(`p`,{className:`sl-next__title`,children:n}),r===void 0?null:(0,h.jsx)(`p`,{className:`sl-next__why`,children:r}),i===void 0?null:(0,h.jsx)(`div`,{className:`flex flex-col [&>*]:w-full`,children:i})]})}function Vge({project:e,stages:t,resumable:n,sample:r,gates:i,outdated:a,waits:o,uploadReady:s,actions:c,controller:l,openSection:u,openUpload:d}){let{api:f}=R(),p=_(),h=Xi(),[g,v]=(0,m.useState)(),y=(0,m.useRef)(new Map),b=Nge({project:e,stages:t,resumable:n,sample:r,held:i.filter(e=>(e.state===`held`||e.state===`pending-review`)&&e.fingerprint===e.currentFingerprint).map(e=>({checkpointId:e.checkpointId,stage:e.stage,dependents:e.dependents})),outdated:a,waits:o,uploadReady:s,fixOf:t=>N3(t,e),clock:nF}),x=N({mutationFn:()=>Uy(f,e.id),onSuccess:async({projectId:e})=>{await p.invalidateQueries({queryKey:z.projects}),await h({to:`/projects/$projectId`,params:{projectId:e}})},onError:e=>v(`${_o(e.message)} The copy was not made. Press Make my own copy to try again.`)}),S=(0,m.useRef)(null),C=sP(),w=N({mutationFn:async()=>{if(C===null)throw Error(`Play isn't available on this page. Reload the page`);if(C.review.starting||C.review.uncertain||C.review.created!==null)throw Error(`Play is starting a run from its open draft. Wait for it to start`);if(!await C.flush())throw Error(`The draft open in Play couldn't be saved. Open Play, save or discard it`);S.current??=crypto.randomUUID();let{draft:t}=await zy(f,{projectId:e.id,draftId:S.current});if(await p.invalidateQueries({queryKey:[`play-drafts`]}),!await C.open(t.id))throw Error(`The full video's draft was made but didn't open. Open Play and pick it`);S.current=null,await h({to:`/play`})},onError:e=>v(`${_o(e.message)} Then press Make the full video on this topic again.`)}),T=N({mutationFn:async t=>{let n=i.find(e=>e.checkpointId===t.checkpointId);if(n===void 0)throw Error(`The review changed before it was approved. Reload the page.`);let r=`${n.checkpointId}:${n.fingerprint}`,a=y.current.get(r)??crypto.randomUUID();y.current.set(r,a);let o=await M3(f,e.id,n.checkpointId,{revisionId:n.revisionId,fingerprint:n.fingerprint,idempotencyKey:a});if(y.current.delete(r),!o.ok)throw Error(o.message)},onSettled:async()=>{await p.invalidateQueries({queryKey:O3(e.id)}),await p.invalidateQueries({queryKey:z.project(e.id)}),p.invalidateQueries({queryKey:z.projects})},onError:e=>v(`${_o(e.message)} Press the approve button again to check whether it went through.`)});return{next:b,run:e=>{switch(v(void 0),e.kind){case`copy-sample`:x.mutate();return;case`resume`:case`pause`:c.run({kind:e.kind});return;case`retry`:case`soften`:c.run({kind:e.kind,stage:e.stage});return;case`sign-in`:p0(e.fix.command).then(t=>v(t?`Copied ${e.fix.command}. Run it in a terminal on the computer running Slopify, sign in, then press Check again.`:`Couldn't copy: the browser blocked the clipboard. Type ${e.fix.command} in a terminal, sign in, then press Check again.`));return;case`approve`:T.mutate(e.gate);return;case`remake`:l.review({kind:`selected`,workKeys:e.workKeys},{autoStart:!0});return;case`edit`:u(`settings`);return;case`open-settings`:h({to:`/settings`,search:{section:e.section}});return;case`prepare-upload`:d();return;case`full-video`:w.mutate();return}},pending:x.isPending||w.isPending||T.isPending||c.pending||l.pending,message:g}}function Hge(e){switch(e.kind){case`copy-sample`:return`Copying…`;case`resume`:return`Continuing…`;case`pause`:return`Pausing…`;case`approve`:return`Approving…`;case`remake`:return`Starting the remake…`;case`retry`:return`Trying again…`;case`soften`:return`Softening…`;case`full-video`:return`Opening Play…`;default:return}}function d5({state:e,variant:t,className:n}){let[r,i]=(0,m.useState)(!1),a=e.next?.action;if(a===void 0)return null;let o=a.intent;if(o.kind===`sign-in`)return(0,h.jsx)(m0,{fix:o.fix,variant:t,retry:{run:()=>e.run({kind:`retry`,stage:o.stage}),busy:e.pending}});if(o.kind===`open-settings`)return(0,h.jsx)(lS,{to:`/settings`,search:{section:o.section},variant:t,...n===void 0?{}:{className:n},children:a.label});let s=e.pending?Hge(o)??a.label:a.label;return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(L,{variant:t,className:n,disabled:e.pending,disabledReason:`Working on the last press`,"aria-keyshortcuts":t===`primary`?kx(mP.nextAction):void 0,onClick:()=>o.kind===`soften`?i(!0):e.run(o),children:s}),o.kind===`soften`?(0,h.jsx)(Ay,{open:r,tone:`primary`,title:`Soften the refused prompt and try again?`,consequence:`Your project's AI model rewrites each refused prompt without what a content filter could flag, keeping the scene and style. The image is then drawn again from the new wording, which it keeps as its prompt. The AI call and the new image are charged like any other.`,confirmLabel:`Soften and retry`,cancelLabel:`Keep the prompt`,pending:e.pending,onConfirm:()=>{i(!1),e.run(o)},onCancel:()=>i(!1)}):null]})}function Uge({state:e,feedback:t}){let n=e.next;return n===void 0&&t===void 0&&e.message===void 0?null:(0,h.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[n===void 0?null:(0,h.jsx)(Bge,{tone:n.tone,status:n.status,title:n.title,...n.why===void 0?{}:{why:n.why},...n.action===void 0?{}:{action:(0,h.jsx)(d5,{state:e,variant:`primary`})}}),e.message===void 0?null:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-small text-danger`,children:e.message}),t]})}var Wge={sample:void 0,paused:void 0,stopped:void 0,queued:void 0,running:void 0,failed:`danger`,held:`waiting`,waiting:`waiting`,outdated:`info`,done:`info`};function Gge({state:e,section:t}){let n=e.next;if(n===void 0||n.section!==t)return null;let r=Wge[n.situation];return r===void 0?null:(0,h.jsx)(fI,{className:`max-[1180px]:hidden`,tone:r,title:n.title,...n.action===void 0?{}:{actions:(0,h.jsx)(d5,{state:e,variant:`secondary`})},children:n.why===void 0&&n.detail===void 0?void 0:(0,h.jsxs)(h.Fragment,{children:[n.why===void 0?null:(0,h.jsx)(`span`,{className:`block`,children:n.why}),n.detail===void 0?null:(0,h.jsxs)(`details`,{className:`mt-1`,children:[(0,h.jsx)(`summary`,{className:`cursor-pointer`,children:`Error details`}),(0,h.jsx)(`pre`,{className:`m-0 mt-1 max-h-48 overflow-auto whitespace-pre-wrap break-words font-mono text-small`,children:n.detail})]})]})})}var Kge={research:`Research again`,article:`Write the article again`,audio:`Record the narration again`,images:`Make all images again`,thumbnail:`Make the thumbnails again`,video:`Render the video again`,document:`Render the PDF again`};function f5(e,t){return e===`video`&&t.config.sources.video===`off`?`Export the audio again`:Kge[e]}function p5({id:e,title:t,kicker:n,stages:r,project:i,outputs:a,actions:o,next:s,active:c,meta:l,head:u=!0,extra:d,resumable:f=!1,children:p}){let m=r[0],g=r.some(e=>o.refusal?.stage===e.kind)?o.refusal?.message:void 0,_=r.filter(t=>t.state===`failed`&&t.retryAt===void 0&&(s.next?.situation!==`failed`||s.next.section!==e)),v=r.find(e=>e.state===`running`),y=v===void 0||v.progressTotal===null||v.progressTotal<=0?void 0:Math.min(1,Math.max(0,(v.progressCurrent??0)/v.progressTotal)),b=l??(m===void 0?void 0:r.filter(e=>e.state!==`skipped`).map(e=>e===m?tF(e,a,i,f):`${s5[e.kind]}: ${tF(e,a,i,f)}`).join(` · `));return(0,h.jsxs)(`section`,{hidden:!c,"aria-label":t,"data-tour":m===void 0?void 0:`project-${m.kind}`,className:`flex min-w-0 flex-col gap-5`,children:[u?(0,h.jsxs)(V,{title:t,...n===void 0?{}:{kicker:n},...b===void 0||b===``?{}:{meta:b},children:[d,(0,h.jsx)(h5,{stages:r,project:i,actions:o})]}):null,y===void 0||v===void 0?null:(0,h.jsx)(u4,{value:y,label:`${s5[v.kind]} progress`,valueText:tF(v,a,i,f)}),(0,h.jsx)(Gge,{state:s,section:e}),_.map(e=>(0,h.jsx)(fI,{tone:`danger`,title:`${s5[e.kind]} stopped with an error.`,children:e.failureReason===null?void 0:(0,h.jsxs)(`details`,{children:[(0,h.jsx)(`summary`,{className:`cursor-pointer`,children:`Error details`}),(0,h.jsx)(`pre`,{className:`m-0 mt-1 max-h-48 overflow-auto whitespace-pre-wrap break-words font-mono text-small`,children:e.failureReason})]})},e.id)),g===void 0?null:(0,h.jsx)(fI,{tone:`danger`,title:g,actions:(0,h.jsx)(L,{variant:`quiet`,size:`small`,onClick:o.dismissRefusal,children:`Dismiss`})}),m?.state===`running`&&m.kind!==`article`&&m.kind!==`images`&&m.kind!==`video`&&m.kind!==`document`?(0,h.jsx)(q3,{projectId:i.id,stage:m.kind}):null,p]})}function m5({stage:e,project:t,name:n}){return e===void 0||e.state===`skipped`?(0,h.jsx)(T0,{title:`${n} is off for this run.`,children:`Switch it on in the project settings to make it.`}):(0,h.jsx)(T0,{title:`No ${n.toLowerCase()} yet.`,children:t.status===`paused`?`It is made once you continue the run.`:`It starts when the steps before it are done. Finished work elsewhere can be looked at meanwhile.`})}function h5({stages:e,project:t,actions:n}){let r=(0,m.useContext)(r5),i=k8(),[a,o]=(0,m.useState)(),s=e.filter(e=>e.state!==`skipped`&&e.state!==`pending`&&(!r||i!==void 0&&Mge(i,e.kind)));if(s.length===0)return null;let c=n.pending||t.status===`running`||e.some(e=>e.state===`running`),l=a===void 0?void 0:n5({kind:`rerun`,stage:a});return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(w8,{modal:!1,children:[(0,h.jsx)(T8,{asChild:!0,children:(0,h.jsx)(Cy,{label:`More actions for ${s5[e[0]?.kind??`article`]}`,children:(0,h.jsx)(mc,{"aria-hidden":`true`,strokeWidth:1.75})})}),(0,h.jsx)(E8,{children:s.map(e=>(0,h.jsx)(D8,{disabled:c,onSelect:()=>o(e.kind),children:f5(e.kind,t)},e.id))})]}),(0,h.jsx)(Ay,{open:a!==void 0,title:a===void 0?``:`${f5(a,t)}?`,consequence:l?.consequence??``,confirmLabel:a===void 0?``:f5(a,t),cancelLabel:`Keep what is there`,pending:n.pending,onConfirm:()=>{let e=a;o(void 0),e!==void 0&&n.run({kind:`rerun`,stage:e})},onCancel:()=>o(void 0)})]})}function qge({stage:e,project:t,outputs:n,actions:r,busy:i}){let a=S8(n,e),o=W8(t.id),s=RS(t.config),c=Array.from({length:s},(e,t)=>t+1).map(e=>({variant:e,output:a.find(t=>t.role===`thumbnail`&&(t.meta.index??1)===e)})),l=c.flatMap(e=>e.output===void 0?[]:[e.output]),u=j8(l),[d,f]=(0,m.useState)(null),p=l.filter(e=>u.has(e.id)),g=p.map(e=>({src:u.get(e.id)?.url??``,alt:`Thumbnail ${String(e.meta.index??1)}`})),_=t.format===`9:16`,v=({variant:n,output:a})=>(0,h.jsx)(Jge,{variant:n,count:s,output:a,review:G8(o,{outputId:a?.id}),stage:e,project:t,actions:r,busy:i,onOpen:()=>f(a===void 0?null:Yge(p,a))},n);return(0,h.jsxs)(`section`,{"aria-label":s===1?`Thumbnail`:`Thumbnails`,className:`flex min-w-0 flex-col gap-5`,children:[(0,h.jsxs)(V,{title:s===1?`Thumbnail`:`Thumbnails`,meta:s===1?`The picture YouTube shows before the video plays`:`${String(s)} variants for YouTube's Test & compare`,children:[(0,h.jsx)(L8,{variant:`secondary`,files:l.map(e=>({output:e,label:s===1?`Thumbnail`:`Thumbnail ${String(e.meta.index??1)}`}))}),(0,h.jsx)(R8,{output:l[0]}),(0,h.jsx)(h5,{stages:[e],project:t,actions:r})]}),c.length===1?(0,h.jsx)(`div`,{className:_?`max-w-[280px]`:`max-w-[480px]`,children:c.map(v)}):(0,h.jsx)(o2,{list:!0,label:`Thumbnail variants`,children:c.map(e=>(0,h.jsx)(`li`,{className:`min-w-0`,children:v(e)},e.variant))}),(0,h.jsx)(s2,{items:g,index:d,onIndex:f,onClose:()=>f(null),actions:(e,t)=>{let n=p[t];return n===void 0?null:(0,h.jsx)(b5,{output:n,name:s===1?`the thumbnail`:`thumbnail ${String(n.meta.index??1)}`,actions:r,busy:i,onLeave:()=>f(null)},n.id)}})]})}function Jge({variant:e,count:t,output:n,review:r,stage:i,project:a,actions:o,busy:s,onOpen:c}){let l=A8(n),u=a5(n,o,s),d=t===1?`the thumbnail`:`thumbnail ${String(e)}`;_x({id:`project.thumbnail.${String(e)}`,title:t===1?`Regenerate the thumbnail`:`Regenerate thumbnail ${String(e)}`,group:`This project`,context:a.title,keywords:[`thumbnail`,`redraw`,`remake`],run:()=>u.act(`regenerate-image`)});let f=r!==void 0&&!r.passed&&r.action===null,p=String.fromCharCode(64+e),m=u.asking===void 0||n===void 0?void 0:n5({kind:u.asking,outputId:n.id});return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(a2,{alt:t===1?`Thumbnail for ${a.title}`:`Thumbnail ${String(e)} for ${a.title}`,aspect:g5(a.format),...l===void 0?{}:{src:l.url},...n===void 0&&i.state===`running`?{generating:`Making the thumbnail`}:{},title:t===1?`Thumbnail`:p,...n===void 0?{meta:Xge(i)}:{},onOpen:c,openLabel:`Open ${d} full size`,...r===void 0?{}:{badge:(0,h.jsx)(X8,{review:r})},actionsShown:f,...n===void 0?{}:{actions:(0,h.jsxs)(h.Fragment,{children:[f&&r!==void 0?(0,h.jsx)(J8,{review:r,projectId:a.id,busy:s}):null,(0,h.jsxs)(L,{size:`small`,disabled:u.unavailable,disabledReason:`Wait until the work on this project is done`,onClick:()=>u.act(`regenerate-image`),"aria-label":`Regenerate ${d}`,children:[(0,h.jsx)(jc,{"aria-hidden":`true`,strokeWidth:1.75}),`Regenerate`]}),l===void 0?null:(0,h.jsx)(x5,{href:l.url,label:`Download ${d}`})]})}}),(0,h.jsx)(Ay,{open:u.asking!==void 0,tone:`primary`,title:m?.title??``,consequence:m?.consequence??``,confirmLabel:`Regenerate the thumbnail`,cancelLabel:`Keep it`,pending:o.pending,onConfirm:u.confirm,onCancel:u.dismiss})]})}function Yge(e,t){let n=e.indexOf(t);return n===-1?null:n}function Xge(e){switch(e.state){case`running`:return`Being made`;case`failed`:case`canceled`:return`Not made`;default:return`Not made yet`}}function Zge(e,t){let n=e.filter(e=>e.role===`image`),r=new Map;for(let e of n){let t=e.meta.promptName??`Images`;r.set(t,[...r.get(t)??[],e])}let i=t.filter(e=>r.has(e)),a=[...r.keys()].filter(e=>!i.includes(e)).sort();return[...i,...a].flatMap(e=>{let t=r.get(e);return t===void 0?[]:[{name:e,images:[...t].sort(Qge)}]})}function Qge(e,t){return(e.meta.index??0)-(t.meta.index??0)}function $ge(e,t,n,r,i){let a=Dy(),[o,s]=(0,m.useState)(),c=(r,i)=>{let o=r===`image`?t:n,c=r===`image`?`image`:`on-screen card`;if(i===void 0){a(`Type the ${c}'s number with the command, for example "regenerate ${c} 3".`);return}let l=o.find(e=>e.meta.index===i);if(l===void 0){let t=o.flatMap(e=>e.meta.index===void 0?[]:[e.meta.index]);a(t.length===0?`${e.title} has no ${c}s yet, so there is no ${c} ${String(i)} to regenerate. They appear under Images once the run makes them.`:`${e.title} has no ${c} ${String(i)}: its ${c}s are numbered ${String(Math.min(...t))} to ${String(Math.max(...t))}. Type one of those, or press Regenerate on the ${c} in Images.`,`error`);return}s(e=>({image:l,name:`${c[0]?.toUpperCase()??``}${c.slice(1)} ${String(i)}`,nonce:(e?.nonce??0)+1}))};return _x({id:`project.image.regenerate`,title:`Regenerate an image`,numbered:e=>`Regenerate image ${String(e)}`,group:`This project`,context:e.title,keywords:[`image`,`picture`,`redraw`,`remake`],searchOnly:!0,run:e=>c(`image`,e)}),_x({id:`project.card.regenerate`,title:`Regenerate an on-screen card`,numbered:e=>`Regenerate on-screen card ${String(e)}`,group:`This project`,context:e.title,keywords:[`card`,`figure`,`table`,`redraw`,`remake`],searchOnly:!0,run:e=>c(`card`,e)}),Kx(Vx.regenerateImage(e.id),e=>c(`image`,e)),o===void 0?null:(0,h.jsx)(e_e,{request:o,actions:r,busy:i},o.nonce)}function e_e({request:e,actions:t,busy:n}){let r=Dy(),i=a5(e.image,t,n),a=(0,m.useRef)(!1);(0,m.useEffect)(()=>{!a.current&&i.ready&&(a.current=!0,i.unavailable?r(`${e.name} can't be regenerated while work on this project is running. Wait until it finishes, then run the command again or press Regenerate on it in Images.`,`error`):i.act(`regenerate-image`))},[i,r,e.name]);let o=i.asking===void 0?void 0:n5({kind:i.asking,outputId:e.image.id});return(0,h.jsx)(Ay,{open:i.asking!==void 0,tone:`primary`,title:o?.title??``,consequence:o?.consequence??``,confirmLabel:`Regenerate the image`,cancelLabel:`Keep it`,pending:t.pending,onConfirm:i.confirm,onCancel:i.dismiss})}function g5(e){return e===`9:16`?`portrait`:`landscape`}function t_e({stage:e,companion:t,project:n,outputs:r,actions:i,busy:a}){let o=W8(n.id),s=S8(r,e),c=Zge(s,n.config.imagePrompts?.map(e=>e.name)??[]),l=c.flatMap(e=>e.images),u=s.filter(e=>e.role===`figure_card`&&(e.meta.format??n.format)===n.format).toSorted((e,t)=>(e.meta.index??0)-(t.meta.index??0)),d=[...l,...u],f=$ge(n,l,u,i,a),p=j8(d),[g,_]=(0,m.useState)(null),v=d.filter(e=>p.has(e.id)),y=v.map(e=>({src:p.get(e.id)?.url??``,alt:e.role===`figure_card`?`On-screen card ${String(e.meta.index??``)}`:e.meta.prompt??`Image ${String(e.meta.index??``)}`,..._5(e)?{kind:`video`}:{},caption:e.role===`figure_card`?`Shown while the narration describes it`:e.meta.prompt??e.meta.promptName??`Slideshow image`})),b=n.config.reference===void 0?null:(0,h.jsx)(n_e,{image:C8(s,`reference`),format:n.format,generated:n.config.reference.source===`prompt`,affected:l.length,actions:i,busy:a}),x=t?.kind===`thumbnail`?(0,h.jsx)(qge,{stage:t,project:n,outputs:r,actions:i,busy:a}):null,S=e.state===`running`&&e.progressTotal!==null?Math.max(0,e.progressTotal-l.length):0,C=o.filter(e=>l.some(t=>t.id===e.outputId)),w=C.filter(e=>e.passed&&e.attempt>1).length,T=C.filter(e=>!e.passed&&e.action===null).length,E=[l.length===0?void 0:`${String(l.length)} in the video`,C.length===0?void 0:`reviewed`,w===0?void 0:`${String(w)} redone after review`,T===0?void 0:`${String(T)} flagged`].filter(e=>e!==void 0).join(` · `);return(0,h.jsxs)(h.Fragment,{children:[f,b,b===null||x===null&&e.state===`skipped`?null:(0,h.jsx)(Nq,{className:`m-0`}),x,x===null||e.state===`skipped`?null:(0,h.jsx)(Nq,{className:`m-0`}),e.state===`skipped`?null:(0,h.jsxs)(`section`,{"aria-label":`Slideshow images`,className:`flex min-w-0 flex-col gap-5`,children:[(0,h.jsxs)(V,{title:`Images`,...E===``?{}:{meta:E},children:[(0,h.jsx)(oge,{projectId:n.id,asset:`images.zip`,label:`Download all`}),(0,h.jsx)(h5,{stages:[e],project:n,actions:i})]}),c.length===0&&S===0?(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:e.state===`pending`?`The images are made once the narration is timed.`:`No images have landed yet.`}):null,c.map((e,t)=>(0,h.jsx)(S5,{name:e.name,count:e.images.length,showName:c.length>1,trailing:t===c.length-1&&S>0?Array.from({length:Math.min(S,3)},(e,t)=>(0,h.jsx)(a2,{alt:`An image being made`,aspect:g5(n.format),generating:t===0?`Drawing the next image`:`Waiting its turn`},t)):null,children:t=>e.images.slice(0,t).map(e=>(0,h.jsx)(C5,{image:e,projectId:n.id,review:G8(o,{outputId:e.id}),format:n.format,actions:i,busy:a,onOpen:()=>_(y5(v,e))},e.id))},e.name)),u.length===0?null:(0,h.jsx)(S5,{name:`From the article`,count:u.length,showName:!0,children:e=>u.slice(0,e).map(e=>(0,h.jsx)(C5,{image:e,projectId:n.id,review:void 0,format:n.format,actions:i,busy:a,card:!0,onOpen:()=>_(y5(v,e))},e.id))}),c.length===0&&S>0?(0,h.jsx)(o2,{label:`Images being made`,children:Array.from({length:Math.min(S,3)},(e,t)=>(0,h.jsx)(a2,{alt:`An image being made`,aspect:g5(n.format),generating:t===0?`Drawing the first image`:`Waiting its turn`},t))}):null,(0,h.jsx)(s2,{items:y,index:g,onIndex:_,onClose:()=>_(null),actions:(e,t)=>{let n=v[t];return n===void 0?null:(0,h.jsx)(b5,{output:n,name:n.role===`figure_card`?`on-screen card${v5(n)}`:`image${v5(n)}`,actions:i,busy:a,onLeave:()=>_(null)},n.id)}})]})]})}var _5=e=>/\.(mp4|mov|m4v|webm|mkv)$/i.test(e.path),v5=e=>e.meta.index===void 0?``:` ${String(e.meta.index)}`;function y5(e,t){let n=e.indexOf(t);return n===-1?null:n}function b5({output:e,name:t,actions:n,busy:r,onLeave:i}){let a=A8(e),o=a5(e,n,r),s=o.asking===void 0?void 0:n5({kind:o.asking,outputId:e.id});return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(L,{size:`small`,disabled:o.unavailable,disabledReason:`Wait until the work on this project is done`,onClick:()=>{o.act(`regenerate-image`),o.viaEdit&&i()},"aria-label":`Regenerate ${t}`,children:[(0,h.jsx)(jc,{"aria-hidden":`true`,strokeWidth:1.75}),`Regenerate`]}),a===void 0?null:(0,h.jsx)(x5,{href:a.url,label:`Download ${t}`}),(0,h.jsx)(Ay,{open:o.asking!==void 0,tone:`primary`,title:s?.title??``,consequence:s?.consequence??``,confirmLabel:`Regenerate it`,cancelLabel:`Keep it`,pending:n.pending,onConfirm:o.confirm,onCancel:o.dismiss})]})}function x5({href:e,label:t,text:n}){return(0,h.jsxs)(dS,{href:e,download:!0,"aria-label":t,title:t,size:`small`,children:[(0,h.jsx)(pc,{"aria-hidden":`true`,strokeWidth:1.75}),n]})}function n_e({image:e,format:t,generated:n,affected:r,actions:i,busy:a}){let o=A8(e),s=a5(e,i,a),[c,l]=(0,m.useState)(null);return(0,h.jsxs)(`section`,{"aria-label":`Establishing image`,className:`flex min-w-0 flex-col gap-5`,children:[(0,h.jsx)(V,{kicker:`Reference · not in the video`,title:`Establishing image`,meta:`Every image follows it for the look, palette and style`,children:e!==void 0&&n?(0,h.jsx)(L,{disabled:s.unavailable,disabledReason:`Wait until the work on this project is done`,onClick:()=>s.act(`regenerate-image`),children:`Make the establishing image again`}):null}),(0,h.jsx)(a2,{className:`w-full max-w-[360px]`,alt:e?.meta.prompt??`Establishing image`,aspect:g5(t),...o===void 0?{}:{src:o.url},title:`Establishing image`,...e===void 0?{meta:`Not made yet`}:{},onOpen:()=>l(0),openLabel:`Open the establishing image full size`,...e===void 0||o===void 0?{}:{actions:(0,h.jsx)(x5,{href:o.url,label:`Download the establishing image`,text:`Download`})}}),n&&r>0?(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:`Making it again marks ${String(r)} image${r===1?``:`s`} outdated. They keep their current version until you remake them.`}):null,(0,h.jsx)(s2,{items:o===void 0?[]:[{src:o.url,alt:`Establishing image`,caption:e?.meta.prompt??`The reference every image follows`}],index:c,onIndex:l,onClose:()=>l(null),actions:()=>o===void 0?null:(0,h.jsxs)(h.Fragment,{children:[n?(0,h.jsxs)(L,{size:`small`,disabled:s.unavailable,disabledReason:`Wait until the work on this project is done`,onClick:()=>{l(null),s.act(`regenerate-image`)},"aria-label":`Make the establishing image again`,children:[(0,h.jsx)(jc,{"aria-hidden":`true`,strokeWidth:1.75}),`Regenerate`]}):null,(0,h.jsx)(x5,{href:o.url,label:`Download the establishing image`})]})}),(0,h.jsx)(Ay,{open:s.asking!==void 0,tone:`primary`,title:`Make the establishing image again?`,consequence:`A new establishing image replaces this one${r>0?`, and the ${String(r)} images drawn from it become outdated until you remake them`:``}. The old one stays in History.`,confirmLabel:`Make it again`,cancelLabel:`Keep this one`,pending:i.pending,onConfirm:s.confirm,onCancel:s.dismiss})]})}function S5({name:e,count:t,showName:n,trailing:r,children:i}){let[a,o]=(0,m.useState)(!1),s=t>12&&!a;return(0,h.jsxs)(`section`,{"aria-label":`${e} × ${String(t)}`,className:`flex flex-col gap-3`,children:[n?(0,h.jsx)(`h3`,{className:`sl-kicker m-0`,children:`${e} × ${String(t)}`}):null,(0,h.jsxs)(o2,{children:[i(s?12:t),r]}),t>12?(0,h.jsx)(L,{variant:`quiet`,"aria-expanded":a,className:`self-start`,onClick:()=>o(e=>!e),children:a?`Show fewer`:`Show all ${String(t)} images`}):null]})}function C5({image:e,projectId:t,review:n,format:r,actions:i,busy:a,card:o=!1,onOpen:s}){let c=A8(e),l=v5(e),u=o?`on-screen card${l}`:`image${l}`,d=a5(e,i,a),f=jge(e),p=n!==void 0&&!n.passed&&n.action===null,m=d.asking===void 0?void 0:n5({kind:d.asking,outputId:e.id});return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(a2,{alt:o?`On-screen card${l}`:e.meta.prompt??`Slideshow ${u}`,kind:_5(e)?`video`:`image`,aspect:g5(r),...c===void 0?{}:{src:c.url},title:o?`Card${l}`:e.meta.prompt??`Image${l}`,...e.meta.index===void 0?{}:{meta:`#${String(e.meta.index)}`},onOpen:s,openLabel:`Open ${u} full size`,...n===void 0&&!f?{}:{badge:(0,h.jsxs)(`span`,{className:`inline-flex flex-wrap gap-1`,children:[f?(0,h.jsx)(hS,{tone:`info`,children:`Outdated`}):null,n===void 0?null:(0,h.jsx)(X8,{review:n})]})},actionsShown:p,actions:(0,h.jsxs)(h.Fragment,{children:[p&&n!==void 0?(0,h.jsx)(J8,{review:n,projectId:t,busy:a}):null,(0,h.jsxs)(L,{size:`small`,disabled:d.unavailable,disabledReason:`Wait until the work on this project is done`,onClick:()=>d.act(`regenerate-image`),"aria-label":`Regenerate ${u}`,children:[(0,h.jsx)(jc,{"aria-hidden":`true`,strokeWidth:1.75}),`Regenerate`]}),c===void 0?null:(0,h.jsx)(x5,{href:c.url,label:`Download ${u}`}),o?null:(0,h.jsx)(L,{size:`small`,variant:`destructive`,disabled:d.unavailable,disabledReason:`Wait until the work on this project is done`,onClick:()=>d.act(`delete-image`),"aria-label":`Delete ${u}`,title:`Delete ${u}`,children:(0,h.jsx)(Ic,{"aria-hidden":`true`,strokeWidth:1.75})})]})}),(0,h.jsx)(Ay,{open:d.asking!==void 0,tone:d.asking===`delete-image`?`destructive`:`primary`,title:m?.title??``,consequence:m?.consequence??``,confirmLabel:d.asking===`delete-image`?`Delete the image`:`Regenerate the image`,cancelLabel:`Keep it`,pending:i.pending,onConfirm:d.confirm,onCancel:d.dismiss})]})}function w5(e){let t=Math.max(0,Math.floor(e)),n=Math.floor(t/3600),r=Math.floor(t%3600/60),i=String(t%60).padStart(2,`0`);return n>0?`${String(n)}:${String(r).padStart(2,`0`)}:${i}`:`${String(r)}:${i}`}function T5(e){let t=/^(?:(\d+):)?(\d{1,2}):(\d{2})$/.exec(e.trim());if(t===null)return;let n=Number(t[1]??`0`),r=Number(t[2]),i=Number(t[3]);if(!(i>59||t[1]!==void 0&&r>59))return n*3600+r*60+i}function r_e(e){let t=e.trim(),n=/^(\S+)\s+(.+)$/u.exec(t);if(n===null)return;let r=T5(n[1]??``),i=(n[2]??``).trim();return r===void 0||i===``?void 0:{start:r,title:i}}function E5(e,t){let n=e.replace(/\r\n?/gu,`
290
+ `);return(0,h.jsxs)(`section`,{"aria-labelledby":`${t}-title`,className:`flex min-w-0 flex-col gap-2`,children:[(0,h.jsx)(`h3`,{id:`${t}-title`,className:`sl-kicker text-ink-3`,children:`Narration text`}),(0,h.jsx)(EB,{markdown:u,label:`Narration text`,regionLabel:`Narration text`,anchorPrefix:`narration-`,what:`narration text`,onCopy:c,children:(0,h.jsx)(`span`,{className:`block h-4 w-[40ch] max-w-full rounded-control bg-raised`})}),(0,h.jsx)(v0,{tone:o?.tone??`info`,children:o?.text})]})}var t5=[{role:`audio_intro`,segment:`intro`,name:`Intro`},{role:`audio_body`,segment:`body`,name:`Body`},{role:`audio_outro`,segment:`outro`,name:`Outro`}];function Tge({stage:e,project:t,outputs:n,busy:r}){let{api:i}=R(),a=M(Qy(i)),o=W8(t.id),s=S8(n,e),c=s.filter(e=>e.role===`audio_levelled`),l=t5.flatMap(e=>{let t=c.find(t=>t.meta.segment===e.segment)??C8(s,e.role);return t===void 0?[]:[{...e,output:t}]}),u=t5.flatMap(e=>{let t=c.find(t=>t.meta.segment===e.segment)?.meta.loudness;return t===void 0?[]:[{name:e.name,report:t}]}),d=l.find(e=>e.output.meta.voice!==void 0)?.output.meta,f=l.length>0?d?.voice:t.config.audio?.voice,p=l.length>0?d?.provider:t.config.audio?.provider,m=a.data?.voices.find(e=>e.voiceId===f&&e.provider===p)?.name??f;return(0,h.jsxs)(P8,{children:[e.state===`running`?(0,h.jsx)(xge,{projectId:t.id}):null,l.length===0?(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:`No narration has landed yet.`}):l.map(e=>(0,h.jsx)(Ege,{name:e.name,output:e.output},e.role)),(0,h.jsx)(z8,{files:mge(s,l)}),u.length===0?null:(0,h.jsx)(B8,{children:u.map(({name:e,report:t})=>u.length===1?Ck(t):`${e}: ${Ck(t)}`).join(` `)}),(0,h.jsxs)($8,{label:`How it was recorded`,children:[m===void 0?null:(0,h.jsx)(e5,{label:`Voice`,children:m}),(0,h.jsx)(e5,{label:`Chunking`,children:Dge(Oge(t.config.chunking))}),hge(s)?(0,h.jsx)(e5,{label:`Text files`,children:(0,h.jsx)(`span`,{className:`text-small text-ink-2`,children:`Clean narration is the spoken text used for captions. The TTS script adds delivery cues, with a blank line between requests. Uploaded audio has no TTS request.`})}):null]}),(0,h.jsx)(Y8,{review:G8(o,{itemKey:`narration`}),projectId:t.id,busy:r}),(0,h.jsx)(wge,{outputs:s})]})}function Ege({name:e,output:t}){let n=A8(t);return(0,h.jsxs)(`div`,{className:`grid grid-cols-[64px_minmax(0,1fr)] items-center gap-3 text-small`,children:[(0,h.jsx)(ege,{children:e}),(0,h.jsx)(Q8,{label:`${e} narration`,src:n?.url,className:`max-w-[640px]`})]})}function Dge(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Oge(e){return e===void 0||e.mode===`whole`?`the whole text as one request`:e.mode===`paragraph`?`one request per paragraph`:e.mode===`characters`?`every ${String(e.characters??3e3)} characters`:`every ${String(e.words??500)} words`}function kge({stage:e,project:t,outputs:n}){let r=C8(S8(n,e),`document_pdf`),i=A8(r),a=qS(t.config.document);return(0,h.jsxs)(P8,{children:[r===void 0?(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:e.state===`running`?`The PDF will be saved when rendering finishes.`:`No PDF has been saved yet.`}):(0,h.jsx)(z8,{files:[{output:r,label:`PDF`}],label:`Download PDF`,children:i?.folder?(0,h.jsxs)(dS,{href:`${i.url}?inline=1`,target:`_blank`,rel:`noopener`,variant:`secondary`,children:[(0,h.jsx)(hc,{"aria-hidden":`true`,strokeWidth:1.75}),`Open PDF`]}):null}),(0,h.jsx)($8,{label:`PDF details`,children:(0,h.jsx)(e5,{label:`Theme`,children:a})})]})}var Age={research:`Generates fresh research and affected article, narration, entries, thumbnail and exports; previous outputs stay in History.`,article:`Generates a fresh article and affected narration, entries, thumbnail and exports; previous outputs stay in History.`,audio:`Regenerates narration and affected exports, keeping compatible cue preparation; previous outputs stay in History.`,images:`Regenerates generated images and affected video, keeping supplied images and narration; previous outputs stay in History.`,thumbnail:`Regenerates the thumbnail without changing the main video; previous outputs stay in History.`,video:`Rebuilds local exports from saved media without regenerating narration or images; previous outputs stay in History.`,document:`Renders the PDF again from the saved article and title without regenerating anything else; previous outputs stay in History.`};function n5(e){switch(e.kind){case`cancel`:return{title:`Cancel this run?`,consequence:`Stops every running stage; finished outputs are kept.`,verb:`Cancel run`,dismiss:`Keep running`};case`rerun`:return{title:`Re-run this stage?`,consequence:Age[e.stage],verb:`Re-run`,dismiss:`Cancel`};case`delete-image`:return{title:`Delete this image?`,consequence:`Removes the image and re-renders video when enabled.`,verb:`Delete`,dismiss:`Cancel`};case`regenerate-image`:return{title:`Regenerate this image?`,consequence:`Replaces the image with a new one and re-renders video when enabled.`,verb:`Regenerate`,dismiss:`Cancel`};case`save-article`:return{title:`Save the edited article?`,consequence:`Replaces the article, then updates the enabled narration and final export.`,verb:`Save & update outputs`,dismiss:`Cancel`};case`discard-article`:return{title:`Discard these edits?`,consequence:`The article goes back to the text on disk.`,verb:`Discard`,dismiss:`Keep editing`}}}var r5=(0,m.createContext)(!1),i5=(0,m.createContext)(void 0);function jge(e){let t=k8();return e===void 0?!1:t?.outputs.some(t=>t.output.id===e.id&&t.state===`outdated`)??!1}function a5(e,t,n){let[r,i]=(0,m.useState)(),a=(0,m.use)(r5),o=(0,m.use)(i5),s=k8(),c=e===void 0?void 0:s?.outputs.find(t=>t.output.id===e.id)?.workKey,l=a&&c!==void 0;return{act:t=>{if(e===void 0)return;if(!l||c===void 0){i(t);return}let n=c.startsWith(`image:`)?c.slice(6):void 0;o?.({section:`images`,change:e=>t===`regenerate-image`||n===void 0?{...e,regenerate:[...new Set([...e.regenerate??[],c])]}:{...e,content:{...e.content,imageOrder:e.content.imageOrder.filter(e=>e!==n),imageDefinitions:Object.fromEntries(Object.entries(e.content.imageDefinitions).filter(([e])=>e!==n))},regenerate:(e.regenerate??[]).filter(e=>e!==c)}})},asking:r,confirm:()=>{let n=r;i(void 0),n!==void 0&&e!==void 0&&t.run({kind:n,outputId:e.id})},dismiss:()=>i(void 0),unavailable:e===void 0||n||t.pending||l&&o===void 0,viaEdit:l,ready:!a||s!==void 0}}function Mge(e,t){let n=(0,m.use)(r5),r=(0,m.use)(i5),i=k8();if(!n||i===void 0)return;let a=new Set(e.map(e=>e.id)),o=i.outputs.flatMap(e=>a.has(e.output.id)&&e.workKey.startsWith(`image:`)?[e.workKey]:[]);if(o.length!==0)return{act:()=>r?.({section:`images`,change:e=>({...e,regenerate:[...new Set([...e.regenerate??[],...o])]})}),unavailable:t||r===void 0}}function Nge(e,t){let{config:n,content:r,fingerprints:i}=e.revision;switch(t){case`research`:return n.sources.research===`generate`;case`article`:return n.sources.article===`generate`&&!r.articleEdited;case`audio`:return n.sources.audio===`generate`&&Object.keys(i).some(e=>!/^audio:(body:.+|intro|outro):[0-9]+$/.test(e)&&!/^audio:(body|intro|outro):future$/.test(e)?!1:!Object.entries(r.narrationOverrides).some(([t,n])=>n.kind===`asset`&&(e===t||e.startsWith(`${t}:`))));case`images`:return n.sources.images!==`off`&&r.imageOrder.some(e=>r.imageDefinitions[e]?.source===`generate`);case`thumbnail`:return n.sources.thumbnail===`from_prompt`||n.sources.thumbnail===`prompt_by_llm`;case`video`:return n.sources.video!==`off`||n.sources.audio!==`off`;case`document`:return FS(n.sources,`document`)===`generate`}}function o5(e){switch(e){case`research`:case`article`:return`article`;case`audio`:return`narration`;case`images`:case`thumbnail`:return`images`;case`video`:return`video`;case`document`:return`document`}}var s5={research:`Research`,article:`Article`,audio:`Narration`,images:`Images`,thumbnail:`Thumbnail`,video:`Video`,document:`PDF`},c5=e=>/^[A-Z]{2}/.test(e)?e:e.charAt(0).toLowerCase()+e.slice(1);function Pge(e){let{project:t,stages:n}=e,r=t.config,i=e=>e===`video`&&XP(r)===`audio`?`Audio export`:s5[e];if(e.sample)return{situation:`sample`,tone:`info`,status:`Sample project`,title:`This is the sample project, finished and free to explore.`,why:`It is read-only. Your own copy can be edited and made again.`,action:{label:`Make my own copy`,intent:{kind:`copy-sample`}}};if(t.status===`paused`)return{situation:`paused`,tone:`waiting`,status:`Paused`,title:`The run is paused.`,why:`Everything made so far is kept. Continuing picks up where it stopped.`,action:{label:`Continue the run`,intent:{kind:`resume`}}};let a=n.find(e=>e.state===`failed`&&e.retryAt===void 0);if(a!==void 0){let t=i(a.kind),n=e.fixOf(a),r={label:`Try ${c5(l5(t))} again`,intent:{kind:`retry`,stage:a.kind}},o={situation:`failed`,tone:`failed`,status:`Failed`,section:o5(a.kind),...a.failureReason===null?{}:{detail:a.failureReason}};switch(n?.kind){case`sign-in`:return{...o,title:`${n.label.replace(/^Sign in to /,``)} is signed out, so ${c5(l5(t))} stopped.`,why:`Copy the sign-in command (${n.command}), run it in a terminal on the computer running Slopify and sign in, then press Check again. Once ${n.label.replace(/^Sign in to /,``)} is signed in, Slopify tries ${c5(l5(t))} again.`,action:{label:`Copy sign-in command`,intent:{kind:`sign-in`,stage:a.kind,fix:n}}};case`refused`:return{...o,title:`A content filter refused a prompt, so ${c5(l5(t))} stopped.`,why:n.soften?`Softening rewrites each refused prompt without what the filter flagged, then draws it again.`:`Change the prompt in the project settings, then try again.`,action:n.soften?{label:n.label,intent:{kind:`soften`,stage:a.kind}}:{label:`Edit the prompt`,intent:{kind:`edit`}}};case`switch-model`:return{...o,title:`The model for ${c5(l5(t))} is no longer offered.`,why:`Pick another model in the project settings, then try again.`,action:{label:`Switch model`,intent:{kind:`edit`}}};case`provider-settings`:return{...o,title:`The provider did not accept its key, so ${c5(l5(t))} stopped.`,why:`Check the key in Settings, then try again.`,action:{label:n.label,intent:{kind:`open-settings`,section:`providers`}}};case`free-space`:return{...o,title:`The disk is full, so ${c5(l5(t))} stopped.`,why:`Storage in Settings shows what can go. Then try again.`,action:{label:n.label,intent:{kind:`open-settings`,section:`storage`}}};case void 0:return{...o,title:`${t} stopped with an error.`,why:`Trying again keeps everything already made.`,action:r}}}let o=e.held[0];if(o!==void 0){let e=i(o.stage);return{situation:`held`,tone:`waiting`,status:`Waiting for you`,title:`The ${c5(e)} ${Lge(e)} ready for your review.`,why:o.dependents.length===0?`Approving marks it reviewed.`:`Approving lets ${Rge(o.dependents.map(e=>c5(l5(i(e)))))} run. Nothing after it runs until you do.`,action:{label:Fge(o,i),intent:{kind:`approve`,gate:o}},section:o5(o.stage)}}let s=n.find(e=>e.state===`failed`&&e.retryAt!==void 0),c=e.waits[0];if(c!==void 0||s!==void 0){if(c!==void 0){let t=QH(e.waits);return{situation:`waiting`,tone:`waiting`,status:`Waiting for limits`,title:`${ZH(e.waits,e.clock)??``}.`,why:`Nothing to do: the run carries on by itself when they reset, and work that does not need ${t} keeps going.`,section:o5(c.stage)}}if(s!==void 0)return{situation:`waiting`,tone:`waiting`,status:`Waiting to try again`,title:`${i(s.kind)} will try again by itself at ${e.clock(s.retryAt??``)}.`,why:`Nothing to do: the run carries on when it does.`,section:o5(s.kind),...s.failureReason===null?{}:{detail:s.failureReason}}}let l=n.find(e=>e.state===`running`);if(t.status===`running`||l!==void 0)return{situation:`running`,tone:`running`,status:`Running`,title:l===void 0?`The run is starting.`:`Making the ${c5(i(l.kind))}${Ige(l)}.`,why:`Pausing lets the current call finish and keeps everything made so far.`,action:{label:`Pause`,intent:{kind:`pause`}},...l===void 0?{}:{section:o5(l.kind)}};if(e.resumable||t.status===`canceled`||t.status===`failed`&&a===void 0)return{situation:`stopped`,tone:`off`,status:t.status===`canceled`?`Canceled`:`Stopped`,title:`The run stopped before it finished.`,why:`Continuing makes only what is missing; everything made so far is kept.`,action:{label:`Continue the run`,intent:{kind:`resume`}}};if(t.status===`pending`)return{situation:`queued`,tone:`off`,status:`Queued`,title:`Waiting for its turn.`,why:`It starts by itself when the videos ahead of it are done.`};let u=zge(e.outdated);if(u!==void 0)return{situation:`outdated`,tone:`info`,status:`Outdated`,title:u.count===1||u.singular?`The ${u.noun} ${u.noun.endsWith(`s`)?`are`:`is`} outdated after your edit.`:`${String(u.count)} ${u.plural} are outdated after your edit.`,why:`They keep their current version until you remake them. Nothing else is made again.`,action:{label:u.count===1||u.singular?`Remake the outdated ${u.noun}`:`Remake ${String(u.count)} outdated ${u.plural}`,intent:{kind:`remake`,workKeys:u.workKeys}},section:u.section};if(t.status===`done`&&r.mode===`short`)return{situation:`done`,tone:`done`,status:`Done`,title:`The short is ready.`,why:`Play opens set up for a long video on the same topic, with the same starter pack and providers. Nothing starts until you press Play.`,action:{label:`Make the full video on this topic`,intent:{kind:`full-video`}}};if((t.status===`done`||t.status===`partial`)&&e.uploadReady)return{situation:`done`,tone:`done`,status:`Done`,title:`The video is ready.`,why:`Prepare upload lays out the file, title, description, thumbnails and tags in the order YouTube Studio asks for them.`,action:{label:`Prepare upload`,intent:{kind:`prepare-upload`}},section:`youtube`}}function Fge(e,t){if(e.dependents.includes(`video`))return`Approve and render the video`;if(e.dependents.includes(`images`))return`Approve and make the images`;if(e.dependents.includes(`audio`))return`Approve and record the narration`;let n=e.dependents[0];return n===void 0?`Approve the ${c5(t(e.stage))}`:`Approve and make the ${c5(t(n))}`}function Ige(e){return e.progressTotal===null||e.progressTotal<=0?``:` · ${String(e.progressCurrent??0)} of ${String(e.progressTotal)}`}function l5(e){return/s$/i.test(e)?e:`the ${c5(e)}`}function Lge(e){return/s$/i.test(e)?`are`:`is`}function Rge(e){return e.length<=1?e[0]??``:`${e.slice(0,-1).join(`, `)} and ${e.at(-1)??``}`}var u5=[{id:`article`,noun:`article`,plural:`article files`,singular:!0,section:`article`,roles:[`notes`,`sources`,`article_md`,`article_txt`,`script_md`],counted:[`article_md`]},{id:`narration`,noun:`narration`,plural:`narration parts`,singular:!0,section:`narration`,roles:[`narration_txt`,`tts_script`,`glossary`,`audio_body`,`audio_intro`,`audio_outro`],counted:[`audio_body`]},{id:`reference`,noun:`establishing image`,plural:`establishing images`,singular:!0,section:`images`,roles:[`reference`],counted:[`reference`]},{id:`images`,noun:`image`,plural:`images`,singular:!1,section:`images`,roles:[`image`],counted:[`image`]},{id:`animated`,noun:`animated image`,plural:`animated images`,singular:!1,section:`images`,roles:[`animated_image`],counted:[`animated_image`]},{id:`thumbnails`,noun:`thumbnail`,plural:`thumbnails`,singular:!1,section:`images`,roles:[`thumbnail`],counted:[`thumbnail`]},{id:`video`,noun:`video`,plural:`video files`,singular:!0,section:`video`,roles:[`video`,`audio_export`,`audio_mp3`,`audio_m4b`,`render_params`,`subtitles_srt`,`subtitles_vtt`,`subtitle_words`,`subtitle_ass`,`subtitle_font`],counted:[`video`,`audio_export`]},{id:`shorts`,noun:`short`,plural:`shorts`,singular:!1,section:`shorts`,roles:[`shorts`,`short_image`,`short_video`],counted:[`short_video`]},{id:`youtube`,noun:`YouTube description`,plural:`YouTube descriptions`,singular:!0,section:`youtube`,roles:[`youtube_description`,`youtube_tags`],counted:[`youtube_description`]},{id:`document`,noun:`PDF`,plural:`PDFs`,singular:!0,section:`document`,roles:[`document_pdf`],counted:[`document_pdf`]}];function zge(e){for(let t of u5){let n=e.filter(e=>t.roles.includes(e.role));if(n.length===0)continue;let r=n.filter(e=>t.counted.includes(e.role)).length;return{noun:t.noun,plural:t.plural,singular:t.singular,count:Math.max(1,r),workKeys:[...new Set(n.map(e=>e.workKey))],section:t.section}}}function Bge(e){return u5.flatMap(t=>{let n=e.filter(e=>t.roles.includes(e.role));if(n.length===0)return[];let r=Math.max(1,n.filter(e=>t.counted.includes(e.role)).length);return[{label:r===1||t.singular?`Remake the outdated ${t.noun}`:`Remake ${String(r)} outdated ${t.plural}`,workKeys:[...new Set(n.map(e=>e.workKey))],section:t.section,count:r}]})}function Vge({tone:e,status:t,title:n,why:r,action:i,className:a}){return(0,h.jsxs)(`section`,{"aria-label":`Next action`,className:I(`sl-next`,a),children:[(0,h.jsx)(mS,{tone:e,children:t}),(0,h.jsx)(`p`,{className:`sl-next__title`,children:n}),r===void 0?null:(0,h.jsx)(`p`,{className:`sl-next__why`,children:r}),i===void 0?null:(0,h.jsx)(`div`,{className:`flex flex-col [&>*]:w-full`,children:i})]})}function Hge({project:e,stages:t,resumable:n,sample:r,gates:i,outdated:a,waits:o,uploadReady:s,actions:c,controller:l,openSection:u,openUpload:d}){let{api:f}=R(),p=_(),h=Xi(),[g,v]=(0,m.useState)(),y=(0,m.useRef)(new Map),b=Pge({project:e,stages:t,resumable:n,sample:r,held:i.filter(e=>(e.state===`held`||e.state===`pending-review`)&&e.fingerprint===e.currentFingerprint).map(e=>({checkpointId:e.checkpointId,stage:e.stage,dependents:e.dependents})),outdated:a,waits:o,uploadReady:s,fixOf:t=>N3(t,e),clock:nF}),x=N({mutationFn:()=>Uy(f,e.id),onSuccess:async({projectId:e})=>{await p.invalidateQueries({queryKey:z.projects}),await h({to:`/projects/$projectId`,params:{projectId:e}})},onError:e=>v(`${_o(e.message)} The copy was not made. Press Make my own copy to try again.`)}),S=(0,m.useRef)(null),C=sP(),w=N({mutationFn:async()=>{if(C===null)throw Error(`Play isn't available on this page. Reload the page`);if(C.review.starting||C.review.uncertain||C.review.created!==null)throw Error(`Play is starting a run from its open draft. Wait for it to start`);if(!await C.flush())throw Error(`The draft open in Play couldn't be saved. Open Play, save or discard it`);S.current??=crypto.randomUUID();let{draft:t}=await zy(f,{projectId:e.id,draftId:S.current});if(await p.invalidateQueries({queryKey:[`play-drafts`]}),!await C.open(t.id))throw Error(`The full video's draft was made but didn't open. Open Play and pick it`);S.current=null,await h({to:`/play`})},onError:e=>v(`${_o(e.message)} Then press Make the full video on this topic again.`)}),T=N({mutationFn:async t=>{let n=i.find(e=>e.checkpointId===t.checkpointId);if(n===void 0)throw Error(`The review changed before it was approved. Reload the page.`);let r=`${n.checkpointId}:${n.fingerprint}`,a=y.current.get(r)??crypto.randomUUID();y.current.set(r,a);let o=await M3(f,e.id,n.checkpointId,{revisionId:n.revisionId,fingerprint:n.fingerprint,idempotencyKey:a});if(y.current.delete(r),!o.ok)throw Error(o.message)},onSettled:async()=>{await p.invalidateQueries({queryKey:O3(e.id)}),await p.invalidateQueries({queryKey:z.project(e.id)}),p.invalidateQueries({queryKey:z.projects})},onError:e=>v(`${_o(e.message)} Press the approve button again to check whether it went through.`)});return{next:b,run:e=>{switch(v(void 0),e.kind){case`copy-sample`:x.mutate();return;case`resume`:case`pause`:c.run({kind:e.kind});return;case`retry`:case`soften`:c.run({kind:e.kind,stage:e.stage});return;case`sign-in`:p0(e.fix.command).then(t=>v(t?`Copied ${e.fix.command}. Run it in a terminal on the computer running Slopify, sign in, then press Check again.`:`Couldn't copy: the browser blocked the clipboard. Type ${e.fix.command} in a terminal, sign in, then press Check again.`));return;case`approve`:T.mutate(e.gate);return;case`remake`:l.review({kind:`selected`,workKeys:e.workKeys},{autoStart:!0});return;case`edit`:u(`settings`);return;case`open-settings`:h({to:`/settings`,search:{section:e.section}});return;case`prepare-upload`:d();return;case`full-video`:w.mutate();return}},pending:x.isPending||w.isPending||T.isPending||c.pending||l.pending,message:g}}function Uge(e){switch(e.kind){case`copy-sample`:return`Copying…`;case`resume`:return`Continuing…`;case`pause`:return`Pausing…`;case`approve`:return`Approving…`;case`remake`:return`Starting the remake…`;case`retry`:return`Trying again…`;case`soften`:return`Softening…`;case`full-video`:return`Opening Play…`;default:return}}function d5({state:e,variant:t,className:n}){let[r,i]=(0,m.useState)(!1),a=e.next?.action;if(a===void 0)return null;let o=a.intent;if(o.kind===`sign-in`)return(0,h.jsx)(m0,{fix:o.fix,variant:t,retry:{run:()=>e.run({kind:`retry`,stage:o.stage}),busy:e.pending}});if(o.kind===`open-settings`)return(0,h.jsx)(lS,{to:`/settings`,search:{section:o.section},variant:t,...n===void 0?{}:{className:n},children:a.label});let s=e.pending?Uge(o)??a.label:a.label;return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(L,{variant:t,className:n,disabled:e.pending,disabledReason:`Working on the last press`,"aria-keyshortcuts":t===`primary`?kx(mP.nextAction):void 0,onClick:()=>o.kind===`soften`?i(!0):e.run(o),children:s}),o.kind===`soften`?(0,h.jsx)(Ay,{open:r,tone:`primary`,title:`Soften the refused prompt and try again?`,consequence:`Your project's AI model rewrites each refused prompt without what a content filter could flag, keeping the scene and style. The image is then drawn again from the new wording, which it keeps as its prompt. The AI call and the new image are charged like any other.`,confirmLabel:`Soften and retry`,cancelLabel:`Keep the prompt`,pending:e.pending,onConfirm:()=>{i(!1),e.run(o)},onCancel:()=>i(!1)}):null]})}function Wge({state:e,feedback:t}){let n=e.next;return n===void 0&&t===void 0&&e.message===void 0?null:(0,h.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[n===void 0?null:(0,h.jsx)(Vge,{tone:n.tone,status:n.status,title:n.title,...n.why===void 0?{}:{why:n.why},...n.action===void 0?{}:{action:(0,h.jsx)(d5,{state:e,variant:`primary`})}}),e.message===void 0?null:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-small text-danger`,children:e.message}),t]})}var Gge={sample:void 0,paused:void 0,stopped:void 0,queued:void 0,running:void 0,failed:`danger`,held:`waiting`,waiting:`waiting`,outdated:`info`,done:`info`};function Kge({state:e,section:t}){let n=e.next;if(n===void 0||n.section!==t)return null;let r=Gge[n.situation];return r===void 0?null:(0,h.jsx)(fI,{className:`max-[1180px]:hidden`,tone:r,title:n.title,...n.action===void 0?{}:{actions:(0,h.jsx)(d5,{state:e,variant:`secondary`})},children:n.why===void 0&&n.detail===void 0?void 0:(0,h.jsxs)(h.Fragment,{children:[n.why===void 0?null:(0,h.jsx)(`span`,{className:`block`,children:n.why}),n.detail===void 0?null:(0,h.jsxs)(`details`,{className:`mt-1`,children:[(0,h.jsx)(`summary`,{className:`cursor-pointer`,children:`Error details`}),(0,h.jsx)(`pre`,{className:`m-0 mt-1 max-h-48 overflow-auto whitespace-pre-wrap break-words font-mono text-small`,children:n.detail})]})]})})}var qge={research:`Research again`,article:`Write the article again`,audio:`Record the narration again`,images:`Make all images again`,thumbnail:`Make the thumbnails again`,video:`Render the video again`,document:`Render the PDF again`};function f5(e,t){return e===`video`&&t.config.sources.video===`off`?`Export the audio again`:qge[e]}function p5({id:e,title:t,kicker:n,stages:r,project:i,outputs:a,actions:o,next:s,active:c,meta:l,head:u=!0,extra:d,resumable:f=!1,children:p}){let m=r[0],g=r.some(e=>o.refusal?.stage===e.kind)?o.refusal?.message:void 0,_=r.filter(t=>t.state===`failed`&&t.retryAt===void 0&&(s.next?.situation!==`failed`||s.next.section!==e)),v=r.find(e=>e.state===`running`),y=v===void 0||v.progressTotal===null||v.progressTotal<=0?void 0:Math.min(1,Math.max(0,(v.progressCurrent??0)/v.progressTotal)),b=l??(m===void 0?void 0:r.filter(e=>e.state!==`skipped`).map(e=>e===m?tF(e,a,i,f):`${s5[e.kind]}: ${tF(e,a,i,f)}`).join(` · `));return(0,h.jsxs)(`section`,{hidden:!c,"aria-label":t,"data-tour":m===void 0?void 0:`project-${m.kind}`,className:`flex min-w-0 flex-col gap-5`,children:[u?(0,h.jsxs)(V,{title:t,...n===void 0?{}:{kicker:n},...b===void 0||b===``?{}:{meta:b},children:[d,(0,h.jsx)(h5,{stages:r,project:i,actions:o})]}):null,y===void 0||v===void 0?null:(0,h.jsx)(u4,{value:y,label:`${s5[v.kind]} progress`,valueText:tF(v,a,i,f)}),(0,h.jsx)(Kge,{state:s,section:e}),_.map(e=>(0,h.jsx)(fI,{tone:`danger`,title:`${s5[e.kind]} stopped with an error.`,children:e.failureReason===null?void 0:(0,h.jsxs)(`details`,{children:[(0,h.jsx)(`summary`,{className:`cursor-pointer`,children:`Error details`}),(0,h.jsx)(`pre`,{className:`m-0 mt-1 max-h-48 overflow-auto whitespace-pre-wrap break-words font-mono text-small`,children:e.failureReason})]})},e.id)),g===void 0?null:(0,h.jsx)(fI,{tone:`danger`,title:g,actions:(0,h.jsx)(L,{variant:`quiet`,size:`small`,onClick:o.dismissRefusal,children:`Dismiss`})}),m?.state===`running`&&m.kind!==`article`&&m.kind!==`images`&&m.kind!==`video`&&m.kind!==`document`?(0,h.jsx)(q3,{projectId:i.id,stage:m.kind}):null,p]})}function m5({stage:e,project:t,name:n}){return e===void 0||e.state===`skipped`?(0,h.jsx)(T0,{title:`${n} is off for this run.`,children:`Switch it on in the project settings to make it.`}):(0,h.jsx)(T0,{title:`No ${n.toLowerCase()} yet.`,children:t.status===`paused`?`It is made once you continue the run.`:`It starts when the steps before it are done. Finished work elsewhere can be looked at meanwhile.`})}function h5({stages:e,project:t,actions:n}){let r=(0,m.useContext)(r5),i=k8(),[a,o]=(0,m.useState)(),s=e.filter(e=>e.state!==`skipped`&&e.state!==`pending`&&(!r||i!==void 0&&Nge(i,e.kind)));if(s.length===0)return null;let c=n.pending||t.status===`running`||e.some(e=>e.state===`running`),l=a===void 0?void 0:n5({kind:`rerun`,stage:a});return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(w8,{modal:!1,children:[(0,h.jsx)(T8,{asChild:!0,children:(0,h.jsx)(Cy,{label:`More actions for ${s5[e[0]?.kind??`article`]}`,children:(0,h.jsx)(mc,{"aria-hidden":`true`,strokeWidth:1.75})})}),(0,h.jsx)(E8,{children:s.map(e=>(0,h.jsx)(D8,{disabled:c,onSelect:()=>o(e.kind),children:f5(e.kind,t)},e.id))})]}),(0,h.jsx)(Ay,{open:a!==void 0,title:a===void 0?``:`${f5(a,t)}?`,consequence:l?.consequence??``,confirmLabel:a===void 0?``:f5(a,t),cancelLabel:`Keep what is there`,pending:n.pending,onConfirm:()=>{let e=a;o(void 0),e!==void 0&&n.run({kind:`rerun`,stage:e})},onCancel:()=>o(void 0)})]})}function Jge({stage:e,project:t,outputs:n,actions:r,busy:i}){let a=S8(n,e),o=W8(t.id),s=RS(t.config),c=Array.from({length:s},(e,t)=>t+1).map(e=>({variant:e,output:a.find(t=>t.role===`thumbnail`&&(t.meta.index??1)===e)})),l=c.flatMap(e=>e.output===void 0?[]:[e.output]),u=j8(l),[d,f]=(0,m.useState)(null),p=l.filter(e=>u.has(e.id)),g=p.map(e=>({src:u.get(e.id)?.url??``,alt:`Thumbnail ${String(e.meta.index??1)}`})),_=t.format===`9:16`,v=({variant:n,output:a})=>(0,h.jsx)(Yge,{variant:n,count:s,output:a,review:G8(o,{outputId:a?.id}),stage:e,project:t,actions:r,busy:i,onOpen:()=>f(a===void 0?null:Xge(p,a))},n);return(0,h.jsxs)(`section`,{"aria-label":s===1?`Thumbnail`:`Thumbnails`,className:`flex min-w-0 flex-col gap-5`,children:[(0,h.jsxs)(V,{title:s===1?`Thumbnail`:`Thumbnails`,meta:s===1?`The picture YouTube shows before the video plays`:`${String(s)} variants for YouTube's Test & compare`,children:[(0,h.jsx)(L8,{variant:`secondary`,files:l.map(e=>({output:e,label:s===1?`Thumbnail`:`Thumbnail ${String(e.meta.index??1)}`}))}),(0,h.jsx)(R8,{output:l[0]}),(0,h.jsx)(h5,{stages:[e],project:t,actions:r})]}),c.length===1?(0,h.jsx)(`div`,{className:_?`max-w-[280px]`:`max-w-[480px]`,children:c.map(v)}):(0,h.jsx)(o2,{list:!0,label:`Thumbnail variants`,children:c.map(e=>(0,h.jsx)(`li`,{className:`min-w-0`,children:v(e)},e.variant))}),(0,h.jsx)(s2,{items:g,index:d,onIndex:f,onClose:()=>f(null),actions:(e,t)=>{let n=p[t];return n===void 0?null:(0,h.jsx)(b5,{output:n,name:s===1?`the thumbnail`:`thumbnail ${String(n.meta.index??1)}`,actions:r,busy:i,onLeave:()=>f(null)},n.id)}})]})}function Yge({variant:e,count:t,output:n,review:r,stage:i,project:a,actions:o,busy:s,onOpen:c}){let l=A8(n),u=a5(n,o,s),d=t===1?`the thumbnail`:`thumbnail ${String(e)}`;_x({id:`project.thumbnail.${String(e)}`,title:t===1?`Regenerate the thumbnail`:`Regenerate thumbnail ${String(e)}`,group:`This project`,context:a.title,keywords:[`thumbnail`,`redraw`,`remake`],run:()=>u.act(`regenerate-image`)});let f=r!==void 0&&!r.passed&&r.action===null,p=String.fromCharCode(64+e),m=u.asking===void 0||n===void 0?void 0:n5({kind:u.asking,outputId:n.id});return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(a2,{alt:t===1?`Thumbnail for ${a.title}`:`Thumbnail ${String(e)} for ${a.title}`,aspect:g5(a.format),...l===void 0?{}:{src:l.url},...n===void 0&&i.state===`running`?{generating:`Making the thumbnail`}:{},title:t===1?`Thumbnail`:p,...n===void 0?{meta:Zge(i)}:{},onOpen:c,openLabel:`Open ${d} full size`,...r===void 0?{}:{badge:(0,h.jsx)(X8,{review:r})},actionsShown:f,...n===void 0?{}:{actions:(0,h.jsxs)(h.Fragment,{children:[f&&r!==void 0?(0,h.jsx)(J8,{review:r,projectId:a.id,busy:s}):null,(0,h.jsxs)(L,{size:`small`,disabled:u.unavailable,disabledReason:`Wait until the work on this project is done`,onClick:()=>u.act(`regenerate-image`),"aria-label":`Regenerate ${d}`,children:[(0,h.jsx)(jc,{"aria-hidden":`true`,strokeWidth:1.75}),`Regenerate`]}),l===void 0?null:(0,h.jsx)(x5,{href:l.url,label:`Download ${d}`})]})}}),(0,h.jsx)(Ay,{open:u.asking!==void 0,tone:`primary`,title:m?.title??``,consequence:m?.consequence??``,confirmLabel:`Regenerate the thumbnail`,cancelLabel:`Keep it`,pending:o.pending,onConfirm:u.confirm,onCancel:u.dismiss})]})}function Xge(e,t){let n=e.indexOf(t);return n===-1?null:n}function Zge(e){switch(e.state){case`running`:return`Being made`;case`failed`:case`canceled`:return`Not made`;default:return`Not made yet`}}function Qge(e,t){let n=e.filter(e=>e.role===`image`),r=new Map;for(let e of n){let t=e.meta.promptName??`Images`;r.set(t,[...r.get(t)??[],e])}let i=t.filter(e=>r.has(e)),a=[...r.keys()].filter(e=>!i.includes(e)).sort();return[...i,...a].flatMap(e=>{let t=r.get(e);return t===void 0?[]:[{name:e,images:[...t].sort($ge)}]})}function $ge(e,t){return(e.meta.index??0)-(t.meta.index??0)}function e_e(e,t,n,r,i){let a=Dy(),[o,s]=(0,m.useState)(),c=(r,i)=>{let o=r===`image`?t:n,c=r===`image`?`image`:`on-screen card`;if(i===void 0){a(`Type the ${c}'s number with the command, for example "regenerate ${c} 3".`);return}let l=o.find(e=>e.meta.index===i);if(l===void 0){let t=o.flatMap(e=>e.meta.index===void 0?[]:[e.meta.index]);a(t.length===0?`${e.title} has no ${c}s yet, so there is no ${c} ${String(i)} to regenerate. They appear under Images once the run makes them.`:`${e.title} has no ${c} ${String(i)}: its ${c}s are numbered ${String(Math.min(...t))} to ${String(Math.max(...t))}. Type one of those, or press Regenerate on the ${c} in Images.`,`error`);return}s(e=>({image:l,name:`${c[0]?.toUpperCase()??``}${c.slice(1)} ${String(i)}`,nonce:(e?.nonce??0)+1}))};return _x({id:`project.image.regenerate`,title:`Regenerate an image`,numbered:e=>`Regenerate image ${String(e)}`,group:`This project`,context:e.title,keywords:[`image`,`picture`,`redraw`,`remake`],searchOnly:!0,run:e=>c(`image`,e)}),_x({id:`project.card.regenerate`,title:`Regenerate an on-screen card`,numbered:e=>`Regenerate on-screen card ${String(e)}`,group:`This project`,context:e.title,keywords:[`card`,`figure`,`table`,`redraw`,`remake`],searchOnly:!0,run:e=>c(`card`,e)}),Kx(Vx.regenerateImage(e.id),e=>c(`image`,e)),o===void 0?null:(0,h.jsx)(t_e,{request:o,actions:r,busy:i},o.nonce)}function t_e({request:e,actions:t,busy:n}){let r=Dy(),i=a5(e.image,t,n),a=(0,m.useRef)(!1);(0,m.useEffect)(()=>{!a.current&&i.ready&&(a.current=!0,i.unavailable?r(`${e.name} can't be regenerated while work on this project is running. Wait until it finishes, then run the command again or press Regenerate on it in Images.`,`error`):i.act(`regenerate-image`))},[i,r,e.name]);let o=i.asking===void 0?void 0:n5({kind:i.asking,outputId:e.image.id});return(0,h.jsx)(Ay,{open:i.asking!==void 0,tone:`primary`,title:o?.title??``,consequence:o?.consequence??``,confirmLabel:`Regenerate the image`,cancelLabel:`Keep it`,pending:t.pending,onConfirm:i.confirm,onCancel:i.dismiss})}function g5(e){return e===`9:16`?`portrait`:`landscape`}function n_e({stage:e,companion:t,project:n,outputs:r,actions:i,busy:a}){let o=W8(n.id),s=S8(r,e),c=Qge(s,n.config.imagePrompts?.map(e=>e.name)??[]),l=c.flatMap(e=>e.images),u=s.filter(e=>e.role===`figure_card`&&(e.meta.format??n.format)===n.format).toSorted((e,t)=>(e.meta.index??0)-(t.meta.index??0)),d=[...l,...u],f=e_e(n,l,u,i,a),p=Mge(l,a),g=j8(d),[_,v]=(0,m.useState)(null),y=d.filter(e=>g.has(e.id)),b=y.map(e=>({src:g.get(e.id)?.url??``,alt:e.role===`figure_card`?`On-screen card ${String(e.meta.index??``)}`:e.meta.prompt??`Image ${String(e.meta.index??``)}`,..._5(e)?{kind:`video`}:{},caption:e.role===`figure_card`?`Shown while the narration describes it`:e.meta.prompt??e.meta.promptName??`Slideshow image`})),x=n.config.reference===void 0?null:(0,h.jsx)(r_e,{image:C8(s,`reference`),format:n.format,generated:n.config.reference.source===`prompt`,affected:l.length,actions:i,busy:a}),S=t?.kind===`thumbnail`?(0,h.jsx)(Jge,{stage:t,project:n,outputs:r,actions:i,busy:a}):null,C=e.state===`running`&&e.progressTotal!==null?Math.max(0,e.progressTotal-l.length):0,w=o.filter(e=>l.some(t=>t.id===e.outputId)),T=w.filter(e=>e.passed&&e.attempt>1).length,E=w.filter(e=>!e.passed&&e.action===null).length,D=[l.length===0?void 0:`${String(l.length)} in the video`,w.length===0?void 0:`reviewed`,T===0?void 0:`${String(T)} redone after review`,E===0?void 0:`${String(E)} flagged`].filter(e=>e!==void 0).join(` · `);return(0,h.jsxs)(h.Fragment,{children:[f,x,x===null||S===null&&e.state===`skipped`?null:(0,h.jsx)(Nq,{className:`m-0`}),S,S===null||e.state===`skipped`?null:(0,h.jsx)(Nq,{className:`m-0`}),e.state===`skipped`?null:(0,h.jsxs)(`section`,{"aria-label":`Slideshow images`,className:`flex min-w-0 flex-col gap-5`,children:[(0,h.jsxs)(V,{title:`Images`,...D===``?{}:{meta:D},children:[p===void 0?null:(0,h.jsxs)(L,{size:`small`,disabled:p.unavailable,disabledReason:`Wait until the work on this project is done`,onClick:p.act,children:[(0,h.jsx)(jc,{"aria-hidden":`true`,strokeWidth:1.75}),`Regenerate all`]}),(0,h.jsx)(oge,{projectId:n.id,asset:`images.zip`,label:`Download all`}),(0,h.jsx)(h5,{stages:[e],project:n,actions:i})]}),c.length===0&&C===0?(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:e.state===`pending`?`The images are made once the narration is timed.`:`No images have landed yet.`}):null,c.map((e,t)=>(0,h.jsx)(S5,{name:e.name,count:e.images.length,showName:c.length>1,trailing:t===c.length-1&&C>0?Array.from({length:Math.min(C,3)},(e,t)=>(0,h.jsx)(a2,{alt:`An image being made`,aspect:g5(n.format),generating:t===0?`Drawing the next image`:`Waiting its turn`},t)):null,children:t=>e.images.slice(0,t).map(e=>(0,h.jsx)(C5,{image:e,projectId:n.id,review:G8(o,{outputId:e.id}),format:n.format,actions:i,busy:a,onOpen:()=>v(y5(y,e))},e.id))},e.name)),u.length===0?null:(0,h.jsx)(S5,{name:`From the article`,count:u.length,showName:!0,children:e=>u.slice(0,e).map(e=>(0,h.jsx)(C5,{image:e,projectId:n.id,review:void 0,format:n.format,actions:i,busy:a,card:!0,onOpen:()=>v(y5(y,e))},e.id))}),c.length===0&&C>0?(0,h.jsx)(o2,{label:`Images being made`,children:Array.from({length:Math.min(C,3)},(e,t)=>(0,h.jsx)(a2,{alt:`An image being made`,aspect:g5(n.format),generating:t===0?`Drawing the first image`:`Waiting its turn`},t))}):null,(0,h.jsx)(s2,{items:b,index:_,onIndex:v,onClose:()=>v(null),actions:(e,t)=>{let n=y[t];return n===void 0?null:(0,h.jsx)(b5,{output:n,name:n.role===`figure_card`?`on-screen card${v5(n)}`:`image${v5(n)}`,actions:i,busy:a,onLeave:()=>v(null)},n.id)}})]})]})}var _5=e=>/\.(mp4|mov|m4v|webm|mkv)$/i.test(e.path),v5=e=>e.meta.index===void 0?``:` ${String(e.meta.index)}`;function y5(e,t){let n=e.indexOf(t);return n===-1?null:n}function b5({output:e,name:t,actions:n,busy:r,onLeave:i}){let a=A8(e),o=a5(e,n,r),s=o.asking===void 0?void 0:n5({kind:o.asking,outputId:e.id});return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(L,{size:`small`,disabled:o.unavailable,disabledReason:`Wait until the work on this project is done`,onClick:()=>{o.act(`regenerate-image`),o.viaEdit&&i()},"aria-label":`Regenerate ${t}`,children:[(0,h.jsx)(jc,{"aria-hidden":`true`,strokeWidth:1.75}),`Regenerate`]}),a===void 0?null:(0,h.jsx)(x5,{href:a.url,label:`Download ${t}`}),(0,h.jsx)(Ay,{open:o.asking!==void 0,tone:`primary`,title:s?.title??``,consequence:s?.consequence??``,confirmLabel:`Regenerate it`,cancelLabel:`Keep it`,pending:n.pending,onConfirm:o.confirm,onCancel:o.dismiss})]})}function x5({href:e,label:t,text:n}){return(0,h.jsxs)(dS,{href:e,download:!0,"aria-label":t,title:t,size:`small`,children:[(0,h.jsx)(pc,{"aria-hidden":`true`,strokeWidth:1.75}),n]})}function r_e({image:e,format:t,generated:n,affected:r,actions:i,busy:a}){let o=A8(e),s=a5(e,i,a),[c,l]=(0,m.useState)(null);return(0,h.jsxs)(`section`,{"aria-label":`Establishing image`,className:`flex min-w-0 flex-col gap-5`,children:[(0,h.jsx)(V,{kicker:`Reference · not in the video`,title:`Establishing image`,meta:`Every image follows it for the look, palette and style`,children:e!==void 0&&n?(0,h.jsx)(L,{disabled:s.unavailable,disabledReason:`Wait until the work on this project is done`,onClick:()=>s.act(`regenerate-image`),children:`Make the establishing image again`}):null}),(0,h.jsx)(a2,{className:`w-full max-w-[360px]`,alt:e?.meta.prompt??`Establishing image`,aspect:g5(t),...o===void 0?{}:{src:o.url},title:`Establishing image`,...e===void 0?{meta:`Not made yet`}:{},onOpen:()=>l(0),openLabel:`Open the establishing image full size`,...e===void 0||o===void 0?{}:{actions:(0,h.jsx)(x5,{href:o.url,label:`Download the establishing image`,text:`Download`})}}),n&&r>0?(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:`Making it again marks ${String(r)} image${r===1?``:`s`} outdated. They keep their current version until you remake them.`}):null,(0,h.jsx)(s2,{items:o===void 0?[]:[{src:o.url,alt:`Establishing image`,caption:e?.meta.prompt??`The reference every image follows`}],index:c,onIndex:l,onClose:()=>l(null),actions:()=>o===void 0?null:(0,h.jsxs)(h.Fragment,{children:[n?(0,h.jsxs)(L,{size:`small`,disabled:s.unavailable,disabledReason:`Wait until the work on this project is done`,onClick:()=>{l(null),s.act(`regenerate-image`)},"aria-label":`Make the establishing image again`,children:[(0,h.jsx)(jc,{"aria-hidden":`true`,strokeWidth:1.75}),`Regenerate`]}):null,(0,h.jsx)(x5,{href:o.url,label:`Download the establishing image`})]})}),(0,h.jsx)(Ay,{open:s.asking!==void 0,tone:`primary`,title:`Make the establishing image again?`,consequence:`A new establishing image replaces this one${r>0?`, and the ${String(r)} images drawn from it become outdated until you remake them`:``}. The old one stays in History.`,confirmLabel:`Make it again`,cancelLabel:`Keep this one`,pending:i.pending,onConfirm:s.confirm,onCancel:s.dismiss})]})}function S5({name:e,count:t,showName:n,trailing:r,children:i}){let[a,o]=(0,m.useState)(!1),s=t>12&&!a;return(0,h.jsxs)(`section`,{"aria-label":`${e} × ${String(t)}`,className:`flex flex-col gap-3`,children:[n?(0,h.jsx)(`h3`,{className:`sl-kicker m-0`,children:`${e} × ${String(t)}`}):null,(0,h.jsxs)(o2,{children:[i(s?12:t),r]}),t>12?(0,h.jsx)(L,{variant:`quiet`,"aria-expanded":a,className:`self-start`,onClick:()=>o(e=>!e),children:a?`Show fewer`:`Show all ${String(t)} images`}):null]})}function C5({image:e,projectId:t,review:n,format:r,actions:i,busy:a,card:o=!1,onOpen:s}){let c=A8(e),l=v5(e),u=o?`on-screen card${l}`:`image${l}`,d=a5(e,i,a),f=jge(e),p=n!==void 0&&!n.passed&&n.action===null,m=d.asking===void 0?void 0:n5({kind:d.asking,outputId:e.id});return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(a2,{alt:o?`On-screen card${l}`:e.meta.prompt??`Slideshow ${u}`,kind:_5(e)?`video`:`image`,aspect:g5(r),...c===void 0?{}:{src:c.url},title:o?`Card${l}`:e.meta.prompt??`Image${l}`,...e.meta.index===void 0?{}:{meta:`#${String(e.meta.index)}`},onOpen:s,openLabel:`Open ${u} full size`,...n===void 0&&!f?{}:{badge:(0,h.jsxs)(`span`,{className:`inline-flex flex-wrap gap-1`,children:[f?(0,h.jsx)(hS,{tone:`info`,children:`Outdated`}):null,n===void 0?null:(0,h.jsx)(X8,{review:n})]})},actionsShown:p,actions:(0,h.jsxs)(h.Fragment,{children:[p&&n!==void 0?(0,h.jsx)(J8,{review:n,projectId:t,busy:a}):null,(0,h.jsxs)(L,{size:`small`,disabled:d.unavailable,disabledReason:`Wait until the work on this project is done`,onClick:()=>d.act(`regenerate-image`),"aria-label":`Regenerate ${u}`,children:[(0,h.jsx)(jc,{"aria-hidden":`true`,strokeWidth:1.75}),`Regenerate`]}),c===void 0?null:(0,h.jsx)(x5,{href:c.url,label:`Download ${u}`}),o?null:(0,h.jsx)(L,{size:`small`,variant:`destructive`,disabled:d.unavailable,disabledReason:`Wait until the work on this project is done`,onClick:()=>d.act(`delete-image`),"aria-label":`Delete ${u}`,title:`Delete ${u}`,children:(0,h.jsx)(Ic,{"aria-hidden":`true`,strokeWidth:1.75})})]})}),(0,h.jsx)(Ay,{open:d.asking!==void 0,tone:d.asking===`delete-image`?`destructive`:`primary`,title:m?.title??``,consequence:m?.consequence??``,confirmLabel:d.asking===`delete-image`?`Delete the image`:`Regenerate the image`,cancelLabel:`Keep it`,pending:i.pending,onConfirm:d.confirm,onCancel:d.dismiss})]})}function w5(e){let t=Math.max(0,Math.floor(e)),n=Math.floor(t/3600),r=Math.floor(t%3600/60),i=String(t%60).padStart(2,`0`);return n>0?`${String(n)}:${String(r).padStart(2,`0`)}:${i}`:`${String(r)}:${i}`}function T5(e){let t=/^(?:(\d+):)?(\d{1,2}):(\d{2})$/.exec(e.trim());if(t===null)return;let n=Number(t[1]??`0`),r=Number(t[2]),i=Number(t[3]);if(!(i>59||t[1]!==void 0&&r>59))return n*3600+r*60+i}function i_e(e){let t=e.trim(),n=/^(\S+)\s+(.+)$/u.exec(t);if(n===null)return;let r=T5(n[1]??``),i=(n[2]??``).trim();return r===void 0||i===``?void 0:{start:r,title:i}}function E5(e,t){let n=e.replace(/\r\n?/gu,`
291
291
  `).split(`
292
- `),r=[],i=[];for(let[e,t]of n.entries()){let n=r_e(t);n!==void 0&&(r.push(e),i.push(n))}if(i.length===0)return{text:e,adjustments:[]};let a=[],o=e=>`"${e.title}"`,s=[...i].sort((e,t)=>e.start-t.start);s.some((e,t)=>e!==i[t])&&a.push(`put the chapters in time order`);let c=[];for(let e of s){let t=c.at(-1);t!==void 0&&t.start===e.start?a.push(`merged ${o(e)} (0 s) into ${o(t)}`):c.push(e)}s=c;let l=t!==void 0&&Number.isFinite(t)&&t>0?t:void 0;if(l!==void 0){let e=s.filter((e,t)=>t>0&&e.start>=l);for(let t of e)a.push(`removed ${o(t)} (${w5(t.start)}), which starts after the video ends at ${w5(l)}`);s=s.filter(t=>!e.includes(t))}let u=s[0];u!==void 0&&u.start!==0&&(a.push(`moved the first, ${o(u)}, from ${w5(u.start)} to 0:00`),s=[{start:0,title:u.title},...s.slice(1)]);let d=e=>{let t=s[e+1],n=s[e]?.start??0;return t===void 0?l===void 0?1/0:l-n:t.start-n},f=e=>`${String(Math.max(0,Math.floor(e)))} s`;for(;s.length>1;){let e=s.findIndex((e,t)=>d(t)<10);if(e===-1)break;let t=s[e];if(t===void 0)break;let n=f(d(e));if(e===0){let e=s[1];if(e===void 0)break;a.push(`merged ${o(t)} (${n}) into ${o(e)}`),s=[{start:0,title:e.title},...s.slice(2)]}else{let r=s[e-1];if(r===void 0)break;a.push(`merged ${o(t)} (${n}) into ${o(r)}`),s=s.filter((t,n)=>n!==e)}}if(s.length<3&&(a.push(`left the chapter list out, since YouTube needs at least 3 chapters of 10 s or more and only ${String(s.length)} ${s.length===1?`is`:`are`} left`),s=[]),a.length===0)return{text:e,adjustments:a};let p=new Map(r.map((e,t)=>[e,s[t]]));return{text:n.flatMap((e,t)=>{if(!p.has(t))return[e];let n=p.get(t);return n===void 0?[]:[`${w5(n.start)} ${n.title}`]}).join(`
293
- `).trim(),adjustments:a}}function i_e(e){return e.length===0?void 0:`Chapters adjusted for YouTube: ${e.join(`; `)}.`}function D5(e,t){let n=e.replace(/\r\n?/gu,`
292
+ `),r=[],i=[];for(let[e,t]of n.entries()){let n=i_e(t);n!==void 0&&(r.push(e),i.push(n))}if(i.length===0)return{text:e,adjustments:[]};let a=[],o=e=>`"${e.title}"`,s=[...i].sort((e,t)=>e.start-t.start);s.some((e,t)=>e!==i[t])&&a.push(`put the chapters in time order`);let c=[];for(let e of s){let t=c.at(-1);t!==void 0&&t.start===e.start?a.push(`merged ${o(e)} (0 s) into ${o(t)}`):c.push(e)}s=c;let l=t!==void 0&&Number.isFinite(t)&&t>0?t:void 0;if(l!==void 0){let e=s.filter((e,t)=>t>0&&e.start>=l);for(let t of e)a.push(`removed ${o(t)} (${w5(t.start)}), which starts after the video ends at ${w5(l)}`);s=s.filter(t=>!e.includes(t))}let u=s[0];u!==void 0&&u.start!==0&&(a.push(`moved the first, ${o(u)}, from ${w5(u.start)} to 0:00`),s=[{start:0,title:u.title},...s.slice(1)]);let d=e=>{let t=s[e+1],n=s[e]?.start??0;return t===void 0?l===void 0?1/0:l-n:t.start-n},f=e=>`${String(Math.max(0,Math.floor(e)))} s`;for(;s.length>1;){let e=s.findIndex((e,t)=>d(t)<10);if(e===-1)break;let t=s[e];if(t===void 0)break;let n=f(d(e));if(e===0){let e=s[1];if(e===void 0)break;a.push(`merged ${o(t)} (${n}) into ${o(e)}`),s=[{start:0,title:e.title},...s.slice(2)]}else{let r=s[e-1];if(r===void 0)break;a.push(`merged ${o(t)} (${n}) into ${o(r)}`),s=s.filter((t,n)=>n!==e)}}if(s.length<3&&(a.push(`left the chapter list out, since YouTube needs at least 3 chapters of 10 s or more and only ${String(s.length)} ${s.length===1?`is`:`are`} left`),s=[]),a.length===0)return{text:e,adjustments:a};let p=new Map(r.map((e,t)=>[e,s[t]]));return{text:n.flatMap((e,t)=>{if(!p.has(t))return[e];let n=p.get(t);return n===void 0?[]:[`${w5(n.start)} ${n.title}`]}).join(`
293
+ `).trim(),adjustments:a}}function a_e(e){return e.length===0?void 0:`Chapters adjusted for YouTube: ${e.join(`; `)}.`}function D5(e,t){let n=e.replace(/\r\n?/gu,`
294
294
  `).split(`
295
- `);for(;n.length>0&&n.at(-1)?.trim()===``;)n.pop();let r=``,i=n.at(-1)?.trim()??``;for(i!==``&&i.split(/\s+/u).every(e=>/^#[\p{L}\p{N}_]+$/u.test(e))&&(r=i,n.pop());n.length>0&&n.at(-1)?.trim()===``;)n.pop();let a=[];for(;n.length>0&&a_e(n.at(-1)??``);)a.unshift((n.pop()??``).trim());return{summary:n.join(`
295
+ `);for(;n.length>0&&n.at(-1)?.trim()===``;)n.pop();let r=``,i=n.at(-1)?.trim()??``;for(i!==``&&i.split(/\s+/u).every(e=>/^#[\p{L}\p{N}_]+$/u.test(e))&&(r=i,n.pop());n.length>0&&n.at(-1)?.trim()===``;)n.pop();let a=[];for(;n.length>0&&o_e(n.at(-1)??``);)a.unshift((n.pop()??``).trim());return{summary:n.join(`
296
296
  `).trim(),chapters:a.join(`
297
- `),hashtags:r,tags:t.trim()}}function a_e(e){let[t=``,...n]=e.trim().split(/\s+/u);return T5(t)!==void 0&&n.length>0}function o_e(e){return[e.summary.trim(),e.chapters.trim(),e.hashtags.trim()].filter(e=>e!==``).join(`
297
+ `),hashtags:r,tags:t.trim()}}function o_e(e){let[t=``,...n]=e.trim().split(/\s+/u);return T5(t)!==void 0&&n.length>0}function s_e(e){return[e.summary.trim(),e.chapters.trim(),e.hashtags.trim()].filter(e=>e!==``).join(`
298
298
 
299
- `)}function s_e(e,t){return t===void 0?{text:e??``,edited:!1}:e===void 0||t.base===e?{text:t.text,edited:!0}:t.text===e?{text:e,edited:!1}:{text:t.text,edited:!0,pending:e}}function O5(e,t){let n=n=>s_e(e?.[n],t[n]);return{summary:n(`summary`),chapters:n(`chapters`),hashtags:n(`hashtags`),tags:n(`tags`)}}function k5(e){return{summary:e.summary.text,chapters:e.chapters.text,hashtags:e.hashtags.text,tags:e.tags.text}}var c_e=K({number:W().int().positive(),first:W().int().positive(),last:W().int().positive(),start:W().finite().nonnegative(),end:W().finite().positive(),title:U(),description:U(),hashtags:G(U()),why:U(),text:U(),seed:U().nullable().optional()}),l_e=.25,u_e=.4;function A5(e,t,n,r){let i=e[t-1],a=e[n-1];if(i===void 0||a===void 0||t>n)return;let o=e[t-2]?.end??0,s=e[n]?.start??r,c=Math.max(0,i.start-Math.max(0,Math.min(l_e,(i.start-o)/2))),l=Math.min(r,a.end+Math.max(0,Math.min(u_e,(s-a.end)/2)));return{start:j5(c),end:j5(l)}}K({first:uO([W(),U()]),last:uO([W(),U()]),title:U(),description:U(),hashtags:G(U()),why:U().optional()});function j5(e){return Math.round(e*1e3)/1e3}var d_e=K({shorts:G(c_e),durationSeconds:W().finite().nonnegative().optional(),sentences:G(K({start:W().finite().nonnegative(),end:W().finite().nonnegative(),text:U()})).optional()});function f_e(e){if(e!=null)try{let t=d_e.safeParse(JSON.parse(e));return t.success?t.data:void 0}catch{return}}function p_e(e,t,n,r,i,a=[]){let o=e.sentences;if(o===void 0||o.length===0)return`These shorts were picked before clips could be adjusted by hand. Use Pick different moments, then adjust the new clips.`;if(!e.shorts.some(e=>e.number===t))return`There is no short ${String(t)} any more. Reload the page and choose again.`;if(!Number.isInteger(n)||!Number.isInteger(r)||n<1||r>o.length||n>r)return`Choose a start sentence that comes before the end sentence, between 1 and ${String(o.length)}.`;let s=A5(o,n,r,m_e(e));if(s===void 0)return`Choose a start and an end sentence from the transcript.`;let c=s.end-s.start;if(c<i.minSeconds-.01)return`Short ${String(t)} would last ${String(Math.round(c))} seconds, shorter than the ${String(i.minSeconds)}-second minimum. Start it earlier or end it later.`;if(c>i.maxSeconds+.01)return`Short ${String(t)} would last ${String(Math.round(c))} seconds, longer than the ${String(i.maxSeconds)}-second maximum. Start it later or end it earlier.`;let l=a.find(e=>e.number!==t&&n<=e.last&&r>=e.first);if(l!==void 0)return`Short ${String(t)} would share sentences with short ${String(l.number)} (sentences ${String(l.first)}-${String(l.last)}). Choose a range that doesn't overlap it.`}function m_e(e){return e.durationSeconds??e.sentences?.at(-1)?.end??0}function M5(e){let t=Object.fromEntries(Object.entries(e.content.imageDefinitions).map(([t,n])=>{let r=n.templateKey===null||n.templateKey===void 0?null:e.content.promptTemplates[n.templateKey]??null;return[t,r===null||n.source!==`generate`?n:{...n,prompt:hq(r,e.config.values)}]}));return{...e,content:{...e.content,imageDefinitions:t},config:{...e.config,rendered:{...e.config.rendered,...Object.fromEntries(Object.entries(e.content.promptTemplates).map(([t,n])=>[t,n===null?e.config.rendered[t]??``:hq(n,e.config.values)]))}}}}function h_e(e,t,n){let r={...e.config.sources,[t]:n,...t===`images`&&n===`off`?{video:`off`}:{}};return{...e,config:{...e.config,sources:r,subtitles:PN(e.config.subtitles,r)}}}function N5(e,t,n){return M5({...e,content:{...e.content,promptTemplates:{...e.content.promptTemplates,[t]:n}}})}function g_e(e){return new Promise((t,n)=>{if(e.aborted){n(Error(`Upload canceled.`));return}let r=()=>{clearTimeout(i),n(Error(`Upload canceled.`))},i=setTimeout(()=>{e.removeEventListener(`abort`,r),t()},200);e.addEventListener(`abort`,r,{once:!0})})}function P5({label:e,kind:t,disabled:n=!1,onReady:r,onPending:i,accept:a}){let{api:o}=R(),s=(0,m.useId)(),[c,l]=(0,m.useState)(),[u,d]=(0,m.useState)(!1),f=(0,m.useRef)(void 0),p=(0,m.useRef)(r);p.current=r;let g=(0,m.useRef)(i);g.current=i;let _=(0,m.useRef)(!0);(0,m.useEffect)(()=>(_.current=!0,()=>{_.current=!1,f.current?.abort(),g.current(!1)}),[]);async function v(e){if(n||f.current!==void 0)return;let r=new AbortController;f.current=r,d(!0),g.current(!0),l(void 0);let i;try{let n=await Ro(o,t,e);for(i=n.id,r.signal.throwIfAborted();n.state!==`staged`;){await g_e(r.signal);let e=(await jo(o)).files.find(e=>e.id===n.id);if(r.signal.throwIfAborted(),e===void 0)throw Error(`The upload stopped before the file finished copying. Choose the file again.`);n=e}p.current(n)}catch(e){let t=r.signal.aborted?`Upload canceled.`:e instanceof Error?e.message:String(e);if(i!==void 0)try{await zo(o,i)}catch(e){t+=` The partial upload couldn't be removed (${e instanceof Error?e.message:String(e)}); use Clean orphan files in Settings → Backup & storage to clear it.`}_.current?l(t):t.includes(`partial upload couldn't be removed`)&&console.error(t)}finally{f.current===r&&(f.current=void 0,_.current&&(d(!1),g.current(!1)))}}return(0,h.jsxs)(`div`,{className:`space-y-2`,children:[(0,h.jsx)(Y,{label:e,id:s,children:(0,h.jsx)(OV,{id:s,type:`file`,disabled:u||n,accept:a??(t===`audio`?`audio/*`:`image/png,image/jpeg,image/webp`),onChange:e=>{let t=e.target.files?.[0];e.target.value=``,t!==void 0&&v(t)}})}),u?(0,h.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,h.jsx)(`p`,{role:`status`,className:`text-small text-ink-2`,children:`Copying upload…`}),(0,h.jsx)(L,{type:`button`,onClick:()=>f.current?.abort(),children:`Cancel upload`})]}):null,c===void 0?null:(0,h.jsx)(`p`,{role:`alert`,className:`text-small text-danger`,children:c})]})}var F5=`shorts:pick`,I5=e=>`shorts:${String(e)}`;function L5(e){let{shortsRanges:t,...n}=e.content;return{...e,content:n,regenerate:[...new Set([...e.regenerate??[],F5])]}}function R5(e,t){return{...e,regenerate:[...new Set([...e.regenerate??[],I5(t)])]}}function __e(e){let t=e.pieces.find(e=>e.key===`shorts:pick`&&e.selected&&e.piece.state===`done`),n=f_e(t?.piece.payload);return t===void 0||n===void 0?void 0:{fingerprint:t.fingerprint,picked:n}}function v_e({edit:e,view:t,prompts:n,problem:r,onChange:i,onPending:a}){let o=e.config.shorts??Kk,[s,c]=(0,m.useState)({count:String(o.count),minSeconds:String(o.minSeconds),maxSeconds:String(o.maxSeconds),...rA(o)}),l=[...n,...z5(t,`shorts`,`shorts`,t.revision.config.shorts?.prompt,n),...z5(t,`image`,`shortsImage`,t.revision.config.shorts?.imagePrompt,n)],u={enabled:o.enabled,...s,prompt:o.prompt??``,imagePrompt:o.imagePrompt??``,...o.titleOnScreen===void 0?{}:{titleOnScreen:o.titleOnScreen}},d=e.regenerate?.includes(F5)===!0,f=__e(t);return(0,h.jsxs)(`div`,{className:`space-y-4`,children:[(0,h.jsx)(QV,{value:u,prompts:l,narrated:e.config.sources.audio!==`off`,problem:r,music:(0,h.jsx)(y_e,{edit:e,disabled:!o.enabled,onChange:i,onPending:a}),preview:(0,h.jsx)(U6,{settings:YV(u,e.config.subtitles?.fontId??`default`)}),onChange:t=>{c({count:t.count,minSeconds:t.minSeconds,maxSeconds:t.maxSeconds,...t.musicVolume===void 0?{}:{musicVolume:t.musicVolume},...t.speed===void 0?{}:{speed:t.speed},...t.fullVideoLink===void 0?{}:{fullVideoLink:t.fullVideoLink}});let n=e;for(let[e,r,i,a]of[[`shorts`,`shorts`,u.prompt,t.prompt],[`shortsImage`,`image`,u.imagePrompt,t.imagePrompt]]){if(i===a)continue;let t=l.find(e=>e.kind===r&&e.name===a);n=t===void 0?S_e(n,e):N5(n,e,t.body)}let r=e=>{let t=Number(e);return e.trim()===``||!Number.isFinite(t)?0:t},a=nA(t);i({...n,config:{...n.config,shorts:{enabled:t.enabled,count:r(t.count),minSeconds:r(t.minSeconds),maxSeconds:r(t.maxSeconds),...t.prompt===``?{}:{prompt:t.prompt},...t.imagePrompt===``?{}:{imagePrompt:t.imagePrompt},...a,...a.musicVolume!==void 0&&!Number.isFinite(a.musicVolume)?{musicVolume:-1}:{},...a.speed!==void 0&&!Number.isFinite(a.speed)?{speed:0}:{}}}})}}),f!==void 0&&o.enabled?(0,h.jsx)(b_e,{edit:e,view:t,pick:f,settings:o,again:d,problem:r,onChange:i}):null]})}function y_e({edit:e,disabled:t,onChange:n,onPending:r}){let i=(e.uploads??[]).some(e=>e.destination.kind===`shortsMusic`),a=e.content.shortsMusic!==void 0;return(0,h.jsxs)(`div`,{className:`basis-full space-y-2`,children:[i||a?(0,h.jsxs)(`p`,{className:`flex flex-wrap items-center gap-2 text-small text-ink-2`,children:[i?`New background music chosen. It is mixed under every short after you save and press Remake.`:`Background music plays quietly under every short and dips while the narrator speaks.`,(0,h.jsx)(L,{type:`button`,variant:`quiet`,disabled:t,onClick:()=>{let{shortsMusic:t,...r}=e.content;n({...e,content:r,uploads:(e.uploads??[]).filter(e=>e.destination.kind!==`shortsMusic`)})},children:`Remove the music`})]}):null,(0,h.jsx)(P5,{label:i||a?`Replace the background music`:`Background music (optional): an audio file, looped if shorter than a short`,kind:`audio`,disabled:t,onPending:r,onReady:t=>n({...e,uploads:[...(e.uploads??[]).filter(e=>e.destination.kind!==`shortsMusic`),{stagedFileId:t.id,destination:{kind:`shortsMusic`}}]})})]})}function b_e({edit:e,view:t,pick:n,settings:r,again:i,problem:a,onChange:o}){let s=(0,m.useId)(),c=t.revision.config.shorts,l=i||c===void 0||c.count!==r.count||c.minSeconds!==r.minSeconds||c.maxSeconds!==r.maxSeconds||(c.prompt??``)!==(r.prompt??``),u=Object.fromEntries(Object.entries(e.content.shortsRanges??{}).filter(([,e])=>e.pick===n.fingerprint)),d=n.picked.sentences??[],f=n.picked.durationSeconds??d.at(-1)?.end??0,p=n.picked.shorts.map(e=>{let t=u[String(e.number)],n=t===void 0?void 0:A5(d,t.first,t.last,f);return t===void 0||n===void 0?e:{...e,first:t.first,last:t.last,...n}}),g=(t,r,i)=>{let a=n.picked.shorts.find(e=>e.number===t.number),{[String(t.number)]:s,...c}=u,l=a!==void 0&&a.first===r&&a.last===i?c:{...c,[String(t.number)]:{first:r,last:i,pick:n.fingerprint}},{shortsRanges:d,...f}=e.content;o({...e,content:Object.keys(l).length===0?f:{...f,shortsRanges:l}})};return(0,h.jsxs)(`section`,{"aria-labelledby":`${s}-clips`,className:`space-y-3 border-t border-line pt-3`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,h.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,h.jsx)(`h4`,{id:`${s}-clips`,className:`sl-kicker m-0`,children:`Picked clips`}),(0,h.jsx)(B,{id:`project.shorts.clips`})]}),i?(0,h.jsxs)(`p`,{className:`flex flex-wrap items-center gap-2 text-small text-accent-ink`,children:[`The moments will be picked again after you save and press Remake; clips on the same sentences keep their images.`,(0,h.jsx)(L,{type:`button`,variant:`quiet`,onClick:()=>o({...e,regenerate:(e.regenerate??[]).filter(e=>e!==F5)}),children:`Keep the current moments`})]}):(0,h.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,h.jsx)(L,{type:`button`,onClick:()=>o(L5(e)),children:`Pick different moments`}),(0,h.jsx)(B,{id:`project.shorts.pick-again`})]})]}),l&&!i?(0,h.jsx)(`p`,{className:`text-small text-ink-2`,children:`These settings pick the moments again after you save and press Remake, so the clips below can be adjusted once the new ones are picked.`}):null,(0,h.jsx)(`ol`,{className:`space-y-3`,children:p.map(t=>(0,h.jsx)(x_e,{clip:t,picked:n.picked,adjusted:u[String(t.number)]!==void 0,locked:l,remade:e.regenerate?.includes(I5(t.number))===!0,problem:(()=>{let e=u[String(t.number)];return e===void 0?a(`content.shortsRanges.${String(t.number)}`):p_e(n.picked,t.number,e.first,e.last,r,p)})(),onRange:(e,n)=>g(t,e,n),onRemake:n=>o(n?R5(e,t.number):{...e,regenerate:(e.regenerate??[]).filter(e=>e!==I5(t.number))})},t.number))})]})}function x_e({clip:e,picked:t,adjusted:n,locked:r,remade:i,problem:a,onRange:o,onRemake:s}){let c=(0,m.useId)(),l=t.sentences??[],[u,d]=(0,m.useState)(!1),f=String(e.number),p=e=>l[e-1]?.text??``,g=(e,t,n,i)=>(0,h.jsx)(L,{type:`button`,variant:`quiet`,"aria-label":`${e} of short ${f}`,disabled:r||!i,onClick:()=>o(t,n),children:e.split(` `)[0]}),_=Math.round(e.end-e.start);return(0,h.jsxs)(`li`,{"aria-labelledby":`${c}-title`,className:`space-y-2 border-t border-line pt-3 first:border-t-0 first:pt-0`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-baseline justify-between gap-2`,children:[(0,h.jsxs)(`h5`,{id:`${c}-title`,className:`min-w-0 text-small font-semibold text-ink`,children:[`Short `,f,` · `,e.title]}),(0,h.jsxs)(`span`,{className:`text-label text-ink-3`,children:[`Sentences `,String(e.first),`-`,String(e.last),` · `,String(_),` s`,n?` · set by hand`:``]})]}),l.length===0?(0,h.jsx)(`p`,{className:`text-small text-ink-2`,children:`These shorts were picked before clips could be moved by hand. Use Pick different moments to adjust them.`}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`p`,{className:`flex flex-wrap items-center gap-x-2 text-small text-ink-2`,children:[(0,h.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[`Starts: “`,p(e.first),`”`]}),g(`Earlier start`,e.first-1,e.last,e.first>1),g(`Later start`,e.first+1,e.last,e.first<e.last)]}),(0,h.jsxs)(`p`,{className:`flex flex-wrap items-center gap-x-2 text-small text-ink-2`,children:[(0,h.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[`Ends: “`,p(e.last),`”`]}),g(`Earlier end`,e.first,e.last-1,e.last>e.first),g(`Later end`,e.first,e.last+1,e.last<l.length)]}),u?(0,h.jsx)(`div`,{className:`grid gap-3 md:grid-cols-2`,children:[`first`,`last`].map(t=>(0,h.jsx)(Y,{id:`${c}-${t}`,label:t===`first`?`Start sentence`:`End sentence`,tip:`project.shorts.range`,children:(0,h.jsx)(AV,{value:String(e[t]),disabled:r,onChange:n=>{let r=Number(n.target.value);o(t===`first`?r:e.first,t===`last`?r:e.last)},children:l.map((e,t)=>(0,h.jsxs)(`option`,{value:String(t+1),children:[String(t+1),`.`,` `,e.text.length>70?`${e.text.slice(0,69)}…`:e.text]},String(t+1)))})},t))}):null]}),a===void 0?null:(0,h.jsx)(`p`,{role:`alert`,className:`text-small text-danger`,children:a}),(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[l.length===0?null:(0,h.jsx)(L,{type:`button`,variant:`quiet`,disabled:r,onClick:()=>d(!u),children:u?`Hide the sentence lists`:`Use my own range`}),n?(0,h.jsx)(L,{type:`button`,variant:`quiet`,disabled:r,onClick:()=>{let n=t.shorts.find(t=>t.number===e.number);n!==void 0&&o(n.first,n.last)},children:`Back to the AI's choice`}):null,i?(0,h.jsxs)(`p`,{className:`flex flex-wrap items-center gap-2 text-small text-accent-ink`,children:[`Short `,f,` will be made again, with new images, after you save and press Remake.`,(0,h.jsx)(L,{type:`button`,variant:`quiet`,onClick:()=>s(!1),children:`Keep this short`})]}):(0,h.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,h.jsx)(L,{type:`button`,disabled:r,onClick:()=>s(!0),children:`Make this short again`}),(0,h.jsx)(B,{id:`project.shorts.remake`})]})]})]})}function z5(e,t,n,r,i){let a=e.revision.content.promptTemplates[n]??e.revision.config.rendered[n];return!r||a==null||i.some(e=>e.kind===t&&e.name===r)?[]:[{id:`saved-${n}`,kind:t,name:r,body:a,slots:[],updatedAt:e.revision.createdAt}]}function S_e(e,t){let{[t]:n,...r}=e.content.promptTemplates,{[t]:i,...a}=e.config.rendered;return M5({...e,config:{...e.config,rendered:a},content:{...e.content,promptTemplates:r}})}var C_e=K({shorts:G(K({number:W(),first:W().optional(),last:W().optional(),start:W(),end:W(),title:U(),description:U(),hashtags:G(U())}))});function w_e({stage:e,project:t,outputs:n}){let r=(0,m.useId)(),i=S8(n,e),a=C8(i,`shorts`),o=H5(i),s=W8(t.id),[c,l]=(0,m.useState)(),u=B5(i,`short_video`,o),d=t.config.shorts,f=(0,m.use)(r5),p=(0,m.use)(i5);if(d?.enabled!==!0&&a===void 0&&u.length===0)return null;let g=f&&p!==void 0&&d?.enabled===!0,_=e=>{let t=Qk(e,d?.fullVideoLink),n={text:`Couldn't copy short ${String(e.number)}. Select its text and copy it.`,tone:`error`};if(!navigator.clipboard){l(n);return}navigator.clipboard.writeText(t).then(()=>l({text:`Copied short ${String(e.number)}.`,tone:`success`}),()=>l(n))};return(0,h.jsxs)(`section`,{"aria-labelledby":`${r}-title`,className:`flex min-w-0 flex-col gap-4`,children:[(0,h.jsx)(`h3`,{id:`${r}-title`,className:`sl-kicker m-0`,children:o.length===0?`Shorts`:`${String(o.length)} short${o.length===1?``:`s`} · 9:16`}),(0,h.jsx)(z8,{files:o.map(e=>({output:u.find(t=>V5(t,e)),label:`Short ${String(e.number)}: ${e.title} (.mp4)`})),label:u.length===1?`Download the short`:`Download`,children:g&&o.length>0?(0,h.jsxs)(`span`,{className:`inline-flex items-center gap-1`,...Tb,children:[(0,h.jsx)(L,{onClick:()=>p({section:`shorts`,change:L5}),children:`Pick different moments`}),(0,h.jsx)(B,{id:`project.shorts.pick-again`})]}):null}),o.length===0?(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:e.state===`running`?`The clips are picked after the subtitle timing.`:`Not made yet. They are made with the video.`}):(0,h.jsx)(o2,{shorts:!0,list:!0,label:`Shorts`,className:`gap-y-7`,children:o.map(n=>(0,h.jsx)(T_e,{clip:n,projectId:t.id,review:G8(s,{itemKey:`shorts:${String(n.number)}`}),video:u.find(e=>V5(e,n)),stills:B5(i,`short_image`,o).filter(e=>V5(e,n)).toSorted((e,t)=>(e.meta.index??0)-(t.meta.index??0)),link:d?.fullVideoLink,wanted:tA(n.end-n.start,t.config.imageSeconds),state:e.state,failed:O_e(e.failureReason,n.number),ownDownload:u.length>1,onCopy:()=>_(n),...g?{onRemake:()=>p({section:`shorts`,change:e=>R5(e,n.number)})}:{}},n.number))}),(0,h.jsx)(v0,{tone:c?.tone??`info`,children:c?.text})]})}function T_e({clip:e,projectId:t,review:n,video:r,stills:i,wanted:a,state:o,failed:s,link:c,ownDownload:l,onCopy:u,onRemake:d}){let f=(0,m.useId)(),p=A8(r),g=A8(i[0]),_=i.length,v=s?`Couldn't make this short. Open Error details in the Video section to see why.`:o===`running`?_<a?`Making images · ${String(_)} of ${String(a)}`:`Rendering`:`Not made yet. It is made with the video.`;return(0,h.jsxs)(`li`,{"aria-labelledby":`${f}-title`,className:`flex min-w-0 flex-col gap-2`,children:[r!==void 0&&p!==void 0?(0,h.jsx)(i2,{src:p.url,label:`Short ${String(e.number)}`,portrait:!0,...g===void 0?{}:{poster:g.url}},r.id):s||o!==`running`?(0,h.jsx)(`div`,{className:`sl-media__frame sl-media__frame--portrait`,children:(0,h.jsx)(`p`,{className:`m-0 flex size-full items-center justify-center p-3 text-center text-small ${s?`text-danger`:`text-ink-3`}`,children:v})}):(0,h.jsx)(a2,{alt:`Short ${String(e.number)}`,aspect:`portrait`,generating:v}),(0,h.jsx)(`h4`,{id:`${f}-title`,className:`m-0 min-w-0 break-words text-small font-semibold text-ink`,children:e.title}),(0,h.jsx)(`p`,{className:`m-0 text-label text-ink-2 tabular-nums`,children:sF(r?.durationMs??Math.round((e.end-e.start)*1e3))}),(0,h.jsx)(`p`,{className:`m-0 break-words text-small text-ink-2`,children:e.description}),(0,h.jsx)(E_e,{link:c}),(0,h.jsx)(`p`,{className:`m-0 break-words text-small text-ink-2`,children:e.hashtags.join(` `)}),(0,h.jsx)(Y8,{review:n,projectId:t,busy:o===`running`}),(0,h.jsxs)(Ty,{className:`mt-1 flex-nowrap gap-1`,children:[l&&r!==void 0&&p!==void 0?(0,h.jsx)(fS,{href:p.url,download:!0,size:`small`,label:`Download short ${String(e.number)}`,tip:`Download`,children:(0,h.jsx)(pc,{"aria-hidden":`true`,strokeWidth:1.75})}):null,(0,h.jsx)(Cy,{size:`small`,tip:`Copy title, description and hashtags`,label:`Copy short ${String(e.number)}'s title, description and hashtags`,onClick:u,children:(0,h.jsx)(fc,{"aria-hidden":`true`,strokeWidth:1.75})}),d===void 0?null:(0,h.jsxs)(w8,{children:[(0,h.jsx)(T8,{asChild:!0,children:(0,h.jsx)(Cy,{size:`small`,tip:`More`,label:`More for short ${String(e.number)}`,children:(0,h.jsx)(mc,{"aria-hidden":`true`,strokeWidth:1.75})})}),(0,h.jsx)(E8,{align:`start`,children:(0,h.jsxs)(D8,{onSelect:d,children:[(0,h.jsx)(jc,{"aria-hidden":`true`,strokeWidth:1.75,className:`size-4`}),`Make short `,String(e.number),` again`]})})]})]})]})}function E_e({link:e}){let t=e?.trim()??``;return(0,h.jsxs)(`p`,{className:`m-0 flex flex-wrap items-center gap-x-2 gap-y-1 break-words text-small text-ink-2`,children:[(0,h.jsx)(`span`,{children:`Watch the full video:`}),t===``?(0,h.jsxs)(hS,{tone:`waiting`,title:`No link to the full video is saved. Copy leaves a placeholder to paste it over; to fill it in for every short, add the link under Edit settings → Shorts.`,children:[(0,h.jsx)(xc,{"aria-hidden":`true`,strokeWidth:1.75,className:`size-3`}),`Link needed`]}):(0,h.jsx)(`span`,{className:`min-w-0 break-all text-ink`,children:t})]})}function B5(e,t,n){let r=e.find(e=>e.role===`shorts`);return e.filter(e=>e.role===t&&(r===void 0||e.createdAt>=r.createdAt||n.some(t=>V5(e,t)&&e.meta.sentences?.[0]===t.first&&e.meta.sentences?.[1]===t.last)))}function V5(e,t){return e.meta.short===t.number}function H5(e){return D_e(V8(C8(e,`shorts`)).data)}function D_e(e){if(e===void 0)return[];try{let t=C_e.safeParse(JSON.parse(e));return t.success?t.data.shorts:[]}catch{return[]}}function O_e(e,t){return e?.startsWith(`Short ${String(t)}:`)===!0||e?.startsWith(`Short ${String(t)} `)===!0}function k_e({stage:e,project:t,outputs:n,subtitleControls:r}){let{api:i}=R(),a=Dy(),o=t.config.sources.video===`off`&&t.config.sources.audio!==`off`,s=C8(S8(n,e),o?`audio_export`:`video`),c=S8(n,e),l=C8(c,`subtitles_srt`),u=C8(c,`subtitles_vtt`),d=C8(c,`youtube_description`),f=C8(c,`youtube_tags`),p=C8(c,`audio_mp3`),m=C8(c,`audio_m4b`),g=B5(c,`short_video`,H5(c)).toSorted((e,t)=>(e.meta.short??0)-(t.meta.short??0)),_=A8(s),v=A8(A_e(n)),y=j_e(t.id,d,f,s?.durationMs??null),b=A8(u),x=s?.meta.subtitlesMode??t.config.subtitles?.mode,S=e.state===`running`,C=cF(e.progressCurrent??0,e.progressTotal??0);return _x({id:`project.folder`,title:`Open the project folder`,group:`This project`,context:t.title,keywords:[`folder`,`files`,`finder`,`explorer`,`video`],run:async()=>{if(s===void 0){a(`The video has not been saved yet, so there is no folder to open.`,`info`);return}try{let e=await D2(i,{projectId:t.id,asset:U3(s),folder:_?.folder??null});e.opened||a(`${O2} ${e.path}`,`info`)}catch(e){a(e instanceof Error?e.message:`The folder couldn't be opened. Use Open folder under the video.`,`error`)}}}),t.config.sources.video===`off`&&!o?(0,h.jsx)(P8,{children:r}):(0,h.jsxs)(P8,{className:`p-0`,children:[S?(0,h.jsx)(`p`,{className:`m-0 text-small text-accent-ink`,children:QP(e,t.config)?`Preparing subtitles · ${String(cF(e.progressCurrent??0,35))}%`:o?`Exporting combined audio`:e.progressTotal===null?`Rendering`:`Rendering · ${String(C)}%`}):null,s===void 0?(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:o?`No combined audio export has landed yet.`:`No render has landed yet.`}):o?(0,h.jsx)(Q8,{label:`Combined narration`,src:_?.url,marks:y},s.id):_===void 0?null:(0,h.jsx)(i2,{src:_.url,label:`Generated video`,...v===void 0?{}:{poster:v.url},chapters:y,portrait:t.format===`9:16`,className:t.format===`9:16`?`max-w-[360px]`:`max-w-[1100px]`,...x===`files`&&u&&b?{captions:{src:b.url,lang:`en`,label:`English`}}:{}},s.id),(0,h.jsx)(z8,{files:[{output:s,label:o?`Audio (.wav)`:`Video (.mp4)`},{output:l,label:`Subtitles (.srt)`},{output:u,label:`Subtitles (.vtt)`},{output:d,label:`YouTube description (.txt)`},{output:f,label:`YouTube tags (.txt)`},{output:p,label:`Audio with chapters (.mp3)`},{output:m,label:`Audiobook with chapters (.m4b)`},...g.map(e=>({output:e,label:`Short ${String(e.meta.short??``)} (.mp4)`}))]}),s===void 0?null:(0,h.jsx)(B8,{children:[sF(s?.durationMs??void 0),o?`WAV · stereo · 48 kHz`:t.format,s?.meta.master===void 0?void 0:wk(s.meta.master)].filter(e=>e!==void 0).join(` · `)}),s?.meta.warnings?.length?(0,h.jsx)(`ul`,{"aria-label":`Render notes`,className:`m-0 flex flex-col gap-1 pl-5 text-small text-ink-2`,children:s.meta.warnings.map(e=>(0,h.jsx)(`li`,{children:e},e))}):null,t.config.sources.audio===`off`||XO(t.config.language)===void 0?null:(0,h.jsx)(`p`,{role:`note`,className:`border-t border-line pt-3 text-small text-ink-2`,children:XO(t.config.language)}),s?.meta.subtitleOmissions?.length?(0,h.jsxs)(`details`,{className:`border-t border-line pt-3 text-small`,children:[(0,h.jsxs)(`summary`,{className:`cursor-pointer font-semibold`,children:[`Subtitles recovered after missing narration (`,s.meta.subtitleOmissions.length,`)`]}),(0,h.jsx)(`p`,{className:`m-0 mt-2 text-ink-2`,children:`These transcript passages could not be matched to the audio and were left out of the captions. The audio is unchanged. Review these passages before sharing.`}),(0,h.jsx)(`ul`,{className:`m-0 mt-2 flex flex-col gap-2 pl-5`,children:s.meta.subtitleOmissions.map(e=>(0,h.jsxs)(`li`,{children:[(0,h.jsx)(`strong`,{children:new Date(e.start*1e3).toISOString().slice(11,19)}),` —`,` `,e.text]},`${e.start}-${e.text}`))})]}):null,r?(0,h.jsxs)(`details`,{className:`border-t border-line pt-3`,children:[(0,h.jsx)(`summary`,{className:`cursor-pointer text-small font-semibold`,children:`Subtitles & fonts`}),r]}):null]})}function A_e(e){return e.filter(e=>e.role===`thumbnail`).toSorted((e,t)=>(e.meta.index??1)-(t.meta.index??1))[0]}function j_e(e,t,n,r){let{api:i}=R(),a=V8(t).data,o=V8(n).data,s=M({queryKey:z.youtubeEdits(e),queryFn:()=>Ss(i,e),enabled:t!==void 0});return a===void 0?[]:M_e(k5(O5(D5(a,o??``),s.data?.fields??{})).chapters,r===null?void 0:r/1e3)}function M_e(e,t){return E5(e,t).text.split(`
300
- `).flatMap(e=>{let t=/^(\S+)\s+(.+)$/u.exec(e.trim()),n=t===null?void 0:T5(t[1]??``),r=t?.[2]?.trim()??``;return n===void 0||r===``?[]:[{start:n,title:r}]})}function N_e(e){switch(e.stage.kind){case`article`:return(0,h.jsx)(bge,{...e});case`audio`:return(0,h.jsx)(Tge,{...e});case`images`:return(0,h.jsx)(t_e,{...e});case`video`:return(0,h.jsx)(k_e,{...e});case`document`:return(0,h.jsx)(kge,{...e});case`research`:case`thumbnail`:return null}}K({summary:U(),chapters:G(K({start:uO([U(),W()]),title:U()})),hashtags:G(U()),tags:G(U())});function U5(e){return e.reduce((e,t)=>e+t.length+(/\s/.test(t)?2:0),0)+Math.max(0,e.length-1)}var W5={summary:`Summary`,chapters:`Chapters`,hashtags:`Hashtags`,tags:`Tags`},G5={Summary:`project.youtube.summary`,Chapters:`project.youtube.chapters`,Hashtags:`project.youtube.hashtags`,Tags:`project.youtube.tags`};function P_e({stage:e,project:t,outputs:n}){let r=(0,m.useId)(),{api:i}=R(),a=_(),o=S8(n,e),s=C8(o,`youtube_description`),c=C8(o,`youtube_tags`),l=V8(s).data,u=V8(c).data,d=M({queryKey:z.youtubeEdits(t.id),queryFn:()=>Ss(i,t.id)}),f=M({queryKey:z.projectChannelLinks(t.id),queryFn:()=>xs(i,t.id)}),[p,g]=(0,m.useState)(),v=Dy(),y=e=>a.setQueryData(z.youtubeEdits(t.id),e),b=N({mutationFn:e=>Cs(i,t.id,e.field,e.edit),onSuccess:(e,t)=>{y(e),g({text:t.done,tone:`success`})},onError:e=>g({text:`Couldn't save the change: ${e.message}`,tone:`error`})}),x=(0,m.useRef)({});if(_x({id:`project.copy-description`,title:`Copy description`,group:`This project`,context:t.title,keywords:[`youtube`,`description`,`chapters`,`clipboard`],shortcut:mP.copyDescription,run:()=>x.current.description===void 0?v(`The description has not been written yet.`,`info`):x.current.description()}),_x({id:`project.copy-tags`,title:`Copy tags`,group:`This project`,context:t.title,keywords:[`youtube`,`tags`,`clipboard`],run:()=>x.current.tags===void 0?v(`The tags have not been written yet.`,`info`):x.current.tags()}),t.config.youtubeDescription!==!0&&s===void 0)return null;let S=l===void 0?void 0:D5(l,u??``),C=O5(S,d.data?.fields??{}),w=k5(C),T=zj(f.data?.links??[],d.data?.links??[]),E=C8(o,`video`),D=E5(w.chapters,E?.durationMs===null||E?.durationMs===void 0?void 0:E.durationMs/1e3),O=i_e(D.adjustments),k=Vj(o_e({...w,chapters:D.text}),T),ee=Vj(w.tags,T),te=[...k.unknown,...ee.unknown].filter((e,t,n)=>n.findIndex(t=>Rj(t)===Rj(e))===t),ne=J5(ee.text),re=S!==void 0,A=(e,t)=>{let n=`Couldn't copy the ${t}. Select the text in the YouTube section and copy it.`;if(!navigator.clipboard){g({text:n,tone:`error`}),v(n,`error`);return}navigator.clipboard.writeText(e).then(()=>{g({text:`Copied the ${t}.`,tone:`success`}),v(`Copied the ${t}.`,`success`)},()=>{g({text:n,tone:`error`}),v(n,`error`)})};x.current=re?{description:()=>A(k.text,`description`),tags:()=>A(ee.text,`tags`)}:{};let ie=e.state===`running`?`Written after the subtitle timing.`:`Not written yet. It is made with the video.`,j=(e,t)=>(0,h.jsx)(F_e,{label:W5[e],value:C[e],links:T,disabled:!re||b.isPending,multiline:e!==`hashtags`,placeholder:ie,render:t,onSave:t=>b.mutate({field:e,edit:{text:t,base:S?.[e]??``},done:`Saved your ${W5[e].toLowerCase()}.`}),onUseGenerated:()=>b.mutate({field:e,edit:null,done:`The ${W5[e].toLowerCase()} follows the generated text again.`}),onKeepMine:(t,n)=>b.mutate({field:e,edit:{text:t,base:n},done:`Kept your ${W5[e].toLowerCase()}.`})},e);return(0,h.jsxs)(`section`,{"aria-labelledby":`${r}-title`,className:`@container flex min-w-0 flex-col gap-4`,children:[(0,h.jsx)(`h3`,{id:`${r}-title`,className:`sr-only`,children:`YouTube`}),(0,h.jsxs)(`div`,{className:`grid min-w-0 grid-cols-[minmax(0,1fr)] gap-x-8 gap-y-6 @4xl:grid-cols-[minmax(0,75ch)_minmax(0,1fr)]`,children:[(0,h.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3`,children:[(0,h.jsx)(K5,{id:`${r}-description`,label:`Description`,copy:re?()=>A(k.text,`description`):void 0,keyshortcuts:kx(mP.copyDescription),count:re?`${String(k.text.length)} / ${String(L6)} characters`:void 0,over:k.text.length>L6,main:!0}),j(`summary`),j(`chapters`,()=>D.text===``?(0,h.jsx)(`span`,{className:`text-ink-3`,children:`Left out; see the note below.`}):(0,h.jsx)(q5,{text:D.text,links:T})),O===void 0?null:(0,h.jsx)(`p`,{className:`text-small text-waiting`,children:O}),j(`hashtags`)]}),(0,h.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3`,children:[(0,h.jsx)(K5,{id:`${r}-tags`,label:`Tags`,copy:re?()=>A(ee.text,`tags`):void 0,count:re?`${String(U5(ne))} / 500 characters`:void 0,over:U5(ne)>500}),j(`tags`,e=>(0,h.jsx)(I_e,{text:e,links:T}))]})]}),te.length===0?null:(0,h.jsxs)(`p`,{className:`text-small text-waiting`,children:[`No link is saved for ${te.map(e=>`{{${e}}}`).join(`, `)}, so it stays as typed. Add it under Channel links on `,f.data===void 0?`the channel's Brand tab`:(0,h.jsx)(pa,{to:`/channels/$channelId`,params:{channelId:f.data.channelId},className:`underline`,children:`the channel's Brand tab`}),`${te.some(e=>Rj(e)===Rj(`Previous video`))?`, or set this project's Previous video below`:``}.`]}),(0,h.jsx)(L_e,{projectId:t.id,edits:d.data,onSaved:e=>{y(e),g({text:`Saved this project's Previous video link.`,tone:`success`})},onError:e=>g({text:e,tone:`error`})}),(0,h.jsx)(v0,{tone:p?.tone??`info`,children:p?.text})]})}function K5({id:e,label:t,copy:n,count:r,over:i,keyshortcuts:a,main:o=!1}){return(0,h.jsxs)(`div`,{className:`flex min-h-8 flex-wrap items-center gap-3 border-b border-line pb-2`,children:[(0,h.jsx)(`h4`,{id:e,className:`m-0 text-title-3 font-semibold text-ink`,children:t}),r===void 0?null:(0,h.jsx)(`span`,{className:I(`text-small tabular-nums`,i?`text-danger`:`text-ink-3`),children:i?`${r}, over YouTube's limit`:r}),(0,h.jsx)(`span`,{className:`flex-1`}),(0,h.jsxs)(L,{type:`button`,variant:o?`primary`:`secondary`,disabled:n===void 0,"aria-label":`Copy ${t.toLowerCase()}`,"aria-keyshortcuts":a,onClick:n,children:[(0,h.jsx)(fc,{"aria-hidden":`true`,strokeWidth:1.75}),`Copy`]})]})}function F_e({label:e,value:t,links:n,disabled:r,multiline:i,placeholder:a,render:o,onSave:s,onUseGenerated:c,onKeepMine:l}){let u=(0,m.useId)(),[d,f]=(0,m.useState)(),[p,g]=(0,m.useState)(!1),_=d!==void 0,v=e.toLowerCase(),y=e in G5?G5[e]:void 0;return(0,h.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,...Tb,children:[(0,h.jsxs)(`div`,{className:`flex min-h-8 flex-wrap items-center gap-2`,children:[(0,h.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,h.jsx)(`h5`,{id:`${u}-label`,className:`sl-kicker text-ink-3`,children:e}),y===void 0?null:(0,h.jsx)(B,{id:y,label:v,className:`-my-1`})]}),t.edited?(0,h.jsx)(`span`,{className:`text-small text-ink-2`,children:`Your edit`}):null,(0,h.jsx)(`span`,{className:`flex-1`}),t.edited&&!_?(0,h.jsx)(L,{type:`button`,variant:`quiet`,size:`small`,disabled:r,"aria-label":`Use the generated ${v}`,onClick:c,children:`Use generated`}):null,(0,h.jsxs)(L,{type:`button`,variant:`quiet`,size:`small`,disabled:r||_,"aria-label":`Edit ${v}`,onClick:()=>f(t.text),children:[(0,h.jsx)(Ec,{"aria-hidden":`true`,strokeWidth:1.75}),`Edit`]})]}),t.pending===void 0?null:(0,h.jsxs)(`div`,{className:`flex flex-col gap-2 border-l-2 border-waiting pl-3`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,h.jsx)(`p`,{className:`text-small text-ink`,children:`New generated version available.`}),(0,h.jsx)(L,{type:`button`,disabled:r,"aria-label":`Use the new generated ${v}`,onClick:c,children:`Use it`}),(0,h.jsx)(L,{type:`button`,disabled:r,"aria-label":`Keep my ${v}`,onClick:()=>l(t.text,t.pending??``),children:`Keep mine`}),(0,h.jsx)(L,{type:`button`,variant:`quiet`,"aria-expanded":p,"aria-label":`${p?`Hide`:`View`} the ${v} diff`,onClick:()=>g(e=>!e),children:p?`Hide diff`:`View diff`})]}),p?(0,h.jsx)(V4,{before:t.text,after:t.pending,beforeLabel:`Yours`,afterLabel:`New generated`}):null]}),_?(0,h.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,h.jsx)(`label`,{htmlFor:`${u}-edit`,className:`sr-only`,children:e}),i?(0,h.jsx)(kV,{id:`${u}-edit`,rows:e===`Chapters`?8:5,value:d,onChange:e=>f(e.currentTarget.value)}):(0,h.jsx)(OV,{id:`${u}-edit`,value:d,onChange:e=>f(e.currentTarget.value)}),(0,h.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,h.jsxs)(L,{type:`button`,variant:`primary`,disabled:r,onClick:()=>{s(d),f(void 0)},children:[`Save `,v]}),(0,h.jsx)(L,{type:`button`,variant:`secondary`,onClick:()=>f(void 0),children:`Cancel`})]})]}):(0,h.jsx)(`section`,{"aria-labelledby":`${u}-label`,className:I(`min-w-0 whitespace-pre-wrap break-words text-small`,t.text===``?`text-ink-3`:`text-ink`),children:t.text===``?a:o===void 0?(0,h.jsx)(q5,{text:t.text,links:n}):o(t.text)})]})}function q5({text:e,links:t}){let n=0;return(0,h.jsx)(h.Fragment,{children:Bj(e,t).map(e=>{let t=String(n);return n+=e.kind===`text`?e.text.length:e.raw.length,e.kind===`text`?(0,h.jsx)(`span`,{children:e.text},t):e.url===void 0?(0,h.jsx)(`mark`,{title:`No link named ${e.name}`,className:`rounded-[2px] bg-waiting/25 px-0.5 text-ink`,children:e.raw},t):(0,h.jsx)(`span`,{title:e.raw,className:`underline decoration-dotted underline-offset-[3px]`,children:e.url},t)})})}function J5(e){return e.split(`,`).map(e=>e.trim()).filter(e=>e!==``)}function I_e({text:e,links:t}){return(0,h.jsx)(`ul`,{className:`flex flex-wrap gap-2 whitespace-normal`,children:J5(e).map((e,n)=>(0,h.jsx)(`li`,{className:`rounded-full border border-line bg-raised px-2 py-0.5 text-small text-ink`,children:(0,h.jsx)(q5,{text:e,links:t})},n))})}function L_e({projectId:e,edits:t,onSaved:n,onError:r}){let{api:i}=R(),a=(0,m.useId)(),o=t?.links.find(e=>Rj(e.name)===Rj(`Previous video`))?.url??``,[s,c]=(0,m.useState)(),l=s??o,u=N({mutationFn:()=>{let n=(t?.links??[]).filter(e=>Rj(e.name)!==Rj(Fj));return ws(i,e,l.trim()===``?n:[...n,{name:Fj,url:l.trim()}])},onSuccess:e=>{c(void 0),n(e)},onError:e=>r(e.message)});return(0,h.jsxs)(`div`,{className:`flex flex-wrap items-end gap-2`,children:[(0,h.jsxs)(`div`,{className:`flex min-w-[260px] flex-1 flex-col gap-1 sm:max-w-[520px]`,...Tb,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,h.jsx)(`label`,{className:`sl-field__label`,htmlFor:a,children:`Previous video for this project`}),(0,h.jsx)(B,{id:`project.youtube.previous-video`,className:`-my-1`})]}),(0,h.jsx)(OV,{id:a,type:`url`,placeholder:`https://youtu.be/…`,value:l,onChange:e=>c(e.currentTarget.value)})]}),(0,h.jsx)(L,{type:`button`,disabled:u.isPending||t===void 0||l.trim()===o,onClick:()=>u.mutate(),children:`Save links`})]})}var Y5=[{stage:`audio`,name:`Audio`},{stage:`images`,name:`Images`},{stage:`video`,name:`Video / export`}];function R_e({projectId:e,revisionId:t,gates:n,stages:r,reload:i,saved:a}){let{api:o}=R(),[s,c]=(0,m.useState)(null),[l,u]=(0,m.useState)(!1),[d,f]=(0,m.useState)(null),p=(0,m.useRef)(!1),g=(0,m.useRef)(!0),_=(0,m.useRef)(null),v=(0,m.useRef)(null),y=JSON.stringify([t,n.map(e=>[e.stage,e.checkpointId]).toSorted()]),b=s!==null&&s.baseIdentity!==y,x=s?.stages??n.map(e=>e.stage),S=Y5.some(({stage:e})=>x.includes(e)!==n.some(t=>t.stage===e)),C=b||d!==null&&d.kind!==`success`,w=b?{kind:`refused`,message:`Checkpoint choices changed elsewhere. Press Reload checkpoint choices before saving, then make your change again.`}:d;(0,m.useEffect)(()=>(g.current=!0,()=>{g.current=!1}),[]),(0,m.useEffect)(()=>{(d||b)&&_.current?.focus()},[d,b]);async function T(){if(!(p.current||!S||C)){p.current=!0,u(!0);try{let n=await dpe(o,e,{revisionId:t,stages:x});if(!g.current)return;n.ok?n.value.revisionId===t?(a(n.value),c(null),f({kind:`success`,message:`Checkpoint choices saved.`})):f({kind:`refused`,message:`The project was edited elsewhere. Press Reload checkpoint choices to see its current choices.`}):f({kind:`refused`,message:n.message})}catch(e){g.current&&f({kind:`transport`,message:`${_o(e instanceof Error?e.message:`Slopify didn't confirm the change`)} It may or may not have saved. Press Reload checkpoint choices before changing anything else.`})}finally{p.current=!1,g.current&&u(!1)}}}async function E(){if(!p.current){p.current=!0,u(!0);try{let e=await i();g.current&&e&&(c(null),f(null),v.current?.focus())}finally{p.current=!1,g.current&&u(!1)}}}return(0,h.jsxs)(`div`,{className:`space-y-2`,children:[(0,h.jsxs)(`fieldset`,{ref:v,tabIndex:-1,className:`space-y-2`,...Tb,children:[(0,h.jsx)(`legend`,{className:`float-left mr-1`,children:`Checkpoint choices`}),(0,h.jsx)(B,{id:`project.checkpoints.choices`,className:`-my-1`}),(0,h.jsx)(`div`,{className:`clear-both`}),Y5.map(({stage:e,name:t})=>{let n=r.find(t=>t.kind===e),i=n?.state===`pending`&&(e===`video`?n.source!==`off`||r.some(e=>e.kind===`audio`&&e.source!==`off`&&e.state!==`skipped`):(n.source??`generate`)===`generate`);return(0,h.jsxs)(`label`,{className:`flex min-h-10 items-center gap-3`,children:[(0,h.jsx)(`input`,{type:`checkbox`,checked:x.includes(e),disabled:!i||l||C,onChange:t=>{c({baseIdentity:s?.baseIdentity??y,stages:t.target.checked?[...x,e]:x.filter(t=>t!==e)}),f(null)}}),`Before `,t]},e)})]}),w?(0,h.jsx)(`p`,{ref:_,tabIndex:-1,role:w.kind===`success`?`status`:`alert`,children:w.message}):null,(0,h.jsx)(L,{type:`button`,disabled:!S||l||C,onClick:()=>void T(),children:l?`Saving…`:`Save checkpoints`}),C?(0,h.jsx)(L,{type:`button`,disabled:l,onClick:()=>void E(),children:`Reload checkpoint choices`}):null]})}var X5=e=>e.charAt(0).toUpperCase()+e.slice(1);function z_e(e){return e.revisionId===null?null:(0,h.jsx)(B_e,{...e,revisionId:e.revisionId},`${e.projectId}:${e.revisionId}`)}function B_e({projectId:e,revisionId:t,paused:n,stages:r,approvedInRail:i}){let{api:a}=R(),o=_(),s=M({queryKey:k3(e,t),queryFn:()=>j3(a,e),retry:!1}),c=s.data,l=async()=>{let e=await s.refetch();return!e.isError&&e.data?.ok===!0&&e.data.value.revisionId===t?e.data.value:void 0},u=async()=>{let e=await s.refetch();return!e.isError&&e.data?.ok===!0&&e.data.value.revisionId===t};return s.isPending?null:s.error||c?.ok===!1?(0,h.jsxs)(`section`,{"aria-label":`Review checkpoints`,className:`flex flex-col items-start gap-3`,children:[(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-small text-danger`,children:s.error?.message??(c?.ok===!1?c.message:`Checkpoints couldn't be loaded. Press Reload checkpoints.`)}),(0,h.jsx)(L,{onClick:()=>void u(),children:`Reload checkpoints`})]}):c?.ok?c.value.revisionId===t?(0,h.jsxs)(`section`,{"aria-label":`Review checkpoints`,className:`flex flex-col gap-5`,children:[(0,h.jsx)(V,{title:`Review checkpoints`,size:`small`,className:`pb-0`}),n?(0,h.jsx)(`p`,{className:`m-0 text-small text-waiting`,children:`The project is paused. Continue the run before approving held work.`}):null,(0,h.jsx)(R_e,{projectId:e,revisionId:t,gates:c.value.checkpoints,stages:r,reload:l,saved:n=>{o.setQueryData(k3(e,t),{ok:!0,value:n}),o.invalidateQueries({queryKey:z.project(e)}),o.invalidateQueries({queryKey:z.projects})}}),c.value.checkpoints.map(a=>(0,h.jsx)(V_e,{gate:a,disabled:n||a.projectId!==e||a.revisionId!==t||r.some(e=>e.kind===a.stage&&[`running`,`canceled`].includes(e.state)),reload:u,...a.checkpointId===i?{inRail:!0}:{}},`${a.checkpointId}:${a.fingerprint}`))]}):(0,h.jsx)(`section`,{"aria-label":`Review checkpoints`,className:`flex flex-col items-start gap-3`,children:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-small text-danger`,children:`The project was edited after these checkpoints loaded. Press Reload checkpoints before approving.`})}):null}function V_e({gate:e,disabled:t,reload:n,inRail:r=!1}){let{api:i}=R(),a=_(),o=(0,m.useRef)(null),s=(0,m.useRef)(!1),c=(0,m.useRef)(!0),l=(0,m.useRef)(null),[u,d]=(0,m.useState)(!1),[f,p]=(0,m.useState)(null);(0,m.useEffect)(()=>(c.current=!0,()=>{c.current=!1}),[]),(0,m.useEffect)(()=>{f!==null&&l.current?.focus()},[f]);let g=[`configured`,`pending-review`,`held`].includes(e.state)&&e.fingerprint===e.currentFingerprint;async function v(){if(!(s.current||t||!g||f?.kind===`refused`||f?.kind===`success`)){s.current=!0,d(!0),o.current??={revisionId:e.revisionId,fingerprint:e.fingerprint,idempotencyKey:crypto.randomUUID()};try{let t=await M3(i,e.projectId,e.checkpointId,o.current);o.current=null,c.current&&p(t.ok?{kind:`success`,message:t.value.replayed?`Checkpoint already approved.`:`Checkpoint approved. Work will run when its dependencies are ready.`}:{kind:`refused`,message:t.message}),a.invalidateQueries({queryKey:O3(e.projectId)}),a.invalidateQueries({queryKey:z.project(e.projectId)}),a.invalidateQueries({queryKey:z.projects})}catch(e){c.current&&p({kind:`transport`,message:`${_o(e instanceof Error?e.message:`Slopify didn't confirm the approval`)} Press Retry approval to check whether it went through.`})}finally{s.current=!1,c.current&&d(!1)}}}return(0,h.jsxs)(`div`,{className:`flex flex-col gap-2 border-t border-line pt-4`,children:[(0,h.jsx)(V,{as:`h3`,title:`${X5(e.stage)} checkpoint`,className:`pb-0`}),(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:e.state===`released`&&e.approvedAt!==null?`Authorized for this revision. Work can run when dependencies are ready and the project is resumed.`:e.state===`satisfied`?`Checkpoint satisfied. Its reviewed work is complete.`:e.state===`invalidated`||e.fingerprint!==e.currentFingerprint?`Inputs changed. Review the current revision before approving.`:g?`${X5(e.stage)} is held for your review. Its dependent work waits for this approval; independent work can continue.`:`Checkpoint ${e.state}.`}),(0,h.jsxs)(`p`,{className:`m-0 text-small text-ink-3`,children:[`Reviewed revision: `,e.revisionId]}),e.dependents.length?(0,h.jsx)(`ul`,{"aria-label":`Dependent work`,className:`m-0 flex list-none flex-wrap gap-2 p-0`,children:e.dependents.map(e=>(0,h.jsx)(`li`,{className:`sl-chip`,children:X5(e)},e))}):(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:`No dependent stages.`}),f?(0,h.jsx)(`p`,{ref:l,tabIndex:-1,role:f.kind===`success`?`status`:`alert`,className:f.kind===`success`?`m-0 text-small`:`m-0 text-small text-danger`,children:f.message}):null,g&&r&&f===null?(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:`Its approval is the project's next action, in the right rail.`}):g?(0,h.jsx)(L,{className:`self-start`,disabled:t||u||f?.kind===`refused`||f?.kind===`success`,onClick:()=>void v(),children:u?`Approving…`:f?.kind===`transport`?`Retry approval`:`Approve ${X5(e.stage)} checkpoint`}):null,f?.kind===`refused`?(0,h.jsx)(L,{className:`self-start`,onClick:async()=>{await n()&&p(null)},children:`Reload checkpoints`}):null]})}function H_e({projects:e,queryKey:t}){let{api:n}=R(),r=_(),i=Dy(),[a,o]=(0,m.useState)(),[s,c]=(0,m.useState)(),l=N({mutationFn:e=>Lo(n,e.id),onMutate:()=>c(void 0),onSuccess:(e,t)=>{i(e.files===0?`"${t.title}" had no working files left to remove.`:`Freed ${Q5(e.bytesFreed)} from "${t.title}" (${String(e.files)} working file${e.files===1?``:`s`}).`,`success`)},onError:e=>c(e.message),onSettled:()=>r.invalidateQueries({queryKey:t})}),u=e.toSorted((e,t)=>t.bytes-e.bytes);return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`p`,{className:`m-0 mb-2 flex items-center gap-1 text-small text-ink-2`,children:[`Keep outputs only frees a finished project's working files.`,(0,h.jsx)(B,{id:`settings.storage.keep-outputs`})]}),(0,h.jsx)(hU,{label:`Storage by project`,children:u.map(e=>(0,h.jsx)(gU,{title:e.title,meta:(0,h.jsxs)(`span`,{className:`tabular-nums`,children:[Q5(e.bytes),` · outputs `,Q5(e.outputsBytes),` · working files `,Q5(e.workingBytes)]}),actions:(0,h.jsx)(L,{variant:`quiet`,size:`small`,disabled:!e.finished||e.removableBytes===0||l.isPending,title:e.finished?e.removableBytes===0?`No working files left to remove.`:`Frees ${Q5(e.removableBytes)}.`:`Available once the project has finished.`,onClick:()=>o(e),children:l.isPending&&l.variables?.id===e.id?`Removing…`:`Keep outputs only`})},e.id))}),s===void 0?null:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 mt-2 text-small text-danger`,children:s}),(0,h.jsx)(Ay,{open:a!==void 0,title:`Keep only the outputs of "${a?.title??``}"?`,consequence:Z5(a?.removableFiles??0,a?.removableBytes??0),confirmLabel:`Keep outputs only`,pending:l.isPending,onConfirm:()=>{let e=a;o(void 0),e!==void 0&&l.mutate(e)},onCancel:()=>o(void 0)})]})}function Z5(e,t){return`This removes ${String(e)} working file(s) and frees ${Q5(t)}: the images, narration parts, subtitle timing and render settings the project was made from. The video, shorts, thumbnail, article, description and document stay, and so does anything you uploaded. If you change this project later (edit an image, a caption style or the narration, or re-render), Slopify has to make those files again first, which takes time and uses provider credits.`}function Q5(e){if(e<1024)return`${e} B`;let t=[`KB`,`MB`,`GB`,`TB`],n=e,r=t[0]??`KB`;for(let e of t)if(n/=1024,r=e,n<1024||e===t.at(-1))break;return`${n>=10?n.toFixed(0):n.toFixed(1).replace(/\.0$/,``)} ${r}`}var $5=e=>[`storage`,`project`,e];function U_e({projectId:e,title:t,status:n,sample:r}){let{api:i}=R(),a=_(),o=Dy(),[s,c]=(0,m.useState)(!1),l=n===`done`||n===`partial`,u=M({queryKey:[...$5(e),n],queryFn:()=>Io(i,e),enabled:l&&!r}),d=N({mutationFn:()=>Lo(i,e),onSuccess:e=>o(e.files===0?`"${t}" had no working files left to remove.`:`Freed ${Q5(e.bytesFreed)} from "${t}". The outputs are all still here.`,`success`),onError:e=>o(`The working files of "${t}" weren't removed: ${e.message}`,`error`),onSettled:async()=>{await Promise.all([a.invalidateQueries({queryKey:$5(e)}),a.invalidateQueries({queryKey:[`storage-usage`]}),a.invalidateQueries({queryKey:z.project(e)})])}}),f=u.data;if(!l||r||f===void 0||!f.finished||f.removableBytes===0)return null;let p=Q5(f.removableBytes);return(0,h.jsxs)(`section`,{"aria-label":`Free space`,className:`flex flex-col gap-2`,children:[(0,h.jsx)(V,{as:`h3`,title:`Free space`,meta:`Outputs ${Q5(f.outputsBytes)} · working files ${Q5(f.workingBytes)}`,info:`project.free-space`}),(0,h.jsx)(`div`,{children:(0,h.jsx)(L,{variant:`secondary`,size:`small`,className:`h-auto min-h-8 max-w-full whitespace-normal py-1 text-left`,disabled:d.isPending,disabledReason:`Removing the working files…`,onClick:()=>c(!0),children:d.isPending?`Removing…`:`Free ${p}: keep the outputs, drop the working files`})}),(0,h.jsx)(Ay,{open:s,title:`Free ${p} from "${t}"?`,consequence:Z5(f.removableFiles,f.removableBytes),confirmLabel:`Free ${p}`,cancelLabel:`Keep the working files`,pending:d.isPending,onConfirm:()=>{c(!1),d.mutate()},onCancel:()=>c(!1)})]})}function W_e({project:e,prompts:t,editing:n,onEdit:r,more:i,nextChapter:a}){let o=q_e(e.status);return(0,h.jsx)(Aq,{crumb:(0,h.jsxs)(pa,{to:`/projects`,className:`inline-flex items-center gap-1 text-ink-3 hover:text-ink`,children:[(0,h.jsx)(sc,{"aria-hidden":`true`,strokeWidth:1.75}),`Projects`]}),title:e.title,meta:J_e(e,t),actions:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(mS,{tone:o.tone,children:[o.word,(0,h.jsx)(`span`,{className:`sr-only`,role:`status`,"aria-live":`polite`,children:`Project: ${o.word}`})]}),a!==void 0&&G_e(e)?(0,h.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,h.jsx)(L,{variant:`secondary`,disabled:a.pending,onClick:a.run,children:a.pending?`Making the next chapter…`:`Make the next chapter`}),(0,h.jsx)(B,{id:`project.next-chapter`}),a.error===void 0?null:(0,h.jsx)(`span`,{role:`alert`,className:`max-w-[320px] text-small text-danger`,children:a.error})]}):null,(0,h.jsxs)(L,{variant:`secondary`,"aria-pressed":n,onClick:r,children:[(0,h.jsx)(Fc,{"aria-hidden":`true`,strokeWidth:1.75}),`Edit settings`]}),(0,h.jsxs)(w8,{modal:!1,children:[(0,h.jsx)(T8,{asChild:!0,children:(0,h.jsx)(Cy,{label:`More project actions`,children:(0,h.jsx)(mc,{"aria-hidden":`true`,strokeWidth:1.75})})}),(0,h.jsx)(E8,{children:i.map(e=>(0,h.jsx)(K_e,{item:e},e.id))})]})]})})}function G_e(e){return e.config.voices?.format===`audiobook`&&(e.status===`done`||e.status===`partial`)}function K_e({item:e}){return(0,h.jsxs)(h.Fragment,{children:[e.apart?(0,h.jsx)(Zhe,{}):null,(0,h.jsx)(D8,{...e.disabled?{disabled:!0}:{},onSelect:()=>e.run(),children:e.label})]})}function q_e(e){switch(e){case`running`:return{tone:`running`,word:`Running`};case`paused`:return{tone:`waiting`,word:`Paused`};case`failed`:return{tone:`failed`,word:`Failed`};case`partial`:return{tone:`waiting`,word:`Done with problems`};case`done`:return{tone:`done`,word:`Done`};case`canceled`:return{tone:`off`,word:`Canceled`};case`pending`:return{tone:`off`,word:`Queued`}}}function J_e(e,t){let n=e.config.articlePrompt,r=t===void 0||t.some(e=>e.name===n),i=n===void 0||n===``?void 0:r?n:`${n} (deleted)`,a=e.config.voices?.book;return[a===void 0?void 0:KA(a),i,e.format,`started ${Tu(e.createdAt)}`].filter(e=>e!==void 0).join(` · `)}var Y_e={pending:`text-ink-3`,running:`text-accent-ink`,done:`text-accent-ink`,failed:`text-danger`,partial:`text-waiting`,canceled:`text-waiting`,paused:`text-waiting`,provided:`text-ink-2`,skipped:`text-ink-3`},e7={partial:`done with problems`};function X_e({state:e,announce:t,className:n}){return(0,h.jsxs)(`span`,{className:I(`inline-flex items-center`,n),children:[(0,h.jsx)(`span`,{"data-state":e,className:I(`engraved font-bold`,Y_e[e]),children:e7[e]??e}),t===void 0?null:(0,h.jsx)(`span`,{className:`sr-only`,role:`status`,"aria-live":`polite`,children:`${t}: ${e7[e]??e}`})]})}var Z_e={pending:`bg-line shadow-[inset_0_0_0_1px_var(--color-line-strong)]`,running:`bg-accent shadow-[0_0_0_3px_var(--color-accent-tint)] animate-lamp-pulse motion-reduce:animate-none`,done:`bg-accent-ink`,failed:`bg-danger`,partial:`bg-waiting`,canceled:`bg-waiting`,paused:`bg-waiting`,provided:`bg-line shadow-[inset_0_0_0_1px_var(--color-line-strong)]`,skipped:`bg-line shadow-[inset_0_0_0_1px_var(--color-line-strong)]`};function Q_e({state:e,className:t}){return(0,h.jsx)(`span`,{"aria-hidden":`true`,"data-lamp":e,className:I(`size-[10px] shrink-0 rounded-full`,Z_e[e],t)})}function $_e({label:e,state:t,className:n}){return(0,h.jsxs)(`span`,{className:I(`inline-flex items-center gap-2`,n),children:[(0,h.jsx)(Q_e,{state:t}),(0,h.jsx)(X_e,{state:t,announce:e})]})}var t7={research:`Research`,article:`Article`,audio:`Narration`,images:`Images`,thumbnail:`Thumbnail`,video:`Video`,document:`Document`};function eve({project:e,revisionId:t,stages:n,outputs:r}){let i=r.filter(e=>e.role===`image`);return(0,h.jsxs)(`div`,{className:`grid min-w-0 gap-6 lg:grid-cols-[260px_minmax(0,1fr)]`,children:[(0,h.jsxs)(`div`,{className:`min-w-0`,children:[(0,h.jsx)(V,{title:`Steps`}),(0,h.jsx)(hU,{label:`Steps`,children:n.filter(e=>e.state!==`skipped`).map(e=>(0,h.jsx)(gU,{title:t7[e.kind],actions:(0,h.jsx)($_e,{label:t7[e.kind],state:e.state})},e.id))})]}),(0,h.jsxs)(`div`,{className:`min-w-0`,children:[(0,h.jsx)(V,{title:`Article`}),(0,h.jsx)(q3,{projectId:e.id,stage:`article`,className:`mb-6`}),(0,h.jsx)(V,{title:`Narration`}),(0,h.jsx)(rve,{projectId:e.id,revisionId:t}),(0,h.jsx)(V,{title:`Images`}),i.length===0?(0,h.jsx)(`p`,{className:`text-small text-ink-2`,children:`The images appear here as each one is drawn.`}):(0,h.jsx)(o2,{list:!0,density:`compact`,label:`Images so far`,children:i.map(t=>(0,h.jsx)(tve,{output:t,aspect:g5(e.format)},t.id))})]})]})}function tve({output:e,aspect:t}){let n=A8(e);if(n===void 0)return null;let r=e.meta.index===void 0?``:` ${String(e.meta.index)}`;return(0,h.jsx)(`li`,{className:`min-w-0`,children:(0,h.jsx)(a2,{src:n.url,alt:e.meta.prompt??`Image${r}`,aspect:t,...e.meta.index===void 0?{}:{meta:`#${String(e.meta.index)}`}})})}var nve=240;function rve({projectId:e,revisionId:t}){let{api:n}=R(),r=M({queryKey:Ny(e,t),queryFn:()=>Gy(n,e),enabled:t!==null}),i=(r.data?.pieces??[]).flatMap(e=>e.peaks),a=(r.data?.pieces??[]).reduce((e,t)=>e+t.seconds,0),o=Math.max(1,Math.ceil(i.length/nve)),s=[];for(let e=0;e<i.length;e+=o)s.push(Math.max(...i.slice(e,e+o)));return(0,h.jsxs)(`div`,{className:`mb-6`,children:[(0,h.jsx)(`div`,{role:`img`,"aria-label":s.length===0?`No narration yet`:`Narration so far: ${String(Math.round(a))} seconds`,className:`flex h-16 items-center gap-px overflow-hidden rounded-control border border-line bg-raised px-2`,children:s.map((e,t)=>(0,h.jsx)(`span`,{className:`w-[3px] shrink-0 rounded-full bg-accent`,style:{height:`${String(Math.max(4,Math.round(e*100)))}%`}},t))}),(0,h.jsx)(`p`,{className:`mt-1 text-label text-ink-3`,children:r.error?r.error.message:s.length===0?`The waveform grows as each part of the narration is spoken.`:`${String(Math.round(a))} s narrated${r.data!==void 0&&`complete`in r.data&&r.data.complete?``:` so far`}`})]})}function ive(e){let t=[],n=[],r=0,i=()=>{let e=n[0],r=n.at(-1);e!==void 0&&r!==void 0&&t.push({start:e.start,end:r.end,text:n7(n.map(e=>e.text)),...e.speaker===void 0?{}:{speaker:e.speaker}}),n=[]};for(let t of e){if(!Number.isFinite(t.start)||!Number.isFinite(t.end)||t.start<r-.001||t.end<=t.start)throw Error(`The saved caption timing is damaged. Use More → Render the video again in the Video section to time them again, then Try again.`);let e=n[0];e!==void 0&&(t.start-r>.7||t.speaker!==e.speaker||t.end-e.start>5||n7([...n.map(e=>e.text),t.text]).split(`
299
+ `)}function c_e(e,t){return t===void 0?{text:e??``,edited:!1}:e===void 0||t.base===e?{text:t.text,edited:!0}:t.text===e?{text:e,edited:!1}:{text:t.text,edited:!0,pending:e}}function O5(e,t){let n=n=>c_e(e?.[n],t[n]);return{summary:n(`summary`),chapters:n(`chapters`),hashtags:n(`hashtags`),tags:n(`tags`)}}function k5(e){return{summary:e.summary.text,chapters:e.chapters.text,hashtags:e.hashtags.text,tags:e.tags.text}}var l_e=K({number:W().int().positive(),first:W().int().positive(),last:W().int().positive(),start:W().finite().nonnegative(),end:W().finite().positive(),title:U(),description:U(),hashtags:G(U()),why:U(),text:U(),seed:U().nullable().optional()}),u_e=.25,d_e=.4;function A5(e,t,n,r){let i=e[t-1],a=e[n-1];if(i===void 0||a===void 0||t>n)return;let o=e[t-2]?.end??0,s=e[n]?.start??r,c=Math.max(0,i.start-Math.max(0,Math.min(u_e,(i.start-o)/2))),l=Math.min(r,a.end+Math.max(0,Math.min(d_e,(s-a.end)/2)));return{start:j5(c),end:j5(l)}}K({first:uO([W(),U()]),last:uO([W(),U()]),title:U(),description:U(),hashtags:G(U()),why:U().optional()});function j5(e){return Math.round(e*1e3)/1e3}var f_e=K({shorts:G(l_e),durationSeconds:W().finite().nonnegative().optional(),sentences:G(K({start:W().finite().nonnegative(),end:W().finite().nonnegative(),text:U()})).optional()});function p_e(e){if(e!=null)try{let t=f_e.safeParse(JSON.parse(e));return t.success?t.data:void 0}catch{return}}function m_e(e,t,n,r,i,a=[]){let o=e.sentences;if(o===void 0||o.length===0)return`These shorts were picked before clips could be adjusted by hand. Use Pick different moments, then adjust the new clips.`;if(!e.shorts.some(e=>e.number===t))return`There is no short ${String(t)} any more. Reload the page and choose again.`;if(!Number.isInteger(n)||!Number.isInteger(r)||n<1||r>o.length||n>r)return`Choose a start sentence that comes before the end sentence, between 1 and ${String(o.length)}.`;let s=A5(o,n,r,h_e(e));if(s===void 0)return`Choose a start and an end sentence from the transcript.`;let c=s.end-s.start;if(c<i.minSeconds-.01)return`Short ${String(t)} would last ${String(Math.round(c))} seconds, shorter than the ${String(i.minSeconds)}-second minimum. Start it earlier or end it later.`;if(c>i.maxSeconds+.01)return`Short ${String(t)} would last ${String(Math.round(c))} seconds, longer than the ${String(i.maxSeconds)}-second maximum. Start it later or end it earlier.`;let l=a.find(e=>e.number!==t&&n<=e.last&&r>=e.first);if(l!==void 0)return`Short ${String(t)} would share sentences with short ${String(l.number)} (sentences ${String(l.first)}-${String(l.last)}). Choose a range that doesn't overlap it.`}function h_e(e){return e.durationSeconds??e.sentences?.at(-1)?.end??0}function M5(e){let t=Object.fromEntries(Object.entries(e.content.imageDefinitions).map(([t,n])=>{let r=n.templateKey===null||n.templateKey===void 0?null:e.content.promptTemplates[n.templateKey]??null;return[t,r===null||n.source!==`generate`?n:{...n,prompt:hq(r,e.config.values)}]}));return{...e,content:{...e.content,imageDefinitions:t},config:{...e.config,rendered:{...e.config.rendered,...Object.fromEntries(Object.entries(e.content.promptTemplates).map(([t,n])=>[t,n===null?e.config.rendered[t]??``:hq(n,e.config.values)]))}}}}function g_e(e,t,n){let r={...e.config.sources,[t]:n,...t===`images`&&n===`off`?{video:`off`}:{}};return{...e,config:{...e.config,sources:r,subtitles:PN(e.config.subtitles,r)}}}function N5(e,t,n){return M5({...e,content:{...e.content,promptTemplates:{...e.content.promptTemplates,[t]:n}}})}function __e(e){return new Promise((t,n)=>{if(e.aborted){n(Error(`Upload canceled.`));return}let r=()=>{clearTimeout(i),n(Error(`Upload canceled.`))},i=setTimeout(()=>{e.removeEventListener(`abort`,r),t()},200);e.addEventListener(`abort`,r,{once:!0})})}function P5({label:e,kind:t,disabled:n=!1,onReady:r,onPending:i,accept:a}){let{api:o}=R(),s=(0,m.useId)(),[c,l]=(0,m.useState)(),[u,d]=(0,m.useState)(!1),f=(0,m.useRef)(void 0),p=(0,m.useRef)(r);p.current=r;let g=(0,m.useRef)(i);g.current=i;let _=(0,m.useRef)(!0);(0,m.useEffect)(()=>(_.current=!0,()=>{_.current=!1,f.current?.abort(),g.current(!1)}),[]);async function v(e){if(n||f.current!==void 0)return;let r=new AbortController;f.current=r,d(!0),g.current(!0),l(void 0);let i;try{let n=await Ro(o,t,e);for(i=n.id,r.signal.throwIfAborted();n.state!==`staged`;){await __e(r.signal);let e=(await jo(o)).files.find(e=>e.id===n.id);if(r.signal.throwIfAborted(),e===void 0)throw Error(`The upload stopped before the file finished copying. Choose the file again.`);n=e}p.current(n)}catch(e){let t=r.signal.aborted?`Upload canceled.`:e instanceof Error?e.message:String(e);if(i!==void 0)try{await zo(o,i)}catch(e){t+=` The partial upload couldn't be removed (${e instanceof Error?e.message:String(e)}); use Clean orphan files in Settings → Backup & storage to clear it.`}_.current?l(t):t.includes(`partial upload couldn't be removed`)&&console.error(t)}finally{f.current===r&&(f.current=void 0,_.current&&(d(!1),g.current(!1)))}}return(0,h.jsxs)(`div`,{className:`space-y-2`,children:[(0,h.jsx)(Y,{label:e,id:s,children:(0,h.jsx)(OV,{id:s,type:`file`,disabled:u||n,accept:a??(t===`audio`?`audio/*`:`image/png,image/jpeg,image/webp`),onChange:e=>{let t=e.target.files?.[0];e.target.value=``,t!==void 0&&v(t)}})}),u?(0,h.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,h.jsx)(`p`,{role:`status`,className:`text-small text-ink-2`,children:`Copying upload…`}),(0,h.jsx)(L,{type:`button`,onClick:()=>f.current?.abort(),children:`Cancel upload`})]}):null,c===void 0?null:(0,h.jsx)(`p`,{role:`alert`,className:`text-small text-danger`,children:c})]})}var F5=`shorts:pick`,I5=e=>`shorts:${String(e)}`;function L5(e){let{shortsRanges:t,...n}=e.content;return{...e,content:n,regenerate:[...new Set([...e.regenerate??[],F5])]}}function R5(e,t){return{...e,regenerate:[...new Set([...e.regenerate??[],I5(t)])]}}function v_e(e){let t=e.pieces.find(e=>e.key===`shorts:pick`&&e.selected&&e.piece.state===`done`),n=p_e(t?.piece.payload);return t===void 0||n===void 0?void 0:{fingerprint:t.fingerprint,picked:n}}function y_e({edit:e,view:t,prompts:n,problem:r,onChange:i,onPending:a}){let o=e.config.shorts??Kk,[s,c]=(0,m.useState)({count:String(o.count),minSeconds:String(o.minSeconds),maxSeconds:String(o.maxSeconds),...rA(o)}),l=[...n,...z5(t,`shorts`,`shorts`,t.revision.config.shorts?.prompt,n),...z5(t,`image`,`shortsImage`,t.revision.config.shorts?.imagePrompt,n)],u={enabled:o.enabled,...s,prompt:o.prompt??``,imagePrompt:o.imagePrompt??``,...o.titleOnScreen===void 0?{}:{titleOnScreen:o.titleOnScreen}},d=e.regenerate?.includes(F5)===!0,f=v_e(t);return(0,h.jsxs)(`div`,{className:`space-y-4`,children:[(0,h.jsx)(QV,{value:u,prompts:l,narrated:e.config.sources.audio!==`off`,problem:r,music:(0,h.jsx)(b_e,{edit:e,disabled:!o.enabled,onChange:i,onPending:a}),preview:(0,h.jsx)(U6,{settings:YV(u,e.config.subtitles?.fontId??`default`)}),onChange:t=>{c({count:t.count,minSeconds:t.minSeconds,maxSeconds:t.maxSeconds,...t.musicVolume===void 0?{}:{musicVolume:t.musicVolume},...t.speed===void 0?{}:{speed:t.speed},...t.fullVideoLink===void 0?{}:{fullVideoLink:t.fullVideoLink}});let n=e;for(let[e,r,i,a]of[[`shorts`,`shorts`,u.prompt,t.prompt],[`shortsImage`,`image`,u.imagePrompt,t.imagePrompt]]){if(i===a)continue;let t=l.find(e=>e.kind===r&&e.name===a);n=t===void 0?C_e(n,e):N5(n,e,t.body)}let r=e=>{let t=Number(e);return e.trim()===``||!Number.isFinite(t)?0:t},a=nA(t);i({...n,config:{...n.config,shorts:{enabled:t.enabled,count:r(t.count),minSeconds:r(t.minSeconds),maxSeconds:r(t.maxSeconds),...t.prompt===``?{}:{prompt:t.prompt},...t.imagePrompt===``?{}:{imagePrompt:t.imagePrompt},...a,...a.musicVolume!==void 0&&!Number.isFinite(a.musicVolume)?{musicVolume:-1}:{},...a.speed!==void 0&&!Number.isFinite(a.speed)?{speed:0}:{}}}})}}),f!==void 0&&o.enabled?(0,h.jsx)(x_e,{edit:e,view:t,pick:f,settings:o,again:d,problem:r,onChange:i}):null]})}function b_e({edit:e,disabled:t,onChange:n,onPending:r}){let i=(e.uploads??[]).some(e=>e.destination.kind===`shortsMusic`),a=e.content.shortsMusic!==void 0;return(0,h.jsxs)(`div`,{className:`basis-full space-y-2`,children:[i||a?(0,h.jsxs)(`p`,{className:`flex flex-wrap items-center gap-2 text-small text-ink-2`,children:[i?`New background music chosen. It is mixed under every short after you save and press Remake.`:`Background music plays quietly under every short and dips while the narrator speaks.`,(0,h.jsx)(L,{type:`button`,variant:`quiet`,disabled:t,onClick:()=>{let{shortsMusic:t,...r}=e.content;n({...e,content:r,uploads:(e.uploads??[]).filter(e=>e.destination.kind!==`shortsMusic`)})},children:`Remove the music`})]}):null,(0,h.jsx)(P5,{label:i||a?`Replace the background music`:`Background music (optional): an audio file, looped if shorter than a short`,kind:`audio`,disabled:t,onPending:r,onReady:t=>n({...e,uploads:[...(e.uploads??[]).filter(e=>e.destination.kind!==`shortsMusic`),{stagedFileId:t.id,destination:{kind:`shortsMusic`}}]})})]})}function x_e({edit:e,view:t,pick:n,settings:r,again:i,problem:a,onChange:o}){let s=(0,m.useId)(),c=t.revision.config.shorts,l=i||c===void 0||c.count!==r.count||c.minSeconds!==r.minSeconds||c.maxSeconds!==r.maxSeconds||(c.prompt??``)!==(r.prompt??``),u=Object.fromEntries(Object.entries(e.content.shortsRanges??{}).filter(([,e])=>e.pick===n.fingerprint)),d=n.picked.sentences??[],f=n.picked.durationSeconds??d.at(-1)?.end??0,p=n.picked.shorts.map(e=>{let t=u[String(e.number)],n=t===void 0?void 0:A5(d,t.first,t.last,f);return t===void 0||n===void 0?e:{...e,first:t.first,last:t.last,...n}}),g=(t,r,i)=>{let a=n.picked.shorts.find(e=>e.number===t.number),{[String(t.number)]:s,...c}=u,l=a!==void 0&&a.first===r&&a.last===i?c:{...c,[String(t.number)]:{first:r,last:i,pick:n.fingerprint}},{shortsRanges:d,...f}=e.content;o({...e,content:Object.keys(l).length===0?f:{...f,shortsRanges:l}})};return(0,h.jsxs)(`section`,{"aria-labelledby":`${s}-clips`,className:`space-y-3 border-t border-line pt-3`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,h.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,h.jsx)(`h4`,{id:`${s}-clips`,className:`sl-kicker m-0`,children:`Picked clips`}),(0,h.jsx)(B,{id:`project.shorts.clips`})]}),i?(0,h.jsxs)(`p`,{className:`flex flex-wrap items-center gap-2 text-small text-accent-ink`,children:[`The moments will be picked again after you save and press Remake; clips on the same sentences keep their images.`,(0,h.jsx)(L,{type:`button`,variant:`quiet`,onClick:()=>o({...e,regenerate:(e.regenerate??[]).filter(e=>e!==F5)}),children:`Keep the current moments`})]}):(0,h.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,h.jsx)(L,{type:`button`,onClick:()=>o(L5(e)),children:`Pick different moments`}),(0,h.jsx)(B,{id:`project.shorts.pick-again`})]})]}),l&&!i?(0,h.jsx)(`p`,{className:`text-small text-ink-2`,children:`These settings pick the moments again after you save and press Remake, so the clips below can be adjusted once the new ones are picked.`}):null,(0,h.jsx)(`ol`,{className:`space-y-3`,children:p.map(t=>(0,h.jsx)(S_e,{clip:t,picked:n.picked,adjusted:u[String(t.number)]!==void 0,locked:l,remade:e.regenerate?.includes(I5(t.number))===!0,problem:(()=>{let e=u[String(t.number)];return e===void 0?a(`content.shortsRanges.${String(t.number)}`):m_e(n.picked,t.number,e.first,e.last,r,p)})(),onRange:(e,n)=>g(t,e,n),onRemake:n=>o(n?R5(e,t.number):{...e,regenerate:(e.regenerate??[]).filter(e=>e!==I5(t.number))})},t.number))})]})}function S_e({clip:e,picked:t,adjusted:n,locked:r,remade:i,problem:a,onRange:o,onRemake:s}){let c=(0,m.useId)(),l=t.sentences??[],[u,d]=(0,m.useState)(!1),f=String(e.number),p=e=>l[e-1]?.text??``,g=(e,t,n,i)=>(0,h.jsx)(L,{type:`button`,variant:`quiet`,"aria-label":`${e} of short ${f}`,disabled:r||!i,onClick:()=>o(t,n),children:e.split(` `)[0]}),_=Math.round(e.end-e.start);return(0,h.jsxs)(`li`,{"aria-labelledby":`${c}-title`,className:`space-y-2 border-t border-line pt-3 first:border-t-0 first:pt-0`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-baseline justify-between gap-2`,children:[(0,h.jsxs)(`h5`,{id:`${c}-title`,className:`min-w-0 text-small font-semibold text-ink`,children:[`Short `,f,` · `,e.title]}),(0,h.jsxs)(`span`,{className:`text-label text-ink-3`,children:[`Sentences `,String(e.first),`-`,String(e.last),` · `,String(_),` s`,n?` · set by hand`:``]})]}),l.length===0?(0,h.jsx)(`p`,{className:`text-small text-ink-2`,children:`These shorts were picked before clips could be moved by hand. Use Pick different moments to adjust them.`}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`p`,{className:`flex flex-wrap items-center gap-x-2 text-small text-ink-2`,children:[(0,h.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[`Starts: “`,p(e.first),`”`]}),g(`Earlier start`,e.first-1,e.last,e.first>1),g(`Later start`,e.first+1,e.last,e.first<e.last)]}),(0,h.jsxs)(`p`,{className:`flex flex-wrap items-center gap-x-2 text-small text-ink-2`,children:[(0,h.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[`Ends: “`,p(e.last),`”`]}),g(`Earlier end`,e.first,e.last-1,e.last>e.first),g(`Later end`,e.first,e.last+1,e.last<l.length)]}),u?(0,h.jsx)(`div`,{className:`grid gap-3 md:grid-cols-2`,children:[`first`,`last`].map(t=>(0,h.jsx)(Y,{id:`${c}-${t}`,label:t===`first`?`Start sentence`:`End sentence`,tip:`project.shorts.range`,children:(0,h.jsx)(AV,{value:String(e[t]),disabled:r,onChange:n=>{let r=Number(n.target.value);o(t===`first`?r:e.first,t===`last`?r:e.last)},children:l.map((e,t)=>(0,h.jsxs)(`option`,{value:String(t+1),children:[String(t+1),`.`,` `,e.text.length>70?`${e.text.slice(0,69)}…`:e.text]},String(t+1)))})},t))}):null]}),a===void 0?null:(0,h.jsx)(`p`,{role:`alert`,className:`text-small text-danger`,children:a}),(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[l.length===0?null:(0,h.jsx)(L,{type:`button`,variant:`quiet`,disabled:r,onClick:()=>d(!u),children:u?`Hide the sentence lists`:`Use my own range`}),n?(0,h.jsx)(L,{type:`button`,variant:`quiet`,disabled:r,onClick:()=>{let n=t.shorts.find(t=>t.number===e.number);n!==void 0&&o(n.first,n.last)},children:`Back to the AI's choice`}):null,i?(0,h.jsxs)(`p`,{className:`flex flex-wrap items-center gap-2 text-small text-accent-ink`,children:[`Short `,f,` will be made again, with new images, after you save and press Remake.`,(0,h.jsx)(L,{type:`button`,variant:`quiet`,onClick:()=>s(!1),children:`Keep this short`})]}):(0,h.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,h.jsx)(L,{type:`button`,disabled:r,onClick:()=>s(!0),children:`Make this short again`}),(0,h.jsx)(B,{id:`project.shorts.remake`})]})]})]})}function z5(e,t,n,r,i){let a=e.revision.content.promptTemplates[n]??e.revision.config.rendered[n];return!r||a==null||i.some(e=>e.kind===t&&e.name===r)?[]:[{id:`saved-${n}`,kind:t,name:r,body:a,slots:[],updatedAt:e.revision.createdAt}]}function C_e(e,t){let{[t]:n,...r}=e.content.promptTemplates,{[t]:i,...a}=e.config.rendered;return M5({...e,config:{...e.config,rendered:a},content:{...e.content,promptTemplates:r}})}var w_e=K({shorts:G(K({number:W(),first:W().optional(),last:W().optional(),start:W(),end:W(),title:U(),description:U(),hashtags:G(U())}))});function T_e({stage:e,project:t,outputs:n}){let r=(0,m.useId)(),i=S8(n,e),a=C8(i,`shorts`),o=H5(i),s=W8(t.id),[c,l]=(0,m.useState)(),u=B5(i,`short_video`,o),d=t.config.shorts,f=(0,m.use)(r5),p=(0,m.use)(i5);if(d?.enabled!==!0&&a===void 0&&u.length===0)return null;let g=f&&p!==void 0&&d?.enabled===!0,_=e=>{let t=Qk(e,d?.fullVideoLink),n={text:`Couldn't copy short ${String(e.number)}. Select its text and copy it.`,tone:`error`};if(!navigator.clipboard){l(n);return}navigator.clipboard.writeText(t).then(()=>l({text:`Copied short ${String(e.number)}.`,tone:`success`}),()=>l(n))};return(0,h.jsxs)(`section`,{"aria-labelledby":`${r}-title`,className:`flex min-w-0 flex-col gap-4`,children:[(0,h.jsx)(`h3`,{id:`${r}-title`,className:`sl-kicker m-0`,children:o.length===0?`Shorts`:`${String(o.length)} short${o.length===1?``:`s`} · 9:16`}),(0,h.jsx)(z8,{files:o.map(e=>({output:u.find(t=>V5(t,e)),label:`Short ${String(e.number)}: ${e.title} (.mp4)`})),label:u.length===1?`Download the short`:`Download`,children:g&&o.length>0?(0,h.jsxs)(`span`,{className:`inline-flex items-center gap-1`,...Tb,children:[(0,h.jsx)(L,{onClick:()=>p({section:`shorts`,change:L5}),children:`Pick different moments`}),(0,h.jsx)(B,{id:`project.shorts.pick-again`})]}):null}),o.length===0?(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:e.state===`running`?`The clips are picked after the subtitle timing.`:`Not made yet. They are made with the video.`}):(0,h.jsx)(o2,{shorts:!0,list:!0,label:`Shorts`,className:`gap-y-7`,children:o.map(n=>(0,h.jsx)(E_e,{clip:n,projectId:t.id,review:G8(s,{itemKey:`shorts:${String(n.number)}`}),video:u.find(e=>V5(e,n)),stills:B5(i,`short_image`,o).filter(e=>V5(e,n)).toSorted((e,t)=>(e.meta.index??0)-(t.meta.index??0)),link:d?.fullVideoLink,wanted:tA(n.end-n.start,t.config.imageSeconds),state:e.state,failed:k_e(e.failureReason,n.number),ownDownload:u.length>1,onCopy:()=>_(n),...g?{onRemake:()=>p({section:`shorts`,change:e=>R5(e,n.number)})}:{}},n.number))}),(0,h.jsx)(v0,{tone:c?.tone??`info`,children:c?.text})]})}function E_e({clip:e,projectId:t,review:n,video:r,stills:i,wanted:a,state:o,failed:s,link:c,ownDownload:l,onCopy:u,onRemake:d}){let f=(0,m.useId)(),p=A8(r),g=A8(i[0]),_=i.length,v=s?`Couldn't make this short. Open Error details in the Video section to see why.`:o===`running`?_<a?`Making images · ${String(_)} of ${String(a)}`:`Rendering`:`Not made yet. It is made with the video.`;return(0,h.jsxs)(`li`,{"aria-labelledby":`${f}-title`,className:`flex min-w-0 flex-col gap-2`,children:[r!==void 0&&p!==void 0?(0,h.jsx)(i2,{src:p.url,label:`Short ${String(e.number)}`,portrait:!0,...g===void 0?{}:{poster:g.url}},r.id):s||o!==`running`?(0,h.jsx)(`div`,{className:`sl-media__frame sl-media__frame--portrait`,children:(0,h.jsx)(`p`,{className:`m-0 flex size-full items-center justify-center p-3 text-center text-small ${s?`text-danger`:`text-ink-3`}`,children:v})}):(0,h.jsx)(a2,{alt:`Short ${String(e.number)}`,aspect:`portrait`,generating:v}),(0,h.jsx)(`h4`,{id:`${f}-title`,className:`m-0 min-w-0 break-words text-small font-semibold text-ink`,children:e.title}),(0,h.jsx)(`p`,{className:`m-0 text-label text-ink-2 tabular-nums`,children:sF(r?.durationMs??Math.round((e.end-e.start)*1e3))}),(0,h.jsx)(`p`,{className:`m-0 break-words text-small text-ink-2`,children:e.description}),(0,h.jsx)(D_e,{link:c}),(0,h.jsx)(`p`,{className:`m-0 break-words text-small text-ink-2`,children:e.hashtags.join(` `)}),(0,h.jsx)(Y8,{review:n,projectId:t,busy:o===`running`}),(0,h.jsxs)(Ty,{className:`mt-1 flex-nowrap gap-1`,children:[l&&r!==void 0&&p!==void 0?(0,h.jsx)(fS,{href:p.url,download:!0,size:`small`,label:`Download short ${String(e.number)}`,tip:`Download`,children:(0,h.jsx)(pc,{"aria-hidden":`true`,strokeWidth:1.75})}):null,(0,h.jsx)(Cy,{size:`small`,tip:`Copy title, description and hashtags`,label:`Copy short ${String(e.number)}'s title, description and hashtags`,onClick:u,children:(0,h.jsx)(fc,{"aria-hidden":`true`,strokeWidth:1.75})}),d===void 0?null:(0,h.jsxs)(w8,{children:[(0,h.jsx)(T8,{asChild:!0,children:(0,h.jsx)(Cy,{size:`small`,tip:`More`,label:`More for short ${String(e.number)}`,children:(0,h.jsx)(mc,{"aria-hidden":`true`,strokeWidth:1.75})})}),(0,h.jsx)(E8,{align:`start`,children:(0,h.jsxs)(D8,{onSelect:d,children:[(0,h.jsx)(jc,{"aria-hidden":`true`,strokeWidth:1.75,className:`size-4`}),`Make short `,String(e.number),` again`]})})]})]})]})}function D_e({link:e}){let t=e?.trim()??``;return(0,h.jsxs)(`p`,{className:`m-0 flex flex-wrap items-center gap-x-2 gap-y-1 break-words text-small text-ink-2`,children:[(0,h.jsx)(`span`,{children:`Watch the full video:`}),t===``?(0,h.jsxs)(hS,{tone:`waiting`,title:`No link to the full video is saved. Copy leaves a placeholder to paste it over; to fill it in for every short, add the link under Edit settings → Shorts.`,children:[(0,h.jsx)(xc,{"aria-hidden":`true`,strokeWidth:1.75,className:`size-3`}),`Link needed`]}):(0,h.jsx)(`span`,{className:`min-w-0 break-all text-ink`,children:t})]})}function B5(e,t,n){let r=e.find(e=>e.role===`shorts`);return e.filter(e=>e.role===t&&(r===void 0||e.createdAt>=r.createdAt||n.some(t=>V5(e,t)&&e.meta.sentences?.[0]===t.first&&e.meta.sentences?.[1]===t.last)))}function V5(e,t){return e.meta.short===t.number}function H5(e){return O_e(V8(C8(e,`shorts`)).data)}function O_e(e){if(e===void 0)return[];try{let t=w_e.safeParse(JSON.parse(e));return t.success?t.data.shorts:[]}catch{return[]}}function k_e(e,t){return e?.startsWith(`Short ${String(t)}:`)===!0||e?.startsWith(`Short ${String(t)} `)===!0}function A_e({stage:e,project:t,outputs:n,subtitleControls:r}){let{api:i}=R(),a=Dy(),o=t.config.sources.video===`off`&&t.config.sources.audio!==`off`,s=C8(S8(n,e),o?`audio_export`:`video`),c=S8(n,e),l=C8(c,`subtitles_srt`),u=C8(c,`subtitles_vtt`),d=C8(c,`youtube_description`),f=C8(c,`youtube_tags`),p=C8(c,`audio_mp3`),m=C8(c,`audio_m4b`),g=B5(c,`short_video`,H5(c)).toSorted((e,t)=>(e.meta.short??0)-(t.meta.short??0)),_=A8(s),v=A8(j_e(n)),y=M_e(t.id,d,f,s?.durationMs??null),b=A8(u),x=s?.meta.subtitlesMode??t.config.subtitles?.mode,S=e.state===`running`,C=cF(e.progressCurrent??0,e.progressTotal??0);return _x({id:`project.folder`,title:`Open the project folder`,group:`This project`,context:t.title,keywords:[`folder`,`files`,`finder`,`explorer`,`video`],run:async()=>{if(s===void 0){a(`The video has not been saved yet, so there is no folder to open.`,`info`);return}try{let e=await D2(i,{projectId:t.id,asset:U3(s),folder:_?.folder??null});e.opened||a(`${O2} ${e.path}`,`info`)}catch(e){a(e instanceof Error?e.message:`The folder couldn't be opened. Use Open folder under the video.`,`error`)}}}),t.config.sources.video===`off`&&!o?(0,h.jsx)(P8,{children:r}):(0,h.jsxs)(P8,{className:`p-0`,children:[S?(0,h.jsx)(`p`,{className:`m-0 text-small text-accent-ink`,children:QP(e,t.config)?`Preparing subtitles · ${String(cF(e.progressCurrent??0,35))}%`:o?`Exporting combined audio`:e.progressTotal===null?`Rendering`:`Rendering · ${String(C)}%`}):null,s===void 0?(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:o?`No combined audio export has landed yet.`:`No render has landed yet.`}):o?(0,h.jsx)(Q8,{label:`Combined narration`,src:_?.url,marks:y},s.id):_===void 0?null:(0,h.jsx)(i2,{src:_.url,label:`Generated video`,...v===void 0?{}:{poster:v.url},chapters:y,portrait:t.format===`9:16`,className:t.format===`9:16`?`max-w-[360px]`:`max-w-[1100px]`,...x===`files`&&u&&b?{captions:{src:b.url,lang:`en`,label:`English`}}:{}},s.id),(0,h.jsx)(z8,{files:[{output:s,label:o?`Audio (.wav)`:`Video (.mp4)`},{output:l,label:`Subtitles (.srt)`},{output:u,label:`Subtitles (.vtt)`},{output:d,label:`YouTube description (.txt)`},{output:f,label:`YouTube tags (.txt)`},{output:p,label:`Audio with chapters (.mp3)`},{output:m,label:`Audiobook with chapters (.m4b)`},...g.map(e=>({output:e,label:`Short ${String(e.meta.short??``)} (.mp4)`}))]}),s===void 0?null:(0,h.jsx)(B8,{children:[sF(s?.durationMs??void 0),o?`WAV · stereo · 48 kHz`:t.format,s?.meta.master===void 0?void 0:wk(s.meta.master)].filter(e=>e!==void 0).join(` · `)}),s?.meta.warnings?.length?(0,h.jsx)(`ul`,{"aria-label":`Render notes`,className:`m-0 flex flex-col gap-1 pl-5 text-small text-ink-2`,children:s.meta.warnings.map(e=>(0,h.jsx)(`li`,{children:e},e))}):null,t.config.sources.audio===`off`||XO(t.config.language)===void 0?null:(0,h.jsx)(`p`,{role:`note`,className:`border-t border-line pt-3 text-small text-ink-2`,children:XO(t.config.language)}),s?.meta.subtitleOmissions?.length?(0,h.jsxs)(`details`,{className:`border-t border-line pt-3 text-small`,children:[(0,h.jsxs)(`summary`,{className:`cursor-pointer font-semibold`,children:[`Subtitles recovered after missing narration (`,s.meta.subtitleOmissions.length,`)`]}),(0,h.jsx)(`p`,{className:`m-0 mt-2 text-ink-2`,children:`These transcript passages could not be matched to the audio and were left out of the captions. The audio is unchanged. Review these passages before sharing.`}),(0,h.jsx)(`ul`,{className:`m-0 mt-2 flex flex-col gap-2 pl-5`,children:s.meta.subtitleOmissions.map(e=>(0,h.jsxs)(`li`,{children:[(0,h.jsx)(`strong`,{children:new Date(e.start*1e3).toISOString().slice(11,19)}),` —`,` `,e.text]},`${e.start}-${e.text}`))})]}):null,r?(0,h.jsxs)(`details`,{className:`border-t border-line pt-3`,children:[(0,h.jsx)(`summary`,{className:`cursor-pointer text-small font-semibold`,children:`Subtitles & fonts`}),r]}):null]})}function j_e(e){return e.filter(e=>e.role===`thumbnail`).toSorted((e,t)=>(e.meta.index??1)-(t.meta.index??1))[0]}function M_e(e,t,n,r){let{api:i}=R(),a=V8(t).data,o=V8(n).data,s=M({queryKey:z.youtubeEdits(e),queryFn:()=>Ss(i,e),enabled:t!==void 0});return a===void 0?[]:N_e(k5(O5(D5(a,o??``),s.data?.fields??{})).chapters,r===null?void 0:r/1e3)}function N_e(e,t){return E5(e,t).text.split(`
300
+ `).flatMap(e=>{let t=/^(\S+)\s+(.+)$/u.exec(e.trim()),n=t===null?void 0:T5(t[1]??``),r=t?.[2]?.trim()??``;return n===void 0||r===``?[]:[{start:n,title:r}]})}function P_e(e){switch(e.stage.kind){case`article`:return(0,h.jsx)(bge,{...e});case`audio`:return(0,h.jsx)(Tge,{...e});case`images`:return(0,h.jsx)(n_e,{...e});case`video`:return(0,h.jsx)(A_e,{...e});case`document`:return(0,h.jsx)(kge,{...e});case`research`:case`thumbnail`:return null}}K({summary:U(),chapters:G(K({start:uO([U(),W()]),title:U()})),hashtags:G(U()),tags:G(U())});function U5(e){return e.reduce((e,t)=>e+t.length+(/\s/.test(t)?2:0),0)+Math.max(0,e.length-1)}var W5={summary:`Summary`,chapters:`Chapters`,hashtags:`Hashtags`,tags:`Tags`},G5={Summary:`project.youtube.summary`,Chapters:`project.youtube.chapters`,Hashtags:`project.youtube.hashtags`,Tags:`project.youtube.tags`};function F_e({stage:e,project:t,outputs:n}){let r=(0,m.useId)(),{api:i}=R(),a=_(),o=S8(n,e),s=C8(o,`youtube_description`),c=C8(o,`youtube_tags`),l=V8(s).data,u=V8(c).data,d=M({queryKey:z.youtubeEdits(t.id),queryFn:()=>Ss(i,t.id)}),f=M({queryKey:z.projectChannelLinks(t.id),queryFn:()=>xs(i,t.id)}),[p,g]=(0,m.useState)(),v=Dy(),y=e=>a.setQueryData(z.youtubeEdits(t.id),e),b=N({mutationFn:e=>Cs(i,t.id,e.field,e.edit),onSuccess:(e,t)=>{y(e),g({text:t.done,tone:`success`})},onError:e=>g({text:`Couldn't save the change: ${e.message}`,tone:`error`})}),x=(0,m.useRef)({});if(_x({id:`project.copy-description`,title:`Copy description`,group:`This project`,context:t.title,keywords:[`youtube`,`description`,`chapters`,`clipboard`],shortcut:mP.copyDescription,run:()=>x.current.description===void 0?v(`The description has not been written yet.`,`info`):x.current.description()}),_x({id:`project.copy-tags`,title:`Copy tags`,group:`This project`,context:t.title,keywords:[`youtube`,`tags`,`clipboard`],run:()=>x.current.tags===void 0?v(`The tags have not been written yet.`,`info`):x.current.tags()}),t.config.youtubeDescription!==!0&&s===void 0)return null;let S=l===void 0?void 0:D5(l,u??``),C=O5(S,d.data?.fields??{}),w=k5(C),T=zj(f.data?.links??[],d.data?.links??[]),E=C8(o,`video`),D=E5(w.chapters,E?.durationMs===null||E?.durationMs===void 0?void 0:E.durationMs/1e3),O=a_e(D.adjustments),k=Vj(s_e({...w,chapters:D.text}),T),ee=Vj(w.tags,T),te=[...k.unknown,...ee.unknown].filter((e,t,n)=>n.findIndex(t=>Rj(t)===Rj(e))===t),ne=J5(ee.text),re=S!==void 0,A=(e,t)=>{let n=`Couldn't copy the ${t}. Select the text in the YouTube section and copy it.`;if(!navigator.clipboard){g({text:n,tone:`error`}),v(n,`error`);return}navigator.clipboard.writeText(e).then(()=>{g({text:`Copied the ${t}.`,tone:`success`}),v(`Copied the ${t}.`,`success`)},()=>{g({text:n,tone:`error`}),v(n,`error`)})};x.current=re?{description:()=>A(k.text,`description`),tags:()=>A(ee.text,`tags`)}:{};let ie=e.state===`running`?`Written after the subtitle timing.`:`Not written yet. It is made with the video.`,j=(e,t)=>(0,h.jsx)(I_e,{label:W5[e],value:C[e],links:T,disabled:!re||b.isPending,multiline:e!==`hashtags`,placeholder:ie,render:t,onSave:t=>b.mutate({field:e,edit:{text:t,base:S?.[e]??``},done:`Saved your ${W5[e].toLowerCase()}.`}),onUseGenerated:()=>b.mutate({field:e,edit:null,done:`The ${W5[e].toLowerCase()} follows the generated text again.`}),onKeepMine:(t,n)=>b.mutate({field:e,edit:{text:t,base:n},done:`Kept your ${W5[e].toLowerCase()}.`})},e);return(0,h.jsxs)(`section`,{"aria-labelledby":`${r}-title`,className:`@container flex min-w-0 flex-col gap-4`,children:[(0,h.jsx)(`h3`,{id:`${r}-title`,className:`sr-only`,children:`YouTube`}),(0,h.jsxs)(`div`,{className:`grid min-w-0 grid-cols-[minmax(0,1fr)] gap-x-8 gap-y-6 @4xl:grid-cols-[minmax(0,75ch)_minmax(0,1fr)]`,children:[(0,h.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3`,children:[(0,h.jsx)(K5,{id:`${r}-description`,label:`Description`,copy:re?()=>A(k.text,`description`):void 0,keyshortcuts:kx(mP.copyDescription),count:re?`${String(k.text.length)} / ${String(L6)} characters`:void 0,over:k.text.length>L6,main:!0}),j(`summary`),j(`chapters`,()=>D.text===``?(0,h.jsx)(`span`,{className:`text-ink-3`,children:`Left out; see the note below.`}):(0,h.jsx)(q5,{text:D.text,links:T})),O===void 0?null:(0,h.jsx)(`p`,{className:`text-small text-waiting`,children:O}),j(`hashtags`)]}),(0,h.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3`,children:[(0,h.jsx)(K5,{id:`${r}-tags`,label:`Tags`,copy:re?()=>A(ee.text,`tags`):void 0,count:re?`${String(U5(ne))} / 500 characters`:void 0,over:U5(ne)>500}),j(`tags`,e=>(0,h.jsx)(L_e,{text:e,links:T}))]})]}),te.length===0?null:(0,h.jsxs)(`p`,{className:`text-small text-waiting`,children:[`No link is saved for ${te.map(e=>`{{${e}}}`).join(`, `)}, so it stays as typed. Add it under Channel links on `,f.data===void 0?`the channel's Brand tab`:(0,h.jsx)(pa,{to:`/channels/$channelId`,params:{channelId:f.data.channelId},className:`underline`,children:`the channel's Brand tab`}),`${te.some(e=>Rj(e)===Rj(`Previous video`))?`, or set this project's Previous video below`:``}.`]}),(0,h.jsx)(R_e,{projectId:t.id,edits:d.data,onSaved:e=>{y(e),g({text:`Saved this project's Previous video link.`,tone:`success`})},onError:e=>g({text:e,tone:`error`})}),(0,h.jsx)(v0,{tone:p?.tone??`info`,children:p?.text})]})}function K5({id:e,label:t,copy:n,count:r,over:i,keyshortcuts:a,main:o=!1}){return(0,h.jsxs)(`div`,{className:`flex min-h-8 flex-wrap items-center gap-3 border-b border-line pb-2`,children:[(0,h.jsx)(`h4`,{id:e,className:`m-0 text-title-3 font-semibold text-ink`,children:t}),r===void 0?null:(0,h.jsx)(`span`,{className:I(`text-small tabular-nums`,i?`text-danger`:`text-ink-3`),children:i?`${r}, over YouTube's limit`:r}),(0,h.jsx)(`span`,{className:`flex-1`}),(0,h.jsxs)(L,{type:`button`,variant:o?`primary`:`secondary`,disabled:n===void 0,"aria-label":`Copy ${t.toLowerCase()}`,"aria-keyshortcuts":a,onClick:n,children:[(0,h.jsx)(fc,{"aria-hidden":`true`,strokeWidth:1.75}),`Copy`]})]})}function I_e({label:e,value:t,links:n,disabled:r,multiline:i,placeholder:a,render:o,onSave:s,onUseGenerated:c,onKeepMine:l}){let u=(0,m.useId)(),[d,f]=(0,m.useState)(),[p,g]=(0,m.useState)(!1),_=d!==void 0,v=e.toLowerCase(),y=e in G5?G5[e]:void 0;return(0,h.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,...Tb,children:[(0,h.jsxs)(`div`,{className:`flex min-h-8 flex-wrap items-center gap-2`,children:[(0,h.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,h.jsx)(`h5`,{id:`${u}-label`,className:`sl-kicker text-ink-3`,children:e}),y===void 0?null:(0,h.jsx)(B,{id:y,label:v,className:`-my-1`})]}),t.edited?(0,h.jsx)(`span`,{className:`text-small text-ink-2`,children:`Your edit`}):null,(0,h.jsx)(`span`,{className:`flex-1`}),t.edited&&!_?(0,h.jsx)(L,{type:`button`,variant:`quiet`,size:`small`,disabled:r,"aria-label":`Use the generated ${v}`,onClick:c,children:`Use generated`}):null,(0,h.jsxs)(L,{type:`button`,variant:`quiet`,size:`small`,disabled:r||_,"aria-label":`Edit ${v}`,onClick:()=>f(t.text),children:[(0,h.jsx)(Ec,{"aria-hidden":`true`,strokeWidth:1.75}),`Edit`]})]}),t.pending===void 0?null:(0,h.jsxs)(`div`,{className:`flex flex-col gap-2 border-l-2 border-waiting pl-3`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,h.jsx)(`p`,{className:`text-small text-ink`,children:`New generated version available.`}),(0,h.jsx)(L,{type:`button`,disabled:r,"aria-label":`Use the new generated ${v}`,onClick:c,children:`Use it`}),(0,h.jsx)(L,{type:`button`,disabled:r,"aria-label":`Keep my ${v}`,onClick:()=>l(t.text,t.pending??``),children:`Keep mine`}),(0,h.jsx)(L,{type:`button`,variant:`quiet`,"aria-expanded":p,"aria-label":`${p?`Hide`:`View`} the ${v} diff`,onClick:()=>g(e=>!e),children:p?`Hide diff`:`View diff`})]}),p?(0,h.jsx)(V4,{before:t.text,after:t.pending,beforeLabel:`Yours`,afterLabel:`New generated`}):null]}),_?(0,h.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,h.jsx)(`label`,{htmlFor:`${u}-edit`,className:`sr-only`,children:e}),i?(0,h.jsx)(kV,{id:`${u}-edit`,rows:e===`Chapters`?8:5,value:d,onChange:e=>f(e.currentTarget.value)}):(0,h.jsx)(OV,{id:`${u}-edit`,value:d,onChange:e=>f(e.currentTarget.value)}),(0,h.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,h.jsxs)(L,{type:`button`,variant:`primary`,disabled:r,onClick:()=>{s(d),f(void 0)},children:[`Save `,v]}),(0,h.jsx)(L,{type:`button`,variant:`secondary`,onClick:()=>f(void 0),children:`Cancel`})]})]}):(0,h.jsx)(`section`,{"aria-labelledby":`${u}-label`,className:I(`min-w-0 whitespace-pre-wrap break-words text-small`,t.text===``?`text-ink-3`:`text-ink`),children:t.text===``?a:o===void 0?(0,h.jsx)(q5,{text:t.text,links:n}):o(t.text)})]})}function q5({text:e,links:t}){let n=0;return(0,h.jsx)(h.Fragment,{children:Bj(e,t).map(e=>{let t=String(n);return n+=e.kind===`text`?e.text.length:e.raw.length,e.kind===`text`?(0,h.jsx)(`span`,{children:e.text},t):e.url===void 0?(0,h.jsx)(`mark`,{title:`No link named ${e.name}`,className:`rounded-[2px] bg-waiting/25 px-0.5 text-ink`,children:e.raw},t):(0,h.jsx)(`span`,{title:e.raw,className:`underline decoration-dotted underline-offset-[3px]`,children:e.url},t)})})}function J5(e){return e.split(`,`).map(e=>e.trim()).filter(e=>e!==``)}function L_e({text:e,links:t}){return(0,h.jsx)(`ul`,{className:`flex flex-wrap gap-2 whitespace-normal`,children:J5(e).map((e,n)=>(0,h.jsx)(`li`,{className:`rounded-full border border-line bg-raised px-2 py-0.5 text-small text-ink`,children:(0,h.jsx)(q5,{text:e,links:t})},n))})}function R_e({projectId:e,edits:t,onSaved:n,onError:r}){let{api:i}=R(),a=(0,m.useId)(),o=t?.links.find(e=>Rj(e.name)===Rj(`Previous video`))?.url??``,[s,c]=(0,m.useState)(),l=s??o,u=N({mutationFn:()=>{let n=(t?.links??[]).filter(e=>Rj(e.name)!==Rj(Fj));return ws(i,e,l.trim()===``?n:[...n,{name:Fj,url:l.trim()}])},onSuccess:e=>{c(void 0),n(e)},onError:e=>r(e.message)});return(0,h.jsxs)(`div`,{className:`flex flex-wrap items-end gap-2`,children:[(0,h.jsxs)(`div`,{className:`flex min-w-[260px] flex-1 flex-col gap-1 sm:max-w-[520px]`,...Tb,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,h.jsx)(`label`,{className:`sl-field__label`,htmlFor:a,children:`Previous video for this project`}),(0,h.jsx)(B,{id:`project.youtube.previous-video`,className:`-my-1`})]}),(0,h.jsx)(OV,{id:a,type:`url`,placeholder:`https://youtu.be/…`,value:l,onChange:e=>c(e.currentTarget.value)})]}),(0,h.jsx)(L,{type:`button`,disabled:u.isPending||t===void 0||l.trim()===o,onClick:()=>u.mutate(),children:`Save links`})]})}var Y5=[{stage:`audio`,name:`Audio`},{stage:`images`,name:`Images`},{stage:`video`,name:`Video / export`}];function z_e({projectId:e,revisionId:t,gates:n,stages:r,reload:i,saved:a}){let{api:o}=R(),[s,c]=(0,m.useState)(null),[l,u]=(0,m.useState)(!1),[d,f]=(0,m.useState)(null),p=(0,m.useRef)(!1),g=(0,m.useRef)(!0),_=(0,m.useRef)(null),v=(0,m.useRef)(null),y=JSON.stringify([t,n.map(e=>[e.stage,e.checkpointId]).toSorted()]),b=s!==null&&s.baseIdentity!==y,x=s?.stages??n.map(e=>e.stage),S=Y5.some(({stage:e})=>x.includes(e)!==n.some(t=>t.stage===e)),C=b||d!==null&&d.kind!==`success`,w=b?{kind:`refused`,message:`Checkpoint choices changed elsewhere. Press Reload checkpoint choices before saving, then make your change again.`}:d;(0,m.useEffect)(()=>(g.current=!0,()=>{g.current=!1}),[]),(0,m.useEffect)(()=>{(d||b)&&_.current?.focus()},[d,b]);async function T(){if(!(p.current||!S||C)){p.current=!0,u(!0);try{let n=await dpe(o,e,{revisionId:t,stages:x});if(!g.current)return;n.ok?n.value.revisionId===t?(a(n.value),c(null),f({kind:`success`,message:`Checkpoint choices saved.`})):f({kind:`refused`,message:`The project was edited elsewhere. Press Reload checkpoint choices to see its current choices.`}):f({kind:`refused`,message:n.message})}catch(e){g.current&&f({kind:`transport`,message:`${_o(e instanceof Error?e.message:`Slopify didn't confirm the change`)} It may or may not have saved. Press Reload checkpoint choices before changing anything else.`})}finally{p.current=!1,g.current&&u(!1)}}}async function E(){if(!p.current){p.current=!0,u(!0);try{let e=await i();g.current&&e&&(c(null),f(null),v.current?.focus())}finally{p.current=!1,g.current&&u(!1)}}}return(0,h.jsxs)(`div`,{className:`space-y-2`,children:[(0,h.jsxs)(`fieldset`,{ref:v,tabIndex:-1,className:`space-y-2`,...Tb,children:[(0,h.jsx)(`legend`,{className:`float-left mr-1`,children:`Checkpoint choices`}),(0,h.jsx)(B,{id:`project.checkpoints.choices`,className:`-my-1`}),(0,h.jsx)(`div`,{className:`clear-both`}),Y5.map(({stage:e,name:t})=>{let n=r.find(t=>t.kind===e),i=n?.state===`pending`&&(e===`video`?n.source!==`off`||r.some(e=>e.kind===`audio`&&e.source!==`off`&&e.state!==`skipped`):(n.source??`generate`)===`generate`);return(0,h.jsxs)(`label`,{className:`flex min-h-10 items-center gap-3`,children:[(0,h.jsx)(`input`,{type:`checkbox`,checked:x.includes(e),disabled:!i||l||C,onChange:t=>{c({baseIdentity:s?.baseIdentity??y,stages:t.target.checked?[...x,e]:x.filter(t=>t!==e)}),f(null)}}),`Before `,t]},e)})]}),w?(0,h.jsx)(`p`,{ref:_,tabIndex:-1,role:w.kind===`success`?`status`:`alert`,children:w.message}):null,(0,h.jsx)(L,{type:`button`,disabled:!S||l||C,onClick:()=>void T(),children:l?`Saving…`:`Save checkpoints`}),C?(0,h.jsx)(L,{type:`button`,disabled:l,onClick:()=>void E(),children:`Reload checkpoint choices`}):null]})}var X5=e=>e.charAt(0).toUpperCase()+e.slice(1);function B_e(e){return e.revisionId===null?null:(0,h.jsx)(V_e,{...e,revisionId:e.revisionId},`${e.projectId}:${e.revisionId}`)}function V_e({projectId:e,revisionId:t,paused:n,stages:r,approvedInRail:i}){let{api:a}=R(),o=_(),s=M({queryKey:k3(e,t),queryFn:()=>j3(a,e),retry:!1}),c=s.data,l=async()=>{let e=await s.refetch();return!e.isError&&e.data?.ok===!0&&e.data.value.revisionId===t?e.data.value:void 0},u=async()=>{let e=await s.refetch();return!e.isError&&e.data?.ok===!0&&e.data.value.revisionId===t};return s.isPending?null:s.error||c?.ok===!1?(0,h.jsxs)(`section`,{"aria-label":`Review checkpoints`,className:`flex flex-col items-start gap-3`,children:[(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-small text-danger`,children:s.error?.message??(c?.ok===!1?c.message:`Checkpoints couldn't be loaded. Press Reload checkpoints.`)}),(0,h.jsx)(L,{onClick:()=>void u(),children:`Reload checkpoints`})]}):c?.ok?c.value.revisionId===t?(0,h.jsxs)(`section`,{"aria-label":`Review checkpoints`,className:`flex flex-col gap-5`,children:[(0,h.jsx)(V,{title:`Review checkpoints`,size:`small`,className:`pb-0`}),n?(0,h.jsx)(`p`,{className:`m-0 text-small text-waiting`,children:`The project is paused. Continue the run before approving held work.`}):null,(0,h.jsx)(z_e,{projectId:e,revisionId:t,gates:c.value.checkpoints,stages:r,reload:l,saved:n=>{o.setQueryData(k3(e,t),{ok:!0,value:n}),o.invalidateQueries({queryKey:z.project(e)}),o.invalidateQueries({queryKey:z.projects})}}),c.value.checkpoints.map(a=>(0,h.jsx)(H_e,{gate:a,disabled:n||a.projectId!==e||a.revisionId!==t||r.some(e=>e.kind===a.stage&&[`running`,`canceled`].includes(e.state)),reload:u,...a.checkpointId===i?{inRail:!0}:{}},`${a.checkpointId}:${a.fingerprint}`))]}):(0,h.jsx)(`section`,{"aria-label":`Review checkpoints`,className:`flex flex-col items-start gap-3`,children:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-small text-danger`,children:`The project was edited after these checkpoints loaded. Press Reload checkpoints before approving.`})}):null}function H_e({gate:e,disabled:t,reload:n,inRail:r=!1}){let{api:i}=R(),a=_(),o=(0,m.useRef)(null),s=(0,m.useRef)(!1),c=(0,m.useRef)(!0),l=(0,m.useRef)(null),[u,d]=(0,m.useState)(!1),[f,p]=(0,m.useState)(null);(0,m.useEffect)(()=>(c.current=!0,()=>{c.current=!1}),[]),(0,m.useEffect)(()=>{f!==null&&l.current?.focus()},[f]);let g=[`configured`,`pending-review`,`held`].includes(e.state)&&e.fingerprint===e.currentFingerprint;async function v(){if(!(s.current||t||!g||f?.kind===`refused`||f?.kind===`success`)){s.current=!0,d(!0),o.current??={revisionId:e.revisionId,fingerprint:e.fingerprint,idempotencyKey:crypto.randomUUID()};try{let t=await M3(i,e.projectId,e.checkpointId,o.current);o.current=null,c.current&&p(t.ok?{kind:`success`,message:t.value.replayed?`Checkpoint already approved.`:`Checkpoint approved. Work will run when its dependencies are ready.`}:{kind:`refused`,message:t.message}),a.invalidateQueries({queryKey:O3(e.projectId)}),a.invalidateQueries({queryKey:z.project(e.projectId)}),a.invalidateQueries({queryKey:z.projects})}catch(e){c.current&&p({kind:`transport`,message:`${_o(e instanceof Error?e.message:`Slopify didn't confirm the approval`)} Press Retry approval to check whether it went through.`})}finally{s.current=!1,c.current&&d(!1)}}}return(0,h.jsxs)(`div`,{className:`flex flex-col gap-2 border-t border-line pt-4`,children:[(0,h.jsx)(V,{as:`h3`,title:`${X5(e.stage)} checkpoint`,className:`pb-0`}),(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:e.state===`released`&&e.approvedAt!==null?`Authorized for this revision. Work can run when dependencies are ready and the project is resumed.`:e.state===`satisfied`?`Checkpoint satisfied. Its reviewed work is complete.`:e.state===`invalidated`||e.fingerprint!==e.currentFingerprint?`Inputs changed. Review the current revision before approving.`:g?`${X5(e.stage)} is held for your review. Its dependent work waits for this approval; independent work can continue.`:`Checkpoint ${e.state}.`}),(0,h.jsxs)(`p`,{className:`m-0 text-small text-ink-3`,children:[`Reviewed revision: `,e.revisionId]}),e.dependents.length?(0,h.jsx)(`ul`,{"aria-label":`Dependent work`,className:`m-0 flex list-none flex-wrap gap-2 p-0`,children:e.dependents.map(e=>(0,h.jsx)(`li`,{className:`sl-chip`,children:X5(e)},e))}):(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:`No dependent stages.`}),f?(0,h.jsx)(`p`,{ref:l,tabIndex:-1,role:f.kind===`success`?`status`:`alert`,className:f.kind===`success`?`m-0 text-small`:`m-0 text-small text-danger`,children:f.message}):null,g&&r&&f===null?(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:`Its approval is the project's next action, in the right rail.`}):g?(0,h.jsx)(L,{className:`self-start`,disabled:t||u||f?.kind===`refused`||f?.kind===`success`,onClick:()=>void v(),children:u?`Approving…`:f?.kind===`transport`?`Retry approval`:`Approve ${X5(e.stage)} checkpoint`}):null,f?.kind===`refused`?(0,h.jsx)(L,{className:`self-start`,onClick:async()=>{await n()&&p(null)},children:`Reload checkpoints`}):null]})}function U_e({projects:e,queryKey:t}){let{api:n}=R(),r=_(),i=Dy(),[a,o]=(0,m.useState)(),[s,c]=(0,m.useState)(),l=N({mutationFn:e=>Lo(n,e.id),onMutate:()=>c(void 0),onSuccess:(e,t)=>{i(e.files===0?`"${t.title}" had no working files left to remove.`:`Freed ${Q5(e.bytesFreed)} from "${t.title}" (${String(e.files)} working file${e.files===1?``:`s`}).`,`success`)},onError:e=>c(e.message),onSettled:()=>r.invalidateQueries({queryKey:t})}),u=e.toSorted((e,t)=>t.bytes-e.bytes);return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`p`,{className:`m-0 mb-2 flex items-center gap-1 text-small text-ink-2`,children:[`Keep outputs only frees a finished project's working files.`,(0,h.jsx)(B,{id:`settings.storage.keep-outputs`})]}),(0,h.jsx)(hU,{label:`Storage by project`,children:u.map(e=>(0,h.jsx)(gU,{title:e.title,meta:(0,h.jsxs)(`span`,{className:`tabular-nums`,children:[Q5(e.bytes),` · outputs `,Q5(e.outputsBytes),` · working files `,Q5(e.workingBytes)]}),actions:(0,h.jsx)(L,{variant:`quiet`,size:`small`,disabled:!e.finished||e.removableBytes===0||l.isPending,title:e.finished?e.removableBytes===0?`No working files left to remove.`:`Frees ${Q5(e.removableBytes)}.`:`Available once the project has finished.`,onClick:()=>o(e),children:l.isPending&&l.variables?.id===e.id?`Removing…`:`Keep outputs only`})},e.id))}),s===void 0?null:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 mt-2 text-small text-danger`,children:s}),(0,h.jsx)(Ay,{open:a!==void 0,title:`Keep only the outputs of "${a?.title??``}"?`,consequence:Z5(a?.removableFiles??0,a?.removableBytes??0),confirmLabel:`Keep outputs only`,pending:l.isPending,onConfirm:()=>{let e=a;o(void 0),e!==void 0&&l.mutate(e)},onCancel:()=>o(void 0)})]})}function Z5(e,t){return`This removes ${String(e)} working file(s) and frees ${Q5(t)}: the images, narration parts, subtitle timing and render settings the project was made from. The video, shorts, thumbnail, article, description and document stay, and so does anything you uploaded. If you change this project later (edit an image, a caption style or the narration, or re-render), Slopify has to make those files again first, which takes time and uses provider credits.`}function Q5(e){if(e<1024)return`${e} B`;let t=[`KB`,`MB`,`GB`,`TB`],n=e,r=t[0]??`KB`;for(let e of t)if(n/=1024,r=e,n<1024||e===t.at(-1))break;return`${n>=10?n.toFixed(0):n.toFixed(1).replace(/\.0$/,``)} ${r}`}var $5=e=>[`storage`,`project`,e];function W_e({projectId:e,title:t,status:n,sample:r}){let{api:i}=R(),a=_(),o=Dy(),[s,c]=(0,m.useState)(!1),l=n===`done`||n===`partial`,u=M({queryKey:[...$5(e),n],queryFn:()=>Io(i,e),enabled:l&&!r}),d=N({mutationFn:()=>Lo(i,e),onSuccess:e=>o(e.files===0?`"${t}" had no working files left to remove.`:`Freed ${Q5(e.bytesFreed)} from "${t}". The outputs are all still here.`,`success`),onError:e=>o(`The working files of "${t}" weren't removed: ${e.message}`,`error`),onSettled:async()=>{await Promise.all([a.invalidateQueries({queryKey:$5(e)}),a.invalidateQueries({queryKey:[`storage-usage`]}),a.invalidateQueries({queryKey:z.project(e)})])}}),f=u.data;if(!l||r||f===void 0||!f.finished||f.removableBytes===0)return null;let p=Q5(f.removableBytes);return(0,h.jsxs)(`section`,{"aria-label":`Free space`,className:`flex flex-col gap-2`,children:[(0,h.jsx)(V,{as:`h3`,title:`Free space`,meta:`Outputs ${Q5(f.outputsBytes)} · working files ${Q5(f.workingBytes)}`,info:`project.free-space`}),(0,h.jsx)(`div`,{children:(0,h.jsx)(L,{variant:`secondary`,size:`small`,className:`h-auto min-h-8 max-w-full whitespace-normal py-1 text-left`,disabled:d.isPending,disabledReason:`Removing the working files…`,onClick:()=>c(!0),children:d.isPending?`Removing…`:`Free ${p}: keep the outputs, drop the working files`})}),(0,h.jsx)(Ay,{open:s,title:`Free ${p} from "${t}"?`,consequence:Z5(f.removableFiles,f.removableBytes),confirmLabel:`Free ${p}`,cancelLabel:`Keep the working files`,pending:d.isPending,onConfirm:()=>{c(!1),d.mutate()},onCancel:()=>c(!1)})]})}function G_e({project:e,prompts:t,editing:n,onEdit:r,more:i,nextChapter:a}){let o=J_e(e.status);return(0,h.jsx)(Aq,{crumb:(0,h.jsxs)(pa,{to:`/projects`,className:`inline-flex items-center gap-1 text-ink-3 hover:text-ink`,children:[(0,h.jsx)(sc,{"aria-hidden":`true`,strokeWidth:1.75}),`Projects`]}),title:e.title,meta:Y_e(e,t),actions:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(mS,{tone:o.tone,children:[o.word,(0,h.jsx)(`span`,{className:`sr-only`,role:`status`,"aria-live":`polite`,children:`Project: ${o.word}`})]}),a!==void 0&&K_e(e)?(0,h.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,h.jsx)(L,{variant:`secondary`,disabled:a.pending,onClick:a.run,children:a.pending?`Making the next chapter…`:`Make the next chapter`}),(0,h.jsx)(B,{id:`project.next-chapter`}),a.error===void 0?null:(0,h.jsx)(`span`,{role:`alert`,className:`max-w-[320px] text-small text-danger`,children:a.error})]}):null,(0,h.jsxs)(L,{variant:`secondary`,"aria-pressed":n,onClick:r,children:[(0,h.jsx)(Fc,{"aria-hidden":`true`,strokeWidth:1.75}),`Edit settings`]}),(0,h.jsxs)(w8,{modal:!1,children:[(0,h.jsx)(T8,{asChild:!0,children:(0,h.jsx)(Cy,{label:`More project actions`,children:(0,h.jsx)(mc,{"aria-hidden":`true`,strokeWidth:1.75})})}),(0,h.jsx)(E8,{children:i.map(e=>(0,h.jsx)(q_e,{item:e},e.id))})]})]})})}function K_e(e){return e.config.voices?.format===`audiobook`&&(e.status===`done`||e.status===`partial`)}function q_e({item:e}){return(0,h.jsxs)(h.Fragment,{children:[e.apart?(0,h.jsx)(Zhe,{}):null,(0,h.jsx)(D8,{...e.disabled?{disabled:!0}:{},onSelect:()=>e.run(),children:e.label})]})}function J_e(e){switch(e){case`running`:return{tone:`running`,word:`Running`};case`paused`:return{tone:`waiting`,word:`Paused`};case`failed`:return{tone:`failed`,word:`Failed`};case`partial`:return{tone:`waiting`,word:`Done with problems`};case`done`:return{tone:`done`,word:`Done`};case`canceled`:return{tone:`off`,word:`Canceled`};case`pending`:return{tone:`off`,word:`Queued`}}}function Y_e(e,t){let n=e.config.articlePrompt,r=t===void 0||t.some(e=>e.name===n),i=n===void 0||n===``?void 0:r?n:`${n} (deleted)`,a=e.config.voices?.book;return[a===void 0?void 0:KA(a),i,e.format,`started ${Tu(e.createdAt)}`].filter(e=>e!==void 0).join(` · `)}var X_e={pending:`text-ink-3`,running:`text-accent-ink`,done:`text-accent-ink`,failed:`text-danger`,partial:`text-waiting`,canceled:`text-waiting`,paused:`text-waiting`,provided:`text-ink-2`,skipped:`text-ink-3`},e7={partial:`done with problems`};function Z_e({state:e,announce:t,className:n}){return(0,h.jsxs)(`span`,{className:I(`inline-flex items-center`,n),children:[(0,h.jsx)(`span`,{"data-state":e,className:I(`engraved font-bold`,X_e[e]),children:e7[e]??e}),t===void 0?null:(0,h.jsx)(`span`,{className:`sr-only`,role:`status`,"aria-live":`polite`,children:`${t}: ${e7[e]??e}`})]})}var Q_e={pending:`bg-line shadow-[inset_0_0_0_1px_var(--color-line-strong)]`,running:`bg-accent shadow-[0_0_0_3px_var(--color-accent-tint)] animate-lamp-pulse motion-reduce:animate-none`,done:`bg-accent-ink`,failed:`bg-danger`,partial:`bg-waiting`,canceled:`bg-waiting`,paused:`bg-waiting`,provided:`bg-line shadow-[inset_0_0_0_1px_var(--color-line-strong)]`,skipped:`bg-line shadow-[inset_0_0_0_1px_var(--color-line-strong)]`};function $_e({state:e,className:t}){return(0,h.jsx)(`span`,{"aria-hidden":`true`,"data-lamp":e,className:I(`size-[10px] shrink-0 rounded-full`,Q_e[e],t)})}function eve({label:e,state:t,className:n}){return(0,h.jsxs)(`span`,{className:I(`inline-flex items-center gap-2`,n),children:[(0,h.jsx)($_e,{state:t}),(0,h.jsx)(Z_e,{state:t,announce:e})]})}var t7={research:`Research`,article:`Article`,audio:`Narration`,images:`Images`,thumbnail:`Thumbnail`,video:`Video`,document:`Document`};function tve({project:e,revisionId:t,stages:n,outputs:r}){let i=r.filter(e=>e.role===`image`);return(0,h.jsxs)(`div`,{className:`grid min-w-0 gap-6 lg:grid-cols-[260px_minmax(0,1fr)]`,children:[(0,h.jsxs)(`div`,{className:`min-w-0`,children:[(0,h.jsx)(V,{title:`Steps`}),(0,h.jsx)(hU,{label:`Steps`,children:n.filter(e=>e.state!==`skipped`).map(e=>(0,h.jsx)(gU,{title:t7[e.kind],actions:(0,h.jsx)(eve,{label:t7[e.kind],state:e.state})},e.id))})]}),(0,h.jsxs)(`div`,{className:`min-w-0`,children:[(0,h.jsx)(V,{title:`Article`}),(0,h.jsx)(q3,{projectId:e.id,stage:`article`,className:`mb-6`}),(0,h.jsx)(V,{title:`Narration`}),(0,h.jsx)(ive,{projectId:e.id,revisionId:t}),(0,h.jsx)(V,{title:`Images`}),i.length===0?(0,h.jsx)(`p`,{className:`text-small text-ink-2`,children:`The images appear here as each one is drawn.`}):(0,h.jsx)(o2,{list:!0,density:`compact`,label:`Images so far`,children:i.map(t=>(0,h.jsx)(nve,{output:t,aspect:g5(e.format)},t.id))})]})]})}function nve({output:e,aspect:t}){let n=A8(e);if(n===void 0)return null;let r=e.meta.index===void 0?``:` ${String(e.meta.index)}`;return(0,h.jsx)(`li`,{className:`min-w-0`,children:(0,h.jsx)(a2,{src:n.url,alt:e.meta.prompt??`Image${r}`,aspect:t,...e.meta.index===void 0?{}:{meta:`#${String(e.meta.index)}`}})})}var rve=240;function ive({projectId:e,revisionId:t}){let{api:n}=R(),r=M({queryKey:Ny(e,t),queryFn:()=>Gy(n,e),enabled:t!==null}),i=(r.data?.pieces??[]).flatMap(e=>e.peaks),a=(r.data?.pieces??[]).reduce((e,t)=>e+t.seconds,0),o=Math.max(1,Math.ceil(i.length/rve)),s=[];for(let e=0;e<i.length;e+=o)s.push(Math.max(...i.slice(e,e+o)));return(0,h.jsxs)(`div`,{className:`mb-6`,children:[(0,h.jsx)(`div`,{role:`img`,"aria-label":s.length===0?`No narration yet`:`Narration so far: ${String(Math.round(a))} seconds`,className:`flex h-16 items-center gap-px overflow-hidden rounded-control border border-line bg-raised px-2`,children:s.map((e,t)=>(0,h.jsx)(`span`,{className:`w-[3px] shrink-0 rounded-full bg-accent`,style:{height:`${String(Math.max(4,Math.round(e*100)))}%`}},t))}),(0,h.jsx)(`p`,{className:`mt-1 text-label text-ink-3`,children:r.error?r.error.message:s.length===0?`The waveform grows as each part of the narration is spoken.`:`${String(Math.round(a))} s narrated${r.data!==void 0&&`complete`in r.data&&r.data.complete?``:` so far`}`})]})}function ave(e){let t=[],n=[],r=0,i=()=>{let e=n[0],r=n.at(-1);e!==void 0&&r!==void 0&&t.push({start:e.start,end:r.end,text:n7(n.map(e=>e.text)),...e.speaker===void 0?{}:{speaker:e.speaker}}),n=[]};for(let t of e){if(!Number.isFinite(t.start)||!Number.isFinite(t.end)||t.start<r-.001||t.end<=t.start)throw Error(`The saved caption timing is damaged. Use More → Render the video again in the Video section to time them again, then Try again.`);let e=n[0];e!==void 0&&(t.start-r>.7||t.speaker!==e.speaker||t.end-e.start>5||n7([...n.map(e=>e.text),t.text]).split(`
301
301
  `).length>2)&&i(),n.push({...t,text:t.text.replace(/\s+/g,` `).trim()}),r=t.end,/[.!?]["'’”)]*$/.test(t.text)&&i()}return i(),t}function n7(e){let t=[],n=``;for(let r of e)n!==``&&n.length+r.length+1>42&&(t.push(n),n=``),n=n===``?r:`${n} ${r}`;return n!==``&&t.push(n),t.join(`
302
- `)}function ave({cues:e,duration:t,onChange:n,onPending:r}){let i=(0,m.useId)(),[a,o]=(0,m.useState)(()=>e.map(e=>({...e,start:String(e.start),end:String(e.end)}))),[s,c]=(0,m.useState)(),[l,u]=(0,m.useState)(!1),d=(0,m.useRef)(r);d.current=r,(0,m.useEffect)(()=>{d.current(l)},[l]),(0,m.useEffect)(()=>()=>d.current(!1),[]);function f(){let e=[],r=new Set,i=0;if(!Number.isFinite(t)||t<=0){c(`The narration length isn't known yet, so captions can't be checked. Reload the page and try again.`);return}for(let[n,o]of a.entries()){let a=o.start.trim()===``?NaN:Number(o.start),s=o.end.trim()===``?NaN:Number(o.end);if(r.has(o.id)){c(`Caption ${n+1}: this caption is listed twice. Remove the copy.`);return}if(r.add(o.id),!Number.isFinite(a)||a<0||a<i){c(`Caption ${n+1}: start must be a number of seconds, no earlier than the previous caption's end.`);return}if(!Number.isFinite(s)||s<=a||s>t){c(`Caption ${n+1}: end must be after its start and no later than the end of the narration.`);return}if(o.text.trim()===``){c(`Caption ${n+1}: enter caption text.`);return}e.push({id:o.id,text:o.text,start:a,end:s,...o.speaker===void 0?{}:{speaker:o.speaker}}),i=s}n(e),c(void 0),u(!1)}return(0,h.jsxs)(`section`,{"aria-label":`Edit caption cues`,className:`space-y-3`,...Tb,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,h.jsx)(`h3`,{children:`Caption text and timing`}),(0,h.jsx)(B,{id:`project.captions.editor`})]}),a.map((e,t)=>(0,h.jsxs)(`fieldset`,{className:`space-y-2 rounded-control border border-line-strong p-3`,children:[(0,h.jsxs)(`legend`,{children:[`Caption `,t+1]}),(0,h.jsxs)(`label`,{htmlFor:`${i}-${e.id}-text`,className:`block text-small`,children:[`Text for caption `,t+1,(0,h.jsx)(kV,{id:`${i}-${e.id}-text`,value:e.text,onChange:n=>{u(!0),o(a.with(t,{...e,text:n.target.value}))}})]}),(0,h.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,h.jsxs)(`label`,{htmlFor:`${i}-${e.id}-start`,className:`block text-small`,children:[`Start for caption `,t+1,(0,h.jsx)(OV,{id:`${i}-${e.id}-start`,inputMode:`decimal`,value:e.start,onChange:n=>{u(!0),o(a.with(t,{...e,start:n.target.value}))}})]}),(0,h.jsxs)(`label`,{htmlFor:`${i}-${e.id}-end`,className:`block text-small`,children:[`End for caption `,t+1,(0,h.jsx)(OV,{id:`${i}-${e.id}-end`,inputMode:`decimal`,value:e.end,onChange:n=>{u(!0),o(a.with(t,{...e,end:n.target.value}))}})]})]})]},e.id)),s===void 0?null:(0,h.jsx)(`p`,{role:`alert`,className:`text-danger`,children:s}),(0,h.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,h.jsx)(L,{type:`button`,onClick:f,children:`Apply caption edits to draft`}),(0,h.jsx)(B,{id:`project.captions.apply`})]}),l?(0,h.jsx)(`p`,{children:`Apply these caption edits before saving the project.`}):null]})}function r7(e){return`imagePrompts.${String(e)}`}function i7(e){let t=/^imagePrompts\.(\d+)$/.exec(e??``);return t?.[1]===void 0?void 0:Number(t[1])}function ove(e,t){return e.length===t.length&&e.every((e,n)=>e.name===t[n]?.name&&e.number===t[n]?.number)}function sve(e){let{from:t,to:n,content:r}=e,i=n.map(e=>t.findIndex(t=>t.name===e.name)),a=[],o={},s={};for(let[e,t]of Object.entries(r.promptTemplates))i7(e)===void 0&&(o[e]=t);for(let[t,n]of Object.entries(e.rendered))i7(t)===void 0&&(s[t]=n);for(let[t,c]of n.entries()){let n=r7(t),l=i[t]??-1;if(l>=0){let t=r7(l);Object.hasOwn(r.promptTemplates,t)&&(o[n]=r.promptTemplates[t]??null);let i=e.rendered[t];i!==void 0&&(s[n]=i);continue}let u=e.body(c.name);if(u===void 0){a.push({field:`imagePrompts.${String(t)}.name`,message:`The image prompt "${c.name}" is not in the Library any more. Untick it under Images, or add it back on Library → Prompts.`});continue}o[n]=u,s[n]=hq(u,e.values)}if(a.length>0)return{ok:!1,fields:a};let c=new Map;for(let e of r.imageOrder){let n=i7(r.imageDefinitions[e]?.templateKey);n===void 0||n>=t.length||c.set(n,[...c.get(n)??[],e])}let l={},u=[],d=[],f=(e,t)=>{let n=r7(e),r=o[n];return t===void 0?{source:`generate`,assetId:null,prompt:s[n]??null,templateKey:r==null?null:n}:{...t,source:`generate`,assetId:null,templateKey:t.templateKey??null}},p=(t,n,r)=>Array.from({length:Math.max(0,n)},()=>{let n=e.key();return l[n]=f(t,r),u.push(n),n}),m=[];for(let e of r.imageOrder){let a=r.imageDefinitions[e];if(a===void 0)continue;let o=i7(a.templateKey);if(o===void 0||o>=t.length){l[e]=a,m.push(e);continue}let s=i.indexOf(o);if(s===-1){d.push(e);continue}let u=c.get(o)??[],f=t[o]?.number!==n[s]?.number,h=f?n[s]?.number??0:u.length,g=u.indexOf(e);if(g>=h){d.push(e);continue}let _=a.templateKey===r7(s)?a:{...a,templateKey:r7(s)};l[e]=_,m.push(e),f&&g===Math.min(u.length,h)-1&&m.push(...p(s,h-u.length,_))}for(let[e,r]of n.entries()){let n=i[e]??-1,a=n>=0?c.get(n)??[]:[];n>=0&&(a.length>0||t[n]?.number===r.number)||m.push(...p(e,r.number,void 0))}return{ok:!0,content:{...r,imageOrder:m,imageDefinitions:l,promptTemplates:o},rendered:s,added:u,removed:d}}function cve({edit:e,saved:t,prompts:n,problem:r,onChange:i}){let{config:a}=e;if(a.sources.images!==`generate`)return null;let o=n.filter(e=>e.kind===`image`);return(0,h.jsxs)(`section`,{"aria-label":`Image prompts`,className:`space-y-3`,children:[(0,h.jsx)(u6,{prompts:o,picked:a.imagePrompts,problem:r,onPick:t=>i({...e,config:{...a,imagePrompts:t}})}),(0,h.jsx)(lve,{edit:e,saved:t,prompts:o,problem:r})]})}function lve({edit:e,saved:t,prompts:n,problem:r}){let i=e.config.imagePrompts,a=r(`imagePrompts`);if(ove(t,i))return a===void 0?null:(0,h.jsx)(a7,{children:a});let o=0,s=sve({from:t,to:i,content:e.content,rendered:e.config.rendered,values:e.config.values,body:e=>n.find(t=>t.name===e)?.body,key:()=>`planned-${String(++o)}`});if(!s.ok)return(0,h.jsx)(a7,{children:s.fields.map(e=>e.message).join(` `)});let c=e=>`${String(e)} ${e===1?`image`:`images`}`,l=[...s.added.length>0?[`adds ${c(s.added.length)} to make`]:[],...s.removed.length>0?[`removes ${c(s.removed.length)}`]:[]];return(0,h.jsxs)(h.Fragment,{children:[a===void 0?null:(0,h.jsx)(a7,{children:a}),(0,h.jsx)(`p`,{role:`status`,className:`m-0 text-small text-ink-2`,children:l.length===0?`Saving keeps every image as it is.`:`Saving ${l.join(` and `)}. The other images are kept; the new ones are made when you remake outdated outputs.`})]})}function a7({children:e}){return(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-small text-danger`,children:e})}function uve({edit:e,problem:t,onChange:n}){let r=e.config.ambientBed,[i,a]=(0,m.useState)(()=>r===void 0?void 0:pA(r)),o=r?.source===`upload`?[...oA,`upload`]:oA,s=i===void 0?[]:[...pve(i)];return(0,h.jsx)(q2,{value:i,inherit:`None`,sources:o,offerNone:!1,problem:e=>t(`ambientBed.${e}`)??s.find(t=>t.field===e)?.message,onChange:t=>{a(t);let r=mA(t),{ambientBed:i,...o}=e.config;n({...e,config:r===void 0?o:{...o,ambientBed:r}})}})}function dve({edit:e,problem:t,onChange:n}){let r=e.config.loudness,[i,a]=(0,m.useState)(()=>r===void 0?{...uk,enabled:!1}:{...r,enabled:!0});return(0,h.jsx)(W6,{value:i,problem:e=>t(`loudness.${e}`),onChange:t=>{a(t);let{loudness:r,...i}=e.config;n({...e,config:t.enabled?{...i,loudness:{videoLufs:t.videoLufs,audioFilesLufs:t.audioFilesLufs}}:i})}})}function fve({edit:e,problem:t,onChange:n}){let[r,i]=(0,m.useState)(()=>({sentencePauseSeconds:String(e.config.sentencePauseSeconds??0),paragraphPauseSeconds:String(e.config.paragraphPauseSeconds??0)}));if(e.config.sources.audio!==`generate`)return null;let a=e=>{let t=X6(r[e]);return t===void 0?`Enter a number of seconds.`:kk(t,e===`sentencePauseSeconds`?`sentences`:`paragraphs`)};return(0,h.jsx)(Y6,{sentence:r.sentencePauseSeconds,paragraph:r.paragraphPauseSeconds,problem:e=>a(e)??t(e),onChange:(t,a)=>{i({...r,[t]:a});let o=X6(a);if(o===void 0)return;let{[t]:s,...c}=e.config;n({...e,config:o===0?c:{...c,[t]:o}})}})}function pve(e){let t=mA(e);return t===void 0?[]:dA(t)}function mve({edit:e,problem:t,onChange:n}){let r=(0,m.useId)(),{config:i}=e,a=i.imageScale,[o,s]=(0,m.useState)(()=>a===void 0?void 0:ak(a));if(i.sources.images!==`generate`)return null;let c=a?.words??(nk(e.content.articleMarkdown??``)||1500),l=t=>{s(t);let{imageScale:r,...o}=i;if(t===void 0){n({...e,config:o});return}let l=o7(t);l!==void 0&&n({...e,config:{...o,imageScale:{perHour:l,words:c},...a===void 0&&i.motionStyle===`zoom`?{motionStyle:`mixed`}:{}}})},u=i.imagePrompts.reduce((e,t)=>e+t.number,0),d=a===void 0?u:ck(i).reduce((e,t)=>e+t,0),f=o===void 0?void 0:o7(o),p=o===void 0?void 0:f===void 0?{problem:!0,text:o.every===`minutes`?`Enter a number of minutes between ${String(QO)} and 60.`:`Enter a number of images per hour between 1 and 240.`}:{problem:!1,text:`For about ${String(Math.max(1,Math.round(rk(c))))} minutes of narration: ${String(d)} images${d>u?`, ${String(d-u)} more than the prompts' ${String(u)}`:`, which the prompts' Numbers already cover`}.`},g=t(`imageScale`)??void 0;return(0,h.jsxs)(`div`,{className:`flex flex-col items-start gap-2`,...Tb,children:[(0,h.jsx)(Eb,{checked:o!==void 0,label:`More images for long videos`,describedBy:`${r}-line`,tip:`play.image-scale`,onChange:e=>l(e?{every:`minutes`,value:`2`}:void 0)}),o===void 0?null:(0,h.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2 text-small`,children:[(0,h.jsx)(Db,{label:`How the rate is given`,value:o.every,options:[{value:`minutes`,label:`Every N minutes`},{value:`hour`,label:`N per hour`}],onChange:e=>l({every:e,value:hve(o.value,o.every,e)})}),o.every===`minutes`?(0,h.jsx)(`span`,{children:`One image every`}):null,(0,h.jsx)(OV,{"aria-label":o.every===`minutes`?`Minutes per image`:`Images per hour`,inputMode:`decimal`,className:`w-[72px] tabular-nums`,"aria-invalid":p?.problem===!0,"aria-describedby":`${r}-line`,value:o.value,onChange:e=>l({every:o.every,value:e.target.value})}),(0,h.jsx)(`span`,{children:o.every===`minutes`?`minutes`:`images per hour`})]}),g===void 0&&p===void 0?null:(0,h.jsx)(`p`,{id:`${r}-line`,className:g!==void 0||p?.problem?`m-0 text-label text-danger`:`m-0 text-label text-ink-3`,children:g??p?.text})]})}function o7(e){let t=Number(e.value.trim());if(e.value.trim()!==``&&Number.isFinite(t))return e.every===`minutes`?t>=.25&&t<=60?ik(t):void 0:t>=1&&t<=240?t:void 0}function hve(e,t,n){if(t===n)return e;let r=Number(e.trim());return e.trim()===``||!Number.isFinite(r)||r<=0?e:String(Math.round(60/r*100)/100)}function gve({edit:e,view:t,imageKey:n,index:r}){let{api:i}=R(),a=e.content.imageDefinitions[n];if(a===void 0)return null;let o=t?.outputs.filter(e=>e.output.stageKind===`images`&&e.output.role===`image`)??[],s=o.find(e=>e.selected&&e.workKey===`image:${n}`),c=e.uploads?.some(e=>e.destination.kind===`image`&&e.destination.imageKey===n)??!1,l=a.source===`generate`||c||s?.assetId===a.assetId?s:o.find(e=>e.assetId===a.assetId&&e.available),u=l?.available===!0,d=!u&&(l!==void 0||a.source===`provide`&&a.assetId!==null),f=c?u?`Replacement ready to save; previous image shown until Save`:`Replacement ready to save; preview available after Save`:d?`Image file unavailable`:u?a.source===`provide`&&l!==s?`Provided image selected`:l.state===`review`?`Image retained; review required`:l.state===`outdated`?`Outdated image retained until rebuilt`:`Current image retained`:`No completed image yet`,p=u&&/\.(mp4|mov|m4v|webm|mkv)$/i.test(l.output.path);return(0,h.jsxs)(h.Fragment,{children:[!u||t===void 0?null:p?(0,h.jsx)(i2,{className:`max-w-[240px]`,label:`Video clip ${r+1}`,src:E2(i,t.revision.projectId,t.revision.id,l.recordId)}):(0,h.jsx)(a2,{className:`max-w-[240px]`,alt:`Retained scene ${r+1}`,src:E2(i,t.revision.projectId,t.revision.id,l.recordId)}),(0,h.jsx)(`p`,{children:p?`${f} · video clip, played muted`:f})]})}function s7(e,t,n){let r=t+n,i=e[t],a=e[r];if(i===void 0||a===void 0)return e;let o=[...e];return o[t]=a,o[r]=i,o}function _ve({edit:e,onChange:t,onPending:n,view:r,getEdit:i}){let a=(0,m.useId)(),[o,s]=(0,m.useState)({}),{content:c}=e,l=tk(e.config),u=(0,m.useRef)(e);u.current=e;function d(e){let n=e.content.imageOrder.flatMap(t=>{let n=e.content.imageDefinitions[t];return n===void 0?[]:[n]}),r=e.content.imageOrder.length===0||e.config.sources.images===`off`?`off`:n.some(e=>e.source===`generate`)?`generate`:`provide`,i={...e,config:{...e.config,sources:{...e.config.sources,images:r,...r===`off`?{video:`off`}:{}}}};u.current=i,t(i)}function f(e,t){let n=i?.()??u.current,r=n.content.imageDefinitions[e];if(r===void 0)return;let a=r.templateKey??`image:${e}`;s(t=>({...t,[e]:(t[e]??0)+1})),d(N5({...n,...n.uploads===void 0?{}:{uploads:n.uploads.filter(t=>t.destination.kind!==`image`||t.destination.imageKey!==e)},content:{...n.content,imageDefinitions:{...n.content.imageDefinitions,[e]:{...r,templateKey:a}}}},a,t))}function p(e){let t=i?.()??u.current,n=t.content,r=crypto.randomUUID();d({...t,config:{...t.config,sources:{...t.config.sources,images:t.config.sources.images===`off`?`provide`:t.config.sources.images}},content:{...n,imageOrder:[...n.imageOrder,r],imageDefinitions:{...n.imageDefinitions,[r]:{source:`provide`,assetId:null,prompt:null}}},uploads:[...t.uploads??[],{stagedFileId:e.id,destination:{kind:`image`,imageKey:r}}]})}return(0,h.jsxs)(`section`,{"aria-label":`Edit images`,className:`space-y-3`,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,h.jsx)(`h3`,{children:`Images`}),(0,h.jsx)(B,{id:`project.images.editor`})]}),c.imageOrder.map((t,s)=>{let l=c.imageDefinitions[t];return l===void 0?(0,h.jsxs)(`p`,{role:`alert`,children:[`Image definition missing: `,t]},t):(0,h.jsxs)(`fieldset`,{className:`space-y-2 rounded-control border border-line-strong p-3`,children:[(0,h.jsxs)(`legend`,{children:[`Image `,s+1]}),(0,h.jsx)(gve,{edit:e,view:r,imageKey:t,index:s}),l.source===`generate`?(0,h.jsxs)(`div`,{...Tb,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,h.jsxs)(`label`,{htmlFor:`${a}-${t}-prompt`,children:[`Prompt for image `,s+1]}),(0,h.jsx)(B,{id:`project.images.prompt`,label:`prompt for image ${String(s+1)}`})]}),(0,h.jsx)(kV,{id:`${a}-${t}-prompt`,value:l.templateKey===void 0||l.templateKey===null?l.prompt??``:c.promptTemplates[l.templateKey]??l.prompt??``,onChange:e=>f(t,e.target.value)})]}):null,l.source===`generate`&&l.templateKey==null?(0,h.jsxs)(L,{type:`button`,onClick:()=>f(t,l.prompt??``),children:[`Use saved wording as template for image `,s+1]}):null,(0,h.jsx)(P5,{label:`Replace image ${s+1}`,kind:`images`,onPending:e=>n(`image:${t}`,e),onReady:e=>{let n=i?.()??u.current,r=n.content,a=r.imageDefinitions[t];a!==void 0&&r.imageOrder.includes(t)&&d({...n,regenerate:(n.regenerate??[]).filter(e=>e!==`image:${t}`),uploads:[...(n.uploads??[]).filter(e=>e.destination.kind!==`image`||e.destination.imageKey!==t),{stagedFileId:e.id,destination:{kind:`image`,imageKey:t}}],content:{...r,imageDefinitions:{...r.imageDefinitions,[t]:{...a,source:`provide`,prompt:null,templateKey:null}}}})}},`${t}:${o[t]??0}:${e.config.sources.images===`off`}`),(0,h.jsxs)(L,{type:`button`,disabled:s===0,onClick:()=>d({...e,content:{...c,imageOrder:s7(c.imageOrder,s,-1)}}),children:[`Move image `,s+1,` earlier`]}),(0,h.jsxs)(L,{type:`button`,disabled:s===c.imageOrder.length-1,onClick:()=>d({...e,content:{...c,imageOrder:s7(c.imageOrder,s,1)}}),children:[`Move image `,s+1,` later`]}),(0,h.jsxs)(L,{type:`button`,onClick:()=>{let n=c.imageOrder.filter(e=>e!==t);d({...e,config:n.length===0?{...e.config,sources:{...e.config.sources,images:`off`,video:`off`}}:e.config,content:{...c,imageOrder:n,imageDefinitions:Object.fromEntries(Object.entries(c.imageDefinitions).filter(([e])=>e!==t))},regenerate:(e.regenerate??[]).filter(e=>e!==`image:${t}`),uploads:(e.uploads??[]).filter(e=>e.destination.kind!==`image`||e.destination.imageKey!==t)})},children:[`Delete image `,s+1,c.imageOrder.length===1?` and turn Images and Video Off`:``]}),l.source===`generate`?(0,h.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,h.jsxs)(L,{type:`button`,onClick:()=>d({...e,regenerate:[...new Set([...e.regenerate??[],`image:${t}`])]}),children:[`Regenerate image `,s+1,` after review`]}),(0,h.jsx)(B,{id:`project.images.regenerate`})]}):null]},t)}),(0,h.jsx)(L,{type:`button`,disabled:c.imageOrder.length>=l,onClick:()=>{if(c.imageOrder.length>=l)return;let t=crypto.randomUUID();d({...e,config:{...e.config,sources:{...e.config.sources,images:`generate`}},content:{...c,imageOrder:[...c.imageOrder,t],promptTemplates:{...c.promptTemplates,[`image:${t}`]:``},imageDefinitions:{...c.imageDefinitions,[t]:{source:`generate`,assetId:null,prompt:``,templateKey:`image:${t}`}}}})},children:`Add generated image`}),c.imageOrder.length>=l?(0,h.jsxs)(`p`,{children:[`At most `,l,` images can be included.`]}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(P5,{label:`Add provided image`,kind:`images`,onPending:e=>n(`image:new`,e),onReady:p},`new-image:${e.config.sources.images===`off`}`),(0,h.jsx)(P5,{label:`Add a video clip`,kind:`images`,accept:`video/mp4,video/quicktime,video/webm,video/x-matroska,.mp4,.mov,.m4v,.webm,.mkv`,onPending:e=>n(`clip:new`,e),onReady:p},`new-clip:${e.config.sources.images===`off`}`)]})]})}var vve=K({logicalKey:U().min(1),logicalText:U(),segment:q([`body`,`intro`,`outro`]),text:U()});function yve(e,t){if(t==null)return e;let n=[...t.intro??[],...t.body??[],...t.outro??[]];return n.length===0?e:n.flatMap(t=>e.filter(e=>e.key===t))}function bve(e){let t=new Map,n=new Set,r=0;for(let i of e.pieces){if(!i.selected||i.stageKind!==`audio`||i.piece.kind!==`chunk`)continue;let e;try{e=i.piece.payload===null?null:JSON.parse(i.piece.payload)}catch{r++;continue}let a=vve.safeParse(e);if(!a.success){r++;continue}let{logicalKey:o,logicalText:s}=a.data;if(n.has(o)){r++;continue}let c=t.get(o);if(c!==void 0&&c.text!==s){r+=c.parts+1,t.delete(o),n.add(o);continue}t.set(o,{key:o,text:s,parts:(c?.parts??0)+1})}return{groups:[...t.values()],unmapped:r}}function xve({view:e,edit:t,onChange:n,onPending:r,getEdit:i}){let a=(0,m.useId)(),{api:o}=R(),s=M({queryKey:[`narration-chunks`,e.revision.projectId,e.revision.id],queryFn:async()=>{let t=await Ede(o,e.revision.projectId,e.revision.id);return t.ok?t.value.chunks:null},staleTime:1/0}),c=bve(e),l=yve(c.groups,s.data),u=c.unmapped,d=(0,m.useRef)(t);d.current=t;let[f,p]=(0,m.useState)({});function g(e){d.current=e,n(e)}return(0,h.jsxs)(`section`,{"aria-label":`Edit narration`,className:`space-y-3`,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,h.jsx)(`h3`,{children:`Narration`}),(0,h.jsx)(B,{id:`project.narration.editor`})]}),t.config.chunking?.mode===`whole`||t.config.chunking===void 0?(0,h.jsx)(`p`,{children:`This narration uses one whole request. Editing its text rebuilds the whole narration request.`}):null,u===0?null:(0,h.jsx)(`p`,{children:`Some older audio cannot be matched reliably to its narration text. Replace the provided narration or rebuild from the article to edit those chunks.`}),l.map((e,n)=>{let o=t.content.narrationOverrides[e.key];return(0,h.jsxs)(`fieldset`,{className:`space-y-2 rounded-control border border-line-strong p-3`,children:[(0,h.jsxs)(`legend`,{children:[`Narration chunk `,n+1]}),(0,h.jsxs)(`p`,{children:[e.parts,` audio `,e.parts===1?`part`:`parts`,` in this narration chunk.`]}),(0,h.jsxs)(`div`,{className:`text-small`,...Tb,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,h.jsxs)(`label`,{htmlFor:`${a}-${e.key}-text`,children:[`Text for narration chunk `,n+1]}),(0,h.jsx)(B,{id:`project.narration.chunk-text`,label:`text for narration chunk ${String(n+1)}`})]}),(0,h.jsx)(kV,{id:`${a}-${e.key}-text`,value:o?.kind===`text`?o.text:e.text,onChange:n=>{p(t=>({...t,[e.key]:(t[e.key]??0)+1})),g({...t,...t.uploads===void 0?{}:{uploads:t.uploads.filter(t=>t.destination.kind!==`narration`||t.destination.key!==e.key)},content:{...t.content,narrationOverrides:{...t.content.narrationOverrides,[e.key]:{kind:`text`,text:n.target.value}}}})}})]}),(0,h.jsx)(P5,{label:`Replace narration chunk ${n+1}`,kind:`audio`,onPending:t=>r(`narration:${e.key}`,t),onReady:t=>{let n=i?.()??d.current;g({...n,regenerate:(n.regenerate??[]).filter(t=>t!==e.key),uploads:[...(n.uploads??[]).filter(t=>t.destination.kind!==`narration`||t.destination.key!==e.key),{stagedFileId:t.id,destination:{kind:`narration`,key:e.key}}]})}},`${e.key}:${f[e.key]??0}`),t.regenerate?.includes(e.key)?(0,h.jsxs)(`p`,{className:`flex flex-wrap items-center gap-2 text-small text-accent-ink`,children:[`Narration chunk `,n+1,` will be regenerated after you save and press Remake.`,(0,h.jsxs)(L,{type:`button`,variant:`quiet`,onClick:()=>{let t=i?.()??d.current;g({...t,regenerate:(t.regenerate??[]).filter(t=>t!==e.key)})},children:[`Keep narration chunk `,n+1]})]}):(0,h.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,h.jsxs)(L,{type:`button`,onClick:()=>{let t=i?.()??d.current,n={...t.content.narrationOverrides};n[e.key]?.kind===`asset`&&delete n[e.key],p(t=>({...t,[e.key]:(t[e.key]??0)+1})),g({...t,content:{...t.content,narrationOverrides:n},uploads:t.uploads?.filter(t=>t.destination.kind!==`narration`||t.destination.key!==e.key),regenerate:[...new Set([...t.regenerate??[],e.key])]})},children:[`Regenerate narration chunk `,n+1,` after review`]}),(0,h.jsx)(B,{id:`project.narration.regenerate`})]})]},e.key)})]})}function Sve(e){let{config:t,fingerprints:n}=e.revision;if(t.sources.audio===`off`)return;let r=t.sources.audio===`provide`?[{key:`audio:provided`,role:`audio_body`}]:[...t.intro===void 0?[]:[{key:`audio:intro`,role:`audio_intro`}],{key:`audio:body:concat`,role:`audio_body`},...t.outro===void 0?[]:[{key:`audio:outro`,role:`audio_outro`}]],i=e.outputs.filter(e=>e.selected&&e.state===`ready`&&e.available&&e.fingerprint===n[e.workKey]),a=r.map(({key:e,role:t})=>i.find(n=>n.workKey===e&&n.output.role===t));if(a.some(e=>e===void 0))return;let o=a.map(e=>e?.output.durationMs);if(o.every(c7))return o.reduce((e,t)=>e+t,0)/1e3+Math.max(0,r.length-1)*t.silenceGapSeconds+2*t.edgeSilenceSeconds;let s=i.find(e=>(e.output.role===`audio_export`||e.output.role===`video`)&&c7(e.output.durationMs))?.output.durationMs;return c7(s)?s/1e3:void 0}function c7(e){return e!=null&&Number.isFinite(e)&&e>0}function Cve({edit:e,prompts:t,problem:n,onChange:r,onPending:i,getEdit:a}){let{config:o}=e;if(o.sources.images!==`generate`)return null;let s=o.reference,c=s===void 0?N6:{source:s.source,prompt:s.prompt??``,thumbnail:s.thumbnail!==!1},l=e=>({...e,uploads:(e.uploads??[]).filter(e=>e.destination.kind!==`provided`||e.destination.stage!==`reference`)});return(0,h.jsx)(`section`,{"aria-label":`Establishing image`,className:`space-y-3`,children:(0,h.jsx)(P6,{value:c,prompts:t,problem:n,onChange:n=>{let{reference:i,...a}=o;if(n.source===`off`){r(l({...e,config:a}));return}let s={source:n.source,...n.source===`prompt`?{prompt:n.prompt}:{},...n.thumbnail?{}:{thumbnail:!1}},u=n.source===`prompt`&&n.prompt!==c.prompt?t.find(e=>e.kind===`image`&&e.name===n.prompt):void 0,d={...e,config:{...a,reference:s}},f=u===void 0?d:N5(d,`referencePrompt`,u.body);r(n.source===`provide`?f:l(f))},upload:(0,h.jsx)(P5,{label:e.content.provided.reference===void 0?`Upload the establishing image`:`Replace the establishing image`,kind:`images`,accept:`image/png,image/jpeg`,onPending:i,onReady:t=>{let n=l(a?.()??e);n.config.reference?.source===`provide`&&r({...n,uploads:[...n.uploads??[],{stagedFileId:t.id,destination:{kind:`provided`,stage:`reference`}}]})}})})})}var wve=K({words:G(K({text:U().trim().min(1),start:W().finite().nonnegative(),end:W().finite().positive(),confidence:W().optional(),speaker:U().min(1).optional()})).min(1)});function l7(e){let{config:t,content:n}=e;return JSON.stringify({source:t.sources.audio,audio:n.provided.audio,uploads:e.uploads?.filter(e=>e.destination.kind===`narration`||e.destination.kind===`provided`&&e.destination.stage===`audio`)??[],edge:t.edgeSilenceSeconds,...t.sources.audio===`generate`?{choice:t.audio,chunking:t.chunking,article:n.articleMarkdown??t.provided.article,articleSource:t.sources.article,renderedArticle:t.rendered.article,intro:t.intro,outro:t.outro,renderedIntro:t.rendered.intro,renderedOutro:t.rendered.outro,gap:t.silenceGapSeconds,overrides:n.narrationOverrides,regenerate:e.regenerate?.filter(e=>/^(audio:|article:|entry:)/.test(e))??[]}:{}})}function Tve({view:e,edit:t,fields:n,onChange:r,onPending:i,section:a}){let{api:o}=R(),s=M($y(o)).data?.prompts??[],c=l7(t),l=t.config.sources.audio!==`off`&&c===l7({config:e.revision.config,content:e.revision.content}),u=e.revision.fingerprints[`subtitles:timing`],d=l?Sve(e):void 0,f=d!==void 0&&u!==void 0&&u!==``,p=(0,m.useRef)({edit:t,onChange:r,revisionId:e.revision.id,identity:c});p.current={edit:t,onChange:r,revisionId:e.revision.id,identity:c};let g=(0,m.useRef)(i);g.current=i;let[_,v]=(0,m.useState)(new Set),[y,b]=(0,m.useState)(),x=(0,m.useRef)(void 0),S=(0,m.useRef)(!0),C=(0,m.useCallback)((e,t)=>{S.current&&v(n=>{if(n.has(e)===t)return n;let r=new Set(n);return t?r.add(e):r.delete(e),r})},[]);(0,m.useEffect)(()=>{g.current(_.size>0)},[_]),(0,m.useEffect)(()=>(S.current=!0,()=>{S.current=!1,x.current?.abort(),g.current(!1)}),[]),(0,m.useEffect)(()=>{let t=e.revision.id;return()=>{(p.current.revisionId!==t||p.current.identity!==c)&&x.current?.abort()}},[e.revision.id,c]);function w(e){let t=p.current.onChange;p.current={...p.current,edit:e,identity:l7(e)},t(e)}async function T(){if(x.current!==void 0)return;let t=new AbortController;x.current=t;let n=p.current;C(`captions:load`,!0),b(void 0);try{let r=e.outputs.find(e=>e.selected&&e.state===`ready`&&e.output.role===`subtitle_words`&&e.available);if(!f||d===void 0||u===void 0||r===void 0)throw Error(`Captions can't be edited until the current narration has finished and its subtitle timing is ready.`);let i=await o.fetch(E2(o,e.revision.projectId,e.revision.id,r.recordId),{signal:t.signal});if(!i.ok)throw Error(`The subtitle timing file couldn't be read. Reload the page and try again; if it still fails, use More → make it again in its section on Audio.`);let a=wve.parse(await i.json()),s=0;for(let e of a.words){if(e.start<s||e.end<=e.start||e.end>d)throw Error(`The saved subtitle timing doesn't match the current narration. Use More → make it again in its section on Audio to rebuild it.`);s=e.end}let c=ive(a.words).map(e=>({...e,id:crypto.randomUUID()})),l=p.current;if(!S.current||t.signal.aborted||l.revisionId!==n.revisionId||l.identity!==n.identity||l.edit.content.subtitleCues!==n.edit.content.subtitleCues)return;w({...l.edit,content:{...l.edit.content,subtitleCues:{audioFingerprint:u,cues:c}}})}catch(e){S.current&&!t.signal.aborted&&b(e instanceof Error?e.message:String(e))}finally{x.current===t&&(x.current=void 0),C(`captions:load`,!1)}}let E=t.content.subtitleCues,D=e=>a===void 0||a===e;return(0,h.jsxs)(`div`,{className:`space-y-5`,children:[(0,h.jsxs)(`section`,{"aria-label":`Images`,hidden:!D(`images`),className:`space-y-6`,children:[(0,h.jsx)(cve,{edit:t,saved:e.revision.config.imagePrompts,prompts:s,problem:e=>n.find(t=>t.field===e||t.field===`config.${e}`)?.message,onChange:w}),(0,h.jsx)(mve,{edit:t,problem:e=>n.find(t=>t.field===e||t.field===`config.${e}`)?.message,onChange:w}),(0,h.jsx)(Cve,{edit:t,prompts:s,problem:e=>n.find(t=>t.field===e||t.field===`content.${e}`)?.message,getEdit:()=>p.current.edit,onChange:w,onPending:e=>C(`provided:reference`,e)}),t.config.sources.thumbnail===`from_prompt`||t.config.sources.thumbnail===`prompt_by_llm`?(0,h.jsx)(Z6,{value:t.config.thumbnailCount===3?3:1,onPick:e=>{let{thumbnailCount:t,...n}=p.current.edit.config;w({...p.current.edit,config:e===3?{...n,thumbnailCount:3}:n})}}):null,[`audio`,`thumbnail`].map(e=>t.config.sources[e]===`provide`?(0,h.jsx)(P5,{label:`Replace provided ${e}`,kind:e,onPending:t=>C(`provided:${e}`,t),onReady:t=>{let n=p.current;n.edit.config.sources[e]===`provide`&&w({...n.edit,uploads:[...(n.edit.uploads??[]).filter(t=>t.destination.kind!==`provided`||t.destination.stage!==e),{stagedFileId:t.id,destination:{kind:`provided`,stage:e}}]})}},e):null),(0,h.jsx)(_ve,{getEdit:()=>p.current.edit,view:e,edit:t,onChange:w,onPending:C})]}),(0,h.jsx)(`section`,{"aria-label":`Narration`,hidden:!D(`narration`),className:`space-y-5`,children:t.config.sources.audio===`generate`?(0,h.jsx)(xve,{getEdit:()=>p.current.edit,view:e,edit:t,onChange:w,onPending:C}):null}),y===void 0?null:(0,h.jsx)(`p`,{role:`alert`,className:`text-danger`,children:y}),(0,h.jsxs)(`section`,{"aria-label":`Captions`,hidden:!D(`captions`),className:`space-y-5`,children:[f?null:(0,h.jsx)(`p`,{children:`Captions can be edited once the current narration has finished and its subtitle timing is ready.`}),E===void 0?(0,h.jsx)(L,{type:`button`,disabled:!f||_.has(`captions:load`),onClick:()=>void T(),children:`Edit existing caption cues`}):(0,h.jsxs)(h.Fragment,{children:[E.audioFingerprint===u?null:(0,h.jsx)(`p`,{children:`These caption edits belong to an earlier narration. Review their text and timing against the current narration, then apply your corrections and save the project.`}),f&&d!==void 0?(0,h.jsx)(ave,{cues:E.cues,duration:d,onPending:e=>C(`captions:dirty`,e),onChange:e=>{let t=p.current,n=t.edit.content.subtitleCues;n!==void 0&&w({...t.edit,content:{...t.edit.content,subtitleCues:{...n,cues:e}}})}},`${e.revision.id}:${u}`):null,(0,h.jsx)(L,{type:`button`,onClick:()=>w({...t,content:{...t.content,subtitleCues:void 0}}),children:`Discard caption edits`})]})]})]})}function Eve({edit:e,error:t,onChange:n}){return(0,h.jsx)(`div`,{className:`mb-5`,children:(0,h.jsx)(K2,{value:e.config.language,error:t,onChange:t=>{let{language:r,...i}=e.config;n({...e,config:t===void 0||t===`en`?i:{...i,language:t}})}})})}function Dve({edit:e,saved:t,problem:n,onChange:r}){let{api:i}=R(),a=M(Jb(i)),{config:o}=e,s=e=>e!==void 0&&(a.data?.some(t=>t.id===e)??!0)?e:Vb,c=s(o.channelId),l=a.data?.find(e=>e.id===c),u=o.useBrandKit!==!1,d=c!==s(t.channelId),f=u!==(t.useBrandKit!==!1);return(0,h.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,h.jsx)(Y,{label:`Channel`,tip:`play.channel`,error:n(`channelId`),help:l===void 0?void 0:(0,h.jsxs)(pa,{to:`/channels/$channelId`,params:{channelId:l.id},className:`underline`,children:[`Edit `,l.name]}),children:(0,h.jsxs)(AV,{value:c,onChange:t=>r({...e,config:{...o,channelId:t.target.value}}),children:[a.data===void 0?(0,h.jsx)(`option`,{value:c,children:`Loading channels…`}):null,(a.data??[]).map(e=>(0,h.jsxs)(`option`,{value:e.id,children:[e.name,e.cast>0?` · ${String(e.cast)} in the cast`:``]},e.id))]})}),(0,h.jsxs)(`div`,{className:`flex min-w-0 flex-col justify-end gap-1`,children:[(0,h.jsx)(Eb,{checked:u,label:`Use the channel's brand kit`,tip:`play.brand-kit`,onChange:t=>{let{useBrandKit:n,...i}=o;r({...e,config:t?i:{...i,useBrandKit:!1}})}}),u?null:(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-3`,children:`Its cast is still used.`})]}),a.error===null?null:(0,h.jsxs)(`p`,{className:`m-0 text-small text-danger md:col-span-2`,children:[`The channels couldn't be loaded: `,a.error.message,`. Reload the page to pick a channel.`]}),d||f?(0,h.jsxs)(`p`,{className:`m-0 text-small text-ink-2 md:col-span-2`,children:[d?`Saving moves the project to this channel and takes its cast as it is now. `:``,u?`The brand kit fills the caption font and colours, title style, end screen, intro, outro and document theme where they are at their default or were set by the old kit.`:`What the old brand kit had set is taken off.`]}):null]})}function Ove(e,t,n){let r=e.outputs.find(e=>e.selected&&e.available&&e.output.role===`reference`);if(t.config.reference!==void 0&&r!==void 0)return{image:{kind:`output`,outputId:r.output.id},drawnOn:`the establishing image`};let i=n.flatMap(e=>{let t=e.images.find(e=>e.state===`ready`&&e.sha256!==null);return t?.sha256?[{...e,images:[t.sha256]}]:[]}),a=i8([t.config.title,...Object.values(t.config.values??{})].join(` `),i)[0]??i[0],o=a?.images[0];if(a!==void 0&&o!==void 0)return{image:{kind:`picture`,sha256:o},drawnOn:`${a.name}'s picture`}}function kve({edit:e,view:t,prompts:n,error:r,onChange:i}){let a=(0,m.useRef)(e.config.narrationPrompt);if(e.config.sources.audio!==`generate`)return null;let o=t.revision.config.narrationPrompt,s=t.revision.content.promptTemplates.narration??t.revision.config.rendered.narration,c=o&&s!==void 0&&!n.some(e=>e.kind===`narration`&&e.name===o)?[...n,{id:`saved-narration`,kind:`narration`,name:o,body:s,slots:[],updatedAt:t.revision.createdAt}]:n;return(0,h.jsx)(j6,{value:e.config.narrationPrompt??``,prompts:c,libraryLinks:!1,supported:e.config.audio?.provider===`inworld`&&e.config.audio.model===`inworld-tts-2`,error:r,onChange:t=>{let n=e.config.narrationPrompt||a.current;t===``&&(a.current=e.config.narrationPrompt);let r=c.find(e=>e.kind===`narration`&&e.name===t),o=r===void 0||t===n?e:N5(e,`narration`,r.body);i({...o,config:{...o.config,narrationPrompt:t}})}})}function Ave({edit:e,saved:t=e.config.imagePrompts,prompts:n,entries:r,onChange:i}){let a=(0,m.useId)(),o=[...new Set([...Object.keys(e.config.rendered),...Object.keys(e.content.promptTemplates),...e.config.sources.article===`generate`?[`article`]:[],..._j(e.config)?[`narration`]:[],...bj(e.config)&&e.config.descriptionPrompt?[`description`]:[],...wj(e.config)&&e.config.shorts?.prompt?[`shorts`]:[],...wj(e.config)&&e.config.shorts?.imagePrompt?[`shortsImage`]:[],...[`from_prompt`,`prompt_by_llm`].includes(e.config.sources.thumbnail)?[`thumbnailPrompt`]:[],...Sj(e.config)&&e.config.reference?.source===`prompt`?[`referencePrompt`]:[],...e.config.intro===void 0?[]:[`intro`],...e.config.outro===void 0?[]:[`outro`]])].filter(n=>{let r=u7(n);if(r===void 0)return!0;let i=t[r]?.name;return i===void 0||e.config.imagePrompts.some(e=>e.name===i)}),s=e.config.imagePrompts.filter(e=>!t.some(t=>t.name===e.name)),c=e=>Nve(e,t),l=[...new Set([...Object.keys(e.config.values),...Object.values(e.content.promptTemplates).flatMap(e=>e===null?[]:pq(e).names)])],u=t=>[...pq(e.config.title).names.includes(t)?[`Project title`]:[],...Object.entries(e.content.promptTemplates).flatMap(([e,n])=>n!==null&&pq(n).names.includes(t)?[c(e)]:[])],d=pq(e.config.title).names;return(0,h.jsxs)(`section`,{"aria-label":`Prompt snapshots`,className:`space-y-6`,children:[o.map(o=>{let s=c(o),l=e.content.promptTemplates[o]??null,u=o===`intro`||o===`outro`?r.filter(e=>e.category===o):n.filter(t=>t.kind===(o===`article`?QA(e.config)?`script`:`article`:o===`narration`?`narration`:o===`description`?`description`:o===`shorts`?`shorts`:o===`thumbnailPrompt`?`thumbnail`:`image`));return(0,h.jsxs)(`div`,{className:`min-w-0 space-y-4 border-t border-line pt-6 first:border-t-0 first:pt-0`,children:[(0,h.jsx)(`h3`,{className:`m-0 text-title-3`,children:s}),l===null?(0,h.jsx)(fI,{tone:`info`,title:`Original template unavailable`,actions:(0,h.jsx)(L,{"aria-label":`Use saved wording as template for ${s}`,onClick:()=>i(N5(e,o,e.config.rendered[o]??``)),children:`Use saved wording as template`}),children:`The saved prompt below stays as it is until you choose or write a template.`}):null,(0,h.jsx)(Mve,{label:s,raw:l,library:jve(e,o,u,t),onUse:t=>i(N5(e,o,t))}),(0,h.jsx)(Y,{label:`Use saved template for ${s}`,id:`${a}-library-${o}`,tip:`project.prompts.template`,children:(0,h.jsxs)(AV,{value:``,onChange:t=>{let n=u.find(e=>e.id===t.target.value);if(n===void 0)return;let r=N5(e,o,n.body),a=`category`in n?{...r.config,[n.category]:{name:n.name,mode:n.mode}}:o===`article`?{...r.config,articlePrompt:n.name}:o===`narration`?{...r.config,narrationPrompt:n.name}:o===`description`?{...r.config,descriptionPrompt:n.name}:(o===`shorts`||o===`shortsImage`)&&r.config.shorts!==void 0?{...r.config,shorts:{...r.config.shorts,[o===`shorts`?`prompt`:`imagePrompt`]:n.name}}:o===`thumbnailPrompt`?{...r.config,thumbnailPrompt:n.name}:o===`referencePrompt`&&r.config.reference!==void 0?{...r.config,reference:{...r.config.reference,prompt:n.name}}:r.config;i({...r,config:a})},children:[(0,h.jsx)(`option`,{value:``,children:`Choose a saved template`}),u.map(e=>(0,h.jsx)(`option`,{value:e.id,children:e.name},e.id))]})}),(0,h.jsx)(Y,{label:`Raw prompt for ${s}`,id:`${a}-raw-${o}`,tip:`project.prompts.raw`,children:(0,h.jsx)(kV,{rows:4,value:l??``,onChange:t=>i(N5(e,o,t.target.value))})}),(0,h.jsxs)(`details`,{children:[(0,h.jsx)(`summary`,{className:`text-small text-ink-2`,children:`Saved rendered prompt`}),(0,h.jsx)(`pre`,{className:`m-0 mt-2 whitespace-pre-wrap break-words text-small`,children:e.config.rendered[o]??``})]})]},o)}),s.length===0?null:(0,h.jsxs)(`p`,{className:`m-0 text-small text-ink-2`,children:[s.map(e=>`"${e.name}"`).join(`, `),` `,s.length===1?`uses its`:`use their`,` Library wording. Save, then change it here.`]}),l.length?(0,h.jsxs)(`section`,{"aria-label":`Keywords`,className:`space-y-3 pt-3`,children:[(0,h.jsx)(`h3`,{className:`m-0 text-title-3`,children:`Keywords`}),(0,h.jsx)(L0,{fieldPrefix:`config.values`,keywords:l.map(t=>({name:t,value:e.config.values[t]??``,feeds:u(t),topic:d.includes(t)})),onChange:(t,n)=>i(M5({...e,config:{...e.config,values:{...e.config.values,[t]:n}}}))})]}):null]})}function jve(e,t,n,r){let{config:i}=e,a=u7(t),o=t===`article`?i.articlePrompt:t===`narration`?i.narrationPrompt:t===`description`?i.descriptionPrompt:t===`shorts`?i.shorts?.prompt:t===`shortsImage`?i.shorts?.imagePrompt:t===`thumbnailPrompt`?i.thumbnailPrompt:t===`referencePrompt`?i.reference?.prompt:a===void 0?void 0:r[a]?.name;if(o!==void 0&&o!==``)return n.find(e=>!(`category`in e)&&e.name===o)}function Mve({label:e,raw:t,library:n,onUse:r}){return n===void 0||t===null||n.body===t?null:(0,h.jsx)(fI,{tone:`info`,title:`The Library's "${n.name}" has changed since this project copied it`,actions:(0,h.jsx)(L,{"aria-label":`Use the Library version for ${e}`,onClick:()=>{r(n.body)},children:`Use the Library version`}),children:`The project still uses its own copy below.`})}function u7(e){let t=/^imagePrompts\.(\d+)$/.exec(e);return t?.[1]===void 0?void 0:Number(t[1])}function Nve(e,t){if(e===`article`)return`Article`;if(e===`narration`)return`Narration Preparation`;if(e===`description`)return`YouTube description`;if(e===`shorts`)return`Shorts`;if(e===`shortsImage`)return`Shorts image style`;if(e===`thumbnailPrompt`)return`Thumbnail`;if(e===`referencePrompt`)return`Establishing image`;if(e===`intro`)return`Intro`;if(e===`outro`)return`Outro`;let n=u7(e);if(n!==void 0){let e=t[n]?.name;return e===void 0||e===``?`Image prompt ${String(n+1)}`:`Image prompt "${e}"`}return e.replace(/[._-]/g,` `).replace(/([a-z])([A-Z])/g,`$1 $2`)}function Pve(e,t,n){let{api:r}=R(),[i,a]=(0,m.useState)({busy:!1}),{config:o}=t,s=o.audio,c=async()=>{if(s!==void 0){a({busy:!0});try{let i=await Ps(r,e),{sharedGlossary:c,...l}=o;n({...t,config:{...l,audio:{...s,shareGlossary:!0},...i.entries.length===0?{}:{sharedGlossary:i.entries}}}),a({busy:!1,projects:i.projects})}catch(e){a({busy:!1,error:e instanceof Error?e.message:String(e)})}}},l=()=>{if(s===void 0)return;let{sharedGlossary:e,...r}=o;n({...t,config:{...r,audio:{...s,shareGlossary:!1}}})},u=o.sharedGlossary?.length??0,d=s?.shareGlossary===!0?(0,h.jsxs)(`p`,{className:`flex flex-wrap items-center gap-2 text-label text-ink-2`,children:[i.error===void 0?u===0?`No pronunciations from other projects are copied yet.`:`${String(u)} ${u===1?`term`:`terms`} copied from ${i.projects===void 0?`your other projects`:`${String(i.projects)} other ${i.projects===1?`project`:`projects`}`}.`:`Couldn't read your other projects' pronunciations: ${i.error}`,(0,h.jsx)(L,{type:`button`,variant:`quiet`,disabled:i.busy,onClick:()=>void c(),children:i.busy?`Copying…`:`Update from other projects`}),(0,h.jsx)(B,{id:`project.edit.update-glossary`})]}):void 0;return{value:s?.shareGlossary===!0,onChange:e=>{e?c():l()},note:d}}function Fve(e,t){let{api:n}=R(),[r,i]=(0,m.useState)({busy:!1}),{config:a}=e,o=a.audio,s=async()=>{if(o!==void 0){i({busy:!0});try{let{aliases:r}=await Fs(n),{narrationAliases:s,...c}=a;t({...e,config:{...c,audio:{...o,useNarrationAliases:!0},...r.length===0?{}:{narrationAliases:r}}}),i({busy:!1})}catch(e){i({busy:!1,error:e instanceof Error?e.message:String(e)})}}},c=a.narrationAliases?.length??0;return{value:o?.useNarrationAliases===!0,onChange:n=>{if(o!==void 0){if(n)s();else{let{narrationAliases:n,...r}=a;t({...e,config:{...r,audio:{...o,useNarrationAliases:!1}}})}}},note:o?.useNarrationAliases===!0?(0,h.jsxs)(`p`,{className:`flex flex-wrap items-center gap-2 text-label text-ink-2`,children:[r.error===void 0?c===0?`No aliases are copied yet. Add some in Library → Aliases.`:`${String(c)} ${c===1?`alias`:`aliases`} copied from Library → Aliases.`:`Couldn't read Library → Aliases: ${r.error} Try Update from Library again.`,(0,h.jsx)(L,{type:`button`,variant:`quiet`,disabled:r.busy,onClick:()=>void s(),children:r.busy?`Copying…`:`Update from Library`}),(0,h.jsx)(B,{id:`project.edit.update-aliases`})]}):void 0}}function Ive({projectId:e,edit:t,providers:n,voices:r,onChange:i}){let{config:a}=t,o=a.llm??{provider:``,model:``},s=a.audio??{provider:``,model:``,voice:``},c=Pve(e,t,i),l=Fve(t,i),{api:u}=R(),d=M(Yb(u,a.channelId??`00000000-0000-4000-8000-000000000001`)),f=a.images??{provider:``,model:``},p=_j(a)||a.sources.audio===`generate`&&a.audio?.describeFigures===!0||a.sources.research===`generate`||a.sources.article===`generate`||a.sources.thumbnail===`prompt_by_llm`||ZA(a)&&a.voices?.source===`attribute`||a.sources.audio===`generate`&&(a.intro?.mode===`llm`||a.outro?.mode===`llm`),m=a.sources.images===`generate`||a.sources.thumbnail===`from_prompt`||a.sources.thumbnail===`prompt_by_llm`,g=r.filter(e=>e.provider===s.provider).map(e=>({value:e.voiceId,label:e.name}));return(0,h.jsxs)(`section`,{"aria-label":`Generation providers`,className:`grid min-w-0 gap-3 sm:grid-cols-2`,children:[p?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(HV,{label:`Text provider`,tip:`play.llm.provider`,family:`llm`,providers:n,value:o.provider,problem:void 0,onPick:e=>i({...t,config:{...a,llm:{provider:e,model:``}}})}),(0,h.jsx)(UV,{label:`Text model`,tip:`play.llm.model`,provider:o.provider,value:o.model,problem:void 0,onPick:e=>i({...t,config:{...a,llm:{...o,model:e}}})}),(0,h.jsx)(F6,{choice:o,onChange:e=>i({...t,config:{...a,llm:e}})})]}):null,a.sources.audio===`generate`?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(HV,{label:`Narration provider`,tip:`play.tts.provider`,family:`tts`,providers:n,value:s.provider,problem:void 0,onPick:e=>i({...t,config:{...a,audio:{...s,provider:e,model:``,voice:``}}})}),(0,h.jsx)(UV,{label:`Narration model`,tip:`play.tts.model`,provider:s.provider,value:s.model,problem:void 0,onPick:e=>i({...t,config:{...a,audio:{...s,model:e}}})}),(0,h.jsx)(zV,{label:`Narration voice`,tip:`play.voice`,value:s.voice,problem:void 0,placeholder:`Choose a saved voice`,options:s.voice!==``&&!g.some(e=>e.value===s.voice)?[{value:s.voice,label:`${s.voice} (saved voice)`},...g]:g,onPick:e=>i({...t,config:{...a,audio:{...s,voice:e}}})}),(0,h.jsx)(c6,{value:a.chunking??{mode:`whole`},onPick:e=>i({...t,config:{...a,chunking:e}})}),(0,h.jsx)(M6,{shared:c,value:s.usePronunciationGlossary,supported:kj({sources:a.sources,audio:{...s,usePronunciationGlossary:!0}}),onChange:e=>i({...t,config:{...a,audio:{...s,usePronunciationGlossary:e}}})}),(0,h.jsx)(A6,{...l}),(0,h.jsx)(O6,{tip:`project.edit.describe-figures`,value:s.describeFigures,skipCode:s.skipCode,onChange:({describeFigures:e,skipCode:n})=>{let{describeFigures:r,skipCode:o,...c}=s;i({...t,config:{...a,audio:{...c,...e?{describeFigures:e}:{},...e&&n?{skipCode:n}:{}}}})}}),(0,h.jsxs)(`section`,{"aria-label":`Speakers`,className:`col-span-full border-t border-line pt-3`,children:[(0,h.jsx)(`h3`,{className:`mb-2 text-small font-semibold`,children:`Speakers`}),(0,h.jsx)(D6,{value:a.voices,cast:d.data?.cast??[],language:a.language,providers:n,voices:r,script:t.content.articleMarkdown??void 0,onChange:e=>{let{voices:n,...r}=a;i({...t,config:e===void 0?r:{...r,voices:e}})}})]})]}):null,m?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(HV,{label:`Image provider`,tip:`play.images.provider`,family:`image`,providers:n,value:f.provider,problem:void 0,onPick:e=>i({...t,config:{...a,images:{provider:e,model:``}}})}),(0,h.jsx)(UV,{label:`Image model`,tip:`play.images.model`,provider:f.provider,value:f.model,problem:void 0,onPick:e=>i({...t,config:{...a,images:{...f,model:e}}})}),(0,h.jsx)(F6,{field:`images.thinking`,label:`Effort`,tip:`play.images.effort`,choice:f,onChange:e=>i({...t,config:{...a,images:e}})})]}):null]})}function Lve({edit:e,providers:t,prompts:n,problem:r,onChange:i}){let{config:a}=e,o=a.reviews===void 0?KV:Bk(a.reviews),[s,c]=(0,m.useState)(o),l=a.shorts?.enabled===!0&&a.sources.audio!==`off`,u=e=>Hk({sources:a.sources,shorts:l?{enabled:!0}:void 0},e),d=Vk(s,u).retriesProblem;return(0,h.jsx)(qV,{value:s,providers:t,prompts:n,makes:u,problem:e=>e===`reviews.retries`&&d!==void 0?d:r(e),onChange:t=>{c(t);let{settings:r}=Vk(t,u),o={...e.content.promptTemplates},s={...a.rendered};for(let e of Mk){let t=zk(e),i=r?.stages[e]?.prompt??``,c=n.find(e=>e.kind===`review`&&e.name===i);if(i===``){let{[t]:e,...n}=o,{[t]:r,...i}=s;o=n,s=i}else c!==void 0&&i!==(a.reviews?.stages[e]?.prompt??``)&&(o={...o,[t]:c.body})}let{reviews:l,...d}=a;i(M5({...e,config:{...d,rendered:s,...r===void 0?{}:{reviews:r}},content:{...e.content,promptTemplates:o}}))}})}function Rve({edit:e,view:t,prompts:n,problem:r,onChange:i}){let a=t.revision.config.descriptionPrompt,o=t.revision.content.promptTemplates.description??t.revision.config.rendered.description,s=a&&o!==void 0&&!n.some(e=>e.kind===`description`&&e.name===a)?[...n,{id:`saved-description`,kind:`description`,name:a,body:o,slots:[],updatedAt:t.revision.createdAt}]:n,c=t.outputs.some(e=>e.selected&&e.workKey===d7&&e.state===`ready`),l=e.regenerate?.includes(d7)===!0;return(0,h.jsxs)(`div`,{className:`space-y-2`,children:[(0,h.jsx)(R6,{enabled:e.config.youtubeDescription===!0,prompt:e.config.descriptionPrompt??``,prompts:s,narrated:e.config.sources.audio!==`off`,problem:r,onChange:({youtubeDescription:t,descriptionPrompt:n})=>{let r=s.find(e=>e.kind===`description`&&e.name===n),a=n===(e.config.descriptionPrompt??``)?e:r===void 0?zve(e):N5(e,`description`,r.body),{descriptionPrompt:o,...c}=a.config;i({...a,config:{...c,youtubeDescription:t,...n===``?{}:{descriptionPrompt:n}}})}}),c&&e.config.youtubeDescription===!0?l?(0,h.jsxs)(`p`,{className:`flex flex-wrap items-center gap-2 text-small text-accent-ink`,children:[`The YouTube description will be written again after you save and press Remake.`,(0,h.jsx)(L,{type:`button`,variant:`quiet`,onClick:()=>{i({...e,regenerate:(e.regenerate??[]).filter(e=>e!==d7)})},children:`Keep the current description`})]}):(0,h.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,h.jsx)(L,{type:`button`,onClick:()=>{i({...e,regenerate:[...new Set([...e.regenerate??[],d7])]})},children:`Write the description again after review`}),(0,h.jsx)(B,{id:`project.edit.rewrite-description`})]}):null]})}var d7=`youtube:description`;function zve(e){let{description:t,...n}=e.content.promptTemplates,{description:r,...i}=e.config.rendered;return M5({config:{...e.config,rendered:i},content:{...e.content,promptTemplates:n}})}var Bve={research:`Research source`,article:`Article source`,audio:`Audio source`,images:`Images source`,thumbnail:`Thumbnail source`,video:`Video source`,document:`Document source`},Vve={research:`play.source.research`,article:`play.source.article`,audio:`play.source.audio`,images:`play.source.images`,thumbnail:`play.source.thumbnail`,video:`play.source.video`,document:`play.source.document`};function f7({title:e,children:t,columns:n=!0}){return(0,h.jsxs)(`div`,{className:`space-y-4`,children:[(0,h.jsx)(`h3`,{className:`m-0 text-title-3`,children:e}),(0,h.jsx)(`div`,{className:I(`grid min-w-0 gap-4`,n&&`md:grid-cols-2`),children:t})]})}function Hve(e){let{view:t,edit:n,onChange:r,onPending:i,fields:a}=e,o=(0,m.useId)(),[s,c]=(0,m.useState)(e.focus?.section??`inputs`);(0,m.useEffect)(()=>{e.focus!==void 0&&c(e.focus.section)},[e.focus]);let[l,u]=(0,m.useState)({font:!1,content:!1,music:!1});(0,m.useEffect)(()=>{i(l.font||l.content||l.music)},[i,l]);let d=(0,m.useCallback)(e=>{u(t=>t.font===e?t:{...t,font:e})},[]),f=(0,m.useCallback)(e=>{u(t=>t.content===e?t:{...t,content:e})},[]),p=(0,m.useCallback)(e=>{u(t=>t.music===e?t:{...t,music:e})},[]),{api:g}=R(),_=M(Zy(g)),v=M(Qy(g)),y=M($y(g)),b=M(eb(g)),{config:x}=n,S=Ove(t,n,M(Yb(g,x.channelId??`00000000-0000-4000-8000-000000000001`)).data?.cast??[]),C=S?.image.kind===`output`?t.outputs.find(e=>e.selected&&e.available&&S.image.kind===`output`&&e.output.id===S.image.outputId):void 0,w=C===void 0?void 0:E2(g,t.revision.projectId,t.revision.id,C.recordId),T=e=>a.find(t=>t.field===e||t.field===`config.${e}`||t.field===`edit.config.${e}`)?.message,E=z6({value:x.videoEdit,narrated:x.sources.audio!==`off`,imageProvider:x.images?.provider??``,problem:T,language:x.language,onChange:e=>r({...n,config:{...x,videoEdit:e}})}),D=[{id:`inputs`,label:`Inputs`},{id:`article`,label:`Article`,...n.content.articleEdited?{badge:`edited`}:{}},{id:`providers`,label:`Providers`},{id:`prompts`,label:`Prompts`},{id:`reviews`,label:`Reviews`,...x.reviews===void 0?{}:{badge:`on`}},...x.sources.audio!==`off`||x.shorts?.enabled===!0?[{id:`shorts`,label:`Shorts`,...x.shorts?.enabled?{badge:`on`}:{}}]:[],{id:`subtitles`,label:`Subtitles`},{id:`images`,label:`Images`,badge:String(n.content.imageOrder.length)},...x.sources.audio===`generate`?[{id:`narration`,label:`Narration`}]:[],{id:`captions`,label:`Captions`,...n.content.subtitleCues===void 0?{}:{badge:String(n.content.subtitleCues.cues.length)}}],O=D.some(e=>e.id===s)?s:`inputs`,k=e=>I(`min-w-0 space-y-6`,O===e?void 0:`hidden`),ee=e=>Number.isFinite(e)?e:``,te=x.sources.video!==`off`;return(0,h.jsxs)(`div`,{className:`grid min-w-0 gap-8 md:grid-cols-[180px_minmax(0,1fr)]`,children:[(0,h.jsx)(`nav`,{"aria-label":`Edit sections`,className:`min-w-0 md:sticky md:top-16 md:self-start`,children:(0,h.jsx)(`ul`,{className:`m-0 flex list-none gap-1 overflow-x-auto p-0 [scrollbar-width:none] md:flex-col`,children:D.map(e=>(0,h.jsx)(`li`,{className:`shrink-0`,children:(0,h.jsx)(m8,{current:e.id===O,onClick:()=>c(e.id),meta:e.badge,className:`whitespace-nowrap`,children:e.label})},e.id))})}),(0,h.jsxs)(`div`,{className:`min-w-0 space-y-6`,children:[Object.entries({providers:_.error,voices:v.error,prompts:y.error,entries:b.error}).flatMap(([e,t])=>t===null?[]:[(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-small text-danger`,children:t.message},e)]),a.length===0?null:(0,h.jsx)(`ul`,{role:`alert`,className:`m-0 space-y-1 pl-5 text-small text-danger`,children:a.map(e=>(0,h.jsxs)(`li`,{children:[e.field,`: `,e.message]},`${e.field}-${e.message}`))}),(0,h.jsxs)(`section`,{"aria-label":`Inputs`,hidden:O!==`inputs`,className:k(`inputs`),children:[(0,h.jsxs)(f7,{title:`Project`,children:[(0,h.jsx)(Y,{label:`Project title`,error:T(`title`),className:`md:col-span-2`,children:(0,h.jsx)(OV,{value:x.title,maxLength:200,onChange:e=>r({...n,config:{...x,title:e.target.value}})})}),(0,h.jsx)(`div`,{className:`md:col-span-2`,children:(0,h.jsx)(r8,{value:x.format,onPick:e=>r({...n,config:{...x,format:e}})})})]}),(0,h.jsx)(Nq,{}),(0,h.jsx)(f7,{title:`Channel`,columns:!1,children:(0,h.jsx)(Dve,{edit:n,saved:t.revision.config,problem:T,onChange:r})}),(0,h.jsx)(Nq,{}),(0,h.jsxs)(f7,{title:`Stages`,children:[MS.map(e=>(0,h.jsx)(Y,{label:Bve[e],tip:Vve[e],error:T(`sources.${e}`),children:(0,h.jsx)(AV,{value:FS(x.sources,e),onChange:i=>{let a=VN(e).find(e=>e.value===i.target.value);if(a===void 0)return;let o=h_e(n,e,a.value);r(e===`article`&&a.value===`provide`&&!n.content.articleEdited?{...o,content:{...o.content,articleMarkdown:t.articleMarkdown??n.content.articleMarkdown}}:o)},children:VN(e).map(t=>(0,h.jsx)(`option`,{value:t.value,disabled:e===`video`&&t.value===`generate`&&x.sources.images===`off`,children:t.label},t.value))})},e)),x.sources.images===`off`?(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2 md:col-span-2`,children:`Images are Off. Video is also Off in these changes.`}):null,(0,h.jsx)(Y,{label:`Document theme`,id:`${o}-document-theme`,tip:`play.document-theme`,children:(0,h.jsx)(o6,{id:`${o}-document-theme`,disabled:FS(x.sources,`document`)===`off`,value:x.document,onChange:e=>{r({...n,config:{...x,document:e}})}})})]}),(0,h.jsx)(Nq,{}),(0,h.jsxs)(f7,{title:`Timing`,children:[(0,h.jsx)(Y,{label:`Silence gap (seconds)`,tip:`play.silence-gap`,error:T(`silenceGapSeconds`),children:(0,h.jsx)(OV,{type:`number`,min:0,max:30,step:.1,value:ee(x.silenceGapSeconds),onChange:e=>r({...n,config:{...x,silenceGapSeconds:Number(e.target.value)}})})}),x.sources.audio===`off`?null:(0,h.jsx)(Y,{label:`Silence at start and end (seconds)`,tip:`play.edge-silence`,error:T(`edgeSilenceSeconds`),children:(0,h.jsx)(OV,{type:`number`,min:0,max:30,step:.5,value:ee(x.edgeSilenceSeconds),onChange:e=>r({...n,config:{...x,edgeSilenceSeconds:Number(e.target.value)}})})}),te?(0,h.jsx)(Y,{label:`Seconds per image`,tip:`play.image-seconds`,error:T(`imageSeconds`),children:(0,h.jsx)(OV,{type:`number`,min:1,max:600,step:1,value:ee(x.imageSeconds),onChange:e=>r({...n,config:{...x,imageSeconds:Number(e.target.value)}})})}):null,te?(0,h.jsx)(Y,{label:`Zoom (%)`,tip:`play.zoom`,error:T(`zoomPercent`),children:(0,h.jsx)(OV,{type:`number`,min:0,max:50,step:.5,value:ee(x.zoomPercent),onChange:e=>r({...n,config:{...x,zoomPercent:Number(e.target.value)}})})}):null,te?(0,h.jsx)(Y,{label:`Motion`,tip:`play.motion`,children:(0,h.jsx)(AV,{value:x.motionStyle,onChange:e=>r({...n,config:{...x,motionStyle:e.target.value}}),children:IS.map(e=>(0,h.jsx)(`option`,{value:e,children:ij[e]},e))})}):null]}),te?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(Nq,{}),(0,h.jsxs)(f7,{title:`Cuts and look`,columns:!1,children:[E.cuts,E.look,x.sources.audio===`generate`&&x.audio?.describeFigures===!0?(0,h.jsx)(k6,{tip:`project.edit.show-figures`,value:x.showFigures,onChange:e=>{let{showFigures:t,...i}=x;r({...n,config:e?{...i,showFigures:!0}:i})}}):null]}),x.sources.audio===`off`?null:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(Nq,{}),(0,h.jsx)(f7,{title:`Ambient sound`,columns:!1,children:(0,h.jsx)(uve,{edit:n,problem:T,onChange:r})})]})]}):null,x.sources.audio===`off`?null:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(Nq,{}),(0,h.jsxs)(f7,{title:`Pauses and volume`,columns:!1,children:[(0,h.jsx)(fve,{edit:n,problem:T,onChange:r}),(0,h.jsx)(dve,{edit:n,problem:T,onChange:r})]})]}),(0,h.jsx)(Nq,{}),(0,h.jsx)(f7,{title:`Intro and outro`,children:[`intro`,`outro`].map(e=>(0,h.jsx)(Y,{label:e===`intro`?`Intro`:`Outro`,tip:e===`intro`?`play.intro`:`play.outro`,children:(0,h.jsxs)(AV,{value:x[e]?.name??``,onChange:t=>{let i=b.data?.entries.find(n=>n.category===e&&n.name===t.target.value),a={...x};i===void 0?delete a[e]:a[e]={name:i.name,mode:i.mode},r(M5({...n,config:a,content:i===void 0?n.content:{...n.content,promptTemplates:{...n.content.promptTemplates,[e]:i.body}}}))},children:[(0,h.jsx)(`option`,{value:``,children:`Off`}),x[e]!==void 0&&!b.data?.entries.some(t=>t.category===e&&t.name===x[e]?.name)?(0,h.jsxs)(`option`,{value:x[e]?.name,children:[x[e]?.name,` (saved entry)`]}):null,b.data?.entries.filter(t=>t.category===e).map(e=>(0,h.jsx)(`option`,{value:e.name,children:e.name},e.id))]})},e))}),x.sources.research===`provide`?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(Nq,{}),(0,h.jsx)(f7,{title:`Research`,columns:!1,children:(0,h.jsx)(Y,{label:`Research notes`,tip:`play.provided.research`,error:T(`provided.research`),children:(0,h.jsx)(kV,{rows:6,value:x.provided.research??``,onChange:e=>r({...n,config:{...x,provided:{...x.provided,research:e.target.value}}})})})})]}):null]}),(0,h.jsxs)(`section`,{"aria-label":`Article`,hidden:O!==`article`,className:k(`article`),children:[(0,h.jsx)(Y,{label:`Article text`,tip:`project.edit.article-text`,error:T(`content.articleMarkdown`)??T(`provided.article`),help:n.content.articleEdited?`Your edited article is kept when other settings change. Regenerating it replaces it after the rebuild review.`:void 0,children:(0,h.jsx)(kV,{rows:12,maxLength:5e5,value:(n.content.articleEdited?n.content.articleMarkdown:t.articleMarkdown)??n.content.articleMarkdown??x.provided.article??``,onChange:e=>r({...n,content:{...n.content,articleMarkdown:e.target.value,articleEdited:!0}})})}),x.sources.article===`generate`?(0,h.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,h.jsx)(L,{onClick:()=>r({...n,regenerate:[...new Set([...n.regenerate??[],`article:body`])]}),children:`Regenerate article after review`}),(0,h.jsx)(B,{id:`project.edit.regenerate-article`})]}):null]}),(0,h.jsxs)(`section`,{"aria-label":`Providers`,hidden:O!==`providers`,className:k(`providers`),children:[(0,h.jsx)(Eve,{edit:n,error:T(`language`),onChange:r}),(0,h.jsx)(Ive,{projectId:t.revision.projectId,edit:n,providers:_.data?.providers??[],voices:v.data?.voices??[],onChange:r}),(0,h.jsx)(kve,{edit:n,view:t,prompts:y.data?.prompts??[],error:T(`narrationPrompt`),onChange:r})]}),(0,h.jsxs)(`section`,{"aria-label":`Prompts`,hidden:O!==`prompts`,className:k(`prompts`),children:[(0,h.jsx)(Rve,{edit:n,view:t,prompts:y.data?.prompts??[],problem:T,onChange:r}),(0,h.jsx)(Ave,{edit:n,saved:t.revision.config.imagePrompts,prompts:y.data?.prompts??[],entries:b.data?.entries??[],onChange:r})]}),(0,h.jsx)(`section`,{"aria-label":`Reviews`,hidden:O!==`reviews`,className:k(`reviews`),children:(0,h.jsx)(Lve,{edit:n,providers:_.data?.providers??[],prompts:y.data?.prompts??[],problem:T,onChange:r})}),(0,h.jsx)(`section`,{"aria-label":`Shorts`,hidden:O!==`shorts`,className:k(`shorts`),children:(0,h.jsx)(v_e,{edit:n,view:t,prompts:y.data?.prompts??[],problem:T,onChange:r,onPending:p})}),(0,h.jsxs)(`section`,{"aria-label":`Subtitles`,hidden:O!==`subtitles`,className:k(`subtitles`),children:[(0,h.jsx)(`div`,{"data-tour":`project-subtitles`,children:(0,h.jsx)(n8,{value:x.subtitles??xM,format:x.format,audioEnabled:x.sources.audio!==`off`,videoEnabled:te,onChange:e=>r({...n,config:{...x,subtitles:PN(e,x.sources)}}),onUploading:d,problem:T})}),O!==`subtitles`||!te?null:(0,h.jsx)(U6,{drawnOn:S?.drawnOn,poster:w,settings:{format:x.format,subtitles:{mode:(x.subtitles??xM).mode,fontId:(x.subtitles??xM).fontId,fontSize:(x.subtitles??xM).fontSize,position:(x.subtitles??xM).position??`bottom`},videoEdit:x.videoEdit,image:S?.image}})]}),e.renderContent?.({view:t,edit:n,fields:a,onChange:r,onPending:f,section:O})]})]})}var p7={notes:`Research notes`,article_md:`Article (Markdown)`,article_txt:`Article text`,narration_txt:`Clean Narration`,tts_script:`TTS Script`,sources:`Research sources`,glossary:`Glossary`,audio_body:`Narration`,audio_intro:`Intro narration`,audio_outro:`Outro narration`,audio_export:`Audio export`,image:`Image`,thumbnail:`Thumbnail`,video:`Video`,render_params:`Export settings`,subtitles_srt:`Subtitles (SRT)`,subtitles_vtt:`Subtitles (VTT)`,subtitle_words:`Subtitle timing`,subtitle_ass:`Styled subtitles`,subtitle_font:`Subtitle font`,instructions:`Generation instructions`,document_pdf:`Document (PDF)`,youtube_description:`YouTube description`,youtube_tags:`YouTube tags`,shorts:`Shorts list`,short_image:`Short image`,short_video:`Short`,animated_image:`Animated image`,figure_card:`On-screen card`,reference:`Establishing image (reference)`,script_md:`Script (speaker split)`,audio_mp3:`Audio (MP3 with chapters)`,audio_m4b:`Audiobook (M4B with chapters)`,audio_levelled:`Levelled narration`};function m7(e){return(e.role===`narration_txt`||e.role===`tts_script`)&&e.meta.segment?`${e.meta.segment===`body`?`Body`:e.meta.segment===`intro`?`Intro`:`Outro`} ${p7[e.role]}`:e.role===`short_video`&&typeof e.meta.short==`number`?`Short ${String(e.meta.short)}`:e.role===`short_image`&&typeof e.meta.short==`number`?`Short ${String(e.meta.short)} image ${String(e.meta.index??1)}`:e.role===`figure_card`&&typeof e.meta.index==`number`?`On-screen card ${String(e.meta.index)}`:e.role===`animated_image`&&typeof e.meta.index==`number`?`Animated image ${String(e.meta.index)}`:e.role===`image`&&typeof e.meta.index==`number`?`Image ${e.meta.index}`:p7[e.role]}function Uve(e){if(e.startsWith(`image:`))return`Image`;if(e.startsWith(`animate:`))return p7.animated_image;if(/^shorts:\d+:render$/.test(e))return p7.short_video;if(/^shorts:\d+:image:\d+$/.test(e))return p7.short_image;if(e===`document:pdf`)return p7.document_pdf;let t=e.split(`:`).at(-1);return Object.entries(p7).find(([e])=>e===t)?.[1]??`Saved output`}function Wve({preview:e,pending:t,feedback:n,onStart:r,onCancel:i}){let a=Xve(e),[o,s]=(0,m.useState)([]),[c,l]=(0,m.useState)(!1),u=(0,m.useId)(),d=e.work.filter(e=>e.disposition===`blocked`),f=e.providedReuseRequired.filter(e=>!o.includes(e)),p=e.work.filter(e=>e.disposition===`generate`||e.disposition===`local`||e.disposition===`review`).length,g=p===1?`Remake 1 output`:`Remake ${String(p)} outputs`,_=[...d.length===0?[]:[`${d.length===1?`1 item is`:`${d.length} items are`} unavailable (reasons above)`],...f.map(e=>`tick “Keep the provided content for ${a(e)}”`),...e.costs.unknown===0||c?[]:[`tick “I understand that ${e.costs.unknown} cost estimates are unknown”`]],v=_.length===0,y=Kve.map(t=>({disposition:t,count:e.work.filter(e=>e.disposition===t).length})).filter(e=>e.count>0),b=e.costs.rows.some(e=>e.onPlan===!0),x=e.costs.apiLow,S=e.costs.apiHigh;return(0,h.jsxs)(`section`,{"aria-label":`Review affected rebuild`,className:`flex flex-col gap-5`,children:[(0,h.jsxs)(`dl`,{className:`m-0 grid grid-cols-2 gap-x-6 gap-y-3 sm:grid-cols-3`,children:[y.map(e=>(0,h.jsxs)(`div`,{className:`flex flex-col`,children:[(0,h.jsx)(`dt`,{className:`order-2 text-small text-ink-2`,children:y7[e.disposition]}),(0,h.jsx)(`dd`,{className:`order-1 m-0 font-condensed text-title-2 tabular-nums`,children:e.count})]},e.disposition)),(0,h.jsxs)(`div`,{className:`flex flex-col`,children:[(0,h.jsx)(`dt`,{className:`order-2 text-small text-ink-2`,children:e.costs.unknown>0?`known cost`:`cost`}),(0,h.jsx)(`dd`,{className:`order-1 m-0 font-condensed text-title-2 tabular-nums`,children:v7(e.costs.low,e.costs.high)})]})]}),b?(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:`CLI work: $0 on your plan${x===void 0||S===void 0?``:` · ~${v7(x,S)} via API`}.`}):null,d.length===0?null:(0,h.jsx)(fI,{tone:`danger`,title:`${d.length===1?`1 item can’t`:`${d.length} items can’t`} run, so this rebuild can’t start`,children:(0,h.jsx)(`ul`,{className:`m-0 flex flex-col gap-1 pl-5`,children:qve(d,a).map(e=>(0,h.jsxs)(`li`,{children:[(0,h.jsxs)(`span`,{className:`font-semibold`,children:[e.what,`:`]}),` `,e.reason]},e.reason))})}),e.wholeRequestNotice===null?null:(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:e.wholeRequestNotice}),e.warnings.map(e=>(0,h.jsx)(`p`,{className:`m-0 text-small text-waiting`,children:e},e)),(0,h.jsxs)(`div`,{className:`flex flex-col divide-y divide-line border-y border-line`,children:[e.review?.inputChanges.length?(0,h.jsx)(h7,{summary:`Changed inputs (${String(e.review.inputChanges.length)})`,children:(0,h.jsx)(`dl`,{className:`m-0 flex flex-col gap-3`,children:e.review.inputChanges.map(e=>(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`dt`,{className:`font-semibold`,children:e.label}),(0,h.jsxs)(`dd`,{className:`m-0 grid gap-2 sm:grid-cols-2`,children:[(0,h.jsx)(g7,{label:`Before`,text:e.before}),(0,h.jsx)(g7,{label:`After`,text:e.after})]})]},e.label))})}):null,(0,h.jsxs)(h7,{summary:`Work items (${e.work.length}): ${y.map(e=>`${e.count} ${y7[e.disposition]}`).join(`, `)||`none`}`,children:[e.changedInputs.length===0?null:(0,h.jsx)(`ul`,{className:`m-0 mb-3 flex flex-col gap-1 pl-5`,children:e.changedInputs.map(e=>(0,h.jsxs)(`li`,{children:[a(e.path),`:`,` `,e.after===null?`Removed`:e.before===null?`New output`:`Inputs changed`]},e.path))}),(0,h.jsx)(`ul`,{className:`m-0 flex flex-col gap-2 pl-5`,children:e.work.map(t=>(0,h.jsxs)(`li`,{children:[a(t.key),`: `,y7[t.disposition],`. `,t.reason,t.inflight?` An already submitted request may still be billed.`:``,e.review?.requests.filter(e=>e.key===t.key).map(e=>(0,h.jsxs)(`div`,{children:[e.settings===null?null:(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:e.settings}),e.text===null?null:(0,h.jsxs)(`details`,{children:[(0,h.jsx)(`summary`,{className:`cursor-pointer text-small`,children:`View request text`}),(0,h.jsx)(`pre`,{className:`m-0 max-h-56 overflow-auto whitespace-pre-wrap break-words font-mono text-small`,children:e.text})]})]},e.key))]},t.key))}),(0,h.jsxs)(`p`,{className:`m-0 mt-3 text-small text-ink-2`,children:[`Retained outputs:`,` `,e.retained.map(e=>Uve(e.slot)).join(`, `)||`None`]})]}),e.costs.rows.length===0?null:(0,h.jsx)(h7,{summary:`Cost by step`,children:(0,h.jsx)(`ul`,{className:`m-0 flex flex-col gap-1 pl-5`,children:e.costs.rows.map(e=>(0,h.jsxs)(`li`,{children:[a(e.stage),`: `,Gve(e),`. `,e.detail]},`${e.stage}-${e.detail}`))})})]}),n,(0,h.jsxs)(`div`,{className:`sticky bottom-[-16px] -mx-4 flex flex-col gap-3 border-t border-line bg-raised px-4 py-3`,children:[e.providedReuseRequired.length===0&&e.costs.unknown===0?null:(0,h.jsxs)(`div`,{className:`flex flex-col gap-2 text-small`,children:[e.providedReuseRequired.map(e=>(0,h.jsxs)(`div`,{className:`flex items-start gap-1`,...Tb,children:[(0,h.jsxs)(`label`,{className:`flex items-start gap-2`,children:[(0,h.jsx)(`input`,{type:`checkbox`,className:`mt-1`,disabled:t,checked:o.includes(e),onChange:t=>s(t.target.checked?[...o,e]:o.filter(t=>t!==e))}),(0,h.jsxs)(`span`,{children:[`Keep the provided content for `,a(e)]})]}),(0,h.jsx)(B,{id:`project.rebuild.keep-provided`,className:`-my-1`})]},e)),e.costs.unknown===0?null:(0,h.jsxs)(`div`,{className:`flex items-start gap-1`,...Tb,children:[(0,h.jsxs)(`label`,{className:`flex items-start gap-2`,children:[(0,h.jsx)(`input`,{type:`checkbox`,className:`mt-1`,disabled:t,checked:c,onChange:e=>l(e.target.checked)}),(0,h.jsxs)(`span`,{children:[`I understand that `,e.costs.unknown,` cost estimates are unknown.`]})]}),(0,h.jsx)(B,{id:`project.rebuild.unknown-costs`,className:`-my-1`})]})]}),(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,h.jsx)(L,{variant:`primary`,disabled:t||!v,"aria-describedby":v?void 0:u,onClick:()=>r({acknowledgeUnknownCosts:c,confirmedProvidedWorkKeys:o}),children:t?`Starting the remake…`:g}),(0,h.jsx)(L,{disabled:t,onClick:i,children:`Keep things as they are`}),v||t?null:(0,h.jsx)(`p`,{id:u,className:`m-0 min-w-0 text-small text-ink-2`,children:`${g} is off until: ${_.join(`; `)}.`})]})]})]})}function h7({summary:e,children:t}){return(0,h.jsxs)(`details`,{className:`py-3 text-small`,children:[(0,h.jsx)(`summary`,{className:`cursor-pointer font-semibold text-ink`,children:e}),(0,h.jsx)(`div`,{className:`mt-3`,children:t})]})}function g7({label:e,text:t}){return(0,h.jsxs)(`div`,{className:`min-w-0`,children:[(0,h.jsx)(`span`,{className:`text-small text-ink-2`,children:e}),(0,h.jsx)(`pre`,{className:`m-0 max-h-40 overflow-auto whitespace-pre-wrap break-words text-small`,children:t??`Not set`})]})}var _7=e=>e===null?`Unknown`:e===0?`$0`:new Intl.NumberFormat(`en-US`,{style:`currency`,currency:`USD`,maximumFractionDigits:e>0&&e<.01?4:2}).format(e);function v7(e,t){return e===t?_7(e):`${_7(e)}–${_7(t)}`}function Gve(e){return e.onPlan===!0?`$0 on plan${e.apiLow===void 0||e.apiLow===null||e.apiHigh===void 0?``:` · ~${v7(e.apiLow,e.apiHigh??null)} via API`}`:v7(e.low,e.high)}var Kve=[`generate`,`local`,`review`,`reuse`,`blocked`];function qve(e,t){let n=new Map;for(let t of e){let e=t.reason.trim()||`No reason was given.`;n.set(e,[...n.get(e)??[],t.key])}return[...n].map(([e,n])=>({reason:e,what:n.length===1?t(n[0]??``):`${n.length} ${new Set(n.map(b7)).size===1?Jve(b7(n[0]??``)):`items`}`}))}function Jve(e){return/s$/u.test(e)?e:`${e.charAt(0).toLowerCase()}${e.slice(1)}s`}var y7={reuse:`kept as they are`,generate:`to make`,local:`built on this computer`,review:`to confirm`,blocked:`can't run`},Yve={"export:wav":`Audio export (WAV)`,"export:video":`Video export`,"subtitles:timing":`Subtitle timing`,"subtitles:cues":`Caption text and timing`,"subtitles:files":`Subtitle files`,"article:body":`Article`,"audio:provided":`Provided narration`,"audio:body:concat":`Combined narration`,"audio:intro":`Combined intro narration`,"audio:outro":`Combined outro narration`,"research:planner":`Research plan`,"research:notes":`Research notes`,"entry:intro:text":`Intro text`,"entry:outro:text":`Outro text`};function b7(e){let t=Yve[e];return t===void 0?{image:`Image request`,images:`Images`,audio:`Narration request`,article:`Article`,research:`Research`,thumbnail:`Thumbnail`,subtitles:`Subtitles`,video:`Video export`,export:`Export`,entry:`Intro or outro`}[e.split(`:`)[0]??``]??`Output`:t}function Xve(e){let t=new Map,n=new Map;for(let t of e.work){let e=b7(t.key);n.set(e,(n.get(e)??0)+1)}let r=new Map;for(let i of e.work){let e=b7(i.key),a=(r.get(e)??0)+1;r.set(e,a),t.set(i.key,(n.get(e)??0)>1?`${e} ${a}`:e)}for(let n of e.review?.requests??[])t.set(n.key,n.label);return e=>t.get(e)??b7(e)}var Zve={llm:`Text generation`,image:`Images`,images:`Images`,tts:`Audio`,audio:`Audio`};function x7({error:e,refusal:t}){let n=(0,m.useRef)(null);return(0,m.useEffect)(()=>{(e!==void 0||t!==void 0)&&n.current?.focus()},[e,t]),e===void 0&&t===void 0?null:(0,h.jsxs)(`div`,{ref:n,role:`alert`,tabIndex:-1,"data-tone":`danger`,className:`sl-callout sl-callout--danger outline-none`,children:[(0,h.jsx)(Lc,{"aria-hidden":`true`,strokeWidth:1.75}),(0,h.jsx)(`p`,{className:`sl-callout__title m-0`,children:e??(t?.reason===`readiness`?t.fields.length>0?`This can't start yet. Fix the items below, then try again.`:`Slopify couldn't check your providers. Open Settings → Providers, make sure each one you use is set up, then try again.`:t?.message)}),t?.fields.length?(0,h.jsx)(`ul`,{className:`sl-callout__body m-0 list-disc pl-5`,children:t.fields.map(({field:e,message:t})=>(0,h.jsxs)(`li`,{children:[Zve[e.split(`.`)[0]??``]??`Project`,`: `,t]},`${e}:${t}`))}):null]})}var Qve=K({text:U().optional(),logicalText:U().optional(),title:U().optional(),notes:U().optional(),outline:G(U()).optional(),prompt:U().optional()});function $ve(e){if(e===null)return`No text was recorded for this part.`;try{let t=Qve.safeParse(JSON.parse(e));if(!t.success)return`Recorded text cannot be decoded.`;let{logicalText:n,text:r,title:i,notes:a,outline:o,prompt:s}=t.data;return[n,r,a?.trim()?[i,a].filter(e=>e?.trim()).join(`
302
+ `)}function ove({cues:e,duration:t,onChange:n,onPending:r}){let i=(0,m.useId)(),[a,o]=(0,m.useState)(()=>e.map(e=>({...e,start:String(e.start),end:String(e.end)}))),[s,c]=(0,m.useState)(),[l,u]=(0,m.useState)(!1),d=(0,m.useRef)(r);d.current=r,(0,m.useEffect)(()=>{d.current(l)},[l]),(0,m.useEffect)(()=>()=>d.current(!1),[]);function f(){let e=[],r=new Set,i=0;if(!Number.isFinite(t)||t<=0){c(`The narration length isn't known yet, so captions can't be checked. Reload the page and try again.`);return}for(let[n,o]of a.entries()){let a=o.start.trim()===``?NaN:Number(o.start),s=o.end.trim()===``?NaN:Number(o.end);if(r.has(o.id)){c(`Caption ${n+1}: this caption is listed twice. Remove the copy.`);return}if(r.add(o.id),!Number.isFinite(a)||a<0||a<i){c(`Caption ${n+1}: start must be a number of seconds, no earlier than the previous caption's end.`);return}if(!Number.isFinite(s)||s<=a||s>t){c(`Caption ${n+1}: end must be after its start and no later than the end of the narration.`);return}if(o.text.trim()===``){c(`Caption ${n+1}: enter caption text.`);return}e.push({id:o.id,text:o.text,start:a,end:s,...o.speaker===void 0?{}:{speaker:o.speaker}}),i=s}n(e),c(void 0),u(!1)}return(0,h.jsxs)(`section`,{"aria-label":`Edit caption cues`,className:`space-y-3`,...Tb,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,h.jsx)(`h3`,{children:`Caption text and timing`}),(0,h.jsx)(B,{id:`project.captions.editor`})]}),a.map((e,t)=>(0,h.jsxs)(`fieldset`,{className:`space-y-2 rounded-control border border-line-strong p-3`,children:[(0,h.jsxs)(`legend`,{children:[`Caption `,t+1]}),(0,h.jsxs)(`label`,{htmlFor:`${i}-${e.id}-text`,className:`block text-small`,children:[`Text for caption `,t+1,(0,h.jsx)(kV,{id:`${i}-${e.id}-text`,value:e.text,onChange:n=>{u(!0),o(a.with(t,{...e,text:n.target.value}))}})]}),(0,h.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,h.jsxs)(`label`,{htmlFor:`${i}-${e.id}-start`,className:`block text-small`,children:[`Start for caption `,t+1,(0,h.jsx)(OV,{id:`${i}-${e.id}-start`,inputMode:`decimal`,value:e.start,onChange:n=>{u(!0),o(a.with(t,{...e,start:n.target.value}))}})]}),(0,h.jsxs)(`label`,{htmlFor:`${i}-${e.id}-end`,className:`block text-small`,children:[`End for caption `,t+1,(0,h.jsx)(OV,{id:`${i}-${e.id}-end`,inputMode:`decimal`,value:e.end,onChange:n=>{u(!0),o(a.with(t,{...e,end:n.target.value}))}})]})]})]},e.id)),s===void 0?null:(0,h.jsx)(`p`,{role:`alert`,className:`text-danger`,children:s}),(0,h.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,h.jsx)(L,{type:`button`,onClick:f,children:`Apply caption edits to draft`}),(0,h.jsx)(B,{id:`project.captions.apply`})]}),l?(0,h.jsx)(`p`,{children:`Apply these caption edits before saving the project.`}):null]})}function r7(e){return`imagePrompts.${String(e)}`}function i7(e){let t=/^imagePrompts\.(\d+)$/.exec(e??``);return t?.[1]===void 0?void 0:Number(t[1])}function sve(e,t){return e.length===t.length&&e.every((e,n)=>e.name===t[n]?.name&&e.number===t[n]?.number)}function cve(e){let{from:t,to:n,content:r}=e,i=n.map(e=>t.findIndex(t=>t.name===e.name)),a=[],o={},s={};for(let[e,t]of Object.entries(r.promptTemplates))i7(e)===void 0&&(o[e]=t);for(let[t,n]of Object.entries(e.rendered))i7(t)===void 0&&(s[t]=n);for(let[t,c]of n.entries()){let n=r7(t),l=i[t]??-1;if(l>=0){let t=r7(l);Object.hasOwn(r.promptTemplates,t)&&(o[n]=r.promptTemplates[t]??null);let i=e.rendered[t];i!==void 0&&(s[n]=i);continue}let u=e.body(c.name);if(u===void 0){a.push({field:`imagePrompts.${String(t)}.name`,message:`The image prompt "${c.name}" is not in the Library any more. Untick it under Images, or add it back on Library → Prompts.`});continue}o[n]=u,s[n]=hq(u,e.values)}if(a.length>0)return{ok:!1,fields:a};let c=new Map;for(let e of r.imageOrder){let n=i7(r.imageDefinitions[e]?.templateKey);n===void 0||n>=t.length||c.set(n,[...c.get(n)??[],e])}let l={},u=[],d=[],f=(e,t)=>{let n=r7(e),r=o[n];return t===void 0?{source:`generate`,assetId:null,prompt:s[n]??null,templateKey:r==null?null:n}:{...t,source:`generate`,assetId:null,templateKey:t.templateKey??null}},p=(t,n,r)=>Array.from({length:Math.max(0,n)},()=>{let n=e.key();return l[n]=f(t,r),u.push(n),n}),m=[];for(let e of r.imageOrder){let a=r.imageDefinitions[e];if(a===void 0)continue;let o=i7(a.templateKey);if(o===void 0||o>=t.length){l[e]=a,m.push(e);continue}let s=i.indexOf(o);if(s===-1){d.push(e);continue}let u=c.get(o)??[],f=t[o]?.number!==n[s]?.number,h=f?n[s]?.number??0:u.length,g=u.indexOf(e);if(g>=h){d.push(e);continue}let _=a.templateKey===r7(s)?a:{...a,templateKey:r7(s)};l[e]=_,m.push(e),f&&g===Math.min(u.length,h)-1&&m.push(...p(s,h-u.length,_))}for(let[e,r]of n.entries()){let n=i[e]??-1,a=n>=0?c.get(n)??[]:[];n>=0&&(a.length>0||t[n]?.number===r.number)||m.push(...p(e,r.number,void 0))}return{ok:!0,content:{...r,imageOrder:m,imageDefinitions:l,promptTemplates:o},rendered:s,added:u,removed:d}}function lve({edit:e,saved:t,prompts:n,problem:r,onChange:i}){let{config:a}=e;if(a.sources.images!==`generate`)return null;let o=n.filter(e=>e.kind===`image`);return(0,h.jsxs)(`section`,{"aria-label":`Image prompts`,className:`space-y-3`,children:[(0,h.jsx)(u6,{prompts:o,picked:a.imagePrompts,problem:r,onPick:t=>i({...e,config:{...a,imagePrompts:t}})}),(0,h.jsx)(uve,{edit:e,saved:t,prompts:o,problem:r})]})}function uve({edit:e,saved:t,prompts:n,problem:r}){let i=e.config.imagePrompts,a=r(`imagePrompts`);if(sve(t,i))return a===void 0?null:(0,h.jsx)(a7,{children:a});let o=0,s=cve({from:t,to:i,content:e.content,rendered:e.config.rendered,values:e.config.values,body:e=>n.find(t=>t.name===e)?.body,key:()=>`planned-${String(++o)}`});if(!s.ok)return(0,h.jsx)(a7,{children:s.fields.map(e=>e.message).join(` `)});let c=e=>`${String(e)} ${e===1?`image`:`images`}`,l=[...s.added.length>0?[`adds ${c(s.added.length)} to make`]:[],...s.removed.length>0?[`removes ${c(s.removed.length)}`]:[]];return(0,h.jsxs)(h.Fragment,{children:[a===void 0?null:(0,h.jsx)(a7,{children:a}),(0,h.jsx)(`p`,{role:`status`,className:`m-0 text-small text-ink-2`,children:l.length===0?`Saving keeps every image as it is.`:`Saving ${l.join(` and `)}. The other images are kept; the new ones are made when you remake outdated outputs.`})]})}function a7({children:e}){return(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-small text-danger`,children:e})}function dve({edit:e,problem:t,onChange:n}){let r=e.config.ambientBed,[i,a]=(0,m.useState)(()=>r===void 0?void 0:pA(r)),o=r?.source===`upload`?[...oA,`upload`]:oA,s=i===void 0?[]:[...mve(i)];return(0,h.jsx)(q2,{value:i,inherit:`None`,sources:o,offerNone:!1,problem:e=>t(`ambientBed.${e}`)??s.find(t=>t.field===e)?.message,onChange:t=>{a(t);let r=mA(t),{ambientBed:i,...o}=e.config;n({...e,config:r===void 0?o:{...o,ambientBed:r}})}})}function fve({edit:e,problem:t,onChange:n}){let r=e.config.loudness,[i,a]=(0,m.useState)(()=>r===void 0?{...uk,enabled:!1}:{...r,enabled:!0});return(0,h.jsx)(W6,{value:i,problem:e=>t(`loudness.${e}`),onChange:t=>{a(t);let{loudness:r,...i}=e.config;n({...e,config:t.enabled?{...i,loudness:{videoLufs:t.videoLufs,audioFilesLufs:t.audioFilesLufs}}:i})}})}function pve({edit:e,problem:t,onChange:n}){let[r,i]=(0,m.useState)(()=>({sentencePauseSeconds:String(e.config.sentencePauseSeconds??0),paragraphPauseSeconds:String(e.config.paragraphPauseSeconds??0)}));if(e.config.sources.audio!==`generate`)return null;let a=e=>{let t=X6(r[e]);return t===void 0?`Enter a number of seconds.`:kk(t,e===`sentencePauseSeconds`?`sentences`:`paragraphs`)};return(0,h.jsx)(Y6,{sentence:r.sentencePauseSeconds,paragraph:r.paragraphPauseSeconds,problem:e=>a(e)??t(e),onChange:(t,a)=>{i({...r,[t]:a});let o=X6(a);if(o===void 0)return;let{[t]:s,...c}=e.config;n({...e,config:o===0?c:{...c,[t]:o}})}})}function mve(e){let t=mA(e);return t===void 0?[]:dA(t)}function hve({edit:e,problem:t,onChange:n}){let r=(0,m.useId)(),{config:i}=e,a=i.imageScale,[o,s]=(0,m.useState)(()=>a===void 0?void 0:ak(a));if(i.sources.images!==`generate`)return null;let c=a?.words??(nk(e.content.articleMarkdown??``)||1500),l=t=>{s(t);let{imageScale:r,...o}=i;if(t===void 0){n({...e,config:o});return}let l=o7(t);l!==void 0&&n({...e,config:{...o,imageScale:{perHour:l,words:c},...a===void 0&&i.motionStyle===`zoom`?{motionStyle:`mixed`}:{}}})},u=i.imagePrompts.reduce((e,t)=>e+t.number,0),d=a===void 0?u:ck(i).reduce((e,t)=>e+t,0),f=o===void 0?void 0:o7(o),p=o===void 0?void 0:f===void 0?{problem:!0,text:o.every===`minutes`?`Enter a number of minutes between ${String(QO)} and 60.`:`Enter a number of images per hour between 1 and 240.`}:{problem:!1,text:`For about ${String(Math.max(1,Math.round(rk(c))))} minutes of narration: ${String(d)} images${d>u?`, ${String(d-u)} more than the prompts' ${String(u)}`:`, which the prompts' Numbers already cover`}.`},g=t(`imageScale`)??void 0;return(0,h.jsxs)(`div`,{className:`flex flex-col items-start gap-2`,...Tb,children:[(0,h.jsx)(Eb,{checked:o!==void 0,label:`More images for long videos`,describedBy:`${r}-line`,tip:`play.image-scale`,onChange:e=>l(e?{every:`minutes`,value:`2`}:void 0)}),o===void 0?null:(0,h.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2 text-small`,children:[(0,h.jsx)(Db,{label:`How the rate is given`,value:o.every,options:[{value:`minutes`,label:`Every N minutes`},{value:`hour`,label:`N per hour`}],onChange:e=>l({every:e,value:gve(o.value,o.every,e)})}),o.every===`minutes`?(0,h.jsx)(`span`,{children:`One image every`}):null,(0,h.jsx)(OV,{"aria-label":o.every===`minutes`?`Minutes per image`:`Images per hour`,inputMode:`decimal`,className:`w-[72px] tabular-nums`,"aria-invalid":p?.problem===!0,"aria-describedby":`${r}-line`,value:o.value,onChange:e=>l({every:o.every,value:e.target.value})}),(0,h.jsx)(`span`,{children:o.every===`minutes`?`minutes`:`images per hour`})]}),g===void 0&&p===void 0?null:(0,h.jsx)(`p`,{id:`${r}-line`,className:g!==void 0||p?.problem?`m-0 text-label text-danger`:`m-0 text-label text-ink-3`,children:g??p?.text})]})}function o7(e){let t=Number(e.value.trim());if(e.value.trim()!==``&&Number.isFinite(t))return e.every===`minutes`?t>=.25&&t<=60?ik(t):void 0:t>=1&&t<=240?t:void 0}function gve(e,t,n){if(t===n)return e;let r=Number(e.trim());return e.trim()===``||!Number.isFinite(r)||r<=0?e:String(Math.round(60/r*100)/100)}function _ve({edit:e,view:t,imageKey:n,index:r}){let{api:i}=R(),a=e.content.imageDefinitions[n];if(a===void 0)return null;let o=t?.outputs.filter(e=>e.output.stageKind===`images`&&e.output.role===`image`)??[],s=o.find(e=>e.selected&&e.workKey===`image:${n}`),c=e.uploads?.some(e=>e.destination.kind===`image`&&e.destination.imageKey===n)??!1,l=a.source===`generate`||c||s?.assetId===a.assetId?s:o.find(e=>e.assetId===a.assetId&&e.available),u=l?.available===!0,d=!u&&(l!==void 0||a.source===`provide`&&a.assetId!==null),f=e.regenerate?.includes(`image:${n}`)===!0,p=c?u?`Replacement ready to save; previous image shown until Save`:`Replacement ready to save; preview available after Save`:f?`Made again after you press Save changes; the current image stays until then`:d?`Image file unavailable`:u?a.source===`provide`&&l!==s?`Provided image selected`:l.state===`review`?`Image retained; review required`:l.state===`outdated`?`Outdated image retained until rebuilt`:`Current image retained`:`No completed image yet`,m=u&&/\.(mp4|mov|m4v|webm|mkv)$/i.test(l.output.path);return(0,h.jsxs)(h.Fragment,{children:[!u||t===void 0?null:m?(0,h.jsx)(i2,{className:`max-w-[240px]`,label:`Video clip ${r+1}`,src:E2(i,t.revision.projectId,t.revision.id,l.recordId)}):(0,h.jsx)(a2,{className:`max-w-[240px]`,alt:`Retained scene ${r+1}`,src:E2(i,t.revision.projectId,t.revision.id,l.recordId)}),(0,h.jsx)(`p`,{children:m?`${p} · video clip, played muted`:p})]})}function s7(e,t,n){let r=t+n,i=e[t],a=e[r];if(i===void 0||a===void 0)return e;let o=[...e];return o[t]=a,o[r]=i,o}function vve({edit:e,onChange:t,onPending:n,view:r,getEdit:i}){let a=(0,m.useId)(),[o,s]=(0,m.useState)({}),{content:c}=e,l=tk(e.config),u=(0,m.useRef)(e);u.current=e;function d(e){let n=e.content.imageOrder.flatMap(t=>{let n=e.content.imageDefinitions[t];return n===void 0?[]:[n]}),r=e.content.imageOrder.length===0||e.config.sources.images===`off`?`off`:n.some(e=>e.source===`generate`)?`generate`:`provide`,i={...e,config:{...e.config,sources:{...e.config.sources,images:r,...r===`off`?{video:`off`}:{}}}};u.current=i,t(i)}function f(e,t){let n=i?.()??u.current,r=n.content.imageDefinitions[e];if(r===void 0)return;let a=r.templateKey??`image:${e}`;s(t=>({...t,[e]:(t[e]??0)+1})),d(N5({...n,...n.uploads===void 0?{}:{uploads:n.uploads.filter(t=>t.destination.kind!==`image`||t.destination.imageKey!==e)},content:{...n.content,imageDefinitions:{...n.content.imageDefinitions,[e]:{...r,templateKey:a}}}},a,t))}function p(e){let t=i?.()??u.current,n=t.content,r=crypto.randomUUID();d({...t,config:{...t.config,sources:{...t.config.sources,images:t.config.sources.images===`off`?`provide`:t.config.sources.images}},content:{...n,imageOrder:[...n.imageOrder,r],imageDefinitions:{...n.imageDefinitions,[r]:{source:`provide`,assetId:null,prompt:null}}},uploads:[...t.uploads??[],{stagedFileId:e.id,destination:{kind:`image`,imageKey:r}}]})}return(0,h.jsxs)(`section`,{"aria-label":`Edit images`,className:`space-y-3`,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,h.jsx)(`h3`,{children:`Images`}),(0,h.jsx)(B,{id:`project.images.editor`})]}),c.imageOrder.map((t,s)=>{let l=c.imageDefinitions[t];return l===void 0?(0,h.jsxs)(`p`,{role:`alert`,children:[`Image definition missing: `,t]},t):(0,h.jsxs)(`fieldset`,{className:`space-y-2 rounded-control border border-line-strong p-3`,children:[(0,h.jsxs)(`legend`,{children:[`Image `,s+1]}),(0,h.jsx)(_ve,{edit:e,view:r,imageKey:t,index:s}),l.source===`generate`?(0,h.jsxs)(`div`,{...Tb,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,h.jsxs)(`label`,{htmlFor:`${a}-${t}-prompt`,children:[`Prompt for image `,s+1]}),(0,h.jsx)(B,{id:`project.images.prompt`,label:`prompt for image ${String(s+1)}`})]}),(0,h.jsx)(kV,{id:`${a}-${t}-prompt`,value:l.templateKey===void 0||l.templateKey===null?l.prompt??``:c.promptTemplates[l.templateKey]??l.prompt??``,onChange:e=>f(t,e.target.value)})]}):null,l.source===`generate`&&l.templateKey==null?(0,h.jsxs)(L,{type:`button`,onClick:()=>f(t,l.prompt??``),children:[`Use saved wording as template for image `,s+1]}):null,(0,h.jsx)(P5,{label:`Replace image ${s+1}`,kind:`images`,onPending:e=>n(`image:${t}`,e),onReady:e=>{let n=i?.()??u.current,r=n.content,a=r.imageDefinitions[t];a!==void 0&&r.imageOrder.includes(t)&&d({...n,regenerate:(n.regenerate??[]).filter(e=>e!==`image:${t}`),uploads:[...(n.uploads??[]).filter(e=>e.destination.kind!==`image`||e.destination.imageKey!==t),{stagedFileId:e.id,destination:{kind:`image`,imageKey:t}}],content:{...r,imageDefinitions:{...r.imageDefinitions,[t]:{...a,source:`provide`,prompt:null,templateKey:null}}}})}},`${t}:${o[t]??0}:${e.config.sources.images===`off`}`),(0,h.jsxs)(L,{type:`button`,disabled:s===0,onClick:()=>d({...e,content:{...c,imageOrder:s7(c.imageOrder,s,-1)}}),children:[`Move image `,s+1,` earlier`]}),(0,h.jsxs)(L,{type:`button`,disabled:s===c.imageOrder.length-1,onClick:()=>d({...e,content:{...c,imageOrder:s7(c.imageOrder,s,1)}}),children:[`Move image `,s+1,` later`]}),(0,h.jsxs)(L,{type:`button`,onClick:()=>{let n=c.imageOrder.filter(e=>e!==t);d({...e,config:n.length===0?{...e.config,sources:{...e.config.sources,images:`off`,video:`off`}}:e.config,content:{...c,imageOrder:n,imageDefinitions:Object.fromEntries(Object.entries(c.imageDefinitions).filter(([e])=>e!==t))},regenerate:(e.regenerate??[]).filter(e=>e!==`image:${t}`),uploads:(e.uploads??[]).filter(e=>e.destination.kind!==`image`||e.destination.imageKey!==t)})},children:[`Delete image `,s+1,c.imageOrder.length===1?` and turn Images and Video Off`:``]}),l.source===`generate`?(0,h.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[e.regenerate?.includes(`image:${t}`)===!0?(0,h.jsxs)(L,{type:`button`,onClick:()=>d({...e,regenerate:(e.regenerate??[]).filter(e=>e!==`image:${t}`)}),children:[`Keep image `,s+1]}):(0,h.jsxs)(L,{type:`button`,onClick:()=>d({...e,regenerate:[...new Set([...e.regenerate??[],`image:${t}`])]}),children:[`Regenerate image `,s+1]}),(0,h.jsx)(B,{id:`project.images.regenerate`})]}):null]},t)}),(0,h.jsx)(L,{type:`button`,disabled:c.imageOrder.length>=l,onClick:()=>{if(c.imageOrder.length>=l)return;let t=crypto.randomUUID();d({...e,config:{...e.config,sources:{...e.config.sources,images:`generate`}},content:{...c,imageOrder:[...c.imageOrder,t],promptTemplates:{...c.promptTemplates,[`image:${t}`]:``},imageDefinitions:{...c.imageDefinitions,[t]:{source:`generate`,assetId:null,prompt:``,templateKey:`image:${t}`}}}})},children:`Add generated image`}),c.imageOrder.length>=l?(0,h.jsxs)(`p`,{children:[`At most `,l,` images can be included.`]}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(P5,{label:`Add provided image`,kind:`images`,onPending:e=>n(`image:new`,e),onReady:p},`new-image:${e.config.sources.images===`off`}`),(0,h.jsx)(P5,{label:`Add a video clip`,kind:`images`,accept:`video/mp4,video/quicktime,video/webm,video/x-matroska,.mp4,.mov,.m4v,.webm,.mkv`,onPending:e=>n(`clip:new`,e),onReady:p},`new-clip:${e.config.sources.images===`off`}`)]})]})}var yve=K({logicalKey:U().min(1),logicalText:U(),segment:q([`body`,`intro`,`outro`]),text:U()});function bve(e,t){if(t==null)return e;let n=[...t.intro??[],...t.body??[],...t.outro??[]];return n.length===0?e:n.flatMap(t=>e.filter(e=>e.key===t))}function xve(e){let t=new Map,n=new Set,r=0;for(let i of e.pieces){if(!i.selected||i.stageKind!==`audio`||i.piece.kind!==`chunk`)continue;let e;try{e=i.piece.payload===null?null:JSON.parse(i.piece.payload)}catch{r++;continue}let a=yve.safeParse(e);if(!a.success){r++;continue}let{logicalKey:o,logicalText:s}=a.data;if(n.has(o)){r++;continue}let c=t.get(o);if(c!==void 0&&c.text!==s){r+=c.parts+1,t.delete(o),n.add(o);continue}t.set(o,{key:o,text:s,parts:(c?.parts??0)+1})}return{groups:[...t.values()],unmapped:r}}function Sve({view:e,edit:t,onChange:n,onPending:r,getEdit:i}){let a=(0,m.useId)(),{api:o}=R(),s=M({queryKey:[`narration-chunks`,e.revision.projectId,e.revision.id],queryFn:async()=>{let t=await Ede(o,e.revision.projectId,e.revision.id);return t.ok?t.value.chunks:null},staleTime:1/0}),c=xve(e),l=bve(c.groups,s.data),u=c.unmapped,d=(0,m.useRef)(t);d.current=t;let[f,p]=(0,m.useState)({});function g(e){d.current=e,n(e)}return(0,h.jsxs)(`section`,{"aria-label":`Edit narration`,className:`space-y-3`,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,h.jsx)(`h3`,{children:`Narration`}),(0,h.jsx)(B,{id:`project.narration.editor`})]}),t.config.chunking?.mode===`whole`||t.config.chunking===void 0?(0,h.jsx)(`p`,{children:`This narration uses one whole request. Editing its text rebuilds the whole narration request.`}):null,u===0?null:(0,h.jsx)(`p`,{children:`Some older audio cannot be matched reliably to its narration text. Replace the provided narration or rebuild from the article to edit those chunks.`}),l.map((e,n)=>{let o=t.content.narrationOverrides[e.key];return(0,h.jsxs)(`fieldset`,{className:`space-y-2 rounded-control border border-line-strong p-3`,children:[(0,h.jsxs)(`legend`,{children:[`Narration chunk `,n+1]}),(0,h.jsxs)(`p`,{children:[e.parts,` audio `,e.parts===1?`part`:`parts`,` in this narration chunk.`]}),(0,h.jsxs)(`div`,{className:`text-small`,...Tb,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,h.jsxs)(`label`,{htmlFor:`${a}-${e.key}-text`,children:[`Text for narration chunk `,n+1]}),(0,h.jsx)(B,{id:`project.narration.chunk-text`,label:`text for narration chunk ${String(n+1)}`})]}),(0,h.jsx)(kV,{id:`${a}-${e.key}-text`,value:o?.kind===`text`?o.text:e.text,onChange:n=>{p(t=>({...t,[e.key]:(t[e.key]??0)+1})),g({...t,...t.uploads===void 0?{}:{uploads:t.uploads.filter(t=>t.destination.kind!==`narration`||t.destination.key!==e.key)},content:{...t.content,narrationOverrides:{...t.content.narrationOverrides,[e.key]:{kind:`text`,text:n.target.value}}}})}})]}),(0,h.jsx)(P5,{label:`Replace narration chunk ${n+1}`,kind:`audio`,onPending:t=>r(`narration:${e.key}`,t),onReady:t=>{let n=i?.()??d.current;g({...n,regenerate:(n.regenerate??[]).filter(t=>t!==e.key),uploads:[...(n.uploads??[]).filter(t=>t.destination.kind!==`narration`||t.destination.key!==e.key),{stagedFileId:t.id,destination:{kind:`narration`,key:e.key}}]})}},`${e.key}:${f[e.key]??0}`),t.regenerate?.includes(e.key)?(0,h.jsxs)(`p`,{className:`flex flex-wrap items-center gap-2 text-small text-accent-ink`,children:[`Narration chunk `,n+1,` will be regenerated after you save and press Remake.`,(0,h.jsxs)(L,{type:`button`,variant:`quiet`,onClick:()=>{let t=i?.()??d.current;g({...t,regenerate:(t.regenerate??[]).filter(t=>t!==e.key)})},children:[`Keep narration chunk `,n+1]})]}):(0,h.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,h.jsxs)(L,{type:`button`,onClick:()=>{let t=i?.()??d.current,n={...t.content.narrationOverrides};n[e.key]?.kind===`asset`&&delete n[e.key],p(t=>({...t,[e.key]:(t[e.key]??0)+1})),g({...t,content:{...t.content,narrationOverrides:n},uploads:t.uploads?.filter(t=>t.destination.kind!==`narration`||t.destination.key!==e.key),regenerate:[...new Set([...t.regenerate??[],e.key])]})},children:[`Regenerate narration chunk `,n+1,` after review`]}),(0,h.jsx)(B,{id:`project.narration.regenerate`})]})]},e.key)})]})}function Cve(e){let{config:t,fingerprints:n}=e.revision;if(t.sources.audio===`off`)return;let r=t.sources.audio===`provide`?[{key:`audio:provided`,role:`audio_body`}]:[...t.intro===void 0?[]:[{key:`audio:intro`,role:`audio_intro`}],{key:`audio:body:concat`,role:`audio_body`},...t.outro===void 0?[]:[{key:`audio:outro`,role:`audio_outro`}]],i=e.outputs.filter(e=>e.selected&&e.state===`ready`&&e.available&&e.fingerprint===n[e.workKey]),a=r.map(({key:e,role:t})=>i.find(n=>n.workKey===e&&n.output.role===t));if(a.some(e=>e===void 0))return;let o=a.map(e=>e?.output.durationMs);if(o.every(c7))return o.reduce((e,t)=>e+t,0)/1e3+Math.max(0,r.length-1)*t.silenceGapSeconds+2*t.edgeSilenceSeconds;let s=i.find(e=>(e.output.role===`audio_export`||e.output.role===`video`)&&c7(e.output.durationMs))?.output.durationMs;return c7(s)?s/1e3:void 0}function c7(e){return e!=null&&Number.isFinite(e)&&e>0}function wve({edit:e,prompts:t,problem:n,onChange:r,onPending:i,getEdit:a}){let{config:o}=e;if(o.sources.images!==`generate`)return null;let s=o.reference,c=s===void 0?N6:{source:s.source,prompt:s.prompt??``,thumbnail:s.thumbnail!==!1},l=e=>({...e,uploads:(e.uploads??[]).filter(e=>e.destination.kind!==`provided`||e.destination.stage!==`reference`)});return(0,h.jsx)(`section`,{"aria-label":`Establishing image`,className:`space-y-3`,children:(0,h.jsx)(P6,{value:c,prompts:t,problem:n,onChange:n=>{let{reference:i,...a}=o;if(n.source===`off`){r(l({...e,config:a}));return}let s={source:n.source,...n.source===`prompt`?{prompt:n.prompt}:{},...n.thumbnail?{}:{thumbnail:!1}},u=n.source===`prompt`&&n.prompt!==c.prompt?t.find(e=>e.kind===`image`&&e.name===n.prompt):void 0,d={...e,config:{...a,reference:s}},f=u===void 0?d:N5(d,`referencePrompt`,u.body);r(n.source===`provide`?f:l(f))},upload:(0,h.jsx)(P5,{label:e.content.provided.reference===void 0?`Upload the establishing image`:`Replace the establishing image`,kind:`images`,accept:`image/png,image/jpeg`,onPending:i,onReady:t=>{let n=l(a?.()??e);n.config.reference?.source===`provide`&&r({...n,uploads:[...n.uploads??[],{stagedFileId:t.id,destination:{kind:`provided`,stage:`reference`}}]})}})})})}var Tve=K({words:G(K({text:U().trim().min(1),start:W().finite().nonnegative(),end:W().finite().positive(),confidence:W().optional(),speaker:U().min(1).optional()})).min(1)});function l7(e){let{config:t,content:n}=e;return JSON.stringify({source:t.sources.audio,audio:n.provided.audio,uploads:e.uploads?.filter(e=>e.destination.kind===`narration`||e.destination.kind===`provided`&&e.destination.stage===`audio`)??[],edge:t.edgeSilenceSeconds,...t.sources.audio===`generate`?{choice:t.audio,chunking:t.chunking,article:n.articleMarkdown??t.provided.article,articleSource:t.sources.article,renderedArticle:t.rendered.article,intro:t.intro,outro:t.outro,renderedIntro:t.rendered.intro,renderedOutro:t.rendered.outro,gap:t.silenceGapSeconds,overrides:n.narrationOverrides,regenerate:e.regenerate?.filter(e=>/^(audio:|article:|entry:)/.test(e))??[]}:{}})}function Eve({view:e,edit:t,fields:n,onChange:r,onPending:i,section:a}){let{api:o}=R(),s=M($y(o)).data?.prompts??[],c=l7(t),l=t.config.sources.audio!==`off`&&c===l7({config:e.revision.config,content:e.revision.content}),u=e.revision.fingerprints[`subtitles:timing`],d=l?Cve(e):void 0,f=d!==void 0&&u!==void 0&&u!==``,p=(0,m.useRef)({edit:t,onChange:r,revisionId:e.revision.id,identity:c});p.current={edit:t,onChange:r,revisionId:e.revision.id,identity:c};let g=(0,m.useRef)(i);g.current=i;let[_,v]=(0,m.useState)(new Set),[y,b]=(0,m.useState)(),x=(0,m.useRef)(void 0),S=(0,m.useRef)(!0),C=(0,m.useCallback)((e,t)=>{S.current&&v(n=>{if(n.has(e)===t)return n;let r=new Set(n);return t?r.add(e):r.delete(e),r})},[]);(0,m.useEffect)(()=>{g.current(_.size>0)},[_]),(0,m.useEffect)(()=>(S.current=!0,()=>{S.current=!1,x.current?.abort(),g.current(!1)}),[]),(0,m.useEffect)(()=>{let t=e.revision.id;return()=>{(p.current.revisionId!==t||p.current.identity!==c)&&x.current?.abort()}},[e.revision.id,c]);function w(e){let t=p.current.onChange;p.current={...p.current,edit:e,identity:l7(e)},t(e)}async function T(){if(x.current!==void 0)return;let t=new AbortController;x.current=t;let n=p.current;C(`captions:load`,!0),b(void 0);try{let r=e.outputs.find(e=>e.selected&&e.state===`ready`&&e.output.role===`subtitle_words`&&e.available);if(!f||d===void 0||u===void 0||r===void 0)throw Error(`Captions can't be edited until the current narration has finished and its subtitle timing is ready.`);let i=await o.fetch(E2(o,e.revision.projectId,e.revision.id,r.recordId),{signal:t.signal});if(!i.ok)throw Error(`The subtitle timing file couldn't be read. Reload the page and try again; if it still fails, use More → make it again in its section on Audio.`);let a=Tve.parse(await i.json()),s=0;for(let e of a.words){if(e.start<s||e.end<=e.start||e.end>d)throw Error(`The saved subtitle timing doesn't match the current narration. Use More → make it again in its section on Audio to rebuild it.`);s=e.end}let c=ave(a.words).map(e=>({...e,id:crypto.randomUUID()})),l=p.current;if(!S.current||t.signal.aborted||l.revisionId!==n.revisionId||l.identity!==n.identity||l.edit.content.subtitleCues!==n.edit.content.subtitleCues)return;w({...l.edit,content:{...l.edit.content,subtitleCues:{audioFingerprint:u,cues:c}}})}catch(e){S.current&&!t.signal.aborted&&b(e instanceof Error?e.message:String(e))}finally{x.current===t&&(x.current=void 0),C(`captions:load`,!1)}}let E=t.content.subtitleCues,D=e=>a===void 0||a===e;return(0,h.jsxs)(`div`,{className:`space-y-5`,children:[(0,h.jsxs)(`section`,{"aria-label":`Images`,hidden:!D(`images`),className:`space-y-6`,children:[(0,h.jsx)(lve,{edit:t,saved:e.revision.config.imagePrompts,prompts:s,problem:e=>n.find(t=>t.field===e||t.field===`config.${e}`)?.message,onChange:w}),(0,h.jsx)(hve,{edit:t,problem:e=>n.find(t=>t.field===e||t.field===`config.${e}`)?.message,onChange:w}),(0,h.jsx)(wve,{edit:t,prompts:s,problem:e=>n.find(t=>t.field===e||t.field===`content.${e}`)?.message,getEdit:()=>p.current.edit,onChange:w,onPending:e=>C(`provided:reference`,e)}),t.config.sources.thumbnail===`from_prompt`||t.config.sources.thumbnail===`prompt_by_llm`?(0,h.jsx)(Z6,{value:t.config.thumbnailCount===3?3:1,onPick:e=>{let{thumbnailCount:t,...n}=p.current.edit.config;w({...p.current.edit,config:e===3?{...n,thumbnailCount:3}:n})}}):null,[`audio`,`thumbnail`].map(e=>t.config.sources[e]===`provide`?(0,h.jsx)(P5,{label:`Replace provided ${e}`,kind:e,onPending:t=>C(`provided:${e}`,t),onReady:t=>{let n=p.current;n.edit.config.sources[e]===`provide`&&w({...n.edit,uploads:[...(n.edit.uploads??[]).filter(t=>t.destination.kind!==`provided`||t.destination.stage!==e),{stagedFileId:t.id,destination:{kind:`provided`,stage:e}}]})}},e):null),(0,h.jsx)(vve,{getEdit:()=>p.current.edit,view:e,edit:t,onChange:w,onPending:C})]}),(0,h.jsx)(`section`,{"aria-label":`Narration`,hidden:!D(`narration`),className:`space-y-5`,children:t.config.sources.audio===`generate`?(0,h.jsx)(Sve,{getEdit:()=>p.current.edit,view:e,edit:t,onChange:w,onPending:C}):null}),y===void 0?null:(0,h.jsx)(`p`,{role:`alert`,className:`text-danger`,children:y}),(0,h.jsxs)(`section`,{"aria-label":`Captions`,hidden:!D(`captions`),className:`space-y-5`,children:[f?null:(0,h.jsx)(`p`,{children:`Captions can be edited once the current narration has finished and its subtitle timing is ready.`}),E===void 0?(0,h.jsx)(L,{type:`button`,disabled:!f||_.has(`captions:load`),onClick:()=>void T(),children:`Edit existing caption cues`}):(0,h.jsxs)(h.Fragment,{children:[E.audioFingerprint===u?null:(0,h.jsx)(`p`,{children:`These caption edits belong to an earlier narration. Review their text and timing against the current narration, then apply your corrections and save the project.`}),f&&d!==void 0?(0,h.jsx)(ove,{cues:E.cues,duration:d,onPending:e=>C(`captions:dirty`,e),onChange:e=>{let t=p.current,n=t.edit.content.subtitleCues;n!==void 0&&w({...t.edit,content:{...t.edit.content,subtitleCues:{...n,cues:e}}})}},`${e.revision.id}:${u}`):null,(0,h.jsx)(L,{type:`button`,onClick:()=>w({...t,content:{...t.content,subtitleCues:void 0}}),children:`Discard caption edits`})]})]})]})}function Dve({edit:e,error:t,onChange:n}){return(0,h.jsx)(`div`,{className:`mb-5`,children:(0,h.jsx)(K2,{value:e.config.language,error:t,onChange:t=>{let{language:r,...i}=e.config;n({...e,config:t===void 0||t===`en`?i:{...i,language:t}})}})})}function Ove({edit:e,saved:t,problem:n,onChange:r}){let{api:i}=R(),a=M(Jb(i)),{config:o}=e,s=e=>e!==void 0&&(a.data?.some(t=>t.id===e)??!0)?e:Vb,c=s(o.channelId),l=a.data?.find(e=>e.id===c),u=o.useBrandKit!==!1,d=c!==s(t.channelId),f=u!==(t.useBrandKit!==!1);return(0,h.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,h.jsx)(Y,{label:`Channel`,tip:`play.channel`,error:n(`channelId`),help:l===void 0?void 0:(0,h.jsxs)(pa,{to:`/channels/$channelId`,params:{channelId:l.id},className:`underline`,children:[`Edit `,l.name]}),children:(0,h.jsxs)(AV,{value:c,onChange:t=>r({...e,config:{...o,channelId:t.target.value}}),children:[a.data===void 0?(0,h.jsx)(`option`,{value:c,children:`Loading channels…`}):null,(a.data??[]).map(e=>(0,h.jsxs)(`option`,{value:e.id,children:[e.name,e.cast>0?` · ${String(e.cast)} in the cast`:``]},e.id))]})}),(0,h.jsxs)(`div`,{className:`flex min-w-0 flex-col justify-end gap-1`,children:[(0,h.jsx)(Eb,{checked:u,label:`Use the channel's brand kit`,tip:`play.brand-kit`,onChange:t=>{let{useBrandKit:n,...i}=o;r({...e,config:t?i:{...i,useBrandKit:!1}})}}),u?null:(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-3`,children:`Its cast is still used.`})]}),a.error===null?null:(0,h.jsxs)(`p`,{className:`m-0 text-small text-danger md:col-span-2`,children:[`The channels couldn't be loaded: `,a.error.message,`. Reload the page to pick a channel.`]}),d||f?(0,h.jsxs)(`p`,{className:`m-0 text-small text-ink-2 md:col-span-2`,children:[d?`Saving moves the project to this channel and takes its cast as it is now. `:``,u?`The brand kit fills the caption font and colours, title style, end screen, intro, outro and document theme where they are at their default or were set by the old kit.`:`What the old brand kit had set is taken off.`]}):null]})}function kve(e,t,n){let r=e.outputs.find(e=>e.selected&&e.available&&e.output.role===`reference`);if(t.config.reference!==void 0&&r!==void 0)return{image:{kind:`output`,outputId:r.output.id},drawnOn:`the establishing image`};let i=n.flatMap(e=>{let t=e.images.find(e=>e.state===`ready`&&e.sha256!==null);return t?.sha256?[{...e,images:[t.sha256]}]:[]}),a=i8([t.config.title,...Object.values(t.config.values??{})].join(` `),i)[0]??i[0],o=a?.images[0];if(a!==void 0&&o!==void 0)return{image:{kind:`picture`,sha256:o},drawnOn:`${a.name}'s picture`}}function Ave({edit:e,view:t,prompts:n,error:r,onChange:i}){let a=(0,m.useRef)(e.config.narrationPrompt);if(e.config.sources.audio!==`generate`)return null;let o=t.revision.config.narrationPrompt,s=t.revision.content.promptTemplates.narration??t.revision.config.rendered.narration,c=o&&s!==void 0&&!n.some(e=>e.kind===`narration`&&e.name===o)?[...n,{id:`saved-narration`,kind:`narration`,name:o,body:s,slots:[],updatedAt:t.revision.createdAt}]:n;return(0,h.jsx)(j6,{value:e.config.narrationPrompt??``,prompts:c,libraryLinks:!1,supported:e.config.audio?.provider===`inworld`&&e.config.audio.model===`inworld-tts-2`,error:r,onChange:t=>{let n=e.config.narrationPrompt||a.current;t===``&&(a.current=e.config.narrationPrompt);let r=c.find(e=>e.kind===`narration`&&e.name===t),o=r===void 0||t===n?e:N5(e,`narration`,r.body);i({...o,config:{...o.config,narrationPrompt:t}})}})}function jve({edit:e,saved:t=e.config.imagePrompts,prompts:n,entries:r,onChange:i}){let a=(0,m.useId)(),o=[...new Set([...Object.keys(e.config.rendered),...Object.keys(e.content.promptTemplates),...e.config.sources.article===`generate`?[`article`]:[],..._j(e.config)?[`narration`]:[],...bj(e.config)&&e.config.descriptionPrompt?[`description`]:[],...wj(e.config)&&e.config.shorts?.prompt?[`shorts`]:[],...wj(e.config)&&e.config.shorts?.imagePrompt?[`shortsImage`]:[],...[`from_prompt`,`prompt_by_llm`].includes(e.config.sources.thumbnail)?[`thumbnailPrompt`]:[],...Sj(e.config)&&e.config.reference?.source===`prompt`?[`referencePrompt`]:[],...e.config.intro===void 0?[]:[`intro`],...e.config.outro===void 0?[]:[`outro`]])].filter(n=>{let r=u7(n);if(r===void 0)return!0;let i=t[r]?.name;return i===void 0||e.config.imagePrompts.some(e=>e.name===i)}),s=e.config.imagePrompts.filter(e=>!t.some(t=>t.name===e.name)),c=e=>Pve(e,t),l=[...new Set([...Object.keys(e.config.values),...Object.values(e.content.promptTemplates).flatMap(e=>e===null?[]:pq(e).names)])],u=t=>[...pq(e.config.title).names.includes(t)?[`Project title`]:[],...Object.entries(e.content.promptTemplates).flatMap(([e,n])=>n!==null&&pq(n).names.includes(t)?[c(e)]:[])],d=pq(e.config.title).names;return(0,h.jsxs)(`section`,{"aria-label":`Prompt snapshots`,className:`space-y-6`,children:[o.map(o=>{let s=c(o),l=e.content.promptTemplates[o]??null,u=o===`intro`||o===`outro`?r.filter(e=>e.category===o):n.filter(t=>t.kind===(o===`article`?QA(e.config)?`script`:`article`:o===`narration`?`narration`:o===`description`?`description`:o===`shorts`?`shorts`:o===`thumbnailPrompt`?`thumbnail`:`image`));return(0,h.jsxs)(`div`,{className:`min-w-0 space-y-4 border-t border-line pt-6 first:border-t-0 first:pt-0`,children:[(0,h.jsx)(`h3`,{className:`m-0 text-title-3`,children:s}),l===null?(0,h.jsx)(fI,{tone:`info`,title:`Original template unavailable`,actions:(0,h.jsx)(L,{"aria-label":`Use saved wording as template for ${s}`,onClick:()=>i(N5(e,o,e.config.rendered[o]??``)),children:`Use saved wording as template`}),children:`The saved prompt below stays as it is until you choose or write a template.`}):null,(0,h.jsx)(Nve,{label:s,raw:l,library:Mve(e,o,u,t),onUse:t=>i(N5(e,o,t))}),(0,h.jsx)(Y,{label:`Use saved template for ${s}`,id:`${a}-library-${o}`,tip:`project.prompts.template`,children:(0,h.jsxs)(AV,{value:``,onChange:t=>{let n=u.find(e=>e.id===t.target.value);if(n===void 0)return;let r=N5(e,o,n.body),a=`category`in n?{...r.config,[n.category]:{name:n.name,mode:n.mode}}:o===`article`?{...r.config,articlePrompt:n.name}:o===`narration`?{...r.config,narrationPrompt:n.name}:o===`description`?{...r.config,descriptionPrompt:n.name}:(o===`shorts`||o===`shortsImage`)&&r.config.shorts!==void 0?{...r.config,shorts:{...r.config.shorts,[o===`shorts`?`prompt`:`imagePrompt`]:n.name}}:o===`thumbnailPrompt`?{...r.config,thumbnailPrompt:n.name}:o===`referencePrompt`&&r.config.reference!==void 0?{...r.config,reference:{...r.config.reference,prompt:n.name}}:r.config;i({...r,config:a})},children:[(0,h.jsx)(`option`,{value:``,children:`Choose a saved template`}),u.map(e=>(0,h.jsx)(`option`,{value:e.id,children:e.name},e.id))]})}),(0,h.jsx)(Y,{label:`Raw prompt for ${s}`,id:`${a}-raw-${o}`,tip:`project.prompts.raw`,children:(0,h.jsx)(kV,{rows:4,value:l??``,onChange:t=>i(N5(e,o,t.target.value))})}),(0,h.jsxs)(`details`,{children:[(0,h.jsx)(`summary`,{className:`text-small text-ink-2`,children:`Saved rendered prompt`}),(0,h.jsx)(`pre`,{className:`m-0 mt-2 whitespace-pre-wrap break-words text-small`,children:e.config.rendered[o]??``})]})]},o)}),s.length===0?null:(0,h.jsxs)(`p`,{className:`m-0 text-small text-ink-2`,children:[s.map(e=>`"${e.name}"`).join(`, `),` `,s.length===1?`uses its`:`use their`,` Library wording. Save, then change it here.`]}),l.length?(0,h.jsxs)(`section`,{"aria-label":`Keywords`,className:`space-y-3 pt-3`,children:[(0,h.jsx)(`h3`,{className:`m-0 text-title-3`,children:`Keywords`}),(0,h.jsx)(L0,{fieldPrefix:`config.values`,keywords:l.map(t=>({name:t,value:e.config.values[t]??``,feeds:u(t),topic:d.includes(t)})),onChange:(t,n)=>i(M5({...e,config:{...e.config,values:{...e.config.values,[t]:n}}}))})]}):null]})}function Mve(e,t,n,r){let{config:i}=e,a=u7(t),o=t===`article`?i.articlePrompt:t===`narration`?i.narrationPrompt:t===`description`?i.descriptionPrompt:t===`shorts`?i.shorts?.prompt:t===`shortsImage`?i.shorts?.imagePrompt:t===`thumbnailPrompt`?i.thumbnailPrompt:t===`referencePrompt`?i.reference?.prompt:a===void 0?void 0:r[a]?.name;if(o!==void 0&&o!==``)return n.find(e=>!(`category`in e)&&e.name===o)}function Nve({label:e,raw:t,library:n,onUse:r}){return n===void 0||t===null||n.body===t?null:(0,h.jsx)(fI,{tone:`info`,title:`The Library's "${n.name}" has changed since this project copied it`,actions:(0,h.jsx)(L,{"aria-label":`Use the Library version for ${e}`,onClick:()=>{r(n.body)},children:`Use the Library version`}),children:`The project still uses its own copy below.`})}function u7(e){let t=/^imagePrompts\.(\d+)$/.exec(e);return t?.[1]===void 0?void 0:Number(t[1])}function Pve(e,t){if(e===`article`)return`Article`;if(e===`narration`)return`Narration Preparation`;if(e===`description`)return`YouTube description`;if(e===`shorts`)return`Shorts`;if(e===`shortsImage`)return`Shorts image style`;if(e===`thumbnailPrompt`)return`Thumbnail`;if(e===`referencePrompt`)return`Establishing image`;if(e===`intro`)return`Intro`;if(e===`outro`)return`Outro`;let n=u7(e);if(n!==void 0){let e=t[n]?.name;return e===void 0||e===``?`Image prompt ${String(n+1)}`:`Image prompt "${e}"`}return e.replace(/[._-]/g,` `).replace(/([a-z])([A-Z])/g,`$1 $2`)}function Fve(e,t,n){let{api:r}=R(),[i,a]=(0,m.useState)({busy:!1}),{config:o}=t,s=o.audio,c=async()=>{if(s!==void 0){a({busy:!0});try{let i=await Ps(r,e),{sharedGlossary:c,...l}=o;n({...t,config:{...l,audio:{...s,shareGlossary:!0},...i.entries.length===0?{}:{sharedGlossary:i.entries}}}),a({busy:!1,projects:i.projects})}catch(e){a({busy:!1,error:e instanceof Error?e.message:String(e)})}}},l=()=>{if(s===void 0)return;let{sharedGlossary:e,...r}=o;n({...t,config:{...r,audio:{...s,shareGlossary:!1}}})},u=o.sharedGlossary?.length??0,d=s?.shareGlossary===!0?(0,h.jsxs)(`p`,{className:`flex flex-wrap items-center gap-2 text-label text-ink-2`,children:[i.error===void 0?u===0?`No pronunciations from other projects are copied yet.`:`${String(u)} ${u===1?`term`:`terms`} copied from ${i.projects===void 0?`your other projects`:`${String(i.projects)} other ${i.projects===1?`project`:`projects`}`}.`:`Couldn't read your other projects' pronunciations: ${i.error}`,(0,h.jsx)(L,{type:`button`,variant:`quiet`,disabled:i.busy,onClick:()=>void c(),children:i.busy?`Copying…`:`Update from other projects`}),(0,h.jsx)(B,{id:`project.edit.update-glossary`})]}):void 0;return{value:s?.shareGlossary===!0,onChange:e=>{e?c():l()},note:d}}function Ive(e,t){let{api:n}=R(),[r,i]=(0,m.useState)({busy:!1}),{config:a}=e,o=a.audio,s=async()=>{if(o!==void 0){i({busy:!0});try{let{aliases:r}=await Fs(n),{narrationAliases:s,...c}=a;t({...e,config:{...c,audio:{...o,useNarrationAliases:!0},...r.length===0?{}:{narrationAliases:r}}}),i({busy:!1})}catch(e){i({busy:!1,error:e instanceof Error?e.message:String(e)})}}},c=a.narrationAliases?.length??0;return{value:o?.useNarrationAliases===!0,onChange:n=>{if(o!==void 0){if(n)s();else{let{narrationAliases:n,...r}=a;t({...e,config:{...r,audio:{...o,useNarrationAliases:!1}}})}}},note:o?.useNarrationAliases===!0?(0,h.jsxs)(`p`,{className:`flex flex-wrap items-center gap-2 text-label text-ink-2`,children:[r.error===void 0?c===0?`No aliases are copied yet. Add some in Library → Aliases.`:`${String(c)} ${c===1?`alias`:`aliases`} copied from Library → Aliases.`:`Couldn't read Library → Aliases: ${r.error} Try Update from Library again.`,(0,h.jsx)(L,{type:`button`,variant:`quiet`,disabled:r.busy,onClick:()=>void s(),children:r.busy?`Copying…`:`Update from Library`}),(0,h.jsx)(B,{id:`project.edit.update-aliases`})]}):void 0}}function Lve({projectId:e,edit:t,providers:n,voices:r,onChange:i}){let{config:a}=t,o=a.llm??{provider:``,model:``},s=a.audio??{provider:``,model:``,voice:``},c=Fve(e,t,i),l=Ive(t,i),{api:u}=R(),d=M(Yb(u,a.channelId??`00000000-0000-4000-8000-000000000001`)),f=a.images??{provider:``,model:``},p=_j(a)||a.sources.audio===`generate`&&a.audio?.describeFigures===!0||a.sources.research===`generate`||a.sources.article===`generate`||a.sources.thumbnail===`prompt_by_llm`||ZA(a)&&a.voices?.source===`attribute`||a.sources.audio===`generate`&&(a.intro?.mode===`llm`||a.outro?.mode===`llm`),m=a.sources.images===`generate`||a.sources.thumbnail===`from_prompt`||a.sources.thumbnail===`prompt_by_llm`,g=r.filter(e=>e.provider===s.provider).map(e=>({value:e.voiceId,label:e.name}));return(0,h.jsxs)(`section`,{"aria-label":`Generation providers`,className:`grid min-w-0 gap-3 sm:grid-cols-2`,children:[p?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(HV,{label:`Text provider`,tip:`play.llm.provider`,family:`llm`,providers:n,value:o.provider,problem:void 0,onPick:e=>i({...t,config:{...a,llm:{provider:e,model:``}}})}),(0,h.jsx)(UV,{label:`Text model`,tip:`play.llm.model`,provider:o.provider,value:o.model,problem:void 0,onPick:e=>i({...t,config:{...a,llm:{...o,model:e}}})}),(0,h.jsx)(F6,{choice:o,onChange:e=>i({...t,config:{...a,llm:e}})})]}):null,a.sources.audio===`generate`?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(HV,{label:`Narration provider`,tip:`play.tts.provider`,family:`tts`,providers:n,value:s.provider,problem:void 0,onPick:e=>i({...t,config:{...a,audio:{...s,provider:e,model:``,voice:``}}})}),(0,h.jsx)(UV,{label:`Narration model`,tip:`play.tts.model`,provider:s.provider,value:s.model,problem:void 0,onPick:e=>i({...t,config:{...a,audio:{...s,model:e}}})}),(0,h.jsx)(zV,{label:`Narration voice`,tip:`play.voice`,value:s.voice,problem:void 0,placeholder:`Choose a saved voice`,options:s.voice!==``&&!g.some(e=>e.value===s.voice)?[{value:s.voice,label:`${s.voice} (saved voice)`},...g]:g,onPick:e=>i({...t,config:{...a,audio:{...s,voice:e}}})}),(0,h.jsx)(c6,{value:a.chunking??{mode:`whole`},onPick:e=>i({...t,config:{...a,chunking:e}})}),(0,h.jsx)(M6,{shared:c,value:s.usePronunciationGlossary,supported:kj({sources:a.sources,audio:{...s,usePronunciationGlossary:!0}}),onChange:e=>i({...t,config:{...a,audio:{...s,usePronunciationGlossary:e}}})}),(0,h.jsx)(A6,{...l}),(0,h.jsx)(O6,{tip:`project.edit.describe-figures`,value:s.describeFigures,skipCode:s.skipCode,onChange:({describeFigures:e,skipCode:n})=>{let{describeFigures:r,skipCode:o,...c}=s;i({...t,config:{...a,audio:{...c,...e?{describeFigures:e}:{},...e&&n?{skipCode:n}:{}}}})}}),(0,h.jsxs)(`section`,{"aria-label":`Speakers`,className:`col-span-full border-t border-line pt-3`,children:[(0,h.jsx)(`h3`,{className:`mb-2 text-small font-semibold`,children:`Speakers`}),(0,h.jsx)(D6,{value:a.voices,cast:d.data?.cast??[],language:a.language,providers:n,voices:r,script:t.content.articleMarkdown??void 0,onChange:e=>{let{voices:n,...r}=a;i({...t,config:e===void 0?r:{...r,voices:e}})}})]})]}):null,m?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(HV,{label:`Image provider`,tip:`play.images.provider`,family:`image`,providers:n,value:f.provider,problem:void 0,onPick:e=>i({...t,config:{...a,images:{provider:e,model:``}}})}),(0,h.jsx)(UV,{label:`Image model`,tip:`play.images.model`,provider:f.provider,value:f.model,problem:void 0,onPick:e=>i({...t,config:{...a,images:{...f,model:e}}})}),(0,h.jsx)(F6,{field:`images.thinking`,label:`Effort`,tip:`play.images.effort`,choice:f,onChange:e=>i({...t,config:{...a,images:e}})})]}):null]})}function Rve({edit:e,providers:t,prompts:n,problem:r,onChange:i}){let{config:a}=e,o=a.reviews===void 0?KV:Bk(a.reviews),[s,c]=(0,m.useState)(o),l=a.shorts?.enabled===!0&&a.sources.audio!==`off`,u=e=>Hk({sources:a.sources,shorts:l?{enabled:!0}:void 0},e),d=Vk(s,u).retriesProblem;return(0,h.jsx)(qV,{value:s,providers:t,prompts:n,makes:u,problem:e=>e===`reviews.retries`&&d!==void 0?d:r(e),onChange:t=>{c(t);let{settings:r}=Vk(t,u),o={...e.content.promptTemplates},s={...a.rendered};for(let e of Mk){let t=zk(e),i=r?.stages[e]?.prompt??``,c=n.find(e=>e.kind===`review`&&e.name===i);if(i===``){let{[t]:e,...n}=o,{[t]:r,...i}=s;o=n,s=i}else c!==void 0&&i!==(a.reviews?.stages[e]?.prompt??``)&&(o={...o,[t]:c.body})}let{reviews:l,...d}=a;i(M5({...e,config:{...d,rendered:s,...r===void 0?{}:{reviews:r}},content:{...e.content,promptTemplates:o}}))}})}function zve({edit:e,view:t,prompts:n,problem:r,onChange:i}){let a=t.revision.config.descriptionPrompt,o=t.revision.content.promptTemplates.description??t.revision.config.rendered.description,s=a&&o!==void 0&&!n.some(e=>e.kind===`description`&&e.name===a)?[...n,{id:`saved-description`,kind:`description`,name:a,body:o,slots:[],updatedAt:t.revision.createdAt}]:n,c=t.outputs.some(e=>e.selected&&e.workKey===d7&&e.state===`ready`),l=e.regenerate?.includes(d7)===!0;return(0,h.jsxs)(`div`,{className:`space-y-2`,children:[(0,h.jsx)(R6,{enabled:e.config.youtubeDescription===!0,prompt:e.config.descriptionPrompt??``,prompts:s,narrated:e.config.sources.audio!==`off`,problem:r,onChange:({youtubeDescription:t,descriptionPrompt:n})=>{let r=s.find(e=>e.kind===`description`&&e.name===n),a=n===(e.config.descriptionPrompt??``)?e:r===void 0?Bve(e):N5(e,`description`,r.body),{descriptionPrompt:o,...c}=a.config;i({...a,config:{...c,youtubeDescription:t,...n===``?{}:{descriptionPrompt:n}}})}}),c&&e.config.youtubeDescription===!0?l?(0,h.jsxs)(`p`,{className:`flex flex-wrap items-center gap-2 text-small text-accent-ink`,children:[`The YouTube description will be written again after you save and press Remake.`,(0,h.jsx)(L,{type:`button`,variant:`quiet`,onClick:()=>{i({...e,regenerate:(e.regenerate??[]).filter(e=>e!==d7)})},children:`Keep the current description`})]}):(0,h.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,h.jsx)(L,{type:`button`,onClick:()=>{i({...e,regenerate:[...new Set([...e.regenerate??[],d7])]})},children:`Write the description again after review`}),(0,h.jsx)(B,{id:`project.edit.rewrite-description`})]}):null]})}var d7=`youtube:description`;function Bve(e){let{description:t,...n}=e.content.promptTemplates,{description:r,...i}=e.config.rendered;return M5({config:{...e.config,rendered:i},content:{...e.content,promptTemplates:n}})}var Vve={research:`Research source`,article:`Article source`,audio:`Audio source`,images:`Images source`,thumbnail:`Thumbnail source`,video:`Video source`,document:`Document source`},Hve={research:`play.source.research`,article:`play.source.article`,audio:`play.source.audio`,images:`play.source.images`,thumbnail:`play.source.thumbnail`,video:`play.source.video`,document:`play.source.document`};function f7({title:e,children:t,columns:n=!0}){return(0,h.jsxs)(`div`,{className:`space-y-4`,children:[(0,h.jsx)(`h3`,{className:`m-0 text-title-3`,children:e}),(0,h.jsx)(`div`,{className:I(`grid min-w-0 gap-4`,n&&`md:grid-cols-2`),children:t})]})}function Uve(e){let{view:t,edit:n,onChange:r,onPending:i,fields:a}=e,o=(0,m.useId)(),[s,c]=(0,m.useState)(e.focus?.section??`inputs`);(0,m.useEffect)(()=>{e.focus!==void 0&&c(e.focus.section)},[e.focus]);let[l,u]=(0,m.useState)({font:!1,content:!1,music:!1});(0,m.useEffect)(()=>{i(l.font||l.content||l.music)},[i,l]);let d=(0,m.useCallback)(e=>{u(t=>t.font===e?t:{...t,font:e})},[]),f=(0,m.useCallback)(e=>{u(t=>t.content===e?t:{...t,content:e})},[]),p=(0,m.useCallback)(e=>{u(t=>t.music===e?t:{...t,music:e})},[]),{api:g}=R(),_=M(Zy(g)),v=M(Qy(g)),y=M($y(g)),b=M(eb(g)),{config:x}=n,S=kve(t,n,M(Yb(g,x.channelId??`00000000-0000-4000-8000-000000000001`)).data?.cast??[]),C=S?.image.kind===`output`?t.outputs.find(e=>e.selected&&e.available&&S.image.kind===`output`&&e.output.id===S.image.outputId):void 0,w=C===void 0?void 0:E2(g,t.revision.projectId,t.revision.id,C.recordId),T=e=>a.find(t=>t.field===e||t.field===`config.${e}`||t.field===`edit.config.${e}`)?.message,E=z6({value:x.videoEdit,narrated:x.sources.audio!==`off`,imageProvider:x.images?.provider??``,problem:T,language:x.language,onChange:e=>r({...n,config:{...x,videoEdit:e}})}),D=[{id:`inputs`,label:`Inputs`},{id:`article`,label:`Article`,...n.content.articleEdited?{badge:`edited`}:{}},{id:`providers`,label:`Providers`},{id:`prompts`,label:`Prompts`},{id:`reviews`,label:`Reviews`,...x.reviews===void 0?{}:{badge:`on`}},...x.sources.audio!==`off`||x.shorts?.enabled===!0?[{id:`shorts`,label:`Shorts`,...x.shorts?.enabled?{badge:`on`}:{}}]:[],{id:`subtitles`,label:`Subtitles`},{id:`images`,label:`Images`,badge:String(n.content.imageOrder.length)},...x.sources.audio===`generate`?[{id:`narration`,label:`Narration`}]:[],{id:`captions`,label:`Captions`,...n.content.subtitleCues===void 0?{}:{badge:String(n.content.subtitleCues.cues.length)}}],O=D.some(e=>e.id===s)?s:`inputs`,k=e=>I(`min-w-0 space-y-6`,O===e?void 0:`hidden`),ee=e=>Number.isFinite(e)?e:``,te=x.sources.video!==`off`;return(0,h.jsxs)(`div`,{className:`grid min-w-0 gap-8 md:grid-cols-[180px_minmax(0,1fr)]`,children:[(0,h.jsx)(`nav`,{"aria-label":`Edit sections`,className:`min-w-0 md:sticky md:top-16 md:self-start`,children:(0,h.jsx)(`ul`,{className:`m-0 flex list-none gap-1 overflow-x-auto p-0 [scrollbar-width:none] md:flex-col`,children:D.map(e=>(0,h.jsx)(`li`,{className:`shrink-0`,children:(0,h.jsx)(m8,{current:e.id===O,onClick:()=>c(e.id),meta:e.badge,className:`whitespace-nowrap`,children:e.label})},e.id))})}),(0,h.jsxs)(`div`,{className:`min-w-0 space-y-6`,children:[Object.entries({providers:_.error,voices:v.error,prompts:y.error,entries:b.error}).flatMap(([e,t])=>t===null?[]:[(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-small text-danger`,children:t.message},e)]),a.length===0?null:(0,h.jsx)(`ul`,{role:`alert`,className:`m-0 space-y-1 pl-5 text-small text-danger`,children:a.map(e=>(0,h.jsx)(`li`,{children:e.message},`${e.field}-${e.message}`))}),(0,h.jsxs)(`section`,{"aria-label":`Inputs`,hidden:O!==`inputs`,className:k(`inputs`),children:[(0,h.jsxs)(f7,{title:`Project`,children:[(0,h.jsx)(Y,{label:`Project title`,error:T(`title`),className:`md:col-span-2`,children:(0,h.jsx)(OV,{value:x.title,maxLength:200,onChange:e=>r({...n,config:{...x,title:e.target.value}})})}),(0,h.jsx)(`div`,{className:`md:col-span-2`,children:(0,h.jsx)(r8,{value:x.format,onPick:e=>r({...n,config:{...x,format:e}})})})]}),(0,h.jsx)(Nq,{}),(0,h.jsx)(f7,{title:`Channel`,columns:!1,children:(0,h.jsx)(Ove,{edit:n,saved:t.revision.config,problem:T,onChange:r})}),(0,h.jsx)(Nq,{}),(0,h.jsxs)(f7,{title:`Stages`,children:[MS.map(e=>(0,h.jsx)(Y,{label:Vve[e],tip:Hve[e],error:T(`sources.${e}`),children:(0,h.jsx)(AV,{value:FS(x.sources,e),onChange:i=>{let a=VN(e).find(e=>e.value===i.target.value);if(a===void 0)return;let o=g_e(n,e,a.value);r(e===`article`&&a.value===`provide`&&!n.content.articleEdited?{...o,content:{...o.content,articleMarkdown:t.articleMarkdown??n.content.articleMarkdown}}:o)},children:VN(e).map(t=>(0,h.jsx)(`option`,{value:t.value,disabled:e===`video`&&t.value===`generate`&&x.sources.images===`off`,children:t.label},t.value))})},e)),x.sources.images===`off`?(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2 md:col-span-2`,children:`Images are Off. Video is also Off in these changes.`}):null,(0,h.jsx)(Y,{label:`Document theme`,id:`${o}-document-theme`,tip:`play.document-theme`,children:(0,h.jsx)(o6,{id:`${o}-document-theme`,disabled:FS(x.sources,`document`)===`off`,value:x.document,onChange:e=>{r({...n,config:{...x,document:e}})}})})]}),(0,h.jsx)(Nq,{}),(0,h.jsxs)(f7,{title:`Timing`,children:[(0,h.jsx)(Y,{label:`Silence gap (seconds)`,tip:`play.silence-gap`,error:T(`silenceGapSeconds`),children:(0,h.jsx)(OV,{type:`number`,min:0,max:30,step:.1,value:ee(x.silenceGapSeconds),onChange:e=>r({...n,config:{...x,silenceGapSeconds:Number(e.target.value)}})})}),x.sources.audio===`off`?null:(0,h.jsx)(Y,{label:`Silence at start and end (seconds)`,tip:`play.edge-silence`,error:T(`edgeSilenceSeconds`),children:(0,h.jsx)(OV,{type:`number`,min:0,max:30,step:.5,value:ee(x.edgeSilenceSeconds),onChange:e=>r({...n,config:{...x,edgeSilenceSeconds:Number(e.target.value)}})})}),te?(0,h.jsx)(Y,{label:`Seconds per image`,tip:`play.image-seconds`,error:T(`imageSeconds`),children:(0,h.jsx)(OV,{type:`number`,min:1,max:600,step:1,value:ee(x.imageSeconds),onChange:e=>r({...n,config:{...x,imageSeconds:Number(e.target.value)}})})}):null,te?(0,h.jsx)(Y,{label:`Zoom (%)`,tip:`play.zoom`,error:T(`zoomPercent`),children:(0,h.jsx)(OV,{type:`number`,min:0,max:50,step:.5,value:ee(x.zoomPercent),onChange:e=>r({...n,config:{...x,zoomPercent:Number(e.target.value)}})})}):null,te?(0,h.jsx)(Y,{label:`Motion`,tip:`play.motion`,children:(0,h.jsx)(AV,{value:x.motionStyle,onChange:e=>r({...n,config:{...x,motionStyle:e.target.value}}),children:IS.map(e=>(0,h.jsx)(`option`,{value:e,children:ij[e]},e))})}):null]}),te?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(Nq,{}),(0,h.jsxs)(f7,{title:`Cuts and look`,columns:!1,children:[E.cuts,E.look,x.sources.audio===`generate`&&x.audio?.describeFigures===!0?(0,h.jsx)(k6,{tip:`project.edit.show-figures`,value:x.showFigures,onChange:e=>{let{showFigures:t,...i}=x;r({...n,config:e?{...i,showFigures:!0}:i})}}):null]}),x.sources.audio===`off`?null:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(Nq,{}),(0,h.jsx)(f7,{title:`Ambient sound`,columns:!1,children:(0,h.jsx)(dve,{edit:n,problem:T,onChange:r})})]})]}):null,x.sources.audio===`off`?null:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(Nq,{}),(0,h.jsxs)(f7,{title:`Pauses and volume`,columns:!1,children:[(0,h.jsx)(pve,{edit:n,problem:T,onChange:r}),(0,h.jsx)(fve,{edit:n,problem:T,onChange:r})]})]}),(0,h.jsx)(Nq,{}),(0,h.jsx)(f7,{title:`Intro and outro`,children:[`intro`,`outro`].map(e=>(0,h.jsx)(Y,{label:e===`intro`?`Intro`:`Outro`,tip:e===`intro`?`play.intro`:`play.outro`,children:(0,h.jsxs)(AV,{value:x[e]?.name??``,onChange:t=>{let i=b.data?.entries.find(n=>n.category===e&&n.name===t.target.value),a={...x};i===void 0?delete a[e]:a[e]={name:i.name,mode:i.mode},r(M5({...n,config:a,content:i===void 0?n.content:{...n.content,promptTemplates:{...n.content.promptTemplates,[e]:i.body}}}))},children:[(0,h.jsx)(`option`,{value:``,children:`Off`}),x[e]!==void 0&&!b.data?.entries.some(t=>t.category===e&&t.name===x[e]?.name)?(0,h.jsxs)(`option`,{value:x[e]?.name,children:[x[e]?.name,` (saved entry)`]}):null,b.data?.entries.filter(t=>t.category===e).map(e=>(0,h.jsx)(`option`,{value:e.name,children:e.name},e.id))]})},e))}),x.sources.research===`provide`?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(Nq,{}),(0,h.jsx)(f7,{title:`Research`,columns:!1,children:(0,h.jsx)(Y,{label:`Research notes`,tip:`play.provided.research`,error:T(`provided.research`),children:(0,h.jsx)(kV,{rows:6,value:x.provided.research??``,onChange:e=>r({...n,config:{...x,provided:{...x.provided,research:e.target.value}}})})})})]}):null]}),(0,h.jsxs)(`section`,{"aria-label":`Article`,hidden:O!==`article`,className:k(`article`),children:[(0,h.jsx)(Y,{label:`Article text`,tip:`project.edit.article-text`,error:T(`content.articleMarkdown`)??T(`provided.article`),help:n.content.articleEdited?`Your edited article is kept when other settings change. Regenerating it replaces it after the rebuild review.`:void 0,children:(0,h.jsx)(kV,{rows:12,maxLength:5e5,value:(n.content.articleEdited?n.content.articleMarkdown:t.articleMarkdown)??n.content.articleMarkdown??x.provided.article??``,onChange:e=>r({...n,content:{...n.content,articleMarkdown:e.target.value,articleEdited:!0}})})}),x.sources.article===`generate`?(0,h.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,h.jsx)(L,{onClick:()=>r({...n,regenerate:[...new Set([...n.regenerate??[],`article:body`])]}),children:`Regenerate article after review`}),(0,h.jsx)(B,{id:`project.edit.regenerate-article`})]}):null]}),(0,h.jsxs)(`section`,{"aria-label":`Providers`,hidden:O!==`providers`,className:k(`providers`),children:[(0,h.jsx)(Dve,{edit:n,error:T(`language`),onChange:r}),(0,h.jsx)(Lve,{projectId:t.revision.projectId,edit:n,providers:_.data?.providers??[],voices:v.data?.voices??[],onChange:r}),(0,h.jsx)(Ave,{edit:n,view:t,prompts:y.data?.prompts??[],error:T(`narrationPrompt`),onChange:r})]}),(0,h.jsxs)(`section`,{"aria-label":`Prompts`,hidden:O!==`prompts`,className:k(`prompts`),children:[(0,h.jsx)(zve,{edit:n,view:t,prompts:y.data?.prompts??[],problem:T,onChange:r}),(0,h.jsx)(jve,{edit:n,saved:t.revision.config.imagePrompts,prompts:y.data?.prompts??[],entries:b.data?.entries??[],onChange:r})]}),(0,h.jsx)(`section`,{"aria-label":`Reviews`,hidden:O!==`reviews`,className:k(`reviews`),children:(0,h.jsx)(Rve,{edit:n,providers:_.data?.providers??[],prompts:y.data?.prompts??[],problem:T,onChange:r})}),(0,h.jsx)(`section`,{"aria-label":`Shorts`,hidden:O!==`shorts`,className:k(`shorts`),children:(0,h.jsx)(y_e,{edit:n,view:t,prompts:y.data?.prompts??[],problem:T,onChange:r,onPending:p})}),(0,h.jsxs)(`section`,{"aria-label":`Subtitles`,hidden:O!==`subtitles`,className:k(`subtitles`),children:[(0,h.jsx)(`div`,{"data-tour":`project-subtitles`,children:(0,h.jsx)(n8,{value:x.subtitles??xM,format:x.format,audioEnabled:x.sources.audio!==`off`,videoEnabled:te,onChange:e=>r({...n,config:{...x,subtitles:PN(e,x.sources)}}),onUploading:d,problem:T})}),O!==`subtitles`||!te?null:(0,h.jsx)(U6,{drawnOn:S?.drawnOn,poster:w,settings:{format:x.format,subtitles:{mode:(x.subtitles??xM).mode,fontId:(x.subtitles??xM).fontId,fontSize:(x.subtitles??xM).fontSize,position:(x.subtitles??xM).position??`bottom`},videoEdit:x.videoEdit,image:S?.image}})]}),e.renderContent?.({view:t,edit:n,fields:a,onChange:r,onPending:f,section:O})]})]})}var p7={notes:`Research notes`,article_md:`Article (Markdown)`,article_txt:`Article text`,narration_txt:`Clean Narration`,tts_script:`TTS Script`,sources:`Research sources`,glossary:`Glossary`,audio_body:`Narration`,audio_intro:`Intro narration`,audio_outro:`Outro narration`,audio_export:`Audio export`,image:`Image`,thumbnail:`Thumbnail`,video:`Video`,render_params:`Export settings`,subtitles_srt:`Subtitles (SRT)`,subtitles_vtt:`Subtitles (VTT)`,subtitle_words:`Subtitle timing`,subtitle_ass:`Styled subtitles`,subtitle_font:`Subtitle font`,instructions:`Generation instructions`,document_pdf:`Document (PDF)`,youtube_description:`YouTube description`,youtube_tags:`YouTube tags`,shorts:`Shorts list`,short_image:`Short image`,short_video:`Short`,animated_image:`Animated image`,figure_card:`On-screen card`,reference:`Establishing image (reference)`,script_md:`Script (speaker split)`,audio_mp3:`Audio (MP3 with chapters)`,audio_m4b:`Audiobook (M4B with chapters)`,audio_levelled:`Levelled narration`};function m7(e){return(e.role===`narration_txt`||e.role===`tts_script`)&&e.meta.segment?`${e.meta.segment===`body`?`Body`:e.meta.segment===`intro`?`Intro`:`Outro`} ${p7[e.role]}`:e.role===`short_video`&&typeof e.meta.short==`number`?`Short ${String(e.meta.short)}`:e.role===`short_image`&&typeof e.meta.short==`number`?`Short ${String(e.meta.short)} image ${String(e.meta.index??1)}`:e.role===`figure_card`&&typeof e.meta.index==`number`?`On-screen card ${String(e.meta.index)}`:e.role===`animated_image`&&typeof e.meta.index==`number`?`Animated image ${String(e.meta.index)}`:e.role===`image`&&typeof e.meta.index==`number`?`Image ${e.meta.index}`:p7[e.role]}function Wve(e){if(e.startsWith(`image:`))return`Image`;if(e.startsWith(`animate:`))return p7.animated_image;if(/^shorts:\d+:render$/.test(e))return p7.short_video;if(/^shorts:\d+:image:\d+$/.test(e))return p7.short_image;if(e===`document:pdf`)return p7.document_pdf;let t=e.split(`:`).at(-1);return Object.entries(p7).find(([e])=>e===t)?.[1]??`Saved output`}function Gve({preview:e,pending:t,feedback:n,onStart:r,onCancel:i}){let a=Zve(e),[o,s]=(0,m.useState)([]),[c,l]=(0,m.useState)(!1),u=(0,m.useId)(),d=e.work.filter(e=>e.disposition===`blocked`),f=e.providedReuseRequired.filter(e=>!o.includes(e)),p=e.work.filter(e=>e.disposition===`generate`||e.disposition===`local`||e.disposition===`review`).length,g=p===1?`Remake 1 output`:`Remake ${String(p)} outputs`,_=[...d.length===0?[]:[`${d.length===1?`1 item is`:`${d.length} items are`} unavailable (reasons above)`],...f.map(e=>`tick “Keep the provided content for ${a(e)}”`),...e.costs.unknown===0||c?[]:[`tick “I understand that ${e.costs.unknown} cost estimates are unknown”`]],v=_.length===0,y=qve.map(t=>({disposition:t,count:e.work.filter(e=>e.disposition===t).length})).filter(e=>e.count>0),b=e.costs.rows.some(e=>e.onPlan===!0),x=e.costs.apiLow,S=e.costs.apiHigh;return(0,h.jsxs)(`section`,{"aria-label":`Review affected rebuild`,className:`flex flex-col gap-5`,children:[(0,h.jsxs)(`dl`,{className:`m-0 grid grid-cols-2 gap-x-6 gap-y-3 sm:grid-cols-3`,children:[y.map(e=>(0,h.jsxs)(`div`,{className:`flex flex-col`,children:[(0,h.jsx)(`dt`,{className:`order-2 text-small text-ink-2`,children:y7[e.disposition]}),(0,h.jsx)(`dd`,{className:`order-1 m-0 font-condensed text-title-2 tabular-nums`,children:e.count})]},e.disposition)),(0,h.jsxs)(`div`,{className:`flex flex-col`,children:[(0,h.jsx)(`dt`,{className:`order-2 text-small text-ink-2`,children:e.costs.unknown>0?`known cost`:`cost`}),(0,h.jsx)(`dd`,{className:`order-1 m-0 font-condensed text-title-2 tabular-nums`,children:v7(e.costs.low,e.costs.high)})]})]}),b?(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:`CLI work: $0 on your plan${x===void 0||S===void 0?``:` · ~${v7(x,S)} via API`}.`}):null,d.length===0?null:(0,h.jsx)(fI,{tone:`danger`,title:`${d.length===1?`1 item can’t`:`${d.length} items can’t`} run, so this rebuild can’t start`,children:(0,h.jsx)(`ul`,{className:`m-0 flex flex-col gap-1 pl-5`,children:Jve(d,a).map(e=>(0,h.jsxs)(`li`,{children:[(0,h.jsxs)(`span`,{className:`font-semibold`,children:[e.what,`:`]}),` `,e.reason]},e.reason))})}),e.wholeRequestNotice===null?null:(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:e.wholeRequestNotice}),e.warnings.map(e=>(0,h.jsx)(`p`,{className:`m-0 text-small text-waiting`,children:e},e)),(0,h.jsxs)(`div`,{className:`flex flex-col divide-y divide-line border-y border-line`,children:[e.review?.inputChanges.length?(0,h.jsx)(h7,{summary:`Changed inputs (${String(e.review.inputChanges.length)})`,children:(0,h.jsx)(`dl`,{className:`m-0 flex flex-col gap-3`,children:e.review.inputChanges.map(e=>(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`dt`,{className:`font-semibold`,children:e.label}),(0,h.jsxs)(`dd`,{className:`m-0 grid gap-2 sm:grid-cols-2`,children:[(0,h.jsx)(g7,{label:`Before`,text:e.before}),(0,h.jsx)(g7,{label:`After`,text:e.after})]})]},e.label))})}):null,(0,h.jsxs)(h7,{summary:`Work items (${e.work.length}): ${y.map(e=>`${e.count} ${y7[e.disposition]}`).join(`, `)||`none`}`,children:[e.changedInputs.length===0?null:(0,h.jsx)(`ul`,{className:`m-0 mb-3 flex flex-col gap-1 pl-5`,children:e.changedInputs.map(e=>(0,h.jsxs)(`li`,{children:[a(e.path),`:`,` `,e.after===null?`Removed`:e.before===null?`New output`:`Inputs changed`]},e.path))}),(0,h.jsx)(`ul`,{className:`m-0 flex flex-col gap-2 pl-5`,children:e.work.map(t=>(0,h.jsxs)(`li`,{children:[a(t.key),`: `,y7[t.disposition],`. `,t.reason,t.inflight?` An already submitted request may still be billed.`:``,e.review?.requests.filter(e=>e.key===t.key).map(e=>(0,h.jsxs)(`div`,{children:[e.settings===null?null:(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:e.settings}),e.text===null?null:(0,h.jsxs)(`details`,{children:[(0,h.jsx)(`summary`,{className:`cursor-pointer text-small`,children:`View request text`}),(0,h.jsx)(`pre`,{className:`m-0 max-h-56 overflow-auto whitespace-pre-wrap break-words font-mono text-small`,children:e.text})]})]},e.key))]},t.key))}),(0,h.jsxs)(`p`,{className:`m-0 mt-3 text-small text-ink-2`,children:[`Retained outputs:`,` `,e.retained.map(e=>Wve(e.slot)).join(`, `)||`None`]})]}),e.costs.rows.length===0?null:(0,h.jsx)(h7,{summary:`Cost by step`,children:(0,h.jsx)(`ul`,{className:`m-0 flex flex-col gap-1 pl-5`,children:e.costs.rows.map(e=>(0,h.jsxs)(`li`,{children:[a(e.stage),`: `,Kve(e),`. `,e.detail]},`${e.stage}-${e.detail}`))})})]}),n,(0,h.jsxs)(`div`,{className:`sticky bottom-[-16px] -mx-4 flex flex-col gap-3 border-t border-line bg-raised px-4 py-3`,children:[e.providedReuseRequired.length===0&&e.costs.unknown===0?null:(0,h.jsxs)(`div`,{className:`flex flex-col gap-2 text-small`,children:[e.providedReuseRequired.map(e=>(0,h.jsxs)(`div`,{className:`flex items-start gap-1`,...Tb,children:[(0,h.jsxs)(`label`,{className:`flex items-start gap-2`,children:[(0,h.jsx)(`input`,{type:`checkbox`,className:`mt-1`,disabled:t,checked:o.includes(e),onChange:t=>s(t.target.checked?[...o,e]:o.filter(t=>t!==e))}),(0,h.jsxs)(`span`,{children:[`Keep the provided content for `,a(e)]})]}),(0,h.jsx)(B,{id:`project.rebuild.keep-provided`,className:`-my-1`})]},e)),e.costs.unknown===0?null:(0,h.jsxs)(`div`,{className:`flex items-start gap-1`,...Tb,children:[(0,h.jsxs)(`label`,{className:`flex items-start gap-2`,children:[(0,h.jsx)(`input`,{type:`checkbox`,className:`mt-1`,disabled:t,checked:c,onChange:e=>l(e.target.checked)}),(0,h.jsxs)(`span`,{children:[`I understand that `,e.costs.unknown,` cost estimates are unknown.`]})]}),(0,h.jsx)(B,{id:`project.rebuild.unknown-costs`,className:`-my-1`})]})]}),(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,h.jsx)(L,{variant:`primary`,disabled:t||!v,"aria-describedby":v?void 0:u,onClick:()=>r({acknowledgeUnknownCosts:c,confirmedProvidedWorkKeys:o}),children:t?`Starting the remake…`:g}),(0,h.jsx)(L,{disabled:t,onClick:i,children:`Keep things as they are`}),v||t?null:(0,h.jsx)(`p`,{id:u,className:`m-0 min-w-0 text-small text-ink-2`,children:`${g} is off until: ${_.join(`; `)}.`})]})]})]})}function h7({summary:e,children:t}){return(0,h.jsxs)(`details`,{className:`py-3 text-small`,children:[(0,h.jsx)(`summary`,{className:`cursor-pointer font-semibold text-ink`,children:e}),(0,h.jsx)(`div`,{className:`mt-3`,children:t})]})}function g7({label:e,text:t}){return(0,h.jsxs)(`div`,{className:`min-w-0`,children:[(0,h.jsx)(`span`,{className:`text-small text-ink-2`,children:e}),(0,h.jsx)(`pre`,{className:`m-0 max-h-40 overflow-auto whitespace-pre-wrap break-words text-small`,children:t??`Not set`})]})}var _7=e=>e===null?`Unknown`:e===0?`$0`:new Intl.NumberFormat(`en-US`,{style:`currency`,currency:`USD`,maximumFractionDigits:e>0&&e<.01?4:2}).format(e);function v7(e,t){return e===t?_7(e):`${_7(e)}–${_7(t)}`}function Kve(e){return e.onPlan===!0?`$0 on plan${e.apiLow===void 0||e.apiLow===null||e.apiHigh===void 0?``:` · ~${v7(e.apiLow,e.apiHigh??null)} via API`}`:v7(e.low,e.high)}var qve=[`generate`,`local`,`review`,`reuse`,`blocked`];function Jve(e,t){let n=new Map;for(let t of e){let e=t.reason.trim()||`No reason was given.`;n.set(e,[...n.get(e)??[],t.key])}return[...n].map(([e,n])=>({reason:e,what:n.length===1?t(n[0]??``):`${n.length} ${new Set(n.map(b7)).size===1?Yve(b7(n[0]??``)):`items`}`}))}function Yve(e){return/s$/u.test(e)?e:`${e.charAt(0).toLowerCase()}${e.slice(1)}s`}var y7={reuse:`kept as they are`,generate:`to make`,local:`built on this computer`,review:`to confirm`,blocked:`can't run`},Xve={"export:wav":`Audio export (WAV)`,"export:video":`Video export`,"subtitles:timing":`Subtitle timing`,"subtitles:cues":`Caption text and timing`,"subtitles:files":`Subtitle files`,"article:body":`Article`,"audio:provided":`Provided narration`,"audio:body:concat":`Combined narration`,"audio:intro":`Combined intro narration`,"audio:outro":`Combined outro narration`,"research:planner":`Research plan`,"research:notes":`Research notes`,"entry:intro:text":`Intro text`,"entry:outro:text":`Outro text`};function b7(e){let t=Xve[e];return t===void 0?{image:`Image request`,images:`Images`,audio:`Narration request`,article:`Article`,research:`Research`,thumbnail:`Thumbnail`,subtitles:`Subtitles`,video:`Video export`,export:`Export`,entry:`Intro or outro`}[e.split(`:`)[0]??``]??`Output`:t}function Zve(e){let t=new Map,n=new Map;for(let t of e.work){let e=b7(t.key);n.set(e,(n.get(e)??0)+1)}let r=new Map;for(let i of e.work){let e=b7(i.key),a=(r.get(e)??0)+1;r.set(e,a),t.set(i.key,(n.get(e)??0)>1?`${e} ${a}`:e)}for(let n of e.review?.requests??[])t.set(n.key,n.label);return e=>t.get(e)??b7(e)}var Qve={llm:`Text generation`,image:`Images`,images:`Images`,tts:`Audio`,audio:`Audio`};function x7({error:e,refusal:t}){let n=(0,m.useRef)(null);return(0,m.useEffect)(()=>{(e!==void 0||t!==void 0)&&n.current?.focus()},[e,t]),e===void 0&&t===void 0?null:(0,h.jsxs)(`div`,{ref:n,role:`alert`,tabIndex:-1,"data-tone":`danger`,className:`sl-callout sl-callout--danger outline-none`,children:[(0,h.jsx)(Lc,{"aria-hidden":`true`,strokeWidth:1.75}),(0,h.jsx)(`p`,{className:`sl-callout__title m-0`,children:e??(t?.reason===`readiness`?t.fields.length>0?`This can't start yet. Fix the items below, then try again.`:`Slopify couldn't check your providers. Open Settings → Providers, make sure each one you use is set up, then try again.`:t?.message)}),t?.fields.length?(0,h.jsx)(`ul`,{className:`sl-callout__body m-0 list-disc pl-5`,children:t.fields.map(({field:e,message:t})=>(0,h.jsxs)(`li`,{children:[Qve[e.split(`.`)[0]??``]??`Project`,`: `,t]},`${e}:${t}`))}):null]})}var $ve=K({text:U().optional(),logicalText:U().optional(),title:U().optional(),notes:U().optional(),outline:G(U()).optional(),prompt:U().optional()});function eye(e){if(e===null)return`No text was recorded for this part.`;try{let t=$ve.safeParse(JSON.parse(e));if(!t.success)return`Recorded text cannot be decoded.`;let{logicalText:n,text:r,title:i,notes:a,outline:o,prompt:s}=t.data;return[n,r,a?.trim()?[i,a].filter(e=>e?.trim()).join(`
303
303
 
304
304
  `):void 0,o?.filter(e=>e.trim()).map((e,t)=>`${t+1}. ${e}`).join(`
305
- `),s].find(e=>e?.trim())??`No text was recorded for this part.`}catch{return`Recorded text cannot be decoded.`}}function eye({projectId:e,pending:t,onRestore:n}){let{api:r}=R(),[i,a]=(0,m.useState)(),o=M({queryKey:z.revisions(e),queryFn:async()=>{let t=await Tde(r,e);if(!t.ok)throw Error(t.message);return t.value.revisions}}),s=M({queryKey:z.revision(e,i??``),enabled:i!==void 0,queryFn:async()=>{if(i===void 0)throw Error(`Choose a version from History first.`);let t=await w2(r,e,i);if(!t.ok)throw Error(t.message);return t.value.view}}),c=s.data,l=c?.outputs.find(e=>e.selected&&e.available&&(e.output.role===`image`||e.output.role===`thumbnail`)),u=l??c?.outputs.find(e=>e.available);return(0,h.jsxs)(`section`,{"aria-label":`Project history`,className:`space-y-3`,children:[(0,h.jsx)(V,{title:`Project history`}),o.error===null?null:(0,h.jsx)(`p`,{role:`alert`,children:o.error.message}),(0,h.jsx)(`ol`,{className:`space-y-2`,children:o.data?.map(e=>(0,h.jsx)(`li`,{children:(0,h.jsxs)(L,{type:`button`,onClick:()=>a(e.id),children:[e.title,` · `,e.createdAt,e.current?` · Current`:``]})},e.id))}),s.error===null?null:(0,h.jsx)(`p`,{role:`alert`,children:s.error.message}),c===void 0?null:(0,h.jsxs)(`div`,{className:`space-y-3`,children:[(0,h.jsx)(`h3`,{className:`m-0 text-title-3`,children:c.revision.config.title}),(0,h.jsxs)(Ty,{children:[(0,h.jsx)(L,{variant:`primary`,disabled:t,onClick:()=>n(c.revision.id),children:`Restore this revision`}),l===void 0?null:(0,h.jsxs)(dS,{href:Ade(r,e,c.revision.id),download:!0,children:[(0,h.jsx)(pc,{"aria-hidden":`true`,strokeWidth:1.75}),`Download all images`]}),u===void 0?null:(0,h.jsx)(k2,{projectId:e,asset:``,folder:{revisionId:c.revision.id,recordId:u.recordId}})]}),(0,h.jsx)(`ul`,{className:`m-0 list-none space-y-3 p-0`,children:c.outputs.map(t=>(0,h.jsxs)(`li`,{className:`space-y-2 border-t border-line pt-3 first:border-t-0 first:pt-0`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-4 gap-y-2`,children:[(0,h.jsxs)(`span`,{className:`min-w-0`,children:[(0,h.jsx)(`span`,{className:`font-semibold text-ink`,children:m7(t.output)}),(0,h.jsxs)(`span`,{className:`text-small text-ink-2`,children:[` · ${t.state}${t.selected?``:` · Earlier result`}`,t.available?``:` · File missing`]})]}),t.available?(0,h.jsxs)(dS,{href:E2(r,e,c.revision.id,t.recordId),download:!0,size:`small`,"aria-label":`Download ${m7(t.output)}`,children:[(0,h.jsx)(pc,{"aria-hidden":`true`,strokeWidth:1.75}),`Download`]}):null]}),t.available?(0,h.jsxs)(`details`,{children:[(0,h.jsx)(`summary`,{children:`Preview retained output`}),t.output.role===`video`?(0,h.jsx)(i2,{className:`max-w-[640px]`,label:m7(t.output),src:E2(r,e,c.revision.id,t.recordId)}):[`audio_export`,`audio_body`,`audio_intro`,`audio_outro`].includes(t.output.role)?(0,h.jsx)(Q8,{label:m7(t.output),src:E2(r,e,c.revision.id,t.recordId)}):t.output.role===`image`||t.output.role===`thumbnail`?(0,h.jsx)(a2,{className:`max-w-[480px]`,alt:m7(t.output),title:m7(t.output),meta:t.selected?`Current`:`Earlier result`,src:E2(r,e,c.revision.id,t.recordId)}):(0,h.jsx)(`p`,{children:`Use Download to inspect this retained file.`})]}):null]},t.recordId))}),(0,h.jsx)(`ul`,{"aria-label":`Retained narration parts`,children:c.pieces.filter(e=>e.stageKind===`audio`&&e.assetId!==null).map(t=>(0,h.jsxs)(`li`,{children:[`Narration part `,t.piece.idx,t.selected?``:` · Earlier result`,t.available?(0,h.jsxs)(`details`,{children:[(0,h.jsx)(`summary`,{children:`Preview retained audio part`}),(0,h.jsx)(Q8,{label:`Narration part ${String(t.piece.idx)}`,src:E2(r,e,c.revision.id,t.recordId)}),(0,h.jsxs)(dS,{href:E2(r,e,c.revision.id,t.recordId),download:!0,size:`small`,children:[(0,h.jsx)(pc,{"aria-hidden":`true`,strokeWidth:1.75}),`Download narration part`]})]}):(0,h.jsx)(`span`,{children:` · File missing`})]},t.recordId))}),(0,h.jsx)(`ul`,{"aria-label":`Retained text parts`,children:c.pieces.filter(e=>e.assetId===null).map(e=>(0,h.jsx)(`li`,{children:(0,h.jsxs)(`details`,{children:[(0,h.jsxs)(`summary`,{children:[e.stageKind,` part `,e.piece.idx]}),(0,h.jsx)(`pre`,{className:`whitespace-pre-wrap break-words`,children:$ve(e.piece.payload)})]})},e.recordId))})]})]})}function S7(e,t,n){let r=JSON.stringify(t);return e?.payload===r?e:{payload:r,idempotencyKey:n()}}function tye(e,t,n={}){let{api:r}=R(),i=_(),a=M({queryKey:z.revision(e,t??``),enabled:t!==null,queryFn:async()=>{if(t===null)throw Error(`This project has no saved settings to show yet. Reload the page and try again.`);let n=await w2(r,e,t);if(!n.ok)throw Error(n.message);return n.value.view}}),[o,s]=(0,m.useState)(),[c,l]=(0,m.useState)(),[u,d]=(0,m.useState)(),[f,p]=(0,m.useState)(),[h,g]=(0,m.useState)(!1),[v,y]=(0,m.useState)(!1),[b,x]=(0,m.useState)(),[S,C]=(0,m.useState)(),w=(0,m.useRef)(void 0),T=(0,m.useRef)(void 0),E=(0,m.useRef)(void 0),D=(0,m.useRef)(n.onOpenEdit);D.current=n.onOpenEdit;let O=(0,m.useMemo)(()=>c!==void 0&&(o===void 0||(c.regenerate?.length??0)>0||(c.uploads?.length??0)>0||JSON.stringify(c.config)!==JSON.stringify(o.revision.config)||JSON.stringify(c.content)!==JSON.stringify(o.revision.content)),[c,o]),k=c!==void 0&&o!==void 0&&t!==null&&t!==o.revision.id,ee=(0,m.useRef)(!1);async function te(e){if(!ee.current){ee.current=!0,g(!0),x(void 0),C(void 0);try{await e()}catch(e){x(e instanceof Error?e.message:String(e))}finally{ee.current=!1,g(!1)}}}async function ne(t){let n=await C2(r,e);if(!n.ok){C(n);return}return C(void 0),s(n.value.view),t&&l({config:structuredClone(n.value.view.revision.config),content:structuredClone(n.value.view.revision.content)}),n.value.view}async function re(t){let n=await Oo(r,e);if(i.setQueryData(z.project(e),n),await i.invalidateQueries({queryKey:z.revisions(e)}),!t.current||n.revisionId!==t.revision.id){C({ok:!1,reason:`conflict`,message:`The project changed again. Your draft is preserved.`,currentRevisionId:n.revisionId,fields:[]});return}s(t),l(void 0),C(void 0),d(void 0)}async function A(){if(v||o===void 0||c===void 0)return;let t={baseRevisionId:o.revision.id,edit:c},n=S7(w.current,t,()=>crypto.randomUUID());w.current=n;let i=await Cde(r,e,{...t,idempotencyKey:n.idempotencyKey});if(!i.ok){C(i);return}await re(i.value.view),w.current=void 0}async function ie(t,n=u){if(n===void 0)return;let a={baseRevisionId:n.baseRevisionId,previewId:n.id,...t},o=S7(E.current,a,()=>crypto.randomUUID());E.current=o;let s=await Ode(r,e,{...a,idempotencyKey:o.idempotencyKey});if(!s.ok){C(s),(s.reason===`stale-preview`||s.reason===`conflict`)&&d(void 0);return}E.current=void 0,d(void 0),await i.invalidateQueries({queryKey:z.project(e)})}async function j(t,n){let i=await ne(!1);if(i===void 0)return;let a=await Dde(r,e,{baseRevisionId:i.revision.id,request:t});if(!a.ok){C(a);return}let o=a.value.value;if(E.current=void 0,n&&nye(o)){await ie({acknowledgeUnknownCosts:!1,confirmedProvidedWorkKeys:[]},o);return}d(o)}async function ae(t){let n=o??a.data??await ne(!1);if(n===void 0)return;let i={baseRevisionId:n.revision.id,targetRevisionId:t},s=S7(T.current,i,()=>crypto.randomUUID());T.current=s;let c=await wde(r,e,{...i,idempotencyKey:s.idempotencyKey});if(!c.ok){C(c);return}await re(c.value.view),T.current=void 0}return{saved:a,view:o,edit:c,preview:u,focus:f,pending:h,uploading:v,error:b,refusal:S,unsaved:O,remoteChanged:k,busy:h||v||c!==void 0||u!==void 0,setEdit:l,setUploading:y,openEditor:()=>void te(async()=>{await ne(!0)}),discard:()=>{l(void 0),C(void 0),y(!1),w.current=void 0},save:()=>void te(A),reloadDraft:()=>void te(async()=>{w.current=void 0,y(!1),await ne(!0),C(void 0)}),reloadCurrent:()=>void te(async()=>{T.current=void 0,E.current=void 0,d(void 0),await ne(!1),await i.invalidateQueries({queryKey:z.project(e)})}),requestEdit:e=>void te(async()=>{let t=o,n=c;if(t===void 0||n===void 0){if(t=await ne(!1),t===void 0)return;n={config:structuredClone(t.revision.config),content:structuredClone(t.revision.content)}}l(e.change(n,t)),p({section:e.section}),D.current?.()}),review:(e,t)=>void te(()=>j(e,t?.autoStart===!0)),start:e=>void te(()=>ie(e)),closePreview:()=>{h||(d(void 0),E.current=void 0)},restore:e=>void te(()=>ae(e))}}function nye(e){return!e.work.some(e=>e.disposition===`blocked`)&&e.providedReuseRequired.length===0&&e.costs.unknown===0}function rye({controller:e,renderEditor:t,active:n=!0,intro:r}){let i=e;return i.view===void 0||i.edit===void 0?(0,h.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[r??(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(V,{title:`Saved revision`,info:`project.saved-revision`}),i.saved.error===null?null:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-small text-danger`,children:i.saved.error.message}),i.saved.data===void 0?null:(0,h.jsx)(`ul`,{"aria-label":`Saved output status`,className:`sl-list m-0 list-none p-0`,children:i.saved.data.outputs.filter(e=>e.selected).map(e=>(0,h.jsxs)(`li`,{className:`sl-row`,children:[(0,h.jsx)(`span`,{className:`sl-row__title`,children:m7(e.output)}),(0,h.jsx)(`span`,{className:`sl-row__meta`,children:e.available?e.state===`ready`?`Ready`:e.state===`outdated`?`Outdated; the retained version stays until it is remade`:`Provided content needs review`:`Retained file missing`})]},e.recordId))})]}),i.preview===void 0&&n?(0,h.jsx)(x7,{error:i.error,refusal:i.refusal}):null,(0,h.jsxs)(y0,{children:[i.refusal?.reason===`conflict`&&n?(0,h.jsx)(L,{disabled:i.pending,onClick:i.reloadCurrent,children:`Reload current revision`}):null,(0,h.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,h.jsx)(L,{disabled:i.busy,onClick:()=>i.review({kind:`allAffected`}),variant:`secondary`,children:`Choose what to remake`}),(0,h.jsx)(B,{id:`project.choose-remake`})]}),(0,h.jsx)(L,{variant:`primary`,disabled:i.busy,onClick:i.openEditor,children:`Edit project`})]})]}):(0,h.jsxs)(`form`,{"aria-label":`Edit project`,onSubmit:e=>{e.preventDefault(),i.save()},children:[(0,h.jsx)(`fieldset`,{disabled:i.pending,className:`m-0 min-w-0 border-0 p-0`,children:t({view:i.view,edit:i.edit,fields:i.refusal?.fields??[],onChange:i.setEdit,onPending:i.setUploading,...i.focus===void 0?{}:{focus:i.focus}})}),i.preview===void 0?(0,h.jsx)(x7,{error:i.error,refusal:i.refusal}):null,(0,h.jsxs)(y0,{status:(0,h.jsx)(v0,{tone:i.remoteChanged?`warning`:`info`,children:i.remoteChanged?`A newer revision is available. Your unsaved changes are kept below.`:i.uploading?`Waiting for uploads to finish…`:void 0}),children:[i.remoteChanged||i.refusal?.reason===`conflict`?(0,h.jsx)(L,{disabled:i.pending||i.uploading,onClick:i.reloadDraft,children:`Reload current revision and discard my draft`}):null,(0,h.jsx)(L,{variant:`quiet`,disabled:i.pending||i.uploading,onClick:i.discard,children:`Discard changes`}),(0,h.jsx)(L,{variant:`primary`,type:`submit`,disabled:i.pending||i.uploading,children:`Save changes`})]})]})}function iye({controller:e,projectId:t,active:n}){let r=e;return n?(0,h.jsxs)(h.Fragment,{children:[r.preview===void 0&&(r.error||r.refusal)?(0,h.jsxs)(`div`,{className:`mb-4 flex flex-col gap-3`,children:[(0,h.jsx)(x7,{error:r.error,refusal:r.refusal}),r.edit===void 0&&r.refusal?.reason===`conflict`?(0,h.jsx)(L,{disabled:r.pending,onClick:r.reloadCurrent,className:`self-start`,children:`Reload current revision`}):null]}):null,(0,h.jsx)(eye,{projectId:t,pending:r.busy,onRestore:r.restore})]}):null}function aye({controller:e}){let t=e;return(0,h.jsx)(HP,{open:t.preview!==void 0,title:`Choose what to remake`,onClose:t.closePreview,children:t.preview===void 0?null:(0,h.jsx)(Wve,{preview:t.preview,feedback:(0,h.jsx)(x7,{error:t.error,refusal:t.refusal}),pending:t.pending,onStart:t.start,onCancel:t.closePreview},t.preview.id)})}function oye({projectId:e}){let{api:t}=R(),n=M(Jy(t,e));return n.error===null?n.data===void 0?(0,h.jsxs)(`div`,{role:`status`,"aria-label":`Loading run cost`,className:`flex flex-col gap-8`,children:[(0,h.jsx)(`span`,{className:`h-16 max-w-3xl rounded-control bg-sunken`}),(0,h.jsx)(`span`,{className:`h-40 rounded-control bg-sunken`})]}):(0,h.jsx)(dye,{cost:n.data}):(0,h.jsx)(fI,{tone:`danger`,title:`The run cost could not be loaded.`,children:`${n.error.message} Reload the page to try again.`})}function sye({cost:e,status:t,onOpen:n}){if(e===void 0||!cye.has(t)||e.calls===0&&e.byStage.length===0)return null;let r=[`${t===`done`||t===`partial`?`This run cost`:`Spent so far`} ${j7(e.cost)}${e.unpriced>0?` plus unpriced calls`:``}`,...e.apiEquivalent===null?[]:[`~${j7(e.apiEquivalent)} via API`],`${M7(e.totals.wallMs)} end to end`];return(0,h.jsxs)(`section`,{"aria-label":`Run cost`,className:`flex flex-wrap items-center gap-x-3 gap-y-1 border-b border-line pb-3 text-small text-ink-2`,children:[(0,h.jsx)(`span`,{children:r.join(` · `)}),(0,h.jsxs)(L,{variant:`quiet`,size:`small`,onClick:n,children:[(0,h.jsx)(Ac,{"aria-hidden":`true`,strokeWidth:1.75}),`See cost by stage`]})]})}var cye=new Set([`done`,`partial`,`failed`,`canceled`]),lye=[{id:`stage`,header:`Stage`,cell:e=>(0,h.jsx)(`strong`,{children:YP[e.stage]})},{id:`cost`,header:`Cost`,numeric:!0,cell:w7},{id:`api`,header:`Via API`,numeric:!0,cell:T7},{id:`usage`,header:`Usage`,numeric:!0,cell:e=>E7(e)||`—`},{id:`time`,header:`Time`,numeric:!0,cell:e=>e.wallMs===null?`—`:M7(e.wallMs)}],uye=[{id:`model`,header:`Provider · model`,cell:e=>(0,h.jsx)(`strong`,{children:mye(e)})},{id:`cost`,header:`Cost`,numeric:!0,cell:w7},{id:`api`,header:`Via API`,numeric:!0,cell:T7},{id:`usage`,header:`Usage`,numeric:!0,cell:e=>E7(e)||`—`},{id:`calls`,header:`Calls`,numeric:!0,cell:e=>D7.format(e.calls)}];function C7(e){return e===`five_hour`?`5-hour`:e===`weekly`?`weekly`:`current`}function dye({cost:e}){if(e.calls===0&&e.byStage.length===0)return(0,h.jsx)(`p`,{className:`m-0 text-body text-ink-2`,children:`Nothing has been spent yet. The cost of each provider call appears here as the run makes it.`});let t=e.byModel.some(e=>e.onPlan),n=e.plans.flatMap(e=>e.reported?e.windows.map(t=>({plan:e,window:t})):[]);return(0,h.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[(0,h.jsxs)(`section`,{"aria-label":`Run cost summary`,className:`flex flex-col gap-3`,children:[(0,h.jsxs)(c4,{children:[(0,h.jsx)(l4,{value:j7(e.cost),label:e.unpriced>0?`known cost, paid to providers`:`paid to providers`}),e.apiEquivalent===null?null:(0,h.jsx)(l4,{value:`~${j7(e.apiEquivalent)}`,label:`same work via API`}),n.map(({plan:e,window:t})=>{let n=`${C7(t.kind)} ${e.name} limit`,r=t.usedPercent<1?`<1%`:`${O7.format(t.usedPercent)}%`;return(0,h.jsx)(l4,{value:r,label:`of ${n}`,children:(0,h.jsx)(u4,{value:t.usedPercent/100,label:`Share of the ${n} this run used`,valueText:`${r} of your ${n}; now at ${O7.format(t.nowPercent)}%`,tone:t.nowPercent>=80?`waiting`:`accent`})},`${e.account}/${t.kind}`)}),(0,h.jsx)(l4,{value:M7(e.totals.wallMs),label:`end to end`})]}),(0,h.jsxs)(`div`,{className:`flex flex-col gap-1 text-small text-ink-2`,children:[e.unpriced>0?(0,h.jsx)(`p`,{className:`m-0`,children:`Plus ${A7(e.unpriced,`call`)} the model catalogue has no price for.`}):null,t?(0,h.jsx)(`p`,{className:`m-0`,children:fye(e)}):null,e.plans.map(e=>(0,h.jsx)(`p`,{className:`m-0`,children:pye(e)},e.account))]})]}),(0,h.jsxs)(`section`,{"aria-label":`By stage`,children:[(0,h.jsx)(V,{title:`By stage`,info:`project.cost.by-stage`,className:`mb-3`}),(0,h.jsx)(`div`,{className:`overflow-x-auto`,children:(0,h.jsx)(d4,{caption:`Run cost by stage`,columns:lye,rows:e.byStage,rowKey:e=>e.stage})})]}),(0,h.jsxs)(`section`,{"aria-label":`By model`,children:[(0,h.jsx)(V,{title:`By model`,info:`project.cost.by-model`,className:`mb-3`}),(0,h.jsx)(`div`,{className:`overflow-x-auto`,children:(0,h.jsx)(d4,{caption:`Run cost by model`,columns:uye,rows:e.byModel,rowKey:e=>`${e.provider}/${e.model}/${e.kind}`})})]}),(0,h.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:`In total: ${E7(e.totals)||`no reported usage`} · ${M7(e.totals.wallMs)} of stage time.`}),(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-3`,children:`Priced from the model catalogue${e.catalogueDate===null?``:` of ${e.catalogueDate}`} when each call finished. Retries that failed are not charged here; taxes and included credits are not counted.`})]})]})}function fye(e){let t=e.apiEquivalent??0;if(t===0&&e.apiUnpriced>0)return`CLI calls: $0 on your plan · no API price is listed for their models.`;let n=e.apiUnpriced>0?` (plus ${A7(e.apiUnpriced,`call`)} with no API price)`:``;return`CLI calls: $0 on your plan · ~${j7(t)} via API${n}.`}function pye(e){return e.reported?e.windows.length===0?`${e.name} reported no limit windows for this run.`:e.windows.map(t=>{let n=C7(t.kind),r=t.usedPercent<1?`under 1%`:`~${O7.format(t.usedPercent)}%`,i=`now at ${O7.format(t.nowPercent)}%${t.resetsAt===null?``:`, resets ${gye(t.resetsAt)}`}`;return`This run used ${r} of your ${n} ${e.name} limit (${i}).`}).join(` `):`${e.name} did not report its plan limits for this run, so the share it used is not known.`}function w7(e){return e.calls===0?`—`:`onPlan`in e&&e.onPlan?`$0 on plan`:e.unpriced>0?e.unpriced===e.calls?`Unknown`:`${j7(e.cost)} + unknown`:j7(e.cost)}function T7(e){return e.apiEquivalent===null?`—`:e.apiUnpriced>0&&e.apiEquivalent===0?`No API price`:`~${j7(e.apiEquivalent)}`}function mye(e){let t=e.model===``?`default model`:e.model;return e.apiModel===null?`${e.provider} · ${t}`:`${e.provider} · ${t} (as ${e.apiModel})`}function E7(e){let t=[];return e.tokensIn+e.tokensOut>0&&t.push(`${k7(e.tokensIn)} in / ${k7(e.tokensOut)} out tokens${e.cachedTokens>0?` (${k7(e.cachedTokens)} cached)`:``}`),e.characters>0&&t.push(`${k7(e.characters)} characters`),e.images>0&&t.push(A7(e.images,`image`)),e.seconds>0&&t.push(`${D7.format(e.seconds)} s of video`),t.join(` · `)}var D7=new Intl.NumberFormat(void 0,{maximumFractionDigits:0}),O7=new Intl.NumberFormat(void 0,{maximumFractionDigits:1}),hye=new Intl.NumberFormat(void 0,{notation:`compact`,maximumFractionDigits:1});function k7(e){return e<1e4?D7.format(e):hye.format(e)}function A7(e,t){return`${D7.format(e)} ${t}${e===1?``:`s`}`}function j7(e){return e===0?`$0`:e<.01?`<$0.01`:`$${e.toFixed(2)}`}function M7(e){let t=Math.round(e/1e3);if(t<60)return`${t} s`;let n=Math.floor(t/60);return n<60?`${n} min ${t%60} s`:`${Math.floor(n/60)} h ${n%60} min`}function gye(e){return new Date(e).toLocaleString(void 0,{weekday:`short`,hour:`2-digit`,minute:`2-digit`})}var _ye=(e,t)=>{if(t)return`waiting`;switch(e.state){case`running`:return`running`;case`done`:case`provided`:return`done`;case`failed`:return e.retryAt===void 0?`failed`:`waiting`;default:return`off`}},vye=(e,t)=>{if(t)return`Held for you`;switch(e.state){case`running`:return`Running`;case`done`:return`Done`;case`provided`:return`Provided`;case`failed`:return e.retryAt===void 0?`Failed`:`Waiting to try again`;case`canceled`:return`Canceled`;case`skipped`:return`Off`;case`pending`:return`Not started`}};function yye(e,t){if(e.startedAt===null)return;let n=Date.parse(e.startedAt),r=e.finishedAt===null?t:Date.parse(e.finishedAt);if(!Number.isFinite(n)||!Number.isFinite(r)||r<n)return;let i=Math.round((r-n)/1e3);if(i<1)return;if(i<60)return`${String(i)} s`;let a=Math.round(i/60);return a<60?`${String(a)} min`:`${String(Math.floor(a/60))} h ${String(a%60)} min`}function bye(e,t,n){let r=V3(t,n);return r===void 0?e:e===void 0||e===``?H3(r):`${e} · ${H3(r)}`}function xye({stages:e,outputs:t,project:n,resumable:r,held:i,now:a}){return e.filter(e=>e.state!==`skipped`).map(e=>{let o=i.some(t=>t.stage===e.kind),s=yye(e,a);return{id:e.id,name:e.kind===`video`&&XP(n.config)===`audio`?`Audio export`:s5[e.kind],tone:_ye(e,o),state:vye(e,o),...s===void 0?{}:{time:s},detail:o?`Held for your review`:bye(tF(e,t,n,r),e,a)}})}function Sye({stages:e}){return(0,h.jsx)(`div`,{className:`sr-only`,children:e.filter(e=>e.state!==`skipped`).map(e=>(0,h.jsx)(`span`,{role:`status`,"aria-live":`polite`,children:`${s5[e.kind]}: ${e.state}`},e.id))})}function Cye({steps:e}){return(0,h.jsxs)(`section`,{"aria-labelledby":`run-steps-title`,className:`flex flex-col gap-2`,children:[(0,h.jsx)(V,{id:`run-steps-title`,title:`Run`,size:`small`,className:`pb-0`}),(0,h.jsx)(W3,{steps:e,label:`Run steps`})]})}var N7=new Intl.NumberFormat(void 0,{maximumFractionDigits:0});function wye({cost:e}){if(e===void 0||e.calls===0&&e.byStage.length===0)return null;let t=e.plans.flatMap(e=>e.reported?e.windows.map(t=>({key:`${e.account}/${t.kind}`,name:e.name,window:t.kind===`five_hour`?`5-hour`:t.kind===`weekly`?`weekly`:`current`,used:t.usedPercent,now:t.nowPercent})):[]);return(0,h.jsxs)(`section`,{"aria-labelledby":`cost-so-far-title`,className:`flex flex-col gap-3`,children:[(0,h.jsx)(V,{id:`cost-so-far-title`,title:`Cost so far`,size:`small`,className:`pb-0`}),(0,h.jsxs)(c4,{className:`grid-cols-2`,children:[(0,h.jsx)(l4,{value:j7(e.cost),label:e.unpriced>0?`known, spent`:`spent`}),e.apiEquivalent===null?null:(0,h.jsx)(l4,{value:`~${j7(e.apiEquivalent)}`,label:`same work via API`})]}),t.map(e=>{let t=e.used<1?`under 1%`:`${N7.format(e.used)}%`,n=`${e.window} ${e.name} limit`;return(0,h.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:`${e.name}: ${t} of your ${e.window} limit`}),(0,h.jsx)(u4,{value:e.used/100,label:`Share of the ${n} this run used`,valueText:`${t} of your ${n}; now at ${N7.format(e.now)}%`,tone:e.now>=80?`waiting`:`accent`})]},e.key)})]})}function Tye({projectId:e,revisionId:t,title:n,open:r,onClose:i}){let{api:a}=R(),o=_(),[s,c]=(0,m.useState)(null),[l,u]=(0,m.useState)(!1),[d,f]=(0,m.useState)(null),p=Dy(),g=(0,m.useRef)(!1),v=(0,m.useRef)(null);(0,m.useEffect)(()=>{r&&t!==null&&(c({revisionId:t,name:n}),f(null)),r||c(null)},[r,t,n]);async function y(){if(!s||g.current||!s.name.trim())return;g.current=!0,u(!0),f(null);let t=JSON.stringify([e,s.revisionId,s.name.trim()]);v.current?.key!==t&&(v.current={key:t,id:crypto.randomUUID()});try{let t=await Jq(a,e,{id:v.current.id,name:s.name.trim(),revisionId:s.revisionId});if(!t.ok){v.current=null,f(t.message);return}v.current=null,i(),p(`Template saved.`,`success`),await o.invalidateQueries({queryKey:Rq})}catch(e){f(e instanceof Error?e.message:`The template wasn't saved. Press Save template to try again.`)}finally{g.current=!1,u(!1)}}return(0,h.jsx)(ky,{open:r&&s!==null,onOpenChange:e=>{!e&&!g.current&&i()},title:`Save as template`,description:`Save this revision’s setup for a fresh Play draft. This does not rebuild the project.`,children:(0,h.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),y()},children:[(0,h.jsx)(Y,{label:`Template name`,tip:`play.template-name`,children:(0,h.jsx)(OV,{autoFocus:!0,required:!0,maxLength:200,disabled:l,value:s?.name??``,onChange:e=>{let t=e.target.value;c(e=>e&&{...e,name:t})}})}),d?(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-small text-danger`,children:d}):null,(0,h.jsxs)(`div`,{className:`sl-dialog__foot`,children:[(0,h.jsx)(L,{disabled:l,onClick:i,children:`Cancel`}),(0,h.jsx)(L,{variant:`primary`,type:`submit`,disabled:l||!s?.name.trim(),children:`Save template`})]})]})})}var P7=K({baseRevisionId:U().min(1).max(64),idempotencyKey:ND()}).strict(),Eye=fO(`kind`,[K({kind:SO(`resume`)}).strict(),K({kind:SO(`retry`),stage:q(MS)}).strict(),K({kind:SO(`rerun`),stage:q(MS)}).strict(),K({kind:SO(`redo`),item:U().min(1).max(200)}).strict()]);P7.extend({action:Eye}).strict();var Dye=fO(`ok`,[K({ok:SO(!0),value:f2.and(K({warnings:G(U()).readonly()}))}),K({ok:SO(!1),reason:q([`no-project`,`no-revision`,`conflict`,`idempotency-conflict`,`invalid-edit`,`stale-preview`,`invalid-selection`,`review-required`,`cost-ack-required`,`readiness`,`running`,`accepted-job`,`control-changed`]),fields:G(K({field:U(),message:U()})).readonly().optional(),intentRevisionId:U().optional(),currentRevisionId:U().nullable().optional()})]),F7=new Set([400,404,409]);async function Oye(e,t,n){return L7(e,t,`cancel`,n)}async function kye(e,t,n){return L7(e,t,`pause`,n)}function Aye(e,t,n){return R7(e,t,`resume`,n)}function jye(e,t,n,r){return R7(e,t,`stages/${n}/retry`,r)}function Mye(e,t,n,r){return R7(e,t,`stages/${n}/soften`,r)}function Nye(e,t,n,r){return R7(e,t,`stages/${n}/rerun`,r)}async function Pye(e,t,n){return I7(await e.fetch(`${e.origin}/api/projects/${encodeURIComponent(t)}/providers`,{method:`PATCH`,headers:{"content-type":`application/json`},body:JSON.stringify(n)}))}async function Fye(e,t,n){return I7(await e.fetch(`${e.origin}/api/projects/${encodeURIComponent(t)}/subtitles`,{method:`PATCH`,headers:{"content-type":`application/json`},body:JSON.stringify(n)}))}async function Iye(e,t,n){return I7(await e.fetch(`${e.origin}/api/projects/${encodeURIComponent(t)}/article`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({markdown:n})}))}async function Lye(e,t,n){return I7(await e.client.projects[`:id`].images[`:outputId`].$delete({param:{id:t,outputId:n}}))}async function Rye(e,t,n){return I7(await e.client.projects[`:id`].images[`:outputId`].regenerate.$post({param:{id:t,outputId:n}}))}async function I7(e){if(e.ok)return{ok:!0,value:await e.json()};let t=await uo(e);if(t!==void 0&&F7.has(e.status))return{ok:!1,message:lo(e,t).message};throw lo(e,t)}async function L7(e,t,n,r){let i=P7.parse(r);return I7(await e.fetch(`${e.origin}/api/projects/${encodeURIComponent(t)}/${n}`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(i)}))}async function R7(e,t,n,r){let i=await e.fetch(`${e.origin}/api/projects/${encodeURIComponent(t)}/${n}`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(P7.parse(r))});if(i.ok){let e=Dye.parse(await i.json());if(!e.ok)throw Error(vo);return{ok:!0,value:e.value,warnings:e.value.warnings}}let a=await uo(i);if(a!==void 0&&F7.has(i.status))return{ok:!1,message:lo(i,a).message};throw lo(i,a)}function zye(e){let{api:t}=R(),n=_(),[r,i]=(0,m.useState)(void 0),[a,o]=(0,m.useState)(),s=(0,m.useRef)(new Map),c=(0,m.useRef)(!1),l=N({mutationFn:async e=>{let r=e.action;if(![`pause`,`cancel`,`resume`,`retry`,`soften`,`rerun`].includes(r.kind))return B7(t,e.projectId,r);let i=r.kind===`retry`||r.kind===`soften`||r.kind===`rerun`?r.stage:``,a=`${e.projectId}:${r.kind}:${i}`,o=s.current.get(a);if(!o){let r=n.getQueryData(z.project(e.projectId))?.revisionId;if(!r){let n=await C2(t,e.projectId);if(!n.ok)return{ok:!1,message:n.message};r=n.value.view.revision.id}o={baseRevisionId:r,idempotencyKey:crypto.randomUUID()},s.current.set(a,o)}let c=await B7(t,e.projectId,r,o);return s.current.delete(a),c.ok&&await Oo(t,e.projectId).then(t=>n.setQueryData(z.project(e.projectId),t),e=>console.warn(`Project refresh after an accepted action failed`,e)),c},onMutate:()=>{i(void 0),o(void 0)},onSuccess:async(e,t)=>{e.ok?(o(`warnings`in e&&e.warnings.length>0?e.warnings.join(` `):void 0),n.invalidateQueries({queryKey:z.projects})):i({message:e.message,stage:z7(t.action)}),await n.invalidateQueries({queryKey:z.project(t.projectId)})},onSettled:()=>{c.current=!1},onError:(e,t)=>{i({message:e.message,stage:z7(t.action)})}});return{run:(t,n)=>{c.current||(c.current=!0,l.mutate({projectId:e,action:t},{onSuccess:e=>{e.ok&&n?.()}}))},pending:l.isPending,performing:l.isPending?l.variables?.action:void 0,refusal:r,dismissRefusal:()=>{i(void 0)},notice:a}}function z7(e){switch(e.kind){case`cancel`:case`pause`:case`resume`:case`providers`:return;case`retry`:case`soften`:case`rerun`:return e.stage;case`subtitles`:return`video`;case`save-article`:return`article`;case`delete-image`:case`regenerate-image`:return`images`}}function B7(e,t,n,r){let i=()=>{if(!r)throw Error(`A saved revision and request identity are required.`);return r};switch(n.kind){case`pause`:return kye(e,t,i());case`cancel`:return Oye(e,t,i());case`resume`:return Aye(e,t,i());case`retry`:return jye(e,t,n.stage,i());case`soften`:return Mye(e,t,n.stage,i());case`rerun`:return Nye(e,t,n.stage,i());case`providers`:return Pye(e,t,n.choices);case`subtitles`:return Fye(e,t,n.subtitles);case`save-article`:return Iye(e,t,n.markdown);case`delete-image`:return Lye(e,t,n.outputId);case`regenerate-image`:return Rye(e,t,n.outputId)}}var V7=e=>e.state===`done`||e.state===`provided`;function Bye(e){let t=e.find(e=>e.state===`failed`)??e.find(e=>e.state===`running`);if(t)return t.kind;let n=e.find(e=>e.kind===`video`&&V7(e));if(n)return n.kind;let r=e.find(e=>e.state===`pending`);return r?r.kind:e.find(e=>e.kind===`article`&&V7(e))?.kind??e.find(e=>e.state!==`skipped`)?.kind??`article`}function Vye({projectId:e,openDraft:t}){return(0,h.jsx)(Hye,{projectId:e,openDraft:t},e)}var H7=e=>{let t=e.filter(e=>e!==void 0);if(!(t.length===0||t.every(e=>e.state===`skipped`)))return t.some(e=>e.state===`failed`&&e.retryAt===void 0)?`failed`:t.some(e=>e.state===`running`)?`running`:t.some(e=>e.state===`failed`)?`waiting`:t.every(e=>e.state===`done`||e.state===`provided`||e.state===`skipped`)?`done`:`off`};function Hye({projectId:e,openDraft:t}){let{api:n}=R(),r=Dy(),i=Gye(e,t),a=M(qy(n,e)),o=M($y(n)),s=M(Jy(n,e)),c=zye(e),[l,u]=(0,m.useState)(),[d,f]=(0,m.useState)(!1),[p,g]=(0,m.useState)(!1),[_,v]=(0,m.useState)(!1),y=a.data?.revisionId??null,b=tye(e,y,{onOpenEdit:()=>u(`settings`)}),x=eI(e),S=(0,m.useRef)(void 0);(0,m.useEffect)(()=>{if(x===void 0){S.current=void 0;return}a.data!==void 0&&S.current!==x&&(S.current=x,x===`download`&&u(XP(a.data.project.config)===`article`?`article`:`video`))},[x,a.data]),Y3(e,y);let C=M({queryKey:My,queryFn:()=>By(n)}),w=Vy(C.data,e),T=M({queryKey:k3(e,y??``),queryFn:()=>j3(n,e),enabled:y!==null,retry:!1}),E=T.data?.ok===!0?T.data.value.checkpoints:[],D=b.saved.data?.outputs.filter(e=>e.selected&&e.state===`outdated`).map(e=>({workKey:e.workKey,role:e.output.role}))??[],O=a.data?.project,k=a.data?.stages??[],ee=a.data?.outputs??[],te=ee.some(e=>e.role===`video`),ne=e=>u(e),re=Vge({project:O??Uye,stages:k,resumable:a.data?.resumable??!1,sample:w,gates:E,outdated:D,waits:s.data?.waits??[],uploadReady:te,actions:c,controller:b,openSection:ne,openUpload:()=>f(!0)}),A=l===`settings`,ie=(0,m.useRef)(!1);(0,m.useEffect)(()=>{if(!A){ie.current=!1;return}b.edit!==void 0&&(ie.current=!0),!(ie.current||b.busy)&&(ie.current=!0,b.openEditor())},[A,b]);let j=k.some(e=>e.state===`running`),ae=O?.status===`running`,oe=O?.title??``,se=re.next?.action;_x({id:`project.next`,title:se?.label??`Show the project's next action`,group:`This project`,context:oe,keywords:[`next`,`continue`,`resume`,`approve`,`retry`],shortcut:mP.nextAction,run:()=>{se===void 0?r(`This project has no next action right now: nothing waits on you.`,`info`):se.intent.kind===`soften`?r(`Soften and retry asks first: press it in the Next action panel on the right.`):re.run(se.intent)}}),Kx(Vx.showImages(e),()=>{let e=a.data?.stages.find(e=>e.kind===`images`);e===void 0||e.state===`skipped`?r(`${oe} makes no slideshow images, so there is no image to regenerate. To add them, open Settings in this project and choose how its images are made.`,`error`):u(`images`)},a.data!==void 0),_x({id:`project.pause`,title:O?.status===`paused`?`Continue the run`:`Pause the run`,group:`This project`,context:oe,keywords:[`pause`,`resume`,`continue`,`stop`],run:()=>c.run({kind:O?.status===`paused`?`resume`:`pause`})}),_x({id:`project.prepare-upload`,title:`Prepare upload`,group:`This project`,context:oe,keywords:[`youtube`,`studio`,`upload`,`publish`],run:()=>{te?f(!0):r(`Prepare upload opens once the video has been made.`,`info`)}}),_x({id:`project.settings`,title:`Edit project settings`,group:`This project`,context:oe,keywords:[`edit`,`settings`,`prompts`,`providers`,`channel`],run:()=>u(`settings`)}),_x({id:`project.rebuild-review`,title:`Choose what to remake`,group:`This project`,context:oe,keywords:[`rebuild`,`review`,`remake`,`outdated`,`affected`],run:()=>b.review({kind:`allAffected`})}),_x({id:`project.template`,title:`Save as template`,group:`This project`,context:oe,keywords:[`template`,`reuse`],run:()=>g(!0)}),_x({id:`project.cancel`,title:`Cancel the run`,group:`This project`,context:oe,keywords:[`cancel`,`stop`],run:()=>v(!0)});let ce=zge(D);if(_x({id:`project.remake-1`,title:ce[0]?.label??`Remake outdated outputs`,group:`This project`,context:oe,keywords:[`remake`,`outdated`,`rebuild`],run:()=>{let e=ce[0];e===void 0?r(`Nothing is outdated in this project.`,`info`):b.review({kind:`selected`,workKeys:e.workKeys},{autoStart:!0})}}),_x({id:`project.remake-all`,title:`Remake everything outdated`,group:`This project`,context:oe,keywords:[`remake`,`outdated`,`rebuild`,`all`],run:()=>{let e=[...new Set(ce.flatMap(e=>e.workKeys))];e.length===0?r(`Nothing is outdated in this project.`,`info`):b.review({kind:`selected`,workKeys:e},{autoStart:!0})}}),_x({id:`project.copy`,title:`Make my own copy`,group:`This project`,context:oe,keywords:[`sample`,`copy`,`duplicate`],run:()=>w?re.run({kind:`copy-sample`}):r(`Only the sample project is copied this way.`,`info`)}),a.error!==null)return(0,h.jsx)(fI,{tone:`danger`,title:`The project could not be loaded.`,children:`${a.error.message} Reload the page to try again, or go back to Projects.`});if(a.data===void 0||O===void 0)return(0,h.jsx)(Wye,{});let le=e=>k.find(t=>t.kind===e),ue=le(`article`),de=le(`research`),fe=le(`audio`),pe=le(`images`),me=le(`thumbnail`),he=le(`video`),ge=le(`document`),_e=O.config,ve=e=>e!==void 0&&e.state!==`skipped`,ye=_e.shorts?.enabled===!0||ee.some(e=>e.role===`short_video`||e.role===`shorts`),be=_e.youtubeDescription===!0||ee.some(e=>e.role===`youtube_description`),xe=E.filter(e=>e.state===`held`||e.state===`pending-review`),Se=[...ve(ue)||ve(de)?[{id:`article`,label:`Article`,tone:H7([ue,de])}]:[],...ve(fe)?[{id:`narration`,label:`Narration`,tone:H7([fe])}]:[],...ve(pe)||ve(me)||_e.reference!==void 0?[{id:`images`,label:`Images`,tone:H7([pe,me])}]:[],...ve(he)?[{id:`video`,label:XP(_e)===`audio`?`Audio export`:`Video`,tone:H7([he])}]:[],...ye?[{id:`shorts`,label:`Shorts`}]:[],...be?[{id:`youtube`,label:`YouTube`}]:[],...ve(ge)?[{id:`document`,label:`PDF`,tone:H7([ge])}]:[],{id:`cost`,label:`Cost`},{id:`live`,label:`Live`}].map(e=>{let t=ce.filter(t=>t.section===e.id).reduce((e,t)=>e+t.count,0);return t===0?e:{...e,meta:`${String(t)} outdated`}}),Ce=[{id:`settings`,label:`Settings`,...b.unsaved?{meta:`unsaved`}:{}},...y===null?[]:[{id:`checkpoints`,label:`Checkpoints`,...xe.length===0?{}:{meta:`${String(xe.length)} held`}}],{id:`history`,label:`History`}],we=[...Se,...Ce],Te=re.next?.situation,Ee=re.next?.section!==void 0&&Te!==`done`&&Te!==`running`?re.next.section:Te===`done`&&ee.some(e=>e.role===`youtube_description`)?`youtube`:o5(Bye(k)),De=l!==void 0&&we.some(e=>e.id===l)?l:we.find(e=>e.id===Ee)?.id??Se[0]?.id??`cost`,Oe=(...e)=>y===null?O.status===`running`||O.status===`paused`||j||c.pending:c.pending||e.some(e=>e?.state===`running`),ke={project:O,outputs:ee,actions:c,next:re,resumable:a.data.resumable},Ae=(e,t)=>e===void 0?null:(0,h.jsx)(N_e,{stage:e,...t===void 0||t.state===`skipped`?{}:{companion:t},project:O,outputs:ee,actions:c,busy:Oe(e,t)}),je=(...e)=>ee.some(t=>e.some(e=>e!==void 0&&t.stageKind===e.kind)),Me=(...e)=>je(...e)||e.some(e=>e!==void 0&&[`running`,`done`,`provided`,`failed`,`canceled`].includes(e.state)),Ne=[{id:`rebuild`,label:`Choose what to remake…`,run:()=>b.review({kind:`allAffected`}),disabled:b.busy},{id:`template`,label:`Save as template…`,run:()=>g(!0),disabled:y===null||w},{id:`cancel`,label:`Cancel the run…`,run:()=>v(!0),disabled:!ae||c.pending,apart:!0}],Pe=n5({kind:`cancel`}),Fe=c.refusal?.stage===void 0?c.refusal:void 0,Ie=Fe===void 0?c.notice===void 0?b.preview===void 0&&(b.error||b.refusal)&&De!==`settings`&&De!==`history`?(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-small text-danger`,children:b.error??b.refusal?.message}):void 0:(0,h.jsx)(`p`,{role:`status`,className:`m-0 text-small text-ink-2`,children:c.notice}):(0,h.jsx)(fI,{tone:`danger`,title:Fe.message,children:(0,h.jsx)(L,{variant:`quiet`,size:`small`,className:`mt-1`,onClick:c.dismissRefusal,children:`Dismiss`})}),Le=xye({stages:k,outputs:ee,project:O,resumable:a.data.resumable,held:xe.map(e=>({checkpointId:e.checkpointId,stage:e.stage,dependents:e.dependents})),now:Date.now()});return(0,h.jsx)(Qhe,{projectId:e,revisionId:y,children:(0,h.jsx)(r5,{value:y!==null,children:(0,h.jsx)(fpe,{value:e=>u(e===`edit`?`settings`:`article`),children:(0,h.jsxs)(i5,{value:b.pending||b.preview!==void 0?void 0:b.requestEdit,children:[(0,h.jsx)(`div`,{"data-tour":`project-controls`,children:(0,h.jsx)(W_e,{project:O,prompts:o.data?.prompts,editing:De===`settings`,onEdit:()=>u(`settings`),more:Ne,nextChapter:i})}),(0,h.jsx)(Sye,{stages:k}),De===`cost`?null:(0,h.jsx)(sye,{cost:s.data,status:O.status,onOpen:()=>ne(`cost`)}),(0,h.jsxs)(jq,{sections:(0,h.jsxs)(p8,{label:`Project sections`,children:[Se.map(e=>(0,h.jsx)(W7,{item:e,selected:De,onSelect:ne},e.id)),(0,h.jsx)(`hr`,{className:`sl-rule my-2`}),Ce.map(e=>(0,h.jsx)(W7,{item:e,selected:De,onSelect:ne},e.id))]}),aside:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(Uge,{state:re,feedback:Ie}),O===void 0?null:(0,h.jsx)(U_e,{projectId:e,title:O.title,status:O.status,sample:w||C.isPending}),(0,h.jsxs)(`div`,{className:`flex flex-col gap-6 max-[1180px]:hidden`,children:[(0,h.jsx)(Cye,{steps:Le}),(0,h.jsx)(wye,{cost:s.data}),(0,h.jsx)(Ihe,{})]})]}),children:[(0,h.jsx)(p5,{id:`article`,title:`Article`,stages:[ue,de].filter(U7),active:De===`article`,...ke,children:ve(ue)||ve(de)?Ae(ue,de):(0,h.jsx)(m5,{stage:ue,project:O,name:`Article`})}),(0,h.jsx)(p5,{id:`narration`,title:`Narration`,stages:[fe].filter(U7),active:De===`narration`,...ke,children:Me(fe)?Ae(fe):(0,h.jsx)(m5,{stage:fe,project:O,name:`Narration`})}),(0,h.jsx)(p5,{id:`images`,title:`Images`,head:!1,stages:[pe,me].filter(U7),active:De===`images`,...ke,children:Ae(pe,me)}),(0,h.jsx)(p5,{id:`video`,title:XP(_e)===`audio`?`Audio export`:`Video`,stages:[he].filter(U7),active:De===`video`,...ke,children:Ae(he)}),he===void 0?null:(0,h.jsx)(p5,{id:`shorts`,title:`Shorts`,stages:[],active:De===`shorts`,...ke,meta:`Vertical clips picked from the video, each with its title and hashtags`,children:(0,h.jsx)(w_e,{stage:he,project:O,outputs:ee})}),he===void 0?null:(0,h.jsx)(p5,{id:`youtube`,title:`YouTube`,stages:[],active:De===`youtube`,...ke,meta:`The description, chapters, hashtags and tags, as they go into YouTube Studio`,...te&&re.next?.action?.intent.kind!==`prepare-upload`?{extra:(0,h.jsx)(L,{variant:`secondary`,onClick:()=>f(!0),children:`Prepare upload`})}:{},children:(0,h.jsx)(P_e,{stage:he,project:O,outputs:ee})}),ge===void 0?null:(0,h.jsx)(p5,{id:`document`,title:`PDF`,stages:[ge],active:De===`document`,...ke,children:Me(ge)?Ae(ge):(0,h.jsx)(m5,{stage:ge,project:O,name:`PDF`})}),(0,h.jsx)(G7,{id:`cost`,title:`Run cost`,selected:De,children:(0,h.jsx)(oye,{projectId:e})}),(0,h.jsx)(G7,{id:`live`,title:`Live`,selected:De,children:De===`live`?(0,h.jsx)(eve,{project:O,revisionId:y,stages:k,outputs:ee}):null}),(0,h.jsx)(G7,{id:`settings`,title:`Settings`,selected:De,children:(0,h.jsx)(rye,{controller:b,active:De===`settings`,renderEditor:e=>(0,h.jsx)(Hve,{...e,renderContent:e=>(0,h.jsx)(Tve,{...e},e.view.revision.id)})})}),y===null?null:(0,h.jsx)(G7,{id:`checkpoints`,title:`Checkpoints`,selected:De,children:(0,h.jsx)(z_e,{projectId:e,revisionId:y,paused:O.status===`paused`,stages:k,approvedInRail:re.next?.action?.intent.kind===`approve`?re.next.action.intent.gate.checkpointId:void 0})}),(0,h.jsx)(G7,{id:`history`,title:`History`,selected:De,children:(0,h.jsx)(iye,{controller:b,projectId:e,active:De===`history`})})]}),(0,h.jsx)(aye,{controller:b}),d?(0,h.jsx)(L2,{projectId:e,onClose:()=>f(!1)}):null,(0,h.jsx)(Tye,{projectId:e,revisionId:y,title:O.title,open:p,onClose:()=>g(!1)}),(0,h.jsx)(Ay,{open:_,title:Pe.title,consequence:Pe.consequence,confirmLabel:Pe.verb,cancelLabel:Pe.dismiss,pending:c.pending,onConfirm:()=>{v(!1),c.run({kind:`cancel`})},onCancel:()=>v(!1)})]})})})})}var U7=e=>e!==void 0;function W7({item:e,selected:t,onSelect:n}){return(0,h.jsx)(m8,{className:`max-md:w-auto`,"data-tour":`project-rail-${e.id}`,current:e.id===t,onClick:()=>n(e.id),...e.tone===void 0?{}:{icon:(0,h.jsx)(pS,{tone:e.tone})},...e.meta===void 0?{}:{meta:e.meta},children:e.label})}function G7({id:e,title:t,selected:n,children:r}){return(0,h.jsxs)(`section`,{hidden:n!==e,"aria-label":t,className:`flex min-w-0 flex-col gap-5`,children:[(0,h.jsx)(`h2`,{className:`sl-section-head__title m-0`,children:t}),r]})}var Uye={id:``,title:``,format:`16:9`,status:`pending`,createdAt:``,config:{sources:{}}};function Wye(){return(0,h.jsxs)(`div`,{role:`status`,"aria-label":`Loading project`,children:[(0,h.jsxs)(`div`,{className:`mb-6 flex flex-col gap-2`,children:[(0,h.jsx)(`span`,{className:`h-3 w-20 rounded-control bg-sunken`}),(0,h.jsx)(`span`,{className:`h-8 w-80 max-w-full rounded-control bg-sunken`})]}),(0,h.jsx)(jq,{sections:(0,h.jsx)(`div`,{className:`flex flex-col gap-2`,children:[`a`,`b`,`c`,`d`,`e`].map(e=>(0,h.jsx)(`span`,{className:`h-8 rounded-control bg-sunken`},e))}),aside:(0,h.jsx)(`span`,{className:`h-40 rounded-control bg-sunken`}),children:(0,h.jsx)(`span`,{className:`h-[480px] rounded-control bg-sunken`})})]})}function Gye(e,t){let{api:n}=R(),r=(0,m.useRef)(void 0),[i,a]=(0,m.useState)(!1),[o,s]=(0,m.useState)(void 0);if(t!==void 0)return{pending:i,error:o,run:()=>{i||(r.current??=crypto.randomUUID(),a(!0),s(void 0),Xq(n,e,r.current).then(async e=>{if(!e.ok){s(e.message);return}await t(e.value.draft.id)?r.current=void 0:s(`The next chapter's draft was made, but Play could not open it because the draft open there is not saved yet. Open Play, let it save, then press Make the next chapter again.`)}).catch(e=>s(`The next chapter could not be made (${e instanceof Error?e.message:`the connection dropped`}). Press Make the next chapter again.`)).finally(()=>a(!1)))}}}var Kye=[`all`,`running`,`queued`,`waiting`,`ready`,`failed`];function qye(e){return Kye.find(t=>t===e)}var K7=[{value:`all`,label:`All`},{value:`running`,label:`Running`},{value:`queued`,label:`Queued`},{value:`waiting`,label:`Needs you`},{value:`ready`,label:`Ready to upload`},{value:`failed`,label:`Failed`}];function q7(e,t){switch(t){case`all`:return!0;case`running`:return e.status===`running`||e.status===`paused`;case`queued`:return B3(e);case`waiting`:return F3(e);case`ready`:return z3(e);case`failed`:return e.status===`failed`||e.status===`partial`}}function Jye(e){let t={running:{tone:`running`,word:`Running`},paused:{tone:`waiting`,word:`Paused`},pending:{tone:`off`,word:`Queued`},failed:{tone:`failed`,word:`Failed`},partial:{tone:`info`,word:`Done with problems`},done:{tone:`done`,word:`Done`},canceled:{tone:`off`,word:`Canceled`}};if(F3(e))return{tone:`waiting`,word:`Waiting for you`};let n=e.status===`running`?ZH(e.limitWaits):void 0;return n===void 0?t[e.status]:{tone:`waiting`,word:n}}function Yye(e){let t=e.config.articlePrompt,n=e.config.voices?.book;return[n===void 0?void 0:KA(n),t===void 0||t===``?void 0:t,e.format].filter(e=>e!==void 0).join(` · `)}function Xye({initialFilter:e=`all`}={}){let{api:t}=R(),n=_(),r=Dy(),i=px(),a=M(Ky(t)),[o,s]=(0,m.useState)(void 0),[c,l]=(0,m.useState)(e),u=M({queryKey:jy,queryFn:()=>Fy(t)}),d=new Set(Object.values(u.data?.samples??{}).filter(e=>e!==null)),[f,p]=(0,m.useState)(``),g=(0,m.useRef)(null),v=vx(g,`projects`),y=N({mutationFn:e=>Ao(t,e),onSettled:async()=>{s(void 0),await n.invalidateQueries({queryKey:z.projects})}}),b=N({mutationFn:e=>R3(t,e.project.id,e.uploaded),onError:(e,t)=>r(`${t.project.title} wasn't changed: ${e.message} Press the button again.`,`error`),onSettled:async()=>{await n.invalidateQueries({queryKey:z.projects})}});_x({id:`projects.show.waiting`,title:`Show projects that need you`,group:`Projects`,keywords:[`waiting`,`filter`],run:()=>l(`waiting`)}),_x({id:`projects.show.ready`,title:`Show videos ready to upload`,group:`Projects`,keywords:[`upload`,`finished`,`filter`],run:()=>l(`ready`)}),_x({id:`projects.show.failed`,title:`Show failed projects`,group:`Projects`,keywords:[`error`,`filter`],run:()=>l(`failed`)});let x=(a.data?.projects??[]).filter(e=>i.includes(e.channelId)),S=f.trim().toLowerCase(),C=x.filter(e=>q7(e,c)&&(S===``||e.title.toLowerCase().includes(S)));return(0,h.jsxs)(`div`,{children:[(0,h.jsx)(Aq,{title:`Projects`,meta:a.data===void 0?void 0:`${String(x.length)} ${x.length===1?`project`:`projects`} · ${i.channel?.name??`every channel`}`,actions:(0,h.jsxs)(lS,{to:`/play`,variant:`primary`,children:[(0,h.jsx)(kc,{"aria-hidden":`true`,strokeWidth:1.75}),`New video`]})}),a.data?.projects.length===0?(0,h.jsx)(PB,{}):null,a.error===null?null:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 mb-4 text-danger`,children:a.error.message}),a.data===void 0?a.error===null?(0,h.jsx)(Qye,{}):null:a.data.projects.length===0?(0,h.jsx)(T0,{title:`No projects yet`,actions:(0,h.jsx)(lS,{to:`/play`,variant:`primary`,children:`Make your first video`}),children:`Set up a run on Play: pick a template, type a topic and start.`}):(0,h.jsxs)(b0,{split:`aside`,children:[(0,h.jsxs)(x0,{label:`Project list`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,h.jsxs)(`div`,{className:`relative w-full max-w-[320px]`,children:[(0,h.jsx)(Nc,{"aria-hidden":`true`,strokeWidth:1.75,className:`pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2 text-ink-3`}),(0,h.jsx)(`input`,{type:`search`,ref:g,"aria-label":`Search projects`,"aria-keyshortcuts":kx(v),placeholder:`Search projects`,value:f,onChange:e=>p(e.target.value),className:`sl-input pl-9`})]}),(0,h.jsx)(Db,{label:`Show`,value:c,options:K7,onChange:l,className:`max-w-full overflow-x-auto`})]}),C.length===0?(0,h.jsx)(`p`,{className:`m-0 text-ink-2`,children:x.length===0?`No projects in ${i.channel?.name??`this channel`} yet. Pick All channels in the rail to see the others.`:`No project matches. Clear the search or pick All.`}):(0,h.jsx)(hU,{label:`Projects`,children:C.map(e=>(0,h.jsx)(Zye,{project:e,sample:d.has(e.id),onDelete:()=>s(e),onUploaded:t=>b.mutate({project:e,uploaded:t}),busy:b.isPending},e.id))})]}),(0,h.jsxs)(x0,{as:`aside`,label:`Projects at a glance`,children:[(0,h.jsxs)(`section`,{children:[(0,h.jsx)(V,{title:`At a glance`}),(0,h.jsx)(c4,{children:K7.filter(e=>e.value!==`all`).map(e=>(0,h.jsx)(l4,{label:e.label,value:String(x.filter(t=>q7(t,e.value)).length)},e.value))})]}),(0,h.jsxs)(`section`,{"aria-label":`Video queue`,className:`flex flex-col gap-2`,children:[(0,h.jsx)(V,{title:`Video queue`,info:`play.queue`}),(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:`Videos started together, in the order they run, are on the calendar.`}),(0,h.jsx)(`div`,{children:(0,h.jsx)(uS,{to:`/calendar`,children:`Open calendar`})})]})]})]}),y.error===null?null:(0,h.jsx)(`p`,{role:`alert`,className:`mt-3 text-small text-danger`,children:y.error.message}),(0,h.jsx)(Ay,{open:o!==void 0,title:o===void 0?``:`Delete "${o.title}"?`,consequence:`Moves the project to the trash for 30 days. Restore it or delete it for good in Settings → Trash.`,confirmLabel:`Delete project`,cancelLabel:`Keep it`,pending:y.isPending,onConfirm:()=>{o!==void 0&&y.mutate(o.id)},onCancel:()=>s(void 0)})]})}function Zye({project:e,sample:t,onDelete:n,onUploaded:r,busy:i}){let a=Jye(e),o=e.status===`running`;return(0,h.jsx)(gU,{title:(0,h.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,h.jsx)(pa,{to:`/projects/$projectId`,params:{projectId:e.id},children:e.title}),t?(0,h.jsx)(hS,{children:`Sample`}):null]}),meta:(0,h.jsxs)(`span`,{className:`flex flex-col gap-1`,children:[(0,h.jsx)(`span`,{children:`${Yye(e)} · started ${Tu(e.createdAt)}`}),o?(0,h.jsx)(u4,{value:e.progress,label:`${e.title} progress`,valueText:`${String(Math.round(e.progress*100))}% done`,className:`max-w-[240px]`}):null]}),actions:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(mS,{tone:a.tone,children:[a.word,(0,h.jsx)(`span`,{className:`sr-only`,role:`status`,"aria-live":`polite`,children:`${e.title}: ${a.word}`})]}),z3(e)?(0,h.jsx)(L,{variant:`quiet`,size:`small`,disabled:i,disabledReason:`Saving…`,onClick:()=>r(!0),children:`Mark uploaded`}):null,z3(e)?(0,h.jsx)(B,{id:`project.mark-uploaded`}):e.uploadedAt===null?null:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(hS,{children:`Uploaded`}),(0,h.jsx)(L,{variant:`quiet`,size:`small`,"aria-label":`Mark ${e.title} not uploaded`,disabled:i,disabledReason:`Saving…`,onClick:()=>r(!1),children:`Undo`})]}),(0,h.jsx)(Cy,{label:`Delete ${e.title}`,size:`small`,disabled:o,disabledReason:`Cancel the run first, then delete it.`,onClick:n,children:(0,h.jsx)(Ic,{"aria-hidden":`true`,strokeWidth:1.75})})]})})}function Qye(){return(0,h.jsx)(`ul`,{"aria-label":`Loading projects`,className:`sl-list m-0 list-none p-0`,children:[0,1,2,3,4,5].map(e=>(0,h.jsxs)(`li`,{className:`sl-row`,"data-slot":`skeleton-row`,children:[(0,h.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-2`,children:[(0,h.jsx)(`span`,{className:`h-3 w-2/5 rounded-control bg-sunken`}),(0,h.jsx)(`span`,{className:`h-[10px] w-1/4 rounded-control bg-sunken`})]}),(0,h.jsx)(`span`,{className:`h-[10px] w-16 rounded-control bg-sunken`})]},e))})}var $ye=`Prepare restrained delivery cues for a documentary narrator. Let the facts carry the scene. Use a measured pace and make only occasional changes where the supplied wording clearly calls for emphasis, reflection or tension. Prefer no cue to an unnecessary cue. Avoid theatrical emotion, invented reactions and routine laughter or sighs. Never rewrite, summarize, translate or add spoken words. Return only the cue annotations required by the supplied format contract.`;function J7({promptId:e,kind:t,from:n,onLeave:r}){let{api:i}=R(),a=_(),o=$F(),s=M($y(i)),c=(0,m.useId)(),l=(0,m.useId)(),u=(0,m.useId)(),[d,f]=dP(JSON.stringify(e===void 0?[`new`,t,n??null]:[`prompt`,e])),[p,g]=(0,m.useState)([]),[v,y]=(0,m.useState)(void 0),b=v!==void 0,[x,S]=(0,m.useState)(!1),[C,w]=(0,m.useState)(!1),T=s.data?.prompts,E=e??n,D=E===void 0?void 0:T?.find(e=>e.id===E),O=D===void 0?{kind:t,name:``,body:``}:e===void 0?{kind:D.kind,name:`${D.name} copy`,body:D.body}:{kind:D.kind,name:D.name,body:D.body},k=d??v??O,ee=N({mutationFn:t=>_s(i,t,e),onSuccess:async(e,t)=>{if(!e.ok){g(e.fields);return}y(e.value),f(e=>e===t?void 0:e),o({type:`prompt-saved`,id:e.value.id,kind:e.value.kind}),await a.invalidateQueries({queryKey:$y(i).queryKey})}}),te=N({mutationFn:e=>ys(i,e),onSuccess:async()=>{S(!1),f(void 0),await a.invalidateQueries({queryKey:$y(i).queryKey}),r(k.kind)}}),ne=N({mutationFn:({id:e,on:t})=>vs(i,e,t),onSettled:async()=>{await a.invalidateQueries({queryKey:$y(i).queryKey})}});p4(b,()=>{r(k.kind)});let re=(e,t)=>{f(e),g(e=>e.filter(e=>e.field!==t))},A=v3(k,p),ie=y3(A),j=S3(k.body),ae=k.body.trim()===``?[]:b3(A),oe=k.name.trim()===``?[]:x3(A);return QF({promptNamed:k.name.trim()!==``&&oe.length===0,promptBodyReady:k.body.trim()!==``&&ae.length===0,promptHasKeywords:j.length>0&&ae.length===0,promptSaveReady:ie===void 0&&!ee.isPending&&!b,promptSaving:ee.isPending||b,promptIsArticle:k.kind===`article`,promptIsImage:k.kind===`image`}),s.error===null?E!==void 0&&T===void 0?(0,h.jsx)(g4,{}):E!==void 0&&D===void 0?(0,h.jsx)(X7,{kind:t,children:`That prompt is gone. It may have been deleted in another tab.`}):(0,h.jsxs)(`div`,{children:[(0,h.jsx)(Aq,{crumb:(0,h.jsx)(M4,{children:(0,h.jsx)(pa,{to:`/prompts`,search:{kind:k.kind},children:`Prompts`})}),title:e===void 0?`New prompt`:`Edit prompt`,meta:`${bV(k.kind)} prompt`}),(0,h.jsxs)(`div`,{"data-tour":`prompt-editor`,className:`grid grid-cols-[minmax(0,1fr)] items-start gap-6 lg:grid-cols-[minmax(0,1fr)_360px]`,children:[(0,h.jsxs)(`div`,{className:`${A4} flex min-w-0 flex-col gap-4`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-end gap-4`,children:[(0,h.jsx)(`div`,{"data-tour":`prompt-name`,className:`min-w-[min(100%,240px)] flex-1`,children:(0,h.jsx)(Y,{label:`Name`,tip:`library.prompt.name`,...oe.length===0?{}:{error:oe.map(e=>e.message).join(` `)},children:(0,h.jsx)(OV,{value:k.name,onChange:e=>{re({...k,name:e.target.value},`name`)}})})}),(0,h.jsx)(g3,{label:`Kind`,value:k.kind,options:yV,tip:`library.prompt.kind`,onPick:e=>{re({...k,kind:e},`name`)}})]}),(0,h.jsxs)(`div`,{"data-tour":`prompt-body`,...Tb,children:[(0,h.jsxs)(`div`,{className:`mb-1 flex min-h-8 items-end justify-between gap-3`,children:[(0,h.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,h.jsx)(`label`,{htmlFor:c,className:`sl-field__label`,children:`Body`}),(0,h.jsx)(B,{id:ebe[k.kind],label:`${bV(k.kind)} prompt body`,className:`-my-1`})]}),Y7(k.kind)?(0,h.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,h.jsx)(L,{variant:`quiet`,size:`small`,onClick:()=>{let e=Y7(k.kind);e!==void 0&&(k.body.trim()===``?re({...k,body:e.body},`body`):w(!0))},children:Y7(k.kind)?.label}),(0,h.jsx)(B,{id:`library.prompt.starter`,label:Y7(k.kind)?.label})]}):null]}),(0,h.jsx)(w3,{id:c,value:k.body,invalid:ae.length>0,describedBy:ae.length===0?void 0:l,onChange:e=>{re({...k,body:e},`body`)}})]}),k.kind===`image`?(0,h.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[e!==void 0&&D?.kind===`image`?(0,h.jsx)(Eb,{checked:ne.isPending?ne.variables.on:D.photorealistic===!0,disabled:ne.isPending,onChange:t=>ne.mutate({id:e,on:t}),label:`Draws photorealistic pictures`,tip:`library.prompt.photorealistic`}):(0,h.jsxs)(`span`,{className:`flex items-center gap-1 text-small text-ink-2`,children:[`Save this Image prompt first, then choose whether it draws photorealistic pictures.`,(0,h.jsx)(B,{id:`library.prompt.photorealistic`})]}),ne.error===null?null:(0,h.jsx)(`span`,{role:`alert`,className:`text-small text-danger`,children:`Couldn't change Draws photorealistic pictures: ${ne.error.message} Press the switch again.`})]}):null,(0,h.jsx)(`div`,{"data-tour":`prompt-save`,children:(0,h.jsx)(h4,{onDelete:e===void 0?void 0:()=>{S(!0)},blocked:ie,blockedId:u,pending:ee.isPending,saved:b,cancel:(0,h.jsx)(lS,{to:`/prompts`,search:{kind:k.kind},onClick:()=>{f(void 0)},variant:`secondary`,children:`Cancel`}),errors:[ee.error,te.error].flatMap(e=>e===null?[]:[e.message]),onSave:()=>{ee.mutate(k)}})})]}),(0,h.jsx)(`div`,{"data-tour":`prompt-slots`,className:j4,children:(0,h.jsx)(f3,{slots:j,body:k.body,lint:ae,lintId:l})})]}),(0,h.jsx)(Ay,{open:C,title:`Replace this prompt body?`,consequence:`The starter replaces the text in this editor. Nothing is saved until you choose Save.`,confirmLabel:`Use starter`,tone:`primary`,onConfirm:()=>{let e=Y7(k.kind);e!==void 0&&re({...k,body:e.body},`body`),w(!1)},onCancel:()=>w(!1)}),(0,h.jsx)(Ay,{open:x,title:`Delete "${k.name}"?`,consequence:`Moves it to the trash for 30 days (Settings → Trash). Projects that used it keep their text.`,confirmLabel:`Delete prompt`,pending:te.isPending,onConfirm:()=>{e!==void 0&&te.mutate(e)},onCancel:()=>{S(!1)}})]}):(0,h.jsx)(X7,{kind:k.kind,children:s.error.message})}var ebe={article:`library.prompt.body.article`,image:`library.prompt.body.image`,thumbnail:`library.prompt.body.thumbnail`,narration:`library.prompt.body.narration`,description:`library.prompt.body.description`,shorts:`library.prompt.body.shorts`,review:`library.prompt.body.review`,script:`library.prompt.body.script`};function Y7(e){if(e===`narration`)return{label:`Use Documentary Starter`,body:$ye};if(e===`description`)return{label:`Use Built-in Starter`,body:Tme};if(e===`shorts`)return{label:`Use Built-in Starter`,body:eA}}function X7({kind:e,children:t}){return(0,h.jsx)(N4,{back:(0,h.jsx)(pa,{to:`/prompts`,search:{kind:e},children:`Back to Prompts`}),children:t})}function tbe({kind:e,onKind:t,onUseInPlay:n,playBlocked:r}){let{api:i}=R(),a=_(),o=M($y(i)),[s,c]=(0,m.useState)(``),l=(0,m.useRef)(null),u=vx(l,`prompts`),[d,f]=(0,m.useState)(void 0),[p,g]=(0,m.useState)(void 0),[v,y]=(0,m.useState)(void 0),b=N({mutationFn:e=>ys(i,e),onSettled:async()=>{g(void 0),await a.invalidateQueries({queryKey:z.prompts})}}),x=async(e,t)=>{let n=await _s(i,{kind:e.kind,name:t,body:e.body},e.id);return await a.invalidateQueries({queryKey:z.prompts}),n.ok?null:u3(n.fields)},S=o.data?.prompts.filter(t=>t.kind===e),C=s.trim().toLowerCase(),w=C===``?S:S?.filter(e=>e.name.toLowerCase().includes(C)||e.body.toLowerCase().includes(C)),T=w?.find(e=>e.id===d)??w?.[0];return(0,h.jsxs)(`div`,{children:[(0,h.jsxs)(r3,{action:(0,h.jsx)(rbe,{kind:e}),children:[(0,h.jsx)(OV,{type:`search`,ref:l,"aria-label":`Search prompts`,"aria-keyshortcuts":kx(u),placeholder:`Search prompts`,value:s,className:`w-full min-w-0 sm:w-64`,onChange:e=>c(e.target.value)}),(0,h.jsxs)(`span`,{className:`flex w-full items-center gap-1 sm:w-auto`,...Tb,children:[(0,h.jsx)(AV,{"aria-label":`Prompt kind`,value:e,className:`w-full sm:w-56`,options:yV,onChange:e=>{let n=yV.find(t=>t.value===e.target.value);n!==void 0&&t(n.value)}}),(0,h.jsx)(B,{id:`library.prompt.kind`})]})]}),o.error===null?null:(0,h.jsx)(t3,{what:`prompts`,message:o.error.message,onRetry:()=>void o.refetch()}),w===void 0||S===void 0?o.error===null?(0,h.jsx)(e3,{label:`Prompts`}):null:S.length===0?(0,h.jsxs)(T0,{title:`No ${bV(e).toLowerCase()} prompts yet`,children:[`A prompt is text with `,`{{keywords}}`,`; each keyword becomes a field on Play.`]}):(0,h.jsx)(Mq,{className:Q4,list:w.length===0?(0,h.jsx)(`p`,{className:`m-0 py-3 text-small text-ink-2`,children:`No ${bV(e).toLowerCase()} prompts match "${s.trim()}".`}):(0,h.jsx)(hU,{label:`Prompts`,children:w.map(e=>(0,h.jsx)(gU,{className:$4,title:(0,h.jsx)(d3,{name:e.name,onSelect:()=>f(e.id),onRename:t=>x(e,t)}),meta:nbe(e),selected:e.id===T?.id,actions:(0,h.jsx)(n3,{name:e.name,edit:(0,h.jsx)(lS,{to:`/prompts/$promptId`,params:{promptId:e.id},"aria-label":`Edit ${e.name}`,variant:`quiet`,size:`small`,children:`Edit`}),duplicate:(0,h.jsx)(lS,{to:`/prompts/new`,search:{kind:e.kind,from:e.id},"aria-label":`Duplicate ${e.name}`,variant:`quiet`,size:`small`,children:`Duplicate`}),play:{run:n===void 0?void 0:()=>n(e),blocked:r},onHistory:()=>y(e),onDelete:()=>g(e)})},e.id))}),detail:T===void 0?null:(0,h.jsx)(Y4,{item:`prompt`,id:T.id,name:T.name,kicker:`${bV(T.kind)} prompt`,meta:`Updated ${Z4(T.updatedAt)}`,body:T.body,slots:T.slots,actions:(0,h.jsx)(lS,{to:`/prompts/$promptId`,params:{promptId:T.id},size:`small`,children:`Edit prompt`}),onOpenHistory:()=>y(T)},T.id)}),b.error===null?null:(0,h.jsx)(fI,{tone:`danger`,title:`The prompt wasn't deleted.`,className:`mt-4`,children:b.error.message}),v===void 0?null:(0,h.jsx)(G4,{item:`prompt`,id:v.id,name:v.name,onClose:()=>y(void 0)},v.id),(0,h.jsx)(Ay,{open:p!==void 0,title:p===void 0?``:`Delete "${p.name}"?`,consequence:`Moves it to the trash for 30 days (Settings → Trash). Projects that used it keep their text.`,confirmLabel:`Delete prompt`,pending:b.isPending,onConfirm:()=>{p!==void 0&&b.mutate(p.id)},onCancel:()=>g(void 0)})]})}function nbe(e){return`${bV(e.kind)} · ${X4(e.slots.length,`keyword`)} · updated ${Z4(e.updatedAt)}`}function rbe({kind:e}){return(0,h.jsx)(lS,{to:`/prompts/new`,search:{kind:e},variant:`primary`,children:`New prompt`})}var ibe={template:`Template`,schedule:`Schedule`,draft:`Draft`,project:`Project`};function Z7(e){let t=[e.added.length>0?`${e.added.length} new`:null,e.priced.length>0?`${e.priced.length} repriced`:null,e.retired.length>0?`${e.retired.length} retired`:null].filter(e=>e!==null);return t.length===0?`No changes`:t.join(`, `)}function abe(){let{api:e}=R(),t=_(),n=Dy(),r=M({queryKey:c0.catalogue,queryFn:()=>mue(e),refetchInterval:3e4}),i=M({queryKey:c0.retired,queryFn:()=>d0(e)}),a=async()=>{await Promise.all([t.invalidateQueries({queryKey:[`provider-models`]}),t.invalidateQueries({queryKey:c0.retired})])},o=N({mutationFn:()=>hue(e),onSuccess:async e=>{t.setQueryData(c0.catalogue,e),n(e.sync?.warning??`Model list checked: ${Z7(e.sync?.changes??obe)}.`,e.sync?.warning?`error`:`success`),await a()}}),s=N({mutationFn:()=>gue(e),onSuccess:async e=>{n(`Catalogue replaced with the published file.`,`success`),t.setQueryData(c0.catalogue,e),await a()}}),c=async()=>{await Promise.all([t.invalidateQueries({queryKey:c0.retired}),t.invalidateQueries({queryKey:Rq}),t.invalidateQueries({queryKey:OH}),t.invalidateQueries({queryKey:[`play-drafts`]}),t.invalidateQueries({queryKey:[`projects`]}),t.invalidateQueries({queryKey:[`project`]})])},l=N({mutationFn:t=>f0(e,t),onSuccess:c}),u=N({mutationFn:()=>_ue(e),onSuccess:async e=>{n(e.failed.length===0?`Switched ${e.switched} ${e.switched===1?`use`:`uses`}.`:`Switched ${e.switched}; ${e.failed.length} could not be switched: ${e.failed[0]?.message??``}`,e.failed.length===0?`success`:`error`),await c()}}),d=r.data?.sync,f=i.data??[],p=f.filter(e=>e.blocked===null&&e.replacement!==null),m=o.error?.message??s.error?.message??r.error?.message??r.data?.warning??d?.warning??null;return _x({id:`settings.check-models`,title:`Check for new models`,group:`Settings`,context:`Models`,keywords:[`catalogue`,`prices`,`retired`],run:()=>{!o.isPending&&r.data?.path&&o.mutate()}}),(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`div`,{children:[(0,h.jsxs)(V,{title:`Model catalogue`,info:`settings.models.catalogue`,children:[(0,h.jsx)(L,{disabled:o.isPending||!r.data?.path,onClick:()=>o.mutate(),children:o.isPending?`Checking…`:`Check now`}),(0,h.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,h.jsx)(L,{variant:`quiet`,disabled:s.isPending||!r.data?.path,onClick:()=>s.mutate(),children:s.isPending?`Replacing…`:`Replace with published file`}),(0,h.jsx)(B,{id:`settings.models.replace`})]})]}),(0,h.jsxs)(`dl`,{className:`m-0 grid gap-x-6 border-t border-line text-small sm:grid-cols-[160px_minmax(0,1fr)]`,children:[(0,h.jsx)(`dt`,{className:`pt-3 font-semibold text-ink sm:border-b sm:border-line sm:pb-3`,children:`Catalogue file`}),(0,h.jsx)(`dd`,{className:`m-0 min-w-0 border-b border-line pb-3 break-all font-mono text-ink-2 sm:pt-3`,children:r.data?.path??`Not available`}),(0,h.jsx)(`dt`,{className:`pt-3 font-semibold text-ink sm:border-b sm:border-line sm:pb-3`,children:`Verified`}),(0,h.jsx)(`dd`,{className:`m-0 border-b border-line pb-3 text-ink-2 sm:pt-3`,children:r.data?.updatedAt??`date unavailable`}),(0,h.jsx)(`dt`,{className:`pt-3 font-semibold text-ink sm:border-b sm:border-line sm:pb-3`,children:`Last checked`}),(0,h.jsx)(`dd`,{className:`m-0 border-b border-line pb-3 text-ink-2 sm:pt-3`,children:d?.checkedAt?`${new Date(d.checkedAt).toLocaleString()} · ${Z7(d.changes)}`:`Not checked yet`})]}),d!==void 0&&d.changes.retired.length+d.changes.added.length>0?(0,h.jsxs)(`div`,{className:`mt-3 flex flex-col gap-1 text-small text-ink-2`,children:[d.changes.added.length>0?(0,h.jsxs)(`span`,{children:[`New: `,d.changes.added.map(e=>e.name).join(`, `)]}):null,d.changes.retired.length>0?(0,h.jsxs)(`span`,{children:[`Retired: `,d.changes.retired.map(e=>e.name).join(`, `)]}):null]}):null,m===null?null:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 mt-3 text-body text-danger`,children:m})]}),(0,h.jsxs)(`section`,{"aria-label":`Retired models in use`,children:[(0,h.jsx)(V,{title:`Retired models in use`,info:`settings.models.retired`,children:(0,h.jsx)(L,{variant:`primary`,disabled:u.isPending||p.length===0,onClick:()=>u.mutate(),children:u.isPending?`Switching…`:`Switch all`})}),i.error?(0,h.jsx)(`p`,{role:`alert`,className:`m-0 mb-2 text-body text-danger`,children:i.error.message}):null,l.error?(0,h.jsx)(`p`,{role:`alert`,className:`m-0 mb-2 text-body text-danger`,children:l.error.message}):null,f.length===0?(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:i.isPending?`Looking…`:`Nothing uses a retired model.`}):(0,h.jsx)(`ul`,{"aria-label":`Retired models in use`,className:`sl-list m-0 list-none p-0`,children:f.map(e=>(0,h.jsxs)(`li`,{className:`sl-row max-sm:grid-cols-1`,children:[(0,h.jsxs)(`div`,{className:`min-w-0`,children:[(0,h.jsxs)(`p`,{className:`m-0`,children:[(0,h.jsx)(`span`,{className:`sl-kicker`,children:ibe[e.kind]}),` `,(0,h.jsx)(`span`,{className:`font-semibold`,children:e.name})]}),(0,h.jsxs)(`p`,{className:`m-0 text-small text-ink-2`,children:[D0[e.slot],`: `,e.model,` (`,e.why===`retired`?`retired`:`no longer listed`,`)`]}),e.blocked===null?null:(0,h.jsx)(`p`,{className:`m-0 text-small text-waiting`,children:e.blocked})]}),(0,h.jsx)(Ty,{children:(0,h.jsx)(L,{size:`small`,disabled:e.blocked!==null||e.replacement===null||l.isPending,onClick:()=>l.mutate(e),children:e.replacement===null?`No replacement`:`Switch to ${e.replacement.name}`})})]},e.key))})]})]})}var obe={added:[],retired:[],priced:[]},sbe={ok:`Ready`,warning:`Check`,problem:`Needs fixing`,unused:`Not set up`},cbe={ok:`done`,warning:`waiting`,problem:`failed`,unused:`off`},lbe={ok:`text-ink-2`,warning:`text-waiting`,problem:`text-danger`,skipped:`text-ink-3`};function Q7(){let{api:e}=R();return N({mutationFn:()=>u0(e)})}function ube(e){let{api:t}=R(),[n,r]=(0,m.useState)({byId:new Map});return{one:N({mutationFn:e=>u0(t,e),onSuccess:t=>{r(n=>{let r=new Map(n.after===e?n.byId:[]);for(let e of t.providers)r.set(e.id,e);return{after:e,byId:r}})}}),latest:t=>n.after===e?n.byId.get(t.id)??t:t}}function dbe({run:e}={}){let t=Q7(),n=e??t,r=n.data,i=ube(r?.checkedAt),a=r?.providers.filter(e=>e.state!==`unused`).map(i.latest)??[],o=r?.providers.filter(e=>e.state===`unused`)??[];return(0,h.jsxs)(`section`,{"aria-label":`Health check`,children:[(0,h.jsx)(V,{title:`Health check`,info:`settings.health`,children:e===void 0?(0,h.jsx)(L,{disabled:n.isPending,onClick:()=>{n.mutate()},children:n.isPending?`Checking…`:`Check all`}):void 0}),n.error===null?null:(0,h.jsxs)(`p`,{role:`alert`,className:`m-0 mb-2 text-body text-danger`,children:[`The health check didn't finish: `,n.error.message,` Press Check all to try again.`]}),i.one.error===null?null:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 mb-2 text-body text-danger`,children:`The check didn't finish: ${i.one.error.message} Press Check again on the provider to try again.`}),r===void 0?(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:n.isPending?`Checking every provider…`:`Not checked yet.`}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`ul`,{"aria-label":`Health by provider`,className:`sl-list m-0 list-none p-0`,children:a.map(e=>(0,h.jsxs)(`li`,{className:`sl-row grid-cols-1 gap-1`,children:[(0,h.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center justify-between gap-2`,children:[(0,h.jsx)(`span`,{className:`sl-row__title`,children:e.displayName}),(0,h.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,h.jsx)(mS,{tone:cbe[e.state],children:sbe[e.state]}),(0,h.jsx)(L,{variant:`quiet`,size:`small`,"aria-label":`Check ${e.displayName} again`,disabled:i.one.isPending,onClick:()=>{i.one.mutate(e.id)},children:i.one.isPending&&i.one.variables===e.id?`Checking…`:`Check again`})]})]}),(0,h.jsx)(`ul`,{className:`m-0 list-none space-y-1 p-0`,children:e.checks.map(e=>(0,h.jsxs)(`li`,{className:I(`text-small`,lbe[e.state]),children:[(0,h.jsxs)(`span`,{className:`font-semibold`,children:[e.label,`:`]}),` `,e.detail]},e.label))})]},e.id))}),(0,h.jsx)(`p`,{className:`m-0 mt-3 text-small text-ink-2`,children:o.length===0?`Checked at ${new Date(r.checkedAt).toLocaleTimeString()}.`:`Not set up and not used anywhere: ${o.map(e=>e.displayName).join(`, `)}.`})]})]})}var $7={openrouter:`settings.provider.openrouter`,"claude-code":`settings.provider.claude-code`,codex:`settings.provider.codex`,gemini:`settings.provider.gemini`,elevenlabs:`settings.provider.elevenlabs`,"openai-tts":`settings.provider.openai-tts`,cartesia:`settings.provider.cartesia`,inworld:`settings.provider.inworld`,"system-voice":`settings.provider.system-voice`,"google-tts":`settings.provider.google-tts`,fal:`settings.provider.fal`,replicate:`settings.provider.replicate`,"openai-image":`settings.provider.openai-image`,"google-image":`settings.provider.google-image`,"codex-image":`settings.provider.codex-image`};function e9(e){return JP(e)?{tone:`done`,word:`Ready`}:e.installed?{tone:`waiting`,word:`Needs attention`}:{tone:`off`,word:`Not found`}}function fbe({provider:e,readiness:t,kind:n}){let{api:r}=R(),i=_(),a=(0,m.useId)(),[o,s]=(0,m.useState)(void 0),[c,l]=(0,m.useState)(!1),u=e.cliPath?.configured??null,d=e.cliPath?.managedOnHost===!0,f=e.id===`claude-code`?`claude`:e.id===`codex-image`?`codex`:e.id,p=e.cliPath?.command??f,g=o??u??``,v=JP(t),y=N({mutationFn:t=>Ko(r,e.id,t),onMutate:()=>l(!1),onSuccess:async e=>{i.setQueryData(z.providers,t=>t?{...t,providers:t.providers.map(t=>t.id===e.id?e:t)}:void 0),s(void 0),l(!0),await i.invalidateQueries({queryKey:z.providers})}});(0,m.useEffect)(()=>{if(!c)return;let e=setTimeout(()=>l(!1),f4);return()=>clearTimeout(e)},[c]);let[b,x]=(0,m.useState)(!1),S=(0,m.useId)();return(0,h.jsxs)(`section`,{"aria-labelledby":a,"data-ready":v,className:`flex min-w-0 flex-col gap-5`,children:[(0,h.jsxs)(`div`,{children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,h.jsx)(`h3`,{id:a,className:`sl-section-head__title`,children:e.displayName}),(0,h.jsx)(B,{id:$7[e.id],label:e.displayName})]}),(0,h.jsxs)(`p`,{className:`sl-section-head__meta`,children:[n,` · command line, no key needed`]})]}),(0,h.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,h.jsxs)(`p`,{className:`m-0 flex min-w-0 items-center gap-2`,"aria-live":`polite`,children:[(0,h.jsx)(pS,{tone:e9(t).tone}),(0,h.jsx)(`span`,{className:`min-w-0 break-words`,children:pbe(t,u)})]}),(0,h.jsxs)(`p`,{className:`m-0 flex min-w-0 items-center gap-2 text-small text-ink-2`,children:[(0,h.jsx)(`span`,{children:`Command`}),(0,h.jsx)(jV,{className:`min-w-0 truncate`,title:p,children:p})]})]}),(0,h.jsxs)(Ty,{children:[d?(0,h.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-small text-ink-2`,children:[`Managed on host`,(0,h.jsx)(B,{id:`settings.cli.managed-on-host`})]}):(0,h.jsx)(L,{"aria-expanded":b,"aria-controls":S,onClick:()=>x(e=>!e),children:b?`Close path`:`Change path`}),(0,h.jsx)(`span`,{className:`inline-flex w-[52px]`,children:c?(0,h.jsx)(m4,{}):null})]}),d||!b?null:(0,h.jsx)(`form`,{id:S,onSubmit:e=>{e.preventDefault(),y.isPending||y.mutate(g)},children:(0,h.jsx)(Y,{label:`Executable path`,tip:`settings.cli.path`,help:(0,h.jsxs)(h.Fragment,{children:[`Leave blank to find `,(0,h.jsx)(jV,{children:f}),` on PATH. Use an absolute path without quotes or arguments.`]}),error:y.error?.message,children:(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,h.jsx)(OV,{autoComplete:`off`,spellCheck:!1,maxLength:4096,"aria-label":`${e.displayName} Executable path`,className:`min-w-0 flex-1 basis-[220px]`,placeholder:f,value:g,disabled:y.isPending,onChange:e=>{s(e.target.value),l(!1),y.reset()}}),(0,h.jsx)(L,{type:`submit`,variant:`primary`,"aria-label":`Save ${e.displayName} path`,disabled:y.isPending,children:y.isPending?`Checking…`:`Save path`})]})})})]})}function pbe(e,t){return e.issue===void 0?e.installed?e.version===void 0?`Installed`:`Installed, version ${e.version}`:t===null?`Not found on PATH`:`Not found at saved path`:e.issue}var mbe=[`providers`,`system-voice`,`voices`];async function hbe(e){return P(await e.fetch(`${e.origin}/api/providers/system-voice/voices`))}function t9(e=!0){let{api:t}=R();return M({queryKey:mbe,queryFn:()=>hbe(t),enabled:e})}function n9(e){return e.available?{tone:`done`,word:`Ready`}:{tone:`off`,word:`Not found`}}function gbe({provider:e,readiness:t}){let n=(0,m.useId)(),r=t9(t.available).data?.engines??[];return(0,h.jsxs)(`section`,{"aria-labelledby":n,"data-ready":t.available,className:`flex min-w-0 flex-col gap-5`,children:[(0,h.jsxs)(`div`,{children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,h.jsx)(`h3`,{id:n,className:`sl-section-head__title`,children:e.displayName}),(0,h.jsx)(B,{id:$7[e.id],label:e.displayName})]}),(0,h.jsx)(`p`,{className:`sl-section-head__meta`,children:`Speech · built into this computer, no key needed`})]}),(0,h.jsxs)(`p`,{className:`m-0 flex min-w-0 items-center gap-2`,"aria-live":`polite`,children:[(0,h.jsx)(pS,{tone:n9(t).tone}),(0,h.jsx)(`span`,{className:`min-w-0 break-words`,children:t.available?`Found ${t.engine??`a speech program`}. Narration with it is free; a keyed voice (ElevenLabs, OpenAI) sounds better.`:t.issue??`No speech program was found on this computer.`})]}),r.length===0?null:(0,h.jsx)(`ul`,{className:`m-0 list-none p-0 text-small text-ink-2`,children:r.map(e=>{let t=e.voices.length;return(0,h.jsx)(`li`,{children:`${e.name}: ${t} voice${t===1?``:`s`}`},e.id)})}),t.available?(0,h.jsx)(Ty,{children:(0,h.jsx)(lS,{to:`/settings`,search:{section:`voices`},children:`Add a system voice`})}):null]})}function _be({value:e,onPick:t}){let n=t9(),r=n.data?.engines??[];return n.data!==void 0&&r.length===0?(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-small text-danger`,children:n.data.issue??`No speech program was found on this computer.`}):(0,h.jsxs)(AV,{value:e,onChange:e=>{for(let n of r){let r=n.voices.find(t=>t.id===e.target.value);if(r!==void 0)return t(r)}},children:[(0,h.jsx)(`option`,{value:``,children:n.data===void 0?`Looking for voices…`:`Pick a voice`}),r.map(e=>(0,h.jsx)(`optgroup`,{label:e.name,children:e.voices.map(e=>(0,h.jsx)(`option`,{value:e.id,children:e.language===void 0?e.name:`${e.name} (${e.language})`},e.id))},e.id))]})}var r9=[`llm`,`tts`,`image`],i9={llm:`Text`,tts:`Speech`,image:`Images`},vbe=`••••••••••••`;function ybe(e){return JP(e.readiness)}function bbe(e){return e.readiness.kind===`cli`?e9(e.readiness):e.readiness.kind===`local`?n9(e.readiness):e.readiness.hasKey?{tone:`done`,word:`Key saved`}:{tone:`off`,word:`No key`}}function xbe(){let{api:e}=R(),t=M(Zy(e)),[n,r]=(0,m.useState)(void 0),i=(0,m.useRef)(null),a=(0,m.useRef)(!1);(0,m.useEffect)(()=>{n!==void 0&&a.current&&(a.current=!1,typeof window.matchMedia==`function`&&window.matchMedia(`(max-width: 1023px)`).matches&&i.current?.scrollIntoView?.({block:`start`,behavior:`smooth`}))},[n]);let o=r9.flatMap(e=>(t.data?.providers??[]).filter(t=>t.family===e)),s=o.find(e=>!ybe(e))??o[0];if(n===void 0&&s!==void 0&&r(s.id),t.error!==null)return(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-body text-danger`,children:t.error.message});if(t.data===void 0)return(0,h.jsx)(Cbe,{});let c=o.find(e=>e.id===n)??s,l=o.every(e=>e.readiness.kind!==`keyed`||!e.readiness.hasKey),u=e=>{a.current=!0,r(e)};return(0,h.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-8`,children:[l?(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:`Paste a key to make its provider selectable on Play.`}):null,r9.map(e=>(0,h.jsxs)(`section`,{"data-tour":`keys-${e}`,"aria-labelledby":`keys-${e}-title`,className:`grid items-start gap-x-8 gap-y-6 lg:grid-cols-[minmax(0,1fr)_minmax(0,1fr)]`,children:[(0,h.jsxs)(`div`,{className:`min-w-0`,children:[(0,h.jsx)(V,{id:`keys-${e}-title`,title:i9[e],size:`small`,className:`pb-2`}),(0,h.jsx)(hU,{label:`${i9[e]} providers`,children:o.filter(t=>t.family===e).map(e=>{let t=bbe(e);return(0,h.jsx)(gU,{title:e.displayName,meta:e.readiness.kind===`cli`?`Command line`:e.readiness.kind===`local`?`Built in, no key`:`API key`,selected:e.id===c?.id,onSelect:()=>u(e.id),actions:(0,h.jsx)(mS,{tone:t.tone,children:t.word})},e.id)})})]}),c===void 0||c.family!==e?null:(0,h.jsx)(`div`,{ref:i,className:`min-w-0 scroll-mt-4`,children:c.readiness.kind===`cli`?(0,h.jsx)(fbe,{provider:c,readiness:c.readiness,kind:i9[c.family]},c.id):c.readiness.kind===`local`?(0,h.jsx)(gbe,{provider:c,readiness:c.readiness},c.id):(0,h.jsx)(Sbe,{provider:c,hasKey:c.readiness.hasKey},c.id)})]},e))]})}function Sbe({provider:e,hasKey:t}){let{api:n}=R(),r=_(),i=(0,m.useId)(),a=(0,m.useId)(),[o,s]=(0,m.useState)(``),[c,l]=(0,m.useState)(!1),[u,d]=(0,m.useState)(!1),[f,p]=(0,m.useState)(void 0),[g,v]=(0,m.useState)(!1),[y,b]=(0,m.useState)(!1),[x,S]=(0,m.useState)(void 0),C=(0,m.useId)(),w=jF[e.id],T=o.trim(),E=async()=>{b(!0),S(void 0);try{S(await pue(n,e.id,T===``?void 0:T))}catch(e){p(e instanceof Error?e.message:String(e))}finally{b(!1)}},D=async()=>{l(!0),p(void 0);try{await Go(n,e.id,o),s(``),d(!0),S(void 0),await r.invalidateQueries({queryKey:z.providers})}catch(e){p(e instanceof Error?e.message:String(e))}finally{l(!1)}},O=N({mutationFn:()=>qo(n,e.id),onSuccess:async()=>{v(!1),p(void 0),await r.invalidateQueries({queryKey:z.providers})},onError:e=>{v(!1),p(e.message)}});(0,m.useEffect)(()=>{if(!u)return;let e=setTimeout(()=>{d(!1)},f4);return()=>{clearTimeout(e)}},[u]);let k=[t?a:void 0,x===void 0?void 0:C].filter(e=>e!==void 0).join(` `);return(0,h.jsxs)(`section`,{"aria-labelledby":i,"data-ready":t,className:`flex min-w-0 flex-col gap-5`,children:[(0,h.jsx)(V,{as:`h3`,size:`default`,id:i,title:t?e.displayName:`Set up ${e.displayName}`,info:$7[e.id],infoLabel:e.displayName,meta:`${i9[e.family]} · ${t?`a key is saved`:`needs an API key`}`,className:`pb-0`}),w===void 0?null:t?(0,h.jsxs)(`details`,{className:`text-small text-ink-2`,children:[(0,h.jsx)(`summary`,{className:`cursor-pointer`,children:`Where to get a key`}),(0,h.jsx)(`div`,{className:`mt-2 flex flex-col gap-2`,children:(0,h.jsx)(a9,{guide:w})})]}):(0,h.jsx)(`div`,{className:`flex flex-col gap-2 text-small text-ink-2`,children:(0,h.jsx)(a9,{guide:w})}),(0,h.jsx)(Y,{label:`${e.displayName} API key`,tip:`settings.providers.api-key`,help:`Stored on this computer only. Never in backups or exports.`,error:f,children:(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,h.jsx)(OV,{type:`password`,autoComplete:`off`,spellCheck:!1,className:`min-w-0 flex-1 basis-[200px]`,"aria-describedby":k===``?void 0:k,placeholder:t?vbe:`Paste API key`,value:o,onChange:e=>{s(e.target.value)}}),(0,h.jsx)(L,{variant:`primary`,"aria-label":`Save ${e.displayName} key`,disabled:o.trim()===``||c,onClick:()=>{D()},children:`Save`})]})}),t?(0,h.jsx)(`span`,{id:a,className:`sr-only`,children:`A key is stored for this provider.`}):null,x===void 0?null:(0,h.jsx)(`p`,{id:C,role:x.ok?`status`:`alert`,className:I(`m-0 text-small`,x.ok?`text-accent-ink`:`text-danger`),children:x.message}),(0,h.jsxs)(Ty,{children:[(0,h.jsx)(L,{"aria-label":`Test ${e.displayName} key`,disabled:!t&&T===``||y,disabledReason:`Paste a key first.`,onClick:()=>{E()},children:y?`Testing…`:`Test`}),(0,h.jsx)(B,{id:`settings.providers.test-key`,label:`Test`}),(0,h.jsx)(L,{variant:`quiet`,"aria-label":`Remove ${e.displayName} key`,disabled:!t,onClick:()=>{v(!0)},children:`Remove`}),(0,h.jsx)(`span`,{className:`inline-flex w-[52px]`,children:u?(0,h.jsx)(m4,{}):null})]}),(0,h.jsx)(Ay,{open:g,title:`Remove the ${e.displayName} key?`,consequence:`Projects that used this provider cannot retry until a key is saved.`,confirmLabel:`Remove key`,pending:O.isPending,onConfirm:()=>{O.mutate()},onCancel:()=>{v(!1)}})]})}function a9({guide:e}){let t=(e,t)=>(0,h.jsx)(`a`,{href:e,target:`_blank`,rel:`noreferrer`,className:`underline`,children:t});return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`ol`,{className:`m-0 list-decimal space-y-1 pl-5`,children:e.steps.map(e=>(0,h.jsx)(`li`,{children:e},e))}),(0,h.jsxs)(`p`,{className:`m-0`,children:[`Sign up: `,t(e.signUp.url,e.signUp.label),`. Make the key:`,` `,t(e.keyPage.url,e.keyPage.label),`.`,e.billing===void 0?null:(0,h.jsxs)(h.Fragment,{children:[` Credit: `,t(e.billing.url,e.billing.label),`.`]})]}),(0,h.jsx)(`p`,{className:`m-0`,children:e.permissions}),(0,h.jsxs)(`p`,{className:`m-0`,children:[`More in the provider's `,t(e.docs.url,e.docs.label),`. After saving, choose Test.`]})]})}function Cbe(){return(0,h.jsxs)(`div`,{className:`grid items-start gap-8 lg:grid-cols-[minmax(0,1fr)_minmax(0,1fr)]`,role:`status`,"aria-label":`Loading providers`,children:[(0,h.jsx)(`div`,{className:`flex flex-col gap-6`,children:[[`llm`,4],[`tts`,5],[`image`,5]].map(([e,t])=>(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`span`,{className:`mb-2 block h-3 w-16 rounded-control bg-raised`}),(0,h.jsx)(`div`,{className:`sl-list`,children:Array.from({length:t},(t,n)=>`${e}-${n}`).map(e=>(0,h.jsxs)(`div`,{className:`sl-row`,children:[(0,h.jsx)(`span`,{className:`h-4 w-32 rounded-control bg-raised`}),(0,h.jsx)(`span`,{className:`h-4 w-20 rounded-control bg-raised`})]},e))})]},e))}),(0,h.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,h.jsx)(`span`,{className:`h-6 w-48 rounded-control bg-raised`}),(0,h.jsx)(`span`,{className:`h-10 rounded-control bg-raised`})]})]})}function o9(e){return e.split(/[\s,;]+/).map(e=>e.trim().toLowerCase()).filter(e=>e!==``)}function wbe(e){return e.languages===void 0?`Any (not known)`:e.languages.map(e=>YO(e).code===e?YO(e).name:e).join(`, `)}function Tbe({voice:e}){let{api:t}=R(),n=_(),r=(0,m.useId)(),[i,a]=(0,m.useState)(!1),[o,s]=(0,m.useState)((e.languages??[]).join(`, `)),[c,l]=(0,m.useState)(void 0),u=N({mutationFn:()=>ds(t,e.id,o9(o)),onSuccess:async e=>{if(e!==void 0){l(e.message);return}a(!1),l(void 0),await n.invalidateQueries({queryKey:z.voices})}});return i?(0,h.jsxs)(`div`,{className:`grid gap-1`,children:[(0,h.jsx)(OV,{id:r,"aria-label":`Languages of ${e.name}`,value:o,placeholder:`es, de`,"aria-invalid":c!==void 0,onChange:e=>{s(e.target.value),l(void 0)}}),c===void 0?null:(0,h.jsx)(`p`,{className:`m-0 text-small text-danger`,children:c}),u.error===null?null:(0,h.jsx)(`p`,{className:`m-0 text-small text-danger`,children:u.error.message}),(0,h.jsxs)(`div`,{className:`flex gap-2`,children:[(0,h.jsx)(L,{size:`small`,disabled:u.isPending,onClick:()=>u.mutate(),children:`Save`}),(0,h.jsx)(L,{variant:`quiet`,size:`small`,onClick:()=>{a(!1),l(void 0),s((e.languages??[]).join(`, `))},children:`Cancel`})]})]}):(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,h.jsx)(`span`,{className:`text-ink-2`,children:wbe(e)}),(0,h.jsx)(L,{variant:`quiet`,size:`small`,"aria-label":`Edit the languages of ${e.name}`,onClick:()=>a(!0),children:`Edit`})]})}function Ebe(){let{api:e}=R(),t=_(),n=M(Qy(e)),r=M(Zy(e)),[i,a]=(0,m.useState)(void 0),o=N({mutationFn:t=>ps(e,t),onSettled:async()=>{a(void 0),await t.invalidateQueries({queryKey:z.voices})}}),s=N({mutationFn:({id:t,on:n})=>fs(e,t,n),onSettled:async()=>{await t.invalidateQueries({queryKey:z.voices})}}),c=(r.data?.providers??[]).filter(e=>e.family===`tts`);if(n.error!==null)return(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-body text-danger`,children:n.error.message});let l=n.data?.voices;return(0,h.jsxs)(`div`,{"data-tour":`voices`,className:`flex min-w-0 flex-col gap-10`,children:[(0,h.jsxs)(`div`,{className:`min-w-0 overflow-x-auto`,children:[(0,h.jsxs)(`table`,{className:`sl-table min-w-[640px] table-fixed`,...Tb,children:[(0,h.jsx)(`caption`,{className:`sr-only`,children:`Voices`}),(0,h.jsx)(`thead`,{children:(0,h.jsxs)(`tr`,{children:[(0,h.jsx)(`th`,{scope:`col`,className:`w-[22%] pr-4`,children:`Name`}),(0,h.jsx)(`th`,{scope:`col`,className:`w-[18%] pr-4`,children:`Provider`}),(0,h.jsx)(`th`,{scope:`col`,className:`pr-4`,children:`Voice ID`}),(0,h.jsx)(`th`,{scope:`col`,className:`w-[22%] pr-4`,children:(0,h.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[`Languages`,(0,h.jsx)(B,{id:`play.voices.languages`,className:`-my-1`})]})}),(0,h.jsx)(`th`,{scope:`col`,className:`w-[20%] pr-4`,children:(0,h.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[`Real person`,(0,h.jsx)(B,{id:`play.voices.real-person`,className:`-my-1`})]})}),(0,h.jsx)(`th`,{scope:`col`,className:`w-[96px]`,children:(0,h.jsx)(`span`,{className:`sr-only`,children:`Remove`})})]})}),(0,h.jsx)(`tbody`,{children:l===void 0?(0,h.jsx)(`tr`,{children:(0,h.jsx)(`td`,{colSpan:6,children:(0,h.jsx)(`span`,{className:`block h-4 w-64 rounded-control bg-raised`})})}):l.length===0?(0,h.jsx)(`tr`,{children:(0,h.jsx)(`td`,{colSpan:6,className:`text-ink-2`,children:`Add a voice ID from your text-to-speech provider. Audio needs one to narrate.`})}):l.map(e=>(0,h.jsxs)(`tr`,{children:[(0,h.jsx)(`td`,{className:`truncate pr-4 font-semibold`,children:e.name}),(0,h.jsx)(`td`,{className:`truncate pr-4 text-ink-2`,children:Obe(c,e.provider)}),(0,h.jsx)(`td`,{className:`truncate pr-4 text-ink-2`,children:e.voiceId}),(0,h.jsx)(`td`,{className:`pr-4`,children:(0,h.jsx)(Tbe,{voice:e})}),(0,h.jsx)(`td`,{className:`pr-4`,children:(0,h.jsx)(Eb,{checked:s.isPending&&s.variables.id===e.id?s.variables.on:e.imitatesRealPerson===!0,disabled:s.isPending,onChange:t=>s.mutate({id:e.id,on:t}),label:(0,h.jsx)(`span`,{className:`sr-only`,children:`${e.name} imitates a real person`}),className:`text-small`})}),(0,h.jsx)(`td`,{className:`text-right`,children:(0,h.jsx)(L,{variant:`quiet`,size:`small`,"aria-label":`Remove ${e.name}`,onClick:()=>{a(e)},children:`Remove`})})]},e.id))})]}),s.error===null?null:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 mt-2 text-small text-danger`,children:`Couldn't change Real person: ${s.error.message} Press the switch again.`}),o.error===null?null:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 mt-2 text-small text-danger`,children:o.error.message})]}),(0,h.jsxs)(`div`,{children:[(0,h.jsx)(V,{title:`Add a voice`}),(0,h.jsx)(Dbe,{tts:c})]}),(0,h.jsx)(Ay,{open:i!==void 0,title:i===void 0?``:`Remove ${i.name}?`,consequence:`Projects that used this voice keep the audio they made with it.`,confirmLabel:`Remove voice`,pending:o.isPending,onConfirm:()=>{i!==void 0&&o.mutate(i.id)},onCancel:()=>{a(void 0)}})]})}function Dbe({tts:e}){let{api:t}=R(),n=_(),[r,i]=(0,m.useState)(``),[a,o]=(0,m.useState)(``),[s,c]=(0,m.useState)(``),[l,u]=(0,m.useState)(void 0),[d,f]=(0,m.useState)(void 0),p=l??e[0]?.id,g=N({mutationFn:e=>us(t,e),onSuccess:async e=>{if(!e.ok){f(e.refusal);return}i(``),o(``),c(``),f(void 0),await n.invalidateQueries({queryKey:z.voices})}}),v=(e,t)=>{t(),d?.field===e&&f(void 0)},y=e=>d?.field===e?d.message:void 0;return(0,h.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,h.jsxs)(`div`,{className:`grid items-start gap-4 md:grid-cols-[minmax(0,1fr)_minmax(0,1fr)_minmax(0,1fr)_minmax(0,1fr)_auto]`,children:[(0,h.jsx)(Y,{label:`Voice name`,tip:`play.voices.name`,error:y(`name`),children:(0,h.jsx)(OV,{value:r,onChange:e=>{let t=e.target.value;v(`name`,()=>{i(t)})}})}),(0,h.jsx)(Y,{label:`Provider`,tip:`play.voices.provider`,error:y(`provider`),children:(0,h.jsxs)(AV,{value:p??``,onChange:t=>{let n=e.find(e=>e.id===t.target.value);n!==void 0&&v(`provider`,()=>{u(n.id)})},children:[e.length===0?(0,h.jsx)(`option`,{value:``,children:`No speech provider`}):null,e.map(e=>(0,h.jsx)(`option`,{value:e.id,children:e.displayName},e.id))]})}),(0,h.jsx)(Y,{label:`Voice ID`,tip:`play.voices.voice-id`,error:y(`voiceId`),...p===`inworld`?{help:`Use an Inworld voice ID, such as Dennis, or one from your workspace.`}:{},children:p===`system-voice`?(0,h.jsx)(_be,{value:a,onPick:e=>{v(`voiceId`,()=>{o(e.id)}),r.trim()===``&&i(e.name);let t=/^([a-z]{2,3})(?:[-_]|$)/i.exec(e.language??``)?.[1];s.trim()===``&&t!==void 0&&c(t.toLowerCase())}}):p===`google-tts`?(0,h.jsx)(AV,{value:a,options:[{value:``,label:`Pick a Gemini voice`},...NF.map(e=>({value:e.name,label:`${e.name} (${e.style})`}))],onChange:e=>{let t=e.target.value;v(`voiceId`,()=>{o(t),r.trim()===``&&i(t)})}}):(0,h.jsx)(OV,{className:`tabular-nums`,value:a,onChange:e=>{let t=e.target.value;v(`voiceId`,()=>{o(t)})}})}),(0,h.jsx)(Y,{label:`Languages`,tip:`play.voices.languages`,help:`Codes such as es, de.`,error:y(`languages`),children:(0,h.jsx)(OV,{value:s,placeholder:`es, de`,onChange:e=>{let t=e.target.value;v(`languages`,()=>{c(t)})}})}),(0,h.jsx)(L,{variant:`primary`,className:`md:mt-6`,disabled:p===void 0||d!==void 0||g.isPending,onClick:()=>{if(p!==void 0){let e=o9(s);g.mutate({provider:p,name:r,voiceId:a,...e.length===0?{}:{languages:e}})}},children:`Add voice`})]}),g.error===null?null:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-small text-danger`,children:g.error.message})]})}function Obe(e,t){return e.find(e=>e.id===t)?.displayName??t}var s9=[`settings`,`notifications`],kbe=`The test notification couldn't be shown: this browser only allows notifications from installed apps. Set a Notification URL below instead.`;function Abe(){return(0,h.jsxs)(`div`,{children:[(0,h.jsx)(V,{title:`Browser and phone`,info:`settings.notifications`}),(0,h.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[(0,h.jsx)(jbe,{}),(0,h.jsx)(Mbe,{})]})]})}function jbe(){let e=(0,m.useSyncExternalStore)(CP,xP,()=>!1),[t,n]=(0,m.useState)(bP),[r,i]=(0,m.useState)(void 0),[a,o]=(0,m.useState)(!1),s=Dy(),c=e&&t===`granted`;async function l(e){if(i(void 0),!e){SP(!1);return}o(!0);try{let e=await EP();n(e);let t=TP(e);e===`granted`?(SP(!0),xP()||i(`Browser notifications couldn't be turned on because this browser blocks site storage for Slopify. Allow site data for this address in your browser's settings, then turn Browser notifications on again.`)):i(t??`Browser notifications weren't turned on because the permission prompt was dismissed. Turn Browser notifications on again and choose Allow.`)}finally{o(!1)}}return(0,h.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-6 gap-y-2`,children:[(0,h.jsx)(Eb,{label:`Browser notifications`,tip:`settings.notifications.browser`,checked:c,disabled:a,onChange:e=>void l(e)}),(0,h.jsx)(L,{variant:`quiet`,disabled:!c,disabledReason:`Turn Browser notifications on first.`,onClick:()=>{i(void 0);try{OP({projectId:`test`,text:LP},()=>{}),s(`Test notification sent to this browser.`,`success`)}catch{i(kbe)}},children:`Send test notification`})]}),(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:`Works while any Slopify tab is open.`}),r===void 0?null:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-small text-danger`,children:r})]})}function Mbe(){let{api:e}=R(),t=_(),n=Dy(),r=(0,m.useId)(),i=M({queryKey:s9,queryFn:()=>Xo(e)}),[a,o]=(0,m.useState)(void 0),s=a??i.data?.url??``,c=zP(s),l=N({mutationFn:t=>Qo(e,t),onSuccess:e=>{t.setQueryData(s9,e),o(void 0),n(e.url===null?`Notification URL removed.`:`Notification URL saved.`,`success`)}}),u=N({mutationFn:t=>$o(e,t),onSuccess:()=>{n(`Test notification sent. Check the app or page behind your Notification URL.`,`success`)}}),d=c??l.error?.message??u.error?.message,f=l.isPending||u.isPending||i.data===void 0;return(0,h.jsxs)(Y,{label:`Notification URL`,tip:`settings.notifications.url`,help:`Works with no tab open, for example an ntfy topic on your phone.`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,h.jsx)(OV,{type:`url`,inputMode:`url`,autoComplete:`off`,spellCheck:!1,placeholder:`https://ntfy.sh/your-topic`,className:`min-w-0 flex-1 basis-[220px]`,value:s,disabled:i.data===void 0,"aria-invalid":c!==void 0,"aria-describedby":d===void 0?void 0:r,onChange:e=>{l.reset(),u.reset(),o(e.target.value)}}),(0,h.jsx)(L,{variant:`primary`,disabled:f||c!==void 0||a===void 0,onClick:()=>l.mutate(s),children:`Save`}),(0,h.jsx)(L,{variant:`quiet`,disabled:f||c!==void 0||s.trim()===``,onClick:()=>u.mutate(s),children:`Send test notification`})]}),i.error===null?null:(0,h.jsxs)(`p`,{role:`alert`,className:`m-0 text-small text-danger`,children:[`The saved Notification URL couldn't be read: `,i.error.message]}),d===void 0?null:(0,h.jsx)(`p`,{id:r,role:`alert`,className:`m-0 text-small text-danger`,children:d})]})}var c9={library:`The Library of Alexandria`,audiobook:`The Wind in the Willows (audiobook)`,podcast:`The Antikythera Mechanism (podcast)`};function Nbe(){let{api:e}=R(),t=_(),n=M({queryKey:My,queryFn:()=>By(e)}),r=N({mutationFn:()=>Hy(e),onSettled:async()=>{await t.invalidateQueries({queryKey:My}),await t.invalidateQueries({queryKey:jy}),await t.invalidateQueries({queryKey:z.projects})}}),i=r.data?.samples??n.data?.samples;return(0,h.jsxs)(`div`,{className:`mt-8`,children:[(0,h.jsx)(V,{title:`Sample projects`,info:`settings.sample.restore`}),(0,h.jsx)(hU,{label:`Sample projects`,children:Object.keys(c9).map(e=>{let t=i?.[e]??null;return(0,h.jsx)(gU,{title:c9[e],meta:t===null?`Not in your projects`:`In your projects`,actions:t===null?void 0:(0,h.jsx)(uS,{to:`/projects/$projectId`,params:{projectId:t},className:mU,children:`Open`})},e)})}),(0,h.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-3`,children:[(0,h.jsx)(L,{disabled:r.isPending,onClick:()=>r.mutate(),children:r.isPending?`Restoring…`:`Restore samples`}),(0,h.jsx)(`span`,{className:`text-small text-ink-2`,children:`Puts all three back as they shipped.`})]}),(0,h.jsx)(v0,{tone:r.error?`error`:`success`,children:r.error?.message??(r.isSuccess?`The samples are back in Projects.`:void 0)})]})}var Pbe=[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`];function Fbe(e){let[t,n,r]=e.split(`-`).map(Number),i=Pbe[(n??0)-1];return i===void 0||r===void 0?e:`${String(r)} ${i} ${String(t)}`}function l9(e,t){let n=[e.range===void 0?e.version:`Versions ${e.range}`,`released ${Fbe(e.date)}`].filter(e=>e!==void 0).join(`, `),r=n.charAt(0).toUpperCase()+n.slice(1);return e.version===t?`${r}. The version you are running.`:`${r}.`}function Ibe({note:e,onNote:t}){let{api:n}=R(),r=M(nI(n));if(r.error!==null)return(0,h.jsx)(fI,{tone:`danger`,title:`The patch notes did not load`,actions:(0,h.jsx)(L,{onClick:()=>void r.refetch(),children:`Try again`}),children:`${r.error.message} Press Try again, or reload the page.`});if(r.data===void 0)return(0,h.jsx)(`p`,{className:`m-0 text-ink-3`,children:`Loading the patch notes…`});let{notes:i,version:a}=r.data,[o,...s]=i;if(o===void 0)return(0,h.jsx)(`p`,{className:`m-0 text-ink-2`,children:`This version of Slopify has no patch notes.`});let c=e===void 0?void 0:i.find(t=>t.id===e),l=c!==void 0&&c.id!==o.id?c:void 0;return l===void 0?(0,h.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[e!==void 0&&c===void 0?(0,h.jsx)(`p`,{role:`status`,className:`m-0 text-small text-ink-2`,children:`There are no patch notes called "${e}" in this version. The latest are below; older ones are under Earlier versions.`}):null,(0,h.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,h.jsx)(V,{title:`Latest version`,meta:l9(o,a),info:`settings.patch-notes`}),(0,h.jsx)(DB,{id:o.id})]}),s.length===0?null:(0,h.jsxs)(`details`,{className:`max-w-prose border-t border-line py-3`,children:[(0,h.jsx)(`summary`,{className:`cursor-pointer font-semibold`,children:`Earlier versions (${String(s.length)})`}),(0,h.jsx)(hU,{label:`Earlier versions`,className:`mt-2`,children:s.map(e=>(0,h.jsx)(gU,{title:e.title,meta:l9(e,a),onSelect:()=>t(e.id),actions:(0,h.jsx)(L,{"aria-label":`Read ${e.title}`,onClick:()=>t(e.id),children:`Read`})},e.id))})]})]}):(0,h.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,h.jsx)(`div`,{children:(0,h.jsxs)(L,{variant:`quiet`,onClick:()=>t(void 0),children:[(0,h.jsx)(Qs,{"aria-hidden":`true`,strokeWidth:1.75}),`Back to the latest patch notes`]})}),(0,h.jsx)(V,{title:`Earlier version`,meta:l9(l,a)}),(0,h.jsx)(DB,{id:l.id})]})}var u9=[`trash`];async function Lbe(e){return(await P(await e.client.trash.$get())).items}async function Rbe(e,t,n){return(await P(await e.client.trash[`:kind`][`:id`].restore.$post({param:{kind:t,id:n}}))).restored}async function zbe(e,t,n){let r=await e.client.trash[`:kind`][`:id`].$delete({param:{kind:t,id:n}});if(!r.ok)throw await co(r)}var Bbe={project:`Project`,prompt:`Prompt`,entry:`Intro/outro`,template:`Template`,schedule:`Schedule`};function Vbe(e){return e.kind===`entry`&&e.detail!==null?e.detail===`intro`?`Intro`:`Outro`:e.kind===`prompt`&&e.detail!==null?`Prompt · ${e.detail}`:Bbe[e.kind]}function Hbe(e){return e<=0?`removed for good today`:e===1?`1 day left`:`${String(e)} days left`}var Ube=new Intl.DateTimeFormat(void 0,{dateStyle:`medium`}),Wbe={project:[z.projects,[`calendar`]],prompt:[z.prompts],entry:[z.entries],template:[Rq],schedule:[OH,[`calendar`]]};function Gbe(){let{api:e}=R(),t=_(),n=Dy(),r=M({queryKey:u9,queryFn:()=>Lbe(e)}),[i,a]=(0,m.useState)(void 0),o=async e=>{await Promise.all([u9,...Wbe[e.kind]].map(e=>t.invalidateQueries({queryKey:e})))},s=N({mutationFn:t=>Rbe(e,t.kind,t.id),onSuccess:async(e,t)=>{await o(t),n(e.renamedFrom===null?`Restored "${e.name}".`:`Restored as "${e.name}": another item is now called "${e.renamedFrom}".`,`success`),e.kind===`schedule`&&n(`The schedule is paused. Press Resume on Schedules to run it again.`,`info`)},onError:e=>n(e.message,`error`)}),c=N({mutationFn:t=>zbe(e,t.kind,t.id),onSuccess:async(e,t)=>{a(void 0),await o(t),n(`Deleted "${t.name}" for good.`,`success`)},onError:e=>{a(void 0),n(e.message,`error`)}}),l=r.data??[];return(0,h.jsxs)(`div`,{children:[(0,h.jsx)(V,{title:`Trash`,info:`settings.trash`}),r.isPending?(0,h.jsx)(`p`,{className:`text-small text-ink-3`,children:`Loading the trash…`}):r.error?(0,h.jsx)(`p`,{role:`alert`,className:`text-small text-danger`,children:r.error.message}):l.length===0?(0,h.jsx)(T0,{title:`The trash is empty`,children:`Anything you delete stays here for 30 days before it is removed for good.`}):(0,h.jsx)(hU,{label:`Deleted items`,children:l.map(e=>(0,h.jsx)(gU,{title:e.name,meta:`${Vbe(e)} · deleted ${Ube.format(new Date(e.deletedAt))} · ${Hbe(e.daysLeft)}`,actions:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(L,{size:`small`,disabled:s.isPending||c.isPending,disabledReason:`Working on it`,onClick:()=>s.mutate(e),children:`Restore`}),(0,h.jsx)(L,{size:`small`,variant:`destructive`,disabled:s.isPending||c.isPending,disabledReason:`Working on it`,onClick:()=>a(e),children:`Delete now`})]})},`${e.kind}:${e.id}`))}),(0,h.jsx)(Ay,{open:i!==void 0,title:i===void 0?``:`Delete "${i.name}" for good?`,consequence:i?.kind===`project`?`The project and every file it produced are removed from disk. This cannot be undone.`:i?.kind===`schedule`?`The schedule leaves the trash and cannot be restored. Its run history stays on Schedules.`:`It is removed for good. This cannot be undone.`,confirmLabel:`Delete for good`,cancelLabel:`Keep it`,pending:c.isPending,onConfirm:()=>{i!==void 0&&c.mutate(i)},onCancel:()=>{c.isPending||a(void 0)}})]})}var Kbe=`https://github.com/GentBajko/slopify`,qbe=`https://www.patreon.com/cw/GentBajko`,Jbe=`https://buymeacoffee.com/gentbajko`;function Ybe(){return[{href:Kbe,label:`GitHub`,detail:`The code, issues and releases.`,glyph:`github`},{href:qbe,label:`Patreon`,detail:`Monthly support for the project.`,glyph:`patreon`},{href:Jbe,label:`Buy Me a Coffee`,detail:`A one-off thank you.`,glyph:`coffee`},{href:`https://slopify.stream/channel.html`,label:`How I run a channel with it`,detail:`A lore channel run on Slopify, start to finish.`}]}function Xbe({onWhatsNew:e}){return(0,h.jsxs)(`div`,{className:`max-w-prose`,children:[(0,h.jsx)(V,{title:`About`}),(0,h.jsx)(`p`,{className:`m-0 mb-3 text-ink-2`,children:`Slopify is free and open source, and runs on your machine with your own keys. If it saves you time, you can support it here.`}),(0,h.jsxs)(`p`,{className:`m-0 mb-3 flex items-center gap-1 text-small text-ink-2`,children:[`Updates: the circular-arrows button at the foot of the sidebar (at the top on a phone).`,(0,h.jsx)(B,{id:`settings.updates`})]}),e===void 0?null:(0,h.jsxs)(`p`,{className:`m-0 mb-3 flex items-center gap-1`,children:[(0,h.jsx)(L,{onClick:e,children:`What's new in this version`}),(0,h.jsx)(B,{id:`settings.whats-new`})]}),(0,h.jsx)(`p`,{className:`m-0 mb-4 text-small text-ink-2`,children:`Made by Gent Bajko. Apache License 2.0: anyone who redistributes Slopify or builds on it keeps this credit.`}),(0,h.jsx)(`ul`,{"aria-label":`Links`,className:`sl-list m-0 list-none p-0`,children:Ybe().map(e=>(0,h.jsx)(`li`,{className:`sl-row`,children:(0,h.jsxs)(`div`,{className:`sl-row__lead`,children:[e.glyph===void 0?(0,h.jsx)(`span`,{"aria-hidden":`true`,className:`size-[14px] shrink-0`}):(0,h.jsx)(oS,{name:e.glyph,className:`shrink-0 text-ink-2`}),(0,h.jsxs)(`div`,{className:`sl-row__text`,children:[(0,h.jsx)(`a`,{href:e.href,target:`_blank`,rel:`noreferrer`,className:`font-semibold text-ink underline underline-offset-3`,children:e.label}),(0,h.jsx)(`span`,{className:`sl-row__meta`,children:e.detail})]})]})},e.label))})]})}var d9=[`backups`],f9=1,p9=30;function m9(){return Intl.DateTimeFormat().resolvedOptions().timeZone||`UTC`}function Zbe(e){let t=e.trim();return/^\d+$/.test(t)&&Number(t)>=f9&&Number(t)<=p9?void 0:`Keep between ${f9} and ${p9} backups.`}function Qbe(e){return{enabled:e.config.enabled,time:e.config.time,keep:String(e.config.keep),folder:e.config.folder??``}}function h9(){let{api:e}=R(),t=_(),n=Dy();return N({mutationFn:()=>Eo(e),onSuccess:e=>{t.setQueryData(d9,e),n(`Backup started. Its result shows here when it finishes.`,`success`)}})}function $be(){let{api:e}=R(),t=_(),n=M({queryKey:d9,queryFn:()=>wo(e),refetchInterval:e=>e.state.data?.running===!0&&2e3}),[r,i]=(0,m.useState)(void 0),[a,o]=(0,m.useState)(!1),s=N({mutationFn:t=>To(e,t),onSuccess:e=>{t.setQueryData(d9,e),i(void 0),o(!0)}}),c=h9();(0,m.useEffect)(()=>{if(!a)return;let e=setTimeout(()=>o(!1),f4);return()=>clearTimeout(e)},[a]);let l=n.data,u=r??(l===void 0?void 0:Qbe(l)),d=u===void 0?void 0:Zbe(u.keep),f=e=>{u!==void 0&&i({...u,...e})};return(0,h.jsxs)(`div`,{children:[(0,h.jsx)(V,{title:`Daily backup`,info:`settings.backups`,children:(0,h.jsx)(L,{variant:`primary`,disabled:l===void 0||l.running||c.isPending,onClick:()=>c.mutate(),children:`Back up now`})}),(0,h.jsxs)(`div`,{className:`mb-6 flex flex-col gap-3`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap justify-between gap-x-4 gap-y-1 text-small text-ink-2`,children:[(0,h.jsx)(`span`,{role:`status`,children:l===void 0?(0,h.jsx)(`span`,{className:`inline-block h-4 w-48 rounded-control bg-raised`}):exe(l)}),(0,h.jsx)(`span`,{children:l===void 0?null:txe(l)})]}),l?.status.detail?l.status.lastResult===`failed`?(0,h.jsx)(fI,{tone:`danger`,title:`Why the last backup stopped`,children:l.status.detail}):(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:l.status.detail}):null,c.error?(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-small text-danger`,children:c.error.message}):null]}),n.error?(0,h.jsxs)(`p`,{role:`alert`,className:`m-0 text-small text-danger`,children:[`The backup settings couldn't be read: `,n.error.message]}):(0,h.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,h.jsx)(Eb,{label:`Back up automatically`,tip:`settings.backups.auto`,checked:u?.enabled===!0,disabled:u===void 0,className:`self-start`,onChange:e=>f({enabled:e})}),(0,h.jsxs)(`div`,{className:`grid items-start gap-6 md:grid-cols-2`,children:[(0,h.jsx)(Y,{label:`Time of day`,tip:`settings.backups.time`,help:`${m9()} time`,children:(0,h.jsx)(OV,{type:`time`,className:`w-[140px] tabular-nums`,value:u?.time??`03:00`,disabled:u===void 0,onChange:e=>f({time:e.target.value})})}),(0,h.jsx)(Y,{label:`Keep last`,tip:`settings.backups.keep`,help:`Backups kept in the folder.`,error:d,children:(0,h.jsx)(OV,{type:`number`,inputMode:`numeric`,min:f9,max:p9,step:1,className:`w-[88px] tabular-nums`,value:u?.keep??`5`,disabled:u===void 0,onChange:e=>f({keep:e.target.value})})}),(0,h.jsx)(Y,{label:`Folder`,tip:`settings.backups.folder`,className:`md:col-span-2`,...l===void 0?{}:{help:nxe(l)},children:(0,h.jsx)(OV,{value:u?.folder??``,placeholder:l?.defaultFolder??``,disabled:u===void 0,onChange:e=>f({folder:e.target.value})})})]}),(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,h.jsx)(L,{variant:`primary`,disabled:u===void 0||d!==void 0||s.isPending,onClick:()=>{u!==void 0&&(o(!1),s.mutate({enabled:u.enabled,time:u.time,timeZone:m9(),keep:Number(u.keep.trim()),folder:u.folder.trim()===``?null:u.folder.trim()}))},children:`Save`}),(0,h.jsx)(`span`,{className:`inline-flex w-[52px]`,children:a?(0,h.jsx)(m4,{}):null}),s.error===null?null:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 basis-full text-small text-danger`,children:s.error.message})]})]})]})}function g9(e){return new Date(e).toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`})}function exe(e){if(e.running)return`Backing up now…`;let{status:t}=e,n=t.lastSuccessAt===null?`No backup yet.`:`Last backup ${g9(t.lastSuccessAt)}${t.lastSuccessBytes===null?``:`, ${_9(t.lastSuccessBytes)}`}.`;return t.lastResult===`failed`&&t.lastAttemptAt!==null?`${n} The backup at ${g9(t.lastAttemptAt)} failed.`:t.lastResult===`waiting`?`${n} Waiting for projects to finish.`:n}function txe(e){return e.config.enabled?e.overdue?`Next: shortly.`:e.nextRunAt===null?``:`Next: ${g9(e.nextRunAt)}.`:`Automatic backups are off.`}function nxe(e){let t=`${e.files.length} backup${e.files.length===1?``:`s`} here (${_9(e.files.reduce((e,t)=>e+t.bytes,0))}).`;return e.hostFolder===null?`Inside Slopify's Docker volume, not on your computer. Leave Folder empty to save backups in the Backups folder on your computer. ${t}`:`${e.config.folder===null?`Empty uses the default: `:`On your computer: `}${e.hostFolder}. ${t}`}function _9(e){if(e<1024)return`${e} B`;let t=[`KB`,`MB`,`GB`,`TB`],n=e,r=t[0]??`KB`;for(let e of t)if(n/=1024,r=e,n<1024||e===t.at(-1))break;return`${n>=10?n.toFixed(0):n.toFixed(1).replace(/\.0$/,``)} ${r}`}var v9=[`storage-files`];function rxe({usageQueryKey:e}){let{api:t}=R(),n=_(),r=Dy(),[i,a]=(0,m.useState)(!1),[o,s]=(0,m.useState)(``),[c,l]=(0,m.useState)(),u=M({queryKey:v9,queryFn:()=>No(t),refetchInterval:e=>b9(e.state.data)?1e3:!1}),d=N({mutationFn:e=>Po(t,e),onMutate:()=>l(void 0),onSuccess:e=>{n.setQueryData(v9,e),a(!1)},onError:e=>l(e.message)}),f=N({mutationFn:()=>Fo(t),onSuccess:e=>{e.opened||r(`Your files are in ${e.path}.`,`info`)},onError:e=>r(e.message,`error`)}),p=u.data,g=b9(p),v=p?.move?.phase;if((0,m.useEffect)(()=>{v===`done`&&n.invalidateQueries({queryKey:e})},[v,n,e]),p===void 0)return(0,h.jsx)(`div`,{children:(0,h.jsx)(V,{title:`Your files`,meta:u.error?`Where your files are is unavailable. Reload the page to try again.`:`Loading…`})});if(p.docker)return(0,h.jsxs)(`div`,{children:[(0,h.jsx)(V,{title:`Your files`,meta:p.folder??`The Docker project folder isn't set up.`,info:`settings.files.docker`,children:(0,h.jsx)(L,{disabled:p.folder===null||f.isPending,onClick:()=>f.mutate(),children:`Open folder`})}),(0,h.jsxs)(`div`,{className:`flex flex-col gap-2 text-small text-ink-2`,children:[(0,h.jsx)(y9,{view:p}),p.dockerCommand===null?null:(0,h.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,h.jsxs)(`p`,{className:`m-0`,children:[`To move your projects to Documents/Slopify, run this on the computer running Docker (or use `,(0,h.jsx)(jV,{children:`--projects-dir <folder>`}),` for another folder):`]}),(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,h.jsx)(jV,{className:`min-w-0 break-all`,children:p.dockerCommand}),(0,h.jsx)(L,{variant:`quiet`,size:`small`,onClick:()=>{let e=p.dockerCommand??``;navigator.clipboard.writeText(e).then(()=>r(`Command copied.`,`success`)).catch(()=>r(`Copying failed: this browser doesn't allow it here. Select the command and copy it yourself.`,`error`))},children:`Copy command`})]})]})]})]});let y=v===`failed`||v===`interrupted`;return(0,h.jsxs)(`div`,{children:[(0,h.jsxs)(V,{title:`Your files`,meta:p.folder,info:`settings.files`,children:[p.inDocuments||p.documentsRoot===null?null:(0,h.jsx)(L,{variant:`primary`,disabled:g||d.isPending,onClick:()=>d.mutate(`documents`),children:`Move to Documents/Slopify`}),(0,h.jsx)(L,{disabled:f.isPending,onClick:()=>f.mutate(),children:`Open folder`}),(0,h.jsx)(L,{variant:`quiet`,disabled:g||d.isPending,onClick:()=>{a(e=>!e),l(void 0)},children:`Choose another folder`})]}),(0,h.jsxs)(`div`,{className:`flex flex-col gap-3 text-small text-ink-2`,children:[(0,h.jsx)(y9,{view:p}),i?(0,h.jsxs)(`form`,{className:`flex flex-wrap items-end gap-2`,onSubmit:e=>{e.preventDefault(),d.mutate(o)},children:[(0,h.jsx)(Y,{label:`New folder`,tip:`settings.files.new-folder`,help:`The full path; it must be empty or new.`,error:c,className:`min-w-0 flex-1 basis-80`,children:(0,h.jsx)(OV,{value:o,placeholder:p.documentsRoot??`/home/you/Videos/Slopify`,onChange:e=>s(e.target.value)})}),(0,h.jsx)(L,{type:`submit`,disabled:o.trim()===``||d.isPending,children:`Move here`})]}):c===void 0?null:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-danger`,children:c}),p.move===null?null:g?(0,h.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,h.jsxs)(`p`,{role:`status`,className:`m-0 text-ink tabular-nums`,children:[p.move.phase===`copying`?`Copying`:`Checking the copy of`,` your files to`,` `,p.move.target,`: `,p.move.files,` of `,p.move.totalFiles,` files (`,Q5(p.move.bytes),` of `,Q5(p.move.totalBytes),`). Keep Slopify running until it finishes.`]}),(0,h.jsx)(u4,{label:p.move.phase===`copying`?`Files copied`:`Files checked`,value:p.move.totalBytes===0?0:p.move.bytes/p.move.totalBytes})]}):y?(0,h.jsx)(fI,{tone:v===`failed`?`danger`:`waiting`,title:v===`failed`?`Moving your files to ${p.move.target} stopped`:`Moving your files to ${p.move.target} didn't finish`,actions:(0,h.jsx)(L,{disabled:d.isPending,onClick:()=>d.mutate(p.move?.target??``),children:`Continue moving`}),children:p.move.error??`Slopify was stopped before the copy was checked, so it still uses the old folder. Continue moving picks up where it left off.`}):v===`done`&&p.move.oldFolder!==null?(0,h.jsxs)(fI,{tone:`info`,title:`Your files are now in ${p.move.target}`,children:[`Every file was copied and checked. The old folder `,p.move.oldFolder,` still has a copy; once your projects open fine, you can delete it to free the space.`]}):null]})]})}function y9({view:e}){let t=[[`Projects`,e.projects],[`Automatic backups`,e.backups],[`Exports`,e.exports]].filter(e=>e[1]!==null);return(0,h.jsx)(`dl`,{className:`m-0 grid grid-cols-[auto_minmax(0,1fr)] gap-x-3 gap-y-1`,children:t.map(([e,t])=>(0,h.jsxs)(`div`,{className:`contents`,children:[(0,h.jsx)(`dt`,{className:`text-ink-3`,children:e}),(0,h.jsx)(`dd`,{className:`m-0 break-all`,children:t})]},e))})}function b9(e){return e?.move?.phase===`copying`||e?.move?.phase===`verifying`}function ixe(){let{api:e}=R(),t=M(Xy(e));return(0,h.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[t.error===null?null:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-body text-danger`,children:t.error.message}),t.data===void 0?t.error===null?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(dxe,{cells:5}),(0,h.jsx)(fxe,{})]}):null:(0,h.jsx)(oxe,{usage:t.data})]})}var axe=[{id:`stage`,header:`Stage`,cell:e=>YP[e.stage]},{id:`model`,header:`Provider · model`,cell:e=>sxe(e)},{id:`in`,header:`Tokens in`,numeric:!0,cell:e=>x9.format(e.tokensIn)},{id:`out`,header:`Tokens out`,numeric:!0,cell:e=>x9.format(e.tokensOut)}];function oxe({usage:e}){let t=Object.values(e.counters).every(e=>e===0);return(0,h.jsxs)(b0,{split:`even`,children:[(0,h.jsxs)(x0,{children:[(0,h.jsxs)(`div`,{children:[(0,h.jsx)(c4,{children:uxe(e).map(e=>(0,h.jsx)(l4,{label:e.label,value:e.value},e.label))}),t?(0,h.jsx)(`p`,{className:`m-0 mt-3 text-body text-ink-2`,children:`Numbers appear after your first run.`}):null]}),(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-3`,children:`Machine ID ${e.machineId??`not made yet`} · Slopify ${e.appVersion}`})]}),(0,h.jsx)(x0,{children:(0,h.jsx)(`div`,{className:`min-w-0 overflow-x-auto`,children:(0,h.jsx)(d4,{caption:`Tokens by stage`,columns:axe,rows:e.byStage,rowKey:e=>`${e.stage}/${e.provider}/${e.model??``}`,empty:`No stages have run yet.`,className:`min-w-[480px] [&_td]:pr-4 [&_th]:pr-4`})})})]})}function sxe(e){return e.model===null?e.provider:`${e.provider} · ${e.model}`}var x9=new Intl.NumberFormat(void 0,{maximumFractionDigits:0}),cxe=new Intl.NumberFormat(void 0,{maximumFractionDigits:1}),lxe=new Intl.NumberFormat(void 0,{notation:`compact`,maximumFractionDigits:1});function uxe(e){let t=e.counters;return[{label:`Videos made`,value:x9.format(t.videosMade)},{label:`Hours of audio`,value:cxe.format(t.audioSeconds/3600)},{label:`Images made`,value:x9.format(t.imagesMade)},{label:`Tokens used`,value:t.tokensUsed<1e6?x9.format(t.tokensUsed):lxe.format(t.tokensUsed)},{label:`Projects`,value:x9.format(t.projects)}]}function dxe({cells:e}){return(0,h.jsx)(`div`,{className:`sl-stats`,children:Array.from({length:e},(e,t)=>t).map(e=>(0,h.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,h.jsx)(`span`,{className:`h-8 w-20 rounded-control bg-sunken`}),(0,h.jsx)(`span`,{className:`h-3 w-24 rounded-control bg-sunken`})]},e))})}function fxe(){return(0,h.jsx)(`div`,{className:`border-t border-line`,children:[0,1,2,3].map(e=>(0,h.jsxs)(`div`,{className:`flex items-center gap-4 border-b border-line py-3`,children:[(0,h.jsx)(`span`,{className:`h-3 w-24 rounded-control bg-sunken`}),(0,h.jsx)(`span`,{className:`h-3 w-56 max-w-[40%] rounded-control bg-sunken`}),(0,h.jsx)(`span`,{className:`ml-auto h-3 w-20 rounded-control bg-sunken`}),(0,h.jsx)(`span`,{className:`h-3 w-20 rounded-control bg-sunken`})]},e))})}var S9=[`storage-usage`],pxe=[S9,z.projects,[`project`],z.usage,z.documentThemes,OH,[`play-drafts`],z.settings,z.providers,z.voices,z.prompts,z.entries,z.staging,Rq,pN,[`provider-models`]];async function mxe(e){await Promise.all(pxe.map(t=>e.invalidateQueries({queryKey:t})))}var C9=30,hxe=[{value:`system`,label:`System`},{value:`dark`,label:`Dark`},{value:`light`,label:`Light`}];function gxe(e){let t=e.trim();return/^\d+$/.test(t)&&Number(t)>=0&&Number(t)<=C9?void 0:`The silence gap is a whole number of seconds between 0 and ${String(C9)}.`}var w9=[{id:`general`,label:`General`,meta:`How Slopify starts on this computer.`},{id:`providers`,label:`Providers`,meta:`Keys stay on this machine and go only to their provider. Readiness is checked again before each run.`},{id:`voices`,label:`Voices`,meta:`A wrong voice ID shows up when the audio stage uses it.`},{id:`models`,label:`Models`,meta:`New models, prices and retirements, checked once a day.`},{id:`playback`,label:`Playback & appearance`,meta:`How narration is paced and how Slopify looks.`},{id:`notifications`,label:`Notifications`,meta:`When a run finishes, fails, waits for you, or a review needs a decision.`},{id:`channel-links`,label:`Channel links`,meta:`The links a YouTube description's {{Name}} placeholders fill from.`},{id:`studio`,label:`YouTube Studio`,meta:`The playlist upload packs name, and the Studio extension's pairing.`},{id:`storage`,label:`Backup & storage`,meta:`Export everything, import a backup, and see what uses disk space.`},{id:`backups`,label:`Backups`,meta:`A daily copy of everything, in a folder you choose.`},{id:`trash`,label:`Trash`,meta:`Deleted projects, prompts, templates and schedules, kept for 30 days.`},{id:`usage`,label:`Usage`,meta:`This machine only. The same counters, anonymised, feed slopify.stream.`},{id:`patch-notes`,label:`Patch notes`,meta:`What changed in each version of Slopify.`},{id:`about`,label:`About`,meta:`Free and open source, running on your machine with your own keys.`}];function _xe(e){return w9.find(t=>t.id===e)?.id??`providers`}function vxe(e){let t=document.createElement(`a`);t.href=`${e}/api/diagnostics`,t.download=`slopify-diagnostics.json`,document.body.append(t),t.click(),t.remove()}function yxe({section:e=`providers`,note:t,onSection:n=()=>{},onNote:r=()=>{}}){let{api:i}=R(),a=_(),o=Dy(),s=Q7(),c=h9(),l=w9.find(t=>t.id===e)??w9[0];return _x({id:`settings.check-providers`,title:`Check all providers`,group:`Settings`,keywords:[`health`,`keys`,`signed in`],run:()=>{n(`providers`),s.mutate()}}),_x({id:`settings.back-up-now`,title:`Back up now`,group:`Settings`,keywords:[`backup`],run:()=>{n(`backups`),c.mutate(void 0,{onError:e=>{o(`The backup didn't start: ${e.message} Open Settings → Backups to see its state.`,`error`)}})}}),_x({id:`settings.download-diagnostics`,title:`Download diagnostics`,group:`Settings`,keywords:[`support`,`bug report`],run:()=>{vxe(i.origin)}}),(0,h.jsxs)(`div`,{children:[(0,h.jsx)(Aq,{crumb:`Settings`,title:l.label,meta:l.meta,actions:(0,h.jsxs)(h.Fragment,{children:[e===`providers`?(0,h.jsx)(L,{disabled:s.isPending,onClick:()=>s.mutate(),children:s.isPending?`Checking…`:`Check all`}):null,(0,h.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,h.jsxs)(dS,{variant:`secondary`,href:`${i.origin}/api/diagnostics`,download:`slopify-diagnostics.json`,children:[(0,h.jsx)(pc,{"aria-hidden":`true`,strokeWidth:1.75}),`Download diagnostics`]}),(0,h.jsx)(B,{id:`settings.diagnostics`})]})]})}),(0,h.jsx)(jq,{sections:(0,h.jsx)(p8,{label:`Settings sections`,children:w9.map(t=>(0,h.jsx)(m8,{current:t.id===e,onClick:()=>n(t.id),className:`whitespace-nowrap max-md:w-auto`,children:t.label},t.id))}),children:(0,h.jsxs)(`section`,{"aria-label":l.label,className:`flex min-w-0 flex-col gap-10`,children:[e===`providers`?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(t6,{}),(0,h.jsx)(xbe,{}),(0,h.jsx)(dbe,{run:s})]}):null,e===`general`?(0,h.jsx)(Ib,{}):null,e===`voices`?(0,h.jsx)(Ebe,{}):null,e===`models`?(0,h.jsx)(abe,{}):null,e===`playback`?(0,h.jsx)(Cxe,{}):null,e===`notifications`?(0,h.jsx)(Abe,{}):null,e===`channel-links`?(0,h.jsx)(Yde,{}):null,e===`studio`?(0,h.jsx)(Pde,{}):null,e===`storage`?(0,h.jsx)(rxe,{usageQueryKey:S9}):null,e===`storage`?(0,h.jsx)(bxe,{}):null,e===`storage`?(0,h.jsx)(Nbe,{}):null,e===`backups`?(0,h.jsx)($be,{}):null,e===`trash`?(0,h.jsx)(Gbe,{}):null,e===`usage`?(0,h.jsx)(ixe,{}):null,e===`patch-notes`?(0,h.jsx)(Ibe,{note:t,onNote:r}):null,e===`about`?(0,h.jsx)(Xbe,{onWhatsNew:()=>{a.fetchQuery(nI(i)).then(e=>r(e.current??void 0),e=>{o(`The patch notes did not open: ${e instanceof Error?e.message:String(e)} Open Settings → Patch notes to try again.`,`error`)})}}):null]})})]})}var T9=`The backup wasn't imported. Check it is a file made with Export everything (.tar) or Export backup (.zip), then try again.`;function bxe(){let{api:e}=R(),t=_(),n=M({queryKey:S9,queryFn:()=>Mo(e),staleTime:3e4}),[r,i]=(0,m.useState)(!1),[a,o]=(0,m.useState)({phase:`idle`}),[s,c]=(0,m.useState)({phase:`idle`}),[l,u]=(0,m.useState)(null),d=Dy(),[f,p]=(0,m.useState)(null);async function g(){p(null),o({phase:`preparing`});try{let t=await Co(e);if(!t.ready){o({phase:`idle`}),p(t.detail??`The backup can't be made right now. Try again in a moment.`);return}o({phase:`downloading`,bytes:t.bytes??0,projects:t.projects??0});let n=document.createElement(`a`);n.href=`${e.origin}/api/storage/export`,n.download=``,document.body.append(n),n.click(),n.remove()}catch(e){o({phase:`idle`}),p(e instanceof Error?e.message:`The backup couldn't be prepared. Try again in a moment.`)}}async function v(n){let r=n.name.toLowerCase().endsWith(`.zip`)||n.type===`application/zip`;if(n.size===0||r&&n.size>104857600){p(r?`This file is empty or larger than 100 MB. Choose a .zip made with Export backup, or a .tar made with Export everything.`:`This file is empty. Choose the .tar made with Export everything.`);return}i(!0),p(null),u(null),c({phase:`uploading`,sent:0,total:n.size});try{let i=await e.upload(`${e.origin}/api/storage/import`,n,r?`application/zip`:`application/x-tar`,(e,t)=>{c(e>=t?{phase:`importing`}:{phase:`uploading`,sent:e,total:t})}),a=await i.json();if(!i.ok)throw Error(a.detail??T9);a.projects===void 0?d(`Imported ${a.templates??0} template(s), ${a.fonts??0} uploaded font(s), and ${a.stagedFiles??0} staged file(s).${a.fontFallbacks?` ${a.fontFallbacks} missing legacy font reference(s) now use the default font.`:``}`,`success`):(u(a),d(`Backup imported.`,`success`)),await mxe(t)}catch(e){p(e instanceof Error?e.message:T9)}finally{c({phase:`idle`}),i(!1)}}async function y(){i(!0),p(null);try{let n=await e.fetch(`${e.origin}/api/storage/cleanup`,{method:`POST`}),r=await n.json();if(!n.ok)throw Error(`Clean orphan files didn't finish. Try again in a moment.`);d(`Removed ${r.orphanFiles??0} orphan project file(s) and ${r.stagedFiles??0} stale staged file(s).`,`success`),await t.invalidateQueries({queryKey:S9})}catch(e){p(e instanceof Error?e.message:`Clean orphan files didn't finish. Try again in a moment.`)}finally{i(!1)}}_x({id:`settings.export-everything`,title:`Export everything`,group:`Settings`,context:`Backup & storage`,keywords:[`backup`,`download`],run:()=>{!r&&a.phase!==`preparing`&&g()}});let b=r||a.phase===`preparing`,x=(0,m.useRef)(null);return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`div`,{children:[(0,h.jsxs)(V,{title:`Export and import`,info:`settings.storage.export`,children:[(0,h.jsx)(L,{disabled:b,onClick:()=>void g(),children:`Export everything`}),(0,h.jsx)(L,{disabled:b,onClick:()=>x.current?.click(),children:`Import a backup`}),(0,h.jsx)(`input`,{ref:x,className:`sr-only`,type:`file`,tabIndex:-1,"aria-label":`Import a backup`,accept:`.tar,application/x-tar,.zip,application/zip`,disabled:b,onChange:e=>{let t=e.target.files?.[0];t&&v(t),e.target.value=``}}),(0,h.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,h.jsx)(L,{variant:`quiet`,disabled:b,onClick:()=>void y(),children:`Clean orphan files`}),(0,h.jsx)(B,{id:`settings.storage.clean`})]})]}),(0,h.jsxs)(`div`,{className:`flex flex-col gap-2 text-small text-ink-2`,children:[(0,h.jsx)(`p`,{className:`m-0`,children:`Provider keys are never included in a backup. After importing, enter them again in Settings → Providers.`}),a.phase===`preparing`?(0,h.jsx)(`p`,{role:`status`,className:`m-0 text-ink`,children:`Preparing the backup…`}):null,a.phase===`downloading`?(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,h.jsxs)(`p`,{role:`status`,className:`m-0 min-w-0 flex-1 text-ink`,children:[`Downloading `,Q5(a.bytes),` (`,a.projects,` project`,a.projects===1?``:`s`,`). Your browser's downloads show its progress; keep Slopify running until it finishes.`]}),(0,h.jsx)(L,{variant:`quiet`,size:`small`,onClick:()=>o({phase:`idle`}),children:`Dismiss`})]}):null,s.phase===`uploading`?(0,h.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,h.jsxs)(`p`,{role:`status`,className:`m-0 text-ink tabular-nums`,children:[`Uploading the backup: `,Q5(s.sent),` of`,` `,Q5(s.total)]}),(0,h.jsx)(u4,{label:`Backup upload`,value:s.total===0?0:s.sent/s.total})]}):null,s.phase===`importing`?(0,h.jsx)(`p`,{role:`status`,className:`m-0 text-ink`,children:`Checking and importing the backup… large projects can take a minute.`}):null,f?(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-danger`,children:f}):null]})]}),l?(0,h.jsx)(Sxe,{result:l,onDismiss:()=>u(null)}):null,(0,h.jsxs)(`div`,{children:[(0,h.jsx)(V,{title:`Disk space`,info:`settings.storage.disk`,meta:n.data?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`span`,{className:`font-semibold text-ink`,children:[Q5(n.data.data),` stored`]}),(0,h.jsxs)(`span`,{className:`tabular-nums`,children:[` `,`· `,Q5(Math.max(0,n.data.projects-n.data.trash.bytes)),` project files · `,Q5(n.data.staging),` staged files`,n.data.trash.projects>0?` · ${Q5(n.data.trash.bytes)} in the trash (${xxe(n.data.trash.projects)}), freed when removed for good`:null]})]}):n.error?`Storage usage is unavailable. Reload the page to try again.`:(0,h.jsx)(`span`,{className:`inline-block h-4 w-48 rounded-control bg-raised`})}),n.data&&n.data.byProject.length>0?(0,h.jsx)(H_e,{projects:n.data.byProject,queryKey:[...S9]}):null]})]})}function xxe(e){return e===1?`1 deleted project`:`${String(e)} deleted projects`}function E9(e,t){if(t===void 0)return null;let n=[t.added>0?`${t.added} added`:null,t.renamed>0?`${t.renamed} added as “(imported)” because the name was taken`:null,t.skipped>0?`${t.skipped} already here`:null].filter(e=>e!==null);return n.length===0?null:`${e}: ${n.join(`, `)}.`}function Sxe({result:e,onDismiss:t}){let n=[e.projects.imported.length>0?`Projects: ${e.projects.imported.length} added (${Q5(e.files.bytes)} of files).`:`Projects: none added.`,E9(`Prompts`,e.prompts),E9(`Intros and outros`,e.entries),E9(`Channels`,e.channels),E9(`Cast members`,e.cast),E9(`Episode memories`,e.episodeMemories),E9(`Existing videos`,e.channelVideos),E9(`Document themes`,e.documentThemes),E9(`Templates`,e.templates),E9(`Schedules`,e.schedules),e.schedules.paused>0?`${e.schedules.paused} schedule(s) arrived paused so two installs never run them both; resume them on the Schedules screen.`:null,E9(`Voices`,e.voices),E9(`Play drafts`,e.drafts),e.settings.added+e.settings.kept>0?`Settings: ${e.settings.added} filled in${e.settings.kept>0?`, ${e.settings.kept} kept as this install has them`:``}.`:null,e.fonts>0?`Uploaded fonts: ${e.fonts} added.`:null,e.usage.alreadyImported?`Usage: this backup's history was already added before, so it wasn't counted twice.`:`Usage: ${e.usage.events} recorded event(s) added to the totals.`,`Provider keys are not in backups: enter them in Settings → Providers.`].filter(e=>e!==null);return(0,h.jsxs)(`div`,{children:[(0,h.jsx)(V,{as:`h3`,title:`Imported the backup from ${e.backup.createdAt.slice(0,10)}`,children:(0,h.jsx)(L,{variant:`quiet`,size:`small`,onClick:t,children:`Dismiss`})}),(0,h.jsxs)(`ul`,{"aria-label":`Import result`,className:`m-0 list-disc pl-5 text-small text-ink-2`,children:[n.map(e=>(0,h.jsx)(`li`,{className:`py-0.5`,children:e},e)),e.projects.skipped.map(e=>(0,h.jsxs)(`li`,{className:`py-0.5`,children:[`Skipped “`,e.title,`”: `,e.reason]},e.id))]})]})}function Cxe(){let{api:e}=R(),t=_(),n=M(rb(e)),[r,i]=(0,m.useState)(void 0),[a,o]=(0,m.useState)(!1),s=N({mutationFn:t=>Yo(e,t),onMutate:e=>{let n=t.getQueryData(z.settings);return t.setQueryData(z.settings,e),{previous:n}},onError:(e,n,r)=>{r?.previous!==void 0&&t.setQueryData(z.settings,r.previous)},onSuccess:e=>{t.setQueryData(z.settings,e)}});if((0,m.useEffect)(()=>{if(!a)return;let e=setTimeout(()=>{o(!1)},f4);return()=>{clearTimeout(e)}},[a]),n.error!==null)return(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-body text-danger`,children:n.error.message});if(n.data===void 0)return(0,h.jsxs)(`div`,{className:`grid gap-6 md:grid-cols-2`,role:`status`,"aria-label":`Loading settings`,children:[(0,h.jsx)(`span`,{className:`h-16 rounded-control bg-raised`}),(0,h.jsx)(`span`,{className:`h-16 rounded-control bg-raised`})]});let c=n.data,l=r??String(c.silenceGapSeconds),u=gxe(l);return(0,h.jsxs)(`div`,{className:`grid items-start gap-6 md:grid-cols-2`,children:[(0,h.jsx)(Y,{label:`Silence between segments`,tip:`settings.playback.silence-gap`,help:`Seconds of quiet between narrated segments.`,error:u??s.error?.message,children:(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,h.jsx)(OV,{type:`number`,inputMode:`numeric`,min:0,max:C9,step:1,className:`w-[88px] tabular-nums`,value:l,"aria-invalid":u!==void 0,onChange:e=>{i(e.target.value)}}),(0,h.jsx)(`span`,{className:`text-small text-ink-2`,children:`seconds`}),(0,h.jsx)(L,{variant:`primary`,disabled:u!==void 0||s.isPending,onClick:()=>{o(!1),s.mutate({...c,silenceGapSeconds:Number(l.trim())},{onSuccess:()=>{i(void 0),o(!0)}})},children:`Save`}),(0,h.jsx)(`span`,{className:`inline-flex w-[52px]`,children:a?(0,h.jsx)(m4,{}):null})]})}),(0,h.jsxs)(`div`,{className:`sl-field`,...Tb,children:[(0,h.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1`,children:[(0,h.jsx)(`span`,{className:`sl-field__label`,children:`Appearance`}),(0,h.jsx)(B,{id:`settings.appearance`,className:`-my-1`})]}),(0,h.jsx)(Db,{label:`Appearance`,value:c.appearance,options:hxe,className:`self-start`,onChange:e=>{s.mutate({...c,appearance:e})}})]}),(0,h.jsx)(`div`,{className:`md:col-span-2`,children:(0,h.jsx)(W6,{value:c.loudness??uk,switchLabel:`Level the volume for new runs`,switchTip:`settings.loudness`,onChange:e=>{s.mutate({...c,loudness:e})}})})]})}function wxe({open:e,onClose:t,onInstalled:n}){let{api:r}=R(),i=_(),a=M({queryKey:jy,queryFn:()=>Fy(r),enabled:e}),o=N({mutationFn:e=>Ly(r,e),onSuccess:()=>n(),onSettled:()=>i.invalidateQueries({queryKey:jy})});return(0,h.jsxs)(HP,{open:e,title:`Add a starter pack`,onClose:t,footer:(0,h.jsx)(v0,{tone:o.error||a.error?`error`:`success`,children:o.error?.message??a.error?.message??(o.data===void 0?void 0:o.data.added?`Added: its prompts are in Prompts and its template is in this list.`:`That pack was already added.`)}),children:[(0,h.jsxs)(`p`,{className:`mb-4 flex items-center gap-1 text-small text-ink-2`,children:[`Prompts, a suggested voice and a template for one kind of channel.`,(0,h.jsx)(B,{id:`welcome.packs`})]}),(0,h.jsxs)(hU,{label:`Starter packs`,className:`[&_.sl-row__meta]:whitespace-normal`,children:[(a.data?.packs??[]).map(e=>(0,h.jsx)(gU,{title:e.name,meta:e.summary,actions:(0,h.jsx)(L,{disabled:e.installed||o.isPending,onClick:()=>o.mutate(e.id),children:e.installed?`Added`:`Add pack`})},e.id)),a.data===void 0?(0,h.jsx)(gU,{title:`Loading packs…`}):null]})]})}function Txe({template:e}){let{api:t}=R(),n=M({queryKey:[...Rq,e.id,e.version],queryFn:async()=>{let n=await Wq(t,e.id);if(!n.ok)throw Error(n.message);return n.value}});if(n.error)return(0,h.jsxs)(`p`,{role:`alert`,className:`m-0 text-small text-danger`,children:[`The keywords of `,e.name,` didn't load. `,n.error.message,` Press Keywords again.`]});if(!n.data)return(0,h.jsx)(`p`,{role:`status`,className:`m-0 text-small text-ink-2`,children:`Reading the keywords…`});let{form:r,librarySnapshot:i}=n.data.document,a=F0({form:r,prompts:i?.prompts??[],entries:i?.entries??[]}),o=e6(r.title),s=[...new Set([...a.keys(),...Object.keys(r.values)])];return(0,h.jsx)(L0,{keywords:s.map(e=>({name:e,value:r.values[e]??``,feeds:a.get(e)??[],topic:o.includes(e)})),empty:`No keywords: the prompts and the title name none.`})}async function Exe(e,t,n,r){let i=await Kq(e,t.id,{baseVersion:t.version,mutationId:r,...n});if(!i.ok)throw Error(i.message);return i.value}function Dxe({template:e}){return e===void 0?(0,h.jsx)(`p`,{className:`m-0 py-3 text-small text-ink-2`,children:`Pick a template to see the keywords it fills.`}):(0,h.jsxs)(`section`,{"aria-label":`Keywords of ${e.name}`,className:`flex flex-col gap-4`,children:[(0,h.jsx)(V,{title:e.name,as:`h3`,info:`templates.edit`,className:`pb-0`}),(0,h.jsx)(Txe,{template:e}),(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:`To change the settings, press Use in Play, change the draft, then Save a setup.`})]})}function Oxe({template:e,onClose:t}){let{api:n}=R(),r=_(),i=Array.from({length:e.version},(t,n)=>e.version-n),a=st({queries:i.map(t=>({queryKey:[...Rq,e.id,`version`,t],queryFn:async()=>{let r=await Wq(n,e.id,t);if(!r.ok)throw Error(r.message);return r.value},staleTime:1/0}))}),o=a[0]?.data,[s,c]=(0,m.useState)(i[1]??e.version),l=a[i.indexOf(s)]?.data,u=(0,m.useRef)(crypto.randomUUID()),d=Dy(),f=N({mutationFn:t=>Exe(n,e,{name:t.name,document:t.document},u.current),onSuccess:async(n,i)=>{u.current=crypto.randomUUID(),d(`Restored version ${String(i.version)} of ${e.name} as version ${String(n.version)}.`,`success`),await r.invalidateQueries({queryKey:Rq}),t()}}),p=a.find(e=>e.error!==null)?.error;return(0,h.jsx)(HP,{open:!0,title:`History of ${e.name}`,onClose:t,className:`sm:w-[min(1080px,100vw)]`,children:(0,h.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[p?(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-body text-danger`,children:`A version couldn't be read: ${p.message} Close History and open it again.`}):null,(0,h.jsxs)(`section`,{className:`flex flex-col gap-2`,children:[(0,h.jsx)(V,{title:`Versions`,as:`h3`,info:`templates.history`}),(0,h.jsx)(hU,{label:`Versions of ${e.name}`,children:i.map((t,n)=>{let r=a[n]?.data;return(0,h.jsx)(gU,{title:`Version ${String(t)}`,selected:t===s,onSelect:()=>c(t),meta:r===void 0?`Loading…`:`${r.name} · ${J4(r.updatedAt)}`,actions:t===e.version?(0,h.jsx)(`span`,{className:`text-small text-ink-2`,children:`Current`}):(0,h.jsx)(L,{size:`small`,"aria-label":`Restore version ${String(t)}`,disabled:r===void 0||f.isPending,disabledReason:r===void 0?`Reading the version`:`Restoring`,onClick:()=>{r!==void 0&&f.mutate(r)},children:`Restore`})},t)})}),(0,h.jsx)(v0,{tone:`error`,children:f.error===null?void 0:`The version wasn't restored: ${f.error.message}`})]}),(0,h.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,h.jsx)(V,{title:`Compare with the current version`,as:`h3`}),o===void 0||l===void 0?(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:`Loading the versions…`}):l.version===o.version?(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:e.version===1?`This is the only version so far.`:`Pick an older version in the list to compare it.`}):(0,h.jsxs)(h.Fragment,{children:[l.name===o.name?null:(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:`Renamed from "${l.name}" to "${o.name}".`}),(0,h.jsx)(V4,{before:D9(l),after:D9(o),beforeLabel:`Version ${String(l.version)}`,afterLabel:`Version ${String(o.version)} (current)`})]})]})]})})}function D9(e){return JSON.stringify(e.document,null,1).split(`
305
+ `),s].find(e=>e?.trim())??`No text was recorded for this part.`}catch{return`Recorded text cannot be decoded.`}}function tye({projectId:e,pending:t,onRestore:n}){let{api:r}=R(),[i,a]=(0,m.useState)(),o=M({queryKey:z.revisions(e),queryFn:async()=>{let t=await Tde(r,e);if(!t.ok)throw Error(t.message);return t.value.revisions}}),s=M({queryKey:z.revision(e,i??``),enabled:i!==void 0,queryFn:async()=>{if(i===void 0)throw Error(`Choose a version from History first.`);let t=await w2(r,e,i);if(!t.ok)throw Error(t.message);return t.value.view}}),c=s.data,l=c?.outputs.find(e=>e.selected&&e.available&&(e.output.role===`image`||e.output.role===`thumbnail`)),u=l??c?.outputs.find(e=>e.available);return(0,h.jsxs)(`section`,{"aria-label":`Project history`,className:`space-y-3`,children:[(0,h.jsx)(V,{title:`Project history`}),o.error===null?null:(0,h.jsx)(`p`,{role:`alert`,children:o.error.message}),(0,h.jsx)(`ol`,{className:`space-y-2`,children:o.data?.map(e=>(0,h.jsx)(`li`,{children:(0,h.jsxs)(L,{type:`button`,onClick:()=>a(e.id),children:[e.title,` · `,e.createdAt,e.current?` · Current`:``]})},e.id))}),s.error===null?null:(0,h.jsx)(`p`,{role:`alert`,children:s.error.message}),c===void 0?null:(0,h.jsxs)(`div`,{className:`space-y-3`,children:[(0,h.jsx)(`h3`,{className:`m-0 text-title-3`,children:c.revision.config.title}),(0,h.jsxs)(Ty,{children:[(0,h.jsx)(L,{variant:`primary`,disabled:t,onClick:()=>n(c.revision.id),children:`Restore this revision`}),l===void 0?null:(0,h.jsxs)(dS,{href:Ade(r,e,c.revision.id),download:!0,children:[(0,h.jsx)(pc,{"aria-hidden":`true`,strokeWidth:1.75}),`Download all images`]}),u===void 0?null:(0,h.jsx)(k2,{projectId:e,asset:``,folder:{revisionId:c.revision.id,recordId:u.recordId}})]}),(0,h.jsx)(`ul`,{className:`m-0 list-none space-y-3 p-0`,children:c.outputs.map(t=>(0,h.jsxs)(`li`,{className:`space-y-2 border-t border-line pt-3 first:border-t-0 first:pt-0`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-4 gap-y-2`,children:[(0,h.jsxs)(`span`,{className:`min-w-0`,children:[(0,h.jsx)(`span`,{className:`font-semibold text-ink`,children:m7(t.output)}),(0,h.jsxs)(`span`,{className:`text-small text-ink-2`,children:[` · ${t.state}${t.selected?``:` · Earlier result`}`,t.available?``:` · File missing`]})]}),t.available?(0,h.jsxs)(dS,{href:E2(r,e,c.revision.id,t.recordId),download:!0,size:`small`,"aria-label":`Download ${m7(t.output)}`,children:[(0,h.jsx)(pc,{"aria-hidden":`true`,strokeWidth:1.75}),`Download`]}):null]}),t.available?(0,h.jsxs)(`details`,{children:[(0,h.jsx)(`summary`,{children:`Preview retained output`}),t.output.role===`video`?(0,h.jsx)(i2,{className:`max-w-[640px]`,label:m7(t.output),src:E2(r,e,c.revision.id,t.recordId)}):[`audio_export`,`audio_body`,`audio_intro`,`audio_outro`].includes(t.output.role)?(0,h.jsx)(Q8,{label:m7(t.output),src:E2(r,e,c.revision.id,t.recordId)}):t.output.role===`image`||t.output.role===`thumbnail`?(0,h.jsx)(a2,{className:`max-w-[480px]`,alt:m7(t.output),title:m7(t.output),meta:t.selected?`Current`:`Earlier result`,src:E2(r,e,c.revision.id,t.recordId)}):(0,h.jsx)(`p`,{children:`Use Download to inspect this retained file.`})]}):null]},t.recordId))}),(0,h.jsx)(`ul`,{"aria-label":`Retained narration parts`,children:c.pieces.filter(e=>e.stageKind===`audio`&&e.assetId!==null).map(t=>(0,h.jsxs)(`li`,{children:[`Narration part `,t.piece.idx,t.selected?``:` · Earlier result`,t.available?(0,h.jsxs)(`details`,{children:[(0,h.jsx)(`summary`,{children:`Preview retained audio part`}),(0,h.jsx)(Q8,{label:`Narration part ${String(t.piece.idx)}`,src:E2(r,e,c.revision.id,t.recordId)}),(0,h.jsxs)(dS,{href:E2(r,e,c.revision.id,t.recordId),download:!0,size:`small`,children:[(0,h.jsx)(pc,{"aria-hidden":`true`,strokeWidth:1.75}),`Download narration part`]})]}):(0,h.jsx)(`span`,{children:` · File missing`})]},t.recordId))}),(0,h.jsx)(`ul`,{"aria-label":`Retained text parts`,children:c.pieces.filter(e=>e.assetId===null).map(e=>(0,h.jsx)(`li`,{children:(0,h.jsxs)(`details`,{children:[(0,h.jsxs)(`summary`,{children:[e.stageKind,` part `,e.piece.idx]}),(0,h.jsx)(`pre`,{className:`whitespace-pre-wrap break-words`,children:eye(e.piece.payload)})]})},e.recordId))})]})]})}function S7(e,t,n){let r=JSON.stringify(t);return e?.payload===r?e:{payload:r,idempotencyKey:n()}}function nye(e,t,n={}){let{api:r}=R(),i=_(),a=M({queryKey:z.revision(e,t??``),enabled:t!==null,queryFn:async()=>{if(t===null)throw Error(`This project has no saved settings to show yet. Reload the page and try again.`);let n=await w2(r,e,t);if(!n.ok)throw Error(n.message);return n.value.view}}),[o,s]=(0,m.useState)(),[c,l]=(0,m.useState)(),[u,d]=(0,m.useState)(),[f,p]=(0,m.useState)(),[h,g]=(0,m.useState)(!1),[v,y]=(0,m.useState)(!1),[b,x]=(0,m.useState)(),[S,C]=(0,m.useState)(),w=(0,m.useRef)(void 0),T=(0,m.useRef)(void 0),E=(0,m.useRef)(void 0),D=(0,m.useRef)(n.onOpenEdit);D.current=n.onOpenEdit;let O=(0,m.useMemo)(()=>c!==void 0&&(o===void 0||(c.regenerate?.length??0)>0||(c.uploads?.length??0)>0||JSON.stringify(c.config)!==JSON.stringify(o.revision.config)||JSON.stringify(c.content)!==JSON.stringify(o.revision.content)),[c,o]),k=c!==void 0&&o!==void 0&&t!==null&&t!==o.revision.id,ee=(0,m.useRef)(!1);async function te(e){if(!ee.current){ee.current=!0,g(!0),x(void 0),C(void 0);try{await e()}catch(e){x(e instanceof Error?e.message:String(e))}finally{ee.current=!1,g(!1)}}}async function ne(t){let n=await C2(r,e);if(!n.ok){C(n);return}return C(void 0),s(n.value.view),t&&l({config:structuredClone(n.value.view.revision.config),content:structuredClone(n.value.view.revision.content)}),n.value.view}async function re(t){let n=await Oo(r,e);if(i.setQueryData(z.project(e),n),await i.invalidateQueries({queryKey:z.revisions(e)}),!t.current||n.revisionId!==t.revision.id){C({ok:!1,reason:`conflict`,message:`The project changed again. Your draft is preserved.`,currentRevisionId:n.revisionId,fields:[]});return}s(t),l(void 0),C(void 0),d(void 0)}async function A(){if(v||o===void 0||c===void 0)return;let t={baseRevisionId:o.revision.id,edit:c},n=S7(w.current,t,()=>crypto.randomUUID());w.current=n;let i=await Cde(r,e,{...t,idempotencyKey:n.idempotencyKey});if(!i.ok){C(i);return}await re(i.value.view),w.current=void 0}async function ie(t,n=u){if(n===void 0)return;let a={baseRevisionId:n.baseRevisionId,previewId:n.id,...t},o=S7(E.current,a,()=>crypto.randomUUID());E.current=o;let s=await Ode(r,e,{...a,idempotencyKey:o.idempotencyKey});if(!s.ok){C(s),(s.reason===`stale-preview`||s.reason===`conflict`)&&d(void 0);return}E.current=void 0,d(void 0),await i.invalidateQueries({queryKey:z.project(e)})}async function j(t,n){let i=await ne(!1);if(i===void 0)return;let a=await Dde(r,e,{baseRevisionId:i.revision.id,request:t});if(!a.ok){C(a);return}let o=a.value.value;if(E.current=void 0,n&&rye(o)){await ie({acknowledgeUnknownCosts:!1,confirmedProvidedWorkKeys:[]},o);return}d(o)}async function ae(t){let n=o??a.data??await ne(!1);if(n===void 0)return;let i={baseRevisionId:n.revision.id,targetRevisionId:t},s=S7(T.current,i,()=>crypto.randomUUID());T.current=s;let c=await wde(r,e,{...i,idempotencyKey:s.idempotencyKey});if(!c.ok){C(c);return}await re(c.value.view),T.current=void 0}return{saved:a,view:o,edit:c,preview:u,focus:f,pending:h,uploading:v,error:b,refusal:S,unsaved:O,remoteChanged:k,busy:h||v||c!==void 0||u!==void 0,setEdit:l,setUploading:y,openEditor:()=>void te(async()=>{await ne(!0)}),discard:()=>{l(void 0),C(void 0),y(!1),w.current=void 0},save:()=>void te(A),reloadDraft:()=>void te(async()=>{w.current=void 0,y(!1),await ne(!0),C(void 0)}),reloadCurrent:()=>void te(async()=>{T.current=void 0,E.current=void 0,d(void 0),await ne(!1),await i.invalidateQueries({queryKey:z.project(e)})}),requestEdit:e=>void te(async()=>{let t=o,n=c;if(t===void 0||n===void 0){if(t=await ne(!1),t===void 0)return;n={config:structuredClone(t.revision.config),content:structuredClone(t.revision.content)}}l(e.change(n,t)),p({section:e.section}),D.current?.()}),review:(e,t)=>void te(()=>j(e,t?.autoStart===!0)),start:e=>void te(()=>ie(e)),closePreview:()=>{h||(d(void 0),E.current=void 0)},restore:e=>void te(()=>ae(e))}}function rye(e){return!e.work.some(e=>e.disposition===`blocked`)&&e.providedReuseRequired.length===0&&e.costs.unknown===0}function iye({controller:e,renderEditor:t,active:n=!0,intro:r}){let i=e;return i.view===void 0||i.edit===void 0?(0,h.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[r??(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(V,{title:`Saved revision`,info:`project.saved-revision`}),i.saved.error===null?null:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-small text-danger`,children:i.saved.error.message}),i.saved.data===void 0?null:(0,h.jsx)(`ul`,{"aria-label":`Saved output status`,className:`sl-list m-0 list-none p-0`,children:i.saved.data.outputs.filter(e=>e.selected).map(e=>(0,h.jsxs)(`li`,{className:`sl-row`,children:[(0,h.jsx)(`span`,{className:`sl-row__title`,children:m7(e.output)}),(0,h.jsx)(`span`,{className:`sl-row__meta`,children:e.available?e.state===`ready`?`Ready`:e.state===`outdated`?`Outdated; the retained version stays until it is remade`:`Provided content needs review`:`Retained file missing`})]},e.recordId))})]}),i.preview===void 0&&n?(0,h.jsx)(x7,{error:i.error,refusal:i.refusal}):null,(0,h.jsxs)(y0,{children:[i.refusal?.reason===`conflict`&&n?(0,h.jsx)(L,{disabled:i.pending,onClick:i.reloadCurrent,children:`Reload current revision`}):null,(0,h.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,h.jsx)(L,{disabled:i.busy,onClick:()=>i.review({kind:`allAffected`}),variant:`secondary`,children:`Choose what to remake`}),(0,h.jsx)(B,{id:`project.choose-remake`})]}),(0,h.jsx)(L,{variant:`primary`,disabled:i.busy,onClick:i.openEditor,children:`Edit project`})]})]}):(0,h.jsxs)(`form`,{"aria-label":`Edit project`,onSubmit:e=>{e.preventDefault(),i.save()},children:[(0,h.jsx)(`fieldset`,{disabled:i.pending,className:`m-0 min-w-0 border-0 p-0`,children:t({view:i.view,edit:i.edit,fields:i.refusal?.fields??[],onChange:i.setEdit,onPending:i.setUploading,...i.focus===void 0?{}:{focus:i.focus}})}),i.preview===void 0?(0,h.jsx)(x7,{error:i.error,refusal:i.refusal}):null,(0,h.jsxs)(y0,{status:(0,h.jsx)(v0,{tone:i.remoteChanged?`warning`:`info`,children:i.remoteChanged?`A newer revision is available. Your unsaved changes are kept below.`:i.uploading?`Waiting for uploads to finish…`:void 0}),children:[i.remoteChanged||i.refusal?.reason===`conflict`?(0,h.jsx)(L,{disabled:i.pending||i.uploading,onClick:i.reloadDraft,children:`Reload current revision and discard my draft`}):null,(0,h.jsx)(L,{variant:`quiet`,disabled:i.pending||i.uploading,onClick:i.discard,children:`Discard changes`}),(0,h.jsx)(L,{variant:`primary`,type:`submit`,disabled:i.pending||i.uploading,children:`Save changes`})]})]})}function aye({controller:e,projectId:t,active:n}){let r=e;return n?(0,h.jsxs)(h.Fragment,{children:[r.preview===void 0&&(r.error||r.refusal)?(0,h.jsxs)(`div`,{className:`mb-4 flex flex-col gap-3`,children:[(0,h.jsx)(x7,{error:r.error,refusal:r.refusal}),r.edit===void 0&&r.refusal?.reason===`conflict`?(0,h.jsx)(L,{disabled:r.pending,onClick:r.reloadCurrent,className:`self-start`,children:`Reload current revision`}):null]}):null,(0,h.jsx)(tye,{projectId:t,pending:r.busy,onRestore:r.restore})]}):null}function oye({controller:e}){let t=e;return(0,h.jsx)(HP,{open:t.preview!==void 0,title:`Choose what to remake`,onClose:t.closePreview,children:t.preview===void 0?null:(0,h.jsx)(Gve,{preview:t.preview,feedback:(0,h.jsx)(x7,{error:t.error,refusal:t.refusal}),pending:t.pending,onStart:t.start,onCancel:t.closePreview},t.preview.id)})}function sye({projectId:e}){let{api:t}=R(),n=M(Jy(t,e));return n.error===null?n.data===void 0?(0,h.jsxs)(`div`,{role:`status`,"aria-label":`Loading run cost`,className:`flex flex-col gap-8`,children:[(0,h.jsx)(`span`,{className:`h-16 max-w-3xl rounded-control bg-sunken`}),(0,h.jsx)(`span`,{className:`h-40 rounded-control bg-sunken`})]}):(0,h.jsx)(fye,{cost:n.data}):(0,h.jsx)(fI,{tone:`danger`,title:`The run cost could not be loaded.`,children:`${n.error.message} Reload the page to try again.`})}function cye({cost:e,status:t,onOpen:n}){if(e===void 0||!lye.has(t)||e.calls===0&&e.byStage.length===0)return null;let r=[`${t===`done`||t===`partial`?`This run cost`:`Spent so far`} ${j7(e.cost)}${e.unpriced>0?` plus unpriced calls`:``}`,...e.apiEquivalent===null?[]:[`~${j7(e.apiEquivalent)} via API`],`${M7(e.totals.wallMs)} end to end`];return(0,h.jsxs)(`section`,{"aria-label":`Run cost`,className:`flex flex-wrap items-center gap-x-3 gap-y-1 border-b border-line pb-3 text-small text-ink-2`,children:[(0,h.jsx)(`span`,{children:r.join(` · `)}),(0,h.jsxs)(L,{variant:`quiet`,size:`small`,onClick:n,children:[(0,h.jsx)(Ac,{"aria-hidden":`true`,strokeWidth:1.75}),`See cost by stage`]})]})}var lye=new Set([`done`,`partial`,`failed`,`canceled`]),uye=[{id:`stage`,header:`Stage`,cell:e=>(0,h.jsx)(`strong`,{children:YP[e.stage]})},{id:`cost`,header:`Cost`,numeric:!0,cell:w7},{id:`api`,header:`Via API`,numeric:!0,cell:T7},{id:`usage`,header:`Usage`,numeric:!0,cell:e=>E7(e)||`—`},{id:`time`,header:`Time`,numeric:!0,cell:e=>e.wallMs===null?`—`:M7(e.wallMs)}],dye=[{id:`model`,header:`Provider · model`,cell:e=>(0,h.jsx)(`strong`,{children:hye(e)})},{id:`cost`,header:`Cost`,numeric:!0,cell:w7},{id:`api`,header:`Via API`,numeric:!0,cell:T7},{id:`usage`,header:`Usage`,numeric:!0,cell:e=>E7(e)||`—`},{id:`calls`,header:`Calls`,numeric:!0,cell:e=>D7.format(e.calls)}];function C7(e){return e===`five_hour`?`5-hour`:e===`weekly`?`weekly`:`current`}function fye({cost:e}){if(e.calls===0&&e.byStage.length===0)return(0,h.jsx)(`p`,{className:`m-0 text-body text-ink-2`,children:`Nothing has been spent yet. The cost of each provider call appears here as the run makes it.`});let t=e.byModel.some(e=>e.onPlan),n=e.plans.flatMap(e=>e.reported?e.windows.map(t=>({plan:e,window:t})):[]);return(0,h.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[(0,h.jsxs)(`section`,{"aria-label":`Run cost summary`,className:`flex flex-col gap-3`,children:[(0,h.jsxs)(c4,{children:[(0,h.jsx)(l4,{value:j7(e.cost),label:e.unpriced>0?`known cost, paid to providers`:`paid to providers`}),e.apiEquivalent===null?null:(0,h.jsx)(l4,{value:`~${j7(e.apiEquivalent)}`,label:`same work via API`}),n.map(({plan:e,window:t})=>{let n=`${C7(t.kind)} ${e.name} limit`,r=t.usedPercent<1?`<1%`:`${O7.format(t.usedPercent)}%`;return(0,h.jsx)(l4,{value:r,label:`of ${n}`,children:(0,h.jsx)(u4,{value:t.usedPercent/100,label:`Share of the ${n} this run used`,valueText:`${r} of your ${n}; now at ${O7.format(t.nowPercent)}%`,tone:t.nowPercent>=80?`waiting`:`accent`})},`${e.account}/${t.kind}`)}),(0,h.jsx)(l4,{value:M7(e.totals.wallMs),label:`end to end`})]}),(0,h.jsxs)(`div`,{className:`flex flex-col gap-1 text-small text-ink-2`,children:[e.unpriced>0?(0,h.jsx)(`p`,{className:`m-0`,children:`Plus ${A7(e.unpriced,`call`)} the model catalogue has no price for.`}):null,t?(0,h.jsx)(`p`,{className:`m-0`,children:pye(e)}):null,e.plans.map(e=>(0,h.jsx)(`p`,{className:`m-0`,children:mye(e)},e.account))]})]}),(0,h.jsxs)(`section`,{"aria-label":`By stage`,children:[(0,h.jsx)(V,{title:`By stage`,info:`project.cost.by-stage`,className:`mb-3`}),(0,h.jsx)(`div`,{className:`overflow-x-auto`,children:(0,h.jsx)(d4,{caption:`Run cost by stage`,columns:uye,rows:e.byStage,rowKey:e=>e.stage})})]}),(0,h.jsxs)(`section`,{"aria-label":`By model`,children:[(0,h.jsx)(V,{title:`By model`,info:`project.cost.by-model`,className:`mb-3`}),(0,h.jsx)(`div`,{className:`overflow-x-auto`,children:(0,h.jsx)(d4,{caption:`Run cost by model`,columns:dye,rows:e.byModel,rowKey:e=>`${e.provider}/${e.model}/${e.kind}`})})]}),(0,h.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:`In total: ${E7(e.totals)||`no reported usage`} · ${M7(e.totals.wallMs)} of stage time.`}),(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-3`,children:`Priced from the model catalogue${e.catalogueDate===null?``:` of ${e.catalogueDate}`} when each call finished. Retries that failed are not charged here; taxes and included credits are not counted.`})]})]})}function pye(e){let t=e.apiEquivalent??0;if(t===0&&e.apiUnpriced>0)return`CLI calls: $0 on your plan · no API price is listed for their models.`;let n=e.apiUnpriced>0?` (plus ${A7(e.apiUnpriced,`call`)} with no API price)`:``;return`CLI calls: $0 on your plan · ~${j7(t)} via API${n}.`}function mye(e){return e.reported?e.windows.length===0?`${e.name} reported no limit windows for this run.`:e.windows.map(t=>{let n=C7(t.kind),r=t.usedPercent<1?`under 1%`:`~${O7.format(t.usedPercent)}%`,i=`now at ${O7.format(t.nowPercent)}%${t.resetsAt===null?``:`, resets ${_ye(t.resetsAt)}`}`;return`This run used ${r} of your ${n} ${e.name} limit (${i}).`}).join(` `):`${e.name} did not report its plan limits for this run, so the share it used is not known.`}function w7(e){return e.calls===0?`—`:`onPlan`in e&&e.onPlan?`$0 on plan`:e.unpriced>0?e.unpriced===e.calls?`Unknown`:`${j7(e.cost)} + unknown`:j7(e.cost)}function T7(e){return e.apiEquivalent===null?`—`:e.apiUnpriced>0&&e.apiEquivalent===0?`No API price`:`~${j7(e.apiEquivalent)}`}function hye(e){let t=e.model===``?`default model`:e.model;return e.apiModel===null?`${e.provider} · ${t}`:`${e.provider} · ${t} (as ${e.apiModel})`}function E7(e){let t=[];return e.tokensIn+e.tokensOut>0&&t.push(`${k7(e.tokensIn)} in / ${k7(e.tokensOut)} out tokens${e.cachedTokens>0?` (${k7(e.cachedTokens)} cached)`:``}`),e.characters>0&&t.push(`${k7(e.characters)} characters`),e.images>0&&t.push(A7(e.images,`image`)),e.seconds>0&&t.push(`${D7.format(e.seconds)} s of video`),t.join(` · `)}var D7=new Intl.NumberFormat(void 0,{maximumFractionDigits:0}),O7=new Intl.NumberFormat(void 0,{maximumFractionDigits:1}),gye=new Intl.NumberFormat(void 0,{notation:`compact`,maximumFractionDigits:1});function k7(e){return e<1e4?D7.format(e):gye.format(e)}function A7(e,t){return`${D7.format(e)} ${t}${e===1?``:`s`}`}function j7(e){return e===0?`$0`:e<.01?`<$0.01`:`$${e.toFixed(2)}`}function M7(e){let t=Math.round(e/1e3);if(t<60)return`${t} s`;let n=Math.floor(t/60);return n<60?`${n} min ${t%60} s`:`${Math.floor(n/60)} h ${n%60} min`}function _ye(e){return new Date(e).toLocaleString(void 0,{weekday:`short`,hour:`2-digit`,minute:`2-digit`})}var vye=(e,t)=>{if(t)return`waiting`;switch(e.state){case`running`:return`running`;case`done`:case`provided`:return`done`;case`failed`:return e.retryAt===void 0?`failed`:`waiting`;default:return`off`}},yye=(e,t)=>{if(t)return`Held for you`;switch(e.state){case`running`:return`Running`;case`done`:return`Done`;case`provided`:return`Provided`;case`failed`:return e.retryAt===void 0?`Failed`:`Waiting to try again`;case`canceled`:return`Canceled`;case`skipped`:return`Off`;case`pending`:return`Not started`}};function bye(e,t){if(e.startedAt===null)return;let n=Date.parse(e.startedAt),r=e.finishedAt===null?t:Date.parse(e.finishedAt);if(!Number.isFinite(n)||!Number.isFinite(r)||r<n)return;let i=Math.round((r-n)/1e3);if(i<1)return;if(i<60)return`${String(i)} s`;let a=Math.round(i/60);return a<60?`${String(a)} min`:`${String(Math.floor(a/60))} h ${String(a%60)} min`}function xye(e,t,n){let r=V3(t,n);return r===void 0?e:e===void 0||e===``?H3(r):`${e} · ${H3(r)}`}function Sye({stages:e,outputs:t,project:n,resumable:r,held:i,now:a}){return e.filter(e=>e.state!==`skipped`).map(e=>{let o=i.some(t=>t.stage===e.kind),s=bye(e,a);return{id:e.id,name:e.kind===`video`&&XP(n.config)===`audio`?`Audio export`:s5[e.kind],tone:vye(e,o),state:yye(e,o),...s===void 0?{}:{time:s},detail:o?`Held for your review`:xye(tF(e,t,n,r),e,a)}})}function Cye({stages:e}){return(0,h.jsx)(`div`,{className:`sr-only`,children:e.filter(e=>e.state!==`skipped`).map(e=>(0,h.jsx)(`span`,{role:`status`,"aria-live":`polite`,children:`${s5[e.kind]}: ${e.state}`},e.id))})}function wye({steps:e}){return(0,h.jsxs)(`section`,{"aria-labelledby":`run-steps-title`,className:`flex flex-col gap-2`,children:[(0,h.jsx)(V,{id:`run-steps-title`,title:`Run`,size:`small`,className:`pb-0`}),(0,h.jsx)(W3,{steps:e,label:`Run steps`})]})}var N7=new Intl.NumberFormat(void 0,{maximumFractionDigits:0});function Tye({cost:e}){if(e===void 0||e.calls===0&&e.byStage.length===0)return null;let t=e.plans.flatMap(e=>e.reported?e.windows.map(t=>({key:`${e.account}/${t.kind}`,name:e.name,window:t.kind===`five_hour`?`5-hour`:t.kind===`weekly`?`weekly`:`current`,used:t.usedPercent,now:t.nowPercent})):[]);return(0,h.jsxs)(`section`,{"aria-labelledby":`cost-so-far-title`,className:`flex flex-col gap-3`,children:[(0,h.jsx)(V,{id:`cost-so-far-title`,title:`Cost so far`,size:`small`,className:`pb-0`}),(0,h.jsxs)(c4,{className:`grid-cols-2`,children:[(0,h.jsx)(l4,{value:j7(e.cost),label:e.unpriced>0?`known, spent`:`spent`}),e.apiEquivalent===null?null:(0,h.jsx)(l4,{value:`~${j7(e.apiEquivalent)}`,label:`same work via API`})]}),t.map(e=>{let t=e.used<1?`under 1%`:`${N7.format(e.used)}%`,n=`${e.window} ${e.name} limit`;return(0,h.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:`${e.name}: ${t} of your ${e.window} limit`}),(0,h.jsx)(u4,{value:e.used/100,label:`Share of the ${n} this run used`,valueText:`${t} of your ${n}; now at ${N7.format(e.now)}%`,tone:e.now>=80?`waiting`:`accent`})]},e.key)})]})}function Eye({projectId:e,revisionId:t,title:n,open:r,onClose:i}){let{api:a}=R(),o=_(),[s,c]=(0,m.useState)(null),[l,u]=(0,m.useState)(!1),[d,f]=(0,m.useState)(null),p=Dy(),g=(0,m.useRef)(!1),v=(0,m.useRef)(null);(0,m.useEffect)(()=>{r&&t!==null&&(c({revisionId:t,name:n}),f(null)),r||c(null)},[r,t,n]);async function y(){if(!s||g.current||!s.name.trim())return;g.current=!0,u(!0),f(null);let t=JSON.stringify([e,s.revisionId,s.name.trim()]);v.current?.key!==t&&(v.current={key:t,id:crypto.randomUUID()});try{let t=await Jq(a,e,{id:v.current.id,name:s.name.trim(),revisionId:s.revisionId});if(!t.ok){v.current=null,f(t.message);return}v.current=null,i(),p(`Template saved.`,`success`),await o.invalidateQueries({queryKey:Rq})}catch(e){f(e instanceof Error?e.message:`The template wasn't saved. Press Save template to try again.`)}finally{g.current=!1,u(!1)}}return(0,h.jsx)(ky,{open:r&&s!==null,onOpenChange:e=>{!e&&!g.current&&i()},title:`Save as template`,description:`Save this revision’s setup for a fresh Play draft. This does not rebuild the project.`,children:(0,h.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),y()},children:[(0,h.jsx)(Y,{label:`Template name`,tip:`play.template-name`,children:(0,h.jsx)(OV,{autoFocus:!0,required:!0,maxLength:200,disabled:l,value:s?.name??``,onChange:e=>{let t=e.target.value;c(e=>e&&{...e,name:t})}})}),d?(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-small text-danger`,children:d}):null,(0,h.jsxs)(`div`,{className:`sl-dialog__foot`,children:[(0,h.jsx)(L,{disabled:l,onClick:i,children:`Cancel`}),(0,h.jsx)(L,{variant:`primary`,type:`submit`,disabled:l||!s?.name.trim(),children:`Save template`})]})]})})}var P7=K({baseRevisionId:U().min(1).max(64),idempotencyKey:ND()}).strict(),Dye=fO(`kind`,[K({kind:SO(`resume`)}).strict(),K({kind:SO(`retry`),stage:q(MS)}).strict(),K({kind:SO(`rerun`),stage:q(MS)}).strict(),K({kind:SO(`redo`),item:U().min(1).max(200)}).strict()]);P7.extend({action:Dye}).strict();var Oye=fO(`ok`,[K({ok:SO(!0),value:f2.and(K({warnings:G(U()).readonly()}))}),K({ok:SO(!1),reason:q([`no-project`,`no-revision`,`conflict`,`idempotency-conflict`,`invalid-edit`,`stale-preview`,`invalid-selection`,`review-required`,`cost-ack-required`,`readiness`,`running`,`accepted-job`,`control-changed`]),fields:G(K({field:U(),message:U()})).readonly().optional(),intentRevisionId:U().optional(),currentRevisionId:U().nullable().optional()})]),F7=new Set([400,404,409]);async function kye(e,t,n){return L7(e,t,`cancel`,n)}async function Aye(e,t,n){return L7(e,t,`pause`,n)}function jye(e,t,n){return R7(e,t,`resume`,n)}function Mye(e,t,n,r){return R7(e,t,`stages/${n}/retry`,r)}function Nye(e,t,n,r){return R7(e,t,`stages/${n}/soften`,r)}function Pye(e,t,n,r){return R7(e,t,`stages/${n}/rerun`,r)}async function Fye(e,t,n){return I7(await e.fetch(`${e.origin}/api/projects/${encodeURIComponent(t)}/providers`,{method:`PATCH`,headers:{"content-type":`application/json`},body:JSON.stringify(n)}))}async function Iye(e,t,n){return I7(await e.fetch(`${e.origin}/api/projects/${encodeURIComponent(t)}/subtitles`,{method:`PATCH`,headers:{"content-type":`application/json`},body:JSON.stringify(n)}))}async function Lye(e,t,n){return I7(await e.fetch(`${e.origin}/api/projects/${encodeURIComponent(t)}/article`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({markdown:n})}))}async function Rye(e,t,n){return I7(await e.client.projects[`:id`].images[`:outputId`].$delete({param:{id:t,outputId:n}}))}async function zye(e,t,n){return I7(await e.client.projects[`:id`].images[`:outputId`].regenerate.$post({param:{id:t,outputId:n}}))}async function I7(e){if(e.ok)return{ok:!0,value:await e.json()};let t=await uo(e);if(t!==void 0&&F7.has(e.status))return{ok:!1,message:lo(e,t).message};throw lo(e,t)}async function L7(e,t,n,r){let i=P7.parse(r);return I7(await e.fetch(`${e.origin}/api/projects/${encodeURIComponent(t)}/${n}`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(i)}))}async function R7(e,t,n,r){let i=await e.fetch(`${e.origin}/api/projects/${encodeURIComponent(t)}/${n}`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(P7.parse(r))});if(i.ok){let e=Oye.parse(await i.json());if(!e.ok)throw Error(vo);return{ok:!0,value:e.value,warnings:e.value.warnings}}let a=await uo(i);if(a!==void 0&&F7.has(i.status))return{ok:!1,message:lo(i,a).message};throw lo(i,a)}function Bye(e){let{api:t}=R(),n=_(),[r,i]=(0,m.useState)(void 0),[a,o]=(0,m.useState)(),s=(0,m.useRef)(new Map),c=(0,m.useRef)(!1),l=N({mutationFn:async e=>{let r=e.action;if(![`pause`,`cancel`,`resume`,`retry`,`soften`,`rerun`].includes(r.kind))return B7(t,e.projectId,r);let i=r.kind===`retry`||r.kind===`soften`||r.kind===`rerun`?r.stage:``,a=`${e.projectId}:${r.kind}:${i}`,o=s.current.get(a);if(!o){let r=n.getQueryData(z.project(e.projectId))?.revisionId;if(!r){let n=await C2(t,e.projectId);if(!n.ok)return{ok:!1,message:n.message};r=n.value.view.revision.id}o={baseRevisionId:r,idempotencyKey:crypto.randomUUID()},s.current.set(a,o)}let c=await B7(t,e.projectId,r,o);return s.current.delete(a),c.ok&&await Oo(t,e.projectId).then(t=>n.setQueryData(z.project(e.projectId),t),e=>console.warn(`Project refresh after an accepted action failed`,e)),c},onMutate:()=>{i(void 0),o(void 0)},onSuccess:async(e,t)=>{e.ok?(o(`warnings`in e&&e.warnings.length>0?e.warnings.join(` `):void 0),n.invalidateQueries({queryKey:z.projects})):i({message:e.message,stage:z7(t.action)}),await n.invalidateQueries({queryKey:z.project(t.projectId)})},onSettled:()=>{c.current=!1},onError:(e,t)=>{i({message:e.message,stage:z7(t.action)})}});return{run:(t,n)=>{c.current||(c.current=!0,l.mutate({projectId:e,action:t},{onSuccess:e=>{e.ok&&n?.()}}))},pending:l.isPending,performing:l.isPending?l.variables?.action:void 0,refusal:r,dismissRefusal:()=>{i(void 0)},notice:a}}function z7(e){switch(e.kind){case`cancel`:case`pause`:case`resume`:case`providers`:return;case`retry`:case`soften`:case`rerun`:return e.stage;case`subtitles`:return`video`;case`save-article`:return`article`;case`delete-image`:case`regenerate-image`:return`images`}}function B7(e,t,n,r){let i=()=>{if(!r)throw Error(`A saved revision and request identity are required.`);return r};switch(n.kind){case`pause`:return Aye(e,t,i());case`cancel`:return kye(e,t,i());case`resume`:return jye(e,t,i());case`retry`:return Mye(e,t,n.stage,i());case`soften`:return Nye(e,t,n.stage,i());case`rerun`:return Pye(e,t,n.stage,i());case`providers`:return Fye(e,t,n.choices);case`subtitles`:return Iye(e,t,n.subtitles);case`save-article`:return Lye(e,t,n.markdown);case`delete-image`:return Rye(e,t,n.outputId);case`regenerate-image`:return zye(e,t,n.outputId)}}var V7=e=>e.state===`done`||e.state===`provided`;function Vye(e){let t=e.find(e=>e.state===`failed`)??e.find(e=>e.state===`running`);if(t)return t.kind;let n=e.find(e=>e.kind===`video`&&V7(e));if(n)return n.kind;let r=e.find(e=>e.state===`pending`);return r?r.kind:e.find(e=>e.kind===`article`&&V7(e))?.kind??e.find(e=>e.state!==`skipped`)?.kind??`article`}function Hye({projectId:e,openDraft:t}){return(0,h.jsx)(Uye,{projectId:e,openDraft:t},e)}var H7=e=>{let t=e.filter(e=>e!==void 0);if(!(t.length===0||t.every(e=>e.state===`skipped`)))return t.some(e=>e.state===`failed`&&e.retryAt===void 0)?`failed`:t.some(e=>e.state===`running`)?`running`:t.some(e=>e.state===`failed`)?`waiting`:t.every(e=>e.state===`done`||e.state===`provided`||e.state===`skipped`)?`done`:`off`};function Uye({projectId:e,openDraft:t}){let{api:n}=R(),r=Dy(),i=Kye(e,t),a=M(qy(n,e)),o=M($y(n)),s=M(Jy(n,e)),c=Bye(e),[l,u]=(0,m.useState)(),[d,f]=(0,m.useState)(!1),[p,g]=(0,m.useState)(!1),[_,v]=(0,m.useState)(!1),y=a.data?.revisionId??null,b=nye(e,y,{onOpenEdit:()=>u(`settings`)}),x=eI(e),S=(0,m.useRef)(void 0);(0,m.useEffect)(()=>{if(x===void 0){S.current=void 0;return}a.data!==void 0&&S.current!==x&&(S.current=x,x===`download`&&u(XP(a.data.project.config)===`article`?`article`:`video`))},[x,a.data]),Y3(e,y);let C=M({queryKey:My,queryFn:()=>By(n)}),w=Vy(C.data,e),T=M({queryKey:k3(e,y??``),queryFn:()=>j3(n,e),enabled:y!==null,retry:!1}),E=T.data?.ok===!0?T.data.value.checkpoints:[],D=b.saved.data?.outputs.filter(e=>e.selected&&e.state===`outdated`).map(e=>({workKey:e.workKey,role:e.output.role}))??[],O=a.data?.project,k=a.data?.stages??[],ee=a.data?.outputs??[],te=ee.some(e=>e.role===`video`),ne=e=>u(e),re=Hge({project:O??Wye,stages:k,resumable:a.data?.resumable??!1,sample:w,gates:E,outdated:D,waits:s.data?.waits??[],uploadReady:te,actions:c,controller:b,openSection:ne,openUpload:()=>f(!0)}),A=l===`settings`,ie=(0,m.useRef)(!1);(0,m.useEffect)(()=>{if(!A){ie.current=!1;return}b.edit!==void 0&&(ie.current=!0),!(ie.current||b.busy)&&(ie.current=!0,b.openEditor())},[A,b]);let j=k.some(e=>e.state===`running`),ae=O?.status===`running`,oe=O?.title??``,se=re.next?.action;_x({id:`project.next`,title:se?.label??`Show the project's next action`,group:`This project`,context:oe,keywords:[`next`,`continue`,`resume`,`approve`,`retry`],shortcut:mP.nextAction,run:()=>{se===void 0?r(`This project has no next action right now: nothing waits on you.`,`info`):se.intent.kind===`soften`?r(`Soften and retry asks first: press it in the Next action panel on the right.`):re.run(se.intent)}}),Kx(Vx.showImages(e),()=>{let e=a.data?.stages.find(e=>e.kind===`images`);e===void 0||e.state===`skipped`?r(`${oe} makes no slideshow images, so there is no image to regenerate. To add them, open Settings in this project and choose how its images are made.`,`error`):u(`images`)},a.data!==void 0),_x({id:`project.pause`,title:O?.status===`paused`?`Continue the run`:`Pause the run`,group:`This project`,context:oe,keywords:[`pause`,`resume`,`continue`,`stop`],run:()=>c.run({kind:O?.status===`paused`?`resume`:`pause`})}),_x({id:`project.prepare-upload`,title:`Prepare upload`,group:`This project`,context:oe,keywords:[`youtube`,`studio`,`upload`,`publish`],run:()=>{te?f(!0):r(`Prepare upload opens once the video has been made.`,`info`)}}),_x({id:`project.settings`,title:`Edit project settings`,group:`This project`,context:oe,keywords:[`edit`,`settings`,`prompts`,`providers`,`channel`],run:()=>u(`settings`)}),_x({id:`project.rebuild-review`,title:`Choose what to remake`,group:`This project`,context:oe,keywords:[`rebuild`,`review`,`remake`,`outdated`,`affected`],run:()=>b.review({kind:`allAffected`})}),_x({id:`project.template`,title:`Save as template`,group:`This project`,context:oe,keywords:[`template`,`reuse`],run:()=>g(!0)}),_x({id:`project.cancel`,title:`Cancel the run`,group:`This project`,context:oe,keywords:[`cancel`,`stop`],run:()=>v(!0)});let ce=Bge(D);if(_x({id:`project.remake-1`,title:ce[0]?.label??`Remake outdated outputs`,group:`This project`,context:oe,keywords:[`remake`,`outdated`,`rebuild`],run:()=>{let e=ce[0];e===void 0?r(`Nothing is outdated in this project.`,`info`):b.review({kind:`selected`,workKeys:e.workKeys},{autoStart:!0})}}),_x({id:`project.remake-all`,title:`Remake everything outdated`,group:`This project`,context:oe,keywords:[`remake`,`outdated`,`rebuild`,`all`],run:()=>{let e=[...new Set(ce.flatMap(e=>e.workKeys))];e.length===0?r(`Nothing is outdated in this project.`,`info`):b.review({kind:`selected`,workKeys:e},{autoStart:!0})}}),_x({id:`project.copy`,title:`Make my own copy`,group:`This project`,context:oe,keywords:[`sample`,`copy`,`duplicate`],run:()=>w?re.run({kind:`copy-sample`}):r(`Only the sample project is copied this way.`,`info`)}),a.error!==null)return(0,h.jsx)(fI,{tone:`danger`,title:`The project could not be loaded.`,children:`${a.error.message} Reload the page to try again, or go back to Projects.`});if(a.data===void 0||O===void 0)return(0,h.jsx)(Gye,{});let le=e=>k.find(t=>t.kind===e),ue=le(`article`),de=le(`research`),fe=le(`audio`),pe=le(`images`),me=le(`thumbnail`),he=le(`video`),ge=le(`document`),_e=O.config,ve=e=>e!==void 0&&e.state!==`skipped`,ye=_e.shorts?.enabled===!0||ee.some(e=>e.role===`short_video`||e.role===`shorts`),be=_e.youtubeDescription===!0||ee.some(e=>e.role===`youtube_description`),xe=E.filter(e=>e.state===`held`||e.state===`pending-review`),Se=[...ve(ue)||ve(de)?[{id:`article`,label:`Article`,tone:H7([ue,de])}]:[],...ve(fe)?[{id:`narration`,label:`Narration`,tone:H7([fe])}]:[],...ve(pe)||ve(me)||_e.reference!==void 0?[{id:`images`,label:`Images`,tone:H7([pe,me])}]:[],...ve(he)?[{id:`video`,label:XP(_e)===`audio`?`Audio export`:`Video`,tone:H7([he])}]:[],...ye?[{id:`shorts`,label:`Shorts`}]:[],...be?[{id:`youtube`,label:`YouTube`}]:[],...ve(ge)?[{id:`document`,label:`PDF`,tone:H7([ge])}]:[],{id:`cost`,label:`Cost`},{id:`live`,label:`Live`}].map(e=>{let t=ce.filter(t=>t.section===e.id).reduce((e,t)=>e+t.count,0);return t===0?e:{...e,meta:`${String(t)} outdated`}}),Ce=[{id:`settings`,label:`Settings`,...b.unsaved?{meta:`unsaved`}:{}},...y===null?[]:[{id:`checkpoints`,label:`Checkpoints`,...xe.length===0?{}:{meta:`${String(xe.length)} held`}}],{id:`history`,label:`History`}],we=[...Se,...Ce],Te=re.next?.situation,Ee=re.next?.section!==void 0&&Te!==`done`&&Te!==`running`?re.next.section:Te===`done`&&ee.some(e=>e.role===`youtube_description`)?`youtube`:o5(Vye(k)),De=l!==void 0&&we.some(e=>e.id===l)?l:we.find(e=>e.id===Ee)?.id??Se[0]?.id??`cost`,Oe=(...e)=>y===null?O.status===`running`||O.status===`paused`||j||c.pending:c.pending||e.some(e=>e?.state===`running`),ke={project:O,outputs:ee,actions:c,next:re,resumable:a.data.resumable},Ae=(e,t)=>e===void 0?null:(0,h.jsx)(P_e,{stage:e,...t===void 0||t.state===`skipped`?{}:{companion:t},project:O,outputs:ee,actions:c,busy:Oe(e,t)}),je=(...e)=>ee.some(t=>e.some(e=>e!==void 0&&t.stageKind===e.kind)),Me=(...e)=>je(...e)||e.some(e=>e!==void 0&&[`running`,`done`,`provided`,`failed`,`canceled`].includes(e.state)),Ne=[{id:`rebuild`,label:`Choose what to remake…`,run:()=>b.review({kind:`allAffected`}),disabled:b.busy},{id:`template`,label:`Save as template…`,run:()=>g(!0),disabled:y===null||w},{id:`cancel`,label:`Cancel the run…`,run:()=>v(!0),disabled:!ae||c.pending,apart:!0}],Pe=n5({kind:`cancel`}),Fe=c.refusal?.stage===void 0?c.refusal:void 0,Ie=Fe===void 0?c.notice===void 0?b.preview===void 0&&(b.error||b.refusal)&&De!==`settings`&&De!==`history`?(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-small text-danger`,children:b.error??b.refusal?.message}):void 0:(0,h.jsx)(`p`,{role:`status`,className:`m-0 text-small text-ink-2`,children:c.notice}):(0,h.jsx)(fI,{tone:`danger`,title:Fe.message,children:(0,h.jsx)(L,{variant:`quiet`,size:`small`,className:`mt-1`,onClick:c.dismissRefusal,children:`Dismiss`})}),Le=Sye({stages:k,outputs:ee,project:O,resumable:a.data.resumable,held:xe.map(e=>({checkpointId:e.checkpointId,stage:e.stage,dependents:e.dependents})),now:Date.now()});return(0,h.jsx)(Qhe,{projectId:e,revisionId:y,children:(0,h.jsx)(r5,{value:y!==null,children:(0,h.jsx)(fpe,{value:e=>u(e===`edit`?`settings`:`article`),children:(0,h.jsxs)(i5,{value:b.pending||b.preview!==void 0?void 0:b.requestEdit,children:[(0,h.jsx)(`div`,{"data-tour":`project-controls`,children:(0,h.jsx)(G_e,{project:O,prompts:o.data?.prompts,editing:De===`settings`,onEdit:()=>u(`settings`),more:Ne,nextChapter:i})}),(0,h.jsx)(Cye,{stages:k}),De===`cost`?null:(0,h.jsx)(cye,{cost:s.data,status:O.status,onOpen:()=>ne(`cost`)}),(0,h.jsxs)(jq,{sections:(0,h.jsxs)(p8,{label:`Project sections`,children:[Se.map(e=>(0,h.jsx)(W7,{item:e,selected:De,onSelect:ne},e.id)),(0,h.jsx)(`hr`,{className:`sl-rule my-2`}),Ce.map(e=>(0,h.jsx)(W7,{item:e,selected:De,onSelect:ne},e.id))]}),aside:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(Wge,{state:re,feedback:Ie}),O===void 0?null:(0,h.jsx)(W_e,{projectId:e,title:O.title,status:O.status,sample:w||C.isPending}),(0,h.jsxs)(`div`,{className:`flex flex-col gap-6 max-[1180px]:hidden`,children:[(0,h.jsx)(wye,{steps:Le}),(0,h.jsx)(Tye,{cost:s.data}),(0,h.jsx)(Ihe,{})]})]}),children:[(0,h.jsx)(p5,{id:`article`,title:`Article`,stages:[ue,de].filter(U7),active:De===`article`,...ke,children:ve(ue)||ve(de)?Ae(ue,de):(0,h.jsx)(m5,{stage:ue,project:O,name:`Article`})}),(0,h.jsx)(p5,{id:`narration`,title:`Narration`,stages:[fe].filter(U7),active:De===`narration`,...ke,children:Me(fe)?Ae(fe):(0,h.jsx)(m5,{stage:fe,project:O,name:`Narration`})}),(0,h.jsx)(p5,{id:`images`,title:`Images`,head:!1,stages:[pe,me].filter(U7),active:De===`images`,...ke,children:Ae(pe,me)}),(0,h.jsx)(p5,{id:`video`,title:XP(_e)===`audio`?`Audio export`:`Video`,stages:[he].filter(U7),active:De===`video`,...ke,children:Ae(he)}),he===void 0?null:(0,h.jsx)(p5,{id:`shorts`,title:`Shorts`,stages:[],active:De===`shorts`,...ke,meta:`Vertical clips picked from the video, each with its title and hashtags`,children:(0,h.jsx)(T_e,{stage:he,project:O,outputs:ee})}),he===void 0?null:(0,h.jsx)(p5,{id:`youtube`,title:`YouTube`,stages:[],active:De===`youtube`,...ke,meta:`The description, chapters, hashtags and tags, as they go into YouTube Studio`,...te&&re.next?.action?.intent.kind!==`prepare-upload`?{extra:(0,h.jsx)(L,{variant:`secondary`,onClick:()=>f(!0),children:`Prepare upload`})}:{},children:(0,h.jsx)(F_e,{stage:he,project:O,outputs:ee})}),ge===void 0?null:(0,h.jsx)(p5,{id:`document`,title:`PDF`,stages:[ge],active:De===`document`,...ke,children:Me(ge)?Ae(ge):(0,h.jsx)(m5,{stage:ge,project:O,name:`PDF`})}),(0,h.jsx)(G7,{id:`cost`,title:`Run cost`,selected:De,children:(0,h.jsx)(sye,{projectId:e})}),(0,h.jsx)(G7,{id:`live`,title:`Live`,selected:De,children:De===`live`?(0,h.jsx)(tve,{project:O,revisionId:y,stages:k,outputs:ee}):null}),(0,h.jsx)(G7,{id:`settings`,title:`Settings`,selected:De,children:(0,h.jsx)(iye,{controller:b,active:De===`settings`,renderEditor:e=>(0,h.jsx)(Uve,{...e,renderContent:e=>(0,h.jsx)(Eve,{...e},e.view.revision.id)})})}),y===null?null:(0,h.jsx)(G7,{id:`checkpoints`,title:`Checkpoints`,selected:De,children:(0,h.jsx)(B_e,{projectId:e,revisionId:y,paused:O.status===`paused`,stages:k,approvedInRail:re.next?.action?.intent.kind===`approve`?re.next.action.intent.gate.checkpointId:void 0})}),(0,h.jsx)(G7,{id:`history`,title:`History`,selected:De,children:(0,h.jsx)(aye,{controller:b,projectId:e,active:De===`history`})})]}),(0,h.jsx)(oye,{controller:b}),d?(0,h.jsx)(L2,{projectId:e,onClose:()=>f(!1)}):null,(0,h.jsx)(Eye,{projectId:e,revisionId:y,title:O.title,open:p,onClose:()=>g(!1)}),(0,h.jsx)(Ay,{open:_,title:Pe.title,consequence:Pe.consequence,confirmLabel:Pe.verb,cancelLabel:Pe.dismiss,pending:c.pending,onConfirm:()=>{v(!1),c.run({kind:`cancel`})},onCancel:()=>v(!1)})]})})})})}var U7=e=>e!==void 0;function W7({item:e,selected:t,onSelect:n}){return(0,h.jsx)(m8,{className:`max-md:w-auto`,"data-tour":`project-rail-${e.id}`,current:e.id===t,onClick:()=>n(e.id),...e.tone===void 0?{}:{icon:(0,h.jsx)(pS,{tone:e.tone})},...e.meta===void 0?{}:{meta:e.meta},children:e.label})}function G7({id:e,title:t,selected:n,children:r}){return(0,h.jsxs)(`section`,{hidden:n!==e,"aria-label":t,className:`flex min-w-0 flex-col gap-5`,children:[(0,h.jsx)(`h2`,{className:`sl-section-head__title m-0`,children:t}),r]})}var Wye={id:``,title:``,format:`16:9`,status:`pending`,createdAt:``,config:{sources:{}}};function Gye(){return(0,h.jsxs)(`div`,{role:`status`,"aria-label":`Loading project`,children:[(0,h.jsxs)(`div`,{className:`mb-6 flex flex-col gap-2`,children:[(0,h.jsx)(`span`,{className:`h-3 w-20 rounded-control bg-sunken`}),(0,h.jsx)(`span`,{className:`h-8 w-80 max-w-full rounded-control bg-sunken`})]}),(0,h.jsx)(jq,{sections:(0,h.jsx)(`div`,{className:`flex flex-col gap-2`,children:[`a`,`b`,`c`,`d`,`e`].map(e=>(0,h.jsx)(`span`,{className:`h-8 rounded-control bg-sunken`},e))}),aside:(0,h.jsx)(`span`,{className:`h-40 rounded-control bg-sunken`}),children:(0,h.jsx)(`span`,{className:`h-[480px] rounded-control bg-sunken`})})]})}function Kye(e,t){let{api:n}=R(),r=(0,m.useRef)(void 0),[i,a]=(0,m.useState)(!1),[o,s]=(0,m.useState)(void 0);if(t!==void 0)return{pending:i,error:o,run:()=>{i||(r.current??=crypto.randomUUID(),a(!0),s(void 0),Xq(n,e,r.current).then(async e=>{if(!e.ok){s(e.message);return}await t(e.value.draft.id)?r.current=void 0:s(`The next chapter's draft was made, but Play could not open it because the draft open there is not saved yet. Open Play, let it save, then press Make the next chapter again.`)}).catch(e=>s(`The next chapter could not be made (${e instanceof Error?e.message:`the connection dropped`}). Press Make the next chapter again.`)).finally(()=>a(!1)))}}}var qye=[`all`,`running`,`queued`,`waiting`,`ready`,`failed`];function Jye(e){return qye.find(t=>t===e)}var K7=[{value:`all`,label:`All`},{value:`running`,label:`Running`},{value:`queued`,label:`Queued`},{value:`waiting`,label:`Needs you`},{value:`ready`,label:`Ready to upload`},{value:`failed`,label:`Failed`}];function q7(e,t){switch(t){case`all`:return!0;case`running`:return e.status===`running`||e.status===`paused`;case`queued`:return B3(e);case`waiting`:return F3(e);case`ready`:return z3(e);case`failed`:return e.status===`failed`||e.status===`partial`}}function Yye(e){let t={running:{tone:`running`,word:`Running`},paused:{tone:`waiting`,word:`Paused`},pending:{tone:`off`,word:`Queued`},failed:{tone:`failed`,word:`Failed`},partial:{tone:`info`,word:`Done with problems`},done:{tone:`done`,word:`Done`},canceled:{tone:`off`,word:`Canceled`}};if(F3(e))return{tone:`waiting`,word:`Waiting for you`};let n=e.status===`running`?ZH(e.limitWaits):void 0;return n===void 0?t[e.status]:{tone:`waiting`,word:n}}function Xye(e){let t=e.config.articlePrompt,n=e.config.voices?.book;return[n===void 0?void 0:KA(n),t===void 0||t===``?void 0:t,e.format].filter(e=>e!==void 0).join(` · `)}function Zye({initialFilter:e=`all`}={}){let{api:t}=R(),n=_(),r=Dy(),i=px(),a=M(Ky(t)),[o,s]=(0,m.useState)(void 0),[c,l]=(0,m.useState)(e),u=M({queryKey:jy,queryFn:()=>Fy(t)}),d=new Set(Object.values(u.data?.samples??{}).filter(e=>e!==null)),[f,p]=(0,m.useState)(``),g=(0,m.useRef)(null),v=vx(g,`projects`),y=N({mutationFn:e=>Ao(t,e),onSettled:async()=>{s(void 0),await n.invalidateQueries({queryKey:z.projects})}}),b=N({mutationFn:e=>R3(t,e.project.id,e.uploaded),onError:(e,t)=>r(`${t.project.title} wasn't changed: ${e.message} Press the button again.`,`error`),onSettled:async()=>{await n.invalidateQueries({queryKey:z.projects})}});_x({id:`projects.show.waiting`,title:`Show projects that need you`,group:`Projects`,keywords:[`waiting`,`filter`],run:()=>l(`waiting`)}),_x({id:`projects.show.ready`,title:`Show videos ready to upload`,group:`Projects`,keywords:[`upload`,`finished`,`filter`],run:()=>l(`ready`)}),_x({id:`projects.show.failed`,title:`Show failed projects`,group:`Projects`,keywords:[`error`,`filter`],run:()=>l(`failed`)});let x=(a.data?.projects??[]).filter(e=>i.includes(e.channelId)),S=f.trim().toLowerCase(),C=x.filter(e=>q7(e,c)&&(S===``||e.title.toLowerCase().includes(S)));return(0,h.jsxs)(`div`,{children:[(0,h.jsx)(Aq,{title:`Projects`,meta:a.data===void 0?void 0:`${String(x.length)} ${x.length===1?`project`:`projects`} · ${i.channel?.name??`every channel`}`,actions:(0,h.jsxs)(lS,{to:`/play`,variant:`primary`,children:[(0,h.jsx)(kc,{"aria-hidden":`true`,strokeWidth:1.75}),`New video`]})}),a.data?.projects.length===0?(0,h.jsx)(PB,{}):null,a.error===null?null:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 mb-4 text-danger`,children:a.error.message}),a.data===void 0?a.error===null?(0,h.jsx)($ye,{}):null:a.data.projects.length===0?(0,h.jsx)(T0,{title:`No projects yet`,actions:(0,h.jsx)(lS,{to:`/play`,variant:`primary`,children:`Make your first video`}),children:`Set up a run on Play: pick a template, type a topic and start.`}):(0,h.jsxs)(b0,{split:`aside`,children:[(0,h.jsxs)(x0,{label:`Project list`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,h.jsxs)(`div`,{className:`relative w-full max-w-[320px]`,children:[(0,h.jsx)(Nc,{"aria-hidden":`true`,strokeWidth:1.75,className:`pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2 text-ink-3`}),(0,h.jsx)(`input`,{type:`search`,ref:g,"aria-label":`Search projects`,"aria-keyshortcuts":kx(v),placeholder:`Search projects`,value:f,onChange:e=>p(e.target.value),className:`sl-input pl-9`})]}),(0,h.jsx)(Db,{label:`Show`,value:c,options:K7,onChange:l,className:`max-w-full overflow-x-auto`})]}),C.length===0?(0,h.jsx)(`p`,{className:`m-0 text-ink-2`,children:x.length===0?`No projects in ${i.channel?.name??`this channel`} yet. Pick All channels in the rail to see the others.`:`No project matches. Clear the search or pick All.`}):(0,h.jsx)(hU,{label:`Projects`,children:C.map(e=>(0,h.jsx)(Qye,{project:e,sample:d.has(e.id),onDelete:()=>s(e),onUploaded:t=>b.mutate({project:e,uploaded:t}),busy:b.isPending},e.id))})]}),(0,h.jsxs)(x0,{as:`aside`,label:`Projects at a glance`,children:[(0,h.jsxs)(`section`,{children:[(0,h.jsx)(V,{title:`At a glance`}),(0,h.jsx)(c4,{children:K7.filter(e=>e.value!==`all`).map(e=>(0,h.jsx)(l4,{label:e.label,value:String(x.filter(t=>q7(t,e.value)).length)},e.value))})]}),(0,h.jsxs)(`section`,{"aria-label":`Video queue`,className:`flex flex-col gap-2`,children:[(0,h.jsx)(V,{title:`Video queue`,info:`play.queue`}),(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:`Videos started together, in the order they run, are on the calendar.`}),(0,h.jsx)(`div`,{children:(0,h.jsx)(uS,{to:`/calendar`,children:`Open calendar`})})]})]})]}),y.error===null?null:(0,h.jsx)(`p`,{role:`alert`,className:`mt-3 text-small text-danger`,children:y.error.message}),(0,h.jsx)(Ay,{open:o!==void 0,title:o===void 0?``:`Delete "${o.title}"?`,consequence:`Moves the project to the trash for 30 days. Restore it or delete it for good in Settings → Trash.`,confirmLabel:`Delete project`,cancelLabel:`Keep it`,pending:y.isPending,onConfirm:()=>{o!==void 0&&y.mutate(o.id)},onCancel:()=>s(void 0)})]})}function Qye({project:e,sample:t,onDelete:n,onUploaded:r,busy:i}){let a=Yye(e),o=e.status===`running`;return(0,h.jsx)(gU,{title:(0,h.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,h.jsx)(pa,{to:`/projects/$projectId`,params:{projectId:e.id},children:e.title}),t?(0,h.jsx)(hS,{children:`Sample`}):null]}),meta:(0,h.jsxs)(`span`,{className:`flex flex-col gap-1`,children:[(0,h.jsx)(`span`,{children:`${Xye(e)} · started ${Tu(e.createdAt)}`}),o?(0,h.jsx)(u4,{value:e.progress,label:`${e.title} progress`,valueText:`${String(Math.round(e.progress*100))}% done`,className:`max-w-[240px]`}):null]}),actions:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(mS,{tone:a.tone,children:[a.word,(0,h.jsx)(`span`,{className:`sr-only`,role:`status`,"aria-live":`polite`,children:`${e.title}: ${a.word}`})]}),z3(e)?(0,h.jsx)(L,{variant:`quiet`,size:`small`,disabled:i,disabledReason:`Saving…`,onClick:()=>r(!0),children:`Mark uploaded`}):null,z3(e)?(0,h.jsx)(B,{id:`project.mark-uploaded`}):e.uploadedAt===null?null:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(hS,{children:`Uploaded`}),(0,h.jsx)(L,{variant:`quiet`,size:`small`,"aria-label":`Mark ${e.title} not uploaded`,disabled:i,disabledReason:`Saving…`,onClick:()=>r(!1),children:`Undo`})]}),(0,h.jsx)(Cy,{label:`Delete ${e.title}`,size:`small`,disabled:o,disabledReason:`Cancel the run first, then delete it.`,onClick:n,children:(0,h.jsx)(Ic,{"aria-hidden":`true`,strokeWidth:1.75})})]})})}function $ye(){return(0,h.jsx)(`ul`,{"aria-label":`Loading projects`,className:`sl-list m-0 list-none p-0`,children:[0,1,2,3,4,5].map(e=>(0,h.jsxs)(`li`,{className:`sl-row`,"data-slot":`skeleton-row`,children:[(0,h.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-2`,children:[(0,h.jsx)(`span`,{className:`h-3 w-2/5 rounded-control bg-sunken`}),(0,h.jsx)(`span`,{className:`h-[10px] w-1/4 rounded-control bg-sunken`})]}),(0,h.jsx)(`span`,{className:`h-[10px] w-16 rounded-control bg-sunken`})]},e))})}var ebe=`Prepare restrained delivery cues for a documentary narrator. Let the facts carry the scene. Use a measured pace and make only occasional changes where the supplied wording clearly calls for emphasis, reflection or tension. Prefer no cue to an unnecessary cue. Avoid theatrical emotion, invented reactions and routine laughter or sighs. Never rewrite, summarize, translate or add spoken words. Return only the cue annotations required by the supplied format contract.`;function J7({promptId:e,kind:t,from:n,onLeave:r}){let{api:i}=R(),a=_(),o=$F(),s=M($y(i)),c=(0,m.useId)(),l=(0,m.useId)(),u=(0,m.useId)(),[d,f]=dP(JSON.stringify(e===void 0?[`new`,t,n??null]:[`prompt`,e])),[p,g]=(0,m.useState)([]),[v,y]=(0,m.useState)(void 0),b=v!==void 0,[x,S]=(0,m.useState)(!1),[C,w]=(0,m.useState)(!1),T=s.data?.prompts,E=e??n,D=E===void 0?void 0:T?.find(e=>e.id===E),O=D===void 0?{kind:t,name:``,body:``}:e===void 0?{kind:D.kind,name:`${D.name} copy`,body:D.body}:{kind:D.kind,name:D.name,body:D.body},k=d??v??O,ee=N({mutationFn:t=>_s(i,t,e),onSuccess:async(e,t)=>{if(!e.ok){g(e.fields);return}y(e.value),f(e=>e===t?void 0:e),o({type:`prompt-saved`,id:e.value.id,kind:e.value.kind}),await a.invalidateQueries({queryKey:$y(i).queryKey})}}),te=N({mutationFn:e=>ys(i,e),onSuccess:async()=>{S(!1),f(void 0),await a.invalidateQueries({queryKey:$y(i).queryKey}),r(k.kind)}}),ne=N({mutationFn:({id:e,on:t})=>vs(i,e,t),onSettled:async()=>{await a.invalidateQueries({queryKey:$y(i).queryKey})}});p4(b,()=>{r(k.kind)});let re=(e,t)=>{f(e),g(e=>e.filter(e=>e.field!==t))},A=v3(k,p),ie=y3(A),j=S3(k.body),ae=k.body.trim()===``?[]:b3(A),oe=k.name.trim()===``?[]:x3(A);return QF({promptNamed:k.name.trim()!==``&&oe.length===0,promptBodyReady:k.body.trim()!==``&&ae.length===0,promptHasKeywords:j.length>0&&ae.length===0,promptSaveReady:ie===void 0&&!ee.isPending&&!b,promptSaving:ee.isPending||b,promptIsArticle:k.kind===`article`,promptIsImage:k.kind===`image`}),s.error===null?E!==void 0&&T===void 0?(0,h.jsx)(g4,{}):E!==void 0&&D===void 0?(0,h.jsx)(X7,{kind:t,children:`That prompt is gone. It may have been deleted in another tab.`}):(0,h.jsxs)(`div`,{children:[(0,h.jsx)(Aq,{crumb:(0,h.jsx)(M4,{children:(0,h.jsx)(pa,{to:`/prompts`,search:{kind:k.kind},children:`Prompts`})}),title:e===void 0?`New prompt`:`Edit prompt`,meta:`${bV(k.kind)} prompt`}),(0,h.jsxs)(`div`,{"data-tour":`prompt-editor`,className:`grid grid-cols-[minmax(0,1fr)] items-start gap-6 lg:grid-cols-[minmax(0,1fr)_360px]`,children:[(0,h.jsxs)(`div`,{className:`${A4} flex min-w-0 flex-col gap-4`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-end gap-4`,children:[(0,h.jsx)(`div`,{"data-tour":`prompt-name`,className:`min-w-[min(100%,240px)] flex-1`,children:(0,h.jsx)(Y,{label:`Name`,tip:`library.prompt.name`,...oe.length===0?{}:{error:oe.map(e=>e.message).join(` `)},children:(0,h.jsx)(OV,{value:k.name,onChange:e=>{re({...k,name:e.target.value},`name`)}})})}),(0,h.jsx)(g3,{label:`Kind`,value:k.kind,options:yV,tip:`library.prompt.kind`,onPick:e=>{re({...k,kind:e},`name`)}})]}),(0,h.jsxs)(`div`,{"data-tour":`prompt-body`,...Tb,children:[(0,h.jsxs)(`div`,{className:`mb-1 flex min-h-8 items-end justify-between gap-3`,children:[(0,h.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,h.jsx)(`label`,{htmlFor:c,className:`sl-field__label`,children:`Body`}),(0,h.jsx)(B,{id:tbe[k.kind],label:`${bV(k.kind)} prompt body`,className:`-my-1`})]}),Y7(k.kind)?(0,h.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,h.jsx)(L,{variant:`quiet`,size:`small`,onClick:()=>{let e=Y7(k.kind);e!==void 0&&(k.body.trim()===``?re({...k,body:e.body},`body`):w(!0))},children:Y7(k.kind)?.label}),(0,h.jsx)(B,{id:`library.prompt.starter`,label:Y7(k.kind)?.label})]}):null]}),(0,h.jsx)(w3,{id:c,value:k.body,invalid:ae.length>0,describedBy:ae.length===0?void 0:l,onChange:e=>{re({...k,body:e},`body`)}})]}),k.kind===`image`?(0,h.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[e!==void 0&&D?.kind===`image`?(0,h.jsx)(Eb,{checked:ne.isPending?ne.variables.on:D.photorealistic===!0,disabled:ne.isPending,onChange:t=>ne.mutate({id:e,on:t}),label:`Draws photorealistic pictures`,tip:`library.prompt.photorealistic`}):(0,h.jsxs)(`span`,{className:`flex items-center gap-1 text-small text-ink-2`,children:[`Save this Image prompt first, then choose whether it draws photorealistic pictures.`,(0,h.jsx)(B,{id:`library.prompt.photorealistic`})]}),ne.error===null?null:(0,h.jsx)(`span`,{role:`alert`,className:`text-small text-danger`,children:`Couldn't change Draws photorealistic pictures: ${ne.error.message} Press the switch again.`})]}):null,(0,h.jsx)(`div`,{"data-tour":`prompt-save`,children:(0,h.jsx)(h4,{onDelete:e===void 0?void 0:()=>{S(!0)},blocked:ie,blockedId:u,pending:ee.isPending,saved:b,cancel:(0,h.jsx)(lS,{to:`/prompts`,search:{kind:k.kind},onClick:()=>{f(void 0)},variant:`secondary`,children:`Cancel`}),errors:[ee.error,te.error].flatMap(e=>e===null?[]:[e.message]),onSave:()=>{ee.mutate(k)}})})]}),(0,h.jsx)(`div`,{"data-tour":`prompt-slots`,className:j4,children:(0,h.jsx)(f3,{slots:j,body:k.body,lint:ae,lintId:l})})]}),(0,h.jsx)(Ay,{open:C,title:`Replace this prompt body?`,consequence:`The starter replaces the text in this editor. Nothing is saved until you choose Save.`,confirmLabel:`Use starter`,tone:`primary`,onConfirm:()=>{let e=Y7(k.kind);e!==void 0&&re({...k,body:e.body},`body`),w(!1)},onCancel:()=>w(!1)}),(0,h.jsx)(Ay,{open:x,title:`Delete "${k.name}"?`,consequence:`Moves it to the trash for 30 days (Settings → Trash). Projects that used it keep their text.`,confirmLabel:`Delete prompt`,pending:te.isPending,onConfirm:()=>{e!==void 0&&te.mutate(e)},onCancel:()=>{S(!1)}})]}):(0,h.jsx)(X7,{kind:k.kind,children:s.error.message})}var tbe={article:`library.prompt.body.article`,image:`library.prompt.body.image`,thumbnail:`library.prompt.body.thumbnail`,narration:`library.prompt.body.narration`,description:`library.prompt.body.description`,shorts:`library.prompt.body.shorts`,review:`library.prompt.body.review`,script:`library.prompt.body.script`};function Y7(e){if(e===`narration`)return{label:`Use Documentary Starter`,body:ebe};if(e===`description`)return{label:`Use Built-in Starter`,body:Tme};if(e===`shorts`)return{label:`Use Built-in Starter`,body:eA}}function X7({kind:e,children:t}){return(0,h.jsx)(N4,{back:(0,h.jsx)(pa,{to:`/prompts`,search:{kind:e},children:`Back to Prompts`}),children:t})}function nbe({kind:e,onKind:t,onUseInPlay:n,playBlocked:r}){let{api:i}=R(),a=_(),o=M($y(i)),[s,c]=(0,m.useState)(``),l=(0,m.useRef)(null),u=vx(l,`prompts`),[d,f]=(0,m.useState)(void 0),[p,g]=(0,m.useState)(void 0),[v,y]=(0,m.useState)(void 0),b=N({mutationFn:e=>ys(i,e),onSettled:async()=>{g(void 0),await a.invalidateQueries({queryKey:z.prompts})}}),x=async(e,t)=>{let n=await _s(i,{kind:e.kind,name:t,body:e.body},e.id);return await a.invalidateQueries({queryKey:z.prompts}),n.ok?null:u3(n.fields)},S=o.data?.prompts.filter(t=>t.kind===e),C=s.trim().toLowerCase(),w=C===``?S:S?.filter(e=>e.name.toLowerCase().includes(C)||e.body.toLowerCase().includes(C)),T=w?.find(e=>e.id===d)??w?.[0];return(0,h.jsxs)(`div`,{children:[(0,h.jsxs)(r3,{action:(0,h.jsx)(ibe,{kind:e}),children:[(0,h.jsx)(OV,{type:`search`,ref:l,"aria-label":`Search prompts`,"aria-keyshortcuts":kx(u),placeholder:`Search prompts`,value:s,className:`w-full min-w-0 sm:w-64`,onChange:e=>c(e.target.value)}),(0,h.jsxs)(`span`,{className:`flex w-full items-center gap-1 sm:w-auto`,...Tb,children:[(0,h.jsx)(AV,{"aria-label":`Prompt kind`,value:e,className:`w-full sm:w-56`,options:yV,onChange:e=>{let n=yV.find(t=>t.value===e.target.value);n!==void 0&&t(n.value)}}),(0,h.jsx)(B,{id:`library.prompt.kind`})]})]}),o.error===null?null:(0,h.jsx)(t3,{what:`prompts`,message:o.error.message,onRetry:()=>void o.refetch()}),w===void 0||S===void 0?o.error===null?(0,h.jsx)(e3,{label:`Prompts`}):null:S.length===0?(0,h.jsxs)(T0,{title:`No ${bV(e).toLowerCase()} prompts yet`,children:[`A prompt is text with `,`{{keywords}}`,`; each keyword becomes a field on Play.`]}):(0,h.jsx)(Mq,{className:Q4,list:w.length===0?(0,h.jsx)(`p`,{className:`m-0 py-3 text-small text-ink-2`,children:`No ${bV(e).toLowerCase()} prompts match "${s.trim()}".`}):(0,h.jsx)(hU,{label:`Prompts`,children:w.map(e=>(0,h.jsx)(gU,{className:$4,title:(0,h.jsx)(d3,{name:e.name,onSelect:()=>f(e.id),onRename:t=>x(e,t)}),meta:rbe(e),selected:e.id===T?.id,actions:(0,h.jsx)(n3,{name:e.name,edit:(0,h.jsx)(lS,{to:`/prompts/$promptId`,params:{promptId:e.id},"aria-label":`Edit ${e.name}`,variant:`quiet`,size:`small`,children:`Edit`}),duplicate:(0,h.jsx)(lS,{to:`/prompts/new`,search:{kind:e.kind,from:e.id},"aria-label":`Duplicate ${e.name}`,variant:`quiet`,size:`small`,children:`Duplicate`}),play:{run:n===void 0?void 0:()=>n(e),blocked:r},onHistory:()=>y(e),onDelete:()=>g(e)})},e.id))}),detail:T===void 0?null:(0,h.jsx)(Y4,{item:`prompt`,id:T.id,name:T.name,kicker:`${bV(T.kind)} prompt`,meta:`Updated ${Z4(T.updatedAt)}`,body:T.body,slots:T.slots,actions:(0,h.jsx)(lS,{to:`/prompts/$promptId`,params:{promptId:T.id},size:`small`,children:`Edit prompt`}),onOpenHistory:()=>y(T)},T.id)}),b.error===null?null:(0,h.jsx)(fI,{tone:`danger`,title:`The prompt wasn't deleted.`,className:`mt-4`,children:b.error.message}),v===void 0?null:(0,h.jsx)(G4,{item:`prompt`,id:v.id,name:v.name,onClose:()=>y(void 0)},v.id),(0,h.jsx)(Ay,{open:p!==void 0,title:p===void 0?``:`Delete "${p.name}"?`,consequence:`Moves it to the trash for 30 days (Settings → Trash). Projects that used it keep their text.`,confirmLabel:`Delete prompt`,pending:b.isPending,onConfirm:()=>{p!==void 0&&b.mutate(p.id)},onCancel:()=>g(void 0)})]})}function rbe(e){return`${bV(e.kind)} · ${X4(e.slots.length,`keyword`)} · updated ${Z4(e.updatedAt)}`}function ibe({kind:e}){return(0,h.jsx)(lS,{to:`/prompts/new`,search:{kind:e},variant:`primary`,children:`New prompt`})}var abe={template:`Template`,schedule:`Schedule`,draft:`Draft`,project:`Project`};function Z7(e){let t=[e.added.length>0?`${e.added.length} new`:null,e.priced.length>0?`${e.priced.length} repriced`:null,e.retired.length>0?`${e.retired.length} retired`:null].filter(e=>e!==null);return t.length===0?`No changes`:t.join(`, `)}function obe(){let{api:e}=R(),t=_(),n=Dy(),r=M({queryKey:c0.catalogue,queryFn:()=>mue(e),refetchInterval:3e4}),i=M({queryKey:c0.retired,queryFn:()=>d0(e)}),a=async()=>{await Promise.all([t.invalidateQueries({queryKey:[`provider-models`]}),t.invalidateQueries({queryKey:c0.retired})])},o=N({mutationFn:()=>hue(e),onSuccess:async e=>{t.setQueryData(c0.catalogue,e),n(e.sync?.warning??`Model list checked: ${Z7(e.sync?.changes??sbe)}.`,e.sync?.warning?`error`:`success`),await a()}}),s=N({mutationFn:()=>gue(e),onSuccess:async e=>{n(`Catalogue replaced with the published file.`,`success`),t.setQueryData(c0.catalogue,e),await a()}}),c=async()=>{await Promise.all([t.invalidateQueries({queryKey:c0.retired}),t.invalidateQueries({queryKey:Rq}),t.invalidateQueries({queryKey:OH}),t.invalidateQueries({queryKey:[`play-drafts`]}),t.invalidateQueries({queryKey:[`projects`]}),t.invalidateQueries({queryKey:[`project`]})])},l=N({mutationFn:t=>f0(e,t),onSuccess:c}),u=N({mutationFn:()=>_ue(e),onSuccess:async e=>{n(e.failed.length===0?`Switched ${e.switched} ${e.switched===1?`use`:`uses`}.`:`Switched ${e.switched}; ${e.failed.length} could not be switched: ${e.failed[0]?.message??``}`,e.failed.length===0?`success`:`error`),await c()}}),d=r.data?.sync,f=i.data??[],p=f.filter(e=>e.blocked===null&&e.replacement!==null),m=o.error?.message??s.error?.message??r.error?.message??r.data?.warning??d?.warning??null;return _x({id:`settings.check-models`,title:`Check for new models`,group:`Settings`,context:`Models`,keywords:[`catalogue`,`prices`,`retired`],run:()=>{!o.isPending&&r.data?.path&&o.mutate()}}),(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`div`,{children:[(0,h.jsxs)(V,{title:`Model catalogue`,info:`settings.models.catalogue`,children:[(0,h.jsx)(L,{disabled:o.isPending||!r.data?.path,onClick:()=>o.mutate(),children:o.isPending?`Checking…`:`Check now`}),(0,h.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,h.jsx)(L,{variant:`quiet`,disabled:s.isPending||!r.data?.path,onClick:()=>s.mutate(),children:s.isPending?`Replacing…`:`Replace with published file`}),(0,h.jsx)(B,{id:`settings.models.replace`})]})]}),(0,h.jsxs)(`dl`,{className:`m-0 grid gap-x-6 border-t border-line text-small sm:grid-cols-[160px_minmax(0,1fr)]`,children:[(0,h.jsx)(`dt`,{className:`pt-3 font-semibold text-ink sm:border-b sm:border-line sm:pb-3`,children:`Catalogue file`}),(0,h.jsx)(`dd`,{className:`m-0 min-w-0 border-b border-line pb-3 break-all font-mono text-ink-2 sm:pt-3`,children:r.data?.path??`Not available`}),(0,h.jsx)(`dt`,{className:`pt-3 font-semibold text-ink sm:border-b sm:border-line sm:pb-3`,children:`Verified`}),(0,h.jsx)(`dd`,{className:`m-0 border-b border-line pb-3 text-ink-2 sm:pt-3`,children:r.data?.updatedAt??`date unavailable`}),(0,h.jsx)(`dt`,{className:`pt-3 font-semibold text-ink sm:border-b sm:border-line sm:pb-3`,children:`Last checked`}),(0,h.jsx)(`dd`,{className:`m-0 border-b border-line pb-3 text-ink-2 sm:pt-3`,children:d?.checkedAt?`${new Date(d.checkedAt).toLocaleString()} · ${Z7(d.changes)}`:`Not checked yet`})]}),d!==void 0&&d.changes.retired.length+d.changes.added.length>0?(0,h.jsxs)(`div`,{className:`mt-3 flex flex-col gap-1 text-small text-ink-2`,children:[d.changes.added.length>0?(0,h.jsxs)(`span`,{children:[`New: `,d.changes.added.map(e=>e.name).join(`, `)]}):null,d.changes.retired.length>0?(0,h.jsxs)(`span`,{children:[`Retired: `,d.changes.retired.map(e=>e.name).join(`, `)]}):null]}):null,m===null?null:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 mt-3 text-body text-danger`,children:m})]}),(0,h.jsxs)(`section`,{"aria-label":`Retired models in use`,children:[(0,h.jsx)(V,{title:`Retired models in use`,info:`settings.models.retired`,children:(0,h.jsx)(L,{variant:`primary`,disabled:u.isPending||p.length===0,onClick:()=>u.mutate(),children:u.isPending?`Switching…`:`Switch all`})}),i.error?(0,h.jsx)(`p`,{role:`alert`,className:`m-0 mb-2 text-body text-danger`,children:i.error.message}):null,l.error?(0,h.jsx)(`p`,{role:`alert`,className:`m-0 mb-2 text-body text-danger`,children:l.error.message}):null,f.length===0?(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:i.isPending?`Looking…`:`Nothing uses a retired model.`}):(0,h.jsx)(`ul`,{"aria-label":`Retired models in use`,className:`sl-list m-0 list-none p-0`,children:f.map(e=>(0,h.jsxs)(`li`,{className:`sl-row max-sm:grid-cols-1`,children:[(0,h.jsxs)(`div`,{className:`min-w-0`,children:[(0,h.jsxs)(`p`,{className:`m-0`,children:[(0,h.jsx)(`span`,{className:`sl-kicker`,children:abe[e.kind]}),` `,(0,h.jsx)(`span`,{className:`font-semibold`,children:e.name})]}),(0,h.jsxs)(`p`,{className:`m-0 text-small text-ink-2`,children:[D0[e.slot],`: `,e.model,` (`,e.why===`retired`?`retired`:`no longer listed`,`)`]}),e.blocked===null?null:(0,h.jsx)(`p`,{className:`m-0 text-small text-waiting`,children:e.blocked})]}),(0,h.jsx)(Ty,{children:(0,h.jsx)(L,{size:`small`,disabled:e.blocked!==null||e.replacement===null||l.isPending,onClick:()=>l.mutate(e),children:e.replacement===null?`No replacement`:`Switch to ${e.replacement.name}`})})]},e.key))})]})]})}var sbe={added:[],retired:[],priced:[]},cbe={ok:`Ready`,warning:`Check`,problem:`Needs fixing`,unused:`Not set up`},lbe={ok:`done`,warning:`waiting`,problem:`failed`,unused:`off`},ube={ok:`text-ink-2`,warning:`text-waiting`,problem:`text-danger`,skipped:`text-ink-3`};function Q7(){let{api:e}=R();return N({mutationFn:()=>u0(e)})}function dbe(e){let{api:t}=R(),[n,r]=(0,m.useState)({byId:new Map});return{one:N({mutationFn:e=>u0(t,e),onSuccess:t=>{r(n=>{let r=new Map(n.after===e?n.byId:[]);for(let e of t.providers)r.set(e.id,e);return{after:e,byId:r}})}}),latest:t=>n.after===e?n.byId.get(t.id)??t:t}}function fbe({run:e}={}){let t=Q7(),n=e??t,r=n.data,i=dbe(r?.checkedAt),a=r?.providers.filter(e=>e.state!==`unused`).map(i.latest)??[],o=r?.providers.filter(e=>e.state===`unused`)??[];return(0,h.jsxs)(`section`,{"aria-label":`Health check`,children:[(0,h.jsx)(V,{title:`Health check`,info:`settings.health`,children:e===void 0?(0,h.jsx)(L,{disabled:n.isPending,onClick:()=>{n.mutate()},children:n.isPending?`Checking…`:`Check all`}):void 0}),n.error===null?null:(0,h.jsxs)(`p`,{role:`alert`,className:`m-0 mb-2 text-body text-danger`,children:[`The health check didn't finish: `,n.error.message,` Press Check all to try again.`]}),i.one.error===null?null:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 mb-2 text-body text-danger`,children:`The check didn't finish: ${i.one.error.message} Press Check again on the provider to try again.`}),r===void 0?(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:n.isPending?`Checking every provider…`:`Not checked yet.`}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`ul`,{"aria-label":`Health by provider`,className:`sl-list m-0 list-none p-0`,children:a.map(e=>(0,h.jsxs)(`li`,{className:`sl-row grid-cols-1 gap-1`,children:[(0,h.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center justify-between gap-2`,children:[(0,h.jsx)(`span`,{className:`sl-row__title`,children:e.displayName}),(0,h.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,h.jsx)(mS,{tone:lbe[e.state],children:cbe[e.state]}),(0,h.jsx)(L,{variant:`quiet`,size:`small`,"aria-label":`Check ${e.displayName} again`,disabled:i.one.isPending,onClick:()=>{i.one.mutate(e.id)},children:i.one.isPending&&i.one.variables===e.id?`Checking…`:`Check again`})]})]}),(0,h.jsx)(`ul`,{className:`m-0 list-none space-y-1 p-0`,children:e.checks.map(e=>(0,h.jsxs)(`li`,{className:I(`text-small`,ube[e.state]),children:[(0,h.jsxs)(`span`,{className:`font-semibold`,children:[e.label,`:`]}),` `,e.detail]},e.label))})]},e.id))}),(0,h.jsx)(`p`,{className:`m-0 mt-3 text-small text-ink-2`,children:o.length===0?`Checked at ${new Date(r.checkedAt).toLocaleTimeString()}.`:`Not set up and not used anywhere: ${o.map(e=>e.displayName).join(`, `)}.`})]})]})}var $7={openrouter:`settings.provider.openrouter`,"claude-code":`settings.provider.claude-code`,codex:`settings.provider.codex`,gemini:`settings.provider.gemini`,elevenlabs:`settings.provider.elevenlabs`,"openai-tts":`settings.provider.openai-tts`,cartesia:`settings.provider.cartesia`,inworld:`settings.provider.inworld`,"system-voice":`settings.provider.system-voice`,"google-tts":`settings.provider.google-tts`,fal:`settings.provider.fal`,replicate:`settings.provider.replicate`,"openai-image":`settings.provider.openai-image`,"google-image":`settings.provider.google-image`,"codex-image":`settings.provider.codex-image`};function e9(e){return JP(e)?{tone:`done`,word:`Ready`}:e.installed?{tone:`waiting`,word:`Needs attention`}:{tone:`off`,word:`Not found`}}function pbe({provider:e,readiness:t,kind:n}){let{api:r}=R(),i=_(),a=(0,m.useId)(),[o,s]=(0,m.useState)(void 0),[c,l]=(0,m.useState)(!1),u=e.cliPath?.configured??null,d=e.cliPath?.managedOnHost===!0,f=e.id===`claude-code`?`claude`:e.id===`codex-image`?`codex`:e.id,p=e.cliPath?.command??f,g=o??u??``,v=JP(t),y=N({mutationFn:t=>Ko(r,e.id,t),onMutate:()=>l(!1),onSuccess:async e=>{i.setQueryData(z.providers,t=>t?{...t,providers:t.providers.map(t=>t.id===e.id?e:t)}:void 0),s(void 0),l(!0),await i.invalidateQueries({queryKey:z.providers})}});(0,m.useEffect)(()=>{if(!c)return;let e=setTimeout(()=>l(!1),f4);return()=>clearTimeout(e)},[c]);let[b,x]=(0,m.useState)(!1),S=(0,m.useId)();return(0,h.jsxs)(`section`,{"aria-labelledby":a,"data-ready":v,className:`flex min-w-0 flex-col gap-5`,children:[(0,h.jsxs)(`div`,{children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,h.jsx)(`h3`,{id:a,className:`sl-section-head__title`,children:e.displayName}),(0,h.jsx)(B,{id:$7[e.id],label:e.displayName})]}),(0,h.jsxs)(`p`,{className:`sl-section-head__meta`,children:[n,` · command line, no key needed`]})]}),(0,h.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,h.jsxs)(`p`,{className:`m-0 flex min-w-0 items-center gap-2`,"aria-live":`polite`,children:[(0,h.jsx)(pS,{tone:e9(t).tone}),(0,h.jsx)(`span`,{className:`min-w-0 break-words`,children:mbe(t,u)})]}),(0,h.jsxs)(`p`,{className:`m-0 flex min-w-0 items-center gap-2 text-small text-ink-2`,children:[(0,h.jsx)(`span`,{children:`Command`}),(0,h.jsx)(jV,{className:`min-w-0 truncate`,title:p,children:p})]})]}),(0,h.jsxs)(Ty,{children:[d?(0,h.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-small text-ink-2`,children:[`Managed on host`,(0,h.jsx)(B,{id:`settings.cli.managed-on-host`})]}):(0,h.jsx)(L,{"aria-expanded":b,"aria-controls":S,onClick:()=>x(e=>!e),children:b?`Close path`:`Change path`}),(0,h.jsx)(`span`,{className:`inline-flex w-[52px]`,children:c?(0,h.jsx)(m4,{}):null})]}),d||!b?null:(0,h.jsx)(`form`,{id:S,onSubmit:e=>{e.preventDefault(),y.isPending||y.mutate(g)},children:(0,h.jsx)(Y,{label:`Executable path`,tip:`settings.cli.path`,help:(0,h.jsxs)(h.Fragment,{children:[`Leave blank to find `,(0,h.jsx)(jV,{children:f}),` on PATH. Use an absolute path without quotes or arguments.`]}),error:y.error?.message,children:(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,h.jsx)(OV,{autoComplete:`off`,spellCheck:!1,maxLength:4096,"aria-label":`${e.displayName} Executable path`,className:`min-w-0 flex-1 basis-[220px]`,placeholder:f,value:g,disabled:y.isPending,onChange:e=>{s(e.target.value),l(!1),y.reset()}}),(0,h.jsx)(L,{type:`submit`,variant:`primary`,"aria-label":`Save ${e.displayName} path`,disabled:y.isPending,children:y.isPending?`Checking…`:`Save path`})]})})})]})}function mbe(e,t){return e.issue===void 0?e.installed?e.version===void 0?`Installed`:`Installed, version ${e.version}`:t===null?`Not found on PATH`:`Not found at saved path`:e.issue}var hbe=[`providers`,`system-voice`,`voices`];async function gbe(e){return P(await e.fetch(`${e.origin}/api/providers/system-voice/voices`))}function t9(e=!0){let{api:t}=R();return M({queryKey:hbe,queryFn:()=>gbe(t),enabled:e})}function n9(e){return e.available?{tone:`done`,word:`Ready`}:{tone:`off`,word:`Not found`}}function _be({provider:e,readiness:t}){let n=(0,m.useId)(),r=t9(t.available).data?.engines??[];return(0,h.jsxs)(`section`,{"aria-labelledby":n,"data-ready":t.available,className:`flex min-w-0 flex-col gap-5`,children:[(0,h.jsxs)(`div`,{children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,h.jsx)(`h3`,{id:n,className:`sl-section-head__title`,children:e.displayName}),(0,h.jsx)(B,{id:$7[e.id],label:e.displayName})]}),(0,h.jsx)(`p`,{className:`sl-section-head__meta`,children:`Speech · built into this computer, no key needed`})]}),(0,h.jsxs)(`p`,{className:`m-0 flex min-w-0 items-center gap-2`,"aria-live":`polite`,children:[(0,h.jsx)(pS,{tone:n9(t).tone}),(0,h.jsx)(`span`,{className:`min-w-0 break-words`,children:t.available?`Found ${t.engine??`a speech program`}. Narration with it is free; a keyed voice (ElevenLabs, OpenAI) sounds better.`:t.issue??`No speech program was found on this computer.`})]}),r.length===0?null:(0,h.jsx)(`ul`,{className:`m-0 list-none p-0 text-small text-ink-2`,children:r.map(e=>{let t=e.voices.length;return(0,h.jsx)(`li`,{children:`${e.name}: ${t} voice${t===1?``:`s`}`},e.id)})}),t.available?(0,h.jsx)(Ty,{children:(0,h.jsx)(lS,{to:`/settings`,search:{section:`voices`},children:`Add a system voice`})}):null]})}function vbe({value:e,onPick:t}){let n=t9(),r=n.data?.engines??[];return n.data!==void 0&&r.length===0?(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-small text-danger`,children:n.data.issue??`No speech program was found on this computer.`}):(0,h.jsxs)(AV,{value:e,onChange:e=>{for(let n of r){let r=n.voices.find(t=>t.id===e.target.value);if(r!==void 0)return t(r)}},children:[(0,h.jsx)(`option`,{value:``,children:n.data===void 0?`Looking for voices…`:`Pick a voice`}),r.map(e=>(0,h.jsx)(`optgroup`,{label:e.name,children:e.voices.map(e=>(0,h.jsx)(`option`,{value:e.id,children:e.language===void 0?e.name:`${e.name} (${e.language})`},e.id))},e.id))]})}var r9=[`llm`,`tts`,`image`],i9={llm:`Text`,tts:`Speech`,image:`Images`},ybe=`••••••••••••`;function bbe(e){return JP(e.readiness)}function xbe(e){return e.readiness.kind===`cli`?e9(e.readiness):e.readiness.kind===`local`?n9(e.readiness):e.readiness.hasKey?{tone:`done`,word:`Key saved`}:{tone:`off`,word:`No key`}}function Sbe(){let{api:e}=R(),t=M(Zy(e)),[n,r]=(0,m.useState)(void 0),i=(0,m.useRef)(null),a=(0,m.useRef)(!1);(0,m.useEffect)(()=>{n!==void 0&&a.current&&(a.current=!1,typeof window.matchMedia==`function`&&window.matchMedia(`(max-width: 1023px)`).matches&&i.current?.scrollIntoView?.({block:`start`,behavior:`smooth`}))},[n]);let o=r9.flatMap(e=>(t.data?.providers??[]).filter(t=>t.family===e)),s=o.find(e=>!bbe(e))??o[0];if(n===void 0&&s!==void 0&&r(s.id),t.error!==null)return(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-body text-danger`,children:t.error.message});if(t.data===void 0)return(0,h.jsx)(wbe,{});let c=o.find(e=>e.id===n)??s,l=o.every(e=>e.readiness.kind!==`keyed`||!e.readiness.hasKey),u=e=>{a.current=!0,r(e)};return(0,h.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-8`,children:[l?(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:`Paste a key to make its provider selectable on Play.`}):null,r9.map(e=>(0,h.jsxs)(`section`,{"data-tour":`keys-${e}`,"aria-labelledby":`keys-${e}-title`,className:`grid items-start gap-x-8 gap-y-6 lg:grid-cols-[minmax(0,1fr)_minmax(0,1fr)]`,children:[(0,h.jsxs)(`div`,{className:`min-w-0`,children:[(0,h.jsx)(V,{id:`keys-${e}-title`,title:i9[e],size:`small`,className:`pb-2`}),(0,h.jsx)(hU,{label:`${i9[e]} providers`,children:o.filter(t=>t.family===e).map(e=>{let t=xbe(e);return(0,h.jsx)(gU,{title:e.displayName,meta:e.readiness.kind===`cli`?`Command line`:e.readiness.kind===`local`?`Built in, no key`:`API key`,selected:e.id===c?.id,onSelect:()=>u(e.id),actions:(0,h.jsx)(mS,{tone:t.tone,children:t.word})},e.id)})})]}),c===void 0||c.family!==e?null:(0,h.jsx)(`div`,{ref:i,className:`min-w-0 scroll-mt-4`,children:c.readiness.kind===`cli`?(0,h.jsx)(pbe,{provider:c,readiness:c.readiness,kind:i9[c.family]},c.id):c.readiness.kind===`local`?(0,h.jsx)(_be,{provider:c,readiness:c.readiness},c.id):(0,h.jsx)(Cbe,{provider:c,hasKey:c.readiness.hasKey},c.id)})]},e))]})}function Cbe({provider:e,hasKey:t}){let{api:n}=R(),r=_(),i=(0,m.useId)(),a=(0,m.useId)(),[o,s]=(0,m.useState)(``),[c,l]=(0,m.useState)(!1),[u,d]=(0,m.useState)(!1),[f,p]=(0,m.useState)(void 0),[g,v]=(0,m.useState)(!1),[y,b]=(0,m.useState)(!1),[x,S]=(0,m.useState)(void 0),C=(0,m.useId)(),w=jF[e.id],T=o.trim(),E=async()=>{b(!0),S(void 0);try{S(await pue(n,e.id,T===``?void 0:T))}catch(e){p(e instanceof Error?e.message:String(e))}finally{b(!1)}},D=async()=>{l(!0),p(void 0);try{await Go(n,e.id,o),s(``),d(!0),S(void 0),await r.invalidateQueries({queryKey:z.providers})}catch(e){p(e instanceof Error?e.message:String(e))}finally{l(!1)}},O=N({mutationFn:()=>qo(n,e.id),onSuccess:async()=>{v(!1),p(void 0),await r.invalidateQueries({queryKey:z.providers})},onError:e=>{v(!1),p(e.message)}});(0,m.useEffect)(()=>{if(!u)return;let e=setTimeout(()=>{d(!1)},f4);return()=>{clearTimeout(e)}},[u]);let k=[t?a:void 0,x===void 0?void 0:C].filter(e=>e!==void 0).join(` `);return(0,h.jsxs)(`section`,{"aria-labelledby":i,"data-ready":t,className:`flex min-w-0 flex-col gap-5`,children:[(0,h.jsx)(V,{as:`h3`,size:`default`,id:i,title:t?e.displayName:`Set up ${e.displayName}`,info:$7[e.id],infoLabel:e.displayName,meta:`${i9[e.family]} · ${t?`a key is saved`:`needs an API key`}`,className:`pb-0`}),w===void 0?null:t?(0,h.jsxs)(`details`,{className:`text-small text-ink-2`,children:[(0,h.jsx)(`summary`,{className:`cursor-pointer`,children:`Where to get a key`}),(0,h.jsx)(`div`,{className:`mt-2 flex flex-col gap-2`,children:(0,h.jsx)(a9,{guide:w})})]}):(0,h.jsx)(`div`,{className:`flex flex-col gap-2 text-small text-ink-2`,children:(0,h.jsx)(a9,{guide:w})}),(0,h.jsx)(Y,{label:`${e.displayName} API key`,tip:`settings.providers.api-key`,help:`Stored on this computer only. Never in backups or exports.`,error:f,children:(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,h.jsx)(OV,{type:`password`,autoComplete:`off`,spellCheck:!1,className:`min-w-0 flex-1 basis-[200px]`,"aria-describedby":k===``?void 0:k,placeholder:t?ybe:`Paste API key`,value:o,onChange:e=>{s(e.target.value)}}),(0,h.jsx)(L,{variant:`primary`,"aria-label":`Save ${e.displayName} key`,disabled:o.trim()===``||c,onClick:()=>{D()},children:`Save`})]})}),t?(0,h.jsx)(`span`,{id:a,className:`sr-only`,children:`A key is stored for this provider.`}):null,x===void 0?null:(0,h.jsx)(`p`,{id:C,role:x.ok?`status`:`alert`,className:I(`m-0 text-small`,x.ok?`text-accent-ink`:`text-danger`),children:x.message}),(0,h.jsxs)(Ty,{children:[(0,h.jsx)(L,{"aria-label":`Test ${e.displayName} key`,disabled:!t&&T===``||y,disabledReason:`Paste a key first.`,onClick:()=>{E()},children:y?`Testing…`:`Test`}),(0,h.jsx)(B,{id:`settings.providers.test-key`,label:`Test`}),(0,h.jsx)(L,{variant:`quiet`,"aria-label":`Remove ${e.displayName} key`,disabled:!t,onClick:()=>{v(!0)},children:`Remove`}),(0,h.jsx)(`span`,{className:`inline-flex w-[52px]`,children:u?(0,h.jsx)(m4,{}):null})]}),(0,h.jsx)(Ay,{open:g,title:`Remove the ${e.displayName} key?`,consequence:`Projects that used this provider cannot retry until a key is saved.`,confirmLabel:`Remove key`,pending:O.isPending,onConfirm:()=>{O.mutate()},onCancel:()=>{v(!1)}})]})}function a9({guide:e}){let t=(e,t)=>(0,h.jsx)(`a`,{href:e,target:`_blank`,rel:`noreferrer`,className:`underline`,children:t});return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`ol`,{className:`m-0 list-decimal space-y-1 pl-5`,children:e.steps.map(e=>(0,h.jsx)(`li`,{children:e},e))}),(0,h.jsxs)(`p`,{className:`m-0`,children:[`Sign up: `,t(e.signUp.url,e.signUp.label),`. Make the key:`,` `,t(e.keyPage.url,e.keyPage.label),`.`,e.billing===void 0?null:(0,h.jsxs)(h.Fragment,{children:[` Credit: `,t(e.billing.url,e.billing.label),`.`]})]}),(0,h.jsx)(`p`,{className:`m-0`,children:e.permissions}),(0,h.jsxs)(`p`,{className:`m-0`,children:[`More in the provider's `,t(e.docs.url,e.docs.label),`. After saving, choose Test.`]})]})}function wbe(){return(0,h.jsxs)(`div`,{className:`grid items-start gap-8 lg:grid-cols-[minmax(0,1fr)_minmax(0,1fr)]`,role:`status`,"aria-label":`Loading providers`,children:[(0,h.jsx)(`div`,{className:`flex flex-col gap-6`,children:[[`llm`,4],[`tts`,5],[`image`,5]].map(([e,t])=>(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`span`,{className:`mb-2 block h-3 w-16 rounded-control bg-raised`}),(0,h.jsx)(`div`,{className:`sl-list`,children:Array.from({length:t},(t,n)=>`${e}-${n}`).map(e=>(0,h.jsxs)(`div`,{className:`sl-row`,children:[(0,h.jsx)(`span`,{className:`h-4 w-32 rounded-control bg-raised`}),(0,h.jsx)(`span`,{className:`h-4 w-20 rounded-control bg-raised`})]},e))})]},e))}),(0,h.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,h.jsx)(`span`,{className:`h-6 w-48 rounded-control bg-raised`}),(0,h.jsx)(`span`,{className:`h-10 rounded-control bg-raised`})]})]})}function o9(e){return e.split(/[\s,;]+/).map(e=>e.trim().toLowerCase()).filter(e=>e!==``)}function Tbe(e){return e.languages===void 0?`Any (not known)`:e.languages.map(e=>YO(e).code===e?YO(e).name:e).join(`, `)}function Ebe({voice:e}){let{api:t}=R(),n=_(),r=(0,m.useId)(),[i,a]=(0,m.useState)(!1),[o,s]=(0,m.useState)((e.languages??[]).join(`, `)),[c,l]=(0,m.useState)(void 0),u=N({mutationFn:()=>ds(t,e.id,o9(o)),onSuccess:async e=>{if(e!==void 0){l(e.message);return}a(!1),l(void 0),await n.invalidateQueries({queryKey:z.voices})}});return i?(0,h.jsxs)(`div`,{className:`grid gap-1`,children:[(0,h.jsx)(OV,{id:r,"aria-label":`Languages of ${e.name}`,value:o,placeholder:`es, de`,"aria-invalid":c!==void 0,onChange:e=>{s(e.target.value),l(void 0)}}),c===void 0?null:(0,h.jsx)(`p`,{className:`m-0 text-small text-danger`,children:c}),u.error===null?null:(0,h.jsx)(`p`,{className:`m-0 text-small text-danger`,children:u.error.message}),(0,h.jsxs)(`div`,{className:`flex gap-2`,children:[(0,h.jsx)(L,{size:`small`,disabled:u.isPending,onClick:()=>u.mutate(),children:`Save`}),(0,h.jsx)(L,{variant:`quiet`,size:`small`,onClick:()=>{a(!1),l(void 0),s((e.languages??[]).join(`, `))},children:`Cancel`})]})]}):(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,h.jsx)(`span`,{className:`text-ink-2`,children:Tbe(e)}),(0,h.jsx)(L,{variant:`quiet`,size:`small`,"aria-label":`Edit the languages of ${e.name}`,onClick:()=>a(!0),children:`Edit`})]})}function Dbe(){let{api:e}=R(),t=_(),n=M(Qy(e)),r=M(Zy(e)),[i,a]=(0,m.useState)(void 0),o=N({mutationFn:t=>ps(e,t),onSettled:async()=>{a(void 0),await t.invalidateQueries({queryKey:z.voices})}}),s=N({mutationFn:({id:t,on:n})=>fs(e,t,n),onSettled:async()=>{await t.invalidateQueries({queryKey:z.voices})}}),c=(r.data?.providers??[]).filter(e=>e.family===`tts`);if(n.error!==null)return(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-body text-danger`,children:n.error.message});let l=n.data?.voices;return(0,h.jsxs)(`div`,{"data-tour":`voices`,className:`flex min-w-0 flex-col gap-10`,children:[(0,h.jsxs)(`div`,{className:`min-w-0 overflow-x-auto`,children:[(0,h.jsxs)(`table`,{className:`sl-table min-w-[640px] table-fixed`,...Tb,children:[(0,h.jsx)(`caption`,{className:`sr-only`,children:`Voices`}),(0,h.jsx)(`thead`,{children:(0,h.jsxs)(`tr`,{children:[(0,h.jsx)(`th`,{scope:`col`,className:`w-[22%] pr-4`,children:`Name`}),(0,h.jsx)(`th`,{scope:`col`,className:`w-[18%] pr-4`,children:`Provider`}),(0,h.jsx)(`th`,{scope:`col`,className:`pr-4`,children:`Voice ID`}),(0,h.jsx)(`th`,{scope:`col`,className:`w-[22%] pr-4`,children:(0,h.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[`Languages`,(0,h.jsx)(B,{id:`play.voices.languages`,className:`-my-1`})]})}),(0,h.jsx)(`th`,{scope:`col`,className:`w-[20%] pr-4`,children:(0,h.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[`Real person`,(0,h.jsx)(B,{id:`play.voices.real-person`,className:`-my-1`})]})}),(0,h.jsx)(`th`,{scope:`col`,className:`w-[96px]`,children:(0,h.jsx)(`span`,{className:`sr-only`,children:`Remove`})})]})}),(0,h.jsx)(`tbody`,{children:l===void 0?(0,h.jsx)(`tr`,{children:(0,h.jsx)(`td`,{colSpan:6,children:(0,h.jsx)(`span`,{className:`block h-4 w-64 rounded-control bg-raised`})})}):l.length===0?(0,h.jsx)(`tr`,{children:(0,h.jsx)(`td`,{colSpan:6,className:`text-ink-2`,children:`Add a voice ID from your text-to-speech provider. Audio needs one to narrate.`})}):l.map(e=>(0,h.jsxs)(`tr`,{children:[(0,h.jsx)(`td`,{className:`truncate pr-4 font-semibold`,children:e.name}),(0,h.jsx)(`td`,{className:`truncate pr-4 text-ink-2`,children:kbe(c,e.provider)}),(0,h.jsx)(`td`,{className:`truncate pr-4 text-ink-2`,children:e.voiceId}),(0,h.jsx)(`td`,{className:`pr-4`,children:(0,h.jsx)(Ebe,{voice:e})}),(0,h.jsx)(`td`,{className:`pr-4`,children:(0,h.jsx)(Eb,{checked:s.isPending&&s.variables.id===e.id?s.variables.on:e.imitatesRealPerson===!0,disabled:s.isPending,onChange:t=>s.mutate({id:e.id,on:t}),label:(0,h.jsx)(`span`,{className:`sr-only`,children:`${e.name} imitates a real person`}),className:`text-small`})}),(0,h.jsx)(`td`,{className:`text-right`,children:(0,h.jsx)(L,{variant:`quiet`,size:`small`,"aria-label":`Remove ${e.name}`,onClick:()=>{a(e)},children:`Remove`})})]},e.id))})]}),s.error===null?null:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 mt-2 text-small text-danger`,children:`Couldn't change Real person: ${s.error.message} Press the switch again.`}),o.error===null?null:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 mt-2 text-small text-danger`,children:o.error.message})]}),(0,h.jsxs)(`div`,{children:[(0,h.jsx)(V,{title:`Add a voice`}),(0,h.jsx)(Obe,{tts:c})]}),(0,h.jsx)(Ay,{open:i!==void 0,title:i===void 0?``:`Remove ${i.name}?`,consequence:`Projects that used this voice keep the audio they made with it.`,confirmLabel:`Remove voice`,pending:o.isPending,onConfirm:()=>{i!==void 0&&o.mutate(i.id)},onCancel:()=>{a(void 0)}})]})}function Obe({tts:e}){let{api:t}=R(),n=_(),[r,i]=(0,m.useState)(``),[a,o]=(0,m.useState)(``),[s,c]=(0,m.useState)(``),[l,u]=(0,m.useState)(void 0),[d,f]=(0,m.useState)(void 0),p=l??e[0]?.id,g=N({mutationFn:e=>us(t,e),onSuccess:async e=>{if(!e.ok){f(e.refusal);return}i(``),o(``),c(``),f(void 0),await n.invalidateQueries({queryKey:z.voices})}}),v=(e,t)=>{t(),d?.field===e&&f(void 0)},y=e=>d?.field===e?d.message:void 0;return(0,h.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,h.jsxs)(`div`,{className:`grid items-start gap-4 md:grid-cols-[minmax(0,1fr)_minmax(0,1fr)_minmax(0,1fr)_minmax(0,1fr)_auto]`,children:[(0,h.jsx)(Y,{label:`Voice name`,tip:`play.voices.name`,error:y(`name`),children:(0,h.jsx)(OV,{value:r,onChange:e=>{let t=e.target.value;v(`name`,()=>{i(t)})}})}),(0,h.jsx)(Y,{label:`Provider`,tip:`play.voices.provider`,error:y(`provider`),children:(0,h.jsxs)(AV,{value:p??``,onChange:t=>{let n=e.find(e=>e.id===t.target.value);n!==void 0&&v(`provider`,()=>{u(n.id)})},children:[e.length===0?(0,h.jsx)(`option`,{value:``,children:`No speech provider`}):null,e.map(e=>(0,h.jsx)(`option`,{value:e.id,children:e.displayName},e.id))]})}),(0,h.jsx)(Y,{label:`Voice ID`,tip:`play.voices.voice-id`,error:y(`voiceId`),...p===`inworld`?{help:`Use an Inworld voice ID, such as Dennis, or one from your workspace.`}:{},children:p===`system-voice`?(0,h.jsx)(vbe,{value:a,onPick:e=>{v(`voiceId`,()=>{o(e.id)}),r.trim()===``&&i(e.name);let t=/^([a-z]{2,3})(?:[-_]|$)/i.exec(e.language??``)?.[1];s.trim()===``&&t!==void 0&&c(t.toLowerCase())}}):p===`google-tts`?(0,h.jsx)(AV,{value:a,options:[{value:``,label:`Pick a Gemini voice`},...NF.map(e=>({value:e.name,label:`${e.name} (${e.style})`}))],onChange:e=>{let t=e.target.value;v(`voiceId`,()=>{o(t),r.trim()===``&&i(t)})}}):(0,h.jsx)(OV,{className:`tabular-nums`,value:a,onChange:e=>{let t=e.target.value;v(`voiceId`,()=>{o(t)})}})}),(0,h.jsx)(Y,{label:`Languages`,tip:`play.voices.languages`,help:`Codes such as es, de.`,error:y(`languages`),children:(0,h.jsx)(OV,{value:s,placeholder:`es, de`,onChange:e=>{let t=e.target.value;v(`languages`,()=>{c(t)})}})}),(0,h.jsx)(L,{variant:`primary`,className:`md:mt-6`,disabled:p===void 0||d!==void 0||g.isPending,onClick:()=>{if(p!==void 0){let e=o9(s);g.mutate({provider:p,name:r,voiceId:a,...e.length===0?{}:{languages:e}})}},children:`Add voice`})]}),g.error===null?null:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-small text-danger`,children:g.error.message})]})}function kbe(e,t){return e.find(e=>e.id===t)?.displayName??t}var s9=[`settings`,`notifications`],Abe=`The test notification couldn't be shown: this browser only allows notifications from installed apps. Set a Notification URL below instead.`;function jbe(){return(0,h.jsxs)(`div`,{children:[(0,h.jsx)(V,{title:`Browser and phone`,info:`settings.notifications`}),(0,h.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[(0,h.jsx)(Mbe,{}),(0,h.jsx)(Nbe,{})]})]})}function Mbe(){let e=(0,m.useSyncExternalStore)(CP,xP,()=>!1),[t,n]=(0,m.useState)(bP),[r,i]=(0,m.useState)(void 0),[a,o]=(0,m.useState)(!1),s=Dy(),c=e&&t===`granted`;async function l(e){if(i(void 0),!e){SP(!1);return}o(!0);try{let e=await EP();n(e);let t=TP(e);e===`granted`?(SP(!0),xP()||i(`Browser notifications couldn't be turned on because this browser blocks site storage for Slopify. Allow site data for this address in your browser's settings, then turn Browser notifications on again.`)):i(t??`Browser notifications weren't turned on because the permission prompt was dismissed. Turn Browser notifications on again and choose Allow.`)}finally{o(!1)}}return(0,h.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-6 gap-y-2`,children:[(0,h.jsx)(Eb,{label:`Browser notifications`,tip:`settings.notifications.browser`,checked:c,disabled:a,onChange:e=>void l(e)}),(0,h.jsx)(L,{variant:`quiet`,disabled:!c,disabledReason:`Turn Browser notifications on first.`,onClick:()=>{i(void 0);try{OP({projectId:`test`,text:LP},()=>{}),s(`Test notification sent to this browser.`,`success`)}catch{i(Abe)}},children:`Send test notification`})]}),(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:`Works while any Slopify tab is open.`}),r===void 0?null:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-small text-danger`,children:r})]})}function Nbe(){let{api:e}=R(),t=_(),n=Dy(),r=(0,m.useId)(),i=M({queryKey:s9,queryFn:()=>Xo(e)}),[a,o]=(0,m.useState)(void 0),s=a??i.data?.url??``,c=zP(s),l=N({mutationFn:t=>Qo(e,t),onSuccess:e=>{t.setQueryData(s9,e),o(void 0),n(e.url===null?`Notification URL removed.`:`Notification URL saved.`,`success`)}}),u=N({mutationFn:t=>$o(e,t),onSuccess:()=>{n(`Test notification sent. Check the app or page behind your Notification URL.`,`success`)}}),d=c??l.error?.message??u.error?.message,f=l.isPending||u.isPending||i.data===void 0;return(0,h.jsxs)(Y,{label:`Notification URL`,tip:`settings.notifications.url`,help:`Works with no tab open, for example an ntfy topic on your phone.`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,h.jsx)(OV,{type:`url`,inputMode:`url`,autoComplete:`off`,spellCheck:!1,placeholder:`https://ntfy.sh/your-topic`,className:`min-w-0 flex-1 basis-[220px]`,value:s,disabled:i.data===void 0,"aria-invalid":c!==void 0,"aria-describedby":d===void 0?void 0:r,onChange:e=>{l.reset(),u.reset(),o(e.target.value)}}),(0,h.jsx)(L,{variant:`primary`,disabled:f||c!==void 0||a===void 0,onClick:()=>l.mutate(s),children:`Save`}),(0,h.jsx)(L,{variant:`quiet`,disabled:f||c!==void 0||s.trim()===``,onClick:()=>u.mutate(s),children:`Send test notification`})]}),i.error===null?null:(0,h.jsxs)(`p`,{role:`alert`,className:`m-0 text-small text-danger`,children:[`The saved Notification URL couldn't be read: `,i.error.message]}),d===void 0?null:(0,h.jsx)(`p`,{id:r,role:`alert`,className:`m-0 text-small text-danger`,children:d})]})}var c9={library:`The Library of Alexandria`,audiobook:`The Wind in the Willows (audiobook)`,podcast:`The Antikythera Mechanism (podcast)`};function Pbe(){let{api:e}=R(),t=_(),n=M({queryKey:My,queryFn:()=>By(e)}),r=N({mutationFn:()=>Hy(e),onSettled:async()=>{await t.invalidateQueries({queryKey:My}),await t.invalidateQueries({queryKey:jy}),await t.invalidateQueries({queryKey:z.projects})}}),i=r.data?.samples??n.data?.samples;return(0,h.jsxs)(`div`,{className:`mt-8`,children:[(0,h.jsx)(V,{title:`Sample projects`,info:`settings.sample.restore`}),(0,h.jsx)(hU,{label:`Sample projects`,children:Object.keys(c9).map(e=>{let t=i?.[e]??null;return(0,h.jsx)(gU,{title:c9[e],meta:t===null?`Not in your projects`:`In your projects`,actions:t===null?void 0:(0,h.jsx)(uS,{to:`/projects/$projectId`,params:{projectId:t},className:mU,children:`Open`})},e)})}),(0,h.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-3`,children:[(0,h.jsx)(L,{disabled:r.isPending,onClick:()=>r.mutate(),children:r.isPending?`Restoring…`:`Restore samples`}),(0,h.jsx)(`span`,{className:`text-small text-ink-2`,children:`Puts all three back as they shipped.`})]}),(0,h.jsx)(v0,{tone:r.error?`error`:`success`,children:r.error?.message??(r.isSuccess?`The samples are back in Projects.`:void 0)})]})}var Fbe=[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`];function Ibe(e){let[t,n,r]=e.split(`-`).map(Number),i=Fbe[(n??0)-1];return i===void 0||r===void 0?e:`${String(r)} ${i} ${String(t)}`}function l9(e,t){let n=[e.range===void 0?e.version:`Versions ${e.range}`,`released ${Ibe(e.date)}`].filter(e=>e!==void 0).join(`, `),r=n.charAt(0).toUpperCase()+n.slice(1);return e.version===t?`${r}. The version you are running.`:`${r}.`}function Lbe({note:e,onNote:t}){let{api:n}=R(),r=M(nI(n));if(r.error!==null)return(0,h.jsx)(fI,{tone:`danger`,title:`The patch notes did not load`,actions:(0,h.jsx)(L,{onClick:()=>void r.refetch(),children:`Try again`}),children:`${r.error.message} Press Try again, or reload the page.`});if(r.data===void 0)return(0,h.jsx)(`p`,{className:`m-0 text-ink-3`,children:`Loading the patch notes…`});let{notes:i,version:a}=r.data,[o,...s]=i;if(o===void 0)return(0,h.jsx)(`p`,{className:`m-0 text-ink-2`,children:`This version of Slopify has no patch notes.`});let c=e===void 0?void 0:i.find(t=>t.id===e),l=c!==void 0&&c.id!==o.id?c:void 0;return l===void 0?(0,h.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[e!==void 0&&c===void 0?(0,h.jsx)(`p`,{role:`status`,className:`m-0 text-small text-ink-2`,children:`There are no patch notes called "${e}" in this version. The latest are below; older ones are under Earlier versions.`}):null,(0,h.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,h.jsx)(V,{title:`Latest version`,meta:l9(o,a),info:`settings.patch-notes`}),(0,h.jsx)(DB,{id:o.id})]}),s.length===0?null:(0,h.jsxs)(`details`,{className:`max-w-prose border-t border-line py-3`,children:[(0,h.jsx)(`summary`,{className:`cursor-pointer font-semibold`,children:`Earlier versions (${String(s.length)})`}),(0,h.jsx)(hU,{label:`Earlier versions`,className:`mt-2`,children:s.map(e=>(0,h.jsx)(gU,{title:e.title,meta:l9(e,a),onSelect:()=>t(e.id),actions:(0,h.jsx)(L,{"aria-label":`Read ${e.title}`,onClick:()=>t(e.id),children:`Read`})},e.id))})]})]}):(0,h.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,h.jsx)(`div`,{children:(0,h.jsxs)(L,{variant:`quiet`,onClick:()=>t(void 0),children:[(0,h.jsx)(Qs,{"aria-hidden":`true`,strokeWidth:1.75}),`Back to the latest patch notes`]})}),(0,h.jsx)(V,{title:`Earlier version`,meta:l9(l,a)}),(0,h.jsx)(DB,{id:l.id})]})}var u9=[`trash`];async function Rbe(e){return(await P(await e.client.trash.$get())).items}async function zbe(e,t,n){return(await P(await e.client.trash[`:kind`][`:id`].restore.$post({param:{kind:t,id:n}}))).restored}async function Bbe(e,t,n){let r=await e.client.trash[`:kind`][`:id`].$delete({param:{kind:t,id:n}});if(!r.ok)throw await co(r)}var Vbe={project:`Project`,prompt:`Prompt`,entry:`Intro/outro`,template:`Template`,schedule:`Schedule`};function Hbe(e){return e.kind===`entry`&&e.detail!==null?e.detail===`intro`?`Intro`:`Outro`:e.kind===`prompt`&&e.detail!==null?`Prompt · ${e.detail}`:Vbe[e.kind]}function Ube(e){return e<=0?`removed for good today`:e===1?`1 day left`:`${String(e)} days left`}var Wbe=new Intl.DateTimeFormat(void 0,{dateStyle:`medium`}),Gbe={project:[z.projects,[`calendar`]],prompt:[z.prompts],entry:[z.entries],template:[Rq],schedule:[OH,[`calendar`]]};function Kbe(){let{api:e}=R(),t=_(),n=Dy(),r=M({queryKey:u9,queryFn:()=>Rbe(e)}),[i,a]=(0,m.useState)(void 0),o=async e=>{await Promise.all([u9,...Gbe[e.kind]].map(e=>t.invalidateQueries({queryKey:e})))},s=N({mutationFn:t=>zbe(e,t.kind,t.id),onSuccess:async(e,t)=>{await o(t),n(e.renamedFrom===null?`Restored "${e.name}".`:`Restored as "${e.name}": another item is now called "${e.renamedFrom}".`,`success`),e.kind===`schedule`&&n(`The schedule is paused. Press Resume on Schedules to run it again.`,`info`)},onError:e=>n(e.message,`error`)}),c=N({mutationFn:t=>Bbe(e,t.kind,t.id),onSuccess:async(e,t)=>{a(void 0),await o(t),n(`Deleted "${t.name}" for good.`,`success`)},onError:e=>{a(void 0),n(e.message,`error`)}}),l=r.data??[];return(0,h.jsxs)(`div`,{children:[(0,h.jsx)(V,{title:`Trash`,info:`settings.trash`}),r.isPending?(0,h.jsx)(`p`,{className:`text-small text-ink-3`,children:`Loading the trash…`}):r.error?(0,h.jsx)(`p`,{role:`alert`,className:`text-small text-danger`,children:r.error.message}):l.length===0?(0,h.jsx)(T0,{title:`The trash is empty`,children:`Anything you delete stays here for 30 days before it is removed for good.`}):(0,h.jsx)(hU,{label:`Deleted items`,children:l.map(e=>(0,h.jsx)(gU,{title:e.name,meta:`${Hbe(e)} · deleted ${Wbe.format(new Date(e.deletedAt))} · ${Ube(e.daysLeft)}`,actions:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(L,{size:`small`,disabled:s.isPending||c.isPending,disabledReason:`Working on it`,onClick:()=>s.mutate(e),children:`Restore`}),(0,h.jsx)(L,{size:`small`,variant:`destructive`,disabled:s.isPending||c.isPending,disabledReason:`Working on it`,onClick:()=>a(e),children:`Delete now`})]})},`${e.kind}:${e.id}`))}),(0,h.jsx)(Ay,{open:i!==void 0,title:i===void 0?``:`Delete "${i.name}" for good?`,consequence:i?.kind===`project`?`The project and every file it produced are removed from disk. This cannot be undone.`:i?.kind===`schedule`?`The schedule leaves the trash and cannot be restored. Its run history stays on Schedules.`:`It is removed for good. This cannot be undone.`,confirmLabel:`Delete for good`,cancelLabel:`Keep it`,pending:c.isPending,onConfirm:()=>{i!==void 0&&c.mutate(i)},onCancel:()=>{c.isPending||a(void 0)}})]})}var qbe=`https://github.com/GentBajko/slopify`,Jbe=`https://www.patreon.com/cw/GentBajko`,Ybe=`https://buymeacoffee.com/gentbajko`;function Xbe(){return[{href:qbe,label:`GitHub`,detail:`The code, issues and releases.`,glyph:`github`},{href:Jbe,label:`Patreon`,detail:`Monthly support for the project.`,glyph:`patreon`},{href:Ybe,label:`Buy Me a Coffee`,detail:`A one-off thank you.`,glyph:`coffee`},{href:`https://slopify.stream/channel.html`,label:`How I run a channel with it`,detail:`A lore channel run on Slopify, start to finish.`}]}function Zbe({onWhatsNew:e}){return(0,h.jsxs)(`div`,{className:`max-w-prose`,children:[(0,h.jsx)(V,{title:`About`}),(0,h.jsx)(`p`,{className:`m-0 mb-3 text-ink-2`,children:`Slopify is free and open source, and runs on your machine with your own keys. If it saves you time, you can support it here.`}),(0,h.jsxs)(`p`,{className:`m-0 mb-3 flex items-center gap-1 text-small text-ink-2`,children:[`Updates: the circular-arrows button at the foot of the sidebar (at the top on a phone).`,(0,h.jsx)(B,{id:`settings.updates`})]}),e===void 0?null:(0,h.jsxs)(`p`,{className:`m-0 mb-3 flex items-center gap-1`,children:[(0,h.jsx)(L,{onClick:e,children:`What's new in this version`}),(0,h.jsx)(B,{id:`settings.whats-new`})]}),(0,h.jsx)(`p`,{className:`m-0 mb-4 text-small text-ink-2`,children:`Made by Gent Bajko. Apache License 2.0: anyone who redistributes Slopify or builds on it keeps this credit.`}),(0,h.jsx)(`ul`,{"aria-label":`Links`,className:`sl-list m-0 list-none p-0`,children:Xbe().map(e=>(0,h.jsx)(`li`,{className:`sl-row`,children:(0,h.jsxs)(`div`,{className:`sl-row__lead`,children:[e.glyph===void 0?(0,h.jsx)(`span`,{"aria-hidden":`true`,className:`size-[14px] shrink-0`}):(0,h.jsx)(oS,{name:e.glyph,className:`shrink-0 text-ink-2`}),(0,h.jsxs)(`div`,{className:`sl-row__text`,children:[(0,h.jsx)(`a`,{href:e.href,target:`_blank`,rel:`noreferrer`,className:`font-semibold text-ink underline underline-offset-3`,children:e.label}),(0,h.jsx)(`span`,{className:`sl-row__meta`,children:e.detail})]})]})},e.label))})]})}var d9=[`backups`],f9=1,p9=30;function m9(){return Intl.DateTimeFormat().resolvedOptions().timeZone||`UTC`}function Qbe(e){let t=e.trim();return/^\d+$/.test(t)&&Number(t)>=f9&&Number(t)<=p9?void 0:`Keep between ${f9} and ${p9} backups.`}function $be(e){return{enabled:e.config.enabled,time:e.config.time,keep:String(e.config.keep),folder:e.config.folder??``}}function h9(){let{api:e}=R(),t=_(),n=Dy();return N({mutationFn:()=>Eo(e),onSuccess:e=>{t.setQueryData(d9,e),n(`Backup started. Its result shows here when it finishes.`,`success`)}})}function exe(){let{api:e}=R(),t=_(),n=M({queryKey:d9,queryFn:()=>wo(e),refetchInterval:e=>e.state.data?.running===!0&&2e3}),[r,i]=(0,m.useState)(void 0),[a,o]=(0,m.useState)(!1),s=N({mutationFn:t=>To(e,t),onSuccess:e=>{t.setQueryData(d9,e),i(void 0),o(!0)}}),c=h9();(0,m.useEffect)(()=>{if(!a)return;let e=setTimeout(()=>o(!1),f4);return()=>clearTimeout(e)},[a]);let l=n.data,u=r??(l===void 0?void 0:$be(l)),d=u===void 0?void 0:Qbe(u.keep),f=e=>{u!==void 0&&i({...u,...e})};return(0,h.jsxs)(`div`,{children:[(0,h.jsx)(V,{title:`Daily backup`,info:`settings.backups`,children:(0,h.jsx)(L,{variant:`primary`,disabled:l===void 0||l.running||c.isPending,onClick:()=>c.mutate(),children:`Back up now`})}),(0,h.jsxs)(`div`,{className:`mb-6 flex flex-col gap-3`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap justify-between gap-x-4 gap-y-1 text-small text-ink-2`,children:[(0,h.jsx)(`span`,{role:`status`,children:l===void 0?(0,h.jsx)(`span`,{className:`inline-block h-4 w-48 rounded-control bg-raised`}):txe(l)}),(0,h.jsx)(`span`,{children:l===void 0?null:nxe(l)})]}),l?.status.detail?l.status.lastResult===`failed`?(0,h.jsx)(fI,{tone:`danger`,title:`Why the last backup stopped`,children:l.status.detail}):(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:l.status.detail}):null,c.error?(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-small text-danger`,children:c.error.message}):null]}),n.error?(0,h.jsxs)(`p`,{role:`alert`,className:`m-0 text-small text-danger`,children:[`The backup settings couldn't be read: `,n.error.message]}):(0,h.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,h.jsx)(Eb,{label:`Back up automatically`,tip:`settings.backups.auto`,checked:u?.enabled===!0,disabled:u===void 0,className:`self-start`,onChange:e=>f({enabled:e})}),(0,h.jsxs)(`div`,{className:`grid items-start gap-6 md:grid-cols-2`,children:[(0,h.jsx)(Y,{label:`Time of day`,tip:`settings.backups.time`,help:`${m9()} time`,children:(0,h.jsx)(OV,{type:`time`,className:`w-[140px] tabular-nums`,value:u?.time??`03:00`,disabled:u===void 0,onChange:e=>f({time:e.target.value})})}),(0,h.jsx)(Y,{label:`Keep last`,tip:`settings.backups.keep`,help:`Backups kept in the folder.`,error:d,children:(0,h.jsx)(OV,{type:`number`,inputMode:`numeric`,min:f9,max:p9,step:1,className:`w-[88px] tabular-nums`,value:u?.keep??`5`,disabled:u===void 0,onChange:e=>f({keep:e.target.value})})}),(0,h.jsx)(Y,{label:`Folder`,tip:`settings.backups.folder`,className:`md:col-span-2`,...l===void 0?{}:{help:rxe(l)},children:(0,h.jsx)(OV,{value:u?.folder??``,placeholder:l?.defaultFolder??``,disabled:u===void 0,onChange:e=>f({folder:e.target.value})})})]}),(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,h.jsx)(L,{variant:`primary`,disabled:u===void 0||d!==void 0||s.isPending,onClick:()=>{u!==void 0&&(o(!1),s.mutate({enabled:u.enabled,time:u.time,timeZone:m9(),keep:Number(u.keep.trim()),folder:u.folder.trim()===``?null:u.folder.trim()}))},children:`Save`}),(0,h.jsx)(`span`,{className:`inline-flex w-[52px]`,children:a?(0,h.jsx)(m4,{}):null}),s.error===null?null:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 basis-full text-small text-danger`,children:s.error.message})]})]})]})}function g9(e){return new Date(e).toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`})}function txe(e){if(e.running)return`Backing up now…`;let{status:t}=e,n=t.lastSuccessAt===null?`No backup yet.`:`Last backup ${g9(t.lastSuccessAt)}${t.lastSuccessBytes===null?``:`, ${_9(t.lastSuccessBytes)}`}.`;return t.lastResult===`failed`&&t.lastAttemptAt!==null?`${n} The backup at ${g9(t.lastAttemptAt)} failed.`:t.lastResult===`waiting`?`${n} Waiting for projects to finish.`:n}function nxe(e){return e.config.enabled?e.overdue?`Next: shortly.`:e.nextRunAt===null?``:`Next: ${g9(e.nextRunAt)}.`:`Automatic backups are off.`}function rxe(e){let t=`${e.files.length} backup${e.files.length===1?``:`s`} here (${_9(e.files.reduce((e,t)=>e+t.bytes,0))}).`;return e.hostFolder===null?`Inside Slopify's Docker volume, not on your computer. Leave Folder empty to save backups in the Backups folder on your computer. ${t}`:`${e.config.folder===null?`Empty uses the default: `:`On your computer: `}${e.hostFolder}. ${t}`}function _9(e){if(e<1024)return`${e} B`;let t=[`KB`,`MB`,`GB`,`TB`],n=e,r=t[0]??`KB`;for(let e of t)if(n/=1024,r=e,n<1024||e===t.at(-1))break;return`${n>=10?n.toFixed(0):n.toFixed(1).replace(/\.0$/,``)} ${r}`}var v9=[`storage-files`];function ixe({usageQueryKey:e}){let{api:t}=R(),n=_(),r=Dy(),[i,a]=(0,m.useState)(!1),[o,s]=(0,m.useState)(``),[c,l]=(0,m.useState)(),u=M({queryKey:v9,queryFn:()=>No(t),refetchInterval:e=>b9(e.state.data)?1e3:!1}),d=N({mutationFn:e=>Po(t,e),onMutate:()=>l(void 0),onSuccess:e=>{n.setQueryData(v9,e),a(!1)},onError:e=>l(e.message)}),f=N({mutationFn:()=>Fo(t),onSuccess:e=>{e.opened||r(`Your files are in ${e.path}.`,`info`)},onError:e=>r(e.message,`error`)}),p=u.data,g=b9(p),v=p?.move?.phase;if((0,m.useEffect)(()=>{v===`done`&&n.invalidateQueries({queryKey:e})},[v,n,e]),p===void 0)return(0,h.jsx)(`div`,{children:(0,h.jsx)(V,{title:`Your files`,meta:u.error?`Where your files are is unavailable. Reload the page to try again.`:`Loading…`})});if(p.docker)return(0,h.jsxs)(`div`,{children:[(0,h.jsx)(V,{title:`Your files`,meta:p.folder??`The Docker project folder isn't set up.`,info:`settings.files.docker`,children:(0,h.jsx)(L,{disabled:p.folder===null||f.isPending,onClick:()=>f.mutate(),children:`Open folder`})}),(0,h.jsxs)(`div`,{className:`flex flex-col gap-2 text-small text-ink-2`,children:[(0,h.jsx)(y9,{view:p}),p.dockerCommand===null?null:(0,h.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,h.jsxs)(`p`,{className:`m-0`,children:[`To move your projects to Documents/Slopify, run this on the computer running Docker (or use `,(0,h.jsx)(jV,{children:`--projects-dir <folder>`}),` for another folder):`]}),(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,h.jsx)(jV,{className:`min-w-0 break-all`,children:p.dockerCommand}),(0,h.jsx)(L,{variant:`quiet`,size:`small`,onClick:()=>{let e=p.dockerCommand??``;navigator.clipboard.writeText(e).then(()=>r(`Command copied.`,`success`)).catch(()=>r(`Copying failed: this browser doesn't allow it here. Select the command and copy it yourself.`,`error`))},children:`Copy command`})]})]})]})]});let y=v===`failed`||v===`interrupted`;return(0,h.jsxs)(`div`,{children:[(0,h.jsxs)(V,{title:`Your files`,meta:p.folder,info:`settings.files`,children:[p.inDocuments||p.documentsRoot===null?null:(0,h.jsx)(L,{variant:`primary`,disabled:g||d.isPending,onClick:()=>d.mutate(`documents`),children:`Move to Documents/Slopify`}),(0,h.jsx)(L,{disabled:f.isPending,onClick:()=>f.mutate(),children:`Open folder`}),(0,h.jsx)(L,{variant:`quiet`,disabled:g||d.isPending,onClick:()=>{a(e=>!e),l(void 0)},children:`Choose another folder`})]}),(0,h.jsxs)(`div`,{className:`flex flex-col gap-3 text-small text-ink-2`,children:[(0,h.jsx)(y9,{view:p}),i?(0,h.jsxs)(`form`,{className:`flex flex-wrap items-end gap-2`,onSubmit:e=>{e.preventDefault(),d.mutate(o)},children:[(0,h.jsx)(Y,{label:`New folder`,tip:`settings.files.new-folder`,help:`The full path; it must be empty or new.`,error:c,className:`min-w-0 flex-1 basis-80`,children:(0,h.jsx)(OV,{value:o,placeholder:p.documentsRoot??`/home/you/Videos/Slopify`,onChange:e=>s(e.target.value)})}),(0,h.jsx)(L,{type:`submit`,disabled:o.trim()===``||d.isPending,children:`Move here`})]}):c===void 0?null:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-danger`,children:c}),p.move===null?null:g?(0,h.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,h.jsxs)(`p`,{role:`status`,className:`m-0 text-ink tabular-nums`,children:[p.move.phase===`copying`?`Copying`:`Checking the copy of`,` your files to`,` `,p.move.target,`: `,p.move.files,` of `,p.move.totalFiles,` files (`,Q5(p.move.bytes),` of `,Q5(p.move.totalBytes),`). Keep Slopify running until it finishes.`]}),(0,h.jsx)(u4,{label:p.move.phase===`copying`?`Files copied`:`Files checked`,value:p.move.totalBytes===0?0:p.move.bytes/p.move.totalBytes})]}):y?(0,h.jsx)(fI,{tone:v===`failed`?`danger`:`waiting`,title:v===`failed`?`Moving your files to ${p.move.target} stopped`:`Moving your files to ${p.move.target} didn't finish`,actions:(0,h.jsx)(L,{disabled:d.isPending,onClick:()=>d.mutate(p.move?.target??``),children:`Continue moving`}),children:p.move.error??`Slopify was stopped before the copy was checked, so it still uses the old folder. Continue moving picks up where it left off.`}):v===`done`&&p.move.oldFolder!==null?(0,h.jsxs)(fI,{tone:`info`,title:`Your files are now in ${p.move.target}`,children:[`Every file was copied and checked. The old folder `,p.move.oldFolder,` still has a copy; once your projects open fine, you can delete it to free the space.`]}):null]})]})}function y9({view:e}){let t=[[`Projects`,e.projects],[`Automatic backups`,e.backups],[`Exports`,e.exports]].filter(e=>e[1]!==null);return(0,h.jsx)(`dl`,{className:`m-0 grid grid-cols-[auto_minmax(0,1fr)] gap-x-3 gap-y-1`,children:t.map(([e,t])=>(0,h.jsxs)(`div`,{className:`contents`,children:[(0,h.jsx)(`dt`,{className:`text-ink-3`,children:e}),(0,h.jsx)(`dd`,{className:`m-0 break-all`,children:t})]},e))})}function b9(e){return e?.move?.phase===`copying`||e?.move?.phase===`verifying`}function axe(){let{api:e}=R(),t=M(Xy(e));return(0,h.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[t.error===null?null:(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-body text-danger`,children:t.error.message}),t.data===void 0?t.error===null?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(fxe,{cells:5}),(0,h.jsx)(pxe,{})]}):null:(0,h.jsx)(sxe,{usage:t.data})]})}var oxe=[{id:`stage`,header:`Stage`,cell:e=>YP[e.stage]},{id:`model`,header:`Provider · model`,cell:e=>cxe(e)},{id:`in`,header:`Tokens in`,numeric:!0,cell:e=>x9.format(e.tokensIn)},{id:`out`,header:`Tokens out`,numeric:!0,cell:e=>x9.format(e.tokensOut)}];function sxe({usage:e}){let t=Object.values(e.counters).every(e=>e===0);return(0,h.jsxs)(b0,{split:`even`,children:[(0,h.jsxs)(x0,{children:[(0,h.jsxs)(`div`,{children:[(0,h.jsx)(c4,{children:dxe(e).map(e=>(0,h.jsx)(l4,{label:e.label,value:e.value},e.label))}),t?(0,h.jsx)(`p`,{className:`m-0 mt-3 text-body text-ink-2`,children:`Numbers appear after your first run.`}):null]}),(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-3`,children:`Machine ID ${e.machineId??`not made yet`} · Slopify ${e.appVersion}`})]}),(0,h.jsx)(x0,{children:(0,h.jsx)(`div`,{className:`min-w-0 overflow-x-auto`,children:(0,h.jsx)(d4,{caption:`Tokens by stage`,columns:oxe,rows:e.byStage,rowKey:e=>`${e.stage}/${e.provider}/${e.model??``}`,empty:`No stages have run yet.`,className:`min-w-[480px] [&_td]:pr-4 [&_th]:pr-4`})})})]})}function cxe(e){return e.model===null?e.provider:`${e.provider} · ${e.model}`}var x9=new Intl.NumberFormat(void 0,{maximumFractionDigits:0}),lxe=new Intl.NumberFormat(void 0,{maximumFractionDigits:1}),uxe=new Intl.NumberFormat(void 0,{notation:`compact`,maximumFractionDigits:1});function dxe(e){let t=e.counters;return[{label:`Videos made`,value:x9.format(t.videosMade)},{label:`Hours of audio`,value:lxe.format(t.audioSeconds/3600)},{label:`Images made`,value:x9.format(t.imagesMade)},{label:`Tokens used`,value:t.tokensUsed<1e6?x9.format(t.tokensUsed):uxe.format(t.tokensUsed)},{label:`Projects`,value:x9.format(t.projects)}]}function fxe({cells:e}){return(0,h.jsx)(`div`,{className:`sl-stats`,children:Array.from({length:e},(e,t)=>t).map(e=>(0,h.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,h.jsx)(`span`,{className:`h-8 w-20 rounded-control bg-sunken`}),(0,h.jsx)(`span`,{className:`h-3 w-24 rounded-control bg-sunken`})]},e))})}function pxe(){return(0,h.jsx)(`div`,{className:`border-t border-line`,children:[0,1,2,3].map(e=>(0,h.jsxs)(`div`,{className:`flex items-center gap-4 border-b border-line py-3`,children:[(0,h.jsx)(`span`,{className:`h-3 w-24 rounded-control bg-sunken`}),(0,h.jsx)(`span`,{className:`h-3 w-56 max-w-[40%] rounded-control bg-sunken`}),(0,h.jsx)(`span`,{className:`ml-auto h-3 w-20 rounded-control bg-sunken`}),(0,h.jsx)(`span`,{className:`h-3 w-20 rounded-control bg-sunken`})]},e))})}var S9=[`storage-usage`],mxe=[S9,z.projects,[`project`],z.usage,z.documentThemes,OH,[`play-drafts`],z.settings,z.providers,z.voices,z.prompts,z.entries,z.staging,Rq,pN,[`provider-models`]];async function hxe(e){await Promise.all(mxe.map(t=>e.invalidateQueries({queryKey:t})))}var C9=30,gxe=[{value:`system`,label:`System`},{value:`dark`,label:`Dark`},{value:`light`,label:`Light`}];function _xe(e){let t=e.trim();return/^\d+$/.test(t)&&Number(t)>=0&&Number(t)<=C9?void 0:`The silence gap is a whole number of seconds between 0 and ${String(C9)}.`}var w9=[{id:`general`,label:`General`,meta:`How Slopify starts on this computer.`},{id:`providers`,label:`Providers`,meta:`Keys stay on this machine and go only to their provider. Readiness is checked again before each run.`},{id:`voices`,label:`Voices`,meta:`A wrong voice ID shows up when the audio stage uses it.`},{id:`models`,label:`Models`,meta:`New models, prices and retirements, checked once a day.`},{id:`playback`,label:`Playback & appearance`,meta:`How narration is paced and how Slopify looks.`},{id:`notifications`,label:`Notifications`,meta:`When a run finishes, fails, waits for you, or a review needs a decision.`},{id:`channel-links`,label:`Channel links`,meta:`The links a YouTube description's {{Name}} placeholders fill from.`},{id:`studio`,label:`YouTube Studio`,meta:`The playlist upload packs name, and the Studio extension's pairing.`},{id:`storage`,label:`Backup & storage`,meta:`Export everything, import a backup, and see what uses disk space.`},{id:`backups`,label:`Backups`,meta:`A daily copy of everything, in a folder you choose.`},{id:`trash`,label:`Trash`,meta:`Deleted projects, prompts, templates and schedules, kept for 30 days.`},{id:`usage`,label:`Usage`,meta:`This machine only. The same counters, anonymised, feed slopify.stream.`},{id:`patch-notes`,label:`Patch notes`,meta:`What changed in each version of Slopify.`},{id:`about`,label:`About`,meta:`Free and open source, running on your machine with your own keys.`}];function vxe(e){return w9.find(t=>t.id===e)?.id??`providers`}function yxe(e){let t=document.createElement(`a`);t.href=`${e}/api/diagnostics`,t.download=`slopify-diagnostics.json`,document.body.append(t),t.click(),t.remove()}function bxe({section:e=`providers`,note:t,onSection:n=()=>{},onNote:r=()=>{}}){let{api:i}=R(),a=_(),o=Dy(),s=Q7(),c=h9(),l=w9.find(t=>t.id===e)??w9[0];return _x({id:`settings.check-providers`,title:`Check all providers`,group:`Settings`,keywords:[`health`,`keys`,`signed in`],run:()=>{n(`providers`),s.mutate()}}),_x({id:`settings.back-up-now`,title:`Back up now`,group:`Settings`,keywords:[`backup`],run:()=>{n(`backups`),c.mutate(void 0,{onError:e=>{o(`The backup didn't start: ${e.message} Open Settings → Backups to see its state.`,`error`)}})}}),_x({id:`settings.download-diagnostics`,title:`Download diagnostics`,group:`Settings`,keywords:[`support`,`bug report`],run:()=>{yxe(i.origin)}}),(0,h.jsxs)(`div`,{children:[(0,h.jsx)(Aq,{crumb:`Settings`,title:l.label,meta:l.meta,actions:(0,h.jsxs)(h.Fragment,{children:[e===`providers`?(0,h.jsx)(L,{disabled:s.isPending,onClick:()=>s.mutate(),children:s.isPending?`Checking…`:`Check all`}):null,(0,h.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,h.jsxs)(dS,{variant:`secondary`,href:`${i.origin}/api/diagnostics`,download:`slopify-diagnostics.json`,children:[(0,h.jsx)(pc,{"aria-hidden":`true`,strokeWidth:1.75}),`Download diagnostics`]}),(0,h.jsx)(B,{id:`settings.diagnostics`})]})]})}),(0,h.jsx)(jq,{sections:(0,h.jsx)(p8,{label:`Settings sections`,children:w9.map(t=>(0,h.jsx)(m8,{current:t.id===e,onClick:()=>n(t.id),className:`whitespace-nowrap max-md:w-auto`,children:t.label},t.id))}),children:(0,h.jsxs)(`section`,{"aria-label":l.label,className:`flex min-w-0 flex-col gap-10`,children:[e===`providers`?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(t6,{}),(0,h.jsx)(Sbe,{}),(0,h.jsx)(fbe,{run:s})]}):null,e===`general`?(0,h.jsx)(Ib,{}):null,e===`voices`?(0,h.jsx)(Dbe,{}):null,e===`models`?(0,h.jsx)(obe,{}):null,e===`playback`?(0,h.jsx)(wxe,{}):null,e===`notifications`?(0,h.jsx)(jbe,{}):null,e===`channel-links`?(0,h.jsx)(Yde,{}):null,e===`studio`?(0,h.jsx)(Pde,{}):null,e===`storage`?(0,h.jsx)(ixe,{usageQueryKey:S9}):null,e===`storage`?(0,h.jsx)(xxe,{}):null,e===`storage`?(0,h.jsx)(Pbe,{}):null,e===`backups`?(0,h.jsx)(exe,{}):null,e===`trash`?(0,h.jsx)(Kbe,{}):null,e===`usage`?(0,h.jsx)(axe,{}):null,e===`patch-notes`?(0,h.jsx)(Lbe,{note:t,onNote:r}):null,e===`about`?(0,h.jsx)(Zbe,{onWhatsNew:()=>{a.fetchQuery(nI(i)).then(e=>r(e.current??void 0),e=>{o(`The patch notes did not open: ${e instanceof Error?e.message:String(e)} Open Settings → Patch notes to try again.`,`error`)})}}):null]})})]})}var T9=`The backup wasn't imported. Check it is a file made with Export everything (.tar) or Export backup (.zip), then try again.`;function xxe(){let{api:e}=R(),t=_(),n=M({queryKey:S9,queryFn:()=>Mo(e),staleTime:3e4}),[r,i]=(0,m.useState)(!1),[a,o]=(0,m.useState)({phase:`idle`}),[s,c]=(0,m.useState)({phase:`idle`}),[l,u]=(0,m.useState)(null),d=Dy(),[f,p]=(0,m.useState)(null);async function g(){p(null),o({phase:`preparing`});try{let t=await Co(e);if(!t.ready){o({phase:`idle`}),p(t.detail??`The backup can't be made right now. Try again in a moment.`);return}o({phase:`downloading`,bytes:t.bytes??0,projects:t.projects??0});let n=document.createElement(`a`);n.href=`${e.origin}/api/storage/export`,n.download=``,document.body.append(n),n.click(),n.remove()}catch(e){o({phase:`idle`}),p(e instanceof Error?e.message:`The backup couldn't be prepared. Try again in a moment.`)}}async function v(n){let r=n.name.toLowerCase().endsWith(`.zip`)||n.type===`application/zip`;if(n.size===0||r&&n.size>104857600){p(r?`This file is empty or larger than 100 MB. Choose a .zip made with Export backup, or a .tar made with Export everything.`:`This file is empty. Choose the .tar made with Export everything.`);return}i(!0),p(null),u(null),c({phase:`uploading`,sent:0,total:n.size});try{let i=await e.upload(`${e.origin}/api/storage/import`,n,r?`application/zip`:`application/x-tar`,(e,t)=>{c(e>=t?{phase:`importing`}:{phase:`uploading`,sent:e,total:t})}),a=await i.json();if(!i.ok)throw Error(a.detail??T9);a.projects===void 0?d(`Imported ${a.templates??0} template(s), ${a.fonts??0} uploaded font(s), and ${a.stagedFiles??0} staged file(s).${a.fontFallbacks?` ${a.fontFallbacks} missing legacy font reference(s) now use the default font.`:``}`,`success`):(u(a),d(`Backup imported.`,`success`)),await hxe(t)}catch(e){p(e instanceof Error?e.message:T9)}finally{c({phase:`idle`}),i(!1)}}async function y(){i(!0),p(null);try{let n=await e.fetch(`${e.origin}/api/storage/cleanup`,{method:`POST`}),r=await n.json();if(!n.ok)throw Error(`Clean orphan files didn't finish. Try again in a moment.`);d(`Removed ${r.orphanFiles??0} orphan project file(s) and ${r.stagedFiles??0} stale staged file(s).`,`success`),await t.invalidateQueries({queryKey:S9})}catch(e){p(e instanceof Error?e.message:`Clean orphan files didn't finish. Try again in a moment.`)}finally{i(!1)}}_x({id:`settings.export-everything`,title:`Export everything`,group:`Settings`,context:`Backup & storage`,keywords:[`backup`,`download`],run:()=>{!r&&a.phase!==`preparing`&&g()}});let b=r||a.phase===`preparing`,x=(0,m.useRef)(null);return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`div`,{children:[(0,h.jsxs)(V,{title:`Export and import`,info:`settings.storage.export`,children:[(0,h.jsx)(L,{disabled:b,onClick:()=>void g(),children:`Export everything`}),(0,h.jsx)(L,{disabled:b,onClick:()=>x.current?.click(),children:`Import a backup`}),(0,h.jsx)(`input`,{ref:x,className:`sr-only`,type:`file`,tabIndex:-1,"aria-label":`Import a backup`,accept:`.tar,application/x-tar,.zip,application/zip`,disabled:b,onChange:e=>{let t=e.target.files?.[0];t&&v(t),e.target.value=``}}),(0,h.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,h.jsx)(L,{variant:`quiet`,disabled:b,onClick:()=>void y(),children:`Clean orphan files`}),(0,h.jsx)(B,{id:`settings.storage.clean`})]})]}),(0,h.jsxs)(`div`,{className:`flex flex-col gap-2 text-small text-ink-2`,children:[(0,h.jsx)(`p`,{className:`m-0`,children:`Provider keys are never included in a backup. After importing, enter them again in Settings → Providers.`}),a.phase===`preparing`?(0,h.jsx)(`p`,{role:`status`,className:`m-0 text-ink`,children:`Preparing the backup…`}):null,a.phase===`downloading`?(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,h.jsxs)(`p`,{role:`status`,className:`m-0 min-w-0 flex-1 text-ink`,children:[`Downloading `,Q5(a.bytes),` (`,a.projects,` project`,a.projects===1?``:`s`,`). Your browser's downloads show its progress; keep Slopify running until it finishes.`]}),(0,h.jsx)(L,{variant:`quiet`,size:`small`,onClick:()=>o({phase:`idle`}),children:`Dismiss`})]}):null,s.phase===`uploading`?(0,h.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,h.jsxs)(`p`,{role:`status`,className:`m-0 text-ink tabular-nums`,children:[`Uploading the backup: `,Q5(s.sent),` of`,` `,Q5(s.total)]}),(0,h.jsx)(u4,{label:`Backup upload`,value:s.total===0?0:s.sent/s.total})]}):null,s.phase===`importing`?(0,h.jsx)(`p`,{role:`status`,className:`m-0 text-ink`,children:`Checking and importing the backup… large projects can take a minute.`}):null,f?(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-danger`,children:f}):null]})]}),l?(0,h.jsx)(Cxe,{result:l,onDismiss:()=>u(null)}):null,(0,h.jsxs)(`div`,{children:[(0,h.jsx)(V,{title:`Disk space`,info:`settings.storage.disk`,meta:n.data?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`span`,{className:`font-semibold text-ink`,children:[Q5(n.data.data),` stored`]}),(0,h.jsxs)(`span`,{className:`tabular-nums`,children:[` `,`· `,Q5(Math.max(0,n.data.projects-n.data.trash.bytes)),` project files · `,Q5(n.data.staging),` staged files`,n.data.trash.projects>0?` · ${Q5(n.data.trash.bytes)} in the trash (${Sxe(n.data.trash.projects)}), freed when removed for good`:null]})]}):n.error?`Storage usage is unavailable. Reload the page to try again.`:(0,h.jsx)(`span`,{className:`inline-block h-4 w-48 rounded-control bg-raised`})}),n.data&&n.data.byProject.length>0?(0,h.jsx)(U_e,{projects:n.data.byProject,queryKey:[...S9]}):null]})]})}function Sxe(e){return e===1?`1 deleted project`:`${String(e)} deleted projects`}function E9(e,t){if(t===void 0)return null;let n=[t.added>0?`${t.added} added`:null,t.renamed>0?`${t.renamed} added as “(imported)” because the name was taken`:null,t.skipped>0?`${t.skipped} already here`:null].filter(e=>e!==null);return n.length===0?null:`${e}: ${n.join(`, `)}.`}function Cxe({result:e,onDismiss:t}){let n=[e.projects.imported.length>0?`Projects: ${e.projects.imported.length} added (${Q5(e.files.bytes)} of files).`:`Projects: none added.`,E9(`Prompts`,e.prompts),E9(`Intros and outros`,e.entries),E9(`Channels`,e.channels),E9(`Cast members`,e.cast),E9(`Episode memories`,e.episodeMemories),E9(`Existing videos`,e.channelVideos),E9(`Document themes`,e.documentThemes),E9(`Templates`,e.templates),E9(`Schedules`,e.schedules),e.schedules.paused>0?`${e.schedules.paused} schedule(s) arrived paused so two installs never run them both; resume them on the Schedules screen.`:null,E9(`Voices`,e.voices),E9(`Play drafts`,e.drafts),e.settings.added+e.settings.kept>0?`Settings: ${e.settings.added} filled in${e.settings.kept>0?`, ${e.settings.kept} kept as this install has them`:``}.`:null,e.fonts>0?`Uploaded fonts: ${e.fonts} added.`:null,e.usage.alreadyImported?`Usage: this backup's history was already added before, so it wasn't counted twice.`:`Usage: ${e.usage.events} recorded event(s) added to the totals.`,`Provider keys are not in backups: enter them in Settings → Providers.`].filter(e=>e!==null);return(0,h.jsxs)(`div`,{children:[(0,h.jsx)(V,{as:`h3`,title:`Imported the backup from ${e.backup.createdAt.slice(0,10)}`,children:(0,h.jsx)(L,{variant:`quiet`,size:`small`,onClick:t,children:`Dismiss`})}),(0,h.jsxs)(`ul`,{"aria-label":`Import result`,className:`m-0 list-disc pl-5 text-small text-ink-2`,children:[n.map(e=>(0,h.jsx)(`li`,{className:`py-0.5`,children:e},e)),e.projects.skipped.map(e=>(0,h.jsxs)(`li`,{className:`py-0.5`,children:[`Skipped “`,e.title,`”: `,e.reason]},e.id))]})]})}function wxe(){let{api:e}=R(),t=_(),n=M(rb(e)),[r,i]=(0,m.useState)(void 0),[a,o]=(0,m.useState)(!1),s=N({mutationFn:t=>Yo(e,t),onMutate:e=>{let n=t.getQueryData(z.settings);return t.setQueryData(z.settings,e),{previous:n}},onError:(e,n,r)=>{r?.previous!==void 0&&t.setQueryData(z.settings,r.previous)},onSuccess:e=>{t.setQueryData(z.settings,e)}});if((0,m.useEffect)(()=>{if(!a)return;let e=setTimeout(()=>{o(!1)},f4);return()=>{clearTimeout(e)}},[a]),n.error!==null)return(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-body text-danger`,children:n.error.message});if(n.data===void 0)return(0,h.jsxs)(`div`,{className:`grid gap-6 md:grid-cols-2`,role:`status`,"aria-label":`Loading settings`,children:[(0,h.jsx)(`span`,{className:`h-16 rounded-control bg-raised`}),(0,h.jsx)(`span`,{className:`h-16 rounded-control bg-raised`})]});let c=n.data,l=r??String(c.silenceGapSeconds),u=_xe(l);return(0,h.jsxs)(`div`,{className:`grid items-start gap-6 md:grid-cols-2`,children:[(0,h.jsx)(Y,{label:`Silence between segments`,tip:`settings.playback.silence-gap`,help:`Seconds of quiet between narrated segments.`,error:u??s.error?.message,children:(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,h.jsx)(OV,{type:`number`,inputMode:`numeric`,min:0,max:C9,step:1,className:`w-[88px] tabular-nums`,value:l,"aria-invalid":u!==void 0,onChange:e=>{i(e.target.value)}}),(0,h.jsx)(`span`,{className:`text-small text-ink-2`,children:`seconds`}),(0,h.jsx)(L,{variant:`primary`,disabled:u!==void 0||s.isPending,onClick:()=>{o(!1),s.mutate({...c,silenceGapSeconds:Number(l.trim())},{onSuccess:()=>{i(void 0),o(!0)}})},children:`Save`}),(0,h.jsx)(`span`,{className:`inline-flex w-[52px]`,children:a?(0,h.jsx)(m4,{}):null})]})}),(0,h.jsxs)(`div`,{className:`sl-field`,...Tb,children:[(0,h.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1`,children:[(0,h.jsx)(`span`,{className:`sl-field__label`,children:`Appearance`}),(0,h.jsx)(B,{id:`settings.appearance`,className:`-my-1`})]}),(0,h.jsx)(Db,{label:`Appearance`,value:c.appearance,options:gxe,className:`self-start`,onChange:e=>{s.mutate({...c,appearance:e})}})]}),(0,h.jsx)(`div`,{className:`md:col-span-2`,children:(0,h.jsx)(W6,{value:c.loudness??uk,switchLabel:`Level the volume for new runs`,switchTip:`settings.loudness`,onChange:e=>{s.mutate({...c,loudness:e})}})})]})}function Txe({open:e,onClose:t,onInstalled:n}){let{api:r}=R(),i=_(),a=M({queryKey:jy,queryFn:()=>Fy(r),enabled:e}),o=N({mutationFn:e=>Ly(r,e),onSuccess:()=>n(),onSettled:()=>i.invalidateQueries({queryKey:jy})});return(0,h.jsxs)(HP,{open:e,title:`Add a starter pack`,onClose:t,footer:(0,h.jsx)(v0,{tone:o.error||a.error?`error`:`success`,children:o.error?.message??a.error?.message??(o.data===void 0?void 0:o.data.added?`Added: its prompts are in Prompts and its template is in this list.`:`That pack was already added.`)}),children:[(0,h.jsxs)(`p`,{className:`mb-4 flex items-center gap-1 text-small text-ink-2`,children:[`Prompts, a suggested voice and a template for one kind of channel.`,(0,h.jsx)(B,{id:`welcome.packs`})]}),(0,h.jsxs)(hU,{label:`Starter packs`,className:`[&_.sl-row__meta]:whitespace-normal`,children:[(a.data?.packs??[]).map(e=>(0,h.jsx)(gU,{title:e.name,meta:e.summary,actions:(0,h.jsx)(L,{disabled:e.installed||o.isPending,onClick:()=>o.mutate(e.id),children:e.installed?`Added`:`Add pack`})},e.id)),a.data===void 0?(0,h.jsx)(gU,{title:`Loading packs…`}):null]})]})}function Exe({template:e}){let{api:t}=R(),n=M({queryKey:[...Rq,e.id,e.version],queryFn:async()=>{let n=await Wq(t,e.id);if(!n.ok)throw Error(n.message);return n.value}});if(n.error)return(0,h.jsxs)(`p`,{role:`alert`,className:`m-0 text-small text-danger`,children:[`The keywords of `,e.name,` didn't load. `,n.error.message,` Press Keywords again.`]});if(!n.data)return(0,h.jsx)(`p`,{role:`status`,className:`m-0 text-small text-ink-2`,children:`Reading the keywords…`});let{form:r,librarySnapshot:i}=n.data.document,a=F0({form:r,prompts:i?.prompts??[],entries:i?.entries??[]}),o=e6(r.title),s=[...new Set([...a.keys(),...Object.keys(r.values)])];return(0,h.jsx)(L0,{keywords:s.map(e=>({name:e,value:r.values[e]??``,feeds:a.get(e)??[],topic:o.includes(e)})),empty:`No keywords: the prompts and the title name none.`})}async function Dxe(e,t,n,r){let i=await Kq(e,t.id,{baseVersion:t.version,mutationId:r,...n});if(!i.ok)throw Error(i.message);return i.value}function Oxe({template:e}){return e===void 0?(0,h.jsx)(`p`,{className:`m-0 py-3 text-small text-ink-2`,children:`Pick a template to see the keywords it fills.`}):(0,h.jsxs)(`section`,{"aria-label":`Keywords of ${e.name}`,className:`flex flex-col gap-4`,children:[(0,h.jsx)(V,{title:e.name,as:`h3`,info:`templates.edit`,className:`pb-0`}),(0,h.jsx)(Exe,{template:e}),(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:`To change the settings, press Use in Play, change the draft, then Save a setup.`})]})}function kxe({template:e,onClose:t}){let{api:n}=R(),r=_(),i=Array.from({length:e.version},(t,n)=>e.version-n),a=st({queries:i.map(t=>({queryKey:[...Rq,e.id,`version`,t],queryFn:async()=>{let r=await Wq(n,e.id,t);if(!r.ok)throw Error(r.message);return r.value},staleTime:1/0}))}),o=a[0]?.data,[s,c]=(0,m.useState)(i[1]??e.version),l=a[i.indexOf(s)]?.data,u=(0,m.useRef)(crypto.randomUUID()),d=Dy(),f=N({mutationFn:t=>Dxe(n,e,{name:t.name,document:t.document},u.current),onSuccess:async(n,i)=>{u.current=crypto.randomUUID(),d(`Restored version ${String(i.version)} of ${e.name} as version ${String(n.version)}.`,`success`),await r.invalidateQueries({queryKey:Rq}),t()}}),p=a.find(e=>e.error!==null)?.error;return(0,h.jsx)(HP,{open:!0,title:`History of ${e.name}`,onClose:t,className:`sm:w-[min(1080px,100vw)]`,children:(0,h.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[p?(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-body text-danger`,children:`A version couldn't be read: ${p.message} Close History and open it again.`}):null,(0,h.jsxs)(`section`,{className:`flex flex-col gap-2`,children:[(0,h.jsx)(V,{title:`Versions`,as:`h3`,info:`templates.history`}),(0,h.jsx)(hU,{label:`Versions of ${e.name}`,children:i.map((t,n)=>{let r=a[n]?.data;return(0,h.jsx)(gU,{title:`Version ${String(t)}`,selected:t===s,onSelect:()=>c(t),meta:r===void 0?`Loading…`:`${r.name} · ${J4(r.updatedAt)}`,actions:t===e.version?(0,h.jsx)(`span`,{className:`text-small text-ink-2`,children:`Current`}):(0,h.jsx)(L,{size:`small`,"aria-label":`Restore version ${String(t)}`,disabled:r===void 0||f.isPending,disabledReason:r===void 0?`Reading the version`:`Restoring`,onClick:()=>{r!==void 0&&f.mutate(r)},children:`Restore`})},t)})}),(0,h.jsx)(v0,{tone:`error`,children:f.error===null?void 0:`The version wasn't restored: ${f.error.message}`})]}),(0,h.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,h.jsx)(V,{title:`Compare with the current version`,as:`h3`}),o===void 0||l===void 0?(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:`Loading the versions…`}):l.version===o.version?(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:e.version===1?`This is the only version so far.`:`Pick an older version in the list to compare it.`}):(0,h.jsxs)(h.Fragment,{children:[l.name===o.name?null:(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-2`,children:`Renamed from "${l.name}" to "${o.name}".`}),(0,h.jsx)(V4,{before:D9(l),after:D9(o),beforeLabel:`Version ${String(l.version)}`,afterLabel:`Version ${String(o.version)} (current)`})]})]})]})})}function D9(e){return JSON.stringify(e.document,null,1).split(`
306
306
  `).map(e=>e.trim()).filter(e=>!/^[[\]{}],?$/u.test(e)).join(`
307
- `)}function kxe({onApplied:e,beforeApply:t,getGeneration:n,blocked:r=!1}){let{api:i}=R(),a=_(),o=M(Uq(i)),s=M(Jb(i)),[c,l]=(0,m.useState)(``),u=o.data?.filter(e=>c===``||E0(e)===c),d=e=>s.data?.find(t=>t.id===E0(e))?.name,f=M({queryKey:[`play-drafts`],queryFn:async()=>{let e=await rN(i);if(!e.ok)throw Error(e.message);return e.value.drafts}}),[p,g]=(0,m.useState)(``),[v,y]=(0,m.useState)(``),[b,x]=(0,m.useState)(``),[S,C]=(0,m.useState)(!1),[w,T]=(0,m.useState)(null),E=Dy(),[D,O]=(0,m.useState)(!1),[k,ee]=(0,m.useState)(!1),[te,ne]=(0,m.useState)(null),[re,A]=(0,m.useState)(null),[ie,j]=(0,m.useState)(null),ae=(0,m.useRef)(new Map),oe=(0,m.useRef)(!1),se=(0,m.useRef)(null),ce=(0,m.useRef)(new Map),le=(0,m.useRef)(!0);(0,m.useEffect)(()=>(le.current=!0,()=>{le.current=!1}),[]);async function ue(e){if(!oe.current){oe.current=!0,C(!0),T(null);try{await e()}catch(e){T(e instanceof Error?e.message:`That didn't finish. Try again.`)}finally{oe.current=!1,C(!1)}}}async function de(){let e=await aN(i,p);if(!e.ok)throw Error(e.message);let t=JSON.stringify([p,e.value.draft.version,v.trim(),b]);se.current?.key!==t&&(se.current={key:t,id:crypto.randomUUID()});let n=e.value.draft.document,r=o.data?.find(e=>e.id===n.templateSource?.id),s=b||n.channelId||(r?E0(r):void 0),c=await Gq(i,{id:se.current.id,name:v.trim(),document:s===void 0?n:{...n,channelId:s}});if(!c.ok)throw se.current=null,Error(c.message);se.current=null,y(``),O(!1),E(`Template saved.`,`success`),await a.invalidateQueries({queryKey:Rq})}async function fe(o){let s=n?.();if(r||t&&!await t())throw Error(`Save or discard the draft open in Play first, then apply the template again.`);if(!le.current||s!==void 0&&s!==n?.())return;let c=`${o.id}:${o.version}`,l=ce.current.get(c);l||(l=crypto.randomUUID(),ce.current.set(c,l));let u=await Zq(i,o,l);if(!u.ok)throw ce.current.delete(c),Error(u.message);if(!(!le.current||s!==void 0&&s!==n?.())&&(await a.invalidateQueries({queryKey:[`play-drafts`]}),!(!le.current||s!==void 0&&s!==n?.()))){if(await e(u.value.draft.id,()=>le.current)!==!1)ce.current.delete(c);else throw Error(`The template's draft was created but didn't open. Press Use in Play again to open it.`)}}async function pe(e){let t=`${e.id}:${e.version}`,n=ae.current.get(t);n||(n=crypto.randomUUID(),ae.current.set(t,n));let r=await Wq(i,e.id);if(!r.ok)throw Error(r.message);let o=await Gq(i,{id:n,name:`${e.name} copy`,document:r.value.document});if(!o.ok)throw Error(o.message);ae.current.delete(t),E(`Duplicated as ${o.value.name}.`,`success`),await a.invalidateQueries({queryKey:Rq})}async function me(){if(!te)return;let e=te.id,t=await Yq(i,te);if(!t.ok)throw Error(t.message);ne(null),await a.cancelQueries({queryKey:Rq}),a.setQueryData(Rq,t=>t?.filter(t=>t.id!==e)),E(`Template moved to the trash. Restore it in Settings → Trash within 30 days.`,`success`),await a.invalidateQueries({queryKey:Rq})}_x({id:`library.save-template`,title:`Save a setup as a template`,group:`Library`,keywords:[`template`,`new template`,`play draft`],run:()=>O(!0)});let he=w&&!te?{tone:`error`,text:w}:r?{tone:`warning`,text:`A run is still starting in Play. Wait for it to finish (or press Check Start result there), then apply a template.`}:o.error?{tone:`error`,text:o.error.message}:o.isPending?{tone:`info`,text:`Loading templates…`}:void 0;return(0,h.jsxs)(`div`,{children:[(0,h.jsx)(wxe,{open:k,onClose:()=>ee(!1),onInstalled:()=>void a.invalidateQueries({queryKey:Uq(i).queryKey})}),(0,h.jsxs)(r3,{action:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,h.jsx)(L,{variant:`secondary`,onClick:()=>ee(!0),"aria-expanded":k,children:`Add pack`}),(0,h.jsx)(B,{id:`welcome.packs`,label:`Add pack`})]}),(0,h.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,h.jsx)(L,{variant:`primary`,onClick:()=>O(!0),"aria-expanded":D,children:`Save a setup`}),(0,h.jsx)(B,{id:`templates.save`,label:`Save a setup`})]})]}),children:[(0,h.jsxs)(`span`,{className:`flex w-full items-center gap-1 sm:w-auto`,...Tb,children:[(0,h.jsxs)(AV,{"aria-label":`Show templates of`,value:c,className:`w-full sm:w-56`,onChange:e=>l(e.target.value),children:[(0,h.jsx)(`option`,{value:``,children:`All channels`}),(s.data??[]).map(e=>(0,h.jsx)(`option`,{value:e.id,children:e.name},e.id))]}),(0,h.jsx)(B,{id:`templates.show-channel`})]}),(0,h.jsxs)(`p`,{className:`m-0 flex items-center gap-1 text-small text-ink-2`,children:[`Reuse a Play setup and its checkpoint choices. Use in Play creates a fresh draft to review.`,(0,h.jsx)(B,{id:`templates.apply`,label:`Use in Play`})]})]}),(0,h.jsxs)(`div`,{className:`mb-2 flex min-h-8 flex-wrap items-center gap-3`,children:[(0,h.jsx)(v0,{tone:he?.tone??`info`,children:he?.text}),o.error?(0,h.jsx)(L,{size:`small`,onClick:()=>void o.refetch(),children:`Reload templates`}):null,(0,h.jsx)(L,{variant:`quiet`,size:`small`,disabled:S||o.isFetching,onClick:()=>void o.refetch(),children:`Refresh templates`})]}),o.data?.length===0?(0,h.jsx)(T0,{title:`No templates yet`,children:`Use Save a setup to keep a Play draft for reuse.`}):null,o.data?.length&&u?.length===0?(0,h.jsx)(`p`,{className:`m-0 py-3 text-small text-ink-2`,children:`No templates in this channel.`}):null,o.isPending&&!o.error?(0,h.jsx)(e3,{label:`Project templates`}):null,u?.length?(0,h.jsx)(Mq,{className:Q4,list:(0,h.jsx)(hU,{label:`Project templates`,children:u.map(e=>(0,h.jsxs)(m.Fragment,{children:[(0,h.jsx)(gU,{className:`max-md:grid-cols-1`,title:(0,h.jsx)(d3,{name:e.name,maxLength:120,onSelect:()=>A(e.id),onRename:async t=>{let n=await qq(i,e.id,t);return await a.invalidateQueries({queryKey:Rq}),n}}),selected:e.id===re,meta:(0,h.jsxs)(h.Fragment,{children:[d(e)===void 0?``:`${d(e)} · `,`Version `,e.version,` · updated`,` `,(0,h.jsx)(`time`,{dateTime:e.updatedAt,children:e.updatedAt.slice(0,10)})]}),actions:(0,h.jsx)(n3,{name:e.name,edit:(0,h.jsx)(L,{variant:`quiet`,size:`small`,"aria-label":`Edit ${e.name}`,onClick:()=>A(e.id),children:`Edit`}),duplicate:(0,h.jsx)(L,{variant:`quiet`,size:`small`,"aria-label":`Duplicate ${e.name}`,disabled:S,disabledReason:`Working on the last press`,onClick:()=>void ue(()=>pe(e)),children:`Duplicate`}),play:{run:()=>void ue(()=>fe(e)),blocked:r?`A run is still starting in Play. Wait for it, then use the template.`:S?`Working on the last press`:void 0},onHistory:()=>j(e),onDelete:()=>{ne(e),T(null)}})}),(0,h.jsx)(O0,{kind:`template`,id:e.id,name:e.name})]},e.id))}),detail:(0,h.jsx)(Dxe,{template:u.find(e=>e.id===re)})}):null,(0,h.jsxs)(HP,{open:D,title:`Save a setup`,width:`narrow`,onClose:()=>O(!1),footer:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(v0,{tone:w?`error`:`info`,children:w??(S?`Saving…`:void 0)}),(0,h.jsx)(L,{type:`submit`,form:`save-template-form`,variant:`primary`,disabled:S||!p||!v.trim(),children:`Save template`})]}),children:[(0,h.jsxs)(`p`,{className:`m-0 mb-4 text-small text-ink-2`,children:[`Choose a saved Play draft, or`,` `,(0,h.jsx)(pa,{to:`/play`,className:`text-accent-ink underline`,children:`open Play`}),` `,`to prepare one.`]}),(0,h.jsx)(`p`,{className:`mb-4 text-small text-ink-2`,children:`A template keeps the settings, not one video's topic.`}),(0,h.jsxs)(`form`,{id:`save-template-form`,"aria-label":`Save a setup`,className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),p&&v.trim()&&ue(de)},children:[(0,h.jsx)(Y,{label:`Saved Play draft`,tip:`templates.save.draft`,help:f.isPending?`Loading saved drafts…`:f.data?.length===0?`No saved drafts yet.`:void 0,children:(0,h.jsxs)(AV,{value:p,required:!0,disabled:S,onChange:e=>g(e.target.value),children:[(0,h.jsx)(`option`,{value:``,children:`Choose a draft`}),f.data?.filter(e=>e.readable).map(e=>(0,h.jsx)(`option`,{value:e.id,children:e.title||`Untitled draft`},e.id))]})}),f.error?(0,h.jsx)(fI,{tone:`danger`,title:`The saved drafts couldn't be loaded.`,actions:(0,h.jsx)(L,{size:`small`,onClick:()=>void f.refetch(),children:`Reload drafts`}),children:f.error.message}):null,(0,h.jsx)(Y,{label:`Template name`,id:`template-name`,tip:`templates.save.name`,children:(0,h.jsx)(OV,{value:v,required:!0,maxLength:120,disabled:S,onChange:e=>y(e.target.value)})}),(0,h.jsx)(Y,{label:`Channel`,id:`template-channel`,tip:`templates.save.channel`,children:(0,h.jsxs)(AV,{value:b,disabled:S,onChange:e=>x(e.target.value),children:[(0,h.jsx)(`option`,{value:``,children:`The draft's channel`}),(s.data??[]).map(e=>(0,h.jsx)(`option`,{value:e.id,children:e.name},e.id))]})})]})]}),ie===null?null:(0,h.jsx)(Oxe,{template:ie,onClose:()=>j(null)},`${ie.id}:${String(ie.version)}`),(0,h.jsx)(Ay,{open:te!==null,title:`Delete ${te?.name??`template`}?`,consequence:w??`Moves it to the trash for 30 days (Settings → Trash). Existing projects and drafts keep their setup.`,confirmLabel:`Delete template`,pending:S,onConfirm:()=>void ue(me),onCancel:()=>{S||ne(null)}})]})}function Axe({page:e,anchor:t,words:n}){let{api:r}=R(),i=M(IB(r)),a=M(LB(r,e)),o=Xi(),[s,c]=(0,m.useState)(n??``);(0,m.useEffect)(()=>{c(n??``)},[n]);let l=(0,m.useRef)(null),u=(0,m.useMemo)(()=>new Set((i.data?.pages??[]).map(e=>e.id)),[i.data]),d=i.data?.pages.find(t=>t.id===e)?.title??e.replace(/-/g,` `),f=(0,m.useMemo)(()=>gb(a.data??``),[a.data]),p=(0,m.useMemo)(()=>a.data===void 0?``:hb(f.body,u,e),[a.data,f.body,u,e]);(0,m.useEffect)(()=>{if(p===``)return;let e=l.current;if(e===null)return;let n=t===void 0?void 0:vb(e,t,f.title===void 0?[]:[f.title]);n===void 0?window.scrollTo?.({top:0}):n.scrollIntoView?.({block:`start`})},[p,t,f.title]);let g=i.data?.groups.find(t=>t.pages.some(t=>t.id===e));return(0,h.jsxs)(`div`,{children:[(0,h.jsx)(Aq,{crumb:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`span`,{children:`Help`}),(0,h.jsx)(`span`,{"aria-hidden":`true`,children:`›`}),(0,h.jsx)(pa,{to:`/help/tutorials/$page`,params:{page:i.data?.home.id??`Home`},children:`Tutorials`})]}),title:d,meta:g===void 0?`Guides to every screen of Slopify, for the version you are running.`:g.title}),(0,h.jsx)(jq,{className:`sl-workspace--tutorials`,sections:(0,h.jsx)(jxe,{index:i.data,page:e,onOpenHit:(e,t)=>{o({to:`/help/tutorials/$page`,params:{page:e.page},search:{q:t},...e.anchor===``?{}:{hash:e.anchor}})}}),children:a.error===null?(0,h.jsxs)(`div`,{ref:l,onClick:e=>{if(e.defaultPrevented||e.button!==0||e.metaKey||e.ctrlKey)return;let t=e.target.closest(`a`),n=t?.getAttribute(`href`);if(t===null||n==null)return;let r=_b(n);if(r!==void 0){e.preventDefault(),o({to:`/help/tutorials/$page`,params:{page:r.page},...r.anchor===void 0?{}:{hash:r.anchor}});return}/^https?:/.test(n)&&(e.preventDefault(),window.open(n,`_blank`,`noopener,noreferrer`))},children:[(0,h.jsx)(EB,{markdown:p,label:`Tutorial`,what:`tutorial`,query:s,onQuery:c,anchorPrefix:`tutorial-`,children:(0,h.jsx)(`p`,{className:`m-0 text-ink-3`,children:`Loading the tutorial…`})}),i.data?.footer?(0,h.jsx)(`p`,{className:`mt-8 border-t border-line pt-4 text-small text-ink-3`,children:i.data.footer.replace(/\[([^\]]+)\]\([^)]+\)/g,`$1`)}):null]}):(0,h.jsx)(fI,{tone:`danger`,title:`This tutorial did not load`,actions:(0,h.jsx)(L,{onClick:()=>void a.refetch(),variant:`secondary`,children:`Try again`}),children:`${a.error.message} Press Try again, or pick another page on the left.`})})]})}function jxe({index:e,page:t,onOpenHit:n}){let{api:r}=R(),[i,a]=(0,m.useState)(``),[o,s]=(0,m.useState)(``),c=(0,m.useRef)(null),l=(0,m.useId)();vx(c,`the tutorials`),(0,m.useEffect)(()=>{let e=setTimeout(()=>s(i.trim()),200);return()=>clearTimeout(e)},[i]);let u=M(RB(r,o));return(0,h.jsxs)(`nav`,{"aria-label":`Tutorials`,className:`flex min-w-0 flex-col gap-4`,children:[(0,h.jsxs)(`div`,{className:`relative`,children:[(0,h.jsx)(`label`,{htmlFor:l,className:`sr-only`,children:`Search all tutorials`}),(0,h.jsx)(Nc,{"aria-hidden":`true`,strokeWidth:1.75,className:`pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2 text-ink-3`}),(0,h.jsx)(`input`,{ref:c,id:l,type:`search`,value:i,placeholder:`Search all tutorials`,onChange:e=>a(e.target.value),onKeyDown:e=>{let t=u.data?.hits[0];e.key===`Enter`&&t!==void 0&&(e.preventDefault(),n(t,o))},className:`sl-input pl-9`})]}),o===``?e===void 0?(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-3`,children:`Loading the tutorials…`}):(0,h.jsxs)(`div`,{className:`sl-tutorials-nav flex flex-col gap-4`,children:[(0,h.jsx)(O9,{id:e.home.id,title:e.home.title,current:t}),e.groups.map(e=>(0,h.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,h.jsx)(`div`,{className:`sl-kicker px-2.5 pb-1`,children:e.title}),e.pages.map(e=>(0,h.jsx)(O9,{id:e.id,title:e.title,current:t},e.id))]},e.title))]}):(0,h.jsx)(Mxe,{query:o,hits:u.data?.hits,error:u.error?.message})]})}function O9({id:e,title:t,current:n}){return(0,h.jsx)(pa,{to:`/help/tutorials/$page`,params:{page:e},"aria-current":e===n?`page`:void 0,className:`sl-tutorials-nav__link`,children:t})}function Mxe({query:e,hits:t,error:n}){return n===void 0?t===void 0?(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-3`,children:`Searching…`}):t.length===0?(0,h.jsx)(`p`,{role:`status`,className:`m-0 text-small text-ink-2`,children:`No tutorial mentions "${e}". Try fewer or other words.`}):(0,h.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,h.jsx)(`p`,{role:`status`,className:`m-0 px-2.5 text-small text-ink-3`,children:t.length===1?`1 section`:`${String(t.length)} sections`}),(0,h.jsx)(`ul`,{"aria-label":`Search results`,className:`m-0 flex list-none flex-col gap-1 p-0`,children:t.map(t=>(0,h.jsx)(`li`,{children:(0,h.jsxs)(pa,{to:`/help/tutorials/$page`,params:{page:t.page},search:{q:e},...t.anchor===``?{}:{hash:t.anchor},className:`sl-tutorials-hit`,children:[(0,h.jsx)(`span`,{className:`block font-semibold text-ink`,children:t.heading===void 0?t.pageTitle:t.heading}),t.heading===void 0?null:(0,h.jsx)(`span`,{className:`block text-label text-ink-3`,children:t.pageTitle}),(0,h.jsx)(`span`,{className:`mt-0.5 block text-small text-ink-2`,children:t.snippet})]})},`${t.page}#${t.anchor}`))})]}):(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-small text-danger`,children:`The search didn't run: ${n} Change the words or reload the page.`})}var Nxe=[{id:`library`,name:`The Library of Alexandria`,summary:`A narrated video with its two shorts, article, PDF, description and images.`,action:`Explore the sample`},{id:`audiobook`,name:`The Wind in the Willows`,summary:`An audiobook: a narrator and two character voices, captions tagged with who speaks, MP3 and M4B with chapters.`,action:`See an audiobook`},{id:`podcast`,name:`The Antikythera Mechanism`,summary:`A two-host podcast with the speaker panel, name tags and portraits, and its MP3 and M4B.`,action:`Hear a podcast`}],k9=[{id:`found`,label:`1 · What you have`},{id:`style`,label:`2 · Pick a style`},{id:`make`,label:`3 · Make your first short`}];function Pxe(e){return e.length<=2?e.join(` or `):`${e.slice(0,-1).join(`, `)} or ${e.at(-1)??``}`}function Fxe(e){return e===void 0?{ready:!1,text:`Looking for a voice…`}:e.keyed===null?e.system.available?{ready:!0,text:`Narration uses your computer's built-in voice${e.system.engine===null?``:` (${e.system.engine})`}; add an ElevenLabs or OpenAI key later for a better one.`}:{ready:!1,text:e.system.issue??`No voice can narrate yet. Add an ElevenLabs or OpenAI key in Settings → Providers.`}:{ready:!0,text:`Narration uses your ${e.keyed} voice key.`}}function Ixe(){let{api:e}=R(),t=_(),n=Xi(),r=M({queryKey:jy,queryFn:()=>Fy(e)}),[i,a]=(0,m.useState)(`found`),[o,s]=(0,m.useState)(``),[c,l]=(0,m.useState)(``),[u,d]=(0,m.useState)(void 0),f=(0,m.useRef)(void 0),p=N({mutationFn:()=>Iy(e),onSuccess:async()=>{await t.invalidateQueries({queryKey:jy}),await n({to:`/`})}}),g=N({mutationFn:t=>Ly(e,t),onSettled:()=>t.invalidateQueries({queryKey:jy})}),v=N({mutationFn:()=>(f.current??=crypto.randomUUID(),Ry(e,{topic:o,requestId:f.current,...c===``?{}:{packId:c}})),onSuccess:async({projectId:e})=>{f.current=void 0,d(e),await t.invalidateQueries({queryKey:z.projects}),await t.invalidateQueries({queryKey:z.voices})}}),y=e=>{e.preventDefault(),o.trim()!==``&&v.mutate()},b=r.data,x=b?.clis.filter(e=>e.ready)??[],S=Fxe(b?.voice),C=c===``?`General`:b?.packs.find(e=>e.id===c)?.name??c,w=v.error?{tone:`error`,text:v.error.message}:g.error?{tone:`error`,text:g.error.message}:p.error?{tone:`error`,text:p.error.message}:v.isPending?{tone:`info`,text:`Starting your short…`}:void 0,T=k9.findIndex(e=>e.id===i),E=k9[T+1],D=k9[T-1];return(0,h.jsxs)(`div`,{children:[(0,h.jsx)(Aq,{title:`Welcome to Slopify`,meta:`Make a video from a topic, with the tools already on this computer.`,actions:(0,h.jsx)(L,{variant:`quiet`,disabled:p.isPending,onClick:()=>p.mutate(),children:u===void 0?`Skip`:`Done`})}),r.error?(0,h.jsx)(fI,{tone:`danger`,title:`Could not read what this computer has`,className:`mb-6`,children:r.error.message}):null,(0,h.jsx)(C0,{items:k9.map(e=>({id:e.id,label:e.label})),value:i,onChange:a,label:`First-run steps`,idPrefix:`welcome`,className:`mb-6`}),(0,h.jsxs)(w0,{idPrefix:`welcome`,id:`found`,active:i===`found`,children:[(0,h.jsx)(V,{title:`Found on this computer`,info:`welcome.found`}),(0,h.jsxs)(hU,{label:`Tools found on this computer`,className:`mb-4`,children:[(b?.clis??[]).map(e=>(0,h.jsx)(gU,{title:e.name,actions:(0,h.jsx)(`span`,{className:`text-small text-ink-2`,children:e.ready?`Ready${e.version===null?``:` · ${e.version}`}${e.draws?` · writes and draws`:` · writes`}`:e.installed?e.issue??`Installed, not usable yet`:`Not found`})},e.id)),b===void 0?(0,h.jsx)(gU,{title:`Looking for installed tools…`}):null]}),b!==void 0&&x.length>0?(0,h.jsx)(`p`,{className:`mb-6 text-small text-ink-2`,children:`You can make a video now: no API keys are needed for ${Pxe([`the text`,...x.some(e=>e.draws)?[`the images`]:[],...S.ready&&b.voice.keyed===null?[`the narration`]:[]])}.`}):null,b!==void 0&&x.length===0?(0,h.jsx)(fI,{tone:`waiting`,className:`mb-6`,title:`Nothing on this computer can write the script yet.`,actions:(0,h.jsx)(lS,{to:`/settings`,search:{section:`providers`},children:`Open Settings → Providers`}),children:`Install Claude Code, Codex or Gemini CLI and sign in to it, then press Check again; or add an OpenRouter key in Settings → Providers.`}):null,(0,h.jsx)(V,{title:`Narration voice`,info:`welcome.voice`}),b===void 0?(0,h.jsx)(hU,{label:`Narration voice`,className:`mb-6`,children:(0,h.jsx)(gU,{title:`Looking for a voice…`})}):(0,h.jsx)(A9,{voice:S,checking:r.isFetching,onCheck:()=>void r.refetch()})]}),(0,h.jsxs)(w0,{idPrefix:`welcome`,id:`style`,active:i===`style`,children:[(0,h.jsx)(V,{title:`Pick a style`,info:`welcome.pack`}),(0,h.jsx)(hU,{label:`Styles`,className:`mb-3 [&_.sl-row__meta]:whitespace-normal`,children:[{id:``,name:`General`,summary:`A neutral explainer style.`,installed:!1,library:!1},...(b?.packs??[]).map(e=>({...e,library:!0}))].map(e=>(0,h.jsx)(gU,{title:e.name,meta:e.summary,selected:c===e.id,actions:(0,h.jsxs)(h.Fragment,{children:[e.library?(0,h.jsx)(L,{variant:`quiet`,disabled:e.installed||g.isPending,"aria-label":e.installed?`${e.name} is in your library`:`Add ${e.name} to library`,onClick:()=>g.mutate(e.id),children:e.installed?`In your library`:`Add to library`}):null,(0,h.jsx)(L,{variant:c===e.id?`primary`:`secondary`,"aria-pressed":c===e.id,"aria-label":`Use ${e.name}`,onClick:()=>l(e.id),children:c===e.id?`Picked`:`Use this style`})]})},e.id===``?`general`:e.id))}),(0,h.jsxs)(`p`,{className:`mb-6 flex items-center gap-1 text-small text-ink-2`,...Tb,children:[`Add to library keeps a pack's prompts and Play template for later videos.`,(0,h.jsx)(B,{id:`welcome.packs`,className:`-my-1`})]})]}),(0,h.jsxs)(w0,{idPrefix:`welcome`,id:`make`,active:i===`make`,children:[u===void 0?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(V,{title:`Make a 60-second short`,info:`welcome.short`}),(0,h.jsxs)(`p`,{className:`mb-3 text-small text-ink-2`,children:[`Style: ${C}. `,S.text]}),S.ready||b===void 0?null:(0,h.jsx)(`div`,{className:`mb-4`,children:(0,h.jsx)(A9,{voice:S,checking:r.isFetching,onCheck:()=>void r.refetch()})}),(0,h.jsxs)(`form`,{onSubmit:y,className:`mb-6 flex flex-wrap items-end gap-3`,children:[(0,h.jsxs)(`div`,{className:`flex min-w-[240px] flex-1 flex-col gap-1`,...Tb,children:[(0,h.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,h.jsx)(`label`,{htmlFor:`welcome-topic`,className:`text-label text-ink-2`,children:`Topic`}),(0,h.jsx)(B,{id:`welcome.topic`,className:`-my-1`})]}),(0,h.jsx)(SV,{id:`welcome-topic`,value:o,maxLength:200,placeholder:`Why the sea glows at night`,onChange:e=>s(e.target.value)})]}),(0,h.jsx)(L,{type:`submit`,variant:`primary`,disabled:o.trim()===``||v.isPending,disabledReason:`Type a topic first.`,children:`Make a 60-second short`})]})]}):(0,h.jsx)(fI,{tone:`info`,className:`mb-6`,title:`Your short is being made.`,actions:(0,h.jsx)(lS,{variant:`primary`,to:`/projects/$projectId`,params:{projectId:u},children:`Watch it being made`}),children:`It usually takes about five minutes. The live view shows each step as it runs; while you wait, look at a sample or set Slopify to start when you log in.`}),(0,h.jsx)(V,{title:`While you wait: the samples`,info:`welcome.samples`}),(0,h.jsx)(hU,{label:`Samples`,className:`mb-6 [&_.sl-row__meta]:whitespace-normal`,children:Nxe.map(e=>{let t=b?.samples[e.id]??null;return(0,h.jsx)(gU,{title:e.name,meta:e.summary,actions:t===null?(0,h.jsx)(uS,{to:`/settings`,search:{section:`storage`},children:`Restore samples in Settings`}):(0,h.jsx)(lS,{to:`/projects/$projectId`,params:{projectId:t},className:mU,children:e.action})},e.id)})}),(0,h.jsx)(Rb,{})]}),(0,h.jsxs)(y0,{status:(0,h.jsx)(v0,{tone:w?.tone??`info`,children:w?.text}),children:[(0,h.jsx)(uS,{to:`/play`,children:`Set up a long video instead`}),D===void 0?null:(0,h.jsx)(L,{onClick:()=>a(D.id),children:`Back`}),E===void 0?null:(0,h.jsx)(L,{variant:`primary`,onClick:()=>a(E.id),children:`Next: ${E.label.replace(/^\d · /,``)}`})]})]})}function A9({voice:e,checking:t,onCheck:n}){return e.ready?(0,h.jsx)(hU,{label:`Narration voice`,className:`mb-6 [&_.sl-row__title]:whitespace-normal`,children:(0,h.jsx)(gU,{lead:(0,h.jsx)(pS,{tone:`done`}),title:e.text,actions:(0,h.jsx)(lS,{variant:`quiet`,to:`/settings`,search:{section:`providers`},children:`Add a voice key`})})}):(0,h.jsx)(fI,{tone:`waiting`,className:`mb-6`,title:`No voice can narrate the short yet.`,actions:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(lS,{variant:`primary`,to:`/settings`,search:{section:`providers`},children:`Add a voice key`}),(0,h.jsx)(L,{disabled:t,onClick:n,children:t?`Checking…`:`Check again`})]}),children:e.text})}var j9=_a({component:rV}),Lxe=ha({getParentRoute:()=>j9,path:`/`,component:Bpe}),M9=ha({getParentRoute:()=>j9,path:`projects`,validateSearch:e=>{let t=qye(e.show);return t===void 0?{}:{show:t}},component:Rxe});function Rxe(){let{show:e}=M9.useSearch();return(0,h.jsx)(Xye,{initialFilter:e??`all`},e??`all`)}var zxe=ha({getParentRoute:()=>j9,path:`welcome`,component:Ixe}),Bxe=ha({getParentRoute:()=>j9,path:`play`,component:Nhe}),N9=ha({getParentRoute:()=>j9,id:`_library`,component:qfe}),Vxe=ha({getParentRoute:()=>j9,path:`library`,beforeLoad:()=>{throw Vn({to:`/prompts`,search:{kind:`article`}})}}),Hxe=ha({getParentRoute:()=>j9,path:`channels`,component:wfe}),P9=ha({getParentRoute:()=>j9,path:`channels/$channelId`,validateSearch:e=>e.tab===void 0?{}:{tab:Sfe(e.tab)},component:Uxe});function Uxe(){let{channelId:e}=P9.useParams(),{tab:t}=P9.useSearch(),n=Xi();return(0,h.jsx)(Cfe,{channelId:e,tab:t??`brand`,onTab:t=>{n({to:`/channels/$channelId`,params:{channelId:e},search:{tab:t},replace:!0})}},e)}var Wxe=ha({getParentRoute:()=>N9,path:`templates`,component:Yxe}),Gxe=/^[0-9A-Za-z-]{1,64}$/;function F9(e){return zde(e.tab)===`schedules`?typeof e.schedule==`string`&&Gxe.test(e.schedule)?{tab:`schedules`,schedule:e.schedule}:{tab:`schedules`}:{}}var I9=ha({getParentRoute:()=>j9,path:`calendar`,validateSearch:F9,component:Jxe}),Kxe=ha({getParentRoute:()=>j9,path:`schedules`,beforeLoad:()=>{throw Vn({to:`/calendar`,search:{tab:`schedules`},replace:!0})}}),qxe=ha({getParentRoute:()=>j9,path:`schedules/$scheduleId`,beforeLoad:({params:e})=>{throw Vn({to:`/calendar`,search:F9({tab:`schedules`,schedule:e.scheduleId}),replace:!0})}});function Jxe(){let e=F9(I9.useSearch()),t=Xi();return(0,h.jsx)(Vde,{tab:e.tab??`weeks`,schedule:e.schedule,onTab:e=>{t({to:`/calendar`,search:e===`schedules`?{tab:`schedules`}:{},replace:!0})},onSchedule:e=>{t({to:`/calendar`,search:{tab:`schedules`,schedule:e},replace:!0})}})}function Yxe(){let e=cP(),t=Xi();return(0,h.jsx)(kxe,{getGeneration:e.generation,blocked:e.review.starting||e.review.uncertain||e.review.created!==null,beforeApply:e.flush,onApplied:async(n,r)=>!r()||!await e.open(n,r)||!r()?!1:(await t({to:`/play`}),r())})}var L9=ha({getParentRoute:()=>j9,path:`projects/$projectId`,component:iSe}),R9=ha({getParentRoute:()=>N9,path:`prompts`,validateSearch:e=>({kind:xV(e.kind)}),component:aSe}),z9=ha({getParentRoute:()=>j9,path:`prompts/new`,validateSearch:e=>{let t=xV(e.kind);return typeof e.from==`string`?{kind:t,from:e.from}:{kind:t}},component:oSe}),B9=ha({getParentRoute:()=>j9,path:`prompts/$promptId`,component:sSe}),V9=ha({getParentRoute:()=>N9,path:`entries`,validateSearch:e=>({category:vV(e.category)}),component:cSe}),H9=ha({getParentRoute:()=>j9,path:`entries/new`,validateSearch:e=>{let t=vV(e.category);return typeof e.from==`string`?{category:t,from:e.from}:{category:t}},component:lSe}),U9=ha({getParentRoute:()=>j9,path:`entries/$entryId`,component:X9}),Xxe=ha({getParentRoute:()=>N9,path:`narration-aliases`,component:Hpe}),Zxe=ha({getParentRoute:()=>N9,path:`document-themes`,component:Yfe}),W9=ha({getParentRoute:()=>j9,path:`document-themes/new`,validateSearch:e=>typeof e.from==`string`?{from:e.from}:{},component:uSe}),G9=ha({getParentRoute:()=>j9,path:`document-themes/$themeId`,component:dSe});function Qxe(e){let t=e.section===void 0?void 0:_xe(e.section),n=t===`patch-notes`&&typeof e.note==`string`&&/^[0-9A-Za-z][0-9A-Za-z.-]{0,63}$/.test(e.note)?e.note:void 0;return{...t===void 0?{}:{section:t},...n===void 0?{}:{note:n}}}var K9=ha({getParentRoute:()=>j9,path:`settings`,validateSearch:Qxe,component:rSe}),q9=ha({getParentRoute:()=>j9,path:`help/tutorials/$page`,validateSearch:e=>typeof e.q==`string`&&e.q.trim()!==``?{q:e.q.slice(0,200)}:{},component:$xe});function $xe(){let{page:e}=q9.useParams(),{q:t}=q9.useSearch(),n=za({select:e=>e.hash});return(0,h.jsx)(Axe,{page:e,anchor:n===``?void 0:n,words:t})}var eSe=ha({getParentRoute:()=>j9,path:`help`,beforeLoad:()=>{throw Vn({to:`/help/tutorials/$page`,params:{page:`Home`}})}}),tSe=ha({getParentRoute:()=>j9,path:`help/tutorials`,beforeLoad:()=>{throw Vn({to:`/help/tutorials/$page`,params:{page:`Home`}})}}),nSe=ha({getParentRoute:()=>j9,path:`usage`,beforeLoad:()=>{throw Vn({to:`/settings`,search:{section:`usage`}})}});function rSe(){let{section:e,note:t}=K9.useSearch(),n=Xi();return(0,h.jsx)(yxe,{section:e??`providers`,note:t,onSection:e=>{n({to:`/settings`,search:{section:e},replace:!0})},onNote:e=>{n({to:`/settings`,search:{section:`patch-notes`,...e===void 0?{}:{note:e}}})}})}function iSe(){let{projectId:e}=L9.useParams(),t=cP(),n=Xi();return(0,h.jsx)(Vye,{projectId:e,openDraft:async e=>!await t.flush()||!await t.open(e)?!1:(await n({to:`/play`}),!0)},e)}function aSe(){let{kind:e}=R9.useSearch(),t=Xi(),n=J9();return(0,h.jsx)(tbe,{kind:e,onKind:e=>{t({to:`/prompts`,search:{kind:e},replace:!0})},onUseInPlay:n.use,playBlocked:n.blocked})}function J9(){let e=cP(),t=Xi();return{blocked:e.review.starting||e.review.uncertain||e.review.created!==null?`Play is starting a run from its draft. Wait for it to start, then try again.`:void 0,use:n=>{let r=eH(e.document,n);e.edit(r.document),t({to:`/play`}).then(()=>e.navigate(r.section,r.field))}}}function oSe(){let{kind:e,from:t}=z9.useSearch(),n=Y9();return(0,h.jsx)(J7,{promptId:void 0,kind:e,from:t,onLeave:n},`${e}:${t??`new`}`)}function sSe(){let{promptId:e}=B9.useParams(),t=Y9();return(0,h.jsx)(J7,{promptId:e,kind:`article`,from:void 0,onLeave:t},e)}function Y9(){let e=Xi();return t=>{e({to:`/prompts`,search:{kind:t}})}}function cSe(){let{category:e}=V9.useSearch(),t=Xi(),n=J9();return(0,h.jsx)(Xfe,{category:e,onCategory:e=>{t({to:`/entries`,search:{category:e},replace:!0})},onUseInPlay:n.use,playBlocked:n.blocked})}function lSe(){let{category:e,from:t}=H9.useSearch(),n=Q9();return(0,h.jsx)(T3,{entryId:void 0,category:e,from:t,onLeave:n})}function X9(){let{entryId:e}=U9.useParams(),t=Q9();return(0,h.jsx)(T3,{entryId:e,category:`intro`,from:void 0,onLeave:t})}function uSe(){let{from:e}=W9.useSearch(),t=Z9();return(0,h.jsx)(P4,{themeId:void 0,from:e,onLeave:t})}function dSe(){let{themeId:e}=G9.useParams(),t=Z9();return(0,h.jsx)(P4,{themeId:e,from:void 0,onLeave:t})}function Z9(){let e=Xi();return()=>{e({to:`/document-themes`})}}function Q9(){let e=Xi();return t=>{e({to:`/entries`,search:{category:t}})}}var fSe=j9.addChildren({homeRoute:Lxe,projectsRoute:M9,welcomeRoute:zxe,playRoute:Bxe,libraryRoute:N9.addChildren({promptsRoute:R9,entriesRoute:V9,templatesRoute:Wxe,documentThemesRoute:Zxe,narrationAliasesRoute:Xxe}),schedulesRoute:Kxe,scheduleRoute:qxe,calendarRoute:I9,libraryIndexRoute:Vxe,channelsRoute:Hxe,channelRoute:P9,projectRoute:L9,newPromptRoute:z9,promptRoute:B9,newEntryRoute:H9,entryRoute:U9,newDocumentThemeRoute:W9,documentThemeRoute:G9,settingsRoute:K9,usageRoute:nSe,helpRoute:eSe,tutorialsIndexRoute:tSe,tutorialsRoute:q9});function pSe(){return Pa({routeTree:fSe})}function mSe(){let e,t,n=new Set;return{observe:r=>{if(e===void 0){e=r;for(let e of n)e();return}if(r!==e&&r!==t){t=r;for(let e of n)e()}},staleAt:()=>t,loadedAt:()=>e,subscribe:e=>(n.add(e),()=>{n.delete(e)})}}function hSe(e,t){return async(n,r)=>{let i=await e(n,r),a=i.headers.get(`X-Slopify-Version`);return a!==null&&t.observe(a),i}}function gSe(e){let t=mSe(),n={api:bo(window.location.origin,hSe(window.fetch.bind(window),t),So(e=>{let n=e.headers.get(`X-Slopify-Version`);n!==null&&t.observe(n)})),openEvents:e=>new EventSource(e),version:t};(0,ao.createRoot)(e).render((0,h.jsx)(m.StrictMode,{children:(0,h.jsx)(v,{client:new Ye,children:(0,h.jsx)(ite,{deps:n,children:(0,h.jsx)(La,{router:pSe()})})})}))}var $9=document.getElementById(`root`);if($9===null)throw Error(`index.html carries no #root element for the app to mount on`);gSe($9);export{v4 as t};
307
+ `)}function Axe({onApplied:e,beforeApply:t,getGeneration:n,blocked:r=!1}){let{api:i}=R(),a=_(),o=M(Uq(i)),s=M(Jb(i)),[c,l]=(0,m.useState)(``),u=o.data?.filter(e=>c===``||E0(e)===c),d=e=>s.data?.find(t=>t.id===E0(e))?.name,f=M({queryKey:[`play-drafts`],queryFn:async()=>{let e=await rN(i);if(!e.ok)throw Error(e.message);return e.value.drafts}}),[p,g]=(0,m.useState)(``),[v,y]=(0,m.useState)(``),[b,x]=(0,m.useState)(``),[S,C]=(0,m.useState)(!1),[w,T]=(0,m.useState)(null),E=Dy(),[D,O]=(0,m.useState)(!1),[k,ee]=(0,m.useState)(!1),[te,ne]=(0,m.useState)(null),[re,A]=(0,m.useState)(null),[ie,j]=(0,m.useState)(null),ae=(0,m.useRef)(new Map),oe=(0,m.useRef)(!1),se=(0,m.useRef)(null),ce=(0,m.useRef)(new Map),le=(0,m.useRef)(!0);(0,m.useEffect)(()=>(le.current=!0,()=>{le.current=!1}),[]);async function ue(e){if(!oe.current){oe.current=!0,C(!0),T(null);try{await e()}catch(e){T(e instanceof Error?e.message:`That didn't finish. Try again.`)}finally{oe.current=!1,C(!1)}}}async function de(){let e=await aN(i,p);if(!e.ok)throw Error(e.message);let t=JSON.stringify([p,e.value.draft.version,v.trim(),b]);se.current?.key!==t&&(se.current={key:t,id:crypto.randomUUID()});let n=e.value.draft.document,r=o.data?.find(e=>e.id===n.templateSource?.id),s=b||n.channelId||(r?E0(r):void 0),c=await Gq(i,{id:se.current.id,name:v.trim(),document:s===void 0?n:{...n,channelId:s}});if(!c.ok)throw se.current=null,Error(c.message);se.current=null,y(``),O(!1),E(`Template saved.`,`success`),await a.invalidateQueries({queryKey:Rq})}async function fe(o){let s=n?.();if(r||t&&!await t())throw Error(`Save or discard the draft open in Play first, then apply the template again.`);if(!le.current||s!==void 0&&s!==n?.())return;let c=`${o.id}:${o.version}`,l=ce.current.get(c);l||(l=crypto.randomUUID(),ce.current.set(c,l));let u=await Zq(i,o,l);if(!u.ok)throw ce.current.delete(c),Error(u.message);if(!(!le.current||s!==void 0&&s!==n?.())&&(await a.invalidateQueries({queryKey:[`play-drafts`]}),!(!le.current||s!==void 0&&s!==n?.()))){if(await e(u.value.draft.id,()=>le.current)!==!1)ce.current.delete(c);else throw Error(`The template's draft was created but didn't open. Press Use in Play again to open it.`)}}async function pe(e){let t=`${e.id}:${e.version}`,n=ae.current.get(t);n||(n=crypto.randomUUID(),ae.current.set(t,n));let r=await Wq(i,e.id);if(!r.ok)throw Error(r.message);let o=await Gq(i,{id:n,name:`${e.name} copy`,document:r.value.document});if(!o.ok)throw Error(o.message);ae.current.delete(t),E(`Duplicated as ${o.value.name}.`,`success`),await a.invalidateQueries({queryKey:Rq})}async function me(){if(!te)return;let e=te.id,t=await Yq(i,te);if(!t.ok)throw Error(t.message);ne(null),await a.cancelQueries({queryKey:Rq}),a.setQueryData(Rq,t=>t?.filter(t=>t.id!==e)),E(`Template moved to the trash. Restore it in Settings → Trash within 30 days.`,`success`),await a.invalidateQueries({queryKey:Rq})}_x({id:`library.save-template`,title:`Save a setup as a template`,group:`Library`,keywords:[`template`,`new template`,`play draft`],run:()=>O(!0)});let he=w&&!te?{tone:`error`,text:w}:r?{tone:`warning`,text:`A run is still starting in Play. Wait for it to finish (or press Check Start result there), then apply a template.`}:o.error?{tone:`error`,text:o.error.message}:o.isPending?{tone:`info`,text:`Loading templates…`}:void 0;return(0,h.jsxs)(`div`,{children:[(0,h.jsx)(Txe,{open:k,onClose:()=>ee(!1),onInstalled:()=>void a.invalidateQueries({queryKey:Uq(i).queryKey})}),(0,h.jsxs)(r3,{action:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,h.jsx)(L,{variant:`secondary`,onClick:()=>ee(!0),"aria-expanded":k,children:`Add pack`}),(0,h.jsx)(B,{id:`welcome.packs`,label:`Add pack`})]}),(0,h.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,h.jsx)(L,{variant:`primary`,onClick:()=>O(!0),"aria-expanded":D,children:`Save a setup`}),(0,h.jsx)(B,{id:`templates.save`,label:`Save a setup`})]})]}),children:[(0,h.jsxs)(`span`,{className:`flex w-full items-center gap-1 sm:w-auto`,...Tb,children:[(0,h.jsxs)(AV,{"aria-label":`Show templates of`,value:c,className:`w-full sm:w-56`,onChange:e=>l(e.target.value),children:[(0,h.jsx)(`option`,{value:``,children:`All channels`}),(s.data??[]).map(e=>(0,h.jsx)(`option`,{value:e.id,children:e.name},e.id))]}),(0,h.jsx)(B,{id:`templates.show-channel`})]}),(0,h.jsxs)(`p`,{className:`m-0 flex items-center gap-1 text-small text-ink-2`,children:[`Reuse a Play setup and its checkpoint choices. Use in Play creates a fresh draft to review.`,(0,h.jsx)(B,{id:`templates.apply`,label:`Use in Play`})]})]}),(0,h.jsxs)(`div`,{className:`mb-2 flex min-h-8 flex-wrap items-center gap-3`,children:[(0,h.jsx)(v0,{tone:he?.tone??`info`,children:he?.text}),o.error?(0,h.jsx)(L,{size:`small`,onClick:()=>void o.refetch(),children:`Reload templates`}):null,(0,h.jsx)(L,{variant:`quiet`,size:`small`,disabled:S||o.isFetching,onClick:()=>void o.refetch(),children:`Refresh templates`})]}),o.data?.length===0?(0,h.jsx)(T0,{title:`No templates yet`,children:`Use Save a setup to keep a Play draft for reuse.`}):null,o.data?.length&&u?.length===0?(0,h.jsx)(`p`,{className:`m-0 py-3 text-small text-ink-2`,children:`No templates in this channel.`}):null,o.isPending&&!o.error?(0,h.jsx)(e3,{label:`Project templates`}):null,u?.length?(0,h.jsx)(Mq,{className:Q4,list:(0,h.jsx)(hU,{label:`Project templates`,children:u.map(e=>(0,h.jsxs)(m.Fragment,{children:[(0,h.jsx)(gU,{className:`max-md:grid-cols-1`,title:(0,h.jsx)(d3,{name:e.name,maxLength:120,onSelect:()=>A(e.id),onRename:async t=>{let n=await qq(i,e.id,t);return await a.invalidateQueries({queryKey:Rq}),n}}),selected:e.id===re,meta:(0,h.jsxs)(h.Fragment,{children:[d(e)===void 0?``:`${d(e)} · `,`Version `,e.version,` · updated`,` `,(0,h.jsx)(`time`,{dateTime:e.updatedAt,children:e.updatedAt.slice(0,10)})]}),actions:(0,h.jsx)(n3,{name:e.name,edit:(0,h.jsx)(L,{variant:`quiet`,size:`small`,"aria-label":`Edit ${e.name}`,onClick:()=>A(e.id),children:`Edit`}),duplicate:(0,h.jsx)(L,{variant:`quiet`,size:`small`,"aria-label":`Duplicate ${e.name}`,disabled:S,disabledReason:`Working on the last press`,onClick:()=>void ue(()=>pe(e)),children:`Duplicate`}),play:{run:()=>void ue(()=>fe(e)),blocked:r?`A run is still starting in Play. Wait for it, then use the template.`:S?`Working on the last press`:void 0},onHistory:()=>j(e),onDelete:()=>{ne(e),T(null)}})}),(0,h.jsx)(O0,{kind:`template`,id:e.id,name:e.name})]},e.id))}),detail:(0,h.jsx)(Oxe,{template:u.find(e=>e.id===re)})}):null,(0,h.jsxs)(HP,{open:D,title:`Save a setup`,width:`narrow`,onClose:()=>O(!1),footer:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(v0,{tone:w?`error`:`info`,children:w??(S?`Saving…`:void 0)}),(0,h.jsx)(L,{type:`submit`,form:`save-template-form`,variant:`primary`,disabled:S||!p||!v.trim(),children:`Save template`})]}),children:[(0,h.jsxs)(`p`,{className:`m-0 mb-4 text-small text-ink-2`,children:[`Choose a saved Play draft, or`,` `,(0,h.jsx)(pa,{to:`/play`,className:`text-accent-ink underline`,children:`open Play`}),` `,`to prepare one.`]}),(0,h.jsx)(`p`,{className:`mb-4 text-small text-ink-2`,children:`A template keeps the settings, not one video's topic.`}),(0,h.jsxs)(`form`,{id:`save-template-form`,"aria-label":`Save a setup`,className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),p&&v.trim()&&ue(de)},children:[(0,h.jsx)(Y,{label:`Saved Play draft`,tip:`templates.save.draft`,help:f.isPending?`Loading saved drafts…`:f.data?.length===0?`No saved drafts yet.`:void 0,children:(0,h.jsxs)(AV,{value:p,required:!0,disabled:S,onChange:e=>g(e.target.value),children:[(0,h.jsx)(`option`,{value:``,children:`Choose a draft`}),f.data?.filter(e=>e.readable).map(e=>(0,h.jsx)(`option`,{value:e.id,children:e.title||`Untitled draft`},e.id))]})}),f.error?(0,h.jsx)(fI,{tone:`danger`,title:`The saved drafts couldn't be loaded.`,actions:(0,h.jsx)(L,{size:`small`,onClick:()=>void f.refetch(),children:`Reload drafts`}),children:f.error.message}):null,(0,h.jsx)(Y,{label:`Template name`,id:`template-name`,tip:`templates.save.name`,children:(0,h.jsx)(OV,{value:v,required:!0,maxLength:120,disabled:S,onChange:e=>y(e.target.value)})}),(0,h.jsx)(Y,{label:`Channel`,id:`template-channel`,tip:`templates.save.channel`,children:(0,h.jsxs)(AV,{value:b,disabled:S,onChange:e=>x(e.target.value),children:[(0,h.jsx)(`option`,{value:``,children:`The draft's channel`}),(s.data??[]).map(e=>(0,h.jsx)(`option`,{value:e.id,children:e.name},e.id))]})})]})]}),ie===null?null:(0,h.jsx)(kxe,{template:ie,onClose:()=>j(null)},`${ie.id}:${String(ie.version)}`),(0,h.jsx)(Ay,{open:te!==null,title:`Delete ${te?.name??`template`}?`,consequence:w??`Moves it to the trash for 30 days (Settings → Trash). Existing projects and drafts keep their setup.`,confirmLabel:`Delete template`,pending:S,onConfirm:()=>void ue(me),onCancel:()=>{S||ne(null)}})]})}function jxe({page:e,anchor:t,words:n}){let{api:r}=R(),i=M(IB(r)),a=M(LB(r,e)),o=Xi(),[s,c]=(0,m.useState)(n??``);(0,m.useEffect)(()=>{c(n??``)},[n]);let l=(0,m.useRef)(null),u=(0,m.useMemo)(()=>new Set((i.data?.pages??[]).map(e=>e.id)),[i.data]),d=i.data?.pages.find(t=>t.id===e)?.title??e.replace(/-/g,` `),f=(0,m.useMemo)(()=>gb(a.data??``),[a.data]),p=(0,m.useMemo)(()=>a.data===void 0?``:hb(f.body,u,e),[a.data,f.body,u,e]);(0,m.useEffect)(()=>{if(p===``)return;let e=l.current;if(e===null)return;let n=t===void 0?void 0:vb(e,t,f.title===void 0?[]:[f.title]);n===void 0?window.scrollTo?.({top:0}):n.scrollIntoView?.({block:`start`})},[p,t,f.title]);let g=i.data?.groups.find(t=>t.pages.some(t=>t.id===e));return(0,h.jsxs)(`div`,{children:[(0,h.jsx)(Aq,{crumb:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`span`,{children:`Help`}),(0,h.jsx)(`span`,{"aria-hidden":`true`,children:`›`}),(0,h.jsx)(pa,{to:`/help/tutorials/$page`,params:{page:i.data?.home.id??`Home`},children:`Tutorials`})]}),title:d,meta:g===void 0?`Guides to every screen of Slopify, for the version you are running.`:g.title}),(0,h.jsx)(jq,{className:`sl-workspace--tutorials`,sections:(0,h.jsx)(Mxe,{index:i.data,page:e,onOpenHit:(e,t)=>{o({to:`/help/tutorials/$page`,params:{page:e.page},search:{q:t},...e.anchor===``?{}:{hash:e.anchor}})}}),children:a.error===null?(0,h.jsxs)(`div`,{ref:l,onClick:e=>{if(e.defaultPrevented||e.button!==0||e.metaKey||e.ctrlKey)return;let t=e.target.closest(`a`),n=t?.getAttribute(`href`);if(t===null||n==null)return;let r=_b(n);if(r!==void 0){e.preventDefault(),o({to:`/help/tutorials/$page`,params:{page:r.page},...r.anchor===void 0?{}:{hash:r.anchor}});return}/^https?:/.test(n)&&(e.preventDefault(),window.open(n,`_blank`,`noopener,noreferrer`))},children:[(0,h.jsx)(EB,{markdown:p,label:`Tutorial`,what:`tutorial`,query:s,onQuery:c,anchorPrefix:`tutorial-`,children:(0,h.jsx)(`p`,{className:`m-0 text-ink-3`,children:`Loading the tutorial…`})}),i.data?.footer?(0,h.jsx)(`p`,{className:`mt-8 border-t border-line pt-4 text-small text-ink-3`,children:i.data.footer.replace(/\[([^\]]+)\]\([^)]+\)/g,`$1`)}):null]}):(0,h.jsx)(fI,{tone:`danger`,title:`This tutorial did not load`,actions:(0,h.jsx)(L,{onClick:()=>void a.refetch(),variant:`secondary`,children:`Try again`}),children:`${a.error.message} Press Try again, or pick another page on the left.`})})]})}function Mxe({index:e,page:t,onOpenHit:n}){let{api:r}=R(),[i,a]=(0,m.useState)(``),[o,s]=(0,m.useState)(``),c=(0,m.useRef)(null),l=(0,m.useId)();vx(c,`the tutorials`),(0,m.useEffect)(()=>{let e=setTimeout(()=>s(i.trim()),200);return()=>clearTimeout(e)},[i]);let u=M(RB(r,o));return(0,h.jsxs)(`nav`,{"aria-label":`Tutorials`,className:`flex min-w-0 flex-col gap-4`,children:[(0,h.jsxs)(`div`,{className:`relative`,children:[(0,h.jsx)(`label`,{htmlFor:l,className:`sr-only`,children:`Search all tutorials`}),(0,h.jsx)(Nc,{"aria-hidden":`true`,strokeWidth:1.75,className:`pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2 text-ink-3`}),(0,h.jsx)(`input`,{ref:c,id:l,type:`search`,value:i,placeholder:`Search all tutorials`,onChange:e=>a(e.target.value),onKeyDown:e=>{let t=u.data?.hits[0];e.key===`Enter`&&t!==void 0&&(e.preventDefault(),n(t,o))},className:`sl-input pl-9`})]}),o===``?e===void 0?(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-3`,children:`Loading the tutorials…`}):(0,h.jsxs)(`div`,{className:`sl-tutorials-nav flex flex-col gap-4`,children:[(0,h.jsx)(O9,{id:e.home.id,title:e.home.title,current:t}),e.groups.map(e=>(0,h.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,h.jsx)(`div`,{className:`sl-kicker px-2.5 pb-1`,children:e.title}),e.pages.map(e=>(0,h.jsx)(O9,{id:e.id,title:e.title,current:t},e.id))]},e.title))]}):(0,h.jsx)(Nxe,{query:o,hits:u.data?.hits,error:u.error?.message})]})}function O9({id:e,title:t,current:n}){return(0,h.jsx)(pa,{to:`/help/tutorials/$page`,params:{page:e},"aria-current":e===n?`page`:void 0,className:`sl-tutorials-nav__link`,children:t})}function Nxe({query:e,hits:t,error:n}){return n===void 0?t===void 0?(0,h.jsx)(`p`,{className:`m-0 text-small text-ink-3`,children:`Searching…`}):t.length===0?(0,h.jsx)(`p`,{role:`status`,className:`m-0 text-small text-ink-2`,children:`No tutorial mentions "${e}". Try fewer or other words.`}):(0,h.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,h.jsx)(`p`,{role:`status`,className:`m-0 px-2.5 text-small text-ink-3`,children:t.length===1?`1 section`:`${String(t.length)} sections`}),(0,h.jsx)(`ul`,{"aria-label":`Search results`,className:`m-0 flex list-none flex-col gap-1 p-0`,children:t.map(t=>(0,h.jsx)(`li`,{children:(0,h.jsxs)(pa,{to:`/help/tutorials/$page`,params:{page:t.page},search:{q:e},...t.anchor===``?{}:{hash:t.anchor},className:`sl-tutorials-hit`,children:[(0,h.jsx)(`span`,{className:`block font-semibold text-ink`,children:t.heading===void 0?t.pageTitle:t.heading}),t.heading===void 0?null:(0,h.jsx)(`span`,{className:`block text-label text-ink-3`,children:t.pageTitle}),(0,h.jsx)(`span`,{className:`mt-0.5 block text-small text-ink-2`,children:t.snippet})]})},`${t.page}#${t.anchor}`))})]}):(0,h.jsx)(`p`,{role:`alert`,className:`m-0 text-small text-danger`,children:`The search didn't run: ${n} Change the words or reload the page.`})}var Pxe=[{id:`library`,name:`The Library of Alexandria`,summary:`A narrated video with its two shorts, article, PDF, description and images.`,action:`Explore the sample`},{id:`audiobook`,name:`The Wind in the Willows`,summary:`An audiobook: a narrator and two character voices, captions tagged with who speaks, MP3 and M4B with chapters.`,action:`See an audiobook`},{id:`podcast`,name:`The Antikythera Mechanism`,summary:`A two-host podcast with the speaker panel, name tags and portraits, and its MP3 and M4B.`,action:`Hear a podcast`}],k9=[{id:`found`,label:`1 · What you have`},{id:`style`,label:`2 · Pick a style`},{id:`make`,label:`3 · Make your first short`}];function Fxe(e){return e.length<=2?e.join(` or `):`${e.slice(0,-1).join(`, `)} or ${e.at(-1)??``}`}function Ixe(e){return e===void 0?{ready:!1,text:`Looking for a voice…`}:e.keyed===null?e.system.available?{ready:!0,text:`Narration uses your computer's built-in voice${e.system.engine===null?``:` (${e.system.engine})`}; add an ElevenLabs or OpenAI key later for a better one.`}:{ready:!1,text:e.system.issue??`No voice can narrate yet. Add an ElevenLabs or OpenAI key in Settings → Providers.`}:{ready:!0,text:`Narration uses your ${e.keyed} voice key.`}}function Lxe(){let{api:e}=R(),t=_(),n=Xi(),r=M({queryKey:jy,queryFn:()=>Fy(e)}),[i,a]=(0,m.useState)(`found`),[o,s]=(0,m.useState)(``),[c,l]=(0,m.useState)(``),[u,d]=(0,m.useState)(void 0),f=(0,m.useRef)(void 0),p=N({mutationFn:()=>Iy(e),onSuccess:async()=>{await t.invalidateQueries({queryKey:jy}),await n({to:`/`})}}),g=N({mutationFn:t=>Ly(e,t),onSettled:()=>t.invalidateQueries({queryKey:jy})}),v=N({mutationFn:()=>(f.current??=crypto.randomUUID(),Ry(e,{topic:o,requestId:f.current,...c===``?{}:{packId:c}})),onSuccess:async({projectId:e})=>{f.current=void 0,d(e),await t.invalidateQueries({queryKey:z.projects}),await t.invalidateQueries({queryKey:z.voices})}}),y=e=>{e.preventDefault(),o.trim()!==``&&v.mutate()},b=r.data,x=b?.clis.filter(e=>e.ready)??[],S=Ixe(b?.voice),C=c===``?`General`:b?.packs.find(e=>e.id===c)?.name??c,w=v.error?{tone:`error`,text:v.error.message}:g.error?{tone:`error`,text:g.error.message}:p.error?{tone:`error`,text:p.error.message}:v.isPending?{tone:`info`,text:`Starting your short…`}:void 0,T=k9.findIndex(e=>e.id===i),E=k9[T+1],D=k9[T-1];return(0,h.jsxs)(`div`,{children:[(0,h.jsx)(Aq,{title:`Welcome to Slopify`,meta:`Make a video from a topic, with the tools already on this computer.`,actions:(0,h.jsx)(L,{variant:`quiet`,disabled:p.isPending,onClick:()=>p.mutate(),children:u===void 0?`Skip`:`Done`})}),r.error?(0,h.jsx)(fI,{tone:`danger`,title:`Could not read what this computer has`,className:`mb-6`,children:r.error.message}):null,(0,h.jsx)(C0,{items:k9.map(e=>({id:e.id,label:e.label})),value:i,onChange:a,label:`First-run steps`,idPrefix:`welcome`,className:`mb-6`}),(0,h.jsxs)(w0,{idPrefix:`welcome`,id:`found`,active:i===`found`,children:[(0,h.jsx)(V,{title:`Found on this computer`,info:`welcome.found`}),(0,h.jsxs)(hU,{label:`Tools found on this computer`,className:`mb-4`,children:[(b?.clis??[]).map(e=>(0,h.jsx)(gU,{title:e.name,actions:(0,h.jsx)(`span`,{className:`text-small text-ink-2`,children:e.ready?`Ready${e.version===null?``:` · ${e.version}`}${e.draws?` · writes and draws`:` · writes`}`:e.installed?e.issue??`Installed, not usable yet`:`Not found`})},e.id)),b===void 0?(0,h.jsx)(gU,{title:`Looking for installed tools…`}):null]}),b!==void 0&&x.length>0?(0,h.jsx)(`p`,{className:`mb-6 text-small text-ink-2`,children:`You can make a video now: no API keys are needed for ${Fxe([`the text`,...x.some(e=>e.draws)?[`the images`]:[],...S.ready&&b.voice.keyed===null?[`the narration`]:[]])}.`}):null,b!==void 0&&x.length===0?(0,h.jsx)(fI,{tone:`waiting`,className:`mb-6`,title:`Nothing on this computer can write the script yet.`,actions:(0,h.jsx)(lS,{to:`/settings`,search:{section:`providers`},children:`Open Settings → Providers`}),children:`Install Claude Code, Codex or Gemini CLI and sign in to it, then press Check again; or add an OpenRouter key in Settings → Providers.`}):null,(0,h.jsx)(V,{title:`Narration voice`,info:`welcome.voice`}),b===void 0?(0,h.jsx)(hU,{label:`Narration voice`,className:`mb-6`,children:(0,h.jsx)(gU,{title:`Looking for a voice…`})}):(0,h.jsx)(A9,{voice:S,checking:r.isFetching,onCheck:()=>void r.refetch()})]}),(0,h.jsxs)(w0,{idPrefix:`welcome`,id:`style`,active:i===`style`,children:[(0,h.jsx)(V,{title:`Pick a style`,info:`welcome.pack`}),(0,h.jsx)(hU,{label:`Styles`,className:`mb-3 [&_.sl-row__meta]:whitespace-normal`,children:[{id:``,name:`General`,summary:`A neutral explainer style.`,installed:!1,library:!1},...(b?.packs??[]).map(e=>({...e,library:!0}))].map(e=>(0,h.jsx)(gU,{title:e.name,meta:e.summary,selected:c===e.id,actions:(0,h.jsxs)(h.Fragment,{children:[e.library?(0,h.jsx)(L,{variant:`quiet`,disabled:e.installed||g.isPending,"aria-label":e.installed?`${e.name} is in your library`:`Add ${e.name} to library`,onClick:()=>g.mutate(e.id),children:e.installed?`In your library`:`Add to library`}):null,(0,h.jsx)(L,{variant:c===e.id?`primary`:`secondary`,"aria-pressed":c===e.id,"aria-label":`Use ${e.name}`,onClick:()=>l(e.id),children:c===e.id?`Picked`:`Use this style`})]})},e.id===``?`general`:e.id))}),(0,h.jsxs)(`p`,{className:`mb-6 flex items-center gap-1 text-small text-ink-2`,...Tb,children:[`Add to library keeps a pack's prompts and Play template for later videos.`,(0,h.jsx)(B,{id:`welcome.packs`,className:`-my-1`})]})]}),(0,h.jsxs)(w0,{idPrefix:`welcome`,id:`make`,active:i===`make`,children:[u===void 0?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(V,{title:`Make a 60-second short`,info:`welcome.short`}),(0,h.jsxs)(`p`,{className:`mb-3 text-small text-ink-2`,children:[`Style: ${C}. `,S.text]}),S.ready||b===void 0?null:(0,h.jsx)(`div`,{className:`mb-4`,children:(0,h.jsx)(A9,{voice:S,checking:r.isFetching,onCheck:()=>void r.refetch()})}),(0,h.jsxs)(`form`,{onSubmit:y,className:`mb-6 flex flex-wrap items-end gap-3`,children:[(0,h.jsxs)(`div`,{className:`flex min-w-[240px] flex-1 flex-col gap-1`,...Tb,children:[(0,h.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,h.jsx)(`label`,{htmlFor:`welcome-topic`,className:`text-label text-ink-2`,children:`Topic`}),(0,h.jsx)(B,{id:`welcome.topic`,className:`-my-1`})]}),(0,h.jsx)(SV,{id:`welcome-topic`,value:o,maxLength:200,placeholder:`Why the sea glows at night`,onChange:e=>s(e.target.value)})]}),(0,h.jsx)(L,{type:`submit`,variant:`primary`,disabled:o.trim()===``||v.isPending,disabledReason:`Type a topic first.`,children:`Make a 60-second short`})]})]}):(0,h.jsx)(fI,{tone:`info`,className:`mb-6`,title:`Your short is being made.`,actions:(0,h.jsx)(lS,{variant:`primary`,to:`/projects/$projectId`,params:{projectId:u},children:`Watch it being made`}),children:`It usually takes about five minutes. The live view shows each step as it runs; while you wait, look at a sample or set Slopify to start when you log in.`}),(0,h.jsx)(V,{title:`While you wait: the samples`,info:`welcome.samples`}),(0,h.jsx)(hU,{label:`Samples`,className:`mb-6 [&_.sl-row__meta]:whitespace-normal`,children:Pxe.map(e=>{let t=b?.samples[e.id]??null;return(0,h.jsx)(gU,{title:e.name,meta:e.summary,actions:t===null?(0,h.jsx)(uS,{to:`/settings`,search:{section:`storage`},children:`Restore samples in Settings`}):(0,h.jsx)(lS,{to:`/projects/$projectId`,params:{projectId:t},className:mU,children:e.action})},e.id)})}),(0,h.jsx)(Rb,{})]}),(0,h.jsxs)(y0,{status:(0,h.jsx)(v0,{tone:w?.tone??`info`,children:w?.text}),children:[(0,h.jsx)(uS,{to:`/play`,children:`Set up a long video instead`}),D===void 0?null:(0,h.jsx)(L,{onClick:()=>a(D.id),children:`Back`}),E===void 0?null:(0,h.jsx)(L,{variant:`primary`,onClick:()=>a(E.id),children:`Next: ${E.label.replace(/^\d · /,``)}`})]})]})}function A9({voice:e,checking:t,onCheck:n}){return e.ready?(0,h.jsx)(hU,{label:`Narration voice`,className:`mb-6 [&_.sl-row__title]:whitespace-normal`,children:(0,h.jsx)(gU,{lead:(0,h.jsx)(pS,{tone:`done`}),title:e.text,actions:(0,h.jsx)(lS,{variant:`quiet`,to:`/settings`,search:{section:`providers`},children:`Add a voice key`})})}):(0,h.jsx)(fI,{tone:`waiting`,className:`mb-6`,title:`No voice can narrate the short yet.`,actions:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(lS,{variant:`primary`,to:`/settings`,search:{section:`providers`},children:`Add a voice key`}),(0,h.jsx)(L,{disabled:t,onClick:n,children:t?`Checking…`:`Check again`})]}),children:e.text})}var j9=_a({component:rV}),Rxe=ha({getParentRoute:()=>j9,path:`/`,component:Bpe}),M9=ha({getParentRoute:()=>j9,path:`projects`,validateSearch:e=>{let t=Jye(e.show);return t===void 0?{}:{show:t}},component:zxe});function zxe(){let{show:e}=M9.useSearch();return(0,h.jsx)(Zye,{initialFilter:e??`all`},e??`all`)}var Bxe=ha({getParentRoute:()=>j9,path:`welcome`,component:Lxe}),Vxe=ha({getParentRoute:()=>j9,path:`play`,component:Nhe}),N9=ha({getParentRoute:()=>j9,id:`_library`,component:qfe}),Hxe=ha({getParentRoute:()=>j9,path:`library`,beforeLoad:()=>{throw Vn({to:`/prompts`,search:{kind:`article`}})}}),Uxe=ha({getParentRoute:()=>j9,path:`channels`,component:wfe}),P9=ha({getParentRoute:()=>j9,path:`channels/$channelId`,validateSearch:e=>e.tab===void 0?{}:{tab:Sfe(e.tab)},component:Wxe});function Wxe(){let{channelId:e}=P9.useParams(),{tab:t}=P9.useSearch(),n=Xi();return(0,h.jsx)(Cfe,{channelId:e,tab:t??`brand`,onTab:t=>{n({to:`/channels/$channelId`,params:{channelId:e},search:{tab:t},replace:!0})}},e)}var Gxe=ha({getParentRoute:()=>N9,path:`templates`,component:Xxe}),Kxe=/^[0-9A-Za-z-]{1,64}$/;function F9(e){return zde(e.tab)===`schedules`?typeof e.schedule==`string`&&Kxe.test(e.schedule)?{tab:`schedules`,schedule:e.schedule}:{tab:`schedules`}:{}}var I9=ha({getParentRoute:()=>j9,path:`calendar`,validateSearch:F9,component:Yxe}),qxe=ha({getParentRoute:()=>j9,path:`schedules`,beforeLoad:()=>{throw Vn({to:`/calendar`,search:{tab:`schedules`},replace:!0})}}),Jxe=ha({getParentRoute:()=>j9,path:`schedules/$scheduleId`,beforeLoad:({params:e})=>{throw Vn({to:`/calendar`,search:F9({tab:`schedules`,schedule:e.scheduleId}),replace:!0})}});function Yxe(){let e=F9(I9.useSearch()),t=Xi();return(0,h.jsx)(Vde,{tab:e.tab??`weeks`,schedule:e.schedule,onTab:e=>{t({to:`/calendar`,search:e===`schedules`?{tab:`schedules`}:{},replace:!0})},onSchedule:e=>{t({to:`/calendar`,search:{tab:`schedules`,schedule:e},replace:!0})}})}function Xxe(){let e=cP(),t=Xi();return(0,h.jsx)(Axe,{getGeneration:e.generation,blocked:e.review.starting||e.review.uncertain||e.review.created!==null,beforeApply:e.flush,onApplied:async(n,r)=>!r()||!await e.open(n,r)||!r()?!1:(await t({to:`/play`}),r())})}var L9=ha({getParentRoute:()=>j9,path:`projects/$projectId`,component:aSe}),R9=ha({getParentRoute:()=>N9,path:`prompts`,validateSearch:e=>({kind:xV(e.kind)}),component:oSe}),z9=ha({getParentRoute:()=>j9,path:`prompts/new`,validateSearch:e=>{let t=xV(e.kind);return typeof e.from==`string`?{kind:t,from:e.from}:{kind:t}},component:sSe}),B9=ha({getParentRoute:()=>j9,path:`prompts/$promptId`,component:cSe}),V9=ha({getParentRoute:()=>N9,path:`entries`,validateSearch:e=>({category:vV(e.category)}),component:lSe}),H9=ha({getParentRoute:()=>j9,path:`entries/new`,validateSearch:e=>{let t=vV(e.category);return typeof e.from==`string`?{category:t,from:e.from}:{category:t}},component:X9}),U9=ha({getParentRoute:()=>j9,path:`entries/$entryId`,component:uSe}),Zxe=ha({getParentRoute:()=>N9,path:`narration-aliases`,component:Hpe}),Qxe=ha({getParentRoute:()=>N9,path:`document-themes`,component:Yfe}),W9=ha({getParentRoute:()=>j9,path:`document-themes/new`,validateSearch:e=>typeof e.from==`string`?{from:e.from}:{},component:dSe}),G9=ha({getParentRoute:()=>j9,path:`document-themes/$themeId`,component:fSe});function $xe(e){let t=e.section===void 0?void 0:vxe(e.section),n=t===`patch-notes`&&typeof e.note==`string`&&/^[0-9A-Za-z][0-9A-Za-z.-]{0,63}$/.test(e.note)?e.note:void 0;return{...t===void 0?{}:{section:t},...n===void 0?{}:{note:n}}}var K9=ha({getParentRoute:()=>j9,path:`settings`,validateSearch:$xe,component:iSe}),q9=ha({getParentRoute:()=>j9,path:`help/tutorials/$page`,validateSearch:e=>typeof e.q==`string`&&e.q.trim()!==``?{q:e.q.slice(0,200)}:{},component:eSe});function eSe(){let{page:e}=q9.useParams(),{q:t}=q9.useSearch(),n=za({select:e=>e.hash});return(0,h.jsx)(jxe,{page:e,anchor:n===``?void 0:n,words:t})}var tSe=ha({getParentRoute:()=>j9,path:`help`,beforeLoad:()=>{throw Vn({to:`/help/tutorials/$page`,params:{page:`Home`}})}}),nSe=ha({getParentRoute:()=>j9,path:`help/tutorials`,beforeLoad:()=>{throw Vn({to:`/help/tutorials/$page`,params:{page:`Home`}})}}),rSe=ha({getParentRoute:()=>j9,path:`usage`,beforeLoad:()=>{throw Vn({to:`/settings`,search:{section:`usage`}})}});function iSe(){let{section:e,note:t}=K9.useSearch(),n=Xi();return(0,h.jsx)(bxe,{section:e??`providers`,note:t,onSection:e=>{n({to:`/settings`,search:{section:e},replace:!0})},onNote:e=>{n({to:`/settings`,search:{section:`patch-notes`,...e===void 0?{}:{note:e}}})}})}function aSe(){let{projectId:e}=L9.useParams(),t=cP(),n=Xi();return(0,h.jsx)(Hye,{projectId:e,openDraft:async e=>!await t.flush()||!await t.open(e)?!1:(await n({to:`/play`}),!0)},e)}function oSe(){let{kind:e}=R9.useSearch(),t=Xi(),n=J9();return(0,h.jsx)(nbe,{kind:e,onKind:e=>{t({to:`/prompts`,search:{kind:e},replace:!0})},onUseInPlay:n.use,playBlocked:n.blocked})}function J9(){let e=cP(),t=Xi();return{blocked:e.review.starting||e.review.uncertain||e.review.created!==null?`Play is starting a run from its draft. Wait for it to start, then try again.`:void 0,use:n=>{let r=eH(e.document,n);e.edit(r.document),t({to:`/play`}).then(()=>e.navigate(r.section,r.field))}}}function sSe(){let{kind:e,from:t}=z9.useSearch(),n=Y9();return(0,h.jsx)(J7,{promptId:void 0,kind:e,from:t,onLeave:n},`${e}:${t??`new`}`)}function cSe(){let{promptId:e}=B9.useParams(),t=Y9();return(0,h.jsx)(J7,{promptId:e,kind:`article`,from:void 0,onLeave:t},e)}function Y9(){let e=Xi();return t=>{e({to:`/prompts`,search:{kind:t}})}}function lSe(){let{category:e}=V9.useSearch(),t=Xi(),n=J9();return(0,h.jsx)(Xfe,{category:e,onCategory:e=>{t({to:`/entries`,search:{category:e},replace:!0})},onUseInPlay:n.use,playBlocked:n.blocked})}function X9(){let{category:e,from:t}=H9.useSearch(),n=Q9();return(0,h.jsx)(T3,{entryId:void 0,category:e,from:t,onLeave:n})}function uSe(){let{entryId:e}=U9.useParams(),t=Q9();return(0,h.jsx)(T3,{entryId:e,category:`intro`,from:void 0,onLeave:t})}function dSe(){let{from:e}=W9.useSearch(),t=Z9();return(0,h.jsx)(P4,{themeId:void 0,from:e,onLeave:t})}function fSe(){let{themeId:e}=G9.useParams(),t=Z9();return(0,h.jsx)(P4,{themeId:e,from:void 0,onLeave:t})}function Z9(){let e=Xi();return()=>{e({to:`/document-themes`})}}function Q9(){let e=Xi();return t=>{e({to:`/entries`,search:{category:t}})}}var pSe=j9.addChildren({homeRoute:Rxe,projectsRoute:M9,welcomeRoute:Bxe,playRoute:Vxe,libraryRoute:N9.addChildren({promptsRoute:R9,entriesRoute:V9,templatesRoute:Gxe,documentThemesRoute:Qxe,narrationAliasesRoute:Zxe}),schedulesRoute:qxe,scheduleRoute:Jxe,calendarRoute:I9,libraryIndexRoute:Hxe,channelsRoute:Uxe,channelRoute:P9,projectRoute:L9,newPromptRoute:z9,promptRoute:B9,newEntryRoute:H9,entryRoute:U9,newDocumentThemeRoute:W9,documentThemeRoute:G9,settingsRoute:K9,usageRoute:rSe,helpRoute:tSe,tutorialsIndexRoute:nSe,tutorialsRoute:q9});function mSe(){return Pa({routeTree:pSe})}function hSe(){let e,t,n=new Set;return{observe:r=>{if(e===void 0){e=r;for(let e of n)e();return}if(r!==e&&r!==t){t=r;for(let e of n)e()}},staleAt:()=>t,loadedAt:()=>e,subscribe:e=>(n.add(e),()=>{n.delete(e)})}}function gSe(e,t){return async(n,r)=>{let i=await e(n,r),a=i.headers.get(`X-Slopify-Version`);return a!==null&&t.observe(a),i}}function _Se(e){let t=hSe(),n={api:bo(window.location.origin,gSe(window.fetch.bind(window),t),So(e=>{let n=e.headers.get(`X-Slopify-Version`);n!==null&&t.observe(n)})),openEvents:e=>new EventSource(e),version:t};(0,ao.createRoot)(e).render((0,h.jsx)(m.StrictMode,{children:(0,h.jsx)(v,{client:new Ye,children:(0,h.jsx)(ite,{deps:n,children:(0,h.jsx)(La,{router:mSe()})})})}))}var $9=document.getElementById(`root`);if($9===null)throw Error(`index.html carries no #root element for the app to mount on`);_Se($9);export{v4 as t};