@gentbajko/slopify 1.3.1 → 1.4.0

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.
@@ -99,39 +99,39 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
99
99
  `,r+2),a=i===-1?e.length:i,o=e.indexOf(fM,r+2);if(o===-1||o>a){n.push({kind:`unclosed`,at:r}),r=e.indexOf(dM,r+2);continue}let s=e.slice(r+2,o),c=s.trim();s.includes(`{`)||s.includes(`}`)?n.push({kind:`nested`,at:r}):c===``?n.push({kind:`empty`,at:r}):t.includes(c)||t.push(c),r=e.indexOf(dM,o+2)}return{names:t,errors:n}}function mM(e,t){let n=gM(e),r=gM(t),i=[];for(let e of[...n,...r]){if(i.some(t=>t.name===e))continue;let t=n.includes(e),a=r.includes(e);i.push({name:e,group:t&&a?`common`:t?`text`:`image`})}return i}function hM(e,t){return e.replace(uM,(e,n)=>{let r=n.trim(),i=Object.hasOwn(t,r)?t[r]:void 0;return i===void 0?e:i})}function gM(e){let t=[];for(let n of e)for(let e of pM(n).names)t.includes(e)||t.push(e);return t}function _M(e){return yM(e.name,e.body)}function vM(e){return yM(e.name,e.body)}function yM(e,t){let n=[],r=e.trim();if(r===``?n.push({field:`name`,message:`A name is required.`}):r.length>200&&n.push({field:`name`,message:`A name is at most 200 characters.`}),t.trim()===``)return n.push({field:`body`,message:`A body is required.`}),n;if(t.length>1e5)return n.push({field:`body`,message:`A body is at most ${String(sO)} characters.`}),n;for(let e of pM(t).errors)n.push({field:`body`,message:bM(e,t)});return n}function bM(e,t){let n=xM(t,e.at);switch(e.kind){case`unclosed`:return`The \`{{\` at ${n} is never closed.`;case`empty`:return`The slot at ${n} has no name.`;case`nested`:return`The slot at ${n} holds a brace; slots do not nest.`}}function xM(e,t){let n=e.slice(0,t),r=n.lastIndexOf(`
100
100
  `),i=n.split(`
101
101
  `).length,a=t-r;return`line ${String(i)}, column ${String(a)}`}function SM(e,t){return[...`kind`in e?_M(e):vM(e),...t]}function CM(e){return e[0]?.message}function wM(e){return e.filter(e=>e.field===`body`)}function TM(e){return e.filter(e=>e.field===`name`)}function EM(e){return pM(e).names}function DM(e){let t=[],n=0;for(let r of pM(e).errors){if(r.at<n)continue;r.at>n&&t.push({start:n,text:e.slice(n,r.at),marked:!1});let i=Math.min(r.at+2,e.length);t.push({start:r.at,text:e.slice(r.at,i),marked:!0}),n=i}return n<e.length&&t.push({start:n,text:e.slice(n),marked:!1}),t}var OM=`px-3 py-[10px] font-sans text-body leading-[1.5] break-words [scrollbar-gutter:stable]`;function kM({id:e,value:t,invalid:n,describedBy:r,onChange:i}){let a=(0,m.useRef)(null);return(0,h.jsxs)(`div`,{className:`relative max-w-[75ch]`,children:[(0,h.jsxs)(`div`,{ref:a,"aria-hidden":`true`,"data-slot":`lint-overlay`,className:z(OM,`pointer-events-none absolute inset-0 overflow-hidden whitespace-pre-wrap`,`rounded-control border border-transparent bg-panel2 text-ink`),children:[DM(t).map(e=>(0,h.jsx)(`span`,{"data-lint-mark":e.marked?e.start:void 0,className:e.marked?`text-red underline decoration-red decoration-2 underline-offset-[3px]`:void 0,children:e.text},e.start)),`
102
- `]}),(0,h.jsx)(lM,{id:e,rows:24,value:t,spellCheck:!1,"aria-invalid":n,"aria-describedby":r,className:z(OM,`relative block min-h-[520px] resize-y overflow-auto bg-transparent text-transparent caret-ink`),onChange:e=>{i(e.target.value)},onScroll:e=>{let t=a.current;t!==null&&(t.scrollTop=e.currentTarget.scrollTop,t.scrollLeft=e.currentTarget.scrollLeft)}})]})}function AM({entryId:e,category:t,from:n,onLeave:r}){let{api:i}=I(),a=_(),o=nt(xy(i)),s=(0,m.useId)(),c=(0,m.useId)(),l=(0,m.useId)(),u=(0,m.useId)(),d=(0,m.useId)(),f=(0,m.useId)(),[p,g]=(0,m.useState)(void 0),[v,y]=(0,m.useState)([]),[b,x]=(0,m.useState)(!1),[S,C]=(0,m.useState)(!1),w=o.data?.entries,T=e??n,E=T===void 0?void 0:w?.find(e=>e.id===T),D=E===void 0?{category:t,mode:`text`,name:``,body:``}:{category:E.category,mode:E.mode,name:e===void 0?`${E.name} copy`:E.name,body:E.body},O=p??D,ee=it({mutationFn:t=>Po(i,t,e),onSuccess:async e=>{if(!e.ok){y(e.fields);return}x(!0),await a.invalidateQueries({queryKey:xy(i).queryKey})}}),k=it({mutationFn:e=>Fo(i,e),onSuccess:async()=>{C(!1),await a.invalidateQueries({queryKey:xy(i).queryKey}),r(O.category)}});$j(b,()=>{r(O.category)});let A=(e,t)=>{g(e),y(e=>e.filter(e=>e.field!==t))},j=SM(O,v),M=CM(j),N=EM(O.body),P=O.body.trim()===``?[]:wM(j),F=O.name.trim()===``?[]:TM(j);return o.error===null?T!==void 0&&w===void 0?(0,h.jsx)(rM,{}):T!==void 0&&E===void 0?(0,h.jsx)(jM,{category:t,children:`That entry is gone. It may have been deleted in another tab.`}):(0,h.jsxs)(`div`,{className:`mx-auto max-w-[1440px]`,children:[(0,h.jsxs)(sa,{to:`/entries`,search:{category:O.category},className:`mb-[10px] inline-flex items-center gap-1 text-small text-ink2 hover:text-ink`,children:[(0,h.jsx)(YA,{"aria-hidden":`true`,className:`size-[14px]`}),`Intros & Outros`]}),(0,h.jsx)(`h1`,{className:`mb-4 text-title font-bold tracking-[-0.01em]`,children:e===void 0?`New entry`:`Edit entry`}),(0,h.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)] items-start gap-6 lg:grid-cols-[minmax(0,1fr)_360px]`,children:[(0,h.jsxs)(`div`,{className:`${nM} flex min-w-0 flex-col gap-[14px]`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-end gap-[14px]`,children:[(0,h.jsxs)(`div`,{className:`min-w-[200px] flex-1`,children:[(0,h.jsx)(oM,{htmlFor:s,className:`mb-[5px]`,children:`Name`}),(0,h.jsx)(cM,{id:s,value:O.name,"aria-invalid":F.length>0,"aria-describedby":F.length===0?void 0:c,onChange:e=>{A({...O,name:e.target.value},`name`)}}),F.length===0?null:(0,h.jsx)(`p`,{id:c,className:`mt-1 text-label text-red`,children:F.map(e=>e.message).join(` `)})]}),(0,h.jsx)(sM,{label:`Category`,value:O.category,options:Cj,onPick:e=>{A({...O,category:e},`name`)}}),(0,h.jsx)(sM,{label:`Mode`,value:O.mode,options:wj,describedBy:l,onPick:e=>{A({...O,mode:e},`mode`)}})]}),(0,h.jsx)(`p`,{id:l,className:`-mt-[6px] text-right text-small text-ink2`,children:Dj(O.mode)}),(0,h.jsxs)(`div`,{children:[(0,h.jsx)(oM,{htmlFor:u,className:`mb-[5px]`,children:`Body`}),(0,h.jsx)(kM,{id:u,value:O.body,invalid:P.length>0,describedBy:P.length===0?void 0:d,onChange:e=>{A({...O,body:e},`body`)}})]}),(0,h.jsx)(tM,{onDelete:e===void 0?void 0:()=>{C(!0)},blocked:M,blockedId:f,pending:ee.isPending,saved:b,cancel:(0,h.jsx)(B,{asChild:!0,children:(0,h.jsx)(sa,{to:`/entries`,search:{category:O.category},children:`Cancel`})}),errors:[ee.error,k.error].flatMap(e=>e===null?[]:[e.message]),onSave:()=>{ee.mutate(O)}})]}),(0,h.jsx)(`div`,{className:`${nM} flex flex-col gap-3 lg:sticky lg:top-6`,children:(0,h.jsx)(Zj,{slots:N,body:O.body,lint:P,lintId:d,noSlots:Oj(O.mode)})})]}),(0,h.jsx)(Nj,{open:S,title:`Delete "${O.name}"?`,consequence:`Projects that used it keep their text.`,verb:`Delete`,pending:k.isPending,onConfirm:()=>{e!==void 0&&k.mutate(e)},onCancel:()=>{C(!1)}})]}):(0,h.jsx)(jM,{category:O.category,children:o.error.message})}function jM({category:e,children:t}){return(0,h.jsx)(iM,{back:(0,h.jsx)(sa,{to:`/entries`,search:{category:e},className:aM,children:`Back to Intros & Outros`}),children:t})}function MM(e,t){let n={...eO,...e},r=t.audio===`off`?`off`:(t.video===`off`||t.images===`off`)&&n.mode===`burn-in`?`files`:n.mode;if(r!==`off`)return{...n,mode:r};let i=$D.shape.fontId.safeParse(n.fontId),a=$D.shape.fontSize.safeParse(n.fontSize);return{...n,mode:r,fontId:i.success?i.data:eO.fontId,fontSize:a.success?a.data:eO.fontSize}}function NM(e){return e.mode===`off`||e.fontId!==``&&Number.isInteger(e.fontSize)&&e.fontSize>=16&&e.fontSize<=120}({...ck.form});var PM={off:`Off`,generate:`Generate`,provide:`Provide`,from_prompt:`From prompt`,prompt_by_llm:`Prompt by LLM`};function FM(e){return ZO[e].map(e=>({value:e,label:PM[e]}))}function IM(e,t){return ak(e)||e.sources.article===`generate`||e.sources.thumbnail===`prompt_by_llm`||e.sources.audio===`generate`&&(LM(t,`intro`,e.intro)===`llm`||LM(t,`outro`,e.outro)===`llm`)}function LM(e,t,n){if(n!==``)return e.find(e=>e.category===t&&e.name===n)?.mode}function RM(e){return[e.audio,e.thumbnail,...e.images].flatMap(e=>e?.file===void 0?[]:[e.file])}function zM(e){let{form:t}=e;return{...t.checkpoints===void 0?{}:{checkpoints:t.checkpoints},title:t.title,format:t.format,sources:{...t.sources,...t.sources.article===`provide`?{research:`off`}:{},...t.sources.images===`off`?{video:`off`}:{}},llm:t.llm,audio:t.audio,images:t.images,articlePrompt:t.articlePrompt,...t.narrationPrompt===void 0?{}:{narrationPrompt:t.narrationPrompt},imagePrompts:t.imagePrompts,thumbnailPrompt:t.thumbnailPrompt,...BM(VM(e,`intro`),e=>({intro:e})),...BM(VM(e,`outro`),e=>({outro:e})),values:HM(t.values,e.slots),provided:{research:t.provided.research,article:t.provided.article,...BM(t.provided.audio?.file,e=>({audio:e.id})),...BM(t.provided.thumbnail?.file,e=>({thumbnail:e.id})),images:t.provided.images.flatMap(e=>e.file===void 0?[]:[e.file.id])},chunking:t.chunking,subtitles:MM(t.subtitles,t.sources),silenceGapSeconds:e.silenceGapSeconds}}function BM(e,t){return e===void 0?{}:t(e)}function VM(e,t){if(e.form.sources.audio!==`generate`)return;let n=t===`intro`?e.form.intro:e.form.outro,r=LM(e.entries,t,n);return n===``||r===void 0?void 0:{name:n,mode:r}}function HM(e,t){let n=Object.create(null);for(let r of t)n[r]=Object.hasOwn(e,r)?e[r]??``:``;return n}function UM(e){let{form:t}=e,n=[],r=[];if(ak(t)&&QM(n,XM(e.prompts,`narration`,t.narrationPrompt??``)),t.sources.article===`generate`&&QM(n,XM(e.prompts,`article`,t.articlePrompt)),t.sources.audio===`generate`&&(QM(n,ZM(e.entries,`intro`,t.intro)),QM(n,ZM(e.entries,`outro`,t.outro))),t.sources.images===`generate`)for(let n of t.imagePrompts)QM(r,XM(e.prompts,`image`,n.name));return(t.sources.thumbnail===`from_prompt`||t.sources.thumbnail===`prompt_by_llm`)&&QM(r,XM(e.prompts,`thumbnail`,t.thumbnailPrompt)),mM(n,r)}function WM(e){let t=UM(e),n={form:e.form,entries:e.entries,slots:t.map(e=>e.name),silenceGapSeconds:e.silenceGapSeconds},r=zM(n),i=QO({draft:r,staged:RM(e.form.provided),requiredSlots:n.slots}),a=NM(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:KM(e.form,a)}}var GM=[`sources`,`provided.research`,`articlePrompt`,`provided.article`,`audio`,`provided.audio`,`narrationPrompt`,`imagePrompts`,`images`,`provided.images`,`thumbnailPrompt`,`provided.thumbnail`,`subtitles`,`title`,`intro`,`outro`,`llm`,`values`,`silenceGapSeconds`];function KM(e,t){let n=qM(e);if(n!==void 0)return n;if(t.ok)return;let r=[...t.fields].sort((e,t)=>JM(e.field)-JM(t.field))[0];return r===void 0?void 0:{field:r.field,hint:YM(e,r)}}function qM(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),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 JM(e){let t=GM.length;for(let[n,r]of GM.entries())(e===r||e.startsWith(`${r}.`))&&n<t&&(t=n);return t}function YM(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`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`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`;default:return t.message}}function XM(e,t,n){if(n!==``)return e.find(e=>e.kind===t&&e.name===n)?.body}function ZM(e,t,n){if(n!==``)return e.find(e=>e.category===t&&e.name===n)?.body}function QM(e,t){t!==void 0&&e.push(t)}function $M(e){let t=new Map,n=(e,n)=>{if(e)for(let r of pM(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(ak(r)&&n(XM(i,`narration`,r.narrationPrompt??``),`Narration Preparation`),r.sources.article===`generate`&&n(XM(i,`article`,r.articlePrompt),`Article`),r.sources.images===`generate`)for(let e of r.imagePrompts)n(XM(i,`image`,e.name),`Image: ${e.name}`);if((r.sources.thumbnail===`from_prompt`||r.sources.thumbnail===`prompt_by_llm`)&&n(XM(i,`thumbnail`,r.thumbnailPrompt),`Thumbnail`),r.sources.audio===`generate`)for(let e of[`intro`,`outro`])n(ZM(a,e,r[e]),e===`intro`?`Intro`:`Outro`);return t}var eN=[{stage:`audio`,label:`Audio`},{stage:`images`,label:`Images`},{stage:`video`,label:`Video / export`}];function tN(e,t){if(e!==`checkpoints`&&!e.startsWith(`checkpoints.`))return;let n=e.slice(12),r=/^\d+$/.test(n)?t.checkpoints?.[Number(n)]:n;return{section:`outputs`,field:eN.some(e=>e.stage===r)?`checkpoints.${r}`:`checkpoints`}}function nN({problem:e}){let t=Ek(),{document:n,review:r}=t,{form:i}=n,a=(0,m.useId)(),o=i.checkpoints??[];return(0,h.jsxs)(`fieldset`,{"data-play-field":`checkpoints`,tabIndex:-1,"aria-invalid":e(`checkpoints`)!==void 0,disabled:r.starting||r.uncertain,className:`min-w-0 border-b border-line py-6`,children:[(0,h.jsx)(`legend`,{className:`text-lg font-semibold`,children:`Review checkpoints`}),(0,h.jsx)(`p`,{className:`mb-3 text-small text-ink2`,children:`Hold a step so you can review and edit before it runs. Independent steps continue. Approve each checkpoint on the project page when you are ready.`}),eN.map(({stage:r,label:s})=>{let c=o.includes(r),l=r===`video`?i.sources.video!==`off`&&i.sources.images!==`off`||i.sources.audio!==`off`:i.sources[r]===`generate`,u=e(`checkpoints.${r}`),d=`${a}-${r}`;return(0,h.jsxs)(`div`,{children:[(0,h.jsxs)(`label`,{htmlFor:d,className:`flex min-h-10 items-center gap-3 max-[1099px]:min-h-11`,children:[(0,h.jsx)(`input`,{id:d,type:`checkbox`,"data-play-field":`checkpoints.${r}`,"aria-invalid":u!==void 0,"aria-describedby":`${d}-detail`,checked:c,disabled:!l&&!c,className:`size-4 accent-accent`,onChange:e=>{let a=e.target.checked?[...o,r]:o.filter(e=>e!==r);t.edit({...n,form:{...i,checkpoints:a}}),t.invalidateReview(!0)}}),`Before `,s]}),(0,h.jsx)(`p`,{id:`${d}-detail`,className:`pb-2 pl-7 text-small ${u?`text-red`:`text-ink3`}`,children:u??(l?`Approval required before this step and its dependents run.`:c?`This step is unavailable. Remove its checkpoint or enable the step.`:r===`video`?`Enable Video or Audio to review before export.`:`Choose Generate for ${s} to add this checkpoint.`)})]},r)}),e(`checkpoints`)?(0,h.jsx)(`p`,{className:`text-small text-red`,children:e(`checkpoints`)}):null]})}function rN({fields:e,values:t,origins:n,problem:r,onChange:i}){return e.length?(0,h.jsxs)(`section`,{"data-tour":`play-keywords`,className:`min-w-0 py-6`,children:[(0,h.jsx)(`h3`,{className:`mb-2 text-lg font-semibold`,children:`Keywords`}),(0,h.jsxs)(`p`,{className:`mb-5 text-small text-ink3`,children:[`Each keyword is entered once. For example, `,`{{topic}}`,` becomes the topic you enter below.`]}),(0,h.jsx)(`div`,{className:`flex flex-col gap-4`,children:e.map(e=>(0,h.jsx)(iN,{name:e.name,value:Object.hasOwn(t,e.name)?t[e.name]??``:``,origins:n?.get(e.name),problem:r(`values.${e.name}`),onChange:i},e.name))})]}):null}function iN({name:e,origins:t,value:n,problem:r,onChange:i}){let a=(0,m.useId)(),o=(0,m.useId)();return(0,h.jsxs)(`div`,{className:`min-w-0`,children:[(0,h.jsx)(oM,{htmlFor:a,className:`mb-[5px]`,children:e}),(0,h.jsx)(cM,{id:a,"data-play-field":`values.${e}`,value:n,maxLength:200,spellCheck:!1,"aria-invalid":r!==void 0,"aria-describedby":r===void 0?void 0:o,onChange:t=>{i(e,t.target.value)}}),t?.length?(0,h.jsx)(`p`,{className:`mt-1 text-small text-ink3`,children:t.join(` · `)}):null,r===void 0?null:(0,h.jsx)(`p`,{id:o,className:`mt-1 text-label text-red`,children:r})]})}function aN({className:e,children:t,...n}){return(0,h.jsxs)(`span`,{className:`relative inline-flex min-w-0 items-center`,children:[(0,h.jsx)(`select`,{"data-slot":`picker`,className:z(`h-8 w-full min-w-0 appearance-none rounded-control border border-line2 bg-panel2`,`py-[5px] pr-[26px] pl-[10px] text-small text-ink aria-invalid:border-red`,e),...n,children:t}),(0,h.jsx)(JA,{"aria-hidden":`true`,className:`pointer-events-none absolute right-[8px] size-[14px] text-ink2`})]})}var oN=e=>[`provider-models`,e];async function sN(e,t,n=!1,r){let i=`${e.origin}/api/providers/${encodeURIComponent(t)}/models${n?`?refresh=1`:``}`;return eo(await e.fetch(i,r?{signal:r}:void 0))}function cN(e,t){return rt({queryKey:oN(t),queryFn:({signal:n})=>sN(e,t,!1,n),enabled:t!==``,staleTime:3e4,refetchInterval:3e4,retry:!1})}function lN(e){return e!==``&&e!==`fal`&&e!==`replicate`}function uN({label:e,field:t,problem:n,inline:r=!1,children:i}){let a=(0,m.useId)(),o=(0,m.useId)();return(0,h.jsxs)(`div`,{className:z(r?`flex min-w-0 max-w-full items-center gap-[10px]`:`min-w-0 [&>span]:w-full`),children:[(0,h.jsx)(oM,{htmlFor:a,className:r?`shrink-0`:`mb-[5px]`,children:e}),i({field:t,id:a,describedBy:n===void 0?void 0:o}),n===void 0?null:(0,h.jsx)(`p`,{id:o,className:z(`text-label text-red`,r?``:`mt-1`),children:n})]})}function dN({label:e,field:t,value:n,problem:r,inline:i,placeholder:a,options:o,disabled:s=!1,onPick:c}){return(0,h.jsx)(uN,{field:t,label:e,problem:r,inline:i,children:({id:e,describedBy:l})=>(0,h.jsxs)(aN,{id:e,"data-play-field":t,value:n,disabled:s,"aria-invalid":r!==void 0,"aria-describedby":l,className:i===!0?`w-auto min-w-[120px]`:void 0,onChange:e=>{c(e.target.value)},children:[(0,h.jsx)(`option`,{value:``,children:a}),n!==``&&!o.some(e=>e.value===n)?(0,h.jsxs)(`option`,{value:n,children:[n,` (saved choice)`]}):null,o.map(e=>(0,h.jsx)(`option`,{value:e.value,disabled:e.disabled===!0,children:e.label},e.value))]})})}function fN(e,t){return e.filter(e=>e.family===t).map(e=>{let t=pN(e);return{value:e.id,label:t===void 0?e.displayName:`${e.displayName} · ${t}`,disabled:t!==void 0}})}function pN(e){let{readiness:t}=e;return t.kind===`cli`?t.issue===void 0?Rk(t)?void 0:`CLI missing`:`CLI update required`:t.hasKey?void 0:`Key missing`}function mN({label:e,field:t,family:n,providers:r,value:i,problem:a,inline:o,onPick:s}){return(0,h.jsx)(dN,{field:t,label:e,value:i,problem:a,inline:o,placeholder:`Pick a provider`,options:[...i!==``&&!r.some(e=>e.id===i&&e.family===n)?[{value:i,label:`${i} (saved provider)`,disabled:!0}]:[],...fN(r,n)],onPick:s})}function hN(e){return(0,h.jsx)(gN,{...e},e.provider)}function gN({label:e,field:t,provider:n,value:r,problem:i,inline:a,onPick:o}){let{api:s}=I(),c=_(),l=nt(cN(s,n)),[u,d]=(0,m.useState)(!1),f=(0,m.useId)(),p=(0,m.useId)(),g=it({mutationFn:()=>sN(s,n,!0),onSuccess:e=>c.setQueryData(oN(n),e)}),v=l.data?.models??[],y=[...new Set(v.flatMap(e=>e.group?[e.group]:[]))],b=l.data?.allowsCustom??lN(n),x=u&&b,S=l.isFetching||g.isPending,C=g.error?.message??l.error?.message??l.data?.warning,w=r!==``&&!v.some(e=>e.id===r);return(0,h.jsxs)(`div`,{className:`min-w-0 max-w-full`,children:[(0,h.jsx)(uN,{field:t,label:e,problem:i,inline:a,children:({id:e,describedBy:s})=>{let c=[s,C?f:void 0,l.data?.notice?p:void 0].filter(Boolean).join(` `)||void 0;return(0,h.jsx)(`div`,{className:z(`min-w-0 [&>span]:w-full`,a?`max-w-[260px]`:`w-full`),children:x?(0,h.jsx)(cM,{id:e,"data-play-field":t,value:r,spellCheck:!1,placeholder:`Type the model id`,"aria-invalid":i!==void 0,"aria-describedby":c,className:a?`w-[180px] max-w-full`:void 0,onChange:e=>o(e.target.value)}):(0,h.jsxs)(aN,{id:e,"data-play-field":t,value:r,disabled:n===``,"aria-invalid":i!==void 0,"aria-describedby":c,className:a?`w-full min-w-[120px] max-w-[260px]`:void 0,onChange:e=>o(e.target.value),children:[(0,h.jsx)(`option`,{value:``,children:n===``?`Pick a provider first`:l.isPending?`Loading models…`:`Pick a model`}),w?(0,h.jsxs)(`option`,{value:r,children:[r,` (saved model)`]}):null,v.filter(e=>!e.group).map(e=>(0,h.jsx)(`option`,{value:e.id,children:e.name},e.id)),y.map(e=>(0,h.jsx)(`optgroup`,{label:e,children:v.filter(t=>t.group===e).map(e=>(0,h.jsx)(`option`,{value:e.id,children:e.name},e.id))},e))]})})}}),n===``?null:(0,h.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-1`,children:[(0,h.jsxs)(B,{type:`button`,variant:`ghost`,className:`px-2 text-label`,"aria-label":`Refresh ${e} list`,title:`Refresh models`,disabled:S,onClick:()=>g.mutate(),children:[(0,h.jsx)(oj,{"aria-hidden":`true`,className:z(`size-3`,S&&`animate-spin motion-reduce:animate-none`)}),`Refresh`]}),b?(0,h.jsx)(B,{type:`button`,variant:`ghost`,className:`px-2 text-label`,"aria-label":x?`Choose ${e} from list`:`Enter ${e} ID`,onClick:()=>d(!x),children:x?`Use list`:`Custom ID`}):null]}),l.data?.notice?(0,h.jsx)(`p`,{id:p,className:`mt-1 max-w-[360px] text-label text-ink3`,children:l.data.notice}):null,C?(0,h.jsx)(`p`,{id:f,className:`mt-1 max-w-[360px] text-label text-ink3`,role:`status`,children:C}):null]})}function _N({label:e,field:t,hideLabel:n=!1,value:r,options:i,className:a,onPick:o}){let s=(0,m.useId)();return(0,h.jsxs)(`span`,{className:z(`inline-flex items-center gap-[10px]`,a),children:[(0,h.jsx)(oM,{id:s,className:n?`sr-only`:`shrink-0`,children:e}),(0,h.jsx)(Hj,{type:`single`,value:r,"aria-labelledby":s,onValueChange:e=>{let t=i.find(t=>t.value===e);t!==void 0&&t.disabled!==!0&&o(t.value)},children:i.map(e=>(0,h.jsx)(Uj,{value:e.value,"data-play-field":e.value===r?t:void 0,disabled:e.disabled===!0,children:e.label},e.value))})]})}function vN({value:e,onPick:t,rawCounts:n}){let r=e.words??500,i=e.characters??3e3,a=e.mode===`words`||e.mode===`characters`,o=e.mode===`characters`,s=o?e.characters:e.words;return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(_N,{field:`chunking.mode`,label:`Chunking`,className:`min-w-0 max-w-full flex-wrap [&_[data-slot=toggle-group]]:max-w-full [&_[data-slot=toggle-group]]:flex-wrap`,value:e.mode,options:[{value:`whole`,label:`Whole`},{value:`paragraph`,label:`Paragraph`},{value:`words`,label:`Every ${String(n?.words??r)} words`},{value:`characters`,label:`Every ${String(n?.characters??i)} characters`}],onPick:e=>{if(n){n.onChange(e,e===`characters`?n.characters:n.words);return}t(e===`words`?{mode:e,words:r}:e===`characters`?{mode:e,characters:i}:{mode:e})}}),a?(0,h.jsx)(uN,{label:o?`Characters`:`Words`,problem:void 0,inline:!0,children:({id:r})=>(0,h.jsx)(cM,{id:r,"data-play-field":o?`chunking.characters`:`chunking.words`,type:n?`text`:`number`,min:1,max:o?1e6:1e4,inputMode:`numeric`,className:`w-[100px] tabular-nums`,value:n?o?n.characters:n.words:s===void 0?``:String(s),onChange:r=>{if(n){n.onChange(e.mode,r.target.value);return}let i=Number.parseInt(r.target.value,10),a=Number.isFinite(i)&&i>0;t(o?a?{mode:`characters`,characters:Math.min(i,1e6)}:{mode:`characters`}:a?{mode:`words`,words:Math.min(i,1e4)}:{mode:`words`})}})}):null,o?(0,h.jsx)(`p`,{className:`basis-full text-small text-ink3`,children:`Ends at the last complete sentence within the character count, including spaces. A longer sentence stays whole; provider request limits still apply.`}):null]})}var yN=1;function bN({prompts:e,picked:t,problem:n,onPick:r,rawNumbers:i}){let a=(0,m.useId)(),o=t.reduce((e,t)=>e+t.number,0),s=t.filter(t=>!e.some(e=>e.name===t.name)),c=[...e.map(e=>({name:e.name,missing:!1})),...s.map(e=>({name:e.name,missing:!0}))];return c.length===0?(0,h.jsx)(`p`,{className:`basis-full text-right text-small text-ink3`,children:`No image prompts saved. Write one on Prompts.`}):(0,h.jsxs)(`div`,{className:`flex basis-full flex-col items-start gap-[6px]`,children:[(0,h.jsx)(`span`,{id:a,className:`engraved text-ink3`,children:`Image prompts`}),(0,h.jsx)(`ul`,{"aria-labelledby":a,className:`flex flex-wrap justify-start gap-x-4 gap-y-2`,children:c.map(e=>{let a=t.findIndex(t=>t.name===e.name),o=a===-1?void 0:t[a];return(0,h.jsxs)(`li`,{children:[e.missing?(0,h.jsx)(`span`,{className:`block text-label text-red`,children:`Missing template · untick to remove`}):null,(0,h.jsx)(xN,{name:e.name,number:o?.number,rawNumber:i?{value:i.values.find(t=>t.name===e.name)?.number??``,onChange:t=>i.onChange(e.name,t)}:void 0,problem:a===-1?void 0:n(`imagePrompts.${String(a)}.number`),onTick:n=>{r(n?[...t,{name:e.name,number:yN}]:t.filter(t=>t.name!==e.name))},onNumber:n=>{r(t.map(t=>t.name===e.name?{name:t.name,number:n}:t))}})]},e.name)})}),t.length===0?null:(0,h.jsx)(`span`,{className:`text-label text-ink3 tabular-nums`,children:Number.isFinite(o)?`${String(o)} of 60 images`:`Complete image counts to see the total`})]})}function xN({name:e,number:t,problem:n,onTick:r,onNumber:i,rawNumber:a}){let o=(0,m.useId)(),s=(0,m.useId)(),c=(0,m.useId)();return(0,h.jsxs)(`span`,{className:`inline-flex items-center gap-2 text-small`,children:[(0,h.jsx)(`input`,{id:o,"data-play-field":`imagePrompts`,type:`checkbox`,checked:t!==void 0,className:`size-[14px] shrink-0 accent-accent`,onChange:e=>{r(e.target.checked)}}),(0,h.jsx)(`label`,{htmlFor:o,className:t===void 0?`text-ink3`:`text-ink`,children:e}),(0,h.jsx)(oM,{htmlFor:s,className:`sr-only`,children:`Number for ${e}`}),(0,h.jsx)(cM,{id:s,"data-play-field":`imagePrompts.${e}.number`,type:a?`text`:`number`,min:yN,max:20,inputMode:`numeric`,disabled:t===void 0,"aria-invalid":n!==void 0,"aria-describedby":n===void 0?void 0:c,className:`w-[64px] tabular-nums`,value:a?.value??(t===void 0||t===0?``:String(t)),onChange:e=>{if(a){a.onChange(e.target.value);return}let t=Number.parseInt(e.target.value,10);i(Number.isFinite(t)?t:0)}}),n===void 0?null:(0,h.jsx)(`span`,{id:c,className:`text-label text-red`,children:n})]})}var SN=`text-small text-ink2 file:mr-3 file:h-8 file:rounded-control file:border file:border-line2 file:bg-panel2 file:px-3 file:text-ink`;function CN({label:e,field:t,value:n,placeholder:r,problem:i,onChange:a}){let o=(0,m.useId)(),s=(0,m.useId)();return(0,h.jsxs)(`div`,{children:[(0,h.jsx)(oM,{htmlFor:o,className:`mb-[5px]`,children:e}),(0,h.jsx)(lM,{id:o,"data-play-field":t,rows:6,value:n,placeholder:r,"aria-invalid":i!==void 0,"aria-describedby":i===void 0?void 0:s,onChange:e=>{a(e.target.value)}}),i===void 0?null:(0,h.jsx)(`p`,{id:s,className:`mt-1 text-label text-red`,children:i})]})}function wN({label:e,field:t,accept:n,multiple:r=!1,uploads:i,problem:a,numbered:o=!1,onPick:s,onRemove:c,onReattach:l}){let u=(0,m.useId)(),d=(0,m.useId)();return(0,h.jsxs)(`div`,{children:[(0,h.jsx)(oM,{htmlFor:u,className:`mb-[5px]`,children:e}),(0,h.jsx)(`input`,{id:u,"data-play-field":t,type:`file`,accept:n,multiple:r,"aria-invalid":a!==void 0,"aria-describedby":a===void 0?void 0:d,className:SN,onChange:e=>{s([...e.target.files??[]]),e.target.value=``}}),a===void 0?null:(0,h.jsx)(`p`,{id:d,className:`mt-1 text-label text-red`,children:a}),i.length===0?null:(0,h.jsx)(`ul`,{className:`mt-2 flex flex-col gap-1`,children:i.map((e,t)=>(0,h.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3`,children:[o?(0,h.jsx)(`span`,{className:`engraved w-6 text-ink3`,children:String(t+1)}):null,(0,h.jsx)(TN,{upload:e}),e.error!==void 0&&l?(0,h.jsxs)(`label`,{className:`text-small text-ink2`,children:[`Reattach`,(0,h.jsx)(`input`,{"aria-label":`Reattach ${e.name}`,className:`max-w-full`,type:`file`,accept:n,onChange:t=>{let n=t.target.files?.[0];t.target.value=``,n&&l(e.key,n)}})]}):null,c===void 0?null:(0,h.jsx)(B,{variant:`ghost`,className:`ml-auto`,"aria-label":`Remove ${e.name}`,onClick:()=>{c(e.key)},children:`Remove`})]},e.key))})]})}function TN({upload:e}){return(0,h.jsxs)(`span`,{className:`flex min-w-0 flex-wrap items-center gap-3 text-small [overflow-wrap:anywhere]`,children:[(0,h.jsx)(`span`,{className:e.error===void 0?`text-ink`:`text-red`,children:e.name}),e.error===void 0?(0,h.jsx)(`span`,{className:`engraved text-ink3`,children:e.file===void 0?`Copying`:`Staged`}):(0,h.jsx)(`span`,{className:`text-small text-red`,children:e.error})]})}var EN=`col-span-3 grid min-w-0 grid-cols-1 gap-4 min-[700px]:grid-cols-2`,DN=`col-span-3 min-w-0`;function ON({kind:e,name:t,dim:n,children:r}){return(0,h.jsxs)(`section`,{"data-tour":`play-${e}`,className:`grid grid-cols-[24px_1fr_auto] items-center gap-x-2 gap-y-5 border-b border-line py-6`,children:[(0,h.jsx)(Pc,{kind:e,className:n?`text-ink3`:`text-ink2`}),(0,h.jsx)(`h3`,{className:z(`text-lg font-semibold`,n?`text-ink3`:void 0),children:t}),r]})}function kN({kind:e,form:t,update:n}){return(0,h.jsx)(_N,{field:`sources.${e}`,label:`${e} source`,hideLabel:!0,className:`max-[700px]:col-span-3 max-[700px]:justify-self-start [&_[data-slot=toggle-group]]:flex-wrap`,value:t.sources[e],options:FM(e).map(n=>({...n,disabled:e===`video`&&n.value===`generate`&&t.sources.images===`off`})),onPick:r=>{n({sources:{...t.sources,[e]:r,...e===`images`&&r===`off`?{video:`off`}:{}}})}})}function AN(e,t){return e.filter(e=>e.kind===t).map(e=>({value:e.name,label:e.name}))}function jN({value:e,prompts:t,supported:n,error:r,libraryLinks:i=!0,onChange:a}){let o=(0,m.useId)(),s=t.filter(e=>e.kind===`narration`),c=s.find(t=>t.name===e),l=r??(e!==``&&!n?`Choose Inworld TTS-2 or turn preparation Off.`:void 0);return(0,h.jsxs)(`div`,{className:`col-span-full min-w-0 space-y-2`,children:[(0,h.jsx)(`label`,{htmlFor:o,className:`block text-small font-semibold`,children:`Narration Preparation`}),(0,h.jsxs)(aN,{id:o,"data-play-field":`narrationPrompt`,value:e,"aria-describedby":`${o}-help${l?` ${o}-error`:``}`,"aria-invalid":l!==void 0||void 0,onChange:e=>a(e.target.value),children:[(0,h.jsx)(`option`,{value:``,children:`Off`}),e!==``&&c===void 0?(0,h.jsxs)(`option`,{value:e,children:[e,` (saved selection)`]}):null,s.map(e=>(0,h.jsx)(`option`,{value:e.name,children:e.name},e.id))]}),(0,h.jsx)(`p`,{id:`${o}-help`,className:`text-small text-ink3`,children:`Optional. Uses the selected LLM once per narration chunk and entry. Supports Inworld TTS-2; the article and clean narration stay unchanged.`}),l?(0,h.jsx)(`p`,{id:`${o}-error`,className:`text-small text-red`,children:l}):null,i?(0,h.jsxs)(`div`,{className:`flex gap-4 text-small`,children:[(0,h.jsx)(sa,{to:`/prompts/new`,search:{kind:`narration`},children:`Create prompt`}),c?(0,h.jsx)(sa,{to:`/prompts/$promptId`,params:{promptId:c.id},children:`View prompt`}):null]}):null]})}function MN({form:e,prompts:t,providers:n,voices:r,problem:i,update:a,onPickFiles:o,onRemoveFile:s,onReattachFile:c,rawCounts:l}){let u=r.filter(t=>t.provider===e.audio.provider);return(0,h.jsxs)(ON,{kind:`audio`,name:`Audio`,dim:e.sources.audio===`off`,children:[(0,h.jsx)(kN,{kind:`audio`,form:e,update:a}),(0,h.jsx)(`div`,{className:EN,children:e.sources.audio===`generate`?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(mN,{field:`audio.provider`,label:`TTS`,family:`tts`,providers:n,value:e.audio.provider,problem:i(`audio`),onPick:e=>{a({audio:{provider:e,model:``,voice:``}})}}),(0,h.jsx)(hN,{field:`audio.model`,label:`TTS model`,provider:e.audio.provider,value:e.audio.model,problem:i(`audio.model`),onPick:t=>a({audio:{...e.audio,model:t}})}),(0,h.jsx)(dN,{field:`audio.voice`,label:`Voice`,value:e.audio.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:i(`audio.voice`),onPick:t=>{a({audio:{...e.audio,voice:t}})}}),(0,h.jsxs)(`details`,{className:`col-span-full`,children:[(0,h.jsxs)(`summary`,{className:`cursor-pointer py-2`,children:[`Audio Advanced · `,e.chunking.mode]}),(0,h.jsx)(vN,{...l?{rawCounts:l}:{},value:e.chunking,onPick:e=>{a({chunking:e})}})]}),(0,h.jsx)(jN,{value:e.narrationPrompt??``,prompts:t,supported:e.audio.provider===`inworld`&&e.audio.model===`inworld-tts-2`,error:i(`narrationPrompt`),onChange:e=>a({narrationPrompt:e})})]}):null}),e.sources.audio===`provide`?(0,h.jsxs)(`div`,{className:DN,children:[(0,h.jsx)(wN,{field:`provided.audio`,label:`Narration file`,accept:`audio/*`,uploads:e.provided.audio===void 0?[]:[e.provided.audio],problem:i(`provided.audio`),onPick:e=>{o(`audio`,e)},onReattach:c?(e,t)=>c(`audio`,e,t):void 0,onRemove:e=>{s(`audio`,e)}}),(0,h.jsx)(`p`,{className:`mt-2 text-small text-ink2`,children:`Uploaded narration is used as-is; include any intro and outro in that file.`})]}):null]})}function NN({form:e,providers:t,prompts:n,problem:r,update:i,onPickFiles:a,onRemoveFile:o,onReattachFile:s,rawNumbers:c}){return(0,h.jsxs)(ON,{kind:`images`,name:`Images`,dim:e.sources.images===`off`,children:[(0,h.jsx)(kN,{kind:`images`,form:e,update:i}),(0,h.jsx)(`div`,{className:EN,children:e.sources.images===`generate`?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(PN,{form:e,providers:t,problem:r,update:i}),(0,h.jsx)(bN,{prompts:n.filter(e=>e.kind===`image`),...c?{rawNumbers:c}:{},picked:e.imagePrompts,problem:r,onPick:e=>{i({imagePrompts:e})}})]}):null}),e.sources.images===`provide`?(0,h.jsx)(`div`,{className:DN,children:(0,h.jsx)(wN,{field:`provided.images`,label:`Slideshow images`,accept:`image/png,image/jpeg,image/webp`,multiple:!0,numbered:!0,uploads:e.provided.images,problem:r(`provided.images`),onPick:e=>{a(`images`,e)},onReattach:s?(e,t)=>s(`images`,e,t):void 0,onRemove:e=>{o(`images`,e)}})}):null]})}function PN({form:e,providers:t,problem:n,update:r}){return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(mN,{field:`images.provider`,label:`Provider`,family:`image`,providers:t,value:e.images.provider,problem:n(`images`),onPick:e=>r({images:{provider:e,model:``}})}),(0,h.jsx)(hN,{field:`images.model`,label:`Model`,provider:e.images.provider,value:e.images.model,problem:n(`images.model`),onPick:t=>r({images:{...e.images,model:t}})})]})}function FN({form:e,problem:t,update:n}){return(0,h.jsxs)(ON,{kind:`research`,name:`Research`,dim:e.sources.research===`off`,children:[(0,h.jsx)(kN,{kind:`research`,form:e,update:n}),(0,h.jsx)(`div`,{className:EN,children:e.sources.research===`generate`?(0,h.jsx)(`span`,{className:`engraved text-ink3`,children:`Runs through the LLM, one agent per chapter`}):null}),e.sources.research===`provide`?(0,h.jsx)(`div`,{className:DN,children:(0,h.jsx)(CN,{field:`provided.research`,label:`Research notes`,value:e.provided.research,placeholder:`Paste the notes the article will be written from.`,problem:t(`provided.research`),onChange:t=>{n({provided:{...e.provided,research:t}})}})}):null]})}function IN({form:e,prompts:t,problem:n,update:r}){return(0,h.jsxs)(ON,{kind:`article`,name:`Article`,dim:!1,children:[(0,h.jsx)(kN,{kind:`article`,form:e,update:r}),(0,h.jsx)(`div`,{className:`${DN} grid gap-4`,children:e.sources.article===`generate`?(0,h.jsx)(dN,{field:`articlePrompt`,label:`Article prompt`,value:e.articlePrompt,placeholder:`Pick a prompt`,options:AN(t,`article`),problem:n(`articlePrompt`),onPick:e=>{r({articlePrompt:e})}}):null}),e.sources.article===`provide`?(0,h.jsx)(`div`,{className:DN,children:(0,h.jsx)(CN,{field:`provided.article`,label:`Article text`,value:e.provided.article,placeholder:`Paste the article that will be narrated.`,problem:n(`provided.article`),onChange:t=>{r({provided:{...e.provided,article:t}})}})}):null]})}function LN({form:e,providers:t,prompts:n,problem:r,update:i,onPickFiles:a,onRemoveFile:o,onReattachFile:s}){let c=e.sources.thumbnail===`from_prompt`||e.sources.thumbnail===`prompt_by_llm`;return(0,h.jsxs)(ON,{kind:`thumbnail`,name:`Thumbnail`,dim:e.sources.thumbnail===`off`,children:[(0,h.jsx)(kN,{kind:`thumbnail`,form:e,update:i}),(0,h.jsxs)(`div`,{className:EN,children:[c&&e.sources.images!==`generate`?(0,h.jsx)(PN,{form:e,providers:t,problem:r,update:i}):null,c?(0,h.jsx)(dN,{field:`thumbnailPrompt`,label:`Thumbnail prompt`,value:e.thumbnailPrompt,placeholder:`Pick a prompt`,options:AN(n,`thumbnail`),problem:r(`thumbnailPrompt`),onPick:e=>{i({thumbnailPrompt:e})}}):null]}),e.sources.thumbnail===`provide`?(0,h.jsx)(`div`,{className:DN,children:(0,h.jsx)(wN,{field:`provided.thumbnail`,label:`Thumbnail image`,accept:`image/png,image/jpeg,image/webp`,uploads:e.provided.thumbnail===void 0?[]:[e.provided.thumbnail],problem:r(`provided.thumbnail`),onPick:e=>{a(`thumbnail`,e)},onReattach:s?(e,t)=>s(`thumbnail`,e,t):void 0,onRemove:e=>{o(`thumbnail`,e)}})}):null]})}function RN({form:e,silenceGapSeconds:t,update:n}){let r=e.sources.video===`generate`?e.sources.audio===`off`?`Silent video · 5 seconds per image`:`Images and narration · ${String(t)} s segment gaps`:e.sources.audio===`off`?`Download each enabled stage separately`:`Combined WAV export with narration and segment gaps`;return(0,h.jsxs)(ON,{kind:`video`,name:`Export`,dim:e.sources.video===`off`,children:[(0,h.jsx)(kN,{kind:`video`,form:e,update:n}),(0,h.jsx)(`span`,{className:EN,children:(0,h.jsx)(`span`,{className:`engraved text-ink3`,children:r})}),e.sources.images===`off`?(0,h.jsx)(`p`,{className:`${DN} text-small text-ink2`,children:`Video is Off because Images is Off. Generate or provide images to enable video.`}):null]})}function zN({choice:e,onChange:t}){let{api:n}=I(),r=nt(cN(n,e.provider)).data?.models.find(t=>t.id===e.model)?.thinkingModes??[];return!r.length&&!e.thinking?null:(0,h.jsxs)(`div`,{className:`min-w-0`,children:[(0,h.jsx)(dN,{field:`llm.thinking`,label:`Thinking`,value:e.thinking??`default`,placeholder:`Model default`,problem:e.thinking&&!r.includes(e.thinking)?`Choose a supported thinking level.`:void 0,options:[{value:`default`,label:`Model default`},...e.thinking&&!r.includes(e.thinking)?[{value:e.thinking,label:`${e.thinking} (saved level)`}]:[],...r.map(e=>({value:e,label:e===`off`?`Off`:e.charAt(0).toUpperCase()+e.slice(1)}))],onPick:n=>{let i=r.find(e=>e===n);t({...e,thinking:i})}}),r.length&&!r.includes(`off`)?(0,h.jsx)(`p`,{className:`mt-1 text-small text-ink3`,children:`This model does not support turning thinking off.`}):null]})}function BN(e){let{form:t,problem:n,update:r,fields:i,entries:a,onLibrary:o}=e,s=(0,m.useId)(),c=e.prompts.find(e=>e.kind===`article`&&e.name===t.articlePrompt);return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`div`,{className:`mt-7`,children:[(0,h.jsx)(oM,{htmlFor:s,className:`mb-2`,children:`Project title`}),(0,h.jsx)(cM,{id:s,"data-play-field":`title`,value:t.title,maxLength:200,"aria-invalid":n(`title`)!==void 0,onChange:e=>r({title:e.target.value})}),n(`title`)?(0,h.jsx)(`p`,{className:`text-small text-red`,children:n(`title`)}):null]}),(0,h.jsx)(IN,{...e}),t.sources.article===`generate`?(0,h.jsxs)(`div`,{className:`flex flex-wrap items-start gap-3 py-3`,children:[c?(0,h.jsxs)(`details`,{className:`min-w-0 flex-1`,children:[(0,h.jsx)(`summary`,{"data-play-field":`articlePrompt.preview`,className:`cursor-pointer py-2 text-small text-run-text`,children:`View prompt`}),(0,h.jsx)(`pre`,{className:`whitespace-pre-wrap break-words py-3 font-sans text-body text-ink2`,children:c.body})]}):(0,h.jsx)(`p`,{className:`text-small text-ink2`,children:e.prompts.some(e=>e.kind===`article`)?`Choose a saved article prompt.`:`No article prompts saved. Create a prompt to begin.`}),(0,h.jsx)(B,{variant:`ghost`,onClick:()=>o(`/prompts`),children:`Create prompt`})]}):(0,h.jsxs)(`p`,{className:`py-3 text-small text-ink3`,children:[t.provided.article.trim()?t.provided.article.trim().split(/\s+/).length:0,` `,`words · `,t.provided.article.length,` characters`]}),(0,h.jsx)(rN,{fields:i,origins:$M({form:t,prompts:e.prompts,entries:a,silenceGapSeconds:e.silenceGapSeconds}),values:t.values,problem:n,onChange:(e,n)=>r({values:{...t.values,[e]:n}})}),IM(t,a)?(0,h.jsxs)(`section`,{className:`border-y border-line py-6`,children:[(0,h.jsx)(`h3`,{className:`mb-4 text-lg font-semibold`,children:`Text generation`}),(0,h.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 min-[700px]:grid-cols-2`,children:[(0,h.jsx)(mN,{field:`llm.provider`,label:`LLM`,family:`llm`,providers:e.providers,value:t.llm.provider,problem:n(`llm.provider`)??(t.llm.provider===``?n(`llm`):void 0),onPick:e=>r({llm:{provider:e,model:``}})}),(0,h.jsx)(hN,{field:`llm.model`,label:`Text model`,provider:t.llm.provider,value:t.llm.model,problem:n(`llm.model`)??(t.llm.provider!==``&&n(`llm`)?`Pick a text model.`:void 0),onPick:e=>r({llm:{...t.llm,model:e}})}),(0,h.jsx)(zN,{choice:t.llm,onChange:e=>r({llm:e})})]}),(0,h.jsx)(`p`,{className:`mt-3 text-small text-ink3`,children:`Shared by generated article, research, thumbnail wording, generated entries and Narration Preparation when enabled.`}),(0,h.jsx)(B,{variant:`ghost`,onClick:()=>o(`/settings`),children:`Settings`})]}):null,t.sources.article===`provide`?(0,h.jsx)(`p`,{className:`py-4 text-small text-ink3`,children:`Research is Off because the article is provided.`}):(0,h.jsx)(FN,{...e})]})}function VN(){let{api:e}=I(),t=Ek(),n=_(),[r,i]=(0,m.useState)(null),[a,o]=(0,m.useState)(null),[s,c]=(0,m.useState)(!1),l=nt({queryKey:[`play-drafts`],queryFn:async()=>{let t=await NO(e);if(!t.ok)throw Error(t.message);return t.value.drafts}}),u=async()=>{if(!r||s)return;let e=r.id;c(!0),o(null);try{await t.discard({id:r.id,version:r.version}),i(null),await n.cancelQueries({queryKey:[`play-drafts`]}),n.setQueryData([`play-drafts`],t=>t?.filter(t=>t.id!==e))}catch(e){o(e instanceof Error?e.message:`Couldn't discard draft`)}finally{c(!1)}};return(0,h.jsxs)(`section`,{"aria-label":`Drafts`,className:`min-w-0 max-w-full text-small`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-start gap-2`,children:[(0,h.jsxs)(`details`,{className:`max-w-full rounded-control border border-line bg-panel px-3`,children:[(0,h.jsx)(`summary`,{className:`flex min-h-10 cursor-pointer items-center font-semibold`,children:`Drafts`}),l.isPending?(0,h.jsx)(`p`,{role:`status`,children:`Loading drafts…`}):null,l.error?(0,h.jsxs)(`p`,{role:`alert`,children:[l.error.message,(0,h.jsx)(`button`,{type:`button`,onClick:()=>void l.refetch(),children:`Retry`})]}):null,l.data?.length===0?(0,h.jsx)(`p`,{children:`No saved drafts`}):null,(0,h.jsx)(`ul`,{className:`max-h-72 max-w-[320px] overflow-y-auto pb-2`,children:l.data?.map(e=>(0,h.jsxs)(`li`,{className:`flex flex-wrap items-center gap-2 border-t border-line py-2`,children:[(0,h.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,h.jsx)(`button`,{type:`button`,className:`w-full break-words text-left`,onClick:()=>void t.open(e.id),children:(0,h.jsx)(`span`,{className:`block`,children:e.title||`Untitled draft`})}),(0,h.jsxs)(`time`,{dateTime:e.updatedAt,className:`block text-label text-ink3`,children:[`Last edited `,jc(e.updatedAt)]})]}),e.readable?null:(0,h.jsx)(`p`,{children:`Unsupported or corrupt draft. Try opening it to recover, or discard it.`}),(0,h.jsx)(`button`,{type:`button`,onClick:()=>{i(e),o(null)},"aria-label":`Discard ${e.title||`Untitled draft`}`,children:`Discard`})]},e.id))})]}),(0,h.jsx)(B,{onClick:()=>void t.newDraft(),children:`New draft`})]}),(0,h.jsx)(`p`,{role:`status`,className:`mt-2 text-small text-ink3`,children:{unsaved:`Unsaved`,saving:`Saving…`,saved:`Saved`,error:`Couldn't save`,conflict:`Changed elsewhere`}[t.status]}),(0,h.jsx)(Nj,{open:r!==null,title:`Discard draft`,consequence:`Discard ${r?.title||`Untitled draft`}? This cannot be undone.`,verb:`Confirm discard`,pending:s,onConfirm:()=>void u(),onCancel:()=>{s||i(null)}}),a?(0,h.jsx)(`p`,{role:`alert`,children:a}):null,t.error?(0,h.jsxs)(`p`,{role:`alert`,children:[`Couldn't save. `,t.error]}):null,t.status===`error`?(0,h.jsx)(`button`,{type:`button`,onClick:()=>{!t.view&&t.activeId&&t.edited===0?t.open(t.activeId):t.flush()},children:`Retry`}):null,t.status===`conflict`?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`button`,{type:`button`,onClick:()=>{t.activeId&&t.open(t.activeId)},children:`Reload saved draft`}),(0,h.jsx)(`button`,{type:`button`,onClick:()=>void t.saveAsNew(),children:`Save as a new draft`})]}):null]})}function HN(e,t){let n=[...e.querySelectorAll(`[data-play-field]`)].find(e=>e.dataset.playField===t);return!n||n.hasAttribute(`disabled`)?!1:(n.focus(),n.scrollIntoView({block:`nearest`,inline:`nearest`,behavior:`instant`}),document.activeElement===n)}function UN(e,t,n){let r=e;e===`fontUpload`&&(r=`subtitles.fontUpload`),/^provided\.images\.\d+$/.test(e)&&(r=`provided.images`),e===`subtitles`&&(r=`subtitles.mode`),e===`chunking`&&(r=`chunking.mode`),[`audio`,`llm`,`images`].includes(e)&&(r=`${e}.provider`),e===`provided`&&(r=`provided.${[`audio`,`images`,`thumbnail`].find(e=>t.sources[e]===`provide`&&(e===`images`?t.provided.images:[t.provided[e]]).some(e=>e&&(e.error!==void 0||e.file===void 0)))??`audio`}`);let i=/^imagePrompts\.(\d+)\.(.+)$/.exec(e);if(i){let e=t.imagePrompts[Number(i[1])];e&&(r=`imagePrompts.${e.name}.${i[2]}`)}e===`imagePrompts`&&(r=t.imagePrompts[0]?`imagePrompts.${t.imagePrompts[0].name}.number`:`imagePrompts`);let a=/^variants\.(\d+)\.(.+)$/.exec(e);a&&(r=`items.${n[Number(a[1])]?.key??a[1]}.${a[2]}`);let o=/^items\.(\d+)\.(.+)$/.exec(e);o&&(r=Number(o[1])===0?o[2]??e:`items.${n[Number(o[1])-1]?.key??o[1]}.${o[2]}`);let s=t=>t.some(t=>e===t||e.startsWith(`${t}.`));return{section:s([`title`,`articlePrompt`,`provided.article`,`provided.research`,`sources.article`,`sources.research`,`llm`,`values`])?`content`:s([`format`,`subtitles`,`fontUpload`])?`style`:s([`audio`,`narrationPrompt`,`provided.audio`,`intro`,`outro`,`chunking`,`images`,`imagePrompts`,`provided.images`,`thumbnailPrompt`,`provided.thumbnail`,`provided`,`sources`])?`outputs`:`review`,field:r}}function WN(e){return e===`9:16`?{width:1080,height:1920}:{width:1920,height:1080}}function GN(e,t){switch(e){case`top`:return{y:60,alignment:8,translateY:0};case`upper-middle`:return{y:t/4,alignment:5,translateY:-50};case`center`:return{y:t/2,alignment:5,translateY:-50};case`lower-middle`:return{y:t*3/4,alignment:5,translateY:-50};case`bottom`:return{y:t-60,alignment:2,translateY:-100}}}function KN({value:e,format:t,sample:n=`Every story begins with a word.`,backgroundUrl:r,showCaptions:i=!0,maxFrameHeight:a}){let{api:o}=I(),s=KO(o,e.fontId),c=`subtitle-preview-${(0,m.useId)().replace(/[^a-zA-Z0-9]/g,``)}`,[l,u]=(0,m.useState)(!1);(0,m.useEffect)(()=>{if(typeof FontFace>`u`||!document.fonts)return;let e=!0,t=new FontFace(c,`url(${JSON.stringify(s)})`);return u(!1),t.load().then(t=>{e&&document.fonts.add(t)}).catch(()=>{e&&u(!0)}),()=>{e=!1,document.fonts.delete(t)}},[c,s]);let d=WN(t),f=GN(e.position??`bottom`,d.height),p=Number.isFinite(e.fontSize)?Math.max(16,Math.min(120,e.fontSize)):48,g={position:`absolute`,left:`50%`,top:`${f.y/d.height*100}%`,width:`${(d.width-120)/d.width*100}%`,transform:`translate(-50%, ${f.translateY}%)`,fontFamily:`"${c}", sans-serif`,fontSize:`${p/d.width*100}cqw`,lineHeight:1.2,overflowWrap:`anywhere`,WebkitTextStroke:`${2.5/d.width*100}cqw #101010`,paintOrder:`stroke fill`,textShadow:`0 ${100/d.width}cqw ${100/d.width}cqw #000`};return(0,h.jsxs)(`figure`,{className:`min-w-0 self-start`,children:[(0,h.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2 text-label text-ink2`,children:[(0,h.jsx)(`span`,{children:`Style preview`}),(0,h.jsx)(`span`,{children:t})]}),(0,h.jsxs)(`div`,{role:`img`,"aria-label":`Subtitle style preview`,"data-format":t,"data-position":e.position??`bottom`,className:`relative mx-auto w-full overflow-hidden rounded-control border border-line2 bg-screen text-center text-white`,style:{aspectRatio:`${d.width} / ${d.height}`,maxWidth:t===`9:16`?a?`min(240px, calc((${a}) * 9 / 16))`:240:480,containerType:`inline-size`},children:[r?(0,h.jsx)(`img`,{src:r,alt:``,className:`absolute inset-0 h-full w-full object-cover`}):null,i?(0,h.jsx)(`span`,{role:`note`,"aria-label":`Caption sample`,style:g,children:n}):null]}),(0,h.jsxs)(`figcaption`,{className:`mt-2 text-label text-ink3`,children:[d.width,` × `,d.height,` · Preview at reduced scale.`,l?` Font preview unavailable; showing a fallback.`:``]})]})}function qN(){let[e,t]=(0,m.useState)(()=>window.matchMedia?.(`(min-width: 1100px)`).matches??!1);return(0,m.useEffect)(()=>{let e=window.matchMedia?.(`(min-width: 1100px)`);if(!e)return;let n=()=>t(e.matches);return n(),e.addEventListener(`change`,n),()=>e.removeEventListener(`change`,n)},[]),e}function JN(){let{api:e}=I(),t=Ek(),{form:n,previewText:r}=t.document,i=n.sources.images===`provide`?n.provided.images.map(e=>t.view?.attachments.find(t=>t.id===e.attachmentId&&t.kind===`images`&&t.state===`ready`&&t.stagedFileId)).find(Boolean):void 0,a=i&&t.activeId?VO(e,t.activeId,i.id):void 0,o=n.sources.video===`generate`&&n.sources.images!==`off`;return(0,h.jsxs)(`section`,{"aria-label":`Output preview`,className:`min-w-0`,children:[(0,h.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,h.jsx)(`h2`,{className:`text-small font-semibold`,children:`Output preview`}),(0,h.jsx)(B,{variant:`ghost`,className:`text-run-text`,onClick:()=>void t.navigate(`style`),children:`Edit style ↗`})]}),(0,h.jsx)(`div`,{className:`rounded-control border border-line bg-panel p-4`,children:(0,h.jsx)(KN,{value:{...n.subtitles,fontSize:Number(n.subtitles.fontSize)},format:n.format,sample:r,showCaptions:n.sources.audio!==`off`&&n.subtitles.mode!==`off`,maxFrameHeight:`max(160px, 100dvh - 360px)`,...a?{backgroundUrl:a}:{}})}),(0,h.jsx)(`p`,{className:`mt-3 text-small text-ink3`,children:a?`Style preview using your supplied image.`:`Style preview only. No generated image is shown.`}),(0,h.jsx)(`p`,{className:`mt-2 text-small text-ink3`,children:o?n.subtitles.mode===`burn-in`?`Captions will be burned into the MP4.`:`Caption styling previews burn-in. SRT/VTT players choose their own styling.`:`Frame and caption styling apply when Video is enabled.`})]})}function YN(e){let t=Ek(),n=t.document,{form:r,entries:i,problem:a,update:o}=e;return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(MN,{...e,rawCounts:{...n.form.chunking,onChange:(e,r)=>t.edit({...n,form:{...n.form,chunking:{...n.form.chunking,mode:e,...e===`words`?{words:r}:e===`characters`?{characters:r}:{}}}})}}),r.sources.audio===`generate`?(0,h.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 border-b border-line py-4 min-[700px]:grid-cols-2`,children:[r.narrationPrompt?(0,h.jsx)(B,{variant:`ghost`,className:`col-span-full`,onClick:()=>e.onKeyword(`llm`),children:`Choose Text Generation in Content`}):null,[`intro`,`outro`].map(e=>(0,h.jsx)(dN,{field:e,label:e===`intro`?`Intro`:`Outro`,value:r[e],placeholder:`Off`,options:i.filter(t=>t.category===e).map(e=>({value:e.name,label:e.name})),problem:a(e),onPick:t=>o({[e]:t})},e)),(0,h.jsx)(B,{variant:`ghost`,onClick:e.onSettings,children:`Settings`})]}):null,(0,h.jsx)(NN,{...e,rawNumbers:{values:n.form.imagePrompts,onChange:(e,r)=>t.edit({...n,form:{...n.form,imagePrompts:n.form.imagePrompts.map(t=>t.name===e?{...t,number:r}:t)}})}}),(0,h.jsx)(LN,{...e}),(0,h.jsx)(RN,{...e}),(0,h.jsx)(nN,{problem:a}),e.missingKeyword?(0,h.jsxs)(`p`,{className:`py-4 text-small text-ink2`,children:[`A selected template needs keywords.`,` `,(0,h.jsx)(B,{variant:`ghost`,onClick:()=>e.onKeyword(e.missingKeyword??`values`),children:`Complete keywords in Content`})]}):null]})}function XN({selected:e,reviewed:t}){let n=e=>eN.find(t=>t.stage===e)?.label??e;return e?.length?(0,h.jsxs)(`div`,{className:`space-y-3 text-body`,children:[t?.length?t.map(e=>(0,h.jsxs)(`div`,{children:[(0,h.jsxs)(`p`,{className:`font-medium`,children:[`Run `,e.runIndex+1,` · Before `,n(e.stage)]}),(0,h.jsx)(`p`,{className:`text-small text-ink2`,children:e.dependents.length?`Also holds: ${e.dependents.map(n).join(`, `)}.`:`No dependent steps.`})]},`${e.runIndex}-${e.checkpointId}`)):(0,h.jsxs)(`p`,{children:[`Selected: `,e.map(e=>`Before ${n(e)}`).join(`, `),`. Refresh review to confirm dependent steps.`]}),(0,h.jsx)(`p`,{className:`text-small text-ink2`,children:`Approval required on the project page. Starting this run does not approve these checkpoints.`})]}):(0,h.jsx)(`p`,{className:`text-body text-ink2`,children:`No review checkpoints selected.`})}function ZN({items:e,fields:t,title:n,values:r,problem:i,onChange:a}){let o=(0,m.useId)();return(0,h.jsxs)(`details`,{className:`rounded-control border border-line p-3`,children:[(0,h.jsxs)(`summary`,{className:`cursor-pointer text-body font-medium`,children:[`Queue keyword variations `,e.length?`(${e.length+1} videos)`:``]}),(0,h.jsx)(`p`,{className:`my-3 text-small text-ink2`,children:`The setup above is video 1. Add videos with different titles and keywords. They run one at a time; a failed video releases the next, and a pause holds the queue.`}),e.map((n,r)=>(0,h.jsxs)(`fieldset`,{className:`mb-3 flex min-w-0 flex-col gap-2 border-t border-line pt-3`,children:[(0,h.jsxs)(`legend`,{className:`text-small text-ink2`,children:[`Video `,r+2]}),(0,h.jsxs)(`label`,{htmlFor:`${o}-${n.key}-title`,className:`text-small`,children:[`Title`,(0,h.jsx)(cM,{id:`${o}-${n.key}-title`,"data-play-field":`items.${n.key}.title`,"aria-invalid":i?.(`items.${r+1}.title`)!==void 0,value:n.title,maxLength:200,onChange:t=>a(e.map(e=>e.key===n.key?{...e,title:t.target.value}:e))})]}),t.map(t=>(0,h.jsxs)(`label`,{htmlFor:`${o}-${n.key}-${encodeURIComponent(t.name)}`,className:`text-small`,children:[t.name,(0,h.jsx)(cM,{id:`${o}-${n.key}-${encodeURIComponent(t.name)}`,"data-play-field":`items.${n.key}.values.${t.name}`,"aria-invalid":i?.(`items.${r+1}.values.${t.name}`)!==void 0,value:n.values[t.name]??``,onChange:r=>a(e.map(e=>e.key===n.key?{...e,values:{...e.values,[t.name]:r.target.value}}:e))})]},t.name)),(0,h.jsxs)(B,{onClick:()=>a(e.filter(e=>e.key!==n.key)),children:[`Remove video `,r+2]})]},n.key)),(0,h.jsx)(B,{disabled:e.length>=49,onClick:()=>a([...e,{key:crypto.randomUUID(),title:`${n||`Video`} ${e.length+2}`,values:{...r}}]),children:`Add keyword variation`})]})}function QN({estimates:e}){let t=e.reduce((e,t)=>e+t.low,0),n=e.reduce((e,t)=>e+t.high,0),r=e.reduce((e,t)=>e+t.unknown,0),i=e[0]?.rows.map((t,n)=>({...t,low:e.some(e=>e.rows[n]?.low===null)?null:e.reduce((e,t)=>e+(t.rows[n]?.low??0),0),high:e.some(e=>e.rows[n]?.high===null)?null:e.reduce((e,t)=>e+(t.rows[n]?.high??0),0)}))??[];return(0,h.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[` `,e.length?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`p`,{className:`text-title font-bold`,children:[r?`Known subtotal: `:`Estimated total: `,$N(t,n)]}),r?(0,h.jsxs)(`p`,{className:`text-body text-ink2`,children:[`Plus `,r,` stage charge`,r===1?``:`s`,` with unavailable pricing.`]}):null,(0,h.jsx)(`div`,{className:`divide-y divide-line`,children:i.map(e=>(0,h.jsx)(`div`,{className:`py-2`,children:(0,h.jsxs)(`div`,{className:`flex justify-between gap-4 text-body`,children:[(0,h.jsx)(`span`,{children:e.stage}),(0,h.jsx)(`span`,{children:e.low===null||e.high===null?`Unknown`:$N(e.low,e.high)})]})},e.stage))}),(0,h.jsxs)(`details`,{className:`border-t border-line py-3`,children:[(0,h.jsx)(`summary`,{className:`cursor-pointer text-small`,children:`Assumptions and stage details`}),(0,h.jsxs)(`div`,{className:`mt-3 flex flex-col gap-2`,children:[i.map(e=>(0,h.jsxs)(`p`,{className:`text-small text-ink2`,children:[e.stage,`: `,e.detail]},e.stage)),[...new Set(e.flatMap(e=>e.assumptions))].map(e=>(0,h.jsx)(`p`,{className:`text-small text-ink2`,children:e},e))]})]}),(0,h.jsxs)(`p`,{className:`text-small text-ink3`,children:[`Catalogue verified `,e[0]?.catalogueDate??`date unavailable`,`. Batch rows show combined costs.`]})]}):null]})}function $N(e,t){let n=e=>e===0?`$0`:e<.01?`<$0.01`:`$${e.toFixed(2)}`;return e===t?n(e):`${n(e)} – ${n(t)}`}function eP(e){return e===void 0?{ok:!1,text:`Provider status unavailable`}:e.readiness.kind===`cli`?Rk(e.readiness)?{ok:!0,text:e.readiness.version===void 0?`CLI ready`:`CLI ready · ${e.readiness.version}`}:{ok:!1,text:e.readiness.issue??`CLI not found`}:e.readiness.hasKey?{ok:!0,text:`API key saved`}:{ok:!1,text:`API key missing`}}function tP(e,t){let n=e.sources.audio===`generate`,r=[`from_prompt`,`prompt_by_llm`].includes(e.sources.thumbnail);return[...(e.sources.article===`generate`||e.sources.thumbnail===`prompt_by_llm`||n&&[`intro`,`outro`].some(n=>t.some(t=>t.category===n&&t.name===e[n]&&t.mode===`llm`)))&&e.llm?[{field:`llm.provider`,family:`llm`,label:`Text generation`,provider:e.llm.provider,model:e.llm.model}]:[],...n&&e.audio?[{field:`audio.provider`,family:`tts`,label:`Narration`,provider:e.audio.provider,model:e.audio.model,voice:e.audio.voice}]:[],...(e.sources.images===`generate`||r)&&e.images?[{field:`images.provider`,family:`image`,label:`Images`,provider:e.images.provider,model:e.images.model}]:[]]}function nP({name:e,children:t}){return(0,h.jsxs)(`section`,{"aria-label":`${e} summary`,className:`min-w-0 border-t border-line pt-5`,children:[(0,h.jsx)(`h3`,{className:`mb-4 font-semibold`,children:e}),t]})}function rP({form:e,entries:t,providers:n,voices:r,textModels:i,audioModels:a,imageModels:o,onReveal:s}){let c=tP(e,t);if(!c.length)return(0,h.jsx)(nP,{name:`Run readiness`,children:(0,h.jsx)(`p`,{className:`text-body text-ink2`,children:`No generated providers required. Supplied content is ready for processing.`})});let l={llm:i,tts:a,image:o};return(0,h.jsxs)(nP,{name:`Run readiness`,children:[(0,h.jsx)(`p`,{className:`mb-3 text-small text-ink2`,children:`These checks are refreshed with Review and checked again when you start.`}),(0,h.jsx)(`ul`,{className:`divide-y divide-line`,"aria-label":`Run readiness checks`,children:c.map(e=>{let t=n?.find(t=>t.id===e.provider&&t.family===e.family),i=eP(t),a=l[e.family],o=a?.models.find(t=>t.id===e.model),c=a===void 0?{ok:!0,text:`Model checked at Start`}:o!==void 0||a.allowsCustom?{ok:!0,text:`Model available`}:{ok:!1,text:`Model unavailable`},u=e.voice===void 0?void 0:r===void 0?{ok:!1,text:`Voice list unavailable`}:r.some(t=>t.provider===e.provider&&t.voiceId===e.voice)?{ok:!0,text:`Voice saved`}:{ok:!1,text:`Voice missing`},d=[i,c,...u?[u]:[]],f=d.every(e=>e.ok);return(0,h.jsxs)(`li`,{className:`flex flex-wrap items-center justify-between gap-3 py-3`,children:[(0,h.jsx)(`span`,{className:`font-medium`,children:e.label}),(0,h.jsx)(`span`,{className:f?`text-lime`:`text-red`,children:f?`Ready`:d.filter(e=>!e.ok).map(e=>e.text).join(` · `)}),f?null:(0,h.jsx)(B,{variant:`ghost`,onClick:()=>s(e.field),children:`Edit ↗`})]},`${e.family}:${e.provider}`)})})]})}function iP({fields:e,onReveal:t,children:n}){let{document:r,review:i}=Ek(),{form:a}=r,{api:o}=I(),s=_(),c=s.getQueryData(vy(o).queryKey),l=s.getQueryData(xy(o).queryKey),u=s.getQueryData(yy(o).queryKey),d=s.getQueryData(UO),f=s.getQueryData(oN(a.llm.provider)),p=s.getQueryData(oN(a.audio.provider)),m=s.getQueryData(oN(a.images.provider)),g=a.sources.audio===`generate`,v=[`from_prompt`,`prompt_by_llm`].includes(a.sources.thumbnail),y=a.sources.article===`generate`||a.sources.thumbnail===`prompt_by_llm`||g&&[`intro`,`outro`].some(e=>l?.entries.some(t=>t.category===e&&t.name===a[e]&&t.mode===`llm`)),b=e=>c?.providers.find(t=>t.id===e)?.displayName??e,x=(e,n,r)=>(0,h.jsxs)(`div`,{className:`grid min-w-0 grid-cols-[90px_minmax(0,1fr)_auto] items-start gap-x-3 py-1 sm:grid-cols-[145px_minmax(0,1fr)_auto]`,children:[(0,h.jsx)(`dt`,{className:`break-words py-2 text-ink2`,children:e}),(0,h.jsx)(`dd`,{className:`min-w-0 whitespace-pre-wrap break-words py-2`,children:r||`Not selected`}),n?(0,h.jsx)(`dd`,{children:(0,h.jsx)(B,{variant:`ghost`,"aria-label":`Edit ${e}`,onClick:()=>t(n),children:`Edit ↗`})}):null]},n??e),S=a.chunking.mode===`words`||a.chunking.mode===`characters`?a.chunking.mode:null;return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(rP,{form:a,entries:l?.entries??[],providers:c?.providers,voices:u?.voices,textModels:f,audioModels:p,imageModels:m,onReveal:t}),(0,h.jsxs)(nP,{name:`Content`,children:[(0,h.jsxs)(`dl`,{className:`text-body`,children:[x(`Project`,`title`,a.title||`Untitled run`),x(`Article`,`sources.article`,PM[a.sources.article]),a.sources.article===`generate`?x(`Article prompt`,`articlePrompt`,a.articlePrompt):x(`Article text`,`provided.article`,`Your article`),a.sources.article===`generate`?x(`Research`,`sources.research`,PM[a.sources.research]):x(`Research`,null,`Off · Article is provided`),a.sources.research===`provide`&&a.sources.article===`generate`?x(`Research text`,`provided.research`,a.provided.research):null,y?(0,h.jsxs)(h.Fragment,{children:[x(`Text provider`,`llm.provider`,b(a.llm.provider)),x(`Text model`,`llm.model`,f?.models.find(e=>e.id===a.llm.model)?.name??a.llm.model),a.llm.thinking||f?.models.find(e=>e.id===a.llm.model)?.thinkingModes?.length?x(`Thinking`,`llm.thinking`,a.llm.thinking??`Model default`):null]}):null,e.map(({name:e})=>x(e,`values.${e}`,a.values[e]??``))]}),n]}),(0,h.jsx)(nP,{name:`Outputs`,children:(0,h.jsxs)(`dl`,{className:`text-body`,children:[x(`Narration`,`sources.audio`,PM[a.sources.audio]),g?(0,h.jsxs)(h.Fragment,{children:[x(`Audio provider`,`audio.provider`,b(a.audio.provider)),x(`Audio model`,`audio.model`,p?.models.find(e=>e.id===a.audio.model)?.name??a.audio.model),x(`Voice`,`audio.voice`,u?.voices.find(e=>e.provider===a.audio.provider&&e.voiceId===a.audio.voice)?.name??a.audio.voice),x(`Chunking`,S?`chunking.${S}`:`chunking.mode`,S?`Every ${a.chunking[S]||`(not entered)`} ${S}`:a.chunking.mode===`whole`?`Whole text`:`Paragraph`),x(`Intro`,`intro`,a.intro||`Off`),x(`Narration Preparation`,`narrationPrompt`,a.narrationPrompt?`${a.narrationPrompt} · One LLM call per narration chunk and entry`:`Off`),x(`Outro`,`outro`,a.outro||`Off`)]}):null,a.sources.audio===`provide`?x(`Narration file`,`provided.audio`,a.provided.audio?.name):null,x(`Images`,`sources.images`,PM[a.sources.images]),a.sources.images===`generate`||v?(0,h.jsxs)(h.Fragment,{children:[x(`Image provider`,`images.provider`,b(a.images.provider)),x(`Image model`,`images.model`,m?.models.find(e=>e.id===a.images.model)?.name??a.images.model)]}):null,a.sources.images===`generate`?a.imagePrompts.length?a.imagePrompts.map((e,t)=>x(e.name,`imagePrompts.${t}.number`,`${e.name} · ${e.number||`(not entered)`} images`)):x(`Image prompts`,`imagePrompts`,`None selected`):null,a.sources.images===`provide`?x(`Image files`,`provided.images`,a.provided.images.length?(0,h.jsx)(`ol`,{className:`list-inside list-decimal`,children:a.provided.images.map(e=>(0,h.jsx)(`li`,{children:e.name},e.attachmentId))}):`No files selected`):null,x(`Thumbnail`,`sources.thumbnail`,PM[a.sources.thumbnail]),v?x(`Thumbnail prompt`,`thumbnailPrompt`,a.thumbnailPrompt):null,a.sources.thumbnail===`provide`?x(`Thumbnail file`,`provided.thumbnail`,a.provided.thumbnail?.name):null,x(`Video`,`sources.video`,PM[a.sources.video])]})}),(0,h.jsxs)(nP,{name:`Checkpoints`,children:[(0,h.jsx)(XN,{selected:a.checkpoints,reviewed:i.valid?i.receipt?.checkpointSet:void 0}),(0,h.jsx)(B,{variant:`ghost`,"aria-label":`Edit checkpoints`,onClick:()=>t(`checkpoints`),children:`Edit checkpoints ↗`})]}),(0,h.jsxs)(nP,{name:`Style`,children:[(0,h.jsxs)(`dl`,{className:`text-body`,children:[x(`Frame`,`format`,a.format),a.sources.audio===`off`?x(`Subtitles`,null,`Off · Audio is Off`):x(`Subtitles`,`subtitles.mode`,a.subtitles.mode),a.sources.audio!==`off`&&a.subtitles.mode!==`off`?(0,h.jsxs)(h.Fragment,{children:[x(`Subtitle font`,`subtitles.fontId`,d?.fonts.find(e=>e.id===a.subtitles.fontId)?.name??a.subtitles.fontId),x(`Subtitle size`,`subtitles.fontSize`,`${a.subtitles.fontSize||`(not entered)`} px`),x(`Subtitle position`,`subtitles.position`,a.subtitles.position)]}):null]}),a.sources.audio!==`off`&&a.subtitles.mode===`files`?(0,h.jsx)(`p`,{className:`mt-3 text-small text-ink2`,children:`Font, size and position apply to burned captions. SRT/VTT players choose their own styling.`}):null]})]})}function aP({fields:e,errors:t,onReveal:n,problem:r}){let i=Ek(),{document:a,review:o}=i,s=a.form,c=(0,m.useId)(),l=yk(a,i.view),u=o.starting||o.uncertain;(0,m.useEffect)(()=>{i.reviewDraft()},[i.reviewDraft]);let d=o.valid?o.receipt?.runs??[]:[];return(0,h.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-6 py-6`,children:[(0,h.jsx)(`p`,{className:`text-body text-ink2`,children:`Check your setup and estimated costs before starting.`}),t.length?(0,h.jsx)(`ul`,{"aria-label":`Setup errors`,className:`text-small text-red`,children:t.map(e=>(0,h.jsx)(`li`,{children:(0,h.jsx)(B,{variant:`ghost`,onClick:()=>n(e.field),children:e.message})},`${e.field}-${e.message}`))}):null,l?(0,h.jsx)(B,{variant:`ghost`,onClick:()=>n(l),children:`Wait for uploads to finish before Start`}):null,o.error?(0,h.jsx)(`p`,{role:`alert`,className:`text-body text-red`,children:o.error}):null,(0,h.jsx)(iP,{fields:e,onReveal:n,children:(0,h.jsxs)(`details`,{className:`mt-5 border-t border-line py-3`,children:[(0,h.jsx)(`summary`,{className:`cursor-pointer text-small`,children:s.sources.article===`provide`?`Read the supplied article and resolved prompts`:`Read the resolved prompt`}),d.length?d.map((e,t)=>(0,h.jsxs)(`div`,{className:`mt-4`,children:[(0,h.jsx)(`h4`,{className:`font-medium`,children:e.draft.title}),e.draft.sources.article===`provide`?(0,h.jsx)(`p`,{className:`mt-3 whitespace-pre-wrap break-words text-body`,children:e.draft.provided.article}):null,Object.entries(e.rendered).map(([e,t])=>(0,h.jsxs)(`div`,{className:`mt-3`,children:[(0,h.jsx)(`h5`,{className:`text-small text-ink2`,children:e}),(0,h.jsx)(`p`,{className:`whitespace-pre-wrap break-words text-body`,children:t})]},e))]},a.variants[t-1]?.id??i.activeId)):(0,h.jsx)(`p`,{className:`mt-3 text-small text-ink2`,children:`Refresh review to read the exact resolved inputs.`})]})}),(0,h.jsx)(`fieldset`,{disabled:u,className:`min-w-0`,children:(0,h.jsx)(ZN,{fields:e,items:a.variants.map(({id:e,...t})=>({...t,key:e})),title:s.title,values:s.values,problem:r,onChange:e=>i.edit({...a,variants:e.map(({key:e,...t})=>({...t,id:e}))})})}),(0,h.jsxs)(`div`,{className:`flex flex-col gap-4 border-t border-line pt-5`,children:[(0,h.jsx)(`h3`,{className:`font-semibold`,children:`Estimated cost`}),(0,h.jsxs)(`label`,{htmlFor:c,className:`text-body`,children:[`Expected article words per video`,(0,h.jsx)(cM,{id:c,"data-play-field":`expectedWords`,type:`number`,min:1,max:1e5,value:a.expectedWords,disabled:u,onChange:e=>i.edit({...a,expectedWords:e.target.value})})]}),(0,h.jsx)(`p`,{className:`text-small text-ink2`,children:`Estimated provider charges in USD. Actual usage can differ. This estimate does not cap spending.`}),o.pending?(0,h.jsx)(`p`,{role:`status`,children:`Calculating estimate…`}):null,o.valid&&o.receipt?(0,h.jsx)(QN,{estimates:o.receipt.estimates}):(0,h.jsx)(`p`,{className:`text-small text-ink2`,children:`Review needs refreshing before Start.`}),(0,h.jsx)(B,{disabled:o.pending||u||!!l,onClick:()=>{i.reviewDraft()},children:`Refresh review`})]}),(0,h.jsxs)(`div`,{className:`flex justify-between gap-3 border-t border-line pt-5`,children:[(0,h.jsx)(B,{variant:`ghost`,onClick:()=>{i.navigate(`style`)},children:`← Style`}),(0,h.jsx)(B,{variant:`play`,"data-tour":`play-start`,disabled:o.starting||!o.uncertain&&(!o.valid||o.pending||t.length>0||!!l),onClick:()=>{i.startRun()},children:o.starting?`Starting…`:o.uncertain?`Check Start result`:a.variants.length?`Queue ${a.variants.length+1} videos`:`Start run`})]})]})}var oP=[{id:`content`,label:`Content`,description:`Article and keywords`},{id:`outputs`,label:`Outputs`,description:`Voice and images`},{id:`style`,label:`Style`,description:`Frame and captions`},{id:`review`,label:`Review`,description:`Cost and start`}];function sP({section:e,onNavigate:t}){return(0,h.jsx)(`nav`,{"aria-label":`Run setup`,className:`mb-7 grid grid-cols-2 border-b border-line min-[700px]:grid-cols-4`,children:oP.map((n,r)=>(0,h.jsxs)(`div`,{className:`border-b-2 py-4 ${e===n.id?`border-focus`:`border-transparent`}`,children:[(0,h.jsxs)(`button`,{type:`button`,"aria-current":e===n.id?`step`:void 0,onClick:()=>t(n.id),className:`min-h-11 w-full text-left font-semibold ${e===n.id?`text-run-text`:`text-ink`}`,children:[(0,h.jsx)(`span`,{"aria-hidden":`true`,className:`mr-3 inline-flex size-7 items-center justify-center rounded-full border text-small ${e===n.id?`border-accent bg-accent text-accent-ink`:`border-line`}`,children:r+1}),n.label]}),(0,h.jsx)(`p`,{className:`pl-10 text-small text-ink3`,children:n.description})]},n.id))})}function cP({form:e,blocker:t,onReveal:n}){let r=[[`Article`,e.sources.article,e.sources.article===`provide`?`provided.article`:`articlePrompt`],[`Audio`,e.sources.audio,`sources.audio`],...e.sources.audio===`generate`&&e.narrationPrompt?[[`Narration Preparation`,e.narrationPrompt,`narrationPrompt`]]:[],[`Images`,e.sources.images===`generate`?`${e.imagePrompts.reduce((e,t)=>e+t.number,0)} images`:e.sources.images,`sources.images`],[`Export`,e.sources.video===`generate`?e.sources.audio===`off`?`Silent MP4`:`MP4`:e.sources.audio===`off`?`Individual outputs`:`Combined WAV`,`sources.video`]];return(0,h.jsxs)(`aside`,{"aria-label":`Setup summary`,className:`min-w-0`,children:[(0,h.jsx)(`h2`,{className:`mb-3 font-semibold`,children:`This run`}),(0,h.jsx)(`dl`,{className:`divide-y divide-line`,children:r.map(([e,t,r])=>(0,h.jsxs)(`div`,{className:`flex items-center justify-between gap-3 py-2 text-small`,children:[(0,h.jsx)(`dt`,{className:`text-ink3`,children:e}),(0,h.jsx)(`dd`,{children:(0,h.jsx)(B,{variant:`ghost`,onClick:()=>n(r),"aria-label":`Edit ${e}`,children:t})})]},e))}),t?(0,h.jsxs)(`div`,{className:`mt-4 text-small text-ink2`,children:[(0,h.jsx)(`p`,{children:t.hint}),(0,h.jsx)(B,{variant:`ghost`,onClick:()=>n(t.field),children:`Fix setup`})]}):null,(0,h.jsx)(`p`,{className:`mt-4 text-small text-ink3`,children:`Nothing starts until you review the costs and choose Start run.`})]})}function lP(e){return e.upload?(0,h.jsx)(dP,{value:e.value,onPick:e.onPick,upload:e.upload}):(0,h.jsx)(uP,{...e})}function uP({value:e,onPick:t,onUploading:n}){let{api:r}=I(),i=_(),a=it({mutationFn:e=>GO(r,e),onSuccess:({font:e})=>{i.setQueryData(UO,t=>({fonts:[...(t?.fonts??[]).filter(t=>t.id!==e.id),e]})),i.invalidateQueries({queryKey:UO})}}),o=a.isPending,s=(0,m.useRef)(t);s.current=t;let c=(0,m.useRef)(n);return c.current=n,(0,m.useEffect)(()=>{c.current(o)},[o]),(0,m.useEffect)(()=>()=>c.current(!1),[]),(0,h.jsx)(dP,{value:e,onPick:t,upload:{pending:o,error:a.error?.message,pick:e=>a.mutate(e,{onSuccess:({font:e})=>s.current(e.id)})}})}function dP({value:e,onPick:t,upload:n}){let{api:r}=I(),i=(0,m.useId)(),a=(0,m.useId)(),o=nt({queryKey:UO,queryFn:()=>WO(r),staleTime:6e4}),s=n.pending,c=o.data?.fonts??[],l=e!=="default"&&!c.some(t=>t.id===e);return(0,h.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3`,children:[(0,h.jsxs)(`div`,{className:`min-w-0 basis-full`,children:[(0,h.jsx)(oM,{htmlFor:i,className:`mb-1`,children:`Subtitle font`}),(0,h.jsxs)(`select`,{id:i,"data-play-field":`subtitles.fontId`,value:e,disabled:s,onChange:e=>t(e.target.value),className:`h-8 w-full rounded-control border border-line2 bg-panel2 px-[10px] text-small text-ink`,children:[c.some(e=>e.id==="default")?null:(0,h.jsx)(`option`,{value:`default`,children:`Default font · bundled`}),l?(0,h.jsxs)(`option`,{value:e,children:[e,` · saved font`]}):null,c.map(e=>(0,h.jsxs)(`option`,{value:e.id,children:[e.name,` · `,e.source]},e.id))]})]}),(0,h.jsxs)(`div`,{className:`min-w-0 basis-full`,children:[(0,h.jsx)(oM,{htmlFor:a,className:`mb-1`,children:`Upload font (.ttf or .otf)`}),(0,h.jsx)(`input`,{id:a,"data-play-field":`subtitles.fontUpload`,type:`file`,accept:`.ttf,.otf,font/ttf,font/otf`,disabled:s,className:`w-full text-small text-ink2 file:mr-2 file:rounded-control file:border file:border-line2 file:bg-panel2 file:px-2 file:py-1 file:text-ink`,onChange:e=>{let t=e.target.files?.[0];e.target.value=``,t&&n.pick(t)}})]})]}),s?(0,h.jsx)(`p`,{role:`status`,className:`text-small text-ink2`,children:`Uploading font…`}):null,n.error?(0,h.jsx)(`p`,{role:`alert`,className:`text-small text-red`,children:n.error}):null,l&&o.data?(0,h.jsx)(`p`,{role:`alert`,children:`Saved font is unavailable. Choose another font or upload it again.`}):null,o.error?(0,h.jsxs)(`p`,{role:`alert`,className:`text-small text-red`,children:[`Could not load fonts. `,o.error.message]}):null]})}function fP({value:e,format:t=`16:9`,audioEnabled:n,videoEnabled:r,disabled:i=!1,onChange:a,onUploading:o,problem:s,session:c,fontUpload:l,showPreview:u=!0,illustratedPositions:d=!1,rawFontSize:f}){let p=(0,m.useId)(),g=(0,m.useId)(),_=(0,m.useId)(),v=(0,m.useId)(),[y,b]=(0,m.useState)(!1),x=s?.(`subtitles.fontId`),S=s?.(`subtitles.fontSize`),C=s?.(`subtitles.mode`)??s?.(`subtitles`);return(0,h.jsxs)(`section`,{className:`flex min-w-0 flex-col gap-3`,"aria-label":`Subtitles`,children:[(0,h.jsxs)(`fieldset`,{disabled:i||!n,className:`flex min-w-0 flex-col gap-3 disabled:opacity-60`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3`,children:[(0,h.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,h.jsx)(oM,{htmlFor:p,className:`mb-1`,children:`Subtitles`}),(0,h.jsxs)(`select`,{id:p,"data-play-field":`subtitles.mode`,value:n?e.mode:`off`,disabled:l?.pending??y,"aria-describedby":_,"aria-invalid":C!==void 0,onChange:t=>a({...e,mode:t.target.value}),className:`h-8 w-full rounded-control border border-line2 bg-panel2 px-[10px] text-small text-ink`,children:[(0,h.jsx)(`option`,{value:`off`,children:`Off`}),(0,h.jsx)(`option`,{value:`files`,children:`Subtitle files (.srt + .vtt)`}),(0,h.jsx)(`option`,{value:`burn-in`,disabled:!r,children:`Burn into video + files`})]})]}),(0,h.jsx)(`span`,{className:`pb-1 text-label text-ink3`,children:`English · local · no paid API`})]}),e.mode!==`off`&&n?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`p`,{className:`text-small text-ink2`,children:`Timed from your narration on this computer. First use downloads an approximately 95 MB speech model. Review the subtitles before publishing.`}),(0,h.jsxs)(`div`,{className:`grid items-start gap-5`,style:{gridTemplateColumns:`repeat(auto-fit, minmax(min(100%, 240px), 1fr))`},children:[(0,h.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-4`,children:[(0,h.jsx)(lP,{...l?{upload:l}:{},value:e.fontId,onPick:t=>c?c.selectFont(t):a({...e,fontId:t}),onUploading:e=>{b(e),o?.(e)}}),(0,h.jsxs)(`div`,{className:d?`w-full`:`max-w-[180px]`,children:[(0,h.jsx)(oM,{htmlFor:g,className:`mb-1`,children:`Subtitle font size`}),(0,h.jsxs)(`div`,{className:`flex items-center gap-5`,children:[d?(0,h.jsx)(`input`,{"aria-label":`Subtitle font size slider`,type:`range`,min:16,max:120,step:1,value:Math.max(16,Math.min(120,Number.isFinite(e.fontSize)?e.fontSize:48)),className:`min-w-0 flex-1 accent-accent`,onChange:t=>f?f.onChange(t.target.value):a({...e,fontSize:Number(t.target.value)})}):null,(0,h.jsx)(cM,{className:d?`w-20`:void 0,id:g,"data-play-field":`subtitles.fontSize`,type:`number`,min:16,max:120,step:1,value:f?.value??e.fontSize,"aria-invalid":!NM(e)||S!==void 0,onChange:t=>f?f.onChange(t.target.value):a({...e,fontSize:Number(t.target.value)})})]}),!NM(e)||S?(0,h.jsx)(`p`,{role:`alert`,className:`mt-1 text-label text-red`,children:S??`Choose a whole font size from 16 to 120.`}):null]}),(0,h.jsxs)(`div`,{children:[(0,h.jsx)(oM,{htmlFor:d?void 0:v,id:`${v}-label`,className:`mb-1`,children:`Subtitle position`}),d?(0,h.jsx)(Hj,{type:`single`,"aria-labelledby":`${v}-label`,value:e.position??`bottom`,onValueChange:t=>{let n=QD.find(e=>e===t);n&&a({...e,position:n})},className:`grid w-full grid-cols-5 gap-2 overflow-visible border-0`,children:QD.map((t,n)=>(0,h.jsxs)(Uj,{value:t,"aria-label":t,"data-play-field":(e.position??`bottom`)===t?`subtitles.position`:void 0,className:`flex min-w-0 flex-col items-center gap-2 rounded-control border border-line2 bg-panel px-1 py-3 text-[10px] last:border-r data-[state=on]:border-focus data-[state=on]:text-run-text data-[state=on]:shadow-none`,children:[(0,h.jsx)(`span`,{"aria-hidden":`true`,className:`relative block h-11 w-7 rounded-[2px] border border-current`,children:(0,h.jsx)(`span`,{className:`absolute left-1 right-1 h-[3px] bg-current`,style:{top:`${8+n*20}%`}})}),(0,h.jsxs)(`span`,{children:[t[0]?.toUpperCase(),t.slice(1)]})]},t))}):(0,h.jsx)(`select`,{id:v,"data-play-field":`subtitles.position`,value:e.position??`bottom`,onChange:t=>{let n=QD.find(e=>e===t.target.value);n&&a({...e,position:n})},className:`h-8 w-full rounded-control border border-line2 bg-panel2 px-[10px] text-small text-ink`,children:QD.map(e=>(0,h.jsxs)(`option`,{value:e,children:[e[0]?.toUpperCase(),e.slice(1)]},e))})]})]}),u?(0,h.jsx)(KN,{value:e,format:t,...c?{sample:c.previewText}:{}}):null]}),c?.fontUpload&&!c.fontUploading?(0,h.jsxs)(`p`,{role:`alert`,children:[`Reattach `,c.fontUpload.name,`, or select a font.`]}):null,x?(0,h.jsx)(`p`,{role:`alert`,className:`text-small text-red`,children:x}):null,e.mode===`files`?(0,h.jsx)(`p`,{className:`text-label text-ink3`,children:`Font, size and position apply to burned captions. SRT/VTT players choose their own styling.`}):null]}):null]}),c?.fontUpload&&(e.mode===`off`||!n)?(0,h.jsxs)(`div`,{className:`flex flex-col items-start gap-3`,children:[(0,h.jsx)(`p`,{role:c.fontUploading?`status`:`alert`,className:`text-small text-ink2`,children:c.fontUploading?`Uploading ${c.fontUpload.name}…`:`Unfinished font upload: ${c.fontUpload.name}`}),l?.error?(0,h.jsx)(`p`,{role:`alert`,className:`text-small text-red`,children:l.error}):null,(0,h.jsx)(B,{"data-play-field":`subtitles.fontUpload`,disabled:i,onClick:()=>c.selectFont(e.fontId),children:`Keep current font`})]}):null,C?(0,h.jsx)(`p`,{role:`alert`,className:`text-small text-red`,children:C}):null,(0,h.jsx)(`p`,{id:_,className:`text-small text-ink2`,children:n?r?`Optional: download subtitles separately or keep them visible in the video.`:`Audio exports support separate subtitle files. Enable Video to burn captions into an MP4.`:`Turn Audio on to add subtitles.`})]})}function pP({value:e,onPick:t}){let n=(0,m.useId)();return(0,h.jsxs)(`div`,{className:`w-full`,children:[(0,h.jsx)(oM,{id:n,className:`mb-2`,children:`Frame format`}),(0,h.jsx)(Hj,{type:`single`,value:e,"aria-labelledby":n,className:`w-full max-w-[400px] gap-3 overflow-visible border-0`,onValueChange:e=>{(e===`16:9`||e===`9:16`)&&t(e)},children:[`16:9`,`9:16`].map(t=>(0,h.jsxs)(Uj,{value:t,"data-play-field":e===t?`format`:void 0,"aria-label":t,className:`flex h-28 min-w-0 flex-1 items-center justify-center gap-4 rounded-control border border-line2 bg-panel p-3 last:border-r data-[state=on]:border-focus data-[state=on]:shadow-none`,children:[(0,h.jsx)(`span`,{className:`flex h-12 items-center justify-center`,"aria-hidden":`true`,children:(0,h.jsx)(`span`,{"data-format-shape":t,className:`block rounded-[2px] border-2 border-current`,style:{width:t===`16:9`?64:27,aspectRatio:t===`16:9`?`16 / 9`:`9 / 16`}})}),(0,h.jsxs)(`span`,{className:`text-left`,children:[(0,h.jsx)(`span`,{className:`block text-body font-semibold`,children:t}),(0,h.jsx)(`span`,{className:`text-label text-ink3`,children:t===`16:9`?`Landscape`:`Portrait`})]})]},t))})]})}function mP({problem:e}){let t=Ek(),{document:n}=t,{form:r}=n,i=(0,m.useId)(),a=e=>t.edit({...n,form:{...r,subtitles:{...e,fontSize:r.subtitles.fontSize}}});return(0,h.jsxs)(`div`,{"data-tour":`play-subtitles`,className:`flex min-w-0 flex-col gap-6 py-6`,children:[(0,h.jsx)(`p`,{className:`text-body text-ink2`,children:`See frame and caption changes in the preview as you go.`}),(0,h.jsx)(pP,{value:r.format,onPick:e=>t.edit({...n,form:{...r,format:e}})}),(0,h.jsx)(`div`,{className:`border-t border-line pt-6`,children:(0,h.jsx)(fP,{showPreview:!1,illustratedPositions:!0,fontUpload:t.fontUpload,session:{previewText:n.previewText,fontUploading:t.fontUploading,fontUpload:n.fontUpload,selectFont:t.selectFont,uploadSubtitleFont:t.uploadSubtitleFont},value:{...r.subtitles,fontSize:Number(r.subtitles.fontSize)},rawFontSize:{value:r.subtitles.fontSize,onChange:e=>t.edit({...n,form:{...r,subtitles:{...r.subtitles,fontSize:e}}})},format:r.format,audioEnabled:r.sources.audio!==`off`,videoEnabled:r.sources.video===`generate`&&r.sources.images!==`off`,onChange:a,problem:e})}),(0,h.jsxs)(`div`,{className:`border-t border-line pt-6`,children:[(0,h.jsx)(oM,{htmlFor:i,className:`mb-2`,children:`Preview text`}),(0,h.jsx)(cM,{id:i,value:n.previewText,onChange:e=>t.edit({...n,previewText:e.target.value})}),(0,h.jsx)(`p`,{className:`mt-2 text-small text-ink3`,children:`Just a sample. Your actual captions come from the narration.`})]})]})}function hP(e,t,n){let r=e?.prompts??[],i=e?.entries??[];return{prompts:[...r,...t.filter(e=>!r.some(t=>t.kind===e.kind&&t.name.toLowerCase()===e.name.toLowerCase()))],entries:[...i,...n.filter(e=>!i.some(t=>t.category===e.category&&t.name.toLowerCase()===e.name.toLowerCase()))]}}function gP(){let e=Gi();return(0,h.jsx)(_P,{onCreated:t=>{e({to:`/projects/$projectId`,params:{projectId:t}})}})}function _P({onCreated:e}){let{api:t}=I(),n=qN(),r=PA(),i=nt(vy(t)),a=nt(by(t)),o=nt(xy(t)),s=nt(yy(t)),c=nt(Sy(t)),[l,u]=Ak(),d=Ek(),f=hP(d.document.librarySnapshot,a.data?.prompts??[],o.data?.entries??[]),p=d.document.variants.map(({id:e,...t})=>({...t,key:e})),g=d.fontUploading||d.document.fontUpload!==null,_=d.review.fields,[v,y]=(0,m.useState)(new Set),b=(0,m.useRef)(null),x=(0,m.useRef)(null),S=Gi(),C=(0,m.useRef)(d.activeId);(0,m.useLayoutEffect)(()=>{C.current!==d.activeId&&(C.current=d.activeId,y(new Set))},[d.activeId]);let w=(0,m.useRef)(null);(0,m.useLayoutEffect)(()=>{let e=d.reveal;if(e||(w.current=null),e&&e.sequence!==w.current&&e.section===d.section&&b.current){if(w.current=e.sequence,e.field){let t=[...b.current.querySelectorAll(`[data-play-field]`)].find(t=>t.dataset.playField===e.field)?.parentElement;for(;t&&t!==b.current;)t instanceof HTMLDetailsElement&&(t.open=!0),t=t.parentElement;if(HN(b.current,e.field))return}x.current?.focus()}},[d.reveal,d.section]);let T=e=>{let t=tN(e,l)??UN(e,l,p);y(n=>new Set([...n,e,t.field])),d.navigate(t.section,t.field)},E=async e=>{await d.flush()&&(e===`/prompts`?await S({to:`/prompts/new`,search:{kind:`article`}}):await S({to:e}))},D=e=>{u(t=>{let n={...t,...e};return{...n,subtitles:MM(n.subtitles,n.sources)}}),d.invalidateReview(!0)},{fields:O,result:ee,blocker:k}=WM({form:l,prompts:f.prompts,entries:f.entries,silenceGapSeconds:c.data?.silenceGapSeconds??3}),A=g?{field:`subtitles.fontUpload`,hint:`Wait for the subtitle font upload to finish to play`}:k;(0,m.useEffect)(()=>{if(!d.review.created)return;let t=d.takeCreated()?.projectIds[0];t&&(r({type:`project-created`,id:t}),e(t))},[d.review.created,d.takeCreated,r,e]);let j=ee.ok?_:[...ee.fields,..._],M=(...e)=>!j.some(t=>e.some(e=>t.field===e||t.field.startsWith(`${e}.`))),N=(e,t)=>f.prompts.some(n=>n.kind===e&&n.name===t),P=e=>e?.file!==void 0&&e.error===void 0;NA({playArticleReady:M(`sources.article`,`articlePrompt`,`provided.article`)&&(l.sources.article===`provide`||N(`article`,l.articlePrompt)),playAudioReady:l.sources.audio===`off`||M(`sources.audio`,`audio`,`provided.audio`)&&(l.sources.audio!==`provide`||P(l.provided.audio)),playImagesReady:l.sources.images===`off`||M(`sources.images`,`images`,`imagePrompts`,`provided.images`)&&(l.sources.images===`provide`?l.provided.images.every(P):l.imagePrompts.every(e=>N(`image`,e.name))),playVideoReady:M(`sources.video`),playSubtitlesReady:M(`subtitles`)&&!g,playOptionsReady:M(`title`,`format`,`llm`,`intro`,`outro`),playHasKeywords:O.length>0,playKeywordsReady:M(`values`),playReady:A===void 0&&!d.review.starting});let F=e=>{let t=(tN(e,l)??UN(e,l,p)).field;return j.find(n=>(tN(n.field,l)??UN(n.field,l,p)).field===t&&(_.includes(n)||v.has(e)||v.has(t)))?.message},te=()=>{d.navigate(`review`)},ne=e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),te())},re=(e,t)=>{d.invalidateReview(!0),d.attach(e,t)},ie=(e,t)=>{u(n=>({...n,provided:e===`images`?{...n.provided,images:n.provided.images.filter(e=>e.key!==t)}:e===`audio`?{...n.provided,audio:void 0}:{...n.provided,thumbnail:void 0}}))},ae=[i,a,o,s,c].find(e=>e.error!==null)?.error?.message,oe={form:l,providers:i.data?.providers??[],prompts:f.prompts,voices:s.data?.voices??[],silenceGapSeconds:c.data?.silenceGapSeconds??3,problem:F,update:D,onPickFiles:re,onRemoveFile:ie,onReattachFile:(e,t,n)=>{d.attach(e,[n],t)}};return(0,h.jsxs)(`div`,{ref:b,onKeyDown:ne,onBlurCapture:e=>{let t=e.target.dataset.playField;t&&y(e=>new Set([...e,t]))},"data-play-grid":`true`,className:`mx-auto max-w-[1320px] pb-[calc(4rem+env(safe-area-inset-bottom))] [&_input:not([type=checkbox])]:min-h-10 [&_select]:min-h-10 [&_button]:min-h-10 [&_summary]:min-h-10 max-[1099px]:[&_button]:min-h-11 max-[1099px]:[&_input:not([type=checkbox])]:min-h-11 max-[1099px]:[&_select]:min-h-11 max-[1099px]:[&_summary]:min-h-11`,children:[(0,h.jsxs)(`header`,{className:`mb-6 flex flex-wrap items-start justify-between gap-4`,children:[(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`h1`,{className:`mb-1 text-[36px] font-bold tracking-[-0.01em]`,children:`New run`}),(0,h.jsx)(`p`,{className:`text-body text-ink2`,children:`Create the article, choose the outputs, then review.`})]}),(0,h.jsx)(VN,{})]}),ae?(0,h.jsx)(`p`,{className:`mb-4 text-body text-red`,children:ae}):null,(0,h.jsx)(sP,{section:d.section,onNavigate:e=>{d.navigate(e)}}),(0,h.jsxs)(`div`,{className:`grid min-w-0 grid-cols-1 items-start gap-7 min-[1100px]:grid-cols-[minmax(0,1fr)_360px]`,children:[(0,h.jsxs)(`section`,{"data-tour":d.section===`content`?`play-options`:void 0,className:`min-w-0`,children:[(0,h.jsx)(`h2`,{ref:x,tabIndex:-1,className:`text-xl font-semibold`,children:d.section===`style`?`Make it look like yours.`:oP.find(e=>e.id===d.section)?.label}),n?null:d.section===`style`?(0,h.jsx)(`div`,{className:`mt-5`,children:(0,h.jsx)(JN,{})}):(0,h.jsxs)(`details`,{className:`my-5 rounded-control border border-line p-3`,children:[(0,h.jsxs)(`summary`,{className:`min-h-11 cursor-pointer text-small font-semibold`,children:[`Preview · `,l.format]}),(0,h.jsx)(JN,{})]}),d.section===`content`?(0,h.jsx)(BN,{...oe,fields:O,entries:f.entries,onLibrary:e=>{E(e)}}):null,d.section===`outputs`?(0,h.jsx)(YN,{...oe,entries:f.entries,missingKeyword:j.find(e=>e.field.startsWith(`values.`))?.field,onKeyword:T,onSettings:()=>{E(`/settings`)}}):null,d.section===`style`?(0,h.jsx)(mP,{problem:F}):null,d.section===`review`?(0,h.jsx)(aP,{fields:O,errors:j,problem:F,onReveal:T}):(0,h.jsx)(`div`,{className:`mt-8 flex justify-end border-t border-line py-6`,children:(0,h.jsxs)(B,{variant:`play`,onClick:()=>{let e=oP[oP.findIndex(e=>e.id===d.section)+1];e&&d.navigate(e.id)},children:[`Continue to`,` `,oP[oP.findIndex(e=>e.id===d.section)+1]?.label,` `,`→`]})})]}),(0,h.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-6 min-[1100px]:sticky min-[1100px]:top-6`,children:[n?(0,h.jsx)(JN,{}):null,(0,h.jsx)(cP,{form:l,blocker:A,onReveal:T})]})]})]})}function vP(){let{api:e}=I(),t=nt({queryKey:[`batch-queue`],queryFn:async()=>eo(await e.fetch(`${e.origin}/api/projects/queue`)),refetchInterval:2e3,retry:!1}),n=nt(my(e));return t.data?.queue.length?(0,h.jsxs)(`details`,{className:`mb-4 rounded-panel border border-line bg-panel p-3`,open:!0,children:[(0,h.jsxs)(`summary`,{className:`cursor-pointer text-body font-semibold`,children:[`Video queue · `,t.data.queue.length,` remaining`]}),(0,h.jsx)(`p`,{className:`mt-1 text-small text-ink2`,children:`One batch video runs at a time. Pause holds the queue; failure or cancellation advances it.`}),(0,h.jsx)(`ol`,{className:`mt-2 max-h-40 overflow-y-auto`,children:t.data.queue.map((e,t)=>{let r=n.data?.projects.find(t=>t.id===e.projectId);return(0,h.jsxs)(`li`,{className:`flex justify-between gap-3 py-1 text-small`,children:[(0,h.jsxs)(sa,{className:`truncate underline`,to:`/projects/$projectId`,params:{projectId:e.projectId},children:[t+1,`. `,r?.title??`Video`]}),(0,h.jsx)(`span`,{className:`shrink-0 text-ink2`,children:r?.status===`paused`?`Paused`:e.state===`active`?`Active`:`Queued`})]},e.projectId)})})]}):null}function yP(e,t){return e.filter(e=>e.stageKind===t.kind)}function bP(e,t){return e.find(e=>e.role===t)}var xP={research:`Replaces the notes, then re-runs the enabled stages below.`,article:`Replaces the article, then re-runs the enabled stages below.`,audio:`Replaces the narration and refreshes the final audio or video export.`,images:`Replaces every image in this run and re-renders video when enabled.`,thumbnail:`Replaces the thumbnail.`,video:`Replaces the final audio or video export.`};function SP(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:xP[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 CP=(0,m.createContext)(!1);function wP({action:e,run:t,disabled:n=!1,pending:r=!1,variant:i=`outline`,className:a,children:o}){let[s,c]=(0,m.useState)(!1),l=SP(e);return(0,m.useContext)(CP)&&e.kind!==`cancel`?null:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(B,{type:`button`,variant:i,disabled:n,className:z(i===`ghost`?`px-2 text-small`:void 0,a),onClick:()=>{c(!0)},children:o}),(0,h.jsx)(Nj,{open:s,title:l.title,consequence:l.consequence,verb:l.verb,dismiss:l.dismiss,pending:r,onConfirm:()=>{c(!1),t()},onCancel:()=>{c(!1)}})]})}function TP(e){let{api:t}=I();return nt({...hy(t,e),enabled:!1,select:e=>e.revisionId??null}).data??null}var EP=(e,t=null)=>[`live-writing`,e,t];function DP(e,t){let n=e=>e.callId===t.callId&&e.revisionId===t.revisionId&&e.workId===t.workId,r=e.find(n),i=(t.reset?t.text:`${r?.text??``}${t.text}`).slice(-65536),a={...t.revisionId===void 0?{}:{revisionId:t.revisionId},...t.workId===void 0?{}:{workId:t.workId},...t.workPieceId===void 0?{}:{workPieceId:t.workPieceId},stage:t.stage,callId:t.callId,...t.label===void 0?{}:{label:t.label},text:i};return(r?e.map(e=>n(e)?a:e):[...e,a]).slice(-24)}function OP({projectId:e,stage:t}){let n=(nt({queryKey:EP(e,TP(e)),queryFn:()=>[],enabled:!1}).data??[]).filter(e=>e.stage===t),[r,i]=(0,m.useState)(),a=n.find(e=>e.callId===r)??n.at(-1),[o,s]=(0,m.useState)(!0),c=(0,m.useRef)(null);return(0,m.useEffect)(()=>{a?.text&&o&&c.current&&(c.current.scrollTop=c.current.scrollHeight)},[o,a?.text]),n.length===0&&t!==`research`&&t!==`article`?null:(0,h.jsxs)(`div`,{className:`mx-5 mt-5 rounded-control border border-line2 bg-panel2`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 border-b border-line px-4 py-3`,children:[(0,h.jsx)(`span`,{className:`text-small font-semibold text-run-text`,children:`Live writing`}),n.length>1?(0,h.jsx)(aN,{"aria-label":`Live writing task`,value:a?.callId??``,onChange:e=>i(e.target.value),className:`max-w-[280px]`,children:n.map((e,t)=>(0,h.jsxs)(`option`,{value:e.callId,children:[e.label??`Writing`,` · `,t+1]},e.callId))}):null,(0,h.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-label text-ink2`,children:[(0,h.jsx)(`input`,{type:`checkbox`,checked:o,onChange:e=>s(e.target.checked)}),`Follow output`]})]}),(0,h.jsx)(`section`,{ref:c,"aria-label":`Live writing preview`,tabIndex:0,className:`max-h-[360px] min-h-32 overflow-auto whitespace-pre-wrap break-words p-4 font-sans text-small leading-relaxed text-ink2`,children:a?.text||`Waiting for the provider's first text…`}),(0,h.jsx)(`p`,{className:`border-t border-line px-4 py-2 text-label text-ink3`,children:`Live preview. The complete output is saved when this stage finishes.`})]})}function kP(e){let t=e.role.replaceAll(`_`,`-`);return(e.role===`narration_txt`||e.role===`tts_script`)&&e.meta.segment!==void 0?`${t}-${e.meta.segment}`:e.role===`instructions`?`${e.stageKind}-${t}`:e.role===`image`&&e.meta.index!==void 0?`${t}-${String(e.meta.index)}`:t}function AP(e,t){let n=t||{};return(e[e.length-1]===``?[...e,``]:e).join((n.padRight?` `:``)+`,`+(n.padLeft===!1?``:` `)).trim()}var jP=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,MP=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,NP={};function PP(e,t){return((t||NP).jsx?MP:jP).test(e)}var FP=/[ \t\n\f\r]/g;function IP(e){return typeof e==`object`?e.type===`text`&&LP(e.value):LP(e)}function LP(e){return e.replace(FP,``)===``}var RP=class{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}};RP.prototype.normal={},RP.prototype.property={},RP.prototype.space=void 0;function zP(e,t){let n={},r={};for(let t of e)Object.assign(n,t.property),Object.assign(r,t.normal);return new RP(n,r,t)}function BP(e){return e.toLowerCase()}var VP=class{constructor(e,t){this.attribute=t,this.property=e}};VP.prototype.attribute=``,VP.prototype.booleanish=!1,VP.prototype.boolean=!1,VP.prototype.commaOrSpaceSeparated=!1,VP.prototype.commaSeparated=!1,VP.prototype.defined=!1,VP.prototype.mustUseProperty=!1,VP.prototype.number=!1,VP.prototype.overloadedBoolean=!1,VP.prototype.property=``,VP.prototype.spaceSeparated=!1,VP.prototype.space=void 0;var HP=s({boolean:()=>WP,booleanish:()=>GP,commaOrSpaceSeparated:()=>YP,commaSeparated:()=>JP,number:()=>J,overloadedBoolean:()=>KP,spaceSeparated:()=>qP}),UP=0,WP=XP(),GP=XP(),KP=XP(),J=XP(),qP=XP(),JP=XP(),YP=XP();function XP(){return 2**++UP}var ZP=Object.keys(HP),QP=class extends VP{constructor(e,t,n,r){let i=-1;if(super(e,t),$P(this,`space`,r),typeof n==`number`)for(;++i<ZP.length;){let e=ZP[i];$P(this,ZP[i],(n&HP[e])===HP[e])}}};QP.prototype.defined=!0;function $P(e,t,n){n&&(e[t]=n)}function eF(e){let t={},n={};for(let[r,i]of Object.entries(e.properties)){let a=new QP(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(a.mustUseProperty=!0),t[r]=a,n[BP(r)]=r,n[BP(a.attribute)]=r}return new RP(t,n,e.space)}var tF=eF({properties:{ariaActiveDescendant:null,ariaAtomic:GP,ariaAutoComplete:null,ariaBusy:GP,ariaChecked:GP,ariaColCount:J,ariaColIndex:J,ariaColSpan:J,ariaControls:qP,ariaCurrent:null,ariaDescribedBy:qP,ariaDetails:null,ariaDisabled:GP,ariaDropEffect:qP,ariaErrorMessage:null,ariaExpanded:GP,ariaFlowTo:qP,ariaGrabbed:GP,ariaHasPopup:null,ariaHidden:GP,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:qP,ariaLevel:J,ariaLive:null,ariaModal:GP,ariaMultiLine:GP,ariaMultiSelectable:GP,ariaOrientation:null,ariaOwns:qP,ariaPlaceholder:null,ariaPosInSet:J,ariaPressed:GP,ariaReadOnly:GP,ariaRelevant:null,ariaRequired:GP,ariaRoleDescription:qP,ariaRowCount:J,ariaRowIndex:J,ariaRowSpan:J,ariaSelected:GP,ariaSetSize:J,ariaSort:null,ariaValueMax:J,ariaValueMin:J,ariaValueNow:J,ariaValueText:null,role:null},transform(e,t){return t===`role`?t:`aria-`+t.slice(4).toLowerCase()}});function nF(e,t){return t in e?e[t]:t}function rF(e,t){return nF(e,t.toLowerCase())}var iF=eF({attributes:{acceptcharset:`accept-charset`,classname:`class`,htmlfor:`for`,httpequiv:`http-equiv`},mustUseProperty:[`checked`,`multiple`,`muted`,`selected`],properties:{abbr:null,accept:JP,acceptCharset:qP,accessKey:qP,action:null,allow:null,allowFullScreen:WP,allowPaymentRequest:WP,allowUserMedia:WP,alpha:WP,alt:null,as:null,async:WP,autoCapitalize:null,autoComplete:qP,autoFocus:WP,autoPlay:WP,blocking:qP,capture:null,charSet:null,checked:WP,cite:null,className:qP,closedBy:null,colorSpace:null,cols:J,colSpan:J,command:null,commandFor:null,content:null,contentEditable:GP,controls:WP,controlsList:qP,coords:J|JP,crossOrigin:null,data:null,dateTime:null,decoding:null,default:WP,defer:WP,dir:null,dirName:null,disabled:WP,download:KP,draggable:GP,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:WP,formTarget:null,headers:qP,height:J,hidden:KP,high:J,href:null,hrefLang:null,htmlFor:qP,httpEquiv:qP,id:null,imageSizes:null,imageSrcSet:null,inert:WP,inputMode:null,integrity:null,is:null,isMap:WP,itemId:null,itemProp:qP,itemRef:qP,itemScope:WP,itemType:qP,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:WP,low:J,manifest:null,max:null,maxLength:J,media:null,method:null,min:null,minLength:J,multiple:WP,muted:WP,name:null,nonce:null,noModule:WP,noValidate:WP,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:WP,optimum:J,pattern:null,ping:qP,placeholder:null,playsInline:WP,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:WP,referrerPolicy:null,rel:qP,required:WP,reversed:WP,rows:J,rowSpan:J,sandbox:qP,scope:null,scoped:WP,seamless:WP,selected:WP,shadowRootClonable:WP,shadowRootCustomElementRegistry:WP,shadowRootDelegatesFocus:WP,shadowRootMode:null,shadowRootSerializable:WP,shape:null,size:J,sizes:null,slot:null,span:J,spellCheck:GP,src:null,srcDoc:null,srcLang:null,srcSet:null,start:J,step:null,style:null,tabIndex:J,target:null,title:null,translate:null,type:null,typeMustMatch:WP,useMap:null,value:GP,width:J,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:qP,axis:null,background:null,bgColor:null,border:J,borderColor:null,bottomMargin:J,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:WP,declare:WP,event:null,face:null,frame:null,frameBorder:null,hSpace:J,leftMargin:J,link:null,longDesc:null,lowSrc:null,marginHeight:J,marginWidth:J,noResize:WP,noHref:WP,noShade:WP,noWrap:WP,object:null,profile:null,prompt:null,rev:null,rightMargin:J,rules:null,scheme:null,scrolling:GP,standby:null,summary:null,text:null,topMargin:J,valueType:null,version:null,vAlign:null,vLink:null,vSpace:J,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:WP,disablePictureInPicture:WP,disableRemotePlayback:WP,exportParts:JP,part:qP,prefix:null,property:null,results:J,security:null,unselectable:null},space:`html`,transform:rF}),aF=eF({attributes:{accentHeight:`accent-height`,alignmentBaseline:`alignment-baseline`,arabicForm:`arabic-form`,baselineShift:`baseline-shift`,capHeight:`cap-height`,className:`class`,clipPath:`clip-path`,clipRule:`clip-rule`,colorInterpolation:`color-interpolation`,colorInterpolationFilters:`color-interpolation-filters`,colorProfile:`color-profile`,colorRendering:`color-rendering`,crossOrigin:`crossorigin`,dataType:`datatype`,dominantBaseline:`dominant-baseline`,enableBackground:`enable-background`,fillOpacity:`fill-opacity`,fillRule:`fill-rule`,floodColor:`flood-color`,floodOpacity:`flood-opacity`,fontFamily:`font-family`,fontSize:`font-size`,fontSizeAdjust:`font-size-adjust`,fontStretch:`font-stretch`,fontStyle:`font-style`,fontVariant:`font-variant`,fontWeight:`font-weight`,glyphName:`glyph-name`,glyphOrientationHorizontal:`glyph-orientation-horizontal`,glyphOrientationVertical:`glyph-orientation-vertical`,hrefLang:`hreflang`,horizAdvX:`horiz-adv-x`,horizOriginX:`horiz-origin-x`,horizOriginY:`horiz-origin-y`,imageRendering:`image-rendering`,letterSpacing:`letter-spacing`,lightingColor:`lighting-color`,markerEnd:`marker-end`,markerMid:`marker-mid`,markerStart:`marker-start`,maskType:`mask-type`,navDown:`nav-down`,navDownLeft:`nav-down-left`,navDownRight:`nav-down-right`,navLeft:`nav-left`,navNext:`nav-next`,navPrev:`nav-prev`,navRight:`nav-right`,navUp:`nav-up`,navUpLeft:`nav-up-left`,navUpRight:`nav-up-right`,onAbort:`onabort`,onActivate:`onactivate`,onAfterPrint:`onafterprint`,onBeforePrint:`onbeforeprint`,onBegin:`onbegin`,onCancel:`oncancel`,onCanPlay:`oncanplay`,onCanPlayThrough:`oncanplaythrough`,onChange:`onchange`,onClick:`onclick`,onClose:`onclose`,onCopy:`oncopy`,onCueChange:`oncuechange`,onCut:`oncut`,onDblClick:`ondblclick`,onDrag:`ondrag`,onDragEnd:`ondragend`,onDragEnter:`ondragenter`,onDragExit:`ondragexit`,onDragLeave:`ondragleave`,onDragOver:`ondragover`,onDragStart:`ondragstart`,onDrop:`ondrop`,onDurationChange:`ondurationchange`,onEmptied:`onemptied`,onEnd:`onend`,onEnded:`onended`,onError:`onerror`,onFocus:`onfocus`,onFocusIn:`onfocusin`,onFocusOut:`onfocusout`,onHashChange:`onhashchange`,onInput:`oninput`,onInvalid:`oninvalid`,onKeyDown:`onkeydown`,onKeyPress:`onkeypress`,onKeyUp:`onkeyup`,onLoad:`onload`,onLoadedData:`onloadeddata`,onLoadedMetadata:`onloadedmetadata`,onLoadStart:`onloadstart`,onMessage:`onmessage`,onMouseDown:`onmousedown`,onMouseEnter:`onmouseenter`,onMouseLeave:`onmouseleave`,onMouseMove:`onmousemove`,onMouseOut:`onmouseout`,onMouseOver:`onmouseover`,onMouseUp:`onmouseup`,onMouseWheel:`onmousewheel`,onOffline:`onoffline`,onOnline:`ononline`,onPageHide:`onpagehide`,onPageShow:`onpageshow`,onPaste:`onpaste`,onPause:`onpause`,onPlay:`onplay`,onPlaying:`onplaying`,onPopState:`onpopstate`,onProgress:`onprogress`,onRateChange:`onratechange`,onRepeat:`onrepeat`,onReset:`onreset`,onResize:`onresize`,onScroll:`onscroll`,onSeeked:`onseeked`,onSeeking:`onseeking`,onSelect:`onselect`,onShow:`onshow`,onStalled:`onstalled`,onStorage:`onstorage`,onSubmit:`onsubmit`,onSuspend:`onsuspend`,onTimeUpdate:`ontimeupdate`,onToggle:`ontoggle`,onUnload:`onunload`,onVolumeChange:`onvolumechange`,onWaiting:`onwaiting`,onZoom:`onzoom`,overlinePosition:`overline-position`,overlineThickness:`overline-thickness`,paintOrder:`paint-order`,panose1:`panose-1`,pointerEvents:`pointer-events`,referrerPolicy:`referrerpolicy`,renderingIntent:`rendering-intent`,shapeRendering:`shape-rendering`,stopColor:`stop-color`,stopOpacity:`stop-opacity`,strikethroughPosition:`strikethrough-position`,strikethroughThickness:`strikethrough-thickness`,strokeDashArray:`stroke-dasharray`,strokeDashOffset:`stroke-dashoffset`,strokeLineCap:`stroke-linecap`,strokeLineJoin:`stroke-linejoin`,strokeMiterLimit:`stroke-miterlimit`,strokeOpacity:`stroke-opacity`,strokeWidth:`stroke-width`,tabIndex:`tabindex`,textAnchor:`text-anchor`,textDecoration:`text-decoration`,textRendering:`text-rendering`,transformOrigin:`transform-origin`,typeOf:`typeof`,underlinePosition:`underline-position`,underlineThickness:`underline-thickness`,unicodeBidi:`unicode-bidi`,unicodeRange:`unicode-range`,unitsPerEm:`units-per-em`,vAlphabetic:`v-alphabetic`,vHanging:`v-hanging`,vIdeographic:`v-ideographic`,vMathematical:`v-mathematical`,vectorEffect:`vector-effect`,vertAdvY:`vert-adv-y`,vertOriginX:`vert-origin-x`,vertOriginY:`vert-origin-y`,wordSpacing:`word-spacing`,writingMode:`writing-mode`,xHeight:`x-height`,playbackOrder:`playbackorder`,timelineBegin:`timelinebegin`},properties:{about:YP,accentHeight:J,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:J,amplitude:J,arabicForm:null,ascent:J,attributeName:null,attributeType:null,azimuth:J,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:J,by:null,calcMode:null,capHeight:J,className:qP,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:J,diffuseConstant:J,direction:null,display:null,dur:null,divisor:J,dominantBaseline:null,download:WP,dx:null,dy:null,edgeMode:null,editable:null,elevation:J,enableBackground:null,end:null,event:null,exponent:J,externalResourcesRequired:null,fill:null,fillOpacity:J,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:JP,g2:JP,glyphName:JP,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:J,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:J,horizOriginX:J,horizOriginY:J,id:null,ideographic:J,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:J,k:J,k1:J,k2:J,k3:J,k4:J,kernelMatrix:YP,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:J,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskType:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:J,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:J,overlineThickness:J,paintOrder:null,panose1:null,path:null,pathLength:J,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:qP,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:J,pointsAtY:J,pointsAtZ:J,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:YP,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:YP,rev:YP,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:YP,requiredFeatures:YP,requiredFonts:YP,requiredFormats:YP,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:J,specularExponent:J,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:J,strikethroughThickness:J,string:null,stroke:null,strokeDashArray:YP,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:J,strokeOpacity:J,strokeWidth:null,style:null,surfaceScale:J,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:YP,tabIndex:J,tableValues:null,target:null,targetX:J,targetY:J,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:YP,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:J,underlineThickness:J,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:J,values:null,vAlphabetic:J,vMathematical:J,vectorEffect:null,vHanging:J,vIdeographic:J,version:null,vertAdvY:J,vertOriginX:J,vertOriginY:J,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:J,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:`svg`,transform:nF}),oF=eF({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:`xlink`,transform(e,t){return`xlink:`+t.slice(5).toLowerCase()}}),sF=eF({attributes:{xmlnsxlink:`xmlns:xlink`},properties:{xmlnsXLink:null,xmlns:null},space:`xmlns`,transform:rF}),cF=eF({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:`xml`,transform(e,t){return`xml:`+t.slice(3).toLowerCase()}}),lF={classId:`classID`,dataType:`datatype`,itemId:`itemID`,strokeDashArray:`strokeDasharray`,strokeDashOffset:`strokeDashoffset`,strokeLineCap:`strokeLinecap`,strokeLineJoin:`strokeLinejoin`,strokeMiterLimit:`strokeMiterlimit`,typeOf:`typeof`,xLinkActuate:`xlinkActuate`,xLinkArcRole:`xlinkArcrole`,xLinkHref:`xlinkHref`,xLinkRole:`xlinkRole`,xLinkShow:`xlinkShow`,xLinkTitle:`xlinkTitle`,xLinkType:`xlinkType`,xmlnsXLink:`xmlnsXlink`},uF=/[A-Z]/g,dF=/-[a-z]/g,fF=/^data[-\w.:]+$/i;function pF(e,t){let n=BP(t),r=t,i=VP;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)===`data`&&fF.test(t)){if(t.charAt(4)===`-`){let e=t.slice(5).replace(dF,hF);r=`data`+e.charAt(0).toUpperCase()+e.slice(1)}else{let e=t.slice(4);if(!dF.test(e)){let n=e.replace(uF,mF);n.charAt(0)!==`-`&&(n=`-`+n),t=`data`+n}}i=QP}return new i(r,t)}function mF(e){return`-`+e.toLowerCase()}function hF(e){return e.charAt(1).toUpperCase()}var gF=zP([tF,iF,oF,sF,cF],`html`),_F=zP([tF,aF,oF,sF,cF],`svg`);function vF(e){return e.join(` `).trim()}var yF=o(((e,t)=>{var n=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,r=/\n/g,i=/^\s*/,a=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,o=/^:\s*/,s=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,l=/^\s+|\s+$/g;function u(e,t){if(typeof e!=`string`)throw TypeError(`First argument must be a string`);if(!e)return[];t||={};var l=1,u=1;function f(e){var t=e.match(r);t&&(l+=t.length);var n=e.lastIndexOf(`
103
- `);u=~n?e.length-n:u+e.length}function p(){var e={line:l,column:u};return function(t){return t.position=new m(e),_(),t}}function m(e){this.start=e,this.end={line:l,column:u},this.source=t.source}m.prototype.content=e;function h(n){var r=Error(t.source+`:`+l+`:`+u+`: `+n);if(r.reason=n,r.filename=t.source,r.line=l,r.column=u,r.source=e,!t.silent)throw r}function g(t){var n=t.exec(e);if(n){var r=n[0];return f(r),e=e.slice(r.length),n}}function _(){g(i)}function v(e){var t;for(e||=[];t=y();)t!==!1&&e.push(t);return e}function y(){var t=p();if(e.charAt(0)==`/`&&e.charAt(1)==`*`){for(var n=2;e.charAt(n)!=``&&(e.charAt(n)!=`*`||e.charAt(n+1)!=`/`);)++n;if(n+=2,e.charAt(n-1)===``)return h(`End of comment missing`);var r=e.slice(2,n-2);return u+=2,f(r),e=e.slice(n),u+=2,t({type:`comment`,comment:r})}}function b(){var e=p(),t=g(a);if(t){if(y(),!g(o))return h(`property missing ':'`);var r=g(s),i=e({type:`declaration`,property:d(t[0].replace(n,``)),value:r?d(r[0].replace(n,``)):``});return g(c),i}}function x(){var e=[];v(e);for(var t;t=b();)t!==!1&&(e.push(t),v(e));return e}return _(),x()}function d(e){return e?e.replace(l,``):``}t.exports=u})),bF=o((e=>{var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,"__esModule",{value:!0}),e.default=r;var n=t(yF());function r(e,t){let r=null;if(!e||typeof e!=`string`)return r;let i=(0,n.default)(e),a=typeof t==`function`;return i.forEach(e=>{if(e.type!==`declaration`)return;let{property:n,value:i}=e;a?t(n,i,e):i&&(r||={},r[n]=i)}),r}})),xF=o((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.camelCase=void 0;var t=/^--[a-zA-Z0-9_-]+$/,n=/-([a-z])/g,r=/^[^-]+$/,i=/^-(webkit|moz|ms|o|khtml)-/,a=/^-(ms)-/,o=function(e){return!e||r.test(e)||t.test(e)},s=function(e,t){return t.toUpperCase()},c=function(e,t){return`${t}-`};e.camelCase=function(e,t){return t===void 0&&(t={}),o(e)?e:(e=e.toLowerCase(),e=t.reactCompat?e.replace(a,c):e.replace(i,c),e.replace(n,s))}})),SF=o(((e,t)=>{var n=(e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(bF()),r=xF();function i(e,t){var i={};return!e||typeof e!=`string`||(0,n.default)(e,function(e,n){e&&n&&(i[(0,r.camelCase)(e,t)]=n)}),i}i.default=i,t.exports=i})),CF=TF(`end`),wF=TF(`start`);function TF(e){return t;function t(t){let n=t&&t.position&&t.position[e]||{};if(typeof n.line==`number`&&n.line>0&&typeof n.column==`number`&&n.column>0)return{line:n.line,column:n.column,offset:typeof n.offset==`number`&&n.offset>-1?n.offset:void 0}}}function EF(e){let t=wF(e),n=CF(e);if(t&&n)return{start:t,end:n}}function DF(e){return!e||typeof e!=`object`?``:`position`in e||`type`in e?kF(e.position):`start`in e||`end`in e?kF(e):`line`in e||`column`in e?OF(e):``}function OF(e){return AF(e&&e.line)+`:`+AF(e&&e.column)}function kF(e){return OF(e&&e.start)+`-`+OF(e&&e.end)}function AF(e){return e&&typeof e==`number`?e:1}var jF=class extends Error{constructor(e,t,n){super(),typeof t==`string`&&(n=t,t=void 0);let r=``,i={},a=!1;if(t&&(i=`line`in t&&`column`in t||`start`in t&&`end`in t?{place:t}:`type`in t?{ancestors:[t],place:t.position}:{...t}),typeof e==`string`?r=e:!i.cause&&e&&(a=!0,r=e.message,i.cause=e),!i.ruleId&&!i.source&&typeof n==`string`){let e=n.indexOf(`:`);e===-1?i.ruleId=n:(i.source=n.slice(0,e),i.ruleId=n.slice(e+1))}if(!i.place&&i.ancestors&&i.ancestors){let e=i.ancestors[i.ancestors.length-1];e&&(i.place=e.position)}let o=i.place&&`start`in i.place?i.place.start:i.place;this.ancestors=i.ancestors||void 0,this.cause=i.cause||void 0,this.column=o?o.column:void 0,this.fatal=void 0,this.file=``,this.message=r,this.line=o?o.line:void 0,this.name=DF(i.place)||`1:1`,this.place=i.place||void 0,this.reason=this.message,this.ruleId=i.ruleId||void 0,this.source=i.source||void 0,this.stack=a&&i.cause&&typeof i.cause.stack==`string`?i.cause.stack:``,this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}};jF.prototype.file=``,jF.prototype.name=``,jF.prototype.reason=``,jF.prototype.message=``,jF.prototype.stack=``,jF.prototype.column=void 0,jF.prototype.line=void 0,jF.prototype.ancestors=void 0,jF.prototype.cause=void 0,jF.prototype.fatal=void 0,jF.prototype.place=void 0,jF.prototype.ruleId=void 0,jF.prototype.source=void 0;var MF=l(SF(),1),NF={}.hasOwnProperty,PF=new Map,FF=/[A-Z]/g,IF=new Set([`table`,`tbody`,`thead`,`tfoot`,`tr`]),LF=new Set([`td`,`th`]),RF=`https://github.com/syntax-tree/hast-util-to-jsx-runtime`;function zF(e,t){if(!t||t.Fragment===void 0)throw TypeError("Expected `Fragment` in options");let n=t.filePath||void 0,r;if(t.development){if(typeof t.jsxDEV!=`function`)throw TypeError("Expected `jsxDEV` in options when `development: true`");r=XF(n,t.jsxDEV)}else{if(typeof t.jsx!=`function`)throw TypeError("Expected `jsx` in production options");if(typeof t.jsxs!=`function`)throw TypeError("Expected `jsxs` in production options");r=YF(n,t.jsx,t.jsxs)}let i={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||`react`,evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space===`svg`?_F:gF,stylePropertyNameCase:t.stylePropertyNameCase||`dom`,tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},a=BF(i,e,void 0);return a&&typeof a!=`string`?a:i.create(e,i.Fragment,{children:a||void 0},void 0)}function BF(e,t,n){if(t.type===`element`)return VF(e,t,n);if(t.type===`mdxFlowExpression`||t.type===`mdxTextExpression`)return HF(e,t);if(t.type===`mdxJsxFlowElement`||t.type===`mdxJsxTextElement`)return WF(e,t,n);if(t.type===`mdxjsEsm`)return UF(e,t);if(t.type===`root`)return GF(e,t,n);if(t.type===`text`)return KF(e,t)}function VF(e,t,n){let r=e.schema,i=r;t.tagName.toLowerCase()===`svg`&&r.space===`html`&&(i=_F,e.schema=i),e.ancestors.push(t);let a=nI(e,t.tagName,!1),o=ZF(e,t),s=$F(e,t);return IF.has(t.tagName)&&(s=s.filter(function(e){return typeof e!=`string`||!IP(e)})),qF(e,o,a,t),JF(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function HF(e,t){if(t.data&&t.data.estree&&e.evaluater){let n=t.data.estree.body[0];return n.type,e.evaluater.evaluateExpression(n.expression)}rI(e,t.position)}function UF(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);rI(e,t.position)}function WF(e,t,n){let r=e.schema,i=r;t.name===`svg`&&r.space===`html`&&(i=_F,e.schema=i),e.ancestors.push(t);let a=t.name===null?e.Fragment:nI(e,t.name,!0),o=QF(e,t),s=$F(e,t);return qF(e,o,a,t),JF(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function GF(e,t,n){let r={};return JF(r,$F(e,t)),e.create(t,e.Fragment,r,n)}function KF(e,t){return t.value}function qF(e,t,n,r){typeof n!=`string`&&n!==e.Fragment&&e.passNode&&(t.node=r)}function JF(e,t){if(t.length>0){let n=t.length>1?t:t[0];n&&(e.children=n)}}function YF(e,t,n){return r;function r(e,r,i,a){let o=Array.isArray(i.children)?n:t;return a?o(r,i,a):o(r,i)}}function XF(e,t){return n;function n(n,r,i,a){let o=Array.isArray(i.children),s=wF(n);return t(r,i,a,o,{columnNumber:s?s.column-1:void 0,fileName:e,lineNumber:s?s.line:void 0},void 0)}}function ZF(e,t){let n={},r,i;for(i in t.properties)if(i!==`children`&&NF.call(t.properties,i)){let a=eI(e,i,t.properties[i]);if(a){let[i,o]=a;e.tableCellAlignToStyle&&i===`align`&&typeof o==`string`&&LF.has(t.tagName)?r=o:n[i]=o}}if(r){let t=n.style||={};t[e.stylePropertyNameCase===`css`?`text-align`:`textAlign`]=r}return n}function QF(e,t){let n={};for(let r of t.attributes)if(r.type===`mdxJsxExpressionAttribute`){if(r.data&&r.data.estree&&e.evaluater){let t=r.data.estree.body[0];t.type;let i=t.expression;i.type;let a=i.properties[0];a.type,Object.assign(n,e.evaluater.evaluateExpression(a.argument))}else rI(e,t.position)}else{let i=r.name,a;if(r.value&&typeof r.value==`object`){if(r.value.data&&r.value.data.estree&&e.evaluater){let t=r.value.data.estree.body[0];t.type,a=e.evaluater.evaluateExpression(t.expression)}else rI(e,t.position)}else a=r.value===null||r.value;n[i]=a}return n}function $F(e,t){let n=[],r=-1,i=e.passKeys?new Map:PF;for(;++r<t.children.length;){let a=t.children[r],o;if(e.passKeys){let e=a.type===`element`?a.tagName:a.type===`mdxJsxFlowElement`||a.type===`mdxJsxTextElement`?a.name:void 0;if(e){let t=i.get(e)||0;o=e+`-`+t,i.set(e,t+1)}}let s=BF(e,a,o);s!==void 0&&n.push(s)}return n}function eI(e,t,n){let r=pF(e.schema,t);if(!(n==null||typeof n==`number`&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?AP(n):vF(n)),r.property===`style`){let t=typeof n==`object`?n:tI(e,String(n));return e.stylePropertyNameCase===`css`&&(t=iI(t)),[`style`,t]}return[e.elementAttributeNameCase===`react`&&r.space?lF[r.property]||r.property:r.attribute,n]}}function tI(e,t){try{return(0,MF.default)(t,{reactCompat:!0})}catch(t){if(e.ignoreInvalidStyle)return{};let n=t,r=new jF("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:n,ruleId:`style`,source:`hast-util-to-jsx-runtime`});throw r.file=e.filePath||void 0,r.url=RF+`#cannot-parse-style-attribute`,r}}function nI(e,t,n){let r;if(!n)r={type:`Literal`,value:t};else if(t.includes(`.`)){let e=t.split(`.`),n=-1,i;for(;++n<e.length;){let t=PP(e[n])?{type:`Identifier`,name:e[n]}:{type:`Literal`,value:e[n]};i=i?{type:`MemberExpression`,object:i,property:t,computed:!!(n&&t.type===`Literal`),optional:!1}:t}r=i}else r=PP(t)&&!/^[a-z]/.test(t)?{type:`Identifier`,name:t}:{type:`Literal`,value:t};if(r.type===`Literal`){let t=r.value;return NF.call(e.components,t)?e.components[t]:t}if(e.evaluater)return e.evaluater.evaluateExpression(r);rI(e)}function rI(e,t){let n=new jF("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:`mdx-estree`,source:`hast-util-to-jsx-runtime`});throw n.file=e.filePath||void 0,n.url=RF+`#cannot-handle-mdx-estrees-without-createevaluater`,n}function iI(e){let t={},n;for(n in e)NF.call(e,n)&&(t[aI(n)]=e[n]);return t}function aI(e){let t=e.replace(FF,oI);return t.slice(0,3)===`ms-`&&(t=`-`+t),t}function oI(e){return`-`+e.toLowerCase()}var sI={action:[`form`],cite:[`blockquote`,`del`,`ins`,`q`],data:[`object`],formAction:[`button`,`input`],href:[`a`,`area`,`base`,`link`],icon:[`menuitem`],itemId:null,manifest:[`html`],ping:[`a`,`area`],poster:[`video`],src:[`audio`,`embed`,`iframe`,`img`,`input`,`script`,`source`,`track`,`video`]},cI={};function lI(e,t){let n=t||cI;return uI(e,typeof n.includeImageAlt!=`boolean`||n.includeImageAlt,typeof n.includeHtml!=`boolean`||n.includeHtml)}function uI(e,t,n){if(fI(e)){if(`value`in e)return e.type===`html`&&!n?``:e.value;if(t&&`alt`in e&&e.alt)return e.alt;if(`children`in e)return dI(e.children,t,n)}return Array.isArray(e)?dI(e,t,n):``}function dI(e,t,n){let r=[],i=-1;for(;++i<e.length;)r[i]=uI(e[i],t,n);return r.join(``)}function fI(e){return!!(e&&typeof e==`object`)}var pI=document.createElement(`i`);function mI(e){let t=`&`+e+`;`;pI.innerHTML=t;let n=pI.textContent;return n.charCodeAt(n.length-1)===59&&e!==`semi`?!1:n!==t&&n}function hI(e,t,n,r){let i=e.length,a=0,o;if(t=t<0?-t>i?0:i+t:t>i?i:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);a<r.length;)o=r.slice(a,a+1e4),o.unshift(t,0),e.splice(...o),a+=1e4,t+=1e4}function gI(e,t){return e.length>0?(hI(e,e.length,0,t),e):t}var _I={}.hasOwnProperty;function vI(e){let t={},n=-1;for(;++n<e.length;)yI(t,e[n]);return t}function yI(e,t){let n;for(n in t){let r=(_I.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n],a;if(i)for(a in i){_I.call(r,a)||(r[a]=[]);let e=i[a];bI(r[a],Array.isArray(e)?e:e?[e]:[])}}}function bI(e,t){let n=-1,r=[];for(;++n<t.length;)(t[n].add===`after`?e:r).push(t[n]);hI(e,0,0,r)}function xI(e,t){let n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)==65535||(n&65535)==65534||n>1114111?`�`:String.fromCodePoint(n)}function SI(e){return e.replace(/[\t\n\r ]+/g,` `).replace(/^ | $/g,``).toLowerCase().toUpperCase()}var CI=FI(/[A-Za-z]/),wI=FI(/[\dA-Za-z]/),TI=FI(/[#-'*+\--9=?A-Z^-~]/);function EI(e){return e!==null&&(e<32||e===127)}var DI=FI(/\d/),OI=FI(/[\dA-Fa-f]/),kI=FI(/[!-/:-@[-`{-~]/);function AI(e){return e!==null&&e<-2}function jI(e){return e!==null&&(e<0||e===32)}function MI(e){return e===-2||e===-1||e===32}var NI=FI(/\p{P}|\p{S}/u),PI=FI(/\s/);function FI(e){return t;function t(t){return t!==null&&t>-1&&e.test(String.fromCharCode(t))}}function II(e){let t=[],n=-1,r=0,i=0;for(;++n<e.length;){let a=e.charCodeAt(n),o=``;if(a===37&&wI(e.charCodeAt(n+1))&&wI(e.charCodeAt(n+2)))i=2;else if(a<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(a))||(o=String.fromCharCode(a));else if(a>55295&&a<57344){let t=e.charCodeAt(n+1);a<56320&&t>56319&&t<57344?(o=String.fromCharCode(a,t),i=1):o=`�`}else o=String.fromCharCode(a);o&&=(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+i+1,``),i&&=(n+=i,0)}return t.join(``)+e.slice(r)}function LI(e,t,n,r){let i=r?r-1:1/0,a=0;return o;function o(r){return MI(r)?(e.enter(n),s(r)):t(r)}function s(r){return MI(r)&&a++<i?(e.consume(r),s):(e.exit(n),t(r))}}var RI={tokenize:zI};function zI(e){let t=e.attempt(this.parser.constructs.contentInitial,r,i),n;return t;function r(n){if(n===null){e.consume(n);return}return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),LI(e,t,`linePrefix`)}function i(t){return e.enter(`paragraph`),a(t)}function a(t){let r=e.enter(`chunkText`,{contentType:`text`,previous:n});return n&&(n.next=r),n=r,o(t)}function o(t){if(t===null){e.exit(`chunkText`),e.exit(`paragraph`),e.consume(t);return}return AI(t)?(e.consume(t),e.exit(`chunkText`),a):(e.consume(t),o)}}var BI={tokenize:HI},VI={tokenize:UI};function HI(e){let t=this,n=[],r=0,i,a,o;return s;function s(i){if(r<n.length){let a=n[r];return t.containerState=a[1],e.attempt(a[0].continuation,c,l)(i)}return l(i)}function c(e){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&v();let n=t.events.length,a=n,o;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){o=t.events[a][1].end;break}_(r);let s=n;for(;s<t.events.length;)t.events[s][1].end={...o},s++;return hI(t.events,a+1,0,t.events.slice(n)),t.events.length=s,l(e)}return s(e)}function l(a){if(r===n.length){if(!i)return f(a);if(i.currentConstruct&&i.currentConstruct.concrete)return m(a);t.interrupt=!(!i.currentConstruct||i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(VI,u,d)(a)}function u(e){return i&&v(),_(r),f(e)}function d(e){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,m(e)}function f(n){return t.containerState={},e.attempt(VI,p,m)(n)}function p(e){return r++,n.push([t.currentConstruct,t.containerState]),f(e)}function m(n){if(n===null){i&&v(),_(0),e.consume(n);return}return i||=t.parser.flow(t.now()),e.enter(`chunkFlow`,{_tokenizer:i,contentType:`flow`,previous:a}),h(n)}function h(n){if(n===null){g(e.exit(`chunkFlow`),!0),_(0),e.consume(n);return}return AI(n)?(e.consume(n),g(e.exit(`chunkFlow`)),r=0,t.interrupt=void 0,s):(e.consume(n),h)}function g(e,n){let s=t.sliceStream(e);if(n&&s.push(null),e.previous=a,a&&(a.next=e),a=e,i.defineSkip(e.start),i.write(s),t.parser.lazy[e.start.line]){let e=i.events.length;for(;e--;)if(i.events[e][1].start.offset<o&&(!i.events[e][1].end||i.events[e][1].end.offset>o))return;let n=t.events.length,a=n,s,c;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){if(s){c=t.events[a][1].end;break}s=!0}for(_(r),e=n;e<t.events.length;)t.events[e][1].end={...c},e++;hI(t.events,a+1,0,t.events.slice(n)),t.events.length=e}}function _(r){let i=n.length;for(;i-->r;){let r=n[i];t.containerState=r[1],r[0].exit.call(t,e)}n.length=r}function v(){i.write([null]),a=void 0,i=void 0,t.containerState._closeFlow=void 0}}function UI(e,t,n){return LI(e,e.attempt(this.parser.constructs.document,t,n),`linePrefix`,this.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)}function WI(e){if(e===null||jI(e)||PI(e))return 1;if(NI(e))return 2}function GI(e,t,n){let r=[],i=-1;for(;++i<e.length;){let a=e[i].resolveAll;a&&!r.includes(a)&&(t=a(t,n),r.push(a))}return t}var KI={name:`attention`,resolveAll:qI,tokenize:JI};function qI(e,t){let n=-1,r,i,a,o,s,c,l,u;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`attentionSequence`&&e[n][1]._close){for(r=n;r--;)if(e[r][0]===`exit`&&e[r][1].type===`attentionSequence`&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;c=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;let d={...e[r][1].end},f={...e[n][1].start};YI(d,-c),YI(f,c),o={type:c>1?`strongSequence`:`emphasisSequence`,start:d,end:{...e[r][1].end}},s={type:c>1?`strongSequence`:`emphasisSequence`,start:{...e[n][1].start},end:f},a={type:c>1?`strongText`:`emphasisText`,start:{...e[r][1].end},end:{...e[n][1].start}},i={type:c>1?`strong`:`emphasis`,start:{...o.start},end:{...s.end}},e[r][1].end={...o.start},e[n][1].start={...s.end},l=[],e[r][1].end.offset-e[r][1].start.offset&&(l=gI(l,[[`enter`,e[r][1],t],[`exit`,e[r][1],t]])),l=gI(l,[[`enter`,i,t],[`enter`,o,t],[`exit`,o,t],[`enter`,a,t]]),l=gI(l,GI(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),l=gI(l,[[`exit`,a,t],[`enter`,s,t],[`exit`,s,t],[`exit`,i,t]]),e[n][1].end.offset-e[n][1].start.offset?(u=2,l=gI(l,[[`enter`,e[n][1],t],[`exit`,e[n][1],t]])):u=0,hI(e,r-1,n-r+3,l),n=r+l.length-u-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`attentionSequence`&&(e[n][1].type=`data`);return e}function JI(e,t){let n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=WI(r),a;return o;function o(t){return a=t,e.enter(`attentionSequence`),s(t)}function s(o){if(o===a)return e.consume(o),s;let c=e.exit(`attentionSequence`),l=WI(o),u=!l||l===2&&i||n.includes(o),d=!i||i===2&&l||n.includes(r);return c._open=!!(a===42?u:u&&(i||!d)),c._close=!!(a===42?d:d&&(l||!u)),t(o)}}function YI(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}var XI={name:`autolink`,tokenize:ZI};function ZI(e,t,n){let r=0;return i;function i(t){return e.enter(`autolink`),e.enter(`autolinkMarker`),e.consume(t),e.exit(`autolinkMarker`),e.enter(`autolinkProtocol`),a}function a(t){return CI(t)?(e.consume(t),o):t===64?n(t):l(t)}function o(e){return e===43||e===45||e===46||wI(e)?(r=1,s(e)):l(e)}function s(t){return t===58?(e.consume(t),r=0,c):(t===43||t===45||t===46||wI(t))&&r++<32?(e.consume(t),s):(r=0,l(t))}function c(r){return r===62?(e.exit(`autolinkProtocol`),e.enter(`autolinkMarker`),e.consume(r),e.exit(`autolinkMarker`),e.exit(`autolink`),t):r===null||r===32||r===60||EI(r)?n(r):(e.consume(r),c)}function l(t){return t===64?(e.consume(t),u):TI(t)?(e.consume(t),l):n(t)}function u(e){return wI(e)?d(e):n(e)}function d(n){return n===46?(e.consume(n),r=0,u):n===62?(e.exit(`autolinkProtocol`).type=`autolinkEmail`,e.enter(`autolinkMarker`),e.consume(n),e.exit(`autolinkMarker`),e.exit(`autolink`),t):f(n)}function f(t){if((t===45||wI(t))&&r++<63){let n=t===45?f:d;return e.consume(t),n}return n(t)}}var QI={partial:!0,tokenize:$I};function $I(e,t,n){return r;function r(t){return MI(t)?LI(e,i,`linePrefix`)(t):i(t)}function i(e){return e===null||AI(e)?t(e):n(e)}}var eL={continuation:{tokenize:nL},exit:rL,name:`blockQuote`,tokenize:tL};function tL(e,t,n){let r=this;return i;function i(t){if(t===62){let n=r.containerState;return n.open||=(e.enter(`blockQuote`,{_container:!0}),!0),e.enter(`blockQuotePrefix`),e.enter(`blockQuoteMarker`),e.consume(t),e.exit(`blockQuoteMarker`),a}return n(t)}function a(n){return MI(n)?(e.enter(`blockQuotePrefixWhitespace`),e.consume(n),e.exit(`blockQuotePrefixWhitespace`),e.exit(`blockQuotePrefix`),t):(e.exit(`blockQuotePrefix`),t(n))}}function nL(e,t,n){let r=this;return i;function i(t){return MI(t)?LI(e,a,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):a(t)}function a(r){return e.attempt(eL,t,n)(r)}}function rL(e){e.exit(`blockQuote`)}var iL={name:`characterEscape`,tokenize:aL};function aL(e,t,n){return r;function r(t){return e.enter(`characterEscape`),e.enter(`escapeMarker`),e.consume(t),e.exit(`escapeMarker`),i}function i(r){return kI(r)?(e.enter(`characterEscapeValue`),e.consume(r),e.exit(`characterEscapeValue`),e.exit(`characterEscape`),t):n(r)}}var oL={name:`characterReference`,tokenize:sL};function sL(e,t,n){let r=this,i=0,a,o;return s;function s(t){return e.enter(`characterReference`),e.enter(`characterReferenceMarker`),e.consume(t),e.exit(`characterReferenceMarker`),c}function c(t){return t===35?(e.enter(`characterReferenceMarkerNumeric`),e.consume(t),e.exit(`characterReferenceMarkerNumeric`),l):(e.enter(`characterReferenceValue`),a=31,o=wI,u(t))}function l(t){return t===88||t===120?(e.enter(`characterReferenceMarkerHexadecimal`),e.consume(t),e.exit(`characterReferenceMarkerHexadecimal`),e.enter(`characterReferenceValue`),a=6,o=OI,u):(e.enter(`characterReferenceValue`),a=7,o=DI,u(t))}function u(s){if(s===59&&i){let i=e.exit(`characterReferenceValue`);return o===wI&&!mI(r.sliceSerialize(i))?n(s):(e.enter(`characterReferenceMarker`),e.consume(s),e.exit(`characterReferenceMarker`),e.exit(`characterReference`),t)}return o(s)&&i++<a?(e.consume(s),u):n(s)}}var cL={partial:!0,tokenize:dL},lL={concrete:!0,name:`codeFenced`,tokenize:uL};function uL(e,t,n){let r=this,i={partial:!0,tokenize:x},a=0,o=0,s;return c;function c(e){return l(e)}function l(t){let n=r.events[r.events.length-1];return a=n&&n[1].type===`linePrefix`?n[2].sliceSerialize(n[1],!0).length:0,s=t,e.enter(`codeFenced`),e.enter(`codeFencedFence`),e.enter(`codeFencedFenceSequence`),u(t)}function u(t){return t===s?(o++,e.consume(t),u):o<3?n(t):(e.exit(`codeFencedFenceSequence`),MI(t)?LI(e,d,`whitespace`)(t):d(t))}function d(n){return n===null||AI(n)?(e.exit(`codeFencedFence`),r.interrupt?t(n):e.check(cL,h,b)(n)):(e.enter(`codeFencedFenceInfo`),e.enter(`chunkString`,{contentType:`string`}),f(n))}function f(t){return t===null||AI(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),d(t)):MI(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),LI(e,p,`whitespace`)(t)):t===96&&t===s?n(t):(e.consume(t),f)}function p(t){return t===null||AI(t)?d(t):(e.enter(`codeFencedFenceMeta`),e.enter(`chunkString`,{contentType:`string`}),m(t))}function m(t){return t===null||AI(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceMeta`),d(t)):t===96&&t===s?n(t):(e.consume(t),m)}function h(t){return e.attempt(i,b,g)(t)}function g(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),_}function _(t){return a>0&&MI(t)?LI(e,v,`linePrefix`,a+1)(t):v(t)}function v(t){return t===null||AI(t)?e.check(cL,h,b)(t):(e.enter(`codeFlowValue`),y(t))}function y(t){return t===null||AI(t)?(e.exit(`codeFlowValue`),v(t)):(e.consume(t),y)}function b(n){return e.exit(`codeFenced`),t(n)}function x(e,t,n){let i=0;return a;function a(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c}function c(t){return e.enter(`codeFencedFence`),MI(t)?LI(e,l,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):l(t)}function l(t){return t===s?(e.enter(`codeFencedFenceSequence`),u(t)):n(t)}function u(t){return t===s?(i++,e.consume(t),u):i>=o?(e.exit(`codeFencedFenceSequence`),MI(t)?LI(e,d,`whitespace`)(t):d(t)):n(t)}function d(r){return r===null||AI(r)?(e.exit(`codeFencedFence`),t(r)):n(r)}}}function dL(e,t,n){let r=this;return i;function i(t){return t===null?n(t):(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}var fL={name:`codeIndented`,tokenize:mL},pL={partial:!0,tokenize:hL};function mL(e,t,n){let r=this;return i;function i(t){return e.enter(`codeIndented`),LI(e,a,`linePrefix`,5)(t)}function a(e){let t=r.events[r.events.length-1];return t&&t[1].type===`linePrefix`&&t[2].sliceSerialize(t[1],!0).length>=4?o(e):n(e)}function o(t){return t===null?c(t):AI(t)?e.attempt(pL,o,c)(t):(e.enter(`codeFlowValue`),s(t))}function s(t){return t===null||AI(t)?(e.exit(`codeFlowValue`),o(t)):(e.consume(t),s)}function c(n){return e.exit(`codeIndented`),t(n)}}function hL(e,t,n){let r=this;return i;function i(t){return r.parser.lazy[r.now().line]?n(t):AI(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),i):LI(e,a,`linePrefix`,5)(t)}function a(e){let a=r.events[r.events.length-1];return a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(e):AI(e)?i(e):n(e)}}var gL={name:`codeText`,previous:vL,resolve:_L,tokenize:yL};function _L(e){let t=e.length-4,n=3,r,i;if((e[n][1].type===`lineEnding`||e[n][1].type===`space`)&&(e[t][1].type===`lineEnding`||e[t][1].type===`space`)){for(r=n;++r<t;)if(e[r][1].type===`codeTextData`){e[n][1].type=`codeTextPadding`,e[t][1].type=`codeTextPadding`,n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!==`lineEnding`&&(i=r):(r===t||e[r][1].type===`lineEnding`)&&(e[i][1].type=`codeTextData`,r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function vL(e){return e!==96||this.events[this.events.length-1][1].type===`characterEscape`}function yL(e,t,n){let r=0,i,a;return o;function o(t){return e.enter(`codeText`),e.enter(`codeTextSequence`),s(t)}function s(t){return t===96?(e.consume(t),r++,s):(e.exit(`codeTextSequence`),c(t))}function c(t){return t===null?n(t):t===32?(e.enter(`space`),e.consume(t),e.exit(`space`),c):t===96?(a=e.enter(`codeTextSequence`),i=0,u(t)):AI(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c):(e.enter(`codeTextData`),l(t))}function l(t){return t===null||t===32||t===96||AI(t)?(e.exit(`codeTextData`),c(t)):(e.consume(t),l)}function u(n){return n===96?(e.consume(n),i++,u):i===r?(e.exit(`codeTextSequence`),e.exit(`codeText`),t(n)):(a.type=`codeTextData`,l(n))}}var bL=class{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,t){let n=t??1/0;return n<this.left.length?this.left.slice(e,n):e>this.left.length?this.right.slice(this.right.length-n+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-n+this.left.length).reverse())}splice(e,t,n){let r=t||0;this.setCursor(Math.trunc(e));let i=this.right.splice(this.right.length-r,1/0);return n&&xL(this.left,n),i.reverse()}pop(){return this.setCursor(1/0),this.left.pop()}push(e){this.setCursor(1/0),this.left.push(e)}pushMany(e){this.setCursor(1/0),xL(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),xL(this.right,e.reverse())}setCursor(e){if(!(e===this.left.length||e>this.left.length&&this.right.length===0||e<0&&this.left.length===0)){if(e<this.left.length){let t=this.left.splice(e,1/0);xL(this.right,t.reverse())}else{let t=this.right.splice(this.left.length+this.right.length-e,1/0);xL(this.left,t.reverse())}}}};function xL(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function SL(e){let t={},n=-1,r,i,a,o,s,c,l,u=new bL(e);for(;++n<u.length;){for(;n in t;)n=t[n];if(r=u.get(n),n&&r[1].type===`chunkFlow`&&u.get(n-1)[1].type===`listItemPrefix`&&(c=r[1]._tokenizer.events,a=0,a<c.length&&c[a][1].type===`lineEndingBlank`&&(a+=2),a<c.length&&c[a][1].type===`content`))for(;++a<c.length&&c[a][1].type!==`content`;)c[a][1].type===`chunkText`&&(c[a][1]._isInFirstContentOfListItem=!0,a++);if(r[0]===`enter`)r[1].contentType&&(Object.assign(t,CL(u,n)),n=t[n],l=!0);else if(r[1]._container){for(a=n,i=void 0;a--;)if(o=u.get(a),o[1].type===`lineEnding`||o[1].type===`lineEndingBlank`)o[0]===`enter`&&(i&&(u.get(i)[1].type=`lineEndingBlank`),o[1].type=`lineEnding`,i=a);else if(o[1].type!==`linePrefix`&&o[1].type!==`listItemIndent`)break;i&&(r[1].end={...u.get(i)[1].start},s=u.slice(i,n),s.unshift(r),u.splice(i,n-i+1,s))}}return hI(e,0,1/0,u.slice(0)),!l}function CL(e,t){let n=e.get(t)[1],r=e.get(t)[2],i=t-1,a=[],o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));let s=o.events,c=[],l={},u,d,f=-1,p=n,m=0,h=0,g=[h];for(;p;){for(;e.get(++i)[1]!==p;);a.push(i),p._tokenizer||(u=r.sliceStream(p),p.next||u.push(null),d&&o.defineSkip(p.start),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(u),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),d=p,p=p.next}for(p=n;++f<s.length;)s[f][0]===`exit`&&s[f-1][0]===`enter`&&s[f][1].type===s[f-1][1].type&&s[f][1].start.line!==s[f][1].end.line&&(h=f+1,g.push(h),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(o.events=[],p?(p._tokenizer=void 0,p.previous=void 0):g.pop(),f=g.length;f--;){let t=s.slice(g[f],g[f+1]),n=a.pop();c.push([n,n+t.length-1]),e.splice(n,2,t)}for(c.reverse(),f=-1;++f<c.length;)l[m+c[f][0]]=m+c[f][1],m+=c[f][1]-c[f][0]-1;return l}var wL={resolve:EL,tokenize:DL},TL={partial:!0,tokenize:OL};function EL(e){return SL(e),e}function DL(e,t){let n;return r;function r(t){return e.enter(`content`),n=e.enter(`chunkContent`,{contentType:`content`}),i(t)}function i(t){return t===null?a(t):AI(t)?e.check(TL,o,a)(t):(e.consume(t),i)}function a(n){return e.exit(`chunkContent`),e.exit(`content`),t(n)}function o(t){return e.consume(t),e.exit(`chunkContent`),n.next=e.enter(`chunkContent`,{contentType:`content`,previous:n}),n=n.next,i}}function OL(e,t,n){let r=this;return i;function i(t){return e.exit(`chunkContent`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),LI(e,a,`linePrefix`)}function a(i){if(i===null||AI(i))return n(i);let a=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes(`codeIndented`)&&a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(i):e.interrupt(r.parser.constructs.flow,n,t)(i)}}function kL(e,t,n,r,i,a,o,s,c){let l=c||1/0,u=0;return d;function d(t){return t===60?(e.enter(r),e.enter(i),e.enter(a),e.consume(t),e.exit(a),f):t===null||t===32||t===41||EI(t)?n(t):(e.enter(r),e.enter(o),e.enter(s),e.enter(`chunkString`,{contentType:`string`}),h(t))}function f(n){return n===62?(e.enter(a),e.consume(n),e.exit(a),e.exit(i),e.exit(r),t):(e.enter(s),e.enter(`chunkString`,{contentType:`string`}),p(n))}function p(t){return t===62?(e.exit(`chunkString`),e.exit(s),f(t)):t===null||t===60||AI(t)?n(t):(e.consume(t),t===92?m:p)}function m(t){return t===60||t===62||t===92?(e.consume(t),p):p(t)}function h(i){return!u&&(i===null||i===41||jI(i))?(e.exit(`chunkString`),e.exit(s),e.exit(o),e.exit(r),t(i)):u<l&&i===40?(e.consume(i),u++,h):i===41?(e.consume(i),u--,h):i===null||i===32||i===40||EI(i)?n(i):(e.consume(i),i===92?g:h)}function g(t){return t===40||t===41||t===92?(e.consume(t),h):h(t)}}function AL(e,t,n,r,i,a){let o=this,s=0,c;return l;function l(t){return e.enter(r),e.enter(i),e.consume(t),e.exit(i),e.enter(a),u}function u(l){return s>999||l===null||l===91||l===93&&!c||l===94&&!s&&`_hiddenFootnoteSupport`in o.parser.constructs?n(l):l===93?(e.exit(a),e.enter(i),e.consume(l),e.exit(i),e.exit(r),t):AI(l)?(e.enter(`lineEnding`),e.consume(l),e.exit(`lineEnding`),u):(e.enter(`chunkString`,{contentType:`string`}),d(l))}function d(t){return t===null||t===91||t===93||AI(t)||s++>999?(e.exit(`chunkString`),u(t)):(e.consume(t),c||=!MI(t),t===92?f:d)}function f(t){return t===91||t===92||t===93?(e.consume(t),s++,d):d(t)}}function jL(e,t,n,r,i,a){let o;return s;function s(t){return t===34||t===39||t===40?(e.enter(r),e.enter(i),e.consume(t),e.exit(i),o=t===40?41:t,c):n(t)}function c(n){return n===o?(e.enter(i),e.consume(n),e.exit(i),e.exit(r),t):(e.enter(a),l(n))}function l(t){return t===o?(e.exit(a),c(o)):t===null?n(t):AI(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),LI(e,l,`linePrefix`)):(e.enter(`chunkString`,{contentType:`string`}),u(t))}function u(t){return t===o||t===null||AI(t)?(e.exit(`chunkString`),l(t)):(e.consume(t),t===92?d:u)}function d(t){return t===o||t===92?(e.consume(t),u):u(t)}}function ML(e,t){let n;return r;function r(i){return AI(i)?(e.enter(`lineEnding`),e.consume(i),e.exit(`lineEnding`),n=!0,r):MI(i)?LI(e,r,n?`linePrefix`:`lineSuffix`)(i):t(i)}}var NL={name:`definition`,tokenize:FL},PL={partial:!0,tokenize:IL};function FL(e,t,n){let r=this,i;return a;function a(t){return e.enter(`definition`),o(t)}function o(t){return AL.call(r,e,s,n,`definitionLabel`,`definitionLabelMarker`,`definitionLabelString`)(t)}function s(t){return i=SI(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),c):n(t)}function c(t){return jI(t)?ML(e,l)(t):l(t)}function l(t){return kL(e,u,n,`definitionDestination`,`definitionDestinationLiteral`,`definitionDestinationLiteralMarker`,`definitionDestinationRaw`,`definitionDestinationString`)(t)}function u(t){return e.attempt(PL,d,d)(t)}function d(t){return MI(t)?LI(e,f,`whitespace`)(t):f(t)}function f(a){return a===null||AI(a)?(e.exit(`definition`),r.parser.defined.push(i),t(a)):n(a)}}function IL(e,t,n){return r;function r(t){return jI(t)?ML(e,i)(t):n(t)}function i(t){return jL(e,a,n,`definitionTitle`,`definitionTitleMarker`,`definitionTitleString`)(t)}function a(t){return MI(t)?LI(e,o,`whitespace`)(t):o(t)}function o(e){return e===null||AI(e)?t(e):n(e)}}var LL={name:`hardBreakEscape`,tokenize:RL};function RL(e,t,n){return r;function r(t){return e.enter(`hardBreakEscape`),e.consume(t),i}function i(r){return AI(r)?(e.exit(`hardBreakEscape`),t(r)):n(r)}}var zL={name:`headingAtx`,resolve:BL,tokenize:VL};function BL(e,t){let n=e.length-2,r=3,i,a;return e[r][1].type===`whitespace`&&(r+=2),n-2>r&&e[n][1].type===`whitespace`&&(n-=2),e[n][1].type===`atxHeadingSequence`&&(r===n-1||n-4>r&&e[n-2][1].type===`whitespace`)&&(n-=r+1===n?2:4),n>r&&(i={type:`atxHeadingText`,start:e[r][1].start,end:e[n][1].end},a={type:`chunkText`,start:e[r][1].start,end:e[n][1].end,contentType:`text`},hI(e,r,n-r+1,[[`enter`,i,t],[`enter`,a,t],[`exit`,a,t],[`exit`,i,t]])),e}function VL(e,t,n){let r=0;return i;function i(t){return e.enter(`atxHeading`),a(t)}function a(t){return e.enter(`atxHeadingSequence`),o(t)}function o(t){return t===35&&r++<6?(e.consume(t),o):t===null||jI(t)?(e.exit(`atxHeadingSequence`),s(t)):n(t)}function s(n){return n===35?(e.enter(`atxHeadingSequence`),c(n)):n===null||AI(n)?(e.exit(`atxHeading`),t(n)):MI(n)?LI(e,s,`whitespace`)(n):(e.enter(`atxHeadingText`),l(n))}function c(t){return t===35?(e.consume(t),c):(e.exit(`atxHeadingSequence`),s(t))}function l(t){return t===null||t===35||jI(t)?(e.exit(`atxHeadingText`),s(t)):(e.consume(t),l)}}var HL=`address.article.aside.base.basefont.blockquote.body.caption.center.col.colgroup.dd.details.dialog.dir.div.dl.dt.fieldset.figcaption.figure.footer.form.frame.frameset.h1.h2.h3.h4.h5.h6.head.header.hr.html.iframe.legend.li.link.main.menu.menuitem.nav.noframes.ol.optgroup.option.p.param.search.section.summary.table.tbody.td.tfoot.th.thead.title.tr.track.ul`.split(`.`),UL=[`pre`,`script`,`style`,`textarea`],WL={concrete:!0,name:`htmlFlow`,resolveTo:qL,tokenize:JL},GL={partial:!0,tokenize:XL},KL={partial:!0,tokenize:YL};function qL(e){let t=e.length;for(;t--&&(e[t][0]!==`enter`||e[t][1].type!==`htmlFlow`););return t>1&&e[t-2][1].type===`linePrefix`&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function JL(e,t,n){let r=this,i,a,o,s,c;return l;function l(e){return u(e)}function u(t){return e.enter(`htmlFlow`),e.enter(`htmlFlowData`),e.consume(t),d}function d(s){return s===33?(e.consume(s),f):s===47?(e.consume(s),a=!0,h):s===63?(e.consume(s),i=3,r.interrupt?t:F):CI(s)?(e.consume(s),o=String.fromCharCode(s),g):n(s)}function f(a){return a===45?(e.consume(a),i=2,p):a===91?(e.consume(a),i=5,s=0,m):CI(a)?(e.consume(a),i=4,r.interrupt?t:F):n(a)}function p(i){return i===45?(e.consume(i),r.interrupt?t:F):n(i)}function m(i){return i===`CDATA[`.charCodeAt(s++)?(e.consume(i),s===6?r.interrupt?t:O:m):n(i)}function h(t){return CI(t)?(e.consume(t),o=String.fromCharCode(t),g):n(t)}function g(s){if(s===null||s===47||s===62||jI(s)){let c=s===47,l=o.toLowerCase();return!c&&!a&&UL.includes(l)?(i=1,r.interrupt?t(s):O(s)):HL.includes(o.toLowerCase())?(i=6,c?(e.consume(s),_):r.interrupt?t(s):O(s)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(s):a?v(s):y(s))}return s===45||wI(s)?(e.consume(s),o+=String.fromCharCode(s),g):n(s)}function _(i){return i===62?(e.consume(i),r.interrupt?t:O):n(i)}function v(t){return MI(t)?(e.consume(t),v):E(t)}function y(t){return t===47?(e.consume(t),E):t===58||t===95||CI(t)?(e.consume(t),b):MI(t)?(e.consume(t),y):E(t)}function b(t){return t===45||t===46||t===58||t===95||wI(t)?(e.consume(t),b):x(t)}function x(t){return t===61?(e.consume(t),S):MI(t)?(e.consume(t),x):y(t)}function S(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),c=t,C):MI(t)?(e.consume(t),S):w(t)}function C(t){return t===c?(e.consume(t),c=null,T):t===null||AI(t)?n(t):(e.consume(t),C)}function w(t){return t===null||t===34||t===39||t===47||t===60||t===61||t===62||t===96||jI(t)?x(t):(e.consume(t),w)}function T(e){return e===47||e===62||MI(e)?y(e):n(e)}function E(t){return t===62?(e.consume(t),D):n(t)}function D(t){return t===null||AI(t)?O(t):MI(t)?(e.consume(t),D):n(t)}function O(t){return t===45&&i===2?(e.consume(t),j):t===60&&i===1?(e.consume(t),M):t===62&&i===4?(e.consume(t),te):t===63&&i===3?(e.consume(t),F):t===93&&i===5?(e.consume(t),P):AI(t)&&(i===6||i===7)?(e.exit(`htmlFlowData`),e.check(GL,ne,ee)(t)):t===null||AI(t)?(e.exit(`htmlFlowData`),ee(t)):(e.consume(t),O)}function ee(t){return e.check(KL,k,ne)(t)}function k(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),A}function A(t){return t===null||AI(t)?ee(t):(e.enter(`htmlFlowData`),O(t))}function j(t){return t===45?(e.consume(t),F):O(t)}function M(t){return t===47?(e.consume(t),o=``,N):O(t)}function N(t){if(t===62){let n=o.toLowerCase();return UL.includes(n)?(e.consume(t),te):O(t)}return CI(t)&&o.length<8?(e.consume(t),o+=String.fromCharCode(t),N):O(t)}function P(t){return t===93?(e.consume(t),F):O(t)}function F(t){return t===62?(e.consume(t),te):t===45&&i===2?(e.consume(t),F):O(t)}function te(t){return t===null||AI(t)?(e.exit(`htmlFlowData`),ne(t)):(e.consume(t),te)}function ne(n){return e.exit(`htmlFlow`),t(n)}}function YL(e,t,n){let r=this;return i;function i(t){return AI(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a):n(t)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}function XL(e,t,n){return r;function r(r){return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),e.attempt(QI,t,n)}}var ZL={name:`htmlText`,tokenize:QL};function QL(e,t,n){let r=this,i,a,o;return s;function s(t){return e.enter(`htmlText`),e.enter(`htmlTextData`),e.consume(t),c}function c(t){return t===33?(e.consume(t),l):t===47?(e.consume(t),x):t===63?(e.consume(t),y):CI(t)?(e.consume(t),w):n(t)}function l(t){return t===45?(e.consume(t),u):t===91?(e.consume(t),a=0,m):CI(t)?(e.consume(t),v):n(t)}function u(t){return t===45?(e.consume(t),p):n(t)}function d(t){return t===null?n(t):t===45?(e.consume(t),f):AI(t)?(o=d,M(t)):(e.consume(t),d)}function f(t){return t===45?(e.consume(t),p):d(t)}function p(e){return e===62?j(e):e===45?f(e):d(e)}function m(t){return t===`CDATA[`.charCodeAt(a++)?(e.consume(t),a===6?h:m):n(t)}function h(t){return t===null?n(t):t===93?(e.consume(t),g):AI(t)?(o=h,M(t)):(e.consume(t),h)}function g(t){return t===93?(e.consume(t),_):h(t)}function _(t){return t===62?j(t):t===93?(e.consume(t),_):h(t)}function v(t){return t===null||t===62?j(t):AI(t)?(o=v,M(t)):(e.consume(t),v)}function y(t){return t===null?n(t):t===63?(e.consume(t),b):AI(t)?(o=y,M(t)):(e.consume(t),y)}function b(e){return e===62?j(e):y(e)}function x(t){return CI(t)?(e.consume(t),S):n(t)}function S(t){return t===45||wI(t)?(e.consume(t),S):C(t)}function C(t){return AI(t)?(o=C,M(t)):MI(t)?(e.consume(t),C):j(t)}function w(t){return t===45||wI(t)?(e.consume(t),w):t===47||t===62||jI(t)?T(t):n(t)}function T(t){return t===47?(e.consume(t),j):t===58||t===95||CI(t)?(e.consume(t),E):AI(t)?(o=T,M(t)):MI(t)?(e.consume(t),T):j(t)}function E(t){return t===45||t===46||t===58||t===95||wI(t)?(e.consume(t),E):D(t)}function D(t){return t===61?(e.consume(t),O):AI(t)?(o=D,M(t)):MI(t)?(e.consume(t),D):T(t)}function O(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),i=t,ee):AI(t)?(o=O,M(t)):MI(t)?(e.consume(t),O):(e.consume(t),k)}function ee(t){return t===i?(e.consume(t),i=void 0,A):t===null?n(t):AI(t)?(o=ee,M(t)):(e.consume(t),ee)}function k(t){return t===null||t===34||t===39||t===60||t===61||t===96?n(t):t===47||t===62||jI(t)?T(t):(e.consume(t),k)}function A(e){return e===47||e===62||jI(e)?T(e):n(e)}function j(r){return r===62?(e.consume(r),e.exit(`htmlTextData`),e.exit(`htmlText`),t):n(r)}function M(t){return e.exit(`htmlTextData`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),N}function N(t){return MI(t)?LI(e,P,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):P(t)}function P(t){return e.enter(`htmlTextData`),o(t)}}var $L={name:`labelEnd`,resolveAll:rR,resolveTo:iR,tokenize:aR},eR={tokenize:oR},tR={tokenize:sR},nR={tokenize:cR};function rR(e){let t=-1,n=[];for(;++t<e.length;){let r=e[t][1];if(n.push(e[t]),r.type===`labelImage`||r.type===`labelLink`||r.type===`labelEnd`){let e=r.type===`labelImage`?4:2;r.type=`data`,t+=e}}return e.length!==n.length&&hI(e,0,e.length,n),e}function iR(e,t){let n=e.length,r=0,i,a,o,s;for(;n--;)if(i=e[n][1],a){if(i.type===`link`||i.type===`labelLink`&&i._inactive)break;e[n][0]===`enter`&&i.type===`labelLink`&&(i._inactive=!0)}else if(o){if(e[n][0]===`enter`&&(i.type===`labelImage`||i.type===`labelLink`)&&!i._balanced&&(a=n,i.type!==`labelLink`)){r=2;break}}else i.type===`labelEnd`&&(o=n);let c={type:e[a][1].type===`labelLink`?`link`:`image`,start:{...e[a][1].start},end:{...e[e.length-1][1].end}},l={type:`label`,start:{...e[a][1].start},end:{...e[o][1].end}},u={type:`labelText`,start:{...e[a+r+2][1].end},end:{...e[o-2][1].start}};return s=[[`enter`,c,t],[`enter`,l,t]],s=gI(s,e.slice(a+1,a+r+3)),s=gI(s,[[`enter`,u,t]]),s=gI(s,GI(t.parser.constructs.insideSpan.null,e.slice(a+r+4,o-3),t)),s=gI(s,[[`exit`,u,t],e[o-2],e[o-1],[`exit`,l,t]]),s=gI(s,e.slice(o+1)),s=gI(s,[[`exit`,c,t]]),hI(e,a,e.length,s),e}function aR(e,t,n){let r=this,i=r.events.length,a,o;for(;i--;)if((r.events[i][1].type===`labelImage`||r.events[i][1].type===`labelLink`)&&!r.events[i][1]._balanced){a=r.events[i][1];break}return s;function s(t){return a?a._inactive?d(t):(o=r.parser.defined.includes(SI(r.sliceSerialize({start:a.end,end:r.now()}))),e.enter(`labelEnd`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelEnd`),c):n(t)}function c(t){return t===40?e.attempt(eR,u,o?u:d)(t):t===91?e.attempt(tR,u,o?l:d)(t):o?u(t):d(t)}function l(t){return e.attempt(nR,u,d)(t)}function u(e){return t(e)}function d(e){return a._balanced=!0,n(e)}}function oR(e,t,n){return r;function r(t){return e.enter(`resource`),e.enter(`resourceMarker`),e.consume(t),e.exit(`resourceMarker`),i}function i(t){return jI(t)?ML(e,a)(t):a(t)}function a(t){return t===41?u(t):kL(e,o,s,`resourceDestination`,`resourceDestinationLiteral`,`resourceDestinationLiteralMarker`,`resourceDestinationRaw`,`resourceDestinationString`,32)(t)}function o(t){return jI(t)?ML(e,c)(t):u(t)}function s(e){return n(e)}function c(t){return t===34||t===39||t===40?jL(e,l,n,`resourceTitle`,`resourceTitleMarker`,`resourceTitleString`)(t):u(t)}function l(t){return jI(t)?ML(e,u)(t):u(t)}function u(r){return r===41?(e.enter(`resourceMarker`),e.consume(r),e.exit(`resourceMarker`),e.exit(`resource`),t):n(r)}}function sR(e,t,n){let r=this;return i;function i(t){return AL.call(r,e,a,o,`reference`,`referenceMarker`,`referenceString`)(t)}function a(e){return r.parser.defined.includes(SI(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function o(e){return n(e)}}function cR(e,t,n){return r;function r(t){return e.enter(`reference`),e.enter(`referenceMarker`),e.consume(t),e.exit(`referenceMarker`),i}function i(r){return r===93?(e.enter(`referenceMarker`),e.consume(r),e.exit(`referenceMarker`),e.exit(`reference`),t):n(r)}}var lR={name:`labelStartImage`,resolveAll:$L.resolveAll,tokenize:uR};function uR(e,t,n){let r=this;return i;function i(t){return e.enter(`labelImage`),e.enter(`labelImageMarker`),e.consume(t),e.exit(`labelImageMarker`),a}function a(t){return t===91?(e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelImage`),o):n(t)}function o(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):t(e)}}var dR={name:`labelStartLink`,resolveAll:$L.resolveAll,tokenize:fR};function fR(e,t,n){let r=this;return i;function i(t){return e.enter(`labelLink`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelLink`),a}function a(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):t(e)}}var pR={name:`lineEnding`,tokenize:mR};function mR(e,t){return n;function n(n){return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),LI(e,t,`linePrefix`)}}var hR={name:`thematicBreak`,tokenize:gR};function gR(e,t,n){let r=0,i;return a;function a(t){return e.enter(`thematicBreak`),o(t)}function o(e){return i=e,s(e)}function s(a){return a===i?(e.enter(`thematicBreakSequence`),c(a)):r>=3&&(a===null||AI(a))?(e.exit(`thematicBreak`),t(a)):n(a)}function c(t){return t===i?(e.consume(t),r++,c):(e.exit(`thematicBreakSequence`),MI(t)?LI(e,s,`whitespace`)(t):s(t))}}var _R={continuation:{tokenize:xR},exit:CR,name:`list`,tokenize:bR},vR={partial:!0,tokenize:wR},yR={partial:!0,tokenize:SR};function bR(e,t,n){let r=this,i=r.events[r.events.length-1],a=i&&i[1].type===`linePrefix`?i[2].sliceSerialize(i[1],!0).length:0,o=0;return s;function s(t){let i=r.containerState.type||(t===42||t===43||t===45?`listUnordered`:`listOrdered`);if(i===`listUnordered`?!r.containerState.marker||t===r.containerState.marker:DI(t)){if(r.containerState.type||(r.containerState.type=i,e.enter(i,{_container:!0})),i===`listUnordered`)return e.enter(`listItemPrefix`),t===42||t===45?e.check(hR,n,l)(t):l(t);if(!r.interrupt||t===49)return e.enter(`listItemPrefix`),e.enter(`listItemValue`),c(t)}return n(t)}function c(t){return DI(t)&&++o<10?(e.consume(t),c):(!r.interrupt||o<2)&&(r.containerState.marker?t===r.containerState.marker:t===41||t===46)?(e.exit(`listItemValue`),l(t)):n(t)}function l(t){return e.enter(`listItemMarker`),e.consume(t),e.exit(`listItemMarker`),r.containerState.marker=r.containerState.marker||t,e.check(QI,r.interrupt?n:u,e.attempt(vR,f,d))}function u(e){return r.containerState.initialBlankLine=!0,a++,f(e)}function d(t){return MI(t)?(e.enter(`listItemPrefixWhitespace`),e.consume(t),e.exit(`listItemPrefixWhitespace`),f):n(t)}function f(n){return r.containerState.size=a+r.sliceSerialize(e.exit(`listItemPrefix`),!0).length,t(n)}}function xR(e,t,n){let r=this;return r.containerState._closeFlow=void 0,e.check(QI,i,a);function i(n){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,LI(e,t,`listItemIndent`,r.containerState.size+1)(n)}function a(n){return r.containerState.furtherBlankLines||!MI(n)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(n)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(yR,t,o)(n))}function o(i){return r.containerState._closeFlow=!0,r.interrupt=void 0,LI(e,e.attempt(_R,t,n),`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(i)}}function SR(e,t,n){let r=this;return LI(e,i,`listItemIndent`,r.containerState.size+1);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`listItemIndent`&&i[2].sliceSerialize(i[1],!0).length===r.containerState.size?t(e):n(e)}}function CR(e){e.exit(this.containerState.type)}function wR(e,t,n){let r=this;return LI(e,i,`listItemPrefixWhitespace`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:5);function i(e){let i=r.events[r.events.length-1];return!MI(e)&&i&&i[1].type===`listItemPrefixWhitespace`?t(e):n(e)}}var TR={name:`setextUnderline`,resolveTo:ER,tokenize:DR};function ER(e,t){let n=e.length,r,i,a;for(;n--;)if(e[n][0]===`enter`){if(e[n][1].type===`content`){r=n;break}e[n][1].type===`paragraph`&&(i=n)}else e[n][1].type===`content`&&e.splice(n,1),!a&&e[n][1].type===`definition`&&(a=n);let o={type:`setextHeading`,start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type=`setextHeadingText`,a?(e.splice(i,0,[`enter`,o,t]),e.splice(a+1,0,[`exit`,e[r][1],t]),e[r][1].end={...e[a][1].end}):e[r][1]=o,e.push([`exit`,o,t]),e}function DR(e,t,n){let r=this,i;return a;function a(t){let a=r.events.length,s;for(;a--;)if(r.events[a][1].type!==`lineEnding`&&r.events[a][1].type!==`linePrefix`&&r.events[a][1].type!==`content`){s=r.events[a][1].type===`paragraph`;break}return!r.parser.lazy[r.now().line]&&(r.interrupt||s)?(e.enter(`setextHeadingLine`),i=t,o(t)):n(t)}function o(t){return e.enter(`setextHeadingLineSequence`),s(t)}function s(t){return t===i?(e.consume(t),s):(e.exit(`setextHeadingLineSequence`),MI(t)?LI(e,c,`lineSuffix`)(t):c(t))}function c(r){return r===null||AI(r)?(e.exit(`setextHeadingLine`),t(r)):n(r)}}var OR={tokenize:kR};function kR(e){let t=this,n=e.attempt(QI,r,e.attempt(this.parser.constructs.flowInitial,i,LI(e,e.attempt(this.parser.constructs.flow,i,e.attempt(wL,i)),`linePrefix`)));return n;function r(r){if(r===null){e.consume(r);return}return e.enter(`lineEndingBlank`),e.consume(r),e.exit(`lineEndingBlank`),t.currentConstruct=void 0,n}function i(r){if(r===null){e.consume(r);return}return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),t.currentConstruct=void 0,n}}var AR={resolveAll:PR()},jR=NR(`string`),MR=NR(`text`);function NR(e){return{resolveAll:PR(e===`text`?FR:void 0),tokenize:t};function t(t){let n=this,r=this.parser.constructs[e],i=t.attempt(r,a,o);return a;function a(e){return c(e)?i(e):o(e)}function o(e){if(e===null){t.consume(e);return}return t.enter(`data`),t.consume(e),s}function s(e){return c(e)?(t.exit(`data`),i(e)):(t.consume(e),s)}function c(e){if(e===null)return!0;let t=r[e],i=-1;if(t)for(;++i<t.length;){let e=t[i];if(!e.previous||e.previous.call(n,n.previous))return!0}return!1}}}function PR(e){return t;function t(t,n){let r=-1,i;for(;++r<=t.length;)i===void 0?t[r]&&t[r][1].type===`data`&&(i=r,r++):(!t[r]||t[r][1].type!==`data`)&&(r!==i+2&&(t[i][1].end=t[r-1][1].end,t.splice(i+2,r-i-2),r=i+2),i=void 0);return e?e(t,n):t}}function FR(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type===`lineEnding`)&&e[n-1][1].type===`data`){let r=e[n-1][1],i=t.sliceStream(r),a=i.length,o=-1,s=0,c;for(;a--;){let e=i[a];if(typeof e==`string`){for(o=e.length;e.charCodeAt(o-1)===32;)s++,o--;if(o)break;o=-1}else if(e===-2)c=!0,s++;else if(e!==-1){a++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(s=0),s){let i={type:n===e.length||c||s<2?`lineSuffix`:`hardBreakTrailing`,start:{_bufferIndex:a?o:r.start._bufferIndex+o,_index:r.start._index+a,line:r.end.line,column:r.end.column-s,offset:r.end.offset-s},end:{...r.end}};r.end={...i.start},r.start.offset===r.end.offset?Object.assign(r,i):(e.splice(n,0,[`enter`,i,t],[`exit`,i,t]),n+=2)}n++}return e}var IR=s({attentionMarkers:()=>WR,contentInitial:()=>RR,disable:()=>GR,document:()=>LR,flow:()=>BR,flowInitial:()=>zR,insideSpan:()=>UR,string:()=>VR,text:()=>HR}),LR={42:_R,43:_R,45:_R,48:_R,49:_R,50:_R,51:_R,52:_R,53:_R,54:_R,55:_R,56:_R,57:_R,62:eL},RR={91:NL},zR={[-2]:fL,[-1]:fL,32:fL},BR={35:zL,42:hR,45:[TR,hR],60:WL,61:TR,95:hR,96:lL,126:lL},VR={38:oL,92:iL},HR={[-5]:pR,[-4]:pR,[-3]:pR,33:lR,38:oL,42:KI,60:[XI,ZL],91:dR,92:[LL,iL],93:$L,95:KI,96:gL},UR={null:[KI,AR]},WR={null:[42,95]},GR={null:[]};function KR(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0},i={},a=[],o=[],s=[],c={attempt:C(x),check:C(S),consume:v,enter:y,exit:b,interrupt:C(S,{interrupt:!0})},l={code:null,containerState:{},defineSkip:h,events:[],now:m,parser:e,previous:null,sliceSerialize:f,sliceStream:p,write:d},u=t.tokenize.call(l,c);return t.resolveAll&&a.push(t),l;function d(e){return o=gI(o,e),g(),o[o.length-1]===null?(w(t,0),l.events=GI(a,l.events,l),l.events):[]}function f(e,t){return JR(p(e),t)}function p(e){return qR(o,e)}function m(){let{_bufferIndex:e,_index:t,line:n,column:i,offset:a}=r;return{_bufferIndex:e,_index:t,line:n,column:i,offset:a}}function h(e){i[e.line]=e.column,E()}function g(){let e;for(;r._index<o.length;){let t=o[r._index];if(typeof t==`string`)for(e=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===e&&r._bufferIndex<t.length;)_(t.charCodeAt(r._bufferIndex));else _(t)}}function _(e){u=u(e)}function v(e){AI(e)?(r.line++,r.column=1,r.offset+=e===-3?2:1,E()):e!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),l.previous=e}function y(e,t){let n=t||{};return n.type=e,n.start=m(),l.events.push([`enter`,n,l]),s.push(n),n}function b(e){let t=s.pop();return t.end=m(),l.events.push([`exit`,t,l]),t}function x(e,t){w(e,t.from)}function S(e,t){t.restore()}function C(e,t){return n;function n(n,r,i){let a,o,s,u;return Array.isArray(n)?f(n):`tokenize`in n?f([n]):d(n);function d(e){return t;function t(t){let n=t!==null&&e[t],r=t!==null&&e.null;return f([...Array.isArray(n)?n:n?[n]:[],...Array.isArray(r)?r:r?[r]:[]])(t)}}function f(e){return a=e,o=0,e.length===0?i:p(e[o])}function p(e){return n;function n(n){return u=T(),s=e,e.partial||(l.currentConstruct=e),e.name&&l.parser.constructs.disable.null.includes(e.name)?h(n):e.tokenize.call(t?Object.assign(Object.create(l),t):l,c,m,h)(n)}}function m(t){return e(s,u),r}function h(e){return u.restore(),++o<a.length?p(a[o]):i}}}function w(e,t){e.resolveAll&&!a.includes(e)&&a.push(e),e.resolve&&hI(l.events,t,l.events.length-t,e.resolve(l.events.slice(t),l)),e.resolveTo&&(l.events=e.resolveTo(l.events,l))}function T(){let e=m(),t=l.previous,n=l.currentConstruct,i=l.events.length,a=Array.from(s);return{from:i,restore:o};function o(){r=e,l.previous=t,l.currentConstruct=n,l.events.length=i,s=a,E()}}function E(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function qR(e,t){let n=t.start._index,r=t.start._bufferIndex,i=t.end._index,a=t.end._bufferIndex,o;if(n===i)o=[e[n].slice(r,a)];else{if(o=e.slice(n,i),r>-1){let e=o[0];typeof e==`string`?o[0]=e.slice(r):o.shift()}a>0&&o.push(e[i].slice(0,a))}return o}function JR(e,t){let n=-1,r=[],i;for(;++n<e.length;){let a=e[n],o;if(typeof a==`string`)o=a;else switch(a){case-5:o=`\r`;break;case-4:o=`
102
+ `]}),(0,h.jsx)(lM,{id:e,rows:24,value:t,spellCheck:!1,"aria-invalid":n,"aria-describedby":r,className:z(OM,`relative block min-h-[520px] resize-y overflow-auto bg-transparent text-transparent caret-ink`),onChange:e=>{i(e.target.value)},onScroll:e=>{let t=a.current;t!==null&&(t.scrollTop=e.currentTarget.scrollTop,t.scrollLeft=e.currentTarget.scrollLeft)}})]})}function AM({entryId:e,category:t,from:n,onLeave:r}){let{api:i}=I(),a=_(),o=nt(xy(i)),s=(0,m.useId)(),c=(0,m.useId)(),l=(0,m.useId)(),u=(0,m.useId)(),d=(0,m.useId)(),f=(0,m.useId)(),[p,g]=(0,m.useState)(void 0),[v,y]=(0,m.useState)([]),[b,x]=(0,m.useState)(!1),[S,C]=(0,m.useState)(!1),w=o.data?.entries,T=e??n,E=T===void 0?void 0:w?.find(e=>e.id===T),D=E===void 0?{category:t,mode:`text`,name:``,body:``}:{category:E.category,mode:E.mode,name:e===void 0?`${E.name} copy`:E.name,body:E.body},O=p??D,ee=it({mutationFn:t=>Po(i,t,e),onSuccess:async e=>{if(!e.ok){y(e.fields);return}x(!0),await a.invalidateQueries({queryKey:xy(i).queryKey})}}),k=it({mutationFn:e=>Fo(i,e),onSuccess:async()=>{C(!1),await a.invalidateQueries({queryKey:xy(i).queryKey}),r(O.category)}});$j(b,()=>{r(O.category)});let A=(e,t)=>{g(e),y(e=>e.filter(e=>e.field!==t))},j=SM(O,v),M=CM(j),N=EM(O.body),P=O.body.trim()===``?[]:wM(j),F=O.name.trim()===``?[]:TM(j);return o.error===null?T!==void 0&&w===void 0?(0,h.jsx)(rM,{}):T!==void 0&&E===void 0?(0,h.jsx)(jM,{category:t,children:`That entry is gone. It may have been deleted in another tab.`}):(0,h.jsxs)(`div`,{className:`mx-auto max-w-[1440px]`,children:[(0,h.jsxs)(sa,{to:`/entries`,search:{category:O.category},className:`mb-[10px] inline-flex items-center gap-1 text-small text-ink2 hover:text-ink`,children:[(0,h.jsx)(YA,{"aria-hidden":`true`,className:`size-[14px]`}),`Intros & Outros`]}),(0,h.jsx)(`h1`,{className:`mb-4 text-title font-bold tracking-[-0.01em]`,children:e===void 0?`New entry`:`Edit entry`}),(0,h.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)] items-start gap-6 lg:grid-cols-[minmax(0,1fr)_360px]`,children:[(0,h.jsxs)(`div`,{className:`${nM} flex min-w-0 flex-col gap-[14px]`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-end gap-[14px]`,children:[(0,h.jsxs)(`div`,{className:`min-w-[200px] flex-1`,children:[(0,h.jsx)(oM,{htmlFor:s,className:`mb-[5px]`,children:`Name`}),(0,h.jsx)(cM,{id:s,value:O.name,"aria-invalid":F.length>0,"aria-describedby":F.length===0?void 0:c,onChange:e=>{A({...O,name:e.target.value},`name`)}}),F.length===0?null:(0,h.jsx)(`p`,{id:c,className:`mt-1 text-label text-red`,children:F.map(e=>e.message).join(` `)})]}),(0,h.jsx)(sM,{label:`Category`,value:O.category,options:Cj,onPick:e=>{A({...O,category:e},`name`)}}),(0,h.jsx)(sM,{label:`Mode`,value:O.mode,options:wj,describedBy:l,onPick:e=>{A({...O,mode:e},`mode`)}})]}),(0,h.jsx)(`p`,{id:l,className:`-mt-[6px] text-right text-small text-ink2`,children:Dj(O.mode)}),(0,h.jsxs)(`div`,{children:[(0,h.jsx)(oM,{htmlFor:u,className:`mb-[5px]`,children:`Body`}),(0,h.jsx)(kM,{id:u,value:O.body,invalid:P.length>0,describedBy:P.length===0?void 0:d,onChange:e=>{A({...O,body:e},`body`)}})]}),(0,h.jsx)(tM,{onDelete:e===void 0?void 0:()=>{C(!0)},blocked:M,blockedId:f,pending:ee.isPending,saved:b,cancel:(0,h.jsx)(B,{asChild:!0,children:(0,h.jsx)(sa,{to:`/entries`,search:{category:O.category},children:`Cancel`})}),errors:[ee.error,k.error].flatMap(e=>e===null?[]:[e.message]),onSave:()=>{ee.mutate(O)}})]}),(0,h.jsx)(`div`,{className:`${nM} flex flex-col gap-3 lg:sticky lg:top-6`,children:(0,h.jsx)(Zj,{slots:N,body:O.body,lint:P,lintId:d,noSlots:Oj(O.mode)})})]}),(0,h.jsx)(Nj,{open:S,title:`Delete "${O.name}"?`,consequence:`Projects that used it keep their text.`,verb:`Delete`,pending:k.isPending,onConfirm:()=>{e!==void 0&&k.mutate(e)},onCancel:()=>{C(!1)}})]}):(0,h.jsx)(jM,{category:O.category,children:o.error.message})}function jM({category:e,children:t}){return(0,h.jsx)(iM,{back:(0,h.jsx)(sa,{to:`/entries`,search:{category:e},className:aM,children:`Back to Intros & Outros`}),children:t})}function MM(e,t){let n={...eO,...e},r=t.audio===`off`?`off`:(t.video===`off`||t.images===`off`)&&n.mode===`burn-in`?`files`:n.mode;if(r!==`off`)return{...n,mode:r};let i=$D.shape.fontId.safeParse(n.fontId),a=$D.shape.fontSize.safeParse(n.fontSize);return{...n,mode:r,fontId:i.success?i.data:eO.fontId,fontSize:a.success?a.data:eO.fontSize}}function NM(e){return e.mode===`off`||e.fontId!==``&&Number.isInteger(e.fontSize)&&e.fontSize>=16&&e.fontSize<=120}({...ck.form});var PM={off:`Off`,generate:`Generate`,provide:`Provide`,from_prompt:`From prompt`,prompt_by_llm:`Prompt by LLM`};function FM(e){return ZO[e].map(e=>({value:e,label:PM[e]}))}function IM(e,t){return ak(e)||e.sources.article===`generate`||e.sources.thumbnail===`prompt_by_llm`||e.sources.audio===`generate`&&(LM(t,`intro`,e.intro)===`llm`||LM(t,`outro`,e.outro)===`llm`)}function LM(e,t,n){if(n!==``)return e.find(e=>e.category===t&&e.name===n)?.mode}function RM(e){return[e.audio,e.thumbnail,...e.images].flatMap(e=>e?.file===void 0?[]:[e.file])}function zM(e){let{form:t}=e;return{...t.checkpoints===void 0?{}:{checkpoints:t.checkpoints},title:t.title,format:t.format,sources:{...t.sources,...t.sources.article===`provide`?{research:`off`}:{},...t.sources.images===`off`?{video:`off`}:{}},llm:t.llm,audio:t.audio,images:t.images,articlePrompt:t.articlePrompt,...t.narrationPrompt===void 0?{}:{narrationPrompt:t.narrationPrompt},imagePrompts:t.imagePrompts,thumbnailPrompt:t.thumbnailPrompt,...BM(VM(e,`intro`),e=>({intro:e})),...BM(VM(e,`outro`),e=>({outro:e})),values:HM(t.values,e.slots),provided:{research:t.provided.research,article:t.provided.article,...BM(t.provided.audio?.file,e=>({audio:e.id})),...BM(t.provided.thumbnail?.file,e=>({thumbnail:e.id})),images:t.provided.images.flatMap(e=>e.file===void 0?[]:[e.file.id])},chunking:t.chunking,subtitles:MM(t.subtitles,t.sources),silenceGapSeconds:e.silenceGapSeconds}}function BM(e,t){return e===void 0?{}:t(e)}function VM(e,t){if(e.form.sources.audio!==`generate`)return;let n=t===`intro`?e.form.intro:e.form.outro,r=LM(e.entries,t,n);return n===``||r===void 0?void 0:{name:n,mode:r}}function HM(e,t){let n=Object.create(null);for(let r of t)n[r]=Object.hasOwn(e,r)?e[r]??``:``;return n}function UM(e){let{form:t}=e,n=[],r=[];if(ak(t)&&QM(n,XM(e.prompts,`narration`,t.narrationPrompt??``)),t.sources.article===`generate`&&QM(n,XM(e.prompts,`article`,t.articlePrompt)),t.sources.audio===`generate`&&(QM(n,ZM(e.entries,`intro`,t.intro)),QM(n,ZM(e.entries,`outro`,t.outro))),t.sources.images===`generate`)for(let n of t.imagePrompts)QM(r,XM(e.prompts,`image`,n.name));return(t.sources.thumbnail===`from_prompt`||t.sources.thumbnail===`prompt_by_llm`)&&QM(r,XM(e.prompts,`thumbnail`,t.thumbnailPrompt)),mM(n,r)}function WM(e){let t=UM(e),n={form:e.form,entries:e.entries,slots:t.map(e=>e.name),silenceGapSeconds:e.silenceGapSeconds},r=zM(n),i=QO({draft:r,staged:RM(e.form.provided),requiredSlots:n.slots}),a=NM(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:KM(e.form,a)}}var GM=[`sources`,`provided.research`,`articlePrompt`,`provided.article`,`audio`,`provided.audio`,`narrationPrompt`,`imagePrompts`,`images`,`provided.images`,`thumbnailPrompt`,`provided.thumbnail`,`subtitles`,`title`,`intro`,`outro`,`llm`,`values`,`silenceGapSeconds`];function KM(e,t){let n=qM(e);if(n!==void 0)return n;if(t.ok)return;let r=[...t.fields].sort((e,t)=>JM(e.field)-JM(t.field))[0];return r===void 0?void 0:{field:r.field,hint:YM(e,r)}}function qM(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),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 JM(e){let t=GM.length;for(let[n,r]of GM.entries())(e===r||e.startsWith(`${r}.`))&&n<t&&(t=n);return t}function YM(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`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`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`;default:return t.message}}function XM(e,t,n){if(n!==``)return e.find(e=>e.kind===t&&e.name===n)?.body}function ZM(e,t,n){if(n!==``)return e.find(e=>e.category===t&&e.name===n)?.body}function QM(e,t){t!==void 0&&e.push(t)}function $M(e){let t=new Map,n=(e,n)=>{if(e)for(let r of pM(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(ak(r)&&n(XM(i,`narration`,r.narrationPrompt??``),`Narration Preparation`),r.sources.article===`generate`&&n(XM(i,`article`,r.articlePrompt),`Article`),r.sources.images===`generate`)for(let e of r.imagePrompts)n(XM(i,`image`,e.name),`Image: ${e.name}`);if((r.sources.thumbnail===`from_prompt`||r.sources.thumbnail===`prompt_by_llm`)&&n(XM(i,`thumbnail`,r.thumbnailPrompt),`Thumbnail`),r.sources.audio===`generate`)for(let e of[`intro`,`outro`])n(ZM(a,e,r[e]),e===`intro`?`Intro`:`Outro`);return t}var eN=[{stage:`audio`,label:`Audio`},{stage:`images`,label:`Images`},{stage:`video`,label:`Video / export`}];function tN(e,t){if(e!==`checkpoints`&&!e.startsWith(`checkpoints.`))return;let n=e.slice(12),r=/^\d+$/.test(n)?t.checkpoints?.[Number(n)]:n;return{section:`outputs`,field:eN.some(e=>e.stage===r)?`checkpoints.${r}`:`checkpoints`}}function nN({problem:e}){let t=Ek(),{document:n,review:r}=t,{form:i}=n,a=(0,m.useId)(),o=i.checkpoints??[];return(0,h.jsxs)(`fieldset`,{"data-play-field":`checkpoints`,tabIndex:-1,"aria-invalid":e(`checkpoints`)!==void 0,disabled:r.starting||r.uncertain,className:`min-w-0 border-b border-line py-6`,children:[(0,h.jsx)(`legend`,{className:`text-lg font-semibold`,children:`Review checkpoints`}),(0,h.jsx)(`p`,{className:`mb-3 text-small text-ink2`,children:`Hold a step so you can review and edit before it runs. Independent steps continue. Approve each checkpoint on the project page when you are ready.`}),eN.map(({stage:r,label:s})=>{let c=o.includes(r),l=r===`video`?i.sources.video!==`off`&&i.sources.images!==`off`||i.sources.audio!==`off`:i.sources[r]===`generate`,u=e(`checkpoints.${r}`),d=`${a}-${r}`;return(0,h.jsxs)(`div`,{children:[(0,h.jsxs)(`label`,{htmlFor:d,className:`flex min-h-10 items-center gap-3 max-[1099px]:min-h-11`,children:[(0,h.jsx)(`input`,{id:d,type:`checkbox`,"data-play-field":`checkpoints.${r}`,"aria-invalid":u!==void 0,"aria-describedby":`${d}-detail`,checked:c,disabled:!l&&!c,className:`size-4 accent-accent`,onChange:e=>{let a=e.target.checked?[...o,r]:o.filter(e=>e!==r);t.edit({...n,form:{...i,checkpoints:a}}),t.invalidateReview(!0)}}),`Before `,s]}),(0,h.jsx)(`p`,{id:`${d}-detail`,className:`pb-2 pl-7 text-small ${u?`text-red`:`text-ink3`}`,children:u??(l?`Approval required before this step and its dependents run.`:c?`This step is unavailable. Remove its checkpoint or enable the step.`:r===`video`?`Enable Video or Audio to review before export.`:`Choose Generate for ${s} to add this checkpoint.`)})]},r)}),e(`checkpoints`)?(0,h.jsx)(`p`,{className:`text-small text-red`,children:e(`checkpoints`)}):null]})}function rN({fields:e,values:t,origins:n,problem:r,onChange:i}){return e.length?(0,h.jsxs)(`section`,{"data-tour":`play-keywords`,className:`min-w-0 py-6`,children:[(0,h.jsx)(`h3`,{className:`mb-2 text-lg font-semibold`,children:`Keywords`}),(0,h.jsxs)(`p`,{className:`mb-5 text-small text-ink3`,children:[`Each keyword is entered once. For example, `,`{{topic}}`,` becomes the topic you enter below.`]}),(0,h.jsx)(`div`,{className:`flex flex-col gap-4`,children:e.map(e=>(0,h.jsx)(iN,{name:e.name,value:Object.hasOwn(t,e.name)?t[e.name]??``:``,origins:n?.get(e.name),problem:r(`values.${e.name}`),onChange:i},e.name))})]}):null}function iN({name:e,origins:t,value:n,problem:r,onChange:i}){let a=(0,m.useId)(),o=(0,m.useId)();return(0,h.jsxs)(`div`,{className:`min-w-0`,children:[(0,h.jsx)(oM,{htmlFor:a,className:`mb-[5px]`,children:e}),(0,h.jsx)(cM,{id:a,"data-play-field":`values.${e}`,value:n,maxLength:200,spellCheck:!1,"aria-invalid":r!==void 0,"aria-describedby":r===void 0?void 0:o,onChange:t=>{i(e,t.target.value)}}),t?.length?(0,h.jsx)(`p`,{className:`mt-1 text-small text-ink3`,children:t.join(` · `)}):null,r===void 0?null:(0,h.jsx)(`p`,{id:o,className:`mt-1 text-label text-red`,children:r})]})}function aN({className:e,children:t,...n}){return(0,h.jsxs)(`span`,{className:`relative inline-flex min-w-0 items-center`,children:[(0,h.jsx)(`select`,{"data-slot":`picker`,className:z(`h-8 w-full min-w-0 appearance-none rounded-control border border-line2 bg-panel2`,`py-[5px] pr-[26px] pl-[10px] text-small text-ink aria-invalid:border-red`,e),...n,children:t}),(0,h.jsx)(JA,{"aria-hidden":`true`,className:`pointer-events-none absolute right-[8px] size-[14px] text-ink2`})]})}var oN=e=>[`provider-models`,e];async function sN(e,t,n=!1,r){let i=`${e.origin}/api/providers/${encodeURIComponent(t)}/models${n?`?refresh=1`:``}`;return eo(await e.fetch(i,r?{signal:r}:void 0))}function cN(e,t){return rt({queryKey:oN(t),queryFn:({signal:n})=>sN(e,t,!1,n),enabled:t!==``,staleTime:3e4,refetchInterval:3e4,retry:!1})}function lN(e){return e!==``&&e!==`fal`&&e!==`replicate`}function uN(e){if(!Rk(e))return e.kind===`keyed`?`Key Missing`:e.issueKind===`login`?`Sign In Required`:e.issueKind===`bridge`?`Host Helper Unavailable`:e.issueKind===`version`?`CLI Update Required`:e.issue===void 0||e.issueKind===`missing`?`CLI Missing`:`CLI Unavailable`}function dN({label:e,field:t,problem:n,inline:r=!1,children:i}){let a=(0,m.useId)(),o=(0,m.useId)();return(0,h.jsxs)(`div`,{className:z(r?`flex min-w-0 max-w-full items-center gap-[10px]`:`min-w-0 [&>span]:w-full`),children:[(0,h.jsx)(oM,{htmlFor:a,className:r?`shrink-0`:`mb-[5px]`,children:e}),i({field:t,id:a,describedBy:n===void 0?void 0:o}),n===void 0?null:(0,h.jsx)(`p`,{id:o,className:z(`text-label text-red`,r?``:`mt-1`),children:n})]})}function fN({label:e,field:t,value:n,problem:r,inline:i,placeholder:a,options:o,disabled:s=!1,onPick:c}){return(0,h.jsx)(dN,{field:t,label:e,problem:r,inline:i,children:({id:e,describedBy:l})=>(0,h.jsxs)(aN,{id:e,"data-play-field":t,value:n,disabled:s,"aria-invalid":r!==void 0,"aria-describedby":l,className:i===!0?`w-auto min-w-[120px]`:void 0,onChange:e=>{c(e.target.value)},children:[(0,h.jsx)(`option`,{value:``,children:a}),n!==``&&!o.some(e=>e.value===n)?(0,h.jsxs)(`option`,{value:n,children:[n,` (saved choice)`]}):null,o.map(e=>(0,h.jsx)(`option`,{value:e.value,disabled:e.disabled===!0,children:e.label},e.value))]})})}function pN(e,t){return e.filter(e=>e.family===t).map(e=>{let t=mN(e);return{value:e.id,label:t===void 0?e.displayName:`${e.displayName} · ${t}`,disabled:t!==void 0}})}function mN(e){return uN(e.readiness)}function hN({label:e,field:t,family:n,providers:r,value:i,problem:a,inline:o,onPick:s}){return(0,h.jsx)(fN,{field:t,label:e,value:i,problem:a,inline:o,placeholder:`Pick a provider`,options:[...i!==``&&!r.some(e=>e.id===i&&e.family===n)?[{value:i,label:`${i} (saved provider)`,disabled:!0}]:[],...pN(r,n)],onPick:s})}function gN(e){return(0,h.jsx)(_N,{...e},e.provider)}function _N({label:e,field:t,provider:n,value:r,problem:i,inline:a,onPick:o}){let{api:s}=I(),c=_(),l=nt(cN(s,n)),[u,d]=(0,m.useState)(!1),f=(0,m.useId)(),p=(0,m.useId)(),g=it({mutationFn:()=>sN(s,n,!0),onSuccess:e=>c.setQueryData(oN(n),e)}),v=l.data?.models??[],y=[...new Set(v.flatMap(e=>e.group?[e.group]:[]))],b=l.data?.allowsCustom??lN(n),x=u&&b,S=l.isFetching||g.isPending,C=g.error?.message??l.error?.message??l.data?.warning,w=r!==``&&!v.some(e=>e.id===r);return(0,h.jsxs)(`div`,{className:`min-w-0 max-w-full`,children:[(0,h.jsx)(dN,{field:t,label:e,problem:i,inline:a,children:({id:e,describedBy:s})=>{let c=[s,C?f:void 0,l.data?.notice?p:void 0].filter(Boolean).join(` `)||void 0;return(0,h.jsx)(`div`,{className:z(`min-w-0 [&>span]:w-full`,a?`max-w-[260px]`:`w-full`),children:x?(0,h.jsx)(cM,{id:e,"data-play-field":t,value:r,spellCheck:!1,placeholder:`Type the model id`,"aria-invalid":i!==void 0,"aria-describedby":c,className:a?`w-[180px] max-w-full`:void 0,onChange:e=>o(e.target.value)}):(0,h.jsxs)(aN,{id:e,"data-play-field":t,value:r,disabled:n===``,"aria-invalid":i!==void 0,"aria-describedby":c,className:a?`w-full min-w-[120px] max-w-[260px]`:void 0,onChange:e=>o(e.target.value),children:[(0,h.jsx)(`option`,{value:``,children:n===``?`Pick a provider first`:l.isPending?`Loading models…`:`Pick a model`}),w?(0,h.jsxs)(`option`,{value:r,children:[r,` (saved model)`]}):null,v.filter(e=>!e.group).map(e=>(0,h.jsx)(`option`,{value:e.id,children:e.name},e.id)),y.map(e=>(0,h.jsx)(`optgroup`,{label:e,children:v.filter(t=>t.group===e).map(e=>(0,h.jsx)(`option`,{value:e.id,children:e.name},e.id))},e))]})})}}),n===``?null:(0,h.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-1`,children:[(0,h.jsxs)(B,{type:`button`,variant:`ghost`,className:`px-2 text-label`,"aria-label":`Refresh ${e} list`,title:`Refresh models`,disabled:S,onClick:()=>g.mutate(),children:[(0,h.jsx)(oj,{"aria-hidden":`true`,className:z(`size-3`,S&&`animate-spin motion-reduce:animate-none`)}),`Refresh`]}),b?(0,h.jsx)(B,{type:`button`,variant:`ghost`,className:`px-2 text-label`,"aria-label":x?`Choose ${e} from list`:`Enter ${e} ID`,onClick:()=>d(!x),children:x?`Use list`:`Custom ID`}):null]}),l.data?.notice?(0,h.jsx)(`p`,{id:p,className:`mt-1 max-w-[360px] text-label text-ink3`,children:l.data.notice}):null,C?(0,h.jsx)(`p`,{id:f,className:`mt-1 max-w-[360px] text-label text-ink3`,role:`status`,children:C}):null]})}function vN({label:e,field:t,hideLabel:n=!1,value:r,options:i,className:a,onPick:o}){let s=(0,m.useId)();return(0,h.jsxs)(`span`,{className:z(`inline-flex items-center gap-[10px]`,a),children:[(0,h.jsx)(oM,{id:s,className:n?`sr-only`:`shrink-0`,children:e}),(0,h.jsx)(Hj,{type:`single`,value:r,"aria-labelledby":s,onValueChange:e=>{let t=i.find(t=>t.value===e);t!==void 0&&t.disabled!==!0&&o(t.value)},children:i.map(e=>(0,h.jsx)(Uj,{value:e.value,"data-play-field":e.value===r?t:void 0,disabled:e.disabled===!0,children:e.label},e.value))})]})}function yN({value:e,onPick:t,rawCounts:n}){let r=e.words??500,i=e.characters??3e3,a=e.mode===`words`||e.mode===`characters`,o=e.mode===`characters`,s=o?e.characters:e.words;return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(vN,{field:`chunking.mode`,label:`Chunking`,className:`min-w-0 max-w-full flex-wrap [&_[data-slot=toggle-group]]:max-w-full [&_[data-slot=toggle-group]]:flex-wrap`,value:e.mode,options:[{value:`whole`,label:`Whole`},{value:`paragraph`,label:`Paragraph`},{value:`words`,label:`Every ${String(n?.words??r)} words`},{value:`characters`,label:`Every ${String(n?.characters??i)} characters`}],onPick:e=>{if(n){n.onChange(e,e===`characters`?n.characters:n.words);return}t(e===`words`?{mode:e,words:r}:e===`characters`?{mode:e,characters:i}:{mode:e})}}),a?(0,h.jsx)(dN,{label:o?`Characters`:`Words`,problem:void 0,inline:!0,children:({id:r})=>(0,h.jsx)(cM,{id:r,"data-play-field":o?`chunking.characters`:`chunking.words`,type:n?`text`:`number`,min:1,max:o?1e6:1e4,inputMode:`numeric`,className:`w-[100px] tabular-nums`,value:n?o?n.characters:n.words:s===void 0?``:String(s),onChange:r=>{if(n){n.onChange(e.mode,r.target.value);return}let i=Number.parseInt(r.target.value,10),a=Number.isFinite(i)&&i>0;t(o?a?{mode:`characters`,characters:Math.min(i,1e6)}:{mode:`characters`}:a?{mode:`words`,words:Math.min(i,1e4)}:{mode:`words`})}})}):null,o?(0,h.jsx)(`p`,{className:`basis-full text-small text-ink3`,children:`Ends at the last complete sentence within the character count, including spaces. A longer sentence stays whole; provider request limits still apply.`}):null]})}var bN=1;function xN({prompts:e,picked:t,problem:n,onPick:r,rawNumbers:i}){let a=(0,m.useId)(),o=t.reduce((e,t)=>e+t.number,0),s=t.filter(t=>!e.some(e=>e.name===t.name)),c=[...e.map(e=>({name:e.name,missing:!1})),...s.map(e=>({name:e.name,missing:!0}))];return c.length===0?(0,h.jsx)(`p`,{className:`basis-full text-right text-small text-ink3`,children:`No image prompts saved. Write one on Prompts.`}):(0,h.jsxs)(`div`,{className:`flex basis-full flex-col items-start gap-[6px]`,children:[(0,h.jsx)(`span`,{id:a,className:`engraved text-ink3`,children:`Image prompts`}),(0,h.jsx)(`ul`,{"aria-labelledby":a,className:`flex flex-wrap justify-start gap-x-4 gap-y-2`,children:c.map(e=>{let a=t.findIndex(t=>t.name===e.name),o=a===-1?void 0:t[a];return(0,h.jsxs)(`li`,{children:[e.missing?(0,h.jsx)(`span`,{className:`block text-label text-red`,children:`Missing template · untick to remove`}):null,(0,h.jsx)(SN,{name:e.name,number:o?.number,rawNumber:i?{value:i.values.find(t=>t.name===e.name)?.number??``,onChange:t=>i.onChange(e.name,t)}:void 0,problem:a===-1?void 0:n(`imagePrompts.${String(a)}.number`),onTick:n=>{r(n?[...t,{name:e.name,number:bN}]:t.filter(t=>t.name!==e.name))},onNumber:n=>{r(t.map(t=>t.name===e.name?{name:t.name,number:n}:t))}})]},e.name)})}),t.length===0?null:(0,h.jsx)(`span`,{className:`text-label text-ink3 tabular-nums`,children:Number.isFinite(o)?`${String(o)} of 60 images`:`Complete image counts to see the total`})]})}function SN({name:e,number:t,problem:n,onTick:r,onNumber:i,rawNumber:a}){let o=(0,m.useId)(),s=(0,m.useId)(),c=(0,m.useId)();return(0,h.jsxs)(`span`,{className:`inline-flex items-center gap-2 text-small`,children:[(0,h.jsx)(`input`,{id:o,"data-play-field":`imagePrompts`,type:`checkbox`,checked:t!==void 0,className:`size-[14px] shrink-0 accent-accent`,onChange:e=>{r(e.target.checked)}}),(0,h.jsx)(`label`,{htmlFor:o,className:t===void 0?`text-ink3`:`text-ink`,children:e}),(0,h.jsx)(oM,{htmlFor:s,className:`sr-only`,children:`Number for ${e}`}),(0,h.jsx)(cM,{id:s,"data-play-field":`imagePrompts.${e}.number`,type:a?`text`:`number`,min:bN,max:20,inputMode:`numeric`,disabled:t===void 0,"aria-invalid":n!==void 0,"aria-describedby":n===void 0?void 0:c,className:`w-[64px] tabular-nums`,value:a?.value??(t===void 0||t===0?``:String(t)),onChange:e=>{if(a){a.onChange(e.target.value);return}let t=Number.parseInt(e.target.value,10);i(Number.isFinite(t)?t:0)}}),n===void 0?null:(0,h.jsx)(`span`,{id:c,className:`text-label text-red`,children:n})]})}var CN=`text-small text-ink2 file:mr-3 file:h-8 file:rounded-control file:border file:border-line2 file:bg-panel2 file:px-3 file:text-ink`;function wN({label:e,field:t,value:n,placeholder:r,problem:i,onChange:a}){let o=(0,m.useId)(),s=(0,m.useId)();return(0,h.jsxs)(`div`,{children:[(0,h.jsx)(oM,{htmlFor:o,className:`mb-[5px]`,children:e}),(0,h.jsx)(lM,{id:o,"data-play-field":t,rows:6,value:n,placeholder:r,"aria-invalid":i!==void 0,"aria-describedby":i===void 0?void 0:s,onChange:e=>{a(e.target.value)}}),i===void 0?null:(0,h.jsx)(`p`,{id:s,className:`mt-1 text-label text-red`,children:i})]})}function TN({label:e,field:t,accept:n,multiple:r=!1,uploads:i,problem:a,numbered:o=!1,onPick:s,onRemove:c,onReattach:l}){let u=(0,m.useId)(),d=(0,m.useId)();return(0,h.jsxs)(`div`,{children:[(0,h.jsx)(oM,{htmlFor:u,className:`mb-[5px]`,children:e}),(0,h.jsx)(`input`,{id:u,"data-play-field":t,type:`file`,accept:n,multiple:r,"aria-invalid":a!==void 0,"aria-describedby":a===void 0?void 0:d,className:CN,onChange:e=>{s([...e.target.files??[]]),e.target.value=``}}),a===void 0?null:(0,h.jsx)(`p`,{id:d,className:`mt-1 text-label text-red`,children:a}),i.length===0?null:(0,h.jsx)(`ul`,{className:`mt-2 flex flex-col gap-1`,children:i.map((e,t)=>(0,h.jsxs)(`li`,{className:`flex flex-wrap items-center gap-3`,children:[o?(0,h.jsx)(`span`,{className:`engraved w-6 text-ink3`,children:String(t+1)}):null,(0,h.jsx)(EN,{upload:e}),e.error!==void 0&&l?(0,h.jsxs)(`label`,{className:`text-small text-ink2`,children:[`Reattach`,(0,h.jsx)(`input`,{"aria-label":`Reattach ${e.name}`,className:`max-w-full`,type:`file`,accept:n,onChange:t=>{let n=t.target.files?.[0];t.target.value=``,n&&l(e.key,n)}})]}):null,c===void 0?null:(0,h.jsx)(B,{variant:`ghost`,className:`ml-auto`,"aria-label":`Remove ${e.name}`,onClick:()=>{c(e.key)},children:`Remove`})]},e.key))})]})}function EN({upload:e}){return(0,h.jsxs)(`span`,{className:`flex min-w-0 flex-wrap items-center gap-3 text-small [overflow-wrap:anywhere]`,children:[(0,h.jsx)(`span`,{className:e.error===void 0?`text-ink`:`text-red`,children:e.name}),e.error===void 0?(0,h.jsx)(`span`,{className:`engraved text-ink3`,children:e.file===void 0?`Copying`:`Staged`}):(0,h.jsx)(`span`,{className:`text-small text-red`,children:e.error})]})}var DN=`col-span-3 grid min-w-0 grid-cols-1 gap-4 min-[700px]:grid-cols-2`,ON=`col-span-3 min-w-0`;function kN({kind:e,name:t,dim:n,children:r}){return(0,h.jsxs)(`section`,{"data-tour":`play-${e}`,className:`grid grid-cols-[24px_1fr_auto] items-center gap-x-2 gap-y-5 border-b border-line py-6`,children:[(0,h.jsx)(Pc,{kind:e,className:n?`text-ink3`:`text-ink2`}),(0,h.jsx)(`h3`,{className:z(`text-lg font-semibold`,n?`text-ink3`:void 0),children:t}),r]})}function AN({kind:e,form:t,update:n}){return(0,h.jsx)(vN,{field:`sources.${e}`,label:`${e} source`,hideLabel:!0,className:`max-[700px]:col-span-3 max-[700px]:justify-self-start [&_[data-slot=toggle-group]]:flex-wrap`,value:t.sources[e],options:FM(e).map(n=>({...n,disabled:e===`video`&&n.value===`generate`&&t.sources.images===`off`})),onPick:r=>{n({sources:{...t.sources,[e]:r,...e===`images`&&r===`off`?{video:`off`}:{}}})}})}function jN(e,t){return e.filter(e=>e.kind===t).map(e=>({value:e.name,label:e.name}))}function MN({value:e,prompts:t,supported:n,error:r,libraryLinks:i=!0,onChange:a}){let o=(0,m.useId)(),s=t.filter(e=>e.kind===`narration`),c=s.find(t=>t.name===e),l=r??(e!==``&&!n?`Choose Inworld TTS-2 or turn preparation Off.`:void 0);return(0,h.jsxs)(`div`,{className:`col-span-full min-w-0 space-y-2`,children:[(0,h.jsx)(`label`,{htmlFor:o,className:`block text-small font-semibold`,children:`Narration Preparation`}),(0,h.jsxs)(aN,{id:o,"data-play-field":`narrationPrompt`,value:e,"aria-describedby":`${o}-help${l?` ${o}-error`:``}`,"aria-invalid":l!==void 0||void 0,onChange:e=>a(e.target.value),children:[(0,h.jsx)(`option`,{value:``,children:`Off`}),e!==``&&c===void 0?(0,h.jsxs)(`option`,{value:e,children:[e,` (saved selection)`]}):null,s.map(e=>(0,h.jsx)(`option`,{value:e.name,children:e.name},e.id))]}),(0,h.jsx)(`p`,{id:`${o}-help`,className:`text-small text-ink3`,children:`Optional. Uses the selected LLM once per narration chunk and entry. Supports Inworld TTS-2; the article and clean narration stay unchanged.`}),l?(0,h.jsx)(`p`,{id:`${o}-error`,className:`text-small text-red`,children:l}):null,i?(0,h.jsxs)(`div`,{className:`flex gap-4 text-small`,children:[(0,h.jsx)(sa,{to:`/prompts/new`,search:{kind:`narration`},children:`Create prompt`}),c?(0,h.jsx)(sa,{to:`/prompts/$promptId`,params:{promptId:c.id},children:`View prompt`}):null]}):null]})}function NN({form:e,prompts:t,providers:n,voices:r,problem:i,update:a,onPickFiles:o,onRemoveFile:s,onReattachFile:c,rawCounts:l}){let u=r.filter(t=>t.provider===e.audio.provider);return(0,h.jsxs)(kN,{kind:`audio`,name:`Audio`,dim:e.sources.audio===`off`,children:[(0,h.jsx)(AN,{kind:`audio`,form:e,update:a}),(0,h.jsx)(`div`,{className:DN,children:e.sources.audio===`generate`?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(hN,{field:`audio.provider`,label:`TTS`,family:`tts`,providers:n,value:e.audio.provider,problem:i(`audio`),onPick:e=>{a({audio:{provider:e,model:``,voice:``}})}}),(0,h.jsx)(gN,{field:`audio.model`,label:`TTS model`,provider:e.audio.provider,value:e.audio.model,problem:i(`audio.model`),onPick:t=>a({audio:{...e.audio,model:t}})}),(0,h.jsx)(fN,{field:`audio.voice`,label:`Voice`,value:e.audio.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:i(`audio.voice`),onPick:t=>{a({audio:{...e.audio,voice:t}})}}),(0,h.jsxs)(`details`,{className:`col-span-full`,children:[(0,h.jsxs)(`summary`,{className:`cursor-pointer py-2`,children:[`Audio Advanced · `,e.chunking.mode]}),(0,h.jsx)(yN,{...l?{rawCounts:l}:{},value:e.chunking,onPick:e=>{a({chunking:e})}})]}),(0,h.jsx)(MN,{value:e.narrationPrompt??``,prompts:t,supported:e.audio.provider===`inworld`&&e.audio.model===`inworld-tts-2`,error:i(`narrationPrompt`),onChange:e=>a({narrationPrompt:e})})]}):null}),e.sources.audio===`provide`?(0,h.jsxs)(`div`,{className:ON,children:[(0,h.jsx)(TN,{field:`provided.audio`,label:`Narration file`,accept:`audio/*`,uploads:e.provided.audio===void 0?[]:[e.provided.audio],problem:i(`provided.audio`),onPick:e=>{o(`audio`,e)},onReattach:c?(e,t)=>c(`audio`,e,t):void 0,onRemove:e=>{s(`audio`,e)}}),(0,h.jsx)(`p`,{className:`mt-2 text-small text-ink2`,children:`Uploaded narration is used as-is; include any intro and outro in that file.`})]}):null]})}function PN({form:e,providers:t,prompts:n,problem:r,update:i,onPickFiles:a,onRemoveFile:o,onReattachFile:s,rawNumbers:c}){return(0,h.jsxs)(kN,{kind:`images`,name:`Images`,dim:e.sources.images===`off`,children:[(0,h.jsx)(AN,{kind:`images`,form:e,update:i}),(0,h.jsx)(`div`,{className:DN,children:e.sources.images===`generate`?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(FN,{form:e,providers:t,problem:r,update:i}),(0,h.jsx)(xN,{prompts:n.filter(e=>e.kind===`image`),...c?{rawNumbers:c}:{},picked:e.imagePrompts,problem:r,onPick:e=>{i({imagePrompts:e})}})]}):null}),e.sources.images===`provide`?(0,h.jsx)(`div`,{className:ON,children:(0,h.jsx)(TN,{field:`provided.images`,label:`Slideshow images`,accept:`image/png,image/jpeg,image/webp`,multiple:!0,numbered:!0,uploads:e.provided.images,problem:r(`provided.images`),onPick:e=>{a(`images`,e)},onReattach:s?(e,t)=>s(`images`,e,t):void 0,onRemove:e=>{o(`images`,e)}})}):null]})}function FN({form:e,providers:t,problem:n,update:r}){return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(hN,{field:`images.provider`,label:`Provider`,family:`image`,providers:t,value:e.images.provider,problem:n(`images`),onPick:e=>r({images:{provider:e,model:``}})}),(0,h.jsx)(gN,{field:`images.model`,label:`Model`,provider:e.images.provider,value:e.images.model,problem:n(`images.model`),onPick:t=>r({images:{...e.images,model:t}})})]})}function IN({form:e,problem:t,update:n}){return(0,h.jsxs)(kN,{kind:`research`,name:`Research`,dim:e.sources.research===`off`,children:[(0,h.jsx)(AN,{kind:`research`,form:e,update:n}),(0,h.jsx)(`div`,{className:DN,children:e.sources.research===`generate`?(0,h.jsx)(`span`,{className:`engraved text-ink3`,children:`Runs through the LLM, one agent per chapter`}):null}),e.sources.research===`provide`?(0,h.jsx)(`div`,{className:ON,children:(0,h.jsx)(wN,{field:`provided.research`,label:`Research notes`,value:e.provided.research,placeholder:`Paste the notes the article will be written from.`,problem:t(`provided.research`),onChange:t=>{n({provided:{...e.provided,research:t}})}})}):null]})}function LN({form:e,prompts:t,problem:n,update:r}){return(0,h.jsxs)(kN,{kind:`article`,name:`Article`,dim:!1,children:[(0,h.jsx)(AN,{kind:`article`,form:e,update:r}),(0,h.jsx)(`div`,{className:`${ON} grid gap-4`,children:e.sources.article===`generate`?(0,h.jsx)(fN,{field:`articlePrompt`,label:`Article prompt`,value:e.articlePrompt,placeholder:`Pick a prompt`,options:jN(t,`article`),problem:n(`articlePrompt`),onPick:e=>{r({articlePrompt:e})}}):null}),e.sources.article===`provide`?(0,h.jsx)(`div`,{className:ON,children:(0,h.jsx)(wN,{field:`provided.article`,label:`Article text`,value:e.provided.article,placeholder:`Paste the article that will be narrated.`,problem:n(`provided.article`),onChange:t=>{r({provided:{...e.provided,article:t}})}})}):null]})}function RN({form:e,providers:t,prompts:n,problem:r,update:i,onPickFiles:a,onRemoveFile:o,onReattachFile:s}){let c=e.sources.thumbnail===`from_prompt`||e.sources.thumbnail===`prompt_by_llm`;return(0,h.jsxs)(kN,{kind:`thumbnail`,name:`Thumbnail`,dim:e.sources.thumbnail===`off`,children:[(0,h.jsx)(AN,{kind:`thumbnail`,form:e,update:i}),(0,h.jsxs)(`div`,{className:DN,children:[c&&e.sources.images!==`generate`?(0,h.jsx)(FN,{form:e,providers:t,problem:r,update:i}):null,c?(0,h.jsx)(fN,{field:`thumbnailPrompt`,label:`Thumbnail prompt`,value:e.thumbnailPrompt,placeholder:`Pick a prompt`,options:jN(n,`thumbnail`),problem:r(`thumbnailPrompt`),onPick:e=>{i({thumbnailPrompt:e})}}):null]}),e.sources.thumbnail===`provide`?(0,h.jsx)(`div`,{className:ON,children:(0,h.jsx)(TN,{field:`provided.thumbnail`,label:`Thumbnail image`,accept:`image/png,image/jpeg,image/webp`,uploads:e.provided.thumbnail===void 0?[]:[e.provided.thumbnail],problem:r(`provided.thumbnail`),onPick:e=>{a(`thumbnail`,e)},onReattach:s?(e,t)=>s(`thumbnail`,e,t):void 0,onRemove:e=>{o(`thumbnail`,e)}})}):null]})}function zN({form:e,silenceGapSeconds:t,update:n}){let r=e.sources.video===`generate`?e.sources.audio===`off`?`Silent video · 5 seconds per image`:`Images and narration · ${String(t)} s segment gaps`:e.sources.audio===`off`?`Download each enabled stage separately`:`Combined WAV export with narration and segment gaps`;return(0,h.jsxs)(kN,{kind:`video`,name:`Export`,dim:e.sources.video===`off`,children:[(0,h.jsx)(AN,{kind:`video`,form:e,update:n}),(0,h.jsx)(`span`,{className:DN,children:(0,h.jsx)(`span`,{className:`engraved text-ink3`,children:r})}),e.sources.images===`off`?(0,h.jsx)(`p`,{className:`${ON} text-small text-ink2`,children:`Video is Off because Images is Off. Generate or provide images to enable video.`}):null]})}function BN({choice:e,onChange:t}){let{api:n}=I(),r=nt(cN(n,e.provider)).data?.models.find(t=>t.id===e.model)?.thinkingModes??[];return!r.length&&!e.thinking?null:(0,h.jsxs)(`div`,{className:`min-w-0`,children:[(0,h.jsx)(fN,{field:`llm.thinking`,label:`Thinking`,value:e.thinking??`default`,placeholder:`Model default`,problem:e.thinking&&!r.includes(e.thinking)?`Choose a supported thinking level.`:void 0,options:[{value:`default`,label:`Model default`},...e.thinking&&!r.includes(e.thinking)?[{value:e.thinking,label:`${e.thinking} (saved level)`}]:[],...r.map(e=>({value:e,label:e===`off`?`Off`:e.charAt(0).toUpperCase()+e.slice(1)}))],onPick:n=>{let i=r.find(e=>e===n);t({...e,thinking:i})}}),r.length&&!r.includes(`off`)?(0,h.jsx)(`p`,{className:`mt-1 text-small text-ink3`,children:`This model does not support turning thinking off.`}):null]})}function VN(e){let{form:t,problem:n,update:r,fields:i,entries:a,onLibrary:o}=e,s=(0,m.useId)(),c=e.prompts.find(e=>e.kind===`article`&&e.name===t.articlePrompt);return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`div`,{className:`mt-7`,children:[(0,h.jsx)(oM,{htmlFor:s,className:`mb-2`,children:`Project title`}),(0,h.jsx)(cM,{id:s,"data-play-field":`title`,value:t.title,maxLength:200,"aria-invalid":n(`title`)!==void 0,onChange:e=>r({title:e.target.value})}),n(`title`)?(0,h.jsx)(`p`,{className:`text-small text-red`,children:n(`title`)}):null]}),(0,h.jsx)(LN,{...e}),t.sources.article===`generate`?(0,h.jsxs)(`div`,{className:`flex flex-wrap items-start gap-3 py-3`,children:[c?(0,h.jsxs)(`details`,{className:`min-w-0 flex-1`,children:[(0,h.jsx)(`summary`,{"data-play-field":`articlePrompt.preview`,className:`cursor-pointer py-2 text-small text-run-text`,children:`View prompt`}),(0,h.jsx)(`pre`,{className:`whitespace-pre-wrap break-words py-3 font-sans text-body text-ink2`,children:c.body})]}):(0,h.jsx)(`p`,{className:`text-small text-ink2`,children:e.prompts.some(e=>e.kind===`article`)?`Choose a saved article prompt.`:`No article prompts saved. Create a prompt to begin.`}),(0,h.jsx)(B,{variant:`ghost`,onClick:()=>o(`/prompts`),children:`Create prompt`})]}):(0,h.jsxs)(`p`,{className:`py-3 text-small text-ink3`,children:[t.provided.article.trim()?t.provided.article.trim().split(/\s+/).length:0,` `,`words · `,t.provided.article.length,` characters`]}),(0,h.jsx)(rN,{fields:i,origins:$M({form:t,prompts:e.prompts,entries:a,silenceGapSeconds:e.silenceGapSeconds}),values:t.values,problem:n,onChange:(e,n)=>r({values:{...t.values,[e]:n}})}),IM(t,a)?(0,h.jsxs)(`section`,{className:`border-y border-line py-6`,children:[(0,h.jsx)(`h3`,{className:`mb-4 text-lg font-semibold`,children:`Text generation`}),(0,h.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 min-[700px]:grid-cols-2`,children:[(0,h.jsx)(hN,{field:`llm.provider`,label:`LLM`,family:`llm`,providers:e.providers,value:t.llm.provider,problem:n(`llm.provider`)??(t.llm.provider===``?n(`llm`):void 0),onPick:e=>r({llm:{provider:e,model:``}})}),(0,h.jsx)(gN,{field:`llm.model`,label:`Text model`,provider:t.llm.provider,value:t.llm.model,problem:n(`llm.model`)??(t.llm.provider!==``&&n(`llm`)?`Pick a text model.`:void 0),onPick:e=>r({llm:{...t.llm,model:e}})}),(0,h.jsx)(BN,{choice:t.llm,onChange:e=>r({llm:e})})]}),(0,h.jsx)(`p`,{className:`mt-3 text-small text-ink3`,children:`Shared by generated article, research, thumbnail wording, generated entries and Narration Preparation when enabled.`}),(0,h.jsx)(B,{variant:`ghost`,onClick:()=>o(`/settings`),children:`Settings`})]}):null,t.sources.article===`provide`?(0,h.jsx)(`p`,{className:`py-4 text-small text-ink3`,children:`Research is Off because the article is provided.`}):(0,h.jsx)(IN,{...e})]})}function HN(){let{api:e}=I(),t=Ek(),n=_(),[r,i]=(0,m.useState)(null),[a,o]=(0,m.useState)(null),[s,c]=(0,m.useState)(!1),l=nt({queryKey:[`play-drafts`],queryFn:async()=>{let t=await NO(e);if(!t.ok)throw Error(t.message);return t.value.drafts}}),u=async()=>{if(!r||s)return;let e=r.id;c(!0),o(null);try{await t.discard({id:r.id,version:r.version}),i(null),await n.cancelQueries({queryKey:[`play-drafts`]}),n.setQueryData([`play-drafts`],t=>t?.filter(t=>t.id!==e))}catch(e){o(e instanceof Error?e.message:`Couldn't discard draft`)}finally{c(!1)}};return(0,h.jsxs)(`section`,{"aria-label":`Drafts`,className:`min-w-0 max-w-full text-small`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-start gap-2`,children:[(0,h.jsxs)(`details`,{className:`max-w-full rounded-control border border-line bg-panel px-3`,children:[(0,h.jsx)(`summary`,{className:`flex min-h-10 cursor-pointer items-center font-semibold`,children:`Drafts`}),l.isPending?(0,h.jsx)(`p`,{role:`status`,children:`Loading drafts…`}):null,l.error?(0,h.jsxs)(`p`,{role:`alert`,children:[l.error.message,(0,h.jsx)(`button`,{type:`button`,onClick:()=>void l.refetch(),children:`Retry`})]}):null,l.data?.length===0?(0,h.jsx)(`p`,{children:`No saved drafts`}):null,(0,h.jsx)(`ul`,{className:`max-h-72 max-w-[320px] overflow-y-auto pb-2`,children:l.data?.map(e=>(0,h.jsxs)(`li`,{className:`flex flex-wrap items-center gap-2 border-t border-line py-2`,children:[(0,h.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,h.jsx)(`button`,{type:`button`,className:`w-full break-words text-left`,onClick:()=>void t.open(e.id),children:(0,h.jsx)(`span`,{className:`block`,children:e.title||`Untitled draft`})}),(0,h.jsxs)(`time`,{dateTime:e.updatedAt,className:`block text-label text-ink3`,children:[`Last edited `,jc(e.updatedAt)]})]}),e.readable?null:(0,h.jsx)(`p`,{children:`Unsupported or corrupt draft. Try opening it to recover, or discard it.`}),(0,h.jsx)(`button`,{type:`button`,onClick:()=>{i(e),o(null)},"aria-label":`Discard ${e.title||`Untitled draft`}`,children:`Discard`})]},e.id))})]}),(0,h.jsx)(B,{onClick:()=>void t.newDraft(),children:`New draft`})]}),(0,h.jsx)(`p`,{role:`status`,className:`mt-2 text-small text-ink3`,children:{unsaved:`Unsaved`,saving:`Saving…`,saved:`Saved`,error:`Couldn't save`,conflict:`Changed elsewhere`}[t.status]}),(0,h.jsx)(Nj,{open:r!==null,title:`Discard draft`,consequence:`Discard ${r?.title||`Untitled draft`}? This cannot be undone.`,verb:`Confirm discard`,pending:s,onConfirm:()=>void u(),onCancel:()=>{s||i(null)}}),a?(0,h.jsx)(`p`,{role:`alert`,children:a}):null,t.error?(0,h.jsxs)(`p`,{role:`alert`,children:[`Couldn't save. `,t.error]}):null,t.status===`error`?(0,h.jsx)(`button`,{type:`button`,onClick:()=>{!t.view&&t.activeId&&t.edited===0?t.open(t.activeId):t.flush()},children:`Retry`}):null,t.status===`conflict`?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`button`,{type:`button`,onClick:()=>{t.activeId&&t.open(t.activeId)},children:`Reload saved draft`}),(0,h.jsx)(`button`,{type:`button`,onClick:()=>void t.saveAsNew(),children:`Save as a new draft`})]}):null]})}function UN(e,t){let n=[...e.querySelectorAll(`[data-play-field]`)].find(e=>e.dataset.playField===t);return!n||n.hasAttribute(`disabled`)?!1:(n.focus(),n.scrollIntoView({block:`nearest`,inline:`nearest`,behavior:`instant`}),document.activeElement===n)}function WN(e,t,n){let r=e;e===`fontUpload`&&(r=`subtitles.fontUpload`),/^provided\.images\.\d+$/.test(e)&&(r=`provided.images`),e===`subtitles`&&(r=`subtitles.mode`),e===`chunking`&&(r=`chunking.mode`),[`audio`,`llm`,`images`].includes(e)&&(r=`${e}.provider`),e===`provided`&&(r=`provided.${[`audio`,`images`,`thumbnail`].find(e=>t.sources[e]===`provide`&&(e===`images`?t.provided.images:[t.provided[e]]).some(e=>e&&(e.error!==void 0||e.file===void 0)))??`audio`}`);let i=/^imagePrompts\.(\d+)\.(.+)$/.exec(e);if(i){let e=t.imagePrompts[Number(i[1])];e&&(r=`imagePrompts.${e.name}.${i[2]}`)}e===`imagePrompts`&&(r=t.imagePrompts[0]?`imagePrompts.${t.imagePrompts[0].name}.number`:`imagePrompts`);let a=/^variants\.(\d+)\.(.+)$/.exec(e);a&&(r=`items.${n[Number(a[1])]?.key??a[1]}.${a[2]}`);let o=/^items\.(\d+)\.(.+)$/.exec(e);o&&(r=Number(o[1])===0?o[2]??e:`items.${n[Number(o[1])-1]?.key??o[1]}.${o[2]}`);let s=t=>t.some(t=>e===t||e.startsWith(`${t}.`));return{section:s([`title`,`articlePrompt`,`provided.article`,`provided.research`,`sources.article`,`sources.research`,`llm`,`values`])?`content`:s([`format`,`subtitles`,`fontUpload`])?`style`:s([`audio`,`narrationPrompt`,`provided.audio`,`intro`,`outro`,`chunking`,`images`,`imagePrompts`,`provided.images`,`thumbnailPrompt`,`provided.thumbnail`,`provided`,`sources`])?`outputs`:`review`,field:r}}function GN(e){return e===`9:16`?{width:1080,height:1920}:{width:1920,height:1080}}function KN(e,t){switch(e){case`top`:return{y:60,alignment:8,translateY:0};case`upper-middle`:return{y:t/4,alignment:5,translateY:-50};case`center`:return{y:t/2,alignment:5,translateY:-50};case`lower-middle`:return{y:t*3/4,alignment:5,translateY:-50};case`bottom`:return{y:t-60,alignment:2,translateY:-100}}}function qN({value:e,format:t,sample:n=`Every story begins with a word.`,backgroundUrl:r,showCaptions:i=!0,maxFrameHeight:a}){let{api:o}=I(),s=KO(o,e.fontId),c=`subtitle-preview-${(0,m.useId)().replace(/[^a-zA-Z0-9]/g,``)}`,[l,u]=(0,m.useState)(!1);(0,m.useEffect)(()=>{if(typeof FontFace>`u`||!document.fonts)return;let e=!0,t=new FontFace(c,`url(${JSON.stringify(s)})`);return u(!1),t.load().then(t=>{e&&document.fonts.add(t)}).catch(()=>{e&&u(!0)}),()=>{e=!1,document.fonts.delete(t)}},[c,s]);let d=GN(t),f=KN(e.position??`bottom`,d.height),p=Number.isFinite(e.fontSize)?Math.max(16,Math.min(120,e.fontSize)):48,g={position:`absolute`,left:`50%`,top:`${f.y/d.height*100}%`,width:`${(d.width-120)/d.width*100}%`,transform:`translate(-50%, ${f.translateY}%)`,fontFamily:`"${c}", sans-serif`,fontSize:`${p/d.width*100}cqw`,lineHeight:1.2,overflowWrap:`anywhere`,WebkitTextStroke:`${2.5/d.width*100}cqw #101010`,paintOrder:`stroke fill`,textShadow:`0 ${100/d.width}cqw ${100/d.width}cqw #000`};return(0,h.jsxs)(`figure`,{className:`min-w-0 self-start`,children:[(0,h.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2 text-label text-ink2`,children:[(0,h.jsx)(`span`,{children:`Style preview`}),(0,h.jsx)(`span`,{children:t})]}),(0,h.jsxs)(`div`,{role:`img`,"aria-label":`Subtitle style preview`,"data-format":t,"data-position":e.position??`bottom`,className:`relative mx-auto w-full overflow-hidden rounded-control border border-line2 bg-screen text-center text-white`,style:{aspectRatio:`${d.width} / ${d.height}`,maxWidth:t===`9:16`?a?`min(240px, calc((${a}) * 9 / 16))`:240:480,containerType:`inline-size`},children:[r?(0,h.jsx)(`img`,{src:r,alt:``,className:`absolute inset-0 h-full w-full object-cover`}):null,i?(0,h.jsx)(`span`,{role:`note`,"aria-label":`Caption sample`,style:g,children:n}):null]}),(0,h.jsxs)(`figcaption`,{className:`mt-2 text-label text-ink3`,children:[d.width,` × `,d.height,` · Preview at reduced scale.`,l?` Font preview unavailable; showing a fallback.`:``]})]})}function JN(){let[e,t]=(0,m.useState)(()=>window.matchMedia?.(`(min-width: 1100px)`).matches??!1);return(0,m.useEffect)(()=>{let e=window.matchMedia?.(`(min-width: 1100px)`);if(!e)return;let n=()=>t(e.matches);return n(),e.addEventListener(`change`,n),()=>e.removeEventListener(`change`,n)},[]),e}function YN(){let{api:e}=I(),t=Ek(),{form:n,previewText:r}=t.document,i=n.sources.images===`provide`?n.provided.images.map(e=>t.view?.attachments.find(t=>t.id===e.attachmentId&&t.kind===`images`&&t.state===`ready`&&t.stagedFileId)).find(Boolean):void 0,a=i&&t.activeId?VO(e,t.activeId,i.id):void 0,o=n.sources.video===`generate`&&n.sources.images!==`off`;return(0,h.jsxs)(`section`,{"aria-label":`Output preview`,className:`min-w-0`,children:[(0,h.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,h.jsx)(`h2`,{className:`text-small font-semibold`,children:`Output preview`}),(0,h.jsx)(B,{variant:`ghost`,className:`text-run-text`,onClick:()=>void t.navigate(`style`),children:`Edit style ↗`})]}),(0,h.jsx)(`div`,{className:`rounded-control border border-line bg-panel p-4`,children:(0,h.jsx)(qN,{value:{...n.subtitles,fontSize:Number(n.subtitles.fontSize)},format:n.format,sample:r,showCaptions:n.sources.audio!==`off`&&n.subtitles.mode!==`off`,maxFrameHeight:`max(160px, 100dvh - 360px)`,...a?{backgroundUrl:a}:{}})}),(0,h.jsx)(`p`,{className:`mt-3 text-small text-ink3`,children:a?`Style preview using your supplied image.`:`Style preview only. No generated image is shown.`}),(0,h.jsx)(`p`,{className:`mt-2 text-small text-ink3`,children:o?n.subtitles.mode===`burn-in`?`Captions will be burned into the MP4.`:`Caption styling previews burn-in. SRT/VTT players choose their own styling.`:`Frame and caption styling apply when Video is enabled.`})]})}function XN(e){let t=Ek(),n=t.document,{form:r,entries:i,problem:a,update:o}=e;return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(NN,{...e,rawCounts:{...n.form.chunking,onChange:(e,r)=>t.edit({...n,form:{...n.form,chunking:{...n.form.chunking,mode:e,...e===`words`?{words:r}:e===`characters`?{characters:r}:{}}}})}}),r.sources.audio===`generate`?(0,h.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 border-b border-line py-4 min-[700px]:grid-cols-2`,children:[r.narrationPrompt?(0,h.jsx)(B,{variant:`ghost`,className:`col-span-full`,onClick:()=>e.onKeyword(`llm`),children:`Choose Text Generation in Content`}):null,[`intro`,`outro`].map(e=>(0,h.jsx)(fN,{field:e,label:e===`intro`?`Intro`:`Outro`,value:r[e],placeholder:`Off`,options:i.filter(t=>t.category===e).map(e=>({value:e.name,label:e.name})),problem:a(e),onPick:t=>o({[e]:t})},e)),(0,h.jsx)(B,{variant:`ghost`,onClick:e.onSettings,children:`Settings`})]}):null,(0,h.jsx)(PN,{...e,rawNumbers:{values:n.form.imagePrompts,onChange:(e,r)=>t.edit({...n,form:{...n.form,imagePrompts:n.form.imagePrompts.map(t=>t.name===e?{...t,number:r}:t)}})}}),(0,h.jsx)(RN,{...e}),(0,h.jsx)(zN,{...e}),(0,h.jsx)(nN,{problem:a}),e.missingKeyword?(0,h.jsxs)(`p`,{className:`py-4 text-small text-ink2`,children:[`A selected template needs keywords.`,` `,(0,h.jsx)(B,{variant:`ghost`,onClick:()=>e.onKeyword(e.missingKeyword??`values`),children:`Complete keywords in Content`})]}):null]})}function ZN({selected:e,reviewed:t}){let n=e=>eN.find(t=>t.stage===e)?.label??e;return e?.length?(0,h.jsxs)(`div`,{className:`space-y-3 text-body`,children:[t?.length?t.map(e=>(0,h.jsxs)(`div`,{children:[(0,h.jsxs)(`p`,{className:`font-medium`,children:[`Run `,e.runIndex+1,` · Before `,n(e.stage)]}),(0,h.jsx)(`p`,{className:`text-small text-ink2`,children:e.dependents.length?`Also holds: ${e.dependents.map(n).join(`, `)}.`:`No dependent steps.`})]},`${e.runIndex}-${e.checkpointId}`)):(0,h.jsxs)(`p`,{children:[`Selected: `,e.map(e=>`Before ${n(e)}`).join(`, `),`. Refresh review to confirm dependent steps.`]}),(0,h.jsx)(`p`,{className:`text-small text-ink2`,children:`Approval required on the project page. Starting this run does not approve these checkpoints.`})]}):(0,h.jsx)(`p`,{className:`text-body text-ink2`,children:`No review checkpoints selected.`})}function QN({items:e,fields:t,title:n,values:r,problem:i,onChange:a}){let o=(0,m.useId)();return(0,h.jsxs)(`details`,{className:`rounded-control border border-line p-3`,children:[(0,h.jsxs)(`summary`,{className:`cursor-pointer text-body font-medium`,children:[`Queue keyword variations `,e.length?`(${e.length+1} videos)`:``]}),(0,h.jsx)(`p`,{className:`my-3 text-small text-ink2`,children:`The setup above is video 1. Add videos with different titles and keywords. They run one at a time; a failed video releases the next, and a pause holds the queue.`}),e.map((n,r)=>(0,h.jsxs)(`fieldset`,{className:`mb-3 flex min-w-0 flex-col gap-2 border-t border-line pt-3`,children:[(0,h.jsxs)(`legend`,{className:`text-small text-ink2`,children:[`Video `,r+2]}),(0,h.jsxs)(`label`,{htmlFor:`${o}-${n.key}-title`,className:`text-small`,children:[`Title`,(0,h.jsx)(cM,{id:`${o}-${n.key}-title`,"data-play-field":`items.${n.key}.title`,"aria-invalid":i?.(`items.${r+1}.title`)!==void 0,value:n.title,maxLength:200,onChange:t=>a(e.map(e=>e.key===n.key?{...e,title:t.target.value}:e))})]}),t.map(t=>(0,h.jsxs)(`label`,{htmlFor:`${o}-${n.key}-${encodeURIComponent(t.name)}`,className:`text-small`,children:[t.name,(0,h.jsx)(cM,{id:`${o}-${n.key}-${encodeURIComponent(t.name)}`,"data-play-field":`items.${n.key}.values.${t.name}`,"aria-invalid":i?.(`items.${r+1}.values.${t.name}`)!==void 0,value:n.values[t.name]??``,onChange:r=>a(e.map(e=>e.key===n.key?{...e,values:{...e.values,[t.name]:r.target.value}}:e))})]},t.name)),(0,h.jsxs)(B,{onClick:()=>a(e.filter(e=>e.key!==n.key)),children:[`Remove video `,r+2]})]},n.key)),(0,h.jsx)(B,{disabled:e.length>=49,onClick:()=>a([...e,{key:crypto.randomUUID(),title:`${n||`Video`} ${e.length+2}`,values:{...r}}]),children:`Add keyword variation`})]})}function $N({estimates:e}){let t=e.reduce((e,t)=>e+t.low,0),n=e.reduce((e,t)=>e+t.high,0),r=e.reduce((e,t)=>e+t.unknown,0),i=e[0]?.rows.map((t,n)=>({...t,low:e.some(e=>e.rows[n]?.low===null)?null:e.reduce((e,t)=>e+(t.rows[n]?.low??0),0),high:e.some(e=>e.rows[n]?.high===null)?null:e.reduce((e,t)=>e+(t.rows[n]?.high??0),0)}))??[];return(0,h.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[` `,e.length?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`p`,{className:`text-title font-bold`,children:[r?`Known subtotal: `:`Estimated total: `,eP(t,n)]}),r?(0,h.jsxs)(`p`,{className:`text-body text-ink2`,children:[`Plus `,r,` stage charge`,r===1?``:`s`,` with unavailable pricing.`]}):null,(0,h.jsx)(`div`,{className:`divide-y divide-line`,children:i.map(e=>(0,h.jsx)(`div`,{className:`py-2`,children:(0,h.jsxs)(`div`,{className:`flex justify-between gap-4 text-body`,children:[(0,h.jsx)(`span`,{children:e.stage}),(0,h.jsx)(`span`,{children:e.low===null||e.high===null?`Unknown`:eP(e.low,e.high)})]})},e.stage))}),(0,h.jsxs)(`details`,{className:`border-t border-line py-3`,children:[(0,h.jsx)(`summary`,{className:`cursor-pointer text-small`,children:`Assumptions and stage details`}),(0,h.jsxs)(`div`,{className:`mt-3 flex flex-col gap-2`,children:[i.map(e=>(0,h.jsxs)(`p`,{className:`text-small text-ink2`,children:[e.stage,`: `,e.detail]},e.stage)),[...new Set(e.flatMap(e=>e.assumptions))].map(e=>(0,h.jsx)(`p`,{className:`text-small text-ink2`,children:e},e))]})]}),(0,h.jsxs)(`p`,{className:`text-small text-ink3`,children:[`Catalogue verified `,e[0]?.catalogueDate??`date unavailable`,`. Batch rows show combined costs.`]})]}):null]})}function eP(e,t){let n=e=>e===0?`$0`:e<.01?`<$0.01`:`$${e.toFixed(2)}`;return e===t?n(e):`${n(e)} – ${n(t)}`}function tP(e){return e===void 0?{ok:!1,text:`Provider status unavailable`}:e.readiness.kind===`cli`?Rk(e.readiness)?{ok:!0,text:e.readiness.version===void 0?`CLI ready`:`CLI ready · ${e.readiness.version}`}:{ok:!1,text:e.readiness.issue??`CLI not found`}:e.readiness.hasKey?{ok:!0,text:`API key saved`}:{ok:!1,text:`API key missing`}}function nP(e,t){let n=e.sources.audio===`generate`,r=[`from_prompt`,`prompt_by_llm`].includes(e.sources.thumbnail);return[...(e.sources.article===`generate`||e.sources.thumbnail===`prompt_by_llm`||n&&[`intro`,`outro`].some(n=>t.some(t=>t.category===n&&t.name===e[n]&&t.mode===`llm`)))&&e.llm?[{field:`llm.provider`,family:`llm`,label:`Text generation`,provider:e.llm.provider,model:e.llm.model}]:[],...n&&e.audio?[{field:`audio.provider`,family:`tts`,label:`Narration`,provider:e.audio.provider,model:e.audio.model,voice:e.audio.voice}]:[],...(e.sources.images===`generate`||r)&&e.images?[{field:`images.provider`,family:`image`,label:`Images`,provider:e.images.provider,model:e.images.model}]:[]]}function rP({name:e,children:t}){return(0,h.jsxs)(`section`,{"aria-label":`${e} summary`,className:`min-w-0 border-t border-line pt-5`,children:[(0,h.jsx)(`h3`,{className:`mb-4 font-semibold`,children:e}),t]})}function iP({form:e,entries:t,providers:n,voices:r,textModels:i,audioModels:a,imageModels:o,onReveal:s}){let c=nP(e,t);if(!c.length)return(0,h.jsx)(rP,{name:`Run readiness`,children:(0,h.jsx)(`p`,{className:`text-body text-ink2`,children:`No generated providers required. Supplied content is ready for processing.`})});let l={llm:i,tts:a,image:o};return(0,h.jsxs)(rP,{name:`Run readiness`,children:[(0,h.jsx)(`p`,{className:`mb-3 text-small text-ink2`,children:`These checks are refreshed with Review and checked again when you start.`}),(0,h.jsx)(`ul`,{className:`divide-y divide-line`,"aria-label":`Run readiness checks`,children:c.map(e=>{let t=n?.find(t=>t.id===e.provider&&t.family===e.family),i=tP(t),a=l[e.family],o=a?.models.find(t=>t.id===e.model),c=a===void 0?{ok:!0,text:`Model checked at Start`}:o!==void 0||a.allowsCustom?{ok:!0,text:`Model available`}:{ok:!1,text:`Model unavailable`},u=e.voice===void 0?void 0:r===void 0?{ok:!1,text:`Voice list unavailable`}:r.some(t=>t.provider===e.provider&&t.voiceId===e.voice)?{ok:!0,text:`Voice saved`}:{ok:!1,text:`Voice missing`},d=[i,c,...u?[u]:[]],f=d.every(e=>e.ok);return(0,h.jsxs)(`li`,{className:`flex flex-wrap items-center justify-between gap-3 py-3`,children:[(0,h.jsx)(`span`,{className:`font-medium`,children:e.label}),(0,h.jsx)(`span`,{className:f?`text-lime`:`text-red`,children:f?`Ready`:d.filter(e=>!e.ok).map(e=>e.text).join(` · `)}),f?null:(0,h.jsx)(B,{variant:`ghost`,onClick:()=>s(e.field),children:`Edit ↗`})]},`${e.family}:${e.provider}`)})})]})}function aP({fields:e,onReveal:t,children:n}){let{document:r,review:i}=Ek(),{form:a}=r,{api:o}=I(),s=_(),c=s.getQueryData(vy(o).queryKey),l=s.getQueryData(xy(o).queryKey),u=s.getQueryData(yy(o).queryKey),d=s.getQueryData(UO),f=s.getQueryData(oN(a.llm.provider)),p=s.getQueryData(oN(a.audio.provider)),m=s.getQueryData(oN(a.images.provider)),g=a.sources.audio===`generate`,v=[`from_prompt`,`prompt_by_llm`].includes(a.sources.thumbnail),y=a.sources.article===`generate`||a.sources.thumbnail===`prompt_by_llm`||g&&[`intro`,`outro`].some(e=>l?.entries.some(t=>t.category===e&&t.name===a[e]&&t.mode===`llm`)),b=e=>c?.providers.find(t=>t.id===e)?.displayName??e,x=(e,n,r)=>(0,h.jsxs)(`div`,{className:`grid min-w-0 grid-cols-[90px_minmax(0,1fr)_auto] items-start gap-x-3 py-1 sm:grid-cols-[145px_minmax(0,1fr)_auto]`,children:[(0,h.jsx)(`dt`,{className:`break-words py-2 text-ink2`,children:e}),(0,h.jsx)(`dd`,{className:`min-w-0 whitespace-pre-wrap break-words py-2`,children:r||`Not selected`}),n?(0,h.jsx)(`dd`,{children:(0,h.jsx)(B,{variant:`ghost`,"aria-label":`Edit ${e}`,onClick:()=>t(n),children:`Edit ↗`})}):null]},n??e),S=a.chunking.mode===`words`||a.chunking.mode===`characters`?a.chunking.mode:null;return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(iP,{form:a,entries:l?.entries??[],providers:c?.providers,voices:u?.voices,textModels:f,audioModels:p,imageModels:m,onReveal:t}),(0,h.jsxs)(rP,{name:`Content`,children:[(0,h.jsxs)(`dl`,{className:`text-body`,children:[x(`Project`,`title`,a.title||`Untitled run`),x(`Article`,`sources.article`,PM[a.sources.article]),a.sources.article===`generate`?x(`Article prompt`,`articlePrompt`,a.articlePrompt):x(`Article text`,`provided.article`,`Your article`),a.sources.article===`generate`?x(`Research`,`sources.research`,PM[a.sources.research]):x(`Research`,null,`Off · Article is provided`),a.sources.research===`provide`&&a.sources.article===`generate`?x(`Research text`,`provided.research`,a.provided.research):null,y?(0,h.jsxs)(h.Fragment,{children:[x(`Text provider`,`llm.provider`,b(a.llm.provider)),x(`Text model`,`llm.model`,f?.models.find(e=>e.id===a.llm.model)?.name??a.llm.model),a.llm.thinking||f?.models.find(e=>e.id===a.llm.model)?.thinkingModes?.length?x(`Thinking`,`llm.thinking`,a.llm.thinking??`Model default`):null]}):null,e.map(({name:e})=>x(e,`values.${e}`,a.values[e]??``))]}),n]}),(0,h.jsx)(rP,{name:`Outputs`,children:(0,h.jsxs)(`dl`,{className:`text-body`,children:[x(`Narration`,`sources.audio`,PM[a.sources.audio]),g?(0,h.jsxs)(h.Fragment,{children:[x(`Audio provider`,`audio.provider`,b(a.audio.provider)),x(`Audio model`,`audio.model`,p?.models.find(e=>e.id===a.audio.model)?.name??a.audio.model),x(`Voice`,`audio.voice`,u?.voices.find(e=>e.provider===a.audio.provider&&e.voiceId===a.audio.voice)?.name??a.audio.voice),x(`Chunking`,S?`chunking.${S}`:`chunking.mode`,S?`Every ${a.chunking[S]||`(not entered)`} ${S}`:a.chunking.mode===`whole`?`Whole text`:`Paragraph`),x(`Intro`,`intro`,a.intro||`Off`),x(`Narration Preparation`,`narrationPrompt`,a.narrationPrompt?`${a.narrationPrompt} · One LLM call per narration chunk and entry`:`Off`),x(`Outro`,`outro`,a.outro||`Off`)]}):null,a.sources.audio===`provide`?x(`Narration file`,`provided.audio`,a.provided.audio?.name):null,x(`Images`,`sources.images`,PM[a.sources.images]),a.sources.images===`generate`||v?(0,h.jsxs)(h.Fragment,{children:[x(`Image provider`,`images.provider`,b(a.images.provider)),x(`Image model`,`images.model`,m?.models.find(e=>e.id===a.images.model)?.name??a.images.model)]}):null,a.sources.images===`generate`?a.imagePrompts.length?a.imagePrompts.map((e,t)=>x(e.name,`imagePrompts.${t}.number`,`${e.name} · ${e.number||`(not entered)`} images`)):x(`Image prompts`,`imagePrompts`,`None selected`):null,a.sources.images===`provide`?x(`Image files`,`provided.images`,a.provided.images.length?(0,h.jsx)(`ol`,{className:`list-inside list-decimal`,children:a.provided.images.map(e=>(0,h.jsx)(`li`,{children:e.name},e.attachmentId))}):`No files selected`):null,x(`Thumbnail`,`sources.thumbnail`,PM[a.sources.thumbnail]),v?x(`Thumbnail prompt`,`thumbnailPrompt`,a.thumbnailPrompt):null,a.sources.thumbnail===`provide`?x(`Thumbnail file`,`provided.thumbnail`,a.provided.thumbnail?.name):null,x(`Video`,`sources.video`,PM[a.sources.video])]})}),(0,h.jsxs)(rP,{name:`Checkpoints`,children:[(0,h.jsx)(ZN,{selected:a.checkpoints,reviewed:i.valid?i.receipt?.checkpointSet:void 0}),(0,h.jsx)(B,{variant:`ghost`,"aria-label":`Edit checkpoints`,onClick:()=>t(`checkpoints`),children:`Edit checkpoints ↗`})]}),(0,h.jsxs)(rP,{name:`Style`,children:[(0,h.jsxs)(`dl`,{className:`text-body`,children:[x(`Frame`,`format`,a.format),a.sources.audio===`off`?x(`Subtitles`,null,`Off · Audio is Off`):x(`Subtitles`,`subtitles.mode`,a.subtitles.mode),a.sources.audio!==`off`&&a.subtitles.mode!==`off`?(0,h.jsxs)(h.Fragment,{children:[x(`Subtitle font`,`subtitles.fontId`,d?.fonts.find(e=>e.id===a.subtitles.fontId)?.name??a.subtitles.fontId),x(`Subtitle size`,`subtitles.fontSize`,`${a.subtitles.fontSize||`(not entered)`} px`),x(`Subtitle position`,`subtitles.position`,a.subtitles.position)]}):null]}),a.sources.audio!==`off`&&a.subtitles.mode===`files`?(0,h.jsx)(`p`,{className:`mt-3 text-small text-ink2`,children:`Font, size and position apply to burned captions. SRT/VTT players choose their own styling.`}):null]})]})}function oP({fields:e,errors:t,onReveal:n,problem:r}){let i=Ek(),{document:a,review:o}=i,s=a.form,c=(0,m.useId)(),l=yk(a,i.view),u=o.starting||o.uncertain;(0,m.useEffect)(()=>{i.reviewDraft()},[i.reviewDraft]);let d=o.valid?o.receipt?.runs??[]:[];return(0,h.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-6 py-6`,children:[(0,h.jsx)(`p`,{className:`text-body text-ink2`,children:`Check your setup and estimated costs before starting.`}),t.length?(0,h.jsx)(`ul`,{"aria-label":`Setup errors`,className:`text-small text-red`,children:t.map(e=>(0,h.jsx)(`li`,{children:(0,h.jsx)(B,{variant:`ghost`,onClick:()=>n(e.field),children:e.message})},`${e.field}-${e.message}`))}):null,l?(0,h.jsx)(B,{variant:`ghost`,onClick:()=>n(l),children:`Wait for uploads to finish before Start`}):null,o.error?(0,h.jsx)(`p`,{role:`alert`,className:`text-body text-red`,children:o.error}):null,(0,h.jsx)(aP,{fields:e,onReveal:n,children:(0,h.jsxs)(`details`,{className:`mt-5 border-t border-line py-3`,children:[(0,h.jsx)(`summary`,{className:`cursor-pointer text-small`,children:s.sources.article===`provide`?`Read the supplied article and resolved prompts`:`Read the resolved prompt`}),d.length?d.map((e,t)=>(0,h.jsxs)(`div`,{className:`mt-4`,children:[(0,h.jsx)(`h4`,{className:`font-medium`,children:e.draft.title}),e.draft.sources.article===`provide`?(0,h.jsx)(`p`,{className:`mt-3 whitespace-pre-wrap break-words text-body`,children:e.draft.provided.article}):null,Object.entries(e.rendered).map(([e,t])=>(0,h.jsxs)(`div`,{className:`mt-3`,children:[(0,h.jsx)(`h5`,{className:`text-small text-ink2`,children:e}),(0,h.jsx)(`p`,{className:`whitespace-pre-wrap break-words text-body`,children:t})]},e))]},a.variants[t-1]?.id??i.activeId)):(0,h.jsx)(`p`,{className:`mt-3 text-small text-ink2`,children:`Refresh review to read the exact resolved inputs.`})]})}),(0,h.jsx)(`fieldset`,{disabled:u,className:`min-w-0`,children:(0,h.jsx)(QN,{fields:e,items:a.variants.map(({id:e,...t})=>({...t,key:e})),title:s.title,values:s.values,problem:r,onChange:e=>i.edit({...a,variants:e.map(({key:e,...t})=>({...t,id:e}))})})}),(0,h.jsxs)(`div`,{className:`flex flex-col gap-4 border-t border-line pt-5`,children:[(0,h.jsx)(`h3`,{className:`font-semibold`,children:`Estimated cost`}),(0,h.jsxs)(`label`,{htmlFor:c,className:`text-body`,children:[`Expected article words per video`,(0,h.jsx)(cM,{id:c,"data-play-field":`expectedWords`,type:`number`,min:1,max:1e5,value:a.expectedWords,disabled:u,onChange:e=>i.edit({...a,expectedWords:e.target.value})})]}),(0,h.jsx)(`p`,{className:`text-small text-ink2`,children:`Estimated provider charges in USD. Actual usage can differ. This estimate does not cap spending.`}),o.pending?(0,h.jsx)(`p`,{role:`status`,children:`Calculating estimate…`}):null,o.valid&&o.receipt?(0,h.jsx)($N,{estimates:o.receipt.estimates}):(0,h.jsx)(`p`,{className:`text-small text-ink2`,children:`Review needs refreshing before Start.`}),(0,h.jsx)(B,{disabled:o.pending||u||!!l,onClick:()=>{i.reviewDraft()},children:`Refresh review`})]}),(0,h.jsxs)(`div`,{className:`flex justify-between gap-3 border-t border-line pt-5`,children:[(0,h.jsx)(B,{variant:`ghost`,onClick:()=>{i.navigate(`style`)},children:`← Style`}),(0,h.jsx)(B,{variant:`play`,"data-tour":`play-start`,disabled:o.starting||!o.uncertain&&(!o.valid||o.pending||t.length>0||!!l),onClick:()=>{i.startRun()},children:o.starting?`Starting…`:o.uncertain?`Check Start result`:a.variants.length?`Queue ${a.variants.length+1} videos`:`Start run`})]})]})}var sP=[{id:`content`,label:`Content`,description:`Article and keywords`},{id:`outputs`,label:`Outputs`,description:`Voice and images`},{id:`style`,label:`Style`,description:`Frame and captions`},{id:`review`,label:`Review`,description:`Cost and start`}];function cP({section:e,onNavigate:t}){return(0,h.jsx)(`nav`,{"aria-label":`Run setup`,className:`mb-7 grid grid-cols-2 border-b border-line min-[700px]:grid-cols-4`,children:sP.map((n,r)=>(0,h.jsxs)(`div`,{className:`border-b-2 py-4 ${e===n.id?`border-focus`:`border-transparent`}`,children:[(0,h.jsxs)(`button`,{type:`button`,"aria-current":e===n.id?`step`:void 0,onClick:()=>t(n.id),className:`min-h-11 w-full text-left font-semibold ${e===n.id?`text-run-text`:`text-ink`}`,children:[(0,h.jsx)(`span`,{"aria-hidden":`true`,className:`mr-3 inline-flex size-7 items-center justify-center rounded-full border text-small ${e===n.id?`border-accent bg-accent text-accent-ink`:`border-line`}`,children:r+1}),n.label]}),(0,h.jsx)(`p`,{className:`pl-10 text-small text-ink3`,children:n.description})]},n.id))})}function lP({form:e,blocker:t,onReveal:n}){let r=[[`Article`,e.sources.article,e.sources.article===`provide`?`provided.article`:`articlePrompt`],[`Audio`,e.sources.audio,`sources.audio`],...e.sources.audio===`generate`&&e.narrationPrompt?[[`Narration Preparation`,e.narrationPrompt,`narrationPrompt`]]:[],[`Images`,e.sources.images===`generate`?`${e.imagePrompts.reduce((e,t)=>e+t.number,0)} images`:e.sources.images,`sources.images`],[`Export`,e.sources.video===`generate`?e.sources.audio===`off`?`Silent MP4`:`MP4`:e.sources.audio===`off`?`Individual outputs`:`Combined WAV`,`sources.video`]];return(0,h.jsxs)(`aside`,{"aria-label":`Setup summary`,className:`min-w-0`,children:[(0,h.jsx)(`h2`,{className:`mb-3 font-semibold`,children:`This run`}),(0,h.jsx)(`dl`,{className:`divide-y divide-line`,children:r.map(([e,t,r])=>(0,h.jsxs)(`div`,{className:`flex items-center justify-between gap-3 py-2 text-small`,children:[(0,h.jsx)(`dt`,{className:`text-ink3`,children:e}),(0,h.jsx)(`dd`,{children:(0,h.jsx)(B,{variant:`ghost`,onClick:()=>n(r),"aria-label":`Edit ${e}`,children:t})})]},e))}),t?(0,h.jsxs)(`div`,{className:`mt-4 text-small text-ink2`,children:[(0,h.jsx)(`p`,{children:t.hint}),(0,h.jsx)(B,{variant:`ghost`,onClick:()=>n(t.field),children:`Fix setup`})]}):null,(0,h.jsx)(`p`,{className:`mt-4 text-small text-ink3`,children:`Nothing starts until you review the costs and choose Start run.`})]})}function uP(e){return e.upload?(0,h.jsx)(fP,{value:e.value,onPick:e.onPick,upload:e.upload}):(0,h.jsx)(dP,{...e})}function dP({value:e,onPick:t,onUploading:n}){let{api:r}=I(),i=_(),a=it({mutationFn:e=>GO(r,e),onSuccess:({font:e})=>{i.setQueryData(UO,t=>({fonts:[...(t?.fonts??[]).filter(t=>t.id!==e.id),e]})),i.invalidateQueries({queryKey:UO})}}),o=a.isPending,s=(0,m.useRef)(t);s.current=t;let c=(0,m.useRef)(n);return c.current=n,(0,m.useEffect)(()=>{c.current(o)},[o]),(0,m.useEffect)(()=>()=>c.current(!1),[]),(0,h.jsx)(fP,{value:e,onPick:t,upload:{pending:o,error:a.error?.message,pick:e=>a.mutate(e,{onSuccess:({font:e})=>s.current(e.id)})}})}function fP({value:e,onPick:t,upload:n}){let{api:r}=I(),i=(0,m.useId)(),a=(0,m.useId)(),o=nt({queryKey:UO,queryFn:()=>WO(r),staleTime:6e4}),s=n.pending,c=o.data?.fonts??[],l=e!=="default"&&!c.some(t=>t.id===e);return(0,h.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3`,children:[(0,h.jsxs)(`div`,{className:`min-w-0 basis-full`,children:[(0,h.jsx)(oM,{htmlFor:i,className:`mb-1`,children:`Subtitle font`}),(0,h.jsxs)(`select`,{id:i,"data-play-field":`subtitles.fontId`,value:e,disabled:s,onChange:e=>t(e.target.value),className:`h-8 w-full rounded-control border border-line2 bg-panel2 px-[10px] text-small text-ink`,children:[c.some(e=>e.id==="default")?null:(0,h.jsx)(`option`,{value:`default`,children:`Default font · bundled`}),l?(0,h.jsxs)(`option`,{value:e,children:[e,` · saved font`]}):null,c.map(e=>(0,h.jsxs)(`option`,{value:e.id,children:[e.name,` · `,e.source]},e.id))]})]}),(0,h.jsxs)(`div`,{className:`min-w-0 basis-full`,children:[(0,h.jsx)(oM,{htmlFor:a,className:`mb-1`,children:`Upload font (.ttf or .otf)`}),(0,h.jsx)(`input`,{id:a,"data-play-field":`subtitles.fontUpload`,type:`file`,accept:`.ttf,.otf,font/ttf,font/otf`,disabled:s,className:`w-full text-small text-ink2 file:mr-2 file:rounded-control file:border file:border-line2 file:bg-panel2 file:px-2 file:py-1 file:text-ink`,onChange:e=>{let t=e.target.files?.[0];e.target.value=``,t&&n.pick(t)}})]})]}),s?(0,h.jsx)(`p`,{role:`status`,className:`text-small text-ink2`,children:`Uploading font…`}):null,n.error?(0,h.jsx)(`p`,{role:`alert`,className:`text-small text-red`,children:n.error}):null,l&&o.data?(0,h.jsx)(`p`,{role:`alert`,children:`Saved font is unavailable. Choose another font or upload it again.`}):null,o.error?(0,h.jsxs)(`p`,{role:`alert`,className:`text-small text-red`,children:[`Could not load fonts. `,o.error.message]}):null]})}function pP({value:e,format:t=`16:9`,audioEnabled:n,videoEnabled:r,disabled:i=!1,onChange:a,onUploading:o,problem:s,session:c,fontUpload:l,showPreview:u=!0,illustratedPositions:d=!1,rawFontSize:f}){let p=(0,m.useId)(),g=(0,m.useId)(),_=(0,m.useId)(),v=(0,m.useId)(),[y,b]=(0,m.useState)(!1),x=s?.(`subtitles.fontId`),S=s?.(`subtitles.fontSize`),C=s?.(`subtitles.mode`)??s?.(`subtitles`);return(0,h.jsxs)(`section`,{className:`flex min-w-0 flex-col gap-3`,"aria-label":`Subtitles`,children:[(0,h.jsxs)(`fieldset`,{disabled:i||!n,className:`flex min-w-0 flex-col gap-3 disabled:opacity-60`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3`,children:[(0,h.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,h.jsx)(oM,{htmlFor:p,className:`mb-1`,children:`Subtitles`}),(0,h.jsxs)(`select`,{id:p,"data-play-field":`subtitles.mode`,value:n?e.mode:`off`,disabled:l?.pending??y,"aria-describedby":_,"aria-invalid":C!==void 0,onChange:t=>a({...e,mode:t.target.value}),className:`h-8 w-full rounded-control border border-line2 bg-panel2 px-[10px] text-small text-ink`,children:[(0,h.jsx)(`option`,{value:`off`,children:`Off`}),(0,h.jsx)(`option`,{value:`files`,children:`Subtitle files (.srt + .vtt)`}),(0,h.jsx)(`option`,{value:`burn-in`,disabled:!r,children:`Burn into video + files`})]})]}),(0,h.jsx)(`span`,{className:`pb-1 text-label text-ink3`,children:`English · local · no paid API`})]}),e.mode!==`off`&&n?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`p`,{className:`text-small text-ink2`,children:`Timed from your narration on this computer. First use downloads an approximately 95 MB speech model. Review the subtitles before publishing.`}),(0,h.jsxs)(`div`,{className:`grid items-start gap-5`,style:{gridTemplateColumns:`repeat(auto-fit, minmax(min(100%, 240px), 1fr))`},children:[(0,h.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-4`,children:[(0,h.jsx)(uP,{...l?{upload:l}:{},value:e.fontId,onPick:t=>c?c.selectFont(t):a({...e,fontId:t}),onUploading:e=>{b(e),o?.(e)}}),(0,h.jsxs)(`div`,{className:d?`w-full`:`max-w-[180px]`,children:[(0,h.jsx)(oM,{htmlFor:g,className:`mb-1`,children:`Subtitle font size`}),(0,h.jsxs)(`div`,{className:`flex items-center gap-5`,children:[d?(0,h.jsx)(`input`,{"aria-label":`Subtitle font size slider`,type:`range`,min:16,max:120,step:1,value:Math.max(16,Math.min(120,Number.isFinite(e.fontSize)?e.fontSize:48)),className:`min-w-0 flex-1 accent-accent`,onChange:t=>f?f.onChange(t.target.value):a({...e,fontSize:Number(t.target.value)})}):null,(0,h.jsx)(cM,{className:d?`w-20`:void 0,id:g,"data-play-field":`subtitles.fontSize`,type:`number`,min:16,max:120,step:1,value:f?.value??e.fontSize,"aria-invalid":!NM(e)||S!==void 0,onChange:t=>f?f.onChange(t.target.value):a({...e,fontSize:Number(t.target.value)})})]}),!NM(e)||S?(0,h.jsx)(`p`,{role:`alert`,className:`mt-1 text-label text-red`,children:S??`Choose a whole font size from 16 to 120.`}):null]}),(0,h.jsxs)(`div`,{children:[(0,h.jsx)(oM,{htmlFor:d?void 0:v,id:`${v}-label`,className:`mb-1`,children:`Subtitle position`}),d?(0,h.jsx)(Hj,{type:`single`,"aria-labelledby":`${v}-label`,value:e.position??`bottom`,onValueChange:t=>{let n=QD.find(e=>e===t);n&&a({...e,position:n})},className:`grid w-full grid-cols-5 gap-2 overflow-visible border-0`,children:QD.map((t,n)=>(0,h.jsxs)(Uj,{value:t,"aria-label":t,"data-play-field":(e.position??`bottom`)===t?`subtitles.position`:void 0,className:`flex min-w-0 flex-col items-center gap-2 rounded-control border border-line2 bg-panel px-1 py-3 text-[10px] last:border-r data-[state=on]:border-focus data-[state=on]:text-run-text data-[state=on]:shadow-none`,children:[(0,h.jsx)(`span`,{"aria-hidden":`true`,className:`relative block h-11 w-7 rounded-[2px] border border-current`,children:(0,h.jsx)(`span`,{className:`absolute left-1 right-1 h-[3px] bg-current`,style:{top:`${8+n*20}%`}})}),(0,h.jsxs)(`span`,{children:[t[0]?.toUpperCase(),t.slice(1)]})]},t))}):(0,h.jsx)(`select`,{id:v,"data-play-field":`subtitles.position`,value:e.position??`bottom`,onChange:t=>{let n=QD.find(e=>e===t.target.value);n&&a({...e,position:n})},className:`h-8 w-full rounded-control border border-line2 bg-panel2 px-[10px] text-small text-ink`,children:QD.map(e=>(0,h.jsxs)(`option`,{value:e,children:[e[0]?.toUpperCase(),e.slice(1)]},e))})]})]}),u?(0,h.jsx)(qN,{value:e,format:t,...c?{sample:c.previewText}:{}}):null]}),c?.fontUpload&&!c.fontUploading?(0,h.jsxs)(`p`,{role:`alert`,children:[`Reattach `,c.fontUpload.name,`, or select a font.`]}):null,x?(0,h.jsx)(`p`,{role:`alert`,className:`text-small text-red`,children:x}):null,e.mode===`files`?(0,h.jsx)(`p`,{className:`text-label text-ink3`,children:`Font, size and position apply to burned captions. SRT/VTT players choose their own styling.`}):null]}):null]}),c?.fontUpload&&(e.mode===`off`||!n)?(0,h.jsxs)(`div`,{className:`flex flex-col items-start gap-3`,children:[(0,h.jsx)(`p`,{role:c.fontUploading?`status`:`alert`,className:`text-small text-ink2`,children:c.fontUploading?`Uploading ${c.fontUpload.name}…`:`Unfinished font upload: ${c.fontUpload.name}`}),l?.error?(0,h.jsx)(`p`,{role:`alert`,className:`text-small text-red`,children:l.error}):null,(0,h.jsx)(B,{"data-play-field":`subtitles.fontUpload`,disabled:i,onClick:()=>c.selectFont(e.fontId),children:`Keep current font`})]}):null,C?(0,h.jsx)(`p`,{role:`alert`,className:`text-small text-red`,children:C}):null,(0,h.jsx)(`p`,{id:_,className:`text-small text-ink2`,children:n?r?`Optional: download subtitles separately or keep them visible in the video.`:`Audio exports support separate subtitle files. Enable Video to burn captions into an MP4.`:`Turn Audio on to add subtitles.`})]})}function mP({value:e,onPick:t}){let n=(0,m.useId)();return(0,h.jsxs)(`div`,{className:`w-full`,children:[(0,h.jsx)(oM,{id:n,className:`mb-2`,children:`Frame format`}),(0,h.jsx)(Hj,{type:`single`,value:e,"aria-labelledby":n,className:`w-full max-w-[400px] gap-3 overflow-visible border-0`,onValueChange:e=>{(e===`16:9`||e===`9:16`)&&t(e)},children:[`16:9`,`9:16`].map(t=>(0,h.jsxs)(Uj,{value:t,"data-play-field":e===t?`format`:void 0,"aria-label":t,className:`flex h-28 min-w-0 flex-1 items-center justify-center gap-4 rounded-control border border-line2 bg-panel p-3 last:border-r data-[state=on]:border-focus data-[state=on]:shadow-none`,children:[(0,h.jsx)(`span`,{className:`flex h-12 items-center justify-center`,"aria-hidden":`true`,children:(0,h.jsx)(`span`,{"data-format-shape":t,className:`block rounded-[2px] border-2 border-current`,style:{width:t===`16:9`?64:27,aspectRatio:t===`16:9`?`16 / 9`:`9 / 16`}})}),(0,h.jsxs)(`span`,{className:`text-left`,children:[(0,h.jsx)(`span`,{className:`block text-body font-semibold`,children:t}),(0,h.jsx)(`span`,{className:`text-label text-ink3`,children:t===`16:9`?`Landscape`:`Portrait`})]})]},t))})]})}function hP({problem:e}){let t=Ek(),{document:n}=t,{form:r}=n,i=(0,m.useId)(),a=e=>t.edit({...n,form:{...r,subtitles:{...e,fontSize:r.subtitles.fontSize}}});return(0,h.jsxs)(`div`,{"data-tour":`play-subtitles`,className:`flex min-w-0 flex-col gap-6 py-6`,children:[(0,h.jsx)(`p`,{className:`text-body text-ink2`,children:`See frame and caption changes in the preview as you go.`}),(0,h.jsx)(mP,{value:r.format,onPick:e=>t.edit({...n,form:{...r,format:e}})}),(0,h.jsx)(`div`,{className:`border-t border-line pt-6`,children:(0,h.jsx)(pP,{showPreview:!1,illustratedPositions:!0,fontUpload:t.fontUpload,session:{previewText:n.previewText,fontUploading:t.fontUploading,fontUpload:n.fontUpload,selectFont:t.selectFont,uploadSubtitleFont:t.uploadSubtitleFont},value:{...r.subtitles,fontSize:Number(r.subtitles.fontSize)},rawFontSize:{value:r.subtitles.fontSize,onChange:e=>t.edit({...n,form:{...r,subtitles:{...r.subtitles,fontSize:e}}})},format:r.format,audioEnabled:r.sources.audio!==`off`,videoEnabled:r.sources.video===`generate`&&r.sources.images!==`off`,onChange:a,problem:e})}),(0,h.jsxs)(`div`,{className:`border-t border-line pt-6`,children:[(0,h.jsx)(oM,{htmlFor:i,className:`mb-2`,children:`Preview text`}),(0,h.jsx)(cM,{id:i,value:n.previewText,onChange:e=>t.edit({...n,previewText:e.target.value})}),(0,h.jsx)(`p`,{className:`mt-2 text-small text-ink3`,children:`Just a sample. Your actual captions come from the narration.`})]})]})}function gP(e,t,n){let r=e?.prompts??[],i=e?.entries??[];return{prompts:[...r,...t.filter(e=>!r.some(t=>t.kind===e.kind&&t.name.toLowerCase()===e.name.toLowerCase()))],entries:[...i,...n.filter(e=>!i.some(t=>t.category===e.category&&t.name.toLowerCase()===e.name.toLowerCase()))]}}function _P(){let e=Gi();return(0,h.jsx)(vP,{onCreated:t=>{e({to:`/projects/$projectId`,params:{projectId:t}})}})}function vP({onCreated:e}){let{api:t}=I(),n=JN(),r=PA(),i=nt(vy(t)),a=nt(by(t)),o=nt(xy(t)),s=nt(yy(t)),c=nt(Sy(t)),[l,u]=Ak(),d=Ek(),f=gP(d.document.librarySnapshot,a.data?.prompts??[],o.data?.entries??[]),p=d.document.variants.map(({id:e,...t})=>({...t,key:e})),g=d.fontUploading||d.document.fontUpload!==null,_=d.review.fields,[v,y]=(0,m.useState)(new Set),b=(0,m.useRef)(null),x=(0,m.useRef)(null),S=Gi(),C=(0,m.useRef)(d.activeId);(0,m.useLayoutEffect)(()=>{C.current!==d.activeId&&(C.current=d.activeId,y(new Set))},[d.activeId]);let w=(0,m.useRef)(null);(0,m.useLayoutEffect)(()=>{let e=d.reveal;if(e||(w.current=null),e&&e.sequence!==w.current&&e.section===d.section&&b.current){if(w.current=e.sequence,e.field){let t=[...b.current.querySelectorAll(`[data-play-field]`)].find(t=>t.dataset.playField===e.field)?.parentElement;for(;t&&t!==b.current;)t instanceof HTMLDetailsElement&&(t.open=!0),t=t.parentElement;if(UN(b.current,e.field))return}x.current?.focus()}},[d.reveal,d.section]);let T=e=>{let t=tN(e,l)??WN(e,l,p);y(n=>new Set([...n,e,t.field])),d.navigate(t.section,t.field)},E=async e=>{await d.flush()&&(e===`/prompts`?await S({to:`/prompts/new`,search:{kind:`article`}}):await S({to:e}))},D=e=>{u(t=>{let n={...t,...e};return{...n,subtitles:MM(n.subtitles,n.sources)}}),d.invalidateReview(!0)},{fields:O,result:ee,blocker:k}=WM({form:l,prompts:f.prompts,entries:f.entries,silenceGapSeconds:c.data?.silenceGapSeconds??3}),A=g?{field:`subtitles.fontUpload`,hint:`Wait for the subtitle font upload to finish to play`}:k;(0,m.useEffect)(()=>{if(!d.review.created)return;let t=d.takeCreated()?.projectIds[0];t&&(r({type:`project-created`,id:t}),e(t))},[d.review.created,d.takeCreated,r,e]);let j=ee.ok?_:[...ee.fields,..._],M=(...e)=>!j.some(t=>e.some(e=>t.field===e||t.field.startsWith(`${e}.`))),N=(e,t)=>f.prompts.some(n=>n.kind===e&&n.name===t),P=e=>e?.file!==void 0&&e.error===void 0;NA({playArticleReady:M(`sources.article`,`articlePrompt`,`provided.article`)&&(l.sources.article===`provide`||N(`article`,l.articlePrompt)),playAudioReady:l.sources.audio===`off`||M(`sources.audio`,`audio`,`provided.audio`)&&(l.sources.audio!==`provide`||P(l.provided.audio)),playImagesReady:l.sources.images===`off`||M(`sources.images`,`images`,`imagePrompts`,`provided.images`)&&(l.sources.images===`provide`?l.provided.images.every(P):l.imagePrompts.every(e=>N(`image`,e.name))),playVideoReady:M(`sources.video`),playSubtitlesReady:M(`subtitles`)&&!g,playOptionsReady:M(`title`,`format`,`llm`,`intro`,`outro`),playHasKeywords:O.length>0,playKeywordsReady:M(`values`),playReady:A===void 0&&!d.review.starting});let F=e=>{let t=(tN(e,l)??WN(e,l,p)).field;return j.find(n=>(tN(n.field,l)??WN(n.field,l,p)).field===t&&(_.includes(n)||v.has(e)||v.has(t)))?.message},te=()=>{d.navigate(`review`)},ne=e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),te())},re=(e,t)=>{d.invalidateReview(!0),d.attach(e,t)},ie=(e,t)=>{u(n=>({...n,provided:e===`images`?{...n.provided,images:n.provided.images.filter(e=>e.key!==t)}:e===`audio`?{...n.provided,audio:void 0}:{...n.provided,thumbnail:void 0}}))},ae=[i,a,o,s,c].find(e=>e.error!==null)?.error?.message,oe={form:l,providers:i.data?.providers??[],prompts:f.prompts,voices:s.data?.voices??[],silenceGapSeconds:c.data?.silenceGapSeconds??3,problem:F,update:D,onPickFiles:re,onRemoveFile:ie,onReattachFile:(e,t,n)=>{d.attach(e,[n],t)}};return(0,h.jsxs)(`div`,{ref:b,onKeyDown:ne,onBlurCapture:e=>{let t=e.target.dataset.playField;t&&y(e=>new Set([...e,t]))},"data-play-grid":`true`,className:`mx-auto max-w-[1320px] pb-[calc(4rem+env(safe-area-inset-bottom))] [&_input:not([type=checkbox])]:min-h-10 [&_select]:min-h-10 [&_button]:min-h-10 [&_summary]:min-h-10 max-[1099px]:[&_button]:min-h-11 max-[1099px]:[&_input:not([type=checkbox])]:min-h-11 max-[1099px]:[&_select]:min-h-11 max-[1099px]:[&_summary]:min-h-11`,children:[(0,h.jsxs)(`header`,{className:`mb-6 flex flex-wrap items-start justify-between gap-4`,children:[(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`h1`,{className:`mb-1 text-[36px] font-bold tracking-[-0.01em]`,children:`New run`}),(0,h.jsx)(`p`,{className:`text-body text-ink2`,children:`Create the article, choose the outputs, then review.`})]}),(0,h.jsx)(HN,{})]}),ae?(0,h.jsx)(`p`,{className:`mb-4 text-body text-red`,children:ae}):null,(0,h.jsx)(cP,{section:d.section,onNavigate:e=>{d.navigate(e)}}),(0,h.jsxs)(`div`,{className:`grid min-w-0 grid-cols-1 items-start gap-7 min-[1100px]:grid-cols-[minmax(0,1fr)_360px]`,children:[(0,h.jsxs)(`section`,{"data-tour":d.section===`content`?`play-options`:void 0,className:`min-w-0`,children:[(0,h.jsx)(`h2`,{ref:x,tabIndex:-1,className:`text-xl font-semibold`,children:d.section===`style`?`Make it look like yours.`:sP.find(e=>e.id===d.section)?.label}),n?null:d.section===`style`?(0,h.jsx)(`div`,{className:`mt-5`,children:(0,h.jsx)(YN,{})}):(0,h.jsxs)(`details`,{className:`my-5 rounded-control border border-line p-3`,children:[(0,h.jsxs)(`summary`,{className:`min-h-11 cursor-pointer text-small font-semibold`,children:[`Preview · `,l.format]}),(0,h.jsx)(YN,{})]}),d.section===`content`?(0,h.jsx)(VN,{...oe,fields:O,entries:f.entries,onLibrary:e=>{E(e)}}):null,d.section===`outputs`?(0,h.jsx)(XN,{...oe,entries:f.entries,missingKeyword:j.find(e=>e.field.startsWith(`values.`))?.field,onKeyword:T,onSettings:()=>{E(`/settings`)}}):null,d.section===`style`?(0,h.jsx)(hP,{problem:F}):null,d.section===`review`?(0,h.jsx)(oP,{fields:O,errors:j,problem:F,onReveal:T}):(0,h.jsx)(`div`,{className:`mt-8 flex justify-end border-t border-line py-6`,children:(0,h.jsxs)(B,{variant:`play`,onClick:()=>{let e=sP[sP.findIndex(e=>e.id===d.section)+1];e&&d.navigate(e.id)},children:[`Continue to`,` `,sP[sP.findIndex(e=>e.id===d.section)+1]?.label,` `,`→`]})})]}),(0,h.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-6 min-[1100px]:sticky min-[1100px]:top-6`,children:[n?(0,h.jsx)(YN,{}):null,(0,h.jsx)(lP,{form:l,blocker:A,onReveal:T})]})]})]})}function yP(){let{api:e}=I(),t=nt({queryKey:[`batch-queue`],queryFn:async()=>eo(await e.fetch(`${e.origin}/api/projects/queue`)),refetchInterval:2e3,retry:!1}),n=nt(my(e));return t.data?.queue.length?(0,h.jsxs)(`details`,{className:`mb-4 rounded-panel border border-line bg-panel p-3`,open:!0,children:[(0,h.jsxs)(`summary`,{className:`cursor-pointer text-body font-semibold`,children:[`Video queue · `,t.data.queue.length,` remaining`]}),(0,h.jsx)(`p`,{className:`mt-1 text-small text-ink2`,children:`One batch video runs at a time. Pause holds the queue; failure or cancellation advances it.`}),(0,h.jsx)(`ol`,{className:`mt-2 max-h-40 overflow-y-auto`,children:t.data.queue.map((e,t)=>{let r=n.data?.projects.find(t=>t.id===e.projectId);return(0,h.jsxs)(`li`,{className:`flex justify-between gap-3 py-1 text-small`,children:[(0,h.jsxs)(sa,{className:`truncate underline`,to:`/projects/$projectId`,params:{projectId:e.projectId},children:[t+1,`. `,r?.title??`Video`]}),(0,h.jsx)(`span`,{className:`shrink-0 text-ink2`,children:r?.status===`paused`?`Paused`:e.state===`active`?`Active`:`Queued`})]},e.projectId)})})]}):null}function bP(e,t){return e.filter(e=>e.stageKind===t.kind)}function xP(e,t){return e.find(e=>e.role===t)}var SP={research:`Replaces the notes, then re-runs the enabled stages below.`,article:`Replaces the article, then re-runs the enabled stages below.`,audio:`Replaces the narration and refreshes the final audio or video export.`,images:`Replaces every image in this run and re-renders video when enabled.`,thumbnail:`Replaces the thumbnail.`,video:`Replaces the final audio or video export.`};function CP(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:SP[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 wP=(0,m.createContext)(!1);function TP({action:e,run:t,disabled:n=!1,pending:r=!1,variant:i=`outline`,className:a,children:o}){let[s,c]=(0,m.useState)(!1),l=CP(e);return(0,m.useContext)(wP)&&e.kind!==`cancel`?null:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(B,{type:`button`,variant:i,disabled:n,className:z(i===`ghost`?`px-2 text-small`:void 0,a),onClick:()=>{c(!0)},children:o}),(0,h.jsx)(Nj,{open:s,title:l.title,consequence:l.consequence,verb:l.verb,dismiss:l.dismiss,pending:r,onConfirm:()=>{c(!1),t()},onCancel:()=>{c(!1)}})]})}function EP(e){let{api:t}=I();return nt({...hy(t,e),enabled:!1,select:e=>e.revisionId??null}).data??null}var DP=(e,t=null)=>[`live-writing`,e,t];function OP(e,t){let n=e=>e.callId===t.callId&&e.revisionId===t.revisionId&&e.workId===t.workId,r=e.find(n),i=(t.reset?t.text:`${r?.text??``}${t.text}`).slice(-65536),a={...t.revisionId===void 0?{}:{revisionId:t.revisionId},...t.workId===void 0?{}:{workId:t.workId},...t.workPieceId===void 0?{}:{workPieceId:t.workPieceId},stage:t.stage,callId:t.callId,...t.label===void 0?{}:{label:t.label},text:i};return(r?e.map(e=>n(e)?a:e):[...e,a]).slice(-24)}function kP({projectId:e,stage:t}){let n=(nt({queryKey:DP(e,EP(e)),queryFn:()=>[],enabled:!1}).data??[]).filter(e=>e.stage===t),[r,i]=(0,m.useState)(),a=n.find(e=>e.callId===r)??n.at(-1),[o,s]=(0,m.useState)(!0),c=(0,m.useRef)(null);return(0,m.useEffect)(()=>{a?.text&&o&&c.current&&(c.current.scrollTop=c.current.scrollHeight)},[o,a?.text]),n.length===0&&t!==`research`&&t!==`article`?null:(0,h.jsxs)(`div`,{className:`mx-5 mt-5 rounded-control border border-line2 bg-panel2`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 border-b border-line px-4 py-3`,children:[(0,h.jsx)(`span`,{className:`text-small font-semibold text-run-text`,children:`Live writing`}),n.length>1?(0,h.jsx)(aN,{"aria-label":`Live writing task`,value:a?.callId??``,onChange:e=>i(e.target.value),className:`max-w-[280px]`,children:n.map((e,t)=>(0,h.jsxs)(`option`,{value:e.callId,children:[e.label??`Writing`,` · `,t+1]},e.callId))}):null,(0,h.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-label text-ink2`,children:[(0,h.jsx)(`input`,{type:`checkbox`,checked:o,onChange:e=>s(e.target.checked)}),`Follow output`]})]}),(0,h.jsx)(`section`,{ref:c,"aria-label":`Live writing preview`,tabIndex:0,className:`max-h-[360px] min-h-32 overflow-auto whitespace-pre-wrap break-words p-4 font-sans text-small leading-relaxed text-ink2`,children:a?.text||`Waiting for the provider's first text…`}),(0,h.jsx)(`p`,{className:`border-t border-line px-4 py-2 text-label text-ink3`,children:`Live preview. The complete output is saved when this stage finishes.`})]})}function AP(e){let t=e.role.replaceAll(`_`,`-`);return(e.role===`narration_txt`||e.role===`tts_script`)&&e.meta.segment!==void 0?`${t}-${e.meta.segment}`:e.role===`instructions`?`${e.stageKind}-${t}`:e.role===`image`&&e.meta.index!==void 0?`${t}-${String(e.meta.index)}`:t}function jP(e,t){let n=t||{};return(e[e.length-1]===``?[...e,``]:e).join((n.padRight?` `:``)+`,`+(n.padLeft===!1?``:` `)).trim()}var MP=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,NP=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,PP={};function FP(e,t){return((t||PP).jsx?NP:MP).test(e)}var IP=/[ \t\n\f\r]/g;function LP(e){return typeof e==`object`?e.type===`text`&&RP(e.value):RP(e)}function RP(e){return e.replace(IP,``)===``}var zP=class{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}};zP.prototype.normal={},zP.prototype.property={},zP.prototype.space=void 0;function BP(e,t){let n={},r={};for(let t of e)Object.assign(n,t.property),Object.assign(r,t.normal);return new zP(n,r,t)}function VP(e){return e.toLowerCase()}var HP=class{constructor(e,t){this.attribute=t,this.property=e}};HP.prototype.attribute=``,HP.prototype.booleanish=!1,HP.prototype.boolean=!1,HP.prototype.commaOrSpaceSeparated=!1,HP.prototype.commaSeparated=!1,HP.prototype.defined=!1,HP.prototype.mustUseProperty=!1,HP.prototype.number=!1,HP.prototype.overloadedBoolean=!1,HP.prototype.property=``,HP.prototype.spaceSeparated=!1,HP.prototype.space=void 0;var UP=s({boolean:()=>GP,booleanish:()=>KP,commaOrSpaceSeparated:()=>XP,commaSeparated:()=>YP,number:()=>J,overloadedBoolean:()=>qP,spaceSeparated:()=>JP}),WP=0,GP=ZP(),KP=ZP(),qP=ZP(),J=ZP(),JP=ZP(),YP=ZP(),XP=ZP();function ZP(){return 2**++WP}var QP=Object.keys(UP),$P=class extends HP{constructor(e,t,n,r){let i=-1;if(super(e,t),eF(this,`space`,r),typeof n==`number`)for(;++i<QP.length;){let e=QP[i];eF(this,QP[i],(n&UP[e])===UP[e])}}};$P.prototype.defined=!0;function eF(e,t,n){n&&(e[t]=n)}function tF(e){let t={},n={};for(let[r,i]of Object.entries(e.properties)){let a=new $P(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(a.mustUseProperty=!0),t[r]=a,n[VP(r)]=r,n[VP(a.attribute)]=r}return new zP(t,n,e.space)}var nF=tF({properties:{ariaActiveDescendant:null,ariaAtomic:KP,ariaAutoComplete:null,ariaBusy:KP,ariaChecked:KP,ariaColCount:J,ariaColIndex:J,ariaColSpan:J,ariaControls:JP,ariaCurrent:null,ariaDescribedBy:JP,ariaDetails:null,ariaDisabled:KP,ariaDropEffect:JP,ariaErrorMessage:null,ariaExpanded:KP,ariaFlowTo:JP,ariaGrabbed:KP,ariaHasPopup:null,ariaHidden:KP,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:JP,ariaLevel:J,ariaLive:null,ariaModal:KP,ariaMultiLine:KP,ariaMultiSelectable:KP,ariaOrientation:null,ariaOwns:JP,ariaPlaceholder:null,ariaPosInSet:J,ariaPressed:KP,ariaReadOnly:KP,ariaRelevant:null,ariaRequired:KP,ariaRoleDescription:JP,ariaRowCount:J,ariaRowIndex:J,ariaRowSpan:J,ariaSelected:KP,ariaSetSize:J,ariaSort:null,ariaValueMax:J,ariaValueMin:J,ariaValueNow:J,ariaValueText:null,role:null},transform(e,t){return t===`role`?t:`aria-`+t.slice(4).toLowerCase()}});function rF(e,t){return t in e?e[t]:t}function iF(e,t){return rF(e,t.toLowerCase())}var aF=tF({attributes:{acceptcharset:`accept-charset`,classname:`class`,htmlfor:`for`,httpequiv:`http-equiv`},mustUseProperty:[`checked`,`multiple`,`muted`,`selected`],properties:{abbr:null,accept:YP,acceptCharset:JP,accessKey:JP,action:null,allow:null,allowFullScreen:GP,allowPaymentRequest:GP,allowUserMedia:GP,alpha:GP,alt:null,as:null,async:GP,autoCapitalize:null,autoComplete:JP,autoFocus:GP,autoPlay:GP,blocking:JP,capture:null,charSet:null,checked:GP,cite:null,className:JP,closedBy:null,colorSpace:null,cols:J,colSpan:J,command:null,commandFor:null,content:null,contentEditable:KP,controls:GP,controlsList:JP,coords:J|YP,crossOrigin:null,data:null,dateTime:null,decoding:null,default:GP,defer:GP,dir:null,dirName:null,disabled:GP,download:qP,draggable:KP,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:GP,formTarget:null,headers:JP,height:J,hidden:qP,high:J,href:null,hrefLang:null,htmlFor:JP,httpEquiv:JP,id:null,imageSizes:null,imageSrcSet:null,inert:GP,inputMode:null,integrity:null,is:null,isMap:GP,itemId:null,itemProp:JP,itemRef:JP,itemScope:GP,itemType:JP,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:GP,low:J,manifest:null,max:null,maxLength:J,media:null,method:null,min:null,minLength:J,multiple:GP,muted:GP,name:null,nonce:null,noModule:GP,noValidate:GP,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:GP,optimum:J,pattern:null,ping:JP,placeholder:null,playsInline:GP,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:GP,referrerPolicy:null,rel:JP,required:GP,reversed:GP,rows:J,rowSpan:J,sandbox:JP,scope:null,scoped:GP,seamless:GP,selected:GP,shadowRootClonable:GP,shadowRootCustomElementRegistry:GP,shadowRootDelegatesFocus:GP,shadowRootMode:null,shadowRootSerializable:GP,shape:null,size:J,sizes:null,slot:null,span:J,spellCheck:KP,src:null,srcDoc:null,srcLang:null,srcSet:null,start:J,step:null,style:null,tabIndex:J,target:null,title:null,translate:null,type:null,typeMustMatch:GP,useMap:null,value:KP,width:J,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:JP,axis:null,background:null,bgColor:null,border:J,borderColor:null,bottomMargin:J,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:GP,declare:GP,event:null,face:null,frame:null,frameBorder:null,hSpace:J,leftMargin:J,link:null,longDesc:null,lowSrc:null,marginHeight:J,marginWidth:J,noResize:GP,noHref:GP,noShade:GP,noWrap:GP,object:null,profile:null,prompt:null,rev:null,rightMargin:J,rules:null,scheme:null,scrolling:KP,standby:null,summary:null,text:null,topMargin:J,valueType:null,version:null,vAlign:null,vLink:null,vSpace:J,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:GP,disablePictureInPicture:GP,disableRemotePlayback:GP,exportParts:YP,part:JP,prefix:null,property:null,results:J,security:null,unselectable:null},space:`html`,transform:iF}),oF=tF({attributes:{accentHeight:`accent-height`,alignmentBaseline:`alignment-baseline`,arabicForm:`arabic-form`,baselineShift:`baseline-shift`,capHeight:`cap-height`,className:`class`,clipPath:`clip-path`,clipRule:`clip-rule`,colorInterpolation:`color-interpolation`,colorInterpolationFilters:`color-interpolation-filters`,colorProfile:`color-profile`,colorRendering:`color-rendering`,crossOrigin:`crossorigin`,dataType:`datatype`,dominantBaseline:`dominant-baseline`,enableBackground:`enable-background`,fillOpacity:`fill-opacity`,fillRule:`fill-rule`,floodColor:`flood-color`,floodOpacity:`flood-opacity`,fontFamily:`font-family`,fontSize:`font-size`,fontSizeAdjust:`font-size-adjust`,fontStretch:`font-stretch`,fontStyle:`font-style`,fontVariant:`font-variant`,fontWeight:`font-weight`,glyphName:`glyph-name`,glyphOrientationHorizontal:`glyph-orientation-horizontal`,glyphOrientationVertical:`glyph-orientation-vertical`,hrefLang:`hreflang`,horizAdvX:`horiz-adv-x`,horizOriginX:`horiz-origin-x`,horizOriginY:`horiz-origin-y`,imageRendering:`image-rendering`,letterSpacing:`letter-spacing`,lightingColor:`lighting-color`,markerEnd:`marker-end`,markerMid:`marker-mid`,markerStart:`marker-start`,maskType:`mask-type`,navDown:`nav-down`,navDownLeft:`nav-down-left`,navDownRight:`nav-down-right`,navLeft:`nav-left`,navNext:`nav-next`,navPrev:`nav-prev`,navRight:`nav-right`,navUp:`nav-up`,navUpLeft:`nav-up-left`,navUpRight:`nav-up-right`,onAbort:`onabort`,onActivate:`onactivate`,onAfterPrint:`onafterprint`,onBeforePrint:`onbeforeprint`,onBegin:`onbegin`,onCancel:`oncancel`,onCanPlay:`oncanplay`,onCanPlayThrough:`oncanplaythrough`,onChange:`onchange`,onClick:`onclick`,onClose:`onclose`,onCopy:`oncopy`,onCueChange:`oncuechange`,onCut:`oncut`,onDblClick:`ondblclick`,onDrag:`ondrag`,onDragEnd:`ondragend`,onDragEnter:`ondragenter`,onDragExit:`ondragexit`,onDragLeave:`ondragleave`,onDragOver:`ondragover`,onDragStart:`ondragstart`,onDrop:`ondrop`,onDurationChange:`ondurationchange`,onEmptied:`onemptied`,onEnd:`onend`,onEnded:`onended`,onError:`onerror`,onFocus:`onfocus`,onFocusIn:`onfocusin`,onFocusOut:`onfocusout`,onHashChange:`onhashchange`,onInput:`oninput`,onInvalid:`oninvalid`,onKeyDown:`onkeydown`,onKeyPress:`onkeypress`,onKeyUp:`onkeyup`,onLoad:`onload`,onLoadedData:`onloadeddata`,onLoadedMetadata:`onloadedmetadata`,onLoadStart:`onloadstart`,onMessage:`onmessage`,onMouseDown:`onmousedown`,onMouseEnter:`onmouseenter`,onMouseLeave:`onmouseleave`,onMouseMove:`onmousemove`,onMouseOut:`onmouseout`,onMouseOver:`onmouseover`,onMouseUp:`onmouseup`,onMouseWheel:`onmousewheel`,onOffline:`onoffline`,onOnline:`ononline`,onPageHide:`onpagehide`,onPageShow:`onpageshow`,onPaste:`onpaste`,onPause:`onpause`,onPlay:`onplay`,onPlaying:`onplaying`,onPopState:`onpopstate`,onProgress:`onprogress`,onRateChange:`onratechange`,onRepeat:`onrepeat`,onReset:`onreset`,onResize:`onresize`,onScroll:`onscroll`,onSeeked:`onseeked`,onSeeking:`onseeking`,onSelect:`onselect`,onShow:`onshow`,onStalled:`onstalled`,onStorage:`onstorage`,onSubmit:`onsubmit`,onSuspend:`onsuspend`,onTimeUpdate:`ontimeupdate`,onToggle:`ontoggle`,onUnload:`onunload`,onVolumeChange:`onvolumechange`,onWaiting:`onwaiting`,onZoom:`onzoom`,overlinePosition:`overline-position`,overlineThickness:`overline-thickness`,paintOrder:`paint-order`,panose1:`panose-1`,pointerEvents:`pointer-events`,referrerPolicy:`referrerpolicy`,renderingIntent:`rendering-intent`,shapeRendering:`shape-rendering`,stopColor:`stop-color`,stopOpacity:`stop-opacity`,strikethroughPosition:`strikethrough-position`,strikethroughThickness:`strikethrough-thickness`,strokeDashArray:`stroke-dasharray`,strokeDashOffset:`stroke-dashoffset`,strokeLineCap:`stroke-linecap`,strokeLineJoin:`stroke-linejoin`,strokeMiterLimit:`stroke-miterlimit`,strokeOpacity:`stroke-opacity`,strokeWidth:`stroke-width`,tabIndex:`tabindex`,textAnchor:`text-anchor`,textDecoration:`text-decoration`,textRendering:`text-rendering`,transformOrigin:`transform-origin`,typeOf:`typeof`,underlinePosition:`underline-position`,underlineThickness:`underline-thickness`,unicodeBidi:`unicode-bidi`,unicodeRange:`unicode-range`,unitsPerEm:`units-per-em`,vAlphabetic:`v-alphabetic`,vHanging:`v-hanging`,vIdeographic:`v-ideographic`,vMathematical:`v-mathematical`,vectorEffect:`vector-effect`,vertAdvY:`vert-adv-y`,vertOriginX:`vert-origin-x`,vertOriginY:`vert-origin-y`,wordSpacing:`word-spacing`,writingMode:`writing-mode`,xHeight:`x-height`,playbackOrder:`playbackorder`,timelineBegin:`timelinebegin`},properties:{about:XP,accentHeight:J,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:J,amplitude:J,arabicForm:null,ascent:J,attributeName:null,attributeType:null,azimuth:J,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:J,by:null,calcMode:null,capHeight:J,className:JP,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:J,diffuseConstant:J,direction:null,display:null,dur:null,divisor:J,dominantBaseline:null,download:GP,dx:null,dy:null,edgeMode:null,editable:null,elevation:J,enableBackground:null,end:null,event:null,exponent:J,externalResourcesRequired:null,fill:null,fillOpacity:J,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:YP,g2:YP,glyphName:YP,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:J,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:J,horizOriginX:J,horizOriginY:J,id:null,ideographic:J,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:J,k:J,k1:J,k2:J,k3:J,k4:J,kernelMatrix:XP,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:J,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskType:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:J,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:J,overlineThickness:J,paintOrder:null,panose1:null,path:null,pathLength:J,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:JP,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:J,pointsAtY:J,pointsAtZ:J,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:XP,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:XP,rev:XP,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:XP,requiredFeatures:XP,requiredFonts:XP,requiredFormats:XP,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:J,specularExponent:J,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:J,strikethroughThickness:J,string:null,stroke:null,strokeDashArray:XP,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:J,strokeOpacity:J,strokeWidth:null,style:null,surfaceScale:J,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:XP,tabIndex:J,tableValues:null,target:null,targetX:J,targetY:J,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:XP,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:J,underlineThickness:J,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:J,values:null,vAlphabetic:J,vMathematical:J,vectorEffect:null,vHanging:J,vIdeographic:J,version:null,vertAdvY:J,vertOriginX:J,vertOriginY:J,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:J,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:`svg`,transform:rF}),sF=tF({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:`xlink`,transform(e,t){return`xlink:`+t.slice(5).toLowerCase()}}),cF=tF({attributes:{xmlnsxlink:`xmlns:xlink`},properties:{xmlnsXLink:null,xmlns:null},space:`xmlns`,transform:iF}),lF=tF({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:`xml`,transform(e,t){return`xml:`+t.slice(3).toLowerCase()}}),uF={classId:`classID`,dataType:`datatype`,itemId:`itemID`,strokeDashArray:`strokeDasharray`,strokeDashOffset:`strokeDashoffset`,strokeLineCap:`strokeLinecap`,strokeLineJoin:`strokeLinejoin`,strokeMiterLimit:`strokeMiterlimit`,typeOf:`typeof`,xLinkActuate:`xlinkActuate`,xLinkArcRole:`xlinkArcrole`,xLinkHref:`xlinkHref`,xLinkRole:`xlinkRole`,xLinkShow:`xlinkShow`,xLinkTitle:`xlinkTitle`,xLinkType:`xlinkType`,xmlnsXLink:`xmlnsXlink`},dF=/[A-Z]/g,fF=/-[a-z]/g,pF=/^data[-\w.:]+$/i;function mF(e,t){let n=VP(t),r=t,i=HP;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)===`data`&&pF.test(t)){if(t.charAt(4)===`-`){let e=t.slice(5).replace(fF,gF);r=`data`+e.charAt(0).toUpperCase()+e.slice(1)}else{let e=t.slice(4);if(!fF.test(e)){let n=e.replace(dF,hF);n.charAt(0)!==`-`&&(n=`-`+n),t=`data`+n}}i=$P}return new i(r,t)}function hF(e){return`-`+e.toLowerCase()}function gF(e){return e.charAt(1).toUpperCase()}var _F=BP([nF,aF,sF,cF,lF],`html`),vF=BP([nF,oF,sF,cF,lF],`svg`);function yF(e){return e.join(` `).trim()}var bF=o(((e,t)=>{var n=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,r=/\n/g,i=/^\s*/,a=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,o=/^:\s*/,s=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,l=/^\s+|\s+$/g;function u(e,t){if(typeof e!=`string`)throw TypeError(`First argument must be a string`);if(!e)return[];t||={};var l=1,u=1;function f(e){var t=e.match(r);t&&(l+=t.length);var n=e.lastIndexOf(`
103
+ `);u=~n?e.length-n:u+e.length}function p(){var e={line:l,column:u};return function(t){return t.position=new m(e),_(),t}}function m(e){this.start=e,this.end={line:l,column:u},this.source=t.source}m.prototype.content=e;function h(n){var r=Error(t.source+`:`+l+`:`+u+`: `+n);if(r.reason=n,r.filename=t.source,r.line=l,r.column=u,r.source=e,!t.silent)throw r}function g(t){var n=t.exec(e);if(n){var r=n[0];return f(r),e=e.slice(r.length),n}}function _(){g(i)}function v(e){var t;for(e||=[];t=y();)t!==!1&&e.push(t);return e}function y(){var t=p();if(e.charAt(0)==`/`&&e.charAt(1)==`*`){for(var n=2;e.charAt(n)!=``&&(e.charAt(n)!=`*`||e.charAt(n+1)!=`/`);)++n;if(n+=2,e.charAt(n-1)===``)return h(`End of comment missing`);var r=e.slice(2,n-2);return u+=2,f(r),e=e.slice(n),u+=2,t({type:`comment`,comment:r})}}function b(){var e=p(),t=g(a);if(t){if(y(),!g(o))return h(`property missing ':'`);var r=g(s),i=e({type:`declaration`,property:d(t[0].replace(n,``)),value:r?d(r[0].replace(n,``)):``});return g(c),i}}function x(){var e=[];v(e);for(var t;t=b();)t!==!1&&(e.push(t),v(e));return e}return _(),x()}function d(e){return e?e.replace(l,``):``}t.exports=u})),xF=o((e=>{var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,"__esModule",{value:!0}),e.default=r;var n=t(bF());function r(e,t){let r=null;if(!e||typeof e!=`string`)return r;let i=(0,n.default)(e),a=typeof t==`function`;return i.forEach(e=>{if(e.type!==`declaration`)return;let{property:n,value:i}=e;a?t(n,i,e):i&&(r||={},r[n]=i)}),r}})),SF=o((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.camelCase=void 0;var t=/^--[a-zA-Z0-9_-]+$/,n=/-([a-z])/g,r=/^[^-]+$/,i=/^-(webkit|moz|ms|o|khtml)-/,a=/^-(ms)-/,o=function(e){return!e||r.test(e)||t.test(e)},s=function(e,t){return t.toUpperCase()},c=function(e,t){return`${t}-`};e.camelCase=function(e,t){return t===void 0&&(t={}),o(e)?e:(e=e.toLowerCase(),e=t.reactCompat?e.replace(a,c):e.replace(i,c),e.replace(n,s))}})),CF=o(((e,t)=>{var n=(e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(xF()),r=SF();function i(e,t){var i={};return!e||typeof e!=`string`||(0,n.default)(e,function(e,n){e&&n&&(i[(0,r.camelCase)(e,t)]=n)}),i}i.default=i,t.exports=i})),wF=EF(`end`),TF=EF(`start`);function EF(e){return t;function t(t){let n=t&&t.position&&t.position[e]||{};if(typeof n.line==`number`&&n.line>0&&typeof n.column==`number`&&n.column>0)return{line:n.line,column:n.column,offset:typeof n.offset==`number`&&n.offset>-1?n.offset:void 0}}}function DF(e){let t=TF(e),n=wF(e);if(t&&n)return{start:t,end:n}}function OF(e){return!e||typeof e!=`object`?``:`position`in e||`type`in e?AF(e.position):`start`in e||`end`in e?AF(e):`line`in e||`column`in e?kF(e):``}function kF(e){return jF(e&&e.line)+`:`+jF(e&&e.column)}function AF(e){return kF(e&&e.start)+`-`+kF(e&&e.end)}function jF(e){return e&&typeof e==`number`?e:1}var MF=class extends Error{constructor(e,t,n){super(),typeof t==`string`&&(n=t,t=void 0);let r=``,i={},a=!1;if(t&&(i=`line`in t&&`column`in t||`start`in t&&`end`in t?{place:t}:`type`in t?{ancestors:[t],place:t.position}:{...t}),typeof e==`string`?r=e:!i.cause&&e&&(a=!0,r=e.message,i.cause=e),!i.ruleId&&!i.source&&typeof n==`string`){let e=n.indexOf(`:`);e===-1?i.ruleId=n:(i.source=n.slice(0,e),i.ruleId=n.slice(e+1))}if(!i.place&&i.ancestors&&i.ancestors){let e=i.ancestors[i.ancestors.length-1];e&&(i.place=e.position)}let o=i.place&&`start`in i.place?i.place.start:i.place;this.ancestors=i.ancestors||void 0,this.cause=i.cause||void 0,this.column=o?o.column:void 0,this.fatal=void 0,this.file=``,this.message=r,this.line=o?o.line:void 0,this.name=OF(i.place)||`1:1`,this.place=i.place||void 0,this.reason=this.message,this.ruleId=i.ruleId||void 0,this.source=i.source||void 0,this.stack=a&&i.cause&&typeof i.cause.stack==`string`?i.cause.stack:``,this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}};MF.prototype.file=``,MF.prototype.name=``,MF.prototype.reason=``,MF.prototype.message=``,MF.prototype.stack=``,MF.prototype.column=void 0,MF.prototype.line=void 0,MF.prototype.ancestors=void 0,MF.prototype.cause=void 0,MF.prototype.fatal=void 0,MF.prototype.place=void 0,MF.prototype.ruleId=void 0,MF.prototype.source=void 0;var NF=l(CF(),1),PF={}.hasOwnProperty,FF=new Map,IF=/[A-Z]/g,LF=new Set([`table`,`tbody`,`thead`,`tfoot`,`tr`]),RF=new Set([`td`,`th`]),zF=`https://github.com/syntax-tree/hast-util-to-jsx-runtime`;function BF(e,t){if(!t||t.Fragment===void 0)throw TypeError("Expected `Fragment` in options");let n=t.filePath||void 0,r;if(t.development){if(typeof t.jsxDEV!=`function`)throw TypeError("Expected `jsxDEV` in options when `development: true`");r=ZF(n,t.jsxDEV)}else{if(typeof t.jsx!=`function`)throw TypeError("Expected `jsx` in production options");if(typeof t.jsxs!=`function`)throw TypeError("Expected `jsxs` in production options");r=XF(n,t.jsx,t.jsxs)}let i={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||`react`,evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space===`svg`?vF:_F,stylePropertyNameCase:t.stylePropertyNameCase||`dom`,tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},a=VF(i,e,void 0);return a&&typeof a!=`string`?a:i.create(e,i.Fragment,{children:a||void 0},void 0)}function VF(e,t,n){if(t.type===`element`)return HF(e,t,n);if(t.type===`mdxFlowExpression`||t.type===`mdxTextExpression`)return UF(e,t);if(t.type===`mdxJsxFlowElement`||t.type===`mdxJsxTextElement`)return GF(e,t,n);if(t.type===`mdxjsEsm`)return WF(e,t);if(t.type===`root`)return KF(e,t,n);if(t.type===`text`)return qF(e,t)}function HF(e,t,n){let r=e.schema,i=r;t.tagName.toLowerCase()===`svg`&&r.space===`html`&&(i=vF,e.schema=i),e.ancestors.push(t);let a=rI(e,t.tagName,!1),o=QF(e,t),s=eI(e,t);return LF.has(t.tagName)&&(s=s.filter(function(e){return typeof e!=`string`||!LP(e)})),JF(e,o,a,t),YF(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function UF(e,t){if(t.data&&t.data.estree&&e.evaluater){let n=t.data.estree.body[0];return n.type,e.evaluater.evaluateExpression(n.expression)}iI(e,t.position)}function WF(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);iI(e,t.position)}function GF(e,t,n){let r=e.schema,i=r;t.name===`svg`&&r.space===`html`&&(i=vF,e.schema=i),e.ancestors.push(t);let a=t.name===null?e.Fragment:rI(e,t.name,!0),o=$F(e,t),s=eI(e,t);return JF(e,o,a,t),YF(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function KF(e,t,n){let r={};return YF(r,eI(e,t)),e.create(t,e.Fragment,r,n)}function qF(e,t){return t.value}function JF(e,t,n,r){typeof n!=`string`&&n!==e.Fragment&&e.passNode&&(t.node=r)}function YF(e,t){if(t.length>0){let n=t.length>1?t:t[0];n&&(e.children=n)}}function XF(e,t,n){return r;function r(e,r,i,a){let o=Array.isArray(i.children)?n:t;return a?o(r,i,a):o(r,i)}}function ZF(e,t){return n;function n(n,r,i,a){let o=Array.isArray(i.children),s=TF(n);return t(r,i,a,o,{columnNumber:s?s.column-1:void 0,fileName:e,lineNumber:s?s.line:void 0},void 0)}}function QF(e,t){let n={},r,i;for(i in t.properties)if(i!==`children`&&PF.call(t.properties,i)){let a=tI(e,i,t.properties[i]);if(a){let[i,o]=a;e.tableCellAlignToStyle&&i===`align`&&typeof o==`string`&&RF.has(t.tagName)?r=o:n[i]=o}}if(r){let t=n.style||={};t[e.stylePropertyNameCase===`css`?`text-align`:`textAlign`]=r}return n}function $F(e,t){let n={};for(let r of t.attributes)if(r.type===`mdxJsxExpressionAttribute`){if(r.data&&r.data.estree&&e.evaluater){let t=r.data.estree.body[0];t.type;let i=t.expression;i.type;let a=i.properties[0];a.type,Object.assign(n,e.evaluater.evaluateExpression(a.argument))}else iI(e,t.position)}else{let i=r.name,a;if(r.value&&typeof r.value==`object`){if(r.value.data&&r.value.data.estree&&e.evaluater){let t=r.value.data.estree.body[0];t.type,a=e.evaluater.evaluateExpression(t.expression)}else iI(e,t.position)}else a=r.value===null||r.value;n[i]=a}return n}function eI(e,t){let n=[],r=-1,i=e.passKeys?new Map:FF;for(;++r<t.children.length;){let a=t.children[r],o;if(e.passKeys){let e=a.type===`element`?a.tagName:a.type===`mdxJsxFlowElement`||a.type===`mdxJsxTextElement`?a.name:void 0;if(e){let t=i.get(e)||0;o=e+`-`+t,i.set(e,t+1)}}let s=VF(e,a,o);s!==void 0&&n.push(s)}return n}function tI(e,t,n){let r=mF(e.schema,t);if(!(n==null||typeof n==`number`&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?jP(n):yF(n)),r.property===`style`){let t=typeof n==`object`?n:nI(e,String(n));return e.stylePropertyNameCase===`css`&&(t=aI(t)),[`style`,t]}return[e.elementAttributeNameCase===`react`&&r.space?uF[r.property]||r.property:r.attribute,n]}}function nI(e,t){try{return(0,NF.default)(t,{reactCompat:!0})}catch(t){if(e.ignoreInvalidStyle)return{};let n=t,r=new MF("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:n,ruleId:`style`,source:`hast-util-to-jsx-runtime`});throw r.file=e.filePath||void 0,r.url=zF+`#cannot-parse-style-attribute`,r}}function rI(e,t,n){let r;if(!n)r={type:`Literal`,value:t};else if(t.includes(`.`)){let e=t.split(`.`),n=-1,i;for(;++n<e.length;){let t=FP(e[n])?{type:`Identifier`,name:e[n]}:{type:`Literal`,value:e[n]};i=i?{type:`MemberExpression`,object:i,property:t,computed:!!(n&&t.type===`Literal`),optional:!1}:t}r=i}else r=FP(t)&&!/^[a-z]/.test(t)?{type:`Identifier`,name:t}:{type:`Literal`,value:t};if(r.type===`Literal`){let t=r.value;return PF.call(e.components,t)?e.components[t]:t}if(e.evaluater)return e.evaluater.evaluateExpression(r);iI(e)}function iI(e,t){let n=new MF("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:`mdx-estree`,source:`hast-util-to-jsx-runtime`});throw n.file=e.filePath||void 0,n.url=zF+`#cannot-handle-mdx-estrees-without-createevaluater`,n}function aI(e){let t={},n;for(n in e)PF.call(e,n)&&(t[oI(n)]=e[n]);return t}function oI(e){let t=e.replace(IF,sI);return t.slice(0,3)===`ms-`&&(t=`-`+t),t}function sI(e){return`-`+e.toLowerCase()}var cI={action:[`form`],cite:[`blockquote`,`del`,`ins`,`q`],data:[`object`],formAction:[`button`,`input`],href:[`a`,`area`,`base`,`link`],icon:[`menuitem`],itemId:null,manifest:[`html`],ping:[`a`,`area`],poster:[`video`],src:[`audio`,`embed`,`iframe`,`img`,`input`,`script`,`source`,`track`,`video`]},lI={};function uI(e,t){let n=t||lI;return dI(e,typeof n.includeImageAlt!=`boolean`||n.includeImageAlt,typeof n.includeHtml!=`boolean`||n.includeHtml)}function dI(e,t,n){if(pI(e)){if(`value`in e)return e.type===`html`&&!n?``:e.value;if(t&&`alt`in e&&e.alt)return e.alt;if(`children`in e)return fI(e.children,t,n)}return Array.isArray(e)?fI(e,t,n):``}function fI(e,t,n){let r=[],i=-1;for(;++i<e.length;)r[i]=dI(e[i],t,n);return r.join(``)}function pI(e){return!!(e&&typeof e==`object`)}var mI=document.createElement(`i`);function hI(e){let t=`&`+e+`;`;mI.innerHTML=t;let n=mI.textContent;return n.charCodeAt(n.length-1)===59&&e!==`semi`?!1:n!==t&&n}function gI(e,t,n,r){let i=e.length,a=0,o;if(t=t<0?-t>i?0:i+t:t>i?i:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);a<r.length;)o=r.slice(a,a+1e4),o.unshift(t,0),e.splice(...o),a+=1e4,t+=1e4}function _I(e,t){return e.length>0?(gI(e,e.length,0,t),e):t}var vI={}.hasOwnProperty;function yI(e){let t={},n=-1;for(;++n<e.length;)bI(t,e[n]);return t}function bI(e,t){let n;for(n in t){let r=(vI.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n],a;if(i)for(a in i){vI.call(r,a)||(r[a]=[]);let e=i[a];xI(r[a],Array.isArray(e)?e:e?[e]:[])}}}function xI(e,t){let n=-1,r=[];for(;++n<t.length;)(t[n].add===`after`?e:r).push(t[n]);gI(e,0,0,r)}function SI(e,t){let n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)==65535||(n&65535)==65534||n>1114111?`�`:String.fromCodePoint(n)}function CI(e){return e.replace(/[\t\n\r ]+/g,` `).replace(/^ | $/g,``).toLowerCase().toUpperCase()}var wI=II(/[A-Za-z]/),TI=II(/[\dA-Za-z]/),EI=II(/[#-'*+\--9=?A-Z^-~]/);function DI(e){return e!==null&&(e<32||e===127)}var OI=II(/\d/),kI=II(/[\dA-Fa-f]/),AI=II(/[!-/:-@[-`{-~]/);function jI(e){return e!==null&&e<-2}function MI(e){return e!==null&&(e<0||e===32)}function NI(e){return e===-2||e===-1||e===32}var PI=II(/\p{P}|\p{S}/u),FI=II(/\s/);function II(e){return t;function t(t){return t!==null&&t>-1&&e.test(String.fromCharCode(t))}}function LI(e){let t=[],n=-1,r=0,i=0;for(;++n<e.length;){let a=e.charCodeAt(n),o=``;if(a===37&&TI(e.charCodeAt(n+1))&&TI(e.charCodeAt(n+2)))i=2;else if(a<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(a))||(o=String.fromCharCode(a));else if(a>55295&&a<57344){let t=e.charCodeAt(n+1);a<56320&&t>56319&&t<57344?(o=String.fromCharCode(a,t),i=1):o=`�`}else o=String.fromCharCode(a);o&&=(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+i+1,``),i&&=(n+=i,0)}return t.join(``)+e.slice(r)}function RI(e,t,n,r){let i=r?r-1:1/0,a=0;return o;function o(r){return NI(r)?(e.enter(n),s(r)):t(r)}function s(r){return NI(r)&&a++<i?(e.consume(r),s):(e.exit(n),t(r))}}var zI={tokenize:BI};function BI(e){let t=e.attempt(this.parser.constructs.contentInitial,r,i),n;return t;function r(n){if(n===null){e.consume(n);return}return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),RI(e,t,`linePrefix`)}function i(t){return e.enter(`paragraph`),a(t)}function a(t){let r=e.enter(`chunkText`,{contentType:`text`,previous:n});return n&&(n.next=r),n=r,o(t)}function o(t){if(t===null){e.exit(`chunkText`),e.exit(`paragraph`),e.consume(t);return}return jI(t)?(e.consume(t),e.exit(`chunkText`),a):(e.consume(t),o)}}var VI={tokenize:UI},HI={tokenize:WI};function UI(e){let t=this,n=[],r=0,i,a,o;return s;function s(i){if(r<n.length){let a=n[r];return t.containerState=a[1],e.attempt(a[0].continuation,c,l)(i)}return l(i)}function c(e){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&v();let n=t.events.length,a=n,o;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){o=t.events[a][1].end;break}_(r);let s=n;for(;s<t.events.length;)t.events[s][1].end={...o},s++;return gI(t.events,a+1,0,t.events.slice(n)),t.events.length=s,l(e)}return s(e)}function l(a){if(r===n.length){if(!i)return f(a);if(i.currentConstruct&&i.currentConstruct.concrete)return m(a);t.interrupt=!(!i.currentConstruct||i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(HI,u,d)(a)}function u(e){return i&&v(),_(r),f(e)}function d(e){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,m(e)}function f(n){return t.containerState={},e.attempt(HI,p,m)(n)}function p(e){return r++,n.push([t.currentConstruct,t.containerState]),f(e)}function m(n){if(n===null){i&&v(),_(0),e.consume(n);return}return i||=t.parser.flow(t.now()),e.enter(`chunkFlow`,{_tokenizer:i,contentType:`flow`,previous:a}),h(n)}function h(n){if(n===null){g(e.exit(`chunkFlow`),!0),_(0),e.consume(n);return}return jI(n)?(e.consume(n),g(e.exit(`chunkFlow`)),r=0,t.interrupt=void 0,s):(e.consume(n),h)}function g(e,n){let s=t.sliceStream(e);if(n&&s.push(null),e.previous=a,a&&(a.next=e),a=e,i.defineSkip(e.start),i.write(s),t.parser.lazy[e.start.line]){let e=i.events.length;for(;e--;)if(i.events[e][1].start.offset<o&&(!i.events[e][1].end||i.events[e][1].end.offset>o))return;let n=t.events.length,a=n,s,c;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){if(s){c=t.events[a][1].end;break}s=!0}for(_(r),e=n;e<t.events.length;)t.events[e][1].end={...c},e++;gI(t.events,a+1,0,t.events.slice(n)),t.events.length=e}}function _(r){let i=n.length;for(;i-->r;){let r=n[i];t.containerState=r[1],r[0].exit.call(t,e)}n.length=r}function v(){i.write([null]),a=void 0,i=void 0,t.containerState._closeFlow=void 0}}function WI(e,t,n){return RI(e,e.attempt(this.parser.constructs.document,t,n),`linePrefix`,this.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)}function GI(e){if(e===null||MI(e)||FI(e))return 1;if(PI(e))return 2}function KI(e,t,n){let r=[],i=-1;for(;++i<e.length;){let a=e[i].resolveAll;a&&!r.includes(a)&&(t=a(t,n),r.push(a))}return t}var qI={name:`attention`,resolveAll:JI,tokenize:YI};function JI(e,t){let n=-1,r,i,a,o,s,c,l,u;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`attentionSequence`&&e[n][1]._close){for(r=n;r--;)if(e[r][0]===`exit`&&e[r][1].type===`attentionSequence`&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;c=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;let d={...e[r][1].end},f={...e[n][1].start};XI(d,-c),XI(f,c),o={type:c>1?`strongSequence`:`emphasisSequence`,start:d,end:{...e[r][1].end}},s={type:c>1?`strongSequence`:`emphasisSequence`,start:{...e[n][1].start},end:f},a={type:c>1?`strongText`:`emphasisText`,start:{...e[r][1].end},end:{...e[n][1].start}},i={type:c>1?`strong`:`emphasis`,start:{...o.start},end:{...s.end}},e[r][1].end={...o.start},e[n][1].start={...s.end},l=[],e[r][1].end.offset-e[r][1].start.offset&&(l=_I(l,[[`enter`,e[r][1],t],[`exit`,e[r][1],t]])),l=_I(l,[[`enter`,i,t],[`enter`,o,t],[`exit`,o,t],[`enter`,a,t]]),l=_I(l,KI(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),l=_I(l,[[`exit`,a,t],[`enter`,s,t],[`exit`,s,t],[`exit`,i,t]]),e[n][1].end.offset-e[n][1].start.offset?(u=2,l=_I(l,[[`enter`,e[n][1],t],[`exit`,e[n][1],t]])):u=0,gI(e,r-1,n-r+3,l),n=r+l.length-u-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`attentionSequence`&&(e[n][1].type=`data`);return e}function YI(e,t){let n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=GI(r),a;return o;function o(t){return a=t,e.enter(`attentionSequence`),s(t)}function s(o){if(o===a)return e.consume(o),s;let c=e.exit(`attentionSequence`),l=GI(o),u=!l||l===2&&i||n.includes(o),d=!i||i===2&&l||n.includes(r);return c._open=!!(a===42?u:u&&(i||!d)),c._close=!!(a===42?d:d&&(l||!u)),t(o)}}function XI(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}var ZI={name:`autolink`,tokenize:QI};function QI(e,t,n){let r=0;return i;function i(t){return e.enter(`autolink`),e.enter(`autolinkMarker`),e.consume(t),e.exit(`autolinkMarker`),e.enter(`autolinkProtocol`),a}function a(t){return wI(t)?(e.consume(t),o):t===64?n(t):l(t)}function o(e){return e===43||e===45||e===46||TI(e)?(r=1,s(e)):l(e)}function s(t){return t===58?(e.consume(t),r=0,c):(t===43||t===45||t===46||TI(t))&&r++<32?(e.consume(t),s):(r=0,l(t))}function c(r){return r===62?(e.exit(`autolinkProtocol`),e.enter(`autolinkMarker`),e.consume(r),e.exit(`autolinkMarker`),e.exit(`autolink`),t):r===null||r===32||r===60||DI(r)?n(r):(e.consume(r),c)}function l(t){return t===64?(e.consume(t),u):EI(t)?(e.consume(t),l):n(t)}function u(e){return TI(e)?d(e):n(e)}function d(n){return n===46?(e.consume(n),r=0,u):n===62?(e.exit(`autolinkProtocol`).type=`autolinkEmail`,e.enter(`autolinkMarker`),e.consume(n),e.exit(`autolinkMarker`),e.exit(`autolink`),t):f(n)}function f(t){if((t===45||TI(t))&&r++<63){let n=t===45?f:d;return e.consume(t),n}return n(t)}}var $I={partial:!0,tokenize:eL};function eL(e,t,n){return r;function r(t){return NI(t)?RI(e,i,`linePrefix`)(t):i(t)}function i(e){return e===null||jI(e)?t(e):n(e)}}var tL={continuation:{tokenize:rL},exit:iL,name:`blockQuote`,tokenize:nL};function nL(e,t,n){let r=this;return i;function i(t){if(t===62){let n=r.containerState;return n.open||=(e.enter(`blockQuote`,{_container:!0}),!0),e.enter(`blockQuotePrefix`),e.enter(`blockQuoteMarker`),e.consume(t),e.exit(`blockQuoteMarker`),a}return n(t)}function a(n){return NI(n)?(e.enter(`blockQuotePrefixWhitespace`),e.consume(n),e.exit(`blockQuotePrefixWhitespace`),e.exit(`blockQuotePrefix`),t):(e.exit(`blockQuotePrefix`),t(n))}}function rL(e,t,n){let r=this;return i;function i(t){return NI(t)?RI(e,a,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):a(t)}function a(r){return e.attempt(tL,t,n)(r)}}function iL(e){e.exit(`blockQuote`)}var aL={name:`characterEscape`,tokenize:oL};function oL(e,t,n){return r;function r(t){return e.enter(`characterEscape`),e.enter(`escapeMarker`),e.consume(t),e.exit(`escapeMarker`),i}function i(r){return AI(r)?(e.enter(`characterEscapeValue`),e.consume(r),e.exit(`characterEscapeValue`),e.exit(`characterEscape`),t):n(r)}}var sL={name:`characterReference`,tokenize:cL};function cL(e,t,n){let r=this,i=0,a,o;return s;function s(t){return e.enter(`characterReference`),e.enter(`characterReferenceMarker`),e.consume(t),e.exit(`characterReferenceMarker`),c}function c(t){return t===35?(e.enter(`characterReferenceMarkerNumeric`),e.consume(t),e.exit(`characterReferenceMarkerNumeric`),l):(e.enter(`characterReferenceValue`),a=31,o=TI,u(t))}function l(t){return t===88||t===120?(e.enter(`characterReferenceMarkerHexadecimal`),e.consume(t),e.exit(`characterReferenceMarkerHexadecimal`),e.enter(`characterReferenceValue`),a=6,o=kI,u):(e.enter(`characterReferenceValue`),a=7,o=OI,u(t))}function u(s){if(s===59&&i){let i=e.exit(`characterReferenceValue`);return o===TI&&!hI(r.sliceSerialize(i))?n(s):(e.enter(`characterReferenceMarker`),e.consume(s),e.exit(`characterReferenceMarker`),e.exit(`characterReference`),t)}return o(s)&&i++<a?(e.consume(s),u):n(s)}}var lL={partial:!0,tokenize:fL},uL={concrete:!0,name:`codeFenced`,tokenize:dL};function dL(e,t,n){let r=this,i={partial:!0,tokenize:x},a=0,o=0,s;return c;function c(e){return l(e)}function l(t){let n=r.events[r.events.length-1];return a=n&&n[1].type===`linePrefix`?n[2].sliceSerialize(n[1],!0).length:0,s=t,e.enter(`codeFenced`),e.enter(`codeFencedFence`),e.enter(`codeFencedFenceSequence`),u(t)}function u(t){return t===s?(o++,e.consume(t),u):o<3?n(t):(e.exit(`codeFencedFenceSequence`),NI(t)?RI(e,d,`whitespace`)(t):d(t))}function d(n){return n===null||jI(n)?(e.exit(`codeFencedFence`),r.interrupt?t(n):e.check(lL,h,b)(n)):(e.enter(`codeFencedFenceInfo`),e.enter(`chunkString`,{contentType:`string`}),f(n))}function f(t){return t===null||jI(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),d(t)):NI(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),RI(e,p,`whitespace`)(t)):t===96&&t===s?n(t):(e.consume(t),f)}function p(t){return t===null||jI(t)?d(t):(e.enter(`codeFencedFenceMeta`),e.enter(`chunkString`,{contentType:`string`}),m(t))}function m(t){return t===null||jI(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceMeta`),d(t)):t===96&&t===s?n(t):(e.consume(t),m)}function h(t){return e.attempt(i,b,g)(t)}function g(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),_}function _(t){return a>0&&NI(t)?RI(e,v,`linePrefix`,a+1)(t):v(t)}function v(t){return t===null||jI(t)?e.check(lL,h,b)(t):(e.enter(`codeFlowValue`),y(t))}function y(t){return t===null||jI(t)?(e.exit(`codeFlowValue`),v(t)):(e.consume(t),y)}function b(n){return e.exit(`codeFenced`),t(n)}function x(e,t,n){let i=0;return a;function a(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c}function c(t){return e.enter(`codeFencedFence`),NI(t)?RI(e,l,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):l(t)}function l(t){return t===s?(e.enter(`codeFencedFenceSequence`),u(t)):n(t)}function u(t){return t===s?(i++,e.consume(t),u):i>=o?(e.exit(`codeFencedFenceSequence`),NI(t)?RI(e,d,`whitespace`)(t):d(t)):n(t)}function d(r){return r===null||jI(r)?(e.exit(`codeFencedFence`),t(r)):n(r)}}}function fL(e,t,n){let r=this;return i;function i(t){return t===null?n(t):(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}var pL={name:`codeIndented`,tokenize:hL},mL={partial:!0,tokenize:gL};function hL(e,t,n){let r=this;return i;function i(t){return e.enter(`codeIndented`),RI(e,a,`linePrefix`,5)(t)}function a(e){let t=r.events[r.events.length-1];return t&&t[1].type===`linePrefix`&&t[2].sliceSerialize(t[1],!0).length>=4?o(e):n(e)}function o(t){return t===null?c(t):jI(t)?e.attempt(mL,o,c)(t):(e.enter(`codeFlowValue`),s(t))}function s(t){return t===null||jI(t)?(e.exit(`codeFlowValue`),o(t)):(e.consume(t),s)}function c(n){return e.exit(`codeIndented`),t(n)}}function gL(e,t,n){let r=this;return i;function i(t){return r.parser.lazy[r.now().line]?n(t):jI(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),i):RI(e,a,`linePrefix`,5)(t)}function a(e){let a=r.events[r.events.length-1];return a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(e):jI(e)?i(e):n(e)}}var _L={name:`codeText`,previous:yL,resolve:vL,tokenize:bL};function vL(e){let t=e.length-4,n=3,r,i;if((e[n][1].type===`lineEnding`||e[n][1].type===`space`)&&(e[t][1].type===`lineEnding`||e[t][1].type===`space`)){for(r=n;++r<t;)if(e[r][1].type===`codeTextData`){e[n][1].type=`codeTextPadding`,e[t][1].type=`codeTextPadding`,n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!==`lineEnding`&&(i=r):(r===t||e[r][1].type===`lineEnding`)&&(e[i][1].type=`codeTextData`,r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function yL(e){return e!==96||this.events[this.events.length-1][1].type===`characterEscape`}function bL(e,t,n){let r=0,i,a;return o;function o(t){return e.enter(`codeText`),e.enter(`codeTextSequence`),s(t)}function s(t){return t===96?(e.consume(t),r++,s):(e.exit(`codeTextSequence`),c(t))}function c(t){return t===null?n(t):t===32?(e.enter(`space`),e.consume(t),e.exit(`space`),c):t===96?(a=e.enter(`codeTextSequence`),i=0,u(t)):jI(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c):(e.enter(`codeTextData`),l(t))}function l(t){return t===null||t===32||t===96||jI(t)?(e.exit(`codeTextData`),c(t)):(e.consume(t),l)}function u(n){return n===96?(e.consume(n),i++,u):i===r?(e.exit(`codeTextSequence`),e.exit(`codeText`),t(n)):(a.type=`codeTextData`,l(n))}}var xL=class{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,t){let n=t??1/0;return n<this.left.length?this.left.slice(e,n):e>this.left.length?this.right.slice(this.right.length-n+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-n+this.left.length).reverse())}splice(e,t,n){let r=t||0;this.setCursor(Math.trunc(e));let i=this.right.splice(this.right.length-r,1/0);return n&&SL(this.left,n),i.reverse()}pop(){return this.setCursor(1/0),this.left.pop()}push(e){this.setCursor(1/0),this.left.push(e)}pushMany(e){this.setCursor(1/0),SL(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),SL(this.right,e.reverse())}setCursor(e){if(!(e===this.left.length||e>this.left.length&&this.right.length===0||e<0&&this.left.length===0)){if(e<this.left.length){let t=this.left.splice(e,1/0);SL(this.right,t.reverse())}else{let t=this.right.splice(this.left.length+this.right.length-e,1/0);SL(this.left,t.reverse())}}}};function SL(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function CL(e){let t={},n=-1,r,i,a,o,s,c,l,u=new xL(e);for(;++n<u.length;){for(;n in t;)n=t[n];if(r=u.get(n),n&&r[1].type===`chunkFlow`&&u.get(n-1)[1].type===`listItemPrefix`&&(c=r[1]._tokenizer.events,a=0,a<c.length&&c[a][1].type===`lineEndingBlank`&&(a+=2),a<c.length&&c[a][1].type===`content`))for(;++a<c.length&&c[a][1].type!==`content`;)c[a][1].type===`chunkText`&&(c[a][1]._isInFirstContentOfListItem=!0,a++);if(r[0]===`enter`)r[1].contentType&&(Object.assign(t,wL(u,n)),n=t[n],l=!0);else if(r[1]._container){for(a=n,i=void 0;a--;)if(o=u.get(a),o[1].type===`lineEnding`||o[1].type===`lineEndingBlank`)o[0]===`enter`&&(i&&(u.get(i)[1].type=`lineEndingBlank`),o[1].type=`lineEnding`,i=a);else if(o[1].type!==`linePrefix`&&o[1].type!==`listItemIndent`)break;i&&(r[1].end={...u.get(i)[1].start},s=u.slice(i,n),s.unshift(r),u.splice(i,n-i+1,s))}}return gI(e,0,1/0,u.slice(0)),!l}function wL(e,t){let n=e.get(t)[1],r=e.get(t)[2],i=t-1,a=[],o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));let s=o.events,c=[],l={},u,d,f=-1,p=n,m=0,h=0,g=[h];for(;p;){for(;e.get(++i)[1]!==p;);a.push(i),p._tokenizer||(u=r.sliceStream(p),p.next||u.push(null),d&&o.defineSkip(p.start),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(u),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),d=p,p=p.next}for(p=n;++f<s.length;)s[f][0]===`exit`&&s[f-1][0]===`enter`&&s[f][1].type===s[f-1][1].type&&s[f][1].start.line!==s[f][1].end.line&&(h=f+1,g.push(h),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(o.events=[],p?(p._tokenizer=void 0,p.previous=void 0):g.pop(),f=g.length;f--;){let t=s.slice(g[f],g[f+1]),n=a.pop();c.push([n,n+t.length-1]),e.splice(n,2,t)}for(c.reverse(),f=-1;++f<c.length;)l[m+c[f][0]]=m+c[f][1],m+=c[f][1]-c[f][0]-1;return l}var TL={resolve:DL,tokenize:OL},EL={partial:!0,tokenize:kL};function DL(e){return CL(e),e}function OL(e,t){let n;return r;function r(t){return e.enter(`content`),n=e.enter(`chunkContent`,{contentType:`content`}),i(t)}function i(t){return t===null?a(t):jI(t)?e.check(EL,o,a)(t):(e.consume(t),i)}function a(n){return e.exit(`chunkContent`),e.exit(`content`),t(n)}function o(t){return e.consume(t),e.exit(`chunkContent`),n.next=e.enter(`chunkContent`,{contentType:`content`,previous:n}),n=n.next,i}}function kL(e,t,n){let r=this;return i;function i(t){return e.exit(`chunkContent`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),RI(e,a,`linePrefix`)}function a(i){if(i===null||jI(i))return n(i);let a=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes(`codeIndented`)&&a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(i):e.interrupt(r.parser.constructs.flow,n,t)(i)}}function AL(e,t,n,r,i,a,o,s,c){let l=c||1/0,u=0;return d;function d(t){return t===60?(e.enter(r),e.enter(i),e.enter(a),e.consume(t),e.exit(a),f):t===null||t===32||t===41||DI(t)?n(t):(e.enter(r),e.enter(o),e.enter(s),e.enter(`chunkString`,{contentType:`string`}),h(t))}function f(n){return n===62?(e.enter(a),e.consume(n),e.exit(a),e.exit(i),e.exit(r),t):(e.enter(s),e.enter(`chunkString`,{contentType:`string`}),p(n))}function p(t){return t===62?(e.exit(`chunkString`),e.exit(s),f(t)):t===null||t===60||jI(t)?n(t):(e.consume(t),t===92?m:p)}function m(t){return t===60||t===62||t===92?(e.consume(t),p):p(t)}function h(i){return!u&&(i===null||i===41||MI(i))?(e.exit(`chunkString`),e.exit(s),e.exit(o),e.exit(r),t(i)):u<l&&i===40?(e.consume(i),u++,h):i===41?(e.consume(i),u--,h):i===null||i===32||i===40||DI(i)?n(i):(e.consume(i),i===92?g:h)}function g(t){return t===40||t===41||t===92?(e.consume(t),h):h(t)}}function jL(e,t,n,r,i,a){let o=this,s=0,c;return l;function l(t){return e.enter(r),e.enter(i),e.consume(t),e.exit(i),e.enter(a),u}function u(l){return s>999||l===null||l===91||l===93&&!c||l===94&&!s&&`_hiddenFootnoteSupport`in o.parser.constructs?n(l):l===93?(e.exit(a),e.enter(i),e.consume(l),e.exit(i),e.exit(r),t):jI(l)?(e.enter(`lineEnding`),e.consume(l),e.exit(`lineEnding`),u):(e.enter(`chunkString`,{contentType:`string`}),d(l))}function d(t){return t===null||t===91||t===93||jI(t)||s++>999?(e.exit(`chunkString`),u(t)):(e.consume(t),c||=!NI(t),t===92?f:d)}function f(t){return t===91||t===92||t===93?(e.consume(t),s++,d):d(t)}}function ML(e,t,n,r,i,a){let o;return s;function s(t){return t===34||t===39||t===40?(e.enter(r),e.enter(i),e.consume(t),e.exit(i),o=t===40?41:t,c):n(t)}function c(n){return n===o?(e.enter(i),e.consume(n),e.exit(i),e.exit(r),t):(e.enter(a),l(n))}function l(t){return t===o?(e.exit(a),c(o)):t===null?n(t):jI(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),RI(e,l,`linePrefix`)):(e.enter(`chunkString`,{contentType:`string`}),u(t))}function u(t){return t===o||t===null||jI(t)?(e.exit(`chunkString`),l(t)):(e.consume(t),t===92?d:u)}function d(t){return t===o||t===92?(e.consume(t),u):u(t)}}function NL(e,t){let n;return r;function r(i){return jI(i)?(e.enter(`lineEnding`),e.consume(i),e.exit(`lineEnding`),n=!0,r):NI(i)?RI(e,r,n?`linePrefix`:`lineSuffix`)(i):t(i)}}var PL={name:`definition`,tokenize:IL},FL={partial:!0,tokenize:LL};function IL(e,t,n){let r=this,i;return a;function a(t){return e.enter(`definition`),o(t)}function o(t){return jL.call(r,e,s,n,`definitionLabel`,`definitionLabelMarker`,`definitionLabelString`)(t)}function s(t){return i=CI(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),c):n(t)}function c(t){return MI(t)?NL(e,l)(t):l(t)}function l(t){return AL(e,u,n,`definitionDestination`,`definitionDestinationLiteral`,`definitionDestinationLiteralMarker`,`definitionDestinationRaw`,`definitionDestinationString`)(t)}function u(t){return e.attempt(FL,d,d)(t)}function d(t){return NI(t)?RI(e,f,`whitespace`)(t):f(t)}function f(a){return a===null||jI(a)?(e.exit(`definition`),r.parser.defined.push(i),t(a)):n(a)}}function LL(e,t,n){return r;function r(t){return MI(t)?NL(e,i)(t):n(t)}function i(t){return ML(e,a,n,`definitionTitle`,`definitionTitleMarker`,`definitionTitleString`)(t)}function a(t){return NI(t)?RI(e,o,`whitespace`)(t):o(t)}function o(e){return e===null||jI(e)?t(e):n(e)}}var RL={name:`hardBreakEscape`,tokenize:zL};function zL(e,t,n){return r;function r(t){return e.enter(`hardBreakEscape`),e.consume(t),i}function i(r){return jI(r)?(e.exit(`hardBreakEscape`),t(r)):n(r)}}var BL={name:`headingAtx`,resolve:VL,tokenize:HL};function VL(e,t){let n=e.length-2,r=3,i,a;return e[r][1].type===`whitespace`&&(r+=2),n-2>r&&e[n][1].type===`whitespace`&&(n-=2),e[n][1].type===`atxHeadingSequence`&&(r===n-1||n-4>r&&e[n-2][1].type===`whitespace`)&&(n-=r+1===n?2:4),n>r&&(i={type:`atxHeadingText`,start:e[r][1].start,end:e[n][1].end},a={type:`chunkText`,start:e[r][1].start,end:e[n][1].end,contentType:`text`},gI(e,r,n-r+1,[[`enter`,i,t],[`enter`,a,t],[`exit`,a,t],[`exit`,i,t]])),e}function HL(e,t,n){let r=0;return i;function i(t){return e.enter(`atxHeading`),a(t)}function a(t){return e.enter(`atxHeadingSequence`),o(t)}function o(t){return t===35&&r++<6?(e.consume(t),o):t===null||MI(t)?(e.exit(`atxHeadingSequence`),s(t)):n(t)}function s(n){return n===35?(e.enter(`atxHeadingSequence`),c(n)):n===null||jI(n)?(e.exit(`atxHeading`),t(n)):NI(n)?RI(e,s,`whitespace`)(n):(e.enter(`atxHeadingText`),l(n))}function c(t){return t===35?(e.consume(t),c):(e.exit(`atxHeadingSequence`),s(t))}function l(t){return t===null||t===35||MI(t)?(e.exit(`atxHeadingText`),s(t)):(e.consume(t),l)}}var UL=`address.article.aside.base.basefont.blockquote.body.caption.center.col.colgroup.dd.details.dialog.dir.div.dl.dt.fieldset.figcaption.figure.footer.form.frame.frameset.h1.h2.h3.h4.h5.h6.head.header.hr.html.iframe.legend.li.link.main.menu.menuitem.nav.noframes.ol.optgroup.option.p.param.search.section.summary.table.tbody.td.tfoot.th.thead.title.tr.track.ul`.split(`.`),WL=[`pre`,`script`,`style`,`textarea`],GL={concrete:!0,name:`htmlFlow`,resolveTo:JL,tokenize:YL},KL={partial:!0,tokenize:ZL},qL={partial:!0,tokenize:XL};function JL(e){let t=e.length;for(;t--&&(e[t][0]!==`enter`||e[t][1].type!==`htmlFlow`););return t>1&&e[t-2][1].type===`linePrefix`&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function YL(e,t,n){let r=this,i,a,o,s,c;return l;function l(e){return u(e)}function u(t){return e.enter(`htmlFlow`),e.enter(`htmlFlowData`),e.consume(t),d}function d(s){return s===33?(e.consume(s),f):s===47?(e.consume(s),a=!0,h):s===63?(e.consume(s),i=3,r.interrupt?t:F):wI(s)?(e.consume(s),o=String.fromCharCode(s),g):n(s)}function f(a){return a===45?(e.consume(a),i=2,p):a===91?(e.consume(a),i=5,s=0,m):wI(a)?(e.consume(a),i=4,r.interrupt?t:F):n(a)}function p(i){return i===45?(e.consume(i),r.interrupt?t:F):n(i)}function m(i){return i===`CDATA[`.charCodeAt(s++)?(e.consume(i),s===6?r.interrupt?t:O:m):n(i)}function h(t){return wI(t)?(e.consume(t),o=String.fromCharCode(t),g):n(t)}function g(s){if(s===null||s===47||s===62||MI(s)){let c=s===47,l=o.toLowerCase();return!c&&!a&&WL.includes(l)?(i=1,r.interrupt?t(s):O(s)):UL.includes(o.toLowerCase())?(i=6,c?(e.consume(s),_):r.interrupt?t(s):O(s)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(s):a?v(s):y(s))}return s===45||TI(s)?(e.consume(s),o+=String.fromCharCode(s),g):n(s)}function _(i){return i===62?(e.consume(i),r.interrupt?t:O):n(i)}function v(t){return NI(t)?(e.consume(t),v):E(t)}function y(t){return t===47?(e.consume(t),E):t===58||t===95||wI(t)?(e.consume(t),b):NI(t)?(e.consume(t),y):E(t)}function b(t){return t===45||t===46||t===58||t===95||TI(t)?(e.consume(t),b):x(t)}function x(t){return t===61?(e.consume(t),S):NI(t)?(e.consume(t),x):y(t)}function S(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),c=t,C):NI(t)?(e.consume(t),S):w(t)}function C(t){return t===c?(e.consume(t),c=null,T):t===null||jI(t)?n(t):(e.consume(t),C)}function w(t){return t===null||t===34||t===39||t===47||t===60||t===61||t===62||t===96||MI(t)?x(t):(e.consume(t),w)}function T(e){return e===47||e===62||NI(e)?y(e):n(e)}function E(t){return t===62?(e.consume(t),D):n(t)}function D(t){return t===null||jI(t)?O(t):NI(t)?(e.consume(t),D):n(t)}function O(t){return t===45&&i===2?(e.consume(t),j):t===60&&i===1?(e.consume(t),M):t===62&&i===4?(e.consume(t),te):t===63&&i===3?(e.consume(t),F):t===93&&i===5?(e.consume(t),P):jI(t)&&(i===6||i===7)?(e.exit(`htmlFlowData`),e.check(KL,ne,ee)(t)):t===null||jI(t)?(e.exit(`htmlFlowData`),ee(t)):(e.consume(t),O)}function ee(t){return e.check(qL,k,ne)(t)}function k(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),A}function A(t){return t===null||jI(t)?ee(t):(e.enter(`htmlFlowData`),O(t))}function j(t){return t===45?(e.consume(t),F):O(t)}function M(t){return t===47?(e.consume(t),o=``,N):O(t)}function N(t){if(t===62){let n=o.toLowerCase();return WL.includes(n)?(e.consume(t),te):O(t)}return wI(t)&&o.length<8?(e.consume(t),o+=String.fromCharCode(t),N):O(t)}function P(t){return t===93?(e.consume(t),F):O(t)}function F(t){return t===62?(e.consume(t),te):t===45&&i===2?(e.consume(t),F):O(t)}function te(t){return t===null||jI(t)?(e.exit(`htmlFlowData`),ne(t)):(e.consume(t),te)}function ne(n){return e.exit(`htmlFlow`),t(n)}}function XL(e,t,n){let r=this;return i;function i(t){return jI(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a):n(t)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}function ZL(e,t,n){return r;function r(r){return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),e.attempt($I,t,n)}}var QL={name:`htmlText`,tokenize:$L};function $L(e,t,n){let r=this,i,a,o;return s;function s(t){return e.enter(`htmlText`),e.enter(`htmlTextData`),e.consume(t),c}function c(t){return t===33?(e.consume(t),l):t===47?(e.consume(t),x):t===63?(e.consume(t),y):wI(t)?(e.consume(t),w):n(t)}function l(t){return t===45?(e.consume(t),u):t===91?(e.consume(t),a=0,m):wI(t)?(e.consume(t),v):n(t)}function u(t){return t===45?(e.consume(t),p):n(t)}function d(t){return t===null?n(t):t===45?(e.consume(t),f):jI(t)?(o=d,M(t)):(e.consume(t),d)}function f(t){return t===45?(e.consume(t),p):d(t)}function p(e){return e===62?j(e):e===45?f(e):d(e)}function m(t){return t===`CDATA[`.charCodeAt(a++)?(e.consume(t),a===6?h:m):n(t)}function h(t){return t===null?n(t):t===93?(e.consume(t),g):jI(t)?(o=h,M(t)):(e.consume(t),h)}function g(t){return t===93?(e.consume(t),_):h(t)}function _(t){return t===62?j(t):t===93?(e.consume(t),_):h(t)}function v(t){return t===null||t===62?j(t):jI(t)?(o=v,M(t)):(e.consume(t),v)}function y(t){return t===null?n(t):t===63?(e.consume(t),b):jI(t)?(o=y,M(t)):(e.consume(t),y)}function b(e){return e===62?j(e):y(e)}function x(t){return wI(t)?(e.consume(t),S):n(t)}function S(t){return t===45||TI(t)?(e.consume(t),S):C(t)}function C(t){return jI(t)?(o=C,M(t)):NI(t)?(e.consume(t),C):j(t)}function w(t){return t===45||TI(t)?(e.consume(t),w):t===47||t===62||MI(t)?T(t):n(t)}function T(t){return t===47?(e.consume(t),j):t===58||t===95||wI(t)?(e.consume(t),E):jI(t)?(o=T,M(t)):NI(t)?(e.consume(t),T):j(t)}function E(t){return t===45||t===46||t===58||t===95||TI(t)?(e.consume(t),E):D(t)}function D(t){return t===61?(e.consume(t),O):jI(t)?(o=D,M(t)):NI(t)?(e.consume(t),D):T(t)}function O(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),i=t,ee):jI(t)?(o=O,M(t)):NI(t)?(e.consume(t),O):(e.consume(t),k)}function ee(t){return t===i?(e.consume(t),i=void 0,A):t===null?n(t):jI(t)?(o=ee,M(t)):(e.consume(t),ee)}function k(t){return t===null||t===34||t===39||t===60||t===61||t===96?n(t):t===47||t===62||MI(t)?T(t):(e.consume(t),k)}function A(e){return e===47||e===62||MI(e)?T(e):n(e)}function j(r){return r===62?(e.consume(r),e.exit(`htmlTextData`),e.exit(`htmlText`),t):n(r)}function M(t){return e.exit(`htmlTextData`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),N}function N(t){return NI(t)?RI(e,P,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):P(t)}function P(t){return e.enter(`htmlTextData`),o(t)}}var eR={name:`labelEnd`,resolveAll:iR,resolveTo:aR,tokenize:oR},tR={tokenize:sR},nR={tokenize:cR},rR={tokenize:lR};function iR(e){let t=-1,n=[];for(;++t<e.length;){let r=e[t][1];if(n.push(e[t]),r.type===`labelImage`||r.type===`labelLink`||r.type===`labelEnd`){let e=r.type===`labelImage`?4:2;r.type=`data`,t+=e}}return e.length!==n.length&&gI(e,0,e.length,n),e}function aR(e,t){let n=e.length,r=0,i,a,o,s;for(;n--;)if(i=e[n][1],a){if(i.type===`link`||i.type===`labelLink`&&i._inactive)break;e[n][0]===`enter`&&i.type===`labelLink`&&(i._inactive=!0)}else if(o){if(e[n][0]===`enter`&&(i.type===`labelImage`||i.type===`labelLink`)&&!i._balanced&&(a=n,i.type!==`labelLink`)){r=2;break}}else i.type===`labelEnd`&&(o=n);let c={type:e[a][1].type===`labelLink`?`link`:`image`,start:{...e[a][1].start},end:{...e[e.length-1][1].end}},l={type:`label`,start:{...e[a][1].start},end:{...e[o][1].end}},u={type:`labelText`,start:{...e[a+r+2][1].end},end:{...e[o-2][1].start}};return s=[[`enter`,c,t],[`enter`,l,t]],s=_I(s,e.slice(a+1,a+r+3)),s=_I(s,[[`enter`,u,t]]),s=_I(s,KI(t.parser.constructs.insideSpan.null,e.slice(a+r+4,o-3),t)),s=_I(s,[[`exit`,u,t],e[o-2],e[o-1],[`exit`,l,t]]),s=_I(s,e.slice(o+1)),s=_I(s,[[`exit`,c,t]]),gI(e,a,e.length,s),e}function oR(e,t,n){let r=this,i=r.events.length,a,o;for(;i--;)if((r.events[i][1].type===`labelImage`||r.events[i][1].type===`labelLink`)&&!r.events[i][1]._balanced){a=r.events[i][1];break}return s;function s(t){return a?a._inactive?d(t):(o=r.parser.defined.includes(CI(r.sliceSerialize({start:a.end,end:r.now()}))),e.enter(`labelEnd`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelEnd`),c):n(t)}function c(t){return t===40?e.attempt(tR,u,o?u:d)(t):t===91?e.attempt(nR,u,o?l:d)(t):o?u(t):d(t)}function l(t){return e.attempt(rR,u,d)(t)}function u(e){return t(e)}function d(e){return a._balanced=!0,n(e)}}function sR(e,t,n){return r;function r(t){return e.enter(`resource`),e.enter(`resourceMarker`),e.consume(t),e.exit(`resourceMarker`),i}function i(t){return MI(t)?NL(e,a)(t):a(t)}function a(t){return t===41?u(t):AL(e,o,s,`resourceDestination`,`resourceDestinationLiteral`,`resourceDestinationLiteralMarker`,`resourceDestinationRaw`,`resourceDestinationString`,32)(t)}function o(t){return MI(t)?NL(e,c)(t):u(t)}function s(e){return n(e)}function c(t){return t===34||t===39||t===40?ML(e,l,n,`resourceTitle`,`resourceTitleMarker`,`resourceTitleString`)(t):u(t)}function l(t){return MI(t)?NL(e,u)(t):u(t)}function u(r){return r===41?(e.enter(`resourceMarker`),e.consume(r),e.exit(`resourceMarker`),e.exit(`resource`),t):n(r)}}function cR(e,t,n){let r=this;return i;function i(t){return jL.call(r,e,a,o,`reference`,`referenceMarker`,`referenceString`)(t)}function a(e){return r.parser.defined.includes(CI(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function o(e){return n(e)}}function lR(e,t,n){return r;function r(t){return e.enter(`reference`),e.enter(`referenceMarker`),e.consume(t),e.exit(`referenceMarker`),i}function i(r){return r===93?(e.enter(`referenceMarker`),e.consume(r),e.exit(`referenceMarker`),e.exit(`reference`),t):n(r)}}var uR={name:`labelStartImage`,resolveAll:eR.resolveAll,tokenize:dR};function dR(e,t,n){let r=this;return i;function i(t){return e.enter(`labelImage`),e.enter(`labelImageMarker`),e.consume(t),e.exit(`labelImageMarker`),a}function a(t){return t===91?(e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelImage`),o):n(t)}function o(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):t(e)}}var fR={name:`labelStartLink`,resolveAll:eR.resolveAll,tokenize:pR};function pR(e,t,n){let r=this;return i;function i(t){return e.enter(`labelLink`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelLink`),a}function a(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):t(e)}}var mR={name:`lineEnding`,tokenize:hR};function hR(e,t){return n;function n(n){return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),RI(e,t,`linePrefix`)}}var gR={name:`thematicBreak`,tokenize:_R};function _R(e,t,n){let r=0,i;return a;function a(t){return e.enter(`thematicBreak`),o(t)}function o(e){return i=e,s(e)}function s(a){return a===i?(e.enter(`thematicBreakSequence`),c(a)):r>=3&&(a===null||jI(a))?(e.exit(`thematicBreak`),t(a)):n(a)}function c(t){return t===i?(e.consume(t),r++,c):(e.exit(`thematicBreakSequence`),NI(t)?RI(e,s,`whitespace`)(t):s(t))}}var vR={continuation:{tokenize:SR},exit:wR,name:`list`,tokenize:xR},yR={partial:!0,tokenize:TR},bR={partial:!0,tokenize:CR};function xR(e,t,n){let r=this,i=r.events[r.events.length-1],a=i&&i[1].type===`linePrefix`?i[2].sliceSerialize(i[1],!0).length:0,o=0;return s;function s(t){let i=r.containerState.type||(t===42||t===43||t===45?`listUnordered`:`listOrdered`);if(i===`listUnordered`?!r.containerState.marker||t===r.containerState.marker:OI(t)){if(r.containerState.type||(r.containerState.type=i,e.enter(i,{_container:!0})),i===`listUnordered`)return e.enter(`listItemPrefix`),t===42||t===45?e.check(gR,n,l)(t):l(t);if(!r.interrupt||t===49)return e.enter(`listItemPrefix`),e.enter(`listItemValue`),c(t)}return n(t)}function c(t){return OI(t)&&++o<10?(e.consume(t),c):(!r.interrupt||o<2)&&(r.containerState.marker?t===r.containerState.marker:t===41||t===46)?(e.exit(`listItemValue`),l(t)):n(t)}function l(t){return e.enter(`listItemMarker`),e.consume(t),e.exit(`listItemMarker`),r.containerState.marker=r.containerState.marker||t,e.check($I,r.interrupt?n:u,e.attempt(yR,f,d))}function u(e){return r.containerState.initialBlankLine=!0,a++,f(e)}function d(t){return NI(t)?(e.enter(`listItemPrefixWhitespace`),e.consume(t),e.exit(`listItemPrefixWhitespace`),f):n(t)}function f(n){return r.containerState.size=a+r.sliceSerialize(e.exit(`listItemPrefix`),!0).length,t(n)}}function SR(e,t,n){let r=this;return r.containerState._closeFlow=void 0,e.check($I,i,a);function i(n){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,RI(e,t,`listItemIndent`,r.containerState.size+1)(n)}function a(n){return r.containerState.furtherBlankLines||!NI(n)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(n)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(bR,t,o)(n))}function o(i){return r.containerState._closeFlow=!0,r.interrupt=void 0,RI(e,e.attempt(vR,t,n),`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(i)}}function CR(e,t,n){let r=this;return RI(e,i,`listItemIndent`,r.containerState.size+1);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`listItemIndent`&&i[2].sliceSerialize(i[1],!0).length===r.containerState.size?t(e):n(e)}}function wR(e){e.exit(this.containerState.type)}function TR(e,t,n){let r=this;return RI(e,i,`listItemPrefixWhitespace`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:5);function i(e){let i=r.events[r.events.length-1];return!NI(e)&&i&&i[1].type===`listItemPrefixWhitespace`?t(e):n(e)}}var ER={name:`setextUnderline`,resolveTo:DR,tokenize:OR};function DR(e,t){let n=e.length,r,i,a;for(;n--;)if(e[n][0]===`enter`){if(e[n][1].type===`content`){r=n;break}e[n][1].type===`paragraph`&&(i=n)}else e[n][1].type===`content`&&e.splice(n,1),!a&&e[n][1].type===`definition`&&(a=n);let o={type:`setextHeading`,start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type=`setextHeadingText`,a?(e.splice(i,0,[`enter`,o,t]),e.splice(a+1,0,[`exit`,e[r][1],t]),e[r][1].end={...e[a][1].end}):e[r][1]=o,e.push([`exit`,o,t]),e}function OR(e,t,n){let r=this,i;return a;function a(t){let a=r.events.length,s;for(;a--;)if(r.events[a][1].type!==`lineEnding`&&r.events[a][1].type!==`linePrefix`&&r.events[a][1].type!==`content`){s=r.events[a][1].type===`paragraph`;break}return!r.parser.lazy[r.now().line]&&(r.interrupt||s)?(e.enter(`setextHeadingLine`),i=t,o(t)):n(t)}function o(t){return e.enter(`setextHeadingLineSequence`),s(t)}function s(t){return t===i?(e.consume(t),s):(e.exit(`setextHeadingLineSequence`),NI(t)?RI(e,c,`lineSuffix`)(t):c(t))}function c(r){return r===null||jI(r)?(e.exit(`setextHeadingLine`),t(r)):n(r)}}var kR={tokenize:AR};function AR(e){let t=this,n=e.attempt($I,r,e.attempt(this.parser.constructs.flowInitial,i,RI(e,e.attempt(this.parser.constructs.flow,i,e.attempt(TL,i)),`linePrefix`)));return n;function r(r){if(r===null){e.consume(r);return}return e.enter(`lineEndingBlank`),e.consume(r),e.exit(`lineEndingBlank`),t.currentConstruct=void 0,n}function i(r){if(r===null){e.consume(r);return}return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),t.currentConstruct=void 0,n}}var jR={resolveAll:FR()},MR=PR(`string`),NR=PR(`text`);function PR(e){return{resolveAll:FR(e===`text`?IR:void 0),tokenize:t};function t(t){let n=this,r=this.parser.constructs[e],i=t.attempt(r,a,o);return a;function a(e){return c(e)?i(e):o(e)}function o(e){if(e===null){t.consume(e);return}return t.enter(`data`),t.consume(e),s}function s(e){return c(e)?(t.exit(`data`),i(e)):(t.consume(e),s)}function c(e){if(e===null)return!0;let t=r[e],i=-1;if(t)for(;++i<t.length;){let e=t[i];if(!e.previous||e.previous.call(n,n.previous))return!0}return!1}}}function FR(e){return t;function t(t,n){let r=-1,i;for(;++r<=t.length;)i===void 0?t[r]&&t[r][1].type===`data`&&(i=r,r++):(!t[r]||t[r][1].type!==`data`)&&(r!==i+2&&(t[i][1].end=t[r-1][1].end,t.splice(i+2,r-i-2),r=i+2),i=void 0);return e?e(t,n):t}}function IR(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type===`lineEnding`)&&e[n-1][1].type===`data`){let r=e[n-1][1],i=t.sliceStream(r),a=i.length,o=-1,s=0,c;for(;a--;){let e=i[a];if(typeof e==`string`){for(o=e.length;e.charCodeAt(o-1)===32;)s++,o--;if(o)break;o=-1}else if(e===-2)c=!0,s++;else if(e!==-1){a++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(s=0),s){let i={type:n===e.length||c||s<2?`lineSuffix`:`hardBreakTrailing`,start:{_bufferIndex:a?o:r.start._bufferIndex+o,_index:r.start._index+a,line:r.end.line,column:r.end.column-s,offset:r.end.offset-s},end:{...r.end}};r.end={...i.start},r.start.offset===r.end.offset?Object.assign(r,i):(e.splice(n,0,[`enter`,i,t],[`exit`,i,t]),n+=2)}n++}return e}var LR=s({attentionMarkers:()=>GR,contentInitial:()=>zR,disable:()=>KR,document:()=>RR,flow:()=>VR,flowInitial:()=>BR,insideSpan:()=>WR,string:()=>HR,text:()=>UR}),RR={42:vR,43:vR,45:vR,48:vR,49:vR,50:vR,51:vR,52:vR,53:vR,54:vR,55:vR,56:vR,57:vR,62:tL},zR={91:PL},BR={[-2]:pL,[-1]:pL,32:pL},VR={35:BL,42:gR,45:[ER,gR],60:GL,61:ER,95:gR,96:uL,126:uL},HR={38:sL,92:aL},UR={[-5]:mR,[-4]:mR,[-3]:mR,33:uR,38:sL,42:qI,60:[ZI,QL],91:fR,92:[RL,aL],93:eR,95:qI,96:_L},WR={null:[qI,jR]},GR={null:[42,95]},KR={null:[]};function qR(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0},i={},a=[],o=[],s=[],c={attempt:C(x),check:C(S),consume:v,enter:y,exit:b,interrupt:C(S,{interrupt:!0})},l={code:null,containerState:{},defineSkip:h,events:[],now:m,parser:e,previous:null,sliceSerialize:f,sliceStream:p,write:d},u=t.tokenize.call(l,c);return t.resolveAll&&a.push(t),l;function d(e){return o=_I(o,e),g(),o[o.length-1]===null?(w(t,0),l.events=KI(a,l.events,l),l.events):[]}function f(e,t){return YR(p(e),t)}function p(e){return JR(o,e)}function m(){let{_bufferIndex:e,_index:t,line:n,column:i,offset:a}=r;return{_bufferIndex:e,_index:t,line:n,column:i,offset:a}}function h(e){i[e.line]=e.column,E()}function g(){let e;for(;r._index<o.length;){let t=o[r._index];if(typeof t==`string`)for(e=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===e&&r._bufferIndex<t.length;)_(t.charCodeAt(r._bufferIndex));else _(t)}}function _(e){u=u(e)}function v(e){jI(e)?(r.line++,r.column=1,r.offset+=e===-3?2:1,E()):e!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),l.previous=e}function y(e,t){let n=t||{};return n.type=e,n.start=m(),l.events.push([`enter`,n,l]),s.push(n),n}function b(e){let t=s.pop();return t.end=m(),l.events.push([`exit`,t,l]),t}function x(e,t){w(e,t.from)}function S(e,t){t.restore()}function C(e,t){return n;function n(n,r,i){let a,o,s,u;return Array.isArray(n)?f(n):`tokenize`in n?f([n]):d(n);function d(e){return t;function t(t){let n=t!==null&&e[t],r=t!==null&&e.null;return f([...Array.isArray(n)?n:n?[n]:[],...Array.isArray(r)?r:r?[r]:[]])(t)}}function f(e){return a=e,o=0,e.length===0?i:p(e[o])}function p(e){return n;function n(n){return u=T(),s=e,e.partial||(l.currentConstruct=e),e.name&&l.parser.constructs.disable.null.includes(e.name)?h(n):e.tokenize.call(t?Object.assign(Object.create(l),t):l,c,m,h)(n)}}function m(t){return e(s,u),r}function h(e){return u.restore(),++o<a.length?p(a[o]):i}}}function w(e,t){e.resolveAll&&!a.includes(e)&&a.push(e),e.resolve&&gI(l.events,t,l.events.length-t,e.resolve(l.events.slice(t),l)),e.resolveTo&&(l.events=e.resolveTo(l.events,l))}function T(){let e=m(),t=l.previous,n=l.currentConstruct,i=l.events.length,a=Array.from(s);return{from:i,restore:o};function o(){r=e,l.previous=t,l.currentConstruct=n,l.events.length=i,s=a,E()}}function E(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function JR(e,t){let n=t.start._index,r=t.start._bufferIndex,i=t.end._index,a=t.end._bufferIndex,o;if(n===i)o=[e[n].slice(r,a)];else{if(o=e.slice(n,i),r>-1){let e=o[0];typeof e==`string`?o[0]=e.slice(r):o.shift()}a>0&&o.push(e[i].slice(0,a))}return o}function YR(e,t){let n=-1,r=[],i;for(;++n<e.length;){let a=e[n],o;if(typeof a==`string`)o=a;else switch(a){case-5:o=`\r`;break;case-4:o=`
104
104
  `;break;case-3:o=`\r
105
- `;break;case-2:o=t?` `:` `;break;case-1:if(!t&&i)continue;o=` `;break;default:o=String.fromCharCode(a)}i=a===-2,r.push(o)}return r.join(``)}function YR(e){let t={constructs:vI([IR,...(e||{}).extensions||[]]),content:n(RI),defined:[],document:n(BI),flow:n(OR),lazy:{},string:n(jR),text:n(MR)};return t;function n(e){return n;function n(n){return KR(t,e,n)}}}function XR(e){for(;!SL(e););return e}var ZR=/[\0\t\n\r]/g;function QR(){let e=1,t=``,n=!0,r;return i;function i(i,a,o){let s=[],c,l,u,d,f;for(i=t+(typeof i==`string`?i.toString():new TextDecoder(a||void 0).decode(i)),u=0,t=``,n&&=(i.charCodeAt(0)===65279&&u++,void 0);u<i.length;){if(ZR.lastIndex=u,c=ZR.exec(i),d=c&&c.index!==void 0?c.index:i.length,f=i.charCodeAt(d),!c){t=i.slice(u);break}if(f===10&&u===d&&r)s.push(-3),r=void 0;else switch(r&&=(s.push(-5),void 0),u<d&&(s.push(i.slice(u,d)),e+=d-u),f){case 0:s.push(65533),e++;break;case 9:for(l=Math.ceil(e/4)*4,s.push(-2);e++<l;)s.push(-1);break;case 10:s.push(-4),e=1;break;default:r=!0,e=1}u=d+1}return o&&(r&&s.push(-5),t&&s.push(t),s.push(null)),s}}var $R=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function ez(e){return e.replace($R,tz)}function tz(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){let e=n.charCodeAt(1),t=e===120||e===88;return xI(n.slice(t?2:1),t?16:10)}return mI(n)||e}var nz={}.hasOwnProperty;function rz(e,t,n){return t&&typeof t==`object`&&(n=t,t=void 0),iz(n)(XR(YR(n).document().write(QR()(e,t,!0))))}function iz(e){let t={transforms:[],canContainEols:[`emphasis`,`fragment`,`heading`,`paragraph`,`strong`],enter:{autolink:a(ye),autolinkProtocol:T,autolinkEmail:T,atxHeading:a(he),blockQuote:a(ue),characterEscape:T,characterReference:T,codeFenced:a(de),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:a(de,o),codeText:a(fe,o),codeTextData:T,data:T,codeFlowValue:T,definition:a(pe),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:a(me),hardBreakEscape:a(ge),hardBreakTrailing:a(ge),htmlFlow:a(_e,o),htmlFlowData:T,htmlText:a(_e,o),htmlTextData:T,image:a(ve),label:o,link:a(ye),listItem:a(xe),listItemValue:f,listOrdered:a(be,d),listUnordered:a(be),paragraph:a(Se),reference:re,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:a(he),strong:a(Ce),thematicBreak:a(Te)},exit:{atxHeading:c(),atxHeadingSequence:x,autolink:c(),autolinkEmail:le,autolinkProtocol:ce,blockQuote:c(),characterEscapeValue:E,characterReferenceMarkerHexadecimal:ae,characterReferenceMarkerNumeric:ae,characterReferenceValue:oe,characterReference:se,codeFenced:c(g),codeFencedFence:h,codeFencedFenceInfo:p,codeFencedFenceMeta:m,codeFlowValue:E,codeIndented:c(_),codeText:c(A),codeTextData:E,data:E,definition:c(),definitionDestinationString:b,definitionLabelString:v,definitionTitleString:y,emphasis:c(),hardBreakEscape:c(O),hardBreakTrailing:c(O),htmlFlow:c(ee),htmlFlowData:E,htmlText:c(k),htmlTextData:E,image:c(M),label:P,labelText:N,lineEnding:D,link:c(j),listItem:c(),listOrdered:c(),listUnordered:c(),paragraph:c(),referenceString:ie,resourceDestinationString:F,resourceTitleString:te,resource:ne,setextHeading:c(w),setextHeadingLineSequence:C,setextHeadingText:S,strong:c(),thematicBreak:c()}};oz(t,(e||{}).mdastExtensions||[]);let n={};return r;function r(e){let r={type:`root`,children:[]},a={stack:[r],tokenStack:[],config:t,enter:s,exit:l,buffer:o,resume:u,data:n},c=[],d=-1;for(;++d<e.length;)(e[d][1].type===`listOrdered`||e[d][1].type===`listUnordered`)&&(e[d][0]===`enter`?c.push(d):d=i(e,c.pop(),d));for(d=-1;++d<e.length;){let n=t[e[d][0]];nz.call(n,e[d][1].type)&&n[e[d][1].type].call(Object.assign({sliceSerialize:e[d][2].sliceSerialize},a),e[d][1])}if(a.tokenStack.length>0){let e=a.tokenStack[a.tokenStack.length-1];(e[1]||cz).call(a,void 0,e[0])}for(r.position={start:az(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:az(e.length>0?e[e.length-2][1].end:{line:1,column:1,offset:0})},d=-1;++d<t.transforms.length;)r=t.transforms[d](r)||r;return r}function i(e,t,n){let r=t-1,i=-1,a=!1,o,s,c,l;for(;++r<=n;){let t=e[r];switch(t[1].type){case`listUnordered`:case`listOrdered`:case`blockQuote`:t[0]===`enter`?i++:i--,l=void 0;break;case`lineEndingBlank`:t[0]===`enter`&&(o&&!l&&!i&&!c&&(c=r),l=void 0);break;case`linePrefix`:case`listItemValue`:case`listItemMarker`:case`listItemPrefix`:case`listItemPrefixWhitespace`:break;default:l=void 0}if(!i&&t[0]===`enter`&&t[1].type===`listItemPrefix`||i===-1&&t[0]===`exit`&&(t[1].type===`listUnordered`||t[1].type===`listOrdered`)){if(o){let i=r;for(s=void 0;i--;){let t=e[i];if(t[1].type===`lineEnding`||t[1].type===`lineEndingBlank`){if(t[0]===`exit`)continue;s&&(e[s][1].type=`lineEndingBlank`,a=!0),t[1].type=`lineEnding`,s=i}else if(t[1].type!==`linePrefix`&&t[1].type!==`blockQuotePrefix`&&t[1].type!==`blockQuotePrefixWhitespace`&&t[1].type!==`blockQuoteMarker`&&t[1].type!==`listItemIndent`)break}c&&(!s||c<s)&&(o._spread=!0),o.end=Object.assign({},s?e[s][1].start:t[1].end),e.splice(s||r,0,[`exit`,o,t[2]]),r++,n++}if(t[1].type===`listItemPrefix`){let i={type:`listItem`,_spread:!1,start:Object.assign({},t[1].start),end:void 0};o=i,e.splice(r,0,[`enter`,i,t[2]]),r++,n++,c=void 0,l=!0}}}return e[t][1]._spread=a,n}function a(e,t){return n;function n(n){s.call(this,e(n),n),t&&t.call(this,n)}}function o(){this.stack.push({type:`fragment`,children:[]})}function s(e,t,n){this.stack[this.stack.length-1].children.push(e),this.stack.push(e),this.tokenStack.push([t,n||void 0]),e.position={start:az(t.start),end:void 0}}function c(e){return t;function t(t){e&&e.call(this,t),l.call(this,t)}}function l(e,t){let n=this.stack.pop(),r=this.tokenStack.pop();if(r)r[0].type!==e.type&&(t?t.call(this,e,r[0]):(r[1]||cz).call(this,e,r[0]));else throw Error("Cannot close `"+e.type+"` ("+DF({start:e.start,end:e.end})+`): it’s not open`);n.position.end=az(e.end)}function u(){return lI(this.stack.pop())}function d(){this.data.expectingFirstListItemValue=!0}function f(e){if(this.data.expectingFirstListItemValue){let t=this.stack[this.stack.length-2];t.start=Number.parseInt(this.sliceSerialize(e),10),this.data.expectingFirstListItemValue=void 0}}function p(){let e=this.resume(),t=this.stack[this.stack.length-1];t.lang=e}function m(){let e=this.resume(),t=this.stack[this.stack.length-1];t.meta=e}function h(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function g(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,``),this.data.flowCodeInside=void 0}function _(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e.replace(/(\r?\n|\r)$/g,``)}function v(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=SI(this.sliceSerialize(e)).toLowerCase()}function y(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function b(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function x(e){let t=this.stack[this.stack.length-1];t.depth||=this.sliceSerialize(e).length}function S(){this.data.setextHeadingSlurpLineEnding=!0}function C(e){let t=this.stack[this.stack.length-1];t.depth=this.sliceSerialize(e).codePointAt(0)===61?1:2}function w(){this.data.setextHeadingSlurpLineEnding=void 0}function T(e){let t=this.stack[this.stack.length-1].children,n=t[t.length-1];(!n||n.type!==`text`)&&(n=we(),n.position={start:az(e.start),end:void 0},t.push(n)),this.stack.push(n)}function E(e){let t=this.stack.pop();t.value+=this.sliceSerialize(e),t.position.end=az(e.end)}function D(e){let n=this.stack[this.stack.length-1];if(this.data.atHardBreak){let t=n.children[n.children.length-1];t.position.end=az(e.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(n.type)&&(T.call(this,e),E.call(this,e))}function O(){this.data.atHardBreak=!0}function ee(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function k(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function A(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function j(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||`shortcut`;e.type+=`Reference`,e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function M(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||`shortcut`;e.type+=`Reference`,e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function N(e){let t=this.sliceSerialize(e),n=this.stack[this.stack.length-2];n.label=ez(t),n.identifier=SI(t).toLowerCase()}function P(){let e=this.stack[this.stack.length-1],t=this.resume(),n=this.stack[this.stack.length-1];this.data.inReference=!0,n.type===`link`?n.children=e.children:n.alt=t}function F(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function te(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function ne(){this.data.inReference=void 0}function re(){this.data.referenceType=`collapsed`}function ie(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=SI(this.sliceSerialize(e)).toLowerCase(),this.data.referenceType=`full`}function ae(e){this.data.characterReferenceType=e.type}function oe(e){let t=this.sliceSerialize(e),n=this.data.characterReferenceType,r;n?(r=xI(t,n===`characterReferenceMarkerNumeric`?10:16),this.data.characterReferenceType=void 0):r=mI(t);let i=this.stack[this.stack.length-1];i.value+=r}function se(e){let t=this.stack.pop();t.position.end=az(e.end)}function ce(e){E.call(this,e);let t=this.stack[this.stack.length-1];t.url=this.sliceSerialize(e)}function le(e){E.call(this,e);let t=this.stack[this.stack.length-1];t.url=`mailto:`+this.sliceSerialize(e)}function ue(){return{type:`blockquote`,children:[]}}function de(){return{type:`code`,lang:null,meta:null,value:``}}function fe(){return{type:`inlineCode`,value:``}}function pe(){return{type:`definition`,identifier:``,label:null,title:null,url:``}}function me(){return{type:`emphasis`,children:[]}}function he(){return{type:`heading`,depth:0,children:[]}}function ge(){return{type:`break`}}function _e(){return{type:`html`,value:``}}function ve(){return{type:`image`,title:null,url:``,alt:null}}function ye(){return{type:`link`,title:null,url:``,children:[]}}function be(e){return{type:`list`,ordered:e.type===`listOrdered`,start:null,spread:e._spread,children:[]}}function xe(e){return{type:`listItem`,spread:e._spread,checked:null,children:[]}}function Se(){return{type:`paragraph`,children:[]}}function Ce(){return{type:`strong`,children:[]}}function we(){return{type:`text`,value:``}}function Te(){return{type:`thematicBreak`}}}function az(e){return{line:e.line,column:e.column,offset:e.offset}}function oz(e,t){let n=-1;for(;++n<t.length;){let r=t[n];Array.isArray(r)?oz(e,r):sz(e,r)}}function sz(e,t){let n;for(n in t)if(nz.call(t,n))switch(n){case`canContainEols`:{let r=t[n];r&&e[n].push(...r);break}case`transforms`:{let r=t[n];r&&e[n].push(...r);break}case`enter`:case`exit`:{let r=t[n];r&&Object.assign(e[n],r);break}}}function cz(e,t){throw Error(e?"Cannot close `"+e.type+"` ("+DF({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+DF({start:t.start,end:t.end})+`) is open`:"Cannot close document, a token (`"+t.type+"`, "+DF({start:t.start,end:t.end})+`) is still open`)}function lz(e){let t=this;t.parser=n;function n(n){return rz(n,{...t.data(`settings`),...e,extensions:t.data(`micromarkExtensions`)||[],mdastExtensions:t.data(`fromMarkdownExtensions`)||[]})}}function uz(e,t){let n={type:`element`,tagName:`blockquote`,properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function dz(e,t){let n={type:`element`,tagName:`br`,properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:`text`,value:`
106
- `}]}function fz(e,t){let n=t.value?t.value+`
107
- `:``,r={},i=t.lang?t.lang.split(/\s+/):[];i.length>0&&(r.className=[`language-`+i[0]]);let a={type:`element`,tagName:`code`,properties:r,children:[{type:`text`,value:n}]};return t.meta&&(a.data={meta:t.meta}),e.patch(t,a),a=e.applyData(t,a),a={type:`element`,tagName:`pre`,properties:{},children:[a]},e.patch(t,a),a}function pz(e,t){let n={type:`element`,tagName:`del`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function mz(e,t){let n={type:`element`,tagName:`em`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function hz(e,t){let n=typeof e.options.clobberPrefix==`string`?e.options.clobberPrefix:`user-content-`,r=String(t.identifier).toUpperCase(),i=II(r.toLowerCase()),a=e.footnoteOrder.indexOf(r),o,s=e.footnoteCounts.get(r);s===void 0?(s=0,e.footnoteOrder.push(r),o=e.footnoteOrder.length):o=a+1,s+=1,e.footnoteCounts.set(r,s);let c={type:`element`,tagName:`a`,properties:{href:`#`+n+`fn-`+i,id:n+`fnref-`+i+(s>1?`-`+s:``),dataFootnoteRef:!0,ariaDescribedBy:[`footnote-label`]},children:[{type:`text`,value:String(o)}]};e.patch(t,c);let l={type:`element`,tagName:`sup`,properties:{},children:[c]};return e.patch(t,l),e.applyData(t,l)}function gz(e,t){let n={type:`element`,tagName:`h`+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function _z(e,t){if(e.options.allowDangerousHtml){let n={type:`raw`,value:t.value};return e.patch(t,n),e.applyData(t,n)}}function vz(e,t){let n=t.referenceType,r=`]`;if(n===`collapsed`?r+=`[]`:n===`full`&&(r+=`[`+(t.label||t.identifier)+`]`),t.type===`imageReference`)return[{type:`text`,value:`![`+t.alt+r}];let i=e.all(t),a=i[0];a&&a.type===`text`?a.value=`[`+a.value:i.unshift({type:`text`,value:`[`});let o=i[i.length-1];return o&&o.type===`text`?o.value+=r:i.push({type:`text`,value:r}),i}function yz(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return vz(e,t);let i={src:II(r.url||``),alt:t.alt};r.title!==null&&r.title!==void 0&&(i.title=r.title);let a={type:`element`,tagName:`img`,properties:i,children:[]};return e.patch(t,a),e.applyData(t,a)}function bz(e,t){let n={src:II(t.url)};t.alt!==null&&t.alt!==void 0&&(n.alt=t.alt),t.title!==null&&t.title!==void 0&&(n.title=t.title);let r={type:`element`,tagName:`img`,properties:n,children:[]};return e.patch(t,r),e.applyData(t,r)}function xz(e,t){let n={type:`text`,value:t.value.replace(/\r?\n|\r/g,` `)};e.patch(t,n);let r={type:`element`,tagName:`code`,properties:{},children:[n]};return e.patch(t,r),e.applyData(t,r)}function Sz(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return vz(e,t);let i={href:II(r.url||``)};r.title!==null&&r.title!==void 0&&(i.title=r.title);let a={type:`element`,tagName:`a`,properties:i,children:e.all(t)};return e.patch(t,a),e.applyData(t,a)}function Cz(e,t){let n={href:II(t.url)};t.title!==null&&t.title!==void 0&&(n.title=t.title);let r={type:`element`,tagName:`a`,properties:n,children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function wz(e,t,n){let r=e.all(t),i=n?Tz(n):Ez(t),a={},o=[];if(typeof t.checked==`boolean`){let e=r[0],n;e&&e.type===`element`&&e.tagName===`p`?n=e:(n={type:`element`,tagName:`p`,properties:{},children:[]},r.unshift(n)),n.children.length>0&&n.children.unshift({type:`text`,value:` `}),n.children.unshift({type:`element`,tagName:`input`,properties:{type:`checkbox`,checked:t.checked,disabled:!0},children:[]}),a.className=[`task-list-item`]}let s=-1;for(;++s<r.length;){let e=r[s];(i||s!==0||e.type!==`element`||e.tagName!==`p`)&&o.push({type:`text`,value:`
105
+ `;break;case-2:o=t?` `:` `;break;case-1:if(!t&&i)continue;o=` `;break;default:o=String.fromCharCode(a)}i=a===-2,r.push(o)}return r.join(``)}function XR(e){let t={constructs:yI([LR,...(e||{}).extensions||[]]),content:n(zI),defined:[],document:n(VI),flow:n(kR),lazy:{},string:n(MR),text:n(NR)};return t;function n(e){return n;function n(n){return qR(t,e,n)}}}function ZR(e){for(;!CL(e););return e}var QR=/[\0\t\n\r]/g;function $R(){let e=1,t=``,n=!0,r;return i;function i(i,a,o){let s=[],c,l,u,d,f;for(i=t+(typeof i==`string`?i.toString():new TextDecoder(a||void 0).decode(i)),u=0,t=``,n&&=(i.charCodeAt(0)===65279&&u++,void 0);u<i.length;){if(QR.lastIndex=u,c=QR.exec(i),d=c&&c.index!==void 0?c.index:i.length,f=i.charCodeAt(d),!c){t=i.slice(u);break}if(f===10&&u===d&&r)s.push(-3),r=void 0;else switch(r&&=(s.push(-5),void 0),u<d&&(s.push(i.slice(u,d)),e+=d-u),f){case 0:s.push(65533),e++;break;case 9:for(l=Math.ceil(e/4)*4,s.push(-2);e++<l;)s.push(-1);break;case 10:s.push(-4),e=1;break;default:r=!0,e=1}u=d+1}return o&&(r&&s.push(-5),t&&s.push(t),s.push(null)),s}}var ez=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function tz(e){return e.replace(ez,nz)}function nz(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){let e=n.charCodeAt(1),t=e===120||e===88;return SI(n.slice(t?2:1),t?16:10)}return hI(n)||e}var rz={}.hasOwnProperty;function iz(e,t,n){return t&&typeof t==`object`&&(n=t,t=void 0),az(n)(ZR(XR(n).document().write($R()(e,t,!0))))}function az(e){let t={transforms:[],canContainEols:[`emphasis`,`fragment`,`heading`,`paragraph`,`strong`],enter:{autolink:a(ye),autolinkProtocol:T,autolinkEmail:T,atxHeading:a(he),blockQuote:a(ue),characterEscape:T,characterReference:T,codeFenced:a(de),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:a(de,o),codeText:a(fe,o),codeTextData:T,data:T,codeFlowValue:T,definition:a(pe),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:a(me),hardBreakEscape:a(ge),hardBreakTrailing:a(ge),htmlFlow:a(_e,o),htmlFlowData:T,htmlText:a(_e,o),htmlTextData:T,image:a(ve),label:o,link:a(ye),listItem:a(xe),listItemValue:f,listOrdered:a(be,d),listUnordered:a(be),paragraph:a(Se),reference:re,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:a(he),strong:a(Ce),thematicBreak:a(Te)},exit:{atxHeading:c(),atxHeadingSequence:x,autolink:c(),autolinkEmail:le,autolinkProtocol:ce,blockQuote:c(),characterEscapeValue:E,characterReferenceMarkerHexadecimal:ae,characterReferenceMarkerNumeric:ae,characterReferenceValue:oe,characterReference:se,codeFenced:c(g),codeFencedFence:h,codeFencedFenceInfo:p,codeFencedFenceMeta:m,codeFlowValue:E,codeIndented:c(_),codeText:c(A),codeTextData:E,data:E,definition:c(),definitionDestinationString:b,definitionLabelString:v,definitionTitleString:y,emphasis:c(),hardBreakEscape:c(O),hardBreakTrailing:c(O),htmlFlow:c(ee),htmlFlowData:E,htmlText:c(k),htmlTextData:E,image:c(M),label:P,labelText:N,lineEnding:D,link:c(j),listItem:c(),listOrdered:c(),listUnordered:c(),paragraph:c(),referenceString:ie,resourceDestinationString:F,resourceTitleString:te,resource:ne,setextHeading:c(w),setextHeadingLineSequence:C,setextHeadingText:S,strong:c(),thematicBreak:c()}};sz(t,(e||{}).mdastExtensions||[]);let n={};return r;function r(e){let r={type:`root`,children:[]},a={stack:[r],tokenStack:[],config:t,enter:s,exit:l,buffer:o,resume:u,data:n},c=[],d=-1;for(;++d<e.length;)(e[d][1].type===`listOrdered`||e[d][1].type===`listUnordered`)&&(e[d][0]===`enter`?c.push(d):d=i(e,c.pop(),d));for(d=-1;++d<e.length;){let n=t[e[d][0]];rz.call(n,e[d][1].type)&&n[e[d][1].type].call(Object.assign({sliceSerialize:e[d][2].sliceSerialize},a),e[d][1])}if(a.tokenStack.length>0){let e=a.tokenStack[a.tokenStack.length-1];(e[1]||lz).call(a,void 0,e[0])}for(r.position={start:oz(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:oz(e.length>0?e[e.length-2][1].end:{line:1,column:1,offset:0})},d=-1;++d<t.transforms.length;)r=t.transforms[d](r)||r;return r}function i(e,t,n){let r=t-1,i=-1,a=!1,o,s,c,l;for(;++r<=n;){let t=e[r];switch(t[1].type){case`listUnordered`:case`listOrdered`:case`blockQuote`:t[0]===`enter`?i++:i--,l=void 0;break;case`lineEndingBlank`:t[0]===`enter`&&(o&&!l&&!i&&!c&&(c=r),l=void 0);break;case`linePrefix`:case`listItemValue`:case`listItemMarker`:case`listItemPrefix`:case`listItemPrefixWhitespace`:break;default:l=void 0}if(!i&&t[0]===`enter`&&t[1].type===`listItemPrefix`||i===-1&&t[0]===`exit`&&(t[1].type===`listUnordered`||t[1].type===`listOrdered`)){if(o){let i=r;for(s=void 0;i--;){let t=e[i];if(t[1].type===`lineEnding`||t[1].type===`lineEndingBlank`){if(t[0]===`exit`)continue;s&&(e[s][1].type=`lineEndingBlank`,a=!0),t[1].type=`lineEnding`,s=i}else if(t[1].type!==`linePrefix`&&t[1].type!==`blockQuotePrefix`&&t[1].type!==`blockQuotePrefixWhitespace`&&t[1].type!==`blockQuoteMarker`&&t[1].type!==`listItemIndent`)break}c&&(!s||c<s)&&(o._spread=!0),o.end=Object.assign({},s?e[s][1].start:t[1].end),e.splice(s||r,0,[`exit`,o,t[2]]),r++,n++}if(t[1].type===`listItemPrefix`){let i={type:`listItem`,_spread:!1,start:Object.assign({},t[1].start),end:void 0};o=i,e.splice(r,0,[`enter`,i,t[2]]),r++,n++,c=void 0,l=!0}}}return e[t][1]._spread=a,n}function a(e,t){return n;function n(n){s.call(this,e(n),n),t&&t.call(this,n)}}function o(){this.stack.push({type:`fragment`,children:[]})}function s(e,t,n){this.stack[this.stack.length-1].children.push(e),this.stack.push(e),this.tokenStack.push([t,n||void 0]),e.position={start:oz(t.start),end:void 0}}function c(e){return t;function t(t){e&&e.call(this,t),l.call(this,t)}}function l(e,t){let n=this.stack.pop(),r=this.tokenStack.pop();if(r)r[0].type!==e.type&&(t?t.call(this,e,r[0]):(r[1]||lz).call(this,e,r[0]));else throw Error("Cannot close `"+e.type+"` ("+OF({start:e.start,end:e.end})+`): it’s not open`);n.position.end=oz(e.end)}function u(){return uI(this.stack.pop())}function d(){this.data.expectingFirstListItemValue=!0}function f(e){if(this.data.expectingFirstListItemValue){let t=this.stack[this.stack.length-2];t.start=Number.parseInt(this.sliceSerialize(e),10),this.data.expectingFirstListItemValue=void 0}}function p(){let e=this.resume(),t=this.stack[this.stack.length-1];t.lang=e}function m(){let e=this.resume(),t=this.stack[this.stack.length-1];t.meta=e}function h(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function g(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,``),this.data.flowCodeInside=void 0}function _(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e.replace(/(\r?\n|\r)$/g,``)}function v(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=CI(this.sliceSerialize(e)).toLowerCase()}function y(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function b(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function x(e){let t=this.stack[this.stack.length-1];t.depth||=this.sliceSerialize(e).length}function S(){this.data.setextHeadingSlurpLineEnding=!0}function C(e){let t=this.stack[this.stack.length-1];t.depth=this.sliceSerialize(e).codePointAt(0)===61?1:2}function w(){this.data.setextHeadingSlurpLineEnding=void 0}function T(e){let t=this.stack[this.stack.length-1].children,n=t[t.length-1];(!n||n.type!==`text`)&&(n=we(),n.position={start:oz(e.start),end:void 0},t.push(n)),this.stack.push(n)}function E(e){let t=this.stack.pop();t.value+=this.sliceSerialize(e),t.position.end=oz(e.end)}function D(e){let n=this.stack[this.stack.length-1];if(this.data.atHardBreak){let t=n.children[n.children.length-1];t.position.end=oz(e.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(n.type)&&(T.call(this,e),E.call(this,e))}function O(){this.data.atHardBreak=!0}function ee(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function k(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function A(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function j(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||`shortcut`;e.type+=`Reference`,e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function M(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||`shortcut`;e.type+=`Reference`,e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function N(e){let t=this.sliceSerialize(e),n=this.stack[this.stack.length-2];n.label=tz(t),n.identifier=CI(t).toLowerCase()}function P(){let e=this.stack[this.stack.length-1],t=this.resume(),n=this.stack[this.stack.length-1];this.data.inReference=!0,n.type===`link`?n.children=e.children:n.alt=t}function F(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function te(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function ne(){this.data.inReference=void 0}function re(){this.data.referenceType=`collapsed`}function ie(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=CI(this.sliceSerialize(e)).toLowerCase(),this.data.referenceType=`full`}function ae(e){this.data.characterReferenceType=e.type}function oe(e){let t=this.sliceSerialize(e),n=this.data.characterReferenceType,r;n?(r=SI(t,n===`characterReferenceMarkerNumeric`?10:16),this.data.characterReferenceType=void 0):r=hI(t);let i=this.stack[this.stack.length-1];i.value+=r}function se(e){let t=this.stack.pop();t.position.end=oz(e.end)}function ce(e){E.call(this,e);let t=this.stack[this.stack.length-1];t.url=this.sliceSerialize(e)}function le(e){E.call(this,e);let t=this.stack[this.stack.length-1];t.url=`mailto:`+this.sliceSerialize(e)}function ue(){return{type:`blockquote`,children:[]}}function de(){return{type:`code`,lang:null,meta:null,value:``}}function fe(){return{type:`inlineCode`,value:``}}function pe(){return{type:`definition`,identifier:``,label:null,title:null,url:``}}function me(){return{type:`emphasis`,children:[]}}function he(){return{type:`heading`,depth:0,children:[]}}function ge(){return{type:`break`}}function _e(){return{type:`html`,value:``}}function ve(){return{type:`image`,title:null,url:``,alt:null}}function ye(){return{type:`link`,title:null,url:``,children:[]}}function be(e){return{type:`list`,ordered:e.type===`listOrdered`,start:null,spread:e._spread,children:[]}}function xe(e){return{type:`listItem`,spread:e._spread,checked:null,children:[]}}function Se(){return{type:`paragraph`,children:[]}}function Ce(){return{type:`strong`,children:[]}}function we(){return{type:`text`,value:``}}function Te(){return{type:`thematicBreak`}}}function oz(e){return{line:e.line,column:e.column,offset:e.offset}}function sz(e,t){let n=-1;for(;++n<t.length;){let r=t[n];Array.isArray(r)?sz(e,r):cz(e,r)}}function cz(e,t){let n;for(n in t)if(rz.call(t,n))switch(n){case`canContainEols`:{let r=t[n];r&&e[n].push(...r);break}case`transforms`:{let r=t[n];r&&e[n].push(...r);break}case`enter`:case`exit`:{let r=t[n];r&&Object.assign(e[n],r);break}}}function lz(e,t){throw Error(e?"Cannot close `"+e.type+"` ("+OF({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+OF({start:t.start,end:t.end})+`) is open`:"Cannot close document, a token (`"+t.type+"`, "+OF({start:t.start,end:t.end})+`) is still open`)}function uz(e){let t=this;t.parser=n;function n(n){return iz(n,{...t.data(`settings`),...e,extensions:t.data(`micromarkExtensions`)||[],mdastExtensions:t.data(`fromMarkdownExtensions`)||[]})}}function dz(e,t){let n={type:`element`,tagName:`blockquote`,properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function fz(e,t){let n={type:`element`,tagName:`br`,properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:`text`,value:`
106
+ `}]}function pz(e,t){let n=t.value?t.value+`
107
+ `:``,r={},i=t.lang?t.lang.split(/\s+/):[];i.length>0&&(r.className=[`language-`+i[0]]);let a={type:`element`,tagName:`code`,properties:r,children:[{type:`text`,value:n}]};return t.meta&&(a.data={meta:t.meta}),e.patch(t,a),a=e.applyData(t,a),a={type:`element`,tagName:`pre`,properties:{},children:[a]},e.patch(t,a),a}function mz(e,t){let n={type:`element`,tagName:`del`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function hz(e,t){let n={type:`element`,tagName:`em`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function gz(e,t){let n=typeof e.options.clobberPrefix==`string`?e.options.clobberPrefix:`user-content-`,r=String(t.identifier).toUpperCase(),i=LI(r.toLowerCase()),a=e.footnoteOrder.indexOf(r),o,s=e.footnoteCounts.get(r);s===void 0?(s=0,e.footnoteOrder.push(r),o=e.footnoteOrder.length):o=a+1,s+=1,e.footnoteCounts.set(r,s);let c={type:`element`,tagName:`a`,properties:{href:`#`+n+`fn-`+i,id:n+`fnref-`+i+(s>1?`-`+s:``),dataFootnoteRef:!0,ariaDescribedBy:[`footnote-label`]},children:[{type:`text`,value:String(o)}]};e.patch(t,c);let l={type:`element`,tagName:`sup`,properties:{},children:[c]};return e.patch(t,l),e.applyData(t,l)}function _z(e,t){let n={type:`element`,tagName:`h`+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function vz(e,t){if(e.options.allowDangerousHtml){let n={type:`raw`,value:t.value};return e.patch(t,n),e.applyData(t,n)}}function yz(e,t){let n=t.referenceType,r=`]`;if(n===`collapsed`?r+=`[]`:n===`full`&&(r+=`[`+(t.label||t.identifier)+`]`),t.type===`imageReference`)return[{type:`text`,value:`![`+t.alt+r}];let i=e.all(t),a=i[0];a&&a.type===`text`?a.value=`[`+a.value:i.unshift({type:`text`,value:`[`});let o=i[i.length-1];return o&&o.type===`text`?o.value+=r:i.push({type:`text`,value:r}),i}function bz(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return yz(e,t);let i={src:LI(r.url||``),alt:t.alt};r.title!==null&&r.title!==void 0&&(i.title=r.title);let a={type:`element`,tagName:`img`,properties:i,children:[]};return e.patch(t,a),e.applyData(t,a)}function xz(e,t){let n={src:LI(t.url)};t.alt!==null&&t.alt!==void 0&&(n.alt=t.alt),t.title!==null&&t.title!==void 0&&(n.title=t.title);let r={type:`element`,tagName:`img`,properties:n,children:[]};return e.patch(t,r),e.applyData(t,r)}function Sz(e,t){let n={type:`text`,value:t.value.replace(/\r?\n|\r/g,` `)};e.patch(t,n);let r={type:`element`,tagName:`code`,properties:{},children:[n]};return e.patch(t,r),e.applyData(t,r)}function Cz(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return yz(e,t);let i={href:LI(r.url||``)};r.title!==null&&r.title!==void 0&&(i.title=r.title);let a={type:`element`,tagName:`a`,properties:i,children:e.all(t)};return e.patch(t,a),e.applyData(t,a)}function wz(e,t){let n={href:LI(t.url)};t.title!==null&&t.title!==void 0&&(n.title=t.title);let r={type:`element`,tagName:`a`,properties:n,children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function Tz(e,t,n){let r=e.all(t),i=n?Ez(n):Dz(t),a={},o=[];if(typeof t.checked==`boolean`){let e=r[0],n;e&&e.type===`element`&&e.tagName===`p`?n=e:(n={type:`element`,tagName:`p`,properties:{},children:[]},r.unshift(n)),n.children.length>0&&n.children.unshift({type:`text`,value:` `}),n.children.unshift({type:`element`,tagName:`input`,properties:{type:`checkbox`,checked:t.checked,disabled:!0},children:[]}),a.className=[`task-list-item`]}let s=-1;for(;++s<r.length;){let e=r[s];(i||s!==0||e.type!==`element`||e.tagName!==`p`)&&o.push({type:`text`,value:`
108
108
  `}),e.type===`element`&&e.tagName===`p`&&!i?o.push(...e.children):o.push(e)}let c=r[r.length-1];c&&(i||c.type!==`element`||c.tagName!==`p`)&&o.push({type:`text`,value:`
109
- `});let l={type:`element`,tagName:`li`,properties:a,children:o};return e.patch(t,l),e.applyData(t,l)}function Tz(e){let t=!1;if(e.type===`list`){t=e.spread||!1;let n=e.children,r=-1;for(;!t&&++r<n.length;)t=Ez(n[r])}return t}function Ez(e){return e.spread??e.children.length>1}function Dz(e,t){let n={},r=e.all(t),i=-1;for(typeof t.start==`number`&&t.start!==1&&(n.start=t.start);++i<r.length;){let e=r[i];if(e.type===`element`&&e.tagName===`li`&&e.properties&&Array.isArray(e.properties.className)&&e.properties.className.includes(`task-list-item`)){n.className=[`contains-task-list`];break}}let a={type:`element`,tagName:t.ordered?`ol`:`ul`,properties:n,children:e.wrap(r,!0)};return e.patch(t,a),e.applyData(t,a)}function Oz(e,t){let n={type:`element`,tagName:`p`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function kz(e,t){let n={type:`root`,children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function Az(e,t){let n={type:`element`,tagName:`strong`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function jz(e,t){let n=e.all(t),r=n.shift(),i=[];if(r){let n={type:`element`,tagName:`thead`,properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],n),i.push(n)}if(n.length>0){let r={type:`element`,tagName:`tbody`,properties:{},children:e.wrap(n,!0)},a=wF(t.children[1]),o=CF(t.children[t.children.length-1]);a&&o&&(r.position={start:a,end:o}),i.push(r)}let a={type:`element`,tagName:`table`,properties:{},children:e.wrap(i,!0)};return e.patch(t,a),e.applyData(t,a)}function Mz(e,t,n){let r=n?n.children:void 0,i=(r?r.indexOf(t):1)===0?`th`:`td`,a=n&&n.type===`table`?n.align:void 0,o=a?a.length:t.children.length,s=-1,c=[];for(;++s<o;){let n=t.children[s],r={},o=a?a[s]:void 0;o&&(r.align=o);let l={type:`element`,tagName:i,properties:r,children:[]};n&&(l.children=e.all(n),e.patch(n,l),l=e.applyData(n,l)),c.push(l)}let l={type:`element`,tagName:`tr`,properties:{},children:e.wrap(c,!0)};return e.patch(t,l),e.applyData(t,l)}function Nz(e,t){let n={type:`element`,tagName:`td`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}var Pz=9,Fz=32;function Iz(e){let t=String(e),n=/\r?\n|\r/g,r=n.exec(t),i=0,a=[];for(;r;)a.push(Lz(t.slice(i,r.index),i>0,!0),r[0]),i=r.index+r[0].length,r=n.exec(t);return a.push(Lz(t.slice(i),i>0,!1)),a.join(``)}function Lz(e,t,n){let r=0,i=e.length;if(t){let t=e.codePointAt(r);for(;t===Pz||t===Fz;)r++,t=e.codePointAt(r)}if(n){let t=e.codePointAt(i-1);for(;t===Pz||t===Fz;)i--,t=e.codePointAt(i-1)}return i>r?e.slice(r,i):``}function Rz(e,t){let n={type:`text`,value:Iz(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function zz(e,t){let n={type:`element`,tagName:`hr`,properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}var Bz={blockquote:uz,break:dz,code:fz,delete:pz,emphasis:mz,footnoteReference:hz,heading:gz,html:_z,imageReference:yz,image:bz,inlineCode:xz,linkReference:Sz,link:Cz,listItem:wz,list:Dz,paragraph:Oz,root:kz,strong:Az,table:jz,tableCell:Nz,tableRow:Mz,text:Rz,thematicBreak:zz,toml:Vz,yaml:Vz,definition:Vz,footnoteDefinition:Vz};function Vz(){}var{defineProperty:Hz}=Object,Uz=typeof self==`object`?self:globalThis,Wz=(e,t)=>{switch(e){case`Function`:case`SharedWorker`:case`Worker`:case`eval`:case`setInterval`:case`setTimeout`:throw TypeError(`unable to deserialize `+e)}return new Uz[e](t)},Gz=(e,t)=>{let n=(t,n)=>(e.set(n,t),t),r=i=>{if(e.has(i))return e.get(i);let[a,o]=t[i];switch(a){case 0:case-1:return n(o,i);case 1:{let e=n([],i);for(let t of o)e.push(r(t));return e}case 2:{let e=n({},i);for(let[t,n]of o){let i=r(t),a=r(n);i===`__proto__`?Hz(e,i,{value:a,configurable:!0,enumerable:!0,writable:!0}):e[i]=a}return e}case 3:return n(new Date(o),i);case 4:{let{source:e,flags:t}=o;return n(new RegExp(e,t),i)}case 5:{let e=n(new Map,i);for(let[t,n]of o)e.set(r(t),r(n));return e}case 6:{let e=n(new Set,i);for(let t of o)e.add(r(t));return e}case 7:{let{name:e,message:t}=o;return n(typeof Uz[e]==`function`?Wz(e,t):Error(t),i)}case 8:return n(BigInt(o),i);case`BigInt`:return n(Object(BigInt(o)),i);case`ArrayBuffer`:return n(new Uint8Array(o).buffer,o);case`DataView`:{let{buffer:e}=new Uint8Array(o);return n(new DataView(e),o)}case`-0`:return-0}return n(Wz(a,o),i)};return r},Kz=e=>Gz(new Map,e)(0),qz=``,{toString:Jz}={},{keys:Yz,is:Xz}=Object,Zz=e=>{let t=typeof e;if(t!==`object`||!e)return[0,t];let n=Jz.call(e).slice(8,-1);switch(n){case`Array`:return[1,qz];case`Object`:return[2,qz];case`Date`:return[3,qz];case`RegExp`:return[4,qz];case`Map`:return[5,qz];case`Set`:return[6,qz];case`DataView`:return[1,n]}return n.includes(`Array`)?[1,n]:e instanceof Error?[7,e.name||`Error`]:[2,n]},Qz=([e,t])=>e===0&&(t===`function`||t===`symbol`),$z=(e,t,n,r)=>{let i=(e,t)=>{let i=r.push(e)-1;return n.set(t,i),i},a=o=>{if(n.has(o))return n.get(o);let[s,c]=Zz(o);switch(s){case 0:{let t=o;switch(c){case`bigint`:s=8,t=o.toString();break;case`number`:if(!o&&Xz(o,-0))return r.push([`-0`])-1;break;case`function`:case`symbol`:if(e)throw TypeError(`unable to serialize `+c);t=null;break;case`undefined`:return i([-1],o)}return i([s,t],o)}case 1:{if(c){let e=o;return c===`DataView`?e=new Uint8Array(o.buffer):c===`ArrayBuffer`&&(e=new Uint8Array(o)),i([c,[...e]],o)}let e=[],t=i([s,e],o);for(let t of o)e.push(a(t));return t}case 2:{if(c)switch(c){case`BigInt`:return i([c,o.toString()],o);case`Boolean`:case`Number`:case`String`:return i([c,o.valueOf()],o)}if(t&&`toJSON`in o)return a(o.toJSON());let n=[],r=i([s,n],o);for(let t of Yz(o))(e||!Qz(Zz(o[t])))&&n.push([a(t),a(o[t])]);return r}case 3:return i([s,isNaN(o.getTime())?qz:o.toISOString()],o);case 4:{let{source:e,flags:t}=o;return i([s,{source:e,flags:t}],o)}case 5:{let t=[],n=i([s,t],o);for(let[n,r]of o)(e||!(Qz(Zz(n))||Qz(Zz(r))))&&t.push([a(n),a(r)]);return n}case 6:{let t=[],n=i([s,t],o);for(let n of o)(e||!Qz(Zz(n)))&&t.push(a(n));return n}}let{message:l}=o;return i([s,{name:c,message:l}],o)};return a},eB=(e,{json:t,lossy:n}={})=>{let r=[];return $z(!(t||n),!!t,new Map,r)(e),r},tB=typeof structuredClone==`function`?(e,t)=>t&&(`json`in t||`lossy`in t)?Kz(eB(e,t)):structuredClone(e):(e,t)=>Kz(eB(e,t));function nB(e,t){let n=[{type:`text`,value:`↩`}];return t>1&&n.push({type:`element`,tagName:`sup`,properties:{},children:[{type:`text`,value:String(t)}]}),n}function rB(e,t){return`Back to reference `+(e+1)+(t>1?`-`+t:``)}function iB(e){let t=typeof e.options.clobberPrefix==`string`?e.options.clobberPrefix:`user-content-`,n=e.options.footnoteBackContent||nB,r=e.options.footnoteBackLabel||rB,i=e.options.footnoteLabel||`Footnotes`,a=e.options.footnoteLabelTagName||`h2`,o=e.options.footnoteLabelProperties||{className:[`sr-only`]},s=[],c=-1;for(;++c<e.footnoteOrder.length;){let i=e.footnoteById.get(e.footnoteOrder[c]);if(!i)continue;let a=e.all(i),o=String(i.identifier).toUpperCase(),l=II(o.toLowerCase()),u=0,d=[],f=e.footnoteCounts.get(o);for(;f!==void 0&&++u<=f;){d.length>0&&d.push({type:`text`,value:` `});let e=typeof n==`string`?n:n(c,u);typeof e==`string`&&(e={type:`text`,value:e}),d.push({type:`element`,tagName:`a`,properties:{href:`#`+t+`fnref-`+l+(u>1?`-`+u:``),dataFootnoteBackref:``,ariaLabel:typeof r==`string`?r:r(c,u),className:[`data-footnote-backref`]},children:Array.isArray(e)?e:[e]})}let p=a[a.length-1];if(p&&p.type===`element`&&p.tagName===`p`){let e=p.children[p.children.length-1];e&&e.type===`text`?e.value+=` `:p.children.push({type:`text`,value:` `}),p.children.push(...d)}else a.push(...d);let m={type:`element`,tagName:`li`,properties:{id:t+`fn-`+l},children:e.wrap(a,!0)};e.patch(i,m),s.push(m)}if(s.length!==0)return{type:`element`,tagName:`section`,properties:{dataFootnotes:!0,className:[`footnotes`]},children:[{type:`element`,tagName:a,properties:{...tB(o),id:`footnote-label`},children:[{type:`text`,value:i}]},{type:`text`,value:`
109
+ `});let l={type:`element`,tagName:`li`,properties:a,children:o};return e.patch(t,l),e.applyData(t,l)}function Ez(e){let t=!1;if(e.type===`list`){t=e.spread||!1;let n=e.children,r=-1;for(;!t&&++r<n.length;)t=Dz(n[r])}return t}function Dz(e){return e.spread??e.children.length>1}function Oz(e,t){let n={},r=e.all(t),i=-1;for(typeof t.start==`number`&&t.start!==1&&(n.start=t.start);++i<r.length;){let e=r[i];if(e.type===`element`&&e.tagName===`li`&&e.properties&&Array.isArray(e.properties.className)&&e.properties.className.includes(`task-list-item`)){n.className=[`contains-task-list`];break}}let a={type:`element`,tagName:t.ordered?`ol`:`ul`,properties:n,children:e.wrap(r,!0)};return e.patch(t,a),e.applyData(t,a)}function kz(e,t){let n={type:`element`,tagName:`p`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function Az(e,t){let n={type:`root`,children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function jz(e,t){let n={type:`element`,tagName:`strong`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function Mz(e,t){let n=e.all(t),r=n.shift(),i=[];if(r){let n={type:`element`,tagName:`thead`,properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],n),i.push(n)}if(n.length>0){let r={type:`element`,tagName:`tbody`,properties:{},children:e.wrap(n,!0)},a=TF(t.children[1]),o=wF(t.children[t.children.length-1]);a&&o&&(r.position={start:a,end:o}),i.push(r)}let a={type:`element`,tagName:`table`,properties:{},children:e.wrap(i,!0)};return e.patch(t,a),e.applyData(t,a)}function Nz(e,t,n){let r=n?n.children:void 0,i=(r?r.indexOf(t):1)===0?`th`:`td`,a=n&&n.type===`table`?n.align:void 0,o=a?a.length:t.children.length,s=-1,c=[];for(;++s<o;){let n=t.children[s],r={},o=a?a[s]:void 0;o&&(r.align=o);let l={type:`element`,tagName:i,properties:r,children:[]};n&&(l.children=e.all(n),e.patch(n,l),l=e.applyData(n,l)),c.push(l)}let l={type:`element`,tagName:`tr`,properties:{},children:e.wrap(c,!0)};return e.patch(t,l),e.applyData(t,l)}function Pz(e,t){let n={type:`element`,tagName:`td`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}var Fz=9,Iz=32;function Lz(e){let t=String(e),n=/\r?\n|\r/g,r=n.exec(t),i=0,a=[];for(;r;)a.push(Rz(t.slice(i,r.index),i>0,!0),r[0]),i=r.index+r[0].length,r=n.exec(t);return a.push(Rz(t.slice(i),i>0,!1)),a.join(``)}function Rz(e,t,n){let r=0,i=e.length;if(t){let t=e.codePointAt(r);for(;t===Fz||t===Iz;)r++,t=e.codePointAt(r)}if(n){let t=e.codePointAt(i-1);for(;t===Fz||t===Iz;)i--,t=e.codePointAt(i-1)}return i>r?e.slice(r,i):``}function zz(e,t){let n={type:`text`,value:Lz(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function Bz(e,t){let n={type:`element`,tagName:`hr`,properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}var Vz={blockquote:dz,break:fz,code:pz,delete:mz,emphasis:hz,footnoteReference:gz,heading:_z,html:vz,imageReference:bz,image:xz,inlineCode:Sz,linkReference:Cz,link:wz,listItem:Tz,list:Oz,paragraph:kz,root:Az,strong:jz,table:Mz,tableCell:Pz,tableRow:Nz,text:zz,thematicBreak:Bz,toml:Hz,yaml:Hz,definition:Hz,footnoteDefinition:Hz};function Hz(){}var{defineProperty:Uz}=Object,Wz=typeof self==`object`?self:globalThis,Gz=(e,t)=>{switch(e){case`Function`:case`SharedWorker`:case`Worker`:case`eval`:case`setInterval`:case`setTimeout`:throw TypeError(`unable to deserialize `+e)}return new Wz[e](t)},Kz=(e,t)=>{let n=(t,n)=>(e.set(n,t),t),r=i=>{if(e.has(i))return e.get(i);let[a,o]=t[i];switch(a){case 0:case-1:return n(o,i);case 1:{let e=n([],i);for(let t of o)e.push(r(t));return e}case 2:{let e=n({},i);for(let[t,n]of o){let i=r(t),a=r(n);i===`__proto__`?Uz(e,i,{value:a,configurable:!0,enumerable:!0,writable:!0}):e[i]=a}return e}case 3:return n(new Date(o),i);case 4:{let{source:e,flags:t}=o;return n(new RegExp(e,t),i)}case 5:{let e=n(new Map,i);for(let[t,n]of o)e.set(r(t),r(n));return e}case 6:{let e=n(new Set,i);for(let t of o)e.add(r(t));return e}case 7:{let{name:e,message:t}=o;return n(typeof Wz[e]==`function`?Gz(e,t):Error(t),i)}case 8:return n(BigInt(o),i);case`BigInt`:return n(Object(BigInt(o)),i);case`ArrayBuffer`:return n(new Uint8Array(o).buffer,o);case`DataView`:{let{buffer:e}=new Uint8Array(o);return n(new DataView(e),o)}case`-0`:return-0}return n(Gz(a,o),i)};return r},qz=e=>Kz(new Map,e)(0),Jz=``,{toString:Yz}={},{keys:Xz,is:Zz}=Object,Qz=e=>{let t=typeof e;if(t!==`object`||!e)return[0,t];let n=Yz.call(e).slice(8,-1);switch(n){case`Array`:return[1,Jz];case`Object`:return[2,Jz];case`Date`:return[3,Jz];case`RegExp`:return[4,Jz];case`Map`:return[5,Jz];case`Set`:return[6,Jz];case`DataView`:return[1,n]}return n.includes(`Array`)?[1,n]:e instanceof Error?[7,e.name||`Error`]:[2,n]},$z=([e,t])=>e===0&&(t===`function`||t===`symbol`),eB=(e,t,n,r)=>{let i=(e,t)=>{let i=r.push(e)-1;return n.set(t,i),i},a=o=>{if(n.has(o))return n.get(o);let[s,c]=Qz(o);switch(s){case 0:{let t=o;switch(c){case`bigint`:s=8,t=o.toString();break;case`number`:if(!o&&Zz(o,-0))return r.push([`-0`])-1;break;case`function`:case`symbol`:if(e)throw TypeError(`unable to serialize `+c);t=null;break;case`undefined`:return i([-1],o)}return i([s,t],o)}case 1:{if(c){let e=o;return c===`DataView`?e=new Uint8Array(o.buffer):c===`ArrayBuffer`&&(e=new Uint8Array(o)),i([c,[...e]],o)}let e=[],t=i([s,e],o);for(let t of o)e.push(a(t));return t}case 2:{if(c)switch(c){case`BigInt`:return i([c,o.toString()],o);case`Boolean`:case`Number`:case`String`:return i([c,o.valueOf()],o)}if(t&&`toJSON`in o)return a(o.toJSON());let n=[],r=i([s,n],o);for(let t of Xz(o))(e||!$z(Qz(o[t])))&&n.push([a(t),a(o[t])]);return r}case 3:return i([s,isNaN(o.getTime())?Jz:o.toISOString()],o);case 4:{let{source:e,flags:t}=o;return i([s,{source:e,flags:t}],o)}case 5:{let t=[],n=i([s,t],o);for(let[n,r]of o)(e||!($z(Qz(n))||$z(Qz(r))))&&t.push([a(n),a(r)]);return n}case 6:{let t=[],n=i([s,t],o);for(let n of o)(e||!$z(Qz(n)))&&t.push(a(n));return n}}let{message:l}=o;return i([s,{name:c,message:l}],o)};return a},tB=(e,{json:t,lossy:n}={})=>{let r=[];return eB(!(t||n),!!t,new Map,r)(e),r},nB=typeof structuredClone==`function`?(e,t)=>t&&(`json`in t||`lossy`in t)?qz(tB(e,t)):structuredClone(e):(e,t)=>qz(tB(e,t));function rB(e,t){let n=[{type:`text`,value:`↩`}];return t>1&&n.push({type:`element`,tagName:`sup`,properties:{},children:[{type:`text`,value:String(t)}]}),n}function iB(e,t){return`Back to reference `+(e+1)+(t>1?`-`+t:``)}function aB(e){let t=typeof e.options.clobberPrefix==`string`?e.options.clobberPrefix:`user-content-`,n=e.options.footnoteBackContent||rB,r=e.options.footnoteBackLabel||iB,i=e.options.footnoteLabel||`Footnotes`,a=e.options.footnoteLabelTagName||`h2`,o=e.options.footnoteLabelProperties||{className:[`sr-only`]},s=[],c=-1;for(;++c<e.footnoteOrder.length;){let i=e.footnoteById.get(e.footnoteOrder[c]);if(!i)continue;let a=e.all(i),o=String(i.identifier).toUpperCase(),l=LI(o.toLowerCase()),u=0,d=[],f=e.footnoteCounts.get(o);for(;f!==void 0&&++u<=f;){d.length>0&&d.push({type:`text`,value:` `});let e=typeof n==`string`?n:n(c,u);typeof e==`string`&&(e={type:`text`,value:e}),d.push({type:`element`,tagName:`a`,properties:{href:`#`+t+`fnref-`+l+(u>1?`-`+u:``),dataFootnoteBackref:``,ariaLabel:typeof r==`string`?r:r(c,u),className:[`data-footnote-backref`]},children:Array.isArray(e)?e:[e]})}let p=a[a.length-1];if(p&&p.type===`element`&&p.tagName===`p`){let e=p.children[p.children.length-1];e&&e.type===`text`?e.value+=` `:p.children.push({type:`text`,value:` `}),p.children.push(...d)}else a.push(...d);let m={type:`element`,tagName:`li`,properties:{id:t+`fn-`+l},children:e.wrap(a,!0)};e.patch(i,m),s.push(m)}if(s.length!==0)return{type:`element`,tagName:`section`,properties:{dataFootnotes:!0,className:[`footnotes`]},children:[{type:`element`,tagName:a,properties:{...nB(o),id:`footnote-label`},children:[{type:`text`,value:i}]},{type:`text`,value:`
110
110
  `},{type:`element`,tagName:`ol`,properties:{},children:e.wrap(s,!0)},{type:`text`,value:`
111
- `}]}}var aB=(function(e){if(e==null)return uB;if(typeof e==`function`)return lB(e);if(typeof e==`object`)return Array.isArray(e)?oB(e):sB(e);if(typeof e==`string`)return cB(e);throw Error(`Expected function, string, or object as test`)});function oB(e){let t=[],n=-1;for(;++n<e.length;)t[n]=aB(e[n]);return lB(r);function r(...e){let n=-1;for(;++n<t.length;)if(t[n].apply(this,e))return!0;return!1}}function sB(e){let t=e;return lB(n);function n(n){let r=n,i;for(i in e)if(r[i]!==t[i])return!1;return!0}}function cB(e){return lB(t);function t(t){return t&&t.type===e}}function lB(e){return t;function t(t,n,r){return!!(dB(t)&&e.call(this,t,typeof n==`number`?n:void 0,r||void 0))}}function uB(){return!0}function dB(e){return typeof e==`object`&&!!e&&`type`in e}function fB(e){return e}var pB=[];function mB(e,t,n,r){let i;typeof t==`function`&&typeof n!=`function`?(r=n,n=t):i=t;let a=aB(i),o=r?-1:1;s(e,void 0,[])();function s(e,i,c){let l=e&&typeof e==`object`?e:{};if(typeof l.type==`string`){let t=typeof l.tagName==`string`?l.tagName:typeof l.name==`string`?l.name:void 0;Object.defineProperty(u,"name",{value:`node (`+fB(e.type+(t?`<`+t+`>`:``))+`)`})}return u;function u(){let l=pB,u,d,f;if((!t||a(e,i,c[c.length-1]||void 0))&&(l=hB(n(e,c)),l[0]===!1))return l;if(`children`in e&&e.children){let t=e;if(t.children&&l[0]!==`skip`)for(d=(r?t.children.length:-1)+o,f=c.concat(t);d>-1&&d<t.children.length;){let e=t.children[d];if(u=s(e,d,f)(),u[0]===!1)return u;d=typeof u[1]==`number`?u[1]:d+o}}return l}}}function hB(e){return Array.isArray(e)?e:typeof e==`number`?[!0,e]:e==null?pB:[e]}function gB(e,t,n,r){let i,a,o;typeof t==`function`&&typeof n!=`function`?(a=void 0,o=t,i=n):(a=t,o=n,i=r),mB(e,a,s,i);function s(e,t){let n=t[t.length-1],r=n?n.children.indexOf(e):void 0;return o(e,r,n)}}var _B={}.hasOwnProperty,vB={};function yB(e,t){let n=t||vB,r=new Map,i=new Map,a={all:s,applyData:xB,definitionById:r,footnoteById:i,footnoteCounts:new Map,footnoteOrder:[],handlers:{...Bz,...n.handlers},one:o,options:n,patch:bB,wrap:CB};return gB(e,function(e){if(e.type===`definition`||e.type===`footnoteDefinition`){let t=e.type===`definition`?r:i,n=String(e.identifier).toUpperCase();t.has(n)||t.set(n,e)}}),a;function o(e,t){let n=e.type,r=a.handlers[n];if(_B.call(a.handlers,n)&&r)return r(a,e,t);if(a.options.passThrough&&a.options.passThrough.includes(n)){if(`children`in e){let{children:t,...n}=e,r=tB(n);return r.children=a.all(e),r}return tB(e)}return(a.options.unknownHandler||SB)(a,e,t)}function s(e){let t=[];if(`children`in e){let n=e.children,r=-1;for(;++r<n.length;){let i=a.one(n[r],e);if(i){if(r&&n[r-1].type===`break`&&(!Array.isArray(i)&&i.type===`text`&&(i.value=wB(i.value)),!Array.isArray(i)&&i.type===`element`)){let e=i.children[0];e&&e.type===`text`&&(e.value=wB(e.value))}Array.isArray(i)?t.push(...i):t.push(i)}}}return t}}function bB(e,t){e.position&&(t.position=EF(e))}function xB(e,t){let n=t;if(e&&e.data){let t=e.data.hName,r=e.data.hChildren,i=e.data.hProperties;typeof t==`string`&&(n.type===`element`?n.tagName=t:n={type:`element`,tagName:t,properties:{},children:`children`in n?n.children:[n]}),n.type===`element`&&i&&Object.assign(n.properties,tB(i)),`children`in n&&n.children&&r!=null&&(n.children=r)}return n}function SB(e,t){let n=t.data||{},r=`value`in t&&!(_B.call(n,`hProperties`)||_B.call(n,`hChildren`))?{type:`text`,value:t.value}:{type:`element`,tagName:`div`,properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function CB(e,t){let n=[],r=-1;for(t&&n.push({type:`text`,value:`
111
+ `}]}}var oB=(function(e){if(e==null)return dB;if(typeof e==`function`)return uB(e);if(typeof e==`object`)return Array.isArray(e)?sB(e):cB(e);if(typeof e==`string`)return lB(e);throw Error(`Expected function, string, or object as test`)});function sB(e){let t=[],n=-1;for(;++n<e.length;)t[n]=oB(e[n]);return uB(r);function r(...e){let n=-1;for(;++n<t.length;)if(t[n].apply(this,e))return!0;return!1}}function cB(e){let t=e;return uB(n);function n(n){let r=n,i;for(i in e)if(r[i]!==t[i])return!1;return!0}}function lB(e){return uB(t);function t(t){return t&&t.type===e}}function uB(e){return t;function t(t,n,r){return!!(fB(t)&&e.call(this,t,typeof n==`number`?n:void 0,r||void 0))}}function dB(){return!0}function fB(e){return typeof e==`object`&&!!e&&`type`in e}function pB(e){return e}var mB=[];function hB(e,t,n,r){let i;typeof t==`function`&&typeof n!=`function`?(r=n,n=t):i=t;let a=oB(i),o=r?-1:1;s(e,void 0,[])();function s(e,i,c){let l=e&&typeof e==`object`?e:{};if(typeof l.type==`string`){let t=typeof l.tagName==`string`?l.tagName:typeof l.name==`string`?l.name:void 0;Object.defineProperty(u,"name",{value:`node (`+pB(e.type+(t?`<`+t+`>`:``))+`)`})}return u;function u(){let l=mB,u,d,f;if((!t||a(e,i,c[c.length-1]||void 0))&&(l=gB(n(e,c)),l[0]===!1))return l;if(`children`in e&&e.children){let t=e;if(t.children&&l[0]!==`skip`)for(d=(r?t.children.length:-1)+o,f=c.concat(t);d>-1&&d<t.children.length;){let e=t.children[d];if(u=s(e,d,f)(),u[0]===!1)return u;d=typeof u[1]==`number`?u[1]:d+o}}return l}}}function gB(e){return Array.isArray(e)?e:typeof e==`number`?[!0,e]:e==null?mB:[e]}function _B(e,t,n,r){let i,a,o;typeof t==`function`&&typeof n!=`function`?(a=void 0,o=t,i=n):(a=t,o=n,i=r),hB(e,a,s,i);function s(e,t){let n=t[t.length-1],r=n?n.children.indexOf(e):void 0;return o(e,r,n)}}var vB={}.hasOwnProperty,yB={};function bB(e,t){let n=t||yB,r=new Map,i=new Map,a={all:s,applyData:SB,definitionById:r,footnoteById:i,footnoteCounts:new Map,footnoteOrder:[],handlers:{...Vz,...n.handlers},one:o,options:n,patch:xB,wrap:wB};return _B(e,function(e){if(e.type===`definition`||e.type===`footnoteDefinition`){let t=e.type===`definition`?r:i,n=String(e.identifier).toUpperCase();t.has(n)||t.set(n,e)}}),a;function o(e,t){let n=e.type,r=a.handlers[n];if(vB.call(a.handlers,n)&&r)return r(a,e,t);if(a.options.passThrough&&a.options.passThrough.includes(n)){if(`children`in e){let{children:t,...n}=e,r=nB(n);return r.children=a.all(e),r}return nB(e)}return(a.options.unknownHandler||CB)(a,e,t)}function s(e){let t=[];if(`children`in e){let n=e.children,r=-1;for(;++r<n.length;){let i=a.one(n[r],e);if(i){if(r&&n[r-1].type===`break`&&(!Array.isArray(i)&&i.type===`text`&&(i.value=TB(i.value)),!Array.isArray(i)&&i.type===`element`)){let e=i.children[0];e&&e.type===`text`&&(e.value=TB(e.value))}Array.isArray(i)?t.push(...i):t.push(i)}}}return t}}function xB(e,t){e.position&&(t.position=DF(e))}function SB(e,t){let n=t;if(e&&e.data){let t=e.data.hName,r=e.data.hChildren,i=e.data.hProperties;typeof t==`string`&&(n.type===`element`?n.tagName=t:n={type:`element`,tagName:t,properties:{},children:`children`in n?n.children:[n]}),n.type===`element`&&i&&Object.assign(n.properties,nB(i)),`children`in n&&n.children&&r!=null&&(n.children=r)}return n}function CB(e,t){let n=t.data||{},r=`value`in t&&!(vB.call(n,`hProperties`)||vB.call(n,`hChildren`))?{type:`text`,value:t.value}:{type:`element`,tagName:`div`,properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function wB(e,t){let n=[],r=-1;for(t&&n.push({type:`text`,value:`
112
112
  `});++r<e.length;)r&&n.push({type:`text`,value:`
113
113
  `}),n.push(e[r]);return t&&e.length>0&&n.push({type:`text`,value:`
114
- `}),n}function wB(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function TB(e,t){let n=yB(e,t),r=n.one(e,void 0),i=iB(n),a=Array.isArray(r)?{type:`root`,children:r}:r||{type:`root`,children:[]};return i&&(`children`in a,a.children.push({type:`text`,value:`
115
- `},i)),a}function EB(e,t){return e&&`run`in e?async function(n,r){let i=TB(n,{file:r,...t});await e.run(i,r)}:function(n,r){return TB(n,{file:r,...e||t})}}function DB(e){if(e)throw e}var OB=o(((e,t)=>{var n=Object.prototype.hasOwnProperty,r=Object.prototype.toString,i=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o=function(e){return typeof Array.isArray==`function`?Array.isArray(e):r.call(e)===`[object Array]`},s=function(e){if(!e||r.call(e)!==`[object Object]`)return!1;var t=n.call(e,`constructor`),i=e.constructor&&e.constructor.prototype&&n.call(e.constructor.prototype,`isPrototypeOf`);if(e.constructor&&!t&&!i)return!1;for(var a in e);return a===void 0||n.call(e,a)},c=function(e,t){i&&t.name===`__proto__`?i(e,t.name,{enumerable:!0,configurable:!0,value:t.newValue,writable:!0}):e[t.name]=t.newValue},l=function(e,t){if(t===`__proto__`){if(!n.call(e,t))return;if(a)return a(e,t).value}return e[t]};t.exports=function e(){var t,n,r,i,a,u,d=arguments[0],f=1,p=arguments.length,m=!1;for(typeof d==`boolean`&&(m=d,d=arguments[1]||{},f=2),(d==null||typeof d!=`object`&&typeof d!=`function`)&&(d={});f<p;++f)if(t=arguments[f],t!=null)for(n in t)r=l(d,n),i=l(t,n),d!==i&&(m&&i&&(s(i)||(a=o(i)))?(a?(a=!1,u=r&&o(r)?r:[]):u=r&&s(r)?r:{},c(d,{name:n,newValue:e(m,u,i)})):i!==void 0&&c(d,{name:n,newValue:i}));return d}}));function kB(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function AB(){let e=[],t={run:n,use:r};return t;function n(...t){let n=-1,r=t.pop();if(typeof r!=`function`)throw TypeError(`Expected function as last argument, not `+r);i(null,...t);function i(a,...o){let s=e[++n],c=-1;if(a){r(a);return}for(;++c<t.length;)(o[c]===null||o[c]===void 0)&&(o[c]=t[c]);t=o,s?jB(s,i)(...o):r(null,...o)}}function r(n){if(typeof n!=`function`)throw TypeError("Expected `middelware` to be a function, not "+n);return e.push(n),t}}function jB(e,t){let n;return r;function r(...t){let r=e.length>t.length,o;r&&t.push(i);try{o=e.apply(this,t)}catch(e){let t=e;if(r&&n)throw t;return i(t)}r||(o&&o.then&&typeof o.then==`function`?o.then(a,i):o instanceof Error?i(o):a(o))}function i(e,...r){n||(n=!0,t(e,...r))}function a(e){i(null,e)}}var MB={basename:NB,dirname:PB,extname:FB,join:IB,sep:`/`};function NB(e,t){if(t!==void 0&&typeof t!=`string`)throw TypeError(`"ext" argument must be a string`);zB(e);let n=0,r=-1,i=e.length,a;if(t===void 0||t.length===0||t.length>e.length){for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else r<0&&(a=!0,r=i+1);return r<0?``:e.slice(n,r)}if(t===e)return``;let o=-1,s=t.length-1;for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else o<0&&(a=!0,o=i+1),s>-1&&(e.codePointAt(i)===t.codePointAt(s--)?s<0&&(r=i):(s=-1,r=o));return n===r?r=o:r<0&&(r=e.length),e.slice(n,r)}function PB(e){if(zB(e),e.length===0)return`.`;let t=-1,n=e.length,r;for(;--n;)if(e.codePointAt(n)===47){if(r){t=n;break}}else r||=!0;return t<0?e.codePointAt(0)===47?`/`:`.`:t===1&&e.codePointAt(0)===47?`//`:e.slice(0,t)}function FB(e){zB(e);let t=e.length,n=-1,r=0,i=-1,a=0,o;for(;t--;){let s=e.codePointAt(t);if(s===47){if(o){r=t+1;break}continue}n<0&&(o=!0,n=t+1),s===46?i<0?i=t:a!==1&&(a=1):i>-1&&(a=-1)}return i<0||n<0||a===0||a===1&&i===n-1&&i===r+1?``:e.slice(i,n)}function IB(...e){let t=-1,n;for(;++t<e.length;)zB(e[t]),e[t]&&(n=n===void 0?e[t]:n+`/`+e[t]);return n===void 0?`.`:LB(n)}function LB(e){zB(e);let t=e.codePointAt(0)===47,n=RB(e,!t);return n.length===0&&!t&&(n=`.`),n.length>0&&e.codePointAt(e.length-1)===47&&(n+=`/`),t?`/`+n:n}function RB(e,t){let n=``,r=0,i=-1,a=0,o=-1,s,c;for(;++o<=e.length;){if(o<e.length)s=e.codePointAt(o);else if(s===47)break;else s=47;if(s===47){if(i!==o-1&&a!==1){if(i!==o-1&&a===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(c=n.lastIndexOf(`/`),c!==n.length-1){c<0?(n=``,r=0):(n=n.slice(0,c),r=n.length-1-n.lastIndexOf(`/`)),i=o,a=0;continue}}else if(n.length>0){n=``,r=0,i=o,a=0;continue}}t&&(n=n.length>0?n+`/..`:`..`,r=2)}else n.length>0?n+=`/`+e.slice(i+1,o):n=e.slice(i+1,o),r=o-i-1}i=o,a=0}else s===46&&a>-1?a++:a=-1}return n}function zB(e){if(typeof e!=`string`)throw TypeError(`Path must be a string. Received `+JSON.stringify(e))}var BB={cwd:VB};function VB(){return`/`}function HB(e){return!!(typeof e==`object`&&e&&`href`in e&&e.href&&`protocol`in e&&e.protocol&&e.auth===void 0)}function UB(e){if(typeof e==`string`)e=new URL(e);else if(!HB(e)){let t=TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code=`ERR_INVALID_ARG_TYPE`,t}if(e.protocol!==`file:`){let e=TypeError(`The URL must be of scheme file`);throw e.code=`ERR_INVALID_URL_SCHEME`,e}return WB(e)}function WB(e){if(e.hostname!==``){let e=TypeError(`File URL host must be "localhost" or empty on darwin`);throw e.code=`ERR_INVALID_FILE_URL_HOST`,e}let t=e.pathname,n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){let e=t.codePointAt(n+2);if(e===70||e===102){let e=TypeError(`File URL path must not include encoded / characters`);throw e.code=`ERR_INVALID_FILE_URL_PATH`,e}}return decodeURIComponent(t)}var GB=[`history`,`path`,`basename`,`stem`,`extname`,`dirname`],KB=class{constructor(e){let t;t=e?HB(e)?{path:e}:typeof e==`string`||XB(e)?{value:e}:e:{},this.cwd=`cwd`in t?``:BB.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let n=-1;for(;++n<GB.length;){let e=GB[n];e in t&&t[e]!==void 0&&t[e]!==null&&(this[e]=e===`history`?[...t[e]]:t[e])}let r;for(r in t)GB.includes(r)||(this[r]=t[r])}get basename(){return typeof this.path==`string`?MB.basename(this.path):void 0}set basename(e){JB(e,`basename`),qB(e,`basename`),this.path=MB.join(this.dirname||``,e)}get dirname(){return typeof this.path==`string`?MB.dirname(this.path):void 0}set dirname(e){YB(this.basename,`dirname`),this.path=MB.join(e||``,this.basename)}get extname(){return typeof this.path==`string`?MB.extname(this.path):void 0}set extname(e){if(qB(e,`extname`),YB(this.dirname,`extname`),e){if(e.codePointAt(0)!==46)throw Error("`extname` must start with `.`");if(e.includes(`.`,1))throw Error("`extname` cannot contain multiple dots")}this.path=MB.join(this.dirname,this.stem+(e||``))}get path(){return this.history[this.history.length-1]}set path(e){HB(e)&&(e=UB(e)),JB(e,`path`),this.path!==e&&this.history.push(e)}get stem(){return typeof this.path==`string`?MB.basename(this.path,this.extname):void 0}set stem(e){JB(e,`stem`),qB(e,`stem`),this.path=MB.join(this.dirname||``,e+(this.extname||``))}fail(e,t,n){let r=this.message(e,t,n);throw r.fatal=!0,r}info(e,t,n){let r=this.message(e,t,n);return r.fatal=void 0,r}message(e,t,n){let r=new jF(e,t,n);return this.path&&(r.name=this.path+`:`+r.name,r.file=this.path),r.fatal=!1,this.messages.push(r),r}toString(e){return this.value===void 0?``:typeof this.value==`string`?this.value:new TextDecoder(e||void 0).decode(this.value)}};function qB(e,t){if(e&&e.includes(MB.sep))throw Error("`"+t+"` cannot be a path: did not expect `"+MB.sep+"`")}function JB(e,t){if(!e)throw Error("`"+t+"` cannot be empty")}function YB(e,t){if(!e)throw Error("Setting `"+t+"` requires `path` to be set too")}function XB(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var ZB=(function(e){let t=this.constructor.prototype,n=t[e],r=function(){return n.apply(r,arguments)};return Object.setPrototypeOf(r,t),r}),QB=l(OB(),1),$B={}.hasOwnProperty,eV=new class e extends ZB{constructor(){super(`copy`),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=AB()}copy(){let t=new e,n=-1;for(;++n<this.attachers.length;){let e=this.attachers[n];t.use(...e)}return t.data((0,QB.default)(!0,{},this.namespace)),t}data(e,t){return typeof e==`string`?arguments.length===2?(rV(`data`,this.frozen),this.namespace[e]=t,this):$B.call(this.namespace,e)&&this.namespace[e]||void 0:e?(rV(`data`,this.frozen),this.namespace=e,this):this.namespace}freeze(){if(this.frozen)return this;let e=this;for(;++this.freezeIndex<this.attachers.length;){let[t,...n]=this.attachers[this.freezeIndex];if(n[0]===!1)continue;n[0]===!0&&(n[0]=void 0);let r=t.call(e,...n);typeof r==`function`&&this.transformers.use(r)}return this.frozen=!0,this.freezeIndex=1/0,this}parse(e){this.freeze();let t=oV(e),n=this.parser||this.Parser;return tV(`parse`,n),n(String(t),t)}process(e,t){let n=this;return this.freeze(),tV(`process`,this.parser||this.Parser),nV(`process`,this.compiler||this.Compiler),t?r(void 0,t):new Promise(r);function r(r,i){let a=oV(e),o=n.parse(a);n.run(o,a,function(e,t,r){if(e||!t||!r)return s(e);let i=t,a=n.stringify(i,r);cV(a)?r.value=a:r.result=a,s(e,r)});function s(e,n){e||!n?i(e):r?r(n):t(void 0,n)}}}processSync(e){let t=!1,n;return this.freeze(),tV(`processSync`,this.parser||this.Parser),nV(`processSync`,this.compiler||this.Compiler),this.process(e,r),aV(`processSync`,`process`,t),n;function r(e,r){t=!0,DB(e),n=r}}run(e,t,n){iV(e),this.freeze();let r=this.transformers;return!n&&typeof t==`function`&&(n=t,t=void 0),n?i(void 0,n):new Promise(i);function i(i,a){let o=oV(t);r.run(e,o,s);function s(t,r,o){let s=r||e;t?a(t):i?i(s):n(void 0,s,o)}}}runSync(e,t){let n=!1,r;return this.run(e,t,i),aV(`runSync`,`run`,n),r;function i(e,t){DB(e),r=t,n=!0}}stringify(e,t){this.freeze();let n=oV(t),r=this.compiler||this.Compiler;return nV(`stringify`,r),iV(e),r(e,n)}use(e,...t){let n=this.attachers,r=this.namespace;if(rV(`use`,this.frozen),e!=null){if(typeof e==`function`)s(e,t);else if(typeof e==`object`)Array.isArray(e)?o(e):a(e);else throw TypeError("Expected usable value, not `"+e+"`")}return this;function i(e){if(typeof e==`function`)s(e,[]);else if(typeof e==`object`){if(Array.isArray(e)){let[t,...n]=e;s(t,n)}else a(e)}else throw TypeError("Expected usable value, not `"+e+"`")}function a(e){if(!(`plugins`in e)&&!(`settings`in e))throw Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");o(e.plugins),e.settings&&(r.settings=(0,QB.default)(!0,r.settings,e.settings))}function o(e){let t=-1;if(e!=null){if(Array.isArray(e))for(;++t<e.length;){let n=e[t];i(n)}else throw TypeError("Expected a list of plugins, not `"+e+"`")}}function s(e,t){let r=-1,i=-1;for(;++r<n.length;)if(n[r][0]===e){i=r;break}if(i===-1)n.push([e,...t]);else if(t.length>0){let[r,...a]=t,o=n[i][1];kB(o)&&kB(r)&&(r=(0,QB.default)(!0,o,r)),n[i]=[e,r,...a]}}}}().freeze();function tV(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `parser`")}function nV(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `compiler`")}function rV(e,t){if(t)throw Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function iV(e){if(!kB(e)||typeof e.type!=`string`)throw TypeError("Expected node, got `"+e+"`")}function aV(e,t,n){if(!n)throw Error("`"+e+"` finished async. Use `"+t+"` instead")}function oV(e){return sV(e)?e:new KB(e)}function sV(e){return!!(e&&typeof e==`object`&&`message`in e&&`messages`in e)}function cV(e){return typeof e==`string`||lV(e)}function lV(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var uV=[],dV={allowDangerousHtml:!0},fV=/^(https?|ircs?|mailto|xmpp)$/i,pV=[{from:`astPlugins`,id:`remove-buggy-html-in-markdown-parser`},{from:`allowDangerousHtml`,id:`remove-buggy-html-in-markdown-parser`},{from:`allowNode`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`allowElement`},{from:`allowedTypes`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`allowedElements`},{from:`className`,id:`remove-classname`},{from:`disallowedTypes`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`disallowedElements`},{from:`escapeHtml`,id:`remove-buggy-html-in-markdown-parser`},{from:`includeElementIndex`,id:`#remove-includeelementindex`},{from:`includeNodeIndex`,id:`change-includenodeindex-to-includeelementindex`},{from:`linkTarget`,id:`remove-linktarget`},{from:`plugins`,id:`change-plugins-to-remarkplugins`,to:`remarkPlugins`},{from:`rawSourcePos`,id:`#remove-rawsourcepos`},{from:`renderers`,id:`change-renderers-to-components`,to:`components`},{from:`source`,id:`change-source-to-children`,to:`children`},{from:`sourcePos`,id:`#remove-sourcepos`},{from:`transformImageUri`,id:`#add-urltransform`,to:`urlTransform`},{from:`transformLinkUri`,id:`#add-urltransform`,to:`urlTransform`}];function mV(e){let t=hV(e),n=gV(e);return _V(t.runSync(t.parse(n),n),e)}function hV(e){let t=e.rehypePlugins||uV,n=e.remarkPlugins||uV,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...dV}:dV;return eV().use(lz).use(n).use(EB,r).use(t)}function gV(e){let t=e.children||``,n=new KB;return typeof t==`string`?n.value=t:``+t,n}function _V(e,t){let n=t.allowedElements,r=t.allowElement,i=t.components,a=t.disallowedElements,o=t.skipHtml,s=t.unwrapDisallowed,c=t.urlTransform||vV;for(let e of pV)Object.hasOwn(t,e.from)&&``+e.from+(e.to?"use `"+e.to+"` instead":`remove it`)+e.id;return gB(e,l),zF(e,{Fragment:h.Fragment,components:i,ignoreInvalidStyle:!0,jsx:h.jsx,jsxs:h.jsxs,passKeys:!0,passNode:!0});function l(e,t,i){if(e.type===`raw`&&i&&typeof t==`number`)return o?i.children.splice(t,1):i.children[t]={type:`text`,value:e.value},t;if(e.type===`element`){let t;for(t in sI)if(Object.hasOwn(sI,t)&&Object.hasOwn(e.properties,t)){let n=e.properties[t],r=sI[t];(r===null||r.includes(e.tagName))&&(e.properties[t]=c(String(n||``),t,e))}}if(e.type===`element`){let o=n?!n.includes(e.tagName):a?a.includes(e.tagName):!1;if(!o&&r&&typeof t==`number`&&(o=!r(e,t,i)),o&&i&&typeof t==`number`)return s&&e.children?i.children.splice(t,1,...e.children):i.children.splice(t,1),t}}}function vV(e){let t=e.indexOf(`:`),n=e.indexOf(`?`),r=e.indexOf(`#`),i=e.indexOf(`/`);return t===-1||i!==-1&&t>i||n!==-1&&t>n||r!==-1&&t>r||fV.test(e.slice(0,t))?e:``}function yV(e,t){let n=String(e);if(typeof t!=`string`)throw TypeError(`Expected character`);let r=0,i=n.indexOf(t);for(;i!==-1;)r++,i=n.indexOf(t,i+t.length);return r}function bV(e){if(typeof e!=`string`)throw TypeError(`Expected a string`);return e.replace(/[|\\{}()[\]^$+*?.]/g,`\\$&`).replace(/-/g,`\\x2d`)}function xV(e,t,n){let r=aB((n||{}).ignore||[]),i=SV(t),a=-1;for(;++a<i.length;)mB(e,`text`,o);function o(e,t){let n=-1,i;for(;++n<t.length;){let e=t[n],a=i?i.children:void 0;if(r(e,a?a.indexOf(e):void 0,i))return;i=e}if(i)return s(e,t)}function s(e,t){let n=t[t.length-1],r=i[a][0],o=i[a][1],s=0,c=n.children.indexOf(e),l=!1,u=[];r.lastIndex=0;let d=r.exec(e.value);for(;d;){let n=d.index,i={index:d.index,input:d.input,stack:[...t,e]},a=o(...d,i);if(typeof a==`string`&&(a=a.length>0?{type:`text`,value:a}:void 0),a===!1?r.lastIndex=n+1:(s!==n&&u.push({type:`text`,value:e.value.slice(s,n)}),Array.isArray(a)?u.push(...a):a&&u.push(a),s=n+d[0].length,l=!0),!r.global)break;d=r.exec(e.value)}return l?(s<e.value.length&&u.push({type:`text`,value:e.value.slice(s)}),n.children.splice(c,1,...u)):u=[e],c+u.length}}function SV(e){let t=[];if(!Array.isArray(e))throw TypeError(`Expected find and replace tuple or list of tuples`);let n=!e[0]||Array.isArray(e[0])?e:[e],r=-1;for(;++r<n.length;){let e=n[r];t.push([CV(e[0]),wV(e[1])])}return t}function CV(e){return typeof e==`string`?new RegExp(bV(e),`g`):e}function wV(e){return typeof e==`function`?e:function(){return e}}var TV=`phrasing`,EV=[`autolink`,`link`,`image`,`label`];function DV(){return{transforms:[FV],enter:{literalAutolink:kV,literalAutolinkEmail:AV,literalAutolinkHttp:AV,literalAutolinkWww:AV},exit:{literalAutolink:PV,literalAutolinkEmail:NV,literalAutolinkHttp:jV,literalAutolinkWww:MV}}}function OV(){return{unsafe:[{character:`@`,before:`[+\\-.\\w]`,after:`[\\-.\\w]`,inConstruct:TV,notInConstruct:EV},{character:`.`,before:`[Ww]`,after:`[\\-.\\w]`,inConstruct:TV,notInConstruct:EV},{character:`:`,before:`[ps]`,after:`\\/`,inConstruct:TV,notInConstruct:EV}]}}function kV(e){this.enter({type:`link`,title:null,url:``,children:[]},e)}function AV(e){this.config.enter.autolinkProtocol.call(this,e)}function jV(e){this.config.exit.autolinkProtocol.call(this,e)}function MV(e){this.config.exit.data.call(this,e);let t=this.stack[this.stack.length-1];t.type,t.url=`http://`+this.sliceSerialize(e)}function NV(e){this.config.exit.autolinkEmail.call(this,e)}function PV(e){this.exit(e)}function FV(e){xV(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,IV],[/(?<=^|\s|\p{P}|\p{S})([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/gu,LV]],{ignore:[`link`,`linkReference`]})}function IV(e,t,n,r,i){let a=``;if(!BV(i)||(/^w/i.test(t)&&(n=t+n,t=``,a=`http://`),!RV(n)))return!1;let o=zV(n+r);if(!o[0])return!1;let s={type:`link`,title:null,url:a+t+o[0],children:[{type:`text`,value:t+o[0]}]};return o[1]?[s,{type:`text`,value:o[1]}]:s}function LV(e,t,n,r){return!BV(r,!0)||/[-\d_]$/.test(n)?!1:{type:`link`,title:null,url:`mailto:`+t+`@`+n,children:[{type:`text`,value:t+`@`+n}]}}function RV(e){let t=e.split(`.`);return!(t.length<2||t[t.length-1]&&(/_/.test(t[t.length-1])||!/[a-zA-Z\d]/.test(t[t.length-1]))||t[t.length-2]&&(/_/.test(t[t.length-2])||!/[a-zA-Z\d]/.test(t[t.length-2])))}function zV(e){let t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],r=n.indexOf(`)`),i=yV(e,`(`),a=yV(e,`)`);for(;r!==-1&&i>a;)e+=n.slice(0,r+1),n=n.slice(r+1),r=n.indexOf(`)`),a++;return[e,n]}function BV(e,t){let n=e.input.charCodeAt(e.index-1);return(e.index===0||PI(n)||NI(n))&&(!t||n!==47)}XV.peek=YV;function VV(){this.buffer()}function HV(e){this.enter({type:`footnoteReference`,identifier:``,label:``},e)}function UV(){this.buffer()}function WV(e){this.enter({type:`footnoteDefinition`,identifier:``,label:``,children:[]},e)}function GV(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=SI(this.sliceSerialize(e)).toLowerCase(),n.label=t}function KV(e){this.exit(e)}function qV(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=SI(this.sliceSerialize(e)).toLowerCase(),n.label=t}function JV(e){this.exit(e)}function YV(){return`[`}function XV(e,t,n,r){let i=n.createTracker(r),a=i.move(`[^`),o=n.enter(`footnoteReference`),s=n.enter(`reference`);return a+=i.move(n.safe(n.associationId(e),{after:`]`,before:a})),s(),o(),a+=i.move(`]`),a}function ZV(){return{enter:{gfmFootnoteCallString:VV,gfmFootnoteCall:HV,gfmFootnoteDefinitionLabelString:UV,gfmFootnoteDefinition:WV},exit:{gfmFootnoteCallString:GV,gfmFootnoteCall:KV,gfmFootnoteDefinitionLabelString:qV,gfmFootnoteDefinition:JV}}}function QV(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:XV},unsafe:[{character:`[`,inConstruct:[`label`,`phrasing`,`reference`]}]};function n(e,n,r,i){let a=r.createTracker(i),o=a.move(`[^`),s=r.enter(`footnoteDefinition`),c=r.enter(`label`);return o+=a.move(r.safe(r.associationId(e),{before:o,after:`]`})),c(),o+=a.move(`]:`),e.children&&e.children.length>0&&(a.shift(4),o+=a.move((t?`
116
- `:` `)+r.indentLines(r.containerFlow(e,a.current()),t?eH:$V))),s(),o}}function $V(e,t,n){return t===0?e:eH(e,t,n)}function eH(e,t,n){return(n?``:` `)+e}var tH=[`autolink`,`destinationLiteral`,`destinationRaw`,`reference`,`titleQuote`,`titleApostrophe`];oH.peek=sH;function nH(){return{canContainEols:[`delete`],enter:{strikethrough:iH},exit:{strikethrough:aH}}}function rH(){return{unsafe:[{character:`~`,inConstruct:`phrasing`,notInConstruct:tH}],handlers:{delete:oH}}}function iH(e){this.enter({type:`delete`,children:[]},e)}function aH(e){this.exit(e)}function oH(e,t,n,r){let i=n.createTracker(r),a=n.enter(`strikethrough`),o=i.move(`~~`);return o+=n.containerPhrasing(e,{...i.current(),before:o,after:`~`}),o+=i.move(`~~`),a(),o}function sH(){return`~`}function cH(e){return e.length}function lH(e,t){let n=t||{},r=(n.align||[]).concat(),i=n.stringLength||cH,a=[],o=[],s=[],c=[],l=0,u=-1;for(;++u<e.length;){let t=[],r=[],a=-1;for(e[u].length>l&&(l=e[u].length);++a<e[u].length;){let o=uH(e[u][a]);if(n.alignDelimiters!==!1){let e=i(o);r[a]=e,(c[a]===void 0||e>c[a])&&(c[a]=e)}t.push(o)}o[u]=t,s[u]=r}let d=-1;if(typeof r==`object`&&`length`in r)for(;++d<l;)a[d]=dH(r[d]);else{let e=dH(r);for(;++d<l;)a[d]=e}d=-1;let f=[],p=[];for(;++d<l;){let e=a[d],t=``,r=``;e===99?(t=`:`,r=`:`):e===108?t=`:`:e===114&&(r=`:`);let i=n.alignDelimiters===!1?1:Math.max(1,c[d]-t.length-r.length),o=t+`-`.repeat(i)+r;n.alignDelimiters!==!1&&(i=t.length+i+r.length,i>c[d]&&(c[d]=i),p[d]=i),f[d]=o}o.splice(1,0,f),s.splice(1,0,p),u=-1;let m=[];for(;++u<o.length;){let e=o[u],t=s[u];d=-1;let r=[];for(;++d<l;){let i=e[d]||``,o=``,s=``;if(n.alignDelimiters!==!1){let e=c[d]-(t[d]||0),n=a[d];n===114?o=` `.repeat(e):n===99?e%2?(o=` `.repeat(e/2+.5),s=` `.repeat(e/2-.5)):(o=` `.repeat(e/2),s=o):s=` `.repeat(e)}n.delimiterStart!==!1&&!d&&r.push(`|`),n.padding!==!1&&(n.alignDelimiters!==!1||i!==``)&&(n.delimiterStart!==!1||d)&&r.push(` `),n.alignDelimiters!==!1&&r.push(o),r.push(i),n.alignDelimiters!==!1&&r.push(s),n.padding!==!1&&r.push(` `),(n.delimiterEnd!==!1||d!==l-1)&&r.push(`|`)}m.push(n.delimiterEnd===!1?r.join(``).replace(/ +$/,``):r.join(``))}return m.join(`
117
- `)}function uH(e){return e==null?``:String(e)}function dH(e){let t=typeof e==`string`?e.codePointAt(0):0;return t===67||t===99?99:t===76||t===108?108:t===82||t===114?114:0}function fH(e,t,n,r){let i=n.enter(`blockquote`),a=n.createTracker(r);a.move(`> `),a.shift(2);let o=n.indentLines(n.containerFlow(e,a.current()),pH);return i(),o}function pH(e,t,n){return`>`+(n?``:` `)+e}function mH(e,t){return hH(e,t.inConstruct,!0)&&!hH(e,t.notInConstruct,!1)}function hH(e,t,n){if(typeof t==`string`&&(t=[t]),!t||t.length===0)return n;let r=-1;for(;++r<t.length;)if(e.includes(t[r]))return!0;return!1}function gH(e,t,n,r){let i=-1;for(;++i<n.unsafe.length;)if(n.unsafe[i].character===`
118
- `&&mH(n.stack,n.unsafe[i]))return/[ \t]/.test(r.before)?``:` `;return`\\
119
- `}function _H(e,t){let n=String(e),r=n.indexOf(t),i=r,a=0,o=0;if(typeof t!=`string`)throw TypeError(`Expected substring`);for(;r!==-1;)r===i?++a>o&&(o=a):a=1,i=r+t.length,r=n.indexOf(t,i);return o}function vH(e,t){return!(t.options.fences!==!1||!e.value||e.lang||!/[^ \r\n]/.test(e.value)||/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(e.value))}function yH(e){let t=e.options.fence||"`";if(t!=="`"&&t!==`~`)throw Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}function bH(e,t,n,r){let i=yH(n),a=e.value||``,o=i==="`"?`GraveAccent`:`Tilde`;if(vH(e,n)){let e=n.enter(`codeIndented`),t=n.indentLines(a,xH);return e(),t}let s=n.createTracker(r),c=i.repeat(Math.max(_H(a,i)+1,3)),l=n.enter(`codeFenced`),u=s.move(c);if(e.lang){let t=n.enter(`codeFencedLang${o}`);u+=s.move(n.safe(e.lang,{before:u,after:` `,encode:["`"],...s.current()})),t()}if(e.lang&&e.meta){let t=n.enter(`codeFencedMeta${o}`);u+=s.move(` `),u+=s.move(n.safe(e.meta,{before:u,after:`
114
+ `}),n}function TB(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function EB(e,t){let n=bB(e,t),r=n.one(e,void 0),i=aB(n),a=Array.isArray(r)?{type:`root`,children:r}:r||{type:`root`,children:[]};return i&&(`children`in a,a.children.push({type:`text`,value:`
115
+ `},i)),a}function DB(e,t){return e&&`run`in e?async function(n,r){let i=EB(n,{file:r,...t});await e.run(i,r)}:function(n,r){return EB(n,{file:r,...e||t})}}function OB(e){if(e)throw e}var kB=o(((e,t)=>{var n=Object.prototype.hasOwnProperty,r=Object.prototype.toString,i=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o=function(e){return typeof Array.isArray==`function`?Array.isArray(e):r.call(e)===`[object Array]`},s=function(e){if(!e||r.call(e)!==`[object Object]`)return!1;var t=n.call(e,`constructor`),i=e.constructor&&e.constructor.prototype&&n.call(e.constructor.prototype,`isPrototypeOf`);if(e.constructor&&!t&&!i)return!1;for(var a in e);return a===void 0||n.call(e,a)},c=function(e,t){i&&t.name===`__proto__`?i(e,t.name,{enumerable:!0,configurable:!0,value:t.newValue,writable:!0}):e[t.name]=t.newValue},l=function(e,t){if(t===`__proto__`){if(!n.call(e,t))return;if(a)return a(e,t).value}return e[t]};t.exports=function e(){var t,n,r,i,a,u,d=arguments[0],f=1,p=arguments.length,m=!1;for(typeof d==`boolean`&&(m=d,d=arguments[1]||{},f=2),(d==null||typeof d!=`object`&&typeof d!=`function`)&&(d={});f<p;++f)if(t=arguments[f],t!=null)for(n in t)r=l(d,n),i=l(t,n),d!==i&&(m&&i&&(s(i)||(a=o(i)))?(a?(a=!1,u=r&&o(r)?r:[]):u=r&&s(r)?r:{},c(d,{name:n,newValue:e(m,u,i)})):i!==void 0&&c(d,{name:n,newValue:i}));return d}}));function AB(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function jB(){let e=[],t={run:n,use:r};return t;function n(...t){let n=-1,r=t.pop();if(typeof r!=`function`)throw TypeError(`Expected function as last argument, not `+r);i(null,...t);function i(a,...o){let s=e[++n],c=-1;if(a){r(a);return}for(;++c<t.length;)(o[c]===null||o[c]===void 0)&&(o[c]=t[c]);t=o,s?MB(s,i)(...o):r(null,...o)}}function r(n){if(typeof n!=`function`)throw TypeError("Expected `middelware` to be a function, not "+n);return e.push(n),t}}function MB(e,t){let n;return r;function r(...t){let r=e.length>t.length,o;r&&t.push(i);try{o=e.apply(this,t)}catch(e){let t=e;if(r&&n)throw t;return i(t)}r||(o&&o.then&&typeof o.then==`function`?o.then(a,i):o instanceof Error?i(o):a(o))}function i(e,...r){n||(n=!0,t(e,...r))}function a(e){i(null,e)}}var NB={basename:PB,dirname:FB,extname:IB,join:LB,sep:`/`};function PB(e,t){if(t!==void 0&&typeof t!=`string`)throw TypeError(`"ext" argument must be a string`);BB(e);let n=0,r=-1,i=e.length,a;if(t===void 0||t.length===0||t.length>e.length){for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else r<0&&(a=!0,r=i+1);return r<0?``:e.slice(n,r)}if(t===e)return``;let o=-1,s=t.length-1;for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else o<0&&(a=!0,o=i+1),s>-1&&(e.codePointAt(i)===t.codePointAt(s--)?s<0&&(r=i):(s=-1,r=o));return n===r?r=o:r<0&&(r=e.length),e.slice(n,r)}function FB(e){if(BB(e),e.length===0)return`.`;let t=-1,n=e.length,r;for(;--n;)if(e.codePointAt(n)===47){if(r){t=n;break}}else r||=!0;return t<0?e.codePointAt(0)===47?`/`:`.`:t===1&&e.codePointAt(0)===47?`//`:e.slice(0,t)}function IB(e){BB(e);let t=e.length,n=-1,r=0,i=-1,a=0,o;for(;t--;){let s=e.codePointAt(t);if(s===47){if(o){r=t+1;break}continue}n<0&&(o=!0,n=t+1),s===46?i<0?i=t:a!==1&&(a=1):i>-1&&(a=-1)}return i<0||n<0||a===0||a===1&&i===n-1&&i===r+1?``:e.slice(i,n)}function LB(...e){let t=-1,n;for(;++t<e.length;)BB(e[t]),e[t]&&(n=n===void 0?e[t]:n+`/`+e[t]);return n===void 0?`.`:RB(n)}function RB(e){BB(e);let t=e.codePointAt(0)===47,n=zB(e,!t);return n.length===0&&!t&&(n=`.`),n.length>0&&e.codePointAt(e.length-1)===47&&(n+=`/`),t?`/`+n:n}function zB(e,t){let n=``,r=0,i=-1,a=0,o=-1,s,c;for(;++o<=e.length;){if(o<e.length)s=e.codePointAt(o);else if(s===47)break;else s=47;if(s===47){if(i!==o-1&&a!==1){if(i!==o-1&&a===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(c=n.lastIndexOf(`/`),c!==n.length-1){c<0?(n=``,r=0):(n=n.slice(0,c),r=n.length-1-n.lastIndexOf(`/`)),i=o,a=0;continue}}else if(n.length>0){n=``,r=0,i=o,a=0;continue}}t&&(n=n.length>0?n+`/..`:`..`,r=2)}else n.length>0?n+=`/`+e.slice(i+1,o):n=e.slice(i+1,o),r=o-i-1}i=o,a=0}else s===46&&a>-1?a++:a=-1}return n}function BB(e){if(typeof e!=`string`)throw TypeError(`Path must be a string. Received `+JSON.stringify(e))}var VB={cwd:HB};function HB(){return`/`}function UB(e){return!!(typeof e==`object`&&e&&`href`in e&&e.href&&`protocol`in e&&e.protocol&&e.auth===void 0)}function WB(e){if(typeof e==`string`)e=new URL(e);else if(!UB(e)){let t=TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code=`ERR_INVALID_ARG_TYPE`,t}if(e.protocol!==`file:`){let e=TypeError(`The URL must be of scheme file`);throw e.code=`ERR_INVALID_URL_SCHEME`,e}return GB(e)}function GB(e){if(e.hostname!==``){let e=TypeError(`File URL host must be "localhost" or empty on darwin`);throw e.code=`ERR_INVALID_FILE_URL_HOST`,e}let t=e.pathname,n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){let e=t.codePointAt(n+2);if(e===70||e===102){let e=TypeError(`File URL path must not include encoded / characters`);throw e.code=`ERR_INVALID_FILE_URL_PATH`,e}}return decodeURIComponent(t)}var KB=[`history`,`path`,`basename`,`stem`,`extname`,`dirname`],qB=class{constructor(e){let t;t=e?UB(e)?{path:e}:typeof e==`string`||ZB(e)?{value:e}:e:{},this.cwd=`cwd`in t?``:VB.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let n=-1;for(;++n<KB.length;){let e=KB[n];e in t&&t[e]!==void 0&&t[e]!==null&&(this[e]=e===`history`?[...t[e]]:t[e])}let r;for(r in t)KB.includes(r)||(this[r]=t[r])}get basename(){return typeof this.path==`string`?NB.basename(this.path):void 0}set basename(e){YB(e,`basename`),JB(e,`basename`),this.path=NB.join(this.dirname||``,e)}get dirname(){return typeof this.path==`string`?NB.dirname(this.path):void 0}set dirname(e){XB(this.basename,`dirname`),this.path=NB.join(e||``,this.basename)}get extname(){return typeof this.path==`string`?NB.extname(this.path):void 0}set extname(e){if(JB(e,`extname`),XB(this.dirname,`extname`),e){if(e.codePointAt(0)!==46)throw Error("`extname` must start with `.`");if(e.includes(`.`,1))throw Error("`extname` cannot contain multiple dots")}this.path=NB.join(this.dirname,this.stem+(e||``))}get path(){return this.history[this.history.length-1]}set path(e){UB(e)&&(e=WB(e)),YB(e,`path`),this.path!==e&&this.history.push(e)}get stem(){return typeof this.path==`string`?NB.basename(this.path,this.extname):void 0}set stem(e){YB(e,`stem`),JB(e,`stem`),this.path=NB.join(this.dirname||``,e+(this.extname||``))}fail(e,t,n){let r=this.message(e,t,n);throw r.fatal=!0,r}info(e,t,n){let r=this.message(e,t,n);return r.fatal=void 0,r}message(e,t,n){let r=new MF(e,t,n);return this.path&&(r.name=this.path+`:`+r.name,r.file=this.path),r.fatal=!1,this.messages.push(r),r}toString(e){return this.value===void 0?``:typeof this.value==`string`?this.value:new TextDecoder(e||void 0).decode(this.value)}};function JB(e,t){if(e&&e.includes(NB.sep))throw Error("`"+t+"` cannot be a path: did not expect `"+NB.sep+"`")}function YB(e,t){if(!e)throw Error("`"+t+"` cannot be empty")}function XB(e,t){if(!e)throw Error("Setting `"+t+"` requires `path` to be set too")}function ZB(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var QB=(function(e){let t=this.constructor.prototype,n=t[e],r=function(){return n.apply(r,arguments)};return Object.setPrototypeOf(r,t),r}),$B=l(kB(),1),eV={}.hasOwnProperty,tV=new class e extends QB{constructor(){super(`copy`),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=jB()}copy(){let t=new e,n=-1;for(;++n<this.attachers.length;){let e=this.attachers[n];t.use(...e)}return t.data((0,$B.default)(!0,{},this.namespace)),t}data(e,t){return typeof e==`string`?arguments.length===2?(iV(`data`,this.frozen),this.namespace[e]=t,this):eV.call(this.namespace,e)&&this.namespace[e]||void 0:e?(iV(`data`,this.frozen),this.namespace=e,this):this.namespace}freeze(){if(this.frozen)return this;let e=this;for(;++this.freezeIndex<this.attachers.length;){let[t,...n]=this.attachers[this.freezeIndex];if(n[0]===!1)continue;n[0]===!0&&(n[0]=void 0);let r=t.call(e,...n);typeof r==`function`&&this.transformers.use(r)}return this.frozen=!0,this.freezeIndex=1/0,this}parse(e){this.freeze();let t=sV(e),n=this.parser||this.Parser;return nV(`parse`,n),n(String(t),t)}process(e,t){let n=this;return this.freeze(),nV(`process`,this.parser||this.Parser),rV(`process`,this.compiler||this.Compiler),t?r(void 0,t):new Promise(r);function r(r,i){let a=sV(e),o=n.parse(a);n.run(o,a,function(e,t,r){if(e||!t||!r)return s(e);let i=t,a=n.stringify(i,r);lV(a)?r.value=a:r.result=a,s(e,r)});function s(e,n){e||!n?i(e):r?r(n):t(void 0,n)}}}processSync(e){let t=!1,n;return this.freeze(),nV(`processSync`,this.parser||this.Parser),rV(`processSync`,this.compiler||this.Compiler),this.process(e,r),oV(`processSync`,`process`,t),n;function r(e,r){t=!0,OB(e),n=r}}run(e,t,n){aV(e),this.freeze();let r=this.transformers;return!n&&typeof t==`function`&&(n=t,t=void 0),n?i(void 0,n):new Promise(i);function i(i,a){let o=sV(t);r.run(e,o,s);function s(t,r,o){let s=r||e;t?a(t):i?i(s):n(void 0,s,o)}}}runSync(e,t){let n=!1,r;return this.run(e,t,i),oV(`runSync`,`run`,n),r;function i(e,t){OB(e),r=t,n=!0}}stringify(e,t){this.freeze();let n=sV(t),r=this.compiler||this.Compiler;return rV(`stringify`,r),aV(e),r(e,n)}use(e,...t){let n=this.attachers,r=this.namespace;if(iV(`use`,this.frozen),e!=null){if(typeof e==`function`)s(e,t);else if(typeof e==`object`)Array.isArray(e)?o(e):a(e);else throw TypeError("Expected usable value, not `"+e+"`")}return this;function i(e){if(typeof e==`function`)s(e,[]);else if(typeof e==`object`){if(Array.isArray(e)){let[t,...n]=e;s(t,n)}else a(e)}else throw TypeError("Expected usable value, not `"+e+"`")}function a(e){if(!(`plugins`in e)&&!(`settings`in e))throw Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");o(e.plugins),e.settings&&(r.settings=(0,$B.default)(!0,r.settings,e.settings))}function o(e){let t=-1;if(e!=null){if(Array.isArray(e))for(;++t<e.length;){let n=e[t];i(n)}else throw TypeError("Expected a list of plugins, not `"+e+"`")}}function s(e,t){let r=-1,i=-1;for(;++r<n.length;)if(n[r][0]===e){i=r;break}if(i===-1)n.push([e,...t]);else if(t.length>0){let[r,...a]=t,o=n[i][1];AB(o)&&AB(r)&&(r=(0,$B.default)(!0,o,r)),n[i]=[e,r,...a]}}}}().freeze();function nV(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `parser`")}function rV(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `compiler`")}function iV(e,t){if(t)throw Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function aV(e){if(!AB(e)||typeof e.type!=`string`)throw TypeError("Expected node, got `"+e+"`")}function oV(e,t,n){if(!n)throw Error("`"+e+"` finished async. Use `"+t+"` instead")}function sV(e){return cV(e)?e:new qB(e)}function cV(e){return!!(e&&typeof e==`object`&&`message`in e&&`messages`in e)}function lV(e){return typeof e==`string`||uV(e)}function uV(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var dV=[],fV={allowDangerousHtml:!0},pV=/^(https?|ircs?|mailto|xmpp)$/i,mV=[{from:`astPlugins`,id:`remove-buggy-html-in-markdown-parser`},{from:`allowDangerousHtml`,id:`remove-buggy-html-in-markdown-parser`},{from:`allowNode`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`allowElement`},{from:`allowedTypes`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`allowedElements`},{from:`className`,id:`remove-classname`},{from:`disallowedTypes`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`disallowedElements`},{from:`escapeHtml`,id:`remove-buggy-html-in-markdown-parser`},{from:`includeElementIndex`,id:`#remove-includeelementindex`},{from:`includeNodeIndex`,id:`change-includenodeindex-to-includeelementindex`},{from:`linkTarget`,id:`remove-linktarget`},{from:`plugins`,id:`change-plugins-to-remarkplugins`,to:`remarkPlugins`},{from:`rawSourcePos`,id:`#remove-rawsourcepos`},{from:`renderers`,id:`change-renderers-to-components`,to:`components`},{from:`source`,id:`change-source-to-children`,to:`children`},{from:`sourcePos`,id:`#remove-sourcepos`},{from:`transformImageUri`,id:`#add-urltransform`,to:`urlTransform`},{from:`transformLinkUri`,id:`#add-urltransform`,to:`urlTransform`}];function hV(e){let t=gV(e),n=_V(e);return vV(t.runSync(t.parse(n),n),e)}function gV(e){let t=e.rehypePlugins||dV,n=e.remarkPlugins||dV,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...fV}:fV;return tV().use(uz).use(n).use(DB,r).use(t)}function _V(e){let t=e.children||``,n=new qB;return typeof t==`string`?n.value=t:``+t,n}function vV(e,t){let n=t.allowedElements,r=t.allowElement,i=t.components,a=t.disallowedElements,o=t.skipHtml,s=t.unwrapDisallowed,c=t.urlTransform||yV;for(let e of mV)Object.hasOwn(t,e.from)&&``+e.from+(e.to?"use `"+e.to+"` instead":`remove it`)+e.id;return _B(e,l),BF(e,{Fragment:h.Fragment,components:i,ignoreInvalidStyle:!0,jsx:h.jsx,jsxs:h.jsxs,passKeys:!0,passNode:!0});function l(e,t,i){if(e.type===`raw`&&i&&typeof t==`number`)return o?i.children.splice(t,1):i.children[t]={type:`text`,value:e.value},t;if(e.type===`element`){let t;for(t in cI)if(Object.hasOwn(cI,t)&&Object.hasOwn(e.properties,t)){let n=e.properties[t],r=cI[t];(r===null||r.includes(e.tagName))&&(e.properties[t]=c(String(n||``),t,e))}}if(e.type===`element`){let o=n?!n.includes(e.tagName):a?a.includes(e.tagName):!1;if(!o&&r&&typeof t==`number`&&(o=!r(e,t,i)),o&&i&&typeof t==`number`)return s&&e.children?i.children.splice(t,1,...e.children):i.children.splice(t,1),t}}}function yV(e){let t=e.indexOf(`:`),n=e.indexOf(`?`),r=e.indexOf(`#`),i=e.indexOf(`/`);return t===-1||i!==-1&&t>i||n!==-1&&t>n||r!==-1&&t>r||pV.test(e.slice(0,t))?e:``}function bV(e,t){let n=String(e);if(typeof t!=`string`)throw TypeError(`Expected character`);let r=0,i=n.indexOf(t);for(;i!==-1;)r++,i=n.indexOf(t,i+t.length);return r}function xV(e){if(typeof e!=`string`)throw TypeError(`Expected a string`);return e.replace(/[|\\{}()[\]^$+*?.]/g,`\\$&`).replace(/-/g,`\\x2d`)}function SV(e,t,n){let r=oB((n||{}).ignore||[]),i=CV(t),a=-1;for(;++a<i.length;)hB(e,`text`,o);function o(e,t){let n=-1,i;for(;++n<t.length;){let e=t[n],a=i?i.children:void 0;if(r(e,a?a.indexOf(e):void 0,i))return;i=e}if(i)return s(e,t)}function s(e,t){let n=t[t.length-1],r=i[a][0],o=i[a][1],s=0,c=n.children.indexOf(e),l=!1,u=[];r.lastIndex=0;let d=r.exec(e.value);for(;d;){let n=d.index,i={index:d.index,input:d.input,stack:[...t,e]},a=o(...d,i);if(typeof a==`string`&&(a=a.length>0?{type:`text`,value:a}:void 0),a===!1?r.lastIndex=n+1:(s!==n&&u.push({type:`text`,value:e.value.slice(s,n)}),Array.isArray(a)?u.push(...a):a&&u.push(a),s=n+d[0].length,l=!0),!r.global)break;d=r.exec(e.value)}return l?(s<e.value.length&&u.push({type:`text`,value:e.value.slice(s)}),n.children.splice(c,1,...u)):u=[e],c+u.length}}function CV(e){let t=[];if(!Array.isArray(e))throw TypeError(`Expected find and replace tuple or list of tuples`);let n=!e[0]||Array.isArray(e[0])?e:[e],r=-1;for(;++r<n.length;){let e=n[r];t.push([wV(e[0]),TV(e[1])])}return t}function wV(e){return typeof e==`string`?new RegExp(xV(e),`g`):e}function TV(e){return typeof e==`function`?e:function(){return e}}var EV=`phrasing`,DV=[`autolink`,`link`,`image`,`label`];function OV(){return{transforms:[IV],enter:{literalAutolink:AV,literalAutolinkEmail:jV,literalAutolinkHttp:jV,literalAutolinkWww:jV},exit:{literalAutolink:FV,literalAutolinkEmail:PV,literalAutolinkHttp:MV,literalAutolinkWww:NV}}}function kV(){return{unsafe:[{character:`@`,before:`[+\\-.\\w]`,after:`[\\-.\\w]`,inConstruct:EV,notInConstruct:DV},{character:`.`,before:`[Ww]`,after:`[\\-.\\w]`,inConstruct:EV,notInConstruct:DV},{character:`:`,before:`[ps]`,after:`\\/`,inConstruct:EV,notInConstruct:DV}]}}function AV(e){this.enter({type:`link`,title:null,url:``,children:[]},e)}function jV(e){this.config.enter.autolinkProtocol.call(this,e)}function MV(e){this.config.exit.autolinkProtocol.call(this,e)}function NV(e){this.config.exit.data.call(this,e);let t=this.stack[this.stack.length-1];t.type,t.url=`http://`+this.sliceSerialize(e)}function PV(e){this.config.exit.autolinkEmail.call(this,e)}function FV(e){this.exit(e)}function IV(e){SV(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,LV],[/(?<=^|\s|\p{P}|\p{S})([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/gu,RV]],{ignore:[`link`,`linkReference`]})}function LV(e,t,n,r,i){let a=``;if(!VV(i)||(/^w/i.test(t)&&(n=t+n,t=``,a=`http://`),!zV(n)))return!1;let o=BV(n+r);if(!o[0])return!1;let s={type:`link`,title:null,url:a+t+o[0],children:[{type:`text`,value:t+o[0]}]};return o[1]?[s,{type:`text`,value:o[1]}]:s}function RV(e,t,n,r){return!VV(r,!0)||/[-\d_]$/.test(n)?!1:{type:`link`,title:null,url:`mailto:`+t+`@`+n,children:[{type:`text`,value:t+`@`+n}]}}function zV(e){let t=e.split(`.`);return!(t.length<2||t[t.length-1]&&(/_/.test(t[t.length-1])||!/[a-zA-Z\d]/.test(t[t.length-1]))||t[t.length-2]&&(/_/.test(t[t.length-2])||!/[a-zA-Z\d]/.test(t[t.length-2])))}function BV(e){let t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],r=n.indexOf(`)`),i=bV(e,`(`),a=bV(e,`)`);for(;r!==-1&&i>a;)e+=n.slice(0,r+1),n=n.slice(r+1),r=n.indexOf(`)`),a++;return[e,n]}function VV(e,t){let n=e.input.charCodeAt(e.index-1);return(e.index===0||FI(n)||PI(n))&&(!t||n!==47)}ZV.peek=XV;function HV(){this.buffer()}function UV(e){this.enter({type:`footnoteReference`,identifier:``,label:``},e)}function WV(){this.buffer()}function GV(e){this.enter({type:`footnoteDefinition`,identifier:``,label:``,children:[]},e)}function KV(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=CI(this.sliceSerialize(e)).toLowerCase(),n.label=t}function qV(e){this.exit(e)}function JV(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=CI(this.sliceSerialize(e)).toLowerCase(),n.label=t}function YV(e){this.exit(e)}function XV(){return`[`}function ZV(e,t,n,r){let i=n.createTracker(r),a=i.move(`[^`),o=n.enter(`footnoteReference`),s=n.enter(`reference`);return a+=i.move(n.safe(n.associationId(e),{after:`]`,before:a})),s(),o(),a+=i.move(`]`),a}function QV(){return{enter:{gfmFootnoteCallString:HV,gfmFootnoteCall:UV,gfmFootnoteDefinitionLabelString:WV,gfmFootnoteDefinition:GV},exit:{gfmFootnoteCallString:KV,gfmFootnoteCall:qV,gfmFootnoteDefinitionLabelString:JV,gfmFootnoteDefinition:YV}}}function $V(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:ZV},unsafe:[{character:`[`,inConstruct:[`label`,`phrasing`,`reference`]}]};function n(e,n,r,i){let a=r.createTracker(i),o=a.move(`[^`),s=r.enter(`footnoteDefinition`),c=r.enter(`label`);return o+=a.move(r.safe(r.associationId(e),{before:o,after:`]`})),c(),o+=a.move(`]:`),e.children&&e.children.length>0&&(a.shift(4),o+=a.move((t?`
116
+ `:` `)+r.indentLines(r.containerFlow(e,a.current()),t?tH:eH))),s(),o}}function eH(e,t,n){return t===0?e:tH(e,t,n)}function tH(e,t,n){return(n?``:` `)+e}var nH=[`autolink`,`destinationLiteral`,`destinationRaw`,`reference`,`titleQuote`,`titleApostrophe`];sH.peek=cH;function rH(){return{canContainEols:[`delete`],enter:{strikethrough:aH},exit:{strikethrough:oH}}}function iH(){return{unsafe:[{character:`~`,inConstruct:`phrasing`,notInConstruct:nH}],handlers:{delete:sH}}}function aH(e){this.enter({type:`delete`,children:[]},e)}function oH(e){this.exit(e)}function sH(e,t,n,r){let i=n.createTracker(r),a=n.enter(`strikethrough`),o=i.move(`~~`);return o+=n.containerPhrasing(e,{...i.current(),before:o,after:`~`}),o+=i.move(`~~`),a(),o}function cH(){return`~`}function lH(e){return e.length}function uH(e,t){let n=t||{},r=(n.align||[]).concat(),i=n.stringLength||lH,a=[],o=[],s=[],c=[],l=0,u=-1;for(;++u<e.length;){let t=[],r=[],a=-1;for(e[u].length>l&&(l=e[u].length);++a<e[u].length;){let o=dH(e[u][a]);if(n.alignDelimiters!==!1){let e=i(o);r[a]=e,(c[a]===void 0||e>c[a])&&(c[a]=e)}t.push(o)}o[u]=t,s[u]=r}let d=-1;if(typeof r==`object`&&`length`in r)for(;++d<l;)a[d]=fH(r[d]);else{let e=fH(r);for(;++d<l;)a[d]=e}d=-1;let f=[],p=[];for(;++d<l;){let e=a[d],t=``,r=``;e===99?(t=`:`,r=`:`):e===108?t=`:`:e===114&&(r=`:`);let i=n.alignDelimiters===!1?1:Math.max(1,c[d]-t.length-r.length),o=t+`-`.repeat(i)+r;n.alignDelimiters!==!1&&(i=t.length+i+r.length,i>c[d]&&(c[d]=i),p[d]=i),f[d]=o}o.splice(1,0,f),s.splice(1,0,p),u=-1;let m=[];for(;++u<o.length;){let e=o[u],t=s[u];d=-1;let r=[];for(;++d<l;){let i=e[d]||``,o=``,s=``;if(n.alignDelimiters!==!1){let e=c[d]-(t[d]||0),n=a[d];n===114?o=` `.repeat(e):n===99?e%2?(o=` `.repeat(e/2+.5),s=` `.repeat(e/2-.5)):(o=` `.repeat(e/2),s=o):s=` `.repeat(e)}n.delimiterStart!==!1&&!d&&r.push(`|`),n.padding!==!1&&(n.alignDelimiters!==!1||i!==``)&&(n.delimiterStart!==!1||d)&&r.push(` `),n.alignDelimiters!==!1&&r.push(o),r.push(i),n.alignDelimiters!==!1&&r.push(s),n.padding!==!1&&r.push(` `),(n.delimiterEnd!==!1||d!==l-1)&&r.push(`|`)}m.push(n.delimiterEnd===!1?r.join(``).replace(/ +$/,``):r.join(``))}return m.join(`
117
+ `)}function dH(e){return e==null?``:String(e)}function fH(e){let t=typeof e==`string`?e.codePointAt(0):0;return t===67||t===99?99:t===76||t===108?108:t===82||t===114?114:0}function pH(e,t,n,r){let i=n.enter(`blockquote`),a=n.createTracker(r);a.move(`> `),a.shift(2);let o=n.indentLines(n.containerFlow(e,a.current()),mH);return i(),o}function mH(e,t,n){return`>`+(n?``:` `)+e}function hH(e,t){return gH(e,t.inConstruct,!0)&&!gH(e,t.notInConstruct,!1)}function gH(e,t,n){if(typeof t==`string`&&(t=[t]),!t||t.length===0)return n;let r=-1;for(;++r<t.length;)if(e.includes(t[r]))return!0;return!1}function _H(e,t,n,r){let i=-1;for(;++i<n.unsafe.length;)if(n.unsafe[i].character===`
118
+ `&&hH(n.stack,n.unsafe[i]))return/[ \t]/.test(r.before)?``:` `;return`\\
119
+ `}function vH(e,t){let n=String(e),r=n.indexOf(t),i=r,a=0,o=0;if(typeof t!=`string`)throw TypeError(`Expected substring`);for(;r!==-1;)r===i?++a>o&&(o=a):a=1,i=r+t.length,r=n.indexOf(t,i);return o}function yH(e,t){return!(t.options.fences!==!1||!e.value||e.lang||!/[^ \r\n]/.test(e.value)||/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(e.value))}function bH(e){let t=e.options.fence||"`";if(t!=="`"&&t!==`~`)throw Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}function xH(e,t,n,r){let i=bH(n),a=e.value||``,o=i==="`"?`GraveAccent`:`Tilde`;if(yH(e,n)){let e=n.enter(`codeIndented`),t=n.indentLines(a,SH);return e(),t}let s=n.createTracker(r),c=i.repeat(Math.max(vH(a,i)+1,3)),l=n.enter(`codeFenced`),u=s.move(c);if(e.lang){let t=n.enter(`codeFencedLang${o}`);u+=s.move(n.safe(e.lang,{before:u,after:` `,encode:["`"],...s.current()})),t()}if(e.lang&&e.meta){let t=n.enter(`codeFencedMeta${o}`);u+=s.move(` `),u+=s.move(n.safe(e.meta,{before:u,after:`
120
120
  `,encode:["`"],...s.current()})),t()}return u+=s.move(`
121
121
  `),a&&(u+=s.move(a+`
122
- `)),u+=s.move(c),l(),u}function xH(e,t,n){return(n?``:` `)+e}function SH(e){let t=e.options.quote||`"`;if(t!==`"`&&t!==`'`)throw Error("Cannot serialize title with `"+t+"` for `options.quote`, expected `\"`, or `'`");return t}function CH(e,t,n,r){let i=SH(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.enter(`definition`),s=n.enter(`label`),c=n.createTracker(r),l=c.move(`[`);return l+=c.move(n.safe(n.associationId(e),{before:l,after:`]`,...c.current()})),l+=c.move(`]: `),s(),!e.url||/[\0- \u007F]/.test(e.url)?(s=n.enter(`destinationLiteral`),l+=c.move(`<`),l+=c.move(n.safe(e.url,{before:l,after:`>`,...c.current()})),l+=c.move(`>`)):(s=n.enter(`destinationRaw`),l+=c.move(n.safe(e.url,{before:l,after:e.title?` `:`
123
- `,...c.current()}))),s(),e.title&&(s=n.enter(`title${a}`),l+=c.move(` `+i),l+=c.move(n.safe(e.title,{before:l,after:i,...c.current()})),l+=c.move(i),s()),o(),l}function wH(e){let t=e.options.emphasis||`*`;if(t!==`*`&&t!==`_`)throw Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}function TH(e){return`&#x`+e.toString(16).toUpperCase()+`;`}function EH(e,t,n){let r=WI(e),i=WI(t);return r===void 0?i===void 0?n===`_`?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:r===1?i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}DH.peek=OH;function DH(e,t,n,r){let i=wH(n),a=n.enter(`emphasis`),o=n.createTracker(r),s=o.move(i),c=o.move(n.containerPhrasing(e,{after:i,before:s,...o.current()})),l=c.charCodeAt(0),u=EH(r.before.charCodeAt(r.before.length-1),l,i);u.inside&&(c=TH(l)+c.slice(1));let d=c.charCodeAt(c.length-1),f=EH(r.after.charCodeAt(0),d,i);f.inside&&(c=c.slice(0,-1)+TH(d));let p=o.move(i);return a(),n.attentionEncodeSurroundingInfo={after:f.outside,before:u.outside},s+c+p}function OH(e,t,n){return n.options.emphasis||`*`}function kH(e,t){let n=!1;return gB(e,function(e){if(`value`in e&&/\r?\n|\r/.test(e.value)||e.type===`break`)return n=!0,!1}),!!((!e.depth||e.depth<3)&&lI(e)&&(t.options.setext||n))}function AH(e,t,n,r){let i=Math.max(Math.min(6,e.depth||1),1),a=n.createTracker(r);if(kH(e,n)){let t=n.enter(`headingSetext`),r=n.enter(`phrasing`),o=n.containerPhrasing(e,{...a.current(),before:`
122
+ `)),u+=s.move(c),l(),u}function SH(e,t,n){return(n?``:` `)+e}function CH(e){let t=e.options.quote||`"`;if(t!==`"`&&t!==`'`)throw Error("Cannot serialize title with `"+t+"` for `options.quote`, expected `\"`, or `'`");return t}function wH(e,t,n,r){let i=CH(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.enter(`definition`),s=n.enter(`label`),c=n.createTracker(r),l=c.move(`[`);return l+=c.move(n.safe(n.associationId(e),{before:l,after:`]`,...c.current()})),l+=c.move(`]: `),s(),!e.url||/[\0- \u007F]/.test(e.url)?(s=n.enter(`destinationLiteral`),l+=c.move(`<`),l+=c.move(n.safe(e.url,{before:l,after:`>`,...c.current()})),l+=c.move(`>`)):(s=n.enter(`destinationRaw`),l+=c.move(n.safe(e.url,{before:l,after:e.title?` `:`
123
+ `,...c.current()}))),s(),e.title&&(s=n.enter(`title${a}`),l+=c.move(` `+i),l+=c.move(n.safe(e.title,{before:l,after:i,...c.current()})),l+=c.move(i),s()),o(),l}function TH(e){let t=e.options.emphasis||`*`;if(t!==`*`&&t!==`_`)throw Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}function EH(e){return`&#x`+e.toString(16).toUpperCase()+`;`}function DH(e,t,n){let r=GI(e),i=GI(t);return r===void 0?i===void 0?n===`_`?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:r===1?i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}OH.peek=kH;function OH(e,t,n,r){let i=TH(n),a=n.enter(`emphasis`),o=n.createTracker(r),s=o.move(i),c=o.move(n.containerPhrasing(e,{after:i,before:s,...o.current()})),l=c.charCodeAt(0),u=DH(r.before.charCodeAt(r.before.length-1),l,i);u.inside&&(c=EH(l)+c.slice(1));let d=c.charCodeAt(c.length-1),f=DH(r.after.charCodeAt(0),d,i);f.inside&&(c=c.slice(0,-1)+EH(d));let p=o.move(i);return a(),n.attentionEncodeSurroundingInfo={after:f.outside,before:u.outside},s+c+p}function kH(e,t,n){return n.options.emphasis||`*`}function AH(e,t){let n=!1;return _B(e,function(e){if(`value`in e&&/\r?\n|\r/.test(e.value)||e.type===`break`)return n=!0,!1}),!!((!e.depth||e.depth<3)&&uI(e)&&(t.options.setext||n))}function jH(e,t,n,r){let i=Math.max(Math.min(6,e.depth||1),1),a=n.createTracker(r);if(AH(e,n)){let t=n.enter(`headingSetext`),r=n.enter(`phrasing`),o=n.containerPhrasing(e,{...a.current(),before:`
124
124
  `,after:`
125
125
  `});return r(),t(),o+`
126
126
  `+(i===1?`=`:`-`).repeat(o.length-(Math.max(o.lastIndexOf(`\r`),o.lastIndexOf(`
127
127
  `))+1))}let o=`#`.repeat(i),s=n.enter(`headingAtx`),c=n.enter(`phrasing`);a.move(o+` `);let l=n.containerPhrasing(e,{before:`# `,after:`
128
- `,...a.current()});return/^[\t ]/.test(l)&&(l=TH(l.charCodeAt(0))+l.slice(1)),l=l?o+` `+l:o,n.options.closeAtx&&(l+=` `+o),c(),s(),l}jH.peek=MH;function jH(e){return e.value||``}function MH(){return`<`}NH.peek=PH;function NH(e,t,n,r){let i=SH(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.enter(`image`),s=n.enter(`label`),c=n.createTracker(r),l=c.move(`![`);return l+=c.move(n.safe(e.alt,{before:l,after:`]`,...c.current()})),l+=c.move(`](`),s(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(s=n.enter(`destinationLiteral`),l+=c.move(`<`),l+=c.move(n.safe(e.url,{before:l,after:`>`,...c.current()})),l+=c.move(`>`)):(s=n.enter(`destinationRaw`),l+=c.move(n.safe(e.url,{before:l,after:e.title?` `:`)`,...c.current()}))),s(),e.title&&(s=n.enter(`title${a}`),l+=c.move(` `+i),l+=c.move(n.safe(e.title,{before:l,after:i,...c.current()})),l+=c.move(i),s()),l+=c.move(`)`),o(),l}function PH(){return`!`}FH.peek=IH;function FH(e,t,n,r){let i=e.referenceType,a=n.enter(`imageReference`),o=n.enter(`label`),s=n.createTracker(r),c=s.move(`![`),l=n.safe(e.alt,{before:c,after:`]`,...s.current()});c+=s.move(l+`][`),o();let u=n.stack;n.stack=[],o=n.enter(`reference`);let d=n.safe(n.associationId(e),{before:c,after:`]`,...s.current()});return o(),n.stack=u,a(),i===`full`||!l||l!==d?c+=s.move(d+`]`):i===`shortcut`?c=c.slice(0,-1):c+=s.move(`]`),c}function IH(){return`!`}LH.peek=RH;function LH(e,t,n){let r=e.value||``,i="`",a=-1;for(;RegExp("(^|[^`])"+i+"([^`]|$)").test(r);)i+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=` `+r+` `);++a<n.unsafe.length;){let e=n.unsafe[a],t=n.compilePattern(e),i;if(e.atBreak)for(;i=t.exec(r);){let e=i.index;r.charCodeAt(e)===10&&r.charCodeAt(e-1)===13&&e--,r=r.slice(0,e)+` `+r.slice(i.index+1)}}return i+r+i}function RH(){return"`"}function zH(e,t){let n=lI(e);return!(t.options.resourceLink||!e.url||e.title||!e.children||e.children.length!==1||e.children[0].type!==`text`||n!==e.url&&`mailto:`+n!==e.url||!/^[a-z][a-z+.-]+:/i.test(e.url)||/[\0- <>\u007F]/.test(e.url))}BH.peek=VH;function BH(e,t,n,r){let i=SH(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.createTracker(r),s,c;if(zH(e,n)){let t=n.stack;n.stack=[],s=n.enter(`autolink`);let r=o.move(`<`);return r+=o.move(n.containerPhrasing(e,{before:r,after:`>`,...o.current()})),r+=o.move(`>`),s(),n.stack=t,r}s=n.enter(`link`),c=n.enter(`label`);let l=o.move(`[`);return l+=o.move(n.containerPhrasing(e,{before:l,after:`](`,...o.current()})),l+=o.move(`](`),c(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(c=n.enter(`destinationLiteral`),l+=o.move(`<`),l+=o.move(n.safe(e.url,{before:l,after:`>`,...o.current()})),l+=o.move(`>`)):(c=n.enter(`destinationRaw`),l+=o.move(n.safe(e.url,{before:l,after:e.title?` `:`)`,...o.current()}))),c(),e.title&&(c=n.enter(`title${a}`),l+=o.move(` `+i),l+=o.move(n.safe(e.title,{before:l,after:i,...o.current()})),l+=o.move(i),c()),l+=o.move(`)`),s(),l}function VH(e,t,n){return zH(e,n)?`<`:`[`}HH.peek=UH;function HH(e,t,n,r){let i=e.referenceType,a=n.enter(`linkReference`),o=n.enter(`label`),s=n.createTracker(r),c=s.move(`[`),l=n.containerPhrasing(e,{before:c,after:`]`,...s.current()});c+=s.move(l+`][`),o();let u=n.stack;n.stack=[],o=n.enter(`reference`);let d=n.safe(n.associationId(e),{before:c,after:`]`,...s.current()});return o(),n.stack=u,a(),i===`full`||!l||l!==d?c+=s.move(d+`]`):i===`shortcut`?c=c.slice(0,-1):c+=s.move(`]`),c}function UH(){return`[`}function WH(e){let t=e.options.bullet||`*`;if(t!==`*`&&t!==`+`&&t!==`-`)throw Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function GH(e){let t=WH(e),n=e.options.bulletOther;if(!n)return t===`*`?`-`:`*`;if(n!==`*`&&n!==`+`&&n!==`-`)throw Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function KH(e){let t=e.options.bulletOrdered||`.`;if(t!==`.`&&t!==`)`)throw Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function qH(e){let t=e.options.rule||`*`;if(t!==`*`&&t!==`-`&&t!==`_`)throw Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function JH(e,t,n,r){let i=n.enter(`list`),a=n.bulletCurrent,o=e.ordered?KH(n):WH(n),s=e.ordered?o===`.`?`)`:`.`:GH(n),c=t&&n.bulletLastUsed?o===n.bulletLastUsed:!1;if(!e.ordered){let t=e.children?e.children[0]:void 0;if((o===`*`||o===`-`)&&t&&(!t.children||!t.children[0])&&n.stack[n.stack.length-1]===`list`&&n.stack[n.stack.length-2]===`listItem`&&n.stack[n.stack.length-3]===`list`&&n.stack[n.stack.length-4]===`listItem`&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(c=!0),qH(n)===o&&t){let t=-1;for(;++t<e.children.length;){let n=e.children[t];if(n&&n.type===`listItem`&&n.children&&n.children[0]&&n.children[0].type===`thematicBreak`){c=!0;break}}}}c&&(o=s),n.bulletCurrent=o;let l=n.containerFlow(e,r);return n.bulletLastUsed=o,n.bulletCurrent=a,i(),l}function YH(e){let t=e.options.listItemIndent||`one`;if(t!==`tab`&&t!==`one`&&t!==`mixed`)throw Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function XH(e,t,n,r){let i=YH(n),a=n.bulletCurrent||WH(n);t&&t.type===`list`&&t.ordered&&(a=(typeof t.start==`number`&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+a);let o=a.length+1;(i===`tab`||i===`mixed`&&(t&&t.type===`list`&&t.spread||e.spread))&&(o=Math.ceil(o/4)*4);let s=n.createTracker(r);s.move(a+` `.repeat(o-a.length)),s.shift(o);let c=n.enter(`listItem`),l=n.indentLines(n.containerFlow(e,s.current()),u);return c(),l;function u(e,t,n){return t?(n?``:` `.repeat(o))+e:(n?a:a+` `.repeat(o-a.length))+e}}function ZH(e,t,n,r){let i=n.enter(`paragraph`),a=n.enter(`phrasing`),o=n.containerPhrasing(e,r);return a(),i(),o}var QH=aB([`break`,`delete`,`emphasis`,`footnote`,`footnoteReference`,`image`,`imageReference`,`inlineCode`,`inlineMath`,`link`,`linkReference`,`mdxJsxTextElement`,`mdxTextExpression`,`strong`,`text`,`textDirective`]);function $H(e,t,n,r){return(e.children.some(function(e){return QH(e)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function eU(e){let t=e.options.strong||`*`;if(t!==`*`&&t!==`_`)throw Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}tU.peek=nU;function tU(e,t,n,r){let i=eU(n),a=n.enter(`strong`),o=n.createTracker(r),s=o.move(i+i),c=o.move(n.containerPhrasing(e,{after:i,before:s,...o.current()})),l=c.charCodeAt(0),u=EH(r.before.charCodeAt(r.before.length-1),l,i);u.inside&&(c=TH(l)+c.slice(1));let d=c.charCodeAt(c.length-1),f=EH(r.after.charCodeAt(0),d,i);f.inside&&(c=c.slice(0,-1)+TH(d));let p=o.move(i+i);return a(),n.attentionEncodeSurroundingInfo={after:f.outside,before:u.outside},s+c+p}function nU(e,t,n){return n.options.strong||`*`}function rU(e,t,n,r){return n.safe(e.value,r)}function iU(e){let t=e.options.ruleRepetition||3;if(t<3)throw Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function aU(e,t,n){let r=(qH(n)+(n.options.ruleSpaces?` `:``)).repeat(iU(n));return n.options.ruleSpaces?r.slice(0,-1):r}var oU={blockquote:fH,break:gH,code:bH,definition:CH,emphasis:DH,hardBreak:gH,heading:AH,html:jH,image:NH,imageReference:FH,inlineCode:LH,link:BH,linkReference:HH,list:JH,listItem:XH,paragraph:ZH,root:$H,strong:tU,text:rU,thematicBreak:aU};function sU(){return{enter:{table:cU,tableData:fU,tableHeader:fU,tableRow:uU},exit:{codeText:pU,table:lU,tableData:dU,tableHeader:dU,tableRow:dU}}}function cU(e){let t=e._align;this.enter({type:`table`,align:t.map(function(e){return e===`none`?null:e}),children:[]},e),this.data.inTable=!0}function lU(e){this.exit(e),this.data.inTable=void 0}function uU(e){this.enter({type:`tableRow`,children:[]},e)}function dU(e){this.exit(e)}function fU(e){this.enter({type:`tableCell`,children:[]},e)}function pU(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,mU));let n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function mU(e,t){return t===`|`?t:e}function hU(e){let t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,i=t.stringLength,a=n?` `:`|`;return{unsafe:[{character:`\r`,inConstruct:`tableCell`},{character:`
128
+ `,...a.current()});return/^[\t ]/.test(l)&&(l=EH(l.charCodeAt(0))+l.slice(1)),l=l?o+` `+l:o,n.options.closeAtx&&(l+=` `+o),c(),s(),l}MH.peek=NH;function MH(e){return e.value||``}function NH(){return`<`}PH.peek=FH;function PH(e,t,n,r){let i=CH(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.enter(`image`),s=n.enter(`label`),c=n.createTracker(r),l=c.move(`![`);return l+=c.move(n.safe(e.alt,{before:l,after:`]`,...c.current()})),l+=c.move(`](`),s(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(s=n.enter(`destinationLiteral`),l+=c.move(`<`),l+=c.move(n.safe(e.url,{before:l,after:`>`,...c.current()})),l+=c.move(`>`)):(s=n.enter(`destinationRaw`),l+=c.move(n.safe(e.url,{before:l,after:e.title?` `:`)`,...c.current()}))),s(),e.title&&(s=n.enter(`title${a}`),l+=c.move(` `+i),l+=c.move(n.safe(e.title,{before:l,after:i,...c.current()})),l+=c.move(i),s()),l+=c.move(`)`),o(),l}function FH(){return`!`}IH.peek=LH;function IH(e,t,n,r){let i=e.referenceType,a=n.enter(`imageReference`),o=n.enter(`label`),s=n.createTracker(r),c=s.move(`![`),l=n.safe(e.alt,{before:c,after:`]`,...s.current()});c+=s.move(l+`][`),o();let u=n.stack;n.stack=[],o=n.enter(`reference`);let d=n.safe(n.associationId(e),{before:c,after:`]`,...s.current()});return o(),n.stack=u,a(),i===`full`||!l||l!==d?c+=s.move(d+`]`):i===`shortcut`?c=c.slice(0,-1):c+=s.move(`]`),c}function LH(){return`!`}RH.peek=zH;function RH(e,t,n){let r=e.value||``,i="`",a=-1;for(;RegExp("(^|[^`])"+i+"([^`]|$)").test(r);)i+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=` `+r+` `);++a<n.unsafe.length;){let e=n.unsafe[a],t=n.compilePattern(e),i;if(e.atBreak)for(;i=t.exec(r);){let e=i.index;r.charCodeAt(e)===10&&r.charCodeAt(e-1)===13&&e--,r=r.slice(0,e)+` `+r.slice(i.index+1)}}return i+r+i}function zH(){return"`"}function BH(e,t){let n=uI(e);return!(t.options.resourceLink||!e.url||e.title||!e.children||e.children.length!==1||e.children[0].type!==`text`||n!==e.url&&`mailto:`+n!==e.url||!/^[a-z][a-z+.-]+:/i.test(e.url)||/[\0- <>\u007F]/.test(e.url))}VH.peek=HH;function VH(e,t,n,r){let i=CH(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.createTracker(r),s,c;if(BH(e,n)){let t=n.stack;n.stack=[],s=n.enter(`autolink`);let r=o.move(`<`);return r+=o.move(n.containerPhrasing(e,{before:r,after:`>`,...o.current()})),r+=o.move(`>`),s(),n.stack=t,r}s=n.enter(`link`),c=n.enter(`label`);let l=o.move(`[`);return l+=o.move(n.containerPhrasing(e,{before:l,after:`](`,...o.current()})),l+=o.move(`](`),c(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(c=n.enter(`destinationLiteral`),l+=o.move(`<`),l+=o.move(n.safe(e.url,{before:l,after:`>`,...o.current()})),l+=o.move(`>`)):(c=n.enter(`destinationRaw`),l+=o.move(n.safe(e.url,{before:l,after:e.title?` `:`)`,...o.current()}))),c(),e.title&&(c=n.enter(`title${a}`),l+=o.move(` `+i),l+=o.move(n.safe(e.title,{before:l,after:i,...o.current()})),l+=o.move(i),c()),l+=o.move(`)`),s(),l}function HH(e,t,n){return BH(e,n)?`<`:`[`}UH.peek=WH;function UH(e,t,n,r){let i=e.referenceType,a=n.enter(`linkReference`),o=n.enter(`label`),s=n.createTracker(r),c=s.move(`[`),l=n.containerPhrasing(e,{before:c,after:`]`,...s.current()});c+=s.move(l+`][`),o();let u=n.stack;n.stack=[],o=n.enter(`reference`);let d=n.safe(n.associationId(e),{before:c,after:`]`,...s.current()});return o(),n.stack=u,a(),i===`full`||!l||l!==d?c+=s.move(d+`]`):i===`shortcut`?c=c.slice(0,-1):c+=s.move(`]`),c}function WH(){return`[`}function GH(e){let t=e.options.bullet||`*`;if(t!==`*`&&t!==`+`&&t!==`-`)throw Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function KH(e){let t=GH(e),n=e.options.bulletOther;if(!n)return t===`*`?`-`:`*`;if(n!==`*`&&n!==`+`&&n!==`-`)throw Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function qH(e){let t=e.options.bulletOrdered||`.`;if(t!==`.`&&t!==`)`)throw Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function JH(e){let t=e.options.rule||`*`;if(t!==`*`&&t!==`-`&&t!==`_`)throw Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function YH(e,t,n,r){let i=n.enter(`list`),a=n.bulletCurrent,o=e.ordered?qH(n):GH(n),s=e.ordered?o===`.`?`)`:`.`:KH(n),c=t&&n.bulletLastUsed?o===n.bulletLastUsed:!1;if(!e.ordered){let t=e.children?e.children[0]:void 0;if((o===`*`||o===`-`)&&t&&(!t.children||!t.children[0])&&n.stack[n.stack.length-1]===`list`&&n.stack[n.stack.length-2]===`listItem`&&n.stack[n.stack.length-3]===`list`&&n.stack[n.stack.length-4]===`listItem`&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(c=!0),JH(n)===o&&t){let t=-1;for(;++t<e.children.length;){let n=e.children[t];if(n&&n.type===`listItem`&&n.children&&n.children[0]&&n.children[0].type===`thematicBreak`){c=!0;break}}}}c&&(o=s),n.bulletCurrent=o;let l=n.containerFlow(e,r);return n.bulletLastUsed=o,n.bulletCurrent=a,i(),l}function XH(e){let t=e.options.listItemIndent||`one`;if(t!==`tab`&&t!==`one`&&t!==`mixed`)throw Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function ZH(e,t,n,r){let i=XH(n),a=n.bulletCurrent||GH(n);t&&t.type===`list`&&t.ordered&&(a=(typeof t.start==`number`&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+a);let o=a.length+1;(i===`tab`||i===`mixed`&&(t&&t.type===`list`&&t.spread||e.spread))&&(o=Math.ceil(o/4)*4);let s=n.createTracker(r);s.move(a+` `.repeat(o-a.length)),s.shift(o);let c=n.enter(`listItem`),l=n.indentLines(n.containerFlow(e,s.current()),u);return c(),l;function u(e,t,n){return t?(n?``:` `.repeat(o))+e:(n?a:a+` `.repeat(o-a.length))+e}}function QH(e,t,n,r){let i=n.enter(`paragraph`),a=n.enter(`phrasing`),o=n.containerPhrasing(e,r);return a(),i(),o}var $H=oB([`break`,`delete`,`emphasis`,`footnote`,`footnoteReference`,`image`,`imageReference`,`inlineCode`,`inlineMath`,`link`,`linkReference`,`mdxJsxTextElement`,`mdxTextExpression`,`strong`,`text`,`textDirective`]);function eU(e,t,n,r){return(e.children.some(function(e){return $H(e)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function tU(e){let t=e.options.strong||`*`;if(t!==`*`&&t!==`_`)throw Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}nU.peek=rU;function nU(e,t,n,r){let i=tU(n),a=n.enter(`strong`),o=n.createTracker(r),s=o.move(i+i),c=o.move(n.containerPhrasing(e,{after:i,before:s,...o.current()})),l=c.charCodeAt(0),u=DH(r.before.charCodeAt(r.before.length-1),l,i);u.inside&&(c=EH(l)+c.slice(1));let d=c.charCodeAt(c.length-1),f=DH(r.after.charCodeAt(0),d,i);f.inside&&(c=c.slice(0,-1)+EH(d));let p=o.move(i+i);return a(),n.attentionEncodeSurroundingInfo={after:f.outside,before:u.outside},s+c+p}function rU(e,t,n){return n.options.strong||`*`}function iU(e,t,n,r){return n.safe(e.value,r)}function aU(e){let t=e.options.ruleRepetition||3;if(t<3)throw Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function oU(e,t,n){let r=(JH(n)+(n.options.ruleSpaces?` `:``)).repeat(aU(n));return n.options.ruleSpaces?r.slice(0,-1):r}var sU={blockquote:pH,break:_H,code:xH,definition:wH,emphasis:OH,hardBreak:_H,heading:jH,html:MH,image:PH,imageReference:IH,inlineCode:RH,link:VH,linkReference:UH,list:YH,listItem:ZH,paragraph:QH,root:eU,strong:nU,text:iU,thematicBreak:oU};function cU(){return{enter:{table:lU,tableData:pU,tableHeader:pU,tableRow:dU},exit:{codeText:mU,table:uU,tableData:fU,tableHeader:fU,tableRow:fU}}}function lU(e){let t=e._align;this.enter({type:`table`,align:t.map(function(e){return e===`none`?null:e}),children:[]},e),this.data.inTable=!0}function uU(e){this.exit(e),this.data.inTable=void 0}function dU(e){this.enter({type:`tableRow`,children:[]},e)}function fU(e){this.exit(e)}function pU(e){this.enter({type:`tableCell`,children:[]},e)}function mU(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,hU));let n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function hU(e,t){return t===`|`?t:e}function gU(e){let t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,i=t.stringLength,a=n?` `:`|`;return{unsafe:[{character:`\r`,inConstruct:`tableCell`},{character:`
129
129
  `,inConstruct:`tableCell`},{atBreak:!0,character:`|`,after:`[ :-]`},{character:`|`,inConstruct:`tableCell`},{atBreak:!0,character:`:`,after:`-`},{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{inlineCode:f,table:o,tableCell:c,tableRow:s}};function o(e,t,n,r){return l(u(e,n,r),e.align)}function s(e,t,n,r){let i=l([d(e,n,r)]);return i.slice(0,i.indexOf(`
130
- `))}function c(e,t,n,r){let i=n.enter(`tableCell`),o=n.enter(`phrasing`),s=n.containerPhrasing(e,{...r,before:a,after:a});return o(),i(),s}function l(e,t){return lH(e,{align:t,alignDelimiters:r,padding:n,stringLength:i})}function u(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`table`);for(;++i<r.length;)a[i]=d(r[i],t,n);return o(),a}function d(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`tableRow`);for(;++i<r.length;)a[i]=c(r[i],e,t,n);return o(),a}function f(e,t,n){let r=oU.inlineCode(e,t,n);return n.stack.includes(`tableCell`)&&(r=r.replace(/\|/g,`\\$&`)),r}}function gU(){return{exit:{taskListCheckValueChecked:vU,taskListCheckValueUnchecked:vU,paragraph:yU}}}function _U(){return{unsafe:[{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{listItem:bU}}}function vU(e){let t=this.stack[this.stack.length-2];t.type,t.checked=e.type===`taskListCheckValueChecked`}function yU(e){let t=this.stack[this.stack.length-2];if(t&&t.type===`listItem`&&typeof t.checked==`boolean`){let e=this.stack[this.stack.length-1];e.type;let n=e.children[0];if(n&&n.type===`text`){let r=t.children,i=-1,a;for(;++i<r.length;){let e=r[i];if(e.type===`paragraph`){a=e;break}}a===e&&(n.value=n.value.slice(1),n.value.length===0?e.children.shift():e.position&&n.position&&typeof n.position.start.offset==`number`&&(n.position.start.column++,n.position.start.offset++,e.position.start=Object.assign({},n.position.start)))}}this.exit(e)}function bU(e,t,n,r){let i=e.children[0],a=typeof e.checked==`boolean`&&i&&i.type===`paragraph`,o=`[`+(e.checked?`x`:` `)+`] `,s=n.createTracker(r);a&&s.move(o);let c=oU.listItem(e,t,n,{...r,...s.current()});return a&&(c=c.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,l)),c;function l(e){return e+o}}function xU(){return[DV(),ZV(),nH(),sU(),gU()]}function SU(e){return{extensions:[OV(),QV(e),rH(),hU(e),_U()]}}var CU={tokenize:LU,partial:!0},wU={tokenize:RU,partial:!0},TU={tokenize:zU,partial:!0},EU={tokenize:BU,partial:!0},DU={tokenize:VU,partial:!0},OU={name:`wwwAutolink`,tokenize:FU,previous:HU},kU={name:`protocolAutolink`,tokenize:IU,previous:UU},AU={name:`emailAutolink`,tokenize:PU,previous:WU},jU={};function MU(){return{text:jU}}for(var NU=48;NU<123;)jU[NU]=AU,NU++,NU===58?NU=65:NU===91&&(NU=97);jU[43]=AU,jU[45]=AU,jU[46]=AU,jU[95]=AU,jU[72]=[AU,kU],jU[104]=[AU,kU],jU[87]=[AU,OU],jU[119]=[AU,OU];function PU(e,t,n){let r=this,i,a;return o;function o(t){return!GU(t)||!WU.call(r,r.previous)||KU(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkEmail`),s(t))}function s(t){return GU(t)?(e.consume(t),s):t===64?(e.consume(t),c):n(t)}function c(t){return t===46?e.check(DU,u,l)(t):t===45||t===95||wI(t)?(a=!0,e.consume(t),c):u(t)}function l(t){return e.consume(t),i=!0,c}function u(o){return a&&i&&CI(r.previous)?(e.exit(`literalAutolinkEmail`),e.exit(`literalAutolink`),t(o)):n(o)}}function FU(e,t,n){let r=this;return i;function i(t){return t!==87&&t!==119||!HU.call(r,r.previous)||KU(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkWww`),e.check(CU,e.attempt(wU,e.attempt(TU,a),n),n)(t))}function a(n){return e.exit(`literalAutolinkWww`),e.exit(`literalAutolink`),t(n)}}function IU(e,t,n){let r=this,i=``,a=!1;return o;function o(t){return(t===72||t===104)&&UU.call(r,r.previous)&&!KU(r.events)?(e.enter(`literalAutolink`),e.enter(`literalAutolinkHttp`),i+=String.fromCodePoint(t),e.consume(t),s):n(t)}function s(t){if(CI(t)&&i.length<5)return i+=String.fromCodePoint(t),e.consume(t),s;if(t===58){let n=i.toLowerCase();if(n===`http`||n===`https`)return e.consume(t),c}return n(t)}function c(t){return t===47?(e.consume(t),a?l:(a=!0,c)):n(t)}function l(t){return t===null||EI(t)||jI(t)||PI(t)||NI(t)?n(t):e.attempt(wU,e.attempt(TU,u),n)(t)}function u(n){return e.exit(`literalAutolinkHttp`),e.exit(`literalAutolink`),t(n)}}function LU(e,t,n){let r=0;return i;function i(t){return(t===87||t===119)&&r<3?(r++,e.consume(t),i):t===46&&r===3?(e.consume(t),a):n(t)}function a(e){return e===null?n(e):t(e)}}function RU(e,t,n){let r,i,a;return o;function o(t){return t===46||t===95?e.check(EU,c,s)(t):t===null||jI(t)||PI(t)||t!==45&&NI(t)?c(t):(a=!0,e.consume(t),o)}function s(t){return t===95?r=!0:(i=r,r=void 0),e.consume(t),o}function c(e){return i||r||!a?n(e):t(e)}}function zU(e,t){let n=0,r=0;return i;function i(o){return o===40?(n++,e.consume(o),i):o===41&&r<n?a(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?e.check(EU,t,a)(o):o===null||jI(o)||PI(o)?t(o):(e.consume(o),i)}function a(t){return t===41&&r++,e.consume(t),i}}function BU(e,t,n){return r;function r(o){return o===33||o===34||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===63||o===95||o===126?(e.consume(o),r):o===38?(e.consume(o),a):o===93?(e.consume(o),i):o===60||o===null||jI(o)||PI(o)?t(o):n(o)}function i(e){return e===null||e===40||e===91||jI(e)||PI(e)?t(e):r(e)}function a(e){return CI(e)?o(e):n(e)}function o(t){return t===59?(e.consume(t),r):CI(t)?(e.consume(t),o):n(t)}}function VU(e,t,n){return r;function r(t){return e.consume(t),i}function i(e){return wI(e)?n(e):t(e)}}function HU(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||jI(e)}function UU(e){return!CI(e)}function WU(e){return!(e===47||GU(e))}function GU(e){return e===43||e===45||e===46||e===95||wI(e)}function KU(e){let t=e.length,n=!1;for(;t--;){let r=e[t][1];if((r.type===`labelLink`||r.type===`labelImage`)&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}var qU={tokenize:tW,partial:!0};function JU(){return{document:{91:{name:`gfmFootnoteDefinition`,tokenize:QU,continuation:{tokenize:$U},exit:eW}},text:{91:{name:`gfmFootnoteCall`,tokenize:ZU},93:{name:`gfmPotentialFootnoteCall`,add:`after`,tokenize:YU,resolveTo:XU}}}}function YU(e,t,n){let r=this,i=r.events.length,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),o;for(;i--;){let e=r.events[i][1];if(e.type===`labelImage`){o=e;break}if(e.type===`gfmFootnoteCall`||e.type===`labelLink`||e.type===`label`||e.type===`image`||e.type===`link`)break}return s;function s(i){if(!o||!o._balanced)return n(i);let s=SI(r.sliceSerialize({start:o.end,end:r.now()}));return s.codePointAt(0)!==94||!a.includes(s.slice(1))?n(i):(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(i),e.exit(`gfmFootnoteCallLabelMarker`),t(i))}}function XU(e,t){let n=e.length;for(;n--;)if(e[n][1].type===`labelImage`&&e[n][0]===`enter`){e[n][1];break}e[n+1][1].type=`data`,e[n+3][1].type=`gfmFootnoteCallLabelMarker`;let r={type:`gfmFootnoteCall`,start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:`gfmFootnoteCallMarker`,start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;let a={type:`gfmFootnoteCallString`,start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:`chunkString`,contentType:`string`,start:Object.assign({},a.start),end:Object.assign({},a.end)},s=[e[n+1],e[n+2],[`enter`,r,t],e[n+3],e[n+4],[`enter`,i,t],[`exit`,i,t],[`enter`,a,t],[`enter`,o,t],[`exit`,o,t],[`exit`,a,t],e[e.length-2],e[e.length-1],[`exit`,r,t]];return e.splice(n,e.length-n+1,...s),e}function ZU(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a=0,o;return s;function s(t){return e.enter(`gfmFootnoteCall`),e.enter(`gfmFootnoteCallLabelMarker`),e.consume(t),e.exit(`gfmFootnoteCallLabelMarker`),c}function c(t){return t===94?(e.enter(`gfmFootnoteCallMarker`),e.consume(t),e.exit(`gfmFootnoteCallMarker`),e.enter(`gfmFootnoteCallString`),e.enter(`chunkString`).contentType=`string`,l):n(t)}function l(s){if(a>999||s===93&&!o||s===null||s===91||jI(s))return n(s);if(s===93){e.exit(`chunkString`);let a=e.exit(`gfmFootnoteCallString`);return i.includes(SI(r.sliceSerialize(a)))?(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(s),e.exit(`gfmFootnoteCallLabelMarker`),e.exit(`gfmFootnoteCall`),t):n(s)}return jI(s)||(o=!0),a++,e.consume(s),s===92?u:l}function u(t){return t===91||t===92||t===93?(e.consume(t),a++,l):l(t)}}function QU(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a,o=0,s;return c;function c(t){return e.enter(`gfmFootnoteDefinition`)._container=!0,e.enter(`gfmFootnoteDefinitionLabel`),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),l}function l(t){return t===94?(e.enter(`gfmFootnoteDefinitionMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionMarker`),e.enter(`gfmFootnoteDefinitionLabelString`),e.enter(`chunkString`).contentType=`string`,u):n(t)}function u(t){if(o>999||t===93&&!s||t===null||t===91||jI(t))return n(t);if(t===93){e.exit(`chunkString`);let n=e.exit(`gfmFootnoteDefinitionLabelString`);return a=SI(r.sliceSerialize(n)),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),e.exit(`gfmFootnoteDefinitionLabel`),f}return jI(t)||(s=!0),o++,e.consume(t),t===92?d:u}function d(t){return t===91||t===92||t===93?(e.consume(t),o++,u):u(t)}function f(t){return t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),i.includes(a)||i.push(a),LI(e,p,`gfmFootnoteDefinitionWhitespace`)):n(t)}function p(e){return t(e)}}function $U(e,t,n){return e.check(QI,t,e.attempt(qU,t,n))}function eW(e){e.exit(`gfmFootnoteDefinition`)}function tW(e,t,n){let r=this;return LI(e,i,`gfmFootnoteDefinitionIndent`,5);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`gfmFootnoteDefinitionIndent`&&i[2].sliceSerialize(i[1],!0).length===4?t(e):n(e)}}function nW(e){let t=(e||{}).singleTilde,n={name:`strikethrough`,tokenize:i,resolveAll:r};return t??=!0,{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}};function r(e,t){let n=-1;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`strikethroughSequenceTemporary`&&e[n][1]._close){let r=n;for(;r--;)if(e[r][0]===`exit`&&e[r][1].type===`strikethroughSequenceTemporary`&&e[r][1]._open&&e[n][1].end.offset-e[n][1].start.offset===e[r][1].end.offset-e[r][1].start.offset){e[n][1].type=`strikethroughSequence`,e[r][1].type=`strikethroughSequence`;let i={type:`strikethrough`,start:Object.assign({},e[r][1].start),end:Object.assign({},e[n][1].end)},a={type:`strikethroughText`,start:Object.assign({},e[r][1].end),end:Object.assign({},e[n][1].start)},o=[[`enter`,i,t],[`enter`,e[r][1],t],[`exit`,e[r][1],t],[`enter`,a,t]],s=t.parser.constructs.insideSpan.null;s&&hI(o,o.length,0,GI(s,e.slice(r+1,n),t)),hI(o,o.length,0,[[`exit`,a,t],[`enter`,e[n][1],t],[`exit`,e[n][1],t],[`exit`,i,t]]),hI(e,r-1,n-r+3,o),n=r+o.length-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`strikethroughSequenceTemporary`&&(e[n][1].type=`data`);return e}function i(e,n,r){let i=this.previous,a=this.events,o=0;return s;function s(t){return i===126&&a[a.length-1][1].type!==`characterEscape`?r(t):(e.enter(`strikethroughSequenceTemporary`),c(t))}function c(a){let s=WI(i);if(a===126)return o>1?r(a):(e.consume(a),o++,c);if(o<2&&!t)return r(a);let l=e.exit(`strikethroughSequenceTemporary`),u=WI(a);return l._open=!u||u===2&&!!s,l._close=!s||s===2&&!!u,n(a)}}}var rW=class{constructor(){this.map=[]}add(e,t,n){iW(this,e,t,n)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),this.map.length===0)return;let t=this.map.length,n=[];for(;t>0;)--t,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(let t of r)e.push(t);r=n.pop()}this.map.length=0}};function iW(e,t,n,r){let i=0;if(n!==0||r.length!==0){for(;i<e.map.length;){if(e.map[i][0]===t){e.map[i][1]+=n,e.map[i][2].push(...r);return}i+=1}e.map.push([t,n,r])}}function aW(e,t){let n=!1,r=[];for(;t<e.length;){let i=e[t];if(n){if(i[0]===`enter`)i[1].type===`tableContent`&&r.push(e[t+1][1].type===`tableDelimiterMarker`?`left`:`none`);else if(i[1].type===`tableContent`){if(e[t-1][1].type===`tableDelimiterMarker`){let e=r.length-1;r[e]=r[e]===`left`?`center`:`right`}}else if(i[1].type===`tableDelimiterRow`)break}else i[0]===`enter`&&i[1].type===`tableDelimiterRow`&&(n=!0);t+=1}return r}function oW(){return{flow:{null:{name:`table`,tokenize:sW,resolveAll:cW}}}}function sW(e,t,n){let r=this,i=0,a=0,o;return s;function s(e){let t=r.events.length-1;for(;t>-1;){let e=r.events[t][1].type;if(e===`lineEnding`||e===`linePrefix`)t--;else break}let i=t>-1?r.events[t][1].type:null,a=i===`tableHead`||i===`tableRow`?S:c;return a===S&&r.parser.lazy[r.now().line]?n(e):a(e)}function c(t){return e.enter(`tableHead`),e.enter(`tableRow`),l(t)}function l(e){return e===124?u(e):(o=!0,a+=1,u(e))}function u(t){return t===null?n(t):AI(t)?a>1?(a=0,r.interrupt=!0,e.exit(`tableRow`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),p):n(t):MI(t)?LI(e,u,`whitespace`)(t):(a+=1,o&&(o=!1,i+=1),t===124?(e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),o=!0,u):(e.enter(`data`),d(t)))}function d(t){return t===null||t===124||jI(t)?(e.exit(`data`),u(t)):(e.consume(t),t===92?f:d)}function f(t){return t===92||t===124?(e.consume(t),d):d(t)}function p(t){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(t):(e.enter(`tableDelimiterRow`),o=!1,MI(t)?LI(e,m,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):m(t))}function m(t){return t===45||t===58?g(t):t===124?(o=!0,e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),h):x(t)}function h(t){return MI(t)?LI(e,g,`whitespace`)(t):g(t)}function g(t){return t===58?(a+=1,o=!0,e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),_):t===45?(a+=1,_(t)):t===null||AI(t)?b(t):x(t)}function _(t){return t===45?(e.enter(`tableDelimiterFiller`),v(t)):x(t)}function v(t){return t===45?(e.consume(t),v):t===58?(o=!0,e.exit(`tableDelimiterFiller`),e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),y):(e.exit(`tableDelimiterFiller`),y(t))}function y(t){return MI(t)?LI(e,b,`whitespace`)(t):b(t)}function b(n){return n===124?m(n):n===null||AI(n)?!o||i!==a?x(n):(e.exit(`tableDelimiterRow`),e.exit(`tableHead`),t(n)):x(n)}function x(e){return n(e)}function S(t){return e.enter(`tableRow`),C(t)}function C(n){return n===124?(e.enter(`tableCellDivider`),e.consume(n),e.exit(`tableCellDivider`),C):n===null||AI(n)?(e.exit(`tableRow`),t(n)):MI(n)?LI(e,C,`whitespace`)(n):(e.enter(`data`),w(n))}function w(t){return t===null||t===124||jI(t)?(e.exit(`data`),C(t)):(e.consume(t),t===92?T:w)}function T(t){return t===92||t===124?(e.consume(t),w):w(t)}}function cW(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,c=0,l,u,d,f=new rW;for(;++n<e.length;){let p=e[n],m=p[1];p[0]===`enter`?m.type===`tableHead`?(s=!1,c!==0&&(uW(f,t,c,l,u),u=void 0,c=0),l={type:`table`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,l,t]])):m.type===`tableRow`||m.type===`tableDelimiterRow`?(r=!0,d=void 0,a=[0,0,0,0],o=[0,n+1,0,0],s&&(s=!1,u={type:`tableBody`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,u,t]])),i=m.type===`tableDelimiterRow`?2:u?3:1):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],d=lW(f,t,a,i,void 0,d),a=[0,0,0,0]),o[2]=n)):m.type===`tableCellDivider`&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],d=lW(f,t,a,i,void 0,d)),a=o,o=[a[1],n,0,0])):m.type===`tableHead`?(s=!0,c=n):m.type===`tableRow`||m.type===`tableDelimiterRow`?(c=n,a[1]===0?o[1]!==0&&(d=lW(f,t,o,i,n,d)):(o[0]=o[1],d=lW(f,t,a,i,n,d)),i=0):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)&&(o[3]=n)}for(c!==0&&uW(f,t,c,l,u),f.consume(t.events),n=-1;++n<t.events.length;){let e=t.events[n];e[0]===`enter`&&e[1].type===`table`&&(e[1]._align=aW(t.events,n))}return e}function lW(e,t,n,r,i,a){let o=r===1?`tableHeader`:r===2?`tableDelimiter`:`tableData`;n[0]!==0&&(a.end=Object.assign({},dW(t.events,n[0])),e.add(n[0],0,[[`exit`,a,t]]));let s=dW(t.events,n[1]);if(a={type:o,start:Object.assign({},s),end:Object.assign({},s)},e.add(n[1],0,[[`enter`,a,t]]),n[2]!==0){let i=dW(t.events,n[2]),a=dW(t.events,n[3]),o={type:`tableContent`,start:Object.assign({},i),end:Object.assign({},a)};if(e.add(n[2],0,[[`enter`,o,t]]),r!==2){let r=t.events[n[2]],i=t.events[n[3]];if(r[1].end=Object.assign({},i[1].end),r[1].type=`chunkText`,r[1].contentType=`text`,n[3]>n[2]+1){let t=n[2]+1,r=n[3]-n[2]-1;e.add(t,r,[])}}e.add(n[3]+1,0,[[`exit`,o,t]])}return i!==void 0&&(a.end=Object.assign({},dW(t.events,i)),e.add(i,0,[[`exit`,a,t]]),a=void 0),a}function uW(e,t,n,r,i){let a=[],o=dW(t.events,n);i&&(i.end=Object.assign({},o),a.push([`exit`,i,t])),r.end=Object.assign({},o),a.push([`exit`,r,t]),e.add(n+1,0,a)}function dW(e,t){let n=e[t],r=n[0]===`enter`?`start`:`end`;return n[1][r]}var fW={name:`tasklistCheck`,tokenize:mW};function pW(){return{text:{91:fW}}}function mW(e,t,n){let r=this;return i;function i(t){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(t):(e.enter(`taskListCheck`),e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),a)}function a(t){return jI(t)?(e.enter(`taskListCheckValueUnchecked`),e.consume(t),e.exit(`taskListCheckValueUnchecked`),o):t===88||t===120?(e.enter(`taskListCheckValueChecked`),e.consume(t),e.exit(`taskListCheckValueChecked`),o):n(t)}function o(t){return t===93?(e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),e.exit(`taskListCheck`),s):n(t)}function s(r){return AI(r)?t(r):MI(r)?e.check({tokenize:hW},t,n)(r):n(r)}}function hW(e,t,n){return LI(e,r,`whitespace`);function r(e){return e===null?n(e):t(e)}}function gW(e){return vI([MU(),JU(),nW(e),oW(),pW()])}var _W={};function vW(e){let t=this,n=e||_W,r=t.data(),i=r.micromarkExtensions||=[],a=r.fromMarkdownExtensions||=[],o=r.toMarkdownExtensions||=[];i.push(gW(n)),a.push(xU()),o.push(SU(n))}var yW=cD(`kind`,[K({kind:hD(`allAffected`)}).strict(),K({kind:hD(`selected`),workKeys:G(W().min(1).max(200)).min(1).max(1e4)}).strict()]),bW=W().min(1).max(64),xW=K({baseRevisionId:bW,request:yW}).strict(),SW=K({baseRevisionId:bW,idempotencyKey:OE(),previewId:W().min(1).max(64),acknowledgeUnknownCosts:XE(),confirmedProvidedWorkKeys:G(W().min(1).max(200)).max(1e4)}).strict(),CW=K({stage:W(),low:KE().finite().nonnegative().nullable(),high:KE().finite().nonnegative().nullable(),detail:W()}),wW=K({currency:hD(`USD`),rows:G(CW),low:KE().finite().nonnegative(),high:KE().finite().nonnegative(),unknown:KE().int().nonnegative(),expectedWords:KE().finite().nonnegative(),catalogueDate:W().nullable(),assumptions:G(W())}),TW=K({revisionId:bW,admissionId:W().min(1).max(64),workIds:G(W().min(1).max(64)),replayed:XE()}),EW=K({id:W().min(1).max(64),projectId:W().min(1).max(64),baseRevisionId:bW,planFingerprint:W().min(1),selection:yW,changedInputs:G(K({path:W(),before:W().nullable(),after:W().nullable()})),work:G(K({key:W(),stage:q(VD),kind:q([`provider`,`local`,`provided`]),disposition:q([`reuse`,`generate`,`local`,`review`,`blocked`]),requestFingerprint:W(),fingerprint:W(),dependsOn:G(W()),reason:W(),inflight:XE(),pieceIds:G(W())})),retained:G(K({slot:W(),outputId:W(),assetId:W(),state:q([`ready`,`outdated`,`review`])})),providedReuseRequired:G(W()),costs:wW,wholeRequestNotice:W().nullable(),warnings:G(W()),review:K({inputChanges:G(K({label:W(),before:W().nullable(),after:W().nullable()})),requests:G(K({key:W(),label:W(),text:W().nullable(),settings:W().nullable()}))}).optional()}),DW=[`chapter`,`chunk`,`segment`,`image`,`prompt_written`,`article_written`],OW=[`pending`,`running`,`done`,`failed`];K({id:W(),stage_id:W(),kind:q(DW),idx:KE(),state:q(OW),payload:W().nullable()});var kW=[`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`],AW=[`copying`,`staged`],jW=K({segment:q([`body`,`intro`,`outro`]).optional(),subtitleOmissions:G(K({start:KE().finite().nonnegative(),text:W()})).optional(),subtitlesMode:q([`off`,`files`,`burn-in`]).optional(),promptName:W().optional(),prompt:W().optional(),index:KE().optional(),provider:W().optional(),model:W().optional(),voice:W().optional()}),MW=K({id:W(),projectId:W(),stageKind:q(VD),role:q(kW),path:W(),originalFilename:W().nullable(),bytes:KE().nonnegative(),durationMs:KE().nonnegative().nullable(),meta:jW,createdAt:W()});K({id:W(),stageKind:q(VD),path:W(),originalFilename:W(),bytes:KE().nonnegative(),state:q(AW),createdAt:W()});var NW=W().min(1).max(64).regex(/^[0-9A-Za-z_-]+$/),PW=W().min(1).max(256),FW=fD(PW,NW),IW=K({id:NW,text:W().trim().min(1).max(1e4),start:KE().finite().nonnegative(),end:KE().finite().positive()}).strict().refine(e=>e.end>e.start,{path:[`end`],message:`End must be after start.`}),LW=K({articleMarkdown:W().max(5e5).optional(),articleEdited:XE().default(!1),provided:K({research:NW.optional(),article:NW.optional(),audio:NW.optional(),thumbnail:NW.optional()}).strict(),imageOrder:G(NW).max(60),imageDefinitions:fD(NW,K({source:q([`generate`,`provide`]),assetId:NW.nullable(),prompt:W().max(5e5).nullable(),templateKey:W().min(1).max(256).nullable().optional()}).strict()),narrationOverrides:fD(PW,cD(`kind`,[K({kind:hD(`asset`),assetId:NW}).strict(),K({kind:hD(`text`),text:W().trim().min(1).max(5e5)}).strict()])),subtitleCues:K({audioFingerprint:W().min(1),cues:G(IW)}).strict().optional(),regenerationTokens:FW,promptTemplates:fD(W().min(1),W().max(5e5).nullable())}).strict(),RW=K({baseRevisionId:NW,idempotencyKey:NW,edit:K({config:iO.strict(),content:LW,regenerate:G(PW).optional(),uploads:G(K({stagedFileId:NW,destination:cD(`kind`,[K({kind:hD(`provided`),stage:q([`audio`,`thumbnail`])}).strict(),K({kind:hD(`image`),imageKey:NW}).strict(),K({kind:hD(`narration`),key:PW}).strict()])}).strict()).max(1e4).optional()}).strict()}).strict(),zW=K({baseRevisionId:NW,idempotencyKey:NW,targetRevisionId:NW}).strict(),BW=K({id:NW,projectId:NW,parentId:NW.nullable(),restoredFromId:NW.nullable(),config:iO,content:LW,fingerprints:fD(PW,W()),createdAt:W()}),VW=K({id:NW,stageId:NW,kind:q(DW),idx:KE().int(),state:q(OW),payload:W().nullable()}),HW=K({slot:W(),workKey:PW,assetId:NW,output:MW,fingerprint:W(),state:q([`ready`,`outdated`,`review`])}),UW=K({key:PW,stageKind:q(VD),piece:VW,assetId:NW.nullable(),fingerprint:W()}),WW={recordId:NW,publicationId:NW.nullable(),selected:XE(),available:XE()},GW=K({articleMarkdown:W().nullable(),revision:BW,outputs:G(HW.extend(WW)),pieces:G(UW.extend(WW)),current:XE()}),KW=K({id:NW,parentId:NW.nullable(),restoredFromId:NW.nullable(),title:W(),createdAt:W(),current:XE()}),qW=K({ok:hD(!0),view:GW,duplicate:XE()}),JW=K({ok:hD(!0),view:GW,created:XE()}),YW=K({title:W(),status:KE(),detail:W().optional(),reason:W().optional(),currentRevisionId:W().nullable().optional(),fields:G(K({field:W(),message:W()})).optional(),errors:G(K({path:W(),message:W()})).optional()});async function XW(e,t){let n;try{n=await e.json()}catch{throw io(e,void 0)}if(e.ok)return{ok:!0,value:t.parse(n)};let r=YW.safeParse(n);if(!r.success)throw io(e,void 0);let i=r.data;if(![400,404,409].includes(e.status))throw io(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 ZW(e,t,n,r,i){return XW(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 QW(e,t){return ZW(e,t,`/revisions/prepare`,JW,{})}function $W(e,t,n){return ZW(e,t,`/revisions`,qW,RW.parse(n))}function eG(e,t,n){return ZW(e,t,`/revisions/restore`,qW,zW.parse(n))}function tG(e,t){return ZW(e,t,`/revisions`,K({revisions:G(KW)}))}function nG(e,t,n){return ZW(e,t,`/revisions/${encodeURIComponent(n)}`,K({view:GW}))}function rG(e,t,n){return ZW(e,t,`/rebuild/preview`,K({ok:hD(!0),value:EW}),xW.parse(n))}function iG(e,t,n){return ZW(e,t,`/rebuild`,K({ok:hD(!0),value:TW}),SW.parse(n))}function aG(e,t,n,r){return`${e.origin}/files/${encodeURIComponent(t)}/revisions/${encodeURIComponent(n)}/${encodeURIComponent(r)}`}async function oG(e,t,n,r){let i=await e.fetch(`${e.origin}/api/projects/${encodeURIComponent(t)}/revisions/${encodeURIComponent(n)}/${encodeURIComponent(r)}/open-folder`,{method:`POST`});if(!i.ok){let e=await XW(i,eD());if(!e.ok)throw Error(e.message)}}function sG(e,t,n){return aG(e,t,n,`images.zip`)}function cG({projectId:e,asset:t,folder:n=null}){let{api:r}=I(),[i,a]=(0,m.useState)(!1),[o,s]=(0,m.useState)();async function c(){a(!0),s(void 0);try{if(n!==null){await oG(r,e,n.revisionId,n.recordId);return}let i=await r.client.projects[`:id`][`open-folder`].$post({param:{id:e},json:{asset:t}});if(!i.ok)throw io(i,await ao(i))}catch(e){s(e instanceof Error?e.message:`Could not open the folder.`)}finally{a(!1)}}return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`button`,{type:`button`,disabled:i,onClick:()=>void c(),title:`Open the saved output folder on the machine running Slopify`,className:`inline-flex items-center gap-[5px] rounded-control text-small text-ink2 hover:text-ink disabled:opacity-50`,children:[(0,h.jsx)(nj,{"aria-hidden":`true`,className:`size-[14px] shrink-0`}),i?`Opening…`:`Open folder`]}),o!==void 0&&(0,h.jsx)(`span`,{role:`alert`,className:`basis-full text-small text-red`,children:o})]})}var lG=(0,m.createContext)(null);function uG({projectId:e,revisionId:t,children:n}){let{api:r}=I(),i=nt({queryKey:V.revision(e,t??``),enabled:t!==null,queryFn:async()=>{if(t===null)throw Error(`Choose a saved revision.`);let n=await nG(r,e,t);if(!n.ok)throw Error(n.message);let i=n.value.view;if(i.revision.id!==t||i.revision.projectId!==e)throw Error(`The file list belongs to another revision.`);return i}});return(0,h.jsxs)(lG,{value:{projectId:e,revisionId:t,view:i.data},children:[i.error===null?null:(0,h.jsx)(`p`,{role:`alert`,children:i.error.message}),n]})}function dG(e){let t=(0,m.useContext)(lG),{api:n}=I();if(e===void 0||t!==null&&t.projectId!==e.projectId)return;if(t===null||t.revisionId===null)return{url:vo(n,e.projectId,kP(e)),cacheKey:V.file(e.projectId,e.id),folder:null};let r=t.view?.outputs.find(t=>t.selected&&t.available&&t.output.id===e.id);return r===void 0?void 0:pG(n,t.projectId,t.revisionId,r)}function fG(e,t){let n=(0,m.useContext)(lG),{api:r}=I();if(n!==null&&n.projectId!==e)return;if(n===null||n.revisionId===null)return{url:vo(r,e,t),cacheKey:V.file(e,t),folder:null};let i=n.view?.outputs.find(e=>e.selected&&e.available&&(t===`images.zip`?e.output.role===`image`||e.output.role===`thumbnail`:kP(e.output)===t));if(i===void 0)return;let a=pG(r,e,n.revisionId,i);return t===`images.zip`?{...a,url:aG(r,e,n.revisionId,`images.zip`),cacheKey:V.revisionFile(e,n.revisionId,`images.zip`)}:a}function pG(e,t,n,r){return{url:aG(e,t,n,r.recordId),cacheKey:V.revisionFile(t,n,r.recordId),folder:{revisionId:n,recordId:r.recordId}}}function mG({children:e,className:t}){return(0,h.jsx)(`div`,{className:z(`flex min-w-0 flex-col gap-4 p-5`,t),children:e})}function hG({children:e}){return(0,h.jsx)(`div`,{className:`flex flex-wrap items-center gap-4 text-small`,children:e})}function gG({children:e}){return(0,h.jsx)(`span`,{className:`engraved text-ink3`,children:e})}var _G={h1:({children:e})=>(0,h.jsx)(yG,{size:`text-title`,children:e}),h2:({children:e})=>(0,h.jsx)(yG,{size:`text-row`,children:e}),h3:({children:e})=>(0,h.jsx)(yG,{size:`text-row`,children:e}),h4:({children:e})=>(0,h.jsx)(yG,{size:`text-row`,children:e}),h5:({children:e})=>(0,h.jsx)(yG,{size:`text-row`,children:e}),h6:({children:e})=>(0,h.jsx)(yG,{size:`text-row`,children:e}),p:({children:e})=>(0,h.jsx)(`p`,{className:`m-0`,children:e}),strong:({children:e})=>(0,h.jsx)(`strong`,{className:`font-semibold`,children:e}),ul:({children:e})=>(0,h.jsx)(`ul`,{className:`m-0 flex list-disc flex-col gap-1 pl-5`,children:e}),ol:({children:e})=>(0,h.jsx)(`ol`,{className:`m-0 flex list-decimal flex-col gap-1 pl-5`,children:e}),li:({children:e})=>(0,h.jsx)(`li`,{className:`m-0`,children:e}),a:({children:e,href:t})=>(0,h.jsx)(`a`,{href:t,className:`rounded-control text-run-text underline underline-offset-[3px]`,target:`_blank`,rel:`noreferrer`,children:e}),code:({children:e})=>(0,h.jsx)(`code`,{className:`rounded-control bg-panel2 px-[4px] py-[1px] font-sans text-small`,children:e}),pre:({children:e})=>(0,h.jsx)(`pre`,{className:`m-0 overflow-x-auto rounded-control bg-panel2 p-[10px] font-sans text-small`,children:e}),blockquote:({children:e})=>(0,h.jsx)(`blockquote`,{className:`m-0 flex flex-col gap-2 border-l-2 border-line2 pl-3 text-ink2`,children:e}),hr:()=>(0,h.jsx)(`hr`,{className:`my-2 border-line`}),table:({children:e})=>(0,h.jsx)(`table`,{className:`w-full border-collapse text-left text-small`,children:e}),th:({children:e})=>(0,h.jsx)(`th`,{className:`engraved border-b border-line py-[6px] pr-4 text-left text-ink3`,children:e}),td:({children:e})=>(0,h.jsx)(`td`,{className:`border-b border-line py-[6px] pr-4 align-top`,children:e})},vG={p:({children:e})=>(0,h.jsx)(h.Fragment,{children:e}),strong:({children:e})=>(0,h.jsx)(`strong`,{className:`font-semibold`,children:e}),a:({children:e})=>(0,h.jsx)(h.Fragment,{children:e})};function yG({size:e,children:t}){return(0,h.jsx)(`h3`,{className:z(`mt-2 font-bold tracking-[-0.01em]`,e),children:t})}function bG({markdown:e}){return(0,h.jsx)(`div`,{className:`flex max-w-[75ch] flex-col gap-2 text-pretty text-body text-ink`,children:(0,h.jsx)(mV,{remarkPlugins:[vW],components:_G,children:e})})}function xG({markdown:e}){return(0,h.jsx)(mV,{remarkPlugins:[vW],components:vG,children:e})}var SG=/^#{1,6}[ \t]+(.*?)[ \t]*#*[ \t]*(?:\r?\n|$)/;function CG(e){let t=e.replace(/^[\s]*\n/,``),n=SG.exec(t);return n===null?{title:void 0,body:e.trim()}:{title:n[1]??``,body:t.slice(n[0].length).trim()}}function wG({message:e,onDismiss:t}){return(0,h.jsxs)(`div`,{className:`flex items-center gap-3 rounded-control bg-red-tint px-[10px] py-[6px] text-small text-red`,children:[(0,h.jsx)(`span`,{role:`alert`,className:`min-w-0 break-words`,children:e}),(0,h.jsx)(`button`,{type:`button`,onClick:t,className:`ml-auto shrink-0 rounded-control px-2 text-ink2 hover:text-ink`,children:`Dismiss`})]})}function TG({projectId:e,asset:t,label:n=`Download`}){let r=fG(e,t);return r===void 0?null:(0,h.jsxs)(`span`,{className:`inline-flex flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,h.jsxs)(`a`,{href:r.url,download:!0,className:`inline-flex items-center gap-[5px] rounded-control text-small text-ink2 hover:text-ink`,children:[(0,h.jsx)(ej,{"aria-hidden":`true`,className:`size-[14px] shrink-0`}),n]}),(0,h.jsx)(cG,{projectId:e,asset:t,folder:r.folder})]})}function EG({output:e,label:t}){let n=dG(e);return n===void 0?null:(0,h.jsxs)(`span`,{className:`inline-flex flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,h.jsxs)(`a`,{href:n.url,download:!0,className:`inline-flex items-center gap-[5px] rounded-control text-small text-ink2 hover:text-ink`,children:[(0,h.jsx)(ej,{"aria-hidden":`true`,className:`size-[14px] shrink-0`}),t??`Download`]}),(0,h.jsx)(cG,{projectId:e.projectId,asset:kP(e),folder:n.folder})]})}function DG(e){let{api:t}=I(),n=dG(e);return nt({queryKey:n?.cacheKey??V.revisionFile(``,``,`unavailable`),queryFn:async()=>n===void 0?``:to(await t.fetch(n.url)),enabled:n!==void 0,staleTime:1/0})}function OG({output:e,as:t=`prose`}){let n=DG(e);return n.error===null?n.data===void 0?(0,h.jsx)(`span`,{className:`h-4 w-[40ch] max-w-full rounded-control bg-panel2`}):t===`prose`?(0,h.jsx)(bG,{markdown:n.data}):(0,h.jsx)(`pre`,{className:`max-w-[75ch] overflow-x-auto whitespace-pre-wrap font-sans text-small text-ink2`,children:n.data}):(0,h.jsx)(`p`,{className:`text-body text-red`,children:n.error.message})}function kG({output:e}){let[t,n]=(0,m.useState)(!1);return e===void 0?null:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`button`,{type:`button`,"aria-expanded":t,onClick:()=>{n(!t)},className:`rounded-control text-small text-ink2 underline underline-offset-[3px] hover:text-ink`,children:t?`Hide instructions`:`Show instructions`}),t?(0,h.jsx)(OG,{output:e,as:`plain`}):null]})}function AG({stage:e,project:t,outputs:n,actions:r,busy:i}){let a=TP(t.id),o=yP(n,e),s=bP(o,`article_md`)??bP(o,`article_txt`),c=bP(o,`sources`),l=bP(o,`glossary`),u=DG(s),d=nt({queryKey:EP(t.id,a),queryFn:()=>[],enabled:!1}).data?.some(e=>e.stage===`article`)===!0,f=nt({queryKey:V.article(t.id,a),queryFn:()=>``,enabled:!1}),p=u.data??``,m=CG(e.state===`running`?f.data??``:p),g=m.title??t.title;return(0,h.jsxs)(mG,{children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-[14px] text-small text-ink2`,children:[(0,h.jsx)(`span`,{className:`text-row font-semibold text-ink`,children:(0,h.jsx)(xG,{markdown:g})}),c===void 0?null:(0,h.jsx)(EG,{output:c,label:`Sources`}),l===void 0?null:(0,h.jsx)(EG,{output:l,label:`Glossary`})]}),(0,h.jsx)(`p`,{className:`text-small text-ink2`,children:`Use Edit project to save changes, then review affected outputs before rebuilding.`}),(0,h.jsxs)(hG,{children:[(0,h.jsx)(wP,{action:{kind:`rerun`,stage:e.kind},run:()=>r.run({kind:`rerun`,stage:e.kind}),disabled:i,pending:r.pending,children:`Re-run`}),(0,h.jsx)(kG,{output:bP(o,`instructions`)}),s===void 0?null:(0,h.jsx)(EG,{output:s})]}),u.error===null?null:(0,h.jsx)(`p`,{className:`text-body text-red`,children:u.error.message}),(0,h.jsx)(`section`,{"aria-label":`Article content`,tabIndex:0,className:`max-h-[min(58vh,640px)] min-h-48 overflow-auto pr-3`,children:e.state===`running`&&d?(0,h.jsx)(OP,{projectId:t.id,stage:`article`}):(0,h.jsx)(bG,{markdown:m.body})})]})}function jG({projectId:e,revisionId:t}){let n=TP(e),r=t===void 0?n:t,{api:i}=I(),a=nt({queryKey:V.audioPreview(e,r),queryFn:async()=>eo(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 rounded-control border border-line2 bg-panel2 p-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-ink2`,children:`Play any part. Each preview starts from its beginning.`})]}),a.error===null?null:(0,h.jsx)(`p`,{className:`text-small text-ink2`,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-ink2`,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)(MG,{preview:t,url:`${i.origin}/api/projects/${encodeURIComponent(e)}/audio-preview/${t.id}`},t.id))})]})}function MG({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-ink2`,children:a})]}),i&&!n?(0,h.jsx)(NG,{label:e.label,url:t,onError:()=>r(!0)}):(0,h.jsx)(`p`,{className:`text-ink2`,children:e.state===`streaming`&&!n?`Waiting for audio…`:`This preview has stopped. The finished narration will be available when generation completes.`})]})}function NG({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)(`audio`,{ref:r,controls:!0,preload:`none`,"aria-label":`Live ${e} narration`,src:t,onError:n,className:`h-9 w-full max-w-[620px]`})}function PG({outputs:e}){let t=e.filter(e=>e.role===`narration_txt`||e.role===`tts_script`);return t.length===0?null:(0,h.jsxs)(`section`,{"aria-label":`Narration text downloads`,className:`space-y-3`,children:[[`intro`,`body`,`outro`].map(e=>{let n=t.filter(t=>t.meta.segment===e);if(n.length===0)return null;let r=e===`body`?`Body`:e===`intro`?`Intro`:`Outro`;return(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 text-small`,children:[(0,h.jsx)(gG,{children:r}),n.map(e=>(0,h.jsx)(EG,{output:e,label:`${r} ${e.role===`narration_txt`?`Clean Narration`:`TTS Script`}`},e.id))]},e)}),(0,h.jsx)(`p`,{className:`text-small text-ink3`,children:`Clean Narration is the spoken text used for captions. TTS Script includes delivery cues; blank lines separate requests. Uploaded audio has no TTS request.`})]})}var FG=[{role:`audio_intro`,name:`Intro`},{role:`audio_body`,name:`Body`},{role:`audio_outro`,name:`Outro`}];function IG({stage:e,project:t,outputs:n,actions:r,busy:i}){let{api:a}=I(),o=nt(yy(a)),s=yP(n,e),c=FG.flatMap(e=>{let t=bP(s,e.role);return t===void 0?[]:[{...e,output:t}]}),l=c.find(e=>e.output.meta.voice!==void 0)?.output.meta,u=c.length>0?l?.voice:t.config.audio?.voice,d=c.length>0?l?.provider:t.config.audio?.provider,f=o.data?.voices.find(e=>e.voiceId===u&&e.provider===d)?.name??u;return(0,h.jsxs)(mG,{children:[e.state===`running`?(0,h.jsx)(jG,{projectId:t.id}):null,c.length===0?(0,h.jsx)(`p`,{className:`text-small text-ink2`,children:`No narration has landed yet.`}):c.map(e=>(0,h.jsx)(LG,{name:e.name,output:e.output},e.role)),(0,h.jsx)(PG,{outputs:s}),(0,h.jsxs)(hG,{children:[(0,h.jsx)(wP,{action:{kind:`rerun`,stage:e.kind},run:()=>{r.run({kind:`rerun`,stage:e.kind})},disabled:i,pending:r.pending,children:`Re-run`}),f===void 0?null:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(gG,{children:`Voice`}),(0,h.jsx)(`span`,{className:`text-small text-ink`,children:f})]}),(0,h.jsx)(`span`,{className:`text-small text-ink2`,children:`Chunking: ${RG(t.config.chunking)}`})]})]})}function LG({name:e,output:t}){let n=dG(t),r=Xk(t.durationMs??void 0);return(0,h.jsxs)(`div`,{className:`grid grid-cols-[60px_minmax(0,1fr)_auto] items-center gap-3 text-small`,children:[(0,h.jsx)(gG,{children:e}),(0,h.jsx)(`audio`,{controls:!0,preload:`metadata`,"aria-label":`${e} narration`,src:n?.url,className:`h-8 w-full max-w-[520px]`}),(0,h.jsxs)(`span`,{className:`flex items-center gap-4`,children:[r===void 0?null:(0,h.jsx)(`span`,{className:`text-ink2 tabular-nums`,children:r}),(0,h.jsx)(EG,{output:t})]})]})}function RG(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 zG(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(BG)}]})}function BG(e,t){return(e.meta.index??0)-(t.meta.index??0)}function VG(e){return e===`9:16`?`aspect-[9/16]`:`aspect-video`}function HG({stage:e,project:t,outputs:n,actions:r,busy:i}){let a=zG(yP(n,e),t.config.imagePrompts?.map(e=>e.name)??[]);return(0,h.jsxs)(mG,{children:[(0,h.jsxs)(hG,{children:[(0,h.jsx)(wP,{action:{kind:`rerun`,stage:e.kind},run:()=>{r.run({kind:`rerun`,stage:e.kind})},disabled:i,pending:r.pending,children:`Re-run stage`}),(0,h.jsx)(TG,{projectId:t.id,asset:`images.zip`,label:`Download all`})]}),a.length===0?(0,h.jsx)(`p`,{className:`text-small text-ink2`,children:`No images have landed yet.`}):null,a.map(e=>(0,h.jsxs)(`section`,{className:`flex flex-col gap-[10px]`,children:[(0,h.jsx)(gG,{children:`${e.name} × ${String(e.images.length)}`}),(0,h.jsx)(`div`,{className:`grid grid-cols-3 gap-2 min-[900px]:grid-cols-6`,children:e.images.map(e=>(0,h.jsx)(UG,{image:e,format:t.format,actions:r,busy:i},e.id))})]},e.name))]})}function UG({image:e,format:t,actions:n,busy:r}){let i=dG(e),a=e.meta.index===void 0?``:` ${String(e.meta.index)}`;return(0,h.jsxs)(`figure`,{className:`group relative m-0 overflow-hidden rounded-control border border-line bg-panel2`,children:[(0,h.jsx)(`img`,{src:i?.url,alt:e.meta.prompt??`Slideshow image${a}`,className:z(`block w-full object-cover animate-tick-in motion-reduce:animate-none`,VG(t))}),(0,h.jsxs)(`figcaption`,{className:`absolute inset-x-0 bottom-0 flex flex-wrap items-center justify-between gap-1 bg-panel/90 p-1 opacity-0 transition-opacity duration-150 group-hover:opacity-100 focus-within:opacity-100 motion-reduce:transition-none`,children:[(0,h.jsx)(EG,{output:e}),(0,h.jsx)(wP,{action:{kind:`regenerate-image`,outputId:e.id},run:()=>{n.run({kind:`regenerate-image`,outputId:e.id})},disabled:r,pending:n.pending,variant:`ghost`,children:`Regenerate`}),(0,h.jsx)(wP,{action:{kind:`delete-image`,outputId:e.id},run:()=>{n.run({kind:`delete-image`,outputId:e.id})},disabled:r,pending:n.pending,variant:`ghost`,children:`Delete`})]})]})}function WG({stage:e,outputs:t,actions:n,busy:r}){let i=yP(t,e),a=bP(i,`notes`);return e.state===`running`&&a===void 0?null:(0,h.jsxs)(mG,{children:[(0,h.jsxs)(hG,{children:[(0,h.jsx)(wP,{action:{kind:`rerun`,stage:e.kind},run:()=>{n.run({kind:`rerun`,stage:e.kind})},disabled:r,pending:n.pending,children:`Re-run`}),(0,h.jsx)(kG,{output:bP(i,`instructions`)}),a===void 0?null:(0,h.jsx)(EG,{output:a})]}),(0,h.jsx)(`section`,{"aria-label":`Research notes`,tabIndex:0,className:`max-h-[min(58vh,640px)] min-h-48 overflow-auto pr-3`,children:a===void 0?(0,h.jsx)(`p`,{className:`text-small text-ink2`,children:e.state===`running`?`Research notes will be saved when the writing above finishes.`:`No notes were written.`}):(0,h.jsx)(OG,{output:a})})]})}function GG({stage:e,project:t,outputs:n,actions:r,busy:i}){let a=yP(n,e),o=bP(a,`thumbnail`),s=dG(o),c=t.config.sources.thumbnail===`prompt_by_llm`;return(0,h.jsxs)(mG,{className:`grid grid-cols-1 items-start gap-4 min-[900px]:grid-cols-[200px_minmax(0,1fr)]`,children:[o===void 0?(0,h.jsx)(`p`,{className:`text-small text-ink2`,children:`No thumbnail has landed yet.`}):(0,h.jsx)(`img`,{src:s?.url,alt:o.meta.prompt??`Thumbnail`,className:z(`block w-full rounded-control border border-line bg-panel2 object-cover`,VG(t.format))}),(0,h.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,h.jsx)(gG,{children:c?`Prompt written by the LLM`:`Prompt`}),o?.meta.prompt===void 0?(0,h.jsx)(`p`,{className:`text-small text-ink2`,children:`This run stored no prompt for the thumbnail.`}):(0,h.jsx)(`p`,{className:`max-w-[75ch] rounded-control border border-line2 bg-panel2 px-[10px] py-2 text-pretty text-small text-ink`,children:o.meta.prompt}),(0,h.jsxs)(hG,{children:[(0,h.jsx)(wP,{action:{kind:`rerun`,stage:e.kind},run:()=>{r.run({kind:`rerun`,stage:e.kind})},disabled:i,pending:r.pending,children:`Regenerate`}),(0,h.jsx)(kG,{output:bP(a,`instructions`)}),o===void 0?null:(0,h.jsx)(EG,{output:o})]})]})]})}function KG({stage:e,project:t,outputs:n,actions:r,busy:i,subtitleControls:a}){let o=t.config.sources.video===`off`&&t.config.sources.audio!==`off`,s=bP(yP(n,e),o?`audio_export`:`video`),c=yP(n,e),l=bP(c,`subtitles_srt`),u=bP(c,`subtitles_vtt`),d=dG(s),f=dG(u),p=s?.meta.subtitlesMode??t.config.subtitles?.mode,m=e.state===`running`,g=Zk(e.progressCurrent??0,e.progressTotal??0);return t.config.sources.video===`off`&&!o?(0,h.jsx)(mG,{children:a}):(0,h.jsxs)(mG,{children:[m?(0,h.jsx)(`p`,{className:`text-small text-run-text`,children:Hk(e,t.config)?`Preparing subtitles · ${String(Zk(e.progressCurrent??0,35))}%`:o?`Exporting combined audio`:e.progressTotal===null?`Re-rendering`:`Re-rendering · ${String(g)}%`}):null,s===void 0?(0,h.jsx)(`p`,{className:`text-small text-ink2`,children:o?`No combined audio export has landed yet.`:`No render has landed yet.`}):o?(0,h.jsx)(`audio`,{controls:!0,preload:`metadata`,"aria-label":`Combined narration`,src:d?.url,className:`h-9 w-full max-w-[720px]`},s.id):(0,h.jsx)(`video`,{controls:!0,preload:`metadata`,src:d?.url,"aria-label":`Generated video`,className:z(`mx-auto block max-h-[min(58vh,560px)] w-auto max-w-full rounded-control bg-screen`,t.format===`9:16`?`aspect-[9/16]`:`aspect-video`),children:p===`files`&&u&&f?(0,h.jsx)(`track`,{kind:`captions`,srcLang:`en`,label:`English`,default:!0,src:f?.url},u.id):null},s.id),(0,h.jsxs)(hG,{children:[s===void 0?null:(0,h.jsx)(EG,{output:s,label:o?`Download .wav`:`Download .mp4`}),e.state===`pending`||e.state===`skipped`?null:(0,h.jsx)(wP,{action:{kind:`rerun`,stage:e.kind},run:()=>{r.run({kind:`rerun`,stage:e.kind})},disabled:i||![`done`,`failed`,`canceled`].includes(e.state),pending:r.pending,children:o?`Re-export`:`Re-render`}),(0,h.jsx)(`span`,{className:`text-small text-ink2`,children:[Xk(s?.durationMs??void 0),o?`WAV · stereo · 48 kHz`:t.format].filter(e=>e!==void 0).join(` · `)})]}),s?.meta.subtitleOmissions?.length?(0,h.jsxs)(`details`,{className:`rounded-control border border-line p-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:`mt-2 text-ink2`,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:`mt-2 space-y-2`,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,l||u?(0,h.jsxs)(hG,{children:[l?(0,h.jsx)(EG,{output:l,label:`Download .srt`}):null,u?(0,h.jsx)(EG,{output:u,label:`Download .vtt`}):null]}):null,a?(0,h.jsxs)(`details`,{className:`mt-2 rounded-control border border-line px-4 py-3`,children:[(0,h.jsx)(`summary`,{className:`cursor-pointer text-small font-semibold`,children:`Subtitles & fonts`}),a]}):null]})}function qG(e){switch(e.stage.kind){case`research`:return(0,h.jsx)(WG,{...e});case`article`:return(0,h.jsx)(AG,{...e});case`audio`:return(0,h.jsx)(IG,{...e});case`images`:return(0,h.jsx)(HG,{...e});case`thumbnail`:return(0,h.jsx)(GG,{...e});case`video`:return(0,h.jsx)(KG,{...e})}}var JG=K({revisionId:W(),checkpoints:G(JD.unwrap().extend({currentFingerprint:W().regex(/^[a-f0-9]{64}$/),dependents:G(q(VD)),workKeys:G(W())}))}),YG=K({revisionId:W().min(1).max(64).regex(/^[0-9A-Za-z_-]+$/),stages:G(qD).max(3).refine(e=>new Set(e).size===e.length).readonly()}).strict(),XG=K({title:W(),status:KE(),detail:W().optional(),reason:q([`duplicate`,`not-found`,`conflict`,`invalid-input`]).optional()}),ZG=YD.unwrap().omit({projectId:!0,checkpointId:!0,approvedAt:!0}),QG=e=>[`checkpoints`,e],$G=(e,t)=>[...QG(e),t];async function eK(e,t){let n=await e.json();if(e.ok)return{ok:!0,value:t.parse(n)};let r=XG.safeParse(n);if(!r.success)throw io(e,void 0);if(![400,404,409].includes(e.status))throw Error(r.data.detail??r.data.title);return{ok:!1,reason:r.data.reason??`invalid-input`,message:r.data.detail??r.data.title}}async function tK(e,t){return eK(await e.fetch(`${e.origin}/api/projects/${encodeURIComponent(t)}/checkpoints`),JG)}async function nK(e,t,n,r){return eK(await e.fetch(`${e.origin}/api/projects/${encodeURIComponent(t)}/checkpoints/${encodeURIComponent(n)}/approve`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(ZG.parse(r))}),K({checkpoint:JD,replayed:XE()}))}async function rK(e,t,n){return eK(await e.fetch(`${e.origin}/api/projects/${encodeURIComponent(t)}/checkpoints`,{method:`PATCH`,headers:{"content-type":`application/json`},body:JSON.stringify(YG.parse(n))}),JG)}var iK=[{stage:`audio`,name:`Audio`},{stage:`images`,name:`Images`},{stage:`video`,name:`Video / export`}];function aK({projectId:e,revisionId:t,gates:n,stages:r,reload:i,saved:a}){let{api:o}=I(),[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=iK.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. Reload before saving. (conflict)`}: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 rK(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 revision changed. Reload checkpoint choices.`}):f({kind:`refused`,message:`${n.message} (${n.reason})`})}catch(e){g.current&&f({kind:`transport`,message:`${e instanceof Error?e.message:`Checkpoint response unavailable.`} Reload checkpoint choices before making another change.`})}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`,children:[(0,h.jsx)(`legend`,{children:`Checkpoint choices`}),(0,h.jsx)(`p`,{children:`Change checkpoints before a step starts. Removing one lets its already-admitted work continue when ready; project pause still applies.`}),iK.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)(B,{type:`button`,disabled:!S||l||C,onClick:()=>void T(),children:l?`Saving…`:`Save checkpoints`}),C?(0,h.jsx)(B,{type:`button`,disabled:l,onClick:()=>void E(),children:`Reload checkpoint choices`}):null]})}var oK=e=>e.charAt(0).toUpperCase()+e.slice(1);function sK(e){return e.revisionId===null?null:(0,h.jsx)(cK,{...e,revisionId:e.revisionId},`${e.projectId}:${e.revisionId}`)}function cK({projectId:e,revisionId:t,paused:n,stages:r}){let{api:i}=I(),a=_(),o=nt({queryKey:$G(e,t),queryFn:()=>tK(i,e),retry:!1}),s=o.data,c=async()=>{let e=await o.refetch();return!e.isError&&e.data?.ok===!0&&e.data.value.revisionId===t?e.data.value:void 0},l=async()=>{let e=await o.refetch();return!e.isError&&e.data?.ok===!0&&e.data.value.revisionId===t};return o.isPending?null:o.error||s?.ok===!1?(0,h.jsxs)(`section`,{"aria-label":`Review checkpoints`,children:[(0,h.jsx)(`p`,{role:`alert`,children:o.error?.message??(s?.ok===!1?s.message:`Checkpoint status unavailable.`)}),(0,h.jsx)(B,{type:`button`,onClick:()=>void l(),children:`Reload checkpoints`})]}):s?.ok?s.value.revisionId===t?(0,h.jsxs)(`section`,{"aria-label":`Review checkpoints`,className:`space-y-3 rounded-panel border border-line bg-panel p-4`,children:[(0,h.jsx)(`h2`,{children:`Review checkpoints`}),n?(0,h.jsx)(`p`,{children:`Project is paused. Resume it before approving held work.`}):null,(0,h.jsx)(aK,{projectId:e,revisionId:t,gates:s.value.checkpoints,stages:r,reload:c,saved:n=>{a.setQueryData($G(e,t),{ok:!0,value:n}),a.invalidateQueries({queryKey:V.project(e)}),a.invalidateQueries({queryKey:V.projects})}}),s.value.checkpoints.map(i=>(0,h.jsx)(lK,{gate:i,disabled:n||i.projectId!==e||i.revisionId!==t||r.some(e=>e.kind===i.stage&&[`running`,`canceled`].includes(e.state)),reload:l},`${i.checkpointId}:${i.fingerprint}`))]}):(0,h.jsx)(`section`,{"aria-label":`Review checkpoints`,children:(0,h.jsx)(`p`,{role:`alert`,children:`Checkpoint status belongs to another revision. Reload the project before approving.`})}):null}function lK({gate:e,disabled:t,reload:n}){let{api:r}=I(),i=_(),a=(0,m.useRef)(null),o=(0,m.useRef)(!1),s=(0,m.useRef)(!0),c=(0,m.useRef)(null),[l,u]=(0,m.useState)(!1),[d,f]=(0,m.useState)(null);(0,m.useEffect)(()=>(s.current=!0,()=>{s.current=!1}),[]),(0,m.useEffect)(()=>{d!==null&&c.current?.focus()},[d]);let p=[`configured`,`pending-review`,`held`].includes(e.state)&&e.fingerprint===e.currentFingerprint;async function g(){if(!(o.current||t||!p||d?.kind===`refused`||d?.kind===`success`)){o.current=!0,u(!0),a.current??={revisionId:e.revisionId,fingerprint:e.fingerprint,idempotencyKey:crypto.randomUUID()};try{let t=await nK(r,e.projectId,e.checkpointId,a.current);a.current=null,s.current&&f(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} (${t.reason})`}),i.invalidateQueries({queryKey:QG(e.projectId)}),i.invalidateQueries({queryKey:V.project(e.projectId)}),i.invalidateQueries({queryKey:V.projects})}catch(e){s.current&&f({kind:`transport`,message:`${e instanceof Error?e.message:`Approval response unavailable.`} Retry to check the same approval request.`})}finally{o.current=!1,s.current&&u(!1)}}}return(0,h.jsxs)(`div`,{className:`space-y-2 rounded-control border border-line p-3`,children:[(0,h.jsxs)(`h3`,{children:[oK(e.stage),` checkpoint`]}),(0,h.jsx)(`p`,{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.`:p?`${oK(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`,{children:[`Reviewed revision: `,e.revisionId]}),e.dependents.length?(0,h.jsx)(`ul`,{"aria-label":`Dependent work`,children:e.dependents.map(e=>(0,h.jsx)(`li`,{children:oK(e)},e))}):(0,h.jsx)(`p`,{children:`No dependent stages.`}),d?(0,h.jsx)(`p`,{ref:c,tabIndex:-1,role:d.kind===`success`?`status`:`alert`,children:d.message}):null,p?(0,h.jsx)(B,{type:`button`,disabled:t||l||d?.kind===`refused`||d?.kind===`success`,onClick:()=>void g(),children:l?`Approving…`:d?.kind===`transport`?`Retry approval`:`Approve ${oK(e.stage)} checkpoint`}):null,d?.kind===`refused`?(0,h.jsx)(B,{type:`button`,onClick:async()=>{await n()&&f(null)},children:`Reload checkpoints`}):null]})}var uK={pending:`text-ink3`,running:`text-run-text`,done:`text-done`,failed:`text-red`,canceled:`text-amber`,paused:`text-amber`,provided:`text-ink2`,skipped:`text-ink3`};function dK({state:e,announce:t,className:n}){return(0,h.jsxs)(`span`,{className:z(`inline-flex items-center`,n),children:[(0,h.jsx)(`span`,{"data-state":e,className:z(`engraved font-bold`,uK[e]),children:e}),t===void 0?null:(0,h.jsx)(`span`,{className:`sr-only`,role:`status`,"aria-live":`polite`,children:`${t}: ${e}`})]})}var fK={pending:`bg-lamp-off shadow-[inset_0_0_0_1px_var(--color-lamp-ring)]`,running:`bg-lamp-run shadow-[0_0_0_3px_var(--color-lamp-halo)] animate-lamp-pulse motion-reduce:animate-none`,done:`bg-done`,failed:`bg-red`,canceled:`bg-amber`,paused:`bg-amber`,provided:`bg-lamp-off shadow-[inset_0_0_0_1px_var(--color-lamp-ring)]`,skipped:`bg-lamp-off shadow-[inset_0_0_0_1px_var(--color-lamp-ring)]`};function pK({state:e,className:t}){return(0,h.jsx)(`span`,{"aria-hidden":`true`,"data-lamp":e,className:z(`size-[10px] shrink-0 rounded-full`,fK[e],t)})}function mK({project:e,prompts:t,actions:n,inFlight:r,primaryOutput:i,children:a}){let o=e.status===`running`;return(0,h.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-5 py-2`,children:[(0,h.jsxs)(`div`,{className:`w-full min-w-0 sm:min-w-[220px] sm:flex-1`,children:[(0,h.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,h.jsx)(pK,{state:e.status}),(0,h.jsx)(dK,{state:e.status,announce:`Project`})]}),(0,h.jsx)(`h1`,{className:`break-words text-[28px] font-bold leading-tight`,children:e.title}),(0,h.jsx)(`p`,{className:`mt-2 text-small text-ink2`,children:hK(e,t)})]}),(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[a,i?(0,h.jsx)(`span`,{className:`rounded-control border border-accent bg-accent px-4 py-2 [&_a]:font-semibold [&_a]:text-accent-ink`,children:(0,h.jsx)(EG,{output:i,label:i.role===`video`?`Download video`:i.role===`audio_export`?`Download audio`:`Download article`})}):null,o||e.status===`pending`?(0,h.jsx)(B,{disabled:n.pending,onClick:()=>n.run({kind:`pause`}),children:`Pause`}):null,e.status===`paused`||e.status===`failed`?(0,h.jsx)(B,{disabled:n.pending||r,onClick:()=>n.run({kind:`resume`}),children:`Resume`}):null,o?(0,h.jsx)(wP,{action:{kind:`cancel`},run:()=>{n.run({kind:`cancel`})},pending:n.pending,children:`Cancel run`}):null]})]})}function hK(e,t){let n=e.config.articlePrompt,r=t===void 0||t.some(e=>e.name===n);return[n===void 0||n===``?void 0:r?n:`${n} (deleted)`,e.format,`started ${jc(e.createdAt)}`].filter(e=>e!==void 0).join(` · `)}var gK=e=>e.state===`done`||e.state===`provided`;function _K(e){let t=e.filter(e=>e.state!==`skipped`),n=t.length,r=t.filter(gK).length,i=t.reduce((e,t)=>gK(t)?e+1:t.progressTotal===null||t.progressTotal<=0?e:e+Math.min(.99,Math.max(0,(t.progressCurrent??0)/t.progressTotal)),0);return{completed:r,total:n,percent:n===0?0:Math.min(r===n?100:99,Math.round(i/n*100))}}function vK(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`&&gK(e));if(n)return n.kind;let r=e.find(e=>e.state===`pending`);return r?r.kind:e.find(e=>e.kind===`article`&&gK(e))?.kind??e.find(e=>e.state!==`skipped`)?.kind??`article`}function yK({stages:e,project:t}){let n=_K(e);return(0,h.jsxs)(`div`,{className:`rounded-panel border border-line bg-panel px-5 py-4`,children:[(0,h.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center justify-between gap-2`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,h.jsx)(`span`,{className:`text-small font-semibold`,children:`Overall progress`}),(0,h.jsxs)(`span`,{className:`text-small text-ink2`,children:[n.completed,` of `,n.total,` stages finished`]})]}),(0,h.jsxs)(`span`,{className:`text-small font-semibold tabular-nums`,children:[n.percent,`%`]})]}),(0,h.jsx)(`div`,{role:`progressbar`,"aria-label":`Overall progress`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":n.percent,"aria-valuetext":`${n.percent} percent; ${n.completed} of ${n.total} stages finished`,className:`h-2 overflow-hidden rounded-control bg-panel2`,children:(0,h.jsx)(`div`,{className:z(`h-full origin-left bg-accent transition-transform duration-200 motion-reduce:transition-none`,t.status===`failed`&&`bg-red`),style:{transform:`scaleX(${n.percent/100})`}})}),(0,h.jsx)(`p`,{className:`mt-2 text-label text-ink3`,children:`Combines finished stages with progress reported by active stages.`})]})}function bK({stages:e,project:t,outputs:n,selected:r,onSelect:i}){return(0,h.jsxs)(`nav`,{"aria-label":`Project stages`,className:`h-fit rounded-panel border border-line bg-panel lg:sticky lg:top-6`,children:[(0,h.jsx)(`div`,{className:`border-b border-line px-4 py-3`,children:(0,h.jsx)(`h2`,{className:`engraved text-ink3`,children:`Stages`})}),(0,h.jsx)(`div`,{className:`grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-1`,children:e.map(e=>{let a=e.kind===r,o=Vk(e.kind,t.config),s=e.state===`done`||e.state===`provided`;return(0,h.jsxs)(`button`,{type:`button`,"aria-label":`${o}, ${e.state}`,"aria-current":a?`step`:void 0,onClick:()=>i(e.kind),className:z(`group relative flex min-w-0 items-start gap-2 border-b border-line px-3 py-4 sm:gap-3 sm:px-4 text-left transition-colors last:border-b-0 hover:bg-panel2`,a&&`bg-panel2 before:absolute before:inset-y-0 before:left-0 before:w-[3px] before:bg-accent`,e.state===`skipped`&&`text-ink3`),children:[(0,h.jsx)(Pc,{kind:e.kind,className:z(`mt-0.5 shrink-0 text-ink2`,a&&`text-run-text`)}),(0,h.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,h.jsx)(`span`,{className:`block text-body font-semibold`,children:o}),(0,h.jsx)(`span`,{className:`mt-1 block truncate text-label text-ink2`,children:Gk(e,n,t)}),(0,h.jsxs)(`span`,{className:`mt-2 flex items-center gap-2`,children:[(0,h.jsx)(pK,{state:e.state}),(0,h.jsx)(dK,{state:e.state,announce:o})]})]}),s?(0,h.jsx)(qA,{"aria-hidden":`true`,className:`mt-1 hidden size-3.5 shrink-0 text-ink3 sm:block`}):e.state===`canceled`?(0,h.jsx)(QA,{"aria-hidden":`true`,className:`mt-1 hidden size-3.5 shrink-0 sm:block`}):a?(0,h.jsx)(XA,{"aria-hidden":`true`,className:`mt-1 hidden size-3.5 shrink-0 text-ink3 sm:block`}):null]},e.id)})})]})}function xK(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:SK(n.map(e=>e.text))}),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 subtitle word timing is invalid; regenerate alignment.`);let e=n[0];e!==void 0&&(t.start-r>.7||t.end-e.start>5||SK([...n.map(e=>e.text),t.text]).split(`
131
- `).length>2)&&i(),n.push({...t,text:t.text.replace(/\s+/g,` `).trim()}),r=t.end,/[.!?]["'’”)]*$/.test(t.text)&&i()}return i(),t}function SK(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(`
132
- `)}function CK({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 duration is unavailable.`);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}: caption IDs must be unique.`);return}if(r.add(o.id),!Number.isFinite(a)||a<0||a<i){c(`Caption ${n+1}: start must follow the previous caption.`);return}if(!Number.isFinite(s)||s<=a||s>t){c(`Caption ${n+1}: end must be after start and within 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}),i=s}n(e),c(void 0),u(!1)}return(0,h.jsxs)(`section`,{"aria-label":`Edit caption cues`,className:`space-y-3`,children:[(0,h.jsx)(`h3`,{children:`Caption text and timing`}),a.map((e,t)=>(0,h.jsxs)(`fieldset`,{className:`space-y-2 rounded-control border border-line2 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)(lM,{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)(cM,{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)(cM,{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-red`,children:s}),(0,h.jsx)(B,{type:`button`,onClick:f,children:`Apply caption edits to draft`}),l?(0,h.jsx)(`p`,{children:`Apply these caption edits before saving the project.`}):null]})}function wK({edit:e,view:t,imageKey:n,index:r}){let{api:i}=I(),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`;return(0,h.jsxs)(h.Fragment,{children:[!u||t===void 0?null:(0,h.jsx)(`img`,{className:`max-h-32 rounded-control object-contain`,alt:`Retained scene ${r+1}`,src:aG(i,t.revision.projectId,t.revision.id,l.recordId)}),(0,h.jsx)(`p`,{children:f})]})}function TK(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:hM(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]??``:hM(n,e.config.values)]))}}}}function EK(e,t,n){let r={...e.config.sources,[t]:n,...t===`images`&&n===`off`?{video:`off`}:{}};return{...e,config:{...e.config,sources:r,subtitles:MM(e.config.subtitles,r)}}}function DK(e,t,n){return TK({...e,content:{...e.content,promptTemplates:{...e.content.promptTemplates,[t]:n}}})}function OK(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 kK({label:e,kind:t,disabled:n=!1,onReady:r,onPending:i}){let{api:a}=I(),o=(0,m.useId)(),[s,c]=(0,m.useState)(),[l,u]=(0,m.useState)(!1),d=(0,m.useRef)(void 0),f=(0,m.useRef)(r);f.current=r;let p=(0,m.useRef)(i);p.current=i;let g=(0,m.useRef)(!0);(0,m.useEffect)(()=>(g.current=!0,()=>{g.current=!1,d.current?.abort(),p.current(!1)}),[]);async function _(e){if(n||d.current!==void 0)return;let r=new AbortController;d.current=r,u(!0),p.current(!0),c(void 0);let i;try{let n=await po(a,t,e);for(i=n.id,r.signal.throwIfAborted();n.state!==`staged`;){await OK(r.signal);let e=(await uo(a)).files.find(e=>e.id===n.id);if(r.signal.throwIfAborted(),e===void 0)throw Error(`The upload failed before staging completed.`);n=e}f.current(n)}catch(e){let t=r.signal.aborted?`Upload canceled.`:e instanceof Error?e.message:String(e);if(i!==void 0)try{await mo(a,i)}catch(e){t+=` Cleanup failed: ${e instanceof Error?e.message:String(e)}`}g.current?c(t):t.includes(`Cleanup failed:`)&&console.error(t)}finally{d.current===r&&(d.current=void 0,g.current&&(u(!1),p.current(!1)))}}return(0,h.jsxs)(`div`,{className:`space-y-2`,children:[(0,h.jsxs)(`label`,{htmlFor:o,className:`block space-y-1 text-small`,children:[e,(0,h.jsx)(cM,{id:o,type:`file`,disabled:l||n,accept:t===`audio`?`audio/*`:`image/png,image/jpeg,image/webp`,onChange:e=>{let t=e.target.files?.[0];e.target.value=``,t!==void 0&&_(t)}})]}),l?(0,h.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,h.jsx)(`p`,{role:`status`,className:`text-small text-ink2`,children:`Copying upload…`}),(0,h.jsx)(B,{type:`button`,onClick:()=>d.current?.abort(),children:`Cancel upload`})]}):null,s===void 0?null:(0,h.jsx)(`p`,{role:`alert`,className:`text-small text-red`,children:s})]})}function AK(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 jK({edit:e,onChange:t,onPending:n,view:r,getEdit:i}){let a=(0,m.useId)(),[o,s]=(0,m.useState)({}),{content:c}=e,l=(0,m.useRef)(e);l.current=e;function u(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`}:{}}}};l.current=i,t(i)}function d(e,t){let n=i?.()??l.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})),u(DK({...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))}return(0,h.jsxs)(`section`,{"aria-label":`Edit images`,className:`space-y-3`,children:[(0,h.jsx)(`h3`,{children:`Images`}),c.imageOrder.map((t,s)=>{let f=c.imageDefinitions[t];return f===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-line2 p-3`,children:[(0,h.jsxs)(`legend`,{children:[`Image `,s+1]}),(0,h.jsx)(wK,{edit:e,view:r,imageKey:t,index:s}),f.source===`generate`?(0,h.jsxs)(`label`,{htmlFor:`${a}-${t}-prompt`,children:[`Prompt for image `,s+1,(0,h.jsx)(lM,{id:`${a}-${t}-prompt`,value:f.templateKey===void 0||f.templateKey===null?f.prompt??``:c.promptTemplates[f.templateKey]??f.prompt??``,onChange:e=>d(t,e.target.value)})]}):null,f.source===`generate`&&f.templateKey==null?(0,h.jsxs)(B,{type:`button`,onClick:()=>d(t,f.prompt??``),children:[`Use saved wording as template for image `,s+1]}):null,(0,h.jsx)(kK,{label:`Replace image ${s+1}`,kind:`images`,onPending:e=>n(`image:${t}`,e),onReady:e=>{let n=i?.()??l.current,r=n.content,a=r.imageDefinitions[t];a!==void 0&&r.imageOrder.includes(t)&&u({...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)(B,{type:`button`,disabled:s===0,onClick:()=>u({...e,content:{...c,imageOrder:AK(c.imageOrder,s,-1)}}),children:[`Move image `,s+1,` earlier`]}),(0,h.jsxs)(B,{type:`button`,disabled:s===c.imageOrder.length-1,onClick:()=>u({...e,content:{...c,imageOrder:AK(c.imageOrder,s,1)}}),children:[`Move image `,s+1,` later`]}),(0,h.jsxs)(B,{type:`button`,onClick:()=>{let n=c.imageOrder.filter(e=>e!==t);u({...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`:``]}),f.source===`generate`?(0,h.jsxs)(B,{type:`button`,onClick:()=>u({...e,regenerate:[...new Set([...e.regenerate??[],`image:${t}`])]}),children:[`Regenerate image `,s+1,` after review`]}):null]},t)}),(0,h.jsx)(B,{type:`button`,disabled:c.imageOrder.length>=60,onClick:()=>{if(c.imageOrder.length>=60)return;let t=crypto.randomUUID();u({...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>=60?(0,h.jsx)(`p`,{children:`At most 60 images can be included.`}):(0,h.jsx)(kK,{label:`Add provided image`,kind:`images`,onPending:e=>n(`image:new`,e),onReady:e=>{let t=i?.()??l.current,n=t.content,r=crypto.randomUUID();u({...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}}]})}},`new-image:${e.config.sources.images===`off`}`)]})}var MK=K({logicalKey:W().min(1),logicalText:W(),segment:q([`body`,`intro`,`outro`]),text:W()});function NK(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=MK.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 PK({view:e,edit:t,onChange:n,onPending:r,getEdit:i}){let a=(0,m.useId)(),{groups:o,unmapped:s}=NK(e),c=(0,m.useRef)(t);c.current=t;let[l,u]=(0,m.useState)({});function d(e){c.current=e,n(e)}return(0,h.jsxs)(`section`,{"aria-label":`Edit narration`,className:`space-y-3`,children:[(0,h.jsx)(`h3`,{children:`Narration`}),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,s===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.`}),o.map((e,n)=>{let o=t.content.narrationOverrides[e.key];return(0,h.jsxs)(`fieldset`,{className:`space-y-2 rounded-control border border-line2 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)(`label`,{htmlFor:`${a}-${e.key}-text`,className:`block text-small`,children:[`Text for narration chunk `,n+1,(0,h.jsx)(lM,{id:`${a}-${e.key}-text`,value:o?.kind===`text`?o.text:e.text,onChange:n=>{u(t=>({...t,[e.key]:(t[e.key]??0)+1})),d({...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)(kK,{label:`Replace narration chunk ${n+1}`,kind:`audio`,onPending:t=>r(`narration:${e.key}`,t),onReady:t=>{let n=i?.()??c.current;d({...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}:${l[e.key]??0}`),(0,h.jsxs)(B,{type:`button`,onClick:()=>{let t=i?.()??c.current,n={...t.content.narrationOverrides};n[e.key]?.kind===`asset`&&delete n[e.key],u(t=>({...t,[e.key]:(t[e.key]??0)+1})),d({...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`]})]},e.key)})]})}function FK(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(IK))return o.reduce((e,t)=>e+t,0)/1e3+Math.max(0,r.length-1)*t.silenceGapSeconds;let s=i.find(e=>(e.output.role===`audio_export`||e.output.role===`video`)&&IK(e.output.durationMs))?.output.durationMs;return IK(s)?s/1e3:void 0}function IK(e){return e!=null&&Number.isFinite(e)&&e>0}var LK=K({words:G(K({text:W().trim().min(1),start:KE().finite().nonnegative(),end:KE().finite().positive(),confidence:KE().optional()})).min(1)});function RK(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`)??[],...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 zK({view:e,edit:t,onChange:n,onPending:r}){let{api:i}=I(),a=RK(t),o=t.config.sources.audio!==`off`&&a===RK({config:e.revision.config,content:e.revision.content}),s=e.revision.fingerprints[`subtitles:timing`],c=o?FK(e):void 0,l=c!==void 0&&s!==void 0&&s!==``,u=(0,m.useRef)({edit:t,onChange:n,revisionId:e.revision.id,identity:a});u.current={edit:t,onChange:n,revisionId:e.revision.id,identity:a};let d=(0,m.useRef)(r);d.current=r;let[f,p]=(0,m.useState)(new Set),[g,_]=(0,m.useState)(),v=(0,m.useRef)(void 0),y=(0,m.useRef)(!0),b=(0,m.useCallback)((e,t)=>{y.current&&p(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)(()=>{d.current(f.size>0)},[f]),(0,m.useEffect)(()=>(y.current=!0,()=>{y.current=!1,v.current?.abort(),d.current(!1)}),[]),(0,m.useEffect)(()=>{let t=e.revision.id;return()=>{(u.current.revisionId!==t||u.current.identity!==a)&&v.current?.abort()}},[e.revision.id,a]);function x(e){let t=u.current.onChange;u.current={...u.current,edit:e,identity:RK(e)},t(e)}async function S(){if(v.current!==void 0)return;let t=new AbortController;v.current=t;let n=u.current;b(`captions:load`,!0),_(void 0);try{let r=e.outputs.find(e=>e.selected&&e.state===`ready`&&e.output.role===`subtitle_words`&&e.available);if(!l||c===void 0||s===void 0||r===void 0)throw Error(`Build subtitle timing from the current narration before editing its cues.`);let a=await i.fetch(aG(i,e.revision.projectId,e.revision.id,r.recordId),{signal:t.signal});if(!a.ok)throw Error(`The retained timing file is unavailable.`);let o=LK.parse(await a.json()),d=0;for(let e of o.words){if(e.start<d||e.end<=e.start||e.end>c)throw Error(`The subtitle word timing must be ordered and within narration.`);d=e.end}let f=xK(o.words).map(e=>({...e,id:crypto.randomUUID()})),p=u.current;if(!y.current||t.signal.aborted||p.revisionId!==n.revisionId||p.identity!==n.identity||p.edit.content.subtitleCues!==n.edit.content.subtitleCues)return;x({...p.edit,content:{...p.edit.content,subtitleCues:{audioFingerprint:s,cues:f}}})}catch(e){y.current&&!t.signal.aborted&&_(e instanceof Error?e.message:String(e))}finally{v.current===t&&(v.current=void 0),b(`captions:load`,!1)}}let C=t.content.subtitleCues;return(0,h.jsxs)(`div`,{className:`space-y-5`,children:[[`audio`,`thumbnail`].map(e=>t.config.sources[e]===`provide`?(0,h.jsx)(kK,{label:`Replace provided ${e}`,kind:e,onPending:t=>b(`provided:${e}`,t),onReady:t=>{let n=u.current;n.edit.config.sources[e]===`provide`&&x({...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)(jK,{getEdit:()=>u.current.edit,view:e,edit:t,onChange:x,onPending:b}),t.config.sources.audio===`generate`?(0,h.jsx)(PK,{getEdit:()=>u.current.edit,view:e,edit:t,onChange:x,onPending:b}):null,g===void 0?null:(0,h.jsx)(`p`,{role:`alert`,className:`text-red`,children:g}),l?null:(0,h.jsx)(`p`,{children:`Build current narration timing before editing caption cues; its duration or timing is unavailable or stale.`}),C===void 0?(0,h.jsx)(B,{type:`button`,disabled:!l||f.has(`captions:load`),onClick:()=>void S(),children:`Edit existing caption cues`}):(0,h.jsxs)(h.Fragment,{children:[C.audioFingerprint===s?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.`}),l&&c!==void 0?(0,h.jsx)(CK,{cues:C.cues,duration:c,onPending:e=>b(`captions:dirty`,e),onChange:e=>{let t=u.current,n=t.edit.content.subtitleCues;n!==void 0&&x({...t.edit,content:{...t.edit.content,subtitleCues:{...n,cues:e}}})}},`${e.revision.id}:${s}`):null,(0,h.jsx)(B,{type:`button`,onClick:()=>x({...t,content:{...t.content,subtitleCues:void 0}}),children:`Discard caption edits`})]})]})}function BK({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)(jN,{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:DK(e,`narration`,r.body);i({...o,config:{...o.config,narrationPrompt:t}})}})}function VK({edit:e,prompts:t,entries:n,onChange:r}){let i=(0,m.useId)(),a=[...new Set([...Object.keys(e.config.rendered),...Object.keys(e.content.promptTemplates),...e.config.sources.article===`generate`?[`article`]:[],...ak(e.config)?[`narration`]:[],...[`from_prompt`,`prompt_by_llm`].includes(e.config.sources.thumbnail)?[`thumbnailPrompt`]:[],...e.config.intro===void 0?[]:[`intro`],...e.config.outro===void 0?[]:[`outro`]])],o=[...new Set([...Object.keys(e.config.values),...Object.values(e.content.promptTemplates).flatMap(e=>e===null?[]:pM(e).names)])];return(0,h.jsxs)(`section`,{"aria-label":`Prompt snapshots`,className:`space-y-3`,children:[a.map(a=>{let o=HK(a),s=e.content.promptTemplates[a]??null,c=a===`intro`||a===`outro`?n.filter(e=>e.category===a):t.filter(e=>e.kind===(a===`article`?`article`:a===`narration`?`narration`:a===`thumbnailPrompt`?`thumbnail`:`image`));return(0,h.jsxs)(`fieldset`,{className:`min-w-0 space-y-3 rounded-control border border-line p-3`,children:[(0,h.jsx)(`legend`,{className:`px-1 text-small font-semibold`,children:o}),s===null?(0,h.jsxs)(`div`,{className:`space-y-2`,children:[(0,h.jsx)(`p`,{children:`Original template unavailable. The saved rendered prompt stays frozen until you choose or write a template.`}),(0,h.jsx)(B,{type:`button`,"aria-label":`Use saved wording as template for ${o}`,onClick:()=>r(DK(e,a,e.config.rendered[a]??``)),children:`Use saved wording as template`})]}):null,(0,h.jsxs)(`label`,{htmlFor:`${i}-library-${a}`,className:`flex min-w-0 flex-col gap-1 text-small`,children:[`Use saved template for `,o,(0,h.jsxs)(aN,{id:`${i}-library-${a}`,value:``,onChange:t=>{let n=c.find(e=>e.id===t.target.value);if(n===void 0)return;let i=DK(e,a,n.body),o=`category`in n?{...i.config,[n.category]:{name:n.name,mode:n.mode}}:a===`article`?{...i.config,articlePrompt:n.name}:a===`narration`?{...i.config,narrationPrompt:n.name}:a===`thumbnailPrompt`?{...i.config,thumbnailPrompt:n.name}:i.config;r({...i,config:o})},children:[(0,h.jsx)(`option`,{value:``,children:`Choose explicitly`}),c.map(e=>(0,h.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]}),(0,h.jsxs)(`label`,{htmlFor:`${i}-raw-${a}`,className:`block space-y-1 text-small`,children:[`Raw prompt for `,o,(0,h.jsx)(lM,{id:`${i}-raw-${a}`,rows:4,value:s??``,onChange:t=>r(DK(e,a,t.target.value))})]}),(0,h.jsxs)(`details`,{children:[(0,h.jsx)(`summary`,{children:`Saved rendered prompt`}),(0,h.jsx)(`pre`,{className:`whitespace-pre-wrap break-words`,children:e.config.rendered[a]??``})]})]},a)}),o.map(t=>(0,h.jsxs)(`label`,{htmlFor:`${i}-keyword-${t}`,className:`block space-y-1 text-small`,children:[`Keyword `,t,(0,h.jsx)(cM,{id:`${i}-keyword-${t}`,maxLength:200,value:e.config.values[t]??``,onChange:n=>r(TK({...e,config:{...e.config,values:{...e.config.values,[t]:n.target.value}}}))})]},t))]})}function HK(e){if(e===`article`)return`Article`;if(e===`narration`)return`Narration Preparation`;if(e===`thumbnailPrompt`)return`Thumbnail`;if(e===`intro`)return`Intro`;if(e===`outro`)return`Outro`;let t=/^imagePrompts\.(\d+)$/.exec(e);return t?.[1]===void 0?e.replace(/[._-]/g,` `).replace(/([a-z])([A-Z])/g,`$1 $2`):`Image prompt ${Number(t[1])+1}`}function UK({edit:e,providers:t,voices:n,onChange:r}){let{config:i}=e,a=i.llm??{provider:``,model:``},o=i.audio??{provider:``,model:``,voice:``},s=i.images??{provider:``,model:``},c=ak(i)||i.sources.research===`generate`||i.sources.article===`generate`||i.sources.thumbnail===`prompt_by_llm`||i.sources.audio===`generate`&&(i.intro?.mode===`llm`||i.outro?.mode===`llm`),l=i.sources.images===`generate`||i.sources.thumbnail===`from_prompt`||i.sources.thumbnail===`prompt_by_llm`,u=n.filter(e=>e.provider===o.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:[c?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(mN,{label:`Text provider`,family:`llm`,providers:t,value:a.provider,problem:void 0,onPick:t=>r({...e,config:{...i,llm:{provider:t,model:``}}})}),(0,h.jsx)(hN,{label:`Text model`,provider:a.provider,value:a.model,problem:void 0,onPick:t=>r({...e,config:{...i,llm:{...a,model:t}}})}),(0,h.jsx)(zN,{choice:a,onChange:t=>r({...e,config:{...i,llm:t}})})]}):null,i.sources.audio===`generate`?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(mN,{label:`Narration provider`,family:`tts`,providers:t,value:o.provider,problem:void 0,onPick:t=>r({...e,config:{...i,audio:{provider:t,model:``,voice:``}}})}),(0,h.jsx)(hN,{label:`Narration model`,provider:o.provider,value:o.model,problem:void 0,onPick:t=>r({...e,config:{...i,audio:{...o,model:t}}})}),(0,h.jsx)(dN,{label:`Narration voice`,value:o.voice,problem:void 0,placeholder:`Choose a saved voice`,options:o.voice!==``&&!u.some(e=>e.value===o.voice)?[{value:o.voice,label:`${o.voice} (saved voice)`},...u]:u,onPick:t=>r({...e,config:{...i,audio:{...o,voice:t}}})}),(0,h.jsx)(vN,{value:i.chunking??{mode:`whole`},onPick:t=>r({...e,config:{...i,chunking:t}})})]}):null,l?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(mN,{label:`Image provider`,family:`image`,providers:t,value:s.provider,problem:void 0,onPick:t=>r({...e,config:{...i,images:{provider:t,model:``}}})}),(0,h.jsx)(hN,{label:`Image model`,provider:s.provider,value:s.model,problem:void 0,onPick:t=>r({...e,config:{...i,images:{...s,model:t}}})})]}):null]})}function WK(e){let{view:t,edit:n,onChange:r,onPending:i,fields:a}=e,o=(0,m.useId)(),[s,c]=(0,m.useState)({font:!1,content:!1});(0,m.useEffect)(()=>{i(s.font||s.content)},[i,s]);let l=(0,m.useCallback)(e=>{c(t=>t.font===e?t:{...t,font:e})},[]),u=(0,m.useCallback)(e=>{c(t=>t.content===e?t:{...t,content:e})},[]),{api:d}=I(),f=nt(vy(d)),p=nt(yy(d)),g=nt(by(d)),_=nt(xy(d)),{config:v}=n,y=e=>a.find(t=>t.field===e||t.field===`config.${e}`||t.field===`edit.config.${e}`)?.message;return(0,h.jsxs)(`div`,{className:`grid min-w-0 gap-4 lg:grid-cols-2`,children:[Object.entries({providers:f.error,voices:p.error,prompts:g.error,entries:_.error}).flatMap(([e,t])=>t===null?[]:[(0,h.jsx)(`p`,{role:`alert`,className:`text-small text-red lg:col-span-2`,children:t.message},e)]),(0,h.jsxs)(`section`,{className:`min-w-0 space-y-3`,children:[(0,h.jsxs)(`label`,{htmlFor:`${o}-title`,className:`block space-y-1 text-small`,children:[`Project title`,(0,h.jsx)(cM,{id:`${o}-title`,value:v.title,maxLength:200,onChange:e=>r({...n,config:{...v,title:e.target.value}})})]}),(0,h.jsx)(pP,{value:v.format,onPick:e=>r({...n,config:{...v,format:e}})}),VD.map(e=>(0,h.jsxs)(`label`,{htmlFor:`${o}-source-${e}`,className:`flex min-w-0 flex-col gap-1 text-small`,children:[e,` source`,(0,h.jsx)(aN,{id:`${o}-source-${e}`,value:v.sources[e],onChange:i=>{let a=FM(e).find(e=>e.value===i.target.value);if(a===void 0)return;let o=EK(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:FM(e).map(t=>(0,h.jsx)(`option`,{value:t.value,disabled:e===`video`&&t.value===`generate`&&v.sources.images===`off`,children:t.label},t.value))})]},e)),v.sources.images===`off`?(0,h.jsx)(`p`,{children:`Images are Off. Video is also Off in these changes.`}):null,(0,h.jsxs)(`label`,{htmlFor:`${o}-gap`,className:`block space-y-1 text-small`,children:[`Silence gap (seconds)`,(0,h.jsx)(cM,{id:`${o}-gap`,type:`number`,min:0,max:30,step:.1,value:Number.isFinite(v.silenceGapSeconds)?v.silenceGapSeconds:``,onChange:e=>r({...n,config:{...v,silenceGapSeconds:Number(e.target.value)}})})]}),[`intro`,`outro`].map(e=>(0,h.jsxs)(`label`,{htmlFor:`${o}-entry-${e}`,className:`flex min-w-0 flex-col gap-1 text-small`,children:[e,(0,h.jsxs)(aN,{id:`${o}-entry-${e}`,value:v[e]?.name??``,onChange:t=>{let i=_.data?.entries.find(n=>n.category===e&&n.name===t.target.value),a={...v};i===void 0?delete a[e]:a[e]={name:i.name,mode:i.mode},r(TK({...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`}),v[e]!==void 0&&!_.data?.entries.some(t=>t.category===e&&t.name===v[e]?.name)?(0,h.jsxs)(`option`,{value:v[e]?.name,children:[v[e]?.name,` (saved entry)`]}):null,_.data?.entries.filter(t=>t.category===e).map(e=>(0,h.jsx)(`option`,{value:e.name,children:e.name},e.id))]})]},e)),v.sources.research===`provide`?(0,h.jsxs)(`label`,{htmlFor:`${o}-research`,className:`block space-y-1 text-small`,children:[`Research notes`,(0,h.jsx)(lM,{id:`${o}-research`,rows:6,value:v.provided.research??``,onChange:e=>r({...n,config:{...v,provided:{...v.provided,research:e.target.value}}})})]}):null,(0,h.jsxs)(`label`,{htmlFor:`${o}-article`,className:`block space-y-1 text-small`,children:[`Article text`,(0,h.jsx)(lM,{id:`${o}-article`,rows:6,maxLength:5e5,value:(n.content.articleEdited?n.content.articleMarkdown:t.articleMarkdown)??n.content.articleMarkdown??v.provided.article??``,onChange:e=>r({...n,content:{...n.content,articleMarkdown:e.target.value,articleEdited:!0}})})]}),n.content.articleEdited?(0,h.jsx)(`p`,{children:`Your edited article is retained when other settings change. Explicit regeneration replaces it after rebuild review.`}):null,v.sources.article===`generate`?(0,h.jsx)(B,{type:`button`,onClick:()=>r({...n,regenerate:[...new Set([...n.regenerate??[],`article:body`])]}),children:`Regenerate article after review`}):null,(0,h.jsx)(UK,{edit:n,providers:f.data?.providers??[],voices:p.data?.voices??[],onChange:r}),(0,h.jsx)(BK,{edit:n,view:t,prompts:g.data?.prompts??[],error:y(`narrationPrompt`),onChange:r})]}),(0,h.jsxs)(`section`,{className:`min-w-0 space-y-3`,children:[(0,h.jsx)(VK,{edit:n,prompts:g.data?.prompts??[],entries:_.data?.entries??[],onChange:r}),(0,h.jsx)(`div`,{"data-tour":`project-subtitles`,children:(0,h.jsx)(fP,{value:v.subtitles??eO,format:v.format,audioEnabled:v.sources.audio!==`off`,videoEnabled:v.sources.video!==`off`,onChange:e=>r({...n,config:{...v,subtitles:MM(e,v.sources)}}),onUploading:l,problem:y})}),a.length===0?null:(0,h.jsx)(`ul`,{role:`alert`,children:a.map(e=>(0,h.jsxs)(`li`,{children:[e.field,`: `,e.message]},`${e.field}-${e.message}`))})]}),(0,h.jsx)(`div`,{className:`lg:col-span-2`,children:e.renderContent?.({view:t,edit:n,fields:a,onChange:r,onPending:u})})]})}var GK={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`};function KK(e){return(e.role===`narration_txt`||e.role===`tts_script`)&&e.meta.segment?`${e.meta.segment===`body`?`Body`:e.meta.segment===`intro`?`Intro`:`Outro`} ${GK[e.role]}`:e.role===`image`&&typeof e.meta.index==`number`?`Image ${e.meta.index}`:GK[e.role]}function qK(e){if(e.startsWith(`image:`))return`Image`;let t=e.split(`:`).at(-1);return Object.entries(GK).find(([e])=>e===t)?.[1]??`Saved output`}function JK({preview:e,pending:t,onStart:n,onCancel:r}){let i=QK(e),[a,o]=(0,m.useState)([]),[s,c]=(0,m.useState)(!1),l=e=>e===null?`Unknown`:new Intl.NumberFormat(`en-US`,{style:`currency`,currency:`USD`,maximumFractionDigits:4}).format(e),u=!e.work.some(e=>e.disposition===`blocked`)&&e.providedReuseRequired.every(e=>a.includes(e))&&(e.costs.unknown===0||s);return(0,h.jsxs)(`section`,{"aria-label":`Review affected rebuild`,className:`space-y-3 rounded-panel border border-line p-4`,children:[(0,h.jsx)(`h2`,{children:`Review affected rebuild`}),e.review?.inputChanges.length?(0,h.jsxs)(`details`,{open:!0,children:[(0,h.jsx)(`summary`,{children:`Changed inputs since the previous revision`}),(0,h.jsx)(`dl`,{className:`space-y-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:`grid gap-2 sm:grid-cols-2`,children:[(0,h.jsxs)(`div`,{className:`min-w-0`,children:[(0,h.jsx)(`span`,{className:`text-small text-ink2`,children:`Before`}),(0,h.jsx)(`pre`,{className:`max-h-40 overflow-auto whitespace-pre-wrap break-words text-small`,children:e.before??`Not set`})]}),(0,h.jsxs)(`div`,{className:`min-w-0`,children:[(0,h.jsx)(`span`,{className:`text-small text-ink2`,children:`After`}),(0,h.jsx)(`pre`,{className:`max-h-40 overflow-auto whitespace-pre-wrap break-words text-small`,children:e.after??`Not set`})]})]})]},e.label))})]}):null,(0,h.jsx)(`ul`,{children:e.changedInputs.map(e=>(0,h.jsxs)(`li`,{children:[i(e.path),`:`,` `,e.after===null?`Removed`:e.before===null?`New output`:`Inputs changed`]},e.path))}),(0,h.jsx)(`ul`,{children:e.work.map(t=>(0,h.jsxs)(`li`,{children:[i(t.key),`: `,YK[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:`text-small text-ink2`,children:e.settings}),e.text===null?null:(0,h.jsxs)(`details`,{children:[(0,h.jsx)(`summary`,{children:`View request text`}),(0,h.jsx)(`pre`,{className:`max-h-56 overflow-auto whitespace-pre-wrap break-words text-small`,children:e.text})]})]},e.key))]},t.key))}),(0,h.jsxs)(`p`,{children:[`Retained outputs:`,` `,e.retained.map(e=>qK(e.slot)).join(`, `)||`None`]}),e.wholeRequestNotice===null?null:(0,h.jsx)(`p`,{children:e.wholeRequestNotice}),(0,h.jsx)(`ul`,{children:e.costs.rows.map(e=>(0,h.jsxs)(`li`,{children:[i(e.stage),`: `,l(e.low),`–`,l(e.high),`. `,e.detail]},`${e.stage}-${e.detail}`))}),(0,h.jsxs)(`p`,{children:[`Known estimate: `,l(e.costs.low),`–`,l(e.costs.high)]}),e.warnings.map(e=>(0,h.jsx)(`p`,{children:e},e)),e.providedReuseRequired.map(e=>(0,h.jsxs)(`label`,{className:`block`,children:[(0,h.jsx)(`input`,{type:`checkbox`,disabled:t,checked:a.includes(e),onChange:t=>o(t.target.checked?[...a,e]:a.filter(t=>t!==e))}),`Keep the provided content for `,i(e)]},e)),e.costs.unknown===0?null:(0,h.jsxs)(`label`,{className:`block`,children:[(0,h.jsx)(`input`,{type:`checkbox`,disabled:t,checked:s,onChange:e=>c(e.target.checked)}),`I understand that `,e.costs.unknown,` cost estimates are unknown.`]}),(0,h.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[(0,h.jsx)(B,{variant:`primary`,type:`button`,disabled:t||!u,onClick:()=>n({acknowledgeUnknownCosts:s,confirmedProvidedWorkKeys:a}),children:`Start rebuild`}),(0,h.jsx)(B,{type:`button`,disabled:t,onClick:r,children:`Cancel rebuild`})]})]})}var YK={reuse:`Reuse`,generate:`Generate`,local:`Build locally`,review:`Review required`,blocked:`Unavailable`},XK={"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 ZK(e){let t=XK[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 QK(e){let t=new Map,n=new Map;for(let t of e.work){let e=ZK(t.key);n.set(e,(n.get(e)??0)+1)}let r=new Map;for(let i of e.work){let e=ZK(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)??ZK(e)}var $K=K({text:W().optional(),logicalText:W().optional(),title:W().optional(),notes:W().optional(),outline:G(W()).optional(),prompt:W().optional()});function eq(e){if(e===null)return`No text was recorded for this part.`;try{let t=$K.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(`
130
+ `))}function c(e,t,n,r){let i=n.enter(`tableCell`),o=n.enter(`phrasing`),s=n.containerPhrasing(e,{...r,before:a,after:a});return o(),i(),s}function l(e,t){return uH(e,{align:t,alignDelimiters:r,padding:n,stringLength:i})}function u(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`table`);for(;++i<r.length;)a[i]=d(r[i],t,n);return o(),a}function d(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`tableRow`);for(;++i<r.length;)a[i]=c(r[i],e,t,n);return o(),a}function f(e,t,n){let r=sU.inlineCode(e,t,n);return n.stack.includes(`tableCell`)&&(r=r.replace(/\|/g,`\\$&`)),r}}function _U(){return{exit:{taskListCheckValueChecked:yU,taskListCheckValueUnchecked:yU,paragraph:bU}}}function vU(){return{unsafe:[{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{listItem:xU}}}function yU(e){let t=this.stack[this.stack.length-2];t.type,t.checked=e.type===`taskListCheckValueChecked`}function bU(e){let t=this.stack[this.stack.length-2];if(t&&t.type===`listItem`&&typeof t.checked==`boolean`){let e=this.stack[this.stack.length-1];e.type;let n=e.children[0];if(n&&n.type===`text`){let r=t.children,i=-1,a;for(;++i<r.length;){let e=r[i];if(e.type===`paragraph`){a=e;break}}a===e&&(n.value=n.value.slice(1),n.value.length===0?e.children.shift():e.position&&n.position&&typeof n.position.start.offset==`number`&&(n.position.start.column++,n.position.start.offset++,e.position.start=Object.assign({},n.position.start)))}}this.exit(e)}function xU(e,t,n,r){let i=e.children[0],a=typeof e.checked==`boolean`&&i&&i.type===`paragraph`,o=`[`+(e.checked?`x`:` `)+`] `,s=n.createTracker(r);a&&s.move(o);let c=sU.listItem(e,t,n,{...r,...s.current()});return a&&(c=c.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,l)),c;function l(e){return e+o}}function SU(){return[OV(),QV(),rH(),cU(),_U()]}function CU(e){return{extensions:[kV(),$V(e),iH(),gU(e),vU()]}}var wU={tokenize:RU,partial:!0},TU={tokenize:zU,partial:!0},EU={tokenize:BU,partial:!0},DU={tokenize:VU,partial:!0},OU={tokenize:HU,partial:!0},kU={name:`wwwAutolink`,tokenize:IU,previous:UU},AU={name:`protocolAutolink`,tokenize:LU,previous:WU},jU={name:`emailAutolink`,tokenize:FU,previous:GU},MU={};function NU(){return{text:MU}}for(var PU=48;PU<123;)MU[PU]=jU,PU++,PU===58?PU=65:PU===91&&(PU=97);MU[43]=jU,MU[45]=jU,MU[46]=jU,MU[95]=jU,MU[72]=[jU,AU],MU[104]=[jU,AU],MU[87]=[jU,kU],MU[119]=[jU,kU];function FU(e,t,n){let r=this,i,a;return o;function o(t){return!KU(t)||!GU.call(r,r.previous)||qU(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkEmail`),s(t))}function s(t){return KU(t)?(e.consume(t),s):t===64?(e.consume(t),c):n(t)}function c(t){return t===46?e.check(OU,u,l)(t):t===45||t===95||TI(t)?(a=!0,e.consume(t),c):u(t)}function l(t){return e.consume(t),i=!0,c}function u(o){return a&&i&&wI(r.previous)?(e.exit(`literalAutolinkEmail`),e.exit(`literalAutolink`),t(o)):n(o)}}function IU(e,t,n){let r=this;return i;function i(t){return t!==87&&t!==119||!UU.call(r,r.previous)||qU(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkWww`),e.check(wU,e.attempt(TU,e.attempt(EU,a),n),n)(t))}function a(n){return e.exit(`literalAutolinkWww`),e.exit(`literalAutolink`),t(n)}}function LU(e,t,n){let r=this,i=``,a=!1;return o;function o(t){return(t===72||t===104)&&WU.call(r,r.previous)&&!qU(r.events)?(e.enter(`literalAutolink`),e.enter(`literalAutolinkHttp`),i+=String.fromCodePoint(t),e.consume(t),s):n(t)}function s(t){if(wI(t)&&i.length<5)return i+=String.fromCodePoint(t),e.consume(t),s;if(t===58){let n=i.toLowerCase();if(n===`http`||n===`https`)return e.consume(t),c}return n(t)}function c(t){return t===47?(e.consume(t),a?l:(a=!0,c)):n(t)}function l(t){return t===null||DI(t)||MI(t)||FI(t)||PI(t)?n(t):e.attempt(TU,e.attempt(EU,u),n)(t)}function u(n){return e.exit(`literalAutolinkHttp`),e.exit(`literalAutolink`),t(n)}}function RU(e,t,n){let r=0;return i;function i(t){return(t===87||t===119)&&r<3?(r++,e.consume(t),i):t===46&&r===3?(e.consume(t),a):n(t)}function a(e){return e===null?n(e):t(e)}}function zU(e,t,n){let r,i,a;return o;function o(t){return t===46||t===95?e.check(DU,c,s)(t):t===null||MI(t)||FI(t)||t!==45&&PI(t)?c(t):(a=!0,e.consume(t),o)}function s(t){return t===95?r=!0:(i=r,r=void 0),e.consume(t),o}function c(e){return i||r||!a?n(e):t(e)}}function BU(e,t){let n=0,r=0;return i;function i(o){return o===40?(n++,e.consume(o),i):o===41&&r<n?a(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?e.check(DU,t,a)(o):o===null||MI(o)||FI(o)?t(o):(e.consume(o),i)}function a(t){return t===41&&r++,e.consume(t),i}}function VU(e,t,n){return r;function r(o){return o===33||o===34||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===63||o===95||o===126?(e.consume(o),r):o===38?(e.consume(o),a):o===93?(e.consume(o),i):o===60||o===null||MI(o)||FI(o)?t(o):n(o)}function i(e){return e===null||e===40||e===91||MI(e)||FI(e)?t(e):r(e)}function a(e){return wI(e)?o(e):n(e)}function o(t){return t===59?(e.consume(t),r):wI(t)?(e.consume(t),o):n(t)}}function HU(e,t,n){return r;function r(t){return e.consume(t),i}function i(e){return TI(e)?n(e):t(e)}}function UU(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||MI(e)}function WU(e){return!wI(e)}function GU(e){return!(e===47||KU(e))}function KU(e){return e===43||e===45||e===46||e===95||TI(e)}function qU(e){let t=e.length,n=!1;for(;t--;){let r=e[t][1];if((r.type===`labelLink`||r.type===`labelImage`)&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}var JU={tokenize:nW,partial:!0};function YU(){return{document:{91:{name:`gfmFootnoteDefinition`,tokenize:$U,continuation:{tokenize:eW},exit:tW}},text:{91:{name:`gfmFootnoteCall`,tokenize:QU},93:{name:`gfmPotentialFootnoteCall`,add:`after`,tokenize:XU,resolveTo:ZU}}}}function XU(e,t,n){let r=this,i=r.events.length,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),o;for(;i--;){let e=r.events[i][1];if(e.type===`labelImage`){o=e;break}if(e.type===`gfmFootnoteCall`||e.type===`labelLink`||e.type===`label`||e.type===`image`||e.type===`link`)break}return s;function s(i){if(!o||!o._balanced)return n(i);let s=CI(r.sliceSerialize({start:o.end,end:r.now()}));return s.codePointAt(0)!==94||!a.includes(s.slice(1))?n(i):(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(i),e.exit(`gfmFootnoteCallLabelMarker`),t(i))}}function ZU(e,t){let n=e.length;for(;n--;)if(e[n][1].type===`labelImage`&&e[n][0]===`enter`){e[n][1];break}e[n+1][1].type=`data`,e[n+3][1].type=`gfmFootnoteCallLabelMarker`;let r={type:`gfmFootnoteCall`,start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:`gfmFootnoteCallMarker`,start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;let a={type:`gfmFootnoteCallString`,start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:`chunkString`,contentType:`string`,start:Object.assign({},a.start),end:Object.assign({},a.end)},s=[e[n+1],e[n+2],[`enter`,r,t],e[n+3],e[n+4],[`enter`,i,t],[`exit`,i,t],[`enter`,a,t],[`enter`,o,t],[`exit`,o,t],[`exit`,a,t],e[e.length-2],e[e.length-1],[`exit`,r,t]];return e.splice(n,e.length-n+1,...s),e}function QU(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a=0,o;return s;function s(t){return e.enter(`gfmFootnoteCall`),e.enter(`gfmFootnoteCallLabelMarker`),e.consume(t),e.exit(`gfmFootnoteCallLabelMarker`),c}function c(t){return t===94?(e.enter(`gfmFootnoteCallMarker`),e.consume(t),e.exit(`gfmFootnoteCallMarker`),e.enter(`gfmFootnoteCallString`),e.enter(`chunkString`).contentType=`string`,l):n(t)}function l(s){if(a>999||s===93&&!o||s===null||s===91||MI(s))return n(s);if(s===93){e.exit(`chunkString`);let a=e.exit(`gfmFootnoteCallString`);return i.includes(CI(r.sliceSerialize(a)))?(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(s),e.exit(`gfmFootnoteCallLabelMarker`),e.exit(`gfmFootnoteCall`),t):n(s)}return MI(s)||(o=!0),a++,e.consume(s),s===92?u:l}function u(t){return t===91||t===92||t===93?(e.consume(t),a++,l):l(t)}}function $U(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a,o=0,s;return c;function c(t){return e.enter(`gfmFootnoteDefinition`)._container=!0,e.enter(`gfmFootnoteDefinitionLabel`),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),l}function l(t){return t===94?(e.enter(`gfmFootnoteDefinitionMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionMarker`),e.enter(`gfmFootnoteDefinitionLabelString`),e.enter(`chunkString`).contentType=`string`,u):n(t)}function u(t){if(o>999||t===93&&!s||t===null||t===91||MI(t))return n(t);if(t===93){e.exit(`chunkString`);let n=e.exit(`gfmFootnoteDefinitionLabelString`);return a=CI(r.sliceSerialize(n)),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),e.exit(`gfmFootnoteDefinitionLabel`),f}return MI(t)||(s=!0),o++,e.consume(t),t===92?d:u}function d(t){return t===91||t===92||t===93?(e.consume(t),o++,u):u(t)}function f(t){return t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),i.includes(a)||i.push(a),RI(e,p,`gfmFootnoteDefinitionWhitespace`)):n(t)}function p(e){return t(e)}}function eW(e,t,n){return e.check($I,t,e.attempt(JU,t,n))}function tW(e){e.exit(`gfmFootnoteDefinition`)}function nW(e,t,n){let r=this;return RI(e,i,`gfmFootnoteDefinitionIndent`,5);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`gfmFootnoteDefinitionIndent`&&i[2].sliceSerialize(i[1],!0).length===4?t(e):n(e)}}function rW(e){let t=(e||{}).singleTilde,n={name:`strikethrough`,tokenize:i,resolveAll:r};return t??=!0,{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}};function r(e,t){let n=-1;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`strikethroughSequenceTemporary`&&e[n][1]._close){let r=n;for(;r--;)if(e[r][0]===`exit`&&e[r][1].type===`strikethroughSequenceTemporary`&&e[r][1]._open&&e[n][1].end.offset-e[n][1].start.offset===e[r][1].end.offset-e[r][1].start.offset){e[n][1].type=`strikethroughSequence`,e[r][1].type=`strikethroughSequence`;let i={type:`strikethrough`,start:Object.assign({},e[r][1].start),end:Object.assign({},e[n][1].end)},a={type:`strikethroughText`,start:Object.assign({},e[r][1].end),end:Object.assign({},e[n][1].start)},o=[[`enter`,i,t],[`enter`,e[r][1],t],[`exit`,e[r][1],t],[`enter`,a,t]],s=t.parser.constructs.insideSpan.null;s&&gI(o,o.length,0,KI(s,e.slice(r+1,n),t)),gI(o,o.length,0,[[`exit`,a,t],[`enter`,e[n][1],t],[`exit`,e[n][1],t],[`exit`,i,t]]),gI(e,r-1,n-r+3,o),n=r+o.length-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`strikethroughSequenceTemporary`&&(e[n][1].type=`data`);return e}function i(e,n,r){let i=this.previous,a=this.events,o=0;return s;function s(t){return i===126&&a[a.length-1][1].type!==`characterEscape`?r(t):(e.enter(`strikethroughSequenceTemporary`),c(t))}function c(a){let s=GI(i);if(a===126)return o>1?r(a):(e.consume(a),o++,c);if(o<2&&!t)return r(a);let l=e.exit(`strikethroughSequenceTemporary`),u=GI(a);return l._open=!u||u===2&&!!s,l._close=!s||s===2&&!!u,n(a)}}}var iW=class{constructor(){this.map=[]}add(e,t,n){aW(this,e,t,n)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),this.map.length===0)return;let t=this.map.length,n=[];for(;t>0;)--t,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(let t of r)e.push(t);r=n.pop()}this.map.length=0}};function aW(e,t,n,r){let i=0;if(n!==0||r.length!==0){for(;i<e.map.length;){if(e.map[i][0]===t){e.map[i][1]+=n,e.map[i][2].push(...r);return}i+=1}e.map.push([t,n,r])}}function oW(e,t){let n=!1,r=[];for(;t<e.length;){let i=e[t];if(n){if(i[0]===`enter`)i[1].type===`tableContent`&&r.push(e[t+1][1].type===`tableDelimiterMarker`?`left`:`none`);else if(i[1].type===`tableContent`){if(e[t-1][1].type===`tableDelimiterMarker`){let e=r.length-1;r[e]=r[e]===`left`?`center`:`right`}}else if(i[1].type===`tableDelimiterRow`)break}else i[0]===`enter`&&i[1].type===`tableDelimiterRow`&&(n=!0);t+=1}return r}function sW(){return{flow:{null:{name:`table`,tokenize:cW,resolveAll:lW}}}}function cW(e,t,n){let r=this,i=0,a=0,o;return s;function s(e){let t=r.events.length-1;for(;t>-1;){let e=r.events[t][1].type;if(e===`lineEnding`||e===`linePrefix`)t--;else break}let i=t>-1?r.events[t][1].type:null,a=i===`tableHead`||i===`tableRow`?S:c;return a===S&&r.parser.lazy[r.now().line]?n(e):a(e)}function c(t){return e.enter(`tableHead`),e.enter(`tableRow`),l(t)}function l(e){return e===124?u(e):(o=!0,a+=1,u(e))}function u(t){return t===null?n(t):jI(t)?a>1?(a=0,r.interrupt=!0,e.exit(`tableRow`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),p):n(t):NI(t)?RI(e,u,`whitespace`)(t):(a+=1,o&&(o=!1,i+=1),t===124?(e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),o=!0,u):(e.enter(`data`),d(t)))}function d(t){return t===null||t===124||MI(t)?(e.exit(`data`),u(t)):(e.consume(t),t===92?f:d)}function f(t){return t===92||t===124?(e.consume(t),d):d(t)}function p(t){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(t):(e.enter(`tableDelimiterRow`),o=!1,NI(t)?RI(e,m,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):m(t))}function m(t){return t===45||t===58?g(t):t===124?(o=!0,e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),h):x(t)}function h(t){return NI(t)?RI(e,g,`whitespace`)(t):g(t)}function g(t){return t===58?(a+=1,o=!0,e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),_):t===45?(a+=1,_(t)):t===null||jI(t)?b(t):x(t)}function _(t){return t===45?(e.enter(`tableDelimiterFiller`),v(t)):x(t)}function v(t){return t===45?(e.consume(t),v):t===58?(o=!0,e.exit(`tableDelimiterFiller`),e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),y):(e.exit(`tableDelimiterFiller`),y(t))}function y(t){return NI(t)?RI(e,b,`whitespace`)(t):b(t)}function b(n){return n===124?m(n):n===null||jI(n)?!o||i!==a?x(n):(e.exit(`tableDelimiterRow`),e.exit(`tableHead`),t(n)):x(n)}function x(e){return n(e)}function S(t){return e.enter(`tableRow`),C(t)}function C(n){return n===124?(e.enter(`tableCellDivider`),e.consume(n),e.exit(`tableCellDivider`),C):n===null||jI(n)?(e.exit(`tableRow`),t(n)):NI(n)?RI(e,C,`whitespace`)(n):(e.enter(`data`),w(n))}function w(t){return t===null||t===124||MI(t)?(e.exit(`data`),C(t)):(e.consume(t),t===92?T:w)}function T(t){return t===92||t===124?(e.consume(t),w):w(t)}}function lW(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,c=0,l,u,d,f=new iW;for(;++n<e.length;){let p=e[n],m=p[1];p[0]===`enter`?m.type===`tableHead`?(s=!1,c!==0&&(dW(f,t,c,l,u),u=void 0,c=0),l={type:`table`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,l,t]])):m.type===`tableRow`||m.type===`tableDelimiterRow`?(r=!0,d=void 0,a=[0,0,0,0],o=[0,n+1,0,0],s&&(s=!1,u={type:`tableBody`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,u,t]])),i=m.type===`tableDelimiterRow`?2:u?3:1):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],d=uW(f,t,a,i,void 0,d),a=[0,0,0,0]),o[2]=n)):m.type===`tableCellDivider`&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],d=uW(f,t,a,i,void 0,d)),a=o,o=[a[1],n,0,0])):m.type===`tableHead`?(s=!0,c=n):m.type===`tableRow`||m.type===`tableDelimiterRow`?(c=n,a[1]===0?o[1]!==0&&(d=uW(f,t,o,i,n,d)):(o[0]=o[1],d=uW(f,t,a,i,n,d)),i=0):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)&&(o[3]=n)}for(c!==0&&dW(f,t,c,l,u),f.consume(t.events),n=-1;++n<t.events.length;){let e=t.events[n];e[0]===`enter`&&e[1].type===`table`&&(e[1]._align=oW(t.events,n))}return e}function uW(e,t,n,r,i,a){let o=r===1?`tableHeader`:r===2?`tableDelimiter`:`tableData`;n[0]!==0&&(a.end=Object.assign({},fW(t.events,n[0])),e.add(n[0],0,[[`exit`,a,t]]));let s=fW(t.events,n[1]);if(a={type:o,start:Object.assign({},s),end:Object.assign({},s)},e.add(n[1],0,[[`enter`,a,t]]),n[2]!==0){let i=fW(t.events,n[2]),a=fW(t.events,n[3]),o={type:`tableContent`,start:Object.assign({},i),end:Object.assign({},a)};if(e.add(n[2],0,[[`enter`,o,t]]),r!==2){let r=t.events[n[2]],i=t.events[n[3]];if(r[1].end=Object.assign({},i[1].end),r[1].type=`chunkText`,r[1].contentType=`text`,n[3]>n[2]+1){let t=n[2]+1,r=n[3]-n[2]-1;e.add(t,r,[])}}e.add(n[3]+1,0,[[`exit`,o,t]])}return i!==void 0&&(a.end=Object.assign({},fW(t.events,i)),e.add(i,0,[[`exit`,a,t]]),a=void 0),a}function dW(e,t,n,r,i){let a=[],o=fW(t.events,n);i&&(i.end=Object.assign({},o),a.push([`exit`,i,t])),r.end=Object.assign({},o),a.push([`exit`,r,t]),e.add(n+1,0,a)}function fW(e,t){let n=e[t],r=n[0]===`enter`?`start`:`end`;return n[1][r]}var pW={name:`tasklistCheck`,tokenize:hW};function mW(){return{text:{91:pW}}}function hW(e,t,n){let r=this;return i;function i(t){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(t):(e.enter(`taskListCheck`),e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),a)}function a(t){return MI(t)?(e.enter(`taskListCheckValueUnchecked`),e.consume(t),e.exit(`taskListCheckValueUnchecked`),o):t===88||t===120?(e.enter(`taskListCheckValueChecked`),e.consume(t),e.exit(`taskListCheckValueChecked`),o):n(t)}function o(t){return t===93?(e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),e.exit(`taskListCheck`),s):n(t)}function s(r){return jI(r)?t(r):NI(r)?e.check({tokenize:gW},t,n)(r):n(r)}}function gW(e,t,n){return RI(e,r,`whitespace`);function r(e){return e===null?n(e):t(e)}}function _W(e){return yI([NU(),YU(),rW(e),sW(),mW()])}var vW={};function yW(e){let t=this,n=e||vW,r=t.data(),i=r.micromarkExtensions||=[],a=r.fromMarkdownExtensions||=[],o=r.toMarkdownExtensions||=[];i.push(_W(n)),a.push(SU()),o.push(CU(n))}var bW=cD(`kind`,[K({kind:hD(`allAffected`)}).strict(),K({kind:hD(`selected`),workKeys:G(W().min(1).max(200)).min(1).max(1e4)}).strict()]),xW=W().min(1).max(64),SW=K({baseRevisionId:xW,request:bW}).strict(),CW=K({baseRevisionId:xW,idempotencyKey:OE(),previewId:W().min(1).max(64),acknowledgeUnknownCosts:XE(),confirmedProvidedWorkKeys:G(W().min(1).max(200)).max(1e4)}).strict(),wW=K({stage:W(),low:KE().finite().nonnegative().nullable(),high:KE().finite().nonnegative().nullable(),detail:W()}),TW=K({currency:hD(`USD`),rows:G(wW),low:KE().finite().nonnegative(),high:KE().finite().nonnegative(),unknown:KE().int().nonnegative(),expectedWords:KE().finite().nonnegative(),catalogueDate:W().nullable(),assumptions:G(W())}),EW=K({revisionId:xW,admissionId:W().min(1).max(64),workIds:G(W().min(1).max(64)),replayed:XE()}),DW=K({id:W().min(1).max(64),projectId:W().min(1).max(64),baseRevisionId:xW,planFingerprint:W().min(1),selection:bW,changedInputs:G(K({path:W(),before:W().nullable(),after:W().nullable()})),work:G(K({key:W(),stage:q(VD),kind:q([`provider`,`local`,`provided`]),disposition:q([`reuse`,`generate`,`local`,`review`,`blocked`]),requestFingerprint:W(),fingerprint:W(),dependsOn:G(W()),reason:W(),inflight:XE(),pieceIds:G(W())})),retained:G(K({slot:W(),outputId:W(),assetId:W(),state:q([`ready`,`outdated`,`review`])})),providedReuseRequired:G(W()),costs:TW,wholeRequestNotice:W().nullable(),warnings:G(W()),review:K({inputChanges:G(K({label:W(),before:W().nullable(),after:W().nullable()})),requests:G(K({key:W(),label:W(),text:W().nullable(),settings:W().nullable()}))}).optional()}),OW=[`chapter`,`chunk`,`segment`,`image`,`prompt_written`,`article_written`],kW=[`pending`,`running`,`done`,`failed`];K({id:W(),stage_id:W(),kind:q(OW),idx:KE(),state:q(kW),payload:W().nullable()});var AW=[`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`],jW=[`copying`,`staged`],MW=K({segment:q([`body`,`intro`,`outro`]).optional(),subtitleOmissions:G(K({start:KE().finite().nonnegative(),text:W()})).optional(),subtitlesMode:q([`off`,`files`,`burn-in`]).optional(),promptName:W().optional(),prompt:W().optional(),index:KE().optional(),provider:W().optional(),model:W().optional(),voice:W().optional()}),NW=K({id:W(),projectId:W(),stageKind:q(VD),role:q(AW),path:W(),originalFilename:W().nullable(),bytes:KE().nonnegative(),durationMs:KE().nonnegative().nullable(),meta:MW,createdAt:W()});K({id:W(),stageKind:q(VD),path:W(),originalFilename:W(),bytes:KE().nonnegative(),state:q(jW),createdAt:W()});var PW=W().min(1).max(64).regex(/^[0-9A-Za-z_-]+$/),FW=W().min(1).max(256),IW=fD(FW,PW),LW=K({id:PW,text:W().trim().min(1).max(1e4),start:KE().finite().nonnegative(),end:KE().finite().positive()}).strict().refine(e=>e.end>e.start,{path:[`end`],message:`End must be after start.`}),RW=K({articleMarkdown:W().max(5e5).optional(),articleEdited:XE().default(!1),provided:K({research:PW.optional(),article:PW.optional(),audio:PW.optional(),thumbnail:PW.optional()}).strict(),imageOrder:G(PW).max(60),imageDefinitions:fD(PW,K({source:q([`generate`,`provide`]),assetId:PW.nullable(),prompt:W().max(5e5).nullable(),templateKey:W().min(1).max(256).nullable().optional()}).strict()),narrationOverrides:fD(FW,cD(`kind`,[K({kind:hD(`asset`),assetId:PW}).strict(),K({kind:hD(`text`),text:W().trim().min(1).max(5e5)}).strict()])),subtitleCues:K({audioFingerprint:W().min(1),cues:G(LW)}).strict().optional(),regenerationTokens:IW,promptTemplates:fD(W().min(1),W().max(5e5).nullable())}).strict(),zW=K({baseRevisionId:PW,idempotencyKey:PW,edit:K({config:iO.strict(),content:RW,regenerate:G(FW).optional(),uploads:G(K({stagedFileId:PW,destination:cD(`kind`,[K({kind:hD(`provided`),stage:q([`audio`,`thumbnail`])}).strict(),K({kind:hD(`image`),imageKey:PW}).strict(),K({kind:hD(`narration`),key:FW}).strict()])}).strict()).max(1e4).optional()}).strict()}).strict(),BW=K({baseRevisionId:PW,idempotencyKey:PW,targetRevisionId:PW}).strict(),VW=K({id:PW,projectId:PW,parentId:PW.nullable(),restoredFromId:PW.nullable(),config:iO,content:RW,fingerprints:fD(FW,W()),createdAt:W()}),HW=K({id:PW,stageId:PW,kind:q(OW),idx:KE().int(),state:q(kW),payload:W().nullable()}),UW=K({slot:W(),workKey:FW,assetId:PW,output:NW,fingerprint:W(),state:q([`ready`,`outdated`,`review`])}),WW=K({key:FW,stageKind:q(VD),piece:HW,assetId:PW.nullable(),fingerprint:W()}),GW={recordId:PW,publicationId:PW.nullable(),selected:XE(),available:XE()},KW=K({articleMarkdown:W().nullable(),revision:VW,outputs:G(UW.extend(GW)),pieces:G(WW.extend(GW)),current:XE()}),qW=K({id:PW,parentId:PW.nullable(),restoredFromId:PW.nullable(),title:W(),createdAt:W(),current:XE()}),JW=K({ok:hD(!0),view:KW,duplicate:XE()}),YW=K({ok:hD(!0),view:KW,created:XE()}),XW=K({title:W(),status:KE(),detail:W().optional(),reason:W().optional(),currentRevisionId:W().nullable().optional(),fields:G(K({field:W(),message:W()})).optional(),errors:G(K({path:W(),message:W()})).optional()});async function ZW(e,t){let n;try{n=await e.json()}catch{throw io(e,void 0)}if(e.ok)return{ok:!0,value:t.parse(n)};let r=XW.safeParse(n);if(!r.success)throw io(e,void 0);let i=r.data;if(![400,404,409].includes(e.status))throw io(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 QW(e,t,n,r,i){return ZW(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 $W(e,t){return QW(e,t,`/revisions/prepare`,YW,{})}function eG(e,t,n){return QW(e,t,`/revisions`,JW,zW.parse(n))}function tG(e,t,n){return QW(e,t,`/revisions/restore`,JW,BW.parse(n))}function nG(e,t){return QW(e,t,`/revisions`,K({revisions:G(qW)}))}function rG(e,t,n){return QW(e,t,`/revisions/${encodeURIComponent(n)}`,K({view:KW}))}function iG(e,t,n){return QW(e,t,`/rebuild/preview`,K({ok:hD(!0),value:DW}),SW.parse(n))}function aG(e,t,n){return QW(e,t,`/rebuild`,K({ok:hD(!0),value:EW}),CW.parse(n))}function oG(e,t,n,r){return`${e.origin}/files/${encodeURIComponent(t)}/revisions/${encodeURIComponent(n)}/${encodeURIComponent(r)}`}async function sG(e,t,n,r){let i=await e.fetch(`${e.origin}/api/projects/${encodeURIComponent(t)}/revisions/${encodeURIComponent(n)}/${encodeURIComponent(r)}/open-folder`,{method:`POST`});if(!i.ok){let e=await ZW(i,eD());if(!e.ok)throw Error(e.message)}}function cG(e,t,n){return oG(e,t,n,`images.zip`)}function lG({projectId:e,asset:t,folder:n=null}){let{api:r}=I(),[i,a]=(0,m.useState)(!1),[o,s]=(0,m.useState)();async function c(){a(!0),s(void 0);try{if(n!==null){await sG(r,e,n.revisionId,n.recordId);return}let i=await r.client.projects[`:id`][`open-folder`].$post({param:{id:e},json:{asset:t}});if(!i.ok)throw io(i,await ao(i))}catch(e){s(e instanceof Error?e.message:`Could not open the folder.`)}finally{a(!1)}}return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`button`,{type:`button`,disabled:i,onClick:()=>void c(),title:`Open the saved output folder on the machine running Slopify`,className:`inline-flex items-center gap-[5px] rounded-control text-small text-ink2 hover:text-ink disabled:opacity-50`,children:[(0,h.jsx)(nj,{"aria-hidden":`true`,className:`size-[14px] shrink-0`}),i?`Opening…`:`Open folder`]}),o!==void 0&&(0,h.jsx)(`span`,{role:`alert`,className:`basis-full text-small text-red`,children:o})]})}var uG=(0,m.createContext)(null);function dG({projectId:e,revisionId:t,children:n}){let{api:r}=I(),i=nt({queryKey:V.revision(e,t??``),enabled:t!==null,queryFn:async()=>{if(t===null)throw Error(`Choose a saved revision.`);let n=await rG(r,e,t);if(!n.ok)throw Error(n.message);let i=n.value.view;if(i.revision.id!==t||i.revision.projectId!==e)throw Error(`The file list belongs to another revision.`);return i}});return(0,h.jsxs)(uG,{value:{projectId:e,revisionId:t,view:i.data},children:[i.error===null?null:(0,h.jsx)(`p`,{role:`alert`,children:i.error.message}),n]})}function fG(e){let t=(0,m.useContext)(uG),{api:n}=I();if(e===void 0||t!==null&&t.projectId!==e.projectId)return;if(t===null||t.revisionId===null)return{url:vo(n,e.projectId,AP(e)),cacheKey:V.file(e.projectId,e.id),folder:null};let r=t.view?.outputs.find(t=>t.selected&&t.available&&t.output.id===e.id);return r===void 0?void 0:mG(n,t.projectId,t.revisionId,r)}function pG(e,t){let n=(0,m.useContext)(uG),{api:r}=I();if(n!==null&&n.projectId!==e)return;if(n===null||n.revisionId===null)return{url:vo(r,e,t),cacheKey:V.file(e,t),folder:null};let i=n.view?.outputs.find(e=>e.selected&&e.available&&(t===`images.zip`?e.output.role===`image`||e.output.role===`thumbnail`:AP(e.output)===t));if(i===void 0)return;let a=mG(r,e,n.revisionId,i);return t===`images.zip`?{...a,url:oG(r,e,n.revisionId,`images.zip`),cacheKey:V.revisionFile(e,n.revisionId,`images.zip`)}:a}function mG(e,t,n,r){return{url:oG(e,t,n,r.recordId),cacheKey:V.revisionFile(t,n,r.recordId),folder:{revisionId:n,recordId:r.recordId}}}function hG({children:e,className:t}){return(0,h.jsx)(`div`,{className:z(`flex min-w-0 flex-col gap-4 p-5`,t),children:e})}function gG({children:e}){return(0,h.jsx)(`div`,{className:`flex flex-wrap items-center gap-4 text-small`,children:e})}function _G({children:e}){return(0,h.jsx)(`span`,{className:`engraved text-ink3`,children:e})}var vG={h1:({children:e})=>(0,h.jsx)(bG,{size:`text-title`,children:e}),h2:({children:e})=>(0,h.jsx)(bG,{size:`text-row`,children:e}),h3:({children:e})=>(0,h.jsx)(bG,{size:`text-row`,children:e}),h4:({children:e})=>(0,h.jsx)(bG,{size:`text-row`,children:e}),h5:({children:e})=>(0,h.jsx)(bG,{size:`text-row`,children:e}),h6:({children:e})=>(0,h.jsx)(bG,{size:`text-row`,children:e}),p:({children:e})=>(0,h.jsx)(`p`,{className:`m-0`,children:e}),strong:({children:e})=>(0,h.jsx)(`strong`,{className:`font-semibold`,children:e}),ul:({children:e})=>(0,h.jsx)(`ul`,{className:`m-0 flex list-disc flex-col gap-1 pl-5`,children:e}),ol:({children:e})=>(0,h.jsx)(`ol`,{className:`m-0 flex list-decimal flex-col gap-1 pl-5`,children:e}),li:({children:e})=>(0,h.jsx)(`li`,{className:`m-0`,children:e}),a:({children:e,href:t})=>(0,h.jsx)(`a`,{href:t,className:`rounded-control text-run-text underline underline-offset-[3px]`,target:`_blank`,rel:`noreferrer`,children:e}),code:({children:e})=>(0,h.jsx)(`code`,{className:`rounded-control bg-panel2 px-[4px] py-[1px] font-sans text-small`,children:e}),pre:({children:e})=>(0,h.jsx)(`pre`,{className:`m-0 overflow-x-auto rounded-control bg-panel2 p-[10px] font-sans text-small`,children:e}),blockquote:({children:e})=>(0,h.jsx)(`blockquote`,{className:`m-0 flex flex-col gap-2 border-l-2 border-line2 pl-3 text-ink2`,children:e}),hr:()=>(0,h.jsx)(`hr`,{className:`my-2 border-line`}),table:({children:e})=>(0,h.jsx)(`table`,{className:`w-full border-collapse text-left text-small`,children:e}),th:({children:e})=>(0,h.jsx)(`th`,{className:`engraved border-b border-line py-[6px] pr-4 text-left text-ink3`,children:e}),td:({children:e})=>(0,h.jsx)(`td`,{className:`border-b border-line py-[6px] pr-4 align-top`,children:e})},yG={p:({children:e})=>(0,h.jsx)(h.Fragment,{children:e}),strong:({children:e})=>(0,h.jsx)(`strong`,{className:`font-semibold`,children:e}),a:({children:e})=>(0,h.jsx)(h.Fragment,{children:e})};function bG({size:e,children:t}){return(0,h.jsx)(`h3`,{className:z(`mt-2 font-bold tracking-[-0.01em]`,e),children:t})}function xG({markdown:e}){return(0,h.jsx)(`div`,{className:`flex max-w-[75ch] flex-col gap-2 text-pretty text-body text-ink`,children:(0,h.jsx)(hV,{remarkPlugins:[yW],components:vG,children:e})})}function SG({markdown:e}){return(0,h.jsx)(hV,{remarkPlugins:[yW],components:yG,children:e})}var CG=/^#{1,6}[ \t]+(.*?)[ \t]*#*[ \t]*(?:\r?\n|$)/;function wG(e){let t=e.replace(/^[\s]*\n/,``),n=CG.exec(t);return n===null?{title:void 0,body:e.trim()}:{title:n[1]??``,body:t.slice(n[0].length).trim()}}function TG({message:e,onDismiss:t}){return(0,h.jsxs)(`div`,{className:`flex items-center gap-3 rounded-control bg-red-tint px-[10px] py-[6px] text-small text-red`,children:[(0,h.jsx)(`span`,{role:`alert`,className:`min-w-0 break-words`,children:e}),(0,h.jsx)(`button`,{type:`button`,onClick:t,className:`ml-auto shrink-0 rounded-control px-2 text-ink2 hover:text-ink`,children:`Dismiss`})]})}function EG({projectId:e,asset:t,label:n=`Download`}){let r=pG(e,t);return r===void 0?null:(0,h.jsxs)(`span`,{className:`inline-flex flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,h.jsxs)(`a`,{href:r.url,download:!0,className:`inline-flex items-center gap-[5px] rounded-control text-small text-ink2 hover:text-ink`,children:[(0,h.jsx)(ej,{"aria-hidden":`true`,className:`size-[14px] shrink-0`}),n]}),(0,h.jsx)(lG,{projectId:e,asset:t,folder:r.folder})]})}function DG({output:e,label:t}){let n=fG(e);return n===void 0?null:(0,h.jsxs)(`span`,{className:`inline-flex flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,h.jsxs)(`a`,{href:n.url,download:!0,className:`inline-flex items-center gap-[5px] rounded-control text-small text-ink2 hover:text-ink`,children:[(0,h.jsx)(ej,{"aria-hidden":`true`,className:`size-[14px] shrink-0`}),t??`Download`]}),(0,h.jsx)(lG,{projectId:e.projectId,asset:AP(e),folder:n.folder})]})}function OG(e){let{api:t}=I(),n=fG(e);return nt({queryKey:n?.cacheKey??V.revisionFile(``,``,`unavailable`),queryFn:async()=>n===void 0?``:to(await t.fetch(n.url)),enabled:n!==void 0,staleTime:1/0})}function kG({output:e,as:t=`prose`}){let n=OG(e);return n.error===null?n.data===void 0?(0,h.jsx)(`span`,{className:`h-4 w-[40ch] max-w-full rounded-control bg-panel2`}):t===`prose`?(0,h.jsx)(xG,{markdown:n.data}):(0,h.jsx)(`pre`,{className:`max-w-[75ch] overflow-x-auto whitespace-pre-wrap font-sans text-small text-ink2`,children:n.data}):(0,h.jsx)(`p`,{className:`text-body text-red`,children:n.error.message})}function AG({output:e}){let[t,n]=(0,m.useState)(!1);return e===void 0?null:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`button`,{type:`button`,"aria-expanded":t,onClick:()=>{n(!t)},className:`rounded-control text-small text-ink2 underline underline-offset-[3px] hover:text-ink`,children:t?`Hide instructions`:`Show instructions`}),t?(0,h.jsx)(kG,{output:e,as:`plain`}):null]})}function jG({stage:e,project:t,outputs:n,actions:r,busy:i}){let a=EP(t.id),o=bP(n,e),s=xP(o,`article_md`)??xP(o,`article_txt`),c=xP(o,`sources`),l=xP(o,`glossary`),u=OG(s),d=nt({queryKey:DP(t.id,a),queryFn:()=>[],enabled:!1}).data?.some(e=>e.stage===`article`)===!0,f=nt({queryKey:V.article(t.id,a),queryFn:()=>``,enabled:!1}),p=u.data??``,m=wG(e.state===`running`?f.data??``:p),g=m.title??t.title;return(0,h.jsxs)(hG,{children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-[14px] text-small text-ink2`,children:[(0,h.jsx)(`span`,{className:`text-row font-semibold text-ink`,children:(0,h.jsx)(SG,{markdown:g})}),c===void 0?null:(0,h.jsx)(DG,{output:c,label:`Sources`}),l===void 0?null:(0,h.jsx)(DG,{output:l,label:`Glossary`})]}),(0,h.jsx)(`p`,{className:`text-small text-ink2`,children:`Use Edit project to save changes, then review affected outputs before rebuilding.`}),(0,h.jsxs)(gG,{children:[(0,h.jsx)(TP,{action:{kind:`rerun`,stage:e.kind},run:()=>r.run({kind:`rerun`,stage:e.kind}),disabled:i,pending:r.pending,children:`Re-run`}),(0,h.jsx)(AG,{output:xP(o,`instructions`)}),s===void 0?null:(0,h.jsx)(DG,{output:s})]}),u.error===null?null:(0,h.jsx)(`p`,{className:`text-body text-red`,children:u.error.message}),(0,h.jsx)(`section`,{"aria-label":`Article content`,tabIndex:0,className:`max-h-[min(58vh,640px)] min-h-48 overflow-auto pr-3`,children:e.state===`running`&&d?(0,h.jsx)(kP,{projectId:t.id,stage:`article`}):(0,h.jsx)(xG,{markdown:m.body})})]})}function MG({projectId:e,revisionId:t}){let n=EP(e),r=t===void 0?n:t,{api:i}=I(),a=nt({queryKey:V.audioPreview(e,r),queryFn:async()=>eo(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 rounded-control border border-line2 bg-panel2 p-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-ink2`,children:`Play any part. Each preview starts from its beginning.`})]}),a.error===null?null:(0,h.jsx)(`p`,{className:`text-small text-ink2`,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-ink2`,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)(NG,{preview:t,url:`${i.origin}/api/projects/${encodeURIComponent(e)}/audio-preview/${t.id}`},t.id))})]})}function NG({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-ink2`,children:a})]}),i&&!n?(0,h.jsx)(PG,{label:e.label,url:t,onError:()=>r(!0)}):(0,h.jsx)(`p`,{className:`text-ink2`,children:e.state===`streaming`&&!n?`Waiting for audio…`:`This preview has stopped. The finished narration will be available when generation completes.`})]})}function PG({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)(`audio`,{ref:r,controls:!0,preload:`none`,"aria-label":`Live ${e} narration`,src:t,onError:n,className:`h-9 w-full max-w-[620px]`})}function FG({outputs:e}){let t=e.filter(e=>e.role===`narration_txt`||e.role===`tts_script`);return t.length===0?null:(0,h.jsxs)(`section`,{"aria-label":`Narration text downloads`,className:`space-y-3`,children:[[`intro`,`body`,`outro`].map(e=>{let n=t.filter(t=>t.meta.segment===e);if(n.length===0)return null;let r=e===`body`?`Body`:e===`intro`?`Intro`:`Outro`;return(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 text-small`,children:[(0,h.jsx)(_G,{children:r}),n.map(e=>(0,h.jsx)(DG,{output:e,label:`${r} ${e.role===`narration_txt`?`Clean Narration`:`TTS Script`}`},e.id))]},e)}),(0,h.jsx)(`p`,{className:`text-small text-ink3`,children:`Clean Narration is the spoken text used for captions. TTS Script includes delivery cues; blank lines separate requests. Uploaded audio has no TTS request.`})]})}var IG=[{role:`audio_intro`,name:`Intro`},{role:`audio_body`,name:`Body`},{role:`audio_outro`,name:`Outro`}];function LG({stage:e,project:t,outputs:n,actions:r,busy:i}){let{api:a}=I(),o=nt(yy(a)),s=bP(n,e),c=IG.flatMap(e=>{let t=xP(s,e.role);return t===void 0?[]:[{...e,output:t}]}),l=c.find(e=>e.output.meta.voice!==void 0)?.output.meta,u=c.length>0?l?.voice:t.config.audio?.voice,d=c.length>0?l?.provider:t.config.audio?.provider,f=o.data?.voices.find(e=>e.voiceId===u&&e.provider===d)?.name??u;return(0,h.jsxs)(hG,{children:[e.state===`running`?(0,h.jsx)(MG,{projectId:t.id}):null,c.length===0?(0,h.jsx)(`p`,{className:`text-small text-ink2`,children:`No narration has landed yet.`}):c.map(e=>(0,h.jsx)(RG,{name:e.name,output:e.output},e.role)),(0,h.jsx)(FG,{outputs:s}),(0,h.jsxs)(gG,{children:[(0,h.jsx)(TP,{action:{kind:`rerun`,stage:e.kind},run:()=>{r.run({kind:`rerun`,stage:e.kind})},disabled:i,pending:r.pending,children:`Re-run`}),f===void 0?null:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(_G,{children:`Voice`}),(0,h.jsx)(`span`,{className:`text-small text-ink`,children:f})]}),(0,h.jsx)(`span`,{className:`text-small text-ink2`,children:`Chunking: ${zG(t.config.chunking)}`})]})]})}function RG({name:e,output:t}){let n=fG(t),r=Xk(t.durationMs??void 0);return(0,h.jsxs)(`div`,{className:`grid grid-cols-[60px_minmax(0,1fr)_auto] items-center gap-3 text-small`,children:[(0,h.jsx)(_G,{children:e}),(0,h.jsx)(`audio`,{controls:!0,preload:`metadata`,"aria-label":`${e} narration`,src:n?.url,className:`h-8 w-full max-w-[520px]`}),(0,h.jsxs)(`span`,{className:`flex items-center gap-4`,children:[r===void 0?null:(0,h.jsx)(`span`,{className:`text-ink2 tabular-nums`,children:r}),(0,h.jsx)(DG,{output:t})]})]})}function zG(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 BG(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(VG)}]})}function VG(e,t){return(e.meta.index??0)-(t.meta.index??0)}function HG(e){return e===`9:16`?`aspect-[9/16]`:`aspect-video`}function UG({stage:e,project:t,outputs:n,actions:r,busy:i}){let a=BG(bP(n,e),t.config.imagePrompts?.map(e=>e.name)??[]);return(0,h.jsxs)(hG,{children:[(0,h.jsxs)(gG,{children:[(0,h.jsx)(TP,{action:{kind:`rerun`,stage:e.kind},run:()=>{r.run({kind:`rerun`,stage:e.kind})},disabled:i,pending:r.pending,children:`Re-run stage`}),(0,h.jsx)(EG,{projectId:t.id,asset:`images.zip`,label:`Download all`})]}),a.length===0?(0,h.jsx)(`p`,{className:`text-small text-ink2`,children:`No images have landed yet.`}):null,a.map(e=>(0,h.jsxs)(`section`,{className:`flex flex-col gap-[10px]`,children:[(0,h.jsx)(_G,{children:`${e.name} × ${String(e.images.length)}`}),(0,h.jsx)(`div`,{className:`grid grid-cols-3 gap-2 min-[900px]:grid-cols-6`,children:e.images.map(e=>(0,h.jsx)(WG,{image:e,format:t.format,actions:r,busy:i},e.id))})]},e.name))]})}function WG({image:e,format:t,actions:n,busy:r}){let i=fG(e),a=e.meta.index===void 0?``:` ${String(e.meta.index)}`;return(0,h.jsxs)(`figure`,{className:`group relative m-0 overflow-hidden rounded-control border border-line bg-panel2`,children:[(0,h.jsx)(`img`,{src:i?.url,alt:e.meta.prompt??`Slideshow image${a}`,className:z(`block w-full object-cover animate-tick-in motion-reduce:animate-none`,HG(t))}),(0,h.jsxs)(`figcaption`,{className:`absolute inset-x-0 bottom-0 flex flex-wrap items-center justify-between gap-1 bg-panel/90 p-1 opacity-0 transition-opacity duration-150 group-hover:opacity-100 focus-within:opacity-100 motion-reduce:transition-none`,children:[(0,h.jsx)(DG,{output:e}),(0,h.jsx)(TP,{action:{kind:`regenerate-image`,outputId:e.id},run:()=>{n.run({kind:`regenerate-image`,outputId:e.id})},disabled:r,pending:n.pending,variant:`ghost`,children:`Regenerate`}),(0,h.jsx)(TP,{action:{kind:`delete-image`,outputId:e.id},run:()=>{n.run({kind:`delete-image`,outputId:e.id})},disabled:r,pending:n.pending,variant:`ghost`,children:`Delete`})]})]})}function GG({stage:e,outputs:t,actions:n,busy:r}){let i=bP(t,e),a=xP(i,`notes`);return e.state===`running`&&a===void 0?null:(0,h.jsxs)(hG,{children:[(0,h.jsxs)(gG,{children:[(0,h.jsx)(TP,{action:{kind:`rerun`,stage:e.kind},run:()=>{n.run({kind:`rerun`,stage:e.kind})},disabled:r,pending:n.pending,children:`Re-run`}),(0,h.jsx)(AG,{output:xP(i,`instructions`)}),a===void 0?null:(0,h.jsx)(DG,{output:a})]}),(0,h.jsx)(`section`,{"aria-label":`Research notes`,tabIndex:0,className:`max-h-[min(58vh,640px)] min-h-48 overflow-auto pr-3`,children:a===void 0?(0,h.jsx)(`p`,{className:`text-small text-ink2`,children:e.state===`running`?`Research notes will be saved when the writing above finishes.`:`No notes were written.`}):(0,h.jsx)(kG,{output:a})})]})}function KG({stage:e,project:t,outputs:n,actions:r,busy:i}){let a=bP(n,e),o=xP(a,`thumbnail`),s=fG(o),c=t.config.sources.thumbnail===`prompt_by_llm`;return(0,h.jsxs)(hG,{className:`grid grid-cols-1 items-start gap-4 min-[900px]:grid-cols-[200px_minmax(0,1fr)]`,children:[o===void 0?(0,h.jsx)(`p`,{className:`text-small text-ink2`,children:`No thumbnail has landed yet.`}):(0,h.jsx)(`img`,{src:s?.url,alt:o.meta.prompt??`Thumbnail`,className:z(`block w-full rounded-control border border-line bg-panel2 object-cover`,HG(t.format))}),(0,h.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,h.jsx)(_G,{children:c?`Prompt written by the LLM`:`Prompt`}),o?.meta.prompt===void 0?(0,h.jsx)(`p`,{className:`text-small text-ink2`,children:`This run stored no prompt for the thumbnail.`}):(0,h.jsx)(`p`,{className:`max-w-[75ch] rounded-control border border-line2 bg-panel2 px-[10px] py-2 text-pretty text-small text-ink`,children:o.meta.prompt}),(0,h.jsxs)(gG,{children:[(0,h.jsx)(TP,{action:{kind:`rerun`,stage:e.kind},run:()=>{r.run({kind:`rerun`,stage:e.kind})},disabled:i,pending:r.pending,children:`Regenerate`}),(0,h.jsx)(AG,{output:xP(a,`instructions`)}),o===void 0?null:(0,h.jsx)(DG,{output:o})]})]})]})}function qG({stage:e,project:t,outputs:n,actions:r,busy:i,subtitleControls:a}){let o=t.config.sources.video===`off`&&t.config.sources.audio!==`off`,s=xP(bP(n,e),o?`audio_export`:`video`),c=bP(n,e),l=xP(c,`subtitles_srt`),u=xP(c,`subtitles_vtt`),d=fG(s),f=fG(u),p=s?.meta.subtitlesMode??t.config.subtitles?.mode,m=e.state===`running`,g=Zk(e.progressCurrent??0,e.progressTotal??0);return t.config.sources.video===`off`&&!o?(0,h.jsx)(hG,{children:a}):(0,h.jsxs)(hG,{children:[m?(0,h.jsx)(`p`,{className:`text-small text-run-text`,children:Hk(e,t.config)?`Preparing subtitles · ${String(Zk(e.progressCurrent??0,35))}%`:o?`Exporting combined audio`:e.progressTotal===null?`Re-rendering`:`Re-rendering · ${String(g)}%`}):null,s===void 0?(0,h.jsx)(`p`,{className:`text-small text-ink2`,children:o?`No combined audio export has landed yet.`:`No render has landed yet.`}):o?(0,h.jsx)(`audio`,{controls:!0,preload:`metadata`,"aria-label":`Combined narration`,src:d?.url,className:`h-9 w-full max-w-[720px]`},s.id):(0,h.jsx)(`video`,{controls:!0,preload:`metadata`,src:d?.url,"aria-label":`Generated video`,className:z(`mx-auto block max-h-[min(58vh,560px)] w-auto max-w-full rounded-control bg-screen`,t.format===`9:16`?`aspect-[9/16]`:`aspect-video`),children:p===`files`&&u&&f?(0,h.jsx)(`track`,{kind:`captions`,srcLang:`en`,label:`English`,default:!0,src:f?.url},u.id):null},s.id),(0,h.jsxs)(gG,{children:[s===void 0?null:(0,h.jsx)(DG,{output:s,label:o?`Download .wav`:`Download .mp4`}),e.state===`pending`||e.state===`skipped`?null:(0,h.jsx)(TP,{action:{kind:`rerun`,stage:e.kind},run:()=>{r.run({kind:`rerun`,stage:e.kind})},disabled:i||![`done`,`failed`,`canceled`].includes(e.state),pending:r.pending,children:o?`Re-export`:`Re-render`}),(0,h.jsx)(`span`,{className:`text-small text-ink2`,children:[Xk(s?.durationMs??void 0),o?`WAV · stereo · 48 kHz`:t.format].filter(e=>e!==void 0).join(` · `)})]}),s?.meta.subtitleOmissions?.length?(0,h.jsxs)(`details`,{className:`rounded-control border border-line p-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:`mt-2 text-ink2`,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:`mt-2 space-y-2`,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,l||u?(0,h.jsxs)(gG,{children:[l?(0,h.jsx)(DG,{output:l,label:`Download .srt`}):null,u?(0,h.jsx)(DG,{output:u,label:`Download .vtt`}):null]}):null,a?(0,h.jsxs)(`details`,{className:`mt-2 rounded-control border border-line px-4 py-3`,children:[(0,h.jsx)(`summary`,{className:`cursor-pointer text-small font-semibold`,children:`Subtitles & fonts`}),a]}):null]})}function JG(e){switch(e.stage.kind){case`research`:return(0,h.jsx)(GG,{...e});case`article`:return(0,h.jsx)(jG,{...e});case`audio`:return(0,h.jsx)(LG,{...e});case`images`:return(0,h.jsx)(UG,{...e});case`thumbnail`:return(0,h.jsx)(KG,{...e});case`video`:return(0,h.jsx)(qG,{...e})}}var YG=K({revisionId:W(),checkpoints:G(JD.unwrap().extend({currentFingerprint:W().regex(/^[a-f0-9]{64}$/),dependents:G(q(VD)),workKeys:G(W())}))}),XG=K({revisionId:W().min(1).max(64).regex(/^[0-9A-Za-z_-]+$/),stages:G(qD).max(3).refine(e=>new Set(e).size===e.length).readonly()}).strict(),ZG=K({title:W(),status:KE(),detail:W().optional(),reason:q([`duplicate`,`not-found`,`conflict`,`invalid-input`]).optional()}),QG=YD.unwrap().omit({projectId:!0,checkpointId:!0,approvedAt:!0}),$G=e=>[`checkpoints`,e],eK=(e,t)=>[...$G(e),t];async function tK(e,t){let n=await e.json();if(e.ok)return{ok:!0,value:t.parse(n)};let r=ZG.safeParse(n);if(!r.success)throw io(e,void 0);if(![400,404,409].includes(e.status))throw Error(r.data.detail??r.data.title);return{ok:!1,reason:r.data.reason??`invalid-input`,message:r.data.detail??r.data.title}}async function nK(e,t){return tK(await e.fetch(`${e.origin}/api/projects/${encodeURIComponent(t)}/checkpoints`),YG)}async function rK(e,t,n,r){return tK(await e.fetch(`${e.origin}/api/projects/${encodeURIComponent(t)}/checkpoints/${encodeURIComponent(n)}/approve`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(QG.parse(r))}),K({checkpoint:JD,replayed:XE()}))}async function iK(e,t,n){return tK(await e.fetch(`${e.origin}/api/projects/${encodeURIComponent(t)}/checkpoints`,{method:`PATCH`,headers:{"content-type":`application/json`},body:JSON.stringify(XG.parse(n))}),YG)}var aK=[{stage:`audio`,name:`Audio`},{stage:`images`,name:`Images`},{stage:`video`,name:`Video / export`}];function oK({projectId:e,revisionId:t,gates:n,stages:r,reload:i,saved:a}){let{api:o}=I(),[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=aK.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. Reload before saving. (conflict)`}: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 iK(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 revision changed. Reload checkpoint choices.`}):f({kind:`refused`,message:`${n.message} (${n.reason})`})}catch(e){g.current&&f({kind:`transport`,message:`${e instanceof Error?e.message:`Checkpoint response unavailable.`} Reload checkpoint choices before making another change.`})}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`,children:[(0,h.jsx)(`legend`,{children:`Checkpoint choices`}),(0,h.jsx)(`p`,{children:`Change checkpoints before a step starts. Removing one lets its already-admitted work continue when ready; project pause still applies.`}),aK.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)(B,{type:`button`,disabled:!S||l||C,onClick:()=>void T(),children:l?`Saving…`:`Save checkpoints`}),C?(0,h.jsx)(B,{type:`button`,disabled:l,onClick:()=>void E(),children:`Reload checkpoint choices`}):null]})}var sK=e=>e.charAt(0).toUpperCase()+e.slice(1);function cK(e){return e.revisionId===null?null:(0,h.jsx)(lK,{...e,revisionId:e.revisionId},`${e.projectId}:${e.revisionId}`)}function lK({projectId:e,revisionId:t,paused:n,stages:r}){let{api:i}=I(),a=_(),o=nt({queryKey:eK(e,t),queryFn:()=>nK(i,e),retry:!1}),s=o.data,c=async()=>{let e=await o.refetch();return!e.isError&&e.data?.ok===!0&&e.data.value.revisionId===t?e.data.value:void 0},l=async()=>{let e=await o.refetch();return!e.isError&&e.data?.ok===!0&&e.data.value.revisionId===t};return o.isPending?null:o.error||s?.ok===!1?(0,h.jsxs)(`section`,{"aria-label":`Review checkpoints`,children:[(0,h.jsx)(`p`,{role:`alert`,children:o.error?.message??(s?.ok===!1?s.message:`Checkpoint status unavailable.`)}),(0,h.jsx)(B,{type:`button`,onClick:()=>void l(),children:`Reload checkpoints`})]}):s?.ok?s.value.revisionId===t?(0,h.jsxs)(`section`,{"aria-label":`Review checkpoints`,className:`space-y-3 rounded-panel border border-line bg-panel p-4`,children:[(0,h.jsx)(`h2`,{children:`Review checkpoints`}),n?(0,h.jsx)(`p`,{children:`Project is paused. Resume it before approving held work.`}):null,(0,h.jsx)(oK,{projectId:e,revisionId:t,gates:s.value.checkpoints,stages:r,reload:c,saved:n=>{a.setQueryData(eK(e,t),{ok:!0,value:n}),a.invalidateQueries({queryKey:V.project(e)}),a.invalidateQueries({queryKey:V.projects})}}),s.value.checkpoints.map(i=>(0,h.jsx)(uK,{gate:i,disabled:n||i.projectId!==e||i.revisionId!==t||r.some(e=>e.kind===i.stage&&[`running`,`canceled`].includes(e.state)),reload:l},`${i.checkpointId}:${i.fingerprint}`))]}):(0,h.jsx)(`section`,{"aria-label":`Review checkpoints`,children:(0,h.jsx)(`p`,{role:`alert`,children:`Checkpoint status belongs to another revision. Reload the project before approving.`})}):null}function uK({gate:e,disabled:t,reload:n}){let{api:r}=I(),i=_(),a=(0,m.useRef)(null),o=(0,m.useRef)(!1),s=(0,m.useRef)(!0),c=(0,m.useRef)(null),[l,u]=(0,m.useState)(!1),[d,f]=(0,m.useState)(null);(0,m.useEffect)(()=>(s.current=!0,()=>{s.current=!1}),[]),(0,m.useEffect)(()=>{d!==null&&c.current?.focus()},[d]);let p=[`configured`,`pending-review`,`held`].includes(e.state)&&e.fingerprint===e.currentFingerprint;async function g(){if(!(o.current||t||!p||d?.kind===`refused`||d?.kind===`success`)){o.current=!0,u(!0),a.current??={revisionId:e.revisionId,fingerprint:e.fingerprint,idempotencyKey:crypto.randomUUID()};try{let t=await rK(r,e.projectId,e.checkpointId,a.current);a.current=null,s.current&&f(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} (${t.reason})`}),i.invalidateQueries({queryKey:$G(e.projectId)}),i.invalidateQueries({queryKey:V.project(e.projectId)}),i.invalidateQueries({queryKey:V.projects})}catch(e){s.current&&f({kind:`transport`,message:`${e instanceof Error?e.message:`Approval response unavailable.`} Retry to check the same approval request.`})}finally{o.current=!1,s.current&&u(!1)}}}return(0,h.jsxs)(`div`,{className:`space-y-2 rounded-control border border-line p-3`,children:[(0,h.jsxs)(`h3`,{children:[sK(e.stage),` checkpoint`]}),(0,h.jsx)(`p`,{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.`:p?`${sK(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`,{children:[`Reviewed revision: `,e.revisionId]}),e.dependents.length?(0,h.jsx)(`ul`,{"aria-label":`Dependent work`,children:e.dependents.map(e=>(0,h.jsx)(`li`,{children:sK(e)},e))}):(0,h.jsx)(`p`,{children:`No dependent stages.`}),d?(0,h.jsx)(`p`,{ref:c,tabIndex:-1,role:d.kind===`success`?`status`:`alert`,children:d.message}):null,p?(0,h.jsx)(B,{type:`button`,disabled:t||l||d?.kind===`refused`||d?.kind===`success`,onClick:()=>void g(),children:l?`Approving…`:d?.kind===`transport`?`Retry approval`:`Approve ${sK(e.stage)} checkpoint`}):null,d?.kind===`refused`?(0,h.jsx)(B,{type:`button`,onClick:async()=>{await n()&&f(null)},children:`Reload checkpoints`}):null]})}var dK={pending:`text-ink3`,running:`text-run-text`,done:`text-done`,failed:`text-red`,canceled:`text-amber`,paused:`text-amber`,provided:`text-ink2`,skipped:`text-ink3`};function fK({state:e,announce:t,className:n}){return(0,h.jsxs)(`span`,{className:z(`inline-flex items-center`,n),children:[(0,h.jsx)(`span`,{"data-state":e,className:z(`engraved font-bold`,dK[e]),children:e}),t===void 0?null:(0,h.jsx)(`span`,{className:`sr-only`,role:`status`,"aria-live":`polite`,children:`${t}: ${e}`})]})}var pK={pending:`bg-lamp-off shadow-[inset_0_0_0_1px_var(--color-lamp-ring)]`,running:`bg-lamp-run shadow-[0_0_0_3px_var(--color-lamp-halo)] animate-lamp-pulse motion-reduce:animate-none`,done:`bg-done`,failed:`bg-red`,canceled:`bg-amber`,paused:`bg-amber`,provided:`bg-lamp-off shadow-[inset_0_0_0_1px_var(--color-lamp-ring)]`,skipped:`bg-lamp-off shadow-[inset_0_0_0_1px_var(--color-lamp-ring)]`};function mK({state:e,className:t}){return(0,h.jsx)(`span`,{"aria-hidden":`true`,"data-lamp":e,className:z(`size-[10px] shrink-0 rounded-full`,pK[e],t)})}function hK({project:e,prompts:t,actions:n,inFlight:r,primaryOutput:i,children:a}){let o=e.status===`running`;return(0,h.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-5 py-2`,children:[(0,h.jsxs)(`div`,{className:`w-full min-w-0 sm:min-w-[220px] sm:flex-1`,children:[(0,h.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,h.jsx)(mK,{state:e.status}),(0,h.jsx)(fK,{state:e.status,announce:`Project`})]}),(0,h.jsx)(`h1`,{className:`break-words text-[28px] font-bold leading-tight`,children:e.title}),(0,h.jsx)(`p`,{className:`mt-2 text-small text-ink2`,children:gK(e,t)})]}),(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[a,i?(0,h.jsx)(`span`,{className:`rounded-control border border-accent bg-accent px-4 py-2 [&_a]:font-semibold [&_a]:text-accent-ink`,children:(0,h.jsx)(DG,{output:i,label:i.role===`video`?`Download video`:i.role===`audio_export`?`Download audio`:`Download article`})}):null,o||e.status===`pending`?(0,h.jsx)(B,{disabled:n.pending,onClick:()=>n.run({kind:`pause`}),children:`Pause`}):null,e.status===`paused`||e.status===`failed`?(0,h.jsx)(B,{disabled:n.pending||r,onClick:()=>n.run({kind:`resume`}),children:`Resume`}):null,o?(0,h.jsx)(TP,{action:{kind:`cancel`},run:()=>{n.run({kind:`cancel`})},pending:n.pending,children:`Cancel run`}):null]})]})}function gK(e,t){let n=e.config.articlePrompt,r=t===void 0||t.some(e=>e.name===n);return[n===void 0||n===``?void 0:r?n:`${n} (deleted)`,e.format,`started ${jc(e.createdAt)}`].filter(e=>e!==void 0).join(` · `)}var _K=e=>e.state===`done`||e.state===`provided`;function vK(e){let t=e.filter(e=>e.state!==`skipped`),n=t.length,r=t.filter(_K).length,i=t.reduce((e,t)=>_K(t)?e+1:t.progressTotal===null||t.progressTotal<=0?e:e+Math.min(.99,Math.max(0,(t.progressCurrent??0)/t.progressTotal)),0);return{completed:r,total:n,percent:n===0?0:Math.min(r===n?100:99,Math.round(i/n*100))}}function yK(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`&&_K(e));if(n)return n.kind;let r=e.find(e=>e.state===`pending`);return r?r.kind:e.find(e=>e.kind===`article`&&_K(e))?.kind??e.find(e=>e.state!==`skipped`)?.kind??`article`}function bK({stages:e,project:t}){let n=vK(e);return(0,h.jsxs)(`div`,{className:`rounded-panel border border-line bg-panel px-5 py-4`,children:[(0,h.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center justify-between gap-2`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,h.jsx)(`span`,{className:`text-small font-semibold`,children:`Overall progress`}),(0,h.jsxs)(`span`,{className:`text-small text-ink2`,children:[n.completed,` of `,n.total,` stages finished`]})]}),(0,h.jsxs)(`span`,{className:`text-small font-semibold tabular-nums`,children:[n.percent,`%`]})]}),(0,h.jsx)(`div`,{role:`progressbar`,"aria-label":`Overall progress`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":n.percent,"aria-valuetext":`${n.percent} percent; ${n.completed} of ${n.total} stages finished`,className:`h-2 overflow-hidden rounded-control bg-panel2`,children:(0,h.jsx)(`div`,{className:z(`h-full origin-left bg-accent transition-transform duration-200 motion-reduce:transition-none`,t.status===`failed`&&`bg-red`),style:{transform:`scaleX(${n.percent/100})`}})}),(0,h.jsx)(`p`,{className:`mt-2 text-label text-ink3`,children:`Combines finished stages with progress reported by active stages.`})]})}function xK({stages:e,project:t,outputs:n,selected:r,onSelect:i}){return(0,h.jsxs)(`nav`,{"aria-label":`Project stages`,className:`h-fit rounded-panel border border-line bg-panel lg:sticky lg:top-6`,children:[(0,h.jsx)(`div`,{className:`border-b border-line px-4 py-3`,children:(0,h.jsx)(`h2`,{className:`engraved text-ink3`,children:`Stages`})}),(0,h.jsx)(`div`,{className:`grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-1`,children:e.map(e=>{let a=e.kind===r,o=Vk(e.kind,t.config),s=e.state===`done`||e.state===`provided`;return(0,h.jsxs)(`button`,{type:`button`,"aria-label":`${o}, ${e.state}`,"aria-current":a?`step`:void 0,onClick:()=>i(e.kind),className:z(`group relative flex min-w-0 items-start gap-2 border-b border-line px-3 py-4 sm:gap-3 sm:px-4 text-left transition-colors last:border-b-0 hover:bg-panel2`,a&&`bg-panel2 before:absolute before:inset-y-0 before:left-0 before:w-[3px] before:bg-accent`,e.state===`skipped`&&`text-ink3`),children:[(0,h.jsx)(Pc,{kind:e.kind,className:z(`mt-0.5 shrink-0 text-ink2`,a&&`text-run-text`)}),(0,h.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,h.jsx)(`span`,{className:`block text-body font-semibold`,children:o}),(0,h.jsx)(`span`,{className:`mt-1 block truncate text-label text-ink2`,children:Gk(e,n,t)}),(0,h.jsxs)(`span`,{className:`mt-2 flex items-center gap-2`,children:[(0,h.jsx)(mK,{state:e.state}),(0,h.jsx)(fK,{state:e.state,announce:o})]})]}),s?(0,h.jsx)(qA,{"aria-hidden":`true`,className:`mt-1 hidden size-3.5 shrink-0 text-ink3 sm:block`}):e.state===`canceled`?(0,h.jsx)(QA,{"aria-hidden":`true`,className:`mt-1 hidden size-3.5 shrink-0 sm:block`}):a?(0,h.jsx)(XA,{"aria-hidden":`true`,className:`mt-1 hidden size-3.5 shrink-0 text-ink3 sm:block`}):null]},e.id)})})]})}function SK(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:CK(n.map(e=>e.text))}),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 subtitle word timing is invalid; regenerate alignment.`);let e=n[0];e!==void 0&&(t.start-r>.7||t.end-e.start>5||CK([...n.map(e=>e.text),t.text]).split(`
131
+ `).length>2)&&i(),n.push({...t,text:t.text.replace(/\s+/g,` `).trim()}),r=t.end,/[.!?]["'’”)]*$/.test(t.text)&&i()}return i(),t}function CK(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(`
132
+ `)}function wK({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 duration is unavailable.`);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}: caption IDs must be unique.`);return}if(r.add(o.id),!Number.isFinite(a)||a<0||a<i){c(`Caption ${n+1}: start must follow the previous caption.`);return}if(!Number.isFinite(s)||s<=a||s>t){c(`Caption ${n+1}: end must be after start and within 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}),i=s}n(e),c(void 0),u(!1)}return(0,h.jsxs)(`section`,{"aria-label":`Edit caption cues`,className:`space-y-3`,children:[(0,h.jsx)(`h3`,{children:`Caption text and timing`}),a.map((e,t)=>(0,h.jsxs)(`fieldset`,{className:`space-y-2 rounded-control border border-line2 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)(lM,{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)(cM,{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)(cM,{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-red`,children:s}),(0,h.jsx)(B,{type:`button`,onClick:f,children:`Apply caption edits to draft`}),l?(0,h.jsx)(`p`,{children:`Apply these caption edits before saving the project.`}):null]})}function TK({edit:e,view:t,imageKey:n,index:r}){let{api:i}=I(),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`;return(0,h.jsxs)(h.Fragment,{children:[!u||t===void 0?null:(0,h.jsx)(`img`,{className:`max-h-32 rounded-control object-contain`,alt:`Retained scene ${r+1}`,src:oG(i,t.revision.projectId,t.revision.id,l.recordId)}),(0,h.jsx)(`p`,{children:f})]})}function EK(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:hM(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]??``:hM(n,e.config.values)]))}}}}function DK(e,t,n){let r={...e.config.sources,[t]:n,...t===`images`&&n===`off`?{video:`off`}:{}};return{...e,config:{...e.config,sources:r,subtitles:MM(e.config.subtitles,r)}}}function OK(e,t,n){return EK({...e,content:{...e.content,promptTemplates:{...e.content.promptTemplates,[t]:n}}})}function kK(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 AK({label:e,kind:t,disabled:n=!1,onReady:r,onPending:i}){let{api:a}=I(),o=(0,m.useId)(),[s,c]=(0,m.useState)(),[l,u]=(0,m.useState)(!1),d=(0,m.useRef)(void 0),f=(0,m.useRef)(r);f.current=r;let p=(0,m.useRef)(i);p.current=i;let g=(0,m.useRef)(!0);(0,m.useEffect)(()=>(g.current=!0,()=>{g.current=!1,d.current?.abort(),p.current(!1)}),[]);async function _(e){if(n||d.current!==void 0)return;let r=new AbortController;d.current=r,u(!0),p.current(!0),c(void 0);let i;try{let n=await po(a,t,e);for(i=n.id,r.signal.throwIfAborted();n.state!==`staged`;){await kK(r.signal);let e=(await uo(a)).files.find(e=>e.id===n.id);if(r.signal.throwIfAborted(),e===void 0)throw Error(`The upload failed before staging completed.`);n=e}f.current(n)}catch(e){let t=r.signal.aborted?`Upload canceled.`:e instanceof Error?e.message:String(e);if(i!==void 0)try{await mo(a,i)}catch(e){t+=` Cleanup failed: ${e instanceof Error?e.message:String(e)}`}g.current?c(t):t.includes(`Cleanup failed:`)&&console.error(t)}finally{d.current===r&&(d.current=void 0,g.current&&(u(!1),p.current(!1)))}}return(0,h.jsxs)(`div`,{className:`space-y-2`,children:[(0,h.jsxs)(`label`,{htmlFor:o,className:`block space-y-1 text-small`,children:[e,(0,h.jsx)(cM,{id:o,type:`file`,disabled:l||n,accept:t===`audio`?`audio/*`:`image/png,image/jpeg,image/webp`,onChange:e=>{let t=e.target.files?.[0];e.target.value=``,t!==void 0&&_(t)}})]}),l?(0,h.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,h.jsx)(`p`,{role:`status`,className:`text-small text-ink2`,children:`Copying upload…`}),(0,h.jsx)(B,{type:`button`,onClick:()=>d.current?.abort(),children:`Cancel upload`})]}):null,s===void 0?null:(0,h.jsx)(`p`,{role:`alert`,className:`text-small text-red`,children:s})]})}function jK(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 MK({edit:e,onChange:t,onPending:n,view:r,getEdit:i}){let a=(0,m.useId)(),[o,s]=(0,m.useState)({}),{content:c}=e,l=(0,m.useRef)(e);l.current=e;function u(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`}:{}}}};l.current=i,t(i)}function d(e,t){let n=i?.()??l.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})),u(OK({...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))}return(0,h.jsxs)(`section`,{"aria-label":`Edit images`,className:`space-y-3`,children:[(0,h.jsx)(`h3`,{children:`Images`}),c.imageOrder.map((t,s)=>{let f=c.imageDefinitions[t];return f===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-line2 p-3`,children:[(0,h.jsxs)(`legend`,{children:[`Image `,s+1]}),(0,h.jsx)(TK,{edit:e,view:r,imageKey:t,index:s}),f.source===`generate`?(0,h.jsxs)(`label`,{htmlFor:`${a}-${t}-prompt`,children:[`Prompt for image `,s+1,(0,h.jsx)(lM,{id:`${a}-${t}-prompt`,value:f.templateKey===void 0||f.templateKey===null?f.prompt??``:c.promptTemplates[f.templateKey]??f.prompt??``,onChange:e=>d(t,e.target.value)})]}):null,f.source===`generate`&&f.templateKey==null?(0,h.jsxs)(B,{type:`button`,onClick:()=>d(t,f.prompt??``),children:[`Use saved wording as template for image `,s+1]}):null,(0,h.jsx)(AK,{label:`Replace image ${s+1}`,kind:`images`,onPending:e=>n(`image:${t}`,e),onReady:e=>{let n=i?.()??l.current,r=n.content,a=r.imageDefinitions[t];a!==void 0&&r.imageOrder.includes(t)&&u({...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)(B,{type:`button`,disabled:s===0,onClick:()=>u({...e,content:{...c,imageOrder:jK(c.imageOrder,s,-1)}}),children:[`Move image `,s+1,` earlier`]}),(0,h.jsxs)(B,{type:`button`,disabled:s===c.imageOrder.length-1,onClick:()=>u({...e,content:{...c,imageOrder:jK(c.imageOrder,s,1)}}),children:[`Move image `,s+1,` later`]}),(0,h.jsxs)(B,{type:`button`,onClick:()=>{let n=c.imageOrder.filter(e=>e!==t);u({...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`:``]}),f.source===`generate`?(0,h.jsxs)(B,{type:`button`,onClick:()=>u({...e,regenerate:[...new Set([...e.regenerate??[],`image:${t}`])]}),children:[`Regenerate image `,s+1,` after review`]}):null]},t)}),(0,h.jsx)(B,{type:`button`,disabled:c.imageOrder.length>=60,onClick:()=>{if(c.imageOrder.length>=60)return;let t=crypto.randomUUID();u({...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>=60?(0,h.jsx)(`p`,{children:`At most 60 images can be included.`}):(0,h.jsx)(AK,{label:`Add provided image`,kind:`images`,onPending:e=>n(`image:new`,e),onReady:e=>{let t=i?.()??l.current,n=t.content,r=crypto.randomUUID();u({...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}}]})}},`new-image:${e.config.sources.images===`off`}`)]})}var NK=K({logicalKey:W().min(1),logicalText:W(),segment:q([`body`,`intro`,`outro`]),text:W()});function PK(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=NK.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 FK({view:e,edit:t,onChange:n,onPending:r,getEdit:i}){let a=(0,m.useId)(),{groups:o,unmapped:s}=PK(e),c=(0,m.useRef)(t);c.current=t;let[l,u]=(0,m.useState)({});function d(e){c.current=e,n(e)}return(0,h.jsxs)(`section`,{"aria-label":`Edit narration`,className:`space-y-3`,children:[(0,h.jsx)(`h3`,{children:`Narration`}),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,s===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.`}),o.map((e,n)=>{let o=t.content.narrationOverrides[e.key];return(0,h.jsxs)(`fieldset`,{className:`space-y-2 rounded-control border border-line2 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)(`label`,{htmlFor:`${a}-${e.key}-text`,className:`block text-small`,children:[`Text for narration chunk `,n+1,(0,h.jsx)(lM,{id:`${a}-${e.key}-text`,value:o?.kind===`text`?o.text:e.text,onChange:n=>{u(t=>({...t,[e.key]:(t[e.key]??0)+1})),d({...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)(AK,{label:`Replace narration chunk ${n+1}`,kind:`audio`,onPending:t=>r(`narration:${e.key}`,t),onReady:t=>{let n=i?.()??c.current;d({...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}:${l[e.key]??0}`),(0,h.jsxs)(B,{type:`button`,onClick:()=>{let t=i?.()??c.current,n={...t.content.narrationOverrides};n[e.key]?.kind===`asset`&&delete n[e.key],u(t=>({...t,[e.key]:(t[e.key]??0)+1})),d({...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`]})]},e.key)})]})}function IK(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(LK))return o.reduce((e,t)=>e+t,0)/1e3+Math.max(0,r.length-1)*t.silenceGapSeconds;let s=i.find(e=>(e.output.role===`audio_export`||e.output.role===`video`)&&LK(e.output.durationMs))?.output.durationMs;return LK(s)?s/1e3:void 0}function LK(e){return e!=null&&Number.isFinite(e)&&e>0}var RK=K({words:G(K({text:W().trim().min(1),start:KE().finite().nonnegative(),end:KE().finite().positive(),confidence:KE().optional()})).min(1)});function zK(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`)??[],...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 BK({view:e,edit:t,onChange:n,onPending:r}){let{api:i}=I(),a=zK(t),o=t.config.sources.audio!==`off`&&a===zK({config:e.revision.config,content:e.revision.content}),s=e.revision.fingerprints[`subtitles:timing`],c=o?IK(e):void 0,l=c!==void 0&&s!==void 0&&s!==``,u=(0,m.useRef)({edit:t,onChange:n,revisionId:e.revision.id,identity:a});u.current={edit:t,onChange:n,revisionId:e.revision.id,identity:a};let d=(0,m.useRef)(r);d.current=r;let[f,p]=(0,m.useState)(new Set),[g,_]=(0,m.useState)(),v=(0,m.useRef)(void 0),y=(0,m.useRef)(!0),b=(0,m.useCallback)((e,t)=>{y.current&&p(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)(()=>{d.current(f.size>0)},[f]),(0,m.useEffect)(()=>(y.current=!0,()=>{y.current=!1,v.current?.abort(),d.current(!1)}),[]),(0,m.useEffect)(()=>{let t=e.revision.id;return()=>{(u.current.revisionId!==t||u.current.identity!==a)&&v.current?.abort()}},[e.revision.id,a]);function x(e){let t=u.current.onChange;u.current={...u.current,edit:e,identity:zK(e)},t(e)}async function S(){if(v.current!==void 0)return;let t=new AbortController;v.current=t;let n=u.current;b(`captions:load`,!0),_(void 0);try{let r=e.outputs.find(e=>e.selected&&e.state===`ready`&&e.output.role===`subtitle_words`&&e.available);if(!l||c===void 0||s===void 0||r===void 0)throw Error(`Build subtitle timing from the current narration before editing its cues.`);let a=await i.fetch(oG(i,e.revision.projectId,e.revision.id,r.recordId),{signal:t.signal});if(!a.ok)throw Error(`The retained timing file is unavailable.`);let o=RK.parse(await a.json()),d=0;for(let e of o.words){if(e.start<d||e.end<=e.start||e.end>c)throw Error(`The subtitle word timing must be ordered and within narration.`);d=e.end}let f=SK(o.words).map(e=>({...e,id:crypto.randomUUID()})),p=u.current;if(!y.current||t.signal.aborted||p.revisionId!==n.revisionId||p.identity!==n.identity||p.edit.content.subtitleCues!==n.edit.content.subtitleCues)return;x({...p.edit,content:{...p.edit.content,subtitleCues:{audioFingerprint:s,cues:f}}})}catch(e){y.current&&!t.signal.aborted&&_(e instanceof Error?e.message:String(e))}finally{v.current===t&&(v.current=void 0),b(`captions:load`,!1)}}let C=t.content.subtitleCues;return(0,h.jsxs)(`div`,{className:`space-y-5`,children:[[`audio`,`thumbnail`].map(e=>t.config.sources[e]===`provide`?(0,h.jsx)(AK,{label:`Replace provided ${e}`,kind:e,onPending:t=>b(`provided:${e}`,t),onReady:t=>{let n=u.current;n.edit.config.sources[e]===`provide`&&x({...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)(MK,{getEdit:()=>u.current.edit,view:e,edit:t,onChange:x,onPending:b}),t.config.sources.audio===`generate`?(0,h.jsx)(FK,{getEdit:()=>u.current.edit,view:e,edit:t,onChange:x,onPending:b}):null,g===void 0?null:(0,h.jsx)(`p`,{role:`alert`,className:`text-red`,children:g}),l?null:(0,h.jsx)(`p`,{children:`Build current narration timing before editing caption cues; its duration or timing is unavailable or stale.`}),C===void 0?(0,h.jsx)(B,{type:`button`,disabled:!l||f.has(`captions:load`),onClick:()=>void S(),children:`Edit existing caption cues`}):(0,h.jsxs)(h.Fragment,{children:[C.audioFingerprint===s?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.`}),l&&c!==void 0?(0,h.jsx)(wK,{cues:C.cues,duration:c,onPending:e=>b(`captions:dirty`,e),onChange:e=>{let t=u.current,n=t.edit.content.subtitleCues;n!==void 0&&x({...t.edit,content:{...t.edit.content,subtitleCues:{...n,cues:e}}})}},`${e.revision.id}:${s}`):null,(0,h.jsx)(B,{type:`button`,onClick:()=>x({...t,content:{...t.content,subtitleCues:void 0}}),children:`Discard caption edits`})]})]})}function VK({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)(MN,{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:OK(e,`narration`,r.body);i({...o,config:{...o.config,narrationPrompt:t}})}})}function HK({edit:e,prompts:t,entries:n,onChange:r}){let i=(0,m.useId)(),a=[...new Set([...Object.keys(e.config.rendered),...Object.keys(e.content.promptTemplates),...e.config.sources.article===`generate`?[`article`]:[],...ak(e.config)?[`narration`]:[],...[`from_prompt`,`prompt_by_llm`].includes(e.config.sources.thumbnail)?[`thumbnailPrompt`]:[],...e.config.intro===void 0?[]:[`intro`],...e.config.outro===void 0?[]:[`outro`]])],o=[...new Set([...Object.keys(e.config.values),...Object.values(e.content.promptTemplates).flatMap(e=>e===null?[]:pM(e).names)])];return(0,h.jsxs)(`section`,{"aria-label":`Prompt snapshots`,className:`space-y-3`,children:[a.map(a=>{let o=UK(a),s=e.content.promptTemplates[a]??null,c=a===`intro`||a===`outro`?n.filter(e=>e.category===a):t.filter(e=>e.kind===(a===`article`?`article`:a===`narration`?`narration`:a===`thumbnailPrompt`?`thumbnail`:`image`));return(0,h.jsxs)(`fieldset`,{className:`min-w-0 space-y-3 rounded-control border border-line p-3`,children:[(0,h.jsx)(`legend`,{className:`px-1 text-small font-semibold`,children:o}),s===null?(0,h.jsxs)(`div`,{className:`space-y-2`,children:[(0,h.jsx)(`p`,{children:`Original template unavailable. The saved rendered prompt stays frozen until you choose or write a template.`}),(0,h.jsx)(B,{type:`button`,"aria-label":`Use saved wording as template for ${o}`,onClick:()=>r(OK(e,a,e.config.rendered[a]??``)),children:`Use saved wording as template`})]}):null,(0,h.jsxs)(`label`,{htmlFor:`${i}-library-${a}`,className:`flex min-w-0 flex-col gap-1 text-small`,children:[`Use saved template for `,o,(0,h.jsxs)(aN,{id:`${i}-library-${a}`,value:``,onChange:t=>{let n=c.find(e=>e.id===t.target.value);if(n===void 0)return;let i=OK(e,a,n.body),o=`category`in n?{...i.config,[n.category]:{name:n.name,mode:n.mode}}:a===`article`?{...i.config,articlePrompt:n.name}:a===`narration`?{...i.config,narrationPrompt:n.name}:a===`thumbnailPrompt`?{...i.config,thumbnailPrompt:n.name}:i.config;r({...i,config:o})},children:[(0,h.jsx)(`option`,{value:``,children:`Choose explicitly`}),c.map(e=>(0,h.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]}),(0,h.jsxs)(`label`,{htmlFor:`${i}-raw-${a}`,className:`block space-y-1 text-small`,children:[`Raw prompt for `,o,(0,h.jsx)(lM,{id:`${i}-raw-${a}`,rows:4,value:s??``,onChange:t=>r(OK(e,a,t.target.value))})]}),(0,h.jsxs)(`details`,{children:[(0,h.jsx)(`summary`,{children:`Saved rendered prompt`}),(0,h.jsx)(`pre`,{className:`whitespace-pre-wrap break-words`,children:e.config.rendered[a]??``})]})]},a)}),o.map(t=>(0,h.jsxs)(`label`,{htmlFor:`${i}-keyword-${t}`,className:`block space-y-1 text-small`,children:[`Keyword `,t,(0,h.jsx)(cM,{id:`${i}-keyword-${t}`,maxLength:200,value:e.config.values[t]??``,onChange:n=>r(EK({...e,config:{...e.config,values:{...e.config.values,[t]:n.target.value}}}))})]},t))]})}function UK(e){if(e===`article`)return`Article`;if(e===`narration`)return`Narration Preparation`;if(e===`thumbnailPrompt`)return`Thumbnail`;if(e===`intro`)return`Intro`;if(e===`outro`)return`Outro`;let t=/^imagePrompts\.(\d+)$/.exec(e);return t?.[1]===void 0?e.replace(/[._-]/g,` `).replace(/([a-z])([A-Z])/g,`$1 $2`):`Image prompt ${Number(t[1])+1}`}function WK({edit:e,providers:t,voices:n,onChange:r}){let{config:i}=e,a=i.llm??{provider:``,model:``},o=i.audio??{provider:``,model:``,voice:``},s=i.images??{provider:``,model:``},c=ak(i)||i.sources.research===`generate`||i.sources.article===`generate`||i.sources.thumbnail===`prompt_by_llm`||i.sources.audio===`generate`&&(i.intro?.mode===`llm`||i.outro?.mode===`llm`),l=i.sources.images===`generate`||i.sources.thumbnail===`from_prompt`||i.sources.thumbnail===`prompt_by_llm`,u=n.filter(e=>e.provider===o.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:[c?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(hN,{label:`Text provider`,family:`llm`,providers:t,value:a.provider,problem:void 0,onPick:t=>r({...e,config:{...i,llm:{provider:t,model:``}}})}),(0,h.jsx)(gN,{label:`Text model`,provider:a.provider,value:a.model,problem:void 0,onPick:t=>r({...e,config:{...i,llm:{...a,model:t}}})}),(0,h.jsx)(BN,{choice:a,onChange:t=>r({...e,config:{...i,llm:t}})})]}):null,i.sources.audio===`generate`?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(hN,{label:`Narration provider`,family:`tts`,providers:t,value:o.provider,problem:void 0,onPick:t=>r({...e,config:{...i,audio:{provider:t,model:``,voice:``}}})}),(0,h.jsx)(gN,{label:`Narration model`,provider:o.provider,value:o.model,problem:void 0,onPick:t=>r({...e,config:{...i,audio:{...o,model:t}}})}),(0,h.jsx)(fN,{label:`Narration voice`,value:o.voice,problem:void 0,placeholder:`Choose a saved voice`,options:o.voice!==``&&!u.some(e=>e.value===o.voice)?[{value:o.voice,label:`${o.voice} (saved voice)`},...u]:u,onPick:t=>r({...e,config:{...i,audio:{...o,voice:t}}})}),(0,h.jsx)(yN,{value:i.chunking??{mode:`whole`},onPick:t=>r({...e,config:{...i,chunking:t}})})]}):null,l?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(hN,{label:`Image provider`,family:`image`,providers:t,value:s.provider,problem:void 0,onPick:t=>r({...e,config:{...i,images:{provider:t,model:``}}})}),(0,h.jsx)(gN,{label:`Image model`,provider:s.provider,value:s.model,problem:void 0,onPick:t=>r({...e,config:{...i,images:{...s,model:t}}})})]}):null]})}function GK(e){let{view:t,edit:n,onChange:r,onPending:i,fields:a}=e,o=(0,m.useId)(),[s,c]=(0,m.useState)({font:!1,content:!1});(0,m.useEffect)(()=>{i(s.font||s.content)},[i,s]);let l=(0,m.useCallback)(e=>{c(t=>t.font===e?t:{...t,font:e})},[]),u=(0,m.useCallback)(e=>{c(t=>t.content===e?t:{...t,content:e})},[]),{api:d}=I(),f=nt(vy(d)),p=nt(yy(d)),g=nt(by(d)),_=nt(xy(d)),{config:v}=n,y=e=>a.find(t=>t.field===e||t.field===`config.${e}`||t.field===`edit.config.${e}`)?.message;return(0,h.jsxs)(`div`,{className:`grid min-w-0 gap-4 lg:grid-cols-2`,children:[Object.entries({providers:f.error,voices:p.error,prompts:g.error,entries:_.error}).flatMap(([e,t])=>t===null?[]:[(0,h.jsx)(`p`,{role:`alert`,className:`text-small text-red lg:col-span-2`,children:t.message},e)]),(0,h.jsxs)(`section`,{className:`min-w-0 space-y-3`,children:[(0,h.jsxs)(`label`,{htmlFor:`${o}-title`,className:`block space-y-1 text-small`,children:[`Project title`,(0,h.jsx)(cM,{id:`${o}-title`,value:v.title,maxLength:200,onChange:e=>r({...n,config:{...v,title:e.target.value}})})]}),(0,h.jsx)(mP,{value:v.format,onPick:e=>r({...n,config:{...v,format:e}})}),VD.map(e=>(0,h.jsxs)(`label`,{htmlFor:`${o}-source-${e}`,className:`flex min-w-0 flex-col gap-1 text-small`,children:[e,` source`,(0,h.jsx)(aN,{id:`${o}-source-${e}`,value:v.sources[e],onChange:i=>{let a=FM(e).find(e=>e.value===i.target.value);if(a===void 0)return;let o=DK(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:FM(e).map(t=>(0,h.jsx)(`option`,{value:t.value,disabled:e===`video`&&t.value===`generate`&&v.sources.images===`off`,children:t.label},t.value))})]},e)),v.sources.images===`off`?(0,h.jsx)(`p`,{children:`Images are Off. Video is also Off in these changes.`}):null,(0,h.jsxs)(`label`,{htmlFor:`${o}-gap`,className:`block space-y-1 text-small`,children:[`Silence gap (seconds)`,(0,h.jsx)(cM,{id:`${o}-gap`,type:`number`,min:0,max:30,step:.1,value:Number.isFinite(v.silenceGapSeconds)?v.silenceGapSeconds:``,onChange:e=>r({...n,config:{...v,silenceGapSeconds:Number(e.target.value)}})})]}),[`intro`,`outro`].map(e=>(0,h.jsxs)(`label`,{htmlFor:`${o}-entry-${e}`,className:`flex min-w-0 flex-col gap-1 text-small`,children:[e,(0,h.jsxs)(aN,{id:`${o}-entry-${e}`,value:v[e]?.name??``,onChange:t=>{let i=_.data?.entries.find(n=>n.category===e&&n.name===t.target.value),a={...v};i===void 0?delete a[e]:a[e]={name:i.name,mode:i.mode},r(EK({...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`}),v[e]!==void 0&&!_.data?.entries.some(t=>t.category===e&&t.name===v[e]?.name)?(0,h.jsxs)(`option`,{value:v[e]?.name,children:[v[e]?.name,` (saved entry)`]}):null,_.data?.entries.filter(t=>t.category===e).map(e=>(0,h.jsx)(`option`,{value:e.name,children:e.name},e.id))]})]},e)),v.sources.research===`provide`?(0,h.jsxs)(`label`,{htmlFor:`${o}-research`,className:`block space-y-1 text-small`,children:[`Research notes`,(0,h.jsx)(lM,{id:`${o}-research`,rows:6,value:v.provided.research??``,onChange:e=>r({...n,config:{...v,provided:{...v.provided,research:e.target.value}}})})]}):null,(0,h.jsxs)(`label`,{htmlFor:`${o}-article`,className:`block space-y-1 text-small`,children:[`Article text`,(0,h.jsx)(lM,{id:`${o}-article`,rows:6,maxLength:5e5,value:(n.content.articleEdited?n.content.articleMarkdown:t.articleMarkdown)??n.content.articleMarkdown??v.provided.article??``,onChange:e=>r({...n,content:{...n.content,articleMarkdown:e.target.value,articleEdited:!0}})})]}),n.content.articleEdited?(0,h.jsx)(`p`,{children:`Your edited article is retained when other settings change. Explicit regeneration replaces it after rebuild review.`}):null,v.sources.article===`generate`?(0,h.jsx)(B,{type:`button`,onClick:()=>r({...n,regenerate:[...new Set([...n.regenerate??[],`article:body`])]}),children:`Regenerate article after review`}):null,(0,h.jsx)(WK,{edit:n,providers:f.data?.providers??[],voices:p.data?.voices??[],onChange:r}),(0,h.jsx)(VK,{edit:n,view:t,prompts:g.data?.prompts??[],error:y(`narrationPrompt`),onChange:r})]}),(0,h.jsxs)(`section`,{className:`min-w-0 space-y-3`,children:[(0,h.jsx)(HK,{edit:n,prompts:g.data?.prompts??[],entries:_.data?.entries??[],onChange:r}),(0,h.jsx)(`div`,{"data-tour":`project-subtitles`,children:(0,h.jsx)(pP,{value:v.subtitles??eO,format:v.format,audioEnabled:v.sources.audio!==`off`,videoEnabled:v.sources.video!==`off`,onChange:e=>r({...n,config:{...v,subtitles:MM(e,v.sources)}}),onUploading:l,problem:y})}),a.length===0?null:(0,h.jsx)(`ul`,{role:`alert`,children:a.map(e=>(0,h.jsxs)(`li`,{children:[e.field,`: `,e.message]},`${e.field}-${e.message}`))})]}),(0,h.jsx)(`div`,{className:`lg:col-span-2`,children:e.renderContent?.({view:t,edit:n,fields:a,onChange:r,onPending:u})})]})}var KK={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`};function qK(e){return(e.role===`narration_txt`||e.role===`tts_script`)&&e.meta.segment?`${e.meta.segment===`body`?`Body`:e.meta.segment===`intro`?`Intro`:`Outro`} ${KK[e.role]}`:e.role===`image`&&typeof e.meta.index==`number`?`Image ${e.meta.index}`:KK[e.role]}function JK(e){if(e.startsWith(`image:`))return`Image`;let t=e.split(`:`).at(-1);return Object.entries(KK).find(([e])=>e===t)?.[1]??`Saved output`}function YK({preview:e,pending:t,onStart:n,onCancel:r}){let i=$K(e),[a,o]=(0,m.useState)([]),[s,c]=(0,m.useState)(!1),l=e=>e===null?`Unknown`:new Intl.NumberFormat(`en-US`,{style:`currency`,currency:`USD`,maximumFractionDigits:4}).format(e),u=!e.work.some(e=>e.disposition===`blocked`)&&e.providedReuseRequired.every(e=>a.includes(e))&&(e.costs.unknown===0||s);return(0,h.jsxs)(`section`,{"aria-label":`Review affected rebuild`,className:`space-y-3 rounded-panel border border-line p-4`,children:[(0,h.jsx)(`h2`,{children:`Review affected rebuild`}),e.review?.inputChanges.length?(0,h.jsxs)(`details`,{open:!0,children:[(0,h.jsx)(`summary`,{children:`Changed inputs since the previous revision`}),(0,h.jsx)(`dl`,{className:`space-y-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:`grid gap-2 sm:grid-cols-2`,children:[(0,h.jsxs)(`div`,{className:`min-w-0`,children:[(0,h.jsx)(`span`,{className:`text-small text-ink2`,children:`Before`}),(0,h.jsx)(`pre`,{className:`max-h-40 overflow-auto whitespace-pre-wrap break-words text-small`,children:e.before??`Not set`})]}),(0,h.jsxs)(`div`,{className:`min-w-0`,children:[(0,h.jsx)(`span`,{className:`text-small text-ink2`,children:`After`}),(0,h.jsx)(`pre`,{className:`max-h-40 overflow-auto whitespace-pre-wrap break-words text-small`,children:e.after??`Not set`})]})]})]},e.label))})]}):null,(0,h.jsx)(`ul`,{children:e.changedInputs.map(e=>(0,h.jsxs)(`li`,{children:[i(e.path),`:`,` `,e.after===null?`Removed`:e.before===null?`New output`:`Inputs changed`]},e.path))}),(0,h.jsx)(`ul`,{children:e.work.map(t=>(0,h.jsxs)(`li`,{children:[i(t.key),`: `,XK[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:`text-small text-ink2`,children:e.settings}),e.text===null?null:(0,h.jsxs)(`details`,{children:[(0,h.jsx)(`summary`,{children:`View request text`}),(0,h.jsx)(`pre`,{className:`max-h-56 overflow-auto whitespace-pre-wrap break-words text-small`,children:e.text})]})]},e.key))]},t.key))}),(0,h.jsxs)(`p`,{children:[`Retained outputs:`,` `,e.retained.map(e=>JK(e.slot)).join(`, `)||`None`]}),e.wholeRequestNotice===null?null:(0,h.jsx)(`p`,{children:e.wholeRequestNotice}),(0,h.jsx)(`ul`,{children:e.costs.rows.map(e=>(0,h.jsxs)(`li`,{children:[i(e.stage),`: `,l(e.low),`–`,l(e.high),`. `,e.detail]},`${e.stage}-${e.detail}`))}),(0,h.jsxs)(`p`,{children:[`Known estimate: `,l(e.costs.low),`–`,l(e.costs.high)]}),e.warnings.map(e=>(0,h.jsx)(`p`,{children:e},e)),e.providedReuseRequired.map(e=>(0,h.jsxs)(`label`,{className:`block`,children:[(0,h.jsx)(`input`,{type:`checkbox`,disabled:t,checked:a.includes(e),onChange:t=>o(t.target.checked?[...a,e]:a.filter(t=>t!==e))}),`Keep the provided content for `,i(e)]},e)),e.costs.unknown===0?null:(0,h.jsxs)(`label`,{className:`block`,children:[(0,h.jsx)(`input`,{type:`checkbox`,disabled:t,checked:s,onChange:e=>c(e.target.checked)}),`I understand that `,e.costs.unknown,` cost estimates are unknown.`]}),(0,h.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[(0,h.jsx)(B,{variant:`primary`,type:`button`,disabled:t||!u,onClick:()=>n({acknowledgeUnknownCosts:s,confirmedProvidedWorkKeys:a}),children:`Start rebuild`}),(0,h.jsx)(B,{type:`button`,disabled:t,onClick:r,children:`Cancel rebuild`})]})]})}var XK={reuse:`Reuse`,generate:`Generate`,local:`Build locally`,review:`Review required`,blocked:`Unavailable`},ZK={"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 QK(e){let t=ZK[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 $K(e){let t=new Map,n=new Map;for(let t of e.work){let e=QK(t.key);n.set(e,(n.get(e)??0)+1)}let r=new Map;for(let i of e.work){let e=QK(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)??QK(e)}var eq=K({text:W().optional(),logicalText:W().optional(),title:W().optional(),notes:W().optional(),outline:G(W()).optional(),prompt:W().optional()});function tq(e){if(e===null)return`No text was recorded for this part.`;try{let t=eq.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(`
133
133
 
134
134
  `):void 0,o?.filter(e=>e.trim()).map((e,t)=>`${t+1}. ${e}`).join(`
135
- `),s].find(e=>e?.trim())??`No text was recorded for this part.`}catch{return`Recorded text cannot be decoded.`}}function tq({projectId:e,pending:t,onRestore:n}){let{api:r}=I(),[i,a]=(0,m.useState)(),o=nt({queryKey:V.revisions(e),queryFn:async()=>{let t=await tG(r,e);if(!t.ok)throw Error(t.message);return t.value.revisions}}),s=nt({queryKey:V.revision(e,i??``),enabled:i!==void 0,queryFn:async()=>{if(i===void 0)throw Error(`Choose a revision.`);let t=await nG(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`));return(0,h.jsxs)(`section`,{"aria-label":`Project history`,className:`space-y-3 rounded-panel border border-line bg-panel p-4`,children:[(0,h.jsx)(`h2`,{children:`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)(B,{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`,{children:c.revision.config.title}),l===void 0?null:(0,h.jsxs)(`span`,{className:`inline-flex gap-3`,children:[(0,h.jsx)(`a`,{href:sG(r,e,c.revision.id),download:!0,children:`Download all images`}),(0,h.jsx)(cG,{projectId:e,asset:``,folder:{revisionId:c.revision.id,recordId:l.recordId}})]}),(0,h.jsx)(`ul`,{className:`space-y-3`,children:c.outputs.map(t=>(0,h.jsxs)(`li`,{className:`space-y-2 rounded-control border border-line p-3`,children:[KK(t.output),` · `,t.state,t.selected?``:` · Earlier result`,`:`,` `,t.available?(0,h.jsx)(`a`,{href:aG(r,e,c.revision.id,t.recordId),children:`Download`}):`File missing`,t.available?(0,h.jsx)(cG,{projectId:e,asset:``,folder:{revisionId:c.revision.id,recordId:t.recordId}}):null,t.available?(0,h.jsxs)(`details`,{children:[(0,h.jsx)(`summary`,{children:`Preview retained output`}),t.output.role===`video`?(0,h.jsx)(`video`,{className:`max-h-[480px] max-w-full`,controls:!0,preload:`metadata`,src:aG(r,e,c.revision.id,t.recordId)}):[`audio_export`,`audio_body`,`audio_intro`,`audio_outro`].includes(t.output.role)?(0,h.jsx)(`audio`,{className:`max-w-full`,controls:!0,preload:`metadata`,src:aG(r,e,c.revision.id,t.recordId)}):t.output.role===`image`||t.output.role===`thumbnail`?(0,h.jsx)(`img`,{className:`max-h-[480px] max-w-full object-contain`,alt:KK(t.output),loading:`lazy`,src:aG(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)(`audio`,{className:`max-w-full`,controls:!0,preload:`metadata`,src:aG(r,e,c.revision.id,t.recordId)}),(0,h.jsx)(`a`,{href:aG(r,e,c.revision.id,t.recordId),children:`Download narration part`}),(0,h.jsx)(cG,{projectId:e,asset:``,folder:{revisionId:c.revision.id,recordId:t.recordId}})]}):(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:eq(e.piece.payload)})]})},e.recordId))}),(0,h.jsx)(B,{type:`button`,disabled:t,onClick:()=>n(c.revision.id),children:`Restore this revision`})]})]})}function nq(e,t,n){let r=JSON.stringify(t);return e?.payload===r?e:{payload:r,idempotencyKey:n()}}function rq({projectId:e,currentRevisionId:t,renderEditor:n}){let{api:r}=I(),i=_(),a=nt({queryKey:V.revision(e,t??``),enabled:t!==null,queryFn:async()=>{if(t===null)throw Error(`Prepare this legacy project before inspecting revision status.`);let n=await nG(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)(!1),[f,p]=(0,m.useState)(),[g,v]=(0,m.useState)(!1),[y,b]=(0,m.useState)(!1),[x,S]=(0,m.useState)(),[C,w]=(0,m.useState)(),T=(0,m.useRef)(void 0),E=(0,m.useRef)(void 0),D=(0,m.useRef)(void 0),O=c!==void 0&&o!==void 0&&t!==null&&t!==o.revision.id,ee=(0,m.useRef)(!1);async function k(e){if(!ee.current){ee.current=!0,v(!0),S(void 0);try{await e()}catch(e){S(e instanceof Error?e.message:String(e))}finally{ee.current=!1,v(!1)}}}async function A(t){let n=await QW(r,e);if(!n.ok){w(n);return}return w(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 j(t){let n=await co(r,e);if(i.setQueryData(V.project(e),n),await i.invalidateQueries({queryKey:V.revisions(e)}),!t.current||n.revisionId!==t.revision.id){w({ok:!1,reason:`conflict`,message:`The project changed again. Your draft is preserved.`,currentRevisionId:n.revisionId,fields:[]});return}s(t),l(void 0),w(void 0),p(void 0)}async function M(){if(y||o===void 0||c===void 0)return;let t={baseRevisionId:o.revision.id,edit:c},n=nq(T.current,t,()=>crypto.randomUUID());T.current=n;let i=await $W(r,e,{...t,idempotencyKey:n.idempotencyKey});if(!i.ok){w(i);return}await j(i.value.view),T.current=void 0}async function N(){let t=await A(!1);if(t===void 0)return;let n=await rG(r,e,{baseRevisionId:t.revision.id,request:{kind:`allAffected`}});if(!n.ok){w(n);return}p(n.value.value),D.current=void 0}async function P(t){if(f===void 0)return;let n={baseRevisionId:f.baseRevisionId,previewId:f.id,...t},a=nq(D.current,n,()=>crypto.randomUUID());D.current=a;let o=await iG(r,e,{...n,idempotencyKey:a.idempotencyKey});if(!o.ok){w(o),(o.reason===`stale-preview`||o.reason===`conflict`)&&p(void 0);return}D.current=void 0,p(void 0),await i.invalidateQueries({queryKey:V.project(e)})}async function F(t){let n=o??a.data??await A(!1);if(n===void 0)return;let i={baseRevisionId:n.revision.id,targetRevisionId:t},s=nq(E.current,i,()=>crypto.randomUUID());E.current=s;let c=await eG(r,e,{...i,idempotencyKey:s.idempotencyKey});if(!c.ok){w(c);return}await j(c.value.view),E.current=void 0}return(0,h.jsxs)(`section`,{"aria-label":`Project revisions`,className:`space-y-4`,children:[a.error===null?null:(0,h.jsx)(`p`,{role:`alert`,children:a.error.message}),a.data===void 0?null:(0,h.jsx)(`ul`,{"aria-label":`Saved output status`,className:`flex flex-wrap gap-x-4 gap-y-1 text-small text-ink2`,children:a.data.outputs.filter(e=>e.selected).map(e=>(0,h.jsxs)(`li`,{children:[KK(e.output),`:`,` `,e.available?e.state===`ready`?`Ready`:e.state===`outdated`?`Needs rebuild; retained output available`:`Provided content needs review`:`Retained file missing`]},e.recordId))}),(0,h.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[(0,h.jsx)(B,{type:`button`,disabled:g||y||c!==void 0||f!==void 0,onClick:()=>void k(async()=>{await A(!0)}),children:`Edit project`}),(0,h.jsx)(B,{type:`button`,onClick:()=>d(!u),children:`History`}),(0,h.jsx)(B,{type:`button`,disabled:g||y||c!==void 0||f!==void 0,onClick:()=>void k(N),children:`Rebuild affected outputs`})]}),x===void 0?null:(0,h.jsx)(`p`,{role:`alert`,children:x}),C===void 0?null:(0,h.jsx)(`p`,{role:`alert`,children:C.message}),c===void 0&&C?.reason===`conflict`?(0,h.jsx)(B,{type:`button`,disabled:g,onClick:()=>void k(async()=>{E.current=void 0,D.current=void 0,p(void 0),await A(!1),await i.invalidateQueries({queryKey:V.project(e)})}),children:`Reload current revision`}):null,O?(0,h.jsx)(`p`,{role:`status`,children:`A newer revision is available. Your unsaved changes are kept below.`}):null,o===void 0||c===void 0?null:(0,h.jsxs)(`form`,{className:`space-y-4 rounded-panel border border-line bg-panel p-4`,onSubmit:e=>{e.preventDefault(),k(M)},children:[(0,h.jsx)(`fieldset`,{disabled:g,children:n({view:o,edit:c,fields:C?.fields??[],onChange:l,onPending:b})}),(0,h.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[(0,h.jsx)(B,{variant:`primary`,type:`submit`,disabled:g||y,children:`Save changes`}),(0,h.jsx)(B,{type:`button`,disabled:g||y,onClick:()=>{l(void 0),w(void 0),b(!1),T.current=void 0},children:`Discard changes`}),O||C?.reason===`conflict`?(0,h.jsx)(B,{type:`button`,disabled:g||y,onClick:()=>void k(async()=>{T.current=void 0,b(!1),await A(!0),w(void 0)}),children:`Reload current revision and discard my draft`}):null]})]}),u?(0,h.jsx)(tq,{projectId:e,pending:g||y||c!==void 0||f!==void 0,onRestore:e=>void k(()=>F(e))}):null,f===void 0?null:(0,h.jsx)(JK,{preview:f,pending:g,onStart:e=>void k(()=>P(e)),onCancel:()=>{p(void 0),D.current=void 0}},f.id)]})}var iq=K({id:OE(),name:W(),version:KE().int().positive(),updatedAt:W()}),aq=iq.extend({document:gO}),oq=oD([aq,K({template:aq}).transform(e=>e.template)]),sq=K({title:W(),detail:W().optional(),reason:W().optional()}),cq=[`project-templates`],lq=e=>`${e.origin}/api/project-templates`;async function uq(e,t){let n;try{n=await e.json()}catch{throw io(e,void 0)}if(e.ok)return{ok:!0,value:t.parse(n)};let r=sq.safeParse(n);if(!r.success)throw io(e,void 0);let i=r.data.detail??r.data.title;if(![400,404,409].includes(e.status))throw Error(i);return{ok:!1,message:i,reason:r.data.reason??`invalid-request`}}var dq=(e,t)=>({method:e,headers:{"content-type":`application/json`},body:JSON.stringify(t)});async function fq(e){return uq(await e.fetch(lq(e)),K({templates:G(iq)}).transform(e=>e.templates))}function pq(e){return{queryKey:cq,queryFn:async()=>{let t=await fq(e);if(!t.ok)throw Error(t.message);return t.value}}}async function mq(e,t){let n=K({id:OE(),name:W().trim().min(1),document:gO}).parse(t);return uq(await e.fetch(lq(e),dq(`POST`,n)),oq)}async function hq(e,t,n){let r=K({id:OE(),name:W().trim().min(1).max(200),revisionId:W().min(1).max(64)}).parse(n);return uq(await e.fetch(`${lq(e)}/from-project/${encodeURIComponent(t)}`,dq(`POST`,r)),oq)}async function gq(e,t){let n=await e.fetch(`${lq(e)}/${encodeURIComponent(t.id)}`,dq(`DELETE`,{baseVersion:t.version}));return n.ok?{ok:!0,value:null}:uq(n,QE())}async function _q(e,t,n){let r=K({id:OE(),version:KE().int().positive()}).parse({id:n,version:t.version});return uq(await e.fetch(`${lq(e)}/${encodeURIComponent(t.id)}/instantiate`,dq(`POST`,r)),oD([EO,K({draft:EO}).transform(e=>e.draft)]))}function vq({projectId:e,revisionId:t,title:n}){let{api:r}=I(),i=_(),a=(0,m.useId)(),[o,s]=(0,m.useState)(null),[c,l]=(0,m.useState)(!1),[u,d]=(0,m.useState)(null),[f,p]=(0,m.useState)(!1),g=(0,m.useRef)(!1),v=(0,m.useRef)(null);async function y(){if(!o||g.current||!o.name.trim())return;g.current=!0,l(!0),d(null);let t=JSON.stringify([e,o.revisionId,o.name.trim()]);v.current?.key!==t&&(v.current={key:t,id:crypto.randomUUID()});try{let t=await hq(r,e,{id:v.current.id,name:o.name.trim(),revisionId:o.revisionId});if(!t.ok){v.current=null,d(t.message);return}v.current=null,s(null),p(!0),await i.invalidateQueries({queryKey:cq})}catch(e){d(e instanceof Error?e.message:`Could not save the template.`)}finally{g.current=!1,l(!1)}}return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(B,{disabled:t===null||c,onClick:()=>{t!==null&&(s({revisionId:t,name:n}),d(null),p(!1))},children:`Save as template`}),f?(0,h.jsx)(`p`,{role:`status`,children:`Template saved.`}):null,(0,h.jsx)(cy,{open:o!==null,onOpenChange:e=>{!e&&!g.current&&s(null)},children:(0,h.jsxs)(dy,{children:[(0,h.jsx)(fy,{children:`Save as template`}),(0,h.jsx)(py,{children:`Save this revision’s setup for a fresh Play draft. This does not rebuild the project.`}),(0,h.jsxs)(`form`,{className:`space-y-4`,onSubmit:e=>{e.preventDefault(),y()},children:[(0,h.jsx)(`label`,{htmlFor:a,children:`Template name`}),(0,h.jsx)(cM,{id:a,autoFocus:!0,required:!0,maxLength:200,disabled:c,value:o?.name??``,onChange:e=>{let t=e.target.value;s(e=>e&&{...e,name:t})}}),u?(0,h.jsx)(`p`,{role:`alert`,className:`text-red`,children:u}):null,(0,h.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,h.jsx)(B,{type:`button`,disabled:c,onClick:()=>s(null),children:`Cancel`}),(0,h.jsx)(B,{type:`submit`,disabled:c||!o?.name.trim(),children:`Save template`})]})]})]})})]})}function yq(e,t){switch(e){case`research`:case`article`:return t.llm?.provider;case`audio`:return t.audio?.provider;case`images`:case`thumbnail`:return t.images?.provider;case`video`:return}}function bq(e,t,n){if(e===`audio`&&t.narrationPrompt&&ak(t)){let e=bq(`article`,t,n);if(e!==void 0)return e}let r=yq(e,t);if(r===void 0||r===``)return;let i=n.find(e=>e.id===r);if(i!==void 0)return i.readiness.kind===`keyed`?i.readiness.hasKey?void 0:{label:`Key missing`,provider:r}:Rk(i.readiness)?void 0:{label:i.readiness.issue?`CLI update required`:`CLI missing`,provider:r}}var xq={research:`Research notes`,article:`Article workspace`,audio:`Narration`,images:`Image library`,thumbnail:`Thumbnail preview`,video:`Preview & export`};function Sq({stage:e,project:t,outputs:n,providers:r,actions:i,children:a,active:o=!0}){let s=(0,m.useContext)(CP),c=Vk(e.kind,t.config),l=t.status===`paused`?{...i,pending:!0}:i,u=bq(e.kind,t.config,r),d=i.refusal?.stage===e.kind?i.refusal.message:void 0,f=e.state===`failed`||e.state===`canceled`,p=n.some(t=>t.stageKind===e.kind&&t.role!==`instructions`)||e.state===`running`||e.state===`done`||e.state===`provided`||e.kind===`video`&&e.state!==`skipped`,g=e.progressTotal===null||e.progressTotal<=0?void 0:Math.min(100,Math.max(0,Math.round((e.progressCurrent??0)/e.progressTotal*100)));return(0,h.jsxs)(`section`,{"data-tour":`project-${e.kind}`,hidden:!o,"aria-label":`${c} workspace`,className:o?`min-w-0 rounded-panel border border-line bg-panel`:`hidden`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 border-b border-line px-5 py-4`,children:[(0,h.jsx)(Pc,{kind:e.kind,className:`text-ink2`}),(0,h.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,h.jsx)(`h2`,{className:`text-row font-bold`,children:e.kind===`video`&&c===`Audio export`?`Listen & export`:xq[e.kind]}),(0,h.jsx)(`p`,{className:`mt-1 text-small text-ink2`,children:Gk(e,n,t)})]}),(0,h.jsx)(dK,{state:e.state})]}),e.state===`running`?(0,h.jsxs)(`div`,{className:`border-b border-line px-5 py-3`,children:[(0,h.jsxs)(`div`,{className:`mb-2 flex justify-between text-small text-run-text`,children:[(0,h.jsxs)(`span`,{children:[c,` in progress`]}),g===void 0?(0,h.jsx)(`span`,{children:`Waiting for provider progress`}):(0,h.jsxs)(`span`,{className:`tabular-nums`,children:[g,`%`]})]}),(0,h.jsx)(`div`,{role:`progressbar`,"aria-label":`${c} progress`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":g,className:`h-1.5 overflow-hidden rounded-control bg-panel2`,children:(0,h.jsx)(`div`,{className:`h-full origin-left bg-accent`,style:{transform:`scaleX(${(g??0)/100})`}})})]}):null,f?(0,h.jsxs)(`div`,{className:`m-5 rounded-control border border-red/30 bg-red-tint p-4`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,h.jsx)(`p`,{className:`min-w-0 flex-1 text-small text-red`,children:e.state===`failed`?`${c} needs attention.`:`${c} was canceled.`}),(0,h.jsx)(`span`,{className:`text-label text-ink2`,children:Kk(e)}),s?null:(0,h.jsx)(`button`,{type:`button`,disabled:u!==void 0||l.pending,onClick:()=>l.run({kind:`retry`,stage:e.kind}),className:`rounded-control border border-red px-3 py-2 text-small text-ink hover:bg-panel2 disabled:opacity-50`,children:u?.label??`Retry stage`})]}),(0,h.jsx)(`p`,{className:`mt-2 text-small text-ink2`,children:s?`Use Rebuild affected outputs to review the work and cost before retrying.`:t.status===`paused`?`Resume the project to continue with its saved settings.`:`Retry keeps completed outputs. To change the provider or model, open Run settings.`}),e.failureReason?(0,h.jsxs)(`details`,{className:`mt-3`,children:[(0,h.jsx)(`summary`,{className:`cursor-pointer text-small text-red`,children:`Error details`}),(0,h.jsx)(`span`,{className:`mt-2 block max-h-48 overflow-auto whitespace-pre-wrap break-words text-label text-ink2`,children:e.failureReason})]}):null,u?(0,h.jsxs)(`p`,{className:`mt-3 text-small text-ink2`,children:[u.label,` for `,u.provider,`.`,` `,(0,h.jsx)(sa,{to:`/settings`,className:`underline underline-offset-4`,children:`Open Settings`})]}):null]}):null,d?(0,h.jsx)(`div`,{className:`px-5 pt-4`,children:(0,h.jsx)(wG,{message:d,onDismiss:i.dismissRefusal})}):null,e.state===`running`&&e.kind!==`article`&&e.kind!==`images`&&e.kind!==`video`?(0,h.jsx)(OP,{projectId:t.id,stage:e.kind}):null,p?a:f?null:(0,h.jsxs)(`div`,{className:`flex min-h-64 flex-col items-center justify-center gap-3 p-8 text-center`,children:[(0,h.jsx)(Pc,{kind:e.kind,className:`size-8 text-ink3`}),(0,h.jsx)(`p`,{className:`text-body text-ink2`,children:e.state===`skipped`?`${c} was switched off for this run.`:t.status===`paused`?`Resume the project when you are ready to continue.`:`This stage will start when its inputs are ready.`}),(0,h.jsx)(`p`,{className:`max-w-md text-small text-ink3`,children:e.state===`skipped`?`The other stages are available from the list.`:`You can review completed outputs while the project runs.`})]})]})}var Cq=K({baseRevisionId:W().min(1).max(64),idempotencyKey:OE()}).strict(),wq=new Set([400,404,409]);async function Tq(e,t,n){return Iq(e,t,`cancel`,n)}async function Eq(e,t,n){return Iq(e,t,`pause`,n)}async function Dq(e,t){return Fq(await e.client.projects[`:id`].resume.$post({param:{id:t}}))}async function Oq(e,t,n){return Fq(await e.fetch(`${e.origin}/api/projects/${encodeURIComponent(t)}/providers`,{method:`PATCH`,headers:{"content-type":`application/json`},body:JSON.stringify(n)}))}async function kq(e,t,n){return Fq(await e.fetch(`${e.origin}/api/projects/${encodeURIComponent(t)}/subtitles`,{method:`PATCH`,headers:{"content-type":`application/json`},body:JSON.stringify(n)}))}async function Aq(e,t,n){return Fq(await e.client.projects[`:id`].stages[`:kind`].retry.$post({param:{id:t,kind:n}}))}async function jq(e,t,n){return Fq(await e.client.projects[`:id`].stages[`:kind`].rerun.$post({param:{id:t,kind:n}}))}async function Mq(e,t,n){return Fq(await e.fetch(`${e.origin}/api/projects/${encodeURIComponent(t)}/article`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({markdown:n})}))}async function Nq(e,t,n){return Fq(await e.client.projects[`:id`].images[`:outputId`].$delete({param:{id:t,outputId:n}}))}async function Pq(e,t,n){return Fq(await e.client.projects[`:id`].images[`:outputId`].regenerate.$post({param:{id:t,outputId:n}}))}async function Fq(e){if(e.ok)return{ok:!0,value:await e.json()};let t=await ao(e);if(t!==void 0&&wq.has(e.status))return{ok:!1,message:io(e,t).message};throw io(e,t)}async function Iq(e,t,n,r){let i=Cq.parse(r);return Fq(await e.fetch(`${e.origin}/api/projects/${encodeURIComponent(t)}/${n}`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(i)}))}function Lq(e){let{api:t}=I(),n=_(),[r,i]=(0,m.useState)(void 0),a=(0,m.useRef)(new Map),o=(0,m.useRef)(!1),s=it({mutationFn:async e=>{let r=e.action.kind;if(r!==`pause`&&r!==`cancel`)return zq(t,e.projectId,e.action);let i=`${e.projectId}:${r}`,o=a.current.get(i);if(!o){let r=n.getQueryData(V.project(e.projectId))?.revisionId;if(!r){let n=await QW(t,e.projectId);if(!n.ok)return{ok:!1,message:n.message};r=n.value.view.revision.id}o={baseRevisionId:r,idempotencyKey:crypto.randomUUID()},a.current.set(i,o)}let s=await(r===`pause`?Eq:Tq)(t,e.projectId,o);return a.current.delete(i),s},onMutate:()=>{i(void 0)},onSuccess:async(e,t)=>{e.ok?n.invalidateQueries({queryKey:V.projects}):i({message:e.message,stage:Rq(t.action)}),await n.invalidateQueries({queryKey:V.project(t.projectId)})},onSettled:()=>{o.current=!1},onError:(e,t)=>{i({message:e.message,stage:Rq(t.action)})}});return{run:(t,n)=>{o.current||(o.current=!0,s.mutate({projectId:e,action:t},{onSuccess:e=>{e.ok&&n?.()}}))},pending:s.isPending,refusal:r,dismissRefusal:()=>{i(void 0)}}}function Rq(e){switch(e.kind){case`cancel`:case`pause`:case`resume`:case`providers`:return;case`retry`:case`rerun`:return e.stage;case`subtitles`:return`video`;case`save-article`:return`article`;case`delete-image`:case`regenerate-image`:return`images`}}function zq(e,t,n){switch(n.kind){case`resume`:return Dq(e,t);case`providers`:return Oq(e,t,n.choices);case`subtitles`:return kq(e,t,n.subtitles);case`retry`:return Aq(e,t,n.stage);case`rerun`:return jq(e,t,n.stage);case`save-article`:return Mq(e,t,n.markdown);case`delete-image`:return Nq(e,t,n.outputId);case`regenerate-image`:return Pq(e,t,n.outputId)}}var Bq=200;function Vq(e,t=null){let{api:n,openEvents:r}=I(),i=_();(0,m.useEffect)(()=>{i.setQueryData(V.article(e,t),``),i.setQueryData(EP(e,t),[]);let a=()=>i.getQueryData(V.project(e))?.revisionId??null,o=Nk(()=>{i.invalidateQueries({queryKey:V.project(e)}),i.invalidateQueries({queryKey:V.projects}),i.invalidateQueries({queryKey:QG(e)})},Bq),s=My(r,Io(n,`projects/${e}`),{refetch:o.ask,accept:e=>e.type===`project.updated`||e.type===`project.state`&&e.revisionId===void 0||(e.revisionId??null)===a()||(o.ask(),!1),previewWriting:t=>{i.setQueryData(EP(e,a()),e=>DP(e??[],t))},appendArticle:t=>{i.setQueryData(V.article(e,a()),e=>`${e??``}${t}`)},patch:t=>{if(t.type===`stage.state`&&t.state===`running`&&(i.setQueryData(EP(e,a()),e=>(e??[]).filter(e=>e.stage!==t.stage||e.workId!==t.workId||e.revisionId!==t.revisionId)),t.stage===`article`&&i.setQueryData(V.article(e,a()),``)),t.type!==`project.state`&&t.workId!==void 0){o.ask();return}i.setQueryData(V.project(e),e=>jk(e,t))}});return()=>{s(),o.stop()}},[n,r,i,e,t])}function Hq({projectId:e}){return(0,h.jsx)(Uq,{projectId:e},e)}function Uq({projectId:e}){let{api:t}=I(),n=nt(hy(t,e)),r=nt(vy(t)),i=nt(by(t)),a=Lq(e),[o,s]=(0,m.useState)(),c=FA(e),l=(0,m.useRef)(void 0);if((0,m.useEffect)(()=>{if(c===void 0){l.current=void 0;return}n.data!==void 0&&l.current!==c&&(l.current=c,c===`download`&&s({projectId:e,stage:Bk(n.data.project.config)===`article`?`article`:`video`}))},[c,e,n.data]),Vq(e,n.data?.revisionId??null),n.error!==null)return(0,h.jsx)(`p`,{className:`text-body text-red`,children:n.error.message});if(n.data===void 0)return(0,h.jsx)(Wq,{});let{project:u,stages:d,outputs:f}=n.data,p=o?.projectId===e?o.stage:vK(d),g=t=>s({projectId:e,stage:t}),_=f.find(e=>e.role===`video`||e.role===`audio_export`)??(u.config.sources.video===`off`&&u.config.sources.audio===`off`?f.find(e=>e.role===`article_md`)??f.find(e=>e.role===`article_txt`):void 0),v=d.some(e=>e.state===`running`),y=u.status===`running`||u.status===`paused`||v||a.pending;return(0,h.jsx)(uG,{projectId:e,revisionId:n.data.revisionId,children:(0,h.jsx)(CP,{value:n.data.revisionId!==null,children:(0,h.jsxs)(`div`,{className:`mx-auto max-w-[1440px] space-y-5`,children:[(0,h.jsx)(sa,{to:`/`,className:`mb-[10px] block text-small text-ink2 hover:text-ink`,children:`< Projects`}),(0,h.jsxs)(`div`,{"data-tour":`project-controls`,children:[(0,h.jsx)(mK,{project:u,prompts:i.data?.prompts,actions:a,inFlight:v,primaryOutput:_,children:(0,h.jsx)(vq,{projectId:e,revisionId:n.data.revisionId,title:u.title})}),a.refusal===void 0||a.refusal.stage!==void 0?null:(0,h.jsx)(Fj,{className:`py-[10px]`,children:(0,h.jsx)(wG,{message:a.refusal.message,onDismiss:a.dismissRefusal})}),(0,h.jsx)(rq,{projectId:e,currentRevisionId:n.data.revisionId,renderEditor:e=>(0,h.jsx)(WK,{...e,renderContent:e=>(0,h.jsx)(zK,{...e},e.view.revision.id)})})]}),(0,h.jsx)(vP,{}),(0,h.jsx)(yK,{stages:d,project:u}),(0,h.jsx)(sK,{projectId:e,revisionId:n.data.revisionId,paused:u.status===`paused`,stages:d}),(0,h.jsxs)(`div`,{className:`grid items-start gap-5 lg:grid-cols-[240px_minmax(0,1fr)]`,children:[(0,h.jsx)(bK,{stages:d,project:u,outputs:f,selected:p,onSelect:g}),(0,h.jsx)(`div`,{className:`min-w-0`,children:d.map(e=>(0,h.jsx)(Sq,{active:e.kind===p,stage:e,project:u,outputs:f,providers:r.data?.providers??[],actions:a,children:(0,h.jsx)(qG,{stage:e,project:u,outputs:f,actions:a,busy:y})},e.id))})]})]})})})}function Wq(){return(0,h.jsxs)(`div`,{className:`mx-auto max-w-[1440px] space-y-5`,role:`status`,"aria-label":`Loading project`,children:[(0,h.jsx)(`div`,{className:`h-28 rounded-panel bg-panel`}),(0,h.jsx)(`div`,{className:`h-24 rounded-panel border border-line bg-panel`}),(0,h.jsxs)(`div`,{className:`grid items-start gap-5 lg:grid-cols-[240px_minmax(0,1fr)]`,children:[(0,h.jsx)(Pj,{children:[0,1,2,3,4,5].map(e=>(0,h.jsxs)(Fj,{children:[(0,h.jsx)(`span`,{className:`size-[10px] rounded-full bg-panel2`}),(0,h.jsx)(`span`,{className:`h-4 w-24 rounded-control bg-panel2`}),(0,h.jsx)(`span`,{className:`ml-auto h-3 w-16 rounded-control bg-panel2`})]},e))}),(0,h.jsx)(`div`,{className:`h-[560px] rounded-panel border border-line bg-panel`})]})]})}var Gq=`relative grid grid-cols-[14px_minmax(0,1fr)_auto_32px] items-center gap-x-[14px] gap-y-[4px] border-b border-line px-4 py-[14px] last:border-b-0 md:grid-cols-[14px_minmax(0,1fr)_140px_100px_32px]`,Kq=`col-start-2 row-start-2 text-small text-ink2 tabular-nums md:col-start-3 md:row-start-1`,qq=`col-start-3 row-start-1 justify-end md:col-start-4`,Jq=`relative z-10 col-start-4 row-start-1 size-8 p-0 md:col-start-5`;function Yq(){let{api:e}=I(),t=_(),n=nt(my(e)),[r,i]=(0,m.useState)(void 0),a=it({mutationFn:t=>lo(e,t),onSettled:async()=>{i(void 0),await t.invalidateQueries({queryKey:V.projects})}});return(0,h.jsxs)(`div`,{className:`mx-auto max-w-[1440px]`,children:[(0,h.jsxs)(`div`,{className:`mb-4 flex items-center`,children:[(0,h.jsx)(`h1`,{className:`text-title font-bold tracking-[-0.01em]`,children:`Projects`}),(0,h.jsx)(B,{variant:`accent`,className:`ml-auto`,asChild:!0,children:(0,h.jsx)(sa,{to:`/play`,children:`New run`})})]}),(0,h.jsx)(vP,{}),n.data?.projects.length===0?(0,h.jsx)(lj,{}):null,n.error===null?null:(0,h.jsx)(Pj,{children:(0,h.jsx)(`p`,{className:`px-4 py-[14px] text-body text-red`,children:n.error.message})}),n.data===void 0?n.error===null?(0,h.jsx)($q,{}):null:n.data.projects.length===0?(0,h.jsx)(Pj,{children:(0,h.jsxs)(`p`,{className:`px-4 py-7 text-body text-ink2`,children:[`No projects yet. Set up a run on`,` `,(0,h.jsx)(sa,{to:`/play`,className:`rounded-control text-ink underline underline-offset-[3px]`,children:`Play`}),`.`]})}):(0,h.jsx)(Pj,{children:n.data.projects.map(e=>(0,h.jsx)(Xq,{project:e,onDelete:()=>{i(e)}},e.id))}),a.error===null?null:(0,h.jsx)(`p`,{role:`alert`,className:`mt-[10px] text-label text-red`,children:a.error.message}),(0,h.jsx)(Nj,{open:r!==void 0,title:r===void 0?``:`Delete "${r.title}"?`,consequence:`Deletes the project and every file it produced.`,verb:`Delete`,pending:a.isPending,onConfirm:()=>{r!==void 0&&a.mutate(r.id)},onCancel:()=>{i(void 0)}})]})}function Xq({project:e,onDelete:t}){return(0,h.jsxs)(`div`,{className:Gq,children:[(0,h.jsx)(pK,{state:e.status,className:`col-start-1 row-start-1`}),(0,h.jsxs)(`span`,{className:`col-start-2 row-start-1 flex min-w-0 flex-wrap items-baseline gap-x-3`,children:[(0,h.jsx)(sa,{to:`/projects/$projectId`,params:{projectId:e.id},className:`rounded-control font-semibold after:absolute after:inset-0 after:content-['']`,children:e.title}),(0,h.jsx)(`span`,{className:`truncate text-small text-ink2`,children:Zq(e)})]}),(0,h.jsx)(`span`,{className:Kq,children:jc(e.createdAt)}),(0,h.jsx)(dK,{state:e.status,announce:e.title,className:qq}),(0,h.jsx)(Qq,{project:e,onDelete:t}),e.status===`running`?(0,h.jsx)(Ij,{current:e.progress,total:1}):null]})}function Zq(e){let t=e.config.articlePrompt;return[t===void 0||t===``?void 0:t,e.format].filter(e=>e!==void 0).join(` · `)}function Qq({project:e,onDelete:t}){let n=e.status===`running`;return(0,h.jsxs)(Rj,{children:[(0,h.jsx)(zj,{asChild:!0,children:(0,h.jsx)(B,{variant:`ghost`,"aria-label":`More for ${e.title}`,className:Jq,children:(0,h.jsx)(tj,{"aria-hidden":`true`,className:`size-4`})})}),(0,h.jsxs)(Bj,{children:[(0,h.jsx)(`span`,{title:n?`Cancel the run first`:void 0,children:(0,h.jsx)(Vj,{disabled:n,onSelect:t,children:`Delete`})}),n?(0,h.jsx)(`p`,{className:`engraved px-[10px] py-[5px] text-ink3`,children:`Cancel the run first`}):null]})]})}function $q(){return(0,h.jsx)(Pj,{children:[0,1,2,3,4,5].map(e=>(0,h.jsxs)(`div`,{className:Gq,children:[(0,h.jsx)(`span`,{className:`col-start-1 row-start-1 size-[10px] rounded-full bg-panel2`}),(0,h.jsx)(`span`,{className:`col-start-2 row-start-1 h-3 w-2/5 rounded-control bg-panel2`}),(0,h.jsx)(`span`,{className:`col-start-3 row-start-1 h-[10px] w-[90px] rounded-control bg-panel2 md:col-start-3`}),(0,h.jsx)(`span`,{className:`col-start-4 row-start-1 h-[10px] w-14 justify-self-end rounded-control bg-panel2 md:col-start-4`})]},e))})}var eJ=`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 tJ({promptId:e,kind:t,from:n,onLeave:r}){let{api:i}=I(),a=_(),o=PA(),s=nt(by(i)),c=(0,m.useId)(),l=(0,m.useId)(),u=(0,m.useId)(),d=(0,m.useId)(),f=(0,m.useId)(),[p,g]=kk(JSON.stringify(e===void 0?[`new`,t,n??null]:[`prompt`,e])),[v,y]=(0,m.useState)([]),[b,x]=(0,m.useState)(void 0),S=b!==void 0,[C,w]=(0,m.useState)(!1),[T,E]=(0,m.useState)(!1),D=s.data?.prompts,O=e??n,ee=O===void 0?void 0:D?.find(e=>e.id===O),k=ee===void 0?{kind:t,name:``,body:``}:e===void 0?{kind:ee.kind,name:`${ee.name} copy`,body:ee.body}:{kind:ee.kind,name:ee.name,body:ee.body},A=p??b??k,j=it({mutationFn:t=>jo(i,t,e),onSuccess:async(e,t)=>{if(!e.ok){y(e.fields);return}x(e.value),g(e=>e===t?void 0:e),o({type:`prompt-saved`,id:e.value.id,kind:e.value.kind}),await a.invalidateQueries({queryKey:by(i).queryKey})}}),M=it({mutationFn:e=>Mo(i,e),onSuccess:async()=>{w(!1),g(void 0),await a.invalidateQueries({queryKey:by(i).queryKey}),r(A.kind)}});$j(S,()=>{r(A.kind)});let N=(e,t)=>{g(e),y(e=>e.filter(e=>e.field!==t))},P=SM(A,v),F=CM(P),te=EM(A.body),ne=A.body.trim()===``?[]:wM(P),re=A.name.trim()===``?[]:TM(P);return NA({promptNamed:A.name.trim()!==``&&re.length===0,promptBodyReady:A.body.trim()!==``&&ne.length===0,promptHasKeywords:te.length>0&&ne.length===0,promptSaveReady:F===void 0&&!j.isPending&&!S,promptSaving:j.isPending||S,promptIsArticle:A.kind===`article`,promptIsImage:A.kind===`image`}),s.error===null?O!==void 0&&D===void 0?(0,h.jsx)(rM,{}):O!==void 0&&ee===void 0?(0,h.jsx)(nJ,{kind:t,children:`That prompt is gone. It may have been deleted in another tab.`}):(0,h.jsxs)(`div`,{className:`mx-auto max-w-[1440px]`,children:[(0,h.jsxs)(sa,{to:`/prompts`,search:{kind:A.kind},className:`mb-[10px] inline-flex items-center gap-1 text-small text-ink2 hover:text-ink`,children:[(0,h.jsx)(YA,{"aria-hidden":`true`,className:`size-[14px]`}),`Prompts`]}),(0,h.jsx)(`h1`,{className:`mb-4 text-title font-bold tracking-[-0.01em]`,children:e===void 0?`New prompt`:`Edit 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:`${nM} flex min-w-0 flex-col gap-[14px]`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-end gap-[14px]`,children:[(0,h.jsxs)(`div`,{"data-tour":`prompt-name`,className:`flex-1`,children:[(0,h.jsx)(oM,{htmlFor:c,className:`mb-[5px]`,children:`Name`}),(0,h.jsx)(cM,{id:c,value:A.name,"aria-invalid":re.length>0,"aria-describedby":re.length===0?void 0:l,onChange:e=>{N({...A,name:e.target.value},`name`)}}),re.length===0?null:(0,h.jsx)(`p`,{id:l,className:`mt-1 text-label text-red`,children:re.map(e=>e.message).join(` `)})]}),(0,h.jsx)(sM,{label:`Kind`,value:A.kind,options:Aj,onPick:e=>{N({...A,kind:e},`name`)}})]}),(0,h.jsxs)(`div`,{"data-tour":`prompt-body`,children:[A.kind===`narration`?(0,h.jsx)(B,{type:`button`,className:`mb-3`,onClick:()=>{A.body.trim()===``?N({...A,body:eJ},`body`):E(!0)},children:`Use Documentary Starter`}):null,(0,h.jsx)(oM,{htmlFor:u,className:`mb-[5px]`,children:`Body`}),(0,h.jsx)(kM,{id:u,value:A.body,invalid:ne.length>0,describedBy:ne.length===0?void 0:d,onChange:e=>{N({...A,body:e},`body`)}})]}),(0,h.jsx)(`div`,{"data-tour":`prompt-save`,children:(0,h.jsx)(tM,{onDelete:e===void 0?void 0:()=>{w(!0)},blocked:F,blockedId:f,pending:j.isPending,saved:S,cancel:(0,h.jsx)(B,{asChild:!0,children:(0,h.jsx)(sa,{to:`/prompts`,search:{kind:A.kind},onClick:()=>{g(void 0)},children:`Cancel`})}),errors:[j.error,M.error].flatMap(e=>e===null?[]:[e.message]),onSave:()=>{j.mutate(A)}})})]}),(0,h.jsx)(`div`,{"data-tour":`prompt-slots`,className:`${nM} flex flex-col gap-3 lg:sticky lg:top-6`,children:(0,h.jsx)(Zj,{slots:te,body:A.body,lint:ne,lintId:d})})]}),(0,h.jsx)(Nj,{open:T,title:`Replace this prompt body?`,consequence:`The documentary starter replaces the text in this editor. Nothing is saved until you choose Save.`,verb:`Use starter`,pending:!1,onConfirm:()=>{N({...A,body:eJ},`body`),E(!1)},onCancel:()=>E(!1)}),(0,h.jsx)(Nj,{open:C,title:`Delete "${A.name}"?`,consequence:`Projects that used it keep their text.`,verb:`Delete`,pending:M.isPending,onConfirm:()=>{e!==void 0&&M.mutate(e)},onCancel:()=>{w(!1)}})]}):(0,h.jsx)(nJ,{kind:A.kind,children:s.error.message})}function nJ({kind:e,children:t}){return(0,h.jsx)(iM,{back:(0,h.jsx)(sa,{to:`/prompts`,search:{kind:e},className:aM,children:`Back to Prompts`}),children:t})}var rJ=`grid grid-cols-[minmax(0,1fr)_auto_32px] items-center gap-x-[14px] gap-y-[6px] border-b border-line px-4 py-[14px] last:border-b-0 md:grid-cols-[260px_minmax(0,1fr)_auto_32px]`,iJ=`col-span-3 col-start-1 row-start-2 flex flex-wrap gap-[6px] md:col-span-1`,aJ=`md:col-start-2 md:row-start-1`;function oJ({kind:e,onKind:t}){let{api:n}=I(),r=_(),i=nt(by(n)),[a,o]=(0,m.useState)(void 0),s=it({mutationFn:e=>Mo(n,e),onSettled:async()=>{o(void 0),await r.invalidateQueries({queryKey:V.prompts})}}),c=i.data?.prompts.filter(t=>t.kind===e);return(0,h.jsxs)(`div`,{className:`mx-auto max-w-[1440px]`,children:[(0,h.jsx)(`h1`,{className:`mb-4 text-title font-bold tracking-[-0.01em]`,children:`Prompts`}),(0,h.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-4`,children:[(0,h.jsx)(Hj,{type:`single`,value:e,"aria-label":`Prompt kind`,className:`flex-wrap`,onValueChange:e=>{let n=Aj.find(t=>t.value===e);n!==void 0&&t(n.value)},children:Aj.map(e=>(0,h.jsx)(Uj,{value:e.value,children:e.label},e.value))}),(0,h.jsx)(`span`,{className:`flex-1`}),(0,h.jsx)(sJ,{kind:e})]}),i.error===null?null:(0,h.jsx)(Pj,{children:(0,h.jsx)(`p`,{className:`px-4 py-[14px] text-body text-red`,children:i.error.message})}),c===void 0?i.error===null?(0,h.jsx)(uJ,{}):null:c.length===0?(0,h.jsx)(cJ,{kind:e}):(0,h.jsx)(Pj,{children:c.map(e=>(0,h.jsxs)(`div`,{className:rJ,children:[(0,h.jsx)(`span`,{className:`col-start-1 row-start-1 font-semibold`,children:e.name}),(0,h.jsx)(`span`,{className:z(iJ,aJ),children:e.slots.map(e=>(0,h.jsx)(Lj,{name:e},e))}),(0,h.jsx)(B,{className:`col-start-2 row-start-1 md:col-start-3`,asChild:!0,children:(0,h.jsx)(sa,{to:`/prompts/$promptId`,params:{promptId:e.id},children:`Edit`})}),(0,h.jsx)(lJ,{prompt:e,onDelete:()=>{o(e)}})]},e.id))}),s.error===null?null:(0,h.jsx)(`p`,{className:`mt-[10px] text-label text-red`,children:s.error.message}),(0,h.jsx)(Nj,{open:a!==void 0,title:a===void 0?``:`Delete "${a.name}"?`,consequence:`Projects that used it keep their text.`,verb:`Delete`,pending:s.isPending,onConfirm:()=>{a!==void 0&&s.mutate(a.id)},onCancel:()=>{o(void 0)}})]})}function sJ({kind:e}){return(0,h.jsx)(B,{asChild:!0,children:(0,h.jsxs)(sa,{to:`/prompts/new`,search:{kind:e},children:[(0,h.jsx)(aj,{"aria-hidden":`true`,className:`size-[14px]`}),`New prompt`]})})}function cJ({kind:e}){return(0,h.jsx)(Pj,{children:(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4 px-4 py-7 text-ink2`,children:[(0,h.jsx)(`span`,{className:`max-w-[75ch]`,children:`No ${e} prompts yet. A prompt is text with {{keywords}}; each keyword becomes a field on Play.`}),(0,h.jsx)(sJ,{kind:e})]})})}function lJ({prompt:e,onDelete:t}){return(0,h.jsxs)(Rj,{children:[(0,h.jsx)(zj,{asChild:!0,children:(0,h.jsx)(B,{variant:`ghost`,"aria-label":`More for ${e.name}`,className:`col-start-3 row-start-1 size-8 p-0 md:col-start-4`,children:(0,h.jsx)(tj,{"aria-hidden":`true`,className:`size-4`})})}),(0,h.jsxs)(Bj,{children:[(0,h.jsx)(Vj,{asChild:!0,children:(0,h.jsx)(sa,{to:`/prompts/new`,search:{kind:e.kind,from:e.id},children:`Duplicate`})}),(0,h.jsx)(Vj,{onSelect:t,children:`Delete`})]})]})}function uJ(){return(0,h.jsx)(Pj,{children:[0,1,2].map(e=>(0,h.jsxs)(`div`,{className:rJ,children:[(0,h.jsx)(`span`,{className:`col-start-1 row-start-1 h-3 w-40 rounded-control bg-panel2`}),(0,h.jsxs)(`span`,{className:z(iJ,aJ),children:[(0,h.jsx)(`span`,{className:`h-[18px] w-14 rounded-control bg-panel2`}),(0,h.jsx)(`span`,{className:`h-[18px] w-[72px] rounded-control bg-panel2`})]}),(0,h.jsx)(`span`,{className:`col-start-2 row-start-1 h-7 w-12 rounded-control bg-panel2 md:col-start-3`})]},e))})}var dJ=cD(`kind`,[K({kind:hD(`once`),at:W().datetime({offset:!0})}).strict(),K({kind:hD(`daily`),time:W().regex(/^([01]\d|2[0-3]):[0-5]\d$/)}).strict(),K({kind:hD(`weekly`),time:W().regex(/^([01]\d|2[0-3]):[0-5]\d$/),days:G(KE().int().min(0).max(6)).min(1).max(7).readonly()}).strict()]);function fJ(e){try{return new Intl.DateTimeFormat(`en`,{timeZone:e}).format(),!0}catch{return!1}}var pJ=OE(),mJ=W().min(1).max(200).refine(e=>e===e.trim(),`Keyword names cannot start or end with spaces.`),hJ=K({title:W().trim().min(1).max(200),values:fD(mJ,W().max(1e4)).readonly()}).strict().readonly(),gJ=q([`skip`,`run-once`]);K({id:pJ,name:W().trim().min(1).max(200),templateId:pJ,templateVersion:KE().int().positive(),cadence:dJ,timezone:W().min(1).max(100).refine(fJ,`Choose a valid IANA timezone.`),missedPolicy:gJ.default(`skip`),overlapPolicy:hD(`skip`).default(`skip`),spendLimitCents:KE().int().nonnegative().nullable().default(null),items:G(hJ).max(49).default([]).readonly()}).strict().readonly().unwrap().extend({baseVersion:KE().int().positive(),mutationId:pJ}).strict().readonly(),K({id:pJ,baseVersion:KE().int().positive()}).strict().readonly(),K({id:pJ,baseVersion:KE().int().positive()}).strict().readonly();var _J=K({id:pJ,name:W(),templateId:pJ,templateVersion:KE().int().positive(),cadence:dJ,timezone:W(),missedPolicy:gJ,overlapPolicy:hD(`skip`),spendLimitCents:KE().int().nonnegative().nullable(),items:G(hJ).readonly(),status:q([`active`,`paused`,`completed`,`canceled`]),version:KE().int().positive(),nextRunAt:W().datetime({offset:!0}).nullable(),createdAt:W(),updatedAt:W(),deletedAt:W().datetime({offset:!0}).nullable()}).strict().readonly(),vJ=K({id:pJ,scheduleId:pJ,scheduledFor:W().datetime({offset:!0}),status:q([`running`,`succeeded`,`failed`,`skipped`]),requestId:pJ.nullable(),projectIds:G(W()).readonly(),estimate:eD().nullable(),startedAt:W().datetime({offset:!0}),endedAt:W().datetime({offset:!0}).nullable(),error:W().nullable()}).strict().readonly(),yJ=K({title:W(),detail:W().optional(),reason:W().optional()}),bJ=K({schedules:G(_J)}),xJ=K({schedule:_J,runs:G(vJ)}),SJ=e=>`${e.origin}/api/schedules`;async function CJ(e,t){let n;try{n=await e.json()}catch{throw io(e,void 0)}if(e.ok)return{ok:!0,value:t.parse(n)};let r=yJ.safeParse(n);if(!r.success)throw io(e,void 0);let i=r.data.detail??r.data.title;if(![400,404,409].includes(e.status))throw Error(i);return{ok:!1,message:i,reason:r.data.reason??`invalid-request`}}var wJ=(e,t)=>({method:e,headers:{"content-type":`application/json`},body:JSON.stringify(t)}),TJ=[`schedules`];function EJ(e){return{queryKey:TJ,queryFn:async()=>{let t=await CJ(await e.fetch(SJ(e)),bJ);if(!t.ok)throw Error(t.message);return t.value.schedules},refetchInterval:3e4}}async function DJ(e,t){return CJ(await e.fetch(`${SJ(e)}/${encodeURIComponent(t)}`),xJ)}async function OJ(e,t){return CJ(await e.fetch(SJ(e),wJ(`POST`,t)),_J)}async function kJ(e,t,n){return CJ(await e.fetch(`${SJ(e)}/${encodeURIComponent(t)}`,wJ(`PUT`,n)),_J)}async function AJ(e,t,n,r){return CJ(await e.fetch(`${SJ(e)}/${encodeURIComponent(t)}/${n}`,wJ(`POST`,{baseVersion:r})),_J)}async function jJ(e,t,n){return CJ(await e.fetch(`${SJ(e)}/${encodeURIComponent(t)}`,wJ(`DELETE`,{baseVersion:n})),K({deleted:hD(!0)}))}var Y=l(o(((e,t)=>{(function(n,r){typeof e==`object`&&t!==void 0?t.exports=r():typeof define==`function`&&define.amd?define(r):(n||=self,n.JSBI=r())})(e,function(){var e=Math.imul,t=Math.clz32;function n(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function r(e){if(Array.isArray(e))return e}function i(e){if(e===void 0)throw ReferenceError(`this hasn't been initialised - super() hasn't been called`);return e}function a(e,t,n){return t=d(t),_(e,m()?Reflect.construct(t,n||[],d(e).constructor):t.apply(e,n))}function o(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function s(e,t,n){if(m())return Reflect.construct.apply(null,arguments);var r=[null];r.push.apply(r,t);var i=new(e.bind.apply(e,r));return n&&v(i,n.prototype),i}function c(e,t){for(var n,r=0;r<t.length;r++)n=t[r],n.enumerable=n.enumerable||!1,n.configurable=!0,`value`in n&&(n.writable=!0),Object.defineProperty(e,x(n.key),n)}function l(e,t,n){return t&&c(e.prototype,t),n&&c(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function u(e,t){var n=typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(!n){if(Array.isArray(e)||(n=C(e))||t&&e&&typeof e.length==`number`){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw TypeError(`Invalid attempt to iterate non-iterable instance.
135
+ `),s].find(e=>e?.trim())??`No text was recorded for this part.`}catch{return`Recorded text cannot be decoded.`}}function nq({projectId:e,pending:t,onRestore:n}){let{api:r}=I(),[i,a]=(0,m.useState)(),o=nt({queryKey:V.revisions(e),queryFn:async()=>{let t=await nG(r,e);if(!t.ok)throw Error(t.message);return t.value.revisions}}),s=nt({queryKey:V.revision(e,i??``),enabled:i!==void 0,queryFn:async()=>{if(i===void 0)throw Error(`Choose a revision.`);let t=await rG(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`));return(0,h.jsxs)(`section`,{"aria-label":`Project history`,className:`space-y-3 rounded-panel border border-line bg-panel p-4`,children:[(0,h.jsx)(`h2`,{children:`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)(B,{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`,{children:c.revision.config.title}),l===void 0?null:(0,h.jsxs)(`span`,{className:`inline-flex gap-3`,children:[(0,h.jsx)(`a`,{href:cG(r,e,c.revision.id),download:!0,children:`Download all images`}),(0,h.jsx)(lG,{projectId:e,asset:``,folder:{revisionId:c.revision.id,recordId:l.recordId}})]}),(0,h.jsx)(`ul`,{className:`space-y-3`,children:c.outputs.map(t=>(0,h.jsxs)(`li`,{className:`space-y-2 rounded-control border border-line p-3`,children:[qK(t.output),` · `,t.state,t.selected?``:` · Earlier result`,`:`,` `,t.available?(0,h.jsx)(`a`,{href:oG(r,e,c.revision.id,t.recordId),children:`Download`}):`File missing`,t.available?(0,h.jsx)(lG,{projectId:e,asset:``,folder:{revisionId:c.revision.id,recordId:t.recordId}}):null,t.available?(0,h.jsxs)(`details`,{children:[(0,h.jsx)(`summary`,{children:`Preview retained output`}),t.output.role===`video`?(0,h.jsx)(`video`,{className:`max-h-[480px] max-w-full`,controls:!0,preload:`metadata`,src:oG(r,e,c.revision.id,t.recordId)}):[`audio_export`,`audio_body`,`audio_intro`,`audio_outro`].includes(t.output.role)?(0,h.jsx)(`audio`,{className:`max-w-full`,controls:!0,preload:`metadata`,src:oG(r,e,c.revision.id,t.recordId)}):t.output.role===`image`||t.output.role===`thumbnail`?(0,h.jsx)(`img`,{className:`max-h-[480px] max-w-full object-contain`,alt:qK(t.output),loading:`lazy`,src:oG(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)(`audio`,{className:`max-w-full`,controls:!0,preload:`metadata`,src:oG(r,e,c.revision.id,t.recordId)}),(0,h.jsx)(`a`,{href:oG(r,e,c.revision.id,t.recordId),children:`Download narration part`}),(0,h.jsx)(lG,{projectId:e,asset:``,folder:{revisionId:c.revision.id,recordId:t.recordId}})]}):(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:tq(e.piece.payload)})]})},e.recordId))}),(0,h.jsx)(B,{type:`button`,disabled:t,onClick:()=>n(c.revision.id),children:`Restore this revision`})]})]})}function rq(e,t,n){let r=JSON.stringify(t);return e?.payload===r?e:{payload:r,idempotencyKey:n()}}function iq({projectId:e,currentRevisionId:t,renderEditor:n}){let{api:r}=I(),i=_(),a=nt({queryKey:V.revision(e,t??``),enabled:t!==null,queryFn:async()=>{if(t===null)throw Error(`Prepare this legacy project before inspecting revision status.`);let n=await rG(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)(!1),[f,p]=(0,m.useState)(),[g,v]=(0,m.useState)(!1),[y,b]=(0,m.useState)(!1),[x,S]=(0,m.useState)(),[C,w]=(0,m.useState)(),T=(0,m.useRef)(void 0),E=(0,m.useRef)(void 0),D=(0,m.useRef)(void 0),O=c!==void 0&&o!==void 0&&t!==null&&t!==o.revision.id,ee=(0,m.useRef)(!1);async function k(e){if(!ee.current){ee.current=!0,v(!0),S(void 0);try{await e()}catch(e){S(e instanceof Error?e.message:String(e))}finally{ee.current=!1,v(!1)}}}async function A(t){let n=await $W(r,e);if(!n.ok){w(n);return}return w(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 j(t){let n=await co(r,e);if(i.setQueryData(V.project(e),n),await i.invalidateQueries({queryKey:V.revisions(e)}),!t.current||n.revisionId!==t.revision.id){w({ok:!1,reason:`conflict`,message:`The project changed again. Your draft is preserved.`,currentRevisionId:n.revisionId,fields:[]});return}s(t),l(void 0),w(void 0),p(void 0)}async function M(){if(y||o===void 0||c===void 0)return;let t={baseRevisionId:o.revision.id,edit:c},n=rq(T.current,t,()=>crypto.randomUUID());T.current=n;let i=await eG(r,e,{...t,idempotencyKey:n.idempotencyKey});if(!i.ok){w(i);return}await j(i.value.view),T.current=void 0}async function N(){let t=await A(!1);if(t===void 0)return;let n=await iG(r,e,{baseRevisionId:t.revision.id,request:{kind:`allAffected`}});if(!n.ok){w(n);return}p(n.value.value),D.current=void 0}async function P(t){if(f===void 0)return;let n={baseRevisionId:f.baseRevisionId,previewId:f.id,...t},a=rq(D.current,n,()=>crypto.randomUUID());D.current=a;let o=await aG(r,e,{...n,idempotencyKey:a.idempotencyKey});if(!o.ok){w(o),(o.reason===`stale-preview`||o.reason===`conflict`)&&p(void 0);return}D.current=void 0,p(void 0),await i.invalidateQueries({queryKey:V.project(e)})}async function F(t){let n=o??a.data??await A(!1);if(n===void 0)return;let i={baseRevisionId:n.revision.id,targetRevisionId:t},s=rq(E.current,i,()=>crypto.randomUUID());E.current=s;let c=await tG(r,e,{...i,idempotencyKey:s.idempotencyKey});if(!c.ok){w(c);return}await j(c.value.view),E.current=void 0}return(0,h.jsxs)(`section`,{"aria-label":`Project revisions`,className:`space-y-4`,children:[a.error===null?null:(0,h.jsx)(`p`,{role:`alert`,children:a.error.message}),a.data===void 0?null:(0,h.jsx)(`ul`,{"aria-label":`Saved output status`,className:`flex flex-wrap gap-x-4 gap-y-1 text-small text-ink2`,children:a.data.outputs.filter(e=>e.selected).map(e=>(0,h.jsxs)(`li`,{children:[qK(e.output),`:`,` `,e.available?e.state===`ready`?`Ready`:e.state===`outdated`?`Needs rebuild; retained output available`:`Provided content needs review`:`Retained file missing`]},e.recordId))}),(0,h.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[(0,h.jsx)(B,{type:`button`,disabled:g||y||c!==void 0||f!==void 0,onClick:()=>void k(async()=>{await A(!0)}),children:`Edit project`}),(0,h.jsx)(B,{type:`button`,onClick:()=>d(!u),children:`History`}),(0,h.jsx)(B,{type:`button`,disabled:g||y||c!==void 0||f!==void 0,onClick:()=>void k(N),children:`Rebuild affected outputs`})]}),x===void 0?null:(0,h.jsx)(`p`,{role:`alert`,children:x}),C===void 0?null:(0,h.jsx)(`p`,{role:`alert`,children:C.message}),c===void 0&&C?.reason===`conflict`?(0,h.jsx)(B,{type:`button`,disabled:g,onClick:()=>void k(async()=>{E.current=void 0,D.current=void 0,p(void 0),await A(!1),await i.invalidateQueries({queryKey:V.project(e)})}),children:`Reload current revision`}):null,O?(0,h.jsx)(`p`,{role:`status`,children:`A newer revision is available. Your unsaved changes are kept below.`}):null,o===void 0||c===void 0?null:(0,h.jsxs)(`form`,{className:`space-y-4 rounded-panel border border-line bg-panel p-4`,onSubmit:e=>{e.preventDefault(),k(M)},children:[(0,h.jsx)(`fieldset`,{disabled:g,children:n({view:o,edit:c,fields:C?.fields??[],onChange:l,onPending:b})}),(0,h.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[(0,h.jsx)(B,{variant:`primary`,type:`submit`,disabled:g||y,children:`Save changes`}),(0,h.jsx)(B,{type:`button`,disabled:g||y,onClick:()=>{l(void 0),w(void 0),b(!1),T.current=void 0},children:`Discard changes`}),O||C?.reason===`conflict`?(0,h.jsx)(B,{type:`button`,disabled:g||y,onClick:()=>void k(async()=>{T.current=void 0,b(!1),await A(!0),w(void 0)}),children:`Reload current revision and discard my draft`}):null]})]}),u?(0,h.jsx)(nq,{projectId:e,pending:g||y||c!==void 0||f!==void 0,onRestore:e=>void k(()=>F(e))}):null,f===void 0?null:(0,h.jsx)(YK,{preview:f,pending:g,onStart:e=>void k(()=>P(e)),onCancel:()=>{p(void 0),D.current=void 0}},f.id)]})}var aq=K({id:OE(),name:W(),version:KE().int().positive(),updatedAt:W()}),oq=aq.extend({document:gO}),sq=oD([oq,K({template:oq}).transform(e=>e.template)]),cq=K({title:W(),detail:W().optional(),reason:W().optional()}),lq=[`project-templates`],uq=e=>`${e.origin}/api/project-templates`;async function dq(e,t){let n;try{n=await e.json()}catch{throw io(e,void 0)}if(e.ok)return{ok:!0,value:t.parse(n)};let r=cq.safeParse(n);if(!r.success)throw io(e,void 0);let i=r.data.detail??r.data.title;if(![400,404,409].includes(e.status))throw Error(i);return{ok:!1,message:i,reason:r.data.reason??`invalid-request`}}var fq=(e,t)=>({method:e,headers:{"content-type":`application/json`},body:JSON.stringify(t)});async function pq(e){return dq(await e.fetch(uq(e)),K({templates:G(aq)}).transform(e=>e.templates))}function mq(e){return{queryKey:lq,queryFn:async()=>{let t=await pq(e);if(!t.ok)throw Error(t.message);return t.value}}}async function hq(e,t){let n=K({id:OE(),name:W().trim().min(1),document:gO}).parse(t);return dq(await e.fetch(uq(e),fq(`POST`,n)),sq)}async function gq(e,t,n){let r=K({id:OE(),name:W().trim().min(1).max(200),revisionId:W().min(1).max(64)}).parse(n);return dq(await e.fetch(`${uq(e)}/from-project/${encodeURIComponent(t)}`,fq(`POST`,r)),sq)}async function _q(e,t){let n=await e.fetch(`${uq(e)}/${encodeURIComponent(t.id)}`,fq(`DELETE`,{baseVersion:t.version}));return n.ok?{ok:!0,value:null}:dq(n,QE())}async function vq(e,t,n){let r=K({id:OE(),version:KE().int().positive()}).parse({id:n,version:t.version});return dq(await e.fetch(`${uq(e)}/${encodeURIComponent(t.id)}/instantiate`,fq(`POST`,r)),oD([EO,K({draft:EO}).transform(e=>e.draft)]))}function yq({projectId:e,revisionId:t,title:n}){let{api:r}=I(),i=_(),a=(0,m.useId)(),[o,s]=(0,m.useState)(null),[c,l]=(0,m.useState)(!1),[u,d]=(0,m.useState)(null),[f,p]=(0,m.useState)(!1),g=(0,m.useRef)(!1),v=(0,m.useRef)(null);async function y(){if(!o||g.current||!o.name.trim())return;g.current=!0,l(!0),d(null);let t=JSON.stringify([e,o.revisionId,o.name.trim()]);v.current?.key!==t&&(v.current={key:t,id:crypto.randomUUID()});try{let t=await gq(r,e,{id:v.current.id,name:o.name.trim(),revisionId:o.revisionId});if(!t.ok){v.current=null,d(t.message);return}v.current=null,s(null),p(!0),await i.invalidateQueries({queryKey:lq})}catch(e){d(e instanceof Error?e.message:`Could not save the template.`)}finally{g.current=!1,l(!1)}}return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(B,{disabled:t===null||c,onClick:()=>{t!==null&&(s({revisionId:t,name:n}),d(null),p(!1))},children:`Save as template`}),f?(0,h.jsx)(`p`,{role:`status`,children:`Template saved.`}):null,(0,h.jsx)(cy,{open:o!==null,onOpenChange:e=>{!e&&!g.current&&s(null)},children:(0,h.jsxs)(dy,{children:[(0,h.jsx)(fy,{children:`Save as template`}),(0,h.jsx)(py,{children:`Save this revision’s setup for a fresh Play draft. This does not rebuild the project.`}),(0,h.jsxs)(`form`,{className:`space-y-4`,onSubmit:e=>{e.preventDefault(),y()},children:[(0,h.jsx)(`label`,{htmlFor:a,children:`Template name`}),(0,h.jsx)(cM,{id:a,autoFocus:!0,required:!0,maxLength:200,disabled:c,value:o?.name??``,onChange:e=>{let t=e.target.value;s(e=>e&&{...e,name:t})}}),u?(0,h.jsx)(`p`,{role:`alert`,className:`text-red`,children:u}):null,(0,h.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,h.jsx)(B,{type:`button`,disabled:c,onClick:()=>s(null),children:`Cancel`}),(0,h.jsx)(B,{type:`submit`,disabled:c||!o?.name.trim(),children:`Save template`})]})]})]})})]})}function bq(e,t){switch(e){case`research`:case`article`:return t.llm?.provider;case`audio`:return t.audio?.provider;case`images`:case`thumbnail`:return t.images?.provider;case`video`:return}}function xq(e,t,n){if(e===`audio`&&t.narrationPrompt&&ak(t)){let e=xq(`article`,t,n);if(e!==void 0)return e}let r=bq(e,t);if(r===void 0||r===``)return;let i=n.find(e=>e.id===r);if(i===void 0)return;let a=uN(i.readiness);return a===void 0?void 0:{label:a,provider:r}}var Sq={research:`Research notes`,article:`Article workspace`,audio:`Narration`,images:`Image library`,thumbnail:`Thumbnail preview`,video:`Preview & export`};function Cq({stage:e,project:t,outputs:n,providers:r,actions:i,children:a,active:o=!0}){let s=(0,m.useContext)(wP),c=Vk(e.kind,t.config),l=t.status===`paused`?{...i,pending:!0}:i,u=xq(e.kind,t.config,r),d=i.refusal?.stage===e.kind?i.refusal.message:void 0,f=e.state===`failed`||e.state===`canceled`,p=n.some(t=>t.stageKind===e.kind&&t.role!==`instructions`)||e.state===`running`||e.state===`done`||e.state===`provided`||e.kind===`video`&&e.state!==`skipped`,g=e.progressTotal===null||e.progressTotal<=0?void 0:Math.min(100,Math.max(0,Math.round((e.progressCurrent??0)/e.progressTotal*100)));return(0,h.jsxs)(`section`,{"data-tour":`project-${e.kind}`,hidden:!o,"aria-label":`${c} workspace`,className:o?`min-w-0 rounded-panel border border-line bg-panel`:`hidden`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 border-b border-line px-5 py-4`,children:[(0,h.jsx)(Pc,{kind:e.kind,className:`text-ink2`}),(0,h.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,h.jsx)(`h2`,{className:`text-row font-bold`,children:e.kind===`video`&&c===`Audio export`?`Listen & export`:Sq[e.kind]}),(0,h.jsx)(`p`,{className:`mt-1 text-small text-ink2`,children:Gk(e,n,t)})]}),(0,h.jsx)(fK,{state:e.state})]}),e.state===`running`?(0,h.jsxs)(`div`,{className:`border-b border-line px-5 py-3`,children:[(0,h.jsxs)(`div`,{className:`mb-2 flex justify-between text-small text-run-text`,children:[(0,h.jsxs)(`span`,{children:[c,` in progress`]}),g===void 0?(0,h.jsx)(`span`,{children:`Waiting for provider progress`}):(0,h.jsxs)(`span`,{className:`tabular-nums`,children:[g,`%`]})]}),(0,h.jsx)(`div`,{role:`progressbar`,"aria-label":`${c} progress`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":g,className:`h-1.5 overflow-hidden rounded-control bg-panel2`,children:(0,h.jsx)(`div`,{className:`h-full origin-left bg-accent`,style:{transform:`scaleX(${(g??0)/100})`}})})]}):null,f?(0,h.jsxs)(`div`,{className:`m-5 rounded-control border border-red/30 bg-red-tint p-4`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,h.jsx)(`p`,{className:`min-w-0 flex-1 text-small text-red`,children:e.state===`failed`?`${c} needs attention.`:`${c} was canceled.`}),(0,h.jsx)(`span`,{className:`text-label text-ink2`,children:Kk(e)}),s?null:(0,h.jsx)(`button`,{type:`button`,disabled:u!==void 0||l.pending,onClick:()=>l.run({kind:`retry`,stage:e.kind}),className:`rounded-control border border-red px-3 py-2 text-small text-ink hover:bg-panel2 disabled:opacity-50`,children:u?.label??`Retry stage`})]}),(0,h.jsx)(`p`,{className:`mt-2 text-small text-ink2`,children:s?`Use Rebuild affected outputs to review the work and cost before retrying.`:t.status===`paused`?`Resume the project to continue with its saved settings.`:`Retry keeps completed outputs. To change the provider or model, open Run settings.`}),e.failureReason?(0,h.jsxs)(`details`,{className:`mt-3`,children:[(0,h.jsx)(`summary`,{className:`cursor-pointer text-small text-red`,children:`Error details`}),(0,h.jsx)(`span`,{className:`mt-2 block max-h-48 overflow-auto whitespace-pre-wrap break-words text-label text-ink2`,children:e.failureReason})]}):null,u?(0,h.jsxs)(`p`,{className:`mt-3 text-small text-ink2`,children:[u.label,` for `,u.provider,`.`,` `,(0,h.jsx)(sa,{to:`/settings`,className:`underline underline-offset-4`,children:`Open Settings`})]}):null]}):null,d?(0,h.jsx)(`div`,{className:`px-5 pt-4`,children:(0,h.jsx)(TG,{message:d,onDismiss:i.dismissRefusal})}):null,e.state===`running`&&e.kind!==`article`&&e.kind!==`images`&&e.kind!==`video`?(0,h.jsx)(kP,{projectId:t.id,stage:e.kind}):null,p?a:f?null:(0,h.jsxs)(`div`,{className:`flex min-h-64 flex-col items-center justify-center gap-3 p-8 text-center`,children:[(0,h.jsx)(Pc,{kind:e.kind,className:`size-8 text-ink3`}),(0,h.jsx)(`p`,{className:`text-body text-ink2`,children:e.state===`skipped`?`${c} was switched off for this run.`:t.status===`paused`?`Resume the project when you are ready to continue.`:`This stage will start when its inputs are ready.`}),(0,h.jsx)(`p`,{className:`max-w-md text-small text-ink3`,children:e.state===`skipped`?`The other stages are available from the list.`:`You can review completed outputs while the project runs.`})]})]})}var wq=K({baseRevisionId:W().min(1).max(64),idempotencyKey:OE()}).strict(),Tq=new Set([400,404,409]);async function Eq(e,t,n){return Lq(e,t,`cancel`,n)}async function Dq(e,t,n){return Lq(e,t,`pause`,n)}async function Oq(e,t){return Iq(await e.client.projects[`:id`].resume.$post({param:{id:t}}))}async function kq(e,t,n){return Iq(await e.fetch(`${e.origin}/api/projects/${encodeURIComponent(t)}/providers`,{method:`PATCH`,headers:{"content-type":`application/json`},body:JSON.stringify(n)}))}async function Aq(e,t,n){return Iq(await e.fetch(`${e.origin}/api/projects/${encodeURIComponent(t)}/subtitles`,{method:`PATCH`,headers:{"content-type":`application/json`},body:JSON.stringify(n)}))}async function jq(e,t,n){return Iq(await e.client.projects[`:id`].stages[`:kind`].retry.$post({param:{id:t,kind:n}}))}async function Mq(e,t,n){return Iq(await e.client.projects[`:id`].stages[`:kind`].rerun.$post({param:{id:t,kind:n}}))}async function Nq(e,t,n){return Iq(await e.fetch(`${e.origin}/api/projects/${encodeURIComponent(t)}/article`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({markdown:n})}))}async function Pq(e,t,n){return Iq(await e.client.projects[`:id`].images[`:outputId`].$delete({param:{id:t,outputId:n}}))}async function Fq(e,t,n){return Iq(await e.client.projects[`:id`].images[`:outputId`].regenerate.$post({param:{id:t,outputId:n}}))}async function Iq(e){if(e.ok)return{ok:!0,value:await e.json()};let t=await ao(e);if(t!==void 0&&Tq.has(e.status))return{ok:!1,message:io(e,t).message};throw io(e,t)}async function Lq(e,t,n,r){let i=wq.parse(r);return Iq(await e.fetch(`${e.origin}/api/projects/${encodeURIComponent(t)}/${n}`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(i)}))}function Rq(e){let{api:t}=I(),n=_(),[r,i]=(0,m.useState)(void 0),a=(0,m.useRef)(new Map),o=(0,m.useRef)(!1),s=it({mutationFn:async e=>{let r=e.action.kind;if(r!==`pause`&&r!==`cancel`)return Bq(t,e.projectId,e.action);let i=`${e.projectId}:${r}`,o=a.current.get(i);if(!o){let r=n.getQueryData(V.project(e.projectId))?.revisionId;if(!r){let n=await $W(t,e.projectId);if(!n.ok)return{ok:!1,message:n.message};r=n.value.view.revision.id}o={baseRevisionId:r,idempotencyKey:crypto.randomUUID()},a.current.set(i,o)}let s=await(r===`pause`?Dq:Eq)(t,e.projectId,o);return a.current.delete(i),s},onMutate:()=>{i(void 0)},onSuccess:async(e,t)=>{e.ok?n.invalidateQueries({queryKey:V.projects}):i({message:e.message,stage:zq(t.action)}),await n.invalidateQueries({queryKey:V.project(t.projectId)})},onSettled:()=>{o.current=!1},onError:(e,t)=>{i({message:e.message,stage:zq(t.action)})}});return{run:(t,n)=>{o.current||(o.current=!0,s.mutate({projectId:e,action:t},{onSuccess:e=>{e.ok&&n?.()}}))},pending:s.isPending,refusal:r,dismissRefusal:()=>{i(void 0)}}}function zq(e){switch(e.kind){case`cancel`:case`pause`:case`resume`:case`providers`:return;case`retry`:case`rerun`:return e.stage;case`subtitles`:return`video`;case`save-article`:return`article`;case`delete-image`:case`regenerate-image`:return`images`}}function Bq(e,t,n){switch(n.kind){case`resume`:return Oq(e,t);case`providers`:return kq(e,t,n.choices);case`subtitles`:return Aq(e,t,n.subtitles);case`retry`:return jq(e,t,n.stage);case`rerun`:return Mq(e,t,n.stage);case`save-article`:return Nq(e,t,n.markdown);case`delete-image`:return Pq(e,t,n.outputId);case`regenerate-image`:return Fq(e,t,n.outputId)}}var Vq=200;function Hq(e,t=null){let{api:n,openEvents:r}=I(),i=_();(0,m.useEffect)(()=>{i.setQueryData(V.article(e,t),``),i.setQueryData(DP(e,t),[]);let a=()=>i.getQueryData(V.project(e))?.revisionId??null,o=Nk(()=>{i.invalidateQueries({queryKey:V.project(e)}),i.invalidateQueries({queryKey:V.projects}),i.invalidateQueries({queryKey:$G(e)})},Vq),s=My(r,Io(n,`projects/${e}`),{refetch:o.ask,accept:e=>e.type===`project.updated`||e.type===`project.state`&&e.revisionId===void 0||(e.revisionId??null)===a()||(o.ask(),!1),previewWriting:t=>{i.setQueryData(DP(e,a()),e=>OP(e??[],t))},appendArticle:t=>{i.setQueryData(V.article(e,a()),e=>`${e??``}${t}`)},patch:t=>{if(t.type===`stage.state`&&t.state===`running`&&(i.setQueryData(DP(e,a()),e=>(e??[]).filter(e=>e.stage!==t.stage||e.workId!==t.workId||e.revisionId!==t.revisionId)),t.stage===`article`&&i.setQueryData(V.article(e,a()),``)),t.type!==`project.state`&&t.workId!==void 0){o.ask();return}i.setQueryData(V.project(e),e=>jk(e,t))}});return()=>{s(),o.stop()}},[n,r,i,e,t])}function Uq({projectId:e}){return(0,h.jsx)(Wq,{projectId:e},e)}function Wq({projectId:e}){let{api:t}=I(),n=nt(hy(t,e)),r=nt(vy(t)),i=nt(by(t)),a=Rq(e),[o,s]=(0,m.useState)(),c=FA(e),l=(0,m.useRef)(void 0);if((0,m.useEffect)(()=>{if(c===void 0){l.current=void 0;return}n.data!==void 0&&l.current!==c&&(l.current=c,c===`download`&&s({projectId:e,stage:Bk(n.data.project.config)===`article`?`article`:`video`}))},[c,e,n.data]),Hq(e,n.data?.revisionId??null),n.error!==null)return(0,h.jsx)(`p`,{className:`text-body text-red`,children:n.error.message});if(n.data===void 0)return(0,h.jsx)(Gq,{});let{project:u,stages:d,outputs:f}=n.data,p=o?.projectId===e?o.stage:yK(d),g=t=>s({projectId:e,stage:t}),_=f.find(e=>e.role===`video`||e.role===`audio_export`)??(u.config.sources.video===`off`&&u.config.sources.audio===`off`?f.find(e=>e.role===`article_md`)??f.find(e=>e.role===`article_txt`):void 0),v=d.some(e=>e.state===`running`),y=u.status===`running`||u.status===`paused`||v||a.pending;return(0,h.jsx)(dG,{projectId:e,revisionId:n.data.revisionId,children:(0,h.jsx)(wP,{value:n.data.revisionId!==null,children:(0,h.jsxs)(`div`,{className:`mx-auto max-w-[1440px] space-y-5`,children:[(0,h.jsx)(sa,{to:`/`,className:`mb-[10px] block text-small text-ink2 hover:text-ink`,children:`< Projects`}),(0,h.jsxs)(`div`,{"data-tour":`project-controls`,children:[(0,h.jsx)(hK,{project:u,prompts:i.data?.prompts,actions:a,inFlight:v,primaryOutput:_,children:(0,h.jsx)(yq,{projectId:e,revisionId:n.data.revisionId,title:u.title})}),a.refusal===void 0||a.refusal.stage!==void 0?null:(0,h.jsx)(Fj,{className:`py-[10px]`,children:(0,h.jsx)(TG,{message:a.refusal.message,onDismiss:a.dismissRefusal})}),(0,h.jsx)(iq,{projectId:e,currentRevisionId:n.data.revisionId,renderEditor:e=>(0,h.jsx)(GK,{...e,renderContent:e=>(0,h.jsx)(BK,{...e},e.view.revision.id)})})]}),(0,h.jsx)(yP,{}),(0,h.jsx)(bK,{stages:d,project:u}),(0,h.jsx)(cK,{projectId:e,revisionId:n.data.revisionId,paused:u.status===`paused`,stages:d}),(0,h.jsxs)(`div`,{className:`grid items-start gap-5 lg:grid-cols-[240px_minmax(0,1fr)]`,children:[(0,h.jsx)(xK,{stages:d,project:u,outputs:f,selected:p,onSelect:g}),(0,h.jsx)(`div`,{className:`min-w-0`,children:d.map(e=>(0,h.jsx)(Cq,{active:e.kind===p,stage:e,project:u,outputs:f,providers:r.data?.providers??[],actions:a,children:(0,h.jsx)(JG,{stage:e,project:u,outputs:f,actions:a,busy:y})},e.id))})]})]})})})}function Gq(){return(0,h.jsxs)(`div`,{className:`mx-auto max-w-[1440px] space-y-5`,role:`status`,"aria-label":`Loading project`,children:[(0,h.jsx)(`div`,{className:`h-28 rounded-panel bg-panel`}),(0,h.jsx)(`div`,{className:`h-24 rounded-panel border border-line bg-panel`}),(0,h.jsxs)(`div`,{className:`grid items-start gap-5 lg:grid-cols-[240px_minmax(0,1fr)]`,children:[(0,h.jsx)(Pj,{children:[0,1,2,3,4,5].map(e=>(0,h.jsxs)(Fj,{children:[(0,h.jsx)(`span`,{className:`size-[10px] rounded-full bg-panel2`}),(0,h.jsx)(`span`,{className:`h-4 w-24 rounded-control bg-panel2`}),(0,h.jsx)(`span`,{className:`ml-auto h-3 w-16 rounded-control bg-panel2`})]},e))}),(0,h.jsx)(`div`,{className:`h-[560px] rounded-panel border border-line bg-panel`})]})]})}var Kq=`relative grid grid-cols-[14px_minmax(0,1fr)_auto_32px] items-center gap-x-[14px] gap-y-[4px] border-b border-line px-4 py-[14px] last:border-b-0 md:grid-cols-[14px_minmax(0,1fr)_140px_100px_32px]`,qq=`col-start-2 row-start-2 text-small text-ink2 tabular-nums md:col-start-3 md:row-start-1`,Jq=`col-start-3 row-start-1 justify-end md:col-start-4`,Yq=`relative z-10 col-start-4 row-start-1 size-8 p-0 md:col-start-5`;function Xq(){let{api:e}=I(),t=_(),n=nt(my(e)),[r,i]=(0,m.useState)(void 0),a=it({mutationFn:t=>lo(e,t),onSettled:async()=>{i(void 0),await t.invalidateQueries({queryKey:V.projects})}});return(0,h.jsxs)(`div`,{className:`mx-auto max-w-[1440px]`,children:[(0,h.jsxs)(`div`,{className:`mb-4 flex items-center`,children:[(0,h.jsx)(`h1`,{className:`text-title font-bold tracking-[-0.01em]`,children:`Projects`}),(0,h.jsx)(B,{variant:`accent`,className:`ml-auto`,asChild:!0,children:(0,h.jsx)(sa,{to:`/play`,children:`New run`})})]}),(0,h.jsx)(yP,{}),n.data?.projects.length===0?(0,h.jsx)(lj,{}):null,n.error===null?null:(0,h.jsx)(Pj,{children:(0,h.jsx)(`p`,{className:`px-4 py-[14px] text-body text-red`,children:n.error.message})}),n.data===void 0?n.error===null?(0,h.jsx)(eJ,{}):null:n.data.projects.length===0?(0,h.jsx)(Pj,{children:(0,h.jsxs)(`p`,{className:`px-4 py-7 text-body text-ink2`,children:[`No projects yet. Set up a run on`,` `,(0,h.jsx)(sa,{to:`/play`,className:`rounded-control text-ink underline underline-offset-[3px]`,children:`Play`}),`.`]})}):(0,h.jsx)(Pj,{children:n.data.projects.map(e=>(0,h.jsx)(Zq,{project:e,onDelete:()=>{i(e)}},e.id))}),a.error===null?null:(0,h.jsx)(`p`,{role:`alert`,className:`mt-[10px] text-label text-red`,children:a.error.message}),(0,h.jsx)(Nj,{open:r!==void 0,title:r===void 0?``:`Delete "${r.title}"?`,consequence:`Deletes the project and every file it produced.`,verb:`Delete`,pending:a.isPending,onConfirm:()=>{r!==void 0&&a.mutate(r.id)},onCancel:()=>{i(void 0)}})]})}function Zq({project:e,onDelete:t}){return(0,h.jsxs)(`div`,{className:Kq,children:[(0,h.jsx)(mK,{state:e.status,className:`col-start-1 row-start-1`}),(0,h.jsxs)(`span`,{className:`col-start-2 row-start-1 flex min-w-0 flex-wrap items-baseline gap-x-3`,children:[(0,h.jsx)(sa,{to:`/projects/$projectId`,params:{projectId:e.id},className:`rounded-control font-semibold after:absolute after:inset-0 after:content-['']`,children:e.title}),(0,h.jsx)(`span`,{className:`truncate text-small text-ink2`,children:Qq(e)})]}),(0,h.jsx)(`span`,{className:qq,children:jc(e.createdAt)}),(0,h.jsx)(fK,{state:e.status,announce:e.title,className:Jq}),(0,h.jsx)($q,{project:e,onDelete:t}),e.status===`running`?(0,h.jsx)(Ij,{current:e.progress,total:1}):null]})}function Qq(e){let t=e.config.articlePrompt;return[t===void 0||t===``?void 0:t,e.format].filter(e=>e!==void 0).join(` · `)}function $q({project:e,onDelete:t}){let n=e.status===`running`;return(0,h.jsxs)(Rj,{children:[(0,h.jsx)(zj,{asChild:!0,children:(0,h.jsx)(B,{variant:`ghost`,"aria-label":`More for ${e.title}`,className:Yq,children:(0,h.jsx)(tj,{"aria-hidden":`true`,className:`size-4`})})}),(0,h.jsxs)(Bj,{children:[(0,h.jsx)(`span`,{title:n?`Cancel the run first`:void 0,children:(0,h.jsx)(Vj,{disabled:n,onSelect:t,children:`Delete`})}),n?(0,h.jsx)(`p`,{className:`engraved px-[10px] py-[5px] text-ink3`,children:`Cancel the run first`}):null]})]})}function eJ(){return(0,h.jsx)(Pj,{children:[0,1,2,3,4,5].map(e=>(0,h.jsxs)(`div`,{className:Kq,children:[(0,h.jsx)(`span`,{className:`col-start-1 row-start-1 size-[10px] rounded-full bg-panel2`}),(0,h.jsx)(`span`,{className:`col-start-2 row-start-1 h-3 w-2/5 rounded-control bg-panel2`}),(0,h.jsx)(`span`,{className:`col-start-3 row-start-1 h-[10px] w-[90px] rounded-control bg-panel2 md:col-start-3`}),(0,h.jsx)(`span`,{className:`col-start-4 row-start-1 h-[10px] w-14 justify-self-end rounded-control bg-panel2 md:col-start-4`})]},e))})}var tJ=`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 nJ({promptId:e,kind:t,from:n,onLeave:r}){let{api:i}=I(),a=_(),o=PA(),s=nt(by(i)),c=(0,m.useId)(),l=(0,m.useId)(),u=(0,m.useId)(),d=(0,m.useId)(),f=(0,m.useId)(),[p,g]=kk(JSON.stringify(e===void 0?[`new`,t,n??null]:[`prompt`,e])),[v,y]=(0,m.useState)([]),[b,x]=(0,m.useState)(void 0),S=b!==void 0,[C,w]=(0,m.useState)(!1),[T,E]=(0,m.useState)(!1),D=s.data?.prompts,O=e??n,ee=O===void 0?void 0:D?.find(e=>e.id===O),k=ee===void 0?{kind:t,name:``,body:``}:e===void 0?{kind:ee.kind,name:`${ee.name} copy`,body:ee.body}:{kind:ee.kind,name:ee.name,body:ee.body},A=p??b??k,j=it({mutationFn:t=>jo(i,t,e),onSuccess:async(e,t)=>{if(!e.ok){y(e.fields);return}x(e.value),g(e=>e===t?void 0:e),o({type:`prompt-saved`,id:e.value.id,kind:e.value.kind}),await a.invalidateQueries({queryKey:by(i).queryKey})}}),M=it({mutationFn:e=>Mo(i,e),onSuccess:async()=>{w(!1),g(void 0),await a.invalidateQueries({queryKey:by(i).queryKey}),r(A.kind)}});$j(S,()=>{r(A.kind)});let N=(e,t)=>{g(e),y(e=>e.filter(e=>e.field!==t))},P=SM(A,v),F=CM(P),te=EM(A.body),ne=A.body.trim()===``?[]:wM(P),re=A.name.trim()===``?[]:TM(P);return NA({promptNamed:A.name.trim()!==``&&re.length===0,promptBodyReady:A.body.trim()!==``&&ne.length===0,promptHasKeywords:te.length>0&&ne.length===0,promptSaveReady:F===void 0&&!j.isPending&&!S,promptSaving:j.isPending||S,promptIsArticle:A.kind===`article`,promptIsImage:A.kind===`image`}),s.error===null?O!==void 0&&D===void 0?(0,h.jsx)(rM,{}):O!==void 0&&ee===void 0?(0,h.jsx)(rJ,{kind:t,children:`That prompt is gone. It may have been deleted in another tab.`}):(0,h.jsxs)(`div`,{className:`mx-auto max-w-[1440px]`,children:[(0,h.jsxs)(sa,{to:`/prompts`,search:{kind:A.kind},className:`mb-[10px] inline-flex items-center gap-1 text-small text-ink2 hover:text-ink`,children:[(0,h.jsx)(YA,{"aria-hidden":`true`,className:`size-[14px]`}),`Prompts`]}),(0,h.jsx)(`h1`,{className:`mb-4 text-title font-bold tracking-[-0.01em]`,children:e===void 0?`New prompt`:`Edit 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:`${nM} flex min-w-0 flex-col gap-[14px]`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-end gap-[14px]`,children:[(0,h.jsxs)(`div`,{"data-tour":`prompt-name`,className:`flex-1`,children:[(0,h.jsx)(oM,{htmlFor:c,className:`mb-[5px]`,children:`Name`}),(0,h.jsx)(cM,{id:c,value:A.name,"aria-invalid":re.length>0,"aria-describedby":re.length===0?void 0:l,onChange:e=>{N({...A,name:e.target.value},`name`)}}),re.length===0?null:(0,h.jsx)(`p`,{id:l,className:`mt-1 text-label text-red`,children:re.map(e=>e.message).join(` `)})]}),(0,h.jsx)(sM,{label:`Kind`,value:A.kind,options:Aj,onPick:e=>{N({...A,kind:e},`name`)}})]}),(0,h.jsxs)(`div`,{"data-tour":`prompt-body`,children:[A.kind===`narration`?(0,h.jsx)(B,{type:`button`,className:`mb-3`,onClick:()=>{A.body.trim()===``?N({...A,body:tJ},`body`):E(!0)},children:`Use Documentary Starter`}):null,(0,h.jsx)(oM,{htmlFor:u,className:`mb-[5px]`,children:`Body`}),(0,h.jsx)(kM,{id:u,value:A.body,invalid:ne.length>0,describedBy:ne.length===0?void 0:d,onChange:e=>{N({...A,body:e},`body`)}})]}),(0,h.jsx)(`div`,{"data-tour":`prompt-save`,children:(0,h.jsx)(tM,{onDelete:e===void 0?void 0:()=>{w(!0)},blocked:F,blockedId:f,pending:j.isPending,saved:S,cancel:(0,h.jsx)(B,{asChild:!0,children:(0,h.jsx)(sa,{to:`/prompts`,search:{kind:A.kind},onClick:()=>{g(void 0)},children:`Cancel`})}),errors:[j.error,M.error].flatMap(e=>e===null?[]:[e.message]),onSave:()=>{j.mutate(A)}})})]}),(0,h.jsx)(`div`,{"data-tour":`prompt-slots`,className:`${nM} flex flex-col gap-3 lg:sticky lg:top-6`,children:(0,h.jsx)(Zj,{slots:te,body:A.body,lint:ne,lintId:d})})]}),(0,h.jsx)(Nj,{open:T,title:`Replace this prompt body?`,consequence:`The documentary starter replaces the text in this editor. Nothing is saved until you choose Save.`,verb:`Use starter`,pending:!1,onConfirm:()=>{N({...A,body:tJ},`body`),E(!1)},onCancel:()=>E(!1)}),(0,h.jsx)(Nj,{open:C,title:`Delete "${A.name}"?`,consequence:`Projects that used it keep their text.`,verb:`Delete`,pending:M.isPending,onConfirm:()=>{e!==void 0&&M.mutate(e)},onCancel:()=>{w(!1)}})]}):(0,h.jsx)(rJ,{kind:A.kind,children:s.error.message})}function rJ({kind:e,children:t}){return(0,h.jsx)(iM,{back:(0,h.jsx)(sa,{to:`/prompts`,search:{kind:e},className:aM,children:`Back to Prompts`}),children:t})}var iJ=`grid grid-cols-[minmax(0,1fr)_auto_32px] items-center gap-x-[14px] gap-y-[6px] border-b border-line px-4 py-[14px] last:border-b-0 md:grid-cols-[260px_minmax(0,1fr)_auto_32px]`,aJ=`col-span-3 col-start-1 row-start-2 flex flex-wrap gap-[6px] md:col-span-1`,oJ=`md:col-start-2 md:row-start-1`;function sJ({kind:e,onKind:t}){let{api:n}=I(),r=_(),i=nt(by(n)),[a,o]=(0,m.useState)(void 0),s=it({mutationFn:e=>Mo(n,e),onSettled:async()=>{o(void 0),await r.invalidateQueries({queryKey:V.prompts})}}),c=i.data?.prompts.filter(t=>t.kind===e);return(0,h.jsxs)(`div`,{className:`mx-auto max-w-[1440px]`,children:[(0,h.jsx)(`h1`,{className:`mb-4 text-title font-bold tracking-[-0.01em]`,children:`Prompts`}),(0,h.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-4`,children:[(0,h.jsx)(Hj,{type:`single`,value:e,"aria-label":`Prompt kind`,className:`flex-wrap`,onValueChange:e=>{let n=Aj.find(t=>t.value===e);n!==void 0&&t(n.value)},children:Aj.map(e=>(0,h.jsx)(Uj,{value:e.value,children:e.label},e.value))}),(0,h.jsx)(`span`,{className:`flex-1`}),(0,h.jsx)(cJ,{kind:e})]}),i.error===null?null:(0,h.jsx)(Pj,{children:(0,h.jsx)(`p`,{className:`px-4 py-[14px] text-body text-red`,children:i.error.message})}),c===void 0?i.error===null?(0,h.jsx)(dJ,{}):null:c.length===0?(0,h.jsx)(lJ,{kind:e}):(0,h.jsx)(Pj,{children:c.map(e=>(0,h.jsxs)(`div`,{className:iJ,children:[(0,h.jsx)(`span`,{className:`col-start-1 row-start-1 font-semibold`,children:e.name}),(0,h.jsx)(`span`,{className:z(aJ,oJ),children:e.slots.map(e=>(0,h.jsx)(Lj,{name:e},e))}),(0,h.jsx)(B,{className:`col-start-2 row-start-1 md:col-start-3`,asChild:!0,children:(0,h.jsx)(sa,{to:`/prompts/$promptId`,params:{promptId:e.id},children:`Edit`})}),(0,h.jsx)(uJ,{prompt:e,onDelete:()=>{o(e)}})]},e.id))}),s.error===null?null:(0,h.jsx)(`p`,{className:`mt-[10px] text-label text-red`,children:s.error.message}),(0,h.jsx)(Nj,{open:a!==void 0,title:a===void 0?``:`Delete "${a.name}"?`,consequence:`Projects that used it keep their text.`,verb:`Delete`,pending:s.isPending,onConfirm:()=>{a!==void 0&&s.mutate(a.id)},onCancel:()=>{o(void 0)}})]})}function cJ({kind:e}){return(0,h.jsx)(B,{asChild:!0,children:(0,h.jsxs)(sa,{to:`/prompts/new`,search:{kind:e},children:[(0,h.jsx)(aj,{"aria-hidden":`true`,className:`size-[14px]`}),`New prompt`]})})}function lJ({kind:e}){return(0,h.jsx)(Pj,{children:(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4 px-4 py-7 text-ink2`,children:[(0,h.jsx)(`span`,{className:`max-w-[75ch]`,children:`No ${e} prompts yet. A prompt is text with {{keywords}}; each keyword becomes a field on Play.`}),(0,h.jsx)(cJ,{kind:e})]})})}function uJ({prompt:e,onDelete:t}){return(0,h.jsxs)(Rj,{children:[(0,h.jsx)(zj,{asChild:!0,children:(0,h.jsx)(B,{variant:`ghost`,"aria-label":`More for ${e.name}`,className:`col-start-3 row-start-1 size-8 p-0 md:col-start-4`,children:(0,h.jsx)(tj,{"aria-hidden":`true`,className:`size-4`})})}),(0,h.jsxs)(Bj,{children:[(0,h.jsx)(Vj,{asChild:!0,children:(0,h.jsx)(sa,{to:`/prompts/new`,search:{kind:e.kind,from:e.id},children:`Duplicate`})}),(0,h.jsx)(Vj,{onSelect:t,children:`Delete`})]})]})}function dJ(){return(0,h.jsx)(Pj,{children:[0,1,2].map(e=>(0,h.jsxs)(`div`,{className:iJ,children:[(0,h.jsx)(`span`,{className:`col-start-1 row-start-1 h-3 w-40 rounded-control bg-panel2`}),(0,h.jsxs)(`span`,{className:z(aJ,oJ),children:[(0,h.jsx)(`span`,{className:`h-[18px] w-14 rounded-control bg-panel2`}),(0,h.jsx)(`span`,{className:`h-[18px] w-[72px] rounded-control bg-panel2`})]}),(0,h.jsx)(`span`,{className:`col-start-2 row-start-1 h-7 w-12 rounded-control bg-panel2 md:col-start-3`})]},e))})}var fJ=cD(`kind`,[K({kind:hD(`once`),at:W().datetime({offset:!0})}).strict(),K({kind:hD(`daily`),time:W().regex(/^([01]\d|2[0-3]):[0-5]\d$/)}).strict(),K({kind:hD(`weekly`),time:W().regex(/^([01]\d|2[0-3]):[0-5]\d$/),days:G(KE().int().min(0).max(6)).min(1).max(7).readonly()}).strict()]);function pJ(e){try{return new Intl.DateTimeFormat(`en`,{timeZone:e}).format(),!0}catch{return!1}}var mJ=OE(),hJ=W().min(1).max(200).refine(e=>e===e.trim(),`Keyword names cannot start or end with spaces.`),gJ=K({title:W().trim().min(1).max(200),values:fD(hJ,W().max(1e4)).readonly()}).strict().readonly(),_J=q([`skip`,`run-once`]);K({id:mJ,name:W().trim().min(1).max(200),templateId:mJ,templateVersion:KE().int().positive(),cadence:fJ,timezone:W().min(1).max(100).refine(pJ,`Choose a valid IANA timezone.`),missedPolicy:_J.default(`skip`),overlapPolicy:hD(`skip`).default(`skip`),spendLimitCents:KE().int().nonnegative().nullable().default(null),items:G(gJ).max(49).default([]).readonly()}).strict().readonly().unwrap().extend({baseVersion:KE().int().positive(),mutationId:mJ}).strict().readonly(),K({id:mJ,baseVersion:KE().int().positive()}).strict().readonly(),K({id:mJ,baseVersion:KE().int().positive()}).strict().readonly();var vJ=K({id:mJ,name:W(),templateId:mJ,templateVersion:KE().int().positive(),cadence:fJ,timezone:W(),missedPolicy:_J,overlapPolicy:hD(`skip`),spendLimitCents:KE().int().nonnegative().nullable(),items:G(gJ).readonly(),status:q([`active`,`paused`,`completed`,`canceled`]),version:KE().int().positive(),nextRunAt:W().datetime({offset:!0}).nullable(),createdAt:W(),updatedAt:W(),deletedAt:W().datetime({offset:!0}).nullable()}).strict().readonly(),yJ=K({id:mJ,scheduleId:mJ,scheduledFor:W().datetime({offset:!0}),status:q([`running`,`succeeded`,`failed`,`skipped`]),requestId:mJ.nullable(),projectIds:G(W()).readonly(),estimate:eD().nullable(),startedAt:W().datetime({offset:!0}),endedAt:W().datetime({offset:!0}).nullable(),error:W().nullable()}).strict().readonly(),bJ=K({title:W(),detail:W().optional(),reason:W().optional()}),xJ=K({schedules:G(vJ)}),SJ=K({schedule:vJ,runs:G(yJ)}),CJ=e=>`${e.origin}/api/schedules`;async function wJ(e,t){let n;try{n=await e.json()}catch{throw io(e,void 0)}if(e.ok)return{ok:!0,value:t.parse(n)};let r=bJ.safeParse(n);if(!r.success)throw io(e,void 0);let i=r.data.detail??r.data.title;if(![400,404,409].includes(e.status))throw Error(i);return{ok:!1,message:i,reason:r.data.reason??`invalid-request`}}var TJ=(e,t)=>({method:e,headers:{"content-type":`application/json`},body:JSON.stringify(t)}),EJ=[`schedules`];function DJ(e){return{queryKey:EJ,queryFn:async()=>{let t=await wJ(await e.fetch(CJ(e)),xJ);if(!t.ok)throw Error(t.message);return t.value.schedules},refetchInterval:3e4}}async function OJ(e,t){return wJ(await e.fetch(`${CJ(e)}/${encodeURIComponent(t)}`),SJ)}async function kJ(e,t){return wJ(await e.fetch(CJ(e),TJ(`POST`,t)),vJ)}async function AJ(e,t,n){return wJ(await e.fetch(`${CJ(e)}/${encodeURIComponent(t)}`,TJ(`PUT`,n)),vJ)}async function jJ(e,t,n,r){return wJ(await e.fetch(`${CJ(e)}/${encodeURIComponent(t)}/${n}`,TJ(`POST`,{baseVersion:r})),vJ)}async function MJ(e,t,n){return wJ(await e.fetch(`${CJ(e)}/${encodeURIComponent(t)}`,TJ(`DELETE`,{baseVersion:n})),K({deleted:hD(!0)}))}var Y=l(o(((e,t)=>{(function(n,r){typeof e==`object`&&t!==void 0?t.exports=r():typeof define==`function`&&define.amd?define(r):(n||=self,n.JSBI=r())})(e,function(){var e=Math.imul,t=Math.clz32;function n(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function r(e){if(Array.isArray(e))return e}function i(e){if(e===void 0)throw ReferenceError(`this hasn't been initialised - super() hasn't been called`);return e}function a(e,t,n){return t=d(t),_(e,m()?Reflect.construct(t,n||[],d(e).constructor):t.apply(e,n))}function o(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function s(e,t,n){if(m())return Reflect.construct.apply(null,arguments);var r=[null];r.push.apply(r,t);var i=new(e.bind.apply(e,r));return n&&v(i,n.prototype),i}function c(e,t){for(var n,r=0;r<t.length;r++)n=t[r],n.enumerable=n.enumerable||!1,n.configurable=!0,`value`in n&&(n.writable=!0),Object.defineProperty(e,x(n.key),n)}function l(e,t,n){return t&&c(e.prototype,t),n&&c(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function u(e,t){var n=typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(!n){if(Array.isArray(e)||(n=C(e))||t&&e&&typeof e.length==`number`){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw TypeError(`Invalid attempt to iterate non-iterable instance.
136
136
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||n.return==null||n.return()}finally{if(s)throw a}}}}function d(e){return d=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},d(e)}function f(e,t){if(typeof t!=`function`&&t!==null)throw TypeError(`Super expression must either be null or a function`);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&v(e,t)}function p(e){try{return Function.toString.call(e).indexOf(`[native code]`)!==-1}catch{return typeof e==`function`}}function m(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(m=function(){return!!e})()}function h(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function g(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
137
- 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),MJ=Y.default.BigInt(0),NJ=Y.default.BigInt(1),PJ=Y.default.BigInt(2),FJ=Y.default.BigInt(10),IJ=Y.default.BigInt(24),LJ=Y.default.BigInt(60),RJ=Y.default.BigInt(1e3),zJ=Y.default.BigInt(1e6),BJ=Y.default.BigInt(1e9),VJ=Y.default.multiply(Y.default.BigInt(3600),BJ),HJ=Y.default.multiply(LJ,BJ),UJ=Y.default.multiply(VJ,IJ);function WJ(e){return typeof e==`bigint`?Y.default.BigInt(e.toString(10)):e}function GJ(e){return Y.default.equal(Y.default.remainder(e,PJ),MJ)}function KJ(e){return Y.default.lessThan(e,MJ)?Y.default.unaryMinus(e):e}function qJ(e,t){return Y.default.lessThan(e,t)?-1:+!!Y.default.greaterThan(e,t)}function JJ(e,t){return{quotient:Y.default.divide(e,t),remainder:Y.default.remainder(e,t)}}var YJ,XJ,ZJ=`slot-epochNanoSeconds`,QJ=`slot-iso-date`,$J=`slot-iso-date-time`,eY=`slot-time`,X=`slot-calendar`,tY=`slot-date-brand`,nY=`slot-year-month-brand`,rY=`slot-month-day-brand`,iY=`slot-time-zone`,aY=`slot-years`,oY=`slot-months`,sY=`slot-weeks`,cY=`slot-days`,lY=`slot-hours`,uY=`slot-minutes`,dY=`slot-seconds`,fY=`slot-milliseconds`,pY=`slot-microseconds`,mY=`slot-nanoseconds`,hY=`date`,gY=`ym`,_Y=`md`,vY=`time`,yY=`datetime`,bY=`instant`,xY=`original`,SY=`timezone-canonical`,CY=`timezone-original`,wY=`calendar-id`,TY=`locale`,EY=`options`,DY=new WeakMap,OY=Symbol.for(`@@Temporal__GetSlots`);(YJ=globalThis)[OY]||(YJ[OY]=function(e){return DY.get(e)});var kY=globalThis[OY],AY=Symbol.for(`@@Temporal__CreateSlots`);(XJ=globalThis)[AY]||(XJ[AY]=function(e){DY.set(e,Object.create(null))});var jY=globalThis[AY];function MY(e,...t){if(!e||typeof e!=`object`)return!1;let n=kY(e);return!!n&&t.every((e=>e in n))}function Z(e,t){let n=kY(e)?.[t];if(n===void 0)throw TypeError(`Missing internal slot ${t}`);return n}function NY(e,t,n){let r=kY(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 PY={};function FY(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))}IY(t,e),IY(`${t}.prototype`,e.prototype)}function IY(e,t){let n=`%${e}%`;if(PY[n]!==void 0)throw Error(`intrinsic ${e} already exists`);PY[n]=t}function LY(e){return PY[e]}function RY(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 zY(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 BY(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 VY(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 HY=class e{constructor(e){this.totalNs=WJ(e),this.sec=Y.default.toNumber(Y.default.divide(this.totalNs,BJ)),this.subsec=Y.default.toNumber(Y.default.remainder(this.totalNs,BJ))}static validateNew(t,n){if(Y.default.greaterThan(KJ(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=Y.default.subtract(WJ(t),WJ(n));return new e(r)}static fromComponents(t,n,r,i,a,o){let s=Y.default.add(Y.default.add(Y.default.add(Y.default.add(Y.default.add(Y.default.BigInt(o),Y.default.multiply(Y.default.BigInt(a),RJ)),Y.default.multiply(Y.default.BigInt(i),zJ)),Y.default.multiply(Y.default.BigInt(r),BJ)),Y.default.multiply(Y.default.BigInt(n),HJ)),Y.default.multiply(Y.default.BigInt(t),VJ));return e.validateNew(s,`total`)}abs(){return new e(KJ(this.totalNs))}add(t){return e.validateNew(Y.default.add(this.totalNs,t.totalNs),`sum`)}add24HourDays(t){return e.validateNew(Y.default.add(this.totalNs,Y.default.multiply(Y.default.BigInt(t),UJ)),`sum`)}addToEpochNs(e){return Y.default.add(WJ(e),this.totalNs)}cmp(e){return qJ(this.totalNs,e.totalNs)}divmod(t){let{quotient:n,remainder:r}=JJ(this.totalNs,Y.default.BigInt(t));return{quotient:Y.default.toNumber(n),remainder:new e(r)}}fdiv(e){let t=WJ(e),n=Y.default.BigInt(t),{quotient:r,remainder:i}=JJ(this.totalNs,n),a=[],o,s=(Y.default.lessThan(this.totalNs,MJ)?-1:1)*Math.sign(Y.default.toNumber(t));for(;!Y.default.equal(i,MJ)&&a.length<50;)i=Y.default.multiply(i,FJ),{quotient:o,remainder:i}=JJ(i,n),a.push(Math.abs(Y.default.toNumber(o)));return s*Number(KJ(r).toString()+`.`+a.join(``))}isZero(){return Y.default.equal(this.totalNs,MJ)}round(t,n){let r=WJ(t);if(Y.default.equal(r,NJ))return this;let{quotient:i,remainder:a}=JJ(this.totalNs,r),o=Y.default.lessThan(this.totalNs,MJ)?`negative`:`positive`,s=Y.default.multiply(KJ(i),r),c=Y.default.add(s,r),l=qJ(KJ(Y.default.multiply(a,PJ)),r),u=BY(n,o),d=Y.default.equal(KJ(this.totalNs),s)?s:VY(s,c,l,GJ(i),u),f=o===`positive`?d:Y.default.unaryMinus(d);return e.validateNew(f,`rounding`)}sign(){return this.cmp(new e(MJ))}subtract(t){return e.validateNew(Y.default.subtract(this.totalNs,t.totalNs),`difference`)}};HY.MAX=Y.default.BigInt(`9007199254740991999999999`),HY.ZERO=new HY(MJ);var UY=/[A-Za-z._][A-Za-z._0-9+-]*/,WY=RegExp(`(?:(?:[+-](?:[01][0-9]|2[0-3])(?::?[0-5][0-9])?)|(?:${UY.source})(?:\\/(?:${UY.source}))*)`),GY=/(?:[+-]\d{6}|\d{4})/,KY=/(?:0[1-9]|1[0-2])/,qY=/(?:0[1-9]|[12]\d|3[01])/,JY=RegExp(`(${GY.source})(?:-(${KY.source})-(${qY.source})|(${KY.source})(${qY.source}))`),YY=/(\d{2})(?::(\d{2})(?::(\d{2})(?:[.,](\d{1,9}))?)?|(\d{2})(?:(\d{2})(?:[.,](\d{1,9}))?)?)?/,XY=/((?:[+-])(?:[01][0-9]|2[0-3])(?::?(?:[0-5][0-9])(?::?(?:[0-5][0-9])(?:[.,](?:\d{1,9}))?)?)?)/,ZY=RegExp(`([zZ])|${XY.source}?`),QY=/\[(!)?([a-z_][a-z0-9_-]*)=([A-Za-z0-9]+(?:-[A-Za-z0-9]+)*)\]/g,$Y=new RegExp([`^${JY.source}`,`(?:(?:[tT]|\\s+)${YY.source}(?:${ZY.source})?)?`,`(?:\\[!?(${WY.source})\\])?`,`((?:${QY.source})*)$`].join(``)),eX=new RegExp([`^[tT]?${YY.source}`,`(?:${ZY.source})?`,`(?:\\[!?${WY.source}\\])?`,`((?:${QY.source})*)$`].join(``)),tX=RegExp(`^(${GY.source})-?(${KY.source})(?:\\[!?${WY.source}\\])?((?:${QY.source})*)$`),nX=RegExp(`^(?:--)?(${KY.source})-?(${qY.source})(?:\\[!?${WY.source}\\])?((?:${QY.source})*)$`),rX=/(\d+)(?:[.,](\d{1,9}))?/,iX=RegExp(`(?:${rX.source}H)?(?:${rX.source}M)?(?:${rX.source}S)?`),aX=RegExp(`^([+-])?P(?:(\\d+)Y)?(?:(\\d+)M)?(?:(\\d+)W)?(?:(\\d+)D)?(?:T(?!$)${iX.source})?$`,`i`),oX=864e5,sX=1e6*oX,cX=6e10,lX=1e8*oX,uX=c1(lX),dX=Y.default.unaryMinus(uX),fX=Y.default.add(Y.default.subtract(dX,UJ),NJ),pX=Y.default.subtract(Y.default.add(uX,UJ),NJ),mX=146097*oX,hX=-271821,gX=275760,_X=Date.UTC(1847,0,1),vX=[`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`],yX=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 bX(e){return typeof e==`object`&&!!e||typeof e==`function`}function xX(e){if(typeof e==`bigint`)throw TypeError(`Cannot convert BigInt to number`);return Number(e)}function SX(e){if(typeof e==`symbol`)throw TypeError(`Cannot convert a Symbol value to a String`);return String(e)}function CX(e){let t=xX(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 wX(e,t){let n=CX(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 TX(e){let t=xX(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 EX(e,t){return String(e).padStart(t,`0`)}function DX(e){if(typeof e!=`string`)throw TypeError(`expected a string, not ${String(e)}`);return e}function OX(e,t){if(bX(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 kX=[`era`,`eraYear`,`year`,`month`,`monthCode`,`day`,`hour`,`minute`,`second`,`millisecond`,`microsecond`,`nanosecond`,`offset`,`timeZone`],AX={era:SX,eraYear:CX,year:CX,month:wX,monthCode:function(e){let t=DX(OX(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:wX,hour:CX,minute:CX,second:CX,millisecond:CX,microsecond:CX,nanosecond:CX,offset:function(e){let t=DX(OX(e));return FQ(t),t},timeZone:pQ},jX={hour:0,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0},MX=[[`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`]],NX=Object.fromEntries(MX.map((e=>[e[0],e[1]]))),PX=Object.fromEntries(MX.map((([e,t])=>[t,e]))),FX=MX.map((([,e])=>e)),IX={day:sX,hour:36e11,minute:6e10,second:1e9,millisecond:1e6,microsecond:1e3,nanosecond:1},LX=[`days`,`hours`,`microseconds`,`milliseconds`,`minutes`,`months`,`nanoseconds`,`seconds`,`weeks`,`years`],RX=Intl.DateTimeFormat,zX=new Map;function BX(e){let t=g1(e),n=zX.get(t);return n===void 0&&(n=new RX(`en-us`,{timeZone:t,hour12:!1,era:`short`,year:`numeric`,month:`numeric`,day:`numeric`,hour:`numeric`,minute:`numeric`,second:`numeric`}),zX.set(t,n)),n}function VX(e){return MY(e,ZJ)&&!MY(e,iY,X)}function HX(e){return MY(e,aY,oY,cY,lY,uY,dY,fY,pY,mY)}function UX(e){return MY(e,tY)}function WX(e){return MY(e,eY)}function GX(e){return MY(e,$J)}function KX(e){return MY(e,nY)}function qX(e){return MY(e,rY)}function JX(e){return MY(e,ZJ,iY,X)}function Q(e,t){if(!t(e))throw TypeError(`invalid receiver: method called with the wrong type of this-object`)}function YX(e){if(MY(e,X)||MY(e,iY))throw TypeError(`with() does not support a calendar or timeZone property`);if(WX(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 XX(e,t){return t===`never`||t===`auto`&&e===`iso8601`?``:`[${t===`critical`?`!`:``}u-ca=${e}]`}function ZX(e){let t,n,r=!1;for(QY.lastIndex=0;n=QY.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 QX(e){let t=$Y.exec(e);if(!t)throw RangeError(`invalid RFC 9557 string: ${e}`);let n=ZX(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 f$(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 $X(e){let t=eX.exec(e),n,r,i,a,o,s,c;if(t){c=ZX(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}=QX(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(d$(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}=tZ(e);l$(1972,t,n)}catch{try{let{year:t,month:n}=eZ(e);l$(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 eZ(e){let t=tX.exec(e),n,r,i,a;if(t){i=ZX(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}=QX(e),t)throw RangeError(`Z designator not supported for PlainYearMonth`)}return{year:n,month:r,calendar:i,referenceISODay:a}}function tZ(e){let t=nX.exec(e),n,r,i,a;if(t){if(i=ZX(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}=QX(e),t)throw RangeError(`Z designator not supported for PlainMonthDay`)}return{month:n,day:r,calendar:i,referenceISOYear:a}}var nZ=RegExp(`^${WY.source}$`,`i`),rZ=RegExp(`^([+-])([01][0-9]|2[0-3])(?::?([0-5][0-9])?)?$`);function iZ(e){let t=v1.test(e)?`Seconds not allowed in offset time zone`:`Invalid time zone`;throw RangeError(`${t}: ${e}`)}function aZ(e){return nZ.test(e)||iZ(e),rZ.test(e)?{offsetMinutes:FQ(e)/6e10}:{tzName:e}}function oZ(e,t,n,r){let i=e,a=t,o=n;switch(r){case`reject`:l$(i,a,o);break;case`constrain`:({year:i,month:a,day:o}=s$(i,a,o))}return{year:i,month:a,day:o}}function sZ(e,t,n,r,i,a,o){let s=e,c=t,l=n,u=r,d=i,f=a;switch(o){case`reject`:d$(s,c,l,u,d,f);break;case`constrain`:s=o$(s,0,23),c=o$(c,0,59),l=o$(l,0,59),u=o$(u,0,999),d=o$(d,0,999),f=o$(f,0,999)}return{hour:s,minute:c,second:l,millisecond:u,microsecond:d,nanosecond:f}}function cZ(e){if(!bX(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<LX.length;r++){let i=LX[r],a=e[i];a!==void 0&&(n=!0,t[i]=TX(a))}if(!n)throw TypeError(`invalid duration-like`);return t}function lZ({years:e,months:t,weeks:n,days:r},i,a,o){return{years:e,months:o??t,weeks:a??n,days:i??r}}function uZ(e,t){return{isoDate:e,time:t}}function dZ(e){return m1(e,`overflow`,[`constrain`,`reject`],`constrain`)}function fZ(e){return m1(e,`disambiguation`,[`compatible`,`earlier`,`later`,`reject`],`compatible`)}function pZ(e,t){return m1(e,`roundingMode`,[`ceil`,`floor`,`expand`,`trunc`,`halfCeil`,`halfFloor`,`halfExpand`,`halfTrunc`,`halfEven`],t)}function mZ(e,t){return m1(e,`offset`,[`prefer`,`use`,`ignore`,`reject`],t)}function hZ(e){return m1(e,`calendarName`,[`auto`,`always`,`never`,`critical`],`auto`)}function gZ(e){let t=e.roundingIncrement;if(t===void 0)return 1;let n=CX(t);if(n<1||n>1e9)throw RangeError(`roundingIncrement must be at least 1 and at most 1e9, not ${t}`);return n}function _Z(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 vZ(e){let t=e.fractionalSecondDigits;if(t===void 0)return`auto`;if(typeof t!=`number`){if(SX(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 yZ(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 bZ=Symbol(`~required~`);function xZ(e,t,n,r,i=[]){let a=[];for(let e=0;e<MX.length;e++){let t=MX[e],r=t[1],i=t[2];n!==`datetime`&&n!==i||a.push(r)}a=a.concat(i);let o=r;o===bZ?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=PX[a[e]];t!==void 0&&s.push(t)}let c=m1(e,t,s,o);if(c===void 0&&r===bZ)throw RangeError(`${t} is required`);return c&&c in NX?NX[c]:c}function SZ(e){let t=e.relativeTo;if(t===void 0)return{};let n,r,i,a,o,s=`option`,c=!1;if(bX(t)){if(JX(t))return{zonedRelativeTo:t};if(UX(t))return{plainRelativeTo:t};if(GX(t))return{plainRelativeTo:WZ(Z(t,$J).isoDate,Z(t,X))};i=cQ(t);let e=AZ(i,t,[`year`,`month`,`monthCode`,`day`],[`hour`,`minute`,`second`,`millisecond`,`microsecond`,`nanosecond`,`offset`,`timeZone`],[]);({isoDate:n,time:r}=NZ(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}=QX(DX(t)),e)a=pQ(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=h1(i),n={year:u,month:d,day:f}}return a===void 0?{plainRelativeTo:WZ(n,i)}:{zonedRelativeTo:nQ(VZ(n,r,s,s===`option`?FQ(o):0,a,`compatible`,`reject`,c),a,i)}}function CZ(e){return Z(e,aY)===0?Z(e,oY)===0?Z(e,sY)===0?Z(e,cY)===0?Z(e,lY)===0?Z(e,uY)===0?Z(e,dY)===0?Z(e,fY)===0?Z(e,pY)===0?`nanosecond`:`microsecond`:`millisecond`:`second`:`minute`:`hour`:`day`:`week`:`month`:`year`}function wZ(e,t){return FX.indexOf(e)>FX.indexOf(t)?t:e}function TZ(e){return e===`year`||e===`month`||e===`week`}function EZ(e){return TZ(e)||e===`day`?`date`:`time`}function DZ(e){return LY(`%calendarImpl%`)(e)}function OZ(e){return LY(`%calendarImpl%`)(Z(e,X))}function kZ(e,t,n=`date`){let r=Object.create(null),i=DZ(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 AZ(e,t,n,r,i){let a=DZ(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,AX[n])(r);else if(i!==`partial`){if(i.includes(n))throw TypeError(`required property '${n}' missing or undefined`);s[n]=jX[n]}}if(i===`partial`&&!c)throw TypeError(`no supported properties found`);return s}function jZ(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]=CX(s),r=!0)}if(!r)throw TypeError(`invalid time-like`);return i}function MZ(e,t){if(bX(e)){if(UX(e))return dZ($(t)),WZ(Z(e,QJ),Z(e,X));if(JX(e)){let n=_Q(Z(e,iY),Z(e,ZJ));return dZ($(t)),WZ(n.isoDate,Z(e,X))}if(GX(e))return dZ($(t)),WZ(Z(e,$J).isoDate,Z(e,X));let n=cQ(e);return WZ(uQ(n,AZ(n,e,[`year`,`month`,`monthCode`,`day`],[],[]),dZ($(t))),n)}let{year:n,month:r,day:i,calendar:a,z:o}=QX(DX(e));if(o)throw RangeError(`Z designator not supported for PlainDate`);return a||=`iso8601`,a=h1(a),dZ($(t)),WZ({year:n,month:r,day:i},a)}function NZ(e,t,n){return uZ(uQ(e,t,n),sZ(t.hour,t.minute,t.second,t.millisecond,t.microsecond,t.nanosecond,n))}function PZ(e,t){let n,r,i;if(bX(e)){if(GX(e))return dZ($(t)),KZ(Z(e,$J),Z(e,X));if(JX(e)){let n=_Q(Z(e,iY),Z(e,ZJ));return dZ($(t)),KZ(n,Z(e,X))}if(UX(e))return dZ($(t)),KZ(uZ(Z(e,QJ),{deltaDays:0,hour:0,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0}),Z(e,X));i=cQ(e);let a=AZ(i,e,[`year`,`month`,`monthCode`,`day`],[`hour`,`minute`,`second`,`millisecond`,`microsecond`,`nanosecond`],[]),o=dZ($(t));({isoDate:n,time:r}=NZ(i,a,o))}else{let a,o,s,c;if({year:o,month:s,day:c,time:r,calendar:i,z:a}=QX(DX(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}),f$(o,s,c,r.hour,r.minute,r.second,r.millisecond,r.microsecond,r.nanosecond),i||=`iso8601`,i=h1(i),dZ($(t)),n={year:o,month:s,day:c}}return KZ(uZ(n,r),i)}function FZ(e){let t=LY(`%Temporal.Duration%`);if(HX(e))return new t(Z(e,aY),Z(e,oY),Z(e,sY),Z(e,cY),Z(e,lY),Z(e,uY),Z(e,dY),Z(e,fY),Z(e,pY),Z(e,mY));if(!bX(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=aX.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:CX(t[2])*n,i=t[3]===void 0?0:CX(t[3])*n,a=t[4]===void 0?0:CX(t[4])*n,o=t[5]===void 0?0:CX(t[5])*n,s=t[6]===void 0?0:CX(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*CX((c+`000000000`).slice(0,9))*n}else if(p=l===void 0?0:CX(l)*n,u!==void 0){if(d??f)throw RangeError(`only the smallest unit can be fractional`);h=60*CX((u+`000000000`).slice(0,9))*n}else m=d===void 0?0:CX(d)*n,f!==void 0&&(h=CX((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),_$(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(LY(`%Temporal.Duration%`))(t,n,r,i,a,o,s,c,l,u)}(DX(e));let n={years:0,months:0,weeks:0,days:0,hours:0,minutes:0,seconds:0,milliseconds:0,microseconds:0,nanoseconds:0},r=cZ(e);for(let e=0;e<LX.length;e++){let t=LX[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 IZ(e){let t;if(bX(e)){if(VX(e)||JX(e))return eQ(Z(e,ZJ));t=OX(e)}else t=e;let{year:n,month:r,day:i,time:a,offset:o,z:s}=function(e){let t=QX(e);if(!t.z&&!t.offset)throw RangeError(`Temporal.Instant requires a time zone offset`);return t}(DX(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=n$(n,r,i,c,l,u,d,f,p-(s?0:FQ(o)));return w$(m.isoDate),eQ(WQ(m))}function LZ(e,t){if(bX(e)){if(qX(e))return dZ($(t)),JZ(Z(e,QJ),Z(e,X));let n;return MY(e,X)?n=Z(e,X):(n=e.calendar,n===void 0&&(n=`iso8601`),n=sQ(n)),JZ(fQ(n,AZ(n,e,[`year`,`month`,`monthCode`,`day`],[],[]),dZ($(t))),n)}let{month:n,day:r,referenceISOYear:i,calendar:a}=tZ(DX(e));if(a===void 0&&(a=`iso8601`),a=h1(a),dZ($(t)),a===`iso8601`)return JZ({year:1972,month:n,day:r},a);let o={year:i,month:n,day:r};return u$(o),o=fQ(a,kZ(a,o,`month-day`),`constrain`),JZ(o,a)}function RZ(e,t){let n;if(bX(e)){if(WX(e))return dZ($(t)),XZ(Z(e,eY));if(GX(e))return dZ($(t)),XZ(Z(e,$J).time);if(JX(e)){let n=_Q(Z(e,iY),Z(e,ZJ));return dZ($(t)),XZ(n.time)}let{hour:r,minute:i,second:a,millisecond:o,microsecond:s,nanosecond:c}=jZ(e);n=sZ(r,i,a,o,s,c,dZ($(t)))}else n=$X(DX(e)),dZ($(t));return XZ(n)}function zZ(e){return e===void 0?{deltaDays:0,hour:0,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0}:Z(RZ(e),eY)}function BZ(e,t){if(bX(e)){if(KX(e))return dZ($(t)),QZ(Z(e,QJ),Z(e,X));let n=cQ(e);return QZ(dQ(n,AZ(n,e,[`year`,`month`,`monthCode`],[],[]),dZ($(t))),n)}let{year:n,month:r,referenceISODay:i,calendar:a}=eZ(DX(e));a===void 0&&(a=`iso8601`),a=h1(a),dZ($(t));let o={year:n,month:r,day:i};return g$(o),o=dQ(a,kZ(a,o,`year-month`),`constrain`),QZ(o,a)}function VZ(e,t,n,r,i,a,o,s){if(t===`start-of-day`)return xQ(i,e);let c=uZ(e,t);if(n===`wall`||o===`ignore`)return vQ(i,c,a);if(n===`exact`||o===`use`){let n=n$(e.year,e.month,e.day,t.hour,t.minute,t.second,t.millisecond,t.microsecond,t.nanosecond-r);w$(n.isoDate);let i=WQ(n);return h$(i),i}w$(e);let l=WQ(c),u=bQ(i,c);for(let e=0;e<u.length;e++){let t=u[e],n=Y.default.toNumber(Y.default.subtract(l,t)),i=Z$(n,6e10,`halfExpand`);if(n===r||s&&i===r)return t}if(o===`reject`){let e=gQ(r),t=AQ(c,`iso8601`,`auto`);throw RangeError(`Offset ${e} is invalid for ${t} in ${i}`)}return yQ(u,i,c,a)}function HZ(e,t){let n,r,i,a,o,s,c,l=!1,u=`option`;if(bX(e)){if(JX(e)){let n=$(t);return fZ(n),mZ(n,`reject`),dZ(n),nQ(Z(e,ZJ),Z(e,iY),Z(e,X))}o=cQ(e);let l=AZ(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=$(t);s=fZ(d),c=mZ(d,`reject`);let f=dZ(d);({isoDate:n,time:r}=NZ(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=QX(e);if(!t.tzAnnotation)throw RangeError(`Temporal.ZonedDateTime requires a time zone ID in brackets`);return t}(DX(e))),i=pQ(d),f?u=`exact`:a||(u=`wall`),o||=`iso8601`,o=h1(o),l=!0;let g=$(t);s=fZ(g),c=mZ(g,`reject`),dZ(g),n={year:p,month:m,day:h}}let d=0;return u===`option`&&(d=FQ(a)),nQ(VZ(n,r,u,d,i,s,c,l),i,o)}function UZ(e,t,n){u$(t),jY(e),NY(e,QJ,t),NY(e,X,n),NY(e,tY,!0)}function WZ(e,t){let n=LY(`%Temporal.PlainDate%`),r=Object.create(n.prototype);return UZ(r,e,t),r}function GZ(e,t,n){p$(t),jY(e),NY(e,$J,t),NY(e,X,n)}function KZ(e,t){let n=LY(`%Temporal.PlainDateTime%`),r=Object.create(n.prototype);return GZ(r,e,t),r}function qZ(e,t,n){u$(t),jY(e),NY(e,QJ,t),NY(e,X,n),NY(e,rY,!0)}function JZ(e,t){let n=LY(`%Temporal.PlainMonthDay%`),r=Object.create(n.prototype);return qZ(r,e,t),r}function YZ(e,t){jY(e),NY(e,eY,t)}function XZ(e){let t=LY(`%Temporal.PlainTime%`),n=Object.create(t.prototype);return YZ(n,e),n}function ZZ(e,t,n){g$(t),jY(e),NY(e,QJ,t),NY(e,X,n),NY(e,nY,!0)}function QZ(e,t){let n=LY(`%Temporal.PlainYearMonth%`),r=Object.create(n.prototype);return ZZ(r,e,t),r}function $Z(e,t){h$(t),jY(e),NY(e,ZJ,t)}function eQ(e){let t=LY(`%Temporal.Instant%`),n=Object.create(t.prototype);return $Z(n,e),n}function tQ(e,t,n,r){h$(t),jY(e),NY(e,ZJ,t),NY(e,iY,n),NY(e,X,r)}function nQ(e,t,n=`iso8601`){let r=LY(`%Temporal.ZonedDateTime%`),i=Object.create(r.prototype);return tQ(i,e,t,n),i}function rQ(e){return kX.filter((t=>e[t]!==void 0))}function iQ(e,t,n){let r=rQ(n),i=DZ(e).fieldKeysToIgnore(r),a=Object.create(null),o=rQ(t);for(let e=0;e<kX.length;e++){let s,c=kX[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 aQ(e,t,n,r){let i=DZ(e).dateAdd(t,n,r);return u$(i),i}function oQ(e,t,n,r){return DZ(e).dateUntil(t,n,r)}function sQ(e){if(bX(e)&&MY(e,X))return Z(e,X);let t=DX(e);try{return h1(t)}catch{}let n;try{({calendar:n}=QX(t))}catch{try{({calendar:n}=$X(t))}catch{try{({calendar:n}=eZ(t))}catch{({calendar:n}=tZ(t))}}}return n||=`iso8601`,h1(n)}function cQ(e){if(MY(e,X))return Z(e,X);let{calendar:t}=e;return t===void 0?`iso8601`:sQ(t)}function lQ(e,t){return h1(e)===h1(t)}function uQ(e,t,n){let r=DZ(e);r.resolveFields(t,`date`);let i=r.dateToISO(t,n);return u$(i),i}function dQ(e,t,n){let r=DZ(e);r.resolveFields(t,`year-month`),t.day=1;let i=r.dateToISO(t,n);return g$(i),i}function fQ(e,t,n){let r=DZ(e);r.resolveFields(t,`month-day`);let i=r.monthDayToISOReferenceDate(t,n);return u$(i),i}function pQ(e){if(bX(e)&&JX(e))return Z(e,iY);let t=DX(e);if(t===`UTC`)return`UTC`;let{tzName:n,offsetMinutes:r}=function(e){let{tzAnnotation:t,offset:n,z:r}=function(e){if(nZ.test(e))return{tzAnnotation:e,offset:void 0,z:!1};try{let{tzAnnotation:t,offset:n,z:r}=QX(e);if(r||t||n)return{tzAnnotation:t,offset:n,z:r}}catch{}iZ(e)}(e);return t?aZ(t):r?aZ(`UTC`):n?aZ(n):void 0}(t);if(r!==void 0)return VQ(r);let i=RQ(n);if(!i)throw RangeError(`Unrecognized time zone ${n}`);return i.identifier}function mQ(e,t){if(e===t)return!0;let n=aZ(e).offsetMinutes,r=aZ(t).offsetMinutes;if(n===void 0&&r===void 0){let n=RQ(t);if(!n)return!1;let r=RQ(e);return!!r&&r.primaryIdentifier===n.primaryIdentifier}return n===r}function hQ(e,t){let n=aZ(e).offsetMinutes;return n===void 0?BQ(e,t):6e10*n}function gQ(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}${TQ(r,i,a,o,a===0&&o===0?`minute`:`auto`)}`}function _Q(e,t){let n=hQ(e,t),{isoDate:{year:r,month:i,day:a},time:{hour:o,minute:s,second:c,millisecond:l,microsecond:u,nanosecond:d}}=GQ(t);return n$(r,i,a,o,s,c,l,u,d+n)}function vQ(e,t,n){return yQ(bQ(e,t),e,t,n)}function yQ(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=WQ(n),o=Y.default.subtract(a,UJ);h$(o);let s=hQ(t,o),c=Y.default.add(a,UJ);h$(c);let l=hQ(t,c)-s;switch(r){case`earlier`:{let e=HY.fromComponents(0,0,0,0,0,-l),r=V$(n.time,e);return bQ(t,uZ(t$(n.isoDate.year,n.isoDate.month,n.isoDate.day+r.deltaDays),r))[0]}case`compatible`:case`later`:{let e=HY.fromComponents(0,0,0,0,0,l),r=V$(n.time,e),i=bQ(t,uZ(t$(n.isoDate.year,n.isoDate.month,n.isoDate.day+r.deltaDays),r));return i[i.length-1]}}}function bQ(e,t){if(e===`UTC`)return w$(t.isoDate),[WQ(t)];let n=aZ(e).offsetMinutes;if(n!==void 0){let e=n$(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);w$(e.isoDate);let r=WQ(e);return h$(r),[r]}return w$(t.isoDate),function(e,t){let n=WQ(t),r=Y.default.subtract(n,UJ);Y.default.lessThan(r,dX)&&(r=n);let i=Y.default.add(n,UJ);Y.default.greaterThan(i,uX)&&(i=n);let a=BQ(e,r),o=BQ(e,i);return(a===o?[a]:[a,o]).map((r=>{let i=Y.default.subtract(n,Y.default.BigInt(r));if(a1(t,function(e,t){let{epochMilliseconds:n,time:{millisecond:r,microsecond:i,nanosecond:a}}=GQ(t),{year:o,month:s,day:c,hour:l,minute:u,second:d}=JQ(e,n);return n$(o,s,c,l,u,d,r,i,a)}(e,i))===0)return h$(i),i})).filter((e=>e!==void 0))}(e,t)}function xQ(e,t){let n=uZ(t,{deltaDays:0,hour:0,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0}),r=bQ(e,n);if(r.length)return r[0];let i=WQ(n),a=Y.default.subtract(i,UJ);return h$(a),KQ(e,a)}function SQ(e){let t;return t=e<0||e>9999?(e<0?`-`:`+`)+EX(Math.abs(e),6):EX(e,4),t}function CQ(e){return EX(e,2)}function wQ(e,t){let n;if(t===`auto`){if(e===0)return``;n=EX(e,9).replace(/0+$/,``)}else{if(t===0)return``;n=EX(e,9).slice(0,t)}return`.${n}`}function TQ(e,t,n,r,i){let a=`${CQ(e)}:${CQ(t)}`;return i===`minute`||(a+=`:${CQ(n)}`,a+=wQ(r,i)),a}function EQ(e,t,n){let r=t;r===void 0&&(r=`UTC`);let i=Z(e,ZJ),a=AQ(_Q(r,i),`iso8601`,n,`never`),o=`Z`;return t!==void 0&&(o=HQ(hQ(r,i))),`${a}${o}`}function DQ(e,t){let n=Z(e,aY),r=Z(e,oY),i=Z(e,sY),a=Z(e,cY),o=Z(e,lY),s=Z(e,uY),c=ZQ(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=HY.fromComponents(0,0,Z(e,dY),Z(e,fY),Z(e,pY),Z(e,mY));d.isZero()&&![`second`,`millisecond`,`microsecond`,`nanosecond`].includes(CZ(e))&&t===`auto`||(u+=`${Math.abs(d.sec)}${wQ(Math.abs(d.subsec),t)}S`);let f=`${c<0?`-`:``}P${l}`;return u&&(f=`${f}T${u}`),f}function OQ(e,t=`auto`){let{year:n,month:r,day:i}=Z(e,QJ);return`${SQ(n)}-${CQ(r)}-${CQ(i)}${XX(Z(e,X),t)}`}function kQ({hour:e,minute:t,second:n,millisecond:r,microsecond:i,nanosecond:a},o){return TQ(e,t,n,1e6*r+1e3*i+a,o)}function AQ(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`${SQ(i)}-${CQ(a)}-${CQ(o)}T${TQ(s,c,l,1e6*u+1e3*d+f,n)}${XX(t,r)}`}function jQ(e,t=`auto`){let{year:n,month:r,day:i}=Z(e,QJ),a=`${CQ(r)}-${CQ(i)}`,o=Z(e,X);t!==`always`&&t!==`critical`&&o===`iso8601`||(a=`${SQ(n)}-${a}`);let s=XX(o,t);return s&&(a+=s),a}function MQ(e,t=`auto`){let{year:n,month:r,day:i}=Z(e,QJ),a=`${SQ(n)}-${CQ(r)}`,o=Z(e,X);t!==`always`&&t!==`critical`&&o===`iso8601`||(a+=`-${CQ(i)}`);let s=XX(o,t);return s&&(a+=s),a}function NQ(e,t,n=`auto`,r=`auto`,i=`auto`,a=void 0){let o=Z(e,ZJ);if(a){let{unit:e,increment:t,roundingMode:n}=a;o=Q$(o,t,e,n)}let s=Z(e,iY),c=hQ(s,o),l=AQ(_Q(s,o),`iso8601`,t,`never`);return i!==`never`&&(l+=HQ(c)),r!==`never`&&(l+=`[${r===`critical`?`!`:``}${s}]`),l+=XX(Z(e,X),n),l}function PQ(e){return rZ.test(e)}function FQ(e){let t=y1.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 IQ,LQ=Object.assign(Object.create(null),{"/":!0,"-":!0,_:!0});function RQ(e){if(IQ===void 0){let e=Intl.supportedValuesOf?.(`timeZone`);if(e){IQ=new Map;for(let t=0;t<e.length;t++){let n=e[t];IQ.set(g1(n),n)}}else IQ=null}let t=g1(e),n=IQ?.get(t);if(n)return{identifier:n,primaryIdentifier:n};try{n=BX(e).resolvedOptions().timeZone}catch{return}if(t===`antarctica/south_pole`&&(n=`Antarctica/McMurdo`),yX.has(e))throw RangeError(`${e} is a legacy time zone identifier from ICU. Use ${n} instead`);let r=[...t].map(((e,n)=>n===0||LQ[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 zQ(e,t){let{year:n,month:r,day:i,hour:a,minute:o,second:s}=JQ(e,t),c=t%1e3;return c<0&&(c+=1e3),1e6*(UQ({isoDate:{year:n,month:r,day:i},time:{hour:a,minute:o,second:s,millisecond:c}})-t)}function BQ(e,t){return zQ(e,s1(t,`floor`))}function VQ(e){let t=e<0?`-`:`+`,n=Math.abs(e);return`${t}${TQ(Math.floor(n/60),n%60,0,0,`minute`)}`}function HQ(e){return VQ(Z$(e,cX,`halfExpand`)/6e10)}function UQ({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()+mX*c}function WQ(e){let t=UQ(e),n=1e3*e.time.microsecond+e.time.nanosecond;return Y.default.add(c1(t),Y.default.BigInt(n))}function GQ(e){let t=s1(e,`trunc`),n=Y.default.toNumber(Y.default.remainder(e,zJ));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 KQ(e,t){if(e===`UTC`)return null;let n=s1(t,`floor`);if(n<_X)return KQ(e,c1(_X));let r=Math.max(n,Date.now())+366*oX*3,i=n,a=zQ(e,i),o=i,s=a;for(;a===s&&i<r;){if(o=i+2*oX*7,o>lX)return null;s=zQ(e,o),a===s&&(i=o)}return a===s?null:c1(b1((t=>zQ(e,t)),i,o,a,s))}function qQ(e,t){if(e===`UTC`)return null;let n=s1(t,`ceil`),r=Date.now(),i=r+366*oX*3;if(n>i){let t=qQ(e,c1(i));if(t===null||Y.default.lessThan(t,c1(r)))return t}if(e===`Africa/Casablanca`||e===`Africa/El_Aaiun`){let t=Date.UTC(2088,0,1);if(t<n)return qQ(e,c1(t))}let a=n-1;if(a<_X)return null;let o=zQ(e,a),s=a,c=o;for(;o===c&&a>_X;){if(s=a-2*oX*7,s<_X)return null;c=zQ(e,s),o===c&&(a=s)}return o===c?null:c1(b1((t=>zQ(e,t)),s,a,c,o))}function JQ(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}}(BX(e).format(t))}function YQ(e){return e!==void 0&&!(e%4!=0||e%100==0&&e%400!=0)}function XQ(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]}[YQ(e)?`leapyear`:`standard`][t-1]}function ZQ(e){let t=[Z(e,aY),Z(e,oY),Z(e,sY),Z(e,cY),Z(e,lY),Z(e,uY),Z(e,dY),Z(e,fY),Z(e,pY),Z(e,mY)];for(let e=0;e<t.length;e++){let n=t[e];if(n!==0)return n<0?-1:1}return 0}function QQ(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 $Q(e){let t=QQ(e.date);return t===0?e.time.sign():t}function e$(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 t$(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}=e$(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=YQ(c)?366:365,a<-s;)--r,--c,a+=s;for(c+=1;s=YQ(c)?366:365,a>s;)r+=1,c+=1,a-=s;for(;a<1;)({year:r,month:i}=e$(r,i-1)),a+=XQ(r,i);for(;a>XQ(r,i);)a-=XQ(r,i),{year:r,month:i}=e$(r,i+1);return{year:r,month:i,day:a}}function n$(e,t,n,r,i,a,o,s,c){let l=r$(r,i,a,o,s,c);return uZ(t$(e,t,n+l.deltaDays),l)}function r$(e,t,n,r,i,a){let o,s=e,c=t,l=n,u=r,d=i,f=a;({div:o,mod:f}=RY(f,3)),d+=o,f<0&&(--d,f+=1e3),{div:o,mod:d}=RY(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 i$(e,t){let n=lZ(e,0);if(QQ(n)===0)return e.days;let r=Z(t,QJ),i=aQ(Z(t,X),r,n,`constrain`),a=C$(r.year,r.month-1,r.day),o=C$(i.year,i.month-1,i.day)-a;return e.days+o}function a$(e){return new(LY(`%Temporal.Duration%`))(-Z(e,aY),-Z(e,oY),-Z(e,sY),-Z(e,cY),-Z(e,lY),-Z(e,uY),-Z(e,dY),-Z(e,fY),-Z(e,pY),-Z(e,mY))}function o$(e,t,n){return Math.min(n,Math.max(t,e))}function s$(e,t,n){let r=o$(t,1,12);return{year:e,month:r,day:o$(n,1,XQ(e,r))}}function c$(e,t,n){if(e<t||e>n)throw RangeError(`value out of range: ${t} <= ${e} <= ${n}`)}function l$(e,t,n){c$(t,1,12),c$(n,1,XQ(e,t))}function u$(e){p$(uZ(e,{deltaDays:0,hour:12,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0}))}function d$(e,t,n,r,i,a){c$(e,0,23),c$(t,0,59),c$(n,0,59),c$(r,0,999),c$(i,0,999),c$(a,0,999)}function f$(e,t,n,r,i,a,o,s,c){l$(e,t,n),d$(r,i,a,o,s,c)}function p$(e){let t=WQ(e);(Y.default.lessThan(t,fX)||Y.default.greaterThan(t,pX))&&h$(t)}function m$(e){WQ(e)}function h$(e){if(Y.default.lessThan(e,dX)||Y.default.greaterThan(e,uX))throw RangeError(`date/time value is outside of supported range`)}function g$({year:e,month:t}){c$(e,hX,gX),e===hX?c$(t,4,12):e===gX&&c$(t,1,9)}function _$(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=RY(s,3),p=RY(c,6),m=RY(l,9),h=RY(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 v$(e){return{date:{years:Z(e,aY),months:Z(e,oY),weeks:Z(e,sY),days:Z(e,cY)},time:HY.fromComponents(Z(e,lY),Z(e,uY),Z(e,dY),Z(e,fY),Z(e,pY),Z(e,mY))}}function y$(e){let t=HY.fromComponents(Z(e,lY),Z(e,uY),Z(e,dY),Z(e,fY),Z(e,pY),Z(e,mY)).add24HourDays(Z(e,cY));return{date:{years:Z(e,aY),months:Z(e,oY),weeks:Z(e,sY),days:0},time:t}}function b$(e){let t=y$(e),n=Math.trunc(t.time.sec/86400);return _$(t.date.years,t.date.months,t.date.weeks,n,0,0,0,0,0,0),{...t.date,days:n}}function x$(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=zY(o,3,Math.trunc(i/1e3)),i%=1e3,o=0;break;case`microsecond`:i=zY(o,6,Math.trunc(r/1e3)),r%=1e3,o=0;break;case`nanosecond`:r=zY(o,9,r),o=0}return new(LY(`%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 S$(e,t){return QQ(e),t.sign(),{date:e,time:t}}function C$(e,t,n){return UQ({isoDate:{year:e,month:t+1,day:n},time:{hour:0,minute:0,second:0,millisecond:0}})/oX}function w$({year:e,month:t,day:n}){if(Math.abs(C$(e,t-1,n))>1e8)throw RangeError(`date/time value is outside the supported range`)}function T$(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 HY.fromComponents(n,r,i,a,o,s)}function E$(e,t,n,r,i){let a=HY.fromEpochNsDiff(t,e);return a=t1(a,n,r,i),S$({years:0,months:0,weeks:0,days:0},a)}function D$(e,t,n,r){m$(e),m$(t);let i=T$(e.time,t.time),a=i.sign(),o=r1(e.isoDate,t.isoDate),s=t.isoDate;o===a&&(s=t$(s.year,s.month,s.day+a),i=i.add24HourDays(-a));let c=wZ(`day`,r),l=oQ(n,e.isoDate,s,c);return r!==c&&(i=i.add24HourDays(l.days),l.days=0),S$(l,i)}function O$(e,t,n,r,i){let a=Y.default.subtract(t,e);if(Y.default.equal(a,MJ))return{date:{years:0,months:0,weeks:0,days:0},time:HY.ZERO};let o=Y.default.lessThan(a,MJ)?-1:1,s=_Q(n,e),c=_Q(n,t),l,u=0,d=o===1?2:1,f=T$(s.time,c.time);for(f.sign()===-o&&u++;u<=d;u++){l=uZ(t$(c.isoDate.year,c.isoDate.month,c.isoDate.day-u*o),s.time);let e=vQ(n,l,`compatible`);if(f=HY.fromEpochNsDiff(t,e),f.sign()!==-o)break}let p=wZ(`day`,i);return S$(oQ(r,s.isoDate,l.isoDate,p),f)}function k$(e,t,n,r,i,a,o,s,c){let l,u,d,f,p=t;switch(s){case`year`:{let t=Z$(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=Z$(p.date.months,o,`trunc`);l=t,u=t+o*e,d=lZ(p.date,0,0,l),f=lZ(p.date,0,0,u);break}case`week`:{let t=lZ(p.date,0,0),n=aQ(a,r.isoDate,t,`constrain`),i=oQ(a,n,t$(n.year,n.month,n.day+p.date.days),`week`),s=Z$(p.date.weeks+i.weeks,o,`trunc`);l=s,u=s+o*e,d=lZ(p.date,0,l),f=lZ(p.date,0,u);break}case`day`:{let t=Z$(p.date.days,o,`trunc`);l=t,u=t+o*e,d=lZ(p.date,l),f=lZ(p.date,u);break}}let m=aQ(a,r.isoDate,d,`constrain`),h=aQ(a,r.isoDate,f,`constrain`),g,_,v=uZ(m,r.time),y=uZ(h,r.time);i?(g=vQ(i,v,`compatible`),_=vQ(i,y,`compatible`)):(g=WQ(v),_=WQ(y));let b=HY.fromEpochNsDiff(n,g),x=HY.fromEpochNsDiff(_,g),S=BY(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)?VY(Math.abs(l),Math.abs(u),C,w,S):Math.abs(u),E=new HY(Y.default.add(Y.default.multiply(x.totalNs,Y.default.BigInt(l)),Y.default.multiply(b.totalNs,Y.default.BigInt(o*e)))).fdiv(x.totalNs),D=T===Math.abs(u);return p={date:D?f:d,time:HY.ZERO},{nudgeResult:{duration:p,nudgedEpochNs:D?_:g,didExpandCalendarUnit:D},total:E}}function A$(e,t,n,r,i,a,o,s,c){let l=e,u=TZ(s)||r&&s===`day`,d=$Q(l)<0?-1:1,f;return u?{nudgeResult:f}=k$(d,l,t,n,r,i,o,s,c):f=r?function(e,t,n,r,i,a,o,s){let c=t,l=aQ(i,n.isoDate,c.date,`constrain`),u=uZ(l,n.time),d=uZ(t$(l.year,l.month,l.day+e),n.time),f=vQ(r,u,`compatible`),p=vQ(r,d,`compatible`),m=HY.fromEpochNsDiff(p,f);if(m.sign()!==e)throw RangeError(`time zone returned inconsistent Instants`);let h=Y.default.BigInt(IX[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:S$(lZ(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(Y.default.BigInt(r*IX[i]),a),l=c.subtract(s),{quotient:u}=s.divmod(sX),{quotient:d}=c.divmod(sX),f=Math.sign(d-u)===s.sign(),p=l.addToEpochNs(t),m=0,h=c;return EZ(n)===`date`&&(m=d,h=c.add(HY.fromComponents(24*-d,0,0,0,0,0))),{duration:{date:lZ(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=FX.indexOf(o);for(let t=FX.indexOf(s)-1;t>=l;t--){let s=FX[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=lZ(c.date,0,0,t);break}case`week`:{let t=c.date.weeks+e;l=lZ(c.date,0,t);break}}let u=uZ(aQ(a,r.isoDate,l,`constrain`),r.time),d;if(d=i?vQ(i,u,`compatible`):WQ(u),qJ(n,d)===-e)break;c={date:l,time:HY.ZERO}}return c}(d,l,f.nudgedEpochNs,n,r,i,a,wZ(s,`day`))),l}function j$(e,t,n,r,i,a){return TZ(a)||r&&a===`day`?k$($Q(e)<0?-1:1,e,t,n,r,i,1,a,`trunc`).total:n1(e.time.add24HourDays(e.date.days),a)}function M$(e,t,n,r,i,a,o){if(a1(e,t)==0)return{date:{years:0,months:0,weeks:0,days:0},time:HY.ZERO};p$(e),p$(t);let s=D$(e,t,n,r);return a===`nanosecond`&&i===1?s:A$(s,WQ(t),e,null,n,r,i,a,o)}function N$(e,t,n,r,i,a,o,s){if(EZ(i)===`time`)return E$(e,t,a,o,s);let c=O$(e,t,n,r,i);return o===`nanosecond`&&a===1?c:A$(c,t,_Q(n,e),n,r,i,a,o,s)}function P$(e,t,n,r,i,a){let o=MX.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=xZ(t,`largestUnit`,n,`auto`);if(r.includes(s))throw RangeError(`largestUnit must be one of ${o.join(`, `)}, not ${s}`);let c=gZ(t),l=pZ(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=xZ(t,`smallestUnit`,n,i);if(r.includes(u))throw RangeError(`smallestUnit must be one of ${o.join(`, `)}, not ${u}`);let d=wZ(a,u);if(s===`auto`&&(s=d),wZ(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&&_Z(c,f,!1),{largestUnit:s,roundingIncrement:c,roundingMode:l,smallestUnit:u}}function F$(e,t,n,r){let i=IZ(n),a=P$(e,$(r),`time`,[],`nanosecond`,`second`),o=x$(E$(Z(t,ZJ),Z(i,ZJ),a.roundingIncrement,a.smallestUnit,a.roundingMode),a.largestUnit);return e===`since`&&(o=a$(o)),o}function I$(e,t,n,r){let i=MZ(n),a=Z(t,X),o=Z(i,X);if(!lQ(a,o))throw RangeError(`cannot compute difference between dates of ${a} and ${o} calendars`);let s=P$(e,$(r),`date`,[],`day`,`day`),c=LY(`%Temporal.Duration%`),l=Z(t,QJ),u=Z(i,QJ);if(r1(l,u)===0)return new c;let d={date:oQ(a,l,u,s.largestUnit),time:HY.ZERO};if(s.smallestUnit!==`day`||s.roundingIncrement!==1){let e=uZ(l,{deltaDays:0,hour:0,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0});d=A$(d,WQ(uZ(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=x$(d,`day`);return e===`since`&&(f=a$(f)),f}function L$(e,t,n,r){let i=PZ(n),a=Z(t,X),o=Z(i,X);if(!lQ(a,o))throw RangeError(`cannot compute difference between dates of ${a} and ${o} calendars`);let s=P$(e,$(r),`datetime`,[],`nanosecond`,`day`),c=LY(`%Temporal.Duration%`),l=Z(t,$J),u=Z(i,$J);if(a1(l,u)===0)return new c;let d=x$(M$(l,u,a,s.largestUnit,s.roundingIncrement,s.smallestUnit,s.roundingMode),s.largestUnit);return e===`since`&&(d=a$(d)),d}function R$(e,t,n,r){let i=RZ(n),a=P$(e,$(r),`time`,[],`nanosecond`,`hour`),o=T$(Z(t,eY),Z(i,eY));o=t1(o,a.roundingIncrement,a.smallestUnit,a.roundingMode);let s=x$(S$({years:0,months:0,weeks:0,days:0},o),a.largestUnit);return e===`since`&&(s=a$(s)),s}function z$(e,t,n,r){let i=BZ(n),a=Z(t,X),o=Z(i,X);if(!lQ(a,o))throw RangeError(`cannot compute difference between months of ${a} and ${o} calendars`);let s=P$(e,$(r),`date`,[`week`,`day`],`month`,`year`),c=LY(`%Temporal.Duration%`);if(r1(Z(t,QJ),Z(i,QJ))==0)return new c;let l=kZ(a,Z(t,QJ),`year-month`);l.day=1;let u=uQ(a,l,`constrain`),d=kZ(a,Z(i,QJ),`year-month`);d.day=1;let f=uQ(a,d,`constrain`),p={date:lZ(oQ(a,u,f,s.largestUnit),0,0),time:HY.ZERO};if(s.smallestUnit!==`month`||s.roundingIncrement!==1){let e=uZ(u,{deltaDays:0,hour:0,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0});p=A$(p,WQ(uZ(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=x$(p,`day`);return e===`since`&&(m=a$(m)),m}function B$(e,t,n,r){let i=HZ(n),a=Z(t,X),o=Z(i,X);if(!lQ(a,o))throw RangeError(`cannot compute difference between dates of ${a} and ${o} calendars`);let s=P$(e,$(r),`datetime`,[],`nanosecond`,`hour`),c=Z(t,ZJ),l=Z(i,ZJ),u=LY(`%Temporal.Duration%`),d;if(EZ(s.largestUnit)!==`date`)d=x$(E$(c,l,s.roundingIncrement,s.smallestUnit,s.roundingMode),s.largestUnit);else{let e=Z(t,iY);if(!mQ(e,Z(i,iY)))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(Y.default.equal(c,l))return new u;d=x$(N$(c,l,e,a,s.largestUnit,s.roundingIncrement,s.smallestUnit,s.roundingMode),`hour`)}return e===`since`&&(d=a$(d)),d}function V$({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,r$(e,t,s,r,i,c)}function H$(e,t){let n=t.addToEpochNs(e);return h$(n),n}function U$(e,t,n,r,i=`constrain`){if(QQ(r.date)===0)return H$(e,r.time);let a=_Q(t,e);return H$(vQ(t,uZ(aQ(n,a.isoDate,r.date,i),a.time),`compatible`),r.time)}function W$(e,t,n){let r=FZ(n);e===`subtract`&&(r=a$(r));let i=wZ(CZ(t),CZ(r));if(TZ(i))throw RangeError(`For years, months, or weeks arithmetic, use date arithmetic relative to a starting point`);let a=y$(t),o=y$(r);return x$(S$({years:0,months:0,weeks:0,days:0},a.time.add(o.time)),i)}function G$(e,t,n){let r=FZ(n);e===`subtract`&&(r=a$(r));let i=CZ(r);if(EZ(i)===`date`)throw RangeError(`Duration field ${i} not supported by Temporal.Instant. Try Temporal.ZonedDateTime instead.`);let a=y$(r);return eQ(H$(Z(t,ZJ),a.time))}function K$(e,t,n,r){let i=Z(t,X),a=FZ(n);e===`subtract`&&(a=a$(a));let o=b$(a),s=dZ($(r));return WZ(aQ(i,Z(t,QJ),o,s),i)}function q$(e,t,n,r){let i=FZ(n);e===`subtract`&&(i=a$(i));let a=dZ($(r)),o=Z(t,X),s=y$(i),c=Z(t,$J),l=V$(c.time,s.time),u=lZ(s.date,l.deltaDays);return _$(u.years,u.months,u.weeks,u.days,0,0,0,0,0,0),KZ(uZ(aQ(o,c.isoDate,u,a),l),o)}function J$(e,t,n){let r=FZ(n);e===`subtract`&&(r=a$(r));let i=y$(r),{hour:a,minute:o,second:s,millisecond:c,microsecond:l,nanosecond:u}=V$(Z(t,eY),i.time);return XZ(sZ(a,o,s,c,l,u,`reject`))}function Y$(e,t,n,r){let i=FZ(n);e===`subtract`&&(i=a$(i));let a=dZ($(r)),o=ZQ(i),s=Z(t,X),c=kZ(s,Z(t,QJ),`year-month`);c.day=1;let l=uQ(s,c,`constrain`);if(o<0){let e=aQ(s,l,{months:1},`constrain`);l=t$(e.year,e.month,e.day-1)}let u=b$(i);return u$(l),QZ(dQ(s,kZ(s,aQ(s,l,u,a),`year-month`),a),s)}function X$(e,t,n,r){let i=FZ(n);e===`subtract`&&(i=a$(i));let a=dZ($(r)),o=Z(t,iY),s=Z(t,X),c=v$(i);return nQ(U$(Z(t,ZJ),o,s,c,a),o,s)}function Z$(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=f1(Math.abs(2*i)-t),l=o%2==0,u=BY(n,a),d=i===0?o:VY(o,s,c,l,u);return t*(a===`positive`?d:-d)}function Q$(e,t,n,r){let i=IX[n]*t;return function(e,t,n){let r=WJ(e),i=WJ(t),a=Y.default.divide(r,i),o=Y.default.remainder(r,i),s=BY(n,`positive`),c,l;Y.default.lessThan(r,MJ)?(c=Y.default.subtract(a,NJ),l=a):(c=a,l=Y.default.add(a,NJ));let u=qJ(KJ(Y.default.multiply(o,PJ)),i)*(Y.default.lessThan(r,MJ)?-1:1)+0,d=Y.default.equal(o,MJ)?a:VY(c,l,u,GJ(c),s);return Y.default.multiply(d,i)}(e,Y.default.BigInt(i),r)}function $$(e,t,n,r){m$(e);let{year:i,month:a,day:o}=e.isoDate,s=e1(e.time,t,n,r);return uZ(t$(i,a,o+s.deltaDays),s)}function e1({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=IX[s],d=Z$(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 r$(d,0,0,0,0,0);case`minute`:return r$(e,d,0,0,0,0);case`second`:return r$(e,t,d,0,0,0);case`millisecond`:return r$(e,t,n,d,0,0);case`microsecond`:return r$(e,t,n,r,d,0);case`nanosecond`:return r$(e,t,n,r,i,d);default:throw Error(`Invalid unit ${s}`)}}function t1(e,t,n,r){let i=IX[n];return e.round(Y.default.BigInt(i*t),r)}function n1(e,t){let n=IX[t];return e.fdiv(Y.default.BigInt(n))}function r1(e,t){return e.year===t.year?e.month===t.month?e.day===t.day?0:f1(e.day-t.day):f1(e.month-t.month):f1(e.year-t.year)}function i1(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:f1(e.nanosecond-t.nanosecond):f1(e.microsecond-t.microsecond):f1(e.millisecond-t.millisecond):f1(e.second-t.second):f1(e.minute-t.minute):f1(e.hour-t.hour)}function a1(e,t){let n=r1(e.isoDate,t.isoDate);return n===0?i1(e.time,t.time):n}function o1(e){let t=l1(e);return globalThis.BigInt===void 0?t:globalThis.BigInt(t.toString(10))}function s1(e,t){let{quotient:n,remainder:r}=JJ(WJ(e),zJ),i=Y.default.toNumber(n);return t===`floor`&&Y.default.toNumber(r)<0&&--i,t===`ceil`&&Y.default.toNumber(r)>0&&(i+=1),i}function c1(e){if(!Number.isInteger(e))throw RangeError(`epoch milliseconds must be an integer`);return Y.default.multiply(Y.default.BigInt(e),zJ)}function l1(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`?Y.default.BigInt(t.toString(10)):Y.default.BigInt(t)}var u1=(()=>{let e=Y.default.BigInt(Date.now()%1e6);return()=>{let t=Date.now(),n=Y.default.BigInt(t),r=Y.default.add(c1(t),e);return e=Y.default.remainder(n,zJ),Y.default.greaterThan(r,uX)?uX:Y.default.lessThan(r,dX)?dX:r}})();function d1(){return new Intl.DateTimeFormat().resolvedOptions().timeZone}function f1(e){return e<0?-1:e>0?1:e}function $(e){if(e===void 0)return Object.create(null);if(bX(e)&&e!==null)return e;throw TypeError(`Options parameter must be an object, not `+(e===null?`null`:typeof e))}function p1(e,t){let n=Object.create(null);return n[e]=t,n}function m1(e,t,n,r){let i=e[t];if(i!==void 0){if(i=SX(i),!n.includes(i))throw RangeError(`${t} must be one of ${n.join(`, `)}, not ${i}`);return i}if(r===bZ)throw RangeError(`${t} option is required`);return r}function h1(e){let t=g1(e);if(!vX.includes(g1(t)))throw RangeError(`invalid calendar identifier ${t}`);switch(t){case`ethiopic-amete-alem`:return`ethioaa`;case`islamicc`:return`islamic-civil`}return t}function g1(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 _1(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 v1=RegExp(`^${XY.source}$`),y1=RegExp(`^([+-])([01][0-9]|2[0-3])(?::?([0-5][0-9])(?::?([0-5][0-9])(?:[.,](\\d{1,9}))?)?)?$`);function b1(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 x1(e){return[...e]}function S1(e,t){if(e!==`gregory`&&e!==`iso8601`)return;let n=w1[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 C1(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 w1={};function T1(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 E1(e,t=!1){return`M${`${e}`.padStart(2,`0`)}${t?`L`:``}`}function D1(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`&&c$(r,1,n),t===`constrain`&&(r=o$(r,1,n)),i=E1(r)}else{let e=T1(i);if(i!==E1(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}}w1.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,D1(e))},dateToISO:(e,t)=>oZ(e.year,e.month,e.day,t),monthDayToISOReferenceDate(e,t){let{month:n,day:r}=oZ(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 x1(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}=e$(o,s),{year:o,month:s,day:c}=oZ(o,s,c,a),c+=i+7*r,t$(o,s,c)},dateUntil(e,t,n){let r=-r1(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);!C1(r,e.year+s,e.month,e.day,t);)a=s,s+=r;let c=r;for(i=e$(e.year+a,e.month+c);!C1(r,i.year,i.month,e.day,t);)o=c,c+=r,i=e$(i.year,i.month+r);n===`month`&&(o+=12*a,a=0)}i=e$(e.year+a,e.month+o);let s=s$(i.year,i.month,e.day),c=0,l=C$(t.year,t.month-1,t.day)-C$(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=E1(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+=XQ(e,n);i.dayOfYear=r}return r.weekOfYear&&(i.weekOfYear=S1(`iso8601`,{year:e,month:t,day:n})),r.daysInMonth&&(i.daysInMonth=XQ(e,t)),(r.daysInYear||r.inLeapYear)&&(i.inLeapYear=YQ(e),i.daysInYear=i.inLeapYear?366:365),i},getFirstDayOfWeek:()=>1,getMinimalDaysInFirstWeek:()=>4};var O1=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 k1({isoYear:e,isoMonth:t,isoDay:n}){return`${SQ(e)}-${CQ(t)}-${CQ(n)}T00:00Z`}function A1(e,t){return{years:e.year-t.year,months:e.month-t.month,days:e.day-t.day}}O1.objectMap=new WeakMap,O1.MAX_CACHE_ENTRIES=1e3;var j1=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=k1({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}=D1(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`?(c$(i,1,r),c$(a,1,this.maximumMonthLength(e))):(i=o$(i,1,r),a=o$(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=A1(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=A1(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=A1(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:f1(e.day-t.day):f1(e.month-t.month):f1(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 t$(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 C$(i.year,i.month-1,i.day)-C$(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(){}},M1=class extends j1{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?E1(5,!0):E1(t<6?t:t-1):E1(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=T1(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`?(c$(a,1,this.monthsInYear({year:i})),c$(s,1,this.maximumMonthLength({year:i,month:a}))):(a=o$(a,1,this.monthsInYear({year:i})),s=o$(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}}},N1=class extends j1{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}}},P1=class extends N1{constructor(){super(...arguments),this.id=`islamic`}},F1=class extends N1{constructor(){super(...arguments),this.id=`islamic-umalqura`}},I1=class extends N1{constructor(){super(...arguments),this.id=`islamic-tbla`}},L1=class extends N1{constructor(){super(...arguments),this.id=`islamic-civil`}},R1=class extends N1{constructor(){super(...arguments),this.id=`islamic-rgsa`}},z1=class extends N1{constructor(){super(...arguments),this.id=`islamicc`}},B1=class extends j1{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 T1(e)<=6?31:30}estimateIsoDate(e){let{year:t}=this.adjustCalendarDate(e);return{year:t+621,month:1,day:1}}},V1=class extends j1{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 H1(e.year+78)}monthsInYear(){return 12}minimumMonthLength(e){return this.getMonthInfo(e).length}maximumMonthLength(e){return this.getMonthInfo(e).length}maxLengthOfMonthCodeInAnyYear(e){let t=T1(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 t$(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 H1(e){return e%4==0&&(e%100!=0||e%400==0)}var U1=class extends j1{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 H1(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][T1(e)-1]}estimateIsoDate(e){let t=this.adjustCalendarDate(e);return oZ(t.year+this.isoEpoch.year,t.month+this.isoEpoch.month,t.day+this.isoEpoch.day,`constrain`)}},W1=class extends j1{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 H1(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][T1(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:T1(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 oZ(t+i.isoEpoch.year-+!i.hasYearZero,n,r,`constrain`)}},G1=class extends W1{constructor(e,t){super(e,t)}isoToCalendarDate(e){let{year:t,month:n,day:r}=e,i=E1(n),a=t-this.anchorEra.isoEpoch.year+1;return this.completeEraYear({year:a,month:n,monthCode:i,day:r})}},K1={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},q1=class extends U1{constructor(e,t){super(e,t),this.inLeapYear=K1.inLeapYear,this.monthsInYear=K1.monthsInYear,this.minimumMonthLength=K1.minimumMonthLength,this.maximumMonthLength=K1.maximumMonthLength,this.maxLengthOfMonthCodeInAnyYear=K1.maxLengthOfMonthCodeInAnyYear}},J1=class extends W1{constructor(e,t){super(e,t),this.inLeapYear=K1.inLeapYear,this.monthsInYear=K1.monthsInYear,this.minimumMonthLength=K1.minimumMonthLength,this.maximumMonthLength=K1.maximumMonthLength,this.maxLengthOfMonthCodeInAnyYear=K1.maxLengthOfMonthCodeInAnyYear}},Y1=class extends q1{constructor(){super(`ethioaa`,{year:-5492,month:7,day:17})}},X1=class extends J1{constructor(){super(`coptic`,[{code:`coptic`,isoEpoch:{year:284,month:8,day:29}},{code:`coptic-inverse`,reverseOf:`coptic`}])}},Z1=class extends J1{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}}])}},Q1=class extends G1{constructor(){super(`roc`,[{code:`roc`,names:[`minguo`],isoEpoch:{year:1912,month:1,day:1}},{code:`roc-inverse`,names:[`before-roc`],reverseOf:`roc`}])}},$1=class extends U1{constructor(){super(`buddhist`,{year:-543,month:1,day:1})}},e0=class extends G1{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}},t0=class extends G1{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}}},n0=class extends j1{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=k1({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=E1(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=E1(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`?(c$(a,1,o),c$(s,1,this.maximumMonthLength())):(a=o$(a,1,o),s=o$(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=E1(+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}}},r0=class extends n0{constructor(){super(...arguments),this.id=`chinese`}},i0=class extends n0{constructor(){super(...arguments),this.id=`dangi`}},a0=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 O1;D1(e,void 0,this.helper.monthsInYear({year:e.year??1972},t))}}dateToISO(e,t){let n=new O1,r=this.helper.calendarToIsoDate(e,t,n);return n.setObject(r),r}monthDayToISOReferenceDate(e,t){let n=new O1,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 x1(t)}dateAdd(e,{years:t,months:n,weeks:r,days:i},a){let o=O1.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 O1.getCacheForObject(l)||new O1(o).setObject(l),l}dateUntil(e,t,n){let r=O1.getCacheForObject(e),i=O1.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=O1.getCacheForObject(e),r=this.helper.isoToCalendarDate(e,n);if(t.dayOfWeek&&(r.dayOfWeek=w1.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=S1(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[M1,B1,Z1,Y1,X1,r0,i0,Q1,V1,$1,e0,t0,P1,F1,I1,L1,R1,z1]){let t=new e;w1[t.id]=new a0(t)}IY(`calendarImpl`,(function(e){return w1[e]}));var o0=Intl.DateTimeFormat;function s0(e,t){let n=Z(e,t);return typeof n==`function`&&(n=new o0(Z(e,TY),n(Z(e,EY))),function(e,t,n){let r=kY(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 c0(e){return MY(e,xY)}var l0=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 o0(t,i),o=a.resolvedOptions();if(jY(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,NY(e,EY,t)}else NY(e,EY,i);NY(e,TY,o.locale),NY(e,xY,a),NY(e,SY,o.timeZone),NY(e,wY,o.calendar),NY(e,hY,b0),NY(e,gY,v0),NY(e,_Y,y0),NY(e,vY,_0),NY(e,yY,x0),NY(e,bY,S0);let s=r?i.timeZone:void 0;if(s===void 0)NY(e,CY,o.timeZone);else{let t=SX(s);if(t.startsWith(`−`))throw RangeError(`Unicode minus (U+2212) is not supported in time zone offsets`);NY(e,CY,pQ(t))}})(this,e,t)}get format(){Q(this,c0);let e=f0.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 Q(this,c0),m0.call(this,e,t)}formatToParts(e,...t){return Q(this,c0),p0.call(this,e,...t)}formatRangeToParts(e,t){return Q(this,c0),h0.call(this,e,t)}resolvedOptions(){return Q(this,c0),d0.call(this)}};`formatToParts`in o0.prototype||delete l0.prototype.formatToParts,`formatRangeToParts`in o0.prototype||delete l0.prototype.formatRangeToParts;var u0=function(e=void 0,t=void 0){return new l0(e,t)};function d0(){let e=Z(this,xY).resolvedOptions();return e.timeZone=Z(this,CY),e}function f0(e,...t){let n,r,i=k0(e,this);return i.formatter?(n=i.formatter,r=[s1(i.epochNs,`floor`)]):(n=Z(this,xY),r=[e,...t]),n.format(...r)}function p0(e,...t){let n,r,i=k0(e,this);return i.formatter?(n=i.formatter,r=[s1(i.epochNs,`floor`)]):(n=Z(this,xY),r=[e,...t]),n.formatToParts(...r)}function m0(e,t){if(e===void 0||t===void 0)throw TypeError(`Intl.DateTimeFormat.formatRange requires two values`);let n=D0(e),r=D0(t),i,a=[n,r];if(E0(n)!==E0(r))throw TypeError(`Intl.DateTimeFormat.formatRange accepts two values of the same type`);if(E0(n)){if(!O0(n,r))throw TypeError(`Intl.DateTimeFormat.formatRange accepts two values of the same type`);let{epochNs:e,formatter:t}=k0(n,this),{epochNs:o,formatter:s}=k0(r,this);t&&(i=t,a=[s1(e,`floor`),s1(o,`floor`)])}return i||=Z(this,xY),i.formatRange(...a)}function h0(e,t){if(e===void 0||t===void 0)throw TypeError(`Intl.DateTimeFormat.formatRange requires two values`);let n=D0(e),r=D0(t),i,a=[n,r];if(E0(n)!==E0(r))throw TypeError(`Intl.DateTimeFormat.formatRangeToParts accepts two values of the same type`);if(E0(n)){if(!O0(n,r))throw TypeError(`Intl.DateTimeFormat.formatRangeToParts accepts two values of the same type`);let{epochNs:e,formatter:t}=k0(n,this),{epochNs:o,formatter:s}=k0(r,this);t&&(i=t,a=[s1(e,`floor`),s1(o,`floor`)])}return i||=Z(this,xY),i.formatRangeToParts(...a)}function g0(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 _0(e){let t=g0(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`})),!w0(t)){if(T0(e))throw TypeError(`cannot format Temporal.PlainTime with options [${Object.keys(e)}]`);Object.assign(t,{hour:`numeric`,minute:`numeric`,second:`numeric`})}return t}function v0(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=g0(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(T0(e))throw TypeError(`cannot format PlainYearMonth with options [${Object.keys(e)}]`);Object.assign(n,{year:`numeric`,month:`numeric`})}return n}function y0(e){let t={short:{month:`numeric`,day:`numeric`},medium:{month:`short`,day:`numeric`},long:{month:`long`,day:`numeric`},full:{month:`long`,day:`numeric`}},n=g0(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(T0(e))throw TypeError(`cannot format PlainMonthDay with options [${Object.keys(e)}]`);Object.assign(n,{month:`numeric`,day:`numeric`})}return n}function b0(e){let t=g0(e,{hour:!1,minute:!1,second:!1,dayPeriod:!1,timeZoneName:!1,timeStyle:!1});if(!C0(t)){if(T0(e))throw TypeError(`cannot format PlainDate with options [${Object.keys(e)}]`);Object.assign(t,{year:`numeric`,month:`numeric`,day:`numeric`})}return t}function x0(e){let t=g0(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),!w0(t)&&!C0(t)){if(T0(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 S0(e){let t=e;return w0(t)||C0(t)||(t=Object.assign({},t,{year:`numeric`,month:`numeric`,day:`numeric`,hour:`numeric`,minute:`numeric`,second:`numeric`})),t}function C0(e){return`year`in e||`month`in e||`day`in e||`weekday`in e||`dateStyle`in e||`era`in e}function w0(e){return`hour`in e||`minute`in e||`second`in e||`timeStyle`in e||`dayPeriod`in e||`fractionalSecondDigits`in e}function T0(e){return C0(e)||w0(e)||`dateStyle`in e||`timeStyle`in e||`timeZoneName`in e}function E0(e){return UX(e)||WX(e)||GX(e)||JX(e)||KX(e)||qX(e)||VX(e)}function D0(e){return E0(e)?e:xX(e)}function O0(e,t){return!(!E0(e)||!E0(t)||WX(e)&&!WX(t)||UX(e)&&!UX(t)||GX(e)&&!GX(t)||JX(e)&&!JX(t)||KX(e)&&!KX(t)||qX(e)&&!qX(t)||VX(e)&&!VX(t))}function k0(e,t){if(WX(e)){let n={isoDate:{year:1970,month:1,day:1},time:Z(e,eY)};return{epochNs:vQ(Z(t,SY),n,`compatible`),formatter:s0(t,vY)}}if(KX(e)){let n=Z(e,X),r=Z(t,wY);if(n!==r)throw RangeError(`cannot format PlainYearMonth with calendar ${n} in locale with calendar ${r}`);let i=uZ(Z(e,QJ),{deltaDays:0,hour:12,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0});return{epochNs:vQ(Z(t,SY),i,`compatible`),formatter:s0(t,gY)}}if(qX(e)){let n=Z(e,X),r=Z(t,wY);if(n!==r)throw RangeError(`cannot format PlainMonthDay with calendar ${n} in locale with calendar ${r}`);let i=uZ(Z(e,QJ),{deltaDays:0,hour:12,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0});return{epochNs:vQ(Z(t,SY),i,`compatible`),formatter:s0(t,_Y)}}if(UX(e)){let n=Z(e,X),r=Z(t,wY);if(n!==`iso8601`&&n!==r)throw RangeError(`cannot format PlainDate with calendar ${n} in locale with calendar ${r}`);let i=uZ(Z(e,QJ),{deltaDays:0,hour:12,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0});return{epochNs:vQ(Z(t,SY),i,`compatible`),formatter:s0(t,hY)}}if(GX(e)){let n=Z(e,X),r=Z(t,wY);if(n!==`iso8601`&&n!==r)throw RangeError(`cannot format PlainDateTime with calendar ${n} in locale with calendar ${r}`);let i=Z(e,$J);return{epochNs:vQ(Z(t,SY),i,`compatible`),formatter:s0(t,yY)}}if(JX(e))throw TypeError(`Temporal.ZonedDateTime not supported in DateTimeFormat methods. Use toLocaleString() instead.`);return VX(e)?{epochNs:Z(e,ZJ),formatter:s0(t,bY)}:{}}function A0(e){let t=Object.create(null);return t.years=Z(e,aY),t.months=Z(e,oY),t.weeks=Z(e,sY),t.days=Z(e,cY),t.hours=Z(e,lY),t.minutes=Z(e,uY),t.seconds=Z(e,dY),t.milliseconds=Z(e,fY),t.microseconds=Z(e,pY),t.nanoseconds=Z(e,mY),t}l0.prototype.constructor=u0,Object.defineProperty(u0,"prototype",{value:l0.prototype,writable:!1,enumerable:!1,configurable:!1}),u0.supportedLocalesOf=o0.supportedLocalesOf,FY(u0,`Intl.DateTimeFormat`);var{format:j0,formatToParts:M0}=Intl.DurationFormat?.prototype??Object.create(null);function N0(e){Intl.DurationFormat.prototype.resolvedOptions.call(this);let t=A0(FZ(e));return j0.call(this,t)}Intl.DurationFormat?.prototype&&(Intl.DurationFormat.prototype.format=N0,Intl.DurationFormat.prototype.formatToParts=function(e){Intl.DurationFormat.prototype.resolvedOptions.call(this);let t=A0(FZ(e));return M0.call(this,t)}),Object.freeze({__proto__:null,DateTimeFormat:u0,ModifiedIntlDurationFormatPrototypeFormat:N0});var P0=class{constructor(e){if(arguments.length<1)throw TypeError(`missing argument: epochNanoseconds is required`);$Z(this,l1(e))}get epochMilliseconds(){return Q(this,VX),s1(Z(this,ZJ),`floor`)}get epochNanoseconds(){return Q(this,VX),o1(Y.default.BigInt(Z(this,ZJ)))}add(e){return Q(this,VX),G$(`add`,this,e)}subtract(e){return Q(this,VX),G$(`subtract`,this,e)}until(e,t=void 0){return Q(this,VX),F$(`until`,this,e,t)}since(e,t=void 0){return Q(this,VX),F$(`since`,this,e,t)}round(e){if(Q(this,VX),e===void 0)throw TypeError(`options parameter is required`);let t=typeof e==`string`?p1(`smallestUnit`,e):$(e),n=gZ(t),r=pZ(t,`halfExpand`),i=xZ(t,`smallestUnit`,`time`,bZ);return _Z(n,{hour:24,minute:1440,second:86400,millisecond:864e5,microsecond:864e8,nanosecond:864e11}[i],!0),eQ(Q$(Z(this,ZJ),n,i,r))}equals(e){Q(this,VX);let t=IZ(e),n=Z(this,ZJ),r=Z(t,ZJ);return Y.default.equal(Y.default.BigInt(n),Y.default.BigInt(r))}toString(e=void 0){Q(this,VX);let t=$(e),n=vZ(t),r=pZ(t,`trunc`),i=xZ(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=pQ(a));let{precision:o,unit:s,increment:c}=yZ(i,n);return EQ(eQ(Q$(Z(this,ZJ),c,s,r)),a,o)}toJSON(){return Q(this,VX),EQ(this,void 0,`auto`)}toLocaleString(e=void 0,t=void 0){return Q(this,VX),new u0(e,t).format(this)}valueOf(){_1(`Instant`)}toZonedDateTimeISO(e){Q(this,VX);let t=pQ(e);return nQ(Z(this,ZJ),t,`iso8601`)}static fromEpochMilliseconds(e){return eQ(c1(xX(e)))}static fromEpochNanoseconds(e){return eQ(l1(e))}static from(e){return IZ(e)}static compare(e,t){let n=IZ(e),r=IZ(t),i=Z(n,ZJ),a=Z(r,ZJ);return Y.default.lessThan(i,a)?-1:+!!Y.default.greaterThan(i,a)}};FY(P0,`Temporal.Instant`);var F0=class{constructor(e,t,n,r=`iso8601`){let i=CX(e),a=CX(t),o=CX(n),s=h1(r===void 0?`iso8601`:DX(r));l$(i,a,o),UZ(this,{year:i,month:a,day:o},s)}get calendarId(){return Q(this,UX),Z(this,X)}get era(){return I0(this,`era`)}get eraYear(){return I0(this,`eraYear`)}get year(){return I0(this,`year`)}get month(){return I0(this,`month`)}get monthCode(){return I0(this,`monthCode`)}get day(){return I0(this,`day`)}get dayOfWeek(){return I0(this,`dayOfWeek`)}get dayOfYear(){return I0(this,`dayOfYear`)}get weekOfYear(){return I0(this,`weekOfYear`)?.week}get yearOfWeek(){return I0(this,`weekOfYear`)?.year}get daysInWeek(){return I0(this,`daysInWeek`)}get daysInMonth(){return I0(this,`daysInMonth`)}get daysInYear(){return I0(this,`daysInYear`)}get monthsInYear(){return I0(this,`monthsInYear`)}get inLeapYear(){return I0(this,`inLeapYear`)}with(e,t=void 0){if(Q(this,UX),!bX(e))throw TypeError(`invalid argument`);YX(e);let n=Z(this,X),r=kZ(n,Z(this,QJ));return r=iQ(n,r,AZ(n,e,[`year`,`month`,`monthCode`,`day`],[],`partial`)),WZ(uQ(n,r,dZ($(t))),n)}withCalendar(e){Q(this,UX);let t=sQ(e);return WZ(Z(this,QJ),t)}add(e,t=void 0){return Q(this,UX),K$(`add`,this,e,t)}subtract(e,t=void 0){return Q(this,UX),K$(`subtract`,this,e,t)}until(e,t=void 0){return Q(this,UX),I$(`until`,this,e,t)}since(e,t=void 0){return Q(this,UX),I$(`since`,this,e,t)}equals(e){Q(this,UX);let t=MZ(e);return r1(Z(this,QJ),Z(t,QJ))===0&&lQ(Z(this,X),Z(t,X))}toString(e=void 0){return Q(this,UX),OQ(this,hZ($(e)))}toJSON(){return Q(this,UX),OQ(this)}toLocaleString(e=void 0,t=void 0){return Q(this,UX),new u0(e,t).format(this)}valueOf(){_1(`PlainDate`)}toPlainDateTime(e=void 0){Q(this,UX);let t=zZ(e);return KZ(uZ(Z(this,QJ),t),Z(this,X))}toZonedDateTime(e){let t,n;if(Q(this,UX),bX(e)){let r=e.timeZone;r===void 0?t=pQ(e):(t=pQ(r),n=e.plainTime)}else t=pQ(e);let r=Z(this,QJ),i;return n===void 0?i=xQ(t,r):(n=RZ(n),i=vQ(t,uZ(r,Z(n,eY)),`compatible`)),nQ(i,t,Z(this,X))}toPlainYearMonth(){Q(this,UX);let e=Z(this,X);return QZ(dQ(e,kZ(e,Z(this,QJ)),`constrain`),e)}toPlainMonthDay(){Q(this,UX);let e=Z(this,X);return JZ(fQ(e,kZ(e,Z(this,QJ)),`constrain`),e)}static from(e,t=void 0){return MZ(e,t)}static compare(e,t){let n=MZ(e),r=MZ(t);return r1(Z(n,QJ),Z(r,QJ))}};function I0(e,t){Q(e,UX);let n=Z(e,QJ);return OZ(e).isoToDate(n,{[t]:!0})[t]}FY(F0,`Temporal.PlainDate`);var L0=class{constructor(e,t,n,r=0,i=0,a=0,o=0,s=0,c=0,l=`iso8601`){let u=CX(e),d=CX(t),f=CX(n),p=r===void 0?0:CX(r),m=i===void 0?0:CX(i),h=a===void 0?0:CX(a),g=o===void 0?0:CX(o),_=s===void 0?0:CX(s),v=c===void 0?0:CX(c),y=h1(l===void 0?`iso8601`:DX(l));f$(u,d,f,p,m,h,g,_,v),GZ(this,{isoDate:{year:u,month:d,day:f},time:{hour:p,minute:m,second:h,millisecond:g,microsecond:_,nanosecond:v}},y)}get calendarId(){return Q(this,GX),Z(this,X)}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 z0(this,`hour`)}get minute(){return z0(this,`minute`)}get second(){return z0(this,`second`)}get millisecond(){return z0(this,`millisecond`)}get microsecond(){return z0(this,`microsecond`)}get nanosecond(){return z0(this,`nanosecond`)}get era(){return R0(this,`era`)}get eraYear(){return R0(this,`eraYear`)}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 daysInWeek(){return R0(this,`daysInWeek`)}get daysInYear(){return R0(this,`daysInYear`)}get daysInMonth(){return R0(this,`daysInMonth`)}get monthsInYear(){return R0(this,`monthsInYear`)}get inLeapYear(){return R0(this,`inLeapYear`)}with(e,t=void 0){if(Q(this,GX),!bX(e))throw TypeError(`invalid argument`);YX(e);let n=Z(this,X),r=Z(this,$J),i={...kZ(n,r.isoDate),...r.time};return i=iQ(n,i,AZ(n,e,[`year`,`month`,`monthCode`,`day`],[`hour`,`minute`,`second`,`millisecond`,`microsecond`,`nanosecond`],`partial`)),KZ(NZ(n,i,dZ($(t))),n)}withPlainTime(e=void 0){Q(this,GX);let t=zZ(e);return KZ(uZ(Z(this,$J).isoDate,t),Z(this,X))}withCalendar(e){Q(this,GX);let t=sQ(e);return KZ(Z(this,$J),t)}add(e,t=void 0){return Q(this,GX),q$(`add`,this,e,t)}subtract(e,t=void 0){return Q(this,GX),q$(`subtract`,this,e,t)}until(e,t=void 0){return Q(this,GX),L$(`until`,this,e,t)}since(e,t=void 0){return Q(this,GX),L$(`since`,this,e,t)}round(e){if(Q(this,GX),e===void 0)throw TypeError(`options parameter is required`);let t=typeof e==`string`?p1(`smallestUnit`,e):$(e),n=gZ(t),r=pZ(t,`halfExpand`),i=xZ(t,`smallestUnit`,`time`,bZ,[`day`]),a={day:1,hour:24,minute:60,second:60,millisecond:1e3,microsecond:1e3,nanosecond:1e3}[i];_Z(n,a,a===1);let o=Z(this,$J);return KZ(n===1&&i===`nanosecond`?o:$$(o,n,i,r),Z(this,X))}equals(e){Q(this,GX);let t=PZ(e);return a1(Z(this,$J),Z(t,$J))===0&&lQ(Z(this,X),Z(t,X))}toString(e=void 0){Q(this,GX);let t=$(e),n=hZ(t),r=vZ(t),i=pZ(t,`trunc`),a=xZ(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}=yZ(a,r),l=$$(Z(this,$J),c,s,i);return p$(l),AQ(l,Z(this,X),o,n)}toJSON(){return Q(this,GX),AQ(Z(this,$J),Z(this,X),`auto`)}toLocaleString(e=void 0,t=void 0){return Q(this,GX),new u0(e,t).format(this)}valueOf(){_1(`PlainDateTime`)}toZonedDateTime(e,t=void 0){Q(this,GX);let n=pQ(e),r=fZ($(t));return nQ(vQ(n,Z(this,$J),r),n,Z(this,X))}toPlainDate(){return Q(this,GX),WZ(Z(this,$J).isoDate,Z(this,X))}toPlainTime(){return Q(this,GX),XZ(Z(this,$J).time)}static from(e,t=void 0){return PZ(e,t)}static compare(e,t){let n=PZ(e),r=PZ(t);return a1(Z(n,$J),Z(r,$J))}};function R0(e,t){Q(e,GX);let n=Z(e,$J).isoDate;return OZ(e).isoToDate(n,{[t]:!0})[t]}function z0(e,t){return Q(e,GX),Z(e,$J).time[t]}FY(L0,`Temporal.PlainDateTime`);var B0=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:TX(e),d=t===void 0?0:TX(t),f=n===void 0?0:TX(n),p=r===void 0?0:TX(r),m=i===void 0?0:TX(i),h=a===void 0?0:TX(a),g=o===void 0?0:TX(o),_=s===void 0?0:TX(s),v=c===void 0?0:TX(c),y=l===void 0?0:TX(l);_$(u,d,f,p,m,h,g,_,v,y),jY(this),NY(this,aY,u),NY(this,oY,d),NY(this,sY,f),NY(this,cY,p),NY(this,lY,m),NY(this,uY,h),NY(this,dY,g),NY(this,fY,_),NY(this,pY,v),NY(this,mY,y)}get years(){return Q(this,HX),Z(this,aY)}get months(){return Q(this,HX),Z(this,oY)}get weeks(){return Q(this,HX),Z(this,sY)}get days(){return Q(this,HX),Z(this,cY)}get hours(){return Q(this,HX),Z(this,lY)}get minutes(){return Q(this,HX),Z(this,uY)}get seconds(){return Q(this,HX),Z(this,dY)}get milliseconds(){return Q(this,HX),Z(this,fY)}get microseconds(){return Q(this,HX),Z(this,pY)}get nanoseconds(){return Q(this,HX),Z(this,mY)}get sign(){return Q(this,HX),ZQ(this)}get blank(){return Q(this,HX),ZQ(this)===0}with(t){Q(this,HX);let{years:n=Z(this,aY),months:r=Z(this,oY),weeks:i=Z(this,sY),days:a=Z(this,cY),hours:o=Z(this,lY),minutes:s=Z(this,uY),seconds:c=Z(this,dY),milliseconds:l=Z(this,fY),microseconds:u=Z(this,pY),nanoseconds:d=Z(this,mY)}=cZ(t);return new e(n,r,i,a,o,s,c,l,u,d)}negated(){return Q(this,HX),a$(this)}abs(){return Q(this,HX),new e(Math.abs(Z(this,aY)),Math.abs(Z(this,oY)),Math.abs(Z(this,sY)),Math.abs(Z(this,cY)),Math.abs(Z(this,lY)),Math.abs(Z(this,uY)),Math.abs(Z(this,dY)),Math.abs(Z(this,fY)),Math.abs(Z(this,pY)),Math.abs(Z(this,mY)))}add(e){return Q(this,HX),W$(`add`,this,e)}subtract(e){return Q(this,HX),W$(`subtract`,this,e)}round(e){if(Q(this,HX),e===void 0)throw TypeError(`options parameter is required`);let t=CZ(this),n=typeof e==`string`?p1(`smallestUnit`,e):$(e),r=xZ(n,`largestUnit`,`datetime`,void 0,[`auto`]),{plainRelativeTo:i,zonedRelativeTo:a}=SZ(n),o=gZ(n),s=pZ(n,`halfExpand`),c=xZ(n,`smallestUnit`,`datetime`,void 0),l=!0;c||=(l=!1,`nanosecond`);let u=wZ(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(wZ(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&&_Z(o,f,!1),o>1&&EZ(c)===`date`&&r!==c)throw RangeError(`For calendar units with roundingIncrement > 1, use largestUnit = smallestUnit`);if(a){let e=v$(this),t=Z(a,iY),n=Z(a,X),i=Z(a,ZJ);return e=N$(i,U$(i,t,n,e),t,n,r,o,c,s),EZ(r)===`date`&&(r=`hour`),x$(e,r)}if(i){let e=y$(this),t=V$({deltaDays:0,hour:0,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0},e.time),n=Z(i,QJ),a=Z(i,X),l=aQ(a,n,lZ(e.date,t.deltaDays),`constrain`);return e=M$(uZ(n,{deltaDays:0,hour:0,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0}),uZ(l,t),a,r,o,c,s),x$(e,r)}if(TZ(t))throw RangeError(`a starting point is required for ${t}s balancing`);if(TZ(r))throw RangeError(`a starting point is required for ${r}s balancing`);let p=y$(this);if(c===`day`){let{quotient:e,remainder:t}=p.time.divmod(sX),n=p.date.days+e+n1(t,`day`);n=Z$(n,o,s),p=S$({years:0,months:0,weeks:0,days:n},HY.ZERO)}else p=S$({years:0,months:0,weeks:0,days:0},t1(p.time,o,c,s));return x$(p,r)}total(e){if(Q(this,HX),e===void 0)throw TypeError(`options argument is required`);let t=typeof e==`string`?p1(`unit`,e):$(e),{plainRelativeTo:n,zonedRelativeTo:r}=SZ(t),i=xZ(t,`unit`,`datetime`,bZ);if(r){let e=v$(this),t=Z(r,iY),n=Z(r,X),a=Z(r,ZJ);return function(e,t,n,r,i){return EZ(i)===`time`?n1(HY.fromEpochNsDiff(t,e),i):j$(O$(e,t,n,r,i),t,_Q(n,e),n,r,i)}(a,U$(a,t,n,e),t,n,i)}if(n){let e=y$(this),t=V$({deltaDays:0,hour:0,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0},e.time),r=Z(n,QJ),a=Z(n,X),o=aQ(a,r,lZ(e.date,t.deltaDays),`constrain`);return function(e,t,n,r){if(a1(e,t)==0)return 0;p$(e),p$(t);let i=D$(e,t,n,r);return r===`nanosecond`?Y.default.toNumber(i.time.totalNs):j$(i,WQ(t),e,null,n,r)}(uZ(r,{deltaDays:0,hour:0,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0}),uZ(o,t),a,i)}let a=CZ(this);if(TZ(a))throw RangeError(`a starting point is required for ${a}s total`);if(TZ(i))throw RangeError(`a starting point is required for ${i}s total`);return n1(y$(this).time,i)}toString(e=void 0){Q(this,HX);let t=$(e),n=vZ(t),r=pZ(t,`trunc`),i=xZ(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}=yZ(i,n);if(o===`nanosecond`&&s===1)return DQ(this,a);let c=CZ(this),l=v$(this),u=t1(l.time,s,o,r);return l=S$(l.date,u),DQ(x$(l,wZ(c,`second`)),a)}toJSON(){return Q(this,HX),DQ(this,`auto`)}toLocaleString(e=void 0,t=void 0){if(Q(this,HX),typeof Intl.DurationFormat==`function`){let n=new Intl.DurationFormat(e,t);return N0.call(n,this)}return console.warn(`Temporal.Duration.prototype.toLocaleString() requires Intl.DurationFormat.`),DQ(this,`auto`)}valueOf(){_1(`Duration`)}static from(e){return FZ(e)}static compare(e,t,n=void 0){let r=FZ(e),i=FZ(t),{plainRelativeTo:a,zonedRelativeTo:o}=SZ($(n));if(Z(r,aY)===Z(i,aY)&&Z(r,oY)===Z(i,oY)&&Z(r,sY)===Z(i,sY)&&Z(r,cY)===Z(i,cY)&&Z(r,lY)===Z(i,lY)&&Z(r,uY)===Z(i,uY)&&Z(r,dY)===Z(i,dY)&&Z(r,fY)===Z(i,fY)&&Z(r,pY)===Z(i,pY)&&Z(r,mY)===Z(i,mY))return 0;let s=CZ(r),c=CZ(i),l=v$(r),u=v$(i);if(o&&(EZ(s)===`date`||EZ(c)===`date`)){let e=Z(o,iY),t=Z(o,X),n=Z(o,ZJ),r=U$(n,e,t,l),i=U$(n,e,t,u);return f1(Y.default.toNumber(Y.default.subtract(r,i)))}let d=l.date.days,f=u.date.days;if(TZ(s)||TZ(c)){if(!a)throw RangeError(`A starting point is required for years, months, or weeks comparison`);d=i$(l.date,a),f=i$(u.date,a)}let p=l.time.add24HourDays(d),m=u.time.add24HourDays(f);return p.cmp(m)}};FY(B0,`Temporal.Duration`);var V0=class{constructor(e,t,n=`iso8601`,r=1972){let i=CX(e),a=CX(t),o=h1(n===void 0?`iso8601`:DX(n)),s=CX(r);l$(s,i,a),qZ(this,{year:s,month:i,day:a},o)}get monthCode(){return H0(this,`monthCode`)}get day(){return H0(this,`day`)}get calendarId(){return Q(this,qX),Z(this,X)}with(e,t=void 0){if(Q(this,qX),!bX(e))throw TypeError(`invalid argument`);YX(e);let n=Z(this,X),r=kZ(n,Z(this,QJ),`month-day`);return r=iQ(n,r,AZ(n,e,[`year`,`month`,`monthCode`,`day`],[],`partial`)),JZ(fQ(n,r,dZ($(t))),n)}equals(e){Q(this,qX);let t=LZ(e);return r1(Z(this,QJ),Z(t,QJ))===0&&lQ(Z(this,X),Z(t,X))}toString(e=void 0){return Q(this,qX),jQ(this,hZ($(e)))}toJSON(){return Q(this,qX),jQ(this)}toLocaleString(e=void 0,t=void 0){return Q(this,qX),new u0(e,t).format(this)}valueOf(){_1(`PlainMonthDay`)}toPlainDate(e){if(Q(this,qX),!bX(e))throw TypeError(`argument should be an object`);let t=Z(this,X);return WZ(uQ(t,iQ(t,kZ(t,Z(this,QJ),`month-day`),AZ(t,e,[`year`],[],[])),`constrain`),t)}static from(e,t=void 0){return LZ(e,t)}};function H0(e,t){Q(e,qX);let n=Z(e,QJ);return OZ(e).isoToDate(n,{[t]:!0})[t]}function U0(e){return _Q(e,u1())}FY(V0,`Temporal.PlainMonthDay`);var W0={instant:()=>eQ(u1()),plainDateTimeISO:(e=d1())=>KZ(U0(pQ(e)),`iso8601`),plainDateISO:(e=d1())=>WZ(U0(pQ(e)).isoDate,`iso8601`),plainTimeISO:(e=d1())=>XZ(U0(pQ(e)).time),timeZoneId:()=>d1(),zonedDateTimeISO:(e=d1())=>{let t=pQ(e);return nQ(u1(),t,`iso8601`)},[Symbol.toStringTag]:`Temporal.Now`};Object.defineProperty(W0,Symbol.toStringTag,{value:`Temporal.Now`,writable:!1,enumerable:!1,configurable:!0});var G0=class e{constructor(e=0,t=0,n=0,r=0,i=0,a=0){let o=e===void 0?0:CX(e),s=t===void 0?0:CX(t),c=n===void 0?0:CX(n),l=r===void 0?0:CX(r),u=i===void 0?0:CX(i),d=a===void 0?0:CX(a);d$(o,s,c,l,u,d),YZ(this,{hour:o,minute:s,second:c,millisecond:l,microsecond:u,nanosecond:d})}get hour(){return Q(this,WX),Z(this,eY).hour}get minute(){return Q(this,WX),Z(this,eY).minute}get second(){return Q(this,WX),Z(this,eY).second}get millisecond(){return Q(this,WX),Z(this,eY).millisecond}get microsecond(){return Q(this,WX),Z(this,eY).microsecond}get nanosecond(){return Q(this,WX),Z(this,eY).nanosecond}with(t,n=void 0){if(Q(this,WX),!bX(t))throw TypeError(`invalid argument`);YX(t);let r=jZ(t,`partial`),i=jZ(this),{hour:a,minute:o,second:s,millisecond:c,microsecond:l,nanosecond:u}=Object.assign(i,r),d=dZ($(n));return{hour:a,minute:o,second:s,millisecond:c,microsecond:l,nanosecond:u}=sZ(a,o,s,c,l,u,d),new e(a,o,s,c,l,u)}add(e){return Q(this,WX),J$(`add`,this,e)}subtract(e){return Q(this,WX),J$(`subtract`,this,e)}until(e,t=void 0){return Q(this,WX),R$(`until`,this,e,t)}since(e,t=void 0){return Q(this,WX),R$(`since`,this,e,t)}round(e){if(Q(this,WX),e===void 0)throw TypeError(`options parameter is required`);let t=typeof e==`string`?p1(`smallestUnit`,e):$(e),n=gZ(t),r=pZ(t,`halfExpand`),i=xZ(t,`smallestUnit`,`time`,bZ);return _Z(n,{hour:24,minute:60,second:60,millisecond:1e3,microsecond:1e3,nanosecond:1e3}[i],!1),XZ(e1(Z(this,eY),n,i,r))}equals(e){Q(this,WX);let t=RZ(e);return i1(Z(this,eY),Z(t,eY))===0}toString(e=void 0){Q(this,WX);let t=$(e),n=vZ(t),r=pZ(t,`trunc`),i=xZ(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}=yZ(i,n);return kQ(e1(Z(this,eY),s,o,r),a)}toJSON(){return Q(this,WX),kQ(Z(this,eY),`auto`)}toLocaleString(e=void 0,t=void 0){return Q(this,WX),new u0(e,t).format(this)}valueOf(){_1(`PlainTime`)}static from(e,t=void 0){return RZ(e,t)}static compare(e,t){let n=RZ(e),r=RZ(t);return i1(Z(n,eY),Z(r,eY))}};FY(G0,`Temporal.PlainTime`);var K0=class{constructor(e,t,n=`iso8601`,r=1){let i=CX(e),a=CX(t),o=h1(n===void 0?`iso8601`:DX(n)),s=CX(r);l$(i,a,s),ZZ(this,{year:i,month:a,day:s},o)}get year(){return q0(this,`year`)}get month(){return q0(this,`month`)}get monthCode(){return q0(this,`monthCode`)}get calendarId(){return Q(this,KX),Z(this,X)}get era(){return q0(this,`era`)}get eraYear(){return q0(this,`eraYear`)}get daysInMonth(){return q0(this,`daysInMonth`)}get daysInYear(){return q0(this,`daysInYear`)}get monthsInYear(){return q0(this,`monthsInYear`)}get inLeapYear(){return q0(this,`inLeapYear`)}with(e,t=void 0){if(Q(this,KX),!bX(e))throw TypeError(`invalid argument`);YX(e);let n=Z(this,X),r=kZ(n,Z(this,QJ),`year-month`);return r=iQ(n,r,AZ(n,e,[`year`,`month`,`monthCode`],[],`partial`)),QZ(dQ(n,r,dZ($(t))),n)}add(e,t=void 0){return Q(this,KX),Y$(`add`,this,e,t)}subtract(e,t=void 0){return Q(this,KX),Y$(`subtract`,this,e,t)}until(e,t=void 0){return Q(this,KX),z$(`until`,this,e,t)}since(e,t=void 0){return Q(this,KX),z$(`since`,this,e,t)}equals(e){Q(this,KX);let t=BZ(e);return r1(Z(this,QJ),Z(t,QJ))===0&&lQ(Z(this,X),Z(t,X))}toString(e=void 0){return Q(this,KX),MQ(this,hZ($(e)))}toJSON(){return Q(this,KX),MQ(this)}toLocaleString(e=void 0,t=void 0){return Q(this,KX),new u0(e,t).format(this)}valueOf(){_1(`PlainYearMonth`)}toPlainDate(e){if(Q(this,KX),!bX(e))throw TypeError(`argument should be an object`);let t=Z(this,X);return WZ(uQ(t,iQ(t,kZ(t,Z(this,QJ),`year-month`),AZ(t,e,[`day`],[],[])),`constrain`),t)}static from(e,t=void 0){return BZ(e,t)}static compare(e,t){let n=BZ(e),r=BZ(t);return r1(Z(n,QJ),Z(r,QJ))}};function q0(e,t){Q(e,KX);let n=Z(e,QJ);return OZ(e).isoToDate(n,{[t]:!0})[t]}FY(K0,`Temporal.PlainYearMonth`);var J0=u0.prototype.resolvedOptions,Y0=class{constructor(e,t,n=`iso8601`){if(arguments.length<1)throw TypeError(`missing argument: epochNanoseconds is required`);let r=l1(e),i=DX(t),{tzName:a,offsetMinutes:o}=aZ(i);if(o===void 0){let e=RQ(a);if(!e)throw RangeError(`unknown time zone ${a}`);i=e.identifier}else i=VQ(o);tQ(this,r,i,h1(n===void 0?`iso8601`:DX(n)))}get calendarId(){return Q(this,JX),Z(this,X)}get timeZoneId(){return Q(this,JX),Z(this,iY)}get year(){return Z0(this,`year`)}get month(){return Z0(this,`month`)}get monthCode(){return Z0(this,`monthCode`)}get day(){return Z0(this,`day`)}get hour(){return Q0(this,`hour`)}get minute(){return Q0(this,`minute`)}get second(){return Q0(this,`second`)}get millisecond(){return Q0(this,`millisecond`)}get microsecond(){return Q0(this,`microsecond`)}get nanosecond(){return Q0(this,`nanosecond`)}get era(){return Z0(this,`era`)}get eraYear(){return Z0(this,`eraYear`)}get epochMilliseconds(){return Q(this,JX),s1(Z(this,ZJ),`floor`)}get epochNanoseconds(){return Q(this,JX),o1(Z(this,ZJ))}get dayOfWeek(){return Z0(this,`dayOfWeek`)}get dayOfYear(){return Z0(this,`dayOfYear`)}get weekOfYear(){return Z0(this,`weekOfYear`)?.week}get yearOfWeek(){return Z0(this,`weekOfYear`)?.year}get hoursInDay(){Q(this,JX);let e=Z(this,iY),t=X0(this).isoDate,n=t$(t.year,t.month,t.day+1),r=xQ(e,t),i=xQ(e,n);return n1(HY.fromEpochNsDiff(i,r),`hour`)}get daysInWeek(){return Z0(this,`daysInWeek`)}get daysInMonth(){return Z0(this,`daysInMonth`)}get daysInYear(){return Z0(this,`daysInYear`)}get monthsInYear(){return Z0(this,`monthsInYear`)}get inLeapYear(){return Z0(this,`inLeapYear`)}get offset(){return Q(this,JX),gQ(hQ(Z(this,iY),Z(this,ZJ)))}get offsetNanoseconds(){return Q(this,JX),hQ(Z(this,iY),Z(this,ZJ))}with(e,t=void 0){if(Q(this,JX),!bX(e))throw TypeError(`invalid zoned-date-time-like`);YX(e);let n=Z(this,X),r=Z(this,iY),i=hQ(r,Z(this,ZJ)),a=X0(this),o={...kZ(n,a.isoDate),...a.time,offset:gQ(i)};o=iQ(n,o,AZ(n,e,[`year`,`month`,`monthCode`,`day`],[`hour`,`minute`,`second`,`millisecond`,`microsecond`,`nanosecond`,`offset`],`partial`));let s=$(t),c=fZ(s),l=mZ(s,`prefer`),u=NZ(n,o,dZ(s)),d=FQ(o.offset);return nQ(VZ(u.isoDate,u.time,`option`,d,r,c,l,!1),r,n)}withPlainTime(e=void 0){Q(this,JX);let t=Z(this,iY),n=Z(this,X),r=X0(this).isoDate,i;return i=e===void 0?xQ(t,r):vQ(t,uZ(r,Z(RZ(e),eY)),`compatible`),nQ(i,t,n)}withTimeZone(e){Q(this,JX);let t=pQ(e);return nQ(Z(this,ZJ),t,Z(this,X))}withCalendar(e){Q(this,JX);let t=sQ(e);return nQ(Z(this,ZJ),Z(this,iY),t)}add(e,t=void 0){return Q(this,JX),X$(`add`,this,e,t)}subtract(e,t=void 0){return Q(this,JX),X$(`subtract`,this,e,t)}until(e,t=void 0){return Q(this,JX),B$(`until`,this,e,t)}since(e,t=void 0){return Q(this,JX),B$(`since`,this,e,t)}round(e){if(Q(this,JX),e===void 0)throw TypeError(`options parameter is required`);let t=typeof e==`string`?p1(`smallestUnit`,e):$(e),n=gZ(t),r=pZ(t,`halfExpand`),i=xZ(t,`smallestUnit`,`time`,bZ,[`day`]),a={day:1,hour:24,minute:60,second:60,millisecond:1e3,microsecond:1e3,nanosecond:1e3}[i];if(_Z(n,a,a===1),i===`nanosecond`&&n===1)return nQ(Z(this,ZJ),Z(this,iY),Z(this,X));let o=Z(this,iY),s=Z(this,ZJ),c=X0(this),l;if(i===`day`){let e=c.isoDate,t=t$(e.year,e.month,e.day+1),n=xQ(o,e),i=xQ(o,t),a=Y.default.subtract(i,n);l=HY.fromEpochNsDiff(s,n).round(a,r).addToEpochNs(n)}else{let e=$$(c,n,i,r),t=hQ(o,s);l=VZ(e.isoDate,e.time,`option`,t,o,`compatible`,`prefer`,!1)}return nQ(l,o,Z(this,X))}equals(e){Q(this,JX);let t=HZ(e),n=Z(this,ZJ),r=Z(t,ZJ);return!!Y.default.equal(Y.default.BigInt(n),Y.default.BigInt(r))&&!!mQ(Z(this,iY),Z(t,iY))&&lQ(Z(this,X),Z(t,X))}toString(e=void 0){Q(this,JX);let t=$(e),n=hZ(t),r=vZ(t),i=function(e){return m1(e,`offset`,[`auto`,`never`],`auto`)}(t),a=pZ(t,`trunc`),o=xZ(t,`smallestUnit`,`time`,void 0);if(o===`hour`)throw RangeError(`smallestUnit must be a time unit other than "hour"`);let s=function(e){return m1(e,`timeZoneName`,[`auto`,`never`,`critical`],`auto`)}(t),{precision:c,unit:l,increment:u}=yZ(o,r);return NQ(this,c,n,s,i,{unit:l,increment:u,roundingMode:a})}toLocaleString(e=void 0,t=void 0){Q(this,JX);let 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=Z(this,iY),PQ(r.timeZone))throw RangeError(`toLocaleString does not currently support offset time zones`);let i=new u0(e,r),a=J0.call(i).calendar,o=Z(this,X);if(o!==`iso8601`&&a!==`iso8601`&&!lQ(a,o))throw RangeError(`cannot format ZonedDateTime with calendar ${o} in locale with calendar ${a}`);return i.format(eQ(Z(this,ZJ)))}toJSON(){return Q(this,JX),NQ(this,`auto`)}valueOf(){_1(`ZonedDateTime`)}startOfDay(){Q(this,JX);let e=Z(this,iY);return nQ(xQ(e,X0(this).isoDate),e,Z(this,X))}getTimeZoneTransition(e){Q(this,JX);let t=Z(this,iY);if(e===void 0)throw TypeError(`options parameter is required`);let n=m1(typeof e==`string`?p1(`direction`,e):$(e),`direction`,[`next`,`previous`],bZ);if(n===void 0)throw TypeError(`direction option is required`);if(PQ(t)||t===`UTC`)return null;let r=Z(this,ZJ),i=n===`next`?KQ(t,r):qQ(t,r);return i===null?null:nQ(i,t,Z(this,X))}toInstant(){return Q(this,JX),eQ(Z(this,ZJ))}toPlainDate(){return Q(this,JX),WZ(X0(this).isoDate,Z(this,X))}toPlainTime(){return Q(this,JX),XZ(X0(this).time)}toPlainDateTime(){return Q(this,JX),KZ(X0(this),Z(this,X))}static from(e,t=void 0){return HZ(e,t)}static compare(e,t){let n=HZ(e),r=HZ(t),i=Z(n,ZJ),a=Z(r,ZJ);return Y.default.lessThan(Y.default.BigInt(i),Y.default.BigInt(a))?-1:+!!Y.default.greaterThan(Y.default.BigInt(i),Y.default.BigInt(a))}};function X0(e){return _Q(Z(e,iY),Z(e,ZJ))}function Z0(e,t){Q(e,JX);let n=X0(e).isoDate;return OZ(e).isoToDate(n,{[t]:!0})[t]}function Q0(e,t){return Q(e,JX),X0(e).time[t]}FY(Y0,`Temporal.ZonedDateTime`);var $0=Object.freeze({__proto__:null,Duration:B0,Instant:P0,Now:W0,PlainDate:F0,PlainDateTime:L0,PlainMonthDay:V0,PlainTime:G0,PlainYearMonth:K0,ZonedDateTime:Y0});(class{toTemporalInstant(){return eQ(c1(Date.prototype.valueOf.call(this)))}}).prototype.toTemporalInstant;var e2=[P0,F0,L0,B0,V0,G0,K0,Y0];for(let e of e2){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 t2(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(`Could not resolve the selected timezone.`);return t.value};return`${r(`year`)}-${r(`month`)}-${r(`day`)}T${r(`hour`)}:${r(`minute`)}`}function n2(e,t){return t2(new Date(e),t)}function r2(e,t){if(!/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}$/.test(e))throw Error(`Choose a valid date and time for the one-off run.`);let n=$0.PlainDateTime.from(e,{overflow:`reject`}),r=n.toZonedDateTime(t,{disambiguation:`compatible`});if(!n.equals(r.toPlainDateTime()))throw Error(`This local time does not exist in the selected timezone. Choose another time.`);return r.toInstant().toString({smallestUnit:`millisecond`})}function i2(e,t){return new Intl.DateTimeFormat(void 0,{timeZone:t,dateStyle:`medium`,timeStyle:`short`}).format(new Date(e))}var a2=[[1,`Mon`],[2,`Tue`],[3,`Wed`],[4,`Thu`],[5,`Fri`],[6,`Sat`],[0,`Sun`]];function o2({templates:e,pending:t,onCreated:n,onError:r,editing:i,onCancel:a,onBusy:o}){let{api:s}=I(),[c,l]=(0,m.useState)(i?.name??``),[u,d]=(0,m.useState)(i?.templateId??``),[f,p]=(0,m.useState)(i?.cadence.kind??`daily`),[g,_]=(0,m.useState)(i?.cadence.kind===`once`?n2(i.cadence.at,i.timezone):``),[v,y]=(0,m.useState)(i&&i.cadence.kind!==`once`?i.cadence.time:`09:00`),[b,x]=(0,m.useState)(i?.cadence.kind===`weekly`?i.cadence.days:[1,3,5]),[S,C]=(0,m.useState)(()=>i?.timezone??(Intl.DateTimeFormat().resolvedOptions().timeZone||`UTC`)),[w,T]=(0,m.useState)(i?.missedPolicy??`skip`),[E,D]=(0,m.useState)(i?.spendLimitCents?.toString()??``),[O,ee]=(0,m.useState)(()=>(i?.items??[]).map(e=>({id:crypto.randomUUID(),title:e.title,values:Object.entries(e.values).map(([e,t])=>({id:crypto.randomUUID(),name:e,value:t}))}))),[k,A]=(0,m.useState)(!1),[j,M]=(0,m.useState)(!1),N=(0,m.useRef)(!1),P=(0,m.useRef)(null),F=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),te=F.find(e=>e.id===u);async function ne(e){if(e.preventDefault(),!(N.current||t)){if(!te&&!P.current){r(`Choose a template before saving the schedule.`);return}if(f===`weekly`&&b.length===0){r(`Choose at least one weekday for a weekly schedule.`);return}N.current=!0,A(!0),o(!0);try{if(!P.current){if(!te)throw Error(`Choose a template before saving the schedule.`);let e=S.trim();if(!fJ(e))throw Error(`Choose a valid IANA timezone, such as Europe/Tirane.`);let t=f===`once`?{kind:f,at:r2(g,e)}:f===`weekly`?{kind:f,time:v,days:b}:{kind:f,time:v},n=E.trim()===``?null:Number(E);if(n!==null&&(!Number.isInteger(n)||n<0))throw Error(`Spend limit must be a non-negative whole number of cents.`);let r={id:i?.id??crypto.randomUUID(),name:c.trim(),templateId:te.id,templateVersion:i?.templateId===u?i.templateVersion:te.version,cadence:t,timezone:e,missedPolicy:w,overlapPolicy:`skip`,spendLimitCents:n,items:s2(O)};P.current=i?{...r,baseVersion:i.version,mutationId:crypto.randomUUID()}:r}let e=P.current,{id:t,...a}=e,o=`mutationId`in a?await kJ(s,t,a):await OJ(s,e);if(!o.ok){P.current=null,M(!1),r(o.reason===`conflict`?`${o.message} Your inputs are kept. Cancel editing and reopen Edit to load the latest saved version.`:o.message);return}P.current=null,M(!1),l(``),ee([]),n()}catch(e){M(P.current!==null),r(e instanceof Error?e.message:`Could not save the schedule. Try again.`)}finally{N.current=!1,A(!1),o(P.current!==null)}}}return(0,h.jsxs)(`section`,{"aria-labelledby":`new-schedule-heading`,className:`rounded-panel border border-line bg-panel p-4 sm:p-5`,children:[(0,h.jsx)(`h2`,{id:`new-schedule-heading`,className:`font-semibold`,children:i?`Edit schedule`:`New schedule`}),(0,h.jsx)(`p`,{className:`mt-1 text-small text-ink2`,children:`Schedules use the selected template version and never include uploaded media.`}),(0,h.jsxs)(`form`,{onSubmit:e=>void ne(e),children:[(0,h.jsxs)(`fieldset`,{disabled:k||j||t,className:`mt-4 grid gap-4 md:grid-cols-2`,children:[(0,h.jsxs)(`label`,{className:`space-y-1`,htmlFor:`schedule-name`,children:[(0,h.jsx)(`span`,{children:`Name`}),(0,h.jsx)(cM,{id:`schedule-name`,required:!0,value:c,onChange:e=>l(e.target.value),placeholder:`Monday morning stories`})]}),(0,h.jsxs)(`label`,{className:`space-y-1`,htmlFor:`schedule-template`,children:[(0,h.jsx)(`span`,{children:`Template`}),(0,h.jsxs)(`select`,{id:`schedule-template`,required:!0,value:u,onChange:e=>d(e.target.value),className:`h-8 w-full rounded-control border border-line2 bg-panel2 px-2 text-small`,disabled:F.length===0,children:[(0,h.jsx)(`option`,{value:``,children:`Choose a template`}),F.map(e=>(0,h.jsxs)(`option`,{value:e.id,children:[e.name,` · v`,e.version]},e.id))]})]}),(0,h.jsxs)(`label`,{className:`space-y-1`,htmlFor:`schedule-cadence`,children:[(0,h.jsx)(`span`,{children:`Cadence`}),(0,h.jsxs)(`select`,{id:`schedule-cadence`,value:f,onChange:e=>p(e.target.value===`once`?`once`:e.target.value===`weekly`?`weekly`:`daily`),className:`h-8 w-full rounded-control border border-line2 bg-panel2 px-2 text-small`,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`})]})]}),f===`once`?(0,h.jsxs)(`label`,{className:`space-y-1`,htmlFor:`schedule-once`,children:[(0,h.jsx)(`span`,{children:`Run at`}),(0,h.jsx)(cM,{id:`schedule-once`,required:!0,type:`datetime-local`,value:g,onChange:e=>_(e.target.value)})]}):(0,h.jsxs)(`label`,{className:`space-y-1`,htmlFor:`schedule-time`,children:[(0,h.jsx)(`span`,{children:`Local time`}),(0,h.jsx)(cM,{id:`schedule-time`,required:!0,type:`time`,value:v,onChange:e=>y(e.target.value)})]}),f===`weekly`?(0,h.jsxs)(`fieldset`,{className:`space-y-2`,children:[(0,h.jsx)(`legend`,{children:`Weekdays`}),(0,h.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:a2.map(([e,t])=>(0,h.jsxs)(`label`,{className:`inline-flex items-center gap-1 text-small`,children:[(0,h.jsx)(`input`,{type:`checkbox`,checked:b.includes(e),onChange:t=>x(n=>t.target.checked?[...n,e]:n.filter(t=>t!==e))}),t]},e))})]}):(0,h.jsx)(`div`,{}),(0,h.jsxs)(`label`,{className:`space-y-1`,htmlFor:`schedule-timezone`,children:[(0,h.jsx)(`span`,{children:`Timezone`}),(0,h.jsx)(cM,{id:`schedule-timezone`,value:S,onChange:e=>C(e.target.value),placeholder:`Europe/Tirane`}),(0,h.jsx)(`small`,{className:`block text-ink3`,children:f===`once`?`IANA zone; the one-off instant is calculated here. Repeated clock times use the earlier occurrence; nonexistent spring-forward times are refused.`:`IANA zone; next run is calculated here. Repeated clock times use the earlier occurrence; nonexistent spring-forward times move forward by the gap.`})]}),(0,h.jsxs)(`label`,{className:`space-y-1`,htmlFor:`schedule-missed`,children:[(0,h.jsx)(`span`,{children:`Missed run`}),(0,h.jsxs)(`select`,{id:`schedule-missed`,value:w,onChange:e=>T(e.target.value===`run-once`?`run-once`:`skip`),className:`h-8 w-full rounded-control border border-line2 bg-panel2 px-2 text-small`,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.jsxs)(`label`,{className:`space-y-1`,htmlFor:`schedule-spend`,children:[(0,h.jsx)(`span`,{children:`Spend ceiling (cents, optional)`}),(0,h.jsx)(cM,{id:`schedule-spend`,inputMode:`numeric`,value:E,onChange:e=>D(e.target.value),placeholder:`1000`})]}),(0,h.jsx)(c2,{variants:O,onChange:ee})]}),(0,h.jsxs)(`div`,{className:`mt-4 flex gap-2`,children:[(0,h.jsx)(B,{type:`submit`,disabled:t||k||F.length===0&&!j,children:k?`Saving…`:j?`Retry save`:i?`Save changes`:`Save schedule`}),i?(0,h.jsx)(B,{type:`button`,disabled:k||j,onClick:a,children:`Cancel editing`}):null]})]})]})}function s2(e){return e.map(e=>{let t=e.values.map(e=>e.name.trim());if(t.some(e=>!e)||new Set(t).size!==t.length)throw Error(`Each variant needs non-empty, unique keyword names.`);return{title:e.title,values:Object.fromEntries(e.values.map(({name:e,value:t})=>[e.trim(),t]))}})}function c2({variants:e,onChange:t}){let n=n=>t(e.map(e=>e.id===n.id?n:e)),r=`min-h-10 w-full rounded-control border border-line2 bg-panel2 px-[10px] py-2 text-small`;return(0,h.jsxs)(`fieldset`,{className:`space-y-3 md:col-span-2`,children:[(0,h.jsx)(`legend`,{children:`Keyword variants (optional)`}),(0,h.jsx)(`p`,{className:`text-small text-ink3`,children:`The base template run is always included. Add up to 49 variants.`}),e.map((i,a)=>(0,h.jsxs)(`fieldset`,{className:`space-y-3 rounded-control border border-line p-3`,children:[(0,h.jsxs)(`legend`,{children:[`Variant `,a+1]}),(0,h.jsxs)(`label`,{className:`block space-y-1`,children:[(0,h.jsxs)(`span`,{children:[`Variant `,a+1,` title`]}),(0,h.jsx)(`textarea`,{required:!0,maxLength:200,rows:1,className:r,value:i.title,onChange:e=>n({...i,title:e.target.value})})]}),i.values.map((e,t)=>(0,h.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:[(0,h.jsxs)(`label`,{className:`block space-y-1`,children:[(0,h.jsxs)(`span`,{children:[`Variant `,a+1,` keyword `,t+1,` name`]}),(0,h.jsx)(`textarea`,{required:!0,maxLength:200,rows:1,className:r,value:e.name,onChange:t=>n({...i,values:i.values.map(n=>n.id===e.id?{...n,name:t.target.value}:n)})})]}),(0,h.jsxs)(`label`,{className:`block space-y-1`,children:[(0,h.jsxs)(`span`,{children:[`Variant `,a+1,` keyword `,t+1,` value`]}),(0,h.jsx)(`textarea`,{maxLength:1e4,rows:2,className:r,value:e.value,onChange:t=>n({...i,values:i.values.map(n=>n.id===e.id?{...n,value:t.target.value}:n)})})]}),(0,h.jsxs)(B,{type:`button`,className:`min-h-10`,onClick:()=>n({...i,values:i.values.filter(t=>t.id!==e.id)}),children:[`Remove keyword `,t+1,` from variant `,a+1]})]},e.id)),(0,h.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,h.jsxs)(B,{type:`button`,className:`min-h-10`,onClick:()=>n({...i,values:[...i.values,{id:crypto.randomUUID(),name:``,value:``}]}),children:[`Add keyword to variant `,a+1]}),(0,h.jsxs)(B,{type:`button`,className:`min-h-10`,onClick:()=>t(e.filter(e=>e.id!==i.id)),children:[`Remove variant `,a+1]})]})]},i.id)),(0,h.jsx)(B,{type:`button`,className:`min-h-10`,disabled:e.length>=49,onClick:()=>t([...e,{id:crypto.randomUUID(),title:``,values:[]}]),children:`Add variant`})]})}function l2(){let{api:e}=I(),t=_(),n=nt(EJ(e)),r=nt(pq(e)),[i,a]=(0,m.useState)(null),[o,s]=(0,m.useState)(null),[c,l]=(0,m.useState)(null),[u,d]=(0,m.useState)(!1),f=(0,m.useRef)(!1),p=n.data?.filter(e=>e.deletedAt===null)??[],g=n.data?.filter(e=>e.deletedAt!==null)??[],v=it({onError:e=>a(e.message),onSettled:async()=>{f.current=!1,await t.invalidateQueries({queryKey:TJ})},mutationFn:async e=>e(),onSuccess:async e=>{if(!e.ok){a(e.message);return}a(null)}}),y=e=>{f.current||(f.current=!0,s(null),a(null),v.mutate(e))};return(0,h.jsxs)(`div`,{className:`mx-auto max-w-[1200px] space-y-6`,children:[(0,h.jsxs)(`div`,{children:[(0,h.jsxs)(`h1`,{className:`flex items-center gap-2 text-title font-bold tracking-[-0.01em]`,children:[(0,h.jsx)(KA,{"aria-hidden":`true`,className:`size-6 text-lamp-run`}),`Schedules`]}),(0,h.jsx)(`p`,{className:`mt-2 max-w-[70ch] text-body text-ink2`,children:`Run a saved template on this machine at a predictable local time. Each schedule keeps a durable history and creates fresh projects, so changing a template never rewrites an old run.`})]}),(0,h.jsx)(o2,{onBusy:d,editing:c,onCancel:()=>{l(null),a(null)},templates:r.data??[],pending:v.isPending,onCreated:()=>{s(c?`Schedule updated.`:`Schedule saved. It will run automatically while Slopify is open.`),l(null),a(null),t.invalidateQueries({queryKey:TJ})},onError:e=>{a(e),t.invalidateQueries({queryKey:TJ})}},c?.id??`new`),r.data?.length===0?(0,h.jsxs)(`p`,{className:`text-small text-ink2`,children:[`Save a template in`,` `,(0,h.jsx)(`a`,{className:`underline`,href:`/templates`,children:`Templates`}),` `,`before creating a schedule.`]}):null,r.error?(0,h.jsx)(`p`,{role:`alert`,children:r.error.message}):null,n.error?(0,h.jsx)(`p`,{role:`alert`,className:`text-red`,children:n.error.message}):null,i?(0,h.jsx)(`p`,{role:`alert`,className:`text-red`,children:i}):null,o?(0,h.jsx)(`p`,{role:`status`,className:`text-lamp-run`,children:o}):null,n.data&&p.length===0?(0,h.jsx)(Pj,{children:(0,h.jsx)(`p`,{className:`px-4 py-6 text-ink2`,children:g.length===0?`No schedules yet. Your first one can be a one-off run or a recurring series.`:`No active schedules. Create one above or review deleted history below.`})}):null,(0,h.jsx)(`section`,{className:`space-y-3`,"aria-label":`Saved schedules`,children:p.map(e=>(0,h.jsx)(u2,{schedule:e,pending:v.isPending||u||c!==null,onAction:y,error:i,onEdit:()=>{l(e),a(null),window.scrollTo?.({top:0})}},e.id))}),g.length>0?(0,h.jsxs)(`details`,{className:`rounded-panel border border-line bg-panel p-4`,children:[(0,h.jsxs)(`summary`,{className:`cursor-pointer font-semibold`,children:[`Deleted schedule history · `,g.length]}),(0,h.jsx)(`p`,{className:`mt-2 text-small text-ink2`,children:`Deleted schedules cannot run again. Their occurrence history remains available here.`}),(0,h.jsx)(`section`,{className:`mt-4 space-y-3`,"aria-label":`Deleted schedules`,children:g.map(e=>(0,h.jsx)(u2,{schedule:e,pending:!1,onAction:y,error:null,onEdit:()=>void 0},e.id))})]}):null]})}function u2({schedule:e,pending:t,onAction:n,onEdit:r,error:i}){let{api:a}=I(),[o,s]=(0,m.useState)(!1),[c,l]=(0,m.useState)(null),u=nt({queryKey:[`schedule`,e.id],queryFn:async()=>{let t=await DJ(a,e.id);if(!t.ok)throw Error(t.message);return t.value},enabled:o,refetchInterval:3e4}),d=e.cadence.kind===`once`?`One time`:e.cadence.kind===`daily`?`Daily at ${e.cadence.time}`:`Weekly at ${e.cadence.time}`;return(0,h.jsxs)(`article`,{className:`rounded-panel border border-line bg-panel p-4`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,h.jsxs)(`div`,{className:`min-w-0`,children:[(0,h.jsx)(`h2`,{className:`break-words font-semibold`,children:e.name}),(0,h.jsxs)(`p`,{className:`text-small text-ink2`,children:[d,` · `,e.timezone,` · `,e.items.length,` variant`,e.items.length===1?``:`s`]}),(0,h.jsxs)(`p`,{className:`mt-1 text-small text-ink3`,children:[e.deletedAt===null?e.nextRunAt===null?`No future run`:`Next: ${i2(e.nextRunAt,e.timezone)}`:`Deleted: ${i2(e.deletedAt,e.timezone)}`,` `,`· `,(0,h.jsx)(`span`,{className:`capitalize`,children:e.status})]}),(0,h.jsxs)(`p`,{className:`text-small text-ink2`,children:[`Missed runs: `,e.missedPolicy===`skip`?`skip`:`run once on reopening`,`. Overlap: skip. Spend ceiling:`,` `,e.spendLimitCents===null?`not set`:`${e.spendLimitCents} cents`,`.`]})]}),(0,h.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[e.deletedAt===null&&(e.status===`active`||e.status===`paused`)?(0,h.jsx)(B,{type:`button`,disabled:t,onClick:r,children:`Edit`}):null,e.deletedAt===null&&e.status===`active`?(0,h.jsxs)(B,{type:`button`,variant:`ghost`,disabled:t,onClick:()=>n(()=>AJ(a,e.id,`pause`,e.version)),children:[(0,h.jsx)(rj,{"aria-hidden":`true`,className:`size-4`}),`Pause`]}):null,e.deletedAt===null&&e.status===`paused`?(0,h.jsxs)(B,{type:`button`,variant:`ghost`,disabled:t,onClick:()=>n(()=>AJ(a,e.id,`resume`,e.version)),children:[(0,h.jsx)(ij,{"aria-hidden":`true`,className:`size-4`}),`Resume`]}):null,e.deletedAt===null&&(e.status===`active`||e.status===`paused`)?(0,h.jsxs)(B,{type:`button`,variant:`ghost`,disabled:t,onClick:()=>l(`cancel`),children:[(0,h.jsx)(sj,{"aria-hidden":`true`,className:`size-4`}),`Cancel`]}):null,(0,h.jsxs)(B,{type:`button`,variant:`ghost`,onClick:()=>s(e=>!e),"aria-expanded":o,children:[o?(0,h.jsx)(ZA,{"aria-hidden":`true`,className:`size-4`}):(0,h.jsx)(JA,{"aria-hidden":`true`,className:`size-4`}),`History`]}),e.deletedAt===null&&(e.status===`canceled`||e.status===`completed`)?(0,h.jsx)(B,{type:`button`,variant:`ghost`,disabled:t,onClick:()=>l(`delete`),children:`Delete`}):null]})]}),(0,h.jsx)(Nj,{open:c!==null,title:c===`delete`?`Delete schedule?`:`Cancel schedule?`,consequence:(c===`delete`?`Removes this schedule from the active list. Its run history is kept.`:`Stops future scheduled runs. Existing projects and run history are kept.`)+(i?` ${i}`:``),verb:c===`delete`?`Delete schedule`:`Cancel schedule`,dismiss:`Keep schedule`,pending:t,onCancel:()=>{t||l(null)},onConfirm:()=>{let t=c;t&&n(async()=>{let n=t===`delete`?await jJ(a,e.id,e.version):await AJ(a,e.id,`cancel`,e.version);return n.ok&&l(null),n})}}),o?(0,h.jsx)(`div`,{className:`mt-4 border-t border-line pt-3`,children:u.isPending?(0,h.jsx)(`p`,{className:`text-small text-ink3`,children:`Loading history…`}):u.error?(0,h.jsx)(`p`,{className:`text-small text-red`,children:u.error.message}):u.data?.runs.length===0?(0,h.jsx)(`p`,{className:`text-small text-ink3`,children:`No runs yet.`}):(0,h.jsx)(`ul`,{className:`space-y-2`,children:u.data?.runs.map(t=>(0,h.jsxs)(`li`,{className:`flex flex-wrap justify-between gap-2 text-small`,children:[(0,h.jsxs)(`span`,{className:`capitalize`,children:[t.status,` · `,i2(t.scheduledFor,e.timezone)]}),t.error?(0,h.jsx)(`span`,{className:`text-ink3`,children:t.error}):t.projectIds.length>0?(0,h.jsx)(`span`,{className:`flex flex-wrap gap-x-3 gap-y-1 text-ink3`,children:t.projectIds.map((e,t)=>(0,h.jsxs)(sa,{className:`underline hover:text-ink`,to:`/projects/$projectId`,params:{projectId:e},children:[`Project `,t+1]},e))}):(0,h.jsx)(`span`,{className:`text-ink3`,children:`No projects`})]},t.id))})}):null]})}function d2(){let{api:e}=I(),t=_(),n=nt({queryKey:[`catalogue`],queryFn:async()=>eo(await e.fetch(`${e.origin}/api/providers/catalogue`)),refetchInterval:3e4}),r=it({mutationFn:async()=>eo(await e.fetch(`${e.origin}/api/providers/catalogue/refresh`,{method:`POST`})),onSuccess:e=>{t.setQueryData([`catalogue`],e),t.invalidateQueries({queryKey:[`provider-models`]})}});return(0,h.jsxs)(`section`,{className:`rounded-panel border border-line bg-panel p-4`,children:[(0,h.jsx)(`h2`,{className:`engraved text-ink3`,children:`Models and request limits`}),(0,h.jsx)(`p`,{className:`my-2 text-body text-ink2`,children:`The catalogue lists supported text, image and speech models, their prices and request limits. Local YAML edits load automatically; model pickers refresh every 30 seconds.`}),n.data?.path?(0,h.jsx)(`p`,{className:`my-2 break-all font-mono text-small`,children:n.data.path}):null,(0,h.jsxs)(`p`,{className:`mb-3 text-small text-ink2`,children:[`Verified `,n.data?.updatedAt??`date unavailable`,`. Refresh replaces your local file with the published catalogue and saves the previous file alongside it.`]}),(0,h.jsx)(B,{disabled:r.isPending||!n.data?.path,onClick:()=>r.mutate(),children:r.isPending?`Refreshing…`:`Refresh published catalogue`}),n.data?.warning||n.error||r.error?(0,h.jsx)(`p`,{role:`alert`,className:`mt-2 text-body text-red`,children:r.error?.message??n.error?.message??n.data?.warning}):null,r.isSuccess?(0,h.jsx)(`p`,{role:`status`,className:`mt-2 text-small text-green`,children:`Catalogue updated.`}):null]})}function f2({provider:e,readiness:t}){let{api:n}=I(),r=_(),i=(0,m.useId)(),a=(0,m.useId)(),o=(0,m.useId)(),s=(0,m.useId)(),c=(0,m.useId)(),[l,u]=(0,m.useState)(void 0),[d,f]=(0,m.useState)(!1),p=e.cliPath?.configured??null,g=e.id===`claude-code`?`claude`:e.id===`codex-image`?`codex`:e.id,v=e.cliPath?.command??g,y=l??p??``,b=Rk(t),x=it({mutationFn:t=>xo(n,e.id,t),onMutate:()=>f(!1),onSuccess:async e=>{r.setQueryData(V.providers,t=>t?{...t,providers:t.providers.map(t=>t.id===e.id?e:t)}:void 0),u(void 0),f(!0),await r.invalidateQueries({queryKey:V.providers})}});return(0,m.useEffect)(()=>{if(!d)return;let e=setTimeout(()=>f(!1),Qj);return()=>clearTimeout(e)},[d]),(0,h.jsxs)(`div`,{"data-ready":b,className:`grid gap-[14px] border-t border-line px-4 py-[14px] first:border-t-0 sm:grid-cols-[140px_1fr]`,children:[(0,h.jsx)(`span`,{id:i,className:z(`font-semibold`,b?`text-ink`:`text-ink3`),children:e.displayName}),(0,h.jsxs)(`div`,{className:`min-w-0`,children:[(0,h.jsxs)(`p`,{className:`flex flex-wrap items-center gap-2 text-small text-ink2`,"aria-live":`polite`,children:[(0,h.jsx)(pK,{state:b?`done`:`pending`}),(0,h.jsx)(`span`,{children:p2(t,p)})]}),(0,h.jsxs)(`p`,{className:`mt-1 break-all text-label text-ink3`,children:[`Command: `,(0,h.jsx)(`code`,{children:v})]}),(0,h.jsxs)(`form`,{className:`mt-3`,onSubmit:e=>{e.preventDefault(),x.isPending||x.mutate(y)},children:[(0,h.jsx)(oM,{htmlFor:a,id:o,className:`mb-[5px]`,children:`Executable path`}),(0,h.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,h.jsx)(cM,{id:a,autoComplete:`off`,spellCheck:!1,maxLength:4096,"aria-labelledby":`${i} ${o}`,"aria-invalid":x.error!==null,"aria-describedby":`${s}${x.error?` ${c}`:``}`,placeholder:g,value:y,disabled:x.isPending,onChange:e=>{u(e.target.value),f(!1),x.reset()}}),(0,h.jsx)(B,{type:`submit`,"aria-label":`Save ${e.displayName} path`,disabled:x.isPending,children:x.isPending?`Checking…`:`Save path`}),d?(0,h.jsx)(eM,{}):null]}),(0,h.jsxs)(`p`,{id:s,className:`mt-1 text-label text-ink3`,children:[`Leave blank to find `,(0,h.jsx)(`code`,{children:g}),` on PATH. Use an absolute path without quotes or arguments.`]}),x.error?(0,h.jsx)(`p`,{id:c,role:`alert`,className:`mt-1 text-label text-red`,children:x.error.message}):null]}),(0,h.jsxs)(`p`,{className:`mt-2 text-label text-ink3`,children:[`Sign in through `,e.displayName,` itself before generating; Slopify uses that login.`,e.id===`codex-image`?` Executable path and login are shared with Codex text generation.`:null]})]})]})}function p2(e,t){return e.installed?e.issue===void 0?e.version===void 0?`Installed`:`Installed, version ${e.version}`:e.issue:t===null?`Not found on PATH`:`Not found at saved path`}var m2=[`llm`,`tts`,`image`],h2={llm:`API keys · LLM`,tts:`API keys · Text to speech`,image:`API keys · Image generation`},g2=`••••••••••••`,_2=`grid grid-cols-[140px_1fr_auto] items-end gap-[14px] border-t border-line px-4 py-[14px] first:border-t-0`,v2=`engraved border-t border-line px-4 py-3 text-ink3 first:border-t-0`;function y2(){let{api:e}=I(),t=nt(vy(e));if(t.error!==null)return(0,h.jsx)(Pj,{children:(0,h.jsx)(Fj,{children:(0,h.jsx)(`p`,{className:`text-body text-red`,children:t.error.message})})});if(t.data===void 0)return(0,h.jsx)(x2,{});let n=t.data.providers,r=n.every(e=>e.readiness.kind!==`keyed`||!e.readiness.hasKey);return(0,h.jsx)(Pj,{children:m2.map(e=>(0,h.jsxs)(`section`,{"data-tour":`keys-${e}`,className:`border-t border-line first:border-t-0`,children:[(0,h.jsx)(`h2`,{className:v2,children:h2[e]}),n.filter(t=>t.family===e).map(e=>e.readiness.kind===`cli`?(0,h.jsx)(f2,{provider:e,readiness:e.readiness},e.id):(0,h.jsx)(b2,{provider:e,hasKey:e.readiness.hasKey},e.id)),e===`llm`&&r?(0,h.jsx)(`p`,{className:`border-t border-line px-4 pt-[10px] pb-[14px] text-small text-ink2`,children:`Paste a key to make its provider selectable on Play.`}):null]},e))})}function b2({provider:e,hasKey:t}){let{api:n}=I(),r=_(),i=(0,m.useId)(),a=(0,m.useId)(),o=(0,m.useId)(),s=(0,m.useId)(),c=(0,m.useId)(),[l,u]=(0,m.useState)(``),[d,f]=(0,m.useState)(!1),[p,g]=(0,m.useState)(!1),[v,y]=(0,m.useState)(void 0),[b,x]=(0,m.useState)(!1),S=async()=>{f(!0),y(void 0);try{await bo(n,e.id,l),u(``),g(!0),await r.invalidateQueries({queryKey:V.providers})}catch(e){y(e instanceof Error?e.message:String(e))}finally{f(!1)}},C=it({mutationFn:()=>So(n,e.id),onSuccess:async()=>{x(!1),y(void 0),await r.invalidateQueries({queryKey:V.providers})},onError:e=>{x(!1),y(e.message)}});(0,m.useEffect)(()=>{if(!p)return;let e=setTimeout(()=>{g(!1)},Qj);return()=>{clearTimeout(e)}},[p]);let w=[t?s:void 0,v===void 0?void 0:c].filter(e=>e!==void 0).join(` `);return(0,h.jsxs)(`div`,{"data-ready":t,className:_2,children:[(0,h.jsx)(`span`,{id:o,className:`pb-[7px] font-semibold`,children:e.displayName}),(0,h.jsxs)(`div`,{children:[(0,h.jsx)(oM,{htmlFor:i,id:a,className:`mb-[5px]`,children:`API key`}),(0,h.jsx)(cM,{id:i,type:`password`,autoComplete:`off`,spellCheck:!1,"aria-labelledby":`${o} ${a}`,"aria-invalid":v!==void 0,"aria-describedby":w===``?void 0:w,placeholder:t?g2:void 0,value:l,onChange:e=>{u(e.target.value)}}),e.id===`inworld`?(0,h.jsx)(`p`,{className:`mt-1 text-label text-ink3`,children:`Paste the Base64 credentials from Inworld Settings → API Keys.`}):null,t?(0,h.jsx)(`span`,{id:s,className:`sr-only`,children:`A key is stored for this provider.`}):null,v===void 0?null:(0,h.jsx)(`p`,{id:c,className:`mt-1 text-label text-red`,children:v})]}),(0,h.jsxs)(`div`,{className:`flex min-h-8 items-center gap-2`,children:[(0,h.jsx)(B,{"aria-label":`Save ${e.displayName} key`,disabled:l.trim()===``||d,onClick:()=>{S()},children:`Save`}),p?(0,h.jsx)(eM,{}):null,t?(0,h.jsx)(B,{className:`bg-transparent`,"aria-label":`Remove ${e.displayName} key`,onClick:()=>{x(!0)},children:`Remove`}):null]}),(0,h.jsx)(Nj,{open:b,title:`Remove the ${e.displayName} key?`,consequence:`Projects that used this provider cannot retry until a key is saved.`,verb:`Remove`,pending:C.isPending,onConfirm:()=>{C.mutate()},onCancel:()=>{x(!1)}})]})}function x2(){return(0,h.jsx)(Pj,{children:[0,1,2,3].map(e=>(0,h.jsxs)(Fj,{children:[(0,h.jsx)(`span`,{className:`h-4 w-28 rounded-control bg-panel2`}),(0,h.jsx)(`span`,{className:`h-8 flex-1 rounded-control bg-panel2`})]},e))})}var S2=ev,C2=iv;function w2({className:e,children:t,...n}){return(0,h.jsxs)(nv,{"data-slot":`select-trigger`,className:z(`flex h-8 w-full items-center justify-between gap-2 rounded-control border border-line2`,`bg-panel2 px-[10px] text-left text-small text-ink data-[placeholder]:text-ink3`,e),...n,children:[t,(0,h.jsx)(av,{asChild:!0,children:(0,h.jsx)(JA,{"aria-hidden":`true`,className:`size-[14px] shrink-0 text-ink2`})})]})}function T2({className:e,children:t,position:n=`popper`,...r}){return(0,h.jsx)(cv,{children:(0,h.jsx)(uv,{"data-slot":`select-content`,position:n,sideOffset:4,className:z(`z-50 min-w-[var(--radix-select-trigger-width)] overflow-hidden rounded-panel`,`border border-line bg-panel p-1 shadow-[0_8px_24px_var(--color-shadow)]`,e),...r,children:(0,h.jsx)(Sv,{children:t})})})}function E2({className:e,children:t,...n}){return(0,h.jsxs)(Ov,{"data-slot":`select-item`,className:z(`relative flex cursor-default items-center rounded-control py-[5px] pr-8 pl-[10px]`,`text-small text-ink outline-hidden select-none`,`focus:bg-panel2 data-highlighted:bg-panel2`,e),...n,children:[(0,h.jsx)(Av,{children:t}),(0,h.jsx)(Mv,{className:`absolute right-[10px] flex items-center`,children:(0,h.jsx)(qA,{"aria-hidden":`true`,className:`size-[14px] text-done`})})]})}var D2=`px-4 align-top`;function O2(){let{api:e}=I(),t=_(),n=nt(yy(e)),r=nt(vy(e)),[i,a]=(0,m.useState)(void 0),o=it({mutationFn:t=>Do(e,t),onSettled:async()=>{a(void 0),await t.invalidateQueries({queryKey:V.voices})}}),s=(r.data?.providers??[]).filter(e=>e.family===`tts`);if(n.error!==null)return(0,h.jsx)(Pj,{children:(0,h.jsx)(Fj,{children:(0,h.jsx)(`p`,{className:`text-body text-red`,children:n.error.message})})});let c=n.data?.voices;return(0,h.jsxs)(Pj,{"data-tour":`voices`,children:[(0,h.jsxs)(`table`,{className:`w-full table-fixed border-collapse text-small`,children:[(0,h.jsx)(`thead`,{children:(0,h.jsxs)(`tr`,{className:`border-b border-line`,children:[(0,h.jsx)(`th`,{className:z(D2,`engraved w-[26%] py-3 text-left text-ink3`),children:`Voices · Name`}),(0,h.jsx)(`th`,{className:z(D2,`engraved w-[26%] py-3 text-left text-ink3`),children:`Provider`}),(0,h.jsx)(`th`,{className:z(D2,`engraved py-3 text-left text-ink3`),children:`Voice ID`}),(0,h.jsx)(`th`,{className:z(D2,`w-[104px] py-3`),children:(0,h.jsx)(`span`,{className:`sr-only`,children:`Remove`})})]})}),(0,h.jsx)(`tbody`,{children:c===void 0?(0,h.jsx)(`tr`,{className:`border-b border-line`,children:(0,h.jsx)(`td`,{colSpan:4,className:z(D2,`py-4`),children:(0,h.jsx)(`span`,{className:`block h-4 w-64 rounded-control bg-panel2`})})}):c.length===0?(0,h.jsx)(`tr`,{className:`border-b border-line`,children:(0,h.jsx)(`td`,{colSpan:4,className:z(D2,`py-4 text-ink2`),children:`Add a voice ID from your text-to-speech provider. Audio needs one to narrate.`})}):c.map(e=>(0,h.jsxs)(`tr`,{className:`border-b border-line`,children:[(0,h.jsx)(`td`,{className:z(D2,`py-3 font-semibold`),children:e.name}),(0,h.jsx)(`td`,{className:z(D2,`py-3 text-ink2`),children:j2(s,e.provider)}),(0,h.jsx)(`td`,{className:z(D2,`py-3 text-ink2 tabular-nums`),children:e.voiceId}),(0,h.jsx)(`td`,{className:z(D2,`py-3 text-right`),children:(0,h.jsx)(B,{className:`bg-transparent`,"aria-label":`Remove ${e.name}`,onClick:()=>{a(e)},children:`Remove`})})]},e.id))}),(0,h.jsx)(`tfoot`,{children:(0,h.jsx)(k2,{tts:s})})]}),o.error===null?null:(0,h.jsx)(`p`,{className:`border-t border-line px-4 py-3 text-label text-red`,children:o.error.message}),(0,h.jsx)(Nj,{open:i!==void 0,title:i===void 0?``:`Remove ${i.name}?`,consequence:`Projects that used this voice keep the audio they made with it.`,verb:`Remove`,pending:o.isPending,onConfirm:()=>{i!==void 0&&o.mutate(i.id)},onCancel:()=>{a(void 0)}})]})}function k2({tts:e}){let{api:t}=I(),n=_(),r=(0,m.useId)(),i=(0,m.useId)(),a=(0,m.useId)(),o=(0,m.useId)(),s=(0,m.useId)(),[c,l]=(0,m.useState)(``),[u,d]=(0,m.useState)(``),[f,p]=(0,m.useState)(void 0),[g,v]=(0,m.useState)(void 0),y=f??e[0]?.id,b=it({mutationFn:e=>Eo(t,e),onSuccess:async e=>{if(!e.ok){v(e.refusal);return}l(``),d(``),v(void 0),await n.invalidateQueries({queryKey:V.voices})}}),x=(e,t)=>{t(),g?.field===e&&v(void 0)},S=e=>g?.field===e?g.message:void 0;return(0,h.jsxs)(`tr`,{children:[(0,h.jsxs)(`td`,{className:z(D2,`py-[14px]`),children:[(0,h.jsx)(oM,{htmlFor:r,className:`mb-[5px]`,children:`Voice name`}),(0,h.jsx)(cM,{id:r,value:c,"aria-invalid":S(`name`)!==void 0,onChange:e=>{let t=e.target.value;x(`name`,()=>{l(t)})}}),(0,h.jsx)(A2,{id:`${s}-name`,message:S(`name`)})]}),(0,h.jsxs)(`td`,{className:z(D2,`py-[14px]`),children:[(0,h.jsx)(oM,{id:a,className:`mb-[5px]`,children:`Provider`}),(0,h.jsxs)(S2,{value:y??``,onValueChange:t=>{let n=e.find(e=>e.id===t);n!==void 0&&x(`provider`,()=>{p(n.id)})},children:[(0,h.jsx)(w2,{id:i,"aria-labelledby":`${a} ${i}`,children:(0,h.jsx)(C2,{placeholder:`Pick a provider`})}),(0,h.jsx)(T2,{children:e.map(e=>(0,h.jsx)(E2,{value:e.id,children:e.displayName},e.id))})]}),(0,h.jsx)(A2,{id:`${s}-provider`,message:S(`provider`)})]}),(0,h.jsxs)(`td`,{className:z(D2,`py-[14px]`),children:[(0,h.jsx)(oM,{htmlFor:o,className:`mb-[5px]`,children:`Voice ID`}),(0,h.jsx)(cM,{id:o,className:`tabular-nums`,value:u,"aria-invalid":S(`voiceId`)!==void 0,"aria-describedby":S(`voiceId`)===void 0?void 0:`${s}-voiceId`,onChange:e=>{let t=e.target.value;x(`voiceId`,()=>{d(t)})}}),(0,h.jsx)(A2,{id:`${s}-voiceId`,message:S(`voiceId`)}),y===`inworld`?(0,h.jsx)(`p`,{className:`mt-1 text-label text-ink3`,children:`Use an Inworld voice ID, such as Dennis, or one from your workspace.`}):null,b.error===null?null:(0,h.jsx)(`p`,{className:`mt-1 text-label text-red`,children:b.error.message})]}),(0,h.jsx)(`td`,{className:z(D2,`py-[14px] text-right`),children:(0,h.jsx)(B,{className:`mt-[22px]`,disabled:y===void 0||g!==void 0||b.isPending,onClick:()=>{y!==void 0&&b.mutate({provider:y,name:c,voiceId:u})},children:`Add voice`})})]})}function A2({id:e,message:t}){return t===void 0?null:(0,h.jsx)(`p`,{id:e,className:`mt-1 text-label text-red`,children:t})}function j2(e,t){return e.find(e=>e.id===t)?.displayName??t}var M2=[`storage-usage`],N2=[M2,V.settings,V.providers,V.voices,V.prompts,V.entries,V.staging,cq,UO,[`provider-models`]];async function P2(e){await Promise.all(N2.map(t=>e.invalidateQueries({queryKey:t})))}var F2=30,I2=[{value:`system`,label:`System`},{value:`dark`,label:`Dark`},{value:`light`,label:`Light`}];function L2(e){let t=e.trim();return/^\d+$/.test(t)&&Number(t)>=0&&Number(t)<=F2?void 0:`The silence gap is a whole number of seconds between 0 and ${String(F2)}.`}function R2(){let{api:e}=I();return(0,h.jsxs)(`div`,{className:`flex max-w-[1100px] flex-col gap-6`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`h1`,{className:`text-title font-bold tracking-[-0.01em]`,children:`Settings`}),(0,h.jsx)(`p`,{className:`mt-1 text-small text-ink2`,children:`Provider readiness is checked again before each run.`})]}),(0,h.jsx)(B,{asChild:!0,variant:`ghost`,children:(0,h.jsx)(`a`,{href:`${e.origin}/api/diagnostics`,download:`slopify-diagnostics.json`,children:`Download diagnostics`})})]}),(0,h.jsx)(y2,{}),(0,h.jsx)(O2,{}),(0,h.jsx)(d2,{}),(0,h.jsx)(V2,{}),(0,h.jsx)(z2,{})]})}function z2(){let{api:e}=I(),t=_(),n=nt({queryKey:M2,queryFn:()=>fo(e),staleTime:3e4}),[r,i]=(0,m.useState)(!1),[a,o]=(0,m.useState)(null),[s,c]=(0,m.useState)(null);async function l(n){if(n.size===0||n.size>104857600){o(null),c(`The backup must be between 1 byte and 100 MB.`);return}i(!0),c(null),o(null);try{let r=await e.fetch(`${e.origin}/api/storage/import`,{method:`PUT`,headers:{"content-type":`application/zip`},body:n}),i=await r.json();if(!r.ok)throw Error(i.detail??`The backup could not be imported.`);o(`Imported ${i.templates??0} template(s), ${i.fonts??0} uploaded font(s), and ${i.stagedFiles??0} staged file(s).${i.fontFallbacks?` ${i.fontFallbacks} missing legacy font reference(s) now use the default font.`:``}`),await P2(t)}catch(e){c(e instanceof Error?e.message:`The backup could not be imported.`)}finally{i(!1)}}async function u(){i(!0),c(null),o(null);try{let n=await e.fetch(`${e.origin}/api/storage/cleanup`,{method:`POST`}),r=await n.json();if(!n.ok)throw Error(`Storage cleanup could not finish.`);o(`Removed ${r.orphanFiles??0} orphan project file(s) and ${r.stagedFiles??0} stale staged file(s).`),await t.invalidateQueries({queryKey:M2})}catch(e){c(e instanceof Error?e.message:`Storage cleanup could not finish.`)}finally{i(!1)}}return(0,h.jsxs)(`section`,{"aria-labelledby":`storage-tools-heading`,className:`rounded-panel border border-line bg-panel p-4`,children:[(0,h.jsx)(`h2`,{id:`storage-tools-heading`,className:`font-semibold`,children:`Backup and storage`}),(0,h.jsx)(`p`,{className:`mt-1 max-w-[70ch] text-small text-ink2`,children:`Backups include templates, prompts, voices, settings and staged assets. Provider keys and telemetry are never included. Existing projects and their retained revisions stay untouched when a backup is imported.`}),(0,h.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,h.jsx)(B,{asChild:!0,disabled:r,children:(0,h.jsx)(`a`,{href:`${e.origin}/api/storage/export`,download:`slopify-backup.zip`,children:`Export backup`})}),(0,h.jsxs)(`label`,{className:`inline-flex h-8 cursor-pointer items-center rounded-control border border-line2 bg-panel2 px-3 text-body hover:border-ink3`,children:[`Import backup`,(0,h.jsx)(`input`,{className:`sr-only`,type:`file`,accept:`application/zip,.zip`,disabled:r,onChange:e=>{let t=e.target.files?.[0];t&&l(t),e.target.value=``}})]}),(0,h.jsx)(B,{type:`button`,variant:`ghost`,disabled:r,onClick:()=>void u(),children:`Clean orphan files`})]}),n.data?(0,h.jsxs)(`div`,{className:`mt-4 border-t border-line pt-3 text-small text-ink2`,children:[(0,h.jsxs)(`p`,{children:[B2(n.data.data),` stored · `,B2(n.data.projects),` project files · `,B2(n.data.staging),` staged files`]}),n.data.byProject.length>0?(0,h.jsx)(`ul`,{className:`mt-2 space-y-1`,"aria-label":`Storage by project`,children:n.data.byProject.slice(0,5).map(e=>(0,h.jsxs)(`li`,{className:`flex justify-between gap-4`,children:[(0,h.jsx)(`span`,{className:`truncate`,children:e.title}),(0,h.jsx)(`span`,{className:`shrink-0 tabular-nums`,children:B2(e.bytes)})]},e.id))}):null]}):n.error?(0,h.jsx)(`p`,{className:`mt-3 text-small text-ink2`,children:`Storage usage is unavailable.`}):null,a?(0,h.jsx)(`p`,{role:`status`,className:`mt-2 text-small text-lamp-run`,children:a}):null,s?(0,h.jsx)(`p`,{role:`alert`,className:`mt-2 text-small text-red`,children:s}):null]})}function B2(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}`}function V2(){let{api:e}=I(),t=_(),n=nt(Sy(e)),r=(0,m.useId)(),i=(0,m.useId)(),a=(0,m.useId)(),[o,s]=(0,m.useState)(void 0),[c,l]=(0,m.useState)(!1),u=it({mutationFn:t=>wo(e,t),onMutate:e=>{let n=t.getQueryData(V.settings);return t.setQueryData(V.settings,e),{previous:n}},onError:(e,n,r)=>{r?.previous!==void 0&&t.setQueryData(V.settings,r.previous)},onSuccess:e=>{t.setQueryData(V.settings,e)}});if((0,m.useEffect)(()=>{if(!c)return;let e=setTimeout(()=>{l(!1)},Qj);return()=>{clearTimeout(e)}},[c]),n.error!==null)return(0,h.jsx)(Pj,{children:(0,h.jsx)(Fj,{children:(0,h.jsx)(`p`,{className:`text-body text-red`,children:n.error.message})})});if(n.data===void 0)return(0,h.jsxs)(Pj,{children:[(0,h.jsx)(`h2`,{className:`engraved border-b border-line px-4 py-3 text-ink3`,children:`Playback`}),(0,h.jsxs)(Fj,{children:[(0,h.jsx)(`span`,{className:`h-4 w-48 rounded-control bg-panel2`}),(0,h.jsx)(`span`,{className:`h-8 w-[72px] rounded-control bg-panel2`})]})]});let d=n.data,f=o??String(d.silenceGapSeconds),p=L2(f);return(0,h.jsxs)(Pj,{children:[(0,h.jsx)(`h2`,{className:`engraved border-b border-line px-4 py-3 text-ink3`,children:`Playback`}),(0,h.jsxs)(`div`,{className:`grid grid-cols-[240px_1fr] items-center gap-[14px] border-b border-line px-4 py-[14px]`,children:[(0,h.jsx)(`label`,{htmlFor:r,className:`font-semibold`,children:`Silence between segments`}),(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-[10px]`,children:[(0,h.jsx)(cM,{id:r,type:`number`,inputMode:`numeric`,min:0,max:F2,step:1,className:`w-[72px] tabular-nums`,value:f,"aria-invalid":p!==void 0,"aria-describedby":p===void 0?void 0:i,onChange:e=>{s(e.target.value)}}),(0,h.jsx)(`span`,{className:`text-small text-ink2`,children:`seconds`}),(0,h.jsx)(B,{className:`ml-[6px]`,disabled:p!==void 0||u.isPending,onClick:()=>{l(!1),u.mutate({silenceGapSeconds:Number(f.trim()),appearance:d.appearance},{onSuccess:()=>{s(void 0),l(!0)}})},children:`Save`}),c?(0,h.jsx)(eM,{}):null,p===void 0?null:(0,h.jsx)(`p`,{id:i,className:`basis-full text-label text-red`,children:p}),u.error===null?null:(0,h.jsx)(`p`,{className:`basis-full text-label text-red`,children:u.error.message})]})]}),(0,h.jsxs)(`div`,{className:`grid grid-cols-[240px_1fr] items-center gap-[14px] px-4 py-[14px]`,children:[(0,h.jsx)(`span`,{id:a,className:`font-semibold`,children:`Appearance`}),(0,h.jsx)(Hj,{type:`single`,value:d.appearance,"aria-labelledby":a,className:`justify-self-start`,onValueChange:e=>{let t=I2.find(t=>t.value===e);t!==void 0&&u.mutate({silenceGapSeconds:d.silenceGapSeconds,appearance:t.value})},children:I2.map(e=>(0,h.jsx)(Uj,{value:e.value,children:e.label},e.value))})]})]})}function H2({onApplied:e,beforeApply:t,getGeneration:n,blocked:r=!1}){let{api:i}=I(),a=_(),o=nt(pq(i)),s=nt({queryKey:[`play-drafts`],queryFn:async()=>{let e=await NO(i);if(!e.ok)throw Error(e.message);return e.value.drafts}}),[c,l]=(0,m.useState)(``),[u,d]=(0,m.useState)(``),[f,p]=(0,m.useState)(!1),[g,v]=(0,m.useState)(null),[y,b]=(0,m.useState)(null),[x,S]=(0,m.useState)(null),C=(0,m.useRef)(!1),w=(0,m.useRef)(null),T=(0,m.useRef)(new Map),E=(0,m.useRef)(!0);(0,m.useEffect)(()=>(E.current=!0,()=>{E.current=!1}),[]);async function D(e){if(!C.current){C.current=!0,p(!0),v(null),b(null);try{await e()}catch(e){v(e instanceof Error?e.message:`The template action could not finish.`)}finally{C.current=!1,p(!1)}}}async function O(){let e=await FO(i,c);if(!e.ok)throw Error(e.message);let t=JSON.stringify([c,e.value.draft.version,u.trim()]);w.current?.key!==t&&(w.current={key:t,id:crypto.randomUUID()});let n=await mq(i,{id:w.current.id,name:u.trim(),document:e.value.draft.document});if(!n.ok)throw w.current=null,Error(n.message);w.current=null,d(``),b(`Template saved.`),await a.invalidateQueries({queryKey:cq})}async function ee(o){let s=n?.();if(r||t&&!await t())throw Error(`Resolve the current Play draft before applying a template.`);if(!E.current||s!==void 0&&s!==n?.())return;let c=`${o.id}:${o.version}`,l=T.current.get(c);l||(l=crypto.randomUUID(),T.current.set(c,l));let u=await _q(i,o,l);if(!u.ok)throw T.current.delete(c),Error(u.message);if(!(!E.current||s!==void 0&&s!==n?.())&&(await a.invalidateQueries({queryKey:[`play-drafts`]}),!(!E.current||s!==void 0&&s!==n?.()))){if(await e(u.value.draft.id,()=>E.current)!==!1)T.current.delete(c);else throw Error(`The new template draft could not be opened. Try again.`)}}async function k(){if(!x)return;let e=x.id,t=await gq(i,x);if(!t.ok)throw Error(t.message);S(null),await a.cancelQueries({queryKey:cq}),a.setQueryData(cq,t=>t?.filter(t=>t.id!==e)),b(`Template deleted.`),await a.invalidateQueries({queryKey:cq})}return(0,h.jsxs)(`div`,{className:`mx-auto max-w-[1440px] space-y-6`,children:[(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`h1`,{className:`text-title font-bold tracking-[-0.01em]`,children:`Templates`}),(0,h.jsx)(`p`,{className:`mt-2 text-body text-ink2`,children:`Reuse a Play setup and its checkpoint choices. Apply creates a fresh draft for review before you start.`})]}),(0,h.jsxs)(`section`,{"aria-labelledby":`save-template-heading`,className:`max-w-2xl space-y-3 rounded-panel border border-line bg-panel p-4`,children:[(0,h.jsx)(`h2`,{id:`save-template-heading`,className:`font-semibold`,children:`Save a setup`}),(0,h.jsxs)(`p`,{className:`text-small text-ink2`,children:[`Choose a saved Play draft, or`,` `,(0,h.jsx)(sa,{to:`/play`,className:`underline`,children:`open Play`}),` `,`to prepare one.`]}),(0,h.jsxs)(`form`,{className:`space-y-3`,onSubmit:e=>{e.preventDefault(),c&&u.trim()&&D(O)},children:[(0,h.jsxs)(`label`,{className:`block space-y-1`,children:[(0,h.jsx)(`span`,{children:`Saved Play draft`}),(0,h.jsxs)(`select`,{className:`h-10 w-full rounded-control border border-line2 bg-panel2 px-2`,value:c,required:!0,disabled:f,onChange:e=>l(e.target.value),children:[(0,h.jsx)(`option`,{value:``,children:`Choose a draft`}),s.data?.filter(e=>e.readable).map(e=>(0,h.jsx)(`option`,{value:e.id,children:e.title||`Untitled draft`},e.id))]})]}),(0,h.jsxs)(`label`,{className:`block space-y-1`,htmlFor:`template-name`,children:[(0,h.jsx)(`span`,{children:`Template name`}),(0,h.jsx)(cM,{id:`template-name`,value:u,required:!0,maxLength:120,disabled:f,onChange:e=>d(e.target.value)})]}),(0,h.jsx)(B,{type:`submit`,disabled:f||!c||!u.trim(),children:`Save template`})]}),s.isPending?(0,h.jsx)(`p`,{role:`status`,children:`Loading saved drafts…`}):null,s.data?.length===0?(0,h.jsx)(`p`,{children:`No saved drafts yet.`}):null,s.error?(0,h.jsxs)(`p`,{role:`alert`,children:[s.error.message,` `,(0,h.jsx)(B,{type:`button`,onClick:()=>void s.refetch(),children:`Reload drafts`})]}):null]}),r?(0,h.jsx)(`p`,{role:`status`,children:`Resolve the pending Start in Play before applying a template.`}):null,g&&!x?(0,h.jsx)(`p`,{role:`alert`,className:`text-red`,children:g}):null,y?(0,h.jsx)(`p`,{role:`status`,children:y}):null,o.isPending?(0,h.jsx)(`p`,{role:`status`,children:`Loading templates…`}):null,o.error?(0,h.jsxs)(`p`,{role:`alert`,children:[o.error.message,` `,(0,h.jsx)(B,{type:`button`,onClick:()=>void o.refetch(),children:`Reload templates`})]}):null,o.data?.length===0?(0,h.jsx)(`p`,{children:`No templates yet. Save a Play draft above to reuse its setup.`}):null,(0,h.jsx)(B,{type:`button`,variant:`ghost`,disabled:f||o.isFetching,onClick:()=>void o.refetch(),children:`Refresh templates`}),(0,h.jsx)(`ul`,{className:`space-y-3`,"aria-label":`Project templates`,children:o.data?.map(e=>(0,h.jsxs)(`li`,{className:`flex flex-wrap items-center justify-between gap-4 rounded-panel border border-line bg-panel p-4`,children:[(0,h.jsxs)(`div`,{className:`min-w-0`,children:[(0,h.jsx)(`h2`,{className:`break-words font-semibold`,children:e.name}),(0,h.jsxs)(`p`,{className:`text-small text-ink3`,children:[`Version `,e.version,` · Updated`,` `,(0,h.jsx)(`time`,{dateTime:e.updatedAt,children:e.updatedAt.slice(0,10)})]})]}),(0,h.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,h.jsx)(B,{type:`button`,"aria-label":`Apply ${e.name}`,disabled:f||r,onClick:()=>void D(()=>ee(e)),children:`Apply to Play`}),(0,h.jsx)(B,{type:`button`,variant:`ghost`,"aria-label":`Delete ${e.name}`,disabled:f,onClick:()=>{S(e),v(null)},children:`Delete`})]})]},e.id))}),(0,h.jsx)(Nj,{open:x!==null,title:`Delete ${x?.name??`template`}?`,consequence:g??`Existing projects and drafts keep their setup.`,verb:`Delete template`,pending:f,onConfirm:()=>void D(k),onCancel:()=>{f||S(null)}})]})}function U2({counters:e}){return(0,h.jsx)(`dl`,{className:`m-0 grid grid-cols-2 overflow-hidden rounded-panel border border-line bg-panel md:grid-cols-5`,children:e.map(e=>(0,h.jsxs)(`div`,{className:`-ml-px flex flex-col-reverse gap-2 border-l border-line p-[18px]`,children:[(0,h.jsx)(`dt`,{className:`engraved text-ink3`,children:e.label}),(0,h.jsx)(`dd`,{className:`m-0 text-counter font-bold tabular-nums tracking-[-0.01em]`,children:e.value})]},e.label))})}function W2({cells:e}){return(0,h.jsx)(`div`,{className:`grid grid-cols-2 overflow-hidden rounded-panel border border-line bg-panel md:grid-cols-5`,children:Array.from({length:e},(e,t)=>t).map(e=>(0,h.jsxs)(`div`,{className:`-ml-px flex flex-col gap-2 border-l border-line p-[18px]`,children:[(0,h.jsx)(`span`,{className:`h-8 w-20 rounded-control bg-panel2`}),(0,h.jsx)(`span`,{className:`h-3 w-24 rounded-control bg-panel2`})]},e))})}function G2(){let{api:e}=I(),t=nt(_y(e));return(0,h.jsxs)(`div`,{className:`flex max-w-[1100px] flex-col gap-6`,children:[(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`h1`,{className:`mb-1 text-title font-bold tracking-[-0.01em]`,children:`Usage`}),(0,h.jsx)(`p`,{className:`text-body text-ink2`,children:`This machine only. The same counters, anonymised, feed slopify.stream.`})]}),t.error===null?null:(0,h.jsx)(Pj,{children:(0,h.jsx)(`p`,{className:`px-4 py-[14px] text-body text-red`,children:t.error.message})}),t.data===void 0?t.error===null?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(W2,{cells:5}),(0,h.jsx)(e4,{})]}):null:(0,h.jsx)(K2,{usage:t.data})]})}function K2({usage:e}){let t=Object.values(e.counters).every(e=>e===0);return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(U2,{counters:$2(e)}),t?(0,h.jsx)(`p`,{className:`-mt-3 text-body text-ink2`,children:`Numbers appear after your first run.`}):null,(0,h.jsxs)(`div`,{className:`overflow-hidden rounded-panel border border-line bg-panel`,children:[(0,h.jsxs)(`table`,{"aria-label":`Tokens by stage`,className:`w-full table-fixed border-collapse`,children:[(0,h.jsx)(`thead`,{children:(0,h.jsxs)(`tr`,{className:`border-b border-line`,children:[(0,h.jsx)(q2,{className:`w-[24%]`,children:`Tokens by stage`}),(0,h.jsx)(q2,{className:`w-[38%]`,children:`Provider · model`}),(0,h.jsx)(q2,{className:`w-[19%] text-right`,children:`Tokens in`}),(0,h.jsx)(q2,{className:`w-[19%] text-right`,children:`Tokens out`})]})}),(0,h.jsx)(`tbody`,{children:e.byStage.map(e=>(0,h.jsxs)(`tr`,{className:`border-b border-line last:border-b-0`,children:[(0,h.jsx)(J2,{className:`truncate font-semibold`,children:zk[e.stage]}),(0,h.jsx)(J2,{className:`truncate text-ink2`,children:Y2(e)}),(0,h.jsx)(J2,{className:`text-right tabular-nums`,children:X2.format(e.tokensIn)}),(0,h.jsx)(J2,{className:`text-right tabular-nums`,children:X2.format(e.tokensOut)})]},`${e.stage}/${e.provider}/${e.model??``}`))})]}),e.byStage.length===0?(0,h.jsx)(`p`,{className:`px-4 py-5 text-small text-ink3`,children:`No stages have run yet.`}):null]}),(0,h.jsx)(`p`,{className:`engraved text-ink3`,children:`Machine ID ${e.machineId??`not made yet`} · Slopify ${e.appVersion}`})]})}function q2({children:e,className:t}){return(0,h.jsx)(`th`,{className:`engraved px-4 py-3 text-left text-ink3 ${t}`,children:e})}function J2({children:e,className:t}){return(0,h.jsx)(`td`,{className:`px-4 py-3 align-top text-small ${t}`,children:e})}function Y2(e){return e.model===null?e.provider:`${e.provider} · ${e.model}`}var X2=new Intl.NumberFormat(void 0,{maximumFractionDigits:0}),Z2=new Intl.NumberFormat(void 0,{maximumFractionDigits:1}),Q2=new Intl.NumberFormat(void 0,{notation:`compact`,maximumFractionDigits:1});function $2(e){let t=e.counters;return[{label:`Videos made`,value:X2.format(t.videosMade)},{label:`Hours of audio`,value:Z2.format(t.audioSeconds/3600)},{label:`Images made`,value:X2.format(t.imagesMade)},{label:`Tokens used`,value:t.tokensUsed<1e6?X2.format(t.tokensUsed):Q2.format(t.tokensUsed)},{label:`Projects`,value:X2.format(t.projects)}]}function e4(){return(0,h.jsx)(Pj,{children:[0,1,2,3].map(e=>(0,h.jsxs)(`div`,{className:`flex items-center gap-[14px] border-b border-line px-4 py-3 last:border-b-0`,children:[(0,h.jsx)(`span`,{className:`h-3 w-24 rounded-control bg-panel2`}),(0,h.jsx)(`span`,{className:`h-3 w-56 rounded-control bg-panel2`}),(0,h.jsx)(`span`,{className:`ml-auto h-3 w-20 rounded-control bg-panel2`}),(0,h.jsx)(`span`,{className:`h-3 w-20 rounded-control bg-panel2`})]},e))})}var t4=da({component:xj}),n4=la({getParentRoute:()=>t4,path:`/`,component:Yq}),r4=la({getParentRoute:()=>t4,path:`play`,component:gP}),i4=la({getParentRoute:()=>t4,path:`templates`,component:o4}),a4=la({getParentRoute:()=>t4,path:`schedules`,component:l2});function o4(){let e=Ek(),t=Gi();return(0,h.jsx)(H2,{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 s4=la({getParentRoute:()=>t4,path:`projects/$projectId`,component:g4}),c4=la({getParentRoute:()=>t4,path:`prompts`,validateSearch:e=>({kind:Mj(e.kind)}),component:_4}),l4=la({getParentRoute:()=>t4,path:`prompts/new`,validateSearch:e=>{let t=Mj(e.kind);return typeof e.from==`string`?{kind:t,from:e.from}:{kind:t}},component:v4}),u4=la({getParentRoute:()=>t4,path:`prompts/$promptId`,component:y4}),d4=la({getParentRoute:()=>t4,path:`entries`,validateSearch:e=>({category:kj(e.category)}),component:x4}),f4=la({getParentRoute:()=>t4,path:`entries/new`,validateSearch:e=>{let t=kj(e.category);return typeof e.from==`string`?{category:t,from:e.from}:{category:t}},component:S4}),p4=la({getParentRoute:()=>t4,path:`entries/$entryId`,component:C4}),m4=la({getParentRoute:()=>t4,path:`settings`,component:R2}),h4=la({getParentRoute:()=>t4,path:`usage`,component:G2});function g4(){let{projectId:e}=s4.useParams();return(0,h.jsx)(Hq,{projectId:e},e)}function _4(){let{kind:e}=c4.useSearch(),t=Gi();return(0,h.jsx)(oJ,{kind:e,onKind:e=>{t({to:`/prompts`,search:{kind:e},replace:!0})}})}function v4(){let{kind:e,from:t}=l4.useSearch(),n=b4();return(0,h.jsx)(tJ,{promptId:void 0,kind:e,from:t,onLeave:n},`${e}:${t??`new`}`)}function y4(){let{promptId:e}=u4.useParams(),t=b4();return(0,h.jsx)(tJ,{promptId:e,kind:`article`,from:void 0,onLeave:t},e)}function b4(){let e=Gi();return t=>{e({to:`/prompts`,search:{kind:t}})}}function x4(){let{category:e}=d4.useSearch(),t=Gi();return(0,h.jsx)(Kj,{category:e,onCategory:e=>{t({to:`/entries`,search:{category:e},replace:!0})}})}function S4(){let{category:e,from:t}=f4.useSearch(),n=w4();return(0,h.jsx)(AM,{entryId:void 0,category:e,from:t,onLeave:n})}function C4(){let{entryId:e}=p4.useParams(),t=w4();return(0,h.jsx)(AM,{entryId:e,category:`intro`,from:void 0,onLeave:t})}function w4(){let e=Gi();return t=>{e({to:`/entries`,search:{category:t}})}}var T4=t4.addChildren({projectsRoute:n4,playRoute:r4,templatesRoute:i4,schedulesRoute:a4,projectRoute:s4,promptsRoute:c4,newPromptRoute:l4,promptRoute:u4,entriesRoute:d4,newEntryRoute:f4,entryRoute:p4,settingsRoute:m4,usageRoute:h4});function E4(){return Oa({routeTree:T4})}function D4(){let e,t,n=new Set;return{observe:r=>{if(e===void 0){e=r;return}if(r!==e&&r!==t){t=r;for(let e of n)e()}},staleAt:()=>t,subscribe:e=>(n.add(e),()=>{n.delete(e)})}}function O4(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 k4(e){let t=D4(),n={api:oo(window.location.origin,O4(window.fetch.bind(window),t)),openEvents:e=>new EventSource(e),version:t};(0,$a.createRoot)(e).render((0,h.jsx)(m.StrictMode,{children:(0,h.jsx)(v,{client:new Ue,children:(0,h.jsx)(Ro,{deps:n,children:(0,h.jsx)(ja,{router:E4()})})})}))}var A4=document.getElementById(`root`);if(A4===null)throw Error(`index.html carries no #root element for the app to mount on`);k4(A4);
137
+ 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),NJ=Y.default.BigInt(0),PJ=Y.default.BigInt(1),FJ=Y.default.BigInt(2),IJ=Y.default.BigInt(10),LJ=Y.default.BigInt(24),RJ=Y.default.BigInt(60),zJ=Y.default.BigInt(1e3),BJ=Y.default.BigInt(1e6),VJ=Y.default.BigInt(1e9),HJ=Y.default.multiply(Y.default.BigInt(3600),VJ),UJ=Y.default.multiply(RJ,VJ),WJ=Y.default.multiply(HJ,LJ);function GJ(e){return typeof e==`bigint`?Y.default.BigInt(e.toString(10)):e}function KJ(e){return Y.default.equal(Y.default.remainder(e,FJ),NJ)}function qJ(e){return Y.default.lessThan(e,NJ)?Y.default.unaryMinus(e):e}function JJ(e,t){return Y.default.lessThan(e,t)?-1:+!!Y.default.greaterThan(e,t)}function YJ(e,t){return{quotient:Y.default.divide(e,t),remainder:Y.default.remainder(e,t)}}var XJ,ZJ,QJ=`slot-epochNanoSeconds`,$J=`slot-iso-date`,eY=`slot-iso-date-time`,tY=`slot-time`,X=`slot-calendar`,nY=`slot-date-brand`,rY=`slot-year-month-brand`,iY=`slot-month-day-brand`,aY=`slot-time-zone`,oY=`slot-years`,sY=`slot-months`,cY=`slot-weeks`,lY=`slot-days`,uY=`slot-hours`,dY=`slot-minutes`,fY=`slot-seconds`,pY=`slot-milliseconds`,mY=`slot-microseconds`,hY=`slot-nanoseconds`,gY=`date`,_Y=`ym`,vY=`md`,yY=`time`,bY=`datetime`,xY=`instant`,SY=`original`,CY=`timezone-canonical`,wY=`timezone-original`,TY=`calendar-id`,EY=`locale`,DY=`options`,OY=new WeakMap,kY=Symbol.for(`@@Temporal__GetSlots`);(XJ=globalThis)[kY]||(XJ[kY]=function(e){return OY.get(e)});var AY=globalThis[kY],jY=Symbol.for(`@@Temporal__CreateSlots`);(ZJ=globalThis)[jY]||(ZJ[jY]=function(e){OY.set(e,Object.create(null))});var MY=globalThis[jY];function NY(e,...t){if(!e||typeof e!=`object`)return!1;let n=AY(e);return!!n&&t.every((e=>e in n))}function Z(e,t){let n=AY(e)?.[t];if(n===void 0)throw TypeError(`Missing internal slot ${t}`);return n}function PY(e,t,n){let r=AY(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 FY={};function IY(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))}LY(t,e),LY(`${t}.prototype`,e.prototype)}function LY(e,t){let n=`%${e}%`;if(FY[n]!==void 0)throw Error(`intrinsic ${e} already exists`);FY[n]=t}function RY(e){return FY[e]}function zY(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 BY(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 VY(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 HY(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 UY=class e{constructor(e){this.totalNs=GJ(e),this.sec=Y.default.toNumber(Y.default.divide(this.totalNs,VJ)),this.subsec=Y.default.toNumber(Y.default.remainder(this.totalNs,VJ))}static validateNew(t,n){if(Y.default.greaterThan(qJ(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=Y.default.subtract(GJ(t),GJ(n));return new e(r)}static fromComponents(t,n,r,i,a,o){let s=Y.default.add(Y.default.add(Y.default.add(Y.default.add(Y.default.add(Y.default.BigInt(o),Y.default.multiply(Y.default.BigInt(a),zJ)),Y.default.multiply(Y.default.BigInt(i),BJ)),Y.default.multiply(Y.default.BigInt(r),VJ)),Y.default.multiply(Y.default.BigInt(n),UJ)),Y.default.multiply(Y.default.BigInt(t),HJ));return e.validateNew(s,`total`)}abs(){return new e(qJ(this.totalNs))}add(t){return e.validateNew(Y.default.add(this.totalNs,t.totalNs),`sum`)}add24HourDays(t){return e.validateNew(Y.default.add(this.totalNs,Y.default.multiply(Y.default.BigInt(t),WJ)),`sum`)}addToEpochNs(e){return Y.default.add(GJ(e),this.totalNs)}cmp(e){return JJ(this.totalNs,e.totalNs)}divmod(t){let{quotient:n,remainder:r}=YJ(this.totalNs,Y.default.BigInt(t));return{quotient:Y.default.toNumber(n),remainder:new e(r)}}fdiv(e){let t=GJ(e),n=Y.default.BigInt(t),{quotient:r,remainder:i}=YJ(this.totalNs,n),a=[],o,s=(Y.default.lessThan(this.totalNs,NJ)?-1:1)*Math.sign(Y.default.toNumber(t));for(;!Y.default.equal(i,NJ)&&a.length<50;)i=Y.default.multiply(i,IJ),{quotient:o,remainder:i}=YJ(i,n),a.push(Math.abs(Y.default.toNumber(o)));return s*Number(qJ(r).toString()+`.`+a.join(``))}isZero(){return Y.default.equal(this.totalNs,NJ)}round(t,n){let r=GJ(t);if(Y.default.equal(r,PJ))return this;let{quotient:i,remainder:a}=YJ(this.totalNs,r),o=Y.default.lessThan(this.totalNs,NJ)?`negative`:`positive`,s=Y.default.multiply(qJ(i),r),c=Y.default.add(s,r),l=JJ(qJ(Y.default.multiply(a,FJ)),r),u=VY(n,o),d=Y.default.equal(qJ(this.totalNs),s)?s:HY(s,c,l,KJ(i),u),f=o===`positive`?d:Y.default.unaryMinus(d);return e.validateNew(f,`rounding`)}sign(){return this.cmp(new e(NJ))}subtract(t){return e.validateNew(Y.default.subtract(this.totalNs,t.totalNs),`difference`)}};UY.MAX=Y.default.BigInt(`9007199254740991999999999`),UY.ZERO=new UY(NJ);var WY=/[A-Za-z._][A-Za-z._0-9+-]*/,GY=RegExp(`(?:(?:[+-](?:[01][0-9]|2[0-3])(?::?[0-5][0-9])?)|(?:${WY.source})(?:\\/(?:${WY.source}))*)`),KY=/(?:[+-]\d{6}|\d{4})/,qY=/(?:0[1-9]|1[0-2])/,JY=/(?:0[1-9]|[12]\d|3[01])/,YY=RegExp(`(${KY.source})(?:-(${qY.source})-(${JY.source})|(${qY.source})(${JY.source}))`),XY=/(\d{2})(?::(\d{2})(?::(\d{2})(?:[.,](\d{1,9}))?)?|(\d{2})(?:(\d{2})(?:[.,](\d{1,9}))?)?)?/,ZY=/((?:[+-])(?:[01][0-9]|2[0-3])(?::?(?:[0-5][0-9])(?::?(?:[0-5][0-9])(?:[.,](?:\d{1,9}))?)?)?)/,QY=RegExp(`([zZ])|${ZY.source}?`),$Y=/\[(!)?([a-z_][a-z0-9_-]*)=([A-Za-z0-9]+(?:-[A-Za-z0-9]+)*)\]/g,eX=new RegExp([`^${YY.source}`,`(?:(?:[tT]|\\s+)${XY.source}(?:${QY.source})?)?`,`(?:\\[!?(${GY.source})\\])?`,`((?:${$Y.source})*)$`].join(``)),tX=new RegExp([`^[tT]?${XY.source}`,`(?:${QY.source})?`,`(?:\\[!?${GY.source}\\])?`,`((?:${$Y.source})*)$`].join(``)),nX=RegExp(`^(${KY.source})-?(${qY.source})(?:\\[!?${GY.source}\\])?((?:${$Y.source})*)$`),rX=RegExp(`^(?:--)?(${qY.source})-?(${JY.source})(?:\\[!?${GY.source}\\])?((?:${$Y.source})*)$`),iX=/(\d+)(?:[.,](\d{1,9}))?/,aX=RegExp(`(?:${iX.source}H)?(?:${iX.source}M)?(?:${iX.source}S)?`),oX=RegExp(`^([+-])?P(?:(\\d+)Y)?(?:(\\d+)M)?(?:(\\d+)W)?(?:(\\d+)D)?(?:T(?!$)${aX.source})?$`,`i`),sX=864e5,cX=1e6*sX,lX=6e10,uX=1e8*sX,dX=l1(uX),fX=Y.default.unaryMinus(dX),pX=Y.default.add(Y.default.subtract(fX,WJ),PJ),mX=Y.default.subtract(Y.default.add(dX,WJ),PJ),hX=146097*sX,gX=-271821,_X=275760,vX=Date.UTC(1847,0,1),yX=[`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`],bX=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 xX(e){return typeof e==`object`&&!!e||typeof e==`function`}function SX(e){if(typeof e==`bigint`)throw TypeError(`Cannot convert BigInt to number`);return Number(e)}function CX(e){if(typeof e==`symbol`)throw TypeError(`Cannot convert a Symbol value to a String`);return String(e)}function wX(e){let t=SX(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 TX(e,t){let n=wX(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 EX(e){let t=SX(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 DX(e,t){return String(e).padStart(t,`0`)}function OX(e){if(typeof e!=`string`)throw TypeError(`expected a string, not ${String(e)}`);return e}function kX(e,t){if(xX(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 AX=[`era`,`eraYear`,`year`,`month`,`monthCode`,`day`,`hour`,`minute`,`second`,`millisecond`,`microsecond`,`nanosecond`,`offset`,`timeZone`],jX={era:CX,eraYear:wX,year:wX,month:TX,monthCode:function(e){let t=OX(kX(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:TX,hour:wX,minute:wX,second:wX,millisecond:wX,microsecond:wX,nanosecond:wX,offset:function(e){let t=OX(kX(e));return IQ(t),t},timeZone:mQ},MX={hour:0,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0},NX=[[`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`]],PX=Object.fromEntries(NX.map((e=>[e[0],e[1]]))),FX=Object.fromEntries(NX.map((([e,t])=>[t,e]))),IX=NX.map((([,e])=>e)),LX={day:cX,hour:36e11,minute:6e10,second:1e9,millisecond:1e6,microsecond:1e3,nanosecond:1},RX=[`days`,`hours`,`microseconds`,`milliseconds`,`minutes`,`months`,`nanoseconds`,`seconds`,`weeks`,`years`],zX=Intl.DateTimeFormat,BX=new Map;function VX(e){let t=_1(e),n=BX.get(t);return n===void 0&&(n=new zX(`en-us`,{timeZone:t,hour12:!1,era:`short`,year:`numeric`,month:`numeric`,day:`numeric`,hour:`numeric`,minute:`numeric`,second:`numeric`}),BX.set(t,n)),n}function HX(e){return NY(e,QJ)&&!NY(e,aY,X)}function UX(e){return NY(e,oY,sY,lY,uY,dY,fY,pY,mY,hY)}function WX(e){return NY(e,nY)}function GX(e){return NY(e,tY)}function KX(e){return NY(e,eY)}function qX(e){return NY(e,rY)}function JX(e){return NY(e,iY)}function YX(e){return NY(e,QJ,aY,X)}function Q(e,t){if(!t(e))throw TypeError(`invalid receiver: method called with the wrong type of this-object`)}function XX(e){if(NY(e,X)||NY(e,aY))throw TypeError(`with() does not support a calendar or timeZone property`);if(GX(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 ZX(e,t){return t===`never`||t===`auto`&&e===`iso8601`?``:`[${t===`critical`?`!`:``}u-ca=${e}]`}function QX(e){let t,n,r=!1;for($Y.lastIndex=0;n=$Y.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 $X(e){let t=eX.exec(e);if(!t)throw RangeError(`invalid RFC 9557 string: ${e}`);let n=QX(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 p$(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 eZ(e){let t=tX.exec(e),n,r,i,a,o,s,c;if(t){c=QX(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}=$X(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(f$(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}=nZ(e);u$(1972,t,n)}catch{try{let{year:t,month:n}=tZ(e);u$(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 tZ(e){let t=nX.exec(e),n,r,i,a;if(t){i=QX(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}=$X(e),t)throw RangeError(`Z designator not supported for PlainYearMonth`)}return{year:n,month:r,calendar:i,referenceISODay:a}}function nZ(e){let t=rX.exec(e),n,r,i,a;if(t){if(i=QX(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}=$X(e),t)throw RangeError(`Z designator not supported for PlainMonthDay`)}return{month:n,day:r,calendar:i,referenceISOYear:a}}var rZ=RegExp(`^${GY.source}$`,`i`),iZ=RegExp(`^([+-])([01][0-9]|2[0-3])(?::?([0-5][0-9])?)?$`);function aZ(e){let t=y1.test(e)?`Seconds not allowed in offset time zone`:`Invalid time zone`;throw RangeError(`${t}: ${e}`)}function oZ(e){return rZ.test(e)||aZ(e),iZ.test(e)?{offsetMinutes:IQ(e)/6e10}:{tzName:e}}function sZ(e,t,n,r){let i=e,a=t,o=n;switch(r){case`reject`:u$(i,a,o);break;case`constrain`:({year:i,month:a,day:o}=c$(i,a,o))}return{year:i,month:a,day:o}}function cZ(e,t,n,r,i,a,o){let s=e,c=t,l=n,u=r,d=i,f=a;switch(o){case`reject`:f$(s,c,l,u,d,f);break;case`constrain`:s=s$(s,0,23),c=s$(c,0,59),l=s$(l,0,59),u=s$(u,0,999),d=s$(d,0,999),f=s$(f,0,999)}return{hour:s,minute:c,second:l,millisecond:u,microsecond:d,nanosecond:f}}function lZ(e){if(!xX(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]=EX(a))}if(!n)throw TypeError(`invalid duration-like`);return t}function uZ({years:e,months:t,weeks:n,days:r},i,a,o){return{years:e,months:o??t,weeks:a??n,days:i??r}}function dZ(e,t){return{isoDate:e,time:t}}function fZ(e){return h1(e,`overflow`,[`constrain`,`reject`],`constrain`)}function pZ(e){return h1(e,`disambiguation`,[`compatible`,`earlier`,`later`,`reject`],`compatible`)}function mZ(e,t){return h1(e,`roundingMode`,[`ceil`,`floor`,`expand`,`trunc`,`halfCeil`,`halfFloor`,`halfExpand`,`halfTrunc`,`halfEven`],t)}function hZ(e,t){return h1(e,`offset`,[`prefer`,`use`,`ignore`,`reject`],t)}function gZ(e){return h1(e,`calendarName`,[`auto`,`always`,`never`,`critical`],`auto`)}function _Z(e){let t=e.roundingIncrement;if(t===void 0)return 1;let n=wX(t);if(n<1||n>1e9)throw RangeError(`roundingIncrement must be at least 1 and at most 1e9, not ${t}`);return n}function vZ(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 yZ(e){let t=e.fractionalSecondDigits;if(t===void 0)return`auto`;if(typeof t!=`number`){if(CX(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 bZ(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 xZ=Symbol(`~required~`);function SZ(e,t,n,r,i=[]){let a=[];for(let e=0;e<NX.length;e++){let t=NX[e],r=t[1],i=t[2];n!==`datetime`&&n!==i||a.push(r)}a=a.concat(i);let o=r;o===xZ?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=FX[a[e]];t!==void 0&&s.push(t)}let c=h1(e,t,s,o);if(c===void 0&&r===xZ)throw RangeError(`${t} is required`);return c&&c in PX?PX[c]:c}function CZ(e){let t=e.relativeTo;if(t===void 0)return{};let n,r,i,a,o,s=`option`,c=!1;if(xX(t)){if(YX(t))return{zonedRelativeTo:t};if(WX(t))return{plainRelativeTo:t};if(KX(t))return{plainRelativeTo:GZ(Z(t,eY).isoDate,Z(t,X))};i=lQ(t);let e=jZ(i,t,[`year`,`month`,`monthCode`,`day`],[`hour`,`minute`,`second`,`millisecond`,`microsecond`,`nanosecond`,`offset`,`timeZone`],[]);({isoDate:n,time:r}=PZ(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}=$X(OX(t)),e)a=mQ(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=g1(i),n={year:u,month:d,day:f}}return a===void 0?{plainRelativeTo:GZ(n,i)}:{zonedRelativeTo:rQ(HZ(n,r,s,s===`option`?IQ(o):0,a,`compatible`,`reject`,c),a,i)}}function wZ(e){return Z(e,oY)===0?Z(e,sY)===0?Z(e,cY)===0?Z(e,lY)===0?Z(e,uY)===0?Z(e,dY)===0?Z(e,fY)===0?Z(e,pY)===0?Z(e,mY)===0?`nanosecond`:`microsecond`:`millisecond`:`second`:`minute`:`hour`:`day`:`week`:`month`:`year`}function TZ(e,t){return IX.indexOf(e)>IX.indexOf(t)?t:e}function EZ(e){return e===`year`||e===`month`||e===`week`}function DZ(e){return EZ(e)||e===`day`?`date`:`time`}function OZ(e){return RY(`%calendarImpl%`)(e)}function kZ(e){return RY(`%calendarImpl%`)(Z(e,X))}function AZ(e,t,n=`date`){let r=Object.create(null),i=OZ(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 jZ(e,t,n,r,i){let a=OZ(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,jX[n])(r);else if(i!==`partial`){if(i.includes(n))throw TypeError(`required property '${n}' missing or undefined`);s[n]=MX[n]}}if(i===`partial`&&!c)throw TypeError(`no supported properties found`);return s}function MZ(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]=wX(s),r=!0)}if(!r)throw TypeError(`invalid time-like`);return i}function NZ(e,t){if(xX(e)){if(WX(e))return fZ($(t)),GZ(Z(e,$J),Z(e,X));if(YX(e)){let n=vQ(Z(e,aY),Z(e,QJ));return fZ($(t)),GZ(n.isoDate,Z(e,X))}if(KX(e))return fZ($(t)),GZ(Z(e,eY).isoDate,Z(e,X));let n=lQ(e);return GZ(dQ(n,jZ(n,e,[`year`,`month`,`monthCode`,`day`],[],[]),fZ($(t))),n)}let{year:n,month:r,day:i,calendar:a,z:o}=$X(OX(e));if(o)throw RangeError(`Z designator not supported for PlainDate`);return a||=`iso8601`,a=g1(a),fZ($(t)),GZ({year:n,month:r,day:i},a)}function PZ(e,t,n){return dZ(dQ(e,t,n),cZ(t.hour,t.minute,t.second,t.millisecond,t.microsecond,t.nanosecond,n))}function FZ(e,t){let n,r,i;if(xX(e)){if(KX(e))return fZ($(t)),qZ(Z(e,eY),Z(e,X));if(YX(e)){let n=vQ(Z(e,aY),Z(e,QJ));return fZ($(t)),qZ(n,Z(e,X))}if(WX(e))return fZ($(t)),qZ(dZ(Z(e,$J),{deltaDays:0,hour:0,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0}),Z(e,X));i=lQ(e);let a=jZ(i,e,[`year`,`month`,`monthCode`,`day`],[`hour`,`minute`,`second`,`millisecond`,`microsecond`,`nanosecond`],[]),o=fZ($(t));({isoDate:n,time:r}=PZ(i,a,o))}else{let a,o,s,c;if({year:o,month:s,day:c,time:r,calendar:i,z:a}=$X(OX(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}),p$(o,s,c,r.hour,r.minute,r.second,r.millisecond,r.microsecond,r.nanosecond),i||=`iso8601`,i=g1(i),fZ($(t)),n={year:o,month:s,day:c}}return qZ(dZ(n,r),i)}function IZ(e){let t=RY(`%Temporal.Duration%`);if(UX(e))return new t(Z(e,oY),Z(e,sY),Z(e,cY),Z(e,lY),Z(e,uY),Z(e,dY),Z(e,fY),Z(e,pY),Z(e,mY),Z(e,hY));if(!xX(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=oX.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:wX(t[2])*n,i=t[3]===void 0?0:wX(t[3])*n,a=t[4]===void 0?0:wX(t[4])*n,o=t[5]===void 0?0:wX(t[5])*n,s=t[6]===void 0?0:wX(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*wX((c+`000000000`).slice(0,9))*n}else if(p=l===void 0?0:wX(l)*n,u!==void 0){if(d??f)throw RangeError(`only the smallest unit can be fractional`);h=60*wX((u+`000000000`).slice(0,9))*n}else m=d===void 0?0:wX(d)*n,f!==void 0&&(h=wX((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),v$(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)}(OX(e));let n={years:0,months:0,weeks:0,days:0,hours:0,minutes:0,seconds:0,milliseconds:0,microseconds:0,nanoseconds:0},r=lZ(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 LZ(e){let t;if(xX(e)){if(HX(e)||YX(e))return tQ(Z(e,QJ));t=kX(e)}else t=e;let{year:n,month:r,day:i,time:a,offset:o,z:s}=function(e){let t=$X(e);if(!t.z&&!t.offset)throw RangeError(`Temporal.Instant requires a time zone offset`);return t}(OX(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=r$(n,r,i,c,l,u,d,f,p-(s?0:IQ(o)));return T$(m.isoDate),tQ(GQ(m))}function RZ(e,t){if(xX(e)){if(JX(e))return fZ($(t)),YZ(Z(e,$J),Z(e,X));let n;return NY(e,X)?n=Z(e,X):(n=e.calendar,n===void 0&&(n=`iso8601`),n=cQ(n)),YZ(pQ(n,jZ(n,e,[`year`,`month`,`monthCode`,`day`],[],[]),fZ($(t))),n)}let{month:n,day:r,referenceISOYear:i,calendar:a}=nZ(OX(e));if(a===void 0&&(a=`iso8601`),a=g1(a),fZ($(t)),a===`iso8601`)return YZ({year:1972,month:n,day:r},a);let o={year:i,month:n,day:r};return d$(o),o=pQ(a,AZ(a,o,`month-day`),`constrain`),YZ(o,a)}function zZ(e,t){let n;if(xX(e)){if(GX(e))return fZ($(t)),ZZ(Z(e,tY));if(KX(e))return fZ($(t)),ZZ(Z(e,eY).time);if(YX(e)){let n=vQ(Z(e,aY),Z(e,QJ));return fZ($(t)),ZZ(n.time)}let{hour:r,minute:i,second:a,millisecond:o,microsecond:s,nanosecond:c}=MZ(e);n=cZ(r,i,a,o,s,c,fZ($(t)))}else n=eZ(OX(e)),fZ($(t));return ZZ(n)}function BZ(e){return e===void 0?{deltaDays:0,hour:0,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0}:Z(zZ(e),tY)}function VZ(e,t){if(xX(e)){if(qX(e))return fZ($(t)),$Z(Z(e,$J),Z(e,X));let n=lQ(e);return $Z(fQ(n,jZ(n,e,[`year`,`month`,`monthCode`],[],[]),fZ($(t))),n)}let{year:n,month:r,referenceISODay:i,calendar:a}=tZ(OX(e));a===void 0&&(a=`iso8601`),a=g1(a),fZ($(t));let o={year:n,month:r,day:i};return _$(o),o=fQ(a,AZ(a,o,`year-month`),`constrain`),$Z(o,a)}function HZ(e,t,n,r,i,a,o,s){if(t===`start-of-day`)return SQ(i,e);let c=dZ(e,t);if(n===`wall`||o===`ignore`)return yQ(i,c,a);if(n===`exact`||o===`use`){let n=r$(e.year,e.month,e.day,t.hour,t.minute,t.second,t.millisecond,t.microsecond,t.nanosecond-r);T$(n.isoDate);let i=GQ(n);return g$(i),i}T$(e);let l=GQ(c),u=xQ(i,c);for(let e=0;e<u.length;e++){let t=u[e],n=Y.default.toNumber(Y.default.subtract(l,t)),i=Q$(n,6e10,`halfExpand`);if(n===r||s&&i===r)return t}if(o===`reject`){let e=_Q(r),t=jQ(c,`iso8601`,`auto`);throw RangeError(`Offset ${e} is invalid for ${t} in ${i}`)}return bQ(u,i,c,a)}function UZ(e,t){let n,r,i,a,o,s,c,l=!1,u=`option`;if(xX(e)){if(YX(e)){let n=$(t);return pZ(n),hZ(n,`reject`),fZ(n),rQ(Z(e,QJ),Z(e,aY),Z(e,X))}o=lQ(e);let l=jZ(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=$(t);s=pZ(d),c=hZ(d,`reject`);let f=fZ(d);({isoDate:n,time:r}=PZ(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=$X(e);if(!t.tzAnnotation)throw RangeError(`Temporal.ZonedDateTime requires a time zone ID in brackets`);return t}(OX(e))),i=mQ(d),f?u=`exact`:a||(u=`wall`),o||=`iso8601`,o=g1(o),l=!0;let g=$(t);s=pZ(g),c=hZ(g,`reject`),fZ(g),n={year:p,month:m,day:h}}let d=0;return u===`option`&&(d=IQ(a)),rQ(HZ(n,r,u,d,i,s,c,l),i,o)}function WZ(e,t,n){d$(t),MY(e),PY(e,$J,t),PY(e,X,n),PY(e,nY,!0)}function GZ(e,t){let n=RY(`%Temporal.PlainDate%`),r=Object.create(n.prototype);return WZ(r,e,t),r}function KZ(e,t,n){m$(t),MY(e),PY(e,eY,t),PY(e,X,n)}function qZ(e,t){let n=RY(`%Temporal.PlainDateTime%`),r=Object.create(n.prototype);return KZ(r,e,t),r}function JZ(e,t,n){d$(t),MY(e),PY(e,$J,t),PY(e,X,n),PY(e,iY,!0)}function YZ(e,t){let n=RY(`%Temporal.PlainMonthDay%`),r=Object.create(n.prototype);return JZ(r,e,t),r}function XZ(e,t){MY(e),PY(e,tY,t)}function ZZ(e){let t=RY(`%Temporal.PlainTime%`),n=Object.create(t.prototype);return XZ(n,e),n}function QZ(e,t,n){_$(t),MY(e),PY(e,$J,t),PY(e,X,n),PY(e,rY,!0)}function $Z(e,t){let n=RY(`%Temporal.PlainYearMonth%`),r=Object.create(n.prototype);return QZ(r,e,t),r}function eQ(e,t){g$(t),MY(e),PY(e,QJ,t)}function tQ(e){let t=RY(`%Temporal.Instant%`),n=Object.create(t.prototype);return eQ(n,e),n}function nQ(e,t,n,r){g$(t),MY(e),PY(e,QJ,t),PY(e,aY,n),PY(e,X,r)}function rQ(e,t,n=`iso8601`){let r=RY(`%Temporal.ZonedDateTime%`),i=Object.create(r.prototype);return nQ(i,e,t,n),i}function iQ(e){return AX.filter((t=>e[t]!==void 0))}function aQ(e,t,n){let r=iQ(n),i=OZ(e).fieldKeysToIgnore(r),a=Object.create(null),o=iQ(t);for(let e=0;e<AX.length;e++){let s,c=AX[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 oQ(e,t,n,r){let i=OZ(e).dateAdd(t,n,r);return d$(i),i}function sQ(e,t,n,r){return OZ(e).dateUntil(t,n,r)}function cQ(e){if(xX(e)&&NY(e,X))return Z(e,X);let t=OX(e);try{return g1(t)}catch{}let n;try{({calendar:n}=$X(t))}catch{try{({calendar:n}=eZ(t))}catch{try{({calendar:n}=tZ(t))}catch{({calendar:n}=nZ(t))}}}return n||=`iso8601`,g1(n)}function lQ(e){if(NY(e,X))return Z(e,X);let{calendar:t}=e;return t===void 0?`iso8601`:cQ(t)}function uQ(e,t){return g1(e)===g1(t)}function dQ(e,t,n){let r=OZ(e);r.resolveFields(t,`date`);let i=r.dateToISO(t,n);return d$(i),i}function fQ(e,t,n){let r=OZ(e);r.resolveFields(t,`year-month`),t.day=1;let i=r.dateToISO(t,n);return _$(i),i}function pQ(e,t,n){let r=OZ(e);r.resolveFields(t,`month-day`);let i=r.monthDayToISOReferenceDate(t,n);return d$(i),i}function mQ(e){if(xX(e)&&YX(e))return Z(e,aY);let t=OX(e);if(t===`UTC`)return`UTC`;let{tzName:n,offsetMinutes:r}=function(e){let{tzAnnotation:t,offset:n,z:r}=function(e){if(rZ.test(e))return{tzAnnotation:e,offset:void 0,z:!1};try{let{tzAnnotation:t,offset:n,z:r}=$X(e);if(r||t||n)return{tzAnnotation:t,offset:n,z:r}}catch{}aZ(e)}(e);return t?oZ(t):r?oZ(`UTC`):n?oZ(n):void 0}(t);if(r!==void 0)return HQ(r);let i=zQ(n);if(!i)throw RangeError(`Unrecognized time zone ${n}`);return i.identifier}function hQ(e,t){if(e===t)return!0;let n=oZ(e).offsetMinutes,r=oZ(t).offsetMinutes;if(n===void 0&&r===void 0){let n=zQ(t);if(!n)return!1;let r=zQ(e);return!!r&&r.primaryIdentifier===n.primaryIdentifier}return n===r}function gQ(e,t){let n=oZ(e).offsetMinutes;return n===void 0?VQ(e,t):6e10*n}function _Q(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}${EQ(r,i,a,o,a===0&&o===0?`minute`:`auto`)}`}function vQ(e,t){let n=gQ(e,t),{isoDate:{year:r,month:i,day:a},time:{hour:o,minute:s,second:c,millisecond:l,microsecond:u,nanosecond:d}}=KQ(t);return r$(r,i,a,o,s,c,l,u,d+n)}function yQ(e,t,n){return bQ(xQ(e,t),e,t,n)}function bQ(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=GQ(n),o=Y.default.subtract(a,WJ);g$(o);let s=gQ(t,o),c=Y.default.add(a,WJ);g$(c);let l=gQ(t,c)-s;switch(r){case`earlier`:{let e=UY.fromComponents(0,0,0,0,0,-l),r=H$(n.time,e);return xQ(t,dZ(n$(n.isoDate.year,n.isoDate.month,n.isoDate.day+r.deltaDays),r))[0]}case`compatible`:case`later`:{let e=UY.fromComponents(0,0,0,0,0,l),r=H$(n.time,e),i=xQ(t,dZ(n$(n.isoDate.year,n.isoDate.month,n.isoDate.day+r.deltaDays),r));return i[i.length-1]}}}function xQ(e,t){if(e===`UTC`)return T$(t.isoDate),[GQ(t)];let n=oZ(e).offsetMinutes;if(n!==void 0){let e=r$(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);T$(e.isoDate);let r=GQ(e);return g$(r),[r]}return T$(t.isoDate),function(e,t){let n=GQ(t),r=Y.default.subtract(n,WJ);Y.default.lessThan(r,fX)&&(r=n);let i=Y.default.add(n,WJ);Y.default.greaterThan(i,dX)&&(i=n);let a=VQ(e,r),o=VQ(e,i);return(a===o?[a]:[a,o]).map((r=>{let i=Y.default.subtract(n,Y.default.BigInt(r));if(o1(t,function(e,t){let{epochMilliseconds:n,time:{millisecond:r,microsecond:i,nanosecond:a}}=KQ(t),{year:o,month:s,day:c,hour:l,minute:u,second:d}=YQ(e,n);return r$(o,s,c,l,u,d,r,i,a)}(e,i))===0)return g$(i),i})).filter((e=>e!==void 0))}(e,t)}function SQ(e,t){let n=dZ(t,{deltaDays:0,hour:0,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0}),r=xQ(e,n);if(r.length)return r[0];let i=GQ(n),a=Y.default.subtract(i,WJ);return g$(a),qQ(e,a)}function CQ(e){let t;return t=e<0||e>9999?(e<0?`-`:`+`)+DX(Math.abs(e),6):DX(e,4),t}function wQ(e){return DX(e,2)}function TQ(e,t){let n;if(t===`auto`){if(e===0)return``;n=DX(e,9).replace(/0+$/,``)}else{if(t===0)return``;n=DX(e,9).slice(0,t)}return`.${n}`}function EQ(e,t,n,r,i){let a=`${wQ(e)}:${wQ(t)}`;return i===`minute`||(a+=`:${wQ(n)}`,a+=TQ(r,i)),a}function DQ(e,t,n){let r=t;r===void 0&&(r=`UTC`);let i=Z(e,QJ),a=jQ(vQ(r,i),`iso8601`,n,`never`),o=`Z`;return t!==void 0&&(o=UQ(gQ(r,i))),`${a}${o}`}function OQ(e,t){let n=Z(e,oY),r=Z(e,sY),i=Z(e,cY),a=Z(e,lY),o=Z(e,uY),s=Z(e,dY),c=QQ(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=UY.fromComponents(0,0,Z(e,fY),Z(e,pY),Z(e,mY),Z(e,hY));d.isZero()&&![`second`,`millisecond`,`microsecond`,`nanosecond`].includes(wZ(e))&&t===`auto`||(u+=`${Math.abs(d.sec)}${TQ(Math.abs(d.subsec),t)}S`);let f=`${c<0?`-`:``}P${l}`;return u&&(f=`${f}T${u}`),f}function kQ(e,t=`auto`){let{year:n,month:r,day:i}=Z(e,$J);return`${CQ(n)}-${wQ(r)}-${wQ(i)}${ZX(Z(e,X),t)}`}function AQ({hour:e,minute:t,second:n,millisecond:r,microsecond:i,nanosecond:a},o){return EQ(e,t,n,1e6*r+1e3*i+a,o)}function jQ(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`${CQ(i)}-${wQ(a)}-${wQ(o)}T${EQ(s,c,l,1e6*u+1e3*d+f,n)}${ZX(t,r)}`}function MQ(e,t=`auto`){let{year:n,month:r,day:i}=Z(e,$J),a=`${wQ(r)}-${wQ(i)}`,o=Z(e,X);t!==`always`&&t!==`critical`&&o===`iso8601`||(a=`${CQ(n)}-${a}`);let s=ZX(o,t);return s&&(a+=s),a}function NQ(e,t=`auto`){let{year:n,month:r,day:i}=Z(e,$J),a=`${CQ(n)}-${wQ(r)}`,o=Z(e,X);t!==`always`&&t!==`critical`&&o===`iso8601`||(a+=`-${wQ(i)}`);let s=ZX(o,t);return s&&(a+=s),a}function PQ(e,t,n=`auto`,r=`auto`,i=`auto`,a=void 0){let o=Z(e,QJ);if(a){let{unit:e,increment:t,roundingMode:n}=a;o=$$(o,t,e,n)}let s=Z(e,aY),c=gQ(s,o),l=jQ(vQ(s,o),`iso8601`,t,`never`);return i!==`never`&&(l+=UQ(c)),r!==`never`&&(l+=`[${r===`critical`?`!`:``}${s}]`),l+=ZX(Z(e,X),n),l}function FQ(e){return iZ.test(e)}function IQ(e){let t=b1.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 LQ,RQ=Object.assign(Object.create(null),{"/":!0,"-":!0,_:!0});function zQ(e){if(LQ===void 0){let e=Intl.supportedValuesOf?.(`timeZone`);if(e){LQ=new Map;for(let t=0;t<e.length;t++){let n=e[t];LQ.set(_1(n),n)}}else LQ=null}let t=_1(e),n=LQ?.get(t);if(n)return{identifier:n,primaryIdentifier:n};try{n=VX(e).resolvedOptions().timeZone}catch{return}if(t===`antarctica/south_pole`&&(n=`Antarctica/McMurdo`),bX.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 BQ(e,t){let{year:n,month:r,day:i,hour:a,minute:o,second:s}=YQ(e,t),c=t%1e3;return c<0&&(c+=1e3),1e6*(WQ({isoDate:{year:n,month:r,day:i},time:{hour:a,minute:o,second:s,millisecond:c}})-t)}function VQ(e,t){return BQ(e,c1(t,`floor`))}function HQ(e){let t=e<0?`-`:`+`,n=Math.abs(e);return`${t}${EQ(Math.floor(n/60),n%60,0,0,`minute`)}`}function UQ(e){return HQ(Q$(e,lX,`halfExpand`)/6e10)}function WQ({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()+hX*c}function GQ(e){let t=WQ(e),n=1e3*e.time.microsecond+e.time.nanosecond;return Y.default.add(l1(t),Y.default.BigInt(n))}function KQ(e){let t=c1(e,`trunc`),n=Y.default.toNumber(Y.default.remainder(e,BJ));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 qQ(e,t){if(e===`UTC`)return null;let n=c1(t,`floor`);if(n<vX)return qQ(e,l1(vX));let r=Math.max(n,Date.now())+366*sX*3,i=n,a=BQ(e,i),o=i,s=a;for(;a===s&&i<r;){if(o=i+2*sX*7,o>uX)return null;s=BQ(e,o),a===s&&(i=o)}return a===s?null:l1(x1((t=>BQ(e,t)),i,o,a,s))}function JQ(e,t){if(e===`UTC`)return null;let n=c1(t,`ceil`),r=Date.now(),i=r+366*sX*3;if(n>i){let t=JQ(e,l1(i));if(t===null||Y.default.lessThan(t,l1(r)))return t}if(e===`Africa/Casablanca`||e===`Africa/El_Aaiun`){let t=Date.UTC(2088,0,1);if(t<n)return JQ(e,l1(t))}let a=n-1;if(a<vX)return null;let o=BQ(e,a),s=a,c=o;for(;o===c&&a>vX;){if(s=a-2*sX*7,s<vX)return null;c=BQ(e,s),o===c&&(a=s)}return o===c?null:l1(x1((t=>BQ(e,t)),s,a,c,o))}function YQ(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}}(VX(e).format(t))}function XQ(e){return e!==void 0&&!(e%4!=0||e%100==0&&e%400!=0)}function ZQ(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]}[XQ(e)?`leapyear`:`standard`][t-1]}function QQ(e){let t=[Z(e,oY),Z(e,sY),Z(e,cY),Z(e,lY),Z(e,uY),Z(e,dY),Z(e,fY),Z(e,pY),Z(e,mY),Z(e,hY)];for(let e=0;e<t.length;e++){let n=t[e];if(n!==0)return n<0?-1:1}return 0}function $Q(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 e$(e){let t=$Q(e.date);return t===0?e.time.sign():t}function t$(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 n$(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}=t$(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=XQ(c)?366:365,a<-s;)--r,--c,a+=s;for(c+=1;s=XQ(c)?366:365,a>s;)r+=1,c+=1,a-=s;for(;a<1;)({year:r,month:i}=t$(r,i-1)),a+=ZQ(r,i);for(;a>ZQ(r,i);)a-=ZQ(r,i),{year:r,month:i}=t$(r,i+1);return{year:r,month:i,day:a}}function r$(e,t,n,r,i,a,o,s,c){let l=i$(r,i,a,o,s,c);return dZ(n$(e,t,n+l.deltaDays),l)}function i$(e,t,n,r,i,a){let o,s=e,c=t,l=n,u=r,d=i,f=a;({div:o,mod:f}=zY(f,3)),d+=o,f<0&&(--d,f+=1e3),{div:o,mod:d}=zY(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 a$(e,t){let n=uZ(e,0);if($Q(n)===0)return e.days;let r=Z(t,$J),i=oQ(Z(t,X),r,n,`constrain`),a=w$(r.year,r.month-1,r.day),o=w$(i.year,i.month-1,i.day)-a;return e.days+o}function o$(e){return new(RY(`%Temporal.Duration%`))(-Z(e,oY),-Z(e,sY),-Z(e,cY),-Z(e,lY),-Z(e,uY),-Z(e,dY),-Z(e,fY),-Z(e,pY),-Z(e,mY),-Z(e,hY))}function s$(e,t,n){return Math.min(n,Math.max(t,e))}function c$(e,t,n){let r=s$(t,1,12);return{year:e,month:r,day:s$(n,1,ZQ(e,r))}}function l$(e,t,n){if(e<t||e>n)throw RangeError(`value out of range: ${t} <= ${e} <= ${n}`)}function u$(e,t,n){l$(t,1,12),l$(n,1,ZQ(e,t))}function d$(e){m$(dZ(e,{deltaDays:0,hour:12,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0}))}function f$(e,t,n,r,i,a){l$(e,0,23),l$(t,0,59),l$(n,0,59),l$(r,0,999),l$(i,0,999),l$(a,0,999)}function p$(e,t,n,r,i,a,o,s,c){u$(e,t,n),f$(r,i,a,o,s,c)}function m$(e){let t=GQ(e);(Y.default.lessThan(t,pX)||Y.default.greaterThan(t,mX))&&g$(t)}function h$(e){GQ(e)}function g$(e){if(Y.default.lessThan(e,fX)||Y.default.greaterThan(e,dX))throw RangeError(`date/time value is outside of supported range`)}function _$({year:e,month:t}){l$(e,gX,_X),e===gX?l$(t,4,12):e===_X&&l$(t,1,9)}function v$(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=zY(s,3),p=zY(c,6),m=zY(l,9),h=zY(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 y$(e){return{date:{years:Z(e,oY),months:Z(e,sY),weeks:Z(e,cY),days:Z(e,lY)},time:UY.fromComponents(Z(e,uY),Z(e,dY),Z(e,fY),Z(e,pY),Z(e,mY),Z(e,hY))}}function b$(e){let t=UY.fromComponents(Z(e,uY),Z(e,dY),Z(e,fY),Z(e,pY),Z(e,mY),Z(e,hY)).add24HourDays(Z(e,lY));return{date:{years:Z(e,oY),months:Z(e,sY),weeks:Z(e,cY),days:0},time:t}}function x$(e){let t=b$(e),n=Math.trunc(t.time.sec/86400);return v$(t.date.years,t.date.months,t.date.weeks,n,0,0,0,0,0,0),{...t.date,days:n}}function S$(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=BY(o,3,Math.trunc(i/1e3)),i%=1e3,o=0;break;case`microsecond`:i=BY(o,6,Math.trunc(r/1e3)),r%=1e3,o=0;break;case`nanosecond`:r=BY(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 C$(e,t){return $Q(e),t.sign(),{date:e,time:t}}function w$(e,t,n){return WQ({isoDate:{year:e,month:t+1,day:n},time:{hour:0,minute:0,second:0,millisecond:0}})/sX}function T$({year:e,month:t,day:n}){if(Math.abs(w$(e,t-1,n))>1e8)throw RangeError(`date/time value is outside the supported range`)}function E$(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 UY.fromComponents(n,r,i,a,o,s)}function D$(e,t,n,r,i){let a=UY.fromEpochNsDiff(t,e);return a=n1(a,n,r,i),C$({years:0,months:0,weeks:0,days:0},a)}function O$(e,t,n,r){h$(e),h$(t);let i=E$(e.time,t.time),a=i.sign(),o=i1(e.isoDate,t.isoDate),s=t.isoDate;o===a&&(s=n$(s.year,s.month,s.day+a),i=i.add24HourDays(-a));let c=TZ(`day`,r),l=sQ(n,e.isoDate,s,c);return r!==c&&(i=i.add24HourDays(l.days),l.days=0),C$(l,i)}function k$(e,t,n,r,i){let a=Y.default.subtract(t,e);if(Y.default.equal(a,NJ))return{date:{years:0,months:0,weeks:0,days:0},time:UY.ZERO};let o=Y.default.lessThan(a,NJ)?-1:1,s=vQ(n,e),c=vQ(n,t),l,u=0,d=o===1?2:1,f=E$(s.time,c.time);for(f.sign()===-o&&u++;u<=d;u++){l=dZ(n$(c.isoDate.year,c.isoDate.month,c.isoDate.day-u*o),s.time);let e=yQ(n,l,`compatible`);if(f=UY.fromEpochNsDiff(t,e),f.sign()!==-o)break}let p=TZ(`day`,i);return C$(sQ(r,s.isoDate,l.isoDate,p),f)}function A$(e,t,n,r,i,a,o,s,c){let l,u,d,f,p=t;switch(s){case`year`:{let t=Q$(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=Q$(p.date.months,o,`trunc`);l=t,u=t+o*e,d=uZ(p.date,0,0,l),f=uZ(p.date,0,0,u);break}case`week`:{let t=uZ(p.date,0,0),n=oQ(a,r.isoDate,t,`constrain`),i=sQ(a,n,n$(n.year,n.month,n.day+p.date.days),`week`),s=Q$(p.date.weeks+i.weeks,o,`trunc`);l=s,u=s+o*e,d=uZ(p.date,0,l),f=uZ(p.date,0,u);break}case`day`:{let t=Q$(p.date.days,o,`trunc`);l=t,u=t+o*e,d=uZ(p.date,l),f=uZ(p.date,u);break}}let m=oQ(a,r.isoDate,d,`constrain`),h=oQ(a,r.isoDate,f,`constrain`),g,_,v=dZ(m,r.time),y=dZ(h,r.time);i?(g=yQ(i,v,`compatible`),_=yQ(i,y,`compatible`)):(g=GQ(v),_=GQ(y));let b=UY.fromEpochNsDiff(n,g),x=UY.fromEpochNsDiff(_,g),S=VY(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)?HY(Math.abs(l),Math.abs(u),C,w,S):Math.abs(u),E=new UY(Y.default.add(Y.default.multiply(x.totalNs,Y.default.BigInt(l)),Y.default.multiply(b.totalNs,Y.default.BigInt(o*e)))).fdiv(x.totalNs),D=T===Math.abs(u);return p={date:D?f:d,time:UY.ZERO},{nudgeResult:{duration:p,nudgedEpochNs:D?_:g,didExpandCalendarUnit:D},total:E}}function j$(e,t,n,r,i,a,o,s,c){let l=e,u=EZ(s)||r&&s===`day`,d=e$(l)<0?-1:1,f;return u?{nudgeResult:f}=A$(d,l,t,n,r,i,o,s,c):f=r?function(e,t,n,r,i,a,o,s){let c=t,l=oQ(i,n.isoDate,c.date,`constrain`),u=dZ(l,n.time),d=dZ(n$(l.year,l.month,l.day+e),n.time),f=yQ(r,u,`compatible`),p=yQ(r,d,`compatible`),m=UY.fromEpochNsDiff(p,f);if(m.sign()!==e)throw RangeError(`time zone returned inconsistent Instants`);let h=Y.default.BigInt(LX[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:C$(uZ(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(Y.default.BigInt(r*LX[i]),a),l=c.subtract(s),{quotient:u}=s.divmod(cX),{quotient:d}=c.divmod(cX),f=Math.sign(d-u)===s.sign(),p=l.addToEpochNs(t),m=0,h=c;return DZ(n)===`date`&&(m=d,h=c.add(UY.fromComponents(24*-d,0,0,0,0,0))),{duration:{date:uZ(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=IX.indexOf(o);for(let t=IX.indexOf(s)-1;t>=l;t--){let s=IX[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=uZ(c.date,0,0,t);break}case`week`:{let t=c.date.weeks+e;l=uZ(c.date,0,t);break}}let u=dZ(oQ(a,r.isoDate,l,`constrain`),r.time),d;if(d=i?yQ(i,u,`compatible`):GQ(u),JJ(n,d)===-e)break;c={date:l,time:UY.ZERO}}return c}(d,l,f.nudgedEpochNs,n,r,i,a,TZ(s,`day`))),l}function M$(e,t,n,r,i,a){return EZ(a)||r&&a===`day`?A$(e$(e)<0?-1:1,e,t,n,r,i,1,a,`trunc`).total:r1(e.time.add24HourDays(e.date.days),a)}function N$(e,t,n,r,i,a,o){if(o1(e,t)==0)return{date:{years:0,months:0,weeks:0,days:0},time:UY.ZERO};m$(e),m$(t);let s=O$(e,t,n,r);return a===`nanosecond`&&i===1?s:j$(s,GQ(t),e,null,n,r,i,a,o)}function P$(e,t,n,r,i,a,o,s){if(DZ(i)===`time`)return D$(e,t,a,o,s);let c=k$(e,t,n,r,i);return o===`nanosecond`&&a===1?c:j$(c,t,vQ(n,e),n,r,i,a,o,s)}function F$(e,t,n,r,i,a){let o=NX.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=SZ(t,`largestUnit`,n,`auto`);if(r.includes(s))throw RangeError(`largestUnit must be one of ${o.join(`, `)}, not ${s}`);let c=_Z(t),l=mZ(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=SZ(t,`smallestUnit`,n,i);if(r.includes(u))throw RangeError(`smallestUnit must be one of ${o.join(`, `)}, not ${u}`);let d=TZ(a,u);if(s===`auto`&&(s=d),TZ(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&&vZ(c,f,!1),{largestUnit:s,roundingIncrement:c,roundingMode:l,smallestUnit:u}}function I$(e,t,n,r){let i=LZ(n),a=F$(e,$(r),`time`,[],`nanosecond`,`second`),o=S$(D$(Z(t,QJ),Z(i,QJ),a.roundingIncrement,a.smallestUnit,a.roundingMode),a.largestUnit);return e===`since`&&(o=o$(o)),o}function L$(e,t,n,r){let i=NZ(n),a=Z(t,X),o=Z(i,X);if(!uQ(a,o))throw RangeError(`cannot compute difference between dates of ${a} and ${o} calendars`);let s=F$(e,$(r),`date`,[],`day`,`day`),c=RY(`%Temporal.Duration%`),l=Z(t,$J),u=Z(i,$J);if(i1(l,u)===0)return new c;let d={date:sQ(a,l,u,s.largestUnit),time:UY.ZERO};if(s.smallestUnit!==`day`||s.roundingIncrement!==1){let e=dZ(l,{deltaDays:0,hour:0,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0});d=j$(d,GQ(dZ(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=S$(d,`day`);return e===`since`&&(f=o$(f)),f}function R$(e,t,n,r){let i=FZ(n),a=Z(t,X),o=Z(i,X);if(!uQ(a,o))throw RangeError(`cannot compute difference between dates of ${a} and ${o} calendars`);let s=F$(e,$(r),`datetime`,[],`nanosecond`,`day`),c=RY(`%Temporal.Duration%`),l=Z(t,eY),u=Z(i,eY);if(o1(l,u)===0)return new c;let d=S$(N$(l,u,a,s.largestUnit,s.roundingIncrement,s.smallestUnit,s.roundingMode),s.largestUnit);return e===`since`&&(d=o$(d)),d}function z$(e,t,n,r){let i=zZ(n),a=F$(e,$(r),`time`,[],`nanosecond`,`hour`),o=E$(Z(t,tY),Z(i,tY));o=n1(o,a.roundingIncrement,a.smallestUnit,a.roundingMode);let s=S$(C$({years:0,months:0,weeks:0,days:0},o),a.largestUnit);return e===`since`&&(s=o$(s)),s}function B$(e,t,n,r){let i=VZ(n),a=Z(t,X),o=Z(i,X);if(!uQ(a,o))throw RangeError(`cannot compute difference between months of ${a} and ${o} calendars`);let s=F$(e,$(r),`date`,[`week`,`day`],`month`,`year`),c=RY(`%Temporal.Duration%`);if(i1(Z(t,$J),Z(i,$J))==0)return new c;let l=AZ(a,Z(t,$J),`year-month`);l.day=1;let u=dQ(a,l,`constrain`),d=AZ(a,Z(i,$J),`year-month`);d.day=1;let f=dQ(a,d,`constrain`),p={date:uZ(sQ(a,u,f,s.largestUnit),0,0),time:UY.ZERO};if(s.smallestUnit!==`month`||s.roundingIncrement!==1){let e=dZ(u,{deltaDays:0,hour:0,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0});p=j$(p,GQ(dZ(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=S$(p,`day`);return e===`since`&&(m=o$(m)),m}function V$(e,t,n,r){let i=UZ(n),a=Z(t,X),o=Z(i,X);if(!uQ(a,o))throw RangeError(`cannot compute difference between dates of ${a} and ${o} calendars`);let s=F$(e,$(r),`datetime`,[],`nanosecond`,`hour`),c=Z(t,QJ),l=Z(i,QJ),u=RY(`%Temporal.Duration%`),d;if(DZ(s.largestUnit)!==`date`)d=S$(D$(c,l,s.roundingIncrement,s.smallestUnit,s.roundingMode),s.largestUnit);else{let e=Z(t,aY);if(!hQ(e,Z(i,aY)))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(Y.default.equal(c,l))return new u;d=S$(P$(c,l,e,a,s.largestUnit,s.roundingIncrement,s.smallestUnit,s.roundingMode),`hour`)}return e===`since`&&(d=o$(d)),d}function H$({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,i$(e,t,s,r,i,c)}function U$(e,t){let n=t.addToEpochNs(e);return g$(n),n}function W$(e,t,n,r,i=`constrain`){if($Q(r.date)===0)return U$(e,r.time);let a=vQ(t,e);return U$(yQ(t,dZ(oQ(n,a.isoDate,r.date,i),a.time),`compatible`),r.time)}function G$(e,t,n){let r=IZ(n);e===`subtract`&&(r=o$(r));let i=TZ(wZ(t),wZ(r));if(EZ(i))throw RangeError(`For years, months, or weeks arithmetic, use date arithmetic relative to a starting point`);let a=b$(t),o=b$(r);return S$(C$({years:0,months:0,weeks:0,days:0},a.time.add(o.time)),i)}function K$(e,t,n){let r=IZ(n);e===`subtract`&&(r=o$(r));let i=wZ(r);if(DZ(i)===`date`)throw RangeError(`Duration field ${i} not supported by Temporal.Instant. Try Temporal.ZonedDateTime instead.`);let a=b$(r);return tQ(U$(Z(t,QJ),a.time))}function q$(e,t,n,r){let i=Z(t,X),a=IZ(n);e===`subtract`&&(a=o$(a));let o=x$(a),s=fZ($(r));return GZ(oQ(i,Z(t,$J),o,s),i)}function J$(e,t,n,r){let i=IZ(n);e===`subtract`&&(i=o$(i));let a=fZ($(r)),o=Z(t,X),s=b$(i),c=Z(t,eY),l=H$(c.time,s.time),u=uZ(s.date,l.deltaDays);return v$(u.years,u.months,u.weeks,u.days,0,0,0,0,0,0),qZ(dZ(oQ(o,c.isoDate,u,a),l),o)}function Y$(e,t,n){let r=IZ(n);e===`subtract`&&(r=o$(r));let i=b$(r),{hour:a,minute:o,second:s,millisecond:c,microsecond:l,nanosecond:u}=H$(Z(t,tY),i.time);return ZZ(cZ(a,o,s,c,l,u,`reject`))}function X$(e,t,n,r){let i=IZ(n);e===`subtract`&&(i=o$(i));let a=fZ($(r)),o=QQ(i),s=Z(t,X),c=AZ(s,Z(t,$J),`year-month`);c.day=1;let l=dQ(s,c,`constrain`);if(o<0){let e=oQ(s,l,{months:1},`constrain`);l=n$(e.year,e.month,e.day-1)}let u=x$(i);return d$(l),$Z(fQ(s,AZ(s,oQ(s,l,u,a),`year-month`),a),s)}function Z$(e,t,n,r){let i=IZ(n);e===`subtract`&&(i=o$(i));let a=fZ($(r)),o=Z(t,aY),s=Z(t,X),c=y$(i);return rQ(W$(Z(t,QJ),o,s,c,a),o,s)}function Q$(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=p1(Math.abs(2*i)-t),l=o%2==0,u=VY(n,a),d=i===0?o:HY(o,s,c,l,u);return t*(a===`positive`?d:-d)}function $$(e,t,n,r){let i=LX[n]*t;return function(e,t,n){let r=GJ(e),i=GJ(t),a=Y.default.divide(r,i),o=Y.default.remainder(r,i),s=VY(n,`positive`),c,l;Y.default.lessThan(r,NJ)?(c=Y.default.subtract(a,PJ),l=a):(c=a,l=Y.default.add(a,PJ));let u=JJ(qJ(Y.default.multiply(o,FJ)),i)*(Y.default.lessThan(r,NJ)?-1:1)+0,d=Y.default.equal(o,NJ)?a:HY(c,l,u,KJ(c),s);return Y.default.multiply(d,i)}(e,Y.default.BigInt(i),r)}function e1(e,t,n,r){h$(e);let{year:i,month:a,day:o}=e.isoDate,s=t1(e.time,t,n,r);return dZ(n$(i,a,o+s.deltaDays),s)}function t1({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=LX[s],d=Q$(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 i$(d,0,0,0,0,0);case`minute`:return i$(e,d,0,0,0,0);case`second`:return i$(e,t,d,0,0,0);case`millisecond`:return i$(e,t,n,d,0,0);case`microsecond`:return i$(e,t,n,r,d,0);case`nanosecond`:return i$(e,t,n,r,i,d);default:throw Error(`Invalid unit ${s}`)}}function n1(e,t,n,r){let i=LX[n];return e.round(Y.default.BigInt(i*t),r)}function r1(e,t){let n=LX[t];return e.fdiv(Y.default.BigInt(n))}function i1(e,t){return e.year===t.year?e.month===t.month?e.day===t.day?0:p1(e.day-t.day):p1(e.month-t.month):p1(e.year-t.year)}function a1(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:p1(e.nanosecond-t.nanosecond):p1(e.microsecond-t.microsecond):p1(e.millisecond-t.millisecond):p1(e.second-t.second):p1(e.minute-t.minute):p1(e.hour-t.hour)}function o1(e,t){let n=i1(e.isoDate,t.isoDate);return n===0?a1(e.time,t.time):n}function s1(e){let t=u1(e);return globalThis.BigInt===void 0?t:globalThis.BigInt(t.toString(10))}function c1(e,t){let{quotient:n,remainder:r}=YJ(GJ(e),BJ),i=Y.default.toNumber(n);return t===`floor`&&Y.default.toNumber(r)<0&&--i,t===`ceil`&&Y.default.toNumber(r)>0&&(i+=1),i}function l1(e){if(!Number.isInteger(e))throw RangeError(`epoch milliseconds must be an integer`);return Y.default.multiply(Y.default.BigInt(e),BJ)}function u1(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`?Y.default.BigInt(t.toString(10)):Y.default.BigInt(t)}var d1=(()=>{let e=Y.default.BigInt(Date.now()%1e6);return()=>{let t=Date.now(),n=Y.default.BigInt(t),r=Y.default.add(l1(t),e);return e=Y.default.remainder(n,BJ),Y.default.greaterThan(r,dX)?dX:Y.default.lessThan(r,fX)?fX:r}})();function f1(){return new Intl.DateTimeFormat().resolvedOptions().timeZone}function p1(e){return e<0?-1:e>0?1:e}function $(e){if(e===void 0)return Object.create(null);if(xX(e)&&e!==null)return e;throw TypeError(`Options parameter must be an object, not `+(e===null?`null`:typeof e))}function m1(e,t){let n=Object.create(null);return n[e]=t,n}function h1(e,t,n,r){let i=e[t];if(i!==void 0){if(i=CX(i),!n.includes(i))throw RangeError(`${t} must be one of ${n.join(`, `)}, not ${i}`);return i}if(r===xZ)throw RangeError(`${t} option is required`);return r}function g1(e){let t=_1(e);if(!yX.includes(_1(t)))throw RangeError(`invalid calendar identifier ${t}`);switch(t){case`ethiopic-amete-alem`:return`ethioaa`;case`islamicc`:return`islamic-civil`}return t}function _1(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 v1(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 y1=RegExp(`^${ZY.source}$`),b1=RegExp(`^([+-])([01][0-9]|2[0-3])(?::?([0-5][0-9])(?::?([0-5][0-9])(?:[.,](\\d{1,9}))?)?)?$`);function x1(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 S1(e){return[...e]}function C1(e,t){if(e!==`gregory`&&e!==`iso8601`)return;let n=T1[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 w1(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 T1={};function E1(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 D1(e,t=!1){return`M${`${e}`.padStart(2,`0`)}${t?`L`:``}`}function O1(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`&&l$(r,1,n),t===`constrain`&&(r=s$(r,1,n)),i=D1(r)}else{let e=E1(i);if(i!==D1(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}}T1.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,O1(e))},dateToISO:(e,t)=>sZ(e.year,e.month,e.day,t),monthDayToISOReferenceDate(e,t){let{month:n,day:r}=sZ(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 S1(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}=t$(o,s),{year:o,month:s,day:c}=sZ(o,s,c,a),c+=i+7*r,n$(o,s,c)},dateUntil(e,t,n){let r=-i1(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);!w1(r,e.year+s,e.month,e.day,t);)a=s,s+=r;let c=r;for(i=t$(e.year+a,e.month+c);!w1(r,i.year,i.month,e.day,t);)o=c,c+=r,i=t$(i.year,i.month+r);n===`month`&&(o+=12*a,a=0)}i=t$(e.year+a,e.month+o);let s=c$(i.year,i.month,e.day),c=0,l=w$(t.year,t.month-1,t.day)-w$(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=D1(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+=ZQ(e,n);i.dayOfYear=r}return r.weekOfYear&&(i.weekOfYear=C1(`iso8601`,{year:e,month:t,day:n})),r.daysInMonth&&(i.daysInMonth=ZQ(e,t)),(r.daysInYear||r.inLeapYear)&&(i.inLeapYear=XQ(e),i.daysInYear=i.inLeapYear?366:365),i},getFirstDayOfWeek:()=>1,getMinimalDaysInFirstWeek:()=>4};var k1=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 A1({isoYear:e,isoMonth:t,isoDay:n}){return`${CQ(e)}-${wQ(t)}-${wQ(n)}T00:00Z`}function j1(e,t){return{years:e.year-t.year,months:e.month-t.month,days:e.day-t.day}}k1.objectMap=new WeakMap,k1.MAX_CACHE_ENTRIES=1e3;var M1=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=A1({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}=O1(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`?(l$(i,1,r),l$(a,1,this.maximumMonthLength(e))):(i=s$(i,1,r),a=s$(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=j1(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=j1(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=j1(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:p1(e.day-t.day):p1(e.month-t.month):p1(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 n$(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 w$(i.year,i.month-1,i.day)-w$(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(){}},N1=class extends M1{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?D1(5,!0):D1(t<6?t:t-1):D1(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=E1(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`?(l$(a,1,this.monthsInYear({year:i})),l$(s,1,this.maximumMonthLength({year:i,month:a}))):(a=s$(a,1,this.monthsInYear({year:i})),s=s$(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}}},P1=class extends M1{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}}},F1=class extends P1{constructor(){super(...arguments),this.id=`islamic`}},I1=class extends P1{constructor(){super(...arguments),this.id=`islamic-umalqura`}},L1=class extends P1{constructor(){super(...arguments),this.id=`islamic-tbla`}},R1=class extends P1{constructor(){super(...arguments),this.id=`islamic-civil`}},z1=class extends P1{constructor(){super(...arguments),this.id=`islamic-rgsa`}},B1=class extends P1{constructor(){super(...arguments),this.id=`islamicc`}},V1=class extends M1{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 E1(e)<=6?31:30}estimateIsoDate(e){let{year:t}=this.adjustCalendarDate(e);return{year:t+621,month:1,day:1}}},H1=class extends M1{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 U1(e.year+78)}monthsInYear(){return 12}minimumMonthLength(e){return this.getMonthInfo(e).length}maximumMonthLength(e){return this.getMonthInfo(e).length}maxLengthOfMonthCodeInAnyYear(e){let t=E1(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 n$(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 U1(e){return e%4==0&&(e%100!=0||e%400==0)}var W1=class extends M1{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 U1(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][E1(e)-1]}estimateIsoDate(e){let t=this.adjustCalendarDate(e);return sZ(t.year+this.isoEpoch.year,t.month+this.isoEpoch.month,t.day+this.isoEpoch.day,`constrain`)}},G1=class extends M1{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 U1(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][E1(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:E1(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 sZ(t+i.isoEpoch.year-+!i.hasYearZero,n,r,`constrain`)}},K1=class extends G1{constructor(e,t){super(e,t)}isoToCalendarDate(e){let{year:t,month:n,day:r}=e,i=D1(n),a=t-this.anchorEra.isoEpoch.year+1;return this.completeEraYear({year:a,month:n,monthCode:i,day:r})}},q1={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},J1=class extends W1{constructor(e,t){super(e,t),this.inLeapYear=q1.inLeapYear,this.monthsInYear=q1.monthsInYear,this.minimumMonthLength=q1.minimumMonthLength,this.maximumMonthLength=q1.maximumMonthLength,this.maxLengthOfMonthCodeInAnyYear=q1.maxLengthOfMonthCodeInAnyYear}},Y1=class extends G1{constructor(e,t){super(e,t),this.inLeapYear=q1.inLeapYear,this.monthsInYear=q1.monthsInYear,this.minimumMonthLength=q1.minimumMonthLength,this.maximumMonthLength=q1.maximumMonthLength,this.maxLengthOfMonthCodeInAnyYear=q1.maxLengthOfMonthCodeInAnyYear}},X1=class extends J1{constructor(){super(`ethioaa`,{year:-5492,month:7,day:17})}},Z1=class extends Y1{constructor(){super(`coptic`,[{code:`coptic`,isoEpoch:{year:284,month:8,day:29}},{code:`coptic-inverse`,reverseOf:`coptic`}])}},Q1=class extends Y1{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}}])}},$1=class extends K1{constructor(){super(`roc`,[{code:`roc`,names:[`minguo`],isoEpoch:{year:1912,month:1,day:1}},{code:`roc-inverse`,names:[`before-roc`],reverseOf:`roc`}])}},e0=class extends W1{constructor(){super(`buddhist`,{year:-543,month:1,day:1})}},t0=class extends K1{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}},n0=class extends K1{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}}},r0=class extends M1{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=A1({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=D1(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=D1(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`?(l$(a,1,o),l$(s,1,this.maximumMonthLength())):(a=s$(a,1,o),s=s$(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=D1(+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}}},i0=class extends r0{constructor(){super(...arguments),this.id=`chinese`}},a0=class extends r0{constructor(){super(...arguments),this.id=`dangi`}},o0=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 k1;O1(e,void 0,this.helper.monthsInYear({year:e.year??1972},t))}}dateToISO(e,t){let n=new k1,r=this.helper.calendarToIsoDate(e,t,n);return n.setObject(r),r}monthDayToISOReferenceDate(e,t){let n=new k1,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 S1(t)}dateAdd(e,{years:t,months:n,weeks:r,days:i},a){let o=k1.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 k1.getCacheForObject(l)||new k1(o).setObject(l),l}dateUntil(e,t,n){let r=k1.getCacheForObject(e),i=k1.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=k1.getCacheForObject(e),r=this.helper.isoToCalendarDate(e,n);if(t.dayOfWeek&&(r.dayOfWeek=T1.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=C1(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[N1,V1,Q1,X1,Z1,i0,a0,$1,H1,e0,t0,n0,F1,I1,L1,R1,z1,B1]){let t=new e;T1[t.id]=new o0(t)}LY(`calendarImpl`,(function(e){return T1[e]}));var s0=Intl.DateTimeFormat;function c0(e,t){let n=Z(e,t);return typeof n==`function`&&(n=new s0(Z(e,EY),n(Z(e,DY))),function(e,t,n){let r=AY(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 l0(e){return NY(e,SY)}var u0=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 s0(t,i),o=a.resolvedOptions();if(MY(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,PY(e,DY,t)}else PY(e,DY,i);PY(e,EY,o.locale),PY(e,SY,a),PY(e,CY,o.timeZone),PY(e,TY,o.calendar),PY(e,gY,x0),PY(e,_Y,y0),PY(e,vY,b0),PY(e,yY,v0),PY(e,bY,S0),PY(e,xY,C0);let s=r?i.timeZone:void 0;if(s===void 0)PY(e,wY,o.timeZone);else{let t=CX(s);if(t.startsWith(`−`))throw RangeError(`Unicode minus (U+2212) is not supported in time zone offsets`);PY(e,wY,mQ(t))}})(this,e,t)}get format(){Q(this,l0);let e=p0.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 Q(this,l0),h0.call(this,e,t)}formatToParts(e,...t){return Q(this,l0),m0.call(this,e,...t)}formatRangeToParts(e,t){return Q(this,l0),g0.call(this,e,t)}resolvedOptions(){return Q(this,l0),f0.call(this)}};`formatToParts`in s0.prototype||delete u0.prototype.formatToParts,`formatRangeToParts`in s0.prototype||delete u0.prototype.formatRangeToParts;var d0=function(e=void 0,t=void 0){return new u0(e,t)};function f0(){let e=Z(this,SY).resolvedOptions();return e.timeZone=Z(this,wY),e}function p0(e,...t){let n,r,i=A0(e,this);return i.formatter?(n=i.formatter,r=[c1(i.epochNs,`floor`)]):(n=Z(this,SY),r=[e,...t]),n.format(...r)}function m0(e,...t){let n,r,i=A0(e,this);return i.formatter?(n=i.formatter,r=[c1(i.epochNs,`floor`)]):(n=Z(this,SY),r=[e,...t]),n.formatToParts(...r)}function h0(e,t){if(e===void 0||t===void 0)throw TypeError(`Intl.DateTimeFormat.formatRange requires two values`);let n=O0(e),r=O0(t),i,a=[n,r];if(D0(n)!==D0(r))throw TypeError(`Intl.DateTimeFormat.formatRange accepts two values of the same type`);if(D0(n)){if(!k0(n,r))throw TypeError(`Intl.DateTimeFormat.formatRange accepts two values of the same type`);let{epochNs:e,formatter:t}=A0(n,this),{epochNs:o,formatter:s}=A0(r,this);t&&(i=t,a=[c1(e,`floor`),c1(o,`floor`)])}return i||=Z(this,SY),i.formatRange(...a)}function g0(e,t){if(e===void 0||t===void 0)throw TypeError(`Intl.DateTimeFormat.formatRange requires two values`);let n=O0(e),r=O0(t),i,a=[n,r];if(D0(n)!==D0(r))throw TypeError(`Intl.DateTimeFormat.formatRangeToParts accepts two values of the same type`);if(D0(n)){if(!k0(n,r))throw TypeError(`Intl.DateTimeFormat.formatRangeToParts accepts two values of the same type`);let{epochNs:e,formatter:t}=A0(n,this),{epochNs:o,formatter:s}=A0(r,this);t&&(i=t,a=[c1(e,`floor`),c1(o,`floor`)])}return i||=Z(this,SY),i.formatRangeToParts(...a)}function _0(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 v0(e){let t=_0(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`})),!T0(t)){if(E0(e))throw TypeError(`cannot format Temporal.PlainTime with options [${Object.keys(e)}]`);Object.assign(t,{hour:`numeric`,minute:`numeric`,second:`numeric`})}return t}function y0(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=_0(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(E0(e))throw TypeError(`cannot format PlainYearMonth with options [${Object.keys(e)}]`);Object.assign(n,{year:`numeric`,month:`numeric`})}return n}function b0(e){let t={short:{month:`numeric`,day:`numeric`},medium:{month:`short`,day:`numeric`},long:{month:`long`,day:`numeric`},full:{month:`long`,day:`numeric`}},n=_0(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(E0(e))throw TypeError(`cannot format PlainMonthDay with options [${Object.keys(e)}]`);Object.assign(n,{month:`numeric`,day:`numeric`})}return n}function x0(e){let t=_0(e,{hour:!1,minute:!1,second:!1,dayPeriod:!1,timeZoneName:!1,timeStyle:!1});if(!w0(t)){if(E0(e))throw TypeError(`cannot format PlainDate with options [${Object.keys(e)}]`);Object.assign(t,{year:`numeric`,month:`numeric`,day:`numeric`})}return t}function S0(e){let t=_0(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),!T0(t)&&!w0(t)){if(E0(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 C0(e){let t=e;return T0(t)||w0(t)||(t=Object.assign({},t,{year:`numeric`,month:`numeric`,day:`numeric`,hour:`numeric`,minute:`numeric`,second:`numeric`})),t}function w0(e){return`year`in e||`month`in e||`day`in e||`weekday`in e||`dateStyle`in e||`era`in e}function T0(e){return`hour`in e||`minute`in e||`second`in e||`timeStyle`in e||`dayPeriod`in e||`fractionalSecondDigits`in e}function E0(e){return w0(e)||T0(e)||`dateStyle`in e||`timeStyle`in e||`timeZoneName`in e}function D0(e){return WX(e)||GX(e)||KX(e)||YX(e)||qX(e)||JX(e)||HX(e)}function O0(e){return D0(e)?e:SX(e)}function k0(e,t){return!(!D0(e)||!D0(t)||GX(e)&&!GX(t)||WX(e)&&!WX(t)||KX(e)&&!KX(t)||YX(e)&&!YX(t)||qX(e)&&!qX(t)||JX(e)&&!JX(t)||HX(e)&&!HX(t))}function A0(e,t){if(GX(e)){let n={isoDate:{year:1970,month:1,day:1},time:Z(e,tY)};return{epochNs:yQ(Z(t,CY),n,`compatible`),formatter:c0(t,yY)}}if(qX(e)){let n=Z(e,X),r=Z(t,TY);if(n!==r)throw RangeError(`cannot format PlainYearMonth with calendar ${n} in locale with calendar ${r}`);let i=dZ(Z(e,$J),{deltaDays:0,hour:12,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0});return{epochNs:yQ(Z(t,CY),i,`compatible`),formatter:c0(t,_Y)}}if(JX(e)){let n=Z(e,X),r=Z(t,TY);if(n!==r)throw RangeError(`cannot format PlainMonthDay with calendar ${n} in locale with calendar ${r}`);let i=dZ(Z(e,$J),{deltaDays:0,hour:12,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0});return{epochNs:yQ(Z(t,CY),i,`compatible`),formatter:c0(t,vY)}}if(WX(e)){let n=Z(e,X),r=Z(t,TY);if(n!==`iso8601`&&n!==r)throw RangeError(`cannot format PlainDate with calendar ${n} in locale with calendar ${r}`);let i=dZ(Z(e,$J),{deltaDays:0,hour:12,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0});return{epochNs:yQ(Z(t,CY),i,`compatible`),formatter:c0(t,gY)}}if(KX(e)){let n=Z(e,X),r=Z(t,TY);if(n!==`iso8601`&&n!==r)throw RangeError(`cannot format PlainDateTime with calendar ${n} in locale with calendar ${r}`);let i=Z(e,eY);return{epochNs:yQ(Z(t,CY),i,`compatible`),formatter:c0(t,bY)}}if(YX(e))throw TypeError(`Temporal.ZonedDateTime not supported in DateTimeFormat methods. Use toLocaleString() instead.`);return HX(e)?{epochNs:Z(e,QJ),formatter:c0(t,xY)}:{}}function j0(e){let t=Object.create(null);return t.years=Z(e,oY),t.months=Z(e,sY),t.weeks=Z(e,cY),t.days=Z(e,lY),t.hours=Z(e,uY),t.minutes=Z(e,dY),t.seconds=Z(e,fY),t.milliseconds=Z(e,pY),t.microseconds=Z(e,mY),t.nanoseconds=Z(e,hY),t}u0.prototype.constructor=d0,Object.defineProperty(d0,"prototype",{value:u0.prototype,writable:!1,enumerable:!1,configurable:!1}),d0.supportedLocalesOf=s0.supportedLocalesOf,IY(d0,`Intl.DateTimeFormat`);var{format:M0,formatToParts:N0}=Intl.DurationFormat?.prototype??Object.create(null);function P0(e){Intl.DurationFormat.prototype.resolvedOptions.call(this);let t=j0(IZ(e));return M0.call(this,t)}Intl.DurationFormat?.prototype&&(Intl.DurationFormat.prototype.format=P0,Intl.DurationFormat.prototype.formatToParts=function(e){Intl.DurationFormat.prototype.resolvedOptions.call(this);let t=j0(IZ(e));return N0.call(this,t)}),Object.freeze({__proto__:null,DateTimeFormat:d0,ModifiedIntlDurationFormatPrototypeFormat:P0});var F0=class{constructor(e){if(arguments.length<1)throw TypeError(`missing argument: epochNanoseconds is required`);eQ(this,u1(e))}get epochMilliseconds(){return Q(this,HX),c1(Z(this,QJ),`floor`)}get epochNanoseconds(){return Q(this,HX),s1(Y.default.BigInt(Z(this,QJ)))}add(e){return Q(this,HX),K$(`add`,this,e)}subtract(e){return Q(this,HX),K$(`subtract`,this,e)}until(e,t=void 0){return Q(this,HX),I$(`until`,this,e,t)}since(e,t=void 0){return Q(this,HX),I$(`since`,this,e,t)}round(e){if(Q(this,HX),e===void 0)throw TypeError(`options parameter is required`);let t=typeof e==`string`?m1(`smallestUnit`,e):$(e),n=_Z(t),r=mZ(t,`halfExpand`),i=SZ(t,`smallestUnit`,`time`,xZ);return vZ(n,{hour:24,minute:1440,second:86400,millisecond:864e5,microsecond:864e8,nanosecond:864e11}[i],!0),tQ($$(Z(this,QJ),n,i,r))}equals(e){Q(this,HX);let t=LZ(e),n=Z(this,QJ),r=Z(t,QJ);return Y.default.equal(Y.default.BigInt(n),Y.default.BigInt(r))}toString(e=void 0){Q(this,HX);let t=$(e),n=yZ(t),r=mZ(t,`trunc`),i=SZ(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=mQ(a));let{precision:o,unit:s,increment:c}=bZ(i,n);return DQ(tQ($$(Z(this,QJ),c,s,r)),a,o)}toJSON(){return Q(this,HX),DQ(this,void 0,`auto`)}toLocaleString(e=void 0,t=void 0){return Q(this,HX),new d0(e,t).format(this)}valueOf(){v1(`Instant`)}toZonedDateTimeISO(e){Q(this,HX);let t=mQ(e);return rQ(Z(this,QJ),t,`iso8601`)}static fromEpochMilliseconds(e){return tQ(l1(SX(e)))}static fromEpochNanoseconds(e){return tQ(u1(e))}static from(e){return LZ(e)}static compare(e,t){let n=LZ(e),r=LZ(t),i=Z(n,QJ),a=Z(r,QJ);return Y.default.lessThan(i,a)?-1:+!!Y.default.greaterThan(i,a)}};IY(F0,`Temporal.Instant`);var I0=class{constructor(e,t,n,r=`iso8601`){let i=wX(e),a=wX(t),o=wX(n),s=g1(r===void 0?`iso8601`:OX(r));u$(i,a,o),WZ(this,{year:i,month:a,day:o},s)}get calendarId(){return Q(this,WX),Z(this,X)}get era(){return L0(this,`era`)}get eraYear(){return L0(this,`eraYear`)}get year(){return L0(this,`year`)}get month(){return L0(this,`month`)}get monthCode(){return L0(this,`monthCode`)}get day(){return L0(this,`day`)}get dayOfWeek(){return L0(this,`dayOfWeek`)}get dayOfYear(){return L0(this,`dayOfYear`)}get weekOfYear(){return L0(this,`weekOfYear`)?.week}get yearOfWeek(){return L0(this,`weekOfYear`)?.year}get daysInWeek(){return L0(this,`daysInWeek`)}get daysInMonth(){return L0(this,`daysInMonth`)}get daysInYear(){return L0(this,`daysInYear`)}get monthsInYear(){return L0(this,`monthsInYear`)}get inLeapYear(){return L0(this,`inLeapYear`)}with(e,t=void 0){if(Q(this,WX),!xX(e))throw TypeError(`invalid argument`);XX(e);let n=Z(this,X),r=AZ(n,Z(this,$J));return r=aQ(n,r,jZ(n,e,[`year`,`month`,`monthCode`,`day`],[],`partial`)),GZ(dQ(n,r,fZ($(t))),n)}withCalendar(e){Q(this,WX);let t=cQ(e);return GZ(Z(this,$J),t)}add(e,t=void 0){return Q(this,WX),q$(`add`,this,e,t)}subtract(e,t=void 0){return Q(this,WX),q$(`subtract`,this,e,t)}until(e,t=void 0){return Q(this,WX),L$(`until`,this,e,t)}since(e,t=void 0){return Q(this,WX),L$(`since`,this,e,t)}equals(e){Q(this,WX);let t=NZ(e);return i1(Z(this,$J),Z(t,$J))===0&&uQ(Z(this,X),Z(t,X))}toString(e=void 0){return Q(this,WX),kQ(this,gZ($(e)))}toJSON(){return Q(this,WX),kQ(this)}toLocaleString(e=void 0,t=void 0){return Q(this,WX),new d0(e,t).format(this)}valueOf(){v1(`PlainDate`)}toPlainDateTime(e=void 0){Q(this,WX);let t=BZ(e);return qZ(dZ(Z(this,$J),t),Z(this,X))}toZonedDateTime(e){let t,n;if(Q(this,WX),xX(e)){let r=e.timeZone;r===void 0?t=mQ(e):(t=mQ(r),n=e.plainTime)}else t=mQ(e);let r=Z(this,$J),i;return n===void 0?i=SQ(t,r):(n=zZ(n),i=yQ(t,dZ(r,Z(n,tY)),`compatible`)),rQ(i,t,Z(this,X))}toPlainYearMonth(){Q(this,WX);let e=Z(this,X);return $Z(fQ(e,AZ(e,Z(this,$J)),`constrain`),e)}toPlainMonthDay(){Q(this,WX);let e=Z(this,X);return YZ(pQ(e,AZ(e,Z(this,$J)),`constrain`),e)}static from(e,t=void 0){return NZ(e,t)}static compare(e,t){let n=NZ(e),r=NZ(t);return i1(Z(n,$J),Z(r,$J))}};function L0(e,t){Q(e,WX);let n=Z(e,$J);return kZ(e).isoToDate(n,{[t]:!0})[t]}IY(I0,`Temporal.PlainDate`);var R0=class{constructor(e,t,n,r=0,i=0,a=0,o=0,s=0,c=0,l=`iso8601`){let u=wX(e),d=wX(t),f=wX(n),p=r===void 0?0:wX(r),m=i===void 0?0:wX(i),h=a===void 0?0:wX(a),g=o===void 0?0:wX(o),_=s===void 0?0:wX(s),v=c===void 0?0:wX(c),y=g1(l===void 0?`iso8601`:OX(l));p$(u,d,f,p,m,h,g,_,v),KZ(this,{isoDate:{year:u,month:d,day:f},time:{hour:p,minute:m,second:h,millisecond:g,microsecond:_,nanosecond:v}},y)}get calendarId(){return Q(this,KX),Z(this,X)}get year(){return z0(this,`year`)}get month(){return z0(this,`month`)}get monthCode(){return z0(this,`monthCode`)}get day(){return z0(this,`day`)}get hour(){return B0(this,`hour`)}get minute(){return B0(this,`minute`)}get second(){return B0(this,`second`)}get millisecond(){return B0(this,`millisecond`)}get microsecond(){return B0(this,`microsecond`)}get nanosecond(){return B0(this,`nanosecond`)}get era(){return z0(this,`era`)}get eraYear(){return z0(this,`eraYear`)}get dayOfWeek(){return z0(this,`dayOfWeek`)}get dayOfYear(){return z0(this,`dayOfYear`)}get weekOfYear(){return z0(this,`weekOfYear`)?.week}get yearOfWeek(){return z0(this,`weekOfYear`)?.year}get daysInWeek(){return z0(this,`daysInWeek`)}get daysInYear(){return z0(this,`daysInYear`)}get daysInMonth(){return z0(this,`daysInMonth`)}get monthsInYear(){return z0(this,`monthsInYear`)}get inLeapYear(){return z0(this,`inLeapYear`)}with(e,t=void 0){if(Q(this,KX),!xX(e))throw TypeError(`invalid argument`);XX(e);let n=Z(this,X),r=Z(this,eY),i={...AZ(n,r.isoDate),...r.time};return i=aQ(n,i,jZ(n,e,[`year`,`month`,`monthCode`,`day`],[`hour`,`minute`,`second`,`millisecond`,`microsecond`,`nanosecond`],`partial`)),qZ(PZ(n,i,fZ($(t))),n)}withPlainTime(e=void 0){Q(this,KX);let t=BZ(e);return qZ(dZ(Z(this,eY).isoDate,t),Z(this,X))}withCalendar(e){Q(this,KX);let t=cQ(e);return qZ(Z(this,eY),t)}add(e,t=void 0){return Q(this,KX),J$(`add`,this,e,t)}subtract(e,t=void 0){return Q(this,KX),J$(`subtract`,this,e,t)}until(e,t=void 0){return Q(this,KX),R$(`until`,this,e,t)}since(e,t=void 0){return Q(this,KX),R$(`since`,this,e,t)}round(e){if(Q(this,KX),e===void 0)throw TypeError(`options parameter is required`);let t=typeof e==`string`?m1(`smallestUnit`,e):$(e),n=_Z(t),r=mZ(t,`halfExpand`),i=SZ(t,`smallestUnit`,`time`,xZ,[`day`]),a={day:1,hour:24,minute:60,second:60,millisecond:1e3,microsecond:1e3,nanosecond:1e3}[i];vZ(n,a,a===1);let o=Z(this,eY);return qZ(n===1&&i===`nanosecond`?o:e1(o,n,i,r),Z(this,X))}equals(e){Q(this,KX);let t=FZ(e);return o1(Z(this,eY),Z(t,eY))===0&&uQ(Z(this,X),Z(t,X))}toString(e=void 0){Q(this,KX);let t=$(e),n=gZ(t),r=yZ(t),i=mZ(t,`trunc`),a=SZ(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}=bZ(a,r),l=e1(Z(this,eY),c,s,i);return m$(l),jQ(l,Z(this,X),o,n)}toJSON(){return Q(this,KX),jQ(Z(this,eY),Z(this,X),`auto`)}toLocaleString(e=void 0,t=void 0){return Q(this,KX),new d0(e,t).format(this)}valueOf(){v1(`PlainDateTime`)}toZonedDateTime(e,t=void 0){Q(this,KX);let n=mQ(e),r=pZ($(t));return rQ(yQ(n,Z(this,eY),r),n,Z(this,X))}toPlainDate(){return Q(this,KX),GZ(Z(this,eY).isoDate,Z(this,X))}toPlainTime(){return Q(this,KX),ZZ(Z(this,eY).time)}static from(e,t=void 0){return FZ(e,t)}static compare(e,t){let n=FZ(e),r=FZ(t);return o1(Z(n,eY),Z(r,eY))}};function z0(e,t){Q(e,KX);let n=Z(e,eY).isoDate;return kZ(e).isoToDate(n,{[t]:!0})[t]}function B0(e,t){return Q(e,KX),Z(e,eY).time[t]}IY(R0,`Temporal.PlainDateTime`);var V0=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:EX(e),d=t===void 0?0:EX(t),f=n===void 0?0:EX(n),p=r===void 0?0:EX(r),m=i===void 0?0:EX(i),h=a===void 0?0:EX(a),g=o===void 0?0:EX(o),_=s===void 0?0:EX(s),v=c===void 0?0:EX(c),y=l===void 0?0:EX(l);v$(u,d,f,p,m,h,g,_,v,y),MY(this),PY(this,oY,u),PY(this,sY,d),PY(this,cY,f),PY(this,lY,p),PY(this,uY,m),PY(this,dY,h),PY(this,fY,g),PY(this,pY,_),PY(this,mY,v),PY(this,hY,y)}get years(){return Q(this,UX),Z(this,oY)}get months(){return Q(this,UX),Z(this,sY)}get weeks(){return Q(this,UX),Z(this,cY)}get days(){return Q(this,UX),Z(this,lY)}get hours(){return Q(this,UX),Z(this,uY)}get minutes(){return Q(this,UX),Z(this,dY)}get seconds(){return Q(this,UX),Z(this,fY)}get milliseconds(){return Q(this,UX),Z(this,pY)}get microseconds(){return Q(this,UX),Z(this,mY)}get nanoseconds(){return Q(this,UX),Z(this,hY)}get sign(){return Q(this,UX),QQ(this)}get blank(){return Q(this,UX),QQ(this)===0}with(t){Q(this,UX);let{years:n=Z(this,oY),months:r=Z(this,sY),weeks:i=Z(this,cY),days:a=Z(this,lY),hours:o=Z(this,uY),minutes:s=Z(this,dY),seconds:c=Z(this,fY),milliseconds:l=Z(this,pY),microseconds:u=Z(this,mY),nanoseconds:d=Z(this,hY)}=lZ(t);return new e(n,r,i,a,o,s,c,l,u,d)}negated(){return Q(this,UX),o$(this)}abs(){return Q(this,UX),new e(Math.abs(Z(this,oY)),Math.abs(Z(this,sY)),Math.abs(Z(this,cY)),Math.abs(Z(this,lY)),Math.abs(Z(this,uY)),Math.abs(Z(this,dY)),Math.abs(Z(this,fY)),Math.abs(Z(this,pY)),Math.abs(Z(this,mY)),Math.abs(Z(this,hY)))}add(e){return Q(this,UX),G$(`add`,this,e)}subtract(e){return Q(this,UX),G$(`subtract`,this,e)}round(e){if(Q(this,UX),e===void 0)throw TypeError(`options parameter is required`);let t=wZ(this),n=typeof e==`string`?m1(`smallestUnit`,e):$(e),r=SZ(n,`largestUnit`,`datetime`,void 0,[`auto`]),{plainRelativeTo:i,zonedRelativeTo:a}=CZ(n),o=_Z(n),s=mZ(n,`halfExpand`),c=SZ(n,`smallestUnit`,`datetime`,void 0),l=!0;c||=(l=!1,`nanosecond`);let u=TZ(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(TZ(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&&vZ(o,f,!1),o>1&&DZ(c)===`date`&&r!==c)throw RangeError(`For calendar units with roundingIncrement > 1, use largestUnit = smallestUnit`);if(a){let e=y$(this),t=Z(a,aY),n=Z(a,X),i=Z(a,QJ);return e=P$(i,W$(i,t,n,e),t,n,r,o,c,s),DZ(r)===`date`&&(r=`hour`),S$(e,r)}if(i){let e=b$(this),t=H$({deltaDays:0,hour:0,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0},e.time),n=Z(i,$J),a=Z(i,X),l=oQ(a,n,uZ(e.date,t.deltaDays),`constrain`);return e=N$(dZ(n,{deltaDays:0,hour:0,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0}),dZ(l,t),a,r,o,c,s),S$(e,r)}if(EZ(t))throw RangeError(`a starting point is required for ${t}s balancing`);if(EZ(r))throw RangeError(`a starting point is required for ${r}s balancing`);let p=b$(this);if(c===`day`){let{quotient:e,remainder:t}=p.time.divmod(cX),n=p.date.days+e+r1(t,`day`);n=Q$(n,o,s),p=C$({years:0,months:0,weeks:0,days:n},UY.ZERO)}else p=C$({years:0,months:0,weeks:0,days:0},n1(p.time,o,c,s));return S$(p,r)}total(e){if(Q(this,UX),e===void 0)throw TypeError(`options argument is required`);let t=typeof e==`string`?m1(`unit`,e):$(e),{plainRelativeTo:n,zonedRelativeTo:r}=CZ(t),i=SZ(t,`unit`,`datetime`,xZ);if(r){let e=y$(this),t=Z(r,aY),n=Z(r,X),a=Z(r,QJ);return function(e,t,n,r,i){return DZ(i)===`time`?r1(UY.fromEpochNsDiff(t,e),i):M$(k$(e,t,n,r,i),t,vQ(n,e),n,r,i)}(a,W$(a,t,n,e),t,n,i)}if(n){let e=b$(this),t=H$({deltaDays:0,hour:0,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0},e.time),r=Z(n,$J),a=Z(n,X),o=oQ(a,r,uZ(e.date,t.deltaDays),`constrain`);return function(e,t,n,r){if(o1(e,t)==0)return 0;m$(e),m$(t);let i=O$(e,t,n,r);return r===`nanosecond`?Y.default.toNumber(i.time.totalNs):M$(i,GQ(t),e,null,n,r)}(dZ(r,{deltaDays:0,hour:0,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0}),dZ(o,t),a,i)}let a=wZ(this);if(EZ(a))throw RangeError(`a starting point is required for ${a}s total`);if(EZ(i))throw RangeError(`a starting point is required for ${i}s total`);return r1(b$(this).time,i)}toString(e=void 0){Q(this,UX);let t=$(e),n=yZ(t),r=mZ(t,`trunc`),i=SZ(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}=bZ(i,n);if(o===`nanosecond`&&s===1)return OQ(this,a);let c=wZ(this),l=y$(this),u=n1(l.time,s,o,r);return l=C$(l.date,u),OQ(S$(l,TZ(c,`second`)),a)}toJSON(){return Q(this,UX),OQ(this,`auto`)}toLocaleString(e=void 0,t=void 0){if(Q(this,UX),typeof Intl.DurationFormat==`function`){let n=new Intl.DurationFormat(e,t);return P0.call(n,this)}return console.warn(`Temporal.Duration.prototype.toLocaleString() requires Intl.DurationFormat.`),OQ(this,`auto`)}valueOf(){v1(`Duration`)}static from(e){return IZ(e)}static compare(e,t,n=void 0){let r=IZ(e),i=IZ(t),{plainRelativeTo:a,zonedRelativeTo:o}=CZ($(n));if(Z(r,oY)===Z(i,oY)&&Z(r,sY)===Z(i,sY)&&Z(r,cY)===Z(i,cY)&&Z(r,lY)===Z(i,lY)&&Z(r,uY)===Z(i,uY)&&Z(r,dY)===Z(i,dY)&&Z(r,fY)===Z(i,fY)&&Z(r,pY)===Z(i,pY)&&Z(r,mY)===Z(i,mY)&&Z(r,hY)===Z(i,hY))return 0;let s=wZ(r),c=wZ(i),l=y$(r),u=y$(i);if(o&&(DZ(s)===`date`||DZ(c)===`date`)){let e=Z(o,aY),t=Z(o,X),n=Z(o,QJ),r=W$(n,e,t,l),i=W$(n,e,t,u);return p1(Y.default.toNumber(Y.default.subtract(r,i)))}let d=l.date.days,f=u.date.days;if(EZ(s)||EZ(c)){if(!a)throw RangeError(`A starting point is required for years, months, or weeks comparison`);d=a$(l.date,a),f=a$(u.date,a)}let p=l.time.add24HourDays(d),m=u.time.add24HourDays(f);return p.cmp(m)}};IY(V0,`Temporal.Duration`);var H0=class{constructor(e,t,n=`iso8601`,r=1972){let i=wX(e),a=wX(t),o=g1(n===void 0?`iso8601`:OX(n)),s=wX(r);u$(s,i,a),JZ(this,{year:s,month:i,day:a},o)}get monthCode(){return U0(this,`monthCode`)}get day(){return U0(this,`day`)}get calendarId(){return Q(this,JX),Z(this,X)}with(e,t=void 0){if(Q(this,JX),!xX(e))throw TypeError(`invalid argument`);XX(e);let n=Z(this,X),r=AZ(n,Z(this,$J),`month-day`);return r=aQ(n,r,jZ(n,e,[`year`,`month`,`monthCode`,`day`],[],`partial`)),YZ(pQ(n,r,fZ($(t))),n)}equals(e){Q(this,JX);let t=RZ(e);return i1(Z(this,$J),Z(t,$J))===0&&uQ(Z(this,X),Z(t,X))}toString(e=void 0){return Q(this,JX),MQ(this,gZ($(e)))}toJSON(){return Q(this,JX),MQ(this)}toLocaleString(e=void 0,t=void 0){return Q(this,JX),new d0(e,t).format(this)}valueOf(){v1(`PlainMonthDay`)}toPlainDate(e){if(Q(this,JX),!xX(e))throw TypeError(`argument should be an object`);let t=Z(this,X);return GZ(dQ(t,aQ(t,AZ(t,Z(this,$J),`month-day`),jZ(t,e,[`year`],[],[])),`constrain`),t)}static from(e,t=void 0){return RZ(e,t)}};function U0(e,t){Q(e,JX);let n=Z(e,$J);return kZ(e).isoToDate(n,{[t]:!0})[t]}function W0(e){return vQ(e,d1())}IY(H0,`Temporal.PlainMonthDay`);var G0={instant:()=>tQ(d1()),plainDateTimeISO:(e=f1())=>qZ(W0(mQ(e)),`iso8601`),plainDateISO:(e=f1())=>GZ(W0(mQ(e)).isoDate,`iso8601`),plainTimeISO:(e=f1())=>ZZ(W0(mQ(e)).time),timeZoneId:()=>f1(),zonedDateTimeISO:(e=f1())=>{let t=mQ(e);return rQ(d1(),t,`iso8601`)},[Symbol.toStringTag]:`Temporal.Now`};Object.defineProperty(G0,Symbol.toStringTag,{value:`Temporal.Now`,writable:!1,enumerable:!1,configurable:!0});var K0=class e{constructor(e=0,t=0,n=0,r=0,i=0,a=0){let o=e===void 0?0:wX(e),s=t===void 0?0:wX(t),c=n===void 0?0:wX(n),l=r===void 0?0:wX(r),u=i===void 0?0:wX(i),d=a===void 0?0:wX(a);f$(o,s,c,l,u,d),XZ(this,{hour:o,minute:s,second:c,millisecond:l,microsecond:u,nanosecond:d})}get hour(){return Q(this,GX),Z(this,tY).hour}get minute(){return Q(this,GX),Z(this,tY).minute}get second(){return Q(this,GX),Z(this,tY).second}get millisecond(){return Q(this,GX),Z(this,tY).millisecond}get microsecond(){return Q(this,GX),Z(this,tY).microsecond}get nanosecond(){return Q(this,GX),Z(this,tY).nanosecond}with(t,n=void 0){if(Q(this,GX),!xX(t))throw TypeError(`invalid argument`);XX(t);let r=MZ(t,`partial`),i=MZ(this),{hour:a,minute:o,second:s,millisecond:c,microsecond:l,nanosecond:u}=Object.assign(i,r),d=fZ($(n));return{hour:a,minute:o,second:s,millisecond:c,microsecond:l,nanosecond:u}=cZ(a,o,s,c,l,u,d),new e(a,o,s,c,l,u)}add(e){return Q(this,GX),Y$(`add`,this,e)}subtract(e){return Q(this,GX),Y$(`subtract`,this,e)}until(e,t=void 0){return Q(this,GX),z$(`until`,this,e,t)}since(e,t=void 0){return Q(this,GX),z$(`since`,this,e,t)}round(e){if(Q(this,GX),e===void 0)throw TypeError(`options parameter is required`);let t=typeof e==`string`?m1(`smallestUnit`,e):$(e),n=_Z(t),r=mZ(t,`halfExpand`),i=SZ(t,`smallestUnit`,`time`,xZ);return vZ(n,{hour:24,minute:60,second:60,millisecond:1e3,microsecond:1e3,nanosecond:1e3}[i],!1),ZZ(t1(Z(this,tY),n,i,r))}equals(e){Q(this,GX);let t=zZ(e);return a1(Z(this,tY),Z(t,tY))===0}toString(e=void 0){Q(this,GX);let t=$(e),n=yZ(t),r=mZ(t,`trunc`),i=SZ(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}=bZ(i,n);return AQ(t1(Z(this,tY),s,o,r),a)}toJSON(){return Q(this,GX),AQ(Z(this,tY),`auto`)}toLocaleString(e=void 0,t=void 0){return Q(this,GX),new d0(e,t).format(this)}valueOf(){v1(`PlainTime`)}static from(e,t=void 0){return zZ(e,t)}static compare(e,t){let n=zZ(e),r=zZ(t);return a1(Z(n,tY),Z(r,tY))}};IY(K0,`Temporal.PlainTime`);var q0=class{constructor(e,t,n=`iso8601`,r=1){let i=wX(e),a=wX(t),o=g1(n===void 0?`iso8601`:OX(n)),s=wX(r);u$(i,a,s),QZ(this,{year:i,month:a,day:s},o)}get year(){return J0(this,`year`)}get month(){return J0(this,`month`)}get monthCode(){return J0(this,`monthCode`)}get calendarId(){return Q(this,qX),Z(this,X)}get era(){return J0(this,`era`)}get eraYear(){return J0(this,`eraYear`)}get daysInMonth(){return J0(this,`daysInMonth`)}get daysInYear(){return J0(this,`daysInYear`)}get monthsInYear(){return J0(this,`monthsInYear`)}get inLeapYear(){return J0(this,`inLeapYear`)}with(e,t=void 0){if(Q(this,qX),!xX(e))throw TypeError(`invalid argument`);XX(e);let n=Z(this,X),r=AZ(n,Z(this,$J),`year-month`);return r=aQ(n,r,jZ(n,e,[`year`,`month`,`monthCode`],[],`partial`)),$Z(fQ(n,r,fZ($(t))),n)}add(e,t=void 0){return Q(this,qX),X$(`add`,this,e,t)}subtract(e,t=void 0){return Q(this,qX),X$(`subtract`,this,e,t)}until(e,t=void 0){return Q(this,qX),B$(`until`,this,e,t)}since(e,t=void 0){return Q(this,qX),B$(`since`,this,e,t)}equals(e){Q(this,qX);let t=VZ(e);return i1(Z(this,$J),Z(t,$J))===0&&uQ(Z(this,X),Z(t,X))}toString(e=void 0){return Q(this,qX),NQ(this,gZ($(e)))}toJSON(){return Q(this,qX),NQ(this)}toLocaleString(e=void 0,t=void 0){return Q(this,qX),new d0(e,t).format(this)}valueOf(){v1(`PlainYearMonth`)}toPlainDate(e){if(Q(this,qX),!xX(e))throw TypeError(`argument should be an object`);let t=Z(this,X);return GZ(dQ(t,aQ(t,AZ(t,Z(this,$J),`year-month`),jZ(t,e,[`day`],[],[])),`constrain`),t)}static from(e,t=void 0){return VZ(e,t)}static compare(e,t){let n=VZ(e),r=VZ(t);return i1(Z(n,$J),Z(r,$J))}};function J0(e,t){Q(e,qX);let n=Z(e,$J);return kZ(e).isoToDate(n,{[t]:!0})[t]}IY(q0,`Temporal.PlainYearMonth`);var Y0=d0.prototype.resolvedOptions,X0=class{constructor(e,t,n=`iso8601`){if(arguments.length<1)throw TypeError(`missing argument: epochNanoseconds is required`);let r=u1(e),i=OX(t),{tzName:a,offsetMinutes:o}=oZ(i);if(o===void 0){let e=zQ(a);if(!e)throw RangeError(`unknown time zone ${a}`);i=e.identifier}else i=HQ(o);nQ(this,r,i,g1(n===void 0?`iso8601`:OX(n)))}get calendarId(){return Q(this,YX),Z(this,X)}get timeZoneId(){return Q(this,YX),Z(this,aY)}get year(){return Q0(this,`year`)}get month(){return Q0(this,`month`)}get monthCode(){return Q0(this,`monthCode`)}get day(){return Q0(this,`day`)}get hour(){return $0(this,`hour`)}get minute(){return $0(this,`minute`)}get second(){return $0(this,`second`)}get millisecond(){return $0(this,`millisecond`)}get microsecond(){return $0(this,`microsecond`)}get nanosecond(){return $0(this,`nanosecond`)}get era(){return Q0(this,`era`)}get eraYear(){return Q0(this,`eraYear`)}get epochMilliseconds(){return Q(this,YX),c1(Z(this,QJ),`floor`)}get epochNanoseconds(){return Q(this,YX),s1(Z(this,QJ))}get dayOfWeek(){return Q0(this,`dayOfWeek`)}get dayOfYear(){return Q0(this,`dayOfYear`)}get weekOfYear(){return Q0(this,`weekOfYear`)?.week}get yearOfWeek(){return Q0(this,`weekOfYear`)?.year}get hoursInDay(){Q(this,YX);let e=Z(this,aY),t=Z0(this).isoDate,n=n$(t.year,t.month,t.day+1),r=SQ(e,t),i=SQ(e,n);return r1(UY.fromEpochNsDiff(i,r),`hour`)}get daysInWeek(){return Q0(this,`daysInWeek`)}get daysInMonth(){return Q0(this,`daysInMonth`)}get daysInYear(){return Q0(this,`daysInYear`)}get monthsInYear(){return Q0(this,`monthsInYear`)}get inLeapYear(){return Q0(this,`inLeapYear`)}get offset(){return Q(this,YX),_Q(gQ(Z(this,aY),Z(this,QJ)))}get offsetNanoseconds(){return Q(this,YX),gQ(Z(this,aY),Z(this,QJ))}with(e,t=void 0){if(Q(this,YX),!xX(e))throw TypeError(`invalid zoned-date-time-like`);XX(e);let n=Z(this,X),r=Z(this,aY),i=gQ(r,Z(this,QJ)),a=Z0(this),o={...AZ(n,a.isoDate),...a.time,offset:_Q(i)};o=aQ(n,o,jZ(n,e,[`year`,`month`,`monthCode`,`day`],[`hour`,`minute`,`second`,`millisecond`,`microsecond`,`nanosecond`,`offset`],`partial`));let s=$(t),c=pZ(s),l=hZ(s,`prefer`),u=PZ(n,o,fZ(s)),d=IQ(o.offset);return rQ(HZ(u.isoDate,u.time,`option`,d,r,c,l,!1),r,n)}withPlainTime(e=void 0){Q(this,YX);let t=Z(this,aY),n=Z(this,X),r=Z0(this).isoDate,i;return i=e===void 0?SQ(t,r):yQ(t,dZ(r,Z(zZ(e),tY)),`compatible`),rQ(i,t,n)}withTimeZone(e){Q(this,YX);let t=mQ(e);return rQ(Z(this,QJ),t,Z(this,X))}withCalendar(e){Q(this,YX);let t=cQ(e);return rQ(Z(this,QJ),Z(this,aY),t)}add(e,t=void 0){return Q(this,YX),Z$(`add`,this,e,t)}subtract(e,t=void 0){return Q(this,YX),Z$(`subtract`,this,e,t)}until(e,t=void 0){return Q(this,YX),V$(`until`,this,e,t)}since(e,t=void 0){return Q(this,YX),V$(`since`,this,e,t)}round(e){if(Q(this,YX),e===void 0)throw TypeError(`options parameter is required`);let t=typeof e==`string`?m1(`smallestUnit`,e):$(e),n=_Z(t),r=mZ(t,`halfExpand`),i=SZ(t,`smallestUnit`,`time`,xZ,[`day`]),a={day:1,hour:24,minute:60,second:60,millisecond:1e3,microsecond:1e3,nanosecond:1e3}[i];if(vZ(n,a,a===1),i===`nanosecond`&&n===1)return rQ(Z(this,QJ),Z(this,aY),Z(this,X));let o=Z(this,aY),s=Z(this,QJ),c=Z0(this),l;if(i===`day`){let e=c.isoDate,t=n$(e.year,e.month,e.day+1),n=SQ(o,e),i=SQ(o,t),a=Y.default.subtract(i,n);l=UY.fromEpochNsDiff(s,n).round(a,r).addToEpochNs(n)}else{let e=e1(c,n,i,r),t=gQ(o,s);l=HZ(e.isoDate,e.time,`option`,t,o,`compatible`,`prefer`,!1)}return rQ(l,o,Z(this,X))}equals(e){Q(this,YX);let t=UZ(e),n=Z(this,QJ),r=Z(t,QJ);return!!Y.default.equal(Y.default.BigInt(n),Y.default.BigInt(r))&&!!hQ(Z(this,aY),Z(t,aY))&&uQ(Z(this,X),Z(t,X))}toString(e=void 0){Q(this,YX);let t=$(e),n=gZ(t),r=yZ(t),i=function(e){return h1(e,`offset`,[`auto`,`never`],`auto`)}(t),a=mZ(t,`trunc`),o=SZ(t,`smallestUnit`,`time`,void 0);if(o===`hour`)throw RangeError(`smallestUnit must be a time unit other than "hour"`);let s=function(e){return h1(e,`timeZoneName`,[`auto`,`never`,`critical`],`auto`)}(t),{precision:c,unit:l,increment:u}=bZ(o,r);return PQ(this,c,n,s,i,{unit:l,increment:u,roundingMode:a})}toLocaleString(e=void 0,t=void 0){Q(this,YX);let 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=Z(this,aY),FQ(r.timeZone))throw RangeError(`toLocaleString does not currently support offset time zones`);let i=new d0(e,r),a=Y0.call(i).calendar,o=Z(this,X);if(o!==`iso8601`&&a!==`iso8601`&&!uQ(a,o))throw RangeError(`cannot format ZonedDateTime with calendar ${o} in locale with calendar ${a}`);return i.format(tQ(Z(this,QJ)))}toJSON(){return Q(this,YX),PQ(this,`auto`)}valueOf(){v1(`ZonedDateTime`)}startOfDay(){Q(this,YX);let e=Z(this,aY);return rQ(SQ(e,Z0(this).isoDate),e,Z(this,X))}getTimeZoneTransition(e){Q(this,YX);let t=Z(this,aY);if(e===void 0)throw TypeError(`options parameter is required`);let n=h1(typeof e==`string`?m1(`direction`,e):$(e),`direction`,[`next`,`previous`],xZ);if(n===void 0)throw TypeError(`direction option is required`);if(FQ(t)||t===`UTC`)return null;let r=Z(this,QJ),i=n===`next`?qQ(t,r):JQ(t,r);return i===null?null:rQ(i,t,Z(this,X))}toInstant(){return Q(this,YX),tQ(Z(this,QJ))}toPlainDate(){return Q(this,YX),GZ(Z0(this).isoDate,Z(this,X))}toPlainTime(){return Q(this,YX),ZZ(Z0(this).time)}toPlainDateTime(){return Q(this,YX),qZ(Z0(this),Z(this,X))}static from(e,t=void 0){return UZ(e,t)}static compare(e,t){let n=UZ(e),r=UZ(t),i=Z(n,QJ),a=Z(r,QJ);return Y.default.lessThan(Y.default.BigInt(i),Y.default.BigInt(a))?-1:+!!Y.default.greaterThan(Y.default.BigInt(i),Y.default.BigInt(a))}};function Z0(e){return vQ(Z(e,aY),Z(e,QJ))}function Q0(e,t){Q(e,YX);let n=Z0(e).isoDate;return kZ(e).isoToDate(n,{[t]:!0})[t]}function $0(e,t){return Q(e,YX),Z0(e).time[t]}IY(X0,`Temporal.ZonedDateTime`);var e2=Object.freeze({__proto__:null,Duration:V0,Instant:F0,Now:G0,PlainDate:I0,PlainDateTime:R0,PlainMonthDay:H0,PlainTime:K0,PlainYearMonth:q0,ZonedDateTime:X0});(class{toTemporalInstant(){return tQ(l1(Date.prototype.valueOf.call(this)))}}).prototype.toTemporalInstant;var t2=[F0,I0,R0,V0,H0,K0,q0,X0];for(let e of t2){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 n2(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(`Could not resolve the selected timezone.`);return t.value};return`${r(`year`)}-${r(`month`)}-${r(`day`)}T${r(`hour`)}:${r(`minute`)}`}function r2(e,t){return n2(new Date(e),t)}function i2(e,t){if(!/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}$/.test(e))throw Error(`Choose a valid date and time for the one-off run.`);let n=e2.PlainDateTime.from(e,{overflow:`reject`}),r=n.toZonedDateTime(t,{disambiguation:`compatible`});if(!n.equals(r.toPlainDateTime()))throw Error(`This local time does not exist in the selected timezone. Choose another time.`);return r.toInstant().toString({smallestUnit:`millisecond`})}function a2(e,t){return new Intl.DateTimeFormat(void 0,{timeZone:t,dateStyle:`medium`,timeStyle:`short`}).format(new Date(e))}var o2=[[1,`Mon`],[2,`Tue`],[3,`Wed`],[4,`Thu`],[5,`Fri`],[6,`Sat`],[0,`Sun`]];function s2({templates:e,pending:t,onCreated:n,onError:r,editing:i,onCancel:a,onBusy:o}){let{api:s}=I(),[c,l]=(0,m.useState)(i?.name??``),[u,d]=(0,m.useState)(i?.templateId??``),[f,p]=(0,m.useState)(i?.cadence.kind??`daily`),[g,_]=(0,m.useState)(i?.cadence.kind===`once`?r2(i.cadence.at,i.timezone):``),[v,y]=(0,m.useState)(i&&i.cadence.kind!==`once`?i.cadence.time:`09:00`),[b,x]=(0,m.useState)(i?.cadence.kind===`weekly`?i.cadence.days:[1,3,5]),[S,C]=(0,m.useState)(()=>i?.timezone??(Intl.DateTimeFormat().resolvedOptions().timeZone||`UTC`)),[w,T]=(0,m.useState)(i?.missedPolicy??`skip`),[E,D]=(0,m.useState)(i?.spendLimitCents?.toString()??``),[O,ee]=(0,m.useState)(()=>(i?.items??[]).map(e=>({id:crypto.randomUUID(),title:e.title,values:Object.entries(e.values).map(([e,t])=>({id:crypto.randomUUID(),name:e,value:t}))}))),[k,A]=(0,m.useState)(!1),[j,M]=(0,m.useState)(!1),N=(0,m.useRef)(!1),P=(0,m.useRef)(null),F=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),te=F.find(e=>e.id===u);async function ne(e){if(e.preventDefault(),!(N.current||t)){if(!te&&!P.current){r(`Choose a template before saving the schedule.`);return}if(f===`weekly`&&b.length===0){r(`Choose at least one weekday for a weekly schedule.`);return}N.current=!0,A(!0),o(!0);try{if(!P.current){if(!te)throw Error(`Choose a template before saving the schedule.`);let e=S.trim();if(!pJ(e))throw Error(`Choose a valid IANA timezone, such as Europe/Tirane.`);let t=f===`once`?{kind:f,at:i2(g,e)}:f===`weekly`?{kind:f,time:v,days:b}:{kind:f,time:v},n=E.trim()===``?null:Number(E);if(n!==null&&(!Number.isInteger(n)||n<0))throw Error(`Spend limit must be a non-negative whole number of cents.`);let r={id:i?.id??crypto.randomUUID(),name:c.trim(),templateId:te.id,templateVersion:i?.templateId===u?i.templateVersion:te.version,cadence:t,timezone:e,missedPolicy:w,overlapPolicy:`skip`,spendLimitCents:n,items:c2(O)};P.current=i?{...r,baseVersion:i.version,mutationId:crypto.randomUUID()}:r}let e=P.current,{id:t,...a}=e,o=`mutationId`in a?await AJ(s,t,a):await kJ(s,e);if(!o.ok){P.current=null,M(!1),r(o.reason===`conflict`?`${o.message} Your inputs are kept. Cancel editing and reopen Edit to load the latest saved version.`:o.message);return}P.current=null,M(!1),l(``),ee([]),n()}catch(e){M(P.current!==null),r(e instanceof Error?e.message:`Could not save the schedule. Try again.`)}finally{N.current=!1,A(!1),o(P.current!==null)}}}return(0,h.jsxs)(`section`,{"aria-labelledby":`new-schedule-heading`,className:`rounded-panel border border-line bg-panel p-4 sm:p-5`,children:[(0,h.jsx)(`h2`,{id:`new-schedule-heading`,className:`font-semibold`,children:i?`Edit schedule`:`New schedule`}),(0,h.jsx)(`p`,{className:`mt-1 text-small text-ink2`,children:`Schedules use the selected template version and never include uploaded media.`}),(0,h.jsxs)(`form`,{onSubmit:e=>void ne(e),children:[(0,h.jsxs)(`fieldset`,{disabled:k||j||t,className:`mt-4 grid gap-4 md:grid-cols-2`,children:[(0,h.jsxs)(`label`,{className:`space-y-1`,htmlFor:`schedule-name`,children:[(0,h.jsx)(`span`,{children:`Name`}),(0,h.jsx)(cM,{id:`schedule-name`,required:!0,value:c,onChange:e=>l(e.target.value),placeholder:`Monday morning stories`})]}),(0,h.jsxs)(`label`,{className:`space-y-1`,htmlFor:`schedule-template`,children:[(0,h.jsx)(`span`,{children:`Template`}),(0,h.jsxs)(`select`,{id:`schedule-template`,required:!0,value:u,onChange:e=>d(e.target.value),className:`h-8 w-full rounded-control border border-line2 bg-panel2 px-2 text-small`,disabled:F.length===0,children:[(0,h.jsx)(`option`,{value:``,children:`Choose a template`}),F.map(e=>(0,h.jsxs)(`option`,{value:e.id,children:[e.name,` · v`,e.version]},e.id))]})]}),(0,h.jsxs)(`label`,{className:`space-y-1`,htmlFor:`schedule-cadence`,children:[(0,h.jsx)(`span`,{children:`Cadence`}),(0,h.jsxs)(`select`,{id:`schedule-cadence`,value:f,onChange:e=>p(e.target.value===`once`?`once`:e.target.value===`weekly`?`weekly`:`daily`),className:`h-8 w-full rounded-control border border-line2 bg-panel2 px-2 text-small`,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`})]})]}),f===`once`?(0,h.jsxs)(`label`,{className:`space-y-1`,htmlFor:`schedule-once`,children:[(0,h.jsx)(`span`,{children:`Run at`}),(0,h.jsx)(cM,{id:`schedule-once`,required:!0,type:`datetime-local`,value:g,onChange:e=>_(e.target.value)})]}):(0,h.jsxs)(`label`,{className:`space-y-1`,htmlFor:`schedule-time`,children:[(0,h.jsx)(`span`,{children:`Local time`}),(0,h.jsx)(cM,{id:`schedule-time`,required:!0,type:`time`,value:v,onChange:e=>y(e.target.value)})]}),f===`weekly`?(0,h.jsxs)(`fieldset`,{className:`space-y-2`,children:[(0,h.jsx)(`legend`,{children:`Weekdays`}),(0,h.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:o2.map(([e,t])=>(0,h.jsxs)(`label`,{className:`inline-flex items-center gap-1 text-small`,children:[(0,h.jsx)(`input`,{type:`checkbox`,checked:b.includes(e),onChange:t=>x(n=>t.target.checked?[...n,e]:n.filter(t=>t!==e))}),t]},e))})]}):(0,h.jsx)(`div`,{}),(0,h.jsxs)(`label`,{className:`space-y-1`,htmlFor:`schedule-timezone`,children:[(0,h.jsx)(`span`,{children:`Timezone`}),(0,h.jsx)(cM,{id:`schedule-timezone`,value:S,onChange:e=>C(e.target.value),placeholder:`Europe/Tirane`}),(0,h.jsx)(`small`,{className:`block text-ink3`,children:f===`once`?`IANA zone; the one-off instant is calculated here. Repeated clock times use the earlier occurrence; nonexistent spring-forward times are refused.`:`IANA zone; next run is calculated here. Repeated clock times use the earlier occurrence; nonexistent spring-forward times move forward by the gap.`})]}),(0,h.jsxs)(`label`,{className:`space-y-1`,htmlFor:`schedule-missed`,children:[(0,h.jsx)(`span`,{children:`Missed run`}),(0,h.jsxs)(`select`,{id:`schedule-missed`,value:w,onChange:e=>T(e.target.value===`run-once`?`run-once`:`skip`),className:`h-8 w-full rounded-control border border-line2 bg-panel2 px-2 text-small`,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.jsxs)(`label`,{className:`space-y-1`,htmlFor:`schedule-spend`,children:[(0,h.jsx)(`span`,{children:`Spend ceiling (cents, optional)`}),(0,h.jsx)(cM,{id:`schedule-spend`,inputMode:`numeric`,value:E,onChange:e=>D(e.target.value),placeholder:`1000`})]}),(0,h.jsx)(l2,{variants:O,onChange:ee})]}),(0,h.jsxs)(`div`,{className:`mt-4 flex gap-2`,children:[(0,h.jsx)(B,{type:`submit`,disabled:t||k||F.length===0&&!j,children:k?`Saving…`:j?`Retry save`:i?`Save changes`:`Save schedule`}),i?(0,h.jsx)(B,{type:`button`,disabled:k||j,onClick:a,children:`Cancel editing`}):null]})]})]})}function c2(e){return e.map(e=>{let t=e.values.map(e=>e.name.trim());if(t.some(e=>!e)||new Set(t).size!==t.length)throw Error(`Each variant needs non-empty, unique keyword names.`);return{title:e.title,values:Object.fromEntries(e.values.map(({name:e,value:t})=>[e.trim(),t]))}})}function l2({variants:e,onChange:t}){let n=n=>t(e.map(e=>e.id===n.id?n:e)),r=`min-h-10 w-full rounded-control border border-line2 bg-panel2 px-[10px] py-2 text-small`;return(0,h.jsxs)(`fieldset`,{className:`space-y-3 md:col-span-2`,children:[(0,h.jsx)(`legend`,{children:`Keyword variants (optional)`}),(0,h.jsx)(`p`,{className:`text-small text-ink3`,children:`The base template run is always included. Add up to 49 variants.`}),e.map((i,a)=>(0,h.jsxs)(`fieldset`,{className:`space-y-3 rounded-control border border-line p-3`,children:[(0,h.jsxs)(`legend`,{children:[`Variant `,a+1]}),(0,h.jsxs)(`label`,{className:`block space-y-1`,children:[(0,h.jsxs)(`span`,{children:[`Variant `,a+1,` title`]}),(0,h.jsx)(`textarea`,{required:!0,maxLength:200,rows:1,className:r,value:i.title,onChange:e=>n({...i,title:e.target.value})})]}),i.values.map((e,t)=>(0,h.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:[(0,h.jsxs)(`label`,{className:`block space-y-1`,children:[(0,h.jsxs)(`span`,{children:[`Variant `,a+1,` keyword `,t+1,` name`]}),(0,h.jsx)(`textarea`,{required:!0,maxLength:200,rows:1,className:r,value:e.name,onChange:t=>n({...i,values:i.values.map(n=>n.id===e.id?{...n,name:t.target.value}:n)})})]}),(0,h.jsxs)(`label`,{className:`block space-y-1`,children:[(0,h.jsxs)(`span`,{children:[`Variant `,a+1,` keyword `,t+1,` value`]}),(0,h.jsx)(`textarea`,{maxLength:1e4,rows:2,className:r,value:e.value,onChange:t=>n({...i,values:i.values.map(n=>n.id===e.id?{...n,value:t.target.value}:n)})})]}),(0,h.jsxs)(B,{type:`button`,className:`min-h-10`,onClick:()=>n({...i,values:i.values.filter(t=>t.id!==e.id)}),children:[`Remove keyword `,t+1,` from variant `,a+1]})]},e.id)),(0,h.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,h.jsxs)(B,{type:`button`,className:`min-h-10`,onClick:()=>n({...i,values:[...i.values,{id:crypto.randomUUID(),name:``,value:``}]}),children:[`Add keyword to variant `,a+1]}),(0,h.jsxs)(B,{type:`button`,className:`min-h-10`,onClick:()=>t(e.filter(e=>e.id!==i.id)),children:[`Remove variant `,a+1]})]})]},i.id)),(0,h.jsx)(B,{type:`button`,className:`min-h-10`,disabled:e.length>=49,onClick:()=>t([...e,{id:crypto.randomUUID(),title:``,values:[]}]),children:`Add variant`})]})}function u2(){let{api:e}=I(),t=_(),n=nt(DJ(e)),r=nt(mq(e)),[i,a]=(0,m.useState)(null),[o,s]=(0,m.useState)(null),[c,l]=(0,m.useState)(null),[u,d]=(0,m.useState)(!1),f=(0,m.useRef)(!1),p=n.data?.filter(e=>e.deletedAt===null)??[],g=n.data?.filter(e=>e.deletedAt!==null)??[],v=it({onError:e=>a(e.message),onSettled:async()=>{f.current=!1,await t.invalidateQueries({queryKey:EJ})},mutationFn:async e=>e(),onSuccess:async e=>{if(!e.ok){a(e.message);return}a(null)}}),y=e=>{f.current||(f.current=!0,s(null),a(null),v.mutate(e))};return(0,h.jsxs)(`div`,{className:`mx-auto max-w-[1200px] space-y-6`,children:[(0,h.jsxs)(`div`,{children:[(0,h.jsxs)(`h1`,{className:`flex items-center gap-2 text-title font-bold tracking-[-0.01em]`,children:[(0,h.jsx)(KA,{"aria-hidden":`true`,className:`size-6 text-lamp-run`}),`Schedules`]}),(0,h.jsx)(`p`,{className:`mt-2 max-w-[70ch] text-body text-ink2`,children:`Run a saved template on this machine at a predictable local time. Each schedule keeps a durable history and creates fresh projects, so changing a template never rewrites an old run.`})]}),(0,h.jsx)(s2,{onBusy:d,editing:c,onCancel:()=>{l(null),a(null)},templates:r.data??[],pending:v.isPending,onCreated:()=>{s(c?`Schedule updated.`:`Schedule saved. It will run automatically while Slopify is open.`),l(null),a(null),t.invalidateQueries({queryKey:EJ})},onError:e=>{a(e),t.invalidateQueries({queryKey:EJ})}},c?.id??`new`),r.data?.length===0?(0,h.jsxs)(`p`,{className:`text-small text-ink2`,children:[`Save a template in`,` `,(0,h.jsx)(`a`,{className:`underline`,href:`/templates`,children:`Templates`}),` `,`before creating a schedule.`]}):null,r.error?(0,h.jsx)(`p`,{role:`alert`,children:r.error.message}):null,n.error?(0,h.jsx)(`p`,{role:`alert`,className:`text-red`,children:n.error.message}):null,i?(0,h.jsx)(`p`,{role:`alert`,className:`text-red`,children:i}):null,o?(0,h.jsx)(`p`,{role:`status`,className:`text-lamp-run`,children:o}):null,n.data&&p.length===0?(0,h.jsx)(Pj,{children:(0,h.jsx)(`p`,{className:`px-4 py-6 text-ink2`,children:g.length===0?`No schedules yet. Your first one can be a one-off run or a recurring series.`:`No active schedules. Create one above or review deleted history below.`})}):null,(0,h.jsx)(`section`,{className:`space-y-3`,"aria-label":`Saved schedules`,children:p.map(e=>(0,h.jsx)(d2,{schedule:e,pending:v.isPending||u||c!==null,onAction:y,error:i,onEdit:()=>{l(e),a(null),window.scrollTo?.({top:0})}},e.id))}),g.length>0?(0,h.jsxs)(`details`,{className:`rounded-panel border border-line bg-panel p-4`,children:[(0,h.jsxs)(`summary`,{className:`cursor-pointer font-semibold`,children:[`Deleted schedule history · `,g.length]}),(0,h.jsx)(`p`,{className:`mt-2 text-small text-ink2`,children:`Deleted schedules cannot run again. Their occurrence history remains available here.`}),(0,h.jsx)(`section`,{className:`mt-4 space-y-3`,"aria-label":`Deleted schedules`,children:g.map(e=>(0,h.jsx)(d2,{schedule:e,pending:!1,onAction:y,error:null,onEdit:()=>void 0},e.id))})]}):null]})}function d2({schedule:e,pending:t,onAction:n,onEdit:r,error:i}){let{api:a}=I(),[o,s]=(0,m.useState)(!1),[c,l]=(0,m.useState)(null),u=nt({queryKey:[`schedule`,e.id],queryFn:async()=>{let t=await OJ(a,e.id);if(!t.ok)throw Error(t.message);return t.value},enabled:o,refetchInterval:3e4}),d=e.cadence.kind===`once`?`One time`:e.cadence.kind===`daily`?`Daily at ${e.cadence.time}`:`Weekly at ${e.cadence.time}`;return(0,h.jsxs)(`article`,{className:`rounded-panel border border-line bg-panel p-4`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,h.jsxs)(`div`,{className:`min-w-0`,children:[(0,h.jsx)(`h2`,{className:`break-words font-semibold`,children:e.name}),(0,h.jsxs)(`p`,{className:`text-small text-ink2`,children:[d,` · `,e.timezone,` · `,e.items.length,` variant`,e.items.length===1?``:`s`]}),(0,h.jsxs)(`p`,{className:`mt-1 text-small text-ink3`,children:[e.deletedAt===null?e.nextRunAt===null?`No future run`:`Next: ${a2(e.nextRunAt,e.timezone)}`:`Deleted: ${a2(e.deletedAt,e.timezone)}`,` `,`· `,(0,h.jsx)(`span`,{className:`capitalize`,children:e.status})]}),(0,h.jsxs)(`p`,{className:`text-small text-ink2`,children:[`Missed runs: `,e.missedPolicy===`skip`?`skip`:`run once on reopening`,`. Overlap: skip. Spend ceiling:`,` `,e.spendLimitCents===null?`not set`:`${e.spendLimitCents} cents`,`.`]})]}),(0,h.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[e.deletedAt===null&&(e.status===`active`||e.status===`paused`)?(0,h.jsx)(B,{type:`button`,disabled:t,onClick:r,children:`Edit`}):null,e.deletedAt===null&&e.status===`active`?(0,h.jsxs)(B,{type:`button`,variant:`ghost`,disabled:t,onClick:()=>n(()=>jJ(a,e.id,`pause`,e.version)),children:[(0,h.jsx)(rj,{"aria-hidden":`true`,className:`size-4`}),`Pause`]}):null,e.deletedAt===null&&e.status===`paused`?(0,h.jsxs)(B,{type:`button`,variant:`ghost`,disabled:t,onClick:()=>n(()=>jJ(a,e.id,`resume`,e.version)),children:[(0,h.jsx)(ij,{"aria-hidden":`true`,className:`size-4`}),`Resume`]}):null,e.deletedAt===null&&(e.status===`active`||e.status===`paused`)?(0,h.jsxs)(B,{type:`button`,variant:`ghost`,disabled:t,onClick:()=>l(`cancel`),children:[(0,h.jsx)(sj,{"aria-hidden":`true`,className:`size-4`}),`Cancel`]}):null,(0,h.jsxs)(B,{type:`button`,variant:`ghost`,onClick:()=>s(e=>!e),"aria-expanded":o,children:[o?(0,h.jsx)(ZA,{"aria-hidden":`true`,className:`size-4`}):(0,h.jsx)(JA,{"aria-hidden":`true`,className:`size-4`}),`History`]}),e.deletedAt===null&&(e.status===`canceled`||e.status===`completed`)?(0,h.jsx)(B,{type:`button`,variant:`ghost`,disabled:t,onClick:()=>l(`delete`),children:`Delete`}):null]})]}),(0,h.jsx)(Nj,{open:c!==null,title:c===`delete`?`Delete schedule?`:`Cancel schedule?`,consequence:(c===`delete`?`Removes this schedule from the active list. Its run history is kept.`:`Stops future scheduled runs. Existing projects and run history are kept.`)+(i?` ${i}`:``),verb:c===`delete`?`Delete schedule`:`Cancel schedule`,dismiss:`Keep schedule`,pending:t,onCancel:()=>{t||l(null)},onConfirm:()=>{let t=c;t&&n(async()=>{let n=t===`delete`?await MJ(a,e.id,e.version):await jJ(a,e.id,`cancel`,e.version);return n.ok&&l(null),n})}}),o?(0,h.jsx)(`div`,{className:`mt-4 border-t border-line pt-3`,children:u.isPending?(0,h.jsx)(`p`,{className:`text-small text-ink3`,children:`Loading history…`}):u.error?(0,h.jsx)(`p`,{className:`text-small text-red`,children:u.error.message}):u.data?.runs.length===0?(0,h.jsx)(`p`,{className:`text-small text-ink3`,children:`No runs yet.`}):(0,h.jsx)(`ul`,{className:`space-y-2`,children:u.data?.runs.map(t=>(0,h.jsxs)(`li`,{className:`flex flex-wrap justify-between gap-2 text-small`,children:[(0,h.jsxs)(`span`,{className:`capitalize`,children:[t.status,` · `,a2(t.scheduledFor,e.timezone)]}),t.error?(0,h.jsx)(`span`,{className:`text-ink3`,children:t.error}):t.projectIds.length>0?(0,h.jsx)(`span`,{className:`flex flex-wrap gap-x-3 gap-y-1 text-ink3`,children:t.projectIds.map((e,t)=>(0,h.jsxs)(sa,{className:`underline hover:text-ink`,to:`/projects/$projectId`,params:{projectId:e},children:[`Project `,t+1]},e))}):(0,h.jsx)(`span`,{className:`text-ink3`,children:`No projects`})]},t.id))})}):null]})}function f2(){let{api:e}=I(),t=_(),n=nt({queryKey:[`catalogue`],queryFn:async()=>eo(await e.fetch(`${e.origin}/api/providers/catalogue`)),refetchInterval:3e4}),r=it({mutationFn:async()=>eo(await e.fetch(`${e.origin}/api/providers/catalogue/refresh`,{method:`POST`})),onSuccess:e=>{t.setQueryData([`catalogue`],e),t.invalidateQueries({queryKey:[`provider-models`]})}});return(0,h.jsxs)(`section`,{className:`rounded-panel border border-line bg-panel p-4`,children:[(0,h.jsx)(`h2`,{className:`engraved text-ink3`,children:`Models and request limits`}),(0,h.jsx)(`p`,{className:`my-2 text-body text-ink2`,children:`The catalogue lists supported text, image and speech models, their prices and request limits. Local YAML edits load automatically; model pickers refresh every 30 seconds.`}),n.data?.path?(0,h.jsx)(`p`,{className:`my-2 break-all font-mono text-small`,children:n.data.path}):null,(0,h.jsxs)(`p`,{className:`mb-3 text-small text-ink2`,children:[`Verified `,n.data?.updatedAt??`date unavailable`,`. Refresh replaces your local file with the published catalogue and saves the previous file alongside it.`]}),(0,h.jsx)(B,{disabled:r.isPending||!n.data?.path,onClick:()=>r.mutate(),children:r.isPending?`Refreshing…`:`Refresh published catalogue`}),n.data?.warning||n.error||r.error?(0,h.jsx)(`p`,{role:`alert`,className:`mt-2 text-body text-red`,children:r.error?.message??n.error?.message??n.data?.warning}):null,r.isSuccess?(0,h.jsx)(`p`,{role:`status`,className:`mt-2 text-small text-green`,children:`Catalogue updated.`}):null]})}function p2({provider:e,readiness:t}){let{api:n}=I(),r=_(),i=(0,m.useId)(),a=(0,m.useId)(),o=(0,m.useId)(),s=(0,m.useId)(),c=(0,m.useId)(),[l,u]=(0,m.useState)(void 0),[d,f]=(0,m.useState)(!1),p=e.cliPath?.configured??null,g=e.cliPath?.managedOnHost===!0,v=e.id===`claude-code`?`claude`:e.id===`codex-image`?`codex`:e.id,y=e.cliPath?.command??v,b=l??p??``,x=Rk(t),S=it({mutationFn:t=>xo(n,e.id,t),onMutate:()=>f(!1),onSuccess:async e=>{r.setQueryData(V.providers,t=>t?{...t,providers:t.providers.map(t=>t.id===e.id?e:t)}:void 0),u(void 0),f(!0),await r.invalidateQueries({queryKey:V.providers})}});return(0,m.useEffect)(()=>{if(!d)return;let e=setTimeout(()=>f(!1),Qj);return()=>clearTimeout(e)},[d]),(0,h.jsxs)(`div`,{"data-ready":x,className:`grid gap-[14px] border-t border-line px-4 py-[14px] first:border-t-0 sm:grid-cols-[140px_1fr]`,children:[(0,h.jsx)(`span`,{id:i,className:z(`font-semibold`,x?`text-ink`:`text-ink3`),children:e.displayName}),(0,h.jsxs)(`div`,{className:`min-w-0`,children:[(0,h.jsxs)(`p`,{className:`flex flex-wrap items-center gap-2 text-small text-ink2`,"aria-live":`polite`,children:[(0,h.jsx)(mK,{state:x?`done`:`pending`}),(0,h.jsx)(`span`,{children:m2(t,p)})]}),(0,h.jsxs)(`p`,{className:`mt-1 break-all text-label text-ink3`,children:[`Command: `,(0,h.jsx)(`code`,{children:y})]}),g?(0,h.jsx)(`p`,{className:`mt-2 text-label text-ink3`,children:`Runs on your host using its existing CLI login. Rerun the Docker launcher after changing CLI installations.`}):(0,h.jsxs)(`form`,{className:`mt-3`,onSubmit:e=>{e.preventDefault(),S.isPending||S.mutate(b)},children:[(0,h.jsx)(oM,{htmlFor:a,id:o,className:`mb-[5px]`,children:`Executable path`}),(0,h.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,h.jsx)(cM,{id:a,autoComplete:`off`,spellCheck:!1,maxLength:4096,"aria-labelledby":`${i} ${o}`,"aria-invalid":S.error!==null,"aria-describedby":`${s}${S.error?` ${c}`:``}`,placeholder:v,value:b,disabled:S.isPending,onChange:e=>{u(e.target.value),f(!1),S.reset()}}),(0,h.jsx)(B,{type:`submit`,"aria-label":`Save ${e.displayName} path`,disabled:S.isPending,children:S.isPending?`Checking…`:`Save path`}),d?(0,h.jsx)(eM,{}):null]}),(0,h.jsxs)(`p`,{id:s,className:`mt-1 text-label text-ink3`,children:[`Leave blank to find `,(0,h.jsx)(`code`,{children:v}),` on PATH. Use an absolute path without quotes or arguments.`]}),S.error?(0,h.jsx)(`p`,{id:c,role:`alert`,className:`mt-1 text-label text-red`,children:S.error.message}):null]}),(0,h.jsxs)(`p`,{className:`mt-2 text-label text-ink3`,children:[`Sign in through `,e.displayName,` itself before generating; Slopify uses that login.`,e.id===`codex-image`?` Executable path and login are shared with Codex text generation.`:null]})]})]})}function m2(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 h2=[`llm`,`tts`,`image`],g2={llm:`API keys · LLM`,tts:`API keys · Text to speech`,image:`API keys · Image generation`},_2=`••••••••••••`,v2=`grid grid-cols-[140px_1fr_auto] items-end gap-[14px] border-t border-line px-4 py-[14px] first:border-t-0`,y2=`engraved border-t border-line px-4 py-3 text-ink3 first:border-t-0`;function b2(){let{api:e}=I(),t=nt(vy(e));if(t.error!==null)return(0,h.jsx)(Pj,{children:(0,h.jsx)(Fj,{children:(0,h.jsx)(`p`,{className:`text-body text-red`,children:t.error.message})})});if(t.data===void 0)return(0,h.jsx)(S2,{});let n=t.data.providers,r=n.every(e=>e.readiness.kind!==`keyed`||!e.readiness.hasKey);return(0,h.jsx)(Pj,{children:h2.map(e=>(0,h.jsxs)(`section`,{"data-tour":`keys-${e}`,className:`border-t border-line first:border-t-0`,children:[(0,h.jsx)(`h2`,{className:y2,children:g2[e]}),n.filter(t=>t.family===e).map(e=>e.readiness.kind===`cli`?(0,h.jsx)(p2,{provider:e,readiness:e.readiness},e.id):(0,h.jsx)(x2,{provider:e,hasKey:e.readiness.hasKey},e.id)),e===`llm`&&r?(0,h.jsx)(`p`,{className:`border-t border-line px-4 pt-[10px] pb-[14px] text-small text-ink2`,children:`Paste a key to make its provider selectable on Play.`}):null]},e))})}function x2({provider:e,hasKey:t}){let{api:n}=I(),r=_(),i=(0,m.useId)(),a=(0,m.useId)(),o=(0,m.useId)(),s=(0,m.useId)(),c=(0,m.useId)(),[l,u]=(0,m.useState)(``),[d,f]=(0,m.useState)(!1),[p,g]=(0,m.useState)(!1),[v,y]=(0,m.useState)(void 0),[b,x]=(0,m.useState)(!1),S=async()=>{f(!0),y(void 0);try{await bo(n,e.id,l),u(``),g(!0),await r.invalidateQueries({queryKey:V.providers})}catch(e){y(e instanceof Error?e.message:String(e))}finally{f(!1)}},C=it({mutationFn:()=>So(n,e.id),onSuccess:async()=>{x(!1),y(void 0),await r.invalidateQueries({queryKey:V.providers})},onError:e=>{x(!1),y(e.message)}});(0,m.useEffect)(()=>{if(!p)return;let e=setTimeout(()=>{g(!1)},Qj);return()=>{clearTimeout(e)}},[p]);let w=[t?s:void 0,v===void 0?void 0:c].filter(e=>e!==void 0).join(` `);return(0,h.jsxs)(`div`,{"data-ready":t,className:v2,children:[(0,h.jsx)(`span`,{id:o,className:`pb-[7px] font-semibold`,children:e.displayName}),(0,h.jsxs)(`div`,{children:[(0,h.jsx)(oM,{htmlFor:i,id:a,className:`mb-[5px]`,children:`API key`}),(0,h.jsx)(cM,{id:i,type:`password`,autoComplete:`off`,spellCheck:!1,"aria-labelledby":`${o} ${a}`,"aria-invalid":v!==void 0,"aria-describedby":w===``?void 0:w,placeholder:t?_2:void 0,value:l,onChange:e=>{u(e.target.value)}}),e.id===`inworld`?(0,h.jsx)(`p`,{className:`mt-1 text-label text-ink3`,children:`Paste the Base64 credentials from Inworld Settings → API Keys.`}):null,t?(0,h.jsx)(`span`,{id:s,className:`sr-only`,children:`A key is stored for this provider.`}):null,v===void 0?null:(0,h.jsx)(`p`,{id:c,className:`mt-1 text-label text-red`,children:v})]}),(0,h.jsxs)(`div`,{className:`flex min-h-8 items-center gap-2`,children:[(0,h.jsx)(B,{"aria-label":`Save ${e.displayName} key`,disabled:l.trim()===``||d,onClick:()=>{S()},children:`Save`}),p?(0,h.jsx)(eM,{}):null,t?(0,h.jsx)(B,{className:`bg-transparent`,"aria-label":`Remove ${e.displayName} key`,onClick:()=>{x(!0)},children:`Remove`}):null]}),(0,h.jsx)(Nj,{open:b,title:`Remove the ${e.displayName} key?`,consequence:`Projects that used this provider cannot retry until a key is saved.`,verb:`Remove`,pending:C.isPending,onConfirm:()=>{C.mutate()},onCancel:()=>{x(!1)}})]})}function S2(){return(0,h.jsx)(Pj,{children:[0,1,2,3].map(e=>(0,h.jsxs)(Fj,{children:[(0,h.jsx)(`span`,{className:`h-4 w-28 rounded-control bg-panel2`}),(0,h.jsx)(`span`,{className:`h-8 flex-1 rounded-control bg-panel2`})]},e))})}var C2=ev,w2=iv;function T2({className:e,children:t,...n}){return(0,h.jsxs)(nv,{"data-slot":`select-trigger`,className:z(`flex h-8 w-full items-center justify-between gap-2 rounded-control border border-line2`,`bg-panel2 px-[10px] text-left text-small text-ink data-[placeholder]:text-ink3`,e),...n,children:[t,(0,h.jsx)(av,{asChild:!0,children:(0,h.jsx)(JA,{"aria-hidden":`true`,className:`size-[14px] shrink-0 text-ink2`})})]})}function E2({className:e,children:t,position:n=`popper`,...r}){return(0,h.jsx)(cv,{children:(0,h.jsx)(uv,{"data-slot":`select-content`,position:n,sideOffset:4,className:z(`z-50 min-w-[var(--radix-select-trigger-width)] overflow-hidden rounded-panel`,`border border-line bg-panel p-1 shadow-[0_8px_24px_var(--color-shadow)]`,e),...r,children:(0,h.jsx)(Sv,{children:t})})})}function D2({className:e,children:t,...n}){return(0,h.jsxs)(Ov,{"data-slot":`select-item`,className:z(`relative flex cursor-default items-center rounded-control py-[5px] pr-8 pl-[10px]`,`text-small text-ink outline-hidden select-none`,`focus:bg-panel2 data-highlighted:bg-panel2`,e),...n,children:[(0,h.jsx)(Av,{children:t}),(0,h.jsx)(Mv,{className:`absolute right-[10px] flex items-center`,children:(0,h.jsx)(qA,{"aria-hidden":`true`,className:`size-[14px] text-done`})})]})}var O2=`px-4 align-top`;function k2(){let{api:e}=I(),t=_(),n=nt(yy(e)),r=nt(vy(e)),[i,a]=(0,m.useState)(void 0),o=it({mutationFn:t=>Do(e,t),onSettled:async()=>{a(void 0),await t.invalidateQueries({queryKey:V.voices})}}),s=(r.data?.providers??[]).filter(e=>e.family===`tts`);if(n.error!==null)return(0,h.jsx)(Pj,{children:(0,h.jsx)(Fj,{children:(0,h.jsx)(`p`,{className:`text-body text-red`,children:n.error.message})})});let c=n.data?.voices;return(0,h.jsxs)(Pj,{"data-tour":`voices`,children:[(0,h.jsxs)(`table`,{className:`w-full table-fixed border-collapse text-small`,children:[(0,h.jsx)(`thead`,{children:(0,h.jsxs)(`tr`,{className:`border-b border-line`,children:[(0,h.jsx)(`th`,{className:z(O2,`engraved w-[26%] py-3 text-left text-ink3`),children:`Voices · Name`}),(0,h.jsx)(`th`,{className:z(O2,`engraved w-[26%] py-3 text-left text-ink3`),children:`Provider`}),(0,h.jsx)(`th`,{className:z(O2,`engraved py-3 text-left text-ink3`),children:`Voice ID`}),(0,h.jsx)(`th`,{className:z(O2,`w-[104px] py-3`),children:(0,h.jsx)(`span`,{className:`sr-only`,children:`Remove`})})]})}),(0,h.jsx)(`tbody`,{children:c===void 0?(0,h.jsx)(`tr`,{className:`border-b border-line`,children:(0,h.jsx)(`td`,{colSpan:4,className:z(O2,`py-4`),children:(0,h.jsx)(`span`,{className:`block h-4 w-64 rounded-control bg-panel2`})})}):c.length===0?(0,h.jsx)(`tr`,{className:`border-b border-line`,children:(0,h.jsx)(`td`,{colSpan:4,className:z(O2,`py-4 text-ink2`),children:`Add a voice ID from your text-to-speech provider. Audio needs one to narrate.`})}):c.map(e=>(0,h.jsxs)(`tr`,{className:`border-b border-line`,children:[(0,h.jsx)(`td`,{className:z(O2,`py-3 font-semibold`),children:e.name}),(0,h.jsx)(`td`,{className:z(O2,`py-3 text-ink2`),children:M2(s,e.provider)}),(0,h.jsx)(`td`,{className:z(O2,`py-3 text-ink2 tabular-nums`),children:e.voiceId}),(0,h.jsx)(`td`,{className:z(O2,`py-3 text-right`),children:(0,h.jsx)(B,{className:`bg-transparent`,"aria-label":`Remove ${e.name}`,onClick:()=>{a(e)},children:`Remove`})})]},e.id))}),(0,h.jsx)(`tfoot`,{children:(0,h.jsx)(A2,{tts:s})})]}),o.error===null?null:(0,h.jsx)(`p`,{className:`border-t border-line px-4 py-3 text-label text-red`,children:o.error.message}),(0,h.jsx)(Nj,{open:i!==void 0,title:i===void 0?``:`Remove ${i.name}?`,consequence:`Projects that used this voice keep the audio they made with it.`,verb:`Remove`,pending:o.isPending,onConfirm:()=>{i!==void 0&&o.mutate(i.id)},onCancel:()=>{a(void 0)}})]})}function A2({tts:e}){let{api:t}=I(),n=_(),r=(0,m.useId)(),i=(0,m.useId)(),a=(0,m.useId)(),o=(0,m.useId)(),s=(0,m.useId)(),[c,l]=(0,m.useState)(``),[u,d]=(0,m.useState)(``),[f,p]=(0,m.useState)(void 0),[g,v]=(0,m.useState)(void 0),y=f??e[0]?.id,b=it({mutationFn:e=>Eo(t,e),onSuccess:async e=>{if(!e.ok){v(e.refusal);return}l(``),d(``),v(void 0),await n.invalidateQueries({queryKey:V.voices})}}),x=(e,t)=>{t(),g?.field===e&&v(void 0)},S=e=>g?.field===e?g.message:void 0;return(0,h.jsxs)(`tr`,{children:[(0,h.jsxs)(`td`,{className:z(O2,`py-[14px]`),children:[(0,h.jsx)(oM,{htmlFor:r,className:`mb-[5px]`,children:`Voice name`}),(0,h.jsx)(cM,{id:r,value:c,"aria-invalid":S(`name`)!==void 0,onChange:e=>{let t=e.target.value;x(`name`,()=>{l(t)})}}),(0,h.jsx)(j2,{id:`${s}-name`,message:S(`name`)})]}),(0,h.jsxs)(`td`,{className:z(O2,`py-[14px]`),children:[(0,h.jsx)(oM,{id:a,className:`mb-[5px]`,children:`Provider`}),(0,h.jsxs)(C2,{value:y??``,onValueChange:t=>{let n=e.find(e=>e.id===t);n!==void 0&&x(`provider`,()=>{p(n.id)})},children:[(0,h.jsx)(T2,{id:i,"aria-labelledby":`${a} ${i}`,children:(0,h.jsx)(w2,{placeholder:`Pick a provider`})}),(0,h.jsx)(E2,{children:e.map(e=>(0,h.jsx)(D2,{value:e.id,children:e.displayName},e.id))})]}),(0,h.jsx)(j2,{id:`${s}-provider`,message:S(`provider`)})]}),(0,h.jsxs)(`td`,{className:z(O2,`py-[14px]`),children:[(0,h.jsx)(oM,{htmlFor:o,className:`mb-[5px]`,children:`Voice ID`}),(0,h.jsx)(cM,{id:o,className:`tabular-nums`,value:u,"aria-invalid":S(`voiceId`)!==void 0,"aria-describedby":S(`voiceId`)===void 0?void 0:`${s}-voiceId`,onChange:e=>{let t=e.target.value;x(`voiceId`,()=>{d(t)})}}),(0,h.jsx)(j2,{id:`${s}-voiceId`,message:S(`voiceId`)}),y===`inworld`?(0,h.jsx)(`p`,{className:`mt-1 text-label text-ink3`,children:`Use an Inworld voice ID, such as Dennis, or one from your workspace.`}):null,b.error===null?null:(0,h.jsx)(`p`,{className:`mt-1 text-label text-red`,children:b.error.message})]}),(0,h.jsx)(`td`,{className:z(O2,`py-[14px] text-right`),children:(0,h.jsx)(B,{className:`mt-[22px]`,disabled:y===void 0||g!==void 0||b.isPending,onClick:()=>{y!==void 0&&b.mutate({provider:y,name:c,voiceId:u})},children:`Add voice`})})]})}function j2({id:e,message:t}){return t===void 0?null:(0,h.jsx)(`p`,{id:e,className:`mt-1 text-label text-red`,children:t})}function M2(e,t){return e.find(e=>e.id===t)?.displayName??t}var N2=[`storage-usage`],P2=[N2,V.settings,V.providers,V.voices,V.prompts,V.entries,V.staging,lq,UO,[`provider-models`]];async function F2(e){await Promise.all(P2.map(t=>e.invalidateQueries({queryKey:t})))}var I2=30,L2=[{value:`system`,label:`System`},{value:`dark`,label:`Dark`},{value:`light`,label:`Light`}];function R2(e){let t=e.trim();return/^\d+$/.test(t)&&Number(t)>=0&&Number(t)<=I2?void 0:`The silence gap is a whole number of seconds between 0 and ${String(I2)}.`}function z2(){let{api:e}=I();return(0,h.jsxs)(`div`,{className:`flex max-w-[1100px] flex-col gap-6`,children:[(0,h.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`h1`,{className:`text-title font-bold tracking-[-0.01em]`,children:`Settings`}),(0,h.jsx)(`p`,{className:`mt-1 text-small text-ink2`,children:`Provider readiness is checked again before each run.`})]}),(0,h.jsx)(B,{asChild:!0,variant:`ghost`,children:(0,h.jsx)(`a`,{href:`${e.origin}/api/diagnostics`,download:`slopify-diagnostics.json`,children:`Download diagnostics`})})]}),(0,h.jsx)(b2,{}),(0,h.jsx)(k2,{}),(0,h.jsx)(f2,{}),(0,h.jsx)(H2,{}),(0,h.jsx)(B2,{})]})}function B2(){let{api:e}=I(),t=_(),n=nt({queryKey:N2,queryFn:()=>fo(e),staleTime:3e4}),[r,i]=(0,m.useState)(!1),[a,o]=(0,m.useState)(null),[s,c]=(0,m.useState)(null);async function l(n){if(n.size===0||n.size>104857600){o(null),c(`The backup must be between 1 byte and 100 MB.`);return}i(!0),c(null),o(null);try{let r=await e.fetch(`${e.origin}/api/storage/import`,{method:`PUT`,headers:{"content-type":`application/zip`},body:n}),i=await r.json();if(!r.ok)throw Error(i.detail??`The backup could not be imported.`);o(`Imported ${i.templates??0} template(s), ${i.fonts??0} uploaded font(s), and ${i.stagedFiles??0} staged file(s).${i.fontFallbacks?` ${i.fontFallbacks} missing legacy font reference(s) now use the default font.`:``}`),await F2(t)}catch(e){c(e instanceof Error?e.message:`The backup could not be imported.`)}finally{i(!1)}}async function u(){i(!0),c(null),o(null);try{let n=await e.fetch(`${e.origin}/api/storage/cleanup`,{method:`POST`}),r=await n.json();if(!n.ok)throw Error(`Storage cleanup could not finish.`);o(`Removed ${r.orphanFiles??0} orphan project file(s) and ${r.stagedFiles??0} stale staged file(s).`),await t.invalidateQueries({queryKey:N2})}catch(e){c(e instanceof Error?e.message:`Storage cleanup could not finish.`)}finally{i(!1)}}return(0,h.jsxs)(`section`,{"aria-labelledby":`storage-tools-heading`,className:`rounded-panel border border-line bg-panel p-4`,children:[(0,h.jsx)(`h2`,{id:`storage-tools-heading`,className:`font-semibold`,children:`Backup and storage`}),(0,h.jsx)(`p`,{className:`mt-1 max-w-[70ch] text-small text-ink2`,children:`Backups include templates, prompts, voices, settings and staged assets. Provider keys and telemetry are never included. Existing projects and their retained revisions stay untouched when a backup is imported.`}),(0,h.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,h.jsx)(B,{asChild:!0,disabled:r,children:(0,h.jsx)(`a`,{href:`${e.origin}/api/storage/export`,download:`slopify-backup.zip`,children:`Export backup`})}),(0,h.jsxs)(`label`,{className:`inline-flex h-8 cursor-pointer items-center rounded-control border border-line2 bg-panel2 px-3 text-body hover:border-ink3`,children:[`Import backup`,(0,h.jsx)(`input`,{className:`sr-only`,type:`file`,accept:`application/zip,.zip`,disabled:r,onChange:e=>{let t=e.target.files?.[0];t&&l(t),e.target.value=``}})]}),(0,h.jsx)(B,{type:`button`,variant:`ghost`,disabled:r,onClick:()=>void u(),children:`Clean orphan files`})]}),n.data?(0,h.jsxs)(`div`,{className:`mt-4 border-t border-line pt-3 text-small text-ink2`,children:[(0,h.jsxs)(`p`,{children:[V2(n.data.data),` stored · `,V2(n.data.projects),` project files · `,V2(n.data.staging),` staged files`]}),n.data.byProject.length>0?(0,h.jsx)(`ul`,{className:`mt-2 space-y-1`,"aria-label":`Storage by project`,children:n.data.byProject.slice(0,5).map(e=>(0,h.jsxs)(`li`,{className:`flex justify-between gap-4`,children:[(0,h.jsx)(`span`,{className:`truncate`,children:e.title}),(0,h.jsx)(`span`,{className:`shrink-0 tabular-nums`,children:V2(e.bytes)})]},e.id))}):null]}):n.error?(0,h.jsx)(`p`,{className:`mt-3 text-small text-ink2`,children:`Storage usage is unavailable.`}):null,a?(0,h.jsx)(`p`,{role:`status`,className:`mt-2 text-small text-lamp-run`,children:a}):null,s?(0,h.jsx)(`p`,{role:`alert`,className:`mt-2 text-small text-red`,children:s}):null]})}function V2(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}`}function H2(){let{api:e}=I(),t=_(),n=nt(Sy(e)),r=(0,m.useId)(),i=(0,m.useId)(),a=(0,m.useId)(),[o,s]=(0,m.useState)(void 0),[c,l]=(0,m.useState)(!1),u=it({mutationFn:t=>wo(e,t),onMutate:e=>{let n=t.getQueryData(V.settings);return t.setQueryData(V.settings,e),{previous:n}},onError:(e,n,r)=>{r?.previous!==void 0&&t.setQueryData(V.settings,r.previous)},onSuccess:e=>{t.setQueryData(V.settings,e)}});if((0,m.useEffect)(()=>{if(!c)return;let e=setTimeout(()=>{l(!1)},Qj);return()=>{clearTimeout(e)}},[c]),n.error!==null)return(0,h.jsx)(Pj,{children:(0,h.jsx)(Fj,{children:(0,h.jsx)(`p`,{className:`text-body text-red`,children:n.error.message})})});if(n.data===void 0)return(0,h.jsxs)(Pj,{children:[(0,h.jsx)(`h2`,{className:`engraved border-b border-line px-4 py-3 text-ink3`,children:`Playback`}),(0,h.jsxs)(Fj,{children:[(0,h.jsx)(`span`,{className:`h-4 w-48 rounded-control bg-panel2`}),(0,h.jsx)(`span`,{className:`h-8 w-[72px] rounded-control bg-panel2`})]})]});let d=n.data,f=o??String(d.silenceGapSeconds),p=R2(f);return(0,h.jsxs)(Pj,{children:[(0,h.jsx)(`h2`,{className:`engraved border-b border-line px-4 py-3 text-ink3`,children:`Playback`}),(0,h.jsxs)(`div`,{className:`grid grid-cols-[240px_1fr] items-center gap-[14px] border-b border-line px-4 py-[14px]`,children:[(0,h.jsx)(`label`,{htmlFor:r,className:`font-semibold`,children:`Silence between segments`}),(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-[10px]`,children:[(0,h.jsx)(cM,{id:r,type:`number`,inputMode:`numeric`,min:0,max:I2,step:1,className:`w-[72px] tabular-nums`,value:f,"aria-invalid":p!==void 0,"aria-describedby":p===void 0?void 0:i,onChange:e=>{s(e.target.value)}}),(0,h.jsx)(`span`,{className:`text-small text-ink2`,children:`seconds`}),(0,h.jsx)(B,{className:`ml-[6px]`,disabled:p!==void 0||u.isPending,onClick:()=>{l(!1),u.mutate({silenceGapSeconds:Number(f.trim()),appearance:d.appearance},{onSuccess:()=>{s(void 0),l(!0)}})},children:`Save`}),c?(0,h.jsx)(eM,{}):null,p===void 0?null:(0,h.jsx)(`p`,{id:i,className:`basis-full text-label text-red`,children:p}),u.error===null?null:(0,h.jsx)(`p`,{className:`basis-full text-label text-red`,children:u.error.message})]})]}),(0,h.jsxs)(`div`,{className:`grid grid-cols-[240px_1fr] items-center gap-[14px] px-4 py-[14px]`,children:[(0,h.jsx)(`span`,{id:a,className:`font-semibold`,children:`Appearance`}),(0,h.jsx)(Hj,{type:`single`,value:d.appearance,"aria-labelledby":a,className:`justify-self-start`,onValueChange:e=>{let t=L2.find(t=>t.value===e);t!==void 0&&u.mutate({silenceGapSeconds:d.silenceGapSeconds,appearance:t.value})},children:L2.map(e=>(0,h.jsx)(Uj,{value:e.value,children:e.label},e.value))})]})]})}function U2({onApplied:e,beforeApply:t,getGeneration:n,blocked:r=!1}){let{api:i}=I(),a=_(),o=nt(mq(i)),s=nt({queryKey:[`play-drafts`],queryFn:async()=>{let e=await NO(i);if(!e.ok)throw Error(e.message);return e.value.drafts}}),[c,l]=(0,m.useState)(``),[u,d]=(0,m.useState)(``),[f,p]=(0,m.useState)(!1),[g,v]=(0,m.useState)(null),[y,b]=(0,m.useState)(null),[x,S]=(0,m.useState)(null),C=(0,m.useRef)(!1),w=(0,m.useRef)(null),T=(0,m.useRef)(new Map),E=(0,m.useRef)(!0);(0,m.useEffect)(()=>(E.current=!0,()=>{E.current=!1}),[]);async function D(e){if(!C.current){C.current=!0,p(!0),v(null),b(null);try{await e()}catch(e){v(e instanceof Error?e.message:`The template action could not finish.`)}finally{C.current=!1,p(!1)}}}async function O(){let e=await FO(i,c);if(!e.ok)throw Error(e.message);let t=JSON.stringify([c,e.value.draft.version,u.trim()]);w.current?.key!==t&&(w.current={key:t,id:crypto.randomUUID()});let n=await hq(i,{id:w.current.id,name:u.trim(),document:e.value.draft.document});if(!n.ok)throw w.current=null,Error(n.message);w.current=null,d(``),b(`Template saved.`),await a.invalidateQueries({queryKey:lq})}async function ee(o){let s=n?.();if(r||t&&!await t())throw Error(`Resolve the current Play draft before applying a template.`);if(!E.current||s!==void 0&&s!==n?.())return;let c=`${o.id}:${o.version}`,l=T.current.get(c);l||(l=crypto.randomUUID(),T.current.set(c,l));let u=await vq(i,o,l);if(!u.ok)throw T.current.delete(c),Error(u.message);if(!(!E.current||s!==void 0&&s!==n?.())&&(await a.invalidateQueries({queryKey:[`play-drafts`]}),!(!E.current||s!==void 0&&s!==n?.()))){if(await e(u.value.draft.id,()=>E.current)!==!1)T.current.delete(c);else throw Error(`The new template draft could not be opened. Try again.`)}}async function k(){if(!x)return;let e=x.id,t=await _q(i,x);if(!t.ok)throw Error(t.message);S(null),await a.cancelQueries({queryKey:lq}),a.setQueryData(lq,t=>t?.filter(t=>t.id!==e)),b(`Template deleted.`),await a.invalidateQueries({queryKey:lq})}return(0,h.jsxs)(`div`,{className:`mx-auto max-w-[1440px] space-y-6`,children:[(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`h1`,{className:`text-title font-bold tracking-[-0.01em]`,children:`Templates`}),(0,h.jsx)(`p`,{className:`mt-2 text-body text-ink2`,children:`Reuse a Play setup and its checkpoint choices. Apply creates a fresh draft for review before you start.`})]}),(0,h.jsxs)(`section`,{"aria-labelledby":`save-template-heading`,className:`max-w-2xl space-y-3 rounded-panel border border-line bg-panel p-4`,children:[(0,h.jsx)(`h2`,{id:`save-template-heading`,className:`font-semibold`,children:`Save a setup`}),(0,h.jsxs)(`p`,{className:`text-small text-ink2`,children:[`Choose a saved Play draft, or`,` `,(0,h.jsx)(sa,{to:`/play`,className:`underline`,children:`open Play`}),` `,`to prepare one.`]}),(0,h.jsxs)(`form`,{className:`space-y-3`,onSubmit:e=>{e.preventDefault(),c&&u.trim()&&D(O)},children:[(0,h.jsxs)(`label`,{className:`block space-y-1`,children:[(0,h.jsx)(`span`,{children:`Saved Play draft`}),(0,h.jsxs)(`select`,{className:`h-10 w-full rounded-control border border-line2 bg-panel2 px-2`,value:c,required:!0,disabled:f,onChange:e=>l(e.target.value),children:[(0,h.jsx)(`option`,{value:``,children:`Choose a draft`}),s.data?.filter(e=>e.readable).map(e=>(0,h.jsx)(`option`,{value:e.id,children:e.title||`Untitled draft`},e.id))]})]}),(0,h.jsxs)(`label`,{className:`block space-y-1`,htmlFor:`template-name`,children:[(0,h.jsx)(`span`,{children:`Template name`}),(0,h.jsx)(cM,{id:`template-name`,value:u,required:!0,maxLength:120,disabled:f,onChange:e=>d(e.target.value)})]}),(0,h.jsx)(B,{type:`submit`,disabled:f||!c||!u.trim(),children:`Save template`})]}),s.isPending?(0,h.jsx)(`p`,{role:`status`,children:`Loading saved drafts…`}):null,s.data?.length===0?(0,h.jsx)(`p`,{children:`No saved drafts yet.`}):null,s.error?(0,h.jsxs)(`p`,{role:`alert`,children:[s.error.message,` `,(0,h.jsx)(B,{type:`button`,onClick:()=>void s.refetch(),children:`Reload drafts`})]}):null]}),r?(0,h.jsx)(`p`,{role:`status`,children:`Resolve the pending Start in Play before applying a template.`}):null,g&&!x?(0,h.jsx)(`p`,{role:`alert`,className:`text-red`,children:g}):null,y?(0,h.jsx)(`p`,{role:`status`,children:y}):null,o.isPending?(0,h.jsx)(`p`,{role:`status`,children:`Loading templates…`}):null,o.error?(0,h.jsxs)(`p`,{role:`alert`,children:[o.error.message,` `,(0,h.jsx)(B,{type:`button`,onClick:()=>void o.refetch(),children:`Reload templates`})]}):null,o.data?.length===0?(0,h.jsx)(`p`,{children:`No templates yet. Save a Play draft above to reuse its setup.`}):null,(0,h.jsx)(B,{type:`button`,variant:`ghost`,disabled:f||o.isFetching,onClick:()=>void o.refetch(),children:`Refresh templates`}),(0,h.jsx)(`ul`,{className:`space-y-3`,"aria-label":`Project templates`,children:o.data?.map(e=>(0,h.jsxs)(`li`,{className:`flex flex-wrap items-center justify-between gap-4 rounded-panel border border-line bg-panel p-4`,children:[(0,h.jsxs)(`div`,{className:`min-w-0`,children:[(0,h.jsx)(`h2`,{className:`break-words font-semibold`,children:e.name}),(0,h.jsxs)(`p`,{className:`text-small text-ink3`,children:[`Version `,e.version,` · Updated`,` `,(0,h.jsx)(`time`,{dateTime:e.updatedAt,children:e.updatedAt.slice(0,10)})]})]}),(0,h.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,h.jsx)(B,{type:`button`,"aria-label":`Apply ${e.name}`,disabled:f||r,onClick:()=>void D(()=>ee(e)),children:`Apply to Play`}),(0,h.jsx)(B,{type:`button`,variant:`ghost`,"aria-label":`Delete ${e.name}`,disabled:f,onClick:()=>{S(e),v(null)},children:`Delete`})]})]},e.id))}),(0,h.jsx)(Nj,{open:x!==null,title:`Delete ${x?.name??`template`}?`,consequence:g??`Existing projects and drafts keep their setup.`,verb:`Delete template`,pending:f,onConfirm:()=>void D(k),onCancel:()=>{f||S(null)}})]})}function W2({counters:e}){return(0,h.jsx)(`dl`,{className:`m-0 grid grid-cols-2 overflow-hidden rounded-panel border border-line bg-panel md:grid-cols-5`,children:e.map(e=>(0,h.jsxs)(`div`,{className:`-ml-px flex flex-col-reverse gap-2 border-l border-line p-[18px]`,children:[(0,h.jsx)(`dt`,{className:`engraved text-ink3`,children:e.label}),(0,h.jsx)(`dd`,{className:`m-0 text-counter font-bold tabular-nums tracking-[-0.01em]`,children:e.value})]},e.label))})}function G2({cells:e}){return(0,h.jsx)(`div`,{className:`grid grid-cols-2 overflow-hidden rounded-panel border border-line bg-panel md:grid-cols-5`,children:Array.from({length:e},(e,t)=>t).map(e=>(0,h.jsxs)(`div`,{className:`-ml-px flex flex-col gap-2 border-l border-line p-[18px]`,children:[(0,h.jsx)(`span`,{className:`h-8 w-20 rounded-control bg-panel2`}),(0,h.jsx)(`span`,{className:`h-3 w-24 rounded-control bg-panel2`})]},e))})}function K2(){let{api:e}=I(),t=nt(_y(e));return(0,h.jsxs)(`div`,{className:`flex max-w-[1100px] flex-col gap-6`,children:[(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`h1`,{className:`mb-1 text-title font-bold tracking-[-0.01em]`,children:`Usage`}),(0,h.jsx)(`p`,{className:`text-body text-ink2`,children:`This machine only. The same counters, anonymised, feed slopify.stream.`})]}),t.error===null?null:(0,h.jsx)(Pj,{children:(0,h.jsx)(`p`,{className:`px-4 py-[14px] text-body text-red`,children:t.error.message})}),t.data===void 0?t.error===null?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(G2,{cells:5}),(0,h.jsx)(t4,{})]}):null:(0,h.jsx)(q2,{usage:t.data})]})}function q2({usage:e}){let t=Object.values(e.counters).every(e=>e===0);return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(W2,{counters:e4(e)}),t?(0,h.jsx)(`p`,{className:`-mt-3 text-body text-ink2`,children:`Numbers appear after your first run.`}):null,(0,h.jsxs)(`div`,{className:`overflow-hidden rounded-panel border border-line bg-panel`,children:[(0,h.jsxs)(`table`,{"aria-label":`Tokens by stage`,className:`w-full table-fixed border-collapse`,children:[(0,h.jsx)(`thead`,{children:(0,h.jsxs)(`tr`,{className:`border-b border-line`,children:[(0,h.jsx)(J2,{className:`w-[24%]`,children:`Tokens by stage`}),(0,h.jsx)(J2,{className:`w-[38%]`,children:`Provider · model`}),(0,h.jsx)(J2,{className:`w-[19%] text-right`,children:`Tokens in`}),(0,h.jsx)(J2,{className:`w-[19%] text-right`,children:`Tokens out`})]})}),(0,h.jsx)(`tbody`,{children:e.byStage.map(e=>(0,h.jsxs)(`tr`,{className:`border-b border-line last:border-b-0`,children:[(0,h.jsx)(Y2,{className:`truncate font-semibold`,children:zk[e.stage]}),(0,h.jsx)(Y2,{className:`truncate text-ink2`,children:X2(e)}),(0,h.jsx)(Y2,{className:`text-right tabular-nums`,children:Z2.format(e.tokensIn)}),(0,h.jsx)(Y2,{className:`text-right tabular-nums`,children:Z2.format(e.tokensOut)})]},`${e.stage}/${e.provider}/${e.model??``}`))})]}),e.byStage.length===0?(0,h.jsx)(`p`,{className:`px-4 py-5 text-small text-ink3`,children:`No stages have run yet.`}):null]}),(0,h.jsx)(`p`,{className:`engraved text-ink3`,children:`Machine ID ${e.machineId??`not made yet`} · Slopify ${e.appVersion}`})]})}function J2({children:e,className:t}){return(0,h.jsx)(`th`,{className:`engraved px-4 py-3 text-left text-ink3 ${t}`,children:e})}function Y2({children:e,className:t}){return(0,h.jsx)(`td`,{className:`px-4 py-3 align-top text-small ${t}`,children:e})}function X2(e){return e.model===null?e.provider:`${e.provider} · ${e.model}`}var Z2=new Intl.NumberFormat(void 0,{maximumFractionDigits:0}),Q2=new Intl.NumberFormat(void 0,{maximumFractionDigits:1}),$2=new Intl.NumberFormat(void 0,{notation:`compact`,maximumFractionDigits:1});function e4(e){let t=e.counters;return[{label:`Videos made`,value:Z2.format(t.videosMade)},{label:`Hours of audio`,value:Q2.format(t.audioSeconds/3600)},{label:`Images made`,value:Z2.format(t.imagesMade)},{label:`Tokens used`,value:t.tokensUsed<1e6?Z2.format(t.tokensUsed):$2.format(t.tokensUsed)},{label:`Projects`,value:Z2.format(t.projects)}]}function t4(){return(0,h.jsx)(Pj,{children:[0,1,2,3].map(e=>(0,h.jsxs)(`div`,{className:`flex items-center gap-[14px] border-b border-line px-4 py-3 last:border-b-0`,children:[(0,h.jsx)(`span`,{className:`h-3 w-24 rounded-control bg-panel2`}),(0,h.jsx)(`span`,{className:`h-3 w-56 rounded-control bg-panel2`}),(0,h.jsx)(`span`,{className:`ml-auto h-3 w-20 rounded-control bg-panel2`}),(0,h.jsx)(`span`,{className:`h-3 w-20 rounded-control bg-panel2`})]},e))})}var n4=da({component:xj}),r4=la({getParentRoute:()=>n4,path:`/`,component:Xq}),i4=la({getParentRoute:()=>n4,path:`play`,component:_P}),a4=la({getParentRoute:()=>n4,path:`templates`,component:s4}),o4=la({getParentRoute:()=>n4,path:`schedules`,component:u2});function s4(){let e=Ek(),t=Gi();return(0,h.jsx)(U2,{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 c4=la({getParentRoute:()=>n4,path:`projects/$projectId`,component:_4}),l4=la({getParentRoute:()=>n4,path:`prompts`,validateSearch:e=>({kind:Mj(e.kind)}),component:v4}),u4=la({getParentRoute:()=>n4,path:`prompts/new`,validateSearch:e=>{let t=Mj(e.kind);return typeof e.from==`string`?{kind:t,from:e.from}:{kind:t}},component:y4}),d4=la({getParentRoute:()=>n4,path:`prompts/$promptId`,component:b4}),f4=la({getParentRoute:()=>n4,path:`entries`,validateSearch:e=>({category:kj(e.category)}),component:S4}),p4=la({getParentRoute:()=>n4,path:`entries/new`,validateSearch:e=>{let t=kj(e.category);return typeof e.from==`string`?{category:t,from:e.from}:{category:t}},component:C4}),m4=la({getParentRoute:()=>n4,path:`entries/$entryId`,component:w4}),h4=la({getParentRoute:()=>n4,path:`settings`,component:z2}),g4=la({getParentRoute:()=>n4,path:`usage`,component:K2});function _4(){let{projectId:e}=c4.useParams();return(0,h.jsx)(Uq,{projectId:e},e)}function v4(){let{kind:e}=l4.useSearch(),t=Gi();return(0,h.jsx)(sJ,{kind:e,onKind:e=>{t({to:`/prompts`,search:{kind:e},replace:!0})}})}function y4(){let{kind:e,from:t}=u4.useSearch(),n=x4();return(0,h.jsx)(nJ,{promptId:void 0,kind:e,from:t,onLeave:n},`${e}:${t??`new`}`)}function b4(){let{promptId:e}=d4.useParams(),t=x4();return(0,h.jsx)(nJ,{promptId:e,kind:`article`,from:void 0,onLeave:t},e)}function x4(){let e=Gi();return t=>{e({to:`/prompts`,search:{kind:t}})}}function S4(){let{category:e}=f4.useSearch(),t=Gi();return(0,h.jsx)(Kj,{category:e,onCategory:e=>{t({to:`/entries`,search:{category:e},replace:!0})}})}function C4(){let{category:e,from:t}=p4.useSearch(),n=T4();return(0,h.jsx)(AM,{entryId:void 0,category:e,from:t,onLeave:n})}function w4(){let{entryId:e}=m4.useParams(),t=T4();return(0,h.jsx)(AM,{entryId:e,category:`intro`,from:void 0,onLeave:t})}function T4(){let e=Gi();return t=>{e({to:`/entries`,search:{category:t}})}}var E4=n4.addChildren({projectsRoute:r4,playRoute:i4,templatesRoute:a4,schedulesRoute:o4,projectRoute:c4,promptsRoute:l4,newPromptRoute:u4,promptRoute:d4,entriesRoute:f4,newEntryRoute:p4,entryRoute:m4,settingsRoute:h4,usageRoute:g4});function D4(){return Oa({routeTree:E4})}function O4(){let e,t,n=new Set;return{observe:r=>{if(e===void 0){e=r;return}if(r!==e&&r!==t){t=r;for(let e of n)e()}},staleAt:()=>t,subscribe:e=>(n.add(e),()=>{n.delete(e)})}}function k4(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 A4(e){let t=O4(),n={api:oo(window.location.origin,k4(window.fetch.bind(window),t)),openEvents:e=>new EventSource(e),version:t};(0,$a.createRoot)(e).render((0,h.jsx)(m.StrictMode,{children:(0,h.jsx)(v,{client:new Ue,children:(0,h.jsx)(Ro,{deps:n,children:(0,h.jsx)(ja,{router:D4()})})})}))}var j4=document.getElementById(`root`);if(j4===null)throw Error(`index.html carries no #root element for the app to mount on`);A4(j4);